blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
8f0e62094bdcfa002ad7ec3dacf6ec332092576b
c451db45f27dc9fbc2d8b133d6ff07b87c57de53
/SkyboxA3/Belt.h
084ca7f6b6da3ad03cbb8720660c89573340e0a0
[]
no_license
LexaFayte/SkyBoxCPP1
ca15a34c36c728deb954d8420f24caacdd8c1c26
02aab5a8d388cb1ec681d73ef70d66299a255af9
refs/heads/master
2021-05-02T15:30:25.002457
2018-05-14T03:45:18
2018-05-14T03:45:18
120,697,372
1
0
null
2018-05-14T03:45:52
2018-02-08T02:03:19
C++
UTF-8
C++
false
false
140
h
#pragma once class Belt { private: int mSize = 0; public: Belt(); Belt(int size); ~Belt(); int getSize(); void setSize(int size); };
[ "alex.kabak@skyboxlabs.com" ]
alex.kabak@skyboxlabs.com
8848659b82146e39782fd7be49f12916c132fae3
bce175496a3dd5d9b331e52a69f541c51254323c
/Project4/Project4/main.cpp
40f181ac36e7cc3a64aa8caebe20b57f3484bf4e
[]
no_license
dustinchhum/class-and-header-cpp-example-files
4ae4f1ca92527d99b2db9c70debfb1353f82a65a
1400fd713863e2874723a965ea82a856161edd09
refs/heads/master
2021-05-01T02:32:47.103801
2018-02-12T01:02:24
2018-02-12T01:02:24
121,182,808
1
0
null
null
null
null
UTF-8
C++
false
false
3,098
cpp
#include "GameExceptions.h" #include "GameBoard.h" #include "GameMove.h" #include "GameView.h" #include "OthelloBoard.h" #include "OthelloView.h" #include "OthelloMove.h" #include "TicTacToeBoard.h" #include "TicTacToeMove.h" #include "TicTacToeView.h" #include <iostream> #include <string> #include <sstream> #include <vector> using namespace std; int main(int argc, char* argv[]) { string s; cout << "Do you want to play Othello or TicTacToe?" << endl; cout << "Enter: 1) Othello, Any Key) Tic-Tac-Toe" << endl; cin >> s; GameBoard *board; GameView *v; if (s == "1") { board = new OthelloBoard(); v = new OthelloView(board); } else { board = new TicTacToeBoard(); v = new TicTacToeView(board); } getline(cin, s); string input; vector<GameMove *> possMoves; do { cout << *v; board->GetPossibleMoves(&possMoves); for (vector<GameMove *>::iterator itr = possMoves.begin(); itr != possMoves.end(); itr++) { cout << (string)**itr << " "; delete *itr; } cout << endl; possMoves.clear(); char playerOne = board->GetNextPlayer(); string player = board->GetPlayerString(playerOne); cout << player << ", make a move?" << endl; getline(cin, input); if (input.find("move") == 0) { GameMove *move = board->CreateMove(); try { *move = input.substr(5); board->GetPossibleMoves(&possMoves); bool useAgain = false; for (vector<GameMove*>::iterator itr = possMoves.begin(); itr != possMoves.end(); itr++) { if (**itr == *move && !useAgain) { useAgain = true; } delete *itr; } possMoves.clear(); if (useAgain) { board->ApplyMove(move); } else { delete move; } } catch (GameException& e) { cout << endl; cout << e.GetMessage() << endl; cout << endl; delete move; } } if (input.find("undo") == 0) { vector<GameMove *> history = *board->GetMoveHistory(); string s = input.substr(5); istringstream stream(s); int sizeOfHistory = 0; int numUndos = 0; stream >> numUndos; for (vector<GameMove*>::iterator itr = history.begin(); itr != history.end(); itr++) { sizeOfHistory++; } for (int i = 0; i < numUndos; i++) { if (sizeOfHistory == 0) { break; } board->UndoLastMove(); } } if (input.find("show value") == 0) { cout << endl; cout << "Value: " << board->GetValue() << endl; cout << endl; } if (input.find("show history") == 0) { string person = ""; char player = playerOne * -1; cout << endl; for (vector<GameMove* >::const_reverse_iterator itr = board->GetMoveHistory()->rbegin(); itr != board->GetMoveHistory()->rend(); itr++) { person = board->GetPlayerString(player); cout << person << " " << (string)**itr << endl; player *= -1; } cout << endl; } if (input.find("quit") == 0) { break; } } while (!board->IsFinished()); if (board->GetValue() == 0) { cout << "Its a tie!" << endl; } else { cout << board->GetPlayerString(board->GetNextPlayer()) << " wins!"; } }
[ "shabo9810@gmail.com" ]
shabo9810@gmail.com
5229a4740325705cd631538ff153a26768986790
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_6521.cpp
4a659c6c4709e384c2fc32063f0c4d62c5677340
[]
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
125
cpp
{ free(certbuf); failf(data, "SSL: out of memory creating CA certificate array"); return CURLE_OUT_OF_MEMORY; }
[ "993273596@qq.com" ]
993273596@qq.com
46c356492a43872b47c100dcf20de7b10ae4f5e9
2022dbdae1d6aa7725359a864901f7900a7a8468
/Special/String mod.cpp
b33dfdfe369d951764ba8d32c3578e4377578dd7
[]
no_license
emtiajium/practice
95368684d8212c52ce671a7dccc5fdd599bb8f6c
d0ad84cc96ed7aec48c7c1b896a6f788d1f0af0a
refs/heads/master
2023-07-26T20:43:30.761816
2021-09-12T05:39:42
2021-09-12T05:39:42
405,553,811
0
0
null
null
null
null
UTF-8
C++
false
false
1,001
cpp
#include<stdio.h> #include<iostream> #include<ctype.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<string> #include<algorithm> #include<vector> #include<stack> #include<queue> using namespace std; //const double PI=3.14159265358979323846264338327950288419716939937511; char num[1005]; long long bigmod(long long ,long long,long long); int main() { //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); long long base,mod,deci,res,p,i,m,sum,emti,k; while(scanf("%s %lld",num,&base)==2){ res=0; p=strlen(num)-1; for(i=0;num[i];i++){ res+=bigmod(10,p,base)*((num[i]-48)%base); res%=base; p--; } res%=base; printf("%lld\n",res); } return 0; } long long bigmod(long long b,long long p,long long m){ long long r=1; while(p!=0){ if(p%2==1) r=(r*b)%m; b=(b*b)%m; p/=2; } return r; }
[ "ehasan@testreach.com" ]
ehasan@testreach.com
3b69000c63ed3cc26f49c2d2e674d6e0a6bff7d9
29e68b2ec669679e460e738d51cf582bd3daeea5
/PrintHelper/SnmpMonitorHelperLG.cpp
781904e4d32e3c6c7bf1a1e5bcc1ce84244c0c4c
[]
no_license
15831944/vs2008PackPrj
30c2f86007822542392a40b4fa4d8f332a87602d
1b7bbf81c7ed507c6482a28fcb15f70c5e54c521
refs/heads/master
2022-04-02T10:53:05.312430
2020-01-16T07:07:12
2020-01-16T07:07:12
null
0
0
null
null
null
null
GB18030
C++
false
false
9,956
cpp
#include "StdAfx.h" #include "SnmpMonitorHelperLG.h" #include "RicohMIB_Def.h" #define Ricoh_Fax_Alert_Modify_20170525 0 //是否启用修改,0-禁用,1-启用。 //当时重写GetAlert时,oid的格式与现在分析看到的不一样, //因为现在没有复现这个oid,可能当时的打印机型号是支持的,暂时保持原样,不修改。 CSnmpMonitorHelperLG::CSnmpMonitorHelperLG(void) { InitOID(); } CSnmpMonitorHelperLG::~CSnmpMonitorHelperLG(void) { } void CSnmpMonitorHelperLG::InitOID() { m_szRicohEngPrtAlertEntryOID = DecryptOID(RicohEngPrtAlertEntryOID); m_szRicohEngFAXAlertEntryOID = DecryptOID(RicohEngFAXAlertEntryOID); m_szRicohEngCpyAlertEntryOID = DecryptOID(RicohEngCpyAlertEntryOID); m_szRicohEngScnAlertEntryOID = DecryptOID(RicohEngScnAlertEntryOID); m_szRicohEngCounterEntryOID = DecryptOID(RicohEngCounterEntryOID); m_szRicohTonerColorOID = DecryptOID(RicohTonerColorOID); m_szRicohTonerDescOID = DecryptOID(RicohTonerDescOID); m_szRicohTonerColorTypeOID = DecryptOID(RicohTonerColorTypeOID); m_szRicohTonerLevelPercentOID = DecryptOID(RicohTonerLevelPercentOID); //ricohEngFAXAlertEntry比ricohEngPrtAlertEntry、ricohEngCpyAlertEntry和ricohEngScnAlertEntry信息更全 //所以以ricohEngFAXAlertEntry为标准,获取预警信息。 m_szRicohAlertEntryOID = m_szRicohEngFAXAlertEntryOID; #if Ricoh_Fax_Alert_Modify_20170525 m_szRicohAlertIndexOID.Format("%s.1", m_szRicohAlertEntryOID); m_szRicohAlertSeverityLevelOID.Format("%s.2", m_szRicohAlertEntryOID); m_szRicohAlertTrainingLevelOID.Format("%s.3", m_szRicohAlertEntryOID); m_szRicohAlertGroupOID.Format("%s.4", m_szRicohAlertEntryOID); m_szRicohAlertGroupIndexOID.Format("%s.5", m_szRicohAlertEntryOID); m_szRicohAlertLocationOID.Format("%s.6", m_szRicohAlertEntryOID); m_szRicohAlertCodeOID.Format("%s.7", m_szRicohAlertEntryOID); m_szRicohAlertDescriptionOID.Format("%s.8", m_szRicohAlertEntryOID); m_szRicohAlertTimeOID.Format("%s.9", m_szRicohAlertEntryOID); #else m_szRicohAlertIndexOID.Format("%s.1.4", m_szRicohAlertEntryOID); m_szRicohAlertSeverityLevelOID.Format("%s.2.4", m_szRicohAlertEntryOID); m_szRicohAlertTrainingLevelOID.Format("%s.3.4", m_szRicohAlertEntryOID); m_szRicohAlertGroupOID.Format("%s.4.4", m_szRicohAlertEntryOID); m_szRicohAlertGroupIndexOID.Format("%s.5.4", m_szRicohAlertEntryOID); m_szRicohAlertLocationOID.Format("%s.6.4", m_szRicohAlertEntryOID); m_szRicohAlertCodeOID.Format("%s.7.4", m_szRicohAlertEntryOID); m_szRicohAlertDescriptionOID.Format("%s.8.4", m_szRicohAlertEntryOID); m_szRicohAlertTimeOID.Format("%s.9.4", m_szRicohAlertEntryOID); #endif } //本函数是重写CSnmpMonitorHelper::GetMarkerSupplies //只构造和添加墨盒信息 BOOL CSnmpMonitorHelperLG::GetMarkerSupplies() { CCriticalSection2::Owner lock(m_cs4MarkerSuppliesMap); char *cOidBegin = CStringToChar(m_szRicohTonerColorOID); //RicohTonerColorOID char *cOidCurrent = cOidBegin; char pszValue[128] = {0}; char pszOidNext[128] = {0}; while (TRUE) { if (GetNextRequestStrEx(cOidCurrent, pszValue, sizeof(pszValue), pszOidNext, sizeof(pszOidNext)) && OidBeginWithStr(pszOidNext, cOidBegin)) { cOidCurrent = pszOidNext; int nIndex = GetOidEndNumber(cOidCurrent); if (m_oMarkerSuppliesMap.find(nIndex) == m_oMarkerSuppliesMap.end()) { PPrtMarkerSuppliesEntry pEntry = new PrtMarkerSuppliesEntry; memset(pEntry, 0x0, sizeof(PrtMarkerSuppliesEntry)); m_oMarkerSuppliesMap.insert(pair<int,PPrtMarkerSuppliesEntry>(nIndex, pEntry)); pEntry->prtMarkerSuppliesIndex = nIndex; } } else { break; } } PrtMarkerSuppliesEntryMap::iterator it; for (it=m_oMarkerSuppliesMap.begin(); it!=m_oMarkerSuppliesMap.end(); it++) { PPrtMarkerSuppliesEntry pEntry = it->second; if (pEntry) { pEntry->prtMarkerSuppliesClass = ENUM_STRUCT_VALUE(PrtMarkerSuppliesClassTC)::SupplyThatIsConsumed; pEntry->prtMarkerSuppliesType = ENUM_STRUCT_VALUE(PrtMarkerSuppliesTypeTC)::Toner; //默认为墨盒信息 pEntry->prtMarkerSuppliesSupplyUnit = ENUM_STRUCT_VALUE(PrtMarkerSuppliesSupplyUnitTC)::Percent; pEntry->prtMarkerSuppliesMaxCapacity = 100; //本函数获取的是粉盒的剩余百分比,所以默认最大为容量为100。 int nIndex = pEntry->prtMarkerSuppliesIndex; char cOidStr[128] = {0}; sprintf(cOidStr, "%s.%d", m_szRicohTonerColorOID, nIndex); //RicohTonerColorOID GetRequest(cOidStr, pEntry->prtMarkerSuppliesDescription, sizeof(pEntry->prtMarkerSuppliesDescription)); //sprintf(cOidStr, "%s.%d", m_szRicohTonerDescOID, nIndex); //RicohTonerDescOID //GetRequest(cOidStr, pEntry->prtMarkerSuppliesDescription); //sprintf(cOidStr, "%s.%d", m_szRicohTonerColorTypeOID, nIndex); //RicohTonerColorTypeOID //GetRequest(cOidStr, (int&)pEntry->prtMarkerSuppliesClass); sprintf(cOidStr, "%s.%d", m_szRicohTonerLevelPercentOID, nIndex); //RicohTonerLevelPercentOID GetRequest(cOidStr, pEntry->prtMarkerSuppliesLevel); } } return TRUE; } //本函数是重写CSnmpMonitorHelper::GetAlert BOOL CSnmpMonitorHelperLG::GetAlert() { CCriticalSection2::Owner lock(m_cs4AlertMap); //因为有一些型号的理光打印机在私有节点(m_szRicohAlertSeverityLevelOID)下没有预警信息, //所有,先获取父类的打印机标准节点(m_szPrtAlertSeverityLevelOID)下的打印机预警信息, //然后再获取理光私有节点下的预警信息。 //1.获取标准预警信息 CSnmpMonitorHelper::GetAlert(); //2.获取理光私有的预警信息 PrtAlertEntryMap oAlertMapTmp; //临时预警map,最终会合并到m_oAlertMap中 char *cOidBegin = CStringToChar(m_szRicohAlertSeverityLevelOID); //ricohEngFAXAlertSeverityLevel char *cOidCurrent = cOidBegin; char pszValue[128] = {0}; char pszOidNext[128] = {0}; while (TRUE) { if (GetNextRequestStrEx(cOidCurrent, pszValue, sizeof(pszValue), pszOidNext, sizeof(pszOidNext)) && OidBeginWithStr(pszOidNext, cOidBegin)) { cOidCurrent = pszOidNext; int nIndex = GetOidEndNumber(cOidCurrent); if (m_oAlertMap.find(nIndex) == m_oAlertMap.end()) { PPrtAlertEntry pEntry = new PrtAlertEntry; memset(pEntry, 0x0, sizeof(PrtAlertEntry)); m_oAlertMap.insert(pair<int,PPrtAlertEntry>(nIndex, pEntry)); oAlertMapTmp.insert(pair<int,PPrtAlertEntry>(nIndex, pEntry)); //同时插入临时预警map中 pEntry->prtAlertIndex = nIndex; } } else { break; } } PrtAlertEntryMap::iterator it; for (it=oAlertMapTmp.begin(); it!=oAlertMapTmp.end(); it++) { PPrtAlertEntry pEntry = it->second; if (pEntry) { int nIndex = pEntry->prtAlertIndex; char cOidStr[128] = {0}; #if Ricoh_Fax_Alert_Modify_20170525 //sprintf(cOidStr, "%s.1.%d", m_szRicohAlertSeverityLevelOID, nIndex); //ricohEngFAXAlertIndex //Not-accessible //GetRequest(cOidStr, (int&)pEntry->prtAlertSeverityLevel); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertTrainingLevelOID, nIndex); //ricohEngFAXAlertTrainingLevel GetRequest(cOidStr, (int&)pEntry->prtAlertTrainingLevel); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertGroupOID, nIndex); //ricohEngFAXAlertGroup GetRequest(cOidStr, (int&)pEntry->prtAlertGroup); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertGroupIndexOID, nIndex); //ricohEngFAXAlertGroupIndex GetRequest(cOidStr, pEntry->prtAlertGroupIndex); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertLocationOID, nIndex); //ricohEngFAXAlertLocation GetRequest(cOidStr, pEntry->prtAlertLocation); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertCodeOID, nIndex); //ricohEngFAXAlertCode GetRequest(cOidStr, (int&)pEntry->prtAlertCode); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertDescriptionOID, nIndex); //ricohEngFAXAlertDescription GetRequest(cOidStr, pEntry->prtAlertDescription, sizeof(pEntry->prtAlertDescription)); sprintf(cOidStr, "%s.1.%d", m_szRicohAlertTimeOID, nIndex); //ricohEngFAXAlertTime GetRequest(cOidStr, pEntry->prtAlertTime); #else //sprintf(cOidStr, "%s.%d", m_szRicohAlertSeverityLevelOID, nIndex); //ricohEngFAXAlertIndex //Not-accessible //GetRequest(cOidStr, (int&)pEntry->prtAlertSeverityLevel); sprintf(cOidStr, "%s.%d", m_szRicohAlertTrainingLevelOID, nIndex); //ricohEngFAXAlertTrainingLevel GetRequest(cOidStr, (int&)pEntry->prtAlertTrainingLevel); sprintf(cOidStr, "%s.%d", m_szRicohAlertGroupOID, nIndex); //ricohEngFAXAlertGroup GetRequest(cOidStr, (int&)pEntry->prtAlertGroup); sprintf(cOidStr, "%s.%d", m_szRicohAlertGroupIndexOID, nIndex); //ricohEngFAXAlertGroupIndex GetRequest(cOidStr, pEntry->prtAlertGroupIndex); sprintf(cOidStr, "%s.%d", m_szRicohAlertLocationOID, nIndex); //ricohEngFAXAlertLocation GetRequest(cOidStr, pEntry->prtAlertLocation); sprintf(cOidStr, "%s.%d", m_szRicohAlertCodeOID, nIndex); //ricohEngFAXAlertCode GetRequest(cOidStr, (int&)pEntry->prtAlertCode); sprintf(cOidStr, "%s.%d", m_szRicohAlertDescriptionOID, nIndex); //ricohEngFAXAlertDescription GetRequest(cOidStr, pEntry->prtAlertDescription, sizeof(pEntry->prtAlertDescription)); sprintf(cOidStr, "%s.%d", m_szRicohAlertTimeOID, nIndex); //ricohEngFAXAlertTime GetRequest(cOidStr, pEntry->prtAlertTime); #endif } } return TRUE; } BOOL CSnmpMonitorHelperLG::IsFalutInfo(CString szDetial) { BOOL bYes = FALSE; szDetial.Trim(); if (szDetial.Find("SC") >= 0 || szDetial.Find("错误:") >= 0) { bYes = TRUE; } return bYes; } CString CSnmpMonitorHelperLG::GetFaultCode(CString szDetial) { CString szFaultCode = ""; szDetial.Trim(); //联系服务中心:SC142{40800} szDetial.MakeUpper(); int nPos = szDetial.Find("SC"); if (nPos >= 0) { CString szTemp = ""; for (int i=nPos+2; i<szDetial.GetLength(); i++) { if (!isdigit(szDetial.GetAt(i))) { break; } szTemp.AppendFormat("%c", szDetial.GetAt(i)); } if (szTemp.GetLength() > 0) { szFaultCode.Format("SC%s", szTemp); } } return szFaultCode; }
[ "1007482035@qq.com" ]
1007482035@qq.com
94eddb0eac035c274a05aa279965db8d10e4b5d5
0c7e20a002108d636517b2f0cde6de9019fdf8c4
/Sources/Elastos/Frameworks/Droid/Base/Core/inc/elastos/droid/google/mms/pdu/SendReq.h
4b0db9a27436bb0c63e6841a8221d51c88571a97
[ "Apache-2.0" ]
permissive
kernal88/Elastos5
022774d8c42aea597e6f8ee14e80e8e31758f950
871044110de52fcccfbd6fd0d9c24feefeb6dea0
refs/heads/master
2021-01-12T15:23:52.242654
2016-10-24T08:20:15
2016-10-24T08:20:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,182
h
#ifndef __ELASTOS_DROID_GOOGLE_MMS_PDU_SENDREQ_H__ #define __ELASTOS_DROID_GOOGLE_MMS_PDU_SENDREQ_H__ #include "elastos/droid/ext/frameworkext.h" #include "elastos/droid/google/mms/pdu/MultimediaMessagePdu.h" namespace Elastos { namespace Droid { namespace Google { namespace Mms { namespace Pdu { class SendReq : public MultimediaMessagePdu , public ISendReq { public: CAR_INTERFACE_DECL(); SendReq(); CARAPI constructor(); /** * Constructor, used when composing a M-Send.req pdu. * * @param contentType the content type value * @param from the from value * @param mmsVersion current viersion of mms * @param transactionId the transaction-id value * @throws InvalidHeaderValueException if parameters are invalid. * NullPointerException if contentType, form or transactionId is null. */ CARAPI constructor( /* [in] */ ArrayOf<Byte>* contentType, /* [in] */ IEncodedStringValue* from, /* [in] */ Int32 mmsVersion, /* [in] */ ArrayOf<Byte>* transactionId); /** * Constructor with given headers. * * @param headers Headers for this PDU. */ CARAPI constructor( /* [in] */ IPduHeaders* headers); /** * Constructor with given headers and body * * @param headers Headers for this PDU. * @param body Body of this PDu. */ CARAPI constructor( /* [in] */ IPduHeaders* headers, /* [in] */ IPduBody* body); /** * Get Bcc value. * * @return the value */ virtual CARAPI GetBcc( /* [out] */ ArrayOf<IEncodedStringValue*>** result); /** * Add a "BCC" value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI AddBcc( /* [in] */ IEncodedStringValue* value); /** * Set "BCC" value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetBcc( /* [in] */ ArrayOf<IEncodedStringValue*>* value); /** * Get CC value. * * @return the value */ virtual CARAPI GetCc( /* [out] */ ArrayOf<IEncodedStringValue*>** result); /** * Add a "CC" value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI AddCc( /* [in] */ IEncodedStringValue* value); /** * Set "CC" value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetCc( /* [in] */ ArrayOf<IEncodedStringValue*>* value); /** * Get Content-type value. * * @return the value */ virtual CARAPI GetContentType( /* [out] */ ArrayOf<Byte>** result); /** * Set Content-type value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetContentType( /* [in] */ ArrayOf<Byte>* value); /** * Get X-Mms-Delivery-Report value. * * @return the value */ virtual CARAPI GetDeliveryReport( /* [out] */ Int32* result); /** * Set X-Mms-Delivery-Report value. * * @param value the value * @throws InvalidHeaderValueException if the value is invalid. */ virtual CARAPI SetDeliveryReport( /* [in] */ Int32 value); /** * Get X-Mms-Expiry value. * * Expiry-value = Value-length * (Absolute-token Date-value | Relative-token Delta-seconds-value) * * @return the value */ virtual CARAPI GetExpiry( /* [out] */ Int64* result); /** * Set X-Mms-Expiry value. * * @param value the value */ virtual CARAPI SetExpiry( /* [in] */ Int64 value); /** * Get X-Mms-MessageSize value. * * Expiry-value = size of message * * @return the value */ virtual CARAPI GetMessageSize( /* [out] */ Int64* result); /** * Set X-Mms-MessageSize value. * * @param value the value */ virtual CARAPI SetMessageSize( /* [in] */ Int64 value); /** * Get X-Mms-Message-Class value. * Message-class-value = Class-identifier | Token-text * Class-identifier = Personal | Advertisement | Informational | Auto * * @return the value */ virtual CARAPI GetMessageClass( /* [out] */ ArrayOf<Byte>** result); /** * Set X-Mms-Message-Class value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetMessageClass( /* [in] */ ArrayOf<Byte>* value); /** * Get X-Mms-Read-Report value. * * @return the value */ virtual CARAPI GetReadReport( /* [out] */ Int32* result); /** * Set X-Mms-Read-Report value. * * @param value the value * @throws InvalidHeaderValueException if the value is invalid. */ virtual CARAPI SetReadReport( /* [in] */ Int32 value); /** * Set "To" value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetTo( /* [in] */ ArrayOf<IEncodedStringValue*>* value); /** * Get X-Mms-Transaction-Id field value. * * @return the X-Mms-Report-Allowed value */ virtual CARAPI GetTransactionId( /* [out] */ ArrayOf<Byte>** result); /** * Set X-Mms-Transaction-Id field value. * * @param value the value * @throws NullPointerException if the value is null. */ virtual CARAPI SetTransactionId( /* [in] */ ArrayOf<Byte>* value); private: CARAPI_(AutoPtr<ArrayOf<Byte> >) GenerateTransactionId(); private: static const String TAG; }; } // namespace Pdu } // namespace Mms } // namespace Google } // namespace Droid } // namespace Elastos #endif // __ELASTOS_DROID_GOOGLE_MMS_PDU_SENDREQ_H__
[ "zhang.leliang@kortide.com" ]
zhang.leliang@kortide.com
d32b06292f3171903a0b29c4e21de2419bdfa168
df430be8407bd7eff51cd060e83074a6e67ea816
/PROBLEM SOLVING - UVA/P-10394.cpp
49ae37e2555b9f3708697351d4ec39f69d1e039c
[]
no_license
sohag-aust/Problem-Solving---UVA
445b9d02b93764b7a20ca7da090f0c9f61ed54bf
d7b396efcfd314a96236f8eb94c6bd27339e11f4
refs/heads/master
2021-07-20T06:34:10.794244
2021-07-10T04:48:58
2021-07-10T04:48:58
160,833,208
0
0
null
null
null
null
UTF-8
C++
false
false
696
cpp
#include<bits/stdc++.h> using namespace std; const int sz = 20000000 + 5; bool visit[sz+5]; vector<int>v; vector<pair<int,int> >ans; void seive() { memset(visit,false,sizeof(visit)); visit[0] = visit[1] = 1; v.push_back(2); for(int i=3; i<=sz; i+=2) { if(visit[i]) continue; v.push_back(i); for(int j=i; j<=sz; j+=2*i) visit[j] = 1; } for(int i=1; i<v.size(); i++) { if(v[i]-v[i-1] == 2) ans.push_back({v[i-1],v[i]}); } } int main() { seive(); int n; while(cin>>n) { n--; cout<<"("<<ans[n].first<<", "<<ans[n].second<<")"<<endl; } return 0; }
[ "frustratedcoder96@gmail.com" ]
frustratedcoder96@gmail.com
9e63a5db64cbded0d1f16e2eeeda9ac55f8a0d8a
ed8d8c0ac212f2227f8238c9f609440b0d975552
/Util/NAMTraceWriter.h
50923255dedd8df104a1806648cecd90fce40051
[]
no_license
vonami/inet-flc
bb3ddf69b702a6936798231748d1e846784f6fb1
db1df841da2db9afcc8f621d4b69bc5801bbdcff
refs/heads/master
2021-01-01T19:39:20.455074
2008-10-05T19:30:18
2008-10-05T19:30:18
55,999
1
0
null
null
null
null
UTF-8
C++
false
false
1,751
h
// // Copyright (C) 2005 Andras Varga // // 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. // #ifndef __NAMTRACEWRITER_H #define __NAMTRACEWRITER_H #include <iostream> #include <fstream> #include <omnetpp.h> #include "INETDefs.h" #include "INotifiable.h" #include "NotifierConsts.h" class NAMTrace; class InterfaceEntry; /** * Writes a "nam" trace. */ class INET_API NAMTraceWriter : public cSimpleModule, public INotifiable { protected: int namid; NAMTrace *nt; protected: void recordNodeEvent(char *state, char *shape); void recordLinkEvent(int peernamid, double datarate, double delay, char *state); void recordLinkEvent(InterfaceEntry *ie, char *state); void recordPacketEvent(const char event, int peernamid, cMessage *msg); protected: virtual int numInitStages() const {return 3;} virtual void initialize(int stage); virtual void finish(); /** * Redefined INotifiable method. Called by NotificationBoard on changes. */ virtual void receiveChangeNotification(int category, cPolymorphic *details); }; #endif
[ "ivanovd@1339srv.(none)" ]
ivanovd@1339srv.(none)
3ea7f72efedf792d2e4187b74f2712e298880bd3
c4f539ea7065d11c997ffdddae8302f261f1327c
/apps/RawLogViewer/MyGLCanvas.h
bbce4f6b1ca0f46316b1f123e8918df66499a981
[ "BSD-3-Clause" ]
permissive
Tednsn/mrpt
0d3d566b6df1eb83752da323585de6860dfeb1c9
66af769da390ec2409b0bf68078a9f1f7ca17d7f
refs/heads/master
2020-04-16T12:23:23.675830
2019-01-14T01:40:34
2019-01-14T01:40:34
165,577,002
1
0
BSD-3-Clause
2019-01-14T01:42:20
2019-01-14T01:42:19
null
UTF-8
C++
false
false
1,669
h
/* +------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ #ifndef MYGLCANVAS_H #define MYGLCANVAS_H #include <mrpt/gui/CWxGLCanvasBase.h> using namespace mrpt::gui; // Allow RawlogViewer to build without 3D: #define RAWLOGVIEWER_HAS_3D (wxUSE_GLCANVAS && MRPT_HAS_OPENGL_GLUT) #if RAWLOGVIEWER_HAS_3D class CMyGLCanvas : public CWxGLCanvasBase { public: CMyGLCanvas( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = _T("CMyGLCanvas")); ~CMyGLCanvas() override; void OnPreRender() override; void OnPostRender() override; void OnPostRenderSwapBuffers(double At, wxPaintDC& dc) override; void OnRenderError(const wxString& str) override; }; #else // Dummy class class CMyGLCanvas : public wxPanel { public: CMyGLCanvas( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = _T("CMyGLCanvas")) { } }; #endif // Have glut #endif // MYGLCANVAS_H
[ "joseluisblancoc@gmail.com" ]
joseluisblancoc@gmail.com
8861cb75862ebd45feeab8c422e10c0ea5db0b2e
5d14b86bde758afb7e3955e241d8f6db5316246f
/Imitator_prototype/Imitator_prototype/ResultOfScan.cpp
f320556f0832155dcb492029f20e217956f6228b
[]
no_license
AlexeyPipchuk/ImitatorAirStates
c86cd090946d66c8c97b89f2976d2626cf68a7ad
bb1287cb6162cc4620e9f210a8b7bdd2f5e49fe3
refs/heads/master
2020-04-02T12:48:37.754418
2018-11-27T09:09:19
2018-11-27T09:09:19
154,452,857
2
0
null
null
null
null
UTF-8
C++
false
false
318
cpp
#include "stdafx.h" CResultOfScan::CResultOfScan(CVector coordinates, double vr, double time, double** cov) { this->Coordinates.x = coordinates.x; this->Coordinates.y = coordinates.y; this->Coordinates.z = coordinates.z; this->Vr = vr; DetectionTime = time; CovMat = cov; } CResultOfScan::~CResultOfScan() { }
[ "alexeypipchuk@gmail.com" ]
alexeypipchuk@gmail.com
c99391d0ae396c5c52484fe5869b0e262ecbaa15
bc3d11eb8c1219f73a05a73b3dae24eeb4285313
/CombineHarvester/HTTAC2017/interface/HttSystematics_SMRun2_D0merged_DCP_ggHSyst_fL1_rw.h
30ee14346494897d0c3ca3902ea84eea74930c81
[]
no_license
senka/HTT_AC_81X
49818a0a610a12bd7ded1b3a51bc33ae7dfe60c3
b23fb715281e74d17d428ef5fbffa9cde6d3a312
refs/heads/master
2020-03-09T02:48:08.919346
2018-05-01T22:54:22
2018-05-01T22:54:22
128,549,024
0
1
null
null
null
null
UTF-8
C++
false
false
456
h
#ifndef SM2016_HttSystematics_SMRun2_D0merged_DCP_ggHSyst_fL1_rw_h #define SM2016_HttSystematics_SMRun2_D0merged_DCP_ggHSyst_fL1_rw_h #include "CombineHarvester/CombineTools/interface/CombineHarvester.h" namespace ch { // Run2 SM analysis systematics // Implemented in src/HttSystematics_SMRun2.cc void AddSMRun2Systematics_D0merged_DCP_ggHSyst_fL1_rw(CombineHarvester& cb, int control_region = 0, bool zmm_fit = false, bool ttbar_fit = false); } #endif
[ "senka.duric@cern.ch" ]
senka.duric@cern.ch
ef86eebe1c32e29f9a8ba7bff62e64e3b0e1bdc8
533f24402d5b72bdaae17f1daa272119c3a649a0
/Package/Launcher/arm/moc_HomeWidget.cpp
29da00742baa12f772abadb766a5577720c3d70b
[]
no_license
Fneger/ArkPro
36dfa3405177580f9343ea1c67347e6685a90974
e7437446cacc79e242d9b7a90e3724af52c33bba
refs/heads/master
2021-12-23T06:33:04.304197
2017-10-31T03:31:28
2017-10-31T03:31:28
399,509,726
0
1
null
2021-08-24T15:07:45
2021-08-24T15:07:44
null
UTF-8
C++
false
false
3,046
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'HomeWidget.h' ** ** Created: Tue Oct 24 11:31:34 2017 ** by: The Qt Meta Object Compiler version 62 (Qt 4.7.4) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../Launcher/UserInterface/MainWidget/HomeWidget/HomeWidget.h" #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'HomeWidget.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 62 #error "This file was generated using the moc from 4.7.4. 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_HomeWidget[] = { // content: 5, // 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 24, 12, 11, 11, 0x09, 66, 12, 11, 11, 0x09, 97, 11, 11, 11, 0x08, 118, 11, 11, 11, 0x08, 0 // eod }; static const char qt_meta_stringdata_HomeWidget[] = { "HomeWidget\0\0type,status\0" "ontWidgetTypeChange(Widget::Type,QString)\0" "onDeviceWatcherStatus(int,int)\0" "onBmpButtonRelease()\0onTimeout()\0" }; const QMetaObject HomeWidget::staticMetaObject = { { &QWidget::staticMetaObject, qt_meta_stringdata_HomeWidget, qt_meta_data_HomeWidget, 0 } }; #ifdef Q_NO_DATA_RELOCATION const QMetaObject &HomeWidget::getStaticMetaObject() { return staticMetaObject; } #endif //Q_NO_DATA_RELOCATION const QMetaObject *HomeWidget::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; } void *HomeWidget::qt_metacast(const char *_clname) { if (!_clname) return 0; if (!strcmp(_clname, qt_meta_stringdata_HomeWidget)) return static_cast<void*>(const_cast< HomeWidget*>(this)); if (!strcmp(_clname, "Widget::Interface")) return static_cast< Widget::Interface*>(const_cast< HomeWidget*>(this)); return QWidget::qt_metacast(_clname); } int HomeWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: ontWidgetTypeChange((*reinterpret_cast< const Widget::Type(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break; case 1: onDeviceWatcherStatus((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; case 2: onBmpButtonRelease(); break; case 3: onTimeout(); break; default: ; } _id -= 4; } return _id; } QT_END_MOC_NAMESPACE
[ "850601130@qq.com" ]
850601130@qq.com
c8d470be90fd609217eaf5387768609beced68fc
eff550ccfe3f26ed0b368c54d7718c95356d420a
/퀴즈2/Pattern matching/deque.cpp
22624abefbd289500822edec2c39a0b9dd6199b4
[]
no_license
yt4307/Algorithm_design
a0094eb9c0c06f297027198a0fad510198ee446b
2e85757b91203c9b1f6d8f87e27c749a0693aebc
refs/heads/master
2023-05-28T08:51:26.596026
2021-06-15T07:41:03
2021-06-15T07:41:03
344,013,684
1
0
null
null
null
null
UTF-8
C++
false
false
289
cpp
#include "deque.h" void Deque::insertFirst(int v) { deque[first--] = v; } void Deque::insertLast(int v) { deque[++last] = v; } int Deque::deleteFirst() { deque[first] = 0; return deque[++first]; } int Deque::isEmpty() { if (first == last) return true; else return false; }
[ "yt4307@gmail.com" ]
yt4307@gmail.com
931bd17d9026016b5ffc80ed95f2199593673a23
411bcc57cc3f58eea7e0d5f8661c351445ad9e9e
/competitive_programming/interview_bit/LinkedList/segregate_smaller_larger.cpp
d61ea67716b4bfbeed673fb831dd4ea6bf6ea428
[]
no_license
pruthig/algorithms
1d1c5d6acc44fcf4272c13eeae09a8dec808d25a
64b488b495adcf836b79462695f36308e52a48da
refs/heads/master
2022-12-06T07:59:01.202471
2022-11-24T13:19:58
2022-11-24T13:19:58
124,031,673
1
0
null
null
null
null
UTF-8
C++
false
false
2,128
cpp
// This program will partition the list in 2 halves such that elements less than given element comes // before the element that are larger than given element #include<iostream> using namespace std; // Definition for singly-linked list. struct ListNode { int value; ListNode *next; ListNode(int x) : value(x), next(NULL) {} }; void printList(ListNode* head) { while(head) { cout<<head->value<<"->"; head = head->next; } cout<<"nullptr"; } void createList(ListNode **head) { (*head) = new ListNode(3); (*head)->next = new ListNode(7); /*(*head)->next->next = new ListNode(12); (*head)->next->next->next = new ListNode(6); (*head)->next->next->next->next = new ListNode(8); (*head)->next->next->next->next->next = new ListNode(21); (*head)->next->next->next->next->next->next = new ListNode(3); (*head)->next->next->next->next->next->next->next = new ListNode(6); (*head)->next->next->next->next->next->next->next->next = new ListNode(10); (*head)->next->next->next->next->next->next->next->next->next = new ListNode(4); */ } void segregate(ListNode **head, int element) { ListNode *larger = nullptr, *smaller = nullptr, *larger_head = nullptr, *smaller_head = nullptr; ListNode *cursor = *head; while(cursor) { if(cursor->value < element) { if(!smaller) smaller_head = cursor; if(smaller) smaller->next = cursor; smaller = cursor; cout<<"Added in Smaller: "<<smaller->value<<endl; } else { if(!larger) larger_head = cursor; if(larger) larger->next = cursor; larger = cursor; cout<<"Added in larger: "<<larger->value<<endl; } cursor = cursor->next; } if(larger) larger->next = nullptr; if(smaller) smaller->next = nullptr; // End of loop if(!smaller_head) *head = larger_head; else { *head = smaller_head; if(smaller) smaller->next = larger_head; } } int main() { // Create list ListNode *head = nullptr; createList(&head); int element; cout<<"Enter the element\n"; cin>>element; segregate(&head, element); printList(head); return 0; }
[ "gaurav.pruthi88@gmail.com" ]
gaurav.pruthi88@gmail.com
b38b12f4048286db57fed73459cc3127c234dbea
38c10c01007624cd2056884f25e0d6ab85442194
/ui/app_list/views/folder_header_view.cc
bd87c4873a9c68ac5a0b993de15569045b68a8bb
[ "BSD-3-Clause" ]
permissive
zenoalbisser/chromium
6ecf37b6c030c84f1b26282bc4ef95769c62a9b2
e71f21b9b4b9b839f5093301974a45545dad2691
refs/heads/master
2022-12-25T14:23:18.568575
2016-07-14T21:49:52
2016-07-23T08:02:51
63,980,627
0
2
BSD-3-Clause
2022-12-12T12:43:41
2016-07-22T20:14:04
null
UTF-8
C++
false
false
8,251
cc
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/app_list/views/folder_header_view.h" #include <algorithm> #include "base/strings/utf_string_conversions.h" #include "ui/app_list/app_list_constants.h" #include "ui/app_list/app_list_folder_item.h" #include "ui/app_list/app_list_switches.h" #include "ui/app_list/resources/grit/app_list_resources.h" #include "ui/app_list/views/app_list_folder_view.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" #include "ui/strings/grit/ui_strings.h" #include "ui/views/border.h" #include "ui/views/controls/button/image_button.h" #include "ui/views/controls/textfield/textfield.h" #include "ui/views/focus/focus_manager.h" #include "ui/views/painter.h" namespace app_list { namespace { const int kPreferredWidth = 360; const int kPreferredHeight = 48; const int kIconDimension = 24; const int kBackButtonPadding = 14; const int kBottomSeparatorPadding = 9; // Non-experimental app list only. const int kBottomSeparatorHeight = 1; const int kMaxFolderNameWidth = 300; } // namespace class FolderHeaderView::FolderNameView : public views::Textfield { public: FolderNameView() { SetBorder(views::Border::CreateEmptyBorder(1, 1, 1, 1)); const SkColor kFocusBorderColor = SkColorSetRGB(64, 128, 250); SetFocusPainter(views::Painter::CreateSolidFocusPainter( kFocusBorderColor, gfx::Insets(0, 0, 1, 1))); SetTextColor(kFolderTitleColor); } ~FolderNameView() override {} private: DISALLOW_COPY_AND_ASSIGN(FolderNameView); }; FolderHeaderView::FolderHeaderView(FolderHeaderViewDelegate* delegate) : folder_item_(nullptr), back_button_(nullptr), folder_name_view_(new FolderNameView), folder_name_placeholder_text_( ui::ResourceBundle::GetSharedInstance().GetLocalizedString( IDS_APP_LIST_FOLDER_NAME_PLACEHOLDER)), delegate_(delegate), folder_name_visible_(true) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); if (!app_list::switches::IsExperimentalAppListEnabled()) { back_button_ = new views::ImageButton(this); back_button_->SetImage( views::ImageButton::STATE_NORMAL, rb.GetImageSkiaNamed(IDR_APP_LIST_FOLDER_BACK_NORMAL)); back_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); AddChildView(back_button_); back_button_->SetFocusable(true); back_button_->SetAccessibleName( ui::ResourceBundle::GetSharedInstance().GetLocalizedString( IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME)); } folder_name_view_->SetFontList( rb.GetFontList(ui::ResourceBundle::MediumFont)); folder_name_view_->set_placeholder_text_color(kFolderTitleHintTextColor); folder_name_view_->set_placeholder_text(folder_name_placeholder_text_); folder_name_view_->SetBorder(views::Border::NullBorder()); folder_name_view_->SetBackgroundColor(kContentsBackgroundColor); folder_name_view_->set_controller(this); AddChildView(folder_name_view_); } FolderHeaderView::~FolderHeaderView() { if (folder_item_) folder_item_->RemoveObserver(this); } void FolderHeaderView::SetFolderItem(AppListFolderItem* folder_item) { if (folder_item_) folder_item_->RemoveObserver(this); folder_item_ = folder_item; if (!folder_item_) return; folder_item_->AddObserver(this); folder_name_view_->SetEnabled(folder_item_->folder_type() != AppListFolderItem::FOLDER_TYPE_OEM); Update(); } void FolderHeaderView::UpdateFolderNameVisibility(bool visible) { folder_name_visible_ = visible; Update(); SchedulePaint(); } void FolderHeaderView::OnFolderItemRemoved() { folder_item_ = NULL; } void FolderHeaderView::SetTextFocus() { if (!folder_name_view_->HasFocus()) { views::FocusManager* focus_manager = GetFocusManager(); if (focus_manager) focus_manager->SetFocusedView(folder_name_view_); } } bool FolderHeaderView::HasTextFocus() const { return folder_name_view_->HasFocus(); } void FolderHeaderView::Update() { if (!folder_item_) return; folder_name_view_->SetVisible(folder_name_visible_); if (folder_name_visible_) { folder_name_view_->SetText(base::UTF8ToUTF16(folder_item_->name())); UpdateFolderNameAccessibleName(); } Layout(); } void FolderHeaderView::UpdateFolderNameAccessibleName() { // Sets |folder_name_view_|'s accessible name to the placeholder text if // |folder_name_view_| is blank; otherwise, clear the accessible name, the // accessible state's value is set to be folder_name_view_->text() by // TextField. base::string16 accessible_name = folder_name_view_->text().empty() ? folder_name_placeholder_text_ : base::string16(); folder_name_view_->SetAccessibleName(accessible_name); } const base::string16& FolderHeaderView::GetFolderNameForTest() { return folder_name_view_->text(); } void FolderHeaderView::SetFolderNameForTest(const base::string16& name) { folder_name_view_->SetText(name); } bool FolderHeaderView::IsFolderNameEnabledForTest() const { return folder_name_view_->enabled(); } gfx::Size FolderHeaderView::GetPreferredSize() const { return gfx::Size(kPreferredWidth, kPreferredHeight); } void FolderHeaderView::Layout() { gfx::Rect rect(GetContentsBounds()); if (rect.IsEmpty()) return; if (!switches::IsExperimentalAppListEnabled()) { gfx::Rect back_bounds; DCHECK(back_button_); back_bounds = rect; back_bounds.set_width(kIconDimension + 2 * kBackButtonPadding); back_button_->SetBoundsRect(back_bounds); } gfx::Rect text_bounds(rect); base::string16 text = folder_item_ && !folder_item_->name().empty() ? base::UTF8ToUTF16(folder_item_->name()) : folder_name_placeholder_text_; int text_width = gfx::Canvas::GetStringWidth(text, folder_name_view_->GetFontList()) + folder_name_view_->GetCaretBounds().width() + folder_name_view_->GetInsets().width(); text_width = std::min(text_width, kMaxFolderNameWidth); text_bounds.set_x(rect.x() + (rect.width() - text_width) / 2); text_bounds.set_width(text_width); text_bounds.ClampToCenteredSize(gfx::Size(text_bounds.width(), folder_name_view_->GetPreferredSize().height())); folder_name_view_->SetBoundsRect(text_bounds); } bool FolderHeaderView::OnKeyPressed(const ui::KeyEvent& event) { if (event.key_code() == ui::VKEY_RETURN) delegate_->GiveBackFocusToSearchBox(); return false; } void FolderHeaderView::OnPaint(gfx::Canvas* canvas) { views::View::OnPaint(canvas); gfx::Rect rect(GetContentsBounds()); if (rect.IsEmpty() || !folder_name_visible_) return; // Draw bottom separator line. int horizontal_padding = app_list::switches::IsExperimentalAppListEnabled() ? kExperimentalAppsGridPadding : kBottomSeparatorPadding; rect.Inset(horizontal_padding, 0); rect.set_y(rect.bottom() - kBottomSeparatorHeight); rect.set_height(kBottomSeparatorHeight); canvas->FillRect(rect, kTopSeparatorColor); } void FolderHeaderView::ContentsChanged(views::Textfield* sender, const base::string16& new_contents) { // Temporarily remove from observer to ignore data change caused by us. if (!folder_item_) return; folder_item_->RemoveObserver(this); // Enforce the maximum folder name length in UI. std::string name = base::UTF16ToUTF8( folder_name_view_->text().substr(0, kMaxFolderNameChars)); if (name != folder_item_->name()) delegate_->SetItemName(folder_item_, name); folder_item_->AddObserver(this); UpdateFolderNameAccessibleName(); Layout(); } void FolderHeaderView::ButtonPressed(views::Button* sender, const ui::Event& event) { delegate_->NavigateBack(folder_item_, event); } void FolderHeaderView::ItemNameChanged() { Update(); } } // namespace app_list
[ "zeno.albisser@hemispherian.com" ]
zeno.albisser@hemispherian.com
8087bd758af9799f379b0c3300345fd42614d8e0
1dccf1de4298d0a39364c81cc3118c233cf84002
/code/bnn_lib_tests/hls/etc/ap_private.h
f486562d37051724eef7686a0fb968210d8731d3
[ "Apache-2.0" ]
permissive
elimkwan/Entropy-Driven-Adaptive-Filter-for-FPGA-Object-Recognition-System
8d4e2786c292698aef5e2cffb20883f9c5ebedb3
8b151db765a4b9e362b38617613fc0c6b7e5ce8d
refs/heads/master
2023-01-29T22:32:20.715425
2020-12-17T00:21:49
2020-12-17T00:21:49
220,653,257
4
0
null
null
null
null
UTF-8
C++
false
false
216,832
h
/* __VIVADO_HLS_COPYRIGHT-INFO__ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef LLVM_SUPPORT_MATHEXTRAS_H #define LLVM_SUPPORT_MATHEXTRAS_H #ifdef _MSC_VER #if _MSC_VER <= 1500 typedef __int8 int8_t; typedef unsigned __int8 uint8_t; typedef __int16 int16_t; typedef unsigned __int16 uint16_t; typedef __int32 int32_t; typedef unsigned __int32 uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else #include <stdint.h> #endif #else #include <stdint.h> #endif #include "hls_half.h" #undef INLINE #if 1 #define INLINE inline #else //Enable to debug ap_int/ap_fixed #define INLINE __attribute__((weak)) #endif #define AP_MAX(a,b) ((a) > (b) ? (a) : (b)) #define AP_MIN(a,b) ((a) < (b) ? (a) : (b)) #define AP_ABS(a) ((a)>=0 ? (a):-(a)) #ifndef AP_INT_MAX_W #define AP_INT_MAX_W 1024 #endif #define BIT_WIDTH_UPPER_LIMIT (1 << 15) #if AP_INT_MAX_W > BIT_WIDTH_UPPER_LIMIT #error "Bitwidth exceeds 32768 (1 << 15), the maximum allowed value" #endif #define MAX_MODE(BITS) ((BITS + 1023) / 1024) // NOTE: The following support functions use the _32/_64 extensions instead of // type overloading so that signed and unsigned integers can be used without // ambiguity. namespace AESL_std { template <class DataType> DataType INLINE min(DataType a, DataType b) { // if (a >= b) return b; // else return a; return (a>=b) ? b : a; } template <class DataType> DataType INLINE max(DataType a, DataType b) { // if (a >= b) return a; // else return b; return (a>=b) ? a : b; } } #include <cassert> #include <string> #include <stdio.h> #include <math.h> #include <limits> #include <cstring> #include <cstdlib> #include <iomanip> #include <sstream> template<int _AP_W, bool _AP_S, bool _AP_C = _AP_W <= 64> class ap_private; namespace ap_private_ops { /// Hi_32 - This function returns the high 32 bits of a 64 bit value. static INLINE uint32_t Hi_32(uint64_t Value) { return static_cast<uint32_t>(Value >> 32); } /// Lo_32 - This function returns the low 32 bits of a 64 bit value. static INLINE uint32_t Lo_32(uint64_t Value) { return static_cast<uint32_t>(Value); } template<int _AP_W> INLINE bool isNegative(const ap_private<_AP_W, false>& a) { return false; } template<int _AP_W> INLINE bool isNegative(const ap_private<_AP_W, true>& a) { enum {APINT_BITS_PER_WORD=64,_AP_N=(_AP_W+APINT_BITS_PER_WORD-1)/APINT_BITS_PER_WORD}; static const uint64_t sign_mask = 1ULL << ((_AP_W - 1) %APINT_BITS_PER_WORD); return (sign_mask & a.get_pVal(_AP_N-1)) != 0; } /// CountLeadingZeros_32 - this function performs the platform optimal form of /// counting the number of zeros from the most significant bit to the first one /// bit. Ex. CountLeadingZeros_32(0x00F000FF) == 8. /// Returns 32 if the word is zero. static INLINE unsigned CountLeadingZeros_32(uint32_t Value) { unsigned Count; // result #if __GNUC__ >= 4 // PowerPC is defined for __builtin_clz(0) #if !defined(__ppc__) && !defined(__ppc64__) if (Value == 0) return 32; #endif Count = __builtin_clz(Value); #else if (Value == 0) return 32; Count = 0; // bisecton method for count leading zeros for (unsigned Shift = 32 >> 1; Shift; Shift >>= 1) { uint32_t Tmp = (Value) >> (Shift); if (Tmp) { Value = Tmp; } else { Count |= Shift; } } #endif return Count; } /// CountLeadingZeros_64 - This function performs the platform optimal form /// of counting the number of zeros from the most significant bit to the first /// one bit (64 bit edition.) /// Returns 64 if the word is zero. static INLINE unsigned CountLeadingZeros_64(uint64_t Value) { unsigned Count; // result #if __GNUC__ >= 4 // PowerPC is defined for __builtin_clzll(0) #if !defined(__ppc__) && !defined(__ppc64__) if (!Value) return 64; #endif Count = __builtin_clzll(Value); #else if (sizeof(long) == sizeof(int64_t)) { if (!Value) return 64; Count = 0; // bisecton method for count leading zeros for (unsigned Shift = 64 >> 1; Shift; Shift >>= 1) { uint64_t Tmp = (Value) >> (Shift); if (Tmp) { Value = Tmp; } else { Count |= Shift; } } } else { // get hi portion uint32_t Hi = Hi_32(Value); // if some bits in hi portion if (Hi) { // leading zeros in hi portion plus all bits in lo portion Count = CountLeadingZeros_32(Hi); } else { // get lo portion uint32_t Lo = Lo_32(Value); // same as 32 bit value Count = CountLeadingZeros_32(Lo)+32; } } #endif return Count; } /// CountTrailingZeros_64 - This function performs the platform optimal form /// of counting the number of zeros from the least significant bit to the first /// one bit (64 bit edition.) /// Returns 64 if the word is zero. static INLINE unsigned CountTrailingZeros_64(uint64_t Value) { #if __GNUC__ >= 4 return (Value != 0) ? __builtin_ctzll(Value) : 64; #else static const unsigned Mod67Position[] = { 64, 0, 1, 39, 2, 15, 40, 23, 3, 12, 16, 59, 41, 19, 24, 54, 4, 64, 13, 10, 17, 62, 60, 28, 42, 30, 20, 51, 25, 44, 55, 47, 5, 32, 65, 38, 14, 22, 11, 58, 18, 53, 63, 9, 61, 27, 29, 50, 43, 46, 31, 37, 21, 57, 52, 8, 26, 49, 45, 36, 56, 7, 48, 35, 6, 34, 33, 0 }; return Mod67Position[(uint64_t)(-(int64_t)Value & (int64_t)Value) % 67]; #endif } /// CountPopulation_64 - this function counts the number of set bits in a value, /// (64 bit edition.) static INLINE unsigned CountPopulation_64(uint64_t Value) { #if __GNUC__ >= 4 return __builtin_popcountll(Value); #else uint64_t v = Value - (((Value) >> 1) & 0x5555555555555555ULL); v = (v & 0x3333333333333333ULL) + (((v) >> 2) & 0x3333333333333333ULL); v = (v + ((v) >> 4)) & 0x0F0F0F0F0F0F0F0FULL; return unsigned((uint64_t)(v * 0x0101010101010101ULL) >> 56); #endif } static INLINE uint32_t countLeadingOnes_64(uint64_t __V, uint32_t skip) { uint32_t Count = 0; if (skip) (__V) <<= (skip); while (__V && (__V & (1ULL << 63))) { Count++; (__V) <<= 1; } return Count; } static INLINE std::string oct2Bin(char oct) { switch (oct) { case '\0': { return ""; } case '.': { return "."; } case '0': { return "000"; } case '1': { return "001"; } case '2': { return "010"; } case '3': { return "011"; } case '4': { return "100"; } case '5': { return "101"; } case '6': { return "110"; } case '7': { return "111"; } } assert(0 && "Invalid character in digit string"); return ""; } static INLINE std::string hex2Bin(char hex) { switch (hex) { case '\0': { return ""; } case '.': { return "."; } case '0': { return "0000"; } case '1': { return "0001"; } case '2': { return "0010"; } case '3': { return "0011"; } case '4': { return "0100"; } case '5': { return "0101"; } case '6': { return "0110"; } case '7': { return "0111"; } case '8': { return "1000"; } case '9': { return "1001"; } case 'A': case 'a': { return "1010"; } case 'B': case 'b': { return "1011"; } case 'C': case 'c': { return "1100"; } case 'D': case 'd': { return "1101"; } case 'E': case 'e': { return "1110"; } case 'F': case 'f': { return "1111"; } } assert(0 && "Invalid character in digit string"); return ""; } static INLINE uint32_t decode_digit(char cdigit, int radix) { uint32_t digit = 0; if (radix == 16) { #define isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #define isdigit(c) ((c) >= '0' && (c) <= '9') if (!isxdigit(cdigit)) assert(0 && "Invalid hex digit in string"); if (isdigit(cdigit)) digit = cdigit - '0'; else if (cdigit >= 'a') digit = cdigit - 'a' + 10; else if (cdigit >= 'A') digit = cdigit - 'A' + 10; else assert(0 && "huh? we shouldn't get here"); } else if (isdigit(cdigit)) { digit = cdigit - '0'; } else { assert(0 && "Invalid character in digit string"); } #undef isxdigit #undef isdigit return digit; } // Determine the radix of "val". static INLINE std::string parseString(const std::string& input, int& radix) { size_t len = input.length(); if(len == 0) return input; size_t startPos = 0; // Trim whitespace while(input[startPos] == ' ' && startPos < len) startPos++; while(input[len-1] == ' ' && startPos < len) len--; std::string val = input.substr(startPos, len-startPos); // std::cout << "val = " << val << "\n"; len = val.length(); startPos = 0; // If the length of the string is less than 2, then radix // is decimal and there is no exponent. if (len < 2) return val; bool isNegative = false; std::string ans; // First check to see if we start with a sign indicator if (val[0] == '-') { ans = "-"; ++startPos; isNegative = true; } else if (val[0] == '+') ++startPos; if (len - startPos < 2) return val; if (val.substr(startPos, 2) == "0x" || val.substr(startPos, 2) == "0X") { // If we start with "0x", then the radix is hex. radix = 16; startPos += 2; } else if (val.substr(startPos, 2) == "0b" || val.substr(startPos, 2) == "0B") { // If we start with "0b", then the radix is binary. radix = 2; startPos += 2; } if (val.substr(startPos, 2) == "0o" || val.substr(startPos, 2) == "0O") { // If we start with "0o", then the radix is octal. radix = 8; startPos += 2; } int exp = 0; if (radix == 10) { // If radix is decimal, then see if there is an // exponent indicator. size_t expPos = val.find('e'); bool has_exponent = true; if (expPos == std::string::npos) expPos = val.find('E'); if (expPos == std::string::npos) { // No exponent indicator, so the mantissa goes to the end. expPos = len; has_exponent = false; } // std::cout << "startPos = " << startPos << " " << expPos << "\n"; ans += val.substr(startPos, expPos-startPos); if(has_exponent) { // Parse the exponent. std::istringstream iss(val.substr(expPos+1, len-expPos-1)); iss >> exp; } } else { // Check for a binary exponent indicator. size_t expPos = val.find('p'); bool has_exponent = true; if (expPos == std::string::npos) expPos = val.find('P'); if (expPos == std::string::npos) { // No exponent indicator, so the mantissa goes to the end. expPos = len; has_exponent = false; } // std::cout << "startPos = " << startPos << " " << expPos << "\n"; assert(startPos <= expPos); // Convert to binary as we go. for (size_t i=startPos; i<expPos; ++i) { if(radix == 16) { ans += hex2Bin(val[i]); } else if(radix == 8) { ans += oct2Bin(val[i]); } else { // radix == 2 ans += val[i]; } } // End in binary radix = 2; if (has_exponent) { // Parse the exponent. std::istringstream iss(val.substr(expPos+1, len-expPos-1)); iss >> exp; } } if (exp == 0) return ans; size_t decPos = ans.find('.'); if (decPos == std::string::npos) decPos = ans.length(); if ((int) decPos + exp >= (int) ans.length()) { int i = decPos; for (; i< (int) ans.length()-1; ++i) ans[i] = ans[i+1]; for (; i< (int) ans.length(); ++i) ans[i] = '0'; for (; i< (int) decPos + exp; ++i) ans += '0'; return ans; } else if ((int) decPos + exp < (int) isNegative) { std::string dupAns = "0."; if (ans[0] == '-') dupAns = "-0."; for (int i=0; i<isNegative-(int)decPos-exp; ++i) dupAns += '0'; for (size_t i=isNegative; i< ans.length(); ++i) if (ans[i] != '.') dupAns += ans[i]; return dupAns; } if (exp > 0) for (size_t i=decPos; i<decPos+exp; ++i) ans[i] = ans[i+1]; else { if (decPos == ans.length()) ans += ' '; for (int i=decPos; i>(int)decPos+exp; --i) ans[i] = ans[i-1]; } ans[decPos+exp] = '.'; return ans; } /// sub_1 - This function subtracts a single "digit" (64-bit word), y, from /// the multi-digit integer array, x[], propagating the borrowed 1 value until /// no further borrowing is neeeded or it runs out of "digits" in x. The result /// is 1 if "borrowing" exhausted the digits in x, or 0 if x was not exhausted. /// In other words, if y > x then this function returns 1, otherwise 0. /// @returns the borrow out of the subtraction static INLINE bool sub_1(uint64_t x[], uint32_t len, uint64_t y) { for (uint32_t i = 0; i < len; ++i) { uint64_t __X = x[i]; x[i] -= y; if (y > __X) y = 1; // We have to "borrow 1" from next "digit" else { y = 0; // No need to borrow break; // Remaining digits are unchanged so exit early } } return (y != 0); } /// add_1 - This function adds a single "digit" integer, y, to the multiple /// "digit" integer array, x[]. x[] is modified to reflect the addition and /// 1 is returned if there is a carry out, otherwise 0 is returned. /// @returns the carry of the addition. static INLINE bool add_1(uint64_t dest[], uint64_t x[], uint32_t len, uint64_t y) { for (uint32_t i = 0; i < len; ++i) { dest[i] = y + x[i]; if (dest[i] < y) y = 1; // Carry one to next digit. else { y = 0; // No need to carry so exit early break; } } return (y != 0); } /// add - This function adds the integer array x to the integer array Y and /// places the result in dest. /// @returns the carry out from the addition /// @brief General addition of 64-bit integer arrays static INLINE bool add(uint64_t *dest, const uint64_t *x, const uint64_t *y, uint32_t destlen, uint32_t xlen, uint32_t ylen, bool xsigned, bool ysigned) { bool carry = false; uint32_t len = AESL_std::min(xlen, ylen); uint32_t i; for (i = 0; i< len && i < destlen; ++i) { uint64_t limit = AESL_std::min(x[i],y[i]); // must come first in case dest == x dest[i] = x[i] + y[i] + carry; carry = dest[i] < limit || (carry && dest[i] == limit); } if (xlen > ylen) { const uint64_t yext = ysigned && int64_t(y[ylen-1])<0 ? -1 : 0; for (i=ylen; i< xlen && i < destlen; i++) { uint64_t limit = AESL_std::min(x[i], yext); dest[i] = x[i] + yext + carry; carry = (dest[i] < limit)||(carry && dest[i] == limit); } } else if (ylen> xlen) { const uint64_t xext = xsigned && int64_t(x[xlen-1])<0 ? -1 : 0; for (i=xlen; i< ylen && i < destlen; i++) { uint64_t limit = AESL_std::min(xext, y[i]); dest[i] = xext + y[i] + carry; carry = (dest[i] < limit)||(carry && dest[i] == limit); } } return carry; } /// @returns returns the borrow out. /// @brief Generalized subtraction of 64-bit integer arrays. static INLINE bool sub(uint64_t *dest, const uint64_t *x, const uint64_t *y, uint32_t destlen, uint32_t xlen, uint32_t ylen, bool xsigned, bool ysigned) { bool borrow = false; uint32_t i; uint32_t len = AESL_std::min(xlen, ylen); for (i = 0; i < len && i < destlen; ++i) { uint64_t x_tmp = borrow ? x[i] - 1 : x[i]; borrow = y[i] > x_tmp || (borrow && x[i] == 0); dest[i] = x_tmp - y[i]; } if (xlen > ylen) { const uint64_t yext = ysigned && int64_t(y[ylen-1])<0 ? -1 : 0; for (i=ylen; i< xlen && i < destlen; i++) { uint64_t x_tmp = borrow ? x[i] - 1 : x[i]; borrow = yext > x_tmp || (borrow && x[i] == 0); dest[i] = x_tmp - yext; } } else if (ylen> xlen) { const uint64_t xext = xsigned && int64_t(x[xlen-1])<0 ? -1 : 0; for (i=xlen; i< ylen && i < destlen; i++) { uint64_t x_tmp = borrow ? xext - 1 : xext; borrow = y[i] > x_tmp || (borrow && xext==0); dest[i] = x_tmp - y[i]; } } return borrow; } /// Subtracts the RHS ap_private from this ap_private /// @returns this, after subtraction /// @brief Subtraction assignment operator. /// Multiplies an integer array, x by a a uint64_t integer and places the result /// into dest. /// @returns the carry out of the multiplication. /// @brief Multiply a multi-digit ap_private by a single digit (64-bit) integer. static INLINE uint64_t mul_1(uint64_t dest[], const uint64_t x[], uint32_t len, uint64_t y) { // Split y into high 32-bit part (hy) and low 32-bit part (ly) uint64_t ly = y & 0xffffffffULL, hy = (y) >> 32; uint64_t carry = 0; static const uint64_t two_power_32 = 1ULL << 32; // For each digit of x. for (uint32_t i = 0; i < len; ++i) { // Split x into high and low words uint64_t lx = x[i] & 0xffffffffULL; uint64_t hx = (x[i]) >> 32; // hasCarry - A flag to indicate if there is a carry to the next digit. // hasCarry == 0, no carry // hasCarry == 1, has carry // hasCarry == 2, no carry and the calculation result == 0. uint8_t hasCarry = 0; dest[i] = carry + lx * ly; // Determine if the add above introduces carry. hasCarry = (dest[i] < carry) ? 1 : 0; carry = hx * ly + ((dest[i]) >> 32) + (hasCarry ? two_power_32 : 0); // The upper limit of carry can be (2^32 - 1)(2^32 - 1) + // (2^32 - 1) + 2^32 = 2^64. hasCarry = (!carry && hasCarry) ? 1 : (!carry ? 2 : 0); carry += (lx * hy) & 0xffffffffULL; dest[i] = ((carry) << 32) | (dest[i] & 0xffffffffULL); carry = (((!carry && hasCarry != 2) || hasCarry == 1) ? two_power_32 : 0) + ((carry) >> 32) + ((lx * hy) >> 32) + hx * hy; } return carry; } /// Multiplies integer array x by integer array y and stores the result into /// the integer array dest. Note that dest's size must be >= xlen + ylen in order to /// do a full precision computation. If it is not, then only the low-order words /// are returned. /// @brief Generalized multiplicate of integer arrays. static INLINE void mul(uint64_t dest[], const uint64_t x[], uint32_t xlen, const uint64_t y[], uint32_t ylen, uint32_t destlen) { assert(xlen > 0); assert(ylen > 0); assert(destlen >= xlen + ylen); if(xlen < destlen) dest[xlen] = mul_1(dest, x, xlen, y[0]); for (uint32_t i = 1; i < ylen; ++i) { uint64_t ly = y[i] & 0xffffffffULL, hy = (y[i]) >> 32; uint64_t carry = 0, lx = 0, hx = 0; for (uint32_t j = 0; j < xlen; ++j) { lx = x[j] & 0xffffffffULL; hx = (x[j]) >> 32; // hasCarry - A flag to indicate if has carry. // hasCarry == 0, no carry // hasCarry == 1, has carry // hasCarry == 2, no carry and the calculation result == 0. uint8_t hasCarry = 0; uint64_t resul = carry + lx * ly; hasCarry = (resul < carry) ? 1 : 0; carry = (hasCarry ? (1ULL << 32) : 0) + hx * ly + ((resul) >> 32); hasCarry = (!carry && hasCarry) ? 1 : (!carry ? 2 : 0); carry += (lx * hy) & 0xffffffffULL; resul = ((carry) << 32) | (resul & 0xffffffffULL); if(i+j < destlen) dest[i+j] += resul; carry = (((!carry && hasCarry != 2) || hasCarry == 1) ? (1ULL << 32) : 0)+ ((carry) >> 32) + (dest[i+j] < resul ? 1 : 0) + ((lx * hy) >> 32) + hx * hy; } if (i+xlen < destlen) dest[i+xlen] = carry; } } /// Implementation of Knuth's Algorithm D (Division of nonnegative integers) /// from "Art of Computer Programming, Volume 2", section 4.3.1, p. 272. The /// variables here have the same names as in the algorithm. Comments explain /// the algorithm and any deviation from it. static INLINE void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r, uint32_t m, uint32_t n) { assert(u && "Must provide dividend"); assert(v && "Must provide divisor"); assert(q && "Must provide quotient"); assert(u != v && u != q && v != q && "Must us different memory"); assert(n>1 && "n must be > 1"); // Knuth uses the value b as the base of the number system. In our case b // is 2^31 so we just set it to -1u. uint64_t b = uint64_t(1) << 32; //DEBUG(cerr << "KnuthDiv: m=" << m << " n=" << n << '\n'); //DEBUG(cerr << "KnuthDiv: original:"); //DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << std::setbase(16) << u[i]); //DEBUG(cerr << " by"); //DEBUG(for (int i = n; i >0; i--) cerr << " " << std::setbase(16) << v[i-1]); //DEBUG(cerr << '\n'); // D1. [Normalize.] Set d = b / (v[n-1] + 1) and multiply all the digits of // u and v by d. Note that we have taken Knuth's advice here to use a power // of 2 value for d such that d * v[n-1] >= b/2 (b is the base). A power of // 2 allows us to shift instead of multiply and it is easy to determine the // shift amount from the leading zeros. We are basically normalizing the u // and v so that its high bits are shifted to the top of v's range without // overflow. Note that this can require an extra word in u so that u must // be of length m+n+1. uint32_t shift = CountLeadingZeros_32(v[n-1]); uint32_t v_carry = 0; uint32_t u_carry = 0; if (shift) { for (uint32_t i = 0; i < m+n; ++i) { uint32_t u_tmp = (u[i]) >> (32 - shift); u[i] = ((u[i]) << (shift)) | u_carry; u_carry = u_tmp; } for (uint32_t i = 0; i < n; ++i) { uint32_t v_tmp = (v[i]) >> (32 - shift); v[i] = ((v[i]) << (shift)) | v_carry; v_carry = v_tmp; } } u[m+n] = u_carry; //DEBUG(cerr << "KnuthDiv: normal:"); //DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << std::setbase(16) << u[i]); //DEBUG(cerr << " by"); //DEBUG(for (int i = n; i >0; i--) cerr << " " << std::setbase(16) << v[i-1]); //DEBUG(cerr << '\n'); // D2. [Initialize j.] Set j to m. This is the loop counter over the places. int j = m; do { //DEBUG(cerr << "KnuthDiv: quotient digit #" << j << '\n'); // D3. [Calculate q'.]. // Set qp = (u[j+n]*b + u[j+n-1]) / v[n-1]. (qp=qprime=q') // Set rp = (u[j+n]*b + u[j+n-1]) % v[n-1]. (rp=rprime=r') // Now test if qp == b or qp*v[n-2] > b*rp + u[j+n-2]; if so, decrease // qp by 1, inrease rp by v[n-1], and repeat this test if rp < b. The test // on v[n-2] determines at high speed most of the cases in which the trial // value qp is one too large, and it eliminates all cases where qp is two // too large. uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]); //DEBUG(cerr << "KnuthDiv: dividend == " << dividend << '\n'); uint64_t qp = dividend / v[n-1]; uint64_t rp = dividend % v[n-1]; if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) { qp--; rp += v[n-1]; if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) qp--; } //DEBUG(cerr << "KnuthDiv: qp == " << qp << ", rp == " << rp << '\n'); // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation // consists of a simple multiplication by a one-place number, combined with // a subtraction. bool isNeg = false; for (uint32_t i = 0; i < n; ++i) { uint64_t u_tmp = uint64_t(u[j+i]) | ((uint64_t(u[j+i+1])) << 32); uint64_t subtrahend = uint64_t(qp) * uint64_t(v[i]); bool borrow = subtrahend > u_tmp; /*DEBUG(cerr << "KnuthDiv: u_tmp == " << u_tmp << ", subtrahend == " << subtrahend << ", borrow = " << borrow << '\n');*/ uint64_t result = u_tmp - subtrahend; uint32_t k = j + i; u[k++] = (uint32_t)(result & (b-1)); // subtract low word u[k++] = (uint32_t)((result) >> 32); // subtract high word while (borrow && k <= m+n) { // deal with borrow to the left borrow = u[k] == 0; u[k]--; k++; } isNeg |= borrow; /*DEBUG(cerr << "KnuthDiv: u[j+i] == " << u[j+i] << ", u[j+i+1] == " << u[j+i+1] << '\n');*/ } /*DEBUG(cerr << "KnuthDiv: after subtraction:"); DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << u[i]); DEBUG(cerr << '\n');*/ // The digits (u[j+n]...u[j]) should be kept positive; if the result of // this step is actually negative, (u[j+n]...u[j]) should be left as the // true value plus b**(n+1), namely as the b's complement of // the true value, and a "borrow" to the left should be remembered. // if (isNeg) { bool carry = true; // true because b's complement is "complement + 1" for (uint32_t i = 0; i <= m+n; ++i) { u[i] = ~u[i] + carry; // b's complement carry = carry && u[i] == 0; } } /*DEBUG(cerr << "KnuthDiv: after complement:"); DEBUG(for (int i = m+n; i >=0; i--) cerr << " " << u[i]); DEBUG(cerr << '\n');*/ // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was // negative, go to step D6; otherwise go on to step D7. q[j] = (uint32_t)qp; if (isNeg) { // D6. [Add back]. The probability that this step is necessary is very // small, on the order of only 2/b. Make sure that test data accounts for // this possibility. Decrease q[j] by 1 q[j]--; // and add (0v[n-1]...v[1]v[0]) to (u[j+n]u[j+n-1]...u[j+1]u[j]). // A carry will occur to the left of u[j+n], and it should be ignored // since it cancels with the borrow that occurred in D4. bool carry = false; for (uint32_t i = 0; i < n; i++) { uint32_t limit = AESL_std::min(u[j+i],v[i]); u[j+i] += v[i] + carry; carry = u[j+i] < limit || (carry && u[j+i] == limit); } u[j+n] += carry; } /*DEBUG(cerr << "KnuthDiv: after correction:"); DEBUG(for (int i = m+n; i >=0; i--) cerr <<" " << u[i]); DEBUG(cerr << "\nKnuthDiv: digit result = " << q[j] << '\n');*/ // D7. [Loop on j.] Decrease j by one. Now if j >= 0, go back to D3. } while (--j >= 0); /*DEBUG(cerr << "KnuthDiv: quotient:"); DEBUG(for (int i = m; i >=0; i--) cerr <<" " << q[i]); DEBUG(cerr << '\n');*/ // D8. [Unnormalize]. Now q[...] is the desired quotient, and the desired // remainder may be obtained by dividing u[...] by d. If r is non-null we // compute the remainder (urem uses this). if (r) { // The value d is expressed by the "shift" value above since we avoided // multiplication by d by using a shift left. So, all we have to do is // shift right here. In order to mak if (shift) { uint32_t carry = 0; //DEBUG(cerr << "KnuthDiv: remainder:"); for (int i = n-1; i >= 0; i--) { r[i] = ((u[i]) >> (shift)) | carry; carry = (u[i]) << (32 - shift); //DEBUG(cerr << " " << r[i]); } } else { for (int i = n-1; i >= 0; i--) { r[i] = u[i]; //DEBUG(cerr << " " << r[i]); } } //DEBUG(cerr << '\n'); } //DEBUG(cerr << std::setbase(10) << '\n'); } template<int _AP_W, bool _AP_S> void divide(const ap_private<_AP_W, _AP_S>& LHS, uint32_t lhsWords, const ap_private<_AP_W, _AP_S>& RHS, uint32_t rhsWords, ap_private<_AP_W, _AP_S> *Quotient, ap_private<_AP_W, _AP_S> *Remainder) { assert(lhsWords >= rhsWords && "Fractional result"); enum {APINT_BITS_PER_WORD=64}; // First, compose the values into an array of 32-bit words instead of // 64-bit words. This is a necessity of both the "short division" algorithm // and the the Knuth "classical algorithm" which requires there to be native // operations for +, -, and * on an m bit value with an m*2 bit result. We // can't use 64-bit operands here because we don't have native results of // 128-bits. Furthremore, casting the 64-bit values to 32-bit values won't // work on large-endian machines. uint64_t mask = ~0ull >> (sizeof(uint32_t)*8); uint32_t n = rhsWords * 2; uint32_t m = (lhsWords * 2) - n; // Allocate space for the temporary values we need either on the stack, if // it will fit, or on the heap if it won't. uint32_t SPACE[128]; uint32_t *__U = 0; uint32_t *__V = 0; uint32_t *__Q = 0; uint32_t *__R = 0; if ((Remainder?4:3)*n+2*m+1 <= 128) { __U = &SPACE[0]; __V = &SPACE[m+n+1]; __Q = &SPACE[(m+n+1) + n]; if (Remainder) __R = &SPACE[(m+n+1) + n + (m+n)]; } else { __U = new uint32_t[m + n + 1]; __V = new uint32_t[n]; __Q = new uint32_t[m+n]; if (Remainder) __R = new uint32_t[n]; } // Initialize the dividend memset(__U, 0, (m+n+1)*sizeof(uint32_t)); for (unsigned i = 0; i < lhsWords; ++i) { uint64_t tmp = LHS.get_pVal(i); __U[i * 2] = (uint32_t)(tmp & mask); __U[i * 2 + 1] = (tmp) >> (sizeof(uint32_t)*8); } __U[m+n] = 0; // this extra word is for "spill" in the Knuth algorithm. // Initialize the divisor memset(__V, 0, (n)*sizeof(uint32_t)); for (unsigned i = 0; i < rhsWords; ++i) { uint64_t tmp = RHS.get_pVal(i); __V[i * 2] = (uint32_t)(tmp & mask); __V[i * 2 + 1] = (tmp) >> (sizeof(uint32_t)*8); } // initialize the quotient and remainder memset(__Q, 0, (m+n) * sizeof(uint32_t)); if (Remainder) memset(__R, 0, n * sizeof(uint32_t)); // Now, adjust m and n for the Knuth division. n is the number of words in // the divisor. m is the number of words by which the dividend exceeds the // divisor (i.e. m+n is the length of the dividend). These sizes must not // contain any zero words or the Knuth algorithm fails. for (unsigned i = n; i > 0 && __V[i-1] == 0; i--) { n--; m++; } for (unsigned i = m+n; i > 0 && __U[i-1] == 0; i--) m--; // If we're left with only a single word for the divisor, Knuth doesn't work // so we implement the short division algorithm here. This is much simpler // and faster because we are certain that we can divide a 64-bit quantity // by a 32-bit quantity at hardware speed and short division is simply a // series of such operations. This is just like doing short division but we // are using base 2^32 instead of base 10. assert(n != 0 && "Divide by zero?"); if (n == 1) { uint32_t divisor = __V[0]; uint32_t remainder = 0; for (int i = m+n-1; i >= 0; i--) { uint64_t partial_dividend = (uint64_t(remainder)) << 32 | __U[i]; if (partial_dividend == 0) { __Q[i] = 0; remainder = 0; } else if (partial_dividend < divisor) { __Q[i] = 0; remainder = (uint32_t)partial_dividend; } else if (partial_dividend == divisor) { __Q[i] = 1; remainder = 0; } else { __Q[i] = (uint32_t)(partial_dividend / divisor); remainder = (uint32_t)(partial_dividend - (__Q[i] * divisor)); } } if (__R) __R[0] = remainder; } else { // Now we're ready to invoke the Knuth classical divide algorithm. In this // case n > 1. KnuthDiv(__U, __V, __Q, __R, m, n); } // If the caller wants the quotient if (Quotient) { // Set up the Quotient value's memory. if (Quotient->BitWidth != LHS.BitWidth) { if (Quotient->isSingleWord()) Quotient->set_VAL(0); } else Quotient->clear(); // The quotient is in Q. Reconstitute the quotient into Quotient's low // order words. if (lhsWords == 1) { uint64_t tmp = uint64_t(__Q[0]) | ((uint64_t(__Q[1])) << (APINT_BITS_PER_WORD / 2)); Quotient->set_VAL(tmp); } else { assert(!Quotient->isSingleWord() && "Quotient ap_private not large enough"); for (unsigned i = 0; i < lhsWords; ++i) Quotient->set_pVal(i, uint64_t(__Q[i*2]) | ((uint64_t(__Q[i*2+1])) << (APINT_BITS_PER_WORD / 2))); } Quotient->clearUnusedBits(); } // If the caller wants the remainder if (Remainder) { // Set up the Remainder value's memory. if (Remainder->BitWidth != RHS.BitWidth) { if (Remainder->isSingleWord()) Remainder->set_VAL(0); } else Remainder->clear(); // The remainder is in R. Reconstitute the remainder into Remainder's low // order words. if (rhsWords == 1) { uint64_t tmp = uint64_t(__R[0]) | ((uint64_t(__R[1])) << (APINT_BITS_PER_WORD / 2)); Remainder->set_VAL(tmp); } else { assert(!Remainder->isSingleWord() && "Remainder ap_private not large enough"); for (unsigned i = 0; i < rhsWords; ++i) Remainder->set_pVal(i, uint64_t(__R[i*2]) | ((uint64_t(__R[i*2+1])) << (APINT_BITS_PER_WORD / 2))); } Remainder->clearUnusedBits(); } // Clean up the memory we allocated. if (__U != &SPACE[0]) { delete [] __U; delete [] __V; delete [] __Q; delete [] __R; } } template<int _AP_W, bool _AP_S> void divide(const ap_private<_AP_W, _AP_S>& LHS, uint32_t lhsWords, uint64_t RHS, ap_private<_AP_W, _AP_S> *Quotient, ap_private<_AP_W, _AP_S> *Remainder) { uint32_t rhsWords=1; assert(lhsWords >= rhsWords && "Fractional result"); enum {APINT_BITS_PER_WORD=64}; // First, compose the values into an array of 32-bit words instead of // 64-bit words. This is a necessity of both the "short division" algorithm // and the the Knuth "classical algorithm" which requires there to be native // operations for +, -, and * on an m bit value with an m*2 bit result. We // can't use 64-bit operands here because we don't have native results of // 128-bits. Furthremore, casting the 64-bit values to 32-bit values won't // work on large-endian machines. uint64_t mask = ~0ull >> (sizeof(uint32_t)*8); uint32_t n = 2; uint32_t m = (lhsWords * 2) - n; // Allocate space for the temporary values we need either on the stack, if // it will fit, or on the heap if it won't. uint32_t SPACE[128]; uint32_t *__U = 0; uint32_t *__V = 0; uint32_t *__Q = 0; uint32_t *__R = 0; if ((Remainder?4:3)*n+2*m+1 <= 128) { __U = &SPACE[0]; __V = &SPACE[m+n+1]; __Q = &SPACE[(m+n+1) + n]; if (Remainder) __R = &SPACE[(m+n+1) + n + (m+n)]; } else { __U = new uint32_t[m + n + 1]; __V = new uint32_t[n]; __Q = new uint32_t[m+n]; if (Remainder) __R = new uint32_t[n]; } // Initialize the dividend memset(__U, 0, (m+n+1)*sizeof(uint32_t)); for (unsigned i = 0; i < lhsWords; ++i) { uint64_t tmp = LHS.get_pVal(i); __U[i * 2] = tmp & mask; __U[i * 2 + 1] = (tmp) >> (sizeof(uint32_t)*8); } __U[m+n] = 0; // this extra word is for "spill" in the Knuth algorithm. // Initialize the divisor memset(__V, 0, (n)*sizeof(uint32_t)); __V[0] = RHS & mask; __V[1] = (RHS) >> (sizeof(uint32_t)*8); // initialize the quotient and remainder memset(__Q, 0, (m+n) * sizeof(uint32_t)); if (Remainder) memset(__R, 0, n * sizeof(uint32_t)); // Now, adjust m and n for the Knuth division. n is the number of words in // the divisor. m is the number of words by which the dividend exceeds the // divisor (i.e. m+n is the length of the dividend). These sizes must not // contain any zero words or the Knuth algorithm fails. for (unsigned i = n; i > 0 && __V[i-1] == 0; i--) { n--; m++; } for (unsigned i = m+n; i > 0 && __U[i-1] == 0; i--) m--; // If we're left with only a single word for the divisor, Knuth doesn't work // so we implement the short division algorithm here. This is much simpler // and faster because we are certain that we can divide a 64-bit quantity // by a 32-bit quantity at hardware speed and short division is simply a // series of such operations. This is just like doing short division but we // are using base 2^32 instead of base 10. assert(n != 0 && "Divide by zero?"); if (n == 1) { uint32_t divisor = __V[0]; uint32_t remainder = 0; for (int i = m+n-1; i >= 0; i--) { uint64_t partial_dividend = (uint64_t(remainder)) << 32 | __U[i]; if (partial_dividend == 0) { __Q[i] = 0; remainder = 0; } else if (partial_dividend < divisor) { __Q[i] = 0; remainder = partial_dividend; } else if (partial_dividend == divisor) { __Q[i] = 1; remainder = 0; } else { __Q[i] = partial_dividend / divisor; remainder = partial_dividend - (__Q[i] * divisor); } } if (__R) __R[0] = remainder; } else { // Now we're ready to invoke the Knuth classical divide algorithm. In this // case n > 1. KnuthDiv(__U, __V, __Q, __R, m, n); } // If the caller wants the quotient if (Quotient) { // Set up the Quotient value's memory. if (Quotient->BitWidth != LHS.BitWidth) { if (Quotient->isSingleWord()) Quotient->set_VAL(0); } else Quotient->clear(); // The quotient is in Q. Reconstitute the quotient into Quotient's low // order words. if (lhsWords == 1) { uint64_t tmp = uint64_t(__Q[0]) | ((uint64_t(__Q[1])) << (APINT_BITS_PER_WORD / 2)); Quotient->set_VAL(tmp); } else { assert(!Quotient->isSingleWord() && "Quotient ap_private not large enough"); for (unsigned i = 0; i < lhsWords; ++i) Quotient->set_pVal(i, uint64_t(__Q[i*2]) | ((uint64_t(__Q[i*2+1])) << (APINT_BITS_PER_WORD / 2))); } Quotient->clearUnusedBits(); } // If the caller wants the remainder if (Remainder) { // Set up the Remainder value's memory. if (Remainder->BitWidth != 64 /* RHS.BitWidth */) { if (Remainder->isSingleWord()) Remainder->set_VAL(0); } else Remainder->clear(); // The remainder is in __R. Reconstitute the remainder into Remainder's low // order words. if (rhsWords == 1) { uint64_t tmp = uint64_t(__R[0]) | ((uint64_t(__R[1])) << (APINT_BITS_PER_WORD / 2)); Remainder->set_VAL(tmp); } else { assert(!Remainder->isSingleWord() && "Remainder ap_private not large enough"); for (unsigned i = 0; i < rhsWords; ++i) Remainder->set_pVal(i, uint64_t(__R[i*2]) | ((uint64_t(__R[i*2+1])) << (APINT_BITS_PER_WORD / 2))); } Remainder->clearUnusedBits(); } // Clean up the memory we allocated. if (__U != &SPACE[0]) { delete [] __U; delete [] __V; delete [] __Q; delete [] __R; } } /// @brief Logical right-shift function. template<int _AP_W, bool _AP_S, bool _AP_C> INLINE ap_private<_AP_W, _AP_S, _AP_C> lshr(const ap_private<_AP_W, _AP_S, _AP_C>& LHS, uint32_t shiftAmt) { return LHS.lshr(shiftAmt); } /// Left-shift the ap_private by shiftAmt. /// @brief Left-shift function. template<int _AP_W, bool _AP_S, bool _AP_C> INLINE ap_private<_AP_W, _AP_S, _AP_C> shl(const ap_private<_AP_W, _AP_S, _AP_C>& LHS, uint32_t shiftAmt) { return LHS.shl(shiftAmt); } } // namespace ap_private_ops #endif // LLVM_SUPPORT_MATHEXTRAS_H #ifndef AP_PRIVATE_H #define AP_PRIVATE_H enum ap_q_mode { AP_RND, // rounding to plus infinity AP_RND_ZERO,// rounding to zero AP_RND_MIN_INF,// rounding to minus infinity AP_RND_INF,// rounding to infinity AP_RND_CONV, // convergent rounding AP_TRN, // truncation AP_TRN_ZERO // truncation to zero }; enum ap_o_mode { AP_SAT, // saturation AP_SAT_ZERO, // saturation to zero AP_SAT_SYM, // symmetrical saturation AP_WRAP, // wrap-around (*) AP_WRAP_SM // sign magnitude wrap-around (*) }; template<int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N> struct ap_fixed_base; template<int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N> struct af_range_ref; template<int _AP_W, int _AP_I, bool _AP_S, ap_q_mode _AP_Q, ap_o_mode _AP_O, int _AP_N> struct af_bit_ref; template<int _AP_W, bool _AP_S> struct ap_range_ref; template<int _AP_W, bool _AP_S> struct ap_bit_ref; template<int _AP_W1, typename _AP_T1, int _AP_W2, typename _AP_T2> struct ap_concat_ref; /// This enumeration just provides for internal constants used in this /// translation unit. enum { MIN_INT_BITS = 1, ///< Minimum number of bits that can be specified ///< Note that this must remain synchronized with IntegerType::MIN_INT_BITS MAX_INT_BITS = (1<<23)-1 ///< Maximum number of bits that can be specified ///< Note that this must remain synchronized with IntegerType::MAX_INT_BITS }; //===----------------------------------------------------------------------===// // ap_private Class //===----------------------------------------------------------------------===// /// ap_private - This class represents arbitrary precision constant integral values. /// It is a functional replacement for common case unsigned integer type like /// "unsigned", "unsigned long" or "uint64_t", but also allows non-byte-width /// integer sizes and large integer value types such as 3-bits, 15-bits, or more /// than 64-bits of precision. ap_private provides a variety of arithmetic operators /// and methods to manipulate integer values of any bit-width. It supports both /// the typical integer arithmetic and comparison operations as well as bitwise /// manipulation. /// /// The class has several invariants worth noting: /// * All bit, byte, and word positions are zero-based. /// * Once the bit width is set, it doesn't change except by the Truncate, /// SignExtend, or ZeroExtend operations. /// * All binary operators must be on ap_private instances of the same bit width. /// Attempting to use these operators on instances with different bit /// widths will yield an assertion. /// * The value is stored canonically as an unsigned value. For operations /// where it makes a difference, there are both signed and unsigned variants /// of the operation. For example, sdiv and udiv. However, because the bit /// widths must be the same, operations such as Mul and Add produce the same /// results regardless of whether the values are interpreted as signed or /// not. /// * In general, the class tries to follow the style of computation that LLVM /// uses in its IR. This simplifies its use for LLVM. /// /// @brief Class for arbitrary precision integers. #if defined(_MSC_VER) # if _MSC_VER < 1400 && !defined(for) # define for if(0);else for # endif typedef unsigned __int64 ap_ulong; typedef signed __int64 ap_slong; #else typedef unsigned long long ap_ulong; typedef signed long long ap_slong; #endif template <int _AP_N8, bool _AP_S> struct valtype; template<int _AP_N8> struct valtype<_AP_N8, false> { typedef uint64_t Type; }; template<int _AP_N8> struct valtype<_AP_N8, true> { typedef int64_t Type; }; template<> struct valtype<1, false> { typedef unsigned char Type; }; template<> struct valtype<2, false> { typedef unsigned short Type; }; template<> struct valtype<3, false> { typedef unsigned int Type; }; template<> struct valtype<4, false> { typedef unsigned int Type; }; template<> struct valtype<1, true> { typedef signed char Type; }; template<> struct valtype<2, true> { typedef short Type; }; template<> struct valtype<3, true> { typedef int Type; }; template<> struct valtype<4, true> { typedef int Type; }; template<bool enable> struct ap_private_enable_if {}; template<> struct ap_private_enable_if<true> {static const bool isValid = true;}; //When bitwidth < 64 template<int _AP_W, bool _AP_S> class ap_private <_AP_W, _AP_S, true> { // SFINAE pattern. Only consider this class when _AP_W <= 64 const static bool valid = ap_private_enable_if<_AP_W <= 64>::isValid; #ifdef _MSC_VER #pragma warning( disable : 4521 4522 ) #endif public: typedef typename valtype<(_AP_W+7)/8, _AP_S>::Type ValType; template<int _AP_W2, bool _AP_S2> struct RType { enum { mult_w = _AP_W+_AP_W2, mult_s = _AP_S||_AP_S2, plus_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2))+1, plus_s = _AP_S||_AP_S2, minus_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2))+1, minus_s = true, div_w = _AP_W+_AP_S2, div_s = _AP_S||_AP_S2, mod_w = AP_MIN(_AP_W,_AP_W2+(!_AP_S2&&_AP_S)), mod_s = _AP_S, logic_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2)), logic_s = _AP_S||_AP_S2 }; typedef ap_private<mult_w, mult_s> mult; typedef ap_private<plus_w, plus_s> plus; typedef ap_private<minus_w, minus_s> minus; typedef ap_private<logic_w, logic_s> logic; typedef ap_private<div_w, div_s> div; typedef ap_private<mod_w, mod_s> mod; typedef ap_private<_AP_W, _AP_S> arg1; typedef bool reduce; }; enum { APINT_BITS_PER_WORD = sizeof(uint64_t) * 8 }; enum { excess_bits = (_AP_W%APINT_BITS_PER_WORD) ? APINT_BITS_PER_WORD -(_AP_W%APINT_BITS_PER_WORD) : 0}; static const uint64_t mask = ((uint64_t)~0ULL >> (excess_bits)); static const uint64_t not_mask = ~mask; static const uint64_t sign_bit_mask = 1ULL << (APINT_BITS_PER_WORD-1); template<int _AP_W1> struct sign_ext_mask { static const uint64_t mask=~0ULL<<_AP_W1;}; static const int width = _AP_W; enum { BitWidth=_AP_W, _AP_N = 1, }; ValType VAL; ///< Used to store the <= 64 bits integer value. #ifdef AP_CANARY ValType CANARY; void check_canary() { assert(CANARY == (ValType)0xDEADBEEFDEADBEEF); } void set_canary() { CANARY = (ValType)0xDEADBEEFDEADBEEF; } #else void check_canary() {} void set_canary() {} #endif INLINE ValType& get_VAL(void) { return VAL; } INLINE ValType get_VAL(void) const{ return VAL; } INLINE ValType get_VAL(void) const volatile{ return VAL; } INLINE void set_VAL(uint64_t value) { VAL = (ValType)value; } INLINE ValType& get_pVal(int i) { return VAL; } INLINE ValType get_pVal(int i) const{ return VAL; } INLINE const uint64_t* get_pVal() const{ assert(0 && "invalid usage"); return 0; } INLINE ValType get_pVal(int i) const volatile { return VAL; } INLINE uint64_t* get_pVal() const volatile { assert(0 && "invalid usage"); return 0; } INLINE void set_pVal(int i, uint64_t value) { VAL = (ValType)value; } INLINE uint32_t getBitWidth() const { return BitWidth; } template<int _AP_W1, bool _AP_S1> ap_private<_AP_W, _AP_S>& operator=(const ap_private<_AP_W1, _AP_S1>& RHS) { VAL = (ValType)(RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> ap_private<_AP_W, _AP_S>& operator=(const volatile ap_private<_AP_W1, _AP_S1>& RHS) { VAL = (ValType)(RHS.get_VAL()); clearUnusedBits(); return *this; } void operator=(const ap_private& RHS) volatile { // Don't do anything for X = X VAL = RHS.get_VAL(); // No need to check because no harm done by copying. } ap_private& operator=(const ap_private& RHS) { // Don't do anything for X = X VAL = RHS.get_VAL(); // No need to check because no harm done by copying. return *this; } void operator=(const volatile ap_private& RHS) volatile { // Don't do anything for X = X VAL = RHS.get_VAL(); // No need to check because no harm done by copying. } ap_private& operator=(const volatile ap_private& RHS) { // Don't do anything for X = X VAL = RHS.get_VAL(); // No need to check because no harm done by copying. return *this; } template<int _AP_W2, bool _AP_S2> INLINE ap_private& operator = (const ap_range_ref<_AP_W2, _AP_S2>& op2) { *this = ap_private<_AP_W2, false>(op2); return *this; } private: explicit INLINE ap_private(uint64_t* val):VAL(val[0]) { set_canary(); clearUnusedBits(); check_canary(); } INLINE bool isSingleWord() const { return true; } INLINE void fromString(const char *strStart, uint32_t slen, uint8_t radix) { // Check our assumptions here assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); assert(strStart && "String is null?"); uint64_t tmpVAL = VAL; bool isNeg = false; if (*strStart == '-') { isNeg = true; strStart++; } switch(radix) { case 2: // sscanf(strStart,"%b",&VAL); // tmpVAL = *strStart =='1' ? ~0ULL : 0; for (;*strStart; ++strStart) { assert((*strStart=='0'|| *strStart=='1')&&("Wrong binary number") ); tmpVAL <<=1; tmpVAL |= (*strStart-'0'); } break; case 8: #if defined _MSC_VER sscanf_s(strStart,"%llo",&tmpVAL,slen+1); #else #if (defined(__WIN32__) || defined(__MINGW32__)) && !defined(__clang__) sscanf(strStart,"%I64o",&tmpVAL); #else #if defined(__x86_64__) && !defined(__MINGW32__) && !defined(__WIN32__) sscanf(strStart,"%lo",&tmpVAL); #else sscanf(strStart,"%llo",&tmpVAL); #endif //__x86_64__ #endif //__WIN32__ #endif //_MSC_VER break; case 10: #if defined _MSC_VER sscanf_s(strStart,"%llu",&tmpVAL,slen+1); #else #if (defined(__WIN32__) || defined(__MINGW32__)) && !defined(__clang__) sscanf(strStart,"%I64u",&tmpVAL); #else #if defined(__x86_64__) && !defined(__MINGW32__) && !defined(__WIN32__) sscanf(strStart,"%lu",&tmpVAL); #else sscanf(strStart,"%llu",&tmpVAL); #endif //__x86_64__ #endif //__WIN32__ #endif //_MSC_VER break; case 16: #if defined _MSC_VER sscanf_s(strStart,"%llx",&tmpVAL,slen+1); #else #if (defined(__WIN32__) || defined(__MINGW32__)) && !defined(__clang__) sscanf(strStart,"%I64x",&tmpVAL); #else #if defined(__x86_64__) && !defined(__MINGW32__) && !defined(__WIN32__) sscanf(strStart,"%lx",&tmpVAL); #else sscanf(strStart,"%llx",&tmpVAL); #endif //__x86_64__ #endif //__WIN32__ #endif //_MSC_VER break; default: assert(true && "Unknown radix"); // error } VAL = isNeg ? (ValType)(-tmpVAL) : (ValType) (tmpVAL); clearUnusedBits(); } INLINE ap_private(const std::string& val, uint8_t radix=2): VAL(0) { assert(!val.empty() && "String empty?"); set_canary(); fromString(val.c_str(), val.size(), radix); check_canary(); } INLINE ap_private(const char strStart[], uint32_t slen, uint8_t radix) : VAL(0) { set_canary(); fromString(strStart, slen, radix); check_canary(); } INLINE ap_private(uint32_t numWords, const uint64_t bigVal[]): VAL(bigVal[0]) { set_canary(); clearUnusedBits(); check_canary(); } public: INLINE ap_private() { set_canary(); clearUnusedBits(); check_canary(); } #define CTOR(TYPE) \ INLINE ap_private(TYPE v) : VAL((ValType)v) { \ set_canary(); \ clearUnusedBits(); \ check_canary(); \ } CTOR(int) CTOR(bool) CTOR(signed char) CTOR(unsigned char) CTOR(short) CTOR(unsigned short) CTOR(unsigned int) CTOR(long) CTOR(unsigned long) CTOR(unsigned long long) CTOR(long long) CTOR(half) CTOR(float) CTOR(double) #undef CTOR // INLINE ap_private(const ap_private& that) : VAL(that.get_VAL()) { // set_canary(); // clearUnusedBits(); // check_canary(); // } // INLINE ap_private(const ap_private<_AP_W, !_AP_S>& that) : VAL(that.get_VAL()) { // set_canary(); // clearUnusedBits(); // check_canary(); // } template<int _AP_W1, bool _AP_S1, bool _AP_OPT> INLINE ap_private(const ap_private<_AP_W1, _AP_S1, _AP_OPT>& that) : VAL((ValType)that.get_VAL()) { set_canary(); clearUnusedBits(); check_canary(); } template<int _AP_W1, bool _AP_S1, bool _AP_OPT> INLINE ap_private(const volatile ap_private<_AP_W1, _AP_S1, _AP_OPT>& that) : VAL((ValType)that.get_VAL()) { set_canary(); clearUnusedBits(); check_canary(); } explicit INLINE ap_private(const char* val) { set_canary(); int radix = 10; std::string str = ap_private_ops::parseString(val, radix); std::string::size_type pos = str.find('.'); //trunc all fraction part if (pos != std::string::npos) str = str.substr(pos); ap_private<_AP_W, _AP_S> ap_private_val(str, radix); operator = (ap_private_val); check_canary(); } INLINE ap_private(const char* val, signed char rd) { set_canary(); int radix = rd; std::string str = ap_private_ops::parseString(val, radix); std::string::size_type pos = str.find('.'); //trunc all fraction part if (pos != std::string::npos) str = str.substr(pos); ap_private<_AP_W, _AP_S> ap_private_val(str, radix); operator = (ap_private_val); check_canary(); } INLINE ~ap_private() {check_canary();} INLINE bool isNegative() const { static const uint64_t sign_mask = 1ULL << (_AP_W-1); return _AP_S && (sign_mask & VAL); } INLINE bool isPositive() const { return !isNegative(); } INLINE bool isStrictlyPositive() const { return !isNegative() && VAL!=0; } INLINE bool isAllOnesValue() const { return (mask & VAL) == mask; } INLINE bool operator==(const ap_private<_AP_W, _AP_S>& RHS) const { return VAL == RHS.get_VAL(); } INLINE bool operator==(const ap_private<_AP_W, !_AP_S>& RHS) const { return (uint64_t)VAL == (uint64_t)RHS.get_VAL(); } INLINE bool operator==(uint64_t Val) const { return ((uint64_t)VAL == Val); } INLINE bool operator!=(uint64_t Val) const { return ((uint64_t)VAL != Val); } INLINE bool operator!=(const ap_private<_AP_W, _AP_S>& RHS) const { return VAL != RHS.get_VAL(); } INLINE bool operator!=(const ap_private<_AP_W, !_AP_S>& RHS) const { return (uint64_t)VAL != (uint64_t)RHS.get_VAL(); } const ap_private operator++() { ++VAL; clearUnusedBits(); return *this; } const ap_private operator--(int) { ap_private orig(*this); --VAL; clearUnusedBits(); return orig; } const ap_private operator--() { --VAL; clearUnusedBits(); return *this;} INLINE bool operator !() const { return !VAL;} const ap_private operator++(int) { ap_private orig(*this); VAL++; clearUnusedBits(); return orig; } INLINE ap_private<AP_MIN(64, _AP_W + 1), true> operator-() const { return ap_private<1,false>(0) - (*this); } INLINE std::string toString(uint8_t radix, bool wantSigned) const ; INLINE std::string toStringUnsigned(uint8_t radix = 10) const { return toString(radix, false); } INLINE std::string toStringSigned(uint8_t radix = 10) const { return toString(radix, true); } INLINE void clear() { VAL=0; } INLINE ap_private& clear(uint32_t bitPosition) { VAL &= ~(1ULL<<(bitPosition)); clearUnusedBits(); return *this;} INLINE ap_private ashr(uint32_t shiftAmt) const { if (_AP_S) return ap_private((shiftAmt == BitWidth) ? 0 : ((int64_t)VAL) >> (shiftAmt)); else return ap_private((shiftAmt == BitWidth) ? 0 : ((uint64_t)VAL) >> (shiftAmt)); } INLINE ap_private lshr(uint32_t shiftAmt) const { return ap_private((shiftAmt == BitWidth) ? ap_private(0) : ap_private((VAL&mask) >> (shiftAmt))); } INLINE ap_private shl(uint32_t shiftAmt) const //just for clang compiler #if defined(__clang__) && !defined(__CLANG_3_1__) __attribute__((no_sanitize("undefined"))) #endif { if (shiftAmt > BitWidth) { if (!isNegative()) return ap_private(0); else return ap_private(-1); } if (shiftAmt == BitWidth) return ap_private(0); else return ap_private((VAL) << (shiftAmt)); //return ap_private((shiftAmt == BitWidth) ? ap_private(0ULL) : ap_private(VAL << shiftAmt)); } INLINE int64_t getSExtValue() const { return VAL; } INLINE uint64_t getZExtValue() const { return VAL & mask; } template<int _AP_W2, bool _AP_S2> INLINE ap_private(const ap_range_ref<_AP_W2,_AP_S2>& ref) { set_canary(); *this=ref.get(); check_canary(); } template<int _AP_W2, bool _AP_S2> INLINE ap_private(const ap_bit_ref<_AP_W2,_AP_S2>& ref) { set_canary(); *this = ((uint64_t)(bool)ref); check_canary(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private(const ap_concat_ref<_AP_W2, _AP_T2,_AP_W3, _AP_T3>& ref) { set_canary(); *this=ref.get(); check_canary(); } template<int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_private(const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &val) { set_canary(); *this = ((val.operator ap_private<_AP_W2, false> ())); check_canary(); } template<int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_private(const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &val) { set_canary(); *this = (uint64_t)(bool)val; check_canary(); } INLINE void write(const ap_private<_AP_W, _AP_S>& op2) volatile { *this = (op2); } //Explicit conversions to C interger types //----------------------------------------------------------- INLINE operator ValType () const { return get_VAL(); } INLINE int to_uchar() const { return (unsigned char) get_VAL(); } INLINE int to_char() const { return (signed char) get_VAL(); } INLINE int to_ushort() const { return (unsigned short) get_VAL(); } INLINE int to_short() const { return (short) get_VAL(); } INLINE int to_int() const { // ap_private<64 /* _AP_W */, _AP_S> res(V); return (int) get_VAL(); } INLINE unsigned to_uint() const { return (unsigned) get_VAL(); } INLINE long to_long() const { return (long) get_VAL(); } INLINE unsigned long to_ulong() const { return (unsigned long) get_VAL(); } INLINE ap_slong to_int64() const { return (ap_slong) get_VAL(); } INLINE ap_ulong to_uint64() const { return (ap_ulong) get_VAL(); } INLINE double to_double() const { if (isNegative()) return roundToDouble(true); else return roundToDouble(false); } INLINE unsigned length() const { return _AP_W; } INLINE bool isMinValue() const { return VAL == 0;} template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator&=(const ap_private<_AP_W1, _AP_S1>& RHS) { VAL = (ValType)(((uint64_t)VAL)&RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator|=(const ap_private<_AP_W1, _AP_S1>& RHS) { if(_AP_W != _AP_W1) fprintf(stderr, "Warning! Bitsize mismach for ap_[u]int |= ap_[u]int.\n"); VAL = (ValType)(((uint64_t)VAL)|RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator^=(const ap_private<_AP_W1, _AP_S1>& RHS){ if(_AP_W != _AP_W1) fprintf(stderr, "Warning! Bitsize mismach for ap_[u]int ^= ap_[u]int.\n"); VAL = (ValType)(((uint64_t)VAL)^RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator*=(const ap_private<_AP_W1, _AP_S1>& RHS){ if(_AP_W != _AP_W1) fprintf(stderr, "Warning! Bitsize mismach for ap_[u]int *= ap_[u]int.\n"); VAL = (ValType)(((uint64_t)VAL)*RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator+=(const ap_private<_AP_W1, _AP_S1>& RHS){ VAL = (ValType)(((uint64_t)VAL)+RHS.get_VAL()); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator-=(const ap_private<_AP_W1, _AP_S1>& RHS){ VAL = (ValType)(((uint64_t)VAL)-RHS.get_VAL()); clearUnusedBits(); return *this; } INLINE const ap_private& operator<<=(uint32_t shiftAmt) { VAL<<=shiftAmt; clearUnusedBits(); return *this; } template <int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1, _AP_S1>::logic operator&(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1, _AP_S1>::logic_w <= 64) { typename RType<_AP_W1, _AP_S1>::logic Ret(((uint64_t)VAL) & RHS.get_VAL()); return Ret; } else { typename RType<_AP_W1, _AP_S1>::logic Ret = *this; return Ret & RHS; } } template <int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1, _AP_S1>::logic operator^(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1, _AP_S1>::logic_w <= 64) { typename RType<_AP_W1, _AP_S1>::logic Ret(((uint64_t)VAL) ^ RHS.get_VAL()); return Ret; } else { typename RType<_AP_W1, _AP_S1>::logic Ret = *this; return Ret ^ RHS; } } template <int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1, _AP_S1>::logic operator|(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1, _AP_S1>::logic_w <= 64) { typename RType<_AP_W1, _AP_S1>::logic Ret(((uint64_t)VAL) | RHS.get_VAL()); return Ret; } else { typename RType<_AP_W1, _AP_S1>::logic Ret = *this; return Ret | RHS; } } INLINE ap_private And(const ap_private& RHS) const { return ap_private(VAL & RHS.get_VAL()); } INLINE ap_private Or(const ap_private& RHS) const { return ap_private(VAL | RHS.get_VAL()); } INLINE ap_private Xor(const ap_private& RHS) const { return ap_private(VAL ^ RHS.get_VAL()); } #if 1 template <int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1, _AP_S1>::mult operator*(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1, _AP_S1>::mult_w <= 64) { typename RType<_AP_W1, _AP_S1>::mult Result(((uint64_t)VAL) * RHS.get_VAL()); return Result; } else { typename RType<_AP_W1, _AP_S1>::mult Result(*this); Result *= RHS; return Result; } } #endif INLINE ap_private Mul(const ap_private& RHS) const { return ap_private(VAL * RHS.get_VAL()); } INLINE ap_private Add(const ap_private& RHS) const { return ap_private(VAL + RHS.get_VAL()); } INLINE ap_private Sub(const ap_private& RHS) const { return ap_private(VAL - RHS.get_VAL()); } #if 1 INLINE ap_private& operator&=(uint64_t RHS) { VAL &= (ValType)RHS; clearUnusedBits(); return *this;} INLINE ap_private& operator|=(uint64_t RHS) { VAL |= (ValType)RHS; clearUnusedBits(); return *this;} INLINE ap_private& operator^=(uint64_t RHS){ VAL ^= (ValType)RHS; clearUnusedBits(); return *this;} INLINE ap_private& operator*=(uint64_t RHS){ VAL *= (ValType)RHS; clearUnusedBits(); return *this; } INLINE ap_private& operator+=(uint64_t RHS){ VAL += (ValType)RHS; clearUnusedBits(); return *this;} INLINE ap_private& operator-=(uint64_t RHS){ VAL -= (ValType)RHS; clearUnusedBits(); return *this; } #else INLINE ap_private operator&(uint64_t RHS) const { return ap_private(VAL & RHS); } INLINE ap_private operator|(uint64_t RHS) const { return ap_private(VAL | RHS); } INLINE ap_private operator^(uint64_t RHS) const { return ap_private(VAL ^ RHS); } INLINE ap_private operator*(uint64_t RHS) const { return ap_private(VAL * RHS); } INLINE ap_private operator/(uint64_t RHS) const { return ap_private(VAL / RHS); } INLINE ap_private operator+(uint64_t RHS) const { return ap_private(VAL + RHS); } INLINE ap_private operator-(uint64_t RHS) const { return ap_private(VAL - RHS); } #endif INLINE bool isMinSignedValue() const { static const uint64_t min_mask = ~(~0ULL << (_AP_W-1)); return BitWidth == 1 ? VAL == 1 : (ap_private_ops::isNegative<_AP_W>(*this) && ((min_mask & VAL)==0)); } template<int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1,_AP_S1>::plus operator+(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1,_AP_S1>::plus_w <=64) return typename RType<_AP_W1,_AP_S1>::plus(RType<_AP_W1,_AP_S1>::plus_s ? int64_t(((uint64_t)VAL)+RHS.get_VAL()):uint64_t(((uint64_t)VAL)+RHS.get_VAL())); typename RType<_AP_W1,_AP_S1>::plus Result=RHS; Result += VAL; return Result; } template<int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1,_AP_S1>::minus operator-(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (RType<_AP_W1,_AP_S1>::minus_w <=64) return typename RType<_AP_W1,_AP_S1>::minus(int64_t(((uint64_t)VAL)-RHS.get_VAL())); typename RType<_AP_W1,_AP_S1>::minus Result=*this; Result -= RHS; return Result; } INLINE uint32_t countPopulation() const { return ap_private_ops::CountPopulation_64(VAL);} INLINE uint32_t countLeadingZeros() const { int remainder = BitWidth % 64; int excessBits = (64 - remainder) % 64; uint32_t Count = ap_private_ops::CountLeadingZeros_64(VAL); if (Count) Count-=excessBits; return AESL_std::min(Count, (uint32_t)_AP_W); } /// HiBits - This function returns the high "numBits" bits of this ap_private. INLINE ap_private<_AP_W, _AP_S> getHiBits(uint32_t numBits) const { ap_private<_AP_W, _AP_S> ret(*this); ret = (ret)>>(BitWidth - numBits); return ret; } /// LoBits - This function returns the low "numBits" bits of this ap_private. INLINE ap_private<_AP_W, _AP_S> getLoBits(uint32_t numBits) const { ap_private<_AP_W, _AP_S> ret(((uint64_t)VAL) << (BitWidth - numBits)); ret = (ret)>>(BitWidth - numBits); return ret; //return ap_private(numBits, (VAL << (BitWidth - numBits))>> (BitWidth - numBits)); } INLINE ap_private<_AP_W, _AP_S>& set(uint32_t bitPosition) { VAL |= (1ULL << (bitPosition)); clearUnusedBits(); return *this; // clearUnusedBits(); } INLINE void set() { VAL = (ValType)~0ULL; clearUnusedBits(); } template<int _AP_W3> INLINE void set(const ap_private<_AP_W3, false> & val) { operator = (ap_private<_AP_W3, _AP_S>(val)); } INLINE void set(const ap_private & val) { operator = (val); } INLINE void clearUnusedBits(void) //just for clang compiler #if defined(__clang__) && !defined(__CLANG_3_1__) __attribute__((no_sanitize("undefined"))) #endif { enum { excess_bits = (_AP_W%64) ? 64 -_AP_W%64 : 0}; VAL = (ValType)(_AP_S ? ((((int64_t)VAL)<<(excess_bits))>> (excess_bits)) : (excess_bits ? (((uint64_t)VAL)<<(excess_bits))>>(excess_bits) : (uint64_t)VAL)); } INLINE void clearUnusedBitsToZero(void) { enum { excess_bits = (_AP_W%64) ? 64 -_AP_W%64 : 0}; static uint64_t mask = ~0ULL >> (excess_bits); VAL &= mask; } INLINE ap_private udiv(const ap_private& RHS) const { return ap_private((uint64_t)VAL / RHS.get_VAL()); } /// Signed divide this ap_private by ap_private RHS. /// @brief Signed division function for ap_private. INLINE ap_private sdiv(const ap_private& RHS) const { if (isNegative()) if (RHS.isNegative()) return ((uint64_t)(0 -(*this))) / (uint64_t) (0-RHS); else return 0 -((uint64_t)(0-(*this)) / (uint64_t)(RHS)); else if (RHS.isNegative()) return 0 -(this->udiv((ap_private)(0-RHS))); return this->udiv(RHS); } template<bool _AP_S2> INLINE ap_private urem(const ap_private<_AP_W, _AP_S2>& RHS) const { assert(RHS.get_VAL() != 0 && "Divide by 0"); return ap_private(((uint64_t)VAL)%((uint64_t)RHS.get_VAL())); } /// Signed remainder operation on ap_private. /// @brief Function for signed remainder operation. template<bool _AP_S2> INLINE ap_private srem(const ap_private<_AP_W, _AP_S2>& RHS) const { if (isNegative()) { ap_private lhs = 0 -(*this); if (RHS.isNegative()) { ap_private rhs = 0 -RHS; return 0 -(lhs.urem(rhs)); } else return 0 -(lhs.urem(RHS)); } else if (RHS.isNegative()) { ap_private rhs = 0-RHS; return this->urem(rhs); } return this->urem(RHS); } template <int _AP_W1, bool _AP_S1> INLINE bool eq(const ap_private<_AP_W1, _AP_S1>& RHS) const { return (*this) == RHS; } template <int _AP_W1, bool _AP_S1> INLINE bool ne(const ap_private<_AP_W1, _AP_S1>& RHS) const { return !((*this) == RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// the validity of the less-than relationship. /// @returns true if *this < RHS when both are considered unsigned. /// @brief Unsigned less than comparison template <int _AP_W1, bool _AP_S1> INLINE bool ult(const ap_private<_AP_W1, _AP_S1>& RHS) const { if (_AP_W1 <= 64) { uint64_t lhsZext = ((uint64_t(VAL)) << (64-_AP_W)) >> (64-_AP_W); uint64_t rhsZext = ((uint64_t(RHS.get_VAL())) << (64-_AP_W1)) >> (64-_AP_W1); return lhsZext < rhsZext; } else return RHS.uge(*this); } /// Regards both *this and RHS as signed quantities and compares them for /// validity of the less-than relationship. /// @returns true if *this < RHS when both are considered signed. /// @brief Signed less than comparison template <int _AP_W1, bool _AP_S1> INLINE bool slt(const ap_private<_AP_W1, _AP_S1>& RHS) const //just for clang compiler #if defined(__clang__) && !defined(__CLANG_3_1__) __attribute__((no_sanitize("undefined"))) #endif { if (_AP_W1 <= 64) { int64_t lhsSext = ((int64_t(VAL)) << (64-_AP_W)) >> (64-_AP_W); int64_t rhsSext = ((int64_t(RHS.get_VAL())) << (64-_AP_W1)) >> (64-_AP_W1); return lhsSext < rhsSext; } else return RHS.sge(*this); } /// Regards both *this and RHS as unsigned quantities and compares them for /// validity of the less-or-equal relationship. /// @returns true if *this <= RHS when both are considered unsigned. /// @brief Unsigned less or equal comparison template <int _AP_W1, bool _AP_S1> INLINE bool ule(const ap_private<_AP_W1, _AP_S1>& RHS) const { return ult(RHS) || eq(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// validity of the less-or-equal relationship. /// @returns true if *this <= RHS when both are considered signed. /// @brief Signed less or equal comparison template <int _AP_W1, bool _AP_S1> INLINE bool sle(const ap_private<_AP_W1, _AP_S1>& RHS) const { return slt(RHS) || eq(RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// the validity of the greater-than relationship. /// @returns true if *this > RHS when both are considered unsigned. /// @brief Unsigned greather than comparison template <int _AP_W1, bool _AP_S1> INLINE bool ugt(const ap_private<_AP_W1, _AP_S1>& RHS) const { return !ult(RHS) && !eq(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// the validity of the greater-than relationship. /// @returns true if *this > RHS when both are considered signed. /// @brief Signed greather than comparison template <int _AP_W1, bool _AP_S1> INLINE bool sgt(const ap_private<_AP_W1, _AP_S1>& RHS) const { return !slt(RHS) && !eq(RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// validity of the greater-or-equal relationship. /// @returns true if *this >= RHS when both are considered unsigned. /// @brief Unsigned greater or equal comparison template <int _AP_W1, bool _AP_S1> INLINE bool uge(const ap_private<_AP_W1, _AP_S1>& RHS) const { return !ult(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// validity of the greater-or-equal relationship. /// @returns true if *this >= RHS when both are considered signed. /// @brief Signed greather or equal comparison template <int _AP_W1, bool _AP_S1> INLINE bool sge(const ap_private<_AP_W1, _AP_S1>& RHS) const { return !slt(RHS); } INLINE ap_private abs() const { if (isNegative()) return -(*this); return *this; } INLINE ap_private<_AP_W, false> get() const { ap_private<_AP_W,false> ret(*this); return ret; } INLINE static uint32_t getBitsNeeded(const char* str, uint32_t slen, uint8_t radix) { return _AP_W; } INLINE uint32_t getActiveBits() const { uint32_t bits=_AP_W - countLeadingZeros(); return bits?bits:1; } INLINE double roundToDouble(bool isSigned=false) const { return isSigned ? double((int64_t)VAL) : double((uint64_t)VAL); } /*Reverse the contents of ap_private instance. I.e. LSB becomes MSB and vise versa*/ INLINE ap_private& reverse () { for (int i = 0; i < _AP_W/2; ++i) { bool tmp = operator[](i); if (operator[](_AP_W - 1 - i)) set(i); else clear(i); if (tmp) set(_AP_W - 1 - i); else clear(_AP_W - 1 - i); } clearUnusedBits(); return *this; } /*Return true if the value of ap_private instance is zero*/ INLINE bool iszero () const { return isMinValue(); } INLINE bool to_bool() const { return !iszero(); } /* x < 0 */ INLINE bool sign () const { if (isNegative()) return true; return false; } /* x[i] = !x[i] */ INLINE void invert (int i) { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); flip(i); } /* x[i] */ INLINE bool test (int i) const { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); return operator[](i); } //This is used for sc_lv and sc_bv, which is implemented by sc_uint //Rotate an ap_private object n places to the left INLINE void lrotate(int n) { assert( n >= 0 && "Attempting to shift negative index"); assert( n < _AP_W && "Shift value larger than bit width"); operator = (shl(n) | lshr(_AP_W - n)); } //This is used for sc_lv and sc_bv, which is implemented by sc_uint //Rotate an ap_private object n places to the right INLINE void rrotate(int n) { assert( n >= 0 && "Attempting to shift negative index"); assert( n < _AP_W && "Shift value larger than bit width"); operator = (lshr(n) | shl(_AP_W - n)); } //Set the ith bit into v INLINE void set (int i, bool v) { assert( i >= 0 && "Attempting to write bit with negative index"); assert( i < _AP_W && "Attempting to write bit beyond MSB"); v ? set(i) : clear(i); } //Set the ith bit into v INLINE void set_bit (int i, bool v) { assert( i >= 0 && "Attempting to write bit with negative index"); assert( i < _AP_W && "Attempting to write bit beyond MSB"); v ? set(i) : clear(i); } //Get the value of ith bit INLINE bool get_bit (int i) const { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); return (((1ULL << i) & VAL) != 0); } /// Toggle all bits. INLINE ap_private& flip() { VAL = (ValType)((~0ULL ^ VAL) & mask); clearUnusedBits(); return *this; } /// Toggles a given bit to its opposite value. INLINE ap_private& flip(uint32_t bitPosition) { assert(bitPosition < BitWidth && "Out of the bit-width range!"); set_bit(bitPosition, !get_bit(bitPosition)); return *this; } //complements every bit INLINE void b_not() { flip(); } //Binary Arithmetic //----------------------------------------------------------- #define OP_BIN_AP(Sym,Rty, Fun) \ template<int _AP_W2, bool _AP_S2> \ INLINE \ typename RType<_AP_W2,_AP_S2>::Rty \ operator Sym (const ap_private<_AP_W2,_AP_S2>& op) const { \ typename RType<_AP_W2,_AP_S2>::Rty lhs(*this); \ typename RType<_AP_W2,_AP_S2>::Rty rhs(op); \ return lhs.Fun(rhs); \ } \ ///Bitwise and, or, xor //OP_BIN_AP(&,logic, And) //OP_BIN_AP(|,logic, Or) //OP_BIN_AP(^,logic, Xor) #undef OP_BIN_AP template<int _AP_W2, bool _AP_S2> INLINE typename RType<_AP_W2,_AP_S2>::div operator / (const ap_private<_AP_W2,_AP_S2>&op) const { ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> lhs=*this; ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> rhs=op; return typename RType<_AP_W2,_AP_S2>::div((_AP_S||_AP_S2)?lhs.sdiv(rhs):lhs.udiv(rhs)); } template<int _AP_W2, bool _AP_S2> INLINE typename RType<_AP_W2,_AP_S2>::mod operator % (const ap_private<_AP_W2,_AP_S2>&op) const { ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> lhs=*this; ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> rhs=op; typename RType<_AP_W2,_AP_S2>::mod res = typename RType<_AP_W2,_AP_S2>::mod (_AP_S?lhs.srem(rhs):lhs.urem(rhs)); return res; } #define OP_ASSIGN_AP_2(Sym) \ template<int _AP_W2, bool _AP_S2> \ INLINE ap_private<_AP_W, _AP_S>& operator Sym##=(const ap_private<_AP_W2,_AP_S2>& op) \ { \ *this=operator Sym (op); \ return *this; \ } \ OP_ASSIGN_AP_2(/) OP_ASSIGN_AP_2(%) #undef OP_ASSIGN_AP_2 ///Bitwise assign: and, or, xor //------------------------------------------------------------- // OP_ASSIGN_AP(&) // OP_ASSIGN_AP(^) // OP_ASSIGN_AP(|) #undef OP_ASSIGN_AP #define OP_LEFT_SHIFT_CTYPE(TYPE, SIGNED) \ INLINE ap_private \ operator << (const TYPE op) const { \ if (op >= _AP_W) \ return ap_private(0); \ if (SIGNED && op < 0) \ return *this >> (0-op); \ return shl(op); \ } OP_LEFT_SHIFT_CTYPE(int, true) //OP_LEFT_SHIFT_CTYPE(bool, false) OP_LEFT_SHIFT_CTYPE(signed char, true) OP_LEFT_SHIFT_CTYPE(unsigned char, false) OP_LEFT_SHIFT_CTYPE(short, true) OP_LEFT_SHIFT_CTYPE(unsigned short, false) OP_LEFT_SHIFT_CTYPE(unsigned int, false) OP_LEFT_SHIFT_CTYPE(long, true) OP_LEFT_SHIFT_CTYPE(unsigned long, false) OP_LEFT_SHIFT_CTYPE(unsigned long long, false) OP_LEFT_SHIFT_CTYPE(long long, true) OP_LEFT_SHIFT_CTYPE(half, false) OP_LEFT_SHIFT_CTYPE(float, false) OP_LEFT_SHIFT_CTYPE(double, false) #undef OP_LEFT_SHIFT_CTYPE template<int _AP_W2, bool _AP_S2> INLINE ap_private operator << (const ap_private<_AP_W2, _AP_S2>& op2) const { if (_AP_S2 == false) { uint32_t sh = op2.to_uint(); return *this << sh; } else { int sh = op2.to_int(); return *this << sh; } } #define OP_RIGHT_SHIFT_CTYPE(TYPE, SIGNED) \ INLINE ap_private \ operator >> (const TYPE op) const { \ if (op >= _AP_W) { \ if (isNegative()) \ return ap_private(-1); \ else \ return ap_private(0); \ } \ if (SIGNED && op < 0) \ return *this << (0-op); \ if (_AP_S) \ return ashr(op) ; \ else \ return lshr(op); \ } OP_RIGHT_SHIFT_CTYPE(int, true) //OP_RIGHT_SHIFT_CTYPE(bool, false) OP_RIGHT_SHIFT_CTYPE(signed char, true) OP_RIGHT_SHIFT_CTYPE(unsigned char, false) OP_RIGHT_SHIFT_CTYPE(short, true) OP_RIGHT_SHIFT_CTYPE(unsigned short, false) OP_RIGHT_SHIFT_CTYPE(unsigned int, false) OP_RIGHT_SHIFT_CTYPE(long, true) OP_RIGHT_SHIFT_CTYPE(unsigned long, false) OP_RIGHT_SHIFT_CTYPE(unsigned long long, false) OP_RIGHT_SHIFT_CTYPE(long long, true) OP_RIGHT_SHIFT_CTYPE(half, false) OP_RIGHT_SHIFT_CTYPE(float, false) OP_RIGHT_SHIFT_CTYPE(double, false) #undef OP_RITHT_SHIFT_CTYPE template<int _AP_W2, bool _AP_S2> INLINE ap_private operator >> (const ap_private<_AP_W2, _AP_S2>& op2) const { if (_AP_S2 == false) { uint32_t sh = op2.to_uint(); return *this >> sh; } else { int sh = op2.to_int(); return *this >> sh; } } ///Shift assign //------------------------------------------------------------------ #define OP_ASSIGN_AP_3_SINGLE(Sym) \ template<int _AP_W2, bool _AP_S2> \ INLINE ap_private<_AP_W, _AP_S>& operator Sym##=(const ap_private<_AP_W2,_AP_S2>& op) \ { \ *this=operator Sym (op.get_VAL()); \ return *this; \ } OP_ASSIGN_AP_3_SINGLE(>>) #undef OP_ASSIGN_AP_3_SINGLE ///Comparisons //----------------------------------------------------------------- template<int _AP_W1, bool _AP_S1> INLINE bool operator == (const ap_private<_AP_W1, _AP_S1>& op) const { enum { _AP_MAX_W = AP_MAX(AP_MAX(_AP_W,_AP_W1), 32)}; ap_private<_AP_MAX_W, false> lhs(*this); ap_private<_AP_MAX_W, false> rhs(op); if (_AP_MAX_W <= 64) { return (uint64_t) lhs.get_VAL() == (uint64_t) rhs.get_VAL(); } else return lhs == rhs; } template<int _AP_W2, bool _AP_S2> INLINE bool operator != (const ap_private<_AP_W2, _AP_S2>& op) const { return !(*this==op); } template<int _AP_W2, bool _AP_S2> INLINE bool operator > (const ap_private<_AP_W2, _AP_S2>& op) const { enum { _AP_MAX_W = AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2))}; ap_private<_AP_MAX_W, _AP_S> lhs(*this); ap_private<_AP_MAX_W, _AP_S2> rhs(op); // this will follow gcc rule for comparison // between different bitwidth and signness if (_AP_S == _AP_S2) return _AP_S?lhs.sgt(rhs):lhs.ugt(rhs); else if (_AP_W < 32 && _AP_W2 < 32) // different signness but both bitwidth is less than 32 return lhs.sgt(rhs); else // different signness but bigger bitwidth // is greater or equal to 32 if (_AP_S) if (_AP_W2 >= _AP_W) return lhs.ugt(rhs); else return lhs.sgt(rhs); else if (_AP_W >= _AP_W2) return lhs.ugt(rhs); else return lhs.sgt(rhs); } template<int _AP_W2, bool _AP_S2> INLINE bool operator <= (const ap_private<_AP_W2, _AP_S2>& op) const { return !(*this>op); } template<int _AP_W2, bool _AP_S2> INLINE bool operator < (const ap_private<_AP_W2, _AP_S2>& op) const { enum { _AP_MAX_W = AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2))}; ap_private<_AP_MAX_W, _AP_S> lhs(*this); ap_private<_AP_MAX_W, _AP_S2> rhs(op); if (_AP_S == _AP_S2) return _AP_S?lhs.slt(rhs):lhs.ult(rhs); else if (_AP_W < 32 && _AP_W2 < 32) return lhs.slt(rhs); else if (_AP_S) if (_AP_W2 >= _AP_W) return lhs.ult(rhs); else return lhs.slt(rhs); else if (_AP_W >= _AP_W2) return lhs.ult(rhs); else return lhs.slt(rhs); } template<int _AP_W2, bool _AP_S2> INLINE bool operator >=(const ap_private<_AP_W2, _AP_S2>& op) const { return !(*this<op); } ///Bit and Part Select //-------------------------------------------------------------- INLINE ap_range_ref<_AP_W,_AP_S> operator () (int Hi, int Lo) { return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> operator () (int Hi, int Lo) const { return ap_range_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W, _AP_S>*>(this), Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> range (int Hi, int Lo) const { return ap_range_ref<_AP_W,_AP_S>((const_cast<ap_private<_AP_W, _AP_S>*> (this)), Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> range (int Hi, int Lo) { return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } INLINE ap_bit_ref<_AP_W,_AP_S> operator [] (int index) { return ap_bit_ref<_AP_W,_AP_S> (*this, index); } template<int _AP_W2, bool _AP_S2> INLINE ap_bit_ref<_AP_W,_AP_S> operator [] (const ap_private<_AP_W2,_AP_S2> &index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index.to_int() ); } INLINE const ap_bit_ref<_AP_W,_AP_S> operator [](int index) const { return ap_bit_ref<_AP_W,_AP_S> (const_cast<ap_private<_AP_W,_AP_S>& >(*this), index); } template<int _AP_W2, bool _AP_S2> INLINE const ap_bit_ref<_AP_W,_AP_S> operator [] (const ap_private<_AP_W2,_AP_S2>& index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index.to_int() ); } INLINE ap_bit_ref<_AP_W,_AP_S> bit (int index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index ); } template<int _AP_W2, bool _AP_S2> INLINE ap_bit_ref<_AP_W,_AP_S> bit (const ap_private<_AP_W2,_AP_S2> &index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index.to_int() ); } INLINE const ap_bit_ref<_AP_W,_AP_S> bit (int index) const { return ap_bit_ref<_AP_W,_AP_S> (const_cast<ap_private<_AP_W,_AP_S>& >(*this), index); } template<int _AP_W2, bool _AP_S2> INLINE const ap_bit_ref<_AP_W,_AP_S> bit (const ap_private<_AP_W2,_AP_S2>& index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index.to_int() ); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W,ap_private<_AP_W, _AP_S>,_AP_W2,ap_private<_AP_W2,_AP_S2> > concat(const ap_private<_AP_W2,_AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_private<_AP_W2,_AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W,ap_private<_AP_W, _AP_S>,_AP_W2,ap_private<_AP_W2,_AP_S2> > concat(ap_private<_AP_W2,_AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_private<_AP_W2,_AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (const ap_private<_AP_W2, _AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (const ap_private<_AP_W2, _AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(*this, const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (ap_private<_AP_W2, _AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (ap_private<_AP_W2, _AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> > operator, (const ap_range_ref<_AP_W2, _AP_S2> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_range_ref<_AP_W2, _AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> > operator, (ap_range_ref<_AP_W2, _AP_S2> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> > operator, (const ap_bit_ref<_AP_W2, _AP_S2> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_bit_ref<_AP_W2, _AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> > operator, (ap_bit_ref<_AP_W2, _AP_S2> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> > operator, (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& >(a2)); } template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> > operator, (ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> >(*this, a2); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<af_range_ref<_AP_W2,_AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& >(a2)); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(*this, a2); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) const { return ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<af_bit_ref<_AP_W2,_AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& >(a2)); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) { return ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(*this, a2); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator & (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this & a2.get(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator | (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this | a2.get(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator ^ (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this ^ a2.get(); } //Reduce operation //----------------------------------------------------------- INLINE bool and_reduce() const { return (VAL & mask) == mask; } INLINE bool nand_reduce() const { return (VAL & mask) != mask; } INLINE bool or_reduce() const { return (bool)VAL; } INLINE bool nor_reduce() const { return VAL==0; } INLINE bool xor_reduce() const { unsigned int i=countPopulation(); return (i%2)?true:false; } INLINE bool xnor_reduce() const { unsigned int i=countPopulation(); return (i%2)?false:true; } INLINE std::string to_string(uint8_t radix=2, bool sign=false) const { return toString(radix, radix==10?_AP_S:sign); } }; // End of class ap_private <_AP_W, _AP_S, true> template<int _AP_W, bool _AP_S> std::string ap_private<_AP_W, _AP_S, true>::toString(uint8_t radix, bool wantSigned) const { assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); static const char *digits[] = { "0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f" }; std::string result; if (radix != 10) { // For the 2, 8 and 16 bit cases, we can just shift instead of divide // because the number of bits per digit (1,3 and 4 respectively) divides // equaly. We just shift until there value is zero. // First, check for a zero value and just short circuit the logic below. if (*this == (uint64_t)(0)) { // Always generate a radix indicator because fixed-point // formats require it. switch (radix) { case 2: result = "0b0"; break; case 8: result = "0o0"; break; case 16: result = "0x0"; break; default: assert("invalid radix" && 0); } } else { ap_private<_AP_W, false, true> tmp(*this); size_t insert_at = 0; bool leading_zero = true; if (wantSigned && isNegative()) { // They want to print the signed version and it is a negative value // Flip the bits and add one to turn it into the equivalent positive // value and put a '-' in the result. tmp.flip(); tmp++; result = "-"; insert_at = 1; leading_zero = false; } switch (radix) { case 2: result += "0b"; break; case 8: result += "0o"; break; case 16: result += "0x"; break; default: assert("invalid radix" && 0); } insert_at += 2; // Just shift tmp right for each digit width until it becomes zero uint32_t shift = (radix == 16 ? 4 : (radix == 8 ? 3 : 1)); uint64_t mask = radix - 1; ap_private<_AP_W, false, true> zero(0); unsigned bits = 0; bool msb = false; while (tmp.ne(zero)) { unsigned digit = (unsigned)(tmp.get_VAL() & mask); result.insert(insert_at, digits[digit]); tmp = tmp.lshr(shift); bits++; msb = (digit >> (shift - 1)) == 1; } bits *= shift; if (bits < _AP_W && leading_zero && msb) result.insert(insert_at, digits[0]); } return result; } ap_private<_AP_W, false, true> tmp(*this); ap_private<6, false, true> divisor(radix); ap_private<_AP_W, _AP_S, true> zero(0); size_t insert_at = 0; if (wantSigned && isNegative()) { // They want to print the signed version and it is a negative value // Flip the bits and add one to turn it into the equivalent positive // value and put a '-' in the result. tmp.flip(); tmp++; result = "-"; insert_at = 1; } if (tmp == ap_private<_AP_W, false, true>(0ULL)) result = "0"; else while (tmp.ne(zero)) { ap_private<_AP_W, false, true> APdigit = tmp%divisor; ap_private<_AP_W, false, true> tmp2 = tmp/divisor; uint32_t digit = (uint32_t)(APdigit.getZExtValue()); assert(digit < radix && "divide failed"); result.insert(insert_at,digits[digit]); tmp = tmp2; } return result; } // End of ap_private<_AP_W, _AP_S, true>::toString() //bitwidth > 64 template<int _AP_W, bool _AP_S> class ap_private <_AP_W, _AP_S, false> { // SFINAE pattern. Only consider this class when _AP_W > 64 const static bool valid = ap_private_enable_if<(_AP_W > 64)>::isValid; #ifdef _MSC_VER #pragma warning( disable : 4521 4522 ) #endif public: enum { BitWidth = _AP_W, _AP_N = (_AP_W + 63) / 64 }; static const int width = _AP_W; private: /// This constructor is used only internally for speed of construction of /// temporaries. It is unsafe for general use so it is not public. /* Constructors */ /// Note that numWords can be smaller or larger than the corresponding bit /// width but any extraneous bits will be dropped. /// @param numBits the bit width of the constructed ap_private /// @param numWords the number of words in bigVal /// @param bigVal a sequence of words to form the initial value of the ap_private /// @brief Construct an ap_private of numBits width, initialized as bigVal[]. INLINE ap_private(uint32_t numWords, const uint64_t bigVal[]) { set_canary(); assert(bigVal && "Null pointer detected!"); { // Get memory, cleared to 0 memset(pVal, 0, _AP_N * sizeof(uint64_t)); // Calculate the number of words to copy uint32_t words = AESL_std::min<uint32_t>(numWords, _AP_N); // Copy the words from bigVal to pVal memcpy(pVal, bigVal, words * APINT_WORD_SIZE); if (words >= _AP_W) clearUnusedBits(); // Make sure unused high bits are cleared } check_canary(); } /// This constructor interprets Val as a string in the given radix. The /// interpretation stops when the first charater that is not suitable for the /// radix is encountered. Acceptable radix values are 2, 8, 10 and 16. It is /// an error for the value implied by the string to require more bits than /// numBits. /// @param numBits the bit width of the constructed ap_private /// @param val the string to be interpreted /// @param radix the radix of Val to use for the intepretation /// @brief Construct an ap_private from a string representation. INLINE ap_private(const std::string& val, uint8_t radix=2) { set_canary(); assert(!val.empty() && "The input string is empty."); const char *c_str = val.c_str(); fromString(c_str, val.size(), radix); check_canary(); } /// This constructor interprets the slen characters starting at StrStart as /// a string in the given radix. The interpretation stops when the first /// character that is not suitable for the radix is encountered. Acceptable /// radix values are 2, 8, 10 and 16. It is an error for the value implied by /// the string to require more bits than numBits. /// @param numBits the bit width of the constructed ap_private /// @param strStart the start of the string to be interpreted /// @param slen the maximum number of characters to interpret /// @param radix the radix to use for the conversion /// @brief Construct an ap_private from a string representation. /// This method does not consider whether it is negative or not. INLINE ap_private(const char strStart[], uint32_t slen, uint8_t radix) { set_canary(); fromString(strStart, slen, radix); check_canary(); } INLINE void report() { #if 0 if (_AP_W > 1024 && _AP_W <= 4096) { fprintf(stderr, "[W] W=%d is out of bound (1<=W<=1024): for" " synthesis: please define macro AP_INT_TYPE_EXT(N)" " to extend the valid range.\n", _AP_W); } else #endif if (_AP_W > MAX_MODE(AP_INT_MAX_W) * 1024) { fprintf(stderr, "[E] ap_%sint<%d>: Bitwidth exceeds the " "default max value %d. Please use macro " "AP_INT_MAX_W to set a larger max value.\n", _AP_S?"":"u", _AP_W, MAX_MODE(AP_INT_MAX_W) * 1024); exit(1); } } /// This union is used to store the integer value. When the /// integer bit-width <= 64, it uses VAL, otherwise it uses pVal. /// This enum is used to hold the constants we needed for ap_private. //uint64_t VAL; ///< Used to store the <= 64 bits integer value. uint64_t pVal[_AP_N]; ///< Used to store the >64 bits integer value. #ifdef AP_CANARY uint64_t CANARY; INLINE void check_canary() { assert(CANARY == (uint64_t)0xDEADBEEFDEADBEEF); } INLINE void set_canary() { CANARY = (uint64_t)0xDEADBEEFDEADBEEF; } #else INLINE void check_canary() {} INLINE void set_canary() {} #endif public: typedef typename valtype<8, _AP_S>::Type ValType; template<int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> friend struct ap_fixed_base; ///return type of variety of operations //---------------------------------------------------------- template<int _AP_W2, bool _AP_S2> struct RType { enum { mult_w = _AP_W+_AP_W2, mult_s = _AP_S||_AP_S2, plus_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2))+1, plus_s = _AP_S||_AP_S2, minus_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2))+1, minus_s = true, div_w = _AP_W+_AP_S2, div_s = _AP_S||_AP_S2, mod_w = AP_MIN(_AP_W,_AP_W2+(!_AP_S2&&_AP_S)), mod_s = _AP_S, logic_w = AP_MAX(_AP_W+(_AP_S2&&!_AP_S),_AP_W2+(_AP_S&&!_AP_S2)), logic_s = _AP_S||_AP_S2 }; typedef ap_private<mult_w, mult_s> mult; typedef ap_private<plus_w, plus_s> plus; typedef ap_private<minus_w, minus_s> minus; typedef ap_private<logic_w, logic_s> logic; typedef ap_private<div_w, div_s> div; typedef ap_private<mod_w, mod_s> mod; typedef ap_private<_AP_W, _AP_S> arg1; typedef bool reduce; }; INLINE uint64_t& get_VAL(void) { return pVal[0]; } INLINE uint64_t get_VAL(void) const { return pVal[0]; } INLINE uint64_t get_VAL(void) const volatile{ return pVal[0]; } INLINE void set_VAL(uint64_t value) { pVal[0] = value; } INLINE uint64_t& get_pVal(int index) { return pVal[index]; } INLINE uint64_t* get_pVal() { return pVal; } INLINE const uint64_t* get_pVal() const{ return pVal; } INLINE uint64_t get_pVal(int index) const{ return pVal[index]; } INLINE uint64_t* get_pVal() const volatile { return pVal; } INLINE uint64_t get_pVal(int index) const volatile { return pVal[index]; } INLINE void set_pVal(int i, uint64_t value) { pVal[i] = value; } /// This enum is used to hold the constants we needed for ap_private. enum { APINT_BITS_PER_WORD = sizeof(uint64_t) * 8, ///< Bits in a word APINT_WORD_SIZE = sizeof(uint64_t) ///< Byte size of a word }; enum { excess_bits = (_AP_W%APINT_BITS_PER_WORD) ? APINT_BITS_PER_WORD -(_AP_W%APINT_BITS_PER_WORD) : 0}; static const uint64_t mask = ((uint64_t)~0ULL >> (excess_bits)); public: INLINE ap_private(const char* val) { set_canary(); int radix = 10; std::string str = ap_private_ops::parseString(val, radix); std::string::size_type pos = str.find('.'); if (pos != std::string::npos) str = str.substr(pos); ap_private ap_private_val(str, radix); operator = (ap_private_val); report(); check_canary(); } INLINE ap_private(const char* val, int rd) { set_canary(); int radix = rd; std::string str = ap_private_ops::parseString(val, radix); std::string::size_type pos = str.find('.'); if (pos != std::string::npos) str = str.substr(pos); ap_private ap_private_val(str, radix); operator = (ap_private_val); report(); report(); check_canary(); } template<int _AP_W2, bool _AP_S2> INLINE ap_private(const ap_range_ref<_AP_W2,_AP_S2>& ref) { set_canary(); *this=ref.get(); report(); check_canary(); } template<int _AP_W2, bool _AP_S2> INLINE ap_private(const ap_bit_ref<_AP_W2,_AP_S2>& ref) { set_canary(); *this = ((uint64_t)(bool)ref); report(); check_canary(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private(const ap_concat_ref<_AP_W2, _AP_T2,_AP_W3, _AP_T3>& ref) { set_canary(); *this=ref.get(); report(); check_canary(); } template<int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_private(const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &val) { set_canary(); *this = ((val.operator ap_private<_AP_W2, false> ())); report(); check_canary(); } template<int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_private(const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &val) { set_canary(); *this = (uint64_t)(bool)val; report(); check_canary(); } /// Simply makes *this a copy of that. /// @brief Copy Constructor. template<int _AP_W1, bool _AP_S1> INLINE ap_private(const volatile ap_private<_AP_W1, _AP_S1, false>& that) { set_canary(); operator = (const_cast<const ap_private<_AP_W1, _AP_S1, false>& >(that)); check_canary(); } template<int _AP_W1, bool _AP_S1> INLINE ap_private(const ap_private<_AP_W1, _AP_S1, false>& that) { set_canary(); operator = (that); check_canary(); } template<int _AP_W1, bool _AP_S1> INLINE ap_private(const ap_private<_AP_W1, _AP_S1, true>& that) { set_canary(); static const uint64_t that_sign_ext_mask = (_AP_W1==APINT_BITS_PER_WORD)?0:~0ULL>>(_AP_W1%APINT_BITS_PER_WORD)<<(_AP_W1%APINT_BITS_PER_WORD); if (that.isNegative()) { pVal[0] = that.get_VAL()|that_sign_ext_mask; memset(pVal+1, ~0, sizeof(uint64_t)*(_AP_N-1)); } else { pVal[0] = that.get_VAL(); memset(pVal+1, 0, sizeof(uint64_t)*(_AP_N-1)); } clearUnusedBits(); check_canary(); } // INLINE ap_private(const ap_private& that) { // set_canary(); // memcpy(pVal, that.get_pVal(), _AP_N * APINT_WORD_SIZE); // clearUnusedBits(); // check_canary(); // } /// @brief Destructor. //virtual ~ap_private() {} INLINE ~ap_private() {check_canary();} /// Default constructor that creates an uninitialized ap_private. This is useful /// for object deserialization (pair this with the static method Read). INLINE ap_private(){ set_canary(); clearUnusedBits(); check_canary(); } INLINE ap_private(uint64_t* val, uint32_t bits=_AP_W) {assert(0);} INLINE ap_private(const uint64_t *const val, uint32_t bits) {assert(0);} /// @name Constructors /// @{ /// If isSigned is true then val is treated as if it were a signed value /// (i.e. as an int64_t) and the appropriate sign extension to the bit width /// will be done. Otherwise, no sign extension occurs (high order bits beyond /// the range of val are zero filled). /// @param numBits the bit width of the constructed ap_private /// @param val the initial value of the ap_private /// @param isSigned how to treat signedness of val /// @brief Create a new ap_private of numBits width, initialized as val. #define CTOR(TYPE, SIGNED) \ INLINE ap_private(TYPE val, bool isSigned=SIGNED) { \ set_canary(); \ pVal[0] = (ValType) val; \ if (isSigned && int64_t(pVal[0]) < 0) { \ memset(pVal+1, ~0, sizeof(uint64_t)*(_AP_N-1)); \ } else { \ memset(pVal+1, 0, sizeof(uint64_t)*(_AP_N-1)); \ } \ clearUnusedBits(); \ check_canary(); \ } #if 1 CTOR(int, true) CTOR(bool, false) CTOR(signed char, true) CTOR(unsigned char, false) CTOR(short, true) CTOR(unsigned short, false) CTOR(unsigned int, false) CTOR(long, true) CTOR(unsigned long, false) CTOR(unsigned long long, false) CTOR(long long, true) CTOR(half, false) CTOR(float, false) CTOR(double, false) #undef CTOR #else CTOR(uint64_t) #undef CTOR #endif /// @returns true if the number of bits <= 64, false otherwise. /// @brief Determine if this ap_private just has one word to store value. INLINE bool isSingleWord() const { return false; } /// @returns the word position for the specified bit position. /// @brief Determine which word a bit is in. static INLINE uint32_t whichWord(uint32_t bitPosition) { // return bitPosition / APINT_BITS_PER_WORD; return (bitPosition) >> 6; } /// @returns the bit position in a word for the specified bit position /// in the ap_private. /// @brief Determine which bit in a word a bit is in. static INLINE uint32_t whichBit(uint32_t bitPosition) { // return bitPosition % APINT_BITS_PER_WORD; return bitPosition & 0x3f; } /// bit at a specific bit position. This is used to mask the bit in the /// corresponding word. /// @returns a uint64_t with only bit at "whichBit(bitPosition)" set /// @brief Get a single bit mask. static INLINE uint64_t maskBit(uint32_t bitPosition) { return 1ULL << (whichBit(bitPosition)); } /// @returns the corresponding word for the specified bit position. /// @brief Get the word corresponding to a bit position INLINE uint64_t getWord(uint32_t bitPosition) const { return pVal[whichWord(bitPosition)]; } /// This method is used internally to clear the to "N" bits in the high order /// word that are not used by the ap_private. This is needed after the most /// significant word is assigned a value to ensure that those bits are /// zero'd out. /// @brief Clear unused high order bits INLINE void clearUnusedBits(void) //just for clang compiler #if defined(__clang__) && !defined(__CLANG_3_1__) __attribute__((no_sanitize("undefined"))) #endif { pVal[_AP_N-1] = _AP_S ? ((((int64_t)pVal[_AP_N-1])<<(excess_bits))>> excess_bits) : (excess_bits ? ((pVal[_AP_N-1])<<(excess_bits))>>(excess_bits) : pVal[_AP_N-1]); } INLINE void clearUnusedBitsToZero(void) { pVal[_AP_N-1] &= mask; } INLINE void clearUnusedBitsToOne(void) { pVal[_AP_N-1] |= mask; } /// This is used by the constructors that take string arguments. /// @brief Convert a char array into an ap_private INLINE void fromString(const char *str, uint32_t slen, uint8_t radix) { enum { numbits=_AP_W}; // Check our assumptions here assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); assert(str && "String is null?"); bool isNeg = str[0] == '-'; if (isNeg) str++, slen--; //skip any leading zero while(*str == '0' && *(str+1) != '\0') {str++; slen--;} assert((slen <= numbits || radix != 2) && "Insufficient bit width"); assert(((slen - 1)*3 <= numbits || radix != 8) && "Insufficient bit width"); assert(((slen - 1)*4 <= numbits || radix != 16) && "Insufficient bit width"); assert((((slen -1)*64)/22 <= numbits || radix != 10) && "Insufficient bit width"); memset(pVal, 0, _AP_N * sizeof(uint64_t)); // Figure out if we can shift instead of multiply uint32_t shift = (radix == 16 ? 4 : radix == 8 ? 3 : radix == 2 ? 1 : 0); // Set up an ap_private for the digit to add outside the loop so we don't // constantly construct/destruct it. uint64_t bigVal[_AP_N]; memset(bigVal, 0, _AP_N * sizeof(uint64_t)); ap_private<_AP_W, _AP_S> apdigit(getBitWidth(), bigVal); ap_private<_AP_W, _AP_S> apradix(radix); // Enter digit traversal loop for (unsigned i = 0; i < slen; i++) { // Get a digit uint32_t digit = 0; char cdigit = str[i]; if (radix == 16) { #define isxdigit(c) (((c) >= '0' && (c) <= '9') || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #define isdigit(c) ((c) >= '0' && (c) <= '9') if (!isxdigit(cdigit)) assert(0 && "Invalid hex digit in string"); if (isdigit(cdigit)) digit = cdigit - '0'; else if (cdigit >= 'a') digit = cdigit - 'a' + 10; else if (cdigit >= 'A') digit = cdigit - 'A' + 10; else assert(0 && "huh? we shouldn't get here"); } else if (isdigit(cdigit)) { digit = cdigit - '0'; } else if (cdigit != '\0'){ assert(0 && "Invalid character in digit string"); } #undef isxdigit #undef isdigit // Shift or multiply the value by the radix if (shift) *this <<= shift; else *this *= apradix; // Add in the digit we just interpreted apdigit.set_VAL(digit); *this += apdigit; } // If its negative, put it in two's complement form if (isNeg) { (*this)--; this->flip(); } clearUnusedBits(); } INLINE ap_private read() volatile { return *this; } INLINE void write(const ap_private& op2) volatile { *this = (op2); } INLINE operator ValType () const { return get_VAL(); } INLINE int to_uchar() const { return (unsigned char) get_VAL(); } INLINE int to_char() const { return (signed char) get_VAL(); } INLINE int to_ushort() const { return (unsigned short) get_VAL(); } INLINE int to_short() const { return (short) get_VAL(); } INLINE int to_int() const { return (int) get_VAL(); } INLINE unsigned to_uint() const { return (unsigned) get_VAL(); } INLINE long to_long() const { return (long) get_VAL(); } INLINE unsigned long to_ulong() const { return (unsigned long) get_VAL(); } INLINE ap_slong to_int64() const { return (ap_slong) get_VAL(); } INLINE ap_ulong to_uint64() const { return (ap_ulong) get_VAL(); } INLINE double to_double() const { if (isNegative()) return roundToDouble(true); else return roundToDouble(false); } INLINE unsigned length() const { return _AP_W; } /*Reverse the contents of ap_private instance. I.e. LSB becomes MSB and vise versa*/ INLINE ap_private& reverse () { for (int i = 0; i < _AP_W/2; ++i) { bool tmp = operator[](i); if (operator[](_AP_W - 1 - i)) set(i); else clear(i); if (tmp) set(_AP_W - 1 - i); else clear(_AP_W - 1 - i); } clearUnusedBits(); return *this; } /*Return true if the value of ap_private instance is zero*/ INLINE bool iszero () const { return isMinValue(); } INLINE bool to_bool() const { return !iszero(); } /* x < 0 */ INLINE bool sign () const { if (isNegative()) return true; return false; } /* x[i] = !x[i] */ INLINE void invert (int i) { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); flip(i); } /* x[i] */ INLINE bool test (int i) const { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); return operator[](i); } //Set the ith bit into v INLINE void set (int i, bool v) { assert( i >= 0 && "Attempting to write bit with negative index"); assert( i < _AP_W && "Attempting to write bit beyond MSB"); v ? set(i) : clear(i); } //Set the ith bit into v INLINE void set_bit (int i, bool v) { assert( i >= 0 && "Attempting to write bit with negative index"); assert( i < _AP_W && "Attempting to write bit beyond MSB"); v ? set(i) : clear(i); } INLINE ap_private& set(uint32_t bitPosition) { pVal[whichWord(bitPosition)] |= maskBit(bitPosition); clearUnusedBits(); return *this; } INLINE void set() { for (int i = 0; i < _AP_N; ++i) pVal[i] = ~0ULL; clearUnusedBits(); } //Get the value of ith bit INLINE bool get (int i) const { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); return ((maskBit(i) & (pVal[whichWord(i)])) != 0); } //Get the value of ith bit INLINE bool get_bit (int i) const { assert( i >= 0 && "Attempting to read bit with negative index"); assert( i < _AP_W && "Attempting to read bit beyond MSB"); return ((maskBit(i) & (pVal[whichWord(i)])) != 0); } //This is used for sc_lv and sc_bv, which is implemented by sc_uint //Rotate an ap_private object n places to the left INLINE void lrotate(int n) { assert( n >= 0 && "Attempting to shift negative index"); assert( n < _AP_W && "Shift value larger than bit width"); operator = (shl(n) | lshr(_AP_W - n)); } //This is used for sc_lv and sc_bv, which is implemented by sc_uint //Rotate an ap_private object n places to the right INLINE void rrotate(int n) { assert( n >= 0 && "Attempting to shift negative index"); assert( n < _AP_W && "Shift value larger than bit width"); operator = (lshr(n) | shl(_AP_W - n)); } /// Set the given bit to 0 whose position is given as "bitPosition". /// @brief Set a given bit to 0. INLINE ap_private& clear(uint32_t bitPosition) { pVal[whichWord(bitPosition)] &= ~maskBit(bitPosition); clearUnusedBits(); return *this; } /// @brief Set every bit to 0. INLINE void clear() { memset(pVal, 0, _AP_N * APINT_WORD_SIZE); } /// @brief Toggle every bit to its opposite value. ap_private& flip() { for (int i = 0; i < _AP_N; ++i) pVal[i] ^= ~0ULL; clearUnusedBits(); return *this; } /// Toggle a given bit to its opposite value whose position is given /// as "bitPosition". /// @brief Toggles a given bit to its opposite value. INLINE ap_private& flip(uint32_t bitPosition) { assert(bitPosition < BitWidth && "Out of the bit-width range!"); set_bit(bitPosition, !get_bit(bitPosition)); return *this; } //complements every bit INLINE void b_not() { flip(); } INLINE ap_private getLoBits(uint32_t numBits) const { return ap_private_ops::lshr(ap_private_ops::shl(*this, _AP_W - numBits), _AP_W - numBits); } INLINE ap_private getHiBits(uint32_t numBits) const { return ap_private_ops::lshr(*this, _AP_W - numBits); } //Binary Arithmetic //----------------------------------------------------------- template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator & (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this & a2.get(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator | (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this | a2.get(); } template<int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_private<AP_MAX(_AP_W2+_AP_W3,_AP_W), _AP_S> operator ^ (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& a2) { return *this ^ a2.get(); } ///Arithmetic assign //------------------------------------------------------------- #define OP_BIN_LOGIC_ASSIGN_AP(Sym) \ template<int _AP_W1, bool _AP_S1> \ INLINE ap_private& operator Sym(const ap_private<_AP_W1, _AP_S1>& RHS) { \ const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; \ uint32_t numWords = AESL_std::min((int)_AP_N, _AP_N1); \ uint32_t i; \ if(_AP_W != _AP_W1) \ fprintf(stderr, "Warning! Bitsize mismach for ap_[u]int " #Sym " ap_[u]int.\n");\ for (i = 0; i < numWords; ++i) \ pVal[i] Sym RHS.get_pVal(i); \ if (_AP_N1 < _AP_N) { \ uint64_t ext = RHS.isNegative()?~0ULL:0; \ for (;i<_AP_N; i++) \ pVal[i] Sym ext; \ } \ clearUnusedBits(); \ return *this; \ } OP_BIN_LOGIC_ASSIGN_AP(&=); OP_BIN_LOGIC_ASSIGN_AP(|=); OP_BIN_LOGIC_ASSIGN_AP(^=); #undef OP_BIN_LOGIC_ASSIGN_AP /// Adds the RHS APint to this ap_private. /// @returns this, after addition of RHS. /// @brief Addition assignment operator. template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator+=(const ap_private<_AP_W1, _AP_S1>& RHS) { const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; uint64_t RHSpVal[_AP_N1]; for (int i=0; i<_AP_N1; ++i) RHSpVal[i] = RHS.get_pVal(i); ap_private_ops::add(pVal, pVal, RHSpVal, _AP_N, _AP_N, _AP_N1, _AP_S, _AP_S1); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator-=(const ap_private<_AP_W1, _AP_S1>& RHS) { const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; uint64_t RHSpVal[_AP_N1]; for (int i=0; i<_AP_N1; ++i) RHSpVal[i] = RHS.get_pVal(i); ap_private_ops::sub(pVal, pVal, RHSpVal, _AP_N, _AP_N, _AP_N1, _AP_S, _AP_S1); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator*=(const ap_private<_AP_W1, _AP_S1>& RHS) { // Get some bit facts about LHS and check for zero uint32_t lhsBits = getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : whichWord(lhsBits - 1) + 1; if (!lhsWords) { // 0 * X ===> 0 return *this; } ap_private dupRHS = RHS; // Get some bit facts about RHS and check for zero uint32_t rhsBits = dupRHS.getActiveBits(); uint32_t rhsWords = !rhsBits ? 0 : whichWord(rhsBits - 1) + 1; if (!rhsWords) { // X * 0 ===> 0 clear(); return *this; } // Allocate space for the result uint32_t destWords = rhsWords + lhsWords; uint64_t *dest = (uint64_t*) malloc(destWords*sizeof(uint64_t)); // Perform the long multiply ap_private_ops::mul(dest, pVal, lhsWords, dupRHS.get_pVal(), rhsWords, destWords); // Copy result back into *this clear(); uint32_t wordsToCopy = destWords >= _AP_N ? _AP_N : destWords; memcpy(pVal, dest, wordsToCopy* APINT_WORD_SIZE); uint64_t ext = (isNegative() ^ RHS.isNegative()) ? ~0ULL : 0ULL; for (int i=wordsToCopy; i<_AP_N; i++) pVal[i]=ext; clearUnusedBits(); // delete dest array and return free(dest); return *this; } #define OP_ASSIGN_AP(Sym) \ template<int _AP_W2, bool _AP_S2> \ INLINE ap_private& operator Sym##=(const ap_private<_AP_W2,_AP_S2>& op) \ { \ *this=operator Sym (op); \ return *this; \ } \ OP_ASSIGN_AP(/) OP_ASSIGN_AP(%) #undef OP_ASSIGN_AP #define OP_BIN_LOGIC_AP(Sym) \ template<int _AP_W1, bool _AP_S1> \ INLINE \ typename RType<_AP_W1, _AP_S1>::logic \ operator Sym (const ap_private<_AP_W1, _AP_S1>& RHS) const { \ enum { numWords = (RType<_AP_W1, _AP_S1>::logic_w +APINT_BITS_PER_WORD-1)/APINT_BITS_PER_WORD}; \ typename RType<_AP_W1, _AP_S1>::logic Result; \ uint32_t i; \ const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; \ uint32_t min_N = std::min((int)_AP_N, _AP_N1); \ uint32_t max_N = std::max((int)_AP_N, _AP_N1); \ for (i = 0; i < min_N; ++i) \ Result.set_pVal(i, pVal[i] Sym RHS.get_pVal(i)); \ if (numWords > i) { \ uint64_t ext = ((_AP_N<_AP_N1 && isNegative() )||(_AP_N1 < _AP_N && RHS.isNegative())) ? ~0ULL : 0; \ if (_AP_N>_AP_N1) \ for (;i<max_N;i++) \ Result.set_pVal(i, pVal[i] Sym ext); \ else \ for (;i<max_N;i++) \ Result.set_pVal(i, RHS.get_pVal(i) Sym ext); \ if (numWords > i) { \ uint64_t ext2 = ((_AP_N>_AP_N1 && isNegative() )||(_AP_N1 > _AP_N && RHS.isNegative())) ? ~0ULL : 0; \ Result.set_pVal(i, ext Sym ext2); \ } \ } \ Result.clearUnusedBits(); \ return Result; \ } OP_BIN_LOGIC_AP(|); OP_BIN_LOGIC_AP(&); OP_BIN_LOGIC_AP(^); #undef OP_BIN_LOGIC_AP template<int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1,_AP_S1>::plus operator+(const ap_private<_AP_W1, _AP_S1>& RHS) const { typename RType<_AP_W1,_AP_S1>::plus Result, lhs(*this), rhs(RHS); const int Result_AP_N = (RType<_AP_W1,_AP_S1>::plus_w + 63) / 64; ap_private_ops::add(Result.get_pVal(), lhs.get_pVal(), rhs.get_pVal(), Result_AP_N, Result_AP_N, Result_AP_N, _AP_S, _AP_S1); Result.clearUnusedBits(); return Result; } template<int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1,_AP_S1>::minus operator-(const ap_private<_AP_W1, _AP_S1>& RHS) const { typename RType<_AP_W1,_AP_S1>::minus Result, lhs(*this), rhs(RHS); const int Result_AP_N = (RType<_AP_W1,_AP_S1>::minus_w + 63) / 64; ap_private_ops::sub(Result.get_pVal(), lhs.get_pVal(), rhs.get_pVal(), Result_AP_N, Result_AP_N, Result_AP_N, _AP_S, _AP_S1); Result.clearUnusedBits(); return Result; } template<int _AP_W1, bool _AP_S1> INLINE typename RType<_AP_W1, _AP_S1>::mult operator*(const ap_private<_AP_W1, _AP_S1>& RHS) const { typename RType<_AP_W1, _AP_S1>::mult temp = *this; temp *= RHS; return temp; } template<int _AP_W2, bool _AP_S2> INLINE typename RType<_AP_W2,_AP_S2>::div operator / (const ap_private<_AP_W2,_AP_S2>& op) const { ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> lhs=*this; ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> rhs=op; return typename RType<_AP_W2,_AP_S2>::div((_AP_S||_AP_S2)?lhs.sdiv(rhs):lhs.udiv(rhs)); } template<int _AP_W2, bool _AP_S2> INLINE typename RType<_AP_W2,_AP_S2>::mod operator % (const ap_private<_AP_W2,_AP_S2>& op) const { ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> lhs=*this; ap_private<AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2)), (_AP_W>_AP_W2?_AP_S:(_AP_W2>_AP_W?_AP_S2:_AP_S||_AP_S2))> rhs= op; typename RType<_AP_W2,_AP_S2>::mod res = typename RType<_AP_W2,_AP_S2>::mod(_AP_S?lhs.srem(rhs):lhs.urem(rhs)); return res; } #define OP_LEFT_SHIFT_CTYPE(TYPE, SIGNED) \ INLINE ap_private \ operator << (const TYPE op) const { \ if (op >= _AP_W) \ return ap_private(0); \ if (SIGNED && op < 0) \ return *this >> (0-op); \ return shl(op); \ } OP_LEFT_SHIFT_CTYPE(int, true) //OP_LEFT_SHIFT_CTYPE(bool, false) OP_LEFT_SHIFT_CTYPE(signed char, true) OP_LEFT_SHIFT_CTYPE(unsigned char, false) OP_LEFT_SHIFT_CTYPE(short, true) OP_LEFT_SHIFT_CTYPE(unsigned short, false) OP_LEFT_SHIFT_CTYPE(unsigned int, false) OP_LEFT_SHIFT_CTYPE(long, true) OP_LEFT_SHIFT_CTYPE(unsigned long, false) OP_LEFT_SHIFT_CTYPE(unsigned long long, false) OP_LEFT_SHIFT_CTYPE(long long, true) OP_LEFT_SHIFT_CTYPE(half, false) OP_LEFT_SHIFT_CTYPE(float, false) OP_LEFT_SHIFT_CTYPE(double, false) #undef OP_LEFT_SHIFT_CTYPE template<int _AP_W2, bool _AP_S2> INLINE ap_private operator << (const ap_private<_AP_W2, _AP_S2>& op2) const { if (_AP_S2 == false) { uint32_t sh = op2.to_uint(); return *this << sh; } else { int sh = op2.to_int(); return *this << sh; } } #define OP_RIGHT_SHIFT_CTYPE(TYPE, SIGNED) \ INLINE ap_private \ operator >> (const TYPE op) const { \ if (op >= _AP_W) { \ if (isNegative()) \ return ap_private(-1); \ else \ return ap_private(0); \ } \ if (SIGNED && op < 0) \ return *this << (0-op); \ if (_AP_S) \ return ashr(op) ; \ else \ return lshr(op); \ } OP_RIGHT_SHIFT_CTYPE(int, true) //OP_RIGHT_SHIFT_CTYPE(bool, false) OP_RIGHT_SHIFT_CTYPE(signed char, true) OP_RIGHT_SHIFT_CTYPE(unsigned char, false) OP_RIGHT_SHIFT_CTYPE(short, true) OP_RIGHT_SHIFT_CTYPE(unsigned short, false) OP_RIGHT_SHIFT_CTYPE(unsigned int, false) OP_RIGHT_SHIFT_CTYPE(long, true) OP_RIGHT_SHIFT_CTYPE(unsigned long, false) OP_RIGHT_SHIFT_CTYPE(unsigned long long, false) OP_RIGHT_SHIFT_CTYPE(long long, true) OP_RIGHT_SHIFT_CTYPE(half, false) OP_RIGHT_SHIFT_CTYPE(float, false) OP_RIGHT_SHIFT_CTYPE(double, false) #undef OP_RITHT_SHIFT_CTYPE template<int _AP_W2, bool _AP_S2> INLINE ap_private operator >> (const ap_private<_AP_W2, _AP_S2>& op2) const { if (_AP_S2 == false) { uint32_t sh = op2.to_uint(); return *this >> sh; } else { int sh = op2.to_int(); return *this >> sh; } } ///Shift assign //------------------------------------------------------------------ #define OP_ASSIGN_AP(Sym) \ template<int _AP_W2, bool _AP_S2> \ INLINE ap_private& operator Sym##=(int op) \ { \ *this = operator Sym (op); \ return *this; \ } \ INLINE ap_private& operator Sym##=(unsigned int op) \ { \ *this = operator Sym (op); \ return *this; \ } \ template<int _AP_W2, bool _AP_S2> \ INLINE ap_private& operator Sym##=(const ap_private<_AP_W2,_AP_S2>& op) \ { \ *this = operator Sym (op); \ return *this; \ } OP_ASSIGN_AP(>>) OP_ASSIGN_AP(<<) #undef OP_ASSIGN_AP ///Comparisons //----------------------------------------------------------------- INLINE bool operator==(const ap_private& RHS) const { // Get some facts about the number of bits used in the two operands. uint32_t n1 = getActiveBits(); uint32_t n2 = RHS.getActiveBits(); // If the number of bits isn't the same, they aren't equal if (n1 != n2) return false; // If the number of bits fits in a word, we only need to compare the low word. if (n1 <= APINT_BITS_PER_WORD) return pVal[0] == RHS.get_pVal(0); // Otherwise, compare everything for (int i = whichWord(n1 - 1); i >= 0; --i) if (pVal[i] != RHS.get_pVal(i)) return false; return true; } template<int _AP_W2, bool _AP_S2> INLINE bool operator == (const ap_private<_AP_W2, _AP_S2>& op) const { enum { _AP_MAX_W = AP_MAX(_AP_W,_AP_W2),}; ap_private<_AP_MAX_W, false> lhs(*this); ap_private<_AP_MAX_W, false> rhs(op); return lhs==rhs; } INLINE bool operator==(uint64_t Val) const { uint32_t n = getActiveBits(); if (n <= APINT_BITS_PER_WORD) return pVal[0] == Val; else return false; } template<int _AP_W2, bool _AP_S2> INLINE bool operator != (const ap_private<_AP_W2, _AP_S2>& op) const { return !(*this==op); } template<bool _AP_S1> INLINE bool operator!=(const ap_private<_AP_W, _AP_S1>& RHS) const { return !((*this) == RHS); } INLINE bool operator!=(uint64_t Val) const { return !((*this) == Val); } template<int _AP_W2, bool _AP_S2> INLINE bool operator <= (const ap_private<_AP_W2,_AP_S2>& op) const { return !(*this>op); } INLINE bool operator <(const ap_private& op) const { return _AP_S ? slt(op):ult(op); } template<int _AP_W2, bool _AP_S2> INLINE bool operator < (const ap_private<_AP_W2, _AP_S2>& op) const { enum { _AP_MAX_W = AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2))}; ap_private<_AP_MAX_W, _AP_S> lhs(*this); ap_private<_AP_MAX_W, _AP_S2> rhs(op); if (_AP_S == _AP_S2) return _AP_S?lhs.slt(rhs):lhs.ult(rhs); else if (_AP_S) if (_AP_W2 >= _AP_W) return lhs.ult(rhs); else return lhs.slt(rhs); else if (_AP_W >= _AP_W2) return lhs.ult(rhs); else return lhs.slt(rhs); } template<int _AP_W2, bool _AP_S2> INLINE bool operator >=(const ap_private<_AP_W2,_AP_S2>& op) const { return !(*this<op); } INLINE bool operator >(const ap_private& op) const { return _AP_S ? sgt(op):ugt(op); } template<int _AP_W2, bool _AP_S2> INLINE bool operator > (const ap_private<_AP_W2, _AP_S2>& op) const { enum { _AP_MAX_W = AP_MAX(_AP_W+(_AP_S||_AP_S2),_AP_W2+(_AP_S||_AP_S2))}; ap_private<_AP_MAX_W, _AP_S> lhs(*this); ap_private<_AP_MAX_W, _AP_S2> rhs(op); if (_AP_S == _AP_S2) return _AP_S?lhs.sgt(rhs):lhs.ugt(rhs); else if (_AP_S) if (_AP_W2 >= _AP_W) return lhs.ugt(rhs); else return lhs.sgt(rhs); else if (_AP_W >= _AP_W2) return lhs.ugt(rhs); else return lhs.sgt(rhs); } ///Bit and Part Select //-------------------------------------------------------------- INLINE ap_range_ref<_AP_W,_AP_S> operator () (int Hi, int Lo) { return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> operator () (int Hi, int Lo) const { return ap_range_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W, _AP_S>*>(this), Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> range (int Hi, int Lo) const { return ap_range_ref<_AP_W,_AP_S>((const_cast<ap_private<_AP_W, _AP_S>*> (this)), Hi, Lo); } INLINE ap_range_ref<_AP_W,_AP_S> range (int Hi, int Lo) { return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } template<int _AP_W2, bool _AP_S2, int _AP_W3, bool _AP_S3> INLINE ap_range_ref<_AP_W,_AP_S> range (const ap_private<_AP_W2, _AP_S2> &HiIdx, const ap_private<_AP_W3, _AP_S3> &LoIdx) { int Hi = HiIdx.to_int(); int Lo = LoIdx.to_int(); return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } template<int _AP_W2, bool _AP_S2, int _AP_W3, bool _AP_S3> INLINE ap_range_ref<_AP_W,_AP_S> operator () (const ap_private<_AP_W2, _AP_S2> &HiIdx, const ap_private<_AP_W3, _AP_S3> &LoIdx) { int Hi = HiIdx.to_int(); int Lo = LoIdx.to_int(); return ap_range_ref<_AP_W,_AP_S>(this, Hi, Lo); } template<int _AP_W2, bool _AP_S2, int _AP_W3, bool _AP_S3> INLINE ap_range_ref<_AP_W,_AP_S> range (const ap_private<_AP_W2, _AP_S2> &HiIdx, const ap_private<_AP_W3, _AP_S3> &LoIdx) const { int Hi = HiIdx.to_int(); int Lo = LoIdx.to_int(); return ap_range_ref<_AP_W,_AP_S>(const_cast<ap_private*>(this), Hi, Lo); } template<int _AP_W2, bool _AP_S2, int _AP_W3, bool _AP_S3> INLINE ap_range_ref<_AP_W,_AP_S> operator () (const ap_private<_AP_W2, _AP_S2> &HiIdx, const ap_private<_AP_W3, _AP_S3> &LoIdx) const { int Hi = HiIdx.to_int(); int Lo = LoIdx.to_int(); return this->range(Hi, Lo); } INLINE ap_bit_ref<_AP_W,_AP_S> operator [] (int index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index ); } template<int _AP_W2, bool _AP_S2> INLINE ap_bit_ref<_AP_W,_AP_S> operator [] (const ap_private<_AP_W2,_AP_S2> &index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index.to_int() ); } template<int _AP_W2, bool _AP_S2> INLINE const ap_bit_ref<_AP_W,_AP_S> operator [] (const ap_private<_AP_W2,_AP_S2>& index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index.to_int() ); } INLINE const ap_bit_ref<_AP_W,_AP_S> operator [](int index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index ); } INLINE ap_bit_ref<_AP_W,_AP_S> bit (int index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index ); } template<int _AP_W2, bool _AP_S2> INLINE ap_bit_ref<_AP_W,_AP_S> bit (const ap_private<_AP_W2,_AP_S2> &index) { return ap_bit_ref<_AP_W,_AP_S>( *this, index.to_int() ); } INLINE const ap_bit_ref<_AP_W,_AP_S> bit (int index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index ); } template<int _AP_W2, bool _AP_S2> INLINE const ap_bit_ref<_AP_W,_AP_S> bit (const ap_private<_AP_W2,_AP_S2>& index) const { return ap_bit_ref<_AP_W,_AP_S>(const_cast<ap_private<_AP_W,_AP_S>& >(*this), index.to_int() ); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W,ap_private<_AP_W, _AP_S>,_AP_W2,ap_private<_AP_W2,_AP_S2> > concat(ap_private<_AP_W2,_AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_private<_AP_W2,_AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W,ap_private<_AP_W, _AP_S>,_AP_W2,ap_private<_AP_W2,_AP_S2> > concat(const ap_private<_AP_W2,_AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_private<_AP_W2,_AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (ap_private<_AP_W2, _AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (ap_private<_AP_W2, _AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (const ap_private<_AP_W2, _AP_S2>& a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(*this, const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> > operator, (const ap_private<_AP_W2, _AP_S2>& a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, ap_private<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_private<_AP_W2,_AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> > operator, (const ap_range_ref<_AP_W2, _AP_S2> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_range_ref<_AP_W2, _AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> > operator, (ap_range_ref<_AP_W2, _AP_S2> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2, ap_range_ref<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> > operator, (const ap_bit_ref<_AP_W2, _AP_S2> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_bit_ref<_AP_W2, _AP_S2>& >(a2)); } template <int _AP_W2, bool _AP_S2> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> > operator, (ap_bit_ref<_AP_W2, _AP_S2> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, 1, ap_bit_ref<_AP_W2, _AP_S2> >(*this, a2); } template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> > operator, (const ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> &a2) const { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3>& >(a2)); } template <int _AP_W2, typename _AP_T2, int _AP_W3, typename _AP_T3> INLINE ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> > operator, (ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> &a2) { return ap_concat_ref<_AP_W, ap_private<_AP_W, _AP_S>, _AP_W2+_AP_W3, ap_concat_ref<_AP_W2, _AP_T2, _AP_W3, _AP_T3> >(*this, a2); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (const af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) const { return ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<af_range_ref<_AP_W2,_AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& >(a2)); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) { return ap_concat_ref<_AP_W, ap_private, _AP_W2, af_range_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(*this, a2); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (const af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) const { return ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(const_cast<ap_private<_AP_W,_AP_S>& >(*this), const_cast<af_bit_ref<_AP_W2,_AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2>& >(a2)); } template <int _AP_W2, int _AP_I2, bool _AP_S2, ap_q_mode _AP_Q2, ap_o_mode _AP_O2, int _AP_N2> INLINE ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> > operator, (af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> &a2) { return ap_concat_ref<_AP_W, ap_private, 1, af_bit_ref<_AP_W2, _AP_I2, _AP_S2, _AP_Q2, _AP_O2, _AP_N2> >(*this, a2); } INLINE ap_private<_AP_W,false> get() const { ap_private<_AP_W,false> ret(*this); return ret; } template<int _AP_W3> INLINE void set(const ap_private<_AP_W3, false> & val) { operator = (ap_private<_AP_W3, _AP_S>(val)); } /// /// @name Value Tests /// /// This tests the high bit of this ap_private to determine if it is set. /// @returns true if this ap_private is negative, false otherwise /// @brief Determine sign of this ap_private. INLINE bool isNegative() const { //just for get rid of warnings enum {shift = (_AP_W-APINT_BITS_PER_WORD*(_AP_N-1)-1)}; static const uint64_t mask = 1ULL << (shift); return _AP_S && (pVal[_AP_N-1]&mask); } /// This tests the high bit of the ap_private to determine if it is unset. /// @brief Determine if this ap_private Value is positive (not negative). INLINE bool isPositive() const { return !isNegative(); } /// This tests if the value of this ap_private is strictly positive (> 0). /// @returns true if this ap_private is Positive and not zero. /// @brief Determine if this ap_private Value is strictly positive. INLINE bool isStrictlyPositive() const { return isPositive() && (*this) != 0; } /// This checks to see if the value has all bits of the ap_private are set or not. /// @brief Determine if all bits are set INLINE bool isAllOnesValue() const { return countPopulation() == _AP_W; } /// This checks to see if the value of this ap_private is the maximum unsigned /// value for the ap_private's bit width. /// @brief Determine if this is the largest unsigned value. INLINE bool isMaxValue() const { return countPopulation() == _AP_W; } /// This checks to see if the value of this ap_private is the maximum signed /// value for the ap_private's bit width. /// @brief Determine if this is the largest signed value. INLINE bool isMaxSignedValue() const { return !isNegative() && countPopulation() == _AP_W - 1; } /// This checks to see if the value of this ap_private is the minimum unsigned /// value for the ap_private's bit width. /// @brief Determine if this is the smallest unsigned value. INLINE bool isMinValue() const { return countPopulation() == 0; } /// This checks to see if the value of this ap_private is the minimum signed /// value for the ap_private's bit width. /// @brief Determine if this is the smallest signed value. INLINE bool isMinSignedValue() const { return isNegative() && countPopulation() == 1; } /// This function returns a pointer to the internal storage of the ap_private. /// This is useful for writing out the ap_private in binary form without any /// conversions. INLINE const uint64_t* getRawData() const { return &pVal[0]; } // Square Root - this method computes and returns the square root of "this". // Three mechanisms are used for computation. For small values (<= 5 bits), // a table lookup is done. This gets some performance for common cases. For // values using less than 52 bits, the value is converted to double and then // the libc sqrt function is called. The result is rounded and then converted // back to a uint64_t which is then used to construct the result. Finally, // the Babylonian method for computing square roots is used. INLINE ap_private sqrt() const { // Determine the magnitude of the value. uint32_t magnitude = getActiveBits(); // Use a fast table for some small values. This also gets rid of some // rounding errors in libc sqrt for small values. if (magnitude <= 5) { static const uint8_t results[32] = { /* 0 */ 0, /* 1- 2 */ 1, 1, /* 3- 6 */ 2, 2, 2, 2, /* 7-12 */ 3, 3, 3, 3, 3, 3, /* 13-20 */ 4, 4, 4, 4, 4, 4, 4, 4, /* 21-30 */ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, /* 31 */ 6 }; return ap_private<_AP_W, _AP_S>(/*BitWidth,*/ results[get_VAL()]); } // If the magnitude of the value fits in less than 52 bits (the precision of // an IEEE double precision floating point value), then we can use the // libc sqrt function which will probably use a hardware sqrt computation. // This should be faster than the algorithm below. if (magnitude < 52) { #ifdef _MSC_VER // Amazingly, VC++ doesn't have round(). return ap_private<_AP_W, _AP_S>(/*BitWidth,*/ uint64_t(::sqrt(double(get_VAL()))) + 0.5); #else return ap_private<_AP_W, _AP_S>(/*BitWidth,*/ uint64_t(::round(::sqrt(double(get_VAL()))))); #endif } // Okay, all the short cuts are exhausted. We must compute it. The following // is a classical Babylonian method for computing the square root. This code // was adapted to APINt from a wikipedia article on such computations. // See http://www.wikipedia.org/ and go to the page named // Calculate_an_integer_square_root. uint32_t nbits = BitWidth, i = 4; ap_private<_AP_W, _AP_S> testy(16); ap_private<_AP_W, _AP_S> x_old(/*BitWidth,*/ 1); ap_private<_AP_W, _AP_S> x_new(0); ap_private<_AP_W, _AP_S> two(/*BitWidth,*/ 2); // Select a good starting value using binary logarithms. for ( ; ; i += 2, testy = testy.shl(2)) if (i >= nbits || this->ule(testy)) { x_old = x_old.shl(i / 2); break; } // Use the Babylonian method to arrive at the integer square root: for ( ; ; ) { x_new = (this->udiv(x_old) + x_old).udiv(two); if (x_old.ule(x_new)) break; x_old = x_new; } // Make sure we return the closest approximation // NOTE: The rounding calculation below is correct. It will produce an // off-by-one discrepancy with results from pari/gp. That discrepancy has been // determined to be a rounding issue with pari/gp as it begins to use a // floating point representation after 192 bits. There are no discrepancies // between this algorithm and pari/gp for bit widths < 192 bits. ap_private<_AP_W, _AP_S> square(x_old * x_old); ap_private<_AP_W, _AP_S> nextSquare((x_old + 1) * (x_old +1)); if (this->ult(square)) return x_old; else if (this->ule(nextSquare)) { ap_private<_AP_W, _AP_S> midpoint((nextSquare - square).udiv(two)); ap_private<_AP_W, _AP_S> offset(*this - square); if (offset.ult(midpoint)) return x_old; else return x_old + 1; } else assert(0 && "Error in ap_private<_AP_W, _AP_S>::sqrt computation"); return x_old + 1; } /// /// @Assignment Operators /// /// @returns *this after assignment of RHS. /// @brief Copy assignment operator. INLINE ap_private& operator=(const ap_private& RHS) { if (this != &RHS) memcpy(pVal, RHS.get_pVal(), _AP_N * APINT_WORD_SIZE); return *this; } INLINE ap_private& operator=(const volatile ap_private& RHS) { if (this != &RHS) for (int i=0; i<_AP_N; ++i) pVal[i] = RHS.get_pVal(i); return *this; } INLINE void operator=(const ap_private& RHS) volatile { if (this != &RHS) for (int i=0; i<_AP_N; ++i) pVal[i] = RHS.get_pVal(i); } INLINE void operator=(const volatile ap_private& RHS) volatile { if (this != &RHS) for (int i=0; i<_AP_N; ++i) pVal[i] = RHS.get_pVal(i); } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator=(const ap_private<_AP_W1, _AP_S1>& RHS) { if (_AP_S1) cpSextOrTrunc(RHS); else cpZextOrTrunc(RHS); clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator=(const volatile ap_private<_AP_W1, _AP_S1>& RHS) { if (_AP_S1) cpSextOrTrunc(RHS); else cpZextOrTrunc(RHS); clearUnusedBits(); return *this; } #if 0 template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator=(const ap_private<_AP_W1, _AP_S1, true>& RHS) { static const uint64_t that_sign_ext_mask = (_AP_W1==APINT_BITS_PER_WORD)?0:~0ULL>>(_AP_W1%APINT_BITS_PER_WORD)<<(_AP_W1%APINT_BITS_PER_WORD); if (RHS.isNegative()) { pVal[0] = RHS.get_VAL() | that_sign_ext_mask; memset(pVal+1,~0, APINT_WORD_SIZE*(_AP_N-1)); } else { pVal[0] = RHS.get_VAL(); memset(pVal+1, 0, APINT_WORD_SIZE*(_AP_N-1)); } clearUnusedBits(); return *this; } template<int _AP_W1, bool _AP_S1> INLINE ap_private& operator=(const volatile ap_private<_AP_W1, _AP_S1, true>& RHS) { static const uint64_t that_sign_ext_mask = (_AP_W1==APINT_BITS_PER_WORD)?0:~0ULL>>(_AP_W1%APINT_BITS_PER_WORD)<<(_AP_W1%APINT_BITS_PER_WORD); if (RHS.isNegative()) { pVal[0] = RHS.get_VAL() | that_sign_ext_mask; memset(pVal+1,~0, APINT_WORD_SIZE*(_AP_N-1)); } else { pVal[0] = RHS.get_VAL(); memset(pVal+1, 0, APINT_WORD_SIZE*(_AP_N-1)); } clearUnusedBits(); return *this; } #endif /// /// @name Unary Operators /// /// @returns a new ap_private value representing *this incremented by one /// @brief Postfix increment operator. INLINE const ap_private operator++(int) { ap_private API(*this); ++(*this); return API; } /// @returns *this incremented by one /// @brief Prefix increment operator. INLINE ap_private& operator++() { ap_private_ops::add_1(pVal, pVal, _AP_N, 1); clearUnusedBits(); return *this; } /// @returns a new ap_private representing *this decremented by one. /// @brief Postfix decrement operator. INLINE const ap_private operator--(int) { ap_private API(*this); --(*this); return API; } /// @returns *this decremented by one. /// @brief Prefix decrement operator. INLINE ap_private& operator--() { ap_private_ops::sub_1(pVal, _AP_N, 1); clearUnusedBits(); return *this; } /// Performs a bitwise complement operation on this ap_private. /// @returns an ap_private that is the bitwise complement of *this /// @brief Unary bitwise complement operator. INLINE ap_private<_AP_W + !_AP_S, true> operator~() const { ap_private<_AP_W + !_AP_S, true> Result(*this); Result.flip(); return Result; } /// Negates *this using two's complement logic. /// @returns An ap_private value representing the negation of *this. /// @brief Unary negation operator INLINE typename RType<1,false>::minus operator-() const { return ap_private<1,false>(0) - (*this); } /// Performs logical negation operation on this ap_private. /// @returns true if *this is zero, false otherwise. /// @brief Logical negation operator. INLINE bool operator !() const { for (int i = 0; i < _AP_N; ++i) if (pVal[i]) return false; return true; } template<bool _AP_S1> INLINE ap_private<_AP_W, _AP_S||_AP_S1> And(const ap_private<_AP_W, _AP_S1>& RHS) const { return this->operator&(RHS); } template<bool _AP_S1> INLINE ap_private Or(const ap_private<_AP_W, _AP_S1>& RHS) const { return this->operator|(RHS); } template<bool _AP_S1> INLINE ap_private Xor(const ap_private<_AP_W, _AP_S1>& RHS) const { return this->operator^(RHS); } INLINE ap_private Mul(const ap_private& RHS) const { ap_private Result(*this); Result *= RHS; return Result; } INLINE ap_private Add(const ap_private& RHS) const { ap_private Result(0); ap_private_ops::add(Result.get_pVal(), pVal, RHS.get_pVal(), _AP_N, _AP_N, _AP_N, _AP_S, _AP_S); Result.clearUnusedBits(); return Result; } INLINE ap_private Sub(const ap_private& RHS) const { ap_private Result(0); ap_private_ops::sub(Result.get_pVal(), pVal, RHS.get_pVal(), _AP_N, _AP_N, _AP_N, _AP_S, _AP_S); Result.clearUnusedBits(); return Result; } /// Arithmetic right-shift this ap_private by shiftAmt. /// @brief Arithmetic right-shift function. INLINE ap_private ashr(uint32_t shiftAmt) const { assert(shiftAmt <= BitWidth && "Invalid shift amount, too big"); // Handle a degenerate case if (shiftAmt == 0) return *this; // If all the bits were shifted out, the result is, technically, undefined. // We return -1 if it was negative, 0 otherwise. We check this early to avoid // issues in the algorithm below. if (shiftAmt == BitWidth) { if (isNegative()) return ap_private(-1); else return ap_private(0); } // Create some space for the result. ap_private Retval(0); uint64_t * val = Retval.get_pVal(); // Compute some values needed by the following shift algorithms uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; // bits to shift per word uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; // word offset for shift uint32_t breakWord = _AP_N - 1 - offset; // last word affected uint32_t bitsInWord = whichBit(BitWidth); // how many bits in last word? if (bitsInWord == 0) bitsInWord = APINT_BITS_PER_WORD; // If we are shifting whole words, just move whole words if (wordShift == 0) { // Move the words containing significant bits for (uint32_t i = 0; i <= breakWord; ++i) val[i] = pVal[i+offset]; // move whole word // Adjust the top significant word for sign bit fill, if negative if (isNegative()) if (bitsInWord < APINT_BITS_PER_WORD) val[breakWord] |= ~0ULL << (bitsInWord); // set high bits } else { // Shift the low order words for (uint32_t i = 0; i < breakWord; ++i) { // This combines the shifted corresponding word with the low bits from // the next word (shifted into this word's high bits). val[i] = ((pVal[i+offset]) >> (wordShift)); val[i] |= ((pVal[i+offset+1]) << (APINT_BITS_PER_WORD - wordShift)); } // Shift the break word. In this case there are no bits from the next word // to include in this word. val[breakWord] = (pVal[breakWord+offset]) >> (wordShift); // Deal with sign extenstion in the break word, and possibly the word before // it. if (isNegative()) { if (wordShift > bitsInWord) { if (breakWord > 0) val[breakWord-1] |= ~0ULL << (APINT_BITS_PER_WORD - (wordShift - bitsInWord)); val[breakWord] |= ~0ULL; } else val[breakWord] |= (~0ULL << (bitsInWord - wordShift)); } } // Remaining words are 0 or -1, just assign them. uint64_t fillValue = (isNegative() ? ~0ULL : 0); for (int i = breakWord+1; i < _AP_N; ++i) val[i] = fillValue; Retval.clearUnusedBits(); return Retval; } /// Logical right-shift this ap_private by shiftAmt. /// @brief Logical right-shift function. INLINE ap_private lshr(uint32_t shiftAmt) const { // If all the bits were shifted out, the result is 0. This avoids issues // with shifting by the size of the integer type, which produces undefined // results. We define these "undefined results" to always be 0. if (shiftAmt == BitWidth) return ap_private(0); // If none of the bits are shifted out, the result is *this. This avoids // issues with shifting byt he size of the integer type, which produces // undefined results in the code below. This is also an optimization. if (shiftAmt == 0) return *this; // Create some space for the result. ap_private Retval(0); uint64_t * val = Retval.get_pVal(); // If we are shifting less than a word, compute the shift with a simple carry if (shiftAmt < APINT_BITS_PER_WORD) { uint64_t carry = 0; for (int i = _AP_N-1; i >= 0; --i) { val[i] = ((pVal[i]) >> (shiftAmt)) | carry; carry = (pVal[i]) << (APINT_BITS_PER_WORD - shiftAmt); } Retval.clearUnusedBits(); return Retval; } // Compute some values needed by the remaining shift algorithms uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; // If we are shifting whole words, just move whole words if (wordShift == 0) { for (uint32_t i = 0; i < _AP_N - offset; ++i) val[i] = pVal[i+offset]; for (uint32_t i = _AP_N-offset; i < _AP_N; i++) val[i] = 0; Retval.clearUnusedBits(); return Retval; } // Shift the low order words uint32_t breakWord = _AP_N - offset -1; for (uint32_t i = 0; i < breakWord; ++i) val[i] = ((pVal[i+offset]) >> (wordShift)) | ((pVal[i+offset+1]) << (APINT_BITS_PER_WORD - wordShift)); // Shift the break word. val[breakWord] = (pVal[breakWord+offset]) >> (wordShift); // Remaining words are 0 for (int i = breakWord+1; i < _AP_N; ++i) val[i] = 0; Retval.clearUnusedBits(); return Retval; } /// Left-shift this ap_private by shiftAmt. /// @brief Left-shift function. INLINE ap_private shl(uint32_t shiftAmt) const { assert(shiftAmt <= BitWidth && "Invalid shift amount, too big"); // If all the bits were shifted out, the result is 0. This avoids issues // with shifting by the size of the integer type, which produces undefined // results. We define these "undefined results" to always be 0. if (shiftAmt == BitWidth) return ap_private(0); // If none of the bits are shifted out, the result is *this. This avoids a // lshr by the words size in the loop below which can produce incorrect // results. It also avoids the expensive computation below for a common case. if (shiftAmt == 0) return *this; // Create some space for the result. ap_private Retval(0); uint64_t* val = Retval.get_pVal(); // If we are shifting less than a word, do it the easy way if (shiftAmt < APINT_BITS_PER_WORD) { uint64_t carry = 0; for (int i = 0; i < _AP_N; i++) { val[i] = ((pVal[i]) << (shiftAmt)) | carry; carry = (pVal[i]) >> (APINT_BITS_PER_WORD - shiftAmt); } Retval.clearUnusedBits(); return Retval; } // Compute some values needed by the remaining shift algorithms uint32_t wordShift = shiftAmt % APINT_BITS_PER_WORD; uint32_t offset = shiftAmt / APINT_BITS_PER_WORD; // If we are shifting whole words, just move whole words if (wordShift == 0) { for (uint32_t i = 0; i < offset; i++) val[i] = 0; for (int i = offset; i < _AP_N; i++) val[i] = pVal[i-offset]; Retval.clearUnusedBits(); return Retval; } // Copy whole words from this to Result. uint32_t i = _AP_N - 1; for (; i > offset; --i) val[i] = (pVal[i-offset]) << (wordShift) | (pVal[i-offset-1]) >> (APINT_BITS_PER_WORD - wordShift); val[offset] = (pVal[0]) << (wordShift); for (i = 0; i < offset; ++i) val[i] = 0; Retval.clearUnusedBits(); return Retval; } INLINE ap_private rotl(uint32_t rotateAmt) const { if (rotateAmt == 0) return *this; // Don't get too fancy, just use existing shift/or facilities ap_private hi(*this); ap_private lo(*this); hi.shl(rotateAmt); lo.lshr(BitWidth - rotateAmt); return hi | lo; } INLINE ap_private rotr(uint32_t rotateAmt) const { if (rotateAmt == 0) return *this; // Don't get too fancy, just use existing shift/or facilities ap_private hi(*this); ap_private lo(*this); lo.lshr(rotateAmt); hi.shl(BitWidth - rotateAmt); return hi | lo; } /// Perform an unsigned divide operation on this ap_private by RHS. Both this and /// RHS are treated as unsigned quantities for purposes of this division. /// @returns a new ap_private value containing the division result /// @brief Unsigned division operation. INLINE ap_private udiv(const ap_private& RHS) const { // Get some facts about the LHS and RHS number of bits and words uint32_t rhsBits = RHS.getActiveBits(); uint32_t rhsWords = !rhsBits ? 0 : (whichWord(rhsBits - 1) + 1); assert(rhsWords && "Divided by zero???"); uint32_t lhsBits = this->getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : (whichWord(lhsBits - 1) + 1); // Deal with some degenerate cases if (!lhsWords) // 0 / X ===> 0 return ap_private(0); else if (lhsWords < rhsWords || this->ult(RHS)) { // X / Y ===> 0, iff X < Y return ap_private(0); } else if (*this == RHS) { // X / X ===> 1 return ap_private(1); } else if (lhsWords == 1 && rhsWords == 1) { // All high words are zero, just use native divide return ap_private(this->pVal[0] / RHS.get_pVal(0)); } // We have to compute it the hard way. Invoke the Knuth divide algorithm. ap_private Quotient(0); // to hold result. ap_private_ops::divide(*this, lhsWords, RHS, rhsWords, &Quotient, (ap_private*)0); return Quotient; } /// Signed divide this ap_private by ap_private RHS. /// @brief Signed division function for ap_private. INLINE ap_private sdiv(const ap_private& RHS) const { if (isNegative()) if (RHS.isNegative()) return (-(*this)).udiv(-RHS); else return -((-(*this)).udiv(RHS)); else if (RHS.isNegative()) return -(this->udiv((ap_private)(-RHS))); return this->udiv(RHS); } /// Perform an unsigned remainder operation on this ap_private with RHS being the /// divisor. Both this and RHS are treated as unsigned quantities for purposes /// of this operation. Note that this is a true remainder operation and not /// a modulo operation because the sign follows the sign of the dividend /// which is *this. /// @returns a new ap_private value containing the remainder result /// @brief Unsigned remainder operation. INLINE ap_private urem(const ap_private& RHS) const { // Get some facts about the LHS uint32_t lhsBits = getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : (whichWord(lhsBits - 1) + 1); // Get some facts about the RHS uint32_t rhsBits = RHS.getActiveBits(); uint32_t rhsWords = !rhsBits ? 0 : (whichWord(rhsBits - 1) + 1); assert(rhsWords && "Performing remainder operation by zero ???"); // Check the degenerate cases if (lhsWords == 0) { // 0 % Y ===> 0 return ap_private(0); } else if (lhsWords < rhsWords || this->ult(RHS)) { // X % Y ===> X, iff X < Y return *this; } else if (*this == RHS) { // X % X == 0; return ap_private(0); } else if (lhsWords == 1) { // All high words are zero, just use native remainder return ap_private(pVal[0] % RHS.get_pVal(0)); } // We have to compute it the hard way. Invoke the Knuth divide algorithm. ap_private Remainder(0); ap_private_ops::divide(*this, lhsWords, RHS, rhsWords, (ap_private*)(0), &Remainder); return Remainder; } INLINE ap_private urem(uint64_t RHS) const { // Get some facts about the LHS uint32_t lhsBits = getActiveBits(); uint32_t lhsWords = !lhsBits ? 0 : (whichWord(lhsBits - 1) + 1); // Get some facts about the RHS uint32_t rhsWords = 1;//!rhsBits ? 0 : (ap_private<_AP_W, _AP_S>::whichWord(rhsBits - 1) + 1); assert(rhsWords && "Performing remainder operation by zero ???"); // Check the degenerate cases if (lhsWords == 0) { // 0 % Y ===> 0 return ap_private(0); } else if (lhsWords < rhsWords || this->ult(RHS)) { // X % Y ===> X, iff X < Y return *this; } else if (*this == RHS) { // X % X == 0; return ap_private(0); } else if (lhsWords == 1) { // All high words are zero, just use native remainder return ap_private(pVal[0] % RHS); } // We have to compute it the hard way. Invoke the Knuth divide algorithm. ap_private Remainder(0); divide(*this, lhsWords, RHS, (ap_private*)(0), &Remainder); return Remainder; } /// Signed remainder operation on ap_private. /// @brief Function for signed remainder operation. INLINE ap_private srem(const ap_private& RHS) const { if (isNegative()) { ap_private lhs = -(*this); if (RHS.isNegative()) { ap_private rhs = -RHS; return -(lhs.urem(rhs)); } else return -(lhs.urem(RHS)); } else if (RHS.isNegative()) { ap_private rhs = -RHS; return this->urem(rhs); } return this->urem(RHS); } /// Signed remainder operation on ap_private. /// @brief Function for signed remainder operation. INLINE ap_private srem(int64_t RHS) const { if (isNegative()) if (RHS<0) return -((-(*this)).urem(-RHS)); else return -((-(*this)).urem(RHS)); else if (RHS<0) return this->urem(-RHS); return this->urem(RHS); } /// Compares this ap_private with RHS for the validity of the equality /// relationship. /// @returns true if *this == Val /// @brief Equality comparison. template<bool _AP_S1> INLINE bool eq(const ap_private<_AP_W, _AP_S1>& RHS) const { return (*this) == RHS; } /// Compares this ap_private with RHS for the validity of the inequality /// relationship. /// @returns true if *this != Val /// @brief Inequality comparison template<bool _AP_S1> INLINE bool ne(const ap_private<_AP_W, _AP_S1> &RHS) const { return !((*this) == RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// the validity of the less-than relationship. /// @returns true if *this < RHS when both are considered unsigned. /// @brief Unsigned less than comparison template<bool _AP_S1> INLINE bool ult(const ap_private<_AP_W, _AP_S1>& RHS) const { // Get active bit length of both operands uint32_t n1 = getActiveBits(); uint32_t n2 = RHS.getActiveBits(); // If magnitude of LHS is less than RHS, return true. if (n1 < n2) return true; // If magnitude of RHS is greather than LHS, return false. if (n2 < n1) return false; // If they bot fit in a word, just compare the low order word if (n1 <= APINT_BITS_PER_WORD && n2 <= APINT_BITS_PER_WORD) return pVal[0] < RHS.get_pVal(0); // Otherwise, compare all words uint32_t topWord = whichWord(AESL_std::max(n1,n2)-1); for (int i = topWord; i >= 0; --i) { if (pVal[i] > RHS.get_pVal(i)) return false; if (pVal[i] < RHS.get_pVal(i)) return true; } return false; } INLINE bool ult(uint64_t RHS) const { // Get active bit length of both operands uint32_t n1 = getActiveBits(); uint32_t n2 = 64 - ap_private_ops::CountLeadingZeros_64(RHS); //RHS.getActiveBits(); // If magnitude of LHS is less than RHS, return true. if (n1 < n2) return true; // If magnitude of RHS is greather than LHS, return false. if (n2 < n1) return false; // If they bot fit in a word, just compare the low order word if (n1 <= APINT_BITS_PER_WORD && n2 <= APINT_BITS_PER_WORD) return pVal[0] < RHS; assert(0); } template<bool _AP_S1> INLINE bool slt(const ap_private<_AP_W, _AP_S1>& RHS) const { ap_private lhs(*this); ap_private<_AP_W, _AP_S1> rhs(RHS); bool lhsNeg = isNegative(); bool rhsNeg = rhs.isNegative(); if (lhsNeg) { // Sign bit is set so perform two's complement to make it positive lhs.flip(); lhs++; } if (rhsNeg) { // Sign bit is set so perform two's complement to make it positive rhs.flip(); rhs++; } // Now we have unsigned values to compare so do the comparison if necessary // based on the negativeness of the values. if (lhsNeg) if (rhsNeg) return lhs.ugt(rhs); else return true; else if (rhsNeg) return false; else return lhs.ult(rhs); } /// Regards both *this and RHS as unsigned quantities and compares them for /// validity of the less-or-equal relationship. /// @returns true if *this <= RHS when both are considered unsigned. /// @brief Unsigned less or equal comparison template<bool _AP_S1> INLINE bool ule(const ap_private<_AP_W, _AP_S1>& RHS) const { return ult(RHS) || eq(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// validity of the less-or-equal relationship. /// @returns true if *this <= RHS when both are considered signed. /// @brief Signed less or equal comparison template<bool _AP_S1> INLINE bool sle(const ap_private<_AP_W, _AP_S1>& RHS) const { return slt(RHS) || eq(RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// the validity of the greater-than relationship. /// @returns true if *this > RHS when both are considered unsigned. /// @brief Unsigned greather than comparison template<bool _AP_S1> INLINE bool ugt(const ap_private<_AP_W, _AP_S1>& RHS) const { return !ult(RHS) && !eq(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// the validity of the greater-than relationship. /// @returns true if *this > RHS when both are considered signed. /// @brief Signed greather than comparison template<bool _AP_S1> INLINE bool sgt(const ap_private<_AP_W, _AP_S1>& RHS) const { return !slt(RHS) && !eq(RHS); } /// Regards both *this and RHS as unsigned quantities and compares them for /// validity of the greater-or-equal relationship. /// @returns true if *this >= RHS when both are considered unsigned. /// @brief Unsigned greater or equal comparison template<bool _AP_S1> INLINE bool uge(const ap_private<_AP_W, _AP_S>& RHS) const { return !ult(RHS); } /// Regards both *this and RHS as signed quantities and compares them for /// validity of the greater-or-equal relationship. /// @returns true if *this >= RHS when both are considered signed. /// @brief Signed greather or equal comparison template<bool _AP_S1> INLINE bool sge(const ap_private<_AP_W, _AP_S1>& RHS) const { return !slt(RHS); } // Sign extend to a new width. template<int _AP_W1, bool _AP_S1> INLINE void cpSext(const ap_private<_AP_W1, _AP_S1>& that) { assert(_AP_W1 < BitWidth && "Invalid ap_private SignExtend request"); assert(_AP_W1 <= MAX_INT_BITS && "Too many bits"); // If the sign bit isn't set, this is the same as zext. if (!that.isNegative()) { cpZext(that); return; } // The sign bit is set. First, get some facts enum { wordBits = _AP_W1 % APINT_BITS_PER_WORD}; const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; // Mask the high order word appropriately if (_AP_N1 == _AP_N) { enum { newWordBits = _AP_W % APINT_BITS_PER_WORD}; // The extension is contained to the wordsBefore-1th word. static const uint64_t mask = wordBits?(~0ULL<<(wordBits)):0ULL; for (int i = 0; i < _AP_N; ++i) pVal[i] = that.get_pVal(i); pVal[_AP_N-1] |= mask; return; } enum { newWordBits = _AP_W % APINT_BITS_PER_WORD}; // The extension is contained to the wordsBefore-1th word. static const uint64_t mask = wordBits?(~0ULL<<(wordBits)):0ULL; int i; for (i = 0; i < _AP_N1; ++i) pVal[i] = that.get_pVal(i); pVal[i - 1] |= mask; for (; i < _AP_N-1; i++) pVal[i] = ~0ULL; pVal[i] = ~0ULL; clearUnusedBits(); return; } // Zero extend to a new width. template <int _AP_W1, bool _AP_S1> INLINE void cpZext(const ap_private<_AP_W1, _AP_S1>& that) { assert(_AP_W1 < BitWidth && "Invalid ap_private ZeroExtend request"); assert(_AP_W1 <= MAX_INT_BITS && "Too many bits"); const int _AP_N1 = ap_private<_AP_W1, _AP_S1>::_AP_N; int i = 0; for (; i < _AP_N1; ++i) pVal[i] = that.get_pVal(i); for (; i < _AP_N; ++i) pVal[i] = 0; clearUnusedBits(); } template<int _AP_W1, bool _AP_S1> INLINE void cpZextOrTrunc(const ap_private<_AP_W1, _AP_S1>& that) { if (BitWidth > _AP_W1) cpZext(that); else { for (int i=0; i<_AP_N; ++i) pVal[i]=that.get_pVal(i); clearUnusedBits(); } } template<int _AP_W1, bool _AP_S1> INLINE void cpSextOrTrunc(const ap_private<_AP_W1, _AP_S1>& that) { if (BitWidth > _AP_W1) cpSext(that); else { for (int i=0; i<_AP_N; ++i) pVal[i] = that.get_pVal(i); clearUnusedBits(); } } /// @} /// @name Value Characterization Functions /// @{ /// @returns the total number of bits. INLINE uint32_t getBitWidth() const { return BitWidth; } /// Here one word's bitwidth equals to that of uint64_t. /// @returns the number of words to hold the integer value of this ap_private. /// @brief Get the number of words. INLINE uint32_t getNumWords() const { return (BitWidth + APINT_BITS_PER_WORD - 1) / APINT_BITS_PER_WORD; } /// This function returns the number of active bits which is defined as the /// bit width minus the number of leading zeros. This is used in several /// computations to see how "wide" the value is. /// @brief Compute the number of active bits in the value INLINE uint32_t getActiveBits() const { uint32_t bits=BitWidth - countLeadingZeros(); return bits?bits:1; } /// This method attempts to return the value of this ap_private as a zero extended /// uint64_t. The bitwidth must be <= 64 or the value must fit within a /// uint64_t. Otherwise an assertion will result. /// @brief Get zero extended value INLINE uint64_t getZExtValue() const { assert(getActiveBits() <= 64 && "Too many bits for uint64_t"); return *pVal; } /// This method attempts to return the value of this ap_private as a sign extended /// int64_t. The bit width must be <= 64 or the value must fit within an /// int64_t. Otherwise an assertion will result. /// @brief Get sign extended value INLINE int64_t getSExtValue() const { assert(getActiveBits() <= 64 && "Too many bits for int64_t"); return int64_t(pVal[0]); } /// This method determines how many bits are required to hold the ap_private /// equivalent of the string given by \p str of length \p slen. /// @brief Get bits required for string value. INLINE static uint32_t getBitsNeeded(const char* str, uint32_t slen, uint8_t radix) { assert(str != 0 && "Invalid value string"); assert(slen > 0 && "Invalid string length"); // Each computation below needs to know if its negative uint32_t isNegative = str[0] == '-'; if (isNegative) { slen--; str++; } // For radixes of power-of-two values, the bits required is accurately and // easily computed if (radix == 2) return slen + isNegative; if (radix == 8) return slen * 3 + isNegative; if (radix == 16) return slen * 4 + isNegative; // Otherwise it must be radix == 10, the hard case assert(radix == 10 && "Invalid radix"); // Convert to the actual binary value. //ap_private<_AP_W, _AP_S> tmp(sufficient, str, slen, radix); // Compute how many bits are required. //return isNegative + tmp.logBase2() + 1; return isNegative + slen * 4; } /// countLeadingZeros - This function is an ap_private version of the /// countLeadingZeros_{32,64} functions in MathExtras.h. It counts the number /// of zeros from the most significant bit to the first one bit. /// @returns BitWidth if the value is zero. /// @returns the number of zeros from the most significant bit to the first /// one bits. INLINE uint32_t countLeadingZeros() const { enum { msw_bits = (BitWidth % APINT_BITS_PER_WORD)?(BitWidth % APINT_BITS_PER_WORD):APINT_BITS_PER_WORD, excessBits = APINT_BITS_PER_WORD - msw_bits }; uint32_t Count = ap_private_ops::CountLeadingZeros_64(pVal[_AP_N-1]); if (Count>=excessBits) Count -= excessBits; if (!pVal[_AP_N-1]) { for (int i = _AP_N-1 ; i ; --i) { if (!pVal[i-1]) Count += APINT_BITS_PER_WORD; else { Count += ap_private_ops::CountLeadingZeros_64(pVal[i-1]); break; } } } return Count; } /// countLeadingOnes - This function counts the number of contiguous 1 bits /// in the high order bits. The count stops when the first 0 bit is reached. /// @returns 0 if the high order bit is not set /// @returns the number of 1 bits from the most significant to the least /// @brief Count the number of leading one bits. INLINE uint32_t countLeadingOnes() const { if (isSingleWord()) return countLeadingOnes_64(get_VAL(), APINT_BITS_PER_WORD - BitWidth); uint32_t highWordBits = BitWidth % APINT_BITS_PER_WORD; uint32_t shift = (highWordBits == 0 ? 0 : APINT_BITS_PER_WORD - highWordBits); int i = _AP_N - 1; uint32_t Count = countLeadingOnes_64(get_pVal(i), shift); if (Count == highWordBits) { for (i--; i >= 0; --i) { if (get_pVal(i) == ~0ULL) Count += APINT_BITS_PER_WORD; else { Count += countLeadingOnes_64(get_pVal(i), 0); break; } } } return Count; } /// countTrailingZeros - This function is an ap_private version of the /// countTrailingZoers_{32,64} functions in MathExtras.h. It counts /// the number of zeros from the least significant bit to the first set bit. /// @returns BitWidth if the value is zero. /// @returns the number of zeros from the least significant bit to the first /// one bit. /// @brief Count the number of trailing zero bits. INLINE uint32_t countTrailingZeros() const { uint32_t Count = 0; uint32_t i = 0; for (; i < _AP_N && get_pVal(i) == 0; ++i) Count += APINT_BITS_PER_WORD; if (i < _AP_N) Count += ap_private_ops::CountTrailingZeros_64(get_pVal(i)); return AESL_std::min(Count, BitWidth); } /// countPopulation - This function is an ap_private version of the /// countPopulation_{32,64} functions in MathExtras.h. It counts the number /// of 1 bits in the ap_private value. /// @returns 0 if the value is zero. /// @returns the number of set bits. /// @brief Count the number of bits set. INLINE uint32_t countPopulation() const { uint32_t Count = 0; for (int i = 0; i<_AP_N-1 ; ++i) Count += ap_private_ops::CountPopulation_64(pVal[i]); Count += ap_private_ops::CountPopulation_64(pVal[_AP_N-1]&mask); return Count; } /// @} /// @name Conversion Functions /// @ /// This is used internally to convert an ap_private to a string. /// @brief Converts an ap_private to a std::string INLINE std::string toString(uint8_t radix, bool wantSigned) const ; /// Considers the ap_private to be unsigned and converts it into a string in the /// radix given. The radix can be 2, 8, 10 or 16. /// @returns a character interpretation of the ap_private /// @brief Convert unsigned ap_private to string representation. INLINE std::string toStringUnsigned(uint8_t radix = 10) const { return toString(radix, false); } /// Considers the ap_private to be unsigned and converts it into a string in the /// radix given. The radix can be 2, 8, 10 or 16. /// @returns a character interpretation of the ap_private /// @brief Convert unsigned ap_private to string representation. INLINE std::string toStringSigned(uint8_t radix = 10) const { return toString(radix, true); } /// @brief Converts this ap_private to a double value. INLINE double roundToDouble(bool isSigned) const { // Handle the simple case where the value is contained in one uint64_t. if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) { uint64_t val = pVal[0]; if (isSigned) { int64_t sext = ((int64_t(val)) << (64-BitWidth)) >> (64-BitWidth); return double(sext); } else return double(val); } // Determine if the value is negative. bool isNeg = isSigned ? (*this)[BitWidth-1] : false; // Construct the absolute value if we're negative. ap_private<_AP_W, _AP_S> Tmp(isNeg ? -(*this) : (*this)); // Figure out how many bits we're using. uint32_t n = Tmp.getActiveBits(); // The exponent (without bias normalization) is just the number of bits // we are using. Note that the sign bit is gone since we constructed the // absolute value. uint64_t exp = n; // Return infinity for exponent overflow if (exp > 1023) { if (!isSigned || !isNeg) return std::numeric_limits<double>::infinity(); else return -std::numeric_limits<double>::infinity(); } exp += 1023; // Increment for 1023 bias // Number of bits in mantissa is 52. To obtain the mantissa value, we must // extract the high 52 bits from the correct words in pVal. uint64_t mantissa; unsigned hiWord = whichWord(n-1); if (hiWord == 0) { mantissa = Tmp.get_pVal(0); if (n > 52) (mantissa) >>= (n - 52); // shift down, we want the top 52 bits. } else { assert(hiWord > 0 && "High word is negative?"); uint64_t hibits = (Tmp.get_pVal(hiWord)) << (52 - n % APINT_BITS_PER_WORD); uint64_t lobits = (Tmp.get_pVal(hiWord-1)) >> (11 + n % APINT_BITS_PER_WORD); mantissa = hibits | lobits; } // The leading bit of mantissa is implicit, so get rid of it. uint64_t sign = isNeg ? (1ULL << (APINT_BITS_PER_WORD - 1)) : 0; union { double __D; uint64_t __I; } __T; __T.__I = sign | ((exp) << 52) | mantissa; return __T.__D; } /// @brief Converts this unsigned ap_private to a double value. INLINE double roundToDouble() const { return roundToDouble(false); } /// @brief Converts this signed ap_private to a double value. INLINE double signedRoundToDouble() const { return roundToDouble(true); } /// The conversion does not do a translation from integer to double, it just /// re-interprets the bits as a double. Note that it is valid to do this on /// any bit width. Exactly 64 bits will be translated. /// @brief Converts ap_private bits to a double INLINE double bitsToDouble() const { union { uint64_t __I; double __D; } __T; __T.__I = pVal[0]; return __T.__D; } /// The conversion does not do a translation from integer to float, it just /// re-interprets the bits as a float. Note that it is valid to do this on /// any bit width. Exactly 32 bits will be translated. /// @brief Converts ap_private bits to a double INLINE float bitsToFloat() const { union { uint32_t __I; float __F; } __T; __T.__I = uint32_t(pVal[0]); return __T.__F; } /// The conversion does not do a translation from double to integer, it just /// re-interprets the bits of the double. Note that it is valid to do this on /// any bit width but bits from V may get truncated. /// @brief Converts a double to ap_private bits. INLINE ap_private& doubleToBits(double __V) { union { uint64_t __I; double __D; } __T; __T.__D = __V; pVal[0] = __T.__I; return *this; } /// The conversion does not do a translation from float to integer, it just /// re-interprets the bits of the float. Note that it is valid to do this on /// any bit width but bits from V may get truncated. /// @brief Converts a float to ap_private bits. INLINE ap_private& floatToBits(float __V) { union { uint32_t __I; float __F; } __T; __T.__F = __V; pVal[0] = __T.__I; } //Reduce operation //----------------------------------------------------------- INLINE bool and_reduce() const { return isMaxValue(); } INLINE bool nand_reduce() const { return isMinValue(); } INLINE bool or_reduce() const { return (bool)countPopulation(); } INLINE bool nor_reduce() const { return countPopulation()==0; } INLINE bool xor_reduce() const { unsigned int i=countPopulation(); return (i%2)?true:false; } INLINE bool xnor_reduce() const { unsigned int i=countPopulation(); return (i%2)?false:true; } INLINE std::string to_string(uint8_t radix=16, bool sign=false) const { return toString(radix, radix==10?_AP_S:sign); } }; //End of class ap_private <_AP_W, _AP_S, false> namespace ap_private_ops { enum {APINT_BITS_PER_WORD=64}; template<int _AP_W, bool _AP_S> INLINE bool operator==(uint64_t V1, const ap_private<_AP_W, _AP_S>& V2) { return V2 == V1; } template<int _AP_W, bool _AP_S> INLINE bool operator!=(uint64_t V1, const ap_private<_AP_W, _AP_S>& V2) { return V2 != V1; } template<int _AP_W, bool _AP_S, int index> INLINE bool get(const ap_private<_AP_W, _AP_S>& a) { static const uint64_t mask=1ULL << (index&0x3f); return ((mask & a.get_pVal((index)>>6)) != 0); } template<int _AP_W, bool _AP_S, int msb_index, int lsb_index> INLINE void set(ap_private<_AP_W, _AP_S>& a, const ap_private<AP_MAX(msb_index,1), true>& mark1 = 0, const ap_private<AP_MAX(lsb_index,1), true>& mark2 = 0) { enum { APINT_BITS_PER_WORD=64, lsb_word = lsb_index /APINT_BITS_PER_WORD, msb_word = msb_index / APINT_BITS_PER_WORD, msb = msb_index % APINT_BITS_PER_WORD, lsb=lsb_index % APINT_BITS_PER_WORD}; if (msb_word==lsb_word) { const uint64_t mask = ~0ULL >> (lsb) << (APINT_BITS_PER_WORD-msb+lsb-1)>>(APINT_BITS_PER_WORD-msb-1); //a.set_pVal(msb_word, a.get_pVal(msb_word) | mask); a.get_pVal(msb_word) |= mask; } else { const uint64_t lsb_mask = ~0ULL >> (lsb) << (lsb); const uint64_t msb_mask = ~0ULL << (APINT_BITS_PER_WORD-msb-1)>>(APINT_BITS_PER_WORD-msb-1); //a.set_pVal(lsb_word, a.get_pVal(lsb_word) | lsb_mask); a.get_pVal(lsb_word) |=lsb_mask; for (int i=lsb_word+1; i<msb_word; i++) { a.set_pVal(i, ~0ULL); //a.get_pVal(i)=0; } //a.set_pVal(msb_word, a.get_pVal(msb_word) | msb_mask); a.get_pVal(msb_word) |= msb_mask; } a.clearUnusedBits(); } template<int _AP_W, bool _AP_S, int msb_index, int lsb_index> INLINE void clear(ap_private<_AP_W, _AP_S>& a, const ap_private<AP_MAX(msb_index,1), true>& mark1 = 0, const ap_private<AP_MAX(lsb_index,1), true>& mark2 = 0) { enum { APINT_BITS_PER_WORD=64, lsb_word = lsb_index /APINT_BITS_PER_WORD, msb_word = msb_index / APINT_BITS_PER_WORD, msb = msb_index % APINT_BITS_PER_WORD, lsb=lsb_index % APINT_BITS_PER_WORD}; if (msb_word == lsb_word) { const uint64_t mask = ~(~0ULL >> (lsb) << (APINT_BITS_PER_WORD-msb+lsb-1)>>(APINT_BITS_PER_WORD-msb-1)); //a.set_pVal(msb_word, a.get_pVal(msb_word) & mask); a.get_pVal(msb_word) &= mask; } else { const uint64_t lsb_mask = ~(~0ULL >> (lsb) << (lsb)); const uint64_t msb_mask = ~(~0ULL << (APINT_BITS_PER_WORD-msb-1)>>(APINT_BITS_PER_WORD-msb-1)); //a.set_pVal(lsb_word, a.get_pVal(lsb_word) & lsb_mask); a.get_pVal(lsb_word) &=lsb_mask; for (int i=lsb_word+1; i<msb_word; i++) { //a.set_pVal(i, 0); a.get_pVal(i)=0; } //a.set_pVal(msb_word, a.get_pVal(msb_word) & msb_mask); a.get_pVal(msb_word) &= msb_mask; } a.clearUnusedBits(); } template<int _AP_W, bool _AP_S, int index> INLINE void set(ap_private<_AP_W, _AP_S>& a, const ap_private<AP_MAX(index, 1), true>& mark = 0) { enum { APINT_BITS_PER_WORD=64, word = index/APINT_BITS_PER_WORD}; static const uint64_t mask=1ULL << (index%APINT_BITS_PER_WORD); //a.set_pVal(word, a.get_pVal(word) | mask); a.get_pVal(word) |= mask; a.clearUnusedBits(); } template<int _AP_W, bool _AP_S, int index> INLINE void clear(ap_private<_AP_W, _AP_S>& a, const ap_private<AP_MAX(index,1), true>& mark = 0) { enum { APINT_BITS_PER_WORD=64, word = index/APINT_BITS_PER_WORD}; static const uint64_t mask=~(1ULL << (index%APINT_BITS_PER_WORD)); //a.set_pVal(word, a.get_pVal(word) & mask); a.get_pVal(word) &= mask; a.clearUnusedBits(); } } // End of ap_private_ops namespace template<int _AP_W, bool _AP_S> INLINE std::string ap_private<_AP_W, _AP_S, false>::toString(uint8_t radix, bool wantSigned) const { assert((radix == 10 || radix == 8 || radix == 16 || radix == 2) && "Radix should be 2, 8, 10, or 16!"); static const char *digits[] = { "0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F" }; std::string result; if (radix != 10) { // For the 2, 8 and 16 bit cases, we can just shift instead of divide // because the number of bits per digit (1,3 and 4 respectively) divides // equaly. We just shift until there value is zero. // First, check for a zero value and just short circuit the logic below. if (*this == (uint64_t)(0)) result = "0"; else { ap_private<_AP_W, false> tmp(*this); size_t insert_at = 0; bool leading_zero = true; if (wantSigned && isNegative()) { // They want to print the signed version and it is a negative value // Flip the bits and add one to turn it into the equivalent positive // value and put a '-' in the result. tmp.flip(); tmp++; tmp.clearUnusedBitsToZero(); result = "-"; insert_at = 1; leading_zero = false; } switch (radix) { case 2: result += "0b"; break; case 8: result += "0o"; break; case 16: result += "0x"; break; default: assert("invalid radix" && 0); } insert_at += 2; // Just shift tmp right for each digit width until it becomes zero uint32_t shift = (radix == 16 ? 4 : (radix == 8 ? 3 : 1)); uint64_t mask = radix - 1; ap_private<_AP_W, false> zero(0); unsigned bits = 0; while (tmp.ne(zero)) { uint64_t digit = tmp.get_VAL() & mask; result.insert(insert_at, digits[digit]); tmp = tmp.lshr(shift); ++bits; } bits *= shift; if (bits < _AP_W && leading_zero) result.insert(insert_at, digits[0]); } return result; } ap_private<_AP_W, false> tmp(*this); ap_private<_AP_W, false> divisor(radix); ap_private<_AP_W, false> zero(0); size_t insert_at = 0; if (wantSigned && isNegative()) { // They want to print the signed version and it is a negative value // Flip the bits and add one to turn it into the equivalent positive // value and put a '-' in the result. tmp.flip(); tmp++; tmp.clearUnusedBitsToZero(); result = "-"; insert_at = 1; } if (tmp == ap_private<_AP_W, false>(0)) result = "0"; else while (tmp.ne(zero)) { ap_private<_AP_W, false> APdigit(0); ap_private<_AP_W, false> tmp2(0); ap_private_ops::divide(tmp, tmp.getNumWords(), divisor, divisor.getNumWords(), &tmp2, &APdigit); uint64_t digit = APdigit.getZExtValue(); assert(digit < radix && "divide failed"); result.insert(insert_at,digits[digit]); tmp = tmp2; } return result; } // End of ap_private<_AP_W, _AP_S, false>::toString() #endif // AP_PRIVATE_H
[ "elimkwan@github.com" ]
elimkwan@github.com
7bba3e9c084f9fd235cdca44a93e0a527ab1b454
d751b29b5612acb15523521f5228260b0d5344bf
/lab2/WeatherStationPro/Observer.h
38cad9b6930c2905948b2da3a3498a31fe240416
[]
no_license
Dekhant/ood
fa05ddb8eb1820f233bbaa7441e3433053c6176d
8180281926266b7562706f015d9ed57ecb5413af
refs/heads/master
2023-02-24T06:21:21.351285
2021-01-19T08:26:00
2021-01-19T08:26:00
293,547,588
0
0
null
null
null
null
UTF-8
C++
false
false
1,233
h
#pragma once #include <map> template <typename T> class IObserver { public: virtual void Update(T const& data) = 0; virtual ~IObserver() = default; }; template <typename T> class IObservable { public: virtual ~IObservable() = default; virtual void RegisterObserver(IObserver<T>& observer, unsigned priority) = 0; virtual void NotifyObservers() = 0; virtual void RemoveObserver(IObserver<T>& observer) = 0; }; template <class T> class CObservable : public IObservable<T> { public: typedef IObserver<T> ObserverType; void RegisterObserver(ObserverType& observer, unsigned priority) override { m_observers.emplace(priority, &observer); } void NotifyObservers() override { T data = GetChangedData(); std::multimap<int, ObserverType*> observers = m_observers; for (auto iter = observers.rbegin(); iter != observers.rend(); ++iter) { iter->second->Update(data); } } void RemoveObserver(ObserverType& observer) override { for (auto iter = m_observers.begin(); iter != m_observers.end(); ++iter) { if (iter->second == &observer) { m_observers.erase(iter); break; } } } protected: virtual T GetChangedData() const = 0; private: std::multimap<int, ObserverType*> m_observers; };
[ "52196622+Jurmmander@users.noreply.github.com" ]
52196622+Jurmmander@users.noreply.github.com
e89c81d5d6f8fc776a9565be2902498e357fa46c
1c8e5a1fc7f9dfee4969194c1bd77918eea73095
/Source/AllProjects/WndUtils/CIDCtrls/CIDCtrls_TouchWnd.hpp
e9a2370403e5b882da6d8ac38cfd84f195e8d68f
[]
no_license
naushad-rahman/CIDLib
bcb579a6f9517d23d25ad17a152cc99b7508330e
577c343d33d01e0f064d76dfc0b3433d1686f488
refs/heads/master
2020-04-28T01:08:35.084154
2019-03-10T02:03:20
2019-03-10T02:03:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,558
hpp
// // FILE NAME: CIDCtrls_TouchWnd.hpp // // AUTHOR: Dean Roddey // // CREATED: 06/19/2015 // // COPYRIGHT: $_CIDLib_CopyRight_$ // // $_CIDLib_CopyRight2_$ // // DESCRIPTION: // // This is the base class for any windows that want to use touch input. You can do all // of this stuff yourself if you need to, but it's just a nice convenience. // // This guy will handle both mouse and touch input messages and convert them into a // consistent touch interface that is easy to use. So the caller doesn't need to care if // the monitor is multi-touch or only mouse (or old style single-touch which looks // like a mouse to us.) // // We use the pluggable gesture handler interface, and just ask it to give us a gesture // handler based on the local system capabilities. We just feed that gesture handler the // appropriate window messages, and he generates the gesture output calls. We implement // his gesture target mixin and just leave those methods unhandled so that the derived // class has to provide them. // // So the way it works is: // // Us sending wnd msgs input to // -> multi-touch or mouse enabled gesture handler // -> which digests them and calls gesture methods on the gesture target // -> which come to use since we implement the target and pass ourself // -> which he derived class overrides and uses as appropriate // // CAVEATS/GOTCHAS: // // LOG: // // $_CIDLib_Log_$ // #pragma once #pragma CIDLIB_PACK(CIDLIBPACK) // --------------------------------------------------------------------------- // CLASS: TTouchWnd // PREFIX: wnd // --------------------------------------------------------------------------- class CIDCTRLSEXP TTouchWnd : public TWindow, public MCIDGestTarget { public : // ------------------------------------------------------------------- // Constructors and Destructor // ------------------------------------------------------------------- TTouchWnd(const TTouchWnd&) = delete; ~TTouchWnd(); // ------------------------------------------------------------------- // Public oprators // ------------------------------------------------------------------- TTouchWnd& operator=(const TTouchWnd&) = delete; // ------------------------------------------------------------------- // Public, non-virtual methods // ------------------------------------------------------------------- tCIDLib::TVoid CreateTouchWnd ( const TWindow& wndParent , const tCIDCtrls::TWndId widThis , const TArea& areaInit , const tCIDCtrls::EWndStyles eStyles ); protected : // ------------------------------------------------------------------- // Hidden constructors // ------------------------------------------------------------------- TTouchWnd(); // ------------------------------------------------------------------- // Protected, inherited methods // ------------------------------------------------------------------- tCIDLib::TBoolean bCreated() override; tCIDLib::TBoolean bEatSubClassMsg ( const tCIDCtrls::TWndMsg wmsgMsg , const tCIDCtrls::TWParam wParam , const tCIDCtrls::TLParam lParam , tCIDCtrls::TMsgResult& mresRet ) override; tCIDLib::TVoid Destroyed() override; private : // ------------------------------------------------------------------- // Private data members // // m_bFlag // We maintain a flag which we pass into the gesture handler's msg handler. // So we basically are just persisting a flag for him across invocations. // He can change it and we pass it back in next time. // // m_pgesthCur // The gesture handler that we got upon startup. We just ask the gesture // handler engine for an appropriate handler and use it. // ------------------------------------------------------------------- tCIDLib::TBoolean m_bFlag; TCIDWndGestHandler* m_pgesthCur; // ------------------------------------------------------------------- // Do any needed magic macros // ------------------------------------------------------------------- RTTIDefs(TTouchWnd, TWindow) }; #pragma CIDLIB_POPPACK
[ "droddey@charmedquark.com" ]
droddey@charmedquark.com
eebab277367c264d399af53f5df585addf4e5622
a89266f25b2538151336c537546894491b424456
/src/SpecialDumper.cpp
4ac02afeea7ce08f47dbc058b81c67ab82ef07a6
[ "MIT" ]
permissive
RickeyEstes/SimpleCompiler
a249303c17a0a9937275fc1510dbdca010ff00a9
6c9063f355d573d4d2dbd74448647d7074d69c8a
refs/heads/master
2022-04-11T22:06:27.526449
2019-10-02T11:45:54
2019-10-02T11:45:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,092
cpp
#include "SpecialDumper.h" #include "Semantics.h" #include <iostream> #include <functional> #include <regex> static std::string escapeSlash(const std::string &s) { return regex_replace(s, std::regex("\\\\"), "\\\\"); } static std::string escapePersent(const std::string &s) { return regex_replace(s, std::regex("%"), "%%"); } template<> void SpecialDumper::operator()(Program &local, const ASTNode &node) { ss << "#include <stdio.h>" << std::endl; auto dft = [&] (const ASTNode &node) { SourceCode::const_iterator a = node.startIter->srcPos, b = node.endIter->srcPos; for(auto i = a; i != b; ++i) ss << *i; ss << std::endl; }; if(node.hasChild("const")) { dft(node.getChild("const")); } if(node.hasChild("var")) { dft(node.getChild("var")); } for(const Function &f : local.functions) { std::string t = f.node.is("VoidFunc") ? "void" : f.node.is("IntFunc") || f.node.is("MainFunc") ? "int" : "char"; ss << t << " " << f.identifier << "("; bool first = true; for(const auto &v : f.paramList.variables) { if(first) { first = false; } else { ss << ", "; } if(v.type == VarIntType) { ss << "int "; } else { ss << "char "; } ss << v.identifier; } ss << ") {" << std::endl; ss << text[f.identifier] << std::endl; ss << "}" << std::endl; } } template<> void SpecialDumper::operator()(Function &local, const ASTNode &node) { assert(node.is("Compound")); assert(text.find(local.identifier) == text.end()); auto &code = text[local.identifier]; auto dft = [&] (const ASTNode &node) { SourceCode::const_iterator a = node.startIter->srcPos, b = node.endIter->srcPos; for(auto i = a; i != b; ++i) code.push_back(*i); }; if(node.hasChild("const")) { dft(node.getChild("const")); } if(node.hasChild("var")) { dft(node.getChild("var")); } auto to_cstrliteral = [] (const Token &t) { return escapePersent(escapeSlash(((const StringLiteral *)&t)->getLiteral())); }; std::function<const Function *(const ASTNode &)> involk; std::function<VarType(const ASTNode &)> expression, item, factor; std::function<void(const ASTNode &)> statement; involk = [&] (const ASTNode &node) -> const Function * { const auto name = node.getChild("funcName").valIter->str(); auto res = local.lookup(name); const Function *f = res.result.f; return f; }; factor = [&] (const ASTNode &node) { if(node.hasChild("child") && node.getChild("child").is("Expression")) { } else if(node.hasChild("child") && node.getChild("child").is("InvolkExpression")) { const Function *func = involk(node.getChild("child")); return func->node.is("CharFunc") ? VarCharType : VarIntType; } else if(node.hasChild("int")) { } else if(node.hasChild("char")) { return VarCharType; } else if(node.hasChild("index")) { const std::string &arr = node.getChild("identifier").valIter->str(); const auto res = local.lookup(arr); return (res.type == TGlobalVariable || res.type == TLocalVariable) && (res.result.v->type == VarCharArray) ? VarCharType : VarIntType; } else if(node.hasChild("identifier")) { const std::string &v = node.getChild("identifier").valIter->str(); if(local.lookup(v).type == TConstant) { if(local.lookup(v).result.c->type == ConstCharType) { return VarCharType; } } else { const auto res = local.lookup(v); return (res.type == TGlobalVariable || res.type == TLocalVariable || res.type == TParameter) && (res.result.v->type == VarCharType) ? VarCharType : VarIntType; } } return VarIntType; }; item = [&] (const ASTNode &node) { if(node.getChildren().size() <= 1) { return factor(node.getChildren()[0]); } return VarIntType; }; expression = [&] (const ASTNode &node) { if(node.getChildren().size() <= 1) { return item(node.getChildren()[0]); } return VarIntType; }; auto printStatement = [&] (const ASTNode &node) { if(node.hasChild("string")) { std::string s = to_cstrliteral(*node.getChild("string").valIter); code += std::string("printf(\"") + s + "\");\n"; } if(!node.hasChild("expression")) return; VarType t = expression(node.getChild("expression")); if(t == VarCharType) { code += std::string("printf(\"%c\", "); } else { code += std::string("printf(\"%d\", "); } dft(node.getChild("expression")); code += ");\n"; code += "printf(\"\\n\");"; }; auto readVar = [&] (const ASTNode &node) { const auto id = node.valIter->str(); auto res = local.lookup(id); switch(res.type) { case TParameter: case TGlobalVariable: case TLocalVariable: { const auto v = *res.result.v; if(v.type == VarIntType) { code += "scanf(\" %d\", &"; code += id; code += ");"; } else { code += "scanf(\" %c\", &"; code += id; code += ");"; } break; } default: break; } }; auto scanStatement = [&] (const ASTNode &node) { for(const auto &c : node) readVar(c); }; auto dowhileStatement = [&] (const ASTNode &node) { code += "do {\n"; statement(node.getChild("statement")); code += "} while("; dft(node.getChild("condition")); code += ");\n"; }; auto ifStatement = [&] (const ASTNode &node) { if(node.hasChild("statementB")) { code += "if("; dft(node.getChild("condition")); code += ") {\n"; statement(node.getChild("statementA")); code += "} else {\n"; statement(node.getChild("statementB")); code += "}\n"; } else { code += "if("; dft(node.getChild("condition")); code += ") {\n"; statement(node.getChild("statementA")); code += "}\n"; } }; auto forStatement = [&] (const ASTNode &node) { auto id = node.getChild("idA").valIter->str(); ((code += "for(") += id) += " = "; dft(node.getChild("init")); code += "; "; dft(node.getChild("condition")); uint32_t step = node.getChild("step").valIter->getVal<uint32_t>(); (((((((code += "; ") += id) += " = ") += id) += " ") += node.getChild("op").valIter->tokenType.indicator) += " ") += std::to_string(step); code += ") {\n"; statement(node.getChild("statement")); code += "}\n"; }; statement = [&] (const ASTNode &node) { for(const auto &c : node) { if(c.is("Statement")) { statement(c); } else if(c.is("AssignmentStatement")) { dft(c); } else if(c.is("IfStatement")) { ifStatement(c); } else if(c.is("DoWhileStatement")) { dowhileStatement(c); } else if(c.is("ForStatement")) { forStatement(c); } else if(c.is("ReturnStatement")) { dft(c); } else if(c.is("PrintStatement")) { printStatement(c); } else if(c.is("ScanStatement")) { scanStatement(c); } else if(c.is("InvolkStatement")) { dft(c); } code.push_back('\n'); } }; statement(node); }
[ "ChieloNewctle@Yandex.com" ]
ChieloNewctle@Yandex.com
bc7180ac4f8e2e353ab11643c93489a13814895e
b5bb24596deb19b9114783fe44577009fdd1d296
/ptlib/tags/FireDoor14/include/ptlib/pdirect.h
b800f08e0b646b7090ff652fe2dc5ecbe6c6fbb1
[]
no_license
erdincay/opal-voip
0ca10d30105795272b505995309b2af5836d1079
7937e4df5833f48a273a9b3519de87c6bcdc5410
refs/heads/master
2020-05-17T18:41:42.371445
2015-09-10T17:38:14
2015-09-10T17:38:14
42,303,471
3
0
null
null
null
null
UTF-8
C++
false
false
14,961
h
/* * $Id: pdirect.h,v 1.27 1998/03/05 12:44:34 robertj Exp $ * * Portable Windows Library * * Operating System Classes Interface Declarations * * Copyright 1993 Equivalence * * $Log: pdirect.h,v $ * Revision 1.27 1998/03/05 12:44:34 robertj * Added cluster size. * * Revision 1.26 1997/03/31 11:34:00 robertj * Fixed default permissions for directories , different from that for files. * * Revision 1.25 1997/01/12 04:22:21 robertj * Added function to get disk size and free space. * * Revision 1.24 1995/12/23 03:45:31 robertj * Added constructor for C string literals. * * Revision 1.23 1995/11/09 12:17:23 robertj * Added platform independent base type access classes. * * Revision 1.22 1995/10/14 15:02:22 robertj * Added function to get parent directory. * * Revision 1.21 1995/06/17 11:12:52 robertj * Documentation update. * * Revision 1.20 1995/03/14 12:42:00 robertj * Updated documentation to use HTML codes. * * Revision 1.19 1995/03/12 04:42:48 robertj * Updated documentation. * Changed return type of functions to the correct case string. * * Revision 1.18 1995/02/22 10:50:33 robertj * Changes required for compiling release (optimised) version. * * Revision 1.17 1995/01/06 10:42:25 robertj * Moved identifiers into different scope. * Changed file size to 64 bit integer. * Documentation * * Revision 1.16 1994/10/24 00:07:03 robertj * Changed PFilePath and PDirectory so descends from either PString or * PCaselessString depending on the platform. * * Revision 1.15 1994/10/23 04:49:25 robertj * Chnaged PDirectory to descend of PString. * Added PDirectory Exists() function. * * Revision 1.14 1994/08/23 11:32:52 robertj * Oops * * Revision 1.13 1994/08/22 00:46:48 robertj * Added pragma fro GNU C++ compiler. * * Revision 1.12 1994/06/25 11:55:15 robertj * Unix version synchronisation. * * Revision 1.11 1994/04/20 12:17:44 robertj * Split name into PFilePath * * Revision 1.10 1994/04/11 14:16:27 robertj * Added function for determining if character is a valid directory separator. * * Revision 1.9 1994/04/01 14:14:57 robertj * Put platform independent file permissions and type codes back. * * Revision 1.7 1994/01/13 03:17:55 robertj * Added functions to get the name of the volume the directory is contained in * and a function to determine if the directory is a root directory of the * volume (ie is does not have a parent directory). * * Revision 1.6 1994/01/03 04:42:23 robertj * Mass changes to common container classes and interactors etc etc etc. * * Revision 1.5 1993/12/31 06:45:38 robertj * Made inlines optional for debugging purposes. * * Revision 1.4 1993/08/21 01:50:33 robertj * Made Clone() function optional, default will assert if called. * * Revision 1.3 1993/07/14 12:49:16 robertj * Fixed RCS keywords. * */ #define _PDIRECTORY #ifdef __GNUC__ #pragma interface #endif /////////////////////////////////////////////////////////////////////////////// // File System PDECLARE_CLASS(PFileInfo, PObject) /* Class containing the system information on a file path. Information can be obtained on any directory entry event if it is not a "file" in the strictest sense. Sub-directories, devices etc may also have information retrieved. */ public: enum FileTypes { RegularFile = 1, // Ordinary disk file. SymbolicLink = 2, // File path is a symbolic link. SubDirectory = 4, // File path is a sub-directory CharDevice = 8, // File path is a character device name. BlockDevice = 16, // File path is a block device name. Fifo = 32, // File path is a fifo (pipe) device. SocketDevice = 64, // File path is a socket device. UnknownFileType = 256, // File path is of an unknown type. AllFiles = 0x1ff // Mask for all file types. }; /* All types that a particular file path may be. Not all platforms support all of the file types. For example under DOS no file may be of the type <CODE>SymbolicLink</CODE>. */ FileTypes type; // File type for this file. Only one bit is set at a time here. PTime created; /* Time of file creation of the file. Not all platforms support a separate creation time in which case the last modified time is returned. */ PTime modified; // Time of last modifiaction of the file. PTime accessed; /* Time of last access to the file. Not all platforms support a separate access time in which case the last modified time is returned. */ PUInt64 size; /* Size of the file in bytes. This is a quadword or 8 byte value to allow for files greater than 4 gigabytes. */ enum Permissions { WorldExecute = 1, // File has world execute permission WorldWrite = 2, // File has world write permission WorldRead = 4, // File has world read permission GroupExecute = 8, // File has group execute permission GroupWrite = 16, // File has group write permission GroupRead = 32, // File has group read permission UserExecute = 64, // File has owner execute permission UserWrite = 128, // File has owner write permission UserRead = 256, // File has owner read permission AllPermissions = 0x1ff, // All possible permissions. DefaultPerms = UserRead|UserWrite|GroupRead|WorldRead, DefaultDirPerms = DefaultPerms|UserExecute|GroupExecute|WorldExecute // Owner read & write plus group and world read permissions. }; // File access permissions for the file. int permissions; /* A bit mask of all the file acces permissions. See the <A>Permissions enum</A> for the possible bit values. Not all platforms support all permissions. */ BOOL hidden; /* File is a hidden file. What constitutes a hidden file is platform dependent, for example under unix it is a file beginning with a '.' character while under MS-DOS there is a file system attribute for it. */ }; PDECLARE_CONTAINER(PDirectory, PFILE_PATH_STRING) /* Class to represent a directory in the operating system file system. A directory is a special file that contains a list of file paths. The directory paths are highly platform dependent and a minimum number of assumptions should be made. The PDirectory object is a string consisting of a possible volume name, and a series directory names in the path from the volumes root to the directory that the object represents. Each directory is separated by the platform dependent separator character which is defined by the PDIR_SEPARATOR macro. The path always has a trailing separator. Some platforms allow more than one character to act as a directory separator so when doing any processing the <A>IsSeparator()</A> function should be used to determine if a character is a possible separator. The directory may be opened to gain access to the list of files that it contains. Note that the directory does <EM>not</EM> contain the "." and ".." entries that some platforms support. The ancestor class is dependent on the platform. For file systems that are case sensitive, eg Unix, the ancestor is <A>PString</A>. For other platforms, the ancestor class is <A>PCaselessString</A>. */ public: PDirectory(); // Create a directory object of the current working directory PDirectory( const char * cpathname // Directory path name for new object. ); PDirectory( const PString & pathname // Directory path name for new object. ); /* Create a directory object of the specified directory. The <CODE>pathname</CODE> parameter may be a relative directory which is made absolute by the creation of the <A>PDirectory</A> object. */ // New member functions PDirectory GetParent() const; /* Get the directory for the parent to the current directory. If the directory is already the root directory it returns the root directory again. <H2>Returns:</H2> parent directory. */ PFILE_PATH_STRING GetVolume() const; /* Get the volume name that the directory is in. This is platform dependent, for example for MS-DOS it is the 11 character volume name for the drive, eg "DOS_DISK", and for Macintosh it is the disks volume name eg "Untitled". For a unix platform it is the device name for the file system eg "/dev/sda1". <H2>Returns:</H2> string for the directory volume. */ BOOL IsRoot() const; /* Determine if the directory is the root directory of a volume. <H2>Returns:</H2> TRUE if the object is a root directory. */ PINLINE static BOOL IsSeparator( char ch // Character to check as being a separator. ); /* Determine if the character <CODE>ch</CODE> is a directory path separator. <H2>Returns:</H2> TRUE if may be used to separate directories in a path. */ BOOL GetVolumeSpace( PInt64 & total, // Total number of bytes available on volume PInt64 & free, // Number of bytes unused on the volume DWORD & clusterSize // "Quantisation factor" in bytes for files on volume ) const; /* Determine the total number of bytes and number of bytes free on the volume that this directory is contained on. Note that the free space will be the physical limit and if user quotas are in force by the operating system, the use may not actually be able to use all of these bytes. <H2>Returns:</H2> TRUE if the information could be determined. */ BOOL Exists() const; static BOOL Exists( const PString & p // Directory file path. ); /* Test for if the directory exists. The parameterless version tests against the name contained in the object instance. The static version may be simply passed a path name. <H2>Returns:</H2> TRUE if directory exists. */ BOOL Change() const; static BOOL Change( const PString & p // Directory file path. ); /* Change the current working directory. The parameterless version changes to the name contained in the object instance. The static version may be simply passed a path name. <H2>Returns:</H2> TRUE if current working directory was changed. */ BOOL Create( int perm = PFileInfo::DefaultDirPerms // Permission on new directory. ) const; PINLINE static BOOL Create( const PString & p, // Directory file path. int perm = PFileInfo::DefaultDirPerms // Permission on new directory. ); /* Create a new directory with the specified permissions. The parameterless version changes to the name contained in the object instance. The static version may be simply passed a path name. <H2>Returns:</H2> TRUE if directory created. */ BOOL Remove(); PINLINE static BOOL Remove( const PString & p // Directory file path. ); /* Delete the specified directory. The parameterless version changes to the name contained in the object instance. The static version may be simply passed a path name. <H2>Returns:</H2> TRUE if directory was deleted. */ BOOL Open( int scanMask = PFileInfo::AllFiles // Mask of files to provide. ); /* Open the directory for scanning its list of files. Once opened the <A>GetEntryName()</A> function may be used to get the current directory entry and the <A>Next()</A> function used to move to the next directory entry. Only files that are of a type that is specified in the mask will be returned. Note that the directory scan will <EM>not</EM> return the "." and ".." entries that some platforms support. <H2>Returns:</H2> TRUE if directory was successfully opened, and there was at least one file in it of the specified types. */ BOOL Restart( int scanMask = PFileInfo::AllFiles // Mask of files to provide. ); /* Restart file list scan from the beginning of directory. This is similar to the <A>Open()</A> command but does not require that the directory be closed (using <A>Close()</A>) first. Only files that are of a type that is specified in the mask will be returned. Note that the directory scan will <EM>not</EM> return the "." and ".." entries that some platforms support. <H2>Returns:</H2> TRUE if directory was successfully opened, and there was at least one file in it of the specified types. */ BOOL Next(); /* Move to the next file in the directory scan. Only files that are of a type that is specified in the mask passed to the <A>Open()</A> or <A>Restart()</A> functions will be returned. Note that the directory scan will <EM>not</EM> return the "." and ".." entries that some platforms support. <H2>Returns:</H2> TRUS if there is another valid file in the directory. */ void Close(); // Close the directory during or after a file list scan. PFILE_PATH_STRING GetEntryName() const; /* Get the name (without the volume or directory path) of the current entry in the directory scan. This may be the name of a file or a subdirectory or even a link or device for operating systems that support them. To get a full path name concatenate the PDirectory object itself with the entry name. Note that the directory scan will <EM>not</EM> return the "." and ".." entries that some platforms support. <H2>Returns:</H2> string for directory entry. */ BOOL IsSubDir() const; /* Determine if the directory entry currently being scanned is itself another directory entry. Note that the directory scan will <EM>not</EM> return the "." and ".." entries that some platforms support. <H2>Returns:</H2> TRUE if entry is a subdirectory. */ BOOL GetInfo( PFileInfo & info // Object to receive the file information. ) const; /* Get file information on the current directory entry. <H2>Returns:</H2> TRUE if file information was successfully retrieved. */ protected: // New functions for class void Construct(); // Common constructor code // Member variables int scanMask; // Mask of file types that the directory scan will return. // Class declaration continued in platform specific header file ///////////////
[ "robertj@023b2edf-31b2-4de3-b41e-bca80c47788f" ]
robertj@023b2edf-31b2-4de3-b41e-bca80c47788f
897a54fe0498cb738a97d939d7961353a1340110
ec8ba9b076b368bdeabbdebc89cda7b48a857ad4
/grammarAnalyzer.h
eb64c9b3c2944a74e963f671ffcb4fd99df0d485
[]
no_license
NotEnterprising/C-like-Grammar-Compiler
9d4bad1b4dc871fab7b0a44b9beadf12de0fedfe
b97908a58821f82740802e59cb5b9bd6464d160b
refs/heads/master
2023-03-22T21:01:47.267496
2021-03-22T02:20:55
2021-03-22T02:20:55
350,171,903
0
1
null
null
null
null
UTF-8
C++
false
false
2,289
h
#pragma once #include <fstream> #include "lexicalanalysis.h" #include "error.h" #include "intermediateCode.h" #define printGrammarAnswer(str) { printvector.emplace_back(str); } #define keyword mylexicalanalyzer.keyword #define getSym() mylexicalanalyzer.getSym(); class grammarAnalyzer { public: grammarAnalyzer(lexicalanalysis& lexicalanalyzer, std::ofstream& output, std::vector<std::string>& vectorin,error& Error); error& myerror; lexicalanalysis& mylexicalanalyzer; std::ofstream& fileOutput; std::vector<std::string>& printvector; std::string funcName; int arraySizei ; int arraySizej ; std::string currentFunc; bool hasReturn; void startAnalyze(); int checkInMap(std::string name); void errorPrint(char a,int line); void program(); void constStatement(); void addArray(bool flag, std::string identifier,int sizei,int sizej); void addVar(bool flag, std::string identifier,int value); int varStatement(bool flag, std::string identifier); void varDefinition(bool flag,std::string identifier); //void varDefinitionInitial(bool flag); void varDefinitionWithoutInitial(bool flag); void returnFuncDefinition(std::string funcName,int type); void noReturnFuncDefinition(std::string funcName); void constDefinition(); int integer(std::string &value); void parametersTable(); void compoundSentence(); void statementList(); void statement(); void loopStatement(); void conditionalStatements(); void functionCallStatement(bool flag, std::string nameIn); void valueParameterTable(std::string nameIn); int expression(std::string& value); int item(std::string & value); int factor(std::string &value); void assignmentStatement(std::string name); void scanfSentence(); void printfSentence(); void returnStatement(); int unsignedInteger(std::string &value); void condition(std::string label); int step(); void switchStatements(); void switchTable(int type,std::string labelOut,std::string value); void switchCaseStatements(int type,std::string labelOut,std::string value); void defaultStatement(); void twoDimensionalArray(); void oneDimensionalArray(); void oneDimensionalAssignment(std::string identifier,bool flag,int arraySize); void twoDimensionalAssignment(std::string identifier,bool flag, int arraySizeOfI, int arraySizeOfJ); };
[ "18373118@buaa.edu.cn" ]
18373118@buaa.edu.cn
2f2bfce64f46a7412561fb6e53a4786757e199d7
4fa9ee124402fcb0bfb60b663f8f316311d7ef50
/project/directBase/begin/aStar_grape.cpp
c2d2666c34eeeb148049006f416e2dc60d87cfa1
[]
no_license
newkid004/portfolio_02_directx9
78594351055cfd88d1b60c6cad8c04235118ca0b
a7f00fc5f29b911d571da90ccaa687c516bef8eb
refs/heads/master
2020-04-18T01:50:22.215330
2019-02-27T09:26:05
2019-02-27T09:26:05
167,136,634
1
0
null
null
null
null
UHC
C++
false
false
4,011
cpp
#include "aStar_grape.h" #include "aStar_node.h" #include "aStar_runner.h" #include "aStar_path.h" #include "gMng.h" #include "gFunc.h" #include "heap.h" using namespace std; aStar_grape::~aStar_grape() { for (auto iter : _vNodeList) SAFE_DELETE(iter); } void aStar_grape::addNode(aStar_node * input) { input->getBindGrape() = this; gMng::add(input, _vNodeList); input->getIndex() = _vNodeList.size() - 1; } bool aStar_grape::deleteNode(aStar_node * input) { if (gMng::find(input, _vNodeList)) return deleteNode(input->getIndex()); return false; } bool aStar_grape::deleteNode(int index) { SAFE_DELETE(_vNodeList[index]); _vNodeList.erase(_vNodeList.begin() + index); for (int i = index; i < _vNodeList.size(); ++i) _vNodeList[i]->getIndex() = i; return true; } bool aStar_grape::connectNode(aStar_node * n1, aStar_node * n2, bool reConnect) { bool isConnected = false; auto & nodeConnection = n1->getLinkedNodeList(); // 중복 시, 거리 재계산 for (auto & iter : nodeConnection) { if (iter.connector == n2) { iter.distance = aStar_grape::calDistance(n1, n2); return true; } } float distance = aStar_grape::calDistance(n1, n2); nodeConnection.push_back(aStar_node::LIST::value_type({ n2, distance })); gMng::add(n2->getIndex(), _mConnection[n1->getIndex()]); if (reConnect) return connectNode(n2, n1, false); return true; } bool aStar_grape::connectNode(int index1, int index2) { if (index1 < _vNodeList.size() && index2 < _vNodeList.size()) { connectNode(_vNodeList[index1], _vNodeList[index2]); return true; } return false; } void aStar_grape::pathfind(aStar_path** out_path, aStar_node* sour, aStar_node* dest) { vector<aStar_runner*> runnerContainer; heap<aStar_runner*, aStar_runner::comparer> openList; vector<aStar_runner*> closeList; _currentNode = sour; _destNode = dest; // calc start aStar_runner* runStart = new aStar_runner(_currentNode); openList.push(runStart); runnerContainer.push_back(runStart); while (!openList.empty()) { // current runner aStar_runner* runner = openList.top(); _currentNode = runner->getMember().placedNode; if (_currentNode == _destNode) break; openList.pop(); closeList.push_back(runner); // closing node for (auto & iter : _currentNode->getLinkedNodeList()) { aStar_node* viewNode = iter.connector; // close check bool isInCloseList = false; for (auto i : closeList) { if (viewNode->getIndex() == i->getMember().placedNode->getIndex()) { isInCloseList = true; break; } } if (isInCloseList) continue; // open check bool isInOpenList = false; for (auto i : openList) { if (viewNode->getIndex() == i->getMember().placedNode->getIndex()) { isInOpenList = true; // distance check if (runner->getMember().distance.G < i->getMember().distance.G) i->setPrevRunner(runner); break; } } // is not in openList if (!isInOpenList) { aStar_runner* traveler = new aStar_runner(runner, iter.connector); openList.push(traveler); runnerContainer.push_back(traveler); } } } // result *out_path = nullptr; if (!openList.empty()) { std::list<aStar_runner*> resultPath; aStar_runner* backRunner = openList.top(); while (backRunner->getMember().placedNode != sour) { resultPath.push_front(new aStar_runner(backRunner->getMember())); backRunner = backRunner->getMember().prevRunner; } resultPath.push_front(new aStar_runner(runStart->getMember())); *out_path = new aStar_path(resultPath); } // memory delete for (auto i : runnerContainer) SAFE_DELETE(i); } float aStar_grape::calDistance(aStar_node * n1, aStar_node * n2) { aStar_node::info *infoA, *infoB; n1->getInfo(infoA); n2->getInfo(infoB); return gFunc::Vec3Distance(infoA->pos, infoB->pos); } float aStar_grape::calDistance(aStar_node * n, D3DXVECTOR3 & pos) { aStar_node::info *info; n->getInfo(info); return gFunc::Vec3Distance(info->pos, pos); }
[ "newkid004@gmail.com" ]
newkid004@gmail.com
9febe94721fe056eccb188d1d899f28af4637465
83eae18ee94568b3d7addae1365f0f05bbb3cc1d
/app/src/main/cpp/core/_2d/ParticleEmitters.h
7754ebc9aa19c05600c5236e5506d353bfcc17b0
[]
no_license
whulzz1993/BubbleGame
0332232d00748edaa232db5d4fd8d501217c287a
649834ddbf2e79aa0131dd65538edd3560cc3f07
refs/heads/master
2023-03-18T18:08:25.741529
2021-03-12T02:57:44
2021-03-12T02:57:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,009
h
#pragma once #include <memory> #include <vector> #include <array> #include <cstring> #include <cstdlib> #include "Particle.h" //#include "ParticleSystem.h" #include "../Texture.h" #include "../ImageSprite.h" #include "../Vector2.h" #include "../Math2D.h" namespace core { namespace _2d { class RandomParticleEmitter : public ParticleEmitter { protected: constexpr static unsigned short Mask = 0x3FF; constexpr static float Div = 1.0f / (Mask + 1); public: RandomParticleEmitter(ParticleSystem *_parent); void initParticle(Particle *_prt); }; class PointRandomParticleEmitter : public ParticleEmitter { protected: constexpr static unsigned short Mask = 0x3FF; constexpr static float Div = 1.0f / (Mask + 1); public: PointRandomParticleEmitter(ParticleSystem *_parent); void initParticle(Particle *_prt); }; } }
[ "nirme.89@gmail.com" ]
nirme.89@gmail.com
7d07542fd3ae32526bb77eb5c521c30152a4f82f
512afa93438988ec22c3551a919844d1f55244c4
/Shape.cpp
536d563e1d041c877019873639f3fc39bd182b2a
[]
no_license
Big-Boss-Monchas/tec8
f13345dbad627b21f3500a6d843f15e2ad04eb0f
a6ab366895c785e3a181989fd0a275d8b5b89df5
refs/heads/master
2020-07-27T21:13:48.143336
2019-09-25T19:10:09
2019-09-25T19:10:09
209,217,852
0
0
null
2019-09-29T05:00:09
2019-09-18T04:32:59
C++
UTF-8
C++
false
false
2,383
cpp
#include <iostream> #include "Shapes.h" #include <GL/glut.h> void quadrantFour(int, int, int, int); void initiate(int, int); void mainLines(void); int x, y; int main(int argc, char *argv[]) { glutInit(&argc, argv); std::cout << "Please enter width size:"; std::cin >> x; std::cout << "Please enter height size:"; std::cin >> y; quadrantFour(0, 0, x, y); glutMainLoop(); } void quadrantFour(int x_start, int y_start, int x_end, int y_end) { glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowPosition(50, 50); glutInitWindowSize(x_end + x_start, y_end + y_start); // Establece el tamaño de la ventana glutCreateWindow("Four Quadrant Window"); initiate(x_end, y_end); glutDisplayFunc(mainLines); } void initiate(int x_end, int y_end) { glClearColor(0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(-(x_end / 2), x_end / 2, -(y_end / 2), y_end / 2); } void mainLines(void) { int x_center = (int)x / 2, y_center = (int)y / 2, spacing = 20; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.5, 0.5, 0.5); glLineWidth(1); glBegin(GL_LINES); int x1 = 0 + spacing, x2 = 0 - spacing; int y1 = 0 + spacing, y2 = 0 - spacing; while (x1 < x / 2) { glVertex2i(x1, -y_center); glVertex2i(x1, y_center); glVertex2i(x2, -y_center); glVertex2i(x2, y_center); x1 += spacing; x2 -= spacing; } while (y1 < y / 2) { glVertex2i(-x_center, y1); glVertex2i(x_center, y1); glVertex2i(-x_center, y2); glVertex2i(x_center, y2); y1 += spacing; y2 -= spacing; } glEnd(); glColor3f(1.0, 0.0, 0.0); glBegin(GL_LINES); glVertex2i(0, 0); glVertex2i(x_center, 0); glEnd(); glColor3f(0.0, 1.0, 0.0); glBegin(GL_LINES); glVertex2i(0, 0); glVertex2i(0, y_center); glEnd(); glColor3f(0.0, 0.0, 1.0); glBegin(GL_LINES); glVertex2i(0, 0); glVertex2i(-x_center, 0); glEnd(); glColor3f(1.0, 1.0, 0.0); glBegin(GL_LINES); glVertex2i(0, 0); glVertex2i(0, -y_center); glEnd(); Rectangle rec(40, 20, 100, 120, 0.0, 1.0, 1.0, 5); rec.drawShape(); Square sq(60, 40, 60, 0.0, 1.0, 0.0, 3); sq.drawShape(); Triangle tri(80, 60, 40, 40, 0.0, 0.0, 1.0, 4); tri.drawShape(); Circle cir(100, 100, 50, 0.75, 0.75, 0.0, 2); cir.drawShape(); Circle cir2(100, -100, 50, 0.75, 0.75, 0.0, 5); cir2.drawShapeTrig(); glFlush(); }
[ "noreply@github.com" ]
noreply@github.com
922ea9f058c74a805bf1d7cfb83a98f42cec6f2c
9d74b8a8d42a217669e27534132787b522829e03
/FastVideoPro/FastVideov1/VideoDownloader/uiutils.h
f39a345acd54e6ee3725258c9d023730d3aca1ff
[]
no_license
TommyZhang936/TChallaOld
c8450880135d1ff2392236e288c515ccb799216e
6d980b31f40fc7e6b789b862e2e7f408296dadfc
refs/heads/master
2020-07-01T08:15:02.259552
2016-11-10T01:32:59
2016-11-10T01:32:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
899
h
#ifndef UIUTILS_H #define UIUTILS_H #include <QString> #include <QToolTip> #include <QWidget> #include <QPoint> #include <string> #include <QTimer> #include <QThread> #include <QLabel> #include <QListWidget> class UIUtils { public: static void showTip(QWidget &w, const QString &text, const QPoint &pos = QPoint(0, 0), int seconds = 3); static void addToListWidget(QListWidget& lw, QWidget& itemWidget); static void insertToListWidget(QListWidget& lw, QWidget& itemWidget, int row); static void getChildrenSortByX(QWidget& parent, std::vector<QWidget*>& mvcChildren); static bool showQuetionBox(const QString& title, const QString& msg); static bool showQuetionBox(const QString& title, const QString& msg, const QString& sYes, const QString& sNo); private: /* * 构造函数 * @return void */ UIUtils(); }; #endif // UIUTILS_H
[ "janyboo@gmail.com" ]
janyboo@gmail.com
f47a44e97f23d0ccf7350608d943d2812d20efdb
a35b30a7c345a988e15d376a4ff5c389a6e8b23a
/boost/thread/is_locked_by_this_thread.hpp
1685b560fee06dcf666f1f6b9830642b4bc07c23
[]
no_license
huahang/thirdparty
55d4cc1c8a34eff1805ba90fcbe6b99eb59a7f0b
07a5d64111a55dda631b7e8d34878ca5e5de05ab
refs/heads/master
2021-01-15T14:29:26.968553
2014-02-06T07:35:22
2014-02-06T07:35:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
77
hpp
#include "thirdparty/boost_1_55_0/boost/thread/is_locked_by_this_thread.hpp"
[ "liuhuahang@xiaomi.com" ]
liuhuahang@xiaomi.com
35ec87bcbdaf91149ed8d67f879393de159933ca
689375ba151993ce381484413f59b5ac909bd939
/src/CMSHemisphere.cc
5913c5957c983fd47cfc0a0fecc83529ca920cf7
[]
no_license
VecbosApp/VecbosApp
f7efa483ca844a7697db90035fce2611c5082fbf
1fd25e4dcf4a48770b4fdc711470f6329bc9fb7c
refs/heads/master
2021-01-18T20:29:51.411877
2015-03-30T05:39:12
2015-03-30T05:39:12
11,135,590
0
0
null
null
null
null
UTF-8
C++
false
false
5,667
cc
#include <vector> #include <math.h> #include <TLorentzVector.h> #include "CMSHemisphere.hh" using namespace std; CMSHemisphere::CMSHemisphere(vector<TLorentzVector> jets){ if(jets.size() < 2) cout << "Error in CMSHemisphere: you should provide at least two jets to form Henispheres" << endl; jIN = jets; CombineSaveConstituents(); //Combine(); } CMSHemisphere::~CMSHemisphere() { } vector<TLorentzVector> CMSHemisphere::GetHemispheres() { return jOUT; } vector<int> CMSHemisphere::GetHem1Constituents() { vector<int> hem_temp; if(no_switch) { for (int i = 0; i < 40; i++){ hem_temp.push_back(hem[chosen_perm][i]); } return hem_temp; delete hem; } else { for (int i = 0; i < 40; i++){ hem_temp.push_back(hem2[chosen_perm][i]); } return hem_temp; delete hem2; } } vector<int> CMSHemisphere::GetHem2Constituents() { vector<int> hem_temp; if(no_switch) { for (int i = 0; i < 40; i++){ hem_temp.push_back(hem2[chosen_perm][i]); } return hem_temp; delete hem2; } else { for(int i;i < 40;i++){ hem_temp.push_back(hem[chosen_perm][i]); } return hem_temp; delete hem; } } void CMSHemisphere::Combine() { int N_JETS = jIN.size(); int N_comb = 1; for(int i = 0; i < N_JETS; i++){ N_comb *= 2; } int j_count; for(int i = 1; i < N_comb-1; i++){ TLorentzVector j_temp1, j_temp2; int itemp = i; j_count = N_comb/2; int count = 0; while(j_count > 0){ if(itemp/j_count == 1){ j_temp1 += jIN[count]; } else { j_temp2 += jIN[count]; } itemp -= j_count*(itemp/j_count); j_count /= 2; count++; } j1.push_back(j_temp1); j2.push_back(j_temp2); } } void CMSHemisphere::CombineMinMass() { double M_min = -1; // default value (in case none is found) TLorentzVector myJ1 = j1[0]; TLorentzVector myJ2 = j2[0]; for(int i=0; i< j1.size(); i++) { double M_temp = j1[i].M2()+j2[i].M2(); if(M_min < 0 || M_temp < M_min){ M_min = M_temp; myJ1 = j1[i]; myJ2 = j2[i]; chosen_perm = i; } } // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0); // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0); jOUT.clear(); if(myJ1.Pt() > myJ2.Pt()){ no_switch = true; jOUT.push_back(myJ1); jOUT.push_back(myJ2); } else { no_switch = false; jOUT.push_back(myJ2); jOUT.push_back(myJ1); } } void CMSHemisphere::CombineMinEnergyMass() { double M_min = -1; // default value (in case none is found) TLorentzVector myJ1 = j1[0]; TLorentzVector myJ2 = j2[0]; for(int i=0; i< j1.size(); i++) { double M_temp = j1[i].M2()/j1[i].E()+j2[i].M2()/j2[i].E(); if(M_min < 0 || M_temp < M_min){ M_min = M_temp; myJ1 = j1[i]; myJ2 = j2[i]; chosen_perm = i; } } // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0); // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0); jOUT.clear(); if(myJ1.Pt() > myJ2.Pt()){ no_switch = true; jOUT.push_back(myJ1); jOUT.push_back(myJ2); } else { no_switch = false; jOUT.push_back(myJ2); jOUT.push_back(myJ1); } } void CMSHemisphere::CombineGeorgi(){ double M_max = -10000; // default value (in case none is found) TLorentzVector myJ1 = j1[0]; TLorentzVector myJ2 = j2[0]; for(int i=0; i< j1.size(); i++) { int myBeta = 2; double M_temp = (j1[i].E()-myBeta*j1[i].M2()/j1[i].E())+(j2[i].E()-myBeta*j2[i].M2()/j2[i].E()); if(M_max < -9999 || M_temp > M_max){ M_max = M_temp; myJ1 = j1[i]; myJ2 = j2[i]; chosen_perm = i; } } // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0); // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0); jOUT.clear(); if(myJ1.Pt() > myJ2.Pt()){ no_switch = true; jOUT.push_back(myJ1); jOUT.push_back(myJ2); } else { no_switch = false; jOUT.push_back(myJ2); jOUT.push_back(myJ1); } } void CMSHemisphere::CombineSaveConstituents() { int N_JETS = jIN.size(); // jets NEED to be ordered by pT // saves 2D array, first index = # of combination of jets // saved number = jet # that goes into hemisphere int N_comb = 1; for(int i = 0; i < N_JETS; i++){ N_comb *= 2; } for (int i = 0; i < 20000; i++){ for (int j = 0; j < 40; j++){ hem[i][j] = -1; hem2[i][j] = -1; } } int j_count; int array_count=0; for(int i = 1; i < N_comb-1; i++){ TLorentzVector j_temp1, j_temp2; int itemp = i; j_count = N_comb/2; int count = 0; int hem_count = 0; //loops through # of jets in first hem int hem_count2 = 0; // loops through # of jets in second hem while(j_count > 0){ if(itemp/j_count == 1){ j_temp1 += jIN[count]; hem[array_count][hem_count] = count; hem_count++; } else { j_temp2 += jIN[count]; hem2[array_count][hem_count2]=count; hem_count2++; } itemp -= j_count*(itemp/j_count); j_count /= 2; count++; } j1.push_back(j_temp1); j2.push_back(j_temp2); array_count++; } } void CMSHemisphere::CombineMinHT() { double dHT_min = 999999999999999.0; // default value (in case none is found) TLorentzVector myJ1 = j1[0]; TLorentzVector myJ2 = j2[0]; for(int i=0; i< j1.size(); i++) { double dHT_temp = fabs(j1[i].E()-j2[i].E()); if(dHT_temp < dHT_min){ dHT_min = dHT_temp; myJ1 = j1[i]; myJ2 = j2[i]; } } jOUT.clear(); if(myJ1.Pt() > myJ2.Pt()){ jOUT.push_back(myJ1); jOUT.push_back(myJ2); } else { jOUT.push_back(myJ2); jOUT.push_back(myJ1); } }
[ "jduarte@caltech.edu" ]
jduarte@caltech.edu
d8e7281d46359e1e01dec8babae9e8aad9093224
70a2dcf9901aa5e9756dcd65a0694663393a313a
/ar05_rpt10/AR05_waterlevel___/AR05_waterlevel___.ino
9734fa69c3c928b617aa73d4b6b2113fda931bcf
[]
no_license
smj3343/ar05
d9923fbd48d62ebc3cec31424b3b0e70e7c668f9
801422a767cc9598a04380455cdd3a05c4b7e9d8
refs/heads/main
2023-05-09T18:38:53.027862
2021-06-15T17:34:12
2021-06-15T17:34:12
344,036,512
0
0
null
null
null
null
UTF-8
C++
false
false
2,029
ino
/* 예제 6.4 수위 센서 입력 */ // I2C 통신 라이브러리 설정 #include <Wire.h> // I2C LCD 라리브러리 설정 #include <LiquidCrystal_I2C.h> // LCD I2C address 설정 PCF8574:0x27, PCF8574A:0x3F LiquidCrystal_I2C lcd(0x27,16,2); // LCD address:0x27, 16X2 LCD // 0번 아날로그핀을 WaterLevel Sensor 입력으로 설정한다. const int waterLevelPin = 0; // 센서마다 만수시 ADC 값이 틀리므로 만수 시 ADC 값을 참고하여 설정한다. const int waterFullAdcValue = 798; void setup() { pinMode(13, OUTPUT); lcd.init(); // LCD 설정 lcd.backlight(); // 백라이트를 켠다. // 메세지를 표시한다. lcd.print("ex 6.4"); lcd.setCursor(0,1); lcd.print("Water Level"); // 3초동안 메세지를 표시한다. delay(3000); // 모든 메세지를 삭제한 뒤 // 숫자를 제외한 부분들을 미리 출력시킨다. lcd.clear(); lcd.setCursor(0,0); lcd.print("ADC : "); lcd.setCursor(0,1); lcd.print("Water Level:"); lcd.setCursor(15,1); lcd.print("%"); } void loop(){ int adcValue; // 실제 센서로부터 읽은 값 (0~1023) int waterLevel; // 수위 0~100% // 수위 센서를 통하여 입력되는 전압을 읽는다. adcValue = analogRead(waterLevelPin); // 아날로그 입력 값을 0~100의 범위로 변경한다. waterLevel = map(adcValue, 0, waterFullAdcValue, 0, 100); digitalWrite(13, HIGH); // 전에 표시했던 내용을 지우고 // LCD에 ADC 값과 수위를 출력한다. // 지우지 않으면 이전에 표시했던 값이 남게 된다. // 전에 표시했던 내용을 지운다. lcd.setCursor(9,0); lcd.print(" "); // ADC 값을 표시한다 lcd.setCursor(9,0); lcd.print(adcValue); // 전에 표시했던 내용을 지운다. lcd.setCursor(13,1); lcd.print(" "); // 수위를 표시한다 lcd.setCursor(12,1); lcd.print(waterLevel); delay(1000); }
[ "noreply@github.com" ]
noreply@github.com
56782c6804c9da480da7e75d35e1a9d1aa2a964e
fe82dc5d82d4a8d3fc806cacdbe05035e1b379e6
/Hello/Network/ASIO/mQ.cpp
67ce6767aa39ca10e1ca4424139b46fd1708f6a7
[]
no_license
HarounH/spaceRash
5bab67d16a4539c603b096441a7c6076ef6a5bd4
a51ce510c70f32f7f46ed221749d7e3d2e700b37
refs/heads/master
2016-08-04T20:01:40.360068
2015-04-25T18:18:18
2015-04-25T18:18:18
34,252,186
0
0
null
null
null
null
UTF-8
C++
false
false
20
cpp
#include "mQ.h"
[ "haroun7@gmail.com" ]
haroun7@gmail.com
d6fcf939203daf1092dd0d3950b984ed8a6b6a6f
fd51438414286f9a732f7c05b24c7f5d87141fc3
/Units/Defectoscope/Windows/LineViewer.cpp
40ecc06b5c41059c935a681c5260f9035a174f91
[]
no_license
andreyV512/samara
3bed94c4e7f9c85d228ab11758fe67c280e2bb80
81e17f383307482a1231cc1ec85bfb0cec0f17fb
refs/heads/master
2020-04-24T03:03:54.965694
2019-02-22T09:23:14
2019-02-22T09:23:14
171,658,831
0
0
null
null
null
null
UTF-8
C++
false
false
3,065
cpp
#include "stdafx.h" #include "LineViewer.h" #include "Graphics/FixedGridSeries.h" #include "debug_tools/DebugMess.h" #include "templates/templates.hpp" using namespace Gdiplus; LineViewer::LineViewer() : backScreen(NULL) { label.fontHeight = 9; label.top = 0; } void LineViewer::operator()(TSize &l) { if(l.resizing == SIZE_MINIMIZED || 0 == l.Width || 0 == l.Height) return; if(NULL != backScreen) { if(backScreen->GetWidth() < l.Width || backScreen->GetHeight() < l.Height) { delete backScreen; backScreen = new Bitmap(l.Width, l.Height); } } else if(l.Width > 0 && l.Height > 0) { backScreen = new Bitmap(l.Width, l.Height); } else { return; } Graphics g(backScreen); SolidBrush solidBrush(Color(0xffaaaaaa)); g.FillRectangle(&solidBrush, 0, 0, 10, l.Height); g.FillRectangle(&solidBrush, 0, 0, l.Width, 29); if(0 == chart->rect.right && 0 == chart->rect.bottom) { storedMouseMove.x = WORD(l.Width / 2); storedMouseMove.y = WORD(l.Height / 2); } chart->rect.right = l.Width; chart->rect.bottom = l.Height; chart->Draw(g); } void LineViewer::operator()(TPaint &l) { if(NULL == backScreen) return; PAINTSTRUCT p; HDC hdc = BeginPaint(l.hwnd, &p); { Graphics g(hdc); g.DrawCachedBitmap(&CachedBitmap(backScreen, &g), 0, 0); cursor->VerticalCursor(storedMouseMove, PaintGraphics(g)); } EndPaint(l.hwnd, &p); } unsigned LineViewer::operator()(TCreate &l) { chart->minAxesX = 0; chart->maxAxesX = 512; chart->rect.top = 17; storedMouseMove.hwnd = l.hwnd; storedMouseMove.x = WORD((chart->rect.right - chart->rect.left)/ 2); storedMouseMove.y = WORD((chart->rect.bottom - chart->rect.top)/ 2); mouseMove = false; offsetX = 5; return 0; } //---------------------------------------------------------------- void LineViewer::operator()(TMouseWell &l) { mouseMove = false; if(l.delta > 0) offsetX -= 1; else if(l.delta < 0)offsetX += 1; double dX = (chart->rect.right - chart->rect.left - chart->offsetAxesLeft - chart->offsetAxesRight) /(chart->maxAxesX - chart->minAxesX); storedMouseMove.x = (WORD)(chart->rect.left + chart->offsetAxesLeft + dX * offsetX + dX / 2); cursor->VerticalCursor(storedMouseMove, HDCGraphics(storedMouseMove.hwnd, backScreen)); } //-------------------------------------------------------------------------- void LineViewer::operator()(TMouseMove &l) { if(mouseMove) { if(cursor->VerticalCursor(l, HDCGraphics(l.hwnd, backScreen))) { storedMouseMove = l; int y; chart->CoordCell(l.x, l.y, offsetX, y); } } } //-------------------------------------------------------------- void LineViewer::operator()(TLButtonDown &l) { mouseMove = false; } //----------------------------------------------------------------- void LineViewer::operator()(TLButtonDbClk &l) { mouseMove = true; if(cursor->VerticalCursor(*(TMouseMove *)&l, HDCGraphics(l.hwnd, backScreen))) { int y; chart->CoordCell(l.x, l.y, offsetX, y); } } //-----------------------------------------------------------------------------
[ "drewan@rambler.ru" ]
drewan@rambler.ru
d082bad553d5f4b8b1f0449594cb8154eebab02d
4ace1e82a57146404a5a360faab64b4beb038946
/src/qt/qtipcserver.cpp
4e634c5ef21b8ba597aae978f5223b7e8308e279
[ "MIT" ]
permissive
zahidaliayub/kidscoin
0a22d4009e8efd057f3e765bc1da3d8490071b08
00453e4ef53cdf25f31d12137e3256b0527dea96
refs/heads/master
2021-08-30T13:09:22.909535
2017-04-15T19:06:53
2017-04-15T19:06:53
114,594,939
0
1
null
null
null
null
UTF-8
C++
false
false
4,927
cpp
// Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/version.hpp> #if defined(WIN32) && BOOST_VERSION == 104900 #define BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME #endif #include "qtipcserver.h" #include "guiconstants.h" #include "ui_interface.h" #include "util.h" #include <boost/algorithm/string/predicate.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/interprocess/ipc/message_queue.hpp> #include <boost/version.hpp> #if defined(WIN32) && (!defined(BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME) || !defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME) || BOOST_VERSION < 104900) #warning Compiling without BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME and BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME uncommented in boost/interprocess/detail/tmp_dir_helpers.hpp or using a boost version before 1.49 may have unintended results see svn.boost.org/trac/boost/ticket/5392 #endif using namespace boost; using namespace boost::interprocess; using namespace boost::posix_time; #if defined MAC_OSX || defined __FreeBSD__ // URI handling not implemented on OSX yet void ipcScanRelay(int argc, char *argv[]) { } void ipcInit(int argc, char *argv[]) { } #else static void ipcThread2(void* pArg); static bool ipcScanCmd(int argc, char *argv[], bool fRelay) { // Check for URI in argv bool fSent = false; for (int i = 1; i < argc; i++) { if (boost::algorithm::istarts_with(argv[i], "KidsCoin:")) { const char *strURI = argv[i]; try { boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME); if (mq.try_send(strURI, strlen(strURI), 0)) fSent = true; else if (fRelay) break; } catch (boost::interprocess::interprocess_exception &ex) { // don't log the "file not found" exception, because that's normal for // the first start of the first instance if (ex.get_error_code() != boost::interprocess::not_found_error || !fRelay) { printf("main() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); break; } } } } return fSent; } void ipcScanRelay(int argc, char *argv[]) { if (ipcScanCmd(argc, argv, true)) exit(0); } static void ipcThread(void* pArg) { // Make this thread recognisable as the GUI-IPC thread RenameThread("KidsCoin-gui-ipc"); try { ipcThread2(pArg); } catch (std::exception& e) { PrintExceptionContinue(&e, "ipcThread()"); } catch (...) { PrintExceptionContinue(NULL, "ipcThread()"); } printf("ipcThread exited\n"); } static void ipcThread2(void* pArg) { printf("ipcThread started\n"); message_queue* mq = (message_queue*)pArg; char buffer[MAX_URI_LENGTH + 1] = ""; size_t nSize = 0; unsigned int nPriority = 0; while (true) { ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100); if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d)) { uiInterface.ThreadSafeHandleURI(std::string(buffer, nSize)); MilliSleep(1000); } if (fShutdown) break; } // Remove message queue message_queue::remove(BITCOINURI_QUEUE_NAME); // Cleanup allocated memory delete mq; } void ipcInit(int argc, char *argv[]) { message_queue* mq = NULL; char buffer[MAX_URI_LENGTH + 1] = ""; size_t nSize = 0; unsigned int nPriority = 0; try { mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH); // Make sure we don't lose any bitcoin: URIs for (int i = 0; i < 2; i++) { ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1); if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d)) { uiInterface.ThreadSafeHandleURI(std::string(buffer, nSize)); } else break; } // Make sure only one bitcoin instance is listening message_queue::remove(BITCOINURI_QUEUE_NAME); delete mq; mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH); } catch (interprocess_exception &ex) { printf("ipcInit() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); return; } if (!NewThread(ipcThread, mq)) { delete mq; return; } ipcScanCmd(argc, argv, false); } #endif
[ "kidscoin@scryptmail.com" ]
kidscoin@scryptmail.com
98d7d6f11a843e1d32bbd0385013a185721ded95
44036fb20e2a7242588bc09771a13395266c408f
/Codechef/XENTASK.cpp
4bc44d72d9801e0909812d16dcc4ddb87996418d
[]
no_license
adMenon/Competetive-programing-codes
d03a5f3a8111b87897e9d24f29d2d92a79b301dd
c0b34556da5092151426784f2f9f1d03d2837736
refs/heads/master
2021-04-06T08:36:50.005676
2018-03-16T02:34:52
2018-03-16T02:34:52
125,392,087
0
0
null
null
null
null
UTF-8
C++
false
false
715
cpp
/* Author - Aditya Haridas Menon Codechef id - ad2411 */ #include <iostream> #include<algorithm> using namespace std; int main() { // your code goes here int t; cin>>t; while(t--) { int n,sum1=0,sum2=0; cin>>n; int *x=new int[n],*y=new int[n]; for(int i=0;i<n;i++) cin>>x[i]; for(int i=0;i<n;i++) cin>>y[i]; for(int i=0;i<n;i++) { if(i%2==0) { sum1+=x[i]; sum2+=y[i]; } else { sum1+=y[i]; sum2+=x[i]; } } cout<<min(sum1,sum2)<<endl; } return 0; }
[ "adityaharidas.m16@iiits.in" ]
adityaharidas.m16@iiits.in
24252267ea9ccd8c2f72e169d13d56568b3ae7b6
9dc9ad709b3772d5b49adb1fc424caecde07988a
/dinput8/src/CWeaponEffectsHack.cpp
dc7cf28893764a084cb09d05dad7e290fc5e6a74
[]
no_license
ModelingMan/gtalc-dinput8
b31deb699a9b3ac7d985639a062602727001dd8e
76f574d50c364af3241b2214863d69a0af215733
refs/heads/master
2021-01-19T01:48:23.794965
2019-08-19T19:09:23
2019-08-19T19:09:23
29,551,092
8
7
null
2019-06-17T21:30:48
2015-01-20T20:43:42
C++
UTF-8
C++
false
false
1,473
cpp
#include "CWeaponEffectsHack.h" #include "Globals.h" #include "SilentCall.h" #include "vcversion.h" static unsigned long initJumpEnd = vcversion::AdjustOffset(0x005D512D); bool CWeaponEffectsHack::initialise() { // auto-aim crosshair InjectHook(0x005D511C, &CWeaponEffectsHack::InitHackProxy, PATCH_JUMP); // transparent crosshair Patch<unsigned char>(0x005D4EEE, 9); // use 6 for no outline // sniper dot (aap's skygfx_vc) Patch<unsigned char>(0x00558024, 6); return true; } void __declspec(naked) CWeaponEffectsHack::InitHackProxy() { __asm { call CWeaponEffectsHack::InitHack jmp initJumpEnd } } RwTexture *CWeaponEffectsHack::InitHack() { RwTexture *addr = RwTextureRead("crosshair", "crosshairm"); // use alternative target texture if it exists if (!GetPrivateProfileInt("Misc", "UseVCAutoAimTexture", 1, "./gta-lc.ini") && addr) { VCGlobals::strcpy(reinterpret_cast<char *>(vcversion::AdjustOffset(0x0069D818)), "crosshair"); VCGlobals::strcpy(reinterpret_cast<char *>(vcversion::AdjustOffset(0x0069D80C)), "crosshairm"); DWORD flOldProtect; void *address = reinterpret_cast<void *>(vcversion::AdjustOffset(0x005D4ECC)); VirtualProtect(address, 0x23, PAGE_EXECUTE_READWRITE, &flOldProtect); Nop(0x005D4ECC, 11); Patch<unsigned char>(0x005D4EE3, 2); Patch<unsigned char>(0x005D4EEE, 2); VirtualProtect(address, 0x23, flOldProtect, &flOldProtect); } else { addr = RwTextureRead("target256", "target256m"); } return addr; }
[ "spaceeinstein@yahoo.com" ]
spaceeinstein@yahoo.com
da1f478f75901b1f229444ea9f8d82c50ae43c5b
530e077ff7fc0fb83f69c24aae1c57b2a775b7d2
/RecursionPractice/3.Factorial by recursion.cpp
a07c712c03f0df96334e302807a0d6d6c578f8cc
[]
no_license
Chirag291/Algos-coded-by-me
882dbd342d0b93d292bf410ba2530ca9979d85a8
beb5f5e53abef0ec2196f4c5914cf2c962d636ab
refs/heads/master
2023-05-13T09:22:38.186725
2021-05-19T07:53:54
2021-05-19T07:53:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
502
cpp
#include<bits/stdc++.h> using namespace std; int factorial (int n){ if(n == 1) return 1; else return n*factorial(n-1); } int32_t main() { #ifndef ONLINE_JUDGE clock_t tStart = clock(); freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base:: sync_with_stdio(false); cin.tie(0); //////////////////////////////////////start............... int n; cin>>n; cout<<factorial(n)<<endl; ///////////////////////end-......................... return 0; }
[ "ashish_business@yahoo.com" ]
ashish_business@yahoo.com
a6041754e78cb447e1829d89994d08ec36a908a0
f7cd4fee05656a4b543d0db22a029d91efe0310e
/main.cpp
1ee97ebcc710b7361985c6a2b151e0ed3536f011
[]
no_license
JIucT/Clasters_Lab1
cf29b41844934567433f1ac46020d5ff072207e3
fe8f03a4e5df2b0dc7d49035c75f99fdb0e748b9
refs/heads/master
2016-08-03T20:58:47.005741
2012-12-16T08:25:49
2012-12-16T08:25:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,311
cpp
/* * File: main.cpp * Author: phoenix * * Created on October 26, 2012, 7:33 PM */ #include <QtGui/QApplication> //#include "FOREL.h" //#include "FOREL2.h" #include <fstream> #include <vector> #include <iomanip> //#include "Gustafson-Kessel.h" #include "mainwindow.h" void test() { Gkk* f = new Gkk("/home/phoenix/Study_&_books/Clasters/PatRec/data/lab1,2(clustering)/8"); /* f->set_memberships_byrandom(5, 500); for (int i=0; i<f->membership_matrix.size(); ++i) { for (int j=0; j<f->membership_matrix[i].size(); ++j) { cout<<f->membership_matrix[i][j]<<" "; } cout<<endl; }*/ vector<Claster*> cl; f->standartization(); cl = f->clustering(3, 0.0001, 2); for (int i=0; i<cl.size(); ++i) { cl[i]->show(); cout<<endl; } } int main(int argc, char *argv[]) { // initialize resources, if needed // Q_INIT_RESOURCE(resfile); // cout<<num_of_col("/home/phoenix/Study_&_books/Clasters/PatRec/data/lab1,2 (clustering)/11.txt"); srand(static_cast<unsigned>(time(NULL))); // test(); QApplication app(argc, argv); MainWindow* mainwindow = new MainWindow(); mainwindow->show(); // create and show your widgets here return app.exec(); // return 0; }
[ "dgoul11@gmail.com" ]
dgoul11@gmail.com
76e9e79249036126b4c6994b5e445d5cb4122cf9
13a6c77d8573f61c995ba810d2abe881a977ce36
/lc/27_removeElement.cpp
c5dc6f7b8b00852977a570544af8333a4f0f3abd
[]
no_license
kakachen4129/Cracking_the_code_interview
91242d4b786ef25dfcfaa10edd97173757564a7a
6da3348f41dbc951719a1d24f0ab60979d700aa2
refs/heads/master
2021-01-10T09:37:43.530674
2016-03-04T18:42:18
2016-03-04T18:42:18
48,786,541
0
0
null
null
null
null
UTF-8
C++
false
false
245
cpp
class Solution { public: int removeElement(int A[], int n, int elem) { int count = 0; for (int i = 0; i < n; i++){ if (A[i] != elem) A[count++] = A[i]; } return count; } };
[ "weichen@weideMacBook-Pro.local" ]
weichen@weideMacBook-Pro.local
f540fd378f7dbf0b917b60befe07d5d3193e9242
d599a171890a8f8aadee129fcfd6ed6e23dec791
/Gra_w_szachy/Project1/RealPlayer.h
cccef46036e29a56567c8488df6104e19c5dc466
[]
no_license
pawebas155/Cpp
4d5bf46acf4946ad638c68e375ac075ca281594e
180351398b542b66220b552bc345043a0980ae99
refs/heads/master
2020-04-01T11:23:22.971304
2018-10-22T22:19:56
2018-10-22T22:19:56
153,159,948
0
0
null
null
null
null
UTF-8
C++
false
false
1,200
h
#pragma once #include "Player.h" class RealPlayer : public Player { private: public: RealPlayer(int color, bool *tempIsCheck, bool *tempCheckMat, bool *tempWillBeCheck); list<MyPoint> *PlayerSpeculation(MyPoint point, vector<vector<MyAllPawns*>> Board, Moves * allMoves, int playerColor); bool PlayerChoose(MyPoint point, vector<vector<MyAllPawns*>> *Board, Moves * allMoves, MyPoint tempPawnPosition, vector<MyAllPawns*> * ArrayOfDeathPawn); void moveThePawn(MyPoint point, vector<vector<MyAllPawns*>> *Board, Moves * allMoves, MyPoint tempPawnPosition, bool writeMoveToList, vector<MyAllPawns*> * ArrayOfDeathPawn); void undoMove(vector<vector<MyAllPawns*>> *Board, Moves * allMoves, vector<MyAllPawns*> * ArrayOfDeathPawn); void setBoardPointsForPawns(); void setPointsForPawns(); void ComputerMove(vector<vector<MyAllPawns*>> *Board, Moves * allMoves, int TreeDepth, int tempColor, vector<MyAllPawns*> * ArrayOfDeathPawn); void MiniMax( vector<vector<MyAllPawns*>> *Board, Moves * allMoves, int TreeDepth, int tempColor, int *BoardValue, int ComputerPlayerColor, vector<MyAllPawns*> * ArrayOfDeathPawn); int countBoardPoints(vector<vector<MyAllPawns*>> *Board, int color); };
[ "pawebas155@student.polsl.pl" ]
pawebas155@student.polsl.pl
147a6cac55fcc9cf01aa997c0b6b057d9e7884a0
6e0d0b5e7086cbf8bf98b8262f1ae3a42679e8f8
/src/rpcwallet.cpp
b61c7744e7ee70347455b5440ebcf1c76afe2a26
[ "MIT" ]
permissive
Jasperu2/powercoin
75864aaffa748e00796e6deea3ed9ce93ca3e085
a2f2a3f85236e67d1e126bef7288705082bd1233
refs/heads/master
2021-01-18T06:39:06.919929
2016-05-17T15:59:57
2016-05-17T15:59:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
61,930
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "wallet.h" #include "walletdb.h" #include "powercoinrpc.h" #include "init.h" #include "base58.h" using namespace json_spirit; using namespace std; int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry); static void accountingDeprecationCheck() { if (!GetBoolArg("-enableaccounts", false)) throw runtime_error( "Accounting API is deprecated and will be removed in future.\n" "It can easily result in negative or odd balances if misused or misunderstood, which has happened in the field.\n" "If you still want to enable it, add to your config file enableaccounts=1\n"); if (GetBoolArg("-staking", true)) throw runtime_error("If you want to use accounting API, staking must be disabled, add to your config file staking=0\n"); } std::string HelpRequiringPassphrase() { return pwalletMain->IsCrypted() ? "\nrequires wallet passphrase to be set with walletpassphrase first" : ""; } void EnsureWalletIsUnlocked() { if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); if (fWalletUnlockStakingOnly) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Wallet is unlocked for staking only."); } void WalletTxToJSON(const CWalletTx& wtx, Object& entry) { int confirms = wtx.GetDepthInMainChain(); entry.push_back(Pair("confirmations", confirms)); if (wtx.IsCoinBase() || wtx.IsCoinStake()) entry.push_back(Pair("generated", true)); if (confirms > 0) { entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); entry.push_back(Pair("blockindex", wtx.nIndex)); entry.push_back(Pair("blocktime", (boost::int64_t)(mapBlockIndex[wtx.hashBlock]->nTime))); } entry.push_back(Pair("txid", wtx.GetHash().GetHex())); entry.push_back(Pair("time", (boost::int64_t)wtx.GetTxTime())); entry.push_back(Pair("timereceived", (boost::int64_t)wtx.nTimeReceived)); BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) entry.push_back(Pair(item.first, item.second)); } string AccountFromValue(const Value& value) { string strAccount = value.get_str(); if (strAccount == "*") throw JSONRPCError(RPC_WALLET_INVALID_ACCOUNT_NAME, "Invalid account name"); return strAccount; } Value getinfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getinfo\n" "Returns an object containing various state info."); proxyType proxy; GetProxy(NET_IPV4, proxy); Object obj, diff; obj.push_back(Pair("version", FormatFullVersion())); obj.push_back(Pair("protocolversion",(int)PROTOCOL_VERSION)); obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); obj.push_back(Pair("newmint", ValueFromAmount(pwalletMain->GetNewMint()))); obj.push_back(Pair("stake", ValueFromAmount(pwalletMain->GetStake()))); obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("timeoffset", (boost::int64_t)GetTimeOffset())); obj.push_back(Pair("moneysupply", ValueFromAmount(pindexBest->nMoneySupply))); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); obj.push_back(Pair("ip", addrSeenByPeer.ToStringIP())); diff.push_back(Pair("proof-of-work", GetDifficulty())); diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("difficulty", diff)); obj.push_back(Pair("testnet", fTestNet)); obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); obj.push_back(Pair("mininput", ValueFromAmount(nMinimumInputValue))); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } Value getnewpubkey(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getnewpubkey [account]\n" "Returns new public key for coinbase generation."); // Parse the account first so we don't generate a key if there's an error string strAccount; if (params.size() > 0) strAccount = AccountFromValue(params[0]); if (!pwalletMain->IsLocked()) pwalletMain->TopUpKeyPool(); // Generate a new key that is added to wallet CPubKey newKey; if (!pwalletMain->GetKeyFromPool(newKey, false)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); CKeyID keyID = newKey.GetID(); pwalletMain->SetAddressBookName(keyID, strAccount); vector<unsigned char> vchPubKey = newKey.Raw(); return HexStr(vchPubKey.begin(), vchPubKey.end()); } Value getnewaddress(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getnewaddress [account]\n" "Returns a new powercoin address for receiving payments. " "If [account] is specified (recommended), it is added to the address book " "so payments received with the address will be credited to [account]."); // Parse the account first so we don't generate a key if there's an error string strAccount; if (params.size() > 0) strAccount = AccountFromValue(params[0]); if (!pwalletMain->IsLocked()) pwalletMain->TopUpKeyPool(); // Generate a new key that is added to wallet CPubKey newKey; if (!pwalletMain->GetKeyFromPool(newKey, false)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); CKeyID keyID = newKey.GetID(); pwalletMain->SetAddressBookName(keyID, strAccount); return CpowercoinAddress(keyID).ToString(); } CpowercoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) { CWalletDB walletdb(pwalletMain->strWalletFile); CAccount account; walletdb.ReadAccount(strAccount, account); bool bKeyUsed = false; // Check if the current key has been used if (account.vchPubKey.IsValid()) { CScript scriptPubKey; scriptPubKey.SetDestination(account.vchPubKey.GetID()); for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end() && account.vchPubKey.IsValid(); ++it) { const CWalletTx& wtx = (*it).second; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if (txout.scriptPubKey == scriptPubKey) bKeyUsed = true; } } // Generate a new key if (!account.vchPubKey.IsValid() || bForceNew || bKeyUsed) { if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); pwalletMain->SetAddressBookName(account.vchPubKey.GetID(), strAccount); walletdb.WriteAccount(strAccount, account); } return CpowercoinAddress(account.vchPubKey.GetID()); } Value getaccountaddress(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "getaccountaddress <account>\n" "Returns the current powercoin address for receiving payments to this account."); // Parse the account first so we don't generate a key if there's an error string strAccount = AccountFromValue(params[0]); Value ret; ret = GetAccountAddress(strAccount).ToString(); return ret; } Value setaccount(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "setaccount <powercoinaddress> <account>\n" "Sets the account associated with the given address."); CpowercoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid powercoin address"); string strAccount; if (params.size() > 1) strAccount = AccountFromValue(params[1]); // Detect when changing the account of an address that is the 'unused current key' of another account: if (pwalletMain->mapAddressBook.count(address.Get())) { string strOldAccount = pwalletMain->mapAddressBook[address.Get()]; if (address == GetAccountAddress(strOldAccount)) GetAccountAddress(strOldAccount, true); } pwalletMain->SetAddressBookName(address.Get(), strAccount); return Value::null; } Value getaccount(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "getaccount <powercoinaddress>\n" "Returns the account associated with the given address."); CpowercoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid powercoin address"); string strAccount; map<CTxDestination, string>::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) strAccount = (*mi).second; return strAccount; } Value getaddressesbyaccount(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "getaddressesbyaccount <account>\n" "Returns the list of addresses for the given account."); string strAccount = AccountFromValue(params[0]); // Find all addresses that have the given account Array ret; BOOST_FOREACH(const PAIRTYPE(CpowercoinAddress, string)& item, pwalletMain->mapAddressBook) { const CpowercoinAddress& address = item.first; const string& strName = item.second; if (strName == strAccount) ret.push_back(address.ToString()); } return ret; } Value sendtoaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "sendtoaddress <powercoinaddress> <amount> [comment] [comment-to]\n" "<amount> is a real and is rounded to the nearest 0.000001" + HelpRequiringPassphrase()); CpowercoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid powercoin address"); // Amount int64_t nAmount = AmountFromValue(params[1]); // Wallet comments CWalletTx wtx; if (params.size() > 2 && params[2].type() != null_type && !params[2].get_str().empty()) wtx.mapValue["comment"] = params[2].get_str(); if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) wtx.mapValue["to"] = params[3].get_str(); if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); } Value listaddressgroupings(const Array& params, bool fHelp) { if (fHelp) throw runtime_error( "listaddressgroupings\n" "Lists groups of addresses which have had their common ownership\n" "made public by common use as inputs or as the resulting change\n" "in past transactions"); Array jsonGroupings; map<CTxDestination, int64_t> balances = pwalletMain->GetAddressBalances(); BOOST_FOREACH(set<CTxDestination> grouping, pwalletMain->GetAddressGroupings()) { Array jsonGrouping; BOOST_FOREACH(CTxDestination address, grouping) { Array addressInfo; addressInfo.push_back(CpowercoinAddress(address).ToString()); addressInfo.push_back(ValueFromAmount(balances[address])); { LOCK(pwalletMain->cs_wallet); if (pwalletMain->mapAddressBook.find(CpowercoinAddress(address).Get()) != pwalletMain->mapAddressBook.end()) addressInfo.push_back(pwalletMain->mapAddressBook.find(CpowercoinAddress(address).Get())->second); } jsonGrouping.push_back(addressInfo); } jsonGroupings.push_back(jsonGrouping); } return jsonGroupings; } Value signmessage(const Array& params, bool fHelp) { if (fHelp || params.size() != 2) throw runtime_error( "signmessage <powercoinaddress> <message>\n" "Sign a message with the private key of an address"); EnsureWalletIsUnlocked(); string strAddress = params[0].get_str(); string strMessage = params[1].get_str(); CpowercoinAddress addr(strAddress); if (!addr.IsValid()) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); CKeyID keyID; if (!addr.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); CKey key; if (!pwalletMain->GetKey(keyID, key)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); CDataStream ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; vector<unsigned char> vchSig; if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); return EncodeBase64(&vchSig[0], vchSig.size()); } Value verifymessage(const Array& params, bool fHelp) { if (fHelp || params.size() != 3) throw runtime_error( "verifymessage <powercoinaddress> <signature> <message>\n" "Verify a signed message"); string strAddress = params[0].get_str(); string strSign = params[1].get_str(); string strMessage = params[2].get_str(); CpowercoinAddress addr(strAddress); if (!addr.IsValid()) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); CKeyID keyID; if (!addr.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); bool fInvalid = false; vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid); if (fInvalid) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); CDataStream ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; CKey key; if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) return false; return (key.GetPubKey().GetID() == keyID); } Value getreceivedbyaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "getreceivedbyaddress <powercoinaddress> [minconf=1]\n" "Returns the total amount received by <powercoinaddress> in transactions with at least [minconf] confirmations."); // powercoin address CpowercoinAddress address = CpowercoinAddress(params[0].get_str()); CScript scriptPubKey; if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid powercoin address"); scriptPubKey.SetDestination(address.Get()); if (!IsMine(*pwalletMain,scriptPubKey)) return (double)0.0; // Minimum confirmations int nMinDepth = 1; if (params.size() > 1) nMinDepth = params[1].get_int(); // Tally int64_t nAmount = 0; for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal()) continue; BOOST_FOREACH(const CTxOut& txout, wtx.vout) if (txout.scriptPubKey == scriptPubKey) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; } return ValueFromAmount(nAmount); } void GetAccountAddresses(string strAccount, set<CTxDestination>& setAddress) { BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& item, pwalletMain->mapAddressBook) { const CTxDestination& address = item.first; const string& strName = item.second; if (strName == strAccount) setAddress.insert(address); } } Value getreceivedbyaccount(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "getreceivedbyaccount <account> [minconf=1]\n" "Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations."); accountingDeprecationCheck(); // Minimum confirmations int nMinDepth = 1; if (params.size() > 1) nMinDepth = params[1].get_int(); // Get the set of pub keys assigned to account string strAccount = AccountFromValue(params[0]); set<CTxDestination> setAddress; GetAccountAddresses(strAccount, setAddress); // Tally int64_t nAmount = 0; for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal()) continue; BOOST_FOREACH(const CTxOut& txout, wtx.vout) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address)) if (wtx.GetDepthInMainChain() >= nMinDepth) nAmount += txout.nValue; } } return (double)nAmount / (double)COIN; } int64_t GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth) { int64_t nBalance = 0; // Tally wallet transactions for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (!wtx.IsFinal() || wtx.GetDepthInMainChain() < 0) continue; int64_t nReceived, nSent, nFee; wtx.GetAccountAmounts(strAccount, nReceived, nSent, nFee); if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth && wtx.GetBlocksToMaturity() == 0) nBalance += nReceived; nBalance -= nSent + nFee; } // Tally internal accounting entries nBalance += walletdb.GetAccountCreditDebit(strAccount); return nBalance; } int64_t GetAccountBalance(const string& strAccount, int nMinDepth) { CWalletDB walletdb(pwalletMain->strWalletFile); return GetAccountBalance(walletdb, strAccount, nMinDepth); } Value getbalance(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "getbalance [account] [minconf=1]\n" "If [account] is not specified, returns the server's total available balance.\n" "If [account] is specified, returns the balance in the account."); if (params.size() == 0) return ValueFromAmount(pwalletMain->GetBalance()); int nMinDepth = 1; if (params.size() > 1) nMinDepth = params[1].get_int(); if (params[0].get_str() == "*") { // Calculate total balance a different way from GetBalance() // (GetBalance() sums up all unspent TxOuts) // getbalance and getbalance '*' 0 should return the same number. int64_t nBalance = 0; for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (!wtx.IsTrusted()) continue; int64_t allFee; string strSentAccount; list<pair<CTxDestination, int64_t> > listReceived; list<pair<CTxDestination, int64_t> > listSent; wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount); if (wtx.GetDepthInMainChain() >= nMinDepth && wtx.GetBlocksToMaturity() == 0) { BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listReceived) nBalance += r.second; } BOOST_FOREACH(const PAIRTYPE(CTxDestination,int64_t)& r, listSent) nBalance -= r.second; nBalance -= allFee; } return ValueFromAmount(nBalance); } accountingDeprecationCheck(); string strAccount = AccountFromValue(params[0]); int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); return ValueFromAmount(nBalance); } Value movecmd(const Array& params, bool fHelp) { if (fHelp || params.size() < 3 || params.size() > 5) throw runtime_error( "move <fromaccount> <toaccount> <amount> [minconf=1] [comment]\n" "Move from one account in your wallet to another."); accountingDeprecationCheck(); string strFrom = AccountFromValue(params[0]); string strTo = AccountFromValue(params[1]); int64_t nAmount = AmountFromValue(params[2]); if (params.size() > 3) // unused parameter, used to be nMinDepth, keep type-checking it though (void)params[3].get_int(); string strComment; if (params.size() > 4) strComment = params[4].get_str(); CWalletDB walletdb(pwalletMain->strWalletFile); if (!walletdb.TxnBegin()) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); int64_t nNow = GetAdjustedTime(); // Debit CAccountingEntry debit; debit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); debit.strAccount = strFrom; debit.nCreditDebit = -nAmount; debit.nTime = nNow; debit.strOtherAccount = strTo; debit.strComment = strComment; walletdb.WriteAccountingEntry(debit); // Credit CAccountingEntry credit; credit.nOrderPos = pwalletMain->IncOrderPosNext(&walletdb); credit.strAccount = strTo; credit.nCreditDebit = nAmount; credit.nTime = nNow; credit.strOtherAccount = strFrom; credit.strComment = strComment; walletdb.WriteAccountingEntry(credit); if (!walletdb.TxnCommit()) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); return true; } Value sendfrom(const Array& params, bool fHelp) { if (fHelp || params.size() < 3 || params.size() > 6) throw runtime_error( "sendfrom <fromaccount> <topowercoinaddress> <amount> [minconf=1] [comment] [comment-to]\n" "<amount> is a real and is rounded to the nearest 0.000001" + HelpRequiringPassphrase()); string strAccount = AccountFromValue(params[0]); CpowercoinAddress address(params[1].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid powercoin address"); int64_t nAmount = AmountFromValue(params[2]); int nMinDepth = 1; if (params.size() > 3) nMinDepth = params[3].get_int(); CWalletTx wtx; wtx.strFromAccount = strAccount; if (params.size() > 4 && params[4].type() != null_type && !params[4].get_str().empty()) wtx.mapValue["comment"] = params[4].get_str(); if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty()) wtx.mapValue["to"] = params[5].get_str(); EnsureWalletIsUnlocked(); // Check funds int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); if (nAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); // Send string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); } Value sendmany(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 4) throw runtime_error( "sendmany <fromaccount> {address:amount,...} [minconf=1] [comment]\n" "amounts are double-precision floating point numbers" + HelpRequiringPassphrase()); string strAccount = AccountFromValue(params[0]); Object sendTo = params[1].get_obj(); int nMinDepth = 1; if (params.size() > 2) nMinDepth = params[2].get_int(); CWalletTx wtx; wtx.strFromAccount = strAccount; if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) wtx.mapValue["comment"] = params[3].get_str(); set<CpowercoinAddress> setAddress; vector<pair<CScript, int64_t> > vecSend; int64_t totalAmount = 0; BOOST_FOREACH(const Pair& s, sendTo) { CpowercoinAddress address(s.name_); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid powercoin address: ")+s.name_); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+s.name_); setAddress.insert(address); CScript scriptPubKey; scriptPubKey.SetDestination(address.Get()); int64_t nAmount = AmountFromValue(s.value_); totalAmount += nAmount; vecSend.push_back(make_pair(scriptPubKey, nAmount)); } EnsureWalletIsUnlocked(); // Check funds int64_t nBalance = GetAccountBalance(strAccount, nMinDepth); if (totalAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); // Send CReserveKey keyChange(pwalletMain); int64_t nFeeRequired = 0; bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired); if (!fCreated) { if (totalAmount + nFeeRequired > pwalletMain->GetBalance()) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); throw JSONRPCError(RPC_WALLET_ERROR, "Transaction creation failed"); } if (!pwalletMain->CommitTransaction(wtx, keyChange)) throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed"); return wtx.GetHash().GetHex(); } Value addmultisigaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 3) { string msg = "addmultisigaddress <nrequired> <'[\"key\",\"key\"]'> [account]\n" "Add a nrequired-to-sign multisignature address to the wallet\"\n" "each key is a powercoin address or hex-encoded public key\n" "If [account] is specified, assign address to [account]."; throw runtime_error(msg); } int nRequired = params[0].get_int(); const Array& keys = params[1].get_array(); string strAccount; if (params.size() > 2) strAccount = AccountFromValue(params[2]); // Gather public keys if (nRequired < 1) throw runtime_error("a multisignature address must require at least one key to redeem"); if ((int)keys.size() < nRequired) throw runtime_error( strprintf("not enough keys supplied " "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired)); std::vector<CKey> pubkeys; pubkeys.resize(keys.size()); for (unsigned int i = 0; i < keys.size(); i++) { const std::string& ks = keys[i].get_str(); // Case 1: powercoin address and we have full public key: CpowercoinAddress address(ks); if (address.IsValid()) { CKeyID keyID; if (!address.GetKeyID(keyID)) throw runtime_error( strprintf("%s does not refer to a key",ks.c_str())); CPubKey vchPubKey; if (!pwalletMain->GetPubKey(keyID, vchPubKey)) throw runtime_error( strprintf("no full public key for address %s",ks.c_str())); if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey)) throw runtime_error(" Invalid public key: "+ks); } // Case 2: hex public key else if (IsHex(ks)) { CPubKey vchPubKey(ParseHex(ks)); if (!vchPubKey.IsValid() || !pubkeys[i].SetPubKey(vchPubKey)) throw runtime_error(" Invalid public key: "+ks); } else { throw runtime_error(" Invalid public key: "+ks); } } // Construct using pay-to-script-hash: CScript inner; inner.SetMultisig(nRequired, pubkeys); CScriptID innerID = inner.GetID(); pwalletMain->AddCScript(inner); pwalletMain->SetAddressBookName(innerID, strAccount); return CpowercoinAddress(innerID).ToString(); } Value addredeemscript(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) { string msg = "addredeemscript <redeemScript> [account]\n" "Add a P2SH address with a specified redeemScript to the wallet.\n" "If [account] is specified, assign address to [account]."; throw runtime_error(msg); } string strAccount; if (params.size() > 1) strAccount = AccountFromValue(params[1]); // Construct using pay-to-script-hash: vector<unsigned char> innerData = ParseHexV(params[0], "redeemScript"); CScript inner(innerData.begin(), innerData.end()); CScriptID innerID = inner.GetID(); pwalletMain->AddCScript(inner); pwalletMain->SetAddressBookName(innerID, strAccount); return CpowercoinAddress(innerID).ToString(); } struct tallyitem { int64_t nAmount; int nConf; tallyitem() { nAmount = 0; nConf = std::numeric_limits<int>::max(); } }; Value ListReceived(const Array& params, bool fByAccounts) { // Minimum confirmations int nMinDepth = 1; if (params.size() > 0) nMinDepth = params[0].get_int(); // Whether to include empty accounts bool fIncludeEmpty = false; if (params.size() > 1) fIncludeEmpty = params[1].get_bool(); // Tally map<CpowercoinAddress, tallyitem> mapTally; for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || wtx.IsCoinStake() || !wtx.IsFinal()) continue; int nDepth = wtx.GetDepthInMainChain(); if (nDepth < nMinDepth) continue; BOOST_FOREACH(const CTxOut& txout, wtx.vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address) || !IsMine(*pwalletMain, address)) continue; tallyitem& item = mapTally[address]; item.nAmount += txout.nValue; item.nConf = min(item.nConf, nDepth); } } // Reply Array ret; map<string, tallyitem> mapAccountTally; BOOST_FOREACH(const PAIRTYPE(CpowercoinAddress, string)& item, pwalletMain->mapAddressBook) { const CpowercoinAddress& address = item.first; const string& strAccount = item.second; map<CpowercoinAddress, tallyitem>::iterator it = mapTally.find(address); if (it == mapTally.end() && !fIncludeEmpty) continue; int64_t nAmount = 0; int nConf = std::numeric_limits<int>::max(); if (it != mapTally.end()) { nAmount = (*it).second.nAmount; nConf = (*it).second.nConf; } if (fByAccounts) { tallyitem& item = mapAccountTally[strAccount]; item.nAmount += nAmount; item.nConf = min(item.nConf, nConf); } else { Object obj; obj.push_back(Pair("address", address.ToString())); obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); ret.push_back(obj); } } if (fByAccounts) { for (map<string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it) { int64_t nAmount = (*it).second.nAmount; int nConf = (*it).second.nConf; Object obj; obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); ret.push_back(obj); } } return ret; } Value listreceivedbyaddress(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "listreceivedbyaddress [minconf=1] [includeempty=false]\n" "[minconf] is the minimum number of confirmations before payments are included.\n" "[includeempty] whether to include addresses that haven't received any payments.\n" "Returns an array of objects containing:\n" " \"address\" : receiving address\n" " \"account\" : the account of the receiving address\n" " \"amount\" : total amount received by the address\n" " \"confirmations\" : number of confirmations of the most recent transaction included"); return ListReceived(params, false); } Value listreceivedbyaccount(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "listreceivedbyaccount [minconf=1] [includeempty=false]\n" "[minconf] is the minimum number of confirmations before payments are included.\n" "[includeempty] whether to include accounts that haven't received any payments.\n" "Returns an array of objects containing:\n" " \"account\" : the account of the receiving addresses\n" " \"amount\" : total amount received by addresses with this account\n" " \"confirmations\" : number of confirmations of the most recent transaction included"); accountingDeprecationCheck(); return ListReceived(params, true); } static void MaybePushAddress(Object & entry, const CTxDestination &dest) { CpowercoinAddress addr; if (addr.Set(dest)) entry.push_back(Pair("address", addr.ToString())); } void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDepth, bool fLong, Array& ret) { int64_t nFee; string strSentAccount; list<pair<CTxDestination, int64_t> > listReceived; list<pair<CTxDestination, int64_t> > listSent; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); bool fAllAccounts = (strAccount == string("*")); // Sent if ((!wtx.IsCoinStake()) && (!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) { BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) { Object entry; entry.push_back(Pair("account", strSentAccount)); MaybePushAddress(entry, s.first); entry.push_back(Pair("category", "send")); entry.push_back(Pair("amount", ValueFromAmount(-s.second))); entry.push_back(Pair("fee", ValueFromAmount(-nFee))); if (fLong) WalletTxToJSON(wtx, entry); ret.push_back(entry); } } // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { bool stop = false; BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) { string account; if (pwalletMain->mapAddressBook.count(r.first)) account = pwalletMain->mapAddressBook[r.first]; if (fAllAccounts || (account == strAccount)) { Object entry; entry.push_back(Pair("account", account)); MaybePushAddress(entry, r.first); if (wtx.IsCoinBase() || wtx.IsCoinStake()) { if (wtx.GetDepthInMainChain() < 1) entry.push_back(Pair("category", "orphan")); else if (wtx.GetBlocksToMaturity() > 0) entry.push_back(Pair("category", "immature")); else entry.push_back(Pair("category", "generate")); } else { entry.push_back(Pair("category", "receive")); } if (!wtx.IsCoinStake()) entry.push_back(Pair("amount", ValueFromAmount(r.second))); else { entry.push_back(Pair("amount", ValueFromAmount(-nFee))); stop = true; // only one coinstake output } if (fLong) WalletTxToJSON(wtx, entry); ret.push_back(entry); } if (stop) break; } } } void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret) { bool fAllAccounts = (strAccount == string("*")); if (fAllAccounts || acentry.strAccount == strAccount) { Object entry; entry.push_back(Pair("account", acentry.strAccount)); entry.push_back(Pair("category", "move")); entry.push_back(Pair("time", (boost::int64_t)acentry.nTime)); entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit))); entry.push_back(Pair("otheraccount", acentry.strOtherAccount)); entry.push_back(Pair("comment", acentry.strComment)); ret.push_back(entry); } } Value listtransactions(const Array& params, bool fHelp) { if (fHelp || params.size() > 3) throw runtime_error( "listtransactions [account] [count=10] [from=0]\n" "Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]."); string strAccount = "*"; if (params.size() > 0) strAccount = params[0].get_str(); int nCount = 10; if (params.size() > 1) nCount = params[1].get_int(); int nFrom = 0; if (params.size() > 2) nFrom = params[2].get_int(); if (nCount < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count"); if (nFrom < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from"); Array ret; std::list<CAccountingEntry> acentries; CWallet::TxItems txOrdered = pwalletMain->OrderedTxItems(acentries, strAccount); // iterate backwards until we have nCount items to return: for (CWallet::TxItems::reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) ListTransactions(*pwtx, strAccount, 0, true, ret); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); if ((int)ret.size() >= (nCount+nFrom)) break; } // ret is newest to oldest if (nFrom > (int)ret.size()) nFrom = ret.size(); if ((nFrom + nCount) > (int)ret.size()) nCount = ret.size() - nFrom; Array::iterator first = ret.begin(); std::advance(first, nFrom); Array::iterator last = ret.begin(); std::advance(last, nFrom+nCount); if (last != ret.end()) ret.erase(last, ret.end()); if (first != ret.begin()) ret.erase(ret.begin(), first); std::reverse(ret.begin(), ret.end()); // Return oldest to newest return ret; } Value listaccounts(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "listaccounts [minconf=1]\n" "Returns Object that has account names as keys, account balances as values."); accountingDeprecationCheck(); int nMinDepth = 1; if (params.size() > 0) nMinDepth = params[0].get_int(); map<string, int64_t> mapAccountBalances; BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& entry, pwalletMain->mapAddressBook) { if (IsMine(*pwalletMain, entry.first)) // This address belongs to me mapAccountBalances[entry.second] = 0; } for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; int64_t nFee; string strSentAccount; list<pair<CTxDestination, int64_t> > listReceived; list<pair<CTxDestination, int64_t> > listSent; int nDepth = wtx.GetDepthInMainChain(); if (nDepth < 0) continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount); mapAccountBalances[strSentAccount] -= nFee; BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& s, listSent) mapAccountBalances[strSentAccount] -= s.second; if (nDepth >= nMinDepth && wtx.GetBlocksToMaturity() == 0) { BOOST_FOREACH(const PAIRTYPE(CTxDestination, int64_t)& r, listReceived) if (pwalletMain->mapAddressBook.count(r.first)) mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second; else mapAccountBalances[""] += r.second; } } list<CAccountingEntry> acentries; CWalletDB(pwalletMain->strWalletFile).ListAccountCreditDebit("*", acentries); BOOST_FOREACH(const CAccountingEntry& entry, acentries) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; Object ret; BOOST_FOREACH(const PAIRTYPE(string, int64_t)& accountBalance, mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; } Value listsinceblock(const Array& params, bool fHelp) { if (fHelp) throw runtime_error( "listsinceblock [blockhash] [target-confirmations]\n" "Get all transactions in blocks since block [blockhash], or all transactions if omitted"); CBlockIndex *pindex = NULL; int target_confirms = 1; if (params.size() > 0) { uint256 blockId = 0; blockId.SetHex(params[0].get_str()); pindex = CBlockLocator(blockId).GetBlockIndex(); } if (params.size() > 1) { target_confirms = params[1].get_int(); if (target_confirms < 1) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); } int depth = pindex ? (1 + nBestHeight - pindex->nHeight) : -1; Array transactions; for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) { CWalletTx tx = (*it).second; if (depth == -1 || tx.GetDepthInMainChain() < depth) ListTransactions(tx, "*", 0, true, transactions); } uint256 lastblock; if (target_confirms == 1) { lastblock = hashBestChain; } else { int target_height = pindexBest->nHeight + 1 - target_confirms; CBlockIndex *block; for (block = pindexBest; block && block->nHeight > target_height; block = block->pprev) { } lastblock = block ? block->GetBlockHash() : 0; } Object ret; ret.push_back(Pair("transactions", transactions)); ret.push_back(Pair("lastblock", lastblock.GetHex())); return ret; } Value gettransaction(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "gettransaction <txid>\n" "Get detailed information about <txid>"); uint256 hash; hash.SetHex(params[0].get_str()); Object entry; if (pwalletMain->mapWallet.count(hash)) { const CWalletTx& wtx = pwalletMain->mapWallet[hash]; TxToJSON(wtx, 0, entry); int64_t nCredit = wtx.GetCredit(); int64_t nDebit = wtx.GetDebit(); int64_t nNet = nCredit - nDebit; int64_t nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); if (wtx.IsFromMe()) entry.push_back(Pair("fee", ValueFromAmount(nFee))); WalletTxToJSON(wtx, entry); Array details; ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details); entry.push_back(Pair("details", details)); } else { CTransaction tx; uint256 hashBlock = 0; if (GetTransaction(hash, tx, hashBlock)) { TxToJSON(tx, 0, entry); if (hashBlock == 0) entry.push_back(Pair("confirmations", 0)); else { entry.push_back(Pair("blockhash", hashBlock.GetHex())); map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight)); else entry.push_back(Pair("confirmations", 0)); } } } else throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); } return entry; } Value backupwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "backupwallet <destination>\n" "Safely copies wallet.dat to destination, which can be a directory or a path with filename."); string strDest = params[0].get_str(); if (!BackupWallet(*pwalletMain, strDest)) throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); return Value::null; } Value keypoolrefill(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "keypoolrefill [new-size]\n" "Fills the keypool." + HelpRequiringPassphrase()); unsigned int nSize = max(GetArg("-keypool", 100), (int64_t)0); if (params.size() > 0) { if (params[0].get_int() < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size"); nSize = (unsigned int) params[0].get_int(); } EnsureWalletIsUnlocked(); pwalletMain->TopUpKeyPool(nSize); if (pwalletMain->GetKeyPoolSize() < nSize) throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); return Value::null; } void ThreadTopUpKeyPool(void* parg) { // Make this thread recognisable as the key-topping-up thread RenameThread("powercoin-key-top"); pwalletMain->TopUpKeyPool(); } void ThreadCleanWalletPassphrase(void* parg) { // Make this thread recognisable as the wallet relocking thread RenameThread("powercoin-lock-wa"); int64_t nMyWakeTime = GetTimeMillis() + *((int64_t*)parg) * 1000; ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); if (nWalletUnlockTime == 0) { nWalletUnlockTime = nMyWakeTime; do { if (nWalletUnlockTime==0) break; int64_t nToSleep = nWalletUnlockTime - GetTimeMillis(); if (nToSleep <= 0) break; LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); MilliSleep(nToSleep); ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime); } while(1); if (nWalletUnlockTime) { nWalletUnlockTime = 0; pwalletMain->Lock(); } } else { if (nWalletUnlockTime < nMyWakeTime) nWalletUnlockTime = nMyWakeTime; } LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime); delete (int64_t*)parg; } Value walletpassphrase(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() < 2 || params.size() > 3)) throw runtime_error( "walletpassphrase <passphrase> <timeout> [stakingonly]\n" "Stores the wallet decryption key in memory for <timeout> seconds.\n" "if [stakingonly] is true sending functions are disabled."); if (fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called."); if (!pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already unlocked, use walletlock first if need to change unlock settings."); // Note that the walletpassphrase is stored in params[0] which is not mlock()ed SecureString strWalletPass; strWalletPass.reserve(100); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make params[0] mlock()'d to begin with. strWalletPass = params[0].get_str().c_str(); if (strWalletPass.length() > 0) { if (!pwalletMain->Unlock(strWalletPass)) throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); } else throw runtime_error( "walletpassphrase <passphrase> <timeout>\n" "Stores the wallet decryption key in memory for <timeout> seconds."); NewThread(ThreadTopUpKeyPool, NULL); int64_t* pnSleepTime = new int64_t(params[1].get_int64()); NewThread(ThreadCleanWalletPassphrase, pnSleepTime); // powercoin: if user OS account compromised prevent trivial sendmoney commands if (params.size() > 2) fWalletUnlockStakingOnly = params[2].get_bool(); else fWalletUnlockStakingOnly = false; return Value::null; } Value walletpassphrasechange(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) throw runtime_error( "walletpassphrasechange <oldpassphrase> <newpassphrase>\n" "Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>."); if (fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string) // Alternately, find a way to make params[0] mlock()'d to begin with. SecureString strOldWalletPass; strOldWalletPass.reserve(100); strOldWalletPass = params[0].get_str().c_str(); SecureString strNewWalletPass; strNewWalletPass.reserve(100); strNewWalletPass = params[1].get_str().c_str(); if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1) throw runtime_error( "walletpassphrasechange <oldpassphrase> <newpassphrase>\n" "Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>."); if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); return Value::null; } Value walletlock(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) throw runtime_error( "walletlock\n" "Removes the wallet encryption key from memory, locking the wallet.\n" "After calling this method, you will need to call walletpassphrase again\n" "before being able to call any methods which require the wallet to be unlocked."); if (fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); { LOCK(cs_nWalletUnlockTime); pwalletMain->Lock(); nWalletUnlockTime = 0; } return Value::null; } Value encryptwallet(const Array& params, bool fHelp) { if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1)) throw runtime_error( "encryptwallet <passphrase>\n" "Encrypts the wallet with <passphrase>."); if (fHelp) return true; if (pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called."); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make params[0] mlock()'d to begin with. SecureString strWalletPass; strWalletPass.reserve(100); strWalletPass = params[0].get_str().c_str(); if (strWalletPass.length() < 1) throw runtime_error( "encryptwallet <passphrase>\n" "Encrypts the wallet with <passphrase>."); if (!pwalletMain->EncryptWallet(strWalletPass)) throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet."); // BDB seems to have a bad habit of writing old data into // slack space in .dat files; that is bad if the old data is // unencrypted private keys. So: StartShutdown(); return "wallet encrypted; powercoin server stopping, restart to run with encrypted wallet. The keypool has been flushed, you need to make a new backup."; } class DescribeAddressVisitor : public boost::static_visitor<Object> { public: Object operator()(const CNoDestination &dest) const { return Object(); } Object operator()(const CKeyID &keyID) const { Object obj; CPubKey vchPubKey; pwalletMain->GetPubKey(keyID, vchPubKey); obj.push_back(Pair("isscript", false)); obj.push_back(Pair("pubkey", HexStr(vchPubKey.Raw()))); obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); return obj; } Object operator()(const CScriptID &scriptID) const { Object obj; obj.push_back(Pair("isscript", true)); CScript subscript; pwalletMain->GetCScript(scriptID, subscript); std::vector<CTxDestination> addresses; txnouttype whichType; int nRequired; ExtractDestinations(subscript, whichType, addresses, nRequired); obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); Array a; BOOST_FOREACH(const CTxDestination& addr, addresses) a.push_back(CpowercoinAddress(addr).ToString()); obj.push_back(Pair("addresses", a)); if (whichType == TX_MULTISIG) obj.push_back(Pair("sigsrequired", nRequired)); return obj; } }; Value validateaddress(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "validateaddress <powercoinaddress>\n" "Return information about <powercoinaddress>."); CpowercoinAddress address(params[0].get_str()); bool isValid = address.IsValid(); Object ret; ret.push_back(Pair("isvalid", isValid)); if (isValid) { CTxDestination dest = address.Get(); string currentAddress = address.ToString(); ret.push_back(Pair("address", currentAddress)); bool fMine = IsMine(*pwalletMain, dest); ret.push_back(Pair("ismine", fMine)); if (fMine) { Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest); ret.insert(ret.end(), detail.begin(), detail.end()); } if (pwalletMain->mapAddressBook.count(dest)) ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest])); } return ret; } Value validatepubkey(const Array& params, bool fHelp) { if (fHelp || !params.size() || params.size() > 2) throw runtime_error( "validatepubkey <powercoinpubkey>\n" "Return information about <powercoinpubkey>."); std::vector<unsigned char> vchPubKey = ParseHex(params[0].get_str()); CPubKey pubKey(vchPubKey); bool isValid = pubKey.IsValid(); bool isCompressed = pubKey.IsCompressed(); CKeyID keyID = pubKey.GetID(); CpowercoinAddress address; address.Set(keyID); Object ret; ret.push_back(Pair("isvalid", isValid)); if (isValid) { CTxDestination dest = address.Get(); string currentAddress = address.ToString(); ret.push_back(Pair("address", currentAddress)); bool fMine = IsMine(*pwalletMain, dest); ret.push_back(Pair("ismine", fMine)); ret.push_back(Pair("iscompressed", isCompressed)); if (fMine) { Object detail = boost::apply_visitor(DescribeAddressVisitor(), dest); ret.insert(ret.end(), detail.begin(), detail.end()); } if (pwalletMain->mapAddressBook.count(dest)) ret.push_back(Pair("account", pwalletMain->mapAddressBook[dest])); } return ret; } // powercoin: reserve balance from being staked for network protection Value reservebalance(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "reservebalance [<reserve> [amount]]\n" "<reserve> is true or false to turn balance reserve on or off.\n" "<amount> is a real and rounded to cent.\n" "Set reserve amount not participating in network protection.\n" "If no parameters provided current setting is printed.\n"); if (params.size() > 0) { bool fReserve = params[0].get_bool(); if (fReserve) { if (params.size() == 1) throw runtime_error("must provide amount to reserve balance.\n"); int64_t nAmount = AmountFromValue(params[1]); nAmount = (nAmount / CENT) * CENT; // round to cent if (nAmount < 0) throw runtime_error("amount cannot be negative.\n"); nReserveBalance = nAmount; } else { if (params.size() > 1) throw runtime_error("cannot specify amount to turn off reserve.\n"); nReserveBalance = 0; } } Object result; result.push_back(Pair("reserve", (nReserveBalance > 0))); result.push_back(Pair("amount", ValueFromAmount(nReserveBalance))); return result; } // powercoin: check wallet integrity Value checkwallet(const Array& params, bool fHelp) { if (fHelp || params.size() > 0) throw runtime_error( "checkwallet\n" "Check wallet for integrity.\n"); int nMismatchSpent; int64_t nBalanceInQuestion; pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion, true); Object result; if (nMismatchSpent == 0) result.push_back(Pair("wallet check passed", true)); else { result.push_back(Pair("mismatched spent coins", nMismatchSpent)); result.push_back(Pair("amount in question", ValueFromAmount(nBalanceInQuestion))); } return result; } // powercoin: repair wallet Value repairwallet(const Array& params, bool fHelp) { if (fHelp || params.size() > 0) throw runtime_error( "repairwallet\n" "Repair wallet if checkwallet reports any problem.\n"); int nMismatchSpent; int64_t nBalanceInQuestion; pwalletMain->FixSpentCoins(nMismatchSpent, nBalanceInQuestion); Object result; if (nMismatchSpent == 0) result.push_back(Pair("wallet check passed", true)); else { result.push_back(Pair("mismatched spent coins", nMismatchSpent)); result.push_back(Pair("amount affected by repair", ValueFromAmount(nBalanceInQuestion))); } return result; } // Powercoin: resend unconfirmed wallet transactions Value resendtx(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "resendtx\n" "Re-send unconfirmed transactions.\n" ); ResendWalletTransactions(true); return Value::null; } // powercoin: make a public-private key pair Value makekeypair(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "makekeypair [prefix]\n" "Make a public/private key pair.\n" "[prefix] is optional preferred prefix for the public key.\n"); string strPrefix = ""; if (params.size() > 0) strPrefix = params[0].get_str(); CKey key; key.MakeNewKey(false); CPrivKey vchPrivKey = key.GetPrivKey(); Object result; result.push_back(Pair("PrivateKey", HexStr<CPrivKey::iterator>(vchPrivKey.begin(), vchPrivKey.end()))); result.push_back(Pair("PublicKey", HexStr(key.GetPubKey().Raw()))); return result; }
[ "you@example.com" ]
you@example.com
09c7f30bacc36b38b207c61ca249ab95c5002044
3a3b58b0161ae6ea298f9886716b03fb3e7cfc35
/src_203308508/src/string_pm_bf1/pm_brute1.cpp
a0422f4c74934e5acbcdaaffda0b7a3bd0e1d8c4
[]
no_license
tantantzp/datastructure
cc052c6434e9be051a273848342e6fcd11e129af
8d4ade4b6c91a8738d78e1442ff2fb534a814067
refs/heads/master
2021-01-01T17:16:41.662236
2015-07-04T08:25:29
2015-07-04T08:25:29
38,527,341
1
0
null
null
null
null
GB18030
C++
false
false
1,599
cpp
/****************************************************************************************** * Data Structures in C++ * ISBN: 7-302-26883-3 & 7-302-29652-2 * Junhui DENG, deng@tsinghua.edu.cn * Computer Science & Technology, Tsinghua University * Copyright (c) 2011. All rights reserved. ******************************************************************************************/ /*DSA*/#include <stdio.h> #include <string.h> /*DSA*/void showProgress(char*, char*, int, int); /****************************************************************************************** * Text : 0 1 2 . . . i-j . . . . i . . n-1 * ------------------------|-------------------|------------ * Pattern : 0 . . . . j . . * |-------------------| ******************************************************************************************/ int match(char* P, char* T) { //串匹配算法(Brute-force-1) size_t n = strlen(T), i = 0; //主串长度、当前接受比对字符的位置 size_t m = strlen(P), j = 0; //模式串长度、当前接受比对字符的位置 while (j < m && i < n) //自左向右逐个比对字符 /*DSA*/{ /*DSA*/showProgress(T, P, i - j, j); getchar(); if (T[i] == P[j]) //若匹配 { i ++; j ++; } //则转到下一对字符 else //否则 { i -= j - 1; j = 0; } //主串回退、模式串复位 /*DSA*/} return i - j; //如何通过返回值,判断匹配结果? }
[ "610082896@qq.com" ]
610082896@qq.com
d203a64471daa1b84a710bfa73510e998ea05f87
82af3f9280613cfb5ee16eb79de15ef7ce34ee3f
/Google Code Jam/2015/round_1C/brattleship/brattleship.cc
76bc5bf40063dde14478da28f915551fde491c2e
[]
no_license
wangkexue/Contests
1148ef9a2f142065ca9a85aa8e283069df4aebf3
ca7a872040dc4b8077c49693c5be806642f3c13b
refs/heads/master
2021-01-10T01:34:40.751346
2016-04-10T04:31:19
2016-04-10T04:31:19
55,879,854
0
0
null
null
null
null
UTF-8
C++
false
false
323
cc
#include <cstdio> #include <climits> #include <algorithm> using namespace std; int sol(int R, int C, int W) { return C / W * R + min(C % W, 1) + W - 1; } int main() { int T, R, C, W; int i; scanf("%d", &T); for (i = 1; i <= T; i++) { scanf("%d%d%d", &R, &C, &W); printf("Case #%d: %d\n", i, sol(R, C, W)); } }
[ "wang.mingwan@gmail.com" ]
wang.mingwan@gmail.com
8edc1d086a40f66fa5b086d44e9a18b494490e5e
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/chrome/browser/fast_checkout/fast_checkout_personal_data_helper.h
377ae36b7aa2a5bf87081181d835bcf606604749
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
1,736
h
// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_FAST_CHECKOUT_FAST_CHECKOUT_PERSONAL_DATA_HELPER_H_ #define CHROME_BROWSER_FAST_CHECKOUT_FAST_CHECKOUT_PERSONAL_DATA_HELPER_H_ #include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/data_model/credit_card.h" #include "components/autofill/core/browser/personal_data_manager.h" // Filters data from the personal data manager for Fast Checkout's purposes, // i.e. returns valid and complete profiles and credit cards. class FastCheckoutPersonalDataHelper { public: virtual ~FastCheckoutPersonalDataHelper() = default; FastCheckoutPersonalDataHelper(const FastCheckoutPersonalDataHelper&) = delete; FastCheckoutPersonalDataHelper& operator=( const FastCheckoutPersonalDataHelper&) = delete; // Returns profiles to suggest. virtual std::vector<autofill::AutofillProfile*> GetProfilesToSuggest() const = 0; // Returns credit cards to suggest that have a number. virtual std::vector<autofill::CreditCard*> GetCreditCardsToSuggest() const = 0; // Returns unexpired credit cards with valid number and name. virtual std::vector<autofill::CreditCard*> GetValidCreditCards() const = 0; // Returns profiles with name, address, country, email and phone number. virtual std::vector<autofill::AutofillProfile*> GetValidAddressProfiles() const = 0; // Returns the current profile's `PersonalDataManager` instance. virtual autofill::PersonalDataManager* GetPersonalDataManager() const = 0; protected: FastCheckoutPersonalDataHelper() = default; }; #endif
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
6bb1ee99fc1f5b8119844fbccf79cb36e32b1fab
7c97f137f7f5573ba392cd9dec6e8fdb7056d358
/main.cpp
668953f336610c01f1bed81ac77039eabd341257
[]
no_license
ran784388220/nlp_segmention
738c9f25bfe87fc57bd37e20b1f0f37d741a714b
7256c61d4a3dba56325f5554f85dfd58a47f19ff
refs/heads/master
2020-04-17T02:32:58.368593
2016-07-30T14:59:27
2016-07-30T14:59:27
null
0
0
null
null
null
null
GB18030
C++
false
false
4,268
cpp
#include "dic.h" # define MaxWordLength 10 // 最大词长为个字节(即个汉字) # define Separator " " // 词界标记 CDictionary WordDic; //初始化一个词典 //对字符串用最大匹配法(正向或逆向)处理 string SegmentSentence(string s1) { string s2 = ""; //用s2存放分词结果 while (!s1.empty()) { int len = (int)s1.length(); // 取输入串长度 if (len > MaxWordLength) // 如果输入串长度大于最大词长 { len = MaxWordLength; // 只在最大词长范围内进行处理 } //string w = s1.substr(0, len); // (正向用)将输入串左边等于最大词长长度串取出作为候选词 string w = s1.substr(s1.length() - len, len); //逆向用 int n = WordDic.FindWord(w); // 在词典中查找相应的词 while (len > 2 && n == 0) // 如果不是词 { len -= 2; // 从候选词右边减掉一个汉字,将剩下的部分作为候选词 //w = w.substr(0, len); //正向用 w = s1.substr(s1.length() - len, len); //逆向用 n = WordDic.FindWord(w); } //s2 += w + Separator; // (正向用)将匹配得到的词连同词界标记加到输出串末尾 w = w + Separator; // (逆向用) s2 = w + s2; // (逆向用) //s1 = s1.substr(w.length(), s1.length()); //(正向用)从s1-w处开始 s1 = s1.substr(0, s1.length() - len); // (逆向用) } return s2; } //对句子进行最大匹配法处理,包含对特殊字符的处理 string SegmentSentenceMM(string s1) { string s2 = ""; //用s2存放分词结果 int i; int dd; while (!s1.empty()) { unsigned char ch = (unsigned char)s1[0]; if (ch < 128) // 处理西文字符 { i = 1; dd = (int)s1.length(); while (i < dd && ((unsigned char)s1[i] < 128) && (s1[i] != 10) && (s1[i] != 13)) // s1[i]不能是换行符或回车符 { i++; } if ((ch != 32) && (ch != 10) && (ch != 13)) // 如果不是西文空格或换行或回车符 { s2 += s1.substr(0, i) + Separator; } else { //if (ch == 10 || ch == 13) // 如果是换行或回车符,将它拷贝给s2输出 if (ch == 10 || ch == 13 || ch == 32) //谢谢读者mces89的指正 { s2 += s1.substr(0, i); } } s1 = s1.substr(i, dd); continue; } else { if (ch < 176) // 中文标点等非汉字字符 { i = 0; dd = (int)s1.length(); while (i < dd && ((unsigned char)s1[i] < 176) && ((unsigned char)s1[i] >= 161)&& (!((unsigned char)s1[i] == 161 && ((unsigned char)s1[i + 1] >= 162 && (unsigned char)s1[i + 1] <= 168))) && (!((unsigned char)s1[i] == 161 && ((unsigned char)s1[i + 1] >= 171 && (unsigned char)s1[i + 1] <= 191))) && (!((unsigned char)s1[i] == 163 && ((unsigned char)s1[i + 1] == 172 || (unsigned char)s1[i + 1] == 161) || (unsigned char)s1[i + 1] == 168 || (unsigned char)s1[i + 1] == 169 || (unsigned char)s1[i + 1] == 186 || (unsigned char)s1[i + 1] == 187 || (unsigned char)s1[i + 1] == 191))) { i = i + 2; // 假定没有半个汉字 } if (i == 0) { i = i + 2; } if (!(ch == 161 && (unsigned char)s1[1] == 161)) // 不处理中文空格 { s2 += s1.substr(0, i) + Separator; // 其他的非汉字双字节字符可能连续输出 } s1 = s1.substr(i, dd); continue; } } // 以下处理汉字串 i = 2; dd = (int)s1.length(); while (i < dd && (unsigned char)s1[i] >= 176) { i += 2; } s2 += SegmentSentence(s1.substr(0, i)); s1 = s1.substr(i, dd); } return s2; } int main(int argc, char *argv[]) { string strtmp; //用于保存从语料库中读入的每一行 string line; //用于输出每一行的结果 ifstream infile(argv[1]); // 打开输入文件 if (!infile.is_open()) // 打开输入文件失败则退出程序 { cerr << "Unable to open input file: " << argv[1] << " -- bailing out!" << endl; exit(-1); } ofstream outfile1("SegmentResult.txt"); //确定输出文件 if (!outfile1.is_open()) { cerr << "Unable to open file:SegmentResult.txt" << "--bailing out!" << endl; exit(-1); } while (getline(infile, strtmp)) //读入语料库中的每一行并用最大匹配法处理 { line = strtmp; line = SegmentSentenceMM(line); // 调用分词函数进行分词处理 outfile1 << line << endl; // 将分词结果写入目标文件 } return 0; }
[ "583101017@qq.com" ]
583101017@qq.com
eb829d71abecf75e5baf90fb710dc00bbbe766b0
b615211e97b85df312947fed83c7d1cd68041551
/src/rpc/protocol.h
95135399b4955fc8dbca34a8911adb5f596dc447
[ "MIT" ]
permissive
coinstew/the420coin
d8b9aa580d86e465ed26558717c5c13cfa79b768
54adb228bf265414efd98a2d05cbe5b6b4a909ba
refs/heads/master
2020-03-10T13:52:37.922754
2018-04-14T12:33:48
2018-04-14T12:33:48
129,409,380
0
0
null
null
null
null
UTF-8
C++
false
false
4,541
h
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_RPCPROTOCOL_H #define BITCOIN_RPCPROTOCOL_H #include <list> #include <map> #include <stdint.h> #include <string> #include <boost/filesystem.hpp> #include <univalue.h> //! HTTP status codes enum HTTPStatusCode { HTTP_OK = 200, HTTP_BAD_REQUEST = 400, HTTP_UNAUTHORIZED = 401, HTTP_FORBIDDEN = 403, HTTP_NOT_FOUND = 404, HTTP_BAD_METHOD = 405, HTTP_INTERNAL_SERVER_ERROR = 500, HTTP_SERVICE_UNAVAILABLE = 503, }; //! The420Coin Core RPC error codes enum RPCErrorCode { //! Standard JSON-RPC 2.0 errors RPC_INVALID_REQUEST = -32600, RPC_METHOD_NOT_FOUND = -32601, RPC_INVALID_PARAMS = -32602, RPC_INTERNAL_ERROR = -32603, RPC_PARSE_ERROR = -32700, //! General application defined errors RPC_MISC_ERROR = -1, //! std::exception thrown in command handling RPC_FORBIDDEN_BY_SAFE_MODE = -2, //! Server is in safe mode, and command is not allowed in safe mode RPC_TYPE_ERROR = -3, //! Unexpected type was passed as parameter RPC_INVALID_ADDRESS_OR_KEY = -5, //! Invalid address or key RPC_OUT_OF_MEMORY = -7, //! Ran out of memory during operation RPC_INVALID_PARAMETER = -8, //! Invalid, missing or duplicate parameter RPC_DATABASE_ERROR = -20, //! Database error RPC_DESERIALIZATION_ERROR = -22, //! Error parsing or validating structure in raw format RPC_VERIFY_ERROR = -25, //! General error during transaction or block submission RPC_VERIFY_REJECTED = -26, //! Transaction or block was rejected by network rules RPC_VERIFY_ALREADY_IN_CHAIN = -27, //! Transaction already in chain RPC_IN_WARMUP = -28, //! Client still warming up //! Aliases for backward compatibility RPC_TRANSACTION_ERROR = RPC_VERIFY_ERROR, RPC_TRANSACTION_REJECTED = RPC_VERIFY_REJECTED, RPC_TRANSACTION_ALREADY_IN_CHAIN= RPC_VERIFY_ALREADY_IN_CHAIN, //! P2P client errors RPC_CLIENT_NOT_CONNECTED = -9, //! The420Coin Core is not connected RPC_CLIENT_IN_INITIAL_DOWNLOAD = -10, //! Still downloading initial blocks RPC_CLIENT_NODE_ALREADY_ADDED = -23, //! Node is already added RPC_CLIENT_NODE_NOT_ADDED = -24, //! Node has not been added before RPC_CLIENT_NODE_NOT_CONNECTED = -29, //! Node to disconnect not found in connected nodes RPC_CLIENT_INVALID_IP_OR_SUBNET = -30, //! Invalid IP/Subnet RPC_CLIENT_P2P_DISABLED = -31, //!< No valid connection manager instance found //! Wallet errors RPC_WALLET_ERROR = -4, //! Unspecified problem with wallet (key not found etc.) RPC_WALLET_INSUFFICIENT_FUNDS = -6, //! Not enough funds in wallet or account RPC_WALLET_INVALID_ACCOUNT_NAME = -11, //! Invalid account name RPC_WALLET_KEYPOOL_RAN_OUT = -12, //! Keypool ran out, call keypoolrefill first RPC_WALLET_UNLOCK_NEEDED = -13, //! Enter the wallet passphrase with walletpassphrase first RPC_WALLET_PASSPHRASE_INCORRECT = -14, //! The wallet passphrase entered was incorrect RPC_WALLET_WRONG_ENC_STATE = -15, //! Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.) RPC_WALLET_ENCRYPTION_FAILED = -16, //! Failed to encrypt the wallet RPC_WALLET_ALREADY_UNLOCKED = -17, //! Wallet is already unlocked }; std::string JSONRPCRequest(const std::string& strMethod, const UniValue& params, const UniValue& id); UniValue JSONRPCReplyObj(const UniValue& result, const UniValue& error, const UniValue& id); std::string JSONRPCReply(const UniValue& result, const UniValue& error, const UniValue& id); UniValue JSONRPCError(int code, const std::string& message); /** Get name of RPC authentication cookie file */ boost::filesystem::path GetAuthCookieFile(); /** Generate a new RPC authentication cookie and write it to disk */ bool GenerateAuthCookie(std::string *cookie_out); /** Read the RPC authentication cookie from disk */ bool GetAuthCookie(std::string *cookie_out); /** Delete RPC authentication cookie from disk */ void DeleteAuthCookie(); #endif // BITCOIN_RPCPROTOCOL_H
[ "info@coinstew.com" ]
info@coinstew.com
259a33c13ef8efffa9e18f9d2af22df72eeb2621
aaeedd36f90b8cae12bc07edbc5f99e08b573327
/04 Behavior Planner - Cost Functions/C++/Example/cost.cpp
673cc2757a7fa6d2f27c23ae773136d9beda45b2
[ "MIT" ]
permissive
cuevas1208/AI_notes
738dc0f7e5918edd54486b4cba15906d313f60a5
63f55c851cc5e147810137545d369cfb4a321436
refs/heads/master
2021-05-02T15:51:15.614324
2018-05-01T06:21:02
2018-05-01T06:21:02
120,703,860
0
0
null
null
null
null
UTF-8
C++
false
false
1,089
cpp
#include <functional> #include <iostream> #include "cost.h" #include "cmath" using namespace std; float goal_distance_cost(int goal_lane, int intended_lane, int final_lane, float distance_to_goal) { /* The cost increases with both the distance of intended lane from the goal and the distance of the final lane from the goal. The cost of being out of the goal lane also becomes larger as vehicle approaches the goal. */ int delta_d = 2.0*goal_lane - intended_lane - final_lane; float cost = 1 - exp(-(abs(delta_d)/ distance_to_goal)); return cost; } float inefficiency_cost(int target_speed, int intended_lane, int final_lane, vector<int> lane_speeds) { /* Cost becomes higher for trajectories with intended lane and final lane that have traffic slower than target_speed. */ float speed_intended = lane_speeds[intended_lane]; float speed_final = lane_speeds[final_lane]; float delta_d = 2.0*target_speed - speed_intended - speed_final; float cost = delta_d/target_speed; return cost; }
[ "cuevas1208@gmail.com" ]
cuevas1208@gmail.com
1be66543b4908e2a2d297ce5e282304eab016c06
4d317369bd7de599e0364e9097e50f381845e22c
/Contests/Educational Round 37/Programs/Tanks.cpp
bc30ed9b587503f8930d8722fdc37b7abdca2f34
[]
no_license
MathProgrammer/CodeForces
4865f0bad799c674ff9e6fde9a008b988af2aed0
e3483c1ac4a7c81662f6a0bc8af20be69e0c0a98
refs/heads/master
2023-04-07T11:27:31.766011
2023-04-01T06:29:19
2023-04-01T06:29:19
84,833,335
256
114
null
2021-10-02T21:14:47
2017-03-13T14:02:57
C++
UTF-8
C++
false
false
3,358
cpp
#include <iostream> #include <vector> using namespace std; long long ceil(long long n, long long r) { return (n/r) + (n%r != 0); } int main() { long long no_of_elements, capacity, total_volume; cin >> no_of_elements >> capacity >> total_volume; vector <long long> A(no_of_elements + 1); for(int i = 1; i <= no_of_elements; i++) { cin >> A[i]; } int sum = 0; for(int i = 1; i <= no_of_elements; i++) { sum += A[i]; } vector < vector <int> > reachable(no_of_elements + 1, vector <int> (capacity + 1, false)); reachable[0][0] = true; for(int i = 1; i <= no_of_elements; i++) { reachable[i][A[i]%capacity] = true; for(int m = 0; m < capacity; m++) { int new_m = (m + A[i])%capacity; if(reachable[i - 1][m]) { reachable[i][new_m] = true; reachable[i][m] = true; } } } if(sum < total_volume || !reachable[no_of_elements][total_volume%capacity]) { cout << "NO\n"; return 0; } cout << "YES\n"; vector <int> is_good(no_of_elements + 1, false); for(int i = no_of_elements, looking_for = total_volume%capacity; i >= 1; i--) { int remaining = (looking_for - A[i]%capacity + capacity)%capacity; if(reachable[i - 1][remaining]) { is_good[i] = true; looking_for = remaining; } if(looking_for == 0) { break; } } vector <int> good_set, bad_set; for(int i = 1; i <= no_of_elements; i++) { if(is_good[i]) { good_set.push_back(i); } else { bad_set.push_back(i); } } for(int i = 1; i < good_set.size(); i++) { if(A[good_set[i]] == 0) { continue; } cout << ceil(A[good_set[i]], capacity) << " " << good_set[i] << " " << good_set[0] << "\n"; A[good_set[0]] += A[good_set[i]]; A[good_set[i]] = 0; } if(good_set.size() > 0 && A[good_set[0]] > total_volume) { int other; if(good_set.size() >= 2) { other = good_set[1]; } else { other = bad_set[0]; } cout << (A[good_set[0]] - total_volume)/capacity << " " << good_set[0] << " " << other << "\n"; A[other] += (A[good_set[0]] - total_volume)/capacity; A[good_set[0]] = total_volume; } for(int i = 1; i < bad_set.size(); i++) { if(A[bad_set[i]] == 0) { continue; } cout << ceil(A[bad_set[i]], capacity) << " " << bad_set[i] << " " << bad_set[0] << "\n"; A[bad_set[0]] += A[bad_set[i]]; A[bad_set[i]] = 0; if(total_volume%capacity == 0) { good_set.push_back(bad_set[i]); } } if(A[good_set[0]] < total_volume) { int extra = total_volume - A[good_set[0]]; cout << ceil(extra,capacity) << " " << bad_set[0] << " " << good_set[0] << "\n"; A[good_set[0]] += extra; A[bad_set[0]] -= extra; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
9275cd6fe4ee648b7536abcc15346dc02010470a
f3e98577117f25566bbb18c8fba9e45235967410
/MicromouseNavigationTest/Utility.ino
5805aa33a963d6a664a8071df4461f35a11deea9
[]
no_license
NortheasternIEEE/Micromouse
e5fbe166b1e0483c9bcf5d7f19580cf7e2b3288f
7b4c2cd035f0fe74364cb6536488780b4a6cf2d6
refs/heads/master
2021-01-10T15:51:27.262132
2016-04-16T09:34:21
2016-04-16T09:34:21
51,794,771
3
0
null
2016-04-09T02:14:56
2016-02-16T00:01:39
Arduino
UTF-8
C++
false
false
5,949
ino
#include "Utility.h" void configureTimer(Tcc* timer, IRQn_Type irqn, uint16_t period) { //Start by initializing the clock that will drive the timer. REG_GCLK_CLKCTRL = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID_TCC0_TCC1) ; while ( GCLK->STATUS.bit.SYNCBUSY == 1 ); // Disable peripheral so that the timer can be configured. timer->CTRLA.reg &= ~TCC_CTRLA_ENABLE; while(timer->SYNCBUSY.bit.ENABLE == 1); //CONFIGURE FIELDS OF THE STRUCTURE------------------------------------------------------------------------ timer->CTRLA.reg |= TCC_CTRLA_PRESCALER_DIV256; //Set the prescaler timer->WAVE.reg |= TCC_WAVE_WAVEGEN_NFRQ; //Set wave form configuration while(timer->SYNCBUSY.bit.WAVE == 1); timer->PER.reg = period; //48MHz/256 = 187500Hz. We want 10ms intervals, so 187500*0.01s = 1875 ticks, -1 for interval between TOP and clearing while(timer->SYNCBUSY.bit.PER == 1); // INTERRUPT SELECTION ------------------------------------------------------------------------------------ timer->INTENSET.reg = 0; timer->INTENSET.bit.OVF = 1; // Enable InterruptVector NVIC_EnableIRQ(irqn); // Enable TC timer->CTRLA.reg |= TCC_CTRLA_ENABLE; while (timer->SYNCBUSY.bit.ENABLE == 1); // wait for sync } float floatMap(float x, float in_min, float in_max, float out_min, float out_max) { return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } void moveRobot(location *p, direction d) { switch (d) { case RIGHT: // MOVE THE MOUSE RIGHT // UPDATE ITS POSITION p->x = p->x + 1; if(getFrontDistance() <= TURN_BEGIN_THRESHOLD) { budge(); } turnAbsolute(90); while(isTurning()); setLeftMotorDirection(FORWARD); setRightMotorDirection(FORWARD); driveDistance(15.25, 0.565); //0.575 was changed -Charlie break; case LEFT: // MOVE THE MOUSE LEFT // UPDATE ITS POSITION p->x = p->x - 1; if(getFrontDistance() <= TURN_BEGIN_THRESHOLD) { budge(); } turnAbsolute(270); while(isTurning()); setLeftMotorDirection(FORWARD); setRightMotorDirection(FORWARD); driveDistance(15.25, 0.565); //0.575 was changed -Charlie break; case DOWN: // MOVE THE MOUSE DOWN // UPDATE ITS POSITION p->y = p->y - 1; if(getFrontDistance() <= TURN_BEGIN_THRESHOLD) { budge(); } turnAbsolute(180); while(isTurning()); setLeftMotorDirection(FORWARD); setRightMotorDirection(FORWARD); driveDistance(15.25, 0.565); //0.575 was changed -Charlie break; case UP: // MOVE THE MOUSE UP // UPDATE ITS POSITIONw p->y = p->y + 1; if(getFrontDistance() <= TURN_BEGIN_THRESHOLD) { budge(); } turnAbsolute(0); while(isTurning()); setLeftMotorDirection(FORWARD); setRightMotorDirection(FORWARD); driveDistance(15.25, 0.565); //0.575 was changed -Charlie break; case STOP: // DO NOTHING break; default: break; } } void initializeLoc(location *spot) { spot->x = 0; spot->y = 0; } void setLoc(location *spot, int x, int y) { spot->x = x; spot->y = y; } void initializeGraph(node param[mazeSize][mazeSize]) { for (int i = 0; i < mazeSize; i ++) { for (int j = 0; j < mazeSize; j++) { if (i == 0) { // IF i == 0 then you are on the left edge of the maze so the mouse can not move left param[i][j].left = false; } else { param[i][j].left = true; } if (i == mazeSize - 1){ // if i == mazeSize - 1 you are on the right edge so the mouse can not move right param[i][j].right = false; } else { param[i][j].right = true; } if (j == 0) { // If j == 0 then you are on the bottom edge so the mouse can not move down param[i][j].down = false; } else { param[i][j].down = true; } if (j == mazeSize -1) { // if j == mazeSize - 1 then you are on the top edge so the mouse can not move up param[i][j].up = false; } else { param[i][j].up = true; } param[i][j].mapped = false; param[i][j].parent = STOP; param[i][j].x = i; param[i][j].y = j; } } } direction goRight(node v) { if (v.right) { return RIGHT; } else { return STOP; } } direction goLeft(node v) { if (v.left) { return LEFT; } else { return STOP; } } direction goUp(node v) { if (v.up) { return UP; } else { return STOP; } } direction goDown(node v) { if (v.down) { return DOWN; } else { return STOP; } } direction reverse(direction d) { switch (d) { case RIGHT: return LEFT; break; case LEFT: return RIGHT; break; case DOWN: return UP; break; case UP: return DOWN; break; case STOP: return STOP; break; default: return STOP; break; } } void clearMapped(node param[mazeSize][mazeSize]) { for (int i = 0; i < mazeSize; i ++) { for (int j = 0; j < mazeSize; j++) { param[i][j].mapped = false; } } }
[ "billydk@optonline.net" ]
billydk@optonline.net
8f7216e295a5db529d7b2ce2d4bc20a658a53714
fe6360bf697243c6c318836a3c64a9c1984b610b
/deprecated/calc/colourPickerWidget.h
992bfa9e221d00c02210ffa2abcfac6d2050fa26
[]
no_license
davidmueller13/vexx
366cec96f4abac2e814176cd5d2ae75393561c0d
9194877951c78cd3fde3e7fbe6d511e40c24f8eb
refs/heads/master
2021-01-10T11:51:19.124071
2015-09-26T15:30:05
2015-09-26T15:30:05
43,210,604
0
0
null
null
null
null
UTF-8
C++
false
false
661
h
#ifndef COLOURPICKERWIDGET_H #define COLOURPICKERWIDGET_H #include "QWidget" #include "AProperty" namespace calcPropertyInfo { enum PropertyType { Colour = propertyInfo::UserType + 5, ColourNoAlpha = propertyInfo::UserType + 6 }; } class QToolButton; class AProperty; class colourPickerWidget : public QWidget { public: colourPickerWidget( AProperty * ); ~colourPickerWidget( ); void colourPicked( XColour, bool ); static QWidget *create( AProperty * ); private: QToolButton *_button; AProperty *_property; }; #endif // COLOURPICKERWIDGET_H
[ "jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9" ]
jorjpimm@e3525c50-fa1a-11de-8c8a-61c5e9addfc9
4b05002efc3fc2a99b2ebc6c6f70d2da8436877c
a6232c747080f3739caffa95c3f293e728ffed35
/ExtSDK/KSFT_API4CTP/CTP20120530/testmdapi/testmdapi.cpp
5c48904ac1ff7ac8ea2f4da348334b53fb35d4c9
[]
no_license
artu001/KSFT_API
ff3918dfa6dd48ab93c7763b40e4315384eea957
e2bc32795fb15b7034067a687d8eb9472bf214ad
refs/heads/KSFT_API4py接口
2021-01-17T15:50:00.809606
2013-12-30T06:30:28
2013-12-30T06:30:28
53,299,086
1
0
null
2016-03-07T05:47:12
2016-03-07T05:47:11
null
GB18030
C++
false
false
7,431
cpp
// testmdapi.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "stdio.h" #include "windows.h" #include "../CTP/ThostFtdcMdApi.h" #ifdef _DEBUG #pragma comment(lib, "../thostmduserapi/Debug/thostmduserapid.lib") #pragma message("Automatically linking with thostmduserapid.lib") #else #pragma comment(lib, "../thostmduserapi/Release/thostmduserapi.lib") #pragma message("Automatically linking with thostmduserapi.lib") #endif class CSampleHandler : public CThostFtdcMdSpi { public: // request id int m_nRequestID; public: // constructor,which need a valid pointer to a CThostFtdcMduserApi instance CSampleHandler(CThostFtdcMdApi *pUserApi) : m_pUserApi(pUserApi) {} ~CSampleHandler() {} // After making a succeed connection with the CTP server, the client should send the login request to the CTP server. virtual void OnFrontConnected() { printf("OnFrontConnected:\n"); CThostFtdcReqUserLoginField reqUserLogin = {0}; // set BrokerID strcpy(reqUserLogin. BrokerID, "6A89B428"); // set user id strcpy(reqUserLogin.UserID, "80002"); // set password strcpy(reqUserLogin.Password, "123456"); // send the login request m_pUserApi->ReqUserLogin(&reqUserLogin, m_nRequestID++ ); } //When the connection between client and the CTP server disconnected,the follwing function will be called. virtual void OnFrontDisconnected(int nReason) { // Inthis case, API willreconnect,the client application can ignore this. printf("OnFrontDisconnected.\n"); } // After receiving the login request from the client,the CTP server will send the following response to notify the client whether the login success or not. virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { printf("OnRspUserLogin:"); if (pRspUserLogin != NULL) { printf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%d|%d|%s|", pRspUserLogin->BrokerID, // 经纪公司代码 pRspUserLogin->UserID, // 用户代码 pRspUserLogin->TradingDay, // 交易日 pRspUserLogin->SystemName, // 交易系统名称 pRspUserLogin->LoginTime, // 登陆成功时间 pRspUserLogin->SHFETime, // 上期所时间 pRspUserLogin->DCETime, // 大商所时间 pRspUserLogin->CZCETime, // 郑商所时间 pRspUserLogin->FFEXTime, // 中金所时间 pRspUserLogin->FrontID, // frond id pRspUserLogin->SessionID, // session id pRspUserLogin->MaxOrderRef // 最大报单引用 ); } printf("\n"); printf("ErrorCode=[%d], ErrorMsg=[%s]\n", pRspInfo->ErrorID, pRspInfo->ErrorMsg); printf("RequestID=[%d], Chain=[%d]\n", nRequestID, bIsLast); // 行情订阅列表 char *ppInstrumentID[] = {"IF1303"}; // 行情订阅个数 int iInstrumentID = 1; // 订阅 m_pUserApi->SubscribeMarketData(ppInstrumentID, iInstrumentID); } ///RspSubMarketData return virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { printf("OnRspSubMarketData:%s\n", pSpecificInstrument->InstrumentID); printf("ErrorCode=[%d], ErrorMsg=[%s]\n", pRspInfo->ErrorID, pRspInfo->ErrorMsg); /* if (bIsLast == true) { // 行情退订列表 char *ppInstrumentID[] = {"CF1109"}; // 行情退订个数 int iInstrumentID = 1; m_pUserApi->UnSubscribeMarketData(ppInstrumentID,iInstrumentID); } */ } ///OnRspUnSubMarketData return virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { printf("OnRspUnSubMarketData:\n"); printf("ErrorCode=[%d], ErrorMsg=[%s]\n", pRspInfo->ErrorID, pRspInfo->ErrorMsg); // logout /* CThostFtdcUserLogoutField UserLogout; memset(&UserLogout, 0, sizeof(UserLogout)); // broker id strcpy(UserLogout.BrokerID, g_chBrokerID); // investor ID strcpy(UserLogout.UserID, g_chUserID); m_pUserApi->ReqUserLogout(&UserLogout,3); */ } ///OnRtnDepthMarketData virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) { printf("OnRtnDepthMarketData:"); if(pDepthMarketData != NULL) { printf("%s|%s|%.04f|%.04f|%.04f|%.04f|%.04f|%d|%.04f|%.04f|%.04f|%d|%d|%.04f|%.04f|%.04f|%.04f|%.04f|%s|%d|%.04f|%d|%.04f|%d|%.04f|%d|%.04f|%d|%.04f|%d|%.04f|%d|%.04f|%d|%.04f|", pDepthMarketData->ExchangeID, // 交易所代码 pDepthMarketData->InstrumentID, // 合约代码 pDepthMarketData->PreClosePrice, // 昨收盘 pDepthMarketData->OpenPrice, // 今开盘 pDepthMarketData->HighestPrice, // 最高价 pDepthMarketData->LowestPrice, // 最低价 pDepthMarketData->LastPrice, // 最新价 pDepthMarketData->Volume, // 数量 pDepthMarketData->Turnover, // 成交金额 pDepthMarketData->BidPrice1, // 申买价一 pDepthMarketData->AskPrice1, // 申卖价一 pDepthMarketData->BidVolume1, // 申买量一 pDepthMarketData->AskVolume1, // 申卖量一 pDepthMarketData->UpperLimitPrice, // 涨停板价 pDepthMarketData->LowerLimitPrice, // 跌停板价 pDepthMarketData->PreSettlementPrice, // 上次结算价 pDepthMarketData->SettlementPrice, // 本次结算价 pDepthMarketData->OpenInterest, // 持仓量 pDepthMarketData->TradingDay, // 交易日 pDepthMarketData->BidVolume2, // 申买量二 pDepthMarketData->BidPrice2, // 申买价二 pDepthMarketData->BidVolume3, // 申买量三 pDepthMarketData->BidPrice3, // 申买价三 pDepthMarketData->BidVolume4, // 申买量四 pDepthMarketData->BidPrice4, // 申买价四 pDepthMarketData->BidVolume5, // 申买量五 pDepthMarketData->BidPrice5, // 申买价五 pDepthMarketData->AskVolume2, // 申卖量二 pDepthMarketData->AskPrice2, // 申卖价二 pDepthMarketData->AskVolume3, // 申卖量三 pDepthMarketData->AskPrice3, // 申卖价三 pDepthMarketData->AskVolume4, // 申卖量四 pDepthMarketData->AskPrice4, // 申卖价四 pDepthMarketData->AskVolume5, // 申卖量五 pDepthMarketData->AskPrice5 // 申卖价五 ); } printf("\n"); } // logout return virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { printf("OnRspUserLogout:"); if (NULL != pUserLogout) { printf("%s\n",pUserLogout->UserID); } printf("ErrorCode=[%d], ErrorMsg=[%s]\n", pRspInfo->ErrorID, pRspInfo->ErrorMsg); printf("RequestID=[%d], Chain=[%d]\n", nRequestID, bIsLast); return; } private: // a pointer of CThostFtdcMduserApi instance CThostFtdcMdApi *m_pUserApi; }; int main(int argc, char* argv[]) { // create a CThostFtdcMdApi instance CThostFtdcMdApi *pUserApi = CThostFtdcMdApi::CreateFtdcMdApi(); CSampleHandler pSpi(pUserApi); // register an event handler instance pUserApi->RegisterSpi(&pSpi); pUserApi->RegisterFront("tcp://10.253.117.107:13153"); // make the connection between client and CTP server pUserApi->Init(); printf ("\npress return to release...\n"); getchar(); // release the API instance pUserApi->Release(); printf ("\npress return to quit...\n"); getchar(); return 0; }
[ "ksftapi@gmail.com" ]
ksftapi@gmail.com
c29a8162ea143001a9dc57a97c58dd23d6d8e425
53f5cf387ceffce3e737af8b12e77a8286988170
/GFG/Arrays/Sort-an-array-of-0s-1s-and-2s.cpp
3dd35243710529e20e3a10a03a92e51c7918ddf6
[]
no_license
Mudassir710/Daily-Coding-Practice
fe0b8264e7adbdbbf17f06ae418a61bdf95f78a3
ec2e8d0e7894c7b37e97e8fc7251aca3493983ef
refs/heads/master
2023-03-17T20:15:20.002090
2021-02-19T12:01:21
2021-02-19T12:01:21
281,991,117
0
0
null
null
null
null
UTF-8
C++
false
false
736
cpp
/* Mohammed Mudassir Mohiuddin Given an array A of size N containing 0s, 1s, and 2s; you need to sort the array in ascending order. */ #include<bits/stdc++.h> using namespace std; int main() { int tests; cin>>tests; while(tests--) { int num; cin>>num; //int arr[num]; int zero=0,one=0,two=0; for(int i=0;i<num;i++) { int inp; cin>>inp; if(inp == 0) zero++; else if(inp == 1) one++; else two++; } for(int i=0; i<zero; ++i) { cout<<"0 "; } for(int i=0; i<one; ++i) { cout<<"1 "; } for(int i=0; i<two; ++i) { cout<<"2 "; } cout<<"\n"; //cin>>arr[i]; } return 0; }
[ "mudassir.anas@gmail.com" ]
mudassir.anas@gmail.com
0045c8ecdbbe077618ac7f1f964f95e9955e82c9
b2db63c41a4ed21ff2e3a18252c47832499ca52a
/Quotables.ino
1e5494887675ad997df9b10607bf63e0e69e01ef
[]
no_license
WindyCityLab/Quotables-Yun-
b74b4c9943443ce59c890ed0cacc857c759774bd
80ce9f3adb0a352bee9bc08758a97ad87dcc8b9b
refs/heads/master
2021-01-17T04:59:13.447697
2015-04-16T22:26:05
2015-04-16T22:26:05
34,083,663
2
0
null
null
null
null
UTF-8
C++
false
false
3,878
ino
/********************* Example code for the Adafruit RGB Character LCD Shield and Library This code displays text on the shield, and also reads the buttons on the keypad. When a button is pressed, the backlight changes color. **********************/ // include the library code: #include <Wire.h> #include <Adafruit_MCP23017.h> #include <Adafruit_RGBLCDShield.h> // The shield uses the I2C SCL and SDA pins. On classic Arduinos // this is Analog 4 and 5 so you can't use those for analogRead() anymore // However, you can connect other I2C sensors to the I2C bus and share // the I2C bus. Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield(); // These #defines make it easy to set the backlight color #define RED 0x1 #define YELLOW 0x3 #define GREEN 0x2 #define TEAL 0x6 #define BLUE 0x4 #define VIOLET 0x5 #define WHITE 0x7 //PARSE STUFF #include <Parse.h> #include <Bridge.h> ParseClient client; void setup() { // Debugging output Serial.begin(9600); // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. We track how long it takes since // this library has been optimized a bit and we're proud of it :) // int time = millis(); lcd.print("Time for Quotes!"); // time = millis() - time; // Serial.print("Took "); Serial.print(time); Serial.println(" ms"); lcd.setBacklight(GREEN); while(!Serial); Serial.println("Before Parse setup"); parseSetup(); parseRetrieval(); } void parseSetup() { Serial.println("Parse setup"); // Initialize Bridge Bridge.begin(); // Initialize Parse client.begin("OL0i1OhDkRscie1SlaqRinQsn78CwY4gL1vThHaF", "vIuRlq40qlDDCYffI8yeTd7aixpQB4vGVnKYoBKu"); Serial.println("Parse setup complete"); } void parseRetrieval() { Serial.println("Begin Parse retrieval"); String quotesArray [] = {}; //Query for Quote objects ParseQuery query; query.setClassName("Quote"); query.whereNotEqualTo("text", "foo"); ParseResponse response = query.send(); int countOfResults = response.count(); Serial.println(countOfResults); // for(int i = 0; i < countOfResults; i++) // { //// Serial.println(i); // quotesArray[i] = response.getString("text"); // Serial.println(quotesArray[i]); // } // lcd.print(quotesArray[0]); int i = 0; while(response.nextObject()) { // Serial.println(response.getJSONBody()); // Serial.println(response.getString("text")); quotesArray[i] = response.getString("text"); Serial.println(quotesArray[i]); i++; } lcd.begin(16, 2); lcd.print(quotesArray[0]); response.close(); // Free the resource Serial.println("Close Parse retrieval"); } void displayItemsFromArray(String TheArray[]) { // int countOfArray = sizeof(TheArray); // Serial.println("Should print: "); Serial.print(TheArray[0]); // lcd.print(TheArray[0]); // for (int i = 0; i < countOfArray; i++) // { // TheArray[i] // } } void loop() { } //uint8_t i=0; //void loop() { // // set the cursor to column 0, line 1 // // (note: line 1 is the second row, since counting begins with 0): // lcd.setCursor(0, 1); // // print the number of seconds since reset: // lcd.print(millis()/1000); // // uint8_t buttons = lcd.readButtons(); // // if (buttons) { // lcd.clear(); // lcd.setCursor(0,0); // if (buttons & BUTTON_UP) { // lcd.print("UP "); // lcd.setBacklight(RED); // } // if (buttons & BUTTON_DOWN) { // lcd.print("DOWN "); // lcd.setBacklight(YELLOW); // } // if (buttons & BUTTON_LEFT) { // lcd.print("LEFT "); // lcd.setBacklight(GREEN); // } // if (buttons & BUTTON_RIGHT) { // lcd.print("RIGHT "); // lcd.setBacklight(TEAL); // } // if (buttons & BUTTON_SELECT) { // lcd.print("SELECT "); // lcd.setBacklight(VIOLET); // } // } //}
[ "vik.denic@gmail.com" ]
vik.denic@gmail.com
c135ffe6fac1b655b9dda4fd5ab83e8bcfe23825
f20e965e19b749e84281cb35baea6787f815f777
/Online/Online/ActiveMQ/src/activemq_test.cpp
370ee00b8a1812db14fd581929b5e7489c717b0a
[]
no_license
marromlam/lhcb-software
f677abc9c6a27aa82a9b68c062eab587e6883906
f3a80ecab090d9ec1b33e12b987d3d743884dc24
refs/heads/master
2020-12-23T15:26:01.606128
2016-04-08T15:48:59
2016-04-08T15:48:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,775
cpp
#include "CPP/Event.h" #include "CPP/Interactor.h" #include "ActiveMQ/Log.h" #include "ActiveMQ/ActiveMQSensor.h" #include <cstdlib> #include <cstring> #include <memory> namespace ActiveMQ { class AMQSensor; } using namespace std; using namespace ActiveMQ; namespace { struct AMQHandler : public Interactor { AMQHandler() {} virtual ~AMQHandler() {} virtual void handle(const Event& ev) { if ( ev.eventtype == NetEvent ) { const char* chan = ev.device; const char* body = ev.buffer_ptr; ActiveMQSensor* sens = (ActiveMQSensor*)ev.data; ::fprintf(stdout, "Response: %s %s\n",chan,body); if ( strstr(body,"quit") != 0 ) { sens->remove(this,0); ::fprintf(stdout, "Sending Disconnect."); int rc = sens->disconnect(); ::fprintf(stdout, "OK\n"); ::fprintf(stdout, "Disconnecting..."); rc = sens->disconnectServer(); ::fprintf(stdout, "OK\n"); sens->stop(); } } } }; } static void help() { ::printf(" test_amq_sensor or test_amq -option [-option]\n" \ " -c[onnection]=<name> AMQ connection string: failover:(tcp://ecs03.lbdaq.cern.ch:61616)\n" \ " -t[opic]=<name> Topic name.\n" \ " -d[ebug] Wait to attach debugger.\n" \ " -p[rint]=<value Set print level.\n"); } extern "C" int test_amq_sensor(int argc, char** argv) { int prt = LIB_RTL_DEBUG; RTL::CLI cli(argc,argv,help); string con = "failover:(tcp://ecs03.lbdaq.cern.ch:61616)"; string topic = "lbWeb.TEST"; cli.getopt("connection",1,con); cli.getopt("topic",1, topic); cli.getopt("print",1, prt); setbuf(stdout, NULL); install_printer(prt); if ( cli.getopt("debug",1) != 0 ) { #ifdef WIN32 _asm int 3 #else fprintf(stdout, "You got 10 seconds to connect a debugger...... pid: %d\n",::lib_rtl_pid()); ::lib_rtl_sleep(10000); #endif } std::auto_ptr<ActiveMQSensor> sensor(createSensor<AMQSensor>("myAMQ",con)); AMQHandler handler; sensor->start(); sensor->add(&handler,(void*)topic.c_str()); sensor->run(); fprintf(stdout, "All stopped. OK\n"); return 0; } extern "C" int test_amq(int argc, char** argv) { int rc, prt = LIB_RTL_DEBUG; RTL::CLI cli(argc,argv,help); string con = "failover:(tcp://ecs03.lbdaq.cern.ch:61616)"; string topic = "lbWeb.TEST"; cli.getopt("connection",1,con); cli.getopt("topic",1, topic); cli.getopt("print",1, prt); install_printer(prt); setbuf(stdout, NULL); if ( cli.getopt("debug",1) != 0 ) { #ifdef WIN32 _asm int 3 #else ::lib_rtl_output(LIB_RTL_INFO, "You got 10 seconds to connect a debugger...... pid: %d",::lib_rtl_pid()); ::lib_rtl_sleep(10000); #endif } std::auto_ptr<ActiveMQSensor> sensor(createSensor<AMQSensor>("myAMQ",con)); ::lib_rtl_output(LIB_RTL_INFO, "Connected"); ::lib_rtl_output(LIB_RTL_INFO, "Sending Messages."); for(int i=0; i<=20;++i) { char text[255], buf[12]; memset(buf,'a'+i%('z'-'a'),sizeof(buf)); buf[sizeof(buf)-1]=0; sprintf(text,"<message id=\"%s\" vid=\"%d\"><![CDATA[Message No.%d %s]]></message>",topic.c_str(),i,i,buf); //sprintf(text,"Message No.%d %s",i,buf); //sprintf(text,"<message><![CDATA[Message No.%d %s]]></message>",i,buf); if ( 1==sensor->send(topic, text) ) ::lib_rtl_output(LIB_RTL_INFO,"Sent message:%s",text); else ::lib_rtl_output(LIB_RTL_INFO,"FAILED to send message:%s",text); ::lib_rtl_sleep(200); } ::lib_rtl_output(LIB_RTL_INFO, "Sending Disconnect."); rc = sensor->disconnect(); ::lib_rtl_output(LIB_RTL_INFO, "Disconnecting..."); rc = sensor->disconnectServer(); ::lib_rtl_output(LIB_RTL_INFO, "Done.\n"); return 0; }
[ "frankb@cern.ch" ]
frankb@cern.ch
68347736ac283a69d58df3a517998ebaf2ca570d
71ac04a461f4f45599dda6d5cda7b8d4b624108c
/debug.h
71e00b9d9443a969e185450f550c0dd89088204c
[]
no_license
sonald/cjs
37d85a0eb6f3f86654e03b174736c0ae9dd9a00b
87de5ca3fc54773a60d4c5c4459dff504e2e88b0
refs/heads/master
2021-03-12T19:20:57.118970
2015-01-20T10:16:08
2015-01-20T10:16:08
29,241,323
5
0
null
null
null
null
UTF-8
C++
false
false
2,718
h
// 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. // // Copyright (C) Sian Cao <yinshuiboy@gmail.com>, 2015 #ifndef _CJS_DEBUG #define _CJS_DEBUG #include <iostream> #include <unordered_map> namespace cjs { using namespace std; class Logger { public: enum Domain { Tokenizer, Parser, TypeChecker, Env, Emitter, Stage, Backend, }; Logger(); template <class... Args> void error(Domain dom, const char* fmt, Args... args) { cerr << _domains[dom] << ": "; debug(fmt, args...); exit(-1); } template <class... Args> void debug(Domain dom, const char* fmt, Args... args) { if (!on(dom)) return; cerr << _domains[dom] << ": "; debug(fmt, args...); } private: template <class T, class... Args> void debug(const char* fmt, T arg, Args... args) { while (*fmt) { if (*fmt == '%') { cerr << arg; debug(fmt+1, args...); return; } cerr << *fmt; fmt++; } } void debug(const char* fmt) { cerr << fmt << endl; } bool on(Domain dom); private: unordered_map<Domain, string> _domains; unordered_map<string, bool> _enabled; }; #define DEF_DEBUG_FOR(domain) \ template <class... Args> \ static void debug(const char* fmt, Args... args) \ { log.debug(domain, fmt, args...); } #define DEF_ERROR_FOR(domain) \ template <class... Args> \ static void error(const char* fmt, Args... args) \ { log.error(domain, fmt, args...); } extern Logger log; }; #endif
[ "yinshuiboy@gmail.com" ]
yinshuiboy@gmail.com
189fcabcd302f3995530aa658cdae37c22f5f91a
42db63713c72c4e9349ca524961fa475c14463de
/similaridade/met2_AL_karlos/QR-K/main.cpp
4749160031db518e8f3a7b1ca2744e8e270290c9
[]
no_license
karlositalo/Numerical-Methods-II
db51abb2ad2ef35875590c7d87c54d7d4ae3217a
de561047bd234991996e262b42c7403b4fc89b8f
refs/heads/master
2021-09-05T17:35:45.258906
2018-01-30T02:48:18
2018-01-30T02:48:18
119,450,846
0
0
null
null
null
null
UTF-8
C++
false
false
1,700
cpp
#include<fstream> #include<iostream> #include "LibKarlos.h" int main(int argc, char *argv[]) { LibKarlos *f; f = new LibKarlos(); double **A, **T, e; int n; ifstream lermatrix, lerTolerancia; ofstream file; lermatrix.open("matrix.txt"); lerTolerancia.open("tolerancia.txt"); file.open("resultados.txt"); lermatrix >> n; lerTolerancia >> e; A = (double**)malloc(n*sizeof(double*)); for(int i=0;i<n;i++){ A[i] = (double*)calloc(n,sizeof(double)); for(int j=0; j<n; j++){ lermatrix >> A[i][j]; } } file<<"Metodo QR"<<endl; cout<<"Metodo QR"<<endl; cout<<"matrix Entrada: "<<endl; file<<"matrix Entrada: "<<endl; for(int i=0;i<n;i++){ cout<<"|"; file<<"|"; for(int j=0;j<n;j++){ cout<<A[i][j]<<" "; file<<A[i][j]<<" "; } cout<<"|"<<endl; file<<"|"<<endl; } T = f->QRmethod(A, e, n); cout<<"matrix Diagonal: "<<endl; file<<"matrix Diagonal: "<<endl; for(int i=0;i<n;i++){ cout<<"|"; file<<"|"; for(int j=0;j<n;j++){ cout<<T[i][j]<<" "; file<<T[i][j]<<" "; } cout<<"|"<<endl; file<<"|"<<endl; } double **J; J = f->getQ(); cout<<"matrix Q: "<<endl; file<<"matrix Q: "<<endl; for(int i=0;i<n;i++){ cout<<"|"; file<<"|"; for(int j=0;j<n;j++){ cout<<J[i][j]<<" "; file<<J[i][j]<<" "; } cout<<"|"<<endl; file<<"|"<<endl; } file.close(); cout<<"Gravado com sucesso em 'resultados.txt'"<<endl; return 0; }
[ "karlosinfbastos@gmail.com" ]
karlosinfbastos@gmail.com
aa0699e04ad51e1b8065633c2642a6b4e4fe4d74
9a40259e2fdf18f0e3071a79e2fa24b4b84f1b27
/Source/ProjectX/ProjectX.cpp
c46bbd3076d9a8f69d3528ca28d2e148fa0a1ce6
[]
no_license
xcmayday/ProjectX
a8d809fa56214014efb3e408c09cb780e3281a07
05c505f8467b7b69e320b359a6e1ec6d00f779a8
refs/heads/main
2023-03-19T21:29:37.438440
2021-03-11T12:48:53
2021-03-11T12:48:53
329,599,665
0
0
null
null
null
null
MacCentralEurope
C++
false
false
288
cpp
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. #include "ProjectX.h" #include "Modules/ModuleManager.h" #include "Logging/LogMacros.h" IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, ProjectX, "ProjectX" ); /*∂®“Ślog*/ //DEFINE_LOG_CATEGORY(LogActionRPG);
[ "xcmayday@users.noreply.github.com" ]
xcmayday@users.noreply.github.com
a3c7d83ad95501f29aa647532782e45a4e76e878
02e4fe454a368579278b49085ea0b6882f371909
/src/Vehicle.h
c0d59b58f8957f17e25f40f5674887e12ffeb89b
[]
no_license
miev88/V2V-Intersection-Communication
1c9a5064b934c1560bbd3bd45f0ab054b881c4ec
d2629a777b846353dcd7b45ece37540ac7aefc61
refs/heads/master
2020-12-09T10:51:10.816098
2020-01-12T18:08:51
2020-01-12T18:08:51
233,283,076
0
0
null
null
null
null
UTF-8
C++
false
false
1,226
h
#ifndef VEHICLE_H #define VEHICLE_H #include "TrafficObject.h" // forward declarations to avoid include cycle class Street; class Intersection; class Vehicle : public TrafficObject, public std::enable_shared_from_this<Vehicle> { public: // constructor Vehicle(size_t name); // getters / setters std::shared_ptr<Street> getCurrStreet() { return _currStreet; } std::shared_ptr<Intersection> getCurrDestination() { return _currDestination; } void setCurrentStreet(std::shared_ptr<Street> street) { _currStreet = street; }; void setCurrentDestination(std::shared_ptr<Intersection> destination); // typical behaviour methods void simulate(); // miscellaneous std::shared_ptr<Vehicle> get_shared_this() { return shared_from_this(); } protected: // typical behaviour methods virtual void drive() {}; std::shared_ptr<Street> _currStreet; // street on which the vehicle is currently on std::shared_ptr<Intersection> _currDestination; // destination to which the vehicle is currently driving double _posStreet; // position on current street double _speed; // ego speed in m/s }; #endif
[ "pariani.michele@gmx.de" ]
pariani.michele@gmx.de
09013a501d2304ea110e7be0ca1762d93b05747f
b8411d90424c8dbfdbf3d37b9705de68835bcc66
/0x00_first_steps/fileio.cpp
930db940b8d13769f6e425fa95035cbc27a64663
[ "MIT" ]
permissive
jepez90/Cpp
57d25ea3d783943a1ef9ce6fb25efe919a1ad69f
8c4bb0399c37f461720f5564d637f62fb038c481
refs/heads/main
2023-04-24T23:49:29.283614
2021-05-11T22:45:01
2021-05-11T22:45:01
364,061,410
0
0
null
null
null
null
UTF-8
C++
false
false
1,367
cpp
#include <iostream> //******* 1 - Include the <fstream> library #include <fstream> #include <string> using namespace std; int main () { string line; /******* 2 - Create a stream (input, output, both) app=append in this case * - ofstream myfile; (for writing to a file) * - ifstream myfile; (for reading a file) * - fstream myfile; (for reading and writing a file) */ /* - Open the file myfile.open(“filename”); */ ofstream myOutputFile("file.txt", ios::app); /* in this case the file is open when the stream is created */ if (myOutputFile.is_open()){ /*- Write or read the file*/ myOutputFile<<"this is a new line for the file\n"; myOutputFile<<"this is another new line for the file\n"; /*- Close the file myfile.close();*/ myOutputFile.close(); } else cout << "Unable to open file for writing"; //create an input stream to read the file ifstream myInputFile ("file.txt"); if (myInputFile.is_open()) { /*- Write or read the file*/ while ( getline(myInputFile, line)) { /*getline copy the line of the file to line */ cout << line << '\n'; } /*- Close the file myfile.close();*/ myInputFile.close(); } else cout << "Unable to open file for reading"; return 0; }
[ "ing.jersonperez@gmail.com" ]
ing.jersonperez@gmail.com
7cb255796af123c3818e7ad1041ae4c99b27c880
6632978c8096cf307a76c58b0c41cc4eeca5338e
/10062 - Tell me the frequencies!.cpp
090cee99e36d93e263d10cbc816d50259af62fc5
[]
no_license
bakernpp/Unsolved-All-OJ-Problems
9123ed340233947406d53333ae0396ac8000b4c2
bad19e2dca8cf6f27e75f43cface922abdecd56b
refs/heads/main
2023-08-04T00:59:30.688397
2021-09-21T05:09:52
2021-09-21T05:09:52
377,095,647
0
0
null
null
null
null
UTF-8
C++
false
false
496
cpp
#include<bits/stdc++.h> #include<cstdio> #include<cstring> using namespace std; int main(){ char word[100], ch, s[100]; int i, len, p, d; map<int,int> mp; while(gets(s)){ for(i = 0; s[i]!='\0'; i++){ d = s[i] - 0; mp[d]++; } for(auto it : mp){ cout << it.first << " " << it.second <<endl; } //cout << mp.size(); mp.clear(); cout << "\n\n"; } return 0; }
[ "noreply@github.com" ]
noreply@github.com
03ada2c97861a0b81fda734942f8580d3e8a7b06
62cfd24925fd9c17f78f6938ad90d549b57b3df4
/CPP_VM/lectures/G/Galdor.cpp
b1b990f33e4d79a56a17a70c55cbfd2c8ab79ac5
[]
no_license
Username1337/CPP
5f7dcd3a79f11f3f26544ac33aca819a096d9749
78d2298c999898eb321c797a7e1046952983dced
refs/heads/master
2020-06-26T00:49:50.018353
2017-07-12T11:15:16
2017-07-12T11:15:16
96,999,538
0
0
null
2017-07-12T11:20:00
2017-07-12T11:20:00
null
UTF-8
C++
false
false
1,563
cpp
#include <iostream> #include <vector> using namespace std; class Complex { private: double x; double y; public: Complex(): x(0), y(0){ } Complex(double x, double y): x(x), y(y){ } Complex(const Complex& c): x(c.x), y(c.y){ } friend ostream& operator<<(ostream& os, const Complex& c){ // 5 + 3*i if(c.y<0){ os << c.x << " - " << -1*c.y << "*i"; } else { os << c.x << " + " << c.y << "*i"; } return os; } Complex& operator+=(const Complex& c){ this->x += c.x; this->y += c.y; return *this; } friend Complex operator+(const Complex& a, const Complex& b){ Complex out(a); out+=b; return out; } Complex& operator-=(const Complex& c){ this->x -= c.x; this->y -= c.y; return *this; } friend Complex operator-(const Complex& a, const Complex& b){ Complex out(a); out-=b; return out; } Complex& operator*=(const Complex& c){ //TODO //(x1*x2-y1*y2) + (x1*y2 + x2*y1)*i //(x1*x2 - y1*y2) this->x = (this->x * c.x) + (this->y * c.y); //(x1*y2 + x2*y1) this->y = (this->x * c.y) + (c.x * this->y); return *this; } friend Complex operator*(const Complex& a, const Complex& b){ Complex out(a); out*=b; return out; } void konjugiere(){ this->y = -1*this->y; } }; int main(){ Complex a(1,-2); Complex b(-2,2); cout << "a = " << a << endl; cout << "b = " << b << endl; Complex c; c = a+b; cout << "a+b = " << c << endl; c = a-b; cout << "a-b = " << c << endl; c = a*b; cout << "a*b = " << c << endl; return 0; }
[ "marcoschlicht@onlinehome.de" ]
marcoschlicht@onlinehome.de
5572cf3f98147e22a91a69a7fa91854e2fa4da0d
862b99ca55bd20d28d08d64436270c402da21905
/depends/ogre_v1_7/ogre/OgreMain/include/OgrePrefabFactory.h
9949c0157f8e57898a745164cbbd621836930c21
[ "MIT" ]
permissive
Olganix/LibXenoverse2
5dbe669a21cccb95e46af0f59e1f23cb91a8d8d2
b398e34196e48705619d2681ec02c4b219b948e4
refs/heads/master
2022-06-11T08:53:21.235816
2020-07-17T13:41:07
2020-07-17T13:41:07
94,200,397
7
7
null
2022-05-25T23:38:03
2017-06-13T10:22:23
C++
UTF-8
C++
false
false
2,486
h
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2009 Torus Knot Software Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #ifndef __PrefabFactory_H__ #define __PrefabFactory_H__ #include "OgrePrerequisites.h" namespace Ogre { /** \addtogroup Core * @{ */ /** \addtogroup Resources * @{ */ /** A factory class that can create various mesh prefabs. @remarks This class is used by OgreMeshManager to offload the loading of various prefab types to a central location. */ class _OgreExport PrefabFactory { public: /** If the given mesh has a known prefab resource name (e.g "Prefab_Plane") then this prefab will be created as a submesh of the given mesh. @param mesh The mesh that the potential prefab will be created in. @returns true if a prefab has been created, otherwise false. */ static bool createPrefab(Mesh* mesh); private: /// Creates a plane as a submesh of the given mesh static void createPlane(Mesh* mesh); /// Creates a 100x100x100 cube as a submesh of the given mesh static void createCube(Mesh* mesh); /// Creates a sphere with a diameter of 100 units as a submesh of the given mesh static void createSphere(Mesh* mesh); }; /** @} */ /** @} */ } // namespace Ogre #endif
[ "Olganix@hotmail.fr" ]
Olganix@hotmail.fr
144325086c645a3d0800bd238a296c6aa086c2ae
865c9133d44211f8cc35f43b32327df5bbb43f02
/DFS.cpp
6a78fc19e5ee48eb50efc7d2f4edce05c072168e
[]
no_license
Worldeditory/baek_solve
d4ca6d875e218d081e3586f837f6989425cb48b8
7a0a38c598bd29151f7c5f493c5a3a08ac5e3183
refs/heads/master
2022-05-01T13:11:35.774888
2022-03-16T10:59:04
2022-03-16T10:59:04
236,423,132
0
0
null
null
null
null
UTF-8
C++
false
false
764
cpp
#include<iostream> #include<algorithm> #include<map> #include<unordered_map> #include<vector> #include<string> using namespace std; int N, ans; string S; int cal(int a, int b, char X){ if(X == '+'){ return a+b; } else if(X == '-'){ return a-b; } else { return a*b; } } void recur(int idx, int now){ if(idx > N-1){ ans = max(ans,now); return; } char oper = (idx == 0) ? '+' : S[idx - 1]; if(idx+2 < N){ int bracket = cal(S[idx] - '0', S[idx+2] - '0' , S[idx + 1]); recur(idx+4 , cal(now, bracket, oper)); } recur(idx + 2, cal(now, S[idx] - '0', oper)); } int main(){ cin >> N; cin >> S; ans = INT_MIN; recur(0,0); cout << ans; return 0; }
[ "shh9904@gmail.com" ]
shh9904@gmail.com
5e624916e96b38eeeb18cea835088b58e38c14b3
641d47e130b249a5412c1e84a4013d3e22d41cfd
/1188.cpp
3b58b612714568888996b2a4cc0b1b61bd1429ec
[]
no_license
nafiamahjabin/LightOJ-Solutions
b4d817ca6df87098d87a0519fd3216657b63735b
e9b73475a73a3f85274120c1be729e67a946a06d
refs/heads/master
2020-09-25T01:29:11.804477
2019-12-04T15:04:34
2019-12-04T15:04:34
225,889,052
0
0
null
null
null
null
UTF-8
C++
false
false
1,544
cpp
#include<bits/stdc++.h> using namespace std; #define sz 1000010 struct query { int l, r, no; }q[sz]; int f[sz], arr[sz], ans[sz],cnt, block; bool cmp(query a, query b) { int x=a.l/block; int y=b.l/block; if(x!=y) return x<y; else return a.r<b.r; } void del(int index) { f[arr[index]]--; if(!f[arr[index]]) cnt--; } void add(int index) { if(!f[arr[index]])cnt++; f[arr[index]]++; } int main() { int t,cs=1; scanf("%d", &t); while(t--) { int n,i, que; memset(f,0,sizeof(f)); memset(q,0,sizeof(q)); memset(arr,0,sizeof(arr)); scanf("%d%d", &n, &que); block=1000; for(i=1; i<=n; i++) { scanf("%d", &arr[i]); } for(i=1; i<=que; i++) { scanf("%d%d", &q[i].l, &q[i].r); q[i].no=i; } sort(q+1,q+que+1, cmp); int s=1; int e=0; cnt=0; for(i=1; i<=que; i++) { int x=q[i].l, y=q[i].r; while(s<x) { del(s); s++; } while(s>x) { s--; add(s); } while(e>y) { del(e); e--; } while(e<y) { e++; add(e); } ans[q[i].no]=cnt; } printf("Case %d:\n", cs++); for(i=1; i<=que; i++) printf("%d\n", ans[i]); } }
[ "mahjabinnafia@gmail.com" ]
mahjabinnafia@gmail.com
979e6342c1edfed4a79717b3e67e899f50173337
dfb83f9e1d2a64e719c3d61004b25650f372f5a2
/src/compiler/lowering-builder.cc
a8838d4cfc06db620921263bcd33a5c555b3b414
[]
no_license
kingland/v8-MinGW
8ae0a89ebe9ad022bd88612f7e38398cfd50287e
83c03915b0005faf60a517b7fe1938c08dd44d18
refs/heads/master
2021-01-10T08:27:14.667611
2015-10-01T04:17:59
2015-10-01T04:17:59
43,477,682
0
0
null
null
null
null
UTF-8
C++
false
false
1,233
cc
// Copyright 2014 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "compiler/graph-inl.h" #include "compiler/lowering-builder.h" #include "compiler/node-aux-data-inl.h" #include "compiler/node-properties-inl.h" namespace v8 { namespace internal { namespace compiler { class LoweringBuilder::NodeVisitor : public NullNodeVisitor { public: explicit NodeVisitor(LoweringBuilder* lowering) : lowering_(lowering) {} GenericGraphVisit::Control Post(Node* node) { if (lowering_->source_positions_ != NULL) { SourcePositionTable::Scope pos(lowering_->source_positions_, node); lowering_->Lower(node); } else { lowering_->Lower(node); } return GenericGraphVisit::CONTINUE; } private: LoweringBuilder* lowering_; }; LoweringBuilder::LoweringBuilder(Graph* graph, SourcePositionTable* source_positions) : graph_(graph), source_positions_(source_positions) {} void LoweringBuilder::LowerAllNodes() { NodeVisitor visitor(this); graph()->VisitNodeInputsFromEnd(&visitor); } } // namespace compiler } // namespace internal } // namespace v8
[ "sarayu.noo@gmail.com" ]
sarayu.noo@gmail.com
47cfce3dbdb16cbd4b2277150bbf2d76d485ce9d
0b44ffbc42887ae852f208ef5d9d59269c3a2740
/rocsolver/library/src/lapack/roclapack_getrs_strided_batched.cpp
851c80e5b184dfa115c5a53eb99a6b53f1536ba8
[ "BSD-2-Clause" ]
permissive
LuckyBoyDE/rocSOLVER
0278c57e52724ebae4ba7886185eff0393391a50
6431459ce3f68b5a4c14b28b4ec35c25d664f0bc
refs/heads/develop
2023-01-03T03:14:44.647845
2020-10-17T10:46:38
2020-10-17T10:46:38
304,855,150
0
0
BSD-2-Clause
2020-10-17T10:46:39
2020-10-17T10:44:29
null
UTF-8
C++
false
false
8,160
cpp
/* ************************************************************************ * Copyright (c) 2019-2020 Advanced Micro Devices, Inc. * ************************************************************************ */ #include "roclapack_getrs.hpp" template <typename T, typename U> rocblas_status rocsolver_getrs_strided_batched_impl(rocblas_handle handle, const rocblas_operation trans, const rocblas_int n, const rocblas_int nrhs, U A, const rocblas_int lda, const rocblas_stride strideA, const rocblas_int* ipiv, const rocblas_stride strideP, U B, const rocblas_int ldb, const rocblas_stride strideB, const rocblas_int batch_count) { if(!handle) return rocblas_status_invalid_handle; // logging is missing ??? // argument checking rocblas_status st = rocsolver_getrs_argCheck(trans, n, nrhs, lda, ldb, A, B, ipiv, batch_count); if(st != rocblas_status_continue) return st; // working with unshifted arrays rocblas_int shiftA = 0; rocblas_int shiftB = 0; // memory workspace sizes: // size of workspace (for calling TRSM) size_t size_work1, size_work2, size_work3, size_work4; rocsolver_getrs_getMemorySize<false, T>(n, nrhs, batch_count, &size_work1, &size_work2, &size_work3, &size_work4); if(rocblas_is_device_memory_size_query(handle)) return rocblas_set_optimal_device_memory_size(handle, size_work1, size_work2, size_work3, size_work4); // always allocate all required memory for TRSM optimal performance bool optim_mem = true; // memory workspace allocation void *work1, *work2, *work3, *work4; rocblas_device_malloc mem(handle, size_work1, size_work2, size_work3, size_work4); if(!mem) return rocblas_status_memory_error; work1 = mem[0]; work2 = mem[1]; work3 = mem[2]; work4 = mem[3]; // execution return rocsolver_getrs_template<false, T>(handle, trans, n, nrhs, A, shiftA, lda, strideA, ipiv, strideP, B, shiftB, ldb, strideB, batch_count, work1, work2, work3, work4, optim_mem); } /* * =========================================================================== * C wrapper * =========================================================================== */ extern "C" rocblas_status rocsolver_sgetrs_strided_batched(rocblas_handle handle, const rocblas_operation trans, const rocblas_int n, const rocblas_int nrhs, float* A, const rocblas_int lda, const rocblas_stride strideA, const rocblas_int* ipiv, const rocblas_stride strideP, float* B, const rocblas_int ldb, const rocblas_stride strideB, const rocblas_int batch_count) { return rocsolver_getrs_strided_batched_impl<float>(handle, trans, n, nrhs, A, lda, strideA, ipiv, strideP, B, ldb, strideB, batch_count); } extern "C" rocblas_status rocsolver_dgetrs_strided_batched(rocblas_handle handle, const rocblas_operation trans, const rocblas_int n, const rocblas_int nrhs, double* A, const rocblas_int lda, const rocblas_stride strideA, const rocblas_int* ipiv, const rocblas_stride strideP, double* B, const rocblas_int ldb, const rocblas_stride strideB, const rocblas_int batch_count) { return rocsolver_getrs_strided_batched_impl<double>(handle, trans, n, nrhs, A, lda, strideA, ipiv, strideP, B, ldb, strideB, batch_count); } extern "C" rocblas_status rocsolver_cgetrs_strided_batched(rocblas_handle handle, const rocblas_operation trans, const rocblas_int n, const rocblas_int nrhs, rocblas_float_complex* A, const rocblas_int lda, const rocblas_stride strideA, const rocblas_int* ipiv, const rocblas_stride strideP, rocblas_float_complex* B, const rocblas_int ldb, const rocblas_stride strideB, const rocblas_int batch_count) { return rocsolver_getrs_strided_batched_impl<rocblas_float_complex>( handle, trans, n, nrhs, A, lda, strideA, ipiv, strideP, B, ldb, strideB, batch_count); } extern "C" rocblas_status rocsolver_zgetrs_strided_batched(rocblas_handle handle, const rocblas_operation trans, const rocblas_int n, const rocblas_int nrhs, rocblas_double_complex* A, const rocblas_int lda, const rocblas_stride strideA, const rocblas_int* ipiv, const rocblas_stride strideP, rocblas_double_complex* B, const rocblas_int ldb, const rocblas_stride strideB, const rocblas_int batch_count) { return rocsolver_getrs_strided_batched_impl<rocblas_double_complex>( handle, trans, n, nrhs, A, lda, strideA, ipiv, strideP, B, ldb, strideB, batch_count); }
[ "noreply@github.com" ]
noreply@github.com
2d7a304c122b582e0a39b44ce672b6911f6c24fa
7398750b5f7247d794d6ec0dc656e8df1e5bca48
/view/micampotexto.h
22886022cabbeb60a1a4f47b7d5ce656be06f833
[]
no_license
cosimani/tapadita-ra
244d417e947182f5800636ca8c36bc4cfc4b04bf
fad5e2318f2714cfbdb75cba802a019f3d125073
refs/heads/master
2021-01-22T21:57:52.973113
2017-08-25T17:27:43
2017-08-25T17:27:43
92,746,766
0
0
null
null
null
null
UTF-8
C++
false
false
472
h
#ifndef MICAMPOTEXTO_H #define MICAMPOTEXTO_H #include <QWidget> namespace Ui { class MiCampoTexto; } class MiCampoTexto : public QWidget { Q_OBJECT QString userName; public: explicit MiCampoTexto(QWidget *parent = 0); ~MiCampoTexto(); void setTextToLabel(QString text); void setTextToFild(QString text); QString getUserName(); void setUserName(const QString &value); private: Ui::MiCampoTexto *ui; }; #endif // MICAMPOTEXTO_H
[ "jasinjunior@gmail.com" ]
jasinjunior@gmail.com
cec5d96ccb9fb02a4fdec8aeac28a7a7d521d0f3
36f662012217669dce03ea4baf8d797885b7b1d7
/tests/cpp-empty-test/Classes/core/msg/win32/OptionsDesc.cpp
c9ac3a47cec63b80467d8d499f04a24ac0e62391
[]
no_license
ryank231231/kirikiroid2_fork
f93d4bec5f5d2b25b160f619db2474f48dfa9d9e
592083a5bb5f0c87ecb0d708a1baefec3865c0a2
refs/heads/master
2022-11-06T11:12:46.066020
2020-06-25T07:21:27
2020-06-25T07:21:27
270,176,664
0
0
null
null
null
null
UTF-8
C++
false
false
44,919
cpp
/* TVP2 ( T Visual Presenter 2 ) A script authoring tool Copyright (C) 2000-2007 W.Dee <dee@kikyou.info> and contributors See details of license at "license.txt" */ /* This file is always generated by gen_optdesc_res.pl and option_desc(_ja).txt . */ /* Modification by hand will be lost. */ #include "tjsCommHead.h" #include "MsgIntf.h" #include <zlib.h> /* option description string (compressed) */ static tjs_uint8 compressed_option_desc_string[] = { 0x78, 0x9c, 0xed, 0x3c, 0xfd, 0x73, 0x53, 0xd7, 0x95, 0xbf, 0x77, 0xa6, 0xff, 0x83, 0x3a, 0xdd, 0x2e, 0x36, 0xab, 0x10, 0xbd, 0x27, 0xc9, 0x96, 0x79, 0x33, 0x9d, 0xca, 0xc6, 0x80, 0x09, 0x60, 0x16, 0x1b, 0xf0, 0xa6, 0x84, 0x44, 0x58, 0xcf, 0xb2, 0x5a, 0x59, 0x72, 0xf5, 0x61, 0x03, 0x25, 0x4c, 0x74, 0x5f, 0xda, 0x20, 0xd9, 0xd6, 0x87, 0x6d, 0xd9, 0xdd, 0x9d, 0x96, 0x6d, 0x5d, 0x26, 0x2d, 0x4a, 0x20, 0xdb, 0xcd, 0x12, 0x92, 0x06, 0x9a, 0x92, 0xc5, 0x80, 0x19, 0x39, 0x9d, 0x76, 0x3b, 0x69, 0x77, 0x93, 0x34, 0x84, 0xb4, 0x04, 0x98, 0xa6, 0x15, 0xdb, 0x99, 0x9d, 0x4e, 0x93, 0x1f, 0xf6, 0x9c, 0x73, 0xdf, 0xb7, 0x9e, 0x6c, 0xe3, 0x6e, 0x33, 0xb3, 0x33, 0x1d, 0xc6, 0xe8, 0xdd, 0xaf, 0x73, 0xcf, 0xd7, 0x3d, 0xf7, 0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, 0xd8, 0xd7, 0x81, 0x7d, 0x34, 0x02, 0x08, 0x15, 0x88, 0x52, 0x01, 0x48, 0x15, 0x88, 0x56, 0x01, 0x88, 0x15, 0x88, 0x5a, 0x01, 0xc8, 0x15, 0x88, 0x5e, 0x01, 0x08, 0x16, 0x88, 0x62, 0x01, 0x48, 0x16, 0x88, 0x66, 0x01, 0x88, 0x16, 0x88, 0x6a, 0x01, 0xc8, 0x16, 0x88, 0x6e, 0x01, 0x08, 0x17, 0x3a, 0xb8, 0x64, 0x28, 0x06, 0x45, 0x4f, 0x20, 0x1c, 0xa2, 0x5c, 0x04, 0xca, 0x45, 0xa2, 0x5c, 0x04, 0xca, 0x45, 0xa2, 0x5c, 0x04, 0xca, 0x45, 0x2e, 0x4b, 0x14, 0x26, 0x97, 0x26, 0x8a, 0x93, 0xcb, 0x13, 0x05, 0x4a, 0x94, 0x8b, 0x40, 0xb9, 0x48, 0x94, 0x8b, 0x40, 0xb9, 0x48, 0x94, 0x83, 0x1f, 0x02, 0x62, 0xe7, 0xf2, 0x47, 0x05, 0xa0, 0x11, 0x40, 0xb9, 0x48, 0x94, 0x8b, 0x40, 0xb9, 0x48, 0x94, 0x8b, 0x40, 0xb9, 0x88, 0x94, 0xdb, 0x96, 0x0f, 0x3c, 0x4c, 0x80, 0x9e, 0xef, 0x56, 0xf2, 0xb0, 0x5a, 0x67, 0xb4, 0xac, 0x10, 0x9e, 0x4f, 0xe1, 0xd8, 0xc4, 0x96, 0x60, 0x31, 0x2d, 0xb0, 0xbb, 0xd8, 0x65, 0xa5, 0x4d, 0x53, 0x4d, 0x24, 0x68, 0x02, 0x23, 0xff, 0x26, 0x2e, 0x94, 0xb9, 0x5b, 0xe5, 0x3b, 0x2b, 0xee, 0xa2, 0x43, 0xa9, 0x11, 0x39, 0x3d, 0x9c, 0x30, 0x9c, 0xce, 0x70, 0x38, 0x19, 0x1a, 0x57, 0xf7, 0xbb, 0x2d, 0xf0, 0xe8, 0x1e, 0x0c, 0xa7,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0x31, 0x32, 0x1a, 0xe2, 0xb5, 0xc6, 0x6c, 0x0d, 0xea, 0x61, 0x4e, 0xa2, 0xff, 0x2a, 0xe0, 0x8d, 0xaf, 0x40, 0x3e, 0x45, 0x1f, 0xd2, 0xc8, 0xd8, 0xde, 0x30, 0xb0, 0xb5, 0x5a, 0x15, 0x63, 0xe5, 0xae, 0xcb, 0x28, 0x4c, 0xaf, 0xe0, 0x12, 0x3d, 0x82, 0xf0, 0x70, 0xdb, 0xc3, 0xfa, 0xce, 0x80, 0xff, 0x4f, 0x5f, 0xcc, 0xff, 0x1b, 0x1c, 0x0a, 0xae, 0xab, 0x5d, 0x2d, 0x26, 0xea, 0x78, 0x38, 0x35, 0x96, 0x88, 0x0d, 0x85, 0x06, 0xd3, 0x86, 0x77, 0xbd, 0xd1, 0xeb, 0x15, 0x45, 0x89, 0xc0, 0x99, 0x88, 0xa5, 0x37, 0x84, 0xa9, 0xd2, 0x4c, 0xeb, 0xff, 0x02, 0x9a, 0x8e, 0x5c, 0x4a, }; static const unsigned long compressed_size = 7229; static const unsigned long decompressed_size = 21817; ttstr TVPGetCommandDesc() { unsigned char * dest = new unsigned char [decompressed_size + 1]; ttstr ret; try { unsigned long dest_size = decompressed_size; int result = uncompress(dest, &dest_size, (unsigned char*)compressed_option_desc_string, compressed_size); if(result != Z_OK || dest_size != decompressed_size) { TVPThrowInternalError; } dest[decompressed_size] = 0; ret = (const char *)dest; } catch(...) { delete [] dest; __debugbreak(); throw; } delete [] dest; return ret; }
[ "weimingtom@qq.com" ]
weimingtom@qq.com
2ceb982820e3211f7676290c6370a4bebc2d613e
b8d69ca1b0e3d04e139f4f3e7b3026f0c44fb4de
/Josephus_object/ring.cpp
f89e108bffc194044a8bb8d38f3d7dfcae0ea214
[]
no_license
troyzhaoyue/cpp
9d1459af923d03c0694e132335ab15f3c9bf970b
e9be12f0fead13e308ce4c5229e0ec1199c995af
refs/heads/master
2021-06-12T13:29:16.997707
2017-03-18T04:41:45
2017-03-18T04:41:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
775
cpp
#include <iostream> #include <iomanip> #include "ring.h" using namespace std; Ring::Ring(int n){ pBegin = new Boy[n]; //malloc pCurrent = pBegin; for(int i = 1; i <= n ; i++){ pCurrent ->code = i; pCurrent -> next = pBegin + i%n ; pCurrent = pCurrent -> next ; } cout << endl ; pCurrent = &pBegin[n-1] ; //initial begin at the last boy } void Ring::Count(int m){ for(int i = 0 ;i < m ; i++){ pivot = pCurrent ; pCurrent = pivot -> next ; } cout<< "the current is :" << pCurrent->code<<'\n'; } void Ring::PutBoy(){ static int numInLine; cout << setw(4) << pCurrent -> code <<"out" << '\n'; } void Ring::ClearBoy(){ pivot -> next = pCurrent ->next ; pCurrent = pivot ; //clear the current node } Ring::~Ring(){ delete[]pBegin ; //free the list }
[ "tigerzhaoyue@outlook.com" ]
tigerzhaoyue@outlook.com
7bcf8107c2d3537447037d45e9d331b95351ab5b
3a08b5c6fcb81527fa5ccc5576d08a36cd5657ae
/neo_pixel_panel/neo_pixel_panel.ino
a8adc023a2c6cc65344b0dfaf64439b8a5a962d4
[]
no_license
freemansoft/build-monitor-devices
e7c0fb9e117de9097616fe6f623d8d4245d3ed4d
75c641ce94d4db7ccf40d8ad7a603fdbf7443589
refs/heads/main
2023-01-24T12:09:46.261506
2022-12-29T20:18:06
2022-12-29T20:18:06
4,893,765
6
9
null
null
null
null
UTF-8
C++
false
false
13,217
ino
/* Written by Freemansoft Inc. Exercise Neopixel (WS2811 or WS2812) shield using the adafruit NeoPixel library You need to download the Adafruit NeoPixel library from github, unzip it and put it in your arduino libraries directory commands include rgb <led 0..39> <red 0..255> <green 0..255> <blue 0..255> <pattern 0..9>: set RGB pattern to pattern <0:off, 1:continuous> rgb <all -1> <red 0..255> <green 0..255> <blue 0..255> <pattern 0..9>: set RGB pattern to pattern <0:off, 1:continuous> debug <true|false> log all input to serial blank clears all demo random colors */ #include <Adafruit_NeoPixel.h> #include <MsTimer2.h> boolean logDebug = false; // pin used to talk to NeoPixel #define PIN 6 // Parameter 1 = number of pixels in strip // Parameter 2 = pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_RGB Pixels are wired for RGB bitstream // NEO_GRB Pixels are wired for GRB bitstream // NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip) // using the arduino shield which is 5x8 const int NUM_PIXELS = 40; Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800); typedef struct { uint32_t activeValues; // packed 32 bit created by Strip.Color uint32_t lastWrittenValues; //for fade in the future byte currentState; // used for blink byte pattern; unsigned long lastChangeTime; // where are we timewise in the pattern } pixelDefinition; // should these be 8x5 intead of linear 40 ? volatile pixelDefinition lightStatus[NUM_PIXELS]; volatile boolean stripShowRequired = false; /////////////////////////////////////////////////////////////////////////// // time between steps const int STATE_STEP_INTERVAL = 10; // in milliseconds - all our table times are even multiples of this const int MAX_PWM_CHANGE_SIZE = 32; // used for fading at some later date /*================================================================================ * * bell pattern buffer programming pattern lifted from http://arduino.cc/playground/Code/MultiBlink * *================================================================================*/ typedef struct { boolean isActive; // digital value for this state to be active (on off) unsigned long activeTime; // time to stay active in this state stay in milliseconds } stateDefinition; // the number of pattern steps in every blink pattern const int MAX_STATES = 4; typedef struct { stateDefinition state[MAX_STATES]; // can pick other numbers of slots } ringerTemplate; const int NUM_PATTERNS = 10; const ringerTemplate ringPatterns[] = { // state0 state1 state2 state3 // the length of these times also limit how quickly changes will occure. color changes are only picked up when a true transition happens { /* no variable before stateDefinition*/ {{false, 1000}, {false, 1000}, {false, 1000}, {false, 1000}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{true, 1000}, {true, 1000}, {true, 1000}, {true, 1000}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{true , 300}, {false, 300}, {false, 300}, {false, 300}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{false, 300}, {true , 300}, {true , 300}, {true , 300}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{true , 200}, {false, 100}, {true , 200}, {false, 800}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{false, 200}, {true , 100}, {false, 200}, {true , 800}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{true , 300}, {false, 400}, {true , 150}, {false, 400}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{false, 300}, {true , 400}, {false, 150}, {true , 400}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{true , 100}, {false, 100}, {true , 100}, {false, 800}} /* no variable after stateDefinition*/ }, { /* no variable before stateDefinition*/ {{false, 100}, {true , 100}, {false, 100}, {true , 800}} /* no variable after stateDefinition*/ }, }; /////////////////////////////////////////////////////////////////////////// void setup() { // 50usec for 40pix @ 1.25usec/pixel : 19200 is .5usec/bit or 5usec/character // there is a 50usec quiet period between updates //Serial.begin(19200); // don't want to lose characters if interrupt handler too long // serial interrupt handler can't run so arduino input buffer length is no help Serial.begin(9600); strip.begin(); strip.show(); // Initialize all pixels to 'off' stripShowRequired = false; // initialize our buffer as all LEDS off go_dark(); //show a quickcolor pattern configureForDemo(); delay(3000); go_dark(); MsTimer2::set(STATE_STEP_INTERVAL, process_blink); MsTimer2::start(); } void loop(){ const int READ_BUFFER_SIZE = 4*6; // rgb_lmp_red_grn_blu_rng where ringer is only 1 digit but need place for \0 char readBuffer[READ_BUFFER_SIZE]; int readCount = 0; char newCharacter = '\0'; while((readCount < READ_BUFFER_SIZE) && newCharacter !='\r'){ // did the timer interrupt handler make changes that require a strip.show()? // note: strip.show() attempts to unmask interrupts as much as possible // must be inside character read while loop if (stripShowRequired) { stripShowRequired = false; strip.show(); } if (Serial.available()){ newCharacter = Serial.read(); if (newCharacter != '\r'){ readBuffer[readCount] = newCharacter; readCount++; } } } if (newCharacter == '\r'){ readBuffer[readCount] = '\0'; // this has to be before process_Command because buffer is wiped if (logDebug){ Serial.print("received "); Serial.print(readCount); Serial.print(" characters, command: "); Serial.println(readBuffer); } // got a command so parse it process_command(readBuffer,readCount); } else { // while look exited because too many characters so start over } } /* * blank out the LEDs and buffer */ void go_dark(){ unsigned long ledLastChangeTime = millis(); for ( int index = 0 ; index < NUM_PIXELS; index++){ lightStatus[index].currentState = 0; lightStatus[index].pattern = 0; lightStatus[index].activeValues = strip.Color(0,0,0); lightStatus[index].lastChangeTime = ledLastChangeTime; strip.setPixelColor(index, lightStatus[index].activeValues); } // force them all dark immediatly so they go out at the same time // could have waited for timer but different blink rates would go dark at slighly different times strip.show(); } //////////////////////////// handler ////////////////////////////// // /* Interrupt handler that handles all blink operations */ void process_blink(){ boolean didChangeSomething = false; unsigned long now = millis(); for ( int index = 0 ; index < NUM_PIXELS; index++){ byte currentPattern = lightStatus[index].pattern; if (currentPattern >= 0){ // quick range check for valid pattern? if (now >= lightStatus[index].lastChangeTime + ringPatterns[currentPattern].state[lightStatus[index].currentState].activeTime){ // calculate next state with rollover/repeat int currentState = (lightStatus[index].currentState+1) % MAX_STATES; lightStatus[index].currentState = currentState; lightStatus[index].lastChangeTime = now; // will this cause slight flicker if already showing led? if (ringPatterns[currentPattern].state[currentState].isActive){ strip.setPixelColor(index, lightStatus[index].activeValues); } else { strip.setPixelColor(index,strip.Color(0,0,0)); } didChangeSomething = true; } } } // don't show in the interrupt handler because interrupts would be masked // for a long time. if (didChangeSomething){ stripShowRequired = true; } } // first look for commands without parameters then with parametes boolean process_command(char *readBuffer, int readCount){ int indexValue; byte redValue; byte greenValue; byte blueValue; byte patternValue; // use string tokenizer to simplify parameters -- could be faster by only running if needed char *command; char *parsePointer; // First strtok iteration command = strtok_r(readBuffer," ",&parsePointer); boolean processedCommand = false; if (strcmp(command,"h") == 0 || strcmp(command,"?") == 0){ help(); processedCommand = true; } else if (strcmp(command,"rgb") == 0){ char * index = strtok_r(NULL," ",&parsePointer); char * red = strtok_r(NULL," ",&parsePointer); char * green = strtok_r(NULL," ",&parsePointer); char * blue = strtok_r(NULL," ",&parsePointer); char * pattern = strtok_r(NULL," ",&parsePointer); if (index == NULL || red == NULL || green == NULL || blue == NULL || pattern == NULL){ help(); } else { // this code shows how lazy I am. int numericValue; numericValue = atoi(index); if (numericValue < 0) { numericValue = -1; } else if (numericValue >= NUM_PIXELS) { numericValue = NUM_PIXELS-1; }; indexValue = numericValue; numericValue = atoi(red); if (numericValue < 0) { numericValue = 0; } else if (numericValue > 255) { numericValue = 255; }; redValue = numericValue; numericValue = atoi(green); if (numericValue < 0) { numericValue = 0; } else if (numericValue > 255) { numericValue = 255; }; greenValue = numericValue; numericValue = atoi(blue); if (numericValue < 0) { numericValue = 0; } else if (numericValue > 255) { numericValue = 255; }; blueValue = numericValue; numericValue = atoi(pattern); if (numericValue < 0) { numericValue = 0; } else if (numericValue > NUM_PATTERNS) { numericValue = NUM_PATTERNS-1; }; patternValue = numericValue; /* Serial.println(indexValue); Serial.println(redValue); Serial.println(greenValue); Serial.println(blueValue); Serial.println(patternValue); */ if (indexValue >= 0){ lightStatus[indexValue].activeValues = strip.Color(redValue,greenValue,blueValue); lightStatus[indexValue].pattern = patternValue; } else { for (int i = 0; i < NUM_PIXELS; i++){ lightStatus[i].activeValues = strip.Color(redValue,greenValue,blueValue); lightStatus[i].pattern = patternValue; } } processedCommand = true; } } else if (strcmp(command,"blank") == 0){ go_dark(); processedCommand = true; } else if (strcmp(command,"debug") == 0){ char * shouldLog = strtok_r(NULL," ",&parsePointer); if (strcmp(shouldLog,"true") == 0){ logDebug = true; } else { logDebug = false; } processedCommand = true; } else if (strcmp(command,"demo") == 0){ configureForDemo(); processedCommand = true; } else { // completely unrecognized } if (!processedCommand){ Serial.print(command); Serial.println(" not recognized "); } return processedCommand; } /* * Simple method that displays the help */ void help(){ Serial.println("h: help"); Serial.println("?: help"); Serial.println("rgb <led 0..39> <red 0..255> <green 0..255> <blue 0..255> <pattern 0..9>: set RGB pattern to pattern <0:off, 1:continuous>"); Serial.println("rgb <all -1> <red 0..255> <green 0..255> <blue 0..255> <pattern 0..9>: set RGB pattern to pattern <0:off, 1:continuous>"); Serial.println("debug <true|false> log all input to serial"); Serial.println("blank clears all"); Serial.println("demo color and blank wheel"); Serial.flush(); } //////////////////////////// demo ////////////////////////////// /* * show the various blink patterns */ void configureForDemo(){ unsigned long ledLastChangeTime = millis(); for ( int index = 0 ; index < NUM_PIXELS; index++){ lightStatus[index].currentState = 0; lightStatus[index].pattern = (index%8)+1; // the shield is 8x5 so we do 8 patterns and we know pattern 0 is off lightStatus[index].activeValues = Wheel(index*index & 255); lightStatus[index].lastChangeTime = ledLastChangeTime; } uint16_t i; for(i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i,lightStatus[i].activeValues); } strip.show(); } //////////////////////////// stuff from the Adafruit NeoPixel sample ////////////////////////////// // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } }
[ "joe+github@freemansoft.com" ]
joe+github@freemansoft.com
0f8eb7186da7afe80093ef2a925ba71e53996b8a
4b2fdd51cc63ae0b3a3e91ea168dfdf85f781218
/practice/CF-B/B-Easter-Eggs.cpp
64c681b48e39f57a1a1c1526ca7699092f5ffb6e
[ "MIT" ]
permissive
RahulKumar78/codes
408303e4240b1853b8b29aa4ef76a7fced73bfc9
b9724d3b6e3fa0523612aab909f8ca5fe1d0587e
refs/heads/master
2022-11-17T13:11:37.237858
2020-07-16T14:01:10
2020-07-16T14:01:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,284
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector< vi > vvi; ///////////////////////// #define F first #define S second #define PB push_back #define MP make_pair #define loop(i,a,b) for (int i = a; i < b; i++) ////////////////////////// #define printvector(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n' #define printstack(n) for(int i=0;i<n.size();i++){cout<<n[i]<<" ";}cout<<'\n' #define PI_val 3.14159265359 #define printpair(n) cout<<n.F<<" "<<n.S #define printvop(n) loop(i,0,n.size()-1){printpair(n[i])<<endl;} #define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define endl "\n" long long int mod=1000000007; ////////////////////////// int main() { #ifndef ONLINE_JUDGE // for getting input from input.txt freopen("E:/codes/testcases/input.in", "r", stdin); // for writing output to output.txt freopen("E:/codes/testcases/output.in", "w", stdout); #endif long long int a,b,x,n,m,k,sum=0,ans=0,res=0; cin >> n; string s="ROYGBIV",s2="VIBGYOR"; for(int i=0;i<n/7;i++){ cout<<s; } if(n%7==1)cout<<'G'; if(n%7==2)cout<<"GB"; if(n%7==3)cout<<"YGB"; if(n%7==4)cout<<"YGBI"; if(n%7==5)cout<<"OYGBI"; if(n%7==6)cout<<"OYGBIV"; return 0; }
[ "kulkarnianirudha8@gmail.com" ]
kulkarnianirudha8@gmail.com
ebaf96d091d2f2da6c033c407d5c041eea933943
38804bb6bbe2ebf4953e4ee834edb41ce0f9a55c
/371_Sum_of_Two_Integers/371.cpp
22e8960f3eb7aaca06bd45506db6485a9a4780de
[]
no_license
mumuxijili/MyLCode
d90da042477193e23a2a215c8e4d29d4911a2dd3
5998073e400f732b144f742d257b8f97631cbc00
refs/heads/master
2021-01-01T05:19:06.388875
2017-06-02T03:50:04
2017-06-02T03:50:04
59,084,603
0
0
null
null
null
null
UTF-8
C++
false
false
697
cpp
#include <iostream> using namespace std; /* 首先,我们通过对x和y进行&位运算,得出每一位上的进位。 然后对x和y进行^位运算,得出没有加进位的和。 最后将所得的和当做新的x,所得的进位往左移一位(第零位的进位输入为0)当做新的y, 继续做上面的步骤,直到进位为0,此时x中保存的就是我们要求的x和y的和了。 */ class Solution { public: int getSum(int a, int b) { int sum = a; int carry = b; while(carry) { int tmp = sum; sum = tmp ^ carry; carry = (tmp & carry) << 1; } return sum; } }; int main() { Solution s; int c = s.getSum(10, 20); cout << c << endl; return 0; }
[ "mengjiepang@gmail.com" ]
mengjiepang@gmail.com
9e85165e45345f4e1d259c66b30eddcd39389b1d
9fad4848e43f4487730185e4f50e05a044f865ab
/src/chrome/browser/notifications/message_center_settings_controller_unittest.cc
770b31cf7d2a9d43a2d8ddb391fc307dc6342bc2
[ "BSD-3-Clause" ]
permissive
dummas2008/chromium
d1b30da64f0630823cb97f58ec82825998dbb93e
82d2e84ce3ed8a00dc26c948219192c3229dfdaa
refs/heads/master
2020-12-31T07:18:45.026190
2016-04-14T03:17:45
2016-04-14T03:17:45
56,194,439
4
0
null
null
null
null
UTF-8
C++
false
false
13,924
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <string> #include <utility> #include "base/command_line.h" #include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/test_extension_system.h" #include "chrome/browser/notifications/desktop_notification_profile_util.h" #include "chrome/browser/notifications/message_center_settings_controller.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile_manager.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "content/public/test/test_browser_thread_bundle.h" #include "extensions/common/extension.h" #include "extensions/common/extension_builder.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/message_center/notifier_settings.h" #if defined(OS_CHROMEOS) #include "ash/system/system_notifier.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" #endif class MessageCenterSettingsControllerBaseTest : public testing::Test { protected: MessageCenterSettingsControllerBaseTest() : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) {} ~MessageCenterSettingsControllerBaseTest() override{}; base::FilePath GetProfilePath(const std::string& base_name) { return testing_profile_manager_.profile_manager()->user_data_dir() .AppendASCII(base_name); } void SetUp() override { ASSERT_TRUE(testing_profile_manager_.SetUp()); } virtual TestingProfile* CreateProfile(const std::string& name) { return testing_profile_manager_.CreateTestingProfile(name); } void CreateController() { controller_.reset(new MessageCenterSettingsController( *testing_profile_manager_.profile_attributes_storage())); } void ResetController() { controller_.reset(); } MessageCenterSettingsController* controller() { return controller_.get(); } private: content::TestBrowserThreadBundle thread_bundle_; TestingProfileManager testing_profile_manager_; scoped_ptr<MessageCenterSettingsController> controller_; DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerBaseTest); }; #if defined(OS_CHROMEOS) class MessageCenterSettingsControllerChromeOSTest : public MessageCenterSettingsControllerBaseTest { protected: MessageCenterSettingsControllerChromeOSTest() {} ~MessageCenterSettingsControllerChromeOSTest() override {} void SetUp() override { MessageCenterSettingsControllerBaseTest::SetUp(); // Initialize the UserManager singleton to a fresh FakeUserManager instance. user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( new chromeos::FakeChromeUserManager)); } void TearDown() override { ResetController(); MessageCenterSettingsControllerBaseTest::TearDown(); } TestingProfile* CreateProfile(const std::string& name) override { TestingProfile* profile = MessageCenterSettingsControllerBaseTest::CreateProfile(name); GetFakeUserManager()->AddUser(AccountId::FromUserEmail(name)); GetFakeUserManager()->LoginUser(AccountId::FromUserEmail(name)); return profile; } void SwitchActiveUser(const std::string& name) { GetFakeUserManager()->SwitchActiveUser(AccountId::FromUserEmail(name)); controller()->ActiveUserChanged(GetFakeUserManager()->GetActiveUser()); } private: chromeos::FakeChromeUserManager* GetFakeUserManager() { return static_cast<chromeos::FakeChromeUserManager*>( user_manager::UserManager::Get()); } scoped_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; DISALLOW_COPY_AND_ASSIGN(MessageCenterSettingsControllerChromeOSTest); }; typedef MessageCenterSettingsControllerChromeOSTest MessageCenterSettingsControllerTest; #else typedef MessageCenterSettingsControllerBaseTest MessageCenterSettingsControllerTest; #endif // OS_CHROMEOS #if !defined(OS_CHROMEOS) TEST_F(MessageCenterSettingsControllerTest, NotifierGroups) { CreateProfile("Profile-1"); CreateProfile("Profile-2"); CreateController(); EXPECT_EQ(controller()->GetNotifierGroupCount(), 2u); EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, base::UTF8ToUTF16("Profile-1")); EXPECT_EQ(controller()->GetNotifierGroupAt(1).name, base::UTF8ToUTF16("Profile-2")); EXPECT_EQ(controller()->GetActiveNotifierGroup().name, base::UTF8ToUTF16("Profile-1")); controller()->SwitchToNotifierGroup(1); EXPECT_EQ(controller()->GetActiveNotifierGroup().name, base::UTF8ToUTF16("Profile-2")); controller()->SwitchToNotifierGroup(0); EXPECT_EQ(controller()->GetActiveNotifierGroup().name, base::UTF8ToUTF16("Profile-1")); } #else // !defined(OS_CHROMEOS) TEST_F(MessageCenterSettingsControllerChromeOSTest, NotifierGroups) { CreateProfile("Profile-1"); CreateProfile("Profile-2"); CreateController(); EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, base::UTF8ToUTF16("Profile-1")); SwitchActiveUser("Profile-2"); EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, base::UTF8ToUTF16("Profile-2")); SwitchActiveUser("Profile-1"); EXPECT_EQ(controller()->GetNotifierGroupCount(), 1u); EXPECT_EQ(controller()->GetNotifierGroupAt(0).name, base::UTF8ToUTF16("Profile-1")); } // TODO(mukai): write a test case to reproduce the actual guest session scenario // in ChromeOS -- no profiles in |profile_attributes_storage_|. #endif // !defined(OS_CHROMEOS) TEST_F(MessageCenterSettingsControllerTest, NotifierSortOrder) { TestingProfile* profile = CreateProfile("Profile-1"); extensions::TestExtensionSystem* test_extension_system = static_cast<extensions::TestExtensionSystem*>( extensions::ExtensionSystem::Get(profile)); base::CommandLine command_line(base::CommandLine::NO_PROGRAM); ExtensionService* extension_service = test_extension_system->CreateExtensionService( &command_line, base::FilePath() /* install_directory */, false /* autoupdate_enabled*/); extensions::ExtensionBuilder foo_app; // Foo is an app with name Foo and should appear second. const std::string kFooId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; // Bar is an app with name Bar and should appear first. const std::string kBarId = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; // Baz is an app with name Baz and should not appear in the notifier list // since it doesn't have notifications permission. const std::string kBazId = "cccccccccccccccccccccccccccccccc"; // Baf is a hosted app which should not appear in the notifier list. const std::string kBafId = "dddddddddddddddddddddddddddddddd"; foo_app.SetManifest( extensions::DictionaryBuilder() .Set("name", "Foo") .Set("version", "1.0.0") .Set("manifest_version", 2) .Set("app", extensions::DictionaryBuilder() .Set("background", extensions::DictionaryBuilder() .Set("scripts", extensions::ListBuilder() .Append("background.js") .Build()) .Build()) .Build()) .Set("permissions", extensions::ListBuilder().Append("notifications").Build()) .Build()); foo_app.SetID(kFooId); extension_service->AddExtension(foo_app.Build().get()); extensions::ExtensionBuilder bar_app; bar_app.SetManifest( extensions::DictionaryBuilder() .Set("name", "Bar") .Set("version", "1.0.0") .Set("manifest_version", 2) .Set("app", extensions::DictionaryBuilder() .Set("background", extensions::DictionaryBuilder() .Set("scripts", extensions::ListBuilder() .Append("background.js") .Build()) .Build()) .Build()) .Set("permissions", extensions::ListBuilder().Append("notifications").Build()) .Build()); bar_app.SetID(kBarId); extension_service->AddExtension(bar_app.Build().get()); extensions::ExtensionBuilder baz_app; baz_app.SetManifest( extensions::DictionaryBuilder() .Set("name", "baz") .Set("version", "1.0.0") .Set("manifest_version", 2) .Set("app", extensions::DictionaryBuilder() .Set("background", extensions::DictionaryBuilder() .Set("scripts", extensions::ListBuilder() .Append("background.js") .Build()) .Build()) .Build()) .Build()); baz_app.SetID(kBazId); extension_service->AddExtension(baz_app.Build().get()); extensions::ExtensionBuilder baf_app; baf_app.SetManifest( extensions::DictionaryBuilder() .Set("name", "baf") .Set("version", "1.0.0") .Set("manifest_version", 2) .Set("app", extensions::DictionaryBuilder() .Set("urls", extensions::ListBuilder() .Append("http://localhost/extensions/" "hosted_app/main.html") .Build()) .Build()) .Set("launch", extensions::DictionaryBuilder() .Set("urls", extensions::ListBuilder() .Append("http://localhost/extensions/" "hosted_app/main.html") .Build()) .Build()) .Build()); baf_app.SetID(kBafId); extension_service->AddExtension(baf_app.Build().get()); CreateController(); std::vector<message_center::Notifier*> notifiers; controller()->GetNotifierList(&notifiers); #if !defined(OS_CHROMEOS) EXPECT_EQ(2u, notifiers.size()); #else // ChromeOS always adds a system notifier to end of the list. EXPECT_EQ(3u, notifiers.size()); EXPECT_EQ(ash::system_notifier::kNotifierScreenshot, notifiers[2]->notifier_id.id); #endif EXPECT_EQ(kBarId, notifiers[0]->notifier_id.id); EXPECT_EQ(kFooId, notifiers[1]->notifier_id.id); STLDeleteElements(&notifiers); } TEST_F(MessageCenterSettingsControllerTest, SetWebPageNotifierEnabled) { Profile* profile = CreateProfile("MyProfile"); CreateController(); GURL origin("https://example.com/"); message_center::NotifierId notifier_id(origin); message_center::Notifier enabled_notifier( notifier_id, base::string16(), true); message_center::Notifier disabled_notifier( notifier_id, base::string16(), false); ContentSetting default_setting = HostContentSettingsMapFactory::GetForProfile(profile) ->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, NULL); ASSERT_EQ(CONTENT_SETTING_ASK, default_setting); // (1) Enable the permission when the default is to ask (expected to set). controller()->SetNotifierEnabled(disabled_notifier, true); EXPECT_EQ(CONTENT_SETTING_ALLOW, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); // (2) Disable the permission when the default is to ask (expected to clear). controller()->SetNotifierEnabled(enabled_notifier, false); EXPECT_EQ(CONTENT_SETTING_ASK, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); // Change the default content setting vaule for notifications to ALLOW. HostContentSettingsMapFactory::GetForProfile(profile) ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_ALLOW); // (3) Disable the permission when the default is allowed (expected to set). controller()->SetNotifierEnabled(enabled_notifier, false); EXPECT_EQ(CONTENT_SETTING_BLOCK, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); // (4) Enable the permission when the default is allowed (expected to clear). controller()->SetNotifierEnabled(disabled_notifier, true); EXPECT_EQ(CONTENT_SETTING_ALLOW, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); // Now change the default content setting value to BLOCK. HostContentSettingsMapFactory::GetForProfile(profile) ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, CONTENT_SETTING_BLOCK); // (5) Enable the permission when the default is blocked (expected to set). controller()->SetNotifierEnabled(disabled_notifier, true); EXPECT_EQ(CONTENT_SETTING_ALLOW, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); // (6) Disable the permission when the default is blocked (expected to clear). controller()->SetNotifierEnabled(enabled_notifier, false); EXPECT_EQ(CONTENT_SETTING_BLOCK, DesktopNotificationProfileUtil::GetContentSetting(profile, origin)); }
[ "dummas@163.com" ]
dummas@163.com
4e7c54bce78258e6237b60bfb05cc5dbee1fbbe5
3e70eda6819fec5bf5ba2299573b333a3a610131
/mole/dbsvr/ser/src/Croominfo_list.cpp
29aedb070cf5c17c05cb81fe7ed0c74984e8c3a2
[]
no_license
dawnbreaks/taomee
cdd4f9cecaf659d134d207ae8c9dd2247bef97a1
f21b3633680456b09a40036d919bf9f58c9cd6d7
refs/heads/master
2021-01-17T10:45:31.240038
2013-03-14T08:10:27
2013-03-14T08:10:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,001
cpp
/* * ===================================================================================== * * Filename: Croominfo_list.cpp * * Description: 把roominfo表内的大字段分解出来 * * Version: 1.0 * Created: 01/19/2010 10:41:18 AM * Revision: none * Compiler: gcc -Wall -Wextra Croominfo_list.cpp * * Author: easyeagel (LiuGuangBao), easyeagel@gmx.com * Company: 淘米网络-taomee.com * * ===================================================================================== */ #include"Croominfo_list.h" Croominfo_list::Croominfo_list(mysql_interface * db ) :CtableRoute10x10( db, "ROOMINFO","t_roominfo_list","room_id") { } int Croominfo_list::insert(userid_t userid) { sprintf(this->sqlstr, "insert into %s values(%u, 0x00000000, 0x00000000, 0x00000000)", this->get_table_name(userid), userid ); STD_SET_RETURN_EX (this->sqlstr, USER_ID_EXISTED_ERR); } int Croominfo_list::pk_add(userid_t userid, roominfo_pk_add_in *p_in ) { int ret; stru_pk_list pklist = { }; ret=this->get_pk_list(userid,&pklist ); if(ret!=SUCC) return ret; pklist.count++; if (pklist.count>PK_LIST_MAX_COUNT){ pklist.count=PK_LIST_MAX_COUNT; } for (uint32_t i = 0; i < pklist.count; i++) { if ((pklist.items[i].guestid == p_in->guestid) && (pklist.items[i].gameid == p_in->gameid)) { if (pklist.items[i].userid_score < p_in->userid_score) { pklist.items[i].userid_score = p_in->userid_score; } pklist.count--; return this->update_pk_list(userid, &pklist); } } for(uint32_t i=pklist.count-1;i>0;i-- ){ memcpy(&(pklist.items[i]),&(pklist.items[i-1]),sizeof(pklist.items[0])); } //第一个数据填上 memcpy(&(pklist.items[0]),p_in,sizeof(pklist.items[0])); //更新 ret = this->update_pk_list(userid,&pklist); if (ret != SUCC) { this->insert(userid); return this->update_pk_list(userid,&pklist); } return 0; } int Croominfo_list::get_pk_list(userid_t userid, stru_pk_list *p_out ) { sprintf( this->sqlstr, "select pk_list \ from %s where room_id=%d ", this->get_table_name(userid),userid); STD_QUERY_ONE_BEGIN(this-> sqlstr,USER_ID_NOFIND_ERR); BIN_CPY_NEXT_FIELD (p_out, sizeof ( *p_out) ); STD_QUERY_ONE_END(); } int Croominfo_list::update_pk_list( userid_t userid, stru_pk_list *p_list ) { char mysql_list[mysql_str_len(sizeof (*p_list))]; set_mysql_string(mysql_list,(char*)p_list, 4+sizeof(p_list->items[0])* p_list->count); sprintf( this->sqlstr, " update %s set pk_list ='%s' \ where room_id=%u " , this->get_table_name(userid), mysql_list, userid ); STD_SET_RETURN(this->sqlstr,userid,USER_ID_NOFIND_ERR ); } int Croominfo_list::get_presentlist(userid_t userid, stru_presentlist *p_out ) { memset(p_out,0,sizeof(*p_out)); sprintf( this->sqlstr, "select presentlist from %s where room_id=%d", this->get_table_name(userid),userid); STD_QUERY_ONE_BEGIN(this-> sqlstr,USER_ID_NOFIND_ERR); BIN_CPY_NEXT_FIELD (p_out, sizeof ( *p_out) ); STD_QUERY_ONE_END(); } int Croominfo_list::update_presentlist(userid_t userid ,stru_presentlist * p_list ) { char mysql_list[mysql_str_len(sizeof (*p_list))]; set_mysql_string(mysql_list,(char*)p_list, 4+sizeof(p_list->items[0])* p_list->count); sprintf( this->sqlstr, " update %s set presentlist ='%s' \ where room_id=%u " , this->get_table_name(userid), mysql_list, userid ); STD_SET_RETURN(this->sqlstr,userid,USER_ID_NOFIND_ERR ); } int Croominfo_list::presentlist_add(userid_t userid ,stru_present * p_item ) { int ret; stru_presentlist list; ret=this->get_presentlist(userid,&list ); if(ret!=SUCC) return ret; list.count++; if (list.count>20) list.count=20; uint32_t i=list.count; if (i==20) i=19; for (;i>0;i--){ memcpy(&(list.items[i]),&(list.items[i-1]),sizeof(list.items[0])); } memcpy(&(list.items[0]),p_item,sizeof(list.items[0])); ret = this->update_presentlist(userid,&list ); if (ret != SUCC) { this->insert(userid); return this->update_presentlist(userid,&list ); } return 0; } /** * @brief 更新心愿字节 * @param usrid 米米号 * @param p_list 保存心愿的结构体 */ int Croominfo_list::update_wish_sql(userid_t userid, stru_roominfo_wish *p_list) { char mysql_list[mysql_str_len(sizeof (*p_list))]; set_mysql_string(mysql_list, (char*)p_list, sizeof(*p_list)); sprintf( this->sqlstr, " update %s set wish = '%s' where room_id = %u" , this->get_table_name(userid), mysql_list, userid ); STD_SET_RETURN(this->sqlstr, userid, USER_ID_NOFIND_ERR); } /** * @brief 得到心愿内容 * @param userid 米米号 * @param p_out 保存返回的内容 */ int Croominfo_list::select_wish_sql(userid_t user_id, stru_roominfo_wish *p_out) { sprintf( this->sqlstr, " select wish from %s where room_id=%d", this->get_table_name(user_id), user_id ); STD_QUERY_ONE_BEGIN(this->sqlstr,USER_ID_NOFIND_ERR); BIN_CPY_NEXT_FIELD(p_out, sizeof(stru_roominfo_socks)); STD_QUERY_ONE_END(); }
[ "smyang.ustc@gmail.com" ]
smyang.ustc@gmail.com
9ec477f0ff9d32fdb9ede7cd4a26ba1f51a99a1e
372b7b645555a2f82c9edbbbe05967ca32eb1c5a
/Date.h
6d15148b2b280b5d69a3c8f027255fa4fa07a6d8
[]
no_license
Matt043270/WeatherData
9b9908f13d08e2e8dab2db417c9d3141da4f2df9
29abdd763cf26a086f167767e77f3ebf9a138c1b
refs/heads/master
2020-04-28T23:03:14.778353
2019-03-14T14:55:22
2019-03-14T14:55:22
175,640,203
0
0
null
null
null
null
UTF-8
C++
false
false
1,023
h
#ifndef DATE_H #define DATE_H /** * @class Date * @brief Class that stores date information. * * @author Matt Smooker * @version 01 */ class Date { public: /** * @brief The default constructor for the Date class. */ Date(); /** * @brief Sets the day variable. * * @param d - the day to be stored. * @return void */ void SetDay(int d); /** * @brief Retrieves the day variable. * * @return int */ int GetDay(); /** * @brief Sets the month variable. * * @param m - the month to be stored. * @return void */ void SetMonth(int m); /** * @brief Retrieves the month variable. * * @return int */ int GetMonth(); /** * @brief Sets the year variable. * * @param y - the year to be stored. * @return void */ void SetYear(int y); /** * @brief Retrieves the year variable. * * @return int */ int GetYear(); private: /// The day number. int m_day; /// The month number. int m_month; /// The year. int m_year; }; #endif // !DATE_H
[ "matt.smooker@hotmail.com" ]
matt.smooker@hotmail.com
930bb8aaa3d57af8d535a8c2e108b8f9f809d288
ccb5875093ec348e670480b1ba430514d5736be4
/hw3/main.cpp
2b33ec09e2db60ec19014620a8d833ad70012ae6
[]
no_license
evantravers/CS-475
ce43ff3e6c0abc96a3a3d7cc0ef0610835517de8
14336e02b1e1ed47a148b1fd762d2d6ae94e83e2
refs/heads/master
2021-01-20T04:29:52.237929
2011-04-23T01:50:19
2011-04-23T01:50:19
1,223,469
0
0
null
null
null
null
UTF-8
C++
false
false
5,700
cpp
#include <iostream> #include <cstdlib> #include <stdlib.h> #include <stdio.h> #include <vector> #ifdef __APPLE__ #include <OpenGL/OpenGL.h> #include <GLUT/glut.h> #else #include <GL/glut.h> #endif #include "imageloader.h" #include "vec3f.h" #include "marchingcubes.cpp" using namespace std; // for storing vertexes float _angle = 60.0f; float _angleLat = 60.0f; float _angleLon = 0.0f; float _walk = -10.0f; float _stride = 0.0f; float _elevate = 0.0f; int width; int height; double *** voxels; vector<vertex> vertices; int sample=1; void cleanup() { } void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 27: //Escape key cleanup(); exit(0); case 97: // A key _angleLat += 2.0f; if (_angleLat > 360) { _angleLat -= 360; } glutPostRedisplay(); break; case 100: // D key _angleLat -= 2.0f; if (_angleLat < 0) { _angleLat -= 360; } glutPostRedisplay(); break; case 119: // W key _angleLon += 2.0f; if (_angleLon > 360) { _angleLon -= 360; } glutPostRedisplay(); break; case 115: // S key _angleLon -= 2.0f; if (_angleLon < 0) { _angleLon -= 360; } glutPostRedisplay(); break; case 105: // I key _walk += 5.f; glutPostRedisplay(); break; case 107: // K key _walk -= 5.f; glutPostRedisplay(); break; case 106: // J key _stride += 5.f; glutPostRedisplay(); break; case 108: // L key _stride -= 5.f; glutPostRedisplay(); break; case 113: // Q key _elevate += 5.f; glutPostRedisplay(); break; case 101: // E key _elevate -= 5.f; glutPostRedisplay(); break; } } void initRendering() { glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_NORMALIZE); glShadeModel(GL_SMOOTH); } void handleResize(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(50.0, (double)w / (double)h, 1.0, 7000.0); } void drawScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); // Create light components GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f }; GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f }; GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat position[] = { -1.5f, 1.0f, -4.0f, 1.0f }; // Assign created components to GL_LIGHT0 glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight); glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight); glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight); glLightfv(GL_LIGHT0, GL_POSITION, position); glEnable(GL_NORMALIZE); glEnable(GL_COLOR_MATERIAL); // Set material properties which will be assigned by glColor glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); float specReflection[] = { 0.8f, 0.8f, 0.8f, 1.0f }; glMaterialfv(GL_FRONT, GL_SPECULAR, specReflection); glMatrixMode(GL_PROJECTION); glLoadIdentity(); // glRotatef(_angle, 0.0f, 1.0f, 0.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); glScalef(0.003f, 0.003f, 0.003f); glColor3f(0.9f, 0.9f, 0.5f); glTranslatef(-_stride*20.f, _elevate, _walk); glRotatef(-_angleLat, 0.0f, 1.0f, 0.0f); glRotatef(-_angleLon, -_angleLon, 1.0f, 0.0f); // glTranslatef(0.0f, -128.0f, 52.0f); // glRotatef(80.0f, 0.0f, 0.0f, 1.0f); // this is where you should draw your objects // there had better be code here by tomorrow or I will make you sad. // I should take the cheeseMesh that I hopefully created, consisting of two solid objects // derived from the slices of the cheese I took vector<vertex>::iterator it; glBegin(GL_TRIANGLES); for(it = vertices.begin(); it < vertices.end(); it++) { glNormal3d(it->normal_x, it->normal_y, it->normal_z); // glVertex3d(it->x*25.f, it->y, it->z); glVertex3d(it->x*25.f, it->y-200.f, it->z-(width/2)); } glEnd(); glutSwapBuffers(); } void update(int value) { _angle += .5f; if (_angle > 360) { _angle -= 360; } glutPostRedisplay(); glutTimerFunc(25, update, 0); } int main(int argc, char** argv) { // build the datatype char filename[21]; int i=1; // this is where you specify the number of slices // rewrite this in xyz form, i think that's the current issue voxels = new double**[9]; for (i = 0; i < 9; i++) { sprintf(filename, "data/blurry/%d.bmp",i+1); Image* image; image = loadBMP(filename); width = image->width; height = image->height; // need 3d array here. int y = i; int x, z; // voxels[y].resize(width); voxels[y] = new double*[width]; for (x = 0; x < width; x+=sample) { // voxels[y][x].resize(height); voxels[y][x] = new double[height]; for (z = 0; z < height; z+=sample) { unsigned char redcolor = 0; // redcolor = (unsigned char)image ->pixels[3*(z * image->width + x)+2]; redcolor = (unsigned char)image ->pixels[3*(z * image->width + x)]; double red = (double)redcolor; voxels[y][x][z]=red; } } } vertices = runMarchingCubes(voxels, 5, height, width, 1, 3, 3, 145.0); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 800); glutCreateWindow("cheese smells funny"); initRendering(); glutDisplayFunc(drawScene); glutKeyboardFunc(handleKeypress); glutReshapeFunc(handleResize); glutTimerFunc(25, update, 0); glutMainLoop(); return 0; }
[ "widgetwebworks@gmail.com" ]
widgetwebworks@gmail.com
704e688cb2c71c7b53b6f21f8ac3b2ec548acf59
3b79c45bc6b9d9e7f7226ba18b30d265176c2f17
/CPPCOM01.cpp
077afde29ff58404baa5c0bc1e76695f92fd116a
[]
no_license
thisisRen/Code-in-ZcodePTIT
30a8dfa66f7fc4bb608c3369fafc47b59d5cf1fe
e8a1d9439324889f95a04ba2b3e5eceb27370258
refs/heads/main
2023-02-01T10:28:09.576258
2020-12-16T15:14:30
2020-12-16T15:14:30
322,009,310
0
0
null
null
null
null
UTF-8
C++
false
false
592
cpp
#include <bits/stdc++.h> #include <string> using namespace std; void gen(int A[], int n) { ++A[n - 1]; for (int i = n - 1; i > 0; --i) { if (A[i] > 1) { ++A[i - 1]; A[i] -= 2; } } } void xuat(int A[], int n) { for (int i = 0; i < n; i++) cout << A[i]; cout << " "; } int main(){ int t; cin>>t; while(t--){ int n; cin >> n; int *A = new int[n]; for (int i = 0; i < n; i++) A[i] = 0; for (int i = 0; i < pow(2, n); i++) { xuat(A, n); gen(A, n); } cout << endl; } }
[ "noreply@github.com" ]
noreply@github.com
955fa85b9e11303460768ca32865a95e54100f7d
01d5128bcfa3850db4d1d65c4c468241cc0a65d1
/example/windows/runner/main.cpp
c5fda77eaa6e9ee72544282402879a2f711f0432
[ "Apache-2.0" ]
permissive
alnitak/flutter_opengl
15fae88b606bf34ffcc9e6e08344fb9809116809
19a0f50af3199f1897c51e8f9ee9c57b6cdffffd
refs/heads/master
2023-04-02T19:54:16.954044
2023-03-18T16:50:17
2023-03-18T16:50:17
191,439,046
157
20
null
null
null
null
UTF-8
C++
false
false
1,281
cpp
#include <flutter/dart_project.h> #include <flutter/flutter_view_controller.h> #include <windows.h> #include "flutter_window.h" #include "utils.h" int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { // Attach to console when present (e.g., 'flutter run') or create a // new console when running with a debugger. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { CreateAndAttachConsole(); } // Initialize COM, so that it is available for use in the library and/or // plugins. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); flutter::DartProject project(L"data"); std::vector<std::string> command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(500, 800); if (!window.CreateAndShow(L"flutter_opengl_example", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); ::MSG msg; while (::GetMessage(&msg, nullptr, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } ::CoUninitialize(); return EXIT_SUCCESS; }
[ "marcobavagnolidev@gmail.com" ]
marcobavagnolidev@gmail.com
f9aeac1053cfdf41c5ce49d04f1fedfbb03f3623
764ae6ab48307368b1a5c3ccd0cebf9e8d625957
/Components/Stopwatch/Stopwatch.cpp
1be5787bdd5d1f5b939e74f29cc3b4557c3d3741
[]
no_license
DmitriyODS/clock
d44b6714204ff309869726e02cc252a2d5536633
1414bca45effe78f2b28a1fa875a757831ad640c
refs/heads/main
2023-04-02T23:07:28.536367
2021-04-10T03:59:21
2021-04-10T03:59:21
355,192,682
0
0
null
null
null
null
UTF-8
C++
false
false
1,724
cpp
#include "Stopwatch.h" Stopwatch::Stopwatch(Vector2f position, Vector2f size) : BaseComponent(position, size) { m_background_texture.loadFromFile(PATH_CARD_STOPWATCH); m_background_sprite.setTexture(m_background_texture); m_background_sprite.setPosition(m_position); m_font.loadFromFile(PATH_FONT_TITLE_TEXT); m_font_text.loadFromFile(PATH_FONT_TEXT); m_text_title.setFont(m_font); m_text_title.setPosition(989, 251); m_text_title.setCharacterSize(48); m_text_title.setFillColor(Color(96, 125, 139)); m_text_title.setString("Stopwatch"); m_text_time.setFont(m_font_text); m_text_time.setFillColor(Color(96, 125, 139)); m_text_time.setPosition(Vector2f(1059, 392)); m_text_time.setCharacterSize(120); auto *button = new Button("Start", Vector2f(1019, 641), Vector2f(160, 60)); m_buttons.push_back(button); button = new Button("Stop", Vector2f(1315, 641), Vector2f(160, 60)); m_buttons.push_back(button); button = new Button("Reset", Vector2f(1139, 734), Vector2f(215, 60)); button->setClickListener([this](void *) { m_store->dispatch(setExit()); }); m_buttons.push_back(button); } void Stopwatch::render(RenderWindow *window) { if (!checkVisible()) return; BaseComponent::render(window); window->draw(m_text_title); window->draw(m_text_time); for (auto *pItem : m_buttons) { pItem->render(window); } } BaseComponent *Stopwatch::mouseCollision(Event::MouseMoveEvent mouse_move) { BaseComponent *cmpnt, *save{}; for (auto &item : m_buttons) { cmpnt = item->mouseCollision(mouse_move); if (cmpnt) { save = cmpnt; } } return save; }
[ "osipovskij.dima@yandex.ru" ]
osipovskij.dima@yandex.ru
46c8406b9767ec2b15cf38ec7f6acfc61cb1870b
22db45a022f46887cd2e1fab9e828bd02a14438a
/include/STC/IPv4Converter.hpp
d8221cb61be5cfb776d276d5791cf2d3a9c92c73
[]
no_license
fr830/ScadaTrafficController
336be93a3f6809ddf41db2d32157d2660dba3524
fa57bf018125f732ac1d36809bee03056607de38
refs/heads/master
2020-04-01T09:42:08.650211
2018-07-19T09:43:19
2018-07-19T09:43:19
153,086,429
1
1
null
null
null
null
UTF-8
C++
false
false
445
hpp
#ifndef INCLUDE_STC_IPV4CONVERTER_HPP #define INCLUDE_STC_IPV4CONVERTER_HPP #include <cstdint> namespace stc { namespace network { class IPv4Converter { public: IPv4Converter(char const * ip_str) noexcept; IPv4Converter(uint32_t ip_be) noexcept; uint32_t getIpBE() const noexcept; operator uint32_t() const noexcept; private: uint32_t mIP; }; }//namespace network }//namespace stc #endif //INCLUDE_STC_IPCONVERTER_HPP
[ "croessmah@ya.ru" ]
croessmah@ya.ru
963ec422ffcf41387e7ab095db1df5866b14c7e0
a9e0a502304ecf88009829d0e650a2cf4aa0bab7
/src/main.cpp
abdf66d9c3f072249e73fc551a7d0d622d3b1ccc
[]
no_license
leandrolfre/EyeOfThundera
7399419f292f27641a246b64a4b8c4107dc7f55c
310e3c154dc1da103c77665823686b5783cb4e8b
refs/heads/master
2020-03-18T02:05:53.449678
2018-05-07T22:24:06
2018-05-07T22:24:06
134,174,465
0
0
null
null
null
null
UTF-8
C++
false
false
3,026
cpp
#include <glad\glad.h> #include <GLFW\glfw3.h> #include <iostream> #include <math.h> #include "globals.h" #include "Scene.h" #include "light.h" void resizeCallback(GLFWwindow* window, int width, int height); void errorCallback(int error, const char* description); void processInput(GLFWwindow* window); void mouseCallback(GLFWwindow* window, double xpos, double ypos); float deltaTime, lastFrame; int width = 800; int height = 600; Scene scene; int main() { glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwSetErrorCallback(errorCallback); GLFWwindow* window = glfwCreateWindow(width, height, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwSetFramebufferSizeCallback(window, resizeCallback); glfwSetCursorPosCallback(window, mouseCallback); if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Failed to initialize GLAD" << std::endl; glfwTerminate(); return -1; } glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); float currentFrame = 0.0f; deltaTime = lastFrame = 0.0f; scene.init(); scene.addModel("nanosuit/nanosuit.obj"); std::unique_ptr<Light> pointLight(new PointLight()); pointLight->setPosition(glm::vec3(1.2f, 1.0f, 2.0f)); scene.addLight(std::move(pointLight)); //TODO: Add Lights to shader //TODO: Set Model on shader inside Model object //TODO: Set View and Projection on shader //TODO: Create a class Material to encapsulate a shader and global parameters like shininess and attach it to a Model object while (!glfwWindowShouldClose(window)) { currentFrame = glfwGetTime(); processInput(window); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); scene.draw(); glfwSwapBuffers(window); glfwPollEvents(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; } glfwTerminate(); return 0; } void processInput(GLFWwindow* window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { glfwSetWindowShouldClose(window, true); } if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS) scene.getCurrentCamera().moveForward(); if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS) scene.getCurrentCamera().moveBackward(); if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS) scene.getCurrentCamera().moveLeft(); if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) scene.getCurrentCamera().moveRight(); } void mouseCallback(GLFWwindow* window, double xpos, double ypos) { scene.getCurrentCamera().lookAt(xpos+width, ypos+height); } void resizeCallback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); } void errorCallback(int error, const char* description) { std::cout << error << ":" << description << std::endl; }
[ "leandrolfre@gmail.com" ]
leandrolfre@gmail.com
4d180fa7733442554dc960f7fe08d92c7b43efe6
bb9b83b2526d3ff8a932a1992885a3fac7ee064d
/src/modules/osgAnimation/generated_code/InOutElasticFunction.pypp.cpp
52fe1eb153dd4a645ae082012fd0db94b0987596
[]
no_license
JaneliaSciComp/osgpyplusplus
4ceb65237772fe6686ddc0805b8c77d7b4b61b40
a5ae3f69c7e9101a32d8cc95fe680dab292f75ac
refs/heads/master
2021-01-10T19:12:31.756663
2015-09-09T19:10:16
2015-09-09T19:10:16
23,578,052
20
7
null
null
null
null
UTF-8
C++
false
false
535
cpp
// This file has been generated by Py++. #include "boost/python.hpp" #include "wrap_osganimation.h" #include "inoutelasticfunction.pypp.hpp" namespace bp = boost::python; void register_InOutElasticFunction_class(){ bp::class_< osgAnimation::InOutElasticFunction >( "InOutElasticFunction" ) .def( "getValueAt" , (void (*)( float,float & ))( &::osgAnimation::InOutElasticFunction::getValueAt ) , ( bp::arg("t"), bp::arg("result") ) ) .staticmethod( "getValueAt" ); }
[ "brunsc@janelia.hhmi.org" ]
brunsc@janelia.hhmi.org
13ce1e1d0091f580c922baf5579d0719326df4db
9834dda4d32af2ab05c4a3448f8ace20541123be
/Gravity.h
253e2257d1550e39dad5491dfdb22d029d944e8d
[]
no_license
knihovnice/zelvici
32a57b9e4925d3c0c388dfb3b57b5c6f3a131b14
fba84ee7a9a4cbe1a6db88bc344ff7649004c19a
refs/heads/master
2023-04-26T18:30:20.014225
2021-05-24T14:07:45
2021-05-24T14:07:45
370,370,677
1
0
null
null
null
null
ISO-8859-1
C++
false
false
1,888
h
/*************************************************************************** * Želvíci Gold, Copyright (c) 2006 Dave Schwarz * * http://vkapse.aspweb.cz, dave_cz@jabber.cz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This 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 Library 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. * ***************************************************************************/ #ifndef GRAV_H #define GRAV_H const float MAXIMUM_GRAVITY = 15.0f; class CGravity { private: float m_acceleration; float m_const; float m_default; float m_antiDefault; public: CGravity(); void SetAcceleration(float value) { m_acceleration = value; } void ResetAntiGravity(); void AntiGravity(); void Update(); void ResetGravity(); float Get(); }; #endif
[ "david.schwarz@live.com" ]
david.schwarz@live.com
bc63380a0bdd8dddf1090613239c169b22130e22
19a05305e04ed064777a5b7906a154b0fb65e6e4
/Partition.h
d86be071a2fdb340c1bfefa2fdf4c5153596b6e5
[]
no_license
shreya1221/Scheduler
eb4d2e7c2f5c0a95819bca83acd1bd24dad2f7fb
f7f575a60c7035aa9b37a263ce8236a0143ba478
refs/heads/master
2020-06-04T00:32:26.749469
2019-06-13T17:55:44
2019-06-13T17:55:44
191,796,749
0
0
null
null
null
null
UTF-8
C++
false
false
293
h
#include"PCB.h" class Partition { PCB* pb; int cpu; Partition *nextp; public: Partition(); void setcpunum(int); void setpb(PCB *); void setnext(Partition *); int getcpunum(); PCB* getpb(); Partition* getnext(); // all needed accessor functions }; #pragma once
[ "noreply@github.com" ]
noreply@github.com
e86a9e2d8c7757a7c8d0abf655cbfbeb26b5c601
67b450e1e8cb0d5bcafd428a66416f0b13cc1e93
/topics wise codes/dp/DP ON TREE/C. Helga Hufflepuffs Cup.cpp
2ba0680c920b4223b692a04d37cffb9bce460831
[]
no_license
Musfiqshohan/Competitive-Programming
2b895ba4e78d14d029de8df2f052260bc4b36e9a
aa6865d5b2808222cf6dc62bbc740c0490a857ae
refs/heads/master
2021-05-14T06:54:36.633792
2018-04-07T15:59:48
2018-04-07T15:59:48
116,248,872
0
0
null
null
null
null
UTF-8
C++
false
false
5,901
cpp
///http://codeforces.com/contest/855/problem/C #include<bits/stdc++.h> #define ll long long #define MOD 1000000007 using namespace std; vector<ll>edge[100009]; vector<ll>seq; ll par[100009],sib[100009], fc[100009]; ll dp[100009][12][2][2]; ll n,k,x,m; void dfs(ll src, ll pr) { par[src]=pr; for(ll i=0; i<edge[src].size(); i++) { ll node= edge[src][i]; if(node!=pr) { dfs(node,src); } } } ll add(ll u, ll v) { return (u+v)%MOD; } ll mul(ll w,ll u, ll v) { if(w>=MOD) w%=MOD; if(u>=MOD) u%=MOD; if(v>=MOD) v%=MOD; ll temp=(w*u); if(temp>=MOD) temp%=MOD; return (temp*v)%MOD; } ///k is value of maximum security ///m is number of different value types which needs to multiply ///x number of max security vaults ll f(ll src, ll rem, bool par_flag, bool isGreater) { if(src==-1) { if(rem>=0) return 1; else return 0; } if(dp[src][rem][par_flag][isGreater]!=-1) return dp[src][rem][par_flag][isGreater]; ll ret=0; if(par_flag==false) { if(isGreater==false) /// i can make it secure or not. /// one is will i secure this or not, and how many remains { /// another is how many ways, i will count it later if(sib[src]==-1 && rem-1>=0) ret= add(ret, mul(1, f(fc[src], rem-1, true, true), 1) ); ///if no sibling take only else if(fc[src]==-1 && rem-1>=0) ret= add(ret, mul(1, 1, f(sib[src], rem-1, par_flag, isGreater)) ); else if(sib[src]==-1 && fc[src]==-1) return 1; else { for(ll i=0; i<rem; i++) ///lets secure first which can be in 1 way { ret= add(ret, mul(1, f(fc[src], i, true, true), f(sib[src], rem-1-i, par_flag, isGreater)) ); /// false } printf("at %lld rem=%lld par=%d isGR=%d res=%lld where sec\n",src, rem, par_flag, isGreater,ret); } if(sib[src]==-1) ret= add(ret, mul( k-1, f(fc[src], rem, false, false), 1 )); else if(fc[src]==-1) ret= add(ret, mul( k-1, 1, f(sib[src], rem, par_flag, isGreater) )); else if(sib[src]==-1 && fc[src]==-1)return 1; else { for(ll i=0; i<=rem; i++) ///now i will not secure and if smaller than K { ret= add(ret, mul( k-1, f(fc[src], i, false, false), f(sib[src], rem-i, par_flag, isGreater) )); } } printf("at %lld rem=%lld par=%d isGR=%d res=%lld where small\n",src, rem, par_flag, isGreater,ret); if(sib[src]==-1) ret= add(ret, mul( m-k, f(fc[src], rem, false, true), 1 )); else if(fc[src]==-1) ret= add(ret, mul( m-k, 1, f(sib[src], rem, par_flag, isGreater) )); else if(sib[src]==-1 && fc[src]==-1)return 1; else { for(ll i=0; i<=rem; i++) ///now i will not secure and if greater or equal than k { ret= add(ret, mul( m-k, f(fc[src], i, false, true), f(sib[src], rem-i, par_flag, isGreater) )); } } printf("at %lld rem=%lld par=%d isGR=%d res=%lld where grt\n",src, rem, par_flag, isGreater,ret); } else { if(sib[src]==-1) ret= add(ret, mul( k-1, f(fc[src], rem, false, false), 1) ); else if(fc[src]==-1) ret= add(ret, mul( k-1, 1, f(sib[src], rem, par_flag, isGreater) )); else if(sib[src]==-1 && fc[src]==-1)return 1; else { for(ll i=0; i<=rem; i++) ///now i will not secure and if smaller than K { ret= add(ret, mul( k-1, f(fc[src], i, false, false), f(sib[src], rem, par_flag, isGreater) )); } } if(sib[src]==-1) ret= add(ret, mul( m-k, f(fc[src], rem, false, true), 1 )); else if(fc[src]==-1) ret= add(ret, mul( m-k, 1, f(sib[src], rem, par_flag, isGreater) )); else if(sib[src]==-1 && fc[src]==-1)return 1; else { for(ll i=0; i<=rem; i++) ///now i will not secure and if greater or equal than k { ret= add(ret, mul( m-k, f(fc[src], i, false, true), f(sib[src], rem-i, par_flag, isGreater) )); } } } } else { ///ok if(sib[src]==-1) ret= add(ret, mul( k-1, f(fc[src],rem, false, false), 1 )) ; else if(fc[src]==-1) ret= add(ret, mul( k-1, 1, f(sib[src], rem, par_flag, isGreater)) ); else if(sib[src]==-1 && fc[src]==-1)return 1; else { for(ll i=0; i<=rem; i++) /// since parent is secured, i cant secure any child and their value will be less than k { ret= add(ret, mul( k-1, f(fc[src],i, false, false), f(sib[src], rem-i, par_flag, isGreater)) ); } } } return dp[src][rem][par_flag][isGreater]=ret; } int main() { ll u,v; memset(dp, -1,sizeof dp); memset(sib, -1,sizeof sib); memset(fc, -1,sizeof fc); scanf("%lld %lld",&n,&m); for(ll i=1; i<n; i++) { scanf("%lld %lld",&u,&v); edge[u].push_back(v); edge[v].push_back(u); } scanf("%lld %lld",&k,&x); dfs(1,-1); for(ll i=1; i<=n; i++) { seq.clear(); for(ll j=0; j<edge[i].size(); j++) { if(edge[i][j]!=par[i]) seq.push_back(edge[i][j]); } if(seq.size()) fc[i]=seq[0]; for(ll j=0; j+1<(ll)seq.size(); j++) { sib[seq[j]]=seq[j+1]; } } ll res=(ll)f(4,1,0,0); if(res!=0 && k==1) printf("1\n"); else printf("%lld\n",res); return 0; }
[ "musfuq14shohan@gmail.com" ]
musfuq14shohan@gmail.com
94019f6b77be9fc6bac1eeb1b9e0872bcd10d667
a33aac97878b2cb15677be26e308cbc46e2862d2
/program_data/PKU_raw/104/397.c
b51b5181e9b56d27b0984a0334cb150d729ecff0
[]
no_license
GabeOchieng/ggnn.tensorflow
f5d7d0bca52258336fc12c9de6ae38223f28f786
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
refs/heads/master
2022-05-30T11:17:42.278048
2020-05-02T11:33:31
2020-05-02T11:33:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
227
c
int f(int x,int y); int main() { int x,y; cin>>x>>y; cout<<f(x,y); } int f(int x,int y) { if(x==y) return x; if(x>y) { x=x/2; return f(x,y); } if(x<y) { y=y/2; return f(x,y); } }
[ "bdqnghi@gmail.com" ]
bdqnghi@gmail.com
322d29bff33f7e84766179645ac16db1d9973d6e
f59d2742db2582779b60bc8e54a0a6504de39f4d
/a5-peakMeterPlugin/PeakProgramMeterPlugin/Source/PluginProcessor.cpp
bf96e254cb05a1667cdde76c8c151c326120bfb8
[ "MIT" ]
permissive
SomeshGanesh94/MUSI-6106-assignments
06f001756444fa5d03666e26180a0a20576a71c2
784fba4e73bb083012e8982119483a5b755ca91e
refs/heads/master
2021-05-10T10:28:46.693636
2018-04-18T20:44:59
2018-04-18T20:44:59
118,385,769
1
0
null
null
null
null
UTF-8
C++
false
false
6,889
cpp
/* ============================================================================== This file was auto-generated! It contains the basic framework code for a JUCE plugin processor. ============================================================================== */ #include "PluginProcessor.h" #include "PluginEditor.h" //============================================================================== PeakProgramMeterPluginAudioProcessor::PeakProgramMeterPluginAudioProcessor() #ifndef JucePlugin_PreferredChannelConfigurations : AudioProcessor (BusesProperties() #if ! JucePlugin_IsMidiEffect #if ! JucePlugin_IsSynth .withInput ("Input", AudioChannelSet::stereo(), true) #endif .withOutput ("Output", AudioChannelSet::stereo(), true) #endif ) #endif { CPpm::createInstance(m_pCPpm); m_pfVPpm = new float[50]; } PeakProgramMeterPluginAudioProcessor::~PeakProgramMeterPluginAudioProcessor() { CPpm::destroyInstance(m_pCPpm); m_pCPpm = NULL; delete [] m_pfVPpm; m_pfVPpm = NULL; } //============================================================================== const String PeakProgramMeterPluginAudioProcessor::getName() const { return JucePlugin_Name; } bool PeakProgramMeterPluginAudioProcessor::acceptsMidi() const { #if JucePlugin_WantsMidiInput return true; #else return false; #endif } bool PeakProgramMeterPluginAudioProcessor::producesMidi() const { #if JucePlugin_ProducesMidiOutput return true; #else return false; #endif } bool PeakProgramMeterPluginAudioProcessor::isMidiEffect() const { #if JucePlugin_IsMidiEffect return true; #else return false; #endif } double PeakProgramMeterPluginAudioProcessor::getTailLengthSeconds() const { return 0.0; } int PeakProgramMeterPluginAudioProcessor::getNumPrograms() { return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, // so this should be at least 1, even if you're not really implementing programs. } int PeakProgramMeterPluginAudioProcessor::getCurrentProgram() { return 0; } void PeakProgramMeterPluginAudioProcessor::setCurrentProgram (int index) { } const String PeakProgramMeterPluginAudioProcessor::getProgramName (int index) { return {}; } void PeakProgramMeterPluginAudioProcessor::changeProgramName (int index, const String& newName) { } //============================================================================== void PeakProgramMeterPluginAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) { // Use this method as the place to do any pre-playback // initialisation that you need.. m_pCPpm->init(samplesPerBlock, samplesPerBlock, sampleRate, getTotalNumInputChannels()); } void PeakProgramMeterPluginAudioProcessor::releaseResources() { // When playback stops, you can use this as an opportunity to free up any // spare memory, etc. } #ifndef JucePlugin_PreferredChannelConfigurations bool PeakProgramMeterPluginAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const { #if JucePlugin_IsMidiEffect ignoreUnused (layouts); return true; #else // This is the place where you check if the layout is supported. // In this template code we only support mono or stereo. if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) return false; // This checks if the input layout matches the output layout #if ! JucePlugin_IsSynth if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false; #endif return true; #endif } #endif void PeakProgramMeterPluginAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages) { if (m_pCPpm->isInitialized()) { ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); m_pCPpm->setNumChannels(totalNumInputChannels); // In case we have more outputs than inputs, this code clears any output // channels that didn't contain input data, (because these aren't // guaranteed to be empty - they may contain garbage). // This is here to avoid people getting screaming feedback // when they first compile a plugin, but obviously you don't need to keep // this code if your algorithm always overwrites all the output channels. for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear (i, 0, buffer.getNumSamples()); // This is the place where you'd normally do the guts of your plugin's // audio processing... // Make sure to reset the state if your inner loop is processing // the samples and the outer loop is handling the channels. // Alternatively, you can process the samples with the channels // interleaved by keeping the same state. m_pCPpm->process((float **)buffer.getArrayOfReadPointers(), m_pfVPpm, buffer.getNumSamples()); } } //============================================================================== bool PeakProgramMeterPluginAudioProcessor::hasEditor() const { return true; // (change this to false if you choose to not supply an editor) } AudioProcessorEditor* PeakProgramMeterPluginAudioProcessor::createEditor() { return new PeakProgramMeterPluginAudioProcessorEditor (*this); } //============================================================================== void PeakProgramMeterPluginAudioProcessor::getStateInformation (MemoryBlock& destData) { // You should use this method to store your parameters in the memory block. // You could do that either as raw data, or use the XML or ValueTree classes // as intermediaries to make it easy to save and load complex data. } void PeakProgramMeterPluginAudioProcessor::setStateInformation (const void* data, int sizeInBytes) { // You should use this method to restore your parameters from this memory block, // whose contents will have been created by the getStateInformation() call. } //============================================================================== // This creates new instances of the plugin.. AudioProcessor* JUCE_CALLTYPE createPluginFilter() { return new PeakProgramMeterPluginAudioProcessor(); } float* PeakProgramMeterPluginAudioProcessor::getLastMaxPpmValue() { return m_pfVPpm; }
[ "someshganesh94@gmail.com" ]
someshganesh94@gmail.com
02d8c50175db8a12c5e7cd7002e4c5bed4022c22
4a80a82f76982d6b7b57b03097735c7b1ca27b3c
/ext/facter/facter/lib/src/facts/posix/networking_resolver.cc
5b77759d025501ca084fcfa5f2ac131ebfcdc50b
[ "Apache-2.0" ]
permissive
branan/facter.gem
33bb0ccc8a698fe8328ae08abf458ef1ef8b1141
54bee5cb8844d4a717e3fa897be68fd291c62cc3
refs/heads/master
2020-06-17T08:11:39.475470
2016-11-29T02:37:14
2016-11-29T02:37:14
75,015,869
2
0
null
null
null
null
UTF-8
C++
false
false
5,603
cc
#include <internal/facts/posix/networking_resolver.hpp> #include <internal/util/posix/scoped_addrinfo.hpp> #include <leatherman/file_util/file.hpp> #include <leatherman/logging/logging.hpp> #include <boost/algorithm/string.hpp> #include <unistd.h> #include <limits.h> #include <netinet/in.h> #include <arpa/inet.h> using namespace std; using namespace facter::util::posix; namespace lth_file = leatherman::file_util; namespace facter { namespace facts { namespace posix { string networking_resolver::address_to_string(sockaddr const* addr, sockaddr const* mask) const { if (!addr) { return {}; } // Check for IPv4 and IPv6 if (addr->sa_family == AF_INET) { in_addr ip = reinterpret_cast<sockaddr_in const*>(addr)->sin_addr; // Apply an IPv4 mask if (mask && mask->sa_family == addr->sa_family) { ip.s_addr &= reinterpret_cast<sockaddr_in const*>(mask)->sin_addr.s_addr; } char buffer[INET_ADDRSTRLEN] = {}; inet_ntop(AF_INET, &ip, buffer, sizeof(buffer)); return buffer; } else if (addr->sa_family == AF_INET6) { in6_addr ip = reinterpret_cast<sockaddr_in6 const*>(addr)->sin6_addr; // Apply an IPv6 mask if (mask && mask->sa_family == addr->sa_family) { auto mask_ptr = reinterpret_cast<sockaddr_in6 const*>(mask); for (size_t i = 0; i < 16; ++i) { ip.s6_addr[i] &= mask_ptr->sin6_addr.s6_addr[i]; } } char buffer[INET6_ADDRSTRLEN] = {}; inet_ntop(AF_INET6, &ip, buffer, sizeof(buffer)); return buffer; } else if (is_link_address(addr)) { auto link_addr = get_link_address_bytes(addr); if (link_addr) { return macaddress_to_string(reinterpret_cast<uint8_t const*>(link_addr)); } } return {}; } networking_resolver::data networking_resolver::collect_data(collection& facts) { data result; // Get the maximum size of the host name int size = sysconf(_SC_HOST_NAME_MAX); if (size <= 0) { size = 1024; } // Get the hostname (+1 to ensure a null is returned on platforms where maximum truncation may occur) vector<char> name(size + 1); if (gethostname(name.data(), size) != 0) { LOG_WARNING("gethostname failed: {1} ({2}): hostname is unavailable.", strerror(errno), errno); } else { // Check for fully-qualified hostname auto it = find(name.begin(), name.end(), '.'); if (it != name.end()) { LOG_DEBUG("using the FQDN returned by gethostname: {1}.", name.data()); result.hostname.assign(name.begin(), it); if (++it != name.end()) { // Use the remainder of the string, up to the first null character result.domain = &*it; } } else { // Not fully qualified; just set hostname result.hostname = name.data(); } } // If the hostname was not already fully qualified, attempt to resolve it if (result.domain.empty() && !result.hostname.empty()) { // Retrieve the FQDN by resolving the hostname scoped_addrinfo info(result.hostname); if (info.result() != 0 && info.result() != EAI_NONAME) { LOG_WARNING("getaddrinfo failed: {1} ({2}): hostname may not be externally resolvable.", gai_strerror(info.result()), info.result()); } else if (!info || info.result() == EAI_NONAME || result.hostname == static_cast<addrinfo*>(info)->ai_canonname) { LOG_DEBUG("hostname \"{1}\" could not be resolved: hostname may not be externally resolvable.", result.hostname); } else { result.fqdn = static_cast<addrinfo*>(info)->ai_canonname; } // Set the domain name if the FQDN is prefixed with the hostname if (boost::starts_with(result.fqdn, result.hostname + ".")) { result.domain = result.fqdn.substr(result.hostname.size() + 1); } } // If no domain, look it up based on resolv.conf if (result.domain.empty()) { string search; lth_file::each_line("/etc/resolv.conf", [&](string& line) { vector<boost::iterator_range<string::iterator>> parts; boost::split(parts, line, boost::is_space(), boost::token_compress_on); if (parts.size() < 2) { return true; } if (parts[0] == boost::as_literal("domain")) { // Treat the first domain entry as the domain result.domain.assign(parts[1].begin(), parts[1].end()); return false; } if (search.empty() && parts[0] == boost::as_literal("search")) { // Found a "search" entry, but keep looking for other domain entries // We use the first search domain as the domain. search.assign(parts[1].begin(), parts[1].end()); return true; } return true; }); if (result.domain.empty()) { result.domain = move(search); } } return result; } }}} // namespace facter::facts::posix
[ "branan@puppet.com" ]
branan@puppet.com
a00ae4c175217b29ab9bf1dbcf1e3bc45343819b
c51febc209233a9160f41913d895415704d2391f
/YorozuyaGSLib/source/_map_fld.cpp
a1007396231c53da5b4ffb4f47037e5a790b4cb7
[ "MIT" ]
permissive
roussukke/Yorozuya
81f81e5e759ecae02c793e65d6c3acc504091bc3
d9a44592b0714da1aebf492b64fdcb3fa072afe5
refs/heads/master
2023-07-08T03:23:00.584855
2023-06-29T08:20:25
2023-06-29T08:20:25
463,330,454
0
0
MIT
2022-02-24T23:15:01
2022-02-24T23:15:00
null
UTF-8
C++
false
false
346
cpp
#include <_map_fld.hpp> START_ATF_NAMESPACE _map_fld::_map_fld() { using org_ptr = void (WINAPIV*)(struct _map_fld*); (org_ptr(0x140198ff0L))(this); }; void _map_fld::ctor__map_fld() { using org_ptr = void (WINAPIV*)(struct _map_fld*); (org_ptr(0x140198ff0L))(this); }; END_ATF_NAMESPACE
[ "b1ll.cipher@yandex.ru" ]
b1ll.cipher@yandex.ru
29a50bcae9b9d3f6af9346da6df355180efe66b1
b9c286684f5504c8ecb42c142344b0e8495fda24
/software/open_standard/opengl/opengl_tutotial/learn_opengl/1.getting_started/4.textures/4.1.textures/textures.cpp
9618b4980af54edeaae7456ad68aa0b89fb194aa
[]
no_license
qingqinghljin/knowledge
59854f384d98d68812400d25122aacf0309a510e
a639891e3913a505a9ecd0110d3500eed2302921
refs/heads/main
2023-04-03T21:29:48.430952
2021-04-16T17:41:59
2021-04-16T17:41:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,429
cpp
#define STB_IMAGE_IMPLEMENTATION #include <iostream> #include "glad.h" #include <GLFW/glfw3.h> #include "stb_image.h" #include "shader_s.h" void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow *window); // settings window //---------------------------------- const unsigned int SCR_WIDTH = 800; const unsigned int SCR_HEIGHT = 600; //---------------------------------- int main() { // glfw: initialize and configure //------------------------------------------------------------ glfwInit(); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //------------------------------------------------------------ // glfw window creation // ------------------------------------------------------------------------------------- GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL); if (window == NULL) { std::cout << "Failed to create GLFW window" << std::endl; glfwTerminate(); return -1; } glfwMakeContextCurrent(window); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); //----------------------------------------------------------------------------------------- // glad: load all OpenGL function pointers // ----------------------------------------------------------- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { std::cout << "Faild to initialize GLAD" << std::endl; return -1; } // ------------------------------------------------------------ // build and compile our shader program //------------------------------------------------------------- Shader ourShader("4.1.texture.vs", "4.1.texture.fs"); //------------------------------------------------------------- // set up vertex data (and buffers(s) and configure vertex attributes) // ---------------------------------------------------------------------------------------------------------------- float vertices[] = { // positions colors 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, // top right 0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, // bottom right -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // bottom left -0.5f, 0.5f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f // top left }; unsigned int indices[] { // note that we start from 0 0, 1, 3, // first triangle 1, 2, 3 // second triangle }; unsigned int VBO, VAO, EBO; glGenVertexArrays(1, &VAO); glGenBuffers(1, &VBO); glGenBuffers(1, &EBO); // bind the Vertex Array Object first // ---------------------------------- glBindVertexArray(VAO); // ---------------------------------- // bind and set vertex buffer(s) // ---------------------------------------------------------------------- glBindBuffer(GL_ARRAY_BUFFER, VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); // ----------------------------------------------------------------------- // bind and set emement buffer(s) // ---------------------------------------------------------------------- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); // ---------------------------------------------------------------------- // configure vertex attributtes(s) // ---------------------------------------------------------------------------------------- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)(3*sizeof(float))); glEnableVertexAttribArray(1); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8*sizeof(float), (void*)(6*sizeof(float))); glEnableVertexAttribArray(2); // ---------------------------------------------------------------------------------------- // note that this is allowed, the call to glVertexAttribPointer registered VBO as the vertex attribute's // bound vertex buffer object so afterwards we can safely unbind // ------------------------------ // glBindBuffer(GL_ARRAY_BUFFER, 0); // ------------------------------ // You can unbind the VAO afterwards so other VAO calls won't accidentally modify this VAO, but this rarely // happens. VAOs requires a call a glBindVectexArray anyways so we generally don't unbind VAOs (nor VBOs) when // it's not directly neccessary // ------------------ // glBindVertexArray(0); // ------------------ // uncomment this call to draw in wireframe polygons //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); // load and create texture // -------------------------------------------------- unsigned int texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); // all upcoming GL_TEXTURE_2D operations now have effect on this texture object // set the texture wrapping parameters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // set texture wrapping to GL_REPEAT (default wrapping method) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // set texture filtering paramenters glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load image, create texture and generate mipmaps int width, height, nrChannels; // unsigned char *data = stbi_load("/home/hljin/knowledge/graphics/opengl/learn_opengl/resources/textures/container.jpg", &width, &height, &nrChannels, 0); unsigned char *data = stbi_load("./container.jpg", &width, &height, &nrChannels, 0); if (data) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); } else { std::cout << "Faild to load texture" << std::endl; } stbi_image_free(data); // render loop // --------------------------------------------------------------------------------------------------------------- while (!glfwWindowShouldClose(window)) { // input // ------------------ processInput(window); // ------------------ // render // ---------------------------------- glClearColor(0.2f, 0.3f, 0.3f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // ---------------------------------- // bind Texture glBindTexture(GL_TEXTURE_2D, texture); // render container // -------------------------------------------------------------------------------------------------------------- ourShader.use(); //glBindVertexArray(VAO); // seeing as we only have a single VAO there's no need to bind it every time, but we'll // do so to keep things a bit more organized //glDrawArrays(GL_TRIANGLES, 0, 3); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0); // glBindVertexArray(0); // no need to unbind it every time // -------------------------------------------------------------------------------------------------------------- // glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.) // --------------------- glfwSwapBuffers(window); glfwPollEvents(); // --------------------- } // ----------------------------------------------------------------------------------------------------------------- // optional: de-allocate all resources once they've outlived their purpose: // ---------------------------- glDeleteVertexArrays(1, &VAO); glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &EBO); // ---------------------------- // glfw: terminate, clearing all previously allocated GLFW resources // ------------- glfwTerminate(); // ------------- return 0; } // process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly void processInput(GLFWwindow *window) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, true); } // glfw: whenever the window size changed (by OS or user resize) this callback function executes void framebuffer_size_callback(GLFWwindow *window, int width, int height) { // make sure the viewport matches the new window dimensions; note that width and // height will be significantly large than specified on retina displays glViewport(0, 0, width, height); }
[ "18270949493@163.com" ]
18270949493@163.com
d8c574a6f05f3e81ed9e33e657095afd30e0b8e5
2bc7a0e6100d5e4767803bb534879d6a91d961c5
/jsk_mbzirc_tasks/src/uav_detect_landing_region_node.cpp
60f1cb23a21da8ddffd86f0576a6a6ee6cfdb260
[]
no_license
cretaceous-creature/jsk_mbzirc
203c4665e5ff6c69e5d11dfc11b85469e904ea26
ce5bce965f25b9e02276631896534fe74517d9f1
refs/heads/master
2021-01-18T20:48:24.280520
2016-06-03T08:54:51
2016-06-03T08:54:51
48,639,778
0
0
null
2016-11-21T05:45:06
2015-12-27T09:28:03
C++
UTF-8
C++
false
false
11,362
cpp
// Copyright (C) 2016 by Krishneel Chaudhary @ JSK Lab, The University // of Tokyo, Japan #include <jsk_mbzirc_tasks/uav_detect_landing_region.h> UAVLandingRegion::UAVLandingRegion() : down_size_(2), ground_plane_(0.0), track_width_(3.0f), landing_marker_width_(1.5f), min_wsize_(8), nms_thresh_(0.01f) { this->nms_client_ = this->pnh_.serviceClient< jsk_tasks::NonMaximumSuppression>("non_maximum_suppression"); this->svm_ = cv::ml::SVM::create(); //! svm load or save path std::string svm_path; this->pnh_.getParam("svm_path", svm_path); if (svm_path.empty()) { ROS_ERROR("NOT SVM DETECTOR PATH. PROVIDE A VALID PATH"); return; } //! train svm bool is_train = true; if (is_train) { std::string object_data_path; std::string background_dataset_path; this->pnh_.getParam("object_dataset_path", object_data_path); this->pnh_.getParam("background_dataset_path", background_dataset_path); std::string data_path; this->pnh_.getParam("data_directory", data_path); this->trainUAVLandingRegionDetector(data_path, object_data_path, background_dataset_path, svm_path); ROS_INFO("\033[34m-- SVM DETECTOR SUCCESSFULLY TRAINED \033[0m"); } // TODO(BUG): the loaded model doesnot work.... // this->svm_->load(static_cast<std::string>(svm_path)); // this->svm_ = cv::Algorithm::load<cv::ml::SVM>(svm_path); ROS_INFO("\033[34m-- SVM DETECTOR SUCCESSFULLY LOADED \033[0m"); this->onInit(); } void UAVLandingRegion::onInit() { this->subscribe(); this->pub_image_ = pnh_.advertise<sensor_msgs::Image>( "/image", sizeof(char)); this->pub_point_ = pnh_.advertise<geometry_msgs::PointStamped>( "/uav_landing_region/output/point", sizeof(char)); } void UAVLandingRegion::subscribe() { this->sub_image_.subscribe(this->pnh_, "input_image", 1); this->sub_mask_.subscribe(this->pnh_, "input_mask", 1); this->sub_proj_.subscribe(this->pnh_, "input_proj_mat", 1); this->sync_ = boost::make_shared<message_filters::Synchronizer< SyncPolicy> >(100); this->sync_->connectInput( this->sub_image_, this->sub_mask_, this->sub_proj_); this->sync_->registerCallback( boost::bind( &UAVLandingRegion::imageCB, this, _1, _2, _3)); } void UAVLandingRegion::unsubscribe() { this->sub_image_.unsubscribe(); this->sub_mask_.unsubscribe(); } void UAVLandingRegion::imageCB( const sensor_msgs::Image::ConstPtr &image_msg, const sensor_msgs::Image::ConstPtr &mask_msg, const jsk_msgs::ProjectionMatrix::ConstPtr &proj_mat_msg) { cv::Mat image = this->convertImageToMat(image_msg, "bgr8"); cv::Mat im_mask = this->convertImageToMat(mask_msg, "mono8"); if (image.empty() || im_mask.empty()) { ROS_ERROR("EMPTY IMAGE. SKIP LANDING SITE DETECTION"); return; } cv::Size im_downsize = cv::Size(image.cols/this->down_size_, image.rows/this->down_size_); cv::resize(image, image, im_downsize); cv::resize(im_mask, im_mask, im_downsize); cv::Mat detector_path = im_mask.clone(); cv::Size wsize = this->getSlidingWindowSize(*proj_mat_msg); if (wsize.width < this->min_wsize_) { ROS_WARN("HIGH ALTITUDE. SKIPPING DETECTION"); return; } std::cout << "DETECTION" << "\n"; cv::Point2f marker_point = this->traceandDetectLandingMarker( image, im_mask, wsize); if (marker_point.x == -1) { return; } geometry_msgs::PointStamped ros_point = this->pointToWorldCoords( *proj_mat_msg, marker_point.x, marker_point.y); ros_point.header = image_msg->header; this->pub_point_.publish(ros_point); cv_bridge::CvImagePtr pub_msg(new cv_bridge::CvImage); pub_msg->header = image_msg->header; pub_msg->encoding = sensor_msgs::image_encodings::BGR8; pub_msg->image = image.clone(); this->pub_image_.publish(pub_msg); cv::waitKey(5); } cv::Point2f UAVLandingRegion::traceandDetectLandingMarker( cv::Mat img, const cv::Mat marker, const cv::Size wsize) { if (img.empty() || marker.empty() || img.size() != marker.size()) { ROS_ERROR("EMPTY INPUT IMAGE FOR DETECTION"); return cv::Point2f(-1, -1); } // cv::Mat image = marker.clone(); cv::Mat image = img.clone(); if (image.type() != CV_8UC1) { cv::cvtColor(image, image, CV_BGR2GRAY); } cv::Mat im_edge; cv::Canny(image, im_edge, 50, 100); cv::Mat weight = img.clone(); jsk_tasks::NonMaximumSuppression nms_srv; //! 1 - detect #ifdef _OPENMP #pragma omp parallel for num_threads(8) #endif for (int j = 0; j < im_edge.rows; j += 2) { for (int i = 0; i < im_edge.cols; i += 2) { if (static_cast<int>(im_edge.at<uchar>(j, i)) != 0) { cv::Rect rect = cv::Rect(i, j, wsize.width, wsize.height); if (rect.x + rect.width < image.cols && rect.y + rect.height < image.rows) { cv::Mat roi = img(rect).clone(); cv::resize(roi, roi, this->sliding_window_size_); cv::Mat desc = this->extractFeauture(roi); float response = this->svm_->predict(desc); if (response == 1) { jsk_msgs::Rect bbox; bbox.x = rect.x; bbox.y = rect.y; bbox.width = rect.width; bbox.height = rect.height; nms_srv.request.rect.push_back(bbox); nms_srv.request.probabilities.push_back(response); // cv::rectangle(weight, rect, cv::Scalar(0, 255, 0), 1); } } } } } nms_srv.request.threshold = this->nms_thresh_; //! 2 - non_max_suprresion cv::Point2f center = cv::Point2f(-1, -1); if (this->nms_client_.call(nms_srv)) { for (int i = 0; i < nms_srv.response.bbox_count; i++) { cv::Rect_<int> rect = cv::Rect_<int>( nms_srv.response.bbox[i].x, nms_srv.response.bbox[i].y, nms_srv.response.bbox[i].width, nms_srv.response.bbox[i].height); center.x = rect.x + rect.width / 2; center.y = rect.y + rect.height / 2; // for viz cv::Point2f vert1 = cv::Point2f(center.x, center.y - wsize.width); cv::Point2f vert2 = cv::Point2f(center.x, center.y + wsize.width); cv::Point2f hori1 = cv::Point2f(center.x - wsize.width, center.y); cv::Point2f hori2 = cv::Point2f(center.x + wsize.width, center.y); cv::line(weight, vert1, vert2, cv::Scalar(0, 0, 255), 1); cv::line(weight, hori1, hori2, cv::Scalar(0, 0, 255), 1); cv::rectangle(weight, rect, cv::Scalar(0, 255, 0), 1); } } else { ROS_FATAL("NON-MAXIMUM SUPPRESSION SRV NOT CALLED"); return cv::Point2f(-1, -1); } // 3 - return bounding box // TODO(REMOVE OTHER FALSE POSITIVES): HERE? std::string wname = "result"; cv::namedWindow(wname, cv::WINDOW_NORMAL); cv::imshow(wname, weight); return center; } cv::Size UAVLandingRegion::getSlidingWindowSize( const jsk_msgs::ProjectionMatrix projection_matrix) { float A[2][2]; float bv[2]; const int NUM_POINTS = 2; const float pixel_lenght = 10; float init_point = 10; cv::Point2f point[NUM_POINTS]; point[0] = cv::Point2f(init_point, init_point); point[1] = cv::Point2f(init_point + pixel_lenght, init_point + pixel_lenght); cv::Point3_<float> world_coords[NUM_POINTS]; for (int k = 0; k < NUM_POINTS; k++) { int i = static_cast<int>(point[k].y); int j = static_cast<int>(point[k].x); A[0][0] = j * projection_matrix.data.at(8) - projection_matrix.data.at(0); A[0][1] = j * projection_matrix.data.at(9) - projection_matrix.data.at(1); A[1][0] = i * projection_matrix.data.at(8) - projection_matrix.data.at(4); A[1][1] = i * projection_matrix.data.at(9) - projection_matrix.data.at(5); bv[0] = projection_matrix.data.at(2)*ground_plane_ + projection_matrix.data.at(3) - j*projection_matrix.data.at( 10)*ground_plane_ - j*projection_matrix.data.at(11); bv[1] = projection_matrix.data.at(4)*ground_plane_ + projection_matrix.data.at(7) - i*projection_matrix.data.at( 10)*ground_plane_ - i*projection_matrix.data.at(11); float dominator = A[1][1] * A[0][0] - A[0][1] * A[1][0]; world_coords[k].x = (A[1][1]*bv[0]-A[0][1]*bv[1]) / dominator; world_coords[k].y = (A[0][0]*bv[1]-A[1][0]*bv[0]) / dominator; world_coords[k].z = this->ground_plane_; } float world_distance = this->EuclideanDistance(world_coords); float wsize = (pixel_lenght * landing_marker_width_) / world_distance; return cv::Size(static_cast<int>(wsize), static_cast<int>(wsize)); } float UAVLandingRegion::EuclideanDistance( const cv::Point3_<float> *world_coords) { float x = world_coords[1].x - world_coords[0].x; float y = world_coords[1].y - world_coords[0].y; float z = world_coords[1].z - world_coords[0].z; return std::sqrt((std::pow(x, 2) + (std::pow(y, 2)) + (std::pow(z, 2)))); } cv::Mat UAVLandingRegion::convertImageToMat( const sensor_msgs::Image::ConstPtr &image_msg, std::string encoding) { cv_bridge::CvImagePtr cv_ptr; try { cv_ptr = cv_bridge::toCvCopy(image_msg, encoding); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return cv::Mat(); } return cv_ptr->image.clone(); } geometry_msgs::PointStamped UAVLandingRegion::pointToWorldCoords( const jsk_msgs::ProjectionMatrix projection_matrix, const float x, const float y) { float A[2][2]; float bv[2]; int i = static_cast<int>(y); int j = static_cast<int>(x); A[0][0] = j * projection_matrix.data.at(8) - projection_matrix.data.at(0); A[0][1] = j * projection_matrix.data.at(9) - projection_matrix.data.at(1); A[1][0] = i * projection_matrix.data.at(8) - projection_matrix.data.at(4); A[1][1] = i * projection_matrix.data.at(9) - projection_matrix.data.at(5); bv[0] = projection_matrix.data.at(2)*ground_plane_ + projection_matrix.data.at(3) - j*projection_matrix.data.at( 10)*ground_plane_ - j*projection_matrix.data.at(11); bv[1] = projection_matrix.data.at(4)*ground_plane_ + projection_matrix.data.at(7) - i*projection_matrix.data.at( 10)*ground_plane_ - i*projection_matrix.data.at(11); float dominator = A[1][1] * A[0][0] - A[0][1] * A[1][0]; geometry_msgs::PointStamped world_coords; world_coords.point.x = (A[1][1]*bv[0]-A[0][1]*bv[1]) / dominator; world_coords.point.y = (A[0][0]*bv[1]-A[1][0]*bv[0]) / dominator; world_coords.point.z = this->ground_plane_; return world_coords; } int main(int argc, char *argv[]) { ros::init(argc, argv, "jsk_mbzirc_tasks"); UAVLandingRegion ulr; ros::spin(); return 0; }
[ "krishneel.chand.chaudhary@gmail.com" ]
krishneel.chand.chaudhary@gmail.com
72953005c58c053512a4f5be70c8870a7f264da7
2eb7118d391e2a8bf336bd3bdcc021c345d54482
/Event.h
2ea10115a01834a33dbafb2163e5a3c06700511e
[]
no_license
ryonamin/CAINPlus
e8e796119dcb45e50281430d761382177b74b9fb
63af0464d02484433244c3beee8191411d36c0f3
refs/heads/master
2021-07-07T19:14:40.702142
2020-08-05T21:58:37
2020-08-05T21:58:37
164,369,127
0
1
null
null
null
null
UTF-8
C++
false
false
562
h
#ifndef __EVENT_H__ #define __EVENT_H__ const int NMAXPARTICLES = 50000; class Event { public: Event(int ev) : _nEvt(ev) {} int _nEvt; int _nParticles; int _pdg[NMAXPARTICLES]; float _vtx_x[NMAXPARTICLES]; float _vtx_y[NMAXPARTICLES]; float _vtx_z[NMAXPARTICLES]; float _t[NMAXPARTICLES]; float _p_x[NMAXPARTICLES]; float _p_y[NMAXPARTICLES]; float _p_z[NMAXPARTICLES]; float _e[NMAXPARTICLES]; float _s_x[NMAXPARTICLES]; float _s_y[NMAXPARTICLES]; float _s_z[NMAXPARTICLES]; }; #endif
[ "yonamine@epx.phys.tohoku.ac.jp" ]
yonamine@epx.phys.tohoku.ac.jp
fd821a65606f93cb2074d6909b089349f95dbf9f
0ce577bad754c58a376834299e776a13637ed92d
/aaaaa/Range.h
84f1f262717c0f79fdb9c03e061878751cc0bf1a
[]
no_license
Aescosaurus/directx-is-hard
d0b5e30dbb9876698076804b92773bd7a4ae84e1
ac66116b6fbabb92b9a3b7ca11c7325e64c56963
refs/heads/master
2023-01-13T12:15:42.310613
2020-11-06T03:40:39
2020-11-06T03:40:39
310,483,790
0
0
null
null
null
null
UTF-8
C++
false
false
396
h
#pragma once #include "Random.h" #include <algorithm> // suck it windows #undef min #undef max template<typename T> class Range_ { public: Range_( T min,T max ) : min( min ), max( max ) { if( min > max ) std::swap( min,max ); } operator T() const { return( T( Random::Range( min,max ) ) ); } public: T min; T max; }; typedef Range_<float> Range; typedef Range_<int> RangeI;
[ "michaelbuslik@hotmail.com" ]
michaelbuslik@hotmail.com
a540ac483a6ff512df9b20c98451294f39654c22
18673c9ab0f710dcb94f3d6bfe2629cd6eb2d241
/eyrelib/framework/lib/eyre_string.cpp
531b01df2f46e6cc87ee591872685d83636d9613
[]
no_license
Eyre-Turing/tunnel
84bde0903060a8d579826e7b0333780891052458
a846d07cfb7361e837ac75b0a5faead38580dfc0
refs/heads/main
2023-08-27T11:11:01.775173
2021-10-09T12:34:10
2021-10-09T12:34:10
377,362,602
4
0
null
null
null
null
UTF-8
C++
false
false
18,864
cpp
/* * In class String, m_data save as utf-8. * If system using codec gbk, will convert into utf-8. * When need print String in console, * copy and convert into system codec to print. * * Author: Eyre Turing. * Last edit: 2021-01-21 12:12. */ #include "eyre_string.h" #include "general.h" #include <stdio.h> #include <stdlib.h> #include <string> #include <string.h> StringCodec String::codecAutoDef = CODEC_AUTO_DEF; StringCodec String::codecSysDef = CODEC_SYS_DEF; //codec means what str codec is. String::String(const char *str, StringCodec codec) { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *strc = gbkToUtf8(str); m_data = new ByteArray(strc); free(strc); } else if(codec == CODEC_UTF8) { m_data = new ByteArray(str); } else { m_data = new ByteArray(); #if EYRE_DEBUG fprintf(stderr, "String(%p) unknow codec: \'%d\'!\n", this, codec); #endif } #if EYRE_DETAIL fprintf(stdout, "String(%p) created.\n", this); #endif } String::String(const ByteArray &b, StringCodec codec) { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *strc = gbkToUtf8(b.m_data); m_data = new ByteArray(strc); free(strc); } else if(codec == CODEC_UTF8) { //use b.m_data to create, because b may have '\0' before end, so this operation can clean the data after '\0'. m_data = new ByteArray(b.m_data); } else { m_data = new ByteArray(); #if EYRE_DEBUG fprintf(stderr, "String(%p) unknow codec: \'%d\'!\n", this, codec); #endif } #if EYRE_DETAIL fprintf(stdout, "String(%p) created.\n", this); #endif } String::String(const String &s) { m_data = new ByteArray(*(s.m_data)); #if EYRE_DETAIL fprintf(stdout, "String(%p) copy.\n", this); #endif } String::~String() { delete m_data; #if EYRE_DETAIL fprintf(stdout, "String(%p) destroyed.\n", this); #endif } int String::indexOf(const String &s, unsigned int offset) const { return indexOf(s.m_data->m_data, offset, CODEC_UTF8); } /* * Codec is what str codec is. * If codec is UTF8 do nothing and find, * else convert to UTF8 and find. */ int String::indexOf(const char *str, unsigned int offset, StringCodec codec) const { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *strc = gbkToUtf8(str); int result = m_data->indexOf(strc, offset); free(strc); return result; } else if(codec == CODEC_UTF8) { return m_data->indexOf(str, offset); } else { #if EYRE_DEBUG fprintf(stderr, "String(%p) indexOf(const char*, unsigned int, StringCodec) unknow codec: \'%d\'!\n", this, codec); #endif return -1; } } int String::lastIndexOf(const String &s, unsigned int offset) const { return lastIndexOf(s.m_data->m_data, offset, CODEC_UTF8); } int String::lastIndexOf(const char *str, unsigned int offset, StringCodec codec) const { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *strc = gbkToUtf8(str); int result = m_data->lastIndexOf(strc, offset); free(strc); return result; } else if(codec == CODEC_UTF8) { return m_data->lastIndexOf(str, offset); } else { #if EYRE_DEBUG fprintf(stderr, "String(%p) lastIndexOf(const char*, unsigned int, StringCodec) unknow codec: \'%d\'!\n", this, codec); #endif return -1; } } String::operator char*() { return m_data->m_data; } String::operator const char*() const { return (const char *) m_data->m_data; } std::ostream &operator<<(std::ostream &out, const String &s) { //#if (CODEC_SYS_DEF == CODEC_GBK) if(String::codecSysDef == CODEC_GBK) { char *data = utf8ToGbk(s.m_data->m_data); out<<data; free(data); } //#else else { out<<s.m_data->m_data; } //#endif return out; } std::istream &operator>>(std::istream &in, String &s) { std::string input; in>>input; //#if (CODEC_SYS_DEF == CODEC_GBK) if(String::codecSysDef == CODEC_GBK) { char *data = gbkToUtf8(input.c_str()); *(s.m_data) = data; #if EYRE_DETAIL fprintf(stdout, "in>> codec gbk\ninput: %s\nsize: %d\n", data, strlen(data)); #endif free(data); } //#else else { *(s.m_data) = input.c_str(); #if EYRE_DETAIL fprintf(stdout, "in>> codec utf-8\ninput: %s\nsize: %d\n", input.c_str(), input.size()); #endif } //#endif return in; } std::istream &getline(std::istream &in, String &s) { return getline(in, s, '\n'); } std::istream &getline(std::istream &in, String &s, char delim) { std::string input; getline(in, input, delim); //#if (CODEC_SYS_DEF == CODEC_GBK) if(String::codecSysDef == CODEC_GBK) { char *data = gbkToUtf8(input.c_str()); *(s.m_data) = data; free(data); } //#else else { *(s.m_data) = input.c_str(); } //#endif return in; } String &String::operator=(const String &s) { *m_data = *(s.m_data); return *this; } String &String::operator=(const char *str) { //#if (CODEC_AUTO_DEF == CODEC_GBK) if(codecAutoDef == CODEC_GBK) { char *strc = gbkToUtf8(str); *m_data = strc; free(strc); } //#else else { *m_data = str; } //#endif return *this; } String String::fromGbk(const char *str) { return String(str, CODEC_GBK); } String String::fromUtf8(const char *str) { return String(str, CODEC_UTF8); } String String::fromLocal(const char *str) { //#if (CODEC_SYS_DEF == CODEC_GBK) if(codecSysDef == CODEC_GBK) { return fromGbk(str); } //#else else { return fromUtf8(str); } //#endif } bool String::append(const char *str, StringCodec codec) { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *strc = gbkToUtf8(str); bool status = m_data->append(strc); free(strc); return status; } else if(codec == CODEC_UTF8) { return m_data->append(str); } else { #if EYRE_DEBUG fprintf(stderr, "String(%p)::append(const char*, StringCodec) unknow codec: \'%d\'!\n", this, codec); #endif return false; } } bool String::append(const String &s) { return append(s.m_data->m_data, CODEC_UTF8); } bool String::append(char c) { if(c == 0) { #if EYRE_WARNING fprintf(stderr, "warning: try to append 0 to String(%p), reject!\n", this); #endif return false; } else if(c < 0) { #if EYRE_WARNING fprintf(stderr, "warning: try to append invisible char, it\'s easy to miscode.\n"); #endif } return m_data->append(c); } String &String::operator<<(const char *str) { append(str); return *this; } String &String::operator<<(const String &s) { append(s); return *this; } String &String::operator<<(char c) { append(c); return *this; } String &String::operator+=(const char *str) { return (*this)<<str; } String &String::operator+=(const String &s) { return (*this)<<s; } String &String::operator+=(char c) { return (*this)<<c; } bool String::operator==(const char *str) const { //#if (CODEC_AUTO_DEF == CODEC_GBK) if(codecAutoDef == CODEC_GBK) { char *strc = gbkToUtf8(str); bool status = ((*m_data)==strc); free(strc); return status; } //#else else { return (*m_data)==str; } //#endif } bool String::operator==(char *str) const { return (*this)==(const char *) str; } bool String::operator==(const String &s) const { return (*m_data)==(*(s.m_data)); } bool String::operator!=(const char *str) const { return !((*this)==str); } bool String::operator!=(char *str) const { return !((*this)==str); } bool String::operator!=(const String &s) const { return !((*this)==s); } unsigned int String::size() const { return m_data->size(); } String &String::replace(const String &tag, const String &to) { return replace(tag.m_data->m_data, to.m_data->m_data, CODEC_UTF8, CODEC_UTF8); } String &String::replace(const String &tag, const char *to, StringCodec toCodec) { return replace(tag.m_data->m_data, to, CODEC_UTF8, toCodec); } String &String::replace(const char *tag, const String &to, StringCodec tagCodec) { return replace(tag, to.m_data->m_data, tagCodec, CODEC_UTF8); } String &String::replace(const char *tag, const char *to, StringCodec tagCodec, StringCodec toCodec) { if(tagCodec == CODEC_AUTO) { //tagCodec = CODEC_AUTO_DEF; tagCodec = codecAutoDef; } if(toCodec == CODEC_AUTO) { //toCodec = CODEC_AUTO_DEF; toCodec = codecAutoDef; } const char *tagcc; const char *tocc; char *tagc = NULL; char *toc = NULL; if(tagCodec == CODEC_GBK) { tagc = gbkToUtf8(tag); tagcc = (const char *) tagc; } else if(tagCodec == CODEC_UTF8) { tagcc = tag; } else { #if EYRE_DEBUG fprintf(stderr, "String(%p)::replace unknow tagCodec: \'%d\', stop!\n", this, tagCodec); #endif return *this; } if(toCodec == CODEC_GBK) { toc = gbkToUtf8(to); tocc = (const char *) toc; } else if(toCodec == CODEC_UTF8) { tocc = to; } else { #if EYRE_DEBUG fprintf(stderr, "String(%p)::replace unknow toCodec: \'%d\', stop!\n", this, toCodec); #endif return *this; } m_data->replace(tagcc, tocc); free(tagc); free(toc); return *this; //#if (CODEC_AUTO_DEF == CODEC_GBK) // char *tagc = gbkToUtf8(tag); // char *toc = gbkToUtf8(to); // m_data->replace(tagc, toc); // free(tagc); // free(toc); //#else // m_data->replace(tag, to); //#endif // return *this; } String operator+(const String &a, const String &b) { String result(a); result += b; return result; } String::Iterator String::operator[](unsigned int offset) { if(offset > size()) { offset = 0; } return Iterator(this, offset); } String String::mid(unsigned int offset, int size) const { return String(m_data->mid(offset, size), CODEC_UTF8); } //codec is what tag codec is. std::vector<String> String::split(const char *tag, StringCodec codec) const { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } std::vector<String> result; if(codec == CODEC_GBK) { char *tagc = gbkToUtf8(tag); std::vector<ByteArray> bresult = m_data->split(tagc); free(tagc); int bsize = bresult.size(); for(int i=0; i<bsize; ++i) { result.push_back(String(bresult[i], CODEC_UTF8)); } } else if(codec == CODEC_UTF8) { std::vector<ByteArray> bresult = m_data->split(tag); int bsize = bresult.size(); for(int i=0; i<bsize; ++i) { result.push_back(String(bresult[i], CODEC_UTF8)); } } else { #if EYRE_DEBUG fprintf(stderr, "String(%p)::split(const char*, StringCodec) unknow codec: \'%d\'!\n", this, codec); #endif } return result; } std::vector<String> String::split(const String &tag) const { return split(tag.m_data->m_data, CODEC_UTF8); } //codec is what to codec is. String &String::replace(unsigned int offset, unsigned int range, const char *to, StringCodec codec) { if(codec == CODEC_AUTO) { //codec = CODEC_AUTO_DEF; codec = codecAutoDef; } if(codec == CODEC_GBK) { char *toc = gbkToUtf8(to); m_data->replace(offset, range, toc); free(toc); } else if(codec == CODEC_UTF8) { m_data->replace(offset, range, to); } else { #if EYRE_DEBUG fprintf(stderr, "String(%p)::replace(unsigned int, unsigned int, const char*, StringCodec) unknow codec: \'%d\'!\n", this, codec); #endif } return *this; } String &String::replace(unsigned int offset, unsigned int range, const String &to) { return replace(offset, range, to.m_data->m_data, CODEC_UTF8); } String &String::insert(unsigned int offset, const char *to, StringCodec codec) { return replace(offset, 0, to, codec); } String &String::insert(unsigned int offset, const String &to) { return replace(offset, 0, to); } char String::at(unsigned int pos) const { return m_data->at(pos); } bool String::operator<(const String &s) const { return (*m_data)<(*(s.m_data)); } bool String::operator>(const String &s) const { return (*m_data)>(*(s.m_data)); } bool String::operator<=(const String &s) const { return (*m_data)<=(*(s.m_data)); } bool String::operator>=(const String &s) const { return (*m_data)>=(*(s.m_data)); } String::Iterator::Iterator(String *s, unsigned int offset) : m_s(s), m_offset(offset) { #if EYRE_DETAIL fprintf(stdout, "String::Iterator(%p) created.\n", this); #endif } String::Iterator::~Iterator() { #if EYRE_DETAIL fprintf(stdout, "String::Iterator(%p) destroyed.\n", this); #endif } String::Iterator::operator char() const { return m_s->m_data->m_data[m_offset]; } String String::Iterator::operator[](int size) const { return m_s->mid(m_offset, size); } String::Iterator &String::Iterator::operator=(char c) { if(m_offset >= m_s->size()) { #if EYRE_WARNING fprintf(stderr, "warning: try to change end char in String(%p), reject!\n", m_s); #endif return *this; } if(c == 0) { #if EYRE_WARNING fprintf(stderr, "warning: try to set 0 to String(%p), reject!\n", m_s); #endif return *this; } else if((c<0 && m_s->m_data->m_data[m_offset]>0) || (c>0 && m_s->m_data->m_data[m_offset]<0)) { #if EYRE_WARNING fprintf(stderr, "warning: it\'s easy to miscode.\n"); #endif } m_s->m_data->m_data[m_offset] = c; return *this; } //codec is what to codec is. void String::Iterator::replace(unsigned int range, const char *to, StringCodec codec) { m_s->replace(m_offset, range, to, codec); } void String::Iterator::replace(unsigned int range, const String &to) { replace(range, to.m_data->m_data, CODEC_UTF8); } void String::Iterator::insert(const char *to, StringCodec codec) { replace(0, to, codec); } void String::Iterator::insert(const String &to) { replace(0, to); } std::ostream &operator<<(std::ostream &out, const std::vector<String> &sv) { unsigned int size = sv.size(); out<<"StringVector("; for(unsigned int i=0; i<size; ++i) { if(i) { out<<", "; } out<<sv[i]; } out<<")"; return out; } int String::toInt() const { int result = 0; if(sscanf(m_data->m_data, "%d", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toInt fail!\n", this); #endif } return result; } unsigned int String::toUInt() const { unsigned int result = 0; if(sscanf(m_data->m_data, "%u", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toUInt fail!\n", this); #endif } return result; } long long String::toInt64() const { long long result = 0; if(sscanf(m_data->m_data, "%lld", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toInt64 fail!\n", this); #endif } return result; } unsigned long long String::toUInt64() const { unsigned long long result = 0; if(sscanf(m_data->m_data, "%llu", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toUInt64 fail!\n", this); #endif } return result; } float String::toFloat() const { float result = 0; if(sscanf(m_data->m_data, "%f", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toFloat fail!\n", this); #endif } return result; } double String::toDouble() const { double result = 0; if(sscanf(m_data->m_data, "%lf", &result) != 1) { #if EYRE_DEBUG fprintf(stderr, "String(%p)::toDouble fail!\n", this); #endif } return result; } String String::fromNumber(int num) { char temp[128]; sprintf(temp, "%d", num); return String(temp, CODEC_UTF8); } String String::fromNumber(unsigned int num) { char temp[128]; sprintf(temp, "%u", num); return String(temp, CODEC_UTF8); } String String::fromNumber(long long num) { char temp[128]; sprintf(temp, "%lld", num); return String(temp, CODEC_UTF8); } String String::fromNumber(unsigned long long num) { char temp[128]; sprintf(temp, "%llu", num); return String(temp, CODEC_UTF8); } String String::fromNumber(float num) { char temp[128]; sprintf(temp, "%f", num); return String(temp, CODEC_UTF8); } String String::fromNumber(double num) { char temp[128]; sprintf(temp, "%lf", num); return String(temp, CODEC_UTF8); } bool String::chIsNumber(char ch) { return (ch>='0' && ch<='9'); } String String::argFindMinTag() const { int minNumber = 100; int index = -1; int tempNumber; while((index=indexOf("%", index+1, CODEC_UTF8)) != -1) { if(chIsNumber(at(index+1))) { tempNumber = (int)(at(index+1)-'0'); if(tempNumber == 0) { continue; } if(chIsNumber(at(index+2))) { tempNumber *= 10; tempNumber += (int)(at(index+2)-'0'); } if(tempNumber>0 && tempNumber<minNumber) { minNumber = tempNumber; } } } if(minNumber<100 && minNumber>0) { return String("%", CODEC_UTF8)+String::fromNumber(minNumber); } return ""; } String &String::replaceForArg(const String &tag, const char *to, StringCodec codec) { unsigned int tagsize = tag.size(); unsigned int tosize = strlen(to); int index = 0; while((index=indexOf(tag, index)) != -1) { if(tagsize==3 || !chIsNumber(at(index+2))) { replace(index, tagsize, to, codec); index += tosize; } else { index += tagsize; } } return *this; } String &String::replaceForArg(const String &tag, const String &to) { return replaceForArg(tag, to, CODEC_UTF8); } String &String::arg(const char *to, StringCodec codec) { return replaceForArg(argFindMinTag(), to, codec); } String &String::arg(const String &to) { return replaceForArg(argFindMinTag(), to); } String &String::arg(int to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } String &String::arg(unsigned int to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } String &String::arg(long long to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } String &String::arg(unsigned long long to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } String &String::arg(float to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } String &String::arg(double to) { return replaceForArg(argFindMinTag(), String::fromNumber(to)); } void String::setAutoCodec(StringCodec codec) { codecAutoDef = codec; } void String::setLocalCodec(StringCodec codec) { codecSysDef = codec; } StringCodec String::getAutoCodec() { return codecAutoDef; } StringCodec String::getLocalCodec() { return codecSysDef; }
[ "noreply@github.com" ]
noreply@github.com
84d44f7b2747a7afce38bf3c81d1d2c061067f68
8567438779e6af0754620a25d379c348e4cd5a5d
/media/base/win/mf_initializer.h
6a1b6cafd230af7ec208cbf9e2a8bd2a52101898
[ "BSD-3-Clause" ]
permissive
thngkaiyuan/chromium
c389ac4b50ccba28ee077cbf6115c41b547955ae
dab56a4a71f87f64ecc0044e97b4a8f247787a68
refs/heads/master
2022-11-10T02:50:29.326119
2017-04-08T12:28:57
2017-04-08T12:28:57
84,073,924
0
1
BSD-3-Clause
2022-10-25T19:47:15
2017-03-06T13:04:15
null
UTF-8
C++
false
false
493
h
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_BASE_WIN_MF_INITIALIZER_H_ #define MEDIA_BASE_WIN_MF_INITIALIZER_H_ #include "media/base/win/mf_initializer_export.h" namespace media { // Makes sure MFStartup() is called exactly once. MF_INITIALIZER_EXPORT void InitializeMediaFoundation(); } // namespace media #endif // MEDIA_BASE_WIN_MF_INITIALIZER_H_
[ "hedonist.ky@gmail.com" ]
hedonist.ky@gmail.com
41c06b3fa2641cc827a11cfec6dd44ba7a92564e
4472b6cde9ac0feadc12fee9c856eb90a032e5e1
/C++/include/TCASTable.h
87ebd578e8657382f377481aa3603d2d7836fd3e
[ "LicenseRef-scancode-us-govt-public-domain" ]
permissive
johndpope/icarous
3fb4c3cf72ab1d5e676393e380b6da71db848205
6a1ffc94eba053bf186c21997ffac411f8b1cff6
refs/heads/master
2020-06-10T19:53:12.719610
2016-11-29T03:54:23
2016-11-29T03:54:23
75,891,609
1
0
null
2016-12-08T01:38:40
2016-12-08T01:38:40
null
UTF-8
C++
false
false
4,836
h
/* * Copyright (c) 2012-2016 United States Government as represented by * the National Aeronautics and Space Administration. No copyright * is claimed in the United States under Title 17, U.S.Code. All Other * Rights Reserved. */ #ifndef TCASTABLE_H_ #define TCASTABLE_H_ #include "Units.h" #include "ParameterTable.h" #include "ParameterData.h" #include <string> namespace larcfm { class TCASTable : public ParameterTable { private: /* RA Tau in seconds (-1 if N/A) */ static double RA_TAU[7]; static double TA_TAU[7]; double TAU[7]; double TCOA[7]; /* RA DMOD in internal units (-1 if N/A) */ static double RA_DMOD[7]; static double TA_DMOD[7]; double DMOD[7]; /* RA ZTHR in internal units (-1 if N/A) */ static double RA_ZTHR[7]; static double TA_ZTHR[7]; double ZTHR[7]; /* RA HMD in internal units (-1 if N/A) */ static double RA_HMD[7]; double HMD[7]; bool HMDFilter; public: TCASTable(); TCASTable(bool ra); /** Copy constructor */ TCASTable(const TCASTable& t); /* Return SL-2 from alt, which is provided in internal units */ /** Return sensitivity level from alt, specified in internal units */ static int getSensitivityLevel(double alt); /** * Copy values from t to this table. */ void copyValues(const TCASTable& t); void setDefaultRAThresholds(bool ra); /** * Returns TAU threshold for sensitivity level sl in seconds */ double getTAU(int sl) const; double getTAU(int sl, const std::string& u) const; /** * Returns TCOA threshold for sensitivity level sl in seconds */ double getTCOA(int sl) const; double getTCOA(int sl, const std::string& u) const; /** * Returns DMOD for sensitivity level sl in internal units. */ double getDMOD(int sl) const; /** * Returns DMOD for sensitivity level sl in u units. */ double getDMOD(int sl, const std::string& u) const; /** * Returns Z threshold for sensitivity level sl in internal units. */ double getZTHR(int sl) const; /** * Returns Z threshold for sensitivity level sl in u units. */ double getZTHR(int sl, const std::string& u) const; /** * Returns HMD for sensitivity level sl in internal units. */ double getHMD(int sl) const; /** * Returns HMD for sensitivity level sl in u units. */ double getHMD(int sl, const std::string& u) const; /** Modify the value of Tau Threshold for a given sensitivity level (2-8) * Parameter val is given in seconds */ void setTAU(int sl, double val); void setTAU(int sl, double val, const std::string& u); void setTAU(double val, const std::string& u); /** Modify the value of TCOA Threshold for a given sensitivity level (2-8) * Parameter val is given in seconds */ void setTCOA(int sl, double val); void setTCOA(int sl, double val, const std::string& u); void setTCOA(double val, const std::string& u); /** Modify the value of DMOD for a given sensitivity level (2-8) * Parameter val is given in internal units */ void setDMOD(int sl, double val); /** Modify the value of DMOD for a given sensitivity level (2-8) * Parameter val is given in u units */ void setDMOD(int sl, double val, const std::string& u); /** * Modify the value of DMOD for all sensitivity levels */ void setDMOD(double val, const std::string& u); /** Modify the value of ZTHR for a given sensitivity level (2-8) * Parameter val is given in internal units */ void setZTHR(int sl, double val); /** Modify the value of ZTHR for a given sensitivity level (2-8) * Parameter val is given in u units */ void setZTHR(int sl, double val, const std::string& u); /** * Modify the value of ZTHR for all sensitivity levels */ void setZTHR(double val, const std::string& u); /** * Modify the value of HMD for a given sensitivity level (2-8) * Parameter val is given in internal units */ void setHMD(int sl, double val); /** * Modify the value of HMD for a given sensitivity level (2-8) * Parameter val is given in u units */ void setHMD(int sl, double val, const std::string& u); /** * Modify the value of HMD for all sensitivity levels */ void setHMD(double val, const std::string& u); void setHMDFilter(bool flag); bool getHMDFilter() const; /** Return true if the values in the table correspond to the standard RA values */ bool isRAStandard() const; /** Return true if the values in the table correspond to the standard TA values */ bool isTAStandard() const; ParameterData getParameters() const; void updateParameterData(ParameterData& p) const; void setParameters(const ParameterData& p); bool equals(const TCASTable& t2) const; std::string toString() const; std::string toPVS(int prec) const; bool contains(const TCASTable& tab) const; }; } #endif
[ "cesaramh@gmail.com" ]
cesaramh@gmail.com
8b6b101bb7fa6804739c684ca1bd51ef9f7d1feb
6e96c139c56425283338c14eb753d476fc2e648e
/libraries/contract-engine/engine/chain/apply_context.cpp
1e108d9266c1d8efe9dbf77b6ec3ea73682279e1
[ "MIT" ]
permissive
AAAChain/AAAChain
9b437f5c7aed51f49ae183ebf3db35ce18fd39dc
42929fe8d165c13e79e8fb7215d0918620a499e2
refs/heads/master
2020-03-14T03:21:31.958576
2018-08-24T22:54:21
2018-08-24T22:54:21
131,417,972
3
0
null
null
null
null
UTF-8
C++
false
false
24,109
cpp
#include <algorithm> #include <eosio/chain/apply_context.hpp> #include <eosio/chain/chain_controller.hpp> #include <eosio/chain/wasm_interface.hpp> #include <eosio/chain/generated_transaction_object.hpp> #include <eosio/chain/scope_sequence_object.hpp> #include <boost/container/flat_set.hpp> using boost::container::flat_set; namespace eosio { namespace chain { void apply_context::exec_one() { auto start = fc::time_point::now(); _cpu_usage = 0; try { const auto &a = mutable_controller.get_database().get<account_object, by_name>(receiver); privileged = a.privileged; auto native = mutable_controller.find_apply_handler(receiver, act.account, act.name); if (native) { (*native)(*this); } if (a.code.size() > 0 && !(act.name == N(setcode) && act.account == config::system_account_name)) { try { mutable_controller.get_wasm_interface().apply(a.code_version, a.code, *this); } catch ( const wasm_exit& ){} } } FC_CAPTURE_AND_RETHROW((_pending_console_output.str())); if (!_write_scopes.empty()) { std::sort(_write_scopes.begin(), _write_scopes.end()); } if (!_read_locks.empty()) { std::sort(_read_locks.begin(), _read_locks.end()); // remove any write_scopes auto r_iter = _read_locks.begin(); for( auto w_iter = _write_scopes.cbegin(); (w_iter != _write_scopes.cend()) && (r_iter != _read_locks.end()); ++w_iter) { shard_lock w_lock = {receiver, *w_iter}; while(r_iter != _read_locks.end() && *r_iter < w_lock ) { ++r_iter; } if (*r_iter == w_lock) { r_iter = _read_locks.erase(r_iter); } } } // create a receipt for this vector<data_access_info> data_access; data_access.reserve(_write_scopes.size() + _read_locks.size()); for (const auto& scope: _write_scopes) { auto key = boost::make_tuple(scope, receiver); const auto& scope_sequence = mutable_controller.get_database().find<scope_sequence_object, by_scope_receiver>(key); if (scope_sequence == nullptr) { try { mutable_controller.get_mutable_database().create<scope_sequence_object>([&](scope_sequence_object &ss) { ss.scope = scope; ss.receiver = receiver; ss.sequence = 1; }); } FC_CAPTURE_AND_RETHROW((scope)(receiver)); data_access.emplace_back(data_access_info{data_access_info::write, receiver, scope, 0}); } else { data_access.emplace_back(data_access_info{data_access_info::write, receiver, scope, scope_sequence->sequence}); try { mutable_controller.get_mutable_database().modify(*scope_sequence, [&](scope_sequence_object& ss) { ss.sequence += 1; }); } FC_CAPTURE_AND_RETHROW((scope)(receiver)); } } for (const auto& lock: _read_locks) { auto key = boost::make_tuple(lock.scope, lock.account); const auto& scope_sequence = mutable_controller.get_database().find<scope_sequence_object, by_scope_receiver>(key); if (scope_sequence == nullptr) { data_access.emplace_back(data_access_info{data_access_info::read, lock.account, lock.scope, 0}); } else { data_access.emplace_back(data_access_info{data_access_info::read, lock.account, lock.scope, scope_sequence->sequence}); } } results.applied_actions.emplace_back(action_trace {receiver, context_free, _cpu_usage, act, _pending_console_output.str(), move(data_access)}); _pending_console_output = std::ostringstream(); _read_locks.clear(); _write_scopes.clear(); results.applied_actions.back()._profiling_us = fc::time_point::now() - start; } void apply_context::exec() { _notified.push_back(act.account); for( uint32_t i = 0; i < _notified.size(); ++i ) { receiver = _notified[i]; exec_one(); } for( uint32_t i = 0; i < _cfa_inline_actions.size(); ++i ) { EOS_ASSERT( recurse_depth < config::max_recursion_depth, transaction_exception, "inline action recursion depth reached" ); apply_context ncontext( mutable_controller, mutable_db, _cfa_inline_actions[i], trx_meta, recurse_depth + 1 ); ncontext.context_free = true; ncontext.exec(); append_results(move(ncontext.results)); } for( uint32_t i = 0; i < _inline_actions.size(); ++i ) { EOS_ASSERT( recurse_depth < config::max_recursion_depth, transaction_exception, "inline action recursion depth reached" ); apply_context ncontext( mutable_controller, mutable_db, _inline_actions[i], trx_meta, recurse_depth + 1 ); ncontext.exec(); append_results(move(ncontext.results)); } } /// exec() bool apply_context::is_account( const account_name& account )const { return nullptr != db.find<account_object,by_name>( account ); } bool apply_context::all_authorizations_used()const { for ( bool has_auth : used_authorizations ) { if ( !has_auth ) return false; } return true; } vector<permission_level> apply_context::unused_authorizations()const { vector<permission_level> ret_auths; for ( uint32_t i=0; i < act.authorization.size(); i++ ) if ( !used_authorizations[i] ) ret_auths.push_back( act.authorization[i] ); return ret_auths; } void apply_context::require_authorization( const account_name& account ) { for( uint32_t i=0; i < act.authorization.size(); i++ ) { if( act.authorization[i].actor == account ) { used_authorizations[i] = true; return; } } EOS_ASSERT( false, tx_missing_auth, "missing authority of ${account}", ("account",account)); } bool apply_context::has_authorization( const account_name& account )const { for( const auto& auth : act.authorization ) if( auth.actor == account ) return true; return false; } void apply_context::require_authorization(const account_name& account, const permission_name& permission) { for( uint32_t i=0; i < act.authorization.size(); i++ ) if( act.authorization[i].actor == account ) { if( act.authorization[i].permission == permission ) { used_authorizations[i] = true; return; } } EOS_ASSERT( false, tx_missing_auth, "missing authority of ${account}/${permission}", ("account",account)("permission",permission) ); } static bool scopes_contain(const vector<scope_name>& scopes, const scope_name& scope) { return std::find(scopes.begin(), scopes.end(), scope) != scopes.end(); } static bool locks_contain(const vector<shard_lock>& locks, const account_name& account, const scope_name& scope) { return std::find(locks.begin(), locks.end(), shard_lock{account, scope}) != locks.end(); } void apply_context::require_write_lock(const scope_name& scope) { if (trx_meta.allowed_write_locks) { EOS_ASSERT( locks_contain(**trx_meta.allowed_write_locks, receiver, scope), block_lock_exception, "write lock \"${a}::${s}\" required but not provided", ("a", receiver)("s",scope) ); } if (!scopes_contain(_write_scopes, scope)) { _write_scopes.emplace_back(scope); } } void apply_context::require_read_lock(const account_name& account, const scope_name& scope) { if (trx_meta.allowed_read_locks || trx_meta.allowed_write_locks ) { bool locked_for_read = trx_meta.allowed_read_locks && locks_contain(**trx_meta.allowed_read_locks, account, scope); if (!locked_for_read && trx_meta.allowed_write_locks) { locked_for_read = locks_contain(**trx_meta.allowed_write_locks, account, scope); } EOS_ASSERT( locked_for_read , block_lock_exception, "read lock \"${a}::${s}\" required but not provided", ("a", account)("s",scope) ); } if (!locks_contain(_read_locks, account, scope)) { _read_locks.emplace_back(shard_lock{account, scope}); } } bool apply_context::has_recipient( account_name code )const { for( auto a : _notified ) if( a == code ) return true; return false; } void apply_context::require_recipient( account_name code ) { if( !has_recipient(code) ) _notified.push_back(code); } /** * This will execute an action after checking the authorization. Inline transactions are * implicitly authorized by the current receiver (running code). This method has significant * security considerations and several options have been considered: * * 1. priviledged accounts (those marked as such by block producers) can authorize any action * 2. all other actions are only authorized by 'receiver' which means the following: * a. the user must set permissions on their account to allow the 'receiver' to act on their behalf * * Discarded Implemenation: at one point we allowed any account that authorized the current transaction * to implicitly authorize an inline transaction. This approach would allow privelege escalation and * make it unsafe for users to interact with certain contracts. We opted instead to have applications * ask the user for permission to take certain actions rather than making it implicit. This way users * can better understand the security risk. */ void apply_context::execute_inline( action&& a ) { if ( !privileged ) { if( a.account != receiver ) { const auto delay = controller.check_authorization({a}, flat_set<public_key_type>(), false, {receiver}); FC_ASSERT( trx_meta.published + delay <= controller.head_block_time(), "inline action uses a permission that imposes a delay that is not met, set delay_sec in transaction header to at least ${delay} seconds", ("delay", delay.to_seconds()) ); } } _inline_actions.emplace_back( move(a) ); } void apply_context::execute_context_free_inline( action&& a ) { FC_ASSERT( a.authorization.size() == 0, "context free actions cannot have authorizations" ); _cfa_inline_actions.emplace_back( move(a) ); } void apply_context::execute_deferred( deferred_transaction&& trx ) { try { trx.set_reference_block(controller.head_block_id()); // No TaPoS check necessary trx.sender = receiver; controller.validate_transaction_without_state(trx); // transaction_api::send_deferred guarantees that trx.execute_after is at least head block time, so no need to check expiration. // Any other called of this function needs to similarly meet that precondition. EOS_ASSERT( trx.execute_after < trx.expiration, transaction_exception, "Transaction expires at ${trx.expiration} which is before the first allowed time to execute at ${trx.execute_after}", ("trx.expiration",trx.expiration)("trx.execute_after",trx.execute_after) ); controller.validate_expiration_not_too_far(trx, trx.execute_after); controller.validate_referenced_accounts(trx); controller.validate_uniqueness(trx); // TODO: Move this out of here when we have concurrent shards to somewhere we can check for conflicts between shards. const auto& gpo = controller.get_global_properties(); FC_ASSERT( results.deferred_transactions_count < gpo.configuration.max_generated_transaction_count ); fc::microseconds delay; // privileged accounts can do anything, no need to check auth if( !privileged ) { // check to make sure the payer has authorized this deferred transaction's storage in RAM if (trx.payer != receiver) { require_authorization(trx.payer); } if (trx.payer != receiver) { require_authorization(trx.payer); } // if a contract is deferring only actions to itself then there is no need // to check permissions, it could have done everything anyway. bool check_auth = false; for( const auto& act : trx.actions ) { if( act.account != receiver ) { check_auth = true; break; } } if( check_auth ) { delay = controller.check_authorization(trx.actions, flat_set<public_key_type>(), false, {receiver}); FC_ASSERT( trx_meta.published + delay <= controller.head_block_time(), "deferred transaction uses a permission that imposes a delay that is not met, set delay_sec in transaction header to at least ${delay} seconds", ("delay", delay.to_seconds()) ); } } auto now = controller.head_block_time(); if( delay.count() ) { auto min_execute_after_time = time_point_sec(now + delay + fc::microseconds(999'999)); // rounds up nearest second EOS_ASSERT( min_execute_after_time <= trx.execute_after, transaction_exception, "deferred transaction is specified to execute after ${trx.execute_after} which is earlier than the earliest time allowed by authorization checker", ("trx.execute_after",trx.execute_after)("min_execute_after_time",min_execute_after_time) ); } results.deferred_transaction_requests.push_back(move(trx)); results.deferred_transactions_count++; } FC_CAPTURE_AND_RETHROW((trx)); } void apply_context::cancel_deferred( const uint128_t& sender_id ) { results.deferred_transaction_requests.push_back(deferred_reference(receiver, sender_id)); } const contracts::table_id_object* apply_context::find_table( name code, name scope, name table ) { require_read_lock(code, scope); return db.find<table_id_object, contracts::by_code_scope_table>(boost::make_tuple(code, scope, table)); } const contracts::table_id_object& apply_context::find_or_create_table( name code, name scope, name table, const account_name &payer ) { require_read_lock(code, scope); const auto* existing_tid = db.find<contracts::table_id_object, contracts::by_code_scope_table>(boost::make_tuple(code, scope, table)); if (existing_tid != nullptr) { return *existing_tid; } require_write_lock(scope); update_db_usage(payer, config::billable_size_v<contracts::table_id_object>); return mutable_db.create<contracts::table_id_object>([&](contracts::table_id_object &t_id){ t_id.code = code; t_id.scope = scope; t_id.table = table; t_id.payer = payer; }); } void apply_context::remove_table( const contracts::table_id_object& tid ) { update_db_usage(tid.payer, - config::billable_size_v<contracts::table_id_object>); mutable_db.remove(tid); } vector<account_name> apply_context::get_active_producers() const { const auto& gpo = controller.get_global_properties(); vector<account_name> accounts; for(const auto& producer : gpo.active_producers.producers) accounts.push_back(producer.producer_name); return accounts; } void apply_context::checktime(uint32_t instruction_count) { if (trx_meta.processing_deadline && fc::time_point::now() > (*trx_meta.processing_deadline)) { throw checktime_exceeded(); } _cpu_usage += instruction_count; } const bytes& apply_context::get_packed_transaction() { if( !trx_meta.packed_trx.size() ) { if (_cached_trx.empty()) { auto size = fc::raw::pack_size(trx_meta.trx()); _cached_trx.resize(size); fc::datastream<char *> ds(_cached_trx.data(), size); fc::raw::pack(ds, trx_meta.trx()); } return _cached_trx; } return trx_meta.packed_trx; } void apply_context::update_db_usage( const account_name& payer, int64_t delta ) { require_write_lock( payer ); if( (delta > 0) ) { if (!(privileged || payer == account_name(receiver))) { require_authorization( payer ); } mutable_controller.get_mutable_resource_limits_manager().add_pending_account_ram_usage(payer, delta); } } int apply_context::get_action( uint32_t type, uint32_t index, char* buffer, size_t buffer_size )const { const transaction& trx = trx_meta.trx(); const action* act = nullptr; if( type == 0 ) { if( index >= trx.context_free_actions.size() ) return -1; act = &trx.context_free_actions[index]; } else if( type == 1 ) { if( index >= trx.actions.size() ) return -1; act = &trx.actions[index]; } else if( type == 2 ) { if( index >= _cfa_inline_actions.size() ) return -1; act = &_cfa_inline_actions[index]; } else if( type == 3 ) { if( index >= _inline_actions.size() ) return -1; act = &_inline_actions[index]; } auto ps = fc::raw::pack_size( *act ); if( ps <= buffer_size ) { fc::datastream<char*> ds(buffer, buffer_size); fc::raw::pack( ds, *act ); } return ps; } int apply_context::get_context_free_data( uint32_t index, char* buffer, size_t buffer_size )const { if( index >= trx_meta.context_free_data.size() ) return -1; auto s = trx_meta.context_free_data[index].size(); if( buffer_size == 0 ) return s; if( buffer_size < s ) memcpy( buffer, trx_meta.context_free_data[index].data(), buffer_size ); else memcpy( buffer, trx_meta.context_free_data[index].data(), s ); return s; } void apply_context::check_auth( const transaction& trx, const vector<permission_level>& perm ) { controller.check_authorization( trx.actions, {}, true, {}, flat_set<permission_level>(perm.begin(), perm.end()) ); } int apply_context::db_store_i64( uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) { return db_store_i64( receiver, scope, table, payer, id, buffer, buffer_size); } int apply_context::db_store_i64( uint64_t code, uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) { require_write_lock( scope ); const auto& tab = find_or_create_table( code, scope, table, payer ); auto tableid = tab.id; FC_ASSERT( payer != account_name(), "must specify a valid account to pay for new record" ); const auto& obj = mutable_db.create<key_value_object>( [&]( auto& o ) { o.t_id = tableid; o.primary_key = id; o.value.resize( buffer_size ); o.payer = payer; memcpy( o.value.data(), buffer, buffer_size ); }); mutable_db.modify( tab, [&]( auto& t ) { ++t.count; }); int64_t billable_size = (int64_t)(buffer_size + config::billable_size_v<key_value_object>); update_db_usage( payer, billable_size); keyval_cache.cache_table( tab ); return keyval_cache.add( obj ); } void apply_context::db_update_i64( int iterator, account_name payer, const char* buffer, size_t buffer_size ) { const key_value_object& obj = keyval_cache.get( iterator ); const auto& tab = keyval_cache.get_table( obj.t_id ); require_write_lock( tab.scope ); const int64_t overhead = config::billable_size_v<key_value_object>; int64_t old_size = (int64_t)(obj.value.size() + overhead); int64_t new_size = (int64_t)(buffer_size + overhead); if( payer == account_name() ) payer = obj.payer; if( account_name(obj.payer) != payer ) { // refund the existing payer update_db_usage( obj.payer, -(old_size) ); // charge the new payer update_db_usage( payer, (new_size)); } else if(old_size != new_size) { // charge/refund the existing payer the difference update_db_usage( obj.payer, new_size - old_size); } mutable_db.modify( obj, [&]( auto& o ) { o.value.resize( buffer_size ); memcpy( o.value.data(), buffer, buffer_size ); o.payer = payer; }); } void apply_context::db_remove_i64( int iterator ) { const key_value_object& obj = keyval_cache.get( iterator ); update_db_usage( obj.payer, -(obj.value.size() + config::billable_size_v<key_value_object>) ); const auto& table_obj = keyval_cache.get_table( obj.t_id ); require_write_lock( table_obj.scope ); mutable_db.modify( table_obj, [&]( auto& t ) { --t.count; }); mutable_db.remove( obj ); if (table_obj.count == 0) { remove_table(table_obj); } keyval_cache.remove( iterator ); } int apply_context::db_get_i64( int iterator, char* buffer, size_t buffer_size ) { const key_value_object& obj = keyval_cache.get( iterator ); memcpy( buffer, obj.value.data(), std::min(obj.value.size(), buffer_size) ); return obj.value.size(); } int apply_context::db_next_i64( int iterator, uint64_t& primary ) { if( iterator < -1 ) return -1; // cannot increment past end iterator of table const auto& obj = keyval_cache.get( iterator ); // Check for iterator != -1 happens in this call const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>(); auto itr = idx.iterator_to( obj ); ++itr; if( itr == idx.end() || itr->t_id != obj.t_id ) return keyval_cache.get_end_iterator_by_table_id(obj.t_id); primary = itr->primary_key; return keyval_cache.add( *itr ); } int apply_context::db_previous_i64( int iterator, uint64_t& primary ) { const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>(); if( iterator < -1 ) // is end iterator { auto tab = keyval_cache.find_table_by_end_iterator(iterator); FC_ASSERT( tab, "not a valid end iterator" ); auto itr = idx.upper_bound(tab->id); if( idx.begin() == idx.end() || itr == idx.begin() ) return -1; // Empty table --itr; if( itr->t_id != tab->id ) return -1; // Empty table primary = itr->primary_key; return keyval_cache.add(*itr); } const auto& obj = keyval_cache.get(iterator); // Check for iterator != -1 happens in this call auto itr = idx.iterator_to(obj); if( itr == idx.begin() ) return -1; // cannot decrement past beginning iterator of table --itr; if( itr->t_id != obj.t_id ) return -1; // cannot decrement past beginning iterator of table primary = itr->primary_key; return keyval_cache.add(*itr); } int apply_context::db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) { require_read_lock( code, scope ); // redundant? const auto* tab = find_table( code, scope, table ); if( !tab ) return -1; auto table_end_itr = keyval_cache.cache_table( *tab ); const key_value_object* obj = db.find<key_value_object, contracts::by_scope_primary>( boost::make_tuple( tab->id, id ) ); if( !obj ) return table_end_itr; return keyval_cache.add( *obj ); } int apply_context::db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) { require_read_lock( code, scope ); // redundant? const auto* tab = find_table( code, scope, table ); if( !tab ) return -1; auto table_end_itr = keyval_cache.cache_table( *tab ); const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>(); auto itr = idx.lower_bound( boost::make_tuple( tab->id, id ) ); if( itr == idx.end() ) return table_end_itr; if( itr->t_id != tab->id ) return table_end_itr; return keyval_cache.add( *itr ); } int apply_context::db_upperbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) { require_read_lock( code, scope ); // redundant? const auto* tab = find_table( code, scope, table ); if( !tab ) return -1; auto table_end_itr = keyval_cache.cache_table( *tab ); const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>(); auto itr = idx.upper_bound( boost::make_tuple( tab->id, id ) ); if( itr == idx.end() ) return table_end_itr; if( itr->t_id != tab->id ) return table_end_itr; return keyval_cache.add( *itr ); } int apply_context::db_end_i64( uint64_t code, uint64_t scope, uint64_t table ) { require_read_lock( code, scope ); // redundant? const auto* tab = find_table( code, scope, table ); if( !tab ) return -1; return keyval_cache.cache_table( *tab ); } } } /// eosio::chain
[ "zxg_2002@hotmail.com" ]
zxg_2002@hotmail.com
457fd279ab3ecee322960f5307882d7f1fa7f06a
720b965b4a33110b6ecd125870245f9899c40073
/Object.h
d6a64a8e9251047bfb4db9a2c5c41645b88728df
[]
no_license
theGioiLa/Document
ded6613342932a02d0851e0affc4195da67c97e2
8456e69db579ead0731390db02e9001830325ede
refs/heads/master
2021-09-17T22:59:23.080342
2018-07-06T11:28:35
2018-07-06T11:28:35
115,406,387
0
0
null
null
null
null
UTF-8
C++
false
false
1,481
h
#pragma once #include "Model.h" #include "Texture.h" #include "ResourceManager.h" #include <vector> class Object { protected: GLuint m_Id; Model* m_pModel; std::vector<Texture*> m_LTextures; std::vector<Texture*> m_LCubTexes; Shaders* m_pShader; ResourceManager* resourceManager; Vector3 m_Scale; Vector3 m_RotationalAngle; Vector3 m_Position; Matrix m_TransformMtx; GLint texcoordAttribute; GLint texcoordUniform; void DrawObj(); void DrawEnv(); public: Object(GLuint id) : m_Id(id), m_Scale(Vector3(1, 1, 1)), m_RotationalAngle(Vector3(0, 0, 0)), m_Position(Vector3(0, 0, 0)) { resourceManager = ResourceManager::GetInstance(); } Object() : m_Scale(Vector3(1, 1, 1)), m_RotationalAngle(Vector3(0, 0, 0)), m_Position(Vector3(0, 0, 0)) { resourceManager = ResourceManager::GetInstance(); } int Init(); void Draw(); void SetModel(GLuint modelId); void SetTextures(std::vector<int> texturesID); void SetCubeTex(std::vector<int> cubeTexesId); void SetShader(GLuint shaderId); void SetScale(Vector3 vScale) { m_Scale = vScale; } void SetRotationAngle(Vector3 vRotation) { m_RotationalAngle = ToRadian(vRotation); } Vector3 ToRadian(Vector3 angle) { angle *= 3.14 / 180; return angle; } void SetTranslation(Vector3 position) { m_Position = position; } void UpdateTransformMatrix(Matrix viewMatrix, Matrix projectionMatrix); };
[ "noreply@github.com" ]
noreply@github.com
197fdf023183fcc67258d0553cc33c72243234ec
428e691ab362be864999fde4068d6e8314278707
/Constructibles.cpp
eb41907affd754e5a58582a3f9de8bcc7930cfe3
[]
no_license
ECN-SEC-SMP/projet2021-debeire-furet-nombalay-haon
a3904e84d7e255705439ab0311eecbac15698a8f
96971b37699ff457779fee39ad36d45e2db212ff
refs/heads/master
2023-04-13T05:34:36.907321
2021-04-25T21:13:04
2021-04-25T21:13:04
358,585,528
1
2
null
2021-04-16T14:35:43
2021-04-16T12:03:41
Makefile
UTF-8
C++
false
false
1,359
cpp
#include <iostream> #include "Case.h" #include "Achetables.h" #include "Constructibles.h" using namespace std; //constructeur Constructibles::Constructibles(string nom, int id, int prix, int loyer) : Achetables(nom, id){ this->prix = prix; this->loyer = loyer; this->proprietaire = nullptr; this->nbMaisons = 0; this->nbHotels = 0; } //ajoute de 1 à 4 maisons à la case //la vérification du nombre de maisons pour ne pas dépasser 4 est fait avant cette méthode void Constructibles::ajouterMaison(int nb){ nbMaisons += nb; } //ajoute 1 hotel à la case //vérification si l'ajout d'un hotel est possible avant l'appel à cette méthode void Constructibles::ajouterHotel(){ if (nbHotels != 1) nbHotels ++; } //calcule le loyer //si le joueur ne possède aucune maison ni aucun hotel alors le loyer est de 60% le prix de base //si le joueur possède 1 ou plusieurs maisons le loyer est de 60% le prix de base + 10% du prix de base par maison //si le joueur possède un hotel le loyer est de 150% le prix de base int Constructibles::calculLoyer(){ if(nbMaisons == 0 && nbHotels == 0) return prix * 0.6; else if(nbMaisons != 0 && nbHotels == 0){ return prix * (0.6 + 0.1 * nbMaisons); } else if(nbMaisons == 0 && nbHotels == 1) return (prix + prix * 0.5); }
[ "" ]
367ddaa5549b7e19cbd6589ff39fbb24e21d1b1c
49dc9b1bcd649ed07b1bfce517d192031bde6640
/Old CodeBook/bign.cpp
c5e5f07b65280ba68d1176bca9665a6e8a8bdde9
[]
no_license
mirokuxy/Codebook
4f04b7da6aad6b5c40b89622613fe5e73588bc5a
061786d5cf97388c9cc370dddf0a5568fb76adc9
refs/heads/master
2021-01-10T21:30:10.768819
2016-11-15T07:41:37
2016-11-15T07:41:37
32,563,173
0
0
null
null
null
null
UTF-8
C++
false
false
3,453
cpp
#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; const int maxn = 200; struct bign{ int len, s[maxn]; bign() { memset(s, 0, sizeof(s)); len = 1; } bign(int num) { *this = num; } bign(const char* num) { *this = num; } bign operator = (int num) { char s[maxn]; sprintf(s, "%d", num); *this = s; return *this; } bign operator = (const char* num) { len = strlen(num); for(int i = 0; i < len; i++) s[i] = num[len-i-1] - '0'; return *this; } string str() const { string res = ""; for(int i = 0; i < len; i++) res = (char)(s[i] + '0') + res; if(res == "") res = "0"; return res; } bign operator + (const bign& b) const{ bign c; c.len = 0; for(int i = 0, g = 0; g || i < max(len, b.len); i++) { int x = g; if(i < len) x += s[i]; if(i < b.len) x += b.s[i]; c.s[c.len++] = x % 10; g = x / 10; } return c; } void clean() { while(len > 1 && !s[len-1]) len--; } bign operator * (const bign& b) { bign c; c.len = len + b.len; for(int i = 0; i < len; i++) for(int j = 0; j < b.len; j++) c.s[i+j] += s[i] * b.s[j]; for(int i = 0; i < c.len-1; i++){ c.s[i+1] += c.s[i] / 10; c.s[i] %= 10; } c.clean(); return c; } bign operator - (const bign& b) { bign c; c.len = 0; for(int i = 0, g = 0; i < len; i++) { int x = s[i] - g; if(i < b.len) x -= b.s[i]; if(x >= 0) g = 0; else { g = 1; x += 10; } c.s[c.len++] = x; } c.clean(); return c; } bign operator / (const int b) { bign c; c.len = 1; long long g = 0; int flag = 0; for(int i=len-1; i>=0; i--){ g = g*10 + s[i]; if(g < b) if(!flag) continue; else c.s[i] = 0; else{ if(!flag) { flag = 1; c.len = i+1; } c.s[i] = g/b; g %= b; } } return c; } bign operator % (const int b) { return *this - *this / b * b; } bign operator += (const bign& b) { *this = *this + b; return *this; } bign operator -= (const bign& b) { *this = *this - b; return *this; } bign operator *= (const bign& b) { *this = *this * b; return *this; } bool operator < (const bign& b) const{ if(len != b.len) return len < b.len; for(int i = len-1; i >= 0; i--) if(s[i] != b.s[i]) return s[i] < b.s[i]; return false; } bool operator > (const bign& b) const{ return b < *this; } bool operator <= (const bign& b) { return !(b > *this); } bool operator >= (const bign& b) { return !(b < *this); } bool operator == (const bign& b) { return !(b < *this) && !(*this < b); } bool operator != (const bign& b) { return (b < *this) || (*this < b); } }; istream& operator >> (istream &in, bign& x) { string s; in >> s; x = s.c_str(); return in; } ostream& operator << (ostream &out, const bign& x) { out << x.str(); return out; } int main() { bign a,b; int c; cin >> a >> b >> c; cout << a + b << endl; cout << a * b << endl; cout << a - b << endl; cout << a / c << endl; cout << a % c << endl; return 0; }
[ "mirokuxy@gmail.com" ]
mirokuxy@gmail.com
ed41adc85738e5416b11e6da46578f319de2d59a
04b1803adb6653ecb7cb827c4f4aa616afacf629
/android_webview/browser/gfx/test/fake_window.cc
b4031e3d2930e67e0a8725f03b6e0f664856a59e
[ "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
9,796
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "android_webview/browser/gfx/test/fake_window.h" #include "android_webview/browser/gfx/browser_view_renderer.h" #include "android_webview/browser/gfx/child_frame.h" #include "android_webview/browser/gfx/render_thread_manager.h" #include "base/bind.h" #include "base/location.h" #include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "base/threading/thread_task_runner_handle.h" #include "ui/gl/gl_bindings.h" #include "ui/gl/init/gl_factory.h" namespace android_webview { class FakeWindow::ScopedMakeCurrent { public: ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { DCHECK(!view_root_->context_current_); view_root_->context_current_ = true; bool result = view_root_->context_->MakeCurrent(view_root_->surface_.get()); DCHECK(result); } ~ScopedMakeCurrent() { DCHECK(view_root_->context_current_); view_root_->context_current_ = false; // Release the underlying EGLContext. This is required because the real // GLContextEGL may no longer be current here and to satisfy DCHECK in // GLContextEGL::IsCurrent. eglMakeCurrent(view_root_->surface_->GetDisplay(), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); view_root_->context_->ReleaseCurrent(view_root_->surface_.get()); } private: FakeWindow* view_root_; }; FakeWindow::FakeWindow(BrowserViewRenderer* view, WindowHooks* hooks, gfx::Rect location) : view_(view), hooks_(hooks), surface_size_(100, 100), location_(location), on_draw_hardware_pending_(false), context_current_(false), weak_ptr_factory_(this) { CheckCurrentlyOnUIThread(); DCHECK(view_); view_->OnAttachedToWindow(location_.width(), location_.height()); view_->SetWindowVisibility(true); view_->SetViewVisibility(true); } FakeWindow::~FakeWindow() { CheckCurrentlyOnUIThread(); if (render_thread_loop_) { base::WaitableEvent completion( base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); render_thread_loop_->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::DestroyOnRT, base::Unretained(this), &completion)); completion.Wait(); } render_thread_.reset(); } void FakeWindow::Detach() { CheckCurrentlyOnUIThread(); view_->SetCurrentCompositorFrameConsumer(nullptr); view_->OnDetachedFromWindow(); } void FakeWindow::RequestInvokeGL(FakeFunctor* functor, bool wait_for_completion) { CreateRenderThreadIfNeeded(); CheckCurrentlyOnUIThread(); base::WaitableEvent completion( base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); render_thread_loop_->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::InvokeFunctorOnRT, base::Unretained(this), functor, wait_for_completion ? &completion : nullptr)); if (wait_for_completion) completion.Wait(); } void FakeWindow::InvokeFunctorOnRT(FakeFunctor* functor, base::WaitableEvent* sync) { CheckCurrentlyOnRT(); ScopedMakeCurrent make_current(this); functor->Invoke(hooks_); if (sync) sync->Signal(); } void FakeWindow::RequestDrawGL(FakeFunctor* functor) { CheckCurrentlyOnUIThread(); render_thread_loop_->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::ProcessDrawOnRT, base::Unretained(this), functor)); } void FakeWindow::PostInvalidate() { CheckCurrentlyOnUIThread(); if (on_draw_hardware_pending_) return; on_draw_hardware_pending_ = true; base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); } void FakeWindow::OnDrawHardware() { CheckCurrentlyOnUIThread(); DCHECK(on_draw_hardware_pending_); on_draw_hardware_pending_ = false; view_->PrepareToDraw(gfx::Vector2d(), location_); hooks_->WillOnDraw(); bool success = view_->OnDrawHardware(); hooks_->DidOnDraw(success); FakeFunctor* functor = hooks_->GetFunctor(); if (success && functor) { CreateRenderThreadIfNeeded(); base::WaitableEvent completion( base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); render_thread_loop_->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::DrawFunctorOnRT, base::Unretained(this), functor, &completion)); completion.Wait(); } } void FakeWindow::ProcessSyncOnRT(FakeFunctor* functor, base::WaitableEvent* sync) { CheckCurrentlyOnRT(); functor->Sync(location_, hooks_); sync->Signal(); } void FakeWindow::ProcessDrawOnRT(FakeFunctor* functor) { CheckCurrentlyOnRT(); ScopedMakeCurrent make_current(this); functor->Draw(hooks_); } void FakeWindow::DrawFunctorOnRT(FakeFunctor* functor, base::WaitableEvent* sync) { ProcessSyncOnRT(functor, sync); ProcessDrawOnRT(functor); } void FakeWindow::CheckCurrentlyOnUIThread() { DCHECK(ui_checker_.CalledOnValidSequence()); } void FakeWindow::CreateRenderThreadIfNeeded() { CheckCurrentlyOnUIThread(); if (render_thread_) { DCHECK(render_thread_loop_); return; } render_thread_.reset(new base::Thread("TestRenderThread")); render_thread_->Start(); render_thread_loop_ = render_thread_->task_runner(); rt_checker_.DetachFromSequence(); base::WaitableEvent completion( base::WaitableEvent::ResetPolicy::MANUAL, base::WaitableEvent::InitialState::NOT_SIGNALED); render_thread_loop_->PostTask( FROM_HERE, base::BindOnce(&FakeWindow::InitializeOnRT, base::Unretained(this), &completion)); completion.Wait(); } void FakeWindow::InitializeOnRT(base::WaitableEvent* sync) { CheckCurrentlyOnRT(); surface_ = gl::init::CreateOffscreenGLSurface(surface_size_); DCHECK(surface_); DCHECK(surface_->GetHandle()); context_ = gl::init::CreateGLContext(nullptr, surface_.get(), gl::GLContextAttribs()); DCHECK(context_); sync->Signal(); } void FakeWindow::DestroyOnRT(base::WaitableEvent* sync) { CheckCurrentlyOnRT(); if (context_) { DCHECK(!context_->IsCurrent(surface_.get())); context_ = nullptr; surface_ = nullptr; } sync->Signal(); } void FakeWindow::CheckCurrentlyOnRT() { DCHECK(rt_checker_.CalledOnValidSequence()); } FakeFunctor::FakeFunctor() : window_(nullptr) {} FakeFunctor::~FakeFunctor() { // Older tests delete functor without bothering to // call either release code path. Release thiings here. ReleaseOnUIWithInvoke(); } void FakeFunctor::Init( FakeWindow* window, std::unique_ptr<RenderThreadManager> render_thread_manager) { window_ = window; render_thread_manager_ = std::move(render_thread_manager); } void FakeFunctor::Sync(const gfx::Rect& location, WindowHooks* hooks) { DCHECK(render_thread_manager_); committed_location_ = location; hooks->WillSyncOnRT(); render_thread_manager_->CommitFrameOnRT(); hooks->DidSyncOnRT(); } void FakeFunctor::Draw(WindowHooks* hooks) { DCHECK(render_thread_manager_); HardwareRendererDrawParams params{}; params.clip_left = committed_location_.x(); params.clip_top = committed_location_.y(); params.clip_right = committed_location_.x() + committed_location_.width(); params.clip_bottom = committed_location_.y() + committed_location_.height(); params.width = committed_location_.width(); params.height = committed_location_.height(); if (!hooks->WillDrawOnRT(&params)) return; render_thread_manager_->DrawOnRT(false /* save_restore */, &params); hooks->DidDrawOnRT(); } CompositorFrameConsumer* FakeFunctor::GetCompositorFrameConsumer() { return render_thread_manager_.get(); } void FakeFunctor::ReleaseOnUIWithoutInvoke(base::OnceClosure callback) { DCHECK(render_thread_manager_); render_thread_manager_->RemoveFromCompositorFrameProducerOnUI(); window_->render_thread_task_runner()->PostTask( FROM_HERE, base::BindOnce( &FakeFunctor::ReleaseOnRT, base::Unretained(this), base::BindOnce( base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), base::ThreadTaskRunnerHandle::Get(), FROM_HERE, std::move(callback)))); } void FakeFunctor::ReleaseOnRT(base::OnceClosure callback) { DCHECK(render_thread_manager_); { RenderThreadManager::InsideHardwareReleaseReset release_reset( render_thread_manager_.get()); render_thread_manager_->DestroyHardwareRendererOnRT( false /* save_restore */); } render_thread_manager_.reset(); std::move(callback).Run(); } void FakeFunctor::ReleaseOnUIWithInvoke() { if (!render_thread_manager_) return; render_thread_manager_->RemoveFromCompositorFrameProducerOnUI(); { RenderThreadManager::InsideHardwareReleaseReset release_reset( render_thread_manager_.get()); RequestInvokeGL(true); } render_thread_manager_.reset(); } void FakeFunctor::Invoke(WindowHooks* hooks) { DCHECK(render_thread_manager_); hooks->WillProcessOnRT(); render_thread_manager_->DestroyHardwareRendererOnRT(false /* save_restore */); hooks->DidProcessOnRT(); } bool FakeFunctor::RequestInvokeGL(bool wait_for_completion) { DCHECK(window_); window_->RequestInvokeGL(this, wait_for_completion); return true; } } // namespace android_webview
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
fc278c465253cb3e3b1f2cdc5ee092459cb2e86f
019ee2b17c2e51e2ee8720a24d101cbc70d1d990
/.c9/metadata/workspace/classFiles/C-2016S/session05/02bFraction.cc
04e7b9c80e981a0a032e083bdb69fcc4c1466121
[]
no_license
byrnedawg/programming
a676c99f75aaf54b5f4a8880c8403642ab088042
3b19c62c568cda5ff94dc87d142fba7feed3a462
refs/heads/master
2021-03-24T12:51:07.181785
2017-06-30T19:20:38
2017-06-30T19:20:38
77,976,894
0
0
null
null
null
null
UTF-8
C++
false
false
1,634
cc
{"changed":false,"filter":false,"title":"02bFraction.cc","tooltip":"/classFiles/C-2016S/session05/02bFraction.cc","value":"#include <iostream>\nusing namespace std;\n\nclass Fraction {\nprivate:\n\tint num, den;\npublic:\n\tFraction(int num = 0, int den = 1) : num(num), den(den) {\n\t\t//this.num = num;\n\t}\n\tfriend Fraction add(Fraction a, Fraction b);\n\tvoid print() const {\n\t\tcout << num << \"/\" << den;\n\t}\n\tfriend Fraction operator +(Fraction a, Fraction b) {\n\t\treturn Fraction(a.num*b.den + b.num*a.den,a.den*b.den);\n\t}\n\n\tfriend Fraction operator -(Fraction a) {\n\t\treturn Fraction(-a.num, a.den);\n\t}\n\n\t// x = 1 + 2 + 3 + 4;\n\t//cout << \"hello\" << f1 << \"hello\";\n\tfriend ostream& operator <<(ostream& s, Fraction f) {\n return s << f.num << \"/\" << f.den;\n\t}\n};\n\nFraction add(Fraction a, Fraction b) {\n\treturn Fraction(a.num*b.den + b.num*a.den,a.den*b.den);\n}\n\n\n\nint main() {\n\tFraction a(1,2);\n\tFraction b(3); // 3/1\n\tFraction c();\n\tFraction d; // 0/1\n\tconst Fraction e = add(a,b);\n\tconst Fraction f = a + b;\n\te.print();\n\tf.print();\n\tconst Fraction g = -a;\n\tcout << g << \"hello\";\n\t//Fraction h = ++a;\n\t//Fraction j = a++;\n\n\tint x = 1;\n\tint y = 2;\n\tint z = x < y ? x : y;\n}\n\n\t\n\t\n","undoManager":{"mark":-1,"position":-1,"stack":[]},"ace":{"folds":[],"scrolltop":225,"scrollleft":0,"selection":{"start":{"row":30,"column":17},"end":{"row":30,"column":54},"isBackwards":false},"options":{"guessTabSize":true,"useWrapMode":false,"wrapToView":true},"firstLineState":{"row":13,"state":"start","mode":"ace/mode/c_cpp"}},"timestamp":1456229530768}
[ "greg.byrne53@gmail.com" ]
greg.byrne53@gmail.com
0a3896bbe852d8bbd6c41a50c820a42a40e2d117
394fad9b5bccde5ac86ac4e458bfe92c6be105e0
/Examples/UI/ColorGrid/ColorGrid.cpp
448463a87c64ea04b83d33bdfb13c0597478ab8f
[]
no_license
sway913/AEWBPlugin
a2994b9dafc4c1664bd345edf96acd9ff0f2c197
6ef426993035918d916c4d0baf7e855f5f1833b7
refs/heads/master
2023-03-10T10:39:24.802935
2021-02-25T08:49:14
2021-02-25T08:49:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
19,662
cpp
/*******************************************************************/ /* */ /* ADOBE CONFIDENTIAL */ /* _ _ _ _ _ _ _ _ _ _ _ _ _ */ /* */ /* Copyright 2007 Adobe Systems Incorporated */ /* All Rights Reserved. */ /* */ /* NOTICE: All information contained herein is, and remains the */ /* property of Adobe Systems Incorporated and its suppliers, if */ /* any. The intellectual and technical concepts contained */ /* herein are proprietary to Adobe Systems Incorporated and its */ /* suppliers and may be covered by U.S. and Foreign Patents, */ /* patents in process, and are protected by trade secret or */ /* copyright law. Dissemination of this information or */ /* reproduction of this material is strictly forbidden unless */ /* prior written permission is obtained from Adobe Systems */ /* Incorporated. */ /* */ /*******************************************************************/ /* ColorGrid.cpp Revision History Version Change Engineer Date ======= ====== ======== ====== 1.0 created by eks 10/1/1999 2.0 various bugfixes... bbb 1/4/2003 3.0 updated to C++ bbb 8/21/2003 3.1 handrails, training wheels bbb 3/15/2004 3.2 Added new entry point zal 9/18/2017 */ #include "ColorGrid.h" static PF_Err About ( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output ) { PF_Err err = PF_Err_NONE; AEGP_SuiteHandler suites(in_data->pica_basicP); suites.ANSICallbacksSuite1()->sprintf(out_data->return_msg, "%s, v%d.%d\r%s", NAME, MAJOR_VERSION, MINOR_VERSION, DESCRIPTION); return err; } static PF_Err GlobalSetup ( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output ) { PF_Err err = PF_Err_NONE; out_data->my_version = PF_VERSION( MAJOR_VERSION, MINOR_VERSION, BUG_VERSION, STAGE_VERSION, BUILD_VERSION); out_data->out_flags |= PF_OutFlag_CUSTOM_UI | PF_OutFlag_USE_OUTPUT_EXTENT | PF_OutFlag_PIX_INDEPENDENT | PF_OutFlag_DEEP_COLOR_AWARE; out_data->out_flags2 |= PF_OutFlag2_FLOAT_COLOR_AWARE | PF_OutFlag2_SUPPORTS_SMART_RENDER | PF_OutFlag2_SUPPORTS_THREADED_RENDERING; return err; } static PF_Err ColorGrid_ColorizePixelFloat( void *refcon, A_long x, A_long y, PF_PixelFloat *inP, PF_PixelFloat *outP) { PF_Err err = PF_Err_NONE; PF_PixelFloat *current_color = reinterpret_cast<PF_PixelFloat*>(refcon); outP->red = (current_color->red + inP->red) / 2; outP->green = (current_color->green + inP->green) / 2; outP->blue = (current_color->blue + inP->blue) / 2; outP->alpha = inP->alpha; return err; } static PF_Err ColorGrid_ColorizePixel16( void *refcon, A_long x, A_long y, PF_Pixel16 *inP, PF_Pixel16 *outP) { PF_Err err = PF_Err_NONE; PF_Pixel16 *current_color = reinterpret_cast<PF_Pixel16*>(refcon); outP->red = (current_color->red + inP->red) / 2; outP->green = (current_color->green + inP->green) / 2; outP->blue = (current_color->blue + inP->blue) / 2; outP->alpha = inP->alpha; return err; } static PF_Err ColorGrid_ColorizePixel8( void *refcon, A_long x, A_long y, PF_Pixel8 *inP, PF_Pixel8 *outP) { PF_Err err = PF_Err_NONE; PF_Pixel8 *current_color = reinterpret_cast<PF_Pixel8*>(refcon); outP->red = (current_color->red + inP->red) / 2; outP->green = (current_color->green + inP->green) / 2; outP->blue = (current_color->blue + inP->blue) / 2; outP->alpha = inP->alpha; return err; } static PF_Err ParamsSetup ( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output) { PF_Err err = PF_Err_NONE; PF_ParamDef def; AEFX_CLR_STRUCT(def); ERR(CreateDefaultArb( in_data, out_data, &def.u.arb_d.dephault)); PF_ADD_ARBITRARY2( "Color Grid", UI_GRID_WIDTH, UI_GRID_HEIGHT, 0, PF_PUI_CONTROL | PF_PUI_DONT_ERASE_CONTROL, def.u.arb_d.dephault, COLOR_GRID_UI, ARB_REFCON); if (!err) { PF_CustomUIInfo ci; ci.events = PF_CustomEFlag_EFFECT; ci.comp_ui_width = ci.comp_ui_height = 0; ci.comp_ui_alignment = PF_UIAlignment_NONE; ci.layer_ui_width = ci.layer_ui_height = 0; ci.layer_ui_alignment = PF_UIAlignment_NONE; ci.preview_ui_width = ci.preview_ui_height = 0; ci.layer_ui_alignment = PF_UIAlignment_NONE; err = (*(in_data->inter.register_ui))(in_data->effect_ref, &ci); out_data->num_params = CG_NUM_PARAMS; } return err; } static PF_Err Render ( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output ) { PF_Err err = PF_Err_NONE; PF_PixelFloat *current_colorP = NULL; PF_Handle arbH = params[CG_GRID_UI]->u.arb_d.value; CG_ArbData *arbP = NULL; PF_Point origin = {0,0}; A_u_short iSu = 0; PF_Rect current_rectR = {0,0,0,0}; A_long box_acrossL = 0, box_downL = 0, progress_baseL = 0, progress_finalL = BOXES_PER_GRID; AEGP_SuiteHandler suites(in_data->pica_basicP); arbP = reinterpret_cast<CG_ArbData*>(suites.HandleSuite1()->host_lock_handle(arbH)); current_colorP = reinterpret_cast<PF_PixelFloat*>(arbP); origin.h = (A_short)in_data->pre_effect_source_origin_x; origin.v = (A_short)in_data->pre_effect_source_origin_y; /* This section uses the pre-effect extent hint, since it wants to only be applied to the source layer material, and NOT to any resized effect area. Example: User applies "Resizer" to a layer before using ColorGrid. The effect makes the output area larger than the source footage. ColorGrid will look at the pre-effect extent width and height to determine what the relative coordinates are for the source material inside the params[0] (the layer). */ for(iSu = 0; !err && iSu < BOXES_PER_GRID; ++iSu){ if(box_acrossL == BOXES_ACROSS) { box_downL++; box_acrossL = 0; } ColorGrid_Get_Box_In_Grid( &origin, in_data->width * in_data->downsample_x.num / in_data->downsample_x.den, in_data->height * in_data->downsample_y.num / in_data->downsample_y.den, box_acrossL, box_downL, &current_rectR); PF_Pixel8 temp8; temp8.red = static_cast<A_u_char>(current_colorP->red * PF_MAX_CHAN8); temp8.green = static_cast<A_u_char>(current_colorP->green * PF_MAX_CHAN8); temp8.blue = static_cast<A_u_char>(current_colorP->blue * PF_MAX_CHAN8); progress_baseL++; suites.Iterate8Suite1()->iterate( in_data, progress_baseL, progress_finalL, &params[CG_INPUT]->u.ld, &current_rectR, reinterpret_cast<void*>(&temp8), ColorGrid_ColorizePixel8, output); current_colorP++; box_acrossL++; } PF_UNLOCK_HANDLE(arbH); return err; } static PF_Err PreRender( PF_InData *in_data, PF_OutData *out_data, PF_PreRenderExtra *extra) { PF_Err err = PF_Err_NONE; PF_ParamDef arb_param; PF_RenderRequest req = extra->input->output_request; PF_CheckoutResult in_result; AEFX_CLR_STRUCT(arb_param); ERR(PF_CHECKOUT_PARAM( in_data, CG_GRID_UI, in_data->current_time, in_data->time_step, in_data->time_scale, &arb_param)); ERR(extra->cb->checkout_layer( in_data->effect_ref, CG_INPUT, CG_INPUT, &req, in_data->current_time, in_data->time_step, in_data->time_scale, &in_result)); if (!err){ UnionLRect(&in_result.result_rect, &extra->output->result_rect); UnionLRect(&in_result.max_result_rect, &extra->output->max_result_rect); } ERR(PF_CHECKIN_PARAM(in_data, &arb_param)); return err; } static PF_Err SmartRender( PF_InData *in_data, PF_OutData *out_data, PF_SmartRenderExtra *extra) { PF_Err err = PF_Err_NONE, err2 = PF_Err_NONE; PF_EffectWorld *input_worldP = NULL, *output_worldP = NULL; PF_WorldSuite2 *wsP = NULL; PF_PixelFormat format = PF_PixelFormat_INVALID; PF_Point origin = {0,0}; A_u_short iSu = 0; PF_Rect current_rectR = {0,0,0,0}; A_long box_acrossL = 0, box_downL = 0; AEGP_SuiteHandler suites(in_data->pica_basicP); CG_ArbData *arbP = NULL; PF_PixelFloat *current_colorP = NULL; PF_ParamDef arb_param; AEFX_CLR_STRUCT(arb_param); ERR(PF_CHECKOUT_PARAM( in_data, CG_GRID_UI, in_data->current_time, in_data->time_step, in_data->time_scale, &arb_param)); if (!err){ arbP = reinterpret_cast<CG_ArbData*>(*arb_param.u.arb_d.value); if (arbP){ current_colorP = reinterpret_cast<PF_PixelFloat*>(arbP); } } ERR((extra->cb->checkout_layer_pixels( in_data->effect_ref, CG_INPUT, &input_worldP))); ERR(extra->cb->checkout_output( in_data->effect_ref, &output_worldP)); if (!err){ for(iSu = 0; !err && iSu < BOXES_PER_GRID; ++iSu){ if(box_acrossL == BOXES_ACROSS) { box_downL++; box_acrossL = 0; } ColorGrid_Get_Box_In_Grid( &origin, in_data->width * in_data->downsample_x.num / in_data->downsample_x.den, in_data->height * in_data->downsample_y.num / in_data->downsample_y.den, box_acrossL, box_downL, &current_rectR); if (!err && output_worldP){ ERR(AEFX_AcquireSuite( in_data, out_data, kPFWorldSuite, kPFWorldSuiteVersion2, "Couldn't load suite.", (void**)&wsP)); ERR(wsP->PF_GetPixelFormat(input_worldP, &format)); origin.h = (A_short)(in_data->output_origin_x); origin.v = (A_short)(in_data->output_origin_y); if (!err){ switch (format) { case PF_PixelFormat_ARGB128: ERR(suites.IterateFloatSuite1()->iterate_origin(in_data, 0, output_worldP->height, input_worldP, &current_rectR, &origin, reinterpret_cast<void*>(current_colorP), ColorGrid_ColorizePixelFloat, output_worldP)); break; case PF_PixelFormat_ARGB64: PF_Pixel16 temp16; temp16.red = static_cast<A_u_short>(current_colorP->red * PF_MAX_CHAN16); temp16.green = static_cast<A_u_short>(current_colorP->green * PF_MAX_CHAN16); temp16.blue = static_cast<A_u_short>(current_colorP->blue * PF_MAX_CHAN16); temp16.alpha = static_cast<A_u_short>(current_colorP->red * PF_MAX_CHAN16); ERR(suites.Iterate16Suite1()->iterate_origin( in_data, 0, output_worldP->height, input_worldP, &current_rectR, &origin, reinterpret_cast<void*>(&temp16), ColorGrid_ColorizePixel16, output_worldP)); break; case PF_PixelFormat_ARGB32: PF_Pixel8 temp8; temp8.red = static_cast<A_u_char>(current_colorP->red * PF_MAX_CHAN8); temp8.green = static_cast<A_u_char>(current_colorP->green * PF_MAX_CHAN8); temp8.blue = static_cast<A_u_char>(current_colorP->blue * PF_MAX_CHAN8); ERR(suites.Iterate8Suite1()->iterate_origin( in_data, 0, output_worldP->height, input_worldP, &current_rectR, &origin, reinterpret_cast<void*>(&temp8), ColorGrid_ColorizePixel8, output_worldP)); break; default: err = PF_Err_BAD_CALLBACK_PARAM; break; } } } current_colorP++; box_acrossL++; } } ERR2(AEFX_ReleaseSuite( in_data, out_data, kPFWorldSuite, kPFWorldSuiteVersion2, "Couldn't release suite.")); ERR2(PF_CHECKIN_PARAM(in_data, &arb_param)); ERR2(extra->cb->checkin_layer_pixels(in_data->effect_ref, CG_INPUT)); return err; } static PF_Err HandleEvent( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output, PF_EventExtra *extra) { PF_Err err = PF_Err_NONE; AEGP_SuiteHandler suites(in_data->pica_basicP); switch (extra->e_type) { case PF_Event_DO_CLICK: ERR(DoClick(in_data, out_data, params, output, extra)); // Premiere Pro/Elements does not support this suite if (in_data->appl_id != 'PrMr') { ERR(suites.AdvAppSuite2()->PF_InfoDrawText3("ColorGrid - Do Click Event","Adobe Systems, Inc.", NULL)); } break; case PF_Event_DRAG: // Premiere Pro/Elements does not support this suite if (in_data->appl_id != 'PrMr') { ERR(suites.AdvAppSuite2()->PF_InfoDrawText3("ColorGrid - Drag Event","Adobe Systems, Inc.", NULL)); } break; case PF_Event_DRAW: ERR(DrawEvent(in_data, out_data, params, output, extra, params[1]->u.cd.value)); // Premiere Pro/Elements does not support this suite if (in_data->appl_id != 'PrMr') { // don't draw info palette *during* a draw event, it will mess up // the drawing and cause schmutz // ERR(suites.AdvAppSuite2()->PF_InfoDrawText3("ColorGrid - Draw Event","Adobe Systems, Inc.", NULL)); } break; case PF_Event_ADJUST_CURSOR: ERR(ChangeCursor(in_data, out_data, params, output, extra)); // Premiere Pro/Elements does not support this suite if (in_data->appl_id != 'PrMr') { ERR(suites.AdvAppSuite2()->PF_InfoDrawText3("ColorGrid - Change Cursor Event","Adobe Systems, Inc.", NULL)); } break; default: break; } return err; } static PF_Err HandleArbitrary( PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output, PF_ArbParamsExtra *extra) { PF_Err err = PF_Err_NONE; void *srcP = NULL, *dstP = NULL; switch (extra->which_function) { case PF_Arbitrary_NEW_FUNC: if (extra->u.new_func_params.refconPV != ARB_REFCON) { err = PF_Err_INTERNAL_STRUCT_DAMAGED; } else { err = CreateDefaultArb( in_data, out_data, extra->u.new_func_params.arbPH); } break; case PF_Arbitrary_DISPOSE_FUNC: if (extra->u.dispose_func_params.refconPV != ARB_REFCON) { err = PF_Err_INTERNAL_STRUCT_DAMAGED; } else { PF_DISPOSE_HANDLE(extra->u.dispose_func_params.arbH); } break; case PF_Arbitrary_COPY_FUNC: if(extra->u.copy_func_params.refconPV == ARB_REFCON) { ERR(CreateDefaultArb( in_data, out_data, extra->u.copy_func_params.dst_arbPH)); ERR(Arb_Copy( in_data, out_data, &extra->u.copy_func_params.src_arbH, extra->u.copy_func_params.dst_arbPH)); } break; case PF_Arbitrary_FLAT_SIZE_FUNC: *(extra->u.flat_size_func_params.flat_data_sizePLu) = sizeof(CG_ArbData); break; case PF_Arbitrary_FLATTEN_FUNC: if(extra->u.flatten_func_params.buf_sizeLu == sizeof(CG_ArbData)){ srcP = (CG_ArbData*)PF_LOCK_HANDLE(extra->u.flatten_func_params.arbH); dstP = extra->u.flatten_func_params.flat_dataPV; if (srcP){ memcpy(dstP,srcP,sizeof(CG_ArbData)); } PF_UNLOCK_HANDLE(extra->u.flatten_func_params.arbH); } break; case PF_Arbitrary_UNFLATTEN_FUNC: if(extra->u.unflatten_func_params.buf_sizeLu == sizeof(CG_ArbData)){ PF_Handle handle = PF_NEW_HANDLE(sizeof(CG_ArbData)); dstP = (CG_ArbData*)PF_LOCK_HANDLE(handle); srcP = (void*)extra->u.unflatten_func_params.flat_dataPV; if (srcP){ memcpy(dstP,srcP,sizeof(CG_ArbData)); } *(extra->u.unflatten_func_params.arbPH) = handle; PF_UNLOCK_HANDLE(handle); } break; case PF_Arbitrary_INTERP_FUNC: if(extra->u.interp_func_params.refconPV == ARB_REFCON) { ERR(CreateDefaultArb( in_data, out_data, extra->u.interp_func_params.interpPH)); ERR(Arb_Interpolate( in_data, out_data, extra->u.interp_func_params.tF, &extra->u.interp_func_params.left_arbH, &extra->u.interp_func_params.right_arbH, extra->u.interp_func_params.interpPH)); } break; case PF_Arbitrary_COMPARE_FUNC: ERR(Arb_Compare( in_data, out_data, &extra->u.compare_func_params.a_arbH, &extra->u.compare_func_params.b_arbH, extra->u.compare_func_params.compareP)); break; case PF_Arbitrary_PRINT_SIZE_FUNC: if (extra->u.print_size_func_params.refconPV == ARB_REFCON) { *extra->u.print_size_func_params.print_sizePLu = COLORGRID_ARB_MAX_PRINT_SIZE; } else { err = PF_Err_UNRECOGNIZED_PARAM_TYPE; } break; case PF_Arbitrary_PRINT_FUNC: if (extra->u.print_func_params.refconPV == ARB_REFCON) { ERR(Arb_Print(in_data, out_data, extra->u.print_func_params.print_flags, extra->u.print_func_params.arbH, extra->u.print_func_params.print_sizeLu, extra->u.print_func_params.print_bufferPC)); } else { err = PF_Err_UNRECOGNIZED_PARAM_TYPE; } break; case PF_Arbitrary_SCAN_FUNC: if (extra->u.scan_func_params.refconPV == ARB_REFCON) { ERR(Arb_Scan( in_data, out_data, extra->u.scan_func_params.refconPV, extra->u.scan_func_params.bufPC, extra->u.scan_func_params.bytes_to_scanLu, extra->u.scan_func_params.arbPH)); } else { err = PF_Err_UNRECOGNIZED_PARAM_TYPE; } break; } return err; } extern "C" DllExport PF_Err PluginDataEntryFunction( PF_PluginDataPtr inPtr, PF_PluginDataCB inPluginDataCallBackPtr, SPBasicSuite* inSPBasicSuitePtr, const char* inHostName, const char* inHostVersion) { PF_Err result = PF_Err_INVALID_CALLBACK; result = PF_REGISTER_EFFECT( inPtr, inPluginDataCallBackPtr, "ColorGrid", // Name "ADBE ColorGrid", // Match Name "Sample Plug-ins", // Category AE_RESERVED_INFO); // Reserved Info return result; } PF_Err EffectMain( PF_Cmd cmd, PF_InData *in_data, PF_OutData *out_data, PF_ParamDef *params[], PF_LayerDef *output, void *extra) { PF_Err err = PF_Err_NONE; try { switch (cmd) { case PF_Cmd_ABOUT: err = About(in_data, out_data, params, output); break; case PF_Cmd_GLOBAL_SETUP: err = GlobalSetup( in_data, out_data, params, output); break; case PF_Cmd_PARAMS_SETUP: err = ParamsSetup( in_data, out_data, params, output); break; case PF_Cmd_RENDER: err = Render( in_data, out_data, params, output); break; case PF_Cmd_EVENT: err = HandleEvent( in_data, out_data, params, output, reinterpret_cast<PF_EventExtra*>(extra)); break; case PF_Cmd_ARBITRARY_CALLBACK: err = HandleArbitrary( in_data, out_data, params, output, reinterpret_cast<PF_ArbParamsExtra*>(extra)); break; case PF_Cmd_SMART_PRE_RENDER: err = PreRender(in_data, out_data, reinterpret_cast<PF_PreRenderExtra*>(extra)); break; case PF_Cmd_SMART_RENDER: err = SmartRender( in_data, out_data, reinterpret_cast<PF_SmartRenderExtra*>(extra)); break; } } catch (PF_Err &thrown_err) { err = thrown_err; } return err; }
[ "wangjingxin@wangjingxindeMacBook-Pro.local" ]
wangjingxin@wangjingxindeMacBook-Pro.local