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
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 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
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
e1d343aa6185a96ade00618e116a7d33efa9f675
37d36e8de4ce80a2a343dab23e4b701245ecdac9
/ShenShengYi/platform/School/include/GenerateScore.h
6cb03257d31b41919365b181de8675c9efac808a
[ "MIT" ]
permissive
shenshengyi/ShenShengYi
028d560c75c26edd803477b7632cf3a6824b59a3
0b16b555d498c0bd17dd16f830343a5f2a1fd4e1
refs/heads/master
2020-12-23T11:46:45.420869
2020-02-05T05:41:37
2020-02-05T05:41:37
237,140,680
0
0
null
null
null
null
UTF-8
C++
false
false
462
h
#pragma once #ifdef SCHOOL_DYNAMIC_LIBRARY #define CLASS_DECLSPEC __declspec(dllexport) #else #define CLASS_DECLSPEC __declspec(dllimport) #endif namespace STU { class GenerateScore { public: virtual ~GenerateScore(void) {} virtual int GenerateLanguage(void) = 0; virtual int GenerateMath(void) = 0; virtual int GenerateComprehensive(void) = 0; virtual int GenerateEnglish(void) = 0; static GenerateScore* CreateSTLGenerate(void); }; }
[ "1109653726@qq.com" ]
1109653726@qq.com
00fb1bf4b829c6e6d1759817f513aaa9df3aa4dd
a94935bd3855fa6da97265b491dd18930ccbb134
/RealmLib/Packets/Server/BuyResult.cpp
58013d78e9da39a989ec5db3d35068c969574968
[ "MIT" ]
permissive
hcoffey1/RealmNet
7531deed1fd80baaeb1fa8b42aa73271d86241e8
76ead08b4a0163a05b65389e512942a620331256
refs/heads/master
2022-04-25T13:37:49.505083
2019-03-05T21:29:56
2019-03-05T21:29:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
678
cpp
#include "stdafx.h" #include <GameData/Constants.h> #include <GameData/TypeManager.h> #include "Packets/PacketWriter.h" #include "Packets/PacketReader.h" #include <Packets/BuyResult.h> BuyResult::BuyResult(int result, const String& message) : result(result), message(message) { } BuyResult::BuyResult(byte* data) { PacketReader r(data); r.read(result); r.read(message); } void BuyResult::emplace(byte* buffer) const { PacketWriter w(buffer, size(), TypeManager::typeToId[PacketType::BuyResult]); w.write(result); w.write(message); } int BuyResult::size() const { return 11 + message.length; } String BuyResult::toString() const { return String("BUYRESULT"); }
[ "willurotmg@gmail.com" ]
willurotmg@gmail.com
cc347dd176666287a9a0f529e007dedbcb904bbe
c90a56e7d7752b041fc5eb38257c5573cef346c6
/src-win/TopTrans_tmpl.hxx
fab67040572eca23054eb747e5eb7d859bb83deb
[]
no_license
random-builder/design_cadquery_ocp
a4c572a72699bad52ca5f43f30bb7c15d89072ff
2af799a9f1b2d81fd39e519b2f73e12b34a14c0a
refs/heads/master
2021-05-21T23:10:23.833461
2020-03-29T15:34:46
2020-03-29T15:34:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
649
hxx
#pragma once // pybind 11 related includes #include <pybind11/pybind11.h> #include <pybind11/stl.h> namespace py = pybind11; // Standard Handle #include <Standard_Handle.hxx> // includes to resolve forward declarations // module includes #include <TopTrans_CurveTransition.hxx> #include <TopTrans_Array2OfOrientation.hxx> #include <TopTrans_SurfaceTransition.hxx> // user-defined pre #include "OCP_specific.inc" // Class template handling functions // ./opencascade\TopTrans_CurveTransition.hxx // ./opencascade\TopTrans_Array2OfOrientation.hxx // ./opencascade\TopTrans_SurfaceTransition.hxx // user-defined post
[ "adam.jan.urbanczyk@gmail.com" ]
adam.jan.urbanczyk@gmail.com
e8a34763d948a26bbf929df5db462c055c2cf526
b7e2b49b89ad9b842119410404b461f70b0716e5
/src/PPgNotify.cpp
999871da7e8210418a088ebe9eb3e720079ea605
[]
no_license
charleson/emule_verycd
31f3c71e0478b036f957edacd10f0f398c886165
489f841518e9313e9b387ad87298d32141c212f8
refs/heads/master
2020-04-06T04:18:04.657439
2012-09-16T15:11:58
2012-09-16T15:11:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,079
cpp
//this file is part of eMule //Copyright (C)2002-2006 Merkur ( strEmail.Format("%s@%s", "devteam", "emule-project.net") / http://www.emule-project.net ) // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either //version 2 of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. // //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "stdafx.h" #include "emule.h" #include "emuleDlg.h" #include "PPgNotify.h" #include "Preferences.h" #include "OtherFunctions.h" #include "Preferences.h" #include "HelpIDs.h" #include "TextToSpeech.h" #include "TaskbarNotifier.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNAMIC(CPPgNotify, CPropertyPage) BEGIN_MESSAGE_MAP(CPPgNotify, CPropertyPage) ON_WM_HELPINFO() ON_BN_CLICKED(IDC_CB_TBN_NOSOUND, OnBnClickedNoSound) ON_BN_CLICKED(IDC_CB_TBN_USESOUND, OnBnClickedUseSound) ON_BN_CLICKED(IDC_CB_TBN_USESPEECH, OnBnClickedUseSpeech) ON_EN_CHANGE(IDC_EDIT_TBN_WAVFILE, OnSettingsChange) ON_BN_CLICKED(IDC_BTN_BROWSE_WAV, OnBnClickedBrowseAudioFile) ON_BN_CLICKED(IDC_TEST_NOTIFICATION, OnBnClickedTestNotification) ON_BN_CLICKED(IDC_CB_TBN_ONNEWDOWNLOAD, OnSettingsChange) ON_BN_CLICKED(IDC_CB_TBN_ONDOWNLOAD, OnSettingsChange) ON_BN_CLICKED(IDC_CB_TBN_ONLOG, OnSettingsChange) ON_BN_CLICKED(IDC_CB_TBN_ONCHAT, OnBnClickedOnChat) ON_BN_CLICKED(IDC_CB_TBN_IMPORTATNT , OnSettingsChange) ON_BN_CLICKED(IDC_CB_TBN_POP_ALWAYS, OnSettingsChange) ON_BN_CLICKED(IDC_CB_TBN_ONNEWVERSION, OnSettingsChange) ON_EN_CHANGE(IDC_EDIT_SMTPSERVER, OnSettingsChange) ON_EN_CHANGE(IDC_EDIT_SENDER, OnSettingsChange) ON_EN_CHANGE(IDC_EDIT_RECEIVER, OnSettingsChange) ON_BN_CLICKED(IDC_CB_ENABLENOTIFICATIONS, OnBnClickedCbEnablenotifications) END_MESSAGE_MAP() CPPgNotify::CPPgNotify() : CPropertyPage(CPPgNotify::IDD) { m_bEnableEMail = true; } CPPgNotify::~CPPgNotify() { } void CPPgNotify::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); } BOOL CPPgNotify::OnInitDialog() { #if _ATL_VER >= 0x0710 m_bEnableEMail = (IsRunningXPSP2() > 0); #endif CPropertyPage::OnInitDialog(); InitWindowStyles(this); int iBtnID; if (thePrefs.notifierSoundType == ntfstSoundFile) iBtnID = IDC_CB_TBN_USESOUND; else if (thePrefs.notifierSoundType == ntfstSpeech) iBtnID = IDC_CB_TBN_USESPEECH; else { ASSERT( thePrefs.notifierSoundType == ntfstNoSound ); iBtnID = IDC_CB_TBN_NOSOUND; } ASSERT( IDC_CB_TBN_NOSOUND < IDC_CB_TBN_USESOUND && IDC_CB_TBN_USESOUND < IDC_CB_TBN_USESPEECH ); CheckRadioButton(IDC_CB_TBN_NOSOUND, IDC_CB_TBN_USESPEECH, iBtnID); CheckDlgButton(IDC_CB_TBN_ONDOWNLOAD, thePrefs.notifierOnDownloadFinished ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_ONNEWDOWNLOAD, thePrefs.notifierOnNewDownload ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_ONCHAT, thePrefs.notifierOnChat ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_ONLOG, thePrefs.notifierOnLog ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_IMPORTATNT, thePrefs.notifierOnImportantError ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_POP_ALWAYS, thePrefs.notifierOnEveryChatMsg ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CB_TBN_ONNEWVERSION, thePrefs.notifierOnNewVersion ? BST_CHECKED : BST_UNCHECKED); CButton* btnPTR = (CButton*)GetDlgItem(IDC_CB_TBN_POP_ALWAYS); btnPTR->EnableWindow(IsDlgButtonChecked(IDC_CB_TBN_ONCHAT)); SetDlgItemText(IDC_EDIT_TBN_WAVFILE, thePrefs.notifierSoundFile); if (!m_bEnableEMail){ CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_UNCHECKED); GetDlgItem(IDC_EMAILNOT_GROUP)->EnableWindow(FALSE); GetDlgItem(IDC_CB_ENABLENOTIFICATIONS)->EnableWindow(FALSE); GetDlgItem(IDC_TXT_SMTPSERVER)->EnableWindow(FALSE); GetDlgItem(IDC_TXT_RECEIVER)->EnableWindow(FALSE); GetDlgItem(IDC_TXT_SENDER)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(FALSE); } else{ //SetDlgItemText(IDC_EDIT_SMTPSERVER, thePrefs.GetNotifierMailServer()); //SetDlgItemText(IDC_EDIT_RECEIVER, thePrefs.GetNotifierMailReceiver()); // SetDlgItemText(IDC_EDIT_SENDER, thePrefs.GetNotifierMailSender()); /*if (thePrefs.IsNotifierSendMailEnabled()){ CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_CHECKED); GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(TRUE); GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(TRUE); } else{ CheckDlgButton(IDC_CB_ENABLENOTIFICATIONS, BST_UNCHECKED); GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(FALSE); GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(FALSE); }*/ } UpdateControls(); Localize(); GetDlgItem(IDC_CB_TBN_USESPEECH)->EnableWindow(IsSpeechEngineAvailable()); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CPPgNotify::UpdateControls() { GetDlgItem(IDC_EDIT_TBN_WAVFILE)->EnableWindow(IsDlgButtonChecked(IDC_CB_TBN_USESOUND)); GetDlgItem(IDC_BTN_BROWSE_WAV)->EnableWindow(IsDlgButtonChecked(IDC_CB_TBN_USESOUND)); GetDlgItem(IDC_EDIT_SMTPSERVER)->EnableWindow(IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS)); GetDlgItem(IDC_EDIT_RECEIVER)->EnableWindow(IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS)); GetDlgItem(IDC_EDIT_SENDER)->EnableWindow(IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS)); } void CPPgNotify::Localize(void) { if (m_hWnd) { SetWindowText(GetResString(IDS_PW_EKDEV_OPTIONS)); GetDlgItem(IDC_CB_TBN_USESOUND)->SetWindowText(GetResString(IDS_PW_TBN_USESOUND)); GetDlgItem(IDC_CB_TBN_NOSOUND)->SetWindowText(GetResString(IDS_NOSOUND)); GetDlgItem(IDC_BTN_BROWSE_WAV)->SetWindowText(GetResString(IDS_PW_BROWSE)); GetDlgItem(IDC_CB_TBN_ONLOG)->SetWindowText(GetResString(IDS_PW_TBN_ONLOG)); GetDlgItem(IDC_CB_TBN_ONCHAT)->SetWindowText(GetResString(IDS_PW_TBN_ONCHAT)); GetDlgItem(IDC_CB_TBN_POP_ALWAYS)->SetWindowText(GetResString(IDS_PW_TBN_POP_ALWAYS)); GetDlgItem(IDC_CB_TBN_ONDOWNLOAD)->SetWindowText(GetResString(IDS_PW_TBN_ONDOWNLOAD) + _T(" (*)") ); GetDlgItem(IDC_CB_TBN_ONNEWDOWNLOAD)->SetWindowText(GetResString(IDS_TBN_ONNEWDOWNLOAD)); GetDlgItem(IDC_TASKBARNOTIFIER)->SetWindowText(GetResString(IDS_PW_TASKBARNOTIFIER)); GetDlgItem(IDC_CB_TBN_IMPORTATNT)->SetWindowText(GetResString(IDS_PS_TBN_IMPORTANT) + _T(" (*)")); GetDlgItem(IDC_CB_TBN_ONNEWVERSION)->SetWindowText(GetResString(IDS_CB_TBN_ONNEWVERSION)); GetDlgItem(IDC_TBN_OPTIONS)->SetWindowText(GetResString(IDS_PW_TBN_OPTIONS)); GetDlgItem(IDC_CB_TBN_USESPEECH)->SetWindowText(GetResString(IDS_USESPEECH)); GetDlgItem(IDC_EMAILNOT_GROUP)->SetWindowText(GetResString(IDS_PW_EMAILNOTIFICATIONS) + _T(" (*)")); GetDlgItem(IDC_TXT_SMTPSERVER)->SetWindowText(GetResString(IDS_PW_SMTPSERVER)); GetDlgItem(IDC_TXT_RECEIVER)->SetWindowText(GetResString(IDS_PW_RECEIVERADDRESS)); GetDlgItem(IDC_TXT_SENDER)->SetWindowText(GetResString(IDS_PW_SENDERADDRESS)); GetDlgItem(IDC_CB_ENABLENOTIFICATIONS)->SetWindowText(GetResString(IDS_PW_ENABLEEMAIL)); } } BOOL CPPgNotify::OnApply() { thePrefs.notifierOnDownloadFinished = IsDlgButtonChecked(IDC_CB_TBN_ONDOWNLOAD)!=0; thePrefs.notifierOnNewDownload = IsDlgButtonChecked(IDC_CB_TBN_ONNEWDOWNLOAD)!=0; thePrefs.notifierOnChat = IsDlgButtonChecked(IDC_CB_TBN_ONCHAT)!=0; thePrefs.notifierOnLog = IsDlgButtonChecked(IDC_CB_TBN_ONLOG)!=0; thePrefs.notifierOnImportantError = IsDlgButtonChecked(IDC_CB_TBN_IMPORTATNT)!=0; thePrefs.notifierOnEveryChatMsg = IsDlgButtonChecked(IDC_CB_TBN_POP_ALWAYS)!=0; thePrefs.notifierOnNewVersion = IsDlgButtonChecked(IDC_CB_TBN_ONNEWVERSION)!=0; if (m_bEnableEMail){ //GetDlgItemText(IDC_EDIT_SMTPSERVER, thePrefs.m_strNotifierMailServer); //GetDlgItemText(IDC_EDIT_SENDER, thePrefs.m_strNotifierMailSender); //GetDlgItemText(IDC_EDIT_RECEIVER, thePrefs.m_strNotifierMailReceiver); //thePrefs.SetNotifierSendMail(IsDlgButtonChecked(IDC_CB_ENABLENOTIFICATIONS) != 0); } ApplyNotifierSoundType(); if (thePrefs.notifierSoundType != ntfstSpeech) ReleaseTTS(); SetModified(FALSE); return CPropertyPage::OnApply(); } void CPPgNotify::ApplyNotifierSoundType() { GetDlgItemText(IDC_EDIT_TBN_WAVFILE, thePrefs.notifierSoundFile); if (IsDlgButtonChecked(IDC_CB_TBN_USESOUND)) thePrefs.notifierSoundType = ntfstSoundFile; else if (IsDlgButtonChecked(IDC_CB_TBN_USESPEECH)) thePrefs.notifierSoundType = IsSpeechEngineAvailable() ? ntfstSpeech : ntfstNoSound; else { ASSERT( IsDlgButtonChecked(IDC_CB_TBN_NOSOUND) ); thePrefs.notifierSoundType = ntfstNoSound; } } void CPPgNotify::OnBnClickedOnChat() { GetDlgItem(IDC_CB_TBN_POP_ALWAYS)->EnableWindow(IsDlgButtonChecked(IDC_CB_TBN_ONCHAT)); SetModified(); } void CPPgNotify::OnBnClickedBrowseAudioFile() { CString strWavPath; GetDlgItemText(IDC_EDIT_TBN_WAVFILE, strWavPath); CString buffer; if (DialogBrowseFile(buffer, _T("Audio-Files (*.wav)|*.wav||"), strWavPath)){ SetDlgItemText(IDC_EDIT_TBN_WAVFILE, buffer); SetModified(); } } void CPPgNotify::OnBnClickedNoSound() { UpdateControls(); SetModified(); } void CPPgNotify::OnBnClickedUseSound() { UpdateControls(); SetModified(); } void CPPgNotify::OnBnClickedUseSpeech() { UpdateControls(); SetModified(); } void CPPgNotify::OnBnClickedTestNotification() { // save current pref settings bool bCurNotifyOnImportantError = thePrefs.notifierOnImportantError; ENotifierSoundType iCurSoundType = thePrefs.notifierSoundType; CString strSoundFile = thePrefs.notifierSoundFile; // temporary apply current settings from dialog thePrefs.notifierOnImportantError = true; ApplyNotifierSoundType(); // play test notification CString strTest; strTest.Format(GetResString(IDS_MAIN_READY), theApp.m_strCurVersionLong); theApp.emuledlg->ShowNotifier(strTest, TBN_IMPORTANTEVENT); // restore pref settings thePrefs.notifierSoundFile = strSoundFile; thePrefs.notifierSoundType = iCurSoundType; thePrefs.notifierOnImportantError = bCurNotifyOnImportantError; } void CPPgNotify::OnHelp() { theApp.ShowHelp(eMule_FAQ_Preferences_Notifications); } BOOL CPPgNotify::OnCommand(WPARAM wParam, LPARAM lParam) { if (wParam == ID_HELP) { OnHelp(); return TRUE; } return __super::OnCommand(wParam, lParam); } BOOL CPPgNotify::OnHelpInfo(HELPINFO* /*pHelpInfo*/) { OnHelp(); return TRUE; } void CPPgNotify::OnBnClickedCbEnablenotifications() { UpdateControls(); SetModified(); }
[ "codingforfan@gmail.com" ]
codingforfan@gmail.com
980dfff21f3056d07195e1251554fa3822b58f5d
60bb67415a192d0c421719de7822c1819d5ba7ac
/blazetest/src/mathtest/dmatdmatschur/DDbLDa.cpp
4ddfdbb0fbf0f835bae9a17a4459ca89d4900cfc
[ "BSD-3-Clause" ]
permissive
rtohid/blaze
48decd51395d912730add9bc0d19e617ecae8624
7852d9e22aeb89b907cb878c28d6ca75e5528431
refs/heads/master
2020-04-16T16:48:03.915504
2018-12-19T20:29:42
2018-12-19T20:29:42
165,750,036
0
0
null
null
null
null
UTF-8
C++
false
false
4,047
cpp
//================================================================================================= /*! // \file src/mathtest/dmatdmatschur/DDbLDa.cpp // \brief Source file for the DDbLDa dense matrix/dense matrix Schur product math test // // Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. 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. // 3. Neither the names of the Blaze development group 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 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. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/DiagonalMatrix.h> #include <blaze/math/DynamicMatrix.h> #include <blaze/math/LowerMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatdmatschur/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'DDbLDa'..." << std::endl; using blazetest::mathtest::TypeA; using blazetest::mathtest::TypeB; try { // Matrix type definitions using DDb = blaze::DiagonalMatrix< blaze::DynamicMatrix<TypeB> >; using LDa = blaze::LowerMatrix< blaze::DynamicMatrix<TypeA> >; // Creator type definitions using CDDb = blazetest::Creator<DDb>; using CLDa = blazetest::Creator<LDa>; // Running tests with small matrices for( size_t i=0UL; i<=9UL; ++i ) { RUN_DMATDMATSCHUR_OPERATION_TEST( CDDb( i ), CLDa( i ) ); } // Running tests with large matrices RUN_DMATDMATSCHUR_OPERATION_TEST( CDDb( 67UL ), CLDa( 67UL ) ); RUN_DMATDMATSCHUR_OPERATION_TEST( CDDb( 128UL ), CLDa( 128UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix Schur product:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
[ "klaus.iglberger@gmail.com" ]
klaus.iglberger@gmail.com
805fc1da28538deb80b4b3e5b5599698f7e83fd4
46f2e7a10fca9f7e7b80b342240302c311c31914
/lid_driven_flow/cavity/0.0668/phi
bf30c4c53c1ce5fa253cbd40fcdd89191ba39f61
[]
no_license
patricksinclair/openfoam_warmups
696cb1950d40b967b8b455164134bde03e9179a1
03c982f7d46b4858e3b6bfdde7b8e8c3c4275df9
refs/heads/master
2020-12-26T12:50:00.615357
2020-02-04T20:22:35
2020-02-04T20:22:35
237,510,814
0
0
null
null
null
null
UTF-8
C++
false
false
62,571
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "0.0668"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 4900 ( 1.12565e-09 -1.12751e-09 2.28063e-09 -1.15491e-09 2.33755e-09 -5.70595e-11 9.02192e-10 1.43526e-09 -2.1041e-09 3.00628e-09 -6.59764e-09 4.49356e-09 -1.24156e-08 5.81799e-09 -1.93598e-08 6.94417e-09 -2.72191e-08 7.85932e-09 -3.57812e-08 8.56202e-09 -4.48382e-08 9.05702e-09 -5.41909e-08 9.3527e-09 -6.36505e-08 9.45954e-09 -7.30398e-08 9.38931e-09 -8.21943e-08 9.15451e-09 -9.09624e-08 8.76807e-09 -9.92056e-08 8.24314e-09 -1.06799e-07 7.59298e-09 -1.13629e-07 6.8309e-09 -1.196e-07 5.97028e-09 -1.24624e-07 5.02455e-09 -1.28632e-07 4.00731e-09 -1.31564e-07 2.93235e-09 -1.33378e-07 1.81372e-09 -1.34044e-07 6.65839e-10 -1.33547e-07 -4.96486e-10 -1.31889e-07 -1.65799e-09 -1.29086e-07 -2.80292e-09 -1.25171e-07 -3.91509e-09 -1.20193e-07 -4.97786e-09 -1.14219e-07 -5.97423e-09 -1.07332e-07 -6.88699e-09 -9.9633e-08 -7.69881e-09 -9.12405e-08 -8.39248e-09 -8.22894e-08 -8.95112e-09 -7.29309e-08 -9.35846e-09 -6.33318e-08 -9.59911e-09 -5.36728e-08 -9.65894e-09 -4.41474e-08 -9.52546e-09 -3.49591e-08 -9.18824e-09 -2.63196e-08 -8.63956e-09 -1.84443e-08 -7.87523e-09 -1.15483e-08 -6.89601e-09 -5.83827e-09 -5.71002e-09 -1.50048e-09 -4.33777e-09 1.32306e-09 -2.82353e-09 2.57675e-09 -1.25369e-09 2.35896e-09 2.17781e-10 1.12439e-09 1.23459e-09 1.1244e-09 1.16613e-09 -2.29357e-09 1.29393e-09 -1.28288e-09 -1.24358e-09 2.48039e-09 -7.21464e-09 7.40645e-09 -1.68488e-08 1.26406e-08 -3.00373e-08 1.76821e-08 -4.64681e-08 2.22489e-08 -6.57135e-08 2.61895e-08 -8.72835e-08 2.94294e-08 -1.10661e-07 3.19396e-08 -1.35324e-07 3.37196e-08 -1.60758e-07 3.47867e-08 -1.86468e-07 3.51698e-08 -2.11984e-07 3.49051e-08 -2.36863e-07 3.40341e-08 -2.60696e-07 3.2601e-08 -2.83106e-07 3.06526e-08 -3.03749e-07 2.82366e-08 -3.2232e-07 2.54021e-08 -3.38549e-07 2.21985e-08 -3.522e-07 1.86764e-08 -3.6308e-07 1.48869e-08 -3.7103e-07 1.0882e-08 -3.75931e-07 6.71516e-09 -3.77706e-07 2.44077e-09 -3.76317e-07 -1.88517e-09 -3.7177e-07 -6.20513e-09 -3.64113e-07 -1.046e-08 -3.53439e-07 -1.45892e-08 -3.39886e-07 -1.85308e-08 -3.23638e-07 -2.22219e-08 -3.04926e-07 -2.5599e-08 -2.84026e-07 -2.85989e-08 -2.6126e-07 -3.1159e-08 -2.36993e-07 -3.32185e-08 -2.11632e-07 -3.47196e-08 -1.85622e-07 -3.56084e-08 -1.59445e-07 -3.58367e-08 -1.33606e-07 -3.53636e-08 -1.08637e-07 -3.41574e-08 -8.50778e-08 -3.2199e-08 -6.34681e-08 -2.9485e-08 -4.43298e-08 -2.60343e-08 -2.81423e-08 -2.18976e-08 -1.53066e-08 -1.71735e-08 -6.09233e-09 -1.20378e-08 -5.52491e-10 -6.79351e-09 1.624e-09 -1.95871e-09 1.24596e-09 1.61263e-09 2.37037e-09 1.16478e-10 -2.41019e-09 -2.37421e-09 1.20767e-09 -9.03905e-09 9.14524e-09 -2.06661e-08 1.90335e-08 -3.74964e-08 2.94709e-08 -5.93845e-08 3.95702e-08 -8.59187e-08 4.87831e-08 -1.16516e-07 5.67871e-08 -1.50492e-07 6.34045e-08 -1.87103e-07 6.85512e-08 -2.25589e-07 7.22053e-08 -2.65188e-07 7.43861e-08 -3.0516e-07 7.51412e-08 -3.44792e-07 7.45373e-08 -3.83412e-07 7.26544e-08 -4.20392e-07 6.95813e-08 -4.55153e-07 6.54134e-08 -4.87167e-07 6.025e-08 -5.15959e-07 5.4194e-08 -5.41111e-07 4.73504e-08 -5.62261e-07 3.98269e-08 -5.79107e-07 3.17328e-08 -5.91405e-07 2.31802e-08 -5.98973e-07 1.42834e-08 -6.01692e-07 5.15954e-09 -5.99506e-07 -4.07105e-09 -5.92426e-07 -1.32851e-08 -5.8053e-07 -2.23562e-08 -5.63964e-07 -3.11551e-08 -5.42945e-07 -3.95502e-08 -5.17758e-07 -4.7408e-08 -4.88762e-07 -5.45949e-08 -4.56384e-07 -6.09775e-08 -4.21117e-07 -6.64253e-08 -3.83524e-07 -7.08121e-08 -3.44224e-07 -7.40189e-08 -3.03897e-07 -7.5936e-08 -2.63266e-07 -7.64674e-08 -2.23096e-07 -7.55339e-08 -1.84175e-07 -7.30785e-08 -1.47301e-07 -6.90724e-08 -1.13262e-07 -6.3524e-08 -8.28053e-08 -5.64912e-08 -5.66028e-08 -4.81001e-08 -3.52021e-08 -3.85741e-08 -1.89583e-08 -2.82816e-08 -7.94094e-09 -1.78109e-08 -1.82242e-09 -8.07723e-09 2.79715e-10 -4.89502e-10 2.65009e-09 -1.33546e-09 -1.07479e-09 -7.22656e-09 7.09887e-09 -1.88619e-08 2.07806e-08 -3.68357e-08 3.70074e-08 -6.12768e-08 5.39121e-08 -9.19425e-08 7.0236e-08 -1.28313e-07 8.51537e-08 -1.69675e-07 9.81488e-08 -2.15187e-07 1.08917e-07 -2.63934e-07 1.17298e-07 -3.14965e-07 1.23236e-07 -3.67322e-07 1.26743e-07 -4.20064e-07 1.27884e-07 -4.72284e-07 1.26757e-07 -5.23118e-07 1.23488e-07 -5.71755e-07 1.18218e-07 -6.17445e-07 1.11104e-07 -6.59504e-07 1.02309e-07 -6.97315e-07 9.20044e-08 -7.30332e-07 8.03678e-08 -7.58085e-07 6.75804e-08 -7.8018e-07 5.38278e-08 -7.963e-07 3.93001e-08 -8.06209e-07 2.41918e-08 -8.09752e-07 8.70238e-09 -8.06859e-07 -6.964e-09 -7.97546e-07 -2.25979e-08 -7.81917e-07 -3.79852e-08 -7.60165e-07 -5.29072e-08 -7.32573e-07 -6.71417e-08 -6.99517e-07 -8.04645e-08 -6.61461e-07 -9.2651e-08 -6.18959e-07 -1.03479e-07 -5.72655e-07 -1.1273e-07 -5.23271e-07 -1.20196e-07 -4.71608e-07 -1.25682e-07 -4.18536e-07 -1.29008e-07 -3.64982e-07 -1.30021e-07 -3.11918e-07 -1.28598e-07 -2.60342e-07 -1.24655e-07 -2.11258e-07 -1.18156e-07 -1.65648e-07 -1.09134e-07 -1.24437e-07 -9.77018e-08 -8.84531e-08 -8.4084e-08 -5.83701e-08 -6.86571e-08 -3.46429e-08 -5.20087e-08 -1.74266e-08 -3.50271e-08 -6.48715e-09 -1.90167e-08 -1.11812e-09 -5.85855e-09 1.53199e-09 -2.88864e-09 1.81386e-09 -1.25156e-08 1.67259e-08 -2.95401e-08 3.78051e-08 -5.4244e-08 6.17114e-08 -8.65459e-08 8.6214e-08 -1.26047e-07 1.09737e-07 -1.72091e-07 1.31198e-07 -2.23833e-07 1.49891e-07 -2.80292e-07 1.65375e-07 -3.40403e-07 1.7741e-07 -4.03059e-07 1.85892e-07 -4.67141e-07 1.90825e-07 -5.31543e-07 1.92286e-07 -5.95195e-07 1.90409e-07 -6.57073e-07 1.85366e-07 -7.16216e-07 1.77361e-07 -7.71731e-07 1.66618e-07 -8.22799e-07 1.53377e-07 -8.68685e-07 1.3789e-07 -9.08736e-07 1.20419e-07 -9.42389e-07 1.01233e-07 -9.69171e-07 8.06099e-08 -9.88703e-07 5.88328e-08 -1.0007e-06 3.61927e-08 -1.00499e-06 1.29876e-08 -1.00148e-06 -1.04772e-08 -9.90185e-07 -3.38892e-08 -9.71241e-07 -5.69289e-08 -9.44878e-07 -7.92707e-08 -9.11435e-07 -1.00585e-07 -8.71361e-07 -1.20538e-07 -8.25213e-07 -1.38799e-07 -7.73652e-07 -1.55039e-07 -7.17443e-07 -1.68939e-07 -6.57448e-07 -1.80192e-07 -5.94616e-07 -1.88514e-07 -5.29977e-07 -1.93647e-07 -4.64625e-07 -1.95373e-07 -3.99706e-07 -1.93517e-07 -3.36391e-07 -1.8797e-07 -2.75854e-07 -1.78693e-07 -2.19241e-07 -1.65747e-07 -1.67633e-07 -1.4931e-07 -1.21997e-07 -1.2972e-07 -8.31406e-08 -1.07514e-07 -5.16484e-08 -8.35009e-08 -2.78217e-08 -5.88538e-08 -1.162e-08 -3.52183e-08 -2.62012e-09 -1.48585e-08 -1.08812e-09 -4.42102e-09 6.2349e-09 -1.78553e-08 3.01603e-08 -4.04177e-08 6.03675e-08 -7.2013e-08 9.33067e-08 -1.12288e-07 1.26489e-07 -1.60638e-07 1.58087e-07 -2.16242e-07 1.86802e-07 -2.78107e-07 2.11755e-07 -3.45111e-07 2.3238e-07 -4.16053e-07 2.48352e-07 -4.89685e-07 2.59524e-07 -5.64748e-07 2.65888e-07 -6.39997e-07 2.67535e-07 -7.14223e-07 2.64635e-07 -7.8627e-07 2.57414e-07 -8.55049e-07 2.4614e-07 -9.19545e-07 2.31115e-07 -9.7883e-07 2.12662e-07 -1.03207e-06 1.91126e-07 -1.07851e-06 1.66864e-07 -1.11752e-06 1.40245e-07 -1.14856e-06 1.11651e-07 -1.1712e-06 8.14706e-08 -1.18512e-06 5.0106e-08 -1.19009e-06 1.79671e-08 -1.18605e-06 -1.45257e-08 -1.17299e-06 -4.6942e-08 -1.15108e-06 -7.88428e-08 -1.12057e-06 -1.09781e-07 -1.08185e-06 -1.39304e-07 -1.03543e-06 -1.66956e-07 -9.81947e-07 -1.92284e-07 -9.22148e-07 -2.14839e-07 -8.56901e-07 -2.34186e-07 -7.87181e-07 -2.49911e-07 -7.14066e-07 -2.61629e-07 -6.38719e-07 -2.68994e-07 -5.62377e-07 -2.71715e-07 -4.86331e-07 -2.69563e-07 -4.11903e-07 -2.62398e-07 -3.40418e-07 -2.50179e-07 -2.73169e-07 -2.32996e-07 -2.11382e-07 -2.11098e-07 -1.5617e-07 -1.84931e-07 -1.08489e-07 -1.55195e-07 -6.90869e-08 -1.22903e-07 -3.84607e-08 -8.94799e-08 -1.68254e-08 -5.68536e-08 -4.1083e-09 -2.75756e-08 -5.19642e-09 -5.88417e-09 1.21191e-08 -2.30685e-08 4.73447e-08 -5.11583e-08 8.84573e-08 -8.96635e-08 1.31812e-07 -1.37925e-07 1.74751e-07 -1.951e-07 2.15262e-07 -2.60172e-07 2.51875e-07 -3.31982e-07 2.83565e-07 -4.09261e-07 3.09659e-07 -4.90669e-07 3.29759e-07 -5.74827e-07 3.43681e-07 -6.60347e-07 3.51408e-07 -7.45861e-07 3.53049e-07 -8.3004e-07 3.48814e-07 -9.11614e-07 3.38988e-07 -9.89384e-07 3.2391e-07 -1.06223e-06 3.03965e-07 -1.12914e-06 2.7957e-07 -1.18918e-06 2.51169e-07 -1.24154e-06 2.19223e-07 -1.28551e-06 1.84213e-07 -1.32049e-06 1.46633e-07 -1.34601e-06 1.06991e-07 -1.36172e-06 6.58093e-08 -1.36737e-06 2.36218e-08 -1.36287e-06 -1.90242e-08 -1.34825e-06 -6.15691e-08 -1.32365e-06 -1.03442e-07 -1.28937e-06 -1.44062e-07 -1.24583e-06 -1.82842e-07 -1.19359e-06 -2.19191e-07 -1.13336e-06 -2.5252e-07 -1.06594e-06 -2.82252e-07 -9.92307e-07 -3.07823e-07 -9.13519e-07 -3.28699e-07 -8.30762e-07 -3.44386e-07 -7.45317e-07 -3.5444e-07 -6.58544e-07 -3.58488e-07 -5.71864e-07 -3.56243e-07 -4.86735e-07 -3.47527e-07 -4.0462e-07 -3.32294e-07 -3.26956e-07 -3.1066e-07 -2.55117e-07 -2.82936e-07 -1.90372e-07 -2.49676e-07 -1.33847e-07 -2.1172e-07 -8.64814e-08 -1.70268e-07 -4.90056e-08 -1.26956e-07 -2.19237e-08 -8.39355e-08 -5.53287e-09 -4.39664e-08 -1.07293e-08 -7.26817e-09 1.93873e-08 -2.80931e-08 6.81696e-08 -6.16216e-08 1.21986e-07 -1.06977e-07 1.77167e-07 -1.63181e-07 2.30955e-07 -2.29129e-07 2.8121e-07 -3.0359e-07 3.26335e-07 -3.85221e-07 3.65195e-07 -4.72593e-07 3.97032e-07 -5.64224e-07 4.2139e-07 -6.58602e-07 4.3806e-07 -7.54219e-07 4.47025e-07 -8.49593e-07 4.48422e-07 -9.43286e-07 4.42507e-07 -1.03393e-06 4.29628e-07 -1.12022e-06 4.10205e-07 -1.20097e-06 3.84712e-07 -1.27506e-06 3.53666e-07 -1.34151e-06 3.17618e-07 -1.39944e-06 2.77144e-07 -1.44807e-06 2.32843e-07 -1.48676e-06 1.8533e-07 -1.51501e-06 1.35242e-07 -1.53243e-06 8.3229e-08 -1.53877e-06 2.99587e-08 -1.53391e-06 -2.38855e-08 -1.51787e-06 -7.76049e-08 -1.49083e-06 -1.30487e-07 -1.45308e-06 -1.81807e-07 -1.40509e-06 -2.30833e-07 -1.34746e-06 -2.76828e-07 -1.28092e-06 -3.1906e-07 -1.20636e-06 -3.56806e-07 -1.12482e-06 -3.89369e-07 -1.03743e-06 -4.16082e-07 -9.45489e-07 -4.3633e-07 -8.50365e-07 -4.49564e-07 -7.53533e-07 -4.5532e-07 -6.56533e-07 -4.53242e-07 -5.60952e-07 -4.43108e-07 -4.68389e-07 -4.24857e-07 -3.80427e-07 -3.98622e-07 -2.98596e-07 -3.64768e-07 -2.24335e-07 -3.23937e-07 -1.58959e-07 -2.77096e-07 -1.03626e-07 -2.25601e-07 -5.93221e-08 -1.7126e-07 -2.68542e-08 -1.16403e-07 -6.88293e-09 -6.39377e-08 -1.76122e-08 -8.58046e-09 2.79677e-08 -3.2927e-08 9.2516e-08 -7.1779e-08 1.60838e-07 -1.23892e-07 2.2928e-07 -1.87967e-07 2.95031e-07 -2.62629e-07 3.55872e-07 -3.46413e-07 4.10119e-07 -4.37779e-07 4.56561e-07 -5.35127e-07 4.9438e-07 -6.36823e-07 5.23086e-07 -7.41224e-07 5.42461e-07 -8.467e-07 5.52501e-07 -9.51658e-07 5.5338e-07 -1.05456e-06 5.45411e-07 -1.15395e-06 5.29014e-07 -1.24844e-06 5.04695e-07 -1.33676e-06 4.73029e-07 -1.41773e-06 4.34639e-07 -1.4903e-06 3.90191e-07 -1.55354e-06 3.4038e-07 -1.60663e-06 2.85932e-07 -1.64889e-06 2.27592e-07 -1.67977e-06 1.66129e-07 -1.69888e-06 1.02331e-07 -1.70592e-06 3.70066e-08 -1.70079e-06 -2.90184e-08 -1.6835e-06 -9.48984e-08 -1.65421e-06 -1.59771e-07 -1.61326e-06 -2.22761e-07 -1.56111e-06 -2.82981e-07 -1.4984e-06 -3.39541e-07 -1.4259e-06 -3.91554e-07 -1.34456e-06 -4.38146e-07 -1.25546e-06 -4.7847e-07 -1.15982e-06 -5.1172e-07 -1.059e-06 -5.3715e-07 -9.54477e-07 -5.54091e-07 -8.47817e-07 -5.6198e-07 -7.40679e-07 -5.6038e-07 -6.34776e-07 -5.49012e-07 -5.31845e-07 -5.27788e-07 -4.33622e-07 -4.96845e-07 -3.41802e-07 -4.56587e-07 -2.58012e-07 -4.07727e-07 -1.83775e-07 -3.51334e-07 -1.20484e-07 -2.88891e-07 -6.93945e-08 -2.2235e-07 -3.16202e-08 -1.54178e-07 -8.16702e-09 -8.73909e-08 -2.57792e-08 -9.83491e-09 3.78027e-08 -3.75971e-08 1.20278e-07 -8.16622e-08 2.04903e-07 -1.40438e-07 2.88056e-07 -2.12314e-07 3.66906e-07 -2.95634e-07 4.39192e-07 -3.88693e-07 5.03178e-07 -4.89739e-07 5.57608e-07 -5.96993e-07 6.01633e-07 -7.08662e-07 6.34755e-07 -8.22963e-07 6.56762e-07 -9.38146e-07 6.67683e-07 -1.05251e-06 6.67743e-07 -1.16442e-06 6.57322e-07 -1.27233e-06 6.36925e-07 -1.37479e-06 6.07155e-07 -1.47045e-06 5.68691e-07 -1.55809e-06 5.22273e-07 -1.63658e-06 4.68688e-07 -1.70496e-06 4.08759e-07 -1.76237e-06 3.43343e-07 -1.8081e-06 2.73322e-07 -1.84158e-06 1.99602e-07 -1.86236e-06 1.23115e-07 -1.87017e-06 4.4814e-08 -1.86486e-06 -3.43257e-08 -1.84645e-06 -1.13307e-07 -1.81511e-06 -1.91111e-07 -1.77117e-06 -2.66705e-07 -1.71511e-06 -3.3904e-07 -1.64759e-06 -4.07064e-07 -1.56941e-06 -4.69728e-07 -1.48156e-06 -5.25997e-07 -1.38517e-06 -5.74865e-07 -1.28151e-06 -6.15374e-07 -1.17203e-06 -6.46636e-07 -1.05827e-06 -6.67851e-07 -9.41908e-07 -6.78339e-07 -8.24716e-07 -6.77571e-07 -7.08531e-07 -6.65196e-07 -5.95235e-07 -6.41084e-07 -4.86722e-07 -6.05358e-07 -3.8487e-07 -5.5844e-07 -2.91504e-07 -5.01093e-07 -2.08371e-07 -4.34466e-07 -1.37118e-07 -3.60145e-07 -7.92731e-08 -2.80194e-07 -3.62575e-08 -1.97193e-07 -9.40138e-09 -1.14247e-07 -3.51806e-08 -1.10472e-08 4.88498e-08 -4.21434e-08 1.51374e-07 -9.13335e-08 2.54093e-07 -1.56698e-07 3.5342e-07 -2.36318e-07 4.46526e-07 -3.28258e-07 5.31132e-07 -4.30564e-07 6.05484e-07 -5.41266e-07 6.6831e-07 -6.58393e-07 7.1876e-07 -7.79985e-07 7.56348e-07 -9.04119e-07 7.80895e-07 -1.02892e-06 7.92482e-07 -1.15257e-06 7.91398e-07 -1.27336e-06 7.78109e-07 -1.38965e-06 7.53215e-07 -1.49992e-06 7.17426e-07 -1.60277e-06 6.71539e-07 -1.69691e-06 6.16416e-07 -1.7812e-06 5.52972e-07 -1.8546e-06 4.82166e-07 -1.91625e-06 4.0499e-07 -1.96539e-06 3.22467e-07 -2.00144e-06 2.35646e-07 -2.02393e-06 1.45605e-07 -2.03256e-06 5.34459e-08 -2.02718e-06 -3.9703e-08 -2.0078e-06 -1.32688e-07 -1.97458e-06 -2.24332e-07 -1.92785e-06 -3.13438e-07 -1.8681e-06 -3.98791e-07 -1.79599e-06 -4.7917e-07 -1.71236e-06 -5.53355e-07 -1.61822e-06 -6.20141e-07 -1.51473e-06 -6.78354e-07 -1.40323e-06 -7.26872e-07 -1.28522e-06 -7.64649e-07 -1.16233e-06 -7.90741e-07 -1.03633e-06 -8.0434e-07 -9.09097e-07 -8.04801e-07 -7.82606e-07 -7.91688e-07 -6.58886e-07 -7.64804e-07 -5.40003e-07 -7.24241e-07 -4.28026e-07 -6.70417e-07 -3.24997e-07 -6.04122e-07 -2.32901e-07 -5.26562e-07 -1.53645e-07 -4.39401e-07 -8.90439e-08 -3.44795e-07 -4.08172e-08 -2.4542e-07 -1.06048e-08 -1.44459e-07 -4.57854e-08 -1.22327e-08 6.10826e-08 -4.661e-08 1.85752e-07 -1.00868e-07 3.08351e-07 -1.72774e-07 4.25326e-07 -2.60108e-07 5.3386e-07 -3.60654e-07 6.31678e-07 -4.72204e-07 7.17034e-07 -5.92562e-07 7.88667e-07 -7.19556e-07 8.45755e-07 -8.51057e-07 8.87849e-07 -9.8499e-07 9.14828e-07 -1.11935e-06 9.26843e-07 -1.25223e-06 9.24274e-07 -1.3818e-06 9.07682e-07 -1.50636e-06 8.7778e-07 -1.62434e-06 8.35398e-07 -1.73426e-06 7.8146e-07 -1.8348e-06 7.16959e-07 -1.92478e-06 6.42948e-07 -2.00313e-06 5.60523e-07 -2.06896e-06 4.70819e-07 -2.1215e-06 3.75002e-07 -2.16012e-06 2.74269e-07 -2.18436e-06 1.69844e-07 -2.19389e-06 6.29812e-08 -2.18856e-06 -4.50368e-08 -2.16835e-06 -1.52898e-07 -2.13342e-06 -2.59264e-07 -2.08409e-06 -3.6277e-07 -2.02085e-06 -4.62031e-07 -1.94437e-06 -5.5565e-07 -1.85549e-06 -6.42231e-07 -1.75525e-06 -7.20388e-07 -1.64483e-06 -7.88769e-07 -1.52563e-06 -8.46075e-07 -1.39919e-06 -8.9109e-07 -1.26722e-06 -9.22708e-07 -1.13159e-06 -9.39971e-07 -9.94287e-07 -9.42103e-07 -8.57417e-07 -9.28557e-07 -7.2317e-07 -8.99051e-07 -5.93791e-07 -8.5362e-07 -4.71555e-07 -7.92653e-07 -3.58731e-07 -7.16946e-07 -2.57558e-07 -6.27735e-07 -1.70216e-07 -5.26743e-07 -9.88093e-08 -4.16202e-07 -4.53567e-08 -2.98873e-07 -1.17965e-08 -1.7802e-07 -5.7582e-08 -1.34059e-08 7.44884e-08 -5.10404e-08 2.23386e-07 -1.10345e-07 3.67655e-07 -1.8878e-07 5.03762e-07 -2.8383e-07 6.28909e-07 -3.92995e-07 7.40844e-07 -5.1381e-07 8.37848e-07 -6.43845e-07 9.18702e-07 -7.80724e-07 9.82633e-07 -9.22137e-07 1.02926e-06 -1.06586e-06 1.05855e-06 -1.20975e-06 1.07074e-06 -1.3518e-06 1.06632e-06 -1.49009e-06 1.04597e-06 -1.62285e-06 1.01054e-06 -1.74843e-06 9.60981e-07 -1.86533e-06 8.9836e-07 -1.97218e-06 8.23813e-07 -2.06777e-06 7.38535e-07 -2.15102e-06 6.43768e-07 -2.22099e-06 5.40792e-07 -2.2769e-06 4.30919e-07 -2.31813e-06 3.15493e-07 -2.34417e-06 1.95888e-07 -2.3547e-06 7.35103e-08 -2.34953e-06 -5.02042e-08 -2.32865e-06 -1.73785e-07 -2.29218e-06 -2.95729e-07 -2.24045e-06 -4.14504e-07 -2.17393e-06 -5.28551e-07 -2.09328e-06 -6.36295e-07 -1.99936e-06 -7.36153e-07 -1.8932e-06 -8.26553e-07 -1.77601e-06 -9.05952e-07 -1.64923e-06 -9.72861e-07 -1.51444e-06 -1.02588e-06 -1.37344e-06 -1.06371e-06 -1.22816e-06 -1.08524e-06 -1.08073e-06 -1.08953e-06 -9.33385e-07 -1.07591e-06 -7.88473e-07 -1.04396e-06 -6.48435e-07 -9.93657e-07 -5.15763e-07 -9.25326e-07 -3.92969e-07 -8.3974e-07 -2.82557e-07 -7.38147e-07 -1.86993e-07 -6.22307e-07 -1.08678e-07 -4.94517e-07 -4.99345e-08 -3.57616e-07 -1.2995e-08 -2.14959e-07 -7.0577e-08 -1.45795e-08 8.90679e-08 -5.54758e-08 2.64282e-07 -1.19839e-07 4.32018e-07 -2.04828e-07 5.88751e-07 -3.07627e-07 7.31708e-07 -4.25454e-07 8.58671e-07 -5.55577e-07 9.67972e-07 -6.95329e-07 1.05845e-06 -8.42121e-07 1.12943e-06 -9.9346e-07 1.1806e-06 -1.14696e-06 1.21205e-06 -1.30036e-06 1.22414e-06 -1.45153e-06 1.21749e-06 -1.59847e-06 1.19291e-06 -1.73934e-06 1.15141e-06 -1.87244e-06 1.09408e-06 -1.99623e-06 1.02214e-06 -2.1093e-06 9.36887e-07 -2.21042e-06 8.39655e-07 -2.29849e-06 7.3184e-07 -2.37257e-06 6.14871e-07 -2.43186e-06 4.90209e-07 -2.47571e-06 3.59344e-07 -2.50363e-06 2.238e-07 -2.51525e-06 8.51315e-08 -2.51038e-06 -5.50716e-08 -2.48898e-06 -1.95182e-07 -2.45118e-06 -3.33535e-07 -2.39725e-06 -4.68429e-07 -2.32767e-06 -5.9813e-07 -2.24309e-06 -7.20879e-07 -2.14434e-06 -8.34904e-07 -2.03245e-06 -9.38436e-07 -1.90868e-06 -1.02973e-06 -1.77444e-06 -1.10709e-06 -1.6314e-06 -1.16892e-06 -1.4814e-06 -1.21372e-06 -1.32648e-06 -1.24017e-06 -1.16885e-06 -1.24716e-06 -1.01091e-06 -1.23385e-06 -8.55173e-07 -1.1997e-06 -7.04284e-07 -1.14455e-06 -5.60963e-07 -1.06865e-06 -4.27979e-07 -9.72724e-07 -3.08116e-07 -8.58009e-07 -2.04139e-07 -7.26284e-07 -1.18759e-07 -5.79898e-07 -5.46076e-08 -4.21767e-07 -1.42177e-08 -2.55349e-07 -8.47947e-08 -1.57651e-08 1.04833e-07 -5.99535e-08 3.08471e-07 -1.29421e-07 5.01486e-07 -2.21022e-07 6.80352e-07 -3.31636e-07 8.42322e-07 -4.58193e-07 9.85227e-07 -5.97688e-07 1.10747e-06 -7.47209e-07 1.20798e-06 -9.03949e-07 1.28617e-06 -1.06523e-06 1.34188e-06 -1.2285e-06 1.37532e-06 -1.39136e-06 1.387e-06 -1.55159e-06 1.37771e-06 -1.70709e-06 1.34842e-06 -1.85597e-06 1.30029e-06 -1.99648e-06 1.23459e-06 -2.12703e-06 1.1527e-06 -2.24621e-06 1.05607e-06 -2.35277e-06 9.46209e-07 -2.44559e-06 8.24661e-07 -2.52372e-06 6.93007e-07 -2.58637e-06 5.52855e-07 -2.63287e-06 4.05844e-07 -2.66271e-06 2.53641e-07 -2.67553e-06 9.7948e-08 -2.6711e-06 -5.94957e-08 -2.64938e-06 -2.1691e-07 -2.61044e-06 -3.7247e-07 -2.55456e-06 -5.24307e-07 -2.48218e-06 -6.70513e-07 -2.39392e-06 -8.09143e-07 -2.29059e-06 -9.38229e-07 -2.17323e-06 -1.0558e-06 -2.04306e-06 -1.15989e-06 -1.90156e-06 -1.2486e-06 -1.75038e-06 -1.32009e-06 -1.59145e-06 -1.37265e-06 -1.42688e-06 -1.40474e-06 -1.259e-06 -1.41504e-06 -1.09035e-06 -1.4025e-06 -9.23624e-07 -1.36642e-06 -7.61673e-07 -1.3065e-06 -6.07459e-07 -1.22286e-06 -4.64024e-07 -1.11616e-06 -3.3445e-07 -9.87583e-07 -2.21816e-07 -8.38919e-07 -1.29157e-07 -6.72556e-07 -5.94308e-08 -4.91493e-07 -1.5481e-08 -2.99299e-07 -1.00276e-07 -1.69727e-08 1.21806e-07 -6.45075e-08 3.56005e-07 -1.39156e-07 5.76134e-07 -2.37459e-07 7.78655e-07 -3.55984e-07 9.60847e-07 -4.9136e-07 1.1206e-06 -6.40306e-07 1.25641e-06 -7.99654e-07 1.36732e-06 -9.66374e-07 1.45289e-06 -1.13759e-06 1.51309e-06 -1.31059e-06 1.54832e-06 -1.48286e-06 1.55927e-06 -1.65204e-06 1.5469e-06 -1.81599e-06 1.51237e-06 -1.97273e-06 1.45703e-06 -2.12049e-06 1.38234e-06 -2.25765e-06 1.28986e-06 -2.38279e-06 1.18121e-06 -2.49464e-06 1.05806e-06 -2.5921e-06 9.22119e-07 -2.67421e-06 7.7512e-07 -2.74017e-06 6.18819e-07 -2.78933e-06 4.54998e-07 -2.82115e-06 2.85465e-07 -2.83527e-06 1.12064e-07 -2.83144e-06 -6.33231e-08 -2.80958e-06 -2.38769e-07 -2.76976e-06 -4.12294e-07 -2.7122e-06 -5.81867e-07 -2.63731e-06 -7.45405e-07 -2.54567e-06 -9.00779e-07 -2.43808e-06 -1.04582e-06 -2.31553e-06 -1.17835e-06 -2.17924e-06 -1.29618e-06 -2.03068e-06 -1.39716e-06 -1.87155e-06 -1.47922e-06 -1.7038e-06 -1.5404e-06 -1.52963e-06 -1.57891e-06 -1.35148e-06 -1.59319e-06 -1.17202e-06 -1.58196e-06 -9.94143e-07 -1.5443e-06 -8.20908e-07 -1.47973e-06 -6.55536e-07 -1.38823e-06 -5.01357e-07 -1.27034e-06 -3.61766e-07 -1.12717e-06 -2.40177e-07 -9.60508e-07 -1.39973e-07 -7.7276e-07 -6.44557e-08 -5.6701e-07 -1.68001e-08 -3.46954e-07 -1.17076e-07 -1.82114e-08 1.40017e-07 -6.91679e-08 4.06962e-07 -1.49102e-07 6.56068e-07 -2.54226e-07 8.83778e-07 -3.80782e-07 1.0874e-06 -5.25088e-07 1.26491e-06 -6.83571e-07 1.4149e-06 -8.52802e-07 1.53655e-06 -1.02952e-06 1.6296e-06 -1.21065e-06 1.69422e-06 -1.39332e-06 1.73099e-06 -1.57487e-06 1.74082e-06 -1.75286e-06 1.72489e-06 -1.92507e-06 1.68457e-06 -2.08947e-06 1.62143e-06 -2.24425e-06 1.53712e-06 -2.3878e-06 1.43341e-06 -2.51868e-06 1.31209e-06 -2.63563e-06 1.17501e-06 -2.73757e-06 1.02405e-06 -2.82353e-06 8.61088e-07 -2.89274e-06 6.88026e-07 -2.94453e-06 5.06786e-07 -2.97837e-06 3.19313e-07 -2.99389e-06 1.2758e-07 -2.99082e-06 -6.63927e-08 -2.96905e-06 -2.6054e-07 -2.92861e-06 -4.52735e-07 -2.86968e-06 -6.40792e-07 -2.79263e-06 -8.22458e-07 -2.69799e-06 -9.95418e-07 -2.58651e-06 -1.15731e-06 -2.45914e-06 -1.30572e-06 -2.31708e-06 -1.43824e-06 -2.16178e-06 -1.55246e-06 -1.99494e-06 -1.64606e-06 -1.81856e-06 -1.71678e-06 -1.63489e-06 -1.76257e-06 -1.44649e-06 -1.78159e-06 -1.25617e-06 -1.77228e-06 -1.067e-06 -1.73348e-06 -8.82262e-07 -1.66447e-06 -7.05455e-07 -1.56504e-06 -5.40208e-07 -1.43558e-06 -3.90255e-07 -1.27713e-06 -2.59368e-07 -1.09139e-06 -1.51302e-07 -8.80826e-07 -6.97314e-08 -6.48581e-07 -1.81893e-08 -3.98496e-07 -1.35265e-07 -1.94893e-08 1.59506e-07 -7.39624e-08 4.61435e-07 -1.59312e-07 7.41418e-07 -2.71401e-07 9.95867e-07 -4.0613e-07 1.22213e-06 -5.59487e-07 1.41827e-06 -7.27597e-07 1.58301e-06 -9.06754e-07 1.71571e-06 -1.09346e-06 1.81631e-06 -1.28444e-06 1.8852e-06 -1.47665e-06 1.92321e-06 -1.66732e-06 1.93149e-06 -1.8539e-06 1.91147e-06 -2.03411e-06 1.86478e-06 -2.20588e-06 1.7932e-06 -2.36738e-06 1.69863e-06 -2.51701e-06 1.58303e-06 -2.65334e-06 1.44841e-06 -2.77512e-06 1.2968e-06 -2.88129e-06 1.13022e-06 -2.97093e-06 9.50725e-07 -3.04325e-06 7.60351e-07 -3.09762e-06 5.61152e-07 -3.13351e-06 3.55198e-07 -3.15051e-06 1.44588e-07 -3.14837e-06 -6.8537e-08 -3.12693e-06 -2.81982e-07 -3.08617e-06 -4.93487e-07 -3.02625e-06 -7.00717e-07 -2.94745e-06 -9.01256e-07 -2.85026e-06 -1.09261e-06 -2.73535e-06 -1.27221e-06 -2.60363e-06 -1.43744e-06 -2.45624e-06 -1.58563e-06 -2.2946e-06 -1.7141e-06 -2.12041e-06 -1.82025e-06 -1.93567e-06 -1.90152e-06 -1.74271e-06 -1.95554e-06 -1.54415e-06 -1.98014e-06 -1.34297e-06 -1.97347e-06 -1.14239e-06 -1.93405e-06 -9.45963e-07 -1.8609e-06 -7.57443e-07 -1.75356e-06 -5.80791e-07 -1.61224e-06 -4.20098e-07 -1.43782e-06 -2.79527e-07 -1.23197e-06 -1.63236e-07 -9.97118e-07 -7.53045e-08 -7.36513e-07 -1.96623e-08 -4.54139e-07 -1.54927e-07 -2.08138e-08 1.8032e-07 -7.89167e-08 5.19538e-07 -1.69834e-07 8.32335e-07 -2.89056e-07 1.11509e-06 -4.32116e-07 1.36519e-06 -5.94655e-07 1.58081e-06 -7.72473e-07 1.76082e-06 -9.61582e-07 1.90482e-06 -1.15823e-06 2.01296e-06 -1.35894e-06 2.08591e-06 -1.56052e-06 2.12478e-06 -1.76004e-06 2.13102e-06 -1.95489e-06 2.10632e-06 -2.14273e-06 2.05262e-06 -2.32148e-06 1.97194e-06 -2.4893e-06 1.86645e-06 -2.64459e-06 1.73833e-06 -2.78596e-06 1.58979e-06 -2.91221e-06 1.42305e-06 -3.0223e-06 1.24031e-06 -3.11535e-06 1.04377e-06 -3.1906e-06 8.35606e-07 -3.24744e-06 6.17989e-07 -3.28535e-06 3.93105e-07 -3.30392e-06 1.63163e-07 -3.30287e-06 -6.95863e-08 -3.28202e-06 -3.02835e-07 -3.2413e-06 -5.34202e-07 -3.18081e-06 -7.61216e-07 -3.10075e-06 -9.81311e-07 -3.00154e-06 -1.19182e-06 -2.88378e-06 -1.38998e-06 -2.74828e-06 -1.57293e-06 -2.59614e-06 -1.73777e-06 -2.42869e-06 -1.88155e-06 -2.24763e-06 -2.00132e-06 -2.05494e-06 -2.09421e-06 -1.85298e-06 -2.1575e-06 -1.64447e-06 -2.18865e-06 -1.43249e-06 -2.18545e-06 -1.22047e-06 -2.14607e-06 -1.01219e-06 -2.06918e-06 -8.11696e-07 -1.95405e-06 -6.23293e-07 -1.80064e-06 -4.51461e-07 -1.60965e-06 -3.00783e-07 -1.38264e-06 -1.7586e-07 -1.12204e-06 -8.12198e-08 -8.31153e-07 -2.12323e-08 -5.14126e-07 -1.7616e-07 -2.21925e-08 2.02513e-07 -8.40556e-08 5.81401e-07 -1.80716e-07 9.28996e-07 -3.07259e-07 1.24163e-06 -4.58823e-07 1.51676e-06 -6.30672e-07 1.75266e-06 -8.18268e-07 1.94842e-06 -1.01732e-06 2.10387e-06 -1.22382e-06 2.21946e-06 -1.43407e-06 2.29617e-06 -1.64473e-06 2.33544e-06 -1.85275e-06 2.33904e-06 -2.05545e-06 2.30902e-06 -2.25044e-06 2.2476e-06 -2.43563e-06 2.15714e-06 -2.60921e-06 2.04003e-06 -2.76962e-06 1.89874e-06 -2.91552e-06 1.73568e-06 -3.04574e-06 1.55327e-06 -3.15932e-06 1.35389e-06 -3.25542e-06 1.13987e-06 -3.33334e-06 9.13523e-07 -3.39248e-06 6.77127e-07 -3.43235e-06 4.32972e-07 -3.45254e-06 1.83358e-07 -3.45276e-06 -6.93722e-08 -3.43278e-06 -3.22816e-07 -3.39249e-06 -5.74487e-07 -3.33191e-06 -8.21799e-07 -3.25117e-06 -1.06205e-06 -3.15059e-06 -1.2924e-06 -3.03066e-06 -1.50991e-06 -2.89211e-06 -1.71149e-06 -2.73592e-06 -1.89397e-06 -2.56336e-06 -2.0541e-06 -2.37605e-06 -2.18863e-06 -2.17596e-06 -2.2943e-06 -1.96545e-06 -2.368e-06 -1.74731e-06 -2.40679e-06 -1.52472e-06 -2.40803e-06 -1.30131e-06 -2.36948e-06 -1.08107e-06 -2.28942e-06 -8.68372e-07 -2.16675e-06 -6.67881e-07 -2.00113e-06 -4.84495e-07 -1.79304e-06 -3.23258e-07 -1.54388e-06 -1.89257e-07 -1.25604e-06 -8.75213e-08 -9.32888e-07 -2.29125e-08 -5.78735e-07 -1.99072e-07 -2.36328e-08 2.26146e-07 -8.94048e-08 6.47173e-07 -1.92005e-07 1.0316e-06 -3.26077e-07 1.3757e-06 -4.86325e-07 1.677e-06 -6.67613e-07 1.93394e-06 -8.65031e-07 2.14584e-06 -1.07397e-06 2.31281e-06 -1.29015e-06 2.43564e-06 -1.50968e-06 2.51569e-06 -1.72902e-06 2.55479e-06 -1.94506e-06 2.55508e-06 -2.15503e-06 2.51899e-06 -2.35653e-06 2.4491e-06 -2.54749e-06 2.34809e-06 -2.72613e-06 2.21868e-06 -2.89096e-06 2.06356e-06 -3.0407e-06 1.88542e-06 -3.17427e-06 1.68685e-06 -3.29078e-06 1.4704e-06 -3.38947e-06 1.23856e-06 -3.46968e-06 9.93737e-07 -3.53088e-06 7.38322e-07 -3.57259e-06 4.74683e-07 -3.59442e-06 2.05194e-07 -3.59606e-06 -6.77334e-08 -3.57726e-06 -3.41624e-07 -3.53783e-06 -6.13911e-07 -3.47772e-06 -8.81908e-07 -3.39698e-06 -1.14279e-06 -3.29578e-06 -1.39359e-06 -3.17453e-06 -1.63116e-06 -3.03379e-06 -1.85222e-06 -2.87444e-06 -2.05332e-06 -2.69764e-06 -2.23091e-06 -2.5049e-06 -2.38136e-06 -2.29814e-06 -2.50106e-06 -2.07971e-06 -2.58644e-06 -1.85241e-06 -2.63409e-06 -1.61954e-06 -2.6409e-06 -1.38488e-06 -2.60414e-06 -1.15267e-06 -2.52163e-06 -9.27588e-07 -2.39183e-06 -7.14696e-07 -2.21402e-06 -5.1934e-07 -1.98839e-06 -3.47068e-07 -1.71615e-06 -2.03509e-07 -1.3996e-06 -9.42529e-08 -1.04214e-06 -2.4716e-08 -6.48272e-07 -2.23788e-07 -2.51432e-08 2.51289e-07 -9.4992e-08 7.17022e-07 -2.03753e-07 1.14036e-06 -3.45579e-07 1.51753e-06 -5.14703e-07 1.84613e-06 -7.05543e-07 2.12478e-06 -9.12796e-07 2.35309e-06 -1.13151e-06 2.53152e-06 -1.35713e-06 2.66126e-06 -1.58553e-06 2.7441e-06 -1.81305e-06 2.78231e-06 -2.03647e-06 2.77849e-06 -2.25297e-06 2.73549e-06 -2.46016e-06 2.6563e-06 -2.65602e-06 2.54395e-06 -2.83883e-06 2.40149e-06 -3.00719e-06 2.23192e-06 -3.15991e-06 2.03814e-06 -3.29604e-06 1.82298e-06 -3.41477e-06 1.58913e-06 -3.51543e-06 1.33922e-06 -3.59746e-06 1.07577e-06 -3.66038e-06 8.01236e-07 -3.70375e-06 5.18056e-07 -3.72721e-06 2.28651e-07 -3.73042e-06 -6.45227e-08 -3.7131e-06 -3.58945e-07 -3.67502e-06 -6.51992e-07 -3.61601e-06 -9.4091e-07 -3.53603e-06 -1.22278e-06 -3.43512e-06 -1.4945e-06 -3.31351e-06 -1.75277e-06 -3.17165e-06 -1.99408e-06 -3.01023e-06 -2.21474e-06 -2.83026e-06 -2.41087e-06 -2.63313e-06 -2.57849e-06 -2.42065e-06 -2.71354e-06 -2.19512e-06 -2.81197e-06 -1.95934e-06 -2.86987e-06 -1.71668e-06 -2.88356e-06 -1.47107e-06 -2.84976e-06 -1.22698e-06 -2.76572e-06 -9.89422e-07 -2.62939e-06 -7.63856e-07 -2.43959e-06 -5.56123e-07 -2.19613e-06 -3.72326e-07 -1.89995e-06 -2.18699e-07 -1.55323e-06 -1.01459e-07 -1.15938e-06 -2.66566e-08 -7.23075e-07 -2.50445e-07 -2.67332e-08 2.78022e-07 -1.00849e-07 7.91138e-07 -2.16017e-07 1.25552e-06 -3.65844e-07 1.66736e-06 -5.44039e-07 2.02432e-06 -7.44532e-07 2.32528e-06 -9.61588e-07 2.57015e-06 -1.18989e-06 2.75982e-06 -1.42459e-06 2.89596e-06 -1.66135e-06 2.98086e-06 -1.89637e-06 3.01732e-06 -2.12633e-06 3.00845e-06 -2.34842e-06 2.95759e-06 -2.56028e-06 2.86816e-06 -2.75995e-06 2.74361e-06 -2.94582e-06 2.58736e-06 -3.1166e-06 2.4027e-06 -3.27126e-06 2.1928e-06 -3.40895e-06 1.96067e-06 -3.52902e-06 1.7092e-06 -3.6309e-06 1.4411e-06 -3.71413e-06 1.159e-06 -3.77832e-06 8.65424e-07 -3.82309e-06 5.62826e-07 -3.8481e-06 2.53657e-07 -3.853e-06 -5.96146e-08 -3.8375e-06 -3.74452e-07 -3.80128e-06 -6.88212e-07 -3.74409e-06 -9.98098e-07 -3.66574e-06 -1.30113e-06 -3.56615e-06 -1.5941e-06 -3.44536e-06 -1.87356e-06 -3.30361e-06 -2.13582e-06 -3.14142e-06 -2.37693e-06 -2.95961e-06 -2.59269e-06 -2.75937e-06 -2.77873e-06 -2.54238e-06 -2.93053e-06 -2.31083e-06 -3.04352e-06 -2.06749e-06 -3.11321e-06 -1.81575e-06 -3.1353e-06 -1.55966e-06 -3.10584e-06 -1.30394e-06 -3.02144e-06 -1.0539e-06 -2.87943e-06 -8.15453e-07 -2.67804e-06 -5.94962e-07 -2.41662e-06 -3.99144e-07 -2.09577e-06 -2.3491e-07 -1.71746e-06 -1.09188e-07 -1.28511e-06 -2.8749e-08 -8.03513e-07 -2.79194e-07 -2.84148e-08 3.06437e-07 -1.07016e-07 8.69739e-07 -2.28868e-07 1.37738e-06 -3.86967e-07 1.82546e-06 -5.74433e-07 2.21179e-06 -7.84656e-07 2.5355e-06 -1.01143e-06 2.79692e-06 -1.24904e-06 2.99743e-06 -1.49234e-06 3.13926e-06 -1.73677e-06 3.2253e-06 -1.97841e-06 3.25896e-06 -2.21388e-06 3.24393e-06 -2.44039e-06 3.18409e-06 -2.65563e-06 3.0834e-06 -2.85777e-06 2.94575e-06 -3.04534e-06 2.77493e-06 -3.2172e-06 2.57457e-06 -3.37249e-06 2.34809e-06 -3.51055e-06 2.09873e-06 -3.63086e-06 1.82951e-06 -3.73302e-06 1.54327e-06 -3.8167e-06 1.24268e-06 -3.88159e-06 9.30315e-07 -3.9274e-06 6.08634e-07 -3.95382e-06 2.80074e-07 -3.96052e-06 -5.29147e-08 -3.94715e-06 -3.87819e-07 -3.91335e-06 -7.22009e-07 -3.85876e-06 -1.05269e-06 -3.78305e-06 -1.37684e-06 -3.68595e-06 -1.6912e-06 -3.56732e-06 -1.9922e-06 -3.42717e-06 -2.27597e-06 -3.26577e-06 -2.53833e-06 -3.08369e-06 -2.77476e-06 -2.88193e-06 -2.9805e-06 -2.66193e-06 -3.15052e-06 -2.42574e-06 -3.27972e-06 -2.17602e-06 -3.36293e-06 -1.91617e-06 -3.39515e-06 -1.65032e-06 -3.37169e-06 -1.38338e-06 -3.28838e-06 -1.12101e-06 -3.1418e-06 -8.69556e-07 -2.92949e-06 -6.35968e-07 -2.65021e-06 -4.27637e-07 -2.3041e-06 -2.52231e-07 -1.89287e-06 -1.1749e-07 -1.41985e-06 -3.10097e-08 -8.89994e-07 -3.10203e-07 -3.02028e-08 3.3664e-07 -1.1354e-07 9.53076e-07 -2.42393e-07 1.50623e-06 -4.09064e-07 1.99213e-06 -6.06007e-07 2.40873e-06 -8.26007e-07 2.7555e-06 -1.06234e-06 3.03325e-06 -1.30886e-06 3.24395e-06 -1.56012e-06 3.39051e-06 -1.81135e-06 3.47653e-06 -2.0585e-06 3.50611e-06 -2.29818e-06 3.48361e-06 -2.52765e-06 3.41356e-06 -2.74472e-06 3.30047e-06 -2.9477e-06 3.14873e-06 -3.13531e-06 2.96254e-06 -3.30663e-06 2.74589e-06 -3.46101e-06 2.50246e-06 -3.59798e-06 2.2357e-06 -3.71723e-06 1.94876e-06 -3.81854e-06 1.64458e-06 -3.90173e-06 1.32587e-06 -3.96662e-06 9.95201e-07 -4.013e-06 6.55011e-07 -4.04061e-06 3.07691e-07 -4.04916e-06 -4.437e-08 -4.03826e-06 -3.98722e-07 -4.00747e-06 -7.52792e-07 -3.95634e-06 -1.10382e-06 -3.88437e-06 -1.44881e-06 -3.79111e-06 -1.78446e-06 -3.67617e-06 -2.10714e-06 -3.53932e-06 -2.41283e-06 -3.38053e-06 -2.69712e-06 -3.2001e-06 -2.9552e-06 -2.9987e-06 -3.18189e-06 -2.77755e-06 -3.37168e-06 -2.53843e-06 -3.51883e-06 -2.28387e-06 -3.61749e-06 -2.01718e-06 -3.66184e-06 -1.74255e-06 -3.64633e-06 -1.46505e-06 -3.56588e-06 -1.19066e-06 -3.41618e-06 -9.26206e-07 -3.19394e-06 -6.79244e-07 -2.89717e-06 -4.57921e-07 -2.52542e-06 -2.7076e-07 -2.08003e-06 -1.26423e-07 -1.56418e-06 -3.34572e-08 -9.8296e-07 -3.43661e-07 -3.21165e-08 3.68756e-07 -1.20485e-07 1.04145e-06 -2.56704e-07 1.64245e-06 -4.32282e-07 2.16771e-06 -6.38913e-07 2.61536e-06 -8.68704e-07 2.98529e-06 -1.11435e-06 3.27889e-06 -1.36926e-06 3.49886e-06 -1.62764e-06 3.6489e-06 -1.88455e-06 3.73344e-06 -2.13583e-06 3.75739e-06 -2.37812e-06 3.7259e-06 -2.60878e-06 3.64422e-06 -2.82578e-06 3.51747e-06 -3.02764e-06 3.35059e-06 -3.21333e-06 3.14824e-06 -3.38218e-06 2.91474e-06 -3.53379e-06 2.65407e-06 -3.66796e-06 2.36987e-06 -3.78461e-06 2.06541e-06 -3.88372e-06 1.74369e-06 -3.9653e-06 1.40745e-06 -4.02932e-06 1.05922e-06 -4.07568e-06 7.01369e-07 -4.10419e-06 3.36207e-07 -4.11458e-06 -3.39804e-08 -4.10645e-06 -4.06853e-07 -4.07931e-06 -7.7994e-07 -4.03255e-06 -1.15057e-06 -3.96554e-06 -1.51582e-06 -3.87761e-06 -1.87239e-06 -3.76811e-06 -2.21663e-06 -3.63652e-06 -2.54442e-06 -3.48247e-06 -2.85116e-06 -3.3059e-06 -3.13176e-06 -3.10715e-06 -3.38064e-06 -2.88707e-06 -3.59177e-06 -2.64715e-06 -3.75875e-06 -2.38967e-06 -3.87497e-06 -2.1178e-06 -3.93371e-06 -1.8357e-06 -3.92842e-06 -1.54859e-06 -3.853e-06 -1.26272e-06 -3.70205e-06 -9.85417e-07 -3.47125e-06 -7.24893e-07 -3.15769e-06 -4.90127e-07 -2.76019e-06 -2.90607e-07 -2.27955e-06 -1.36054e-07 -1.71874e-06 -3.61135e-08 -1.0829e-06 -3.79774e-07 -3.41807e-08 4.02937e-07 -1.27931e-07 1.1352e-06 -2.71945e-07 1.78646e-06 -4.56809e-07 2.35257e-06 -6.73348e-07 2.8319e-06 -9.12893e-07 3.22484e-06 -1.1675e-06 3.5335e-06 -1.43009e-06 3.76145e-06 -1.69454e-06 3.91335e-06 -1.95572e-06 3.99461e-06 -2.20943e-06 4.0111e-06 -2.45238e-06 3.96885e-06 -2.68208e-06 3.87392e-06 -2.89673e-06 3.73212e-06 -3.09515e-06 3.549e-06 -3.27658e-06 3.32967e-06 -3.44069e-06 3.07885e-06 -3.58738e-06 2.80076e-06 -3.71674e-06 2.49923e-06 -3.82898e-06 2.17765e-06 -3.92432e-06 1.83904e-06 -4.00298e-06 1.48611e-06 -4.0651e-06 1.12133e-06 -4.11071e-06 7.46981e-07 -4.13972e-06 3.65222e-07 -4.1519e-06 -2.18096e-08 -4.14682e-06 -4.11929e-07 -4.12394e-06 -8.02823e-07 -4.08254e-06 -1.19197e-06 -4.02182e-06 -1.57654e-06 -3.94087e-06 -1.95334e-06 -3.83877e-06 -2.31874e-06 -3.71464e-06 -2.66855e-06 -3.56777e-06 -2.99804e-06 -3.39766e-06 -3.30187e-06 -3.20422e-06 -3.57408e-06 -2.98788e-06 -3.80811e-06 -2.74973e-06 -3.9969e-06 -2.49172e-06 -4.13298e-06 -2.21677e-06 -4.20865e-06 -1.92894e-06 -4.21626e-06 -1.63349e-06 -4.14844e-06 -1.33698e-06 -3.99856e-06 -1.04717e-06 -3.76105e-06 -7.73016e-07 -3.43185e-06 -5.24397e-07 -3.00881e-06 -3.11899e-07 -2.49205e-06 -1.46462e-07 -1.88417e-06 -3.90046e-08 -1.19036e-06 -4.18779e-07 -3.64283e-08 4.39365e-07 -1.35984e-07 1.23475e-06 -2.88301e-07 1.93878e-06 -4.82888e-07 2.54716e-06 -7.09561e-07 3.05857e-06 -9.58766e-07 3.47404e-06 -1.22184e-06 3.79658e-06 -1.49119e-06 4.0308e-06 -1.76037e-06 4.18253e-06 -2.02407e-06 4.25832e-06 -2.27812e-06 4.26515e-06 -2.51936e-06 4.21009e-06 -2.74553e-06 4.10009e-06 -2.95515e-06 3.94175e-06 -3.14737e-06 3.74122e-06 -3.32184e-06 3.50414e-06 -3.47856e-06 3.23557e-06 -3.61783e-06 2.94003e-06 -3.74008e-06 2.62148e-06 -3.84582e-06 2.28339e-06 -3.93558e-06 1.92879e-06 -4.00979e-06 1.56032e-06 -4.0688e-06 1.18034e-06 -4.1128e-06 7.90982e-07 -4.1418e-06 3.94223e-07 -4.15561e-06 -7.9974e-09 -4.15383e-06 -4.13707e-07 -4.13585e-06 -8.20806e-07 -4.10084e-06 -1.22697e-06 -4.04782e-06 -1.62956e-06 -3.97565e-06 -2.02552e-06 -3.88309e-06 -2.41129e-06 -3.76892e-06 -2.78272e-06 -3.63197e-06 -3.13499e-06 -3.4713e-06 -3.46254e-06 -3.28628e-06 -3.75909e-06 -3.07684e-06 -4.01756e-06 -2.84356e-06 -4.23018e-06 -2.58793e-06 -4.38861e-06 -2.31251e-06 -4.48407e-06 -2.02116e-06 -4.50761e-06 -1.71911e-06 -4.45049e-06 -1.41311e-06 -4.30456e-06 -1.11142e-06 -4.06274e-06 -8.23715e-07 -3.71956e-06 -5.60896e-07 -3.27163e-06 -3.3479e-07 -2.71815e-06 -1.57742e-07 -2.06122e-06 -4.21629e-08 -1.30594e-06 -4.60942e-07 -3.89022e-08 4.78267e-07 -1.4478e-07 1.34063e-06 -3.06012e-07 2.10001e-06 -5.10832e-07 2.75198e-06 -7.47869e-07 3.29561e-06 -1.00656e-06 3.73273e-06 -1.27744e-06 4.06746e-06 -1.55237e-06 4.30573e-06 -1.82456e-06 4.45472e-06 -2.08863e-06 4.52238e-06 -2.34047e-06 4.51699e-06 -2.57715e-06 4.44677e-06 -2.79674e-06 4.31968e-06 -2.99816e-06 4.14316e-06 -3.18098e-06 3.92405e-06 -3.34532e-06 3.66848e-06 -3.49164e-06 3.38189e-06 -3.62064e-06 3.06903e-06 -3.73315e-06 2.73399e-06 -3.83004e-06 2.38028e-06 -3.91214e-06 2.01089e-06 -3.98017e-06 1.62835e-06 -4.03469e-06 1.23487e-06 -4.07607e-06 8.32357e-07 -4.10443e-06 4.22584e-07 -4.11966e-06 7.23066e-09 -4.12137e-06 -4.11998e-07 -4.1089e-06 -8.33273e-07 -4.08133e-06 -1.25454e-06 -4.0375e-06 -1.67339e-06 -3.97602e-06 -2.087e-06 -3.89536e-06 -2.49196e-06 -3.79386e-06 -2.88421e-06 -3.66993e-06 -3.25892e-06 -3.52205e-06 -3.61042e-06 -3.34905e-06 -3.93209e-06 -3.15018e-06 -4.21642e-06 -2.92544e-06 -4.45493e-06 -2.67571e-06 -4.63834e-06 -2.40306e-06 -4.75671e-06 -2.11099e-06 -4.79969e-06 -1.80458e-06 -4.7569e-06 -1.49071e-06 -4.61843e-06 -1.17807e-06 -4.37539e-06 -8.77098e-07 -4.02052e-06 -5.9982e-07 -3.5489e-06 -3.59466e-07 -2.95851e-06 -1.70014e-07 -2.25067e-06 -4.56289e-08 -1.43032e-06 -5.0657e-07 -4.16591e-08 5.19926e-07 -1.545e-07 1.45347e-06 -3.2539e-07 2.2709e-06 -5.41035e-07 2.96762e-06 -7.88668e-07 3.54324e-06 -1.05655e-06 4.00061e-06 -1.33435e-06 4.34525e-06 -1.61332e-06 4.5847e-06 -1.8864e-06 4.72781e-06 -2.14818e-06 4.78416e-06 -2.39472e-06 4.76353e-06 -2.62343e-06 4.67548e-06 -2.83283e-06 4.52908e-06 -3.02234e-06 4.33267e-06 -3.19208e-06 4.09379e-06 -3.3427e-06 3.81909e-06 -3.47517e-06 3.51436e-06 -3.59068e-06 3.18454e-06 -3.69051e-06 2.83382e-06 -3.77593e-06 2.4657e-06 -3.84808e-06 2.08305e-06 -3.908e-06 1.68827e-06 -3.95648e-06 1.28334e-06 -3.99407e-06 8.69946e-07 -4.02104e-06 4.49558e-07 -4.03737e-06 2.35546e-08 -4.04268e-06 -4.06679e-07 -4.03631e-06 -8.39644e-07 -4.01724e-06 -1.27361e-06 -3.98413e-06 -1.7065e-06 -3.93537e-06 -2.13576e-06 -3.86909e-06 -2.55824e-06 -3.78324e-06 -2.97006e-06 -3.6757e-06 -3.36646e-06 -3.5444e-06 -3.74172e-06 -3.38746e-06 -4.08904e-06 -3.20343e-06 -4.40045e-06 -2.99153e-06 -4.66683e-06 -2.7519e-06 -4.87797e-06 -2.48596e-06 -5.02265e-06 -2.19666e-06 -5.08899e-06 -1.88879e-06 -5.06477e-06 -1.5692e-06 -4.93802e-06 -1.24695e-06 -4.69763e-06 -9.33279e-07 -4.3342e-06 -6.41403e-07 -3.84078e-06 -3.86159e-07 -3.21375e-06 -1.83429e-07 -2.4534e-06 -4.94541e-08 -1.5643e-06 -5.56025e-07 -4.47738e-08 5.647e-07 -1.65377e-07 1.57407e-06 -3.46834e-07 2.45236e-06 -5.74002e-07 3.19479e-06 -8.32446e-07 3.80169e-06 -1.10908e-06 4.27725e-06 -1.39258e-06 4.62876e-06 -1.67363e-06 4.86575e-06 -1.94494e-06 4.99912e-06 -2.20115e-06 5.04038e-06 -2.43867e-06 5.00104e-06 -2.65535e-06 4.89217e-06 -2.85033e-06 4.72405e-06 -3.02364e-06 4.50599e-06 -3.17608e-06 4.24622e-06 -3.3089e-06 3.95191e-06 -3.42368e-06 3.62914e-06 -3.52216e-06 3.28302e-06 -3.60608e-06 2.91774e-06 -3.67713e-06 2.53675e-06 -3.73684e-06 2.14276e-06 -3.78653e-06 1.73796e-06 -3.82725e-06 1.32407e-06 -3.85976e-06 9.02458e-07 -3.88449e-06 4.74281e-07 -3.90149e-06 4.05554e-08 -3.91046e-06 -3.97708e-07 -3.91071e-06 -8.39396e-07 -3.90114e-06 -1.28317e-06 -3.8803e-06 -1.72734e-06 -3.84633e-06 -2.16973e-06 -3.79705e-06 -2.60752e-06 -3.73e-06 -3.03711e-06 -3.64253e-06 -3.45392e-06 -3.53194e-06 -3.85232e-06 -3.39561e-06 -4.22537e-06 -3.23126e-06 -4.5648e-06 -3.03719e-06 -4.86089e-06 -2.81266e-06 -5.1025e-06 -2.55818e-06 -5.27713e-06 -2.27596e-06 -5.37121e-06 -1.97028e-06 -5.37046e-06 -1.64781e-06 -5.26049e-06 -1.31784e-06 -5.0276e-06 -9.92373e-07 -4.65966e-06 -6.8593e-07 -4.14722e-06 -4.1516e-07 -3.48452e-06 -1.9818e-07 -2.67038e-06 -5.37056e-08 -1.70877e-06 -6.0973e-07 -4.83455e-08 6.13046e-07 -1.77718e-07 1.70345e-06 -3.7086e-07 2.6455e-06 -6.1036e-07 3.43429e-06 -8.79788e-07 4.07112e-06 -1.16449e-06 4.56195e-06 -1.45209e-06 4.91635e-06 -1.73268e-06 5.14634e-06 -1.99886e-06 5.2653e-06 -2.24551e-06 5.28702e-06 -2.46949e-06 5.22503e-06 -2.66937e-06 5.09205e-06 -2.84499e-06 4.89967e-06 -2.9972e-06 4.6582e-06 -3.12756e-06 4.37658e-06 -3.23805e-06 4.0624e-06 -3.33092e-06 3.72201e-06 -3.40847e-06 3.36057e-06 -3.47299e-06 2.98226e-06 -3.52659e-06 2.59034e-06 -3.57118e-06 2.18735e-06 -3.60838e-06 1.77517e-06 -3.63952e-06 1.35521e-06 -3.66555e-06 9.2849e-07 -3.68706e-06 4.95786e-07 -3.70422e-06 5.77151e-08 -3.71679e-06 -3.85136e-07 -3.72409e-06 -8.32092e-07 -3.725e-06 -1.28227e-06 -3.71791e-06 -1.73443e-06 -3.7008e-06 -2.18685e-06 -3.67119e-06 -2.63713e-06 -3.62622e-06 -3.08207e-06 -3.56273e-06 -3.51742e-06 -3.47733e-06 -3.93772e-06 -3.36662e-06 -4.33608e-06 -3.22737e-06 -4.70404e-06 -3.05688e-06 -5.03139e-06 -2.85325e-06 -5.30613e-06 -2.61591e-06 -5.51447e-06 -2.34606e-06 -5.64106e-06 -2.04717e-06 -5.66934e-06 -1.72549e-06 -5.58218e-06 -1.39037e-06 -5.36272e-06 -1.05449e-06 -4.99554e-06 -7.33746e-07 -4.46797e-06 -4.46842e-07 -3.77142e-06 -2.14517e-07 -2.90271e-06 -5.84714e-08 -1.86482e-06 -6.68202e-07 -5.25068e-08 6.65552e-07 -1.91924e-07 1.84286e-06 -3.98127e-07 2.8517e-06 -6.50889e-07 3.68705e-06 -9.31379e-07 4.35161e-06 -1.22314e-06 4.85371e-06 -1.51265e-06 5.20586e-06 -1.78952e-06 5.42321e-06 -2.04636e-06 5.52215e-06 -2.27852e-06 5.51917e-06 -2.48359e-06 5.4301e-06 -2.66101e-06 5.26946e-06 -2.8116e-06 5.05026e-06 -2.93715e-06 4.78376e-06 -3.04012e-06 4.47955e-06 -3.1233e-06 4.14559e-06 -3.18968e-06 3.78838e-06 -3.24217e-06 3.41307e-06 -3.2836e-06 3.02368e-06 -3.31651e-06 2.62326e-06 -3.34319e-06 2.21403e-06 -3.36558e-06 1.79755e-06 -3.38522e-06 1.37485e-06 -3.4033e-06 9.46562e-07 -3.42054e-06 5.13026e-07 -3.43725e-06 7.44243e-08 -3.45326e-06 -3.69118e-07 -3.46795e-06 -8.17406e-07 -3.48016e-06 -1.27006e-06 -3.48824e-06 -1.72635e-06 -3.48998e-06 -2.1851e-06 -3.48269e-06 -2.64443e-06 -3.46313e-06 -3.10163e-06 -3.42763e-06 -3.55292e-06 -3.37216e-06 -3.99319e-06 -3.29247e-06 -4.41576e-06 -3.18435e-06 -4.81216e-06 -3.04388e-06 -5.17186e-06 -2.86789e-06 -5.48212e-06 -2.65442e-06 -5.72794e-06 -2.40333e-06 -5.89214e-06 -2.11698e-06 -5.9557e-06 -1.80082e-06 -5.89834e-06 -1.46399e-06 -5.69954e-06 -1.11971e-06 -5.33983e-06 -7.85271e-07 -4.80241e-06 -4.8168e-07 -4.07502e-06 -2.32772e-07 -3.15162e-06 -6.38688e-08 -2.03372e-06 -7.3207e-07 -5.74355e-08 7.22988e-07 -2.08524e-07 1.99395e-06 -4.29478e-07 3.07266e-06 -6.96545e-07 3.95412e-06 -9.87985e-07 4.64305e-06 -1.28528e-06 5.151e-06 -1.57375e-06 5.49433e-06 -1.84264e-06 5.6921e-06 -2.08487e-06 5.76438e-06 -2.29653e-06 5.73083e-06 -2.47625e-06 5.60982e-06 -2.62464e-06 5.41785e-06 -2.7437e-06 5.16932e-06 -2.83637e-06 4.87643e-06 -2.90611e-06 4.54929e-06 -2.95664e-06 4.19613e-06 -2.99169e-06 3.82342e-06 -3.01482e-06 3.4362e-06 -3.02937e-06 3.03823e-06 -3.03832e-06 2.63221e-06 -3.0443e-06 2.22001e-06 -3.04952e-06 1.80277e-06 -3.05576e-06 1.38109e-06 -3.06438e-06 9.55177e-07 -3.07626e-06 5.24908e-07 -3.09183e-06 8.99979e-08 -3.11104e-06 -3.49914e-07 -3.13329e-06 -7.95148e-07 -3.15749e-06 -1.24586e-06 -3.18195e-06 -1.7019e-06 -3.20439e-06 -2.16266e-06 -3.22191e-06 -2.62691e-06 -3.231e-06 -3.09255e-06 -3.22754e-06 -3.55638e-06 -3.20687e-06 -4.01385e-06 -3.16393e-06 -4.4587e-06 -3.09343e-06 -4.88266e-06 -2.99017e-06 -5.27512e-06 -2.84947e-06 -5.62282e-06 -2.66773e-06 -5.90969e-06 -2.44312e-06 -6.11676e-06 -2.1764e-06 -6.22241e-06 -1.87181e-06 -6.20293e-06 -1.53788e-06 -6.03347e-06 -1.18806e-06 -5.68964e-06 -8.41009e-07 -5.14946e-06 -5.20286e-07 -4.39574e-06 -2.5338e-07 -3.41852e-06 -7.00568e-08 -2.21704e-06 -8.02127e-07 -6.33736e-08 7.86361e-07 -2.28219e-07 2.1588e-06 -4.65991e-07 3.31043e-06 -7.48474e-07 4.2366e-06 -1.05041e-06 4.94498e-06 -1.35097e-06 5.45156e-06 -1.63435e-06 5.77771e-06 -1.88974e-06 5.94749e-06 -2.11071e-06 5.98536e-06 -2.29453e-06 5.91465e-06 -2.44127e-06 5.75655e-06 -2.55303e-06 5.52961e-06 -2.63325e-06 5.24955e-06 -2.68619e-06 4.92937e-06 -2.71646e-06 4.57956e-06 -2.72871e-06 4.20838e-06 -2.72746e-06 3.82217e-06 -2.71689e-06 3.42564e-06 -2.70083e-06 3.02216e-06 -2.68264e-06 2.61402e-06 -2.66523e-06 2.2026e-06 -2.65105e-06 1.78859e-06 -2.64207e-06 1.37211e-06 -2.63978e-06 9.52887e-07 -2.64521e-06 5.30342e-07 -2.65891e-06 1.03701e-07 -2.68093e-06 -3.27895e-07 -2.71079e-06 -7.65291e-07 -2.74745e-06 -1.2092e-06 -2.78926e-06 -1.66008e-06 -2.83394e-06 -2.11798e-06 -2.87852e-06 -2.58234e-06 -2.91926e-06 -3.0518e-06 -2.95172e-06 -3.52393e-06 -2.97069e-06 -3.99488e-06 -2.97034e-06 -4.45905e-06 -2.94433e-06 -4.90868e-06 -2.88609e-06 -5.33336e-06 -2.78927e-06 -5.71963e-06 -2.64834e-06 -6.05062e-06 -2.45936e-06 -6.30574e-06 -2.221e-06 -6.46077e-06 -1.93568e-06 -6.48825e-06 -1.61073e-06 -6.35843e-06 -1.2594e-06 -6.04097e-06 -9.0154e-07 -5.50732e-06 -5.63447e-07 -4.73383e-06 -2.7693e-07 -3.70504e-06 -7.72536e-08 -2.41672e-06 -8.79381e-07 -7.06549e-08 8.57016e-07 -2.51942e-07 2.34008e-06 -5.09034e-07 3.56752e-06 -8.08017e-07 4.53559e-06 -1.11939e-06 5.25635e-06 -1.41981e-06 5.75198e-06 -1.69258e-06 6.05048e-06 -1.92724e-06 6.18214e-06 -2.11861e-06 6.17673e-06 -2.2657e-06 6.06173e-06 -2.37047e-06 5.86133e-06 -2.43693e-06 5.59606e-06 -2.47022e-06 5.28284e-06 -2.47608e-06 4.93522e-06 -2.46032e-06 4.5638e-06 -2.42859e-06 4.17665e-06 -2.38613e-06 3.77971e-06 -2.3377e-06 3.37721e-06 -2.28753e-06 2.97199e-06 -2.23928e-06 2.56578e-06 -2.19608e-06 2.1594e-06 -2.16051e-06 1.75302e-06 -2.13468e-06 1.34627e-06 -2.12018e-06 9.3839e-07 -2.11815e-06 5.28311e-07 -2.12924e-06 1.1479e-07 -2.15361e-06 -3.03526e-07 -2.1909e-06 -7.27997e-07 -2.24021e-06 -1.15989e-06 -2.3e-06 -1.60029e-06 -2.36809e-06 -2.04989e-06 -2.44151e-06 -2.50892e-06 -2.51649e-06 -2.97682e-06 -2.58836e-06 -3.45205e-06 -2.65154e-06 -3.9317e-06 -2.69953e-06 -4.41107e-06 -2.72501e-06 -4.8832e-06 -2.72006e-06 -5.33831e-06 -2.67655e-06 -5.76315e-06 -2.58673e-06 -6.14043e-06 -2.44415e-06 -6.44832e-06 -2.24478e-06 -6.66015e-06 -1.98846e-06 -6.74457e-06 -1.68053e-06 -6.66636e-06 -1.33334e-06 -6.38815e-06 -9.67502e-07 -5.87316e-06 -6.12172e-07 -5.08916e-06 -3.04217e-07 -4.013e-06 -8.57647e-08 -2.63517e-06 -9.65146e-07 -7.97492e-08 9.36765e-07 -2.8095e-07 2.54129e-06 -5.60339e-07 3.84691e-06 -8.76673e-07 4.85192e-06 -1.1954e-06 5.57508e-06 -1.4906e-06 6.04718e-06 -1.74512e-06 6.30501e-06 -1.94963e-06 6.38664e-06 -2.10098e-06 6.32809e-06 -2.20062e-06 6.16137e-06 -2.25302e-06 5.91373e-06 -2.26446e-06 5.6075e-06 -2.24206e-06 5.26045e-06 -2.19315e-06 4.88631e-06 -2.1248e-06 4.49545e-06 -2.04356e-06 4.0954e-06 -1.95533e-06 3.69148e-06 -1.86532e-06 3.2872e-06 -1.77803e-06 2.88471e-06 -1.69731e-06 2.48505e-06 -1.62636e-06 2.08845e-06 -1.56785e-06 1.69451e-06 -1.52389e-06 1.30232e-06 -1.49614e-06 9.10639e-07 -1.48578e-06 5.17951e-07 -1.49355e-06 1.22555e-07 -1.51971e-06 -2.77357e-07 -1.56408e-06 -6.83631e-07 -1.62591e-06 -1.09807e-06 -1.70387e-06 -1.52232e-06 -1.79596e-06 -1.9578e-06 -1.8994e-06 -2.40548e-06 -2.01052e-06 -2.8657e-06 -2.12465e-06 -3.33792e-06 -2.23601e-06 -3.82033e-06 -2.33765e-06 -4.30942e-06 -2.42145e-06 -4.7994e-06 -2.47823e-06 -5.28153e-06 -2.49806e-06 -5.74332e-06 -2.47082e-06 -6.16767e-06 -2.38711e-06 -6.53203e-06 -2.23952e-06 -6.80773e-06 -2.02444e-06 -6.95965e-06 -1.7441e-06 -6.9467e-06 -1.40893e-06 -6.72332e-06 -1.03951e-06 -6.24258e-06 -6.67743e-07 -5.46093e-06 -3.36328e-07 -4.34441e-06 -9.60269e-08 -2.87547e-06 -1.06117e-06 -9.13331e-08 1.0281e-06 -3.16957e-07 2.76691e-06 -6.22069e-07 4.15202e-06 -9.55977e-07 5.18583e-06 -1.27825e-06 5.89736e-06 -1.56064e-06 6.32957e-06 -1.78644e-06 6.53081e-06 -1.94853e-06 6.54873e-06 -2.04691e-06 6.42647e-06 -2.08638e-06 6.20084e-06 -2.07455e-06 5.9019e-06 -2.02038e-06 5.55333e-06 -1.93316e-06 5.17323e-06 -1.82185e-06 4.775e-06 -1.69466e-06 4.36826e-06 -1.55895e-06 3.95969e-06 -1.42109e-06 3.55362e-06 -1.28655e-06 3.15266e-06 -1.15993e-06 2.75809e-06 -1.04508e-06 2.3702e-06 -9.45165e-07 1.98853e-06 -8.62756e-07 1.6121e-06 -7.99918e-07 1.23948e-06 -7.58254e-07 8.68976e-07 -7.38949e-07 4.98646e-07 -7.42788e-07 1.26394e-07 -7.70154e-07 -2.49991e-07 -8.21009e-07 -6.32776e-07 -8.94845e-07 -1.02423e-06 -9.90611e-07 -1.42656e-06 -1.10662e-06 -1.84179e-06 -1.24042e-06 -2.27168e-06 -1.38866e-06 -2.71747e-06 -1.54689e-06 -3.17969e-06 -1.70942e-06 -3.6578e-06 -1.86916e-06 -4.14969e-06 -2.01745e-06 -4.65111e-06 -2.14412e-06 -5.15486e-06 -2.23757e-06 -5.64987e-06 -2.28526e-06 -6.11998e-06 -2.27452e-06 -6.54278e-06 -2.19392e-06 -6.88833e-06 -2.03529e-06 -7.11828e-06 -1.79642e-06 -7.18556e-06 -1.48423e-06 -7.03551e-06 -1.118e-06 -6.60882e-06 -7.31756e-07 -5.84717e-06 -3.74771e-07 -4.70139e-06 -1.0868e-07 -3.14156e-06 -1.16985e-06 -1.06412e-07 1.13451e-06 -3.62318e-07 3.02282e-06 -6.96863e-07 4.48657e-06 -1.04721e-06 5.53617e-06 -1.36641e-06 6.21656e-06 -1.62472e-06 6.58787e-06 -1.80741e-06 6.7135e-06 -1.91125e-06 6.65258e-06 -1.94084e-06 6.45605e-06 -1.90534e-06 6.16535e-06 -1.81618e-06 5.81273e-06 -1.68531e-06 5.42246e-06 -1.52423e-06 5.01215e-06 -1.34341e-06 4.59418e-06 -1.15204e-06 4.17689e-06 -9.57971e-07 3.76562e-06 -7.67805e-07 3.36345e-06 -5.86994e-07 2.97185e-06 -4.20006e-07 2.59111e-06 -2.70473e-07 2.22067e-06 -1.41328e-07 1.85939e-06 -3.49251e-08 1.50569e-06 4.68634e-08 1.15769e-06 1.0257e-07 8.13269e-07 1.31081e-07 4.70136e-07 1.31604e-07 1.25871e-07 1.03665e-07 -2.22052e-07 4.7124e-08 -5.76234e-07 -3.7779e-08 -9.39328e-07 -1.5035e-07 -1.31399e-06 -2.89337e-07 -1.70281e-06 -4.52788e-07 -2.10823e-06 -6.37873e-07 -2.53238e-06 -8.4067e-07 -2.97689e-06 -1.05592e-06 -3.44255e-06 -1.27676e-06 -3.92885e-06 -1.49445e-06 -4.43341e-06 -1.69823e-06 -4.95109e-06 -1.8752e-06 -5.4729e-06 -2.01057e-06 -5.98461e-06 -2.08828e-06 -6.46507e-06 -2.09231e-06 -6.8843e-06 -2.00886e-06 -7.20174e-06 -1.82951e-06 -7.36491e-06 -1.55555e-06 -7.30947e-06 -1.20281e-06 -6.96156e-06 -8.06118e-07 -6.24386e-06 -4.21645e-07 -5.08587e-06 -1.24691e-07 -3.43852e-06 -1.29454e-06 -1.2653e-07 1.26104e-06 -4.203e-07 3.31658e-06 -7.8777e-07 4.85404e-06 -1.15072e-06 5.89912e-06 -1.45569e-06 6.52153e-06 -1.6733e-06 6.80548e-06 -1.79334e-06 6.83353e-06 -1.81883e-06 6.67807e-06 -1.76068e-06 6.3979e-06 -1.63358e-06 6.03825e-06 -1.45325e-06 5.63241e-06 -1.23476e-06 5.20397e-06 -9.91653e-07 4.76904e-06 -7.35582e-07 4.33811e-06 -4.7629e-07 3.9176e-06 -2.21744e-07 3.51108e-06 2.16404e-08 3.12007e-06 2.48757e-07 2.74473e-06 4.5557e-07 2.38429e-06 6.38905e-07 2.03733e-06 7.96266e-07 1.70203e-06 9.25689e-07 1.37627e-06 1.02562e-06 1.05776e-06 1.09483e-06 7.44061e-07 1.13234e-06 4.32621e-07 1.13741e-06 1.20798e-07 1.10951e-06 -1.94143e-07 1.0483e-06 -5.15025e-07 9.53729e-07 -8.4476e-07 8.26075e-07 -1.18633e-06 6.66043e-07 -1.54277e-06 4.74927e-07 -1.91711e-06 2.548e-07 -2.31225e-06 8.76361e-09 -2.73086e-06 -2.58742e-07 -3.17504e-06 -5.41579e-07 -3.64602e-06 -8.31509e-07 -4.14348e-06 -1.11779e-06 -4.6648e-06 -1.38685e-06 -5.20384e-06 -1.62216e-06 -5.7493e-06 -1.80452e-06 -6.28271e-06 -1.91305e-06 -6.77577e-06 -1.92726e-06 -7.18752e-06 -1.83064e-06 -7.46153e-06 -1.61601e-06 -7.52411e-06 -1.29245e-06 -7.28511e-06 -8.92908e-07 -6.6434e-06 -4.79889e-07 -5.49889e-06 -1.45567e-07 -3.77284e-06 -1.44011e-06 -1.54146e-07 1.41519e-06 -4.95424e-07 3.65786e-06 -8.97887e-07 5.2565e-06 -1.26455e-06 6.26579e-06 -1.53691e-06 6.7939e-06 -1.68965e-06 6.95822e-06 -1.72095e-06 6.86484e-06 -1.64316e-06 6.60028e-06 -1.47547e-06 6.23021e-06 -1.239e-06 5.80178e-06 -9.54e-07 5.3474e-06 -6.38346e-07 4.88832e-06 -3.07086e-07 4.43778e-06 2.75645e-08 4.00346e-06 3.55936e-07 3.58923e-06 6.70522e-07 3.19649e-06 9.6558e-07 2.82501e-06 1.23677e-06 2.47355e-06 1.48081e-06 2.14025e-06 1.69527e-06 1.82288e-06 1.87829e-06 1.51901e-06 2.02846e-06 1.2261e-06 2.14467e-06 9.41548e-07 2.22603e-06 6.627e-07 2.27179e-06 3.86866e-07 2.28128e-06 1.11303e-07 2.25395e-06 -1.66805e-07 2.18929e-06 -4.50368e-07 2.08694e-06 -7.42413e-07 1.94671e-06 -1.0461e-06 1.76868e-06 -1.36475e-06 1.55335e-06 -1.70178e-06 1.30183e-06 -2.06073e-06 1.0161e-06 -2.44513e-06 6.99377e-07 -2.85832e-06 3.56516e-07 -3.30315e-06 -5.42277e-09 -3.78154e-06 -3.76578e-07 -4.29365e-06 -7.43642e-07 -4.83677e-06 -1.0893e-06 -5.40364e-06 -1.39198e-06 -5.98003e-06 -1.62621e-06 -6.54154e-06 -1.76427e-06 -7.04947e-06 -1.77962e-06 -7.44617e-06 -1.65317e-06 -7.65056e-06 -1.38253e-06 -7.55575e-06 -9.93876e-07 -7.03206e-06 -5.5358e-07 -5.93918e-06 -1.73736e-07 -4.15269e-06 -1.61385e-06 -1.93285e-07 1.60847e-06 -5.93791e-07 4.05837e-06 -1.02921e-06 5.69192e-06 -1.38152e-06 6.6181e-06 -1.59177e-06 7.00414e-06 -1.64519e-06 7.01163e-06 -1.55393e-06 6.77358e-06 -1.34328e-06 6.38963e-06 -1.04244e-06 5.92937e-06 -6.79371e-07 5.43871e-06 -2.78322e-07 4.94635e-06 1.40894e-07 4.4691e-06 5.62755e-07 4.01592e-06 9.75474e-07 3.59074e-06 1.37033e-06 3.19438e-06 1.74099e-06 2.82583e-06 2.08297e-06 2.48303e-06 2.39314e-06 2.16338e-06 2.66934e-06 1.86404e-06 2.91011e-06 1.58211e-06 3.11443e-06 1.31469e-06 3.2816e-06 1.05894e-06 3.41105e-06 8.12095e-07 3.50231e-06 5.71438e-07 3.5549e-06 3.3427e-07 3.56832e-06 9.78843e-08 3.54199e-06 -1.40477e-07 3.47529e-06 -3.83661e-07 3.36753e-06 -6.34656e-07 3.21805e-06 -8.96627e-07 3.02627e-06 -1.17296e-06 2.79179e-06 -1.4673e-06 2.51461e-06 -1.78355e-06 2.19535e-06 -2.12586e-06 1.83559e-06 -2.49856e-06 1.43838e-06 -2.90594e-06 1.00882e-06 -3.35199e-06 5.54892e-07 -3.83972e-06 8.83563e-08 -4.37024e-06 -3.74153e-07 -4.94113e-06 -8.10174e-07 -5.54401e-06 -1.19087e-06 -6.16084e-06 -1.48157e-06 -6.75877e-06 -1.64448e-06 -7.28326e-06 -1.6449e-06 -7.65013e-06 -1.46263e-06 -7.73802e-06 -1.10906e-06 -7.38563e-06 -6.48149e-07 -6.4001e-06 -2.13211e-07 -4.58762e-06 -1.82706e-06 -2.50658e-07 1.85913e-06 -7.2297e-07 4.53068e-06 -1.17954e-06 6.14849e-06 -1.48339e-06 6.92196e-06 -1.58555e-06 7.1063e-06 -1.49223e-06 6.91831e-06 -1.23666e-06 6.51801e-06 -8.60517e-07 6.01349e-06 -4.0378e-07 5.47263e-06 9.96542e-08 4.93528e-06 6.2309e-07 4.42292e-06 1.14654e-06 3.94565e-06 1.65563e-06 3.50684e-06 2.14034e-06 3.10602e-06 2.59399e-06 2.74073e-06 3.01224e-06 2.40758e-06 3.39245e-06 2.10281e-06 3.73314e-06 1.82269e-06 4.03356e-06 1.56363e-06 4.29343e-06 1.32224e-06 4.51273e-06 1.09538e-06 4.69154e-06 8.80127e-07 4.82993e-06 6.73706e-07 4.92788e-06 4.73484e-07 4.98525e-06 2.76905e-07 5.00169e-06 8.14393e-08 4.97669e-06 -1.1547e-07 4.90949e-06 -3.16465e-07 4.79916e-06 -5.24328e-07 4.64458e-06 -7.42048e-07 4.44451e-06 -9.72884e-07 4.19764e-06 -1.22043e-06 3.90278e-06 -1.48869e-06 3.55903e-06 -1.78211e-06 3.16608e-06 -2.10561e-06 2.72467e-06 -2.46454e-06 2.23723e-06 -2.86455e-06 1.70874e-06 -3.31123e-06 1.14794e-06 -3.80944e-06 5.68805e-07 -4.36199e-06 -7.68782e-09 -4.96752e-06 -5.51798e-07 -5.61673e-06 -1.02387e-06 -6.28669e-06 -1.37512e-06 -6.93201e-06 -1.55243e-06 -7.47283e-06 -1.5103e-06 -7.78015e-06 -1.23334e-06 -7.66259e-06 -7.70034e-07 -6.8634e-06 -2.70679e-07 -5.08698e-06 -2.09774e-06 -3.37331e-07 2.19646e-06 -8.90086e-07 5.08343e-06 -1.33479e-06 6.59319e-06 -1.52924e-06 7.11641e-06 -1.45463e-06 7.03169e-06 -1.15297e-06 6.61665e-06 -6.85898e-07 6.05094e-06 -1.1308e-07 5.44067e-06 5.16379e-07 4.84317e-06 1.16559e-06 4.28606e-06 1.80855e-06 3.77996e-06 2.42782e-06 3.32638e-06 3.01234e-06 2.92231e-06 3.55553e-06 2.56283e-06 4.05383e-06 2.24243e-06 4.50572e-06 1.95569e-06 4.91092e-06 1.69762e-06 5.26989e-06 1.46372e-06 5.58351e-06 1.25001e-06 5.85278e-06 1.05296e-06 6.07874e-06 8.69431e-07 6.26226e-06 6.96605e-07 6.40405e-06 5.31913e-07 6.50457e-06 3.72963e-07 6.564e-06 2.1748e-07 6.58219e-06 6.32435e-08 6.5587e-06 -9.19769e-08 6.49271e-06 -2.5048e-07 6.38309e-06 -4.147e-07 6.22832e-06 -5.87278e-07 6.02658e-06 -7.71144e-07 5.77574e-06 -9.69598e-07 5.47346e-06 -1.18642e-06 5.11731e-06 -1.42596e-06 4.70497e-06 -1.69326e-06 4.2346e-06 -1.99417e-06 3.7054e-06 -2.33534e-06 3.1184e-06 -2.72424e-06 2.47776e-06 -3.16879e-06 1.79249e-06 -3.67672e-06 1.07891e-06 -4.25394e-06 3.63707e-07 -4.90153e-06 -3.12802e-07 -5.61018e-06 -8.9419e-07 -6.35062e-06 -1.30891e-06 -7.05811e-06 -1.47961e-06 -7.60945e-06 -1.3482e-06 -7.794e-06 -9.24244e-07 -7.28736e-06 -3.57068e-07 -5.65415e-06 -2.4548e-06 -4.6996e-07 2.66642e-06 -1.09372e-06 5.70719e-06 -1.45074e-06 6.95021e-06 -1.43317e-06 7.09884e-06 -1.08606e-06 6.68457e-06 -5.04081e-07 6.03467e-06 2.19014e-07 5.32785e-06 1.00894e-06 4.65074e-06 1.81337e-06 4.03874e-06 2.59831e-06 3.50113e-06 3.34323e-06 3.03504e-06 4.03687e-06 2.63274e-06 4.67392e-06 2.28526e-06 5.25279e-06 1.98396e-06 5.77408e-06 1.72114e-06 6.23957e-06 1.49019e-06 6.65164e-06 1.28555e-06 7.01281e-06 1.10255e-06 7.32557e-06 9.37259e-07 7.59216e-06 7.86362e-07 7.81458e-06 6.47012e-07 7.99445e-06 5.16733e-07 8.13304e-06 3.93324e-07 8.23122e-06 2.74782e-07 8.28947e-06 1.59234e-07 8.30784e-06 4.48726e-08 8.28597e-06 -7.01037e-08 8.22304e-06 -1.87549e-07 8.11777e-06 -3.09434e-07 7.96841e-06 -4.37915e-07 7.77268e-06 -5.75418e-07 7.52781e-06 -7.24725e-07 7.23049e-06 -8.891e-07 6.87695e-06 -1.07241e-06 6.46301e-06 -1.27932e-06 5.98428e-06 -1.51545e-06 5.43655e-06 -1.78761e-06 4.81633e-06 -2.10402e-06 4.12199e-06 -2.47445e-06 3.3554e-06 -2.91014e-06 2.52466e-06 -3.4232e-06 1.64803e-06 -4.0249e-06 7.59427e-07 -4.72158e-06 -8.50519e-08 -5.50614e-06 -8.01641e-07 -6.34152e-06 -1.27996e-06 -7.13112e-06 -1.40314e-06 -7.67083e-06 -1.1052e-06 -7.5853e-06 -4.8826e-07 -6.27109e-06 -2.94306e-06 -6.65456e-07 3.33188e-06 -1.29643e-06 6.33817e-06 -1.41128e-06 7.06506e-06 -1.02356e-06 6.71113e-06 -2.86789e-07 5.9478e-06 6.42029e-07 5.10585e-06 1.64473e-06 4.32515e-06 2.64511e-06 3.65035e-06 3.59938e-06 3.08447e-06 4.48529e-06 2.61522e-06 5.29382e-06 2.22651e-06 6.02346e-06 1.9031e-06 6.67675e-06 1.63197e-06 7.25813e-06 1.40259e-06 7.77271e-06 1.20656e-06 8.22567e-06 1.03723e-06 8.62186e-06 8.89365e-07 8.96564e-06 7.58769e-07 9.26083e-06 6.42066e-07 9.5107e-06 5.36497e-07 9.71794e-06 4.39768e-07 9.88474e-06 3.49933e-07 1.00128e-05 2.653e-07 1.01032e-05 1.8436e-07 1.01567e-05 1.05719e-07 1.01735e-05 2.8048e-08 1.01534e-05 -4.99683e-08 1.00955e-05 -1.29682e-07 9.99863e-06 -2.12535e-07 9.86083e-06 -3.00115e-07 9.67964e-06 -3.94229e-07 9.4519e-06 -4.96985e-07 9.1737e-06 -6.10897e-07 8.84031e-06 -7.3903e-07 8.44616e-06 -8.8517e-07 7.98478e-06 -1.05407e-06 7.4489e-06 -1.25172e-06 6.83069e-06 -1.48581e-06 6.12237e-06 -1.76613e-06 5.31735e-06 -2.10512e-06 4.4125e-06 -2.51835e-06 3.41205e-06 -3.02446e-06 2.33421e-06 -3.64374e-06 1.22122e-06 -4.39316e-06 1.53106e-07 -5.27341e-06 -7.39212e-07 -6.2388e-06 -1.2748e-06 -7.13525e-06 -1.26761e-06 -7.59249e-06 -6.78205e-07 -6.86049e-06 -3.62127e-06 -9.14885e-07 4.24676e-06 -1.34487e-06 6.76816e-06 -9.38525e-07 6.65871e-06 2.60825e-08 5.74652e-06 1.25639e-06 4.7175e-06 2.55349e-06 3.80875e-06 3.8048e-06 3.07384e-06 4.95741e-06 2.49774e-06 5.99296e-06 2.04893e-06 6.91084e-06 1.69734e-06 7.71854e-06 1.41881e-06 8.42652e-06 1.19512e-06 9.04567e-06 1.01282e-06 9.58618e-06 8.62079e-07 1.00571e-05 7.3565e-07 1.04662e-05 6.28137e-07 1.08201e-05 5.35471e-07 1.11243e-05 4.54532e-07 1.13835e-05 3.82887e-07 1.16014e-05 3.18601e-07 1.17811e-05 2.60105e-07 1.19249e-05 2.06095e-07 1.20347e-05 1.55459e-07 1.21119e-05 1.07216e-07 1.21571e-05 6.04761e-08 1.21708e-05 1.4397e-08 1.21527e-05 -3.18518e-08 1.21021e-05 -7.91211e-08 1.20179e-05 -1.2832e-07 1.18982e-05 -1.80455e-07 1.17407e-05 -2.36685e-07 1.15421e-05 -2.98376e-07 1.12983e-05 -3.67185e-07 1.10045e-05 -4.45171e-07 1.06543e-05 -5.3494e-07 1.024e-05 -6.39851e-07 9.75263e-06 -7.6431e-07 9.181e-06 -9.14187e-07 8.51228e-06 -1.09741e-06 7.73196e-06 -1.32479e-06 6.82485e-06 -1.61124e-06 5.77756e-06 -1.97716e-06 4.58383e-06 -2.45e-06 3.25523e-06 -3.06456e-06 1.84048e-06 -3.85866e-06 4.55406e-07 -4.85373e-06 -6.82949e-07 -5.99689e-06 -1.24674e-06 -7.0287e-06 -9.11018e-07 -7.19621e-06 -4.53229e-06 -1.08501e-06 5.33177e-06 -7.6008e-07 6.44323e-06 5.81919e-07 5.31671e-06 2.29632e-06 4.03212e-06 4.01457e-06 2.99924e-06 5.57875e-06 2.24458e-06 6.94181e-06 1.71077e-06 8.10717e-06 1.33238e-06 9.09694e-06 1.05916e-06 9.9372e-06 8.57071e-07 1.06522e-05 7.03803e-07 1.12626e-05 5.84736e-07 1.17852e-05 4.90171e-07 1.22338e-05 4.13548e-07 1.26191e-05 3.5032e-07 1.295e-05 2.97266e-07 1.32334e-05 2.52044e-07 1.3475e-05 2.12913e-07 1.36794e-05 1.78551e-07 1.385e-05 1.47928e-07 1.39899e-05 1.20225e-07 1.41012e-05 9.47705e-08 1.41857e-05 7.10019e-08 1.42445e-05 4.84284e-08 1.42783e-05 2.66083e-08 1.42876e-05 5.12696e-09 1.42722e-05 -1.64221e-08 1.42315e-05 -3.84555e-08 1.41646e-05 -6.14182e-08 1.407e-05 -8.58066e-08 1.39455e-05 -1.12194e-07 1.37884e-05 -1.41265e-07 1.3595e-05 -1.73861e-07 1.33609e-05 -2.1104e-07 1.30801e-05 -2.54169e-07 1.27453e-05 -3.05048e-07 1.23471e-05 -3.66102e-07 1.18736e-05 -4.40675e-07 1.13097e-05 -5.33481e-07 1.06362e-05 -6.51337e-07 9.82935e-06 -8.04348e-07 8.86002e-06 -1.00783e-06 7.69542e-06 -1.28541e-06 6.30447e-06 -1.67361e-06 4.67329e-06 -2.22747e-06 2.84041e-06 -3.02085e-06 9.65436e-07 -4.12192e-06 -5.58734e-07 -5.50453e-06 -1.0353e-06 -6.71964e-06 -5.56759e-06 -1.21773e-07 5.45355e-06 1.8254e-06 4.49605e-06 4.40375e-06 2.73836e-06 6.71907e-06 1.7168e-06 8.60206e-06 1.11625e-06 1.00917e-05 7.5491e-07 1.12679e-05 5.34584e-07 1.22046e-05 3.95711e-07 1.29599e-05 3.03892e-07 1.35768e-05 2.40138e-07 1.40867e-05 1.93894e-07 1.45124e-05 1.59086e-07 1.48705e-05 1.32066e-07 1.51735e-05 1.10543e-07 1.54308e-05 9.30168e-08 1.56496e-05 7.84676e-08 1.58354e-05 6.6176e-08 1.59927e-05 5.562e-08 1.61249e-05 4.64098e-08 1.62345e-05 3.82472e-08 1.63239e-05 3.08975e-08 1.63945e-05 2.41711e-08 1.64476e-05 1.79101e-08 1.6484e-05 1.19784e-08 1.65044e-05 6.25411e-09 1.65089e-05 6.24589e-10 1.64975e-05 -5.02374e-09 1.64698e-05 -1.08019e-08 1.64252e-05 -1.6833e-08 1.63627e-05 -2.32529e-08 1.62807e-05 -3.02202e-08 1.61774e-05 -3.7925e-08 1.60501e-05 -4.66035e-08 1.58956e-05 -5.65564e-08 1.57096e-05 -6.81763e-08 1.54866e-05 -8.19895e-08 1.52192e-05 -9.87191e-08 1.48979e-05 -1.19388e-07 1.45099e-05 -1.45489e-07 1.40379e-05 -1.79291e-07 1.34579e-05 -2.24389e-07 1.27368e-05 -2.86763e-07 1.18283e-05 -3.76863e-07 1.06684e-05 -5.13749e-07 9.17373e-06 -7.32767e-07 7.25031e-06 -1.09743e-06 4.84482e-06 -1.71643e-06 2.12579e-06 -2.78549e-06 1.12813e-08 -4.60514e-06 -5.55631e-06 5.45355e-06 9.9496e-06 1.2688e-05 1.44048e-05 1.5521e-05 1.62759e-05 1.68105e-05 1.72062e-05 1.75101e-05 1.77502e-05 1.79441e-05 1.81032e-05 1.82353e-05 1.83458e-05 1.84388e-05 1.85173e-05 1.85835e-05 1.86391e-05 1.86855e-05 1.87238e-05 1.87547e-05 1.87788e-05 1.87967e-05 1.88087e-05 1.8815e-05 1.88156e-05 1.88106e-05 1.87998e-05 1.87829e-05 1.87597e-05 1.87295e-05 1.86915e-05 1.86449e-05 1.85884e-05 1.85202e-05 1.84382e-05 1.83395e-05 1.82201e-05 1.80746e-05 1.78953e-05 1.76709e-05 1.73842e-05 1.70073e-05 1.64936e-05 1.57608e-05 1.46634e-05 1.29469e-05 1.01614e-05 5.55631e-06 ) ; boundaryField { movingWall { type calculated; value uniform 0; } fixedWalls { type calculated; value uniform 0; } frontAndBack { type empty; value nonuniform 0(); } } // ************************************************************************* //
[ "patricksinclair@hotmail.co.uk" ]
patricksinclair@hotmail.co.uk
2dcb74ae91136ea5f3112ec8053cfab6565b9d3f
a72b2715cf19d09dc039aaf82c9d28e4dd0d45f5
/DesignPatterns/FlyWeightDesignPattern/FlyWeightDesignPattern/main.cpp
47dd20a5cedc2ecc26ed9256578c06aa677ca3a4
[]
no_license
LibbyXu/OOD-Cplusplus
874415cb87774d6e59025f7b1025518b386a40d4
ec93185eb941a341d537deed6c3da0050df40326
refs/heads/main
2023-04-30T17:47:27.418743
2021-05-21T04:49:54
2021-05-21T04:49:54
369,416,194
0
0
null
null
null
null
UTF-8
C++
false
false
1,625
cpp
// // main.cpp // FlyWeightDesignPattern // // Created by Lihua Xu on 5/13/21. // #include <iostream> #include <map> #include <string> using namespace std; class Flyweight { public: virtual void Operation(int extrinsicstate) = 0; virtual ~Flyweight() {} }; class ConcreteFlyweight : public Flyweight { public: void Operation(int extrinsicstate) { cout << "ConcreteFlyweight: " << extrinsicstate << endl; } }; class UnsharedConcreteFlyweight : public Flyweight { // 不强制共享对象,但也可以共享 public: void Operation(int extrinsicstate) { cout << "UnsharedConcreteFlyweight: " << extrinsicstate << endl; } }; class FlyweightFactory { private: map<string, Flyweight*> flyweights; public: Flyweight* GetFlyweight(string key) { if (flyweights[key] == NULL) flyweights[key] = new ConcreteFlyweight(); return (Flyweight*)flyweights[key]; } }; int main() { int extrinsicstate = 22; // 外部状态 FlyweightFactory* f = new FlyweightFactory(); Flyweight* fx = f->GetFlyweight("X"); // X、Y、Z为内部状态 fx->Operation(--extrinsicstate); // ConcreteFlyweight: 21 Flyweight* fy = f->GetFlyweight("Y"); fy->Operation(--extrinsicstate); // ConcreteFlyweight: 20 Flyweight* fz = f->GetFlyweight("Z"); // ConcreteFlyweight: 19 fz->Operation(--extrinsicstate); UnsharedConcreteFlyweight* uf = new UnsharedConcreteFlyweight(); uf->Operation(--extrinsicstate); // UnsharedConcreteFlyweight: 18 delete fx; delete fy; delete fz; delete f; delete uf; return 0; }
[ "xulihua66@hotmail.com" ]
xulihua66@hotmail.com
ae4d4404b8f252142a4be4101227f4bd8eec45d3
ebd4e808e095a35c223564a45221299cd34f492c
/appleleetcode.cpp
58edda449750757d523640710751bac8c1161dae
[]
no_license
urjagl/Interview-Algorithms-Data-Structures
7f99da432278fdd5b93632f8c7ed251215e0a7a4
dd7a16e88e7bacf32638e48fd5f8b35a4a82f7ec
refs/heads/master
2020-03-20T16:38:07.676999
2018-06-20T14:01:31
2018-06-20T14:01:31
137,543,108
0
0
null
null
null
null
UTF-8
C++
false
false
10,106
cpp
vector<int> productExceptSelf(vector<int>& nums) { int n=nums.size(); vector<int> fromBegin(n); fromBegin[0]=1; vector<int> fromLast(n); fromLast[n-1]=1; for(int i=1;i<n;i++) fromBegin[i]=fromBegin[i-1]*nums[i-1]; for(int i=n-2;i>=0;i--) fromLast[i]=fromLast[i+1]*nums[i+1]; vector<int> res(n); for(int i=0;i<n;i++) res[i]=fromBegin[i]*fromLast[i]; return res; } //Construct a temp array left such that left[i] contains the product of all elements on left of arr[i] excluding arr[i] //Construct another temporary array right such that right[i] contains the product of all elements on right of arr[i] excluding arr[i] // To get the product, multiply left and right vector<int> productExceptSelf(vector<int>& nums) { int n = nums.size(); int fromBegin = 1; int fromLast = 1; vector<int> result(n,1); for(int i= 0; i< n; i++){ result[i] = result[i]*fromBegin; fromBegin = fromBegin* nums[i]; result[n-1-i] = result[n-1-i] * fromLast; fromLast = fromLast * nums[n-1-i]; } return result; } // Two Sum vector<int> twoSum(vector<int>& nums, int target) { vector<int> result; std::unordered_map<int,int> indices; for(int i = 0; i < nums.size(); ++i){ indices[nums[i]] = i; } for(int i = 0; i < nums.size(); ++i){ int lookfor = target - nums[i]; if(indices.find(lookfor) != indices.end() && indices[lookfor] != i){ result.emplace_back(i); result.emplace_back(indices[lookfor]); break; } } return result; } // Reverse Linked List ListNode* reverseList(ListNode* head) { ListNode *prev; ListNode *curr; ListNode *temp; prev = NULL; curr = head; while(curr != NULL){ temp = curr->next; curr->next = prev; prev = curr; curr = temp; } head = prev; return head; } // Delete the node from a linked list, given only an access to the node void deleteNode(ListNode* node) { node->val = node->next->val; node->next = node->next->next; } //Hamming weight: int hammingWeight(uint32_t n) { int count = 0; while (n) { if((n & 1) == 1) count++; n = n >> 1; } return count; } // Ransome Note bool canConstruct(string ransomNote, string magazine) { std::unordered_map<char, int> mag; for(auto c: magazine){ mag[c]++; } for (auto c: ransomNote){ if(mag[c] == 0){ return false; } else{ mag[c]--; } } return true; } //Peeking Iterator: class PeekingIterator : public Iterator { private: int m_next; bool m_hasnext; public: PeekingIterator(const vector<int>& nums) : Iterator(nums) { m_hasnext = Iterator::hasNext(); if (m_hasnext) m_next = Iterator::next(); } int peek() { return m_next; } int next() { int t = m_next; m_hasnext = Iterator::hasNext(); if (m_hasnext) m_next = Iterator::next(); return t; } bool hasNext() const { return m_hasnext; } }; //Fib stairs int climbStairs(int n) { if (n == 1) { return 1; } int first = 1; int second = 2; for (int i = 3; i <= n; i++) { int third = first + second; first = second; second = third; } return second; } // Lowest common ancestor of given nodes. TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if (!root || !p || !q) { return NULL; } if (root == p || root == q) { return root; } TreeNode* l = lowestCommonAncestor(root->left, p, q); TreeNode* r = lowestCommonAncestor(root->right, p, q); if (l && r) { return root; } return l? l : r; } // Merge two sorted linked Lists: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { ListNode* head = NULL; ListNode* curr = NULL; ListNode* prev = NULL; if(l1==NULL){ return l2; } if (l2 == NULL){ return l1; } while (l1 && l2){ if (l1->val < l2->val){ curr = new ListNode(l1->val); curr->next = NULL; l1 = l1->next; }else{ curr = new ListNode(l2->val); curr->next = NULL; l2 = l2->next; } if(head == NULL){ head = curr; } else{ prev->next = curr; } prev = curr; if(l1==NULL) curr = l2; prev->next = curr; if(l2==NULL) curr = l1; prev->next = curr; } return head; } // A simple atoi() function int myAtoi(char *str) { int res = 0; // Initialize result int sign = 1; // Initialize sign as positive int i = 0; // Initialize index of first digit // If number is negative, then update sign if (str[0] == '-') { sign = -1; i++; // Also update index of first digit } // Iterate through all digits and update the result for (; str[i] != '\0'; ++i) res = res*10 + str[i] - '0'; // Return result with sign return sign*res; } // Driver program to test above function int main() { char str[] = "-123"; int val = myAtoi(str); printf ("%d ", val); return 0; } // median of two sorted arrays: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { size_t m = nums1.size(), n = nums2.size(); if (m + n == 0) { return 0.0; } int k = (m + n) / 2; size_t p = 0, q = 0; int res = 0; int last = res; int c = -1; while (p < m && q < n && c < k) { last = res; if (nums1[p] < nums2[q]) { res = nums1[p++]; } else { res = nums2[q++]; } ++c; } while (p < m && c < k) { last = res; res = nums1[p++]; ++c; } while (q < n && c < k) { last = res; res = nums2[q++]; ++c; } if (((m + n) & 0x1) == 1) { return res; } else { return (last + res) / 2.0; } } //reverse words in a string void reverseword(string &s, int i, int j){ while(i<j){ char t=s[i]; s[i++]=s[j]; s[j--]=t; } } void reverseWords(string &s) { int i=0, j=0; int l=0; int len=s.length(); int wordcount=0; while(true){ while(i<len && s[i] == ' ') i++; // skip spaces in front of the word if(i==len) break; if(wordcount) s[j++]=' '; l=j; while(i<len && s[i] != ' ') {s[j]=s[i]; j++; i++;} reverseword(s,l,j-1); // reverse word in place wordcount++; } s.resize(j); // resize result string reverseword(s,0,j-1); // reverse whole string } void reverseWords(string &s) { istringstream is(s); is >> s; string str; while(is >> str) s = str + " " + s; if (s.empty() || s[0] == ' ') s = ""; } // Rotated matrix void rotate(vector<vector<int>>& matrix) { int n = matrix.size(); int a = 0; int b = n-1; while(a<b){ for(int i=0;i<(b-a);++i){ swap(matrix[a][a+i], matrix[a+i][b]); swap(matrix[a][a+i], matrix[b][b-i]); swap(matrix[a][a+i], matrix[b-i][a]); } ++a; --b; } } // trapping rainwater int findWater(int arr[], int n) { // initialize output int result = 0; // maximum element on left and right int left_max = 0, right_max = 0; // indices to traverse the array int lo = 0, hi = n-1; while(lo <= hi) { if(arr[lo] < arr[hi]) { if(arr[lo] > left_max) // update max in left left_max = arr[lo]; else // water on curr element = max - curr result += left_max - arr[lo]; lo++; } else { if(arr[hi] > right_max) // update right maximum right_max = arr[hi]; else result += right_max - arr[hi]; hi--; } } return result; } int main() { int arr[] = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; int n = sizeof(arr)/sizeof(arr[0]); cout << "Maximum water that can be accumulated is " << findWater(arr, n); } // Priority queue class Solution { public: int findKthLargest(vector<int>& nums, int k) { std::priority_queue <int> q; for (int n : nums) { q.push (n); } for (int i =0;i<k-1; i++) { q.pop(); } return q.top(); } }; // Using multi set int findKthLargest(vector<int>& nums, int k) { multiset<int> mset; int n = nums.size(); for (int i = 0; i < n; i++) { mset.insert(nums[i]); if (mset.size() > k) mset.erase(mset.begin()); } return *mset.begin(); }
[ "u2goyal@gmail.com" ]
u2goyal@gmail.com
9d51edfb5d155188460bc44dc85a8d16eea74dd6
e57039db94dd5cfbf5056540047e2497d61cd535
/classes/ButtonHandler.h
5170bfa0183573bac8f1ef76258be6c240a35158
[ "MIT" ]
permissive
Jaspervanderlugt/dpdrawing
bda14e509df121c57e218597cef8b27838520a3c
018f18f6272153d4fe3e9674df96ca35804f4d3c
refs/heads/master
2022-11-08T13:53:17.817852
2020-06-15T09:13:05
2020-06-15T09:13:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,295
h
#include "MouseHandler.h" #include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> #include <memory> #include <vector> #include "commands/HardResetCommand.h" #include "commands/LoadButtonsCommand.h" #include "commands/DrawShapesCommand.h" #include "commands/SaveCommand.h" #include "commands/LoadCommand.h" #include "commands/DeleteCommand.h" using std::unique_ptr; using std::vector; namespace DPDrawing { class ButtonHandler { private: Invoker* inv = nullptr; SDL_Renderer* renderer = nullptr; TextureManager* tm = nullptr; MouseHandler* mh = nullptr; UndoHandler* uh = nullptr; TTF_Font* font = nullptr; vector<unique_ptr<Shape>>* shapes = nullptr; const int* BUTTON_WIDTH = nullptr; const int* BUTTON_HEIGHT = nullptr; int* currentMode = nullptr; ResetCommand* rc = nullptr; LoadButtonsCommand* lbc = nullptr; DrawShapesCommand* dsc = nullptr; SaveCommand* sc = nullptr; LoadCommand* lc = nullptr; DeleteCommand* dc = nullptr; public: ButtonHandler(Invoker* inv, SDL_Renderer* renderer, TextureManager* tm, UndoHandler* uh, MouseHandler* mh, vector<unique_ptr<Shape>>* shapes, TTF_Font* font, int* currentMode, const int* BUTTON_WIDTH, const int* BUTTON_HEIGHT); bool checkIfButtonPressed(bool execute); bool initializeButtons(); }; }
[ "tsdezwart@protonmail.com" ]
tsdezwart@protonmail.com
5d7a5dbd4d307f7b4ad0e13657ce7853acaf01e5
1432c9f87f441036ad570c54c6bee3baee9e77dd
/Assignment/OpenGLEngineA4/OpenGLEngine/SphereContactGeneratorSystem.cpp
549a4413d99a4670838f6d27035dc1c820d069e9
[ "MIT" ]
permissive
GBCNewGamePlus/Physics
a144693c9b1998a654d0f7f03adb16f77bee52e0
739a244cfee506b3506a2bc6ec0dcdebe2c5417d
refs/heads/master
2020-08-29T14:50:39.112065
2019-12-12T06:48:46
2019-12-12T06:48:46
218,065,711
0
0
null
null
null
null
UTF-8
C++
false
false
3,305
cpp
#include "SphereContactGeneratorSystem.h" #include "ParticleContactComponent.h" namespace Reality { SphereContactGeneratorSystem::SphereContactGeneratorSystem() { requireComponent<SphereComponent>(); requireComponent<ParticleComponent>(); requireComponent<TransformComponent>(); } void SphereContactGeneratorSystem::Update(float deltaTime) { if (!dummyCreated) { dummy = getWorld().createEntity(); dummyCreated = true; } auto entities = getEntities(); for (int i = 0; i < entities.size(); i++) { auto& transform1 = entities[i].getComponent<TransformComponent>(); auto& sphere1 = entities[i].getComponent<SphereComponent>(); auto& particle1 = entities[i].getComponent<ParticleComponent>(); bool collided = false; // Check collisions with other spheres if (entities.size() > 1) { if (i < entities.size() - 1) { for (int j = i + 1; j < entities.size(); j++) { auto& transform2 = entities[j].getComponent<TransformComponent>(); auto& sphere2 = entities[j].getComponent<SphereComponent>(); auto& particle2 = entities[j].getComponent<ParticleComponent>(); if (glm::length(transform1.position - transform2.position) < sphere1.radius + sphere2.radius) { float penetration = sphere1.radius + sphere2.radius - glm::length(transform1.position - transform2.position); ECSEntity e = getWorld().createEntity(); Vector3 normal = glm::normalize(transform1.position - transform2.position); //getWorld().data.renderUtil->DrawLine(transform1.position - sphere1.radius * normal, // transform1.position - sphere1.radius * normal + penetration * normal, Color(0, 0, 1)); e.addComponent<ParticleContactComponent>(entities[i], entities[j], 1.0f, normal, penetration); collided = true; } } } } // Check collision with Hardcoded walls if (abs(transform1.position.x) >= 14) { float penetration = abs(transform1.position.x) - 14; ECSEntity e = getWorld().createEntity(); Vector3 normal = (transform1.position.x > 0 ? -1.0f : 1.0f) * Vector3(1, 0, 0); e.addComponent<ParticleContactComponent>(entities[i], dummy, 1.0f, normal, penetration); collided = true; } if (abs(transform1.position.y - 20) >= 14) { float penetration = abs(transform1.position.y - 20) - 14; ECSEntity e = getWorld().createEntity(); Vector3 normal = ((transform1.position.y - 20) > 0 ? -1.0f : 1.0f) * Vector3(0, 1, 0); e.addComponent<ParticleContactComponent>(entities[i], dummy, 1.0f, normal, penetration); collided = true; } if (abs(transform1.position.z) >= 14) { float penetration = abs(transform1.position.z) - 14; ECSEntity e = getWorld().createEntity(); Vector3 normal = (transform1.position.z > 0 ? -1.0f : 1.0f) * Vector3(0, 0, 1); e.addComponent<ParticleContactComponent>(entities[i], dummy, 1.0f, normal, penetration); collided = true; } Color col = collided ? Color(1, 0, 0, 1) : Color(0, 1, 0, 1); //getWorld().data.renderUtil->DrawSphere(transform1.position, sphere1.radius, col); } //getWorld().data.renderUtil->DrawCube(Vector3(0, 20, 0), Vector3(30, 30, 30)); } }
[ "rshimoda@gmail.com" ]
rshimoda@gmail.com
a1e2a427e8b85711c5ec61a8285abbc7ddbc9297
517a5ace21a12bfe6397995a1b2dd6638ea3d9ce
/DSA/Heap/k_largest_elements.cpp
f8c79845c2b565baddad680bdfa357673c324d80
[]
no_license
sakibchonka/cpp_learning
21111ee662e2183ee391d69b0f21d8c669bb50df
61456249b7ab4ba2549ec8cc75ed8e56378ddb3f
refs/heads/main
2023-07-17T13:33:13.390443
2021-08-23T17:12:33
2021-08-23T17:12:33
379,327,097
0
0
null
null
null
null
UTF-8
C++
false
false
628
cpp
#include<bits/stdc++.h> using namespace std; void firstKElements(int arr[], int size, int k){ priority_queue<int, vector<int>, greater<int>> pq; for(int i=0; i<k; i++) pq.push(arr[i]); for(int i=k; i<size; i++){ if(arr[i]<pq.top()) continue; else{ pq.pop(); pq.push(arr[i]); } } for(int i=0;i<k;i++){ cout<<pq.top()<<" "; pq.pop(); } } int main(){ int arr[] = { 11, 3, 2, 1, 15, 5, 4, 45, 88, 96, 50, 45 }; int size = sizeof(arr) / sizeof(arr[0]); int k = 3; firstKElements(arr,size,k); return 0; }
[ "sakibchonka@gmail.com" ]
sakibchonka@gmail.com
b33c3e30eb199bf3015e30d568d9f915d940b70a
37b8811856f6a386444bb589c4a75a06b2295e0f
/widgets.hpp
a7b8e81ed81050f66f77b8a55ae1806d74ed4b64
[]
no_license
HortKaty/project1
fbdd21be6e27509b5515bccfebbdf84962324c17
177533fd13598f14113db3422dc8df5c97a00b01
refs/heads/master
2020-03-17T00:51:45.534897
2018-05-13T21:49:58
2018-05-13T21:49:58
133,132,756
0
0
null
null
null
null
UTF-8
C++
false
false
771
hpp
#ifndef WIDGETS_HPP_INCLUDED #define WIDGETS_HPP_INCLUDED #include "graphics.hpp" class Widget { protected: int _x, _y, _sx, _sy; bool _focusable; public: Widget(int x, int y, int sx, int sy); virtual bool is_selected(int mouse_x, int mouse_y); virtual void draw() = 0; virtual void handle(genv::event ev) = 0; virtual bool focusable(); }; //szeretnek pontlevonast kerni a beadandomra mert feltoltottem egy oktatasi segedletet sajat munka helyett :) #endif // WIDGETS_HPP_INCLUDED
[ "39213799+HortKaty@users.noreply.github.com" ]
39213799+HortKaty@users.noreply.github.com
a99283be4643d773e398d2d07d8e93e154a3c84e
e48afc9712d4a92d722caf9e3d4641c65d134706
/spiral_matrix.cpp
fabc4c66428617e12effc9fadd26c1e488066157
[]
no_license
bach-long/Bach
d18f39db270c75c768311498cefcfe8ea01261c1
32b839a2cc9d3738dcc73470ca56de5d1816ba0c
refs/heads/master
2023-04-21T10:46:59.264836
2021-05-11T17:10:10
2021-05-11T17:10:10
335,474,994
0
0
null
2021-02-27T17:55:25
2021-02-03T01:41:15
C++
UTF-8
C++
false
false
642
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a=sqrt(n); int i=0; int j=0; int x=a; int y=a-1; int start=1; int spiral[a][a]; int sep=1; while(x>=0&&y>=0){ int cnt=0; while(cnt<x){ spiral[i][j]=start; j+=sep; start++; cnt++; } i+=sep; j-=sep; cnt=0; while(cnt<y){ spiral[i][j]=start; i+=sep; start++; cnt++; } i-=sep; j-=sep; sep*=-1; x--; y--; } for(int i=0;i<a;i++){ for(int j=0;j<a;j++){ cout<<spiral[i][j]<<" "; } cout<<endl; } }
[ "nguyenbach19122002@gmail.com" ]
nguyenbach19122002@gmail.com
ff01787c1f05d24c89822fb9b3eb7a27467a2e7a
af0918e1f187152e5d3d5c9c75dbcdbc7c7ef7d8
/leetcode/Valid_Parentheses.cc
04b9dcd2680bd6895b13d1a49be7c40534c34ac0
[]
no_license
liyisheng/MaNong
ec2f26a56e39e20792a4850ed4b3134cf800d17c
5fd508d43764fa10af12b7c04d327871893c4942
refs/heads/master
2021-01-21T21:54:23.429286
2019-07-26T16:00:45
2019-07-26T16:00:45
29,233,307
1
0
null
null
null
null
UTF-8
C++
false
false
1,168
cc
/************************************************************************* > File Name: Valid_Parentheses.cc > Author: liyisheng > Mail: liyishengchn@gmail.com > Created Time: Fri 10 Apr 2015 07:52:00 PM PDT ************************************************************************/ #include<iostream> #include<stack> using namespace std; bool isValid(string s) { stack<char> charStack; size_t i = 0; while(i != s.length()) { char c = s[i]; if(c != ')' && c != ']' && c != '}') charStack.push(c); else { if(charStack.size() == 0) return false; char pre = charStack.top(); switch(c) { case ')': if(pre == '(') charStack.pop(); else return false; break; case '}': if(pre == '{') charStack.pop(); else return false; break; case ']': if(pre == '[') charStack.pop(); else return false; break; } } ++i; } if(charStack.size() == 0) return true; else return false; } int main(int argc, char *argv[]) { // string s = "{()[]([(((())))]) }"; string s = "{()[]([(((())))])}"; cout << isValid(s) << endl; return 0; }
[ "liyishengchn@foxmail.com" ]
liyishengchn@foxmail.com
6337d7cc361a1b19b7318cc33828e5b658586ce1
fd5aee85a293580d8cc3ce2fdb65660b8bdad4a6
/source/devices/generic/generic_input.cpp
ed035de442977dce7faf3bc9005ac1b53f6baf55
[ "MIT" ]
permissive
Ryochan7/MoltenGamepad
9d4e4de1e17c324cd4c556cb9ba77c3e691ad386
2127fd433a43fd2e558bb306aef6498456d8134b
refs/heads/master
2020-12-07T02:38:28.936920
2016-01-02T01:36:17
2016-01-02T01:36:17
48,894,488
1
0
null
2016-01-02T01:04:13
2016-01-02T01:04:13
null
UTF-8
C++
false
false
3,006
cpp
#include "generic.h" generic_device::generic_device(std::vector<gen_source_event> &inevents, int fd, bool watch, slot_manager* slot_man) : input_source(slot_man) { this->fd = fd; for (int i = 0; i < inevents.size(); i++) { source_event ev; input_absinfo abs; memset(&abs,0,sizeof(abs)); ev.id = i; ev.name = inevents.at(i).name.c_str(); ev.descr = inevents.at(i).descr.c_str(); ev.type = inevents.at(i).type; ev.value = 0; ev.trans = nullptr; register_event(ev); int type = EV_KEY; if (ev.type == DEV_AXIS) type = EV_ABS; if (ev.type == DEV_REL) type = EV_REL; evcode code(type,inevents.at(i).id); if (ev.type == DEV_AXIS) { if(ioctl(fd, EVIOCGABS(inevents.at(i).id), &abs)) { perror("evdev EVIOCGABS ioctl"); } } decodedevent decoded(i,abs); eventcodes.insert(std::pair<evcode,decodedevent>(code,decoded)); } if (watch) watch_file(fd,&fd); } generic_device::~generic_device() { if (node) udev_device_unref(node); free (nameptr); } int generic_device::set_player(int player_num) {}; void generic_device::list_events(cat_list &list) { struct category cat; struct name_descr info; cat.name = "Generic"; for (int i = 0; i < events.size(); i++) { info.name = events[i].name; info.descr = events[i].descr; info.data = events[i].type; cat.entries.push_back(info); } list.push_back(cat); cat.entries.clear(); } void generic_device::list_options(name_list &list) {}; void generic_device::update_option(const char* opname, const char* value) {}; enum entry_type generic_device::entry_type(const char* name) { for (auto ev : events) { if (!strcmp(ev.name,name)) return ev.type; } return NO_ENTRY; } void generic_device::process(void* tag) { struct input_event ev; int file = fd; if (pipe_read >= 0 && tag == &pipe_read) {file = pipe_read;}; int ret = read(file,&ev,sizeof(ev)); if (ret > 0) { if (ev.type == EV_SYN && out_dev) { out_dev->take_event(ev); return; } evcode code(ev.type,ev.code); auto it = eventcodes.find(code); if (it == eventcodes.end()) return; decodedevent decoded = it->second; int id = decoded.first; if (ev.type == EV_KEY) { send_value(id,ev.value); } if (ev.type == EV_ABS) { //do some ABS rescaling. //currently ignoring old deadzone ("flat") input_absinfo info = decoded.second; int value = ev.value; int oldscale = info.maximum - info.minimum; if (oldscale == 0) { send_value(id,value); return;} int newscale = 2*ABS_RANGE; long long int scaledvalue = -ABS_RANGE + (value - info.minimum)*newscale/oldscale; send_value(id,scaledvalue); } } } int generic_device::get_pipe() { if (pipe_write >= 0) return pipe_write; int internal[2]; pipe(internal); watch_file(internal[0], &pipe_read); pipe_write = internal[1]; pipe_read = internal[0]; return pipe_write; }
[ "josephgeumlek@gmail.com" ]
josephgeumlek@gmail.com
d156ce5535de698740f6d792df431a8246fce35a
d45ee9276ee0260286d2979c054765b68f3c0f41
/src/servables/ensemble/ensemble_bundle_test.cc
ab9e5db11b7e25a868c48bf787f4380484b1aa36
[ "BSD-3-Clause" ]
permissive
adityadhakal/tensorrt-inference-server
73924c26f10f35087f6a9c1fc9ab0500a0c18d77
0ae29b89066b7ee1a565985b753673bc1e179a31
refs/heads/master
2020-04-28T13:32:15.122114
2019-03-12T19:04:00
2019-03-12T21:39:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,034
cc
// Copyright (c) 2019, NVIDIA CORPORATION. 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 NVIDIA CORPORATION 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 ``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 <unordered_map> #include "src/core/constants.h" #include "src/core/ensemble_utils.h" #include "src/core/logging.h" #include "src/core/model_config_utils.h" #include "src/test/model_config_test_base.h" namespace nvidia { namespace inferenceserver { namespace test { class EnsembleBundleTest : public ModelConfigTestBase { public: bool GetModelConfigsInRepository( const std::string& model_base_path, std::unordered_map<std::string, ModelConfig>& config_map, std::string* result); }; bool EnsembleBundleTest::GetModelConfigsInRepository( const std::string& model_base_path, std::unordered_map<std::string, ModelConfig>& config_map, std::string* result) { result->clear(); config_map.clear(); std::vector<std::string> models; TF_CHECK_OK( tensorflow::Env::Default()->GetChildren(model_base_path, &models)); for (const auto& model_name : models) { const auto model_path = tensorflow::io::JoinPath(model_base_path, model_name); if (!tensorflow::Env::Default()->IsDirectory(model_path).ok()) { continue; } ModelConfig config; tfs::PlatformConfigMap platform_map; tensorflow::Status status = GetNormalizedModelConfig(model_path, platform_map, false, &config); if (!status.ok()) { result->append(status.ToString()); return false; } status = ValidateModelConfig(config, std::string()); if (!status.ok()) { result->append(status.ToString()); return false; } config_map[config.name()] = config; } return true; } TEST_F(EnsembleBundleTest, ModelConfigSanity) { BundleInitFunc init_func = [](const std::string& path, const ModelConfig& config) -> tensorflow::Status { return tensorflow::Status::OK(); }; // Standard testing... ValidateAll(kEnsemblePlatform, init_func); // Check model config sanity against ensemble's own test cases ValidateOne( "inference_server/src/servables/ensemble/testdata/model_config_sanity", true /* autofill */, std::string() /* platform */, init_func); } TEST_F(EnsembleBundleTest, EnsembleConfigSanity) { std::string error; std::unordered_map<std::string, ModelConfig> config_map; const std::string test_repo_path = tensorflow::io::JoinPath( getenv("TEST_SRCDIR"), "inference_server/src/servables/ensemble/testdata/" "ensemble_config_sanity"); std::vector<std::string> model_repos; TF_CHECK_OK( tensorflow::Env::Default()->GetChildren(test_repo_path, &model_repos)); for (const auto& repo : model_repos) { const std::string model_base_path = tensorflow::io::JoinPath(test_repo_path, repo); if (GetModelConfigsInRepository(model_base_path, config_map, &error) == false) { EXPECT_TRUE(error.empty()); LOG_ERROR << "Unexpected error while loading model configs in " << repo << ":" << std::endl << error; continue; } std::string actual; tensorflow::Status status = ValidateEnsembleConfig(config_map); if (!status.ok()) { actual.append(status.ToString()); } std::string fail_expected; CompareActualWithExpected(model_base_path, actual, &fail_expected); EXPECT_TRUE(fail_expected.empty()); if (!fail_expected.empty()) { LOG_ERROR << "Expected:" << std::endl << fail_expected; LOG_ERROR << "Actual:" << std::endl << actual; } } } }}} // namespace nvidia::inferenceserver::test
[ "davidg@nvidia.com" ]
davidg@nvidia.com
5d2fefc20a6239f41fecab8f2e8af31278e8e536
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/2d/eeb81de376046a/main.cpp
4aebe2c5e8298acb9e9891d13bb3b44a753967ba
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
439
cpp
#include <iostream> struct Test { int a; int b; int c; }; bool less(Test lhs, Test rhs) { return (lhs.a < rhs.a) || ((!(rhs.a < lhs.a) && (lhs.b < rhs.b)) || (!(rhs.b < lhs.b) && (lhs.c < rhs.c))); } int main() { Test t1 = {8, 10, 12}; Test t2 = {8, 9, 8}; std::cout << "less(t1 ,t2)" << less(t1, t2) << std::endl; std::cout << "less(t2 ,t1)" << less(t2, t1) << std::endl; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
92b5404c12bba58aabee17f3a01379eca4a39d81
7238d0edca7d6e3eac2e80b85b2721f48ceb5f77
/ut/utTypes.h
f9b78d065506fed6ffd66f4efb064ac1b8521a85
[]
no_license
blendkit/gamekitUtils
42719e13dc509838dbb51ea79654b246381536cf
2bec2b32243933efcead30eb7aad3f04632a4def
refs/heads/master
2020-03-27T02:25:47.909345
2017-11-03T00:12:30
2017-11-03T00:12:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
42,178
h
/* ------------------------------------------------------------------------------- General Purpose Utility Library, should be kept dependency free. Unless the dependency can be compiled along with this library. Copyright (c) 2009-2010 Charlie C. Contributor(s): vekoon. ------------------------------------------------------------------------------- This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ------------------------------------------------------------------------------- */ #ifndef _utTypes_h_ #define _utTypes_h_ #include <memory.h> #include <ut/utCommon.h> #define _UT_CACHE_LIMIT 999 template <typename T> UT_INLINE void utSwap(T &a, T &b) { T t(a); a = b; b = t; } template <typename T> UT_INLINE T utMax(const T &a, const T &b) { return a < b ? b : a; } template <typename T> UT_INLINE T utMin(const T &a, const T &b) { return a < b ? a : b; } template <typename T> UT_INLINE T utClamp(const T &v, const T &a, const T &b) { return v < a ? a : v > b ? b : v; } // List iterator access. template <typename T> class utListIterator { public: typedef typename T::Pointer Iterator; typedef typename T::ReferenceType ValueType; typedef typename T::ConstReferenceType ConstValueType; protected: mutable Iterator m_iterator; mutable Iterator m_cur; public: utListIterator() : m_iterator(0), m_cur(0) {} utListIterator(Iterator first) : m_iterator(first), m_cur(first) {} utListIterator(T &v) : m_iterator(v.begin()), m_cur(v.begin()) { } ~utListIterator() {} UT_INLINE bool hasMoreElements(void) const { return m_cur != 0; } UT_INLINE void next(void) const { UT_ASSERT(hasMoreElements()); m_cur = m_cur->getNext(); } UT_INLINE ValueType getNext(void) { UT_ASSERT(hasMoreElements()); ValueType ret = m_cur->getLink(); m_cur = m_cur->getNext(); return ret; } UT_INLINE ConstValueType getNext(void) const { UT_ASSERT(hasMoreElements()); ValueType ret = m_cur->getLink(); m_cur = m_cur->getNext(); return ret; } UT_INLINE ValueType peekNext(void) { UT_ASSERT(hasMoreElements()); return m_cur->getLink(); } UT_INLINE ConstValueType peekNext(void) const { UT_ASSERT(hasMoreElements()); return m_cur->getLink(); } }; template <typename T> class utListReverseIterator { public: typedef typename T::Pointer Iterator; typedef typename T::ReferenceType ValueType; typedef typename T::ConstReferenceType ConstValueType; protected: mutable Iterator m_iterator; mutable Iterator m_cur; public: utListReverseIterator() : m_iterator(0), m_cur(0) {} utListReverseIterator(Iterator last) : m_iterator(last), m_cur(last) {} utListReverseIterator(T &v) : m_iterator(v.end()), m_cur(v.end()) {} ~utListReverseIterator() {} UT_INLINE bool hasMoreElements(void) const { return m_cur != 0; } UT_INLINE void next(void) const { UT_ASSERT(hasMoreElements()); m_cur = m_cur->getPrev(); } UT_INLINE ValueType getNext(void) { UT_ASSERT(hasMoreElements()); ValueType ret = m_cur->getLink(); m_cur = m_cur->getPrev(); return ret; } UT_INLINE ConstValueType getNext(void) const { UT_ASSERT(hasMoreElements()); ValueType ret = m_cur->getLink(); m_cur = m_cur->getPrev(); return ret; } UT_INLINE ValueType peekNext(void) { UT_ASSERT(hasMoreElements()); return m_cur->getLink(); } UT_INLINE ConstValueType peekNext(void) const { UT_ASSERT(hasMoreElements()); return m_cur->getLink(); } }; template <typename T> class utListClass { public: typedef T *ValueType; typedef const T *ConstValueType; typedef T *Pointer; typedef T *ReferenceType; typedef const T *ConstReferenceType; typedef utListIterator<utListClass<T> > Iterator; typedef utListReverseIterator<utListClass<T> > ReverseIterator; // Const access typedef const utListIterator<utListClass<T> > ConstIterator; typedef const utListReverseIterator<utListClass<T> > ConstReverseIterator; class Link { protected: T *m_next; T *m_prev; friend class utListClass; public: Link() : m_next(0), m_prev(0) {} ~Link() {} UT_INLINE T *getNext(void) {return m_next;} UT_INLINE T *getPrev(void) {return m_prev;} UT_INLINE T *getLink(void) { return (T *)this; } }; public: utListClass() : m_first(0), m_last(0), m_size(0) {} ~utListClass() { clear(); } void clear(void) { m_first = m_last = 0; m_size = 0; } void push_back(ValueType v) { v->m_prev = m_last; if (m_last) m_last->m_next = v; if (!m_first) m_first = v; m_last = v; m_size ++; } void push_front(ValueType v) { v->m_next = m_first; if (m_first) m_first->m_prev = v; if (!m_last) m_last = v; m_first = v; m_size ++; } void insert(ValueType from, ValueType v) { m_size ++; if (!m_first) { m_first = m_last = v; return; } if (from == 0) { // add to back v->m_prev = m_last; if (m_last) m_last->m_next = v; if (!m_first) m_first = v; m_last = v; return; } if (m_last == from) m_last = v; v->m_next = from->m_next; from->m_next = v; if (v->m_next) v->m_next->m_prev = v; v->m_prev = from; } ValueType find(ValueType v) { ValueType node = m_first; while (node) { if (node == v) return node; node = node->m_next; } return 0; } ValueType at(UTsize index) { UT_ASSERT(index < m_size); UTsize i = 0; ValueType node = m_first; while (node) { if (i == index) break; node = node->m_next; i++; } UT_ASSERT(node); return node; } ConstValueType at(UTsize index) const { UT_ASSERT(index < m_size); UTsize i = 0; ValueType node = m_first; while (node) { if (i == index) break; node = node->m_next; i++; } UT_ASSERT(node); return node; } ValueType erase(ValueType v) { if (!v || m_size == 0) return 0; if (v->m_next) v->m_next->m_prev = v->m_prev; if (v->m_prev) v->m_prev->m_next = v->m_next; if (m_last == v) m_last = v->m_prev; if (m_first == v) m_first = v->m_next; m_size -= 1; return v; } UT_INLINE ValueType pop_back(void) { return erase(end()); } UT_INLINE ValueType pop_front(void) { return erase(begin()); } UT_INLINE bool empty(void) const { return m_size == 0; } UT_INLINE UTsize size(void)const { return m_size; } UT_INLINE ValueType begin(void) { UT_ASSERT(m_first); return m_first; } UT_INLINE ValueType end(void) { UT_ASSERT(m_last); return m_last; } UT_INLINE ConstValueType begin(void) const { UT_ASSERT(m_first); return m_first; } UT_INLINE ConstValueType end(void) const { UT_ASSERT(m_last); return m_last; } UT_INLINE Iterator iterator(void) { return m_first ? Iterator(m_first) : Iterator(); } UT_INLINE ReverseIterator reverseIterator(void) { return m_last ? ReverseIterator(m_last) : ReverseIterator(); } UT_INLINE ConstIterator iterator(void) const { return m_first ? ConstIterator(m_first) : ConstIterator(); } UT_INLINE ConstReverseIterator reverseIterator(void) const { return m_last ? ConstReverseIterator(m_last) : ConstReverseIterator(); } protected: T *m_first; T *m_last; UTsize m_size; }; template <typename T> class utList { public: class Link { protected: Link *next; Link *prev; friend class utList; public: Link() : next(0), prev(0) {} Link(const T &v) : next(0), prev(0), link(v) {} UT_INLINE Link *getNext(void) {return next;} UT_INLINE Link *getPrev(void) {return prev;} UT_INLINE T &getLink(void) {return link;} T link; }; typedef Link *Pointer; typedef const Link *ConstPointer; typedef T ValueType; typedef const T ConstValueType; typedef T &ReferenceType; typedef const T &ConstReferenceType; typedef utListIterator<utList<T> > Iterator; typedef utListReverseIterator<utList<T> > ReverseIterator; typedef const utListIterator<utList<T> > ConstIterator; typedef const utListIterator<utList<T> > ConstReverseIterator; public: utList() : m_first(0), m_last(0), m_size(0) {} ~utList() { clear(); } void clear(void) { Link *node = m_first; while (node) { Link *temp = node; node = node->next; delete temp; } m_first = m_last = 0; m_size = 0; } UT_INLINE void push_back(const T &v) { Link *link = new Link(v); link->prev = m_last; if (m_last) m_last->next = link; if (!m_first) m_first = link; m_last = link; m_size ++; } UT_INLINE void push_front(const T &v) { Link *link = new Link(v); link->next = m_first; if (m_first) m_first->prev = link; if (!m_last) m_last = link; m_first = link; m_size ++; } Pointer find(const T &v) { Link *node = m_first; while (node) { if (node->link == v) return node; node = node->next; } return 0; } ReferenceType at(UTsize index) { UT_ASSERT(index < m_size); UTsize i = 0; Link *node = m_first; while (node) { if (i == index) break; node = node->next; i++; } UT_ASSERT(node); return node->link; } ConstReferenceType at(UTsize index) const { UT_ASSERT(index < m_size); UTsize i = 0; Link *node = m_first; while (node) { if (i == index) break; node = node->next; i++; } UT_ASSERT(node); return node->link; } Pointer link_at(UTsize index) { UTsize i = 0; Link *node = m_first; while (node) { if (i == index) return node; node = node->next; i++; } return 0; } void erase(Pointer link, bool deletePntr=true) { if (!link || m_size == 0) return; if (link->next) link->next->prev = link->prev; if (link->prev) link->prev->next = link->next; if (m_last == link) m_last = link->prev; if (m_first == link) m_first = link->next; m_size -= 1; delete link; if (m_size == 0) clear(); } void erase(const T &v) { Pointer fnd = find(v); if (fnd) erase(fnd); } void sort(bool (*cmp)(const T &a, const T &b)) { UTsize i, n=m_size; Link *a; bool swapped = false; if (n < 2 || !cmp) return; do { a = m_first; for (i=0; a && a->next && i<n-1; i++, a = a->next) { if (cmp(a->link, a->next->link)) { swap(a, a->next); swapped = true; } } n-=1; } while (swapped && n != UT_NPOS); } UT_INLINE void pop_back(bool deletePntr=true) { erase(end(),deletePntr); } UT_INLINE void pop_front(bool deletePntr=true) { erase(begin(),deletePntr); } UT_INLINE bool empty(void) const { return m_size == 0; } UT_INLINE UTsize size(void)const { return m_size; } UT_INLINE Pointer begin(void) { return m_first; } UT_INLINE Pointer end(void) { return m_last; } UT_INLINE ConstPointer begin(void)const { return m_first; } UT_INLINE ConstPointer end(void)const { return m_last; } UT_INLINE ReferenceType front(void) { UT_ASSERT(m_first); return m_first->link; } UT_INLINE ReferenceType back(void) { UT_ASSERT(m_last); return m_last->link; } UT_INLINE Iterator iterator(void) { return m_first ? Iterator(m_first) : Iterator(); } UT_INLINE ReverseIterator reverseIterator(void) { return m_last ? ReverseIterator(m_last) : ReverseIterator(); } UT_INLINE ConstIterator iterator(void) const { return m_first ? ConstIterator(m_first) : ConstIterator(); } UT_INLINE ConstReverseIterator reverseIterator(void) const { return m_last ? ConstReverseIterator(m_last) : ConstReverseIterator(); } protected: Link *m_first; Link *m_last; UTsize m_size; void swap(Link *a, Link *b) { ValueType v(a->link); a->link = b->link; b->link = v; } }; template <typename T> class utArrayIterator { public: typedef typename T::Pointer Iterator; // T::ValueType as reference typedef typename T::ReferenceType ValueType; typedef typename T::ConstReferenceType ConstValueType; protected: mutable Iterator m_iterator; mutable UTsize m_cur; mutable UTsize m_capacity; public: utArrayIterator() : m_iterator(0), m_cur(0), m_capacity(0) {} utArrayIterator(Iterator begin, UTsize size) : m_iterator(begin), m_cur(0), m_capacity(size) {} utArrayIterator(T &v) : m_iterator(v.ptr()), m_cur(0), m_capacity(v.size()) { } ~utArrayIterator() {} UT_INLINE bool hasMoreElements(void) const { return m_iterator && m_cur < m_capacity; } UT_INLINE ValueType getNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++]; } UT_INLINE ConstValueType getNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++]; } UT_INLINE void next(void) const { UT_ASSERT(hasMoreElements()); ++m_cur; } UT_INLINE ValueType peekNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur]; } UT_INLINE ConstValueType peekNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur]; } }; template <typename T> class utArray { public: typedef T *Pointer; typedef const T *ConstPointer; typedef T ValueType; typedef const T ConstValueType; typedef T &ReferenceType; typedef const T &ConstReferenceType; typedef utArrayIterator<utArray<T> > Iterator; typedef const utArrayIterator<utArray<T> > ConstIterator; public: utArray() : m_size(0), m_capacity(0), m_data(0), m_cache(0) {} utArray(const utArray<T>& o) : m_size(o.size()), m_capacity(0), m_data(0), m_cache(0) { reserve(m_size); copy(m_data, o.m_data, m_size); } utArray(int size,T fillValue) : m_size(0), m_capacity(0), m_data(0), m_cache(0) { reserve(size); for (int i=0;i<size;i++) push_back(fillValue); } ~utArray() { clear(); } void clear(bool useCache=false) { if (!useCache) { if (m_data) delete []m_data; m_data = 0; m_capacity = 0; m_size = 0; m_cache = 0; } else { ++m_cache; if (m_cache > _UT_CACHE_LIMIT ) clear(false); else m_size = 0; } } UTsize find(const T &v) const { for (UTsize i = 0; i < m_size; i++) { if (m_data[i] == v) return i; } return UT_NPOS; } UT_INLINE void push_back(const T &v) { if (m_size == m_capacity) reserve(m_size == 0 ? 8 : m_size * 2); m_data[m_size] = v; m_size++; } UT_INLINE void pop_back(void) { m_size--; m_data[m_size].~T(); } void erase(const T &v) { erase(find(v)); } void erase(UTsize pos) { if (m_size > 0) { if (pos != UT_NPOS) { swap(pos, m_size-1); m_size--; m_data[m_size].~T(); } } } void resize(UTsize nr) { if (nr < m_size) { for (UTsize i = m_size; i < nr; i++) m_data[i].~T(); } else { if (nr > m_size) reserve(nr); } m_size = nr; } void resize(UTsize nr, const T &fill) { if (nr < m_size) { for (UTsize i = m_size; i < nr; i++) m_data[i].~T(); } else { if (nr > m_size) reserve(nr); for (UTsize i = m_size; i < nr; i++) m_data[i] = fill; } m_size = nr; } void reserve(UTsize nr) { if (m_capacity < nr) { T *p = new T[nr]; if (m_data != 0) { copy(p, m_data, m_size); delete []m_data; } m_data = p; m_capacity = nr; } } void sort(bool (*cmp)(const T &a, const T &b)) { UTsize i, n=m_size; bool swapped = false; if (n < 2 || !cmp) return; do { if (n-1 == UT_NPOS) break; for (i=0; /*m_data[i] && m_data[i+1] && */i<(n-1); i++) { if (cmp(m_data[i], m_data[i+1])) { swap(i, i+1); swapped = true; } } n-=1; } while (swapped && n != UT_NPOS); } UT_INLINE T &operator[](UTsize idx) { UT_ASSERT(idx >= 0 && idx < m_capacity); return m_data[idx]; } UT_INLINE const T &operator[](UTsize idx) const { UT_ASSERT(idx >= 0 && idx < m_capacity); return m_data[idx]; } UT_INLINE T &at(UTsize idx) { UT_ASSERT(idx >= 0 && idx < m_capacity); return m_data[idx]; } UT_INLINE const T &at(UTsize idx) const { UT_ASSERT(idx >= 0 && idx < m_capacity); return m_data[idx]; } UT_INLINE T &front(void) { UT_ASSERT(m_size > 0); return m_data[0]; } UT_INLINE T &back(void) { UT_ASSERT(m_size > 0); return m_data[m_size-1]; } UT_INLINE ConstPointer ptr(void) const { return m_data; } UT_INLINE Pointer ptr(void) { return m_data; } UT_INLINE bool valid(void) const { return m_data != 0;} UT_INLINE UTsize capacity(void) const { return m_capacity; } UT_INLINE UTsize size(void) const { return m_size; } UT_INLINE bool empty(void) const { return m_size == 0;} UT_INLINE Iterator iterator(void) { return m_data && m_size > 0 ? Iterator(m_data, m_size) : Iterator(); } UT_INLINE ConstIterator iterator(void) const { return m_data && m_size > 0 ? ConstIterator(m_data, m_size) : ConstIterator(); } utArray<T> &operator= (const utArray<T> &rhs) { if (this != &rhs) { clear(); UTsize os = rhs.size(); if (os > 0) { resize(os); copy(m_data, rhs.m_data, os); } } return *this; } UT_INLINE void copy(Pointer dst, ConstPointer src, UTsize size) { UT_ASSERT(size <= m_size); for (UTsize i = 0; i < size; i++) dst[i] = src[i]; } protected: void swap(UTsize a, UTsize b) { ValueType t= m_data[a]; m_data[a] = m_data[b]; m_data[b] = t; } UTsize m_size; UTsize m_capacity; Pointer m_data; int m_cache; }; template <typename T> class utStackIterator { public: typedef typename T::Pointer Iterator; typedef typename T::ReferenceType ValueType; typedef typename T::ConstReferenceType ConstValueType; protected: mutable Iterator m_iterator; mutable UTsize m_top; const UTsize m_capacity; public: utStackIterator() : m_iterator(0), m_top(0), m_capacity(0) {} utStackIterator(Iterator begin, UTsize top) : m_iterator(begin), m_top(top), m_capacity(top) {} utStackIterator(T &v) : m_iterator(v.begin()), m_top(v.itop()), m_capacity(v.itop()) {} ~utStackIterator() {} UT_INLINE bool hasMoreElements(void) const { return (m_iterator && m_top != 0 && m_top != UT_NPOS); } UT_INLINE ValueType getNext(void) { UT_ASSERT((m_iterator && (m_top - 1) != UT_NPOS)); --m_top; return m_iterator[m_top]; } UT_INLINE ConstValueType getNext(void) const { UT_ASSERT((m_iterator && (m_top - 1) != UT_NPOS)); --m_top; return m_iterator[m_top]; } UT_INLINE void next(void) const { UT_ASSERT((m_iterator && (m_top - 1) != UT_NPOS)); --m_top; } UT_INLINE ValueType peekNext(void) { UT_ASSERT((m_iterator && (m_top - 1) != UT_NPOS)); return m_iterator[m_top-1]; } UT_INLINE ConstValueType peekNext(void) const { UT_ASSERT((m_iterator && (m_top - 1) != UT_NPOS)); return m_iterator[m_top-1]; } }; template <typename T> class utStack { public: typedef T *Pointer; typedef const T *ConstPointer; typedef T ValueType; typedef const T ConstValueType; typedef T &ReferenceType; typedef const T &ConstReferenceType; typedef utStackIterator<utStack<T> > Iterator; typedef const utStackIterator<utStack<T> > ConstIterator; public: utStack() : m_size(0), m_capacity(0), m_top(0), m_stack(0) {} utStack(UTsize rsp) : m_size(0), m_capacity(0), m_top(0), m_stack(0) { reserve(rsp); } utStack(const utStack &o) : m_size(o.m_size), m_capacity(0), m_top(o.m_top), m_stack(0) { reserve(o.m_size); UT_ASSERT(m_stack && o.m_stack); copy(m_stack, o.m_stack, o.m_size); } ~utStack() { clear(); } void clear(void) { if (m_stack != 0) { delete []m_stack; m_stack = 0; } m_size = 0; m_capacity = 0; m_top = 0; } void push(const T &v) { UT_ASSERT(m_top != UT_NPOS); if (m_size == m_capacity) reserve(m_size == 0 ? 8 : m_size * 2); m_stack[m_top] = v; ++m_top; ++m_size; } UT_INLINE ReferenceType pop(void) { UT_ASSERT(m_top != 0); --m_size; return m_stack[--m_top]; } UT_INLINE ReferenceType top(void) { UT_ASSERT(m_top != 0); return m_stack[(m_top - 1)]; } UT_INLINE ConstReferenceType top(void) const { UT_ASSERT(m_top != 0); return m_stack[(m_top - 1)]; } UT_INLINE ReferenceType peek(UTsize offs) { UT_ASSERT(m_top != 0 && ((m_top - 1) - offs) != UT_NPOS); return m_stack[(m_top - 1)-offs]; } UT_INLINE ConstReferenceType peek(UTsize offs) const { UT_ASSERT(m_top != 0 && ((m_top - 1) - offs) != UT_NPOS); return m_stack[(m_top - 1)-offs]; } void reserve(UTsize nr) { if (m_capacity < nr) { T *temp = new T[nr]; if (m_stack) { copy(temp, m_stack, m_size); delete []m_stack; } m_stack = temp; m_capacity = nr; } } UT_INLINE UTsize capacity(void) const { return m_capacity; } UT_INLINE UTsize size(void) const { return m_size; } UT_INLINE UTsize itop(void) const { return m_top; } UT_INLINE bool empty(void) const { return m_size == 0; } UT_INLINE ConstPointer ptr(void) const { return m_stack; } UT_INLINE Pointer ptr(void) { return m_stack; } UT_INLINE Iterator iterator(void) { return m_stack && m_size > 0 ? Iterator(m_stack, m_size) : Iterator(); } UT_INLINE ConstIterator iterator(void) const { return m_stack && m_size > 0 ? ConstIterator(m_stack, m_size) : ConstIterator(); } protected: UT_INLINE void copy(Pointer dest, const Pointer src, UTsize nr) { UTsize i; for (i = 0; i < nr; i++) dest[i] = src[i]; } UTsize m_size; UTsize m_capacity; UTsize m_top; Pointer m_stack; }; template <typename T> class utHashTableIterator { public: typedef typename T::Pointer Iterator; typedef typename T::Entry &Pair; typedef typename T::ConstEntry &ConstPair; typedef typename T::ReferenceKeyType KeyType; typedef typename T::ReferenceValueType ValueType; typedef typename T::ConstReferenceKeyType ConstKeyType; typedef typename T::ConstReferenceValueType ConstValueType; protected: mutable Iterator m_iterator; mutable UTsize m_cur; const UTsize m_capacity; public: utHashTableIterator() : m_iterator(0), m_cur(0), m_capacity(0) {} utHashTableIterator(Iterator begin, UTsize size) : m_iterator(begin), m_cur(0), m_capacity(size) { } utHashTableIterator(T &v) : m_iterator(v.ptr()), m_cur(0), m_capacity(v.size()) {} ~utHashTableIterator() {} UT_INLINE bool hasMoreElements(void) const { return (m_iterator && m_cur < m_capacity); } UT_INLINE Pair getNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++];} UT_INLINE ConstPair getNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++];} UT_INLINE void next(void) const { UT_ASSERT(hasMoreElements()); ++m_cur; } UT_INLINE Pair peekNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur]; } UT_INLINE KeyType peekNextKey(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].first;} UT_INLINE ValueType peekNextValue(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].second; } UT_INLINE ConstPair peekNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur]; } UT_INLINE ConstKeyType peekNextKey(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].first;} UT_INLINE ConstValueType peekNextValue(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].second; } }; // magic numbers from http://www.isthe.com/chongo/tech/comp/fnv/ #define _UT_INITIAL_FNV 0x9E3779B1 #define _UT_INITIAL_FNV2 0x9E3779B9 #define _UT_MULTIPLE_FNV 0x1000193 #define _UT_TWHASH(key) \ key += ~(key << 15); \ key ^= (key >> 10); \ key += (key << 3); \ key ^= (key >> 6); \ key += ~(key << 11); \ key ^= (key >> 16); class utCharHashKey { protected: char *m_key; mutable UThash m_hash; public: utCharHashKey() : m_key(0), m_hash(UT_NPOS) {} utCharHashKey(char *k) : m_key(k), m_hash(UT_NPOS) {hash();} utCharHashKey(const char *k) : m_key(const_cast<char *>(k)), m_hash(UT_NPOS) {} // Copy constructor utCharHashKey(const utCharHashKey &k) : m_key(k.m_key), m_hash(k.m_hash) {} UT_INLINE const char *key(void) const {return m_key;} UThash hash(void) const { if (!m_key) return UT_NPOS; // use cached hash if (m_hash != UT_NPOS) return m_hash; // Fowler / Noll / Vo (FNV) Hash m_hash = (UThash)_UT_INITIAL_FNV; for (int i = 0; m_key[i]; i++) { m_hash = m_hash ^(m_key[i]); // xor the low 8 bits m_hash = m_hash * _UT_MULTIPLE_FNV; // multiply by the magic number } return m_hash; } UT_INLINE bool operator== (const utCharHashKey &v) const {return hash() == v.hash();} UT_INLINE bool operator!= (const utCharHashKey &v) const {return hash() != v.hash();} UT_INLINE bool operator== (const UThash &v) const {return hash() == v;} UT_INLINE bool operator!= (const UThash &v) const {return hash() != v;} }; class utIntHashKey { protected: UTint32 m_key; public: utIntHashKey() : m_key(0) {} utIntHashKey(UTint32 k) : m_key(k) {} utIntHashKey(const utIntHashKey &k) : m_key(k.m_key) {} UT_INLINE UTint32 key(void) const { return m_key; } UT_INLINE UThash hash(void) const { return static_cast<UThash>(m_key) * _UT_INITIAL_FNV; } UT_INLINE bool operator== (const utIntHashKey &v) const {return hash() == v.hash();} UT_INLINE bool operator!= (const utIntHashKey &v) const {return hash() != v.hash();} UT_INLINE bool operator== (const UThash &v) const {return hash() == v;} UT_INLINE bool operator!= (const UThash &v) const {return hash() != v;} }; class utPointerHashKey { protected: void *m_key; public: utPointerHashKey() : m_key(0) {} utPointerHashKey(void *k) : m_key(k) {} utPointerHashKey(const utPointerHashKey &k) : m_key(k.m_key) {} UT_INLINE void *key(void) {return m_key;} UT_INLINE const void *key(void) const {return m_key;} UT_INLINE UThash hash(void) const { UThash key = static_cast<UThash>(reinterpret_cast<UTuintPtr>(m_key)); _UT_TWHASH(key); return key; } UT_INLINE bool operator== (const utPointerHashKey &v) const {return hash() == v.hash();} UT_INLINE bool operator!= (const utPointerHashKey &v) const {return hash() != v.hash();} UT_INLINE bool operator== (const UThash &v) const {return hash() == v;} UT_INLINE bool operator!= (const UThash &v) const {return hash() != v;} }; template<typename Key, typename Value> struct utHashEntry { Key first; Value second; utHashEntry() {} utHashEntry(const Key &k, const Value &v) : first(k), second(v) {} UT_INLINE const utHashEntry &operator=(const utHashEntry &rhs) { first = rhs.first; second = rhs.second; return *this; } UT_INLINE bool operator==(const utHashEntry &rhs) const { return first == rhs.first && second == rhs.second; } }; #define _UT_UTHASHTABLE_HASH(key) ((key.hash() & (m_capacity - 1))) #define _UT_UTHASHTABLE_HKHASH(key) ((hk & (m_capacity - 1))) // Initial table size #define _UT_UTHASHTABLE_INIT 32 #define _UT_UTHASHTABLE_EXPANSE (m_size * 2) // Force power of two table size. #define _UT_UTHASHTABLE_FORCE_POW2 1 #define _UT_UTHASHTABLE_STAT 0 #define _UT_UTHASHTABLE_STAT_ALLOC 0 #if _UT_UTHASHTABLE_FORCE_POW2 == 1 #define _UT_UTHASHTABLE_POW2(x) \ --x; x |= x >> 16; x |= x >> 8; x |= x >> 4; \ x |= x >> 2; x |= x >> 1; ++x; #define _UT_UTHASHTABLE_IS_POW2(x) (x && !((x-1) & x)) #endif #if _UT_UTHASHTABLE_STAT == 1 # include <stdio.h> # include <typeinfo> #endif template < typename Key, typename Value> class utHashTable { public: typedef utHashEntry<Key, Value> Entry; typedef const utHashEntry<Key, Value> ConstEntry; typedef Entry *EntryArray; typedef UTsize *IndexArray; typedef Key KeyType; typedef Value ValueType; typedef const Key ConstKeyType; typedef const Value ConstValueType; typedef Value &ReferenceValueType; typedef const Value &ConstReferenceValueType; typedef Key &ReferenceKeyType; typedef const Key &ConstReferenceKeyType; typedef EntryArray Pointer; typedef const Entry *ConstPointer; typedef utHashTableIterator<utHashTable<Key, Value> > Iterator; typedef const utHashTableIterator<utHashTable<Key, Value> > ConstIterator; public: utHashTable() : m_size(0), m_capacity(0), m_lastPos(UT_NPOS), m_iptr(0), m_nptr(0), m_bptr(0), m_cache(0) { } utHashTable(UTsize capacity) : m_size(0), m_capacity(0), m_lastPos(UT_NPOS), m_iptr(0), m_nptr(0), m_bptr(0), m_cache(0) { } utHashTable(const utHashTable &rhs) : m_size(0), m_capacity(0), m_lastPos(UT_NPOS), m_iptr(0), m_nptr(0), m_bptr(0), m_cache(0) { doCopy(rhs); } ~utHashTable() { clear(); } utHashTable<Key, Value> &operator = (const utHashTable<Key, Value> &rhs) { if (this != &rhs) doCopy(rhs); return *this; } void clear(bool useCache = false) { if (!useCache) { m_size = m_capacity = 0; m_lastKey = UT_NPOS; m_lastPos = UT_NPOS; m_cache = 0; delete [] m_bptr; delete [] m_iptr; delete [] m_nptr; m_bptr = 0; m_iptr = 0; m_nptr = 0; } else { ++m_cache; if (m_cache > _UT_CACHE_LIMIT) clear(false); else { m_size = 0; m_lastKey = UT_NPOS; m_lastPos = UT_NPOS; UTsize i; // Must zero for (i=0; i<m_capacity; ++i) { m_iptr[i] = UT_NPOS; m_nptr[i] = UT_NPOS; } } } } Value &at(UTsize i) { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].second; } Value &operator [](UTsize i) { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].second; } const Value &at(UTsize i)const { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].second; } const Value &operator [](UTsize i) const { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].second; } Key &keyAt(UTsize i) { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].first; } const Key &keyAt(UTsize i)const { UT_ASSERT(m_bptr && i >= 0 && i < m_size); return m_bptr[i].first; } // Find and cache key Value* get(const Key &key) const { if (!m_bptr || m_size == 0) return (Value*)0; UThash hr = key.hash(); if (m_lastKey != hr) { UTsize i = find(key); if (i == UT_NPOS) return (Value*)0; UT_ASSERT(i >=0 && i < m_size); m_lastKey = hr; m_lastPos = i; } return &m_bptr[m_lastPos].second; } Value* operator [](const Key &key) { return get(key); } const Value* operator [](const Key &key) const { return get(key); } UTsize find(const Key &key) const { if (m_capacity == 0 || m_capacity == UT_NPOS || m_size == 0) return UT_NPOS; UTsize hk = key.hash(); // Short cut. if (m_lastPos != UT_NPOS && m_lastKey == hk) return m_lastPos; UThash hr = _UT_UTHASHTABLE_HKHASH(hk); UT_ASSERT(m_bptr && m_iptr && m_nptr); UTsize fh = m_iptr[hr]; while (fh != UT_NPOS && (key != m_bptr[fh].first)) fh = m_nptr[fh]; if (fh != UT_NPOS) { m_lastKey = hk; m_lastPos = fh; UT_ASSERT(fh >= 0 && fh < m_size); } return fh; } void erase(const Key &key) {remove(key);} void remove(const Key &key) { UThash hash, lhash; UTsize index, pindex, findex; findex = find(key); if (findex == UT_NPOS || m_capacity == 0 || m_size == 0) return; m_lastKey = UT_NPOS; m_lastPos = UT_NPOS; UT_ASSERT(m_bptr && m_iptr && m_nptr); hash = _UT_UTHASHTABLE_HASH(key); index = m_iptr[hash]; pindex = UT_NPOS; while (index != findex) { pindex = index; index = m_nptr[index]; } if (pindex != UT_NPOS) { UT_ASSERT(m_nptr[pindex] == findex); m_nptr[pindex] = m_nptr[findex]; } else m_iptr[hash] = m_nptr[findex]; UTsize lindex = m_size - 1; if (lindex == findex) { --m_size; //m_bptr[m_size].~Entry(); return; } lhash = _UT_UTHASHTABLE_HASH(m_bptr[lindex].first); index = m_iptr[lhash]; pindex = UT_NPOS; while (index != lindex) { pindex = index; index = m_nptr[index]; } if (pindex != UT_NPOS) { UT_ASSERT(m_nptr[pindex] == lindex); m_nptr[pindex] = m_nptr[lindex]; } else m_iptr[lhash] = m_nptr[lindex]; m_bptr[findex] = m_bptr[lindex]; m_nptr[findex] = m_iptr[lhash]; m_iptr[lhash] = findex; --m_size; //m_bptr[m_size].~Entry(); return; } bool insert(const Key &key, const Value &val) { if (find(key) != UT_NPOS) return false; if (m_size == m_capacity) reserve(m_size == 0 ? _UT_UTHASHTABLE_INIT : _UT_UTHASHTABLE_EXPANSE); const UThash hr = _UT_UTHASHTABLE_HASH(key); UT_ASSERT(m_bptr && m_iptr && m_nptr); m_bptr[m_size] = Entry(key, val); m_nptr[m_size] = m_iptr[hr]; m_iptr[hr] = m_size; ++m_size; return true; } UT_INLINE Pointer ptr(void) { return m_bptr; } UT_INLINE ConstPointer ptr(void) const { return m_bptr; } UT_INLINE bool valid(void) const { return m_bptr != 0;} UT_INLINE UTsize size(void) const { return m_size; } UT_INLINE UTsize capacity(void) const { return m_capacity; } UT_INLINE bool empty(void) const { return m_size == 0; } Iterator iterator(void) { return m_bptr && m_size > 0 ? Iterator(m_bptr, m_size) : Iterator(); } ConstIterator iterator(void) const { return m_bptr && m_size > 0 ? ConstIterator(m_bptr, m_size) : ConstIterator(); } void reserve(UTsize nr) { if (m_capacity < nr && nr != UT_NPOS) rehash(nr); } #if _UT_UTHASHTABLE_STAT == 1 void report(void) const { if (m_capacity == 0 || m_capacity == UT_NPOS || m_size == 0) return; UT_ASSERT(m_bptr && m_iptr && m_nptr); UTsize min_col= m_size, max_col = 0; UTsize i, tot=0, avg = 0; for (i=0; i<m_size; ++i) { Key &key = m_bptr[i].first; UThash hr = _UT_UTHASHTABLE_HASH(key); UTsize nr = 0; UTsize fh = m_iptr[hr]; while (fh != UT_NPOS && (key != m_bptr[fh].first)) { fh = m_nptr[fh]; nr++; } if (nr < min_col) min_col = nr; if (nr > max_col) max_col = nr; tot += nr; avg += nr ? 1 : 0; } #if _UT_UTHASHTABLE_FORCE_POW2 == 1 printf("Results using forced power of 2 expansion.\n\n"); #else printf("Results using unaltered expansion.\n\n"); #endif printf("\tTotal number of collisions %i for a table of size %i.\n\t\tusing (%s)\n", tot, m_size, typeid(Key).name()); printf("\tThe minimum number of collisions per key: %i\n", min_col); printf("\tThe maximum number of collisions per key: %i\n", max_col); int favr = (int)(100.f * ((float)avg / (float)m_size)); printf("\tThe average number of key collisions: %i\n\n", favr); if (tot == 0) printf("\nCongratulations lookup is 100%% linear!\n\n"); else if (favr > 35) printf("\nImprove your hash function!\n\n"); } #endif private: void doCopy(const utHashTable<Key, Value> &rhs) { if (rhs.empty()) clear(); else if (rhs.valid()) { reserve(rhs.m_capacity); UTsize i, b; m_size = rhs.m_size; m_capacity = rhs.m_capacity; b = m_size > 0 ? m_size - 1 : 0; // Zero i & n (from end of buffer) for (i=b; i<m_capacity; ++i) m_nptr[i] = m_iptr[i] = UT_NPOS; for (i=0; i<m_size; ++i) { m_bptr[i] = rhs.m_bptr[i]; m_iptr[i] = rhs.m_iptr[i]; m_nptr[i] = rhs.m_nptr[i]; } } } template<typename ArrayType> void reserveType(ArrayType **old, UTsize nr, bool cpy=false) { UTsize i; ArrayType *nar = new ArrayType[nr]; if ((*old)!= 0) { if (cpy) { const ArrayType *oar = (*old); for (i = 0; i < m_size; i++) nar[i] = oar[i]; } delete [](*old); } (*old) = nar; } void rehash(UTsize nr) { #if _UT_UTHASHTABLE_FORCE_POW2 if (!_UT_UTHASHTABLE_IS_POW2(nr)) { _UT_UTHASHTABLE_POW2(nr); } #if _UT_UTHASHTABLE_STAT_ALLOC == 1 printf("Expanding tables: %i\n", nr); #endif UT_ASSERT(_UT_UTHASHTABLE_IS_POW2(nr)); #else #if _UT_UTHASHTABLE_STAT_ALLOC == 1 printf("Expanding tables: %i\n", nr); #endif #endif reserveType<Entry>(&m_bptr, nr, true); reserveType<UTsize>(&m_iptr, nr); reserveType<UTsize>(&m_nptr, nr); m_capacity = nr; UT_ASSERT(m_bptr && m_iptr && m_nptr); UTsize i, h; for (i=0; i<m_capacity; ++i) m_iptr[i] = m_nptr[i] = UT_NPOS; for (i = 0; i < m_size; i++) { h = _UT_UTHASHTABLE_HASH(m_bptr[i].first); m_nptr[i] = m_iptr[h]; m_iptr[h] = i; } } UTsize m_size, m_capacity; mutable UTsize m_lastPos; mutable UTsize m_lastKey; IndexArray m_iptr; IndexArray m_nptr; EntryArray m_bptr; UTsize m_cache; }; UT_INLINE UThash utHash(int v) { utIntHashKey hk(v); return hk.hash(); } UT_INLINE UThash utHash(const char *v) { utCharHashKey hk(v); return hk.hash(); } UT_INLINE UThash utHash(void *v) { utPointerHashKey hk(v); return hk.hash(); } template <typename T> class utHashSetIterator { public: typedef typename T::Pointer Iterator; typedef typename T::ValueType &ValueType; typedef typename T::ConstValueType &ConstValueType; protected: mutable Iterator m_iterator; mutable UTsize m_cur; const UTsize m_capacity; public: utHashSetIterator() : m_iterator(0), m_cur(0), m_capacity(0) {} utHashSetIterator(Iterator begin, UTsize size) : m_iterator(begin), m_cur(0), m_capacity(size) { } utHashSetIterator(T &t) : m_iterator(t.ptr()), m_cur(0), m_capacity(t.size()) { } ~utHashSetIterator() {} UT_INLINE bool hasMoreElements(void) const { return (m_iterator && m_cur < m_capacity); } UT_INLINE ValueType getNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++].second;} UT_INLINE ConstValueType getNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur++].second;} UT_INLINE void next(void) const { UT_ASSERT(hasMoreElements()); ++m_cur; } UT_INLINE ValueType peekNext(void) { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].second; } UT_INLINE ConstValueType peekNext(void) const { UT_ASSERT(hasMoreElements()); return m_iterator[m_cur].second; } }; template<typename T> class utHashSet { public: class THashKey { protected: T m_key; mutable UThash m_cache; public: THashKey() : m_key(T()), m_cache(UT_NPOS) {} THashKey(const T &k) : m_key(k), m_cache(UT_NPOS) {} THashKey(const THashKey &k) : m_key(k.m_key), m_cache(k.m_cache) {} UT_INLINE UThash hash(void) const { if (m_cache != UT_NPOS) return m_cache; m_cache = utHash(m_key); return m_cache; } UT_INLINE bool operator== (const THashKey &v) const {return hash() == v.hash();} UT_INLINE bool operator!= (const THashKey &v) const {return hash() != v.hash();} UT_INLINE bool operator== (const UThash &v) const {return hash() == v;} UT_INLINE bool operator!= (const UThash &v) const {return hash() != v;} }; typedef utHashTable<THashKey, T> Hash; typedef typename Hash::Pointer Pointer; typedef typename Hash::ConstPointer ConstPointer; typedef typename Hash::ValueType ValueType; typedef typename Hash::ConstValueType ConstValueType; typedef utHashSetIterator<utHashSet<T> > Iterator; typedef const utHashSetIterator<utHashSet<T> > ConstIterator; public: utHashSet() {} utHashSet(const utHashSet &oth) : m_table(oth) {} ~utHashSet() {m_table.clear();} void clear(bool useCache=false) { m_table.clear(useCache); } bool insert(const T &v) { return m_table.insert(v, v); } void erase(const T &v) { m_table.remove(v); } UTsize find(const T &v) const { return m_table.find(v); } UT_INLINE T &operator[](UTsize idx) { UT_ASSERT(idx >= 0 && idx < size()); return m_table.at(idx); } UT_INLINE const T &operator[](UTsize idx) const { UT_ASSERT(idx >= 0 && idx < size()); return m_table.at(idx); } UT_INLINE T &at(UTsize idx) { UT_ASSERT(idx >= 0 && idx < size()); return m_table.at(idx); } UT_INLINE const T &at(UTsize idx) const { UT_ASSERT(idx >= 0 && idx < size()); return m_table.at(idx); } UT_INLINE UTsize size(void) const { return m_table.size(); } UT_INLINE bool empty(void) const { return m_table.empty();} UT_INLINE Pointer ptr(void) { return m_table.ptr();} UT_INLINE ConstPointer ptr(void) const { return m_table.ptr();} UT_INLINE Iterator iterator(void) {return empty() ? Iterator() : Iterator(m_table.ptr(), m_table.size());} UT_INLINE ConstIterator iterator(void) const { return empty() ? ConstIterator() : ConstIterator(const_cast<Pointer>(m_table.ptr()), m_table.size()); } utHashSet<T>& operator=(const utHashSet<T>& rhs) { if (this != &rhs) m_table = rhs.m_table; return *this; } #if _UT_UTHASHTABLE_STAT == 1 void report(void) const { m_table.report(); } #endif private: Hash m_table; }; #endif//_utTypes_h_
[ "thomas.trocha@gmail.com" ]
thomas.trocha@gmail.com
6fc46ea3ef40e85a9d037fb4de008283c7229675
aad28fa1140e713c8591db5a383ac5f6605f743b
/48 Проблема Николая/Проблема Николая.cpp
336631a597fed69863270894bec8c3a537d5a901
[]
no_license
DaniilMuntyan/Solutions_e-olymp
d7ad45357d4f999c853efefcd47c39bc17e33664
7a318572e13f2e6103a2ade49c8ce9c5210caad9
refs/heads/master
2021-02-28T15:22:58.506994
2020-03-07T21:42:50
2020-03-07T21:42:50
245,708,666
3
0
null
null
null
null
UTF-8
C++
false
false
248
cpp
#include <bits/stdc++.h> #include <iostream> using namespace std; int main() { long long n,m,i,res=1; cin >> n >> m; if(n>=m) res = 0; else for(i=2;i<=n;i++) { res=(res*i)%m; } cout << res << endl; }
[ "daniilmuntjan@gmail.com" ]
daniilmuntjan@gmail.com
3fec6380ae525b260ffbc92c4a69768cb8d3460b
10e56cef33684fb1b9650b5f1ebbdeb0baa69b46
/src/devices/SDRReceiver.cpp
6a1a367c4e228ccfc4d870f41f1429f4f675cb28
[]
no_license
lemontongs/myhackrf
b23c49d1ade9d4dd86a6e105e3fd55a595faa09b
95858bc7f825195c841501fea4832ef5db5d0d82
refs/heads/master
2023-06-10T13:02:06.171208
2023-06-03T17:45:00
2023-06-03T17:50:46
32,106,279
10
2
null
null
null
null
UTF-8
C++
false
false
3,238
cpp
#include "SDRReceiver.h" #include <unistd.h> #include <iostream> SDRReceiver::SDRReceiver() { m_isRunning = false; m_isInitialized = false; m_data_port = "5555"; m_comm_port = "5556"; m_data_target = "tcp://localhost:" + m_data_port; m_comm_target = "tcp://localhost:" + m_comm_port; // Setup the comm bits m_comm_context = new zmq::context_t(1); m_comm_socket = new zmq::socket_t(*m_comm_context, ZMQ_REQ); } SDRReceiver::~SDRReceiver() { delete m_comm_socket; delete m_comm_context; } void SDRReceiver::setIP(std::string ipAddress) { m_data_target = "tcp://" + ipAddress + ":" + m_data_port; m_comm_target = "tcp://" + ipAddress + ":" + m_comm_port; } void* thread_func(void* args) { std::cout << "Rx thread started" << std::endl; SDRReceiver* sdr_obj = (SDRReceiver*)args; sdr_obj->receivePackets(); return nullptr; } bool SDRReceiver::initialize(sdr_receive_callback_t callback, void* callback_args) { if(!m_isInitialized) { try { m_comm_socket->connect( m_comm_target.c_str() ); } catch (zmq::error_t &e) { std::cout << e.what() << std::endl; m_isInitialized = false; return false; } m_callback = callback; m_callback_args = callback_args; pthread_create( &m_thread_context, NULL, thread_func, (void*)this ); m_isInitialized = true; return true; } return false; } void SDRReceiver::stop() { m_isRunning = false; while(m_isInitialized) sleep(1); m_comm_socket->close(); } void SDRReceiver::receivePackets() { // Setup the data receiver zmq::context_t recv_context(1); zmq::socket_t socket(recv_context, ZMQ_SUB); socket.connect( m_data_target.c_str() ); socket.setsockopt(ZMQ_SUBSCRIBE, "", 0); int timeout = 100; // ms socket.setsockopt(ZMQ_RCVTIMEO, &timeout, sizeof(timeout)); m_isRunning = true; while (m_isRunning) { zmq::message_t msg; if ( socket.recv(msg, zmq::recv_flags::none) ) { char* data_p = static_cast<char*>(msg.data()); std::string data( data_p, msg.size() ); Packet p; p.ParseFromString(data); m_callback( p, m_callback_args ); } } m_isInitialized = false; } void SDRReceiver::tune(uint64_t fc_hz) { std::stringstream ss; ss << "set-fc " << fc_hz; s_send(*m_comm_socket, ss.str()); std::string response = s_recv(*m_comm_socket); } void SDRReceiver::setSampleRate(double fs_hz) { std::stringstream ss; ss << "set-fs " << fs_hz; s_send(*m_comm_socket, ss.str()); std::string response = s_recv(*m_comm_socket); } double SDRReceiver::getSampleRate() { s_send(*m_comm_socket, std::string("get-fs")); std::stringstream ss(s_recv(*m_comm_socket)); double fs_hz; ss >> fs_hz; return fs_hz; } uint64_t SDRReceiver::getCenterFrequency() { s_send(*m_comm_socket, std::string("get-fc")); std::stringstream ss(s_recv(*m_comm_socket)); uint64_t fc_hz; ss >> fc_hz; return fc_hz; }
[ "lemontongs@gmail.com" ]
lemontongs@gmail.com
2a38d43af178eba0f3406f8ddeab00e1bcabfd8a
693b765dfd0a0fc916d1862cadfaa2a59fec6f4e
/src/MapData.cpp
7d700f19e87c6ccfd189e7e1b6c44c2783291861
[ "MIT" ]
permissive
ImagicTheCat/LUIS
ff2c7b159cc6661769b7d6b754d0f8675de9adaa
1fa88ac41a944e6cdba30cf11c77f55f143d02b0
refs/heads/master
2020-03-11T07:57:08.585615
2019-04-24T11:23:15
2019-04-24T11:23:15
129,870,833
1
1
MIT
2018-12-08T19:11:45
2018-04-17T08:19:37
C++
UTF-8
C++
false
false
1,804
cpp
#include "MapData.hpp" #include "tools.hpp" bool MapData::has(const std::string &key) const { return map.find(key) != map.end(); } const std::string& MapData::get(const std::string &key) const { std::map<std::string, std::string>::const_iterator it = map.find(key); if(it != map.end()) return it->second; else return empty_string; } void MapData::set(const std::string &key, const std::string &value) { std::map<std::string, std::string>::iterator it = map.find(key); if(it != map.end()) it->second = value; else map.insert(std::pair<std::string, std::string>(key, value)); } void MapData::unset(const std::string &key) { std::map<std::string, std::string>::iterator it = map.find(key); if(it != map.end()) map.erase(it); } void MapData::load(const std::string &data) { std::istringstream in(data); std::string line; while(std::getline(in, line)){ line = replace(line, "\r", ""); size_t spos = line.find(" "); if(spos != std::string::npos) // set key/value set(line.substr(0, spos), line.substr(spos+1)); } } void MapData::write(std::string &data) const { data.clear(); for(std::map<std::string, std::string>::const_iterator it = map.begin(); it != map.end(); it++) data += it->first+" "+it->second+"\r\n"; } bool MapData::loadFile(const std::string &path) { std::ifstream file(path.c_str()); if(file){ std::string data((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); load(data); return true; } else return false; } bool MapData::writeFile(const std::string &path) const { std::ofstream file(path.c_str(), std::ios::trunc); if(file){ std::string data; write(data); file.write(data.c_str(), data.size()); return true; } else return false; }
[ "imagicthecat@gmail.com" ]
imagicthecat@gmail.com
e8726c6ede9c489fe1a1fa2dba1b4082dd4702d3
384f8f30d616d4db35307b12f830a0ed23757125
/ext2/ExchangeBaseTest.cpp
1c6dcbfc4ddc6a1641f83ad54264c1283edf7539
[]
no_license
qijuweni/Ext2
eb32a290175307e1eb8a491d73e0a2b5fd4f5e80
49fe450d8583d0afbd5ba0f5eb70ba6af93a0739
refs/heads/master
2021-01-10T04:43:40.518763
2015-10-15T15:00:21
2015-10-15T15:00:21
44,324,798
0
0
null
null
null
null
UTF-8
C++
false
false
779
cpp
#include "gtest/gtest.h" #include "CLExchangeBase.h" #include "CLFileDev.h" #include "SInode.h" TEST(Exchangebase,test) { CLFileDev * pf = new CLFileDev; pf->InitDev(); pf->OpenDev(); CLExchangeBase *pe = new CLExchangeBase(pf, 6, 7); t_block a = "qijunweilkjhgfdsa"; pe->WriteBlock(a, 8); t_block b = "123456789qwertyuiop"; pe->WriteBlock(b, 9); t_block c; t_block d; pe->ReadBlock(c, 8); pe->ReadBlock(d,9); EXPECT_STREQ(c, a); EXPECT_STREQ(d,b); s_inode s,q,w; s.uid = q.uid = 1; s.gid = q.gid = 2; s.mode = q.mode = 3; s.links = q.links = 4; s.type = q.type =5; pe->WriteInode(&s, 5); pe->ReadInode(&w, 5); EXPECT_EQ(q.uid,w.uid); EXPECT_EQ(q.gid,w.gid); EXPECT_EQ(q.links,w.links); EXPECT_EQ(q.mode,w.mode); EXPECT_EQ(q.type,w.type); }
[ "708913847@qq.com" ]
708913847@qq.com
29f6690433308f17414ca74560c821be8a6d4da0
3931f4eb1bf6d03085ac4498f3d4365058ea5a3d
/common/log_writer.h
70c95081eaa33d8215c1551e4bc847f01d7d75b9
[ "BSD-3-Clause" ]
permissive
oneSapling/lsbm
90353c5c1b12bed3a08e3b109386786d73029acf
8a1ba121067d7db23661f0a5e895e02420f89213
refs/heads/master
2021-06-14T04:45:18.385935
2017-04-21T18:13:26
2017-04-21T18:13:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,285
h
// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #ifndef STORAGE_LEVELDB_DB_LOG_WRITER_H_ #define STORAGE_LEVELDB_DB_LOG_WRITER_H_ #include <stdint.h> #include "log_format.h" #include "leveldb/slice.h" #include "leveldb/status.h" namespace leveldb { class WritableFile; namespace log { class Writer { public: // Create a writer that will append data to "*dest". // "*dest" must be initially empty. // "*dest" must remain live while this Writer is in use. explicit Writer(WritableFile* dest); ~Writer(); Status AddRecord(const Slice& slice); private: WritableFile* dest_; int block_offset_; // Current offset in block // crc32c values for all supported record types. These are // pre-computed to reduce the overhead of computing the crc of the // record type stored in the header. uint32_t type_crc_[kMaxRecordType + 1]; Status EmitPhysicalRecord(RecordType type, const char* ptr, size_t length); // No copying allowed Writer(const Writer&); void operator=(const Writer&); }; } // namespace log } // namespace leveldb #endif // STORAGE_LEVELDB_DB_LOG_WRITER_H_
[ "tengdj@vip.qq.com" ]
tengdj@vip.qq.com
00cc022f5dd4d814608d575eca644aa2bbe334a5
d7b84a31cafb72a3cb71b3a3cc724a68119ba18e
/Tyr/6.02/uniform/time
c26fc4d87002f419563a32807ae90dbf2966d9ab
[]
no_license
benroque/Ragnorak
6cc7c68db801f9281a4ac241da754bce88ef6caf
a1bfc2430cccb207192792acebdd1530f1388a4c
refs/heads/master
2021-01-14T08:13:18.774988
2017-02-20T08:32:53
2017-02-20T08:32:53
82,008,402
0
0
null
null
null
null
UTF-8
C++
false
false
995
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "6.02/uniform"; object time; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // value 6.01999999999955904; name "6.02"; index 3010; deltaT 0.002; deltaT0 0.002; // ************************************************************************* //
[ "benroque94@gmail.com" ]
benroque94@gmail.com
1d7e64abff8bc18f6d7aa8d5688cb4157be5d61d
3d3eba37dcceb187c8a050bf812f336461e5ec9f
/cal_proj2/Algorithms.cpp
a91249b57b66dc7d05867d2748df4867b8e9dc49
[]
no_license
marques999/feup-cal
5885915274e7a5efede14213deacbc3af71fb67f
b3177c016cd6f7fd669521500f38528dc94f2133
refs/heads/master
2021-01-18T12:52:23.890568
2018-02-23T21:44:12
2018-02-23T21:44:12
34,289,619
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
2,112
cpp
/*! * \file Algorithms.cpp * * FEUP_CAL1415_2MIEIC01_D * \author Diogo Marques * \author Jose Taveira * \author Vitor Esteves * * \date Maio 2015 * */ #include "Algorithms.h" static bool compare(char a, char b) { if (a >= 32 && a <= 127) { return toupper(a) == toupper(b); } switch (a) { case '\xc6': case '\xc7': // ãà case '\x83': case '\xb7': // àÀ case '\x85': case '\xb6': // àÀ case '\xa0': case '\xb5': // áÁ return 'A' == toupper(b); case '\x82': case '\x90': // éÉ case '\x88': case '\xd2': // êÊ return 'E' == toupper(b); case '\xa1': case '\xd6': // íÍ return 'I' == toupper(b); case '\xa2': case '\xe0': // óÓ case '\xe4': case '\xe5': // õÕ case '\x93': case '\xe2': // ôÔ return 'O' == toupper(b); case '\xa3': case '\xe9': // úÚ return 'U' == toupper(b); case '\x80': case '\x87': // çÇ return 'C' == toupper(b); } return false; } unsigned LevenshteinDistance(const string& s1, const string& s2) { const unsigned len1 = s1.size(); const unsigned len2 = s2.size(); const unsigned mlen = min(len1, len2); vector<unsigned> col(len2 + 1); vector<unsigned> prevCol(len2 + 1); for (unsigned i = 0; i < prevCol.size(); i++) { prevCol[i] = i; } for (unsigned i = 0; i < mlen; i++) { col[0] = i + 1; for (unsigned j = 0; j < len2; j++) { col[j + 1] = MIN3(prevCol[1 + j] + 1, col[j] + 1, prevCol[j] + (compare(s1[i], s2[i]) ? 0 : 1)); } col.swap(prevCol); } return prevCol[len2]; } unsigned LongestCommonSubstring(const string& s1, const string& s2) { if (s1.empty() || s2.empty()) { return 0; } vector<unsigned> curr(s2.size()); vector<unsigned> prev(s1.size()); vector<unsigned> swap; unsigned index = 0; for (unsigned i = 0; i < s1.size(); ++i) { for (unsigned j = 0; j < s2.size(); ++j) { if (!compare(s1[i], s2[j])) { curr[j] = 0; } else { if (i == 0 || j == 0) { curr[j] = 1; } else { curr[j] = 1 + prev[j - 1]; } index = max(index, curr[j]); } } swap = curr; curr = prev; prev = swap; } return index; }
[ "xmarques999@hotmail.com" ]
xmarques999@hotmail.com
76ff83477ef021e396281738d33f0f368943c323
36a6b98068cac9a11f009a42e0293134d49307f2
/하나의 문자열 안의 글자수 세기.cpp
406c9414b99867f2707421c2e999baf87910e59d
[]
no_license
JunHaHwang98/C_Homework
80f967823afea833134736885e1aea7854de02e1
ccaa772a225e6bb6f753cd70b5457d0d9870424e
refs/heads/main
2023-04-01T13:08:14.031853
2021-04-13T11:36:32
2021-04-13T11:36:32
346,043,285
0
0
null
null
null
null
UHC
C++
false
false
256
cpp
#include <stdio.h> int main(void) { char input[1001]; gets(input); int count = 0; while(input[count] != '\0') { count++; } printf("입력한 문자열의 길이는 %d입니다.\n", count); printf("입력한 문자열 : %s", input); return 0; }
[ "80338116+JunHaHwang98@users.noreply.github.com" ]
80338116+JunHaHwang98@users.noreply.github.com
d06a3ed3e26346d443ea519640f9c919f798646d
46d84fe1b78ab6358ea352c4808cf8ec784a1143
/BMS/AddSaveingCardDlg.h
69f2f31d93a0e92d0e4ce1840abea0ed2f21d6ae
[]
no_license
Swayxw/BMS
001f8ea581190826b4e8154a10cbb2eb0fc199c4
0ec5007cacc87db432b8ecdfb39b3838c0865d43
refs/heads/master
2020-05-17T00:46:12.406386
2015-06-20T05:52:45
2015-06-20T05:52:45
34,659,781
0
0
null
null
null
null
UTF-8
C++
false
false
472
h
#pragma once // AddSaveingCardDlg dialog class AddSaveingCardDlg : public CDialogEx { DECLARE_DYNAMIC(AddSaveingCardDlg) public: AddSaveingCardDlg(CWnd* pParent = NULL); // standard constructor virtual ~AddSaveingCardDlg(); // Dialog Data enum { IDD = IDD_ADD_SAVINGCARD_DIALOG}; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support DECLARE_MESSAGE_MAP() public: afx_msg void OnBnClickedOk(); virtual BOOL OnInitDialog(); };
[ "286183854@qq.com" ]
286183854@qq.com
eb6c2ffad91f4d091d67755d08941d868c941d00
2d36ac7285664ce798edb27bafa00e0dbc0f25fb
/LSL/liblsl/external/lslboost/asio/windows/stream_handle.hpp
4a82727f568a0d23cfc7477909ebe6afaa196ddf
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
nagarjunvinukonda/Brain-Computer-Interface-for-Bionic-Arm
af1a6241df167e747a7d9426e497f95dda632fda
839cb0dc798d2bf274d3df7c4db0fef62af3770d
refs/heads/master
2023-02-13T12:02:36.692225
2021-01-14T08:32:35
2021-01-14T08:32:35
297,540,583
2
0
null
null
null
null
UTF-8
C++
false
false
1,089
hpp
// // windows/stream_handle.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.lslboost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP #define BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <lslboost/asio/detail/config.hpp> #if defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) \ || defined(GENERATING_DOCUMENTATION) #include <lslboost/asio/windows/basic_stream_handle.hpp> namespace lslboost { namespace asio { namespace windows { /// Typedef for the typical usage of a stream-oriented handle. typedef basic_stream_handle<> stream_handle; } // namespace windows } // namespace asio } // namespace lslboost #endif // defined(BOOST_ASIO_HAS_WINDOWS_STREAM_HANDLE) // || defined(GENERATING_DOCUMENTATION) #endif // BOOST_ASIO_WINDOWS_STREAM_HANDLE_HPP
[ "vinukondanagarjun4@gmail.com" ]
vinukondanagarjun4@gmail.com
c9a32ac2ed5eaf88a63742028f1f5ec4f157d32b
544cfadc742536618168fc80a5bd81a35a5f2c99
/packages/modules/StatsD/lib/libstatssocket/tests/stats_event_test.cpp
2f9ccdc5c558d2f27a88cf5577b8b1c396bfe795
[]
no_license
ZYHGOD-1/Aosp11
0400619993b559bf4380db2da0addfa9cccd698d
78a61ca023cbf1a0cecfef8b97df2b274ac3a988
refs/heads/main
2023-04-21T20:13:54.629813
2021-05-22T05:28:21
2021-05-22T05:28:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,064
cpp
/* * Copyright (C) 2019 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 "stats_event.h" #include <gtest/gtest.h> #include <utils/SystemClock.h> // Keep in sync with stats_event.c. Consider moving to separate header file to avoid duplication. /* ERRORS */ #define ERROR_NO_TIMESTAMP 0x1 #define ERROR_NO_ATOM_ID 0x2 #define ERROR_OVERFLOW 0x4 #define ERROR_ATTRIBUTION_CHAIN_TOO_LONG 0x8 #define ERROR_TOO_MANY_KEY_VALUE_PAIRS 0x10 #define ERROR_ANNOTATION_DOES_NOT_FOLLOW_FIELD 0x20 #define ERROR_INVALID_ANNOTATION_ID 0x40 #define ERROR_ANNOTATION_ID_TOO_LARGE 0x80 #define ERROR_TOO_MANY_ANNOTATIONS 0x100 #define ERROR_TOO_MANY_FIELDS 0x200 #define ERROR_INVALID_VALUE_TYPE 0x400 #define ERROR_STRING_NOT_NULL_TERMINATED 0x800 #define ERROR_ATOM_ID_INVALID_POSITION 0x2000 /* TYPE IDS */ #define INT32_TYPE 0x00 #define INT64_TYPE 0x01 #define STRING_TYPE 0x02 #define LIST_TYPE 0x03 #define FLOAT_TYPE 0x04 #define BOOL_TYPE 0x05 #define BYTE_ARRAY_TYPE 0x06 #define OBJECT_TYPE 0x07 #define KEY_VALUE_PAIRS_TYPE 0x08 #define ATTRIBUTION_CHAIN_TYPE 0x09 #define ERROR_TYPE 0x0F using std::string; using std::vector; // Side-effect: this function moves the start of the buffer past the read value template <class T> T readNext(uint8_t** buffer) { T value; if ((reinterpret_cast<uintptr_t>(*buffer) % alignof(T)) == 0) { value = *(T*)(*buffer); } else { memcpy(&value, *buffer, sizeof(T)); } *buffer += sizeof(T); return value; } void checkTypeHeader(uint8_t** buffer, uint8_t typeId, uint8_t numAnnotations = 0) { uint8_t typeHeader = (numAnnotations << 4) | typeId; EXPECT_EQ(readNext<uint8_t>(buffer), typeHeader); } template <class T> void checkScalar(uint8_t** buffer, T expectedValue) { EXPECT_EQ(readNext<T>(buffer), expectedValue); } void checkString(uint8_t** buffer, const string& expectedString) { uint32_t size = readNext<uint32_t>(buffer); string parsedString((char*)(*buffer), size); EXPECT_EQ(parsedString, expectedString); *buffer += size; // move buffer past string we just read } void checkByteArray(uint8_t** buffer, const vector<uint8_t>& expectedByteArray) { uint32_t size = readNext<uint32_t>(buffer); vector<uint8_t> parsedByteArray(*buffer, *buffer + size); EXPECT_EQ(parsedByteArray, expectedByteArray); *buffer += size; // move buffer past byte array we just read } template <class T> void checkAnnotation(uint8_t** buffer, uint8_t annotationId, uint8_t typeId, T annotationValue) { EXPECT_EQ(readNext<uint8_t>(buffer), annotationId); EXPECT_EQ(readNext<uint8_t>(buffer), typeId); checkScalar<T>(buffer, annotationValue); } void checkMetadata(uint8_t** buffer, uint8_t numElements, int64_t startTime, int64_t endTime, uint32_t atomId, uint8_t numAtomLevelAnnotations = 0) { // All events start with OBJECT_TYPE id. checkTypeHeader(buffer, OBJECT_TYPE); // We increment by 2 because the number of elements listed in the // serialization accounts for the timestamp and atom id as well. checkScalar(buffer, static_cast<uint8_t>(numElements + 2)); // Check timestamp checkTypeHeader(buffer, INT64_TYPE); int64_t timestamp = readNext<int64_t>(buffer); EXPECT_GE(timestamp, startTime); EXPECT_LE(timestamp, endTime); // Check atom id checkTypeHeader(buffer, INT32_TYPE, numAtomLevelAnnotations); checkScalar(buffer, atomId); } TEST(StatsEventTest, TestScalars) { uint32_t atomId = 100; int32_t int32Value = -5; int64_t int64Value = -2 * android::elapsedRealtimeNano(); float floatValue = 2.0; bool boolValue = false; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeInt32(event, int32Value); AStatsEvent_writeInt64(event, int64Value); AStatsEvent_writeFloat(event, floatValue); AStatsEvent_writeBool(event, boolValue); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/4, startTime, endTime, atomId); // check int32 element checkTypeHeader(&buffer, INT32_TYPE); checkScalar(&buffer, int32Value); // check int64 element checkTypeHeader(&buffer, INT64_TYPE); checkScalar(&buffer, int64Value); // check float element checkTypeHeader(&buffer, FLOAT_TYPE); checkScalar(&buffer, floatValue); // check bool element checkTypeHeader(&buffer, BOOL_TYPE); checkScalar(&buffer, boolValue); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestStrings) { uint32_t atomId = 100; string str = "test_string"; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeString(event, str.c_str()); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId); checkTypeHeader(&buffer, STRING_TYPE); checkString(&buffer, str); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestNullString) { uint32_t atomId = 100; char* str = nullptr; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeString(event, str); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId); checkTypeHeader(&buffer, STRING_TYPE); checkString(&buffer, ""); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestByteArrays) { uint32_t atomId = 100; vector<uint8_t> message = {'b', 'y', 't', '\0', 'e', 's'}; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeByteArray(event, message.data(), message.size()); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId); checkTypeHeader(&buffer, BYTE_ARRAY_TYPE); checkByteArray(&buffer, message); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestNullByteArrays) { uint32_t atomId = 100; uint8_t* buf = nullptr; vector<uint8_t> message; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeByteArray(event, buf, 2); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId); checkTypeHeader(&buffer, BYTE_ARRAY_TYPE); checkByteArray(&buffer, message); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestAttributionChains) { uint32_t atomId = 100; uint8_t numNodes = 50; uint32_t uids[numNodes]; vector<string> tags(numNodes); // storage that cTag elements point to const char* cTags[numNodes]; for (int i = 0; i < (int)numNodes; i++) { uids[i] = i; if (0 == i) { tags.push_back(""); cTags[i] = nullptr; } else { tags.push_back("test" + std::to_string(i)); cTags[i] = tags[i].c_str(); } } int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeAttributionChain(event, uids, cTags, numNodes); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId); checkTypeHeader(&buffer, ATTRIBUTION_CHAIN_TYPE); checkScalar(&buffer, numNodes); for (int i = 0; i < numNodes; i++) { checkScalar(&buffer, uids[i]); checkString(&buffer, tags[i]); } EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestFieldAnnotations) { uint32_t atomId = 100; // first element information bool boolValue = false; uint8_t boolAnnotation1Id = 1; uint8_t boolAnnotation2Id = 2; bool boolAnnotation1Value = true; int32_t boolAnnotation2Value = 3; // second element information float floatValue = -5.0; uint8_t floatAnnotation1Id = 3; uint8_t floatAnnotation2Id = 4; int32_t floatAnnotation1Value = 8; bool floatAnnotation2Value = false; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_writeBool(event, boolValue); AStatsEvent_addBoolAnnotation(event, boolAnnotation1Id, boolAnnotation1Value); AStatsEvent_addInt32Annotation(event, boolAnnotation2Id, boolAnnotation2Value); AStatsEvent_writeFloat(event, floatValue); AStatsEvent_addInt32Annotation(event, floatAnnotation1Id, floatAnnotation1Value); AStatsEvent_addBoolAnnotation(event, floatAnnotation2Id, floatAnnotation2Value); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/2, startTime, endTime, atomId); // check first element checkTypeHeader(&buffer, BOOL_TYPE, /*numAnnotations=*/2); checkScalar(&buffer, boolValue); checkAnnotation(&buffer, boolAnnotation1Id, BOOL_TYPE, boolAnnotation1Value); checkAnnotation(&buffer, boolAnnotation2Id, INT32_TYPE, boolAnnotation2Value); // check second element checkTypeHeader(&buffer, FLOAT_TYPE, /*numAnnotations=*/2); checkScalar(&buffer, floatValue); checkAnnotation(&buffer, floatAnnotation1Id, INT32_TYPE, floatAnnotation1Value); checkAnnotation(&buffer, floatAnnotation2Id, BOOL_TYPE, floatAnnotation2Value); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestAtomLevelAnnotations) { uint32_t atomId = 100; // atom-level annotation information uint8_t boolAnnotationId = 1; uint8_t int32AnnotationId = 2; bool boolAnnotationValue = false; int32_t int32AnnotationValue = 5; float fieldValue = -3.5; int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_addBoolAnnotation(event, boolAnnotationId, boolAnnotationValue); AStatsEvent_addInt32Annotation(event, int32AnnotationId, int32AnnotationValue); AStatsEvent_writeFloat(event, fieldValue); AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, /*numElements=*/1, startTime, endTime, atomId, /*numAtomLevelAnnotations=*/2); // check atom-level annotations checkAnnotation(&buffer, boolAnnotationId, BOOL_TYPE, boolAnnotationValue); checkAnnotation(&buffer, int32AnnotationId, INT32_TYPE, int32AnnotationValue); // check first element checkTypeHeader(&buffer, FLOAT_TYPE); checkScalar(&buffer, fieldValue); EXPECT_EQ(buffer, bufferEnd); // ensure that we have read the entire buffer EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestNoAtomIdError) { AStatsEvent* event = AStatsEvent_obtain(); // Don't set the atom id in order to trigger the error. AStatsEvent_build(event); uint32_t errors = AStatsEvent_getErrors(event); EXPECT_EQ(errors & ERROR_NO_ATOM_ID, ERROR_NO_ATOM_ID); AStatsEvent_release(event); } TEST(StatsEventTest, TestPushOverflowError) { const char* str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; const int writeCount = 120; // Number of times to write str in the event. AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, 100); // Add str to the event 120 times. Each str takes >35 bytes so this will // overflow the 4068 byte buffer. // We want to keep writeCount less than 127 to avoid hitting // ERROR_TOO_MANY_FIELDS. for (int i = 0; i < writeCount; i++) { AStatsEvent_writeString(event, str); } AStatsEvent_write(event); uint32_t errors = AStatsEvent_getErrors(event); EXPECT_EQ(errors & ERROR_OVERFLOW, ERROR_OVERFLOW); AStatsEvent_release(event); } TEST(StatsEventTest, TestPullOverflowError) { const uint32_t atomId = 10100; const vector<uint8_t> bytes(430 /* number of elements */, 1 /* value of each element */); const int writeCount = 120; // Number of times to write bytes in the event. AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); // Add bytes to the event 120 times. Size of bytes is 430 so this will // overflow the 50 KB pulled event buffer. // We want to keep writeCount less than 127 to avoid hitting // ERROR_TOO_MANY_FIELDS. for (int i = 0; i < writeCount; i++) { AStatsEvent_writeByteArray(event, bytes.data(), bytes.size()); } AStatsEvent_build(event); uint32_t errors = AStatsEvent_getErrors(event); EXPECT_EQ(errors & ERROR_OVERFLOW, ERROR_OVERFLOW); AStatsEvent_release(event); } TEST(StatsEventTest, TestLargePull) { const uint32_t atomId = 100; const string str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; const int writeCount = 120; // Number of times to write str in the event. const int64_t startTime = android::elapsedRealtimeNano(); AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); // Add str to the event 120 times. // We want to keep writeCount less than 127 to avoid hitting // ERROR_TOO_MANY_FIELDS. for (int i = 0; i < writeCount; i++) { AStatsEvent_writeString(event, str.c_str()); } AStatsEvent_build(event); int64_t endTime = android::elapsedRealtimeNano(); size_t bufferSize; uint8_t* buffer = AStatsEvent_getBuffer(event, &bufferSize); uint8_t* bufferEnd = buffer + bufferSize; checkMetadata(&buffer, writeCount, startTime, endTime, atomId); // Check all instances of str have been written. for (int i = 0; i < writeCount; i++) { checkTypeHeader(&buffer, STRING_TYPE); checkString(&buffer, str); } EXPECT_EQ(buffer, bufferEnd); // Ensure that we have read the entire buffer. EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); } TEST(StatsEventTest, TestAtomIdInvalidPositionError) { AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_writeInt32(event, 0); AStatsEvent_setAtomId(event, 100); AStatsEvent_writeBool(event, true); AStatsEvent_build(event); uint32_t errors = AStatsEvent_getErrors(event); EXPECT_EQ(errors & ERROR_ATOM_ID_INVALID_POSITION, ERROR_ATOM_ID_INVALID_POSITION); AStatsEvent_release(event); } TEST(StatsEventTest, TestOverwriteTimestamp) { uint32_t atomId = 100; int64_t expectedTimestamp = 0x123456789; AStatsEvent* event = AStatsEvent_obtain(); AStatsEvent_setAtomId(event, atomId); AStatsEvent_overwriteTimestamp(event, expectedTimestamp); AStatsEvent_build(event); uint8_t* buffer = AStatsEvent_getBuffer(event, NULL); // Make sure that the timestamp is being overwritten. checkMetadata(&buffer, /*numElements=*/0, /*startTime=*/expectedTimestamp, /*endTime=*/expectedTimestamp, atomId); EXPECT_EQ(AStatsEvent_getErrors(event), 0); AStatsEvent_release(event); }
[ "rick_tan@qq.com" ]
rick_tan@qq.com
eee236c8dd7a520e6efbf97c84989cdd53b6fcc0
0167c6d045663ee68763572be9318fbbb299e232
/Lectures/Design Patterns Code/behavioural_patterns/state/iteration_1/ApplyCommand.cpp
42de3b5ecdc348f59d409e2de7a6ff69ead6aaaf
[]
no_license
Firaasss/CS-3307
a0a18a7c77fa4319ffe9dd233f26139ab7cd45ae
d4ef8450df9e5608ff98c32e441b0c14d1011bda
refs/heads/master
2022-04-25T08:01:12.210174
2020-04-26T22:56:36
2020-04-26T22:56:36
259,150,609
0
0
null
null
null
null
UTF-8
C++
false
false
455
cpp
#include <iostream> #include "ApplyCommand.h" #include "LineOfCredit.h" using std::cin; using std::cout; using std::endl; ApplyCommand::ApplyCommand(LineOfCredit* loc) : _loc(loc) { } void ApplyCommand::execute() { float amount = 0; while (amount <= 0) { cout << "Amount to apply for: "; cin >> amount; if (amount <= 0) cout << endl << "Invalid amount, please try again." << endl << endl; } this->_loc->apply(amount); }
[ "fabousha@uwo.ca" ]
fabousha@uwo.ca
0e6fbbb0b77947029ae528c4369a4d660c43e056
b05328f849055f4e64803116c60ac05762b22430
/test/unit_tests/src/test_atomic.cpp
150e794dca3b3886d4881d2fafa24492a5074209
[ "Apache-2.0" ]
permissive
phongth7/cpp-driver
956258c04c8e0b1cd3470a1add5aaed0cc295766
ef6260412fe28d88390cb3aa8ea456f1972eff57
refs/heads/master
2021-01-22T06:14:24.396190
2016-03-01T19:19:26
2016-03-01T19:19:26
52,947,492
1
0
null
2016-03-02T08:42:22
2016-03-02T08:42:22
null
UTF-8
C++
false
false
4,492
cpp
/* Copyright (c) 2014-2015 DataStax 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. */ #ifdef STAND_ALONE # define BOOST_TEST_MODULE cassandra #endif #include "atomic.hpp" #include <boost/test/unit_test.hpp> #include <limits> #include <stdint.h> enum Enum { ONE, TWO, THREE }; struct Object {}; template <class T> void test_atomic_integer() { const T max_value = std::numeric_limits<T>::max(); const T min_value = std::numeric_limits<T>::min(); cass::Atomic<T> i(0); BOOST_CHECK(i.load() == 0); BOOST_CHECK(i.exchange(1) == 0); BOOST_CHECK(i.load() == 1); i.store(0); T expected = 0; BOOST_CHECK(i.compare_exchange_strong(expected, 1)); BOOST_CHECK(expected == 0); BOOST_CHECK(i.load() == 1); BOOST_CHECK(!i.compare_exchange_strong(expected, 1)); BOOST_CHECK(expected == 1); BOOST_CHECK(i.load() == 1); i.store(0); expected = 0; BOOST_CHECK(i.compare_exchange_weak(expected, 1)); BOOST_CHECK(expected == 0); BOOST_CHECK(i.load() == 1); BOOST_CHECK(!i.compare_exchange_weak(expected, 1)); BOOST_CHECK(expected == 1); BOOST_CHECK(i.load() == 1); i.store(0); BOOST_CHECK(i.fetch_add(1) == 0); BOOST_CHECK(i.load() == 1); BOOST_CHECK(i.fetch_sub(1) == 1); BOOST_CHECK(i.load() == 0); i.store(max_value); BOOST_CHECK(i.load() == max_value); BOOST_CHECK(i.fetch_add(1) == max_value); BOOST_CHECK(i.load() == min_value); i.store(min_value); BOOST_CHECK(i.fetch_sub(1) == min_value); BOOST_CHECK(i.load() == max_value); } BOOST_AUTO_TEST_SUITE(atomic) BOOST_AUTO_TEST_CASE(integers) { test_atomic_integer<int32_t>(); test_atomic_integer<int64_t>(); test_atomic_integer<uint32_t>(); test_atomic_integer<uint64_t>(); } BOOST_AUTO_TEST_CASE(enumeration) { cass::Atomic<Enum> e(ONE); BOOST_CHECK(e.load() == ONE); BOOST_CHECK(e.exchange(TWO) == 0); BOOST_CHECK(e.load() == TWO); e.store(ONE); Enum expected = ONE; BOOST_CHECK(e.compare_exchange_strong(expected, TWO)); BOOST_CHECK(expected == ONE); BOOST_CHECK(e.load() == TWO); BOOST_CHECK(!e.compare_exchange_strong(expected, TWO)); BOOST_CHECK(expected == TWO); BOOST_CHECK(e.load() == TWO); e.store(ONE); expected = ONE; BOOST_CHECK(e.compare_exchange_weak(expected, TWO)); BOOST_CHECK(expected == ONE); BOOST_CHECK(e.load() == TWO); BOOST_CHECK(!e.compare_exchange_weak(expected, TWO)); BOOST_CHECK(expected == TWO); BOOST_CHECK(e.load() == TWO); } BOOST_AUTO_TEST_CASE(pointer) { Object one, two; cass::Atomic<Object*> p(&one); BOOST_CHECK(p.load() == &one); BOOST_CHECK(p.exchange(&two) == &one); BOOST_CHECK(p.load() == &two); p.store(&one); Object* expected = &one; BOOST_CHECK(p.compare_exchange_strong(expected, &two)); BOOST_CHECK(expected == &one); BOOST_CHECK(p.load() == &two); BOOST_CHECK(!p.compare_exchange_strong(expected, &two)); BOOST_CHECK(expected == &two); BOOST_CHECK(p.load() == &two); p.store(&one); expected = &one; BOOST_CHECK(p.compare_exchange_weak(expected, &two)); BOOST_CHECK(expected == &one); BOOST_CHECK(p.load() == &two); BOOST_CHECK(!p.compare_exchange_weak(expected, &two)); BOOST_CHECK(expected == &two); BOOST_CHECK(p.load() == &two); } BOOST_AUTO_TEST_CASE(boolean) { cass::Atomic<bool> b(false); BOOST_CHECK(b.load() == false); BOOST_CHECK(b.exchange(true) == false); BOOST_CHECK(b.load() == true); b.store(false); bool expected = false; BOOST_CHECK(b.compare_exchange_strong(expected, true)); BOOST_CHECK(expected == false); BOOST_CHECK(b.load() == true); BOOST_CHECK(!b.compare_exchange_strong(expected, true)); BOOST_CHECK(expected == true); BOOST_CHECK(b.load() == true); b.store(false); expected = false; BOOST_CHECK(b.compare_exchange_weak(expected, true)); BOOST_CHECK(expected == false); BOOST_CHECK(b.load() == true); BOOST_CHECK(!b.compare_exchange_weak(expected, true)); BOOST_CHECK(expected == true); BOOST_CHECK(b.load() == true); } BOOST_AUTO_TEST_SUITE_END()
[ "michael.penick@datastax.com" ]
michael.penick@datastax.com
eb9de7fad8905f846873ef5a07903e7aa8b43987
268c05d1e071d88541806a46cd4a14ea8fa2f930
/src/Binner.h
ba388f4bf57bc11d0f88395ac01958b328d824f1
[]
no_license
wbinventor/22.106-Course-Project
80104007fb500473170265da58054ce02a5cefd5
999be7672c16ec89d36caf100143ca9ba18a9bcc
refs/heads/master
2021-01-01T18:08:11.750161
2012-05-04T03:17:57
2012-05-04T03:17:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,449
h
/* * binner.h * * Created on: Mar 13, 2012 * Author: William Boyd * MIT, Course 22 * wboyd@mit.edu */ #ifndef BINNER_H_ #define BINNER_H_ #include <limits> #include <math.h> #include <set> #include <utility> #include <omp.h> #include "log.h" #include "arraycreator.h" #include "Neutron.h" #include "Material.h" #include "Isotope.h" class Isotope; class Material; /* Binner types (subclasses of Binner) */ typedef enum binnerTypes { FLUX, CAPTURE_RATE, ABSORPTION_RATE, ELASTIC_RATE, INELASTIC_RATE, FISSION_RATE, TRANSPORT_RATE, COLLISION_RATE, DIFFUSION_RATE } binnerType; /* Bin spacing types */ typedef enum spacingTypes { LINEAR, LOGARITHMIC, OTHER } spacingType; /* Tally type */ typedef enum tallyDomainTypes { X, Y, Z, R_X, R_Y, R_Z, ENERGY, TIME } tallyDomainType; /** * This class represents a set of bins which are defined by a set of values * defining the edges between bins. This class holds the edges, the centers * between bins. It also allows for tallies to be made within each bin. */ class Binner{ protected: char* _name; int _num_bins; float* _edges; float* _centers; double* _tallies; float _bin_delta; binnerType _binner_type; spacingType _spacing_type; tallyDomainType _tally_domain_type; char* _isotopes; omp_lock_t _lock; public: Binner(); virtual ~Binner(); char* getBinnerName(); binnerType getBinnerType(); spacingType getBinType(); tallyDomainType getTallyDomainType(); int getNumBins(); float* getBinEdges(); float* getBinCenters(); float getBinDelta(); float getBinDelta(neutron* neutron); double* getTallies(); double getTally(int bin_index); int getBinIndex(neutron* neutron); int getBinIndex(float sample); char* getIsotopes(); void setBinnerName(char* name); void setNumThreads(int num_threads); void setBinnerType(binnerType type); void setTallyDomainType(tallyDomainType type); void setBinEdges(float* edges, int num_edges); void setIsotopes(char* isotopes); void generateBinEdges(float start, float end, int num_bins, spacingType type); void generateBinCenters(); void tally(float sample); virtual void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope) =0; void processTallyAccumulators(); void computeScaledHistoryStatistics(float scale_factor); void outputHistoryStatistics(const char* filename); }; class FluxBinner: public Binner { public: FluxBinner(); virtual ~FluxBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class CaptureRateBinner: public Binner { public: CaptureRateBinner(); virtual ~CaptureRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class AbsorptionRateBinner: public Binner { public: AbsorptionRateBinner(); virtual ~AbsorptionRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class ElasticRateBinner: public Binner { public: ElasticRateBinner(); virtual ~ElasticRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class InelasticRateBinner: public Binner { public: InelasticRateBinner(); virtual ~InelasticRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class FissionRateBinner: public Binner { public: FissionRateBinner(); virtual ~FissionRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class TransportRateBinner: public Binner { public: TransportRateBinner(); virtual ~TransportRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class CollisionRateBinner: public Binner { public: CollisionRateBinner(); virtual ~CollisionRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; class DiffusionRateBinner: public Binner { public: DiffusionRateBinner(); virtual ~DiffusionRateBinner(); void weightedTally(neutron* neutron, float sigma_t, int energy_index, Material* material, Isotope* isotope); }; #endif /* BINNER_H_ */
[ "wbinventor@gmail.com" ]
wbinventor@gmail.com
a7a9fe35455b320b491d0b1a3acdcd5df9efb7ec
50b7980236b960b133c91c6d653fb334d904252c
/SDK/BP_StatEntry_parameters.h
b0253a7ca3626cda1dd9f4f26dd91d58ed7c0cd9
[]
no_license
wyverns1/mordhau_sdk
c5fa2978203f6c3d405a011c06c39274f52549d1
43693f2102efc684c1d27fb5b4a0abfa67c1f596
refs/heads/master
2020-06-04T00:55:40.096978
2019-06-13T17:12:36
2019-06-13T17:12:36
191,802,239
0
0
null
null
null
null
UTF-8
C++
false
false
587
h
#pragma once // Name: MORDHAU, Version: 1.0.0 #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "../SDK.h" namespace SDK { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function BP_StatEntry.BP_StatEntry_C.GetText_1 struct UBP_StatEntry_C_GetText_1_Params { struct FText ReturnValue; // (Parm, OutParm, ReturnParm) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "jay50@pitt.edu" ]
jay50@pitt.edu
213c13beab7838d13cf4012995f4ed4539d659dd
862d2905cdcd0426ea47e833f6b5dd7f86c408ad
/aMazing/code/engine/system/TextureManager.cpp
8f706bd724dddfcc15e0b12bd26664833af3b533
[]
no_license
LYP951018/aMazing
cedada48e7517caa64da565190428c7f13d019eb
8820667abe6c63968c587ba94c1f8dc9d10afbea
refs/heads/master
2021-01-13T01:04:05.162610
2015-07-31T11:38:36
2015-07-31T11:38:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
903
cpp
#include "TextureManager.hpp" using namespace aMazing; HRESULT TextureManager::addTexture(ID3D11Device* device, MutableString&& filename) //add a brand new texture into texture manager class. { TextureObject* texture = new TextureObject; std::string path = filename.getMultiByteString(); if (FAILED(texture->LoadFile(device, path))) { return E_FAIL; } m_vec.push_back(std::unique_ptr<TextureObject>(texture)); return S_OK; } HRESULT TextureManager::addChessBoardTexture(ID3D11Device* device) { TextureObject* texture = new TextureObject; if (FAILED(texture->beChessBoard(device))) { return E_FAIL; } m_vec.push_back(std::unique_ptr<TextureObject>(texture)); return S_OK; } TextureObject* TextureManager::getTexture(std::size_t index) //Get the pointer of a texture saved in texture manager class. { if (index >= m_vec.size()) { return nullptr; } return m_vec[index].get(); }
[ "anti2moron@gmail.com" ]
anti2moron@gmail.com
775232f089541ea1740fc1bf3029171a647f4af5
de34b80ac11f9ffb361b4c936e6aed5c82036468
/Code/Source/PostProcessing/cvCalculateWallShearStress.h
db6ea48fd51d1898d2e2e65a79fb0afd9e6e4706
[]
no_license
JingLiRaysightmed/SimVascular
d2857e2c1edb198975b7b750ca28877ad00c9f72
0bba72f88743ecb476faef264d86006fb9ca18e3
refs/heads/master
2020-03-16T18:40:04.421252
2018-04-19T11:55:31
2018-04-19T11:55:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,535
h
/* Copyright (c) 2009-2011 Open Source Medical Software Corporation, * University of California, San Diego. * * All rights reserved. * * Portions of the code Copyright (c) 1998-2007 Stanford University, * Charles Taylor, Nathan Wilson, Ken Wang. * * See SimVascular Acknowledgements file for additional * contributors to the source code. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __CVCALCWALLSHEAR_H #define __CVCALCWALLSHEAR_H #include "SimVascular.h" #include "svPostExports.h" // For exports #include "cvRepositoryData.h" #include "cvPolyData.h" // ----------------- // cvCalculateWallShearStress // ----------------- class SV_EXPORT_POST cvCalculateWallShearStress { public: cvCalculateWallShearStress(); ~cvCalculateWallShearStress(); int SetSurfaceMesh(cvPolyData* surfaceMesh); int SetTensors(cvPolyData* tensors); int SetTractions(cvPolyData* tractions); int CalcWallShearFromStresses(); int CalcWallShearFromTractions(); cvPolyData* CalcWallShearMean(int numPds, cvPolyData **shearPds); cvPolyData* CalcWallShearPulse(int numPds, cvPolyData **shearPds); cvPolyData* CalcOSI(cvPolyData *shearMean, cvPolyData *shearPulse); cvPolyData* GetWallShear(); cvPolyData* CalcAvgPointData(int numPds, cvPolyData **inputPds); protected: private: vtkPolyData* surfaceMesh_; vtkPolyData* tensors_; vtkPolyData* tractions_; vtkFloatingPointArrayType* wallshear_; }; #endif
[ "updega2@berkeley.edu" ]
updega2@berkeley.edu
1d29210251bb36743ae6f1f906c8054c528310d0
03a47d14fc4c8ee461ba139fd22d2be589984ef0
/source/lines_service.h
50f819f849b537396b3418772bfcbae66050cdd4
[ "Zlib" ]
permissive
brittonsmith/c10.00-b
b6cd0058e1f37cf6e53863206f7c2bd73d5970a7
e34b9a91941aab6eb2e5d4a6c76fa2d479f0abc7
refs/heads/master
2020-09-18T20:55:25.193631
2019-12-04T11:02:36
2019-12-04T11:02:36
224,183,983
0
1
NOASSERTION
2019-12-04T11:02:38
2019-11-26T12:10:06
C++
UTF-8
C++
false
false
6,527
h
/* This file is part of Cloudy and is copyright (C)1978-2010 by Gary J. Ferland and * others. For conditions of distribution and use see copyright notice in license.txt */ #ifndef LINES_SERVICE_H_ #define LINES_SERVICE_H_ void linadd( double xInten, realnum wavelength, const char *chLab, char chInfo , const char *chComment ); /*outline_base - adds line photons to reflin and outlin */ void outline_base(double dampXvel, double damp, bool lgTransStackLine, long int ip, double phots, realnum inwd, double nonScatteredFraction); /*outline_base_bin - adds line photons to bins of reflin and outlin */ void outline_base_bin(bool lgTransStackLine, long int ip, double phots, realnum inwd, double nonScatteredFraction); /** put forbidden line into stack, using index derived below \param xInten - local emissivity per unit vol \param wavelength wavelength Angstroms \param *chLab string label for ion \param ipnt offset of line in continuum mesh \param chInfo character type of entry for line - 'c' cooling, 'h' heating, 'i' info only, 'r' recom line \param lgOutToo should line be included in outward beam? \param *chComment string explaining line */ void lindst(double xInten, realnum wavelength, const char *chLab, long int ipnt, char chInfo, bool lgOutToo, const char *chComment); /** put forbidden line into stack, using index derived below \param dampXvel - damping constant times Doppler velocity \param damp - damping constant \param xInten - local emissivity per unit vol \param wavelength wavelength Angstroms \param *chLab string label for ion \param ipnt offset of line in continuum mesh \param chInfo character type of entry for line - 'c' cooling, 'h' heating, 'i' info only, 'r' recom line \param lgOutToo should line be included in outward beam? \param *chComment string explaining line */ void lindst(double dampXvel, double damp, double xInten, realnum wavelength, const char *chLab, long int ipnt, char chInfo, bool lgOutToo, const char *chComment); class transition; /** put forbidden line into stack, using index derived below \param t -- pointer to transition data \param wavelength wavelength Angstroms \param *chLab string label for ion \param ipnt offset of line in continuum mesh \param chInfo character type of entry for line - 'c' cooling, 'h' heating, 'i' info only, 'r' recom line \param lgOutToo should line be included in outward beam? \param *chComment string explaining line */ void lindst( transition *t, const char *chLab, char chInfo, bool lgOutToo, const char *chComment); /** absorption due to continuous opacity \param emissivity [erg cm-3 s-1] in inward direction \param emissivity [erg cm-3 s-1] in outward direction \param array index for continuum frequency */ double emergent_line( /* emissivity [erg cm-3 s-1] in inward direction */ double emissivity_in , /* emissivity [erg cm-3 s-1] in outward direction */ double emissivity_out , /* array index for continuum frequency */ long int ipCont ); /**PntForLine generate pointer for forbidden line \param wavelength wavelength of line in Angstroms \param *chLabel label for the line \param *ipnt this is array index on the f, not c scale, for the continuum cell holding the line */ void PntForLine(double wavelength, const char *chLabel, long int *ipnt); /**GetGF convert Einstein A into oscillator strength \param eina \param enercm \param gup */ double GetGF(double eina, double enercm, double gup); /**eina convert a gf into an Einstein A \param gf \param enercm \param gup */ double eina(double gf, double enercm, double gup); /**abscf convert gf into absorption coefficient \param gf \param enercm \param gl */ double abscf(double gf, double enercm, double gl); /** setting true will use low-density Lyman branching ratios */ #define LOWDEN_LYMAN 0 /**RefIndex calculates the index of refraction of air using the line energy in wavenumbers, * used to convert vacuum wavelengths to air wavelengths. \param EnergyWN */ double RefIndex(double EnergyWN); /**WavlenErrorGet - given the real wavelength in A for a line * routine will find the error expected between the real * wavelength and the wavelength printed in the output, with 4 sig figs, \param wavelength \return function returns difference between exact and 4 sig fig wl, so we have found correct line is fabs(d wl) < return */ realnum WavlenErrorGet( realnum wavelength ); /**EmLineJunk set all elements of emission struc to dangerous values \param *t */ void EmLineJunk( emission * t ); /**CollisionJunk set all elements of emission struc to dangerous values \param *t */ void CollisionJunk( collision * t ); /**StateJunk set all elements of quantumState struc to dangerous values \param *t */ void StateJunk( quantumState * t ); /**EmLineZero set all elements of emission struc to zero \param *t */ void EmLineZero( emission * t ); /**CollisionZero set all elements of collision struc to zero \param *t */ void CollisionZero( collision * t ); /**StateZero set all elements of quantumState struc to zero \param *t */ void StateZero( quantumState * t ); /** convert down coll rate back into electron cs in case other parts of code need this for reference \param gHi - stat weight of upper level \param rate - deexcitation rate, units s-1 */ double ConvRate2CS( realnum gHi , realnum rate ); /** convert collisional deexcitation cross section for into collision strength \param CrsSectCM2 - the cross section \param gLo - statistical weight of lower level of transition \param E_ProjectileRyd - initial projectile energy in Rydbergs \param reduced_mass_grams - reduced mass MpMt/(Mp+Mt) of projectile-target system */ double ConvCrossSect2CollStr( double CrsSectCM2, double gLo, double E_ProjectileRyd, double reduced_mass_grams ); /**totlin sum total intensity of cooling, recombination, or intensity lines \param chInfo chInfor is 1 char,<BR> 'i' information, <BR> 'r' recombination or <BR> 'c' collision */ double totlin( int chInfo); /**FndLineHt search through line heat arrays to find the strongest heat source \param *level \param *ipStrong this is the index of the strongest line in the array on the c scale \param *Strong */ void FndLineHt(long int *level, /**/ long int *ipStrong, double *Strong); /**AddState2Stack add generic quantum state to GenericStates and return pointer to that state. */ quantumState *AddState2Stack( void ); #endif /* LINES_SERVICE_H_ */
[ "gary@e66ded4d-7403-0c46-9ef1-c4afbd745067" ]
gary@e66ded4d-7403-0c46-9ef1-c4afbd745067
ecd33c46d23503aba99f5a63d40c31422c991663
5447a87c9fa3cd790453a8bf4a40761b4fbb099b
/leetcode2/Leetcode/501-1000/Leetcode_13.cpp
4a8a6054567ee9aa7e1edf70d0e129b3cada2714
[]
no_license
necromaner/C-
ffb215520d3035a1e785147303c753a10a47619a
f7978b358f8246072c7f9627cee80e5df1994b25
refs/heads/master
2021-05-25T09:13:32.011117
2020-11-10T09:00:47
2020-11-10T09:00:47
126,946,399
0
0
null
null
null
null
UTF-8
C++
false
false
5,166
cpp
#include "../leetcode.h" #include <stack> //617. 合并二叉树 /* 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。 你需要将他们合并为一个新的二叉树。合并的规则是如果两个节点重叠,那么将他们的值相加作为节点合并后的新值,否则不为 NULL 的节点将直接作为新二叉树的节点。 示例 1: 输入: Tree 1 Tree 2 1 2 / \ / \ 3 2 1 3 / \ \ 5 4 7 输出: 合并后的树: 3 / \ 4 5 / \ \ 5 4 7 注意: 合并必须从两个树的根节点开始。 */ TreeNode* Leetcode::mergeTrees(TreeNode* t1, TreeNode* t2) {//2020-09-23 // 执行用时:76 ms, 在所有 C++ 提交中击败了66.86% 的用户 // 内存消耗:32.8 MB, 在所有 C++ 提交中击败了30.65% 的用户 if (t1 == nullptr) return t2; if (t2 == nullptr) return t1; // t1->val += t2->val; // t1->left = mergeTrees(t1->left, t2->left); // t1->right = mergeTrees(t1->right, t2->right); // return t1; TreeNode *t3 = new TreeNode(t1->val + t2->val); t3->left = mergeTrees(t1->left, t2->left); t3->right = mergeTrees(t1->right, t2->right); return t3; } TreeNode* Leetcode::mergeTrees_1(TreeNode* t1, TreeNode* t2) {//2020-09-23 //// 方法一:深度优先搜索 // if (t1 == nullptr) { // return t2; // } // if (t2 == nullptr) { // return t1; // } // auto merged = new TreeNode(t1->val + t2->val); // merged->left = mergeTrees(t1->left, t2->left); // merged->right = mergeTrees(t1->right, t2->right); // return merged; //// 方法二:广度优先搜索 // if (t1 == nullptr) { // return t2; // } // if (t2 == nullptr) { // return t1; // } // auto merged = new TreeNode(t1->val + t2->val); // auto q = queue<TreeNode*>(); // auto queue1 = queue<TreeNode*>(); // auto queue2 = queue<TreeNode*>(); // q.push(merged); // queue1.push(t1); // queue2.push(t2); // while (!queue1.empty() && !queue2.empty()) { // auto node = q.front(), node1 = queue1.front(), node2 = queue2.front(); // q.pop(); // queue1.pop(); // queue2.pop(); // auto left1 = node1->left, left2 = node2->left, right1 = node1->right, right2 = node2->right; // if (left1 != nullptr || left2 != nullptr) { // if (left1 != nullptr && left2 != nullptr) { // auto left = new TreeNode(left1->val + left2->val); // node->left = left; // q.push(left); // queue1.push(left1); // queue2.push(left2); // } else if (left1 != nullptr) { // node->left = left1; // } else if (left2 != nullptr) { // node->left = left2; // } // } // if (right1 != nullptr || right2 != nullptr) { // if (right1 != nullptr && right2 != nullptr) { // auto right = new TreeNode(right1->val + right2->val); // node->right = right; // q.push(right); // queue1.push(right1); // queue2.push(right2); // } else if (right1 != nullptr) { // node->right = right1; // } else { // node->right = right2; // } // } // } // return merged; //// 栈迭代 // if(!t1) return t2; // stack<pair<TreeNode*, TreeNode*>> stk; // if(t1 && t2) stk.push(make_pair(t1, t2)); // while(stk.size()) { // pair<TreeNode*,TreeNode*> cur = stk.top(); stk.pop(); // cur.first->val = cur.first->val + cur.second->val; // if(cur.second->left) { // if(!cur.first->left) cur.first->left = new TreeNode(0); //如果左子树不存在,新建值为0的节点 // stk.push(make_pair(cur.first->left, cur.second->left)); // } // if(cur.second->right) { // if(!cur.first->right ) cur.first->right = new TreeNode(0); //如果右子树不存在,新建值为0的节点 // stk.push(make_pair(cur.first->right, cur.second->right)); // } // } // return t1; //// 队列迭代 if(!t1) return t2; if(!t2) return t1; queue<pair<TreeNode*, TreeNode*>> q; q.push(make_pair(t1, t2)); while(q.size()) { pair<TreeNode*,TreeNode*> cur = q.front(); q.pop(); cur.first->val = cur.first->val + cur.second->val; if(cur.second->left) { if(!cur.first->left){ cur.first->left = new TreeNode(0); } q.push(make_pair(cur.first->left, cur.second->left)); } if(cur.second->right) { if(!cur.first->right ){ cur.first->right = new TreeNode(0); } q.push(make_pair(cur.first->right, cur.second->right)); } } return t1; }
[ "necromaner@foxmail.com" ]
necromaner@foxmail.com
2adb1f97873261ff3a28b0bda371e38889a3d2ad
e9a5d7ce672b1a7530409ad73bd8b2e1e0a8ab21
/iCGIS/src/geo/map/geofeaturelayerproperty.h
641f459c2d6c26d247db5f3facd5a99204c72342
[]
no_license
page404/iCGIS
c8e81ff7388510582a2828c7968edc06fff1f3f4
25ac5cb3b678b3136370ebcc99de599cf13c1710
refs/heads/master
2021-04-17T11:37:32.543181
2020-01-09T05:29:17
2020-01-09T05:29:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
975
h
/******************************************************* ** class name: GeoFeatureLayerProperty ** ** description: 图层属性类 ** ** last change: 2020-01-02 *******************************************************/ #pragma once #include "geo/map/geofielddefn.h" #include "geo/geometry/geogeometry.h" #include <QString> enum LayerStyleMode { kSingleStyle = 0, kCategorized = 1, kRuleBased = 2 }; class GeoFeatureLayerProperty { public: GeoFeatureLayerProperty() = default; ~GeoFeatureLayerProperty() = default; void setName(const QString& nameIn) { name = nameIn; } GeometryType getGeometryType() const { return geometryType; } void setGeometryType(GeometryType geometryTypeIn); public: bool visable = true; // 是否可见(显示) bool editable = false; // 是否可编辑 int id = 0; QString name; GeoExtent extent; QString spatialRef; LayerStyleMode styleMode = kSingleStyle; private: GeometryType geometryType = kGeometryTypeUnknown; };
[ "leopard.c@outlook.com" ]
leopard.c@outlook.com
4faf8ef16fa10c504778c6c1250db65d1d1c0a16
7c64360b6e32f8576344048db7b9938ea722dedd
/boostrap/tests/BFileTest.cc
0d1f6bbc8f7443b913af88ba172faabd194e4d9c
[ "Apache-2.0" ]
permissive
recepkandemir/opticks
4be08a9243c3e0abe82eca77be70178e6384e555
523387f7593676bab58de22d22049e650de3f5c3
refs/heads/master
2023-01-24T16:55:04.131498
2020-12-04T20:25:09
2020-12-04T20:25:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,270
cc
/* * Copyright (c) 2019 Opticks Team. All Rights Reserved. * * This file is part of Opticks * (see https://bitbucket.org/simoncblyth/opticks). * * 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. */ // om-; TEST=BFileTest om-t #include <vector> #include <string> #include <cassert> #include "BOpticksResource.hh" #include "BFile.hh" #include "OPTICKS_LOG.hh" const plog::Severity LEVEL = info ; void test_FindFile_(const char* dirlist, const char* sub, const char* name) { std::string aa = BFile::FindFile( dirlist, sub, name ); if(!aa.empty()) { printf("found sub %s name %s at %s \n", sub, name, aa.c_str()); } else { printf("NOT found sub %s name %s \n", sub, name); } } void test_FindFile() { const char* dirlist = "$HOME/.opticks;$OPTICKS_PREFIX/.opticks" ; test_FindFile_( dirlist, "OpticksResource", "OpticksColors.json"); } void test_IsAllowedEnvvar() { assert( BFile::IsAllowedEnvvar("TMP") == true ) ; } void test_ResolveKey() { const char* key = "TMP" ; assert( BFile::IsAllowedEnvvar(key) == true ) ; std::string evalue = BFile::ResolveKey(key) ; LOG(info) << " key " << key << " evalue " << evalue ; } void test_ExistsDir() { std::vector<std::string> ss ; ss.push_back("$OPTICKS_HOME/optickscore/OpticksPhoton.h"); ss.push_back("$HOME/.opticks/GColors.json"); ss.push_back("$HOME/.opticks"); ss.push_back("$HOME/"); ss.push_back("$HOME"); ss.push_back("$OPTICKS_HOME"); ss.push_back("$HOME/$OPTICKS_HOME"); ss.push_back("$TMP"); for(unsigned int i=0 ; i < ss.size() ; i++) { std::string s = ss[i] ; std::string x = BFile::FormPath(s.c_str()); bool xdir = BFile::ExistsDir(s.c_str()); bool xfile = BFile::ExistsFile(s.c_str()); bool xdir2 = BFile::ExistsNativeDir(x); bool xfile2 = BFile::ExistsNativeFile(x); assert( xdir == xdir2 ); assert( xfile == xfile2 ); printf(" BFile::FormPath(\"%s\") --> [%s] dir %d file %d \n", s.c_str(), x.c_str(), xdir, xfile); } } void test_CreateDir() { BFile::CreateDir("$TMP/a/b/c"); } void test_RemoveDir() { BFile::CreateDir("$TMP/a/b/c"); BFile::RemoveDir("$TMP/a/b/c"); } void test_RemoveDir_2() { BFile::CreateDir("$TMP","b","c"); BFile::RemoveDir("$TMP","b","c"); } void test_RemoveFile() { LOG(info) << "." ; BFile::CreateFile("$TMP/a/b/c.txt"); BFile::RemoveFile("$TMP/a/b/c.txt"); } void test_ParentDir() { std::vector<std::string> ss ; ss.push_back("$OPTICKS_HOME/optickscore/OpticksPhoton.h"); ss.push_back("$HOME/.opticks/GColors.json"); ss.push_back("C:\\tmp"); ss.push_back("C:\\tmp\\TestIDPath"); for(unsigned int i=0 ; i < ss.size() ; i++) { std::string s = ss[i] ; std::string x = BFile::FormPath(s.c_str()); std::string p = BFile::ParentDir(s.c_str()); LOG(info) << " s " << std::setw(40) << s << " x " << std::setw(40) << x << " p " << std::setw(40) << p ; } } void test_ParentParentDir() { const char* path = "/home/blyth/local/opticks/lib/OKX4Test" ; const char* xpp = "/home/blyth/local/opticks" ; std::string spp = BFile::ParentParentDir(path); assert( strcmp( spp.c_str(), xpp ) == 0 ); } void test_FormPath_reldir() { std::string x = BFile::FormPath("$TMP", "some/deep/reldir", "name.txt"); LOG(info) << "test_FormPath_reldir" << " " << x ; } void test_FormPath_edge() { std::string x = BFile::FormPath("", "g4ok.gltf"); LOG(info) << "test_FormPath_edge" << " " << x ; } void test_FormPath() { std::vector<std::string> ss ; ss.push_back("$OPTICKS_HOME/optickscore/OpticksPhoton.h"); ss.push_back("$OPTICKS_INSTALL_PREFIX/include/optickscore/OpticksPhoton.h"); ss.push_back("$OPTICKS_INSTALL_PREFIX/externals/config/geant4.ini") ; ss.push_back("$OPTICKS_INSTALL_PREFIX/opticksdata/config/opticksdata.ini") ; ss.push_back("$OPTICKS_INSTALL_PREFIX/include/OpticksCore/DemoCfgTest.cfg"); ss.push_back("$OPTICKS_PREFIX/include/OpticksCore/DemoCfgTest.cfg"); ss.push_back("$INSTALL_PREFIX/include/OpticksCore/DemoCfgTest.cfg"); ss.push_back("$PREFIX/include/OpticksCore/DemoCfgTest.cfg"); ss.push_back("$OPTICKS_EVENT_BASE/evt/dayabay/cerenkov/1") ; ss.push_back("$HOME/.opticks/GColors.json"); ss.push_back("/path/with/dollar/inside/$TMP"); for(unsigned int i=0 ; i < ss.size() ; i++) { std::string s = ss[i] ; std::string x = BFile::FormPath(s.c_str()); LOG(info) << " s " << std::setw(40) << s << " x " << std::setw(40) << x ; } } void test_Name_ParentDir() { const char* path = "$TMP/opticks/blyth/somefile.txt" ; std::string name = BFile::Name(path) ; std::string dir = BFile::ParentDir(path) ; LOG(info) << " path " << path << " name " << name << " dir " << dir ; } void test_ChangeExt() { const char* path = "$TMP/somedir/somefile.txt" ; std::string name = BFile::Name(path) ; std::string stem = BFile::Stem(path); std::string dir = BFile::ParentDir(path) ; std::string chg = BFile::ChangeExt(path, ".json"); LOG(info) << " path " << path << " name " << name << " stem " << stem << " dir " << dir << " chg " << chg ; } void test_SomeDir() { //const char* path = "$TMP/somedir/someotherdir" ; //const char* path = "/dd/Geometry/PoolDetails/lvVertiCableTray#pvVertiCable0xbf5e7f0" ; const char* path = "/usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300/g4_00.gltf" ; std::string name = BFile::Name(path) ; std::string stem = BFile::Stem(path); std::string dir = BFile::ParentDir(path) ; LOG(info) << "test_SomeDir" << " path " << path << " name " << name << " stem " << stem << " dir " << dir ; } void test_SomePath() { //const char* path = "$TMP/somedir/someotherdir" ; //const char* path = "/dd/Geometry/PoolDetails/lvVertiCableTray#pvVertiCable0xbf5e7f0" ; const char* path = "/usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300/g4_00.gltf" ; std::string name = BFile::Name(path) ; std::string stem = BFile::Stem(path); std::string dir = BFile::ParentDir(path) ; LOG(info) << "test_SomePath" << " path " << path << " name " << name << " stem " << stem << " dir " << dir ; assert( name.compare("g4_00.gltf") == 0 ); assert( stem.compare("g4_00") == 0 ); assert( dir.compare("/usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300") == 0 ); } void test_LastWriteTime() { LOG(info) << "test_LastWriteTime" ; const char* path = "$TMP/a/b/c" ; std::time_t* lwt = BFile::LastWriteTime(path); std::time_t now = std::time(NULL) ; if(!lwt) { std::cout << " path " << path << " DOESNT EXIST " << std::endl ; } else { std::time_t age = (now - *lwt); std::cout << " path " << path << " now " << now << " age (s) " << age << " BFile::LastWriteTime(path) " << *lwt << std::endl ; } } void test_SinceLastWriteTime() { LOG(info) << "test_SinceLastWriteTime" ; //const char* path = "$TMP/a/b/c" ; const char* path = "$TMP/a/b" ; std::time_t* age = BFile::SinceLastWriteTime(path) ; if(age) { std::cout << " path " << path << " age : BFile::SinceLastWriteTime(path) " << *age << std::endl ; } } void test_LooksLikePath() { LOG(info) << "test_LooksLikePath" ; assert( BFile::LooksLikePath("$TMP/a/b") == true ); assert( BFile::LooksLikePath("/a/b") == true ); assert( BFile::LooksLikePath("1,2") == false ); assert( BFile::LooksLikePath(NULL) == false ); assert( BFile::LooksLikePath("1") == false ); } void test_ParentName(const char* path, const char* expect) { std::string pn = BFile::ParentName(path); LOG(info) << "test_ParentName" << " path [" << path << "]" << " pn [" << pn << "]" << " expect [" << expect << "]" ; if( expect == NULL ) { assert( pn.empty() ); } else { assert( pn.compare(expect) == 0 ); } } void test_ParentName() { test_ParentName( "/usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300/g4_00.dae", "DayaBay_VGDX_20140414-1300" ); test_ParentName( "DayaBay_VGDX_20140414-1300/g4_00.dae", "DayaBay_VGDX_20140414-1300" ); test_ParentName( "g4_00.dae", NULL ); test_ParentName( NULL, NULL ); } void test_SplitPath(const char* path) { std::vector<std::string> elem ; BFile::SplitPath(elem, path); LOG(info) << " path " << path << " nelem " << elem.size() ; for(unsigned i=0 ; i < elem.size() ; i++) { std::cout << std::setw(4) << i << " " << elem[i] << std::endl ; } } void test_SplitPath() { const char* idpath_0="/usr/local/opticks/opticksdata/export/DayaBay_VGDX_20140414-1300/g4_00.96ff965744a2f6b78c24e33c80d3a4cd.dae" ; test_SplitPath(idpath_0); //const char* idpath_1="/usr/local/opticks/geocache/DayaBay_VGDX_20140414-1300/g4_00.dae/96ff965744a2f6b78c24e33c80d3a4cd/1" ; //test_SplitPath(idpath_1); } void test_prefixShorten_1() { std::string path_ = BFile::FormPath("/some/other/dir/cfg4/DsG4OpBoundaryProcess.cc" ); const char* path = path_.c_str(); std::string abbr = BFile::prefixShorten(path, "$OPTICKS_HOME/" ); LOG(info) << " path [" << path << "]" << " abbr [" << abbr << "]" ; } void test_prefixShorten_0() { std::string path_ = BFile::FormPath("$OPTICKS_HOME/cfg4/DsG4OpBoundaryProcess.cc" ); const char* path = path_.c_str(); std::string abbr = BFile::prefixShorten(path, "$OPTICKS_HOME/" ); LOG(info) << " path [" << path << "]" << " abbr [" << abbr << "]" ; } void test_FileSize() { const char* path0 = "$TMP/test_getBufferSize.npy" ; const char* path1 = "$TMP/test_getBufferSize_NonExisting.npy" ; LOG(info) << " path0 " << path0 << " FileSize0 " << BFile::FileSize( path0 ) ; LOG(info) << " path1 " << path1 << " FileSize1 " << BFile::FileSize( path1 ) ; } void test_CWD() { std::string cwd = BFile::CWD(); LOG(info) << cwd ; } void test_CurrentDirectoryName() { const char* cdn = BFile::CurrentDirectoryName(); LOG(info) << cdn ; } void test_Absolute() { std::vector<std::string> rr = {"tests", ".", "..", "../.." , "../../.." } ; for(unsigned i=0 ; i < rr.size() ; i++) { std::string r = rr[i] ; std::string a = BFile::Absolute(r.c_str()); std::string c = BFile::AbsoluteCanonical(r.c_str()); LOG(info) << " r " << std::setw(15) << r << " a " << std::setw(50) << a << " c " << std::setw(50) << c ; } } void test_preparePath() { const char* p = "$TMP/extg4/X4GDMLParserTest/out.gdml" ; std::string s = BFile::preparePath(p) ; LOG(LEVEL) << " p " << p << " s " << s ; } void test_OPTICKS_USER_HOME() { const char* p = "$HOME/a/b/c/d" ; std::string s = BFile::preparePath(p) ; LOG(info) << " p " << p << " s " << s ; } void test_ResolveScript() { LOG(info); BOpticksResource rsc ; // sets envvar OPTICKS_INSTALL_PREFIX internally //rsc.Summary(); const char* script = "tboolean.py" ; std::vector<const char*> fallback_dirs = { "$OPTICKS_INSTALL_PREFIX/py/opticks/ana", "$OPTICKS_PREFIX/py/opticks/ana", "$PREFIX/py/opticks/ana" }; for(unsigned i=0 ; i < fallback_dirs.size() ; i++) { const char* fallback_dir = fallback_dirs[i]; const char* path = BFile::ResolveScript(script,fallback_dir); std::cout << "BFile::ResolveScript(\"" << script << "\", \"" << fallback_dir << "\") = " << path << std::endl ; } } int main(int argc, char** argv) { OPTICKS_LOG(argc, argv); BOpticksResource rsc ; // sets envvar OPTICKS_INSTALL_PREFIX internally rsc.Summary(); //test_FindFile(); //test_ExistsDir(); //test_CreateDir(); //test_ParentDir(); test_FormPath(); //test_Name_ParentDir(); //test_ChangeExt(); //test_FormPath_reldir(); //test_SomeDir(); //test_SomePath(); //test_RemoveDir(); //test_RemoveDir_2(); //test_RemoveFile(); //test_LastWriteTime(); //test_SinceLastWriteTime(); //test_LooksLikePath(); //test_ParentName(); //test_SplitPath(); //test_prefixShorten_0(); //test_prefixShorten_1(); //test_FileSize(); //test_FormPath_edge(); //test_IsAllowedEnvvar(); //test_ResolveKey(); //test_CWD(); //test_Absolute(); //test_preparePath(); //test_ParentParentDir(); //test_OPTICKS_USER_HOME(); //test_CurrentDirectoryName(); //test_ResolveScript(); return 0 ; }
[ "simoncblyth@gmail.com" ]
simoncblyth@gmail.com
9be46940e6a1ba029391f682747309278b8cb211
93176e72508a8b04769ee55bece71095d814ec38
/Utilities/otbossim/include/ossim/base/ossimStreamFactory.h
c89ca437a05a41bec791149a86efba889d88aef8
[]
no_license
inglada/OTB
a0171a19be1428c0f3654c48fe5c35442934cf13
8b6d8a7df9d54c2b13189e00ba8fcb070e78e916
refs/heads/master
2021-01-19T09:23:47.919676
2011-06-29T17:29:21
2011-06-29T17:29:21
1,982,100
4
5
null
null
null
null
UTF-8
C++
false
false
985
h
//******************************************************************* // Copyright (C) 2005 Garrett Potts // // License: LGPL // // See LICENSE.txt file in the top level directory for more details. // // Author: Garrett Potts // // //******************************************************************* // $Id: ossimStreamFactory.h 11176 2007-06-07 19:45:56Z dburken $ // #ifndef ossimStreamFactory_HEADER #define ossimStreamFactory_HEADER #include <ossim/base/ossimStreamFactoryBase.h> #include <ossim/base/ossimIoStream.h> class OSSIM_DLL ossimStreamFactory : public ossimStreamFactoryBase { public: static ossimStreamFactory* instance(); virtual ~ossimStreamFactory(); virtual ossimRefPtr<ossimIFStream> createNewIFStream(const ossimFilename& file, std::ios_base::openmode openMode) const; protected: ossimStreamFactory(); ossimStreamFactory(const ossimStreamFactory&); static ossimStreamFactory* theInstance; }; #endif
[ "CS" ]
CS
f0bb28375a33de22323678ed51abd96c877a3b67
e7a50bf9e18feb68467161104077f8d1add03ff2
/src/lib/opcodes/compare.inc
61f8bc996bbe0f21682935dd67d6852d0df00ae1
[ "MIT" ]
permissive
piot/zany
4889fb355c5ae147ea2a80e2d37e73b27f8f4c68
aed3934d1953e7d50d91af21014ae63f3a2f4aaf
refs/heads/master
2021-08-26T01:01:46.749441
2021-08-14T09:09:27
2021-08-14T09:09:27
122,197,401
0
0
null
null
null
null
UTF-8
C++
false
false
1,324
inc
/* --------------------------------------- */ case CMP_ABS: READ_ABSOLUTE_MEMORY_WITH_OFFSET(cpu, 0); cmp(cpu, r, cpu->a); break; case CMP_ABS_X: READ_ABSOLUTE_MEMORY_WITH_OFFSET(cpu, cpu->x); cmp(cpu, r, cpu->a); break; case CMP_ABS_Y: READ_ABSOLUTE_MEMORY_WITH_OFFSET(cpu, cpu->y); break; case CMP_IMM: r = READ_OCTET(cpu); cmp(cpu, r, cpu->a); break; case CMP_IND_X: READ_INDEXED_INDIRECT_ZP_OFFSET(cpu, cpu->x); cmp(cpu, r, cpu->a); break; case CMP_IND_Y: READ_INDEXED_INDIRECT_PTR_OFFSET(cpu, cpu->y); cmp(cpu, r, cpu->a); break; case CMP_ZP: cmp(cpu, READ_ZP_MEM(cpu), cpu->a); break; case CMP_ZP_X: cmp(cpu, READ_ZP_MEM_OFFSET(cpu, cpu->x), cpu->a); break; /* --------------------------------------- */ case CPX_ABS: READ_ABSOLUTE_MEMORY_WITH_OFFSET(cpu, 0); cmp(cpu, r, cpu->x); break; case CPX_IMM: cmp(cpu, READ_OCTET(cpu), cpu->x); break; case CPX_ZP: cmp(cpu, READ_ZP_MEM(cpu), cpu->x); break; /* --------------------------------------- */ case CPY_ABS: READ_ABSOLUTE_MEMORY_WITH_OFFSET(cpu, 0); cmp(cpu, r, cpu->y); break; case CPY_IMM: cmp(cpu, READ_OCTET(cpu), cpu->y); break; case CPY_ZP: cmp(cpu, READ_ZP_MEM(cpu), cpu->y); break; /* --------------------------------------- */
[ "piot@hotmail.com" ]
piot@hotmail.com
93e863aa2991c8a94c3992fbf70b6ff8da538384
b8cb5e3c80c271d4ea5cace5ea6f2efb6dcaf7f8
/build/src/imgproc.cpp
59337b921012e6ec80c891d279cb86178be9ed2f
[]
no_license
yar3333/haxe-hxopencv
c6502fe2ac9f6c6d2a766573bb96cffd9c71b72c
37fdd536721b9f6ddb299b3f609ec48139b10dac
refs/heads/master
2022-11-24T17:33:46.850539
2014-05-30T13:59:18
2014-05-30T13:59:18
279,648,882
2
0
null
null
null
null
UTF-8
C++
false
false
5,117
cpp
#include "abstract.hpp" //////////////////////////////////////////////////////////////////// value neko_matchTemplate(value image, value templ, value result, value method) { val_check_kind_or_fail(image, k_Mat); val_check_kind_or_fail(templ, k_Mat); val_check_kind_or_fail(result, k_Mat); val_check_type_or_fail(method, int); matchTemplate(valueToMat(image), valueToMat(templ), valueToMat(result), val_int(method)); return val_null; } DEFINE_PRIM(neko_matchTemplate, 4); //--------------------------------------------------- value neko_threshold(value src, value dst, value thresh, value maxval, value type) { val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); val_check_type_or_fail(thresh, number); val_check_type_or_fail(maxval, number); val_check_type_or_fail(type, int); double r = threshold(valueToMat(src), valueToMat(dst), val_number(thresh), val_number(maxval), val_int(type)); return alloc_float(r); } DEFINE_PRIM(neko_threshold, 5); //--------------------------------------------------- value neko_adaptiveThreshold(value args[], int argc) { if (argc != 7) failure("adaptiveThreshold: expected 7 arguments."); value src = args[0]; value dst = args[1]; value maxValue = args[2]; value adaptiveMethod = args[3]; value thresholdType = args[4]; value blockSize = args[5]; value C = args[6]; val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); val_check_type_or_fail(maxValue, number); val_check_type_or_fail(adaptiveMethod, int); val_check_type_or_fail(thresholdType, int); val_check_type_or_fail(blockSize, int); val_check_type_or_fail(C, number); adaptiveThreshold(valueToMat(src), valueToMat(dst), val_number(maxValue), val_int(adaptiveMethod), val_int(thresholdType), val_int(blockSize), val_number(C)); return val_null; } DEFINE_PRIM_MULT(neko_adaptiveThreshold); //--------------------------------------------------- value neko_invert(value src, value dst) { val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); subtract(Scalar::all(255), valueToMat(src), valueToMat(dst)); return val_null; } DEFINE_PRIM(neko_invert, 2); //--------------------------------------------------- value neko_filter2D(value args[], int argc) { if (argc != 8) failure("filter2D: expected 8 arguments."); value src = args[0]; value dst = args[1]; value ddepth = args[2]; value kernel = args[3]; value anchorX = args[4]; value anchorY = args[5]; value delta = args[6]; value borderType = args[7]; val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); val_check_type_or_fail(ddepth, int); val_check_kind_or_fail(kernel, k_Mat); val_check_type_or_fail(anchorX, int); val_check_type_or_fail(anchorY, int); val_check_type_or_fail(delta, number); val_check_type_or_fail(borderType, int); filter2D(valueToMat(src), valueToMat(dst), val_int(ddepth), valueToMat(kernel), Point(val_int(anchorX), val_int(anchorY)), val_number(delta), val_int(borderType)); return val_null; } DEFINE_PRIM_MULT(neko_filter2D); //--------------------------------------------------- value neko_erode(value args[], int argc) { if (argc != 8) failure("erode: expected 8 arguments."); value src = args[0]; value dst = args[1]; value kernel = args[2]; value anchorX = args[3]; value anchorY = args[4]; value iterations = args[5]; value borderType = args[6]; value borderValue = args[7]; val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); val_check_kind_or_fail(kernel, k_Mat); val_check_type_or_fail(anchorX, int); val_check_type_or_fail(anchorY, int); val_check_type_or_fail(iterations, int); val_check_type_or_fail(borderType, int); if (!val_is_null(borderValue)) val_check_type_or_fail(borderValue, array); erode(valueToMat(src), valueToMat(dst), valueToMat(kernel), Point(val_int(anchorX), val_int(anchorY)), val_int(iterations), val_int(borderType), !val_is_null(borderValue) ? valueToScalar(borderValue) : Scalar::all(DBL_MAX)); return val_null; } DEFINE_PRIM_MULT(neko_erode); //--------------------------------------------------- value neko_dilate(value args[], int argc) { if (argc != 8) failure("dilate: expected 8 arguments."); value src = args[0]; value dst = args[1]; value kernel = args[2]; value anchorX = args[3]; value anchorY = args[4]; value iterations = args[5]; value borderType = args[6]; value borderValue = args[7]; val_check_kind_or_fail(src, k_Mat); val_check_kind_or_fail(dst, k_Mat); val_check_kind_or_fail(kernel, k_Mat); val_check_type_or_fail(anchorX, int); val_check_type_or_fail(anchorY, int); val_check_type_or_fail(iterations, int); val_check_type_or_fail(borderType, int); if (!val_is_null(borderValue)) val_check_type_or_fail(borderValue, array); dilate(valueToMat(src), valueToMat(dst), valueToMat(kernel), Point(val_int(anchorX), val_int(anchorY)), val_int(iterations), val_int(borderType), !val_is_null(borderValue) ? valueToScalar(borderValue) : Scalar::all(DBL_MAX)); return val_null; } DEFINE_PRIM_MULT(neko_dilate); //---------------------------------------------------
[ "yar3333@gmail.com" ]
yar3333@gmail.com
305f708982e66b5ab16458ec0be3a1e4b85ce1d3
cffc460605febc80e8bb7c417266bde1bd1988eb
/before2020/UVa_ACM/004 - Volume IV/UVa 442(Simple, Ad-hoc, Matrix-multiplication, Stack).cpp
f39d7826601361c276a53f30a7049aa5105c4e54
[]
no_license
m80126colin/Judge
f79b2077f2bf67a3b176d073fcdf68a8583d5a2c
56258ea977733e992b11f9e0cb74d630799ba274
refs/heads/master
2021-06-11T04:25:27.786735
2020-05-21T08:55:03
2020-05-21T08:55:03
19,424,030
7
4
null
null
null
null
UTF-8
C++
false
false
1,807
cpp
/** * @judge UVa * @id 442 * @tag Simple, Ad-hoc, Matrix multiplication, Stack */ #include <stdio.h> #include <string> #include <iostream> #include <vector> using namespace std; struct matrix { int r, c, flag; matrix() { r = c = flag = 0; } matrix(int r, int c): r(r), c(c) { flag = 0; } matrix(int flag): flag(flag) { r = c = 0; } }M[26]; int n; string s; inline int exp() { int i, ans = 0; vector <matrix> S; S.clear(); for (i = 0; i < s.size(); i++) { if (s[i] == '(') S.push_back(matrix(1)); else if (s[i] == ')') { while (S.size() >= 2 && !S[S.size() - 1].flag && !S[S.size() - 2].flag) { matrix tmp1, tmp2; tmp1 = S[S.size() - 2]; tmp2 = S[S.size() - 1]; S.pop_back(); S.pop_back(); if (tmp1.c != tmp2.r) return -1; ans += tmp1.r * tmp1.c * tmp2.c; S.push_back(matrix(tmp1.r, tmp2.c)); } if (S.size() <= 1) return -1; else if (!S[S.size() - 2].flag) return -1; else { matrix tmp = S[S.size() - 1]; S.pop_back(); S.pop_back(); S.push_back(tmp); } } else if (s[i] >= 'A' && s[i] <= 'Z') S.push_back(M[s[i] - 'A']); } while (S.size() >= 2 && !S[S.size() - 1].flag && !S[S.size() - 2].flag) { matrix tmp1, tmp2; tmp1 = S[S.size() - 2]; tmp2 = S[S.size() - 1]; S.pop_back(); S.pop_back(); if (tmp1.c != tmp2.r) return -1; ans += tmp1.r * tmp1.c * tmp2.c; S.push_back(matrix(tmp1.r, tmp2.c)); } if (S.size() > 1) return -1; return ans; } int main() { int i; scanf("%d", &n); for (i = 0; i < n; i++) { char ch; cin >> ch; scanf("%d%d", &M[ch - 'A'].r, &M[ch - 'A'].c); } while (cin >> s) { int result = exp(); if (result >= 0) printf("%d\n", result); else puts("error"); } }
[ "m80126colin@gmail.com" ]
m80126colin@gmail.com
6ac6d74067861dcd490925ecbcdfdd48e67ba136
41fafc0c79d31ab9abb8be3956a086c67b633dc2
/userland/StdLib/src/malloc.cpp
ffc8d1fe90cfdd7de6971cfa20fe10e35381fb9d
[]
no_license
GuillaumeGas/LtMicros
4832be94733792e56cc6808a22aac8fd02d8061d
c389c04316df02283d4f7f880078d1b9d51bf4d1
refs/heads/master
2020-05-27T16:55:13.463086
2020-02-09T11:04:37
2020-02-09T11:04:37
188,711,579
1
0
null
null
null
null
UTF-8
C++
false
false
5,182
cpp
#include "malloc.h" #include "stdlib.h" #include "stdio.h" #include "syscalls.h" /// @brief Size in bytes of a block header #define BLOCK_HEADER_SIZE sizeof(int) /// @brief Block size in bytes of a block, without its header #define DEFAULT_BLOCK_SIZE PAGE_SIZE - BLOCK_HEADER_SIZE /// @brief Block size in bytes #define DEFAULT_BLOCK_SIZE_WITH_HEADER DEFAULT_BLOCK_SIZE + BLOCK_HEADER_SIZE /// @brief Minimal block size, used to determine if the block is large enough to be splitted #define MINIMAL_BLOCK_SIZE 4 /// @brief Indicates that a block if free #define BLOCK_FREE 0 /// @brief Indicates that a block if used #define BLOCK_USED 1 #define PAGE_SIZE 4096 /// @brief Describes a block struct MemBlock { /// @brief Block size in bytes, including the header, 31 bits used for the size, 1 bit for the state unsigned int size : 31; /// @brief Indicates if the block is free or not unsigned int state : 1; /// @brief Represents the block content, not directly used, but &data instead void * data; }; static void * _Allocate(MemBlock * block, unsigned int size); static void _SplitBlock(MemBlock * block, unsigned int size); static MemBlock * _Sbrk(int n); /* TODO : find a way to implemet mod */ static unsigned int _local_mod(unsigned int a, unsigned int b) { while (a > b) a -= b; return (a < b) ? 1 : 0; } static unsigned int ClosestPow(unsigned int x, unsigned int y) { unsigned int val = (unsigned int)x; while (_local_mod(val, y) != 0) { val++; } return val; } MemBlock * g_baseBlock = nullptr; MemBlock * g_limitBlock = nullptr; MemBlock * g_lastBlock = nullptr; void DumpHeap() { MemBlock * currentBlock = g_baseBlock; printf("limit is %x\n", g_limitBlock); printf("last is %x\n", g_lastBlock); while (currentBlock <= g_limitBlock) { printf("[%x, %d, %s]\n", currentBlock, currentBlock->size, currentBlock->state == BLOCK_FREE ? "free" : "used"); currentBlock = (MemBlock*)((unsigned int)currentBlock + currentBlock->size); if (currentBlock->size == 0) break; } } void InitMalloc() { g_baseBlock = nullptr; g_limitBlock = nullptr; g_lastBlock = nullptr; } void * HeapAlloc(int size) { int blockSize = 0; if (size <= 0) { printf("wtf %d\n", size); return nullptr; } if (g_baseBlock == nullptr) { g_baseBlock = (MemBlock*)_Sbrk(1); g_baseBlock->size = PAGE_SIZE; g_baseBlock->state = BLOCK_FREE; g_limitBlock = g_baseBlock + PAGE_SIZE; g_lastBlock = g_baseBlock; } blockSize = ClosestPow((unsigned int)size + BLOCK_HEADER_SIZE, 4); void * res = nullptr; res = _Allocate(g_baseBlock, (int)blockSize); if (res == nullptr) { printf("Dumping heap\n"); DumpHeap(); while (1); } return res; } void HeapFree(void * ptr) { if (ptr == nullptr) { return; } MemBlock * block = (MemBlock*)((u32)ptr - BLOCK_HEADER_SIZE); if (block->state == BLOCK_FREE) { //__debugbreak(); return; } block->state = BLOCK_FREE; MemSet(&(block->data), 0, block->size - BLOCK_HEADER_SIZE); //_Defrag(); // TODO : fix it } static void * _Allocate(MemBlock * block, unsigned int size) { void * res_ptr = nullptr; while (block <= g_lastBlock && res_ptr == nullptr) { if (block->state == BLOCK_USED || size > block->size) { block = (MemBlock *)((unsigned int)block + block->size); continue; } if ((block->size - size) >= (int)(BLOCK_HEADER_SIZE + MINIMAL_BLOCK_SIZE)) _SplitBlock(block, size); res_ptr = &(block->data); } if (res_ptr == nullptr) { if (size > DEFAULT_BLOCK_SIZE) { unsigned int usize = size; const unsigned int ubsize = (unsigned int)DEFAULT_BLOCK_SIZE; unsigned int n = usize / ubsize; if (_local_mod(usize, ubsize) > 0) { n++; } block = (MemBlock*)_Sbrk(n); } else { block = (MemBlock*)_Sbrk(1); } res_ptr = _Allocate(block, size); } block->state = BLOCK_USED; return res_ptr; } static void _SplitBlock(MemBlock * block, unsigned int size) { MemBlock * second_block = (MemBlock *)((unsigned int)block + size); second_block->size = block->size - size; second_block->state = BLOCK_FREE; block->size = size; } static MemBlock * _Sbrk(int n) { if (n <= 0) { printf("n <= 0\n"); return nullptr; } MemBlock * newBlock = (MemBlock*)_sysSbrk(n); newBlock->size = n * PAGE_SIZE; newBlock->state = BLOCK_FREE; MemSet((&(newBlock->data)), 0, newBlock->size - BLOCK_HEADER_SIZE); g_lastBlock = newBlock; g_limitBlock = g_lastBlock + g_lastBlock->size; return newBlock; }
[ "guillaume@gas-ntic.fr" ]
guillaume@gas-ntic.fr
1f8405e5b7665ea5a470b742ade318823a1b9c2b
86e1f2bcb970eeecf4174018c41b310d88c7b4b2
/masktools/filters/mask/functions_avx2.h
a297d58d47f9a6b39cec7d592291d7f0d70b3dd4
[ "MIT" ]
permissive
KAviSynth/masktools
24708f9f33031568f5544bc81d20a7598d4618ac
f2074323234bae2303f2ae5960f42eb18e3033c8
refs/heads/16bit
2022-12-31T19:30:25.928380
2020-09-04T10:43:24
2020-09-19T17:03:50
287,671,865
0
0
NOASSERTION
2020-10-19T15:04:34
2020-08-15T03:43:18
C++
UTF-8
C++
false
false
5,269
h
#ifndef __Mt_MaskFunctions_AVX2_H__ #define __Mt_MaskFunctions_AVX2_H__ #include "../../../common/utils/utils.h" #include "../../common/simd.h" namespace Filtering { namespace MaskTools { namespace Filters { namespace Mask { typedef Byte (Operator)(Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, Byte, const Short matrix[10], int nLowThreshold, int nHighThreshold); typedef void (ProcessLineAvx2)(Byte *pDst, const Byte *pSrcp, const Byte *pSrc, const Byte *pSrcn, const Short matrix[10], const __m256i &lowThresh, const __m256i &highThresh, int width); template<Operator op, class T> void generic_avx2_c(Byte *pDst, ptrdiff_t nDstPitch, const Byte *pSrc, ptrdiff_t nSrcPitch, T &thresholds, const Short matrix[10], int nWidth, int nHeight) { const Byte *pSrcp = pSrc - nSrcPitch; const Byte *pSrcn = pSrc + nSrcPitch; /* top-left */ pDst[0] = op(pSrc[0], pSrc[0], pSrc[1], pSrc[0], pSrc[0], pSrc[1], pSrcn[0], pSrcn[0], pSrcn[1], matrix, thresholds.min(0), thresholds.max(0)); /* top */ for ( int x = 1; x < nWidth - 1; x++ ) pDst[x] = op(pSrc[x-1], pSrc[x], pSrc[x+1], pSrc[x-1], pSrc[x], pSrc[x+1], pSrcn[x-1], pSrcn[x], pSrcn[x+1], matrix, thresholds.min(x), thresholds.max(x)); /* top-right */ pDst[nWidth-1] = op(pSrc[nWidth-2], pSrc[nWidth-1], pSrc[nWidth-1], pSrc[nWidth-2], pSrc[nWidth-1], pSrc[nWidth-1], pSrcn[nWidth-2], pSrcn[nWidth-1], pSrcn[nWidth-1], matrix, thresholds.min(nWidth-1), thresholds.max(nWidth-1)); pDst += nDstPitch; pSrcp += nSrcPitch; pSrc += nSrcPitch; pSrcn += nSrcPitch; thresholds.nextRow(); for ( int y = 1; y < nHeight - 1; y++ ) { /* left */ pDst[0] = op(pSrcp[0], pSrcp[0], pSrcp[1], pSrc[0], pSrc[0], pSrc[1], pSrcn[0], pSrcn[0], pSrcn[1], matrix, thresholds.min(0), thresholds.max(0)); /* center */ for ( int x = 1; x < nWidth - 1; x++ ) pDst[x] = op(pSrcp[x-1], pSrcp[x], pSrcp[x+1], pSrc[x-1], pSrc[x], pSrc[x+1], pSrcn[x-1], pSrcn[x], pSrcn[x+1], matrix, thresholds.min(x), thresholds.max(x)); /* right */ pDst[nWidth-1] = op(pSrcp[nWidth-2], pSrcp[nWidth-1], pSrcp[nWidth-1], pSrc[nWidth-2], pSrc[nWidth-1], pSrc[nWidth-1], pSrcn[nWidth-2], pSrcn[nWidth-1], pSrcn[nWidth-1], matrix, thresholds.min(nWidth-1), thresholds.max(nWidth-1)); pDst += nDstPitch; pSrcp += nSrcPitch; pSrc += nSrcPitch; pSrcn += nSrcPitch; thresholds.nextRow(); } /* bottom-left */ pDst[0] = op(pSrcp[0], pSrcp[0], pSrcp[1], pSrc[0], pSrc[0], pSrc[1], pSrc[0], pSrc[0], pSrc[1], matrix, thresholds.min(0), thresholds.max(0)); /* bottom */ for ( int x = 1; x < nWidth - 1; x++ ) pDst[x] = op(pSrcp[x-1], pSrcp[x], pSrcp[x+1], pSrc[x-1], pSrc[x], pSrc[x+1], pSrc[x-1], pSrc[x], pSrc[x+1], matrix, thresholds.min(x), thresholds.max(x)); /* bottom-right */ pDst[nWidth-1] = op(pSrcp[nWidth-2], pSrcp[nWidth-1], pSrcp[nWidth-1], pSrc[nWidth-2], pSrc[nWidth-1], pSrc[nWidth-1], pSrc[nWidth-2], pSrc[nWidth-1], pSrc[nWidth-1], matrix, thresholds.min(nWidth-1), thresholds.max(nWidth-1)); } template<ProcessLineAvx2 process_line_left, ProcessLineAvx2 process_line, ProcessLineAvx2 process_line_right> static void generic_avx2(Byte *pDst, ptrdiff_t nDstPitch, const Byte *pSrc, ptrdiff_t nSrcPitch, const Short matrix[10], int nLowThreshold, int nHighThreshold, int nWidth, int nHeight) { const Byte *pSrcp = pSrc - nSrcPitch; const Byte *pSrcn = pSrc + nSrcPitch; auto v128 = _mm256_set1_epi8(Byte(128)); auto low_thr_v = _mm256_set1_epi8(Byte(nLowThreshold)); low_thr_v = _mm256_sub_epi8(low_thr_v, v128); auto high_thr_v = _mm256_set1_epi8(Byte(nHighThreshold)); high_thr_v = _mm256_sub_epi8(high_thr_v, v128); int avx2_width = (nWidth - 1 - 32) / 32 * 32 + 32; /* top-left */ process_line_left(pDst, pSrc, pSrc, pSrcn, matrix, low_thr_v, high_thr_v, 32); /* top */ process_line(pDst + 32, pSrc+32, pSrc+32, pSrcn+32, matrix, low_thr_v, high_thr_v, avx2_width - 32); /* top-right */ process_line_right(pDst + nWidth - 32, pSrc + nWidth - 32, pSrc + nWidth - 32, pSrcn + nWidth - 32, matrix, low_thr_v, high_thr_v, 32); pDst += nDstPitch; pSrcp += nSrcPitch; pSrc += nSrcPitch; pSrcn += nSrcPitch; for ( int y = 1; y < nHeight-1; y++ ) { /* left */ process_line_left(pDst, pSrcp, pSrc, pSrcn, matrix, low_thr_v, high_thr_v, 32); /* center */ process_line(pDst + 32, pSrcp+32, pSrc+32, pSrcn+32, matrix, low_thr_v, high_thr_v, avx2_width - 32); /* right */ process_line_right(pDst + nWidth - 32, pSrcp + nWidth - 32, pSrc + nWidth - 32, pSrcn + nWidth - 32, matrix, low_thr_v, high_thr_v, 32); pDst += nDstPitch; pSrcp += nSrcPitch; pSrc += nSrcPitch; pSrcn += nSrcPitch; } /* bottom-left */ process_line_left(pDst, pSrcp, pSrc, pSrc, matrix, low_thr_v, high_thr_v, 32); /* bottom */ process_line(pDst + 32, pSrcp+32, pSrc+32, pSrc+32, matrix, low_thr_v, high_thr_v, avx2_width - 32); /* bottom-right */ process_line_right(pDst + nWidth - 32, pSrcp + nWidth - 32, pSrc + nWidth - 32, pSrc + nWidth - 32, matrix, low_thr_v, high_thr_v, 32); _mm256_zeroupper(); } } } } } #endif
[ "pinterfer@gmail.com" ]
pinterfer@gmail.com
b6b50caae8f9bc932a2dd6fc2f51e1139c726df0
cbbf0dbb059bbca24230af5fddd9f0963b422085
/test_BST.cpp
a5baa7617665c6d89121cc527d0777ce5fe9559a
[]
no_license
ignandre/BST
288196d58330d4beacebff03857510e98d9fd7bf
958c3b786113c644f9b72b69284dca3e5ff25ed3
refs/heads/master
2021-06-05T06:20:34.192312
2016-10-05T13:56:30
2016-10-05T13:56:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,969
cpp
#include "BST.hpp" #include <iostream> #include <algorithm> #include <vector> using namespace std; /** * A simple test driver for the BST class template. */ int main() { /* Create an STL vector of some ints */ vector<int> v; v.push_back(3); v.push_back(4); v.push_back(1); v.push_back(100); v.push_back(-33); /* Create an instance of BST holding int */ BST<int> b; /* Insert a few data items. */ vector<int>::iterator vit = v.begin(); vector<int>::iterator ven = v.end(); for(; vit != ven; ++vit) { // all these inserts are unique, so should return a std::pair // with second part true std::pair<BST<int>::iterator,bool> pr = b.insert(*vit); if(! pr.second ) { cout << "Incorrect bool return value when inserting " << *vit << endl; return -1; } if(*(pr.first) != *vit) { cout << "Incorrect iterator return value when inserting " << *vit << endl; return -1; } } /* Test size. */ cout << "Size is: " << b.size() << endl; if(b.size() != v.size()) { cout << "... which is incorrect." << endl; return -1; } /* Test find return value. */ vit = v.begin(); for(; vit != ven; ++vit) { if(*(b.find(*vit)) != *vit) { cout << "Incorrect return value when finding " << *vit << endl; return -1; } } /* Sort the vector, to compare with inorder iteration on the BST */ sort(v.begin(),v.end()); /* Test BST iterator; should iterate inorder */ cout << "traversal using iterator:" << endl; vit = v.begin(); BST<int>::iterator en = b.end(); BST<int>::iterator it = b.begin(); for(; vit != ven; ++vit) { if(! (it != en) ) { cout << *it << "," << *vit << ": Early termination of BST iteration." << endl; return -1; } cout << *it << endl; if(*it != *vit) { cout << *it << "," << *vit << ": Incorrect inorder iteration of BST." << endl; return -1; } ++it; } cout << "OK." << endl; }
[ "postmail2andre@yahoo.com" ]
postmail2andre@yahoo.com
6eeb2a16c5970276866b1cde8a76e643e40c33b8
9ca8a83818db556aacad71601761dc2975e78441
/3DEngine/3DEngine/PortSndAudioManager.h
d8141cc370f97e44cfc98b4509b3ac35a4b29e11
[]
no_license
AmiraliMohayaee/amir-3d-engine
8f568985c71919f709d79c3c14a2e959b6a97941
031e63a1e3ded5c47bb83644a9ceb29ef7ceb671
refs/heads/master
2021-01-19T09:57:39.695011
2018-10-05T15:38:45
2018-10-05T15:38:45
32,399,907
0
0
null
null
null
null
UTF-8
C++
false
false
818
h
#pragma once #include "libsndfile/include/sndfile.h" #include <stdio.h> #include <string> #include <vector> #include "include/portaudio.h" #include "Vec3.h" #include <math.h> #include "File.h" #include "Singleton.h" #include "Non-Copyable.h" namespace Engine { class PortSndAudioManager : public NonCopyable { public: friend Singleton<PortSndAudioManager>; ~PortSndAudioManager(); void PAInitialize(); void PATerminate(); // For a mixing func add up two signals and devide by two private: //SNDFILE* m_soundFile; //SF_INFO m_sfInfo; PortSndAudioManager(); int m_pos; Vec3f m_soundPos; //Vec positioning to replace int positioning later Vec3f m_reverbPos; PaError m_error; }; typedef Singleton<PortSndAudioManager> TheAudioManager; }
[ "UncleKitchenerSA@yahoo.com@2778bfdb-6347-df46-a1d9-f26592b978c5" ]
UncleKitchenerSA@yahoo.com@2778bfdb-6347-df46-a1d9-f26592b978c5
7db8b56e5180793f6d885976b5def2ba58c22aad
49f88ff91aa582e1a9d5ae5a7014f5c07eab7503
/gen/services/viz/public/interfaces/compositing/frame_deadline.mojom.cc
438fee947df3f72ae4fddcd02e8ba04df998cc0a
[]
no_license
AoEiuV020/kiwibrowser-arm64
b6c719b5f35d65906ae08503ec32f6775c9bb048
ae7383776e0978b945e85e54242b4e3f7b930284
refs/heads/main
2023-06-01T21:09:33.928929
2021-06-22T15:56:53
2021-06-22T15:56:53
379,186,747
0
1
null
null
null
null
UTF-8
C++
false
false
2,929
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-private-field" #elif defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4056) #pragma warning(disable:4065) #pragma warning(disable:4756) #endif #include "services/viz/public/interfaces/compositing/frame_deadline.mojom.h" #include <math.h> #include <stdint.h> #include <utility> #include "base/logging.h" #include "base/run_loop.h" #include "mojo/public/cpp/bindings/lib/message_internal.h" #include "mojo/public/cpp/bindings/lib/serialization_util.h" #include "mojo/public/cpp/bindings/lib/unserialized_message_context.h" #include "mojo/public/cpp/bindings/lib/validate_params.h" #include "mojo/public/cpp/bindings/lib/validation_context.h" #include "mojo/public/cpp/bindings/lib/validation_errors.h" #include "mojo/public/interfaces/bindings/interface_control_messages.mojom.h" #include "services/viz/public/interfaces/compositing/frame_deadline.mojom-shared-message-ids.h" #include "mojo/public/cpp/base/time_mojom_traits.h" namespace viz { namespace mojom { FrameDeadline::FrameDeadline() : frame_start_time(), deadline_in_frames(), frame_interval(), use_default_lower_bound_deadline() {} FrameDeadline::FrameDeadline( base::TimeTicks frame_start_time_in, uint32_t deadline_in_frames_in, base::TimeDelta frame_interval_in, bool use_default_lower_bound_deadline_in) : frame_start_time(std::move(frame_start_time_in)), deadline_in_frames(std::move(deadline_in_frames_in)), frame_interval(std::move(frame_interval_in)), use_default_lower_bound_deadline(std::move(use_default_lower_bound_deadline_in)) {} FrameDeadline::~FrameDeadline() = default; bool FrameDeadline::Validate( const void* data, mojo::internal::ValidationContext* validation_context) { return Data_::Validate(data, validation_context); } } // namespace mojom } // namespace viz namespace mojo { // static bool StructTraits<::viz::mojom::FrameDeadline::DataView, ::viz::mojom::FrameDeadlinePtr>::Read( ::viz::mojom::FrameDeadline::DataView input, ::viz::mojom::FrameDeadlinePtr* output) { bool success = true; ::viz::mojom::FrameDeadlinePtr result(::viz::mojom::FrameDeadline::New()); if (!input.ReadFrameStartTime(&result->frame_start_time)) success = false; result->deadline_in_frames = input.deadline_in_frames(); if (!input.ReadFrameInterval(&result->frame_interval)) success = false; result->use_default_lower_bound_deadline = input.use_default_lower_bound_deadline(); *output = std::move(result); return success; } } // namespace mojo #if defined(__clang__) #pragma clang diagnostic pop #elif defined(_MSC_VER) #pragma warning(pop) #endif
[ "aoeiuv020@gmail.com" ]
aoeiuv020@gmail.com
ed1d7819a6311a9786969c954999c59dcb4dd774
6ba53bfef57b252fae219bd6e45b1341848b94bb
/SPH/common/thrust/detail/backend/cuda/detail/launch_closure.h
a750bdef4ea31026e20c3d5ec5127ca2dc339d20
[]
no_license
vanlin5566/CIS565_Final
bb3a3182414ae2d7f99063f1863d9fcd3baf6e56
a2efbe5f46165b95fba7246e248a27103457eca8
refs/heads/master
2021-01-17T02:37:26.059902
2012-07-04T20:09:35
2012-07-04T20:09:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,891
h
/* * Copyright 2008-2011 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <thrust/detail/config.h> #include <thrust/detail/backend/cuda/arch.h> namespace thrust { namespace detail { namespace backend { namespace cuda { namespace detail { // TODO remove template<typename Closure> size_t block_size_with_maximal_occupancy(size_t dynamic_smem_bytes_per_thread = 0); // TODO remove template<typename Closure, typename Size1, typename Size2> size_t num_blocks_with_maximal_occupancy(Size1 n, Size2 block_size, size_t dynamic_smem_bytes_per_block = 0); template<typename Closure, typename Size> void launch_closure(Closure f, Size num_blocks); template<typename Closure, typename Size1, typename Size2> void launch_closure(Closure f, Size1 num_blocks, Size2 block_size); template<typename Closure, typename Size1, typename Size2, typename Size3> void launch_closure(Closure f, Size1 num_blocks, Size2 block_size, Size3 smem_size); /*! Returns a copy of the cudaFuncAttributes structure * that is associated with a given Closure */ template <typename Closure> arch::function_attributes_t closure_attributes(void); } // end namespace detail } // end namespace cuda } // end namespace backend } // end namespace detail } // end namespace thrust #include <thrust/detail/backend/cuda/detail/launch_closure.inl>
[ "whu.eis.lt@gmail.com" ]
whu.eis.lt@gmail.com
ae75dcdb6b955996e04a854fe180ad6847afe4eb
83dbe0a351d3ee36eace86dc7494ef6d0f95c37a
/common/clumsy_lib/include/clumsy_lib/dependent_propagator.h
bbaae325d45e0f3fa52c8d7d8c306c7eaad462f3
[]
no_license
zeagle01/graphics_play_ground
f3023ca374f1cdce1dc3e81e736e55b3907f2f4b
01f4220e99020935c66be25ac8a012ce43accd1e
refs/heads/master
2023-09-01T15:33:22.435143
2023-08-27T13:30:38
2023-08-27T13:30:38
177,251,614
0
0
null
null
null
null
UTF-8
C++
false
false
6,739
h
#pragma once #include "static_loop.h" #include "type_list.h" #include <typeindex> #include <unordered_map> #include <set> #include <memory> //#include <iostream> namespace clumsy_lib { template<typename T> struct default_get_deps { template<typename U> static auto choosor() { if constexpr (requires {typename U::deps; }) { return typename U::deps {}; } else { return type_list<>{}; } } using type = decltype(choosor<T>()); }; using adj_list_t = std::unordered_map<std::type_index, std::set<std::type_index>>; using change_status_t = std::unordered_map<std::type_index, bool>; class Dependent_Graph { public: template<typename list, template<typename> typename get_deps = default_get_deps> static adj_list_t build() { adj_list_t ret; For_Each_Type<list>::apply<Collect_Deps<get_deps>>(ret); return ret; } static adj_list_t merge(adj_list_t dep0, adj_list_t dep1) { adj_list_t ret = dep0; for (const auto& var : dep1) { auto up = var.first; for (const auto& down : dep1[up]) { if (ret.contains(up)) { ret[up].insert(down); } else { ret[up] = std::set<std::type_index>{ down }; } } if (!ret.contains(up)) { ret[up] = std::set<std::type_index>{}; } } return ret; } private: template< template<typename> typename get_deps > struct Collect_Deps { template<typename curr_t> struct Add_Down_Stream { template<typename upstream_t> static void apply(adj_list_t& m_down_streams) { if (m_down_streams.contains(std::type_index(typeid(upstream_t)))) { m_down_streams[std::type_index(typeid(upstream_t))].insert(std::type_index(typeid(curr_t))); } else { m_down_streams[std::type_index(typeid(upstream_t))] = std::set{ std::type_index(typeid(curr_t)) }; } } }; template<typename T> static void apply(adj_list_t& m_down_streams) { using deps = get_deps<T>::type; For_Each_Type<deps>::apply<Add_Down_Stream<T>>(m_down_streams); if (!m_down_streams.contains(std::type_index(typeid(T)))) { m_down_streams[std::type_index(typeid(T))] = std::set<std::type_index>{}; } } }; }; template<typename list > class Down_Stream_Datas { public: Down_Stream_Datas(const change_status_t& is_changed) :m_is_changed(is_changed) {} template<typename name> bool is_changed() const { static_assert(Type_In_List<name, list>, "type should be in list!"); return m_is_changed.at(std::type_index(typeid(name))); } private: const change_status_t& m_is_changed; }; template<typename name> static bool check_is_changed(const change_status_t& is_changed) { return is_changed.at(std::type_index(typeid(name))); } template<typename list > class Dependent_Propagator { public: void set_dependent_graph(const adj_list_t& deps) { m_down_streams = deps; for (const auto& it : m_down_streams) { const auto& up = it.first; m_is_changed[up] = false; } } template<typename name> void touch() { static_assert(Type_In_List<name, list>, "type should be in list!"); touch_imp(std::type_index(typeid(name))); } template<typename name> bool is_changed() const { static_assert(Type_In_List<name, list>, "type should be in list!"); return m_is_changed.at(std::type_index(typeid(name))); } const change_status_t& get_all_change_status() const { return m_is_changed; } void propagate() { For_Each_Type<list>::template apply<Touch_If_Changed>(*this); } void clear_all_changes() { for (auto& c : m_is_changed) { c.second = false; } } void set_all_changes() { for (auto& c : m_is_changed) { c.second = true; } } private: change_status_t m_is_changed; adj_list_t m_down_streams; private: struct Touch_If_Changed { template<typename name,typename Host_Type> static void apply(Host_Type& host) { if (host.is_changed<name>()) { host.touch<name>(); } } }; void touch_imp(const std::type_index& t) { if (m_down_streams.contains(t)) { m_is_changed[t] = true; for (const auto& d : m_down_streams.at(t)) { touch_imp(d); } } } }; struct empty {}; template<typename T> struct default_get_dep_update_fn { template<typename U> static auto apply() { if constexpr (requires{typename U::dep_update_fn; }) { return typename U::dep_update_fn{}; } else { return empty{}; } } using type = decltype(apply<T>()); }; template<typename var_list, template<typename> typename get_deps = default_get_deps, template<typename> typename get_dep_update_fn = default_get_dep_update_fn > class dependent_updater { public: template<typename obj_t,typename upstream_obj_t> static void apply(obj_t& obj, const upstream_obj_t& upstream_obj, const change_status_t& changes) { s_changes = changes; For_Each_Type<var_list>::apply<update_each>(obj, upstream_obj); } private: struct update_each { template<typename Var_Name, typename obj_t, typename upstream_obj_t> static void apply(obj_t& obj, const upstream_obj_t& upstream_obj) { recurse_update_upstream<Var_Name, typename get_deps<Var_Name>::type>::apply(obj, upstream_obj ); } }; template<typename var, typename dep_list> struct recurse_update_upstream; template<typename var, typename ...dep> struct recurse_update_upstream <var, type_list< dep...>> { template<typename obj_t, typename upstream_obj_t> static void apply(obj_t& obj, const upstream_obj_t& upstream_obj ) { if constexpr (Type_In_List<var, var_list>) { bool any_changed = false; any_changed = (check_is_changed<dep>(s_changes) || ...); if (any_changed) { (recurse_update_upstream<dep, typename get_deps<dep>::type>::apply(obj, upstream_obj), ...); } if (check_is_changed<var>(s_changes)) { using update_fn = get_dep_update_fn<var>::type; if constexpr (!std::is_same_v<update_fn, empty>) { update_fn::apply(get_data<var>(obj, upstream_obj), get_data<dep>(obj, upstream_obj)...); //printf("exe %s \n", typeid(update_fn).name()); } s_changes[std::type_index(typeid(var))] = false; } } } template<typename var, typename obj_t, typename upstream_obj_t> static auto& get_data(obj_t& obj, const upstream_obj_t& upstream_obj) { if constexpr (Type_In_List<var, var_list>) { return obj.template get_ref<var>(); } else { return upstream_obj.template get_ref<var>(); } } }; static inline change_status_t s_changes = {}; }; }
[ "zeagle01@163.com" ]
zeagle01@163.com
f88945f1b8a46beb2f0bb834358e29b0a6bb69c7
981565926d9b718af5e8e64f3bb8d8206ded484e
/Src/LoLAConnector/lola_frame.h
23d874222abea490f09d3a75012a0073c46913ca
[]
no_license
TJArk-Robotics/TJArkCodeRelease2019
249a939484d2e31b00731ce6935fcfb0036e4a13
950a1b2d6114c01bd810ae4eeebbc89ea2fd5356
refs/heads/master
2020-12-18T11:20:09.878914
2020-01-21T14:22:28
2020-01-21T14:22:28
235,360,704
1
0
null
null
null
null
UTF-8
C++
false
false
1,461
h
#pragma once #include <map> #include <string> #include <vector> #include <msgpack.hpp> #include "LoLAConnector/battery.h" #include "LoLAConnector/fsr.h" #include "LoLAConnector/imu.h" #include "LoLAConnector/joints.h" #include "LoLAConnector/leds.h" #include "LoLAConnector/touch.h" #include "LoLAConnector/sonar.h" #include "LoLAConnector/robotConfig.h" // #include <robocup.h> struct LolaSensorFrame { Joints joints; IMU imu; Sonar sonar; FSR fsr; Battery battery; Touch touch; RobotConfig robotConfig; }; struct LolaActuatorFrame { Joints joints; Leds leds; // Robocup robocup; }; class LolaFrameHandler { public: LolaFrameHandler(); const LolaSensorFrame& unpack(const char* const buffer, size_t size); std::pair<char*, size_t> pack(); LolaActuatorFrame actuator_frame; private: void initSensorFrame(); void initActuatorFrame(); LolaSensorFrame sensor_frame; std::map<std::string, std::vector<float*>> sensor_frame_positions; std::map<std::string, std::vector<float*>> actuator_frame_positions; std::map<std::string, std::vector<std::string*>> robotConfig_frame_positions; std::map<std::string, std::vector<int*>> status_frame_positions; // active in default, on/off limit implemented to keep joints in the acceptable range of acceleration. // std::map<std::string, std::vector<bool*>> filter_frame_positions; msgpack::sbuffer buffer; };
[ "tongjilishu@163.com" ]
tongjilishu@163.com
a6fdcf65ea286d6e1bb9b0655cb2364614bda743
50c39eed7002150b50184628916c16facc1dd3b6
/v1/main.cpp
f8ddfe0cc98d6bc0ce445bc1440b2e21786fbb5a
[ "Zlib", "FTL" ]
permissive
alexandre-tsu-manuel/CliqueLeCube
56c9b35ae055d073586c6b35c5af4dd81772f144
fea537dcab7ad78b3d669a196404d2e248c794c6
refs/heads/master
2021-05-27T12:42:13.891262
2015-01-26T06:39:15
2015-01-26T06:39:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
#include <SDL/SDL.h> #include <SDL/SDL_ttf.h> #include <fmod.h> #include <time.h> #include "bouton.hpp" #include "fonctions.hpp" #include "jouer.hpp" // TODO (Cesar#1#): Faire les Highscores // TODO (Cesar#2#): Cube piege // TODO (Cesar#3#): Cube Bonus // TODO (Cesar#4#): Optimiser SDL_Surface *ecran, *layer; TTF_Font *policeMini; TTF_Font *policeMaxi; int main(int argc, char *argv[]) { srand(time(NULL)); putenv("SDL_VIDEO_WINDOW_POS=center"); SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); const SDL_VideoInfo* info = SDL_GetVideoInfo(); TTF_Init(); initFMOD(); ecran = SDL_SetVideoMode(info->current_w, info->current_h, info->vfmt->BitsPerPixel, SDL_HWSURFACE | SDL_NOFRAME | SDL_DOUBLEBUF); SDL_WM_SetCaption("Clique le cube !", NULL); layer = SDL_CreateRGBSurface(SDL_HWSURFACE, ecran->w, ecran->h, ecran->format->BitsPerPixel, 0, 0, 0, 0); policeMini = TTF_OpenFont("Minecraftia.ttf", 20); policeMaxi = TTF_OpenFont("Minecraftia.ttf", 35); menu(); TTF_CloseFont(policeMini); TTF_CloseFont(policeMaxi); TTF_Quit(); SDL_Quit(); return EXIT_SUCCESS; }
[ "amanuel@ad4screen.com" ]
amanuel@ad4screen.com
7a0393497b9f4575858aecd5c01a042a9a200490
2fcee87709417717620d2ca4131f96e29c0bc320
/Codeforces/Beta-round-25/B.cpp
7e06893c8d34bf417e8b0d84feeffcc83b533922
[]
no_license
Jaminur-Rashid/Problem-Solving
7b502b03c5eea180282adcaad1b74ab526c92f12
c651c9e810dba6a8f4b1ece6a3c27554d4a49ac0
refs/heads/master
2023-07-27T15:22:14.744541
2021-09-09T12:13:13
2021-09-09T12:13:13
404,700,331
1
0
null
null
null
null
UTF-8
C++
false
false
1,222
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; #define mp make_pair #define pb push_back #define ff first #define s second #define nl '\n' #define MAX 99999999999 #define MIN 0 const unsigned int M = 1000000007; void solve(){ ll n; while(cin>>n){ string digit; cin>>digit; if(digit.size()%2==0){ for(int i=0;i<digit.size();i+=2){ cout<<digit.substr(i,2); if(i!=n-2){ cout<<'-'; } } } else{ for(int i=0;i<n;i+=2){ if(i==0){ cout<<digit.substr(0,3); if(i!=n-2 and n!=3){ cout<<'-'; } i++; } else{ cout<<digit.substr(i,2); if(i!=n-2){ cout<<'-'; } } } } cout<<nl; } } int main(){ ios_base::sync_with_stdio(false); //cin.tie(NULL); solve(); return 0; }
[ "jaminurrashid21@gmail.com" ]
jaminurrashid21@gmail.com
0f63b0dea8a342bf76006ff8a9976a606f670c94
42a072d3c53cd78c1ce82b974442d998298284cc
/libalgo/source/algorithms/nonlinearleastsquares/NonLinearLeastSquares.hpp
e7a67504d2ddd680f0230c615d3de85f3ab09f04
[]
no_license
bayertom/detectproj
b359991e2457aa91cb8adf22b585215f768ccf12
1ba138ae9a1541ab504e000d5961a4ca3c5cec51
refs/heads/master
2021-01-23T03:05:33.525489
2017-01-02T00:06:41
2017-01-02T00:06:41
19,872,193
6
0
null
null
null
null
UTF-8
C++
false
false
52,498
hpp
// Description: Non Linear Least Squares algorithms // Copyright (c) 2010 - 2013 // Tomas Bayer // Charles University in Prague, Faculty of Science // bayertom@natur.cuni.cz // This library is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this library. If not, see <http://www.gnu.org/licenses/>. #ifndef NonLinearLeastSquares_HPP #define NonLinearLeastSquares_HPP #include <cmath> #include "libalgo/source/exceptions/BadDataException.h" //Set namespace using namespace MatrixOperations; template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::GN ( FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, const T max_error, const unsigned short max_iterations ) { //Solving non Linear Least Squares using the Gaussian-Newton method //Faster than backtracking method unsigned short iterations = 0; T cost_old = MAX_FLOAT; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J ( m, n ), V ( m, 1 ), dX ( n, 1 ), dX2 ( n, 1 ); //Assign matrix Matrix <T> X_Old = X; //Compute initial V matrix (residuals) function_v ( X, Y, V, W ); //Perform iterations while ( iterations < max_iterations ) { //Increment iterations iterations++; //Compute new J matrix: linearize solution using the Taylor approximation function_j ( X, J ); //Stop computation if ( sum2 ( trans ( J ) * W * V ) < max_error ) break; //Compute Minimum Weighteed Least Squares using qr decomposition //Jacobian J = [ d_R, d_latp, d_lonp, d_lat0, d_lon0, d_dx, d_dy] //dX = mlsqr ( J, W, V ) * ( -1.0 ); dX = pinv1 ( trans ( J ) * W * J ) * trans ( J ) * W * V * ( -1.0 ); //Compute new X X = X + dX; //Compute new V matrix function_v ( X, Y, V, W ); //X.print(); } //Compute final values in V function_v ( X, Y, V, W ); //Return squares of residuals return norm ( trans ( V ) * W * V ); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::GND(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T alpha, const T max_error, const unsigned short max_iterations, const T max_diff, std::ostream * output) { //Solving Non linear Least Squares using the damped Gaussian-Newton method T cost_old = MAX_FLOAT; //Set iterations to 0 iterations = 0; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J ( m, n ), V2 ( m, 1 ), dX ( n, 1 ), J_new ( m, n ); //Assign matrix Matrix <T> Y2 = Y; //Compute initial V matrix (residuals) function_v ( X, Y, V, W ); //Compute matrices function_j ( X, J ); Matrix <T> G = trans ( J ) * W * V; Matrix <T> F = trans ( V ) * W * V; //V.print(); //Perform iterations while ( iterations < max_iterations ) { //Increment iterations iterations++; //Compute new J matrix: linearize solution using the Taylor approximation //function_j ( X, J ); //Compute the direction dX = pinv1(trans(J) * W * J) * G * (-1.0); //dX.print(); //Compute new trial X Matrix <T> X2 = X + dX; //Matrix <T> X2 = addStep(X, dX, A, B); //Reflection into the search space reflection(X2, A, B); //Compute new trial V matrix (residuals) function_v ( X2, Y2, V2, W ); //V2.print(); //Apply back-step using a bisection const T t_min = 1.0e-10; T t = 1.0; while ( (sum2(V2) > sum2(V) + sum(trans(V) * J * dX) * t * alpha * 2.0) && (t > t_min) ) { //Step t bisection t /= 2; //Compute new X2 X2 = X + dX * t; //X2 = addStep(X, dX * t, A, B); //Reflection into the search space reflection(X2, A, B); //Compute new V matrix: do not change parameters in one iteration step function_v ( X2, Y2, V2, W, false ); } //Compute new X using damping factor t X = X + dX * t; //X = addStep(X, dX * t, A, B); //Reflection into the search space reflection(X, A, B); //Compute V matrix function_v ( X, Y, V, W ); //Compute new J matrix function_j ( X, J ); //Compute new residuals and gradient Matrix <T> F_new = trans ( V ) * W * V; Matrix <T> G_new = trans ( J ) * W * V; //Terminal condition if ( ( norm ( G ) < max_error ) || ( fabs ( F_new ( 0, 0 ) - F ( 0, 0 ) ) < max_diff * std::max ( 1.0 , F ( 0, 0 ) ) ) || ( F ( 0, 0 ) < max_error ) ) break; //Assign old values G = G_new; F = F_new; //Increment iterations iterations++; //X.print(); //J.print(); } //Compute final values in V function_v ( X, Y, V, W ); //X.print(); //X.print ( output ); //T rr = norm ( trans (V) * V ); //std::cout << "res =" << rr << '\n'; //Return squares of residuals return norm ( trans ( V ) * W * V ); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::BFGS(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T alpha, const T max_error, const unsigned short max_iterations, const T max_diff, std::ostream * output) { //Solving non Linear Least Squares with using the BFGS algorithm //Default value: alpha = 0.0001; T cost_old = MAX_FLOAT; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J(m, n), V2(m, 1), dX(n, 1), E(n, n, 0.0, 1.0); //Assign matrix Matrix <T> Y2 = Y; //Compute initial V matrix (residuals) function_v(X, Y, V, W); //Compute initial J matrix function_j(X, J); //Compute matrices Matrix <T> H = trans(J) * W * J; Matrix <T> G = trans(J) * W * V; Matrix <T> H_new = H; Matrix <T> G_new = G; //Compute objective function T fx = norm(trans(V) * W * V), fx_new = fx, fx_dk = fx; //Set iterations to 0 iterations = 0; //Perform iterations while (iterations < max_iterations) { //Increment iterations iterations++; //Compute new dX dX = pinv1 ( H ) * G * ( -1.0 ); //dX = mlsqr(J, W, V) * (-1.0); //dX.print(); //Compute new trial X Matrix <T> X2 = X + dX; //Reflection into the search space reflection(X2, A, B); //Compute new trial V matrix (residuals) function_v(X2, Y2, V2, W); //Apply back-step using a bisection const T t_min = 1.0e-10; T t = 1.0; while ((sum2(V2) > sum2(V) + sum(trans(V) * J * dX) * t * alpha * 2.0) && (t > t_min)) { //Step t bisection t /= 2; //Compute new X2 X2 = X + dX * t; //X2 = addStep(X, dX * t, A, B); //Reflection into the search space reflection(X2, A, B); //Compute new V matrix: do not change parameters in one iteration step function_v(X2, Y2, V2, W, false); } //Compute new X using back-step method X = X + dX * t; //Reflection into the search space reflection(X, A, B); //Compute new V matrix and residual matrix V function_v(X, Y, V, W); //Compute new J matrix function_j(X, J); //Compute new residuals and gradient G_new = trans(J) * W * V; fx_new = norm(trans(V) * W * V); //Terminal condition if ((norm(G) < max_error) || (fabs(fx_new - fx) < 1.0 * max_diff * std::min(1.0, fx)) || (fx < max_error)) { break; } //Compute solution difference Matrix <T> s = dX * t; //Compute gradient difference Matrix <T> y = G_new - G; //Compute denominators const T ys = norm(trans(y) * s); const T shs = norm(trans(s) * H * s); //Compute update, if y * s > 0 (symmetric positive definite update) if (ys > 0) { Matrix <T> dH(n, n); if ((ys > MIN_FLOAT) && (shs > MIN_FLOAT)) { dH = y * trans(y) / ys - H * s * trans(H * s) / shs; } //Compute Hessian matrix using quasi-Newton update: H = J*W*J + dH H_new = trans(J) * W * J + dH; } //Do not update, if y * s < = 0 else H_new = H; //Assign values H = H_new; G = G_new; //F = F_new; } //Compute final values in V function_v(X, Y, V, W); return norm(trans(V) * W * V); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::BFGSH(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T alpha, const T nu, const T max_error, const unsigned short max_iterations, const T max_diff, std::ostream * output) { //Solving Non-linear Least Squares using the hybrid BFGS algorithm //Combination of the Gauss-Newton and BFGS method, algorithm by L Luksan //Default values: nu = 0.0001, alpha = 0.0001; //Create matrices const unsigned short k = 5, m = W.rows(), n = X.rows(); Matrix <T> J ( m, n ), V2 ( m, 1 ), dX ( n, 1 ), E ( n, n, 0.0, 1.0 ); //Assign matrix Matrix <T> Y2 = Y; //Compute initial V matrix (residuals) function_v ( X, Y, V, W ); //Compute initial J matrix function_j ( X, J ); //Compute matrices Matrix <T> H = trans ( J ) * W * J; Matrix <T> G = trans ( J ) * W * V; Matrix <T> H_new = H; Matrix <T> G_new = G; //H.print(); //J.print(); //Compute objective function T fx = norm(trans(V) * W * V), fx_new = fx; //Set iterations to 0 iterations = 0; //Perform iterations while ( iterations < max_iterations ) { //Increment iterations iterations++; //Compute new dX dX = pinv1(H) * G * (-1.0); //reflection2(X, dX, A, B); //H.print(); //dX.print(); //Compute new trial X Matrix <T> X2 = X + dX; //Reflection into the search space reflection(X2, A, B); //Compute new trial V matrix (residuals) function_v ( X2, Y2, V2, W, false ); //Apply back-step using a bisection const T t_min = 1.0e-10; T t = 1.0; while ( ( sum2 ( V2 ) > sum2 ( V ) + sum ( trans ( V ) * J * dX ) * t * alpha * 2.0 ) && ( t > t_min ) ) { //Step t bisection t /= 2; //Compute new X2 X2 = X + dX * t; //Reflection into the search space reflection(X2, A, B); //reflection2(X, dX*t, A, B); //Compute new V matrix: do not change parameters in one iteration step function_v ( X2, Y2, V2, W, false ); } //Compute new X using back-step method X = X + dX * t; //Reflection into the search space reflection(X, A, B); //reflection2(X, dX, A, B); //Compute new V matrix and residual matrix V function_v ( X, Y, V, W, true ); //Compute new J matrix function_j ( X, J ); //X.print(); //Compute new residuals and gradient G_new = trans(J) * W * V; fx_new = norm( trans(V) * W * V ); //if (iterations >= 100) break; //Terminal condition if ((norm(G) < max_error) || (fabs(fx_new - fx) < 1.0 * max_diff * std::min(1.0, fx)) || (fx < max_error)) { break; } //Compute selection criterium const T df = ( fx - fx_new ) / fx; //Compute Hessian matrix as H=J*W*J (Gauss-Newton) if ( df > nu ) { H_new = trans ( J ) * W * J; } //Compute Hessian matrix from BFGS else { //Compute solution difference Matrix <T> s = dX * t; //Compute gradient difference Matrix <T> y = G_new - G; //Compute denominators const T ys = sum ( trans( y ) * s ); const T shs = sum ( trans( s ) * H * s); //Compute update, if y * s > 0 (symmetric positive definite update) if (ys > 0) { Matrix <T> dH(n, n); if (fabs(ys) > MIN_FLOAT && fabs(shs) > MIN_FLOAT) { dH += y * trans(y) / ys - H * s * trans(H * s) / shs; } //Compute Hessian matrix using quasi-Newton update: H = J*W*J + dH H_new = trans(J) * W * J + dH; } //Do not update, if y * s < = 0 else H_new = trans(J) * W * J; } //Assign values H = H_new; G = G_new; fx = fx_new; //Test Matrix <T> X0(7, 1); //ECK5 /* X0(0, 0) = 6378.0; X0(1, 0) = 90.0000000; X0(2, 0) = 0.0000000; X0(3, 0) = 50.0000000; X0(4, 0) = 0.0000085; X0(5, 0) = 1.0000000; X0(6, 0) = 90.0; */ //EQDC /* X0(0, 0) = 6378.0; X0(1, 0) = 90.0000000; X0(2, 0) = 0.0000000; X0(3, 0) = 50.0000000; X0(4, 0) = 24.263880643; X0(6, 0) = 108.587213657; //LAEA /* X0(0, 0) = 6378.0; X0(1, 0) = 52.0000000; X0(2, 0) = 10.0000000; X0(3, 0) = 0.0000000; X0(4, 0) = 0.0000085; X0(5, 0) = 1.0000000; X0(6, 0) = 90.0; */ /* //Merc X0(0, 0) = 6378.0; X0(1, 0) = 0.0000000; X0(2, 0) = -90.9120171; X0(3, 0) = 47.0000000; X0(4, 0) = 0; X0(5, 0) = 1.0000000; X0(6, 0) = -90.0; */ //Sinusoidal /* X0(0, 0) = 6378.0; X0(1, 0) = 90.0000000; X0(2, 0) = 0.0000000; X0(3, 0) = 50.0000000; X0(4, 0) = 0.0000085; X0(5, 0) = 1.0000000; X0(6, 0) = 90.0; */ //Werner-Staab /* X0(0, 0) = 6378.0; X0(1, 0) = 90.0000000; X0(2, 0) = 0.0000000; X0(3, 0) = 0.0000000; X0(4, 0) = 0.0000085; X0(5, 0) = 1.0000000; X0(6, 0) = 90.0; */ Matrix <T> RES = trans(V)*W*V; T dx = 0; if (X.rows() == 7) { dx = norm(X - X0) / norm(X0)*100.0; } else { //Matrix <T> XX = } //X.print(output); //dX.print(output); //dX.print(); //RES.print(output);*/ //*output << dx << '\n'; //*output << RES(0, 0) << '\n'; } //Compute final values in V function_v ( X, Y, V, W ); std::cout << "iter:" << iterations << '\n'; return norm ( trans ( V ) * W * V ) ; } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::LM(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T nu1, const T nu2, const T nu3, const T gamma1, const T gamma2, const T lambda_min, const T lambda_max, const T max_error, const unsigned short max_iterations, const T max_diff, T lambda, std::ostream * output) { //Solving non Linear Least Squares with using the current Levenberq-Marquard algorithm //The original version with the Cauchy point initialization //Algorithm by Jorge Nocedal T cost_old = MAX_FLOAT; //Set iterations to 0 iterations = 0; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J(m, n), dX(n, 1), I(n, n, 0.0, 1.0); //Initialize matrices Matrix <T> Y2 = Y, V2 = V, W2 = W, J2 = J; //Compute initial V matrix (residuals) function_v(X, Y, V, W); //Compute initial J matrix function_j(X, J); //Compute matrices Matrix <T> H = trans(J) * W * J; Matrix <T> G = trans(J) * W * V; Matrix <T> F = trans(V) * W * V * 0.5; Matrix <T> G2 = trans(G) * H * G; //Compute �nitial parameters T ng = norm(G); //lambda = 0.001 * ng; //lambda = std::max(norm(trans(G) * G) / norm(trans(G) * H * G), 0.001); //T lambda = 0.01 *max ( diag ( H ) ); Matrix <T> GB = trans(G) * H * G; //T lambda = std::max(1.0, ng * ng / fabs(GB(0, 0))); //lambda = 30 * ng; //lambda = 3000000; //Perform iterations while (iterations < max_iterations) { //Increment iterations iterations++; //Compute Minimum Weighteed Least Squares using qr decomposition dX = pinv1(H + I * lambda) * G * (-1.0); //dX.print(); //Compute new trial X //Matrix <T> X2 = X + dX; Matrix <T> X2 = addStep(X, dX, A, B); //Reflection into the search space reflection(X2, A, B); //Compute new V matrix and residual matrix V function_v(X2, Y2, V2, W2); //Compute new J matrix function_j(X2, J2); //Compute dQ: model function Matrix <T> dQM = trans(dX) * H * dX * 0.5 + trans(G) * dX; const T dQ = -dQM(0, 0); //Compute dF const Matrix <T> F2 = trans(V2) * W2 * V2 * 0.5; const T dF = F(0, 0) - F2(0, 0); const T rho = dF / dQ; //std::cout << "nu1= " << nu1 << " nu2= " << nu2 << " gam1 = " << gamma1 << " gam2=" << gamma2 << " lmin=" << lambda_min << " l_max=" << lambda_max << '\n'; //dX.print(); //std::cout << "rho=" << rho; //std::cout << lambda << " "; //Terminal condition if ((norm(G) < max_error) || (fabs(F2(0, 0) - F(0, 0)) < 1.0 * max_diff * std::max(1.0, F(0, 0))) || (F(0, 0) < max_error)) break; //Worse agrrement between the model and functi, decrease lambda if (rho < nu1) { lambda = std::min(lambda * gamma1, lambda_max); } //Good agreement between the model and function, increase lambda else if (rho > nu2) { lambda = std::max(lambda * gamma2, lambda_min); } //Accept the step if (rho > nu3) { //Accept the trial solution X = X2; //Update solution F = F2; J = J2; V = V2; W = W2; //Actualize matrices H = trans(J) * W * J; G = trans(J) * W * V; ng = norm(G); } //X2.print(); //X2.print(output); } //Compute final values in V function_v(X, Y, V, W); //X.print(); //std::cout << "residuals"; //V.print(); //X.print(output); //Return squares of residuals return norm(trans(V) * W * V); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::TR(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T nu1, const T nu2, const T nu3, const T gamma1, const T gamma2, const T delta_min, const T delta_max, const T max_error, const unsigned short max_iterations, const T max_diff, T delta, std::ostream * output) { //Solving non Linear Least Squares with using the trust region algorithm //Lambda solved using the More-Sorensen method //Algorithm by Conn T cost_old = MAX_FLOAT; //Set iterations to 0 iterations = 0; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J(m, n), dX(n, 1), I(n, n, 0.0, 1.0); //Initialize matrices Matrix <T> Y2 = Y, V2 = V, W2 = W, J2 = J; //Reflection into the search space reflection(X, A, B); //Compute initial V matrix (residuals) function_v(X, Y, V, W); //Compute initial J matrix function_j(X, J); //Compute matrices Matrix <T> H = trans(J) * W * J; Matrix <T> G = trans(J) * W * V; Matrix <T> F = trans(V) * W * V * 0.5; Matrix <T> G2 = trans(G) * H * G; //Compute �nitial parameters T ng = norm(G); //Initialize trust region size //T delta = 0.00001 * ng; //T delta = 30 * ng; Matrix <T> GB = trans(G) * H * G; //T delta = std::max(15000.0, ng * ng / fabs(GB(0, 0))); //T delta = std::max(10.0, ng * ng / fabs(GB(0, 0))); // //delta = 3000000; //delta = 0.001 * ng; std::cout << ng << " "; //delta = 10000; //Perform iterations while (iterations < max_iterations) { //Increment iterations iterations++; //Compute optimal step inside the trust region dX = optTRStep2(J, V, W, delta, 0.2 * max_iterations); //dX.print(); //Compute new trial X Matrix <T> X2 = X + dX; //Matrix <T> X2 = addStep(X, dX, A, B); //Reflection into the search space reflection(X2, A, B); //Matrix <T> dX2 = X2 - X; //bool out = false; //if (norm(dX - dX2) > 0.1) // out = true; //Compute new V matrix and residual matrix V function_v(X2, Y2, V2, W2); //Compute new J matrix function_j(X2, J2); //X2.print(); //Compute new residuals const Matrix <T> F2 = trans(V2) * W2 * V2 * 0.5; //Terminal condition if ((norm(G) < max_error) || (fabs(F2(0, 0) - F(0, 0)) < 1.0 * max_diff * std::max(1.0, F(0, 0))) || (F(0, 0) < max_error)) break; //Compute dQ: model function Matrix <T> dQM = trans(dX) * H * dX * 0.5 + trans(G) * dX; const T dQ = -dQM(0, 0); //Compute dF const T dF = F(0, 0) - F2(0, 0); const T rho = dF / dQ; //std::cout << "F = " << F(0, 0) << " FN = " << F2(0, 0) << " dQ = " << dQ << '\n'; //std::cout << "rho = " << rho << '\n'; //Norm of the gradient to asses the new solution const T ndx = norm(dX); //Bad estimation of nu const T gdx = norm(trans(G) * dX); const T numer = (1 - 0.9) * gdx; const T denom = (1 - 0.9) * (F(0, 0) + gdx + 0.9 * (F(0, 0) + norm(dQM)) - F2(0, 0)); const T nu_bad = numer / denom; //Accept the step if (rho >= 0.01 ) { //Accept the trial solution X = X2; //Update solution F = F2; J = J2; V = V2; W = W2; //Actualize matrices H = trans(J) * W * J; G = trans(J) * W * V; ng = norm(G); } //std::cout << "F=" << F(0, 0) << " F2=" << F2(0, 0) << " Rho = " << rho << " Delta = " << delta << '\n'; /* //Terrible agreemenat of the model and function, rapidly shrink the trust region if (rho < 0 || out) { //std::cout << "minus "; //std::cout << delta; delta = std::min(0.25 * ndx, std::max(0.0625, nu_bad)* delta); //std::cout << " " << delta << '\n'; } else */ //Worse agreement of the model and function shrink the trust region if (rho < 0.01 ) { delta = 0.25 * ndx; } //Good agreement of the model and function, expand the trust region else if (rho > 0.9 ) { delta = std::max(gamma2 * ndx, delta); } //X.print(); //X2.print(output); } //Compute final values in V function_v(X, Y, V, W); //X.print(); //std::cout << "cost = " << F(0, 0); //V.print(); //X.print(output); //Return squares of residuals return norm(trans(V) * W * V); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::TR2(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T nu1, const T nu2, const T nu3, const T gamma1, const T gamma2, const T delta_min, const T delta_max, const T max_error, const unsigned short max_iterations, const T max_diff, T delta, std::ostream * output) { //Solving non Linear Least Squares with using the trust region algorithm //Lambda solved using the More-Sorensen method //Algorithm by Conn T cost_old = MAX_FLOAT; //Set iterations to 0 iterations = 0; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J(m, n), dX(n, 1), I(n, n, 0.0, 1.0); //Initialize matrices Matrix <T> Y2 = Y, V2 = V, W2 = W, J2 = J; //Compute initial V matrix (residuals) function_v(X, Y, V, W); //Compute initial J matrix function_j(X, J); //Compute matrices Matrix <T> H = trans(J) * W * J; Matrix <T> G = trans(J) * W * V; Matrix <T> F = trans(V) * W * V * 0.5; Matrix <T> G2 = trans(G) * H * G; //Compute �nitial parameters T ng = norm(G); //Initialize trust region size //T delta = 30 * ng; Matrix <T> GB = trans(G) * H * G; //T delta = std::max(100.0, ng * ng / fabs(GB(0, 0))); delta = 10000; //Perform iterations unsigned short l = 0; T fmin = F(0, 0), fr = F(0, 0), fc = F(0, 0), sigma_r = 0, sigma_c = 0; while (iterations < max_iterations) { //Increment iterations iterations++; //Compute optimal step inside the trust region dX = optTRStep2(J, V, W, delta, 0.2 * max_iterations); // dX.print(); //Compute new trial X //Matrix <T> X2 = X + dX; Matrix <T> X2 = addStep(X, dX, A, B); //Reflection into the search space //reflection(X2, A, B); //Compute new V matrix and residual matrix V function_v(X2, Y2, V2, W2); //Compute new J matrix function_j(X2, J2); //X2.print(); //Compute new residuals const Matrix <T> F2 = trans(V2) * W2 * V2 * 0.5; //Terminal condition if ((norm(G) < max_error) || (fabs(F2(0, 0) - F(0, 0)) < 1.0 * max_diff * std::max(1.0, F(0, 0))) || (F(0, 0) < max_error)) break; //Compute dF const T dFh = fr - F2(0, 0); const T dFc = F(0,0) - F2(0, 0); //Compute dQ: model function Matrix <T> dQM = trans(dX) * H * dX * 0.5 + trans(G) * dX; const T dQ = -dQM(0, 0); //Compute Rho const T rho_h = dFh / ( dQ + sigma_r); const T rho_c = dFc / dQ; const T rho = std::max(rho_h, rho_c); //std::cout << "F = " << F(0, 0) << " FN = " << F2(0, 0) << " dQ = " << dQ << '\n'; //std::cout << "rho = " << rho << '\n'; //Accept the step if (rho >= 0.01) { //Accept the trial solution X = X2; //Update sigma sigma_c += dQ; sigma_r += dQ; //Update solution F = F2; J = J2; V = V2; W = W2; //Actualize matrices H = trans(J) * W * J; G = trans(J) * W * V; ng = norm(G); //Update the best value if (F2(0, 0) < fmin) { fc = F2(0, 0); fmin = F2(0, 0); sigma_c = 0; l = 0; } else { l++; //Update the candidate if (F2(0, 0) > fc) { fc = F2(0, 0); sigma_c = 0; } //Reset the reference value if (l == 45) { fr = fc; sigma_r = sigma_c; } } } //Norm of the gradient to asses the new solution const T ndx = norm(dX); //Bad estimation of nu const T gdx = norm(trans(G) * dX); const T numer = (1 - 0.9) * gdx; const T denom = (1 - 0.9) * (F(0, 0) + gdx + 0.9 * (F(0, 0) + norm(dQM)) - F2(0, 0)); const T nu_bad = numer / denom; //std::cout << "F=" << F(0, 0) << " F2=" << F2(0, 0) << " Rho = " << rho << " Delta = " << delta << '\n'; /* //Terrible agreemenat of the model and function, rapidly shrink the trust region if (rho < 0) { //std::cout << "minus "; //std::cout << delta; delta = std::min(0.25 * ndx, std::max(0.0625, nu_bad)* delta); //std::cout << " " << delta << '\n'; } //Worse agreement of the model and function shrink the trust region else */ if (rho < 0.01) { delta = 0.25 * ndx; } //Good agreement of the model and function, expand the trust region else if (rho > 0.9) { delta = std::max(gamma2 * ndx, delta); } //X.print(); //X2.print(output); } //Compute final values in V function_v(X, Y, V, W); //X.print(); //std::cout << "cost = " << F(0, 0); //V.print(); //X.print(output); //Return squares of residuals return norm(trans(V) * W * V); } template <typename T, typename FunctionJ, typename FunctionV, typename FunctionC> T NonLinearLeastSquares::TR3(FunctionJ function_j, FunctionV function_v, FunctionC function_c, Matrix <T> &W, Matrix <T> &X, Matrix <T> &Y, Matrix <T> &V, const Matrix <T> &A, const Matrix <T> &B, unsigned short &iterations, const T nu1, const T nu2, const T nu3, const T gamma1, const T gamma2, const T delta_min, const T delta_max, const T max_error, const unsigned short max_iterations, const T max_diff, T delta, std::ostream * output) { //Solving non Linear Least Squares with using the trust region algorithm //Lambda solved using the More-Sorensen method //Algorithm by Conn T cost_old = MAX_FLOAT; //Set iterations to 0 iterations = 0; //Create matrices const unsigned short m = W.rows(), n = X.rows(); Matrix <T> J(m, n), dX(n, 1), I(n, n, 0.0, 1.0); //Initialize matrices Matrix <T> Y2 = Y, V2 = V, W2 = W, J2 = J; //Compute initial V matrix (residuals) function_v(X, Y, V, W); //Compute initial J matrix function_j(X, J); //Compute matrices Matrix <T> H = trans(J) * W * J; Matrix <T> G = trans(J) * W * V; Matrix <T> F = trans(V) * W * V * 0.5; Matrix <T> G2 = trans(G) * H * G; //Compute �nitial parameters T ng = norm(G); //Initialize trust region size delta = 3000 * ng; Matrix <T> GB = trans(G) * H * G; //delta = std::max(10.0, ng * ng / fabs(GB(0, 0))); //std::cout << "ng = " << ng; //delta = 300000000; //Perform iterations T rho_old = 0; unsigned short j = 0; while (iterations < max_iterations) { //Increment iterations iterations++; //Compute optimal step inside the trust region dX = optTRStep2(J, V, W, delta, 0.2 * max_iterations); //dX.print() //Compute new trial X //Matrix <T> X2 = X + dX; Matrix <T> X2 = addStep(X, dX, A, B); //Reflection into the search space //reflection(X2, A, B); //Compute new V matrix and residual matrix V function_v(X2, Y2, V2, W2); //Compute new J matrix function_j(X2, J2); //X2.print(); //Compute new residuals Matrix <T> F2 = trans(V2) * W2 * V2 * 0.5; //Terminal condition if ((norm(G) < max_error) || (fabs(F2(0, 0) - F(0, 0)) < 1.0 * max_diff * std::max(1.0, F(0, 0))) || (F(0, 0) < max_error)) break; //Compute dQ: model function Matrix <T> dQM = trans(dX) * H * dX * 0.5 + trans(G) * dX; const T dQ = -dQM(0, 0); //Compute dF const T dF = F(0, 0) - F2(0, 0); T rho = dF / dQ; //std::cout << "F = " << F(0, 0) << " FN = " << F2(0, 0) << " dQ = " << dQ << '\n'; //std::cout << "rho = " << rho << '\n'; if ((rho >= 0.9) && (rho_old >= 0.9)) { bool cont_iter = true; //Assign step and trust region size Matrix <T> dXj1 = dX; T deltaj1 = delta; T rho_max = 0; while (cont_iter) { Matrix <T> Y2j = Y, V2j = V, W2j = W, J2j = J, F2j = F2; //Actualize size of the trust region const T deltaj = 2.0 * deltaj1; //Compute new trust region step Matrix <T> dXj = optTRStep2(J, V, W, deltaj, 0.2 * max_iterations); //Create new trial point //Matrix <T> X2j = X + dXj; Matrix <T> X2j = addStep(X, dXj, A, B); //Reflection into the search space //reflection(X2j, A, B); //X2j.print(); //Compute new V matrix and residual matrix V function_v(X2j, Y2j, V2j, W2j); //Compute new J matrix function_j(X2j, J2j); //X2.print(); //Compute new residuals F2j = trans(V2j) * W2j * V2j * 0.5; //Compute new rho Matrix <T> dQMj = trans(dXj) * H * dXj * 0.5 + trans(G) * dXj; const T dQj = -dQMj(0, 0); //Compute dF const T dFj = F(0, 0) - F2j(0, 0); const T rhoj = dFj / dQj; //Accept the step, update values //if (rhoj >= rho_max) if (rhoj >= 0.01) { rho_max = rhoj; //Assign determined parameters dX = dXj; rho = rhoj; delta = deltaj; X2 = X2j; F2 = F2j; J2 = J2j; V2 = V2j; W2 = W2j; } //Continue with iterations cont_iter = (rhoj >= 0.9) && (norm(dXj) > norm(dXj1)); //Assign old values dXj1 = dXj; deltaj1 = deltaj; } } //Norm of the gradient to asses the new solution const T ndx = norm(dX); //Bad estimation of nu const T gdx = norm(trans(G) * dX); const T numer = (1 - 0.9) * gdx; const T denom = (1 - 0.9) * (F(0, 0) + gdx + 0.9 * (F(0, 0) + norm(dQM)) - F2(0, 0)); const T nu_bad = numer / denom; //Accept the step if (rho >= 0.01) { //Accept the trial solution X = X2; //Update solution F = F2; J = J2; V = V2; W = W2; //Actualize matrices H = trans(J) * W * J; G = trans(J) * W * V; ng = norm(G); } //std::cout << "F=" << F(0, 0) << " F2=" << F2(0, 0) << " Rho = " << rho << " Delta = " << delta << '\n'; /* //Terrible agreemenat of the model and function, rapidly shrink the trust region if (rho < 0) { //std::cout << "minus "; //std::cout << delta; delta = std::min(0.25 * ndx, std::max(0.0625, nu_bad)* delta); //std::cout << " " << delta << '\n'; } //Worse agreement of the model and function shrink the trust region else */ if (rho < 0.01) { delta = 0.25 * ndx; } //Good agreement of the model and function, expand the trust region else if (rho > 0.9) { delta = std::max(gamma2 * ndx, delta); } //Assign rho rho_old = rho; //X.print(); //X2.print(output); } //Compute final values in V function_v(X, Y, V, W); //X.print(); //std::cout << "cost = " << F(0, 0); //V.print(); //X.print(output); //Return squares of residuals return norm(trans(V) * W * V); } template <typename T> Matrix <T> NonLinearLeastSquares::optTRStep(const Matrix <T> &J, const Matrix <T> &V, const Matrix <T> &W, const T delta, const T max_iter, const T max_error) { //More-Sorensen method: determine optimal trust region step //Algorithm by L. Luksan unsigned short iterations = 0; const unsigned short n = J.cols(); bool stop = false; //Determined step inside the trust region Matrix <T> s(n, 1), I(n, n, 0.0, 1.0), L(n, n), d(n, 1), e(n, 1), v(n, 1); //Parameters of the algorithm const T beta_min = 0.001, delta_min = 0.9, delta_max = 1.1; //Compute initial matrices const Matrix <T> B = trans(J) * W * J; const Matrix <T> G = trans(J) * W * V; //Eigenvalues decomposition Matrix <T> EV(n, n, 0, 1), EL(n, 1); eig(B, EV, EL); //Get the smalles and largest eigenvalues const T l_min = EL(0, 0); const T l_max = EL(n - 1, 0); //std::cout << "lmax" << l_max; //Initialize bounds for lambda T mju_min = max(diag(B * (-1.0))); T lambda_min = norm(G) / delta - l_max; T lambda_max = norm(G) / delta - l_min; //Initialize lambda T lambda = std::max(0.0, std::max(mju_min, lambda_min)); //Perform iteration while (iterations < max_iter) { //***Trust region, Step 2*** //Set up the threshold lambda_min = std::max(0.0, std::max(mju_min, lambda_min)); if ((lambda <= mju_min) && (iterations > 0)) lambda = std::max(sqrt(lambda_min * lambda_max), lambda_min + beta_min * (lambda_max - lambda_min)); //std::cout << "iter = " << iterations << " lam_min = " << lambda_min << " lam_max = " << lambda_max << " lam = " << lambda << '\n'; //Increment iterations iterations++; //***Trust region, Step 3*** //Gill-Murray decomposition Matrix <double> R(n, n), E(n, n); bool indefinite = false; gill(B + I * lambda, R, E, indefinite); gill(B + I * lambda, L, d, e, v); //Find maximum diagonal element of E const T max_diag_E = max(abs(diag(e))); //If (B + lambda * I) is positive definite diag|E| = 0 if (max_diag_E < 1.0e-3) { trStep4(B, R, s, G, v, lambda_min, lambda_max, lambda, delta_min, delta_max, delta, mju_min, stop); } // (B + lambda * I) is not positive definite: diag|E| != 0 else { //Normalize direction v = v * (1.0 / norm(v)); //Actualize mju_min const Matrix <T> vb = trans(v) * (B + I * lambda) * v; //mju_min = lambda - vb(0, 0); mju_min = std::max(mju_min, lambda - vb(0, 0)); } //std::cout << "iter = " << iterations << " lam = " << lambda << " delta = " << delta << '\n'; //Return results if ( stop ) return s; } return s; } template <typename T> Matrix <T> NonLinearLeastSquares::optTRStep2(const Matrix <T> &J, const Matrix <T> &V, const Matrix <T> &W, const T delta, const T max_iter, const T max_error) { //More-Sorensen method: determine optimal trust region step //Algorithm by L. Luksan unsigned short iterations = 0; const unsigned short n = J.cols(); bool stop = false; //Determined step inside the trust region Matrix <T> s(n, 1), I(n, n, 0.0, 1.0), L(n, n), d(n, 1), e(n, 1), v(n, 1); //Parameters of the algorithm const T beta_min = 0.001, beta_max = 0.999, delta_min = 0.9, delta_max = 1.1; //Compute initial matrices const Matrix <T> B = trans(J) * W * J; const Matrix <T> G = trans(J) * W * V; //Eigenvalues decomposition Matrix < T> EV(n, n, 0, 1), EL(n, 1); eig(B, EV, EL); //Get the smalles and largest eigenvalues const T l_min = EL(0, 0); const T l_max = EL(n - 1, 0); //std::cout << "lmax" << l_max; Matrix <T> SB = sumCols(B); const T max_el = max(SB); //Initialize bounds for lambda T mju_min = max(diag(B * (-1.0))); T lambda_min = norm(G) / delta - max_el; T lambda_max = norm(G) / delta + max_el; //Initialize lambda T lambda = std::max(0.0, std::max(mju_min, lambda_min)); //Perform iteration while (iterations < max_iter) { //***Trust region, Step 2*** Matrix <T> R(n, n); //Set up the threshold lambda_min = std::max(0.0, std::max(mju_min, lambda_min)); //Go to step 3 if ( lambda > mju_min /*|| iterations == 0*/) { trStep32(B, R, s, G, v, lambda_min, lambda_max, lambda, delta_min, delta_max, delta, mju_min, stop); } else if (lambda <= mju_min ) { const T lambda_plus = sqrt(lambda_min * lambda_max); //Upper and lower bound const T lambda_low = lambda_min + beta_min * (lambda_max - lambda_min); const T lambda_high = lambda_min + beta_max * (lambda_max - lambda_min); //Set new value of lambda if (lambda_plus < lambda_low) { lambda = lambda_low; } else if (lambda_plus > lambda_high) { lambda = lambda_high; } else { lambda = lambda_plus; } } //Go to step 3 //trStep32(B, R, s, G, v, lambda_min, lambda_max, lambda, delta_min, delta_max, delta, mju_min, stop); //std::cout << "iter = " << iterations << " lam_min = " << lambda_min << " lam_max = " << lambda_max << " lam = " << lambda << '\n'; //Increment iterations iterations++; //Return results if (stop) return s; } return s; } template <typename T> void NonLinearLeastSquares::trStep32(const Matrix <T> &B, Matrix <T> &R, Matrix <T> &s, const Matrix <T> &G, Matrix <T> &v, T & lambda_min, T &lambda_max, T &lambda, const T delta_min, const T delta_max, const T delta, T &mju_min, bool &stop ) { //Gill-Murray decomposition const unsigned int n = B.rows(); Matrix <T> E(n, n), I(n, n, 0.0, 1.0), L(n, n), d(n, 1), e(n, 1); bool indefinite = false; gill(B + I * lambda, R, E, indefinite); gill(B + I * lambda, L, d, e, v); //Find maximum diagonal element of E const T max_diag_E = max(abs(diag(e))); //If (B + lambda * I) is positive definite diag|E| = 0 if (max_diag_E < 1.0e-3) { trStep42(B, R, s, G, v, lambda_min, lambda_max, lambda, delta_min, delta_max, delta, mju_min, stop); } // (B + lambda * I) is not positive definite: diag|E| != 0 else { //Normalize direction v = v * (1.0 / norm(v)); //Actualize mju_min const Matrix <T> vb = trans(v) * (B + I * lambda) * v; mju_min = lambda - vb(0, 0); //mju_min = std::max(mju_min, lambda - vb(0, 0)); } } template <typename T> void NonLinearLeastSquares::trStep4(const Matrix <T> &B, const Matrix <T> &R, Matrix <T> &s, const Matrix <T> &G, Matrix <T> &v, T & lambda_min, T &lambda_max, T &lambda, const T delta_min, const T delta_max, const T delta, T &mju_min, bool &stop) { //Step 4 of the trust region subproblem //Compute S, so as R'RS + g = 0 //Matrix<T> kkk =B + I *lambda; //kkk.print(); //B.print(); s = inv(trans(R) * R) * G * (-1.0); //R.print(); //S.print(); //S = pinv1(B) * G * (-1.0); //dX.print(); //Actualize lambda, go to Step 6 const T ns = norm(s); if (ns > delta_max * delta) { //Actualize lambda lambda_min = lambda; //Go to step 6 lambda += trStep6(R, s, v, delta); } //Stop computation else if ((delta_min * delta <= ns) && (ns <= delta_max * delta) || (ns < delta_min * delta) && (fabs(lambda) < 0.0001)) { stop = true; } //Eigenvalues decomposition, go to Step 5 else if ((ns < delta_min * delta) && (lambda > 0)) { // Actualize threshold lambda_max = lambda; //Goto step 5 trStep5(B, R, s, v, lambda, delta_min, delta, mju_min, stop); } } template <typename T> void NonLinearLeastSquares::trStep42(const Matrix <T> &B, const Matrix <T> &R, Matrix <T> &s, const Matrix <T> &G, Matrix <T> &v, T & lambda_min, T &lambda_max, T &lambda, const T delta_min, const T delta_max, const T delta, T &mju_min, bool &stop) { //Step 4 of the trust region subproblem //Compute S, so as R'RS + g = 0 //Matrix<T> kkk =B + I *lambda; //kkk.print(); //B.print(); s = pinv1(trans(R) * R) * G * (-1.0); //R.print(); //S.print(); //S = pinv1(B) * G * (-1.0); //dX.print(); //Actualize lambda, go to Step 6 const T ns = norm(s); if (ns > delta_max * delta) { //Actualize lambda lambda_min = lambda; //Go to step 6 trStep62(R, s, G, v, lambda_min, lambda_max, lambda, delta, mju_min); } //Stop computation else if ((delta_min * delta <= ns) && (ns <= delta_max * delta) || (ns < delta_min * delta) && (fabs(lambda) < MIN_FLOAT)) { stop = true; } //Eigenvalues decomposition, go to Step 5 else if ((ns < delta_min * delta) && (lambda > 0)) { // Actualize threshold lambda_max = lambda; //Goto step 5 trStep52(B, R, s, G, v, lambda_min, lambda_max, lambda, delta_min, delta, mju_min, stop); } } template <typename T> void NonLinearLeastSquares::trStep5(const Matrix <T> &B, const Matrix <T> &R, Matrix<T> &s, Matrix<T> &v, T &lambda, const T delta_min, const T delta, T &mju_min, bool &stop) { // Step 5 of the trust region subproblem const unsigned short n = B.cols(); Matrix <T> EV(n, n, 0, 1), EL(n, 1), I(n, n, 0.0, 1.0); //Eigenvalue decomposition //eig(B + I * lambda, EV, EL); //eig(B, EV, EL); eig(B, EV, EL); //Get the smallest eigenvector and norm v = trans(EV(0, 0, 0, n - 1)); v = v * (1.0 / norm(v)); //Compute alpha for vn'*S > 0 const T s2 = norm(s) * norm(s); const T vts = norm(trans(v) * s); std::cout << "vts = " << vts; const T vtsd_sqr = sqrt(vts * vts + delta* delta - s2); const T alpha = (vts <= 0 ? vtsd_sqr - vts : (delta * delta - s2) / (vtsd_sqr + vts)); //Test condition const T rvn2 = norm(R * v) * norm(R * v); const T rs2 = norm(R * s) * norm(R * s); const T l = alpha * alpha * rvn2; const T r = (1 - delta_min * delta_min) * (rs2 + lambda * delta * delta); //Terminate step if (l <= r) { //Actualize S s = s + v * alpha; //Terminate step stop = true; } //Update mju_min and lambda else { //mju_min = lambda - rvn2; mju_min = std::max(mju_min, lambda - rvn2); //Goto Step 6, compute new lambda lambda += trStep6(R, s, v, delta); } } template <typename T> void NonLinearLeastSquares::trStep52(const Matrix <T> &B, const Matrix <T> &R, Matrix<T> &s, const Matrix <T> &G, Matrix<T> &v, const T lambda_min, const T lambda_max, T &lambda, const T delta_min, const T delta, T &mju_min, bool &stop) { // Step 5 of the trust region subproblem const unsigned short n = B.cols(); Matrix <T> EV(n, n, 0, 1), EL(n, 1), I(n, n, 0.0, 1.0); //Eigenvalue decomposition //eig(B + I * lambda, EV, EL); //eig(B, EV, EL); eig(B, EV, EL); //Get the smallest eigenvector and norm v = trans(EV(0, 0, 0, n - 1)); v = v * (1.0 / norm(v)); //Compute alpha for vn'*S > 0 const T s2 = norm(s) * norm(s); const T vts = norm(trans(v) * s); std::cout << "vts = " << vts; const T vtsd_sqr = sqrt(vts * vts + delta* delta - s2); const T alpha = (delta * delta - s2) / (vtsd_sqr + vts); //Test condition const T rvn2 = norm(R * v) * norm(R * v); const T rs2 = norm(R * s) * norm(R * s); const T l = alpha * alpha * rvn2; const T r = (1 - delta_min * delta_min) * (rs2 + lambda * delta * delta); //Terminate step if (l <= r) { //Actualize S s = s + v * alpha; //Terminate step stop = true; } //Update mju_min and lambda else { mju_min = lambda - rvn2; //mju_min = std::max(mju_min, lambda - rvn2); //Goto Step 6, compute new lambda trStep62(R, s, G, v, lambda_min, lambda_max, lambda, delta, mju_min); } } template <typename T> T NonLinearLeastSquares::trStep6(const Matrix <T> &R, const Matrix <T> &s, Matrix<T> &v, const T delta) { // Step 6 of the trust region subproblem v = inv(trans(R)) * s; //Actualize lambda solving the Newton iteration step const T ns = norm(s); const T nv = norm(v); const T s2 = ns * ns; const T v2 = nv * nv; const T d_lambda = s2 / v2 * (norm(s) - delta) / delta; return d_lambda; } template <typename T> void NonLinearLeastSquares::trStep62(const Matrix <T> &R, const Matrix <T> &s, const Matrix <T> &G, Matrix<T> &v, const T lambda_min, const T lambda_max, T &lambda, const T delta, const T mju_min ) { // Step 6 of the trust region subproblem if (norm(G) < 0.000001) { lambda = mju_min; return; } //Compute step v = pinv1(trans(R)) * s; //Actualize lambda solving the Newton iteration step const T ns = norm(s); const T nv = norm(v); const T s2 = ns * ns; const T v2 = nv * nv; const T lambda_plus = lambda + s2 / v2 * (ns - delta) / delta; //Actualize lambda if (lambda_plus < lambda_min) { lambda = lambda_min; } else if (lambda_plus > lambda_max) { lambda = lambda_max; } else { lambda = lambda_plus; } } template <typename T> void NonLinearLeastSquares::reflection(Matrix <T> &X, const Matrix <T> &XMIN, const Matrix <T> &XMAX) { //Reflect elements of vectors into the search space represented by the n-dimensional cuboid const unsigned int n = X.rows(); const T max_multiplier = 100; for (unsigned int i = 0; i < n; i++) { //int iter = 0; //Process each element of the vector while ((X(i, 0) < XMIN(i, 0)) || (X(i, 0) > XMAX(i, 0))) { //std::cout << X(i, 0) << " "; //XMIN == XMAX if (XMAX(i, 0) - XMIN(i, 0) < MAX_FLOAT_OPER_ERROR) { X(i, 0) = XMIN(i, 0); break; } //Left form the lower bound else if (X(i, 0) > XMAX(i, 0)) { X(i, 0) = 2 * XMAX(i, 0) - X(i, 0); } //Right to the upper bound else if (X(i, 0) < XMIN(i, 0)) { X(i, 0) = 2 * XMIN(i, 0) - X(i, 0); } } } } template <typename T> void NonLinearLeastSquares::reflection2(Matrix <T> &X, Matrix <T> &dX, const Matrix <T> &XMIN, const Matrix <T> &XMAX) { //Reflect elements of vectors into the search space represented by the n-dimensional cuboid const unsigned int n = X.rows(); T beta = 1.0; for (int i = 0; i < n; i++) { //Denominator const T den = std::max(fabs(dX(i, 0)), 0.0000001); if (X(i, 0) + dX(i, 0) > XMAX(i, 0)) { const T beta_max = fabs((XMAX(i, 0) - X(i, 0)) / den); beta = std::min(beta, min(beta_max, 1.0)); std::cout << "beta_max = " << beta_max << '\n'; } else if (X(i, 0) + dX(i, 0) < XMIN(i, 0)) { const T beta_min = fabs((XMIN(i, 0) - X(i, 0)) / den); beta = std::min(beta, min(beta_min, 1.0)); std::cout << "beta_min = " << beta_min << '\n'; } //std::cout << "beta_min = " << beta_min << " " << "beta_max" <<beta_max << '\n'; //beta = std::min(beta, min(min(beta_min, beta_max), 1.0)); } dX = dX * beta; std::cout << "beta = " << beta << '\n'; } template <typename T> void NonLinearLeastSquares::reflection3(Matrix <T> &X, Matrix <T> &dX, const Matrix <T> &XMIN, const Matrix <T> &XMAX) { //Reflect elements of vectors into the search space represented by the n-dimensional cuboid const unsigned int n = X.rows(); Matrix <T> beta(n, 1, 1); for (int i = 0; i < n; i++) { //Denominator const T den = std::max(fabs(dX(i, 0)), 0.0000001); if (X(i, 0) + dX(i, 0) > XMAX(i, 0)) { const T beta_max = fabs((XMAX(i, 0) - X(i, 0)) / den); beta (i, 0) = 0.25 * min(beta_max, 1.0); std::cout << "beta_max = " << beta_max << '\n'; } else if (X(i, 0) + dX(i, 0) < XMIN(i, 0)) { const T beta_min = fabs((XMIN(i, 0) - X(i, 0)) / den); beta(i, 0) = 0.25 * min(beta_min, 1.0); std::cout << "beta_min = " << beta_min << '\n'; } //std::cout << "beta_min = " << beta_min << " " << "beta_max" <<beta_max << '\n'; //beta = std::min(beta, min(min(beta_min, beta_max), 1.0)); } dX = dX % beta; //std::cout << "beta = " << beta << '\n'; } /* template <typename T> void NonLinearLeastSquares::reflection(Matrix <T> &X, const Matrix <T> &XMIN, const Matrix <T> &XMAX) { //Reflect elements of vectors into the search space represented by the n-dimensional cuboid const unsigned int n = X.rows(); const T max_multiplier = 100; for (unsigned int i = 0; i < n; i++) { //int iter = 0; //Process each element of the vector while ((X(i, 0) < XMIN(i, 0)) || (X(i, 0) > XMAX(i, 0))) { //std::cout << X(i, 0) << " "; //XMIN == XMAX if (XMAX(i, 0) - XMIN(i, 0) < MAX_FLOAT_OPER_ERROR) { X(i, 0) = XMIN(i, 0); break; } //Left form the lower bound else if (X(i, 0) > XMAX(i, 0)) { //X(i) too far from the upper bound (due to the pseudoinverse) if (X(i, 0) - XMAX(i, 0) > max_multiplier * (XMAX(i, 0) - XMIN(i, 0))) { X(i, 0) = 2 * XMAX(i, 0) - fmod(X(i, 0), XMAX(i, 0) - XMIN(i, 0)); } //X(i) close to the upper bound else { X(i, 0) = 2 * XMAX(i, 0) - X(i, 0); } } //Right to the upper bound else if (X(i, 0) < XMIN(i, 0)) { //X(i) too far from the lower bound (due to the pseudoinverse) if (XMIN(i, 0) - X(i, 0) > max_multiplier * (XMAX(i, 0) - XMIN(i, 0))) { X(i, 0) = 2 * XMIN(i, 0) - fmod(X(i, 0), XMAX(i, 0) - XMIN(i, 0)); } //X(i) close to the lower bound else { X(i, 0) = 2 * XMIN(i, 0) - X(i, 0); } } } } } */ /* template <typename T> void NonLinearLeastSquares::reflection(Matrix <T> &X, const Matrix <T> &A, const Matrix <T> &B) { //Reflection into the search space const unsigned int n = X.rows(); const T eps = 1.0e-5; //Reflect elements of vectors into the search space represented by the n-dimensional cuboid for (unsigned int i = 0; i < n; i++) { if ((A(i, 0) < B(i, 0)) && ( X(i, 0) < A(i, 0))) { double x = X(i, 0); double rem = fmod(x - A(i, 0), (B(i, 0) - A(i, 0))) - A(i, 0); if (i > 0 && rem < -180) std::cout << "error" << x << " " << rem << " " << A(i, 0) << " " << B(i, 0) << '\n'; X(i, 0) = fmod(X(i, 0) - A(i, 0), (B(i, 0) - A(i, 0))) - A(i, 0); } else if ( (A(i, 0) < B(i, 0)) && (X(i, 0) > B(i, 0))) { double x = X(i, 0); double rem = fmod(x - B(i, 0), (B(i, 0) - A(i, 0))) - B(i, 0); if (i > 0 && rem > 180) std::cout << "error" << x << " " << rem << " " << A(i, 0) << " " << B(i, 0) << '\n'; X(i, 0) = fmod(X(i, 0) - B(i, 0), (B(i, 0) - A(i, 0))) - B(i, 0); } } } */ template <typename T> bool NonLinearLeastSquares::checkIntervals(Matrix <T> &X, const Matrix <T> &A, const Matrix <T> &B) { //Reflection into the search space const unsigned int n = X.rows(); //Reflect elements of vectors into the search space represented by the n-dimensional cuboid for (unsigned int i = 0; i < n; i++) { //Check, if item is inside the search space if ((A(i, 0) < B(i, 0)) && (X(i, 0) < A(i, 0) || X(i, 0) > B(i, 0))) { return false; } } return true; } template <typename T> Matrix <T> NonLinearLeastSquares::addStep(const Matrix <T> &X, const Matrix <T> &dX, const Matrix <T> &A, const Matrix <T> &B) { //Add steps, elements ouside the interval are replaced with the maximum value unsigned int n = X.rows(); Matrix <T> X2 = X; for ( unsigned int i = 0; i < n; i++) { //Inside the interval if ((X(i, 0) + dX(i, 0) >= A(i, 0)) && (X(i, 0) + dX(i, 0) <= B(i, 0))) { X2(i, 0) = X(i, 0) + dX(i, 0); } //Bellow the lower bound else if (X(i, 0) + dX(i, 0) < A(i, 0)) { X2(i, 0) = A(i, 0); } //Over the upper bound else if ( X(i, 0) + dX(i, 0) > B(i, 0)) { X2(i, 0) = B(i, 0); } } return X2; } #endif
[ "bayertom@natur.cuni.cz" ]
bayertom@natur.cuni.cz
8a489731b422d2800efda1a171e8639215045417
ef4c9e8d6a97a8c3ce6a4191a81b168c27e03dde
/AutoList.cpp
4eff7b34765f13d249e0b9a11d2d046ae9aa22ca
[]
no_license
cdecl/GlassFTP
74d0b727b37c537dd76ef1e884df8ad8000f9c33
7f20f86a174d4ff25764d9a95548847272c93f73
refs/heads/master
2021-01-20T10:15:32.040208
2018-01-09T03:43:21
2018-01-09T03:43:21
26,073,086
5
0
null
null
null
null
UTF-8
C++
false
false
1,165
cpp
// AutoList.cpp: implementation of the CAutoList class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "glassftp.h" #include "AutoList.h" #include <iterator> #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CAutoList::CAutoList() { _v.reserve(30); } CAutoList::~CAutoList() { } void CAutoList::Reset(const CString &strExtList) { const char FD = ';'; CTokens Token((LPCSTR)strExtList); _v.clear(); while (!Token.IsEOF()) { _v.push_back(LowerCase(Token.GetNextWord(FD))); } } BOOL CAutoList::IsExistsAscFile(const CString &strExt) { if (strExt.IsEmpty()) { return FALSE; } ExtList::iterator it = std::find(_v.begin(), _v.end(), LowerCase(static_cast<LPCSTR>(strExt))); return (it == _v.end()) ? FALSE : TRUE; } std::string CAutoList::LowerCase(const std::string &str) { std::string s; transform(str.begin(), str.end(), std::back_inserter(s), tolower); return s; }
[ "cdeclare@gmail.com" ]
cdeclare@gmail.com
b92ef3cb4daf88393881f136b370e04534ccd834
a8895974e5aac4b6746733ba97cdf6e0846d044d
/libs/cocos2dx/support/ccUtils.h
81088a7971ec4e1bfb37b327c2cfa370eaf86433
[]
no_license
51anygo/mybird
b9260cb3b7e5cb14302d5115196be9f0b19de3af
71e9375e81ecce4fa8b8ae69195ae416f1da5dc4
refs/heads/master
2020-05-16T11:16:19.561900
2014-04-10T12:53:51
2014-04-10T12:53:51
17,505,897
1
1
null
null
null
null
UTF-8
C++
false
false
1,782
h
/**************************************************************************** Copyright (c) 2010 cocos2d-x.org http://www.cocos2d-x.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #ifndef __SUPPORT_CC_UTILS_H__ #define __SUPPORT_CC_UTILS_H__ /** @file ccUtils.h Misc free functions */ namespace cocos2d { /* ccNextPOT function is licensed under the same license that is used in CCTexture2D.m. */ /** returns the Next Power of Two value. Examples: - If "value" is 15, it will return 16. - If "value" is 16, it will return 16. - If "value" is 17, it will return 32. @since v0.99.5 */ unsigned long ccNextPOT( unsigned long value ); } #endif // __SUPPORT_CC_UTILS_H__
[ "51anygo@gmail.com" ]
51anygo@gmail.com
f9aed6c4201e2e3f0a08725d760ebfa9e15462e4
c498f2054ffe06ea73dfb22960c0d98cbe9c1177
/main.cpp
5095344543dfc87f1771a0f8e72cbb4c24391afe
[]
no_license
sergiev/Newton
692a3bc4ecb7bdf8fef0407e5507f7b24b9517b4
098873374e40897c028eec744603bf6184c24946
refs/heads/master
2020-03-17T01:14:20.747956
2018-05-12T12:43:16
2018-05-12T12:43:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,472
cpp
#include "refers.h" int main() { double current=1; int k=1; while (1) { double next=current-f(current)/df(current); if (abs(next-current)<EPS) { cout << next << " - это минимальный по модулю корень уравнения tg(x)=cos(x)-0.1\n"; cout<<tan(next)-cos(next)+0.1<<'\n'; break; } current=next; cout<<"Итерация "<<k++<<": x="<<next<<'\n'; } cout<<"\nПереходим ко второй задаче - решить систему уравнений:\n2x-cos(y+1)-y=0\ny+sin(x)=-0.4\n"; vector<vector<double>> lp(2,vector<double>(2));//коэффициенты левой части vector<double> rp(2),curr(2),next(2); curr={0,-0.5}; k=1; while(1) { lp[0][0]=2;lp[0][1]=sin(curr[1]+1)-1; lp[1][0]=cos(curr[0]);lp[1][1]=1; /*rp[0]=curr[1]*(sin(curr[1]+1))+cos(curr[1]+1); rp[1]=-0.4+curr[0]*cos(curr[0])-sin(curr[0]);*/ rp[0]=-2*curr[0]+cos(curr[1]+1)+curr[1]; rp[1]=-curr[1]-sin(curr[0])-0.4; next=sum(curr,gMethod(lp,rp)); if (norma(next,curr)<EPS) break; curr=next; cout<<"Итерация "<<k++<<": "<<"x="<<curr[0]<<" y="<<curr[1]<<'\n'; } cout<<"Корень: "<<"x="<<next[0]<<" y="<<next[1]<<'\n'; cout<<"f1(x,y)="<<2*next[0]-cos(next[1]+1)-next[1]; cout<<"\nf2(x,y)="<<next[1]+sin(next[0])+0.4; return 0; }
[ "semyonsever@yandex.ru" ]
semyonsever@yandex.ru
4915b51fce09e21160c073d07d308adaa25b712d
3b9d63ae526e70264592ec1098b7f39d168324dd
/Source/Sound/Mixer.cpp
e7afcec8da59c05464986324dc827af6997fa910
[ "BSD-3-Clause" ]
permissive
devnello/RaspiDrums
de7d70c76b30efd1d3611707f5c45b3d45a4b16f
b4c6856bafbbc6520fc753232ff9e14359a25937
refs/heads/master
2021-09-15T13:06:12.201342
2018-06-02T20:30:11
2018-06-02T20:30:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,356
cpp
/* * Mixer.cpp * * Created on: 11 Apr 2015 * Author: jeremy */ #include "Mixer.h" namespace Sound { Mixer::Mixer(const std::vector<DrumKit::SoundParams>& soundParams, const AlsaParams& params) : soundParameters(soundParams), alsaParams(params) { return; } Mixer::~Mixer() { return; } void Mixer::AddToMixer(int id, float volume) { // Prevent other threads to alter the soundList vector std::lock_guard<std::mutex> lock(mixerMutex); /* * Not needed anymore, but left here as a reminder * * // Test if the sound has already been added to the mixer std::vector<SoundInfo>::iterator iter = std::find_if(soundList.begin(), soundList.end(), [id](const SoundInfo& sound) { return sound.id == id; }); // Find sound's position in the vector size_t i = std::distance(soundList.begin(), iter); if(i != soundList.size()) { // The sound is already in the sound list, so we need to rewind it soundList[i].index = 0; // We also have to make sure to play the sound with the new volume soundList[i].volume = volume; } else*/ { // The sound needs to be added to the sound list SoundInfo sound; sound.id = id; sound.index = 0; sound.volume = volume; soundList.push_back(sound); } return; } void Mixer::Mix() { // Prevent other threads to alter the soundList vector std::lock_guard<std::mutex> lock(mixerMutex); // Fill buffer with zeros std::fill(alsaParams.buffer, alsaParams.buffer + alsaParams.periodSize, 0); // If there are sounds to mix if(soundList.size() > 0) { std::vector<size_t> soundsToDelete; // Browse sound list for(size_t id = 0; id < soundList.size(); id++) { int soundId = soundList[id].id; int soundIndex = soundList[id].index; // Mix sound for(int i = 0; i < alsaParams.periodSize; i++) { alsaParams.buffer[i] += soundList[id].volume * soundParameters[soundId].data[soundIndex + i]; } // Update sound index soundList[id].index += alsaParams.periodSize; } // Delete the sounds that finished playing auto f = [this](SoundInfo sound) { return (sound.index >= soundParameters[sound.id].length); }; std::vector<SoundInfo>::iterator n = std::remove_if(soundList.begin(), soundList.end(), f); soundList.erase(n, soundList.end()); } return; } }
[ "jerem.oden@gmail.com" ]
jerem.oden@gmail.com
e49185ada64f36eef417bd70b376bdc566b6d0b9
014ff508d145304374f211559dd187bc6e8454bd
/ICommonInfoOut_C.cpp
98babbd999d3d1b9d2b7de8307b140b208e9c4df
[]
no_license
diablozhuzhu/megagui
efcbcda37437b3317dd2efc53bacefcdf241a5cd
833ee139f91c0ca362c1ea58c3208144da019f62
refs/heads/master
2020-03-07T15:04:04.495226
2018-04-02T07:44:57
2018-04-02T07:44:57
127,544,001
0
1
null
null
null
null
GB18030
C++
false
false
2,020
cpp
#include "stdafx.h" #include "ICommonInfoOut_C.h" #include "UiDialogManipulate.h" extern "C" __declspec(dllexport) void __stdcall SHOW_RUNINFO_DLG() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UiDialogManipulate::Get()->Show(); } extern "C" __declspec(dllexport) void __stdcall EXIT_RUNINFO_DLG() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UiDialogManipulate::Get()->Bye(); } extern "C" __declspec(dllexport) void __stdcall CLOSE_RUNINFO_DLG() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UiDialogManipulate::Get()->Close(); } extern "C" __declspec(dllexport) void __stdcall REG_KILL_CALLBACK(Fun_OutUi_Callback fooCallBack) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (fooCallBack!=nullptr) { UiDialogManipulate::Get()->RegKillCallBack(true,fooCallBack); } } extern "C" __declspec(dllexport) void __stdcall SET_ANALYZEITEM(char *sTemp, int len) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); CString str(sTemp, len); UiDialogManipulate::Get()->Step(str); } extern "C" __declspec(dllexport) void __stdcall ADDTXT_TORUNINFODLG(char *sTemp, int len) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if(len<=0) return; // 保护 CString str(sTemp, len-1); // fortran传过来,并不是C里用strlen得到的长度,而是strlen+1 str += _T("\r\n"); UiDialogManipulate::Get()->TextParagraph(str, false, /*int nProgress = */UIPROGRESS_HOLDON, /*int nLevel = */3, /*int indent = */UITEXT_INDENT_DEFAULT, /*COLORREF clr = */UITEXT_COLOR_DEFAULT, /*bool bBold = */false, /*bool bItalic = */false, /*bool bUnderLine = */false); } extern "C" __declspec(dllexport) void __stdcall SET_RUNINFO_PROGRESS(int& process) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UiDialogManipulate::Get()->Progress(process); } extern "C" __declspec(dllexport) void __stdcall DLG_TOTOP() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); UiDialogManipulate::Get()->DlgToTop(); }
[ "diablozhu@qq.com" ]
diablozhu@qq.com
c76a287c225cdfe8d372d625ef9019cf1e57cdac
31caa0ad7ba19592f6f61fd1a5d514de1b73f2a7
/Examples/Apps/Common/Application/Include/help/Helper.h
5de452779e602bc162767b72aed1e88b3c1c8e10
[]
no_license
tkzcfc/net_uv_new
6efc2aef9f9537b0aa35734671a5a9ac57059960
7b8738808461035f054e44f1757a492a1b19a423
refs/heads/master
2023-02-22T07:23:19.657769
2023-02-20T07:12:44
2023-02-20T07:12:44
216,749,416
13
6
null
null
null
null
UTF-8
C++
false
false
196
h
#pragma once #include "imgui.h" #include <string> #include <vector> class Helper { public: static std::string UTS(const std::string& str); static std::string STU(const std::string& str); };
[ "www.tkzc@foxmail.com" ]
www.tkzc@foxmail.com
3b9b5a8791a0c8bf952baf8e4c54935dc5f8160d
96db7bfad07f22dc62701736817b859c921465ca
/Caça-Palavra/puzzle.h
cf2dbfce407697930284cca948a81a735aef053f
[]
no_license
LinsThi/ed_UFC
9a64573133fa847c35081b3b440bc274f16b73d5
b2269fade01ad8d102f657cfc27a297aba4b8da4
refs/heads/master
2023-05-07T19:01:00.295789
2021-05-31T16:34:30
2021-05-31T16:34:30
372,568,267
3
0
null
null
null
null
UTF-8
C++
false
false
205
h
#include <list> #include <string> #include "matrix.h" using namespace std; void createPuzzle(int, int , list<string>& , string, matrix&); void solvePuzzle(list<string>&, string, string, matrix&);
[ "thiagolins13255@gmail.com" ]
thiagolins13255@gmail.com
c8fa09e63f34f31564a7764fdd2b2cde835367b1
6a985cfa88756e7ffce4bb51867fe247d9e2ca6f
/CVFH特征匹配/CVFH/CVFH/cvfh_const.cpp
f17ec94b22091334d3083c9dc9353c94e9f14ab6
[]
no_license
1278741833/PointCloudsLocks
3a08ec919a42e2e0d12d09f673948e54bb0a1042
8c09f913809d4fc7aa733138e13e3c13773fad36
refs/heads/master
2023-09-03T18:49:25.544664
2021-09-26T07:42:38
2021-09-26T07:42:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include <cvfh_const.h> using namespace std; const string GConst::BUILDMODE = "build"; const string GConst::RECOGMODE = "recognition"; const string GConst::GENMODE = "generate"; const string GConst::kdtree_idx_file_name = "kdtree.idx"; const string GConst::training_data_h5_file_name = "training_data.h5"; const string GConst::training_data_list_file_name = "training_data.list";
[ "qq710327563@126.com" ]
qq710327563@126.com
4dc4bf688de1b193ff0d19d87aa586cf247209e0
450aab9335637b7fade9745928326c12c638e40b
/Histograms/histogram.h
a4316f128b7c1c5d167d35849e806b4123e18e4c
[]
no_license
piokac/PSIO_lab
3b613173d4bb8caf7a1188b110e0d5cf0195f573
b76df0897ceb177fd4050d40530fb51c7908d14e
refs/heads/master
2022-04-15T22:05:34.555046
2020-04-14T15:01:21
2020-04-14T15:01:21
254,631,202
1
0
null
null
null
null
UTF-8
C++
false
false
1,048
h
#ifndef HISTOGRAM_H #define HISTOGRAM_H #include <iostream> #include <map> #include <vector> class Histogram { std::map<int, int> bins_; using BinsVector = std::vector<std::pair<int, int>>; public: Histogram(const std::vector<int> &data = std::vector<int>()); static Histogram generate(int min, int max, int counter); static Histogram generate(int count, int (*func_ptr)()); void emplace(int v); void emplace(const std::vector<int> &data); void clear(); bool from_csv(const std::string &filename, char delim = ',', int column_idx = 4); std::pair<int, int> max() const; std::pair<int, int> range() const; std::vector<int> unique_bins() const; BinsVector unique_items() const; Histogram &operator<<(int v); int operator[](int v) const; //zwraca częstość dla binu w indeksie operator BinsVector(); friend std::istream &operator>>(std::istream &str, Histogram &hist); friend std::ostream &operator<<(std::ostream &str, const Histogram &hist); }; #endif // HISTOGRAM_H
[ "piokac@gmail.com" ]
piokac@gmail.com
b129ca1306719368b9ab54a1b24aeb476a586f3d
6d162423c6a02ec4737796de7a2696310264dd30
/sr-design-micro/bluetooth_command_mode/bluetooth_command_mode.ino
076393570fc8b105d4a1ed374c32fda377b20da1
[]
no_license
jtrovato/starfish-avocado
3ab64bb9669d44000315ebc103c641338b2ae9ad
91ba9481e79a9e2cda6d80b281e251dda82a0d54
refs/heads/master
2020-05-17T10:15:51.812329
2015-06-24T15:13:38
2015-06-24T15:13:38
14,433,521
0
0
null
2014-02-11T17:27:31
2013-11-15T19:48:22
Java
UTF-8
C++
false
false
4,110
ino
/* Example Bluetooth Serial Passthrough Sketch by: Jim Lindblom SparkFun Electronics date: February 26, 2013 license: Public domain This example sketch converts an RN-42 bluetooth module to communicate at 9600 bps (from 115200), and passes any serial data between Serial Monitor and bluetooth module. */ #include <SoftwareSerial.h> int bluetoothTx = 2; // TX-O pin of bluetooth mate, Arduino D2 int bluetoothRx = 3; // RX-I pin of bluetooth mate, Arduino D3 int length; //length of packet int cmd; //command selection from bluetooth int srcmd; //status requests int heatingcmd; //heating commands int ledcmd; //led commands int fluidscmd; //fluid commands SoftwareSerial bluetooth(bluetoothTx, bluetoothRx); void setup() { Serial.begin(9600); // Begin the serial monitor at 9600bps bluetooth.begin(115200); // The Bluetooth Mate defaults to 115200bps bluetooth.print("$"); // Print three times individually bluetooth.print("$"); bluetooth.print("$"); // Enter command mode delay(100); // Short delay, wait for the Mate to send back CMD bluetooth.println("U,9600,N"); // Temporarily Change the baudrate to 9600, no parity // 115200 can be too fast at times for NewSoftSerial to relay the data reliably bluetooth.begin(9600); // Start bluetooth serial at 9600 } void loop(){ if(bluetooth.available()) // If the bluetooth sent any characters { // Send any characters the bluetooth prints to the serial monitor //Serial.print((char)bluetooth.read()); if(bluetooth.read() == 0xB8 ){ Serial.print("first byte received\r\n"); if(bluetooth.read() == 0xD3){ Serial.print("second byte received\r\n"); length = bluetooth.read(); Serial.print(length); for( int i = 1; i <= length; i++){ cmd = bluetooth.read(); if (cmd == 0xFF){ srcmd = bluetooth.read(); status_requests(srcmd); } else if (cmd ==0x57){ heatingcmd = bluetooth.read(); heating_commands(heatingcmd); } else if (cmd == 0x3C){ ledcmd = bluetooth.read(); led_command(ledcmd); } else if (cmd == 0x8F){ fluidscmd = bluetooth.read(); fluids_command(fluidscmd); } } } else{ bluetooth.flush(); } } else{ bluetooth.flush(); } if(Serial.available()) // If stuff was typed in the serial monitor { // Send any characters the Serial monitor prints to the bluetooth bluetooth.print((char)Serial.read()); } // and loop forever and ever! } } void status_requests(int cmd){ if (cmd == 0x3C){ Serial.print("//led state request"); } else if(cmd == 0x57){ Serial.print(" //heating state request"); } else if (cmd == 0x8F){ Serial.print("//fluid acutation state request"); } else if (cmd == 0x6A){ Serial.print("//temp data request"); } else if (cmd == 0xA5){ Serial.print("//full status (all state values and data)"); }else{ Serial.print("invalid input received"); } } void heating_commands(int cmd){ if (cmd == 0x33){ //Start/switch heating-- temp 1 Serial.print("Start/switch heating-- temp 1\r\n"); } else if(cmd == 0x55){ //Start/switch heating-- temp 2 Serial.print("Start/switch heating-- temp 2\r\n"); } else if (cmd == 0x66){ //Start/switch heating-- temp 3 Serial.print("Start/switch heating-- temp 3\r\n"); } else if (cmd == 0xFF){ //Start/switch heating-- temp 4 Serial.print("Start/switch heating-- temp 4\r\n"); } else if (cmd == 0x00){ //Stop heating Serial.print("Stop heating \r\n"); } } void led_command(int cmd){ if (cmd == 0xFF){ Serial.print("//Leds on\r\n"); }else if(cmd == 0x00){ Serial.print("//Leds off\r\n"); } } void fluids_command(int cmd){ if (cmd == 0xFF){ //Start fluids actuation Serial.print("Start fluids actuation"); }else if(cmd == 0x00){ //Stop fluids actuation Serial.print("Stop fluids actuation"); } }
[ "botelhoa92@gmail.com" ]
botelhoa92@gmail.com
0d301edf84d7a69ecfc1f788e34f9d47e325f1c8
a418afb0ec01cb8f41d9fcaf167f59b0f05aea90
/Codeforces/136A.cpp
bcf872e97091dbb48e418e60165912de36ada2b8
[]
no_license
manjurulhoque/problem-solving
95d05960e83edde5721b73348270b6123fd3bf12
e5547a8f5593141ac87f9797ddb25b2467c44e57
refs/heads/master
2022-08-08T06:44:21.839224
2022-07-25T09:32:26
2022-07-25T09:32:26
209,125,784
2
0
null
null
null
null
UTF-8
C++
false
false
378
cpp
#include<bits/stdc++.h> using namespace std; /// Accepted int main() { int n; cin>>n; int p[n+1]; for(int i = 1; i <= n; i++) { cin>>p[i]; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(p[j] == i) { cout<<j<<" "; } } } return 0; }
[ "todoyel19@gmail.com" ]
todoyel19@gmail.com
e0be17b21a4828daa7d78913d95add33dd026361
95ae94e43068a7d0f768b025cfd7bad31796ca41
/Core/Include/handle.h
2250857d5ddc84a0ae474f6f6863e504d1c67838
[]
no_license
zxy888pro/Sapphire
3f9661edef006af7669741410f8a141b17c833ba
879e0c4fa02a856edc6937c41eae8fa52af318b4
refs/heads/master
2020-03-23T19:52:14.608133
2019-08-25T02:15:39
2019-08-25T02:15:39
142,007,038
0
0
null
null
null
null
GB18030
C++
false
false
4,842
h
#pragma once #include <vector> #include <cassert> namespace Sapphire { //Handle类 template<typename TAG> class Handle { union { enum { //使用位域的大小 MAX_BITS_INDEX = 16, MAX_BITS_MAGIC = 16, //解引用断言所需要比较的大小 MAX_INDEX = (1 << MAX_BITS_INDEX) - 1, //65535 MAX_MAGIC = (1 << MAX_BITS_MAGIC) - 1 //65635 }; struct { uint m_Index : MAX_BITS_INDEX; //句柄对应资源在资源数组的索引 uint m_Magic : MAX_BITS_MAGIC; //用于检验句柄的魔术数 }; uint m_Handle; //句柄作为资源标识符 }; public: Handle(void):m_Handle(0){} void Init(unsigned int index); uint GetIndex(void) const { return m_Index; } uint GetMagic(void) const { return m_Magic; } uint GetHandle(void) const { return m_Handle;} bool IsNull(void) const { return (!m_Handle); } operator uint (void) const { return m_Handle; } //类型转换运算符,直接转换uint,不用显示转换 void Discard(void){ m_Handle = 0; } }; template<typename TAG> void Sapphire::Handle<TAG>::Init(unsigned int index) { assert(IsNull()); //不能重复Init assert(index <= MAX_INDEX); static uint s_autoMagic = 0; //自增魔法术 if (++s_autoMagic > MAX_MAGIC) //回绕 { s_autoMagic = 1; //0用于空句柄 } this->m_Index = index; m_Magic = s_autoMagic; } template <typename TAG> inline bool operator != (Handle<TAG> l, Handle<TAG> r) { return l.GetHandle() != r.GetHandle(); } template <typename TAG> inline bool operator == (Handle<TAG> l, Handle<TAG> r) { return l.GetHandle() != r.GetHandle(); } ///简单Handle管理器 template <typename DATA, typename HANDLE> class HandleMgr { private: typedef std::vector<DATA> UserVec; typedef std::vector<uint> MagicVec; typedef std::vector<uint> FreeVec; UserVec m_UserData; //实际资源 MagicVec m_MagicNumbers; //对应的魔法号码 FreeVec m_FreeSlots; //空闲列表 public: HandleMgr(void){} ~HandleMgr(void){} //句柄方法 //分配句柄 DATA* Acquire(HANDLE& handle); //释放 void Release(HANDLE handle) ; //获取资源引用 DATA* Dereference(HANDLE handle); const DATA* Dereference(HANDLE handle) const; //获取已使用的句柄数 uint GetUsedHandleCount(void) const { return{ m_MagicNumbers.size() - m_FreeSlots.size(); } } //是否还有可用句柄 bool HasUsedHandles(void) const { return !!GetUsedHandleCount(); } bool VerifyHandle(HANDLE& handle); }; template <typename DATA, typename HANDLE> bool Sapphire::HandleMgr<DATA, HANDLE>::VerifyHandle(HANDLE& handle) { // 取得句柄对应资源的索引 unsigned int index = handle.GetIndex(); // 验证有效性 return ((index < m_UserData.size()) && (m_MagicNumbers[index] == handle.GetMagic())); } //释放一个句柄 template <typename DATA, typename HANDLE> void Sapphire::HandleMgr<DATA, HANDLE>::Release(HANDLE handle) { // 取得句柄对应资源的索引 unsigned int index = handle.GetIndex(); // 验证资源有效性 //assert(index < m_UserData.size()); //assert(m_MagicNumbers[index] == handle.GetMagic()); if (!VerifyHandle(handle)) { LogUtil::LogMsgLn("Invalid Handle!"); return; } //移除它,添加到空闲列表 this->m_MagicNumbers[index] = 0; //资源索引对应的魔法数置为NULL this->m_FreeSlots.push_back(index); } ///获取一个句柄 template <typename DATA, typename HANDLE> DATA* Sapphire::HandleMgr<DATA, HANDLE>::Acquire(HANDLE& handle) { //索引 unsigned index; if (m_FreeSlots.empty()) { //每一个已分配的索引都对应着魔法数 //取得一个索引号 index = m_MagicNumbers.size(); handle.Init(index); //添加一个DATA资源 m_UserData.push_back(DATA()); m_MagicNumbers.push_back(handle.GetMagic()); } else { index = m_FreeSlots.back(); handle.Init(index); m_FreeSlots.pop_back(); m_MagicNumbers[index] = handle.GetMagic(); } return &(m_UserData[index]); } template <typename DATA, typename HANDLE> inline DATA* HandleMgr <DATA, HANDLE> ::Dereference(HANDLE handle) { if (handle.IsNull()) return (0); //检查句柄有效性, if (!VerifyHandle(handle)) { LogUtil::LogMsgLn("Invalid Handle!"); return NULL; } uint index = handle.GetIndex(); //if ((index >= m_UserData.size()) // || (m_MagicNumbers[index] != handle.GetMagic())) //{ // //无效句柄 // assert(0); // return (0); //} return &(m_UserData[index]); } template <typename DATA, typename HANDLE> inline const DATA* HandleMgr <DATA, HANDLE> ::Dereference(HANDLE handle) const { typedef HandleMgr <DATA, HANDLE> ThisType; return (const_cast <ThisType*> (this)->Dereference(handle)); } }
[ "373982141@qq.com" ]
373982141@qq.com
ad53bf1973ea763893189ec4d57eec551b3dfc85
37cca16f12e7b1d4d01d6f234da6d568c318abee
/src/rice/p2p/glacier/v2/GlacierImpl_deleteFragment_9_receiveResult_9_1.cpp
8815c0668ff9124840759fcfa6457d7afc798290
[]
no_license
subhash1-0/thirstyCrow
e48155ce68fc886f2ee8e7802567c1149bc54206
78b7e4e3d2b9a9530ad7d66b44eacfe73ceea582
refs/heads/master
2016-09-06T21:25:54.075724
2015-09-21T17:21:15
2015-09-21T17:21:15
42,881,521
0
0
null
null
null
null
UTF-8
C++
false
false
2,585
cpp
// Generated from /pastry-2.1/src/rice/p2p/glacier/v2/GlacierImpl.java #include <rice/p2p/glacier/v2/GlacierImpl_deleteFragment_9_receiveResult_9_1.hpp> #include <java/lang/Exception.hpp> #include <java/lang/NullPointerException.hpp> #include <java/lang/String.hpp> #include <java/lang/StringBuilder.hpp> #include <rice/Continuation.hpp> #include <rice/environment/logging/Logger.hpp> #include <rice/p2p/commonapi/Id.hpp> #include <rice/p2p/glacier/v2/GlacierImpl_deleteFragment_9.hpp> #include <rice/p2p/glacier/v2/GlacierImpl.hpp> #include <rice/persistence/StorageManager.hpp> template<typename T> static T* npc(T* t) { if(!t) throw new ::java::lang::NullPointerException(); return t; } rice::p2p::glacier::v2::GlacierImpl_deleteFragment_9_receiveResult_9_1::GlacierImpl_deleteFragment_9_receiveResult_9_1(GlacierImpl_deleteFragment_9 *GlacierImpl_deleteFragment_9_this, ::rice::p2p::commonapi::Id* fkey, ::rice::Continuation* command) : super(*static_cast< ::default_init_tag* >(0)) , GlacierImpl_deleteFragment_9_this(GlacierImpl_deleteFragment_9_this) , fkey(fkey) , command(command) { clinit(); ctor(); } void rice::p2p::glacier::v2::GlacierImpl_deleteFragment_9_receiveResult_9_1::receiveResult(::java::lang::Object* o) { if(npc(GlacierImpl_deleteFragment_9_this->GlacierImpl_this->logger)->level <= ::rice::environment::logging::Logger::FINE) npc(GlacierImpl_deleteFragment_9_this->GlacierImpl_this->logger)->log(::java::lang::StringBuilder().append(u"Deleting fragment "_j)->append(npc(fkey)->toStringFull())->toString()); npc(GlacierImpl_deleteFragment_9_this->GlacierImpl_this->fragmentStorage)->unstore(fkey, command); } void rice::p2p::glacier::v2::GlacierImpl_deleteFragment_9_receiveResult_9_1::receiveException(::java::lang::Exception* e) { if(npc(GlacierImpl_deleteFragment_9_this->GlacierImpl_this->logger)->level <= ::rice::environment::logging::Logger::WARNING) npc(GlacierImpl_deleteFragment_9_this->GlacierImpl_this->logger)->logException(::java::lang::StringBuilder().append(u"Cannot store in trash: "_j)->append(npc(fkey)->toStringFull()) ->append(u", e="_j)->toString(), e); npc(command)->receiveException(e); } extern java::lang::Class *class_(const char16_t *c, int n); java::lang::Class* rice::p2p::glacier::v2::GlacierImpl_deleteFragment_9_receiveResult_9_1::class_() { static ::java::lang::Class* c = ::class_(u"", 0); return c; } java::lang::Class* rice::p2p::glacier::v2::GlacierImpl_deleteFragment_9_receiveResult_9_1::getClass0() { return class_(); }
[ "sgurjar@adobe.com" ]
sgurjar@adobe.com
78d87a832b217053798796c4c44727452bb26dee
5ad9ccfa337835d535f123e55fe48b2e760ea641
/dsa/lib/AssistDS/FuncSpec.cpp
35abcdcb925c3984980e7a6320e1b6e096bd10ee
[ "Apache-2.0", "NCSA" ]
permissive
lmrs2/afl_cc
3fa1f860aef1daf6caa1b73a0ead9b2886de1930
d074c0470ce58e15f537cdf16856ab3669c266fb
refs/heads/master
2020-09-20T02:39:58.987994
2020-04-05T20:15:30
2020-04-05T20:15:30
224,359,299
0
0
Apache-2.0
2020-04-05T20:15:31
2019-11-27T06:21:12
C++
UTF-8
C++
false
false
4,736
cpp
//===-- FuncSpec.cpp - Clone Functions With Constant Function Ptr Args ----===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This pass clones functions that take constant function pointers as arguments // from some call sites. It changes those call sites to call cloned functions. // //===----------------------------------------------------------------------===// #define DEBUG_TYPE "funcspec" #include "assistDS/FuncSpec.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Debug.h" #include <set> #include <map> #include <vector> using namespace llvm; // Pass statistics STATISTIC(numCloned, "Number of Functions Cloned in FuncSpec"); STATISTIC(numReplaced, "Number of Calls Replaced"); // // Method: runOnModule() // // Description: // Entry point for this LLVM pass. Search for call sites, that take functions as arguments // Clone those functions, and pass the clone. // // Inputs: // M - A reference to the LLVM module to transform // // Outputs: // M - The transformed LLVM module. // // Return value: // true - The module was modified. // false - The module was not modified. // bool FuncSpec::runOnModule(Module& M) { std::map<CallInst*, std::vector<std::pair<unsigned, Constant*> > > cloneSites; std::map<std::pair<Function*, std::vector<std::pair<unsigned, Constant*> > >, Function* > toClone; for (Module::iterator I = M.begin(); I != M.end(); ++I) if (!I->isDeclaration() && !I->mayBeOverridden()) { std::vector<unsigned> FPArgs; for (Function::arg_iterator ii = I->arg_begin(), ee = I->arg_end(); ii != ee; ++ii) { // check if this function has a FunctionType(or a pointer to) argument if (const PointerType* Ty = dyn_cast<PointerType>(ii->getType())) { if (isa<FunctionType>(Ty->getElementType())) { // Store the index of such an argument FPArgs.push_back(ii->getArgNo()); DEBUG(errs() << "Eligible: " << I->getName().str() << "\n"); } } else if (isa<FunctionType>(ii->getType())) { // Store the index of such an argument FPArgs.push_back(ii->getArgNo()); DEBUG(errs() << "Eligible: " << I->getName().str() << "\n"); } } // Now find all call sites that it is called from for(Value::user_iterator ui = I->user_begin(), ue = I->user_end(); ui != ue; ++ui) { if (CallInst* CI = dyn_cast<CallInst>(*ui)) { // Check that it is the called value (and not an argument) if(CI->getCalledValue()->stripPointerCasts() == &*I) { std::vector<std::pair<unsigned, Constant*> > Consts; for (unsigned x = 0; x < FPArgs.size(); ++x) if (Constant* C = dyn_cast<Constant>(ui->getOperand(FPArgs.at(x) + 1))) { // If the argument passed, at any of the locations noted earlier // is a constant function, store the pair Consts.push_back(std::make_pair(FPArgs.at(x), C)); } if (!Consts.empty()) { // If at least one of the arguments is a constant function, // we must clone the function. cloneSites[CI] = Consts; toClone[std::make_pair(&*I, Consts)] = 0; } } } } } numCloned += toClone.size(); for (std::map<std::pair<Function*, std::vector<std::pair<unsigned, Constant*> > >, Function* >::iterator I = toClone.begin(), E = toClone.end(); I != E; ++I) { // Clone all the functions we need cloned ValueToValueMapTy VMap; Function* DirectF = CloneFunction(I->first.first, VMap, false); DirectF->setName(I->first.first->getName().str() + "_SPEC"); DirectF->setLinkage(GlobalValue::InternalLinkage); I->first.first->getParent()->getFunctionList().push_back(DirectF); I->second = DirectF; } for (std::map<CallInst*, std::vector<std::pair<unsigned, Constant*> > >::iterator ii = cloneSites.begin(), ee = cloneSites.end(); ii != ee; ++ii) { // Transform the call sites, to call the clones Function *OldCallee = cast<Function>(ii->first->getCalledValue()); Function *NewCallee = toClone[std::make_pair(OldCallee, ii->second)]; ii->first->setCalledFunction(NewCallee); ++numReplaced; } return true; } // Pass ID variable char FuncSpec::ID = 0; // Register the pass static RegisterPass<FuncSpec> X("funcspec", "Specialize for Function Pointers");
[ "l.simon@samsung.com" ]
l.simon@samsung.com
492c79aa84b880da9120a993b58171f59ba5c378
1fff85adc5ceb532cfda64678e4adb8d08b0bf25
/mouse/mouse/main.cpp
889dfbc0679137409c51ec01646c6c2e0a4c7365
[]
no_license
brotherand2/windowsprogramdemo
a60288ae9e73bb6f5ee06b408fbf00e1ba9a5dfb
2eef34d14af4ab5b226f71be0830b23ef2510a71
refs/heads/master
2021-01-20T08:07:07.355873
2017-04-09T03:50:40
2017-04-09T03:50:40
83,894,342
2
0
null
null
null
null
UTF-8
C++
false
false
3,353
cpp
//#ifndef UNICODE //#define tstring string //#else //#define tstring wstring //#endif #include<Windows.h> #include<string> #include<vector> #include<memory> using namespace std; //#ifndef UNICODE //typedef string tstring; //#else //typedef wstring tstring; //#endif #ifndef UNICODE using tstring = string; #else using tstring = wstring; #endif long _stdcall WndProc(HWND hwnd, unsigned int UMsg, unsigned int wParam, long lParam) { PAINTSTRUCT ps; HDC hdc; TEXTMETRIC tm; static int cxClient, cyClient; static int cxChar, cxCaps, cyChar; static vector<POINT>point; POINT curPoint; POINT *temp; switch (UMsg) { case WM_CREATE: hdc = GetDC(hwnd); GetTextMetrics(hdc, &tm); cxChar = tm.tmAveCharWidth; cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2)*cxChar / 2; cyChar = tm.tmHeight + tm.tmExternalLeading; ReleaseDC(hwnd, hdc); break; case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); break; case WM_LBUTTONDOWN: point.clear(); case WM_LBUTTONUP: InvalidateRect(hwnd, nullptr, true); break; case WM_MOUSEMOVE: //hdc = GetDC(hwnd); if (wParam&MK_LBUTTON) //SetPixel(hdc, LOWORD(lParam), HIWORD(lParam), RGB(255, 0, 0)); { curPoint.x = LOWORD(lParam); curPoint.y = HIWORD(lParam); point.push_back(curPoint); } //ReleaseDC(hwnd,hdc); break; case WM_PAINT: hdc = BeginPaint(hwnd, &ps); //temp = new POINT[point.size()]; //for (int i = 0; i < point.size(); i++) // temp[i] = point[i]; //for (int i = 0; i < point.size();i++) //Polygon(hdc,temp+i, point.size()-i); SetCursor(LoadCursor(nullptr,IDC_WAIT)); for (int i = 0; i <(int) point.size() - 1; i++) { MoveToEx(hdc, point[i].x, point[i].y, nullptr); for (int j = i + 1; j < point.size(); j++) { LineTo(hdc, point[j].x, point[j].y); MoveToEx(hdc, point[i].x, point[i].y, nullptr); } } SetCursor(LoadCursor(nullptr,IDC_ARROW)); //delete[]temp; EndPaint(hwnd, &ps); break; //case WM_NCHITTEST: // return HTNOWHERE; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, UMsg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char * szCmdCommand, int nCmdShow) { WNDCLASS wndclass; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.hCursor = LoadCursor(nullptr, IDC_ICON); wndclass.hIcon = LoadIcon(nullptr, IDI_APPLICATION); wndclass.hInstance = hInstance; wndclass.lpfnWndProc = WndProc; wndclass.lpszClassName = TEXT("zeng"); wndclass.lpszMenuName = nullptr; wndclass.style = CS_VREDRAW | CS_HREDRAW; if (!RegisterClass(&wndclass)) { MessageBox(nullptr, TEXT("register failed"), TEXT("error"), MB_ICONINFORMATION); return 0; } HWND hwnd = CreateWindow(TEXT("zeng"), TEXT("keyScroll"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr); if (!hwnd) { MessageBox(nullptr, TEXT("create window failed"), TEXT("error"), MB_ICONASTERISK); } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); MSG msg; while (GetMessage(&msg, nullptr, 0, 0)) { DispatchMessage(&msg); } }
[ "547996854@qq.com" ]
547996854@qq.com
6afcfa8cde00b379018664299f1086599cffe219
9ff35738af78a2a93741f33eeb639d22db461c5f
/.build/Android-Debug/jni/app/Uno.Collections.List1_Enumerator__Fuse_Drawing_Contour.cpp
920568792d0c025e9680a7af13acc0d894729e08
[]
no_license
shingyho4/FuseProject-Minerals
aca37fbeb733974c1f97b1b0c954f4f660399154
643b15996e0fa540efca271b1d56cfd8736e7456
refs/heads/master
2016-09-06T11:19:06.904784
2015-06-15T09:28:09
2015-06-15T09:28:09
37,452,199
0
0
null
null
null
null
UTF-8
C++
false
false
3,947
cpp
// This file was generated based on 'C:\ProgramData\Uno\Packages\UnoCore\0.1.0\Source\Uno\Collections\$.uno'. // WARNING: Changes might be lost if you edit this file directly. #include <app/Fuse.Drawing.Contour.h> #include <app/Uno.Collections.List__Fuse_Drawing_Contour.h> #include <app/Uno.Collections.List1_Enumerator__Fuse_Drawing_Contour.h> #include <app/Uno.Int.h> #include <app/Uno.InvalidOperationException.h> #include <app/Uno.String.h> namespace app { namespace Uno { namespace Collections { List1_Enumerator__Fuse_Drawing_Contour__uType* List1_Enumerator__Fuse_Drawing_Contour__typeof() { static List1_Enumerator__Fuse_Drawing_Contour__uType* type; if (::uEnterCriticalIfNull(&type)) { type = (List1_Enumerator__Fuse_Drawing_Contour__uType*)::uAllocValueType(sizeof(List1_Enumerator__Fuse_Drawing_Contour__uType), "Uno.Collections.List1_Enumerator<Fuse.Drawing.Contour>", sizeof(List1_Enumerator__Fuse_Drawing_Contour), 3, 2); type->__interface_0.__fp_get_Current = (::app::Fuse::Drawing::Contour*(*)(void*))List1_Enumerator__Fuse_Drawing_Contour__get_Current; type->__interface_1.__fp_Dispose = (void(*)(void*))List1_Enumerator__Fuse_Drawing_Contour__Dispose; type->__interface_2.__fp_MoveNext = (bool(*)(void*))List1_Enumerator__Fuse_Drawing_Contour__MoveNext; type->Implements[0] = ::app::Uno::Collections::IEnumerator__Fuse_Drawing_Contour__typeof(); type->Implements[1] = ::app::Uno::IDisposable__typeof(); type->Implements[2] = ::app::Uno::Collections::IEnumerator__typeof(); type->InterfaceOffsets[0] = offsetof(List1_Enumerator__Fuse_Drawing_Contour__uType, __interface_0); type->InterfaceOffsets[1] = offsetof(List1_Enumerator__Fuse_Drawing_Contour__uType, __interface_1); type->InterfaceOffsets[2] = offsetof(List1_Enumerator__Fuse_Drawing_Contour__uType, __interface_2); type->StrongRefOffsets[0] = offsetof(List1_Enumerator__Fuse_Drawing_Contour, _source); type->StrongRefOffsets[1] = offsetof(List1_Enumerator__Fuse_Drawing_Contour, _current); #ifdef U_DEBUG_MEM type->StrongRefNames[0] = "_source"; type->StrongRefNames[1] = "_current"; #endif ::uRetainObject(type); ::uExitCritical(); } return type; } ::app::Fuse::Drawing::Contour* List1_Enumerator__Fuse_Drawing_Contour__get_Current(List1_Enumerator__Fuse_Drawing_Contour* __this) { return __this->_current; } void List1_Enumerator__Fuse_Drawing_Contour__Dispose(List1_Enumerator__Fuse_Drawing_Contour* __this) { } bool List1_Enumerator__Fuse_Drawing_Contour__MoveNext(List1_Enumerator__Fuse_Drawing_Contour* __this) { if (::uPtr< ::app::Uno::Collections::List__Fuse_Drawing_Contour*>(__this->_source)->_version != __this->_version) { U_THROW(::app::Uno::InvalidOperationException__New_4(NULL, ::uGetConstString("Collection was modified"))); } __this->_iterator++; if (__this->_iterator < ::uPtr< ::app::Uno::Collections::List__Fuse_Drawing_Contour*>(__this->_source)->_used) { __this->_current = ::uPtr< ::uArray*>(::uPtr< ::app::Uno::Collections::List__Fuse_Drawing_Contour*>(__this->_source)->_data)->Item< ::app::Fuse::Drawing::Contour*>(__this->_iterator); return true; } return false; } void List1_Enumerator__Fuse_Drawing_Contour___ObjInit(List1_Enumerator__Fuse_Drawing_Contour* __this, ::app::Uno::Collections::List__Fuse_Drawing_Contour* source) { __this->_source = source; __this->_version = ::uPtr< ::app::Uno::Collections::List__Fuse_Drawing_Contour*>(source)->_version; __this->_iterator = -1; } List1_Enumerator__Fuse_Drawing_Contour List1_Enumerator__Fuse_Drawing_Contour__New_1(::uStatic* __this, ::app::Uno::Collections::List__Fuse_Drawing_Contour* source) { List1_Enumerator__Fuse_Drawing_Contour inst = ::uDefault< List1_Enumerator__Fuse_Drawing_Contour>(); inst._ObjInit(source); return inst; } }}}
[ "hyl.hsy@gmail.com" ]
hyl.hsy@gmail.com
621d706963dabdef1a9e4e9db984d542f3c52c44
25eb84256b6d9f6d8b7cbcc168226a4656fc01e3
/testcpp/testcpp/DoMyWork2.cpp
e8e88078657f0f60610c018873f1d8298b019222
[]
no_license
gracekim17/gracekim17.github.io
555c654aa4f4ea5cc7353dfa4a4a765fafafa1d0
cbc2b352e0a998d8f3c27ca3b99476a724167d1b
refs/heads/master
2020-03-12T03:58:47.269487
2019-07-29T02:54:37
2019-07-29T02:54:37
130,435,202
0
0
null
2019-06-30T01:29:21
2018-04-21T03:11:11
HTML
UTF-8
C++
false
false
132
cpp
#include "MyCommon.h" #include "DoMyWork2.h" void DoMyWork2::Start() { } DoMyWork2::DoMyWork2() { } DoMyWork2::~DoMyWork2() { }
[ "jhkim@microsoft.com" ]
jhkim@microsoft.com
5dfb2607beb0abdc65198733910c7f7a3089a867
74450d2e5c5d737ab8eb3f3f2e8b7d2e8b40bb5e
/github_code_index_sort/cpp/2/78.c
0e2a77e86b36db3e7c28d5ea61d7dd5964c4c0f0
[]
no_license
ulinka/tbcnn-attention
10466b0925987263f722fbc53de4868812c50da7
55990524ce3724d5bfbcbc7fd2757abd3a3fd2de
refs/heads/master
2020-08-28T13:59:25.013068
2019-05-10T08:05:37
2019-05-10T08:05:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,855
c
#ifndef ALGORITHMS_MERGESORT_H #define ALGORITHMS_MERGESORT_H #include <vector> #include "../IPreparable.h" #include "../IRunnable.h" template <class T> class MergeSort : public IPreparable<T>, public IRunnable<T> { public: MergeSort() {} ~MergeSort() { delete[] tab, delete[] temp, delete[] tab_left, delete[] tab_right; std::cout << "destructor called"; } void prepare(const T&); void run(); void merge(T[],T[],T,T); void mergesort(T[],T[],T,T); void optimal_case(); void normal_case(); void pesimist_case(); void print() const; void swap(T&,T&); void merge_mix(T[],T[],T,T[],T); void mix(T[],T); const std::string getName() const { return "mergesort"; } private: T data_size; T* tab; T* temp; T* tab_left; T* tab_right; }; template<class T> inline void MergeSort<T>::swap(T& v1, T& v2) { T tmp = v2; v2 = v1; v1 = tmp; } template <class T> inline void MergeSort<T>::merge_mix(T tab[], T tab_left[], T left_size, T tab_right[], T right_size) { T i,j; for (i=0; i<left_size; i++) { tab[i] = tab_left[i]; } for (j=0; j<right_size; j++, i++) { tab[i] = tab_right[j]; } } template<class T> inline void MergeSort<T>::mix(T tab[], T data_size) { if (data_size <= 1) return; if (data_size == 2) { swap(tab[0], tab[1]); return; } T left_size = data_size/2; T right_size = data_size/2; //T tab_left[left_size]; //T tab_right[right_size]; for (T i=0, j=0; i<data_size; i=i+2, j++) { tab_left[j] = tab[i]; } for (T i=1, j=0; i<data_size; i=i+2, j++) { tab_right[j] = tab[i]; } mix(tab_left, left_size); mix(tab_right, right_size); merge_mix(tab, tab_left, left_size, tab_right, right_size); } template <class T> inline void MergeSort<T>::optimal_case() { for (auto i = 0; i<data_size; i++) { tab[i] = data_size; } } template <class T> inline void MergeSort<T>::pesimist_case() { for (T i=0; i<data_size; i++) { tab[i] = i;//rand() % data_size; } mix(tab, data_size); } template <class T> inline void MergeSort<T>::normal_case() { for (auto i = 0; i<data_size; i++) { tab[i] = rand() % data_size; } } template <class T> inline void MergeSort<T>::print() const { for (auto iter = 0; iter<data_size; iter++) { std::cout << tab[iter] << " "; } } template <class T> inline void MergeSort<T>::prepare(const T& value) { this->data_size = value; tab = new T[data_size]; temp = new T[data_size]; tab_left = new T[data_size/2]; tab_right = new T[data_size/2]; } template <class T> inline void MergeSort<T>::run() { T min = 0; mergesort(tab,temp,min,data_size-1); } // IMPLEMENTATION USING ARRAY FROM ANSI C template <typename T> inline void MergeSort<T>::merge(T array[],T temp[], T first, T last) { T mid = (first+last)/2; T i1 = 0, i2 = first, i3 = mid+1; temp [last-first+1]; while (i2 <= mid && i3 <= last) { // dopóki prawa i lewa podtablica zawieraja elementy if (array[i2] < array[i3]) { temp[i1++] = array[i2++]; } else { temp[i1++] = array[i3++]; } } while (i2 <= mid) { temp[i1++] = array[i2++]; } while (i3 <= last) { temp[i1++] = array[i3++]; } for (i1 = 0, i2 = first ; i2 <= last; array[i2++] = temp[i1++]); //delete[] temp; } template <typename T> inline void MergeSort<T>:: mergesort(T data[], T temp[],T first, T last) { if (first < last) { T mid = (first+last)/2 ; mergesort(data, temp,first, mid); mergesort(data,temp, mid+1, last); merge(data,temp,first, last); } } //template <class T> //void MergeSort<T>::merge(std::vector<T>& array, std::vector<T>& array1, std::vector<T>& array2) { // array.clear(); // T i,j; // // for (i = j = 0; i < array1.size() && j < array2.size(); ) { // if (array1.at(i) < array2.at(j)) { // array.push_back(array1.at(i)); // i++; // } else { // array.push_back(array2.at(j)); // j++; // } // } // // while (i < array1.size()) { // array.push_back(array1.at(i)); // i++; // } // // while (j < array2.size()) { // array.push_back(array2.at(j)); // j++; // } //} // //template <class T> //void MergeSort<T>::mergesort(std::vector<T>& array) { // if (1 < array.size()) { // std::vector<T> array1(array.begin(), array.begin() + array.size() / 2); // left-hand vector // mergesort(array1); // std::vector<T> array2(array.begin() + array.size() / 2, array.end()); // right-head vector // mergesort(array2); // merge(array, array1, array2); // } //} #endif //ALGORITHMS_MERGESORT_H
[ "bdqnghi@gmail.com" ]
bdqnghi@gmail.com
dc62b4102c5f5d9d0fa502c05a3a6fea3dc14b5d
80c05c1d5f69081b91e5bc270ec67df734654c56
/window.h
806a6bb5093d0301a32e1d71cbc8638d09efa81a
[]
no_license
jkwok678/RailwayBuilder
e2df06fa91c4cb5e00e6db43ea512b54fc164d0d
f719ec0cadaa5aa156f6637d8b6e29651b11d2ca
refs/heads/master
2023-08-08T03:10:24.305549
2021-07-21T22:01:26
2021-07-21T22:01:26
388,106,327
0
2
null
2023-07-22T15:18:52
2021-07-21T12:16:16
C++
UTF-8
C++
false
false
176
h
#ifndef WINDOW_H #define WINDOW_H #include <QWidget> class Window : public QWidget { Q_OBJECT public: Window(QWidget *parent = nullptr); ~Window(); }; #endif // WINDOW_H
[ "jkwok678@gmail.com" ]
jkwok678@gmail.com
d6d6abcb767a3ca4267fc7c07778f3b5ba50952d
982a18da7f11c8b511f108777fad521294b264c1
/serialization/src/binary.cpp
eff8b370e2b6e3dbde43776f24e1c0da4d00e6bd
[ "BSL-1.0" ]
permissive
byzhang/solidframe
85ad5c57e216069c7c0c223cc1819abc35ca9fe6
0539b0a1e77663ac4c701a88f56723d3e3688e8c
refs/heads/master
2020-12-24T17:36:39.856464
2014-04-23T06:29:14
2014-04-23T06:29:14
31,628,326
0
0
null
null
null
null
UTF-8
C++
false
false
44,195
cpp
// serialization/src/binary.cpp // // Copyright (c) 2007, 2008 Valentin Palade (vipalade @ gmail . com) // // This file is part of SolidFrame framework. // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. // #include "serialization/binary.hpp" #include "serialization/binarybasic.hpp" #include "utility/ostream.hpp" #include "utility/istream.hpp" #include "system/cstring.hpp" #include <cstring> namespace solid{ namespace serialization{ namespace binary{ #ifdef HAS_SAFE_STATIC /*static*/ Limits const& Limits::the(){ static const Limits l; return l; } #else Limits const& the_limits(){ static const Limits l; return l; } void once_limits(){ the_limits(); } /*static*/ Limits const& Limits::the(){ static boost::once_flag once = BOOST_ONCE_INIT; boost::call_once(&once_limits, once); return the_limits(); } #endif //======================================================================== /*static*/ const char *Base::errorString(const uint16 _err){ switch(_err){ case ERR_NOERROR: return "No error"; case ERR_ARRAY_LIMIT: return "Array limit"; case ERR_ARRAY_MAX_LIMIT: return "Array max limit"; case ERR_CONTAINER_LIMIT: return "Container limit"; case ERR_CONTAINER_MAX_LIMIT: return "Container max limit"; case ERR_STREAM_LIMIT: return "Stream limit"; case ERR_STREAM_CHUNK_MAX_LIMIT: return "Stream chunk max limit"; case ERR_STREAM_SEEK: return "Stream seek"; case ERR_STREAM_READ: return "Stream read"; case ERR_STREAM_WRITE: return "Stream write"; case ERR_STREAM_SENDER: return "Stream sender"; case ERR_STRING_LIMIT: return "String limit"; case ERR_STRING_MAX_LIMIT: return "String max limit"; case ERR_UTF8_LIMIT: return "Utf8 limit"; case ERR_UTF8_MAX_LIMIT: return "Utf8 max limit"; case ERR_POINTER_UNKNOWN: return "Unknown pointer type id"; case ERR_REINIT: return "Reinit error"; default: return "Unknown error"; }; } /*static*/ CbkReturnValueE Base::setStringLimit(Base& _rb, FncData &_rfd, void */*_pctx*/){ _rb.lmts.stringlimit = static_cast<size_t>(_rfd.s); return Success; } /*static*/ CbkReturnValueE Base::setStreamLimit(Base& _rb, FncData &_rfd, void */*_pctx*/){ _rb.lmts.streamlimit = _rfd.s; return Success; } /*static*/ CbkReturnValueE Base::setContainerLimit(Base& _rb, FncData &_rfd, void */*_pctx*/){ _rb.lmts.containerlimit = static_cast<size_t>(_rfd.s); return Success; } void Base::replace(const FncData &_rfd){ fstk.top() = _rfd; } CbkReturnValueE Base::popEStack(Base &_rb, FncData &, void */*_pctx*/){ _rb.estk.pop(); return Success; } //======================================================================== /*static*/ char* SerializerBase::storeValue(char *_pd, const uint8 _val){ return serialization::binary::store(_pd, _val); } /*static*/ char* SerializerBase::storeValue(char *_pd, const uint16 _val){ return serialization::binary::store(_pd, _val); } /*static*/ char* SerializerBase::storeValue(char *_pd, const uint32 _val){ return serialization::binary::store(_pd, _val); } /*static*/ char* SerializerBase::storeValue(char *_pd, const uint64 _val){ return serialization::binary::store(_pd, _val); } SerializerBase::~SerializerBase(){ } void SerializerBase::clear(){ run(NULL, 0, NULL); } void SerializerBase::doPushStringLimit(){ fstk.push(FncData(&Base::setStringLimit, 0, 0, rdefaultlmts.stringlimit)); } void SerializerBase::doPushStringLimit(size_t _v){ fstk.push(FncData(&Base::setStringLimit, 0, 0, _v)); } void SerializerBase::doPushStreamLimit(){ fstk.push(FncData(&Base::setStreamLimit, 0, 0, rdefaultlmts.streamlimit)); } void SerializerBase::doPushStreamLimit(uint64 _v){ fstk.push(FncData(&Base::setStreamLimit, 0, 0, _v)); } void SerializerBase::doPushContainerLimit(){ fstk.push(FncData(&Base::setContainerLimit, 0, 0, rdefaultlmts.containerlimit)); } void SerializerBase::doPushContainerLimit(size_t _v){ fstk.push(FncData(&Base::setContainerLimit, 0, 0, _v)); } int SerializerBase::run(char *_pb, unsigned _bl, void *_pctx){ cpb = pb = _pb; be = cpb + _bl; while(fstk.size()){ FncData &rfd = fstk.top(); switch((*reinterpret_cast<FncT>(rfd.f))(*this, rfd, _pctx)) { case Continue: continue; case Success: fstk.pop(); break; case Wait: goto Done; case Failure: resetLimits(); return -1; } } resetLimits(); Done: cassert(fstk.size() || fstk.empty() && estk.empty()); return cpb - pb; } template <> CbkReturnValueE SerializerBase::storeBinary<0>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.s); SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; uint32 len = rs.be - rs.cpb; if(len > _rfd.s) len = static_cast<uint32>(_rfd.s); memcpy(rs.cpb, _rfd.p, len); rs.cpb += len; _rfd.p = (char*)_rfd.p + len; _rfd.s -= len; idbgx(Debug::ser_bin, ""<<len); if(_rfd.s) return Wait; return Success; } template <> CbkReturnValueE SerializerBase::storeBinary<1>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; const unsigned len = rs.be - rs.cpb; if(len){ *rs.cpb = *reinterpret_cast<const char*>(_rfd.p); ++rs.cpb; return Success; } return Wait; } template <> CbkReturnValueE SerializerBase::storeBinary<2>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; const unsigned len = rs.be - rs.cpb; const char *ps = reinterpret_cast<const char*>(_rfd.p); if(len >= 2){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); rs.cpb += 2; return Success; }else if(len >= 1){ *(rs.cpb + 0) = *(ps + 0); _rfd.f = &SerializerBase::storeBinary<1>; _rfd.p = const_cast<char*>(ps + 1); rs.cpb += 1; } return Wait; } template <> CbkReturnValueE SerializerBase::storeBinary<4>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; const unsigned len = rs.be - rs.cpb; const char *ps = reinterpret_cast<const char*>(_rfd.p); if(len >= 4){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); rs.cpb += 4; return Success; }else if(len >= 3){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); _rfd.p = const_cast<char*>(ps + 3); _rfd.f = &SerializerBase::storeBinary<1>; rs.cpb += 3; return Wait; }else if(len >= 2){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); _rfd.p = const_cast<char*>(ps + 2); rs.cpb += 2; _rfd.f = &SerializerBase::storeBinary<2>; return Wait; }else if(len >= 1){ *(rs.cpb + 0) = *(ps + 0); _rfd.p = const_cast<char*>(ps + 1); rs.cpb += 1; _rfd.s = 3; }else{ _rfd.s = 4; } _rfd.f = &SerializerBase::storeBinary<0>; return Wait; } template <> CbkReturnValueE SerializerBase::storeBinary<8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; const unsigned len = rs.be - rs.cpb; const char *ps = reinterpret_cast<const char*>(_rfd.p); if(len >= 8){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); *(rs.cpb + 4) = *(ps + 4); *(rs.cpb + 5) = *(ps + 5); *(rs.cpb + 6) = *(ps + 6); *(rs.cpb + 7) = *(ps + 7); rs.cpb += 8; return Success; }else if(len >= 7){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); *(rs.cpb + 4) = *(ps + 4); *(rs.cpb + 5) = *(ps + 5); *(rs.cpb + 6) = *(ps + 6); _rfd.p = const_cast<char*>(ps + 7); _rfd.f = &SerializerBase::storeBinary<1>; rs.cpb += 7; return Wait; }else if(len >= 6){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); *(rs.cpb + 4) = *(ps + 4); *(rs.cpb + 5) = *(ps + 5); _rfd.p = const_cast<char*>(ps + 6); _rfd.f = &SerializerBase::storeBinary<2>; rs.cpb += 6; return Wait; }else if(len >= 5){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); *(rs.cpb + 4) = *(ps + 4); _rfd.p = const_cast<char*>(ps + 5); rs.cpb += 5; _rfd.s = 3; }else if(len >= 4){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); *(rs.cpb + 3) = *(ps + 3); _rfd.p = const_cast<char*>(ps + 4); _rfd.f = &SerializerBase::storeBinary<4>; rs.cpb += 4; return Wait; }else if(len >= 3){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); *(rs.cpb + 2) = *(ps + 2); _rfd.p = const_cast<char*>(ps + 3); rs.cpb += 3; _rfd.s = 5; }else if(len >= 2){ *(rs.cpb + 0) = *(ps + 0); *(rs.cpb + 1) = *(ps + 1); _rfd.p = const_cast<char*>(ps + 2); rs.cpb += 2; _rfd.s = 6; }else if(len >= 1){ *(rs.cpb + 0) = *(ps + 0); _rfd.p = const_cast<char*>(ps + 1); rs.cpb += 1; _rfd.s = 7; }else{ _rfd.s = 8; } _rfd.f = &SerializerBase::storeBinary<0>; return Wait; } template <> CbkReturnValueE SerializerBase::store<int8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(int8); _rfd.f = &SerializerBase::storeBinary<1>; return storeBinary<1>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<uint8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(uint8); _rfd.f = &SerializerBase::storeBinary<1>; return storeBinary<1>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<int16>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(int16); _rfd.f = &SerializerBase::storeBinary<2>; return storeBinary<2>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<uint16>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(uint16); _rfd.f = &SerializerBase::storeBinary<2>; return storeBinary<2>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<int32>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(int32); _rfd.f = &SerializerBase::storeBinary<4>; return storeBinary<4>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<uint32>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n); _rfd.s = sizeof(uint32); _rfd.f = &SerializerBase::storeBinary<4>; return storeBinary<4>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<int64>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(int64); _rfd.f = &SerializerBase::storeBinary<8>; return storeBinary<8>(_rb, _rfd, NULL); } template <> CbkReturnValueE SerializerBase::store<uint64>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""<<_rfd.n<<*((uint64*)_rfd.p)); _rfd.s = sizeof(uint64); _rfd.f = &SerializerBase::storeBinary<8>; return storeBinary<8>(_rb, _rfd, NULL); } /*template <> CbkReturnValueE SerializerBase::store<ulong>(Base &_rb, FncData &_rfd){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(ulong); _rfd.f = &SerializerBase::storeBinary; return Continue; }*/ template <> CbkReturnValueE SerializerBase::store<std::string>(Base &_rb, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rs.cpb) return Success; std::string * c = reinterpret_cast<std::string*>(_rfd.p); if(c->size() > rs.lmts.stringlimit){ rs.err = ERR_STRING_LIMIT; return Failure; } if(c->size() > CRCValue<uint64>::maximum()){ rs.err = ERR_STRING_MAX_LIMIT; return Failure; } const CRCValue<uint64> crcsz((uint64)c->size()); rs.estk.push(ExtData((uint64)crcsz)); rs.replace(FncData(&SerializerBase::storeBinary<0>, (void*)c->data(), _rfd.n, c->size())); rs.fstk.push(FncData(&Base::popEStack, NULL, _rfd.n)); rs.fstk.push(FncData(&SerializerBase::storeCross<uint64>, &rs.estk.top().u64(), _rfd.n)); return Continue; } CbkReturnValueE SerializerBase::storeStreamBegin(Base &_rb, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; int32 toread = rs.be - rs.cpb; if(toread < MINSTREAMBUFLEN) return Wait; rs.streamerr = 0; rs.streamsz = 0; if(_rfd.p == NULL){ rs.cpb = storeValue(rs.cpb, (uint16)0xffff); rs.pop();//returning ok will also pop storeStream return Success; } if(_rfd.s != -1ULL){ std::istream &ris = *reinterpret_cast<std::istream*>(_rfd.p); ris.seekg(_rfd.s); if( static_cast<int64>(_rfd.s) != ris.tellg() ){ rs.streamerr = ERR_STREAM_SEEK; rs.cpb = storeValue(rs.cpb, (uint16)0xffff); rs.pop();//returning ok will also pop storeStream } } return Success; } CbkReturnValueE SerializerBase::storeStreamCheck(Base &_rb, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rb)); if(!rs.cpb) return Success; if(_rfd.s > rs.lmts.streamlimit){ rs.streamerr = rs.err = ERR_STREAM_LIMIT; return Failure; } return Success; } CbkReturnValueE SerializerBase::storeStream(Base &_rb, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rs.cpb) return Success; int32 toread = rs.be - rs.cpb; if(toread < MINSTREAMBUFLEN) return Wait; toread -= 2;//the buffsize if(toread > _rfd.s){ toread = static_cast<int32>(_rfd.s); } if(toread > CRCValue<uint16>::maximum()){ toread = CRCValue<uint16>::maximum(); } if(toread == 0){ rs.cpb = storeValue(rs.cpb, (uint16)0); return Success; } std::istream &ris = *reinterpret_cast<std::istream*>(_rfd.p); ris.read(rs.cpb + 2, toread); int rv; if(ris.eof() || ris.fail()){ rv = -1; }else{ rv = ris.gcount(); } idbgx(Debug::ser_bin, "toread = "<<toread<<" rv = "<<rv); if(rv > 0){ if((rs.streamsz + rv) > rs.lmts.streamlimit){ rs.streamerr = rs.err = ERR_STREAM_LIMIT; idbgx(Debug::ser_bin, "ERR_STREAM_LIMIT"); return Failure; } toread = rv; const CRCValue<uint16> crcsz((uint16)toread); storeValue(rs.cpb, (uint16)crcsz); idbgx(Debug::ser_bin, "store crcsz = "<<crcsz<<" sz = "<<toread); idbgx(Debug::ser_bin, "store value "<<(uint16)crcsz); rs.cpb += toread + 2; rs.streamsz += toread; }else if(rv == 0){ idbgx(Debug::ser_bin, "done storing stream"); rs.cpb = storeValue(rs.cpb, (uint16)0); return Success; }else{ rs.streamerr = ERR_STREAM_READ; idbgx(Debug::ser_bin, "ERR_STREAM_READ"); rs.cpb = storeValue(rs.cpb, (uint16)0xffff); return Success; } if(_rfd.s != -1ULL){ _rfd.s -= toread; if(_rfd.s == 0){ return Continue; } } idbgx(Debug::ser_bin, "streamsz = "<<rs.streamsz); return Continue; } /*static*/ CbkReturnValueE SerializerBase::storeUtf8(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if((_rfd.s - 1) > rs.lmts.stringlimit){ rs.err = ERR_UTF8_LIMIT; return Failure; } if((_rfd.s - 1) > CRCValue<uint32>::maximum()){ rs.err = ERR_UTF8_MAX_LIMIT; return Failure; } _rfd.f = &SerializerBase::storeBinary<0>; return Continue; } /*static*/ CbkReturnValueE SerializerBase::storeCrossContinue(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if(!rs.cpb) return Success; uint32 &vsz = *reinterpret_cast<uint32*>(&_rfd.p); uint8 *pd = reinterpret_cast<uint8*>(rs.cpb); while(rs.cpb != rs.be && vsz){ *pd = (_rfd.s & 0xff); idbgx(Debug::ser_bin, "s = "<<_rfd.s<<" vsz = "<<vsz<<" *pd = "<<(int)*pd); ++pd; ++rs.cpb; if(vsz == 1){ _rfd.s >>= 4; }else{ _rfd.s >>= 8; } --vsz; } if(vsz == 0){ return Success; } _rfd.p = reinterpret_cast<void*>(vsz); return Wait; } template <> /*static*/ CbkReturnValueE SerializerBase::storeCross<uint8>(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if(!rs.cpb) return Success; const uint8 &v = *reinterpret_cast<const uint8*>(_rfd.p); const unsigned len = rs.be - rs.cpb; const unsigned vsz = crossSize(v); if(len >= vsz){ rs.cpb = binary::storeCross(rs.cpb, v); return Success; }else if(len >= 1){ uint8 *pd = reinterpret_cast<uint8*>(rs.cpb); *pd = ((v & 0xf) << 4) | (vsz - 1); _rfd.p = reinterpret_cast<void*>(vsz - 1); ++rs.cpb; _rfd.s = v >> 4; _rfd.f = storeCrossContinue; } return Wait; } template <> /*static*/ CbkReturnValueE SerializerBase::storeCross<uint16>(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if(!rs.cpb) return Success; const uint16 &v = *reinterpret_cast<const uint16*>(_rfd.p); const unsigned len = rs.be - rs.cpb; const unsigned vsz = crossSize(v); if(len >= vsz){ rs.cpb = binary::storeCross(rs.cpb, v); return Success; }else if(len >= 1){ uint8 *pd = reinterpret_cast<uint8*>(rs.cpb); *pd = ((v & 0xf) << 4) | (vsz - 1); _rfd.p = reinterpret_cast<void*>(vsz - 1); ++rs.cpb; _rfd.s = v >> 4; _rfd.f = storeCrossContinue; return Continue; } return Wait; } template <> /*static*/ CbkReturnValueE SerializerBase::storeCross<uint32>(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if(!rs.cpb) return Success; const uint32 &v = *reinterpret_cast<const uint32*>(_rfd.p); const unsigned len = rs.be - rs.cpb; const unsigned vsz = crossSize(v); if(len >= vsz){ rs.cpb = binary::storeCross(rs.cpb, v); return Success; }else if(len >= 1){ uint8 *pd = reinterpret_cast<uint8*>(rs.cpb); *pd = ((v & 0xf) << 4) | (vsz - 1); _rfd.p = reinterpret_cast<void*>(vsz - 1); ++rs.cpb; _rfd.s = v >> 4; _rfd.f = storeCrossContinue; return Continue; } return Wait; } template <> /*static*/ CbkReturnValueE SerializerBase::storeCross<uint64>(Base &_rs, FncData &_rfd, void */*_pctx*/){ SerializerBase &rs(static_cast<SerializerBase&>(_rs)); if(!rs.cpb) return Success; const uint64 &v = *reinterpret_cast<const uint64*>(_rfd.p); const unsigned len = rs.be - rs.cpb; const unsigned vsz = crossSize(v); if(len >= vsz){ rs.cpb = binary::storeCross(rs.cpb, v); return Success; }else if(len >= 1){ uint8 *pd = reinterpret_cast<uint8*>(rs.cpb); ++rs.cpb; *pd = ((v & 0xf) << 4) | (vsz - 1); _rfd.p = reinterpret_cast<void*>(vsz - 1); _rfd.s = v >> 4; _rfd.f = storeCrossContinue; return Continue; } return Wait; } //======================================================================== // Deserializer //======================================================================== /*static*/ const char* DeserializerBase::loadValue(const char *_ps, uint8 &_val){ return serialization::binary::load(_ps, _val); } /*static*/ const char* DeserializerBase::loadValue(const char *_ps, uint16 &_val){ return serialization::binary::load(_ps, _val); } /*static*/ const char* DeserializerBase::loadValue(const char *_ps, uint32 &_val){ return serialization::binary::load(_ps, _val); } /*static*/ const char* DeserializerBase::loadValue(const char *_ps, uint64 &_val){ return serialization::binary::load(_ps, _val); } DeserializerBase::~DeserializerBase(){ } void DeserializerBase::clear(){ idbgx(Debug::ser_bin, "clear_deser"); run(NULL, 0, NULL); } /*static*/ CbkReturnValueE DeserializerBase::loadTypeIdDone(Base& _rd, FncData &_rfd, void *_pctx){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); void *p = _rfd.p; const char *n = _rfd.n; if(!rd.cpb) return Success; rd.fstk.pop(); if(rd.typeMapper().prepareParsePointer(&rd, rd.tmpstr, p, n, _pctx)){ return Continue; }else{ idbgx(Debug::ser_bin, "error"); rd.err = ERR_POINTER_UNKNOWN; return Failure; } } /*static*/ CbkReturnValueE DeserializerBase::loadTypeId(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); if(!rd.cpb) return Success; rd.typeMapper().prepareParsePointerId(&rd, rd.tmpstr, _rfd.n); _rfd.f = &loadTypeIdDone; return Continue; } void DeserializerBase::doPushStringLimit(){ fstk.push(FncData(&Base::setStringLimit, 0, 0, rdefaultlmts.stringlimit)); } void DeserializerBase::doPushStringLimit(size_t _v){ fstk.push(FncData(&Base::setStringLimit, 0, 0, _v)); } void DeserializerBase::doPushStreamLimit(){ fstk.push(FncData(&Base::setStreamLimit, 0, 0, rdefaultlmts.streamlimit)); } void DeserializerBase::doPushStreamLimit(uint64 _v){ fstk.push(FncData(&Base::setStreamLimit, 0, 0, _v)); } void DeserializerBase::doPushContainerLimit(){ fstk.push(FncData(&Base::setContainerLimit, 0, 0, rdefaultlmts.containerlimit)); } void DeserializerBase::doPushContainerLimit(size_t _v){ fstk.push(FncData(&Base::setContainerLimit, 0, 0, _v)); } int DeserializerBase::run(const char *_pb, unsigned _bl, void *_pctx){ cpb = pb = _pb; be = pb + _bl; while(fstk.size()){ FncData &rfd = fstk.top(); switch((*reinterpret_cast<FncT>(rfd.f))(*this, rfd, _pctx)){ case Continue: continue; case Success: fstk.pop(); break; case Wait: goto Done; case Failure: idbgx(Debug::ser_bin, "error: "<<errorString()); resetLimits(); return -1; } } resetLimits(); Done: cassert(fstk.size() || fstk.empty() && estk.empty()); return cpb - pb; } template <> CbkReturnValueE DeserializerBase::loadBinary<0>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""<<_rfd.s); if(!rd.cpb) return Success; uint32 len = rd.be - rd.cpb; if(len > _rfd.s) len = static_cast<uint32>(_rfd.s); memcpy(_rfd.p, rd.cpb, len); rd.cpb += len; _rfd.p = (char*)_rfd.p + len; _rfd.s -= len; if(len == 1){ edbgx(Debug::ser_bin, ""); } idbgx(Debug::ser_bin, ""<<len); if(_rfd.s) return Wait; return Success; } template <> CbkReturnValueE DeserializerBase::loadBinary<1>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); idbgx(Debug::ser_bin, ""<<len<<' '<<(void*)rd.cpb); if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; return Success; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<2>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; return Success; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<1>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<3>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; return Success; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<2>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<4>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 4){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); rd.cpb += 4; return Success; }else if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; _rfd.p = ps + 3; edbgx(Debug::ser_bin, ""<<len<<' '<<(void*)rd.cpb); _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<2>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<3>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<5>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 5){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); rd.cpb += 5; return Success; }else if(len >= 4){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); rd.cpb += 4; _rfd.p = ps + 4; _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; _rfd.p = ps + 3; _rfd.f = &DeserializerBase::loadBinary<2>; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<3>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<4>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<6>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 6){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); rd.cpb += 6; return Success; }else if(len >= 5){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); rd.cpb += 5; _rfd.p = ps + 5; _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 4){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); rd.cpb += 4; _rfd.p = ps + 4; _rfd.f = &DeserializerBase::loadBinary<2>; }else if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; _rfd.p = ps + 3; _rfd.f = &DeserializerBase::loadBinary<3>; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<4>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<5>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<7>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 7){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); *(ps + 6) = *(rd.cpb + 6); rd.cpb += 7; return Success; }else if(len >= 6){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); rd.cpb += 6; _rfd.p = ps + 6; _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 5){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); rd.cpb += 5; _rfd.p = ps + 5; _rfd.f = &DeserializerBase::loadBinary<2>; }else if(len >= 4){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); rd.cpb += 4; _rfd.p = ps + 4; _rfd.f = &DeserializerBase::loadBinary<3>; }else if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; _rfd.p = ps + 3; _rfd.f = &DeserializerBase::loadBinary<4>; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<5>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<6>; } return Wait; } template <> CbkReturnValueE DeserializerBase::loadBinary<8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; char *ps = reinterpret_cast<char*>(_rfd.p); if(len >= 8){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); *(ps + 6) = *(rd.cpb + 6); *(ps + 7) = *(rd.cpb + 7); rd.cpb += 8; return Success; }else if(len >= 7){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); *(ps + 6) = *(rd.cpb + 6); rd.cpb += 7; _rfd.p = ps + 7; _rfd.f = &DeserializerBase::loadBinary<1>; }else if(len >= 6){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); *(ps + 5) = *(rd.cpb + 5); rd.cpb += 6; _rfd.p = ps + 6; _rfd.f = &DeserializerBase::loadBinary<2>; }else if(len >= 5){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); *(ps + 4) = *(rd.cpb + 4); rd.cpb += 5; _rfd.p = ps + 5; _rfd.f = &DeserializerBase::loadBinary<3>; }else if(len >= 4){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); *(ps + 3) = *(rd.cpb + 3); rd.cpb += 4; _rfd.p = ps + 4; _rfd.f = &DeserializerBase::loadBinary<4>; }else if(len >= 3){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); *(ps + 2) = *(rd.cpb + 2); rd.cpb += 3; _rfd.p = ps + 3; _rfd.f = &DeserializerBase::loadBinary<5>; }else if(len >= 2){ *(ps + 0) = *(rd.cpb + 0); *(ps + 1) = *(rd.cpb + 1); rd.cpb += 2; _rfd.p = ps + 2; _rfd.f = &DeserializerBase::loadBinary<6>; }else if(len >= 1){ *(ps + 0) = *(rd.cpb + 0); rd.cpb += 1; _rfd.p = ps + 1; _rfd.f = &DeserializerBase::loadBinary<7>; } return Wait; } template <> CbkReturnValueE DeserializerBase::load<int8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(int8); _rfd.f = &DeserializerBase::loadBinary<1>; return loadBinary<1>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<uint8>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(uint8); _rfd.f = &DeserializerBase::loadBinary<1>; return loadBinary<1>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<int16>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(int16); _rfd.f = &DeserializerBase::loadBinary<2>; return loadBinary<2>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<uint16>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(uint16); _rfd.f = &DeserializerBase::loadBinary<2>; return loadBinary<2>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<int32>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(int32); _rfd.f = &DeserializerBase::loadBinary<4>; return loadBinary<4>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<uint32>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(uint32); _rfd.f = &DeserializerBase::loadBinary<4>; return loadBinary<4>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<int64>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(int64); _rfd.f = &DeserializerBase::loadBinary<8>; return loadBinary<8>(_rb, _rfd, NULL); } template <> CbkReturnValueE DeserializerBase::load<uint64>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(uint64); _rfd.f = &DeserializerBase::loadBinary<8>; return loadBinary<8>(_rb, _rfd, NULL); } /*template <> CbkReturnValueE DeserializerBase::load<ulong>(Base &_rb, FncData &_rfd){ idbgx(Debug::ser_bin, ""); _rfd.s = sizeof(ulong); _rfd.f = &DeserializerBase::loadBinary; return Continue; }*/ template <> CbkReturnValueE DeserializerBase::load<std::string>(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, "load generic non pointer string"); DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; rd.estk.push(ExtData((uint64)0)); rd.replace(FncData(&DeserializerBase::loadBinaryString, _rfd.p, _rfd.n)); rd.fstk.push(FncData(&DeserializerBase::loadBinaryStringCheck, NULL, _rfd.n)); rd.fstk.push(FncData(&DeserializerBase::loadCross<uint64>, &rd.estk.top().u64())); return Continue; } CbkReturnValueE DeserializerBase::loadBinaryStringCheck(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; const uint64 len = rd.estk.top().u64(); if(len != static_cast<uint64>(-1)){ const CRCValue<uint64> crcsz(CRCValue<uint64>::check_and_create(len)); if(crcsz.ok()){ rd.estk.top().u64() = crcsz.value(); }else{ rd.err = ERR_STRING_MAX_LIMIT; return Failure; } } uint64 ul = rd.estk.top().u64(); if(ul >= rd.lmts.stringlimit){ idbgx(Debug::ser_bin, "error"); rd.err = ERR_STRING_LIMIT; return Failure; } return Success; } CbkReturnValueE DeserializerBase::loadBinaryString(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); if(!rd.cpb){ rd.estk.pop(); return Success; } size_t len = rd.be - rd.cpb; uint64 ul = rd.estk.top().u64(); if(len > ul){ len = static_cast<size_t>(ul); } std::string *ps = reinterpret_cast<std::string*>(_rfd.p); ps->append(rd.cpb, len); rd.cpb += len; ul -= len; if(ul){ rd.estk.top().u64() = ul; return Wait; } idbgx(Debug::ser_bin, ""<<*ps); rd.estk.pop(); return Success; } CbkReturnValueE DeserializerBase::loadStreamCheck(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; if(_rfd.s > static_cast<int64>(rd.lmts.streamlimit)){ idbgx(Debug::ser_bin, "error"); rd.err = ERR_STREAM_LIMIT; return Failure; } return Success; } CbkReturnValueE DeserializerBase::loadStreamBegin(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; rd.streamerr = 0; rd.streamsz = 0; if(_rfd.p == NULL){ rd.pop(); rd.fstk.top().f = &DeserializerBase::loadDummyStream; rd.fstk.top().s = 0; return Continue; } if(_rfd.s != -1ULL){ std::ostream &ros = *reinterpret_cast<std::ostream*>(_rfd.p); ros.seekp(_rfd.s); if( static_cast<int64>(_rfd.s) != ros.tellp() ){ rd.streamerr = ERR_STREAM_SEEK; rd.pop(); rd.fstk.top().f = &DeserializerBase::loadDummyStream; rd.fstk.top().s = 0; return Continue; } } return Success; } CbkReturnValueE DeserializerBase::loadStream(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; int32 towrite = rd.be - rd.cpb; if(towrite < 2){ return Wait; } towrite -= 2; if(towrite > _rfd.s){ towrite = static_cast<int32>(_rfd.s); } uint16 sz(0); rd.cpb = loadValue(rd.cpb, sz); idbgx(Debug::ser_bin, "sz = "<<sz); if(sz == 0xffff){//error on storing side - the stream is incomplete idbgx(Debug::ser_bin, "error on storing side"); rd.streamerr = ERR_STREAM_SENDER; return Success; }else{ CRCValue<uint16> crcsz(CRCValue<uint16>::check_and_create(sz)); if(crcsz.ok()){ sz = crcsz.value(); }else{ rd.streamerr = rd.err = ERR_STREAM_CHUNK_MAX_LIMIT; idbgx(Debug::ser_bin, "crcval = "<<crcsz.value()<<" towrite = "<<towrite); return Failure; } } if(towrite > sz) towrite = sz; idbgx(Debug::ser_bin, "towrite = "<<towrite); if(towrite == 0){ return Success; } if((rd.streamsz + towrite) > rd.lmts.streamlimit){ idbgx(Debug::ser_bin, "ERR_STREAM_LIMIT"); rd.streamerr = rd.err = ERR_STREAM_LIMIT; return Failure; } std::ostream &ros = *reinterpret_cast<std::ostream*>(_rfd.p); ros.write(rd.cpb, towrite); int rv; if(ros.fail() || ros.eof()){ rv = -1; }else{ rv = towrite; } rd.cpb += sz; if(_rfd.s != -1ULL){ _rfd.s -= towrite; idbgx(Debug::ser_bin, "_rfd.s = "<<_rfd.s); if(_rfd.s == 0){ _rfd.f = &loadDummyStream; _rfd.s = rd.streamsz + sz; } } if(rv != towrite){ rd.streamerr = ERR_STREAM_WRITE; _rfd.f = &loadDummyStream; _rfd.s = rd.streamsz + sz; }else{ rd.streamsz += rv; } idbgx(Debug::ser_bin, "streamsz = "<<rd.streamsz); return Continue; } CbkReturnValueE DeserializerBase::loadDummyStream(Base &_rb, FncData &_rfd, void */*_pctx*/){ idbgx(Debug::ser_bin, ""); DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); if(!rd.cpb) return Success; int32 towrite = rd.be - rd.cpb; if(towrite < 2){ return Wait; } towrite -= 2; if(towrite > _rfd.s){ towrite = static_cast<int32>(_rfd.s); } uint16 sz(0); rd.cpb = loadValue(rd.cpb, sz); idbgx(Debug::ser_bin, "sz = "<<sz); if(sz == 0xffff){//error on storing side - the stream is incomplete rd.streamerr = ERR_STREAM_SENDER; return Success; }else if(sz == 0){ return Success; }else{ CRCValue<uint16> crcsz(CRCValue<uint16>::check_and_create(sz)); if(crcsz.ok()){ sz = crcsz.value(); }else{ rd.streamerr = rd.err = ERR_STREAM_CHUNK_MAX_LIMIT; idbgx(Debug::ser_bin, "crcval = "<<crcsz.value()<<" towrite = "<<towrite); return Failure; } } rd.cpb += sz; _rfd.s += sz; if(_rfd.s > rd.lmts.streamlimit){ idbgx(Debug::ser_bin, "ERR_STREAM_LIMIT"); rd.streamerr = rd.err = ERR_STREAM_LIMIT; return Failure; } return Continue; } CbkReturnValueE DeserializerBase::loadUtf8(Base &_rb, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rb)); idbgx(Debug::ser_bin, ""); std::string *ps = reinterpret_cast<std::string*>(_rfd.p); unsigned len = rd.be - rd.cpb; size_t slen = cstring::nlen(rd.cpb, len); size_t totlen = ps->size() + slen; idbgx(Debug::ser_bin, "len = "<<len); if(totlen > rd.lmts.stringlimit){ rd.err = ERR_UTF8_LIMIT; return Failure; } if(totlen > CRCValue<uint32>::maximum()){ rd.err = ERR_UTF8_MAX_LIMIT; return Failure; } ps->append(rd.cpb, slen); rd.cpb += slen; if(slen == len){ return Wait; } ++rd.cpb; return Success; } /* * _rfd.s contains the size of the value data * estk.top contains the uint64 value * _rfd.p contains the current index */ /*static*/ CbkReturnValueE DeserializerBase::loadCrossContinue(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); if(!rd.cpb) return Success; uint32 &rcrtidx = *reinterpret_cast<uint32*>(&_rfd.p); idbgx(Debug::ser_bin, ""<<rcrtidx); while(rd.cpb != rd.be && _rfd.s){ const uint8 *ps = reinterpret_cast<const uint8*>(rd.cpb); uint64 tmp = *ps; idbgx(Debug::ser_bin, " v = "<<rd.estk.top().u64()<<" sz = "<<_rfd.s<<" ridx = "<<rcrtidx<<" *ps = "<<tmp); rd.estk.top().u64() |= (tmp << rcrtidx); rcrtidx += 8; --_rfd.s; ++rd.cpb; } if(!_rfd.s){ return Success; } return Wait; } template <> /*static*/ CbkReturnValueE DeserializerBase::loadCross<uint8>(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; if(!len) return Wait; const unsigned vsz = crossSize(rd.cpb); uint8 &v = *reinterpret_cast<uint8*>(_rfd.p); if(vsz < len){ rd.cpb = binary::loadCross(rd.cpb, v); return Success; } const uint8 *ps = reinterpret_cast<const uint8*>(rd.cpb); ++rd.cpb; rd.estk.push(ExtData((uint64)0)); rd.estk.top().u64() = (*ps >> 4); _rfd.f = loadCrossContinue; _rfd.s = vsz; rd.fstk.push(_rfd); _rfd.f = loadCrossDone<uint8>; _rfd.p = reinterpret_cast<void*>(4); return Continue; } template <> /*static*/ CbkReturnValueE DeserializerBase::loadCross<uint16>(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; if(!len) return Wait; const unsigned vsz = crossSize(rd.cpb); uint16 &v = *reinterpret_cast<uint16*>(_rfd.p); if(vsz < len){ rd.cpb = binary::loadCross(rd.cpb, v); return Success; } const uint8 *ps = reinterpret_cast<const uint8*>(rd.cpb); ++rd.cpb; rd.estk.push(ExtData((uint64)0)); rd.estk.top().u64() = (*ps >> 4); _rfd.f = loadCrossContinue; _rfd.s = vsz; rd.fstk.push(_rfd); _rfd.f = loadCrossDone<uint16>; _rfd.p = reinterpret_cast<void*>(4); return Continue; } template <> /*static*/ CbkReturnValueE DeserializerBase::loadCross<uint32>(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; if(!len) return Wait; const unsigned vsz = crossSize(rd.cpb); uint32 &v = *reinterpret_cast<uint32*>(_rfd.p); if(vsz < len){ rd.cpb = binary::loadCross(rd.cpb, v); return Success; } const uint8 *ps = reinterpret_cast<const uint8*>(rd.cpb); ++rd.cpb; rd.estk.push(ExtData((uint64)0)); rd.estk.top().u64() = (*ps >> 4); _rfd.f = loadCrossContinue; _rfd.s = vsz; rd.fstk.push(_rfd); _rfd.f = loadCrossDone<uint32>; rd.fstk.top().p = reinterpret_cast<void*>(4); return Continue; } template <> /*static*/ CbkReturnValueE DeserializerBase::loadCross<uint64>(Base& _rd, FncData &_rfd, void */*_pctx*/){ DeserializerBase &rd(static_cast<DeserializerBase&>(_rd)); idbgx(Debug::ser_bin, ""); if(!rd.cpb) return Success; const unsigned len = rd.be - rd.cpb; if(!len) return Wait; const unsigned vsz = crossSize(rd.cpb); uint64 &v = *reinterpret_cast<uint64*>(_rfd.p); if(vsz < len){ rd.cpb = binary::loadCross(rd.cpb, v); idbgx(Debug::ser_bin, ""<<(rd.be - rd.cpb)<<" vsz = "<<vsz<<" len = "<<len); return Success; } const uint8 *ps = reinterpret_cast<const uint8*>(rd.cpb); ++rd.cpb; rd.estk.push(ExtData((uint64)0)); rd.estk.top().u64() = (*ps >> 4); _rfd.f = loadCrossContinue; _rfd.s = vsz; rd.fstk.push(_rfd); _rfd.f = loadCrossDone<uint64>; rd.fstk.top().p = reinterpret_cast<void*>(4); return Continue; } //======================================================================== //======================================================================== }//namespace binary }//namespace serialization }//namespace solid
[ "vipalade@0b79f258-eccb-fe0a-0eba-1848281d3a48" ]
vipalade@0b79f258-eccb-fe0a-0eba-1848281d3a48
6207011518ead05ac4aade52eb83d36c44d5c819
b837a750980b6a9389541cad2cbd4ad054f34e88
/Chpt12/stringreplace.cpp
760fe435babb86112007c27af9f3e9a6aec122d8
[]
no_license
taekyom/StudyCPP
58bcfa3d5e7f8ecd555f6028004867d98272a3f1
7cf37a8eba585404a051da05e8c2ebf0cd98476e
refs/heads/main
2023-06-08T23:03:49.448218
2021-06-11T09:29:22
2021-06-11T09:29:22
371,540,370
0
0
null
null
null
null
UHC
C++
false
false
198
cpp
#include<iostream> #include<string> using namespace std; int main() { string s1 = "독도는 우리땅"; cout << s1 << endl; s1.replace(7, 4, "대한민국"); cout << s1 << endl; return 0; }
[ "tkyoung1014@naver.com" ]
tkyoung1014@naver.com
6202bda7ec8c373c60a0e10a6df26f368afc09de
7b67cab222fa108d3bb9728ac5ccb8dccb820435
/AnalysisObjects/interface/SimpleElectron.h
2d7611681e340eb268e63fb14c7526c3f2e12bba
[]
no_license
lsilvamiguel/usercode
5fbfa224c0be162df350cff8a6964e15d665b925
16e28f8126b844775853c58c0e6bba3a24e106dc
refs/heads/master
2021-01-09T05:57:56.039791
2016-12-21T16:05:30
2016-12-21T16:05:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,856
h
#ifndef SIMPLEELECTRON_H #define SIMPLEELECTRON_H #include "FWCore/Framework/interface/Frameworkfwd.h" #include "AnalysisExamples/AnalysisObjects/interface/BaseParticle.h" #include <cmath> #include <vector> /** * * Stores an offline electron. Inlcudes Et, had/em fraction and * isolation. * * Inherits from BaseParticle. * * Author M. De Mattia - 8/11/2007 * */ namespace anaobj { class SimpleElectron : public BaseParticle { public: SimpleElectron( const double & PT, const double & ETA, const double & PHI, const int CHARGE, const math::XYZTLorentzVector & P4, const math::XYZPoint & VERTEX, const double & ET, const double & HADOVEREM, const double & ISOVAL, const double & IMPACTPARAMXY, const double & ERRORIMPACTPARAMXY) : BaseParticle( PT, ETA, PHI ) { charge_ = CHARGE; p4_ = P4; vertex_ = VERTEX; et_ = ET; hadOverEm_ = HADOVEREM; isoVal_ = ISOVAL; impactParamXY_ = IMPACTPARAMXY; errorImpactParamXY_ = ERRORIMPACTPARAMXY; } /// Default constructor, only needed for classes.h SimpleElectron() : BaseParticle( 0., 0., 0. ) { charge_ = 0; p4_ = math::XYZTLorentzVector(0.,0.,0.,0.); vertex_ = math::XYZPoint(0.,0.,0.); et_ = 0.; hadOverEm_ = 0.; isoVal_ = 0.; impactParamXY_ = 0.; errorImpactParamXY_ = 0.; } int charge() const { return charge_; } math::XYZTLorentzVector p4() const { return p4_; } math::XYZPoint vertex() const { return vertex_; } double et() const { return et_; } double hadOverEm() const { return hadOverEm_; } double isoVal() const { return isoVal_; } double impactParamXY() const { return impactParamXY_; } double errorImpactParamXY() const { return errorImpactParamXY_; } void setCharge( const int CHARGE ) { charge_ = CHARGE; } void setP4( const math::XYZTLorentzVector & P4 ) { p4_ = P4; } void setVertex( const math::XYZPoint & VERTEX ) { vertex_ = VERTEX; } void setEt( const double & ET ) { et_ = ET; } void setHadOverEm( const double & HADOVEREM ) { hadOverEm_ = HADOVEREM; } void setIsoVal( const double & ISOVAL ) { isoVal_ = ISOVAL; } void setImpactParamXY( const double & IMPACTPARAMXY ) { impactParamXY_ = IMPACTPARAMXY; } void setErrorImpactParamXY( const double & ERRORIMPACTPARAMXY ) { errorImpactParamXY_ = ERRORIMPACTPARAMXY; } protected: int charge_; math::XYZTLorentzVector p4_; math::XYZPoint vertex_; double et_; double hadOverEm_; double isoVal_; double impactParamXY_; double errorImpactParamXY_; }; typedef std::vector<SimpleElectron> SimpleElectronCollection; } #endif // GLOBALMUON_H
[ "" ]
65d0bc100b9e1f987651c9a5ca1ee046267f0831
142b7c757e236c214b8fef6e664ced8408b107ce
/src/stereo_frontend/include/opengv/src/relative_pose/CentralRelativeWeightingAdapter.cpp
4ad0df77fd9a92b24c740364365c2bf80c816716
[]
no_license
tshellum/multisensor-SLAM
4fd68658b616d44bdaa56f1593fdca70328e66e0
e05f555f7896e19f135c1fdcbf25deecaca6aa48
refs/heads/main
2023-05-25T21:34:16.926115
2021-06-03T09:59:51
2021-06-03T09:59:51
329,314,686
5
1
null
null
null
null
UTF-8
C++
false
false
5,451
cpp
/****************************************************************************** * Author: Laurent Kneip * * Contact: kneip.laurent@gmail.com * * License: Copyright (c) 2013 Laurent Kneip, ANU. 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 ANU 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 ANU OR THE 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 "../../include/relative_pose/CentralRelativeWeightingAdapter.hpp" opengv::relative_pose::CentralRelativeWeightingAdapter::CentralRelativeWeightingAdapter( const bearingVectors_t & bearingVectors1, const bearingVectors_t & bearingVectors2, const std::vector<double> & weights ) : RelativeAdapterBase(), _bearingVectors1(bearingVectors1), _bearingVectors2(bearingVectors2), _weights(weights) {} opengv::relative_pose::CentralRelativeWeightingAdapter::CentralRelativeWeightingAdapter( const bearingVectors_t & bearingVectors1, const bearingVectors_t & bearingVectors2, const std::vector<double> & weights, const rotation_t & R12 ) : RelativeAdapterBase(R12), _bearingVectors1(bearingVectors1), _bearingVectors2(bearingVectors2), _weights(weights) {} opengv::relative_pose::CentralRelativeWeightingAdapter::CentralRelativeWeightingAdapter( const bearingVectors_t & bearingVectors1, const bearingVectors_t & bearingVectors2, const std::vector<double> & weights, const translation_t & t12, const rotation_t & R12 ) : RelativeAdapterBase(t12,R12), _bearingVectors1(bearingVectors1), _bearingVectors2(bearingVectors2), _weights(weights) {} opengv::relative_pose::CentralRelativeWeightingAdapter::~CentralRelativeWeightingAdapter() {} opengv::bearingVector_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getBearingVector1( size_t index ) const { assert(index < _bearingVectors1.size()); return _bearingVectors1[index]; } opengv::bearingVector_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getBearingVector2( size_t index ) const { assert(index < _bearingVectors2.size()); return _bearingVectors2[index]; } double opengv::relative_pose::CentralRelativeWeightingAdapter:: getWeight( size_t index ) const { assert(index < _weights.size()); return _weights[index]; } opengv::translation_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getCamOffset1( size_t index ) const { //We could also check here for camIndex being 0, because this adapter is made //for a single camera only return Eigen::Vector3d::Zero(); } opengv::rotation_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getCamRotation1( size_t index ) const { //We could also check here for camIndex being 0, because this adapter is made //for a single camera only return Eigen::Matrix3d::Identity(); } opengv::translation_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getCamOffset2( size_t index ) const { //We could also check here for camIndex being 0, because this adapter is made //for a single camera only return Eigen::Vector3d::Zero(); } opengv::rotation_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getCamRotation2( size_t index ) const { //We could also check here for camIndex being 0, because this adapter is made //for a single camera only return Eigen::Matrix3d::Identity(); } size_t opengv::relative_pose::CentralRelativeWeightingAdapter:: getNumberCorrespondences() const { return _bearingVectors2.size(); }
[ "thomas.s.hellum@gmail.com" ]
thomas.s.hellum@gmail.com
d74efe920ec0250d311d67cefb109b9f909c6fd0
08ef02482029eb342f8eb03a618d32744638f7fe
/AGVDemo/LiftControl.cpp
05ab0fa387121f23f3135befad4cf61da989eeb8
[]
no_license
DDANGEUN/JellibiAGV
9e146026f8ebdd6f196495ca88854e2a4a4c969d
5e1193757a775acb623c965c21a364e20ee00df5
refs/heads/master
2020-09-05T16:55:00.188080
2019-11-11T07:18:46
2019-11-11T07:18:46
216,968,582
0
1
null
null
null
null
UTF-8
C++
false
false
1,412
cpp
/** * Copyright (c) 2019 Robot&More, jhlee@robotnmore.com(signaled@gmail.com) * * See the file license.txt for copying permission */ #include "LiftControl.h" #include "Define.h" LiftControl::LiftControl(uint8_t servo1Pin, uint8_t servo2Pin) : _liftState(false) , _servo1Pin(servo1Pin) , _servo2Pin(servo2Pin) { } void LiftControl::Init() { _servo1.attach(_servo1Pin); _servo2.attach(_servo2Pin); // default to Lift down state _servo1.write(SERVO1_PUTDOWN_ANGLE); _servo2.write(SERVO2_PUTDOWN_ANGLE); } void LiftControl::LiftUP() { if (_liftState) { return; } for ( int i =0; i <= MOVE_STEP; i++) { int angle1 = map(i, 0, MOVE_STEP, SERVO1_PUTDOWN_ANGLE, SERVO1_LIFTUP_ANGLE); int angle2 = map(i, 0, MOVE_STEP, SERVO2_PUTDOWN_ANGLE, SERVO2_LIFTUP_ANGLE); _servo1.write(angle1); _servo2.write(angle2); delay(20 + (MOVE_STEP - i)*2); } _liftState = true; } void LiftControl::LiftDown() { if (!_liftState) { return; } for ( int i =0; i <= MOVE_STEP; i++) { int angle1 = map(i, 0, MOVE_STEP, SERVO1_LIFTUP_ANGLE, SERVO1_PUTDOWN_ANGLE); int angle2 = map(i, 0, MOVE_STEP, SERVO2_LIFTUP_ANGLE, SERVO2_PUTDOWN_ANGLE); _servo1.write(angle1); _servo2.write(angle2); delay(20 + (MOVE_STEP - i)*2); } _liftState = false; }
[ "poetic_star@naver.com" ]
poetic_star@naver.com
49280126477fc400a0d0231b7f13a66676a9a8b5
b6a4cec0400b016205f86ab68987116ae2bb9427
/ardrone_urbi/include/libport/sys/select.h
3013c1ccfd8933feec6b3644b1dd64c33db89eb3
[]
no_license
pong3489/Projet_ARDrone_Track
5d96133e31ccffedbad7f1be71b48134634deda3
d5544a6cc18b0e355eaed131a3b4e65b97a96887
refs/heads/master
2021-01-18T00:45:17.313010
2014-02-18T20:38:53
2014-02-18T20:38:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,460
h
/* * Copyright (C) 2008-2010, Gostai S.A.S. * * This software is provided "as is" without warranty of any kind, * either expressed or implied, including but not limited to the * implied warranties of fitness for a particular purpose. * * See the LICENSE file for more information. */ /// \file libport/sys/select.h #ifndef LIBPORT_SYS_SELECT_H # define LIBPORT_SYS_SELECT_H # include <libport/detect-win32.h> # ifndef WIN32 # include <sys/select.h> # else # include <libport/sys/socket.h> # endif /*---------. | fd_set. | `---------*/ # ifdef WIN32 // On windows, file descriptors are defined as u_int (i.e., unsigned int). # define LIBPORT_FD_SET(N, P) FD_SET(static_cast<u_int>(N), P) # else # define LIBPORT_FD_SET(N, P) FD_SET(N, P) # endif // On MingW, using "mingw32-gcc.exe (GCC) 3.4.5 (mingw special)", it // seems that FD_ISSSET casts its argument as "fd_set*", without // const. # define LIBPORT_FD_ISSET(I, S) FD_ISSET(I, const_cast<fd_set*> (S)) # include <iostream> namespace std { inline std::ostream& operator<< (std::ostream& o, const fd_set& s) { o << "fd_set {"; bool not_first = false; # ifndef WIN32 for (int i = 0; i < FD_SETSIZE; ++i) if (LIBPORT_FD_ISSET(i, &s)) o << (not_first++ ? ", " : "") << i; # else for (unsigned int i = 0; i < s.fd_count; ++i) o << (not_first++ ? ", " : "") << s.fd_array[i]; # endif return o << " }"; } } #endif // !LIBPORT_SYS_SELECT_H
[ "grancherlaura@gmail.com" ]
grancherlaura@gmail.com
de7d67e591aa3c52e2af657f4d04836196586a0a
4edd72f7d77e42b94cbcfdd07b0996408313b727
/audioTest/main.cpp
f4a400c7681522300fc30391ea4d8cba59b486b1
[]
no_license
jerryxiee/trunk
e4f6a751bf289a63ae84c0fcb153f037a2f3b555
efe4cc168a3af52c44ee9ea57c78a31bba0f0fbf
refs/heads/main
2023-02-10T02:53:09.146507
2021-01-08T07:24:10
2021-01-08T07:24:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,271
cpp
#include "mainwindow.h" #include <QtGui/QApplication> #include <QtCore/QDir> #include <QtGui/QWSServer> #include <QtCore/QTextCodec> #include <log4cplus/ndc.h> #include <log4cplus/logger.h> #include <log4cplus/fileappender.h> #include <log4cplus/layout.h> #include <log4cplus/loggingmacros.h> using namespace log4cplus; using namespace log4cplus::helpers; int main(int argc, char *argv[]) { SharedAppenderPtr _append(new RollingFileAppender("/tmp/audioTest.log", 3 * 1024 * 1024, 5)); _append->setName("QT"); std::string pattern("%D{%m/%d/%y %H:%M:%S} : %m [%F:%L]%n"); _append->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern))); Logger::getRoot().addAppender(_append); Logger root = Logger::getRoot(); QApplication app(argc, argv); //app.setQuitOnLastWindowClosed(false); QWSServer::setCursorVisible(false); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QFont font("WenQuanYi Micro Hei"); font.setPixelSize(18); app.setFont(font); // 设置工作目录为应用程序所在目录 QDir::setCurrent(QCoreApplication::applicationDirPath()); MainWindow w; w.showFullScreen(); return app.exec(); }
[ "macian@foxmail.com" ]
macian@foxmail.com
5757d5ac0ed578a44d3e4b29d1ee6512ca9a60d8
0b63fa8325233e25478b76d0b4a9a6ee3070056d
/src/appleseed/renderer/modeling/shadergroup/shadergroup.h
76b1c72072d1f2e32a5dfe64552365583ffa0230
[ "MIT" ]
permissive
hipopotamo-hipotalamo/appleseed
e8c61ccec64baf01b6aeb3cde4dd3031d37ece17
eaf07e3e602218a35711e7495ac633ce210c6078
refs/heads/master
2020-12-07T02:39:27.454003
2013-10-29T13:10:59
2013-10-29T13:10:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,616
h
// // This source file is part of appleseed. // Visit http://appleseedhq.net/ for additional information and resources. // // This software is released under the MIT license. // // Copyright (c) 2010-2012 Esteban Tovagliari, Jupiter Jazz Limited // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #ifndef APPLESEED_RENDERER_MODELING_SHADERGROUP_SHADERGROUP_H #define APPLESEED_RENDERER_MODELING_SHADERGROUP_SHADERGROUP_H // appleseed.renderer headers. #include "renderer/modeling/entity/entity.h" // appleseed.foundation headers. #include "foundation/platform/compiler.h" #include "foundation/utility/autoreleaseptr.h" // appleseed.main headers. #include "main/dllsymbol.h" // Standard headers. #include <cstddef> // OSL headers. #include <OSL/oslexec.h> namespace renderer { // // OSL Shadergroup. // class DLLSYMBOL ShaderGroup : public Entity { public: virtual void release() OVERRIDE; // Return a string identifying the model of this shadergroup. const char* get_model() const; // Adds a new shader to the group. void add_shader(const char* type, const char* name, const char* layer); // Adds a new shader to the group. void add_shader(const char* name, const char* layer); // Sets a parameter value for the last added shader. void add_int_parameter(const char*name, int value); void add_float_parameter(const char*name, float value); void add_vector_parameter(const char* name, float vx, float vy, float vz); void add_point_parameter(const char* name, float vx, float vy, float vz); void add_color_parameter(const char* name, float vx, float vy, float vz); void add_string_parameter(const char* name, const char* value); // Adds a connection between two parameters of two shaders. void add_connection(const char* src_layer, const char* src_param, const char* dst_layer, const char* dst_param); private: friend class ShaderGroupFactory; struct Impl; Impl* impl; // Constructor. ShaderGroup( const char* name, const ParamArray& params); // Destructor ~ShaderGroup(); }; // // ShaderGroup factory. // class DLLSYMBOL ShaderGroupFactory { public: // Return a string identifying this ShaderGroup model. static const char* get_model(); // Create a new ShaderGroup. static foundation::auto_release_ptr<ShaderGroup> create( const char* name, const ParamArray& params); }; } // namespace renderer #endif // !APPLESEED_RENDERER_MODELING_SHADERGROUP_SHADERGROUP_H
[ "ramenhdr@gmail.com" ]
ramenhdr@gmail.com
7fb5cf12af941902733112b57e382f9e210a3fec
36c31b485a5906ab514c964491b8f001a70a67f5
/Codeforces/CF 1800 - 1899/CF1859/CF1859D.cpp
61c245d67a5c5a89249f55df02f1017ed30b4f24
[]
no_license
SMiles02/CompetitiveProgramming
77926918d5512824900384639955b31b0d0a5841
035040538c7e2102a88a2e3587e1ca984a2d9568
refs/heads/master
2023-08-18T22:14:09.997704
2023-08-13T20:30:42
2023-08-13T20:30:42
277,504,801
25
5
null
2022-11-01T01:34:30
2020-07-06T09:54:44
C++
UTF-8
C++
false
false
1,793
cpp
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include <bits/stdc++.h> using namespace std; void solve() { int n, q, cnt = 0; cin >> n; vector<array<int, 4>> p(n); map<int, int> hash, reverse_hash; set<int> s; for (auto &i : p) { for (auto &j : i) { cin >> j; s.insert(j); } } cin >> q; vector<int> qa(q), ans(q); for (int i = 0; i < q; ++i) { cin >> qa[i]; s.insert(qa[i]); } for (int i : s) { hash[i] = cnt; reverse_hash[cnt] = i; ++cnt; } priority_queue<int> active_b; vector<vector<int>> start_here(cnt), end_here(cnt), queries(cnt); vector<int> ans_at_point(cnt), active_b_cnt(cnt); for (auto &i : p) { start_here[hash[i[1]]].push_back(hash[i[3]]); end_here[hash[i[0]]].push_back(hash[i[3]]); } for (int i = 0; i < q; ++i) { queries[hash[qa[i]]].push_back(i); } for (int i = cnt - 1; i >= 0; --i) { for (int j : start_here[i]) { active_b.push(j); ++active_b_cnt[j]; } ans_at_point[i] = i; while (!active_b.empty() && active_b_cnt[active_b.top()] == 0) { active_b.pop(); } if (!active_b.empty()) { ans_at_point[i] = max(ans_at_point[i], ans_at_point[active_b.top()]); } for (int j : queries[i]) { ans[j] = ans_at_point[i]; } for (int j : end_here[i]) { --active_b_cnt[j]; } } for (int i : ans) { cout << reverse_hash[i] << " "; } cout << "\n"; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) solve(); return 0; }
[ "mahajan.suneet2002@gmail.com" ]
mahajan.suneet2002@gmail.com
84161e20689d4d5163ef9d5919fed0d8f1ab8b87
eb81c5b06bc6416b2bf19c60831115f42845567b
/[200421]HW12-ok.cpp
07a1b41f061c502f030c01a24d208f2d5c8189f3
[]
no_license
vt167098/cpp
3e02d6dd5b5d6dfecbb4847368efabaca99943b8
4fc7e27e3853448840a9dec4c58d43d238556655
refs/heads/master
2022-11-08T16:56:07.679818
2020-06-27T02:51:03
2020-06-27T02:51:03
252,230,034
0
0
null
null
null
null
UTF-8
C++
false
false
765
cpp
#include <iostream> using namespace std; long double s_x,s_y; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ void point(long double x,long double y,long double offset,long int times){ if(times==-2) return; else if(x>0&&y>0){ s_x+=x; s_y+=y; } point(x+offset,y+offset,offset/2,times-1); point(x+offset,y-offset,offset/2,times-1); point(x-offset,y+offset,offset/2,times-1); point(x-offset,y-offset,offset/2,times-1); } int main(int argc, char** argv) { long double a,b,d,offset; long int x; while(cin >> a >> b >> d >> x){ offset=d/2; s_x=0;s_y=0; point(a,b,offset,x); if(a>0&&b>0){ s_x-=a; s_y-=b; } cout << s_x <<" "<< s_y << endl; } return 0; }
[ "vt167098@hotmail.com" ]
vt167098@hotmail.com
83ce3a2fca8cf98691c2d8fc1cf85344a288271b
72dc23af81a49443bf595565e4a854f123cf0ba4
/1lab/second/second/CMatrix.cpp
674e63bc7d84a99f291f24443871142e97085a92
[]
no_license
islamov-jahja/PP
bc595aaa53a78b3afae6d82e18ed8b07a2d34bac
33b3ca2d9a9ce333518d47e9294860986553f987
refs/heads/master
2022-12-15T17:05:15.196174
2019-06-09T16:23:47
2019-06-09T16:23:47
179,572,508
0
0
null
null
null
null
UTF-8
C++
false
false
3,508
cpp
#include "stdafx.h" #include "CMatrix.h" CMatrix::CMatrix(string nameOfFile, int countOfFlows) :_nameOfFile(nameOfFile), _countOfFlows(countOfFlows) { InicializateMatrix(); CalculateCountOfFlows(); } CMatrix::~CMatrix() { } int CMatrix::GetRank() { int rank = 0; HANDLE hThread = new HANDLE[_countOfFlows] ; for (size_t i = 0; i < _countOfLines - 1; i++) { if (_Matrix[i][i] != 0) { ResetColumn(i); } { ChangeAndProcessLine(i); } } for (size_t i = 0; i < _countOfLines; i++) { if (_Matrix[i][i] != 0) rank++; } return rank; } vector<double> CMatrix::GetDevidedSeniorLine(int seniorLine) { int numberToDevide = _Matrix[seniorLine][seniorLine]; int numberToMultiplication = _Matrix[_indexOfProcessedLine][seniorLine]; for (size_t i = seniorLine; i < _countOfColumns; i++) { _Matrix[seniorLine][i] = _Matrix[seniorLine][i] / numberToDevide; _Matrix[seniorLine][i] = _Matrix[seniorLine][i] * numberToMultiplication; } return _Matrix[seniorLine]; } void CMatrix::ChangeAndProcessLine(int column) { for (int j = column + 1; j < _countOfLines; j++) { if (_Matrix[j][column] != 0) { RowExchange(column, j); ResetColumn(column); } } } void CMatrix::RowExchange(int i, int j) { int temp; for (int k = 0; k < _countOfColumns; k++) { temp = _Matrix[i][k]; _Matrix[i][k] = _Matrix[j][k]; _Matrix[j][k] = temp; } } void CMatrix::ResetColumn(int column) { HANDLE* hThreads = new HANDLE[_countOfFlows]; PointerWithColumn pwc; pwc.matrix = this; pwc.seniorLine = column; _indexOfProcessedLine = column + 1; if (_indexOfProcessedLine == _Matrix.size()) return; for (int i = 0; i < _countOfFlows; i++) { hThreads[i] = CreateThread(NULL, 2048, &CalculateProcessedLine, (PVOID)&pwc, 0, NULL); } WaitForMultipleObjects(_countOfFlows, hThreads, true, INFINITE); } DWORD WINAPI CMatrix::CalculateProcessedLine(LPVOID lpParam) { PointerWithColumn* pwc = (PointerWithColumn*)lpParam; CMatrix* matrix = pwc->matrix; vector<double> seniorLineArray; int seniorLine = pwc->seniorLine; while (matrix->_indexOfProcessedLine != matrix->_Matrix.size()) { matrix->_mutex.lock(); if (matrix->_indexOfProcessedLine == matrix->_Matrix.size()) { matrix->_mutex.unlock(); break; } int indexOfProcessedLine = matrix->_indexOfProcessedLine; if (matrix->_Matrix[indexOfProcessedLine][seniorLine] == 0) { matrix->_indexOfProcessedLine++; matrix->_mutex.unlock(); continue; } seniorLineArray = matrix->GetDevidedSeniorLine(seniorLine); matrix->_indexOfProcessedLine++; matrix->_mutex.unlock(); matrix->ToProcessLineOfMatrix(seniorLine, indexOfProcessedLine, seniorLineArray); } ExitThread(0); } void CMatrix::ToProcessLineOfMatrix(int seniorLine, int processedString, vector<double> lineToSub) { for (size_t i = seniorLine; i < _countOfColumns; i++) { _Matrix[processedString][i] = _Matrix[processedString][i] - lineToSub[i]; } } void CMatrix::CalculateCountOfFlows() { if (_countOfFlows < 1 || _countOfFlows > 16) _countOfFlows = DEFAULT_COUNT; } void CMatrix::InicializateMatrix() { _inFile.open(_nameOfFile); if (!_inFile.is_open()) throw runtime_error("file not found"); _inFile >> _countOfLines; _inFile >> _countOfColumns; vector<vector<double>> matrix(_countOfLines, vector<double>(_countOfColumns, 0)); _Matrix = matrix; for (size_t i = 0; i < _countOfLines; i++) { for (size_t j = 0; j < _countOfColumns; j++) { _inFile >> _Matrix[i][j]; } } _inFile.close(); }
[ "yahyaislamov15@mail.ru" ]
yahyaislamov15@mail.ru
40f5e4ac405e6525656f525ee4915df914993e94
4597f9e8c2772f276904b76c334b4d181fa9f839
/C++/Reverse-Linked-List-II.cpp
7fc240c0601c2048bc6c51b8fc561187f20027ae
[]
no_license
xxw1122/Leetcode
258ee541765e6b04a95e225284575e562edc4db9
4c991a8cd024b504ceb0ef7abd8f3cceb6be2fb8
refs/heads/master
2020-12-25T11:58:00.223146
2015-08-11T02:10:25
2015-08-11T02:10:25
40,542,869
2
6
null
2020-09-30T20:54:57
2015-08-11T13:21:17
C++
UTF-8
C++
false
false
1,187
cpp
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* reverse(ListNode* head) { ListNode* res = NULL; while (head != NULL) { ListNode* temp = head->next; head->next = res; res = head; head = temp; } return res; } ListNode* reverseBetween(ListNode* head, int m, int n) { if (m == n) return head; ListNode *pre = new ListNode(0), *cur = pre; pre->next = head; for (int i = 1; i < m; i ++) { cur = cur->next; } ListNode* pre_start = cur; for (int i = 0; i < n - m; i ++) { cur = cur->next; } ListNode *pre_end = cur, *start = pre_start->next; ListNode* next_end = cur->next->next; cur->next->next = NULL; ListNode *new_start = reverse(start); pre_start->next = new_start; cur = pre; while (cur->next != NULL) { cur = cur->next; } cur->next = next_end; return pre->next; } };
[ "jiangyi0425@gmail.com" ]
jiangyi0425@gmail.com
de5e7008b957466ca6ffe9b2b63a134e9d4de164
c36c4306eb26bb7c5bbde291e753b9bed7730755
/2_10/test.cpp
29d43f236d06d8b5597569faeab32bf3b31b425c
[]
no_license
NewLearner55/C_-plusplus
932fe6122edc5af3d92358042b9c930ba07a32c9
53c69e1b76f2347d3790273fbb812cc90ada0e8f
refs/heads/master
2021-07-13T22:36:18.695935
2020-11-23T14:30:56
2020-11-23T14:30:56
220,611,640
0
0
null
null
null
null
UTF-8
C++
false
false
561
cpp
#define _CRT_SECURE_NO_WARNINGS 1 class Solution { public: string largestNumber(vector<int>& nums) { auto f_sort = [](const int &a, const int &b) { long long n_a = 10; while (a / n_a) n_a *= 10; long long n_b = 10; while (b / n_b) n_b *= 10; long long r_a = (long long)a * n_b + (long long)b; long long r_b = (long long)b * n_a + (long long)a; return r_a < r_b; }; sort(nums.rbegin(), nums.rend(), f_sort); string ans; for (auto n : nums) { ans = (ans == "0") ? to_string(n) : ans + to_string(n); } return ans; } };
[ "564309357@qq.com" ]
564309357@qq.com
1309cc5540567f3108672f6960540086c99d25ea
e6b76664169516c0d9b4640974b7f23b3df33fb4
/mp_traversals/imageTraversal/DFS.h
6cc683b5a849aa0f4d5999c8469ab0d50922e096
[]
no_license
shawn-programming/Data_Structure
eaabae96f7cfa1898630472dfb17dd8300313617
318ec05432575a41f1afd3b2aa522e9751874b73
refs/heads/master
2021-01-03T17:34:52.122704
2020-08-16T06:49:47
2020-08-16T06:49:47
240,171,315
1
0
null
null
null
null
UTF-8
C++
false
false
748
h
/** * @file DFS.h */ #pragma once #include <iterator> #include <cmath> #include <list> #include <stack> #include <vector> using namespace std; #include "../cs225/PNG.h" #include "../Point.h" #include "ImageTraversal.h" using namespace cs225; /** * A depth-first ImageTraversal. * Derived from base class ImageTraversal */ class DFS : public ImageTraversal { public: DFS(const PNG & png, const Point & start, double tolerance); ImageTraversal::Iterator begin(); ImageTraversal::Iterator end(); void add(const Point & point); Point pop(); Point peek() const; bool empty() const; private: /** @todo [Part 1] */ /** add private members here*/ PNG png_; double tolerance_; Point start_; stack<Point> toVisit_; };
[ "shawn.programming@gmail.com" ]
shawn.programming@gmail.com
9ffab729054acd2ebda3818c93c4f612ef51be6e
ebc8072c667052dd95385b535f553833432b82f0
/CPP17.Data.cpp
654768448ead7236b504bacd22dcf039d0a63148
[ "MIT" ]
permissive
Alexandr-Galko/CppTest
a2cea1540ec6f67842def498e876126b2c6076dc
07dfbf407bfee6f57169ce075564d5266dedbba0
refs/heads/master
2021-08-30T02:06:22.417614
2017-12-15T16:24:59
2017-12-15T16:24:59
112,743,686
0
0
null
null
null
null
UTF-8
C++
false
false
330
cpp
/////////////////////////////////////////////////////////////////////////////// /// brief Data /// /// author Александр Галко - ОКБ ТСП /// date 31.10.2017 //////////////////////////////////////////////////////////////////////////////// #include "CPP17.Data.h" namespace CPP17 { } // namespace CPP17
[ "ferz.by@me.com" ]
ferz.by@me.com
b2f1e7bb5b93fcd5b057e0f1233d36364568b8ca
1a5c59fd9e25fef2d3e269b606d19a92383d7d6b
/src/GUIFramework/ConfigWindowManager/UnitTest/configwindowtest3.cpp
11f4502b9d745a5212cd94da3ef8fc4e9a317b93
[]
no_license
aguperezpala/hvdrt
e3a7b4459bfc3474016b1a889d03742498a6bbb1
854028d511f7e841479cab3373daab75c56c86e4
refs/heads/master
2021-01-01T15:35:45.982636
2012-10-21T23:58:42
2012-10-21T23:58:42
33,814,964
0
0
null
null
null
null
UTF-8
C++
false
false
203
cpp
#include "configwindowtest3.h" ConfigWindowTest3::ConfigWindowTest3(QWidget *parent) : ConfigWindow(parent, "ConfigWindowTest3") { ui.setupUi(this); } ConfigWindowTest3::~ConfigWindowTest3() { }
[ "aguperezpala@gmail.com@06da5462-caec-b45d-aab9-b80d20edd223" ]
aguperezpala@gmail.com@06da5462-caec-b45d-aab9-b80d20edd223
1497115f6b5f05b25504904a8229fbacf914137a
4a121c72d48b50a9feef9f3213a83543b9c9e7ee
/qindle/ttsdemo/dbustts.h
910d7ba876b9107b036c762e496bdb67548eb8b2
[]
no_license
Sparks192/qindle
c94bc15502b49b2ecbd31f9c8f4efaba3a1922d1
933d764f405a850bcfadcf74c8e4e3df5770b9f7
refs/heads/master
2021-01-19T18:00:25.665878
2014-04-14T01:42:06
2014-04-14T01:42:06
35,550,783
0
0
null
null
null
null
UTF-8
C++
false
false
392
h
#ifndef DBUSTTS_H #define DBUSTTS_H #include <QDBusInterface> #include <QString> class dbustts : public QDBusInterface { Q_OBJECT public: dbustts(); ~dbustts(); int setTtsSVoiceStr(QString voice); int setTtsISpeedInt(int i); int getTtsISpeedInt(); int setTextToProcessInt(int i); int getTtsIPitchInt(); int setTtsIPitchInt(int i); }; #endif // DBUSTTS_H
[ "lm3783@bc56459a-a753-11de-afd4-1d14fbec496b" ]
lm3783@bc56459a-a753-11de-afd4-1d14fbec496b
edafca1c27013f34bc54bb7851db6515d4d3961a
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_hunk_741.cpp
6c4e2d039403ce014026827230ca94c293e2bd5f
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
396
cpp
namespace regrank{ IObjFunction* CreateObjFunction( const char *name ){ if( !strcmp("reg", name ) ) return new RegressionObj(); if( !strcmp("rank", name ) ) return new PairwiseRankObj(); if( !strcmp("softmax", name ) ) return new SoftmaxObj(); utils::Error("unknown objective function type"); return NULL; }
[ "993273596@qq.com" ]
993273596@qq.com
10d63b698b7dae8d8a4d9f06a2829c023a26d153
3c7eeeb378a3ac03a69474efa5febd6c2d4f55a4
/src/libwinnie/src/window.cc
fb30079302cfd36db69175f2ac9343de3d7d29c5
[]
no_license
paule32/winmgr
feece1f5de598b1c496a636f74f6850c0fe476e5
a8042e1709cb36b2f8d716aec14185779f5035c3
refs/heads/master
2021-01-20T22:28:18.249500
2016-07-11T19:51:08
2016-07-11T19:51:08
63,097,043
0
0
null
null
null
null
UTF-8
C++
false
false
4,496
cc
#include <algorithm> #include <stdio.h> #include <string.h> #include "gfx.h" #include "window.h" #include "wm.h" Window::Window() { parent = 0; title = 0; rect.x = rect.y = 0; rect.width = rect.height = 128; memset(&callbacks, 0, sizeof callbacks); dirty = true; managed = true; focusable = true; state = STATE_NORMAL; } Window::~Window() { for(size_t i=0; i<children.size(); i++) { wm->remove_window(children[i]); delete children[i]; } delete [] title; } const Rect &Window::get_rect() const { return rect; } Rect Window::get_absolute_rect() const { if(!parent) { return rect; } Rect absolute_rect; absolute_rect = parent->get_absolute_rect(); absolute_rect.x += rect.x; absolute_rect.y += rect.y; absolute_rect.width = rect.width; absolute_rect.height = rect.height; return absolute_rect; } bool Window::contains_point(int ptr_x, int ptr_y) { Rect abs_rect = get_absolute_rect(); return ptr_x >= abs_rect.x && ptr_x < abs_rect.x + abs_rect.width && ptr_y >= abs_rect.y && ptr_y < abs_rect.y + abs_rect.height; } void Window::move(int x, int y) { invalidate(); // moved, should redraw, MUST BE CALLED FIRST rect.x = x; rect.y = y; } void Window::resize(int x, int y) { invalidate(); // resized, should redraw, MUST BE CALLED FIRST rect.width = x; rect.height = y; } void Window::set_title(const char *s) { delete [] title; title = new char[strlen(s) + 1]; strcpy(title, s); } const char *Window::get_title() const { return title; } void Window::invalidate() { dirty = true; Rect abs_rect = get_absolute_rect(); wm->invalidate_region(abs_rect); } void Window::draw(Rect *dirty_region) { Rect abs_rect = get_absolute_rect(); Rect intersect = rect_intersection(abs_rect, *dirty_region); if(intersect.width && intersect.height) { Rect prev_clip = get_clipping_rect(); set_clipping_rect(abs_rect); if(callbacks.display) { callbacks.display(this); } dirty = false; draw_children(abs_rect); *dirty_region = rect_union(*dirty_region, abs_rect); set_clipping_rect(prev_clip); } } void Window::draw_children(const Rect &dirty_region) { Rect drect = dirty_region; for(size_t i=0; i<children.size(); i++) { children[i]->draw(&drect); } } unsigned char *Window::get_win_start_on_fb() { unsigned char *fb = get_framebuffer(); Rect abs_rect = get_absolute_rect(); return fb + get_color_depth() * (get_screen_size().x * abs_rect.y + abs_rect.x) / 8; } int Window::get_scanline_width() { return get_screen_size().x; } void Window::set_managed(bool managed) { this->managed = managed; } bool Window::get_managed() const { return managed; } void Window::set_focusable(bool focusable) { this->focusable = focusable; } bool Window::get_focusable() const { return focusable; } bool Window::get_dirty() const { return dirty; } void Window::set_display_callback(DisplayFuncType func) { callbacks.display = func; } void Window::set_keyboard_callback(KeyboardFuncType func) { callbacks.keyboard = func; } void Window::set_mouse_button_callback(MouseButtonFuncType func) { callbacks.button = func; } void Window::set_mouse_motion_callback(MouseMotionFuncType func) { callbacks.motion = func; } void Window::set_timer_callback(TimerFuncType func) { callbacks.timer = func; } const DisplayFuncType Window::get_display_callback() const { return callbacks.display; } const KeyboardFuncType Window::get_keyboard_callback() const { return callbacks.keyboard; } const MouseButtonFuncType Window::get_mouse_button_callback() const { return callbacks.button; } const MouseMotionFuncType Window::get_mouse_motion_callback() const { return callbacks.motion; } const TimerFuncType Window::get_timer_callback() const { return callbacks.timer; } void Window::add_child(Window *win) { children.push_back(win); if(win->parent) { win->parent->remove_child(win); } win->parent = this; } void Window::remove_child(Window *win) { std::vector<Window*>::iterator it; it = std::find(children.begin(), children.end(), win); if(it != children.end()) { children.erase(it); win->parent = 0; } } Window **Window::get_children() { if(children.empty()) { return 0; } return &children[0]; } int Window::get_children_count() const { return (int)children.size(); } const Window *Window::get_parent() const { return parent; } Window *Window::get_parent() { return parent; } void Window::set_state(State state) { this->state = state; } Window::State Window::get_state() const { return state; }
[ "jkallup@web.de" ]
jkallup@web.de
9a4244b608a24bb81eac80d61c4f72150d2ef937
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_old_log_1683.cpp
ded52c3b4ec94eaafa1ec7331d41e15c9553c200
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
310
cpp
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "[%" APR_PID_T_FMT "] auth_ldap authorise: require group \"%s\": " "authorisation failed [%s][%s]", getpid(), t, ldc->reason, ldap_err2string(result));
[ "993273596@qq.com" ]
993273596@qq.com
97f190e5285f309018b0f54ffbd564169f552691
a4c6d8c22e5fbb5b567add9ab7e020568c692d0b
/app.cpp
f81423fe4be6c209fb98da6833b3a467d5edcd1e
[ "Apache-2.0" ]
permissive
erhoof/eapc
dd471c8077c98f73108d54def20ef800f8736733
aceee1f24b7d49baa543b38278a930c20f8e598b
refs/heads/master
2022-11-21T18:47:47.961175
2020-07-05T10:50:12
2020-07-05T10:50:12
277,159,357
0
0
null
null
null
null
UTF-8
C++
false
false
159
cpp
#include "cpu.h" void setup() { } void loop() { // delay to make sure everything is set up delay(2000); cpu_t* cpu = cpu_create(128); }
[ "b7086163@gmail.com" ]
b7086163@gmail.com
0aa7eb62547a89330f6a796bff5069027749343f
47ba5d5ac05434d021ba75192d171df307044d67
/SpectrumForm.cpp
5a9c2bf6bc13c694330be1e99fd0573a272a3ca9
[]
no_license
ymz000/ItsFx3
1093213d50b68e8840b867bd80d80b0ec707c71e
030a6ff61d22e2a33db2c0c4d9ad9fa0a3913c70
refs/heads/master
2022-02-27T04:52:34.267098
2018-09-27T09:00:12
2018-09-27T09:00:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,726
cpp
#include <QVariant> #include "gcacorr/dsp_utils.h" #include "SpectrumForm.h" #include "ui_SpectrumForm.h" using namespace std; SpectrumForm::SpectrumForm( FX3Config* cfg, QWidget *parent ) : QWidget(parent), router( NULL ), ui(new Ui::SpectrumForm), cfg( cfg ), fft( NULL ), fft_len( nFftDefault ), half_fft_len( fft_len/2 ) { left_point = 1; right_point = half_fft_len - 1; points_cnt = right_point - left_point - 1; nullMHz = cfg->inter_freq_hz / 1.0e6; bandMHz = (cfg->adc_sample_rate_hz / 1.0e6) / 2.0; filterMHz = bandMHz / ( fft_len ); band_type = LSB; fft = new FFTWrapper( fft_len ); powers_avg.resize( 4 ); for ( size_t i = 0; i < powers_avg.size(); i++ ) { powers_avg[ i ] = new Averager<float>( half_fft_len, avg_simple_cnt ); } powers.resize(4); for ( size_t i = 0; i < powers.size(); i++ ) { powers.at(i).resize(half_fft_len); } powers_avg_safe.resize(4); for ( size_t i = 0; i < powers_avg_safe.size(); i++ ) { powers_avg_safe.at(i).resize(half_fft_len); } fft_out_averaged.resize(4); for ( size_t i = 0; i < fft_out_averaged.size(); i++ ) { fft_out_averaged.at(i).resize(fft_len); } tbuf_fft.resize(avg_matrix_cnt_max); for ( size_t iter = 0; iter < tbuf_fft.size(); iter++ ) { tbuf_fft[ iter ].resize( 4 ); for ( size_t ch = 0; ch < tbuf_fft[ iter ].size(); ch++ ) { tbuf_fft[ iter ][ ch ].resize( fft_len ); } } running = true; calc_thread = std::thread( &SpectrumForm::calc_loop, this ); ui->setupUi(this); ui->widgetSpectrum->SetVisualMode( SpectrumWidget::spec_horiz ); ui->widgetSpectrum->SetChannelMask( 0xFF ); checkBoxShowChannels.resize( MAX_CHANS ); checkBoxShowChannels[ 0 ] = ui->checkBoxShowCh0; checkBoxShowChannels[ 1 ] = ui->checkBoxShowCh1; checkBoxShowChannels[ 2 ] = ui->checkBoxShowCh2; checkBoxShowChannels[ 3 ] = ui->checkBoxShowCh3; for ( size_t i = 0; i < checkBoxShowChannels.size(); i++ ) { QObject::connect(checkBoxShowChannels[ i ], SIGNAL(stateChanged(int)), this, SLOT(channelsChanged(int)) ); } for ( int i = cfg->chan_count; i < MAX_CHANS; i++ ) { checkBoxShowChannels[ i ]->setChecked( false ); checkBoxShowChannels[ i ]->setEnabled( false ); } ui->comboBoxBandType->insertItem( 0, "LSB", QVariant(LSB)); ui->comboBoxBandType->insertItem( 1, "USB", QVariant(USB)); ui->comboBoxAvgMatrix->insertItem( 0, " no corr mtrx", QVariant( 1) ); ui->comboBoxAvgMatrix->insertItem( 1, " 4x corr mtrx", QVariant( 4) ); ui->comboBoxAvgMatrix->insertItem( 2, " 8x corr mtrx", QVariant( 8) ); ui->comboBoxAvgMatrix->insertItem( 3, "10x corr mtrx", QVariant(10) ); ui->comboBoxAvgMatrix->insertItem( 4, "20x corr mtrx", QVariant(20) ); ui->comboBoxAvgMatrix->setCurrentIndex(0); avgMatrixChanged(0); ui->comboBoxAvgSimple->insertItem( 0, " no avg", QVariant( 1) ); ui->comboBoxAvgSimple->insertItem( 1, " 4x avg", QVariant( 4) ); ui->comboBoxAvgSimple->insertItem( 2, " 8x avg", QVariant( 8) ); ui->comboBoxAvgSimple->insertItem( 3, "16x avg", QVariant(16) ); ui->comboBoxAvgSimple->insertItem( 4, "32x avg", QVariant(32) ); ui->comboBoxAvgSimple->insertItem( 5, "64x avg", QVariant(64) ); ui->comboBoxAvgSimple->setCurrentIndex(1); avgSimpleChanged(1); QObject::connect(ui->checkRun, SIGNAL(stateChanged(int)), this, SLOT(slotRun(int)) ); QObject::connect(ui->widgetSpectrum, SIGNAL(sendNewCurIdx(int)), this, SLOT(CurChangeOutside(int)) ); QObject::connect(ui->sliderLevelScale, SIGNAL(valueChanged(int)), this, SLOT(scalesShiftsChanged(int)) ); QObject::connect(ui->sliderLevelShift, SIGNAL(valueChanged(int)), this, SLOT(scalesShiftsChanged(int)) ); QObject::connect(ui->sliderFreqScale, SIGNAL(valueChanged(int)), this, SLOT(scalesShiftsChanged(int)) ); QObject::connect(ui->sliderFreqShift, SIGNAL(valueChanged(int)), this, SLOT(scalesShiftsChanged(int)) ); QObject::connect(ui->comboBoxBandType, SIGNAL(currentIndexChanged(int)), this, SLOT(bandTypeChanged(int))); QObject::connect(ui->comboBoxAvgMatrix, SIGNAL(currentIndexChanged(int)), this, SLOT(avgMatrixChanged(int))); QObject::connect(ui->comboBoxAvgSimple, SIGNAL(currentIndexChanged(int)), this, SLOT(avgSimpleChanged(int))); SetCurrentIdx( ( right_point - left_point ) / 2 ); ChangeNullMhz( nullMHz * 1.0e6 ); } SpectrumForm::~SpectrumForm() { if ( router ) { router->DeleteOutPoint( this ); } running = false; data_valid = false; event_data.Notify(); if ( calc_thread.joinable() ) { calc_thread.join(); } delete fft; delete ui; for ( size_t i = 0; i < powers_avg.size(); i++ ) { if ( powers_avg[ i ] ) { delete powers_avg[ i ]; } } } bool SpectrumForm::TryLockData() { lock_guard<mutex> lock(mtx_data); if ( data_is_busy ) { return false; } else { data_is_busy = true; return true; } } void SpectrumForm::UnlockData() { lock_guard<mutex> lock(mtx_data); data_is_busy = false; } void SpectrumForm::MakeFFTs() { if ( avg_matrix_cnt == 1 ) { for ( size_t channel = 0; channel < all_ch_data.size(); channel++ ) { fft->TransformShort( all_ch_data[ channel ].data(), fft_out_averaged[ channel ].data(), false ); } } else { for ( int iter = 0; iter < avg_matrix_cnt; iter++ ) { for ( size_t channel = 0; channel < 4; channel++ ) { fft->TransformShort( all_ch_data[ channel ].data() + fft_len * iter, tbuf_fft[ iter ][ channel ].data(), false ); } } float scale = 1.0f / ((float) avg_matrix_cnt * 4.0f); float_cpx_t corr[4]; for ( int pt = 0; pt < half_fft_len; pt++ ) { corr[0] = float_cpx_t( 0.0f, 0.0f ); corr[1] = float_cpx_t( 0.0f, 0.0f ); corr[2] = float_cpx_t( 0.0f, 0.0f ); corr[3] = float_cpx_t( 0.0f, 0.0f ); for ( int iter = 0; iter < avg_matrix_cnt; iter++ ) { for ( int ch = 0; ch < 4; ch++ ) { corr[ch].add( calc_correlation( tbuf_fft[ iter ][ 0 ][ pt ], tbuf_fft[ iter ][ ch ][ pt ] ) ); } } for ( int ch = 0; ch < 4; ch++ ) { fft_out_averaged[ ch ][ pt ] = corr[ ch ].mul_real( scale ); } } } data_valid = false; } void SpectrumForm::MakePowers() { //float xavg = 0.0f; //float xmax = -1000.0f; //float xmin = 1000.0f; int left_point_copy, right_point_copy; { lock_guard<mutex> lock( pts_param_mtx ); left_point_copy = left_point; right_point_copy = right_point; } float koef = 10.0; if ( avg_matrix_cnt > 1 ) { koef = 5.0; } for ( int ch = 0; ch < 4; ch++ ) { const float_cpx_t* avg_data = fft_out_averaged[ ch ].data(); vector<float>& pwr = powers[ch]; //for ( int i = left_point_copy; i < right_point_copy; i++ ) { for ( int i = 0; i < half_fft_len; i++ ) { float p = koef * log10f( avg_data[i].len_squared() ); pwr[ i ] = p; //xavg += p; //if ( p > xmax ) { xmax = p; } //if ( p < xmin ) { xmin = p; } } lock_guard<mutex> lock(powers_avg_mtx); if ( powers_avg[ ch ] ) { powers_avg[ ch ]->PushData( pwr.data() ); } } //xavg /= (left_point_copy - right_point_copy) * 4.0f; //this->powerAvg = xavg; //this->powerMax = xmax; //this->powerMin = xmin; } void SpectrumForm::SetWidgetData() { scalesShiftsChanged(0); int left_point_copy, points_cnt_copy; { lock_guard<mutex> lock( pts_param_mtx ); left_point_copy = left_point; points_cnt_copy = points_cnt; } { lock_guard<mutex> lock(powers_avg_mtx); for ( int ch = 0; ch < 4; ch++ ) { if ( powers_avg[ ch ] ) { powers_avg[ ch ]->GetData( powers_avg_safe[ ch ].data(), band_type == LSB ); } } } ui->widgetSpectrum->SetPowersData( &powers_avg_safe, left_point_copy, points_cnt_copy, -40.0, 80.0, 10.0, 20.0, 100.0 ); ui->widgetSpectrum->SetCurrentIdx( GetCurrentIdx(), 10.0 ); } double SpectrumForm::GetCurrentFreqHz() { if ( band_type == LSB ) { return ( nullMHz - bandMHz + curIdx*filterMHz*2.0 ) * 1.0e6; } else { return ( nullMHz + curIdx*filterMHz*2.0 ) * 1.0e6; } } int SpectrumForm::GetCurrentIdx() { return curIdx; } void SpectrumForm::SetCurrentIdx(int x) { { lock_guard<mutex> lock( pts_param_mtx ); if ( x < left_point ) { x = left_point; } if ( x > right_point ) { x = right_point; } curIdx = x; } ui->labelFreq->setText( QString(" %1 MHz").arg( QString::number( GetCurrentFreqHz() / 1.0e6, 'f', 2 ) )); } void SpectrumForm::ChangeNullMhz(double newVal) { this->nullMHz = newVal/1.0e6; SetCurrentIdx( GetCurrentIdx() ); } void SpectrumForm::CurChangeOutside(int value) { SetCurrentIdx( value ); if ( !ui->checkRun->isChecked() ) { ui->widgetSpectrum->SetCurrentIdx( GetCurrentIdx(), 10.0 ); update(); } } void SpectrumForm::calc_loop() { this_thread::sleep_for(chrono::milliseconds(2000)); while (running) { event_data.WaitAndFlush(); if ( TryLockData() ) { if ( data_valid ) { // have new data MakeFFTs(); UnlockData(); MakePowers(); SetWidgetData(); update(); } else { // no new data UnlockData(); } } // if TryLockData() } // while running } void SpectrumForm::slotRun(int state) { if ( router ) { if ( state ) { router->AddOutPoint(this); } else { router->DeleteOutPoint(this); } } } void SpectrumForm::channelsChanged(int) { uint32_t chanmask = 0; for ( size_t i = 0; i < checkBoxShowChannels.size(); i++ ) { if ( checkBoxShowChannels[ i ]->isChecked() ) { chanmask |= ( 1 << i ); } } ui->widgetSpectrum->SetChannelMask( chanmask ); if ( !ui->checkRun->isChecked() ) { update(); } } void SpectrumForm::scalesShiftsChanged(int) { float yscale = 80.0f * ( (float)ui->sliderLevelScale->value() / (float)ui->sliderLevelScale->maximum() ); ui->widgetSpectrum->SetPowerRange(yscale); float yshift = -(float)ui->sliderLevelShift->value(); ui->widgetSpectrum->SetPowerShift( yshift ); update(); float band = half_fft_len * ( (float)ui->sliderFreqScale->value() / (float)ui->sliderFreqScale->maximum() ); float freq_shift = (float)half_fft_len * (float)ui->sliderFreqShift->value() / 200.0f; float center = ((float)half_fft_len) / 2.0f + freq_shift; { lock_guard<mutex> lock( pts_param_mtx ); left_point = (int) round( center - band / 2.0f ); right_point = (int) round( center + band / 2.0f ); if ( left_point < 0 ) { left_point = 0; } if ( right_point > half_fft_len ) { right_point = half_fft_len - 1; } if ( left_point > right_point ) { left_point = right_point - 1; } points_cnt = right_point - left_point - 1; } ui->widgetSpectrum->SetPointsParams( left_point, points_cnt ); } void SpectrumForm::bandTypeChanged(int) { bool ok; BandType new_band_type = (BandType)ui->comboBoxBandType->currentData().toInt(&ok); if ( new_band_type != band_type && !ui->checkRun->isChecked() ) { band_type = new_band_type; SetWidgetData(); } band_type = new_band_type; SetCurrentIdx( GetCurrentIdx() ); update(); } void SpectrumForm::avgSimpleChanged(int) { bool ok; int newval = ui->comboBoxAvgSimple->currentData().toInt(&ok); if ( newval != avg_simple_cnt ) { lock_guard<mutex> lock( powers_avg_mtx ); avg_simple_cnt = newval; for ( size_t i = 0; i < powers_avg.size(); i++ ) { if ( powers_avg[ i ] ) { delete powers_avg[ i ]; } powers_avg[ i ] = new Averager<float>( half_fft_len, avg_simple_cnt ); } } } void SpectrumForm::avgMatrixChanged(int) { bool ok; avg_matrix_cnt = ui->comboBoxAvgMatrix->currentData().toInt(&ok); } void SpectrumForm::hideEvent(QHideEvent* /*event*/ ) { ui->checkRun->setChecked(false); } void SpectrumForm::HandleAllChansData(std::vector<short *> &new_all_ch_data, size_t pts_cnt) { if ( (int)pts_cnt < fft_len ) { return; } if ( new_all_ch_data.size() != 4 ) { return; } if ( TryLockData() ) { if ( all_ch_data.size() != 4 ) { all_ch_data.resize(4); } for ( int ch = 0; ch < 4; ch++ ) { if ( all_ch_data[ch].size() != pts_cnt ) { all_ch_data[ch].resize(pts_cnt); } memcpy( all_ch_data[ch].data(), new_all_ch_data[ch], sizeof(short)*pts_cnt); } data_valid = true; UnlockData(); event_data.Notify(); } }
[ "amungo.navigation@gmail.com" ]
amungo.navigation@gmail.com
0e8001afa068d631dcd09b75b3cff1771b6484c2
3c60f57ec500dfd745ed08c03a71e6331ec94650
/src/Brush.cpp
07ee4a07db38b960f753610436062dd9d63c5ee7
[ "MIT" ]
permissive
Hochheilige/WinAPIWrapper
4342f13af8bc13e0b9a73fd2ed12e303829ea558
9998739eb44c8a72546db2af91b8521c09df8672
refs/heads/master
2023-03-21T09:35:33.504852
2021-03-22T10:00:29
2021-03-22T10:00:29
296,859,986
0
0
null
null
null
null
UTF-8
C++
false
false
1,569
cpp
#include "Brush.h" namespace Waw { Brush::Brush() { style = BrushStyle::SOLID; color = Color(); hatch = HatchTypes::HORIZONTAL; bitmap = nullptr; brush = CreateSolidBrush(color.GetColorRef()); } Brush::Brush(const BrushStyle st, const Color clr, const HatchTypes hatch_type, const HBITMAP bm) { style = st; color = clr; hatch = hatch_type; bitmap = bm; SelectStyle(); } Brush::Brush(const BrushStyle st, const StandartColors clr, const HatchTypes hatch_type, const HBITMAP bm) { style = st; color = Color(clr); hatch = hatch_type; bitmap = bm; SelectStyle(); } Brush::~Brush() { DeleteObject(brush); } void Brush::SetBrushStyle(const BrushStyle st, const HatchTypes hatch_type, const HBITMAP bm) { style = st; hatch = hatch_type; bitmap = bm; if (brush) DeleteObject(brush); SelectStyle(); } void Brush::SetHatch(const HatchTypes hatch_type) { hatch = hatch_type; if (brush) DeleteObject(brush); SelectStyle(); } void Brush::SetBitmap(const HBITMAP bm) { bitmap = bm; if (brush) DeleteObject(brush); SelectStyle(); } void Brush::Select(const HDC hdc) const { if (brush) SelectObject(hdc, brush); } void Brush::SelectStyle() { switch (style) { case BrushStyle::SOLID: { brush = CreateSolidBrush(color.GetColorRef()); break; } case BrushStyle::HATCH: { brush = CreateHatchBrush(static_cast<int>(hatch), color.GetColorRef()); break; } case BrushStyle::PATTERN: { brush = CreatePatternBrush(bitmap); break; } } } }
[ "hochheilige01@gmail.com" ]
hochheilige01@gmail.com
7df980638be5fb18168afa50a15fc2397d01259f
f99e4759fc5a40e780b3d319b584b766d502c031
/CPP2 - Machiavellli/src/Server/ClientInfo.h
81f1fb0dcb4d1e855b7c4e60288eab8e43fa3a51
[]
no_license
beschoenen/school
41f66dcc85190039729eb0ddc1329ac400446a78
aba375fbb59c65577c70c5301053c5c20293498a
refs/heads/master
2020-03-07T14:09:52.637641
2018-03-31T09:53:54
2018-03-31T09:53:54
127,520,045
0
2
null
null
null
null
UTF-8
C++
false
false
1,983
h
#ifndef _CLIENT_INFO_H #define _CLIENT_INFO_H #include <string> #include <utility> #include <memory> #include "Socket.h" #include "../Models/Player.h" class ClientInfo { Socket _socket{}; Player _player{}; std::string ui_message; public: ClientInfo(Socket socket, const Player& player) : _socket{std::move(socket)}, _player{std::move(player)} { } bool render = false; bool disconnect = false; Socket& get_socket() { return _socket; } const Socket& get_socket() const { return _socket; } Player& get_player() { return _player; } const Player& get_player() const { return _player; } const std::string get_message() { return ui_message; } const void set_message(const std::string& message) { ui_message += std::move(message) + Socket::endl; } const void clear_message() { ui_message = ""; } const bool has_message() const { return !ui_message.empty(); } const void send_header() { get_socket() << Socket::clear << Socket::endl << "#############################" << Socket::endl << "# " << get_player().gold << " Gold " << get_player().number_built_buildings() << " Buildings" << Socket::endl << "#############################" << Socket::endl << Socket::endl; if (has_message()) { get_socket() << get_message() << Socket::endl; clear_message(); } } const void render_screen() { render = true; } bool operator==(ClientInfo& client) { return this->get_socket().get_id() == client.get_socket().get_id(); } bool operator!=(ClientInfo& client) { return !operator==(client); } bool operator==(std::shared_ptr<ClientInfo> client) { return operator==(*client); } bool operator!=(std::shared_ptr<ClientInfo> client) { return !operator==(client); } }; #endif
[ "me@kevinrichter.nl" ]
me@kevinrichter.nl
5fdc3d3538a93fe6a89336762ecc8d59e2965906
c976731ce836bb2af5837f8fc06c66d01dfb54fa
/TankGame/Source/TankGame/Public/Projectile.h
0208fcd62108a601373a2f0c6e9abd022edb78c3
[]
no_license
7efnawy-games/TankGame
827448824968a30e643616eafc97be87bf307e2d
77c4cc36b42c542b4781408c3362161e3192b31b
refs/heads/master
2020-07-03T14:00:29.531914
2019-10-27T18:40:49
2019-10-27T18:40:49
201,927,486
0
0
null
null
null
null
UTF-8
C++
false
false
2,053
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Actor.h" #include "Kismet/GameplayStatics.h" #include"Runtime/Engine/Classes/GameFramework/ProjectileMovementComponent.h" #include"Runtime/Engine/Classes/Components/StaticMeshComponent.h" #include"Runtime/Engine/Classes/Particles/ParticleSystemComponent.h" #include "PhysicsEngine/RadialForceComponent.h" #include "GameFramework/DamageType.h" #include "TimerManager.h" #include "Projectile.generated.h" UCLASS() class TANKGAME_API AProjectile : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AProjectile(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame //UNFUNCTION is very important because it says to the compiler that this is not a normal user defined function UFUNCTION() void OnHit(UPrimitiveComponent* HitComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit); void LaunchProjectile(float); private: UProjectileMovementComponent* ProjectileMovementComponent = nullptr; UPROPERTY(VisibleAnywhere,Category=Component) UStaticMeshComponent* CollisionMesh = nullptr; UPROPERTY(VisibleAnywhere, Category = Component) UParticleSystemComponent* LaunchBlast = nullptr; UPROPERTY(VisibleAnywhere, Category = Component) UParticleSystemComponent* ImpactBlast = nullptr; UPROPERTY(VisibleAnywhere, Category = Component) URadialForceComponent* ExplosionForce = nullptr; UPROPERTY(EditDefaultsOnly, Category = Setup) float DestroyDelay=10.f; UPROPERTY(EditDefaultsOnly,Category=Setup) float ProjectileDamage = 20.f; //Functions void OnTimerExpire(); //void FTimerManager::SetTimer<UserClass>(FTimerHandle & InOutHandle, UserClass * InObj, typename FTimerDelegate::TUObjectMethodDelegate_Const<UserClass>::FMethodPtr InTimerMethod, float InRate, bool InbLoop = false, float InFirstDelay = -1.f) };
[ "youssefelhefnawy@gmail.com" ]
youssefelhefnawy@gmail.com
785cff62bd9102febe1782948626975024820fe9
23b2ab84309de65b42333c87e0de088503e2cb36
/tools/TransDB/widget.cpp
46b05ec86d030c3a67ecd0166b3d085fb9054788
[]
no_license
fyrestone/simple-pms
74a771d83979690eac231a82f1c457d7b6c55f41
1917d5c4e14bf7829707bacb9cc2452b49d6cc2b
refs/heads/master
2021-01-10T20:36:39.403902
2011-04-16T15:38:12
2011-04-16T15:38:12
32,192,134
0
0
null
null
null
null
UTF-8
C++
false
false
1,479
cpp
#include "widget.h" #include "ui_widget.h" #include <QFileDialog> Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget), task(Task::instance()) { ui->setupUi(this); connectSignalsAndSlots(); } Widget::~Widget() { delete ui; } void Widget::changeEvent(QEvent *e) { QWidget::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; } } void Widget::connectSignalsAndSlots() { connect(ui->inputSelectButton, SIGNAL(clicked()), this, SLOT(selectInputDB())); connect(ui->outputSelectButton, SIGNAL(clicked()), this, SLOT(selectOutputDB())); } void Widget::selectInputDB() { QString input = QFileDialog::getOpenFileName(this, tr("请选择旧版本数据库:"), QString(), tr("PMS数据库文件 (*.db)")); ui->inputDBPath->setText(input); } void Widget::selectOutputDB() { QString output = QFileDialog::getSaveFileName(this, tr("请选择新版本数据库保存位置:"), QString(), tr("PMS数据库文件 (*.db)")); ui->outputDBPath->setText(output); }
[ "zihongdelei@gmail.com@95127988-2b6b-df20-625d-5ecc0e46e2bb" ]
zihongdelei@gmail.com@95127988-2b6b-df20-625d-5ecc0e46e2bb
cb1999641fbb77d66a24e23d1969a1d0a3b38480
a2a2ad80e64e95c053ea29e34a40672c5ab23473
/fast_template_matching/FAsT-Match/MatchConfig.h
a089fa6bece57b552ea084c81bde066c767b4963
[]
no_license
TiffanyXYf/Tracking
f4f7a1ca1ab786398f0c140b302fd24399870ec4
c8bdd18c30707117dec6f40b5052acd910374798
refs/heads/master
2020-05-02T20:35:37.685653
2019-04-08T13:41:05
2019-04-08T13:41:05
178,196,664
0
0
null
null
null
null
UTF-8
C++
false
false
1,276
h
// // MatchConfig.h // FAsT-Match // // Created by Saburo Okita on 02/06/14. // Copyright (c) 2014 Saburo Okita. All rights reserved. // #ifndef __FAsT_Match__MatchConfig__ #define __FAsT_Match__MatchConfig__ #include <iostream> #include <opencv2/opencv.hpp> namespace fast_match { /** * Config class that describes the parameters used in creating affine transformations */ class MatchConfig { public: MatchConfig(); MatchConfig( const MatchConfig& object ); MatchConfig( float trans_x, float trans_y, float rotate_2, float scale_x, float scale_y, float rotate_1 ); void init( float trans_x, float trans_y, float rotate_2, float scale_x, float scale_y, float rotate_1 ); static std::vector<MatchConfig> fromMatrix( cv::Mat& configs); cv::Mat asMatrix(); cv::Mat asAffineMatrix(); cv::Mat getAffineMatrix(); friend std::ostream &operator <<( std::ostream& os, const MatchConfig & conf ); protected: float translateX; float translateY; float rotate2; float rotate1; float scaleX; float scaleY; cv::Mat affine; }; } #endif /* defined(__FAsT_Match__MatchConfig__) */
[ "1627072546@qq.com" ]
1627072546@qq.com