blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
9ec764e3cff080d7f794d69c311b4b1d1144b04e
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/h2/1.8/H2O2
e8ba2d61b9e512cd86611eadfae3f8f233ef8852
[]
no_license
labsandy/OpenFOAM_workspace
a74b473903ddbd34b31dc93917e3719bc051e379
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
refs/heads/master
2022-02-25T02:36:04.164324
2019-08-23T02:27:16
2019-08-23T02:27:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
834
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1.8"; object H2O2; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 2.30129e-06; boundaryField { boundary { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
bc10bfd964a180f611eeddb263ea7316ca3acf28
2ed41ec8cf3f270bbbe0bd646873b34e6c4fe9a6
/laomashitu/chapter01.08.03_dll_relocation/chapter01.08.03_dllload/stdafx.cpp
1adc0d7bf1d843ca4a01e8658086e0151c398abd
[]
no_license
LiWeilian/MachineCode
d8a924dc8cbc8e9900f3508499d4a0b6fa530843
169af9386f8000243063cf7447ac1525fc43e8b0
refs/heads/master
2020-04-18T02:24:52.315992
2013-10-22T12:32:25
2013-10-22T12:32:25
13,772,554
1
0
null
null
null
null
GB18030
C++
false
false
275
cpp
// stdafx.cpp : 只包括标准包含文件的源文件 // chapter01.08.03_dllload.pch 将作为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" // TODO: 在 STDAFX.H 中 // 引用任何所需的附加头文件,而不是在此文件中引用
[ "liweilian0822@163.com" ]
liweilian0822@163.com
e34d80c69eb60ded391ed7e763688c84f29b4de6
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_13176.cpp
78a9b1f2c2d7e2731d3f4eca49b2eff77eedc138
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,263
cpp
{ case NONE: break; case GZIP: if (xar->stream_valid) r = inflateReset(&(xar->stream)); else r = inflateInit(&(xar->stream)); if (r != Z_OK) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Couldn't initialize zlib stream."); return (ARCHIVE_FATAL); } xar->stream_valid = 1; xar->stream.total_in = 0; xar->stream.total_out = 0; break; #if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) case BZIP2: if (xar->bzstream_valid) { BZ2_bzDecompressEnd(&(xar->bzstream)); xar->bzstream_valid = 0; } r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 0); if (r == BZ_MEM_ERROR) r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 1); if (r != BZ_OK) { int err = ARCHIVE_ERRNO_MISC; detail = NULL; switch (r) { case BZ_PARAM_ERROR: detail = "invalid setup parameter"; break; case BZ_MEM_ERROR: err = ENOMEM; detail = "out of memory"; break; case BZ_CONFIG_ERROR: detail = "mis-compiled library"; break; } archive_set_error(&a->archive, err, "Internal error initializing decompressor: %s", detail == NULL ? "??" : detail); xar->bzstream_valid = 0; return (ARCHIVE_FATAL); } xar->bzstream_valid = 1; xar->bzstream.total_in_lo32 = 0; xar->bzstream.total_in_hi32 = 0; xar->bzstream.total_out_lo32 = 0; xar->bzstream.total_out_hi32 = 0; break; #endif #if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA) #if LZMA_VERSION_MAJOR >= 5 /* Effectively disable the limiter. */ #define LZMA_MEMLIMIT UINT64_MAX #else /* NOTE: This needs to check memory size which running system has. */ #define LZMA_MEMLIMIT (1U << 30) #endif case XZ: case LZMA: if (xar->lzstream_valid) { lzma_end(&(xar->lzstream)); xar->lzstream_valid = 0; } if (xar->entry_encoding == XZ) r = lzma_stream_decoder(&(xar->lzstream), LZMA_MEMLIMIT,/* memlimit */ LZMA_CONCATENATED); else r = lzma_alone_decoder(&(xar->lzstream), LZMA_MEMLIMIT);/* memlimit */ if (r != LZMA_OK) { switch (r) { case LZMA_MEM_ERROR: archive_set_error(&a->archive, ENOMEM, "Internal error initializing " "compression library: " "Cannot allocate memory"); break; case LZMA_OPTIONS_ERROR: archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Internal error initializing " "compression library: " "Invalid or unsupported options"); break; default: archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Internal error initializing " "lzma library"); break; } return (ARCHIVE_FATAL); } xar->lzstream_valid = 1; xar->lzstream.total_in = 0; xar->lzstream.total_out = 0; break; #endif /* * Unsupported compression. */ default: #if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) case BZIP2: #endif #if !defined(HAVE_LZMA_H) || !defined(HAVE_LIBLZMA) case LZMA: case XZ: #endif switch (xar->entry_encoding) { case BZIP2: detail = "bzip2"; break; case LZMA: detail = "lzma"; break; case XZ: detail = "xz"; break; default: detail = "??"; break; } archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "%s compression not supported on this platform", detail); return (ARCHIVE_FAILED); }
[ "993273596@qq.com" ]
993273596@qq.com
216f0fa83882ca4479e2437c4e6ceebde3be45fb
554c31b8b5c275e77cf7ec553e8e9e1938bad928
/HAPPYPLAYER/Foundation/CustomShadowEffect.h
489b126ec5e374173c6cb1b32af8bf4b31a80baf
[]
no_license
zhaiyuhan/HAODA
d86f3a0506e66476632388dfc9121610f929f8cc
00361fc8c1e64386140766cf6e9319bee1e1ee2f
refs/heads/master
2021-01-19T17:28:04.877092
2020-03-28T15:03:37
2020-03-28T15:03:37
88,324,011
12
3
null
null
null
null
UTF-8
C++
false
false
764
h
#pragma once #include <qgraphicseffect.h> #include <QGraphicsDropShadowEffect> class CustomShadowEffect : public QGraphicsEffect { Q_OBJECT public: explicit CustomShadowEffect(QObject *parent = 0); void draw(QPainter* painter); QRectF boundingRectFor(const QRectF& rect) const; inline void setDistance(qreal distance) { _distance = distance; updateBoundingRect(); } inline qreal distance() const { return _distance; } inline void setBlurRadius(qreal blurRadius) { _blurRadius = blurRadius; updateBoundingRect(); } inline qreal blurRadius() const { return _blurRadius; } inline void setColor(const QColor& color) { _color = color; } inline QColor color() const { return _color; } private: qreal _distance; qreal _blurRadius; QColor _color; };
[ "zhaiyuhanx@hotmail.com" ]
zhaiyuhanx@hotmail.com
32555138d561d07d7fac55439c864e43315fc3e9
86aa96d73cab729b99d2a3f3c1d1c5bedd7569c3
/cpp/2000/2500/P2562.cpp
ec981cbb00eab5aae470476c60f7729cc3f75c65
[]
no_license
JsKim4/BOJ-BaekJoon-Online-judge-
f09e9b78053b86990257663c63740c77ee2b67c9
99213e332f7775f23e247d9ee7f5b36d0a0ee86f
refs/heads/master
2021-06-25T20:26:12.036408
2021-03-28T16:01:59
2021-03-28T16:01:59
221,194,844
2
0
null
null
null
null
UTF-8
C++
false
false
240
cpp
#include<iostream> #pragma warning (disable:4996) using namespace std; // 2562 최댓값 int main(){ int a=0, b=0; for (int i = 1; i < 10;i++) { int k; scanf("%d",&k); if (a < k) { a = k; b = i; } } printf("%d\n%d",a,b); }
[ "46150254+JsKim4@users.noreply.github.com" ]
46150254+JsKim4@users.noreply.github.com
bf9c1b677b980eb2ecdf67195d49c2bae14a4b8d
688f1406d7a502d040c751b691d19f7208924a25
/pintool_branchpredictors/branch_predictor.h
60716a280b34416561bca6d448c95699ac3d2727
[]
no_license
Lefteris2993/cslab-advcomparch-code
373a23db22d172bbc7761655fd86ac7fc35b5d1a
a013ef8ff1e4018bc248adcc9cdf7d01ef6eecc6
refs/heads/master
2021-05-25T17:52:39.770064
2019-03-09T02:00:51
2019-03-09T02:00:51
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,320
h
#ifndef BRANCH_PREDICTOR_H #define BRANCH_PREDICTOR_H #include <sstream> // std::ostringstream #include <cmath> // pow() #include <cstring> // memset() #include <vector> using std::vector; /** * A generic BranchPredictor base class. * All predictors can be subclasses with overloaded predict() and update() * methods. **/ class BranchPredictor { public: BranchPredictor() : correct_predictions(0), incorrect_predictions(0) {}; ~BranchPredictor() {}; virtual bool predict(ADDRINT ip, ADDRINT target) = 0; virtual void update(bool predicted, bool actual, ADDRINT ip, ADDRINT target) = 0; virtual string getName() = 0; UINT64 getNumCorrectPredictions() { return correct_predictions; } UINT64 getNumIncorrectPredictions() { return incorrect_predictions; } void resetCounters() { correct_predictions = incorrect_predictions = 0; }; protected: void updateCounters(bool predicted, bool actual) { if (predicted == actual) correct_predictions++; else incorrect_predictions++; }; private: UINT64 correct_predictions; UINT64 incorrect_predictions; }; class NbitPredictor : public BranchPredictor { public: NbitPredictor(unsigned index_bits_, unsigned cntr_bits_) : BranchPredictor(), index_bits(index_bits_), cntr_bits(cntr_bits_) { table_entries = 1 << index_bits; TABLE = new unsigned long long[table_entries]; memset(TABLE, 0, table_entries * sizeof(*TABLE)); COUNTER_MAX = (1 << cntr_bits) - 1; }; ~NbitPredictor() { delete TABLE; }; virtual bool predict(ADDRINT ip, ADDRINT target) { unsigned int ip_table_index = ip % table_entries; unsigned long long ip_table_value = TABLE[ip_table_index]; unsigned long long prediction = ip_table_value >> (cntr_bits - 1); return (prediction != 0); }; virtual void update(bool predicted, bool actual, ADDRINT ip, ADDRINT target) { unsigned int ip_table_index = ip % table_entries; if (actual) { if (TABLE[ip_table_index] < COUNTER_MAX) TABLE[ip_table_index]++; } else { if (TABLE[ip_table_index] > 0) TABLE[ip_table_index]--; } updateCounters(predicted, actual); }; virtual string getName() { std::ostringstream stream; stream << "Nbit-" << pow(2.0,double(index_bits)) / 1024.0 << "K-" << cntr_bits; return stream.str(); } private: unsigned int index_bits, cntr_bits; unsigned int COUNTER_MAX; /* Make this unsigned long long so as to support big numbers of cntr_bits. */ unsigned long long *TABLE; unsigned int table_entries; }; //EDITED // Implementation points: // * predict taken for entries found in BTB, otherwise not taken // * replace LRU address in case of conflict // * vector used for sets with (max size == associativity) // * vector head == LRU, vector tail == MRU // * CorrectTargetPredictions = branch was taken and target in BTB was correct // OR branch not taken and no entry in BTB // * CorrectPredictions : prediction == actual // * IncorrectPredictions : prediction != actual // * The *ip* stored in the BTB need not contain the index bits. We keep them // anyway because it makes the implementation easier class BTBPredictor : public BranchPredictor { public: BTBPredictor(UINT32 btb_lines, UINT32 btb_assoc) : table_lines(btb_lines), table_assoc(btb_assoc) { table = new BTB_SET[table_lines]; correct_target_predictions = 0; } ~BTBPredictor() { delete table; } // predict taken if IP exists in the BTB virtual bool predict(ADDRINT ip, ADDRINT target) { int index = ip % table_lines; BTB_SET & set = table[index]; bool found = false; for (BTB_SET::iterator it = set.begin(); !found && it != set.end(); it++) { found = (ip == (*it).ip); } return found; } // we predict taken for entries in the BTB, so predicted == entry exists virtual void update(bool predicted, bool actual, ADDRINT ip, ADDRINT target) { // find set int index = ip % table_lines; BTB_SET & set = table[index]; // count correct/incorrect predictions updateCounters(predicted, actual); // branch was taken and there was no entry in BTB, add it as MRU if (!predicted && actual) { // add entry as MRU set.push_back({ip, target}); if (set.size() > table_assoc) set.erase(set.begin()); } // branch was taken and there was an entry in BTB else if (predicted && actual) { // find entry BTB_SET::iterator entry; for (entry = set.begin(); entry != set.end(); entry++) { if ((*entry).ip == ip) break; } // was target correct? if ((*entry).target == target) { correct_target_predictions++; } // make the (corrected) entry MRU set.erase(entry); set.push_back({ip, target}); } // branch was not taken and there was an entry in BTB else if (predicted && !actual) { // find entry BTB_SET::iterator entry; for (entry = set.begin(); entry != set.end(); entry++) { if ((*entry).ip == ip) break; } // remove it set.erase(entry); } // branch was not taken and there was no entry in BTB else { // prediction was correct, does it count as correct target prediction? correct_target_predictions++; } } virtual string getName() { std::ostringstream stream; stream << "BTB-" << table_lines << "-" << table_assoc; return stream.str(); } UINT64 getNumCorrectTargetPredictions() { return correct_target_predictions; } private: struct addr_pair { UINT64 ip; UINT64 target; }; typedef vector<addr_pair> BTB_SET; UINT32 table_lines, table_assoc; BTB_SET *table; UINT64 correct_target_predictions; }; #endif
[ "neoaggelos@gmail.com" ]
neoaggelos@gmail.com
9dc6a9f00b0aa5598c128d04088b25e141e2b5c6
3f84e550f46760e67330b9d1c24a62b5cae3c7eb
/pfms-2019a-Johnson15177-master/quizzes/review5/a/fibonacci.cpp
46d5f635e824133a518ef1a10c4cea9628454fec
[]
no_license
esteban-andrade/projects
58f303a6901b5eba340ca8c856eaea8ddd633f63
b569f241b6dd1302811cce91407df7ac54a9ffa5
refs/heads/master
2020-07-03T11:59:43.915046
2020-05-15T02:58:18
2020-05-15T02:58:18
201,897,707
0
0
null
null
null
null
UTF-8
C++
false
false
1,345
cpp
#include <thread> //For accessing the standard C++ thread library #include <chrono> //Used for creating thread delays #include <iostream> #include <queue> #include <mutex> #include <condition_variable> struct TDataBuffer { std::queue<long> buffer; std::mutex mu; std::condition_variable cv; } sequence; void fibonacci(void) { static long a = 0; static long b = 1; sequence.buffer.push(a); while(true) { std::this_thread::sleep_for(std::chrono::milliseconds(1000)); std::unique_lock<std::mutex> lock(sequence.mu); sequence.buffer.push(b); sequence.cv.notify_all(); b = a + b; a = b - a; } } void printToTerminal(void) { while(true) { while(sequence.buffer.empty()){ std::unique_lock<std::mutex> lock(sequence.mu); sequence.cv.wait(lock); } if(sequence.buffer.empty()) { std::cout << "<buffer was empty>" << std::endl; } else { long next = sequence.buffer.front(); sequence.buffer.pop(); std::cout << "Next in sequence: " << next << std::endl; } } } int main (void) { //Create the threads std::thread producer(fibonacci); std::thread consumer(printToTerminal); producer.join(); consumer.join(); return 0; }
[ "esgaanza98@gmail.com" ]
esgaanza98@gmail.com
7d1a53817f9bdde4275f829aa08769751d4937fa
1e976ee65d326c2d9ed11c3235a9f4e2693557cf
/CommonSources/SimpleBrowser.h
4c83399ebedde3cb723d4a4c779421e1071ce3ff
[]
no_license
outcast1000/Jaangle
062c7d8d06e058186cb65bdade68a2ad8d5e7e65
18feb537068f1f3be6ecaa8a4b663b917c429e3d
refs/heads/master
2020-04-08T20:04:56.875651
2010-12-25T10:44:38
2010-12-25T10:44:38
19,334,292
3
0
null
null
null
null
UTF-8
C++
false
false
5,169
h
// /* // * // * Copyright (C) 2003-2010 Alexandros Economou // * // * This file is part of Jaangle (http://www.jaangle.com) // * // * This Program is free software; you can redistribute it and/or modify // * it under the terms of the GNU General Public License as published by // * the Free Software Foundation; either version 2, or (at your option) // * any later version. // * // * This Program is distributed in the hope that it will be useful, // * but WITHOUT ANY WARRANTY; without even the implied warranty of // * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // * GNU General Public License for more details. // * // * You should have received a copy of the GNU General Public License // * along with GNU Make; see the file COPYING. If not, write to // * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. // * http://www.gnu.org/copyleft/gpl.html // * // */ // // Change History: // // April 6, 2003 - Original release, and article posted at // http://www.codeproject.com/useritems/SimpleBrowserForMFC.asp // // April 12, 2003 - Replaced NavigateString() with Write() and Clear(). // - Added logic to Create() to wait for document ready. // - Added GetDocument() method. // - Added notification support. // - Added post data and headers to BeforeNavigate2 handling. // #if !defined(SimpleBrowser_defined) #define SimpleBrowser_defined #include "mshtml.h" class SimpleBrowserNotifier { public: virtual void OnBeforeNavigate(LPCTSTR url) = 0; virtual void OnDocumentComplete(LPCTSTR url) = 0; virtual void OnDownloadBegin() = 0; virtual void OnProgressChange(long progress,long progress_max) = 0; virtual void OnDownloadComplete() = 0; virtual void OnNavigateComplete(LPCTSTR url) = 0; virtual void OnStatusTextChange(LPCTSTR text) = 0; virtual void OnTitleChange(LPCTSTR text) = 0; virtual void EnableBackButton(BOOL bEnable) = 0; virtual void EnableNextButton(BOOL bEnable) = 0; }; class SimpleBrowser : public CWnd { public: // construction and creation SimpleBrowser(); virtual ~SimpleBrowser(); // create browser directly BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); // controls BOOL Navigate(LPCTSTR URL); BOOL LoadHTML(LPCTSTR html); BOOL LoadFromResource(INT resID); // append string to current document; note that the WebBrowser control tolerates void Write(LPCTSTR string); // clear current document void Clear(); void GoBack(); void GoForward(); void GoHome(); void Refresh(); void Stop(); // start printing contents; uses same 'metacharacters' for header and // footer as Internet Explorer; see IE Page Setup dialog void Print(LPCTSTR header = _T("&w&b&b&p"), LPCTSTR footer = _T("&d &t")); bool GetBusy(); READYSTATE GetReadyState(); CString GetLocationName(); CString GetLocationURL(); // get/set silent property (if true, dialog and message boxes may not be shown) bool GetSilent(); void PutSilent(bool silent = false); void SetNotifier(SimpleBrowserNotifier* pNotifier) {m_pNotifier = pNotifier;} BOOL ExecuteJavascript(LPCTSTR script); BOOL GetElementText(LPCTSTR elementName, LPTSTR bf, UINT bfLen); // get document interface; returns NULL // if interface is not available // (which is the case if you've navigated to // something that's NOT an HTML document, // like an Excel spreadsheet, which the // WebBrowser control is perfectly willing // to host) IWebBrowser2* GetBrowser() {return m_pBrowser;} IHTMLDocument2* GetDocument(); protected: virtual void PostNcDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg BOOL OnEraseBkgnd(CDC* pDC); DECLARE_MESSAGE_MAP() DECLARE_EVENTSINK_MAP() //-----------------Events // called before navigation begins; URL is destination, frame // is frame name ("" if none), post_data is HTTP POST data (NULL if none), // and headers are HTTP headers sent to server; // return true to cancel navigation, false to continue // navigation to document complete; URL is location private: void OnBeforeNavigate2(LPDISPATCH lpDisp, VARIANT FAR *URL, VARIANT FAR *Flags, VARIANT FAR *TargetFrameName, VARIANT FAR *PostData, VARIANT FAR *Headers, VARIANT_BOOL *Cancel); void ReleaseObjects(); void OnDocumentComplete(LPDISPATCH lpDisp,VARIANT FAR* URL); void OnDownloadBegin(); void OnProgressChange(long progress,long progress_max); void OnDownloadComplete(); void OnNavigateComplete2(LPDISPATCH lpDisp,VARIANT FAR* URL); void OnStatusTextChange(BSTR text); void OnTitleChange(BSTR bstrText); void OnCommandStateChange(long command, VARIANT_BOOL Enable); public: IHTMLDocument3* GetDocument3(); private: CWnd* m_pBrowserWnd; // browser window IWebBrowser2* m_pBrowser; // browser control IDispatch* m_pBrowserDispatch; // browser control dispatch interface SimpleBrowserNotifier* m_pNotifier; }; #endif
[ "outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678" ]
outcast1000@dc1b949e-fa36-4f9e-8e5c-de004ec35678
1fa71db8ebbe84c4bc0c7105674ec3b10d1dbb55
31a0894ea49786b9c33bc1aaa89e530cd0dbbd66
/Module1/lab1.cpp
66813a22a7bf33df167314819b11e1ee33a2cc9b
[]
no_license
neikila/Algo
98da0b2b2f8c60913756b29a8886f76dc1e9d144
1a6786c4d9d543d34d10eff834367da1a8af3f1c
refs/heads/master
2020-04-05T08:57:42.443373
2015-02-13T19:50:44
2015-02-13T19:50:44
30,773,061
0
0
null
null
null
null
UTF-8
C++
false
false
1,112
cpp
/* Выполнил: Нейман Кирилл Аркадьевич. (2.Neiman.Kirill) Группа: АПО-12 1_4. Дано натуральное число N. Представить N в виде A + B, так, что НОД(A, B) максимален, A <= B. Вывести A и B. Если возможно несколько ответов - вывести ответ с минимальным A. Пример: in 35 out 7 28 */ #include <stdio.h> #include <iostream> #include "assert.h" using namespace std; //Поиск наменьшего общего делителя int SearchMinDiv(int N) { int temp = N; for ( int i = 2; i*i <= N ; ++i ) { if (N%i==0) { temp = i; break; } } return temp; } void countAandB(int N, int* A, int* B) { int temp = SearchMinDiv(N); if (temp == N) { *A = 1; *B = N - *A; } else { *B = (N/temp)*(temp-1); *A = N - *B; } } int main() { int N = 0; //Ввод числа N и проверка cin >> N; assert(N > 0); //Расчет А и B int A = 0, B = 0; countAandB(N, &A, &B); cout << A << ' ' << B << endl; return 0; }
[ "neikila@gmail.com" ]
neikila@gmail.com
0a8c2bd9c6fad70663a8230e3bf72d4a10541814
c4fceeb1f0adf7dc67480df898f48d7fe886070e
/kaldi/src/kws/kws-functions.h
8aaf79bb2ee3d80a8d65f4c15d2c4b66e691de1d
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
NitinShuklaML/another-repo
dcc8e7f657bf259012a86e6a404fc578a0c382d7
6c1a4b5f7f5025302e4b4d5d48513ebdf65b5fe2
refs/heads/master
2020-12-02T17:32:30.480098
2019-12-31T10:34:17
2019-12-31T10:34:17
231,075,476
0
0
null
null
null
null
UTF-8
C++
false
false
6,530
h
// kws/kws-functions.h // Copyright 2012 Johns Hopkins University (Author: Guoguo Chen) // See ../../COPYING for clarification regarding multiple authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, // MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache 2 License for the specific language governing permissions and // limitations under the License. #ifndef KALDI_KWS_KWS_FUNCTIONS_H_ #define KALDI_KWS_KWS_FUNCTIONS_H_ #include <vector> #include "lat/kaldi-lattice.h" #include "kws/kaldi-kws.h" namespace kaldi { // We store the time information of the arc into class "Interval". "Interval" // has a public function "int32 Overlap(Interval interval)" which takes in // another interval and returns the overlap of that interval and the current // interval. class Interval { public: Interval() {} Interval(int32 start, int32 end) : start_(start), end_(end) {} Interval(const Interval &interval) : start_(interval.Start()), end_(interval.End()) {} int32 Overlap(Interval interval) { return std::max<int32>(0, std::min(end_, interval.end_) - std::max(start_, interval.start_)); } int32 Start() const {return start_;} int32 End() const {return end_;} ~Interval() {} private: int32 start_; int32 end_; }; // We define a function bool CompareInterval(const Interval &i1, const Interval // &i2) to compare the Interval defined above. If interval i1 is in front of // interval i2, then return true; otherwise return false. bool CompareInterval(const Interval &i1, const Interval &i2); // This function clusters the arcs with same word id and overlapping time-spans. // Examples of clusters: // 0 1 a a (0.1s ~ 0.5s) and 2 3 a a (0.2s ~ 0.4s) are within the same cluster; // 0 1 a a (0.1s ~ 0.5s) and 5 6 b b (0.2s ~ 0.4s) are in different clusters; // 0 1 a a (0.1s ~ 0.5s) and 7 8 a a (0.9s ~ 1.4s) are also in different clusters. // It puts disambiguating symbols in the olabels, leaving the words on the // ilabels. bool ClusterLattice(CompactLattice *clat, const std::vector<int32> &state_times); // This function contains two steps: weight pushing and factor generation. The // original ShortestDistance() is not very efficient, so we do the weight // pushing and shortest path manually by computing the alphas and betas. The // factor generation step expand the lattice to the LXTXT' semiring, with // additional start state and end state (and corresponding arcs) added. bool CreateFactorTransducer(const CompactLattice &clat, const std::vector<int32> &state_times, int32 utterance_id, KwsProductFst *factor_transducer); // This function removes the arcs with long silence. By "long" we mean arcs with // #frames exceeding the given max_silence_frames. We do this filtering because // the gap between adjacent words in a keyword must be <= 0.5 second. // Note that we should not remove the arcs created in the factor generation // step, so the "search area" is limited to the original arcs before factor // generation. void RemoveLongSilences(int32 max_silence_frames, const std::vector<int32> &state_times, KwsProductFst *factor_transducer); // Do the factor merging part: encode input and output, and apply weighted // epsilon removal, determinization and minimization. Modifies factor_transducer. void DoFactorMerging(KwsProductFst *factor_transducer, KwsLexicographicFst *index_transducer); // Do the factor disambiguation step: remove the cluster id's for the non-final // arcs and insert disambiguation symbols for the final arcs void DoFactorDisambiguation(KwsLexicographicFst *index_transducer); // Do the optimization: do encoded determinization, minimization void OptimizeFactorTransducer(KwsLexicographicFst *index_transducer, int32 max_states, bool allow_partial); // the following two functions will, if GetVerboseLevel() >= 2, check that the // cost of the second-best path in the transducers is not negative, and print // out some associated debugging info if GetVerboseLevel() >= 3. The best path // in the transducers will typically be for the empty word sequence, and it may // have negative cost (i.e. probability more than one), but the second-best one // should not have negative cost. A warning will be printed if // GetVerboseLevel() >= 2 and a substantially negative cost is found. void MaybeDoSanityCheck(const KwsProductFst &factor_transducer); void MaybeDoSanityCheck(const KwsLexicographicFst &index_transducer); // this Mapper class is used in some of the the internals; we have to declare it // in the header because, for the sake of compilation time, we split up the // implementation into two .cc files. class KwsProductFstToKwsLexicographicFstMapper { public: typedef KwsProductArc FromArc; typedef KwsProductWeight FromWeight; typedef KwsLexicographicArc ToArc; typedef KwsLexicographicWeight ToWeight; KwsProductFstToKwsLexicographicFstMapper() {} inline ToArc operator()(const FromArc &arc) const { return ToArc(arc.ilabel, arc.olabel, (arc.weight == FromWeight::Zero() ? ToWeight::Zero() : ToWeight(arc.weight.Value1().Value(), StdLStdWeight(arc.weight.Value2().Value1().Value(), arc.weight.Value2().Value2().Value()))), arc.nextstate); } fst::MapFinalAction FinalAction() const { return fst::MAP_NO_SUPERFINAL; } fst::MapSymbolsAction InputSymbolsAction() const { return fst::MAP_COPY_SYMBOLS; } fst::MapSymbolsAction OutputSymbolsAction() const { return fst::MAP_COPY_SYMBOLS;} uint64 Properties(uint64 props) const { return props; } }; } // namespace kaldi #endif // KALDI_KWS_KWS_FUNCTIONS_H_
[ "nitin.shukla2014@gmail.com" ]
nitin.shukla2014@gmail.com
b8a55229fea705c4f63b0e24fd758b63199ff263
c6bddd88916e6c8697a9e02485bd22c58d76bcec
/GeneratedPlaceholders/Engine/MaterialExpressionDistance.h
36d8fa557fc4b6389d37978742b29c860f788b5b
[]
no_license
GIRU-GIRU/Mordhau-Unofficial-SDK
18d13d62d746a838820e387907d13b0a37aed654
f831d7355cf553b81fb6e82468b3abf68f7955aa
refs/heads/master
2020-07-06T03:36:48.908227
2020-04-22T13:54:00
2020-04-22T13:54:00
202,872,898
7
4
null
null
null
null
UTF-8
C++
false
false
364
h
#pragma once #include "CoreMinimal.h" #include "MaterialExpressionDistance.generated.h" UCLASS() class UMaterialExpressionDistance : public UMaterialExpression { GENERATED_BODY() public: UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) struct FExpressionInput A; UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite) struct FExpressionInput B; };
[ "45307738+crypdos@users.noreply.github.com" ]
45307738+crypdos@users.noreply.github.com
fda44d0f71947283f287c1369ec8543833b76b62
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1483488_1/C++/Yeomin/c.cpp
e911aa3fdc46a6389faffda1093423aaa1d990c4
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,175
cpp
#include <cstdio> #include <set> using namespace std; int t, cases; set<pair<int, int> > s; int lng(int n) { if (n < 10) return 1; if (n < 100) return 10; if (n < 1000) return 100; if (n < 10000) return 1000; if (n < 100000) return 10000; if (n < 1000000) return 100000; if (n < 10000000) return 1000000; } int solve(int n, int m) { for (int i = n; i <= m; ++i) { int p, lngi; if (i < 10) continue; lngi = p = lng(i); int t = 10; while (i / t > 0) { int x = (i % t) * p + i / t; t *= 10; p /= 10; if (lngi == lng(x) && x != i && n <= x && x <= m) { int y; if (x > i) { y = x; x = i; } else { y = i; } s.insert(make_pair(x, y)); } } } return s.size(); } int solve2(int n, int m) { int ret = 0; for (set<pair<int, int>>::iterator it = s.begin(); it != s.end(); ++it) { if (n <= it->first && it->second <= m) { ++ret; } } return ret; } int main() { scanf("%d", &t); solve(1, 2000000); while (t--) { int n, m; scanf("%d%d", &n, &m); printf("Case #%d: %d\n", ++cases, solve2(n, m)); } }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
641a5f3361645c26553a5f76b632e3ac667b34a7
5a77bb4eff944f3621e83b687683002f8e3aeaee
/HW1/refer/main.cpp
9ec7c55e86a4a9b3945a5e8cc0dacb79cdf7e512
[]
no_license
huan1182/deep_learning_homework
7a651aee980847caea8d5ad9018d4ed838803ff0
35453c28762df522336bfc4dd25ff5546f1d054a
refs/heads/master
2020-03-27T17:05:03.461628
2018-09-20T19:49:29
2018-09-20T19:49:29
146,827,651
0
0
null
null
null
null
UTF-8
C++
false
false
3,015
cpp
#include <iostream> #include <string> #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/core/core.hpp" #include "opencv2/video/video.hpp" #include <time.h> #include <fstream> #include <vector> using namespace std; using namespace cv; class Conv2D{ public: Conv2D(int ic, int oc, int ks, int s) { in_channel = ic; o_channel = oc; kernel_size = ks; stride = s; for (int i = 0; i < oc; i++) { Mat kernel; kernel.create(kernel_size, kernel_size, CV_8UC1); // the type for the kernel is float and only has one channel cv::randu(kernel, cv::Scalar::all(-2), cv::Scalar::all(2)); //cout << A << endl; //cout << kernel << endl; //cv::waitKey(); // random init the kernel; // in PartB is only has one kernel kernels.push_back(kernel); } } int c_conv(Mat img) { int num_ops = 0; int img_height = img.rows; int img_width = img.cols; int kernel_height = kernel_size; int kernel_width = kernel_size; int conv_height = (img_height - kernel_height) / stride + 1; int conv_width = (img_width - kernel_width) / stride + 1; cout << conv_height << ", " << conv_width << endl; Mat conv_img = Mat::zeros(conv_height, conv_width, CV_32FC1); vector<Mat> channels; for (int k = 0; k < kernels.size(); k++) { for (int c = 0; c < 3; c++) { for (int h = 0; h < conv_height; h++) { int h_pos = h * stride; //cout << h << endl; for (int w = 0; w < conv_width; w++) { int w_pos = w * stride; //cout << w_pos << endl; if (w_pos + kernel_size < img_width && h_pos + kernel_size < img_height) { Mat roi(img, Rect(w_pos, h_pos, kernel_size, kernel_size)); Mat crop = roi.clone(); vector<Mat> split_crop; split(crop, split_crop); //cout << "dot product\n"; double d = kernels[k].dot(split_crop.at(c).clone()); conv_img.at<float>(h,w) += d; num_ops ++; } } //cout << "lines\n"; } //cout << "channels\n"; } } //imwrite("c_conv.png", conv_img); return num_ops; } private: int in_channel; int o_channel; int kernel_size; int stride; //vector<Mat> kernels; vector<Mat> kernels; string mode; }; int main(int argc, char *argv[]) { //string file_name = "trees" string file_name = "mountain"; ofstream out(file_name + ".txt"); if (!out.is_open()) cout << "cannot open an out.txt\n"; clock_t startTime, endTime; int o_channel = 1; Mat img = imread(file_name + ".jpg"); //cvtColor(img, img, CV_BGR2GRAY); for (int i = 0; i < 11; i++) { startTime = clock(); Conv2D conv2d(3,o_channel,3,1); o_channel *= 2; int ops = conv2d.c_conv(img); //out << ops << endl; //cout << ops << endl; endTime = clock(); //cout << "ops: " << ops << endl; cout << "totol time: " << (endTime - startTime) / CLOCKS_PER_SEC << endl; out << (endTime - startTime) / CLOCKS_PER_SEC << endl; } out.close(); }
[ "noreply@github.com" ]
huan1182.noreply@github.com
d27fed4756a1d024031de7616bbc71a176e96a7d
c7585939c230059e367af74ee549ac4e183907ec
/List_test/List_test.cpp
7984400cfef6d001746487cf016789a2e203256d
[]
no_license
lakiGuo/playCplusplus
506bc45eb20591c352b89ae479e159dba309c95f
e64dbb4f8ada91e5ac170d7a24ec9f5691deba18
refs/heads/main
2023-03-01T02:31:53.448465
2021-02-07T13:26:54
2021-02-07T13:26:54
327,230,944
0
0
null
null
null
null
UTF-8
C++
false
false
1,587
cpp
// List_test.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <list> #include "chain.h" using namespace std; int main() { //使用list模拟链表 chain<int> onelist; onelist.insert(0,1); cout << onelist.size()<<endl; onelist.insert(0, 2); onelist.insert(1,4); onelist.erase(0); std::cout << onelist << endl; cout << "element in index 0 is: "<<onelist.get(0)<<endl; cout << "index of element 2 is: "<<onelist.indexOf(2) << endl; list<int> a; list<int> b; a.push_back(1); a.push_back(4); a.push_back(3); a.push_back(5); a.push_back(2); auto a_begin = a.begin(); auto a_end = a.end(); a.sort(); while (a_begin != a_end) { cout << *a_begin << endl; a_begin++; } //std::cout << "second is:" << second << endl; std::cout << "Hello World!\n"; } // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 // 调试程序: F5 或调试 >“开始调试”菜单 // 入门使用技巧: // 1. 使用解决方案资源管理器窗口添加/管理文件 // 2. 使用团队资源管理器窗口连接到源代码管理 // 3. 使用输出窗口查看生成输出和其他消息 // 4. 使用错误列表窗口查看错误 // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
[ "18721510380@163.com" ]
18721510380@163.com
37fc97f94838fecfbf046ce86a70c1fd5ed918f1
62895d5feb418f45f496e080018787e1e4b29bdc
/pvDataCPP/testApp/misc/testBitSet.cpp
36fc645d39c1d4f97ae6e612b6b65675173012b3
[ "MIT", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
ncanestrari/EPICS-EPICS_V4
79248442adaba01243042a3513a30193769663d8
856274668c5e5366adfd9fc753dfa68eb188ad1b
refs/heads/master
2021-01-17T21:48:39.128382
2015-08-27T14:26:47
2015-08-27T14:26:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,167
cpp
/* testBitSet.cpp */ /** * Copyright - See the COPYRIGHT that is included with this distribution. * EPICS pvData is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ /* Author: Matej Sekoranja Date: 2010.10.18 */ #include <iostream> #include <stddef.h> #include <stdlib.h> #include <stddef.h> #include <string.h> #include <stdio.h> #include <sstream> #include <pv/bitSet.h> #include <epicsUnitTest.h> #include <testMain.h> using namespace epics::pvData; using std::string; static string toString(BitSet& bitSet) { std::ostringstream oss; oss << bitSet; return oss.str(); } static void testGetSetClearFlip() { testDiag("testGetSetClearFlip... "); // empty BitSet* b1 = new BitSet(); testOk1(b1->isEmpty()); testOk1(b1->cardinality() == 0); // to string check string str = toString(*b1); testOk1(str == "{}"); // one b1->set(3); testOk1(b1->get(3)); testOk1(!b1->isEmpty()); testOk1(b1->cardinality() == 1); // to string check str = toString(*b1); testOk1(str == "{3}"); // grow b1->set(66); b1->set(67); b1->set(68); testOk1(b1->cardinality() == 4); str = toString(*b1); testOk1(str == "{3, 66, 67, 68}"); // clear one b1->clear(67); testOk1(b1->cardinality() == 3); str = toString(*b1); testOk1(str == "{3, 66, 68}"); // flip b1->flip(66); b1->flip(130); testOk1(b1->cardinality() == 3); str = toString(*b1); testOk1(str == "{3, 68, 130}"); // flip b1->set(130, false); b1->set(4, true); testOk1(b1->cardinality() == 3); str = toString(*b1); testOk1(str == "{3, 4, 68}"); // clear all b1->clear(); testOk1(b1->isEmpty()); testOk1(b1->cardinality() == 0); str = toString(*b1); testOk1(str == "{}"); delete b1; } static void testOperators() { testDiag("testOperators... "); BitSet b1; testOk1(b1 == b1); BitSet b2; testOk1(b1 == b2); b1.set(1); testOk1(!(b1 == b2)); // different internal length, but the same b2.set(100); b2.set(1); b2.flip(100); testOk1(b1 == b2); // OR test b2.set(65); b2.set(106); b2.set(105); b1 |= b2; string str = toString(b1); testOk1(str == "{1, 65, 105, 106}"); b1.clear(); b1 |= b2; str = toString(b1); testOk1(str == "{1, 65, 105, 106}"); // AND test b1.set(128); b1 &= b2; testOk1(b1 == b2); // XOR test b1.set(128); b1 ^= b2; testOk1((b1.cardinality() == 1 && b1.get(128) == true)); b1.clear(); b2.clear(); b1.set(1); b2.set(256); b1 ^= b2; testOk1((b1.cardinality() == 2 && b1.get(1) == true && b1.get(256) == true)); // assign b1 = b2; testOk1(b1 == b2); // or_and b1.clear(); b1.set(2); b2.clear(); b2.set(66); b2.set(128); BitSet b3; b3.set(128); b3.set(520); b1.or_and(b2, b3); str = toString(b1); testOk1(str == "{2, 128}"); } MAIN(testBitSet) { testPlan(29); testGetSetClearFlip(); testOperators(); return testDone(); }
[ "freddie.akeroyd@stfc.ac.uk" ]
freddie.akeroyd@stfc.ac.uk
1475644ed6ce1ea36dac66e79c80cf90e232373e
3b74cf8cb802728af1f7b3d38ed30d2c4c40094b
/cautrucsinhvien.cpp
9d3da41fd51ce163bf08c66aad16712e48bac1bc
[]
no_license
Thuthu2k/CodeTG
075f62e95953244a1c830a84d7733717bbe62e3d
b459f4e0fce37f9637e3df45ad2d3417c7a971c6
refs/heads/master
2023-07-15T12:49:58.340761
2021-08-28T02:24:37
2021-08-28T02:24:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
925
cpp
#include<bits/stdc++.h> using namespace std; vector<string> v; const string ma = "B20DCCN001"; struct SinhVien{ string maSV; string ten, lop, ngaySinh; float diemTB; }; string solve(string s){ vector<string> tmp; string ans = ""; stringstream ss(s); string token; while(getline(ss, token, '/')){ tmp.push_back(token); } for(int i=0 ; i<tmp.size()-1 ; i++){ if(tmp[i].length() == 1){ ans = ans + "0" + tmp[i] + "/"; } else ans = ans + tmp[i] + "/"; } ans = ans + tmp[tmp.size()-1]; return ans; } void nhap(SinhVien& a){ int t=4; while(t--){ string s; getline(cin ,s); v.push_back(s); } } void in(SinhVien& a){ a.maSV = ma; a.ten = v[0]; a.lop = v[1]; a.ngaySinh = solve(v[2]); a.diemTB = atof(v[3].c_str()); cout << a.maSV << " " << a.ten << " " << a.lop << " " << a.ngaySinh << " "; printf("%.2f", a.diemTB); } int main(){ struct SinhVien a; nhap(a); in(a); return 0; }
[ "89471845+ThuThu2k@users.noreply.github.com" ]
89471845+ThuThu2k@users.noreply.github.com
ab7b626e4478ab6da02bc3a7d34742f40aa436de
5054918e46c7297a673d7e2a610fab755bd098f7
/include/noise/simplexnoise.cc
405cafa26fdb503c41faa9cfefb29dfdcdcc570f
[ "MIT" ]
permissive
kretash/D3D12_Vulkan-ProceduralCity
6e997c659705c5023c31d9a37b0373dd5c6b1474
46dc4d2c221d9076b080d359552387af7907bc2e
refs/heads/master
2020-04-13T23:23:29.465878
2020-02-04T21:57:53
2020-02-04T21:57:53
51,383,448
11
2
null
2016-05-10T19:13:35
2016-02-09T17:19:05
C
WINDOWS-1250
C++
false
false
22,313
cc
// Michaelangel007: I formatted perm[] to be readable; // I also cleaned up the code for readability. // i.e. Adding whitespace for multi-column alignment. // // SimplexNoise1234 // Copyright © 2003-2011, Stefan Gustavson // // Contact: stegu@itn.liu.se // // This library is public domain software, released by the author // into the public domain in February 2011. You may do anything // you like with it. You may even remove all attributions, // but of course I'd appreciate it if you kept my name somewhere. // // 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 // General Public License for more details. /** \file \brief Implements the SimplexNoise1234 class for producing Perlin simplex noise. \author Stefan Gustavson (stegu@itn.liu.se) */ /* * This implementation is "Simplex Noise" as presented by * Ken Perlin at a relatively obscure and not often cited course * session "Real-Time Shading" at Siggraph 2001 (before real * time shading actually took on), under the title "hardware noise". * The 3D function is numerically equivalent to his Java reference * code available in the PDF course notes, although I re-implemented * it from scratch to get more readable code. The 1D, 2D and 4D cases * were implemented from scratch by me from Ken Perlin's text. * * This is a highly reusable class. It has no dependencies * on any other file, apart from its own header file. */ #include "SimplexNoise.h" #define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) ) //--------------------------------------------------------------------- // Static data /* * Permutation table. This is just a random jumble of all numbers 0-255, * repeated twice to avoid wrapping the index at 255 for each lookup. * This needs to be exactly the same for all instances on all platforms, * so it's easiest to just keep it as static explicit data. * This also removes the need for any initialisation of this class. * * Note that making this an int[] instead of a char[] might make the * code run faster on platforms with a high penalty for unaligned single * byte addressing. Intel x86 is generally single-byte-friendly, but * some other CPUs are faster with 4-aligned reads. * However, a char[] is smaller, which avoids cache trashing, and that * is probably the most important aspect on most architectures. * This array is accessed a *lot* by the noise functions. * A vector-valued noise over 3D accesses it 96 times, and a * float-valued 4D noise 64 times. We want this to fit in the cache! */ unsigned char SimplexNoise1234::perm[512] = { 151,160,137, 91, 90, 15,131, 13,201, 95, 96, 53,194,233, 7,225, // 0 .. 15 140, 36,103, 30, 69,142, 8, 99, 37,240, 21, 10, 23,190, 6,148, // 16 .. 31 247,120,234, 75, 0, 26,197, 62, 94,252,219,203,117, 35, 11, 32, // 32 .. 47 57,177, 33, 88,237,149, 56, 87,174, 20,125,136,171,168, 68,175, // 48 .. 63 74,165, 71,134,139, 48, 27,166, 77,146,158,231, 83,111,229,122, // 64 .. 79 60,211,133,230,220,105, 92, 41, 55, 46,245, 40,244,102,143, 54, // 80 .. 95 65, 25, 63,161, 1,216, 80, 73,209, 76,132,187,208, 89, 18,169, // 96 .. 111 200,196,135,130,116,188,159, 86,164,100,109,198,173,186, 3, 64, //112 .. 127 52,217,226,250,124,123, 5,202, 38,147,118,126,255, 82, 85,212, //128 .. 143 207,206, 59,227, 47, 16, 58, 17,182,189, 28, 42,223,183,170,213, //144 .. 159 119,248,152, 2, 44,154,163, 70,221,153,101,155,167, 43,172, 9, //160 .. 175 129, 22, 39,253, 19, 98,108,110, 79,113,224,232,178,185,112,104, //176 .. 191 218,246, 97,228,251, 34,242,193,238,210,144, 12,191,179,162,241, //192 .. 207 81, 51,145,235,249, 14,239,107, 49,192,214, 31,181,199,106,157, //208 .. 223 184, 84,204,176,115,121, 50, 45,127, 4,150,254,138,236,205, 93, //224 .. 239 222,114, 67, 29, 24, 72,243,141,128,195, 78, 66,215, 61,156,180, //240 .. 255 //--mirror-- 151,160,137, 91, 90, 15,131, 13,201, 95, 96, 53,194,233, 7,225, // 0 .. 15 140, 36,103, 30, 69,142, 8, 99, 37,240, 21, 10, 23,190, 6,148, // 16 .. 31 247,120,234, 75, 0, 26,197, 62, 94,252,219,203,117, 35, 11, 32, // 32 .. 47 57,177, 33, 88,237,149, 56, 87,174, 20,125,136,171,168, 68,175, // 48 .. 63 74,165, 71,134,139, 48, 27,166, 77,146,158,231, 83,111,229,122, // 64 .. 79 60,211,133,230,220,105, 92, 41, 55, 46,245, 40,244,102,143, 54, // 80 .. 95 65, 25, 63,161, 1,216, 80, 73,209, 76,132,187,208, 89, 18,169, // 96 .. 111 200,196,135,130,116,188,159, 86,164,100,109,198,173,186, 3, 64, //112 .. 127 52,217,226,250,124,123, 5,202, 38,147,118,126,255, 82, 85,212, //128 .. 143 207,206, 59,227, 47, 16, 58, 17,182,189, 28, 42,223,183,170,213, //144 .. 159 119,248,152, 2, 44,154,163, 70,221,153,101,155,167, 43,172, 9, //160 .. 175 129, 22, 39,253, 19, 98,108,110, 79,113,224,232,178,185,112,104, //176 .. 191 218,246, 97,228,251, 34,242,193,238,210,144, 12,191,179,162,241, //192 .. 207 81, 51,145,235,249, 14,239,107, 49,192,214, 31,181,199,106,157, //208 .. 223 184, 84,204,176,115,121, 50, 45,127, 4,150,254,138,236,205, 93, //224 .. 239 222,114, 67, 29, 24, 72,243,141,128,195, 78, 66,215, 61,156,180 //240 .. 255 /* Original unformatted table ... 151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180, 151,160,137,91,90,15, 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 */ }; //--------------------------------------------------------------------- /* * Helper functions to compute gradients-dot-residualvectors (1D to 4D) * Note that these generate gradients of more than unit length. To make * a close match with the value range of classic Perlin noise, the final * noise values need to be rescaled to fit nicely within [-1,1]. * (The simplex noise functions as such also have different scaling.) * Note also that these noise functions are the most practical and useful * signed version of Perlin noise. To return values according to the * RenderMan specification from the SL noise() and pnoise() functions, * the noise values need to be scaled and offset to [0,1], like this: * float SLnoise = (SimplexNoise1234::noise(x,y,z) + 1.0) * 0.5; */ float SimplexNoise1234::grad( int hash, float x ) { int h = hash & 15; float grad = 1.0f + (h & 7); // Gradient value 1.0, 2.0, ..., 8.0 if (h&8) grad = -grad; // Set a random sign for the gradient return ( grad * x ); // Multiply the gradient with the distance } float SimplexNoise1234::grad( int hash, float x, float y ) { int h = hash & 7; // Convert low 3 bits of hash code float u = h<4 ? x : y; // into 8 simple gradient directions, float v = h<4 ? y : x; // and compute the dot product with (x,y). return ((h&1)? -u : u) + ((h&2)? -2.0f*v : 2.0f*v); } float SimplexNoise1234::grad( int hash, float x, float y , float z ) { int h = hash & 15; // Convert low 4 bits of hash code into 12 simple float u = h<8 ? x : y; // gradient directions, and compute dot product. float v = h<4 ? y : h==12||h==14 ? x : z; // Fix repeats at h = 12 to 15 return ((h&1)? -u : u) + ((h&2)? -v : v); } float SimplexNoise1234::grad( int hash, float x, float y, float z, float t ) { int h = hash & 31; // Convert low 5 bits of hash code into 32 simple float u = h<24 ? x : y; // gradient directions, and compute dot product. float v = h<16 ? y : z; float w = h<8 ? z : t; return ((h&1)? -u : u) + ((h&2)? -v : v) + ((h&4)? -w : w); } // A lookup table to traverse the simplex around a given point in 4D. // Details can be found where this table is used, in the 4D noise method. /* TODO: This should not be required, backport it from Bill's GLSL code! */ static unsigned char simplex[64][4] = { {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0} }; // 1D simplex noise float SimplexNoise1234::noise(float x) { int i0 = FASTFLOOR(x); int i1 = i0 + 1; float x0 = x - i0; float x1 = x0 - 1.0f; float n0, n1; float t0 = 1.0f - x0*x0; // if(t0 < 0.0f) t0 = 0.0f; t0 *= t0; n0 = t0 * t0 * grad(perm[i0 & 0xff], x0); float t1 = 1.0f - x1*x1; // if(t1 < 0.0f) t1 = 0.0f; t1 *= t1; n1 = t1 * t1 * grad(perm[i1 & 0xff], x1); // The maximum value of this noise is 8*(3/4)^4 = 2.53125 // A factor of 0.395 would scale to fit exactly within [-1,1], but // we want to match PRMan's 1D noise, so we scale it down some more. return 0.25f * (n0 + n1); } // 2D simplex noise float SimplexNoise1234::noise(float x, float y) { #define F2 0.366025403f // F2 = 0.5*(sqrt(3.0)-1.0) #define G2 0.211324865f // G2 = (3.0-Math.sqrt(3.0))/6.0 float n0, n1, n2; // Noise contributions from the three corners // Skew the input space to determine which simplex cell we're in float s = (x+y)*F2; // Hairy factor for 2D float xs = x + s; float ys = y + s; int i = FASTFLOOR(xs); int j = FASTFLOOR(ys); float t = (float)(i+j)*G2; float X0 = i-t; // Unskew the cell origin back to (x,y) space float Y0 = j-t; float x0 = x-X0; // The x,y distances from the cell origin float y0 = y-Y0; // For the 2D case, the simplex shape is an equilateral triangle. // Determine which simplex we are in. int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords if(x0>y0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where // c = (3-sqrt(3))/6 float x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords float y1 = y0 - j1 + G2; float x2 = x0 - 1.0f + 2.0f * G2; // Offsets for last corner in (x,y) unskewed coords float y2 = y0 - 1.0f + 2.0f * G2; // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds int ii = i & 0xff; int jj = j & 0xff; // Calculate the contribution from the three corners float t0 = 0.5f - x0*x0-y0*y0; if(t0 < 0.0f) n0 = 0.0f; else { t0 *= t0; n0 = t0 * t0 * grad(perm[ii+perm[jj]], x0, y0); } float t1 = 0.5f - x1*x1-y1*y1; if(t1 < 0.0f) n1 = 0.0f; else { t1 *= t1; n1 = t1 * t1 * grad(perm[ii+i1+perm[jj+j1]], x1, y1); } float t2 = 0.5f - x2*x2-y2*y2; if(t2 < 0.0f) n2 = 0.0f; else { t2 *= t2; n2 = t2 * t2 * grad(perm[ii+1+perm[jj+1]], x2, y2); } // Add contributions from each corner to get the final noise value. // The result is scaled to return values in the interval [-1,1]. return 40.0f * (n0 + n1 + n2); // TODO: The scale factor is preliminary! } // 3D simplex noise float SimplexNoise1234::noise(float x, float y, float z) { // Simple skewing factors for the 3D case #define F3 0.333333333f #define G3 0.166666667f float n0, n1, n2, n3; // Noise contributions from the four corners // Skew the input space to determine which simplex cell we're in float s = (x+y+z)*F3; // Very nice and simple skew factor for 3D float xs = x+s; float ys = y+s; float zs = z+s; int i = FASTFLOOR(xs); int j = FASTFLOOR(ys); int k = FASTFLOOR(zs); float t = (float)(i+j+k)*G3; float X0 = i-t; // Unskew the cell origin back to (x,y,z) space float Y0 = j-t; float Z0 = k-t; float x0 = x-X0; // The x,y,z distances from the cell origin float y0 = y-Y0; float z0 = z-Z0; // For the 3D case, the simplex shape is a slightly irregular tetrahedron. // Determine which simplex we are in. int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords /* This code would benefit from a backport from the GLSL version! */ if(x0>=y0) { if(y0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order } else { // x0<y0 if(y0<z0) { i1=0; j1=0; k1=1; i2=0; j2=1; k2=1; } // Z Y X order else if(x0<z0) { i1=0; j1=1; k1=0; i2=0; j2=1; k2=1; } // Y Z X order else { i1=0; j1=1; k1=0; i2=1; j2=1; k2=0; } // Y X Z order } // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where // c = 1/6. float x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords float y1 = y0 - j1 + G3; float z1 = z0 - k1 + G3; float x2 = x0 - i2 + 2.0f*G3; // Offsets for third corner in (x,y,z) coords float y2 = y0 - j2 + 2.0f*G3; float z2 = z0 - k2 + 2.0f*G3; float x3 = x0 - 1.0f + 3.0f*G3; // Offsets for last corner in (x,y,z) coords float y3 = y0 - 1.0f + 3.0f*G3; float z3 = z0 - 1.0f + 3.0f*G3; // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds int ii = i & 0xff; int jj = j & 0xff; int kk = k & 0xff; // Calculate the contribution from the four corners float t0 = 0.6f - x0*x0 - y0*y0 - z0*z0; if (t0 < 0.0f) n0 = 0.0f; else { t0 *= t0; n0 = t0 * t0 * grad(perm[ii+perm[jj+perm[kk]]], x0, y0, z0); } float t1 = 0.6f - x1*x1 - y1*y1 - z1*z1; if (t1 < 0.0f) n1 = 0.0f; else { t1 *= t1; n1 = t1 * t1 * grad(perm[ii+i1+perm[jj+j1+perm[kk+k1]]], x1, y1, z1); } float t2 = 0.6f - x2*x2 - y2*y2 - z2*z2; if (t2 < 0.0f) n2 = 0.0f; else { t2 *= t2; n2 = t2 * t2 * grad(perm[ii+i2+perm[jj+j2+perm[kk+k2]]], x2, y2, z2); } float t3 = 0.6f - x3*x3 - y3*y3 - z3*z3; if (t3<0.0f) n3 = 0.0f; else { t3 *= t3; n3 = t3 * t3 * grad(perm[ii+1+perm[jj+1+perm[kk+1]]], x3, y3, z3); } // Add contributions from each corner to get the final noise value. // The result is scaled to stay just inside [-1,1] return 32.0f * (n0 + n1 + n2 + n3); // TODO: The scale factor is preliminary! } // 4D simplex noise float SimplexNoise1234::noise(float x, float y, float z, float w) { // The skewing and unskewing factors are hairy again for the 4D case #define F4 0.309016994f // F4 = (Math.sqrt(5.0)-1.0)/4.0 #define G4 0.138196601f // G4 = (5.0-Math.sqrt(5.0))/20.0 float n0, n1, n2, n3, n4; // Noise contributions from the five corners // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in float s = (x + y + z + w) * F4; // Factor for 4D skewing float xs = x + s; float ys = y + s; float zs = z + s; float ws = w + s; int i = FASTFLOOR(xs); int j = FASTFLOOR(ys); int k = FASTFLOOR(zs); int l = FASTFLOOR(ws); float t = (i + j + k + l) * G4; // Factor for 4D unskewing float X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space float Y0 = j - t; float Z0 = k - t; float W0 = l - t; float x0 = x - X0; // The x,y,z,w distances from the cell origin float y0 = y - Y0; float z0 = z - Z0; float w0 = w - W0; // For the 4D case, the simplex is a 4D shape I won't even try to describe. // To find out which of the 24 possible simplices we're in, we need to // determine the magnitude ordering of x0, y0, z0 and w0. // The method below is a good way of finding the ordering of x,y,z,w and // then find the correct traversal order for the simplex we’re in. // First, six pair-wise comparisons are performed between each possible pair // of the four coordinates, and the results are used to add up binary bits // for an integer index. int c1 = (x0 > y0) ? 32 : 0; int c2 = (x0 > z0) ? 16 : 0; int c3 = (y0 > z0) ? 8 : 0; int c4 = (x0 > w0) ? 4 : 0; int c5 = (y0 > w0) ? 2 : 0; int c6 = (z0 > w0) ? 1 : 0; int c = c1 + c2 + c3 + c4 + c5 + c6; int i1, j1, k1, l1; // The integer offsets for the second simplex corner int i2, j2, k2, l2; // The integer offsets for the third simplex corner int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w // impossible. Only the 24 indices which have non-zero entries make any sense. // We use a thresholding to set the coordinates in turn from the largest magnitude. // The number 3 in the "simplex" array is at the position of the largest coordinate. i1 = simplex[c][0]>=3 ? 1 : 0; j1 = simplex[c][1]>=3 ? 1 : 0; k1 = simplex[c][2]>=3 ? 1 : 0; l1 = simplex[c][3]>=3 ? 1 : 0; // The number 2 in the "simplex" array is at the second largest coordinate. i2 = simplex[c][0]>=2 ? 1 : 0; j2 = simplex[c][1]>=2 ? 1 : 0; k2 = simplex[c][2]>=2 ? 1 : 0; l2 = simplex[c][3]>=2 ? 1 : 0; // The number 1 in the "simplex" array is at the second smallest coordinate. i3 = simplex[c][0]>=1 ? 1 : 0; j3 = simplex[c][1]>=1 ? 1 : 0; k3 = simplex[c][2]>=1 ? 1 : 0; l3 = simplex[c][3]>=1 ? 1 : 0; // The fifth corner has all coordinate offsets = 1, so no need to look that up. float x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords float y1 = y0 - j1 + G4; float z1 = z0 - k1 + G4; float w1 = w0 - l1 + G4; float x2 = x0 - i2 + 2.0f*G4; // Offsets for third corner in (x,y,z,w) coords float y2 = y0 - j2 + 2.0f*G4; float z2 = z0 - k2 + 2.0f*G4; float w2 = w0 - l2 + 2.0f*G4; float x3 = x0 - i3 + 3.0f*G4; // Offsets for fourth corner in (x,y,z,w) coords float y3 = y0 - j3 + 3.0f*G4; float z3 = z0 - k3 + 3.0f*G4; float w3 = w0 - l3 + 3.0f*G4; float x4 = x0 - 1.0f + 4.0f*G4; // Offsets for last corner in (x,y,z,w) coords float y4 = y0 - 1.0f + 4.0f*G4; float z4 = z0 - 1.0f + 4.0f*G4; float w4 = w0 - 1.0f + 4.0f*G4; // Wrap the integer indices at 256, to avoid indexing perm[] out of bounds int ii = i & 0xff; int jj = j & 0xff; int kk = k & 0xff; int ll = l & 0xff; // Calculate the contribution from the five corners float t0 = 0.6f - x0*x0 - y0*y0 - z0*z0 - w0*w0; if (t0 < 0.0f) n0 = 0.0f; else { t0 *= t0; n0 = t0 * t0 * grad(perm[ii+perm[jj+perm[kk+perm[ll]]]], x0, y0, z0, w0); } float t1 = 0.6f - x1*x1 - y1*y1 - z1*z1 - w1*w1; if (t1 < 0.0f) n1 = 0.0f; else { t1 *= t1; n1 = t1 * t1 * grad(perm[ii+i1+perm[jj+j1+perm[kk+k1+perm[ll+l1]]]], x1, y1, z1, w1); } float t2 = 0.6f - x2*x2 - y2*y2 - z2*z2 - w2*w2; if (t2 < 0.0f) n2 = 0.0f; else { t2 *= t2; n2 = t2 * t2 * grad(perm[ii+i2+perm[jj+j2+perm[kk+k2+perm[ll+l2]]]], x2, y2, z2, w2); } float t3 = 0.6f - x3*x3 - y3*y3 - z3*z3 - w3*w3; if (t3 < 0.0f) n3 = 0.0f; else { t3 *= t3; n3 = t3 * t3 * grad(perm[ii+i3+perm[jj+j3+perm[kk+k3+perm[ll+l3]]]], x3, y3, z3, w3); } float t4 = 0.6f - x4*x4 - y4*y4 - z4*z4 - w4*w4; if (t4 < 0.0f) n4 = 0.0f; else { t4 *= t4; n4 = t4 * t4 * grad(perm[ii+1+perm[jj+1+perm[kk+1+perm[ll+1]]]], x4, y4, z4, w4); } // Sum up and scale the result to cover the range [-1,1] return 27.0f * (n0 + n1 + n2 + n3 + n4); // TODO: The scale factor is preliminary! } //---------------------------------------------------------------------
[ "kretash@gmail.com" ]
kretash@gmail.com
21caae892db84425ca789438b8b733ab1ce6c50e
6833036df7cbb10696e0cfdbb34aae83f16c0923
/Week1/templateClasses/templateClasses/ThreeDArray.h
4525363b53f2967c09c1b43260f768f4f9e2e398
[]
no_license
spboom/c-plus-plus
85217624a5fe7b0ead999535cbe59f3611217b98
19484a67853cb9052d4d507a93621f45c6e81a61
refs/heads/master
2016-09-05T19:10:32.415197
2014-11-13T08:22:00
2014-11-13T08:22:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,628
h
#pragma once template <typename T> class ThreeDArray { public: T* _array; int xSize, ySize, zSize; ThreeDArray() : ThreeDArray(10, 10, 10){ }; ThreeDArray(int x, int y, int z) { xSize = x; ySize = y; zSize = z; _array = new T[xSize * ySize * zSize]; } ThreeDArray(const ThreeDArray& other) { copy(other); } ThreeDArray<T>& operator =(const ThreeDArray& other) { if (this != &other) { clean(); copy(other); } return *this; } ThreeDArray(ThreeDArray&& move) { set(move); move.clean(); } ThreeDArray<T>& operator=(ThreeDArray&& move) { if (this != &move) { clean(); set(move); move.clean(); } return *this; } void put(int x, int y, int z, T value) { _array[index(x, y, z)] = value; } T get(int x, int y, int z) { return _array[index(x, y, z)]; } int index(int x, int y, int z) { if (x >= xSize || y >= ySize || z >= zSize) throw exception("Out of Bounds"); return ySize * xSize * z + xSize * y + x; } int get_x_size(){ return xSize; }; int get_y_size(){ return ySize; }; int get_z_size(){ return zSize; }; ~ThreeDArray(){ clean(); } private: void clean() { delete[] _array; xSize = 0; ySize = 0; zSize = 0; } void set(const ThreeDArray& value) { _array = value._array; xSize = value.xSize; ySize = value.ySize; zSize = value.zSize; } void copy(const ThreeDArray& value) { int length = value.xSize * value.ySize * value.zSize; _array = new T[length]; for (int i = 0; i < length; i++) { _array[i] = value._array[i]; } xSize = value.xSize; ySize = value.ySize; zSize = value.zSize; } };
[ "hyppo8@hotmail.com" ]
hyppo8@hotmail.com
9b54cba4d2ae833c4aff2dbf332b3611a7424bae
cec1016b6392a1514e241db0f10f27034fd45da1
/LibrarySystem/ui_modifyuserinfodialog.h
8f239ec275840f249e448d21c62202fd936c9cf4
[]
no_license
zh-bupt/qt_project
50a89e34b5b5909e1197a7997f517a477c6774c3
cbe8ddc19fc595efb7362c4ccb82ce062b15eb08
refs/heads/master
2021-07-18T18:18:41.411057
2017-10-26T15:25:34
2017-10-26T15:25:34
108,382,471
0
0
null
null
null
null
UTF-8
C++
false
false
5,653
h
/******************************************************************************** ** Form generated from reading UI file 'modifyuserinfodialog.ui' ** ** Created by: Qt User Interface Compiler version 5.8.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_MODIFYUSERINFODIALOG_H #define UI_MODIFYUSERINFODIALOG_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QComboBox> #include <QtWidgets/QDialog> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QPushButton> #include <QtWidgets/QSpinBox> QT_BEGIN_NAMESPACE class Ui_ModifyUserInfoDialog { public: QLabel *label; QLabel *label_2; QLabel *label_3; QLabel *label_4; QLabel *label_5; QLabel *label_6; QLineEdit *name; QLineEdit *id; QLineEdit *password; QComboBox *academy; QComboBox *type; QPushButton *btn_comfirm; QPushButton *btn_cancel; QSpinBox *fine; QPushButton *show_password; void setupUi(QDialog *ModifyUserInfoDialog) { if (ModifyUserInfoDialog->objectName().isEmpty()) ModifyUserInfoDialog->setObjectName(QStringLiteral("ModifyUserInfoDialog")); ModifyUserInfoDialog->resize(391, 255); label = new QLabel(ModifyUserInfoDialog); label->setObjectName(QStringLiteral("label")); label->setGeometry(QRect(50, 35, 60, 16)); label_2 = new QLabel(ModifyUserInfoDialog); label_2->setObjectName(QStringLiteral("label_2")); label_2->setGeometry(QRect(50, 65, 60, 16)); label_3 = new QLabel(ModifyUserInfoDialog); label_3->setObjectName(QStringLiteral("label_3")); label_3->setGeometry(QRect(50, 95, 60, 16)); label_4 = new QLabel(ModifyUserInfoDialog); label_4->setObjectName(QStringLiteral("label_4")); label_4->setGeometry(QRect(215, 95, 60, 16)); label_5 = new QLabel(ModifyUserInfoDialog); label_5->setObjectName(QStringLiteral("label_5")); label_5->setGeometry(QRect(50, 125, 60, 16)); label_6 = new QLabel(ModifyUserInfoDialog); label_6->setObjectName(QStringLiteral("label_6")); label_6->setGeometry(QRect(50, 155, 60, 16)); name = new QLineEdit(ModifyUserInfoDialog); name->setObjectName(QStringLiteral("name")); name->setGeometry(QRect(90, 30, 241, 21)); id = new QLineEdit(ModifyUserInfoDialog); id->setObjectName(QStringLiteral("id")); id->setGeometry(QRect(90, 60, 241, 21)); id->setAutoFillBackground(false); id->setInputMethodHints(Qt::ImhDigitsOnly); password = new QLineEdit(ModifyUserInfoDialog); password->setObjectName(QStringLiteral("password")); password->setGeometry(QRect(90, 120, 151, 21)); password->setEchoMode(QLineEdit::Password); academy = new QComboBox(ModifyUserInfoDialog); academy->setObjectName(QStringLiteral("academy")); academy->setGeometry(QRect(90, 90, 111, 26)); type = new QComboBox(ModifyUserInfoDialog); type->setObjectName(QStringLiteral("type")); type->setGeometry(QRect(250, 90, 81, 26)); btn_comfirm = new QPushButton(ModifyUserInfoDialog); btn_comfirm->setObjectName(QStringLiteral("btn_comfirm")); btn_comfirm->setGeometry(QRect(70, 190, 113, 32)); btn_cancel = new QPushButton(ModifyUserInfoDialog); btn_cancel->setObjectName(QStringLiteral("btn_cancel")); btn_cancel->setGeometry(QRect(210, 190, 113, 32)); fine = new QSpinBox(ModifyUserInfoDialog); fine->setObjectName(QStringLiteral("fine")); fine->setGeometry(QRect(90, 150, 241, 24)); fine->setMaximum(1000); show_password = new QPushButton(ModifyUserInfoDialog); show_password->setObjectName(QStringLiteral("show_password")); show_password->setGeometry(QRect(250, 115, 81, 32)); retranslateUi(ModifyUserInfoDialog); QMetaObject::connectSlotsByName(ModifyUserInfoDialog); } // setupUi void retranslateUi(QDialog *ModifyUserInfoDialog) { ModifyUserInfoDialog->setWindowTitle(QApplication::translate("ModifyUserInfoDialog", "Dialog", Q_NULLPTR)); label->setText(QApplication::translate("ModifyUserInfoDialog", "\345\247\223 \345\220\215", Q_NULLPTR)); label_2->setText(QApplication::translate("ModifyUserInfoDialog", "\345\255\246 \345\217\267", Q_NULLPTR)); label_3->setText(QApplication::translate("ModifyUserInfoDialog", "\345\255\246 \351\231\242", Q_NULLPTR)); label_4->setText(QApplication::translate("ModifyUserInfoDialog", "\347\261\273 \345\236\213", Q_NULLPTR)); label_5->setText(QApplication::translate("ModifyUserInfoDialog", "\345\257\206 \347\240\201", Q_NULLPTR)); label_6->setText(QApplication::translate("ModifyUserInfoDialog", "\346\254\240 \346\254\276", Q_NULLPTR)); btn_comfirm->setText(QApplication::translate("ModifyUserInfoDialog", "\344\277\235\345\255\230", Q_NULLPTR)); btn_cancel->setText(QApplication::translate("ModifyUserInfoDialog", "\345\217\226\346\266\210", Q_NULLPTR)); show_password->setText(QApplication::translate("ModifyUserInfoDialog", "\346\230\276\347\244\272", Q_NULLPTR)); } // retranslateUi }; namespace Ui { class ModifyUserInfoDialog: public Ui_ModifyUserInfoDialog {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_MODIFYUSERINFODIALOG_H
[ "zh2015211203@bupt.edu.cn" ]
zh2015211203@bupt.edu.cn
b7e5efaccfbfe77aa351b2e03f76d16c21365abc
ecb4e3e5239d4dca80c9cf63660d2e2a55d413e4
/cf 807A/main.cpp
1ea039436f25ef9ecb5da139f308d8d19572ecb0
[]
no_license
daatto/codes
15a126577be5f03754d0f7497fc545b53ad10986
9be57580685e3f4a89159f901d0bf3135913483a
refs/heads/master
2021-01-20T22:47:48.308137
2017-08-26T19:58:24
2017-08-26T19:58:24
81,817,179
0
0
null
null
null
null
UTF-8
C++
false
false
650
cpp
#include <bits/stdc++.h> using namespace std; int main() { //cout << "Hello world!" << endl; int n; cin>>n; vector<int>v; vector<int>vv; vector<int>z; for(int i=0;i<n;i++) { int x,y; cin>>x>>y; v.push_back(x); vv.push_back(y); } int c=0; for(int i=0;i<n;i++) { if(v[i]!=vv[i]) {cout<<"rated"<<endl; return 0;} else c++; } if(c==n) { z=v; sort(z.begin(),z.end()); reverse(z.begin(),z.end()); if(v==z) {cout<<"maybe"<<endl;} else cout<<"unrated"<<endl; } return 0; }
[ "daudahmed000@gmail.com" ]
daudahmed000@gmail.com
c39d4ea04550760dae24f4d3755eac0822092716
8d445f5cfa61b1fc34749792db13f538f7baba03
/Trabalho 1 - Princípio da Responsabilidade Única/Exemplo_2-SRP/filmes.cpp
1134c9ffffb335da2827a9d67c226d6b55df05fb
[]
no_license
renandantasp/POOA
3be5df42faf35e4e93e1b2b8ecf02de07bdaba93
77c4fac099159f5ddc4b75e30a14fcb59eeb0ed2
refs/heads/main
2023-02-12T14:32:32.142408
2021-01-07T15:30:35
2021-01-07T15:30:35
314,187,409
0
1
null
2020-12-05T17:02:27
2020-11-19T08:46:37
C++
UTF-8
C++
false
false
2,239
cpp
#include "filmes.h" Filmes::Filmes(){ numFilmes = 0; } bool Filmes::adicionaFilme(std::string t, std::string d, std::string g, int a){ Filme f; f.titulo = t; f.diretor = d; f.genero = g; f.ano = a; for(int i = 0; i < filmes.size(); i++){ if (f == filmes[i]){ std::cout << "Filme já incluido na lista"; return false; } } filmes.push_back(f); numFilmes++; return true; } bool Filmes::removeFilme(Filme& f){ for(int i = 0; i < filmes.size(); i++){ if (f == filmes[i]){ filmes.erase(filmes.begin()+i); numFilmes--; return true; } } std::cout << "Filme não encontrado"; return false; } bool Filmes::trocaFilme(int pos1, int pos2){ if(pos1 < numFilmes && pos2 < numFilmes && pos1 != pos2){ Filme f = filmes[pos1]; filmes[pos1] = filmes[pos2]; filmes[pos2] = f; std::cout << "\"" << filmes[pos1].titulo << "\" trocou de posição com \"" << filmes[pos2].titulo << "\" \n"; return true; } return false; } bool Filmes::leFilme(Filme& f, int pos) const{ if (pos > numFilmes) return false; f = filmes[pos]; return true; } int Filmes::getNumFilmes() const{ return numFilmes; } bool Filmes::imprimeFilme(int pos) const{ if (pos <= numFilmes){ std::cout << "Título: \"" << filmes[pos].titulo << "\"" << std::endl; std::cout << "Diretor: " << filmes[pos].diretor << std::endl; std::cout << "Gênero: " << filmes[pos].genero << std::endl; std::cout << "Ano: " << filmes[pos].ano << std::endl; std::cout << std::endl; return true; } std::cout << "Série não encontrada." << std::endl; return false; } void Filmes::imprimeFilmes() const{ for(int i = 0; i < numFilmes; i++){ std::cout << "Filme " << i+1 << std::endl; std::cout << "Título: \"" << filmes[i].titulo << "\"" << std::endl; std::cout << "Diretor: " << filmes[i].diretor << std::endl; std::cout << "Gênero: " << filmes[i].genero << std::endl; std::cout << "Ano: " << filmes[i].ano << std::endl; std::cout << std::endl; } }
[ "renandantasp@gmail.com" ]
renandantasp@gmail.com
75753cd2fe60c34b939acda386c6df62870b8bef
3736faa3c19a9de9dee75a74fb8b1d07500688c1
/Instruction.hpp
4b5d9cb1111a09b2af4c693f82fa16f807458335
[ "CC-BY-3.0" ]
permissive
supermaximo93/Toaster-VM
f4fb4c69414249a1ec9bc93615eb91a25cad64dc
de574d9ec807640266210e1e3ce52a38b417333e
refs/heads/master
2021-01-01T19:55:27.077256
2012-02-27T19:25:51
2012-02-27T19:25:51
3,317,033
0
0
null
null
null
null
UTF-8
C++
false
false
340
hpp
/* * Instruction.hpp * * Created on: 7 Feb 2012 * Author: Max Foster */ #ifndef INSTRUCTION_HPP #define INSTRUCTION_HPP #include "Token.hpp" struct Instruction { Token label, opcode, operand1, operand2; void clear() { label.clear(); opcode.clear(); operand1.clear(); operand2.clear(); } }; #endif // INSTRUCTION_HPP
[ "supermaximo93@gmail.com" ]
supermaximo93@gmail.com
8a9483a550608cd0b3a1c38e85997c4744d7b6af
6891e26b35b9a9e2536b08ae41766a5c02c9726b
/KalmanFilterinCPP/KalmanFilterinCPP/xzgeev.cpp
78e07f2ef7ba5b6a40940aacb746090e282849a4
[ "MIT" ]
permissive
YDWWYD/MECH552-Project
51df0852fe50f14d8becce4b22702612be82246e
7df8b583d3b4fcd46d71052dc72a767ea1440426
refs/heads/master
2020-03-16T03:38:36.266394
2018-06-11T18:42:16
2018-06-11T18:42:16
132,491,996
0
0
null
null
null
null
UTF-8
C++
false
false
11,678
cpp
/* * Academic License - for use in teaching, academic research, and meeting * course requirements at degree granting institutions only. Not for * government, commercial, or other organizational use. * File: xzgeev.c * * MATLAB Coder version : 3.4 * C/C++ source code generated on : 14-May-2018 23:15:09 */ /* Include Files */ #include "rt_nonfinite.h" #include "butterBandpassOnly.h" #include "xzgeev.h" #include "butterBandpassOnly_emxutil.h" #include "xzlartg.h" #include "xzlascl.h" #include "xzhgeqz.h" #include "relop.h" #include "butterBandpassOnly_rtwutil.h" /* Function Definitions */ /* * Arguments : const emxArray_creal_T *A * int *info * emxArray_creal_T *alpha1 * emxArray_creal_T *beta1 * Return Type : void */ void xzgeev(const emxArray_creal_T *A, int *info, emxArray_creal_T *alpha1, emxArray_creal_T *beta1) { emxArray_creal_T *At; int jcol; int ii; int nzcount; double anrm; boolean_T exitg1; double absxk; boolean_T ilascl; double anrmto; int ilo; double ctoc; int ihi; boolean_T notdone; int exitg3; double cfrom1; int i; double cto1; int j; double mul; creal_T b_At; creal_T c_At; double c; creal_T atmp; boolean_T exitg4; int exitg2; boolean_T d_At; double stemp_re; emxInit_creal_T(&At, 2); jcol = At->size[0] * At->size[1]; At->size[0] = A->size[0]; At->size[1] = A->size[1]; emxEnsureCapacity_creal_T(At, jcol); ii = A->size[0] * A->size[1]; for (jcol = 0; jcol < ii; jcol++) { At->data[jcol] = A->data[jcol]; } nzcount = 0; jcol = alpha1->size[0]; alpha1->size[0] = At->size[0]; emxEnsureCapacity_creal_T1(alpha1, jcol); ii = At->size[0]; for (jcol = 0; jcol < ii; jcol++) { alpha1->data[jcol].re = 0.0; alpha1->data[jcol].im = 0.0; } jcol = beta1->size[0]; beta1->size[0] = At->size[0]; emxEnsureCapacity_creal_T1(beta1, jcol); ii = At->size[0]; for (jcol = 0; jcol < ii; jcol++) { beta1->data[jcol].re = 0.0; beta1->data[jcol].im = 0.0; } if (!((At->size[0] == 0) || (At->size[1] == 0))) { anrm = 0.0; jcol = 0; exitg1 = false; while ((!exitg1) && (jcol <= At->size[0] * At->size[1] - 1)) { absxk = rt_hypotd_snf(At->data[jcol].re, At->data[jcol].im); if (rtIsNaN(absxk)) { anrm = rtNaN; exitg1 = true; } else { if (absxk > anrm) { anrm = absxk; } jcol++; } } if (!((!rtIsInf(anrm)) && (!rtIsNaN(anrm)))) { jcol = alpha1->size[0]; alpha1->size[0] = At->size[0]; emxEnsureCapacity_creal_T1(alpha1, jcol); ii = At->size[0]; for (jcol = 0; jcol < ii; jcol++) { alpha1->data[jcol].re = rtNaN; alpha1->data[jcol].im = 0.0; } jcol = beta1->size[0]; beta1->size[0] = At->size[0]; emxEnsureCapacity_creal_T1(beta1, jcol); ii = At->size[0]; for (jcol = 0; jcol < ii; jcol++) { beta1->data[jcol].re = rtNaN; beta1->data[jcol].im = 0.0; } } else { ilascl = false; anrmto = anrm; if ((anrm > 0.0) && (anrm < 6.7178761075670888E-139)) { anrmto = 6.7178761075670888E-139; ilascl = true; } else { if (anrm > 1.4885657073574029E+138) { anrmto = 1.4885657073574029E+138; ilascl = true; } } if (ilascl) { absxk = anrm; ctoc = anrmto; notdone = true; while (notdone) { cfrom1 = absxk * 2.0041683600089728E-292; cto1 = ctoc / 4.9896007738368E+291; if ((cfrom1 > ctoc) && (ctoc != 0.0)) { mul = 2.0041683600089728E-292; absxk = cfrom1; } else if (cto1 > absxk) { mul = 4.9896007738368E+291; ctoc = cto1; } else { mul = ctoc / absxk; notdone = false; } jcol = At->size[0] * At->size[1]; emxEnsureCapacity_creal_T(At, jcol); jcol = At->size[0]; ii = At->size[1]; ii *= jcol; for (jcol = 0; jcol < ii; jcol++) { At->data[jcol].re *= mul; At->data[jcol].im *= mul; } } } ilo = 0; ihi = At->size[0]; if (At->size[0] <= 1) { ihi = 1; } else { do { exitg3 = 0; i = 0; j = 0; notdone = false; ii = ihi; exitg1 = false; while ((!exitg1) && (ii > 0)) { nzcount = 0; i = ii; j = ihi; jcol = 1; exitg4 = false; while ((!exitg4) && (jcol <= ihi)) { d_At = ((At->data[(ii + At->size[0] * (jcol - 1)) - 1].re != 0.0) || (At->data[(ii + At->size[0] * (jcol - 1)) - 1].im != 0.0)); if (d_At || (ii == jcol)) { if (nzcount == 0) { j = jcol; nzcount = 1; jcol++; } else { nzcount = 2; exitg4 = true; } } else { jcol++; } } if (nzcount < 2) { notdone = true; exitg1 = true; } else { ii--; } } if (!notdone) { exitg3 = 2; } else { nzcount = At->size[0]; if (i != ihi) { for (jcol = 0; jcol + 1 <= nzcount; jcol++) { atmp = At->data[(i + At->size[0] * jcol) - 1]; At->data[(i + At->size[0] * jcol) - 1] = At->data[(ihi + At->size[0] * jcol) - 1]; At->data[(ihi + At->size[0] * jcol) - 1] = atmp; } } if (j != ihi) { for (jcol = 0; jcol + 1 <= ihi; jcol++) { atmp = At->data[jcol + At->size[0] * (j - 1)]; At->data[jcol + At->size[0] * (j - 1)] = At->data[jcol + At->size[0] * (ihi - 1)]; At->data[jcol + At->size[0] * (ihi - 1)] = atmp; } } ihi--; if (ihi == 1) { exitg3 = 1; } } } while (exitg3 == 0); if (exitg3 == 1) { } else { do { exitg2 = 0; i = 0; j = 0; notdone = false; jcol = ilo + 1; exitg1 = false; while ((!exitg1) && (jcol <= ihi)) { nzcount = 0; i = ihi; j = jcol; ii = ilo + 1; exitg4 = false; while ((!exitg4) && (ii <= ihi)) { d_At = ((At->data[(ii + At->size[0] * (jcol - 1)) - 1].re != 0.0) || (At->data[(ii + At->size[0] * (jcol - 1)) - 1].im != 0.0)); if (d_At || (ii == jcol)) { if (nzcount == 0) { i = ii; nzcount = 1; ii++; } else { nzcount = 2; exitg4 = true; } } else { ii++; } } if (nzcount < 2) { notdone = true; exitg1 = true; } else { jcol++; } } if (!notdone) { exitg2 = 1; } else { nzcount = At->size[0]; if (i != ilo + 1) { for (jcol = ilo; jcol + 1 <= nzcount; jcol++) { atmp = At->data[(i + At->size[0] * jcol) - 1]; At->data[(i + At->size[0] * jcol) - 1] = At->data[ilo + At->size[0] * jcol]; At->data[ilo + At->size[0] * jcol] = atmp; } } if (j != ilo + 1) { for (jcol = 0; jcol + 1 <= ihi; jcol++) { atmp = At->data[jcol + At->size[0] * (j - 1)]; At->data[jcol + At->size[0] * (j - 1)] = At->data[jcol + At->size[0] * ilo]; At->data[jcol + At->size[0] * ilo] = atmp; } } ilo++; if (ilo + 1 == ihi) { exitg2 = 1; } } } while (exitg2 == 0); } } nzcount = At->size[0]; if ((!(At->size[0] <= 1)) && (!(ihi < ilo + 3))) { for (jcol = ilo; jcol + 1 < ihi - 1; jcol++) { for (ii = ihi - 1; ii + 1 > jcol + 2; ii--) { b_At = At->data[(ii + At->size[0] * jcol) - 1]; c_At = At->data[ii + At->size[0] * jcol]; xzlartg(b_At, c_At, &c, &atmp, &At->data[(ii + At->size[0] * jcol) - 1]); At->data[ii + At->size[0] * jcol].re = 0.0; At->data[ii + At->size[0] * jcol].im = 0.0; for (j = jcol + 1; j + 1 <= nzcount; j++) { absxk = atmp.re * At->data[ii + At->size[0] * j].re - atmp.im * At->data[ii + At->size[0] * j].im; ctoc = atmp.re * At->data[ii + At->size[0] * j].im + atmp.im * At->data[ii + At->size[0] * j].re; stemp_re = c * At->data[(ii + At->size[0] * j) - 1].re + absxk; absxk = c * At->data[(ii + At->size[0] * j) - 1].im + ctoc; ctoc = At->data[(ii + At->size[0] * j) - 1].re; cfrom1 = At->data[(ii + At->size[0] * j) - 1].im; cto1 = At->data[(ii + At->size[0] * j) - 1].im; mul = At->data[(ii + At->size[0] * j) - 1].re; At->data[ii + At->size[0] * j].re = c * At->data[ii + At->size[0] * j].re - (atmp.re * ctoc + atmp.im * cfrom1); At->data[ii + At->size[0] * j].im = c * At->data[ii + At->size[0] * j].im - (atmp.re * cto1 - atmp.im * mul); At->data[(ii + At->size[0] * j) - 1].re = stemp_re; At->data[(ii + At->size[0] * j) - 1].im = absxk; } atmp.re = -atmp.re; atmp.im = -atmp.im; for (i = 0; i + 1 <= ihi; i++) { absxk = atmp.re * At->data[i + At->size[0] * (ii - 1)].re - atmp.im * At->data[i + At->size[0] * (ii - 1)].im; ctoc = atmp.re * At->data[i + At->size[0] * (ii - 1)].im + atmp.im * At->data[i + At->size[0] * (ii - 1)].re; stemp_re = c * At->data[i + At->size[0] * ii].re + absxk; absxk = c * At->data[i + At->size[0] * ii].im + ctoc; ctoc = At->data[i + At->size[0] * ii].re; cfrom1 = At->data[i + At->size[0] * ii].im; cto1 = At->data[i + At->size[0] * ii].im; mul = At->data[i + At->size[0] * ii].re; At->data[i + At->size[0] * (ii - 1)].re = c * At->data[i + At->size[0] * (ii - 1)].re - (atmp.re * ctoc + atmp.im * cfrom1); At->data[i + At->size[0] * (ii - 1)].im = c * At->data[i + At->size[0] * (ii - 1)].im - (atmp.re * cto1 - atmp.im * mul); At->data[i + At->size[0] * ii].re = stemp_re; At->data[i + At->size[0] * ii].im = absxk; } } } } xzhgeqz(At, ilo + 1, ihi, &nzcount, alpha1, beta1); if ((nzcount == 0) && ilascl) { xzlascl(anrmto, anrm, alpha1); } } } emxFree_creal_T(&At); *info = nzcount; } /* * File trailer for xzgeev.c * * [EOF] */
[ "wangyudiks@gmail.com" ]
wangyudiks@gmail.com
32b8e9d453f905eb7b143343d5a5f920136b455c
55d5c8423a2f1dc74996636a92a3c09dc0e01455
/R/RInside_0.2.5/inst/examples/standard/rinside_sample4.cpp
e7c6b9fa16dd37b2d0ef8532b5d2d454ae4b6e27
[]
no_license
chungers/lab616_third_party
ebe89cbf4ed6f5547e41d0118d7b89a9f6e58cdf
08256391ae533e6889f6850e1255bbb6743d4f37
refs/heads/master
2021-05-28T07:33:29.493301
2013-06-01T20:48:29
2013-06-01T20:48:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,789
cpp
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4; -*- // // Another simple example inspired by an r-devel mail by Abhijit Bera // // Copyright (C) 2009 Dirk Eddelbuettel // Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois #include <RInside.h> // for the embedded R via RInside #include <iomanip> int main(int argc, char *argv[]) { try { RInside R(argc, argv); // create an embedded R instance std::string txt = "suppressMessages(library(fPortfolio)); " "lppData <- 100 * LPP2005.RET[, 1:6]; " "ewSpec <- portfolioSpec(); " "nAssets <- ncol(lppData); "; R.parseEvalQ(txt); // prepare problem const double dvec[6] = { 0.1, 0.1, 0.1, 0.1, 0.3, 0.3 }; // choose any weights const std::vector<double> w(dvec, &dvec[6]); R["weightsvec"] = w; // assign weights txt = "setWeights(ewSpec) <- weightsvec"; R.parseEvalQ(txt); // evaluate assignment txt = "ewPf <- feasiblePortfolio(data=lppData, spec=ewSpec, constraints=\"LongOnly\");" "print(ewPf); " "vec <- getCovRiskBudgets(ewPf@portfolio)"; Rcpp::NumericVector V( (SEXP) R.parseEval(txt) ); Rcpp::CharacterVector names( (SEXP) R.parseEval("names(vec)")); std::cout << "\n\nAnd now from C++\n\n"; for (int i=0; i<names.size(); i++) { std::cout << std::setw(16) << names[i] << "\t" << std::setw(11) << V[i] << "\n"; } } catch(std::exception& ex) { std::cerr << "Exception caught: " << ex.what() << std::endl; } catch(...) { std::cerr << "Unknown exception caught" << std::endl; } exit(0); }
[ "davidc616@gmail.com" ]
davidc616@gmail.com
28c62aba011f77628c3f48bffd037e8845a3a817
a6bb89b2ff6c1fc8c45a4f105ef528416100a360
/examples/tut6/support/texture.cpp
203539ff0a84e7aad5ddf9073a113d56da435d84
[]
no_license
dudochkin-victor/ngxe
2c03717c45431b5a88a7ca4f3a70a2f23695cd63
34687494bcbb4a9ce8cf0a7327a7296bfa95e68a
refs/heads/master
2016-09-06T02:28:20.233312
2013-01-05T19:59:28
2013-01-05T19:59:28
7,311,793
0
1
null
null
null
null
UTF-8
C++
false
false
4,495
cpp
/* Copyright (C) 2005 Heinrich du Toit This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA The license can also be obtained electronically at www.fsf.org or www.freesoftware.org/licenses I can be electronically reached at the following email addresses: 13806335@sun.ac.za (will work till end of 2005) nlhg@eject.co.za */ #include <iostream> using namespace std; #include <SDL/SDL.h> #include <GL/gl.h> #include <GL/glu.h> #include "texture.h" #define TRUE 1 #define FALSE 0 GLTextureclass::GLTextureclass() { glGenTextures(1,&texture); } GLTextureclass::~GLTextureclass() { glDeleteTextures(1,&texture); } int GLTextureclass::Load(const char* filename) { //active and set initial filtering values glBindTexture(GL_TEXTURE_2D,texture); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); SDL_Surface *surface; surface = SDL_LoadBMP(filename); if (surface == NULL){ cout << "Error loading texture file: " << filename << endl; return FALSE; } /* The problems with this: OpenGL textures must be upside down. So we must flip the image. Also we must tell opengl exactly what format the data is in. */ /* format: we must select GL_RGB GL_BGR GL_RGBA or GL_BGRA if Amask is 0 we assume there is no alpha channel if Bshift is 0 we assume BGR */ GLenum format; if (surface->format->Bshift == 0){ //BGR if (surface->format->Amask == 0) format = GL_BGR; else format = GL_BGRA; }else{ //RGB if (surface->format->Amask == 0) format = GL_RGB; else format = GL_RGBA; } GLint intformat; if (surface->format->Amask == 0) intformat = 3; else intformat = 4; /* There is no need for us to convert the format since Opengl will store the texture internally in its own optimized format. And changes are we don't really get it the same as opengl wants it. So its better just to leave it up to the drivers. Now the datatype this is quite complex. Lets hope it works. Note: this is untested code! */ GLenum datatype; if (surface->format->BytesPerPixel >= 3){ //assumption: if 4 -> includes alpha channels datatype = GL_UNSIGNED_BYTE; }else if (surface->format->BytesPerPixel == 1){ datatype = GL_UNSIGNED_BYTE_3_3_2; }else{ //now the 15 or 16-bit crap if (surface->format->Amask == 0){ //no Alpha if (surface->format->BitsPerPixel == 16) datatype = GL_UNSIGNED_SHORT_5_6_5; //16 bpp else datatype = GL_UNSIGNED_SHORT_5_5_5_1; //16bpp }else{ //Alpha datatype = GL_UNSIGNED_SHORT_4_4_4_4; } } /* To flip the image the way opengl wants it we simply create a new buffer into which we copy the image upside down.. or maybe it was upside down? */ Uint8 *buffer = new Uint8[surface->h * surface->pitch]; Uint8 *rowa = (Uint8 *)surface->pixels; Uint8 *rowb = buffer+((surface->h-1) * surface->pitch); for (int y=0; y < surface->h; y++){ memcpy(rowb,rowa,surface->pitch); rowa += surface->pitch; rowb -= surface->pitch; } // Loads the image into OpenGL and create a texture: glTexImage2D(GL_TEXTURE_2D,0,intformat,surface->w,surface->h,0, format,datatype,buffer); //Check for errors: if (glGetError() != GL_NO_ERROR){ cout << "glTexImage2D failed"<< endl; return FALSE; } //cleaup buffers delete [] buffer; SDL_FreeSurface(surface); return TRUE; } void GLTextureclass::SetWrap(GLint mode) { Activate(); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,mode); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,mode); } void GLTextureclass::SetLinearFilter() { glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); }
[ "dudochkin.victor@gmail.com" ]
dudochkin.victor@gmail.com
47ea46e66e107bd3470185bf90dc367239f60dea
0aeb5b6446ad70caf70fb65a4c110b599b44055d
/C++/Largest Rectangle in Histogram.cpp
b4580cf225df47fe9a5f60a3d357c52ced6371a6
[]
no_license
chaoxu1990/LeetCode
75a590ff5214ea17680bd1b3c28616f2dff0a64d
c6a5077ad67cf34a27173401eebf684d3edd16bb
refs/heads/master
2016-09-05T23:29:46.234888
2016-02-24T07:22:54
2016-02-24T07:22:54
25,483,811
0
2
null
null
null
null
UTF-8
C++
false
false
646
cpp
//Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. class Solution { public: int largestRectangleArea(vector<int> &height) { stack<int> s; int sum = 0; height.push_back(0); for(int i = 0; i<height.size();) { if(s.empty() || height[i] > height[s.top()]) s.push(i++); else { int tmp = s.top(); s.pop(); sum = max(sum, height[tmp] * (s.empty()?i:i-s.top()-1)); } } return sum; } };
[ "xc900411@gmail.com" ]
xc900411@gmail.com
1418c406df6c4cb5c144ff9e4e84bda2e2d2ea87
534e2e3d8d8bebd2366c0fee60886d84597ee0ef
/TIOJ/1598.cpp
39060d3b9d13cda12a5a05e7320eeedb3a696cfb
[]
no_license
coldEr66/online-judge
a8844d3f35755adafd4f43a1f08ce56b6b870601
e85ec0750d92dd00133c93284085a0f5d8a11d36
refs/heads/master
2021-09-07T01:58:10.634492
2021-07-28T16:31:13
2021-07-28T16:31:13
128,494,315
0
0
null
null
null
null
UTF-8
C++
false
false
2,922
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef double lf; typedef pair<int,int> ii; typedef pair<ii,int> iii; #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define RREP(i,n) for (int i=n-1;i>=0;i--) #define RST(i,n) memset(i,n,sizeof i) #define SZ(a) (ll)a.size() #define ALL(a) a.begin(),a.end() #define X first #define Y second #define mkp make_pair #define pb push_back #define eb emplace_back #define pob pop_back #ifdef cold66 #define debug(...) do{\ fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\ _do(__VA_ARGS__);\ }while(0) template<typename T>void _do(T &&_x){cerr<<_x<<endl;} template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);} template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";} template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb) { _s<<"{"; for(It _it=_ita;_it!=_itb;_it++) { _s<<(_it==_ita?"":",")<<*_it; } _s<<"}"; return _s; } template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));} template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));} template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));} template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;} #define IOS() #else #define debug(...) #define pary(...) #define endl '\n' #define IOS() ios_base::sync_with_stdio(0);cin.tie(0); #endif // cold66 //} template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; } template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; } template<class T> using MaxHeap = priority_queue<T>; template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2; const ll MOD=1000000007; const int INF=0x3f3f3f3f; ll n,b; ll p[MAXn]; ll mxp(ll x,ll y){ ll k = min(ll(64 - __builtin_clzll(y)-1),x-2); debug(y,k); ll tp = y - (1LL<<k)+1; if (x <= k) return INF; debug(x,y,(x-k) * ((1LL<<k) - tp) + (x-k-1)*2*tp); return (x-k) * ((1LL<<k) - tp) + (x-k-1)*2*tp; } ll gt(ll x,ll num){ ll l=0, r = 1000005; while (l != r-1) { ll mid = (l+r)>>1; if (mxp(x,mid) >= num) r = mid; else l = mid; } return r; } bool chk(ll x){ ll cnt = 0; REP (i,n) { if (p[i] <= x) continue; cnt += gt(x,p[i]); if (cnt > b) return false; } return cnt <= b; } int main(){ IOS(); cin >> n >> b; REP (i,n) cin >> p[i]; ll l = 0, r = 1000005; while (l != r-1) { // debug(l,r); ll mid = (l+r)>>1; if (chk(mid)) r = mid; else l = mid; } cout << r << endl; }
[ "seal1000402@gmail.com" ]
seal1000402@gmail.com
d063b974cd8f24ff2f6c61e8cda64e3eb47eff0d
2a1e82b1d88a3b92eee195336da62ba7459d0b62
/@voteSystem/addons/vote_day/config.cpp
243d2afd171bfbd6611e3646f32248d1cbe01734
[]
no_license
CreepPork/vote-day
99c2e8058cf7435d0fbf1cccc35a46ba73517ac4
39acc2e87403cd37d5ae7ac0d6fdee7b4215ae8e
refs/heads/master
2020-03-21T01:14:17.592077
2018-06-20T16:43:22
2018-06-20T16:43:22
137,931,437
0
0
null
null
null
null
UTF-8
C++
false
false
584
cpp
class CfgPatches { class CP_vote_day_config { weapons[] = {}; requiredVersion = 0.1; author = "CreepPork_LV"; authorUrl = "https://github.com/CreepPork/vote-day"; version = 1.0.0; versionStr = "1.0.0"; versionAr[] = {1,0,0}; units[] = {}; requiredAddons[] = { "CBA_Main" }; }; }; class CfgFunctions { class CP { project = "CP"; tag = "CP"; class voteSystem { file = "\voteSystem\vote_day\functions"; class vote; class setDay; } } } #include "XEH_postInit.cpp"
[ "creepporkstudios@gmail.com" ]
creepporkstudios@gmail.com
53d1c43d2ca5ca7074110c2e2e7f943b3b4be9f7
10bfc815828b7931ebf24486cfec4e2013736373
/p31.cpp
7aa2736a929a2265d2ed4302544cea1d93a90860
[]
no_license
theartist007/Project-Euler-Solutions
1cd5f42cb5886532bdb4f46d2b9edb8584e7c986
4d3472c84528dac04ee0a06b33ae7fbc75d15554
refs/heads/master
2021-04-06T01:47:27.260598
2018-03-12T18:16:30
2018-03-12T18:16:30
124,930,334
1
0
null
null
null
null
UTF-8
C++
false
false
512
cpp
#include<iostream> using namespace std; int main() { int x1,x2,x3,x4,x5,x6,x7,x8,c=0; for(x1=0;x1<=200;x1++) { for(x2=0;x2<=100;x2++) { for(x3=0;x3<=40;x3++) { for(x4=0;x4<=20;x4++) { for(x5=0;x5<=10;x5++) { for(x6=0;x6<=4;x6++) { for(x7=0;x7<=2;x7++) { for(x8=0;x8<=1;x8++) { if((x1+2*x2+5*x3+10*x4+20*x5+50*x6+100*x7+200*x8)==200) c++; } } } } } } } } cout<<c<<endl; return 0; }
[ "noreply@github.com" ]
theartist007.noreply@github.com
162c484288986fc13f25732449b614594d792642
0bf5c15399a640ab8df037006543ca89dd30f768
/main.cpp
31afbb2ce38a266d7c5e05145087791567985a13
[]
no_license
CosimoMarchi/Compito
3edcd25ff4c0c53a36e7c471b69561e45bbaa539
1c099cb2951795a0c2e37cfc407a3fcce80c4e04
refs/heads/master
2021-08-26T08:09:29.716441
2017-11-21T20:51:31
2017-11-21T20:51:31
111,657,825
0
0
null
null
null
null
UTF-8
C++
false
false
412
cpp
#include<iostream> using namespace std; int main() { // // Variabile Contatore di tipo int // int count=0; // // Ciclo che incrementa la variabile // for(int x=0; x<10; x++) { count++; } // <<<<<<< HEAD // Valore finale Variavile count ======= // Visualizzazione Variabile >>>>>>> FIX_BUG // cout<<count<<endl; system("pause"); }
[ "cosimo999@gmail.com" ]
cosimo999@gmail.com
76e1c7acefb74c1d6ffc58abd716a4d9fd6e0505
6a477e7ebf9b6cd5c89ffeaef2e4cccb1fa5022b
/TrueType-exaples/Subtitle/Subtitle/main.cpp
f8eb27acae58c57d16ac3e43f0d97deee505b0c5
[]
no_license
wudping/misc_starting
a86df399bba4c97e77b987c45c20c52397637674
bfed68b25b5751ec4e2c6a146df315e7e136db82
refs/heads/master
2020-04-25T15:05:45.073045
2014-07-29T01:21:04
2014-07-29T01:21:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
#include <stdio.h> #include "subtitle_srt.h" //#define FILE_NAME "E:\\subtitle\\srt\\the.53rd.annual.grammy.awards.srt" //#define FILE_NAME "panda.srt" #define FILE_NAME "subtitle1.srt" int main(int argc,char* argv[]) { subtitle_srt srt; srt.load(FILE_NAME); srt.read_srt_data(); return 0; }
[ "hiccupzhu@gmail.com" ]
hiccupzhu@gmail.com
32e4c212ea1967d557e8d1e2d1d41b168a672ade
8710f4b47da4386e401731efaa781ef3be10992c
/yolox_openvino_version2/openvino_toolkit_ubuntu18_2022.2.0.7713/runtime/include/ngraph/op/nv12_to_rgb.hpp
ed2ad3a0791741db0161968d8c5fe0b05861dafa
[]
no_license
yhwang-hub/dl_model_deploy
3be62c00bd69cddbb1c17236238c31f62495b81b
847dd097075ee25f817b393fd16f91083eb15500
refs/heads/master
2023-05-23T04:32:57.396575
2023-05-16T15:05:58
2023-05-16T15:05:58
578,062,937
65
18
null
null
null
null
UTF-8
C++
false
false
281
hpp
// Copyright (C) 2018-2022 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #pragma once #include "openvino/op/nv12_to_rgb.hpp" namespace ngraph { namespace op { namespace v8 { using ov::op::v8::NV12toRGB; } // namespace v8 } // namespace op } // namespace ngraph
[ "yuehong.wang@uisee.com" ]
yuehong.wang@uisee.com
65d6ecb98ec8727309fc861a2475cfc3c453056b
7e46779d14f823e84902bc0f3dcbb9c1be684160
/dbfzhitboxes/ue4.h
c7b69c62f0670573e64673ebc0210ae0e06ac139
[]
no_license
toolassisted/dbfzhitboxes
6337b64322ae388cae5b19b79bef43869c32961c
71b5fc2d720787cdcc25ef4f0050ebe7e13ae36c
refs/heads/master
2021-09-06T06:03:30.126629
2018-02-03T00:46:32
2018-02-03T00:46:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
866
h
#pragma once #include <cmath> struct FVector2D { float X, Y; FVector2D() : X(0), Y(0) {} FVector2D(float X, float Y) : X(X), Y(Y) {} FVector2D Rotate(const float angle) { const auto ca = cosf(angle); const auto sa = sinf(angle); return FVector2D(X * ca + Y * -sa, X * -sa + Y * -ca); } }; struct FVector { float X, Y, Z; FVector() : X(0), Y(0), Z(0) {} FVector(float X, float Y, float Z) : X(X), Y(Y), Z(Z) {} }; struct FLinearColor { float R, G, B, A; FLinearColor() : R(0), G(0), B(0), A(0) {} FLinearColor(float R, float G, float B, float A) : R(R), G(G), B(B), A(A) {} }; class UCanvas { public: void K2_DrawLine(FVector2D ScreenPositionA, FVector2D ScreenPositionB, float Thickness, const FLinearColor &RenderColor); FVector K2_Project(const FVector &WorldPosition); }; class AHud { char pad01[0x3D8]; public: UCanvas *Canvas; };
[ "altimormc@gmail.com" ]
altimormc@gmail.com
6cc11084fe5d7ba1247d49525c80310ba13b51a1
6d970dd4f8375ce1972afe9eed7a38321947ec19
/elements/include/elements/element/basics.hpp
faa982a51831fea9536037bf9ce0fa99171b07e8
[]
no_license
olilarkin/IPlugElements
4e6fcbd2ad692189e06a80c59427681ba8417bb6
842b660c273c54841d259af064ce463cc24145d0
refs/heads/master
2020-07-22T01:30:45.021153
2019-09-07T22:11:14
2019-09-07T22:11:49
207,031,536
4
0
null
null
null
null
UTF-8
C++
false
false
6,322
hpp
/*============================================================================= Copyright (c) 2016-2019 Joel de Guzman Distributed under the MIT License [ https://opensource.org/licenses/MIT ] =============================================================================*/ #if !defined(CYCFI_ELEMENTS_GUI_LIB_WIDGET_BASIC_APRIL_11_2016) #define CYCFI_ELEMENTS_GUI_LIB_WIDGET_BASIC_APRIL_11_2016 #include <elements/element/element.hpp> #include <elements/element/proxy.hpp> #include <elements/support/theme.hpp> #include <functional> namespace cycfi { namespace elements { //////////////////////////////////////////////////////////////////////////// // Basic Element // // The basic element takes in a function that draws something //////////////////////////////////////////////////////////////////////////// template <typename F> class basic_element : public element { public: basic_element(F f) : f(f) {} virtual void draw(context const& ctx) { f(ctx); } private: F f; }; template <typename F> inline basic_element<F> basic(F f) { return { f }; } //////////////////////////////////////////////////////////////////////////// // Background Fill //////////////////////////////////////////////////////////////////////////// struct background_fill : element { background_fill(color color_) : _color(color_) {} void draw(context const& ctx); color _color; }; //////////////////////////////////////////////////////////////////////////// // Panels //////////////////////////////////////////////////////////////////////////// class panel : public element { public: virtual void draw(context const& ctx); }; //////////////////////////////////////////////////////////////////////////// // Frames //////////////////////////////////////////////////////////////////////////// struct frame : public element { virtual void draw(context const& ctx); }; //////////////////////////////////////////////////////////////////////////// // Headings //////////////////////////////////////////////////////////////////////////// struct heading : element { heading(std::string const& text, float size_ = 1.0) : _text(text) , _size(size_) {} virtual view_limits limits(basic_context const& ctx) const; virtual void draw(context const& ctx); std::string text() const { return _text; } void text(std::string const& text) { _text = text; } using element::text; std::string _text; float _size; }; //////////////////////////////////////////////////////////////////////////// // Title Bars //////////////////////////////////////////////////////////////////////////// class title_bar : public element { public: virtual void draw(context const& ctx); }; //////////////////////////////////////////////////////////////////////////// // Labels //////////////////////////////////////////////////////////////////////////// struct label : element { label(std::string const& text, float size_ = 1.0) : _text(text) , _size(size_) {} virtual view_limits limits(basic_context const& ctx) const; virtual void draw(context const& ctx); std::string text() const { return _text; } void text(std::string const& text) { _text = text; } using element::text; std::string _text; float _size; }; //////////////////////////////////////////////////////////////////////////////////////////////// // Grid Lines //////////////////////////////////////////////////////////////////////////////////////////////// class vgrid_lines : public element { public: vgrid_lines(float major_divisions, float minor_divisions) : _major_divisions(major_divisions) , _minor_divisions(minor_divisions) {} virtual void draw(context const& ctx); private: float _major_divisions; float _minor_divisions; }; //////////////////////////////////////////////////////////////////////////// // Icons //////////////////////////////////////////////////////////////////////////// struct icon : element { icon(std::uint32_t code_, float size_ = 1.0); virtual view_limits limits(basic_context const& ctx) const; virtual void draw(context const& ctx); std::uint32_t _code; float _size; }; //////////////////////////////////////////////////////////////////////////// // Key Intercept //////////////////////////////////////////////////////////////////////////// template <typename Subject> struct key_intercept_element : public proxy<Subject> { using base_type = proxy<Subject>; key_intercept_element(Subject&& subject) : base_type(std::forward<Subject>(subject)) {} virtual bool key(context const& ctx, key_info k); virtual bool is_control() const { return true; } using key_function = std::function<bool(key_info k)>; key_function on_key = [](auto){ return false; }; }; template <typename Subject> inline key_intercept_element<Subject> key_intercept(Subject&& subject) { return { std::forward<Subject>(subject) }; } template <typename Subject> inline bool key_intercept_element<Subject>::key(context const& ctx, key_info k) { return on_key(k); } }} #endif
[ "olilarkin@googlemail.com" ]
olilarkin@googlemail.com
9278b28859841bc890dd38aa22d276d295d1ced1
69772010c5d9f6de9045902017b72cd55e24b9a0
/src/test/key_tests.cpp
5a3dd9e9e181b1586525b27e51ead16cff143a93
[ "MIT" ]
permissive
happyleaf-money/happyleaf
467263751301bc807d4f2f5ddf23bb2f81411607
dc6526057cd16ec14a8d55b8023281d9622c26a5
refs/heads/master
2021-01-05T09:30:59.896096
2020-09-24T07:02:49
2020-09-24T07:02:49
240,972,619
1
0
null
null
null
null
UTF-8
C++
false
false
8,008
cpp
// Copyright (c) 2012-2013 The Bitcoin Core developers // Copyright (c) 2018-2019 The HLF developers // Copyright (c) 2020 The HappyLeaf developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "key.h" #include "base58.h" #include "script/script.h" #include "uint256.h" #include "util.h" #include "utilstrencodings.h" #include <string> #include <vector> #include <boost/test/unit_test.hpp> using namespace std; static const string strSecret1 ("87vK7Vayi3QLsuiva5yWSuVwSMhMcRM9dBsaD6JXMD1P5vnjRFn"); static const string strSecret2 ("87FGYGFDg5SYfdD4XL593hr7do6f52czPecVsYSAXi8N4RGeS9i"); static const string strSecret1C ("YRYJwfAyJ9c2jhi3T2xQyLijGvM7yLTw4izDaNQLxBzgUYrQiPmJ"); static const string strSecret2C ("YNZyazHkwUbkmUpEYsBGWwHnHQTy2n9rJy1gS5k54YXVx3pE8n6N"); static const CBitcoinAddress addr1 ("DBFi8XAE1rcdCQfkv9w22n8Y9RxgaJnrDD"); static const CBitcoinAddress addr2 ("DPvKfv1FVp69yZMDzeuugvfZ9pzYiMv1bs"); static const CBitcoinAddress addr1C("DNPrHK9ezAAUVExFDpZ7EE1xWpPskgp1gP"); static const CBitcoinAddress addr2C("DNBVSAoc2whPFjZVAZ1pQbXPJk1LRrDC8Q"); static const string strAddressBad("Xta1praZQjyELweyMByXyiREw1ZRsjXzVP"); #ifdef KEY_TESTS_DUMPINFO void dumpKeyInfo(uint256 privkey) { CKey key; key.resize(32); memcpy(&secret[0], &privkey, 32); vector<unsigned char> sec; sec.resize(32); memcpy(&sec[0], &secret[0], 32); printf(" * secret (hex): %s\n", HexStr(sec).c_str()); for (int nCompressed=0; nCompressed<2; nCompressed++) { bool fCompressed = nCompressed == 1; printf(" * %s:\n", fCompressed ? "compressed" : "uncompressed"); CBitcoinSecret bsecret; bsecret.SetSecret(secret, fCompressed); printf(" * secret (base58): %s\n", bsecret.ToString().c_str()); CKey key; key.SetSecret(secret, fCompressed); vector<unsigned char> vchPubKey = key.GetPubKey(); printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str()); printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str()); } } #endif BOOST_AUTO_TEST_SUITE(key_tests) BOOST_AUTO_TEST_CASE(key_test1) { CBitcoinSecret bsecret1, bsecret2, bsecret1C, bsecret2C, baddress1; BOOST_CHECK( bsecret1.SetString (strSecret1)); BOOST_CHECK( bsecret2.SetString (strSecret2)); BOOST_CHECK( bsecret1C.SetString(strSecret1C)); BOOST_CHECK( bsecret2C.SetString(strSecret2C)); BOOST_CHECK(!baddress1.SetString(strAddressBad)); CKey key1 = bsecret1.GetKey(); BOOST_CHECK(key1.IsCompressed() == false); CKey key2 = bsecret2.GetKey(); BOOST_CHECK(key2.IsCompressed() == false); CKey key1C = bsecret1C.GetKey(); BOOST_CHECK(key1C.IsCompressed() == true); CKey key2C = bsecret2C.GetKey(); BOOST_CHECK(key2C.IsCompressed() == true); CPubKey pubkey1 = key1. GetPubKey(); CPubKey pubkey2 = key2. GetPubKey(); CPubKey pubkey1C = key1C.GetPubKey(); CPubKey pubkey2C = key2C.GetPubKey(); BOOST_CHECK(key1.VerifyPubKey(pubkey1)); BOOST_CHECK(!key1.VerifyPubKey(pubkey1C)); BOOST_CHECK(!key1.VerifyPubKey(pubkey2)); BOOST_CHECK(!key1.VerifyPubKey(pubkey2C)); BOOST_CHECK(!key1C.VerifyPubKey(pubkey1)); BOOST_CHECK(key1C.VerifyPubKey(pubkey1C)); BOOST_CHECK(!key1C.VerifyPubKey(pubkey2)); BOOST_CHECK(!key1C.VerifyPubKey(pubkey2C)); BOOST_CHECK(!key2.VerifyPubKey(pubkey1)); BOOST_CHECK(!key2.VerifyPubKey(pubkey1C)); BOOST_CHECK(key2.VerifyPubKey(pubkey2)); BOOST_CHECK(!key2.VerifyPubKey(pubkey2C)); BOOST_CHECK(!key2C.VerifyPubKey(pubkey1)); BOOST_CHECK(!key2C.VerifyPubKey(pubkey1C)); BOOST_CHECK(!key2C.VerifyPubKey(pubkey2)); BOOST_CHECK(key2C.VerifyPubKey(pubkey2C)); BOOST_CHECK(addr1.Get() == CTxDestination(pubkey1.GetID())); BOOST_CHECK(addr2.Get() == CTxDestination(pubkey2.GetID())); BOOST_CHECK(addr1C.Get() == CTxDestination(pubkey1C.GetID())); BOOST_CHECK(addr2C.Get() == CTxDestination(pubkey2C.GetID())); for (int n=0; n<16; n++) { string strMsg = strprintf("Very secret message %i: 11", n); uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); // normal signatures vector<unsigned char> sign1, sign2, sign1C, sign2C; BOOST_CHECK(key1.Sign (hashMsg, sign1)); BOOST_CHECK(key2.Sign (hashMsg, sign2)); BOOST_CHECK(key1C.Sign(hashMsg, sign1C)); BOOST_CHECK(key2C.Sign(hashMsg, sign2C)); BOOST_CHECK( pubkey1.Verify(hashMsg, sign1)); BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2)); BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C)); BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C)); BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1)); BOOST_CHECK( pubkey2.Verify(hashMsg, sign2)); BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C)); BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C)); BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1)); BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2)); BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C)); BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C)); BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1)); BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2)); BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C)); BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C)); // compact signatures (with key recovery) vector<unsigned char> csign1, csign2, csign1C, csign2C; BOOST_CHECK(key1.SignCompact (hashMsg, csign1)); BOOST_CHECK(key2.SignCompact (hashMsg, csign2)); BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C)); BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C)); CPubKey rkey1, rkey2, rkey1C, rkey2C; BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1)); BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2)); BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C)); BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C)); BOOST_CHECK(rkey1 == pubkey1); BOOST_CHECK(rkey2 == pubkey2); BOOST_CHECK(rkey1C == pubkey1C); BOOST_CHECK(rkey2C == pubkey2C); } // test deterministic signing std::vector<unsigned char> detsig, detsigc; string strMsg = "Very deterministic message"; uint256 hashMsg = Hash(strMsg.begin(), strMsg.end()); BOOST_CHECK(key1.Sign(hashMsg, detsig)); BOOST_CHECK(key1C.Sign(hashMsg, detsigc)); BOOST_CHECK(detsig == detsigc); BOOST_CHECK(detsig == ParseHex("30450221009071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a02200dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0")); BOOST_CHECK(key2.Sign(hashMsg, detsig)); BOOST_CHECK(key2C.Sign(hashMsg, detsigc)); BOOST_CHECK(detsig == detsigc); BOOST_CHECK(detsig == ParseHex("304402204f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de02204f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a")); BOOST_CHECK(key1.SignCompact(hashMsg, detsig)); BOOST_CHECK(key1C.SignCompact(hashMsg, detsigc)); BOOST_CHECK(detsig == ParseHex("1b9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0")); BOOST_CHECK(detsigc == ParseHex("1f9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0")); BOOST_CHECK(key2.SignCompact(hashMsg, detsig)); BOOST_CHECK(key2C.SignCompact(hashMsg, detsigc)); BOOST_CHECK(detsig == ParseHex("1b4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a")); BOOST_CHECK(detsigc == ParseHex("1f4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a")); } BOOST_AUTO_TEST_SUITE_END()
[ "reyner.info@gmail.com" ]
reyner.info@gmail.com
e79f938feb1c1853fa83e3998e5cf94527c960b9
ff29fe1db22d0f6c0b637c597981bd1cea58ccd8
/Classes/Depends/Application/Global.cpp
2fe580663cd318d1b3999ee495eddb5106b7920c
[]
no_license
CristinaBaby/DecorateChristmas
34603c1848eac8505fe60d480fa6db8c6febbe2a
e0d65ebf898708ce8029bda40f2e7c382e476306
refs/heads/master
2021-04-26T15:01:22.169475
2015-11-23T09:05:51
2015-11-23T09:05:51
46,609,410
0
1
null
null
null
null
UTF-8
C++
false
false
378
cpp
#include "Global.h" float contentScale=1.0f; Size screenSize; int resourceType=SF_RESOURCES_1024_768; float blankArea_width=0; float blankArea_height=0; bool soundOn=true; bool closeAds=true; Size design_size = Size(0, 0); Size frame_size = Size(0, 0); bool gIsHomeVedio = false; bool gNoneIap = false; float gAdsDystent = 90; Size visibleSize = Size::ZERO;
[ "wuguiling@smalltreemedia.com" ]
wuguiling@smalltreemedia.com
faf3a45dd86f83682f27f14104034f91aed13aca
7e2e71956fdf70da787bf4edcfcf7ecd34fd9c99
/o2Editor/Sources/Core/Actions/DeleteActors.cpp
2a4efad75142d0b1f468df79474e82e9bc2f3138
[]
no_license
dmitrykolesnikovich/o2
579abb53c805b117d11986017dcdb50f50d75409
c1b9038c6f56466ab96544c0e9424e4b9baf6553
refs/heads/master
2020-03-13T00:31:46.701057
2018-04-23T19:33:58
2018-04-23T19:33:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,878
cpp
#include "stdafx.h" #include "DeleteActors.h" #include "Scene/Actor.h" #include "SceneWindow/SceneEditScreen.h" #include "TreeWindow/ActorsTree.h" #include "TreeWindow/TreeWindow.h" namespace Editor { DeleteActorsAction::DeleteActorsAction() {} DeleteActorsAction::DeleteActorsAction(const Vector<Actor*>& deletingActors) { for (auto actor : deletingActors) { ActorInfo info; info.actorData.SetValueRaw(actor); info.idx = GetActorIdx(actor); if (actor->GetParent()) { auto parent = actor->GetParent(); info.parentId = parent->GetID(); auto parentChilds = parent->GetChildren(); info.prevActorId = 0; for (auto child : parentChilds) { if (child == actor) break; info.prevActorId = child->id; } } else { info.parentId = 0; auto sceneActors = o2Scene.GetRootActors(); info.prevActorId = 0; for (auto child : sceneActors) { if (child == actor) break; info.prevActorId = child->id; } } actorsInfos.Add(info); } actorsInfos.Sort([](auto& a, auto& b) { return a.idx < b.idx; }); } DeleteActorsAction::~DeleteActorsAction() {} String DeleteActorsAction::GetName() const { return "Actors deletion"; } void DeleteActorsAction::Redo() { for (auto info : actorsInfos) { auto sceneActor = o2Scene.GetActorByID((UInt64)info.actorData["Value"]["Id"]); if (sceneActor) delete sceneActor; } o2EditorSceneScreen.ClearSelectionWithoutAction(); o2EditorTree.GetActorsTree()->UpdateNodesView(); } void DeleteActorsAction::Undo() { for (auto info : actorsInfos) { Actor* parent = o2Scene.GetActorByID(info.parentId); if (parent) { UInt64 prevId = info.prevActorId; int idx = parent->GetChildren().FindIdx([=](Actor* x) { return x->GetID() == prevId; }) + 1; Actor* newActor; info.actorData.GetValueRaw(newActor); parent->AddChild(newActor, idx); o2EditorSceneScreen.SelectActorWithoutAction(newActor); } else { int idx = o2Scene.GetRootActors().FindIdx([&](Actor* x) { return x->GetID() == info.prevActorId; }) + 1; Actor* newActor; info.actorData.GetValueRaw(newActor); newActor->SetPositionIndexInParent(idx); o2EditorSceneScreen.SelectActorWithoutAction(newActor); } } o2EditorTree.GetActorsTree()->UpdateNodesView(); } bool DeleteActorsAction::ActorInfo::operator==(const ActorInfo& other) const { return actorData == other.actorData && parentId == other.parentId && prevActorId == other.prevActorId; } int DeleteActorsAction::GetActorIdx(Actor* actor) { if (actor->GetParent()) { return actor->GetParent()->GetChildren().Find(actor) + GetActorIdx(actor->GetParent()); } return o2Scene.GetRootActors().Find(actor); } } DECLARE_CLASS(Editor::DeleteActorsAction); DECLARE_CLASS(Editor::DeleteActorsAction::ActorInfo);
[ "zenkovichan@gmail.com" ]
zenkovichan@gmail.com
428d502a8577dec66ea194badcac466661723efa
aeb100c75639d121e907795c626f3eff787e5ed5
/bstMin&MaxValue.cpp
b94d0a981e0befa7c20f1450b75543c0656b2fca
[]
no_license
fasher7/DataStructure
0e368f03b4b95892fb7e0b5f5ec50962aa38a0b3
f952942e28bcfc2d484864ef118c9d47a80d7af6
refs/heads/main
2023-07-19T19:22:58.856848
2021-08-22T08:46:11
2021-08-22T08:46:11
352,259,016
0
0
null
null
null
null
UTF-8
C++
false
false
1,308
cpp
#include <iostream> using namespace std; struct node { int data = 0; node *left = nullptr; node *right = nullptr; }; void insertVal(node *&n, int val) { if (n == nullptr) { n = new node; n->data = val; } else if (val > n->data) { insertVal(n->right, val); } else if (val < n->data) { insertVal(n->left, val); } } int minVal(node *n) { if (n == nullptr) { return -10000; } else if (n->left == nullptr) { return n->data; } else return minVal(n->left); } int maxVal(node *n) { if (n == nullptr) { return -10000; } else if (n->right == nullptr) { return n->data; } else return maxVal(n->right); } void printTree(node *n) { if (n == nullptr) { return; } cout << n->data << " "; printTree(n->left); printTree(n->right); } int main() { node *p = nullptr; insertVal(p, 16); insertVal(p, 10); insertVal(p, 27); insertVal(p, 2); insertVal(p, 14); insertVal(p, 13); insertVal(p, 11); insertVal(p, 30); insertVal(p, 50); insertVal(p, 36); printTree(p); cout << endl; cout << minVal(p) << endl; cout << maxVal(p) << endl; return 0; }
[ "noreply@github.com" ]
fasher7.noreply@github.com
529164b72dcf3d8b870048da530d18ff9309884c
7d7f286b78893e608c5426cddaaf9acde5145104
/practice/94_WordBreakII.cpp
6d1f6da3cd1054650f907e2ea6da54dce4744c60
[]
no_license
zqnnn/coding-note
6b82b70364009b3e2368100e7b7b86795699a5e6
eb2bf5b60541da501ed31644e8d86aeaf18881a2
refs/heads/master
2020-04-27T05:34:30.897151
2019-09-18T02:21:11
2019-09-18T02:21:11
174,084,412
0
0
null
null
null
null
UTF-8
C++
false
false
2,837
cpp
// // Created by zhangqianni on 2019-07-24. // //给定一个非空字符串 s 和一个包含非空单词列表的字典 wordDict,在字符串中增加空格来构建一个句子,使得句子中所有的单词都在词典中。返回所有这些可能的句子。 // //说明: // //分隔时可以重复使用字典中的单词。 //你可以假设字典中没有重复的单词。 //示例 1: // //输入: //s = "catsanddog" //wordDict = ["cat", "cats", "and", "sand", "dog"] //输出: //[ //  "cats and dog", //  "cat sand dog" //] //示例 2: // //输入: //s = "pineapplepenapple" //wordDict = ["apple", "pen", "applepen", "pine", "pineapple"] //输出: //[ //  "pine apple pen apple", //  "pineapple pen apple", //  "pine applepen apple" //] //解释: 注意你可以重复使用字典中的单词。 //示例 3: // //输入: //s = "catsandog" //wordDict = ["cats", "dog", "sand", "and", "cat"] //输出: //[] // #include <string> #include <vector> #include <unordered_set> #include <unordered_map> using namespace std; //这道题是之前那道Word Break 拆分词句的拓展,那道题只让我们判断给定的字符串能否被拆分成字典中的词, // 而这道题加大了难度,让我们求出所有可以拆分成的情况,就像题目中给的例子所示。 //像这种返回结果要列举所有情况的题,十有八九都是要用递归来做的。 //要避免重复计算,如何避免呢,还是看上面的分析,如果当s变成 "sanddog"的时候,那么此时我们知道其可以拆分成sand和dog, // 当某个时候如果我们又遇到了这个 "sanddog"的时候,我们难道还需要再调用递归算一遍吗, // 当然不希望啦,所以我们要将这个中间结果保存起来,由于我们必须要同时保存s和其所有的拆分的字符串, // 那么可以使用一个HashMap,来建立二者之间的映射 class Solution { public: vector<string> wordBreak(string s, vector<string>& wordDict) { unordered_map<string, vector<string>> map; return helper(s, wordDict, map); } vector<string> helper(string s, vector<string>& wordDict, unordered_map<string, vector<string>>& map){ if(map.count(s)) return map[s]; if(s.empty()) return {""}; vector<string> res; for(string word : wordDict){ if (s.substr(0, word.size()) != word) continue; vector<string> rem = helper(s.substr(word.size()), wordDict, map); for (string str : rem) { res.push_back(word + (str.empty() ? "" : " ") + str); } } return map[s] = res; } }; int main(){ vector<string> wordDict = {"apple", "pen", "applepen", "pine", "pineapple"}; Solution s; vector<string> res = s.wordBreak("pineapplepenapple", wordDict); }
[ "775784772@qq.com" ]
775784772@qq.com
c383eef98ef613a848b08518b103d9f740ca578a
83d681d15c07c7e2668deaf98f1bbb3479846087
/QFF/Qff/SurvivalCurve.cpp
3a774ccf4081af1ca3d6ffc96cccbd2c5a34a885
[ "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
QuantFinanceFramework/QFF
d38b513a9e7a6f04ccb66eba02084d4edb3e500d
6a9bf51d8f80d862d4e952b2fe33f21d9697a40a
refs/heads/master
2022-07-10T18:10:29.505702
2022-06-30T03:30:18
2022-06-30T03:30:18
119,756,771
3
3
MIT
2020-03-20T11:10:27
2018-01-31T23:29:29
C++
UTF-8
C++
false
false
1,941
cpp
#include "SurvivalCurve.h" #include <algorithm> #include "DateFunctions.h" using boost::gregorian::date; using std::map; using std::unique_ptr; using std::vector; namespace qff { SurvivalCurve::SurvivalCurve(date curve_date, vector<date> dates, const vector<double>& survival_probabilities, const IInterpolator& interpolator, const IDayCounter& day_counter) : curve_date_(curve_date), dates_(std::move(dates)), interpolator_(interpolator.Clone()), day_counter_(day_counter.Clone()) { std::transform(dates_.begin(), dates_.end(), survival_probabilities.begin(), std::inserter(survival_probabilities_map_, survival_probabilities_map_.end()), [&](auto date, auto survival_probability) { return std::make_pair( DateToTime(*day_counter_, curve_date_, date), survival_probability); }); } SurvivalCurve::SurvivalCurve(date&& curve_date, vector<date>&& dates, map<double, double>&& survival_probabilities_map, unique_ptr<IInterpolator> interpolator, unique_ptr<IDayCounter> day_counter) : curve_date_(curve_date), dates_(dates), survival_probabilities_map_(survival_probabilities_map), interpolator_(std::move(interpolator)), day_counter_(std::move(day_counter)) {} date SurvivalCurve::GetCurveDate() const { return curve_date_; } double SurvivalCurve::GetSurvivalProbability(const date& query_date) const { return GetSurvivalProbability( DateToTime(*day_counter_, curve_date_, query_date)); } double SurvivalCurve::GetSurvivalProbability(double query_time) const { return interpolator_->Interpol(query_time, survival_probabilities_map_); } } // namespace qff
[ "kevin_yiu21@hotmail.com" ]
kevin_yiu21@hotmail.com
971185d263dfd4652ac4ec8b01cfabefd45c088b
12cf27e6585ed8ed72522d3f9bd51bc50b199b1c
/GuessTheWord.h
07a4caea958727c971809bca8a423335435d431d
[]
no_license
ageorge/Hangman
e426d6fc671071787292cca58c45d41b9ca68dff
3ce80a9b5f148602b2d85abeb6eaf88a13382a71
refs/heads/master
2020-04-22T14:55:15.289065
2019-02-13T07:24:10
2019-02-13T07:24:10
170,460,933
0
0
null
null
null
null
UTF-8
C++
false
false
1,510
h
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: GuessTheWord.h * Author: anitageorge * * Created on September 15, 2017, 4:10 PM * Compiler Used: * * This is a header file that entails the variables and the function signatures of the class GuessTheWord */ #ifndef GUESSTHEWORD_H #define GUESSTHEWORD_H #include "iostream" #include "fstream" #include "string" using namespace std; class GuessTheWord { string dictionary[50]; string currentWord; string currentState; string currentGuess; int dictionarySize; const string vowels = "AEIOU"; bool CheckVowel(string); void GenerateHint(); public: GuessTheWord(); void LoadDictionary(string filename="InputFile.txt"); //Usage of default parameter void Clear(); int GetSecretWord(); bool CheckChar(); bool IsWin(); friend istream& operator>>(istream &input, GuessTheWord &guess) { //operator overloading of >> as a friend function to input an object input >> guess.currentGuess; return input; } friend ostream& operator<<(ostream &output,const GuessTheWord &guess) { //operator overloading of << as a friend function to output and object output << guess.currentState <<"\n"; return output; } }; #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus } #endif #endif /* GUESSTHEWORD_H */
[ "anitageorge355@gmail.com" ]
anitageorge355@gmail.com
ef0c83aead5b0c638856eef318c43995fef7904b
a9265b150a00b4f81cf82cb8bac598e13147bbae
/HonorsSection2/DirectX - TDNLib/source/system/textLoader.cpp
395f421ddf71ba40606d2d162e6b5de78b5af6ae
[]
no_license
Honors2016ProjectA2/Main
2f7c1dc1dc7d737524f516b84c4e4a9ba558ec90
830eccf808e1525ec9ddd66b7fadd95133e0869b
refs/heads/master
2021-01-21T04:32:42.675528
2016-07-15T13:57:18
2016-07-15T13:57:18
54,442,708
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
8,627
cpp
#include <windows.h> #include "TextLoader.h" //***************************************************************************************************************************** // // // //***************************************************************************************************************************** bool textLoader::Open( LPSTR filename ) { FileBuf = NULL; // ファイル読み込み HANDLE hfile; DWORD dum; hfile = CreateFile( filename, GENERIC_READ, FILE_SHARE_READ, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL ); if( hfile == INVALID_HANDLE_VALUE ) return false; TextSize = GetFileSize( hfile, NULL ); FileBuf = new char[TextSize]; ReadFile( hfile, FileBuf, TextSize, &dum, NULL ); CloseHandle(hfile); ReadIndex = 0; return true; } bool textLoader::EndCheck() { if( ReadIndex < TextSize ) return true; return false; } void textLoader::SetIndex( int index ) { ReadIndex = index; } //***************************************************************************************************************************** // //***************************************************************************************************************************** textLoader::textLoader( LPSTR filename ) { bInit = Open(filename); } //-------------------------------------------------------------------------------------- // 頭出し //-------------------------------------------------------------------------------------- int textLoader::SearchTop( void ) { for(;;){ if( ReadIndex >= TextSize ) return -1; if( IsCharAlphaNumeric(FileBuf[ReadIndex]) ) break; if( FileBuf[ReadIndex] == '{' ) break; if( FileBuf[ReadIndex] == '}' ) break; if( FileBuf[ReadIndex] == '"' ) return 1; if( FileBuf[ReadIndex] == '.' ) break; if( FileBuf[ReadIndex] == '-' ) break; if( FileBuf[ReadIndex] == '=' ) break; ReadIndex ++; if( ReadIndex >= TextSize ) return -1; } return 0; } // void textLoader::LoadString( LPSTR str ) { int len = 0; int mode = SearchTop(); if( ReadIndex >= TextSize ) return; // 名前読み込みモード if( mode == 1 ) { str[len] = '"'; len ++; ReadIndex ++; for(;;){ if( IsDBCSLeadByte(FileBuf[ReadIndex]) ){ str[len] = FileBuf[ReadIndex]; len ++; ReadIndex ++; } else { if( FileBuf[ReadIndex] == '"' ) break; } if( ReadIndex >= TextSize ) break; str[len] = FileBuf[ReadIndex]; len ++; ReadIndex ++; } str[len] = '"'; len ++; str[len] = '\0'; ReadIndex ++; return; } for(;;){ if( ReadIndex>0 && !IsDBCSLeadByte(FileBuf[ReadIndex-1]) ){ if( FileBuf[ReadIndex] == ';' ) break; if( FileBuf[ReadIndex] == ')' ) break; if( FileBuf[ReadIndex] == '(' ) break; if( FileBuf[ReadIndex] == ',' ) break; if( FileBuf[ReadIndex] == ' ' ) break; if( FileBuf[ReadIndex] == '\t' ) break; if( FileBuf[ReadIndex] == 0x0d ) break; if( FileBuf[ReadIndex] == 0x0a ) break; if( ReadIndex >= TextSize ) break; } str[len] = FileBuf[ReadIndex]; len ++; ReadIndex ++; } str[len] = '\0'; ReadIndex ++; } void textLoader::LoadName( LPSTR str ) { int len = 0; bool bDQMode = false; SearchTop(); if( ReadIndex >= TextSize ) return; if( FileBuf[ReadIndex] == '"' ) { ReadIndex++; bDQMode = true; } for(;;){ if( ReadIndex>0 && !IsDBCSLeadByte(FileBuf[ReadIndex-1]) ){ if( FileBuf[ReadIndex] == '"' ){ ReadIndex++; break; } if( FileBuf[ReadIndex] == '(' ) break; if( FileBuf[ReadIndex] == ',' ) break; if( !bDQMode && FileBuf[ReadIndex] == ' ' ) break; if( FileBuf[ReadIndex] == '\t' ) break; if( FileBuf[ReadIndex] == 0x0d ) break; if( FileBuf[ReadIndex] == 0x0a ) break; } str[len] = FileBuf[ReadIndex]; len ++; ReadIndex ++; } str[len] = '\0'; ReadIndex ++; } // void textLoader::LoadStringTest( LPSTR str ) { int len = 0; SearchTop(); if( ReadIndex >= TextSize ) return; DWORD WorkIndex = ReadIndex; for(;;){ if( WorkIndex>0 && !IsDBCSLeadByte(FileBuf[WorkIndex-1]) ){ if( FileBuf[WorkIndex] == ')' ) break; if( FileBuf[WorkIndex] == '(' ) break; if( FileBuf[WorkIndex] == ',' ) break; if( FileBuf[WorkIndex] == ' ' ) break; if( FileBuf[WorkIndex] == '\t' ) break; if( FileBuf[WorkIndex] == 0x0d ) break; if( FileBuf[WorkIndex] == 0x0a ) break; } str[len] = FileBuf[WorkIndex]; len ++; WorkIndex ++; } str[len] = '\0'; } // float textLoader::LoadFloat( void ) { float ret; char temp[20]; LoadString(temp); ret = (float)atof(temp); return ret; } int textLoader::LoadInt( void ) { int ret; char temp[20]; LoadString(temp); ret = atoi(temp); return ret; } DWORD textLoader::LoadDWORD( void ) { DWORD ret = 0; char temp[20]; LoadString(temp); for( DWORD l=0 ; l<strlen(temp) ; l++ ) { ret *= 10; ret += temp[l]-'0'; } return ret; } // {}読み飛ばし!! void textLoader::Skip( void ) { int work = 0; if( FileBuf[ReadIndex] != '{' ) work = 1; for(;;){ if( FileBuf[ReadIndex] == '{' ) work ++; if( FileBuf[ReadIndex] == '}' ){ work--; if( work <= 0 ) break; } ReadIndex++; } ReadIndex++; } // {に入る void textLoader::In( void ) { for(;;){ if( ReadIndex >= TextSize ) return; if( FileBuf[ReadIndex] == '{' ) break; ReadIndex++; } ReadIndex++; } // {から出る void textLoader::Out( void ) { int count = 0; for(;;){ if( ReadIndex >= TextSize ) return; if( FileBuf[ReadIndex] == '{' ) count++; if( FileBuf[ReadIndex] == '}' ){ count--; if( count < 0 ) break; } ReadIndex++; } ReadIndex++; } //------------------------------------------------------ // 検索 //------------------------------------------------------ bool textLoader::Search( LPSTR str ) { char temp[128]; while(EndCheck()){ LoadString(temp); if( lstrcmp( temp, str ) == 0 ) return true; } return false; } //------------------------------------------------------ // 行内検索 //------------------------------------------------------ bool textLoader::SearchLine( LPSTR str ) { char temp[128]; DWORD oldIndex = ReadIndex; // 行頭設定 for(;;) { ReadIndex --; if( FileBuf[ReadIndex] == '\n' ) break; if( FileBuf[ReadIndex] == '\r' ) break; } ReadIndex ++; // 行内検索 for(;;) { if( FileBuf[ReadIndex] == '\n' ) break; if( FileBuf[ReadIndex] == '\r' ) break; if( !IsCharAlphaNumeric(FileBuf[ReadIndex]) ) { ReadIndex ++; continue; } LoadString(temp); if( lstrcmp( temp, str ) == 0 ) return true; } ReadIndex = oldIndex; return false; } //------------------------------------------------------ // 階層内検索 //------------------------------------------------------ bool textLoader::Search2( LPSTR str ) { char temp[128]; int work = 0; if( FileBuf[ReadIndex] != '{' ) work = 1; while(EndCheck()){ LoadString(temp); if( lstrcmp( temp, str ) == 0 ) return true; if( lstrcmp( temp, "{" ) == 0 ){ work++; } if( lstrcmp( temp, "}" ) == 0 ){ work--; if( work <= 0 ) return false; } } return false; } //------------------------------------------------------ // 同一インデント内検索 //------------------------------------------------------ bool textLoader::SearchIndent( LPSTR str ) { char temp[128]; int work = 0; DWORD oldIndex = ReadIndex; for(;;) { LoadString(temp); if( ReadIndex >= TextSize ) { ReadIndex = oldIndex; return false; } if( lstrcmp( temp, str ) == 0 ) return true; if( lstrcmp( temp, "{" ) == 0 ){ Skip(); continue; } if( lstrcmp( temp, "}" ) == 0 ){ work--; if( work <= 0 ) { ReadIndex = oldIndex; return false; } } } ReadIndex = oldIndex; return false; } void textLoader::push() { PushIndex = ReadIndex; } void textLoader::pop() { ReadIndex = PushIndex; } void textLoader::newLine() { for(;;){ if( ReadIndex >= TextSize ) return; if( FileBuf[ReadIndex] == '\n' ) break; if( FileBuf[ReadIndex] == '\r' ) break; ReadIndex++; } } //***************************************************************************************************************************** // //*****************************************************************************************************************************
[ "owatasosan001@gmail.com" ]
owatasosan001@gmail.com
bc895996fa7e201f79f461dd909718f821f6dc28
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/collectd/gumtree/collectd_repos_function_1027_collectd-5.0.1.cpp
3e815139a060f434ec11eb5bb7a412b0857f8aff
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,156
cpp
static int receive_loop (void) /* {{{ */ { pinba_socket_t *s; s = pinba_socket_open (conf_node, conf_service); if (s == NULL) { ERROR ("pinba plugin: Collector thread is exiting prematurely."); return (-1); } while (!collector_thread_do_shutdown) { int status; nfds_t i; if (s->fd_num < 1) break; status = poll (s->fd, s->fd_num, /* timeout = */ 1000); if (status == 0) /* timeout */ { continue; } else if (status < 0) { char errbuf[1024]; if ((errno == EINTR) || (errno == EAGAIN)) continue; ERROR ("pinba plugin: poll(2) failed: %s", sstrerror (errno, errbuf, sizeof (errbuf))); pinba_socket_free (s); return (-1); } for (i = 0; i < s->fd_num; i++) { if (s->fd[i].revents & (POLLERR | POLLHUP | POLLNVAL)) { pb_del_socket (s, i); i--; } else if (s->fd[i].revents & (POLLIN | POLLPRI)) { pinba_udp_read_callback_fn (s->fd[i].fd); } } /* for (s->fd) */ } /* while (!collector_thread_do_shutdown) */ pinba_socket_free (s); s = NULL; return (0); }
[ "993273596@qq.com" ]
993273596@qq.com
5b2b1ef5067921ce06cfec4bd2adcd5d52fcb50c
fe35c9799bc3171f7918ad2883faa3a36eff53ca
/group-privacy-server/group_privacy/mpi/BigIntegerArithmeticOperators.cpp
8c61cbe1f970d2b4dfe163db9afaef5bfce9ba35
[]
no_license
pawel-kieliszczyk/step-out-group-signatures
63a1312b97884a40f8344a884e4dd62187fe07d3
fc2c81f01a9760f5a79719e02f52ae369e8bc2a4
refs/heads/master
2020-12-24T14:17:44.677979
2018-09-12T18:13:37
2018-09-12T18:13:37
31,135,798
0
1
null
null
null
null
UTF-8
C++
false
false
2,164
cpp
/** * @file BigIntegerArithmeticOperators.cpp * @author Pawel Kieliszczyk <pawel.kieliszczyk@gmail.com> * @version 1.0 * * @section LICENSE * * Copyright (C) 2011 Pawel Kieliszczyk * * This file is part of Group Privacy. * * Group Privacy is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Group Privacy is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Group Privacy. If not, see <http://www.gnu.org/licenses/>. * * @section DESCRIPTION */ #include "BigIntegerArithmeticOperators.hpp" #include "BigIntegerClass.hpp" const BigInteger operator+(const BigInteger& p_left, const BigInteger& p_right) { BigInteger l_result(p_left); l_result += p_right; return l_result; } const BigInteger operator-(const BigInteger& p_left, const BigInteger& p_right) { BigInteger l_result(p_left); l_result -= p_right; return l_result; } const BigInteger operator*(const BigInteger& p_left, const BigInteger& p_right) { BigInteger l_result(p_left); l_result *= p_right; return l_result; } const BigInteger operator/(const BigInteger& p_left, const BigInteger& p_right) { BigInteger l_result(p_left); l_result /= p_right; return l_result; } const BigInteger operator%(const BigInteger& p_left, const BigInteger& p_right) { BigInteger l_result(p_left); l_result %= p_right; return l_result; } const BigInteger powm(const BigInteger& p_bigInteger, const BigInteger& p_power, const BigInteger& p_modulo) { BigInteger l_result(p_bigInteger); l_result.powm(p_power, p_modulo); return l_result; } const BigInteger invm(const BigInteger& a, const BigInteger& modulo) { BigInteger result; result.invm(a, modulo); return result; }
[ "pawel.kieliszczyk@gmail.com" ]
pawel.kieliszczyk@gmail.com
680c45ca9daa6546b59e1c3dca5c6ab81875b588
615ecb70e28d608a0422d5b27567681880e08460
/source/uwp/AdaptiveCardsObjectModel/lib/AdaptiveTable.h
a59be2f847bcc72b3f241a72b82ee2d3dcbca7a4
[ "LicenseRef-scancode-proprietary-license", "MIT" ]
permissive
paulcam206/AdaptiveCards
23f8a61ca756a6655760d0a137f888dd68aac560
ba70032204e683122170e9a1bc9d73e316f09a48
refs/heads/main
2023-08-14T13:07:56.337291
2021-08-25T18:19:26
2021-08-25T18:19:26
368,345,206
0
0
MIT
2021-05-17T23:18:09
2021-05-17T23:18:09
null
UTF-8
C++
false
false
7,611
h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include "Table.h" namespace AdaptiveCards::ObjectModel::Uwp { class DECLSPEC_UUID("CA752EA7-A7D4-4D1A-BAA3-3318A29FE52D") AdaptiveTable : public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::WinRtClassicComMix>, ABI::AdaptiveCards::ObjectModel::Uwp::IAdaptiveTable, ABI::AdaptiveCards::ObjectModel::Uwp::IAdaptiveCardElement, Microsoft::WRL::CloakedIid<ITypePeek>, Microsoft::WRL::CloakedIid<AdaptiveCards::ObjectModel::Uwp::AdaptiveCardElementBase>> { AdaptiveRuntime(AdaptiveTable); public: AdaptiveTable(); HRESULT RuntimeClassInitialize() noexcept; HRESULT RuntimeClassInitialize(const std::shared_ptr<AdaptiveCards::Table>& sharedTable); // IAdaptiveTable IFACEMETHODIMP get_Rows( _COM_Outptr_ ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveCards::ObjectModel::Uwp::AdaptiveTableRow*>** rows) override; IFACEMETHODIMP get_Columns( _COM_Outptr_ ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveCards::ObjectModel::Uwp::AdaptiveTableColumnDefinition*>** columns) override; IFACEMETHODIMP get_ShowGridLines(_Out_ boolean* showGridLines); IFACEMETHODIMP put_ShowGridLines(boolean showGridLines); IFACEMETHODIMP get_FirstRowAsHeaders(_Out_ boolean* firstRowAsHeaders); IFACEMETHODIMP put_FirstRowAsHeaders(boolean firstRowAsHeaders); IFACEMETHODIMP get_VerticalCellContentAlignment( _COM_Outptr_ ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::VerticalContentAlignment>** verticalCellContentAlignment) override; IFACEMETHODIMP put_VerticalCellContentAlignment( _In_ ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::VerticalContentAlignment>* verticalCellContentAlignment) override; IFACEMETHODIMP get_HorizontalCellContentAlignment( _COM_Outptr_ ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::HAlignment>** horizontalCellContentAlignment) override; IFACEMETHODIMP put_HorizontalCellContentAlignment( _In_ ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::HAlignment>* horizontalCellContentAlignment) override; IFACEMETHODIMP get_GridStyle(_Out_ ABI::AdaptiveCards::ObjectModel::Uwp::ContainerStyle* style) override; IFACEMETHODIMP put_GridStyle(ABI::AdaptiveCards::ObjectModel::Uwp::ContainerStyle style) override; // IAdaptiveCardElement IFACEMETHODIMP get_ElementType(_Out_ ABI::AdaptiveCards::ObjectModel::Uwp::ElementType* elementType) override; IFACEMETHODIMP get_Spacing(_Out_ ABI::AdaptiveCards::ObjectModel::Uwp::Spacing* spacing) override { return AdaptiveCardElementBase::get_Spacing(spacing); } IFACEMETHODIMP put_Spacing(ABI::AdaptiveCards::ObjectModel::Uwp::Spacing spacing) override { return AdaptiveCardElementBase::put_Spacing(spacing); } IFACEMETHODIMP get_Separator(_Out_ boolean* separator) override { return AdaptiveCardElementBase::get_Separator(separator); } IFACEMETHODIMP put_Separator(boolean separator) override { return AdaptiveCardElementBase::put_Separator(separator); } IFACEMETHODIMP get_IsVisible(_Out_ boolean* isVisible) override { return AdaptiveCardElementBase::get_IsVisible(isVisible); } IFACEMETHODIMP put_IsVisible(boolean isVisible) override { return AdaptiveCardElementBase::put_IsVisible(isVisible); } IFACEMETHODIMP get_Id(_Outptr_ HSTRING* id) override { return AdaptiveCardElementBase::get_Id(id); } IFACEMETHODIMP put_Id(_In_ HSTRING id) override { return AdaptiveCardElementBase::put_Id(id); } IFACEMETHODIMP get_FallbackType(_Out_ ABI::AdaptiveCards::ObjectModel::Uwp::FallbackType* fallback) override { return AdaptiveCardElementBase::get_FallbackType(fallback); } IFACEMETHODIMP get_FallbackContent(_COM_Outptr_ ABI::AdaptiveCards::ObjectModel::Uwp::IAdaptiveCardElement** content) override { return AdaptiveCardElementBase::get_FallbackContent(content); } IFACEMETHODIMP put_FallbackType(ABI::AdaptiveCards::ObjectModel::Uwp::FallbackType fallback) override { return AdaptiveCardElementBase::put_FallbackType(fallback); } IFACEMETHODIMP put_FallbackContent(_In_ ABI::AdaptiveCards::ObjectModel::Uwp::IAdaptiveCardElement* content) override { return AdaptiveCardElementBase::put_FallbackContent(content); } IFACEMETHODIMP get_ElementTypeString(_Outptr_ HSTRING* value) override { return AdaptiveCardElementBase::get_ElementTypeString(value); } IFACEMETHODIMP get_AdditionalProperties(_COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result) override { return AdaptiveCardElementBase::get_AdditionalProperties(result); } IFACEMETHODIMP put_AdditionalProperties(_In_ ABI::Windows::Data::Json::IJsonObject* value) override { return AdaptiveCardElementBase::put_AdditionalProperties(value); } IFACEMETHODIMP get_Requirements( _COM_Outptr_ ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveCards::ObjectModel::Uwp::AdaptiveRequirement*>** requirements) override { return AdaptiveCardElementBase::get_Requirements(requirements); } IFACEMETHODIMP ToJson(_COM_Outptr_ ABI::Windows::Data::Json::IJsonObject** result) override { return AdaptiveCardElementBase::ToJson(result); } IFACEMETHODIMP get_Height(_Out_ ABI::AdaptiveCards::ObjectModel::Uwp::HeightType* height) override { return AdaptiveCardElementBase::get_Height(height); } IFACEMETHODIMP put_Height(ABI::AdaptiveCards::ObjectModel::Uwp::HeightType height) override { return AdaptiveCardElementBase::put_Height(height); } // ITypePeek method void* PeekAt(REFIID riid) override { return PeekHelper(riid, this); } // AdaptiveCardElementBase virtual HRESULT GetSharedModel(std::shared_ptr<AdaptiveCards::BaseCardElement>& sharedModel) override; private: boolean m_showGridLines; boolean m_firstRowAsHeaders; Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::VerticalContentAlignment>> m_verticalCellContentAlignment; Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IReference<ABI::AdaptiveCards::ObjectModel::Uwp::HAlignment>> m_horizontalCellContentAlignment; ABI::AdaptiveCards::ObjectModel::Uwp::ContainerStyle m_gridStyle; Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveCards::ObjectModel::Uwp::AdaptiveTableRow*>> m_rows; Microsoft::WRL::ComPtr<ABI::Windows::Foundation::Collections::IVector<ABI::AdaptiveCards::ObjectModel::Uwp::AdaptiveTableColumnDefinition*>> m_columnDefinitions; }; ActivatableClass(AdaptiveTable); }
[ "noreply@github.com" ]
paulcam206.noreply@github.com
30a415f6361a0d328cf49a4e11059eae6d1adad3
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5744014401732608_1/C++/david942j/code3.cpp
df2aae9c260c20b38715b4619d9c8cfea019f989
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
2,943
cpp
//by david942j #include <cstdio> #include <cstring> #include <set> #include <map> #include <ctime> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <deque> #include <cassert> #include <queue> #include <stack> #include <cstdlib> #ifndef DAVID #include <bits/stdc++.h> #endif #define openfile(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout) #define mpr std::make_pair #define lg(x) (31-__builtin_clz(x)) #define lgll(x) (63-__builtin_clzll(x)) #define __count __builtin_popcount #define __countll __builtin_popcountll #define X first #define Y second #define mst(x) memset(x,0,sizeof(x)) #define mst1(x) memset(x,-1,sizeof(x)) #define ALL(c) (c).begin(),(c).end() #define FOR(i,n) for(int i=0;i<n;i++) #define FOR1(i,n) for(int i=1;i<=n;i++) #define FORit(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();++it) #define pb push_back #define RI(x) scanf("%d",&x) #define RID(x) int x;RI(x) using namespace std; template<typename T> void _R( T &x ) { cin>>x; } void _R( int &x ) { scanf("%d",&x); } #ifdef PRId64 void _R( long long &x ) { scanf("%" PRId64,&x); } #else void _R( long long &x) {cin >> x;} #endif void _R( double &x ) { scanf("%lf",&x); } void _R( char &x ) { scanf(" %c",&x); } void _R( char *x ) { scanf("%s",x); } void R() {} template<typename T, typename... U> void R( T& head, U&... tail ) { _R(head); R(tail...); } template<typename T> void _W( const T &x ) { cout<<x; } void _W( const int &x ) { printf("%d",x); } template<typename T> void _W( const vector<T> &x ) { for ( auto i=x.cbegin(); i!=x.cend(); i++ ) { if ( i!=x.cbegin() ) putchar(' '); _W(*i); } } void W() {} template<typename T, typename... U> void W( const T& head, const U&... tail ) { _W(head); putchar(sizeof...(tail)?' ':'\n'); W(tail...); } #ifdef DAVID #define debug(format, ...) fprintf(stderr, format, ##__VA_ARGS__) #else #define debug(...) #endif typedef long long LL; typedef double LD; typedef vector<int> VI; typedef std::pair<int,int> PII; template<class T>inline void maz(T &a,T b){if(a<b)a=b;} template<class T>inline void miz(T &a,T b){if(a>b)a=b;} template<class T>inline T abs(T a){return a>0?a:-a;} const int N=100; const int INF=1e9+7; int n; LL m; bool A[N]; int main() { RID(T); FOR1(w,T) { RI(n); scanf("%lld", &m); LL Max = 1LL << (n-2); printf("Case #%d: ", w); if(Max < m) {puts("IMPOSSIBLE");continue;} puts("POSSIBLE"); mst(A); if(m==Max) { FOR1(i,n-1) A[i] = true; } else { for(int i=2;i<n;i++) if(m & (1LL<<(i-2))) A[i]=true; } FOR1(i,n)FOR1(j,n) { if(j==n) puts(A[i] ? "1":"0"); else putchar(i<j ? '1':'0'); } } return 0; } /* */
[ "alexandra1.back@gmail.com" ]
alexandra1.back@gmail.com
ab35c8ce809ea81baa7dd4640cd2ccfc88cc394b
5568016bf15db275d3997bb8672d436faa6a1281
/Queue List/node.h
27ed8d4a23aa8f43da51b91d726e75572dba8bf4
[]
no_license
zeeshanarif513/DataStructures-Projects
6c2a7bf638a5799b4345dcca221c82563ddcd76a
edd02e57a5b843e1cae46a82300f3bca40ae61c6
refs/heads/main
2023-07-16T22:34:02.148874
2021-08-18T16:36:02
2021-08-18T16:36:02
397,669,440
0
0
null
null
null
null
UTF-8
C++
false
false
235
h
#ifndef NODE_H #define NODE_H #include<iostream> using namespace std; class Node { private: int data; Node *next; public: Node(); void setData(int); void setNext(Node*); int getData() const; Node* getNext() const; }; #endif
[ "zeeshanarif513@gmail.com" ]
zeeshanarif513@gmail.com
4778dd04594e1ee046b7520549a3d68b2cd19ffe
9c5a9cdad7a0975824d7a291d53c3801fa7c3f80
/PAT/code/fifth/5.1/5.1 2 B1003(20)/5.1 2 B1003(20)/stdafx.cpp
dd63c8457b72dfff90e67c3ee020f4557786a5a5
[]
no_license
luckyxuanyeah/Algorithm_Practice
893c6aaae108ab652a0355352366a393553940fe
4f6206a8bfd94d64961f2a8fb07b8afbeb82c1b1
refs/heads/master
2020-04-06T13:48:11.653204
2019-07-17T15:35:47
2019-07-17T15:35:47
157,508,492
0
0
null
2018-11-14T08:19:44
2018-11-14T07:27:47
null
GB18030
C++
false
false
268
cpp
// stdafx.cpp : 只包括标准包含文件的源文件 // 5.1 2 B1003(20).pch 将作为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" // TODO: 在 STDAFX.H 中 // 引用任何所需的附加头文件,而不是在此文件中引用
[ "382435443@qq.com" ]
382435443@qq.com
ff52bd7ff3f7b9d0e620d35a1836ac7d3831eb68
4df97e21fa3924c8f4204ab52c2a66618f0a18fa
/LimaDetector/specifics/ProsilicaCCD/ProsilicaCCDClass.cpp
df0bb762837797335b4001715b0d4171ba25ddd8
[]
no_license
soleil-ica/Lima-tango
0edda611fd3c80c998486e439d59889d44cc944b
ef051dc3a619c8d845d1b1c1bd7f695964bba82b
refs/heads/master
2021-01-18T05:50:04.894814
2015-11-06T11:24:42
2015-11-06T11:24:42
6,884,986
0
2
null
2012-12-11T16:10:31
2012-11-27T14:43:06
C++
UTF-8
C++
false
false
12,741
cpp
static const char *ClassId = "$Id: $"; static const char *TagName = "$Name: $"; static const char *CvsPath = "$Source: $"; static const char *SvnPath = "$HeadURL: $"; static const char *HttpServer = "http://www.esrf.fr/computing/cs/tango/tango_doc/ds_doc/"; //+============================================================================= // // file : ProsilicaCCDClass.cpp // // description : C++ source for the ProsilicaCCDClass. A singleton // class derived from DeviceClass. It implements the // command list and all properties and methods required // by the ProsilicaCCD once per process. // // project : TANGO Device Server // // $Author: $ // // $Revision: $ // // $Log: $ // // copyleft : European Synchrotron Radiation Facility // BP 220, Grenoble 38043 // FRANCE // //-============================================================================= // // This file is generated by POGO // (Program Obviously used to Generate tango Object) // // (c) - Software Engineering Group - ESRF //============================================================================= #ifdef WIN32 #include "tango.h" #endif #include <ProsilicaCCD.h> #include <ProsilicaCCDClass.h> #ifndef WIN32 #include "tango.h" #endif //+---------------------------------------------------------------------------- /** * Create ProsilicaCCDClass singleton and return it in a C function for Python usage */ //+---------------------------------------------------------------------------- extern "C" { #ifdef WIN32 __declspec(dllexport) #endif Tango::DeviceClass *_create_ProsilicaCCD_class(const char *name) { return ProsilicaCCD_ns::ProsilicaCCDClass::init(name); } } namespace ProsilicaCCD_ns { // //---------------------------------------------------------------- // Initialize pointer for singleton pattern //---------------------------------------------------------------- // ProsilicaCCDClass *ProsilicaCCDClass::_instance = NULL; //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::ProsilicaCCDClass(string &s) // // description : constructor for the ProsilicaCCDClass // // in : - s : The class name // //----------------------------------------------------------------------------- ProsilicaCCDClass::ProsilicaCCDClass(string &s):DeviceClass(s) { cout2 << "Entering ProsilicaCCDClass constructor" << endl; set_default_property(); get_class_property(); write_class_property(); cout2 << "Leaving ProsilicaCCDClass constructor" << endl; } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::~ProsilicaCCDClass() // // description : destructor for the ProsilicaCCDClass // //----------------------------------------------------------------------------- ProsilicaCCDClass::~ProsilicaCCDClass() { _instance = NULL; } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::instance // // description : Create the object if not already done. Otherwise, just // return a pointer to the object // // in : - name : The class name // //----------------------------------------------------------------------------- ProsilicaCCDClass *ProsilicaCCDClass::init(const char *name) { if (_instance == NULL) { try { string s(name); _instance = new ProsilicaCCDClass(s); } catch (bad_alloc) { throw; } } return _instance; } ProsilicaCCDClass *ProsilicaCCDClass::instance() { if (_instance == NULL) { cerr << "Class is not initialised !!" << endl; exit(-1); } return _instance; } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::command_factory // // description : Create the command object(s) and store them in the // command list // //----------------------------------------------------------------------------- void ProsilicaCCDClass::command_factory() { // add polling if any for (unsigned int i=0 ; i<command_list.size(); i++) { } } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::get_class_property // // description : Get the class property for specified name. // // in : string name : The property name // //+---------------------------------------------------------------------------- Tango::DbDatum ProsilicaCCDClass::get_class_property(string &prop_name) { for (unsigned int i=0 ; i<cl_prop.size() ; i++) if (cl_prop[i].name == prop_name) return cl_prop[i]; // if not found, return an empty DbDatum return Tango::DbDatum(prop_name); } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::get_default_device_property() // // description : Return the default value for device property. // //----------------------------------------------------------------------------- Tango::DbDatum ProsilicaCCDClass::get_default_device_property(string &prop_name) { for (unsigned int i=0 ; i<dev_def_prop.size() ; i++) if (dev_def_prop[i].name == prop_name) return dev_def_prop[i]; // if not found, return an empty DbDatum return Tango::DbDatum(prop_name); } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::get_default_class_property() // // description : Return the default value for class property. // //----------------------------------------------------------------------------- Tango::DbDatum ProsilicaCCDClass::get_default_class_property(string &prop_name) { for (unsigned int i=0 ; i<cl_def_prop.size() ; i++) if (cl_def_prop[i].name == prop_name) return cl_def_prop[i]; // if not found, return an empty DbDatum return Tango::DbDatum(prop_name); } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::device_factory // // description : Create the device object(s) and store them in the // device list // // in : Tango::DevVarStringArray *devlist_ptr : The device name list // //----------------------------------------------------------------------------- void ProsilicaCCDClass::device_factory(const Tango::DevVarStringArray *devlist_ptr) { // Create all devices.(Automatic code generation) //------------------------------------------------------------- for (unsigned long i=0 ; i < devlist_ptr->length() ; i++) { cout4 << "Device name : " << (*devlist_ptr)[i].in() << endl; // Create devices and add it into the device list //---------------------------------------------------- device_list.push_back(new ProsilicaCCD(this, (*devlist_ptr)[i])); // Export device to the outside world // Check before if database used. //--------------------------------------------- if ((Tango::Util::_UseDb == true) && (Tango::Util::_FileDb == false)) export_device(device_list.back()); else export_device(device_list.back(), (*devlist_ptr)[i]); } // End of Automatic code generation //------------------------------------------------------------- } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::get_class_property() // // description : Read the class properties from database. // //----------------------------------------------------------------------------- void ProsilicaCCDClass::get_class_property() { // Initialize your default values here (if not done with POGO). //------------------------------------------------------------------ // Read class properties from database.(Automatic code generation) //------------------------------------------------------------------ // Call database and extract values //-------------------------------------------- if (Tango::Util::instance()->_UseDb==true) get_db_class()->get_property(cl_prop); Tango::DbDatum def_prop; int i = -1; // End of Automatic code generation //------------------------------------------------------------------ } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::set_default_property // // description: Set default property (class and device) for wizard. // For each property, add to wizard property name and description // If default value has been set, add it to wizard property and // store it in a DbDatum. // //----------------------------------------------------------------------------- void ProsilicaCCDClass::set_default_property() { string prop_name; string prop_desc; string prop_def; vector<string> vect_data; // Set Default Class Properties // Set Default Device Properties prop_name = "DetectorIP"; prop_desc = "Ip Address of the Detector."; prop_def = "127.0.0.1"; vect_data.clear(); vect_data.push_back("127.0.0.1"); if (prop_def.length()>0) { Tango::DbDatum data(prop_name); data << vect_data ; dev_def_prop.push_back(data); add_wiz_dev_prop(prop_name, prop_desc, prop_def); } else add_wiz_dev_prop(prop_name, prop_desc); } //+---------------------------------------------------------------------------- // // method : ProsilicaCCDClass::write_class_property // // description : Set class description as property in database // //----------------------------------------------------------------------------- void ProsilicaCCDClass::write_class_property() { // First time, check if database used //-------------------------------------------- if (Tango::Util::_UseDb == false) return; Tango::DbData data; string classname = get_name(); string header; string::size_type start, end; // Put title Tango::DbDatum title("ProjectTitle"); string str_title("Device specific for Prosilica CCD detector"); title << str_title; data.push_back(title); // Put Description Tango::DbDatum description("Description"); vector<string> str_desc; str_desc.push_back(" "); description << str_desc; data.push_back(description); // put cvs or svn location string filename(classname); filename += "Class.cpp"; // Create a string with the class ID to // get the string into the binary string class_id(ClassId); // check for cvs information string src_path(CvsPath); start = src_path.find("/"); if (start!=string::npos) { end = src_path.find(filename); if (end>start) { string strloc = src_path.substr(start, end-start); // Check if specific repository start = strloc.find("/cvsroot/"); if (start!=string::npos && start>0) { string repository = strloc.substr(0, start); if (repository.find("/segfs/")!=string::npos) strloc = "ESRF:" + strloc.substr(start, strloc.length()-start); } Tango::DbDatum cvs_loc("cvs_location"); cvs_loc << strloc; data.push_back(cvs_loc); } } // check for svn information else { string src_path(SvnPath); start = src_path.find("://"); if (start!=string::npos) { end = src_path.find(filename); if (end>start) { header = "$HeadURL: "; start = header.length(); string strloc = src_path.substr(start, (end-start)); Tango::DbDatum svn_loc("svn_location"); svn_loc << strloc; data.push_back(svn_loc); } } } // Get CVS or SVN revision tag // CVS tag string tagname(TagName); header = "$Name: "; start = header.length(); string endstr(" $"); end = tagname.find(endstr); if (end!=string::npos && end>start) { string strtag = tagname.substr(start, end-start); Tango::DbDatum cvs_tag("cvs_tag"); cvs_tag << strtag; data.push_back(cvs_tag); } // SVN tag string svnpath(SvnPath); header = "$HeadURL: "; start = header.length(); end = svnpath.find(endstr); if (end!=string::npos && end>start) { string strloc = svnpath.substr(start, end-start); string tagstr ("/tags/"); start = strloc.find(tagstr); if ( start!=string::npos ) { start = start + tagstr.length(); end = strloc.find(filename); string strtag = strloc.substr(start, end-start-1); Tango::DbDatum svn_tag("svn_tag"); svn_tag << strtag; data.push_back(svn_tag); } } // Get URL location string httpServ(HttpServer); if (httpServ.length()>0) { Tango::DbDatum db_doc_url("doc_url"); db_doc_url << httpServ; data.push_back(db_doc_url); } // Put inheritance Tango::DbDatum inher_datum("InheritedFrom"); vector<string> inheritance; inheritance.push_back("Device_4Impl"); inher_datum << inheritance; data.push_back(inher_datum); // Call database and and values //-------------------------------------------- get_db_class()->put_property(data); } } // namespace
[ "noureddine@synchrotron-soleil.fr" ]
noureddine@synchrotron-soleil.fr
dcd891b66c25af2d6eb31ccfc05dbe8d4dd00ce7
d00f4a09a0d6e9269dcba4ade632fae344d8930b
/benchmarks/module/math/tand/big/tand.hpp
2c0578fe211c57a1a8a5b82f30f0375975d6e466
[ "MIT" ]
permissive
mfkiwl/eve
b1e1e623b5d170a885f555906f4dc2faadcc626c
961749111b4edd78e4f69c6e2c5e4b1a9088a19a
refs/heads/main
2023-04-29T04:00:38.030889
2020-09-17T15:58:21
2020-09-17T15:58:21
355,671,435
0
0
MIT
2021-04-07T20:17:04
2021-04-07T20:17:03
null
UTF-8
C++
false
false
954
hpp
//================================================================================================== /** EVE - Expressive Vector Engine Copyright 2020 Joel FALCOU Copyright 2020 Jean-Thierry LAPRESTE Licensed under the MIT License <http://opensource.org/licenses/MIT>. SPDX-License-Identifier: MIT **/ //================================================================================================== #include <eve/function/tand.hpp> #include <eve/function/radindeg.hpp> #include <eve/constant/valmin.hpp> #include <eve/constant/valmax.hpp> #include <cmath> int main() { auto lmin = EVE_VALUE(eve::valmin(eve::as<EVE_VALUE>())); auto lmax = EVE_VALUE(eve::valmax(eve::as<EVE_VALUE>())); auto arg0 = eve::bench::random_<EVE_VALUE>(lmin,lmax); eve::bench::experiment xp; run<EVE_VALUE>(EVE_NAME(big_(eve::tand)) , xp, eve::big_(eve::tand) , arg0); run<EVE_TYPE> (EVE_NAME(big_(eve::tand)) , xp, eve::big_(eve::tand) , arg0); }
[ "noreply@github.com" ]
mfkiwl.noreply@github.com
1cb7568afa20ee3c53fa19fcc3ace0eabc5c7897
b258e2449fd26ab92c4be56a368e45c514efe60a
/moc_mendmodepage.cpp
623459ddfd3a9b52dcbfce4b53dcd3ed3f5dcf7a
[]
no_license
MinnieJewel/DJY
f6c3e6b99104f334fa41f98d6c5256352ff6fad8
74a3b6b34871a7fbd38b9fc0d8158b679d54014a
refs/heads/master
2022-09-16T19:30:46.147808
2020-06-02T06:29:42
2020-06-02T06:29:42
268,722,025
0
0
null
null
null
null
UTF-8
C++
false
false
2,746
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'mendmodepage.h' ** ** Created: Tue Jun 2 11:36:20 2020 ** by: The Qt Meta Object Compiler version 62 (Qt 4.6.3) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "mendmodepage.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mendmodepage.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 62 #error "This file was generated using the moc from 4.6.3. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE static const uint qt_meta_data_MendModePage[] = { // content: 4, // revision 0, // classname 0, 0, // classinfo 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: signature, parameters, type, tag, flags 14, 13, 13, 13, 0x08, 35, 13, 13, 13, 0x08, 62, 13, 13, 13, 0x08, 93, 85, 13, 13, 0x08, 0 // eod }; static const char qt_meta_stringdata_MendModePage[] = { "MendModePage\0\0on_btnBack_clicked()\0" "on_btnMendCancel_clicked()\0" "on_btnMendOk_clicked()\0checked\0" "on_btnMend_toggled(bool)\0" }; const QMetaObject MendModePage::staticMetaObject = { { &MyBase::staticMetaObject, qt_meta_stringdata_MendModePage, qt_meta_data_MendModePage, 0 } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &MendModePage::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *MendModePage::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *MendModePage::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_MendModePage)) return static_cast<void*>(const_cast< MendModePage*>(this)); return MyBase::qt_metacast(_clname); } int MendModePage::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = MyBase::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: on_btnBack_clicked(); break; case 1: on_btnMendCancel_clicked(); break; case 2: on_btnMendOk_clicked(); break; case 3: on_btnMend_toggled((*reinterpret_cast< bool(*)>(_a[1]))); break; default: ; } _id -= 4; } return _id; } QT_END_MOC_NAMESPACE
[ "jewelminnie@163.com" ]
jewelminnie@163.com
7897a6edfa2ca61142f67cdba47c0b751b7d98d1
4152142bf896443d94601cf4eee9690d36854f97
/build/moc/moc_profilesdialog.cpp
4c59cf3e59b3a1ce9262abf60bb16268b63b467d
[]
no_license
Faridik/Courses
02e59face6d89aa0c1207df80886196b6245fc98
bd1cf92cc88dc70b5f43b432aee5849c51bf18ee
refs/heads/master
2020-04-12T16:41:19.531350
2018-12-20T19:43:09
2018-12-20T19:43:09
162,620,909
0
0
null
2018-12-20T19:38:53
2018-12-20T19:05:56
C++
UTF-8
C++
false
false
2,792
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'profilesdialog.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.11.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../profilesdialog.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'profilesdialog.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.11.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_ProfilesDialog_t { QByteArrayData data[1]; char stringdata0[15]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_ProfilesDialog_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_ProfilesDialog_t qt_meta_stringdata_ProfilesDialog = { { QT_MOC_LITERAL(0, 0, 14) // "ProfilesDialog" }, "ProfilesDialog" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_ProfilesDialog[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void ProfilesDialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } QT_INIT_METAOBJECT const QMetaObject ProfilesDialog::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_ProfilesDialog.data, qt_meta_data_ProfilesDialog, qt_static_metacall, nullptr, nullptr} }; const QMetaObject *ProfilesDialog::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *ProfilesDialog::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_ProfilesDialog.stringdata0)) return static_cast<void*>(this); return QDialog::qt_metacast(_clname); } int ProfilesDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "noreply@github.com" ]
Faridik.noreply@github.com
4c26d5b3000bef3f065be95f07d3b6b1e87706ff
d7991ba2766a15e50a560c7d0973f299f2a2987b
/programa9/main.cpp
74b6c5a3fdcb3f90d8e1b70d2cb60df36a81dc3c
[]
no_license
crcenteno9933/programacion2sisty
ca77173ec0c7c065c25aff22735cc2f094bab670
d579ade8b3e9764b183340f24af7c60e6ca827a8
refs/heads/master
2021-01-19T14:33:01.941943
2014-06-13T01:27:45
2014-06-13T01:27:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
932
cpp
#include <iostream> using namespace std; /* ingresar cinco numeros y determinar cuales son pares e impares luego debera de representar al final el primedio de los numeros pares e impares y los contadores */ int main() { int cpar, cimpar, num,c,prom1par,prom2impar,sum1par,sum2impar; cpar=0; cimpar=0; c=0; prom1par=0; sum1par=0; sum2impar=0; prom2impar=0; while(c<5) { cout <<"Ingresar un numeros.....>"; cin>>num; if(num % 2==0) { cpar++; sum1par = sum1par + num; } else { cimpar++; sum2impar = sum2impar + num; } c++; } prom2impar = sum2impar/cimpar; prom1par = sum1par/cpar; cout<<"promedio de los numeros pares...."<<prom1par<<"\n"; cout<<"promedio de los numeros impares..."<<prom2impar<<"\n"; cout<<"Numero de pares es..."<<cpar<<"\n"; cout<<"Numero de numeros impares..."<<cimpar<<"\n"; }
[ "carlosr.centenol@gmail.com" ]
carlosr.centenol@gmail.com
fac159c0fba2ed51acd6d3b2d11b3e48f698db9c
b291f4f513a19c17bd79c66e127a605cb4b7d82e
/Board.cpp
8e0b6275c0ebfee8c8800728ef67ff62d9312b08
[]
no_license
mefisher95/Othello
47a18414af8f14c9c61a51d3270a61847dea619d
d590c179225b93899b5f38522d67cda1e67069d6
refs/heads/master
2021-01-08T15:42:14.880854
2020-02-21T06:39:28
2020-02-21T06:39:28
242,070,437
0
0
null
null
null
null
UTF-8
C++
false
false
11,299
cpp
/******************************************************************************** / Project: Othello /------------------------------------------------------------------------------- / By: Michael Fisher, 2019 /================================================================================ / File: Board.cpp / / Sorce file for the Board Class ********************************************************************************/ #include "Board.h" #include <ctime> Sound Board::sound("sounds/toggle.wav"); // manually changes the turn for the players void Board::change_turn() { if (turn_ == 1) turn_ = 2; else turn_ = 1; } // returns what the player state of a square is (empty = 0, black = 1, white = 2) int Board::board_state(int x, int y) const { return (board_arr[x][y].state()); } // allows moves by human players void Board::select() { if (!is_moveable()) { change_turn(); return; } for(int i = 0; i < size_; ++i) { for (int j = 0; j < size_; ++j) { if (mouse_left() && mouse_x() > board_arr[i][j].x() && mouse_x() < board_arr[i][j].x() + board_arr[i][j].w() && mouse_y() > board_arr[i][j].y() && mouse_y() < board_arr[i][j].y() + board_arr[i][j].h()) { if (board_arr[i][j].state() == 0 && valid(i, j)) { flip(i, j); sound.play(); change_turn(); } } } } } // sets the positions of all squares, and sets all states to 0, except for center void Board::make() { for (int i = 0; i < size_; ++i) { for (int j = 0; j < size_; ++j) { board_arr[i][j].rect_out.x = 80 * i + 2; board_arr[i][j].rect_in.x = 80 * i + 4; board_arr[i][j].rect_out.y = 80 * j + 2; board_arr[i][j].rect_in.y = 80 * j + 4; board_arr[i][j].state() = 0; int mid = 8 / 2; board_arr[mid - 1][mid - 1].state() = 1; board_arr[mid - 1][mid].state() = 2; board_arr[mid][mid - 1].state() = 2; board_arr[mid][mid].state() = 1; } } } // draws the board with pieces corresponding to the square state void Board::draw() { for (int i = 0; i < size_; ++i) { for (int j = 0; j < size_; ++j) { surface_.put_rect(board_arr[i][j].get_rect_out(), BLACK); surface_.put_rect(board_arr[i][j].get_rect_in(), FORREST_GREEN); if (board_arr[i][j].state_ == 1) surface_.put_circle(board_arr[i][j].rect_out.x + board_arr[i][j].rect_out.w / 2, board_arr[i][j].rect_out.y + board_arr[i][j].rect_out.h / 2, 10, BLACK); if (board_arr[i][j].state_ == 2) surface_.put_circle(board_arr[i][j].rect_out.x + board_arr[i][j].rect_out.w / 2, board_arr[i][j].rect_out.y + board_arr[i][j].rect_out.h / 2, 10, WHITE); } } } // returns the number of total squares with the requested state int Board::num_count(int state) const { int ret = 0; for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (board_arr[x][y].state() == state) ++ret; } } return ret; } // ai player; void Board::ai(int player) { srand((unsigned int) time(NULL)); if (!is_moveable()) { change_turn(); return; } if (turn() != player) return; while(1) { int x = rand() % 8; int y = rand() % 8; if (valid(x, y)) { board_arr[x][y].state() = player; flip(x, y); change_turn(); return; } } } //============================================================================== // boolean checks for position //============================================================================== // cardinal positions bool Board::north(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x][y - 1].state() == enemy) for (int i = 0; i < y; ++i) { if (board_arr[x][y - i].state() == enemy && board_arr[x][y - i - 1].state() != 0 && board_arr[x][y - i - 1].state() == player) return true; } return false; } bool Board::south(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x][y + 1].state() == enemy) for (int i = 0; i < 8 - y - 1; ++i) { if (board_arr[x][y + i].state() == enemy && board_arr[x][y + i + 1].state() != 0 && board_arr[x][y + i + 1].state() == player) return true; } return false; } bool Board::east(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x + 1][y].state() == enemy) for (int i = 0; i < 8 - x - 1; ++i) { if (board_arr[x + i][y].state() == enemy && board_arr[x + i + 1][y].state() != 0 && board_arr[x + i + 1][y].state() == player) return true; } return false; } bool Board::west(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x - 1][y].state() == enemy) for (int i = 0; i < x; ++i) { if (board_arr[x - i][y].state() == enemy && board_arr[x - i - 1][y].state() != 0 && board_arr[x - i - 1][y].state() == player) return true; } return false; } // oblique positions bool Board::northeast(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x + 1][y - 1].state() == enemy) for (int i = 0; i < y && i < 8 - x - 1; ++i) { if (board_arr[x + i][y - i].state() == enemy && board_arr[x + i + 1][y - i - 1].state() != 0 && board_arr[x + i + 1][y - i - 1].state() == player) return true; } return false; } bool Board::northwest(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x - 1][y - 1].state() == enemy) for (int i = 0; i < y && i < x; ++i) { if (board_arr[x - i][y - i].state() == enemy && board_arr[x - i - 1][y - i - 1].state() != 0 && board_arr[x - i - 1][y - i - 1].state() == player) return true; } return false; } bool Board::southeast(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x + 1][y + 1].state() == enemy) for (int i = 0; i < 8 - y - 1 && i < 8 - x - 1; ++i) { if (board_arr[x + i][y + i].state() == enemy && board_arr[x + i + 1][y + i + 1].state() != 0 && board_arr[x + i + 1][y + i + 1].state() == player) return true; } return false; } bool Board::southwest(int x, int y) { int player, enemy; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (board_arr[x - 1][y + 1].state() == enemy) for (int i = 0; i < 8 - y - 1 && i < x; ++i) { if (board_arr[x - i][y + i].state() == enemy && board_arr[x - i - 1][y + i + 1].state() != 0 && board_arr[x - i - 1][y + i + 1].state() == player) return true; } return false; } bool Board::valid(int x, int y) { if ((north(x, y) || south(x, y) || west(x, y) || east(x, y) || northwest(x, y) || northeast(x, y) || southwest(x, y) || southeast(x, y)) && board_arr[x][y].state() == 0) return true; return false; } bool Board::is_moveable() { for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (valid(x, y)) return true; } } return false; } bool Board::is_moveable(int turn) { for (int x = 0; x < 8; ++x) { for (int y = 0; y < 8; ++y) { if (valid(x, y)) return true; } } return false; } void Board::flip(int x, int y) { int player, enemy, end; if (turn_ == 1) { player = 1; enemy = 2; } else { player = 2; enemy = 1; } if (north(x, y)) { end = 0; for (int i = 1; i <= y; ++i) { if (board_arr[x][y - i].state() == player) { end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x][y - i].state() = player; } } if (south(x, y)) { end = 0; for (int i = 1; i <= 8 - y; ++i) { if (board_arr[x][y + i].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x][y + i].state() = player; } } if (east(x, y)) { end = 0; for (int i = 1; i <= 8 - x; ++i) { if (board_arr[x + i][y].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x + i][y].state() = player; } } if (west(x, y)) { end = 0; for (int i = 1; i <= 8; ++i) { if (board_arr[x - i][y].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x - i][y].state() = player; } } if (northeast(x, y)) { end = 0; for (int i = 1; i <= 8; ++i) { if (board_arr[x + i][y - i].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x + i][y - i].state() = player; } } if (northwest(x, y)) { end = 0; for (int i = 1; i <= 8; ++i) { if (board_arr[x - i][y - i].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x - i][y - i].state() = player; } } if (southwest(x, y)) { end = 0; for (int i = 1; i <= 8; ++i) { if (board_arr[x - i][y + i].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x - i][y + i].state() = player; } } if (southeast(x, y)) { end = 0; for (int i = 1; i <= 8; ++i) { if (board_arr[x + i][y + i].state() == player) {end = i; break; } } for (int i = 0; i <= end; ++i) { board_arr[x + i][y + i].state() = player; } } }
[ "noreply@github.com" ]
mefisher95.noreply@github.com
9a5f40e9eea36848ad104de2bb0652cf4ccc030c
8c37b5363ff77a10e9c54204bc88b1c9861cdee6
/torch/csrc/jit/script/builtin_functions.cpp
a09d177210a2bc96fa4bc60da7d867907e3ca2e0
[ "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
gchanan/pytorch
50bf0843388c5ce3a818cf79688cf319b2262b15
0d03e73ae73aa6964ef72f848a77d27afeacf329
refs/heads/master
2021-07-02T16:20:50.304428
2019-12-26T20:52:21
2019-12-26T20:52:21
88,906,627
9
1
NOASSERTION
2019-12-26T20:52:23
2017-04-20T20:14:16
Python
UTF-8
C++
false
false
3,955
cpp
#include <torch/csrc/api/include/torch/jit.h> #include <torch/csrc/jit/code_template.h> #include <torch/csrc/jit/script/builtin_functions.h> #include <torch/csrc/jit/script/resolver.h> namespace torch { namespace jit { namespace script { auto scalar_operators_source = CodeTemplate( R"SCRIPT( def mul(a : ${Scalar}, b : Tensor) -> Tensor: return b * a def add(a : ${Scalar}, b : Tensor) -> Tensor: return b + a def ne(a : ${Scalar}, b : Tensor) -> Tensor: return b != a def eq(a : ${Scalar}, b : Tensor) -> Tensor: return b == a def lt(a : ${Scalar}, b : Tensor) -> Tensor: return b > a def le(a : ${Scalar}, b : Tensor) -> Tensor: return b >= a def gt(a : ${Scalar}, b : Tensor) -> Tensor: return b < a def ge(a : ${Scalar}, b : Tensor) -> Tensor: return b <= a def sub(a : ${Scalar}, b : Tensor) -> Tensor: return torch.neg(b) + a def div(a : ${Scalar}, b : Tensor) -> Tensor: return torch.reciprocal(b) * a )SCRIPT"); auto _ntuple_ops = CodeTemplate( R"SCRIPT( def _${name}(x: BroadcastingList${Length}[${Scalar}]) -> List[${Scalar}]: return x )SCRIPT"); auto floordiv = CodeTemplate( R"SCRIPT( def floordiv(self : Tensor, other : ${Rhs_Type}) -> Tensor: return torch.floor_divide(self, other) )SCRIPT"); struct BuiltinFunctionRegistry { const std::vector<Function*>& getAllBuiltinFunctionsFor( Symbol name) { const static std::vector<Function*> empty; // when initializing the builtin function library, we will re-enter // getAllBuiltinFunctionsFor since it is called in the compiler to // lookup builtins and initializing the builtin functions calls the // compiler. To avoid deadlocking, we use a recursive mutex (same thread can // re-lock, the mutex without waiting), and report no loaded builtins during // init. std::lock_guard<std::recursive_mutex> guard(mutex); if (state == INTIIALIZING) { return empty; } else if (state == UNINITIALIZED) { state = INTIIALIZING; loadBuiltinFunctions(); state = INITIALIZED; } AT_ASSERT(state == INITIALIZED); auto it = builtins_by_name_.find(name); if (it == builtins_by_name_.end()) return empty; return it->second; } private: void loadSource(const std::string& source) { std::shared_ptr<CompilationUnit> cu = std::make_shared<CompilationUnit>(); modules.emplace_back(cu); cu->define( c10::nullopt, source, script::nativeResolver(), /*self=*/nullptr); for (auto& method : cu->get_functions()) { builtins_by_name_[Symbol::fromQualString("aten::" + method->name())] .push_back(method); } } void loadBuiltinFunctions() { for (auto scalar : {"float", "int"}) { TemplateEnv env; env.s("Scalar", scalar); loadSource(scalar_operators_source.format(env)); } using str_pair = std::pair<std::string, std::string>; const std::vector<str_pair> name_len = { str_pair("single", "1"), str_pair("pair", "2"), str_pair("triple", "3"), str_pair("quadruple", "4"), }; for (auto scalar : {"float", "int"}) { for (auto pair : name_len) { TemplateEnv env; env.s("Scalar", scalar); env.s("name", pair.first); env.s("Length", pair.second); loadSource(_ntuple_ops.format(env)); } } for (auto rhs : {"number", "Tensor"}) { TemplateEnv env; env.s("Rhs_Type", rhs); loadSource(floordiv.format(env)); } } enum { UNINITIALIZED, INTIIALIZING, INITIALIZED } state = UNINITIALIZED; std::recursive_mutex mutex; std::vector<std::shared_ptr<CompilationUnit>> modules; std::unordered_map<Symbol, std::vector<Function*>> builtins_by_name_; }; const std::vector<Function*>& getAllBuiltinFunctionsFor( Symbol name) { static BuiltinFunctionRegistry registry; return registry.getAllBuiltinFunctionsFor(name); } } // namespace script } // namespace jit } // namespace torch
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
ca47830e3446012cd8c35fb4140f006594e89045
3ac8c943b13d943fbd3b92787e40aa5519460a32
/Source/IPC/Semaphore.cpp
902ca06f146c6ecf022dfd6531720f5a1c7010ff
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
locosoft1986/Microkernel-1
8069bd2be390d6d8ad10f73e8a944112a764a401
c9dfeec4581d4dd8b1e9020adb3778ad78b3e525
refs/heads/master
2021-01-24T04:54:08.589308
2010-09-23T19:38:01
2010-09-23T19:38:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,142
cpp
#include <IPC/Semaphore.h> Semaphore::Semaphore(unsigned int atom) { atomic = atom; } Semaphore::~Semaphore() { } Semaphore &Semaphore::operator =(const Semaphore &x) { atomic = x.atomic; return *this; } unsigned int Semaphore::operator +=(unsigned int x) { return __sync_add_and_fetch(&atomic, x); } unsigned int Semaphore::operator -=(unsigned int x) { return __sync_sub_and_fetch(&atomic, x); } unsigned int Semaphore::operator |=(unsigned int x) { return __sync_or_and_fetch(&atomic, x); } unsigned int Semaphore::operator &=(unsigned int x) { return __sync_and_and_fetch(&atomic, x); } unsigned int Semaphore::operator ^=(unsigned int x) { return __sync_xor_and_fetch(&atomic, x); } bool Semaphore::operator ==(const Semaphore &x) { return (x.atomic == this->atomic); } bool Semaphore::operator !=(const Semaphore &x) { return !(*this == x); } Semaphore::operator unsigned int () const { return atomic; } bool Semaphore::CompareAndSwap(unsigned int oldValue, unsigned int newValue) { return __sync_bool_compare_and_swap(&atomic, oldValue, newValue); }
[ "edward.neal@gmail.com" ]
edward.neal@gmail.com
6aa69b24fc9efd7f5820880a772b739f5aa96874
4435a0a6110b77060478876a464f6187d635f3a3
/MGEOP_gen/Snap-2.3/snap-adv/agmdirected.cpp
df257ae1ba5f9f3dcd810bf64bcdf063cb5dc359
[]
no_license
vshesh/fractal-graphs
014469f650fd42eb9a3334699a73ef9dbfafca1c
5d294f903458148470216d0bca4723d5c8e3644d
refs/heads/main
2021-06-07T07:55:49.462792
2021-04-03T00:51:51
2021-04-03T00:51:51
75,800,804
0
0
null
null
null
null
UTF-8
C++
false
false
130
cpp
version https://git-lfs.github.com/spec/v1 oid sha256:13e8b2f23b638ec4872a80e271bc4f8cf3c3b6a265e7b24e84f08da2154a8f35 size 37627
[ "cayman.simpson@gmail.com" ]
cayman.simpson@gmail.com
b1f521a4e70344a0d11ad1cfe328a7e034facf70
009bd79c41006bb639b91ade662b3d25b67b3a54
/Verifier/Model/Model.h
7702b0688abd1e1772c42b39c67d03adc70ea0f1
[]
no_license
wqythu13/BeagleTranslator
95438049bd4fbc7e5d79c5a51494f398915e0b84
b04bedd5b1ed16617bb6ce76988a4e66e4aaabc6
refs/heads/master
2022-03-30T01:16:31.231940
2020-01-17T03:19:18
2020-01-17T03:19:18
225,153,443
2
0
null
null
null
null
UTF-8
C++
false
false
1,145
h
// // Created by wqy on 19-11-17. // #ifndef VERIFIER_MODEL_H #define VERIFIER_MODEL_H #include "Process/Process.h" #include "Pragma/Property.h" #include "Pragma/InitialKnowledge.h" #include <string> #include <list> using std::string; using std::list; namespace esc { class Model { private: string name; list<Process*> processes; list<Property*> properties; list<InitialKnowledge*> initialKnowledges; public: string getName() {return this->name;} list<Process*> getProcesses() {return this->processes;} list<Property*> getProperties() {return this->properties;} list<InitialKnowledge*> getInitialKnowledge() {return this->initialKnowledges;} void setName(string _name); void setProcesses(list<Process*> _processes); void addProcess(Process* _process); void setProperties(list<Property*> _properties); void addProperty(Property* _property); void setInitialKnowledges(list<InitialKnowledge*> _initialKnowledges); void addInitialKnowledge(InitialKnowledge* _initialKnowledge); }; } #endif //VERIFIER_MODEL_H
[ "wangqinyu303@gmail.com" ]
wangqinyu303@gmail.com
58766c3af20446d76e48ee4ebabddbacb93efd8f
bd9c1a7c6ee0d4ce9bb2e86c6176b28e4c911067
/Ray Tracing Project/task5/hittable.h
7d0749b70d3c68384c79edd3533483351cc2f9ce
[]
no_license
melihkurtaran/Computer_Graphics
0c4e694b411fa162fed32dcd15879473c0ff763c
36d991df993488b40f8fac0b96c96063b70d1bae
refs/heads/main
2023-02-20T01:43:23.708085
2021-01-24T10:25:55
2021-01-24T10:25:55
332,414,002
0
0
null
null
null
null
UTF-8
C++
false
false
358
h
// Created by Melih Kurtaran on 30/10/2020. // Copyright © 2020 melihkurtaran. All rights reserved. // #ifndef hittable_h #define hittable_h #include "ray.h" #include "material.h" #include "vec3.h" class hittable { public: virtual bool hit(const ray& r, double t_min, double t_max, hit_record& rec) const = 0; }; #endif /* hittable_h */
[ "melihkurtaran@sabanciuniv.edu" ]
melihkurtaran@sabanciuniv.edu
3c34121557c2df6bab2530494869b80dc4439c8b
050c8a810d34fe125aecae582f9adfd0625356c6
/heapsort/main.cpp
1258f18a4b3711b510525f2a39aa54d699aeadc7
[]
no_license
georgerapeanu/c-sources
adff7a268121ae8c314e846726267109ba1c62e6
af95d3ce726325dcd18b3d94fe99969006b8e138
refs/heads/master
2022-12-24T22:57:39.526205
2022-12-21T16:05:01
2022-12-21T16:05:01
144,864,608
11
0
null
null
null
null
UTF-8
C++
false
false
911
cpp
#include <fstream> #include <algorithm> using namespace std; ifstream f("heapsort.in"); ofstream g("heapsort.out"); int p,c,N,nh,H[100000],i; int main() { H[0]=10000000; f>>N; for(i=1;i<=N;i++) { f>>H[i]; c=i; p=c/2; while(1) { if(H[p]>H[c]) break; if(p<1) break; swap(H[p],H[c]); c=p; p=p/2; } } nh=N; for(i=1;i<=N;i++) { swap(H[1],H[nh]); nh--; p=1; c=p*2; while(1) { if(H[c]<H[c+1]&&c+1<=nh) c++; if(c>nh) break; if(H[c]<H[p]) break; swap(H[c],H[p]); p=c; c*=2; } } for(i=1;i<=N;i++) g<<H[i]<<" "; f.close(); g.close(); return 0; }
[ "alexandrurapeanu@yahoo.com" ]
alexandrurapeanu@yahoo.com
b33ade86414ff03a05e15182650623e672afa350
4151c674d672e47292ee3b075b5925533741d04a
/Seventh/Seventh/Dlist.cpp
50d01ac643b72e46561484effd3e83f303232a2d
[]
no_license
None-stopCoding/Deque_queue_list
cae2a1ea786fb978c3c2dc2099b210f8c2f142e5
94e762f993bd6e5ad6e47abb3eefb2814ee0d121
refs/heads/master
2020-06-06T15:34:00.222580
2019-06-19T17:53:07
2019-06-19T17:53:07
192,777,931
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,616
cpp
#include "Dlist.h" #include <iostream> #include <conio.h> using namespace std; Dlist::Dlist() : head(NULL), tail(NULL) {} void Dlist::pushBack(int& val) { Elem* tmp = new Elem(val); if (this->isEmpty()) { head = tmp; tail = head; } else { Elem* tmp2 = tail; tail->next = tmp; tail = tmp; tail->prev = tmp2; } } void Dlist::pushFront(int& val) { Elem* tmp = new Elem(val); if (this->isEmpty()) { head = tmp; tail = head; } else { Elem* tmp2 = head; head->prev = tmp; head = tmp; head->next = tmp2; } } void Dlist::popBack() { if (!this->isEmpty()) { if (head == tail) { // если в списке один элемент head = NULL; tail = NULL; } else { tail = tail->prev; } } } void Dlist::popFront() { if (!this->isEmpty()) { if (head == tail) { // если в списке один элемент head = NULL; tail = NULL; } else { head = head->next; } } } void Dlist::printNext() { if (!this->isEmpty()) { Elem* run = head; while (run != tail) { cout << run->val << " "; run = run->next; } cout << run->val << endl; } } void Dlist::printPrev() { if (!this->isEmpty()) { Elem* run = tail; while (run != head) { cout << run->val << " "; run = run->prev; } cout << run->val << endl; } } bool Dlist::isEmpty() { return head == NULL; } int* Dlist::findByVal(int& val) { Elem* run = head; int* index_mas = new int[this->Count() + 1]; for (int i = 0; i <= this->Count(); i++) index_mas[i] = -1; int index = 0, i = 0; while (run->next) { if (run->val == val) index_mas[i++] = index; run = run->next; index++; } if (run->val == val) index_mas[i++] = index; return index_mas; } int Dlist::findByIndex(int ix) { Elem* run = head; int index = 0; while (run != tail) { if (ix == index++) return run->val; run = run->next; } if (ix == index) return run->val; return NULL; } void Dlist::pushAfter(int& after, int& val) { int ix = after; if (ix == -1) this->pushFront(val); if (ix >= 0 && ix < this->Count()) { if (ix == this->Count() - 1) this->pushBack(val); else { Elem* run = head; int index = 0; while (ix != index++) { run = run->next; } Elem* tmp = new Elem(val); tmp->next = run->next; tmp->prev = run; if (run->next) run->next->prev = tmp; run->next = tmp; } } } void Dlist::pushBefore(int& before, int& val) { int ix = before; if (ix >= 0 && ix < this->Count()) { if (!ix) this->pushFront(val); else { Elem* run = head; int index = 0; while (ix != index++) { run = run->next; } Elem* tmp = new Elem(val); tmp->prev = run->prev; if (run->prev) run->prev->next = tmp; tmp->next = run; run->prev = tmp; } } } void Dlist::popAfter(int& after) { int ix = after; if (ix == -1) this->popFront(); if (ix >= 0 && ix < this->Count()) { if (ix == this->Count() - 2) this->popBack(); else { Elem* run = head; int index = 0; while (ix != index++) { run = run->next; } if (run->next) { Elem* tmp = run->next->next; delete run->next; if (tmp) tmp->prev = run; run->next = tmp; } } } } void Dlist::popBefore(int& before) { int ix = before; if (ix >= 0 && ix < this->Count()) { if (ix == 1) this->popFront(); else if (ix) { Elem* run = head; int index = 0; while (ix != index++) { run = run->next; } Elem* tmp = run->prev->prev; delete run->prev; if (tmp) tmp->next = run; run->prev = tmp; } } } int Dlist::Count() { Elem* tmp = head; int res = 0; while (tmp != tail) { tmp = tmp->next; res++; } return ++res; }
[ "gkvalex7@gmail.com" ]
gkvalex7@gmail.com
e19917f690c9969937d59f0089c4896a0f8ac6f7
0b98f2f29b506bc6183600623dd97eb99b03bae5
/flu3d/bmp.h
f98ef2f29b493fdb12b518baaf1fb5f9b3fc8088
[]
no_license
Flushot/flu3d
5a0b687596581fe2b8e90451f4c5e93fdebeb767
04282309a19f5d475220b450c176988a1be0286a
refs/heads/master
2021-03-27T20:01:50.727519
2016-01-11T18:54:11
2016-01-11T18:54:11
49,407,969
0
0
null
null
null
null
UTF-8
C++
false
false
448
h
//--------------------------------------------------------------------------- class AUX_RGBImageRec { void convertBGRtoRGB(); public: byte *data; DWORD sizeX; DWORD sizeY; bool NoErrors; AUX_RGBImageRec(): NoErrors(false), data(NULL) {}; AUX_RGBImageRec(const char *FileName); ~AUX_RGBImageRec(); bool loadFile(const char *FileName); friend AUX_RGBImageRec *auxDIBImageLoad(const char *FileName); };
[ "flushot@gmail.com" ]
flushot@gmail.com
e2c61cec5601342384dfda3fcf2f7fd451ece0bd
d09945668f19bb4bc17087c0cb8ccbab2b2dd688
/codeforce/581-620/606/c2.cpp
d28f5dcf1f3f421e9215e544e956c1719edec8e3
[]
no_license
kmjp/procon
27270f605f3ae5d80fbdb28708318a6557273a57
8083028ece4be1460150aa3f0e69bdb57e510b53
refs/heads/master
2023-09-04T11:01:09.452170
2023-09-03T15:25:21
2023-09-03T15:25:21
30,825,508
23
2
null
2023-08-18T14:02:07
2015-02-15T11:25:23
C++
UTF-8
C++
false
false
1,611
cpp
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int T; int N; string S[202020]; void solve() { int i,j,k,l,r,x,y; string s; cin>>T; while(T--) { cin>>N; vector<int> C[2][2]; set<string> SS; FOR(i,N){ cin>>S[i]; C[S[i][0]-'0'][S[i].back()-'0'].push_back(i+1); SS.insert(S[i]); } if(C[0][0].size() && C[1][1].size() && C[0][1].size()+C[1][0].size()==0) { cout<<-1<<endl; continue; } x=C[0][1].size(); y=C[1][0].size(); vector<int> R; int num=abs(x-y)/2; if(x>y) { FORR(r,C[0][1]) if(num) { s=S[r-1]; reverse(ALL(s)); if(SS.count(s)==0) { R.push_back(r); num--; } } } else { FORR(r,C[1][0]) if(num) { s=S[r-1]; reverse(ALL(s)); if(SS.count(s)==0) { R.push_back(r); num--; } } } if(num) { cout<<-1<<endl; } else { cout<<R.size()<<endl; FORR(r,R) cout<<r<<" "; cout<<endl; } } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }
[ "kmjp@users.noreply.github.com" ]
kmjp@users.noreply.github.com
34710801d4ebfa7624d9f4af6d8ea52f16fab68a
384cc62c83d3802ce42a4a25dea06edcc0ebdf03
/addressList/addressList/mainwindow.h
75b02f0726209adb8d666a41180c88908d6c2bdd
[]
no_license
wtzhu13/CPPOrCProectDemo
f181d5fd63a9cc206fc5b5700841940bba196aed
d1da4c2062577eaf0c3d6c335e62281527d3a7a0
refs/heads/master
2021-05-21T01:33:10.374305
2020-10-24T02:27:11
2020-10-24T02:27:11
252,487,222
8
10
null
null
null
null
UTF-8
C++
false
false
502
h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class QSqlTableModel; class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private slots: void on_pushButton_clicked(); void on_pushButton_2_clicked(); void on_pushButton_4_clicked(); void on_pushButton_3_clicked(); private: Ui::MainWindow *ui; QSqlTableModel *model; }; #endif // MAINWINDOW_H
[ "wtzhu_13@163.com" ]
wtzhu_13@163.com
1b77c986a31f64dabf58c372c93024ba7703aace
03f73885f17027a9e7141c1cdc0ab9795b17932e
/QHTool/example/TestQSettingsXmlFormat/main.cpp
c2863c39240ba89c6dca93a3cec2fa284efe0169
[]
no_license
xinala1122/Qt-1
e9c6d06e79de92238bdab113b7c4b5ff9fff8a9c
0d5b17c852f02750694ac1c031033b9711426a85
refs/heads/master
2021-01-11T19:42:16.898954
2015-05-19T07:58:44
2015-05-19T07:58:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
181
cpp
#include "TestQSettingMainWnd.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
[ "haifu.tian@goland.cn" ]
haifu.tian@goland.cn
693eaca9f763b2d8a00f8ec38102798c0f48c587
7c007d8a5cb1eb652d6ca530048bef0f52ce75da
/cpp/wingchun/portfolio/src/portfolio_manager.cpp
df32744644fb312f4aabdea330168de383b40fae
[ "Apache-2.0" ]
permissive
xybeyond/kungfu
9fc4bca0e127157d71719b14eec81f515e40d37a
d5d9b464adce59f5430c5296d5b741f4e53664a9
refs/heads/master
2020-05-20T03:10:17.086950
2019-05-07T07:30:00
2019-05-07T07:30:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,940
cpp
// // Created by PolarAir on 2019-04-18. // #include "portfolio_manager.hpp" namespace kungfu { PortfolioManager::PortfolioManager(const char *db) : impl_(new impl(db)) { } PortfolioManager::~PortfolioManager() { if (nullptr != impl_) { delete impl_; impl_ = nullptr; } } #define IMPLEMENT_IMPL_POS_FUNC(ret_type, func_name) \ ret_type PortfolioManager::func_name(const char *instrument_id, const char *exchange_id) const \ { \ return impl_->func_name(instrument_id, exchange_id); \ } IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_tot) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_tot_avail) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_tot_fro) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_yd) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_yd_avail) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_long_yd_fro) IMPLEMENT_IMPL_POS_FUNC(double, get_long_realized_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_long_unrealized_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_long_open_price) IMPLEMENT_IMPL_POS_FUNC(double, get_long_cost_price) IMPLEMENT_IMPL_POS_FUNC(double, get_long_margin) IMPLEMENT_IMPL_POS_FUNC(double, get_long_position_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_long_close_pnl) IMPLEMENT_IMPL_POS_FUNC(Position, get_long_pos) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_tot) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_tot_avail) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_tot_fro) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_yd) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_yd_avail) IMPLEMENT_IMPL_POS_FUNC(int64_t, get_short_yd_fro) IMPLEMENT_IMPL_POS_FUNC(double, get_short_realized_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_short_unrealized_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_short_open_price) IMPLEMENT_IMPL_POS_FUNC(double, get_short_cost_price) IMPLEMENT_IMPL_POS_FUNC(double, get_short_margin) IMPLEMENT_IMPL_POS_FUNC(double, get_short_position_pnl) IMPLEMENT_IMPL_POS_FUNC(double, get_short_close_pnl) IMPLEMENT_IMPL_POS_FUNC(Position, get_short_pos) IMPLEMENT_IMPL_POS_FUNC(double, get_last_price) #define IMPLEMENT_IMPL_ACC_FUNC(ret_type, func_name) \ ret_type PortfolioManager::func_name() const \ { \ return impl_->func_name(); \ } IMPLEMENT_IMPL_ACC_FUNC(std::vector<Instrument>, get_all_pos_instruments) IMPLEMENT_IMPL_ACC_FUNC(double, get_initial_equity) IMPLEMENT_IMPL_ACC_FUNC(double, get_static_equity) IMPLEMENT_IMPL_ACC_FUNC(double, get_dynamic_equity) IMPLEMENT_IMPL_ACC_FUNC(double, get_accumulated_pnl) IMPLEMENT_IMPL_ACC_FUNC(double, get_accumulated_pnl_ratio) IMPLEMENT_IMPL_ACC_FUNC(double, get_intraday_pnl) IMPLEMENT_IMPL_ACC_FUNC(double, get_intraday_pnl_ratio) IMPLEMENT_IMPL_ACC_FUNC(double, get_avail) IMPLEMENT_IMPL_ACC_FUNC(double, get_market_value) IMPLEMENT_IMPL_ACC_FUNC(double, get_margin) IMPLEMENT_IMPL_ACC_FUNC(double, get_accumulated_fee) IMPLEMENT_IMPL_ACC_FUNC(double, get_intraday_fee) IMPLEMENT_IMPL_ACC_FUNC(double, get_frozen_cash) IMPLEMENT_IMPL_ACC_FUNC(double, get_frozen_margin) IMPLEMENT_IMPL_ACC_FUNC(double, get_frozen_fee) IMPLEMENT_IMPL_ACC_FUNC(double, get_position_pnl) IMPLEMENT_IMPL_ACC_FUNC(double, get_close_pnl) void PortfolioManager::on_quote(const kungfu::Quote *quote) { impl_->on_quote(quote); } void PortfolioManager::on_order(const kungfu::Order *order) { impl_->on_order(order); } void PortfolioManager::on_trade(const kungfu::Trade *trade) { impl_->on_trade(trade); } void PortfolioManager::on_positions(const std::vector<kungfu::Position> &positions) { impl_->on_positions(positions); } void PortfolioManager::on_position_details(const std::vector<kungfu::Position> &details) { impl_->on_position_details(details); } void PortfolioManager::on_account(const kungfu::AccountInfo &account) { impl_->on_account(account); } void PortfolioManager::insert_order(const kungfu::OrderInput *input) { impl_->insert_order(input); } bool PortfolioManager::freeze_algo_order(uint64_t algo_id, const kungfu::AssetsFrozen &frozen) { return impl_->freeze_algo_order(algo_id, frozen); } void PortfolioManager::release_algo_order(uint64_t algo_id) { impl_->release_algo_order(algo_id); } void PortfolioManager::switch_day(const std::string &trading_day) { impl_->switch_day(trading_day); } int64_t PortfolioManager::get_last_update() const { return impl_->get_last_update(); } std::string PortfolioManager::get_current_trading_day() const { return impl_->get_current_trading_day(); } void PortfolioManager::set_current_trading_day(const std::string &trading_day) { impl_->set_current_trading_day(trading_day); } void PortfolioManager::register_pos_callback(kungfu::PositionCallback cb) { impl_->register_pos_callback(std::move(cb)); } void PortfolioManager::register_acc_callback(kungfu::AccountCallback cb) { impl_->register_acc_callback(std::move(cb)); } void PortfolioManager::register_pnl_callback(kungfu::PnLCallback cb) { impl_->register_pnl_callback(std::move(cb)); } void PortfolioManager::set_initial_equity(double equity) { impl_->set_initial_equity(equity); } void PortfolioManager::set_static_equity(double equity) { impl_->set_static_equity(equity); } const PortfolioInfo* PortfolioManager::get_pnl() const { return impl_->get_pnl(); } const AccountManagerPtr PortfolioManager::get_account(const char *account_id) const { return impl_->get_account(account_id); } }
[ "dongkeren@gmail.com" ]
dongkeren@gmail.com
f5208ee315e8400fb5a24d2d908cfdd1976c5e8d
f0cb939867f21e53fad26ae4969c69ba0f99cd99
/fas/serialization/json/parse/space/ad_comment.hpp
cd112d32f81462c63fa60a7cddf244eb56bf76f9
[]
no_license
migashko/faslib-sandbox
238550c6dce4866392a1527dfee030a6b593dd71
a61b49cbab0e84a9440a1ad5d350ccbaff75995e
refs/heads/master
2021-01-23T03:48:38.525241
2013-11-04T03:19:45
2013-11-04T03:19:45
4,808,593
0
1
null
null
null
null
UTF-8
C++
false
false
727
hpp
// // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2013 // // Copyright: See COPYING file that comes with this distribution // #ifndef FAS_SERIALIZATION_JSON_PARSE_AD_COMMENT_HPP #define FAS_SERIALIZATION_JSON_PARSE_AD_COMMENT_HPP #include <fas/serialization/except/tags.hpp> #include <fas/serialization/parse/ad_entity.hpp> #include <fas/type_list/type_list_n.hpp> #include <fas/serialization/parse/nocopy.hpp> namespace fas{ namespace json{ namespace parse{ struct ad_comment_cp: ::fas::serialization::parse::ad_entity< type_list_n< _begin_comment_, _comment_content_, _end_comment_ >::type> {}; typedef ::fas::serialization::common::parse::nocopy<ad_comment_cp> ad_comment; }}} #endif
[ "migashko@gmail.com" ]
migashko@gmail.com
c85acfdd96ebd0c0b8a26f8210b2209598b178c0
6466e95fc3f54137af13acb908b408bc236eb4fe
/test_code/indi-code-1591-trunk/3rdparty/gerry/ScopeSim.h
7a8001b814a1766e8aad8d20ce5dfa4856852635
[]
no_license
Jesse-V/RLAGS-USU
4581b440fed66b59f020c4ac47967ea7e659af89
596e3387adfa44bb14523141a66500c172ef8dbc
refs/heads/master
2020-06-07T12:07:47.390736
2014-07-31T21:07:02
2014-07-31T21:07:02
20,243,129
1
0
null
null
null
null
UTF-8
C++
false
false
555
h
#ifndef SCOPESIM_H #define SCOPESIM_H #include "IndiTelescope.h" class ScopeSim : public IndiTelescope { protected: private: double ra; double dec; bool Parked; public: ScopeSim(); virtual ~ScopeSim(); virtual char *getDefaultName(); virtual bool Connect(char *); virtual bool Disconnect(); virtual bool ReadScopeStatus(); bool Goto(double,double); bool Park(); bool WritePersistentConfig(FILE *fp); }; #endif // SCOPESIM_H
[ "linaro@linaro-ubuntu-desktop.(none)" ]
linaro@linaro-ubuntu-desktop.(none)
eb27b03ff3351a31a1306b819c3d9a24f15c473c
9a3b9d80afd88e1fa9a24303877d6e130ce22702
/src/Providers/UNIXProviders/QueueHierarchy/UNIX_QueueHierarchy.cpp
b027cf3cfe569eae133d34b38898fd87ae8500f6
[ "MIT" ]
permissive
brunolauze/openpegasus-providers
3244b76d075bc66a77e4ed135893437a66dd769f
f24c56acab2c4c210a8d165bb499cd1b3a12f222
refs/heads/master
2020-04-17T04:27:14.970917
2015-01-04T22:08:09
2015-01-04T22:08:09
19,707,296
0
0
null
null
null
null
UTF-8
C++
false
false
3,292
cpp
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // 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 "UNIX_QueueHierarchy.h" #if defined(PEGASUS_OS_HPUX) # include "UNIX_QueueHierarchy_HPUX.hxx" # include "UNIX_QueueHierarchy_HPUX.hpp" #elif defined(PEGASUS_OS_LINUX) # include "UNIX_QueueHierarchy_LINUX.hxx" # include "UNIX_QueueHierarchy_LINUX.hpp" #elif defined(PEGASUS_OS_DARWIN) # include "UNIX_QueueHierarchy_DARWIN.hxx" # include "UNIX_QueueHierarchy_DARWIN.hpp" #elif defined(PEGASUS_OS_AIX) # include "UNIX_QueueHierarchy_AIX.hxx" # include "UNIX_QueueHierarchy_AIX.hpp" #elif defined(PEGASUS_OS_FREEBSD) # include "UNIX_QueueHierarchy_FREEBSD.hxx" # include "UNIX_QueueHierarchy_FREEBSD.hpp" #elif defined(PEGASUS_OS_SOLARIS) # include "UNIX_QueueHierarchy_SOLARIS.hxx" # include "UNIX_QueueHierarchy_SOLARIS.hpp" #elif defined(PEGASUS_OS_ZOS) # include "UNIX_QueueHierarchy_ZOS.hxx" # include "UNIX_QueueHierarchy_ZOS.hpp" #elif defined(PEGASUS_OS_VMS) # include "UNIX_QueueHierarchy_VMS.hxx" # include "UNIX_QueueHierarchy_VMS.hpp" #elif defined(PEGASUS_OS_TRU64) # include "UNIX_QueueHierarchy_TRU64.hxx" # include "UNIX_QueueHierarchy_TRU64.hpp" #else # include "UNIX_QueueHierarchy_STUB.hxx" # include "UNIX_QueueHierarchy_STUB.hpp" #endif Boolean UNIX_QueueHierarchy::validateKey(CIMKeyBinding &kb) const { /* Keys */ //Antecedent //Dependent CIMName name = kb.getName(); if (name.equal(PROPERTY_ANTECEDENT) || name.equal(PROPERTY_DEPENDENT) ) return true; return false; } void UNIX_QueueHierarchy::setScope(CIMName scope) { currentScope = CIMName(scope.getString()); } void UNIX_QueueHierarchy::setCIMOMHandle(CIMOMHandle &ch) { _cimomHandle = ch; }
[ "brunolauze@msn.com" ]
brunolauze@msn.com
82bad2c44b444d0373badd45abde27ccd5838aab
d61d05748a59a1a73bbf3c39dd2c1a52d649d6e3
/chromium/third_party/abseil-cpp/absl/debugging/stacktrace.h
8b831e2681558702f454d5dbd3e37e8e293e2a3d
[ "BSD-3-Clause", "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Csineneo/Vivaldi
4eaad20fc0ff306ca60b400cd5fad930a9082087
d92465f71fb8e4345e27bd889532339204b26f1e
refs/heads/master
2022-11-23T17:11:50.714160
2019-05-25T11:45:11
2019-05-25T11:45:11
144,489,531
5
4
BSD-3-Clause
2022-11-04T05:55:33
2018-08-12T18:04:37
null
UTF-8
C++
false
false
10,132
h
// Copyright 2018 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // ----------------------------------------------------------------------------- // File: stacktrace.h // ----------------------------------------------------------------------------- // // This file contains routines to extract the current stack trace and associated // stack frames. These functions are thread-safe and async-signal-safe. // // Note that stack trace functionality is platform dependent and requires // additional support from the compiler/build system in most cases. (That is, // this functionality generally only works on platforms/builds that have been // specifically configured to support it.) // // Note: stack traces in Abseil that do not utilize a symbolizer will result in // frames consisting of function addresses rather than human-readable function // names. (See symbolize.h for information on symbolizing these values.) #ifndef ABSL_DEBUGGING_STACKTRACE_H_ #define ABSL_DEBUGGING_STACKTRACE_H_ namespace absl { // GetStackFrames() // // Records program counter values for up to `max_depth` frames, skipping the // most recent `skip_count` stack frames, and stores their corresponding values // and sizes in `results` and `sizes` buffers. (Note that the frame generated // for the `absl::GetStackFrames()` routine itself is also skipped.) // routine itself. // // Example: // // main() { foo(); } // foo() { bar(); } // bar() { // void* result[10]; // int sizes[10]; // int depth = absl::GetStackFrames(result, sizes, 10, 1); // } // // The current stack frame would consist of three function calls: `bar()`, // `foo()`, and then `main()`; however, since the `GetStackFrames()` call sets // `skip_count` to `1`, it will skip the frame for `bar()`, the most recently // invoked function call. It will therefore return two program counters and will // produce values that map to the following function calls: // // result[0] foo() // result[1] main() // // (Note: in practice, a few more entries after `main()` may be added to account // for startup processes.) // // Corresponding stack frame sizes will also be recorded: // // sizes[0] 16 // sizes[1] 16 // // (Stack frame sizes of `16` above are just for illustration purposes.) // // Stack frame sizes of 0 or less indicate that those frame sizes couldn't // be identified. // // This routine may return fewer stack frame entries than are // available. Also note that `result` and `sizes` must both be non-null. extern int GetStackFrames(void** result, int* sizes, int max_depth, int skip_count); // GetStackFramesWithContext() // // Records program counter values obtained from a signal handler. Records // program counter values for up to `max_depth` frames, skipping the most recent // `skip_count` stack frames, and stores their corresponding values and sizes in // `results` and `sizes` buffers. (Note that the frame generated for the // `absl::GetStackFramesWithContext()` routine itself is also skipped.) // // The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value // passed to a signal handler registered via the `sa_sigaction` field of a // `sigaction` struct. (See // http://man7.org/linux/man-pages/man2/sigaction.2.html.) The `uc` value may // help a stack unwinder to provide a better stack trace under certain // conditions. `uc` may safely be null. // // The `min_dropped_frames` output parameter, if non-null, points to the // location to note any dropped stack frames, if any, due to buffer limitations // or other reasons. (This value will be set to `0` if no frames were dropped.) // The number of total stack frames is guaranteed to be >= skip_count + // max_depth + *min_dropped_frames. extern int GetStackFramesWithContext(void** result, int* sizes, int max_depth, int skip_count, const void* uc, int* min_dropped_frames); // GetStackTrace() // // Records program counter values for up to `max_depth` frames, skipping the // most recent `skip_count` stack frames, and stores their corresponding values // in `results`. Note that this function is similar to `absl::GetStackFrames()` // except that it returns the stack trace only, and not stack frame sizes. // // Example: // // main() { foo(); } // foo() { bar(); } // bar() { // void* result[10]; // int depth = absl::GetStackTrace(result, 10, 1); // } // // This produces: // // result[0] foo // result[1] main // .... ... // // `result` must not be null. extern int GetStackTrace(void** result, int max_depth, int skip_count); // GetStackTraceWithContext() // // Records program counter values obtained from a signal handler. Records // program counter values for up to `max_depth` frames, skipping the most recent // `skip_count` stack frames, and stores their corresponding values in // `results`. (Note that the frame generated for the // `absl::GetStackFramesWithContext()` routine itself is also skipped.) // // The `uc` parameter, if non-null, should be a pointer to a `ucontext_t` value // passed to a signal handler registered via the `sa_sigaction` field of a // `sigaction` struct. (See // http://man7.org/linux/man-pages/man2/sigaction.2.html.) The `uc` value may // help a stack unwinder to provide a better stack trace under certain // conditions. `uc` may safely be null. // // The `min_dropped_frames` output parameter, if non-null, points to the // location to note any dropped stack frames, if any, due to buffer limitations // or other reasons. (This value will be set to `0` if no frames were dropped.) // The number of total stack frames is guaranteed to be >= skip_count + // max_depth + *min_dropped_frames. extern int GetStackTraceWithContext(void** result, int max_depth, int skip_count, const void* uc, int* min_dropped_frames); // SetStackUnwinder() // // Provides a custom function for unwinding stack frames that will be used in // place of the default stack unwinder when invoking the static // GetStack{Frames,Trace}{,WithContext}() functions above. // // The arguments passed to the unwinder function will match the // arguments passed to `absl::GetStackFramesWithContext()` except that sizes // will be non-null iff the caller is interested in frame sizes. // // If unwinder is set to null, we revert to the default stack-tracing behavior. // // ***************************************************************************** // WARNING // ***************************************************************************** // // absl::SetStackUnwinder is not suitable for general purpose use. It is // provided for custom runtimes. // Some things to watch out for when calling `absl::SetStackUnwinder()`: // // (a) The unwinder may be called from within signal handlers and // therefore must be async-signal-safe. // // (b) Even after a custom stack unwinder has been unregistered, other // threads may still be in the process of using that unwinder. // Therefore do not clean up any state that may be needed by an old // unwinder. // ***************************************************************************** extern void SetStackUnwinder(int (*unwinder)(void** pcs, int* sizes, int max_depth, int skip_count, const void* uc, int* min_dropped_frames)); // DefaultStackUnwinder() // // Records program counter values of up to `max_depth` frames, skipping the most // recent `skip_count` stack frames, and stores their corresponding values in // `pcs`. (Note that the frame generated for this call itself is also skipped.) // This function acts as a generic stack-unwinder; prefer usage of the more // specific `GetStack{Trace,Frames}{,WithContext}()` functions above. // // If you have set your own stack unwinder (with the `SetStackUnwinder()` // function above, you can still get the default stack unwinder by calling // `DefaultStackUnwinder()`, which will ignore any previously set stack unwinder // and use the default one instead. // // Because this function is generic, only `pcs` is guaranteed to be non-null // upon return. It is legal for `sizes`, `uc`, and `min_dropped_frames` to all // be null when called. // // The semantics are the same as the corresponding `GetStack*()` function in the // case where `absl::SetStackUnwinder()` was never called. Equivalents are: // // null sizes | non-nullptr sizes // |==========================================================| // null uc | GetStackTrace() | GetStackFrames() | // non-null uc | GetStackTraceWithContext() | GetStackFramesWithContext() | // |==========================================================| extern int DefaultStackUnwinder(void** pcs, int* sizes, int max_depth, int skip_count, const void* uc, int* min_dropped_frames); namespace debugging_internal { // Returns true for platforms which are expected to have functioning stack trace // implementations. Intended to be used for tests which want to exclude // verification of logic known to be broken because stack traces are not // working. extern bool StackTraceWorksForTest(); } // namespace debugging_internal } // namespace absl #endif // ABSL_DEBUGGING_STACKTRACE_H_
[ "tofu@rMBP.local" ]
tofu@rMBP.local
7012d49abbcdf075b833bad2149f7966ec94c7b4
1cc31fa016630243ca992a901112306fd6888a8f
/mkr1000_old_code/neon.cpp
16b2b82dd4a7eb0ff20af7d4eecff5e510657d3a
[]
no_license
countitlabs/neon
846e105da8ba725bd986dc49b21d3bd311e6b3ad
5dde883222a25cec8fef65da2e1042310260952d
refs/heads/master
2020-04-14T14:35:10.997061
2019-04-03T14:20:40
2019-04-03T14:20:40
163,898,481
0
0
null
null
null
null
UTF-8
C++
false
false
593
cpp
// File: neon.cpp // Description: This file allows mkr1000 board connection to a wpa wifi source and makes a get request to the worldclock api. // Last updated: 01/06/19 // Libraries added:Arduinojson, WiFi101 #include "SPI.h" #include "api.h" #include "network.h" Network Wifi("<WIFI SSID GOES HERE>","<WIFI PASSWORD>"); Api Test("worldclockapi.com","/api/json/est/now","currentDateTime"); void setup(){ Serial.begin(9600); Serial.println("Starting network functions"); Wifi.networkConnect(); } void loop(){ delay(20000); Serial.println("Starting api test"); Test.sendGET(); }
[ "keithlowc@gmail.com" ]
keithlowc@gmail.com
a50840b6ecc4faa13f56b7353f49726b6391193a
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/ic8h18/0.006/IC4H8O2H-I
2c4b1bb573ff602adf97223669876ff5bc6799d6
[]
no_license
labsandy/OpenFOAM_workspace
a74b473903ddbd34b31dc93917e3719bc051e379
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
refs/heads/master
2022-02-25T02:36:04.164324
2019-08-23T02:27:16
2019-08-23T02:27:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
841
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.006"; object IC4H8O2H-I; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 1.0801e-27; boundaryField { boundary { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
7b568f4bb67fb802644033b6541186a09592e092
f2d55f62f67753509819e631ae2775b281b8ed8e
/tree and graph/Path Sum II/main.cpp
9d4417d034c273fe77b20acd020485862140e469
[]
no_license
caogl/Algorithms_practice
bd2d2081d65e3412910de5d386a3628eb05b6955
c8f9a0bccfcae56fd0cd058b11a33a8233d27c4e
refs/heads/master
2021-06-13T02:03:41.344850
2018-03-13T06:51:59
2018-03-13T06:51:59
16,342,981
0
1
null
null
null
null
UTF-8
C++
false
false
1,634
cpp
#include<iostream> #include<vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; vector<vector<int> > pathSum(TreeNode *root, int sum); void pathSum(TreeNode* root, int sum, int cur, vector<int>& tmp, vector<vector<int> >& result); int main() { TreeNode* root=new TreeNode(0); root->left=new TreeNode(1); root->right=new TreeNode(1); vector<vector<int> > result=pathSum(root, 1); for(int i=0; i<result.size(); i++) { for(int j=0; j<result[i].size(); j++) cout<<result[i][j]<<" "; cout<<endl; } return 0; } vector<vector<int> > pathSum(TreeNode *root, int sum) { int cur=0; vector<int> tmp; vector<vector<int> > result; pathSum(root, sum, cur, tmp, result); return result; } void pathSum(TreeNode* root, int sum, int cur, vector<int>& tmp, vector<vector<int> >& result) { if(root==nullptr) return; if(root->left==nullptr && root->right==nullptr && cur+root->val==sum) { tmp.push_back(root->val); result.push_back(tmp); tmp.pop_back(); /* because we are trying to find multiple possible result, so must pop_back here!! For tree questions, if needs to return all paths, must pop_back afterwords eg: (1)Word ladder || (2)Path Sum || */ } else { tmp.push_back(root->val); cur+=root->val; pathSum(root->left, sum, cur, tmp, result); pathSum(root->right, sum, cur, tmp, result); tmp.pop_back(); } }
[ "caogl@umich.edu" ]
caogl@umich.edu
cc76ba73e1949deb099dda57f18a5630627ccb82
2019158a24d2dc0277d251f6c6dd6288fbd71483
/TASK10.CPP
4bfb6c1db716cbb34c2ec976c85a19ed8b125000
[ "MIT" ]
permissive
varsha2901/coderspack-c-
55b9d7ee687406fb94a6cf7fa9566ce9e0a6d665
ae3e3443491ada87b15cabc951bb06e5387dd084
refs/heads/master
2020-05-27T02:04:58.024933
2019-05-24T16:22:41
2019-05-24T16:22:41
188,447,153
0
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
//Program to convert a string to lowercase. #include <iostream> #include <string.h> using namespace std; int main() { char str[100]; cout<<"Enter string: "; cin.getline(str, 100); for(int i=0;str[i]!='\0';i++) { str[i] = (str[i] >= 'A' && str[i] <= 'Z') ? (str[i] + 32) : str[i]; } cout<<"Lowercase string: " << str << endl; return 0; }
[ "noreply@github.com" ]
varsha2901.noreply@github.com
b0a26b4eada1341d18421271a09394557cf4efa8
792ad26fd812df30bf9a4cc286cca43b87986685
/数据结构/HDU 2795 Billboard 线段树.cpp
78c83fb261bc8af6699bbc8468ba6bf6951e0ba8
[]
no_license
Clqsin45/acmrec
39fbf6e02bb0c1414c05ad7c79bdfbc95dc26bf6
745b341f2e73d6b1dcf305ef466a3ed3df2e65cc
refs/heads/master
2020-06-18T23:44:21.083754
2016-11-28T05:10:44
2016-11-28T05:10:44
74,934,363
0
1
null
null
null
null
UTF-8
C++
false
false
1,078
cpp
#include <stdio.h> #define lson l, m, rt << 1 #define rson m+1, r, rt << 1 | 1 #define MAX 200004 int f[MAX << 2]; int max(int x, int y) { return x > y ? x : y; } void pushup(int x) { f[x] = max(f[x << 1], f[x << 1 | 1]); } void build(int l, int r, int rt, int k) { if(l == r) { f[rt] = k; return; } int m = (l + r) >> 1; build(lson, k); build(rson, k); pushup(rt); return; } int require(int p, int l, int r, int rt) { if(l == r) { f[rt] -= p; return l; } int m = (l + r) >> 1; int ret; ret = (f[rt << 1] >= p ? require(p, lson) : require(p, rson)); pushup(rt); return ret; } int main(void) { int h, w, n, t, i; while(scanf("%d%d%d", &h, &w, &n) != EOF) { if(h > n) h = n; build(1, h, 1, w); for(i = 1; i <= n; i++) { scanf("%d", &t); if(f[1] < t) printf("-1\n"); else printf("%d\n", require(t, 1, h, 1)); } } return 0; }
[ "someway.bit@gmail.com" ]
someway.bit@gmail.com
8c71e0560a254f27335f00ab7d453aa7091604ca
e509715d24d33c7163a73bd0ac7965644c53ca35
/NekoPlace/Components/NekoNinjaComponents/NekoBase.hpp
43ff7a049d590a799cb328f1baf51abd924f9a70
[]
no_license
SleepySquash/NekoPlace.cpp
0b565d2ef2b728e6ef3ddc4196ec82d0c3a4f858
50ee2d4e4c532e88b6b7d40672d097191675d0d9
refs/heads/master
2020-04-19T07:32:14.224693
2019-05-22T19:46:01
2019-05-22T19:46:01
168,050,222
1
0
null
null
null
null
UTF-8
C++
false
false
1,589
hpp
// // NekoBase.hpp // NekoPlace // // Created by Никита Исаенко on 27/02/2019. // Copyright © 2019 Melanholy Hill. All rights reserved. // #ifndef NekoBase_hpp #define NekoBase_hpp #include <iostream> #include <fstream> #include <SFML/Main.hpp> #include "../../Engine/EntitySystem.hpp" #include "AbilityBase.hpp" using std::cin; using std::cout; using std::endl; using namespace ns; namespace NekoNinja { struct NekoBase { std::wstring name, display{ L"" }; float possibility, chance, chanceAfterTamed{ 1.f }, affection{ 0 }; int difficultyAvailable; unsigned int levelNeeded; bool tamed; AbilityBase* ability{ nullptr }; sf::Color color; sf::IntRect offsets; float xySpd, chibiScale, personScale, novelScale; int personSprite_offsetX{ 0 }, personSprite_offsetY{ 0 }; NekoBase(); ~NekoBase(); NekoBase(const std::wstring& name, const float& chance, int difficultyAvailable = 0, float xySpd = 140, unsigned int levelNeeded = 0, sf::IntRect rect = sf::IntRect(15, 15, 15, 15), float chibiScale = 0.48f, float novelScale = 1.f, float personScale = 1.f, bool tamed = false, const sf::Color& ocolor = sf::Color::Transparent); virtual void Save(const std::wofstream& wof); virtual void Load(nss::CommandSettings& command); virtual void NovelTalkTo(Entity* entity); virtual void NovelIntroduction(Entity* entity); virtual std::wstring RandomRoomDialogue(); }; } #endif /* NekoBase_hpp */
[ "mayday@MacBook-Pro-Nikita.local" ]
mayday@MacBook-Pro-Nikita.local
399f0e5a7397b7e6961d872f5ba89960d4329ba0
a12561bd20872c67ac93579949ef9376248b8d51
/src/MuseRecord.cpp
8230bf1155a7f5b7c4d5946419bddb5ab7c9b599
[]
permissive
juyaolongpaul/humlib
fa13119fdf89b22d9c1ac5dc36a46b22c503e052
266528211e727c593a6f8a1e6a9ac46d77aab54c
refs/heads/master
2020-09-10T18:33:09.871995
2019-10-17T07:29:58
2019-10-17T07:29:58
221,797,343
0
0
BSD-2-Clause
2019-11-14T22:24:02
2019-11-14T22:24:02
null
UTF-8
C++
false
false
80,554
cpp
// // Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu> // Creation Date: Tue Jun 30 22:41:24 PDT 1998 // Last Modified: Tue Sep 24 06:47:55 PDT 2019 // Filename: humlib/src/MuseRecord.cpp // Web Address: http://github.com/craigsapp/humlib/blob/master/src/MuseRecord.cpp // Syntax: C++11 // vim: ts=3 // // Description: A class that stores one line of data for a Musedata file. // // To do: check on gracenotes/cuenotes with chord notes. // #include "Convert.h" #include "MuseRecord.h" #include "HumRegex.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <cctype> #include <sstream> using namespace std; namespace hum { // START_MERGE #define E_unknown (0x7fff) ////////////////////////////// // // MuseRecord::MuseRecord -- // MuseRecord::MuseRecord(void) : MuseRecordBasic() { } MuseRecord::MuseRecord(const string& aLine) : MuseRecordBasic(aLine) { } MuseRecord::MuseRecord(MuseRecord& aRecord) : MuseRecordBasic(aRecord) { } ////////////////////////////// // // MuseRecord::~MuseRecord -- // MuseRecord::~MuseRecord() { // do nothing } ////////////////////////////////////////////////////////////////////////// // // functions that work with note records // ////////////////////////////// // // MuseRecord::getNoteField -- returns the string containing the pitch, // accidental and octave characters. // string MuseRecord::getNoteField(void) { switch (getType()) { case E_muserec_note_regular: return extract(1, 4); break; case E_muserec_note_chord: case E_muserec_note_cue: case E_muserec_note_grace: return extract(2, 5); break; default: cerr << "Error: cannot use getNoteField function on line: " << getLine() << endl; } return ""; } ////////////////////////////// // // MuseRecord::getOctave -- returns the first numeric character // in the note field of a MuseData note record // int MuseRecord::getOctave(void) { string recordInfo = getNoteField(); int index = 0; while ((index < (int)recordInfo.size()) && !std::isdigit(recordInfo[index])) { index++; } if (index >= (int)recordInfo.size()) { cerr << "Error: no octave specification in note field: " << recordInfo << endl; return 0; } return recordInfo[index] - '0'; } string MuseRecord::getOctaveString(void) { string recordInfo = getNoteField(); int index = 0; while ((index < (int)recordInfo.size()) && !std::isdigit(recordInfo[index])) { index++; } if (index >= (int)recordInfo.size()) { cerr << "Error: no octave specification in note field: " << recordInfo << endl; return ""; } string output; output += recordInfo[index]; return output; } ////////////////////////////// // // MuseRecord::getPitch -- int version returns the base40 representation // int MuseRecord::getPitch(void) { string recordInfo = getNoteField(); return Convert::museToBase40(recordInfo); } string MuseRecord::getPitchString(void) { string output = getNoteField(); int len = (int)output.size(); int index = len-1; while (index >= 0 && output[index] == ' ') { output.resize(index); index--; } return output; } ////////////////////////////// // // MuseRecord::getPitchClass -- returns the pitch without the octave information // int MuseRecord::getPitchClass(void) { return getPitch() % 40; } string MuseRecord::getPitchClassString(void) { string output = getNoteField(); int index = 0; while ((index < (int)output.size()) && !std::isdigit(output[index])) { index++; } output.resize(index); return output; } ////////////////////////////// // // MuseRecord::getAccidental -- int version return -2 for double flat, // -1 for flat, 0 for natural, +1 for sharp, +2 for double sharp // int MuseRecord::getAccidental(void) { string recordInfo = getNoteField(); int output = 0; int index = 0; while ((index < (int)recordInfo.size()) && (index < 16)) { if (recordInfo[index] == 'f') { output--; } else if (recordInfo[index] == '#') { output++; } index++; } return output; } string MuseRecord::getAccidentalString(void) { string output; int type = getAccidental(); switch (type) { case -2: output = "ff"; break; case -1: output = "f"; break; case 0: output = ""; break; case 1: output = "#"; break; case 2: output = "##"; break; default: output = getNoteField(); cerr << "Error: unknown type of accidental: " << output << endl; return ""; } return output; } ////////////////////////////// // // MuseRecord::getBase40 -- return the base40 pitch value of the data // line. Middle C set to 40 * 4 + 2; Returns -100 for non-pitched items. // (might have to update for note_cur_chord and note_grace_chord which // do not exist yet. // int MuseRecord::getBase40(void) { switch (getType()) { case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_note_cue: case E_muserec_note_grace: break; default: return -100; } return getPitch(); } ////////////////////////////// // // MuseRecord::setStemDown -- // void MuseRecord::setStemDown(void) { getColumn(23) = 'd'; } ////////////////////////////// // // MuseRecord::setStemUp -- // void MuseRecord::setStemUp(void) { getColumn(23) = 'u'; } ////////////////////////////// // // MuseRecord::setPitch -- input is a base40 value which gets converted // to a diatonic pitch name. // Default value: chordnote = 0 // Default value: gracenote = 0 // void MuseRecord::setPitch(int base40, int chordnote, int gracenote) { string diatonic; switch (Convert::base40ToDiatonic(base40) % 7) { case 0: diatonic = 'C'; break; case 1: diatonic = 'D'; break; case 2: diatonic = 'E'; break; case 3: diatonic = 'F'; break; case 4: diatonic = 'G'; break; case 5: diatonic = 'A'; break; case 6: diatonic = 'B'; break; default: diatonic = 'X'; } string octave; octave += char('0' + base40 / 40); string accidental; int acc = Convert::base40ToAccidental(base40); switch (acc) { case -2: accidental = "ff"; break; case -1: accidental = "f"; break; case +1: accidental = "#"; break; case +2: accidental = "##"; break; } string pitchname = diatonic + accidental + octave; if (chordnote) { if (gracenote) { setGraceChordPitch(pitchname); } else { setChordPitch(pitchname); } } else { setPitch(pitchname); } } void MuseRecord::setChordPitch(const string& pitchname) { getColumn(1) = ' '; setPitchAtIndex(1, pitchname); } void MuseRecord::setGracePitch(const string& pitchname) { getColumn(1) = 'g'; setPitchAtIndex(1, pitchname); } void MuseRecord::setGraceChordPitch(const string& pitchname) { getColumn(1) = 'g'; getColumn(2) = ' '; setPitchAtIndex(2, pitchname); } void MuseRecord::setCuePitch(const string& pitchname) { getColumn(1) = 'c'; setPitchAtIndex(1, pitchname); } void MuseRecord::setPitch(const string& pitchname) { int start = 0; // If the record is already set to a grace note or a cue note, // then place pitch information starting at column 2 (index 1). if ((getColumn(1) == 'g') || (getColumn(1) == 'c')) { start = 1; } setPitchAtIndex(start, pitchname); } void MuseRecord::setPitchAtIndex(int index, const string& pitchname) { int len = (int)pitchname.size(); if ((len > 4) && (pitchname != "irest")) { cerr << "Error in MuseRecord::setPitchAtIndex: " << pitchname << endl; return; } insertString(index+1, pitchname); // Clear any text fields not used by current pitch data. for (int i=4-len-1; i>=0; i--) { (*this)[index + len + i] = ' '; } } ////////////////////////////// // // MuseRecord::getTickDurationField -- returns the string containing the // duration, and tie information. // string MuseRecord::getTickDurationField(void) { switch (getType()) { case E_muserec_figured_harmony: case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_rest: case E_muserec_backward: case E_muserec_forward: return extract(6, 9); break; // these record types do not have duration, per se: case E_muserec_note_cue: case E_muserec_note_grace: default: return " "; // cerr << "Error: cannot use getTickDurationField function on line: " // << getLine() << endl; // return ""; } return ""; } ////////////////////////////// // // MuseRecord::getTickDurationString -- returns the string containing the duration, // string MuseRecord::getTickDurationString(void) { string output = getTickDurationField(); int length = (int)output.size(); int i = length - 1; while (i>0 && (output[i] == '-' || output[i] == ' ')) { output.resize(i); i--; length--; } int start = 0; while (output[start] == ' ') { start++; } if (start != 0) { for (i=0; i<length-start; i++) { output[i] = output[start+i]; } } output.resize(length-start); return output; } ////////////////////////////// // // MuseRecord::getTickDuration -- return the tick value found // in columns 6-8 in some data type, returning 0 if the record // type does not have a duration field. // int MuseRecord::getTickDuration(void) { string recordInfo = getTickDurationString(); if (recordInfo.empty()) { return 0; } return std::stoi(recordInfo); } ////////////////////////////// // // MuseRecord::getLineTickDuration -- returns the logical duration of the // data line. Supresses the duration field of secondary chord notes. // int MuseRecord::getLineTickDuration(void) { if (getType() == E_muserec_note_chord) { return 0; } string recordInfo = getTickDurationString(); if (recordInfo.empty()) { return 0; } int value = std::stoi(recordInfo); if (getType() == E_muserec_backspace) { return -value; } return value; } ////////////////////////////// // // MuseRecord::getTicks -- similar to getLineTickDuration, but is non-zero // for secondary chord notes. // int MuseRecord::getTicks(void) { string recordInfo = getTickDurationString(); if (recordInfo.empty()) { return 0; } int value = std::stoi(recordInfo); if (getType() == E_muserec_backspace) { return -value; } return value; } ////////////////////////////// // // MuseRecord::getNoteTickDuration -- Similar to getLineTickDuration, // but do not suppress the duration of secondary chord-tones. // int MuseRecord::getNoteTickDuration(void) { string recordInfo = getTickDurationString(); int value = 0; if (recordInfo.empty()) { return value; } value = std::stoi(recordInfo); if (getType() == E_muserec_backspace) { return -value; } return value; } ////////////////////////////// // // MuseRecord::setDots -- // void MuseRecord::setDots(int value) { switch (value) { case 0: getColumn(18) = ' '; break; case 1: getColumn(18) = '.'; break; case 2: getColumn(18) = ':'; break; case 3: getColumn(18) = ';'; break; case 4: getColumn(18) = '!'; break; default: cerr << "Error in MuseRecord::setDots : " << value << endl; } } ////////////////////////////// // // MuseRecord::getDotCount -- // int MuseRecord::getDotCount(void) { char value = getColumn(18); switch (value) { case ' ': return 0; case '.': return 1; case ':': return 2; case ';': return 3; case '!': return 4; } return 0; } ////////////////////////////// // // MuseRecord::setNoteheadShape -- Duration with augmentation dot component // removed. Duration of 1 is quarter note. // void MuseRecord::setNoteheadShape(HumNum duration) { HumNum note8th(1,2); HumNum note16th(1,4); HumNum note32nd(1,8); HumNum note64th(1,16); HumNum note128th(1,32); HumNum note256th(1,64); if (duration > 16) { // maxima setNoteheadMaxima(); } else if (duration > 8) { // long setNoteheadLong(); } else if (duration > 4) { // breve if (m_roundBreve) { setNoteheadBreveRound(); } else { setNoteheadBreve(); } } else if (duration > 2) { // whole note setNoteheadWhole(); } else if (duration > 1) { // half note setNoteheadHalf(); } else if (duration > note8th) { // quarter note setNoteheadQuarter(); } else if (duration > note16th) { // eighth note setNotehead8th(); } else if (duration > note32nd) { // 16th note setNotehead16th(); } else if (duration > note64th) { // 32nd note setNotehead32nd(); } else if (duration > note128th) { // 64th note setNotehead64th(); } else if (duration > note256th) { // 128th note setNotehead128th(); } else if (duration == note256th) { // 256th note // not allowing tuplets on the 256th note level. setNotehead256th(); } else { cerr << "Error in duration: " << duration << endl; return; } } ////////////////////////////// // // MuseRecord::setNoteheadShape -- Duration with augmentation dot component // removed. Duration of 1 is quarter note. // void MuseRecord::setNoteheadShapeMensural(HumNum duration) { HumNum note8th(1, 2); HumNum note16th(1, 4); HumNum note32th(1, 8); HumNum note64th(1, 16); HumNum note128th(1, 32); HumNum note256th(1, 64); if (duration > 16) { // maxima setNoteheadMaxima(); } else if (duration > 8) { // long setNoteheadLong(); } else if (duration > 4) { // breve setNoteheadBreve(); } else if (duration > 2) { // whole note setNoteheadWholeMensural(); } else if (duration > 1) { // half note setNoteheadHalfMensural(); } else if (duration > note8th) { // quarter note setNoteheadQuarterMensural(); } else if (duration > note16th) { // eighth note setNotehead8thMensural(); } else if (duration > note32th) { // 16th note setNotehead16thMensural(); } else if (duration > note64th) { // 32nd note setNotehead32ndMensural(); } else if (duration > note128th) { // 64th note setNotehead64thMensural(); } else if (duration > note256th) { // 128th note setNotehead128thMensural(); } else if (duration >= note256th) { // 256th note // don't allow tuplets on 256th note level. setNotehead256thMensural(); } else { cerr << "Error in duration: " << duration << endl; return; } } void MuseRecord::setNoteheadMaxima(void) { if ((*this)[0] == 'c' || ((*this)[0] == 'g')) { cerr << "Error: cue/grace notes cannot be maximas in setNoteheadLong" << endl; return; } else { getColumn(17) = 'M'; } } void MuseRecord::setNoteheadLong(void) { if ((*this)[0] == 'c' || ((*this)[0] == 'g')) { cerr << "Error: cue/grace notes cannot be longs in setNoteheadLong" << endl; return; } else { getColumn(17) = 'L'; } } void MuseRecord::setNoteheadBreve(void) { setNoteheadBreveSquare(); } void MuseRecord::setNoteheadBreveSquare(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = 'A'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = 'A'; } else { // normal note getColumn(17) = 'B'; } } void MuseRecord::setNoteheadBreveRound(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = 'A'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = 'A'; } else { // normal note getColumn(17) = 'b'; } } void MuseRecord::setNoteheadBreveMensural(void) { setNoteheadBreveSquare(); } void MuseRecord::setNoteheadWhole(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '9'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '9'; } else { // normal note getColumn(17) = 'w'; } } void MuseRecord::setNoteheadWholeMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '9'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '9'; } else { // normal note getColumn(17) = 'W'; } } void MuseRecord::setNoteheadHalf(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '8'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '8'; } else { // normal note getColumn(17) = 'h'; } } void MuseRecord::setNoteheadHalfMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '8'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '8'; } else { // normal note getColumn(17) = 'H'; } } void MuseRecord::setNoteheadQuarter(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '7'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '7'; } else { // normal note getColumn(17) = 'q'; } } void MuseRecord::setNoteheadQuarterMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '7'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '7'; } else { // normal note getColumn(17) = 'Q'; } } void MuseRecord::setNotehead8th(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '6'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '6'; } else { // normal note getColumn(17) = 'e'; } } void MuseRecord::setNotehead8thMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '6'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '6'; } else { // normal note getColumn(17) = 'E'; } } void MuseRecord::setNotehead16th(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '5'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '5'; } else { // normal note getColumn(17) = 's'; } } void MuseRecord::setNotehead16thMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '5'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '5'; } else { // normal note getColumn(17) = 'S'; } } void MuseRecord::setNotehead32nd(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '4'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '4'; } else { // normal note getColumn(17) = 't'; } } void MuseRecord::setNotehead32ndMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '4'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '4'; } else { // normal note getColumn(17) = 'T'; } } void MuseRecord::setNotehead64th(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '3'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '3'; } else { // normal note getColumn(17) = 'x'; } } void MuseRecord::setNotehead64thMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '3'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '3'; } else { // normal note getColumn(17) = 'X'; } } void MuseRecord::setNotehead128th(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '2'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '2'; } else { // normal note getColumn(17) = 'y'; } } void MuseRecord::setNotehead128thMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '2'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '2'; } else { // normal note getColumn(17) = 'Y'; } } void MuseRecord::setNotehead256th(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '1'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '1'; } else { // normal note getColumn(17) = 'z'; } } void MuseRecord::setNotehead256thMensural(void) { if ((*this)[0] == 'g') { // grace note getColumn(8) = '1'; } else if ((*this)[0] == 'c') { // cue-sized note (with duration) getColumn(17) = '1'; } else { // normal note getColumn(17) = 'Z'; } } ///////////////////////////// // // MuseRecord::setBack -- // void MuseRecord::setBack(int value) { insertString(1, "back"); setTicks(value); } ///////////////////////////// // // MuseRecord::setTicks -- return the numeric value in columns 6-9. // void MuseRecord::setTicks(int value) { if ((value < 0) || (value >= 1000)) { cerr << "@ Error: ticks out of range in MuseRecord::setTicks" << endl; } stringstream ss; ss << value; int len = (int)ss.str().size(); insertString(5+3-len+1, ss.str()); } ////////////////////////////// // // MuseRecord::getTie -- // string MuseRecord::getTieString(void) { string output; output += getColumn(9); if (output == " ") { output = ""; } return output; } int MuseRecord::getTie(void) { return tieQ(); } ////////////////////////////// // // MuseRecord::getTie -- Set a tie marker in column 9. Currently // the function does not check the type of data, so will overr-write any // data found in column 9 (such as if the record is not for a note). // // If the input parameter hidden is true, then the visual tie is not // displayed, but the sounding tie is displayed. // int MuseRecord::setTie(int hidden) { getColumn(9) = '-'; if (!hidden) { return addAdditionalNotation('-'); } else { return -1; } } ////////////////////////////// // // MuseRecord::addAdditionalNotation -- ties, slurs and tuplets. // Currently not handling editorial levels. // int MuseRecord::addAdditionalNotation(char symbol) { // search columns 32 to 43 for the specific symbol. // if it is found, then don't add. If it is not found, // then do add. int i; int blank = -1; int nonempty = 0; // true if a non-space character was found. for (i=43; i>=32; i--) { if (getColumn(i) == symbol) { return i; } else if (!nonempty && (getColumn(i) == ' ')) { blank = i; } else { nonempty = i; } } if (symbol == '-') { // give preferential treatment to placing only ties in // column 32 if (getColumn(32) == ' ') { getColumn(32) = '-'; return 32; } } if (blank < 0) { cerr << "Error in MuseRecord::addAdditionalNotation: " << "no empty space for notation" << endl; return 0; } if ((blank <= 32) && (getColumn(33) == ' ')) { // avoid putting non-tie items in column 32. blank = 33; } getColumn(blank) = symbol; return blank; } // add a multi-character additional notation (such as a dynamic like mf): int MuseRecord::addAdditionalNotation(const string& symbol) { int len = (int)symbol.size(); // search columns 32 to 43 for the specific symbol. // if it is found, then don't add. If it is not found, // then do add. int i, j; int blank = -1; int found = 0; int nonempty = 0; // true if a non-space character was found. for (i=43-len; i>=32; i--) { found = 1; for (j=0; j<len; j++) { if (getColumn(i+j) != symbol[j]) { found = 0; break; } } if (found) { return i; } else if (!nonempty && (getColumn(i) == ' ')) { // cout << "@COLUMN " << i << " is blank: " << getColumn(i) << endl; blank = i; // should check that there are enough blank lines to the right // as well... } else if (getColumn(i) != ' ') { nonempty = i; } } if (blank < 0) { cerr << "Error in MuseRecord::addAdditionalNotation2: " << "no empty space for notation" << endl; return 0; } // cout << "@ GOT HERE symbol = " << symbol << " and blank = " << blank << endl; if ((blank <= 32) && (getColumn(33) == ' ')) { // avoid putting non-tie items in column 32. blank = 33; // not worrying about overwriting something to the right // of column 33 since the empty spot was checked starting // on the right and moving towards the left. } // cout << "@COLUMN 33 = " << getColumn(33) << endl; // cout << "@ GOT HERE symbol = " << symbol << " and blank = " << blank << endl; for (j=0; j<len; j++) { getColumn(blank+j) = symbol[j]; } return blank; } ////////////////////////////// // // MuseRecord::tieQ -- returns true if the current line contains // a tie to a note in the future. Does not check if there is a tie // to a note in the past. // int MuseRecord::tieQ(void) { int output = 0; switch (getType()) { case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_note_cue: case E_muserec_note_grace: if (getColumn(9) == '-') { output = 1; } else if (getColumn(9) == ' ') { output = 0; } else { output = -1; } break; default: return 0; } return output; } ////////////////////////////////////////////////////////////////////////// // // graphical and intrepretive information for notes // ////////////////////////////// // // MuseRecord::getFootnoteFlagField -- returns column 13 value // string MuseRecord::getFootnoteFlagField(void) { allowFigurationAndNotesOnly("getFootnoteField"); return extract(13, 13); } ////////////////////////////// // // MuseRecord::getFootnoteFlagString -- // string MuseRecord::getFootnoteFlagString(void) { string output = getFootnoteFlagField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getFootnoteFlag -- // int MuseRecord::getFootnoteFlag(void) { int output = 0; string recordInfo = getFootnoteFlagString(); if (recordInfo[0] == ' ') { output = -1; } else { output = std::strtol(recordInfo.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::footnoteFlagQ -- // int MuseRecord::footnoteFlagQ(void) { int output = 0; string recordInfo = getFootnoteFlagField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getLevelField -- return column 14 // string MuseRecord::getLevelField(void) { allowFigurationAndNotesOnly("getLevelField"); return extract(14, 14); } ////////////////////////////// // // MuseRecord::getLevel -- // string MuseRecord::getLevelString(void) { string output = getLevelField(); if (output[0] == ' ') { output = ""; } return output; } int MuseRecord::getLevel(void) { int output = 1; string recordInfo = getLevelField(); if (recordInfo[0] == ' ') { output = 1; } else { output = std::strtol(recordInfo.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::levelQ -- // int MuseRecord::levelQ(void) { int output = 0; string recordInfo = getLevelField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getTrackField -- return column 15 // string MuseRecord::getTrackField(void) { if (!isAnyNoteOrRest()) { return extract(15, 15); } else { return " "; } } ////////////////////////////// // // MuseRecord::getTrackString -- // string MuseRecord::getTrackString(void) { string output = getTrackField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getTrack -- Return 0 if no track information (implicitly track 1, // or unlabelled higher track). // int MuseRecord::getTrack(void) { int output = 1; string recordInfo = getTrackField(); if (recordInfo[0] == ' ') { output = 0; } else { output = std::strtol(recordInfo.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::trackQ -- // int MuseRecord::trackQ(void) { int output = 0; string recordInfo = getTrackField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getGraphicNoteTypeField -- return column 17 // string MuseRecord::getGraphicNoteTypeField(void) { // allowNotesOnly("getGraphicNoteTypefield"); if (getLength() < 17) { return " "; } else { return extract(17, 17); } } ////////////////////////////// // // MuseRecord::getGraphicNoteType -- // string MuseRecord::getGraphicNoteTypeString(void) { string output = getGraphicNoteTypeField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getGraphicRecip -- // string MuseRecord::getGraphicRecip(void) { int notetype = getGraphicNoteType(); string output; switch (notetype) { case -3: output = "0000"; break; // double-maxima case -2: output = "000"; break; // maxima case -1: output = "00"; break; // long default: output = to_string(notetype); // regular **recip number } int dotcount = getDotCount(); for (int i=0; i<dotcount; i++) { output += '.'; } return output; } ////////////////////////////// // // MuseRecord::getGraphicNoteType -- // int MuseRecord::getGraphicNoteType(void) { int output = 0; string recordInfo = getGraphicNoteTypeField(); if (recordInfo[0] == ' ') { if (isInvisibleRest()) { // invisible rests do not have graphic note types // so make one up from the logical note type HumNum value = getTickDuration(); value /= getTpq(); if (value >= 32) { return -2; } else if (value >= 16) { return -1; } else if (value >= 8) { return 0; } else if (value >= 4) { return 1; } else if (value >= 2) { return 2; } else if (value >= 1) { return 4; } else if (value.getFloat() >= 0.5) { return 8; } else if (value.getFloat() >= 0.25) { return 16; } else if (value.getFloat() >= 0.125) { return 32; } else if (value.getFloat() >= 0.0625) { return 64; } else if (value.getFloat() >= 1.0/128) { return 128; } else if (value.getFloat() >= 1.0/256) { return 256; } else if (value.getFloat() >= 1.0/512) { return 512; } else { return 0; } } else { cerr << "Error: no graphic note type specified: " << getLine() << endl; return 0; } } switch (recordInfo[0]) { case 'M': // Maxima output = -2; break; case 'L': case 'B': // Longa output = -1; break; case 'b': case 'A': // Breve output = 0; break; case 'w': case '9': // Whole output = 1; break; case 'h': case '8': // Half output = 2; break; case 'q': case '7': // Quarter output = 4; break; case 'e': case '6': // Eighth output = 8; break; case 's': case '5': // Sixteenth output = 16; break; case 't': case '4': // 32nd note output = 32; break; case 'x': case '3': // 64th note output = 64; break; case 'y': case '2': // 128th note output = 128; break; case 'z': case '1': // 256th note output = 256; break; default: cerr << "Error: unknown graphical note type in column 17: " << getLine() << endl; } return output; } ////////////////////////////// // // MuseRecord::graphicNoteTypeQ -- // int MuseRecord::graphicNoteTypeQ(void) { int output = 0; string recordInfo = getGraphicNoteTypeField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::graphicNoteTypeSize -- return 0 if cue note size, // otherwise, it will return 1 if regular size // int MuseRecord::getGraphicNoteTypeSize(void) { int output = 1; string recordInfo = getGraphicNoteTypeField(); if (recordInfo[0] == ' ') { cerr << "Error: not graphic note specified in column 17: " << getLine() << endl; return 0; } switch (recordInfo[0]) { case 'L': case 'b': case 'w': case 'h': case 'q': case 'e': case 's': case 't': case 'x': case 'y': case 'z': output = 1; break; case 'B': case 'A': case '9': case '8': case '7': case '6': case '5': case '4': case '3': case '2': case '1': output = 0; break; default: cerr << "Error: unknown graphical note type in column 17: " << getLine() << endl; return 0; } return output; } ////////////////////////////// // // MuseRecord::getProlongationField -- returns column 18 // string MuseRecord::getProlongationField(void) { // allowNotesOnly("getProlongationField"); ---> rests also if (getLength() < 18) { return " "; } else { return extract(18, 18); } } ////////////////////////////// // // MuseRecord::getProlongationString -- // string MuseRecord::getProlongationString(void) { string output = getProlongationField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getProlongation -- // int MuseRecord::getProlongation(void) { int output = 0; string recordInfo = getProlongationField(); switch (recordInfo[0]) { case ' ': output = 0; break; case '.': output = 1; break; case ':': output = 2; break; default: cerr << "Error: unknon prologation character (column 18): " << getLine() << endl; return 0; } return output; } ////////////////////////////// // // MuseRecord::getStringProlongation -- // string MuseRecord::getStringProlongation(void) { switch (getProlongation()) { case 0: return ""; break; case 1: return "."; break; case 2: return ".."; break; case 3: return "..."; break; case 4: return "...."; break; default: cerr << "Error: unknown number of prolongation dots (column 18): " << getLine() << endl; return ""; } return ""; } ////////////////////////////// // // MuseRecord::prolongationQ -- // int MuseRecord::prolongationQ(void) { return getProlongation(); } ////////////////////////////// // // MuseRecord::getNotatedAccidentalField -- actual notated accidental is // stored in column 19. // string MuseRecord::getNotatedAccidentalField(void) { allowNotesOnly("getNotatedAccidentalField"); if (getLength() < 19) { return " "; } else { string temp; temp += getColumn(19); return temp; } } ////////////////////////////// // // MuseRecord::getNotatedAccidentalString -- // string MuseRecord::getNotatedAccidentalString(void) { string output = getNotatedAccidentalField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getNotatedAccidental -- // int MuseRecord::getNotatedAccidental(void) { int output = 0; string recordInfo = getNotatedAccidentalField(); switch (recordInfo[0]) { case ' ': output = 0; break; case '#': output = 1; break; case 'n': output = 0; break; case 'f': output = -1; break; case 'x': output = 2; break; case 'X': output = 2; break; case '&': output = -2; break; case 'S': output = 1; break; case 'F': output = -1; break; default: cerr << "Error: unknown accidental: " << recordInfo[0] << endl; return 0; } return output; } ////////////////////////////// // // MuseRecord::notatedAccidentalQ -- // int MuseRecord::notatedAccidentalQ(void) { int output; string recordInfo = getNotatedAccidentalField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } /////////////////////////////// // // MuseRecord::getTimeModificationField -- return columns 20 -- 22. // string MuseRecord::getTimeModificationField(void) { // allowNotesOnly("getTimeModificationField"); ---> rests also if (getLength() < 20) { return " "; } else { return extract(20, 22); } } ////////////////////////////// // // MuseRecord::getTimeModification -- // string MuseRecord::getTimeModification(void) { string output = getTimeModificationField(); int index = 2; while (index >= 0 && output[index] == ' ') { output.resize(index); index--; } if (output.size() > 2) { if (output[0] == ' ') { output[0] = output[1]; output[1] = output[2]; output.resize(2); } } if (output.size() > 1) { if (output[0] == ' ') { output[0] = output[1]; output.resize(1); } } if (output[0] == ' ') { cerr << "Error: funny error occured in time modification " << "(columns 20-22): " << getLine() << endl; return ""; } return output; } ////////////////////////////// // // MuseRecord::getTimeModificationLeftField -- return column 20 // string MuseRecord::getTimeModificationLeftField(void) { string output = getTimeModificationField(); output.resize(1); return output; } ////////////////////////////// // // MuseRecord::getTimeModificationLeftString -- // string MuseRecord::getTimeModificationLeftString(void) { string output = getTimeModificationField(); if (output[0] == ' ') { output = ""; } else { output.resize(1); } return output; } ////////////////////////////// // // MuseRecord::getTimeModificationLeft -- // int MuseRecord::getTimeModificationLeft(void) { int output = 0; string recordInfo = getTimeModificationLeftString(); if (recordInfo[0] == ' ') { output = 0; } else { output = std::strtol(recordInfo.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::getTimeModificationRightField -- return column 20 // string MuseRecord::getTimeModificationRightField(void) { string output = getTimeModificationField(); output = output[2]; return output; } ////////////////////////////// // // MuseRecord::getTimeModificationRight -- // string MuseRecord::getTimeModificationRightString(void) { string output = getTimeModificationField(); if (output[2] == ' ') { output = ""; } else { output = output[2]; } return output; } ////////////////////////////// // // MuseRecord::getTimeModificationRight -- // int MuseRecord::getTimeModificationRight(void) { int output = 0; string recordInfo = getTimeModificationRightString(); if (recordInfo[2] == ' ') { output = 0; } else { string temp = recordInfo.substr(2); output = std::strtol(temp.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::timeModificationQ -- // int MuseRecord::timeModificationQ(void) { int output = 0; string recordInfo = getTimeModificationField(); if (recordInfo[0] != ' ' || recordInfo[1] != ' ' || recordInfo[2] != ' ') { output = 1; } else { output = 0; } return output; } ////////////////////////////// // // MuseRecord::timeModificationLeftQ -- // int MuseRecord::timeModificationLeftQ(void) { int output = 0; string recordInfo = getTimeModificationField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::timeModificationRightQ -- // int MuseRecord::timeModificationRightQ(void) { int output = 0; string recordInfo = getTimeModificationField(); if (recordInfo[2] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getStemDirectionField -- // string MuseRecord::getStemDirectionField(void) { allowNotesOnly("getStemDirectionField"); if (getLength() < 23) { return " "; } else { string temp; temp += getColumn(23); return temp; } } ////////////////////////////// // // MuseRecord::getStemDirectionString -- // string MuseRecord::getStemDirectionString(void) { string output = getStemDirectionField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getStemDirection -- // int MuseRecord::getStemDirection(void) { int output = 0; string recordInfo = getStemDirectionField(); switch (recordInfo[0]) { case 'u': output = 1; break; case 'd': output = -1; break; case ' ': output = 0; break; default: cerr << "Error: unknown stem direction: " << recordInfo[0] << endl; return 0; } return output; } ////////////////////////////// // // MuseRecord::stemDirectionQ -- // int MuseRecord::stemDirectionQ(void) { int output = 0; string recordInfo = getStemDirectionField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getStaffField -- returns column 24. // string MuseRecord::getStaffField(void) { allowNotesOnly("getStaffField"); if (getLength() < 24) { return " "; } else { string temp; temp += getColumn(24); return temp; } } ////////////////////////////// // // MuseRecord::getStaffString -- // string MuseRecord::getStaffString(void) { string output = getStaffField(); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getStaff -- // int MuseRecord::getStaff(void) { int output = 1; string recordInfo = getStaffField(); if (recordInfo[0] == ' ') { output = 1; } else { output = std::strtol(recordInfo.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::staffQ -- // int MuseRecord::staffQ(void) { int output = 0; string recordInfo = getStaffField(); if (recordInfo[0] == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getBeamField -- // string MuseRecord::getBeamField(void) { allowNotesOnly("getBeamField"); if (getLength() < 26) { return " "; } else { return extract(26, 31); } } ////////////////////////////// // // MuseRecord::setBeamInfo -- // void MuseRecord::setBeamInfo(string& strang) { setColumns(strang, 26, 31); } ////////////////////////////// // // MuseRecord::beamQ -- // int MuseRecord::beamQ(void) { int output = 0; allowNotesOnly("beamQ"); if (getLength() < 26) { output = 0; } else { for (int i=26; i<=31; i++) { if (getColumn(i) != ' ') { output = 1; break; } } } return output; } ////////////////////////////// // // MuseRecord::getBeam8 -- column 26 // char MuseRecord::getBeam8(void) { allowNotesOnly("getBeam8"); return getColumn(26); } ////////////////////////////// // // MuseRecord::getBeam16 -- column 27 // char MuseRecord::getBeam16(void) { allowNotesOnly("getBeam16"); return getColumn(27); } ////////////////////////////// // // MuseRecord::getBeam32 -- column 28 // char MuseRecord::getBeam32(void) { allowNotesOnly("getBeam32"); return getColumn(28); } ////////////////////////////// // // MuseRecord::getBeam64 -- column 29 // char MuseRecord::getBeam64(void) { allowNotesOnly("getBeam64"); return getColumn(29); } ////////////////////////////// // // MuseRecord::getBeam128 -- column 30 // char MuseRecord::getBeam128(void) { allowNotesOnly("getBeam128"); return getColumn(30); } ////////////////////////////// // // MuseRecord::getBeam256 -- column 31 // char MuseRecord::getBeam256(void) { allowNotesOnly("getBeam256"); return getColumn(31); } ////////////////////////////// // // MuseRecord::beam8Q -- // int MuseRecord::beam8Q(void) { int output = 0; if (getBeam8() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::beam16Q -- // int MuseRecord::beam16Q(void) { int output = 0; if (getBeam16() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::beam32Q -- // int MuseRecord::beam32Q(void) { int output = 0; if (getBeam32() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::beam64Q -- // int MuseRecord::beam64Q(void) { int output = 0; if (getBeam64() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::beam128Q -- // int MuseRecord::beam128Q(void) { int output = 0; if (getBeam128() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::beam256Q -- // int MuseRecord::beam256Q(void) { int output = 0; if (getBeam256() == ' ') { output = 0; } else { output = 1; } return output; } ////////////////////////////// // // MuseRecord::getKernBeamStyle -- // string MuseRecord::getKernBeamStyle(void) { string output; string beams = getBeamField(); for (int i=0; i<(int)beams.size(); i++) { switch (beams[i]) { case '[': // start beam output += "L"; break; case '=': // continue beam // do nothing break; case ']': // end beam output += "J"; break; case '/': // forward hook output += "K"; break; case '\\': // backward hook output += "k"; break; default: ; // do nothing } } return output; } ////////////////////////////// // // MuseRecord::getAdditionalNotationsField -- returns the contents // of columns 32-43. // string MuseRecord::getAdditionalNotationsField(void) { allowNotesOnly("getAdditionalNotationsField"); return extract(32, 43); } ////////////////////////////// // // MuseRecord::additionalNotationsQ -- // int MuseRecord::additionalNotationsQ(void) { int output = 0; if (getLength() < 32) { output = 0; } else { for (int i=32; i<=43; i++) { if (getColumn(i) != ' ') { output = 1; break; } } } return output; } ////////////////////////////// // // MuseRecord::getAddCount -- returns the number of items // in the additional notations field // int MuseRecord::getAddCount(void) { string addString = getAdditionalNotationsField(); string addElement; // element from the notation field int count = 0; int index = 0; while (getAddElementIndex(index, addElement, addString)) { count++; } return count; } ////////////////////////////// // // MuseRecord::getAddItem -- returns the specified item // in the additional notations field // string MuseRecord::getAddItem(int elementIndex) { string output; int count = 0; int index = 0; string addString = getAdditionalNotationsField(); while (count <= elementIndex) { getAddElementIndex(index, output, addString); count++; } return output; } ////////////////////////////// // // MuseRecord::getAddItemLevel -- returns the specified item's // editorial level in the additional notations field // int MuseRecord::getAddItemLevel(int elementIndex) { int count = 0; int index = 0; string number; string addString = getAdditionalNotationsField(); string elementString; // element field while (count < elementIndex) { getAddElementIndex(index, elementString, addString); count++; } int output = -1; repeating: while (addString[index] != '&' && index >= 0) { index--; } if (addString[index] == '&' && !isalnum(addString[index+1])) { index--; goto repeating; } else if (addString[index] == '&') { number = addString[index+1]; output = std::strtol(number.c_str(), NULL, 36); } return output; } ////////////////////////////// // // MuseRecord::getEditorialLevels -- returns a string containing the // edit levels given in the additional notation fields // string MuseRecord::getEditorialLevels(void) { string output; string addString = getAdditionalNotationsField(); for (int index = 0; index < 12-1; index++) { if (addString[index] == '&' && isalnum(addString[index+1])) { output += addString[index+1]; } } return output; } ////////////////////////////// // // MuseRecord::addEditorialLevelQ -- returns true if there are any editorial // levels present in the additional notations fields // int MuseRecord::addEditorialLevelQ(void) { string addString = getAdditionalNotationsField(); int output = 0; for (int i=0; i<12-1; i++) { // minus one for width 2 (&0) if (addString[i] == '&' && isalnum(addString[i+1])) { output = 1; } } return output; } ////////////////////////////// // // MuseRecord::findField -- returns true when it finds the first // instance of the key in the additional fields record. // int MuseRecord::findField(const string& key) { int len = (int)key.size(); string notations = getAdditionalNotationsField(); int output = 0; for (int i=0; i<12-len; i++) { if (notations[i] == key[0]) { output = 1; for (int j=0; j<len; j++) { if (notations[i] != key[j]) { output = 0; goto endofloop; } } } if (output == 1) { break; } endofloop: ; } return output; } ////////////////////////////// // // MuseRecord::findField -- // int MuseRecord::findField(char key, int mincol, int maxcol) { int start = mincol; int stop = getLength() - 1; if (start > stop) { return -1; } if (maxcol < stop) { stop = maxcol; } int i; for (i=start; i<=stop; i++) { if (m_recordString[i-1] == key) { return i; // return the column which is offset from 1 } } return -1; } ////////////////////////////// // // MuseRecord::getSlurParameterRegion -- // string MuseRecord::getSlurParameterRegion(void) { return getColumns(31, 43); } ////////////////////////////// // // MuseRecord::getSlurStartColumn -- search column 32 to 43 for a slur // marker. Returns the first one found from left to right. // returns -1 if a slur character was not found. // int MuseRecord::getSlurStartColumn(void) { int start = 31; int stop = getLength() - 1; if (stop >= 43) { stop = 42; } int i; for (i=start; i<=stop; i++) { switch (m_recordString[i]) { case '(': // slur level 1 case '[': // slur level 2 case '{': // slur level 3 case 'z': // slur level 4 return i+1; // column is offset from 1 } } return -1; } ////////////////////////////// // // MuseRecord::getTextUnderlayField -- returns the contents // of columns 44-80. // string MuseRecord::getTextUnderlayField(void) { allowNotesOnly("getTextUnderlayField"); return extract(44, 80); } ////////////////////////////// // // MuseRecord::textUnderlayQ -- // int MuseRecord::textUnderlayQ(void) { int output = 0; if (getLength() < 44) { output = 0; } else { for (int i=44; i<=80; i++) { if (getColumn(i) != ' ') { output = 1; break; } } } return output; } ////////////////////////////// // // MuseRecord::getVerseCount -- // int MuseRecord::getVerseCount(void) { if (!textUnderlayQ()) { return 0; } int count = 1; for (int i=44; i<=getLength() && i <= 80; i++) { if (getColumn(i) == '|') { count++; } } return count; } ////////////////////////////// // // MuseRecord::getVerse -- // string MuseRecord::getVerse(int index) { string output; if (!textUnderlayQ()) { return output; } int verseCount = getVerseCount(); if (index >= verseCount) { return output; } int tindex = 44; int c = 0; while (c < index && tindex < 80) { if (getColumn(tindex) == '|') { c++; } tindex++; } while (tindex <= 80 && getColumn(tindex) != '|') { output += getColumn(tindex++); } // remove trailing spaces int zindex = (int)output.size() - 1; while (output[zindex] == ' ') { zindex--; } zindex++; output.resize(zindex); // remove leading spaces int spacecount = 0; while (output[spacecount] == ' ') { spacecount++; } // problem here? for (int rr = 0; rr <= zindex-spacecount; rr++) { output[rr] = output[rr+spacecount]; } return output; } ////////////////////////////// // // MuseRecord::getVerseUtf8 -- // string MuseRecord::getVerseUtf8(int index) { string tverse = getVerse(index); return MuseRecord::musedataToUtf8(tverse); } ////////////////////////////// // // MuseRecord::getKernNoteStyle -- // default values: beams = 0, stems = 0 // string MuseRecord::getKernNoteStyle(int beams, int stems) { string output; if (!isAnyNote()) { // not a note, so return nothing return ""; } // place the rhythm stringstream tempdur; int notetype = getGraphicNoteType(); if (timeModificationLeftQ()) { notetype = notetype / 4 * getTimeModificationLeft(); if (timeModificationRightQ()) { notetype = notetype * getTimeModificationRight(); } else { notetype = notetype * 2; } } // logical duration of the note HumNum logicalduration = getTicks(); logicalduration /= getTpq(); string durrecip = Convert::durationToRecip(logicalduration); // graphical duration of the note string graphicrecip = getGraphicRecip(); HumNum graphicdur = Convert::recipToDuration(graphicrecip); string displayrecip; if (graphicdur != logicalduration) { // switch to the logical duration and store the graphic // duration. The logical duration will be used on the // main kern token, and the graphic duration will be stored // as a layout parameter, such as !LO:N:vis=4. to display // the note as a dotted quarter regardless of the logical // duration. // Current test file has encoding bug related to triplets, so // disable graphic notation dealing with tuplets for now. // for now just looking to see if one has a dot and the other does not if ((durrecip.find(".") != string::npos) && (graphicrecip.find(".") == string::npos)) { m_graphicrecip = graphicrecip; displayrecip = durrecip; } else if ((durrecip.find(".") == string::npos) && (graphicrecip.find(".") != string::npos)) { m_graphicrecip = graphicrecip; displayrecip = durrecip; } } if (displayrecip.size() > 0) { output = displayrecip; } else { tempdur << notetype; output = tempdur.str(); // add any dots of prolongation to the output string output += getStringProlongation(); } // add the pitch to the output string string musepitch = getPitchString(); string kernpitch = Convert::musePitchToKernPitch(musepitch); output += kernpitch; string logicalAccidental = getAccidentalString(); string notatedAccidental = getNotatedAccidentalString(); if (notatedAccidental.empty() && !logicalAccidental.empty()) { // Indicate that the logical accidental should not be // displayed (because of key signature or previous // note in the measure that alters the accidental // state of the current note). output += "y"; } else if ((logicalAccidental == notatedAccidental) && !notatedAccidental.empty()) { // Indicate that the accidental should be displayed // and is not suppressed by the key signature or a // previous note in the measure. output += "X"; } // There can be cases where the logical accidental // is natural but the notated accidetnal is sharp (but // the notated accidental means play a natural accidetnal). // Deal with this later. // if there is a notated natural sign, then add it now: string temp = getNotatedAccidentalField(); if (temp == "n") { output += "n"; } // check if a grace note if (getType() == 'g') { output += "Q"; } // if stems is true, then show stem directions if (stems && stemDirectionQ()) { switch (getStemDirection()) { case 1: // 'u' = up output += "/"; break; case -1: // 'd' = down output += "\\"; default: ; // nothing // ' ' = no stem (if stage 2) } } // if beams is true, then show any beams if (beams && beamQ()) { temp = getKernBeamStyle(); output += temp; } if (isTied()) { string tiestarts; string tieends; int lasttie = getLastTiedNoteLineIndex(); int nexttie = getNextTiedNoteLineIndex(); int state = 0; if (lasttie >= 0) { state |= 2; } if (nexttie >= 0) { state |= 1; } switch (state) { case 1: tiestarts += "["; break; case 2: tieends += "]"; break; case 3: tieends += "_"; break; } if (state) { output = tiestarts + output + tieends; } } string slurstarts; string slurends; getSlurInfo(slurstarts, slurends); if ((!slurstarts.empty()) || (!slurends.empty())) { output = slurstarts + output + slurends; } return output; } ////////////////////////////// // // MuseRecord::getSlurInfo -- // // ( ) = regular slur // [ ] = second levels slur, convert to &( and &) // { } = third level slur, convert to &&( and &&) // Z = fourth level slur (how to close?) // void MuseRecord::getSlurInfo(string& slurstarts, string& slurends) { slurstarts.clear(); slurends.clear(); string data = getSlurParameterRegion(); for (int i=0; i<(int)data.size(); i++) { if (data[i] == '(') { slurstarts += '('; } else if (data[i] == ')') { slurends += ')'; } else if (data[i] == '[') { slurstarts += "&{"; } else if (data[i] == ']') { slurends += "&)"; } else if (data[i] == '{') { slurstarts += "&&("; } else if (data[i] == '}') { slurends += "&&)"; } } } ////////////////////////////// // // MuseRecord::getKernNoteAccents -- // string MuseRecord::getKernNoteAccents(void) { string output; int addnotecount = getAddCount(); for (int i=0; i<addnotecount; i++) { string tempnote = getAddItem(i); switch (tempnote[0]) { case 'v': output += "v"; break; // up-bow case 'n': output += "u"; break; // down-bow case 'o': output += "j"; break; // harmonic case 'O': output += "I"; break; // open string (to generic) case 'A': output += "^"; break; // accent up case 'V': output += "^"; break; // accent down case '>': output += "^"; break; // horizontal accent case '.': output += "'"; break; // staccato case '_': output += "~"; break; // tenuto case '=': output += "~'"; break; // detached legato case 'i': output += "s"; break; // spiccato case '\'': output += ","; break; // breath mark case 'F': output += ";"; break; // fermata up case 'E': output += ";"; break; // fermata down case 'S': output += ":"; break; // staccato case 't': output += "O"; break; // trill (to generic) case 'r': output += "S"; break; // turn case 'k': output += "O"; break; // delayed turn (to generic) case 'w': output += "O"; break; // shake (to generic) case 'M': output += "O"; break; // mordent (to generic) case 'j': output += "H"; break; // glissando (slide) } } return output; } ////////////////////////////// // // MuseRecord::getKernRestStyle -- // string MuseRecord::getKernRestStyle(void) { string output; string rhythmstring; // place the rhythm stringstream tempdur; if (!isAnyRest()) { // not a rest, so return nothing return ""; } // logical duration of the note HumNum logicalduration = getTicks(); logicalduration /= getTpq(); string durrecip = Convert::durationToRecip(logicalduration); /* int notetype; if (graphicNoteTypeQ()) { notetype = getGraphicNoteType(); if (timeModificationLeftQ()) { notetype = notetype / 4 * getTimeModificationLeft(); } if (timeModificationRightQ()) { notetype = notetype * getTimeModificationRight() / 2; } tempdur << notetype; output = tempdur.str(); // add any dots of prolongation to the output string output += getStringProlongation(); } else { // stage 1 data: HumNum dnotetype(getTickDuration(), quarter); rhythmstring = Convert::durationToRecip(dnotetype); output += rhythmstring; } */ output = durrecip; // add the pitch to the output string output += "r"; if (isInvisibleRest()) { output += "yy"; } return output; } ////////////////////////////////////////////////////////////////////////// // // functions that work with measure records // ////////////////////////////// // // MuseRecord::getMeasureNumberField -- columns 9-12 // string MuseRecord::getMeasureNumberField(void) { allowMeasuresOnly("getMeasureNumberField"); return extract(9, 12); } ////////////////////////////// // // MuseRecord::getMeasureTypeField -- columns 1 -- 7 // string MuseRecord::getMeasureTypeField(void) { allowMeasuresOnly("getMeasureTypeField"); return extract(1, 7); } ////////////////////////////// // // MuseRecord::getMeasureNumberString -- // string MuseRecord::getMeasureNumberString(void) { string output = getMeasureNumberField(); for (int i=3; i>=0; i--) { if (output[i] == ' ') { output.resize(i); } } return output; } ////////////////////////////// // // MuseRecord::getMeasureNumber -- // int MuseRecord::getMeasureNumber(void) { string measureInfo = getMeasureNumberField(); if (measureInfo.empty()) { return 0; } return std::stoi(measureInfo); } ////////////////////////////// // // MuseRecord::measureNumberQ -- // int MuseRecord::measureNumberQ(void) { string temp = getMeasureNumberString(); int i = 0; int output = 0; while (temp[i] != '\0') { if (temp[i] != ' ') { output = 1; break; } } return output; } ////////////////////////////// // // MuseRecord::getMeasureFlagsString -- Columns 17 to 80. // string MuseRecord::getMeasureFlagsString(void) { if (m_recordString.size() < 17) { return ""; } else { return trimSpaces(m_recordString.substr(16)); } } ////////////////////////////// // // MuseRecord::measureFermataQ -- returns true if there is a // fermata above or below the measure // int MuseRecord::measureFermataQ(void) { int output = 0; for (int i=17; i<=80 && i<= getLength(); i++) { if (getColumn(i) == 'F' || getColumn(i) == 'E') { output = 1; break; } } return output; } ////////////////////////////// // // MuseRecord::measureFlagQ -- Returns true if there are non-space // characters in columns 17 through 80. A more smarter way of // doing this is checking the allocated length of the record, and // do not search non-allocated columns for non-space characters... // int MuseRecord::measureFlagQ(const string& key) { int output = 0; int len = (int)key.size(); for (int i=17; i<=80-len && i<getLength(); i++) { if (getColumn(i) == key[0]) { output = 1; for (int j=0; j<len; j++) { if (getColumn(i+j) != key[j]) { output = 0; break; } } if (output == 1) { break; } } } return output; } ////////////////////////////// // // MuseRecord::addMeasureFlag -- add the following characters to the // Flag region of the measure flag area (columns 17-80). But only // add the flag if it is not already present in the region. If it is // not present, then append it after the last non-space character // in that region. A space will be added between the last item // and the newly added parameter. // void MuseRecord::addMeasureFlag(const string& strang) { string flags = getColumns(17, 80); string flag = strang; HumRegex hre; hre.replaceDestructive(flag, "\\*", "\\*", "g"); hre.replaceDestructive(flag, "\\|", "\\|", "g"); if (hre.search(flags, flag)) { // flag was already found in flags, so don't do anything return; } hre.replaceDestructive(flags, "", "\\s+$"); flags += " "; flags += strang; setColumns(flags, 17, 80); } ////////////////////////////// // // MuseRecord::getKernMeasureStyle -- // string MuseRecord::getKernMeasureStyle(void) { allowMeasuresOnly("getKernMeasureStyle"); string temp; string tempstyle = getMeasureTypeField(); string output = "="; if (tempstyle == "mheavy2") { output += "="; } else if (tempstyle == "mheavy3") { output += "="; } else if (tempstyle == "mheavy4") { output += "="; } if (measureNumberQ()) { temp = getMeasureNumberString(); output += temp; } // what is this for-loop for? for (int i=0; i<(int)temp.size(); i++) { temp[i] = std::tolower(temp[i]); } if (tempstyle == "mheavy1") { output += "!"; } else if (tempstyle == "mheavy2") { if (measureFlagQ(":||:")) { output += ":|!:"; zerase(output, 1); // make "==" become "=" } else if (measureFlagQ(":|")) { output += ":|!"; zerase(output, 1); // make "==" become "=" } } else if (tempstyle == "mheavy3") { output += "!|"; } else if (tempstyle == "mheavy4") { if (measureFlagQ(":||:")) { output += ":!!:"; } else { output += "!!"; } } return output; } ////////////////////////////////////////////////////////////////////////// // // functions that work with musical attributes records // ////////////////////////////// // // MuseRecord::getAttributeMap -- // void MuseRecord::getAttributeMap(map<string, string>& amap) { amap.clear(); // Should be "3" on the next line, but "1" or "2" might catch poorly formatted data. string contents = getLine().substr(2); if (contents.empty()) { return; } int i = 0; string key; string value; int state = 0; // 0 outside, 1 = in key, 2 = in value while (i < (int)contents.size()) { switch (state) { case 0: // outside of key or value if (!isspace(contents[i])) { if (contents[i] == ':') { // Strange: should not happen key.clear(); state = 2; } else { state = 1; key += contents[i]; } } break; case 1: // in key if (!isspace(contents[i])) { if (contents[i] == ':') { value.clear(); state = 2; } else { // Add to key, such as "C2" for second staff clef. key += contents[i]; } } break; case 2: // in value if (key == "D") { value += contents[i]; } else if (isspace(contents[i])) { // store parameter and clear variables amap[key] = value; state = 0; key.clear(); value.clear(); } else { value += contents[i]; } break; } i++; } if ((!key.empty()) && (!value.empty())) { amap[key] = value; } } ////////////////////////////// // // MuseRecord::getAttributes -- // string MuseRecord::getAttributes(void) { string output; switch (getType()) { case E_muserec_musical_attributes: break; default: cerr << "Error: cannot use getAttributes function on line: " << getLine() << endl; return ""; } int ending = 0; int tempcol; for (int column=4; column <= getLength(); column++) { if (getColumn(column) == ':') { tempcol = column - 1; while (tempcol > 0 && getColumn(tempcol) != ' ') { tempcol--; } tempcol++; while (tempcol <= column) { output += getColumn(tempcol); if (output.back() == 'D') { ending = 1; } tempcol++; } } if (ending) { break; } } return output; } ////////////////////////////// // // MuseRecord::attributeQ -- // int MuseRecord::attributeQ(const string& attribute) { switch (getType()) { case E_muserec_musical_attributes: break; default: cerr << "Error: cannot use getAttributes function on line: " << getLine() << endl; return 0; } string attributelist = getAttributes(); int output = 0; int attstrlength = (int)attributelist.size(); int attlength = (int)attribute.size(); for (int i=0; i<attstrlength-attlength+1; i++) { if (attributelist[i] == attribute[0]) { output = 1; for (int j=0; j<attlength; j++) { if (attributelist[i] != attribute[j]) { output = 0; break; } } if (output == 1) { break; } } } return output; } ////////////////////////////// // // MuseRecord::getAttributeInt -- // int MuseRecord::getAttributeInt(char attribute) { switch (getType()) { case E_muserec_musical_attributes: break; default: cerr << "Error: cannot use getAttributeInt function on line: " << getLine() << endl; return 0; } int output = E_unknown; int ending = 0; int index = 0; int tempcol; int column; for (column=4; column <= getLength(); column++) { if (getColumn(column) == ':') { tempcol = column - 1; while (tempcol > 0 && getColumn(tempcol) != ' ') { tempcol--; } tempcol++; while (tempcol <= column) { if (getColumn(tempcol) == attribute) { ending = 2; } else if (getColumn(tempcol) == 'D') { ending = 1; } tempcol++; index++; } } if (ending) { break; } } if (ending == 0 || ending == 1) { return output; } else { string value = &getColumn(column+1); if (value.empty()) { output = std::stoi(value); return output; } else { return 0; } } } ////////////////////////////// // // MuseRecord::getAttributeField -- returns true if found attribute // int MuseRecord::getAttributeField(string& value, const string& key) { switch (getType()) { case E_muserec_musical_attributes: break; default: cerr << "Error: cannot use getAttributeInt function on line: " << getLine() << endl; return 0; } int returnValue = 0; int ending = 0; int index = 0; int tempcol; int column; for (column=4; column <= getLength(); column++) { if (getColumn(column) == ':') { tempcol = column - 1; while (tempcol > 0 && getColumn(tempcol) != ' ') { tempcol--; } tempcol++; while (tempcol <= column) { if (getColumn(tempcol) == key[0]) { ending = 2; } else if (getColumn(tempcol) == 'D') { ending = 1; } tempcol++; index++; } } if (ending) { break; } } value.clear(); if (ending == 0 || ending == 1) { return returnValue; } else { returnValue = 1; column++; while (getColumn(column) != ' ') { value += getColumn(column++); } return returnValue; } } /////////////////////////////////////////////////////////////////////////// // // functions that work with basso continuo figuration records (f): // ////////////////////////////// // // MuseRecord::getFigureCountField -- column 2. // string MuseRecord::getFigureCountField(void) { allowFigurationOnly("getFigureCountField"); return extract(2, 2); } ////////////////////////////// // // MuseRecord::getFigurationCountString -- // string MuseRecord::getFigureCountString(void) { allowFigurationOnly("getFigureCount"); string output = extract(2, 2); if (output[0] == ' ') { output = ""; } return output; } ////////////////////////////// // // MuseRecord::getFigurationCount -- // int MuseRecord::getFigureCount(void) { allowFigurationOnly("getFigureCount"); string temp = getFigureCountString(); int output = std::strtol(temp.c_str(), NULL, 36); return output; } ////////////////////////////// // // getFigurePointerField -- columns 6 -- 8. // string MuseRecord::getFigurePointerField(void) { allowFigurationOnly("getFigurePointerField"); return extract(6, 8); } ////////////////////////////// // // figurePointerQ -- // int MuseRecord::figurePointerQ(void) { allowFigurationOnly("figurePointerQ"); int output = 0; for (int i=6; i<=8; i++) { if (getColumn(i) != ' ') { output = 1; break; } } return output; } ////////////////////////////// // // MuseRecord::getFigureString -- // string MuseRecord::getFigureString(void) { string output = getFigureFields(); for (int i=(int)output.size()-1; i>= 0; i--) { if (isspace(output[i])) { output.resize((int)output.size() - 1); } else { break; } } return output; } ////////////////////////////// // // MuseRecord::getFigureFields -- columns 17 -- 80 // string MuseRecord::getFigureFields(void) { allowFigurationOnly("getFigureFields"); return extract(17, 80); } ////////////////////////////// // // MuseRecord::figureFieldsQ -- // int MuseRecord::figureFieldsQ(void) { allowFigurationOnly("figureFieldsQ"); int output = 0; if (getLength() < 17) { output = 0; } else { for (int i=17; i<=80; i++) { if (getColumn(i) != ' ') { output = 1; break; } } } return output; } ////////////////////////////// // // getFigure -- // string MuseRecord::getFigure(int index) { string output; allowFigurationOnly("getFigure"); if (index >= getFigureCount()) { return output; } string temp = getFigureString(); if (index == 0) { return temp; } HumRegex hre; vector<string> pieces; hre.split(pieces, temp, " +"); if (index < (int)pieces.size()) { output = pieces[index]; } return output; } /////////////////////////////////////////////////////////////////////////// // // protected functions // ////////////////////////////// // // MuseRecord::allowFigurationOnly -- // void MuseRecord::allowFigurationOnly(const string& functionName) { switch (getType()) { case E_muserec_figured_harmony: break; default: cerr << "Error: can only access " << functionName << " on a figuration record. Line is: " << getLine() << endl; return; } } ////////////////////////////// // // MuseRecord::allowFigurationAndNotesOnly -- // void MuseRecord::allowFigurationAndNotesOnly(const string& functionName) { switch (getType()) { case E_muserec_figured_harmony: case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_note_grace: case E_muserec_note_cue: break; default: cerr << "Error: can only access " << functionName << " on a figuration record. Line is: " << getLine() << endl; return; } } ////////////////////////////// // // MuseRecord::allowMeasuresOnly -- // void MuseRecord::allowMeasuresOnly(const string& functionName) { switch (getType()) { case E_muserec_measure: break; default: cerr << "Error: can only access " << functionName << " on a measure record. Line is: " << getLine() << endl; return; } } ////////////////////////////// // // MuseRecord::allowNotesOnly -- // void MuseRecord::allowNotesOnly(const string& functionName) { switch (getType()) { case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_note_grace: case E_muserec_note_cue: break; default: cerr << "Error: can only access " << functionName << " on a note record. Line is: " << getLine() << endl; return; } } ////////////////////////////// // // MuseRecord::allowNotesAndRestsOnly -- // void MuseRecord::allowNotesAndRestsOnly(const string& functionName) { switch (getType()) { case E_muserec_note_regular: case E_muserec_note_chord: case E_muserec_note_grace: case E_muserec_note_cue: case E_muserec_rest: case E_muserec_rest_invisible: break; default: cerr << "Error: can only access " << functionName << " on a note or rest records. Line is: " << getLine() << endl; return; } } ////////////////////////////// // // MuseRecord::getAddElementIndex -- get the first element pointed // to by the specified index in the additional notations field. // returns 0 if no element was found, or 1 if an element was found. // int MuseRecord::getAddElementIndex(int& index, string& output, const string& input) { int finished = 0; int count = 0; output.clear(); while (!finished) { switch (input[index]) { case '&': // editorial level marker // there is exactly one character following an editorial // marker. neither the '&' nor the following character // is counted if the following character is in the set // [0..9, A..Z, a..z] index++; if (isalnum(input[index])) { index++; } else { // count '&' as an element count++; output += '&'; } break; case 'p': case 'f': // piano and forte // any sequence of 'p' and 'f' is considered one element count++; output += input[index++]; while (input[index] == 'p' || input[index] == 'f') { output += input[index++]; } break; case 'Z': // sfz, or Zp = sfp // elements starting with 'Z': // Z = sfz // Zp = sfp count++; output += input[index++]; if (input[index] == 'p') { output += input[index++]; } break; case 'm': // mezzo // a mezzo marking MUST be followed by a 'p' or an 'f'. count++; output += input[index++]; if (input[index] == 'p' || input[index] == 'f') { output += input[index++]; } else { cout << "Error at \'m\' in notation field: " << input << endl; return 0; } break; case 'S': // arpeggiation // elements starting with 'S': // S = arpeggiate (up) // Sd = arpeggiate down) count++; output += input[index++]; if (input[index] == 'd') { output += input[index++]; } break; case '1': // fingering case '2': // fingering case '3': // fingering case '4': // fingering case '5': // fingering // case ':': // finger substitution // keep track of finger substitutions count++; output += input[index++]; if (input[index] == ':') { output += input[index++]; output += input[index++]; } break; ////////////////////////////// // Ornaments // case 't': // trill (tr.) case 'r': // turn case 'k': // delayed turn case 'w': // shake case '~': // trill wavy line extension case 'c': // continued wavy line case 'M': // mordent case 'j': // slide (Schleifer) // ornaments can be modified by accidentals: // s = sharp // ss = double sharp // f = flat // ff = double flat // h = natural // u = next accidental is under the ornament // any combination of these characters following a // ornament is considered one element. // count++; index++; while (input[index] == 's' || input[index] == 'f' || input[index] == 'h' || input[index] == 'u') { output += input[index++]; } break; ////////////////////////////////////////////////////////////// // The following chars are uniquely SINGLE letter items: // // // // // case '-': // tie // case '(': // open slur #1 // case ')': // close slur #1 // case '[': // open slur #2 // case ']': // close slur #2 // case '{': // open slur #3 // case '}': // close slur #3 // case 'z': // open slur #4 // case 'x': // close slur #4 // case '*': // start written tuplet // case '!': // end written tuplet // case 'v': // up bow // case 'n': // down bow // case 'o': // harmonic // case 'O': // open string // case 'Q': // thumb position // case 'A': // accent (^) // case 'V': // accent (v) // case '>': // accent (>) // case '.': // staccatto // case '_': // tenuto // case '=': // detached tenuto // case 'i': // spiccato // case '\'': // breath mark // case 'F': // upright fermata // case 'E': // inverted fermata // case 'R': // rfz // case '^': // editorial accidental // case '+': // cautionary accidental // count++; // output += input[index++]; // break; // // // // // ////////////////////////////////////////////////////////////// case ' ': // ignore blank spaces and continue counting elements index++; break; default: cout << "Error: unknown additional notation: " << input[index] << endl; return 0; } if (count != 0 || index >= 12) { finished = 1; } } // end of while (!finished) loop return count; } //////////////////// // // MuseRecord::zerase -- removes specified number of characters from // the beginning of the string. // void MuseRecord::zerase(string& inout, int num) { int len = (int)inout.size(); if (num >= len) { inout = ""; } else { for (int i=num; i<=len; i++) { inout[i-num] = inout[i]; } } inout.resize(inout.size() - num); } // END_MERGE } // end namespace hum
[ "craigsapp@gmail.com" ]
craigsapp@gmail.com
de3afc217c412c0f6fd0b83512088e159ed712e4
1a9e5914b9aef1627aa8b12b992e600a8f68365f
/AmethystUDPServer/cPhysicsManager.hpp
5aebcf52f19b5a16c2ccb552e3b81f1259efea38
[]
no_license
KirkbyD/edu-Netwrk-UDP
c91b6c87844d9a34254892e3daa97733b6a33639
240f2cccb5f124b7b34769f5d4f230c9b534f139
refs/heads/main
2023-04-09T21:12:33.716446
2021-04-15T02:44:37
2021-04-15T02:44:37
358,109,637
0
0
null
null
null
null
UTF-8
C++
false
false
2,059
hpp
#pragma once #include <vector> #include "iMediatorInterface.hpp" #include "MediatorGlobals.hpp" #include <map> #include "cError.hpp" #include "cPhysics.hpp" #include "cAABB.hpp" #include "cModelObject.hpp" #include "DebugRenderer/cDebugRenderer.hpp" #include "cGameObjectFactory.hpp" #include "cUDPServer.hpp" struct BoundingBox { glm::vec3 minCorner; glm::vec3 maxCorner; glm::quat orientation; }; class cPhysicsManager : iMediatorInterface { cPhysicsManager(); static cPhysicsManager stonPhysMngr; iMediatorInterface* pMediator; cError error; cPhysics* pPhysics; std::map<unsigned long long /*ID*/, cAABB*> g_mapAABBs_World; std::vector<glm::vec3> vec_BoundingBox_Test_Points; std::vector<glm::vec3> vec_BoundingBox_ClosestPoints; //debug aabb cubes with rendered cubes cGameObjectFactory ObjectFactory; unsigned long long prevAABB; std::string currAABB; public: static cPhysicsManager* GetPhysicsManager(); void IntegrationStep(std::vector<cModelObject*>& vec_pGameObjects, float deltaTime); void TestForCollisions(std::vector<cModelObject*>& vec_pGameObjects); void TestForComplexCollisions(std::vector<cComplexObject*> g_vec_pComplexObjects, cDebugRenderer* pDebugRenderer); void TestForNetworkBulletCollisions(std::vector<ServerPlayer>& players); void CalcAABBsForMeshModel(cModelObject* theModel); void AssignTriangle(std::vector<sPlyTriangle>::iterator itTri, glm::vec3 v1, glm::vec3 v2, glm::vec3 v3, float maxLength); void CalculateTransformedMesh(cMesh& originalMesh, glm::mat4 matWorld, cMesh& mesh_transformedInWorld); BoundingBox CalculateBoundingBox(cModelObject* theModel); void DrawAABBs(); int TrianglesInCurrentAABB(glm::vec3 pos); std::string CurrentAABB(glm::vec3 pos); cAABB* GetCurrentAABB(); cAABB* GetPointAABB(glm::vec3 pos); unsigned long long GetPreviousAABB(); void DrawTestPoints(cComplexObject* Parent); // Mediator Functions void setMediatorPointer(iMediatorInterface* pMediator); virtual sNVData RecieveMessage(sNVData message); virtual sData RecieveMessage(sData& data); };
[ "kirkby.dylan@gmail.com" ]
kirkby.dylan@gmail.com
3e3cb54d529976d6bf598987d5d5f7527bcedc52
2066017b8d6a1fb750787c08f5a43d87bf2dff99
/PrMCTools/PrDownstreamChecker.cpp
dbf567f2c022d4dbff22286547dee0ebb9412850
[]
no_license
adamdddave/downstream
3d5290bafa150ac0ade92ded54d236aea2f9f730
149f5802e8c7deacb278b36db4bf4ab787fbfe39
refs/heads/master
2021-01-10T14:50:52.198598
2015-06-10T09:54:24
2015-06-10T09:54:24
36,117,684
0
0
null
null
null
null
UTF-8
C++
false
false
85,891
cpp
// Include files #ifndef PrDownstreamChecker_CPP #define PrDownstreamChecker_CPP #include "GaudiKernel/AlgFactory.h" #include "GaudiKernel/PhysicalConstants.h" #include "Event/FitNode.h" #include "Event/STCluster.h" #include "Kernel/HitPattern.h" #include "Linker/AllLinks.h" #include "Linker/LinkedFrom.h" #include "Event/StateParameters.h" #include "PrDownstreamChecker.h" DECLARE_ALGORITHM_FACTORY( PrDownstreamChecker ) bool dAncestor(const LHCb::MCParticle* mcPart){ bool fromD = false; const LHCb::MCParticle* mother = mcPart->mother(); while ( mother !=0 && fromD == false) { fromD = mother->particleID().hasCharm(); mother = mother->mother(); } return fromD; } //============================================================================= // Standard constructor, initializes variables //============================================================================= PrDownstreamChecker::PrDownstreamChecker(const std::string& name, ISvcLocator* pSvcLocator ) : GaudiTupleAlg( name , pSvcLocator ), m_associator(0,""), m_associator_seed(0,""), m_associator_updatedseed(0,""),evt(-1) { //locations of the downstream and seed containers declareProperty("DownstreamContainer", m_DownstreamContainer = LHCb::TrackLocation::Downstream); declareProperty("TSeedContainer", m_TSeedContainer = LHCb::TrackLocation::Seed); declareProperty("UpdatedTSeed_Container",m_Test_Container = LHCb::TrackLocation::Downstream +"UpdatedSeed"); } //============================================================================= // Destructor //============================================================================= PrDownstreamChecker::~PrDownstreamChecker() {;} //============================================================================= // Initialization //============================================================================= StatusCode PrDownstreamChecker::initialize() { // Mandatory initialization of GaudiAlgorithm StatusCode sc = GaudiTupleAlg::initialize(); if ( sc.isFailure() ) { return sc; } m_selector = tool<IMCReconstructible>("MCReconstructible","Selector",this); return StatusCode::SUCCESS; } //============================================================================= // Execute //============================================================================= StatusCode PrDownstreamChecker::execute() { StatusCode sc = StatusCode::SUCCESS; evt++; // check input data if (!exist<LHCb::Tracks>(m_DownstreamContainer)) return Warning( m_DownstreamContainer+" not found", StatusCode::SUCCESS, 0); if (!exist<LHCb::Tracks>(m_TSeedContainer)) return Warning( m_TSeedContainer+" not found", StatusCode::SUCCESS, 0); //ad if (!exist<LHCb::Tracks>(m_Test_Container)) return Warning( m_Test_Container+" not found", StatusCode::SUCCESS, 0); //ad LHCb::Tracks* downstream = get<LHCb::Tracks>(m_DownstreamContainer); nDownstreamTracks = downstream->size(); LHCb::Tracks* seed = get<LHCb::Tracks>(m_TSeedContainer); nSeedTracks = seed->size(); if ( msgLevel(MSG::DEBUG) ){ //ad. Test the downstream test container and make sure we can get the extra info LHCb::Tracks* downstream_test = get<LHCb::Tracks>(m_DownstreamContainer); // nDownstreamTestTracks = downstream_test->size(); for(LHCb::Tracks::const_iterator itT = downstream_test->begin(); downstream_test->end()!=itT; ++itT){ LHCb::Track* tester = *itT; debug()<<"test info 1800 = "<<tester->info(1800,-999)<<endmsg; //info()<<"test info 21 = "<<tester->info(LHCb::Track::FitTChi2,-999)<<endmsg; } LHCb::Tracks* updatedSeed_test = get<LHCb::Tracks>(m_Test_Container); // nDownstreamTestTracks = downstream_test->size(); for(LHCb::Tracks::const_iterator itT = updatedSeed_test->begin(); updatedSeed_test->end()!=itT; ++itT){ LHCb::Track* tester = *itT; debug()<<"test info for seed 1800 = "<<tester->info(1800,-999)<<endmsg; //info()<<"test info 21 = "<<tester->info(LHCb::Track::FitTChi2,-999)<<endmsg; } } //end test ad //nSeedTracks = //int nDownstreamTracks; // get the association tables m_associator = AsctTool(evtSvc(), m_DownstreamContainer); m_directTable = m_associator.direct(); if (!m_directTable) return Error("Failed to find direct table for Downstream tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); m_inverseTable = m_associator.inverse(); if (!m_inverseTable) return Error("Failed to find inverse table for Downstream tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); m_associator_seed = AsctTool(evtSvc(), m_TSeedContainer); m_directTable_seed = m_associator_seed.direct(); if (!m_directTable_seed) return Error("Failed to find direct table for Seed tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); m_inverseTable_seed = m_associator_seed.inverse(); if (!m_inverseTable_seed) return Error("Failed to find inverse table for Seed tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); //AD 1-10-14 m_associator_updatedseed = AsctTool(evtSvc(), m_Test_Container); m_directTable_updatedseed = m_associator_updatedseed.direct(); if (!m_directTable_updatedseed) return Error("Failed to find direct table for Updated Seed tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); m_inverseTable_updatedseed = m_associator_updatedseed.inverse(); if (!m_inverseTable_updatedseed) return Error("Failed to find inverse table for Updated Seed tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); // loop over MC particles if ( loopOverMCParticles().isFailure() ) return Error("Failed to loop over MC particles", /*StatusCode::FAILURE*/StatusCode::SUCCESS); // loop over tracks if ( loopOverTracks().isFailure() ) return Error("Failed to loop over tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); // loop over tracks if ( loopOverSeeds().isFailure() ) return Error("Failed to loop over tracks", /*StatusCode::FAILURE*/StatusCode::SUCCESS); //loop over updated tseeds. AD 1-10-14 if ( loopOverUpdatedSeeds().isFailure() ) return Error("Failed to loop over updated tseeds", /*StatusCode::FAILURE*/StatusCode::SUCCESS); return StatusCode::SUCCESS; } //============================================================================= // Initialization //============================================================================= StatusCode PrDownstreamChecker::finalize() { return GaudiTupleAlg::finalize(); } //============================================================================= // Loop over MC particles and look for reconstructed tracks //============================================================================= StatusCode PrDownstreamChecker::loopOverMCParticles() { if ( msgLevel(MSG::DEBUG) ) debug() << "==> loopOverMCParticles" << endmsg; n_in_evt = -1; MCTrackInfo trackInfo( evtSvc(), msgSvc() ); // book the ntuple Tuples::Tuple ntuple = GaudiTupleAlg::nTuple("MCParticles","MCParticles", CLID_ColumnWiseTuple ); LHCb::Tracks* downstream_tracks = get<LHCb::Tracks>(m_DownstreamContainer); // loop over MC particles const LHCb::MCParticles* particles = get<LHCb::MCParticles>(LHCb::MCParticleLocation::Default); int nTrack(0); for (LHCb::MCParticles::const_iterator ip = particles->begin(); ip != particles->end(); ++ip) { debug() << "processing MC particle #" << nTrack << "/" << particles->size() << endmsg ; nTrack++; if ( msgLevel(MSG::DEBUG) ) debug() << "==> PID = " << fabs((*ip)->particleID().pid()) << endmsg; //reject electrons at this stage if ( fabs((*ip)->particleID().pid())==11 ) continue; // information for the tuple int nHits = -999; //rest moved to "fill MC particle. 1-15-14 /* bool reconstructible_asLong(false); bool B_child(false); bool D_child(false); bool isLong(false); bool isDown(false); bool isInVelo(false);*/ bool over5(false); int parentABSID = -999;//add to MC partcilefill. AD 1-12-14 /* int has_all_info(-1); //need to make sure we have full track info. has_all_info = trackInfo.fullInfo( *ip ); reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,*ip); isLong = trackInfo.hasVeloAndT( *ip ); isDown = trackInfo.hasT( *ip ) && trackInfo.hasTT( *ip ); */ over5 = 5000. < fabs( (*ip)->p() ); /* isInVelo = trackInfo.hasVelo( *ip ); */ if ( 0 != (*ip)->originVertex() ) { const LHCb::MCParticle* mother = (*ip)->originVertex()->mother(); if ( 0 != mother ) { if ( 0 != mother->originVertex() ) { //double rOrigin = mother->originVertex()->position().rho(); parentABSID = abs( mother->particleID().pid() ); } } } /* if(bAncestor(*ip)){ B_child = true; } if(dAncestor(*ip)){ D_child = true; }*/ //here nHits = getUT_hits(*ip); if(!over5) continue; //if(!over5) continue; if(parentABSID!=310) continue; /// good candidate n_in_evt++; /// fill the tuple with MC information /* ntuple->column("parentABSID", parentABSID); ntuple->column("fullInfo", has_all_info); ntuple->column("reconstructible_asLong", reconstructible_asLong); ntuple->column("isLong", isLong); ntuple->column("isDown", isDown); ntuple->column("over5", over5); ntuple->column("isInVelo", isInVelo); ntuple->column("B_child", B_child); ntuple->column("D_child", D_child);*/ ntuple->column("nUT_hits", nHits); fillMCParticle(*ip,ntuple); /// now start to look for the reconstructed particle AsctTool::InverseType::Range range = m_inverseTable->relations(*ip); bool reconstructed(false); bool reconstructed_seed(false); unsigned int clone(0u); double purity(-1.); reconstructed = !(range.empty()); const LHCb::Track *track(0); if (reconstructed) { track = range.begin()->to(); clone = range.size()-1u; purity = range.begin()->weight(); } range = m_inverseTable_seed->relations(*ip); reconstructed_seed = !(range.empty()); fillTrack(track,ntuple); ntuple->column("reconstructed", reconstructed); ntuple->column("nClones", clone); ntuple->column("purity", purity); ntuple->column("reconstructed_seed", reconstructed_seed); // Loop over the Tracks LinkedFrom<LHCb::STCluster,LHCb::MCParticle> ttLink(evtSvc(),msgSvc(), LHCb::STClusterLocation::UTClusters); /*if (!ttLink.notFound()){ debug() << "now loop over UT clusters for this MC particle" << endmsg; int nhits = 0; const LHCb::STCluster* TTCluster = ttLink.first((*ip)); for ( ; 0 != TTCluster; TTCluster = ttLink.next()) { //if ( !TTCluster->isUT() ) continue; //LHCbID : { UT STChannelID : 20128867 : type=2 strip=99 sector=73 detRegion=1 layer=2 station=1 } } nhits++; debug() << "hit " << nhits //<< ": type=" << TTCluster->type() << ": ID=" << TTCluster->channelID() << ": strip=" << TTCluster->strip() << ": sector=" << TTCluster->sector() << ": detRegion=" << TTCluster->detRegion() << ": layer=" << TTCluster->layer() << ": station=" << TTCluster->station() << endmsg; } }else{ debug () << "no ttLink" << endmsg; }*/ if (!ttLink.notFound()){ debug() << "begin loop over reco downstream tracks" << endmsg; for( LHCb::Tracks::const_iterator it = downstream_tracks->begin(); downstream_tracks->end() != it; ++it ) { //const Track* tr = *it; //debug () << "looping over lhcbIDs" << endmsg; int IDnumber = 0; for( std::vector<LHCb::LHCbID>::const_iterator iId = (*it)->lhcbIDs().begin(); (*it)->lhcbIDs().end() != iId; ++iId ){ IDnumber++; //debug() << "id " << IDnumber << " = " << *iId << endmsg; int TrackSTID((*iId).lhcbID()); if (!ttLink.notFound()){ debug() << "now loop over UT clusters for this MC particle" << endmsg; int nhits = 0; const LHCb::STCluster* TTCluster = ttLink.first((*ip)); for ( ; 0 != TTCluster; TTCluster = ttLink.next()) { //if ( !TTCluster->isUT() ) continue; //LHCbID : { UT STChannelID : 20128867 : type=2 strip=99 sector=73 detRegion=1 layer=2 station=1 } } nhits++; if(TTCluster->channelID() == TrackSTID){ debug() << "matching hit " << nhits << ": type=" << TTCluster->channelID() << ": strip=" << TTCluster->strip() << ": sector=" << TTCluster->sector() << ": detRegion=" << TTCluster->detRegion() << ": layer=" << TTCluster->layer() << ": station=" << TTCluster->station() << endmsg; }else{ debug() << "STID = " << TrackSTID << ", MC ID = " << TTCluster->channelID() << endmsg; } } }else{ debug () << "no ttLink" << endmsg; } } } //break; }else{ debug() << "no TT link found" << endmsg; } StatusCode sc = ntuple->write(); if (sc.isFailure()) return Error("Failed to fill the ntuple", /*StatusCode::FAILURE*/StatusCode::SUCCESS); }//end of loop over MC particles return StatusCode::SUCCESS; } //============================================================================= // Loop over tracks and look for matched MC particles //============================================================================= StatusCode PrDownstreamChecker::loopOverTracks() { debug() << "Loopng over reconstructed downstream tracks" << endmsg ; // book the ntuple Tuples::Tuple ntuple = GaudiTupleAlg::nTuple("DownstreamTracks","DownstreamTracks", CLID_ColumnWiseTuple ); // Loop over tracks LHCb::Tracks* tracks = get<LHCb::Tracks>(m_DownstreamContainer); int nTrack = -1; n_in_evt = -1; for (LHCb::Tracks::const_iterator it = tracks->begin(); it!=tracks->end(); ++it) { n_in_evt++; nTrack++; //debug() << "processing reconstructed downstream track #" //<< nTrack << "/" << tracks->size() << endmsg ; fillTrack(*it,ntuple); //add n tracks info. AD 1-24-14 int ngoodx1(-2), ngoodx2(-2),ngoodu(-2),ngoodv(-2); int ntotx1(-2), ntotx2(-2),ntotu(-2),ntotv(-2); ngoodx1 = (*it)->info(1900,-1);//good ngoodu = (*it)->info(1901,-1);//good ngoodv = (*it)->info(1902,-1);//good ngoodx2 = (*it)->info(1903,-1);//good ntotx1 = (*it)->info(1904,-1);//tot ntotu = (*it)->info(1905,-1);//tot ntotv = (*it)->info(1906,-1);//tot ntotx2 = (*it)->info(1907,-1);//tot //initialized. add it to the tuple ntuple->column("Goodx1Hits",ngoodx1); ntuple->column("GooduHits",ngoodu); ntuple->column("GoodvHits",ngoodv); ntuple->column("Goodx2Hits",ngoodx2); ntuple->column("Totx1Hits",ntotx1); ntuple->column("TotuHits",ntotu); ntuple->column("TotvHits",ntotv); ntuple->column("Totx2Hits",ntotx2); AsctTool::DirectType::Range range = m_directTable->relations(*it); bool ghost = range.empty(); const LHCb::MCParticle* particle(0); if (!ghost) { particle = range.begin()->to(); if( particle && particle->particleID().threeCharge()==0 ) { particle = 0; } } fillMCParticle(particle,ntuple); /* bool reconstructible_asLong(false); reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,particle); ntuple->column("reconstructible_asLong", reconstructible_asLong); bool reconstructible_asDown(false); reconstructible_asDown = m_selector->isReconstructibleAs(IMCReconstructible::ChargedDownstream,particle); ntuple->column("reconstructible_asDown",reconstructible_asDown);//AD 1-10-14 */ LHCb::Track* seedTr = new LHCb::Track; LHCb::Track* seedUTTr = *it; SmartRefVector<LHCb::Track>& ancestor = seedUTTr->ancestors(); for( SmartRefVector<LHCb::Track>::iterator trIt = ancestor.begin(); ancestor.end() != trIt; trIt++) { seedTr = *trIt; } AsctTool::DirectType::Range range_seed = m_directTable_seed->relations(seedTr); bool ghost_seed = range_seed.empty(); ntuple->column("ghost_seed", ghost_seed); std::vector<double>new_chi2s;new_chi2s.reserve(100); std::vector<double>new_ndfs;new_ndfs.reserve(100); std::vector<int>new_chi2_is_mc_cand;new_chi2_is_mc_cand.reserve(100); new_chi2s.clear(); new_ndfs.clear(); new_chi2_is_mc_cand.clear(); int size_of_track_candidates = (*it)->info(36000,-999.); if(size_of_track_candidates >100) { size_of_track_candidates=100;} debug()<<"size_of_track_candidates = "<<size_of_track_candidates<<endmsg; ntuple->column("n_track_candidates_considered",size_of_track_candidates); for(int i=1; i<size_of_track_candidates;++i){ debug()<<"i = "<<i<<endmsg; debug()<<"info 36000 + i = "<<(*it)->info(36000+i,-9999.)<<endmsg; if(i>100)continue; new_chi2s.push_back((*it)->info(36000+i,-9999.)); new_ndfs.push_back((*it)->info(36500+i,-9999.)); new_chi2_is_mc_cand.push_back((*it)->info(37000+i,-1)); //new_chi2_is_matched_2_store.push_back((*it)->info(38000+i,-1)); debug()<<"new_chi2s[i] = "<<new_chi2s[i]<<endmsg; } debug()<<"makking array"<<endmsg; ntuple->farray("new_chi2",new_chi2s.begin(), new_chi2s.end(),"size_of_track_candidates",100); ntuple->farray("new_ndf",new_ndfs.begin(), new_ndfs.end(),"size_of_track_candidates",100); ntuple->farray("new_chi2_is_good_mc_cand",new_chi2_is_mc_cand.begin(),new_chi2_is_mc_cand.end(), "size_of_track_candidates",100); //ntuple->farray("new_chi2_is_final_track",new_chi2_is_matched_2_store.begin(), new_chi2_is_matched_2_store.end(), // "size_of_track_candidates",100); debug()<<"array done"<<endmsg; ntuple->column("saved_track_new_chi2", (*it)->info(38000,-1.) ); ntuple->column("saved_track_new_ndf", (*it)->info(39000,-1.) ); ntuple->column("ft_begin_true_xmid",(*it)->info(99000,-99999.)); ntuple->column("ft_begin_true_ymid",(*it)->info(99001,-99999.)); ntuple->column("ft_begin_true_zmid",(*it)->info(99002,-99999.)); ntuple->column("ft_begin_true_tx",(*it)->info(99003,-99999.)); ntuple->column("ft_begin_true_ty",(*it)->info(99004,-99999.)); ntuple->column("ft_begin_true_qop",(*it)->info(99005,-99999.)); ntuple->column("ft_begin_true_entryx",(*it)->info(99006,-99999.)); ntuple->column("ft_begin_true_entryy",(*it)->info(99007,-99999.)); ntuple->column("ft_begin_true_entryz",(*it)->info(99008,-99999.)); StatusCode sc = ntuple->write(); if (sc.isFailure()) return Error("Failed to fill the ntuple", /*StatusCode::FAILURE*/StatusCode::SUCCESS); }//end of loop over tracks return StatusCode::SUCCESS; } //============================================================================= // Loop over tracks and look for matched MC particles //============================================================================= StatusCode PrDownstreamChecker::loopOverSeeds() { // book the ntuple Tuples::Tuple ntuple = GaudiTupleAlg::nTuple("SeedTracks","SeedTracks", CLID_ColumnWiseTuple ); // Loop over tracks LHCb::Tracks* tracks = get<LHCb::Tracks>(m_TSeedContainer); n_in_evt = -1; for (LHCb::Tracks::const_iterator it = tracks->begin(); it!=tracks->end(); ++it) { n_in_evt++; fillTrack(*it,ntuple); //m_directTable_seed AsctTool::DirectType::Range range = m_directTable_seed->relations(*it); bool ghost = range.empty(); const LHCb::MCParticle* particle(0); if (!ghost) { particle = range.begin()->to(); if( particle && particle->particleID().threeCharge()==0 ) { particle = 0; } } fillMCParticle(particle,ntuple); //hack the ideal states myself bool reconstructible_asLong(false); reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,particle); ntuple->column("reconstructible_asLong", reconstructible_asLong); LHCb::Track* seedTr = new LHCb::Track; LHCb::Track* seedUTTr = *it; SmartRefVector<LHCb::Track>& ancestor = seedUTTr->ancestors(); for( SmartRefVector<LHCb::Track>::iterator trIt = ancestor.begin(); ancestor.end() != trIt; trIt++) { seedTr = *trIt; } AsctTool::DirectType::Range range_seed = m_directTable_seed->relations(seedTr); bool ghost_seed = range_seed.empty(); ntuple->column("ghost_seed", ghost_seed); StatusCode sc = ntuple->write(); if (sc.isFailure()) return Error("Failed to fill the ntuple", /*StatusCode::FAILURE*/StatusCode::SUCCESS); }//end of loop over tracks return StatusCode::SUCCESS; } //============================================================================= // Loop over tracks and look for matched MC particles //============================================================================= StatusCode PrDownstreamChecker::loopOverUpdatedSeeds() { // book the ntuple Tuples::Tuple ntuple = GaudiTupleAlg::nTuple("UpdatedSeedTracks","UpdatedSeedTracks", CLID_ColumnWiseTuple ); // Loop over tracks LHCb::Tracks* tracks = get<LHCb::Tracks>(m_Test_Container); n_in_evt = -1; //stuff for hit info std::vector<double>x1_linehit_mc_x,x1_linehit_mc_y; std::vector<double>presel_track_at_x1_mc_x, presel_track_at_x1_mc_y; std::vector<double>final_track_at_x1_mc_x, final_track_at_x1_mc_y; std::vector<double>x1_truth_mc_x, x1_truth_mc_y,x1_truth_mc_z; std::vector<double>u_linehit_mc_x,u_linehit_mc_y; std::vector<double>presel_track_at_u_mc_x, presel_track_at_u_mc_y; std::vector<double>final_track_at_u_mc_x, final_track_at_u_mc_y; std::vector<double>u_truth_mc_x, u_truth_mc_y,u_truth_mc_z; std::vector<double>v_linehit_mc_x,v_linehit_mc_y; std::vector<double>presel_track_at_v_mc_x, presel_track_at_v_mc_y; std::vector<double>final_track_at_v_mc_x, final_track_at_v_mc_y; std::vector<double>v_truth_mc_x, v_truth_mc_y,v_truth_mc_z; std::vector<double>x2_linehit_mc_x,x2_linehit_mc_y; std::vector<double>presel_track_at_x2_mc_x, presel_track_at_x2_mc_y; std::vector<double>final_track_at_x2_mc_x, final_track_at_x2_mc_y; std::vector<double>x2_truth_mc_x, x2_truth_mc_y,x2_truth_mc_z; //final track candid hits std::vector<double>x1_linehit_final_candid_x,x1_linehit_final_candid_y; std::vector<double>presel_track_at_x1_final_candid_x, presel_track_at_x1_final_candid_y; std::vector<double>final_track_at_x1_final_candid_x, final_track_at_x1_final_candid_y; std::vector<double>x1_truth_final_candid_x, x1_truth_final_candid_y; std::vector<double>u_linehit_final_candid_x,u_linehit_final_candid_y; std::vector<double>presel_track_at_u_final_candid_x, presel_track_at_u_final_candid_y; std::vector<double>final_track_at_u_final_candid_x, final_track_at_u_final_candid_y; std::vector<double>u_truth_final_candid_x, u_truth_final_candid_y; std::vector<double>v_linehit_final_candid_x,v_linehit_final_candid_y; std::vector<double>presel_track_at_v_final_candid_x, presel_track_at_v_final_candid_y; std::vector<double>final_track_at_v_final_candid_x, final_track_at_v_final_candid_y; std::vector<double>v_truth_final_candid_x, v_truth_final_candid_y; std::vector<double>x2_linehit_final_candid_x,x2_linehit_final_candid_y; std::vector<double>presel_track_at_x2_final_candid_x, presel_track_at_x2_final_candid_y; std::vector<double>final_track_at_x2_final_candid_x, final_track_at_x2_final_candid_y; std::vector<double>x2_truth_final_candid_x, x2_truth_final_candid_y; //hacked state params std::vector<double>hacked_state_x, hacked_state_y, hacked_state_tx,hacked_state_ty;//,hacked_state_qop; hacked_state_x.reserve(20);hacked_state_y.reserve(20); hacked_state_tx.reserve(20);hacked_state_ty.reserve(20); //hack zpostUT std::vector<double>hacked_state_zpUT_x, hacked_state_zpUT_y, hacked_state_zpUT_tx,hacked_state_zpUT_ty;//,hacked_state_zpUT_qop; hacked_state_zpUT_x.reserve(20);hacked_state_zpUT_y.reserve(20); hacked_state_zpUT_tx.reserve(20);hacked_state_zpUT_ty.reserve(20); //hack endvelo std::vector<double>hacked_EndVelo_state_x, hacked_EndVelo_state_y, hacked_EndVelo_state_tx,hacked_EndVelo_state_ty;//,hacked_EndVelo_state_qop; hacked_EndVelo_state_x.reserve(20);hacked_EndVelo_state_y.reserve(20); hacked_EndVelo_state_tx.reserve(20);hacked_EndVelo_state_ty.reserve(20); // hack midTT std::vector<double>hacked_midTT_state_x, hacked_midTT_state_y, hacked_midTT_state_tx,hacked_midTT_state_ty;//,hacked_midTT_state_qop; hacked_midTT_state_x.reserve(20);hacked_midTT_state_y.reserve(20); hacked_midTT_state_tx.reserve(20);hacked_midTT_state_ty.reserve(20); //begin T std::vector<double>hacked_begT_state_x, hacked_begT_state_y, hacked_begT_state_tx,hacked_begT_state_ty;//,hacked_begT_state_qop; hacked_begT_state_x.reserve(20);hacked_begT_state_y.reserve(20); hacked_begT_state_tx.reserve(20);hacked_begT_state_ty.reserve(20); x1_linehit_mc_x.reserve(20);x1_linehit_mc_y.reserve(20); presel_track_at_x1_mc_x.reserve(20); presel_track_at_x1_mc_y.reserve(20); final_track_at_x1_mc_x.reserve(20); final_track_at_x1_mc_y.reserve(20); x1_truth_mc_x.reserve(20); x1_truth_mc_y.reserve(20);x1_truth_mc_z.reserve(20); u_linehit_mc_x.reserve(20);u_linehit_mc_y.reserve(20); presel_track_at_u_mc_x.reserve(20); presel_track_at_u_mc_y.reserve(20); final_track_at_u_mc_x.reserve(20); final_track_at_u_mc_y.reserve(20); u_truth_mc_x.reserve(20); u_truth_mc_y.reserve(20);u_truth_mc_z.reserve(20); v_linehit_mc_x.reserve(20);v_linehit_mc_y.reserve(20); presel_track_at_v_mc_x.reserve(20); presel_track_at_v_mc_y.reserve(20); final_track_at_v_mc_x.reserve(20); final_track_at_v_mc_y.reserve(20); v_truth_mc_x.reserve(20); v_truth_mc_y.reserve(20);v_truth_mc_z.reserve(20); x2_linehit_mc_x.reserve(20);x2_linehit_mc_y.reserve(20); presel_track_at_x2_mc_x.reserve(20); presel_track_at_x2_mc_y.reserve(20); final_track_at_x2_mc_x.reserve(20); final_track_at_x2_mc_y.reserve(20); x2_truth_mc_x.reserve(20); x2_truth_mc_y.reserve(20);x2_truth_mc_z.reserve(20); //final track candid hits x1_linehit_final_candid_x.reserve(20);x1_linehit_final_candid_y.reserve(20); presel_track_at_x1_final_candid_x.reserve(20); presel_track_at_x1_final_candid_y.reserve(20); final_track_at_x1_final_candid_x.reserve(20); final_track_at_x1_final_candid_y.reserve(20); x1_truth_final_candid_x.reserve(20); x1_truth_final_candid_y.reserve(20); u_linehit_final_candid_x.reserve(20);u_linehit_final_candid_y.reserve(20); presel_track_at_u_final_candid_x.reserve(20); presel_track_at_u_final_candid_y.reserve(20); final_track_at_u_final_candid_x.reserve(20); final_track_at_u_final_candid_y.reserve(20); u_truth_final_candid_x.reserve(20); u_truth_final_candid_y.reserve(20); v_linehit_final_candid_x.reserve(20);v_linehit_final_candid_y.reserve(20); presel_track_at_v_final_candid_x.reserve(20); presel_track_at_v_final_candid_y.reserve(20); final_track_at_v_final_candid_x.reserve(20); final_track_at_v_final_candid_y.reserve(20); v_truth_final_candid_x.reserve(20); v_truth_final_candid_y.reserve(20); x2_linehit_final_candid_x.reserve(20);x2_linehit_final_candid_y.reserve(20); presel_track_at_x2_final_candid_x.reserve(20); presel_track_at_x2_final_candid_y.reserve(20); final_track_at_x2_final_candid_x.reserve(20); final_track_at_x2_final_candid_y.reserve(20); x2_truth_final_candid_x.reserve(20); x2_truth_final_candid_y.reserve(20); std::vector<double>new_chi2s;new_chi2s.reserve(100); std::vector<double>new_ndfs;new_ndfs.reserve(100); std::vector<int>new_chi2_is_mc_cand;new_chi2_is_mc_cand.reserve(100); //std::vector<int>new_chi2_is_matched_2_store;new_chi2_is_matched_2_store.reserve(100); for (LHCb::Tracks::const_iterator it = tracks->begin(); it!=tracks->end(); ++it) { n_in_evt++; fillTrack(*it,ntuple); /* //add nhits int ngood_before_x1(-2), ngood_before_u(-2),ngood_before_v(-2),ngood_before_x2(-2); int ntot_before_x1(-2), ntot_before_u(-2),ntot_before_v(-2),ntot_before_x2(-2); int ngood_after_x1(-2), ngood_after_u(-2),ngood_after_v(-2),ngood_after_x2(-2); int ntot_after_x1(-2), ntot_after_u(-2),ntot_after_v(-2),ntot_after_x2(-2); //end info added by AD ngood_before_x1=(*it)->info(1810,-1); ngood_before_u=(*it)->info(1811,-1); ngood_before_v=(*it)->info(1812,-1); ngood_before_x2=(*it)->info(1813,-1); ntot_before_x1=(*it)->info(1820,-1); ntot_before_u=(*it)->info(1821,-1); ntot_before_v=(*it)->info(1822,-1); ntot_before_x2=(*it)->info(1823,-1); ngood_after_x1=(*it)->info(1830,-1); ngood_after_u=(*it)->info(1831,-1); ngood_after_v=(*it)->info(1832,-1); ngood_after_x2=(*it)->info(1833,-1); ntot_after_x1=(*it)->info(1840,-1); ntot_after_u=(*it)->info(1841,-1); ntot_after_v=(*it)->info(1842,-1); ntot_after_x2=(*it)->info(1843,-1); debug()<<"added info val in prdownstreamchecker :"<<endmsg; debug()<<"ngood_before_x1 = "<<ngood_before_x1<<endmsg; debug()<<"ngood_before_u = "<<ngood_before_u<<endmsg; debug()<<"ngood_before_v = "<<ngood_before_v<<endmsg; debug()<<"ngood_before_x2 = "<<ngood_before_x2<<endmsg; debug()<<"ntot_before_x1 = "<<ntot_before_x1<<endmsg; debug()<<"ntot_before_u = "<<ntot_before_u<<endmsg; debug()<<"ntot_before_v = "<<ntot_before_v<<endmsg; debug()<<"ntot_before_x2 = "<<ntot_before_x2<<endmsg; debug()<<"ngood_after_x1 = "<<ngood_after_x1<<endmsg; debug()<<"ngood_after_u = "<<ngood_after_u<<endmsg; debug()<<"ngood_after_v = "<<ngood_after_v<<endmsg; debug()<<"ngood_after_x2 = "<<ngood_after_x2<<endmsg; debug()<<"ntot_after_x1 = "<<ntot_after_x1<<endmsg; debug()<<"ntot_after_u = "<<ntot_after_u<<endmsg; debug()<<"ntot_after_v = "<<ntot_after_v<<endmsg; debug()<<"ntot_after_x2 = "<<ntot_after_x2<<endmsg; ntuple->column("beforeFAR_good_x1",ngood_before_x1); ntuple->column("beforeFAR_good_u",ngood_before_u); ntuple->column("beforeFAR_good_v",ngood_before_v); ntuple->column("beforeFAR_good_x2",ngood_before_x2); ntuple->column("beforeFAR_total_x1",ntot_before_x1); ntuple->column("beforeFAR_total_u",ntot_before_u); ntuple->column("beforeFAR_total_v",ntot_before_v); ntuple->column("beforeFAR_total_x2",ntot_before_x2); ntuple->column("afterFAR_good_x1",ngood_after_x1); ntuple->column("afterFAR_good_u",ngood_after_u); ntuple->column("afterFAR_good_v",ngood_after_v); ntuple->column("afterFAR_good_x2",ngood_after_x2); ntuple->column("afterFAR_total_x1",ntot_after_x1); ntuple->column("afterFAR_total_u",ntot_after_u); ntuple->column("afterFAR_total_v",ntot_after_v); ntuple->column("afterFAR_total_x2",ntot_after_x2); */ //added AD 1-29-14 ntuple->column("n_DSCandidates_per_seed",(*it)->info(2000,-1)); ntuple->column("presel_count",(*it)->info(2001,-1)); ntuple->column("candid_nhits",(*it)->info(2002,-1)); ntuple->column("n_Replaced_3hits",(*it)->info(2003,-1)); ntuple->column("n_Replaced_4hits",(*it)->info(2004,-1)); ntuple->column("n_Replaced_5ormore_hits",(*it)->info(2005,-1)); ntuple->column("n_mc_clones",(*it)->info(2006,-1)); ntuple->column("mean_ghost_chi2",(*it)->info(2007,-1.) ); ntuple->column("best_ghost_chi2",(*it)->info(2008,-1.) ); ntuple->column("n_hits_best_ghost", (*it)->info(2009,-1) ); ntuple->column("best_mc_chi2", (*it)->info(2010,-1.) ); ntuple->column("presel_forward_match_x", (*it)->info(2011,-1.) ); ntuple->column("presel_forward_match_uv", (*it)->info(2012,-1.) ); ntuple->column("candid_forward_match_x", (*it)->info(2013,-1.) ); ntuple->column("candid_forward_match_uv", (*it)->info(2014,-1.) ); //m_directTable_seed AsctTool::DirectType::Range range = m_directTable_updatedseed->relations(*it); bool ghost = range.empty(); const LHCb::MCParticle* particle(0); if (!ghost) { particle = range.begin()->to(); if( particle && particle->particleID().threeCharge()==0 ) { particle = 0; } } /* MCTrackInfo trackInfo( evtSvc(), msgSvc() ); // information for the tuple // bool reconstructible_asLong(false); bool B_child(false); bool D_child(false); bool isLong(false); bool isDown(false); bool isInVelo(false); bool over5(false); int parentABSID = -999;//add to MC partcilefill. AD 1-12-14 //int nHits = -999; int has_all_info(-1); if(particle){ //need to make sure we have full track info. has_all_info = trackInfo.fullInfo( particle ); */ /*reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,particle);*/ /* isLong = trackInfo.hasVeloAndT( particle ); isDown = trackInfo.hasT( particle ) && trackInfo.hasTT( particle ); over5 = 5000. < fabs( (particle)->p() ); isInVelo = trackInfo.hasVelo( particle ); if ( 0 != (particle)->originVertex() ) { const LHCb::MCParticle* mother = (particle)->originVertex()->mother(); if ( 0 != mother ) { if ( 0 != mother->originVertex() ) { //double rOrigin = mother->originVertex()->position().rho(); parentABSID = abs( mother->particleID().pid() ); } } } if(bAncestor(particle)){ B_child = true; } if(dAncestor(particle)){ D_child = true; } } /// good candidate /// fill the tuple with MC information ntuple->column("parentABSID", parentABSID); ntuple->column("fullInfo", has_all_info); // ntuple->column("reconstructible_asLong", reconstructible_asLong); ntuple->column("isLong", isLong); ntuple->column("isDown", isDown); ntuple->column("over5", over5); ntuple->column("isInVelo", isInVelo); ntuple->column("B_child", B_child); ntuple->column("D_child", D_child); */ fillMCParticle(particle,ntuple); /* bool reconstructible_asLong(false); reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,particle); ntuple->column("reconstructible_asLong", reconstructible_asLong); */ ///this is now in the fill MC particle. AD 1-15-14 bool reconstructible_asDown(false); reconstructible_asDown = m_selector->isReconstructibleAs(IMCReconstructible::ChargedDownstream,particle); ntuple->column("reconstructible_asDown",reconstructible_asDown);//AD 1-10-14 LHCb::Track* seedTr = new LHCb::Track; LHCb::Track* seedUTTr = *it; SmartRefVector<LHCb::Track>& ancestor = seedUTTr->ancestors(); for( SmartRefVector<LHCb::Track>::iterator trIt = ancestor.begin(); ancestor.end() != trIt; trIt++) { seedTr = *trIt; } AsctTool::DirectType::Range range_seed = m_directTable_updatedseed->relations(seedTr); bool ghost_seed = range_seed.empty(); ntuple->column("ghost_seed", ghost_seed); //add reconstructible seed AsctTool::InverseType::Range range_inv = m_inverseTable_updatedseed->relations(particle); bool reconstructed_seed = !(range_inv.empty()); ntuple->column("reconstructed_seed",reconstructed_seed); //get all the info we added about the residuals //ntuple->column("n_x1_mc_hits", (*it)->info(2100,-999.)); int nx1_mc = (*it)->info(21000,-999); int nu_mc = (*it)->info(22000,-999); int nv_mc = (*it)->info(23000,-999); int nx2_mc = (*it)->info(24000,-999); int nx1_final_candid = (*it)->info(31000,-999); int nu_final_candid = (*it)->info(32000,-999); int nv_final_candid = (*it)->info(33000,-999); int nx2_final_candid = (*it)->info(34000,-999); //initialize all the std::vectors we need. //mc hits hacked_state_x.clear();hacked_state_y.clear(); hacked_state_tx.clear();hacked_state_ty.clear(); hacked_state_zpUT_x.clear();hacked_state_zpUT_y.clear(); hacked_state_zpUT_tx.clear();hacked_state_zpUT_ty.clear(); hacked_EndVelo_state_x.clear();hacked_EndVelo_state_y.clear(); hacked_EndVelo_state_tx.clear();hacked_EndVelo_state_ty.clear(); hacked_midTT_state_x.clear();hacked_midTT_state_y.clear(); hacked_midTT_state_tx.clear();hacked_midTT_state_ty.clear(); hacked_begT_state_x.clear();hacked_begT_state_y.clear(); hacked_begT_state_tx.clear();hacked_begT_state_ty.clear(); x1_linehit_mc_x.clear();x1_linehit_mc_y.clear(); presel_track_at_x1_mc_x.clear();presel_track_at_x1_mc_y.clear(); final_track_at_x1_mc_x.clear(); final_track_at_x1_mc_y.clear(); x1_truth_mc_x.clear(); x1_truth_mc_y.clear();x1_truth_mc_z.clear(); u_linehit_mc_x.clear();u_linehit_mc_y.clear(); presel_track_at_u_mc_x.clear();presel_track_at_u_mc_y.clear(); final_track_at_u_mc_x.clear();final_track_at_u_mc_y.clear(); u_truth_mc_x.clear();u_truth_mc_y.clear();u_truth_mc_z.clear(); v_linehit_mc_x.clear();v_linehit_mc_y.clear(); presel_track_at_v_mc_x.clear();presel_track_at_v_mc_y.clear(); final_track_at_v_mc_x.clear();final_track_at_v_mc_y.clear(); v_truth_mc_x.clear();v_truth_mc_y.clear();v_truth_mc_z.clear(); x2_linehit_mc_x.clear();x2_linehit_mc_y.clear(); presel_track_at_x2_mc_x.clear();presel_track_at_x2_mc_y.clear(); final_track_at_x2_mc_x.clear();final_track_at_x2_mc_y.clear(); x2_truth_mc_x.clear();x2_truth_mc_y.clear();x2_truth_mc_z.clear(); //final track candid hits x1_linehit_final_candid_x.clear();x1_linehit_final_candid_y.clear(); presel_track_at_x1_final_candid_x.clear();presel_track_at_x1_final_candid_y.clear(); final_track_at_x1_final_candid_x.clear();final_track_at_x1_final_candid_y.clear(); x1_truth_final_candid_x.clear();x1_truth_final_candid_y.clear(); u_linehit_final_candid_x.clear();u_linehit_final_candid_y.clear(); presel_track_at_u_final_candid_x.clear();presel_track_at_u_final_candid_y.clear(); final_track_at_u_final_candid_x.clear();final_track_at_u_final_candid_y.clear(); u_truth_final_candid_x.clear();u_truth_final_candid_y.clear(); v_linehit_final_candid_x.clear();v_linehit_final_candid_y.clear(); presel_track_at_v_final_candid_x.clear(); presel_track_at_v_final_candid_y.clear(); final_track_at_v_final_candid_x.clear();final_track_at_v_final_candid_y.clear(); v_truth_final_candid_x.clear();v_truth_final_candid_y.clear(); x2_linehit_final_candid_x.clear();x2_linehit_final_candid_y.clear(); presel_track_at_x2_final_candid_x.clear();presel_track_at_x2_final_candid_y.clear(); final_track_at_x2_final_candid_x.clear();final_track_at_x2_final_candid_y.clear(); x2_truth_final_candid_x.clear();x2_truth_final_candid_y.clear(); new_chi2s.clear(); new_ndfs.clear(); new_chi2_is_mc_cand.clear(); //new_chi2_is_matched_2_store.clear(); /* std::vector<double>x1_linehit_mc_x,x1_linehit_mc_y; std::vector<double>presel_track_at_x1_mc_x, presel_track_at_x1_mc_y; std::vector<double>final_track_at_x1_mc_x, final_track_at_x1_mc_y; std::vector<double>x1_truth_mc_x, x1_truth_mc_y; std::vector<double>u_linehit_mc_x,u_linehit_mc_y; std::vector<double>presel_track_at_u_mc_x, presel_track_at_u_mc_y; std::vector<double>final_track_at_u_mc_x, final_track_at_u_mc_y; std::vector<double>u_truth_mc_x, u_truth_mc_y; std::vector<double>v_linehit_mc_x,v_linehit_mc_y; std::vector<double>presel_track_at_v_mc_x, presel_track_at_v_mc_y; std::vector<double>final_track_at_v_mc_x, final_track_at_v_mc_y; std::vector<double>v_truth_mc_x, v_truth_mc_y; std::vector<double>x2_linehit_mc_x,x2_linehit_mc_y; std::vector<double>presel_track_at_x2_mc_x, presel_track_at_x2_mc_y; std::vector<double>final_track_at_x2_mc_x, final_track_at_x2_mc_y; std::vector<double>x2_truth_mc_x, x2_truth_mc_y; //final track candid hits std::vector<double>x1_linehit_final_candid_x,x1_linehit_final_candid_y; std::vector<double>presel_track_at_x1_final_candid_x, presel_track_at_x1_final_candid_y; std::vector<double>final_track_at_x1_final_candid_x, final_track_at_x1_final_candid_y; std::vector<double>x1_truth_final_candid_x, x1_truth_final_candid_y; std::vector<double>u_linehit_final_candid_x,u_linehit_final_candid_y; std::vector<double>presel_track_at_u_final_candid_x, presel_track_at_u_final_candid_y; std::vector<double>final_track_at_u_final_candid_x, final_track_at_u_final_candid_y; std::vector<double>u_truth_final_candid_x, u_truth_final_candid_y; std::vector<double>v_linehit_final_candid_x,v_linehit_final_candid_y; std::vector<double>presel_track_at_v_final_candid_x, presel_track_at_v_final_candid_y; std::vector<double>final_track_at_v_final_candid_x, final_track_at_v_final_candid_y; std::vector<double>v_truth_final_candid_x, v_truth_final_candid_y; std::vector<double>x2_linehit_final_candid_x,x2_linehit_final_candid_y; std::vector<double>presel_track_at_x2_final_candid_x, presel_track_at_x2_final_candid_y; std::vector<double>final_track_at_x2_final_candid_x, final_track_at_x2_final_candid_y; std::vector<double>x2_truth_final_candid_x, x2_truth_final_candid_y; */ //get all the extra info about the track and the hits from the extra info //AD 5-10-14 int nhit_info = 21000; for(int i=0; i<nx1_mc;++i){ nhit_info++; x1_linehit_mc_x.push_back((*it)->info(nhit_info,-999)); x1_linehit_mc_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_x1_mc_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_x1_mc_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_x1_mc_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_x1_mc_y.push_back((*it)->info(nhit_info+100,-999)); x1_truth_mc_x.push_back((*it)->info(nhit_info+120, -999)); x1_truth_mc_y.push_back((*it)->info(nhit_info+140, -999)); x1_truth_mc_z.push_back((*it)->info(nhit_info+160, -999)); //hacked state hacked_state_x.push_back((*it)->info(nhit_info+20000, -999)); hacked_state_y.push_back((*it)->info(nhit_info+20020, -999)); hacked_state_tx.push_back((*it)->info(nhit_info+20040, -999)); hacked_state_ty.push_back((*it)->info(nhit_info+20060, -999)); hacked_state_zpUT_x.push_back((*it)->info(nhit_info+20400, -999)); hacked_state_zpUT_y.push_back((*it)->info(nhit_info+20420, -999)); hacked_state_zpUT_tx.push_back((*it)->info(nhit_info+20440, -999)); hacked_state_zpUT_ty.push_back((*it)->info(nhit_info+20460, -999)); hacked_EndVelo_state_x.push_back((*it)->info(nhit_info+20100, -999)); hacked_EndVelo_state_y.push_back((*it)->info(nhit_info+20120, -999)); hacked_EndVelo_state_tx.push_back((*it)->info(nhit_info+20140, -999)); hacked_EndVelo_state_ty.push_back((*it)->info(nhit_info+20160, -999)); hacked_midTT_state_x.push_back((*it)->info(nhit_info+20200, -999)); hacked_midTT_state_y.push_back((*it)->info(nhit_info+20220, -999)); hacked_midTT_state_tx.push_back((*it)->info(nhit_info+20240, -999)); hacked_midTT_state_ty.push_back((*it)->info(nhit_info+20260, -999)); hacked_begT_state_x.push_back((*it)->info(nhit_info+20300, -999)); hacked_begT_state_y.push_back((*it)->info(nhit_info+20320, -999)); hacked_begT_state_tx.push_back((*it)->info(nhit_info+20340, -999)); hacked_begT_state_ty.push_back((*it)->info(nhit_info+20360, -999)); // hacked_state_qop.push_back((*it)->info(nhit_info+20080, -999)); /*info()<<"Got hacked state params"<<endmsg <<"x = "<<(*it)->info(nhit_info+20000, -999)<<endmsg <<"y = "<<(*it)->info(nhit_info+20020, -999)<<endmsg <<"tx = "<<(*it)->info(nhit_info+20040, -999)<<endmsg <<"ty = "<<(*it)->info(nhit_info+20060, -999)<<endmsg <<"qop = "<<(*it)->info(nhit_info+20080, -999)<<endmsg; */ } //u nhit_info=22000; for(int i=0; i<nu_mc;++i){ nhit_info++; u_linehit_mc_x.push_back((*it)->info(nhit_info,-999)); u_linehit_mc_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_u_mc_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_u_mc_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_u_mc_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_u_mc_y.push_back((*it)->info(nhit_info+100,-999)); u_truth_mc_x.push_back((*it)->info(nhit_info+120, -999)); u_truth_mc_y.push_back((*it)->info(nhit_info+140, -999)); u_truth_mc_z.push_back((*it)->info(nhit_info+160, -999)); } //v nhit_info=23000; for(int i=0; i<nv_mc;++i){ nhit_info++; v_linehit_mc_x.push_back((*it)->info(nhit_info,-999)); v_linehit_mc_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_v_mc_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_v_mc_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_v_mc_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_v_mc_y.push_back((*it)->info(nhit_info+100,-999)); v_truth_mc_x.push_back((*it)->info(nhit_info+120, -999)); v_truth_mc_y.push_back((*it)->info(nhit_info+140, -999)); v_truth_mc_z.push_back((*it)->info(nhit_info+160, -999)); } //x2 nhit_info=24000; for(int i=0; i<nx2_mc;++i){ nhit_info++; x2_linehit_mc_x.push_back((*it)->info(nhit_info,-999)); x2_linehit_mc_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_x2_mc_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_x2_mc_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_x2_mc_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_x2_mc_y.push_back((*it)->info(nhit_info+100,-999)); x2_truth_mc_x.push_back((*it)->info(nhit_info+120, -999)); x2_truth_mc_y.push_back((*it)->info(nhit_info+140, -999)); x2_truth_mc_z.push_back((*it)->info(nhit_info+160, -999)); } //final track nhit_info = 31000; for(int i=0; i<nx1_final_candid;++i){ nhit_info++; x1_linehit_final_candid_x.push_back((*it)->info(nhit_info,-999)); x1_linehit_final_candid_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_x1_final_candid_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_x1_final_candid_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_x1_final_candid_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_x1_final_candid_y.push_back((*it)->info(nhit_info+100,-999)); x1_truth_final_candid_x.push_back((*it)->info(nhit_info+120, -999)); x1_truth_final_candid_y.push_back((*it)->info(nhit_info+140, -999)); } //u nhit_info=32000; for(int i=0; i<nu_final_candid;++i){ nhit_info++; u_linehit_final_candid_x.push_back((*it)->info(nhit_info,-999)); u_linehit_final_candid_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_u_final_candid_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_u_final_candid_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_u_final_candid_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_u_final_candid_y.push_back((*it)->info(nhit_info+100,-999)); u_truth_final_candid_x.push_back((*it)->info(nhit_info+120, -999)); u_truth_final_candid_y.push_back((*it)->info(nhit_info+140, -999)); } //v nhit_info=33000; for(int i=0; i<nv_final_candid;++i){ nhit_info++; v_linehit_final_candid_x.push_back((*it)->info(nhit_info,-999)); v_linehit_final_candid_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_v_final_candid_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_v_final_candid_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_v_final_candid_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_v_final_candid_y.push_back((*it)->info(nhit_info+100,-999)); v_truth_final_candid_x.push_back((*it)->info(nhit_info+120, -999)); v_truth_final_candid_y.push_back((*it)->info(nhit_info+140, -999)); } //x2 nhit_info=34000; for(int i=0; i<nx2_final_candid;++i){ nhit_info++; x2_linehit_final_candid_x.push_back((*it)->info(nhit_info,-999)); x2_linehit_final_candid_y.push_back((*it)->info(nhit_info+20,-999)); presel_track_at_x2_final_candid_x.push_back((*it)->info(nhit_info+40,-999)); presel_track_at_x2_final_candid_y.push_back((*it)->info(nhit_info+60,-999)); final_track_at_x2_final_candid_x.push_back((*it)->info(nhit_info+80,-999)); final_track_at_x2_final_candid_y.push_back((*it)->info(nhit_info+100,-999)); x2_truth_final_candid_x.push_back((*it)->info(nhit_info+120, -999)); x2_truth_final_candid_y.push_back((*it)->info(nhit_info+140, -999)); } //tuple x1 MC hits ntuple->farray("x1_linehit_mc_x",x1_linehit_mc_x.begin(),x1_linehit_mc_x.end(),"n_x1_mc_hits",20); ntuple->farray("x1_linehit_mc_y",x1_linehit_mc_y.begin(),x1_linehit_mc_y.end(),"n_x1_mc_hits",20); ntuple->farray("presel_track_at_x1_mc_x",presel_track_at_x1_mc_x.begin(),presel_track_at_x1_mc_x.end(),"n_x1_mc_hits",20); ntuple->farray("presel_track_at_x1_mc_y",presel_track_at_x1_mc_y.begin(),presel_track_at_x1_mc_y.end(),"n_x1_mc_hits",20); ntuple->farray("final_track_at_x1_mc_x",final_track_at_x1_mc_x.begin(),final_track_at_x1_mc_x.end(),"n_x1_mc_hits",20); ntuple->farray("final_track_at_x1_mc_y",final_track_at_x1_mc_y.begin(),final_track_at_x1_mc_y.end(),"n_x1_mc_hits",20); ntuple->farray("x1_truth_mc_x",x1_truth_mc_x.begin(),x1_truth_mc_x.end(),"n_x1_mc_hits",20); ntuple->farray("x1_truth_mc_y", x1_truth_mc_y.begin(), x1_truth_mc_y.end(),"n_x1_mc_hits",20); ntuple->farray("x1_truth_mc_z", x1_truth_mc_z.begin(), x1_truth_mc_z.end(),"n_x1_mc_hits",20); //u ntuple->farray("u_linehit_mc_x",u_linehit_mc_x.begin(),u_linehit_mc_x.end(),"n_u_mc_hits",20); ntuple->farray("u_linehit_mc_y",u_linehit_mc_y.begin(),u_linehit_mc_y.end(),"n_u_mc_hits",20); ntuple->farray("presel_track_at_u_mc_x",presel_track_at_u_mc_x.begin(),presel_track_at_u_mc_x.end(),"n_u_mc_hits",20); ntuple->farray("presel_track_at_u_mc_y",presel_track_at_u_mc_y.begin(),presel_track_at_u_mc_y.end(),"n_u_mc_hits",20); ntuple->farray("final_track_at_u_mc_x",final_track_at_u_mc_x.begin(),final_track_at_u_mc_x.end(),"n_u_mc_hits",20); ntuple->farray("final_track_at_u_mc_y",final_track_at_u_mc_y.begin(),final_track_at_u_mc_y.end(),"n_u_mc_hits",20); ntuple->farray("u_truth_mc_x",u_truth_mc_x.begin(),u_truth_mc_x.end(),"n_u_mc_hits",20); ntuple->farray("u_truth_mc_y", u_truth_mc_y.begin(), u_truth_mc_y.end(),"n_u_mc_hits",20); ntuple->farray("u_truth_mc_z", u_truth_mc_z.begin(), u_truth_mc_z.end(),"n_u_mc_hits",20); //v ntuple->farray("v_linehit_mc_x",v_linehit_mc_x.begin(),v_linehit_mc_x.end(),"n_v_mc_hits",20); ntuple->farray("v_linehit_mc_y",v_linehit_mc_y.begin(),v_linehit_mc_y.end(),"n_v_mc_hits",20); ntuple->farray("presel_track_at_v_mc_x",presel_track_at_v_mc_x.begin(),presel_track_at_v_mc_x.end(),"n_v_mc_hits",20); ntuple->farray("presel_track_at_v_mc_y",presel_track_at_v_mc_y.begin(),presel_track_at_v_mc_y.end(),"n_v_mc_hits",20); ntuple->farray("final_track_at_v_mc_x",final_track_at_v_mc_x.begin(),final_track_at_v_mc_x.end(),"n_v_mc_hits",20); ntuple->farray("final_track_at_v_mc_y",final_track_at_v_mc_y.begin(),final_track_at_v_mc_y.end(),"n_v_mc_hits",20); ntuple->farray("v_truth_mc_x",v_truth_mc_x.begin(),v_truth_mc_x.end(),"n_v_mc_hits",20); ntuple->farray("v_truth_mc_y", v_truth_mc_y.begin(), v_truth_mc_y.end(),"n_v_mc_hits",20); ntuple->farray("v_truth_mc_z", v_truth_mc_z.begin(), v_truth_mc_z.end(),"n_v_mc_hits",20); //x2 ntuple->farray("x2_linehit_mc_x",x2_linehit_mc_x.begin(),x2_linehit_mc_x.end(),"n_x2_mc_hits",20); ntuple->farray("x2_linehit_mc_y",x2_linehit_mc_y.begin(),x2_linehit_mc_y.end(),"n_x2_mc_hits",20); ntuple->farray("presel_track_at_x2_mc_x",presel_track_at_x2_mc_x.begin(),presel_track_at_x2_mc_x.end(),"n_x2_mc_hits",20); ntuple->farray("presel_track_at_x2_mc_y",presel_track_at_x2_mc_y.begin(),presel_track_at_x2_mc_y.end(),"n_x2_mc_hits",20); ntuple->farray("final_track_at_x2_mc_x",final_track_at_x2_mc_x.begin(),final_track_at_x2_mc_x.end(),"n_x2_mc_hits",20); ntuple->farray("final_track_at_x2_mc_y",final_track_at_x2_mc_y.begin(),final_track_at_x2_mc_y.end(),"n_x2_mc_hits",20); ntuple->farray("x2_truth_mc_x",x2_truth_mc_x.begin(),x2_truth_mc_x.end(),"n_x2_mc_hits",20); ntuple->farray("x2_truth_mc_y", x2_truth_mc_y.begin(), x2_truth_mc_y.end(),"n_x2_mc_hits",20); ntuple->farray("x2_truth_mc_z", x2_truth_mc_z.begin(), x2_truth_mc_z.end(),"n_x2_mc_hits",20); //tuple final hits ntuple->farray("x1_linehit_final_candid_x",x1_linehit_final_candid_x.begin(),x1_linehit_final_candid_x.end(),"n_x1_final_candid_hits",20); ntuple->farray("x1_linehit_final_candid_y",x1_linehit_final_candid_y.begin(),x1_linehit_final_candid_y.end(),"n_x1_final_candid_hits",20); ntuple->farray("presel_track_at_x1_final_candid_x",presel_track_at_x1_final_candid_x.begin(),presel_track_at_x1_final_candid_x.end(),"n_x1_final_candid_hits",20); ntuple->farray("presel_track_at_x1_final_candid_y",presel_track_at_x1_final_candid_y.begin(),presel_track_at_x1_final_candid_y.end(),"n_x1_final_candid_hits",20); ntuple->farray("final_track_at_x1_final_candid_x",final_track_at_x1_final_candid_x.begin(),final_track_at_x1_final_candid_x.end(),"n_x1_final_candid_hits",20); ntuple->farray("final_track_at_x1_final_candid_y",final_track_at_x1_final_candid_y.begin(),final_track_at_x1_final_candid_y.end(),"n_x1_final_candid_hits",20); ntuple->farray("x1_truth_final_candid_x",x1_truth_final_candid_x.begin(),x1_truth_final_candid_x.end(),"n_x1_final_candid_hits",20); ntuple->farray("x1_truth_final_candid_y", x1_truth_final_candid_y.begin(), x1_truth_final_candid_y.end(),"n_x1_final_candid_hits",20); //u ntuple->farray("u_linehit_final_candid_x",u_linehit_final_candid_x.begin(),u_linehit_final_candid_x.end(),"n_u_final_candid_hits",20); ntuple->farray("u_linehit_final_candid_y",u_linehit_final_candid_y.begin(),u_linehit_final_candid_y.end(),"n_u_final_candid_hits",20); ntuple->farray("presel_track_at_u_final_candid_x",presel_track_at_u_final_candid_x.begin(),presel_track_at_u_final_candid_x.end(),"n_u_final_candid_hits",20); ntuple->farray("presel_track_at_u_final_candid_y",presel_track_at_u_final_candid_y.begin(),presel_track_at_u_final_candid_y.end(),"n_u_final_candid_hits",20); ntuple->farray("final_track_at_u_final_candid_x",final_track_at_u_final_candid_x.begin(),final_track_at_u_final_candid_x.end(),"n_u_final_candid_hits",20); ntuple->farray("final_track_at_u_final_candid_y",final_track_at_u_final_candid_y.begin(),final_track_at_u_final_candid_y.end(),"n_u_final_candid_hits",20); ntuple->farray("u_truth_final_candid_x",u_truth_final_candid_x.begin(),u_truth_final_candid_x.end(),"n_u_final_candid_hits",20); ntuple->farray("u_truth_final_candid_y", u_truth_final_candid_y.begin(), u_truth_final_candid_y.end(),"n_u_final_candid_hits",20); //v ntuple->farray("v_linehit_final_candid_x",v_linehit_final_candid_x.begin(),v_linehit_final_candid_x.end(),"n_v_final_candid_hits",20); ntuple->farray("v_linehit_final_candid_y",v_linehit_final_candid_y.begin(),v_linehit_final_candid_y.end(),"n_v_final_candid_hits",20); ntuple->farray("presel_track_at_v_final_candid_x",presel_track_at_v_final_candid_x.begin(),presel_track_at_v_final_candid_x.end(),"n_v_final_candid_hits",20); ntuple->farray("presel_track_at_v_final_candid_y",presel_track_at_v_final_candid_y.begin(),presel_track_at_v_final_candid_y.end(),"n_v_final_candid_hits",20); ntuple->farray("final_track_at_v_final_candid_x",final_track_at_v_final_candid_x.begin(),final_track_at_v_final_candid_x.end(),"n_v_final_candid_hits",20); ntuple->farray("final_track_at_v_final_candid_y",final_track_at_v_final_candid_y.begin(),final_track_at_v_final_candid_y.end(),"n_v_final_candid_hits",20); ntuple->farray("v_truth_final_candid_x",v_truth_final_candid_x.begin(),v_truth_final_candid_x.end(),"n_v_final_candid_hits",20); ntuple->farray("v_truth_final_candid_y", v_truth_final_candid_y.begin(), v_truth_final_candid_y.end(),"n_v_final_candid_hits",20); //x2 ntuple->farray("x2_linehit_final_candid_x",x2_linehit_final_candid_x.begin(),x2_linehit_final_candid_x.end(),"n_x2_final_candid_hits",20); ntuple->farray("x2_linehit_final_candid_y",x2_linehit_final_candid_y.begin(),x2_linehit_final_candid_y.end(),"n_x2_final_candid_hits",20); ntuple->farray("presel_track_at_x2_final_candid_x",presel_track_at_x2_final_candid_x.begin(),presel_track_at_x2_final_candid_x.end(),"n_x2_final_candid_hits",20); ntuple->farray("presel_track_at_x2_final_candid_y",presel_track_at_x2_final_candid_y.begin(),presel_track_at_x2_final_candid_y.end(),"n_x2_final_candid_hits",20); ntuple->farray("final_track_at_x2_final_candid_x",final_track_at_x2_final_candid_x.begin(),final_track_at_x2_final_candid_x.end(),"n_x2_final_candid_hits",20); ntuple->farray("final_track_at_x2_final_candid_y",final_track_at_x2_final_candid_y.begin(),final_track_at_x2_final_candid_y.end(),"n_x2_final_candid_hits",20); ntuple->farray("x2_truth_final_candid_x",x2_truth_final_candid_x.begin(),x2_truth_final_candid_x.end(),"n_x2_final_candid_hits",20); ntuple->farray("x2_truth_final_candid_y", x2_truth_final_candid_y.begin(), x2_truth_final_candid_y.end(),"n_x2_final_candid_hits",20); //hacked state ntuple->farray("hacked_state_x",hacked_state_x.begin(), hacked_state_x.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_y",hacked_state_y.begin(), hacked_state_y.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_tx",hacked_state_tx.begin(), hacked_state_tx.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_ty",hacked_state_ty.begin(), hacked_state_ty.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_zpUT_x",hacked_state_zpUT_x.begin(), hacked_state_zpUT_x.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_zpUT_y",hacked_state_zpUT_y.begin(), hacked_state_zpUT_y.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_zpUT_tx",hacked_state_zpUT_tx.begin(), hacked_state_zpUT_tx.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_state_zpUT_ty",hacked_state_zpUT_ty.begin(), hacked_state_zpUT_ty.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_EndVelo_state_x",hacked_EndVelo_state_x.begin(), hacked_EndVelo_state_x.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_EndVelo_state_y",hacked_EndVelo_state_y.begin(), hacked_EndVelo_state_y.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_EndVelo_state_tx",hacked_EndVelo_state_tx.begin(), hacked_EndVelo_state_tx.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_EndVelo_state_ty",hacked_EndVelo_state_ty.begin(), hacked_EndVelo_state_ty.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_midTT_state_x",hacked_midTT_state_x.begin(), hacked_midTT_state_x.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_midTT_state_y",hacked_midTT_state_y.begin(), hacked_midTT_state_y.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_midTT_state_tx",hacked_midTT_state_tx.begin(), hacked_midTT_state_tx.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_midTT_state_ty",hacked_midTT_state_ty.begin(), hacked_midTT_state_ty.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_begT_state_x",hacked_begT_state_x.begin(), hacked_begT_state_x.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_begT_state_y",hacked_begT_state_y.begin(), hacked_begT_state_y.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_begT_state_tx",hacked_begT_state_tx.begin(), hacked_begT_state_tx.end(),"n_x1_mc_hits",20); ntuple->farray("hacked_begT_state_ty",hacked_begT_state_ty.begin(), hacked_begT_state_ty.end(),"n_x1_mc_hits",20); // ntuple->farray("hacked_state_qop",hacked_state_qop.begin(), hacked_state_qop.end(),"n_x1_mc_hits",20); //reference state at 2320 mm ntuple->column("ref_state_x",(*it)->info(35000,-999.)); ntuple->column("ref_state_y",(*it)->info(35001,-999.)); ntuple->column("ref_state_tx",(*it)->info(35002,-999.)); ntuple->column("ref_state_ty",(*it)->info(35003,-999.)); ntuple->column("ref_state_qop",(*it)->info(35004,-999.)); //new chi2 stuff debug()<<"starting chi2 check."<<endmsg; int size_of_track_candidates = (*it)->info(36000,-999.); if(size_of_track_candidates >100) { size_of_track_candidates=100;} debug()<<"size_of_track_candidates = "<<size_of_track_candidates<<endmsg; ntuple->column("n_track_candidates_considered",size_of_track_candidates); for(int i=1; i<size_of_track_candidates;++i){ debug()<<"i = "<<i<<endmsg; debug()<<"info 36000 + i = "<<(*it)->info(36000+i,-9999.)<<endmsg; if(i>100)continue; new_chi2s.push_back((*it)->info(36000+i,-9999.)); new_ndfs.push_back((*it)->info(36500+i,-9999.)); new_chi2_is_mc_cand.push_back((*it)->info(37000+i,-1)); //new_chi2_is_matched_2_store.push_back((*it)->info(38000+i,-1)); debug()<<"new_chi2s[i] = "<<new_chi2s[i]<<endmsg; } debug()<<"makking array"<<endmsg; ntuple->farray("new_chi2",new_chi2s.begin(), new_chi2s.end(),"size_of_track_candidates",100); ntuple->farray("new_ndf",new_ndfs.begin(), new_ndfs.end(),"size_of_track_candidates",100); ntuple->farray("new_chi2_is_good_mc_cand",new_chi2_is_mc_cand.begin(),new_chi2_is_mc_cand.end(), "size_of_track_candidates",100); //ntuple->farray("new_chi2_is_final_track",new_chi2_is_matched_2_store.begin(), new_chi2_is_matched_2_store.end(), // "size_of_track_candidates",100); debug()<<"array done"<<endmsg; ntuple->column("saved_track_new_chi2", (*it)->info(38000,-1.) ); ntuple->column("saved_track_new_ndf", (*it)->info(39000,-1.) ); ntuple->column("ft_begin_true_xmid",(*it)->info(99000,-99999.)); ntuple->column("ft_begin_true_ymid",(*it)->info(99001,-99999.)); ntuple->column("ft_begin_true_zmid",(*it)->info(99002,-99999.)); ntuple->column("ft_begin_true_tx",(*it)->info(99003,-99999.)); ntuple->column("ft_begin_true_ty",(*it)->info(99004,-99999.)); ntuple->column("ft_begin_true_qop",(*it)->info(99005,-99999.)); ntuple->column("ft_begin_true_entryx",(*it)->info(99006,-99999.)); ntuple->column("ft_begin_true_entryy",(*it)->info(99007,-99999.)); ntuple->column("ft_begin_true_entryz",(*it)->info(99008,-99999.)); //hack states. /* double true_endvelo_x(-9999.), true_endvelo_y(-9999.),true_endvelo_tx(-9999.), true_endvelo_ty(-9999.); double true_midUT_x(-9999.), true_midUT_y(-9999.),true_midUT_tx(-9999.), true_midUT_ty(-9999.); double true_ftstation_x(-9999.), true_ftstation_y(-9999.),true_ftstation_tx(-9999.), true_ftstation_ty(-9999.); //get states from PRDownstream as before //TODO. std::cout<<"true_endvelo_x = "<<true_endvelo_x<<std::endl; std::cout<<"true_endvelo_y = "<<true_endvelo_y<<std::endl; std::cout<<"true_endvelo_tx = "<<true_endvelo_tx<<std::endl; std::cout<<"true_endvelo_ty = "<<true_endvelo_ty<<std::endl; std::cout<<"true_midUT_x = "<<true_midUT_x<<std::endl; std::cout<<"true_midUT_y = "<<true_midUT_y<<std::endl; std::cout<<"true_midUT_tx = "<<true_midUT_tx<<std::endl; std::cout<<"true_midUT_ty = "<<true_midUT_ty<<std::endl; std::cout<<"true_ftstation_x = "<<true_ftstation_x<<std::endl; std::cout<<"true_ftstation_y = "<<true_ftstation_y<<std::endl; std::cout<<"true_ftstation_tx = "<<true_ftstation_tx<<std::endl; std::cout<<"true_ftstation_ty = "<<true_ftstation_ty<<std::endl; ntuple->column("true_endvelo_x",true_endvelo_x); ntuple->column("true_endvelo_y",true_endvelo_y); ntuple->column("true_endvelo_tx",true_endvelo_tx); ntuple->column("true_endvelo_ty",true_endvelo_ty); ntuple->column("true_midUT_x",true_midUT_x); ntuple->column("true_midUT_y",true_midUT_y); ntuple->column("true_midUT_tx",true_midUT_tx); ntuple->column("true_midUT_ty",true_midUT_ty); ntuple->column("true_ftstation_x",true_ftstation_x); ntuple->column("true_ftstation_y",true_ftstation_y); ntuple->column("true_ftstation_tx",true_ftstation_tx); ntuple->column("true_ftstation_ty",true_ftstation_ty); */ StatusCode sc = ntuple->write(); if (sc.isFailure()) return Error("Failed to fill the ntuple", /*StatusCode::FAILURE*/StatusCode::SUCCESS); }//end of loop over tracks return StatusCode::SUCCESS; } //============================================================================= // Fill ntuple with MC particle's information //============================================================================= void PrDownstreamChecker::fillMCParticle(const LHCb::MCParticle* p, Tuples::Tuple ntuple) { double true_p(-999.99), true_px(-999.99), true_py(-999.99), true_pz(-999.99),true_pt(-999.99); double true_theta(0),true_eta(0),true_phi(0); double true_x(-999.99), true_y(-999.99), true_z(-999.99); double true_tx(-999.99), true_ty(-999.99); bool ghost(true); int pdgcode(0), nUT_hits(0), nUT_layers(0); double true_qop(0.00); /* double true_endvelo_x(-9999.), true_endvelo_y(-9999.),true_endvelo_tx(-9999.), true_endvelo_ty(-9999.); double true_midUT_x(-9999.), true_midUT_y(-9999.),true_midUT_tx(-9999.), true_midUT_ty(-9999.); double true_ftstation_x(-9999.), true_ftstation_y(-9999.),true_ftstation_tx(-9999.), true_ftstation_ty(-9999.); */ //int parentABSID(-999); // information for the tuple. do it in fillmcparticle from 1-15-14 bool reconstructible_asLong(false); bool reconstructible_asDown(false); bool B_child(false); bool D_child(false); bool isLong(false); bool isDown(false); bool isInVelo(false); bool over5(false); int parentABSID = -999;//add to MC partcilefill. AD 1-12-14 int has_all_info(-1); MCTrackInfo trackInfos( evtSvc(), msgSvc() ); //int nHits = -999; //need to make sure we have full track info. // mc level quantities if (p) { ghost = false; true_p = p->p(); true_px = p->momentum().x(); true_py = p->momentum().y(); true_pz = p->momentum().z(); true_pt = p->pt(); true_theta = p->momentum().theta(); true_eta = p->momentum().Eta(); true_phi = p->momentum().Phi(); true_x = p->originVertex()->position4vector().x(); true_y = p->originVertex()->position4vector().y(); true_z = p->originVertex()->position4vector().z(); true_tx = p->momentum().x()/p->momentum().z(); true_ty = p->momentum().y()/p->momentum().z(); pdgcode = p->particleID().pid(); nUT_hits = getUT_hits(p); nUT_layers = getUT_layers(p); true_qop = (p->particleID().threeCharge()/3.0)/(p->p()); /* //fill some additional info on the state LHCb::State *state_end_velo,*state_midUT, *state_FT; m_stateCreator->createState(p,StateParameters::ZEndVelo,*state_end_velo); m_stateCreator->createState(p,StateParameters::ZMidTT,*state_midUT); m_stateCreator->createState(p,StateParameters::ZBegT,*state_FT); //here. Move this to another function. state_end_velo = IdealStateHacker(p,StateParameters::ZEndVelo); state_midUT=IdealStateHacker(p,StateParameters::ZMidTT); state_FT = IdealStateHacker(p,StateParameters::ZBegT); if(state_end_velo==NULL){ debug()<<"no end velo ideal state created"<<endmsg; } if(state_midUT==NULL){ debug()<<"no mid UT ideal state created"<<endmsg; } if(state_FT==NULL){ debug()<<"no FT ideal state created"<<endmsg; } true_endvelo_x =state_end_velo->x(); true_endvelo_y = state_end_velo->y(); true_endvelo_tx = state_end_velo->tx(); true_endvelo_ty = state_end_velo->ty(); true_midUT_x =state_midUT->x(); true_midUT_y = state_midUT->y(); true_midUT_tx = state_midUT->tx(); true_midUT_ty = state_midUT->ty(); true_ftstation_x =state_FT->x(); true_ftstation_y = state_FT->y(); true_ftstation_tx = state_FT->tx(); true_ftstation_ty = state_FT->ty(); std::cout<<"true_endvelo_x = "<<true_endvelo_x<<std::endl; std::cout<<"true_endvelo_y = "<<true_endvelo_y<<std::endl; std::cout<<"true_endvelo_tx = "<<true_endvelo_tx<<std::endl; std::cout<<"true_endvelo_ty = "<<true_endvelo_ty<<std::endl; std::cout<<"true_midUT_x = "<<true_midUT_x<<std::endl; std::cout<<"true_midUT_y = "<<true_midUT_y<<std::endl; std::cout<<"true_midUT_tx = "<<true_midUT_tx<<std::endl; std::cout<<"true_midUT_ty = "<<true_midUT_ty<<std::endl; std::cout<<"true_ftstation_x = "<<true_ftstation_x<<std::endl; std::cout<<"true_ftstation_y = "<<true_ftstation_y<<std::endl; std::cout<<"true_ftstation_tx = "<<true_ftstation_tx<<std::endl; std::cout<<"true_ftstation_ty = "<<true_ftstation_ty<<std::endl; */ //need to make sure we have full track info. has_all_info = trackInfos.fullInfo( p ); reconstructible_asLong = m_selector->isReconstructibleAs(IMCReconstructible::ChargedLong,p); reconstructible_asDown = m_selector->isReconstructibleAs(IMCReconstructible::ChargedDownstream,p); isLong = trackInfos.hasVeloAndT( p ); isDown = trackInfos.hasT( p ) && trackInfos.hasTT( p ); over5 = 5000. < fabs( (p)->p() ); isInVelo = trackInfos.hasVelo( p ); if ( 0 != (p)->originVertex() ) { const LHCb::MCParticle* mother = (p)->originVertex()->mother(); if ( 0 != mother ) { if ( 0 != mother->originVertex() ) { //double rOrigin = mother->originVertex()->position().rho(); parentABSID = abs( mother->particleID().pid() ); } } } if(bAncestor(p)){ B_child = true; } if(dAncestor(p)){ D_child = true; } } ntuple->column("evt", evt); ntuple->column("n_in_evt", n_in_evt); ntuple->column("ghost", ghost); ntuple->column("pdgcode", pdgcode); ntuple->column("true_p", true_p); ntuple->column("true_px", true_px); ntuple->column("true_py", true_py); ntuple->column("true_pz", true_pz); ntuple->column("true_pt", true_pt); ntuple->column("true_theta", true_theta); ntuple->column("true_eta", true_eta); ntuple->column("true_phi", true_phi); ntuple->column("true_x", true_x); ntuple->column("true_y", true_y); ntuple->column("true_z", true_z); ntuple->column("true_tx", true_tx); ntuple->column("true_ty", true_ty); ntuple->column("true_nUT_hits", nUT_hits); ntuple->column("true_nUT_layers", nUT_layers); ntuple->column("true_qop", true_qop); ntuple->column("parentABSID", parentABSID); ntuple->column("fullInfo", has_all_info); ntuple->column("reconstructible_asLong", reconstructible_asLong); ntuple->column("isLong", isLong); ntuple->column("isDown", isDown); ntuple->column("over5", over5); ntuple->column("isInVelo", isInVelo); ntuple->column("B_child", B_child); ntuple->column("D_child", D_child); /* ntuple->column("true_endvelo_x",true_endvelo_x); ntuple->column("true_endvelo_y",true_endvelo_y); ntuple->column("true_endvelo_tx",true_endvelo_tx); ntuple->column("true_endvelo_ty",true_endvelo_ty); ntuple->column("true_midUT_x",true_midUT_x); ntuple->column("true_midUT_y",true_midUT_y); ntuple->column("true_midUT_tx",true_midUT_tx); ntuple->column("true_midUT_ty",true_midUT_ty); ntuple->column("true_ftstation_x",true_ftstation_x); ntuple->column("true_ftstation_y",true_ftstation_y); ntuple->column("true_ftstation_tx",true_ftstation_tx); ntuple->column("true_ftstation_ty",true_ftstation_ty); */ } //============================================================================= // Get MC TT hist for particle p //============================================================================= int PrDownstreamChecker::getUT_layers(const LHCb::MCParticle* p) const { LinkedFrom<LHCb::STCluster,LHCb::MCParticle> ttLink(evtSvc(),msgSvc(), LHCb::STClusterLocation::UTClusters); if (ttLink.notFound()) { return 0; } int nhits = 0; std::vector<int> fired; const LHCb::STCluster* TTCluster = ttLink.first(p); for ( ; 0 != TTCluster; TTCluster = ttLink.next()) { if ( !TTCluster->isUT() ) continue; nhits++; int layer = TTCluster->layer() + 10*TTCluster->station(); if ( fired.empty() || std::find(fired.begin(), fired.end(), layer) == fired.end() ) fired.push_back(layer); } int nlayers = fired.size(); return nlayers; } //============================================================================= // Get MC TT hist for particle p //============================================================================= int PrDownstreamChecker::getUT_hits(const LHCb::MCParticle* p) const { LinkedFrom<LHCb::STCluster,LHCb::MCParticle> ttLink(evtSvc(),msgSvc(), LHCb::STClusterLocation::UTClusters); if (ttLink.notFound()){ return 0; } int nhits = 0; std::vector<int> fired; const LHCb::STCluster* TTCluster = ttLink.first(p); for ( ; 0 != TTCluster; TTCluster = ttLink.next()) { if ( !TTCluster->isUT() ) continue; nhits++; } /*unsigned int station() const; /// shortcut for layer unsigned int layer() const; /// short cut for detRegion unsigned int detRegion() const; /// short cut for sector unsigned int sector() const; /// short cut for strip unsigned int strip() const; */ return nhits; } //============================================================================= // Look if particle mcPart comes from a b-hadron decay //============================================================================= bool PrDownstreamChecker::bAncestor(const LHCb::MCParticle* mcPart) const { bool fromB = false; const LHCb::MCParticle* mother = mcPart->mother(); while ( mother !=0 && fromB == false) { fromB = mother->particleID().hasBottom(); mother = mother->mother(); } return fromB; } //============================================================================= // Fill ntuple with track's information //============================================================================= void PrDownstreamChecker::fillTrack(const LHCb::Track *track, Tuples::Tuple ntuple) { // reconstructed quantities int type(-1), ndf(-1), q(0); double p(-999.99), px(-999.99), py(-999.99), pz(-999.99), pt(-999.99); double x(-999.99), y(-999.99), z(-999.99); double x_endVelo(-999.99), y_endVelo(-999.99), z_endVelo(-999.99); double x_atUT(-999.99), y_atUT(-999.99), z_atUT(-999.99); double tx_endVelo(-999.99), ty_endVelo(-999.99), tx_atUT(-999.99), ty_atUT(-999.99); double x_atFT(-999.99), y_atFT(-999.99), z_atFT(-999.99); double tx_atFT(-999.99), ty_atFT(-999.99); double chi2(-999.99),chi2PerDoF(-999.99); double qop(0.00); double eta(0.00),phi(0.00); double ds_track_p(0.); //double p_corrected; int n_UThits(-1); int n_FThits(-1); int nMeasurementsRemoved(-1); int nLHCbIDs(-1); //fill info from PrDownstream MC Matching. AD 1-7-14 int getPreSelection(-1),findMatchingHits(-1),fitXProjection(-1),addUVHits(-1); int fitAndRemove(-1),acceptCandidate(-1),beforeStore(-1); //HERE. ADD STATES double x_zpUT(-9999.0),y_zpUT(-9999.0),tx_zpUT(-9999.0),ty_zpUT(-9999.0); double x_zpreUT(-9999.0),y_zpreUT(-9999.0),tx_zpreUT(-9999.0),ty_zpreUT(-9999.0); if (track) { type = track->type(); px = track->momentum().x(); py = track->momentum().y(); pz = track->momentum().z(); p = track->p(); pt = track->pt(); eta = track->pseudoRapidity(); phi = track->phi(); q = track->charge(); chi2 = track->chi2(); chi2PerDoF = track->chi2PerDoF(); ndf = track->nDoF(); x = track->firstState().x(); y = track->firstState().y(); z = track->firstState().z(); // if(type == 5){ getPreSelection = track->info(1801,-1); findMatchingHits = track->info(1802,-1); fitXProjection = track->info(1803,-1); addUVHits = track->info(1804,-1); fitAndRemove = track->info(1805,-1); acceptCandidate = track->info(1806,-1); beforeStore = track->info(1807,-1); ds_track_p = track->info(1808,-1); //projected state at zpUT x_zpUT = track->info(1809,-1); y_zpUT = track->info(1810,-1); tx_zpUT = track->info(1811,-1); ty_zpUT = track->info(1812,-1); //pre ut x_zpreUT = track->info(1813,-1); y_zpreUT = track->info(1814,-1); tx_zpreUT = track->info(1815,-1); ty_zpreUT = track->info(1816,-1); // }else{ // debug()<<"not a downsteam track"<<endmsg; // } debug() << "chi2 = " << track->chi2() << endmsg; const LHCb::State *state = track->stateAt(LHCb::State::EndVelo); if (state) { x_endVelo = state->x(); y_endVelo = state->y(); z_endVelo = state->z(); tx_endVelo = state->tx(); ty_endVelo = state->ty(); //p_corrected = p; //if(pt<500.){ //p_corrected = 500./sqrt(tx_endVelo*tx_endVelo + ty_endVelo*ty_endVelo); //} //if(p_corrected<3000.) p_corrected = 3000.; }else{ debug () << "no velo state" << endmsg; } /*const LHCb::State * state_zmid = &(track->closestState(StateParameters::ZMidTT)); if(state_zmid){ debug() << "x_atUT = " << state_zmid->x() << endmsg; }else{ debug() << "no zmid state" << endmsg; }*/ //const LHCb::State *state_tt = track->stateAt(LHCb::State::AtTT); const LHCb::State * state_tt = &(track->closestState(StateParameters::ZMidTT)); if (state_tt) { debug () << "good TT state" << endmsg; x_atUT = state_tt->x(); debug () << "x_atUT = " << x_atUT << endmsg; y_atUT = state_tt->y(); z_atUT = state_tt->z(); tx_atUT = state_tt->tx(); ty_atUT = state_tt->ty(); qop = state_tt->qOverP(); }else{ debug() << "no TT state" << endmsg; } //T state const LHCb::State * state_ft = &(track->closestState(StateParameters::ZBegT)); if (state_ft) { debug () << "good T state" << endmsg; x_atFT = state_ft->x(); debug () << "x_atFT = " << x_atFT << endmsg; y_atFT = state_ft->y(); z_atFT = state_ft->z(); tx_atFT = state_ft->tx(); ty_atFT = state_ft->ty(); }else{ debug() << "no TT state" << endmsg; } // Loop over the LHCbIDs of the Track n_UThits = 0; n_FThits = 0; for( std::vector<LHCb::LHCbID>::const_iterator iId = track->lhcbIDs().begin(); track->lhcbIDs().end() != iId; ++iId ){ //if( (*iId).isVelo() || (*iId).isVP() || (*iId).isVL() ) { if ( (*iId).isTT() || (*iId).isUT() ) { n_UThits++; } else if ( (*iId).isIT() || (*iId).isOT() || (*iId).isFT() ) { n_FThits++; } } nMeasurementsRemoved = track->nMeasurementsRemoved(); nLHCbIDs = track->nLHCbIDs(); //std::vector<LHCb::LHCbID> IDs = track->LHCbIDContainer(); //debug() << "IDs.size() = " << IDs.size() << endmsg; /*LinkedFrom<LHCb::STCluster,LHCb::Track> UTlink(evtSvc(),msgSvc(), LHCb::STClusterLocation::UTClusters); if (!UTlink.notFound()){ n_UThits = 0; std::vector<int> fired; const LHCb::STCluster* UTCluster = UTlink.first(track); for ( ; 0 != UTCluster; UTCluster = UTlink.next()) { if ( !UTCluster->isUT() ) continue; debug() << "layer = " << UTCluster->layer() << endmsg; debug() << "station = " << UTCluster->station() << endmsg; n_UThits++; } }*/ /*LinkedFrom<LHCb::FTCluster,LHCb::Track> FTlink(evtSvc(),msgSvc(), LHCb::FTClusterLocation::Default); if (!FTlink.notFound()){ int nhits = 0; std::vector<int> fired; const LHCb::FTCluster* FTCluster = FTlink.first(track); for ( ; 0 != FTCluster; FTCluster = FTlink.next()) { if ( !FTCluster->isFT() ) continue; n_FThits++; } }*/ } ntuple->column("evt",evt); ntuple->column("n_in_evt",n_in_evt); ntuple->column("nMeasurementsRemoved", nMeasurementsRemoved); ntuple->column("nLHCbIDs", nLHCbIDs); ntuple->column("n_UThits", n_UThits); ntuple->column("n_FThits", n_FThits); ntuple->column("type", type); ntuple->column("p", p); //ntuple->column("p_corrected", p_corrected); ntuple->column("px", px); ntuple->column("py", py); ntuple->column("pz", pz); ntuple->column("pt", pt); ntuple->column("eta",eta); ntuple->column("phi",phi); ntuple->column("x", x); ntuple->column("y", y); ntuple->column("z", z); ntuple->column("q", q); ntuple->column("qop", qop); ntuple->column("x_endVelo", x_endVelo); ntuple->column("y_endVelo", y_endVelo); ntuple->column("z_endVelo", z_endVelo); ntuple->column("tx_endVelo", tx_endVelo); ntuple->column("ty_endVelo", ty_endVelo); ntuple->column("x_atUT", x_atUT); ntuple->column("y_atUT", y_atUT); ntuple->column("z_atUT", z_atUT); ntuple->column("tx_atUT", tx_atUT); ntuple->column("ty_atUT", ty_atUT); ntuple->column("x_atFT", x_atFT); ntuple->column("y_atFT", y_atFT); ntuple->column("z_atFT", z_atFT); ntuple->column("tx_atFT", tx_atFT); ntuple->column("ty_atFT", ty_atFT); ntuple->column("chi2", chi2); ntuple->column("chi2PerDoF", chi2PerDoF); ntuple->column("ndf", ndf); ntuple->column("nDownstreamTracks",nDownstreamTracks); ntuple->column("nSeedTracks",nSeedTracks); ntuple->column("getPreSelection",getPreSelection); ntuple->column("findMatchingHits",findMatchingHits); ntuple->column("fitXProjection",fitXProjection); ntuple->column("addUVHits",addUVHits); ntuple->column("fitAndRemove",fitAndRemove); ntuple->column("acceptCandidate",acceptCandidate); ntuple->column("beforeStore",beforeStore); ntuple->column("ds_track_p",ds_track_p); ntuple->column("x_zpUT_propagated",x_zpUT); ntuple->column("y_zpUT_propagated",y_zpUT); ntuple->column("tx_zpUT_propagated",tx_zpUT); ntuple->column("ty_zpUT_propagated",ty_zpUT); ntuple->column("x_zpreUT_propagated",x_zpreUT); ntuple->column("y_zpreUT_propagated",y_zpreUT); ntuple->column("tx_zpreUT_propagated",tx_zpreUT); ntuple->column("ty_zpreUT_propagated",ty_zpreUT); //HERE add columns for good and total before and after fitandremove /* int ngood_before_x1(-2), ngood_before_u(-2),ngood_before_v(-2),ngood_before_x2(-2); int ntot_before_x1(-2), ntot_before_u(-2),ntot_before_v(-2),ntot_before_x2(-2); int ngood_after_x1(-2), ngood_after_u(-2),ngood_after_v(-2),ngood_after_x2(-2); int ntot_after_x1(-2), ntot_after_u(-2),ntot_after_v(-2),ntot_after_x2(-2); */ //add the nhits stuff } #endif //PrDownstreamChecker_CPP
[ "adamdddave@googlemail.com" ]
adamdddave@googlemail.com
4efc333cbd4c45f647eaec9bb4707a75b078212b
23caaf0e4824eb64e3065e5b4a0d783057f712ab
/Sourcecode/stereo_ver2/solution1/syn/systemc/Loop_2_proc_PAR_RdEe.h
fb1291ca2a218abc07febbc2e6e4045e64d531b6
[]
no_license
prashant87/Binocular-Stereo-Vision-PYNQ
67e126e6ca3c89a00ce0bb974b256c7ba37dc306
efb64c4d6fa229070a4a865f10161ff06c23083e
refs/heads/master
2022-11-24T21:18:12.380550
2020-08-01T10:52:55
2020-08-01T10:52:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,816
h
// ============================================================== // File generated on Sat Aug 01 16:46:15 +0800 2020 // Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit) // SW Build 2405991 on Thu Dec 6 23:38:27 MST 2018 // IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018 // Copyright 1986-2018 Xilinx, Inc. All Rights Reserved. // ============================================================== #ifndef __Loop_2_proc_PAR_RdEe_H__ #define __Loop_2_proc_PAR_RdEe_H__ #include <systemc> using namespace sc_core; using namespace sc_dt; #include <iostream> #include <fstream> struct Loop_2_proc_PAR_RdEe_ram : public sc_core::sc_module { static const unsigned DataWidth = 32; static const unsigned AddressRange = 9; static const unsigned AddressWidth = 4; //latency = 1 //input_reg = 1 //output_reg = 0 sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in <sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in <sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in <sc_lv<AddressWidth> > address2; sc_core::sc_in <sc_logic> ce2; sc_core::sc_out <sc_lv<DataWidth> > q2; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; sc_lv<DataWidth> ram[AddressRange]; SC_CTOR(Loop_2_proc_PAR_RdEe_ram) { ram[0] = "0b01000100100000100100011110110100"; ram[1] = "0b00000000000000000000000000000000"; ram[2] = "0b01000011110110111011100100001100"; ram[3] = "0b00000000000000000000000000000000"; ram[4] = "0b01000100100000100111011111100110"; ram[5] = "0b01000011101011001110111100000010"; ram[6] = "0b00000000000000000000000000000000"; ram[7] = "0b00000000000000000000000000000000"; ram[8] = "0b00111111100000000000000000000000"; SC_METHOD(prc_write_0); sensitive<<clk.pos(); SC_METHOD(prc_write_1); sensitive<<clk.pos(); SC_METHOD(prc_write_2); sensitive<<clk.pos(); } void prc_write_0() { if (ce0.read() == sc_dt::Log_1) { if(address0.read().is_01() && address0.read().to_uint()<AddressRange) q0 = ram[address0.read().to_uint()]; else q0 = sc_lv<DataWidth>(); } } void prc_write_1() { if (ce1.read() == sc_dt::Log_1) { if(address1.read().is_01() && address1.read().to_uint()<AddressRange) q1 = ram[address1.read().to_uint()]; else q1 = sc_lv<DataWidth>(); } } void prc_write_2() { if (ce2.read() == sc_dt::Log_1) { if(address2.read().is_01() && address2.read().to_uint()<AddressRange) q2 = ram[address2.read().to_uint()]; else q2 = sc_lv<DataWidth>(); } } }; //endmodule SC_MODULE(Loop_2_proc_PAR_RdEe) { static const unsigned DataWidth = 32; static const unsigned AddressRange = 9; static const unsigned AddressWidth = 4; sc_core::sc_in <sc_lv<AddressWidth> > address0; sc_core::sc_in<sc_logic> ce0; sc_core::sc_out <sc_lv<DataWidth> > q0; sc_core::sc_in <sc_lv<AddressWidth> > address1; sc_core::sc_in<sc_logic> ce1; sc_core::sc_out <sc_lv<DataWidth> > q1; sc_core::sc_in <sc_lv<AddressWidth> > address2; sc_core::sc_in<sc_logic> ce2; sc_core::sc_out <sc_lv<DataWidth> > q2; sc_core::sc_in<sc_logic> reset; sc_core::sc_in<bool> clk; Loop_2_proc_PAR_RdEe_ram* meminst; SC_CTOR(Loop_2_proc_PAR_RdEe) { meminst = new Loop_2_proc_PAR_RdEe_ram("Loop_2_proc_PAR_RdEe_ram"); meminst->address0(address0); meminst->ce0(ce0); meminst->q0(q0); meminst->address1(address1); meminst->ce1(ce1); meminst->q1(q1); meminst->address2(address2); meminst->ce2(ce2); meminst->q2(q2); meminst->reset(reset); meminst->clk(clk); } ~Loop_2_proc_PAR_RdEe() { delete meminst; } };//endmodule #endif
[ "zhangwenyu3087@163.com" ]
zhangwenyu3087@163.com
3ad5a51a6ced164c04353d9ab1c68d3cd2943a9a
562aaeeb36128a12f31245b49b52584409ac9e79
/10.0.15063.0/winrt/internal/Windows.Devices.Lights.2.h
bb547e0aebf1441293e3aba1b5253dd7e622c391
[ "LicenseRef-scancode-generic-cla", "MIT" ]
permissive
PlainRubbish/cppwinrt
af6b2fde4bb56a8c310f338b440e8db7943e2f2e
532b09e3796bd883394f510ce7b4c35a2fc75743
refs/heads/master
2021-01-19T05:06:17.990730
2017-03-31T20:03:28
2017-03-31T20:03:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,079
h
// C++ for the Windows Runtime v1.0.170331.7 // Copyright (c) 2017 Microsoft Corporation. All rights reserved. #pragma once #include "Windows.Devices.Lights.1.h" #include "Windows.Foundation.1.h" WINRT_EXPORT namespace winrt { namespace ABI::Windows::Foundation { #ifndef WINRT_GENERIC_52a69dfd_f0d6_5931_b8e1_f38066d71bf2 #define WINRT_GENERIC_52a69dfd_f0d6_5931_b8e1_f38066d71bf2 template <> struct __declspec(uuid("52a69dfd-f0d6-5931-b8e1-f38066d71bf2")) __declspec(novtable) IAsyncOperation<Windows::Devices::Lights::Lamp> : impl_IAsyncOperation<Windows::Devices::Lights::Lamp> {}; #endif #ifndef WINRT_GENERIC_556a02d9_7685_576f_89ca_b62dc481d29d #define WINRT_GENERIC_556a02d9_7685_576f_89ca_b62dc481d29d template <> struct __declspec(uuid("556a02d9-7685-576f-89ca-b62dc481d29d")) __declspec(novtable) TypedEventHandler<Windows::Devices::Lights::Lamp, Windows::Devices::Lights::LampAvailabilityChangedEventArgs> : impl_TypedEventHandler<Windows::Devices::Lights::Lamp, Windows::Devices::Lights::LampAvailabilityChangedEventArgs> {}; #endif #ifndef WINRT_GENERIC_191a8c6e_60dd_5a21_a53c_bf3f940a1dde #define WINRT_GENERIC_191a8c6e_60dd_5a21_a53c_bf3f940a1dde template <> struct __declspec(uuid("191a8c6e-60dd-5a21-a53c-bf3f940a1dde")) __declspec(novtable) AsyncOperationCompletedHandler<Windows::Devices::Lights::Lamp> : impl_AsyncOperationCompletedHandler<Windows::Devices::Lights::Lamp> {}; #endif } namespace Windows::Devices::Lights { struct ILamp : Windows::Foundation::IInspectable, impl::consume<ILamp>, impl::require<ILamp, Windows::Foundation::IClosable> { ILamp(std::nullptr_t = nullptr) noexcept {} }; struct ILampAvailabilityChangedEventArgs : Windows::Foundation::IInspectable, impl::consume<ILampAvailabilityChangedEventArgs> { ILampAvailabilityChangedEventArgs(std::nullptr_t = nullptr) noexcept {} }; struct ILampStatics : Windows::Foundation::IInspectable, impl::consume<ILampStatics> { ILampStatics(std::nullptr_t = nullptr) noexcept {} }; } }
[ "kwelton@microsoft.com" ]
kwelton@microsoft.com
3ccd046aa23cba967298ea4d9e03d3f420bbc64e
a5847695db20585b23a58dab21fe19879781ade4
/ArcSoft_Recognition.cpp
8c57b97dc8035b61d1f9dfbd0e03739ef3db2d72
[]
no_license
spz1063769322/ArcSoft-Face-Recognition-SDK
8d76f5b80a9b027026c6839d6a03c84643efc5a7
e6ed1fe9f65def0c7eb8173129daaba014ed6f07
refs/heads/master
2020-06-28T21:46:15.774640
2019-08-16T01:48:09
2019-08-16T01:48:09
200,350,284
1
1
null
null
null
null
GB18030
C++
false
false
19,961
cpp
//#include "stdafx.h" //#include <stdio.h> //#include <stdlib.h> //#include "arcsoft_face_sdk.h" //#include "amcomdef.h" //#include "asvloffscreen.h" //#include "merror.h" //#include <direct.h> //#include <iostream> //#include <stdarg.h> //#include <string> //#include <opencv2\opencv.hpp> //#include <vector> //#include <time.h> //#include <io.h> // // //using namespace std; //#pragma comment(lib, "libarcsoft_face_engine.lib") //MHandle handle = NULL; //MRESULT res; //MFloat maxThreshold = 0.9; //#define APPID "HseWycZ8Ag8gEvTcswpa9h3Gn2DX5c2nNPMEAdpUce1H" //#define SDKKey "H87HDU2AVfWGL5oQvPqTAG67MqV8p8jXms4qd935tgF6" // // //#define SafeFree(p) { if ((p)) free(p); (p) = NULL; } //#define SafeArrayDelete(p) { if ((p)) delete [] (p); (p) = NULL; } //#define SafeDelete(p) { if ((p)) delete (p); (p) = NULL; } // // //vector<clock_t> time_list; //vector<double> Accuracy; //vector<double> Recall; // // // //void CutIplImage(IplImage* src, IplImage* dst, int x, int y) //{ // CvSize size = cvSize(dst->width, dst->height); // cvSetImageROI(src, cvRect(x, y, size.width, size.height)); // cvCopy(src, dst); // cvResetImageROI(src); //} // // //void Feature_ex(IplImage* img, ASF_FaceFeature &feature) //{ // ASF_MultiFaceInfo detectedFaces = { 0 }; // ASF_SingleFaceInfo SingleDetectedFaces = { 0 }; // //IplImage* cutImg = cvCreateImage(cvSize(img->width - img->width % 4, img->height), IPL_DEPTH_8U, img->nChannels); // //CutIplImage(img, cutImg, 0, 0); // res = ASFDetectFaces(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &detectedFaces); // // if (MOK == res) // { // SingleDetectedFaces.faceRect.left = detectedFaces.faceRect[0].left; // SingleDetectedFaces.faceRect.top = detectedFaces.faceRect[0].top; // SingleDetectedFaces.faceRect.right = detectedFaces.faceRect[0].right; // SingleDetectedFaces.faceRect.bottom = detectedFaces.faceRect[0].bottom; // SingleDetectedFaces.faceOrient = detectedFaces.faceOrient[0]; // // res = ASFFaceFeatureExtract(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &SingleDetectedFaces, &feature); // if (MOK != res) // printf("ASFFaceFeatureExtract fail: %d\n", res); // } // else // printf("ASFDetectFaces fail: %d\n", res); //} // // //void getFiles1(string path, vector<string>& files) //{ // //文件句柄 // //long hFile = 0; //win7 // intptr_t hFile = 0; //win10 // //文件信息 // struct _finddata_t fileinfo; // string p; // if ((hFile = _findfirst(p.assign(path).append("\\").c_str(), &fileinfo)) != -1) // // "\\*"是指读取文件夹下的所有类型的文件,若想读取特定类型的文件,以png为例,则用“\\*.png” // { // do // { // //如果是目录,迭代之 // //如果不是,加入列表 // if ((fileinfo.attrib & _A_SUBDIR)) // { // if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) // getFiles1(p.assign(path).append("\\").append(fileinfo.name), files); // } // else // { // files.push_back(fileinfo.name); // } // } while (_findnext(hFile, &fileinfo) == 0); // _findclose(hFile); // } //} // //void getFiles2(string path, vector<string>& files) //{ // //文件句柄 // //long hFile = 0; //win7 // intptr_t hFile = 0; //win10 // //文件信息 // struct _finddata_t fileinfo; // string p; // if ((hFile = _findfirst(p.assign(path).append("\\*.bmp").c_str(), &fileinfo)) != -1) // // "\\*"是指读取文件夹下的所有类型的文件,若想读取特定类型的文件,以png为例,则用“\\*.png” // { // do // { // //如果是目录,迭代之 // //如果不是,加入列表 // if ((fileinfo.attrib & _A_SUBDIR)) // { // if (strcmp(fileinfo.name, ".") != 0 && strcmp(fileinfo.name, "..") != 0) // getFiles1(p.assign(path).append("\\").append(fileinfo.name), files); // } // else // { // files.push_back(fileinfo.name); // } // } while (_findnext(hFile, &fileinfo) == 0); // _findclose(hFile); // } //} // // //int main() //{ // res = ASFOnlineActivation(APPID, SDKKey); // if (MOK != res && MERR_ASF_ALREADY_ACTIVATED != res) // printf("ASFActivation fail: %d\n", res); // else // printf("ASFActivation sucess: %d\n", res); // // ASF_ActiveFileInfo activeFileInfo; // res = ASFGetActiveFileInfo(&activeFileInfo); // if (res != MOK) // printf("ASFGetActiveFileInfo fail: %d\n", res); // // MInt32 mask = ASF_FACE_DETECT | ASF_FACERECOGNITION | ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE | ASF_LIVENESS | ASF_IR_LIVENESS; // res = ASFInitEngine(ASF_DETECT_MODE_IMAGE, ASF_OP_0_ONLY, 30, 10, mask, &handle); // if (res != MOK) // printf("ASFInitEngine fail: %d\n", res); // else // printf("ASFInitEngine sucess: %d\n", res); // // // string file_path = "E:\\Pre_Work\\DataSet\\CASIA_FaceV5\\64_CASIA_FaceV5\\Register_image"; // string search_path = file_path; // vector<string> file_list; // getFiles2(search_path, file_list); // /*if(file_list.empty()) // cout << "open file error!" << endl;*/ // vector<string> image_path; // for (int i = 0; i < file_list.size(); i++) { // image_path.push_back(file_path + "\\" + file_list[i]); // cout << image_path[i] << endl;; // } // random_shuffle(image_path.begin(), image_path.end()); // // //注册人脸特征 // vector<ASF_FaceFeature> m_featuresVec; // for (int i = 0; i < image_path.size(); i++) { // ASF_FaceFeature feature = { 0 }; // ASF_FaceFeature copyfeature1 = { 0 }; // ASF_MultiFaceInfo detectedFaces = { 0 }; // ASF_SingleFaceInfo SingleDetectedFaces = { 0 }; // //cv::Mat image = cv::imread(image_path[i]); // const char* path = image_path[i].data(); // cout << path << endl; // IplImage* img = cvLoadImage(path, 1); // IplImage* imgs; // CvSize size; // size.width = img->width - img->width % 4; // size.height = img->height; // imgs = cvCreateImage(size, img->depth, img->nChannels); // cvResize(img, imgs, CV_INTER_CUBIC); // IplImage* cut_Img = cvCreateImage(cvSize(imgs->width - imgs->width % 4, imgs->height), IPL_DEPTH_8U, imgs->nChannels); // CutIplImage(img, cut_Img, 0, 0); // //cout << img->imageData << endl; // //img = &IplImage(image); // //IplImage* cutImg = cvCreateImage(cvSize(img->width - img->width % 4, img->height), IPL_DEPTH_8U, img->nChannels); // //CutIplImage(img, cutImg, 0, 0); // res = ASFDetectFaces(handle, cut_Img->width, cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)cut_Img->imageData, &detectedFaces); // // if (MOK == res) // { // SingleDetectedFaces.faceRect.left = detectedFaces.faceRect[0].left; // SingleDetectedFaces.faceRect.top = detectedFaces.faceRect[0].top; // SingleDetectedFaces.faceRect.right = detectedFaces.faceRect[0].right; // SingleDetectedFaces.faceRect.bottom = detectedFaces.faceRect[0].bottom; // SingleDetectedFaces.faceOrient = detectedFaces.faceOrient[0]; // // res = ASFFaceFeatureExtract(handle, cut_Img->width, cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)cut_Img->imageData, &SingleDetectedFaces, &feature); // if (res == MOK) // { // //拷贝feature // copyfeature1.featureSize = feature.featureSize; // copyfeature1.feature = (MByte *)malloc(feature.featureSize); // memset(copyfeature1.feature, 0, feature.featureSize); // memcpy(copyfeature1.feature, feature.feature, feature.featureSize); // cout << "Register Face " << i << "/ " << image_path.size() << " " << feature.featureSize << endl; // m_featuresVec.push_back(copyfeature1); // } // else // { // printf("ASFFaceFeatureExtract fail: %d\n", res); // cout << "Register Face " << i << "/ " << image_path.size() << " " << feature.featureSize << endl; // m_featuresVec.push_back(feature); // } // //cout << "Register Face " << i - Random_seed << "/500 " << " " << feature.featureSize << endl; // //cout << copyfeature1.feature << endl; // //m_featuresVec.push_back(copyfeature1); // // } // else // printf("ASFDetectFaces fail: %d\n", res); // //Feature_ex(img, feature); // //m_featuresVec.push_back(feature); // cvReleaseImage(&cut_Img); // cvReleaseImage(&img); // cvReleaseImage(&imgs); // } // cout << "*************************************************************************" << endl;; // // //待识别人脸特征 // double mean_error = 0; // for (int j = 1; j <= 10; j++) { // vector<ASF_FaceFeature> Recognition_featuresVec; // // clock_t start = clock(); // MFloat confidenceLevel; // //真实人脸特征 // //for (int k = Random_seed; k < Random_seed + 500; k++) { // // IplImage* Recognition_img = cvLoadImage(image_path[k].c_str()); // // ASF_MultiFaceInfo detectedFaces = { 0 }; // // ASF_SingleFaceInfo SingleDetectedFaces = { 0 }; // // ASF_FaceFeature feature = { 0 }; // // IplImage* Recognition_cut_Img = cvCreateImage(cvSize(Recognition_img->width - Recognition_img->width % 4, Recognition_img->height), IPL_DEPTH_8U, Recognition_img->nChannels); // // CutIplImage(Recognition_img, Recognition_cut_Img, 0, 0); // // // res = ASFDetectFaces(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &detectedFaces); // // if (MOK == res) // // { // // SingleDetectedFaces.faceRect.left = detectedFaces.faceRect[0].left; // // SingleDetectedFaces.faceRect.top = detectedFaces.faceRect[0].top; // // SingleDetectedFaces.faceRect.right = detectedFaces.faceRect[0].right; // // SingleDetectedFaces.faceRect.bottom = detectedFaces.faceRect[0].bottom; // // SingleDetectedFaces.faceOrient = detectedFaces.faceOrient[0]; // // // res = ASFFaceFeatureExtract(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &SingleDetectedFaces, &feature); // // Recognition_featuresVec.push_back(feature); // // cout << "Real Recognition Face " << k - Random_seed << "/ 1000" << " " << feature.featureSize << endl; // // if (MOK != res) // // printf("ASFFaceFeatureExtract fail: %d\n", res); // // } // // else // // { // // printf("ASFDetectFaces fail: %d\n", res); // // } // // cvReleaseImage(&Recognition_img); // // cvReleaseImage(&Recognition_cut_Img); // //} // //cout << "*************************************************************************" << endl;; // // // // string fake_img_path = "E:\\Pre_Work\\DataSet\\CASIA_FaceV5\\64_CASIA_FaceV5\\image"; // vector<string> fake_file_list; // getFiles2(fake_img_path, fake_file_list); // /*if(file_list.empty()) // cout << "open file error!" << endl;*/ // vector<string> fake_image_path; // for (int i = 0; i < fake_file_list.size(); i++) { // fake_image_path.push_back(fake_img_path + "\\" + fake_file_list[i]); // } // random_shuffle(fake_image_path.begin(), fake_image_path.end()); // for (int k = 0; k < 500; k++) { // IplImage* Recognition_img = cvLoadImage(fake_image_path[k].c_str(), 1); // ASF_MultiFaceInfo detectedFaces = { 0 }; // ASF_SingleFaceInfo SingleDetectedFaces = { 0 }; // ASF_FaceFeature feature = { 0 }; // ASF_FaceFeature copyfeature2 = { 0 }; // IplImage* Recognition_cut_Img = cvCreateImage(cvSize(Recognition_img->width - Recognition_img->width % 4, Recognition_img->height), IPL_DEPTH_8U, Recognition_img->nChannels); // CutIplImage(Recognition_img, Recognition_cut_Img, 0, 0); // // // res = ASFDetectFaces(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &detectedFaces); // if (MOK == res) // { // SingleDetectedFaces.faceRect.left = detectedFaces.faceRect[0].left; // SingleDetectedFaces.faceRect.top = detectedFaces.faceRect[0].top; // SingleDetectedFaces.faceRect.right = detectedFaces.faceRect[0].right; // SingleDetectedFaces.faceRect.bottom = detectedFaces.faceRect[0].bottom; // SingleDetectedFaces.faceOrient = detectedFaces.faceOrient[0]; // // res = ASFFaceFeatureExtract(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &SingleDetectedFaces, &feature); // if (res == MOK) // { // //拷贝feature // copyfeature2.featureSize = feature.featureSize; // copyfeature2.feature = (MByte *)malloc(feature.featureSize); // memset(copyfeature2.feature, 0, feature.featureSize); // memcpy(copyfeature2.feature, feature.feature, feature.featureSize); // cout << "Recognition Face " << k << "/500 " << " " << feature.featureSize << endl; // Recognition_featuresVec.push_back(copyfeature2); // } // else // { // printf("ASFFaceFeatureExtract fail: %d\n", res); // cout << "Recognition Face " << k << "/500 " << " " << feature.featureSize << endl; // Recognition_featuresVec.push_back(feature); // } // } // else // { // printf("ASFDetectFaces fail: %d\n", res); // } // if (feature.featureSize != 0) { // ASF_LivenessThreshold threshold = { 0 }; // threshold.thresholdmodel_BGR = 0.75; // threshold.thresholdmodel_IR = 0.7; // res = ASFSetLivenessParam(handle, &threshold); // if (res != MOK) // printf("ASFSetLivenessParam fail: %d\n", res); // else // printf("RGB Threshold: %f IR Threshold: %f\n", threshold.thresholdmodel_BGR, threshold.thresholdmodel_IR); // // MInt32 processMask = ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE | ASF_LIVENESS; // res = ASFProcess(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &detectedFaces, processMask); // if (res != MOK) // printf("ASFProcess fail: %d\n", res); // else // printf("ASFProcess sucess: %d\n", res); // // ASF_AgeInfo ageInfo = { 0 }; // res = ASFGetAge(handle, &ageInfo); // if (res != MOK) // printf("ASFGetAge fail: %d\n", res); // else // printf("Age: %d\n", ageInfo.ageArray[0]); // // ASF_GenderInfo genderInfo = { 0 }; // res = ASFGetGender(handle, &genderInfo); // if (res != MOK) // printf("ASFGetGender fail: %d\n", res); // else // printf("Gender: %d\n", genderInfo.genderArray[0]); // // ASF_Face3DAngle angleInfo = { 0 }; // res = ASFGetFace3DAngle(handle, &angleInfo); // if (res != MOK) // printf("ASFGetFace3DAngle fail: %d\n", res); // else // printf("3DAngle roll: %f yaw: %f pitch: %f\n", angleInfo.roll[0], angleInfo.yaw[0], angleInfo.pitch[0]); // // ASF_LivenessInfo rgbLivenessInfo = { 0 }; // res = ASFGetLivenessScore(handle, &rgbLivenessInfo); // if (res != MOK) // printf("ASFGetLivenessScore fail: %d\n", res); // else // printf("RGB Liveness: %d\n", rgbLivenessInfo.isLive[0]); // } // else { // printf("No Feature \n"); // } // cvReleaseImage(&Recognition_img); // cvReleaseImage(&Recognition_cut_Img); // } // cout << "*************************************************************************" << endl;; // // int tp_predicion = 0; // int tn_prediction = 0; // int fp_prediction = 0; // int fn_prediction = 0; // // for (int j = 0; j < Recognition_featuresVec.size(); j++) { // for (int i = 0; i < m_featuresVec.size(); i++) { // res = ASFFaceFeatureCompare(handle, &m_featuresVec[i], &Recognition_featuresVec[j], &confidenceLevel); // if (res == MOK && (confidenceLevel > 0.8)) { // cout << "ASFFaceFeatureCompare success: " << (double)confidenceLevel << " 匹配号:" << i << endl; // cvShowImage("Recognition Face", cvLoadImage(fake_image_path[j].c_str(), 1)); // cvShowImage("Match Face", cvLoadImage(image_path[i].c_str(), 1)); // cvWaitKey(1000); // cvDestroyAllWindows(); // break; // } // else if (res == MOK && i == Recognition_featuresVec.size()) { // printf("ASFFaceFeatureCompare fail: %d\n", res); // fp_prediction += 1; // } // } // } // cout << "Error Recognition " << fn_prediction / 5.0 << "%" << endl; // mean_error += fn_prediction / 5.0; // //计算recall值 // /*for (int j = 0; j < Recognition_featuresVec.size(); j++) { // for (int i = 0; i < m_featuresVec.size(); i++) // { // res = ASFFaceFeatureCompare(handle, &m_featuresVec[i], &Recognition_featuresVec[j], &confidenceLevel); // if (res != MOK) { // if (j >= 500) { // printf("ASFFaceFeatureCompare fail: %d\n", res); // } // else if (j < 500 && i > 500) { // fn_prediction += 1; // break; // } // } // else // { // if (j < 500) { // printf("ASFFaceFeatureCompare sucess: %lf\n", confidenceLevel); // tp_predicion += 1; // break; // } // else { // fp_prediction += 1; // break; // } // } // } // }*/ // clock_t end = clock(); // cout << "Recognition Face Use " << end - start << "ms" << endl; // time_list.push_back(end - start); // // /*ASF_LivenessThreshold threshold = { 0 }; // threshold.thresholdmodel_BGR = 0.75; // threshold.thresholdmodel_IR = 0.7; // res = ASFSetLivenessParam(handle, &threshold); // if (res != MOK) // printf("ASFSetLivenessParam fail: %d\n", res); // else // printf("RGB Threshold: %f IR Threshold: %f\n", threshold.thresholdmodel_BGR, threshold.thresholdmodel_IR); // // MInt32 processMask = ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE | ASF_LIVENESS; // res = ASFProcess(handle, Recognition_cut_Img->width, Recognition_cut_Img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)Recognition_cut_Img->imageData, &detectedFaces, processMask); // if (res != MOK) // printf("ASFProcess fail: %d\n", res); // else // printf("ASFProcess sucess: %d\n", res); // // ASF_AgeInfo ageInfo = { 0 }; // res = ASFGetAge(handle, &ageInfo); // if (res != MOK) // printf("ASFGetAge fail: %d\n", res); // else // printf("Age: %d\n", ageInfo.ageArray[0]); // // ASF_GenderInfo genderInfo = { 0 }; // res = ASFGetGender(handle, &genderInfo); // if (res != MOK) // printf("ASFGetGender fail: %d\n", res); // else // printf("Gender: %d\n", genderInfo.genderArray[0]); // // ASF_Face3DAngle angleInfo = { 0 }; // res = ASFGetFace3DAngle(handle, &angleInfo); // if (res != MOK) // printf("ASFGetFace3DAngle fail: %d\n", res); // else // printf("3DAngle roll: %f yaw: %f pitch: %f\n", angleInfo.roll[0], angleInfo.yaw[0], angleInfo.pitch[0]); // // ASF_LivenessInfo rgbLivenessInfo = { 0 }; // res = ASFGetLivenessScore(handle, &rgbLivenessInfo); // if (res != MOK) // printf("ASFGetLivenessScore fail: %d\n", res); // else // printf("RGB Liveness: %d\n", rgbLivenessInfo.isLive[0]);*/ // // tn_prediction = 1000 - tp_predicion - fp_prediction - fn_prediction; // // cout << tp_predicion << " " << tn_prediction << endl; // // cout << "Accuracy " << (tp_predicion + tn_prediction) / 10.0 << "%" << endl; // // cout << " Recall " << tp_predicion / (float)(tp_predicion + fn_prediction) / 10.0 << "%" << endl; // // Accuracy.push_back((tp_predicion + tn_prediction) / 1000); // // Recall.push_back(tp_predicion / (tp_predicion + fn_prediction)); // //} // // //cout << "Accuracy: " << endl; // //for (int k = 0; k < Accuracy.size(); k++) { // // cout << Accuracy[k] << endl; // //} // //cout << "Recall: " << endl; // //for (int k = 0; k < Accuracy.size(); k++) { // // cout << Recall[k] << endl; // } // cout << mean_error / 5.0 << endl; // for (int i = 0; i < time_list.size(); i++) { // cout << time_list[i] << " "; // } // // const ASF_VERSION* pVersionInfo = ASFGetVersion(handle); // res = ASFUninitEngine(handle); // if (res != MOK) // printf("ALUninitEngine fail: %d\n", res); // else // printf("ALUninitEngine sucess: %d\n", res); // getchar(); // return 0; //} //
[ "noreply@github.com" ]
spz1063769322.noreply@github.com
47876aeb1db714e8c2f7a535b730d5a50c7bfe5a
02403958ff3cc25e46d5bdf449d058d67fc377b6
/ultra_sonic/src/ultraSonic.cpp
8530e0260be9b5551d8239b3587472497badf5a5
[]
no_license
ychengkingdom/snbird
15cd02bbf737cfec7a8fb20995d79f22457adfe8
ed70481ec8cd3a67995fc6cdb8dcea41bc3b400d
refs/heads/master
2022-09-12T14:33:31.613675
2020-05-22T08:19:01
2020-05-22T08:19:01
196,955,122
0
0
null
null
null
null
UTF-8
C++
false
false
1,528
cpp
/*********************************************************************** *Coypright 2020 by Ychengking. All rights reserved. * *@file: ultraSonic.cpp. * *Main function of the ultraSonic.cpp * ***********************************************************************/ #include <ros/ros.h> #include "ultraSonic.h" /**************Function definitions for Ultra sonic********************/ UltraSonic::UltraSonic(int trigPin, int echoPin) { m_trigPin = trigPin; m_echoPin = echoPin; gettimeofday(&m_tv1, NULL); gettimeofday(&m_tv2, NULL); m_start = 0; m_stop = 0; pinMode(m_trigPin, OUTPUT); pinMode(m_echoPin, INPUT); } UltraSonic::~UltraSonic() { } int UltraSonic::disUS_015() { float dis; digitalWrite(m_trigPin, HIGH); delayMicroseconds(TRIG_TIME); digitalWrite(m_trigPin, LOW); while(!(digitalRead(m_echoPin) == 1)) { gettimeofday(&m_tv1, NULL); } while(!(digitalRead(m_echoPin) == 0)) { gettimeofday(&m_tv2, NULL); } m_start = m_tv1.tv_sec * 1000000 + m_tv1.tv_usec; m_stop = m_tv2.tv_sec * 1000000 + m_tv2.tv_usec; dis = (float)(m_stop - m_start) / 1000000*34000 / 2; return dis; } /*********************************************************************** * Yc, Mar 13, 2020, Add file description and modulize orgnization * * * * * * * * * * * * * * **********************************************************************/
[ "yangchengemail@126.com" ]
yangchengemail@126.com
b45650eb94f5d2748eefeb53284665bd22d58e84
4bf5ccad5f792672ca230813d9c16b127ac968c5
/Mountain.hpp
b06c801514bcae05fe0ad34a15b67bfc96accf1a
[]
no_license
ThibsG/skiing_singapore
20043e28ef9ae2bdc7c521e55562379c8679829b
9f738ff9074e5f7c0b44408e91a30417ecc729a8
refs/heads/master
2021-01-23T06:34:21.991002
2015-06-21T20:07:11
2015-06-23T08:48:58
37,415,044
0
0
null
null
null
null
UTF-8
C++
false
false
1,236
hpp
#ifndef MOUNTAIN_HPP #define MOUNTAIN_HPP #include <string> #include <vector> #include <list> namespace SkiMountain { class Viewer; /// Path representation typedef std::vector<uint16_t> Path; /** * @class Mountain * Class representation of the mountain */ class Mountain { friend class Viewer; public: /** * @struct Number * Number is an element of the mountain. * It is built from position (row,col) and a value */ struct Number { uint16_t row; uint16_t col; uint16_t value; Number(uint16_t r, uint16_t c); Number(uint16_t r, uint16_t c, uint16_t v); bool operator==(const Number& n) const; }; Mountain(); bool load(const std::string& filename); inline uint16_t cols() const; inline uint16_t rows() const; std::list<Number> neighbors(const Mountain::Number& origine) const; Number numberAt(uint16_t row, uint16_t col) const; void clear(); private: std::vector<std::vector<uint16_t>> m_elements; uint16_t m_cols; uint16_t m_rows; uint16_t valueAt(uint16_t row, uint16_t col) const; }; uint16_t Mountain::cols() const { return m_cols; } uint16_t Mountain::rows() const { return m_rows; } } #endif
[ "thibaud@debian" ]
thibaud@debian
13acbda2b5f78add2e3570dd015ccdbf0d2642ac
cfff7a4bf4be142b91536b4d8fe4edc8488f3403
/Real_Time_Environmental_info_Monitor_Linux/file_op/cloudconfigfile.cpp
7ea192d83774e4a7f5c82eaa60473db86acb53b3
[]
no_license
swiftjiang/Real-Time-Environmental-info-Monitor
5217374d6416a68c0e11dd8c022caf7efa1b9cf7
83636d4f7eb9a099538047a7a89f0064b1644534
refs/heads/master
2021-01-22T02:17:40.370591
2018-04-14T07:13:16
2018-04-14T07:13:16
92,348,739
0
0
null
null
null
null
UTF-8
C++
false
false
103
cpp
#include "cloudconfigfile.h" CloudConfigFile::CloudConfigFile(QObject *parent) : QObject(parent) { }
[ "swiftjiang2018@gmail.com" ]
swiftjiang2018@gmail.com
78c22f85b77db0a5fe69cacc94dd71adf42556c3
1f2ba15e21a80b939cfe8b44851370ed5728b171
/Chapter 2/2.2.11 (1).cpp
db3d2441dceee6c4361c7bc851a92f2dabe0b635
[]
no_license
AWoLf98/CPP-Advanced-Programing
bc8d9fc50731ccd22d433c2c7842bb7c5b68fc6d
1cccb906dc8a3d3ea07b4d55d6fd47284e2fd5be
refs/heads/master
2021-08-31T04:38:12.021413
2017-12-20T10:16:48
2017-12-20T10:16:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
436
cpp
#include <iostream> #include <fstream> #include <set> #include <functional> using namespace std; int main() { set <double, greater<double>> valuesA = { -1.1, 2.9, -2.3, 3.7 }; set <double, greater<double>> valuesB = { -3.14, 2.71, -3.88, 2.19 }; valuesA.swap(valuesB); for (auto value : valuesA) cout << value << " "; cout << endl; for (auto value : valuesB) cout << value << " "; cout << endl; }
[ "andresistuk@ukr.net" ]
andresistuk@ukr.net
ed8fc66b74ee327cd983fe6f5500e8c849aafc0a
f8d76935f342abceff51a90a2844110ac57a4d2e
/solution/srm328_scoredifference.cpp
ecbfcb503f95242f859907a56a4d901cd627d880
[]
no_license
rick-qiu/topcoder
b36cc5bc571f1cbc7be18fdc863a1800deeb5de1
04adddbdc49e35e10090d33618be90fc8d3b8e7d
refs/heads/master
2021-01-01T05:59:41.264459
2014-05-22T06:14:43
2014-05-22T06:14:43
11,315,215
1
0
null
null
null
null
UTF-8
C++
false
false
32,497
cpp
/******************************************************************************* * Automatically generated code for TopCode SRM Problem * Problem URL: http://community.topcoder.com/stat?c=problem_statement&pm=6854 *******************************************************************************/ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; class ScoreDifference { public: int maximize(vector<string> board); }; int ScoreDifference::maximize(vector<string> board) { int ret; return ret; } int test0() { vector<string> board = {"12 4 5 13", "3 14 16 9", "11 6 15 8", "2 1 7 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 2; if(result == expected) { cout << "Test Case 0: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 0: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test1() { vector<string> board = {"15 16 11 12", "10 13 4 7", "1 2 8 6", "9 5 3 14"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 1: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 1: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test2() { vector<string> board = {"6 8 1 16", "10 15 9 3", "2 5 7 14", "13 12 11 4"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 2: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 2: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test3() { vector<string> board = {"9 8 3 1", "10 6 15 5", "12 7 4 11", "14 13 16 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 3: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 3: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test4() { vector<string> board = {"12 8 6 5", "2 11 9 15", "13 10 14 7", "1 16 4 3"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 4; if(result == expected) { cout << "Test Case 4: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 4: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test5() { vector<string> board = {"7 2 8 4", "3 16 10 12", "9 6 14 11", "15 13 1 5"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 5: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 5: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test6() { vector<string> board = {"4 10 14 3", "2 7 15 6", "11 1 13 9", "5 8 16 12"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 6: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 6: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test7() { vector<string> board = {"9 6 2 10", "5 11 3 8", "16 1 12 13", "14 15 7 4"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 7: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 7: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test8() { vector<string> board = {"15 10 12 11", "6 3 4 13", "14 5 16 1", "9 8 7 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 8: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 8: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test9() { vector<string> board = {"11 9 3 4", "1 16 8 13", "14 10 6 5", "7 15 12 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 9: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 9: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test10() { vector<string> board = {"7 3 13 12", "1 5 2 15", "8 4 6 14", "9 16 11 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 10: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 10: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test11() { vector<string> board = {"3 11 7 15", "14 4 16 2", "8 13 1 6", "10 12 5 9"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 11: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 11: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test12() { vector<string> board = {"7 14 6 16", "9 11 5 4", "2 12 8 3", "15 1 13 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 12: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 12: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test13() { vector<string> board = {"8 6 1 4", "3 7 16 2", "11 15 5 9", "14 10 13 12"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 13: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 13: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test14() { vector<string> board = {"13 8 7 15", "6 14 10 1", "11 9 12 5", "2 3 4 16"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 14: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 14: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test15() { vector<string> board = {"5 9 15 6", "2 8 3 12", "14 16 11 1", "13 7 4 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 15: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 15: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test16() { vector<string> board = {"7 2 6 5", "1 13 3 11", "16 4 9 10", "14 8 12 15"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 18; if(result == expected) { cout << "Test Case 16: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 16: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test17() { vector<string> board = {"14 10 8 7", "16 2 12 4", "15 6 3 9", "1 5 13 11"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 17: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 17: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test18() { vector<string> board = {"6 15 16 7", "14 5 12 13", "1 11 2 9", "3 4 10 8"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 18: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 18: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test19() { vector<string> board = {"15 11 7 12", "2 3 8 14", "16 13 9 6", "4 5 1 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 19: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 19: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test20() { vector<string> board = {"11 8 13 12", "1 14 9 6", "7 10 4 3", "5 2 16 15"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 20: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 20: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test21() { vector<string> board = {"13 12 1 4", "2 7 9 6", "11 5 8 15", "3 16 14 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 21: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 21: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test22() { vector<string> board = {"2 3 12 7", "6 16 5 15", "14 4 9 8", "13 10 11 1"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 22: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 22: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test23() { vector<string> board = {"9 11 14 3", "5 6 2 4", "12 13 16 7", "1 15 8 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 23: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 23: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test24() { vector<string> board = {"7 10 13 8", "16 12 5 4", "14 3 15 2", "11 6 9 1"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 24: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 24: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test25() { vector<string> board = {"9 3 6 13", "1 14 2 4", "7 5 11 10", "8 12 16 15"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 25: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 25: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test26() { vector<string> board = {"14 5 16 13", "8 9 3 11", "7 1 12 4", "2 10 6 15"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 26: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 26: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test27() { vector<string> board = {"2 15 10 6", "13 5 1 16", "11 8 3 4", "7 14 12 9"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 27: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 27: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test28() { vector<string> board = {"9 4 11 10", "2 12 3 13", "6 1 16 15", "8 5 7 14"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 28: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 28: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test29() { vector<string> board = {"11 16 9 13", "1 2 4 12", "7 10 6 5", "8 3 15 14"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 29: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 29: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test30() { vector<string> board = {"13 6 3 12", "16 4 14 5", "11 7 1 10", "8 15 9 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 30: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 30: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test31() { vector<string> board = {"6 5 15 4", "10 14 2 8", "3 7 12 9", "11 16 13 1"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 31: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 31: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test32() { vector<string> board = {"10 12 9 7", "13 11 6 8", "16 1 14 4", "3 15 5 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 32: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 32: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test33() { vector<string> board = {"2 9 13 1", "8 15 5 11", "16 12 3 14", "6 4 7 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 10; if(result == expected) { cout << "Test Case 33: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 33: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test34() { vector<string> board = {"11 4 5 13", "3 14 15 9", "12 8 16 6", "2 1 7 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 2; if(result == expected) { cout << "Test Case 34: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 34: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test35() { vector<string> board = {"4 10 3 11", "14 2 15 7", "16 13 5 6", "1 8 9 12"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 12; if(result == expected) { cout << "Test Case 35: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 35: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test36() { vector<string> board = {"10 9 1 5", "12 11 4 13", "14 8 7 16", "3 2 15 6"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 8; if(result == expected) { cout << "Test Case 36: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 36: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test37() { vector<string> board = {"10 3 8 4", "14 7 16 1", "11 12 6 5", "15 9 13 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 37: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 37: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test38() { vector<string> board = {"7 3 8 10", "9 4 16 6", "12 11 1 14", "13 15 5 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 38: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 38: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test39() { vector<string> board = {"12 13 8 4", "5 3 14 9", "2 6 7 16", "10 1 11 15"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 4; if(result == expected) { cout << "Test Case 39: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 39: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test40() { vector<string> board = {"4 3 16 13", "6 10 9 7", "11 12 1 15", "2 5 14 8"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 40: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 40: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test41() { vector<string> board = {"8 5 14 9", "2 12 7 6", "15 4 13 3", "16 1 11 10"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 14; if(result == expected) { cout << "Test Case 41: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 41: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test42() { vector<string> board = {"9 8 3 1", "10 6 15 5", "12 7 4 11", "14 13 16 2"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 16; if(result == expected) { cout << "Test Case 42: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 42: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int test43() { vector<string> board = {"15 16 11 12", "10 13 4 7", "1 2 8 6", "9 5 3 14"}; ScoreDifference* pObj = new ScoreDifference(); clock_t start = clock(); int result = pObj->maximize(board); clock_t end = clock(); delete pObj; int expected = 6; if(result == expected) { cout << "Test Case 43: Passed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 0; } else { cout << "Test Case 43: Failed! Time: " << static_cast<double>(end-start)/CLOCKS_PER_SEC << " seconds" << endl; return 1; } } int main(int argc, char* argv[]) { int passed = 0; int failed = 0; test0() == 0 ? ++passed : ++failed; test1() == 0 ? ++passed : ++failed; test2() == 0 ? ++passed : ++failed; test3() == 0 ? ++passed : ++failed; test4() == 0 ? ++passed : ++failed; test5() == 0 ? ++passed : ++failed; test6() == 0 ? ++passed : ++failed; test7() == 0 ? ++passed : ++failed; test8() == 0 ? ++passed : ++failed; test9() == 0 ? ++passed : ++failed; test10() == 0 ? ++passed : ++failed; test11() == 0 ? ++passed : ++failed; test12() == 0 ? ++passed : ++failed; test13() == 0 ? ++passed : ++failed; test14() == 0 ? ++passed : ++failed; test15() == 0 ? ++passed : ++failed; test16() == 0 ? ++passed : ++failed; test17() == 0 ? ++passed : ++failed; test18() == 0 ? ++passed : ++failed; test19() == 0 ? ++passed : ++failed; test20() == 0 ? ++passed : ++failed; test21() == 0 ? ++passed : ++failed; test22() == 0 ? ++passed : ++failed; test23() == 0 ? ++passed : ++failed; test24() == 0 ? ++passed : ++failed; test25() == 0 ? ++passed : ++failed; test26() == 0 ? ++passed : ++failed; test27() == 0 ? ++passed : ++failed; test28() == 0 ? ++passed : ++failed; test29() == 0 ? ++passed : ++failed; test30() == 0 ? ++passed : ++failed; test31() == 0 ? ++passed : ++failed; test32() == 0 ? ++passed : ++failed; test33() == 0 ? ++passed : ++failed; test34() == 0 ? ++passed : ++failed; test35() == 0 ? ++passed : ++failed; test36() == 0 ? ++passed : ++failed; test37() == 0 ? ++passed : ++failed; test38() == 0 ? ++passed : ++failed; test39() == 0 ? ++passed : ++failed; test40() == 0 ? ++passed : ++failed; test41() == 0 ? ++passed : ++failed; test42() == 0 ? ++passed : ++failed; test43() == 0 ? ++passed : ++failed; cout << "Total Test Case: " << passed + failed << "; Passed: " << passed << "; Failed: " << failed << endl; return failed == 0 ? 0 : 1; } /******************************************************************************* * Top Submission URL: * http://community.topcoder.com/stat?c=problem_solution&cr=22660344&rd=10008&pm=6854 ******************************************************************************** #include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> using namespace std; vector<string> split( const string& s, const string& delim =" " ) { vector<string> res; string t; for ( int i = 0 ; i != s.size() ; i++ ) { if ( delim.find( s[i] ) != string::npos ) { if ( !t.empty() ) { res.push_back( t ); t = ""; } } else { t += s[i]; } } if ( !t.empty() ) { res.push_back(t); } return res; } vector<int> splitInt( const string& s, const string& delim =" " ) { vector<string> tok = split( s, delim ); vector<int> res; for ( int i = 0 ; i != tok.size(); i++ ) res.push_back( atoi( tok[i].c_str() ) ); return res; } #define FORV(i,v) for (int i=0;i<(v).size();++i) #define UPDATEU(a,b) if (a<(b)) a=(b) #define UPDATED(a,b) if (a>(b)) a=(b) class ScoreDifference { public: int maximize(vector <string> board) { short boards[16]; for (int i=0;i<4;i++) { vector<int> p; p=splitInt(board[i]); for (int j=0;j<4;j++) boards[i*4+j]=p[j]; } int best[65536]; best[0]=0; memset(best,0,sizeof(best)); for (int i=1;i<65536;i++) { best[i]=-200; for (int j=0;j<16;j++) if (move(i,j)) UPDATEU(best[i],boards[j]-best[i-(1<<j)]); } return best[65535]; } private: short place[16]; bool move(int stat,int pos) { if ((stat&(1<<pos))==0) return false; memset(place,0,sizeof(place)); fill(stat-(1<<pos),pos); if (place[0]||place[1]||place[2]||place[3]) return true; if (place[4]||place[8]||place[7]||place[11]) return true; if (place[12]||place[13]||place[14]||place[15]) return true; return false; } void fill(int stat,int pos) { if (place[pos]==1) return; place[pos]=1; if (pos>3) if ((stat&(1<<(pos-4)))==0) fill(stat,pos-4); if (pos<12) if ((stat&(1<<(pos+4)))==0) fill(stat,pos+4); if (pos%4!=0) if ((stat&(1<<(pos-1)))==0) fill(stat,pos-1); if (pos%4!=3) if ((stat&(1<<(pos+1)))==0) fill(stat,pos+1); } }; // Powered by FileEdit // Powered by CodeProcessor ******************************************************************************** *******************************************************************************/
[ "qiudejun@gmail.com" ]
qiudejun@gmail.com
b3c8af45721b50d67aea851b91180ff9025e9a6d
746162035bf4802803baa339e397181c9ee4cc2a
/dmoz-0.1/textgarden/Wlb2Bow/Wlb2Bow.cpp
76a3cee3dbae6a6fd24b515c98dabc11209b6128
[]
no_license
edgeflip/dmoz
648a1e1d07aa143d306fc07efaf94349ae3dead6
990d848174c538d72d7f84917a385c46237a8143
refs/heads/master
2021-01-17T18:28:50.378701
2014-01-09T21:39:29
2014-01-09T21:39:29
15,776,307
0
0
null
null
null
null
UTF-8
C++
false
false
2,082
cpp
#include "mine.h" int main(int argc, char* argv[]){ Try; // create environment Env=TEnv(argc, argv, TNotify::StdNotify); // get command line parameters Env.PrepArgs("Web-Log-Binary To Bag-Of-Words-Weights", -1); TStr InWlbFNm=Env.GetIfArgPrefixStr("-i:", "", "Input-WebLogBin-FileName"); TStr OutUsrBowFNm=Env.GetIfArgPrefixStr("-ousr:", "WebLogUsr.Bow", "Output-UserBow-FileName"); TStr OutUsrTxtBowFNm=Env.GetIfArgPrefixStr("-ousrtxt:", "WebLogUsrTxt.Bow", "Output-UserTextBow-FileName"); TStr OutUrlBowFNm=Env.GetIfArgPrefixStr("-ourl:", "WebLogUrl.Bow", "Output-UrlBow-FileName"); int MnUsrClicks=Env.GetIfArgPrefixInt("-mnusrc:", 10, "Min-User-Clicks"); int MnUrlClicks=Env.GetIfArgPrefixInt("-mnurlc:", 3, "Min-Url-Clicks"); TStr WebRootFPath=Env.GetIfArgPrefixStr("-webroot:", "", "Web-Root-Path"); if (Env.IsEndOfRun()){return 0;} // load web-log data PWebLog WebLog; if (!InWlbFNm.Empty()){ WebLog=TWebLog::LoadBin(InWlbFNm); } else { TExcept::Throw("No Input Web-Log-Binary File!"); } // create bag-of-words for users from document-text if ((!OutUsrTxtBowFNm.Empty())&&(!WebRootFPath.Empty())){ printf("*** Users <- Html-Docs\n"); PBowDocBs UsrHtmlBowDocBs= WebLog->GetUsrBowDocBsFromHtml(MnUsrClicks, WebRootFPath); printf("Saving to file '%s'... ", OutUsrTxtBowFNm.CStr()); UsrHtmlBowDocBs->SaveBin(OutUsrTxtBowFNm); printf("Done.\n"); } // create bag-of-words for users from urls if (!OutUsrBowFNm.Empty()){ printf("*** Users <- URLs\n"); PBowDocBs UsrBowDocBs=WebLog->GetUsrBowDocBsFromUrl(MnUsrClicks); printf("Saving to file '%s'... ", OutUsrBowFNm.CStr()); UsrBowDocBs->SaveBin(OutUsrBowFNm); printf("Done.\n"); } // create bag-of-words for urls from users if (!OutUrlBowFNm.Empty()){ printf("*** URLs <- Users\n"); PBowDocBs UrlBowDocBs=WebLog->GetUrlBowDocBsFromUsr(MnUrlClicks); printf("Saving to file '%s'... ", OutUrlBowFNm.CStr()); UrlBowDocBs->SaveBin(OutUrlBowFNm); printf("Done.\n"); } return 0; Catch; return 1; }
[ "f4nt@f4ntasmic.com" ]
f4nt@f4ntasmic.com
2620750489e94123e8f443803c243d36e8c90bd6
ea3df53a91227cc19255fe8b59c276e0d6f26b39
/PLRP_V2_3/Code/Inicio.hpp
07fb350072183a58a465a23ffba5de4b95b825ce
[]
no_license
ljb193843/PLRP_v2
f9c5cc2a90b33e57a61308471e99a16e824220c5
51abe9bb2684e989d80a727cc8a6c08fe6fa0370
refs/heads/master
2021-04-12T08:06:56.355735
2017-11-26T22:57:01
2017-11-26T22:57:01
126,092,053
1
1
null
2018-03-20T22:44:00
2018-03-20T22:44:00
null
UTF-8
C++
false
false
1,600
hpp
double DistEuclidian(double X1, double Y1,double X2, double Y2){ return sqrt(pow((X2-X1),2)+pow((Y2-Y1),2)); } void Asignar_Costos(unmap_st_unmap &costos,unmap_C contenedores,unmap_D depositos){ //Parametros para distancia euclidiana double DX1,DY1,DX2,DY2,CX1,CY1,CX2,CY2,coste; //Iteradores para contenedores y depositos unmap_D_it d_it; unmap_C_it c_it; unmap_C_it c_it_2; string idD,idC,idC2; //Depositos a Contenedores for(d_it=depositos.begin();d_it!=depositos.end();d_it++){ idD = d_it->first; costos[idD]; for(c_it=contenedores.begin();c_it!=contenedores.end();c_it++){ idC = c_it->first; DX1 = d_it->second->get_X(); DY1 = d_it->second->get_Y(); CX2 = c_it->second->get_X(); CY2 = c_it->second->get_Y(); coste = DistEuclidian(DX1,DY1,CX2,CY2); costos[idC][idD] = coste; costos[idD][idC] = coste; //cout << "Dept :"+idD+" => "+idC+" " << coste << endl;; } } //Contenedores a Contenedores for(c_it=contenedores.begin();c_it!=contenedores.end();c_it++){ idC = c_it->first; costos[idC]; for(c_it_2=contenedores.begin();c_it_2!=contenedores.end();c_it_2++){ idC2 = c_it_2->first; CX1 = c_it->second->get_X(); CY1 = c_it->second->get_Y(); CX2 = c_it_2->second->get_X(); CY2 = c_it_2->second->get_Y(); coste = DistEuclidian(CX1,CY1,CX2,CY2); costos[idC][idC2] = coste; //cout << "Cont "+idC+" => "+idC2+" " << coste << endl; } } }
[ "jiflorescarrasco@hotmail.com" ]
jiflorescarrasco@hotmail.com
7e80ccecea5517579f72b8189e4582edf2b4b422
85b9ce4fb88972d9b86dce594ae4fb3acfcd0a4b
/build/iOS/Release/include/Fuse.Triggers.Actions.Resume.h
ad3fca6a93303c1c9e65298f88fbb7e701b36828
[]
no_license
bgirr/Global-Pot_App
16431a99e26f1c60dc16223fb388d9fd525cb5fa
c96c5a8fb95acde66fc286bcd9a5cdf160ba8b1b
refs/heads/master
2021-01-09T06:29:18.255583
2017-02-21T23:27:47
2017-02-21T23:27:47
80,985,681
0
0
null
2017-02-21T23:27:48
2017-02-05T10:29:14
C++
UTF-8
C++
false
false
737
h
// This file was generated based on C:\Users\EliteBook-User\AppData\Local\Fusetools\Packages\Fuse.Triggers\0.44.1\actions\$.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Triggers.Actions.PlaybackAction.h> namespace g{namespace Fuse{namespace Triggers{namespace Actions{struct Resume;}}}} namespace g{namespace Fuse{struct Node;}} namespace g{ namespace Fuse{ namespace Triggers{ namespace Actions{ // public sealed class Resume :464 // { ::g::Fuse::Triggers::Actions::TriggerAction_type* Resume_typeof(); void Resume__Perform_fn(Resume* __this, ::g::Fuse::Node* target); struct Resume : ::g::Fuse::Triggers::Actions::PlaybackAction { }; // } }}}} // ::g::Fuse::Triggers::Actions
[ "girr.benjamin@gmail.com" ]
girr.benjamin@gmail.com
1a3e037e58ce9b6f6ddbae7f6b3a39dfab6e5cb6
e530eef8b1e5f6fd001ad2cb69b1ed0bb201eeea
/Matlab Altered/pdistmex.cpp
5cdd2fed606c9702a2ee5c9cf5cbc96cf1a14f8a
[ "AFL-3.0" ]
permissive
dtbinh/gene-armada
099f51b40d0090229c5a9198a2e269f813492a9d
6d2a624f7a2d05e292201b6120761677866e9449
refs/heads/master
2021-01-17T05:59:53.717597
2016-09-29T13:47:26
2016-09-29T13:47:26
83,699,071
1
0
null
2017-03-02T16:23:07
2017-03-02T16:23:07
null
UTF-8
C++
false
false
12,447
cpp
/* * pdistmex.cpp * * Calculates pairwise distances between observations. * Helper function to pdist.m * * This is a MEX-file for MATLAB. * Copyright 1993-2006 The MathWorks, Inc. */ /* $Revision: 1.1.6.4 $ $Date: 2006/11/11 22:57:35 $ */ #include "mex.h" #include <math.h> #include <string.h> /* Euclidean distance */ template<class T> void eucdist(T *x, mwSize m, mwSize n, T *d) { /* d = sqrt(sum((XI-XJ).^2,2)); % Euclidean */ mwIndex i,j,k; T theSum,Y; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ Y = (*XI)-(*XJ); theSum += Y*Y; } *(d++) = (T)sqrt(theSum); } } } /* Standardized Euclidean distance */ template<class T> void seudist(T *x, mwSize m, mwSize n, T *arg, T *d) { /* d = sqrt(((XI-XJ).^2) * arg); % Standardized Euclidean */ /* arg is a column vector of 1/var(X) */ mwIndex i,j,k; T theSum,Y; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ Y = (*XI)-(*XJ); theSum += Y*Y*(*(arg+k)); } *(d++) = (T)sqrt(theSum); } } } /* City Block Distance */ template<class T> void citdist(T *x, mwSize m, mwSize n, T *d) { /* d = sum(abs((XI-XJ)),2); % City Block */ mwIndex i,j,k; T theSum,Y; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ Y = (*XI)-(*XJ); theSum += (T)fabs(Y); } *(d++) = theSum; } } } /* Mahalanobis distance */ template<class T> void mahdist(T *x, mwSize m, mwSize n, T *arg, T *d) { /* Y = XI - XJ; d = sqrt(sum((Y*arg).*Y,2)); % Mahalanobis */ /* arg is inv(cov(X)) */ mwIndex i,j,k,l; T theSum, inner,Y,YY; T *XXI, *XXJ; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (l=0;l<n; l++,XI++,XJ++){ XXJ = x+j*n; XXI = x+i*n; inner = 0; for (k=0;k<n;k++,XXI++,XXJ++){ YY = (*XXI)-(*XXJ); inner += YY*arg[k+l*n]; } Y = (*XI)-(*XJ); theSum += inner * Y; } *(d++) = (T)sqrt(theSum); } } } /* Minkowski distance */ template<class T> void mindist(T *x, mwSize m, mwSize n, T arg, T *d) { /* d = sum(abs((XI-XJ)).^arg,2).^(1/arg); % Minkowski */ mwIndex i,j,k; T theSum,Y; T argRecip = 1/arg; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ Y = (T)fabs((*XI)-(*XJ)); theSum += (T)pow(Y,arg); } *(d++) = (T)pow(theSum,argRecip); } } } /* Cosine and Correlation distances */ template<class T> void coscordist(T *x, mwSize m, mwSize n, T *d) { /* d = 1 - sum(XI.*XJ,2); % Cosine & Corr & RankCorr */ /* This actually calculates the dot product of pairs of vectors. It * assumes that the data have been properly preprocessed: ranked for * Spearman's rank correlation distance, normalized to zero mean for * both linear and rank correlation distances, and normalized to unit * length for all three distances. */ mwIndex i,j,k; T theSum; T *XI, *XJ, *XI0; XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ theSum += (*XI)*(*XJ); } /* theSum may overshoot 1 due to round-off, protect against * that without overwriting NaNs */ *(d++) = theSum>1 ? 0 : 1-theSum; } } } /* Hamming distance */ template<class T> void hamdist(T *x, mwSize m, mwSize n, T *d) { /* d = sum(XI ~= XJ,2) / size(XI,2); % Hamming */ mwIndex i,j,k; T theSum; T *XI, *XJ, *XI0; T *theNaN = (T*)mxCalloc(m,sizeof(T)); /* Determine which rows of X have missing data. */ XI = x; for (i=0; i<m; i++) { for (k=0;k<n;k++,XI++) if (mxIsNaN(*XI)) theNaN[i] = *XI; } XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; /* If XI or XJ have missing data, set their distance to NaN. */ if (theNaN[i] || theNaN[j]) { XI += n; XJ += n; *(d++) = theNaN[i] + theNaN[j]; } else { theSum = 0; for (k=0;k<n;k++,XI++,XJ++){ if ((*XI)!=(*XJ)) { theSum++; } } *(d++) = theSum/n; } } } mxFree(theNaN); } /* Jaccard distance */ template<class T> void jacdist(T *x, mwSize m, mwSize n, T *d) { /* nz = XI ~= 0 | XJ ~= 0; ne = XI ~= XJ; d = sum(ne&nz,2) ./ sum(nz,2); % Jaccard */ mwIndex i,j,k; T theSum,nz; T *XI, *XJ, *XI0; T *theNaN = (T*)mxCalloc(m,sizeof(T)); /* Determine which rows of X have missing data. */ XI = x; for (i=0; i<m; i++) { for (k=0;k<n;k++,XI++) if (mxIsNaN(*XI)) theNaN[i] = *XI; } XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; /* If XI or XJ have missing data, set their distance to NaN. */ if (theNaN[i] || theNaN[j]) { XI += n; XJ += n; *(d++) = theNaN[i] + theNaN[j]; } else { theSum = 0; nz = 0; for (k=0;k<n;k++,XI++,XJ++){ if ((*XI) || (*XJ)) { nz++; if ((*XI)!=(*XJ)) { theSum++; } } } if (nz) { *(d++) = theSum/nz; } else { *(d++) = (T)mxGetNaN(); } } } } mxFree(theNaN); } /* Chebychev distance */ template<class T> void chedist(T *x, mwSize m, mwSize n, T *d) { /* d = max(abs(XI-XJ),[],2); */ mwIndex i,j,k; T theMax,Y; T *XI, *XJ, *XI0; T *theNaN = (T*)mxCalloc(m,sizeof(T)); /* Determine which rows of X have missing data. */ XI = x; for (i=0; i<m; i++) { for (k=0;k<n;k++,XI++) if (mxIsNaN(*XI)) theNaN[i] = *XI; } XI = x; for (i=0; i<m; i++) { XI0 = XI; XJ = XI+n; for (j=i+1; j<m; j++) { /* XI = x + i*n; XJ = x + j*n; */ XI = XI0; /* If XI or XJ have missing data, set their distance to NaN. */ if (theNaN[i] || theNaN[j]) { XI += n; XJ += n; *(d++) = theNaN[i] + theNaN[j]; } else { theMax = 0; for (k=0;k<n;k++,XI++,XJ++){ Y = (T)fabs((*XI)-(*XJ)); if (Y>theMax) { theMax = Y; } } *(d++) = theMax; } } } mxFree(theNaN); } /* the dispatcher function */ template<class T> void distfun(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[], T classDummy) { int status; mwSize numCoords,numPoints; char metric[4]; T *x,*d,*arg,scalarArg; /* get the metric */ status = mxGetString(prhs[1],metric,4); /* create a pointer to the input matrix y */ x = (T*)mxGetData(prhs[0]); /* get the dimensions of the matrix input y */ numCoords = mxGetM(prhs[0]); numPoints = mxGetN(prhs[0]); /* get extra arg */ if (nrhs>2 && !mxIsEmpty(prhs[2])) { if (mxGetNumberOfElements(prhs[2]) == 1) { /*scalar case */ scalarArg = (T)mxGetScalar(prhs[2]); } else if (mxGetClassID(prhs[2]) == mxGetClassID(prhs[0])) { arg = (T*)mxGetData(prhs[2]); } else { mexErrMsgIdAndTxt("stats:pdistmex:MixedInputTypes", "Additional input arguments must be the same class as X."); } } /* make sure that the distance matrix can be created, then create it. doing * this in double remains exact except in the cases where we error out anyway. */ double numDists = ((double)numPoints * (double)(numPoints-1)) / 2; if (numDists >= (double)MWSIZE_MAX) { mexErrMsgIdAndTxt("stats:pdistmex:OutputTooLarge", "Distance matrix has more elements than the maximum allowed size in MATLAB."); } plhs[0] = mxCreateNumericMatrix(1, (mwSize)numDists, mxGetClassID(prhs[0]), mxREAL); /* create a pointer to a copy of the output matrix */ d = (T*)mxGetData(plhs[0]); /* call the appropriate distance subroutine */ if (strcmp(metric,"euc") == 0) eucdist(x,numPoints,numCoords,d); else if(strcmp(metric,"seu") == 0) seudist(x,numPoints,numCoords,arg,d); else if(strcmp(metric,"cit") == 0) citdist(x,numPoints,numCoords,d); else if(strcmp(metric,"min") == 0) mindist(x,numPoints,numCoords,scalarArg,d); else if(strcmp(metric,"cos") == 0) coscordist(x,numPoints,numCoords,d); else if(strcmp(metric,"cor") == 0) coscordist(x,numPoints,numCoords,d); else if(strcmp(metric,"spe") == 0) coscordist(x,numPoints,numCoords,d); else if(strcmp(metric,"ham") == 0) hamdist(x,numPoints,numCoords,d); else if(strcmp(metric,"jac") == 0) jacdist(x,numPoints,numCoords,d); else if(strcmp(metric,"che") == 0) chedist(x,numPoints,numCoords,d); else if(strcmp(metric,"mah") == 0) mahdist(x,numPoints,numCoords,arg,d); } /* the gateway function */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { /* check for proper number of arguments */ if (nrhs<2) { mexErrMsgIdAndTxt("stats:pdistmex:TooFewInputs", "Two input arguments required."); } else if(nlhs>1) { mexErrMsgIdAndTxt("stats:pdistmex:TooManyOutputs", "Too many output arguments."); } /* Check the type of the input array */ /* Currently only works with double or single(float) */ if (mxIsDouble(prhs[0])) { distfun(nlhs, plhs, nrhs, prhs, (double)1.0); } else if (mxIsSingle(prhs[0])) { distfun(nlhs, plhs, nrhs, prhs, (float)1.0); } else { mexErrMsgIdAndTxt("stats:pdistmex:BadInputType", "PDISTMEX only supports real DOUBLE and SINGLE data."); } }
[ "pmoulos@gmail.com@ac212d5f-9eb8-a257-c634-f571048ff109" ]
pmoulos@gmail.com@ac212d5f-9eb8-a257-c634-f571048ff109
11c0b33d9ebdb8eac8e1af01eb60187fa7dd4299
573a66e4f4753cc0f145de8d60340b4dd6206607
/JS-CS-Detection-byExample/Dataset (ALERT 5 GB)/899902/osquery-1.6.0/osquery-1.6.0/osquery/dispatcher/distributed.h
ba715a4a252aff04ed2b3619c993e39344662a49
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "BSD-3-Clause" ]
permissive
mkaouer/Code-Smells-Detection-in-JavaScript
3919ec0d445637a7f7c5f570c724082d42248e1b
7130351703e19347884f95ce6d6ab1fb4f5cfbff
refs/heads/master
2023-03-09T18:04:26.971934
2022-03-23T22:04:28
2022-03-23T22:04:28
73,915,037
8
3
null
2023-02-28T23:00:07
2016-11-16T11:47:44
null
UTF-8
C++
false
false
686
h
/* * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #pragma once #include "osquery/dispatcher/dispatcher.h" namespace osquery { /// A Dispatcher service thread that implements the distributed query service class DistributedRunner : public InternalRunnable { public: virtual ~DistributedRunner() {} DistributedRunner() {} public: /// The Dispatcher thread entry point. void start(); }; Status startDistributed(); }
[ "mmkaouer@umich.edu" ]
mmkaouer@umich.edu
5f2f51c50117dcd2950955aaab549a9835f0cad1
5f0dc6b8bba6bdacd8128ab86ca308e6a80c4246
/Simplenote/base64.cpp
57ea6437212f509b7d513335ea39101d45182ad8
[]
no_license
pr0v3rbs/Simplenote
4ddef7c960a5b62ce4fbf919b40a34b890c9b349
b121867fa45c3b877edff5ee1e3b62f5be2d54f8
refs/heads/master
2021-01-19T04:06:58.171302
2016-05-02T15:53:24
2016-05-02T15:53:24
61,016,972
0
0
null
null
null
null
UTF-8
C++
false
false
2,995
cpp
#include "stdafx.h" #include "base64.h" #include <iostream> static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789+/"; static inline bool is_base64(unsigned char c) { return (isalnum(c) || (c == '+') || (c == '/')); } std::string Base64Encode(unsigned char const* bytes_to_encode, unsigned int in_len) { std::string ret; int i = 0; int j = 0; unsigned char char_array_3[3]; unsigned char char_array_4[4]; while (in_len--) { char_array_3[i++] = *(bytes_to_encode++); if (i == 3) { char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); char_array_4[3] = char_array_3[2] & 0x3f; for (i = 0; (i <4); i++) ret += base64_chars[char_array_4[i]]; i = 0; } } if (i) { for (j = i; j < 3; j++) char_array_3[j] = '\0'; char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); char_array_4[3] = char_array_3[2] & 0x3f; for (j = 0; (j < i + 1); j++) ret += base64_chars[char_array_4[j]]; while ((i++ < 3)) ret += '='; } return ret; } std::string Base64Decode(std::string const& encoded_string) { int in_len = encoded_string.size(); int i = 0; int j = 0; int in_ = 0; unsigned char char_array_4[4], char_array_3[3]; std::string ret; while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { char_array_4[i++] = encoded_string[in_]; in_++; if (i == 4) { for (i = 0; i <4; i++) char_array_4[i] = static_cast<char>(base64_chars.find(char_array_4[i])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; for (i = 0; (i < 3); i++) ret += char_array_3[i]; i = 0; } } if (i) { for (j = i; j <4; j++) char_array_4[j] = 0; for (j = 0; j <4; j++) char_array_4[j] = static_cast<char>(base64_chars.find(char_array_4[j])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; } return ret; }
[ "rla5072@paran.com" ]
rla5072@paran.com
6549b66d2a2abec641dfd737798180117c3457ff
2449603b9fbb260ff4ab260ba17440605e96ad33
/main.cpp
8f0bfa180a104177f573ccee9a3f75d935c1163f
[]
no_license
99saugat/CPP_Project
73d5d26bddec8e43377201e460194a4e904d00b0
e55b7fbf126939818088f4aa472d927a2f7bbc26
refs/heads/main
2023-07-17T06:33:13.270050
2021-08-25T05:09:01
2021-08-25T05:09:01
382,529,106
0
2
null
null
null
null
UTF-8
C++
false
false
7,648
cpp
/* ***This program prints the truth table of a given expression.*** Written by Saugat Baral(076BEL041) of the group PRSS for object oriented programming project. If you find any problems, please mail me at 99saugat@gmail.com Expressions that have been tested to work: A&B A|B !A&B A&!B !A&!B !A|!B A&B&C !A&B|C !A&B&!C Some homework problems that work in this program and which we did in DL classes: (A&B)|(A&!C)|(B&!C) (A&!B)|(!C&D)|(A&B&!D)|(!A&!B&D) (!A&B)|C (!A&!B)|(!B&C)|(A&B) For debugging purposes: for(int i=0;i<e.length;i++) { cout<<a[i]; } */ #include<iostream> #include<cmath> #include<string> using namespace std; #include "expression.h" #include "kmap.h" //reads expression from the place, where operator is detected void read_expression(int a[], int temp[], int j, int length) { for(int k = 0; k < length-j; k++) { temp[k] = a[j+k]; } } //modifies expression after assigning numerical value to operator void modify_expression(int a[], int temp[], int j, int length) { for(int k = 0; k < length-j; k++) { a[j+k+1] = temp[k]; } } //function to apply not operator void apply_not(int a[], int j, expression e) { if(a[j]==2 ) { a[j] = !a[j+1]; for(int k = j; k < e.length-j; k++) { a[k+1] = a[k+2]; } for(int k=e.length-j+2;k<e.length;k++) { a[k] = 0; } } } //modifies expression after using certain operator with given operands void modify_expression(int a[], int &j, int length) { for(int k=j; k<length-j;k++) { a[k] = a[k+2]; } for(int k=length-j;k<length;k++) { a[k] = 0; } j-=1; } //finds next bracket from the position where first bracket is detected int find_next_bracket(int a[], int i, int length) { for(int j=i+1; j<length; j++) { if(a[j]==5) { return j; } } } //removes brackets; to be used after manipulation expressions inside bracket void remove_brackets(int a[], int i, expression e) { int next_bracket = find_next_bracket(a, i, e.length); for(int j = 0; j < next_bracket; j++) { if(a[j] == 5) { for(int k = j; k < e.length; k++) { a[k] = a[k+1]; } } } } //all possible binary values by decimal to binary conversion void value_to_variables(int a[], int temp[], int number_of_variables, int n) { for(int j=number_of_variables-1; n>0; j--) { temp[0] = a[j]; a[j] = n%2; a[j-1] = temp[0]; n = n/2; } for(int j=0; j<number_of_variables; j++) { cout<<a[j]<<"\t"; } } //copies variable values only from source to destination void copy_variable_value_only(int source[], int destination[], int number_of_variables) { for(int j=0; j<number_of_variables; j++) { destination[j] = source[j]; } } //converting string to number void string_to_number(int a[], int b[], int temp[], int number_of_variables, expression& e) { for(int j = 0; j < e.length; j++) { switch(e.expression[j]) { case '!': read_expression(a, temp, j, e.length); a[j] = 2; modify_expression(a, temp, j, e.length); break; case '&': read_expression(a, temp, j, e.length); a[j] = 3; modify_expression(a, temp, j, e.length); break; case '|': read_expression(a, temp, j, e.length); a[j] = 4; modify_expression(a, temp, j, e.length); break; case '(': read_expression(a, temp, j, e.length); a[j] = 5; modify_expression(a, temp, j, e.length); break; case ')': read_expression(a, temp, j, e.length); a[j] = 5; modify_expression(a, temp, j, e.length); break; } } for(int j=0; j<number_of_variables; j++) { for(int k = 0; k<e.length;k++) { if(e.expression[k] == e.single_variable[j]) { a[k] = b[j]; } } } } int main() { expression e; e.get(); e.analyze(); int number_of_variables = e.n; int total = pow(2, number_of_variables); int result[total] = {0}; int b[number_of_variables] = {0}; for(int i = 0; i < total; i++) { int n = i; int a[e.length] = {0}; int temp[e.length] = {0}; value_to_variables(a, temp, number_of_variables, n); copy_variable_value_only(a, b, number_of_variables); string_to_number(a, b, temp, number_of_variables, e); //String Manipulation from numbers //Brackets int next_bracket = 0; for(int i = 0; i < e.length; i++) { if(a[i]==5 ) { next_bracket = find_next_bracket(a, i, e.length); for(int j = i+1; j < next_bracket; j++) { apply_not(a, j, e); next_bracket = find_next_bracket(a, i, e.length); } next_bracket = find_next_bracket(a, i, e.length); for(int j = i+1; j < next_bracket; j++) { next_bracket = find_next_bracket(a, i, e.length); switch(a[j]) { case(3): a[j-1] = a[j-1]&&a[j+1]; modify_expression(a, j, e.length); break; case(4): a[j-1] = a[j-1]||a[j+1]; modify_expression(a, j, e.length); break; } } remove_brackets(a, i, e); } } //after brackets are solved; for remaining expressions for(int j = 0; j < e.length; j++) { apply_not(a, j, e); } for(int j = 0; j < e.length; j++) { switch(a[j]) { case(3): a[j-1] = a[j-1]&&a[j+1]; modify_expression(a, j, e.length); break; case(4): a[j-1] = a[j-1]||a[j+1]; modify_expression(a, j, e.length); break; } } cout<<a[0]; result[i] = a[0]; cout<<endl<<endl; } //Printing KMAP when number of veriable = 4 if(number_of_variables == 4) { input k; int position = 0; k.var = number_of_variables; for(int s=0; s<16; s++) { if(result[s] == 1) { position++; } } k.terms = position; position = 0; for(int s=0; s<16; s++) { if(result[s] == 1) { k.a4[position] = s; position++; } } k.getdata(); k.exchange(); cout<<endl<<"*******PRINTING KMAP*******"<<endl<<endl; k.display(); k.grouping(); } return 0; }
[ "99saugat@gmail.com" ]
99saugat@gmail.com
31a07800940fad17c94bee6c6059a5cb58ca5895
5614db0bbf44e9e725994fd63adfd122b99c5146
/include/tvm/tir/transform.h
9d55db57101651b8404397b2a42488e10cc74e84
[ "Apache-2.0", "Zlib", "MIT", "LicenseRef-scancode-unknown-license-reference", "Unlicense", "BSD-2-Clause" ]
permissive
jjohnson-arm/incubator-tvm
da28f20dad8ac77d7d8f2c8dfe1acc2944b7cd59
2b6d69c62c07acc102c6ca42ee5c4edcc3de41f1
refs/heads/master
2021-02-15T17:41:24.950462
2020-04-01T02:44:41
2020-04-01T02:44:41
243,564,621
0
0
Apache-2.0
2020-02-27T16:37:04
2020-02-27T16:37:03
null
UTF-8
C++
false
false
2,769
h
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you 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. */ /*! * \file tvm/tir/transform.h * \brief TIR specific transformation passes. */ #ifndef TVM_TIR_TRANSFORM_H_ #define TVM_TIR_TRANSFORM_H_ #include <tvm/ir/transform.h> #include <tvm/tir/expr.h> #include <tvm/tir/function.h> #include <string> namespace tvm { namespace tir { namespace transform { using tvm::transform::Pass; using tvm::transform::PassNode; using tvm::transform::PassInfo; using tvm::transform::PassInfoNode; using tvm::transform::PassContext; using tvm::transform::PassContextNode; using tvm::transform::Sequential; /* * \brief Create a function pass that optimizes PrimFuncs. * * \param pass_func The packed function that contains the optimization. * \param opt_level The optimization level of the function pass. * \param name The name of the function pass. * \param required The list of the passes that the function pass is dependent on. * * \return The created function pass. */ TVM_DLL Pass CreatePrimFuncPass(const runtime::TypedPackedFunc< PrimFunc(PrimFunc, IRModule, PassContext)>& pass_func, int opt_level, const std::string& name, const tvm::Array<tvm::PrimExpr>& required); /*! * \brief Combine context calls in the host function. * * \return The pass. */ TVM_DLL Pass CombineContextCall(); /*! * \brief Lower the target specific function intrinsics in each of the function. * * \return The pass. */ TVM_DLL Pass LowerIntrin(); /*! * \brief Lower attached storage access information on device. * * \note Run this pass after all storage access analysis finish. * * \return The pass. */ TVM_DLL Pass LowerDeviceStorageAccessInfo(); /*! * \brief Lower warp memory access to low-level device related function calls. * \return The pass. */ TVM_DLL Pass LowerWarpMemory(); } // namespace transform } // namespace tir } // namespace tvm #endif // TVM_TIR_TRANSFORM_H_
[ "noreply@github.com" ]
jjohnson-arm.noreply@github.com
09f6272e95f100d0911c1dcd546b3286d517fb94
e21f1f02f68f150771269bea6e4599e7bde6cb17
/RatEngine/Source/Engine/DeviceContext.cpp
5720922d84dfb2941516c3763b51731108873e3e
[]
no_license
virusmarathe/RatEngineECS
b604532dfcbd2fe6a80e546e7e5d41d91740ebbc
bb2c6751cb50dbba7d65de2632151641aa15d34c
refs/heads/master
2022-10-27T23:23:44.186276
2020-06-14T05:54:26
2020-06-14T05:54:26
257,109,654
1
0
null
null
null
null
UTF-8
C++
false
false
3,165
cpp
#include "DeviceContext.h" #include "SwapChain.h" #include "VertexBuffer.h" #include "VertexShader.h" #include "PixelShader.h" #include "ConstantBuffer.h" #include "IndexBuffer.h" #include "Texture.h" #include <exception> DeviceContext::DeviceContext(ID3D11DeviceContext* context, RenderSystem* system) : m_DeviceContext(context), m_RenderSystem(system) { } DeviceContext::~DeviceContext() { m_DeviceContext->Release(); } void DeviceContext::clearRenderTargetColor(SwapChain* swapChain, float r, float g, float b, float a) { FLOAT clearColor[] = {r, g, b, a}; m_DeviceContext->ClearRenderTargetView(swapChain->m_RenderTargetView, clearColor); m_DeviceContext->ClearDepthStencilView(swapChain->m_DepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1, 0); m_DeviceContext->OMSetRenderTargets(1, &swapChain->m_RenderTargetView, swapChain->m_DepthStencilView); } void DeviceContext::setVertexBuffer(VertexBuffer* vbuffer) { UINT stride = vbuffer->m_VertexSize; UINT offset = 0; m_DeviceContext->IASetVertexBuffers(0, 1, &vbuffer->m_VertexBuffer, &stride, &offset); } void DeviceContext::drawTriangleList(UINT vertexCount, UINT startVertexIndex) { m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_DeviceContext->Draw(vertexCount, startVertexIndex); } void DeviceContext::drawIndexedTriangleList(UINT indexCount, UINT startVertexIndex, UINT startIndexLocation) { m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_DeviceContext->DrawIndexed(indexCount, startIndexLocation, startVertexIndex); } void DeviceContext::drawTriangleStrip(UINT vertexCount, UINT startVertexIndex) { m_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); m_DeviceContext->Draw(vertexCount, startVertexIndex); } void DeviceContext::setViewportSize(FLOAT width, FLOAT height) { D3D11_VIEWPORT vp = {}; vp.Width = width; vp.Height = height; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; m_DeviceContext->RSSetViewports(1, &vp); } void DeviceContext::setInputLayout(ID3D11InputLayout* inputLayout) { m_DeviceContext->IASetInputLayout(inputLayout); } void DeviceContext::setVertexShader(VertexShader* vs) { m_DeviceContext->VSSetShader(vs->m_Shader, nullptr, 0); } void DeviceContext::setPixelShader(PixelShader* ps) { m_DeviceContext->PSSetShader(ps->m_PixelShader, nullptr, 0); } void DeviceContext::setTexture(VertexShader* vs, const TexturePointer& texture) { m_DeviceContext->VSSetShaderResources(0, 1, &texture->m_ShaderResourceView); } void DeviceContext::setTexture(PixelShader* ps, const TexturePointer& texture) { m_DeviceContext->PSSetShaderResources(0, 1, &texture->m_ShaderResourceView); } void DeviceContext::setConstantBuffer(VertexShader* vs, ConstantBuffer* constantBuf) { m_DeviceContext->VSSetConstantBuffers(0, 1, &constantBuf->m_Buffer); } void DeviceContext::setConstantBuffer(PixelShader* ps, ConstantBuffer* constantBuf) { m_DeviceContext->PSSetConstantBuffers(0, 1, &constantBuf->m_Buffer); } void DeviceContext::setIndexBuffer(IndexBuffer* iBuffer) { m_DeviceContext->IASetIndexBuffer(iBuffer->m_IndexBuffer, DXGI_FORMAT_R32_UINT, 0); }
[ "virusmarathe@gmail.com" ]
virusmarathe@gmail.com
4af41fef54cc97f257b4d26ae5a092843ad56f1f
fd02283e58d39c4e4068b98c02720ca4c5c176f2
/windows/wrapper/impl_org_webRtc_RTCAnswerOptions.cpp
040ac2461328bf7f9e2f48341d9f4c46ac62ddc3
[ "BSD-3-Clause" ]
permissive
fibann/webrtc-apis
4dbfd3c3fc962250718be0e82a850e784dad6740
0d303d62f7e6483cf4b57c24ef295c487b0c28dd
refs/heads/master
2021-08-18T05:56:40.132259
2019-05-07T15:55:13
2019-05-07T15:55:13
214,481,189
0
0
BSD-3-Clause
2019-10-11T16:21:52
2019-10-11T16:21:52
null
UTF-8
C++
false
false
3,308
cpp
#include "impl_org_webRtc_RTCAnswerOptions.h" #include "impl_org_webRtc_RTCOfferAnswerOptions.h" using ::zsLib::String; using ::zsLib::Optional; using ::zsLib::Any; using ::zsLib::AnyPtr; using ::zsLib::AnyHolder; using ::zsLib::Promise; using ::zsLib::PromisePtr; using ::zsLib::PromiseWithHolder; using ::zsLib::PromiseWithHolderPtr; using ::zsLib::eventing::SecureByteBlock; using ::zsLib::eventing::SecureByteBlockPtr; using ::std::shared_ptr; using ::std::weak_ptr; using ::std::make_shared; using ::std::list; using ::std::set; using ::std::map; // borrow definitions from class ZS_DECLARE_TYPEDEF_PTR(wrapper::impl::org::webRtc::RTCAnswerOptions::WrapperImplType, WrapperImplType); ZS_DECLARE_TYPEDEF_PTR(WrapperImplType::WrapperType, WrapperType); ZS_DECLARE_TYPEDEF_PTR(WrapperImplType::NativeType, NativeType); ZS_DECLARE_TYPEDEF_PTR(wrapper::impl::org::webRtc::RTCOfferAnswerOptions, UseOfferAnswerOptions); //------------------------------------------------------------------------------ wrapper::impl::org::webRtc::RTCAnswerOptions::RTCAnswerOptions() noexcept { } //------------------------------------------------------------------------------ wrapper::org::webRtc::RTCAnswerOptionsPtr wrapper::org::webRtc::RTCAnswerOptions::wrapper_create() noexcept { auto pThis = make_shared<wrapper::impl::org::webRtc::RTCAnswerOptions>(); pThis->thisWeak_ = pThis; return pThis; } //------------------------------------------------------------------------------ wrapper::impl::org::webRtc::RTCAnswerOptions::~RTCAnswerOptions() noexcept { thisWeak_.reset(); } //------------------------------------------------------------------------------ void wrapper::impl::org::webRtc::RTCAnswerOptions::wrapper_init_org_webRtc_RTCAnswerOptions() noexcept { } //------------------------------------------------------------------------------ void wrapper::impl::org::webRtc::RTCAnswerOptions::wrapper_init_org_webRtc_RTCAnswerOptions(wrapper::org::webRtc::RTCAnswerOptionsPtr source) noexcept { } //------------------------------------------------------------------------------ static void apply(const NativeType &from, WrapperImplType &to) { UseOfferAnswerOptions::apply(from, to); } //------------------------------------------------------------------------------ static void apply(const WrapperImplType &from, NativeType &to) { UseOfferAnswerOptions::apply(from, to); } //------------------------------------------------------------------------------ WrapperImplTypePtr WrapperImplType::toWrapper(const NativeType &native) noexcept { auto result = make_shared<WrapperImplType>(); result->thisWeak_ = result; apply(native, *result); return result; } //------------------------------------------------------------------------------ WrapperImplTypePtr WrapperImplType::toWrapper(NativeTypePtr native) noexcept { if (!native) return WrapperImplTypePtr(); return toWrapper(*native); } //------------------------------------------------------------------------------ NativeTypePtr WrapperImplType::toNative(WrapperTypePtr wrapper) noexcept { if (!wrapper) return NativeTypePtr(); auto converted = ZS_DYNAMIC_PTR_CAST(WrapperImplType, wrapper); if (!converted) return NativeTypePtr(); auto cloned = make_shared<NativeType>(); apply(*converted, *cloned); return cloned; }
[ "robin@opticaltone.com" ]
robin@opticaltone.com
dbbe6957445aa120b80890578e2c9f88de41f7f9
d648ec8afd48bc3c5af7199fb94c3db7ce81145a
/src/TItleMake3D/TItleMake3D/src/MyTriangle.cpp
e98fda4ec1791a44888106e567d2923270211c14
[]
no_license
Tukamotosan/TitleViewer
bf32e2489e381da0f03ae231f597fdcf62f41168
1686ee2e78a3bb5524f79d3c509bb5e8d402b38c
refs/heads/master
2020-12-25T14:38:28.584622
2016-07-06T14:40:44
2016-07-06T14:40:44
62,727,479
0
0
null
null
null
null
UTF-8
C++
false
false
301
cpp
#include "MyTriangle.h" MyTriangle::MyTriangle(void) { p1.x = 0.0f;p1.y = 0.0f;p1.z = 0.0f; p2.x = 0.0f;p2.y = 0.0f;p2.z = 0.0f; p3.x = 0.0f;p3.y = 0.0f;p3.z = 0.0; c1.r = 0; c1.g = 0; c1.b = 0; c2.r = 0; c2.g = 0; c2.b = 0; c3.r = 0; c3.g = 0; c3.b = 0; } MyTriangle::~MyTriangle(void) { }
[ "mamoru tsukamoto" ]
mamoru tsukamoto
8bdb741849b3b2b23205dde431fdbd5b4a869ee4
345c6399cfaa444018f1a3bb8c89064605f8acbd
/Kth Smallest Element in the Array.cpp
c24209d76f27cd61568c2af57dec7a618780b08d
[]
no_license
baapji/IBSolution-Git
8be865127864ca769c0fa4e12b418e46629b308e
8f2d5215911d05438fbe878e3fa3e8778fb2a63c
refs/heads/master
2020-07-29T15:30:56.965335
2019-09-29T08:56:53
2019-09-29T08:56:53
209,862,088
1
0
null
null
null
null
UTF-8
C++
false
false
711
cpp
// https://www.interviewbit.com/problems/kth-smallest-element-in-the-array/ int Solution::kthsmallest(const vector<int> &A, int k) { if (k > A.size()) return -1; int lo = *min_element(A.begin(), A.end()); int hi = *max_element(A.begin(), A.end()); while (lo <= hi) { int mid = lo + (hi - lo)/2; int countLess = 0, countEqual = 0; for (auto i = 0; i<A.size(); ++i) { if (A[i]<mid) ++countLess; else if (A[i] == mid) ++countEqual; if (countLess >= k) break; } if (countLess < k && countLess + countEqual >= k) return mid; else if (countLess >= k) hi = mid - 1; else lo = mid + 1; } return -1; }
[ "noreply@github.com" ]
baapji.noreply@github.com
0352ce481821b3bdb5ec17e2fe8c6653ef971add
9430abe2cca18ce9a51be49c438629a37628bc9e
/排序/快速排序.cpp
49095f8f29af90f29e6b36b509e7b6067a80d937
[]
no_license
steamqaqwq/dataStruct
760b2b23673cf6ac55e3efe0a4400608b052f1b8
92039a04d5437cd946b1ef7ba833315a450e8474
refs/heads/main
2023-04-02T11:51:02.251319
2021-04-09T00:52:16
2021-04-09T00:52:16
348,330,625
0
0
null
null
null
null
UTF-8
C++
false
false
2,395
cpp
#include <stdio.h> // 重点!!!!!!!! // 思路 拿一个数抽出当基准,就空出一个 右小于基准 // 快速排序 low基准 分左右 low<基准<high // 左空右移 low==high基准元素找出位置 // 左右字表 再次递归排序 //--------------------------- // 选取元素 头中尾对比挑/随机挑 // 算法效率 划分均匀 递归深度小 算法效率高 // 时间复杂度 = O(n*递归层数) 空间复杂度=O(递归层数) // 最好时间复杂度=O(nlog2n) #每次基准元素均匀划分 // 最坏时间复杂度=O(n^2) #序列本有序/逆序 // 最好空间复杂度=O(log2n) // 最坏空间复杂度=O(n) // 平均时间复杂度=O(nlog2n) 平均最优排序算法 // 稳定性: 不稳定 #稳定方向要对 int Partition(int a[], int low, int high) { int pivot = a[low]; while (low < high) //循环结束条件low==high { //查找小于基准值 while (low < high && a[high] >= pivot) --high; // 找到小的 移动到左端 a[low] = a[high]; while (low < high && a[low] <= pivot) ++low; //找到大的 移动到右端 a[high] = a[low]; } a[low] = pivot; //枢轴元素放到 此时low==high return low; } void QuickSort(int a[], int low, int high) { // low 0 high 7 if (low < high) { int pivotpos = Partition(a, low, high); //定基准 QuickSort(a, low, pivotpos - 1); //划分左 QuickSort(a, pivotpos + 1, high); //划分右 } } ///////////////////////////////////////////////// int partition(int a[], int low, int high) { int pivos = a[low]; while (low < high) { while (low < high && a[high] >= pivos) //找到直到比枢轴元素小的数 high--; a[low] = a[high]; while (low < high && a[low] <= pivos) //找到比枢轴元素大的数 low++; a[high] = a[low]; } a[low] = pivos; return low; } void qSort(int a[], int low, int high) { if (low < high) { int pivotpos = partition(a, low, high); qSort(a, low, pivotpos - 1); qSort(a, pivotpos + 1, high); } } ///////////////////////////////////////////////// int main() { int a[10] = {9, 8, 7, 3, 5, 1}; qSort(a, 0, 5); for (int i = 0; i < 6; i++) { printf("%d ", a[i]); } }
[ "1293410417@qq.com" ]
1293410417@qq.com