blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
19042bee0ea3b594fc4ba400bc5e0dae4dacc814
385314c17cabc082aa54d97c2693d66bb0976a64
/lib/tao/tao/json/external/pegtl/internal/star.hpp
6986c043cb09c53a432d244c45877a27ba27f137
[ "MIT" ]
permissive
21doublenexus/contemplative-game
dd835e66f928ddecc4bd3ab267a04a9058856ac8
cadf92c1b44d226bf97a87f738ea3aad3e7dd376
refs/heads/main
2023-02-15T08:55:55.187533
2021-01-05T17:15:37
2021-01-05T17:15:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,514
hpp
// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_JSON_PEGTL_INTERNAL_STAR_HPP #define TAO_JSON_PEGTL_INTERNAL_STAR_HPP #include <type_traits> #include "../config.hpp" #include "duseltronik.hpp" #include "seq.hpp" #include "skip_control.hpp" #include "../apply_mode.hpp" #include "../rewind_mode.hpp" #include "../analysis/generic.hpp" namespace tao { namespace TAO_JSON_PEGTL_NAMESPACE { namespace internal { template< typename Rule, typename... Rules > struct star { using analyze_t = analysis::generic< analysis::rule_type::OPT, Rule, Rules..., star >; template< apply_mode A, rewind_mode, template< typename... > class Action, template< typename... > class Control, typename Input, typename... States > static bool match( Input& in, States&&... st ) { while( seq< Rule, Rules... >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { } return true; } }; template< typename Rule, typename... Rules > struct skip_control< star< Rule, Rules... > > : std::true_type { }; } // namespace internal } // namespace TAO_JSON_PEGTL_NAMESPACE } // namespace tao #endif
[ "vscavinner@gmail.com" ]
vscavinner@gmail.com
df5ba23233690846709f5c047670e85f48714833
fa6b818e06c5b97ddb131e18bca14ead19091a7f
/Goblim-Student/Core/Engine/Base/Light.hpp
31a927beb4dd1627d7e4fba7705fd8941e2990b6
[]
no_license
nathmotion/Moteur-3D
2bcd2f4624071cda0a4f1d6e510843bf6908dc8b
df6222ba62f92958874677510dfef9473eb1c459
refs/heads/master
2021-07-23T01:33:18.183697
2017-11-01T06:32:18
2017-11-01T06:32:18
107,647,261
0
0
null
null
null
null
UTF-8
C++
false
false
245
hpp
#ifndef _GOBLIM_LIGHT_ #define _GOBLIM_LIGHT_ #include <glm/glm.hpp> #include <string.h> class Light { public: Light(std::string name,glm::vec3 color = glm::vec3(1.0f)); private: glm::vec4 m_Color; std::string m_Name; } #endif
[ "mallet.nathanael@hotmail.fr" ]
mallet.nathanael@hotmail.fr
edc05d56ef306794323e488f09cc6b2b826c7bfb
8f50c262f89d3dc4f15f2f67eb76e686b8f808f5
/TestBeam/TBMonitoring/TBMonitoring/TBADCRawMonTool.h
c81d8d5186b118ef287c12b0f9f8c1d96a741c7c
[ "Apache-2.0" ]
permissive
strigazi/athena
2d099e6aab4a94ab8b636ae681736da4e13ac5c9
354f92551294f7be678aebcd7b9d67d2c4448176
refs/heads/master
2022-12-09T02:05:30.632208
2020-09-03T14:03:18
2020-09-03T14:03:18
292,587,480
0
1
null
null
null
null
UTF-8
C++
false
false
1,343
h
//Dear emacs, this is -*- c++ -*- /* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TBMONITORING_TBADCRAWMONTOOL_H #define TBMONITORING_TBADCRAWMONTOOL_H #include "AthenaMonitoring/MonitorToolBase.h" #include "GaudiKernel/IHistogramSvc.h" #include "AIDA/IHistogram1D.h" #include "AIDA/IHistogram2D.h" #include "StoreGate/StoreGateSvc.h" #include <string> #include <vector> /** @class TBADCRawMonTool TBADCRawMonTool.h "TBMonitoring/TBADCRawMonTool.h" This tool is used to create histograms of tdc data @author Malachi Schram */ class TBADCRawMonTool: public MonitorToolBase { public: TBADCRawMonTool(const std::string & type, const std::string & name, const IInterface* parent); ~TBADCRawMonTool(); StatusCode initialize(); StatusCode bookHists(); // this is called before 1st event StatusCode mybookHists(); // called at 1st event StatusCode fillHists(); // Test method void FillRandomDetect(); private: //std::string m_path; //Declared properties bool m_monitor_adc; bool m_testTool; bool m_isBooked; // ADC histograms IHistogram1D** m_histo_adc; // Histos ranges float m_posMax,m_posMin; int m_numBin; int m_adcNum; std::vector<std::string> m_adcNames; }; #endif // not TBMONITORING_TBADCRAWMONTOOL_H
[ "graemes.cern@gmail.com" ]
graemes.cern@gmail.com
c04b490026f20356954cf19840634ae8da364894
e36c670344356f3fad4a6322ac23e1da6520e7ce
/src/Output/Output_PreparedPatch_Fluid.cpp
db09887861fd23dbfcff52e47c937d6c9e26cc29
[ "BSD-3-Clause" ]
permissive
Aabhash007/gamer
7934c49bc2023403fcb46c4873252a180f2d8f90
62769fe4f680eeb504f84f0aae199012f728492e
refs/heads/master
2022-12-26T13:14:31.279184
2020-09-30T19:58:50
2020-09-30T19:58:50
300,045,686
0
0
NOASSERTION
2020-09-30T19:56:52
2020-09-30T19:56:51
null
UTF-8
C++
false
false
7,787
cpp
#include "GAMER.h" //------------------------------------------------------------------------------------------------------- // Function : Output_PreparedPatch_Fluid // Description : Output the fluid data of a "single patch" plus its ghost zones prepared by Flu_Prepare() // // Note : This function should be placed after invoking Prepare_PatchData() in Flu_Prepare() // // Example: // Prepare_PatchData( ... ); // // const int TLv = 1; // const int TPID = 12; // char comment[10]; // sprintf( comment, "Step%ld", AdvanceCounter[TLv] ); // Output_PreparedPatch_Fluid( TLv, TPID, h_Flu_Array_F_In, h_Mag_Array_F_In, // NPG, PID0_List, lv, comment ); // // Paremeter : TLv : Level you want to output the prepared patch // TPID : Target patch ID // h_Flu_Array : Input fluid array // h_Mag_Array : Input B field array (for MHD onlhy) // NPG : Number of patch groups to be prepared at a time // PID0_List : List recording the patch indices with LocalID==0 to be udpated // CLv : Level of data currently stored in h_Flu_Array // comment : String to attach to the end of the file name //------------------------------------------------------------------------------------------------------- void Output_PreparedPatch_Fluid( const int TLv, const int TPID, const real h_Flu_Array[][FLU_NIN][ CUBE(FLU_NXT) ], const real h_Mag_Array[][NCOMP_MAG][ FLU_NXT_P1*SQR(FLU_NXT) ], const int NPG, const int *PID0_List, const int CLv, const char *comment ) { // nothing to do if the current level is not the target level if ( TLv != CLv ) return; const int LocalID = TPID % 8; const int TPID0 = TPID - LocalID; for (int TID=0; TID<NPG; TID++) { // check if the target patch is within the current patch group if ( TPID0 != PID0_List[TID] ) continue; // begin to output the prepared data patch_t *Relation = amr->patch[0][TLv][TPID]; char FileName[100]; sprintf( FileName, "PrePatch_Fluid_r%d_lv%d_p%d", MPI_Rank, TLv, TPID ); if ( comment != NULL ) { strcat( FileName, "_" ); strcat( FileName, comment ); } if ( Aux_CheckFileExist(FileName) ) Aux_Message( stderr, "WARNING : file \"%s\" already exists and will be overwritten !!\n", FileName ); // header FILE *File = fopen( FileName, "w" ); fprintf( File, "Rank %d Lv %d PID %d Local ID %d Time %13.7e Step %ld Counter %ld\n", MPI_Rank, TLv, TPID, LocalID, Time[TLv], Step, AdvanceCounter[TLv] ); fprintf( File, "Father %d Son %d Corner (%10d,%10d,%10d)\n\n", Relation->father, Relation->son, Relation->corner[0], Relation->corner[1], Relation->corner[2] ); fprintf( File, "Sibling, Sibling->Son, and Father->Sibling Lists :\n" ); int Sib, FaSib, SibSon; for (int S=0; S<26; S++) { Sib = Relation->sibling[S]; FaSib = ( TLv == 0 ) ? -1 : amr->patch[0][TLv-1][Relation->father]->sibling[S]; SibSon = ( Sib < 0 ) ? Sib : amr->patch[0][TLv][Sib]->son; fprintf( File, "Sib[%2d] = %6d Sib_Son = %6d Fa_Sib[%2d] = %6d\n", S, Sib, SibSon, S, FaSib ); } fprintf( File, "\n" ); // output cell-centered fluid data fprintf( File, "\n" ); fprintf( File, "===========================\n" ); fprintf( File, "== FLUID (cell-centered) == \n" ); fprintf( File, "===========================\n" ); fprintf( File, "\n" ); // header fprintf( File, "(%3s,%3s,%3s )", "i", "j", "k" ); # if ( MODEL == ELBDM ) fprintf( File, "%16s%16s", FieldLabel[REAL], FieldLabel[IMAG] ); # else for (int v=0; v<FLU_NIN; v++) fprintf( File, "%16s", FieldLabel[v] ); # if ( MODEL == HYDRO ) fprintf( File, "%16s", "Pressure" ); # endif # endif // MODEL fprintf( File, "\n" ); const int Disp_i = TABLE_02( LocalID, 'x', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); const int Disp_j = TABLE_02( LocalID, 'y', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); const int Disp_k = TABLE_02( LocalID, 'z', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); int K, J, I, Idx; real u[FLU_NIN]; for (int k=-FLU_GHOST_SIZE; k<FLU_GHOST_SIZE+PS1; k++) { K = k + Disp_k; for (int j=-FLU_GHOST_SIZE; j<FLU_GHOST_SIZE+PS1; j++) { J = j + Disp_j; for (int i=-FLU_GHOST_SIZE; i<FLU_GHOST_SIZE+PS1; i++) { I = i + Disp_i; Idx = K*FLU_NXT*FLU_NXT + J*FLU_NXT + I; for (int v=0; v<FLU_NIN; v++) u[v] = h_Flu_Array[TID][v][Idx]; // cell indices fprintf( File, "(%3d,%3d,%3d )", i, j, k ); // all variables in the prepared fluid array for (int v=0; v<FLU_NIN; v++) fprintf( File, " %14.7e", u[v] ); // pressure in HYDRO # if ( MODEL == HYDRO ) const bool CheckMinPres_No = false; # ifdef MHD const real Emag = MHD_GetCellCenteredBEnergy( h_Mag_Array[TID][MAGX], h_Mag_Array[TID][MAGY], h_Mag_Array[TID][MAGZ], FLU_NXT, FLU_NXT, FLU_NXT, I, J, K ); # else const real Emag = NULL_REAL; # endif fprintf( File, " %14.7e", Hydro_Con2Pres(u[DENS],u[MOMX],u[MOMY],u[MOMZ],u[ENGY],u+NCOMP_FLUID, CheckMinPres_No,NULL_REAL,Emag, EoS_DensEint2Pres_CPUPtr, EoS_AuxArray, NULL) ); # endif // #if ( MODEL == HYDRO ) fprintf( File, "\n" ); }}} // output face-centered magnetic field # ifdef MHD fprintf( File, "\n" ); fprintf( File, "====================================\n" ); fprintf( File, "== MAGNETIC FIELD (face-centered) == \n" ); fprintf( File, "====================================\n" ); fprintf( File, "\n" ); // header fprintf( File, "(%3s,%3s,%3s )", "i", "j", "k" ); for (int v=0; v<NCOMP_MAG; v++) fprintf( File, "%16s", MagLabel[v] ); fprintf( File, "\n" ); for (int k=-FLU_GHOST_SIZE; k<FLU_GHOST_SIZE+PS1P1; k++) { K = k + Disp_k; for (int j=-FLU_GHOST_SIZE; j<FLU_GHOST_SIZE+PS1P1; j++) { J = j + Disp_j; for (int i=-FLU_GHOST_SIZE; i<FLU_GHOST_SIZE+PS1P1; i++) { I = i + Disp_i; // cell indices fprintf( File, "(%3d,%3d,%3d )", i, j, k ); // B_X if ( j != FLU_GHOST_SIZE+PS1 && k != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGX][ IDX321_BX(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); // B_Y if ( i != FLU_GHOST_SIZE+PS1 && k != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGY][ IDX321_BY(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); // B_Z if ( i != FLU_GHOST_SIZE+PS1 && j != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGZ][ IDX321_BZ(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); fprintf( File, "\n" ); }}} // i,j,k # endif // #ifdef MHD fclose( File ); break; } // for (int TID=0; TID<NPG; TID++) } // FUNCTION : Output_PreparedPatch_Fluid
[ "hyschive@gmail.com" ]
hyschive@gmail.com
c0a8271b3e26bce75ad19cb207b6fc1f1200b3a1
3d74f759ee48d383aa82eeff0a55864a93a001ba
/shell/common/display.cc
05feded91be5a55d510fa5d8d5b05a91f63e30df
[ "BSD-3-Clause" ]
permissive
flutter/engine
78be5418a9b2f7730dda9ca9fcb25b7055f3da85
902ece7f89d7730cc69f35e098b223cbbf4e25f1
refs/heads/main
2023-09-04T06:12:34.462953
2023-09-04T05:33:32
2023-09-04T05:33:32
39,211,337
7,090
6,862
BSD-3-Clause
2023-09-14T21:58:17
2015-07-16T17:39:56
C++
UTF-8
C++
false
false
319
cc
// Copyright 2013 The Flutter 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 "flutter/shell/common/display.h" namespace flutter { double Display::GetRefreshRate() const { return refresh_rate_; } } // namespace flutter
[ "noreply@github.com" ]
flutter.noreply@github.com
4f646b096b384b1cd1cc8ffe7201644d9f7bd0d3
b9b17fcfac43774e730ecf221bc26164598010b6
/src/TXFaceWnd.h
69ea5625bd09efa522d09cda7ab49fb2f37ba43e
[ "BSD-3-Clause" ]
permissive
taviso/mpgravity
e2334e77e9d5e9769e05d24609e4bbed00f23b5c
f6a2a7a02014b19047e44db76ae551bd689c16ac
refs/heads/master
2023-07-26T00:49:37.297106
2020-04-24T06:15:10
2020-04-24T06:15:10
251,759,803
13
0
null
null
null
null
UTF-8
C++
false
false
3,200
h
/*****************************************************************************/ /* SOURCE CONTROL VERSIONS */ /*---------------------------------------------------------------------------*/ /* */ /* Version Date Time Author / Comment (optional) */ /* */ /* $Log: TXFaceWnd.h,v $ /* Revision 1.1 2010/07/21 17:14:56 richard_wood /* Initial checkin of V3.0.0 source code and other resources. /* Initial code builds V3.0.0 RC1 /* /* Revision 1.2 2009/08/25 20:04:25 richard_wood /* Updates for 2.9.9 /* /* Revision 1.1 2009/06/09 13:21:28 richard_wood /* *** empty log message *** /* /* Revision 1.2 2008/09/19 14:51:08 richard_wood /* Updated for VS 2005 /* /* */ /*****************************************************************************/ /********************************************************************************** Copyright (c) 2003, Albert M. Choy All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Microplanet, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************/ #pragma once // TXFaceWnd.h : header file // ///////////////////////////////////////////////////////////////////////////// // TXFaceWnd window class TXFaceWnd : public CWnd { public: TXFaceWnd(); void SetXFace (LPCTSTR pszLine) ; virtual ~TXFaceWnd(); protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); DECLARE_MESSAGE_MAP() CStatic wndStatic; private: void *m_pixels; HBITMAP m_DIB; };
[ "taviso@gmail.com" ]
taviso@gmail.com
90960cf1843f505379f46931651c6f5738cad984
682b27ef061c6aa0f4ad22a3d9c28350110682b7
/quickPing/quickPing/widget.cpp
0fb018e8982d4ed1c1b652a772897ca9d17115a8
[]
no_license
tangston/quickPing
48a43120573102330b28dd16311f168ead6c8b61
f0263d3749c70fda7b0feb35acae7ec5508ee3c3
refs/heads/master
2020-04-13T14:19:41.103154
2018-12-27T06:58:58
2018-12-27T06:58:58
163,259,213
1
0
null
null
null
null
UTF-8
C++
false
false
1,064
cpp
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::on_startButton_clicked() { myPing mp =myPing(); // QString ip="10.1.11.70"; QString ip=ui->ipEdit->toPlainText();//获取文本框的函数 if(ip==NULL){ QMessageBox box; box.setText(tr("please type your message")); box.exec(); } else{ QStringList list=ip.split("."); QString str=list[3]; int m=str.toInt( ); for(int i=m;i< m+10;++i) { mp.ipCount(ip,i); if( mp.ping(ip) ){ ui->listWidget->addItem(ip+": on "); qDebug()<<"ping yes"; } else { ui->listWidget->addItem(ip+": offline"); qDebug()<<"ping no"; } } } } void Widget::autoScroll()//自动滚屏 { } void Widget::on_exitButton_clicked() { ::exit(0); }
[ "37773841+tangston@users.noreply.github.com" ]
37773841+tangston@users.noreply.github.com
fd5546e3a6b05228535a82dd84269c1026c837d1
643f3dc3c970684ed835bbfa1b3cb31e0b8661be
/src/netbase.cpp
97fc6507d6b4329a9e88c74fcaf6ea52c08d6dd1
[ "MIT" ]
permissive
Aviator-Coding/abet
cf61aeadae2cab51a19bc036dba8d8d8af739ad6
8bee2012deb998d0fbaaad9fbbcdf83a0c84c0d6
refs/heads/master
2020-04-18T21:58:03.380823
2019-01-27T07:07:38
2019-01-27T07:07:38
167,780,598
1
0
MIT
2019-01-27T07:00:56
2019-01-27T07:00:54
null
UTF-8
C++
false
false
39,481
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifdef HAVE_CONFIG_H #include "config/altbet-config.h" #endif #include "netbase.h" #include "hash.h" #include "sync.h" #include "uint256.h" #include "util.h" #include "utilstrencodings.h" #ifdef HAVE_GETADDRINFO_A #include <netdb.h> #endif #ifndef WIN32 #if HAVE_INET_PTON #include <arpa/inet.h> #endif #include <fcntl.h> #endif #include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith() #include <boost/thread.hpp> #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 #endif using namespace std; // Settings static proxyType proxyInfo[NET_MAX]; static CService nameProxy; static CCriticalSection cs_proxyInfos; int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; bool fNameLookup = false; static const unsigned char pchIPv4[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; // Need ample time for negotiation for very slow proxies such as Tor (milliseconds) static const int SOCKS5_RECV_TIMEOUT = 20 * 1000; enum Network ParseNetwork(std::string net) { boost::to_lower(net); if (net == "ipv4") return NET_IPV4; if (net == "ipv6") return NET_IPV6; if (net == "tor" || net == "onion") return NET_TOR; return NET_UNROUTABLE; } std::string GetNetworkName(enum Network net) { switch (net) { case NET_IPV4: return "ipv4"; case NET_IPV6: return "ipv6"; case NET_TOR: return "onion"; default: return ""; } } void SplitHostPort(std::string in, int& portOut, std::string& hostOut) { size_t colon = in.find_last_of(':'); // if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator bool fHaveColon = colon != in.npos; bool fBracketed = fHaveColon && (in[0] == '[' && in[colon - 1] == ']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe bool fMultiColon = fHaveColon && (in.find_last_of(':', colon - 1) != in.npos); if (fHaveColon && (colon == 0 || fBracketed || !fMultiColon)) { int32_t n; if (ParseInt32(in.substr(colon + 1), &n) && n > 0 && n < 0x10000) { in = in.substr(0, colon); portOut = n; } } if (in.size() > 0 && in[0] == '[' && in[in.size() - 1] == ']') hostOut = in.substr(1, in.size() - 2); else hostOut = in; } bool static LookupIntern(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup) { vIP.clear(); { CNetAddr addr; if (addr.SetSpecial(std::string(pszName))) { vIP.push_back(addr); return true; } } #ifdef HAVE_GETADDRINFO_A struct in_addr ipv4_addr; #ifdef HAVE_INET_PTON if (inet_pton(AF_INET, pszName, &ipv4_addr) > 0) { vIP.push_back(CNetAddr(ipv4_addr)); return true; } struct in6_addr ipv6_addr; if (inet_pton(AF_INET6, pszName, &ipv6_addr) > 0) { vIP.push_back(CNetAddr(ipv6_addr)); return true; } #else ipv4_addr.s_addr = inet_addr(pszName); if (ipv4_addr.s_addr != INADDR_NONE) { vIP.push_back(CNetAddr(ipv4_addr)); return true; } #endif #endif struct addrinfo aiHint; memset(&aiHint, 0, sizeof(struct addrinfo)); aiHint.ai_socktype = SOCK_STREAM; aiHint.ai_protocol = IPPROTO_TCP; aiHint.ai_family = AF_UNSPEC; #ifdef WIN32 aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST; #else aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; #endif struct addrinfo* aiRes = NULL; #ifdef HAVE_GETADDRINFO_A struct gaicb gcb, *query = &gcb; memset(query, 0, sizeof(struct gaicb)); gcb.ar_name = pszName; gcb.ar_request = &aiHint; int nErr = getaddrinfo_a(GAI_NOWAIT, &query, 1, NULL); if (nErr) return false; do { // Should set the timeout limit to a resonable value to avoid // generating unnecessary checking call during the polling loop, // while it can still response to stop request quick enough. // 2 seconds looks fine in our situation. struct timespec ts = {2, 0}; gai_suspend(&query, 1, &ts); boost::this_thread::interruption_point(); nErr = gai_error(query); if (0 == nErr) aiRes = query->ar_result; } while (nErr == EAI_INPROGRESS); #else int nErr = getaddrinfo(pszName, NULL, &aiHint, &aiRes); #endif if (nErr) return false; struct addrinfo* aiTrav = aiRes; while (aiTrav != NULL && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions)) { if (aiTrav->ai_family == AF_INET) { assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in)); vIP.push_back(CNetAddr(((struct sockaddr_in*)(aiTrav->ai_addr))->sin_addr)); } if (aiTrav->ai_family == AF_INET6) { assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in6)); vIP.push_back(CNetAddr(((struct sockaddr_in6*)(aiTrav->ai_addr))->sin6_addr)); } aiTrav = aiTrav->ai_next; } freeaddrinfo(aiRes); return (vIP.size() > 0); } bool LookupHost(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup) { std::string strHost(pszName); if (strHost.empty()) return false; if (boost::algorithm::starts_with(strHost, "[") && boost::algorithm::ends_with(strHost, "]")) { strHost = strHost.substr(1, strHost.size() - 2); } return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup); } bool Lookup(const char* pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions) { if (pszName[0] == 0) return false; int port = portDefault; std::string hostname = ""; SplitHostPort(std::string(pszName), port, hostname); std::vector<CNetAddr> vIP; bool fRet = LookupIntern(hostname.c_str(), vIP, nMaxSolutions, fAllowLookup); if (!fRet) return false; vAddr.resize(vIP.size()); for (unsigned int i = 0; i < vIP.size(); i++) vAddr[i] = CService(vIP[i], port); return true; } bool Lookup(const char* pszName, CService& addr, int portDefault, bool fAllowLookup) { std::vector<CService> vService; bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1); if (!fRet) return false; addr = vService[0]; return true; } bool LookupNumeric(const char* pszName, CService& addr, int portDefault) { return Lookup(pszName, addr, portDefault, false); } /** * Convert milliseconds to a struct timeval for select. */ struct timeval static MillisToTimeval(int64_t nTimeout) { struct timeval timeout; timeout.tv_sec = nTimeout / 1000; timeout.tv_usec = (nTimeout % 1000) * 1000; return timeout; } /** * Read bytes from socket. This will either read the full number of bytes requested * or return False on error or timeout. * This function can be interrupted by boost thread interrupt. * * @param data Buffer to receive into * @param len Length of data to receive * @param timeout Timeout in milliseconds for receive operation * * @note This function requires that hSocket is in non-blocking mode. */ bool static InterruptibleRecv(char* data, size_t len, int timeout, SOCKET& hSocket) { int64_t curTime = GetTimeMillis(); int64_t endTime = curTime + timeout; // Maximum time to wait in one select call. It will take up until this time (in millis) // to break off in case of an interruption. const int64_t maxWait = 1000; while (len > 0 && curTime < endTime) { ssize_t ret = recv(hSocket, data, len, 0); // Optimistically try the recv first if (ret > 0) { len -= ret; data += ret; } else if (ret == 0) { // Unexpected disconnection return false; } else { // Other error or blocking int nErr = WSAGetLastError(); if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) { if (!IsSelectableSocket(hSocket)) { return false; } struct timeval tval = MillisToTimeval(std::min(endTime - curTime, maxWait)); fd_set fdset; FD_ZERO(&fdset); FD_SET(hSocket, &fdset); int nRet = select(hSocket + 1, &fdset, NULL, NULL, &tval); if (nRet == SOCKET_ERROR) { return false; } } else { return false; } } boost::this_thread::interruption_point(); curTime = GetTimeMillis(); } return len == 0; } bool static Socks5(string strDest, int port, SOCKET& hSocket) { LogPrintf("SOCKS5 connecting %s\n", strDest); if (strDest.size() > 255) { CloseSocket(hSocket); return error("Hostname too long"); } char pszSocks5Init[] = "\5\1\0"; ssize_t nSize = sizeof(pszSocks5Init) - 1; ssize_t ret = send(hSocket, pszSocks5Init, nSize, MSG_NOSIGNAL); if (ret != nSize) { CloseSocket(hSocket); return error("Error sending to proxy"); } char pchRet1[2]; if (!InterruptibleRecv(pchRet1, 2, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading proxy response"); } if (pchRet1[0] != 0x05 || pchRet1[1] != 0x00) { CloseSocket(hSocket); return error("Proxy failed to initialize"); } string strSocks5("\5\1"); strSocks5 += '\000'; strSocks5 += '\003'; strSocks5 += static_cast<char>(std::min((int)strDest.size(), 255)); strSocks5 += strDest; strSocks5 += static_cast<char>((port >> 8) & 0xFF); strSocks5 += static_cast<char>((port >> 0) & 0xFF); ret = send(hSocket, strSocks5.data(), strSocks5.size(), MSG_NOSIGNAL); if (ret != (ssize_t)strSocks5.size()) { CloseSocket(hSocket); return error("Error sending to proxy"); } char pchRet2[4]; if (!InterruptibleRecv(pchRet2, 4, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading proxy response"); } if (pchRet2[0] != 0x05) { CloseSocket(hSocket); return error("Proxy failed to accept request"); } if (pchRet2[1] != 0x00) { CloseSocket(hSocket); switch (pchRet2[1]) { case 0x01: return error("Proxy error: general failure"); case 0x02: return error("Proxy error: connection not allowed"); case 0x03: return error("Proxy error: network unreachable"); case 0x04: return error("Proxy error: host unreachable"); case 0x05: return error("Proxy error: connection refused"); case 0x06: return error("Proxy error: TTL expired"); case 0x07: return error("Proxy error: protocol error"); case 0x08: return error("Proxy error: address type not supported"); default: return error("Proxy error: unknown"); } } if (pchRet2[2] != 0x00) { CloseSocket(hSocket); return error("Error: malformed proxy response"); } char pchRet3[256]; switch (pchRet2[3]) { case 0x01: ret = InterruptibleRecv(pchRet3, 4, SOCKS5_RECV_TIMEOUT, hSocket); break; case 0x04: ret = InterruptibleRecv(pchRet3, 16, SOCKS5_RECV_TIMEOUT, hSocket); break; case 0x03: { ret = InterruptibleRecv(pchRet3, 1, SOCKS5_RECV_TIMEOUT, hSocket); if (!ret) { CloseSocket(hSocket); return error("Error reading from proxy"); } int nRecv = pchRet3[0]; ret = InterruptibleRecv(pchRet3, nRecv, SOCKS5_RECV_TIMEOUT, hSocket); break; } default: CloseSocket(hSocket); return error("Error: malformed proxy response"); } if (!ret) { CloseSocket(hSocket); return error("Error reading from proxy"); } if (!InterruptibleRecv(pchRet3, 2, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading from proxy"); } LogPrintf("SOCKS5 connected %s\n", strDest); return true; } bool static ConnectSocketDirectly(const CService& addrConnect, SOCKET& hSocketRet, int nTimeout) { hSocketRet = INVALID_SOCKET; struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString()); return false; } SOCKET hSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); if (hSocket == INVALID_SOCKET) return false; #ifdef SO_NOSIGPIPE int set = 1; // Different way of disabling SIGPIPE on BSD setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif // Set to non-blocking if (!SetSocketNonBlocking(hSocket, true)) return error("ConnectSocketDirectly: Setting socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError())); if (connect(hSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) { int nErr = WSAGetLastError(); // WSAEINVAL is here because some legacy version of winsock uses it if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) { struct timeval timeout = MillisToTimeval(nTimeout); fd_set fdset; FD_ZERO(&fdset); FD_SET(hSocket, &fdset); int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); if (nRet == 0) { LogPrint("net", "connection to %s timeout\n", addrConnect.ToString()); CloseSocket(hSocket); return false; } if (nRet == SOCKET_ERROR) { LogPrintf("select() for %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } socklen_t nRetSize = sizeof(nRet); #ifdef WIN32 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR) #else if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) #endif { LogPrintf("getsockopt() for %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } if (nRet != 0) { LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } } #ifdef WIN32 else if (WSAGetLastError() != WSAEISCONN) #else else #endif { LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } } hSocketRet = hSocket; return true; } bool SetProxy(enum Network net, CService addrProxy) { assert(net >= 0 && net < NET_MAX); if (!addrProxy.IsValid()) return false; LOCK(cs_proxyInfos); proxyInfo[net] = addrProxy; return true; } bool GetProxy(enum Network net, proxyType& proxyInfoOut) { assert(net >= 0 && net < NET_MAX); LOCK(cs_proxyInfos); if (!proxyInfo[net].IsValid()) return false; proxyInfoOut = proxyInfo[net]; return true; } bool SetNameProxy(CService addrProxy) { if (!addrProxy.IsValid()) return false; LOCK(cs_proxyInfos); nameProxy = addrProxy; return true; } bool GetNameProxy(CService& nameProxyOut) { LOCK(cs_proxyInfos); if (!nameProxy.IsValid()) return false; nameProxyOut = nameProxy; return true; } bool HaveNameProxy() { LOCK(cs_proxyInfos); return nameProxy.IsValid(); } bool IsProxy(const CNetAddr& addr) { LOCK(cs_proxyInfos); for (int i = 0; i < NET_MAX; i++) { if (addr == (CNetAddr)proxyInfo[i]) return true; } return false; } bool ConnectSocket(const CService& addrDest, SOCKET& hSocketRet, int nTimeout, bool* outProxyConnectionFailed) { proxyType proxy; if (outProxyConnectionFailed) *outProxyConnectionFailed = false; // no proxy needed (none set for target network) if (!GetProxy(addrDest.GetNetwork(), proxy)) return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout); SOCKET hSocket = INVALID_SOCKET; // first connect to proxy server if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) { if (outProxyConnectionFailed) *outProxyConnectionFailed = true; return false; } // do socks negotiation if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket)) return false; hSocketRet = hSocket; return true; } bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed) { string strDest; int port = portDefault; if (outProxyConnectionFailed) *outProxyConnectionFailed = false; SplitHostPort(string(pszDest), port, strDest); SOCKET hSocket = INVALID_SOCKET; CService nameProxy; GetNameProxy(nameProxy); CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port); if (addrResolved.IsValid()) { addr = addrResolved; return ConnectSocket(addr, hSocketRet, nTimeout); } addr = CService("0.0.0.0:0"); if (!HaveNameProxy()) return false; // first connect to name proxy server if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout)) { if (outProxyConnectionFailed) *outProxyConnectionFailed = true; return false; } // do socks negotiation if (!Socks5(strDest, (unsigned short)port, hSocket)) return false; hSocketRet = hSocket; return true; } void CNetAddr::Init() { memset(ip, 0, sizeof(ip)); } void CNetAddr::SetIP(const CNetAddr& ipIn) { memcpy(ip, ipIn.ip, sizeof(ip)); } void CNetAddr::SetRaw(Network network, const uint8_t* ip_in) { switch (network) { case NET_IPV4: memcpy(ip, pchIPv4, 12); memcpy(ip + 12, ip_in, 4); break; case NET_IPV6: memcpy(ip, ip_in, 16); break; default: assert(!"invalid network"); } } static const unsigned char pchOnionCat[] = {0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43}; bool CNetAddr::SetSpecial(const std::string& strName) { if (strName.size() > 6 && strName.substr(strName.size() - 6, 6) == ".onion") { std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str()); if (vchAddr.size() != 16 - sizeof(pchOnionCat)) return false; memcpy(ip, pchOnionCat, sizeof(pchOnionCat)); for (unsigned int i = 0; i < 16 - sizeof(pchOnionCat); i++) ip[i + sizeof(pchOnionCat)] = vchAddr[i]; return true; } return false; } CNetAddr::CNetAddr() { Init(); } CNetAddr::CNetAddr(const struct in_addr& ipv4Addr) { SetRaw(NET_IPV4, (const uint8_t*)&ipv4Addr); } CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr) { SetRaw(NET_IPV6, (const uint8_t*)&ipv6Addr); } CNetAddr::CNetAddr(const char* pszIp, bool fAllowLookup) { Init(); std::vector<CNetAddr> vIP; if (LookupHost(pszIp, vIP, 1, fAllowLookup)) *this = vIP[0]; } CNetAddr::CNetAddr(const std::string& strIp, bool fAllowLookup) { Init(); std::vector<CNetAddr> vIP; if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup)) *this = vIP[0]; } unsigned int CNetAddr::GetByte(int n) const { return ip[15 - n]; } bool CNetAddr::IsIPv4() const { return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); } bool CNetAddr::IsIPv6() const { return (!IsIPv4() && !IsTor()); } bool CNetAddr::IsRFC1918() const { return IsIPv4() && (GetByte(3) == 10 || (GetByte(3) == 192 && GetByte(2) == 168) || (GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31))); } bool CNetAddr::IsRFC2544() const { return IsIPv4() && GetByte(3) == 198 && (GetByte(2) == 18 || GetByte(2) == 19); } bool CNetAddr::IsRFC3927() const { return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); } bool CNetAddr::IsRFC6598() const { return IsIPv4() && GetByte(3) == 100 && GetByte(2) >= 64 && GetByte(2) <= 127; } bool CNetAddr::IsRFC5737() const { return IsIPv4() && ((GetByte(3) == 192 && GetByte(2) == 0 && GetByte(1) == 2) || (GetByte(3) == 198 && GetByte(2) == 51 && GetByte(1) == 100) || (GetByte(3) == 203 && GetByte(2) == 0 && GetByte(1) == 113)); } bool CNetAddr::IsRFC3849() const { return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8; } bool CNetAddr::IsRFC3964() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x02); } bool CNetAddr::IsRFC6052() const { static const unsigned char pchRFC6052[] = {0, 0x64, 0xFF, 0x9B, 0, 0, 0, 0, 0, 0, 0, 0}; return (memcmp(ip, pchRFC6052, sizeof(pchRFC6052)) == 0); } bool CNetAddr::IsRFC4380() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0); } bool CNetAddr::IsRFC4862() const { static const unsigned char pchRFC4862[] = {0xFE, 0x80, 0, 0, 0, 0, 0, 0}; return (memcmp(ip, pchRFC4862, sizeof(pchRFC4862)) == 0); } bool CNetAddr::IsRFC4193() const { return ((GetByte(15) & 0xFE) == 0xFC); } bool CNetAddr::IsRFC6145() const { static const unsigned char pchRFC6145[] = {0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0}; return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); } bool CNetAddr::IsRFC4843() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); } bool CNetAddr::IsTor() const { return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); } bool CNetAddr::IsLocal() const { // IPv4 loopback if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) return true; // IPv6 loopback (::1/128) static const unsigned char pchLocal[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (memcmp(ip, pchLocal, 16) == 0) return true; return false; } bool CNetAddr::IsMulticast() const { return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) || (GetByte(15) == 0xFF); } bool CNetAddr::IsValid() const { // Cleanup 3-byte shifted addresses caused by garbage in size field // of addr messages from versions before 0.2.9 checksum. // Two consecutive addr messages look like this: // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... // so if the first length field is garbled, it reads the second batch // of addr misaligned by 3 bytes. if (memcmp(ip, pchIPv4 + 3, sizeof(pchIPv4) - 3) == 0) return false; // unspecified IPv6 address (::/128) unsigned char ipNone[16] = {}; if (memcmp(ip, ipNone, 16) == 0) return false; // documentation IPv6 address if (IsRFC3849()) return false; if (IsIPv4()) { // INADDR_NONE uint32_t ipNone = INADDR_NONE; if (memcmp(ip + 12, &ipNone, 4) == 0) return false; // 0 ipNone = 0; if (memcmp(ip + 12, &ipNone, 4) == 0) return false; } return true; } bool CNetAddr::IsRoutable() const { return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal()); } enum Network CNetAddr::GetNetwork() const { if (!IsRoutable()) return NET_UNROUTABLE; if (IsIPv4()) return NET_IPV4; if (IsTor()) return NET_TOR; return NET_IPV6; } std::string CNetAddr::ToStringIP() const { if (IsTor()) return EncodeBase32(&ip[6], 10) + ".onion"; CService serv(*this, 0); struct sockaddr_storage sockaddr; socklen_t socklen = sizeof(sockaddr); if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { char name[1025] = ""; if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST)) return std::string(name); } if (IsIPv4()) return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); else return strprintf("%x:%x:%x:%x:%x:%x:%x:%x", GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12), GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8), GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4), GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0)); } std::string CNetAddr::ToString() const { return ToStringIP(); } bool operator==(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) == 0); } bool operator!=(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) != 0); } bool operator<(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) < 0); } bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const { if (!IsIPv4()) return false; memcpy(pipv4Addr, ip + 12, 4); return true; } bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const { memcpy(pipv6Addr, ip, 16); return true; } // get canonical identifier of an address' group // no two connections will be attempted to addresses with the same group std::vector<unsigned char> CNetAddr::GetGroup() const { std::vector<unsigned char> vchRet; int nClass = NET_IPV6; int nStartByte = 0; int nBits = 16; // all local addresses belong to the same group if (IsLocal()) { nClass = 255; nBits = 0; } // all unroutable addresses belong to the same group if (!IsRoutable()) { nClass = NET_UNROUTABLE; nBits = 0; } // for IPv4 addresses, '1' + the 16 higher-order bits of the IP // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix else if (IsIPv4() || IsRFC6145() || IsRFC6052()) { nClass = NET_IPV4; nStartByte = 12; } // for 6to4 tunnelled addresses, use the encapsulated IPv4 address else if (IsRFC3964()) { nClass = NET_IPV4; nStartByte = 2; } // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address else if (IsRFC4380()) { vchRet.push_back(NET_IPV4); vchRet.push_back(GetByte(3) ^ 0xFF); vchRet.push_back(GetByte(2) ^ 0xFF); return vchRet; } else if (IsTor()) { nClass = NET_TOR; nStartByte = 6; nBits = 4; } // for he.net, use /36 groups else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70) nBits = 36; // for the rest of the IPv6 network, use /32 groups else nBits = 32; vchRet.push_back(nClass); while (nBits >= 8) { vchRet.push_back(GetByte(15 - nStartByte)); nStartByte++; nBits -= 8; } if (nBits > 0) vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1)); return vchRet; } uint64_t CNetAddr::GetHash() const { uint256 hash = Hash(&ip[0], &ip[16]); uint64_t nRet; memcpy(&nRet, &hash, sizeof(nRet)); return nRet; } // private extensions to enum Network, only returned by GetExtNetwork, // and only used in GetReachabilityFrom static const int NET_UNKNOWN = NET_MAX + 0; static const int NET_TEREDO = NET_MAX + 1; int static GetExtNetwork(const CNetAddr* addr) { if (addr == NULL) return NET_UNKNOWN; if (addr->IsRFC4380()) return NET_TEREDO; return addr->GetNetwork(); } /** Calculates a metric for how reachable (*this) is from a given partner */ int CNetAddr::GetReachabilityFrom(const CNetAddr* paddrPartner) const { enum Reachability { REACH_UNREACHABLE, REACH_DEFAULT, REACH_TEREDO, REACH_IPV6_WEAK, REACH_IPV4, REACH_IPV6_STRONG, REACH_PRIVATE }; if (!IsRoutable()) return REACH_UNREACHABLE; int ourNet = GetExtNetwork(this); int theirNet = GetExtNetwork(paddrPartner); bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); switch (theirNet) { case NET_IPV4: switch (ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; } case NET_IPV6: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV4: return REACH_IPV4; case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled } case NET_TOR: switch (ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well case NET_TOR: return REACH_PRIVATE; } case NET_TEREDO: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; } case NET_UNKNOWN: case NET_UNROUTABLE: default: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address } } } void CService::Init() { port = 0; } CService::CService() { Init(); } CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn) { } CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn) { } CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn) { } CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { assert(addr.sin_family == AF_INET); } CService::CService(const struct sockaddr_in6& addr) : CNetAddr(addr.sin6_addr), port(ntohs(addr.sin6_port)) { assert(addr.sin6_family == AF_INET6); } bool CService::SetSockAddr(const struct sockaddr* paddr) { switch (paddr->sa_family) { case AF_INET: *this = CService(*(const struct sockaddr_in*)paddr); return true; case AF_INET6: *this = CService(*(const struct sockaddr_in6*)paddr); return true; default: return false; } } CService::CService(const char* pszIpPort, bool fAllowLookup) { Init(); CService ip; if (Lookup(pszIpPort, ip, 0, fAllowLookup)) *this = ip; } CService::CService(const char* pszIpPort, int portDefault, bool fAllowLookup) { Init(); CService ip; if (Lookup(pszIpPort, ip, portDefault, fAllowLookup)) *this = ip; } CService::CService(const std::string& strIpPort, bool fAllowLookup) { Init(); CService ip; if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup)) *this = ip; } CService::CService(const std::string& strIpPort, int portDefault, bool fAllowLookup) { Init(); CService ip; if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup)) *this = ip; } unsigned short CService::GetPort() const { return port; } bool operator==(const CService& a, const CService& b) { return (CNetAddr)a == (CNetAddr)b && a.port == b.port; } bool operator!=(const CService& a, const CService& b) { return (CNetAddr)a != (CNetAddr)b || a.port != b.port; } bool operator<(const CService& a, const CService& b) { return (CNetAddr)a < (CNetAddr)b || ((CNetAddr)a == (CNetAddr)b && a.port < b.port); } bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t* addrlen) const { if (IsIPv4()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in)) return false; *addrlen = sizeof(struct sockaddr_in); struct sockaddr_in* paddrin = (struct sockaddr_in*)paddr; memset(paddrin, 0, *addrlen); if (!GetInAddr(&paddrin->sin_addr)) return false; paddrin->sin_family = AF_INET; paddrin->sin_port = htons(port); return true; } if (IsIPv6()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6)) return false; *addrlen = sizeof(struct sockaddr_in6); struct sockaddr_in6* paddrin6 = (struct sockaddr_in6*)paddr; memset(paddrin6, 0, *addrlen); if (!GetIn6Addr(&paddrin6->sin6_addr)) return false; paddrin6->sin6_family = AF_INET6; paddrin6->sin6_port = htons(port); return true; } return false; } std::vector<unsigned char> CService::GetKey() const { std::vector<unsigned char> vKey; vKey.resize(18); memcpy(&vKey[0], ip, 16); vKey[16] = port / 0x100; vKey[17] = port & 0x0FF; return vKey; } std::string CService::ToStringPort() const { return strprintf("%u", port); } std::string CService::ToStringIPPort() const { if (IsIPv4() || IsTor()) { return ToStringIP() + ":" + ToStringPort(); } else { return "[" + ToStringIP() + "]:" + ToStringPort(); } } std::string CService::ToString() const { return ToStringIPPort(); } void CService::SetPort(unsigned short portIn) { port = portIn; } CSubNet::CSubNet() : valid(false) { memset(netmask, 0, sizeof(netmask)); } CSubNet::CSubNet(const std::string& strSubnet, bool fAllowLookup) { size_t slash = strSubnet.find_last_of('/'); std::vector<CNetAddr> vIP; valid = true; // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask, 255, sizeof(netmask)); std::string strAddress = strSubnet.substr(0, slash); if (LookupHost(strAddress.c_str(), vIP, 1, fAllowLookup)) { network = vIP[0]; if (slash != strSubnet.npos) { std::string strNetmask = strSubnet.substr(slash + 1); int32_t n; // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = network.IsIPv4() ? 12 : 0; if (ParseInt32(strNetmask, &n)) // If valid number, assume /24 symtex { if (n >= 0 && n <= (128 - astartofs * 8)) // Only valid if in range of bits of address { n += astartofs * 8; // Clear bits [n..127] for (; n < 128; ++n) netmask[n >> 3] &= ~(1 << (7 - (n & 7))); } else { valid = false; } } else // If not a valid number, try full netmask syntax { if (LookupHost(strNetmask.c_str(), vIP, 1, false)) // Never allow lookup for netmask { // Copy only the *last* four bytes in case of IPv4, the rest of the mask should stay 1's as // we don't want pchIPv4 to be part of the mask. for (int x = astartofs; x < 16; ++x) netmask[x] = vIP[0].ip[x]; } else { valid = false; } } } } else { valid = false; } // Normalize network according to netmask for (int x = 0; x < 16; ++x) network.ip[x] &= netmask[x]; } bool CSubNet::Match(const CNetAddr& addr) const { if (!valid || !addr.IsValid()) return false; for (int x = 0; x < 16; ++x) if ((addr.ip[x] & netmask[x]) != network.ip[x]) return false; return true; } std::string CSubNet::ToString() const { std::string strNetmask; if (network.IsIPv4()) strNetmask = strprintf("%u.%u.%u.%u", netmask[12], netmask[13], netmask[14], netmask[15]); else strNetmask = strprintf("%x:%x:%x:%x:%x:%x:%x:%x", netmask[0] << 8 | netmask[1], netmask[2] << 8 | netmask[3], netmask[4] << 8 | netmask[5], netmask[6] << 8 | netmask[7], netmask[8] << 8 | netmask[9], netmask[10] << 8 | netmask[11], netmask[12] << 8 | netmask[13], netmask[14] << 8 | netmask[15]); return network.ToString() + "/" + strNetmask; } bool CSubNet::IsValid() const { return valid; } bool operator==(const CSubNet& a, const CSubNet& b) { return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16); } bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); } #ifdef WIN32 std::string NetworkErrorString(int err) { char buf[256]; buf[0] = 0; if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), NULL)) { return strprintf("%s (%d)", buf, err); } else { return strprintf("Unknown error (%d)", err); } } #else std::string NetworkErrorString(int err) { char buf[256]; const char* s = buf; buf[0] = 0; /* Too bad there are two incompatible implementations of the * thread-safe strerror. */ #ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */ s = strerror_r(err, buf, sizeof(buf)); #else /* POSIX variant always returns message in buffer */ if (strerror_r(err, buf, sizeof(buf))) buf[0] = 0; #endif return strprintf("%s (%d)", s, err); } #endif bool CloseSocket(SOCKET& hSocket) { if (hSocket == INVALID_SOCKET) return false; #ifdef WIN32 int ret = closesocket(hSocket); #else int ret = close(hSocket); #endif hSocket = INVALID_SOCKET; return ret != SOCKET_ERROR; } bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking) { if (fNonBlocking) { #ifdef WIN32 u_long nOne = 1; if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) { #else int fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) { #endif CloseSocket(hSocket); return false; } } else { #ifdef WIN32 u_long nZero = 0; if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) { #else int fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags & ~O_NONBLOCK) == SOCKET_ERROR) { #endif CloseSocket(hSocket); return false; } } return true; }
[ "office@altbet.io" ]
office@altbet.io
74be42ba426c1650f995de4a5ddaed1ffc04f073
d4b733f2e00b5d0ab103ea0df6341648d95c993b
/src/c-cpp/lib/sst/private/guts/windows_socket_core/native_so_reuseport.cpp
3c11a25fee80bb679223c19ab226d966ccd8ce97
[ "MIT" ]
permissive
stealthsoftwareinc/sst
ad6117a3d5daf97d947862674336e6938c0bc699
f828f77db0ab27048b3204e10153ee8cfc1b2081
refs/heads/master
2023-04-06T15:21:14.371804
2023-03-24T08:30:48
2023-03-24T08:30:48
302,539,309
1
0
null
null
null
null
UTF-8
C++
false
false
1,638
cpp
// // Copyright (C) 2012-2023 Stealth Software Technologies, Inc. // // 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 (including // the next paragraph) 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. // // SPDX-License-Identifier: MIT // // Include first to test independence. #include <sst/private/guts/windows_socket_core.hpp> // Include twice to test idempotence. #include <sst/private/guts/windows_socket_core.hpp> // #include <sst/config.h> #if SST_WITH_WINDOWS_WS2_32 namespace sst { namespace guts { int windows_socket_core::native_so_reuseport() { return 0; } } // namespace guts } // namespace sst #endif // #if SST_WITH_WINDOWS_WS2_32
[ "sst@stealthsoftwareinc.com" ]
sst@stealthsoftwareinc.com
f5f9d5814fb8a73c2b5e2e29dac84144ae042bd3
b437a9f1bb2e7a8675673fb2d2baf790c8722a27
/Harry Potter sorting hat game.cpp
c54b3f8f4acf1a49ef6cca82f187153c8616298d
[]
no_license
Tierraoscura/Harry-Potter-sorting-hat-game
26f4336b3e421c1afde0d92ce5b52b44aba98a02
160f94d4590f0f6116b836ce6ce4b23a5639d7d0
refs/heads/main
2023-07-27T05:03:06.369799
2021-09-08T06:52:06
2021-09-08T06:52:06
379,875,293
0
0
null
null
null
null
UTF-8
C++
false
false
2,604
cpp
#include <iostream> int main() { int gryffindor = 0; int hufflepuff = 0; int ravenclaw = 0; int slytherin = 0; int answer1 = 0; int answer2 = 0; int answer3 = 0; int answer4 = 0; std::cout << "~~~~~~~~~~~~~~~~~~~~~\n"; std::cout << "The Sorting Hat Quiz!\n"; std::cout << "~~~~~~~~~~~~~~~~~~~~~\n"; std::cout << "Q1) When I'm dead, I want people to remember me as:\n\n"; std::cout << "1) The Good\n"; std::cout << "2) The Great\n"; std::cout << "3) The Wise\n"; std::cout << "4) The Bold\n\n"; std::cin >> answer1; if(answer1 == 1) { hufflepuff++; } else if(answer1 == 2) { slytherin++; } else if(answer1 == 3) { ravenclaw++; } else if(answer1 == 4) { gryffindor++; } else { std::cout << "Invalid input\n"; } std::cout << "Q2) Dawn or Dusk?\n"; std::cout << "1) Dawn\n"; std::cout << "2) Dusk\n"; std::cin >> answer2; if(answer2 == 1) { gryffindor; ravenclaw; } else if(answer2 == 2) { hufflepuff++; slytherin++; } else { std::cout << "Invalid input\n"; } std::cout << "Q3) Which kind of instrument most pleases your ear?\n"; std::cout << "1) The violin\n"; std::cout << "2) The trumpet\n"; std::cout << "3) The piano\n"; std::cout << "4) The drum\n"; std::cin >> answer3; if(answer3 == 1) { slytherin++; } else if(answer3 == 2) { hufflepuff++; } else if(answer3 == 3) { ravenclaw++; } else if(answer3 == 4) { gryffindor++; } else { std::cout << "Invalid input\n"; } std::cout << "Q4) Which road tempts you most?\n"; std::cout << "1) The wide, sunny grassy lane\n"; std::cout << "2) The narrow, dark, lantern-lit alley\n"; std::cout << "3) The twisting, leaf-strewn path through woods\n"; std::cout << "4) The cobbled street lined (ancient buildings)\n"; std::cin >> answer4; if(answer4 == 1) { hufflepuff++; } else if(answer4 == 2) { slytherin++; } else if(answer4 == 3) { gryffindor++; } else if(answer4 == 4) { ravenclaw++; } else { std::cout << "Invalid input\n"; } int max = 0; std::string house; if(gryffindor > max) { max = gryffindor; house = "Gryffindor"; } if(hufflepuff > max) { max = hufflepuff; house = "Hufflepuff"; } if(ravenclaw > max) { max = ravenclaw; house = "Ravenclaw"; } if(slytherin > max) { max = slytherin; house = "Slytherin"; } std::cout << house << "!\n"; return 0; }
[ "noreply@github.com" ]
Tierraoscura.noreply@github.com
10cc70b1993d525716563a9e8c27d233bf2f2e51
f7f6602e4b64c3cb45eab943bdba226a6e4efaf0
/include/Propitious/Memory/allocator.hpp
432f2a8cfa62cfb6c26c3c9f861a6b01aec5e0df
[]
no_license
SleepyAkubi/PropitiousPrivate
8dd87dc8ce182021dae2fb25387b1bb84c825634
e801f567a08d54ce643f457f079a3c3059079169
refs/heads/master
2022-10-02T12:09:17.388756
2016-02-27T19:12:50
2016-02-27T19:12:50
44,257,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,363
hpp
#ifndef PROPITIOUS_MEMORY_ALLOCATOR_HPP #define PROPITIOUS_MEMORY_ALLOCATOR_HPP #include <Propitious/Common.hpp> #include <new> #include <utility> namespace Propitious { class PROPITIOUS_EXPORT Allocator : private NonCopyable { public: using vol = usize; static const vol defaultAlignment = 4; static const vol notTracked = (vol)(-1); Allocator() {} virtual ~Allocator() {} virtual void* allocate(vol size, vol alignment = defaultAlignment) = 0; virtual void deallocate(void* pointer) = 0; virtual vol allocatedSize(void* pointer) = 0; template <typename T, typename... Args> T* spawn(Args&&... args) { return new (allocate(sizeof(T), alignof(T))) T(std::forward<Args>(args...)); } template <typename T> void murder(T* ptr) { if (ptr) { ptr->~T(); deallocate(ptr); } } }; namespace EndOf { const Allocator::vol Vol = (Allocator::vol)(-1); } PROPITIOUS_EXPORT Allocator& defaultAllocator(); } /* #ifndef PROPITIOUS_DONT_MANAGE_MEMORY inline void* operator new(Propitious::usize size) { Propitious::Allocator& allocator = Propitious::defaultAllocator(); return allocator.allocate((Propitious::Allocator::vol) size); } inline void operator delete(void* size) { Propitious::Allocator& allocator = Propitious::defaultAllocator(); return allocator.deallocate(size); } #endif */ #endif
[ "thewarpdimension@gmail.com" ]
thewarpdimension@gmail.com
79d5df9ebdb532a0ca8cb3478651e5ee4377b6ca
afe5e1d8ca27d3465abd0770de11714d78830310
/runtime/stdlib/llambda/list/list.cpp
6c380520104e06891ade12f25219eadd07dab3fe
[ "Apache-2.0" ]
permissive
8l/llambda
8a0c62b744ab0a45d7dd86355823fc70ee93b924
a8624ddb1c8ae1e7ba55d0f853050798892daa58
refs/heads/master
2020-12-25T23:57:24.994389
2015-04-14T10:34:08
2015-04-14T10:34:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,810
cpp
#include <vector> #include <sstream> #include "binding/ListElementCell.h" #include "binding/BooleanCell.h" #include "binding/ProperList.h" #include "binding/TypedProcedureCell.h" #include "binding/FlonumCell.h" #include "binding/ExactIntegerCell.h" #include "alloc/StrongRefVector.h" #include "core/error.h" using namespace lliby; namespace { struct SplitResult { ProperList<AnyCell> *head; AnyCell *tail; }; SplitResult splitList(World &world, const char *procName, AnyCell *obj, std::uint32_t count) { AnyCell *tail = obj; alloc::StrongRefVector<AnyCell> headElements(world); while(count--) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { std::ostringstream message; message << procName << " on list of insufficient length"; signalError(world, ErrorCategory::Range, message.str()); } headElements.push_back(pairTail->car()); tail = cell_unchecked_cast<AnyCell>(pairTail->cdr()); } // Root our tail while we allocate the head list alloc::StrongRoot<AnyCell> tailRoot(world, &tail); // Build the head list ProperList<AnyCell> *head = ProperList<AnyCell>::create(world, headElements); return {head, tail}; } struct SpanResult { ProperList<AnyCell> *head; ProperList<AnyCell> *tail; }; template<typename T> SpanResult spanList(World &world, const char *procName, ProperList<AnyCell> *list, T predicate) { alloc::StrongRef<ProperList<AnyCell>> tail(world, list); alloc::StrongRefVector<AnyCell> headElements(world); while(true) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { // Ran out of list break; } if (!predicate(pairTail->car())) { // Predicate failed break; } headElements.push_back(pairTail->car()); tail = cell_unchecked_cast<ProperList<AnyCell>>(pairTail->cdr()); } // Build the head list ProperList<AnyCell> *head = ProperList<AnyCell>::create(world, headElements); return {head, tail}; } /** * Applies a procedure with the head values from a series of input lists and advances the lists * * If any of the lists have reached their end then this will return false and not apply the procedure. The input * lists are of type AnyCell to reflect that this function and its callers should be prepared to have its input * lists mutated to improper lists by the passed procedure. * * @param world World to apply the procedure in * @param firstList Reference to the first proper list of values. This will be advanced to the next element. * @param restLists Vector of other value proper lists. These will be advanced to their next elements. * @param proc Procedure to apply. This will be passed one argument from each of the input lists. * @param result Pointer to a location to store the result value. If this function returns false then the * result will not be written to. * @return Boolean indicating if all of the input lists were non-empty and the procedure was invoked. */ template<typename T> bool consumeInputLists(World &world, alloc::StrongRef<AnyCell> &firstList, alloc::StrongRefVector<AnyCell> &restLists, alloc::StrongRef<TypedProcedureCell<T, AnyCell*, RestValues<AnyCell>*>> proc, T* result) { auto firstPair = cell_cast<PairCell>(firstList); if (firstPair == nullptr) { // Reached end of the first list return false; } // Advance the list and store the head value firstList.setData(cell_unchecked_cast<ProperList<AnyCell>>(firstPair->cdr())); AnyCell *firstValue = firstPair->car(); std::vector<AnyCell*> restValues(restLists.size()); for(std::size_t i = 0; i < restLists.size(); i++) { auto restPair = cell_cast<PairCell>(restLists[i]); if (restPair == nullptr) { return false; } // Advance the list and store the head value restLists[i] = cell_unchecked_cast<ProperList<AnyCell>>(restPair->cdr()); restValues[i] = restPair->car(); } // Build the rest argument list RestValues<AnyCell> *restArgList = RestValues<AnyCell>::create(world, restValues); // Apply the function *result = proc->apply(world, firstValue, restArgList); return true; } } extern "C" { using PredicateProc = TypedProcedureCell<bool, AnyCell*>; using FoldProc = TypedProcedureCell<AnyCell*, AnyCell*, AnyCell*, RestValues<AnyCell>*>; using TabulateProc = TypedProcedureCell<AnyCell*, std::int64_t>; using AppendMapProc = TypedProcedureCell<ProperList<AnyCell>*, AnyCell*, RestValues<AnyCell>*>; using FilterMapProc = TypedProcedureCell<AnyCell*, AnyCell*, RestValues<AnyCell>*>; using AnyProc = TypedProcedureCell<AnyCell*, AnyCell*, RestValues<AnyCell>*>; using EveryProc = AnyProc; using CountProc = AnyProc; AnyCell *lllist_cons_star(World &world, AnyCell *headValue, RestValues<AnyCell> *tailValues) { const auto elementCount = tailValues->size() + 1; if (elementCount == 1) { // This is easy return headValue; } std::vector<AnyCell*> nonTerminalElements(elementCount - 1); nonTerminalElements[0] = headValue; auto tailArgIt = tailValues->begin(); for(RestValues<AnyCell>::size_type i = 1; i < (elementCount - 1); i++) { nonTerminalElements[i] = *(tailArgIt++); } return ListElementCell::createList(world, nonTerminalElements, *tailArgIt); } AnyCell* lllist_fold(World &world, FoldProc *foldProcRaw, AnyCell *initialValue, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<FoldProc> foldProc(world, foldProcRaw); alloc::StrongRef<AnyCell> accum(world, initialValue); // Collect our input lists alloc::StrongRefVector<ListElementCell> inputLists(world); inputLists.push_back(firstListRaw); for(auto restList : *restListsRaw) { // Create the strong ref for the rest list inputLists.push_back(restList); } const auto inputListCount = inputLists.size(); std::vector<AnyCell*> inputVector(inputListCount + 1); std::vector<AnyCell*> restArgVector(inputListCount - 1); while(true) { // Collect our input from out input lists for(size_t i = 0; i < inputListCount; i++) { if (inputLists[i] == EmptyListCell::instance()) { // Reached the end of the list return accum; } auto inputListPair = cell_unchecked_cast<PairCell>(inputLists[i]); inputVector[i] = inputListPair->car(); // Move this forward to the next element inputLists[i] = cell_checked_cast<ListElementCell>(world, inputListPair->cdr(), "Input list mutated during (fold)"); } inputVector[inputListCount] = accum; // Create the rest argument list - the first two input values are passed explicitly std::copy(inputVector.begin() + 2, inputVector.end(), restArgVector.begin()); RestValues<AnyCell> *restArgList = RestValues<AnyCell>::create(world, restArgVector); auto resultValue = foldProc->apply(world, inputVector[0], inputVector[1], restArgList); accum.setData(resultValue); } } ReturnValues<ProperList<AnyCell>>* lllist_partition(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *listHeadRaw) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<ListElementCell> listHead(world, listHeadRaw); alloc::StrongRefVector<AnyCell> trueValues(world); alloc::StrongRefVector<AnyCell> falseValues(world); while(listHead != EmptyListCell::instance()) { // This must be a pair if we're not the empty list and the predicate hasn't been called yet auto headPair = cell_unchecked_cast<PairCell>(listHead); AnyCell *headValue = headPair->car(); if (predicateProc->apply(world, headValue)) { trueValues.push_back(headValue); } else { falseValues.push_back(headValue); } auto *nextHead = cell_checked_cast<ListElementCell>(world, headPair->cdr(), "Input list mutated during (partition)"); listHead.setData(nextHead); } alloc::StrongRef<ProperList<AnyCell>> trueList(world, ProperList<AnyCell>::create(world, trueValues)); ProperList<AnyCell> *falseList(ProperList<AnyCell>::create(world, falseValues)); return ReturnValues<ProperList<AnyCell>>::create(world, {trueList, falseList}); } ProperList<AnyCell>* lllist_list_tabulate(World &world, std::uint32_t count, TabulateProc *initProcRaw) { alloc::StrongRef<TabulateProc> initProc(world, initProcRaw); alloc::StrongRefVector<AnyCell> resultVec(world); for(std::uint32_t i = 0; i < count; i++) { resultVec.push_back(initProc->apply(world, i)); } return ProperList<AnyCell>::create(world, resultVec); } ProperList<AnyCell>* lllist_take(World &world, AnyCell *obj, std::uint32_t count) { return splitList(world, "(take)", obj, count).head; } AnyCell *lllist_drop(World &world, AnyCell *obj, std::uint32_t count) { // Avoid splitList because it will allocate the head list which we don't use AnyCell *tail = obj; while(count--) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { signalError(world, ErrorCategory::Range, "(drop) on list of insufficient length"); } tail = cell_unchecked_cast<AnyCell>(pairTail->cdr()); } return tail; } ReturnValues<AnyCell>* lllist_split_at(World &world, AnyCell *obj, std::uint32_t count) { SplitResult result = splitList(world, "(split-at)", obj, count); return ReturnValues<AnyCell>::create(world, {result.head, result.tail}); } ReturnValues<ProperList<AnyCell>>* lllist_span(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *list) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); SpanResult result = spanList(world, "(span)", list, [&] (AnyCell *datum) { return predicateProc->apply(world, datum); }); return ReturnValues<ProperList<AnyCell>>::create(world, {result.head, result.tail}); } ReturnValues<ProperList<AnyCell>>* lllist_break(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *list) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); SpanResult result = spanList(world, "(break)", list, [&] (AnyCell *datum) { return !predicateProc->apply(world, datum); }); return ReturnValues<ProperList<AnyCell>>::create(world, {result.head, result.tail}); } AnyCell* lllist_any(World &world, AnyProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { // GC root everything alloc::StrongRef<AnyProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); // Run until we get a truth-y value while(true) { AnyCell *resultValue; if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Ran out of lists return BooleanCell::falseInstance(); } if (resultValue != BooleanCell::falseInstance()) { // Found a non-false value return resultValue; } } } AnyCell* lllist_every(World &world, EveryProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<EveryProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); // If all lists are empty we should return #t AnyCell *resultValue = BooleanCell::trueInstance(); // Run until we get a false value while(true) { if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Ran out of lists - return the last result value // This depends on consumeInputLists not modifying resultValue when it returns false return resultValue; } if (resultValue == BooleanCell::falseInstance()) { // Found a false value - we're false return BooleanCell::falseInstance(); } } } std::int64_t lllist_count(World &world, CountProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<CountProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); std::int64_t counter = 0; while(true) { AnyCell *resultValue; if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Out of lists return counter; } if (resultValue != BooleanCell::falseInstance()) { counter++; } } } ProperList<AnyCell>* lllist_append_map(World &world, AppendMapProc *mapProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<AppendMapProc> mapProc(world, mapProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); alloc::StrongRefVector<AnyCell> resultValues(world); ProperList<AnyCell> *resultList; while(consumeInputLists(world, firstList, restLists, mapProc, &resultList)) { // Splice this list on to the results resultValues.insert(resultValues.end(), resultList->begin(), resultList->end()); } return ProperList<AnyCell>::create(world, resultValues); } ProperList<AnyCell>* lllist_filter_map(World &world, FilterMapProc *mapProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<FilterMapProc> mapProc(world, mapProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); alloc::StrongRefVector<AnyCell> resultValues(world); AnyCell *resultValue; while(consumeInputLists(world, firstList, restLists, mapProc, &resultValue)) { if (resultValue != BooleanCell::falseInstance()) { // Add this value to the results resultValues.push_back(resultValue); } } return ProperList<AnyCell>::create(world, resultValues); } ListElementCell* lllist_iota(World &world, std::uint32_t count, NumberCell *startCell, NumberCell *stepCell) { if (auto startExactIntCell = cell_cast<ExactIntegerCell>(startCell)) { if (auto stepExactIntCell = cell_cast<ExactIntegerCell>(stepCell)) { std::uint32_t start = startExactIntCell->value(); std::uint32_t step = stepExactIntCell->value(); std::vector<std::uint32_t> values(count); for(std::uint32_t i = 0; i < count; i++) { values[i] = start + (step * i); } return ProperList<ExactIntegerCell>::emplaceValues(world, values); } } double start = startCell->toDouble(); double step = stepCell->toDouble(); std::vector<double> values(count); for(std::uint32_t i = 0; i < count; i++) { values[i] = start + (step * i); } return ProperList<FlonumCell>::emplaceValues(world, values); } }
[ "etaoins@gmail.com" ]
etaoins@gmail.com
53376d181f4bc713552f08afdd2b26394bc94216
86b55c5bfd3cbce99db30907ecc63c0038b0f1e2
/components/exo/text_input.cc
50e272f09892f5f1efc85eec3712e7c0da6e22fa
[ "BSD-3-Clause" ]
permissive
Claw-Lang/chromium
3ed8160ea3f2b5d51fdc2a7d764aadd5b443eb3f
651cebac57fcd0ce2c7c974494602cc098fe7348
refs/heads/master
2022-11-19T07:46:03.573023
2020-07-28T06:45:27
2020-07-28T06:45:27
283,134,740
1
0
BSD-3-Clause
2020-07-28T07:26:49
2020-07-28T07:26:48
null
UTF-8
C++
false
false
11,181
cc
// Copyright 2018 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 "components/exo/text_input.h" #include <algorithm> #include "ash/keyboard/ui/keyboard_ui_controller.h" #include "base/strings/utf_string_conversions.h" #include "components/exo/surface.h" #include "components/exo/wm_helper.h" #include "third_party/icu/source/common/unicode/uchar.h" #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/base/ime/input_method.h" #include "ui/events/event.h" namespace exo { namespace { ui::InputMethod* GetInputMethod(aura::Window* window) { if (!window || !window->GetHost()) return nullptr; return window->GetHost()->GetInputMethod(); } } // namespace size_t OffsetFromUTF8Offset(const base::StringPiece& text, uint32_t offset) { return base::UTF8ToUTF16(text.substr(0, offset)).size(); } size_t OffsetFromUTF16Offset(const base::StringPiece16& text, uint32_t offset) { return base::UTF16ToUTF8(text.substr(0, offset)).size(); } TextInput::TextInput(std::unique_ptr<Delegate> delegate) : delegate_(std::move(delegate)) {} TextInput::~TextInput() { if (keyboard_ui_controller_) keyboard_ui_controller_->RemoveObserver(this); if (input_method_) Deactivate(); } void TextInput::Activate(Surface* surface) { DLOG_IF(ERROR, window_) << "Already activated with " << window_; DCHECK(surface); window_ = surface->window(); AttachInputMethod(); } void TextInput::Deactivate() { DetachInputMethod(); window_ = nullptr; } void TextInput::ShowVirtualKeyboardIfEnabled() { // Some clients may ask showing virtual keyboard before sending activation. if (!input_method_) { pending_vk_visible_ = true; return; } input_method_->ShowVirtualKeyboardIfEnabled(); } void TextInput::HideVirtualKeyboard() { if (keyboard_ui_controller_) keyboard_ui_controller_->HideKeyboardByUser(); pending_vk_visible_ = false; } void TextInput::Resync() { if (input_method_) input_method_->OnCaretBoundsChanged(this); } void TextInput::SetSurroundingText(const base::string16& text, uint32_t cursor_pos, uint32_t anchor) { surrounding_text_ = text; cursor_pos_ = gfx::Range(cursor_pos); if (anchor < cursor_pos) cursor_pos_->set_start(anchor); else cursor_pos_->set_end(anchor); } void TextInput::SetTypeModeFlags(ui::TextInputType type, ui::TextInputMode mode, int flags, bool should_do_learning) { if (!input_method_) return; bool changed = (input_type_ != type); input_type_ = type; input_mode_ = mode; flags_ = flags; should_do_learning_ = should_do_learning; if (changed) input_method_->OnTextInputTypeChanged(this); } void TextInput::SetCaretBounds(const gfx::Rect& bounds) { if (caret_bounds_ == bounds) return; caret_bounds_ = bounds; if (!input_method_) return; input_method_->OnCaretBoundsChanged(this); } void TextInput::SetCompositionText(const ui::CompositionText& composition) { composition_ = composition; delegate_->SetCompositionText(composition); } void TextInput::ConfirmCompositionText(bool keep_selection) { // TODO(b/134473433) Modify this function so that when keep_selection is // true, the selection is not changed when text committed if (keep_selection) { NOTIMPLEMENTED_LOG_ONCE(); } delegate_->Commit(composition_.text); } void TextInput::ClearCompositionText() { composition_ = ui::CompositionText(); delegate_->SetCompositionText(composition_); } void TextInput::InsertText(const base::string16& text) { delegate_->Commit(text); } void TextInput::InsertChar(const ui::KeyEvent& event) { base::char16 ch = event.GetCharacter(); if (u_isprint(ch)) { InsertText(base::string16(1, ch)); return; } delegate_->SendKey(event); } ui::TextInputType TextInput::GetTextInputType() const { return input_type_; } ui::TextInputMode TextInput::GetTextInputMode() const { return input_mode_; } base::i18n::TextDirection TextInput::GetTextDirection() const { return direction_; } int TextInput::GetTextInputFlags() const { return flags_; } bool TextInput::CanComposeInline() const { return true; } gfx::Rect TextInput::GetCaretBounds() const { return caret_bounds_ + window_->GetBoundsInScreen().OffsetFromOrigin(); } bool TextInput::GetCompositionCharacterBounds(uint32_t index, gfx::Rect* rect) const { return false; } bool TextInput::HasCompositionText() const { return !composition_.text.empty(); } ui::TextInputClient::FocusReason TextInput::GetFocusReason() const { NOTIMPLEMENTED_LOG_ONCE(); return ui::TextInputClient::FOCUS_REASON_OTHER; } bool TextInput::GetTextRange(gfx::Range* range) const { if (!cursor_pos_) return false; range->set_start(0); if (composition_.text.empty()) { range->set_end(surrounding_text_.size()); } else { range->set_end(surrounding_text_.size() - cursor_pos_->length() + composition_.text.size()); } return true; } bool TextInput::GetCompositionTextRange(gfx::Range* range) const { if (!cursor_pos_ || composition_.text.empty()) return false; range->set_start(cursor_pos_->start()); range->set_end(cursor_pos_->start() + composition_.text.size()); return true; } bool TextInput::GetEditableSelectionRange(gfx::Range* range) const { if (!cursor_pos_) return false; range->set_start(cursor_pos_->start()); range->set_end(cursor_pos_->end()); return true; } bool TextInput::SetEditableSelectionRange(const gfx::Range& range) { if (surrounding_text_.size() < range.GetMax()) return false; delegate_->SetCursor( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, range.start()), OffsetFromUTF16Offset(surrounding_text_, range.end()))); return true; } bool TextInput::DeleteRange(const gfx::Range& range) { if (surrounding_text_.size() < range.GetMax()) return false; delegate_->DeleteSurroundingText( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, range.start()), OffsetFromUTF16Offset(surrounding_text_, range.end()))); return true; } bool TextInput::GetTextFromRange(const gfx::Range& range, base::string16* text) const { gfx::Range text_range; if (!GetTextRange(&text_range) || !text_range.Contains(range)) return false; if (composition_.text.empty() || range.GetMax() <= cursor_pos_->GetMin()) { text->assign(surrounding_text_, range.GetMin(), range.length()); return true; } size_t composition_end = cursor_pos_->GetMin() + composition_.text.size(); if (range.GetMin() >= composition_end) { size_t start = range.GetMin() - composition_.text.size() + cursor_pos_->length(); text->assign(surrounding_text_, start, range.length()); return true; } size_t start_in_composition = 0; if (range.GetMin() <= cursor_pos_->GetMin()) { text->assign(surrounding_text_, range.GetMin(), cursor_pos_->GetMin() - range.GetMin()); } else { start_in_composition = range.GetMin() - cursor_pos_->GetMin(); } if (range.GetMax() <= composition_end) { text->append(composition_.text, start_in_composition, range.GetMax() - cursor_pos_->GetMin() - start_in_composition); } else { text->append(composition_.text, start_in_composition, composition_.text.size() - start_in_composition); text->append(surrounding_text_, cursor_pos_->GetMax(), range.GetMax() - composition_end); } return true; } void TextInput::OnInputMethodChanged() { ui::InputMethod* input_method = GetInputMethod(window_); if (input_method == input_method_) return; input_method_->DetachTextInputClient(this); input_method_ = input_method; input_method_->SetFocusedTextInputClient(this); } bool TextInput::ChangeTextDirectionAndLayoutAlignment( base::i18n::TextDirection direction) { if (direction == direction_) return true; direction_ = direction; delegate_->OnTextDirectionChanged(direction_); return true; } void TextInput::ExtendSelectionAndDelete(size_t before, size_t after) { if (!cursor_pos_) return; uint32_t start = (cursor_pos_->GetMin() < before) ? 0 : (cursor_pos_->GetMin() - before); uint32_t end = std::min(cursor_pos_->GetMax() + after, surrounding_text_.size()); delegate_->DeleteSurroundingText( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, start), OffsetFromUTF16Offset(surrounding_text_, end))); } void TextInput::EnsureCaretNotInRect(const gfx::Rect& rect) {} bool TextInput::IsTextEditCommandEnabled(ui::TextEditCommand command) const { return false; } void TextInput::SetTextEditCommandForNextKeyEvent(ui::TextEditCommand command) { } ukm::SourceId TextInput::GetClientSourceForMetrics() const { NOTIMPLEMENTED_LOG_ONCE(); return ukm::kInvalidSourceId; } bool TextInput::ShouldDoLearning() { return should_do_learning_; } bool TextInput::SetCompositionFromExistingText( const gfx::Range& range, const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) { // TODO(https://crbug.com/952757): Implement this method. NOTIMPLEMENTED_LOG_ONCE(); return false; } gfx::Rect TextInput::GetAutocorrectCharacterBounds() const { // TODO(https://crbug.com/952757): Implement this method. NOTIMPLEMENTED_LOG_ONCE(); return gfx::Rect(); } // TODO(crbug.com/1091088) Implement setAutocorrectRange bool TextInput::SetAutocorrectRange(const base::string16& autocorrect_text, const gfx::Range& range) { NOTIMPLEMENTED_LOG_ONCE(); return false; } void TextInput::OnKeyboardVisibilityChanged(bool is_visible) { delegate_->OnVirtualKeyboardVisibilityChanged(is_visible); } void TextInput::AttachInputMethod() { DCHECK(!input_method_); ui::InputMethod* input_method = GetInputMethod(window_); if (!input_method) { LOG(ERROR) << "input method not found"; return; } input_mode_ = ui::TEXT_INPUT_MODE_TEXT; input_type_ = ui::TEXT_INPUT_TYPE_TEXT; input_method_ = input_method; input_method_->SetFocusedTextInputClient(this); delegate_->Activated(); if (!keyboard_ui_controller_ && keyboard::KeyboardUIController::HasInstance()) { auto* keyboard_ui_controller = keyboard::KeyboardUIController::Get(); if (keyboard_ui_controller->IsEnabled()) { keyboard_ui_controller_ = keyboard_ui_controller; keyboard_ui_controller_->AddObserver(this); } } if (pending_vk_visible_) { input_method_->ShowVirtualKeyboardIfEnabled(); pending_vk_visible_ = false; } } void TextInput::DetachInputMethod() { if (!input_method_) { DLOG(ERROR) << "input method already detached"; return; } input_mode_ = ui::TEXT_INPUT_MODE_DEFAULT; input_type_ = ui::TEXT_INPUT_TYPE_NONE; input_method_->DetachTextInputClient(this); input_method_ = nullptr; delegate_->Deactivated(); } } // namespace exo
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
4632c82ecc687a200a720fc5d88d5d6ac9ad436f
c509ec170f31580895c457c29e78463866397c17
/offline/Simulation/DetSim/ARRAY/LHAASOSim/include/LHAASOEventAction.hh
2931c74c3204f585a660a39e334847b8a21160c3
[]
no_license
feipengsy/lodestar
9e2c35cdbb6edf7ce31eff5fcf05412ff7f8453e
e05c01f15d8b3aeed265210a910e475beb11d9b6
refs/heads/master
2021-01-09T21:47:12.332609
2015-06-24T14:54:59
2015-06-24T14:54:59
36,277,481
0
0
null
null
null
null
UTF-8
C++
false
false
2,126
hh
// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // #ifndef LHAASO_EVENT_ACTION_HH #define LHAASO_EVENT_ACTION_HH 1 #include "G4UserEventAction.hh" #include "LHAASOUserAction.h" #include "globals.hh" class G4Event; class LHAASOEventAction : public G4UserEventAction, public LHAASOUserAction { public: LHAASOEventAction(); ~LHAASOEventAction(); void BeginOfEventAction(const G4Event* anEvent); void EndOfEventAction(const G4Event* anEvent); }; #endif
[ "liteng_shiyan@163.com" ]
liteng_shiyan@163.com
2e69c1176540d78a9457666963e6e3e4a16847bd
6f0445ac23b230232358d71ff08802e47416c9d1
/Source/QuickNote/ListTag.h
683b6c006f8134c1b70ca3d3af56e6451d816da3
[]
no_license
vuquangkhtn/QuickNote
0e26cc30cae4bbd9381550bcc7b1689bc3009d63
21ec89f5cb20d1bcaff5bc8ebc4f92c46d608810
refs/heads/master
2021-01-22T10:47:05.017294
2017-02-15T08:48:56
2017-02-15T08:48:56
82,039,753
1
0
null
null
null
null
UTF-8
C++
false
false
509
h
#pragma once #include "Tag.h" #include "Note.h" #include <fstream> #include <string> #include <locale> #include <codecvt> #include <vector> class CListTag { public: vector<CTag> listTags; public: CListTag(); void docDSTagTuFile(string filename); void ghiDSTagVaoFile(string filename); void themTag(CTag tag); void xoaTag(int pos); void findNewTags(CNote); void eraseTags(CNote oldNote); void increaseCountnotes(CNote note); bool isTrueList(); vector<CTag> DecreaseListTags(); int totalNotes(); };
[ "vuquangkhtn@gmail.com" ]
vuquangkhtn@gmail.com
0dfaefddf7dacfeca8bfd45a08faf8dd56ae8343
8dc84558f0058d90dfc4955e905dab1b22d12c08
/components/viz/service/display/gl_renderer.h
1cd981c9d718f26cb57795628e1b1ce40c8ced5f
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
17,581
h
// Copyright 2010 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 COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_ #define COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_ #include <unordered_map> #include <vector> #include "base/cancelable_callback.h" #include "base/containers/circular_deque.h" #include "base/macros.h" #include "components/viz/common/gpu/context_cache_controller.h" #include "components/viz/common/quads/debug_border_draw_quad.h" #include "components/viz/common/quads/render_pass_draw_quad.h" #include "components/viz/common/quads/solid_color_draw_quad.h" #include "components/viz/common/quads/tile_draw_quad.h" #include "components/viz/common/quads/yuv_video_draw_quad.h" #include "components/viz/service/display/color_lut_cache.h" #include "components/viz/service/display/direct_renderer.h" #include "components/viz/service/display/gl_renderer_copier.h" #include "components/viz/service/display/gl_renderer_draw_cache.h" #include "components/viz/service/display/program_binding.h" #include "components/viz/service/display/scoped_gpu_memory_buffer_texture.h" #include "components/viz/service/display/sync_query_collection.h" #include "components/viz/service/display/texture_deleter.h" #include "components/viz/service/viz_service_export.h" #include "ui/gfx/geometry/quad_f.h" #include "ui/latency/latency_info.h" namespace base { class SingleThreadTaskRunner; } namespace gpu { namespace gles2 { class GLES2Interface; } } // namespace gpu namespace viz { class DynamicGeometryBinding; class GLRendererShaderTest; class OutputSurface; class ScopedRenderPassTexture; class StaticGeometryBinding; class StreamVideoDrawQuad; class TextureDrawQuad; // Class that handles drawing of composited render layers using GL. class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { public: class ScopedUseGrContext; GLRenderer(const RendererSettings* settings, OutputSurface* output_surface, DisplayResourceProvider* resource_provider, scoped_refptr<base::SingleThreadTaskRunner> current_task_runner); ~GLRenderer() override; bool use_swap_with_bounds() const { return use_swap_with_bounds_; } void SwapBuffers(std::vector<ui::LatencyInfo> latency_info, bool need_presentation_feedback) override; void SwapBuffersComplete() override; void DidReceiveTextureInUseResponses( const gpu::TextureInUseResponses& responses) override; virtual bool IsContextLost(); protected: void DidChangeVisibility() override; const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } const StaticGeometryBinding* SharedGeometry() const { return shared_geometry_.get(); } // Returns the format to use for storage if copying from the current // framebuffer. If the root renderpass is current, it uses the best matching // format from the OutputSurface, otherwise it uses the best matching format // from the texture being drawn to as the backbuffer. GLenum GetFramebufferCopyTextureFormat(); void ReleaseRenderPassTextures(); enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; void PrepareGeometry(BoundGeometry geometry_to_bind); void SetStencilEnabled(bool enabled); bool stencil_enabled() const { return stencil_shadow_; } void SetBlendEnabled(bool enabled); bool blend_enabled() const { return blend_shadow_; } bool CanPartialSwap() override; void UpdateRenderPassTextures( const RenderPassList& render_passes_in_draw_order, const base::flat_map<RenderPassId, RenderPassRequirements>& render_passes_in_frame) override; void AllocateRenderPassResourceIfNeeded( const RenderPassId& render_pass_id, const RenderPassRequirements& requirements) override; bool IsRenderPassResourceAllocated( const RenderPassId& render_pass_id) const override; gfx::Size GetRenderPassBackingPixelSize( const RenderPassId& render_pass_id) override; void BindFramebufferToOutputSurface() override; void BindFramebufferToTexture(const RenderPassId render_pass_id) override; void SetScissorTestRect(const gfx::Rect& scissor_rect) override; void PrepareSurfaceForPass(SurfaceInitializationMode initialization_mode, const gfx::Rect& render_pass_scissor) override; void DoDrawQuad(const class DrawQuad*, const gfx::QuadF* draw_region) override; void BeginDrawingFrame() override; void FinishDrawingFrame() override; bool FlippedFramebuffer() const override; bool FlippedRootFramebuffer() const; void EnsureScissorTestEnabled() override; void EnsureScissorTestDisabled() override; void CopyDrawnRenderPass(std::unique_ptr<CopyOutputRequest> request) override; void SetEnableDCLayers(bool enable) override; void FinishDrawingQuadList() override; void GenerateMipmap() override; // Returns true if quad requires antialiasing and false otherwise. static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, bool clipped, bool force_aa); // Inflate the quad and fill edge array for fragment shader. // |local_quad| is set to inflated quad. |edge| array is filled with // inflated quad's edge data. static void SetupQuadForClippingAndAntialiasing( const gfx::Transform& device_transform, const DrawQuad* quad, const gfx::QuadF* device_layer_quad, const gfx::QuadF* clip_region, gfx::QuadF* local_quad, float edge[24]); static void SetupRenderPassQuadForClippingAndAntialiasing( const gfx::Transform& device_transform, const RenderPassDrawQuad* quad, const gfx::QuadF* device_layer_quad, const gfx::QuadF* clip_region, gfx::QuadF* local_quad, float edge[24]); private: friend class GLRendererCopierPixelTest; friend class GLRendererShaderPixelTest; friend class GLRendererShaderTest; friend class GLRendererTest; using OverlayResourceLock = std::unique_ptr<DisplayResourceProvider::ScopedReadLockGL>; using OverlayResourceLockList = std::vector<OverlayResourceLock>; // If a RenderPass is used as an overlay, we render the RenderPass with any // effects into a texture for overlay use. We must keep the texture alive past // the execution of SwapBuffers, and such textures are more expensive to make // so we want to reuse them. struct OverlayTexture { RenderPassId render_pass_id; ScopedGpuMemoryBufferTexture texture; int frames_waiting_for_reuse = 0; }; struct DrawRenderPassDrawQuadParams; // If any of the following functions returns false, then it means that drawing // is not possible. bool InitializeRPDQParameters(DrawRenderPassDrawQuadParams* params); void UpdateRPDQShadersForBlending(DrawRenderPassDrawQuadParams* params); bool UpdateRPDQWithSkiaFilters(DrawRenderPassDrawQuadParams* params); void UpdateRPDQTexturesForSampling(DrawRenderPassDrawQuadParams* params); void UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params); void ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, const gfx::ColorSpace& target_color_space); void UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params); void DrawRPDQ(const DrawRenderPassDrawQuadParams& params); static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); void DiscardPixels(); void ClearFramebuffer(); void SetViewport(); void DrawDebugBorderQuad(const DebugBorderDrawQuad* quad); static bool IsDefaultBlendMode(SkBlendMode blend_mode) { return blend_mode == SkBlendMode::kSrcOver; } bool CanApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); void ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); void RestoreBlendFuncToDefault(SkBlendMode blend_mode); gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( const RenderPassDrawQuad* quad, const gfx::Transform& contents_device_transform, const cc::FilterOperations* filters, const cc::FilterOperations* background_filters, const gfx::QuadF* clip_region, bool use_aa, gfx::Rect* unclipped_rect); // Allocates and returns a texture id that contains a copy of the contents // of the current RenderPass being drawn. uint32_t GetBackdropTexture(const gfx::Rect& window_rect); static bool ShouldApplyBackgroundFilters( const RenderPassDrawQuad* quad, const cc::FilterOperations* background_filters); sk_sp<SkImage> ApplyBackgroundFilters( const RenderPassDrawQuad* quad, const cc::FilterOperations& background_filters, uint32_t background_texture, const gfx::Rect& rect, const gfx::Rect& unclipped_rect); const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass) override; void DrawRenderPassQuad(const RenderPassDrawQuad* quadi, const gfx::QuadF* clip_region); void DrawRenderPassQuadInternal(DrawRenderPassDrawQuadParams* params); void DrawSolidColorQuad(const SolidColorDrawQuad* quad, const gfx::QuadF* clip_region); void DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, const gfx::QuadF* clip_region); void EnqueueTextureQuad(const TextureDrawQuad* quad, const gfx::QuadF* clip_region); void FlushTextureQuadCache(BoundGeometry flush_binding); void DrawTileQuad(const TileDrawQuad* quad, const gfx::QuadF* clip_region); void DrawContentQuad(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::QuadF* clip_region); void DrawContentQuadAA(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::Transform& device_transform, const gfx::QuadF& aa_quad, const gfx::QuadF* clip_region); void DrawContentQuadNoAA(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::QuadF* clip_region); void DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, const gfx::QuadF* clip_region); void DrawOverlayCandidateQuadBorder(float* gl_matrix); void SetShaderOpacity(float opacity); void SetShaderQuadF(const gfx::QuadF& quad); void SetShaderMatrix(const gfx::Transform& transform); void SetShaderColor(SkColor color, float opacity); void DrawQuadGeometryClippedByQuadF(const gfx::Transform& draw_transform, const gfx::RectF& quad_rect, const gfx::QuadF& clipping_region_quad, const float uv[8]); void DrawQuadGeometry(const gfx::Transform& projection_matrix, const gfx::Transform& draw_transform, const gfx::RectF& quad_rect); void DrawQuadGeometryWithAA(const DrawQuad* quad, gfx::QuadF* local_quad, const gfx::Rect& tile_rect); // If |dst_color_space| is invalid, then no color conversion (apart from // YUV to RGB conversion) is performed. This explicit argument is available // so that video color conversion can be enabled separately from general color // conversion. void SetUseProgram(const ProgramKey& program_key, const gfx::ColorSpace& src_color_space, const gfx::ColorSpace& dst_color_space); bool MakeContextCurrent(); void InitializeSharedObjects(); void CleanupSharedObjects(); void ReinitializeGLState(); void RestoreGLState(); void ScheduleCALayers(); void ScheduleDCLayers(); void ScheduleOverlays(); // Copies the contents of the render pass draw quad, including filter effects, // to a GL texture, returned in |overlay_texture|. The resulting texture may // be larger than the RenderPassDrawQuad's output, in order to reuse existing // textures. The new size and position is placed in |new_bounds|. void CopyRenderPassDrawQuadToOverlayResource( const CALayerOverlay* ca_layer_overlay, std::unique_ptr<OverlayTexture>* overlay_texture, gfx::RectF* new_bounds); std::unique_ptr<OverlayTexture> FindOrCreateOverlayTexture( const RenderPassId& render_pass_id, int width, int height, const gfx::ColorSpace& color_space); void ReduceAvailableOverlayTextures( const std::vector<std::unique_ptr<OverlayTexture>>& most_recent); // Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null // |rpdq| parameter. Returns ownership of a GL texture that contains the // output of the RenderPassDrawQuad. std::unique_ptr<OverlayTexture> ScheduleRenderPassDrawQuad( const CALayerOverlay* ca_layer_overlay); // Setup/flush all pending overdraw feedback to framebuffer. void SetupOverdrawFeedback(); void FlushOverdrawFeedback(const gfx::Rect& output_rect); // Process overdraw feedback from query. using OverdrawFeedbackCallback = base::Callback<void(unsigned, int)>; void ProcessOverdrawFeedback(std::vector<int>* overdraw, size_t num_expected_results, int max_result, unsigned query, int multiplier); ResourceFormat BackbufferFormat() const; // A map from RenderPass id to the texture used to draw the RenderPass from. base::flat_map<RenderPassId, ScopedRenderPassTexture> render_pass_textures_; // OverlayTextures that are free to be used in the next frame. std::vector<std::unique_ptr<OverlayTexture>> available_overlay_textures_; // OverlayTextures that have been set up for use but are waiting for // SwapBuffers. std::vector<std::unique_ptr<OverlayTexture>> awaiting_swap_overlay_textures_; // OverlayTextures that have been swapped for display on the gpu. Each vector // represents a single frame, and may be empty if none were used in that // frame. Ordered from oldest to most recent frame. std::vector<std::vector<std::unique_ptr<OverlayTexture>>> displayed_overlay_textures_; // OverlayTextures that we have replaced on the gpu but are awaiting // confirmation that we can reuse them. std::vector<std::unique_ptr<OverlayTexture>> awaiting_release_overlay_textures_; // Resources that have been sent to the GPU process, but not yet swapped. OverlayResourceLockList pending_overlay_resources_; // Resources that should be shortly swapped by the GPU process. base::circular_deque<OverlayResourceLockList> swapping_overlay_resources_; // Resources that the GPU process has finished swapping. The key is the // texture id of the resource. std::map<unsigned, OverlayResourceLock> swapped_and_acked_overlay_resources_; unsigned offscreen_framebuffer_id_ = 0u; std::unique_ptr<StaticGeometryBinding> shared_geometry_; std::unique_ptr<DynamicGeometryBinding> clipped_geometry_; gfx::QuadF shared_geometry_quad_; // This will return nullptr if the requested program has not yet been // initialized. const Program* GetProgramIfInitialized(const ProgramKey& key) const; std::unordered_map<ProgramKey, std::unique_ptr<Program>, ProgramKeyHash> program_cache_; const gfx::ColorTransform* GetColorTransform(const gfx::ColorSpace& src, const gfx::ColorSpace& dst); std::map<gfx::ColorSpace, std::map<gfx::ColorSpace, std::unique_ptr<gfx::ColorTransform>>> color_transform_cache_; gpu::gles2::GLES2Interface* gl_; gpu::ContextSupport* context_support_; std::unique_ptr<ContextCacheController::ScopedVisibility> context_visibility_; TextureDeleter texture_deleter_; GLRendererCopier copier_; gfx::Rect swap_buffer_rect_; std::vector<gfx::Rect> swap_content_bounds_; gfx::Rect scissor_rect_; bool is_scissor_enabled_ = false; bool stencil_shadow_ = false; bool blend_shadow_ = false; const Program* current_program_ = nullptr; TexturedQuadDrawCache draw_cache_; int highp_threshold_cache_ = 0; ScopedRenderPassTexture* current_framebuffer_texture_; SyncQueryCollection sync_queries_; bool use_discard_framebuffer_ = false; bool use_sync_query_ = false; bool use_blend_equation_advanced_ = false; bool use_blend_equation_advanced_coherent_ = false; bool use_occlusion_query_ = false; bool use_swap_with_bounds_ = false; // If true, tints all the composited content to red. bool tint_gl_composited_content_ = true; // The method FlippedFramebuffer determines whether the framebuffer associated // with a DrawingFrame is flipped. It makes the assumption that the // DrawingFrame is being used as part of a render pass. If a DrawingFrame is // not being used as part of a render pass, setting it here forces // FlippedFramebuffer to return |true|. bool force_drawing_frame_framebuffer_unflipped_ = false; BoundGeometry bound_geometry_; ColorLUTCache color_lut_cache_; unsigned offscreen_stencil_renderbuffer_id_ = 0; gfx::Size offscreen_stencil_renderbuffer_size_; unsigned num_triangles_drawn_ = 0; // This may be null if the compositor is run on a thread without a // MessageLoop. scoped_refptr<base::SingleThreadTaskRunner> current_task_runner_; base::WeakPtrFactory<GLRenderer> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(GLRenderer); }; } // namespace viz #endif // COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
d5fb81be84d44be5b025011437562f8041d171ea
7da7ee1ed863d4cd4cadef835b16d8950c6952d6
/AOJ/contest_practice/2/A.cpp
80e9987400b01cf31ea1af94b18d7868224051bc
[]
no_license
rikuya6/ICPC_learning
8fd226bcd9f13f37a4d55d6de57702d0ed7182b8
d01e4c764f93f0330cc687365e3ac397e46f9559
refs/heads/master
2022-06-04T10:12:57.981280
2020-05-06T04:58:15
2020-05-06T04:58:15
52,092,562
0
0
null
2018-09-23T13:29:19
2016-02-19T14:20:22
C++
UTF-8
C++
false
false
1,453
cpp
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012 #include <iostream> using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); i++ ) long long table[3][1000000]; int main() { int x, y, z, m; int idx, idx2; int data; int size = 500; table[0][0] = 0; table[1][0] = 0; table[2][0] = 0; table[0][1] = 1; table[1][1] = 1; table[2][1] = 1; for(int i = 2; i < size; i++){ table[0][i] = i; //cout << "table[0][" << i << "]:" << table[0][i] << endl; } for(int i = 2; i < size; i++){ table[1][i] = i * i; } for(int i = 2; i < size; i++){ table[2][i] = i * i * i; //cout << "table[2][" << i << "]:" << table[2][i] << endl; } while(cin >> data, data){ z = data; //cout << "z:" << z << endl; m = size + 500; for(int i = size - 1; i >= 0; i--){ if(table[2][i] == data){ m = i; break; } if(z >= table[2][i]){ z = table[2][i]; idx = i; //cout << "z:" << z << " table[2][" << i << "]:" << table[2][i] << endl; }else{ continue; } y = data - z; for(int k = size - 1; k >= 0; k--){ if(y >= table[1][k]){ y = table[1][k]; idx2 = k; x = data - z - y; if(m > (idx + idx2 + x)) m = idx + idx2 + x; //cout << m << " = " << idx << " + " << idx2 << " + " << x << endl; } } } cout << m << endl; } }
[ "rikuya6@gmail.com" ]
rikuya6@gmail.com
14761b64adf45e5f10f4a4bcca2c179fc76f5992
d0c5d89a7a7192f5b4ca65f02d93755f7c144c68
/server/inc/Servers.hpp
91db2ab62b82b6c8e0050df744148b45275411d9
[]
no_license
Rhuancpq/FSE_Trabalho_2
42ba25cb232970adc0d913f73e32ec14d686db26
5d27df1a869253f3e9ec5b3dd11e876635154afb
refs/heads/main
2023-08-14T05:57:24.635764
2021-10-07T01:46:34
2021-10-07T01:46:34
410,285,960
0
1
null
null
null
null
UTF-8
C++
false
false
867
hpp
#ifndef __SERVERS_HPP__ #define __SERVERS_HPP__ #include <unordered_map> #include <algorithm> #include <iostream> #include <mutex> using namespace std; #include "Types.hpp" #include "EventQueue.hpp" // this is a singleton class class Servers { public: static Servers* getInstance(); static void destroyInstance(); void addServer(const DistServers & server); void removeServer(const string & name); DistServers getServer(const string& name); vector<DistServers> getServers(); bool hasServer(const string& name); void updateTemperature(const string & name, const double & temperature, const double & humidity); void updateData(const string& name, Data data); private: Servers() = default; ~Servers(); static Servers* instance; mutex servers_mtx; unordered_map<string, DistServers> servers; }; #endif
[ "rhuancarlos.queiroz@gmail.com" ]
rhuancarlos.queiroz@gmail.com
780fef91bf8124cfcd5610367e8278a026ebfac7
bc1d68d7a7c837b8a99e516050364a7254030727
/src/URAL/URAL1019 Line Painting.cpp
67b516a451ae66a09e957b5a55833b26e273a159
[]
no_license
kester-lin/acm_backup
1e86b0b4699f8fa50a526ce091f242ee75282f59
a4850379c6c67a42da6b5aea499306e67edfc9fd
refs/heads/master
2021-05-28T20:01:31.044690
2013-05-16T03:27:21
2013-05-16T03:27:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,004
cpp
/******************************************************************************* # Author : Neo Fung # Email : neosfung@gmail.com # Last modified: 2012-01-20 21:28 # Filename: URAL1019 Line Painting.cpp # Description : ******************************************************************************/ #ifdef _MSC_VER // #define DEBUG #endif #include <fstream> #include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <limits.h> #include <algorithm> #include <math.h> #include <numeric> #include <functional> #include <ctype.h> #define L(x) (x<<1) #define R(x) (x<<1|1) #define MAX 100010 using namespace std; struct NODE { int l,r, val; }node[MAX*4],order[MAX]; int color[MAX]; void init() { memset(node,'\0',sizeof(node)); memset(order,'\0',sizeof(order)); memset(color,0,sizeof(color)); } void build(const int &t , const int &l,const int &r) { if(l>=r) return; node[t].l=l; node[t].r=r; node[t].val=-1; if(l==r-1) return; int mid=(l+r)>>1; build(L(t),l,mid); build(R(t),mid,r); } void update(const int &t,const int &l,const int &r,const int &val) { if(node[t].l==l && node[t].r==r) { node[t].val=val; return; } if(node[t].val>=0 && node[t].val !=val) { node[R(t)].val = node[t].val; node[L(t)].val = node[t].val; node[t].val=-1; } int mid=(node[t].l+node[t].r)>>1; if(l>=mid) update(R(t),l,r,val); else if(r<=mid) update(L(t),l,r,val); else { update(L(t),l,mid,val); update(R(t),mid,r,val); } } void query(const int &t,const int &l,const int &r) { if(node[t].val>=0) { for(int i=node[t].l;i<node[t].r;++i) color[i] = node[t].val; return; } int mid = (node[t].l+node[t].r)>>1; if(l>=mid) query(R(t),l,r); else if(r<=mid) query(L(t),l,r); else { query(L(t),l,mid); query(R(t),mid,r); } } void func(int *len,const int &cnt,const int &n) { build(1,0,cnt); for(int i=0;i<n;++i) { int x = lower_bound(len,len+cnt,order[i].l) - len; int y = lower_bound(len,len+cnt,order[i].r) - len; update(1,x,y,order[i].val); } query(1,0,cnt); color[cnt]=0; len[cnt]=1000000000; int s = 0,e = 0,te,ts; color[cnt] = !color[cnt-1]; len[cnt] = 1000000000; for(int i=0; i<cnt;++i) { ts = len[i]; while( color[i] == 0 ) i++; te = len[i]; if( te - ts > e - s ) { e = te; s = ts; } } printf("%d %d\n",s,e); } int main(void) { #ifdef DEBUG freopen("../stdin.txt","r",stdin); freopen("../stdout.txt","w",stdout); #endif int n; int x,y; char ch; int len[MAX]; while(~scanf("%d",&n)) { int cnt=0; init(); order[0].l=0; order[0].r=1000000000; order[0].val=0;; len[cnt++]=0; len[cnt++]=order[0].r; for(int i=1;i<=n;++i) { scanf("%d %d %c",&order[i].l,&order[i].r,&ch); len[cnt++]=order[i].l; len[cnt++]=order[i].r; if(ch=='b') order[i].val=1; } sort(len,len+cnt); cnt = unique(len,len+cnt)-len; func(len,cnt,n+1); } return 0; }
[ "neosfung@gmail.com" ]
neosfung@gmail.com
29234affa0240f1d846f5f831a27879eba371020
3460665d25f912e76cf23a2cdf40fb825728f18d
/div2/168/2.1.cpp
3645bb2b259201a7aba2facf85d9787e350011e5
[]
no_license
Morphinity/Codeforces
376340d6971ed193895473a1b3abf63f4dcd350d
82c1f769ae9df9d15f053f8d1718998470cec355
refs/heads/master
2016-09-06T01:33:37.834377
2015-01-17T12:39:14
2015-01-17T12:39:14
29,390,614
1
0
null
null
null
null
UTF-8
C++
false
false
351
cpp
#include<iostream> using namespace std; char grid[51][51]; int main(){ int n,m; cin >> n >> m; int black = 0; for(int i=0; i<n; i++) for(int j=0; j<m; j++){ cin >> grid[i][j]; if(grid[i][j] == 'B') black++; } // check for connectivity if(black > 1){ for(int i=0; i<n; i++){ for(int j=0; j<m; j++){
[ "mbakshi@adobe.com" ]
mbakshi@adobe.com
987cbe02ee804c40cb79d269855a8b7749d6f226
a61eac4c44c1021e9125e91c137b0eab670c5e14
/src/protocol.h
54361c5ca61bc3c63bed6d5d0d727da0ce4f3a78
[ "MIT" ]
permissive
valeo-2/anncoin
c0a1effed01e453e8e1077ed9d3c429c9a65b8e1
eed94fd7f7e8463ed0f2b2333cbbc10818779ca6
refs/heads/master
2020-05-18T04:15:25.667359
2014-06-23T07:32:45
2014-06-23T07:32:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,424
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2011-2012 Litecoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __cplusplus # error This header can only be compiled as C++. #endif #ifndef __INCLUDED_PROTOCOL_H__ #define __INCLUDED_PROTOCOL_H__ #include "serialize.h" #include "netbase.h" #include <string> #include "uint256.h" extern bool fTestNet; static inline unsigned short GetDefaultPort(const bool testnet = fTestNet) { return testnet ? 45883 : 19001; } extern unsigned char pchMessageStart[4]; /** Message header. * (4) message start. * (12) command. * (4) size. * (4) checksum. */ class CMessageHeader { public: CMessageHeader(); CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn); std::string GetCommand() const; bool IsValid() const; IMPLEMENT_SERIALIZE ( READWRITE(FLATDATA(pchMessageStart)); READWRITE(FLATDATA(pchCommand)); READWRITE(nMessageSize); READWRITE(nChecksum); ) // TODO: make private (improves encapsulation) public: enum { MESSAGE_START_SIZE=sizeof(::pchMessageStart), COMMAND_SIZE=12, MESSAGE_SIZE_SIZE=sizeof(int), CHECKSUM_SIZE=sizeof(int), MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE, CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE }; char pchMessageStart[MESSAGE_START_SIZE]; char pchCommand[COMMAND_SIZE]; unsigned int nMessageSize; unsigned int nChecksum; }; /** nServices flags */ enum { NODE_NETWORK = (1 << 0), }; /** A CService with information about it as peer */ class CAddress : public CService { public: CAddress(); explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK); void Init(); IMPLEMENT_SERIALIZE ( CAddress* pthis = const_cast<CAddress*>(this); CService* pip = (CService*)pthis; if (fRead) pthis->Init(); if (nType & SER_DISK) READWRITE(nVersion); if ((nType & SER_DISK) || (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH))) READWRITE(nTime); READWRITE(nServices); READWRITE(*pip); ) void print() const; // TODO: make private (improves encapsulation) public: uint64 nServices; // disk and network only unsigned int nTime; // memory only int64 nLastTry; }; /** inv message data */ class CInv { public: CInv(); CInv(int typeIn, const uint256& hashIn); CInv(const std::string& strType, const uint256& hashIn); IMPLEMENT_SERIALIZE ( READWRITE(type); READWRITE(hash); ) friend bool operator<(const CInv& a, const CInv& b); bool IsKnownType() const; const char* GetCommand() const; std::string ToString() const; void print() const; // TODO: make private (improves encapsulation) public: int type; uint256 hash; }; #endif // __INCLUDED_PROTOCOL_H__
[ "root@debian" ]
root@debian
6fa0650f293920f9effac81baabe75c4d59056cc
5470644b5f0834b9646649da365c96101a2f9b2a
/Sources/Elastos/LibCore/inc/elastos/io/Int32ArrayBuffer.h
9e2ccf8080d49844073ba1bfe8f47354929463c1
[]
no_license
dothithuy/ElastosRDK5_0
42372da3c749170581b5ee9b3884f4a27ae81608
2cf231e9f09f8b3b8bcacb11080b4a87d047833f
refs/heads/master
2021-05-13T15:02:22.363934
2015-05-25T01:54:38
2015-05-25T01:54:38
116,755,452
1
0
null
2018-01-09T02:33:06
2018-01-09T02:33:06
null
UTF-8
C++
false
false
1,348
h
#ifndef __INT32ARRAYBUFFER_H__ #define __INT32ARRAYBUFFER_H__ #include "Int32Buffer.h" namespace Elastos { namespace IO { /** * IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose * the implementation of array based int buffers. * <p> * IntArrayBuffer implements all the shared readonly methods and is extended by * the other two classes. * </p> * <p> * All methods are marked final for runtime performance. * </p> * */ class Int32ArrayBuffer : public Int32Buffer { public: Int32ArrayBuffer( /* [in] */ ArrayOf<Int32>* array); Int32ArrayBuffer( /* [in] */ Int32 capacity); Int32ArrayBuffer( /* [in] */ Int32 capacity, /* [in] */ ArrayOf<Int32>* backingArray, /* [in] */ Int32 offset); CARAPI GetInt32( /* [out] */ Int32* value); CARAPI GetInt32Ex( /* [in] */ Int32 index, /* [out] */ Int32* value); CARAPI GetInt32sEx( /* [out] */ ArrayOf<Int32>* dst, /* [in] */ Int32 dstOffset, /* [in] */ Int32 int32Count); CARAPI IsDirect( /* [out] */ Boolean* isDirect); CARAPI GetOrder( /* [out] */ ByteOrder* byteOrder); public: AutoPtr< ArrayOf<Int32> > mBackingArray; Int32 mOffset; }; } // namespace IO } // namespace Elastos #endif // __INT32ARRAYBUFFER_H__
[ "chen.yunzhi@kortide.com" ]
chen.yunzhi@kortide.com
554485d4da5805d2289e8a0a630f63c74f0263cd
46c64211509c25bef42c2483ac6d276f7e2d36f1
/BOJ1476.cpp
39beb20857a0c4584cf78b53e0d549a2f684089e
[]
no_license
LowFreqOn/BOJ
d1a20543436d010d2229bc505c1249074995a835
7a2e1e5a9b0789fdcf21d34de0431a1085aafbc9
refs/heads/master
2022-05-16T05:01:03.402088
2019-06-13T15:33:47
2019-06-13T15:33:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
//BOJ 1476. 날짜 계산 #include<stdio.h> #include<stdlib.h> int E, S, M; int cnt; int main(void) { scanf("%d %d %d", &E, &S, &M); while (1) { cnt++; int a = cnt % 15; int b = cnt % 28; int c = cnt % 19; if (a == 0)a = 15; if (b == 0)b = 28; if (c == 0)c = 19; if (a == E && b == S && c == M) break; } printf("%d\n",cnt); return 0; }
[ "noreply@github.com" ]
LowFreqOn.noreply@github.com
787c352f7133d9852e9c5e8cc5830f40ba56ad7a
a1f1e7dee2b84d07d6b28c4ff9c6e909c7c7feb2
/src/filter.cpp
c0df61b6b0639a181d2f531005b51d0845a9385e
[ "BSD-3-Clause" ]
permissive
khurrumsaleem/OpenBPS
5e0cff64b213a83aae9a4b390427e35878fe667d
8b674ba810be36d863d261024330f271e6b31ed9
refs/heads/master
2023-03-21T19:09:57.008769
2020-10-20T16:22:13
2020-10-20T16:22:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,354
cpp
#include "openbps/filter.h" #include <sstream> #include <iostream> #include <memory> #include <algorithm> #include "../extern/pugiData/pugixml.h" #include "openbps/parse.h" namespace openbps { //============================================================================== // Global variables //============================================================================== std::vector<Filter> filters; std::unique_ptr<MaterialFilter> materialfilter; std::unique_ptr<TimeFilter> timefilter; //============================================================================== // Filters class implementation //============================================================================== Filter::Filter(pugi::xml_node node) { type = node.attribute("type").value(); bins_ = get_node_array<std::string>(node, "filter"); } //! Apply filter to results void Filter::apply(const std::vector<std::string>&input, std::vector<int>& indices) { for (int i = 0; i < input.size(); i++) { auto search = std::find_if(bins_.begin(), bins_.end(), [&input, i](const std::string& bname) { return bname == input[i]; }); if (search != bins_.end()) { indices.push_back(i); } } } MaterialFilter::MaterialFilter(pugi::xml_node node) { type = "material"; bins_ = get_node_array<std::string>(node, "filter"); } //! Apply filter to results void MaterialFilter::apply(const std::string &matname, bool& isValid) { auto search = std::find_if(bins_.begin(), bins_.end(), [&matname](const std::string& bname) { return bname == matname; }); isValid = (search != bins_.end()); } TimeFilter::TimeFilter(pugi::xml_node node) { type = "time"; bins_ = get_node_array<double>(node, "filter"); if (bins_.size() % 2 == 1) { std::cout << "Intervals number should be even" << std::endl; bins_.erase(bins_.begin() + bins_.size() - 1, bins_.end()); } } //! Apply filter to results void TimeFilter::apply(double dt, int numstep, std::vector<int>& indices) { size_t j = 0; for (size_t k = 0; k < bins_.size() / 2; k++) while(j < numstep) { if ((j + 1) * dt <= bins_[2 * k + 1] && (j + 1) * dt > bins_[2 * k]) { indices.push_back(j); } if ((j + 1) * dt > bins_[2 * k + 1]) break; j++; } } //============================================================================== // Non - class methods implementation //============================================================================== //! Reading data from configure.xml void read_fitlers_from_xml(pugi::xml_node root_node) { // Proceed all filters for (pugi::xml_node tool : root_node.children("filter")) { std::string current_type; current_type = tool.attribute("type").value(); if (current_type == "time") { timefilter = std::unique_ptr<TimeFilter>(new TimeFilter(tool)); } else if (current_type == "material") { materialfilter = std::unique_ptr<MaterialFilter>(new MaterialFilter(tool)); } else { Filter f(tool); filters.push_back(f); } } } } //namespace openbps
[ "dr.yuri92@gmail.com" ]
dr.yuri92@gmail.com
4d8aa540f4961617df280eaa9ea88af4850376ab
ac8e27210d8ae1c79e7d0d9db1bcf4e31c737718
/projects/compiler-rt/lib/scudo/standalone/quarantine.h
bac36e01c1ddcbc72e6f91cf19a8486aa6416423
[ "NCSA", "MIT", "LLVM-exception", "Apache-2.0" ]
permissive
steleman/flang9
d583d619bfb67d27a995274e30c8c1a642696ec1
4ad7c213b30422e1e0fcb3ac826640d576977d04
refs/heads/master
2020-11-27T09:50:18.644313
2020-03-07T14:37:32
2020-03-07T14:37:32
229,387,867
0
0
Apache-2.0
2019-12-21T06:35:35
2019-12-21T06:35:34
null
UTF-8
C++
false
false
9,524
h
//===-- quarantine.h --------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef SCUDO_QUARANTINE_H_ #define SCUDO_QUARANTINE_H_ #include "list.h" #include "mutex.h" #include "string_utils.h" namespace scudo { struct QuarantineBatch { // With the following count, a batch (and the header that protects it) occupy // 4096 bytes on 32-bit platforms, and 8192 bytes on 64-bit. static const u32 MaxCount = 1019; QuarantineBatch *Next; uptr Size; u32 Count; void *Batch[MaxCount]; void init(void *Ptr, uptr Size) { Count = 1; Batch[0] = Ptr; this->Size = Size + sizeof(QuarantineBatch); // Account for the Batch Size. } // The total size of quarantined nodes recorded in this batch. uptr getQuarantinedSize() const { return Size - sizeof(QuarantineBatch); } void push_back(void *Ptr, uptr Size) { DCHECK_LT(Count, MaxCount); Batch[Count++] = Ptr; this->Size += Size; } bool canMerge(const QuarantineBatch *const From) const { return Count + From->Count <= MaxCount; } void merge(QuarantineBatch *const From) { DCHECK_LE(Count + From->Count, MaxCount); DCHECK_GE(Size, sizeof(QuarantineBatch)); for (uptr I = 0; I < From->Count; ++I) Batch[Count + I] = From->Batch[I]; Count += From->Count; Size += From->getQuarantinedSize(); From->Count = 0; From->Size = sizeof(QuarantineBatch); } void shuffle(u32 State) { ::scudo::shuffle(Batch, Count, &State); } }; COMPILER_CHECK(sizeof(QuarantineBatch) <= (1U << 13)); // 8Kb. // Per-thread cache of memory blocks. template <typename Callback> class QuarantineCache { public: void initLinkerInitialized() {} void init() { memset(this, 0, sizeof(*this)); initLinkerInitialized(); } // Total memory used, including internal accounting. uptr getSize() const { return atomic_load_relaxed(&Size); } // Memory used for internal accounting. uptr getOverheadSize() const { return List.size() * sizeof(QuarantineBatch); } void enqueue(Callback Cb, void *Ptr, uptr Size) { if (List.empty() || List.back()->Count == QuarantineBatch::MaxCount) { QuarantineBatch *B = reinterpret_cast<QuarantineBatch *>(Cb.allocate(sizeof(*B))); DCHECK(B); B->init(Ptr, Size); enqueueBatch(B); } else { List.back()->push_back(Ptr, Size); addToSize(Size); } } void transfer(QuarantineCache *From) { List.append_back(&From->List); addToSize(From->getSize()); atomic_store_relaxed(&From->Size, 0); } void enqueueBatch(QuarantineBatch *B) { List.push_back(B); addToSize(B->Size); } QuarantineBatch *dequeueBatch() { if (List.empty()) return nullptr; QuarantineBatch *B = List.front(); List.pop_front(); subFromSize(B->Size); return B; } void mergeBatches(QuarantineCache *ToDeallocate) { uptr ExtractedSize = 0; QuarantineBatch *Current = List.front(); while (Current && Current->Next) { if (Current->canMerge(Current->Next)) { QuarantineBatch *Extracted = Current->Next; // Move all the chunks into the current batch. Current->merge(Extracted); DCHECK_EQ(Extracted->Count, 0); DCHECK_EQ(Extracted->Size, sizeof(QuarantineBatch)); // Remove the next batch From the list and account for its Size. List.extract(Current, Extracted); ExtractedSize += Extracted->Size; // Add it to deallocation list. ToDeallocate->enqueueBatch(Extracted); } else { Current = Current->Next; } } subFromSize(ExtractedSize); } void printStats() const { uptr BatchCount = 0; uptr TotalOverheadBytes = 0; uptr TotalBytes = 0; uptr TotalQuarantineChunks = 0; for (const QuarantineBatch &Batch : List) { BatchCount++; TotalBytes += Batch.Size; TotalOverheadBytes += Batch.Size - Batch.getQuarantinedSize(); TotalQuarantineChunks += Batch.Count; } const uptr QuarantineChunksCapacity = BatchCount * QuarantineBatch::MaxCount; const uptr ChunksUsagePercent = (QuarantineChunksCapacity == 0) ? 0 : TotalQuarantineChunks * 100 / QuarantineChunksCapacity; const uptr TotalQuarantinedBytes = TotalBytes - TotalOverheadBytes; const uptr MemoryOverheadPercent = (TotalQuarantinedBytes == 0) ? 0 : TotalOverheadBytes * 100 / TotalQuarantinedBytes; Printf("Global quarantine stats: batches: %zd; bytes: %zd (user: %zd); " "chunks: %zd (capacity: %zd); %zd%% chunks used; %zd%% memory " "overhead\n", BatchCount, TotalBytes, TotalQuarantinedBytes, TotalQuarantineChunks, QuarantineChunksCapacity, ChunksUsagePercent, MemoryOverheadPercent); } private: IntrusiveList<QuarantineBatch> List; atomic_uptr Size; void addToSize(uptr add) { atomic_store_relaxed(&Size, getSize() + add); } void subFromSize(uptr sub) { atomic_store_relaxed(&Size, getSize() - sub); } }; // The callback interface is: // void Callback::recycle(Node *Ptr); // void *Callback::allocate(uptr Size); // void Callback::deallocate(void *Ptr); template <typename Callback, typename Node> class GlobalQuarantine { public: typedef QuarantineCache<Callback> CacheT; void initLinkerInitialized(uptr Size, uptr CacheSize) { // Thread local quarantine size can be zero only when global quarantine size // is zero (it allows us to perform just one atomic read per put() call). CHECK((Size == 0 && CacheSize == 0) || CacheSize != 0); atomic_store_relaxed(&MaxSize, Size); atomic_store_relaxed(&MinSize, Size / 10 * 9); // 90% of max size. atomic_store_relaxed(&MaxCacheSize, CacheSize); Cache.initLinkerInitialized(); } void init(uptr Size, uptr CacheSize) { memset(this, 0, sizeof(*this)); initLinkerInitialized(Size, CacheSize); } uptr getMaxSize() const { return atomic_load_relaxed(&MaxSize); } uptr getCacheSize() const { return atomic_load_relaxed(&MaxCacheSize); } void put(CacheT *C, Callback Cb, Node *Ptr, uptr Size) { C->enqueue(Cb, Ptr, Size); if (C->getSize() > getCacheSize()) drain(C, Cb); } void NOINLINE drain(CacheT *C, Callback Cb) { { ScopedLock L(CacheMutex); Cache.transfer(C); } if (Cache.getSize() > getMaxSize() && RecyleMutex.tryLock()) recycle(atomic_load_relaxed(&MinSize), Cb); } void NOINLINE drainAndRecycle(CacheT *C, Callback Cb) { { ScopedLock L(CacheMutex); Cache.transfer(C); } RecyleMutex.lock(); recycle(0, Cb); } void printStats() const { // It assumes that the world is stopped, just as the allocator's printStats. Printf("Quarantine limits: global: %zdM; thread local: %zdK\n", getMaxSize() >> 20, getCacheSize() >> 10); Cache.printStats(); } private: // Read-only data. alignas(SCUDO_CACHE_LINE_SIZE) HybridMutex CacheMutex; CacheT Cache; alignas(SCUDO_CACHE_LINE_SIZE) HybridMutex RecyleMutex; atomic_uptr MinSize; atomic_uptr MaxSize; alignas(SCUDO_CACHE_LINE_SIZE) atomic_uptr MaxCacheSize; void NOINLINE recycle(uptr MinSize, Callback Cb) { CacheT Tmp; Tmp.init(); { ScopedLock L(CacheMutex); // Go over the batches and merge partially filled ones to // save some memory, otherwise batches themselves (since the memory used // by them is counted against quarantine limit) can overcome the actual // user's quarantined chunks, which diminishes the purpose of the // quarantine. const uptr CacheSize = Cache.getSize(); const uptr OverheadSize = Cache.getOverheadSize(); DCHECK_GE(CacheSize, OverheadSize); // Do the merge only when overhead exceeds this predefined limit (might // require some tuning). It saves us merge attempt when the batch list // quarantine is unlikely to contain batches suitable for merge. constexpr uptr OverheadThresholdPercents = 100; if (CacheSize > OverheadSize && OverheadSize * (100 + OverheadThresholdPercents) > CacheSize * OverheadThresholdPercents) { Cache.mergeBatches(&Tmp); } // Extract enough chunks from the quarantine to get below the max // quarantine size and leave some leeway for the newly quarantined chunks. while (Cache.getSize() > MinSize) Tmp.enqueueBatch(Cache.dequeueBatch()); } RecyleMutex.unlock(); doRecycle(&Tmp, Cb); } void NOINLINE doRecycle(CacheT *C, Callback Cb) { while (QuarantineBatch *B = C->dequeueBatch()) { const u32 Seed = static_cast<u32>( (reinterpret_cast<uptr>(B) ^ reinterpret_cast<uptr>(C)) >> 4); B->shuffle(Seed); constexpr uptr NumberOfPrefetch = 8UL; CHECK(NumberOfPrefetch <= ARRAY_SIZE(B->Batch)); for (uptr I = 0; I < NumberOfPrefetch; I++) PREFETCH(B->Batch[I]); for (uptr I = 0, Count = B->Count; I < Count; I++) { if (I + NumberOfPrefetch < Count) PREFETCH(B->Batch[I + NumberOfPrefetch]); Cb.recycle(reinterpret_cast<Node *>(B->Batch[I])); } Cb.deallocate(B); } } }; } // namespace scudo #endif // SCUDO_QUARANTINE_H_
[ "stefan.teleman@cavium.com" ]
stefan.teleman@cavium.com
72e97f4dd13e4323fa6411fa4b3e77b4b1bd346c
2561dba6586c3d2a3fcd62d29dd6be89cd893855
/code/LaneDetection/src/LaneDetectionAccessories/ContourSplineHelper.cpp
b54e17021a253c2015613f3f7e42f231247bc874
[]
no_license
Yueeeeeeee/SLAMParking
4c5503f46233b4e011775070458e18c49f49fdec
e58190181be8b3758cc26d3f316c9bb8c2ca72a0
refs/heads/master
2020-06-24T18:25:14.778746
2019-07-26T16:05:01
2019-07-26T16:05:01
199,043,789
1
0
null
null
null
null
UTF-8
C++
false
false
3,736
cpp
/* * ContourHelper.cpp * * Created on: Jun 21, 2018 * Author: martin */ #include <opencv2/opencv.hpp> #include <iterator> ////////////////////////// // Note: Opencv coordinate system: (0,0) is at the upper left corner of the image //////////////////////// using namespace std; using namespace cv; namespace csh { void getSplines(vector<vector<Point>> &contours, vector<vector<Point>> &splines); void cleanSpline(vector<Point> &spline); int getLowestPoint(vector<Point2i> &contour); int getHighestPoint(vector<Point2i> &contour); float slope(Vec4i line); float slope(Point p1, Point p2); double meanX(vector<Point2i> &spline); const int SPLINE_DISTANCE = 10; /** * Finds a spline for every contour by following both "sides" from the bottom to the top */ void getSplines(vector<vector<Point>> &contours, vector<vector<Point>> &splines) { splines.clear(); for (vector<Point> vec : contours) { int lowest = getHighestPoint(vec); //lowest point in the image has highest coordinate int side1 = lowest; int side2 = lowest; int currentY = vec[lowest].y; int nextStep = SPLINE_DISTANCE / 2; Point prevPoint = vec[lowest]; vector<Point> spline; while (true) { currentY -= nextStep; if (side1 >= (int) vec.size()) { side1 = 0; } do { side1++; } while (side1 < (int) vec.size() && vec[side1].y > currentY); if (side2 < 0) { side2 = vec.size() - 1; } do { side2--; } while (side2 >= 0 && vec[side2].y > currentY); if (side1 >= (int) vec.size() || side2 < 0) { goto end; } int centerX = (vec[side1].x + vec[side2].x) / 2; int centerY = (vec[side1].y + vec[side2].y) / 2; Point newPoint = Point(centerX, centerY); spline.push_back(newPoint); nextStep = SPLINE_DISTANCE * sin( slope( Vec4i(prevPoint.x, prevPoint.y, newPoint.x, newPoint.y))); prevPoint = newPoint; } end: Point highest = vec[getLowestPoint(vec)]; spline.push_back(highest); cleanSpline(spline); if (spline.size() > 4) { splines.push_back(spline); } } } /** * Not particularly useful, but might break everything if removed */ void cleanSpline(vector<Point> &spline) { if (spline.size() < 3) { return; } vector<float> angle; vector<float> derivative; float avgDerivative = 0.0; for (uint i = 0; i < spline.size() - 1; i++) { angle.push_back( slope( Vec4i(spline[i + 1].x, spline[i + 1].y, spline[i].x, spline[i].y))); } for (uint i = 0; i < spline.size() - 2; i++) { derivative.push_back(angle[i + 1] - angle[i]); avgDerivative += derivative[i]; } if (abs(derivative[0]) > (abs(derivative[1]) + abs(derivative[2])) / 2 - 20) { spline.erase(spline.begin()); angle.erase(angle.begin()); avgDerivative -= derivative[0]; derivative.erase(derivative.begin()); } } int getLowestPoint(vector<Point2i> &contour) { int index = 0; int lowest = 0; for (uint i = 0; i < contour.size(); i++) { if (contour[i].y < lowest) { lowest = contour[i].y; index = i; } } return index; } int getHighestPoint(vector<Point2i> &contour) { int index = 0; int highest = 0; for (uint i = 0; i < contour.size(); i++) { if (contour[i].y > highest) { highest = contour[i].y; index = i; } } return index; } float slope(Vec4i line) { if (line[1] < line[3]) { return atan2(line[3] - line[1], line[2] - line[0]); } else { return atan2(line[1] - line[3], line[0] - line[2]); } } float slope(Point p1, Point p2) { if (p1.y < p2.y) { return atan2(p2.y - p1.y, p2.x - p1.x); } else { return atan2(p1.y - p2.y, p1.x - p2.x); } } double meanX(vector<Point2i> &spline) { int sum = 0; for (Point2i &p : spline) { sum += p.x; } return sum / spline.size(); } }
[ "yuezrhb@gmail.com" ]
yuezrhb@gmail.com
f9456ac51971b9b76d72caf4bc7c38d669beb077
b3039bd708590128db3113e2df799f65f3690f0c
/SP_4/SP_4/SP_4.cpp
3e46a6ddb6c1e83f09a7e4aee934ae6aaafa6177
[]
no_license
degarem/system_programs
2c5816dd18ee0ed9a686b6cf85ca7330b12599d1
d075eec16dd1633eeb615816ae2f468b53e69831
refs/heads/master
2021-01-02T18:46:18.628336
2020-05-20T16:39:37
2020-05-20T16:39:37
239,749,207
0
0
null
null
null
null
UTF-8
C++
false
false
1,057
cpp
#include "stdafx.h" #include <string> #include <iostream> #include <Windows.h> using namespace std; #define MAX_PATH_SYMBOL_COUNT 260 #define MAX_COMMANMD_SYMBOL_COUNT 10 void perfrom_command(wstring command, wstring parameter); bool is_file_exists(wstring path); int wmain(int argc, wchar_t *argv[]) { printf("\n* Archivator *\n\n"); wstring command, parameter; WCHAR input[MAX_PATH_SYMBOL_COUNT + MAX_COMMANMD_SYMBOL_COUNT + 2]; do { wcin.getline(input, sizeof input); wstring input_wstr = input; int end_command_index = input_wstr.find(L" "); command = input_wstr.substr(0, end_command_index); parameter = input_wstr.substr(end_command_index + 1); perfrom_command(command, parameter); } while (command.compare(L"exit") != 0); return 0; } void perfrom_command(wstring command, wstring parameter) { wprintf(L"\n"); if (command.compare(L"zip") == 0) { zip_file() } else if (command.compare(L"unzip") == 0) { } else { wprintf(L"Incorrect command. Use:\nzip <path> for zipping\nunzip<path> for unzipping\n"); } }
[ "40548809+degarem@users.noreply.github.com" ]
40548809+degarem@users.noreply.github.com
54a3553fb55b67f6c6be579bc194aba07b679926
83ed1e2f176133c03a5f6dfa504b8df15ae71efb
/cpp/Heavy_atom_code/decapeptide_utils/txt2txt.cpp
327fde3574477f6e65061609e20cc100f0b66e95
[]
no_license
jmborr/code
319db14f28e1dea27f9fc703be629f171e6bd95f
32720b57699bf01803367566cdc5fff2b6bce810
refs/heads/master
2022-03-09T16:11:07.455402
2019-10-28T15:03:01
2019-10-28T15:03:01
23,627,627
0
0
null
null
null
null
UTF-8
C++
false
false
10,493
cpp
#include<iostream> using namespace std; #include<fstream> #include<string> #include <cstdlib> #include<fstream> #include"pdbClasses2.h" #include"atom_param.h" #include"amino_acid_param.h" #include"miscellanea.h" #include"random.h" /*=====================================================*/ void printSYS_SIZE( ifstream &RLX, ofstream &DMD ){ DMD << txtKeyWords[SYS_SIZE] << endl; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line ; double box[3] ; char cbuf[128] ; while( getline( RLX, line ) ){ if( line.find(txtKeyWords[SYS_SIZE]) != string::npos ){ break ; } } RLX >> box[ 0 ] >> box[ 1 ] >> box[ 2 ] ; sprintf( cbuf, "%9.4f %9.4f %9.4f\n", box[0], box[1], box[2]) ; DMD << cbuf ; RLX.seekg( pos ) ; cout << "SYS_SIZE ...\n" ; } /*=====================================================*/ void printNUM_ATOMS( PDBchain& chain, ofstream &DMD ){ cout << "NUM_ATOMS ...\n" ; DMD << txtKeyWords[NUM_ATOMS] << endl ; DMD << chain.numberOfAtoms( ) << endl ; } /*=====================================================*/ void printATOM_TYPE( ifstream &DAT, ostream& DMD, double *hcr_list ){ cout << "ATOM_TYPE ...\n" ; DMD << txtKeyWords[TYPE_ATOMS] << endl; dmd_atom_t type ; string amino_and_atom ; char cbuf[300] ; for( int i=1; i<=n_dmd_atom_t; i++){ sprintf( cbuf, "%3d ", i ) ; DMD << cbuf ; type = static_cast<dmd_atom_t>( i ) ;/*amino_param.h*/ amino_and_atom = dmd_atom_t2string( type ) ;/*amino_param.cpp*/ print_atom_type_line( cbuf, DAT, amino_and_atom ) ;/*atom_param.cpp*/ hcr_list[ i ] = out_hard_core_radius( DAT, amino_and_atom ) ; DMD << cbuf ; } } /*=====================================================*/ void printNONEL_COL( ifstream &DAT, ostream& DMD, double *hcr_list ){ cout << "NONEL_COL ...\n" ; DMD << txtKeyWords[NONEL_COL] << endl; string nonel_col[n_dmd_atom_t+1][n_dmd_atom_t+1] ; dmd_atom_t type1, type2 ; string stype1, stype2 ; char cbuf[256], cbuf2[256] ; for( int i=1; i<=n_dmd_atom_t; i++ ){ for( int j=i; j<=n_dmd_atom_t; j++ ){ type1 = static_cast<dmd_atom_t>( i ); stype1=dmd_atom_t2string( type1 ) ; type2 = static_cast<dmd_atom_t>( j ); stype2=dmd_atom_t2string( type2 ) ; /*cout<<"stype1=|"<<stype1<<"| stype2=|"<<stype2<<"|\n";*/ get_default_Van_der_Waals( stype1, stype2, nonel_col[i][j], DAT ) ; get_default_hydrophobicity( stype1, stype2, nonel_col[i][j], DAT ) ; get_default_electrostatics( stype1, stype2, nonel_col[i][j], DAT ) ; get_signal_Hydrogen_Bond( stype1, stype2, nonel_col[i][j], DAT ) ; string2char( nonel_col[i][j], cbuf2 ) ; sprintf( cbuf, "%3d %3d %s\n", i, j, cbuf2 ) ; DMD << cbuf ; } } } /*=====================================================*/ void printLINKED_PAIRS( ifstream &DAT, ofstream &DMD ){ cout << "LINKED_PAIRS ...\n" ; DMD << txtKeyWords[LINK_PAIRS] << endl; int i, j, pos = DAT.tellg( ) ; DAT.seekg( 0 ) ; double HBstrength = get_HB_strength( DAT ) ; string link, aa_at1, aa_at2 ; char cbuf[256], cbuf2[256] ; dmd_atom_t type1, type2 ; /*output hydrogen bond links*/ goto_dat_key( DAT, LINK_HB_DAT ) ; getline( DAT, link ) ; while( !is_end( link, LINK_HB_DAT ) ){ /*cout<<"link=|"<<link<<"|\n";*/ if( !is_comment(link) ){ rescale_barriers_of_link_by_factor( link, HBstrength ) ; } if( out_linked_pair( link, aa_at1, aa_at2, cbuf ) ){ type1 = string2dmd_atom_t( aa_at1 ) ; i = static_cast<int>( type1 ) ; type2 = string2dmd_atom_t( aa_at2 ) ; j = static_cast<int>( type2 ) ; if( i==0 ){ cout <<"|"<<aa_at1<<"| has no type!\n"; exit(1); } if( j==0 ){ cout <<"|"<<aa_at2<<"| has no type!\n"; exit(1); } sprintf( cbuf2, "%3d %3d %s\n", i, j, cbuf ) ; DMD << cbuf2 ; } getline( DAT, link ) ; } DAT.seekg( 0 ) ; /*output permanent links*/ goto_dat_key( DAT, LINK_PAIRS_DAT ) ; getline( DAT, link ) ; while( !is_end( link, LINK_PAIRS_DAT ) ){ if( out_linked_pair( link, aa_at1, aa_at2, cbuf ) ){ type1 = string2dmd_atom_t( aa_at1 ) ; i = static_cast<int>( type1 ) ; type2 = string2dmd_atom_t( aa_at2 ) ; j = static_cast<int>( type2 ) ; if( i==0 ){ cout <<"|"<<aa_at1<<"| has no type!\n"; exit(1); } if( j==0 ){ cout <<"|"<<aa_at2<<"| has no type!\n"; exit(1); } if( have_rotamers( DAT, aa_at1, aa_at2 ) ){ /*the default_rotamer_barrier function works only if "link" is only a torsion bond, ie, no mixture of angle and torsion bonds.*/ default_rotamer_barrier( DAT, link, cbuf ) ; } sprintf( cbuf2, "%3d %3d %s\n", i, j, cbuf ) ; DMD << cbuf2 ; } getline( DAT, link ) ; /*cout<<"link=|"<<link<<"|\n" ;*/ } DAT.seekg( pos ) ; } /*=====================================================*/ void printREACT( ifstream &DAT, ofstream &DMD ){ cout << "REACT ...\n" ; string line, sold1, sold2, snew1, snew2 ; dmd_atom_t told1, told2, tnew1, tnew2 ; char cbuf[ 128 ] ; DMD << txtKeyWords[REACT] << endl; goto_dat_key( DAT, REACT_DAT ) ; getline( DAT, line ) ; while( !is_end( line, REACT_DAT ) ){ if( get_reactants_products( line, sold1, sold2, snew1, snew2 ) ){ told1 = string2dmd_atom_t( sold1 ) ; told2 = string2dmd_atom_t( sold2 ) ; tnew1 = string2dmd_atom_t( snew1 ) ; tnew2 = string2dmd_atom_t( snew2 ) ; sprintf( cbuf, "%3d %3d %3d %3d 1\n", static_cast<int>( told1 ), static_cast<int>( told2 ), static_cast<int>( tnew1 ), static_cast<int>( tnew2 ) ) ; DMD << cbuf ; } getline( DAT, line ) ; } } /*===================================================== In the relaxed conformations, there are no hydrogen bonds formed, thus all bonds are permanent bonds */ void printLIST_ATOMS_LIST_OF_BONDS( ifstream &RLX, ofstream &DMD ){ cout << "LIST_ATOMS ...\n" ; cout << "LIST_BONDS ...\n" ; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line ; goto_txt_key( RLX, LIST_ATOMS ) ; DMD << txtKeyWords[LIST_ATOMS] << endl ; while( getline( RLX, line ) ){ DMD << line << endl ; } RLX.clear( ios::goodbit ) ; RLX.seekg( pos ) ; } /*=====================================================*/ void printLIST_PERM_BONDS( ifstream &RLX, PDBchain& chain, ofstream &DMD ){ cout << "LIST_PERM_BONDS ...\n" ; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line, aa_at1, aa_at2 ; dmd_atom_t type1, type2 ; int *ids = NULL, n=0 ; char cbuf[32] ; PDBatom at1, at2 ; /*no list of permanent bonds in the prerelaxed conformation, thus go to list of bonds*/ goto_txt_key( RLX, LIST_BONDS ) ; DMD << txtKeyWords[LIST_PERM_BONDS] << endl ; while( getline( RLX, line ) ){ /*DMD <<"line="<<line<<"\n" ;*/ if(line.find("//") == string::npos){/*line is not a comment*/ ids = split_line2ints( line, n ); /*cout<<"line=|"<<line<<"|, n="<<n<<endl;*/ if( n==2 && ids ){ at1=chain.getAtomWithIndex(ids[0]) ; at2=chain.getAtomWithIndex(ids[1]); aa_at1 = at1.get_resName_nameII( ); aa_at2 = at2.get_resName_nameII( ); type1 = string2dmd_atom_t( aa_at1 ); type2 = string2dmd_atom_t( aa_at2 ); sprintf( cbuf, "%4d %4d %3d %3d\n",ids[0], ids[1], static_cast<int>(type1), static_cast<int>(type2) ) ; DMD << cbuf ; delete [] ids ; ids = NULL ; n = 0 ; } } } RLX.clear( ios::goodbit ) ; RLX.seekg( pos ) ; } /*=====================================================*/ void printHBA_LIST( ifstream &DAT, PDBchain& chain, ofstream &DMD ){ cout << "HB_LIST ...\n" ; string line, *associates=NULL, *atoms=NULL, sbuf, sbuf2 ; int *rel_index=NULL, n=0, l = chain.length( ), ix ; bool flag ; char cbuf[64] ; DMD << txtKeyWords[HB_LIST] << endl ; goto_dat_key( DAT, HB_LIST_DAT ) ; getline( DAT, line ) ; while( !is_end( line, HB_LIST_DAT ) ){ if( get_associates( line, associates, rel_index, atoms, n ) ){ for( int i=1; i<=l; i++ ){/*go through all amino acids in chain*/ flag = true ; for( int j=0; j<n; j++ ){/*check presence of all associates*/ if(!chain.is_there_resName_name_at_resIndexII( associates[j], i+rel_index[j]) ){ flag = false ; break ; } } if( flag ){/*all associates present. Retrieve their atom indexes*/ sbuf.assign("") ; ix=chain.getSerialNumberOfAtomNameAtIndex(atoms[0],i+rel_index[0]); /*below, "-1" indicates amino acid index for DMD simulations is shifted*/ sprintf( cbuf, "%3d %4d ", ix, i+rel_index[0]-1 ) ; sbuf2.assign( cbuf ) ; sbuf += sbuf2 ; for( int j=1; j<n; j++ ){/*get atom serial of all associates*/ ix=chain.getSerialNumberOfAtomNameAtIndex(atoms[j],i+rel_index[j]); sprintf( cbuf, "%3d ", ix ) ; sbuf2.assign( cbuf ) ; sbuf += sbuf2 ; } DMD << sbuf << endl ; } } } getline( DAT, line ) ; } } /*=====================================================*/ bool test_input(int argc, char ** argv ){ int number_of_arguments = argc -1 ; if( number_of_arguments != 4 ){ system("clear"); cout << "Usage: ./txt2txt.x relaxed.txt model.pdb force_field init.txt\n" ; cout << "relaxed.txt: DMD conformation with no hydrogen bond formed and with all permanent bonds present (outcome of a relaxation procedure).\n"; cout << "model.pdb: any conformation of the protein in PDB format\n"; cout << "force_field: file with info on atoms (mass, radius, bonded and nonbonded interactions)\n"; cout << "init.txt: output conformation where we include hydrogen bonds in the backbone and physical interactions.\n"; return false ; } else return true ; } /*=====================================================*/ int main( int argc, char ** argv ){ /*check number of arguments*/ if( test_input(argc, argv) == false ) { return 1 ; } /*retrieve input*/ int n_arg = argc -1 ; ifstream RLX( argv[ 1 ] ) ; ifstream PDB( argv[ 2 ] ) ; PDBchain chain ; PDB >> chain ; PDB.close( ) ; ifstream DAT( argv[ 3 ] ) ; ofstream DMD( argv[ 4 ] ) ; chain.remove_all_hydrogens( ) ; chain.renumberFully( 1 ) ; chain.renumberFullyAtomSerialNumber( 1 ) ; double *hcr_list = new double[ n_dmd_atom_t + 1] ; printSYS_SIZE( RLX, DMD ) ; printNUM_ATOMS( chain, DMD ) ; printATOM_TYPE( DAT, DMD, hcr_list ) ; printNONEL_COL( DAT, DMD, hcr_list ) ; printLINKED_PAIRS( DAT, DMD ) ; printREACT( DAT, DMD ) ; printLIST_ATOMS_LIST_OF_BONDS( RLX, DMD ) ; printLIST_PERM_BONDS( RLX, chain, DMD ) ; printHBA_LIST( DAT, chain, DMD ) ; return 0 ; }
[ "borreguero@gmail.com" ]
borreguero@gmail.com
5f140110f4b38544bb9f560bdaadae83ac0c7d06
69ef4de6d617b09cd0b23715d1aae689fc1f9b56
/src/CalcViewModel/GraphingCalculator/GraphingSettingsViewModel.h
77f1dda1601351236f712a6a541cb63acca63c93
[ "MIT", "Apache-2.0", "LGPL-2.1-or-later" ]
permissive
thisisakshatsri/calculator
661a80196726d9976712ef01eab006cd2c1f3b32
69d0fdaf7f4f1228a63544909f5520d7d320caef
refs/heads/master
2023-08-22T16:32:33.465600
2021-10-20T06:34:35
2021-10-20T06:34:35
410,344,102
1
6
MIT
2021-10-03T22:03:06
2021-09-25T17:54:36
C++
UTF-8
C++
false
false
9,834
h
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "../Common/Utils.h" #include "CalcViewModel/Common/TraceLogger.h" namespace CalculatorApp::ViewModel { #pragma once [Windows::UI::Xaml::Data::Bindable] public ref class GraphingSettingsViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged { public: OBSERVABLE_OBJECT(); OBSERVABLE_PROPERTY_R(bool, YMinError); OBSERVABLE_PROPERTY_R(bool, XMinError); OBSERVABLE_PROPERTY_R(bool, XMaxError); OBSERVABLE_PROPERTY_R(bool, YMaxError); OBSERVABLE_PROPERTY_R(GraphControl::Grapher ^, Graph); GraphingSettingsViewModel(); property bool XError { bool get() { return !m_XMinError && !m_XMaxError && m_XMinValue >= m_XMaxValue; } } property bool YError { bool get() { return !m_YMinError && !m_YMaxError && m_YMinValue >= m_YMaxValue; } } property Platform::String ^ XMin { Platform::String ^ get() { return m_XMin; } void set(Platform::String ^ value) { if (m_XMin == value) { return; } m_XMin = value; m_XIsMinLastChanged = true; if (m_Graph != nullptr) { try { size_t sz; auto number = std::stod(value->Data(), &sz); if (value->Length() == sz) { m_Graph->XAxisMin = m_XMinValue = number; XMinError = false; } else { XMinError = true; } } catch (...) { XMinError = true; } } RaisePropertyChanged("XError"); RaisePropertyChanged("XMin"); UpdateDisplayRange(); } } property Platform::String ^ XMax { Platform::String ^ get() { return m_XMax; } void set(Platform::String ^ value) { if (m_XMax == value) { return; } m_XMax = value; m_XIsMinLastChanged = false; if (m_Graph != nullptr) { try { size_t sz; auto number = std::stod(value->Data(), &sz); if (value->Length() == sz) { m_Graph->XAxisMax = m_XMaxValue = number; XMaxError = false; } else { XMaxError = true; } } catch (...) { XMaxError = true; } } RaisePropertyChanged("XError"); RaisePropertyChanged("XMax"); UpdateDisplayRange(); } } property Platform::String ^ YMin { Platform::String ^ get() { return m_YMin; } void set(Platform::String ^ value) { if (m_YMin == value) { return; } m_YMin = value; m_YIsMinLastChanged = true; if (m_Graph != nullptr) { try { size_t sz; auto number = std::stod(value->Data(), &sz); if (value->Length() == sz) { m_Graph->YAxisMin = m_YMinValue = number; YMinError = false; } else { YMinError = true; } } catch (...) { YMinError = true; } } RaisePropertyChanged("YError"); RaisePropertyChanged("YMin"); UpdateDisplayRange(); } } property Platform::String ^ YMax { Platform::String ^ get() { return m_YMax; } void set(Platform::String ^ value) { if (m_YMax == value) { return; } m_YMax = value; m_YIsMinLastChanged = false; if (m_Graph != nullptr) { try { size_t sz; auto number = std::stod(value->Data(), &sz); if (value->Length() == sz) { m_Graph->YAxisMax = m_YMaxValue = number; YMaxError = false; } else { YMaxError = true; } } catch (...) { YMaxError = true; } } RaisePropertyChanged("YError"); RaisePropertyChanged("YMax"); UpdateDisplayRange(); } } property int TrigUnit { int get() { return m_Graph == nullptr ? (int)Graphing::EvalTrigUnitMode::Invalid : m_Graph->TrigUnitMode; } void set(int value) { if (m_Graph == nullptr) { return; } m_Graph->TrigUnitMode = value; RaisePropertyChanged(L"TrigUnit"); } } property bool TrigModeRadians { bool get() { return m_Graph != nullptr && m_Graph->TrigUnitMode == (int)Graphing::EvalTrigUnitMode::Radians; } void set(bool value) { if (value && m_Graph != nullptr && m_Graph->TrigUnitMode != (int)Graphing::EvalTrigUnitMode::Radians) { m_Graph->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Radians; RaisePropertyChanged(L"TrigModeRadians"); RaisePropertyChanged(L"TrigModeDegrees"); RaisePropertyChanged(L"TrigModeGradians"); CalculatorApp::ViewModel::Common::TraceLogger::GetInstance()->LogGraphSettingsChanged(CalculatorApp::ViewModel::Common::GraphSettingsType::TrigUnits, L"Radians"); } } } property bool TrigModeDegrees { bool get() { return m_Graph != nullptr && m_Graph->TrigUnitMode == (int)Graphing::EvalTrigUnitMode::Degrees; } void set(bool value) { if (value && m_Graph != nullptr && m_Graph->TrigUnitMode != (int)Graphing::EvalTrigUnitMode::Degrees) { m_Graph->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Degrees; RaisePropertyChanged(L"TrigModeDegrees"); RaisePropertyChanged(L"TrigModeRadians"); RaisePropertyChanged(L"TrigModeGradians"); CalculatorApp::ViewModel::Common::TraceLogger::GetInstance()->LogGraphSettingsChanged(CalculatorApp::ViewModel::Common::GraphSettingsType::TrigUnits, L"Degrees"); } } } property bool TrigModeGradians { bool get() { return m_Graph != nullptr && m_Graph->TrigUnitMode == (int)Graphing::EvalTrigUnitMode::Grads; } void set(bool value) { if (value && m_Graph != nullptr && m_Graph->TrigUnitMode != (int)Graphing::EvalTrigUnitMode::Grads) { m_Graph->TrigUnitMode = (int)Graphing::EvalTrigUnitMode::Grads; RaisePropertyChanged(L"TrigModeGradians"); RaisePropertyChanged(L"TrigModeDegrees"); RaisePropertyChanged(L"TrigModeRadians"); CalculatorApp::ViewModel::Common::TraceLogger::GetInstance()->LogGraphSettingsChanged(CalculatorApp::ViewModel::Common::GraphSettingsType::TrigUnits, L"Gradians"); } } } public: void UpdateDisplayRange(); public: void SetGrapher(GraphControl::Grapher ^ grapher); void InitRanges(); void ResetView(); bool HasError(); private: Platform::String ^ m_XMin; Platform::String ^ m_XMax; Platform::String ^ m_YMin; Platform::String ^ m_YMax; double m_XMinValue; double m_XMaxValue; double m_YMinValue; double m_YMaxValue; bool m_dontUpdateDisplayRange; bool m_XIsMinLastChanged; bool m_YIsMinLastChanged; }; }
[ "noreply@github.com" ]
thisisakshatsri.noreply@github.com
99e753d63f42d129b194c3ca790139a3a635581d
56faa945655349a2c529b5076139ad823db2e516
/leetcode/medium/307.cpp
65a5cfed9044090c9b201803c680ca30fc4eb871
[]
no_license
lijinpei/leetcode
61e3fec4ec935ec0d3a8048e5df6c022b3663545
9833469506f4802009398b6217e510e35b188c95
refs/heads/master
2018-10-17T08:28:08.716683
2018-08-02T16:30:50
2018-08-02T16:30:50
120,696,376
0
0
null
null
null
null
UTF-8
C++
false
false
901
cpp
#include <vector> #include <cstdint> uint32_t LOWBITS(uint32_t v) { return v & -v; } class NumArray { uint32_t s; std::vector<int> bit, nums; int sum(uint32_t p) { int ret = 0; while (p) { ret += bit[p]; p -= LOWBITS(p); } return ret; } public: NumArray(const std::vector<int> & nums) : s(nums.size()), bit(s + 1), nums(s) { for (uint32_t i = 0; i < s; ++i) { update(i, nums[i]); } } void update(int i, int val) { int d = val - nums[i]; uint32_t p = i + 1; while (p <= s) { bit[p] += d; p += LOWBITS(p); } nums[i] = val; } int sumRange(int i, int j) { return sum(j + 1) - sum(i); } }; /** * Your NumArray object will be instantiated and called as such: * NumArray obj = new NumArray(nums); * obj.update(i,val); * int param_2 = obj.sumRange(i,j); */
[ "leekingp1994@163.com" ]
leekingp1994@163.com
030b79c12c8e894700ff65bc26fc134493a5d57d
58026475b343b937fcb94e8adeded69ef693e82b
/tools/json-ast-exporter/src/Options.cpp
e4b6c4e41be1c119ad107709e0bdf4ed9a5cf73d
[ "MIT" ]
permissive
plast-lab/cclyzer
ca6107e968579c5ae1156db6556940c65730b5f8
470b614ff26a348d5d9bde1cabe52cf668ec48b9
refs/heads/master
2021-01-16T18:05:18.515778
2020-10-02T11:37:55
2020-10-02T11:37:55
15,769,661
74
15
MIT
2020-10-02T11:37:57
2014-01-09T14:59:04
Python
UTF-8
C++
false
false
5,160
cpp
#include <assert.h> #include <iostream> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <boost/program_options.hpp> #include <boost/program_options/options_description.hpp> #include <boost/program_options/parsers.hpp> #include <boost/program_options/variables_map.hpp> #include "Options.hpp" namespace fs = boost::filesystem; namespace po = boost::program_options; using cclyzer::ast_exporter::Options; using boost::to_lower; Options::Options(int argc, char* argv[]) { const std::string appName = fs::basename(argv[0]); fs::path outdir; // Define and parse the program options po::options_description genericOpts("Options"); genericOpts.add_options() ("help,h", "Print help message") ("out-dir,o", po::value<fs::path>(&outdir), "Output directory for AST in JSON form") ("recursive,r", "Recurse into input directories") ("force,f", "Remove existing contents of output directory"); // hidden options group - don't show in help po::options_description hiddenOpts("hidden options"); hiddenOpts.add_options() ("input-files", po::value<std::vector<fs::path> >()->required(), "C/C++ source input files"); po::options_description cmdline_options; cmdline_options.add(genericOpts).add(hiddenOpts); // positional arguments po::positional_options_description positionalOptions; positionalOptions.add("input-files", -1); po::variables_map vm; try { po::store( po::command_line_parser(argc, argv) .options(cmdline_options) .positional(positionalOptions) .run(), vm); // --help option if (vm.count("help")) { std::cout << "Usage: " << appName << " [OPTIONS] INPUT_FILE...\n\n" << genericOpts; throw EXIT_SUCCESS; } // may throw error po::notify(vm); } catch(boost::program_options::required_option& e) { std::cerr << e.what() << " from option: " << e.get_option_name() << std::endl; throw ERROR_IN_COMMAND_LINE; } catch(boost::program_options::error& e) { std::cerr << e.what() << std::endl; throw ERROR_IN_COMMAND_LINE; } // Sanity checks assert(vm.count("input-files")); // Compute input files and create output directories std::vector<fs::path> paths = vm["input-files"].as<std::vector<fs::path> >(); set_input_files(paths.begin(), paths.end(), vm.count("recursive")); if (vm.count("out-dir")) { set_output_dir(outdir, vm.count("force")); } } template<typename FileIt> void Options::set_input_files(FileIt file_begin, FileIt file_end, bool shouldRecurse) { // Delete old contents inputFiles.clear(); // Iterate over every given path for (FileIt it = file_begin; it != file_end; ++it) { fs::path path = *it; // Check for existence if (!fs::exists(path)) { std::cerr << "Path does not exist: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Add normal files if (!fs::is_directory(path)) { inputFiles.push_back(path); continue; } if (!shouldRecurse) { std::cerr << "Input directory given, without -r option: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Recurse into directories for (fs::recursive_directory_iterator iter(path), end; iter != end; ++iter) { const fs::path& p = iter->path(); // Skip directories if (fs::is_directory(p)) continue; // Skip non C/C++ files if (!p.has_extension()) continue; std::string extension = p.extension().string(); // Downcase extension to_lower(extension); if (extension != ".c" && extension != ".cc" && extension != ".cp" && extension != ".cpp" && extension != ".cxx" && extension != ".c++" && extension != ".h" && extension != ".hpp") { continue; } inputFiles.push_back(iter->path()); } } } void Options::set_output_dir(fs::path path, bool shouldForce) { // Create non-existing directory if (!fs::exists(path)) fs::create_directory(path); if (!fs::is_directory(path)) { std::cerr << "Not a directory: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Remove old contents if (shouldForce) { for (fs::directory_iterator end, it(path); it != end; ++it) remove_all(it->path()); } // Ensure output directory is empty if (!fs::is_empty(path)) { std::cerr << "Directory not empty: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Store output directory (CHECK: should we canonicalize path) outdir = path; }
[ "gbalats@gmail.com" ]
gbalats@gmail.com
57db5926af38920f85257567f1ad2c59ad40ea3f
1af656c548d631368638f76d30a74bf93550b1d3
/chrome/browser/chromeos/power/auto_screen_brightness/als_reader.h
4cc31004eccd9763152cff85ab9171f41948eab8
[ "BSD-3-Clause" ]
permissive
pineal/chromium
8d246c746141ef526a55a0b387ea48cd4e7d42e8
e6901925dd5b37d55accbac55564f639bf4f788a
refs/heads/master
2023-03-17T05:50:14.231220
2018-10-24T20:11:12
2018-10-24T20:11:12
154,564,128
1
0
NOASSERTION
2018-10-24T20:20:43
2018-10-24T20:20:43
null
UTF-8
C++
false
false
1,519
h
// Copyright 2018 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 CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_ #define CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_ #include "base/observer_list_types.h" namespace chromeos { namespace power { namespace auto_screen_brightness { // Interface to ambient light reader. class AlsReader { public: // Status of AlsReader initialization. // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class AlsInitStatus { kSuccess = 0, kInProgress = 1, kDisabled = 2, kIncorrectConfig = 3, kMissingPath = 4, kMaxValue = kMissingPath }; // AlsReader must outlive the observers. class Observer : public base::CheckedObserver { public: Observer() = default; ~Observer() override = default; virtual void OnAmbientLightUpdated(int lux) = 0; virtual void OnAlsReaderInitialized(AlsInitStatus status) = 0; private: DISALLOW_COPY_AND_ASSIGN(Observer); }; virtual ~AlsReader() = default; // Adds or removes an observer. virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; }; } // namespace auto_screen_brightness } // namespace power } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
aa4dfad1b72468809b3d5e951bd26fd143896241
6cf49b15039dbe8c65af72d044ef28c7d6170db9
/ITAK/main.cpp
d97b45fb93aed5037790b2358ff62700a29e8fdb
[]
no_license
drakeaharper/cs1440
cd0d529d049d010b1a41cda7687d5d65b3b82df6
373d65ffbb6214f12b13dec58e4b64f47e78b737
refs/heads/master
2021-01-11T14:54:02.260140
2017-04-30T00:43:17
2017-04-30T00:43:17
80,245,002
0
0
null
null
null
null
UTF-8
C++
false
false
1,185
cpp
#include <iostream> #include <fstream> #include <string> #include "Dictionary.h" #include "Utils.h" #include "Analyzer.h" #include "DenialOfServiceAnalyzer.h" #include "PortScanAnalyzer.h" int main() { Configuration go; return 0; } /* Dictionary<std::string, KeyValue<std::string, KeyValue<std::string, std::string>>> baseDictionary; Utils lyndsee; std::string fileName = "SampleData.csv"; std::ifstream fileIn; fileIn.open(fileName); if (!fileIn) { std::cout << "File not opened." << std::endl; } lyndsee.buildDictionary(baseDictionary, fileIn); // ghetto test Utils::buildDictionary() because I can't get the tester config to work std::ofstream out("testBuilder.txt"); for (unsigned int index = 0; index < baseDictionary.getTotalEntries(); index++) { out << baseDictionary.getByIndex(index).getKey() << ", " << baseDictionary.getByIndex(index).getValue().getKey() << ", " << baseDictionary.getByIndex(index).getValue().getValue().getKey() << ", " << baseDictionary.getByIndex(index).getValue().getValue().getValue() << std::endl; } */
[ "drakeaharper@gmail.com" ]
drakeaharper@gmail.com
fb164e40cc1d4ad6e31c7a7725b327dec9d2a3ae
57a61c7ea1cc0a2e7686a07f3430121597043dab
/irrlicht-1.7.3/source/Irrlicht/CFileList.h
d8213e4c52b4c358f144e781f40ab3df6ea7f51f
[]
no_license
dg8fv2010/WonderLandNet
8c3b85a5abc813dba6407cdc5b72cfea4a8caaaf
22f7aeef8c676c56f49c7c6854c0a469c29bdb91
refs/heads/master
2021-01-10T12:03:31.853501
2015-06-06T12:15:49
2015-06-06T12:15:49
36,978,516
3
0
null
null
null
null
UTF-8
C++
false
false
3,616
h
// Copyright (C) 2002-2010 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __C_FILE_LIST_H_INCLUDED__ #define __C_FILE_LIST_H_INCLUDED__ #include "IFileList.h" #include "irrString.h" #include "irrArray.h" namespace irr { namespace io { //! An entry in a list of files, can be a folder or a file. struct SFileListEntry { //! The name of the file /** If this is a file or folder in the virtual filesystem and the archive was created with the ignoreCase flag then the file name will be lower case. */ io::path Name; //! The name of the file including the path /** If this is a file or folder in the virtual filesystem and the archive was created with the ignoreDirs flag then it will be the same as Name. */ io::path FullName; //! The size of the file in bytes u32 Size; //! The ID of the file in an archive /** This is used to link the FileList entry to extra info held about this file in an archive, which can hold things like data offset and CRC. */ u32 ID; //! True if this is a folder, false if not. bool IsDirectory; //! The == operator is provided so that CFileList can slowly search the list! bool operator ==(const struct SFileListEntry& other) const { if (IsDirectory != other.IsDirectory) return false; return FullName.equals_ignore_case(other.FullName); } //! The < operator is provided so that CFileList can sort and quickly search the list. bool operator <(const struct SFileListEntry& other) const { if (IsDirectory != other.IsDirectory) return IsDirectory; return FullName.lower_ignore_case(other.FullName); } }; //! Implementation of a file list class CFileList : public IFileList { public: // CFileList methods //! Constructor /** \param path The path of this file archive */ CFileList(const io::path& path, bool ignoreCase, bool ignorePaths); //! Destructor virtual ~CFileList(); //! Add as a file or folder to the list /** \param fullPath The file name including path, up to the root of the file list. \param isDirectory True if this is a directory rather than a file. \param size The size of the file in bytes. \param id The ID of the file in the archive which owns it */ virtual u32 addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id=0); //! Sorts the file list. You should call this after adding any items to the file list virtual void sort(); //! Returns the amount of files in the filelist. virtual u32 getFileCount() const; //! Gets the name of a file in the list, based on an index. virtual const io::path& getFileName(u32 index) const; //! Gets the full name of a file in the list, path included, based on an index. virtual const io::path& getFullFileName(u32 index) const; //! Returns the ID of a file in the file list, based on an index. virtual u32 getID(u32 index) const; //! Returns true if the file is a directory virtual bool isDirectory(u32 index) const; //! Returns the size of a file virtual u32 getFileSize(u32 index) const; //! Searches for a file or folder within the list, returns the index virtual s32 findFile(const io::path& filename, bool isFolder) const; //! Returns the base path of the file list virtual const io::path& getPath() const; protected: //! Ignore paths when adding or searching for files bool IgnorePaths; //! Ignore case when adding or searching for files bool IgnoreCase; //! Path to the file list io::path Path; //! List of files core::array<SFileListEntry> Files; }; } // end namespace irr } // end namespace io #endif
[ "xuewentao@zheng-exp.lab" ]
xuewentao@zheng-exp.lab
064c4d6e412580c3b37908b2a19f8243a5c4c7f6
3f5022154cbec1bb4643a50316e297f979b53184
/gcc-7.4.0-amd64/usr/x86_64-astraeus-linux-gnu/include/c++/7.4.0/bits/sstream.tcc
5c0e9993e85aa3c84890a9d8e416dad3780481a3
[]
no_license
ahyangyi/astraeus-toolchain-binary
45b011d3a247e67fa86f0572a183dca3fbf6abd5
4c56bf133c52ddba4e357d39fc13b2755dce0583
refs/heads/master
2020-07-31T06:35:10.026719
2019-09-25T15:12:19
2019-09-25T15:12:19
210,516,474
0
0
null
null
null
null
UTF-8
C++
false
false
130
tcc
version https://git-lfs.github.com/spec/v1 oid sha256:f331fe4c0ec14855eb0e4b41ed1a8be4f020faa1dd3d3e74706a4eb43f12be66 size 10115
[ "ahyangyi@gmail.com" ]
ahyangyi@gmail.com
ee9ef0215f9d55114a321f34cf3fb93045b30a01
fbfa70577946bc5ee45cfd20b8937be098ae2837
/Particle_1D_Mechanics.cpp
0a7ba6c176b6fe44af7b8bcb45402b70606699f0
[]
no_license
srankli/MPM
a26c018c8f6c21a4bc2a0b01aa02dc268e5535a1
4511f6bdd0c01dad2318a5adfb061bd94e1d17a5
refs/heads/master
2020-04-05T15:54:16.235628
2018-11-21T08:13:05
2018-11-21T08:13:05
156,989,019
0
0
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
#include "Particle_1D_Mechanics.h" int ObjectByParticle_1D_Mechanics::addParticle( ParticleParam_1D_Mechanics *pcl_param, ConstitutiveModelParam *pcl_cm) { Particle_1D_Mechanics *pcl; if (!pcl_param || !pcl_cm) return -1; ++particleNum; pcl = static_cast<Particle_1D_Mechanics *>(particles_mem.alloc()); pcl->index = ++curParticleIndex; pcl->object = this; pcl->x = pcl_param->x; pcl->mass = pcl_param->mass; pcl->density = pcl_param->density; pcl->momentum1 = pcl_param->momentum1; pcl->stress11 = pcl_param->stress11; pcl->strain11 = pcl_param->strain11; pcl->estrain11 = pcl_param->estrain11; pcl->pstrain11 = pcl_param->pstrain11; constitutiveModels_mem.add_model(pcl_cm); return 0; } void ObjectByParticle_1D_Mechanics::finish_init() { ObjectByParticle::finish_init(); particles = static_cast<Particle_1D_Mechanics *>(particles_mem.get_mem()); /* // print the whole object size_t i; std::cout << "Particle info:" << std::endl; for (i = 0; i < particleNum; i++) { std::cout << "No.: " << particles[i].index << " CM: " << (unsigned int)(particles[i].cm->getType()) << std::endl; } std::cout << "Mass force BC:" << std::endl; for (i = 0; i < massForceBCNum; i++) { std::cout << "Pcl_id:" << massForceBCs[i].particle->index << " Value: " << massForceBCs[i].bodyForce1 << std::endl; } std::cout << "Surface force BC:" << std::endl; for (i = 0; i < surfaceForceBCNum; i++) { std::cout << "Pcl_id:" << surfaceForceBCs[i].particle->index << " Value: " << surfaceForceBCs[i].surfaceForce1 << std::endl; } */ }
[ "yimingli0802@foxmail.com" ]
yimingli0802@foxmail.com
e77552ec65a438a6ad053575e1b57cded2cdffa4
c0c93e8f0112f9cbfd6333b23749bb429505312a
/crane-common/overlay/hardware/libhardware/gralloc/mapper.cpp
d9f25bbd86cc1838957d27a0386b307e195ea231
[]
no_license
stelios97/allwinner_board_files
2e2a8ca414dfd6f29b4cfa67182dfb7f461dbc18
bf9248c55ce7d878a7ab74bc7bb9ca2c758b4d55
refs/heads/master
2021-01-24T01:10:36.407815
2012-03-13T16:36:16
2012-03-13T16:36:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,212
cpp
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <limits.h> #include <errno.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <cutils/log.h> #include <cutils/atomic.h> #include <hardware/hardware.h> #include <hardware/gralloc.h> #include "gralloc_priv.h" // we need this for now because pmem cannot mmap at an offset #define PMEM_HACK 1 /* desktop Linux needs a little help with gettid() */ #if defined(ARCH_X86) && !defined(HAVE_ANDROID_OS) #define __KERNEL__ # include <linux/unistd.h> pid_t gettid() { return syscall(__NR_gettid);} #undef __KERNEL__ #endif /*****************************************************************************/ static int gralloc_map(gralloc_module_t const* module, buffer_handle_t handle, void** vaddr) { private_handle_t* hnd = (private_handle_t*)handle; if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { size_t size = hnd->size; #if PMEM_HACK size += hnd->offset; #endif void* mappedAddress = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0); if (mappedAddress == MAP_FAILED) { LOGE("Could not mmap %s", strerror(errno)); return -errno; } hnd->base = intptr_t(mappedAddress) + hnd->offset; //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", // hnd->fd, hnd->offset, hnd->size, mappedAddress); } *vaddr = (void*)hnd->base; return 0; } static int gralloc_unmap(gralloc_module_t const* module, buffer_handle_t handle) { private_handle_t* hnd = (private_handle_t*)handle; if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { void* base = (void*)hnd->base; size_t size = hnd->size; #if PMEM_HACK base = (void*)(intptr_t(base) - hnd->offset); size += hnd->offset; #endif //LOGD("unmapping from %p, size=%d", base, size); if (munmap(base, size) < 0) { LOGE("Could not unmap %s", strerror(errno)); } } hnd->base = 0; return 0; } /*****************************************************************************/ static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; /*****************************************************************************/ int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; // In this implementation, we don't need to do anything here /* NOTE: we need to initialize the buffer as not mapped/not locked * because it shouldn't when this function is called the first time * in a new process. Ideally these flags shouldn't be part of the * handle, but instead maintained in the kernel or at least * out-of-line */ // if this handle was created in this process, then we keep it as is. private_handle_t* hnd = (private_handle_t*)handle; if (hnd->pid != getpid()) { hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; } return 0; } int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. * NOTE: the framebuffer is handled differently and is never unmapped. */ private_handle_t* hnd = (private_handle_t*)handle; LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); // never unmap buffers that were created in this process if (hnd->pid != getpid()) { if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { gralloc_unmap(module, handle); } hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; } return 0; } int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd) { /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. */ LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[terminate] handle %p still locked (state=%08x)", hnd, hnd->lockState); if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { // this buffer was mapped, unmap it now if ((hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) && (hnd->pid == getpid())) { // ... unless it's a "master" pmem buffer, that is a buffer // mapped in the process it's been allocated. // (see gralloc_alloc_buffer()) } else { gralloc_unmap(module, hnd); } } return 0; } int gralloc_lock(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr) { if (private_handle_t::validate(handle) < 0) return -EINVAL; int err = 0; private_handle_t* hnd = (private_handle_t*)handle; int32_t current_value, new_value; int retry; do { current_value = hnd->lockState; new_value = current_value; if (current_value & private_handle_t::LOCK_STATE_WRITE) { // already locked for write LOGE("handle %p already locked for write", handle); return -EBUSY; } else if (current_value & private_handle_t::LOCK_STATE_READ_MASK) { // already locked for read if (usage & (GRALLOC_USAGE_SW_WRITE_MASK | GRALLOC_USAGE_HW_RENDER)) { LOGE("handle %p already locked for read", handle); return -EBUSY; } else { // this is not an error //LOGD("%p already locked for read... count = %d", // handle, (current_value & ~(1<<31))); } } // not currently locked if (usage & (GRALLOC_USAGE_SW_WRITE_MASK | GRALLOC_USAGE_HW_RENDER)) { // locking for write new_value |= private_handle_t::LOCK_STATE_WRITE; } new_value++; retry = android_atomic_cmpxchg(current_value, new_value, (volatile int32_t*)&hnd->lockState); } while (retry); if (new_value & private_handle_t::LOCK_STATE_WRITE) { // locking for write, store the tid hnd->writeOwner = gettid(); } if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { if (!(current_value & private_handle_t::LOCK_STATE_MAPPED)) { // we need to map for real pthread_mutex_t* const lock = &sMapLock; pthread_mutex_lock(lock); if (!(hnd->lockState & private_handle_t::LOCK_STATE_MAPPED)) { err = gralloc_map(module, handle, vaddr); if (err == 0) { android_atomic_or(private_handle_t::LOCK_STATE_MAPPED, (volatile int32_t*)&(hnd->lockState)); } } pthread_mutex_unlock(lock); } *vaddr = (void*)hnd->base; } return err; } int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; private_handle_t* hnd = (private_handle_t*)handle; int32_t current_value, new_value; do { current_value = hnd->lockState; new_value = current_value; if (current_value & private_handle_t::LOCK_STATE_WRITE) { // locked for write if (hnd->writeOwner == gettid()) { hnd->writeOwner = 0; new_value &= ~private_handle_t::LOCK_STATE_WRITE; } } if ((new_value & private_handle_t::LOCK_STATE_READ_MASK) == 0) { LOGE("handle %p not locked", handle); return -EINVAL; } new_value--; } while (android_atomic_cmpxchg(current_value, new_value, (volatile int32_t*)&hnd->lockState)); return 0; }
[ "contact@arpandeb.com" ]
contact@arpandeb.com
c67d22637fe0d01965a99ddfea05623be6cb7c8b
d96349b211a135bc63e828f186e3560c0d383197
/Cp8/8-f-1_skill.cpp
2665a1fc0e6f32220f08037ea3747d67b6de1c7b
[]
no_license
masa-k0101/Self-Study_Cpp
116904e7a45d8d211e85b3e20cfbfc602dd866f4
1fdd3b0637274934e7730ca87a400bf2c97daf8f
refs/heads/master
2022-12-14T01:59:20.763522
2020-09-15T13:20:08
2020-09-15T13:20:08
263,053,847
0
0
null
null
null
null
UTF-8
C++
false
false
491
cpp
#include<iostream> using namespace std; main() { // デフォルト設定で表示 cout << 100.0 << '\n'; // ここで書式を変更 cout.setf(ios::hex); cout << 100 << "\n"; cout.unsetf(ios::hex); cout.setf(ios::oct); cout << 100 << "\n"; int n = 100; /* 10進表示 */ printf("n = %d\n", n); /* 8進表記 */ printf("n = %o\n", n); /* 16進表記 */ printf("n = %X\n", n); return 0; }
[ "noreply@github.com" ]
masa-k0101.noreply@github.com
9a68ddb48a81753dc27dcd793647a216f920ec6e
a8a29de75dd6ad07dd75c4e3ffa2d3da807d4250
/include/fastformat/sinks/null.hpp
eaa9e506ed75d98b98fbe0f6669c99afcd926ba3
[ "BSD-2-Clause" ]
permissive
moteus/FastFormat
3dbcdc33359f0d68db3db9f50f56b3f5d9296cdc
acd894848a5c4a6f9f21ccdd15aa80cc0a079496
refs/heads/master
2021-01-17T17:12:18.812317
2015-09-28T12:15:05
2015-09-28T12:15:05
63,425,872
1
1
null
2016-07-15T13:58:11
2016-07-15T13:58:10
null
UTF-8
C++
false
false
5,314
hpp
/* ///////////////////////////////////////////////////////////////////////// * File: fastformat/sinks/null.hpp * * Purpose: A class that acts as a bit-bucket sink. * * Created: 3rd December 2008 * Updated: 14th September 2010 * * Home: http://www.fastformat.org/ * * Copyright (c) 2008-2010, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the names of Matthew Wilson and Synesis Software nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////// */ /** \file fastformat/sinks/null.hpp * * [C++ only] A class that acts as a bit-bucket sink. */ #ifndef FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL #define FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL /* ///////////////////////////////////////////////////////////////////////// * Version information */ #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_MAJOR 1 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_MINOR 1 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_REVISION 2 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_EDIT 6 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * Language */ #ifndef __cplusplus # error This file can only be included in C++ compilation units #endif /* !__cplusplus */ /* ///////////////////////////////////////////////////////////////////////// * Includes */ #include <fastformat/fastformat.h> #include <fastformat/format/standard_flags.hpp> #include <fastformat/quality/contract.h> /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #if !defined(FASTFORMAT_NO_NAMESPACE) namespace fastformat { namespace sinks { #endif /* !FASTFORMAT_NO_NAMESPACE */ /* ///////////////////////////////////////////////////////////////////////// * Classes */ /** A class that acts as a bit-bucket sink * * \ingroup group__sinks */ struct null_sink { size_t numWrites; /*!< The number of times fmt_slices() was invoked on the instance */ size_t numSlices; /*!< The total number of slices passed in all invocations of fmt_slices() */ size_t cchTotal; /*!< The total number of characters passed in all invocations of fmt_slices() */ public: // Construction /** Initialises all statistics members to zero */ null_sink() : numWrites(0u) , numSlices(0u) , cchTotal(0u) {} }; /* ///////////////////////////////////////////////////////////////////////// * Action Shims */ /** Writes an array of string slices into a <code>null_sink</code> sink. * * \ingroup group__sinks */ inline null_sink& fmt_slices( null_sink& sink , int /* flags */ , size_t cchTotal , size_t numResults , ff_string_slice_t const* results ) { if(NULL == results) { FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(0u == cchTotal, "Cannot have non-zero size if the results array pointer is null"); FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(0u == numResults, "Cannot have non-zero array elements if the results array pointer is null"); } else { ++sink.numWrites; sink.numSlices += numResults; sink.cchTotal += cchTotal; } return sink; } /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #if !defined(FASTFORMAT_NO_NAMESPACE) } /* namespace sinks */ } /* namespace fastformat */ #endif /* !FASTFORMAT_NO_NAMESPACE */ /* ////////////////////////////////////////////////////////////////////// */ #endif /* FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL */ /* ///////////////////////////// end of file //////////////////////////// */
[ "matthew@synesis.com.au" ]
matthew@synesis.com.au
0bc16a5e72ff7144a2f809280d3e69bea38c4c23
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/abc053/B/4715497.cpp
74ab4429dd3c740a35ce24dc57ed00d97f86f87c
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
571
cpp
#include <iostream> #include <string> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int a_pos = 0; int z_pos = 0; for (auto itr = s.begin(); itr != s.end(); ++itr, ++a_pos) { if (*itr == 'A') { break; } } for (auto itr = s.end(); itr != s.begin(); --itr, ++z_pos) { if (*itr == 'Z') { break; } } cout << s.length() - a_pos - z_pos + 1 << endl; return 0; }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
62e9d63db8004d66f419f028ad09c82d396ae0a6
74cd1bcbabcebd6b0ae2d9cd5a8e08864bcc1083
/B1463/B1463_강리정.cpp
c2b157ee27994867b384a046fb7ae96491c646e0
[]
no_license
gogosamsung/samsung
6b800c4d7a04bf365e8bc40714830cc9e67bb421
14fe0155ced6b5dd224d5dbde7207b07c0e37be2
refs/heads/main
2023-08-25T03:06:54.054541
2021-10-23T14:56:08
2021-10-23T14:56:08
410,567,433
0
5
null
2021-10-21T13:40:44
2021-09-26T14:01:44
Java
UTF-8
C++
false
false
505
cpp
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int N; int memo[1000000] = { 0 }; void gogo(int n, int cnt) { if (n == 1) { if (memo[1] == 0) { memo[1] = cnt; } else if (memo[1] > cnt) { memo[1] = cnt; } return; } if (memo[n]!=0 && memo[n] <= cnt) return; memo[n] = cnt; if (n % 3 == 0) { gogo(n / 3, cnt + 1); } if (n % 2 == 0) { gogo(n / 2, cnt + 1); } gogo(n - 1, cnt + 1); } int main() { scanf("%d", &N); gogo(N, 0); printf("%d", memo[1]); return 0; }
[ "noreply@github.com" ]
gogosamsung.noreply@github.com
0c353113d49dde5026498454055f1cb171dd194e
6848723448cc22474863f6506f30bdbac2b6293e
/tools/mosesdecoder-master/phrase-extract/syntax-common/tree_test.cc
8e689f0000e50e8ddc0ea7d55fd8bb43950d70af
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only" ]
permissive
Pangeamt/nectm
74b3052ba51f227cd508b89d3c565feccc0d2f4f
6b84f048698f2530b9fdbb30695f2e2217c3fbfe
refs/heads/master
2022-04-09T11:21:56.646469
2020-03-30T07:37:41
2020-03-30T07:37:41
250,306,101
1
0
Apache-2.0
2020-03-26T16:05:11
2020-03-26T16:05:10
null
UTF-8
C++
false
false
4,375
cc
#include "tree.h" #define BOOST_TEST_MODULE TreeTest #include <boost/test/unit_test.hpp> #include <boost/scoped_ptr.hpp> namespace MosesTraining { namespace Syntax { namespace { // Test Tree<>::PreOrderIterator with a trivial, single-node tree. BOOST_AUTO_TEST_CASE(pre_order_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(123)); Tree<int>::PreOrderIterator p(*root); BOOST_REQUIRE(p != Tree<int>::PreOrderIterator()); BOOST_REQUIRE(p->value() == 123); ++p; BOOST_REQUIRE(p == Tree<int>::PreOrderIterator()); } // Test Tree<>::PreOrderIterator on this tree: (1 (2 3) (4) (5 6 (7 8))) BOOST_AUTO_TEST_CASE(pre_order_2) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children().push_back(new Tree<int>(4)); root->children().push_back(new Tree<int>(5)); root->children()[2]->children().push_back(new Tree<int>(6)); root->children()[2]->children().push_back(new Tree<int>(7)); root->children()[2]->children()[1]->children().push_back(new Tree<int>(8)); root->SetParents(); Tree<int>::PreOrderIterator p(*root); Tree<int>::PreOrderIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 1); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 2); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 5); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 7); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 8); ++p; BOOST_REQUIRE(p == end); } // Test Tree<>::ConstPreOrderIterator on this tree: (1 (2 (3 (4 (5) (6)))) (7)) BOOST_AUTO_TEST_CASE(const_pre_order_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children()[0]->children()[0]->children().push_back(new Tree<int>(4)); root->children()[0]->children()[0]->children()[0]->children().push_back( new Tree<int>(5)); root->children()[0]->children()[0]->children()[0]->children().push_back( new Tree<int>(6)); root->children().push_back(new Tree<int>(7)); root->SetParents(); Tree<int>::ConstPreOrderIterator p(*root); Tree<int>::ConstPreOrderIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 1); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 2); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 5); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 7); ++p; BOOST_REQUIRE(p == end); } // Test Tree<>::LeafIterator with a trivial, single-node tree. BOOST_AUTO_TEST_CASE(leaf_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(123)); Tree<int>::LeafIterator p(*root); BOOST_REQUIRE(p != Tree<int>::LeafIterator()); BOOST_REQUIRE(p->value() == 123); ++p; BOOST_REQUIRE(p == Tree<int>::LeafIterator()); } // Test Tree<>::LeafIterator on this tree: (1 (2 3) (4) (5 6 (7 8))) BOOST_AUTO_TEST_CASE(leaf_2) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children().push_back(new Tree<int>(4)); root->children().push_back(new Tree<int>(5)); root->children()[2]->children().push_back(new Tree<int>(6)); root->children()[2]->children().push_back(new Tree<int>(7)); root->children()[2]->children()[1]->children().push_back(new Tree<int>(8)); root->SetParents(); Tree<int>::LeafIterator p(*root); Tree<int>::LeafIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 8); ++p; BOOST_REQUIRE(p == end); } } // namespace } // namespace Syntax } // namespace MosesTraining
[ "alexander.raginsky@gmail.com" ]
alexander.raginsky@gmail.com
f844974909f7ecb127696d2b93920b1a575e48bd
671ef594c3a043b32900864b3f5bf13bbcdab0aa
/src/training/elapsedtimecondition.h
6762d33480632129600dea9b89a5f45cf7cef28c
[ "MIT" ]
permissive
VSitoianu/Allegiance
bae7206b874d02fdbf4c9c746e9834c7ef93154e
6f3213b78f793c6f77fd397c280cd2dd80c46396
refs/heads/master
2021-05-07T17:15:01.811214
2017-10-22T18:18:44
2017-10-22T18:18:44
108,667,678
1
0
null
2017-10-28T17:02:26
2017-10-28T17:02:26
null
UTF-8
C++
false
false
795
h
/* ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved. ** ** File: elapsedtimecondition.h ** ** Author: ** ** Description: ** Header file for the training library "elapsedtimecondition" interface. ** ** History: */ #ifndef _ELAPSED_TIME_CONDITION_H_ #define _ELAPSED_TIME_CONDITION_H_ #ifndef _PERIODIC_CONDITION_H_ #include "PeriodicCondition.h" #endif //_PERIODIC_CONDITION_H_ #ifndef _N_TIMES_CONDITION_H_ #include "NTimesCondition.h" #endif //_N_TIMES_CONDITION_H_ #ifndef _TRUE_CONDITION_H_ #include "TrueCondition.h" #endif //_TRUE_CONDITION_H_ namespace Training { #define ElapsedTimeCondition(fTime) NTimesCondition (new PeriodicCondition (new TrueCondition, fTime), 2, true) } #endif //_ELAPSED_TIME_CONDITION_H_
[ "Administrator@svn-alleg.net" ]
Administrator@svn-alleg.net
d7768827b482fb62285ec1a9dde3e8c737254b75
2de859cf5e8a4e7c0e6b4804495a2dae7404d226
/GeometricTools/Graphics/FontArialW400H12.cpp
0b1c6ab5a510678a697858a2de37df2d0e367215
[]
no_license
thecsapprentice/world-builder-dependencies
ac20734b9b9f5305f5342b0b737d7e34aa6a3bb6
9528ad27fc35f953e1e446fbd9493e291c92aaa8
refs/heads/master
2020-08-27T16:52:39.356801
2019-10-26T20:36:00
2019-10-26T20:36:00
217,438,016
1
0
null
null
null
null
UTF-8
C++
false
false
106,172
cpp
// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2019 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #include <Graphics/GTGraphicsPCH.h> #include <Graphics/FontArialW400H12.h> using namespace gte; FontArialW400H12::FontArialW400H12(std::shared_ptr<ProgramFactory> const& factory, int maxMessageLength) : Font(factory, msWidth, msHeight, reinterpret_cast<unsigned char const*>(msTexels), msCharacterData, maxMessageLength) { } int FontArialW400H12::msWidth = 1666; int FontArialW400H12::msHeight = 12; unsigned char FontArialW400H12::msTexels[19992] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 0, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, }; float FontArialW400H12::msCharacterData[257] = { 0.000300f, 0.005102f, 0.009904f, 0.014706f, 0.019508f, 0.024310f, 0.029112f, 0.033914f, 0.038715f, 0.043517f, 0.048319f, 0.053121f, 0.057923f, 0.062725f, 0.067527f, 0.072329f, 0.077131f, 0.081933f, 0.086735f, 0.091537f, 0.096339f, 0.101140f, 0.105942f, 0.110744f, 0.115546f, 0.120348f, 0.125150f, 0.129952f, 0.134754f, 0.139556f, 0.144358f, 0.149160f, 0.153962f, 0.156363f, 0.158763f, 0.161164f, 0.164766f, 0.168367f, 0.173770f, 0.177971f, 0.179772f, 0.182173f, 0.184574f, 0.187575f, 0.191176f, 0.193577f, 0.195978f, 0.198379f, 0.200780f, 0.204382f, 0.207983f, 0.211585f, 0.215186f, 0.218788f, 0.222389f, 0.225990f, 0.229592f, 0.233193f, 0.236795f, 0.239196f, 0.241597f, 0.245198f, 0.248800f, 0.252401f, 0.256002f, 0.262005f, 0.266206f, 0.270408f, 0.275210f, 0.280012f, 0.284214f, 0.288415f, 0.293217f, 0.298019f, 0.300420f, 0.304022f, 0.308223f, 0.311825f, 0.316627f, 0.321429f, 0.326230f, 0.330432f, 0.335234f, 0.340036f, 0.344238f, 0.347839f, 0.352641f, 0.356843f, 0.362845f, 0.366447f, 0.371248f, 0.375450f, 0.377851f, 0.380252f, 0.382653f, 0.385054f, 0.388655f, 0.391056f, 0.394658f, 0.398259f, 0.401861f, 0.405462f, 0.409064f, 0.412065f, 0.415666f, 0.419268f, 0.421068f, 0.422869f, 0.426471f, 0.428271f, 0.433673f, 0.437275f, 0.440876f, 0.444478f, 0.448079f, 0.450480f, 0.454082f, 0.456483f, 0.460084f, 0.464286f, 0.468487f, 0.472089f, 0.476290f, 0.479292f, 0.481693f, 0.484094f, 0.486495f, 0.490096f, 0.494898f, 0.499700f, 0.504502f, 0.509304f, 0.514106f, 0.518908f, 0.523709f, 0.528511f, 0.533313f, 0.538115f, 0.542917f, 0.547719f, 0.552521f, 0.557323f, 0.562125f, 0.566927f, 0.571729f, 0.576531f, 0.581333f, 0.586134f, 0.590936f, 0.595738f, 0.600540f, 0.605342f, 0.610144f, 0.614946f, 0.619748f, 0.624550f, 0.629352f, 0.634154f, 0.638956f, 0.643757f, 0.648559f, 0.650960f, 0.653361f, 0.656963f, 0.660564f, 0.664166f, 0.667767f, 0.670168f, 0.673769f, 0.676170f, 0.680972f, 0.683373f, 0.686975f, 0.690576f, 0.692977f, 0.697779f, 0.701381f, 0.704382f, 0.707983f, 0.710384f, 0.712785f, 0.715186f, 0.718787f, 0.722389f, 0.724790f, 0.727191f, 0.729592f, 0.731993f, 0.735594f, 0.740996f, 0.746399f, 0.751801f, 0.756002f, 0.760204f, 0.764406f, 0.768607f, 0.772809f, 0.777011f, 0.781212f, 0.787215f, 0.791417f, 0.795618f, 0.799820f, 0.804022f, 0.808223f, 0.810624f, 0.813025f, 0.815426f, 0.817827f, 0.822029f, 0.826230f, 0.831032f, 0.835834f, 0.840636f, 0.845438f, 0.850240f, 0.853841f, 0.858643f, 0.862845f, 0.867047f, 0.871248f, 0.875450f, 0.879652f, 0.883853f, 0.888055f, 0.891657f, 0.895258f, 0.898860f, 0.902461f, 0.906062f, 0.909664f, 0.915066f, 0.918667f, 0.922269f, 0.925870f, 0.929472f, 0.933073f, 0.935474f, 0.937875f, 0.940276f, 0.942677f, 0.946278f, 0.949880f, 0.953481f, 0.957083f, 0.960684f, 0.964286f, 0.967887f, 0.971489f, 0.975090f, 0.978691f, 0.982293f, 0.985894f, 0.989496f, 0.993097f, 0.996699f, 1.000300f, };
[ "nmitchel@cs.wisc.edu" ]
nmitchel@cs.wisc.edu
2987d2dba0e2536fcfd078571b3d66b3038e988a
4c85c3017c86b66f203e46bd7785cb34af9e7eb8
/include/KeyFrameDataBase.h
4180552daeaf3a5de23b1aa5d47f7cda1b265d76
[]
no_license
StanleyYake/Kinect_SLAM
f2481abeaf21999e3fcae8d2e5b201c61537257c
016640c9da5aded6399b4dd95cc7cc68b9696cd1
refs/heads/master
2022-03-14T02:45:37.436040
2018-07-05T13:52:03
2018-07-05T13:56:16
469,284,731
1
0
null
2022-03-13T06:01:43
2022-03-13T06:01:42
null
UTF-8
C++
false
false
1,793
h
/** * This file is part of ORB-SLAM2. * * Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza) * For more information see <https://github.com/raulmur/ORB_SLAM2> * * ORB-SLAM2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ORB-SLAM2 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 ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>. */ #ifndef KEYFRAMEDATABASE_H #define KEYFRAMEDATABASE_H #include <vector> #include <list> #include <set> #include "KeyFrame.h" #include "Frame.h" #include "ORBVocabulary.h" #include<QMutex> namespace KINECT_SLAM { class KeyFrame; class Frame; class KeyFrameDatabase { public: KeyFrameDatabase(const ORBVocabulary &voc); void add(KeyFrame* pKF); void erase(KeyFrame* pKF); void clear(); // Loop Detection std::vector<KeyFrame *> DetectLoopCandidates(KeyFrame* pKF, float minScore); // Relocalization std::vector<KeyFrame*> DetectRelocalizationCandidates(Frame* F); protected: // Associated vocabulary const ORBVocabulary* mpVoc; ///< 预先训练好的词典 TemplatedVocabulary<DBoW2::FORB::TDescriptor, DBoW2::FORB>// Mat嘛 // Inverted file std::vector<list<KeyFrame*> > mvInvertedFile; ///< 倒排索引,mvInvertedFile[i]表示包含了第i个word id的所有关键帧 // Mutex QMutex mMutex; }; } #endif
[ "mysita@vip.qq.com" ]
mysita@vip.qq.com
eaa18a199f1a71d94af83ce901018d228a133c4e
d366edcc8b6202e810c362ba1776cf453ebb13dd
/googletest/src/gtest-death-test.cc
33248caa313e3908dd0b02b04c90183bc61460a1
[ "MIT" ]
permissive
madureira/math
1674b92099d748cc162ed710f62b2196449507e9
85bd826d401ed1632aad21c48e6483cfb9f4ba97
refs/heads/master
2020-04-08T13:53:11.905859
2020-02-19T16:51:53
2020-02-19T16:51:53
159,411,211
0
0
MIT
2018-11-28T02:07:27
2018-11-27T22:53:07
C++
UTF-8
C++
false
false
62,203
cc
// Copyright 2005, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // This file implements death tests. #include "pch.h" #include "gtest/gtest-death-test.h" #include <utility> #include "gtest/internal/gtest-port.h" #include "gtest/internal/custom/gtest.h" #if GTEST_HAS_DEATH_TEST # if GTEST_OS_MAC # include <crt_externs.h> # endif // GTEST_OS_MAC # include <errno.h> # include <fcntl.h> # include <limits.h> # if GTEST_OS_LINUX # include <signal.h> # endif // GTEST_OS_LINUX # include <stdarg.h> # if GTEST_OS_WINDOWS # include <windows.h> # else # include <sys/mman.h> # include <sys/wait.h> # endif // GTEST_OS_WINDOWS # if GTEST_OS_QNX # include <spawn.h> # endif // GTEST_OS_QNX # if GTEST_OS_FUCHSIA # include <lib/fdio/fd.h> # include <lib/fdio/io.h> # include <lib/fdio/spawn.h> # include <lib/zx/channel.h> # include <lib/zx/port.h> # include <lib/zx/process.h> # include <lib/zx/socket.h> # include <zircon/processargs.h> # include <zircon/syscalls.h> # include <zircon/syscalls/policy.h> # include <zircon/syscalls/port.h> # endif // GTEST_OS_FUCHSIA #endif // GTEST_HAS_DEATH_TEST #include "gtest/gtest-message.h" #include "gtest/internal/gtest-string.h" #include "src/gtest-internal-inl.h" namespace testing { // Constants. // The default death test style. // // This is defined in internal/gtest-port.h as "fast", but can be overridden by // a definition in internal/custom/gtest-port.h. The recommended value, which is // used internally at Google, is "threadsafe". static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE; GTEST_DEFINE_string_( death_test_style, internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), "Indicates how to run a death test in a forked child process: " "\"threadsafe\" (child process re-executes the test binary " "from the beginning, running only the specific death test) or " "\"fast\" (child process runs the death test immediately " "after forking)."); GTEST_DEFINE_bool_( death_test_use_fork, internal::BoolFromGTestEnv("death_test_use_fork", false), "Instructs to use fork()/_exit() instead of clone() in death tests. " "Ignored and always uses fork() on POSIX systems where clone() is not " "implemented. Useful when running under valgrind or similar tools if " "those do not support clone(). Valgrind 3.3.1 will just fail if " "it sees an unsupported combination of clone() flags. " "It is not recommended to use this flag w/o valgrind though it will " "work in 99% of the cases. Once valgrind is fixed, this flag will " "most likely be removed."); namespace internal { GTEST_DEFINE_string_( internal_run_death_test, "", "Indicates the file, line number, temporal index of " "the single death test to run, and a file descriptor to " "which a success code may be sent, all separated by " "the '|' characters. This flag is specified if and only if the " "current process is a sub-process launched for running a thread-safe " "death test. FOR INTERNAL USE ONLY."); } // namespace internal #if GTEST_HAS_DEATH_TEST namespace internal { // Valid only for fast death tests. Indicates the code is running in the // child process of a fast style death test. # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA static bool g_in_fast_death_test_child = false; # endif // Returns a Boolean value indicating whether the caller is currently // executing in the context of the death test child process. Tools such as // Valgrind heap checkers may need this to modify their behavior in death // tests. IMPORTANT: This is an internal utility. Using it may break the // implementation of death tests. User code MUST NOT use it. bool InDeathTestChild() { # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA // On Windows and Fuchsia, death tests are thread-safe regardless of the value // of the death_test_style flag. return !GTEST_FLAG(internal_run_death_test).empty(); # else if (GTEST_FLAG(death_test_style) == "threadsafe") return !GTEST_FLAG(internal_run_death_test).empty(); else return g_in_fast_death_test_child; #endif } } // namespace internal // ExitedWithCode constructor. ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { } // ExitedWithCode function-call operator. bool ExitedWithCode::operator()(int exit_status) const { # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return exit_status == exit_code_; # else return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; # endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA } # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // KilledBySignal constructor. KilledBySignal::KilledBySignal(int signum) : signum_(signum) { } // KilledBySignal function-call operator. bool KilledBySignal::operator()(int exit_status) const { # if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) { bool result; if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) { return result; } } # endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; } # endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA namespace internal { // Utilities needed for death tests. // Generates a textual description of a given exit code, in the format // specified by wait(2). static std::string ExitSummary(int exit_code) { Message m; # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA m << "Exited with exit status " << exit_code; # else if (WIFEXITED(exit_code)) { m << "Exited with exit status " << WEXITSTATUS(exit_code); } else if (WIFSIGNALED(exit_code)) { m << "Terminated by signal " << WTERMSIG(exit_code); } # ifdef WCOREDUMP if (WCOREDUMP(exit_code)) { m << " (core dumped)"; } # endif # endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return m.GetString(); } // Returns true if exit_status describes a process that was terminated // by a signal, or exited normally with a nonzero exit code. bool ExitedUnsuccessfully(int exit_status) { return !ExitedWithCode(0)(exit_status); } # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Generates a textual failure message when a death test finds more than // one thread running, or cannot determine the number of threads, prior // to executing the given statement. It is the responsibility of the // caller not to pass a thread_count of 1. static std::string DeathTestThreadWarning(size_t thread_count) { Message msg; msg << "Death tests use fork(), which is unsafe particularly" << " in a threaded context. For this test, " << GTEST_NAME_ << " "; if (thread_count == 0) { msg << "couldn't detect the number of threads."; } else { msg << "detected " << thread_count << " threads."; } msg << " See " "https://github.com/google/googletest/blob/master/googletest/docs/" "advanced.md#death-tests-and-threads" << " for more explanation and suggested solutions, especially if" << " this is the last message you see before your test times out."; return msg.GetString(); } # endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Flag characters for reporting a death test that did not die. static const char kDeathTestLived = 'L'; static const char kDeathTestReturned = 'R'; static const char kDeathTestThrew = 'T'; static const char kDeathTestInternalError = 'I'; #if GTEST_OS_FUCHSIA // File descriptor used for the pipe in the child process. static const int kFuchsiaReadPipeFd = 3; #endif // An enumeration describing all of the possible ways that a death test can // conclude. DIED means that the process died while executing the test // code; LIVED means that process lived beyond the end of the test code; // RETURNED means that the test statement attempted to execute a return // statement, which is not allowed; THREW means that the test statement // returned control by throwing an exception. IN_PROGRESS means the test // has not yet concluded. enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; // Routine for aborting the program which is safe to call from an // exec-style death test child process, in which case the error // message is propagated back to the parent process. Otherwise, the // message is simply printed to stderr. In either case, the program // then exits with status 1. static void DeathTestAbort(const std::string& message) { // On a POSIX system, this function may be called from a threadsafe-style // death test child process, which operates on a very small stack. Use // the heap for any additional non-minuscule memory requirements. const InternalRunDeathTestFlag* const flag = GetUnitTestImpl()->internal_run_death_test_flag(); if (flag != nullptr) { FILE* parent = posix::FDOpen(flag->write_fd(), "w"); fputc(kDeathTestInternalError, parent); fprintf(parent, "%s", message.c_str()); fflush(parent); _exit(1); } else { fprintf(stderr, "%s", message.c_str()); fflush(stderr); posix::Abort(); } } // A replacement for CHECK that calls DeathTestAbort if the assertion // fails. # define GTEST_DEATH_TEST_CHECK_(expression) \ do { \ if (!::testing::internal::IsTrue(expression)) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression); \ } \ } while (::testing::internal::AlwaysFalse()) // This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for // evaluating any system call that fulfills two conditions: it must return // -1 on failure, and set errno to EINTR when it is interrupted and // should be tried again. The macro expands to a loop that repeatedly // evaluates the expression as long as it evaluates to -1 and sets // errno to EINTR. If the expression evaluates to -1 but errno is // something other than EINTR, DeathTestAbort is called. # define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ do { \ int gtest_retval; \ do { \ gtest_retval = (expression); \ } while (gtest_retval == -1 && errno == EINTR); \ if (gtest_retval == -1) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression + " != -1"); \ } \ } while (::testing::internal::AlwaysFalse()) // Returns the message describing the last system error in errno. std::string GetLastErrnoDescription() { return errno == 0 ? "" : posix::StrError(errno); } // This is called from a death test parent process to read a failure // message from the death test child process and log it with the FATAL // severity. On Windows, the message is read from a pipe handle. On other // platforms, it is read from a file descriptor. static void FailFromInternalError(int fd) { Message error; char buffer[256]; int num_read; do { while ((num_read = posix::Read(fd, buffer, 255)) > 0) { buffer[num_read] = '\0'; error << buffer; } } while (num_read == -1 && errno == EINTR); if (num_read == 0) { GTEST_LOG_(FATAL) << error.GetString(); } else { const int last_error = errno; GTEST_LOG_(FATAL) << "Error while reading death test internal: " << GetLastErrnoDescription() << " [" << last_error << "]"; } } // Death test constructor. Increments the running death test count // for the current test. DeathTest::DeathTest() { TestInfo* const info = GetUnitTestImpl()->current_test_info(); if (info == nullptr) { DeathTestAbort("Cannot run a death test outside of a TEST or " "TEST_F construct"); } } // Creates and returns a death test by dispatching to the current // death test factory. bool DeathTest::Create(const char* statement, Matcher<const std::string&> matcher, const char* file, int line, DeathTest** test) { return GetUnitTestImpl()->death_test_factory()->Create( statement, std::move(matcher), file, line, test); } const char* DeathTest::LastMessage() { return last_death_test_message_.c_str(); } void DeathTest::set_last_death_test_message(const std::string& message) { last_death_test_message_ = message; } std::string DeathTest::last_death_test_message_; // Provides cross platform implementation for some death functionality. class DeathTestImpl : public DeathTest { protected: DeathTestImpl(const char* a_statement, Matcher<const std::string&> matcher) : statement_(a_statement), matcher_(std::move(matcher)), spawned_(false), status_(-1), outcome_(IN_PROGRESS), read_fd_(-1), write_fd_(-1) {} // read_fd_ is expected to be closed and cleared by a derived class. ~DeathTestImpl() override { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } void Abort(AbortReason reason) override; bool Passed(bool status_ok) override; const char* statement() const { return statement_; } bool spawned() const { return spawned_; } void set_spawned(bool is_spawned) { spawned_ = is_spawned; } int status() const { return status_; } void set_status(int a_status) { status_ = a_status; } DeathTestOutcome outcome() const { return outcome_; } void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; } int read_fd() const { return read_fd_; } void set_read_fd(int fd) { read_fd_ = fd; } int write_fd() const { return write_fd_; } void set_write_fd(int fd) { write_fd_ = fd; } // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void ReadAndInterpretStatusByte(); // Returns stderr output from the child process. virtual std::string GetErrorLogs(); private: // The textual content of the code this object is testing. This class // doesn't own this string and should not attempt to delete it. const char* const statement_; // A matcher that's expected to match the stderr output by the child process. Matcher<const std::string&> matcher_; // True if the death test child process has been successfully spawned. bool spawned_; // The exit status of the child process. int status_; // How the death test concluded. DeathTestOutcome outcome_; // Descriptor to the read end of the pipe to the child process. It is // always -1 in the child process. The child keeps its write end of the // pipe in write_fd_. int read_fd_; // Descriptor to the child's write end of the pipe to the parent process. // It is always -1 in the parent process. The parent keeps its end of the // pipe in read_fd_. int write_fd_; }; // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void DeathTestImpl::ReadAndInterpretStatusByte() { char flag; int bytes_read; // The read() here blocks until data is available (signifying the // failure of the death test) or until the pipe is closed (signifying // its success), so it's okay to call this in the parent before // the child process has exited. do { bytes_read = posix::Read(read_fd(), &flag, 1); } while (bytes_read == -1 && errno == EINTR); if (bytes_read == 0) { set_outcome(DIED); } else if (bytes_read == 1) { switch (flag) { case kDeathTestReturned: set_outcome(RETURNED); break; case kDeathTestThrew: set_outcome(THREW); break; case kDeathTestLived: set_outcome(LIVED); break; case kDeathTestInternalError: FailFromInternalError(read_fd()); // Does not return. break; default: GTEST_LOG_(FATAL) << "Death test child process reported " << "unexpected status byte (" << static_cast<unsigned int>(flag) << ")"; } } else { GTEST_LOG_(FATAL) << "Read from death test child process failed: " << GetLastErrnoDescription(); } GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); set_read_fd(-1); } std::string DeathTestImpl::GetErrorLogs() { return GetCapturedStderr(); } // Signals that the death test code which should have exited, didn't. // Should be called only in a death test child process. // Writes a status byte to the child's status file descriptor, then // calls _exit(1). void DeathTestImpl::Abort(AbortReason reason) { // The parent process considers the death test to be a failure if // it finds any data in our pipe. So, here we write a single flag byte // to the pipe, then exit. const char status_ch = reason == TEST_DID_NOT_DIE ? kDeathTestLived : reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned; GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); // We are leaking the descriptor here because on some platforms (i.e., // when built as Windows DLL), destructors of global objects will still // run after calling _exit(). On such systems, write_fd_ will be // indirectly closed from the destructor of UnitTestImpl, causing double // close if it is also closed here. On debug configurations, double close // may assert. As there are no in-process buffers to flush here, we are // relying on the OS to close the descriptor after the process terminates // when the destructors are not run. _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) } // Returns an indented copy of stderr output for a death test. // This makes distinguishing death test output lines from regular log lines // much easier. static ::std::string FormatDeathTestOutput(const ::std::string& output) { ::std::string ret; for (size_t at = 0; ; ) { const size_t line_end = output.find('\n', at); ret += "[ DEATH ] "; if (line_end == ::std::string::npos) { ret += output.substr(at); break; } ret += output.substr(at, line_end + 1 - at); at = line_end + 1; } return ret; } // Assesses the success or failure of a death test, using both private // members which have previously been set, and one argument: // // Private data members: // outcome: An enumeration describing how the death test // concluded: DIED, LIVED, THREW, or RETURNED. The death test // fails in the latter three cases. // status: The exit status of the child process. On *nix, it is in the // in the format specified by wait(2). On Windows, this is the // value supplied to the ExitProcess() API or a numeric code // of the exception that terminated the program. // matcher_: A matcher that's expected to match the stderr output by the child // process. // // Argument: // status_ok: true if exit_status is acceptable in the context of // this particular death test, which fails if it is false // // Returns true if and only if all of the above conditions are met. Otherwise, // the first failing condition, in the order given above, is the one that is // reported. Also sets the last death test message string. bool DeathTestImpl::Passed(bool status_ok) { if (!spawned()) return false; const std::string error_message = GetErrorLogs(); bool success = false; Message buffer; buffer << "Death test: " << statement() << "\n"; switch (outcome()) { case LIVED: buffer << " Result: failed to die.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case THREW: buffer << " Result: threw an exception.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case RETURNED: buffer << " Result: illegal return in test statement.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case DIED: if (status_ok) { if (matcher_.Matches(error_message)) { success = true; } else { std::ostringstream stream; matcher_.DescribeTo(&stream); buffer << " Result: died but not with expected error.\n" << " Expected: " << stream.str() << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } } else { buffer << " Result: died but not with expected exit code:\n" << " " << ExitSummary(status()) << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } break; case IN_PROGRESS: default: GTEST_LOG_(FATAL) << "DeathTest::Passed somehow called before conclusion of test"; } DeathTest::set_last_death_test_message(buffer.GetString()); return success; } # if GTEST_OS_WINDOWS // WindowsDeathTest implements death tests on Windows. Due to the // specifics of starting new processes on Windows, death tests there are // always threadsafe, and Google Test considers the // --gtest_death_test_style=fast setting to be equivalent to // --gtest_death_test_style=threadsafe there. // // A few implementation notes: Like the Linux version, the Windows // implementation uses pipes for child-to-parent communication. But due to // the specifics of pipes on Windows, some extra steps are required: // // 1. The parent creates a communication pipe and stores handles to both // ends of it. // 2. The parent starts the child and provides it with the information // necessary to acquire the handle to the write end of the pipe. // 3. The child acquires the write end of the pipe and signals the parent // using a Windows event. // 4. Now the parent can release the write end of the pipe on its side. If // this is done before step 3, the object's reference count goes down to // 0 and it is destroyed, preventing the child from acquiring it. The // parent now has to release it, or read operations on the read end of // the pipe will not return when the child terminates. // 5. The parent reads child's output through the pipe (outcome code and // any possible error messages) from the pipe, and its stderr and then // determines whether to fail the test. // // Note: to distinguish Win32 API calls from the local method and function // calls, the former are explicitly resolved in the global namespace. // class WindowsDeathTest : public DeathTestImpl { public: WindowsDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : DeathTestImpl(a_statement, std::move(matcher)), file_(file), line_(line) {} // All of these virtual functions are inherited from DeathTest. virtual int Wait(); virtual TestRole AssumeRole(); private: // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; // Handle to the write end of the pipe to the child process. AutoHandle write_handle_; // Child process handle. AutoHandle child_handle_; // Event the child process uses to signal the parent that it has // acquired the handle to the write end of the pipe. After seeing this // event the parent can release its own handles to make sure its // ReadFile() calls return when the child terminates. AutoHandle event_handle_; }; // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int WindowsDeathTest::Wait() { if (!spawned()) return 0; // Wait until the child either signals that it has acquired the write end // of the pipe or it dies. const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() }; switch (::WaitForMultipleObjects(2, wait_handles, FALSE, // Waits for any of the handles. INFINITE)) { case WAIT_OBJECT_0: case WAIT_OBJECT_0 + 1: break; default: GTEST_DEATH_TEST_CHECK_(false); // Should not get here. } // The child has acquired the write end of the pipe or exited. // We release the handle on our side and continue. write_handle_.Reset(); event_handle_.Reset(); ReadAndInterpretStatusByte(); // Waits for the child process to exit if it haven't already. This // returns immediately if the child has already exited, regardless of // whether previous calls to WaitForMultipleObjects synchronized on this // handle or not. GTEST_DEATH_TEST_CHECK_( WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(), INFINITE)); DWORD status_code; GTEST_DEATH_TEST_CHECK_( ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE); child_handle_.Reset(); set_status(static_cast<int>(status_code)); return status(); } // The AssumeRole process for a Windows death test. It creates a child // process with the same executable as the current process to run the // death test. The child process is given the --gtest_filter and // --gtest_internal_run_death_test flags such that it knows to run the // current death test only. DeathTest::TestRole WindowsDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { // ParseInternalRunDeathTestFlag() has performed all the necessary // processing. set_write_fd(flag->write_fd()); return EXECUTE_TEST; } // WindowsDeathTest uses an anonymous pipe to communicate results of // a death test. SECURITY_ATTRIBUTES handles_are_inheritable = {sizeof(SECURITY_ATTRIBUTES), nullptr, TRUE}; HANDLE read_handle, write_handle; GTEST_DEATH_TEST_CHECK_( ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable, 0) // Default buffer size. != FALSE); set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle), O_RDONLY)); write_handle_.Reset(write_handle); event_handle_.Reset(::CreateEvent( &handles_are_inheritable, TRUE, // The event will automatically reset to non-signaled state. FALSE, // The initial state is non-signalled. nullptr)); // The even is unnamed. GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) + // size_t has the same width as pointers on both 32-bit and 64-bit // Windows platforms. // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. "|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) + "|" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get())); char executable_path[_MAX_PATH + 1]; // NOLINT GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(nullptr, executable_path, _MAX_PATH)); std::string command_line = std::string(::GetCommandLineA()) + " " + filter_flag + " \"" + internal_flag + "\""; DeathTest::set_last_death_test_message(""); CaptureStderr(); // Flush the log buffers since the log streams are shared with the child. FlushInfoLog(); // The child process will share the standard handles with the parent. STARTUPINFOA startup_info; memset(&startup_info, 0, sizeof(STARTUPINFO)); startup_info.dwFlags = STARTF_USESTDHANDLES; startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); PROCESS_INFORMATION process_info; GTEST_DEATH_TEST_CHECK_( ::CreateProcessA( executable_path, const_cast<char*>(command_line.c_str()), nullptr, // Retuned process handle is not inheritable. nullptr, // Retuned thread handle is not inheritable. TRUE, // Child inherits all inheritable handles (for write_handle_). 0x0, // Default creation flags. nullptr, // Inherit the parent's environment. UnitTest::GetInstance()->original_working_dir(), &startup_info, &process_info) != FALSE); child_handle_.Reset(process_info.hProcess); ::CloseHandle(process_info.hThread); set_spawned(true); return OVERSEE_TEST; } # elif GTEST_OS_FUCHSIA class FuchsiaDeathTest : public DeathTestImpl { public: FuchsiaDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : DeathTestImpl(a_statement, std::move(matcher)), file_(file), line_(line) {} // All of these virtual functions are inherited from DeathTest. int Wait() override; TestRole AssumeRole() override; std::string GetErrorLogs() override; private: // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; // The stderr data captured by the child process. std::string captured_stderr_; zx::process child_process_; zx::channel exception_channel_; zx::socket stderr_socket_; }; // Utility class for accumulating command-line arguments. class Arguments { public: Arguments() { args_.push_back(nullptr); } ~Arguments() { for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); ++i) { free(*i); } } void AddArgument(const char* argument) { args_.insert(args_.end() - 1, posix::StrDup(argument)); } template <typename Str> void AddArguments(const ::std::vector<Str>& arguments) { for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) { args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); } } char* const* Argv() { return &args_[0]; } int size() { return args_.size() - 1; } private: std::vector<char*> args_; }; // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int FuchsiaDeathTest::Wait() { const int kProcessKey = 0; const int kSocketKey = 1; const int kExceptionKey = 2; if (!spawned()) return 0; // Create a port to wait for socket/task/exception events. zx_status_t status_zx; zx::port port; status_zx = zx::port::create(0, &port); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); // Register to wait for the child process to terminate. status_zx = child_process_.wait_async( port, kProcessKey, ZX_PROCESS_TERMINATED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); // Register to wait for the socket to be readable or closed. status_zx = stderr_socket_.wait_async( port, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); // Register to wait for an exception. status_zx = exception_channel_.wait_async( port, kExceptionKey, ZX_CHANNEL_READABLE, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); bool process_terminated = false; bool socket_closed = false; do { zx_port_packet_t packet = {}; status_zx = port.wait(zx::time::infinite(), &packet); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); if (packet.key == kExceptionKey) { // Process encountered an exception. Kill it directly rather than // letting other handlers process the event. We will get a kProcessKey // event when the process actually terminates. status_zx = child_process_.kill(); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); } else if (packet.key == kProcessKey) { // Process terminated. GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_PROCESS_TERMINATED); process_terminated = true; } else if (packet.key == kSocketKey) { GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); if (packet.signal.observed & ZX_SOCKET_READABLE) { // Read data from the socket. constexpr size_t kBufferSize = 1024; do { size_t old_length = captured_stderr_.length(); size_t bytes_read = 0; captured_stderr_.resize(old_length + kBufferSize); status_zx = stderr_socket_.read( 0, &captured_stderr_.front() + old_length, kBufferSize, &bytes_read); captured_stderr_.resize(old_length + bytes_read); } while (status_zx == ZX_OK); if (status_zx == ZX_ERR_PEER_CLOSED) { socket_closed = true; } else { GTEST_DEATH_TEST_CHECK_(status_zx == ZX_ERR_SHOULD_WAIT); status_zx = stderr_socket_.wait_async( port, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); } } else { GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_SOCKET_PEER_CLOSED); socket_closed = true; } } } while (!process_terminated && !socket_closed); ReadAndInterpretStatusByte(); zx_info_process_t buffer; status_zx = child_process_.get_info( ZX_INFO_PROCESS, &buffer, sizeof(buffer), nullptr, nullptr); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); GTEST_DEATH_TEST_CHECK_(buffer.exited); set_status(buffer.return_code); return status(); } // The AssumeRole process for a Fuchsia death test. It creates a child // process with the same executable as the current process to run the // death test. The child process is given the --gtest_filter and // --gtest_internal_run_death_test flags such that it knows to run the // current death test only. DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { // ParseInternalRunDeathTestFlag() has performed all the necessary // processing. set_write_fd(kFuchsiaReadPipeFd); return EXECUTE_TEST; } // Flush the log buffers since the log streams are shared with the child. FlushInfoLog(); // Build the child process command line. const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index); Arguments args; args.AddArguments(GetInjectableArgvs()); args.AddArgument(filter_flag.c_str()); args.AddArgument(internal_flag.c_str()); // Build the pipe for communication with the child. zx_status_t status; zx_handle_t child_pipe_handle; int child_pipe_fd; status = fdio_pipe_half(&child_pipe_fd, &child_pipe_handle); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); set_read_fd(child_pipe_fd); // Set the pipe handle for the child. fdio_spawn_action_t spawn_actions[2] = {}; fdio_spawn_action_t* add_handle_action = &spawn_actions[0]; add_handle_action->action = FDIO_SPAWN_ACTION_ADD_HANDLE; add_handle_action->h.id = PA_HND(PA_FD, kFuchsiaReadPipeFd); add_handle_action->h.handle = child_pipe_handle; // Create a socket pair will be used to receive the child process' stderr. zx::socket stderr_producer_socket; status = zx::socket::create(0, &stderr_producer_socket, &stderr_socket_); GTEST_DEATH_TEST_CHECK_(status >= 0); int stderr_producer_fd = -1; status = fdio_fd_create(stderr_producer_socket.release(), &stderr_producer_fd); GTEST_DEATH_TEST_CHECK_(status >= 0); // Make the stderr socket nonblocking. GTEST_DEATH_TEST_CHECK_(fcntl(stderr_producer_fd, F_SETFL, 0) == 0); fdio_spawn_action_t* add_stderr_action = &spawn_actions[1]; add_stderr_action->action = FDIO_SPAWN_ACTION_CLONE_FD; add_stderr_action->fd.local_fd = stderr_producer_fd; add_stderr_action->fd.target_fd = STDERR_FILENO; // Create a child job. zx_handle_t child_job = ZX_HANDLE_INVALID; status = zx_job_create(zx_job_default(), 0, & child_job); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); zx_policy_basic_t policy; policy.condition = ZX_POL_NEW_ANY; policy.policy = ZX_POL_ACTION_ALLOW; status = zx_job_set_policy( child_job, ZX_JOB_POL_RELATIVE, ZX_JOB_POL_BASIC, &policy, 1); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Create an exception channel attached to the |child_job|, to allow // us to suppress the system default exception handler from firing. status = zx_task_create_exception_channel( child_job, 0, exception_channel_.reset_and_get_address()); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Spawn the child process. status = fdio_spawn_etc( child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0], args.Argv(), nullptr, 2, spawn_actions, child_process_.reset_and_get_address(), nullptr); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); set_spawned(true); return OVERSEE_TEST; } std::string FuchsiaDeathTest::GetErrorLogs() { return captured_stderr_; } #else // We are neither on Windows, nor on Fuchsia. // ForkingDeathTest provides implementations for most of the abstract // methods of the DeathTest interface. Only the AssumeRole method is // left undefined. class ForkingDeathTest : public DeathTestImpl { public: ForkingDeathTest(const char* statement, Matcher<const std::string&> matcher); // All of these virtual functions are inherited from DeathTest. int Wait() override; protected: void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } private: // PID of child process during death test; 0 in the child process itself. pid_t child_pid_; }; // Constructs a ForkingDeathTest. ForkingDeathTest::ForkingDeathTest(const char* a_statement, Matcher<const std::string&> matcher) : DeathTestImpl(a_statement, std::move(matcher)), child_pid_(-1) {} // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int ForkingDeathTest::Wait() { if (!spawned()) return 0; ReadAndInterpretStatusByte(); int status_value; GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0)); set_status(status_value); return status_value; } // A concrete death test class that forks, then immediately runs the test // in the child process. class NoExecDeathTest : public ForkingDeathTest { public: NoExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher) : ForkingDeathTest(a_statement, std::move(matcher)) {} TestRole AssumeRole() override; }; // The AssumeRole process for a fork-and-run death test. It implements a // straightforward fork, with a simple pipe to transmit the status byte. DeathTest::TestRole NoExecDeathTest::AssumeRole() { const size_t thread_count = GetThreadCount(); if (thread_count != 1) { GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count); } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); DeathTest::set_last_death_test_message(""); CaptureStderr(); // When we fork the process below, the log file buffers are copied, but the // file descriptors are shared. We flush all log files here so that closing // the file descriptors in the child process doesn't throw off the // synchronization between descriptors and buffers in the parent process. // This is as close to the fork as possible to avoid a race condition in case // there are multiple threads running before the death test, and another // thread writes to the log file. FlushInfoLog(); const pid_t child_pid = fork(); GTEST_DEATH_TEST_CHECK_(child_pid != -1); set_child_pid(child_pid); if (child_pid == 0) { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); set_write_fd(pipe_fd[1]); // Redirects all logging to stderr in the child process to prevent // concurrent writes to the log files. We capture stderr in the parent // process and append the child process' output to a log. LogToStderr(); // Event forwarding to the listeners of event listener API mush be shut // down in death test subprocesses. GetUnitTestImpl()->listeners()->SuppressEventForwarding(); g_in_fast_death_test_child = true; return EXECUTE_TEST; } else { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } } // A concrete death test class that forks and re-executes the main // program from the beginning, with command-line flags set that cause // only this specific death test to be run. class ExecDeathTest : public ForkingDeathTest { public: ExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : ForkingDeathTest(a_statement, std::move(matcher)), file_(file), line_(line) {} TestRole AssumeRole() override; private: static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() { ::std::vector<std::string> args = GetInjectableArgvs(); # if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) ::std::vector<std::string> extra_args = GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_(); args.insert(args.end(), extra_args.begin(), extra_args.end()); # endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) return args; } // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; }; // Utility class for accumulating command-line arguments. class Arguments { public: Arguments() { args_.push_back(nullptr); } ~Arguments() { for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); ++i) { free(*i); } } void AddArgument(const char* argument) { args_.insert(args_.end() - 1, posix::StrDup(argument)); } template <typename Str> void AddArguments(const ::std::vector<Str>& arguments) { for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) { args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); } } char* const* Argv() { return &args_[0]; } private: std::vector<char*> args_; }; // A struct that encompasses the arguments to the child process of a // threadsafe-style death test process. struct ExecDeathTestArgs { char* const* argv; // Command-line arguments for the child's call to exec int close_fd; // File descriptor to close; the read end of a pipe }; # if GTEST_OS_MAC inline char** GetEnviron() { // When Google Test is built as a framework on MacOS X, the environ variable // is unavailable. Apple's documentation (man environ) recommends using // _NSGetEnviron() instead. return *_NSGetEnviron(); } # else // Some POSIX platforms expect you to declare environ. extern "C" makes // it reside in the global namespace. extern "C" char** environ; inline char** GetEnviron() { return environ; } # endif // GTEST_OS_MAC # if !GTEST_OS_QNX // The main function for a threadsafe-style death test child process. // This function is called in a clone()-ed process and thus must avoid // any potentially unsafe operations like malloc or libc functions. static int ExecDeathTestChildMain(void* child_arg) { ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } // We can safely call execve() as it's a direct system call. We // cannot use execvp() as it's a libc function and thus potentially // unsafe. Since execve() doesn't search the PATH, the user must // invoke the test program via a valid path that contains at least // one path separator. execve(args->argv[0], args->argv, GetEnviron()); DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " + original_dir + " failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } # endif // !GTEST_OS_QNX # if GTEST_HAS_CLONE // Two utility routines that together determine the direction the stack // grows. // This could be accomplished more elegantly by a single recursive // function, but we want to guard against the unlikely possibility of // a smart compiler optimizing the recursion away. // // GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining // StackLowerThanAddress into StackGrowsDown, which then doesn't give // correct answer. static void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; // HWAddressSanitizer add a random tag to the MSB of the local variable address, // making comparison result unpredictable. GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static void StackLowerThanAddress(const void* ptr, bool* result) { int dummy; *result = (&dummy < ptr); } // Make sure AddressSanitizer does not tamper with the stack here. GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } # endif // GTEST_HAS_CLONE // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The // implementation uses fork(2) + exec. On systems where clone(2) is // available, it is used instead, being slightly more thread-safe. On QNX, // fork supports only single-threaded environments, so this function uses // spawn(2) there instead. The function dies with an error message if // anything goes wrong. static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { ExecDeathTestArgs args = { argv, close_fd }; pid_t child_pid = -1; # if GTEST_OS_QNX // Obtains the current directory and sets it to be closed in the child // process. const int cwd_fd = open(".", O_RDONLY); GTEST_DEATH_TEST_CHECK_(cwd_fd != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } int fd_flags; // Set close_fd to be closed after spawn. GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD)); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD, fd_flags | FD_CLOEXEC)); struct inheritance inherit = {0}; // spawn is a system call. child_pid = spawn(args.argv[0], 0, nullptr, &inherit, args.argv, GetEnviron()); // Restores the current working directory. GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); # else // GTEST_OS_QNX # if GTEST_OS_LINUX // When a SIGPROF signal is received while fork() or clone() are executing, // the process may hang. To avoid this, we ignore SIGPROF here and re-enable // it after the call to fork()/clone() is complete. struct sigaction saved_sigprof_action; struct sigaction ignore_sigprof_action; memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action)); sigemptyset(&ignore_sigprof_action.sa_mask); ignore_sigprof_action.sa_handler = SIG_IGN; GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction( SIGPROF, &ignore_sigprof_action, &saved_sigprof_action)); # endif // GTEST_OS_LINUX # if GTEST_HAS_CLONE const bool use_fork = GTEST_FLAG(death_test_use_fork); if (!use_fork) { static const bool stack_grows_down = StackGrowsDown(); const auto stack_size = static_cast<size_t>(getpagesize()); // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED); // Maximum stack alignment in bytes: For a downward-growing stack, this // amount is subtracted from size of the stack space to get an address // that is within the stack space and is aligned on all systems we care // about. As far as I know there is no ABI with stack alignment greater // than 64. We assume stack and stack_size already have alignment of // kMaxStackAlignment. const size_t kMaxStackAlignment = 64; void* const stack_top = static_cast<char*>(stack) + (stack_grows_down ? stack_size - kMaxStackAlignment : 0); GTEST_DEATH_TEST_CHECK_( static_cast<size_t>(stack_size) > kMaxStackAlignment && reinterpret_cast<uintptr_t>(stack_top) % kMaxStackAlignment == 0); child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args); GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1); } # else const bool use_fork = true; # endif // GTEST_HAS_CLONE if (use_fork && (child_pid = fork()) == 0) { ExecDeathTestChildMain(&args); _exit(0); } # endif // GTEST_OS_QNX # if GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_SYSCALL_( sigaction(SIGPROF, &saved_sigprof_action, nullptr)); # endif // GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_(child_pid != -1); return child_pid; } // The AssumeRole process for a fork-and-exec death test. It re-executes the // main program from the beginning, setting the --gtest_filter // and --gtest_internal_run_death_test flags to cause only the current // death test to be re-run. DeathTest::TestRole ExecDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { set_write_fd(flag->write_fd()); return EXECUTE_TEST; } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); // Clear the close-on-exec flag on the write end of the pipe, lest // it be closed when the child process does an exec: GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(pipe_fd[1]); Arguments args; args.AddArguments(GetArgvsForDeathTestChildProcess()); args.AddArgument(filter_flag.c_str()); args.AddArgument(internal_flag.c_str()); DeathTest::set_last_death_test_message(""); CaptureStderr(); // See the comment in NoExecDeathTest::AssumeRole for why the next line // is necessary. FlushInfoLog(); const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_child_pid(child_pid); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } # endif // !GTEST_OS_WINDOWS // Creates a concrete DeathTest-derived class that depends on the // --gtest_death_test_style flag, and sets the pointer pointed to // by the "test" argument to its address. If the test should be // skipped, sets that pointer to NULL. Returns true, unless the // flag is set to an invalid value. bool DefaultDeathTestFactory::Create(const char* statement, Matcher<const std::string&> matcher, const char* file, int line, DeathTest** test) { UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const int death_test_index = impl->current_test_info() ->increment_death_test_count(); if (flag != nullptr) { if (death_test_index > flag->index()) { DeathTest::set_last_death_test_message( "Death test count (" + StreamableToString(death_test_index) + ") somehow exceeded expected maximum (" + StreamableToString(flag->index()) + ")"); return false; } if (!(flag->file() == file && flag->line() == line && flag->index() == death_test_index)) { *test = nullptr; return true; } } # if GTEST_OS_WINDOWS if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new WindowsDeathTest(statement, std::move(matcher), file, line); } # elif GTEST_OS_FUCHSIA if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new FuchsiaDeathTest(statement, std::move(matcher), file, line); } # else if (GTEST_FLAG(death_test_style) == "threadsafe") { *test = new ExecDeathTest(statement, std::move(matcher), file, line); } else if (GTEST_FLAG(death_test_style) == "fast") { *test = new NoExecDeathTest(statement, std::move(matcher)); } # endif // GTEST_OS_WINDOWS else { // NOLINT - this is more readable than unbalanced brackets inside #if. DeathTest::set_last_death_test_message( "Unknown death test style \"" + GTEST_FLAG(death_test_style) + "\" encountered"); return false; } return true; } # if GTEST_OS_WINDOWS // Recreates the pipe and event handles from the provided parameters, // signals the event, and returns a file descriptor wrapped around the pipe // handle. This function is called in the child process only. static int GetStatusFileDescriptor(unsigned int parent_process_id, size_t write_handle_as_size_t, size_t event_handle_as_size_t) { AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, // Non-inheritable. parent_process_id)); if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) { DeathTestAbort("Unable to open parent process " + StreamableToString(parent_process_id)); } GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); const HANDLE write_handle = reinterpret_cast<HANDLE>(write_handle_as_size_t); HANDLE dup_write_handle; // The newly initialized handle is accessible only in the parent // process. To obtain one accessible within the child, we need to use // DuplicateHandle. if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, ::GetCurrentProcess(), &dup_write_handle, 0x0, // Requested privileges ignored since // DUPLICATE_SAME_ACCESS is used. FALSE, // Request non-inheritable handler. DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the pipe handle " + StreamableToString(write_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t); HANDLE dup_event_handle; if (!::DuplicateHandle(parent_process_handle.Get(), event_handle, ::GetCurrentProcess(), &dup_event_handle, 0x0, FALSE, DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the event handle " + StreamableToString(event_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const int write_fd = ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND); if (write_fd == -1) { DeathTestAbort("Unable to convert pipe handle " + StreamableToString(write_handle_as_size_t) + " to a file descriptor"); } // Signals the parent that the write end of the pipe has been acquired // so the parent can release its own write end. ::SetEvent(dup_event_handle); return write_fd; } # endif // GTEST_OS_WINDOWS // Returns a newly created InternalRunDeathTestFlag object with fields // initialized from the GTEST_FLAG(internal_run_death_test) flag if // the flag is specified; otherwise returns NULL. InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { if (GTEST_FLAG(internal_run_death_test) == "") return nullptr; // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we // can use it here. int line = -1; int index = -1; ::std::vector< ::std::string> fields; SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields); int write_fd = -1; # if GTEST_OS_WINDOWS unsigned int parent_process_id = 0; size_t write_handle_as_size_t = 0; size_t event_handle_as_size_t = 0; if (fields.size() != 6 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &parent_process_id) || !ParseNaturalNumber(fields[4], &write_handle_as_size_t) || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t, event_handle_as_size_t); # elif GTEST_OS_FUCHSIA if (fields.size() != 3 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } # else if (fields.size() != 4 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &write_fd)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } # endif // GTEST_OS_WINDOWS return new InternalRunDeathTestFlag(fields[0], line, index, write_fd); } } // namespace internal #endif // GTEST_HAS_DEATH_TEST } // namespace testing
[ "rafael.madureira.santos@gmail.com" ]
rafael.madureira.santos@gmail.com
e5ffa7dfed0312035fc9dd42a983b72834e88f12
9177984cb1cd5843df94a93846367db5dd45daf0
/src/cs/geolib/csTimeStretch.cc
f3b77bc2fc8a58eb241889f46cce7bf58aed1ba2
[]
no_license
fccoguz/OpenSeaSeis
001f8a9d4258ce033ad5e2fa27f719c1f6a5d0a8
eb09a7ed115eaff4b055df25a60e975650635cda
refs/heads/master
2023-03-18T20:11:24.133298
2020-02-18T15:20:58
2020-02-18T15:20:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,380
cc
/* Copyright (c) Colorado School of Mines, 2013.*/ /* All rights reserved. */ #include <cmath> #include <cstring> #include "csTimeStretch.h" #include "csInterpolation.h" #include "geolib_methods.h" #include "csException.h" #include <iostream> #include <cstdio> #include <cstdlib> using namespace cseis_geolib; csTimeStretch::csTimeStretch( double sampleInt_ms, int numSamples ) { init( sampleInt_ms, numSamples, csTimeStretch::SAMPLE_INTERPOL_SINC ); } csTimeStretch::csTimeStretch( double sampleInt_ms, int numSamples, int methodSampleInterpolation ) { init( sampleInt_ms, numSamples, methodSampleInterpolation ); } void csTimeStretch::init( double sampleInt_ms, int numSamples, int methodSampleInterpolation ) { myIsBottomStretch = false; myLayerInterpolationMethod = csTimeStretch::LAYER_INTERPOL_LIN; mySampleInt = sampleInt_ms; myNumSamples = numSamples; myTimeOfLastSample = (myNumSamples-1)*mySampleInt; mySampleInterpolationMethod = methodSampleInterpolation; myIndexBufferOut = NULL; myTimeDepthFunc = NULL; myInterpol_timeDepthConversion = NULL; if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_SINC ) { mySampleInterpolation = new csInterpolation( numSamples, (float)sampleInt_ms ); } else { mySampleInterpolation = NULL; } } csTimeStretch::~csTimeStretch() { if( mySampleInterpolation != NULL ) { delete mySampleInterpolation; mySampleInterpolation = NULL; } if( myIndexBufferOut != NULL ) { delete [] myIndexBufferOut; myIndexBufferOut = NULL; } if( myTimeDepthFunc != NULL ) { delete [] myTimeDepthFunc; myTimeDepthFunc = NULL; } if( myInterpol_timeDepthConversion != NULL ) { delete myInterpol_timeDepthConversion; myInterpol_timeDepthConversion = NULL; } } void csTimeStretch::setLayerInterpolationMethod( int method ) { myLayerInterpolationMethod = method; } //-------------------------------------------------------------------- // // void csTimeStretch::applyStretchFunction( float const* samplesIn, float const* tIn_ms, float const* stretch_ms, int numTimes, float* samplesOut ) { int numLayers = numTimes - 1; float* tOut_ms = new float[numTimes]; tOut_ms[0] = tIn_ms[0]; double stretchSumDbl = 0.0; for( int ilay = 0; ilay < numLayers; ilay++ ) { stretchSumDbl += (double)stretch_ms[ilay]; tOut_ms[ilay+1] = tIn_ms[ilay+1] + (float)stretchSumDbl; } // for( int ilay = 0; ilay < numLayers+1; ilay++ ) { // fprintf(stderr,"STRETCH %.4f %.4f\n", tIn_ms[ilay], tOut_ms[ilay]); // } applyTimeInterval( samplesIn, tIn_ms, tOut_ms, numTimes, samplesOut ); delete [] tOut_ms; } void csTimeStretch::applyTimeInterval( float const* samplesIn, float const* tIn, float const* tOut, int numTimes, float* samplesOut ) { int numLayers = numTimes - 1; int ilay = 0; // Traces always start at time = 0.0. First layer to stretch may start further down. If that is the case, don't stretch the top, just copy. float tTopIn = 0.0; float tTopOut = 0.0; float tBotIn = tIn[ilay]; float tBotOut = tOut[ilay]; float dtIn = tBotIn - tTopIn; // Input layer thickness in [ms] float dtOut = tBotOut - tTopOut; // Output layer thickness in [ms] float timeLast = (float)((myNumSamples-1) * mySampleInt); // fprintf(stdout,"TIMEIO START %f %f %f %f %d\n", tBotIn, tBotOut,dtIn,dtOut,ilay); for( int isamp = 0; isamp < myNumSamples; isamp++ ) { float timeOut = (float)(isamp * mySampleInt); float timeIn = timeOut; while( ilay <= numLayers && timeOut > tBotOut ) { ilay += 1; tTopIn = tBotIn; tTopOut = tBotOut; if( ilay <= numLayers ) { tBotIn = tIn[ilay]; tBotOut = tOut[ilay]; dtIn = tBotIn - tTopIn; // Input layer thickness in [ms] dtOut = tBotOut - tTopOut; // Output layer thickness in [ms] } else { // For bottom of data beyond bottom of last layer: Make stretch ratio = dtIN/dtOut = 1.0 = no stretching, just static shift if( !myIsBottomStretch ) { dtOut = dtIn; } // ..otherwise, keep stretch factor from last specified layer } } if( dtOut != 0.0 ) { timeIn = tTopIn + (dtIn/dtOut) * ( timeOut - tTopOut ); if( timeIn < 0.0 ) timeIn = 0.0; else if( timeIn > timeLast ) timeIn = timeLast; } // fprintf(stdout,"TIMEIO %f %f %f %f %d %f %f\n", timeIn, timeOut,dtIn,dtOut,ilay,tBotIn,tBotOut); if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_SINC ) { samplesOut[isamp] = mySampleInterpolation->valueAt( timeIn, samplesIn ); } else if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_QUAD ) { samplesOut[isamp] = getQuadAmplitudeAtSample( samplesIn, timeIn/mySampleInt, myNumSamples ); } else { samplesOut[isamp] = getLinAmplitudeAtSample( samplesIn, timeIn/mySampleInt, myNumSamples ); } } } //void csTimeStretch::applyDepthTimeConversion( float* samplesInOut, float const* velFunc, float sampleInt_velFunc_m, int numSamp_velFunc, float sampleInt_out ) { void csTimeStretch::initialize_timeDepthConversion( int numSamplesOut, float sampleIntOut ) { if( myIndexBufferOut != NULL ) { delete [] myIndexBufferOut; } if( myTimeDepthFunc != NULL ) { delete [] myTimeDepthFunc; } myNumSamplesOut = numSamplesOut; mySampleIntOut = sampleIntOut; myIndexBufferOut = new float[myNumSamplesOut]; myTimeDepthFunc = new float[myNumSamplesOut]; if( myInterpol_timeDepthConversion != NULL ) { delete myInterpol_timeDepthConversion; } myInterpol_timeDepthConversion = new csInterpolation( myNumSamples, csInterpolation::METHOD_SINC, mySampleInt ); } void csTimeStretch::apply_timeDepthConversion( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut, bool isTime2Depth ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::apply_timeDepthConversion(%d):: Function not initialized. This is a bug in the calling function", isTime2Depth) ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); if( isTime2Depth ) { for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { float time = interpol.valueAt( isampOut*mySampleIntOut, depthTimeFunc ); myIndexBufferOut[isampOut] = time/mySampleInt; } } else { interpol.timeAt_lin( depthTimeFunc, mySampleIntOut, myNumSamplesOut, myTimeDepthFunc ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { myIndexBufferOut[isampOut] = myTimeDepthFunc[isampOut]/mySampleInt; } } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } /* void csTimeStretch::convert_depth2time( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::convert_depth2time:: Function not initialized. This is a bug in the calling function") ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol_timeDepth( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); interpol_timeDepth.timeAt_lin( depthTimeFunc, mySampleIntOut, myNumSamplesOut, myTimeDepthFunc ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { myIndexBufferOut[isampOut] = myTimeDepthFunc[isampOut]/mySampleInt; } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } void csTimeStretch::convert_time2depth( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::convert_time2depth:: Function not initialized. This is a bug in the calling function") ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol_depthTime( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { float time = interpol_depthTime.valueAt( isampOut*mySampleIntOut, depthTimeFunc ); myIndexBufferOut[isampOut] = time/mySampleInt; } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } */
[ "john.19071969@gmail.com" ]
john.19071969@gmail.com
acb71b1d30c41624b4d569aa43e55dd99ea019f3
7a433f33264d0ad90c14254797a58649c012ce0d
/25.1/p11361/p11361/main.cpp
1cfc9c66fe2ba548190e8e7dc5181445fcc4b76b
[ "Apache-2.0" ]
permissive
Qvocha/Grisha
dc1a2d797bbdfe59b01abe03565cd483599148c0
f7a8ce32c3abe5f57c00bdef28c19bf62d1fee28
refs/heads/master
2020-06-09T22:29:17.639576
2019-06-24T15:42:23
2019-06-24T15:42:23
193,518,874
0
0
null
null
null
null
UTF-8
C++
false
false
110
cpp
#include <iostream> #include "task25.h" using namespace std; int main() { fipi2018(); return 0; }
[ "pineappletoe@gmail.com" ]
pineappletoe@gmail.com
dc020678e8d813dc327663a5419e1e27c9740900
75596988cf42a9cf443cdcc77feaa056f29181e6
/ASTAR/Classes/SceneMapWalk.cpp
60e16bc66329281ff0c5c16512c825185b99adaf
[]
no_license
ndlwill1020/AStar
67882cb0f41f605c6a1e41140ee7186b65cf55ca
5dc09943d6be902dfa2b30e3a8d59b1ed873e38d
refs/heads/master
2021-01-19T04:02:12.303495
2016-07-11T04:05:50
2016-07-11T04:05:50
47,319,863
1
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
#include "SceneMapWalk.h" #include "LayerHudControl.h" bool SceneMapWalk::init(){ if(!Scene::init()){ return false; } p_LayerMapWalk=LayerMapWalk::create(); //log("LayerMapWalk->size:%f:%f",p_LayerMapWalk->getContentSize().width,p_LayerMapWalk->getContentSize().height); this->addChild(p_LayerMapWalk); auto p_LayerHudControl=LayerHudControl::create(); //log("LayerHudControl->size:%f:%f",p_LayerHudControl->getContentSize().width,p_LayerHudControl->getContentSize().height); this->addChild(p_LayerHudControl); p_LayerHudControl->p_LayerMapWalk=p_LayerMapWalk; p_LayerMapWalk->m_LayerHudControl=p_LayerHudControl; return true; }
[ "ndl_mac1020@126.com" ]
ndl_mac1020@126.com
05abe423e121cf25f5c743a9703a7d0adba5c41c
3bbad6f1f610ad8cc4edec00aae854f27e9abf73
/cpp/扩展欧几里得算法/扩展欧几里得算法/main.cpp
3b59ef57402de92dfa2b8ede859c9957e36eaffd
[]
no_license
torresng/Algorithms_practice
c765e6e60c4e2a84486a1a88fb6d42503629876a
dae0eaa1dd0663fb428a0002dc5fa8528ff4204f
refs/heads/master
2021-08-07T08:57:16.690536
2020-04-15T06:24:12
2020-04-15T06:24:12
152,349,445
0
0
null
null
null
null
UTF-8
C++
false
false
422
cpp
#include <iostream> using namespace std; int exgcd(int a, int b, int &x, int &y) { if (!b) { x = 1, y = 0; return a; } int d = exgcd(b, a % b, y, x); y -= a / b * x; return d; } int main() { int n; scanf("%d", &n); while (n--) { int a, b, x, y; scanf("%d%d", &a, &b); exgcd(a, b, x, y); printf("%d %d\n", x, y); } return 0; }
[ "torresng2684cte@gmail.com" ]
torresng2684cte@gmail.com
3d711433719fb800b61d79e3634d870eb56683b5
5884451df714e76b8725fa2c68fdce8c782b9bf0
/libcore/src/network/Frame.cpp
92a40f6b0c4369545e3ad843ff1c306c1ec119c6
[ "BSD-3-Clause" ]
permissive
khoshino/sirikata
933a0736161ae561be7c0d9ab306f222d8663a02
f4c1838a4cf7f3aa96752f4c3001c5190908c245
refs/heads/master
2021-01-21T00:25:53.201796
2011-06-22T20:45:05
2011-06-22T20:58:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,079
cpp
/* Sirikata * Frame.cpp * * Copyright (c) 2010, Ewen Cheslack-Postava. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Sirikata nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sirikata/core/util/Standard.hh> #include <sirikata/core/network/Frame.hpp> // htonl, ntohl #include <sirikata/core/network/Asio.hpp> namespace Sirikata { namespace Network { /** Writes the data to the stream as a message. */ std::string Frame::write(const void* data, uint32 len) { std::string result(len + sizeof(uint32), '\0'); uint32 encoded_len = htonl(len); memcpy(&(result[0]), &encoded_len, sizeof(uint32)); memcpy(&(result[sizeof(uint32)]), data, len); return result; } std::string Frame::write(const std::string& data) { return Frame::write(&(data[0]), data.size()); } std::string Frame::parse(std::string& data) { std::string result; if (data.size() < sizeof(uint32)) return result; // Try to parse the length uint32 len; memcpy(&len, &(data[0]), sizeof(uint32)); len = ntohl(len); // Make sure we have the full packet if (data.size() < sizeof(uint32) + len) return result; // Extract it result = data.substr(sizeof(uint32), len); // Remove it data = data.substr(sizeof(uint32) + len); return result; } std::string Frame::parse(std::stringstream& data) { std::string so_far = data.str(); std::string result = parse(so_far); if (!result.empty()) { // Read off the right amount of data from the stringstream data.ignore( sizeof(uint32) + result.size() ); } return result; } } // namespace Network } // namespace Frame
[ "ewencp@cs.stanford.edu" ]
ewencp@cs.stanford.edu
e3b1a27d67e621f8ee6951038f95d5a57c408e16
76fe0a0404ca1d71779fc6c1122b87e0d7a7aa1b
/Treinos equipe/xv de piracikobus/2018/10-26 2017 X Samara/h.cpp
eedda1e77f17931dd15d2b513306f0f900131b8c
[]
no_license
vitorguidi/Competitive-Programming
905dd835671275284418c5885a4a1fae2160f451
823a9299dce7b7f662ea741f31b4687f854bb963
refs/heads/master
2021-06-25T06:58:53.670233
2020-12-19T16:53:15
2020-12-19T16:53:15
133,260,248
3
0
null
2018-05-13T17:46:43
2018-05-13T17:40:24
null
UTF-8
C++
false
false
1,900
cpp
#include "bits/stdc++.h" using namespace std; #define pb push_back #define mp make_pair #define fst first #define snd second #define fr(i,n) for(int i=0;i<n;i++) #define frr(i,n) for(int i=1;i<=n;i++) #define ms(x,i) memset(x,i,sizeof(x)) #define dbg(x) cout << #x << " = " << x << endl #define all(x) x.begin(),x.end() #define gnl cout << endl #define olar cout << "olar" << endl #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) typedef long long int ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef pair<ll,ll> pll; const int INF = 0x3f3f3f3f; const ll llINF = 0x3f3f3f3f3f3f3f; const int MOD = 1e9+7; int main(){ fastio; int n,m; cin >> n >> m; int grid[1010][1010]; vi out; int x,y; int mx = -INF; fr(i,n){ fr(j,m){ cin >> grid[i][j]; if(grid[i][j]>mx){ mx=grid[i][j]; x=i; y=j; } } } //fixa linha x pra tirar e acha a melhor coluna int ans1 = -INF; int idc; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(i==x) continue; if(grid[i][j]>ans1){ ans1=grid[i][j]; idc=j; } } } ans1=-INF; //fixada a linha (x) e escolhida a coluna (idc), pego o max q n ta la for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(i==x || j == idc) continue; ans1=max(ans1,grid[i][j]); } } out.pb(ans1); int idl; ans1=-INF; //exclui coluna y e tenta achar a melhor linha pra excluir for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j==y) continue; if(grid[i][j]>ans1){ ans1=grid[i][j]; idl=i; } } } //acha maior cara excluindo linha idl e coluna y ans1=-INF; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j==y || i==idl) continue; ans1=max(ans1,grid[i][j]); } } out.pb(ans1); x++;y++;idl++;idc++; if(out[0]<=out[1]) cout << x << " " << idc << endl; else cout << idl << " " << y << endl; }
[ "vitorguidi@gmail.com" ]
vitorguidi@gmail.com
4016c5721be33e808eaebf73d6d96970dd4b2d78
95ae7dfa9ee578f1b24a65986ff78bf77ceca0c5
/Engine/lib/opcode/OPC_TreeCollider.h
a887983c34ba3c921c9ebc821bd1b7aeec0bcece
[ "MIT", "LicenseRef-scancode-unknown" ]
permissive
TorqueGameEngines/Torque3D
4e1f6a05cc0928980c8c7c20bcdd680eaa6dcee8
a445a4364664e299196bd551d213844486080145
refs/heads/development
2023-09-03T12:40:40.658487
2023-08-24T14:44:43
2023-08-24T14:44:43
267,440,108
1,192
178
MIT
2023-09-13T14:28:16
2020-05-27T22:35:54
C++
UTF-8
C++
false
false
13,417
h
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* * OPCODE - Optimized Collision Detection * Copyright (C) 2001 Pierre Terdiman * Homepage: http://www.codercorner.com/Opcode.htm */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Contains code for a tree collider. * \file OPC_TreeCollider.h * \author Pierre Terdiman * \date March, 20, 2001 */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Include Guard #ifndef __OPC_TREECOLLIDER_H__ #define __OPC_TREECOLLIDER_H__ //! This structure holds cached information used by the algorithm. //! Two model pointers and two colliding primitives are cached. Model pointers are assigned //! to their respective meshes, and the pair of colliding primitives is used for temporal //! coherence. That is, in case temporal coherence is enabled, those two primitives are //! tested for overlap before everything else. If they still collide, we're done before //! even entering the recursive collision code. struct OPCODE_API BVTCache : Pair { //! Constructor inline_ BVTCache() { ResetCache(); ResetCountDown(); } void ResetCache() { Model0 = null; Model1 = null; id0 = 0; id1 = 1; #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! HullTest = true; SepVector.pid = 0; SepVector.qid = 0; SepVector.SV = Point(1.0f, 0.0f, 0.0f); #endif // __MESHMERIZER_H__ } inline_ void ResetCountDown() { #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! CountDown = 50; #endif // __MESHMERIZER_H__ } const Model* Model0; //!< Model for first object const Model* Model1; //!< Model for second object #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! SVCache SepVector; udword CountDown; bool HullTest; #endif // __MESHMERIZER_H__ }; class OPCODE_API AABBTreeCollider : public Collider { public: // Constructor / Destructor AABBTreeCollider(); virtual ~AABBTreeCollider(); // Generic collision query /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Generic collision query for generic OPCODE models. After the call, access the results with: * - GetContactStatus() * - GetNbPairs() * - GetPairs() * * \param cache [in] collision cache for model pointers and a colliding pair of primitives * \param world0 [in] world matrix for first object, or null * \param world1 [in] world matrix for second object, or null * \return true if success * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Collide(BVTCache& cache, const Matrix4x4* world0=null, const Matrix4x4* world1=null); // Collision queries bool Collide(const AABBCollisionTree* tree0, const AABBCollisionTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBNoLeafTree* tree0, const AABBNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBQuantizedTree* tree0, const AABBQuantizedTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBQuantizedNoLeafTree* tree0, const AABBQuantizedNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); // Settings /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Settings: selects between full box-box tests or "SAT-lite" tests (where Class III axes are discarded) * \param flag [in] true for full tests, false for coarse tests * \see SetFullPrimBoxTest(bool flag) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ void SetFullBoxBoxTest(bool flag) { mFullBoxBoxTest = flag; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Settings: selects between full triangle-box tests or "SAT-lite" tests (where Class III axes are discarded) * \param flag [in] true for full tests, false for coarse tests * \see SetFullBoxBoxTest(bool flag) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ void SetFullPrimBoxTest(bool flag) { mFullPrimBoxTest = flag; } // Stats /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of BV-BV overlap tests after a collision query. * \see GetNbPrimPrimTests() * \see GetNbBVPrimTests() * \return the number of BV-BV tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbBVBVTests() const { return mNbBVBVTests; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of Triangle-Triangle overlap tests after a collision query. * \see GetNbBVBVTests() * \see GetNbBVPrimTests() * \return the number of Triangle-Triangle tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbPrimPrimTests() const { return mNbPrimPrimTests; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of BV-Triangle overlap tests after a collision query. * \see GetNbBVBVTests() * \see GetNbPrimPrimTests() * \return the number of BV-Triangle tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbBVPrimTests() const { return mNbBVPrimTests; } // Data access /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Gets the number of contacts after a collision query. * \see GetContactStatus() * \see GetPairs() * \return the number of contacts / colliding pairs. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbPairs() const { return mPairs.GetNbEntries()>>1; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Gets the pairs of colliding triangles after a collision query. * \see GetContactStatus() * \see GetNbPairs() * \return the list of colliding pairs (triangle indices) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ const Pair* GetPairs() const { return (const Pair*)mPairs.GetEntries(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider. * \return null if everything is ok, else a string describing the problem */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// override(Collider) const char* ValidateSettings(); protected: // Colliding pairs OPC_Container mPairs; //!< Pairs of colliding primitives // User mesh interfaces const MeshInterface* mIMesh0; //!< User-defined mesh interface for object0 const MeshInterface* mIMesh1; //!< User-defined mesh interface for object1 // Stats udword mNbBVBVTests; //!< Number of BV-BV tests udword mNbPrimPrimTests; //!< Number of Primitive-Primitive tests udword mNbBVPrimTests; //!< Number of BV-Primitive tests // Precomputed data Matrix3x3 mAR; //!< Absolute rotation matrix Matrix3x3 mR0to1; //!< Rotation from object0 to object1 Matrix3x3 mR1to0; //!< Rotation from object1 to object0 Point mT0to1; //!< Translation from object0 to object1 Point mT1to0; //!< Translation from object1 to object0 // Dequantization coeffs Point mCenterCoeff0; Point mExtentsCoeff0; Point mCenterCoeff1; Point mExtentsCoeff1; // Leaf description Point mLeafVerts[3]; //!< Triangle vertices udword mLeafIndex; //!< Triangle index // Settings bool mFullBoxBoxTest; //!< Perform full BV-BV tests (true) or SAT-lite tests (false) bool mFullPrimBoxTest; //!< Perform full Primitive-BV tests (true) or SAT-lite tests (false) // Internal methods // Standard AABB trees void _Collide(const AABBCollisionNode* b0, const AABBCollisionNode* b1); // Quantized AABB trees void _Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const Point& a, const Point& Pa, const Point& b, const Point& Pb); // No-leaf AABB trees void _CollideTriBox(const AABBNoLeafNode* b); void _CollideBoxTri(const AABBNoLeafNode* b); void _Collide(const AABBNoLeafNode* a, const AABBNoLeafNode* b); // Quantized no-leaf AABB trees void _CollideTriBox(const AABBQuantizedNoLeafNode* b); void _CollideBoxTri(const AABBQuantizedNoLeafNode* b); void _Collide(const AABBQuantizedNoLeafNode* a, const AABBQuantizedNoLeafNode* b); // Overlap tests void PrimTest(udword id0, udword id1); inline_ void PrimTestTriIndex(udword id1); inline_ void PrimTestIndexTri(udword id0); inline_ BOOL BoxBoxOverlap(const Point& ea, const Point& ca, const Point& eb, const Point& cb); inline_ BOOL TriBoxOverlap(const Point& center, const Point& extents); inline_ BOOL TriTriOverlap(const Point& V0, const Point& V1, const Point& V2, const Point& U0, const Point& U1, const Point& U2); // Init methods void InitQuery(const Matrix4x4* world0=null, const Matrix4x4* world1=null); bool CheckTemporalCoherence(Pair* cache); inline_ BOOL Setup(const MeshInterface* mi0, const MeshInterface* mi1) { mIMesh0 = mi0; mIMesh1 = mi1; if(!mIMesh0 || !mIMesh1) return FALSE; return TRUE; } }; #endif // __OPC_TREECOLLIDER_H__
[ "davew@garagegames.com" ]
davew@garagegames.com
87be81184c9e1ce8364f8b7da2df8c8dd0811783
7dd45eec6918a7c63e8ae87a5f22f8be7f313356
/numeric_simple.cpp
436d6a700cdf067eb16f74e9289f877c96452c93
[]
no_license
yazevnul/yzw2v
f89188d62416bb24ac6833c6dab7b961767f7b48
cc52fa5d0108d255c9b41bb1a282790dcdfeeb60
refs/heads/master
2021-01-21T12:59:09.972976
2016-04-19T15:53:08
2016-04-19T15:53:08
54,340,419
1
0
null
null
null
null
UTF-8
C++
false
false
1,456
cpp
#include "numeric.h" void yzw2v::num::Prefetch(const float* v) noexcept { (void)v; } void yzw2v::num::Fill(float* v, const uint32_t v_size, const float value) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] = value; } } void yzw2v::num::Zeroize(float* v, const uint32_t v_size) noexcept { Fill(v, v_size, 0.0f); } void yzw2v::num::DivideVector(float* v, const uint32_t v_size, const float divisor) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] /= divisor; } } void yzw2v::num::MultiplyVector(float* v, const uint32_t v_size, const float multiple) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] *= multiple; } } void yzw2v::num::AddVector(float* v, const uint32_t v_size, const float* const summand) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] += summand[i]; } } void yzw2v::num::AddVector(float* v, const uint32_t v_size, const float* const summand, const float summand_multiple) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] += summand_multiple * summand[i]; } } float yzw2v::num::ScalarProduct(const float* lhs, const uint32_t lhs_size, const float* rhs) noexcept { auto res = float{}; for (auto i = uint32_t{}; i < lhs_size; ++i) { res += lhs[i] * rhs[i]; } return res; }
[ "kostyabazhanov@mail.ru" ]
kostyabazhanov@mail.ru
c8dc701235155a9caac9d92bf68379fd38f7567c
10341b14f0528b0f4a6449f9a3d8dc70e9044143
/codeforces/1180-A.cpp
2a54cd127fbff35e1f6174dd4071b5d78bc20e00
[]
no_license
ayu16/CodeSolutions
e78fe8ec4c9b322b0071e20313f3b4c6e0185272
503845f6c5956507dbf8e033207ab074dc1d5ad4
refs/heads/main
2023-08-25T12:18:23.496152
2021-10-21T05:56:19
2021-10-21T05:56:19
419,598,280
0
0
null
2021-10-21T05:56:19
2021-10-21T05:53:10
null
UTF-8
C++
false
false
1,193
cpp
// https://codeforces.com/contest/1180/problem/A #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define pb push_back #define mp make_pair #define vi vector<int> #define vll vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second #define pn printf("\n") #define si(n) scanf("%d", &n) #define sl(n) scanf("%lld", &n) #define all(c) (c).begin(), (c).end() #define tra(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; } string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); } const int MOD = 1e9 + 7; ll solve(ll n) { ll ans = 0; for(int i = 0 ; i < n - 1 ; i++) { ans += 2 *((2 * i) + 1); } ans += (2 * (n - 1)) + 1; return ans; } void wrapper() { int n; cin >> n; cout << solve(n) << "\n"; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); // clock_t tStart = clock(); /*******/ int t = 1; // cin >> t; while(t--) { wrapper(); } /*******/ // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); return 0; }
[ "ankurcharan98@gmail.com" ]
ankurcharan98@gmail.com
2bd23cab16a03352e21d9446f50e310cea2a78b2
9618aeab5df07ffd1d4f204c8cc3af1a2345d420
/chrome/browser/chromeos/login/login_ui_keyboard_browsertest.cc
23c814f59235b138670e940ad2ff12214cd9f337
[ "BSD-3-Clause" ]
permissive
dmt3o/chromium
3709c0c73e37aec82dc44d2bbe234d1f1829c32f
d368d5937f235033bd495a57005587ab275536b4
refs/heads/master
2022-12-19T04:43:33.801508
2020-10-02T02:56:57
2020-10-02T02:56:57
279,344,900
0
0
BSD-3-Clause
2020-10-02T02:50:00
2020-07-13T15:43:43
null
UTF-8
C++
false
false
18,941
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 "ash/public/cpp/login_screen_test_api.h" #include "base/command_line.h" #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/input_method/input_method_persistence.h" #include "chrome/browser/chromeos/language_preferences.h" #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" #include "chrome/browser/chromeos/login/lock_screen_utils.h" #include "chrome/browser/chromeos/login/login_manager_test.h" #include "chrome/browser/chromeos/login/startup_utils.h" #include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/login_manager_mixin.h" #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" #include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h" #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/common/pref_names.h" #include "chromeos/constants/chromeos_switches.h" #include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_utils.h" namespace em = enterprise_management; namespace chromeos { namespace { constexpr char kTestUser1[] = "test-user1@gmail.com"; constexpr char kTestUser1NonCanonicalDisplayEmail[] = "test-us.e.r1@gmail.com"; constexpr char kTestUser1GaiaId[] = "1111111111"; constexpr char kTestUser2[] = "test-user2@gmail.com"; constexpr char kTestUser2GaiaId[] = "2222222222"; constexpr char kTestUser3[] = "test-user3@gmail.com"; constexpr char kTestUser3GaiaId[] = "3333333333"; void Append_en_US_InputMethod(std::vector<std::string>* out) { out->push_back("xkb:us::eng"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods(out); } void Append_en_US_InputMethods(std::vector<std::string>* out) { out->push_back("xkb:us::eng"); out->push_back("xkb:us:intl:eng"); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) out->push_back("xkb:us:intl_pc:eng"); #endif out->push_back("xkb:us:altgr-intl:eng"); out->push_back("xkb:us:dvorak:eng"); out->push_back("xkb:us:dvp:eng"); out->push_back("xkb:us:colemak:eng"); out->push_back("xkb:us:workman:eng"); out->push_back("xkb:us:workman-intl:eng"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods(out); } } // anonymous namespace class LoginUIKeyboardTest : public chromeos::LoginManagerTest { public: LoginUIKeyboardTest() : LoginManagerTest() { test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)); test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId)); } ~LoginUIKeyboardTest() override {} void SetUpOnMainThread() override { user_input_methods.push_back("xkb:fr::fra"); user_input_methods.push_back("xkb:de::ger"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &user_input_methods); LoginManagerTest::SetUpOnMainThread(); } // Should be called from PRE_ test so that local_state is saved to disk, and // reloaded in the main test. void InitUserLastInputMethod() { input_method::SetUserLastInputMethodPreferenceForTesting( test_users_[0], user_input_methods[0]); input_method::SetUserLastInputMethodPreferenceForTesting( test_users_[1], user_input_methods[1]); } protected: std::vector<std::string> user_input_methods; std::vector<AccountId> test_users_; }; class LoginUIUserAddingKeyboardTest : public LoginUIKeyboardTest { public: LoginUIUserAddingKeyboardTest() { test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId)); } protected: void FocusUserPod(const AccountId& account_id) { test::ExecuteOobeJS( base::StringPrintf(R"($('pod-row').focusPod($('pod-row'))" R"(.getPodWithUsername_('%s'), true))", account_id.Serialize().c_str())); } }; IN_PROC_BROWSER_TEST_F(LoginUIUserAddingKeyboardTest, PRE_CheckPODSwitches) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); RegisterUser(test_users_[2]); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIUserAddingKeyboardTest, CheckPODSwitches) { EXPECT_EQ(lock_screen_utils::GetUserLastInputMethod(test_users_[2]), std::string()); LoginUser(test_users_[2]); const std::string logged_user_input_method = lock_screen_utils::GetUserLastInputMethod(test_users_[2]); UserAddingScreen::Get()->Start(); OobeScreenWaiter(OobeScreen::SCREEN_ACCOUNT_PICKER).Wait(); std::vector<std::string> expected_input_methods; expected_input_methods.push_back(user_input_methods[0]); // Append just one. Append_en_US_InputMethod(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); FocusUserPod(test_users_[1]); EXPECT_EQ(user_input_methods[1], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); FocusUserPod(test_users_[0]); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); // Check that logged in user settings did not change. EXPECT_EQ(lock_screen_utils::GetUserLastInputMethod(test_users_[2]), logged_user_input_method); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, PRE_CheckPODScreenDefault) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); StartupUtils::MarkOobeCompleted(); } // Check default IME initialization, when there is no IME configuration in // local_state. IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, CheckPODScreenDefault) { EXPECT_EQ(2, ash::LoginScreenTestApi::GetUsersCount()); EXPECT_EQ(test_users_[0], ash::LoginScreenTestApi::GetFocusedUser()); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, PRE_CheckPODScreenWithUsers) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, CheckPODScreenWithUsers) { EXPECT_EQ(2, ash::LoginScreenTestApi::GetUsersCount()); EXPECT_EQ(test_users_[0], ash::LoginScreenTestApi::GetFocusedUser()); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); // Active IM for the first user (active user POD). expected_input_methods.push_back(user_input_methods[0]); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); EXPECT_TRUE(ash::LoginScreenTestApi::FocusUser(test_users_[1])); EXPECT_EQ(user_input_methods[1], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); EXPECT_TRUE(ash::LoginScreenTestApi::FocusUser(test_users_[0])); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); } class LoginUIKeyboardTestWithUsersAndOwner : public chromeos::LoginManagerTest { public: LoginUIKeyboardTestWithUsersAndOwner() = default; ~LoginUIKeyboardTestWithUsersAndOwner() override {} void SetUpOnMainThread() override { user_input_methods.push_back("xkb:fr::fra"); user_input_methods.push_back("xkb:de::ger"); user_input_methods.push_back("xkb:pl::pol"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &user_input_methods); scoped_testing_cros_settings_.device_settings()->Set( kDeviceOwner, base::Value(kTestUser3)); LoginManagerTest::SetUpOnMainThread(); } // Should be called from PRE_ test so that local_state is saved to disk, and // reloaded in the main test. void InitUserLastInputMethod() { input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId), user_input_methods[0]); input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId), user_input_methods[1]); input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId), user_input_methods[2]); PrefService* local_state = g_browser_process->local_state(); local_state->SetString(language_prefs::kPreferredKeyboardLayout, user_input_methods[2]); } void CheckGaiaKeyboard(); protected: std::vector<std::string> user_input_methods; ScopedTestingCrosSettings scoped_testing_cros_settings_; }; void LoginUIKeyboardTestWithUsersAndOwner::CheckGaiaKeyboard() { std::vector<std::string> expected_input_methods; // kPreferredKeyboardLayout is now set to last focused POD. expected_input_methods.push_back(user_input_methods[0]); // Locale default input methods (the first one also is hardware IM). Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTestWithUsersAndOwner, PRE_CheckPODScreenKeyboard) { RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)); RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId)); RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId)); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTestWithUsersAndOwner, CheckPODScreenKeyboard) { EXPECT_EQ(3, ash::LoginScreenTestApi::GetUsersCount()); std::vector<std::string> expected_input_methods; // Owner input method. expected_input_methods.push_back(user_input_methods[2]); // Locale default input methods (the first one also is hardware IM). Append_en_US_InputMethods(&expected_input_methods); // Active IM for the first user (active user POD). expected_input_methods.push_back(user_input_methods[0]); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); // Switch to Gaia. ASSERT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton()); OobeScreenWaiter(GaiaView::kScreenId).Wait(); CheckGaiaKeyboard(); // Switch back. test::ExecuteOobeJS("$('gaia-signin').cancel()"); const auto update_count = ash::LoginScreenTestApi::GetUiUpdateCount(); ash::LoginScreenTestApi::WaitForUiUpdate(update_count); EXPECT_FALSE(ash::LoginScreenTestApi::IsOobeDialogVisible()); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } class LoginUIKeyboardPolicy : public LoginManagerTest { protected: policy::DevicePolicyBuilder* device_policy() { return policy_helper_.device_policy(); } void SetAllowedInputMethod(const std::string& method) { em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); proto.mutable_login_screen_input_methods()->add_login_screen_input_methods( method); policy_helper_.RefreshPolicyAndWaitUntilDeviceSettingsUpdated( {chromeos::kDeviceLoginScreenInputMethods}); } LoginManagerMixin login_manager_{&mixin_host_}; DeviceStateMixin device_state_{ &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_CLOUD_ENROLLED}; policy::DevicePolicyCrosTestHelper policy_helper_; }; IN_PROC_BROWSER_TEST_F(LoginUIKeyboardPolicy, RestrictInputMethods) { input_method::InputMethodManager* imm = input_method::InputMethodManager::Get(); ASSERT_TRUE(imm); // Check that input methods are default when policy is not set. ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 0U); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds(), expected_input_methods); std::vector<std::string> allowed_input_method{"xkb:de::ger"}; SetAllowedInputMethod(allowed_input_method.front()); ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 1U); ASSERT_EQ(imm->GetActiveIMEState()->GetNumActiveInputMethods(), 1U); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &allowed_input_method); ASSERT_EQ(imm->GetActiveIMEState()->GetCurrentInputMethod().id(), allowed_input_method.front()); // The policy method stored to language_prefs::kPreferredKeyboardLayout. So // it will be there after the policy is gone. expected_input_methods.insert( expected_input_methods.begin(), imm->GetActiveIMEState()->GetActiveInputMethodIds()[0]); // Remove the policy again em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); proto.mutable_login_screen_input_methods() ->clear_login_screen_input_methods(); policy_helper_.RefreshPolicyAndWaitUntilDeviceSettingsUpdated( {chromeos::kDeviceLoginScreenInputMethods}); ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 0U); ASSERT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } class LoginUIDevicePolicyUserAdding : public LoginUIKeyboardPolicy { public: LoginUIDevicePolicyUserAdding() { // Need at least two to run user adding screen. login_manager_.AppendRegularUsers(2); } }; IN_PROC_BROWSER_TEST_F(LoginUIDevicePolicyUserAdding, PolicyNotHonored) { const AccountId primary_account_id = login_manager_.users()[0].account_id; LoginUser(primary_account_id); input_method::InputMethodManager* input_manager = input_method::InputMethodManager::Get(); auto user_ime_state = input_manager->GetActiveIMEState(); std::vector<std::string> allowed_input_method{"xkb:de::ger"}; SetAllowedInputMethod(allowed_input_method.front()); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &allowed_input_method); UserAddingScreen::Get()->Start(); OobeScreenWaiter(OobeScreen::SCREEN_ACCOUNT_PICKER).Wait(); auto user_adding_ime_state = input_manager->GetActiveIMEState(); EXPECT_NE(user_ime_state, user_adding_ime_state); std::vector<std::string> default_input_methods; Append_en_US_InputMethods(&default_input_methods); // Input methods should be default because the other user (which is focused) // does not have saved last input method. EXPECT_EQ(user_adding_ime_state->GetActiveInputMethodIds(), default_input_methods); EXPECT_EQ(user_adding_ime_state->GetAllowedInputMethods().size(), 0u); EXPECT_FALSE(base::Contains(user_adding_ime_state->GetActiveInputMethodIds(), allowed_input_method.front())); } class FirstLoginKeyboardTest : public LoginManagerTest { public: FirstLoginKeyboardTest() = default; ~FirstLoginKeyboardTest() override = default; protected: AccountId test_user_{ AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)}; DeviceStateMixin device_state_{ &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_UNOWNED}; }; // Tests that user input method correctly propagated after session start or // session unlock. IN_PROC_BROWSER_TEST_F(FirstLoginKeyboardTest, UsersLastInputMethodPersistsOnLoginOrUnlock) { EXPECT_TRUE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); WizardController::SkipPostLoginScreensForTesting(); // Non canonical display email (typed) should not affect input method storage. LoginDisplayHost::default_host()->SetDisplayEmail( kTestUser1NonCanonicalDisplayEmail); LoginUser(test_user_); // Last input method should be stored. EXPECT_FALSE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); ScreenLockerTester locker_tester; locker_tester.Lock(); // Clear user input method. input_method::SetUserLastInputMethodPreferenceForTesting(test_user_, std::string()); EXPECT_TRUE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); locker_tester.UnlockWithPassword(test_user_, "password"); locker_tester.WaitForUnlock(); // Last input method should be stored. EXPECT_FALSE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); } } // namespace chromeos
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
d738b7df9aeea6d2243526f948c614223cced24b
6f6bbab251671ddcdac118b6e730aaecda463e9e
/polynomial_plus.cpp
033259c674b96d50b938967ce71964d8ec6ebba2
[]
no_license
jc3939/Coursera-PKU-Data-Structures
192696c786c171045001bbb35745b80cd47c90d5
12304715c7fcee82b92a885852a48d6ca060f5f5
refs/heads/master
2021-01-21T13:56:43.504598
2016-05-14T23:54:14
2016-05-14T23:54:14
45,805,699
0
0
null
null
null
null
UTF-8
C++
false
false
5,814
cpp
#include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; template<typename T> class Node{ public: T indx; T coeff; Node<T> * next; Node(T _indx, T _coeff, Node<T> * nextValue=NULL){ //cout<<"construct index"<<_indx<<endl; indx = _indx; coeff = _coeff; next = nextValue; } }; template<typename T> class linkedList{ public: Node<T> *_pHead; Node<T> *_pTail; int len; linkedList(T heaIndx, T heaCoeff); //Constructors ~linkedList(); void clear(); bool isEmpty(); int length(); bool insert( int i, T Indx, T Coeff); bool Sort(); bool RemoveDup(); bool append(T indx, T coeff); Node<T> *setPos(int p); }; template<typename T> linkedList<T>::linkedList(T heaIndx, T heaCoeff){ _pHead = new Node<T>(heaIndx, heaCoeff); _pHead->next = _pTail; len=0; } template<typename T> bool linkedList<T>::isEmpty(){ if (len == 0) { return true; } else return false; } template<typename T> int linkedList<T>::length(){ return len; } template<typename T> bool linkedList<T>::append(T indx, T coeff){ Node<T> *p = new Node<T>(indx, coeff); //cout<<"append index"<<p->indx<<endl; _pTail = p; int i = 0; Node<T> *pfinder = _pHead; while(i<len){ pfinder=pfinder->next; i++; } pfinder->next = p; len++; return true; } //Sort linked list by indx in descending order. template<typename T> bool linkedList<T>::Sort(){ Node<T> *p = _pHead->next; Node<T> *q; if (p == NULL){ cout<<"Cannot sort an empty List!!!"<<endl; return false; } int tempIndex=0; int tempCoeff = 0; while(p!=NULL){ q = p->next; while(q!=NULL){ if(q->indx>p->indx){ //Swap indx and coeff values tempIndex = q->indx; q->indx = p->indx; p->indx = tempIndex; tempCoeff = q->coeff; q->coeff = p->coeff; p->coeff=tempCoeff; } q = q->next; } p=p->next; } return true; } template<typename T> bool linkedList<T>::RemoveDup(){ Node<T> *p = _pHead->next; if(p==NULL){ cout<<"Cannot operate an empty List!!!"<<endl; return false; } Node<T> *q = p->next; while(p!=NULL && q!=NULL){ while(p->indx==q->indx){ p->coeff+=q->coeff; q = q->next; if(q==NULL){ p->next=NULL; return true; } if(p->indx!=q->indx){ p->next = q; break; } } p = p->next; if(p==NULL) return true; q = p->next; } return true; } int main(){ ifstream infile("/Users/jianjun_chen/Documents/Coursera-PKU-Data-Structures/input.txt"); int coeff, indx; int n; string line; getline(infile, line); stringstream linestream(line); linestream>>n; cout<<n<<"&&&&"<<endl; while(n!=0){ //construct new linked list array1 and array2 with //-1 as header and -2 as tail. linkedList<int> *array1 = new linkedList<int>(-1, 0); linkedList<int> *array2 = new linkedList<int>(-1, 0); getline(infile, line); stringstream linestream1(line); //cout<<line<<endl; //linestream>>coeff>>indx; while(linestream1>>coeff>>indx){ cout<<coeff<<" "<<indx<<endl; if(indx<0){ break;//as each line will end with an negative index } array1->append(indx, coeff); } getline(infile, line); stringstream linestream2(line); while(linestream2>>coeff>>indx){ if(indx<0){ break; } array2->append(indx, coeff); } //sort each linked list large to small by their index. array1->Sort(); array2->Sort(); //merge nodes with same index. array1->RemoveDup(); array2->RemoveDup(); //Start from the first node of linked lists. Node<int> *p1 = array1->_pHead->next; Node<int> *p2 = array2->_pHead->next; Node<int> *p1a = array1->_pHead;//p1a to store previous node of p1 Node<int> *p1r; Node<int> *p2r; while(p1!=NULL || p2!=NULL){ //p1r and p2r store next node of p1, p2. if(p1==NULL){ p1a->next=p2; //cout<<"Now p1a->next->indx is "<<p1a->next->indx<<endl; break; } else if(p2==NULL){ break; } p1r = p1->next; p2r = p2->next; if(p1->indx==p2->indx){ //if p1 has same index with p2, then p1.index+p2.index //delete p2. p1->coeff+=p2->coeff; p1a = p1; p1 = p1r; p2 = p2r; }else if(p1->indx < p2->indx){ //if p1.index>p2.index, then insert p2 into //p1 and p1.next(p1r) p1a->next = p2; p2->next = p1; p1a = p2; p2 = p2r; }else{ //if p1.index<p2.index, then insert p2 into //p1 and p1's previous node. p1a = p1; p1 = p1->next; } } p1 = array1->_pHead->next; while(p1!=NULL){ //cout<<p1->coeff<<" "<<p1->indx<<endl; if(p1->coeff!=0){ cout << "[ "<<p1->coeff<<" "<<p1->indx<<" ] "; } p1 = p1->next; } cout << endl; n--; } }
[ "jianjun_chen@Jianjun-Chens-MacBook-Pro.local" ]
jianjun_chen@Jianjun-Chens-MacBook-Pro.local
2d26a6b0187e8ac52e7969028a31b44e3de25b89
8f29bbdbc1b29365eca840b72d61f63abe8f829f
/Semester2/3001/AI midterm/SDLGameEngine/Align.h
d7800e496cb46097c91e1b8ada52797d677fda36
[]
no_license
CccrizzZ/GBC01
d294f01aab97de37f2b70bcf325ae713e4eed740
c44130872f609e5778992d8a6dad09caed29ff71
refs/heads/master
2022-02-22T11:32:54.720661
2019-10-14T00:07:50
2019-10-14T00:07:50
158,318,882
0
0
null
null
null
null
UTF-8
C++
false
false
304
h
#pragma once #include "SteeringBehaviour.h" class Align : public SteeringBehaviour { public: Align(); Align(GameObject* go); ~Align(); void Update(); float orientation; float maxAngularAccelaration = 0.1f; float targetRadius = 0.5f; float slowRadius = 1.0f; float timeToTarget = 0.1f; };
[ "ccccrizzzz@gmail.com" ]
ccccrizzzz@gmail.com
9254d769384a8ea2417fbb2a7db4ce39bed55ed9
fbbef987934e34d3163864008bd6e32008532662
/TechDeMMO/GameObjectFactory.cpp
c582784770b3f045532568314d7953f6c28ce927
[]
no_license
Lugswo/TechDeMMO
bb07f9dc02526b75f971032a283844a679a5cda2
2d50b6355d5fa4abb7876523f990a0ad7c555201
refs/heads/master
2020-06-01T00:23:29.565161
2019-09-05T19:23:16
2019-09-05T19:23:16
190,555,665
0
0
null
null
null
null
UTF-8
C++
false
false
2,152
cpp
#include "GameObjectFactory.h" #include "TraceLog.h" #include "TransformComponent.h" #include "SpriteComponent.h" #include "PlayerComponent.h" #include "RandomEngine.h" std::map<unsigned, GameObject *> GameObjectFactory::archetypeList, GameObjectFactory::objectList, GameObjectFactory::playerList; unsigned GameObjectFactory::id; GameObjectFactory::~GameObjectFactory() { for (auto itr = objectList.begin(); itr != objectList.end(); ++itr) { delete (*itr).second; } for (auto itr = archetypeList.begin(); itr != archetypeList.end(); ++itr) { delete (*itr).second; } } void GameObjectFactory::Init() { id = 0; } void GameObjectFactory::Update(float dt) { for (auto itr = objectList.begin(); itr != objectList.end(); ++itr) { (*itr).second->Update(dt); } } void GameObjectFactory::CreatePlayer(bool t, glm::vec2 pos, unsigned i) { GameObject *obj = new GameObject(); TransformComponent *trans = new TransformComponent(); SpriteComponent *sprite = new SpriteComponent("ArtAssets/bub.png"); PlayerComponent *player = new PlayerComponent(t, pos); obj->AddComponent(trans); obj->AddComponent(sprite); obj->AddComponent(player); glm::vec3 a = trans->GetTranslation(); a.x = pos.x; a.y = pos.y; trans->SetTranslation(a); AddPlayer(obj, i); } void GameObjectFactory::DeletePlayer(unsigned i) { GameObject *temp = playerList[i]; if (temp) { objectList.erase(temp->GetID()); playerList.erase(i); } delete temp; } GameObject * GameObjectFactory::GetPlayer(unsigned i) { auto it = playerList.find(i); if (it == playerList.end()) { TraceLog::Log(TRACE_LEVEL::ERR, "Cannot find player with given id " + std::to_string(i) + "!"); return nullptr; } return playerList[i]; } void GameObjectFactory::AddObject(GameObject *obj) { ++id; obj->SetID(id); objectList.insert(std::pair<unsigned, GameObject*>(id, obj)); obj->Init(); } void GameObjectFactory::AddPlayer(GameObject *obj, unsigned i) { AddObject(obj); playerList.insert(std::pair<unsigned, GameObject *>(i, obj)); } void GameObjectFactory::RemoveObject(unsigned i) { objectList.erase(i); }
[ "spencer.park@digipen.edu" ]
spencer.park@digipen.edu
d2ee9c42388a25df746ce19290d8aff732da086f
7f86aa1f4533a3845dbb7379f4b4d24ac9ed8496
/src/LocalFit.cpp
b43016b9c0d66d63e064d697b8b95d475083a645
[]
no_license
wagenadl/salpa
33cd5e89556bc0913add37e7718cba6822cbba6a
2d9195b21f321fd0913fd3794fee4f59e0ed1ca4
refs/heads/master
2023-03-02T07:17:06.713341
2023-02-28T18:04:14
2023-02-28T18:04:14
271,944,219
1
0
null
null
null
null
UTF-8
C++
false
false
9,964
cpp
/* artifilt/LocalFit.C: part of meabench, an MEA recording and analysis tool ** Copyright (C) 2000-2003 Daniel Wagenaar (wagenaar@caltech.edu) ** ** 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 */ // LocalFit.C #include "LocalFit.h" #include <iostream> #include <cmath> #include <cstdlib> //-------------------------------------------------------------------- // inline functions // inline void LocalFit::update_X012() { int_t y_new = source[t_stream+tau]; int_t y_old = source[t_stream-tau-1]; X0 += y_new - y_old; X1 += tau_plus_1*y_new - minus_tau*y_old - X0; X2 += tau_plus_1_squared*y_new - minus_tau_squared*y_old - X0 - 2*X1; } inline void LocalFit::calc_alpha0() { alpha0 = real_t(T4*X0 - T2*X2) / real_t(T0*T4-T2*T2); } //-------------------------------------------------------------------- // Other LocalFit methods // LocalFit::LocalFit(CyclBuf<raw_t> const &source0, CyclBuf<raw_t> &dest0, timeref_t t_start, raw_t threshold0, timeref_t tau0, timeref_t t_blankdepeg0, timeref_t t_ahead0, timeref_t t_chi20): source(source0), dest(dest0), y_threshold(threshold0), tau(tau0), t_blankdepeg(t_blankdepeg0), t_ahead(t_ahead0), t_chi2(t_chi20) { usenegv = true; state = State::PEGGED; // t_peg = t_start; t_stream = t_start; init_T(); rail1=RAIL1; rail2=RAIL2; debug_name = -1; } void LocalFit::setusenegv(bool t) { usenegv = t; } void LocalFit::reset(timeref_t t_start) { // t_peg = t_start; t_stream = t_start; state = State::PEGGED; } void LocalFit::init_T() { my_thresh = 3.92 * t_chi2 * y_threshold*y_threshold; // 95% conf limit tau_plus_1 = tau+1; tau_plus_1_squared = tau_plus_1 * tau_plus_1; tau_plus_1_cubed = tau_plus_1_squared * tau_plus_1; minus_tau = -tau; minus_tau_squared = minus_tau * minus_tau; minus_tau_cubed = minus_tau_squared * minus_tau; T0=T2=T4=T6=0; for (int t=-tau; t<=tau; t++) { int_t t2=t*t; int_t t4=t2*t2; int_t t6=t4*t2; T0+=1; T2+=t2; T4+=t4; T6+=t6; } } timeref_t LocalFit::process(timeref_t t_limit) { state=statemachine(t_limit, state); return t_stream; } timeref_t LocalFit::forcepeg(timeref_t t_from, timeref_t t_to) { state = statemachine(t_from - tau, state); if (state==State::OK) { // goto state PEGGING t0 = t_stream - 1; calc_X3(); calc_alpha0123(); state = statemachine(t_from, State::PEGGING); } t0 = t_to; state = statemachine(t_to, State::FORCEPEG); return t_stream; } LocalFit::State LocalFit::statemachine(timeref_t t_limit, State s) { /* This is a straightforward implementation of the statemachine I described on 9/9/01. * //// mark boundaries program flow does not pass through. * On exit, t_stream == t_limit. */ // timeref_t t_check=0; //DBG switch (s) { case State::OK: goto l_OK; case State::PEGGED: goto l_PEGGED; case State::PEGGING: goto l_PEGGING; case State::TOOPOOR: goto l_TOOPOOR; case State::DEPEGGING: goto l_DEPEGGING; case State::FORCEPEG: goto l_FORCEPEG; case State::BLANKDEPEG: goto l_BLANKDEPEG; default: crash("Bad State"); } ////////////////////////////////////////////////// l_PEGGED: { if (t_stream>=t_limit) return State::PEGGED; if (ispegged(source[t_stream])) { dest[t_stream]=0; t_stream++; goto l_PEGGED; } for (int dt=1; dt<=2*tau; dt++) if (ispegged(source[t_stream+dt])) { t0 = t_stream+dt; goto l_FORCEPEG; } t0 = t_stream + tau; calc_X012(); calc_X3(); calc_alpha0123(); toopoorcnt=TOOPOORCNT; goto l_TOOPOOR; } crash("Code breach"); ////////////////////////////////////////////////// l_TOOPOOR: { if (t_stream>=t_limit) return State::TOOPOOR; real_t asym=0; real_t sig=0; for (int i=0; i<t_chi2; i++) { int t_i = t_stream+i; int dt = t_i - t0; int dt2=dt*dt; int dt3=dt*dt2; real_t dy = alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3 - source[t_i]; asym += dy; sig += dy*dy; } asym *= asym; if (asym<my_thresh) toopoorcnt--; else toopoorcnt = TOOPOORCNT; if (toopoorcnt<=0 && asym < my_thresh/3.92) { if (usenegv) { int dt = t_stream - t0; int dt2=dt*dt; int dt3=dt*dt2; negv = source[t_stream] < raw_t(alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3); } calc_X012(); calc_X3(); // for numerical stability problem! goto l_BLANKDEPEG; } dest[t_stream] = 0; t_stream++; t0++; if (ispegged(source[t0+tau])) { t0=t0+tau; goto l_FORCEPEG; } update_X0123(); calc_X012(); calc_X3(); // for numerical stability problem! calc_alpha0123(); goto l_TOOPOOR; } crash("Code breach"); ////////////////////////////////////////////////// l_FORCEPEG: { if (t_stream>=t_limit) return State::FORCEPEG; if (t_stream>=t0) goto l_PEGGED; dest[t_stream++] = 0; goto l_FORCEPEG; } crash("Code breach"); ////////////////////////////////////////////////// l_BLANKDEPEG: { if (t_stream>=t_limit) return State::BLANKDEPEG; if (t_stream >= t0-tau+t_blankdepeg) goto l_DEPEGGING; if (usenegv) { int dt=t_stream-t0; int dt2=dt*dt; int dt3=dt*dt2; raw_t y = source[t_stream]; y -= alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3; if ((y<0) != negv) { dest[t_stream] = y; t_stream++; goto l_DEPEGGING; } } dest[t_stream] = 0; t_stream++; goto l_BLANKDEPEG; } crash("Code breach"); ////////////////////////////////////////////////// l_DEPEGGING: { if (t_stream>=t_limit) return State::DEPEGGING; if (t_stream==t0) goto l_OK; int dt = t_stream - t0; int dt2 = dt*dt; int dt3 = dt*dt2; raw_t y = source[t_stream]; y -= (alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3); dest[t_stream++] = y; goto l_DEPEGGING; } crash("Code breach"); ////////////////////////////////////////////////// l_PEGGING: { if (t_stream >= t_limit) return State::PEGGING; if (t_stream >= t0 + tau) { // t_peg = t_stream; goto l_PEGGED; } int dt = t_stream - t0; int dt2 = dt*dt; int dt3 = dt*dt2; raw_t y = source[t_stream]; y -= alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3; dest[t_stream++] = y; goto l_PEGGING; } crash("Code breach"); ////////////////////////////////////////////////// l_OK: { if (t_stream>=t_limit) return State::OK; calc_alpha0(); raw_t y = source[t_stream]; y -= alpha0; dest[t_stream++] = y; if (ispegged(source[t_stream+tau+t_ahead])) { if (debug_name==0) std::cerr << "salpa " << debug_name << " going from OK to pegging at " << t_stream+tau+t_ahead << " because " << source[t_stream+tau+t_ahead] << "\n"; t0 = t_stream-1; calc_X3(); calc_alpha0123(); goto l_PEGGING; } update_X012(); goto l_OK; } crash("Code breach"); ////////////////////////////////////////////////// } void LocalFit::calc_X012() { X0 = X1 = X2 = 0; for (int t=-tau; t<=tau; t++) { int_t t2 = t*t; int_t y = source[t0+t]; X0 += y; X1 += t*y; X2 += t2*y; } } void LocalFit::calc_X3() { X3 = 0; for (int t=-tau; t<=tau; t++) { int_t t3 = t*t*t; int_t y = source[t0+t]; X3 += t3*y; } } void LocalFit::update_X0123() { int_t y_new = source[t0+tau]; int_t y_old = source[t0-tau-1]; X0 += y_new - y_old; X1 += tau_plus_1*y_new - minus_tau*y_old - X0; X2 += tau_plus_1_squared*y_new - minus_tau_squared*y_old - X0 - 2*X1; X3 += tau_plus_1_cubed*y_new - minus_tau_cubed*y_old - X0 - 3*X1 - 3*X2; } void LocalFit::calc_alpha0123() { real_t fact02 = 1./(T0*T4-T2*T2); alpha0 = fact02*(T4*X0 - T2*X2); alpha2 = fact02*(T0*X2 - T2*X0); real_t fact13 = 1./(T2*T6-T4*T4); alpha1 = fact13*(T6*X1 - T4*X3); alpha3 = fact13*(T2*X3 - T4*X1); //// report(); } //-------------------------------------------------------------------- // debug // #include <iostream> char const *LocalFit::stateName(State s) { switch (s) { case State::OK: return "OK"; case State::PEGGING: return "Pegging"; case State::PEGGED: return "Pegged"; case State::TOOPOOR: return "TooPoor"; case State::DEPEGGING: return "Depegging"; case State::FORCEPEG: return "ForcePeg"; case State::BLANKDEPEG: return "BlankDepeg"; default: return "???"; } } void LocalFit::report() { std::cerr << "state=" << stateName(state); std::cerr << " t_stream=" << t_stream; std::cerr << " t0=" << t0; std::cerr << " y[t]=" << source[t_stream]; std::cerr << " alpha=" << alpha0 << " " << alpha1 << " " << alpha2 << " " << alpha3; std::cerr << " X=" << X0 << " " << X1 << " " << X2 << " " << X3; std::cerr << "\n"; } void LocalFit::inirep() { std::cerr << "tau=" << tau; std::cerr << " T0/2/4/6=" << T0 << " " << T2 << " " << T4 << " " << T6; std::cerr << "\n"; } void LocalFit::crash(char const *msg) { std::cerr << "LocalFit: " << msg << "\n"; std::exit(1); } void LocalFit::condreport() { if (t_stream < 45000) report(); }
[ "daw@caltech.edu" ]
daw@caltech.edu
bdb0ea1bfd29fb2e90f269251480495f9b95072a
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-clouddirectory/source/model/UpdateSchemaResult.cpp
2212eb21df8632de13d62bed3387d048b8bfa2ce
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
1,354
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/clouddirectory/model/UpdateSchemaResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::CloudDirectory::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; UpdateSchemaResult::UpdateSchemaResult() { } UpdateSchemaResult::UpdateSchemaResult(const AmazonWebServiceResult<JsonValue>& result) { *this = result; } UpdateSchemaResult& UpdateSchemaResult::operator =(const AmazonWebServiceResult<JsonValue>& result) { const JsonValue& jsonValue = result.GetPayload(); if(jsonValue.ValueExists("SchemaArn")) { m_schemaArn = jsonValue.GetString("SchemaArn"); } return *this; }
[ "henso@amazon.com" ]
henso@amazon.com
920893112aa418d630c07859c9776a9561b602a5
9621b172b8d01dd9d275537293b3d1e9a19ef4ce
/src/chrono_vehicle/cosim/terrain/ChVehicleCosimTerrainNodeSCM.cpp
4582e4919edd167c214b6ef80fa5ab0ed31809ae
[ "BSD-3-Clause" ]
permissive
jmange/chrono
c72173d06824405c958be0914e41db70540b84e8
f25c40d0eccfe30b5a6cdec3148e26d5c393015b
refs/heads/main
2023-07-09T20:03:16.294624
2023-07-05T18:13:27
2023-07-05T18:13:27
629,678,854
0
0
null
2023-04-18T20:03:19
2023-04-18T20:03:18
null
UTF-8
C++
false
false
15,679
cpp
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2020 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Definition of the SCM deformable TERRAIN NODE. // // The global reference frame has Z up, X towards the front of the vehicle, and // Y pointing to the left. // // ============================================================================= #include <algorithm> #include <cmath> #include <set> #include "chrono/utils/ChUtilsCreators.h" #include "chrono/utils/ChUtilsGenerators.h" #include "chrono/utils/ChUtilsInputOutput.h" #include "chrono/assets/ChTriangleMeshShape.h" #include "chrono/physics/ChSystemSMC.h" #include "chrono/physics/ChSystemNSC.h" #include "chrono_vehicle/cosim/terrain/ChVehicleCosimTerrainNodeSCM.h" #ifdef CHRONO_IRRLICHT #include "chrono_irrlicht/ChVisualSystemIrrlicht.h" #endif #ifdef CHRONO_VSG #include "chrono_vsg/ChVisualSystemVSG.h" #endif using std::cout; using std::endl; using namespace rapidjson; namespace chrono { namespace vehicle { // Maximum sinkage for rendering static const double max_sinkage = 0.15; // ----------------------------------------------------------------------------- // Construction of the terrain node: // - create the Chrono system and set solver parameters // - create the Irrlicht visualization window // ----------------------------------------------------------------------------- ChVehicleCosimTerrainNodeSCM::ChVehicleCosimTerrainNodeSCM(double length, double width) : ChVehicleCosimTerrainNodeChrono(Type::SCM, length, width, ChContactMethod::SMC), m_radius_p(5e-3), m_use_checkpoint(false) { // Create system and set default method-specific solver settings m_system = new ChSystemSMC; // Solver settings independent of method type m_system->Set_G_acc(ChVector<>(0, 0, m_gacc)); // Set default number of threads m_system->SetNumThreads(1, 1, 1); } ChVehicleCosimTerrainNodeSCM::ChVehicleCosimTerrainNodeSCM(const std::string& specfile) : ChVehicleCosimTerrainNodeChrono(Type::SCM, 0, 0, ChContactMethod::SMC), m_use_checkpoint(false) { // Create system and set default method-specific solver settings m_system = new ChSystemSMC; // Solver settings independent of method type m_system->Set_G_acc(ChVector<>(0, 0, m_gacc)); // Read SCM parameters from provided specfile SetFromSpecfile(specfile); } ChVehicleCosimTerrainNodeSCM::~ChVehicleCosimTerrainNodeSCM() { delete m_terrain; delete m_system; } // ----------------------------------------------------------------------------- //// TODO: error checking void ChVehicleCosimTerrainNodeSCM::SetFromSpecfile(const std::string& specfile) { Document d; ReadSpecfile(specfile, d); m_dimX = d["Patch dimensions"]["Length"].GetDouble(); m_dimY = d["Patch dimensions"]["Width"].GetDouble(); m_spacing = d["Grid spacing"].GetDouble(); m_Bekker_Kphi = d["Soil parameters"]["Bekker Kphi"].GetDouble(); m_Bekker_Kc = d["Soil parameters"]["Bekker Kc"].GetDouble(); m_Bekker_n = d["Soil parameters"]["Bekker n exponent"].GetDouble(); m_Mohr_cohesion = d["Soil parameters"]["Mohr cohesive limit"].GetDouble(); m_Mohr_friction = d["Soil parameters"]["Mohr friction limit"].GetDouble(); m_Janosi_shear = d["Soil parameters"]["Janosi shear coefficient"].GetDouble(); m_elastic_K = d["Soil parameters"]["Elastic stiffness"].GetDouble(); m_damping_R = d["Soil parameters"]["Damping"].GetDouble(); m_radius_p = d["Simulation settings"]["Proxy contact radius"].GetDouble(); m_fixed_proxies = d["Simulation settings"]["Fix proxies"].GetBool(); } void ChVehicleCosimTerrainNodeSCM::SetPropertiesSCM(double spacing, double Bekker_Kphi, double Bekker_Kc, double Bekker_n, double Mohr_cohesion, double Mohr_friction, double Janosi_shear, double elastic_K, double damping_R) { m_spacing = spacing; m_Bekker_Kphi = Bekker_Kphi; m_Bekker_Kc = Bekker_Kc; m_Bekker_n = Bekker_n; m_Mohr_cohesion = Mohr_cohesion; m_Mohr_friction = Mohr_friction; m_Janosi_shear = Janosi_shear; m_elastic_K = elastic_K; m_damping_R = damping_R; } void ChVehicleCosimTerrainNodeSCM::SetInputFromCheckpoint(const std::string& filename) { m_use_checkpoint = true; m_checkpoint_filename = filename; } void ChVehicleCosimTerrainNodeSCM::SetNumThreads(int num_threads) { m_system->SetNumThreads(num_threads, 1, 1); } // ----------------------------------------------------------------------------- // Complete construction of the mechanical system. // This function is invoked automatically from Initialize. // - adjust system settings // - create the container body // - if specified, create the granular material // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::Construct() { if (m_verbose) cout << "[Terrain node] SCM " << endl; // Create the SCM patch (default center at origin) m_terrain = new SCMTerrain(m_system); m_terrain->SetSoilParameters(m_Bekker_Kphi, m_Bekker_Kc, m_Bekker_n, // m_Mohr_cohesion, m_Mohr_friction, m_Janosi_shear, // m_elastic_K, m_damping_R); m_terrain->SetPlotType(vehicle::SCMTerrain::PLOT_SINKAGE, 0, max_sinkage); m_terrain->Initialize(m_dimX, m_dimY, m_spacing); // If indicated, set node heights from checkpoint file if (m_use_checkpoint) { // Open input file stream std::string checkpoint_filename = m_node_out_dir + "/" + m_checkpoint_filename; std::ifstream ifile(checkpoint_filename); if (!ifile.is_open()) { cout << "ERROR: could not open checkpoint file " << checkpoint_filename << endl; MPI_Abort(MPI_COMM_WORLD, 1); } std::string line; // Read and discard line with current time std::getline(ifile, line); // Read number of modified nodes int num_nodes; std::getline(ifile, line); std::istringstream iss(line); iss >> num_nodes; std::vector<SCMTerrain::NodeLevel> nodes(num_nodes); for (int i = 0; i < num_nodes; i++) { std::getline(ifile, line); std::istringstream iss1(line); int x, y; double h; iss1 >> x >> y >> h; nodes[i] = std::make_pair(ChVector2<>(x, y), h); } m_terrain->SetModifiedNodes(nodes); if (m_verbose) cout << "[Terrain node] read " << checkpoint_filename << " num. nodes = " << num_nodes << endl; } // Add all rigid obstacles for (auto& b : m_obstacles) { auto mat = b.m_contact_mat.CreateMaterial(m_system->GetContactMethod()); auto trimesh = geometry::ChTriangleMeshConnected::CreateFromWavefrontFile(GetChronoDataFile(b.m_mesh_filename), true, true); double mass; ChVector<> baricenter; ChMatrix33<> inertia; trimesh->ComputeMassProperties(true, mass, baricenter, inertia); auto body = std::shared_ptr<ChBody>(m_system->NewBody()); body->SetPos(b.m_init_pos); body->SetRot(b.m_init_rot); body->SetMass(mass * b.m_density); body->SetInertia(inertia * b.m_density); body->SetBodyFixed(false); body->SetCollide(true); body->GetCollisionModel()->ClearModel(); body->GetCollisionModel()->AddTriangleMesh(mat, trimesh, false, false, ChVector<>(0), ChMatrix33<>(1), m_radius_p); body->GetCollisionModel()->SetFamily(2); body->GetCollisionModel()->BuildModel(); auto trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); body->AddVisualShape(trimesh_shape, ChFrame<>()); // Add corresponding moving patch to SCM terrain m_terrain->AddMovingPatch(body, b.m_oobb_center, b.m_oobb_dims); m_system->AddBody(body); } // Write file with terrain node settings std::ofstream outf; outf.open(m_node_out_dir + "/settings.info", std::ios::out); outf << "System settings" << endl; outf << " Integration step size = " << m_step_size << endl; outf << "Patch dimensions" << endl; outf << " X = " << m_dimX << " Y = " << m_dimY << endl; outf << " spacing = " << m_spacing << endl; outf << "Terrain material properties" << endl; outf << " Kphi = " << m_Bekker_Kphi << endl; outf << " Kc = " << m_Bekker_Kc << endl; outf << " n = " << m_Bekker_n << endl; outf << " c = " << m_Mohr_cohesion << endl; outf << " mu = " << m_Mohr_friction << endl; outf << " J = " << m_Janosi_shear << endl; outf << " Ke = " << m_elastic_K << endl; outf << " Rd = " << m_damping_R << endl; } // Create bodies with triangular contact geometry as proxies for the mesh faces. // Used for flexible bodies. // Assign to each body an identifier equal to the index of its corresponding mesh face. // Maintain a list of all bodies associated with the object. // Add all proxy bodies to the same collision family and disable collision between any // two members of this family. void ChVehicleCosimTerrainNodeSCM::CreateMeshProxy(unsigned int i) { //// TODO } void ChVehicleCosimTerrainNodeSCM::CreateRigidProxy(unsigned int i) { // Get shape associated with the given object int i_shape = m_obj_map[i]; // Create wheel proxy body auto body = std::shared_ptr<ChBody>(m_system->NewBody()); body->SetIdentifier(0); body->SetMass(m_load_mass[i_shape]); ////body->SetInertiaXX(); //// TODO body->SetBodyFixed(false); // Cannot fix the proxies with SCM body->SetCollide(true); // Create visualization asset (use collision shapes) m_geometry[i_shape].CreateVisualizationAssets(body, VisualizationType::PRIMITIVES, true); // Create collision shapes for (auto& mesh : m_geometry[i_shape].m_coll_meshes) mesh.m_radius = m_radius_p; m_geometry[i_shape].CreateCollisionShapes(body, 1, m_method); body->GetCollisionModel()->SetFamily(1); body->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(1); m_system->AddBody(body); m_proxies[i].push_back(ProxyBody(body, 0)); // Add corresponding moving patch to SCM terrain //// RADU TODO: this may be overkill for tracked vehicles! m_terrain->AddMovingPatch(body, m_aabb[i_shape].m_center, m_aabb[i_shape].m_dims); } // Once all proxy bodies are created, complete construction of the underlying system. void ChVehicleCosimTerrainNodeSCM::OnInitialize(unsigned int num_objects) { ChVehicleCosimTerrainNodeChrono::OnInitialize(num_objects); // Create the visualization window if (m_renderRT) { #if defined(CHRONO_VSG) auto vsys_vsg = chrono_types::make_shared<vsg3d::ChVisualSystemVSG>(); vsys_vsg->AttachSystem(m_system); vsys_vsg->SetWindowTitle("Terrain Node (SCM)"); vsys_vsg->SetWindowSize(ChVector2<int>(1280, 720)); vsys_vsg->SetWindowPosition(ChVector2<int>(100, 100)); vsys_vsg->SetUseSkyBox(true); vsys_vsg->AddCamera(m_cam_pos, ChVector<>(0, 0, 0)); vsys_vsg->SetCameraAngleDeg(40); vsys_vsg->SetLightIntensity(1.0f); vsys_vsg->AddGuiColorbar("Sinkage (m)", 0.0, 0.1); vsys_vsg->Initialize(); m_vsys = vsys_vsg; #elif defined(CHRONO_IRRLICHT) auto vsys_irr = chrono_types::make_shared<irrlicht::ChVisualSystemIrrlicht>(); vsys_irr->AttachSystem(m_system); vsys_irr->SetWindowTitle("Terrain Node (SCM)"); vsys_irr->SetCameraVertical(CameraVerticalDir::Z); vsys_irr->SetWindowSize(1280, 720); vsys_irr->Initialize(); vsys_irr->AddLogo(); vsys_irr->AddSkyBox(); vsys_irr->AddTypicalLights(); vsys_irr->AddCamera(m_cam_pos, ChVector<>(0, 0, 0)); m_vsys = vsys_irr; #endif } } // Set position, orientation, and velocity of proxy bodies based on mesh faces. void ChVehicleCosimTerrainNodeSCM::UpdateMeshProxy(unsigned int i, MeshState& mesh_state) { //// TODO } // Set state of proxy rigid body. void ChVehicleCosimTerrainNodeSCM::UpdateRigidProxy(unsigned int i, BodyState& rigid_state) { auto& proxies = m_proxies[i]; // proxies for the i-th rigid proxies[0].m_body->SetPos(rigid_state.pos); proxies[0].m_body->SetPos_dt(rigid_state.lin_vel); proxies[0].m_body->SetRot(rigid_state.rot); proxies[0].m_body->SetWvel_par(rigid_state.ang_vel); } // Collect contact forces on the (face) proxy bodies that are in contact. // Load mesh vertex forces and corresponding indices. void ChVehicleCosimTerrainNodeSCM::GetForceMeshProxy(unsigned int i, MeshContact& mesh_contact) { //// TODO } // Collect resultant contact force and torque on rigid proxy body. void ChVehicleCosimTerrainNodeSCM::GetForceRigidProxy(unsigned int i, TerrainForce& rigid_contact) { const auto& proxies = m_proxies[i]; // proxies for the i-th rigid rigid_contact = m_terrain->GetContactForce(proxies[0].m_body); } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::OnRender() { if (!m_vsys) return; if (!m_vsys->Run()) MPI_Abort(MPI_COMM_WORLD, 1); if (m_track) { const auto& proxies = m_proxies[0]; // proxies for first object ChVector<> cam_point = proxies[0].m_body->GetPos(); m_vsys->UpdateCamera(m_cam_pos, cam_point); } m_vsys->BeginScene(); m_vsys->Render(); m_vsys->EndScene(); } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::OnOutputData(int frame) { //// TODO } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::WriteCheckpoint(const std::string& filename) const { utils::CSV_writer csv(" "); // Get all SCM grid nodes modified from start of simulation const auto& nodes = m_terrain->GetModifiedNodes(true); // Write current time and total number of modified grid nodes. csv << m_system->GetChTime() << endl; csv << nodes.size() << endl; // Write node locations and heights for (const auto& node : nodes) { csv << node.first.x() << node.first.y() << node.second << endl; } std::string checkpoint_filename = m_node_out_dir + "/" + filename; csv.write_to_file(checkpoint_filename); if (m_verbose) cout << "[Terrain node] write checkpoint ===> " << checkpoint_filename << endl; } } // end namespace vehicle } // end namespace chrono
[ "serban@wisc.edu" ]
serban@wisc.edu
a04f59337ff272d0381e299706acc9aacc444582
cca59ed6978ee5e6f6f440da63e14eedd28e76d7
/DSA/tpW-QB4ATMqVvkAeAHzKtw_df9ba297ee0745fb8e40b00bde601ded_course1_2020_05_28/week3_greedy_algorithms/1_money_change/change.cpp
2f7e0453aeaf3fcd84dec9da3eacb661b10a1489
[]
no_license
ach-in/moocs
f0d4ab06443442f48df66dad738077c4e13ee66d
6799041ced3506818bf70a5a68b9c283db465808
refs/heads/master
2022-12-01T05:11:59.214070
2020-08-25T21:27:48
2020-08-25T21:27:48
287,500,318
1
0
null
null
null
null
UTF-8
C++
false
false
296
cpp
#include <iostream> int get_change(int m) { //write your code here int n = 0; while(m!=0){ if(m>=10){ m-=10; n++; } else if(m>=5){ m-=5; n++; } else{ m-=1; n++; } } return n; } int main() { int m; std::cin >> m; std::cout << get_change(m) << '\n'; }
[ "achinparashar1000@gmail.com" ]
achinparashar1000@gmail.com
ae6f282ef705101cf4eb36c21886e246d3361d9b
9037aae803aa3b42e73bcb137410d24dd064d450
/service-api/src/thrift/gen-cpp/User_types.cpp
10ffe270f45e5120a54b12cc8fa3f69eb95e4a59
[]
no_license
Vann7/xjll_service
c0a626ab9ef11653fa08038355bc2c96e6a3cc63
8815f204e7e5b89a6bcdbc27667e636f40676769
refs/heads/master
2020-03-27T14:46:33.542499
2018-09-06T06:36:19
2018-09-06T06:36:19
146,678,172
1
0
null
null
null
null
UTF-8
C++
false
true
4,000
cpp
/** * Autogenerated by Thrift Compiler (0.11.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "User_types.h" #include <algorithm> #include <ostream> #include <thrift/TToString.h> namespace com { namespace test { User::~User() throw() { } void User::__set_id(const int32_t val) { this->id = val; } void User::__set_name(const std::string& val) { this->name = val; } void User::__set_age(const int32_t val) { this->age = val; } void User::__set_home(const std::string& val) { this->home = val; } std::ostream& operator<<(std::ostream& out, const User& obj) { obj.printTo(out); return out; } uint32_t User::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { xfer += iprot->readI32(this->id); this->__isset.id = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->name); this->__isset.name = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_I32) { xfer += iprot->readI32(this->age); this->__isset.age = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->home); this->__isset.home = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t User::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); xfer += oprot->writeStructBegin("User"); xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32(this->id); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->name); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("age", ::apache::thrift::protocol::T_I32, 3); xfer += oprot->writeI32(this->age); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("home", ::apache::thrift::protocol::T_STRING, 4); xfer += oprot->writeString(this->home); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(User &a, User &b) { using ::std::swap; swap(a.id, b.id); swap(a.name, b.name); swap(a.age, b.age); swap(a.home, b.home); swap(a.__isset, b.__isset); } User::User(const User& other0) { id = other0.id; name = other0.name; age = other0.age; home = other0.home; __isset = other0.__isset; } User& User::operator=(const User& other1) { id = other1.id; name = other1.name; age = other1.age; home = other1.home; __isset = other1.__isset; return *this; } void User::printTo(std::ostream& out) const { using ::apache::thrift::to_string; out << "User("; out << "id=" << to_string(id); out << ", " << "name=" << to_string(name); out << ", " << "age=" << to_string(age); out << ", " << "home=" << to_string(home); out << ")"; } }} // namespace
[ "272921161@qq.com" ]
272921161@qq.com
5122e75cb244dd1b11bdf28da2502db735e41b69
68c1cc3785e2794a527ff949e30e8fea30f2f44d
/llap/Example/LLAPfly/llapfly/PublicUtility/CABundleLocker.cpp
2161be7447c8988343fc447f3019733690e68f45
[ "MIT" ]
permissive
jswny/LLAP
d9dc1bfe30ed83e685681791473941ed5b26a8ac
e191e7e051b0646648dce0639d429fb5676acadc
refs/heads/master
2022-04-24T13:28:07.055354
2020-04-25T05:36:36
2020-04-25T05:36:36
256,833,518
0
0
MIT
2020-04-18T19:14:49
2020-04-18T19:14:48
null
UTF-8
C++
false
false
3,312
cpp
/* File: CABundleLocker.cpp Abstract: CABundleLocker.h Version: 1.1 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2014 Apple Inc. All Rights Reserved. */ #include "CABundleLocker.h" #include <pthread.h> /* some bundle operations are not thread safe, notably CFCopyLocalizedStringFromTableInBundle */ static pthread_mutex_t sCABundleLocker = PTHREAD_MUTEX_INITIALIZER; #define RECURSIVE_LOCK 0 #if RECURSIVE_LOCK static pthread_once_t sOnce = PTHREAD_ONCE_INIT; static void InitCABundleLocker() { // have to do this because OS X lacks PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&sCABundleLocker, &attr); pthread_mutexattr_destroy(&attr); } #endif CABundleLocker::CABundleLocker() { #if RECURSIVE_LOCK pthread_once(&sOnce, InitCABundleLocker); #endif pthread_mutex_lock(&sCABundleLocker); } CABundleLocker::~CABundleLocker() { pthread_mutex_unlock(&sCABundleLocker); }
[ "sk461236626@163.com" ]
sk461236626@163.com
eac7417b955cb0b9b30e96636949fe736ff46fb1
fb3c1e036f18193d6ffe59f443dad8323cb6e371
/src/flash/core/avmfeatures.cpp
6e3da6e98960af994aa3ea184c8b53c9516ea775
[]
no_license
playbar/nstest
a61aed443af816fdc6e7beab65e935824dcd07b2
d56141912bc2b0e22d1652aa7aff182e05142005
refs/heads/master
2021-06-03T21:56:17.779018
2016-08-01T03:17:39
2016-08-01T03:17:39
64,627,195
3
1
null
null
null
null
UTF-8
C++
false
false
5,033
cpp
// DO NOT EDIT THIS FILE // // This file has been generated by the script core/avmfeatures.as, // from a set of configuration parameters in that file. // // If you feel you need to make changes below, instead edit the configuration // file and rerun it to get a new version of this file. // // ***** BEGIN LICENSE BLOCK ***** // Version: MPL 1.1/GPL 2.0/LGPL 2.1 // // The contents of this file are subject to the Mozilla Public License Version // 1.1 (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.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // The Original Code is [Open Source Virtual Machine.]. // // The Initial Developer of the Original Code is // Adobe System Incorporated. // Portions created by the Initial Developer are Copyright (C) 2009 // the Initial Developer. All Rights Reserved. // // Contributor(s): // Adobe AS3 Team // // Alternatively, the contents of this file may be used under the terms of // either the GNU General Public License Version 2 or later (the "GPL"), or // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), // in which case the provisions of the GPL or the LGPL are applicable instead // of those above. If you wish to allow use of your version of this file only // under the terms of either the GPL or the LGPL, and not to allow others to // use your version of this file under the terms of the MPL, indicate your // decision by deleting the provisions above and replace them with the notice // and other provisions required by the GPL or the LGPL. If you do not delete // the provisions above, a recipient may use your version of this file under // the terms of any one of the MPL, the GPL or the LGPL. // // ***** END LICENSE BLOCK **** #include "avmplus.h" #ifdef AVMSHELL_BUILD // The string avmfeatures contains the names of all features that were enabled // when the program was compiled. Each feature name is terminated by a semicolon. const char * const avmfeatures = "" #if AVMSYSTEM_32BIT "AVMSYSTEM_32BIT;" #endif #if AVMSYSTEM_64BIT "AVMSYSTEM_64BIT;" #endif #if AVMSYSTEM_BIG_ENDIAN "AVMSYSTEM_BIG_ENDIAN;" #endif #if AVMSYSTEM_LITTLE_ENDIAN "AVMSYSTEM_LITTLE_ENDIAN;" #endif #if AVMSYSTEM_DOUBLE_MSW_FIRST "AVMSYSTEM_DOUBLE_MSW_FIRST;" #endif #if AVMSYSTEM_ARM_FPU "AVMSYSTEM_ARM_FPU;" #endif #if AVMSYSTEM_IA32 "AVMSYSTEM_IA32;" #endif #if AVMSYSTEM_AMD64 "AVMSYSTEM_AMD64;" #endif #if AVMSYSTEM_ARM "AVMSYSTEM_ARM;" #endif #if AVMSYSTEM_PPC "AVMSYSTEM_PPC;" #endif #if AVMSYSTEM_SPARC "AVMSYSTEM_SPARC;" #endif #if AVMSYSTEM_MIPS "AVMSYSTEM_MIPS;" #endif #if AVMSYSTEM_UNIX "AVMSYSTEM_UNIX;" #endif #if AVMSYSTEM_MAC "AVMSYSTEM_MAC;" #endif #if AVMSYSTEM_WIN32 "AVMSYSTEM_WIN32;" #endif #if AVMSYSTEM_SYMBIAN "AVMSYSTEM_SYMBIAN;" #endif #if AVMFEATURE_DEBUGGER "AVMFEATURE_DEBUGGER;" #endif #if AVMFEATURE_ALLOCATION_SAMPLER "AVMFEATURE_ALLOCATION_SAMPLER;" #endif #if AVMFEATURE_VTUNE "AVMFEATURE_VTUNE;" #endif #if AVMFEATURE_JIT "AVMFEATURE_JIT;" #endif #if AVMFEATURE_AOT "AVMFEATURE_AOT;" #endif #if AVMFEATURE_ABC_INTERP "AVMFEATURE_ABC_INTERP;" #endif #if AVMFEATURE_WORDCODE_INTERP "AVMFEATURE_WORDCODE_INTERP;" #endif #if AVMFEATURE_THREADED_INTERP "AVMFEATURE_THREADED_INTERP;" #endif #if AVMFEATURE_SELFTEST "AVMFEATURE_SELFTEST;" #endif #if AVMFEATURE_EVAL "AVMFEATURE_EVAL;" #endif #if AVMFEATURE_PROTECT_JITMEM "AVMFEATURE_PROTECT_JITMEM;" #endif #if AVMFEATURE_SHARED_GCHEAP "AVMFEATURE_SHARED_GCHEAP;" #endif #if AVMFEATURE_USE_SYSTEM_MALLOC "AVMFEATURE_USE_SYSTEM_MALLOC;" #endif #if AVMFEATURE_CPP_EXCEPTIONS "AVMFEATURE_CPP_EXCEPTIONS;" #endif #if AVMFEATURE_INTERIOR_POINTERS "AVMFEATURE_INTERIOR_POINTERS;" #endif #if AVMFEATURE_JNI "AVMFEATURE_JNI;" #endif #if AVMFEATURE_HEAP_ALLOCA "AVMFEATURE_HEAP_ALLOCA;" #endif #if AVMFEATURE_STATIC_FUNCTION_PTRS "AVMFEATURE_STATIC_FUNCTION_PTRS;" #endif #if AVMFEATURE_INDIRECT_NATIVE_THUNKS "AVMFEATURE_INDIRECT_NATIVE_THUNKS;" #endif #if AVMFEATURE_OVERRIDE_GLOBAL_NEW "AVMFEATURE_OVERRIDE_GLOBAL_NEW;" #endif #if AVMFEATURE_MEMORY_PROFILER "AVMFEATURE_MEMORY_PROFILER;" #endif #if AVMFEATURE_CACHE_GQCN "AVMFEATURE_CACHE_GQCN;" #endif #if AVMFEATURE_API_VERSIONING "AVMFEATURE_API_VERSIONING;" #endif ; #endif // AVMSHELL_BUILD
[ "hgl868@126.com" ]
hgl868@126.com
2d770f576753e2f5480f4c2f3fc9d984f995238e
52e74962932b8f41d56c8228269183623d51693d
/Count Univalue Subtrees.cpp
8545c0e00186ba3ee1a79d1e1a79665ba3be09b1
[]
no_license
huston66/Leetcode
be63bab22216c62a69281e6955d214e017099241
9d807a2de1257a8a7fe9001db73bba76adeecbbf
refs/heads/master
2021-01-18T23:52:48.242920
2016-10-17T09:06:24
2016-10-17T09:06:24
50,390,668
0
0
null
null
null
null
UTF-8
C++
false
false
623
cpp
class Solution { public: int countUnivalSubtrees(TreeNode* root) { int count=0; dfs(root,count); return count; } bool dfs(TreeNode* root,int &count){ if(root==NULL) return 1; bool left=dfs(root->left,count); bool right=dfs(root->right,count); if((left&&right)&&(root->left==NULL||root->left->val==root->val) &&(root->right==NULL||root->right->val==root->val)) { count++; return 1; } return 0; } };
[ "zhenli@Zhens-MacBook-Pro.local" ]
zhenli@Zhens-MacBook-Pro.local
71748b243672ce83f903dc31c0a8534aab5ada9d
54590b39d4710d32bc129e0e9bf59fd5f56ac32d
/SDK/SoT_bsp_plm_cluster_03_d_functions.cpp
79f0df12248339931c20448987c728460c60c612
[]
no_license
DDan1l232/SoT-SDK
bb3bb85fa813963655288d6fa2747d316ce57af8
cda078f3b8bca304759f05cc71ca55d31878e8e5
refs/heads/master
2023-03-17T13:16:11.076040
2020-09-09T15:19:09
2020-09-09T15:19:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
756
cpp
// Sea of Thieves (1.4.16) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SoT_bsp_plm_cluster_03_d_parameters.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function bsp_plm_cluster_03_d.bsp_plm_cluster_03_d_C.UserConstructionScript // (Event, Public, BlueprintCallable, BlueprintEvent) void Absp_plm_cluster_03_d_C::UserConstructionScript() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function bsp_plm_cluster_03_d.bsp_plm_cluster_03_d_C.UserConstructionScript")); struct { } params; UObject::ProcessEvent(fn, &params); } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "53855178+Shat-sky@users.noreply.github.com" ]
53855178+Shat-sky@users.noreply.github.com
2ce081233676c972cc8885fcb26c9b7e5a52fdee
c057e033602e465adfa3d84d80331a3a21cef609
/C/testcases/CWE127_Buffer_Underread/s03/CWE127_Buffer_Underread__new_wchar_t_loop_32.cpp
5878a9f24605c668c008ee9f7c0e5ab95bef60e9
[]
no_license
Anzsley/My_Juliet_Test_Suite_v1.3_for_C_Cpp
12c2796ae7e580d89e4e7b8274dddf920361c41c
f278f1464588ffb763b7d06e2650fda01702148f
refs/heads/main
2023-04-11T08:29:22.597042
2021-04-09T11:53:16
2021-04-09T11:53:16
356,251,613
1
0
null
null
null
null
UTF-8
C++
false
false
3,946
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE127_Buffer_Underread__new_wchar_t_loop_32.cpp Label Definition File: CWE127_Buffer_Underread__new.label.xml Template File: sources-sink-32.tmpl.cpp */ /* * @description * CWE: 127 Buffer Under-read * BadSource: Set data pointer to before the allocated memory buffer * GoodSource: Set data pointer to the allocated memory buffer * Sink: loop * BadSink : Copy data to string using a loop * Flow Variant: 32 Data flow using two pointers to the same value within the same function * * */ #include "std_testcase.h" #include <wchar.h> namespace CWE127_Buffer_Underread__new_wchar_t_loop_32 { #ifndef OMITBAD void bad() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; { wchar_t * data = *dataPtr1; { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FLAW: Set data pointer to before the allocated memory buffer */ data = dataBuffer - 8; } *dataPtr1 = data; } { wchar_t * data = *dataPtr2; { size_t i; wchar_t dest[100]; wmemset(dest, L'C', 100-1); /* fill with 'C's */ dest[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ for (i = 0; i < 100; i++) { dest[i] = data[i]; } /* Ensure null termination */ dest[100-1] = L'\0'; printWLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by new [] so can't safely call delete [] on it */ } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2B() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; { wchar_t * data = *dataPtr1; { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FIX: Set data pointer to the allocated memory buffer */ data = dataBuffer; } *dataPtr1 = data; } { wchar_t * data = *dataPtr2; { size_t i; wchar_t dest[100]; wmemset(dest, L'C', 100-1); /* fill with 'C's */ dest[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ for (i = 0; i < 100; i++) { dest[i] = data[i]; } /* Ensure null termination */ dest[100-1] = L'\0'; printWLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by new [] so can't safely call delete [] on it */ } } } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE127_Buffer_Underread__new_wchar_t_loop_32; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "65642214+Anzsley@users.noreply.github.com" ]
65642214+Anzsley@users.noreply.github.com
42420aea5678a3bcd04ca82fa7466da05ba99cd6
4e0e8f17ab6808483fe98c1f2ae6f7dae9780ef9
/src/Servers/IIS/AspNetCoreModuleV2/CommonLib/StandardStreamRedirection.h
40250933f6112330481304d021c99ee1c380181b
[ "Apache-2.0" ]
permissive
tin0819tin/aspnetcore
8159cf9be840bc455843f42241cfc9c4bb185347
e4e5f20500c80dd047f76462d9b99a85709edd18
refs/heads/main
2023-02-19T11:04:33.774876
2021-01-23T05:10:23
2021-01-23T05:10:23
332,164,474
7
0
Apache-2.0
2021-01-23T08:40:23
2021-01-23T08:40:22
null
UTF-8
C++
false
false
1,447
h
// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. #pragma once #include "RedirectionOutput.h" #include "StdWrapper.h" #include "ModuleHelpers.h" class StandardStreamRedirection : NonCopyable { // Timeout to be used if a thread never exits #define PIPE_OUTPUT_THREAD_TIMEOUT 2000 #define PIPE_READ_SIZE 4096 public: StandardStreamRedirection(RedirectionOutput& output, bool commandLineLaunch); ~StandardStreamRedirection() noexcept(false); private: void Start(); void Stop(); void TryStartRedirection() { try { Start(); } catch (...) { OBSERVE_CAUGHT_EXCEPTION(); } } void TryStopRedirection() { try { Stop(); } catch (...) { OBSERVE_CAUGHT_EXCEPTION(); } } // Thread functions void ReadStdErrHandleInternal(); static void ReadStdErrHandle(LPVOID pContext); HANDLE m_hErrReadPipe; HANDLE m_hErrWritePipe; HANDLE m_hErrThread; bool m_disposed; bool m_commandLineLaunch; SRWLOCK m_srwLock{}; std::unique_ptr<StdWrapper> stdoutWrapper; std::unique_ptr<StdWrapper> stderrWrapper; RedirectionOutput& m_output; };
[ "noreply@github.com" ]
tin0819tin.noreply@github.com
e7213cc85e18a8d1b5777847b00fbd6df595a936
2a13ef8aac640723d81f8dc28d7a9f9b9481cf17
/Kernel/FileSystem/AnonymousFile.cpp
a0fa76fd426fb0a7710b629595e5ad7abce12873
[ "BSD-2-Clause" ]
permissive
gchenfly/serenity
e2eee85c1445269a8790afe76d597b54879abea6
02cca9276315ac4e92083e1e25edf3e760f433ff
refs/heads/master
2023-02-23T07:07:20.514241
2021-01-24T21:01:39
2021-01-24T21:24:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,060
cpp
/* * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <Kernel/FileSystem/AnonymousFile.h> #include <Kernel/Process.h> #include <Kernel/VM/AnonymousVMObject.h> namespace Kernel { AnonymousFile::AnonymousFile(NonnullRefPtr<AnonymousVMObject> vmobject) : m_vmobject(move(vmobject)) { } AnonymousFile::~AnonymousFile() { } KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot, bool shared) { if (offset != 0) return EINVAL; if (size != m_vmobject->size()) return EINVAL; return process.allocate_region_with_vmobject(preferred_vaddr, size, m_vmobject, offset, {}, prot, shared); } }
[ "kling@serenityos.org" ]
kling@serenityos.org
9fea3960960f63ce4479f6546ebcc96584345cbc
b350b1193f350c349923e0a7baeed08ddf6d8cfd
/Cpp_Algorithms/BinaryTreeInorderTraversal/inorder_traversal.cc
7f589dd337262197322fc5d7a989deb291b02df3
[]
no_license
Oscarchoi/CodeExamples
98c326f56cc403679e1a463895acb23d2e8384ee
716a6ac2a6549068fd109f0a36f8abcbf44f1cf9
refs/heads/master
2023-09-01T06:18:09.427283
2021-11-03T16:30:46
2021-11-03T16:30:46
262,495,049
0
0
null
null
null
null
UTF-8
C++
false
false
684
cc
#include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} }; class Solution { public: vector<int> inorderTraversal(TreeNode *root) { vector<int> res; inOrder(root, res); return res; } void inOrder(TreeNode *node, vector<int> &res) { if (!node) return; if (node->left) inOrder(node->left, res); res.push_back(node->val); if (node->right) inOrder(node->right, res); } };
[ "wychoi502@gmail.com" ]
wychoi502@gmail.com
0a585c6cf2ec3350c6aeee747399fa8d716b9403
2cb3e1435380226bc019f9c4970be871fd54288e
/opencv/build/modules/core/stat.simd_declarations.hpp
5b7be13473b1fb5376736af6201415deb0a2397e
[ "Apache-2.0" ]
permissive
35048542/opencv-contrib-ARM64
0db9f49721055f8597dd766ee8749be68054c526
25386df773f88a071532ec69ff541c31e62ec8f2
refs/heads/main
2023-07-20T10:43:13.265246
2021-08-24T13:55:38
2021-08-24T13:55:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
170
hpp
#define CV_CPU_SIMD_FILENAME "/home/epasholl/opencv/opencv-master/modules/core/src/stat.simd.hpp" #define CV_CPU_DISPATCH_MODES_ALL BASELINE #undef CV_CPU_SIMD_FILENAME
[ "epasholl@umich.edu" ]
epasholl@umich.edu
703566c0ff4f72b9764234e7ef2f7d96aa8afc58
11bd8cd22a7d928b7bcd6cf09feffc295d3482d0
/src/3GModemConnect/CtrlTraffic.h
d39d8820069b3bf9983a009aade11305690b8507
[ "MIT" ]
permissive
amroibrahim/3GModem
7f16a84f8472bfa588bf487c9771aa1282ed3c2c
a7530c712c34fbc0c46a6bc34febd29e4696d06b
refs/heads/master
2021-09-06T16:54:15.682644
2018-02-08T19:19:08
2018-02-08T19:19:08
106,882,175
4
1
null
null
null
null
UTF-8
C++
false
false
553
h
#pragma once #include <vector> // CTraffic class CCtrlTraffic : public CStatic { DECLARE_DYNAMIC(CCtrlTraffic) public: CCtrlTraffic(); virtual ~CCtrlTraffic(); int GetMaxSpeed(void); void SetUpload(float m_fUpload); void SetDownload(float m_fDownload); void AddDownload(int iDownload); void AddUpload(int iUpload); afx_msg void OnPaint(); protected: DECLARE_MESSAGE_MAP() private: std::vector<int> m_vDownloads; std::vector<int> m_vUploads; float m_fDownloadSpeed; float m_fUploadSpeed; };
[ "noreply@github.com" ]
amroibrahim.noreply@github.com
3f816e7a2a9b3f9d9bea59b9db423e4e3db5068b
5f27976c89df498ace71ffa942264e98463cd145
/test/insert.cc
ebe5bad93cb9828f14f9cae6c2c5410a33bde7d3
[ "Zlib", "BSD-3-Clause", "Apache-2.0", "MIT", "BSD-2-Clause" ]
permissive
jangocheng/DTC
98b509733104da77616f12145f276154e9c97c0b
08ed99431c94a6c191bfb4a22af24d3eed93ed8d
refs/heads/master
2023-07-25T01:22:33.389665
2021-09-02T02:22:59
2021-09-02T02:22:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,241
cc
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string> #include <unistd.h> #include "dtcapi.h" void insert(DTC::Server server) { int retCode = 0; DTC::InsertRequest insertReq(&server); DTC::Result stResult; insertReq.set_key(1); insertReq.Set("uid", 1); insertReq.Set("name", "norton"); insertReq.Set("city", "shanghai"); insertReq.Set("age", 18); insertReq.Set("sex", 1); retCode = insertReq.do_execute(stResult); if (retCode != 0) printf("retCode:%d, errmsg:%s, errfrom:%s\n", retCode, stResult.get_error_message(), stResult.get_error_from()); else printf("insert success!\n"); } int main(int argc, char *argv[]) { /* 只要server不析构,后台会保持长连接 */ DTC::Server server; /* 设置的dtc的ip和端口 */ server.set_address("127.0.0.1", "20015"); /* 设置网络超时时间,单次网络IO的超时,单位秒 */ server.SetTimeout(5); /* 设置访问码 AccessToken,在申请dtc实例的时候网站端会生成 */ // server.set_accesskey("000022907e64e117fa92f892a85307782a68afc6"); /* 设置dtc的表名 */ server.set_table_name("dtc_opensource"); /* 声明key类型 */ server.int_key(); insert(server); return 0; }
[ "noreply@github.com" ]
jangocheng.noreply@github.com
b34513dae9dd5334c3394686f4ed7b36ff54b905
f77d436de9db3ec3d0b9cba8baf90895409f5b89
/Term 2/CarND-PID-Control-Project-master/src/PID.h
64d1b974950b75f645b131a37e94eff0fab7d81a
[]
no_license
markusmeyerhofer/SelfDrivingCarND
ecea9f13b018db0df8a718a6c0a8f52818ba04ea
9421fc46b2a05fb9ca5c7aebd18ca4101d019d4c
refs/heads/master
2020-07-04T06:10:21.617199
2019-08-13T16:17:43
2019-08-13T16:17:43
202,181,551
0
0
null
null
null
null
UTF-8
C++
false
false
564
h
#ifndef PID_H #define PID_H class PID { public: /* * Errors */ //private: double p_error; double i_error; double d_error; /* * Coefficients */ double Kp; double Ki; double Kd; public: /* * Constructor */ PID(); /* * Destructor. */ virtual ~PID(); /* * Initialize PID. */ void Init(double Kp, double Ki, double Kd); /* * Update the PID error variables given cross track error. */ void UpdateError(double cte); /* * Calculate the total PID error. */ double TotalError(); }; #endif /* PID_H */
[ "markus.meyerhofer@me.com" ]
markus.meyerhofer@me.com
377b5b927a8ef86fca9652ccd1f1ba88e05034ac
6c40203055fe652f238fb5f3befaa0d04a788d65
/src/armnn/layers/BatchNormalizationLayer.hpp
d8082e5e98662c58524b3704dcc49d4109b3ac61
[ "MIT" ]
permissive
Air000/armnn_s32v
9243f2e8d63b9691b9c7873a54b29ac5a79d2b14
ec3ee60825d6b7642a70987c4911944cef7a3ee6
refs/heads/master
2020-03-27T15:32:37.975405
2018-09-01T14:11:34
2018-09-01T14:11:34
146,724,624
1
1
null
null
null
null
UTF-8
C++
false
false
1,005
hpp
// // Copyright © 2017 Arm Ltd. All rights reserved. // See LICENSE file in the project root for full license information. // #pragma once #include "LayerWithParameters.hpp" namespace armnn { class ScopedCpuTensorHandle; class BatchNormalizationLayer : public LayerWithParameters<BatchNormalizationDescriptor> { public: std::unique_ptr<ScopedCpuTensorHandle> m_Mean; std::unique_ptr<ScopedCpuTensorHandle> m_Variance; std::unique_ptr<ScopedCpuTensorHandle> m_Beta; std::unique_ptr<ScopedCpuTensorHandle> m_Gamma; virtual std::unique_ptr<IWorkload> CreateWorkload(const Graph& graph, const IWorkloadFactory& factory) const override; BatchNormalizationLayer* Clone(Graph& graph) const override; void ValidateTensorShapesFromInputs() override; protected: BatchNormalizationLayer(const BatchNormalizationDescriptor& param, const char* name); ~BatchNormalizationLayer() = default; }; } // namespace
[ "telmo.soares@arm.com" ]
telmo.soares@arm.com
f9c23d0d8bb0b24e415c44057753d70719c03925
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/windows/richedit/re30/_ime.h
381c6669f83c87732a6fdd0d23f929668b4fcfd3
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
10,825
h
/* * @doc INTERNAL * * @module _ime.h -- support for IME APIs | * * Purpose: * Most everything to do with FE composition string editing passes * through here. * * Authors: <nl> * Jon Matousek <nl> * Justin Voskuhl <nl> * Hon Wah Chan <nl> * * History: <nl> * 10/18/1995 jonmat Cleaned up level 2 code and converted it into * a class hierarchy supporting level 3. * * Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved. * */ #ifndef _IME_H #define _IME_H class CTextMsgFilter; // defines for IME Level 2 and 3 #define IME_LEVEL_2 2 #define IME_LEVEL_3 3 #define IME_PROTECTED 4 /* * IME * * @class base class for IME support. * * @devnote * For level 2, at caret IMEs, the IME will draw a window directly over the text giving the * impression that the text is being processed by the application--this is called pseudo inline. * All UI is handled by the IME. This mode is currenlty bypassed in favor of level 3 true inline (TI); * however, it would be trivial to allow a user preference to select this mode. Some IMEs may have * a "special" UI, in which case level 3 TI is *NOT* used, necessitating level 2. * * For level 2, near caret IMEs, the IME will draw a very small and obvious window near the current * caret position in the document. This currently occurs for PRC(?) and Taiwan. * All UI is handled by the IME. * * For level 3, at caret IMEs, the composition string is drawn by the application, which is called * true inline, bypassing the level 2 "composition window". * Currently, we allow the IME to support all remaining UI *except* drawing of the composition string. */ class CIme { friend LRESULT OnGetIMECompositionMode ( CTextMsgFilter &TextMsgFilter ); friend HRESULT CompositionStringGlue ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); friend HRESULT EndCompositionGlue ( CTextMsgFilter &TextMsgFilter, BOOL fForceDelete); friend void CheckDestroyIME ( CTextMsgFilter &TextMsgFilter ); //@access Protected data protected: short _imeLevel; //@cmember IME Level 2 or 3 short _cIgnoreIMECharMsg; //@cmember Level 2 IME use to eat WM_IME_CHAR message short _fIgnoreEndComposition; //@cmember ignore the next End Composition message short _fIMETerminated; //@cmember indicate this IME has been terminated short _fSkipFirstOvertype; //@cmember skip first overtype if selection is // deleted on StartComposition //@access Public methods public: virtual ~CIme() {}; INT _compMessageRefCount; //@cmember so as not to delete if recursed. short _fDestroy; //@cmember set when object wishes to be deleted. //@cmember Handle WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle WM_IME_COMPOSITION and WM_IME_ENDCOMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fCCompWindow ) = 0; virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) = 0; enum TerminateMode { TERMINATE_NORMAL = 1, TERMINATE_FORCECANCEL = 2 }; void TerminateIMEComposition(CTextMsgFilter &TextMsgFilter, CIme::TerminateMode mode); //@cmember Terminate current IME composition session. //@cmember check if we need to ignore WM_IME_CHAR messages BOOL IgnoreIMECharMsg() { return _cIgnoreIMECharMsg > 0; } //@cmember skip WM_IME_CHAR message void SkipIMECharMsg() { _cIgnoreIMECharMsg--; } //@cmember accept WM_IME_CHAR message void AcceptIMECharMsg() { _cIgnoreIMECharMsg = 0; } static void CheckKeyboardFontMatching ( long cp, CTextMsgFilter &TextMsgFilter, ITextFont *pTextFont ); //@cmember Check current font/keyboard matching. BOOL IsTerminated () //@cmember Return _fIMETerminated { return _fIMETerminated; } INT GetIMELevel () //@cmember Return the current IME level. { return _imeLevel; } //@access Protected methods protected: //@cmember Get composition string, convert to unicode. static INT GetCompositionStringInfo( HIMC hIMC, DWORD dwIndex, WCHAR *uniCompStr, INT cchUniCompStr, BYTE *attrib, INT cbAttrib, LONG *cursorCP, LONG *cchAttrib, UINT kbCodePage, BOOL bUnicodeIME, BOOL bUsingAimm ); static HRESULT CheckInsertResultString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter, short *pcch = NULL ); void SetCompositionFont ( CTextMsgFilter &TextMsgFilter, ITextFont *pTextFont ); //@cmember Setup for level 2 and 3 composition and candidate window's font. void SetCompositionForm ( CTextMsgFilter &TextMsgFilter ); //@cmember Setup for level 2 IME composition window's position. }; /* * IME_Lev2 * * @class Level 2 IME support. * */ class CIme_Lev2 : public CIme { //@access Public methods public: //@cmember Handle level 2 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 2 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 2 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fIgnore ); virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} CIme_Lev2( CTextMsgFilter &TextMsgFilter ); virtual ~CIme_Lev2(); ITextFont *_pTextFont; //@cmember base format }; /* * IME_PROTECTED * * @class IME_PROTECTED * */ class CIme_Protected : public CIme { //@access Public methods public: //@cmember Handle level 2 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ) {_imeLevel = IME_PROTECTED; return S_OK;} //@cmember Handle level 2 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ) {} //@cmember Handle level 2 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fIgnore ) {return S_FALSE;} virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} }; /* * IME_Lev3 * * @class Level 3 IME support. * */ class CIme_Lev3 : public CIme_Lev2 { //@access Private data private: //@access Protected data protected: long _ichStart; //@cmember maintain starting ich. long _cchCompStr; //@cmember maintain composition string's cch. short _sIMESuportMouse; //@cmember IME mouse support WPARAM _wParamBefore; //@cmember Previous wParam sent to IME HWND _hwndIME; //@cmember current IME hWnd long _crTextColor; //@cmember current font text color long _crBkColor; //@cmember current font background color // Helper function //@cmember get imeshare color for the attribute COLORREF GetIMEShareColor(CIMEShare *pIMEShare, DWORD dwAttribute, DWORD dwProperty); //@access Public methods public: //@cmember Handle level 3 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 3 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 3 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fCCompWindow ); void SetCompositionStyle ( CTextMsgFilter &TextMsgFilter, UINT attribute, ITextFont *pTextFont ); CIme_Lev3( CTextMsgFilter &TextMsgFilter ); virtual ~CIme_Lev3() {}; virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ); virtual BOOL IMESupportMouse ( CTextMsgFilter &TextMsgFilter ); public: short _fUpdateWindow; //@cmember Update Window after closing CandidateWindow long GetIMECompositionStart() { return _ichStart; } long GetIMECompositionLen() { return _cchCompStr; } }; /* * Special IME_Lev3 for Korean Hangeul -> Hanja conversion * * @class Hangual IME support. * */ class CIme_HangeulToHanja : public CIme_Lev3 { //@access Private data private: public: CIme_HangeulToHanja( CTextMsgFilter &TextMsgFilter ); //@cmember Handle Hangeul WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle Hangeul WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} }; // Glue functions to call the respective methods of an IME object stored in the ed. HRESULT StartCompositionGlue ( CTextMsgFilter &TextMsgFilter ); HRESULT CompositionStringGlue ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); HRESULT EndCompositionGlue ( CTextMsgFilter &TextMsgFilter, BOOL fForceDelete); void PostIMECharGlue ( CTextMsgFilter &TextMsgFilter ); HRESULT IMENotifyGlue ( const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); // @parm the containing text edit. HRESULT IMEMouseCheck(CTextMsgFilter &TextMsgFilter, UINT *pmsg, WPARAM *pwparam, LPARAM *plparam, LRESULT *plres); // IME helper functions. void IMECompositionFull ( CTextMsgFilter &TextMsgFilter ); LRESULT OnGetIMECompositionMode ( CTextMsgFilter &TextMsgFilter ); BOOL IMECheckGetInvertRange(CTextMsgFilter *ed, LONG &, LONG &); void CheckDestroyIME ( CTextMsgFilter &TextMsgFilter ); BOOL IMEHangeulToHanja ( CTextMsgFilter &TextMsgFilter ); BOOL IMEMessage ( CTextMsgFilter &TextMsgFilter, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bPostMessage ); HIMC LocalGetImmContext ( CTextMsgFilter &TextMsgFilter ); void LocalReleaseImmContext ( CTextMsgFilter &TextMsgFilter, HIMC hIMC ); long IMEShareToTomUL ( UINT ulID ); #endif // define _IME_H
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
b8fb6b1611a86c1e0a30e6929c9e3b6bcca5e044
67f988dedfd8ae049d982d1a8213bb83233d90de
/external/chromium/ui/gfx/rect_f.cc
d7b1089c96de6c556d3fc08b85ebc2e1fe86c4cd
[ "BSD-3-Clause" ]
permissive
opensourceyouthprogramming/h5vcc
94a668a9384cc3096a365396b5e4d1d3e02aacc4
d55d074539ba4555e69e9b9a41e5deb9b9d26c5b
refs/heads/master
2020-04-20T04:57:47.419922
2019-02-12T00:56:14
2019-02-12T00:56:14
168,643,719
1
1
null
2019-02-12T00:49:49
2019-02-01T04:47:32
C++
UTF-8
C++
false
false
2,013
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/gfx/rect_f.h" #include <algorithm> #include "base/logging.h" #include "base/stringprintf.h" #include "ui/gfx/insets_f.h" #include "ui/gfx/rect_base_impl.h" #include "ui/gfx/safe_integer_conversions.h" namespace gfx { template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> RectBaseT; bool RectF::IsExpressibleAsRect() const { return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); } std::string RectF::ToString() const { return base::StringPrintf("%s %s", origin().ToString().c_str(), size().ToString().c_str()); } RectF operator+(const RectF& lhs, const Vector2dF& rhs) { RectF result(lhs); result += rhs; return result; } RectF operator-(const RectF& lhs, const Vector2dF& rhs) { RectF result(lhs); result -= rhs; return result; } RectF IntersectRects(const RectF& a, const RectF& b) { RectF result = a; result.Intersect(b); return result; } RectF UnionRects(const RectF& a, const RectF& b) { RectF result = a; result.Union(b); return result; } RectF SubtractRects(const RectF& a, const RectF& b) { RectF result = a; result.Subtract(b); return result; } RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { RectF result = r; result.Scale(x_scale, y_scale); return result; } RectF BoundingRect(const PointF& p1, const PointF& p2) { float rx = std::min(p1.x(), p2.x()); float ry = std::min(p1.y(), p2.y()); float rr = std::max(p1.x(), p2.x()); float rb = std::max(p1.y(), p2.y()); return RectF(rx, ry, rr - rx, rb - ry); } } // namespace gfx
[ "rjogrady@google.com" ]
rjogrady@google.com
1da7f51ab56805344c1191b3cef509e8ff345320
8402df808a7982e7ff22a418d22cf904ac9e8c59
/DATA_STRUCTURES/bst.cpp
92780b1a4368600a2e8e8f2e5e2df634d20b9dfe
[ "MIT" ]
permissive
dskaustubh/3rd-Sem-CSE
98afa6e1eb757fa840be1f4168ec886b71084283
ee3adc32f4432452e5d5b855547440d6231b5822
refs/heads/master
2020-11-24T04:41:27.258822
2020-01-16T13:51:20
2020-01-16T13:51:20
227,969,342
0
0
null
null
null
null
UTF-8
C++
false
false
1,939
cpp
#include <iostream> using namespace std; struct node { node *lc; node *rc; int v; }; typedef node *treeptr; void insert(treeptr *head, int v) { if (*head) { if(v>(*head)->v) { insert(&(*head)->rc,v); } else { insert(&(*head)->lc,v); } } else { treeptr temp = (treeptr)malloc(sizeof(*temp)); temp ->v=v; temp->lc=nullptr; temp->rc=nullptr; *head=temp; } } void inorder(treeptr head) { if(!head) { return; } inorder(head->lc); cout<<head->v<<"\t"; inorder(head->rc); } int search(treeptr root,int k) { if(!root) { return 0; } if(k==root->v) { return 1; } else if(k>(root->v)) { return(search(root->rc,k)); } else { return(search(root->lc,k)); } } int main() { treeptr root=nullptr; int ch=1,t,r; do { cout<<"\n1.insert\n 2.display\n3.search\n4.exit\nEnter your choice: "; cin>>ch; switch(ch) { case 1:cout<<"\n Enter The element to be inserted: "; cin>>t; insert(&root,t); cout<<"\n Insertion Succesfull"; break; case 2:cout<<"\n THe tree is: "; inorder(root); break; case 3:cout<<"\n EnTer the item to key for: "; cin>>t; r=search(root,t); if(r) { cout<<"\n"<<t<<" Found in the tree!"; } else { cout<<"\n "<<t<<" not found in the tree"; } break; default:exit(0); } } while (ch!=4); }
[ "dskaustubh@gmail.com" ]
dskaustubh@gmail.com
964f53c65cc11af3855a82790fc77d8acd8cd908
323eb296cbf740ad6bf678fb15e48f0315b66824
/ps/SWEA/4613 러시아 국기 같은 깃발.cpp
11bc78b776481e7420cb7e2e5a6dbff033cd96db
[]
no_license
zziri/study
0da83d87247dafb1083b6068e9b6354cb960af0c
b0eded396c5201283db2d7f45b66d19d3f2831b4
refs/heads/master
2023-03-26T23:47:13.699539
2021-03-25T01:19:40
2021-03-25T01:19:40
152,895,651
0
0
null
null
null
null
UTF-8
C++
false
false
1,377
cpp
/** * @author Jihoon Jang */ #include <iostream> #include <memory.h> #include <algorithm> #define SIZE 51 #define INF 987654321 #define CHANGE(x) ((x == 'W') ? (x = 'B') : ((x == 'B') ? (x = 'R') : (x = 0))) using namespace std; char map[SIZE][SIZE]; int color[3]; int ans; void init(void) { ans = INF; } void input(int &n, int &m) { cin >> n >> m; for(int i=0; i<n; i++){ cin >> map[i]; } } void setColorNumber(int index, int number) { color[index] = number; } int coloring(int n, int m) { int ret = 0; int color_index = 0; char current = 'W'; for(int y=0, cnt = 0; y<n; y++, cnt++){ if(cnt == color[color_index]){ CHANGE(current); color_index++; cnt = 0; } for(int x=0; x<m; x++){ if(map[y][x] != current) ret++; } } return ret; } void createColor(int depth, int remain, int n, int m) { if(depth == 2){ // base case setColorNumber(depth, remain); ans = min(ans, coloring(n, m)); return; } int limit = remain + depth - 2; for(int i=1; i<=limit; i++){ setColorNumber(depth, i); createColor(depth+1, remain-i, n, m); } } int main(void) { //freopen("input.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; for(int tc=1; tc<=t; tc++){ int n, m; init(); input(n, m); createColor(0, n, n, m); cout << "#" << tc << " " << ans << '\n'; } return 0; }
[ "jihzang@naver.com" ]
jihzang@naver.com
1929dc6e742d2a9a900cc6eb6c5c44e626f1fa88
4c7c9592e056c80f3499cdcbe16be8fa49321ad1
/Game/MissileManager.cpp
bb8e1d4be3cb8a1218892c6804c4156ebbf0570f
[]
no_license
Karrietje/Galaga
00646c2983c189943b7872c686884d2a3cd52c40
a4b5fe2de5bfebb372179b94d924a8c25d5e9710
refs/heads/main
2023-07-09T05:40:10.434977
2021-08-23T02:56:15
2021-08-23T02:56:15
397,385,490
0
0
null
null
null
null
UTF-8
C++
false
false
1,364
cpp
#include "MissileManager.h" #include "GameObject.h" #include "Components.h" #include "GalagaComponents.h" #include "SceneManager.h" #include "Scene.h" void dae::MissileManager::SubscribeGameObject(Scene* pScene, GameObject* pGameObject, bool isEnemy) { if (m_pMissiles.find(pGameObject) != m_pMissiles.end()) return; m_pMissiles.insert(std::make_pair(pGameObject, std::vector<MissileComponent*>())); for (int i{}; i < 2; i++) { GameObject* pMissile = new GameObject(); MissileComponent* pMissileComponent = new MissileComponent(isEnemy); pMissile->AddComponent(ComponentType::MissileComponent, pMissileComponent); m_pMissiles.at(pGameObject).push_back(pMissileComponent); pScene->Add(pMissile, 3); } } bool dae::MissileManager::ShootMissile(GameObject* pGameObject) { for (MissileComponent* pMissile : m_pMissiles.at(pGameObject)) { GameObject* pMissileObject{ pMissile->GetGameObject() }; if (!pMissileObject->IsActive()) { pMissileObject->GetTransform()->SetPosition(pGameObject->GetTransform()->GetPosition()); pMissileObject->SetActive(true); return true; } } return false; } void dae::MissileManager::Reset() { for (std::pair<GameObject*, std::vector<MissileComponent*>> missiles : m_pMissiles) { for (MissileComponent* pMissile : missiles.second) { pMissile->GetGameObject()->SetActive(false); } } }
[ "44691800+Karrietje@users.noreply.github.com" ]
44691800+Karrietje@users.noreply.github.com
bef26b34d1180a2493c7decd3f29552ecc92a581
d0985731c45024388a2d8938a9e8a52dc7f985f3
/src/server/game/Warden/WardenMac.cpp
376de48f9cf6199089aa921f8423b5fb65222d1a
[]
no_license
Naios/MythCore
1ac1096ad8afefdf743ed206e10c2432f7f57bed
38acab976959eed1167b6b4438ce7c7075156dd8
refs/heads/master
2023-08-24T08:26:26.657783
2012-06-07T05:24:00
2012-06-07T05:24:00
4,604,578
1
1
null
null
null
null
UTF-8
C++
false
false
6,364
cpp
/* * Copyright (C) 2008 - 2011 Trinity <http://www.trinitycore.org/> * * Copyright (C) 2010 - 2012 Myth Project <http://mythprojectnetwork.blogspot.com/> * * Myth Project's source is based on the Trinity Project source, you can find the * link to that easily in Trinity Copyrights. Myth Project is a private community. * To get access, you either have to donate or pass a developer test. * You can't share Myth Project's sources! Only for personal use. */ #include "WardenKeyGeneration.h" #include "Common.h" #include "WorldPacket.h" #include "WorldSession.h" #include "Log.h" #include "Opcodes.h" #include "ByteBuffer.h" #include <openssl/md5.h> #include "World.h" #include "Config.h" #include "Player.h" #include "Util.h" #include "WardenMac.h" #include "WardenModuleMac.h" WardenMac::WardenMac() { } WardenMac::~WardenMac() { } void WardenMac::Init(WorldSession* pClient, BigNumber* K) { Client = pClient; // Generate Warden Key SHA1Randx WK(K->AsByteArray(), K->GetNumBytes()); WK.generate(InputKey, 16); WK.generate(OutputKey, 16); uint8 mod_seed[16] = { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE }; memcpy(Seed, mod_seed, 16); iCrypto.Init(InputKey); oCrypto.Init(OutputKey); sLog->outStaticDebug("Server side warden for client %u initializing...", pClient->GetAccountId()); //PrintHexArray(" C->S Key: ", InputKey, 16, true); //PrintHexArray(" S->C Key: ", OutputKey, 16, true); //PrintHexArray(" Seed: ", Seed, 16, true); sLog->outStaticDebug("Loading Module..."); Module = GetModuleForClient(); PrintHexArray(" Module Key: ", Module->Key, 16, true); PrintHexArray(" Module ID: ", Module->ID, 16, true); RequestModule(); } ClientWardenModule* WardenMac::GetModuleForClient() { ClientWardenModule* mod = new ClientWardenModule; uint32 len = sizeof(Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data); // data assign mod->CompressedSize = len; mod->CompressedData = new uint8[len]; memcpy(mod->CompressedData, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Data, len); memcpy(mod->Key, Module_0DBBF209A27B1E279A9FEC5C168A15F7_Key, 16); // md5 hash MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, mod->CompressedData, len); MD5_Final((uint8*)&mod->ID, &ctx); return mod; } void WardenMac::InitializeModule() { sLog->outStaticDebug("Initialize module"); } void WardenMac::RequestHash() { sLog->outStaticDebug("Request hash"); // Create packet structure WardenHashRequest Request; Request.Command = WARDEN_SMSG_HASH_REQUEST; memcpy(Request.Seed, Seed, 16); // Encrypt with warden RC4 key. EncryptData((uint8*)&Request, sizeof(WardenHashRequest)); WorldPacket pkt(SMSG_WARDEN_DATA, sizeof(WardenHashRequest)); pkt.append((uint8*)&Request, sizeof(WardenHashRequest)); Client->SendPacket(&pkt); } void WardenMac::HandleHashResult(ByteBuffer &buff) { // test int keyIn[4]; uint8 mod_seed[16] = { 0x4D, 0x80, 0x8D, 0x2C, 0x77, 0xD9, 0x05, 0xC4, 0x1A, 0x63, 0x80, 0xEC, 0x08, 0x58, 0x6A, 0xFE }; for(int i = 0; i < 4; ++i) { keyIn[i] = *(int*)(&mod_seed[0] + i * 4); } int keyOut[4]; int keyIn1, keyIn2; keyOut[0] = keyIn[0]; keyIn[0] ^= 0xDEADBEEFu; keyIn1 = keyIn[1]; keyIn[1] -= 0x35014542u; keyIn2 = keyIn[2]; keyIn[2] += 0x5313F22u; keyIn[3] *= 0x1337F00Du; keyOut[1] = keyIn1 - 0x6A028A84; keyOut[2] = keyIn2 + 0xA627E44; keyOut[3] = 0x1337F00D * keyIn[3]; // end test buff.rpos(buff.wpos()); SHA1Hash sha1; sha1.UpdateData((uint8*)keyIn, 16); sha1.Finalize(); // verify key not equal kick player if(memcmp(buff.contents() + 1, sha1.GetDigest(), 20) != 0) { sLog->outWarden("Request hash reply: failed"); if(sWorld->getBoolConfig(CONFIG_BOOL_WARDEN_KICK)) Client->KickPlayer(); return; } sLog->outStaticDebug("Request hash reply: succeed"); // change keys here memcpy(InputKey, keyIn, 16); memcpy(OutputKey, keyOut, 16); iCrypto.Init(InputKey); oCrypto.Init(OutputKey); m_initialized = true; m_WardenTimer = getMSTime(); } void WardenMac::RequestData() { sLog->outStaticDebug("Request data"); ByteBuffer buff; buff << uint8(WARDEN_SMSG_CHEAT_CHECKS_REQUEST); std::string str = "Test string!"; buff << uint8(str.size()); buff.append(str.c_str(), str.size()); buff.hexlike(); // Encrypt with warden RC4 key. EncryptData(const_cast<uint8*>(buff.contents()), buff.size()); WorldPacket pkt(SMSG_WARDEN_DATA, buff.size()); pkt.append(buff); Client->SendPacket(&pkt); m_WardenDataSent = true; } void WardenMac::HandleData(ByteBuffer &buff) { sLog->outStaticDebug("Handle data"); m_WardenDataSent = false; m_WardenKickTimer = 0; bool found = false; std::string str = "Test string!"; SHA1Hash sha1; sha1.UpdateData(str); uint32 magic = 0xFEEDFACE; // unsure sha1.UpdateData((uint8*)&magic, 4); sha1.Finalize(); uint8 SHA1Hash[20]; buff.read(SHA1Hash, 20); if(memcmp(SHA1Hash, sha1.GetDigest(), 20)) { sLog->outWarden("Handle data failed: SHA1 hash is wrong!"); found = true; } MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, str.c_str(), str.size()); uint8 ourMD5Hash[16]; MD5_Final(ourMD5Hash, &ctx); uint8 theirsMD5Hash[16]; buff.read(theirsMD5Hash, 16); if(memcmp(ourMD5Hash, theirsMD5Hash, 16)) { sLog->outStaticDebug("Handle data failed: MD5 hash is wrong!"); found = true; } if(found && sWorld->getIntConfig(CONFIG_INT_WARDEN_BANDAY)) { std::string sDuratuin = (std::string(sConfig->GetStringDefault("Warden.BanDay", "")) + "d"); std::string sText = ("Player: " + std::string(Client->GetPlayerName()) + " have used Cheating software and have banned for " + sDuratuin.c_str()); sWorld->SendGMText(LANG_GM_BROADCAST, sText.c_str()); sWorld->BanAccount(BAN_CHARACTER, Client->GetPlayerName(), sDuratuin.c_str(), "Cheating software user", "Server Guard"); } else if(found && sWorld->getBoolConfig(CONFIG_BOOL_WARDEN_KICK)) Client->KickPlayer(); }
[ "taumer943@gmail.com" ]
taumer943@gmail.com
ab621035566315f8cb3352b90edbf0a7ebbce325
eb6a84fea71d698072464e7df25eccbbcbf88e9c
/ipc_msgs/ipc_sensor_msgs/ros/sensor_msgs_LaserScan_publisher.cc
d7a0468950a18493e3744afba75683d67bfbd148
[]
no_license
natanaso/ipc-bridge
a4076fffb0d22342ec6d3350d70f0b457ae22be5
55aefb4c6f1e38a3e4dd8b1677ad467a9ad11c1d
refs/heads/master
2020-04-09T04:13:50.341607
2011-06-25T15:43:22
2011-06-25T15:43:22
1,961,758
3
0
null
null
null
null
UTF-8
C++
false
false
2,116
cc
#include <ros/ros.h> #include <ipc_bridge/ipc_bridge.h> #include <sensor_msgs/LaserScan.h> #include <ipc_bridge/msgs/sensor_msgs_LaserScan.h> #define NAMESPACE sensor_msgs #define NAME LaserScan ipc_bridge::Publisher<ipc_bridge::NAMESPACE::NAME> *p; ipc_bridge::NAMESPACE::NAME out_msg; unsigned int ranges_prior_length = 0; unsigned int intensities_prior_length = 0; unsigned int frame_id_prior_length = 0; void callback(const NAMESPACE::NAME::ConstPtr &msg) { out_msg.header.seq = msg->header.seq; out_msg.header.stamp = msg->header.stamp.toSec(); if (strlen(msg->header.frame_id.c_str()) != frame_id_prior_length) { delete[] out_msg.header.frame_id; out_msg.header.frame_id = new char[strlen(msg->header.frame_id.c_str()) + 1]; frame_id_prior_length = strlen(msg->header.frame_id.c_str()); } strcpy(out_msg.header.frame_id, msg->header.frame_id.c_str()); out_msg.angle_min = msg->angle_min; out_msg.angle_max = msg->angle_max; out_msg.angle_increment = msg->angle_increment; out_msg.time_increment = msg->time_increment; out_msg.scan_time = msg->scan_time; out_msg.range_min = msg->range_min; out_msg.range_max = msg->range_max; out_msg.ranges_length = msg->ranges.size(); if (out_msg.ranges_length > 0) { if (out_msg.ranges_length != ranges_prior_length) { delete[] out_msg.ranges; out_msg.ranges = new float[out_msg.ranges_length]; ranges_prior_length = out_msg.ranges_length; } std::copy(msg->ranges.begin(), msg->ranges.end(), out_msg.ranges); } out_msg.intensities_length = msg->intensities.size(); if (out_msg.intensities_length > 0) { if (out_msg.intensities_length != intensities_prior_length) { delete[] out_msg.intensities; out_msg.intensities = new float[out_msg.intensities_length]; intensities_prior_length = out_msg.intensities_length; } std::copy(msg->intensities.begin(), msg->intensities.end(), out_msg.intensities); } p->Publish(out_msg); } #include "publisher.h"
[ "nate.michael@gmail.com" ]
nate.michael@gmail.com
0baada9cf3a98a7f1d3684441daaf06797110e6d
15333f1086b15ff64ccc4a66764dea63aa94ca85
/src/main.cpp
4b04c6b068a74b1ce51f14976782d43c4f0c19c2
[]
no_license
agdt3/cpprt_old
d7b83b467760229890f35eec28e9ddb08bfaf99b
15f8a412a6180121ce0e0cad7f3291a80bf4c930
refs/heads/master
2021-01-19T23:03:07.306869
2017-04-20T22:22:38
2017-04-20T22:22:38
88,916,317
0
0
null
null
null
null
UTF-8
C++
false
false
9,315
cpp
//#include <math> #include <cstdlib> //for system("pause") #include <string> #include <iostream> #include <fstream> #include "src/variables.h" #include "src/main.h" #include "FreeImage/FreeImage.h" #include "src/transform.h" #include "src/ray.h" #include "src/pixel.h" #include "src/objects.h" #include "gtest/gtest.h" #include "src/camera.h" #include "src/texture.hpp" using namespace std; //global const bool RUN_TEST = true; int HIT_COUNT = 0; int LIGHT_HIT_COUNT = 0; const bool LIGHT_VISIBLE = true; const int NUM_OBJECTS = 3; const int MAX_REFLECTIONS = 1; const bool USE_TEXTURES = true; Object* objects[NUM_OBJECTS]; /* void init_objects() { for (int i=0; i < NUM_OBJECTS; i++) { //cout << (double (rand())/RAND_MAX) * 5 << endl; vec3 pos = vec3((double (rand())/RAND_MAX) * 5, (double (rand())/RAND_MAX) * 5, ((double (rand())/RAND_MAX) * -15) - 5); float radius = ((double (rand())/RAND_MAX) * 2) + 1.0; vec4 color = vec4((double (rand())/RAND_MAX), (double (rand())/RAND_MAX), (double (rand())/RAND_MAX), (double (rand())/RAND_MAX)); mat4 id = mat4(1.0); Object* sphere = new Sphere(pos, radius, color, &id); objects[i] = sphere; } }*/ void object_setup() { mat4 tr = Transform::translate(-2.0, 3.0, -13.0); Light *light1 = new Light(1.0, &tr, vec4(1.0, 1.0, 1.0, 0.5), 0.97, LightType::point); mat4 world = mat4(1.0); tr = Transform::translate(0.0, -0.75, -15.0); mat4 final = world * tr; //Sphere *sphere1 = new Sphere(1.0, &final, vec4(0.0, 0.0, 0.5, 1.0), 0.97); Sphere *sphere1 = new Sphere(2.0, &final, vec4(0.0, 0.0, 0.5, 1.0), 0.97, true, "resources/test.png"); tr = Transform::translate(-2.0, -0.75, -15.0); Sphere *sphere2 = new Sphere(1.0, &tr, vec4(0.0, 0.5, 0.7, 1.0), 0.97); Triangle *triangle1 = new Triangle(vec3(-2.0, 0.0, -25.0), vec3(0.0, 8.0, -12.0), vec3(3.0, -3.0, -5.0), vec4(1.0, 0.0, 0.0, 1.0)); Plane *plane1 = new Plane(vec3(0.0, 1.0, 0.0), 1.0, vec4(0.0, 0.5, 0.0, 1.0), 0.99); //Plane *plane1 = new Plane(vec3(-1.0, -3.0, 0.0), vec3(1.0, -3.0, 0.0), vec3(0.0, -3.0, -1.0), vec4(0.0, 0.5, 0.0, 1.0)); objects[0] = sphere1; //objects[0] = plane1; objects[1] = light1; //objects[2] = sphere2; objects[2] = plane1; //objects[4] = triangle1; } void object_teardown() { for (int i = 0; i < NUM_OBJECTS; i++) { delete objects[i]; } } void world_teardown(Camera *camera) { object_teardown(); delete camera; } Camera* world_setup() { mat4 matv = mat4(1.0); mat4 *matp = &matv; Camera *camp = new Camera(matp, 1024, 768, 45.0, 45.0, vec3(0.0)); object_setup(); return camp; } struct Hit { bool is_hit = false; vec3 hit, n; float d1, d2; ObjType type; Object *obj; vec4 color; bool has_texture; std::string texture_path; }; int NUM_HIT_SPHERE = 0; int NUM_CREATED = 0; ofstream myfile; void trace_ray(Ray *ray, Pixel &pixel, int reflections, bool track=false) { if (reflections > MAX_REFLECTIONS) { return; } else { reflections++; } if (track) { cout << "tracked ray " << endl; cout << *ray << endl; } float nearest = INFINITY; float dist1, dist2; vec3 hit, n; Hit hit_result; for (int k = 0; k < NUM_OBJECTS; k++) { Object* obj = objects[k]; if (obj->intersects(*ray, hit, n, dist1, dist2)) { if (abs(dist1) < nearest) { hit_result = Hit(); HIT_COUNT++; nearest = abs(dist1); hit_result.is_hit = true; hit_result.hit = hit; hit_result.n = n; hit_result.d1 = dist1; hit_result.d2 = dist2; hit_result.type = obj->type; hit_result.color = obj->color; hit_result.has_texture = obj->has_texture; hit_result.texture_path = obj->texture_filepath; hit_result.obj = obj; } } } if (hit_result.is_hit) { if (ray->type == RayType::camera) { if (hit_result.type == ObjType::light && LIGHT_VISIBLE) { pixel.set_color(hit_result.color); } else if (hit_result.type != ObjType::light) { if (hit_result.has_texture && USE_TEXTURES) { //this is temporary //TODO: Figure out dynamic casting here Sphere *sp = (Sphere*)hit_result.obj; float u, v; sp->get_uv(hit_result.n, u, v); //std::cout << u << " " << v << std::endl; vec3 rgb = vec3(0.0); if (TextureManager::get_uv_pixel_color( rgb, hit_result.texture_path, u, v)) { vec4 rgb4 = vec4(rgb.r, rgb.g, rgb.b, 1.0); pixel.set_color(rgb4); }; } else { pixel.set_color(hit_result.color); } //fire a new ray vec3 dir = (Transform::reflect(ray->direction, hit_result.n)); dir = glm::normalize(dir); Ray *nray = new Ray(hit_result.hit, dir, RayType::shadow); trace_ray(nray, pixel, reflections, track); delete nray; } } else if (ray->type == RayType::shadow) { if (hit_result.type == ObjType::light) { LIGHT_HIT_COUNT++; pixel.add_alpha_color(hit_result.color); } } } } void tracer(Camera *camera) { FreeImage_Initialise(); FIBITMAP* bitmap = FreeImage_Allocate(camera->width, camera->height, camera->bpp); RGBQUAD color; for (int i = 0; i < camera->width; i++) { for (int j = 0; j < camera->height; j++) { //base color color.rgbRed = 0.0; color.rgbGreen = 0.0; color.rgbBlue = 0.0; //base pixel remapping Pixel pixel = Pixel(i, j, camera); pixel.remap(); pixel.set_color(vec4(0.0, 0.0, 0.0, 1.0)); vec3 direction = vec3(pixel.x, pixel.y, -1.0); //direction of negative z direction = glm::normalize(direction); vec3 origin = vec3(0.0); //initial camera ray int reflections = 0; Ray *ray = new Ray(origin, direction, RayType::camera); bool track = false; trace_ray(ray, pixel, reflections, track); //draw pixel vec3 rgb_color = pixel.convert_rgba_to_rgb(vec4(1.0)); color.rgbRed = (double)(rgb_color.r * 255.0); color.rgbGreen = (double)(rgb_color.g * 255.0); color.rgbBlue = (double)(rgb_color.b * 255.0); FreeImage_SetPixelColor(bitmap, i, camera->height-j, &color); delete ray; } } if (FreeImage_Save(FIF_PNG, bitmap, "./test/test.png", 0)) { cout << "Saved!"; } FreeImage_DeInitialise(); } FIBITMAP* load_image (const std::string& imagepath, int flag) { FREE_IMAGE_FORMAT fif = FIF_UNKNOWN; const char* path = imagepath.c_str(); fif = FreeImage_GetFileType(path, 0); if (fif == FIF_UNKNOWN) { fif = FreeImage_GetFIFFromFilename(path); } if ((fif != FIF_UNKNOWN) && FreeImage_FIFSupportsReading(fif)) { FIBITMAP *file = FreeImage_Load(fif, path, flag); return file; } return NULL; } bool get_uv_pixel_color(vec3& rgb, FIBITMAP* file, RGBQUAD* val, const float& u, const float& v) { if (file == NULL || val == NULL) { return false; } else { unsigned int width = FreeImage_GetWidth(file); unsigned int height = FreeImage_GetHeight(file); unsigned int x = width * u; unsigned int y = height * v; if (FreeImage_GetPixelColor(file, x, y, val)) { rgb.r = val->rgbRed / 255.0; rgb.g = val->rgbGreen / 255.0; rgb.b = val->rgbBlue / 255.0; return true; } else { return false; } } return false; } int main(int argc, char* argv[]) { /* load_image("resources/test.png", 0); Camera *camp = world_setup(); tracer(camp); world_teardown(camp); cout << endl << "hits " << HIT_COUNT << " total " << (camp->width * camp->height) << endl; cout << "light hits " << LIGHT_HIT_COUNT << endl; //cout << "NUM_RAYS_LIGHT " << NUM_RAYS_LIGHT << endl; //cout << "NUM_RAYS_HIT_LIGHT " << NUM_RAYS_HIT_LIGHT << endl; //cout << "NUM_RAYS_HIT_ELSE " << NUM_RAYS_HIT_ELSE << endl; cout << "NUM_HIT_SPHERE " << NUM_HIT_SPHERE << endl; cout << "NUM_CREATED " << NUM_CREATED << endl; cout << (ObjType::plane == ObjType::light) << endl; printf("Hit any key to continue> "); getchar(); */ if (RUN_TEST) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } else { return 0; } }
[ "pavel.a@aol.com" ]
pavel.a@aol.com
c2880fbcae4dfd5af84f2aad1cfacf3bbe2df371
4dbaab82527acff85c484c312b372ce6aed5b184
/Broken Engine/Source/Wwise/IO/Common/AkMultipleFileLocation.cpp
ce8068b1e38782b19e59d65b4e6d665d88509677
[ "MIT", "Zlib" ]
permissive
Broken-Gem-Studio/Broken-Engine
6103ddfbe116465a432aed1b931a9226723c1af9
71a261bbaaef80b27a9da94f4737fd480caf6e0d
refs/heads/development
2021-01-08T05:19:07.714253
2020-06-15T10:04:56
2020-06-15T10:04:56
241,921,076
5
0
MIT
2020-06-15T22:25:53
2020-02-20T15:36:23
C++
UTF-8
C++
false
false
8,473
cpp
/******************************************************************************* The content of this file includes portions of the AUDIOKINETIC Wwise Technology released in source code form as part of the SDK installer package. Commercial License Usage Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology may use this file in accordance with the end user license agreement provided with the software or, alternatively, in accordance with the terms contained in a written agreement between you and Audiokinetic Inc. Version: v2019.1.6 Build: 7110 Copyright (c) 2006-2019 Audiokinetic Inc. *******************************************************************************/ ////////////////////////////////////////////////////////////////////// // // AkFileLocationBase.cpp // // Basic file location resolving: Uses simple path concatenation logic. // Exposes basic path functions for convenience. // For more details on resolving file location, refer to section "File Location" inside // "Going Further > Overriding Managers > Streaming / Stream Manager > Low-Level I/O" // of the SDK documentation. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <AK/SoundEngine/Common/AkStreamMgrModule.h> #include <AK/Tools/Common/AkPlatformFuncs.h> #ifdef AK_SUPPORT_WCHAR #include <wchar.h> #endif //AK_SUPPORT_WCHAR #include <stdio.h> #include <AK/Tools/Common/AkAssert.h> #include <AK/Tools/Common/AkObject.h> #include "AkFileHelpers.h" #include "AkMultipleFileLocation.h" #define MAX_NUMBER_STRING_SIZE (10) // 4G #define ID_TO_STRING_FORMAT_BANK AKTEXT("%u.bnk") #define ID_TO_STRING_FORMAT_WEM AKTEXT("%u.wem") #define MAX_EXTENSION_SIZE (4) // .xxx #define MAX_FILETITLE_SIZE (MAX_NUMBER_STRING_SIZE+MAX_EXTENSION_SIZE+1) // null-terminated void CAkMultipleFileLocation::Term() { if (!m_Locations.IsEmpty()) { FilePath *p = (*m_Locations.Begin()); while (p) { FilePath *next = p->pNextLightItem; AkDelete(AK::StreamMgr::GetPoolID(), p); p = next; } } m_Locations.Term(); } AKRESULT CAkMultipleFileLocation::Open( const AkOSChar* in_pszFileName, // File name. AkOpenMode in_eOpenMode, // Open mode. AkFileSystemFlags * in_pFlags, // Special flags. Can pass NULL. bool in_bOverlapped, // Overlapped IO open AkFileDesc & out_fileDesc // Returned file descriptor. ) { AkOSChar szFullFilePath[AK_MAX_PATH]; if (m_Locations.IsEmpty()) { // Get the full file path, using path concatenation logic. if (GetFullFilePath(in_pszFileName, in_pFlags, in_eOpenMode, szFullFilePath ) == AK_Success) { AKRESULT res = CAkFileHelpers::Open(szFullFilePath, in_eOpenMode, in_bOverlapped, out_fileDesc); if (res == AK_Success) { // iFileSize must be set by the OpenPolicy. AKASSERT(out_fileDesc.iFileSize != 0 && (in_eOpenMode == AK_OpenModeRead || in_eOpenMode == AK_OpenModeReadWrite) || !(in_eOpenMode == AK_OpenModeRead || in_eOpenMode == AK_OpenModeReadWrite)); return AK_Success; } } } else { for (AkListBareLight<FilePath>::Iterator it = m_Locations.Begin(); it != m_Locations.End(); ++it) { // Get the full file path, using path concatenation logic. if (GetFullFilePath(in_pszFileName, in_pFlags, in_eOpenMode, szFullFilePath, (*it)->szPath) == AK_Success) { AKRESULT res = CAkFileHelpers::Open(szFullFilePath, in_eOpenMode, in_bOverlapped, out_fileDesc); if (res == AK_Success) { // iFileSize must be set by the OpenPolicy. AKASSERT(out_fileDesc.iFileSize != 0 && (in_eOpenMode == AK_OpenModeRead || in_eOpenMode == AK_OpenModeReadWrite) || !(in_eOpenMode == AK_OpenModeRead || in_eOpenMode == AK_OpenModeReadWrite)); return AK_Success; } } } } return AK_Fail; } AKRESULT CAkMultipleFileLocation::Open( AkFileID in_fileID, // File ID. AkOpenMode in_eOpenMode, // Open mode. AkFileSystemFlags * in_pFlags, // Special flags. Can pass NULL. bool in_bOverlapped, // Overlapped IO open AkFileDesc & out_fileDesc // Returned file descriptor. ) { if ( !in_pFlags || !(in_pFlags->uCompanyID == AKCOMPANYID_AUDIOKINETIC || in_pFlags->uCompanyID == AKCOMPANYID_AUDIOKINETIC_EXTERNAL)) { AKASSERT( !"Unhandled file type" ); return AK_Fail; } AkOSChar pszTitle[MAX_FILETITLE_SIZE+1]; if ( in_pFlags->uCodecID == AKCODECID_BANK ) AK_OSPRINTF( pszTitle, MAX_FILETITLE_SIZE, ID_TO_STRING_FORMAT_BANK, (unsigned int)in_fileID ); else AK_OSPRINTF( pszTitle, MAX_FILETITLE_SIZE, ID_TO_STRING_FORMAT_WEM, (unsigned int)in_fileID ); return Open(pszTitle, in_eOpenMode, in_pFlags, in_bOverlapped, out_fileDesc); } // String overload. // Returns AK_Success if input flags are supported and the resulting path is not too long. // Returns AK_Fail otherwise. AKRESULT CAkMultipleFileLocation::GetFullFilePath( const AkOSChar* in_pszFileName, // File name. AkFileSystemFlags * in_pFlags, // Special flags. Can be NULL. AkOpenMode in_eOpenMode, // File open mode (read, write, ...). AkOSChar* out_pszFullFilePath, // Full file path. AkOSChar* in_pszBasePath // Base path to use, might be null ) { if ( !in_pszFileName ) { AKASSERT( !"Invalid file name" ); return AK_InvalidParameter; } // Prepend string path (basic file system logic). // Compute file name with file system paths. size_t uiPathSize = AKPLATFORM::OsStrLen( in_pszFileName ); if ( uiPathSize >= AK_MAX_PATH ) { AKASSERT( !"Input string too large" ); return AK_InvalidParameter; } if (in_pszBasePath != NULL) { AKPLATFORM::SafeStrCpy(out_pszFullFilePath, in_pszBasePath, AK_MAX_PATH); } else { if (m_Locations.IsEmpty()) { out_pszFullFilePath[0] = 0; } else { AkListBareLight<FilePath>::Iterator it = m_Locations.Begin(); AKPLATFORM::SafeStrCpy(out_pszFullFilePath, (*it)->szPath, AK_MAX_PATH); } } if ( in_pFlags && in_eOpenMode == AK_OpenModeRead ) { // Add language directory name if needed. if ( in_pFlags->bIsLanguageSpecific ) { size_t uLanguageStrLen = AKPLATFORM::OsStrLen( AK::StreamMgr::GetCurrentLanguage() ); if ( uLanguageStrLen > 0 ) { uiPathSize += ( uLanguageStrLen + 1 ); if ( uiPathSize >= AK_MAX_PATH ) { AKASSERT( !"Path is too large" ); return AK_Fail; } AKPLATFORM::SafeStrCat( out_pszFullFilePath, AK::StreamMgr::GetCurrentLanguage(), AK_MAX_PATH ); AKPLATFORM::SafeStrCat( out_pszFullFilePath, AK_PATH_SEPARATOR, AK_MAX_PATH ); } } } // Append file title. uiPathSize += AKPLATFORM::OsStrLen( out_pszFullFilePath ); if ( uiPathSize >= AK_MAX_PATH ) { AKASSERT( !"File name string too large" ); return AK_Fail; } AKPLATFORM::SafeStrCat( out_pszFullFilePath, in_pszFileName, AK_MAX_PATH ); return AK_Success; } AKRESULT CAkMultipleFileLocation::AddBasePath(const AkOSChar* in_pszBasePath) { AkUInt32 origLen = (AkUInt32)AKPLATFORM::OsStrLen(in_pszBasePath); AkUInt32 newByteSize = origLen + 1; // One for the trailing \0 if(origLen && in_pszBasePath[origLen - 1] != AK_PATH_SEPARATOR[0]) { newByteSize++; // Add space for a trailing slash } // Make sure the new base path is not too long in case language gets appended // Format of the test is: basePath/Language/. if ( origLen + 1 + AKPLATFORM::OsStrLen( AK::StreamMgr::GetCurrentLanguage() + 1 ) >= AK_MAX_PATH ) return AK_InvalidParameter; FilePath * pPath = (FilePath*)AkAlloc(AK::StreamMgr::GetPoolID(), sizeof(FilePath) + sizeof(AkOSChar)*(newByteSize - 1)); if (pPath == NULL) return AK_InsufficientMemory; // Copy the base path EVEN if the directory does not exist. AKPLATFORM::SafeStrCpy( pPath->szPath, in_pszBasePath, origLen + 1); // Add the trailing slash, if necessary if (origLen)// UWP is not soo happy of the trailing slash on an empty string. { if (in_pszBasePath[origLen - 1] != AK_PATH_SEPARATOR[0]) { pPath->szPath[origLen] = AK_PATH_SEPARATOR[0]; pPath->szPath[origLen + 1] = 0; } } pPath->pNextLightItem = NULL; m_Locations.AddFirst(pPath); AKRESULT eDirectoryResult = CAkFileHelpers::CheckDirectoryExists( in_pszBasePath ); if( eDirectoryResult == AK_Fail ) // AK_NotImplemented could be returned and should be ignored. { return AK_PathNotFound; } return AK_Success; }
[ "jacobo.galofre@gmail.com" ]
jacobo.galofre@gmail.com
248c611847c6f82e6503cfaac83f777da4ef30d9
4e9e492e752e43400f0b728f854f842d13ba4bad
/OmegaUp/batalla.cpp
9b6e577174bc66cb1ca4b77a7ea97926bb638ea8
[]
no_license
jocagos/competitive
0ac497b7e6c30e548e0d7e298df0f2892e7e03b1
89c8467b56d4be10c80189b154e2edadfb6a9f3f
refs/heads/master
2021-07-05T23:53:23.607682
2021-05-27T22:17:13
2021-05-27T22:17:13
84,216,647
0
0
null
null
null
null
UTF-8
C++
false
false
619
cpp
#include <cstdio> #include <algorithm> using namespace std; constexpr int MAXN = 55; int main(){ int n {}; int me[MAXN] {}, lira[MAXN] {}; scanf("%d", &n); for( int i = 0; i < n; ++ i ) scanf("%d", &me[i]); for( int i = 0; i < n; ++ i ) scanf("%d", &lira[i]); sort( me, me + n ); sort( lira, lira + n ); int cnt {}, pos_lira {n-1}; for( int i = n - 1; i >= 0 and pos_lira >= 0; -- i ){ while( pos_lira >= 0 ){ if( lira[pos_lira] < me[i] ){ cnt += me[i]; -- pos_lira; break; } -- pos_lira; } } printf("%d\n", cnt); return 0; }
[ "zagerer@gmail.com" ]
zagerer@gmail.com
fc7ba2dde4d2d6c986bf17919fcc338a6e124b0e
3ea34c23f90326359c3c64281680a7ee237ff0f2
/Data/1555/H
c2b2b9e90c84bfeaa4eeb9e1326cbad018ef1492
[]
no_license
lcnbr/EM
c6b90c02ba08422809e94882917c87ae81b501a2
aec19cb6e07e6659786e92db0ccbe4f3d0b6c317
refs/heads/master
2023-04-28T20:25:40.955518
2020-02-16T23:14:07
2020-02-16T23:14:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
92,096
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | foam-extend: Open Source Cstd::filesystem::create_directory();FD | | \\ / O peration | Version: 4.0 | | \\ / A nd | Web: http://www.foam-extend.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "Data/1555"; object H; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 4096 ( (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.17021823202261e-13,-2.24797938902954e-13,-8.13972093148948e-13) (7.01436357622046e-13,-1.24683658577974e-12,-2.75359076867278e-13) (1.63099075695695e-12,-2.15005435730355e-12,2.65509696971219e-14) (1.95447222972117e-12,-1.81307330384253e-12,2.08562705903815e-13) (2.15079174861925e-12,-1.31992783286494e-12,3.66474873812357e-13) (2.7736395530449e-12,-9.91171366946934e-13,6.79397690592135e-13) (5.35014115661175e-12,9.53027338824659e-14,6.27219203603534e-13) (7.10383673925843e-12,3.52086449250125e-12,2.96540432573329e-13) (8.23552522726242e-12,1.0816721717648e-11,5.98733045493469e-14) (8.8436739026987e-12,1.89782300273553e-11,1.6417473294505e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.95654903481478e-12,-6.04346145985515e-13,-2.31506573180599e-12) (3.10186823678019e-12,-1.24669300849631e-12,-1.39082362052657e-12) (4.12393130764633e-12,-1.8305962257764e-12,-6.74751968102286e-13) (4.52075527940152e-12,-1.92535042055719e-12,-2.14489452469222e-13) (4.83564396367408e-12,-1.81412873682108e-12,2.36757731948271e-13) (5.85854343902424e-12,-9.46808545405285e-13,7.96806136946663e-13) (9.37005461453418e-12,1.01074064447458e-12,9.79622123391392e-13) (1.31049712442622e-11,4.47152040217504e-12,6.16898660914689e-13) (1.57020823996129e-11,1.09137626263361e-11,2.07861513036775e-13) (1.71295640410028e-11,1.90086642474504e-11,4.44623067501667e-15) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.92979610000116e-12,-6.12800010348035e-13,-3.99735817917169e-12) (3.70387346072413e-12,-9.05101920562689e-13,-3.05217024581465e-12) (5.05717955171264e-12,-1.23502289837301e-12,-2.03164004204513e-12) (6.12868448731151e-12,-1.72351456444097e-12,-1.00127153653702e-12) (7.32836845893374e-12,-2.17044806784776e-12,4.89589761218702e-14) (8.82582458253305e-12,-1.08066118250766e-12,6.44447065203803e-13) (1.25439808126185e-11,1.66462122668204e-12,5.77369345649988e-13) (1.80295027828167e-11,5.34444421702263e-12,1.75964323553573e-13) (2.20782352741392e-11,1.12717072549684e-11,-4.64722668026167e-14) (2.39898458704612e-11,1.89680814514771e-11,-1.30536068820772e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.54826336226161e-12,-7.12087803775047e-13,-3.99636651184943e-12) (3.70271913016835e-12,-9.8096051914341e-13,-3.38078272699872e-12) (5.51839934928071e-12,-1.24140182994605e-12,-2.50546720259986e-12) (7.77690528505116e-12,-1.640947853366e-12,-1.42212889609543e-12) (1.06375862719048e-11,-1.78900677946179e-12,-2.53928782608391e-14) (1.24936574085648e-11,-4.59689530735766e-13,7.61810579100426e-13) (1.61703417876947e-11,2.45709176650114e-12,4.83807168149535e-13) (2.21959031575508e-11,6.24203290890203e-12,1.03926119303377e-13) (2.70438701246378e-11,1.20435794856237e-11,-2.08243847630125e-13) (2.95050773660965e-11,1.95530613119945e-11,-8.98810074149688e-14) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.6941362086852e-12,-2.82116078681277e-13,-3.99171819500726e-12) (3.26119593078806e-12,-6.22290444138184e-13,-3.43702166466914e-12) (4.68052365215322e-12,-1.07309053941724e-12,-2.5567028291115e-12) (7.79822390467284e-12,-1.49447927162088e-12,-1.88797186107318e-12) (1.20187035300662e-11,-1.05604560260685e-12,-6.36600176165753e-13) (1.5449671987344e-11,8.07235742609597e-13,4.70806228512095e-13) (1.94270304445609e-11,3.47392489033612e-12,7.22335508682223e-13) (2.53328514158415e-11,7.09722114218239e-12,1.72982080352984e-13) (3.03396937155753e-11,1.24855372034966e-11,-2.8987551340374e-13) (3.22968208559951e-11,2.00460880830918e-11,-1.18466997580673e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (8.11053632690264e-13,5.42367478770544e-13,-4.14239011940248e-12) (2.34922587013058e-12,-1.32701909574066e-13,-3.95827005629859e-12) (4.40808505499781e-12,-8.14312323458131e-13,-3.79207901734713e-12) (7.84969161653418e-12,-1.29268583088351e-12,-3.41245188450673e-12) (1.2508170371725e-11,-4.75656591366782e-13,-2.35621925906527e-12) (1.68148045853319e-11,1.77121113938003e-12,-1.3870209724465e-12) (2.17740963373286e-11,4.4506801787423e-12,-6.05694361716512e-13) (2.80554072027102e-11,7.92973146396103e-12,-6.33849478764766e-13) (3.31324252031319e-11,1.29682641216576e-11,-8.35789970724172e-13) (3.50680944399592e-11,2.03504709195648e-11,-5.08697437981379e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (6.96218540377073e-13,1.19691965736844e-12,-6.46034465623018e-12) (1.9579851548547e-12,6.43672546095424e-13,-6.29053465433496e-12) (4.43742772773833e-12,-2.33298005336516e-13,-6.30907880578005e-12) (7.75437693591963e-12,-6.03650406725829e-13,-6.02245923900867e-12) (1.26593517588456e-11,4.03071908220572e-13,-5.15116544213584e-12) (1.79395132425885e-11,2.22546089759735e-12,-4.37227452064062e-12) (2.3477397063977e-11,4.65899699903186e-12,-3.2700635142031e-12) (2.93481209894161e-11,8.01174788967464e-12,-2.3507478714189e-12) (3.3525839163584e-11,1.2691533075898e-11,-1.61970206020147e-12) (3.51916989099018e-11,1.96764827901494e-11,-8.54248668935364e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4.39126834747126e-13,1.34689897685612e-12,-1.14100311090678e-11) (1.82080205171686e-12,1.37124495032824e-12,-1.09330113671609e-11) (4.62379826574671e-12,3.95713495153717e-13,-1.06093915165833e-11) (8.55007153906052e-12,-2.24779686514917e-13,-1.0343148377042e-11) (1.38070729753785e-11,7.46821209101091e-13,-9.50791953904093e-12) (1.99737374318356e-11,1.92795431742803e-12,-8.53887383371443e-12) (2.57190469106868e-11,3.75451265720501e-12,-7.34808141926187e-12) (3.11886907512417e-11,6.81446683084469e-12,-6.05229562163019e-12) (3.40265800813142e-11,1.11006227230521e-11,-3.97693436076709e-12) (3.45098446639716e-11,1.74772993434554e-11,-1.97258328613914e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (8.83362496047056e-13,1.15818460617557e-12,-1.87008944221402e-11) (2.11003780529632e-12,1.62422421407207e-12,-1.80624717336242e-11) (4.87147526592686e-12,7.77040494995406e-13,-1.73213459793557e-11) (9.1869089115272e-12,-8.36097690291342e-14,-1.69614145355753e-11) (1.41999540132066e-11,9.75561678463428e-13,-1.64311551790502e-11) (2.14826558960597e-11,2.03572196596309e-12,-1.53268637501447e-11) (2.76295708346868e-11,3.17256473020688e-12,-1.35081191300314e-11) (3.20056323443322e-11,5.18724713812404e-12,-1.11858272856551e-11) (3.45062213542795e-11,8.92875870031154e-12,-8.29879870506798e-12) (3.44289709508319e-11,1.45867475905224e-11,-4.82639694695046e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4.85105643188782e-14,7.62348184353302e-13,-2.57605640669833e-11) (1.76085039720169e-12,1.33479896220554e-12,-2.56160451427567e-11) (5.73591744102369e-12,7.85436238710894e-13,-2.46347771603456e-11) (1.02387092329168e-11,5.02815385060412e-14,-2.37980942825792e-11) (1.51863954475929e-11,5.51863239600745e-13,-2.32660046995469e-11) (2.2965851675566e-11,1.17482839118411e-12,-2.23143028820995e-11) (2.85286703701362e-11,1.71202512739252e-12,-2.03949420697265e-11) (3.15604968194451e-11,2.93268631708756e-12,-1.79622948183846e-11) (3.37396528172007e-11,5.59426023684097e-12,-1.51068876035738e-11) (3.37541542476967e-11,9.70033525483896e-12,-9.98240795077396e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.5795701400517e-13,-4.49262037624992e-13,-1.90934564422195e-12) (3.99382733772776e-13,-2.18661436199709e-12,-1.40967481711735e-12) (1.12952088920788e-12,-3.02603223569592e-12,-1.41653300056298e-12) (1.90883717852439e-12,-2.39390118947492e-12,-1.1552223872334e-12) (2.33206983576729e-12,-1.38907342243629e-12,-6.04010076349857e-13) (2.78145521853848e-12,2.77023667664019e-13,1.49767807121048e-13) (4.76538201710759e-12,2.51052159150239e-12,2.62430835393537e-13) (6.38984795734546e-12,8.14071672762628e-12,-6.2559817695061e-14) (8.0341828899693e-12,2.09317457260988e-11,-1.94855404342772e-13) (8.97741441511028e-12,4.61703016029376e-11,-2.19411262633961e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.04076078789824e-12,-1.02811394510396e-12,-4.21096660115644e-12) (2.04420549642824e-12,-2.15650993149923e-12,-3.47630561075216e-12) (3.06809546462289e-12,-2.85239721325463e-12,-2.69120556398682e-12) (3.86767223887525e-12,-2.57780541777824e-12,-1.61980437648523e-12) (4.63191488972101e-12,-1.86453244567474e-12,-7.13822610259766e-13) (5.80958008963893e-12,4.32450442152101e-13,1.90428771069232e-13) (9.07889749470206e-12,3.43451774166275e-12,7.73311744304826e-13) (1.2641084577451e-11,8.93741166604237e-12,3.5688168118956e-13) (1.55475530537688e-11,2.12646890271392e-11,-4.30362068651665e-14) (1.71745930676876e-11,4.65496857517378e-11,-5.09971295716959e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.08389596007257e-12,-1.13295504766677e-12,-7.05023814691161e-12) (2.75920185553703e-12,-1.85571691454845e-12,-6.09365422612726e-12) (4.03318997778567e-12,-2.34937834244097e-12,-4.50177604630036e-12) (4.995887263579e-12,-2.20801252343273e-12,-2.75280600957399e-12) (6.35143908141554e-12,-1.81954309491332e-12,-1.33550062735036e-12) (8.27193065027061e-12,6.97447274035723e-13,-2.84514249252873e-13) (1.21529152949412e-11,4.70814075935931e-12,3.12721331573562e-13) (1.73543506812533e-11,1.03371678402262e-11,-8.96202572144127e-14) (2.13904268452624e-11,2.24527839290523e-11,-3.41970877364667e-13) (2.32743299410091e-11,4.72334199536547e-11,-4.01666249523082e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (5.02707852316329e-13,-1.44561918766055e-12,-7.66961040470169e-12) (2.46873353076389e-12,-2.1003673005129e-12,-6.89596886072211e-12) (4.2667497522424e-12,-2.45484619032562e-12,-5.48843765773721e-12) (6.23370068547511e-12,-2.24693169932624e-12,-3.99320368428625e-12) (9.1174216376919e-12,-1.39368424231782e-12,-2.28652417233093e-12) (1.15047355461757e-11,1.76147688204673e-12,-7.34848363639778e-13) (1.55333897127246e-11,6.50866977112572e-12,1.42271300793655e-13) (2.16528848911188e-11,1.1876253984121e-11,-3.19842045547542e-14) (2.6483549566887e-11,2.32624899620635e-11,-4.48560597632724e-13) (2.89221695878038e-11,4.79004811374146e-11,-3.12887222239652e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.14956120894432e-13,-1.04741196998773e-12,-8.14954865250777e-12) (1.8912885606636e-12,-1.6820078106145e-12,-7.62599021681063e-12) (3.75301446815289e-12,-2.00074155777136e-12,-6.42599301268771e-12) (6.34505877903238e-12,-1.91947071856187e-12,-5.29918318458595e-12) (1.03309081141658e-11,-3.10825434986213e-13,-3.41072119138216e-12) (1.42341673103485e-11,3.37841235731491e-12,-6.32178096570344e-13) (1.89996285845618e-11,8.20510850986706e-12,1.93749223538468e-12) (2.496319868798e-11,1.32736713469148e-11,1.01663061551677e-12) (2.96855582815671e-11,2.35633399158801e-11,-3.44148765296412e-13) (3.18739710215453e-11,4.81384997479284e-11,-4.49661560806962e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.76186090110817e-14,2.98210430444188e-13,-8.83061505441164e-12) (1.40666037550888e-12,-6.55087614086267e-13,-8.6203637333483e-12) (3.44744360403355e-12,-1.10062181064659e-12,-8.09221659177319e-12) (6.10442356693659e-12,-1.1156051274682e-12,-7.04539498418012e-12) (1.06602435855161e-11,7.05790428112886e-13,-5.41659559665375e-12) (1.55792282163774e-11,4.24465795832247e-12,-2.64292944858354e-12) (2.15939346341469e-11,8.49780408523623e-12,7.21231145972684e-13) (2.81753312690334e-11,1.38044602794375e-11,3.14615099228901e-13) (3.30820637162582e-11,2.33298267429826e-11,-8.30560924114857e-13) (3.52333851317219e-11,4.7505284350992e-11,-7.88482404675594e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.76429218994162e-13,1.5095101875435e-12,-1.26597583696459e-11) (1.24895690206734e-12,9.13623309948793e-13,-1.23174733492682e-11) (3.52179666047711e-12,7.73080757921279e-14,-1.1938043614856e-11) (6.50421241882925e-12,8.37426800197174e-14,-1.1061983826317e-11) (1.15367115364824e-11,1.81657460820239e-12,-9.72915203622829e-12) (1.71348088163388e-11,4.72545280778507e-12,-7.24827836848937e-12) (2.34625657630737e-11,8.56543839294033e-12,-3.53150424989398e-12) (2.98143562368977e-11,1.35958415886939e-11,-2.5359588534048e-12) (3.43512961249919e-11,2.2766941164158e-11,-2.20102191015096e-12) (3.65366336883753e-11,4.63299195671912e-11,-1.41382181603978e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.50821463520608e-13,2.1595314654115e-12,-2.1413827837034e-11) (1.2442029373958e-12,2.46618219447103e-12,-2.03044841762935e-11) (3.97622812636621e-12,1.38846974372532e-12,-1.92425312036222e-11) (7.57367278357277e-12,1.07505755190511e-12,-1.84855926041852e-11) (1.2609286800668e-11,2.49713275230495e-12,-1.72806132618672e-11) (1.86751773688683e-11,4.50930758367246e-12,-1.4739769342886e-11) (2.50052090400646e-11,7.29472242107506e-12,-1.14141796488301e-11) (3.07405491829671e-11,1.17794483674978e-11,-9.34995494132041e-12) (3.41940930294999e-11,2.08100316379204e-11,-6.58039533601358e-12) (3.54278131301808e-11,4.36516915831908e-11,-3.56328569660352e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (6.40776229353437e-13,1.80876823227254e-12,-3.45185031162958e-11) (1.65833730289493e-12,2.81154993699129e-12,-3.32188919635833e-11) (4.50314807843254e-12,1.99513084946067e-12,-3.17821047369436e-11) (8.52275824747121e-12,1.33389830604079e-12,-3.09064030812163e-11) (1.3519361023178e-11,2.27886550906696e-12,-2.98438467354351e-11) (2.05248048507059e-11,3.64039769766219e-12,-2.73720322266317e-11) (2.676781859311e-11,5.44311878019581e-12,-2.37360973727341e-11) (3.13731645847652e-11,8.55738181903441e-12,-1.99785002164052e-11) (3.43683180595616e-11,1.68744140357e-11,-1.55495441888489e-11) (3.44889863397532e-11,3.85377872792963e-11,-9.52782448014345e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (6.66339824445694e-13,9.94246910723329e-13,-5.79441872079968e-11) (2.11438137699588e-12,1.97264052088331e-12,-5.73672579245463e-11) (5.6846708019671e-12,1.55236631659585e-12,-5.59911751082526e-11) (9.75690118839194e-12,1.08084997866528e-12,-5.4657053544733e-11) (1.47865568697423e-11,1.26808569618074e-12,-5.31057852098038e-11) (2.22213192543709e-11,1.75484005880472e-12,-5.07339442163473e-11) (2.78080482461825e-11,2.56269454261418e-12,-4.71726275466769e-11) (3.1637775921763e-11,4.35877338063627e-12,-4.3022274882286e-11) (3.42094334012366e-11,1.03672307767266e-11,-3.79753766938778e-11) (3.34720815518804e-11,2.78408287162429e-11,-2.74779429903703e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (2.37138094501764e-13,6.13001963580523e-13,-3.35542197876646e-12) (3.76136486176209e-13,-1.3367568611261e-12,-2.77327521399048e-12) (6.94575253953411e-13,-2.42814975939621e-12,-2.66360036168027e-12) (1.54152909635766e-12,-1.69892802178267e-12,-2.43563152056831e-12) (2.05375097527456e-12,-1.99458454288103e-13,-2.03404112597062e-12) (2.51336541570704e-12,2.44122668888585e-12,-1.71629002305379e-12) (4.16637651952221e-12,6.30011697472752e-12,-1.8666260213028e-12) (5.72544860577502e-12,1.18164709906946e-11,-1.64283125660191e-12) (7.72579544727015e-12,1.97424782849494e-11,-1.07078091730819e-12) (8.37861900383318e-12,2.81270066070014e-11,-4.23455556436807e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4.10940899938734e-13,2.9974913884483e-13,-5.96554957295184e-12) (9.58312432332345e-13,-1.06429901788053e-12,-5.30333748945208e-12) (1.49367540584637e-12,-1.95024135362437e-12,-4.34009890181549e-12) (2.59189757876897e-12,-1.25869779220144e-12,-3.11910500540438e-12) (3.68267415784895e-12,2.43941350193023e-14,-2.33757425899616e-12) (4.96170028449689e-12,2.94889432035094e-12,-2.02980822920503e-12) (8.22170453884903e-12,6.6200392304746e-12,-1.73557982779353e-12) (1.16412462926091e-11,1.15533885534034e-11,-1.25233594927159e-12) (1.48263932405735e-11,1.96144441995352e-11,-1.00673880526261e-12) (1.5980887569997e-11,2.83666016531595e-11,-7.78243670834269e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4.39976177697705e-13,-1.17160189488632e-14,-8.47714479198551e-12) (1.41197406311091e-12,-1.18822799389723e-12,-7.83660051607426e-12) (2.3896877889999e-12,-1.98323231557171e-12,-6.226920402652e-12) (3.61750105683323e-12,-8.63547447551857e-13,-4.3634679410305e-12) (4.87459385039983e-12,5.07159248724836e-13,-2.99749672233398e-12) (6.61066546143021e-12,3.50147446451392e-12,-2.40017321414266e-12) (1.0754727873057e-11,7.43463676165432e-12,-1.69561860722927e-12) (1.60676151565504e-11,1.21433515164654e-11,-9.16507392537065e-13) (2.06404161851211e-11,2.04265595857112e-11,-1.00083026507471e-12) (2.22056025072115e-11,2.8864761430036e-11,-5.63069998225588e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-6.69140909749145e-13,-3.50679377134423e-13,-9.68305042426709e-12) (6.4284283883908e-13,-1.40938428072524e-12,-9.12844606752363e-12) (2.31741114583581e-12,-2.18238971555994e-12,-7.64646524395295e-12) (4.19956019213931e-12,-7.81767359004931e-13,-6.07338736288233e-12) (6.48288702215944e-12,1.17550412517027e-12,-4.30371700107016e-12) (9.01068040638292e-12,4.70429809091225e-12,-2.57496662766343e-12) (1.40112064790702e-11,9.55424735140422e-12,-1.91501767053738e-13) (2.06720439215434e-11,1.37848978078041e-11,6.41105565259806e-13) (2.60470262379956e-11,2.11387326274783e-11,-2.67774966904001e-13) (2.83712637551646e-11,2.98476643872131e-11,-3.67634168549917e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.55422471538991e-12,-1.73135352378545e-13,-1.06931449082086e-11) (-3.35628839580213e-13,-1.09099665410983e-12,-1.04626730202656e-11) (1.72608489258572e-12,-1.85015037211733e-12,-9.34093172649272e-12) (3.65273119439674e-12,-5.01645815291854e-13,-8.09828389168697e-12) (6.53574915735251e-12,2.25684477630416e-12,-5.69577104967572e-12) (1.07982513768973e-11,6.32324005823074e-12,-1.42805360702819e-12) (1.96277946286921e-11,1.38894854172144e-11,7.56303818482721e-12) (2.57931891353954e-11,1.60272490937342e-11,4.58757816122791e-12) (3.00245842516661e-11,2.17577409624391e-11,8.33744449280282e-13) (3.20575248571796e-11,3.05563854231234e-11,-3.68807052843927e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.44916968632376e-12,1.00158495107657e-12,-1.22384777578689e-11) (-6.90197690478376e-13,1.96080118868506e-13,-1.2222948269201e-11) (1.22269210948862e-12,-6.44238700483692e-13,-1.15943330814373e-11) (3.27627637324589e-12,7.70982062687623e-14,-1.0243610198378e-11) (6.77579325636998e-12,2.55027856953445e-12,-7.85307026975415e-12) (1.1734272772515e-11,5.79029268642187e-12,-2.84718195794328e-12) (2.19329163733371e-11,1.08502945519022e-11,7.55539426338934e-12) (2.9529125982647e-11,1.57247289788315e-11,5.0277215939527e-12) (3.36028707759848e-11,2.13478224278437e-11,6.83647517512273e-13) (3.56202675103771e-11,3.00891786548094e-11,-7.17805514837063e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-6.15877078766941e-13,1.920401382909e-12,-1.6318281832334e-11) (-6.83031717243336e-13,1.6883566351567e-12,-1.62520413245569e-11) (1.33457520370657e-12,6.4238612747976e-13,-1.57118583788066e-11) (4.18006575713065e-12,8.94810541911837e-13,-1.43558783380184e-11) (8.37527972499163e-12,2.5588979588774e-12,-1.23616598022812e-11) (1.36341799214544e-11,5.24174136112156e-12,-7.82657791139101e-12) (2.37377363387891e-11,1.07686176956328e-11,2.72835685126874e-12) (3.12958125141377e-11,1.49755862836552e-11,1.1262503464001e-12) (3.55210055575283e-11,2.05617511848342e-11,-1.09627527941657e-12) (3.78010398562697e-11,2.88591567863794e-11,-1.43915745900727e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-6.07758963674813e-13,2.53444881174666e-12,-2.52109878369608e-11) (-1.63117778233578e-13,2.8528844774382e-12,-2.44425581780195e-11) (2.61262842097408e-12,1.51126213804372e-12,-2.31177031128918e-11) (6.10985268783451e-12,1.62588998675867e-12,-2.17004619406565e-11) (1.02867101249188e-11,2.86885125577048e-12,-1.97223823038552e-11) (1.62184975606314e-11,5.4741221367976e-12,-1.58517096836772e-11) (2.47925879735529e-11,1.0500125768551e-11,-9.66949143028827e-12) (3.1193056125235e-11,1.35409686516333e-11,-7.74305962223706e-12) (3.51126009927551e-11,1.89874406665861e-11,-5.67051215435907e-12) (3.69784317377438e-11,2.66666391190342e-11,-3.171755149896e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.55686397874647e-13,2.26524225991252e-12,-3.61674275577354e-11) (1.06045949205881e-12,2.98386024062918e-12,-3.48552288674695e-11) (4.0702109557534e-12,1.90027233771547e-12,-3.28063945337493e-11) (7.71325022935638e-12,1.7572557744179e-12,-3.12222170818189e-11) (1.20583263278537e-11,2.40918949435464e-12,-2.93069781134603e-11) (1.87744276356147e-11,4.00905331960282e-12,-2.59602005920469e-11) (2.58906456738248e-11,6.91531650961643e-12,-2.12966281544885e-11) (3.11428169949739e-11,9.67268428378225e-12,-1.73159894561406e-11) (3.485378161031e-11,1.50769377267062e-11,-1.28796823080993e-11) (3.56581204225548e-11,2.22745919892082e-11,-7.20202161828916e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.0836574513464e-12,1.19362924006011e-12,-4.62023304581126e-11) (2.71093908096394e-12,1.79870904206905e-12,-4.50958250472635e-11) (5.90291555554396e-12,1.22124121487155e-12,-4.28796247143901e-11) (9.28648283141461e-12,1.31420383612719e-12,-4.10531540920039e-11) (1.36828015732142e-11,1.45867635580913e-12,-3.8440044023274e-11) (2.04148426431718e-11,1.9794084137877e-12,-3.48487509017755e-11) (2.62203901247091e-11,3.18748800535609e-12,-3.05853489080618e-11) (3.0949651113133e-11,4.7702839923488e-12,-2.64108343851682e-11) (3.40792304746262e-11,8.50441565392178e-12,-2.13489354701056e-11) (3.38349672783713e-11,1.35612221069768e-11,-1.27232598466184e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.17558455179011e-14,-7.69531772122988e-14,-4.04545404847563e-12) (-5.99620940358308e-15,-1.41713356016213e-12,-3.79213771162757e-12) (-1.13019929204718e-14,-1.30321794274299e-12,-3.79415255380017e-12) (6.99708472204794e-13,2.71218449831552e-13,-3.85758833153936e-12) (1.51214728305532e-12,2.48921361775346e-12,-3.74969579918579e-12) (2.15603378251244e-12,5.74479548090278e-12,-3.36508899776269e-12) (3.62265949908013e-12,9.54949054156201e-12,-3.19051839671303e-12) (5.41648070379978e-12,1.36630869477091e-11,-2.71972358033455e-12) (7.20650417173858e-12,1.73515791895747e-11,-2.04860249390014e-12) (7.715568401306e-12,1.85102403735858e-11,-8.28324940656645e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (6.01939742367876e-14,2.21933555618424e-13,-7.72532859078496e-12) (1.19002820732629e-13,-7.63277382984369e-13,-7.13313734327572e-12) (3.05672471352932e-13,-6.53517529377317e-13,-6.60740589788844e-12) (1.4152164877394e-12,7.94811205043905e-13,-6.03004830911323e-12) (2.89214301433567e-12,2.48222563878181e-12,-5.50321545284612e-12) (4.11489173894208e-12,5.61159238876463e-12,-5.0043676010565e-12) (6.92386312912064e-12,9.03523454390034e-12,-4.61472121394722e-12) (1.08056861855994e-11,1.27641614803273e-11,-3.5787974617436e-12) (1.37857827199619e-11,1.65115828321442e-11,-2.55229376611087e-12) (1.47044841223834e-11,1.84675313622964e-11,-1.33048178020689e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.38395259964932e-13,2.7732555244808e-13,-1.12736312753197e-11) (2.34502364967693e-14,-4.81225454779375e-13,-1.04986536288355e-11) (7.25392727383607e-13,-3.58239701976265e-13,-9.53351546432084e-12) (2.16974974959016e-12,1.4575771594947e-12,-8.24085128547137e-12) (3.60892546577154e-12,3.09125235983293e-12,-6.89378192767749e-12) (4.70328722804962e-12,5.93774303310995e-12,-5.96470602895379e-12) (7.85600606873006e-12,8.77910068633126e-12,-5.60511651019336e-12) (1.45103917376359e-11,1.23114536405815e-11,-3.5482373926832e-12) (1.94904828764473e-11,1.63627512675792e-11,-2.46362346921641e-12) (2.06596295520799e-11,1.82930578081587e-11,-9.85021323043962e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.40128929121729e-12,3.62819879894169e-13,-1.41298852990529e-11) (-1.15752561134402e-12,-2.94936691354957e-13,-1.36874706694077e-11) (4.1209392131643e-13,-1.49655805305636e-13,-1.26248582926786e-11) (2.14976828659388e-12,2.13209259226668e-12,-1.07978886171072e-11) (3.67279599763845e-12,4.06796642525032e-12,-8.36021647188889e-12) (5.00827357846131e-12,7.18268776320535e-12,-5.88794432294948e-12) (8.84336108099266e-12,9.97734571205637e-12,-3.1895636536404e-12) (1.93385731676508e-11,1.26011261357697e-11,4.24505027432921e-13) (2.55278771047835e-11,1.62868860404082e-11,-5.63404550950962e-13) (2.72949085505077e-11,1.88717646020418e-11,-3.57085517979202e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.95941690678145e-12,7.9624206219716e-13,-1.53822785724455e-11) (-2.74444690631488e-12,1.35749924085539e-13,-1.5752581551968e-11) (-7.22474613866784e-13,-7.97803640793496e-14,-1.50485134105639e-11) (6.71474330837148e-13,2.09451231062595e-12,-1.29995885262235e-11) (1.9745979215004e-12,4.17273839819091e-12,-9.38507318846695e-12) (2.34010695673891e-12,6.76961275281845e-12,-5.10656645730566e-12) (2.56424455177146e-11,-4.58580433021857e-12,-5.60447215061425e-17) (2.98495429621839e-11,1.60296144815743e-11,1.27120025324085e-11) (3.16370542883194e-11,1.68824517602879e-11,2.0443652611336e-12) (3.21559245728178e-11,1.98854495975088e-11,-2.00091928232903e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.38351560679338e-12,1.76633806550643e-12,-1.72305317783178e-11) (-2.81108939454381e-12,1.20269660793989e-12,-1.75782279142767e-11) (-1.41465560149352e-12,3.29889037353274e-13,-1.72482239796353e-11) (6.80241089695454e-14,1.32717223882284e-12,-1.52377673689163e-11) (1.76128555519396e-12,2.99841806337608e-12,-1.15379239169956e-11) (1.88024787644221e-12,3.79870753296168e-12,-6.52293848595788e-12) (2.45422658991042e-11,8.34472750121379e-12,-7.12906581820281e-16) (3.46223427542513e-11,1.5496692832214e-11,1.62690591646452e-11) (3.57903950514247e-11,1.64566850281429e-11,2.3508905420397e-12) (3.61324838639127e-11,2.00738661543767e-11,-8.54233312040842e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.29616501537304e-12,2.37159465710252e-12,-2.09581578042319e-11) (-2.38774250528313e-12,2.42184120126977e-12,-2.1339549732361e-11) (-8.90280847641794e-13,9.80667324579058e-13,-2.11602325729835e-11) (1.45476777654298e-12,7.74723553417195e-13,-1.9364332537641e-11) (3.53024453713885e-12,1.31502167510955e-12,-1.62383229562032e-11) (2.84686438317606e-12,-4.77927517204843e-13,-1.29089220261625e-11) (2.56083347709033e-11,1.661722427554e-11,-1.6775190751587e-11) (3.49529557719457e-11,1.3565637760011e-11,7.76981751305626e-12) (3.74381982552855e-11,1.59872520494355e-11,-1.15027270048083e-12) (3.85544000646032e-11,1.91218406750288e-11,-2.20489436246074e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.10698207078636e-12,2.85630806871844e-12,-2.88011585289677e-11) (-1.61894860651507e-12,3.25972376303947e-12,-2.84178964720936e-11) (8.06377049117617e-13,1.60108024484621e-12,-2.74186355074736e-11) (4.00040726323565e-12,1.04947377981084e-12,-2.54624117773072e-11) (6.87569926623916e-12,1.58625529872419e-12,-2.20799543010831e-11) (1.15013481242429e-11,3.51920227051011e-12,-1.74792591606144e-11) (2.64509654246258e-11,1.76804385069641e-11,-6.51521233449161e-12) (3.29887930251502e-11,1.36105967705291e-11,-7.82574257168241e-12) (3.65243469282788e-11,1.52699883753166e-11,-7.11162985400367e-12) (3.8198723717625e-11,1.73606213459791e-11,-4.05491431121056e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-8.48992726722214e-14,2.51963868299738e-12,-3.67027085579528e-11) (1.96776356942467e-13,3.22266725009178e-12,-3.55287611810241e-11) (3.16506462673611e-12,1.93170496730481e-12,-3.35263677987605e-11) (6.24106319921436e-12,1.17630450618447e-12,-3.1320068237916e-11) (9.6620619449544e-12,1.62557260861372e-12,-2.83838525422187e-11) (1.61405001038783e-11,3.11411471956244e-12,-2.48142288842941e-11) (2.56378354797036e-11,7.51778989618932e-12,-2.01001057558114e-11) (3.16089101384679e-11,9.24789407326776e-12,-1.67840907688868e-11) (3.57486429931634e-11,1.19336344924101e-11,-1.2553998455345e-11) (3.71694686865103e-11,1.41520357705834e-11,-6.65309480443848e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.17078128055755e-12,1.23525457822453e-12,-4.13482135186536e-11) (2.2934477901595e-12,1.83874055321701e-12,-4.01361439994385e-11) (5.29768614803259e-12,1.14737859607263e-12,-3.76683983581642e-11) (7.98757659881897e-12,7.66456578536735e-13,-3.5191653675325e-11) (1.15501848075159e-11,1.00560025298664e-12,-3.21202086066771e-11) (1.81308490632792e-11,1.75531984966128e-12,-2.85602262095461e-11) (2.52333636071623e-11,3.18220685027056e-12,-2.47071903380395e-11) (3.06580361905201e-11,4.58763497355312e-12,-2.08462713812143e-11) (3.39579705049144e-11,6.73752022190044e-12,-1.56283899448315e-11) (3.46729295387945e-11,8.21374070056483e-12,-8.15022243463311e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-5.83958915194223e-13,6.87040685226432e-13,-5.45165676419649e-12) (-6.57837544395352e-13,1.43538558340923e-12,-5.25459160114437e-12) (-5.97566628561327e-13,2.70934763738627e-12,-5.36735337004543e-12) (6.82231846495115e-14,4.65195936502651e-12,-5.57880319177905e-12) (1.13452846058337e-12,6.77364357180538e-12,-5.4421364345872e-12) (2.11466627362695e-12,1.07471602273263e-11,-4.79222866595707e-12) (3.66612068035862e-12,1.33997914707658e-11,-4.27885615471469e-12) (5.64428508473968e-12,1.44342906473855e-11,-3.50731836490001e-12) (6.82622297593005e-12,1.3854991374506e-11,-2.35764115395981e-12) (6.92995247196604e-12,1.19477909828782e-11,-9.00382002404151e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-5.87389270068526e-13,7.59918984048169e-13,-9.38577992080269e-12) (-6.88780552881191e-13,1.57392313759604e-12,-9.03002326291644e-12) (-5.66962944812396e-13,3.0364784367543e-12,-8.96940830063443e-12) (2.25617676991725e-13,4.97794029179188e-12,-8.80930740994826e-12) (1.78426844152753e-12,6.5336850713174e-12,-8.30324433451946e-12) (3.39909470749807e-12,9.84039328107251e-12,-7.73318815002441e-12) (6.14407323451753e-12,1.18495387532265e-11,-7.39908577404017e-12) (1.02318903296337e-11,1.3068683906495e-11,-5.14757704958134e-12) (1.27128022986441e-11,1.28953316660738e-11,-2.6665085811285e-12) (1.35484758963345e-11,1.20930414969031e-11,-9.73791436993878e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-7.22076714004391e-13,8.96804576494883e-13,-1.31275359096535e-11) (-1.12797669140992e-12,1.81582879319646e-12,-1.30199994656663e-11) (-7.75855348139131e-13,3.45452784027993e-12,-1.29235338582115e-11) (1.48164958990813e-13,5.38387821296782e-12,-1.18809958595825e-11) (1.70313550162294e-12,6.75024036632297e-12,-1.04775209675646e-11) (3.09875297921269e-12,9.00419262672752e-12,-9.45904893493761e-12) (4.60088192556977e-12,8.14327701164529e-12,-1.18203406715301e-11) (1.31361053189489e-11,1.06286591140011e-11,-5.72722406511927e-12) (1.80877459574386e-11,1.21233266786385e-11,-2.72736088615676e-12) (1.90959014352673e-11,1.22048078929834e-11,-8.17635325336114e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.27712610317553e-12,1.27043736350299e-12,-1.70917947592119e-11) (-2.65082460350387e-12,2.07846632059979e-12,-1.72971814977065e-11) (-1.48475119547458e-12,3.40706222303871e-12,-1.69141070114024e-11) (-2.50323576976111e-13,5.43150270152632e-12,-1.49913261675827e-11) (1.09575187575327e-12,7.31171983795145e-12,-1.21068465725736e-11) (2.7229679194736e-12,1.14238757277837e-11,-7.87206974152639e-12) (1.9792442442211e-11,-2.77231069389437e-12,2.13393181721891e-16) (1.68979944002365e-11,6.96653067366962e-12,-1.14025119455468e-12) (2.47259923518998e-11,1.10901007492402e-11,-1.46261639760748e-12) (2.59241380368073e-11,1.24106292621211e-11,-5.78856767003286e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.55920993057571e-12,1.5152967921362e-12,-2.01131042228834e-11) (-4.51546173157148e-12,2.11676507664148e-12,-2.06375104405705e-11) (-3.18106889965757e-12,2.92045604151437e-12,-2.00881122039367e-11) (-2.1757009351048e-12,4.54445928345403e-12,-1.767057643163e-11) (-1.12958847485212e-12,5.89716753344681e-12,-1.34759853853635e-11) (2.04501764045914e-13,7.51263459931492e-12,-7.80398205017285e-12) (-1.44890848686708e-16,8.8269833688351e-16,-3.58170762496651e-17) (4.1050101882786e-11,5.90083998815339e-12,7.27692313006277e-17) (3.4307278209809e-11,1.09721190645873e-11,-1.44366584612987e-12) (3.17674160878101e-11,1.33997207068496e-11,-1.12294734220141e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.64107606240011e-12,1.92476126271394e-12,-2.34755830668857e-11) (-4.36023792251435e-12,2.33026291478907e-12,-2.35643423332769e-11) (-4.07589049945081e-12,2.20124058513502e-12,-2.2760721356049e-11) (-3.07937065753661e-12,2.36183119690062e-12,-2.0235288567771e-11) (-1.57030348759901e-12,3.22993320044783e-12,-1.58767020773104e-11) (-3.65342652687257e-13,3.46045737455495e-12,-9.17058916772377e-12) (-2.94644891914539e-18,6.68139945075173e-16,-6.54927295602066e-17) (5.04715664490258e-11,3.70137290800182e-12,-3.25512628388557e-16) (3.94649518842802e-11,1.04778429609956e-11,-2.93378927284913e-12) (3.6230276031085e-11,1.35528919053903e-11,-2.60160017004353e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.39948649887684e-12,2.41087669090135e-12,-2.76411947459616e-11) (-3.40494222641248e-12,3.00432984378266e-12,-2.77080865640686e-11) (-3.30659380324868e-12,1.91845665237671e-12,-2.65840566063892e-11) (-1.94599203129898e-12,5.89804428785575e-13,-2.39595536936604e-11) (-7.03900165157321e-14,2.94392827249742e-14,-2.02223392494517e-11) (2.71600332083148e-12,-1.48526335903748e-12,-1.40426179763624e-11) (1.12274906770806e-16,9.19355100684319e-16,-1.13539925483751e-15) (4.38280869748768e-11,9.40707781160347e-12,-1.25305827992082e-11) (3.92100835914198e-11,1.14023405955542e-11,-7.49563336220016e-12) (3.81107250311435e-11,1.27005560328755e-11,-4.26254664989557e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.15357474203127e-12,3.22701998773756e-12,-3.33791776070556e-11) (-2.58115305810789e-12,3.56014550229804e-12,-3.24949385808066e-11) (-1.48047140356205e-12,1.84745078599033e-12,-3.06772613412399e-11) (4.91119060673177e-13,1.96412399167882e-13,-2.85909371117211e-11) (2.2356868158616e-12,-1.8553551137639e-12,-2.6072264891914e-11) (9.42388849043236e-13,-8.17087703409333e-12,-2.39457706770487e-11) (3.79241442727236e-11,1.25304375811001e-11,-2.46137533627982e-11) (3.66373830046374e-11,1.13535075500768e-11,-1.74426963515725e-11) (3.68039852684343e-11,1.11834756942804e-11,-1.14111613462548e-11) (3.73523949818382e-11,1.11471188704535e-11,-5.6523393558634e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (2.55374551674389e-14,2.81428431540995e-12,-3.8127846712319e-11) (-4.21690328481538e-13,3.07541872030011e-12,-3.66209757510364e-11) (1.74309143719436e-12,1.70662223215286e-12,-3.44150687888763e-11) (3.71469543111244e-12,5.18012058469639e-13,-3.23878102728342e-11) (6.71241064265804e-12,-6.60039847917156e-14,-3.01430362860074e-11) (1.27851718452582e-11,8.33341715658088e-14,-2.79945933159859e-11) (2.66574035387386e-11,6.33998332391932e-12,-2.55865096839562e-11) (3.20390769246344e-11,7.84962421368367e-12,-2.01966106001501e-11) (3.50438536127562e-11,8.562914802629e-12,-1.39139237928107e-11) (3.64546689521952e-11,8.64626306077739e-12,-6.85685373116095e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.19396633956701e-12,1.32919055798537e-12,-4.06592719930129e-11) (1.66444270210232e-12,1.61292233100765e-12,-3.91738929146093e-11) (3.96832006126566e-12,1.01824635973083e-12,-3.6676652472536e-11) (5.68258810870788e-12,4.22457170633394e-13,-3.41484455340563e-11) (8.99580266337083e-12,3.5661274772549e-13,-3.16824760185559e-11) (1.60331330414331e-11,1.0782772301248e-12,-2.92220322615794e-11) (2.45546515006077e-11,2.96867598366029e-12,-2.59004879391186e-11) (3.00277897276902e-11,3.94330940216783e-12,-2.07600070352715e-11) (3.32173232166385e-11,4.79098117794884e-12,-1.45396810286531e-11) (3.47364478046977e-11,4.91346850884708e-12,-7.07420150614582e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-8.53902377053307e-13,3.31375439102098e-12,-7.38120013124029e-12) (-6.83613329701668e-13,5.96953590938679e-12,-7.10669123778417e-12) (-7.13247606181829e-13,7.84687958829139e-12,-6.77477019670336e-12) (-3.94424499315232e-13,9.62120449206737e-12,-6.79351602576447e-12) (7.2457919243892e-13,1.1331129198905e-11,-6.86533968060942e-12) (2.5080607086242e-12,1.38361681343596e-11,-6.58594933178712e-12) (4.44483560812137e-12,1.3989672865155e-11,-5.5870572907042e-12) (5.86021461464139e-12,1.28016997489863e-11,-3.94729162584321e-12) (6.32862353287573e-12,1.04220190831278e-11,-2.23368225687355e-12) (5.88431995556937e-12,7.73984892321171e-12,-7.28720695640558e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.0800315203921e-12,2.76385933516003e-12,-1.27395310088581e-11) (-9.9130117077513e-13,5.36422359307339e-12,-1.21346928325731e-11) (-1.14511323900164e-12,7.66061692148825e-12,-1.11556853047634e-11) (-6.8638331963369e-13,9.66052589084432e-12,-1.07383587833391e-11) (9.9765696203333e-13,1.11185292833105e-11,-1.06348889190675e-11) (3.90119298583145e-12,1.28387923838125e-11,-1.03067364120592e-11) (7.59882625162229e-12,1.2380155433091e-11,-8.88596192947162e-12) (1.01908466537173e-11,1.12454410670729e-11,-5.64299090015655e-12) (1.1792090141888e-11,9.14528422432865e-12,-2.71651936593887e-12) (1.24629180633139e-11,7.32834407517029e-12,-9.74294420504733e-13) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.20324594499329e-12,2.28288974376919e-12,-1.68848284615198e-11) (-1.48707982627817e-12,4.58939315073036e-12,-1.65464629643282e-11) (-1.77092772953552e-12,7.24355161363839e-12,-1.55938294945695e-11) (-1.30293442156379e-12,9.34296502012659e-12,-1.43218749609045e-11) (1.23183997337023e-13,1.06268119700936e-11,-1.30667263953964e-11) (3.04036161475757e-12,1.12249378847544e-11,-1.1952131315114e-11) (9.42335302469824e-12,9.12343377214836e-12,-1.24936576166541e-11) (1.37983705802447e-11,8.90651130841701e-12,-6.32710366804397e-12) (1.7211246326018e-11,8.19131628111057e-12,-3.13204743495755e-12) (1.80724447405733e-11,7.37722999853051e-12,-1.09344842813272e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.31659879329644e-12,2.1578644077571e-12,-2.08157888159066e-11) (-3.07219784584948e-12,4.07423575633337e-12,-2.07314049266609e-11) (-2.92092585775054e-12,6.20768015980969e-12,-1.970505907185e-11) (-2.24775975390486e-12,8.19112830981029e-12,-1.76727625551772e-11) (-1.72447265080145e-12,9.9642427517605e-12,-1.4919374295209e-11) (-1.23807408676495e-12,1.25181759058395e-11,-1.06323117669516e-11) (1.81597136377186e-11,2.17373839647698e-12,1.20754511611723e-16) (1.82860502888145e-11,6.20724269424309e-12,-2.67487810513055e-12) (2.39602144059675e-11,7.71133762357187e-12,-2.8046149722887e-12) (2.43561898251449e-11,8.11613628911758e-12,-1.28872531274604e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.44426818347529e-12,1.85954374011671e-12,-2.37781372556909e-11) (-5.27835780634242e-12,3.24489367619897e-12,-2.39095657834039e-11) (-4.8793892156028e-12,4.76203760457841e-12,-2.3095612339133e-11) (-4.1876638948113e-12,6.23616614515295e-12,-2.07670847929177e-11) (-4.13435747705356e-12,7.52432612489739e-12,-1.66147059028426e-11) (-3.54726724431905e-12,8.63499389228159e-12,-1.04266985393186e-11) (-3.89187644286625e-17,4.45482256910077e-16,-3.36048591121347e-17) (4.46933075783002e-11,5.58985214621371e-12,8.40332412585428e-17) (3.44808358094923e-11,8.51197335048586e-12,-4.12116119689019e-12) (3.04912975470442e-11,9.88873375465715e-12,-2.48981740003674e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.03843222418112e-12,1.64988063724422e-12,-2.71383417653527e-11) (-5.83792582875858e-12,2.61244025635491e-12,-2.68143365104311e-11) (-6.31853935493171e-12,3.33102199992873e-12,-2.58738615852611e-11) (-5.66593037994212e-12,3.32278774893453e-12,-2.35820335238236e-11) (-5.07592247942241e-12,3.6125025053275e-12,-1.94210285163784e-11) (-4.59014559411703e-12,2.96310158404074e-12,-1.21480887082635e-11) (5.85829430005848e-18,2.63596633904444e-16,-5.56749650986743e-17) (4.76993253056473e-11,9.00958433354044e-12,-2.40678845533787e-16) (3.82082651468904e-11,1.02597522675211e-11,-6.51388563346034e-12) (3.44810117335663e-11,1.09933995997645e-11,-4.2100198663176e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.14873797763751e-12,1.82992614538098e-12,-3.1125188036415e-11) (-5.08478784256745e-12,2.58785984759503e-12,-3.08271213086258e-11) (-5.86009084959889e-12,2.23794687256315e-12,-2.9475022410445e-11) (-5.28981444588949e-12,6.55492931982635e-13,-2.70383637987203e-11) (-4.36531689310765e-12,-9.54022622998693e-13,-2.40187155960352e-11) (-4.63986558124925e-12,-4.48885944180776e-12,-1.7769996401167e-11) (4.14488611288181e-17,4.24144388508832e-16,-5.69892120041257e-16) (3.68467077993601e-11,2.27059672334321e-11,-2.32904158834656e-11) (3.61958617804252e-11,1.32526968423491e-11,-1.29487046887118e-11) (3.54016155436294e-11,1.12726028290571e-11,-6.33499024027872e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.62507809594301e-12,2.32347554020376e-12,-3.53686984928803e-11) (-3.91410351570971e-12,2.34881678613034e-12,-3.44288466018325e-11) (-3.42596707927158e-12,9.01619164909217e-13,-3.26719500351417e-11) (-2.34915281838125e-12,-1.12758315050088e-12,-3.11023395780325e-11) (-1.68015852799228e-12,-5.078378049584e-12,-3.07499588650487e-11) (-6.64383967081007e-12,-1.90306936991386e-11,-3.34948846168647e-11) (3.69435415186505e-11,2.3290288362127e-11,-5.3669170595687e-11) (3.41097313357107e-11,1.52028252618014e-11,-2.96190970712603e-11) (3.36657241697653e-11,1.15034209196045e-11,-1.6811633890155e-11) (3.42009114355894e-11,9.76969729195953e-12,-7.85904468644157e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.76025135101305e-15,1.60673822579359e-12,-3.86663796665587e-11) (-1.16510090132156e-12,1.19115970516427e-12,-3.7245402107097e-11) (4.04208793485742e-13,6.07006631361386e-15,-3.54703871701752e-11) (1.56547633213728e-12,-8.65907964467422e-13,-3.39082129391866e-11) (4.14135094012552e-12,-1.85147536044973e-12,-3.33646108099105e-11) (9.3821451546443e-12,-2.86280584984428e-12,-3.37681644625291e-11) (2.46388117952116e-11,7.08114903881871e-12,-3.55183184103434e-11) (2.9662704928807e-11,7.85776418006289e-12,-2.67644408889589e-11) (3.17587171757717e-11,7.57520432977632e-12,-1.72975067359096e-11) (3.33306097730129e-11,6.82985082389719e-12,-8.42139748376713e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (1.03777781914867e-12,5.67686087726782e-13,-4.07870983358385e-11) (7.80124591036749e-13,2.72414099445123e-13,-3.92145821565716e-11) (2.4583594825173e-12,-2.12150166648407e-13,-3.72029297545698e-11) (3.63907576384058e-12,-3.75971038191953e-13,-3.51591786042525e-11) (6.89197165412048e-12,-3.65860692036339e-13,-3.41136077867246e-11) (1.37898659490961e-11,1.61613041312343e-13,-3.33001617352179e-11) (2.23828465804211e-11,2.47426597124652e-12,-3.08039503116778e-11) (2.77507731232396e-11,3.013150771271e-12,-2.42923203299047e-11) (3.0542824872088e-11,3.45816550555485e-12,-1.66070094810049e-11) (3.25757148073791e-11,3.32034752773536e-12,-8.33819141212921e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-5.78516214602795e-13,3.8584757611636e-12,-8.65556696019272e-12) (-4.10222054490011e-13,7.13317286151966e-12,-8.85149893580959e-12) (-5.08239110330007e-13,9.83885010343094e-12,-8.81578649084645e-12) (-3.61922243243284e-13,1.25292108185441e-11,-8.69421749600275e-12) (6.57788759202383e-13,1.54600402624672e-11,-8.79022486379179e-12) (2.50654441809774e-12,1.70398898120369e-11,-8.38301638385697e-12) (4.41458737529433e-12,1.57905270717311e-11,-7.0770393976551e-12) (5.70286392760877e-12,1.29466786187942e-11,-5.14174694744957e-12) (6.10039683044922e-12,9.25061311920914e-12,-2.92731562874773e-12) (5.56710410795942e-12,6.73052246469969e-12,-1.00887426697967e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.20390010530621e-12,3.41555937949628e-12,-1.56847552381414e-11) (-1.19547825625533e-12,6.71353843970748e-12,-1.55876294046423e-11) (-1.14537445255725e-12,9.93669019236619e-12,-1.48983317003895e-11) (-4.72292313185994e-13,1.26221403599603e-11,-1.42111209913783e-11) (1.16122176824365e-12,1.4876745948522e-11,-1.40058664420576e-11) (4.09427300226954e-12,1.59576974049646e-11,-1.32157848290749e-11) (7.61257688326859e-12,1.44573685304849e-11,-1.07198252267643e-11) (9.60330487814497e-12,1.14433980106265e-11,-7.27998551284156e-12) (1.10038331396333e-11,8.10995621704334e-12,-3.81739630886584e-12) (1.14397377193808e-11,6.48117732978617e-12,-1.42782363368557e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.41658610616049e-12,2.76128887888482e-12,-2.02733011618818e-11) (-1.92455590164952e-12,5.55174247501538e-12,-2.01987017643099e-11) (-2.00701080936149e-12,9.10305655598811e-12,-1.93209553486601e-11) (-1.40624627676713e-12,1.18258742706049e-11,-1.80178628907975e-11) (-3.28841864588169e-13,1.35420283449284e-11,-1.68493191910248e-11) (2.28864989518311e-12,1.37180028740259e-11,-1.54585898213065e-11) (1.02064944517801e-11,1.23590944859924e-11,-1.26259406194561e-11) (1.33025829613349e-11,9.57592754631796e-12,-8.3434230230046e-12) (1.56526259768362e-11,7.22787755035378e-12,-4.58680122591607e-12) (1.62400900218315e-11,6.64889636596544e-12,-1.84278128345109e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.10266201489093e-12,2.50615927897127e-12,-2.38973872651898e-11) (-3.26920162051371e-12,4.73571663087497e-12,-2.39235712171568e-11) (-3.50757981922796e-12,7.66036231748414e-12,-2.27878003814717e-11) (-3.0461858491725e-12,9.99703076656611e-12,-2.08323951050436e-11) (-3.57161855222977e-12,1.14794609467888e-11,-1.90803319010355e-11) (-7.98732459468197e-12,1.01124825686104e-11,-1.85230163058598e-11) (2.30080054115806e-11,9.94787498750401e-12,-2.94511005890661e-11) (1.90331777039952e-11,8.16023915744927e-12,-9.64282418720887e-12) (2.16436890195407e-11,7.15108532868094e-12,-5.88098654654693e-12) (2.12948670468318e-11,7.50341780468815e-12,-2.58596428623204e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.10317655291045e-12,2.30746590973852e-12,-2.62193877212814e-11) (-5.45985783074858e-12,3.83013530986005e-12,-2.63360747310954e-11) (-5.77690115715888e-12,5.91773411134117e-12,-2.56483054278943e-11) (-5.42666438867797e-12,7.90414733150632e-12,-2.37056318219644e-11) (-6.41054122100516e-12,9.6180326668818e-12,-2.06178648265455e-11) (-8.30203987053311e-12,1.3886249465355e-11,-1.54497510622672e-11) (2.53287582062932e-17,4.51848576109008e-16,-1.23188702927074e-16) (4.53948206211089e-11,7.5611955284257e-12,-2.31958647858198e-11) (3.11017130956314e-11,8.5332259961288e-12,-1.09719361925567e-11) (2.68968143019711e-11,9.44784573714988e-12,-4.87164393696311e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.54248298724847e-12,2.10223835513416e-12,-2.93176363758082e-11) (-6.75382034516539e-12,2.98666604861007e-12,-2.90477933199716e-11) (-7.51729228901899e-12,4.00944734062353e-12,-2.85414343822751e-11) (-7.15964057039556e-12,4.60240689572945e-12,-2.69652416990537e-11) (-7.78233715924117e-12,4.66870065849315e-12,-2.39891122602346e-11) (-9.28621760156872e-12,3.47075974011707e-12,-1.78237501504608e-11) (3.03144201307822e-17,3.03200928378105e-16,-1.64483819478014e-16) (4.05165873603697e-11,1.63347751732211e-11,-2.75715775761078e-11) (3.29114548049506e-11,1.16877900575275e-11,-1.47009375324115e-11) (2.99917886379492e-11,1.10131046070081e-11,-6.92341577580618e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.94035410028683e-12,1.76628090671194e-12,-3.31900641025151e-11) (-6.1978436792798e-12,2.4166148343791e-12,-3.27786238211281e-11) (-6.96042175367184e-12,2.25653472406747e-12,-3.19994185983995e-11) (-6.52638656610214e-12,1.14361119796598e-12,-3.056117955818e-11) (-6.48968066136396e-12,-5.45758742085798e-13,-2.86272031661106e-11) (-7.86745783297388e-12,-4.74378893152944e-12,-2.32593904917735e-11) (2.32224664984663e-17,3.78954087555917e-16,-5.20434250408023e-16) (3.40081385762406e-11,1.82801986420259e-11,-3.49799410596974e-11) (3.13314232546792e-11,1.31164604109759e-11,-1.90417897461464e-11) (3.05695308404531e-11,1.1308438994999e-11,-9.08634064025821e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.84819267260187e-12,1.42341872456375e-12,-3.74823348710102e-11) (-4.51334300142444e-12,1.67587984302755e-12,-3.65912814879289e-11) (-4.10002843775936e-12,4.7653508616484e-13,-3.52319941925431e-11) (-2.96320871742998e-12,-1.46677279504934e-12,-3.41948728378359e-11) (-2.16213546530661e-12,-5.0155917105103e-12,-3.47543799645048e-11) (-2.63744154130533e-12,-1.86363113151532e-11,-3.82724358306549e-11) (2.91026073175638e-11,1.47584555496855e-11,-5.70540023809465e-11) (2.86473292363495e-11,1.32385453078204e-11,-3.47745168338077e-11) (2.86413515558357e-11,1.09454696586065e-11,-2.05995890405788e-11) (2.92817132171608e-11,9.29200651646051e-12,-9.93492469249517e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.78165170060143e-13,4.14431441815196e-13,-4.03308785918844e-11) (-2.02137023248506e-12,4.32323509211478e-13,-3.93789514079586e-11) (-9.3974520456015e-13,-1.77875008646785e-13,-3.8152576589841e-11) (5.31937276568152e-13,-1.01735469861698e-12,-3.70485196590517e-11) (3.0592899243506e-12,-1.98681751222114e-12,-3.70632624687756e-11) (8.10788021130174e-12,-2.93878537644422e-12,-3.78817555310749e-11) (2.04918173413591e-11,5.82632697867179e-12,-3.93934097773363e-11) (2.50403841845382e-11,7.43432973669399e-12,-3.0210094370651e-11) (2.69996467478437e-11,6.92123979606095e-12,-1.97949686229253e-11) (2.84187155854171e-11,5.94177632539747e-12,-9.91272887799948e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.2947727608414e-14,-5.936502778741e-14,-4.23610409164899e-11) (-9.59113711519609e-13,-1.01458463417337e-13,-4.15549774001961e-11) (2.02458165551634e-13,-1.12185037765905e-13,-4.04792371661829e-11) (2.21753390812085e-12,-2.60402985554306e-13,-3.89511397425086e-11) (5.71266491057721e-12,-4.99451780070906e-13,-3.80110783236337e-11) (1.14552675668681e-11,1.06597705034193e-13,-3.7241866562059e-11) (1.83454825698947e-11,2.55328639625417e-12,-3.44767163813228e-11) (2.30786130456123e-11,3.16471357138237e-12,-2.75360438848789e-11) (2.57321723087522e-11,3.22359184004108e-12,-1.91481839582891e-11) (2.75578709229728e-11,2.84507938197526e-12,-9.98000260763562e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (6.03321427139391e-14,4.21949706894578e-12,-1.03494536892316e-11) (-2.63000776722664e-14,7.9510121510568e-12,-1.07818344991243e-11) (-7.27648194070199e-13,1.21725149378563e-11,-1.11820460971182e-11) (-3.58844416884509e-13,1.62914587910519e-11,-1.12622423911736e-11) (8.3387459320161e-13,1.98058826308103e-11,-1.11651447212079e-11) (2.28275983896535e-12,2.05302537371515e-11,-9.9517934813075e-12) (3.81245346630361e-12,1.77002943416632e-11,-7.96322730903698e-12) (4.99171321711152e-12,1.34967604863866e-11,-5.68349673158702e-12) (5.32261237082135e-12,9.26177603563982e-12,-3.33441821518634e-12) (4.807574975886e-12,6.35743788507478e-12,-1.24332942736847e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-6.46755438183598e-13,4.01144343050623e-12,-1.83329182503933e-11) (-7.22979995797027e-13,7.59963995427254e-12,-1.85714177702612e-11) (-9.98951525217237e-13,1.17683672451639e-11,-1.87590375945544e-11) (1.18719226846573e-13,1.55758568259499e-11,-1.84678384555317e-11) (1.70585775886689e-12,1.82859584689114e-11,-1.80246155682958e-11) (3.83800793089035e-12,1.90540207672578e-11,-1.62447569310115e-11) (6.27101121385236e-12,1.68209507373687e-11,-1.29069040364592e-11) (8.00818613846554e-12,1.27549436773048e-11,-8.87335574437355e-12) (9.49633913117731e-12,8.58364786819582e-12,-5.03768413202838e-12) (9.84419504954679e-12,6.2468791274593e-12,-1.99544960184883e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.23605590379468e-12,3.5707246914758e-12,-2.27161370540736e-11) (-1.98627647316721e-12,6.7338282578138e-12,-2.28346021588095e-11) (-1.86740902870349e-12,1.07131019554257e-11,-2.28267737856284e-11) (-7.45946472479362e-13,1.42234877981941e-11,-2.21628287446252e-11) (3.42996163801647e-13,1.62796235186907e-11,-2.10898409063918e-11) (3.06152099874604e-12,1.67467938346461e-11,-1.90695472296417e-11) (8.33519635382278e-12,1.51093842092435e-11,-1.58515013836353e-11) (1.0961649553121e-11,1.13899653001667e-11,-1.10123268429803e-11) (1.29853982560356e-11,7.98220658042886e-12,-6.72935294794369e-12) (1.35427872996391e-11,6.70593405786492e-12,-2.9844575537262e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.87778469370652e-12,3.15063894114687e-12,-2.50506834839085e-11) (-3.49939113519758e-12,5.78265502012393e-12,-2.54201711596287e-11) (-3.72035688949818e-12,9.15621902579581e-12,-2.51705032526673e-11) (-2.70536561814403e-12,1.21164128124177e-11,-2.39115957487538e-11) (-2.26750586748451e-12,1.37079709022492e-11,-2.26885958554829e-11) (-8.33007208212562e-13,1.37812205713307e-11,-2.15971275548103e-11) (1.31471521486902e-11,1.31852391097518e-11,-2.00948995968385e-11) (1.58703836923927e-11,1.0483886452921e-11,-1.40420890812683e-11) (1.69665260917477e-11,7.89504830280614e-12,-8.38120368502699e-12) (1.67644748281332e-11,7.52367767674408e-12,-3.75068726399568e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.78126198849039e-12,2.95215889054571e-12,-2.68040555264563e-11) (-5.30415787271396e-12,4.76738441503194e-12,-2.73164721966641e-11) (-5.8112879923714e-12,7.16718864001593e-12,-2.75148647911143e-11) (-5.21269094832196e-12,9.92288286710949e-12,-2.65110356608193e-11) (-6.62932297689082e-12,1.09553700472634e-11,-2.51232777518751e-11) (-1.33361780188392e-11,9.68733847573922e-12,-2.50779500509599e-11) (2.31959155735225e-11,1.31435019462539e-11,-3.15139339540164e-11) (2.43973123830099e-11,1.07793266378007e-11,-2.12916005289739e-11) (2.18468567785431e-11,8.90602577239385e-12,-1.23814947541042e-11) (2.04599114951705e-11,9.31896071685731e-12,-5.84368605006868e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.47636859469758e-12,2.75887291452411e-12,-3.00254516653803e-11) (-6.69012806860997e-12,3.72712353870692e-12,-3.02018342606089e-11) (-7.34057235567007e-12,4.7805228538343e-12,-3.07154404757661e-11) (-6.67697431145526e-12,6.5918993990275e-12,-3.04444272936963e-11) (-8.73323986844044e-12,6.88639363002335e-12,-2.96957046212621e-11) (-1.88952545965467e-11,3.78693099622261e-12,-3.11619430405789e-11) (2.75713676535493e-11,1.66190762553049e-11,-4.439173108007e-11) (2.57005238478701e-11,1.34342069919223e-11,-2.77772383094356e-11) (2.3705262694967e-11,1.07296647104848e-11,-1.61838692525616e-11) (2.27730384741451e-11,1.0748536091641e-11,-7.72709906543849e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.00893219953815e-12,2.08073323240848e-12,-3.36098222517839e-11) (-6.23631391068483e-12,2.71207073944875e-12,-3.36396807321435e-11) (-6.61866115596558e-12,2.7792072663519e-12,-3.41852002748791e-11) (-5.8499789651689e-12,3.22185842254965e-12,-3.42627354091809e-11) (-7.38766036726053e-12,3.06593221758029e-12,-3.43007922141522e-11) (-1.72338055068664e-11,3.56228920300353e-13,-3.63225064603976e-11) (2.02213672523405e-11,1.7131599453848e-11,-5.1329326475742e-11) (2.31116405968495e-11,1.3598602794701e-11,-3.26637906773606e-11) (2.35469649011966e-11,1.1117137895699e-11,-1.97401039526017e-11) (2.34996226787049e-11,1.06295989265071e-11,-9.5051873092783e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.73025877292716e-12,1.29039411968416e-12,-3.83302474826223e-11) (-4.62907396302869e-12,1.67828960019308e-12,-3.75654982592312e-11) (-4.48273969763523e-12,1.18426781167465e-12,-3.72236868360498e-11) (-2.85311968720938e-12,9.78583068850012e-13,-3.73017292504392e-11) (-1.67285379744039e-12,6.65651866441402e-13,-3.80675539847643e-11) (4.46599070293722e-13,-1.92792918333445e-13,-3.95119327020471e-11) (1.57552503414479e-11,9.43207623922831e-12,-4.28148842475528e-11) (2.0276617014236e-11,1.01133696203433e-11,-3.17950305027476e-11) (2.20009170702972e-11,9.08339224414766e-12,-2.03349745085489e-11) (2.26970187157411e-11,8.63185109338152e-12,-9.90980114739108e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-8.56295884358207e-13,3.48178366639627e-13,-4.23397173341654e-11) (-2.71396307798121e-12,6.44029424653689e-13,-4.15082912517977e-11) (-2.10949210621876e-12,5.57465366409051e-13,-4.07870100763642e-11) (-2.10271626778451e-13,7.78610073848864e-13,-4.04479940484772e-11) (2.39041725450113e-12,7.63698560694033e-13,-4.03836767070462e-11) (6.57415137603106e-12,1.12033682208219e-12,-3.96407597014794e-11) (1.45815425171494e-11,5.09867970503874e-12,-3.78765781083499e-11) (1.88948746021294e-11,6.18676060895692e-12,-3.0022771803722e-11) (2.08150549589375e-11,6.04561818537721e-12,-2.01575125090921e-11) (2.16026836508456e-11,5.93755782012216e-12,-1.00290635378316e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-8.32480816472682e-13,-8.69748428578269e-14,-4.45694582073833e-11) (-2.13631240895005e-12,4.1957686620578e-14,-4.41172132622798e-11) (-1.43782429588888e-12,2.7451683711432e-13,-4.36420372207933e-11) (1.01706950369212e-12,7.46944627510293e-13,-4.29271081391244e-11) (4.44400136893211e-12,5.39689757462322e-13,-4.15327253936083e-11) (8.7967150911645e-12,9.39757784050234e-13,-3.9475886688194e-11) (1.3958096469703e-11,2.37492363781401e-12,-3.58274196500618e-11) (1.78554666904037e-11,2.70705529331969e-12,-2.8826164911134e-11) (1.97875827981312e-11,2.91695996863973e-12,-2.00598951341139e-11) (2.04229476973065e-11,3.08570711651544e-12,-1.0191339332129e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (7.00766591078814e-13,3.09928855112406e-12,-1.42050282176698e-11) (7.25283717106011e-13,7.74782242730025e-12,-1.40012587073425e-11) (-2.43304207328506e-13,1.36362868196084e-11,-1.3639163284045e-11) (2.59659878255706e-13,1.89806541797472e-11,-1.31557787054436e-11) (1.14044751518501e-12,2.28958661150439e-11,-1.24462672086702e-11) (1.77042663662157e-12,2.39231732597699e-11,-1.10154863888384e-11) (2.41206649315511e-12,2.11184800648294e-11,-8.96280177349642e-12) (3.38445150975317e-12,1.597795981142e-11,-6.5212240524143e-12) (3.90965175045968e-12,1.06990083098875e-11,-3.8688544592484e-12) (3.67480430616645e-12,7.43485482791527e-12,-1.45354061582919e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.24628207123413e-14,3.26559377150771e-12,-2.3544944421775e-11) (3.30451524929652e-13,7.78305330132984e-12,-2.33805600631958e-11) (-2.3488537450156e-13,1.30272201590659e-11,-2.28973168294951e-11) (1.02786536739599e-12,1.79404784300552e-11,-2.21655909487059e-11) (1.93233407178178e-12,2.15098414358516e-11,-2.10461440542322e-11) (2.80738196894302e-12,2.23332906098813e-11,-1.89280549082968e-11) (3.94902944993168e-12,1.98225528185263e-11,-1.53715359985412e-11) (5.5374929032374e-12,1.49180477405915e-11,-1.08984245578869e-11) (7.05554588877227e-12,1.0227477190941e-11,-6.63323995073316e-12) (7.38969051729325e-12,7.76510387740566e-12,-2.76403852134462e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-6.97505048703987e-13,3.29768515652029e-12,-2.75019700161104e-11) (-1.04293160867121e-12,7.62024781370686e-12,-2.76999448236258e-11) (-9.74471140081344e-13,1.23183421884808e-11,-2.75033162793197e-11) (2.88140675065741e-13,1.67489234933225e-11,-2.67872746420965e-11) (8.94355103492024e-13,1.97167192290285e-11,-2.53490531336394e-11) (2.8090484160751e-12,1.97867474045121e-11,-2.27127097894972e-11) (5.42016691255102e-12,1.73226357837669e-11,-1.85293489337292e-11) (7.58475450538633e-12,1.32108621577859e-11,-1.33178160417104e-11) (9.32766113944605e-12,9.82730152814786e-12,-8.93665106219398e-12) (9.74058612702177e-12,8.63534031656472e-12,-4.34822816570175e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.30981696739731e-12,3.19687170515104e-12,-2.82176014907544e-11) (-2.7337884370528e-12,6.97899128850229e-12,-2.87714528620384e-11) (-2.99023400761726e-12,1.12167779678707e-11,-2.91262598526452e-11) (-1.73483556609984e-12,1.48324979294365e-11,-2.84688567473957e-11) (-6.06373313206722e-13,1.68632454212755e-11,-2.70130713909137e-11) (1.75864692938796e-12,1.65876200829635e-11,-2.46638066947668e-11) (7.13607879663414e-12,1.49243702561089e-11,-2.11369476424272e-11) (9.91405811122738e-12,1.2382991783829e-11,-1.57091484289384e-11) (1.13250322011153e-11,9.63243399661315e-12,-1.04358629864195e-11) (1.12185045240388e-11,8.76687105591733e-12,-5.04886603394641e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.07555934225823e-12,2.91475346288982e-12,-2.8334030585606e-11) (-4.06550440194098e-12,5.90427744330367e-12,-2.91684277468705e-11) (-4.42845133647676e-12,9.15322467917688e-12,-3.02884647382825e-11) (-3.26946538920535e-12,1.21283990184502e-11,-2.99875221325786e-11) (-2.60567426056158e-12,1.34856624660298e-11,-2.88746913183894e-11) (-9.99786636240637e-13,1.33185684246587e-11,-2.77627285132509e-11) (9.49800783941866e-12,1.35054520330485e-11,-2.60928516576459e-11) (1.28323262540558e-11,1.21991915993952e-11,-1.99627044914549e-11) (1.34854091364452e-11,9.8054212980734e-12,-1.29597328918356e-11) (1.31866500702793e-11,9.0613461997998e-12,-6.19665566030785e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.62184631733199e-12,2.45690881242052e-12,-3.13353813500468e-11) (-5.16146905419179e-12,4.71455421419922e-12,-3.17283444419583e-11) (-5.61026995025798e-12,6.42722568435261e-12,-3.29616273346056e-11) (-4.05565600740971e-12,8.80889174773506e-12,-3.34536886305735e-11) (-3.4465400366761e-12,1.00395698663455e-11,-3.29286452608893e-11) (-2.23476448110459e-12,9.93007250490192e-12,-3.27111336965136e-11) (1.04443516844289e-11,1.3032166484291e-11,-3.24923490392512e-11) (1.39427589881617e-11,1.23543978357219e-11,-2.4632366441966e-11) (1.48610193226876e-11,1.01652616347845e-11,-1.58462857659324e-11) (1.51648765738775e-11,9.70106418140125e-12,-7.65900527711038e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-2.18873460649417e-12,1.42255280353352e-12,-3.53627054217793e-11) (-4.65701322866158e-12,3.34406597364709e-12,-3.5543324888503e-11) (-4.94618656700458e-12,4.24157629129052e-12,-3.63796862233616e-11) (-3.56864680649997e-12,5.80543510138675e-12,-3.68991556684559e-11) (-2.96566576984777e-12,6.8490078515612e-12,-3.68567566572574e-11) (-1.67796365290658e-12,6.76367481589347e-12,-3.69684422865238e-11) (9.25535466863873e-12,1.12109377036324e-11,-3.713942927044e-11) (1.367318704644e-11,1.13914653275557e-11,-2.84697467919086e-11) (1.53457939094191e-11,9.93159678860029e-12,-1.84773079175287e-11) (1.59921832025565e-11,9.86383611904874e-12,-9.00470045549858e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.55279224325087e-12,7.26247063710716e-13,-3.93912915192873e-11) (-3.93662521069503e-12,2.30594136536387e-12,-3.90566662849486e-11) (-3.77789483796806e-12,2.89336386225445e-12,-3.96324013947066e-11) (-1.88732195788254e-12,3.98494252739708e-12,-4.00961231383277e-11) (-3.26521774397838e-13,4.70235054351994e-12,-3.99459334566244e-11) (2.4364208754536e-12,4.58355774236477e-12,-3.92326876370272e-11) (9.06879313074379e-12,7.58238653750321e-12,-3.69902835160915e-11) (1.27431700314403e-11,8.88032992099634e-12,-2.92086507590603e-11) (1.46135177679284e-11,8.60119277210462e-12,-1.92577461329311e-11) (1.54815108416012e-11,9.1169396415453e-12,-9.54494190226521e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.25256875723482e-12,2.3976892526079e-13,-4.35186092448454e-11) (-2.83317251537129e-12,1.60513773577626e-12,-4.34915765807008e-11) (-2.16555960480185e-12,1.97682846135114e-12,-4.36932177528076e-11) (-2.42923521869051e-13,2.81817335679904e-12,-4.36198740962298e-11) (1.87150905214257e-12,3.34442987403316e-12,-4.28459199928283e-11) (4.99054882090447e-12,3.05412895718516e-12,-4.06851508667456e-11) (9.45149227979945e-12,4.63196515755354e-12,-3.69238013568135e-11) (1.25093206231221e-11,5.64465602269e-12,-2.96043997115256e-11) (1.38152642044292e-11,6.27717777791146e-12,-2.02307721705512e-11) (1.44254708166216e-11,7.20888658718807e-12,-1.03260775551026e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.3717006044343e-12,1.75746938165325e-13,-4.62382584860873e-11) (-2.56953076381596e-12,8.75323715208027e-13,-4.64106596740777e-11) (-1.87823654044355e-12,1.0017832392609e-12,-4.64509208526113e-11) (3.6963138568779e-13,1.67382010527289e-12,-4.61940717708463e-11) (2.92685242098221e-12,1.82136568069049e-12,-4.45205863760707e-11) (6.08800583708328e-12,1.67438665411151e-12,-4.13554547335509e-11) (9.33176536858222e-12,2.21807975196017e-12,-3.66218997426589e-11) (1.17962522067053e-11,2.51118071357533e-12,-2.94367161288801e-11) (1.28359869647796e-11,3.22853328733063e-12,-2.08059729889865e-11) (1.33173154816807e-11,4.01663598231798e-12,-1.0891839069876e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3.30691860380863e-13,2.35502535737047e-12,-1.5735138640996e-11) (3.27957419762752e-13,7.74003280526235e-12,-1.59451886021182e-11) (-1.17622125391654e-13,1.38714796505799e-11,-1.59897875733208e-11) (5.90324131199738e-13,1.9167332853916e-11,-1.57166759625541e-11) (1.09569137452532e-12,2.36582169689319e-11,-1.46836084709761e-11) (1.3076246711849e-12,2.52292055359252e-11,-1.30206014378013e-11) (1.26641601836625e-12,2.2980894611932e-11,-1.06526893361856e-11) (1.79199398742351e-12,1.73719787345403e-11,-7.90107388213433e-12) (1.96586902598566e-12,1.1398492515132e-11,-4.30570812074436e-12) (1.89101464082914e-12,8.61459947234247e-12,-1.54416542539252e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.64012922880141e-13,2.89576717887048e-12,-2.65150504874848e-11) (1.00137788672592e-14,8.11258919623138e-12,-2.67241487194738e-11) (-2.57733284687885e-13,1.34807459143731e-11,-2.64988573348942e-11) (1.09997340962311e-12,1.87245894935792e-11,-2.61972413920578e-11) (1.60736713267705e-12,2.30909013102726e-11,-2.43642004889984e-11) (1.79740626455113e-12,2.4168918105529e-11,-2.13769692249265e-11) (1.97583504402985e-12,2.14956951762224e-11,-1.72197165443415e-11) (2.97949387888292e-12,1.55686069605777e-11,-1.24770607357241e-11) (3.58652012217184e-12,1.06028188457717e-11,-7.47892169596499e-12) (3.75541555680422e-12,8.96144868778031e-12,-3.29685023071623e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-3.98716789809223e-13,2.9408524879923e-12,-3.10623245352094e-11) (-5.98303627768954e-13,7.89731159051611e-12,-3.16111628028512e-11) (-5.88948556705164e-13,1.29213966868467e-11,-3.15543021191539e-11) (7.66344730488646e-13,1.79915220001435e-11,-3.12555615716683e-11) (1.11148556711942e-12,2.17110371788874e-11,-2.8634201233855e-11) (1.82481488183628e-12,2.18090716894827e-11,-2.44981143436788e-11) (2.60689954821186e-12,1.87288744116288e-11,-1.9410920022249e-11) (4.03145989980078e-12,1.35499617997079e-11,-1.43676474848695e-11) (4.93410577447955e-12,1.00072675026964e-11,-9.92457203854716e-12) (5.26082722196267e-12,9.42001401386404e-12,-5.1766454469749e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-4.73847353842731e-13,3.09097396583263e-12,-3.18843701145244e-11) (-1.30426760126206e-12,7.24214727905599e-12,-3.22868289707518e-11) (-1.58408382415988e-12,1.20337075826535e-11,-3.28885263837752e-11) (-4.86522011589439e-13,1.6136506392804e-11,-3.27125432585924e-11) (4.21944945896036e-13,1.86864358558353e-11,-3.00913229456969e-11) (1.50083953539803e-12,1.85466922498966e-11,-2.59043114886738e-11) (3.1271978062401e-12,1.62925014224504e-11,-2.12496018586582e-11) (4.82457285308873e-12,1.3138346253191e-11,-1.66185397743406e-11) (5.7650479472012e-12,1.01934466856036e-11,-1.16951316278375e-11) (5.875163346222e-12,9.50419578884957e-12,-6.16520435506074e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-7.83317530499281e-13,3.01958546823262e-12,-3.20442252107269e-11) (-1.75574418141596e-12,6.53957709082446e-12,-3.24820067091089e-11) (-2.00339494738064e-12,1.02736406332968e-11,-3.36914658139037e-11) (-1.06278893266133e-12,1.30287640683316e-11,-3.346424149842e-11) (-2.71544466003892e-13,1.49213693446957e-11,-3.15587788767208e-11) (7.18832427878967e-13,1.53928221552775e-11,-2.89384989947304e-11) (3.84114622198942e-12,1.47886371443637e-11,-2.51737345995388e-11) (5.67414841806623e-12,1.30395109598045e-11,-1.98033882393629e-11) (6.36249156821209e-12,1.04285673600266e-11,-1.34452609122219e-11) (6.35027642837147e-12,9.21415478000606e-12,-6.72237664915081e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.19452721653287e-12,2.67404943611447e-12,-3.41570693053121e-11) (-2.55769792099055e-12,5.99329201418682e-12,-3.44412212648471e-11) (-2.93255926120653e-12,8.04302137042185e-12,-3.57620055515566e-11) (-1.57724273075414e-12,1.0060512513998e-11,-3.63619636263025e-11) (-4.73489586281979e-13,1.20295449966852e-11,-3.51896998610748e-11) (7.12848550623812e-13,1.23468901879909e-11,-3.28813403840601e-11) (4.40559786782e-12,1.32594370061784e-11,-2.92566089396294e-11) (6.11961082033182e-12,1.23555320507021e-11,-2.24694874385906e-11) (6.90740368002216e-12,1.00681746651867e-11,-1.50160954339227e-11) (7.34309935910107e-12,8.84205455922585e-12,-7.44207994987848e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.31180939993488e-12,1.76367417911097e-12,-3.63721708838217e-11) (-2.78252728552338e-12,4.75637837992519e-12,-3.68921730011106e-11) (-3.0785046928399e-12,5.71042018396089e-12,-3.79257903516519e-11) (-1.79055324375436e-12,7.31100601800159e-12,-3.88564486034542e-11) (-7.07322832531452e-13,9.24769593342228e-12,-3.83369835454404e-11) (6.73140404569927e-13,9.43500729416382e-12,-3.62286869853334e-11) (4.21422335618335e-12,1.08779133729559e-11,-3.26353111403226e-11) (6.19188357858338e-12,1.10217508663478e-11,-2.49958359846466e-11) (7.20359046391806e-12,9.40156286117401e-12,-1.63711522668103e-11) (7.73437922455136e-12,8.74307396844804e-12,-8.0272065846038e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.40093933912008e-12,9.71866896465663e-13,-3.84147930771013e-11) (-2.66008647136956e-12,3.00746844495909e-12,-3.93232289788355e-11) (-2.39763769342918e-12,3.56257374291747e-12,-4.09025212013216e-11) (-8.70742468992683e-13,5.0009877162455e-12,-4.17516645318659e-11) (3.18153075480129e-13,6.43207654080338e-12,-4.05536723400525e-11) (1.72344553969567e-12,6.51477185367051e-12,-3.79904001289625e-11) (4.23758175366823e-12,7.45266157347927e-12,-3.37909797080573e-11) (6.02793930359822e-12,8.58895072712241e-12,-2.67777929629299e-11) (7.2247285314525e-12,8.26120764287253e-12,-1.78511862716462e-11) (7.84462199369023e-12,8.45024660839755e-12,-8.83808312086203e-12) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.21557943428612e-12,4.79363459077823e-13,-4.2141752626218e-11) (-1.90171732268596e-12,1.92667419607066e-12,-4.33491717576886e-11) (-1.2638580392979e-12,2.01407938003678e-12,-4.44918261923653e-11) (1.27475626251065e-13,2.93225305544639e-12,-4.46301093667862e-11) (1.23380411939171e-12,4.18695740519678e-12,-4.30535751412477e-11) (2.60894161406201e-12,4.03879697244249e-12,-3.98715436925262e-11) (4.54597604011157e-12,4.67705658201584e-12,-3.53655472349511e-11) (6.26916839126491e-12,5.69028333944302e-12,-2.8782537556138e-11) (6.9592140795562e-12,6.472833023541e-12,-1.991735562125e-11) (7.29164386639162e-12,7.45678548122738e-12,-1.02533927520248e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-1.02355247827897e-12,4.71203156273024e-13,-4.61933385476542e-11) (-1.6539458700755e-12,1.16761130805506e-12,-4.67456878696599e-11) (-1.13330238294547e-12,8.88504515167994e-13,-4.72320224316804e-11) (3.69966096185167e-13,1.48319445615047e-12,-4.74768202994578e-11) (1.58308645915847e-12,2.23873007585376e-12,-4.56236597471221e-11) (3.02883750029229e-12,2.14174212894231e-12,-4.18018432121101e-11) (4.36466150677122e-12,2.64002294331937e-12,-3.66312635828754e-11) (5.6766897803888e-12,3.09426979581429e-12,-2.96265791327849e-11) (6.15038633299869e-12,3.76808423387161e-12,-2.08556195565817e-11) (6.44211239411991e-12,4.49503659559156e-12,-1.09371489897115e-11) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) ) ; boundaryField { fuel { type fixedValue; value uniform (0.1 0 0); } air { type fixedValue; value uniform (-0.1 0 0); } outlet { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
[ "huberlulu@gmail.com" ]
huberlulu@gmail.com
b9947f988c90086b00da2d84c14871c7cf77866a
8a6c3a19f22bc1a86443f3d85a7865a1af60eece
/Edit.cpp
57b3aef047c6fc65371e7c75fbaeb9e2e28a0e63
[]
no_license
datnguyen25082000/Break-Brick-Game
7f22472a835256fdf1854163fe5e61a886f50bb4
e635612edb83c72d47a8b75b13bebe2dde96e45c
refs/heads/master
2020-09-27T07:29:30.382900
2019-12-11T15:00:33
2019-12-11T15:00:33
226,464,025
0
0
null
null
null
null
UTF-8
C++
false
false
991
cpp
#include "Edit.h" void Edit::InitText(std::string text , int size, sf::Color colour, sf::Color border_color, float border_thickness, float x, float y) { _text.setFont(_font); _text.setString(text); _text.setCharacterSize(size); _text.setFillColor(colour); _text.setOutlineColor(border_color); _text.setOutlineThickness(border_thickness); _text.setPosition(x + (WINDOW_WIDTH - _text.getGlobalBounds().width) / 2.0f, _text.getGlobalBounds().height + y*MENU_GAP); } bool Edit::CheckMouseButtonPress(sf::Event* event) { if (event->mouseButton.x > _text.getPosition().x && event->mouseButton.x < _text.getPosition().x + _text.getGlobalBounds().width) { if (event->mouseButton.y > _text.getPosition().y && event->mouseButton.y < _text.getPosition().y + _text.getGlobalBounds().height) { return true; } } return false; } void Edit::Render(sf::RenderWindow* window) { window->draw(_text); } Edit::Edit() { _font.loadFromFile("ASMAN.ttf"); }
[ "noreply@github.com" ]
datnguyen25082000.noreply@github.com
2bbde843bd3b2a46ffd726f7f46b09c478457628
1b73515fb49ac64e0afa5ba7baf03170451d0e46
/GameEngine/CoreEngine/CoreEngine/src/ChunkLoader.meta.cpp
6182de044204dfa1a932daa1c212aafb02ebff24
[ "Apache-2.0" ]
permissive
suddenly-games/SuddenlyGames
2af48c0f31f61bad22e7c95124c0f91443ff2d54
e2ff1c2771d4ca54824650e4f1a33a527536ca61
refs/heads/develop
2023-05-02T03:14:21.384819
2021-05-12T07:10:29
2021-05-12T07:10:29
330,379,384
1
0
Apache-2.0
2021-03-21T03:12:52
2021-01-17T11:52:25
C
UTF-8
C++
false
false
2,089
cpp
#include "ChunkLoader.h" namespace Engine { Reflect_Inherited(ChunkLoader, Object, Document_Class(""); Document(""); Archivable Class_Member(std::weak_ptr<Terrain>, Target); Document(""); Archivable Class_Member(LuaEnum < Enum::ChunkLoaderShape>, Shape); Bind_Function(GetCellCoordinates, Document(""); Function_Overload ( Document(""); Overload_Returns(Vector3); Overload_Parameters(); Bind_Parameters(GetCellCoordinates); ); ); Bind_Function(GetChunkCoordinates, Document(""); Function_Overload ( Document(""); Overload_Returns(Vector3); Overload_Parameters ( Document(""); Function_Parameter(Vector3, chunk); ); Bind_Parameters(GetChunkCoordinates, chunk); ); Document(""); Function_Overload ( Document(""); Overload_Returns(Vector3); Overload_Parameters(); Bind_Parameters(GetChunkCoordinates); ); ); Bind_Function(GetRange, Document(""); Function_Overload ( Document(""); Overload_Returns(Vector3); Overload_Parameters(); Bind_Parameters(GetRange); ); ); Bind_Function(SetRange, Document(""); Function_Overload ( Document(""); Returns_Nothing; Overload_Parameters ( Document(""); Function_Parameter(Vector3, range); ); Bind_Parameters_No_Return(SetRange, range); ); ); Bind_Function(GetChunkStatus, Document(""); Function_Overload ( Document(""); Overload_Returns(LuaEnum<Enum::ChunkStatus>); Overload_Parameters ( Document(""); Function_Parameter(Vector3, chunk); ); Bind_Parameters(GetChunkStatus, chunk); ); ); Bind_Function(GetLocalChunkStatus, Document(""); Function_Overload ( Document(""); Overload_Returns(LuaEnum<Enum::ChunkStatus>); Overload_Parameters ( Document(""); Function_Parameter(Vector3, chunk); ); Bind_Parameters(GetLocalChunkStatus, chunk); ); ); ); }
[ "trevorb101@hotmail.com" ]
trevorb101@hotmail.com
710fc211bd8d9f0a4930d825b461917e815451ed
6e601105760f09d3c9f5306e18e4cf085f0bb4a2
/Algorithm/LCA2.cpp
3e03453a473f8ebcc779f592a9f393ed4872fc41
[]
no_license
WSJI0/BOJ
6412f69fddd46c4bcc96377e2b6e013f3bb1b524
160d8c13f72d7da835d938686f433e7b245be682
refs/heads/master
2023-07-06T15:35:50.815021
2023-07-04T01:39:48
2023-07-04T01:39:48
199,650,520
2
0
null
2020-04-20T09:03:03
2019-07-30T12:48:37
Python
UTF-8
C++
false
false
561
cpp
//LCA(최소 공통조상)의 다른 구현 #include <bits/stdc++.h> using namespace std; int n, m, a, b; int parent[100001][20]; int depth[100001]; vector<int> graph[100001]; void dfs(int cur){ for(auto nxt:graph[cur]){ if(depth[nxt]!=-1) continue; parent[nxt][0]=cur; depth[nxt]=depth[cur]+1; dfs(nxt); } } int main(void){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i=0; i<n; i++){ cin>>a>>b; graph[a].push_back(b); graph[b].push_back(a); } }
[ "lifedev@naver.com" ]
lifedev@naver.com
a32b6d860c642e11d7f8eb1f84797f8d1c21023c
5ead5b57e9846f8c09b4d39e8455e84e052dfcc3
/src/caffe/internal_thread.cpp
294d79bd1b48636b1542cc5f9ed422c95cf841cb
[ "LicenseRef-scancode-generic-cla", "BSD-2-Clause" ]
permissive
zhuyuanhao/caffe-annotated
9f5cd7b1fe97729b86b1ad77aa2785fbce94b0b4
021f8c00403063fd9c46924c41d53428507b91fc
refs/heads/master
2021-05-02T18:11:46.757491
2016-11-28T13:45:59
2016-11-28T13:45:59
72,419,700
1
1
null
null
null
null
UTF-8
C++
false
false
1,942
cpp
#include <boost/thread.hpp> #include <exception> #include "caffe/internal_thread.hpp" #include "caffe/util/math_functions.hpp" namespace caffe { InternalThread::~InternalThread() { StopInternalThread(); } bool InternalThread::is_started() const { return thread_ && thread_->joinable(); } bool InternalThread::must_stop() { return thread_ && thread_->interruption_requested(); } void InternalThread::StartInternalThread() { // 不能重复调用Start函数,线程必须未初始化,或已经停止 CHECK(!is_started()) << "Threads should persist and not be restarted."; int device = 0; #ifndef CPU_ONLY CUDA_CHECK(cudaGetDevice(&device)); #endif Caffe::Brew mode = Caffe::mode(); int rand_seed = caffe_rng_rand(); int solver_count = Caffe::solver_count(); bool root_solver = Caffe::root_solver(); try { // 将当前线程的Caffe的部分状态传给子线程 thread_.reset(new boost::thread(&InternalThread::entry, this, device, mode, rand_seed, solver_count, root_solver)); } catch (std::exception& e) { LOG(FATAL) << "Thread exception: " << e.what(); } } // 子线程执行的函数,设置Caffe的部分状态,然后执行InternalThreadEntry() void InternalThread::entry(int device, Caffe::Brew mode, int rand_seed, int solver_count, bool root_solver) { #ifndef CPU_ONLY CUDA_CHECK(cudaSetDevice(device)); #endif Caffe::set_mode(mode); Caffe::set_random_seed(rand_seed); Caffe::set_solver_count(solver_count); Caffe::set_root_solver(root_solver); InternalThreadEntry(); } void InternalThread::StopInternalThread() { // 可以重复调用停止函数 if (is_started()) { // 产生终止信号停止线程中函数的执行 thread_->interrupt(); try { thread_->join(); } catch (boost::thread_interrupted&) { } catch (std::exception& e) { LOG(FATAL) << "Thread exception: " << e.what(); } } } } // namespace caffe
[ "zhuyuanhao@sensetime.com" ]
zhuyuanhao@sensetime.com
b3c868337a17c2f322f7bc7b022c371003d321a7
d70003dec2b54719b543a011b1814b65b5d8538e
/mfe_nonlinear.cpp
da12d96f3a9501f209c5addf6c3f104068adbc91
[]
no_license
krasheninnik/MFE-nonlinear
5084556d19ff4d33162126d1826dc529643372d8
9996a9ee7457cdb9f481b8d658030c8008841ded
refs/heads/master
2021-10-25T06:16:20.886838
2019-04-02T03:39:44
2019-04-02T03:39:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,421
cpp
#include "pch.h" #include "mfe_nonlinear.h" #include <fstream> #include "matrix.h" #include "assert.h" void NonlinearTask::setParams() { lambda = std::vector<double>(amountSubareas); sigma = std::vector<func2>(amountSubareas); u = std::vector<double>(nodes.size()); /* lambda[0] = 1; sigma[0] = [](const double& u) {return u; }; fFunc = [](const double& x, const double& t, const double& u, const func& sigma) {return -2 * t + sigma(u) * x*x; }; fStart = [](const double& x, const double& t) {return x * x * t; }; */ /* u = 5*x^4 lambda[0] = 1; uExact = [](const double& x, const double& t) {return 5*x*x*x*x; }; sigma[0] = [](const double& u, const double& x) {return 2; }; fFunc = [](const double& x, const double& t, const double& u, const func2& sigma) {return -60*x*x; }; */ lambda[0] = 1; uExact = [](const double& x, const double& t) {return t*t*t; }; sigma[0] = [](const double& u, const double& x) {return 2; }; fFunc = [](const double& x, const double& t, const double& u, const func2& sigma) {return 3*t*t*sigma(u,x); }; //fFunc = [](const double& x, const double& t, const double& u, const func2& sigma) {return sigma(u,x) * 5 *x; }; //fStart = [](const double& x, const double& t) {return x * t; }; // set boundary conditions: leftU = uExact(nodes[0], 0); rightU = uExact(nodes[nodes.size() - 1], 0); } void NonlinearTask::init() { #pragma region outputResultFile fout.open(R"(output/result.txt)"); fout.precision(17); #pragma endregion #pragma region InitTimeGrid { times = std::vector<double>(); std::fstream fin(R"(input/grid_time.txt)"); double t0, step, coef; int amount, numTimeGridDividion; fin >> numTimeGridDividion >> t0 >> amount >> step >> coef; int k = pow(2, numTimeGridDividion - 1); // calculate grid parameters for unevenness: amount *= k; coef = pow(coef, 1.0 / k); // calculate first step double stepsCoef = 0; for (int i = 0; i < k; i++) stepsCoef += pow(coef, i); step /= stepsCoef; for (int i = 0; i < amount; i++) { times.push_back(t0); t0 += step; step *= coef; } fin.close(); } #pragma endregion #pragma region InitSpaceGrid { nodes = std::vector<double>(); elems = std::vector<FiniteElem>(); subareas = std::vector<int>(); std::fstream fin(R"(input/grid_space.txt)"); int numSpaceGridDividion = 1; int numOfAreas = 1; fin >> numSpaceGridDividion >> numOfAreas; double xStart, numOfElems, step, coef; fin >> xStart >> numOfElems >> step >> coef; int k = pow(2, numSpaceGridDividion - 1); // calculate grid parameters for unevenness: numOfElems *= k; coef = pow(coef, 1.0 / k); // calculate first step double stepsCoef = 0; for (int i = 0; i < k; i++) stepsCoef += pow(coef, i); step /= stepsCoef; double x = xStart; nodes.push_back(x); // add x0 in nodes for (int i = 0; i < numOfElems; i++) { nodes.push_back(x + step / 2); // add middle node on finite elem. x += step; nodes.push_back(x); step *= coef; // change step } // fill elems array: int j = 0; for (; j < nodes.size() - 2; j+=2) { elems.push_back(FiniteElem{ j, j + 1, j + 2}); } assert(j == nodes.size() - 1); // fill subareas: int numOfFiniteElems = 0; int sum = 0; fin >> amountSubareas; for (int i = 0; i < amountSubareas; i++) { fin >> numOfFiniteElems; numOfFiniteElems *= k; // consideration of grid dividion sum += numOfFiniteElems; for(int j = 0; j < numOfFiniteElems; j++) subareas.push_back(0); } assert(sum == elems.size()); // init vector of params of equals in subareas: lambda = std::vector<double>(amountSubareas); sigma = std::vector<func2>(amountSubareas); fin.close(); } #pragma endregion #pragma region MatrixInit globalMatrix = Matrix(); const int matrixDim = 3 + (elems.size() - 1) * 2; globalMatrix.init(matrixDim); #pragma endregion #pragma region MemoryAllocation q = std::vector<double>(nodes.size()); qPrev = std::vector<double>(nodes.size()); qPrevTime = std::vector<double>(nodes.size()); qExact = std::vector<double>(nodes.size());; // there should be vector<vvector<doub>> results -> for save q on each step! temp = std::vector<double>(nodes.size()); // local matrix of mass and rigidity, and local vector; const int pointsToFiniteElem = 3; massLocalMatrix = LocalMatrix(pointsToFiniteElem); for (auto& el : massLocalMatrix) el = std::vector<double>(pointsToFiniteElem); rigidLocalMatrix = LocalMatrix(pointsToFiniteElem); for (auto& el : rigidLocalMatrix) el = std::vector<double>(pointsToFiniteElem); fLocal = std::vector<double>(pointsToFiniteElem); // global matrix! f = std::vector<double>(nodes.size());; //TapeMatrix globalMatirx; #pragma endregion } void NonlinearTask::calculateGlobalMatrixAndRightPart(const double t, const double dt) { // clear global matrix and vector: resetGlobalMatrix(); resetGlobalF(); // calculate new global matrix and vector: for (int elemNum = 0; elemNum < elems.size(); elemNum++) { calculateLocalMatrixOfMass(elemNum); // depends on q calculateLocalMatrixOfRigid(elemNum); calculateLocalRightPart(elemNum, t, dt); // depends on q // if method Newton'a need linearizate local matrix globalMatrix.addLocalMatrix(elemNum, rigidLocalMatrix, massLocalMatrix, dt); addLocalRigtPartToGlobal(elemNum); } // set boundary conditions setFirstBoundaryConditions(t); } #include <iostream> void NonlinearTask::solve() { // need input things: epsDiscrep = 1e-15; double t = 0; // calculate u0: for (uint32_t i = 0; i < u.size(); i++) { q[i] = qPrevTime[i] = uExact(nodes[i], times[0]); } // approximation by time: for (uint32_t i = 1; i < times.size(); i++) { const double dt = times[i] - times[i - 1]; const double t = times[i]; calculateGlobalMatrixAndRightPart(t, dt); // solve nonlinear system of equations: A(qi)qi = b(qi) // there method of simple itertations: A(qi-1)qi = b(qi-1) bool calculating = true; while (calculating) { globalMatrix.LUdecompose(); globalMatrix.solveSystem(f, q, temp); // there we have new q. // calculating A(qNew) and f(qNew ) calculateGlobalMatrixAndRightPart(t, dt); if (SimpleIterationDiscrepOut()) { calculating = false; saveResult(i, t); } else { // prepare next iteration: std::swap(q, qPrev); } } // prepare next iteration: //std::swap(q, qPrevTime); qPrevTime = q; } } void NonlinearTask::calculateLocalMatrixOfMass(uint32_t elemNum){ // approximate sigma U part const auto& elem = elems[elemNum]; const auto k = (nodes[elem.right] - nodes[elem.left]); // sigma_k(u) const auto& sigmaLocal = sigma[subareas[elemNum]]; const double coef0 = k * sigmaLocal(q[elem.left], nodes[elem.left]); // sigma(u[elem.first)]; * multiply to step. [nodes[elem.right] - nodes[elem.left]); const double coef1 = k * sigmaLocal(q[elem.mid], nodes[elem.mid]); // sigma(u[elem.second)]' const double coef2 = k * sigmaLocal(q[elem.right], nodes[elem.right]); massLocalMatrix[0][0] = coef0 * 0.09285714285714286 + coef1 * 0.04761904761904761 + coef2 * -7.1428571428571415e-3; massLocalMatrix[0][1] = coef0 * 0.04761904761904761 + coef1 * 0.0380952380952381 + coef2 * -0.01904761904761905; massLocalMatrix[0][2] = coef0 * -7.1428571428571415e-3 + coef1 * -0.01904761904761905 + coef2 * -7.1428571428571415e-3; massLocalMatrix[1][0] = coef0 * 0.04761904761904761 + coef1 * 0.0380952380952381 + coef2 * -0.01904761904761905; massLocalMatrix[1][1] = coef0 * 0.0380952380952381 + coef1 * 0.4571428571428571 + coef2 * 0.03809523809523809; massLocalMatrix[1][2] = coef0 * -0.01904761904761905 +coef1 * 0.03809523809523809 + coef2 * 0.04761904761904761; massLocalMatrix[2][0] = coef0 * -7.1428571428571415e-3 + coef1 * -0.01904761904761905 + coef2 * -7.1428571428571415e-3; massLocalMatrix[2][1] = coef0 * -0.01904761904761905 + coef1 * 0.03809523809523809 + coef2 * 0.04761904761904761; massLocalMatrix[2][2] = coef0 * -7.1428571428571415e-3 + coef1 * 0.04761904761904761 + coef2 * 0.09285714285714286; } void NonlinearTask::calculateLocalMatrixOfRigid(uint32_t elemNum) { // approximate div(lambda grad) part: const auto& elem = elems[elemNum]; const double coef = lambda[subareas[elemNum]] / ( 3 * (nodes[elem.right] - nodes[elem.left])); rigidLocalMatrix[0][0] = coef * 7; rigidLocalMatrix[0][1] = coef * -8; rigidLocalMatrix[0][2] = coef * 1; rigidLocalMatrix[1][0] = coef * -8; rigidLocalMatrix[1][1] = coef * 16; rigidLocalMatrix[1][2] = coef * -8; rigidLocalMatrix[2][0] = coef * 1; rigidLocalMatrix[2][1] = coef * -8; rigidLocalMatrix[2][2] = coef * 7; } void NonlinearTask::calculateLocalRightPart(uint32_t num, const double t, const double dt) { // f = f + (1/dt * M * q_j-1) const int size = 3; const int block = 2; int place = num * block; for (int i = 0; i < size; i++) { fLocal[i] = 0; for (int j = 0; j < size; j++) { fLocal[i] += massLocalMatrix[i][j] * qPrevTime[place + j]; } fLocal[i] /= dt; } const auto& sigmaLocal = sigma[subareas[num]]; // there should be q or qPrevTime !? // => q. because solve the equation in "q" time. const double f0 = fFunc(nodes[place], t, q[place], sigmaLocal); const double f1 = fFunc(nodes[place + 1], t, q[place + 1], sigmaLocal); const double f2 = fFunc(nodes[place + 2], t, q[place + 2], sigmaLocal); const auto& elem = elems[num]; const auto k = (nodes[elem.right] - nodes[elem.left]) / 30; fLocal[0] += k * (4*f0 + 2*f1 - f2) ; fLocal[1] += k * (2*f0 + 16*f1 + 2*f2); fLocal[2] += k * (-f0 + 2*f1 + 4*f2); } void NonlinearTask::addLocalRigtPartToGlobal(uint32_t num) { const int block = 2; int place = num * block; for (int i = 0; i <= block; i++, place++) f[place] += fLocal[i]; } void NonlinearTask::setFirstBoundaryConditions(const double t) { // set first bounday conditions in left side: globalMatrix.setFirstBoundaryConditionsLeft(); f[0] = uExact(nodes[0], t); // set first bounday conditions in right side: globalMatrix.setFirstBoundaryConditionsRight(); f[f.size() - 1] = uExact(nodes[nodes.size() - 1], t); } void vectorSubtraction(std::vector<double>& result, const std::vector<double>& a){ for (int i = 0; i < result.size(); i++) result[i] -= a[i]; } double calcNorm(const std::vector<double> &x) { double norm = 0; for (int i = 0; i < x.size(); i++) { norm += x[i] * x[i]; } norm = sqrt(norm); return norm; } //#include <iostream> bool NonlinearTask::SimpleIterationDiscrepOut() { // || A(qi) * qi - b(qi) || / || b(qi) || < eps => out: temp = globalMatrix.multiplicate_with_vector(q, temp); vectorSubtraction(temp, f); double resultNorm = calcNorm(temp) / calcNorm(f); //std::cout << resultNorm << std::endl; return resultNorm < epsDiscrep; } void NonlinearTask::resetGlobalMatrix() { globalMatrix.reset(); } void NonlinearTask::resetGlobalF() { for (int i = 0; i < f.size(); i++) f[i] = 0; } void NonlinearTask::saveResult(const int timeIter, const double t) { double sum = 0; for (int i = 0; i < qExact.size(); i++) { qExact[i] = uExact(nodes[i], t); sum += (qExact[i] - q[i])*(qExact[i] - q[i]); } sum = sqrt(sum); fout << "TimeIteration: " << timeIter << "\tTime: " << t << "\tNormOfError: " << sum << std::endl; for (const auto& resExact : qExact) fout << resExact << " "; fout << std::endl; for (const auto& res : q) fout << res << " "; fout << std::endl; fout << std::endl; }
[ "krasheninnik99@gmail.com" ]
krasheninnik99@gmail.com
486d5a4e598f499f0aa33e07cbecf1100c38757b
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_5/ISA2+poreleaserelease+poacquireonce+fencembonceonce.c.cbmc_out.cpp
2ea5cf674bd946f31428c8d476d149a0ca83a4a2
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
44,431
cpp
// Global variabls: // 0:vars:3 // 3:atom_1_X0_1:1 // 4:atom_2_X0_1:1 // 5:atom_2_X2_0:1 // Local global variabls: // 0:thr0:1 // 1:thr1:1 // 2:thr2:1 #define ADDRSIZE 6 #define LOCALADDRSIZE 3 #define NTHREAD 4 #define NCONTEXT 5 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // Declare arrays for intial value version in contexts int local_mem[LOCALADDRSIZE]; // Dumping initializations local_mem[0+0] = 0; local_mem[1+0] = 0; local_mem[2+0] = 0; int cstart[NTHREAD]; int creturn[NTHREAD]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NTHREAD*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NTHREAD*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NTHREAD*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NTHREAD*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NTHREAD*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NTHREAD*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NTHREAD*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NTHREAD*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NTHREAD*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NTHREAD]; int cdy[NTHREAD]; int cds[NTHREAD]; int cdl[NTHREAD]; int cisb[NTHREAD]; int caddr[NTHREAD]; int cctrl[NTHREAD]; int r0= 0; char creg_r0; char creg__r0__1_; int r1= 0; char creg_r1; int r2= 0; char creg_r2; char creg__r1__1_; char creg__r2__0_; int r3= 0; char creg_r3; int r4= 0; char creg_r4; int r5= 0; char creg_r5; int r6= 0; char creg_r6; int r7= 0; char creg_r7; int r8= 0; char creg_r8; int r9= 0; char creg_r9; int r10= 0; char creg_r10; int r11= 0; char creg_r11; char creg__r11__1_; int r12= 0; char creg_r12; char old_cctrl= 0; char old_cr= 0; char old_cdy= 0; char old_cw= 0; char new_creg= 0; buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); buff(3,0) = 0; pw(3,0) = 0; cr(3,0) = 0; iw(3,0) = 0; cw(3,0) = 0; cx(3,0) = 0; is(3,0) = 0; cs(3,0) = 0; crmax(3,0) = 0; buff(3,1) = 0; pw(3,1) = 0; cr(3,1) = 0; iw(3,1) = 0; cw(3,1) = 0; cx(3,1) = 0; is(3,1) = 0; cs(3,1) = 0; crmax(3,1) = 0; buff(3,2) = 0; pw(3,2) = 0; cr(3,2) = 0; iw(3,2) = 0; cw(3,2) = 0; cx(3,2) = 0; is(3,2) = 0; cs(3,2) = 0; crmax(3,2) = 0; buff(3,3) = 0; pw(3,3) = 0; cr(3,3) = 0; iw(3,3) = 0; cw(3,3) = 0; cx(3,3) = 0; is(3,3) = 0; cs(3,3) = 0; crmax(3,3) = 0; buff(3,4) = 0; pw(3,4) = 0; cr(3,4) = 0; iw(3,4) = 0; cw(3,4) = 0; cx(3,4) = 0; is(3,4) = 0; cs(3,4) = 0; crmax(3,4) = 0; buff(3,5) = 0; pw(3,5) = 0; cr(3,5) = 0; iw(3,5) = 0; cw(3,5) = 0; cx(3,5) = 0; is(3,5) = 0; cs(3,5) = 0; crmax(3,5) = 0; cl[3] = 0; cdy[3] = 0; cds[3] = 0; cdl[3] = 0; cisb[3] = 0; caddr[3] = 0; cctrl[3] = 0; cstart[3] = get_rng(0,NCONTEXT-1); creturn[3] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; mem(0,1) = meminit(0,1); co(0,1) = coinit(0,1); delta(0,1) = deltainit(0,1); mem(0,2) = meminit(0,2); co(0,2) = coinit(0,2); delta(0,2) = deltainit(0,2); mem(0,3) = meminit(0,3); co(0,3) = coinit(0,3); delta(0,3) = deltainit(0,3); mem(0,4) = meminit(0,4); co(0,4) = coinit(0,4); delta(0,4) = deltainit(0,4); co(1,0) = 0; delta(1,0) = -1; mem(1,1) = meminit(1,1); co(1,1) = coinit(1,1); delta(1,1) = deltainit(1,1); mem(1,2) = meminit(1,2); co(1,2) = coinit(1,2); delta(1,2) = deltainit(1,2); mem(1,3) = meminit(1,3); co(1,3) = coinit(1,3); delta(1,3) = deltainit(1,3); mem(1,4) = meminit(1,4); co(1,4) = coinit(1,4); delta(1,4) = deltainit(1,4); co(2,0) = 0; delta(2,0) = -1; mem(2,1) = meminit(2,1); co(2,1) = coinit(2,1); delta(2,1) = deltainit(2,1); mem(2,2) = meminit(2,2); co(2,2) = coinit(2,2); delta(2,2) = deltainit(2,2); mem(2,3) = meminit(2,3); co(2,3) = coinit(2,3); delta(2,3) = deltainit(2,3); mem(2,4) = meminit(2,4); co(2,4) = coinit(2,4); delta(2,4) = deltainit(2,4); co(3,0) = 0; delta(3,0) = -1; mem(3,1) = meminit(3,1); co(3,1) = coinit(3,1); delta(3,1) = deltainit(3,1); mem(3,2) = meminit(3,2); co(3,2) = coinit(3,2); delta(3,2) = deltainit(3,2); mem(3,3) = meminit(3,3); co(3,3) = coinit(3,3); delta(3,3) = deltainit(3,3); mem(3,4) = meminit(3,4); co(3,4) = coinit(3,4); delta(3,4) = deltainit(3,4); co(4,0) = 0; delta(4,0) = -1; mem(4,1) = meminit(4,1); co(4,1) = coinit(4,1); delta(4,1) = deltainit(4,1); mem(4,2) = meminit(4,2); co(4,2) = coinit(4,2); delta(4,2) = deltainit(4,2); mem(4,3) = meminit(4,3); co(4,3) = coinit(4,3); delta(4,3) = deltainit(4,3); mem(4,4) = meminit(4,4); co(4,4) = coinit(4,4); delta(4,4) = deltainit(4,4); co(5,0) = 0; delta(5,0) = -1; mem(5,1) = meminit(5,1); co(5,1) = coinit(5,1); delta(5,1) = deltainit(5,1); mem(5,2) = meminit(5,2); co(5,2) = coinit(5,2); delta(5,2) = deltainit(5,2); mem(5,3) = meminit(5,3); co(5,3) = coinit(5,3); delta(5,3) = deltainit(5,3); mem(5,4) = meminit(5,4); co(5,4) = coinit(5,4); delta(5,4) = deltainit(5,4); // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !38, metadata !DIExpression()), !dbg !47 // br label %label_1, !dbg !48 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !46), !dbg !49 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !39, metadata !DIExpression()), !dbg !50 // call void @llvm.dbg.value(metadata i64 1, metadata !42, metadata !DIExpression()), !dbg !50 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) release, align 8, !dbg !51 // ST: Guess // : Release iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l21_c3 old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l21_c3 // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); ASSUME(cw(1,0+1*1) >= cr(1,0+0)); ASSUME(cw(1,0+1*1) >= cr(1,0+1)); ASSUME(cw(1,0+1*1) >= cr(1,0+2)); ASSUME(cw(1,0+1*1) >= cr(1,3+0)); ASSUME(cw(1,0+1*1) >= cr(1,4+0)); ASSUME(cw(1,0+1*1) >= cr(1,5+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+0)); ASSUME(cw(1,0+1*1) >= cw(1,0+1)); ASSUME(cw(1,0+1*1) >= cw(1,0+2)); ASSUME(cw(1,0+1*1) >= cw(1,3+0)); ASSUME(cw(1,0+1*1) >= cw(1,4+0)); ASSUME(cw(1,0+1*1) >= cw(1,5+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; is(1,0+1*1) = iw(1,0+1*1); cs(1,0+1*1) = cw(1,0+1*1); ASSUME(creturn[1] >= cw(1,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !43, metadata !DIExpression()), !dbg !52 // call void @llvm.dbg.value(metadata i64 1, metadata !45, metadata !DIExpression()), !dbg !52 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !53 // ST: Guess // : Release iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l22_c3 old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l22_c3 // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); ASSUME(cw(1,0) >= cr(1,0+0)); ASSUME(cw(1,0) >= cr(1,0+1)); ASSUME(cw(1,0) >= cr(1,0+2)); ASSUME(cw(1,0) >= cr(1,3+0)); ASSUME(cw(1,0) >= cr(1,4+0)); ASSUME(cw(1,0) >= cr(1,5+0)); ASSUME(cw(1,0) >= cw(1,0+0)); ASSUME(cw(1,0) >= cw(1,0+1)); ASSUME(cw(1,0) >= cw(1,0+2)); ASSUME(cw(1,0) >= cw(1,3+0)); ASSUME(cw(1,0) >= cw(1,4+0)); ASSUME(cw(1,0) >= cw(1,5+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; is(1,0) = iw(1,0); cs(1,0) = cw(1,0); ASSUME(creturn[1] >= cw(1,0)); // ret i8* null, !dbg !54 ret_thread_1 = (- 1); goto T1BLOCK_END; T1BLOCK_END: // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !57, metadata !DIExpression()), !dbg !67 // br label %label_2, !dbg !50 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !66), !dbg !69 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !59, metadata !DIExpression()), !dbg !70 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) acquire, align 8, !dbg !53 // LD: Guess // : Acquire old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l28_c15 // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); ASSUME(cr(2,0) >= cx(2,0)); ASSUME(cr(2,0) >= cs(2,0+0)); ASSUME(cr(2,0) >= cs(2,0+1)); ASSUME(cr(2,0) >= cs(2,0+2)); ASSUME(cr(2,0) >= cs(2,3+0)); ASSUME(cr(2,0) >= cs(2,4+0)); ASSUME(cr(2,0) >= cs(2,5+0)); // Update creg_r0 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r0 = buff(2,0); ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0)); ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0)); ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0)); ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0)); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r0 = mem(0,cr(2,0)); } cl[2] = max(cl[2],cr(2,0)); ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %0, metadata !61, metadata !DIExpression()), !dbg !70 // %conv = trunc i64 %0 to i32, !dbg !54 // call void @llvm.dbg.value(metadata i32 %conv, metadata !58, metadata !DIExpression()), !dbg !67 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !62, metadata !DIExpression()), !dbg !73 // call void @llvm.dbg.value(metadata i64 1, metadata !64, metadata !DIExpression()), !dbg !73 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !56 // ST: Guess iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l29_c3 old_cw = cw(2,0+2*1); cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l29_c3 // Check ASSUME(active[iw(2,0+2*1)] == 2); ASSUME(active[cw(2,0+2*1)] == 2); ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(cw(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cw(2,0+2*1) >= old_cw); ASSUME(cw(2,0+2*1) >= cr(2,0+2*1)); ASSUME(cw(2,0+2*1) >= cl[2]); ASSUME(cw(2,0+2*1) >= cisb[2]); ASSUME(cw(2,0+2*1) >= cdy[2]); ASSUME(cw(2,0+2*1) >= cdl[2]); ASSUME(cw(2,0+2*1) >= cds[2]); ASSUME(cw(2,0+2*1) >= cctrl[2]); ASSUME(cw(2,0+2*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+2*1) = 1; mem(0+2*1,cw(2,0+2*1)) = 1; co(0+2*1,cw(2,0+2*1))+=1; delta(0+2*1,cw(2,0+2*1)) = -1; ASSUME(creturn[2] >= cw(2,0+2*1)); // %cmp = icmp eq i32 %conv, 1, !dbg !57 creg__r0__1_ = max(0,creg_r0); // %conv1 = zext i1 %cmp to i32, !dbg !57 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !65, metadata !DIExpression()), !dbg !67 // store i32 %conv1, i32* @atom_1_X0_1, align 4, !dbg !58, !tbaa !59 // ST: Guess iw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l31_c15 old_cw = cw(2,3); cw(2,3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l31_c15 // Check ASSUME(active[iw(2,3)] == 2); ASSUME(active[cw(2,3)] == 2); ASSUME(sforbid(3,cw(2,3))== 0); ASSUME(iw(2,3) >= creg__r0__1_); ASSUME(iw(2,3) >= 0); ASSUME(cw(2,3) >= iw(2,3)); ASSUME(cw(2,3) >= old_cw); ASSUME(cw(2,3) >= cr(2,3)); ASSUME(cw(2,3) >= cl[2]); ASSUME(cw(2,3) >= cisb[2]); ASSUME(cw(2,3) >= cdy[2]); ASSUME(cw(2,3) >= cdl[2]); ASSUME(cw(2,3) >= cds[2]); ASSUME(cw(2,3) >= cctrl[2]); ASSUME(cw(2,3) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,3) = (r0==1); mem(3,cw(2,3)) = (r0==1); co(3,cw(2,3))+=1; delta(3,cw(2,3)) = -1; ASSUME(creturn[2] >= cw(2,3)); // ret i8* null, !dbg !63 ret_thread_2 = (- 1); goto T2BLOCK_END; T2BLOCK_END: // Dumping thread 3 int ret_thread_3 = 0; cdy[3] = get_rng(0,NCONTEXT-1); ASSUME(cdy[3] >= cstart[3]); T3BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !84, metadata !DIExpression()), !dbg !96 // br label %label_3, !dbg !52 goto T3BLOCK1; T3BLOCK1: // call void @llvm.dbg.label(metadata !95), !dbg !98 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !86, metadata !DIExpression()), !dbg !99 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !55 // LD: Guess old_cr = cr(3,0+2*1); cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l37_c15 // Check ASSUME(active[cr(3,0+2*1)] == 3); ASSUME(cr(3,0+2*1) >= iw(3,0+2*1)); ASSUME(cr(3,0+2*1) >= 0); ASSUME(cr(3,0+2*1) >= cdy[3]); ASSUME(cr(3,0+2*1) >= cisb[3]); ASSUME(cr(3,0+2*1) >= cdl[3]); ASSUME(cr(3,0+2*1) >= cl[3]); // Update creg_r1 = cr(3,0+2*1); crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1)); caddr[3] = max(caddr[3],0); if(cr(3,0+2*1) < cw(3,0+2*1)) { r1 = buff(3,0+2*1); ASSUME((!(( (cw(3,0+2*1) < 1) && (1 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,1)> 0)); ASSUME((!(( (cw(3,0+2*1) < 2) && (2 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,2)> 0)); ASSUME((!(( (cw(3,0+2*1) < 3) && (3 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,3)> 0)); ASSUME((!(( (cw(3,0+2*1) < 4) && (4 < crmax(3,0+2*1)) )))||(sforbid(0+2*1,4)> 0)); } else { if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) { ASSUME(cr(3,0+2*1) >= old_cr); } pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1)); r1 = mem(0+2*1,cr(3,0+2*1)); } ASSUME(creturn[3] >= cr(3,0+2*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !88, metadata !DIExpression()), !dbg !99 // %conv = trunc i64 %0 to i32, !dbg !56 // call void @llvm.dbg.value(metadata i32 %conv, metadata !85, metadata !DIExpression()), !dbg !96 // call void (...) @dmbsy(), !dbg !57 // dumbsy: Guess old_cdy = cdy[3]; cdy[3] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[3] >= old_cdy); ASSUME(cdy[3] >= cisb[3]); ASSUME(cdy[3] >= cdl[3]); ASSUME(cdy[3] >= cds[3]); ASSUME(cdy[3] >= cctrl[3]); ASSUME(cdy[3] >= cw(3,0+0)); ASSUME(cdy[3] >= cw(3,0+1)); ASSUME(cdy[3] >= cw(3,0+2)); ASSUME(cdy[3] >= cw(3,3+0)); ASSUME(cdy[3] >= cw(3,4+0)); ASSUME(cdy[3] >= cw(3,5+0)); ASSUME(cdy[3] >= cr(3,0+0)); ASSUME(cdy[3] >= cr(3,0+1)); ASSUME(cdy[3] >= cr(3,0+2)); ASSUME(cdy[3] >= cr(3,3+0)); ASSUME(cdy[3] >= cr(3,4+0)); ASSUME(cdy[3] >= cr(3,5+0)); ASSUME(creturn[3] >= cdy[3]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !90, metadata !DIExpression()), !dbg !103 // %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !59 // LD: Guess old_cr = cr(3,0+1*1); cr(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l39_c15 // Check ASSUME(active[cr(3,0+1*1)] == 3); ASSUME(cr(3,0+1*1) >= iw(3,0+1*1)); ASSUME(cr(3,0+1*1) >= 0); ASSUME(cr(3,0+1*1) >= cdy[3]); ASSUME(cr(3,0+1*1) >= cisb[3]); ASSUME(cr(3,0+1*1) >= cdl[3]); ASSUME(cr(3,0+1*1) >= cl[3]); // Update creg_r2 = cr(3,0+1*1); crmax(3,0+1*1) = max(crmax(3,0+1*1),cr(3,0+1*1)); caddr[3] = max(caddr[3],0); if(cr(3,0+1*1) < cw(3,0+1*1)) { r2 = buff(3,0+1*1); ASSUME((!(( (cw(3,0+1*1) < 1) && (1 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,1)> 0)); ASSUME((!(( (cw(3,0+1*1) < 2) && (2 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,2)> 0)); ASSUME((!(( (cw(3,0+1*1) < 3) && (3 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,3)> 0)); ASSUME((!(( (cw(3,0+1*1) < 4) && (4 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,4)> 0)); } else { if(pw(3,0+1*1) != co(0+1*1,cr(3,0+1*1))) { ASSUME(cr(3,0+1*1) >= old_cr); } pw(3,0+1*1) = co(0+1*1,cr(3,0+1*1)); r2 = mem(0+1*1,cr(3,0+1*1)); } ASSUME(creturn[3] >= cr(3,0+1*1)); // call void @llvm.dbg.value(metadata i64 %1, metadata !92, metadata !DIExpression()), !dbg !103 // %conv4 = trunc i64 %1 to i32, !dbg !60 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !89, metadata !DIExpression()), !dbg !96 // %cmp = icmp eq i32 %conv, 1, !dbg !61 creg__r1__1_ = max(0,creg_r1); // %conv5 = zext i1 %cmp to i32, !dbg !61 // call void @llvm.dbg.value(metadata i32 %conv5, metadata !93, metadata !DIExpression()), !dbg !96 // store i32 %conv5, i32* @atom_2_X0_1, align 4, !dbg !62, !tbaa !63 // ST: Guess iw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l41_c15 old_cw = cw(3,4); cw(3,4) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l41_c15 // Check ASSUME(active[iw(3,4)] == 3); ASSUME(active[cw(3,4)] == 3); ASSUME(sforbid(4,cw(3,4))== 0); ASSUME(iw(3,4) >= creg__r1__1_); ASSUME(iw(3,4) >= 0); ASSUME(cw(3,4) >= iw(3,4)); ASSUME(cw(3,4) >= old_cw); ASSUME(cw(3,4) >= cr(3,4)); ASSUME(cw(3,4) >= cl[3]); ASSUME(cw(3,4) >= cisb[3]); ASSUME(cw(3,4) >= cdy[3]); ASSUME(cw(3,4) >= cdl[3]); ASSUME(cw(3,4) >= cds[3]); ASSUME(cw(3,4) >= cctrl[3]); ASSUME(cw(3,4) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,4) = (r1==1); mem(4,cw(3,4)) = (r1==1); co(4,cw(3,4))+=1; delta(4,cw(3,4)) = -1; ASSUME(creturn[3] >= cw(3,4)); // %cmp6 = icmp eq i32 %conv4, 0, !dbg !67 creg__r2__0_ = max(0,creg_r2); // %conv7 = zext i1 %cmp6 to i32, !dbg !67 // call void @llvm.dbg.value(metadata i32 %conv7, metadata !94, metadata !DIExpression()), !dbg !96 // store i32 %conv7, i32* @atom_2_X2_0, align 4, !dbg !68, !tbaa !63 // ST: Guess iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l43_c15 old_cw = cw(3,5); cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l43_c15 // Check ASSUME(active[iw(3,5)] == 3); ASSUME(active[cw(3,5)] == 3); ASSUME(sforbid(5,cw(3,5))== 0); ASSUME(iw(3,5) >= creg__r2__0_); ASSUME(iw(3,5) >= 0); ASSUME(cw(3,5) >= iw(3,5)); ASSUME(cw(3,5) >= old_cw); ASSUME(cw(3,5) >= cr(3,5)); ASSUME(cw(3,5) >= cl[3]); ASSUME(cw(3,5) >= cisb[3]); ASSUME(cw(3,5) >= cdy[3]); ASSUME(cw(3,5) >= cdl[3]); ASSUME(cw(3,5) >= cds[3]); ASSUME(cw(3,5) >= cctrl[3]); ASSUME(cw(3,5) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,5) = (r2==0); mem(5,cw(3,5)) = (r2==0); co(5,cw(3,5))+=1; delta(5,cw(3,5)) = -1; ASSUME(creturn[3] >= cw(3,5)); // ret i8* null, !dbg !69 ret_thread_3 = (- 1); goto T3BLOCK_END; T3BLOCK_END: // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // %thr2 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !118, metadata !DIExpression()), !dbg !140 // call void @llvm.dbg.value(metadata i8** %argv, metadata !119, metadata !DIExpression()), !dbg !140 // %0 = bitcast i64* %thr0 to i8*, !dbg !65 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !65 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !120, metadata !DIExpression()), !dbg !142 // %1 = bitcast i64* %thr1 to i8*, !dbg !67 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !67 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !124, metadata !DIExpression()), !dbg !144 // %2 = bitcast i64* %thr2 to i8*, !dbg !69 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !69 // call void @llvm.dbg.declare(metadata i64* %thr2, metadata !125, metadata !DIExpression()), !dbg !146 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !126, metadata !DIExpression()), !dbg !147 // call void @llvm.dbg.value(metadata i64 0, metadata !128, metadata !DIExpression()), !dbg !147 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !72 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l52_c3 old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l52_c3 // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !129, metadata !DIExpression()), !dbg !149 // call void @llvm.dbg.value(metadata i64 0, metadata !131, metadata !DIExpression()), !dbg !149 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !74 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c3 old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c3 // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !132, metadata !DIExpression()), !dbg !151 // call void @llvm.dbg.value(metadata i64 0, metadata !134, metadata !DIExpression()), !dbg !151 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !76 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c3 old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c3 // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // store i32 0, i32* @atom_1_X0_1, align 4, !dbg !77, !tbaa !78 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l55_c15 old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l55_c15 // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // store i32 0, i32* @atom_2_X0_1, align 4, !dbg !82, !tbaa !78 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l56_c15 old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l56_c15 // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // store i32 0, i32* @atom_2_X2_0, align 4, !dbg !83, !tbaa !78 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l57_c15 old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l57_c15 // Check ASSUME(active[iw(0,5)] == 0); ASSUME(active[cw(0,5)] == 0); ASSUME(sforbid(5,cw(0,5))== 0); ASSUME(iw(0,5) >= 0); ASSUME(iw(0,5) >= 0); ASSUME(cw(0,5) >= iw(0,5)); ASSUME(cw(0,5) >= old_cw); ASSUME(cw(0,5) >= cr(0,5)); ASSUME(cw(0,5) >= cl[0]); ASSUME(cw(0,5) >= cisb[0]); ASSUME(cw(0,5) >= cdy[0]); ASSUME(cw(0,5) >= cdl[0]); ASSUME(cw(0,5) >= cds[0]); ASSUME(cw(0,5) >= cctrl[0]); ASSUME(cw(0,5) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,5) = 0; mem(5,cw(0,5)) = 0; co(5,cw(0,5))+=1; delta(5,cw(0,5)) = -1; ASSUME(creturn[0] >= cw(0,5)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !84 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call5 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !85 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %call6 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !86 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[3] >= cdy[0]); // %3 = load i64, i64* %thr0, align 8, !dbg !87, !tbaa !88 r4 = local_mem[0]; // %call7 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !90 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %4 = load i64, i64* %thr1, align 8, !dbg !91, !tbaa !88 r5 = local_mem[1]; // %call8 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !92 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %5 = load i64, i64* %thr2, align 8, !dbg !93, !tbaa !88 r6 = local_mem[2]; // %call9 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !94 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[3]); // %6 = load i32, i32* @atom_1_X0_1, align 4, !dbg !95, !tbaa !78 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l67_c13 // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r7 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r7 = buff(0,3); ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0)); ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0)); ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0)); ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0)); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r7 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i32 %6, metadata !135, metadata !DIExpression()), !dbg !140 // %7 = load i32, i32* @atom_2_X0_1, align 4, !dbg !96, !tbaa !78 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l68_c13 // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r8 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r8 = buff(0,4); ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0)); ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0)); ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0)); ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0)); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r8 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i32 %7, metadata !136, metadata !DIExpression()), !dbg !140 // %8 = load i32, i32* @atom_2_X2_0, align 4, !dbg !97, !tbaa !78 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l69_c13 // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r9 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r9 = buff(0,5); ASSUME((!(( (cw(0,5) < 1) && (1 < crmax(0,5)) )))||(sforbid(5,1)> 0)); ASSUME((!(( (cw(0,5) < 2) && (2 < crmax(0,5)) )))||(sforbid(5,2)> 0)); ASSUME((!(( (cw(0,5) < 3) && (3 < crmax(0,5)) )))||(sforbid(5,3)> 0)); ASSUME((!(( (cw(0,5) < 4) && (4 < crmax(0,5)) )))||(sforbid(5,4)> 0)); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r9 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // call void @llvm.dbg.value(metadata i32 %8, metadata !137, metadata !DIExpression()), !dbg !140 // %and = and i32 %7, %8, !dbg !98 creg_r10 = max(creg_r8,creg_r9); r10 = r8 & r9; // call void @llvm.dbg.value(metadata i32 %and, metadata !138, metadata !DIExpression()), !dbg !140 // %and10 = and i32 %6, %and, !dbg !99 creg_r11 = max(creg_r10,creg_r7); r11 = r7 & r10; // call void @llvm.dbg.value(metadata i32 %and10, metadata !139, metadata !DIExpression()), !dbg !140 // %cmp = icmp eq i32 %and10, 1, !dbg !100 creg__r11__1_ = max(0,creg_r11); // br i1 %cmp, label %if.then, label %if.end, !dbg !102 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg__r11__1_); if((r11==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 noundef 72, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !103 // unreachable, !dbg !103 r12 = 1; goto T0BLOCK_END; T0BLOCK2: // %9 = bitcast i64* %thr2 to i8*, !dbg !106 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !106 // %10 = bitcast i64* %thr1 to i8*, !dbg !106 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !106 // %11 = bitcast i64* %thr0 to i8*, !dbg !106 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !106 // ret i32 0, !dbg !107 ret_thread_0 = 0; goto T0BLOCK_END; T0BLOCK_END: ASSUME(meminit(0,1) == mem(0,0)); ASSUME(coinit(0,1) == co(0,0)); ASSUME(deltainit(0,1) == delta(0,0)); ASSUME(meminit(0,2) == mem(0,1)); ASSUME(coinit(0,2) == co(0,1)); ASSUME(deltainit(0,2) == delta(0,1)); ASSUME(meminit(0,3) == mem(0,2)); ASSUME(coinit(0,3) == co(0,2)); ASSUME(deltainit(0,3) == delta(0,2)); ASSUME(meminit(0,4) == mem(0,3)); ASSUME(coinit(0,4) == co(0,3)); ASSUME(deltainit(0,4) == delta(0,3)); ASSUME(meminit(1,1) == mem(1,0)); ASSUME(coinit(1,1) == co(1,0)); ASSUME(deltainit(1,1) == delta(1,0)); ASSUME(meminit(1,2) == mem(1,1)); ASSUME(coinit(1,2) == co(1,1)); ASSUME(deltainit(1,2) == delta(1,1)); ASSUME(meminit(1,3) == mem(1,2)); ASSUME(coinit(1,3) == co(1,2)); ASSUME(deltainit(1,3) == delta(1,2)); ASSUME(meminit(1,4) == mem(1,3)); ASSUME(coinit(1,4) == co(1,3)); ASSUME(deltainit(1,4) == delta(1,3)); ASSUME(meminit(2,1) == mem(2,0)); ASSUME(coinit(2,1) == co(2,0)); ASSUME(deltainit(2,1) == delta(2,0)); ASSUME(meminit(2,2) == mem(2,1)); ASSUME(coinit(2,2) == co(2,1)); ASSUME(deltainit(2,2) == delta(2,1)); ASSUME(meminit(2,3) == mem(2,2)); ASSUME(coinit(2,3) == co(2,2)); ASSUME(deltainit(2,3) == delta(2,2)); ASSUME(meminit(2,4) == mem(2,3)); ASSUME(coinit(2,4) == co(2,3)); ASSUME(deltainit(2,4) == delta(2,3)); ASSUME(meminit(3,1) == mem(3,0)); ASSUME(coinit(3,1) == co(3,0)); ASSUME(deltainit(3,1) == delta(3,0)); ASSUME(meminit(3,2) == mem(3,1)); ASSUME(coinit(3,2) == co(3,1)); ASSUME(deltainit(3,2) == delta(3,1)); ASSUME(meminit(3,3) == mem(3,2)); ASSUME(coinit(3,3) == co(3,2)); ASSUME(deltainit(3,3) == delta(3,2)); ASSUME(meminit(3,4) == mem(3,3)); ASSUME(coinit(3,4) == co(3,3)); ASSUME(deltainit(3,4) == delta(3,3)); ASSUME(meminit(4,1) == mem(4,0)); ASSUME(coinit(4,1) == co(4,0)); ASSUME(deltainit(4,1) == delta(4,0)); ASSUME(meminit(4,2) == mem(4,1)); ASSUME(coinit(4,2) == co(4,1)); ASSUME(deltainit(4,2) == delta(4,1)); ASSUME(meminit(4,3) == mem(4,2)); ASSUME(coinit(4,3) == co(4,2)); ASSUME(deltainit(4,3) == delta(4,2)); ASSUME(meminit(4,4) == mem(4,3)); ASSUME(coinit(4,4) == co(4,3)); ASSUME(deltainit(4,4) == delta(4,3)); ASSUME(meminit(5,1) == mem(5,0)); ASSUME(coinit(5,1) == co(5,0)); ASSUME(deltainit(5,1) == delta(5,0)); ASSUME(meminit(5,2) == mem(5,1)); ASSUME(coinit(5,2) == co(5,1)); ASSUME(deltainit(5,2) == delta(5,1)); ASSUME(meminit(5,3) == mem(5,2)); ASSUME(coinit(5,3) == co(5,2)); ASSUME(deltainit(5,3) == delta(5,2)); ASSUME(meminit(5,4) == mem(5,3)); ASSUME(coinit(5,4) == co(5,3)); ASSUME(deltainit(5,4) == delta(5,3)); ASSERT(r12== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
5b18ce0cc7190ef4e4a8c7fb2d4dfaeda0bea7fd
2d1d87ac7cedb68f33e8643e3e5f92d081dffb11
/src/qt/optionsmodel.h
12d5a478cfd6110d9de87a93cb342fdb5f68512b
[ "MIT" ]
permissive
Rockeronhunt/Bitdook
addfa278ace21d4dc7c8512d5e7941aab10cdb38
0de9b7ce557fbec8ed68b05e8b1b3f9e715b42d9
refs/heads/master
2020-03-16T23:05:12.328497
2018-05-11T16:40:24
2018-05-11T16:40:24
133,060,181
0
0
null
null
null
null
UTF-8
C++
false
false
1,904
h
#ifndef OPTIONSMODEL_H #define OPTIONSMODEL_H #include <QAbstractListModel> /** Interface from Qt to configuration data structure for BITDOOK client. To Qt, the options are presented as a list with the different options laid out vertically. This can be changed to a tree once the settings become sufficiently complex. */ class OptionsModel : public QAbstractListModel { Q_OBJECT public: explicit OptionsModel(QObject *parent = 0); enum OptionID { StartAtStartup, // bool MinimizeToTray, // bool MapPortUPnP, // bool MinimizeOnClose, // bool ProxyUse, // bool ProxyIP, // QString ProxyPort, // int ProxySocksVersion, // int Fee, // qint64 DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool Language, // QString OptionIDRowCount, }; void Init(); void Reset(); /* Migrate settings from wallet.dat after app initialization */ bool Upgrade(); /* returns true if settings upgraded */ int rowCount(const QModelIndex & parent = QModelIndex()) const; QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const; bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); /* Explicit getters */ qint64 getTransactionFee(); bool getMinimizeToTray() { return fMinimizeToTray; } bool getMinimizeOnClose() { return fMinimizeOnClose; } int getDisplayUnit() { return nDisplayUnit; } bool getDisplayAddresses() { return bDisplayAddresses; } QString getLanguage() { return language; } private: int nDisplayUnit; bool bDisplayAddresses; bool fMinimizeToTray; bool fMinimizeOnClose; QString language; signals: void displayUnitChanged(int unit); }; #endif // OPTIONSMODEL_H
[ "" ]
5179318005365aaead6e353cb59489dae4d1a62d
1bdb45ffd1618cb2823642c4461be464a6d55792
/Shape.cpp
f2272c045caa0cd1ca483d3c29a85f32e689cd87
[]
no_license
aisbergg/Fast3D
03b1f6eb2e6aec36c35b4019c63cb0721cc6470d
461f4e251c549f071026bba8267139362ffb2989
refs/heads/main
2023-01-03T14:48:08.125478
2020-10-26T15:43:00
2020-10-26T15:43:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,331
cpp
#include "Shape.h" #include <tuple> #define PI 3.14159265 using namespace std; Shape::Shape() : origin(0, 0, 0), faces(nullptr), face_count(0) {} Shape::Shape(Vector3 Origin, Triangle* Faces, int FaceCount) : origin(Origin), faces(Faces), face_count(FaceCount) {} std::tuple<Triangle*, double*, size_t> Shape::FacesFacing(Vector3 Direction) const { auto result_faces = new Triangle[face_count]; auto dots = new double[face_count]; size_t size = 0; for (size_t i = 0; i < (size_t)face_count; i++) { auto& face = faces[i]; double dot = Direction.Dot(face.Normal()); if (dot > 0) { result_faces[size] = std::move(Triangle(face)); dots[size] = dot; size++; } } return make_tuple(result_faces, dots, size); } const Shape& Shape::operator=(Shape&& other) noexcept { faces = other.faces; other.faces = nullptr; face_count = other.face_count; origin = other.origin; return *this; } double Shape::OriginDistanceToPlane(const Vector3& PlaneOrigin, const Vector3& PlaneNormal) { return origin.DistanceToPlane(PlaneOrigin, PlaneNormal); } void Shape::RotateX(double theta) { for (size_t i = 0; i < (size_t)face_count; i++) { auto& face = faces[i]; for (size_t j = 0; j < (size_t)3; j++) { auto& vertex = face[j]; double ct = cos(theta * PI / 180), st = sin(theta * PI / 180); double y = vertex.Y() * ct - vertex.Z() * st, z = vertex.Y() * st + vertex.Z() * ct; vertex.SetY(y); vertex.SetZ(z); } } } void Shape::RotateY(double theta) { for (size_t i = 0; i < (size_t)face_count; i++) { auto& face = faces[i]; for (size_t j = 0; j < (size_t)3; j++) { auto& vertex = face[j]; double ct = cos(theta * PI / 180), st = sin(theta * PI / 180); double x = vertex.X() * ct + vertex.Z() * st, z = -vertex.X() * st + vertex.Z() * ct; vertex.SetX(x); vertex.SetZ(z); } } } void Shape::RotateZ(double theta) { for (size_t i = 0; i < (size_t)face_count; i++) { auto& face = faces[i]; for (size_t j = 0; j < (size_t)3; j++) { auto& vertex = face[j]; double ct = cos(theta * PI / 180), st = sin(theta * PI / 180); double x = (vertex.X() * ct - vertex.Y() * st), y = (vertex.X() * st + vertex.Y() * ct); vertex.SetX(x); vertex.SetY(y); } } } Shape::~Shape() { if (faces == nullptr) return; delete[] faces; faces = nullptr; }
[ "catab212@gmail.com" ]
catab212@gmail.com
8fdf809f056fa3ff0318ccc8b3b123204113b281
f071a719b5ba52162ed808ad602183a651774b34
/src/main.cpp
5345f71d123a5c279fff177cd44ae8a0b84b4d15
[ "MIT" ]
permissive
OneCoinNetwork/onecoin
17816451cbac373cdb8548afce408454df9ade1c
0e553b0939c334b04614d7ee45ecdb442a25d0e2
refs/heads/master
2021-01-23T02:15:33.649030
2017-03-04T11:46:42
2017-03-04T11:46:42
85,978,267
0
1
null
2017-03-23T17:29:38
2017-03-23T17:29:38
null
UTF-8
C++
false
false
129,093
cpp
// Copyright (c) 2009-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 <boost/algorithm/string/replace.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include "chainparams.h" #include "checkpoints.h" #include "db.h" #include "init.h" #include "kernel.h" #include "net.h" #include "txdb.h" #include "txmempool.h" #include "ui_interface.h" using namespace std; using namespace boost; #if defined(NDEBUG) # error "Onecoin cannot be compiled without assertions." #endif // // Global state // CCriticalSection cs_setpwalletRegistered; set<CWallet*> setpwalletRegistered; CCriticalSection cs_main; CTxMemPool mempool; map<uint256, CBlockIndex*> mapBlockIndex; set<pair<COutPoint, unsigned int> > setStakeSeen; CBigNum bnProofOfStakeLimit(~uint256(0) >> 20); int nStakeMinConfirmations = 250; unsigned int nStakeMinAge = 12 * 60 * 60; // 12 hours unsigned int nModifierInterval = 10 * 60; // time to elapse before new modifier is computed int nCoinbaseMaturity = 250; CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; uint256 nBestChainTrust = 0; uint256 nBestInvalidTrust = 0; uint256 hashBestChain = 0; CBlockIndex* pindexBest = NULL; int64_t nTimeBestReceived = 0; bool fImporting = false; bool fReindex = false; bool fHaveGUI = false; struct COrphanBlock { uint256 hashBlock; uint256 hashPrev; std::pair<COutPoint, unsigned int> stake; vector<unsigned char> vchBlock; }; map<uint256, COrphanBlock*> mapOrphanBlocks; multimap<uint256, COrphanBlock*> mapOrphanBlocksByPrev; set<pair<COutPoint, unsigned int> > setStakeSeenOrphan; size_t nOrphanBlocksSize = 0; map<uint256, CTransaction> mapOrphanTransactions; map<uint256, set<uint256> > mapOrphanTransactionsByPrev; // Constant stuff for coinbase transactions we create: CScript COINBASE_FLAGS; const string strMessageMagic = "Onecoin Signed Message:\n"; ////////////////////////////////////////////////////////////////////////////// // // dispatching functions // // These functions dispatch to one or all registered wallets namespace { struct CMainSignals { // Notifies listeners of updated transaction data (passing hash, transaction, and optionally the block it is found in. boost::signals2::signal<void (const CTransaction &, const CBlock *, bool)> SyncTransaction; // Notifies listeners of an erased transaction (currently disabled, requires transaction replacement). boost::signals2::signal<void (const uint256 &)> EraseTransaction; // Notifies listeners of an updated transaction without new data (for now: a coinbase potentially becoming visible). boost::signals2::signal<void (const uint256 &)> UpdatedTransaction; // Notifies listeners of a new active block chain. boost::signals2::signal<void (const CBlockLocator &)> SetBestChain; // Notifies listeners about an inventory item being seen on the network. boost::signals2::signal<void (const uint256 &)> Inventory; // Tells listeners to broadcast their data. boost::signals2::signal<void (bool)> Broadcast; } g_signals; } void RegisterWallet(CWalletInterface* pwalletIn) { g_signals.SyncTransaction.connect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2, _3)); g_signals.EraseTransaction.connect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); g_signals.UpdatedTransaction.connect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.SetBestChain.connect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); g_signals.Inventory.connect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); g_signals.Broadcast.connect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn, _1)); } void UnregisterWallet(CWalletInterface* pwalletIn) { g_signals.Broadcast.disconnect(boost::bind(&CWalletInterface::ResendWalletTransactions, pwalletIn, _1)); g_signals.Inventory.disconnect(boost::bind(&CWalletInterface::Inventory, pwalletIn, _1)); g_signals.SetBestChain.disconnect(boost::bind(&CWalletInterface::SetBestChain, pwalletIn, _1)); g_signals.UpdatedTransaction.disconnect(boost::bind(&CWalletInterface::UpdatedTransaction, pwalletIn, _1)); g_signals.EraseTransaction.disconnect(boost::bind(&CWalletInterface::EraseFromWallet, pwalletIn, _1)); g_signals.SyncTransaction.disconnect(boost::bind(&CWalletInterface::SyncTransaction, pwalletIn, _1, _2, _3)); } void UnregisterAllWallets() { g_signals.Broadcast.disconnect_all_slots(); g_signals.Inventory.disconnect_all_slots(); g_signals.SetBestChain.disconnect_all_slots(); g_signals.UpdatedTransaction.disconnect_all_slots(); g_signals.EraseTransaction.disconnect_all_slots(); g_signals.SyncTransaction.disconnect_all_slots(); } void SyncWithWallets(const CTransaction &tx, const CBlock *pblock, bool fConnect) { g_signals.SyncTransaction(tx, pblock, fConnect); } void ResendWalletTransactions(bool fForce) { g_signals.Broadcast(fForce); } ////////////////////////////////////////////////////////////////////////////// // // Registration of network node signals. // void RegisterNodeSignals(CNodeSignals& nodeSignals) { nodeSignals.ProcessMessages.connect(&ProcessMessages); nodeSignals.SendMessages.connect(&SendMessages); } void UnregisterNodeSignals(CNodeSignals& nodeSignals) { nodeSignals.ProcessMessages.disconnect(&ProcessMessages); nodeSignals.SendMessages.disconnect(&SendMessages); } ////////////////////////////////////////////////////////////////////////////// // // mapOrphanTransactions // bool AddOrphanTx(const CTransaction& tx) { uint256 hash = tx.GetHash(); if (mapOrphanTransactions.count(hash)) return false; // Ignore big transactions, to avoid a // send-big-orphans memory exhaustion attack. If a peer has a legitimate // large transaction with a missing parent then we assume // it will rebroadcast it later, after the parent transaction(s) // have been mined or received. // 10,000 orphans, each of which is at most 5,000 bytes big is // at most 500 megabytes of orphans: size_t nSize = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION); if (nSize > 5000) { LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", nSize, hash.ToString()); return false; } mapOrphanTransactions[hash] = tx; BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(hash); LogPrint("mempool", "stored orphan tx %s (mapsz %u)\n", hash.ToString(), mapOrphanTransactions.size()); return true; } void static EraseOrphanTx(uint256 hash) { map<uint256, CTransaction>::iterator it = mapOrphanTransactions.find(hash); if (it == mapOrphanTransactions.end()) return; BOOST_FOREACH(const CTxIn& txin, it->second.vin) { map<uint256, set<uint256> >::iterator itPrev = mapOrphanTransactionsByPrev.find(txin.prevout.hash); if (itPrev == mapOrphanTransactionsByPrev.end()) continue; itPrev->second.erase(hash); if (itPrev->second.empty()) mapOrphanTransactionsByPrev.erase(itPrev); } mapOrphanTransactions.erase(it); } unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) { unsigned int nEvicted = 0; while (mapOrphanTransactions.size() > nMaxOrphans) { // Evict a random orphan: uint256 randomhash = GetRandHash(); map<uint256, CTransaction>::iterator it = mapOrphanTransactions.lower_bound(randomhash); if (it == mapOrphanTransactions.end()) it = mapOrphanTransactions.begin(); EraseOrphanTx(it->first); ++nEvicted; } return nEvicted; } ////////////////////////////////////////////////////////////////////////////// // // CTransaction and CTxIndex // bool CTransaction::ReadFromDisk(CTxDB& txdb, const uint256& hash, CTxIndex& txindexRet) { SetNull(); if (!txdb.ReadTxIndex(hash, txindexRet)) return false; if (!ReadFromDisk(txindexRet.pos)) return false; return true; } bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet) { if (!ReadFromDisk(txdb, prevout.hash, txindexRet)) return false; if (prevout.n >= vout.size()) { SetNull(); return false; } return true; } bool CTransaction::ReadFromDisk(CTxDB& txdb, COutPoint prevout) { CTxIndex txindex; return ReadFromDisk(txdb, prevout, txindex); } bool CTransaction::ReadFromDisk(COutPoint prevout) { CTxDB txdb("r"); CTxIndex txindex; return ReadFromDisk(txdb, prevout, txindex); } bool IsStandardTx(const CTransaction& tx, string& reason) { if (tx.nVersion > CTransaction::CURRENT_VERSION || tx.nVersion < 1) { reason = "version"; return false; } // Treat non-final transactions as non-standard to prevent a specific type // of double-spend attack, as well as DoS attacks. (if the transaction // can't be mined, the attacker isn't expending resources broadcasting it) // Basically we don't want to propagate transactions that can't be included in // the next block. // // However, IsFinalTx() is confusing... Without arguments, it uses // chainActive.Height() to evaluate nLockTime; when a block is accepted, chainActive.Height() // is set to the value of nHeight in the block. However, when IsFinalTx() // is called within CBlock::AcceptBlock(), the height of the block *being* // evaluated is what is used. Thus if we want to know if a transaction can // be part of the *next* block, we need to call IsFinalTx() with one more // than chainActive.Height(). // // Timestamps on the other hand don't get any special treatment, because we // can't know what timestamp the next block will have, and there aren't // timestamp applications where it matters. if (!IsFinalTx(tx, nBestHeight + 1)) { reason = "non-final"; return false; } // nTime has different purpose from nLockTime but can be used in similar attacks if (tx.nTime > FutureDrift(GetAdjustedTime())) { reason = "time-too-new"; return false; } // Extremely large transactions with lots of inputs can cost the network // almost as much to process as they cost the sender in fees, because // computing signature hashes is O(ninputs*txsize). Limiting transactions // to MAX_STANDARD_TX_SIZE mitigates CPU exhaustion attacks. unsigned int sz = tx.GetSerializeSize(SER_NETWORK, CTransaction::CURRENT_VERSION); if (sz >= MAX_STANDARD_TX_SIZE) { reason = "tx-size"; return false; } BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // keys. (remember the 520 byte limit on redeemScript size) That works // out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 // bytes of scriptSig, which we round off to 1650 bytes for some minor // future-proofing. That's also enough to spend a 20-of-20 // CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not // considered standard) if (txin.scriptSig.size() > 1650) { reason = "scriptsig-size"; return false; } if (!txin.scriptSig.IsPushOnly()) { reason = "scriptsig-not-pushonly"; return false; } if (!txin.scriptSig.HasCanonicalPushes()) { reason = "scriptsig-non-canonical-push"; return false; } } unsigned int nDataOut = 0; txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; } if (whichType == TX_NULL_DATA) nDataOut++; if (txout.nValue == 0) { reason = "dust"; return false; } if (!txout.scriptPubKey.HasCanonicalPushes()) { reason = "scriptpubkey-non-canonical-push"; return false; } } // not more than one data txout per non-data txout is permitted // only one data txout is permitted too if (nDataOut > 1 && nDataOut > tx.vout.size()/2) { reason = "multi-op-return"; return false; } return true; } bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) { AssertLockHeld(cs_main); // Time based nLockTime implemented in 0.1.6 if (tx.nLockTime == 0) return true; if (nBlockHeight == 0) nBlockHeight = nBestHeight; if (nBlockTime == 0) nBlockTime = GetAdjustedTime(); if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; BOOST_FOREACH(const CTxIn& txin, tx.vin) if (!txin.IsFinal()) return false; return true; } // // Check transaction inputs to mitigate two // potential denial-of-service attacks: // // 1. scriptSigs with extra data stuffed into them, // not consumed by scriptPubKey (or P2SH script) // 2. P2SH scripts with a crazy number of expensive // CHECKSIG/CHECKMULTISIG operations // bool AreInputsStandard(const CTransaction& tx, const MapPrevTx& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases don't use vin normally for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prev = tx.GetOutputFor(tx.vin[i], mapInputs); vector<vector<unsigned char> > vSolutions; txnouttype whichType; // get the scriptPubKey corresponding to this input: const CScript& prevScript = prev.scriptPubKey; if (!Solver(prevScript, whichType, vSolutions)) return false; int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions); if (nArgsExpected < 0) return false; // Transactions with extra stuff in their scriptSigs are // non-standard. Note that this EvalScript() call will // be quick, because if there are any operations // beside "push data" in the scriptSig // IsStandard() will have already returned false // and this method isn't called. vector<vector<unsigned char> > stack; if (!EvalScript(stack, tx.vin[i].scriptSig, tx, i, SCRIPT_VERIFY_NONE, 0)) return false; if (whichType == TX_SCRIPTHASH) { if (stack.empty()) return false; CScript subscript(stack.back().begin(), stack.back().end()); vector<vector<unsigned char> > vSolutions2; txnouttype whichType2; if (Solver(subscript, whichType2, vSolutions2)) { int tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2); if (tmpExpected < 0) return false; nArgsExpected += tmpExpected; } else { // Any other Script with less than 15 sigops OK: unsigned int sigops = subscript.GetSigOpCount(true); // ... extra data left on the stack after execution is OK, too: return (sigops <= MAX_P2SH_SIGOPS); } } if (stack.size() != (unsigned int)nArgsExpected) return false; } return true; } unsigned int GetLegacySigOpCount(const CTransaction& tx) { unsigned int nSigOps = 0; BOOST_FOREACH(const CTxIn& txin, tx.vin) { nSigOps += txin.scriptSig.GetSigOpCount(false); } BOOST_FOREACH(const CTxOut& txout, tx.vout) { nSigOps += txout.scriptPubKey.GetSigOpCount(false); } return nSigOps; } unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& inputs) { if (tx.IsCoinBase()) return 0; unsigned int nSigOps = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prevout = tx.GetOutputFor(tx.vin[i], inputs); if (prevout.scriptPubKey.IsPayToScriptHash()) nSigOps += prevout.scriptPubKey.GetSigOpCount(tx.vin[i].scriptSig); } return nSigOps; } int CMerkleTx::SetMerkleBranch(const CBlock* pblock) { AssertLockHeld(cs_main); CBlock blockTmp; if (pblock == NULL) { // Load the block this tx is in CTxIndex txindex; if (!CTxDB("r").ReadTxIndex(GetHash(), txindex)) return 0; if (!blockTmp.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos)) return 0; pblock = &blockTmp; } // Update the tx's hashBlock hashBlock = pblock->GetHash(); // Locate the transaction for (nIndex = 0; nIndex < (int)pblock->vtx.size(); nIndex++) if (pblock->vtx[nIndex] == *(CTransaction*)this) break; if (nIndex == (int)pblock->vtx.size()) { vMerkleBranch.clear(); nIndex = -1; LogPrintf("ERROR: SetMerkleBranch() : couldn't find tx in block\n"); return 0; } // Fill in merkle branch vMerkleBranch = pblock->GetMerkleBranch(nIndex); // Is the tx in a block that's in the main chain map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; CBlockIndex* pindex = (*mi).second; if (!pindex || !pindex->IsInMainChain()) return 0; return pindexBest->nHeight - pindex->nHeight + 1; } bool CTransaction::CheckTransaction() const { // Basic checks that don't depend on any context if (vin.empty()) return DoS(10, error("CTransaction::CheckTransaction() : vin empty")); if (vout.empty()) return DoS(10, error("CTransaction::CheckTransaction() : vout empty")); // Size limits if (::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) return DoS(100, error("CTransaction::CheckTransaction() : size limits failed")); // Check for negative or overflow output values int64_t nValueOut = 0; for (unsigned int i = 0; i < vout.size(); i++) { const CTxOut& txout = vout[i]; if (txout.IsEmpty() && !IsCoinBase() && !IsCoinStake()) return DoS(100, error("CTransaction::CheckTransaction() : txout empty for user transaction")); if (txout.nValue < 0) return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue negative")); if (txout.nValue > MAX_MONEY) return DoS(100, error("CTransaction::CheckTransaction() : txout.nValue too high")); nValueOut += txout.nValue; if (!MoneyRange(nValueOut)) return DoS(100, error("CTransaction::CheckTransaction() : txout total out of range")); } // Check for duplicate inputs set<COutPoint> vInOutPoints; BOOST_FOREACH(const CTxIn& txin, vin) { if (vInOutPoints.count(txin.prevout)) return false; vInOutPoints.insert(txin.prevout); } if (IsCoinBase()) { if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100) return DoS(100, error("CTransaction::CheckTransaction() : coinbase script size is invalid")); } else { BOOST_FOREACH(const CTxIn& txin, vin) if (txin.prevout.IsNull()) return DoS(10, error("CTransaction::CheckTransaction() : prevout is null")); } return true; } int64_t GetMinFee(const CTransaction& tx, unsigned int nBlockSize, enum GetMinFee_mode mode, unsigned int nBytes) { // Base fee is either MIN_TX_FEE or MIN_RELAY_TX_FEE int64_t nBaseFee = (mode == GMF_RELAY) ? MIN_RELAY_TX_FEE : MIN_TX_FEE; unsigned int nNewBlockSize = nBlockSize + nBytes; int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee; // Raise the price as the block approaches full if (nBlockSize != 1 && nNewBlockSize >= MAX_BLOCK_SIZE_GEN/2) { if (nNewBlockSize >= MAX_BLOCK_SIZE_GEN) return MAX_MONEY; nMinFee *= MAX_BLOCK_SIZE_GEN / (MAX_BLOCK_SIZE_GEN - nNewBlockSize); } if (!MoneyRange(nMinFee)) nMinFee = MAX_MONEY; return nMinFee; } bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, bool* pfMissingInputs) { AssertLockHeld(cs_main); if (pfMissingInputs) *pfMissingInputs = false; if (!tx.CheckTransaction()) return error("AcceptToMemoryPool : CheckTransaction failed"); // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) return tx.DoS(100, error("AcceptToMemoryPool : coinbase as individual tx")); // ppcoin: coinstake is also only valid in a block, not as a loose transaction if (tx.IsCoinStake()) return tx.DoS(100, error("AcceptToMemoryPool : coinstake as individual tx")); // Rather not work on nonstandard transactions (unless -testnet) string reason; if (!TestNet() && !IsStandardTx(tx, reason)) return error("AcceptToMemoryPool : nonstandard transaction: %s", reason); // is it already in the memory pool? uint256 hash = tx.GetHash(); if (pool.exists(hash)) return false; // Check for conflicts with in-memory transactions { LOCK(pool.cs); // protect pool.mapNextTx for (unsigned int i = 0; i < tx.vin.size(); i++) { COutPoint outpoint = tx.vin[i].prevout; if (pool.mapNextTx.count(outpoint)) { // Disable replacement feature for now return false; } } } { CTxDB txdb("r"); // do we already have it? if (txdb.ContainsTx(hash)) return false; MapPrevTx mapInputs; map<uint256, CTxIndex> mapUnused; bool fInvalid = false; if (!tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) { if (fInvalid) return error("AcceptToMemoryPool : FetchInputs found invalid tx %s", hash.ToString()); if (pfMissingInputs) *pfMissingInputs = true; return false; } // Check for non-standard pay-to-script-hash in inputs if (!TestNet() && !AreInputsStandard(tx, mapInputs)) return error("AcceptToMemoryPool : nonstandard transaction input"); // Check that the transaction doesn't have an excessive number of // sigops, making it impossible to mine. Since the coinbase transaction // itself can contain sigops MAX_TX_SIGOPS is less than // MAX_BLOCK_SIGOPS; we still consider this an invalid rather than // merely non-standard transaction. unsigned int nSigOps = GetLegacySigOpCount(tx); nSigOps += GetP2SHSigOpCount(tx, mapInputs); if (nSigOps > MAX_TX_SIGOPS) return tx.DoS(0, error("AcceptToMemoryPool : too many sigops %s, %d > %d", hash.ToString(), nSigOps, MAX_TX_SIGOPS)); int64_t nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); // Don't accept it if it can't get into a block int64_t txMinFee = GetMinFee(tx, 1000, GMF_RELAY, nSize); if ((fLimitFree && nFees < txMinFee) || (!fLimitFree && nFees < MIN_TX_FEE)) return error("AcceptToMemoryPool : not enough fees %s, %d < %d", hash.ToString(), nFees, txMinFee); // Continuously rate-limit free transactions // This mitigates 'penny-flooding' -- sending thousands of free transactions just to // be annoying or make others' transactions take longer to confirm. if (fLimitFree && nFees < MIN_RELAY_TX_FEE) { static CCriticalSection csFreeLimiter; static double dFreeCount; static int64_t nLastTime; int64_t nNow = GetTime(); LOCK(csFreeLimiter); // Use an exponentially decaying ~10-minute window: dFreeCount *= pow(1.0 - 1.0/600.0, (double)(nNow - nLastTime)); nLastTime = nNow; // -limitfreerelay unit is thousand-bytes-per-minute // At default rate it would take over a month to fill 1GB if (dFreeCount > GetArg("-limitfreerelay", 15)*10*1000) return error("AcceptToMemoryPool : free transaction rejected by rate limiter"); LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); dFreeCount += nSize; } // Check against previous transactions // This is done last to help prevent CPU exhaustion denial-of-service attacks. if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, STANDARD_SCRIPT_VERIFY_FLAGS)) { return error("AcceptToMemoryPool : ConnectInputs failed %s", hash.ToString()); } // Check again against just the consensus-critical mandatory script // verification flags, in case of bugs in the standard flags that cause // transactions to pass as valid when they're actually invalid. For // instance the STRICTENC flag was incorrectly allowing certain // CHECKSIG NOT scripts to pass, even though they were invalid. // // There is a similar check in CreateNewBlock() to prevent creating // invalid blocks, however allowing such transactions into the mempool // can be exploited as a DoS attack. if (!tx.ConnectInputs(txdb, mapInputs, mapUnused, CDiskTxPos(1,1,1), pindexBest, false, false, MANDATORY_SCRIPT_VERIFY_FLAGS)) { return error("AcceptToMemoryPool: : BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString()); } } // Store transaction in memory pool.addUnchecked(hash, tx); SyncWithWallets(tx, NULL); LogPrint("mempool", "AcceptToMemoryPool : accepted %s (poolsz %u)\n", hash.ToString(), pool.mapTx.size()); return true; } int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const { if (hashBlock == 0 || nIndex == -1) return 0; AssertLockHeld(cs_main); // Find the block it claims to be in map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); if (mi == mapBlockIndex.end()) return 0; CBlockIndex* pindex = (*mi).second; if (!pindex || !pindex->IsInMainChain()) return 0; // Make sure the merkle branch connects to this block if (!fMerkleVerified) { if (CBlock::CheckMerkleBranch(GetHash(), vMerkleBranch, nIndex) != pindex->hashMerkleRoot) return 0; fMerkleVerified = true; } pindexRet = pindex; return pindexBest->nHeight - pindex->nHeight + 1; } int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const { AssertLockHeld(cs_main); int nResult = GetDepthInMainChainINTERNAL(pindexRet); if (nResult == 0 && !mempool.exists(GetHash())) return -1; // Not in chain, not in mempool return nResult; } int CMerkleTx::GetBlocksToMaturity() const { if (!(IsCoinBase() || IsCoinStake())) return 0; return max(0, (nCoinbaseMaturity+1) - GetDepthInMainChain()); } bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree) { return ::AcceptToMemoryPool(mempool, *this, fLimitFree, NULL); } bool CWalletTx::AcceptWalletTransaction(CTxDB& txdb) { { // Add previous supporting transactions first BOOST_FOREACH(CMerkleTx& tx, vtxPrev) { if (!(tx.IsCoinBase() || tx.IsCoinStake())) { uint256 hash = tx.GetHash(); if (!mempool.exists(hash) && !txdb.ContainsTx(hash)) tx.AcceptToMemoryPool(false); } } return AcceptToMemoryPool(false); } return false; } bool CWalletTx::AcceptWalletTransaction() { CTxDB txdb("r"); return AcceptWalletTransaction(txdb); } int CTxIndex::GetDepthInMainChain() const { // Read block header CBlock block; if (!block.ReadFromDisk(pos.nFile, pos.nBlockPos, false)) return 0; // Find the block in the index map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(block.GetHash()); if (mi == mapBlockIndex.end()) return 0; CBlockIndex* pindex = (*mi).second; if (!pindex || !pindex->IsInMainChain()) return 0; return 1 + nBestHeight - pindex->nHeight; } // Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock) { { LOCK(cs_main); { if (mempool.lookup(hash, tx)) { return true; } } CTxDB txdb("r"); CTxIndex txindex; if (tx.ReadFromDisk(txdb, hash, txindex)) { CBlock block; if (block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) hashBlock = block.GetHash(); return true; } // look for transaction in disconnected blocks to find orphaned CoinBase and CoinStake transactions BOOST_FOREACH(PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) { CBlockIndex* pindex = item.second; if (pindex == pindexBest || pindex->pnext != 0) continue; CBlock block; if (!block.ReadFromDisk(pindex)) continue; BOOST_FOREACH(const CTransaction& txOrphan, block.vtx) { if (txOrphan.GetHash() == hash) { tx = txOrphan; return true; } } } } return false; } ////////////////////////////////////////////////////////////////////////////// // // CBlock and CBlockIndex // static CBlockIndex* pblockindexFBBHLast; CBlockIndex* FindBlockByHeight(int nHeight) { CBlockIndex *pblockindex; if (nHeight < nBestHeight / 2) pblockindex = pindexGenesisBlock; else pblockindex = pindexBest; if (pblockindexFBBHLast && abs(nHeight - pblockindex->nHeight) > abs(nHeight - pblockindexFBBHLast->nHeight)) pblockindex = pblockindexFBBHLast; while (pblockindex->nHeight > nHeight) pblockindex = pblockindex->pprev; while (pblockindex->nHeight < nHeight) pblockindex = pblockindex->pnext; pblockindexFBBHLast = pblockindex; return pblockindex; } bool CBlock::ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions) { if (!fReadTransactions) { *this = pindex->GetBlockHeader(); return true; } if (!ReadFromDisk(pindex->nFile, pindex->nBlockPos, fReadTransactions)) return false; if (GetHash() != pindex->GetBlockHash()) return error("CBlock::ReadFromDisk() : GetHash() doesn't match index"); return true; } uint256 static GetOrphanRoot(const uint256& hash) { map<uint256, COrphanBlock*>::iterator it = mapOrphanBlocks.find(hash); if (it == mapOrphanBlocks.end()) return hash; // Work back to the first block in the orphan chain do { map<uint256, COrphanBlock*>::iterator it2 = mapOrphanBlocks.find(it->second->hashPrev); if (it2 == mapOrphanBlocks.end()) return it->first; it = it2; } while(true); } // ppcoin: find block wanted by given orphan block uint256 WantedByOrphan(const COrphanBlock* pblockOrphan) { // Work back to the first block in the orphan chain while (mapOrphanBlocks.count(pblockOrphan->hashPrev)) pblockOrphan = mapOrphanBlocks[pblockOrphan->hashPrev]; return pblockOrphan->hashPrev; } // Remove a random orphan block (which does not have any dependent orphans). void static PruneOrphanBlocks() { size_t nMaxOrphanBlocksSize = GetArg("-maxorphanblocksmib", DEFAULT_MAX_ORPHAN_BLOCKS) * ((size_t) 1 << 20); while (nOrphanBlocksSize > nMaxOrphanBlocksSize) { // Pick a random orphan block. int pos = insecure_rand() % mapOrphanBlocksByPrev.size(); std::multimap<uint256, COrphanBlock*>::iterator it = mapOrphanBlocksByPrev.begin(); while (pos--) it++; // As long as this block has other orphans depending on it, move to one of those successors. do { std::multimap<uint256, COrphanBlock*>::iterator it2 = mapOrphanBlocksByPrev.find(it->second->hashBlock); if (it2 == mapOrphanBlocksByPrev.end()) break; it = it2; } while(1); setStakeSeenOrphan.erase(it->second->stake); uint256 hash = it->second->hashBlock; nOrphanBlocksSize -= it->second->vchBlock.size(); delete it->second; mapOrphanBlocksByPrev.erase(it); mapOrphanBlocks.erase(hash); } } static CBigNum GetProofOfStakeLimit(int nHeight) { return bnProofOfStakeLimit; } // miner's coin base reward int64_t GetProofOfWorkReward(int64_t nFees, int nHeight) { int64_t nSubsidy = 0; if (!TestNet()) { if (nHeight <= 499) nSubsidy = 0; else nSubsidy = 50 * COIN; } else { if (nHeight <= 20) nSubsidy = 0; else nSubsidy = 50 * COIN; } if (!TestNet()) nSubsidy >>= (pindexBest->nHeight / 420480); else nSubsidy >>= (pindexBest->nHeight / 1000); LogPrint("creation", "GetProofOfWorkReward() : create=%s nSubsidy=%d\n", FormatMoney(nSubsidy), nSubsidy); return nSubsidy + nFees; } // miner's coin stake reward int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, int64_t nCoinAge, int64_t nFees) { int64_t nSubsidy = 0; LogPrint("creation", "GetProofOfStakeReward(): create=%s nCoinAge=%d\n", FormatMoney(nSubsidy), nCoinAge); return nSubsidy + nFees; } static const int64_t nTargetTimespan = 60 * 60; // 1 hour // ppcoin: find last block index up to pindex const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake) { while (pindex && pindex->pprev && (pindex->IsProofOfStake() != fProofOfStake)) pindex = pindex->pprev; return pindex; } unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake) { CBigNum bnTargetLimit = fProofOfStake ? GetProofOfStakeLimit(pindexLast->nHeight) : Params().ProofOfWorkLimit(); if (pindexLast == NULL) return bnTargetLimit.GetCompact(); // genesis block const CBlockIndex* pindexPrev = GetLastBlockIndex(pindexLast, fProofOfStake); if (pindexPrev->pprev == NULL) return bnTargetLimit.GetCompact(); // first block const CBlockIndex* pindexPrevPrev = GetLastBlockIndex(pindexPrev->pprev, fProofOfStake); if (pindexPrevPrev->pprev == NULL) return bnTargetLimit.GetCompact(); // second block int64_t nTargetSpacing = GetTargetSpacing(pindexLast->nHeight); int64_t nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); if (nActualSpacing < 0) nActualSpacing = nTargetSpacing; if (nActualSpacing > nTargetSpacing * 10) nActualSpacing = nTargetSpacing * 10; // ppcoin: target change every block // ppcoin: retarget with exponential moving toward target spacing CBigNum bnNew; bnNew.SetCompact(pindexPrev->nBits); int64_t nInterval = nTargetTimespan / nTargetSpacing; bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing); bnNew /= ((nInterval + 1) * nTargetSpacing); if (bnNew <= 0 || bnNew > bnTargetLimit) bnNew = bnTargetLimit; return bnNew.GetCompact(); } bool CheckProofOfWork(uint256 hash, unsigned int nBits) { CBigNum bnTarget; bnTarget.SetCompact(nBits); // Check range if (bnTarget <= 0 || bnTarget > Params().ProofOfWorkLimit()) return error("CheckProofOfWork() : nBits below minimum work"); // Check proof of work matches claimed amount if (hash > bnTarget.getuint256()) return error("CheckProofOfWork() : hash doesn't match nBits"); return true; } bool IsInitialBlockDownload() { LOCK(cs_main); if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate()) return true; static int64_t nLastUpdate; static CBlockIndex* pindexLastBest; if (pindexBest != pindexLastBest) { pindexLastBest = pindexBest; nLastUpdate = GetTime(); } return (GetTime() - nLastUpdate < 15 && pindexBest->GetBlockTime() < GetTime() - 8 * 60 * 60); } void static InvalidChainFound(CBlockIndex* pindexNew) { if (pindexNew->nChainTrust > nBestInvalidTrust) { nBestInvalidTrust = pindexNew->nChainTrust; CTxDB().WriteBestInvalidTrust(CBigNum(nBestInvalidTrust)); } uint256 nBestInvalidBlockTrust = pindexNew->nChainTrust - pindexNew->pprev->nChainTrust; uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; LogPrintf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%d date=%s\n", pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, CBigNum(pindexNew->nChainTrust).ToString(), nBestInvalidBlockTrust.GetLow64(), DateTimeStrFormat("%x %H:%M:%S", pindexNew->GetBlockTime())); LogPrintf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%d date=%s\n", hashBestChain.ToString(), nBestHeight, CBigNum(pindexBest->nChainTrust).ToString(), nBestBlockTrust.GetLow64(), DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime())); } void CBlock::UpdateTime(const CBlockIndex* pindexPrev) { nTime = max(GetBlockTime(), GetAdjustedTime()); } bool IsConfirmedInNPrevBlocks(const CTxIndex& txindex, const CBlockIndex* pindexFrom, int nMaxDepth, int& nActualDepth) { for (const CBlockIndex* pindex = pindexFrom; pindex && pindexFrom->nHeight - pindex->nHeight < nMaxDepth; pindex = pindex->pprev) { if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile) { nActualDepth = pindexFrom->nHeight - pindex->nHeight; return true; } } return false; } bool CTransaction::DisconnectInputs(CTxDB& txdb) { // Relinquish previous transactions' spent pointers if (!IsCoinBase()) { BOOST_FOREACH(const CTxIn& txin, vin) { COutPoint prevout = txin.prevout; // Get prev txindex from disk CTxIndex txindex; if (!txdb.ReadTxIndex(prevout.hash, txindex)) return error("DisconnectInputs() : ReadTxIndex failed"); if (prevout.n >= txindex.vSpent.size()) return error("DisconnectInputs() : prevout.n out of range"); // Mark outpoint as not spent txindex.vSpent[prevout.n].SetNull(); // Write back if (!txdb.UpdateTxIndex(prevout.hash, txindex)) return error("DisconnectInputs() : UpdateTxIndex failed"); } } // Remove transaction from index // This can fail if a duplicate of this transaction was in a chain that got // reorganized away. This is only possible if this transaction was completely // spent, so erasing it would be a no-op anyway. txdb.EraseTxIndex(*this); return true; } bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTestPool, bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid) { // FetchInputs can return false either because we just haven't seen some inputs // (in which case the transaction should be stored as an orphan) // or because the transaction is malformed (in which case the transaction should // be dropped). If tx is definitely invalid, fInvalid will be set to true. fInvalid = false; if (IsCoinBase()) return true; // Coinbase transactions have no inputs to fetch. for (unsigned int i = 0; i < vin.size(); i++) { COutPoint prevout = vin[i].prevout; if (inputsRet.count(prevout.hash)) continue; // Got it already // Read txindex CTxIndex& txindex = inputsRet[prevout.hash].first; bool fFound = true; if ((fBlock || fMiner) && mapTestPool.count(prevout.hash)) { // Get txindex from current proposed changes txindex = mapTestPool.find(prevout.hash)->second; } else { // Read txindex from txdb fFound = txdb.ReadTxIndex(prevout.hash, txindex); } if (!fFound && (fBlock || fMiner)) return fMiner ? false : error("FetchInputs() : %s prev tx %s index entry not found", GetHash().ToString(), prevout.hash.ToString()); // Read txPrev CTransaction& txPrev = inputsRet[prevout.hash].second; if (!fFound || txindex.pos == CDiskTxPos(1,1,1)) { // Get prev tx from single transactions in memory if (!mempool.lookup(prevout.hash, txPrev)) return error("FetchInputs() : %s mempool Tx prev not found %s", GetHash().ToString(), prevout.hash.ToString()); if (!fFound) txindex.vSpent.resize(txPrev.vout.size()); } else { // Get prev tx from disk if (!txPrev.ReadFromDisk(txindex.pos)) return error("FetchInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString(), prevout.hash.ToString()); } } // Make sure all prevout.n indexes are valid: for (unsigned int i = 0; i < vin.size(); i++) { const COutPoint prevout = vin[i].prevout; assert(inputsRet.count(prevout.hash) != 0); const CTxIndex& txindex = inputsRet[prevout.hash].first; const CTransaction& txPrev = inputsRet[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) { // Revisit this if/when transaction replacement is implemented and allows // adding inputs: fInvalid = true; return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %u %u prev tx %s\n%s", GetHash().ToString(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString(), txPrev.ToString())); } } return true; } const CTxOut& CTransaction::GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const { MapPrevTx::const_iterator mi = inputs.find(input.prevout.hash); if (mi == inputs.end()) throw std::runtime_error("CTransaction::GetOutputFor() : prevout.hash not found"); const CTransaction& txPrev = (mi->second).second; if (input.prevout.n >= txPrev.vout.size()) throw std::runtime_error("CTransaction::GetOutputFor() : prevout.n out of range"); return txPrev.vout[input.prevout.n]; } int64_t CTransaction::GetValueIn(const MapPrevTx& inputs) const { if (IsCoinBase()) return 0; int64_t nResult = 0; for (unsigned int i = 0; i < vin.size(); i++) { nResult += GetOutputFor(vin[i], inputs).nValue; } return nResult; } bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags) { // Take over previous transactions' spent pointers // fBlock is true when this is called from AcceptBlock when a new best-block is added to the blockchain // fMiner is true when called from the internal bitcoin miner // ... both are false when called from CTransaction::AcceptToMemoryPool if (!IsCoinBase()) { int64_t nValueIn = 0; int64_t nFees = 0; for (unsigned int i = 0; i < vin.size(); i++) { COutPoint prevout = vin[i].prevout; assert(inputs.count(prevout.hash) > 0); CTxIndex& txindex = inputs[prevout.hash].first; CTransaction& txPrev = inputs[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %u %u prev tx %s\n%s", GetHash().ToString(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString(), txPrev.ToString())); // If prev is coinbase or coinstake, check that it's matured if (txPrev.IsCoinBase() || txPrev.IsCoinStake()) { int nSpendDepth; if (IsConfirmedInNPrevBlocks(txindex, pindexBlock, nCoinbaseMaturity, nSpendDepth)) return error("ConnectInputs() : tried to spend %s at depth %d", txPrev.IsCoinBase() ? "coinbase" : "coinstake", nSpendDepth); } // ppcoin: check transaction timestamp if (txPrev.nTime > nTime) return DoS(100, error("ConnectInputs() : transaction timestamp earlier than input transaction")); if (txPrev.vout[prevout.n].IsEmpty()) return DoS(1, error("ConnectInputs() : special marker is not spendable")); // Check for negative or overflow input values nValueIn += txPrev.vout[prevout.n].nValue; if (!MoneyRange(txPrev.vout[prevout.n].nValue) || !MoneyRange(nValueIn)) return DoS(100, error("ConnectInputs() : txin values out of range")); } // The first loop above does all the inexpensive checks. // Only if ALL inputs pass do we perform expensive ECDSA signature checks. // Helps prevent CPU exhaustion attacks. for (unsigned int i = 0; i < vin.size(); i++) { COutPoint prevout = vin[i].prevout; assert(inputs.count(prevout.hash) > 0); CTxIndex& txindex = inputs[prevout.hash].first; CTransaction& txPrev = inputs[prevout.hash].second; // Check for conflicts (double-spend) // This doesn't trigger the DoS code on purpose; if it did, it would make it easier // for an attacker to attempt to split the network. if (!txindex.vSpent[prevout.n].IsNull()) return fMiner ? false : error("ConnectInputs() : %s prev tx already used at %s", GetHash().ToString(), txindex.vSpent[prevout.n].ToString()); // Skip ECDSA signature verification when connecting blocks (fBlock=true) // before the last blockchain checkpoint. This is safe because block merkle hashes are // still computed and checked, and any change will be caught at the next checkpoint. if (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))) { // Verify signature if (!VerifySignature(txPrev, *this, i, flags, 0)) { if (flags & STANDARD_NOT_MANDATORY_VERIFY_FLAGS) { // Check whether the failure was caused by a // non-mandatory script verification check, such as // non-null dummy arguments; // if so, don't trigger DoS protection to // avoid splitting the network between upgraded and // non-upgraded nodes. if (VerifySignature(txPrev, *this, i, flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS, 0)) return error("ConnectInputs() : %s non-mandatory VerifySignature failed", GetHash().ToString()); } // Failures of other flags indicate a transaction that is // invalid in new blocks, e.g. a invalid P2SH. We DoS ban // such nodes as they are not following the protocol. That // said during an upgrade careful thought should be taken // as to the correct behavior - we may want to continue // peering with non-upgraded nodes even after a soft-fork // super-majority vote has passed. return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString())); } } // Mark outpoints as spent txindex.vSpent[prevout.n] = posThisTx; // Write back if (fBlock || fMiner) { mapTestPool[prevout.hash] = txindex; } } if (!IsCoinStake()) { if (nValueIn < GetValueOut()) return DoS(100, error("ConnectInputs() : %s value in < value out", GetHash().ToString())); // Tally transaction fees int64_t nTxFee = nValueIn - GetValueOut(); if (nTxFee < 0) return DoS(100, error("ConnectInputs() : %s nTxFee < 0", GetHash().ToString())); // enforce transaction fees for every block int64_t nRequiredFee = GetMinFee(*this); if (nTxFee < nRequiredFee) return fBlock? DoS(100, error("ConnectInputs() : %s not paying required fee=%s, paid=%s", GetHash().ToString(), FormatMoney(nRequiredFee), FormatMoney(nTxFee))) : false; nFees += nTxFee; if (!MoneyRange(nFees)) return DoS(100, error("ConnectInputs() : nFees out of range")); } } return true; } bool CBlock::DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex) { // Disconnect in reverse order for (int i = vtx.size()-1; i >= 0; i--) if (!vtx[i].DisconnectInputs(txdb)) return false; // Update block index on disk without changing it in memory. // The memory index structure will be changed after the db commits. if (pindex->pprev) { CDiskBlockIndex blockindexPrev(pindex->pprev); blockindexPrev.hashNext = 0; if (!txdb.WriteBlockIndex(blockindexPrev)) return error("DisconnectBlock() : WriteBlockIndex failed"); } // ppcoin: clean up wallet after disconnecting coinstake BOOST_FOREACH(CTransaction& tx, vtx) SyncWithWallets(tx, this, false); return true; } bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) { // Check it again in case a previous version let a bad block in, but skip BlockSig checking if (!CheckBlock(!fJustCheck, !fJustCheck, false)) return false; unsigned int flags = SCRIPT_VERIFY_NOCACHE; flags |= SCRIPT_VERIFY_NULLDUMMY | SCRIPT_VERIFY_STRICTENC | SCRIPT_VERIFY_ALLOW_EMPTY_SIG | SCRIPT_VERIFY_FIX_HASHTYPE | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY; //// issue here: it doesn't know the version unsigned int nTxPos; if (fJustCheck) // FetchInputs treats CDiskTxPos(1,1,1) as a special "refer to memorypool" indicator // Since we're just checking the block and not actually connecting it, it might not (and probably shouldn't) be on the disk to get the transaction from nTxPos = 1; else nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION) - (2 * GetSizeOfCompactSize(0)) + GetSizeOfCompactSize(vtx.size()); map<uint256, CTxIndex> mapQueuedChanges; int64_t nFees = 0; int64_t nValueIn = 0; int64_t nValueOut = 0; int64_t nStakeReward = 0; unsigned int nSigOps = 0; BOOST_FOREACH(CTransaction& tx, vtx) { uint256 hashTx = tx.GetHash(); // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. // If such overwrites are allowed, coinbases and transactions depending upon those // can be duplicated to remove the ability to spend the first instance -- even after // being sent to another address. // See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information. // This logic is not necessary for memory pool transactions, as AcceptToMemoryPool // already refuses previously-known transaction ids entirely. // This rule was originally applied all blocks whose timestamp was after March 15, 2012, 0:00 UTC. // Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the // two in the chain that violate it. This prevents exploiting the issue against nodes in their // initial block download. CTxIndex txindexOld; if (txdb.ReadTxIndex(hashTx, txindexOld)) { BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent) if (pos.IsNull()) return DoS(100, error("ConnectBlock() : tried to overwrite transaction")); } nSigOps += GetLegacySigOpCount(tx); if (nSigOps > MAX_BLOCK_SIGOPS) return DoS(100, error("ConnectBlock() : too many sigops")); CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); if (!fJustCheck) nTxPos += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); MapPrevTx mapInputs; if (tx.IsCoinBase()) nValueOut += tx.GetValueOut(); else { bool fInvalid; if (!tx.FetchInputs(txdb, mapQueuedChanges, true, false, mapInputs, fInvalid)) return false; // Add in sigops done by pay-to-script-hash inputs; // this is to prevent a "rogue miner" from creating // an incredibly-expensive-to-validate block. nSigOps += GetP2SHSigOpCount(tx, mapInputs); if (nSigOps > MAX_BLOCK_SIGOPS) return DoS(100, error("ConnectBlock() : too many sigops")); int64_t nTxValueIn = tx.GetValueIn(mapInputs); int64_t nTxValueOut = tx.GetValueOut(); nValueIn += nTxValueIn; nValueOut += nTxValueOut; if (!tx.IsCoinStake()) nFees += nTxValueIn - nTxValueOut; if (tx.IsCoinStake()) nStakeReward = nTxValueOut - nTxValueIn; if (!tx.ConnectInputs(txdb, mapInputs, mapQueuedChanges, posThisTx, pindex, true, false, flags)) return false; } mapQueuedChanges[hashTx] = CTxIndex(posThisTx, tx.vout.size()); } if (IsProofOfWork()) { int64_t nReward = GetProofOfWorkReward(nFees, pindex->nHeight); // Check coinbase reward if (vtx[0].GetValueOut() > nReward) return DoS(50, error("ConnectBlock() : coinbase reward exceeded (actual=%d vs calculated=%d)", vtx[0].GetValueOut(), nReward)); } if (IsProofOfStake()) { // ppcoin: coin stake tx earns reward instead of paying fee uint64_t nCoinAge; if (!vtx[1].GetCoinAge(txdb, pindex->pprev, nCoinAge)) return error("ConnectBlock() : %s unable to get coin age for coinstake", vtx[1].GetHash().ToString()); int64_t nCalculatedStakeReward = GetProofOfStakeReward(pindex->pprev, nCoinAge, nFees); if (nStakeReward > nCalculatedStakeReward) return DoS(100, error("ConnectBlock() : coinstake pays too much(actual=%d vs calculated=%d)", nStakeReward, nCalculatedStakeReward)); } // ppcoin: track money supply and mint amount info pindex->nMint = nValueOut - nValueIn + nFees; pindex->nMoneySupply = (pindex->pprev? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn; if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex))) return error("Connect() : WriteBlockIndex for pindex failed"); if (fJustCheck) return true; // Write queued txindex changes for (map<uint256, CTxIndex>::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) { if (!txdb.UpdateTxIndex((*mi).first, (*mi).second)) return error("ConnectBlock() : UpdateTxIndex failed"); } // Update block index on disk without changing it in memory. // The memory index structure will be changed after the db commits. if (pindex->pprev) { CDiskBlockIndex blockindexPrev(pindex->pprev); blockindexPrev.hashNext = pindex->GetBlockHash(); if (!txdb.WriteBlockIndex(blockindexPrev)) return error("ConnectBlock() : WriteBlockIndex failed"); } // Watch for transactions paying to me BOOST_FOREACH(CTransaction& tx, vtx) SyncWithWallets(tx, this); return true; } bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) { LogPrintf("REORGANIZE\n"); // Find the fork CBlockIndex* pfork = pindexBest; CBlockIndex* plonger = pindexNew; while (pfork != plonger) { while (plonger->nHeight > pfork->nHeight) if (!(plonger = plonger->pprev)) return error("Reorganize() : plonger->pprev is null"); if (pfork == plonger) break; if (!(pfork = pfork->pprev)) return error("Reorganize() : pfork->pprev is null"); } // List of what to disconnect vector<CBlockIndex*> vDisconnect; for (CBlockIndex* pindex = pindexBest; pindex != pfork; pindex = pindex->pprev) vDisconnect.push_back(pindex); // List of what to connect vector<CBlockIndex*> vConnect; for (CBlockIndex* pindex = pindexNew; pindex != pfork; pindex = pindex->pprev) vConnect.push_back(pindex); reverse(vConnect.begin(), vConnect.end()); LogPrintf("REORGANIZE: Disconnect %u blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString(), pindexBest->GetBlockHash().ToString()); LogPrintf("REORGANIZE: Connect %u blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString(), pindexNew->GetBlockHash().ToString()); // Disconnect shorter branch list<CTransaction> vResurrect; BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) { CBlock block; if (!block.ReadFromDisk(pindex)) return error("Reorganize() : ReadFromDisk for disconnect failed"); if (!block.DisconnectBlock(txdb, pindex)) return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString()); // Queue memory transactions to resurrect. // We only do this for blocks after the last checkpoint (reorganisation before that // point should only happen with -reindex/-loadblock, or a misbehaving peer. BOOST_REVERSE_FOREACH(const CTransaction& tx, block.vtx) if (!(tx.IsCoinBase() || tx.IsCoinStake()) && pindex->nHeight > Checkpoints::GetTotalBlocksEstimate()) vResurrect.push_front(tx); } // Connect longer branch vector<CTransaction> vDelete; for (unsigned int i = 0; i < vConnect.size(); i++) { CBlockIndex* pindex = vConnect[i]; CBlock block; if (!block.ReadFromDisk(pindex)) return error("Reorganize() : ReadFromDisk for connect failed"); if (!block.ConnectBlock(txdb, pindex)) { // Invalid block return error("Reorganize() : ConnectBlock %s failed", pindex->GetBlockHash().ToString()); } // Queue memory transactions to delete BOOST_FOREACH(const CTransaction& tx, block.vtx) vDelete.push_back(tx); } if (!txdb.WriteHashBestChain(pindexNew->GetBlockHash())) return error("Reorganize() : WriteHashBestChain failed"); // Make sure it's successfully written to disk before changing memory structure if (!txdb.TxnCommit()) return error("Reorganize() : TxnCommit failed"); // Disconnect shorter branch BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) if (pindex->pprev) pindex->pprev->pnext = NULL; // Connect longer branch BOOST_FOREACH(CBlockIndex* pindex, vConnect) if (pindex->pprev) pindex->pprev->pnext = pindex; // Resurrect memory transactions that were in the disconnected branch BOOST_FOREACH(CTransaction& tx, vResurrect) AcceptToMemoryPool(mempool, tx, false, NULL); // Delete redundant memory transactions that are in the connected branch BOOST_FOREACH(CTransaction& tx, vDelete) { mempool.remove(tx); mempool.removeConflicts(tx); } LogPrintf("REORGANIZE: done\n"); return true; } // Called from inside SetBestChain: attaches a block to the new best chain being built bool CBlock::SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew) { uint256 hash = GetHash(); // Adding to current best branch if (!ConnectBlock(txdb, pindexNew) || !txdb.WriteHashBestChain(hash)) { txdb.TxnAbort(); InvalidChainFound(pindexNew); return false; } if (!txdb.TxnCommit()) return error("SetBestChain() : TxnCommit failed"); // Add to current best branch pindexNew->pprev->pnext = pindexNew; // Delete redundant memory transactions BOOST_FOREACH(CTransaction& tx, vtx) mempool.remove(tx); return true; } bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) { uint256 hash = GetHash(); if (!txdb.TxnBegin()) return error("SetBestChain() : TxnBegin failed"); if (pindexGenesisBlock == NULL && hash == Params().HashGenesisBlock()) { txdb.WriteHashBestChain(hash); if (!txdb.TxnCommit()) return error("SetBestChain() : TxnCommit failed"); pindexGenesisBlock = pindexNew; } else if (hashPrevBlock == hashBestChain) { if (!SetBestChainInner(txdb, pindexNew)) return error("SetBestChain() : SetBestChainInner failed"); } else { // the first block in the new chain that will cause it to become the new best chain CBlockIndex *pindexIntermediate = pindexNew; // list of blocks that need to be connected afterwards std::vector<CBlockIndex*> vpindexSecondary; // Reorganize is costly in terms of db load, as it works in a single db transaction. // Try to limit how much needs to be done inside while (pindexIntermediate->pprev && pindexIntermediate->pprev->nChainTrust > pindexBest->nChainTrust) { vpindexSecondary.push_back(pindexIntermediate); pindexIntermediate = pindexIntermediate->pprev; } if (!vpindexSecondary.empty()) LogPrintf("Postponing %u reconnects\n", vpindexSecondary.size()); // Switch to new best branch if (!Reorganize(txdb, pindexIntermediate)) { txdb.TxnAbort(); InvalidChainFound(pindexNew); return error("SetBestChain() : Reorganize failed"); } // Connect further blocks BOOST_REVERSE_FOREACH(CBlockIndex *pindex, vpindexSecondary) { CBlock block; if (!block.ReadFromDisk(pindex)) { LogPrintf("SetBestChain() : ReadFromDisk failed\n"); break; } if (!txdb.TxnBegin()) { LogPrintf("SetBestChain() : TxnBegin 2 failed\n"); break; } // errors now are not fatal, we still did a reorganisation to a new chain in a valid way if (!block.SetBestChainInner(txdb, pindex)) break; } } // Update best block in wallet (so we can detect restored wallets) bool fIsInitialDownload = IsInitialBlockDownload(); if ((pindexNew->nHeight % 20160) == 0 || (!fIsInitialDownload && (pindexNew->nHeight % 144) == 0)) { const CBlockLocator locator(pindexNew); g_signals.SetBestChain(locator); } // New best block hashBestChain = hash; pindexBest = pindexNew; pblockindexFBBHLast = NULL; nBestHeight = pindexBest->nHeight; nBestChainTrust = pindexNew->nChainTrust; nTimeBestReceived = GetTime(); mempool.AddTransactionsUpdated(1); uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; LogPrintf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%d date=%s\n", hashBestChain.ToString(), nBestHeight, CBigNum(nBestChainTrust).ToString(), nBestBlockTrust.GetLow64(), DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime())); // Check the version of the last 100 blocks to see if we need to upgrade: if (!fIsInitialDownload) { int nUpgraded = 0; const CBlockIndex* pindex = pindexBest; for (int i = 0; i < 100 && pindex != NULL; i++) { if (pindex->nVersion > CBlock::CURRENT_VERSION) ++nUpgraded; pindex = pindex->pprev; } if (nUpgraded > 0) LogPrintf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, (int)CBlock::CURRENT_VERSION); if (nUpgraded > 100/2) // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user: strMiscWarning = _("Warning: This version is obsolete, upgrade required!"); } std::string strCmd = GetArg("-blocknotify", ""); if (!fIsInitialDownload && !strCmd.empty()) { boost::replace_all(strCmd, "%s", hashBestChain.GetHex()); boost::thread t(runCommand, strCmd); // thread runs free } return true; } // ppcoin: total coin age spent in transaction, in the unit of coin-days. // Only those coins meeting minimum age requirement counts. As those // transactions not in main chain are not currently indexed so we // might not find out about their coin age. Older transactions are // guaranteed to be in main chain by sync-checkpoint. This rule is // introduced to help nodes establish a consistent view of the coin // age (trust score) of competing branches. bool CTransaction::GetCoinAge(CTxDB& txdb, const CBlockIndex* pindexPrev, uint64_t& nCoinAge) const { CBigNum bnCentSecond = 0; // coin age in the unit of cent-seconds nCoinAge = 0; if (IsCoinBase()) return true; BOOST_FOREACH(const CTxIn& txin, vin) { // First try finding the previous transaction in database CTransaction txPrev; CTxIndex txindex; if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) continue; // previous transaction not in main chain if (nTime < txPrev.nTime) return false; // Transaction timestamp violation int nSpendDepth; if (IsConfirmedInNPrevBlocks(txindex, pindexPrev, nStakeMinConfirmations - 1, nSpendDepth)) { LogPrint("coinage", "coin age skip nSpendDepth=%d\n", nSpendDepth + 1); continue; // only count coins meeting min confirmations requirement } int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue; bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT; LogPrint("coinage", "coin age nValueIn=%d nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString()); } CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); LogPrint("coinage", "coin age bnCoinDay=%s\n", bnCoinDay.ToString()); nCoinAge = bnCoinDay.getuint64(); return true; } bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const uint256& hashProof) { AssertLockHeld(cs_main); // Check for duplicate uint256 hash = GetHash(); if (mapBlockIndex.count(hash)) return error("AddToBlockIndex() : %s already exists", hash.ToString()); // Construct new block index object CBlockIndex* pindexNew = new CBlockIndex(nFile, nBlockPos, *this); if (!pindexNew) return error("AddToBlockIndex() : new CBlockIndex failed"); pindexNew->phashBlock = &hash; map<uint256, CBlockIndex*>::iterator miPrev = mapBlockIndex.find(hashPrevBlock); if (miPrev != mapBlockIndex.end()) { pindexNew->pprev = (*miPrev).second; pindexNew->nHeight = pindexNew->pprev->nHeight + 1; } // ppcoin: compute chain trust score pindexNew->nChainTrust = (pindexNew->pprev ? pindexNew->pprev->nChainTrust : 0) + pindexNew->GetBlockTrust(); // ppcoin: compute stake entropy bit for stake modifier if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit())) return error("AddToBlockIndex() : SetStakeEntropyBit() failed"); // Record proof hash value pindexNew->hashProof = hashProof; // ppcoin: compute stake modifier uint64_t nStakeModifier = 0; bool fGeneratedStakeModifier = false; if (!ComputeNextStakeModifier(pindexNew->pprev, nStakeModifier, fGeneratedStakeModifier)) return error("AddToBlockIndex() : ComputeNextStakeModifier() failed"); pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); pindexNew->bnStakeModifierV2 = ComputeStakeModifierV2(pindexNew->pprev, IsProofOfWork() ? hash : vtx[1].vin[0].prevout.hash); // Add to mapBlockIndex map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; if (pindexNew->IsProofOfStake()) setStakeSeen.insert(make_pair(pindexNew->prevoutStake, pindexNew->nStakeTime)); pindexNew->phashBlock = &((*mi).first); // Write to disk block index CTxDB txdb; if (!txdb.TxnBegin()) return false; txdb.WriteBlockIndex(CDiskBlockIndex(pindexNew)); if (!txdb.TxnCommit()) return false; // New best if (pindexNew->nChainTrust > nBestChainTrust) if (!SetBestChain(txdb, pindexNew)) return false; if (pindexNew == pindexBest) { // Notify UI to display prev block's coinbase if it was ours static uint256 hashPrevBestCoinBase; g_signals.UpdatedTransaction(hashPrevBestCoinBase); hashPrevBestCoinBase = vtx[0].GetHash(); } return true; } bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) const { // These are checks that are independent of context // that can be verified before saving an orphan block. // Size limits if (vtx.empty() || vtx.size() > MAX_BLOCK_SIZE || ::GetSerializeSize(*this, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) return DoS(100, error("CheckBlock() : size limits failed")); // Check proof of work matches claimed amount if (fCheckPOW && IsProofOfWork() && !CheckProofOfWork(GetPoWHash(), nBits)) return DoS(50, error("CheckBlock() : proof of work failed")); // Check timestamp if (GetBlockTime() > FutureDrift(GetAdjustedTime())) return error("CheckBlock() : block timestamp too far in the future"); // First transaction must be coinbase, the rest must not be if (vtx.empty() || !vtx[0].IsCoinBase()) return DoS(100, error("CheckBlock() : first tx is not coinbase")); for (unsigned int i = 1; i < vtx.size(); i++) if (vtx[i].IsCoinBase()) return DoS(100, error("CheckBlock() : more than one coinbase")); if (IsProofOfStake()) { // Coinbase output should be empty if proof-of-stake block if (vtx[0].vout.size() != 1 || !vtx[0].vout[0].IsEmpty()) return DoS(100, error("CheckBlock() : coinbase output not empty for proof-of-stake block")); // Second transaction must be coinstake, the rest must not be if (vtx.empty() || !vtx[1].IsCoinStake()) return DoS(100, error("CheckBlock() : second tx is not coinstake")); for (unsigned int i = 2; i < vtx.size(); i++) if (vtx[i].IsCoinStake()) return DoS(100, error("CheckBlock() : more than one coinstake")); } // Check proof-of-stake block signature if (fCheckSig && !CheckBlockSignature()) return DoS(100, error("CheckBlock() : bad proof-of-stake block signature")); // Check transactions BOOST_FOREACH(const CTransaction& tx, vtx) { if (!tx.CheckTransaction()) return DoS(tx.nDoS, error("CheckBlock() : CheckTransaction failed")); // ppcoin: check transaction timestamp if (GetBlockTime() < (int64_t)tx.nTime) return DoS(50, error("CheckBlock() : block timestamp earlier than transaction timestamp")); } // Check for duplicate txids. This is caught by ConnectInputs(), // but catching it earlier avoids a potential DoS attack: set<uint256> uniqueTx; BOOST_FOREACH(const CTransaction& tx, vtx) { uniqueTx.insert(tx.GetHash()); } if (uniqueTx.size() != vtx.size()) return DoS(100, error("CheckBlock() : duplicate transaction")); unsigned int nSigOps = 0; BOOST_FOREACH(const CTransaction& tx, vtx) { nSigOps += GetLegacySigOpCount(tx); } if (nSigOps > MAX_BLOCK_SIGOPS) return DoS(100, error("CheckBlock() : out-of-bounds SigOpCount")); // Check merkle root if (fCheckMerkleRoot && hashMerkleRoot != BuildMerkleTree()) return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch")); return true; } bool CBlock::AcceptBlock() { AssertLockHeld(cs_main); // Check for duplicate uint256 hash = GetHash(); if (mapBlockIndex.count(hash)) return error("AcceptBlock() : block already in mapBlockIndex"); // Get prev block index map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashPrevBlock); if (mi == mapBlockIndex.end()) return DoS(10, error("AcceptBlock() : prev block not found")); CBlockIndex* pindexPrev = (*mi).second; int nHeight = pindexPrev->nHeight+1; // Check coinstake timestamp if (IsProofOfStake() && !CheckCoinStakeTimestamp(nHeight, GetBlockTime(), (int64_t)vtx[1].nTime)) return DoS(50, error("AcceptBlock() : coinstake timestamp violation nTimeBlock=%d nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); // Check proof-of-work or proof-of-stake if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); // Check timestamp against prev if (GetBlockTime() <= pindexPrev->GetPastTimeLimit() || FutureDrift(GetBlockTime()) < pindexPrev->GetBlockTime()) return error("AcceptBlock() : block's timestamp is too early"); // Check that all transactions are finalized BOOST_FOREACH(const CTransaction& tx, vtx) if (!IsFinalTx(tx, nHeight, GetBlockTime())) return DoS(10, error("AcceptBlock() : contains a non-final transaction")); // Check that the block chain matches the known block chain up to a checkpoint if (!Checkpoints::CheckHardened(nHeight, hash)) return DoS(100, error("AcceptBlock() : rejected by hardened checkpoint lock-in at %d", nHeight)); uint256 hashProof; // Verify hash target and signature of coinstake tx if (IsProofOfStake()) { uint256 targetProofOfStake; if (!CheckProofOfStake(pindexPrev, vtx[1], nBits, hashProof, targetProofOfStake)) { return error("AcceptBlock() : check proof-of-stake failed for block %s", hash.ToString()); } } // PoW is checked in CheckBlock() if (IsProofOfWork()) { hashProof = GetPoWHash(); } // Check that the block satisfies synchronized checkpoint if (!Checkpoints::CheckSync(nHeight)) return error("AcceptBlock() : rejected by synchronized checkpoint"); // Enforce rule that the coinbase starts with serialized block height CScript expect = CScript() << nHeight; if (vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin())) return DoS(100, error("AcceptBlock() : block height mismatch in coinbase")); // Write block to history file if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION))) return error("AcceptBlock() : out of disk space"); unsigned int nFile = -1; unsigned int nBlockPos = 0; if (!WriteToDisk(nFile, nBlockPos)) return error("AcceptBlock() : WriteToDisk failed"); if (!AddToBlockIndex(nFile, nBlockPos, hashProof)) return error("AcceptBlock() : AddToBlockIndex failed"); // Relay inventory, but don't relay old inventory during initial block download int nBlockEstimate = Checkpoints::GetTotalBlocksEstimate(); if (hashBestChain == hash) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); } return true; } uint256 CBlockIndex::GetBlockTrust() const { CBigNum bnTarget; bnTarget.SetCompact(nBits); if (bnTarget <= 0) return 0; return ((CBigNum(1)<<256) / (bnTarget+1)).getuint256(); } bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired, unsigned int nToCheck) { unsigned int nFound = 0; for (unsigned int i = 0; i < nToCheck && nFound < nRequired && pstart != NULL; i++) { if (pstart->nVersion >= minVersion) ++nFound; pstart = pstart->pprev; } return (nFound >= nRequired); } void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd) { // Filter out duplicate requests if (pindexBegin == pnode->pindexLastGetBlocksBegin && hashEnd == pnode->hashLastGetBlocksEnd) return; pnode->pindexLastGetBlocksBegin = pindexBegin; pnode->hashLastGetBlocksEnd = hashEnd; pnode->PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd); } bool static IsCanonicalBlockSignature(CBlock* pblock, bool checkLowS) { if (pblock->IsProofOfWork()) { return pblock->vchBlockSig.empty(); } return checkLowS ? IsLowDERSignature(pblock->vchBlockSig, false) : IsDERSignature(pblock->vchBlockSig, false); } bool ProcessBlock(CNode* pfrom, CBlock* pblock) { AssertLockHeld(cs_main); // Check for duplicate uint256 hash = pblock->GetHash(); if (mapBlockIndex.count(hash)) return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString()); if (mapOrphanBlocks.count(hash)) return error("ProcessBlock() : already have block (orphan) %s", hash.ToString()); // ppcoin: check proof-of-stake // Limited duplicity on stake: prevents block flood attack // Duplicate stake allowed only when there is orphan child block if (!fReindex && !fImporting && pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString()); if (pblock->hashPrevBlock != hashBestChain) { // Extra checks to prevent "fill up memory by spamming with bogus blocks" const CBlockIndex* pcheckpoint = Checkpoints::AutoSelectSyncCheckpoint(); int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; if (deltaTime < 0) { if (pfrom) pfrom->Misbehaving(1); return error("ProcessBlock() : block with timestamp before last checkpoint"); } } if (!IsCanonicalBlockSignature(pblock, false)) { if (pfrom && pfrom->nVersion >= CANONICAL_BLOCK_SIG_VERSION) { pfrom->Misbehaving(100); } return error("ProcessBlock(): bad block signature encoding"); } if (!IsCanonicalBlockSignature(pblock, true)) { if (pfrom && pfrom->nVersion >= CANONICAL_BLOCK_SIG_LOW_S_VERSION) { pfrom->Misbehaving(100); return error("ProcessBlock(): bad block signature encoding (low-s)"); } if (!EnsureLowS(pblock->vchBlockSig)) return error("ProcessBlock(): EnsureLowS failed"); } // Preliminary checks if (!pblock->CheckBlock()) return error("ProcessBlock() : CheckBlock FAILED"); // If we don't already have its previous block, shunt it off to holding area until we get it if (!mapBlockIndex.count(pblock->hashPrevBlock)) { LogPrintf("ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n", (unsigned long)mapOrphanBlocks.size(), pblock->hashPrevBlock.ToString()); // Accept orphans as long as there is a node to request its parents from if (pfrom) { // ppcoin: check proof-of-stake if (pblock->IsProofOfStake()) { // Limited duplicity on stake: prevents block flood attack // Duplicate stake allowed only when there is orphan child block if (setStakeSeenOrphan.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString()); } PruneOrphanBlocks(); COrphanBlock* pblock2 = new COrphanBlock(); { CDataStream ss(SER_DISK, CLIENT_VERSION); ss << *pblock; pblock2->vchBlock = std::vector<unsigned char>(ss.begin(), ss.end()); } pblock2->hashBlock = hash; pblock2->hashPrev = pblock->hashPrevBlock; pblock2->stake = pblock->GetProofOfStake(); nOrphanBlocksSize += pblock2->vchBlock.size(); mapOrphanBlocks.insert(make_pair(hash, pblock2)); mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrev, pblock2)); if (pblock->IsProofOfStake()) setStakeSeenOrphan.insert(pblock->GetProofOfStake()); // Ask this guy to fill in what we're missing PushGetBlocks(pfrom, pindexBest, GetOrphanRoot(hash)); // ppcoin: getblocks may not obtain the ancestor block rejected // earlier by duplicate-stake check so we ask for it again directly if (!IsInitialBlockDownload()) pfrom->AskFor(CInv(MSG_BLOCK, WantedByOrphan(pblock2))); } return true; } // Store to disk if (!pblock->AcceptBlock()) return error("ProcessBlock() : AcceptBlock FAILED"); // Recursively process any orphan blocks that depended on this one vector<uint256> vWorkQueue; vWorkQueue.push_back(hash); for (unsigned int i = 0; i < vWorkQueue.size(); i++) { uint256 hashPrev = vWorkQueue[i]; for (multimap<uint256, COrphanBlock*>::iterator mi = mapOrphanBlocksByPrev.lower_bound(hashPrev); mi != mapOrphanBlocksByPrev.upper_bound(hashPrev); ++mi) { CBlock block; { CDataStream ss(mi->second->vchBlock, SER_DISK, CLIENT_VERSION); ss >> block; } block.BuildMerkleTree(); if (block.AcceptBlock()) vWorkQueue.push_back(mi->second->hashBlock); mapOrphanBlocks.erase(mi->second->hashBlock); setStakeSeenOrphan.erase(block.GetProofOfStake()); nOrphanBlocksSize -= mi->second->vchBlock.size(); delete mi->second; } mapOrphanBlocksByPrev.erase(hashPrev); } LogPrintf("ProcessBlock: ACCEPTED\n"); return true; } #ifdef ENABLE_WALLET // novacoin: attempt to generate suitable proof-of-stake bool CBlock::SignBlock(CWallet& wallet, int64_t nFees) { // if we are trying to sign // something except proof-of-stake block template if (!vtx[0].vout[0].IsEmpty()) return false; // if we are trying to sign // a complete proof-of-stake block if (IsProofOfStake()) return true; static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp CKey key; CTransaction txCoinStake; txCoinStake.nTime &= ~STAKE_TIMESTAMP_MASK; int64_t nSearchTime = txCoinStake.nTime; // search to current time if (nSearchTime > nLastCoinStakeSearchTime) { int64_t nSearchInterval = 1; if (wallet.CreateCoinStake(wallet, nBits, nSearchInterval, nFees, txCoinStake, key)) { if (txCoinStake.nTime >= pindexBest->GetPastTimeLimit()+1) { // make sure coinstake would meet timestamp protocol // as it would be the same as the block timestamp vtx[0].nTime = nTime = txCoinStake.nTime; // we have to make sure that we have no future timestamps in // our transactions set for (vector<CTransaction>::iterator it = vtx.begin(); it != vtx.end();) if (it->nTime > nTime) { it = vtx.erase(it); } else { ++it; } vtx.insert(vtx.begin() + 1, txCoinStake); hashMerkleRoot = BuildMerkleTree(); // append a signature to our block return key.Sign(GetHash(), vchBlockSig); } } nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; nLastCoinStakeSearchTime = nSearchTime; } return false; } #endif bool CBlock::CheckBlockSignature() const { if (IsProofOfWork()) return vchBlockSig.empty(); if (vchBlockSig.empty()) return false; vector<valtype> vSolutions; txnouttype whichType; const CTxOut& txout = vtx[1].vout[1]; if (!Solver(txout.scriptPubKey, whichType, vSolutions)) return false; if (whichType == TX_PUBKEY) { valtype& vchPubKey = vSolutions[0]; return CPubKey(vchPubKey).Verify(GetHash(), vchBlockSig); } else { // Block signing key also can be encoded in the nonspendable output // This allows to not pollute UTXO set with useless outputs e.g. in case of multisig staking const CScript& script = txout.scriptPubKey; CScript::const_iterator pc = script.begin(); opcodetype opcode; valtype vchPushValue; if (!script.GetOp(pc, opcode, vchPushValue)) return false; if (opcode != OP_RETURN) return false; if (!script.GetOp(pc, opcode, vchPushValue)) return false; if (!IsCompressedOrUncompressedPubKey(vchPushValue)) return false; return CPubKey(vchPushValue).Verify(GetHash(), vchBlockSig); } return false; } bool CheckDiskSpace(uint64_t nAdditionalBytes) { uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available; // Check for nMinDiskSpace bytes (currently 50MB) if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) { string strMessage = _("Error: Disk space is low!"); strMiscWarning = strMessage; LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_ERROR); StartShutdown(); return false; } return true; } static filesystem::path BlockFilePath(unsigned int nFile) { string strBlockFn = strprintf("blk%04u.dat", nFile); return GetDataDir() / strBlockFn; } FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode) { if ((nFile < 1) || (nFile == (unsigned int) -1)) return NULL; FILE* file = fopen(BlockFilePath(nFile).string().c_str(), pszMode); if (!file) return NULL; if (nBlockPos != 0 && !strchr(pszMode, 'a') && !strchr(pszMode, 'w')) { if (fseek(file, nBlockPos, SEEK_SET) != 0) { fclose(file); return NULL; } } return file; } static unsigned int nCurrentBlockFile = 1; FILE* AppendBlockFile(unsigned int& nFileRet) { nFileRet = 0; while (true) { FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab"); if (!file) return NULL; if (fseek(file, 0, SEEK_END) != 0) return NULL; // FAT32 file size max 4GB, fseek and ftell max 2GB, so we must stay under 2GB if (ftell(file) < (long)(0x7F000000 - MAX_SIZE)) { nFileRet = nCurrentBlockFile; return file; } fclose(file); nCurrentBlockFile++; } } bool LoadBlockIndex(bool fAllowNew) { LOCK(cs_main); if (TestNet()) { nStakeMinConfirmations = 10; nCoinbaseMaturity = 10; // test maturity is 10 blocks } // // Load block index // CTxDB txdb("cr+"); if (!txdb.LoadBlockIndex()) return false; // // Init with genesis block // if (mapBlockIndex.empty()) { if (!fAllowNew) return false; CBlock &block = const_cast<CBlock&>(Params().GenesisBlock()); // Start new block file unsigned int nFile; unsigned int nBlockPos; if (!block.WriteToDisk(nFile, nBlockPos)) return error("LoadBlockIndex() : writing genesis block to disk failed"); if (!block.AddToBlockIndex(nFile, nBlockPos, Params().HashGenesisBlock())) return error("LoadBlockIndex() : genesis block not accepted"); } return true; } void PrintBlockTree() { AssertLockHeld(cs_main); // pre-compute tree structure map<CBlockIndex*, vector<CBlockIndex*> > mapNext; for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) { CBlockIndex* pindex = (*mi).second; mapNext[pindex->pprev].push_back(pindex); // test //while (rand() % 3 == 0) // mapNext[pindex->pprev].push_back(pindex); } vector<pair<int, CBlockIndex*> > vStack; vStack.push_back(make_pair(0, pindexGenesisBlock)); int nPrevCol = 0; while (!vStack.empty()) { int nCol = vStack.back().first; CBlockIndex* pindex = vStack.back().second; vStack.pop_back(); // print split or gap if (nCol > nPrevCol) { for (int i = 0; i < nCol-1; i++) LogPrintf("| "); LogPrintf("|\\\n"); } else if (nCol < nPrevCol) { for (int i = 0; i < nCol; i++) LogPrintf("| "); LogPrintf("|\n"); } nPrevCol = nCol; // print columns for (int i = 0; i < nCol; i++) LogPrintf("| "); // print item CBlock block; block.ReadFromDisk(pindex); LogPrintf("%d (%u,%u) %s %08x %s mint %7s tx %u", pindex->nHeight, pindex->nFile, pindex->nBlockPos, block.GetHash().ToString(), block.nBits, DateTimeStrFormat("%x %H:%M:%S", block.GetBlockTime()), FormatMoney(pindex->nMint), block.vtx.size()); // put the main time-chain first vector<CBlockIndex*>& vNext = mapNext[pindex]; for (unsigned int i = 0; i < vNext.size(); i++) { if (vNext[i]->pnext) { swap(vNext[0], vNext[i]); break; } } // iterate children for (unsigned int i = 0; i < vNext.size(); i++) vStack.push_back(make_pair(nCol+i, vNext[i])); } } bool LoadExternalBlockFile(FILE* fileIn) { int64_t nStart = GetTimeMillis(); int nLoaded = 0; { try { CAutoFile blkdat(fileIn, SER_DISK, CLIENT_VERSION); unsigned int nPos = 0; while (nPos != (unsigned int)-1 && blkdat.good()) { boost::this_thread::interruption_point(); unsigned char pchData[65536]; do { fseek(blkdat, nPos, SEEK_SET); int nRead = fread(pchData, 1, sizeof(pchData), blkdat); if (nRead <= 8) { nPos = (unsigned int)-1; break; } void* nFind = memchr(pchData, Params().MessageStart()[0], nRead+1-MESSAGE_START_SIZE); if (nFind) { if (memcmp(nFind, Params().MessageStart(), MESSAGE_START_SIZE)==0) { nPos += ((unsigned char*)nFind - pchData) + MESSAGE_START_SIZE; break; } nPos += ((unsigned char*)nFind - pchData) + 1; } else nPos += sizeof(pchData) - MESSAGE_START_SIZE + 1; boost::this_thread::interruption_point(); } while(true); if (nPos == (unsigned int)-1) break; fseek(blkdat, nPos, SEEK_SET); unsigned int nSize; blkdat >> nSize; if (nSize > 0 && nSize <= MAX_BLOCK_SIZE) { CBlock block; blkdat >> block; LOCK(cs_main); if (ProcessBlock(NULL,&block)) { nLoaded++; nPos += 4 + nSize; } } } } catch (std::exception &e) { LogPrintf("%s() : Deserialize or I/O error caught during load\n", __PRETTY_FUNCTION__); } } LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, GetTimeMillis() - nStart); return nLoaded > 0; } struct CImportingNow { CImportingNow() { assert(fImporting == false); fImporting = true; } ~CImportingNow() { assert(fImporting == true); fImporting = false; } }; void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) { RenameThread("onecoin-loadblk"); CImportingNow imp; // -loadblock= BOOST_FOREACH(boost::filesystem::path &path, vImportFiles) { FILE *file = fopen(path.string().c_str(), "rb"); if (file) LoadExternalBlockFile(file); } // hardcoded $DATADIR/bootstrap.dat filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; if (filesystem::exists(pathBootstrap)) { FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); if (file) { filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; LoadExternalBlockFile(file); RenameOver(pathBootstrap, pathBootstrapOld); } } } ////////////////////////////////////////////////////////////////////////////// // // Messages // bool static AlreadyHave(CTxDB& txdb, const CInv& inv) { switch (inv.type) { case MSG_TX: { bool txInMap = false; txInMap = mempool.exists(inv.hash); return txInMap || mapOrphanTransactions.count(inv.hash) || txdb.ContainsTx(inv.hash); } case MSG_BLOCK: return mapBlockIndex.count(inv.hash) || mapOrphanBlocks.count(inv.hash); } // Don't know what it is, just say we already got one return true; } void static ProcessGetData(CNode* pfrom) { std::deque<CInv>::iterator it = pfrom->vRecvGetData.begin(); vector<CInv> vNotFound; LOCK(cs_main); while (it != pfrom->vRecvGetData.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; const CInv &inv = *it; { boost::this_thread::interruption_point(); it++; if (inv.type == MSG_BLOCK) { // Send block from disk map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(inv.hash); if (mi != mapBlockIndex.end()) { CBlock block; block.ReadFromDisk((*mi).second); // previous versions could accept sigs with high s if (!IsCanonicalBlockSignature(&block, true)) { bool ret = EnsureLowS(block.vchBlockSig); assert(ret); } pfrom->PushMessage("block", block); // Trigger them to send a getblocks request for the next batch of inventory if (inv.hash == pfrom->hashContinue) { // Bypass PushInventory, this must send even if redundant, // and we want it right after the last block so they don't // wait for other stuff first. vector<CInv> vInv; vInv.push_back(CInv(MSG_BLOCK, hashBestChain)); pfrom->PushMessage("inv", vInv); pfrom->hashContinue = 0; } } } else if (inv.IsKnownType()) { // Send stream from relay memory bool pushed = false; { LOCK(cs_mapRelay); map<CInv, CDataStream>::iterator mi = mapRelay.find(inv); if (mi != mapRelay.end()) { pfrom->PushMessage(inv.GetCommand(), (*mi).second); pushed = true; } } if (!pushed && inv.type == MSG_TX) { CTransaction tx; if (mempool.lookup(inv.hash, tx)) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(1000); ss << tx; pfrom->PushMessage("tx", ss); pushed = true; } } if (!pushed) { vNotFound.push_back(inv); } } // Track requests for our stuff. g_signals.Inventory(inv.hash); if (inv.type == MSG_BLOCK /* || inv.type == MSG_FILTERED_BLOCK */) break; } } pfrom->vRecvGetData.erase(pfrom->vRecvGetData.begin(), it); if (!vNotFound.empty()) { // Let the peer know that we didn't find what it asked for, so it doesn't // have to wait around forever. Currently only SPV clients actually care // about this message: it's needed when they are recursively walking the // dependencies of relevant unconfirmed transactions. SPV clients want to // do that because they want to know about (and store and rebroadcast and // risk analyze) the dependencies of transactions relevant to them, without // having to download the entire memory pool. pfrom->PushMessage("notfound", vNotFound); } } bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived) { RandAddSeedPerfmon(); LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size()); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } if (strCommand == "version") { // Each connection can only send one version message if (pfrom->nVersion != 0) { pfrom->Misbehaving(1); return false; } int64_t nTime; CAddress addrMe; CAddress addrFrom; uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) { // disconnect from peers older than this proto version LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString(), pfrom->nVersion); pfrom->fDisconnect = true; return false; } if (pfrom->nVersion == 10300) pfrom->nVersion = 300; if (!vRecv.empty()) vRecv >> addrFrom >> nNonce; if (!vRecv.empty()) vRecv >> pfrom->strSubVer; if (!vRecv.empty()) vRecv >> pfrom->nStartingHeight; // Disconnect if we connected to ourself if (nNonce == nLocalHostNonce && nNonce > 1) { LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString()); pfrom->fDisconnect = true; return true; } pfrom->addrLocal = addrMe; if (pfrom->fInbound && addrMe.IsRoutable()) { SeenLocal(addrMe); } // Be shy and don't send version until we hear if (pfrom->fInbound) pfrom->PushVersion(); pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); // Change version pfrom->PushMessage("verack"); pfrom->ssSend.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); if (!pfrom->fInbound) { // Advertise our address if (!fNoListen && !IsInitialBlockDownload()) { CAddress addr = GetLocalAddress(&pfrom->addr); if (addr.IsRoutable()) { pfrom->PushAddress(addr); } else if (IsPeerAddrLocalGood(pfrom)) { addr.SetIP(pfrom->addrLocal); pfrom->PushAddress(addr); } } // Get recent addresses if (pfrom->fOneShot || pfrom->nVersion >= CADDR_TIME_VERSION || addrman.size() < 1000) { pfrom->PushMessage("getaddr"); pfrom->fGetAddr = true; } addrman.Good(pfrom->addr); } else { if (((CNetAddr)pfrom->addr) == (CNetAddr)addrFrom) { addrman.Add(addrFrom, addrFrom); addrman.Good(addrFrom); } } pfrom->fSuccessfullyConnected = true; LogPrintf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), addrFrom.ToString(), pfrom->addr.ToString()); int64_t nTimeOffset = nTime - GetTime(); pfrom->nTimeOffset = nTimeOffset; if (GetBoolArg("-synctime", true)) AddTimeData(pfrom->addr, nTimeOffset); } else if (pfrom->nVersion == 0) { // Must have a version message before anything else pfrom->Misbehaving(1); return false; } else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); } else if (strCommand == "addr") { vector<CAddress> vAddr; vRecv >> vAddr; // Don't want addr from older versions unless seeding if (pfrom->nVersion < CADDR_TIME_VERSION && addrman.size() > 1000) return true; if (vAddr.size() > 1000) { pfrom->Misbehaving(20); return error("message addr size() = %u", vAddr.size()); } // Store the new addresses vector<CAddress> vAddrOk; int64_t nNow = GetAdjustedTime(); int64_t nSince = nNow - 10 * 60; BOOST_FOREACH(CAddress& addr, vAddr) { boost::this_thread::interruption_point(); if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60) addr.nTime = nNow - 5 * 24 * 60 * 60; pfrom->AddAddressKnown(addr); bool fReachable = IsReachable(addr); if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size() <= 10 && addr.IsRoutable()) { // Relay to a limited number of other nodes { LOCK(cs_vNodes); // Use deterministic randomness to send to the same nodes for 24 hours // at a time so the setAddrKnowns of the chosen nodes prevent repeats static uint256 hashSalt; if (hashSalt == 0) hashSalt = GetRandHash(); uint64_t hashAddr = addr.GetHash(); uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60)); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap<uint256, CNode*> mapMix; BOOST_FOREACH(CNode* pnode, vNodes) { if (pnode->nVersion < CADDR_TIME_VERSION) continue; unsigned int nPointer; memcpy(&nPointer, &pnode, sizeof(nPointer)); uint256 hashKey = hashRand ^ nPointer; hashKey = Hash(BEGIN(hashKey), END(hashKey)); mapMix.insert(make_pair(hashKey, pnode)); } int nRelayNodes = fReachable ? 2 : 1; // limited relaying of addresses outside our network(s) for (multimap<uint256, CNode*>::iterator mi = mapMix.begin(); mi != mapMix.end() && nRelayNodes-- > 0; ++mi) ((*mi).second)->PushAddress(addr); } } // Do not store addresses outside our network if (fReachable) vAddrOk.push_back(addr); } addrman.Add(vAddrOk, pfrom->addr, 2 * 60 * 60); if (vAddr.size() < 1000) pfrom->fGetAddr = false; if (pfrom->fOneShot) pfrom->fDisconnect = true; } else if (strCommand == "inv") { vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); return error("message inv size() = %u", vInv.size()); } // find last block in inv vector unsigned int nLastBlock = (unsigned int)(-1); for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK) { nLastBlock = vInv.size() - 1 - nInv; break; } } LOCK(cs_main); CTxDB txdb("r"); for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { const CInv &inv = vInv[nInv]; boost::this_thread::interruption_point(); pfrom->AddInventoryKnown(inv); bool fAlreadyHave = AlreadyHave(txdb, inv); LogPrint("net", " got inventory: %s %s\n", inv.ToString(), fAlreadyHave ? "have" : "new"); if (!fAlreadyHave) { if (!fImporting) pfrom->AskFor(inv); } else if (inv.type == MSG_BLOCK && mapOrphanBlocks.count(inv.hash)) { PushGetBlocks(pfrom, pindexBest, GetOrphanRoot(inv.hash)); } else if (nInv == nLastBlock) { // In case we are on a very long side-chain, it is possible that we already have // the last block in an inv bundle sent in response to getblocks. Try to detect // this situation and push another getblocks to continue. PushGetBlocks(pfrom, mapBlockIndex[inv.hash], uint256(0)); if (fDebug) LogPrintf("force request: %s\n", inv.ToString()); } // Track requests for our stuff g_signals.Inventory(inv.hash); } } else if (strCommand == "getdata") { vector<CInv> vInv; vRecv >> vInv; if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); return error("message getdata size() = %u", vInv.size()); } if (fDebug || (vInv.size() != 1)) LogPrint("net", "received getdata (%u invsz)\n", vInv.size()); if ((fDebug && vInv.size() > 0) || (vInv.size() == 1)) LogPrint("net", "received getdata for: %s\n", vInv[0].ToString()); pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end()); ProcessGetData(pfrom); } else if (strCommand == "getblocks") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; LOCK(cs_main); // Find the last block the caller has in the main chain CBlockIndex* pindex = locator.GetBlockIndex(); // Send the rest of the chain if (pindex) pindex = pindex->pnext; int nLimit = 500; LogPrint("net", "getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), nLimit); for (; pindex; pindex = pindex->pnext) { if (pindex->GetBlockHash() == hashStop) { LogPrint("net", " getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); if (--nLimit <= 0) { // When this block is requested, we'll send an inv that'll make them // getblocks the next batch of inventory. LogPrint("net", " getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString()); pfrom->hashContinue = pindex->GetBlockHash(); break; } } } else if (strCommand == "getheaders") { CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; LOCK(cs_main); CBlockIndex* pindex = NULL; if (locator.IsNull()) { // If locator is null, return the hashStop block map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashStop); if (mi == mapBlockIndex.end()) return true; pindex = (*mi).second; } else { // Find the last block the caller has in the main chain pindex = locator.GetBlockIndex(); if (pindex) pindex = pindex->pnext; } vector<CBlock> vHeaders; int nLimit = 2000; LogPrint("net", "getheaders %d to %s\n", (pindex ? pindex->nHeight : -1), hashStop.ToString()); for (; pindex; pindex = pindex->pnext) { vHeaders.push_back(pindex->GetBlockHeader()); if (--nLimit <= 0 || pindex->GetBlockHash() == hashStop) break; } pfrom->PushMessage("headers", vHeaders); } else if (strCommand == "tx") { vector<uint256> vWorkQueue; vector<uint256> vEraseQueue; CTransaction tx; vRecv >> tx; CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); LOCK(cs_main); bool fMissingInputs = false; mapAlreadyAskedFor.erase(inv); if (AcceptToMemoryPool(mempool, tx, true, &fMissingInputs)) { RelayTransaction(tx, inv.hash); vWorkQueue.push_back(inv.hash); vEraseQueue.push_back(inv.hash); // Recursively process any orphan transactions that depended on this one for (unsigned int i = 0; i < vWorkQueue.size(); i++) { map<uint256, set<uint256> >::iterator itByPrev = mapOrphanTransactionsByPrev.find(vWorkQueue[i]); if (itByPrev == mapOrphanTransactionsByPrev.end()) continue; for (set<uint256>::iterator mi = itByPrev->second.begin(); mi != itByPrev->second.end(); ++mi) { const uint256& orphanTxHash = *mi; CTransaction& orphanTx = mapOrphanTransactions[orphanTxHash]; bool fMissingInputs2 = false; if (AcceptToMemoryPool(mempool, orphanTx, true, &fMissingInputs2)) { LogPrint("mempool", " accepted orphan tx %s\n", orphanTxHash.ToString()); RelayTransaction(orphanTx, orphanTxHash); vWorkQueue.push_back(orphanTxHash); vEraseQueue.push_back(orphanTxHash); } else if (!fMissingInputs2) { // invalid or too-little-fee orphan vEraseQueue.push_back(orphanTxHash); LogPrint("mempool", " removed orphan tx %s\n", orphanTxHash.ToString()); } } } BOOST_FOREACH(uint256 hash, vEraseQueue) EraseOrphanTx(hash); } else if (fMissingInputs) { AddOrphanTx(tx); // DoS prevention: do not allow mapOrphanTransactions to grow unbounded unsigned int nEvicted = LimitOrphanTxSize(MAX_ORPHAN_TRANSACTIONS); if (nEvicted > 0) LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted); } if (tx.nDoS) pfrom->Misbehaving(tx.nDoS); } else if (strCommand == "block" && !fImporting && !fReindex) // Ignore blocks received while importing { CBlock block; vRecv >> block; uint256 hashBlock = block.GetHash(); LogPrint("net", "received block %s\n", hashBlock.ToString()); CInv inv(MSG_BLOCK, hashBlock); pfrom->AddInventoryKnown(inv); LOCK(cs_main); if (ProcessBlock(pfrom, &block)) mapAlreadyAskedFor.erase(inv); if (block.nDoS) pfrom->Misbehaving(block.nDoS); } // This asymmetric behavior for inbound and outbound connections was introduced // to prevent a fingerprinting attack: an attacker can send specific fake addresses // to users' AddrMan and later request them by sending getaddr messages. // Making users (which are behind NAT and can only make outgoing connections) ignore // getaddr message mitigates the attack. else if ((strCommand == "getaddr") && (pfrom->fInbound)) { // Don't return addresses older than nCutOff timestamp int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60); pfrom->vAddrToSend.clear(); vector<CAddress> vAddr = addrman.GetAddr(); BOOST_FOREACH(const CAddress &addr, vAddr) if(addr.nTime > nCutOff) pfrom->PushAddress(addr); } else if (strCommand == "mempool") { LOCK(cs_main); std::vector<uint256> vtxid; mempool.queryHashes(vtxid); vector<CInv> vInv; for (unsigned int i = 0; i < vtxid.size(); i++) { CInv inv(MSG_TX, vtxid[i]); vInv.push_back(inv); if (i == (MAX_INV_SZ - 1)) break; } if (vInv.size() > 0) pfrom->PushMessage("inv", vInv); } else if (strCommand == "ping") { if (pfrom->nVersion > BIP0031_VERSION) { uint64_t nonce = 0; vRecv >> nonce; // Echo the message back with the nonce. This allows for two useful features: // // 1) A remote node can quickly check if the connection is operational // 2) Remote nodes can measure the latency of the network thread. If this node // is overloaded it won't respond to pings quickly and the remote node can // avoid sending us more work, like chain download requests. // // The nonce stops the remote getting confused between different pings: without // it, if the remote node sends a ping once per second and this node takes 5 // seconds to respond to each, the 5th ping the remote sends would appear to // return very quickly. pfrom->PushMessage("pong", nonce); } } else if (strCommand == "pong") { int64_t pingUsecEnd = nTimeReceived; uint64_t nonce = 0; size_t nAvail = vRecv.in_avail(); bool bPingFinished = false; std::string sProblem; if (nAvail >= sizeof(nonce)) { vRecv >> nonce; // Only process pong message if there is an outstanding ping (old ping without nonce should never pong) if (pfrom->nPingNonceSent != 0) { if (nonce == pfrom->nPingNonceSent) { // Matching pong received, this ping is no longer outstanding bPingFinished = true; int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart; if (pingUsecTime > 0) { // Successful ping time measurement, replace previous pfrom->nPingUsecTime = pingUsecTime; } else { // This should never happen sProblem = "Timing mishap"; } } else { // Nonce mismatches are normal when pings are overlapping sProblem = "Nonce mismatch"; if (nonce == 0) { // This is most likely a bug in another implementation somewhere, cancel this ping bPingFinished = true; sProblem = "Nonce zero"; } } } else { sProblem = "Unsolicited pong without ping"; } } else { // This is most likely a bug in another implementation somewhere, cancel this ping bPingFinished = true; sProblem = "Short payload"; } if (!(sProblem.empty())) { LogPrint("net", "pong %s %s: %s, %x expected, %x received, %zu bytes\n" , pfrom->addr.ToString() , pfrom->strSubVer , sProblem , pfrom->nPingNonceSent , nonce , nAvail); } if (bPingFinished) { pfrom->nPingNonceSent = 0; } } else { // Ignore unknown commands for extensibility } // Update the last seen time for this node's address if (pfrom->fNetworkNode) if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping") AddressCurrentlyConnected(pfrom->addr); return true; } // requires LOCK(cs_vRecvMsg) bool ProcessMessages(CNode* pfrom) { //if (fDebug) // LogPrintf("ProcessMessages(%zu messages)\n", pfrom->vRecvMsg.size()); // // Message format // (4) message start // (12) command // (4) size // (4) checksum // (x) data // bool fOk = true; if (!pfrom->vRecvGetData.empty()) ProcessGetData(pfrom); // this maintains the order of responses if (!pfrom->vRecvGetData.empty()) return fOk; std::deque<CNetMessage>::iterator it = pfrom->vRecvMsg.begin(); while (!pfrom->fDisconnect && it != pfrom->vRecvMsg.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) break; // get next message CNetMessage& msg = *it; //if (fDebug) // LogPrintf("ProcessMessages(message %u msgsz, %zu bytes, complete:%s)\n", // msg.hdr.nMessageSize, msg.vRecv.size(), // msg.complete() ? "Y" : "N"); // end, if an incomplete message is found if (!msg.complete()) break; // at this point, any failure means we can delete the current message it++; // Scan for message start if (memcmp(msg.hdr.pchMessageStart, Params().MessageStart(), MESSAGE_START_SIZE) != 0) { LogPrintf("\n\nPROCESSMESSAGE: INVALID MESSAGESTART\n\n"); fOk = false; break; } // Read header CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid()) { LogPrintf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand()); continue; } string strCommand = hdr.GetCommand(); // Message size unsigned int nMessageSize = hdr.nMessageSize; // Checksum CDataStream& vRecv = msg.vRecv; uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); unsigned int nChecksum = 0; memcpy(&nChecksum, &hash, sizeof(nChecksum)); if (nChecksum != hdr.nChecksum) { LogPrintf("ProcessMessages(%s, %u bytes) : CHECKSUM ERROR nChecksum=%08x hdr.nChecksum=%08x\n", strCommand, nMessageSize, nChecksum, hdr.nChecksum); continue; } // Process message bool fRet = false; try { fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime); boost::this_thread::interruption_point(); } catch (std::ios_base::failure& e) { if (strstr(e.what(), "end of data")) { // Allow exceptions from under-length message on vRecv LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught, normally caused by a message being shorter than its stated length\n", strCommand, nMessageSize, e.what()); } else if (strstr(e.what(), "size too large")) { // Allow exceptions from over-long size LogPrintf("ProcessMessages(%s, %u bytes) : Exception '%s' caught\n", strCommand, nMessageSize, e.what()); } else { PrintExceptionContinue(&e, "ProcessMessages()"); } } catch (boost::thread_interrupted) { throw; } catch (std::exception& e) { PrintExceptionContinue(&e, "ProcessMessages()"); } catch (...) { PrintExceptionContinue(NULL, "ProcessMessages()"); } if (!fRet) LogPrintf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand, nMessageSize); break; } // In case the connection got shut down, its receive buffer was wiped if (!pfrom->fDisconnect) pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); return fOk; } bool SendMessages(CNode* pto, bool fSendTrickle) { TRY_LOCK(cs_main, lockMain); if (lockMain) { // Don't send anything until we get their version message if (pto->nVersion == 0) return true; // // Message: ping // bool pingSend = false; if (pto->fPingQueued) { // RPC ping request by user pingSend = true; } if (pto->nPingNonceSent == 0 && pto->nPingUsecStart + PING_INTERVAL * 1000000 < GetTimeMicros()) { // Ping automatically sent as a latency probe & keepalive. pingSend = true; } if (pingSend) { uint64_t nonce = 0; while (nonce == 0) { RAND_bytes((unsigned char*)&nonce, sizeof(nonce)); } pto->fPingQueued = false; pto->nPingUsecStart = GetTimeMicros(); if (pto->nVersion > BIP0031_VERSION) { pto->nPingNonceSent = nonce; pto->PushMessage("ping", nonce); } else { // Peer is too old to support ping command with nonce, pong will never arrive. pto->nPingNonceSent = 0; pto->PushMessage("ping"); } } // Start block sync if (pto->fStartSync && !fImporting && !fReindex) { pto->fStartSync = false; PushGetBlocks(pto, pindexBest, uint256(0)); } // Resend wallet transactions that haven't gotten in a block yet // Except during reindex, importing and IBD, when old wallet // transactions become unconfirmed and spams other nodes. if (!fReindex && !fImporting && !IsInitialBlockDownload()) { ResendWalletTransactions(); } // Address refresh broadcast static int64_t nLastRebroadcast; if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) { LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { // Periodically clear setAddrKnown to allow refresh broadcasts if (nLastRebroadcast) pnode->setAddrKnown.clear(); // Rebroadcast our address AdvertizeLocal(pnode); } if (!vNodes.empty()) nLastRebroadcast = GetTime(); } // // Message: addr // if (fSendTrickle) { vector<CAddress> vAddr; vAddr.reserve(pto->vAddrToSend.size()); BOOST_FOREACH(const CAddress& addr, pto->vAddrToSend) { // returns true if wasn't already contained in the set if (pto->setAddrKnown.insert(addr).second) { vAddr.push_back(addr); // receiver rejects addr messages larger than 1000 if (vAddr.size() >= 1000) { pto->PushMessage("addr", vAddr); vAddr.clear(); } } } pto->vAddrToSend.clear(); if (!vAddr.empty()) pto->PushMessage("addr", vAddr); } // // Message: inventory // vector<CInv> vInv; vector<CInv> vInvWait; { LOCK(pto->cs_inventory); vInv.reserve(pto->vInventoryToSend.size()); vInvWait.reserve(pto->vInventoryToSend.size()); BOOST_FOREACH(const CInv& inv, pto->vInventoryToSend) { if (pto->setInventoryKnown.count(inv)) continue; // trickle out tx inv to protect privacy if (inv.type == MSG_TX && !fSendTrickle) { // 1/4 of tx invs blast to all immediately static uint256 hashSalt; if (hashSalt == 0) hashSalt = GetRandHash(); uint256 hashRand = inv.hash ^ hashSalt; hashRand = Hash(BEGIN(hashRand), END(hashRand)); bool fTrickleWait = ((hashRand & 3) != 0); if (fTrickleWait) { vInvWait.push_back(inv); continue; } } // returns true if wasn't already contained in the set if (pto->setInventoryKnown.insert(inv).second) { vInv.push_back(inv); if (vInv.size() >= 1000) { pto->PushMessage("inv", vInv); vInv.clear(); } } } pto->vInventoryToSend = vInvWait; } if (!vInv.empty()) pto->PushMessage("inv", vInv); // // Message: getdata // vector<CInv> vGetData; int64_t nNow = GetTime() * 1000000; CTxDB txdb("r"); while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) { const CInv& inv = (*pto->mapAskFor.begin()).second; if (!AlreadyHave(txdb, inv)) { if (fDebug) LogPrint("net", "sending getdata: %s\n", inv.ToString()); vGetData.push_back(inv); if (vGetData.size() >= 1000) { pto->PushMessage("getdata", vGetData); vGetData.clear(); } mapAlreadyAskedFor[inv] = nNow; } pto->mapAskFor.erase(pto->mapAskFor.begin()); } if (!vGetData.empty()) pto->PushMessage("getdata", vGetData); } return true; }
[ "amnesia@localhost.localdomain" ]
amnesia@localhost.localdomain
77cd576d2cff906336363081e0b8a138da812377
ec3adbf819a46d516ac03aee9e70db809221a263
/CS576 Final Project/CS576_Final_Images/576proj/faceDetect.cpp
34f1e483325a2ddeaeff26be1120921f54cb47f8
[]
no_license
max79137913/Analyze-video-and-image-similarity-
fb8cd971260f58d98d6b1febb08d2e11985133d1
6fb5f6610e184522845c874025c267966cdd874c
refs/heads/master
2016-09-03T07:06:08.186999
2015-04-06T19:45:47
2015-04-06T19:45:47
33,501,743
0
0
null
null
null
null
GB18030
C++
false
false
3,054
cpp
#include"cluster.h" bool cluster::facedetect(IplImage src) { bool success=0; // 加载Haar特征检测分类器 // haarcascade_frontalface_alt.xml系OpenCV自带的分类器 下面是我机器上的文件路径 const char *pstrCascadeFileName = "haarcascade_frontalface_alt2.xml"; CvHaarClassifierCascade *pHaarCascade = NULL; pHaarCascade = (CvHaarClassifierCascade*)cvLoad(pstrCascadeFileName); // 载入图像 IplImage SrcImage = src; IplImage *pSrcImage = &SrcImage; IplImage *pGrayImage = cvCreateImage(cvGetSize(pSrcImage), IPL_DEPTH_8U, 1); cvCvtColor(pSrcImage, pGrayImage, CV_BGR2GRAY); // 人脸识别与标记 if (pHaarCascade != NULL) { CvScalar FaceCirclecolors[] = { {{0, 0, 255}}, {{0, 128, 255}}, {{0, 255, 255}}, {{0, 255, 0}}, {{255, 128, 0}}, {{255, 255, 0}}, {{255, 0, 0}}, {{255, 0, 255}} }; CvMemStorage *pcvMStorage = cvCreateMemStorage(0); cvClearMemStorage(pcvMStorage); // 识别 DWORD dwTimeBegin, dwTimeEnd; dwTimeBegin = GetTickCount(); CvSeq *pcvSeqFaces = cvHaarDetectObjects(pGrayImage, pHaarCascade, pcvMStorage); //important dwTimeEnd = GetTickCount(); printf("face numbers: %d take times: %d ms\n", pcvSeqFaces->total, dwTimeEnd - dwTimeBegin); if(pcvSeqFaces->total>0) { success=1; } // 标记 for(int i = 0; i <pcvSeqFaces->total; i++) { CvRect* r = (CvRect*)cvGetSeqElem(pcvSeqFaces, i); // (original) CvPoint center; int radius; center.x = cvRound((r->x + r->width * 0.5)); center.y = cvRound((r->y + r->height * 0.5)); radius = cvRound((r->width + r->height) * 0.25); cvCircle(pSrcImage, center, radius, FaceCirclecolors[i % 8], 2); } cvReleaseMemStorage(&pcvMStorage); } const char *pstrWindowsTitle = "face search"; cvDestroyWindow(pstrWindowsTitle); cvReleaseImage(&pGrayImage); return success; } void cluster::getFaces() { vector<Mat> src_img; uchar data[HEIGHT][WIDTH * 3]; //vector<Mat> characterM; //vector<int> character; // Gzrgb data; //Mat temp; int i; bool success; //vector<int> photo; /*for(i=0;i<300;i++){ photo.push_back(i); }*/ for(int i = startPicNum - 1; i <= endPicNum - 1; ++i) { readRGBFile(getImageFilePath(i), data); Mat img = Mat(HEIGHT, WIDTH, CV_8UC3, data); //namedWindow("calcHist Demo", CV_WINDOW_AUTOSIZE); //imshow("calcHist Demo", img); //waitKey(500); src_img.push_back(img.clone()); } for(i=startPicNum-1;i<=endPicNum-1;i++) { cout<<"detecting img "<<i + 1<<endl; success=facedetect(src_img[i]); if(success) { /*vector<int>::iterator it; it = find (photo.begin(), photo.end(), i); if (it != photo.end()){ photo.erase(it); character.push_back(i); }*/ facePic.push_back(i); } } for(int i = 0; i < facePic.size(); i++){ isClassified[facePic[i]] = true; } }
[ "max79137913@gmail.com" ]
max79137913@gmail.com
6fc991690302e66ddb5be645377e8053747c3287
b1cd1abb21d0f2d5fd9feea0ec7dd8378c0dfe32
/Strings/CharsArray.cpp
ba553868d5c464d3a1bdbb3744f30068ce4d37d1
[]
no_license
Noel1827/CppPracticaNavidades
1e946311da662b594c56dbe575c8b6d565dd7153
554da8daafdf9bffbb4b26954488973137020207
refs/heads/main
2023-02-28T06:41:33.625604
2021-02-03T04:13:49
2021-02-03T04:13:49
320,053,318
0
0
null
null
null
null
UTF-8
C++
false
false
187
cpp
#include <iostream> using namespace std; int main(){ string s1 = "Hello"; char ch[] = {'C','+','+'}; string s2 = string(ch); cout << s1 << endl; cout << s2 << endl; }
[ "noel.vargas5@upr.edu" ]
noel.vargas5@upr.edu
fc62baef2c89a66328a8bc5b3567ade5cc684a84
11b9965933d407ed3708a252aebcdafc21c98664
/FEM/include/refel.h
33dfba0cc0667353effded3c3189aaab4b572abe
[ "BSD-3-Clause" ]
permissive
lanl/Dendro-GRCA
a265131e2a5d8327eba49e2133257d553826a41e
8a475b1abd8832c3dfc19d00cc0ec4b9e2789c8a
refs/heads/master
2023-05-31T06:25:06.113867
2020-09-23T18:00:13
2020-09-23T18:00:13
297,793,620
1
1
null
null
null
null
UTF-8
C++
false
false
23,737
h
// // Created by milinda on 12/25/16. // /** * @author Milinda Fernando * @author Hari Sundar * @breif Contains data structures to store the reference element information. * * @refference: Based of HOMG code written in matlab. * */ #ifndef SFCSORTBENCH_REFERENCEELEMENT_H #define SFCSORTBENCH_REFERENCEELEMENT_H #ifdef WITH_BLAS_LAPACK #include "basis.h" #endif #include "tensor.h" #include <fstream> #include <iostream> #include <vector> #include <iomanip> #include <math.h> #include <cstring> #include <assert.h> #include "interpMatrices.h" #include "binUtils.h" template<typename T> void dump_binary(const T* in, unsigned int n, const char* fPrefix) { char fName[256]; sprintf(fName,"%s.bin",fPrefix); std::ofstream ofile(fName,std::ios::binary); ofile.write((char*)&n, sizeof(int)); ofile.write((char*)&in[0], sizeof(T)*n); ofile.close(); return ; } template <typename T> void printArray_1D(const T *a, int length) { for (int i = 0; i < length; i++) { std::cout<<a[i]<<" "; } std::cout<<std::endl; } template <typename T> void printArray_2D(const T *a, int length1,int length2) { for (int i = 0; i < length1; i++) { for (int j = 0; j < length2; j++) { std::cout << a[i * length2 + j] << " "; } std::cout<<std::endl; } std::cout<<std::endl; } class RefElement{ private : /** Dimension */ int m_uiDimension; /** Polynomial Order */ int m_uiOrder; /** Number of 3D interpolation points on the element */ int m_uiNp; /** Number of 2D face interpolation points */ int m_uiNfp; /** Number of 1D interpolation points */ int m_uiNrp; /** reference element volume */ unsigned int m_uiVol; /** 1D reference coordinates of the interpolation nodes (uniform nodal points) */ std::vector<double> u; /** 1D reference coordinates of the interpolation nodes (gll points)*/ std::vector<double> r; /** 1D regular points corresponding to child 0 of u*/ std::vector<double> u_0; /** 1D regular points corresponding to child 1 of u*/ std::vector<double> u_1; /** 1D Gauss points (used for quadrature)*/ std::vector<double> g; /** 1D weights for gauss quadrature */ std::vector<double> w; /** 1D weights for gll quadrature*/ std::vector<double> wgll; /** 1D interpolation matrix for child 0 */ std::vector<double> ip_1D_0; /** 1D interpolation matrix for child 1*/ std::vector<double> ip_1D_1; /** 1D interpolation matrix for child 0 (transpose) */ std::vector<double> ipT_1D_0; /** 1D interpolation matrix for child 1 (transpose)*/ std::vector<double> ipT_1D_1; /**Vandermonde matrix for interpolation points r. */ std::vector<double> Vr; /**Vandermonde matrix for interpolation points u. */ std::vector<double> Vu; /**Vandermonde matrix for polynomial at gauss points */ std::vector<double> Vg; /**gradient of the vandermonde for polynomial eval at points u*/ std::vector<double> gradVu; /**gradient of the vandermonde for polynomial eval at points r*/ std::vector<double> gradVr; /**gradient of the vandermonde for polynomial eval at points g*/ std::vector<double> gradVg; /**derivative of the pol. eval at points r. */ std::vector<double> Dr; /** derivative of the pol. eval at the gauss points. */ std::vector<double> Dg; /** derivative of the pol. eval at the gauss points. (transpose) */ std::vector<double> DgT; /** 1D quadrature matrix*/ std::vector<double> quad_1D; /** 1D quadrature matrix transpose*/ std::vector<double> quadT_1D; /**Vandermonde matrix for interpolation points of child 0 */ std::vector<double> Vu_0; /**Vandermonde matrix for interpolation points of child 1 */ std::vector<double> Vu_1; /**intermidiate vec 1 needed during interploation */ std::vector<double> im_vec1; /**intermidiate vec 1 needed during interploation */ std::vector<double> im_vec2; /**filter matrix for to cutoff high frequency terms. */ std::vector<double> Fr; /**@brief unzip intergrid transwer*/ std::vector<double> gridT; /**@brief unzip intergrid transwer out*/ std::vector<double> out_p2c; public: /**@brief: default constructor for the reference element*/ RefElement(); /**@brief: constructs a reference element * @param dim: dimension of the reference element. * @param order: element order */ RefElement(unsigned int dim, unsigned int order); /**@brief: distructor for the reference element. */ ~RefElement(); /**@brief: Get reference element order*/ inline int getOrder() const {return m_uiOrder;} /**@brief: get reference element dimension*/ inline int getDim() const {return m_uiDimension;} /**@brief: size of the interpolation points 1D*/ inline int get1DNumInterpolationPoints(){return m_uiNrp;} /**@brief: parent to child 0 interpolation operator*/ inline const double * getIMChild0() const {return &(*(ip_1D_0.begin()));} /**@brief: parent to child 1 interpolation operator*/ inline const double * getIMChild1() const {return &(*(ip_1D_1.begin()));} /**@brief: parent to child 0 interpolation operator (transpose)*/ inline const double * getIMTChild0() const { return &(*(ipT_1D_0.begin()));} /**@brief: parent to child 1 interpolation operator (transpose)*/ inline const double * getIMTChild1() const {return &(*(ipT_1D_1.begin()));} /**@brief: get the quadrature points*/ inline const double * getQ1d() const {return &(*(quad_1D.begin()));} /**@brief: get the quadrature points (transpose)*/ inline const double * getQT1d()const {return &(*(quadT_1D.begin()));} /**@brief: derivative of the basis functions evaluated at the quadrature points. */ inline const double * getDg1d()const {return &(*(Dg.begin()));} /**@brief: derivative of the basis functions evaluated at the quadrature points (Transpose) */ inline const double * getDgT1d()const {return &(*(DgT.begin()));} /**@brief: derivative of the basis functions evaluated at the nodal locations points */ inline const double * getDr1d()const {return &(*(Dr.begin()));} inline const double * getFr1D() const {return &(*(Fr.begin()));} inline double * getImVec1() {return &(*(im_vec1.begin()));} inline double * getImVec2() {return &(*(im_vec2.begin()));} inline const double * getWgq()const {return &(*(w.begin()));} inline const double * getWgll()const {return &(*(wgll.begin()));} inline const double getElementSz()const {return (u.back()-u.front());} /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: interpolated values. * * @brief This is computed in way that 3d coordinates changes in the order of z, y, x * Which means first we need to fill all the z values in plane(x=0,y=0) then all the z values in plane (x=0,y=0+h) and so forth. * */ inline void I3D_Parent2Child(const double * in, double* out, unsigned int childNum ) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 1: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 2: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 3: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 4: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 5: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 6: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 7: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; default: std::cout<<"[refel][error]: invalid child number specified for 3D interpolation."<<std::endl; break; } } /** * @brief performs parent to child interpolation in FD stencil. * @param in : input values of the parent. with 3 point padding on each x,y,z direction * @param out: values of the child. * @param cnum: child number * @param pwdith: padding width */ inline void I3D_Parent2Child_FD(const double* in, double* out,unsigned int pw=3) const { assert(pw < m_uiNrp); assert(m_uiNrp>2); // only works for higher order (hard coded) const unsigned int nx = m_uiNrp; const unsigned int ny = m_uiNrp; const unsigned int nz = m_uiNrp; const unsigned int sz_p[3] = {nx + 2*pw , ny + 2*pw , nz + 2*pw}; const unsigned int sz_c[3] = {2*m_uiNrp-1 + 2*pw,2*m_uiNrp-1 + 2*pw,2*m_uiNrp-1 + 2*pw}; const unsigned int c1d = 2*m_uiNrp-1; const unsigned int pp1 = sz_p[0]; const unsigned int pp2 = sz_p[0]*sz_p[1]; const unsigned int pp3 = sz_p[0]*sz_p[1]*sz_p[2]; const unsigned int cc1 = sz_c[0]; const unsigned int cc2 = sz_c[0]*sz_c[1]; const unsigned int cc3 = sz_c[0]*sz_c[1]*sz_c[2]; const unsigned int p2c1 = (pp1*2-1); const unsigned int p2c2 = (pp1*2-1)*p2c1; const unsigned int p2c3 = (pp1*2-1)*p2c2; const unsigned int fd_1d = gridT.size(); const double * c = gridT.data(); // const unsigned int fd_1d=4; // const double c[fd_1d] = {-1/16.0 , 9/16.0,9/16.0, -1/16.0}; // replacement array for p2c resolution. double * out_p = (double *)&(*(out_p2c.begin())); for(unsigned int k=0; k < sz_p[2]; k++) for(unsigned int j=0; j < sz_p[1]; j++) for(unsigned int i=0; i< sz_p[0]; i++) { out_p[ (k<<1u) * p2c2 + (j<<1u)*p2c1 + (i<<1u) ] = in[ k*pp2 + j*pp1 + i]; } const unsigned int N =p2c1; const unsigned int pw2 = pw<<1u; // along x direction. for(unsigned int k=0; k < N; k+=2) for(unsigned int j=0; j < N; j+=2) for(unsigned int i=pw2; i< N-pw2-2; i+=2) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ k*p2c2 + j * p2c1 + (i-4) + 2*m ]; out_p[ k * p2c2 + j*p2c1 + (i+1) ] =s; } // along y direction. for(unsigned int k=0; k < N; k+=2) for(unsigned int j=pw2; j < N-pw2-2; j+=2) for(unsigned int i=pw2; i< N-pw2; i+=1) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ k * p2c2 + (j-4 + 2*m)* p2c1 + i ]; out_p[ k * p2c2 + (j+1)*p2c1 + (i) ] =s; } // along z direction. for(unsigned int k=pw2; k < N-pw2-2; k+=2) for(unsigned int j=pw2; j < N-pw2; j+=1) for(unsigned int i=pw2; i< N-pw2; i+=1) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ (k-4 + 2*m) * p2c2 + (j)* p2c1 + i ]; out_p[ (k+1)* p2c2 + (j)*p2c1 + (i) ] =s; } for(unsigned int k=pw2; k < N-pw2; k+=1) for(unsigned int j=pw2; j < N-pw2; j+=1) for(unsigned int i=pw2; i< N-pw2; i+=1) out[ (k-pw2)*c1d*c1d + (j-pw2)*c1d + (i-pw2)] = out_p[ k* p2c2 + j* p2c1 + i]; return ; } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the contribution needed to be computed. * @param[out] out: child to parent contribution values. (used in FEM integral ivaluation) * * @brief This is computed in way that 3d coordinates changes in the order of z, y, x * Which means first we need to fill all the z values in plane(x=0,y=0) then all the z values in plane (x=0,y=0+h) and so forth. * */ inline void I3D_Child2Parent(const double * in, double* out, unsigned int childNum ) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 1: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 2: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 3: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 4: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 5: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 6: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 7: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; default: std::cout<<"[refel][error]: invalid child number specified for 3D interpolation."<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp*m_uiNrp*m_uiNrp);node++) out[node]=1.0; #endif } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: interpolated values. * */ inline void I2D_Parent2Child(const double * in, double* out, unsigned int childNum) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),im1,out); // along y (in 3d z) break; case 1: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),im1,out); // along y (in 3d z) break; case 2: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),im1,out); // along y (in 3d z) break; case 3: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),im1,out); // along y (in 3d z) break; default: std::cout<<"[refel][error]: invalid child number specified for 2D interpolation."<<std::endl; break; } } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: child to parent contribution values. (used in FEM integral ivaluation) * */ inline void I2D_Child2Parent(const double * in, double* out, unsigned int childNum) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),im1,out); // along y (in 3d z) break; case 1: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),im1,out); // along y (in 3d z) break; case 2: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),im1,out); // along y (in 3d z) break; case 3: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),im1,out); // along y (in 3d z) break; default: std::cout<<"[refel][error]: invalid child number specified for 2D interpolation."<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp*m_uiNrp);node++) out[node]=1.0; #endif } /** * @param [in] in input function values * @param [in] childNum Morton ID of the child number * @param [out] interpolated values from parent to child. * */ inline void I1D_Parent2Child(const double * in,double * out,unsigned int childNUm) const { switch (childNUm) { case 0: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ip_1D_0[j*m_uiNrp+i]*in[j]; } } break; case 1: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ip_1D_1[j*m_uiNrp+i]*in[j]; } } break; default: std::cout<<"[refel][error]: Invalid child number specified for 1D interpolation. "<<std::endl; break; } } /** * @param [in] in input function values * @param [in] childNum Morton ID of the child number * @param [out] child to parent contribution values. (used in FEM integral ivaluation) * */ inline void I1D_Child2Parent(const double * in,double * out,unsigned int childNUm) const { switch (childNUm) { case 0: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ipT_1D_0[j*m_uiNrp+i]*in[j]; } } break; case 1: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ipT_1D_1[j*m_uiNrp+i]*in[j]; } } break; default: std::cout<<"[refel][error]: Invalid child number specified for 1D interpolation. "<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp);node++) out[node]=1.0; #endif } void generateHeaderFile(char * fName); void computeFilterOp(unsigned int nc, unsigned int s); }; #endif //SFCSORTBENCH_REFERENCEELEMENT_H
[ "hylim1988@gmail.com" ]
hylim1988@gmail.com