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
b3d4e38198c83dfe1ebc1df89eebd85740341b78
cea8df4f88a1b2ecfebc1b323bdf3b0138bc9eb6
/open_gl_curso_2/open_gl_curso_2/L21_PointsAnimation.cpp
3c317343b3eb34965aee8e63ff9c44d4c0b32d49
[]
no_license
NorbertoMartinezG/open_gl_curso_2
f7fcefdd6855db46e92a7e4d2ff62feee3f259b1
1dfc62f978c14f89d7e406e6e6a232a35cfccb2e
refs/heads/main
2023-02-16T02:41:22.158391
2021-01-11T20:18:00
2021-01-11T20:18:00
319,791,139
0
0
null
null
null
null
UTF-8
C++
false
false
885
cpp
#include "L21_PointsAnimation.h" L21_PointsAnimation::L21_PointsAnimation() { a = 0; } void L21_PointsAnimation::draw() { background(); //drawPoints(); drawAnimation(); } void L21_PointsAnimation::background() { glClearColor(0, 0, 0.2, 1); } void L21_PointsAnimation::drawAnimation() { double a; a = 30 * seconds(); // velocidad de rotacion glPushMatrix(); //glRotatef(a, 1, 0, 0); // rota en en el eje x glRotatef(a, 0, 1, 0); // rota en en el eje y //glRotatef(a, 0, 0, 1); // // rota en en el eje z drawPoints(); glPopMatrix(); } void L21_PointsAnimation::drawPoints() { glPointSize(4); a = 0; while (a < 360) { drawRotate(); a = a + 15; } } void L21_PointsAnimation::drawRotate() { glPushMatrix(); glRotated(a, 0, 0, 1); drawPoint(); glPopMatrix(); } void L21_PointsAnimation::drawPoint() { glBegin(GL_POINTS); glVertex3d(10, 0, 0); glEnd(); }
[ "nautilus_com@yahoo.com" ]
nautilus_com@yahoo.com
b0f797ee4e2a21bf4e0f64c8e2de1862b7d0d3c0
8fa8ab78770861fe2cee964b381d3b9af0e9d867
/SlatechainCore/src/checkpoints.cpp
a20ae6617ccce900cfdf505f7bc7d656cccd08c5
[ "MIT" ]
permissive
npq7721/coproject
37eb2725d737b46ac2fea20363ee159a6e8b8550
a8110e40bac798f25654e2492ef35ae92eae3bbf
refs/heads/master
2020-03-22T16:31:30.101967
2018-07-12T06:08:26
2018-07-12T06:08:26
140,332,362
0
0
null
null
null
null
UTF-8
C++
false
false
3,434
cpp
// Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The Corallium developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "checkpoints.h" #include "chainparams.h" #include "main.h" #include "uint256.h" #include <stdint.h> #include <boost/foreach.hpp> namespace Checkpoints { /** * How many times we expect transactions after the last checkpoint to * be slower. This number is a compromise, as it can't be accurate for * every system. When reindexing from a fast disk with a slow CPU, it * can be up to 20, while when downloading from a slow network with a * fast multicore CPU, it won't be much higher than 1. */ static const double SIGCHECK_VERIFICATION_FACTOR = 5.0; bool fEnabled = true; bool CheckBlock(int nHeight, const uint256& hash) { if (!fEnabled) return true; const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; MapCheckpoints::const_iterator i = checkpoints.find(nHeight); if (i == checkpoints.end()) return true; return hash == i->second; } //! Guess how far we are in the verification process at the given block index double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks) { if (pindex == NULL) return 0.0; int64_t nNow = time(NULL); double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0; double fWorkBefore = 0.0; // Amount of work done before pindex double fWorkAfter = 0.0; // Amount of work left after pindex (estimated) // Work is defined as: 1.0 per transaction before the last checkpoint, and // fSigcheckVerificationFactor per transaction after. const CCheckpointData& data = Params().Checkpoints(); if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) { double nCheapBefore = pindex->nChainTx; double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx; double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint) / 86400.0 * data.fTransactionsPerDay; fWorkBefore = nCheapBefore; fWorkAfter = nCheapAfter + nExpensiveAfter * fSigcheckVerificationFactor; } else { double nCheapBefore = data.nTransactionsLastCheckpoint; double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint; double nExpensiveAfter = (nNow - pindex->GetBlockTime()) / 86400.0 * data.fTransactionsPerDay; fWorkBefore = nCheapBefore + nExpensiveBefore * fSigcheckVerificationFactor; fWorkAfter = nExpensiveAfter * fSigcheckVerificationFactor; } return fWorkBefore / (fWorkBefore + fWorkAfter); } int GetTotalBlocksEstimate() { if (!fEnabled) return 0; const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; return checkpoints.rbegin()->first; } CBlockIndex* GetLastCheckpoint() { if (!fEnabled) return NULL; const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints; BOOST_REVERSE_FOREACH (const MapCheckpoints::value_type& i, checkpoints) { const uint256& hash = i.second; BlockMap::const_iterator t = mapBlockIndex.find(hash); if (t != mapBlockIndex.end()) return t->second; } return NULL; } } // namespace Checkpoints
[ "tri282@gmail.com" ]
tri282@gmail.com
52057c1dfdbec3375062b6adc039242928cab9f3
8870992bd11c38fa702c2187c0cf5c822a61457c
/src/lz/LZFactory.cpp
16b734df44ded9fbb6492f85acfbfc31e48c5dec
[]
no_license
ggtucker/lz77
8f32d4a56dee8efda0366c613c60d71a25e63810
3de09c9cdb50771eeec8ffee6ecf735e0c7f445a
refs/heads/master
2021-01-20T12:09:42.580262
2016-06-01T13:53:17
2016-06-01T13:53:17
60,049,821
0
0
null
null
null
null
UTF-8
C++
false
false
825
cpp
#include "LZFactory.h" namespace lz { Compressor CreateCompressor(const std::vector<std::string>& args, std::string& fileName) { int windowOffsetBits = 11; int matchLengthBits = 4; int literalLengthBits = 3; for (int i = 0; i < args.size(); ++i) { const std::string& arg = args[i]; if (arg.length() > 0 && arg.substr(0, 1) != "-") { fileName = arg; } else if (arg.length() > 3) { if(arg.substr(0, 3) == "-N=") { windowOffsetBits = std::stoi(arg.substr(3)); } else if (arg.substr(0, 3) == "-L=") { matchLengthBits = std::stoi(arg.substr(3)); } else if (arg.substr(0, 3) == "-S=") { literalLengthBits = std::stoi(arg.substr(3)); } } } return Compressor(windowOffsetBits, matchLengthBits, literalLengthBits); } }
[ "gtuck123@yahoo.com" ]
gtuck123@yahoo.com
7101eb7da318e382886d5f29b12a2847a96b4120
5056c300e4c0324b357c53cb68d077231d1e1c15
/src/DromeAudio/AudioContext.cpp
9878fc14f8f0e56d076a985b7ea38c1111672ecc
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
guthmanny/DromeAudio
0fa952b7009f1667902b6c0251522733a6604f84
f254730e2fb08428b6d78aed1b3dfd880009eba8
refs/heads/master
2021-05-30T07:11:17.009974
2015-07-04T19:15:47
2015-07-04T19:15:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,742
cpp
/* * Copyright (C) 2008-2010 Josh A. Beam * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 CONTACT, 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 <cstdio> #include <DromeAudio/AudioContext.h> namespace DromeAudio { /* * AudioContext class */ AudioContext::AudioContext(unsigned int targetSampleRate) { m_mutex = Mutex::create(); m_targetSampleRate = targetSampleRate; } AudioContext::~AudioContext() { delete m_mutex; } unsigned int AudioContext::getTargetSampleRate() const { return m_targetSampleRate; } void AudioContext::attachSoundEmitter(SoundEmitterPtr emitter) { m_mutex->lock(); m_emitters.insert(m_emitters.end(), emitter); m_mutex->unlock(); } void AudioContext::detachSoundEmitter(SoundEmitterPtr emitter) { m_mutex->lock(); for(unsigned int i = 0; i < m_emitters.size(); i++) { if(m_emitters[i] == emitter) { m_emitters.erase(m_emitters.begin() + i); break; } } m_mutex->unlock(); } SoundEmitterPtr AudioContext::playSound(SoundPtr sound) { SoundEmitterPtr emitter = SoundEmitter::create(m_targetSampleRate); emitter->setSound(sound); attachSoundEmitter(emitter); return emitter; } void AudioContext::writeSamples(AudioDriver *driver, unsigned int numSamples) { m_mutex->lock(); for(unsigned int i = 0; i < numSamples; i++) { Sample sample; // mix samples from all emitters for(unsigned int j = 0; j < m_emitters.size(); j++) sample += m_emitters[j]->getNextSample(); // write sample data driver->writeSample(sample.clamp()); } m_mutex->unlock(); } } // namespace DromeAudio
[ "josh@joshbeam.com" ]
josh@joshbeam.com
942c300d1bf7b5c6d1f07bf5252303d5472574a5
86dae49990a297d199ea2c8e47cb61336b1ca81e
/c/北大题库/1.2/第6题.cpp
e29042e13a269c93cd6e723b557bab5b3de488af
[]
no_license
yingziyu-llt/OI
7cc88f6537df0675b60718da73b8407bdaeb5f90
c8030807fe46b27e431687d5ff050f2f74616bc0
refs/heads/main
2023-04-04T03:59:22.255818
2021-04-11T10:15:03
2021-04-11T10:15:03
354,771,118
0
0
null
null
null
null
UTF-8
C++
false
false
104
cpp
#include <stdio.h> int main() { float a; scanf("%f",&a); printf("%d",(int)a); return 0; }
[ "linletian1@sina.com" ]
linletian1@sina.com
3ca2081a6da7e5d5b02839f209578ca3f87d3ed5
b8499de1a793500b47f36e85828f997e3954e570
/v2_3/build/Android/Preview/app/src/main/include/OpenGL.GLShaderType.h
6359026ad8a620a54b5a1f7331b8384e2979f174
[]
no_license
shrivaibhav/boysinbits
37ccb707340a14f31bd57ea92b7b7ddc4859e989
04bb707691587b253abaac064317715adb9a9fe5
refs/heads/master
2020-03-24T05:22:21.998732
2018-07-26T20:06:00
2018-07-26T20:06:00
142,485,250
0
0
null
2018-07-26T20:03:22
2018-07-26T19:30:12
C++
UTF-8
C++
false
false
357
h
// This file was generated based on 'C:/Users/hp laptop/AppData/Local/Fusetools/Packages/UnoCore/1.9.0/Source/OpenGL/GLEnums.uno'. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Int.h> namespace g{ namespace OpenGL{ // public extern enum GLShaderType :20 uEnumType* GLShaderType_typeof(); }} // ::g::OpenGL
[ "shubhamanandoist@gmail.com" ]
shubhamanandoist@gmail.com
e9e8be9e4ff730a2ac493483f1eb429d71f30789
336246549b947dbcc137508dd785bc963ea8e180
/projects/MonkVG-Test-Android/jni/boost/include/boost/config/user.hpp
d434e2ff85dadad81ede0e14bc66aedf3abdd49d
[ "BSD-3-Clause" ]
permissive
lukelutman/MonkVG
e214cd0f0328b896d39b386bd08ac73a3a53edb2
8abe6574b4661450712add844d3738b7c1e7ba2a
refs/heads/master
2020-12-25T01:51:36.425665
2013-08-20T16:18:46
2013-08-20T16:18:46
4,483,083
1
0
null
null
null
null
UTF-8
C++
false
false
5,379
hpp
// boost/config/user.hpp ---------------------------------------------------// // (C) Copyright John Maddock 2001. // Use, modification and distribution are subject to 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) // Do not check in modified versions of this file, // This file may be customized by the end user, but not by boost. // // Use this file to define a site and compiler specific // configuration policy: // // Android defines //#define BOOST_THREAD_LINUX 1 //#define BOOST_HAS_PTHREADS 1 //#define __arm__ 1 //#define _REENTRANT 1 //#define _GLIBCXX__PTHREADS 1 //#define BOOST_HAS_GETTIMEOFDAY 1 //#define BOOST_HAS_UNISTD_H 1 // define this to locate a compiler config file: // #define BOOST_COMPILER_CONFIG <myheader> // define this to locate a stdlib config file: // #define BOOST_STDLIB_CONFIG <myheader> // define this to locate a platform config file: // #define BOOST_PLATFORM_CONFIG <myheader> // define this to disable compiler config, // use if your compiler config has nothing to set: // #define BOOST_NO_COMPILER_CONFIG // define this to disable stdlib config, // use if your stdlib config has nothing to set: // #define BOOST_NO_STDLIB_CONFIG // define this to disable platform config, // use if your platform config has nothing to set: // #define BOOST_NO_PLATFORM_CONFIG // define this to disable all config options, // excluding the user config. Use if your // setup is fully ISO compliant, and has no // useful extensions, or for autoconf generated // setups: // #define BOOST_NO_CONFIG // define this to make the config "optimistic" // about unknown compiler versions. Normally // unknown compiler versions are assumed to have // all the defects of the last known version, however // setting this flag, causes the config to assume // that unknown compiler versions are fully conformant // with the standard: // #define BOOST_STRICT_CONFIG // define this to cause the config to halt compilation // with an #error if it encounters anything unknown -- // either an unknown compiler version or an unknown // compiler/platform/library: // #define BOOST_ASSERT_CONFIG // define if you want to disable threading support, even // when available: // #define BOOST_DISABLE_THREADS // define when you want to disable Win32 specific features // even when available: // #define BOOST_DISABLE_WIN32 // BOOST_DISABLE_ABI_HEADERS: Stops boost headers from including any // prefix/suffix headers that normally control things like struct // packing and alignment. // #define BOOST_DISABLE_ABI_HEADERS // BOOST_ABI_PREFIX: A prefix header to include in place of whatever // boost.config would normally select, any replacement should set up // struct packing and alignment options as required. // #define BOOST_ABI_PREFIX my-header-name // BOOST_ABI_SUFFIX: A suffix header to include in place of whatever // boost.config would normally select, any replacement should undo // the effects of the prefix header. // #define BOOST_ABI_SUFFIX my-header-name // BOOST_ALL_DYN_LINK: Forces all libraries that have separate source, // to be linked as dll's rather than static libraries on Microsoft Windows // (this macro is used to turn on __declspec(dllimport) modifiers, so that // the compiler knows which symbols to look for in a dll rather than in a // static library). Note that there may be some libraries that can only // be statically linked (Boost.Test for example) and others which may only // be dynamically linked (Boost.Threads for example), in these cases this // macro has no effect. // #define BOOST_ALL_DYN_LINK // BOOST_WHATEVER_DYN_LINK: Forces library "whatever" to be linked as a dll // rather than a static library on Microsoft Windows: replace the WHATEVER // part of the macro name with the name of the library that you want to // dynamically link to, for example use BOOST_DATE_TIME_DYN_LINK or // BOOST_REGEX_DYN_LINK etc (this macro is used to turn on __declspec(dllimport) // modifiers, so that the compiler knows which symbols to look for in a dll // rather than in a static library). // Note that there may be some libraries that can only be statically linked // (Boost.Test for example) and others which may only be dynamically linked // (Boost.Threads for example), in these cases this macro is unsupported. // #define BOOST_WHATEVER_DYN_LINK // BOOST_ALL_NO_LIB: Tells the config system not to automatically select // which libraries to link against. // Normally if a compiler supports #pragma lib, then the correct library // build variant will be automatically selected and linked against, // simply by the act of including one of that library's headers. // This macro turns that feature off. // #define BOOST_ALL_NO_LIB // BOOST_WHATEVER_NO_LIB: Tells the config system not to automatically // select which library to link against for library "whatever", // replace WHATEVER in the macro name with the name of the library; // for example BOOST_DATE_TIME_NO_LIB or BOOST_REGEX_NO_LIB. // Normally if a compiler supports #pragma lib, then the correct library // build variant will be automatically selected and linked against, simply // by the act of including one of that library's headers. This macro turns // that feature off. // #define BOOST_WHATEVER_NO_LIB
[ "p@qwiki.com" ]
p@qwiki.com
fd107c68795d2051fd44b7e7f85916fb7d9863ec
01aec9ef8a6e803c64fa947fdf3177581daca660
/P05/Full_Credit/tax.cpp
d5e0c2e79cd7155779c4ee3f536566a25f0befdb
[]
no_license
billnguyen02/cpp
a19714d6e3a43facb2cb5a894d0660a468290dca
01ed6a321b2c40f471bb58e3f31f26a2765b819a
refs/heads/master
2022-05-31T23:48:45.021759
2020-05-05T03:10:19
2020-05-05T03:10:19
236,669,371
0
0
null
null
null
null
UTF-8
C++
false
false
408
cpp
#include "tax.h" #include "product.h" #include <string.h> #include <iostream> double Taxed::_tax = 0; Taxed::Taxed(std::string name, double cost): Product(name,cost)// creating the object { //Constructor } Taxed::~Taxed() { } void Taxed::set_tax_rate(double sale_tax) { Taxed::_tax = sale_tax; } double Taxed::price() const { double x; x = (_quantity * _cost)*(1+_tax); return x; }
[ "billnguyen02@gmail.com" ]
billnguyen02@gmail.com
719fb41b2d652029fd659064a6f82e7e072b5a59
99e44f844d78de330391f2b17bbf2e293bf24b1b
/pytorch/modules/observers/perf_observer.cc
2de1ce65114f5a5440d4bbf55ba274b851946ca2
[ "MIT", "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "Apache-2.0", "BSD-2-Clause" ]
permissive
raghavnauhria/whatmt
be10d57bcd6134dd5714d0c4058abd56a1b35a13
c20483a437c82936cb0fb8080925e37b9c4bba87
refs/heads/master
2022-12-04T05:39:24.601698
2019-07-22T09:43:30
2019-07-22T09:43:30
193,026,689
0
1
MIT
2022-11-28T17:50:19
2019-06-21T03:48:20
C++
UTF-8
C++
false
false
6,536
cc
#include "observers/perf_observer.h" #include "observers/observer_config.h" #ifndef C10_MOBILE #include "caffe2/core/flags.h" #include "observers/net_observer_reporter_print.h" #endif #include <random> #include "caffe2/core/common.h" #include "caffe2/core/init.h" #include "caffe2/core/operator.h" #ifndef C10_MOBILE C10_DEFINE_int64( aiBench_netInitSampleRate, 0, "One in N sampling rate for net delay"); C10_DEFINE_int64( aiBench_netFollowupSampleRate, 0, "One in N sampling rate for net delay"); C10_DEFINE_int64( aiBench_netFollowupSampleCount, 0, "control the following c logs"); C10_DEFINE_int64( aiBench_operatorNetSampleRatio, 0, "One in N sampling rate for operator delay"); C10_DEFINE_int64( aiBench_skipIters, 0, "skip the first N iterations of the net run"); #endif namespace caffe2 { namespace { bool registerGlobalPerfNetObserverCreator(int* /*pargc*/, char*** /*pargv*/) { AddGlobalNetObserverCreator([](NetBase* subject) { return caffe2::make_unique<PerfNetObserver>(subject); }); #if !defined(C10_MOBILE) // for aibench usage caffe2::ObserverConfig::setReporter( caffe2::make_unique<caffe2::NetObserverReporterPrint>()); caffe2::ObserverConfig::initSampleRate( FLAGS_aiBench_netInitSampleRate, FLAGS_aiBench_netFollowupSampleRate, FLAGS_aiBench_netFollowupSampleCount, FLAGS_aiBench_operatorNetSampleRatio, FLAGS_aiBench_skipIters); #endif return true; } } // namespace REGISTER_CAFFE2_EARLY_INIT_FUNCTION( registerGlobalPerfNetObserverCreator, &registerGlobalPerfNetObserverCreator, "Caffe2 net global observer creator"); PerfNetObserver::PerfNetObserver(NetBase* subject_) : NetObserver(subject_), numRuns_(0) {} PerfNetObserver::~PerfNetObserver() {} void PerfNetObserver::Start() { static int visitCount = 0; // Select whether to log the operator or the net. // We have one sample rate for the entire app. int netInitSampleRate = ObserverConfig::getNetInitSampleRate(); int netFollowupSampleRate = ObserverConfig::getNetFollowupSampleRate(); int netFollowupSampleCount = ObserverConfig::getNetFollowupSampleCount(); int operatorNetSampleRatio = ObserverConfig::getOpoeratorNetSampleRatio(); int skipIters = ObserverConfig::getSkipIters(); int sampleRate = visitCount > 0 ? netFollowupSampleRate : netInitSampleRate; if (skipIters <= numRuns_ && sampleRate > 0 && rand() % sampleRate == 0) { visitCount++; if (visitCount == netFollowupSampleCount) { visitCount = 0; } if (operatorNetSampleRatio > 0 && rand() % operatorNetSampleRatio == 0) { logType_ = PerfNetObserver::OPERATOR_DELAY; } else { logType_ = PerfNetObserver::NET_DELAY; } } else { logType_ = PerfNetObserver::NONE; } numRuns_++; if (logType_ == PerfNetObserver::OPERATOR_DELAY) { /* Always recreate new operator observers whenever we measure operator delay */ const auto& operators = subject_->GetOperators(); for (auto* op : operators) { observerMap_[op] = op->AttachObserver( caffe2::make_unique<PerfOperatorObserver>(op, this)); } } if (logType_ != PerfNetObserver::NONE) { /* Only start timer when we need to */ timer_.Start(); } } void PerfNetObserver::Stop() { if (logType_ == PerfNetObserver::NONE) { return; } auto currentRunTime = timer_.MilliSeconds(); std::map<std::string, PerformanceInformation> info; PerformanceInformation net_perf; net_perf.latency = currentRunTime; if (logType_ == PerfNetObserver::OPERATOR_DELAY) { const auto& operators = subject_->GetOperators(); for (int idx = 0; idx < operators.size(); ++idx) { const auto* op = operators[idx]; auto name = getObserverName(op, idx); PerformanceInformation p; p.latency = static_cast<const PerfOperatorObserver*>(observerMap_[op]) ->getMilliseconds(); p.engine = op->engine(); p.type = op->type(); p.tensor_shapes = static_cast<const PerfOperatorObserver*>(observerMap_[op]) ->getTensorShapes(); if (op->has_debug_def()) { for (auto arg : op->debug_def().arg()) { p.args.emplace_back(arg); } } info.insert({name, p}); } /* clear all operator delay after use so that we don't spent time collecting the operator delay info in later runs */ for (auto* op : operators) { op->DetachObserver(observerMap_[op]); } observerMap_.clear(); } info.insert({"NET_DELAY", net_perf}); ObserverConfig::getReporter()->report(subject_, info); } caffe2::string PerfNetObserver::getObserverName(const OperatorBase* op, int idx) const { string opType = op->has_debug_def() ? op->debug_def().type() : "NO_TYPE"; string displayName = (op->has_debug_def() ? op->debug_def().name().size() ? op->debug_def().name() : (op->debug_def().output_size() ? op->debug_def().output(0) : "NO_OUTPUT") : "NO_DEF"); caffe2::string name = "ID_" + c10::to_string(idx) + "_" + opType + "_" + displayName; return name; } PerfOperatorObserver::PerfOperatorObserver( OperatorBase* op, PerfNetObserver* netObserver) : ObserverBase<OperatorBase>(op), netObserver_(netObserver), milliseconds_(0) { CAFFE_ENFORCE(netObserver_, "Observers can't operate outside of the net"); } PerfOperatorObserver::~PerfOperatorObserver() {} void PerfOperatorObserver::Start() { /* Get the time from the start of the net minus the time spent in previous invocations. It is the time spent on other operators. This way, when the operator finishes, the time from the start of the net minus the time spent in all other operators is the total time on this operator. This is done to avoid saving a timer in each operator */ milliseconds_ = netObserver_->getTimer().MilliSeconds() - milliseconds_; } void PerfOperatorObserver::Stop() { /* Time from the start of the net minus the time spent on all other operators is the time spent on this operator */ milliseconds_ = netObserver_->getTimer().MilliSeconds() - milliseconds_; tensor_shapes_ = subject_->InputTensorShapes(); } double PerfOperatorObserver::getMilliseconds() const { return milliseconds_; } std::vector<TensorShape> PerfOperatorObserver::getTensorShapes() const { return tensor_shapes_; } } // namespace caffe2
[ "rnauhria@gmail.com" ]
rnauhria@gmail.com
56c149472d375627429c10e9cb5465a92cd7b023
1ec08c24602ec02fa6dd688fff88b37a42b368ad
/Filtering/vtkTAG2EDataSetN2OFilterBouwman.h
e4ca850d0953a2467bd9833c09b2c630f3dd03e9
[]
no_license
huhabla/tag2e
da4e852d4b19e29cf35b17370ee3003d1f76702c
ad196c29dc0f669881d153368a7b6a845e104938
refs/heads/master
2021-01-10T10:10:18.597837
2013-11-22T10:36:37
2013-11-22T10:36:37
53,035,499
0
0
null
null
null
null
UTF-8
C++
false
false
4,329
h
/* * Toolkit for Agriculture Greenhouse Gas Emission Estimation TAG2E * * Authors: Soeren Gebbert, soeren.gebbert@vti.bund.de * Rene Dechow, rene.dechow@vti.bund.de * * Copyright: * * Johann Heinrich von Thünen-Institut * Institut für Agrarrelevante Klimaforschung * * Phone: +49 (0)531 596 2601 * * Fax:+49 (0)531 596 2699 * * Mail: ak@vti.bund.de * * Bundesallee 50 * 38116 Braunschweig * Germany * * * 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; version 2 of the License. * * 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. */ /** * \brief This class computes the annual emission of N2O in [kg /(ha a)] for * agricultural mineral soil in Europe. * * As input any vtkDataSet can be used including the input parameter as cell or * point data. The usage of categories for similiar cells/points * (image or polydata) can speed up the processing in case the number of * categories is smaller than the number cells/points. The N2O emission is only * computed for a single category and stored for each cell/point with this category. * * Cell data will be used as default. The resulting data set contains the structure * of the input data set and the resulting N2O emission in [kg /(ha a)]. * * \author Soeren Gebbert * \author Rene Dechow * * \cite Controls and models for estimating direct nitrous oxide emissions from * temperate and sub-boreal agricultural mineral soils in Europe. * Annette Freibauer and Martin Kaltschmitt * * */ #ifndef __vtkTAG2EDataSetN2OFilterBouwman_h #define __vtkTAG2EDataSetN2OFilterBouwman_h #include <vtkDataSetAlgorithm.h> #include "vtkTAG2EFilteringWin32Header.h" class VTK_TAG2E_FILTERING_EXPORT vtkTAG2EDataSetN2OFilterBouwman : public vtkDataSetAlgorithm { public: vtkTypeRevisionMacro(vtkTAG2EDataSetN2OFilterBouwman,vtkDataSetAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); static vtkTAG2EDataSetN2OFilterBouwman *New(); //!\brief The name of the array of annual fertilizer input in [(kg N )/(ha a)] vtkSetStringMacro(NitrogenRateArrayName); //!\brief The name of the category array, which describes cells/points with identical //! data. This is used to speed up the computation in case the input data set //! has many cells/points but does not vary much in parameters (Like the multi polygon //! approach for grouping different but data identical areas) //! Categories must be integer values in range 0 .. n. vtkSetStringMacro(CategoryArrayName); //!\brief The name of the array of annual fertilizer input in [(kg N )/(ha a)] vtkGetStringMacro(NitrogenRateArrayName); //!\brief The name of the category array, which describes cells/points with identical //! data. This is used to speed up the computation in case the input data set //! has many cells/points but does not vary much in parameters (Like the multi polygon //! approach for grouping different but data identical areas) vtkGetStringMacro(CategoryArrayName); //!\brief Use the point data arrays instead of the default cell data arrays vtkSetMacro(UsePointData, int); //!\brief Use the point data arrays instead of the default cell data arrays vtkGetMacro(UsePointData, int); //!\brief Use the point data arrays instead of the default cell data arrays vtkBooleanMacro(UsePointData, int); //!\brief The value which should be used as result for wrong category data vtkSetMacro(NullValue, double); //!\brief The value which should be used as result for wrong category data vtkGetMacro(NullValue, double); protected: vtkTAG2EDataSetN2OFilterBouwman(); ~vtkTAG2EDataSetN2OFilterBouwman() {}; char *NitrogenRateArrayName; char *CategoryArrayName; int UsePointData; double NullValue; int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); private: vtkTAG2EDataSetN2OFilterBouwman(const vtkTAG2EDataSetN2OFilterBouwman&); // Not implemented. void operator=(const vtkTAG2EDataSetN2OFilterBouwman&); // Not implemented. }; #endif
[ "soerengebbert@16fbe261-6e97-5eb1-f61f-830664b603fa" ]
soerengebbert@16fbe261-6e97-5eb1-f61f-830664b603fa
26a345b9c80b2ac662eb21a1d2a0c56364c82cea
48920bcb593311333e08d3dd1f8229e39f37df44
/jni/source/GEventManager/GEventManager.cpp
2c2e147ec55fa6da10b80c84c90ea2b645e89b90
[]
no_license
denny-zefanya/Android-RTSP-Player
d5cded5f4eed75a42e429db3fa1693ec12856dfc
7dc497a604cdd4a8e00b8e38b12abe46e3eaff28
refs/heads/master
2021-06-21T02:10:14.603878
2017-07-11T09:46:03
2017-07-11T09:46:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
430
cpp
#include "GEventManager.h" GEventManager &GEventManager::sharedInstance() { static GEventManager instance; return instance; } int GEventManager::eventRunLoop(JNIEnv *env, jobject javaEventData) { int result = -1; do { if ( !GEngine::sharedInstance().eventRunLoop( &mEventData ) ) break; if ( mEventConverter.convert( env, javaEventData, mEventData ) ) result = 0; } while(0); return result; }
[ "John@johndeMac.local" ]
John@johndeMac.local
0ca5653301aea7a760fe868b95733be30fd3cb4f
a77675f6834ebbc95570df0b5e19018401a8d28f
/codeforces/cf_451B.cpp
29708a14f02f1d22a5f567b941f6bcd95a6a2cb6
[]
no_license
ho-dor/cp-records
1ea29b5d59d119f26b73be5a9663b1a5548ed687
45b6d2bd09ac6082ca722f7b0baea5d2ed10724a
refs/heads/master
2021-06-14T05:19:22.129105
2020-08-13T17:40:30
2020-08-13T17:40:30
254,469,245
0
0
null
null
null
null
UTF-8
C++
false
false
870
cpp
#include <bits/stdc++.h> using namespace std; const int N = (int) 1e5 + 5; int a[N], b[N]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } map<int, int> mp; sort(b, b + n); for (int i = 0; i < n; i++) { mp[b[i]] = i; } for (int i = 0; i < n; i++) { a[i] = mp[a[i]]; } int L = -1; for (int i = 0; i < n; i++) { if (a[i] != i) { L = i; break; } } int R = -1; for (int i = n - 1; i >= 0; i--) { if (a[i] != i) { R = i; break; } } if (L == -1 || R == -1) { cout << "yes" << endl; cout << 1 << " " << 1 << endl; } else { reverse(a + L, a + R + 1); int ok = true; for (int i = 0; i < n; i++) { if (a[i] != i) { ok = false; } } if (ok) { cout << "yes" << endl; cout << L + 1 << " " << R + 1 << endl; } else { cout << "no" << endl; } } return 0; }
[ "kunalrai.cse16@nituk.ac.in" ]
kunalrai.cse16@nituk.ac.in
3ac5171204bc33bd1261e9193d58974dc979e270
fad392b7b1533103a0ddcc18e059fcd2e85c0fda
/build/px4_msgs/rosidl_typesupport_fastrtps_cpp/px4_msgs/msg/sensor_gyro_fft__rosidl_typesupport_fastrtps_cpp.hpp
5d6bd4550eae3f8cafdfe5bf3d746638e70d4220
[]
no_license
adamdai/px4_ros_com_ros2
bee6ef27559a3a157d10c250a45818a5c75f2eff
bcd7a1bd13c318d69994a64215f256b9ec7ae2bb
refs/heads/master
2023-07-24T18:09:24.817561
2021-08-23T21:47:18
2021-08-23T21:47:18
399,255,215
0
0
null
null
null
null
UTF-8
C++
false
false
2,055
hpp
// generated from rosidl_typesupport_fastrtps_cpp/resource/idl__rosidl_typesupport_fastrtps_cpp.hpp.em // with input from px4_msgs:msg/SensorGyroFft.idl // generated code does not contain a copyright notice #ifndef PX4_MSGS__MSG__SENSOR_GYRO_FFT__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_ #define PX4_MSGS__MSG__SENSOR_GYRO_FFT__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_ #include "rosidl_generator_c/message_type_support_struct.h" #include "rosidl_typesupport_interface/macros.h" #include "px4_msgs/msg/rosidl_typesupport_fastrtps_cpp__visibility_control.h" #include "px4_msgs/msg/sensor_gyro_fft__struct.hpp" #ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wunused-parameter" # ifdef __clang__ # pragma clang diagnostic ignored "-Wdeprecated-register" # pragma clang diagnostic ignored "-Wreturn-type-c-linkage" # endif #endif #ifndef _WIN32 # pragma GCC diagnostic pop #endif #include "fastcdr/Cdr.h" namespace px4_msgs { namespace msg { namespace typesupport_fastrtps_cpp { bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_px4_msgs cdr_serialize( const px4_msgs::msg::SensorGyroFft & ros_message, eprosima::fastcdr::Cdr & cdr); bool ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_px4_msgs cdr_deserialize( eprosima::fastcdr::Cdr & cdr, px4_msgs::msg::SensorGyroFft & ros_message); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_px4_msgs get_serialized_size( const px4_msgs::msg::SensorGyroFft & ros_message, size_t current_alignment); size_t ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_px4_msgs max_serialized_size_SensorGyroFft( bool & full_bounded, size_t current_alignment); } // namespace typesupport_fastrtps_cpp } // namespace msg } // namespace px4_msgs #ifdef __cplusplus extern "C" { #endif ROSIDL_TYPESUPPORT_FASTRTPS_CPP_PUBLIC_px4_msgs const rosidl_message_type_support_t * ROSIDL_TYPESUPPORT_INTERFACE__MESSAGE_SYMBOL_NAME(rosidl_typesupport_fastrtps_cpp, px4_msgs, msg, SensorGyroFft)(); #ifdef __cplusplus } #endif #endif // PX4_MSGS__MSG__SENSOR_GYRO_FFT__ROSIDL_TYPESUPPORT_FASTRTPS_CPP_HPP_
[ "adamdai97@gmail.com" ]
adamdai97@gmail.com
29d3473ed334e61fae3eb7b1f8d84936fe722f5a
572024902ee45d7246bceff508f1035f8c464693
/third_party/swiftshader/src/OpenGL/libGLESv2/Texture.h
d5e0c808cfe700eed1f152c7163a4dacba9463eb
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT", "BSD-3-Clause" ]
permissive
mediabuff/Prelude
539a275a52d65e1bf84dc218772ea24fff384391
601507c6dc8cf27999ceffc0fef97afba2bd764d
refs/heads/master
2020-03-12T16:31:18.951711
2018-03-27T13:36:22
2018-04-05T19:31:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,306
h
// Copyright 2016 The SwiftShader Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // 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. // Texture.h: Defines the abstract Texture class and its concrete derived // classes Texture2D and TextureCubeMap. Implements GL texture objects and // related functionality. [OpenGL ES 2.0.24] section 3.7 page 63. #ifndef LIBGLESV2_TEXTURE_H_ #define LIBGLESV2_TEXTURE_H_ #include "Renderbuffer.h" #include "common/Object.hpp" #include "utilities.h" #include "libEGL/Texture.hpp" #include "common/debug.h" #include <GLES2/gl2.h> #include <vector> namespace gl { class Surface; } namespace es2 { class Framebuffer; enum { IMPLEMENTATION_MAX_TEXTURE_LEVELS = sw::MIPMAP_LEVELS, IMPLEMENTATION_MAX_TEXTURE_SIZE = 1 << (IMPLEMENTATION_MAX_TEXTURE_LEVELS - 1), IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE = 1 << (IMPLEMENTATION_MAX_TEXTURE_LEVELS - 1), IMPLEMENTATION_MAX_RENDERBUFFER_SIZE = sw::OUTLINE_RESOLUTION, }; class Texture : public egl::Texture { public: explicit Texture(GLuint name); sw::Resource *getResource() const override; virtual void addProxyRef(const Renderbuffer *proxy) = 0; virtual void releaseProxy(const Renderbuffer *proxy) = 0; virtual GLenum getTarget() const = 0; bool setMinFilter(GLenum filter); bool setMagFilter(GLenum filter); bool setWrapS(GLenum wrap); bool setWrapT(GLenum wrap); bool setWrapR(GLenum wrap); bool setMaxAnisotropy(GLfloat textureMaxAnisotropy); bool setBaseLevel(GLint baseLevel); bool setCompareFunc(GLenum compareFunc); bool setCompareMode(GLenum compareMode); void makeImmutable(GLsizei levels); bool setMaxLevel(GLint maxLevel); bool setMaxLOD(GLfloat maxLOD); bool setMinLOD(GLfloat minLOD); bool setSwizzleR(GLenum swizzleR); bool setSwizzleG(GLenum swizzleG); bool setSwizzleB(GLenum swizzleB); bool setSwizzleA(GLenum swizzleA); GLenum getMinFilter() const; GLenum getMagFilter() const; GLenum getWrapS() const; GLenum getWrapT() const; GLenum getWrapR() const; GLfloat getMaxAnisotropy() const; GLint getBaseLevel() const; GLenum getCompareFunc() const; GLenum getCompareMode() const; GLboolean getImmutableFormat() const; GLsizei getImmutableLevels() const; GLint getMaxLevel() const; GLfloat getMaxLOD() const; GLfloat getMinLOD() const; GLenum getSwizzleR() const; GLenum getSwizzleG() const; GLenum getSwizzleB() const; GLenum getSwizzleA() const; virtual GLsizei getWidth(GLenum target, GLint level) const = 0; virtual GLsizei getHeight(GLenum target, GLint level) const = 0; virtual GLsizei getDepth(GLenum target, GLint level) const; virtual GLenum getFormat(GLenum target, GLint level) const = 0; virtual GLenum getType(GLenum target, GLint level) const = 0; virtual sw::Format getInternalFormat(GLenum target, GLint level) const = 0; virtual int getLevelCount() const = 0; virtual bool isSamplerComplete() const = 0; virtual bool isCompressed(GLenum target, GLint level) const = 0; virtual bool isDepth(GLenum target, GLint level) const = 0; virtual Renderbuffer *getRenderbuffer(GLenum target, GLint level, GLint layer) = 0; virtual egl::Image *getRenderTarget(GLenum target, unsigned int level) = 0; egl::Image *createSharedImage(GLenum target, unsigned int level); virtual bool isShared(GLenum target, unsigned int level) const = 0; virtual void generateMipmaps() = 0; virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) = 0; protected: ~Texture() override; void setImage(egl::Context *context, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels, egl::Image *image); void subImage(egl::Context *context, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels, egl::Image *image); void setCompressedImage(GLsizei imageSize, const void *pixels, egl::Image *image); void subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels, egl::Image *image); bool copy(egl::Image *source, const sw::SliceRect &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, GLint zoffset, egl::Image *dest); bool isMipmapFiltered() const; GLenum mMinFilter; GLenum mMagFilter; GLenum mWrapS; GLenum mWrapT; GLenum mWrapR; GLfloat mMaxAnisotropy; GLint mBaseLevel; GLenum mCompareFunc; GLenum mCompareMode; GLboolean mImmutableFormat; GLsizei mImmutableLevels; GLint mMaxLevel; GLfloat mMaxLOD; GLfloat mMinLOD; GLenum mSwizzleR; GLenum mSwizzleG; GLenum mSwizzleB; GLenum mSwizzleA; sw::Resource *resource; }; class Texture2D : public Texture { public: explicit Texture2D(GLuint name); void addProxyRef(const Renderbuffer *proxy) override; void releaseProxy(const Renderbuffer *proxy) override; void sweep() override; GLenum getTarget() const override; GLsizei getWidth(GLenum target, GLint level) const override; GLsizei getHeight(GLenum target, GLint level) const override; GLenum getFormat(GLenum target, GLint level) const override; GLenum getType(GLenum target, GLint level) const override; sw::Format getInternalFormat(GLenum target, GLint level) const override; int getLevelCount() const override; void setImage(egl::Context *context, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void subImage(egl::Context *context, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) override; void setSharedImage(egl::Image *image); bool isSamplerComplete() const override; bool isCompressed(GLenum target, GLint level) const override; bool isDepth(GLenum target, GLint level) const override; void bindTexImage(gl::Surface *surface); void releaseTexImage() override; void generateMipmaps() override; Renderbuffer *getRenderbuffer(GLenum target, GLint level, GLint layer) override; egl::Image *getRenderTarget(GLenum target, unsigned int level) override; bool isShared(GLenum target, unsigned int level) const override; egl::Image *getImage(unsigned int level); protected: ~Texture2D() override; bool isMipmapComplete() const; egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS]; gl::Surface *mSurface; // A specific internal reference count is kept for colorbuffer proxy references, // because, as the renderbuffer acting as proxy will maintain a binding pointer // back to this texture, there would be a circular reference if we used a binding // pointer here. This reference count will cause the pointer to be set to null if // the count drops to zero, but will not cause deletion of the Renderbuffer. Renderbuffer *mColorbufferProxy; unsigned int mProxyRefs; }; class TextureCubeMap : public Texture { public: explicit TextureCubeMap(GLuint name); void addProxyRef(const Renderbuffer *proxy) override; void releaseProxy(const Renderbuffer *proxy) override; void sweep() override; GLenum getTarget() const override; GLsizei getWidth(GLenum target, GLint level) const override; GLsizei getHeight(GLenum target, GLint level) const override; GLenum getFormat(GLenum target, GLint level) const override; GLenum getType(GLenum target, GLint level) const override; sw::Format getInternalFormat(GLenum target, GLint level) const override; int getLevelCount() const override; void setImage(egl::Context *context, GLenum target, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); void subImage(egl::Context *context, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels); void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source) override; bool isSamplerComplete() const override; bool isCompressed(GLenum target, GLint level) const override; bool isDepth(GLenum target, GLint level) const override; void releaseTexImage() override; void generateMipmaps() override; void updateBorders(int level); Renderbuffer *getRenderbuffer(GLenum target, GLint level, GLint layer) override; egl::Image *getRenderTarget(GLenum target, unsigned int level) override; bool isShared(GLenum target, unsigned int level) const override; egl::Image *getImage(int face, unsigned int level); protected: ~TextureCubeMap() override; private: bool isCubeComplete() const; bool isMipmapCubeComplete() const; // face is one of the GL_TEXTURE_CUBE_MAP_* enumerants. Returns nullptr on failure. egl::Image *getImage(GLenum face, unsigned int level); egl::Image *image[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS]; // A specific internal reference count is kept for colorbuffer proxy references, // because, as the renderbuffer acting as proxy will maintain a binding pointer // back to this texture, there would be a circular reference if we used a binding // pointer here. This reference count will cause the pointer to be set to null if // the count drops to zero, but will not cause deletion of the Renderbuffer. Renderbuffer *mFaceProxies[6]; unsigned int mFaceProxyRefs[6]; }; class Texture3D : public Texture { public: explicit Texture3D(GLuint name); void addProxyRef(const Renderbuffer *proxy) override; void releaseProxy(const Renderbuffer *proxy) override; void sweep() override; GLenum getTarget() const override; GLsizei getWidth(GLenum target, GLint level) const override; GLsizei getHeight(GLenum target, GLint level) const override; GLsizei getDepth(GLenum target, GLint level) const override; GLenum getFormat(GLenum target, GLint level) const override; GLenum getType(GLenum target, GLint level) const override; sw::Format getInternalFormat(GLenum target, GLint level) const override; int getLevelCount() const override; void setImage(egl::Context *context, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void setCompressedImage(GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); void subImage(egl::Context *context, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const egl::Image::UnpackInfo& unpackInfo, const void *pixels); void subImageCompressed(GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *pixels); void copyImage(GLint level, GLenum format, GLint x, GLint y, GLint z, GLsizei width, GLsizei height, GLsizei depth, Framebuffer *source); void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source); void setSharedImage(egl::Image *image); bool isSamplerComplete() const override; bool isCompressed(GLenum target, GLint level) const override; bool isDepth(GLenum target, GLint level) const override; void releaseTexImage() override; void generateMipmaps() override; Renderbuffer *getRenderbuffer(GLenum target, GLint level, GLint layer) override; egl::Image *getRenderTarget(GLenum target, unsigned int level) override; bool isShared(GLenum target, unsigned int level) const override; egl::Image *getImage(unsigned int level); protected: ~Texture3D() override; bool isMipmapComplete() const; egl::Image *image[IMPLEMENTATION_MAX_TEXTURE_LEVELS]; gl::Surface *mSurface; // A specific internal reference count is kept for colorbuffer proxy references, // because, as the renderbuffer acting as proxy will maintain a binding pointer // back to this texture, there would be a circular reference if we used a binding // pointer here. This reference count will cause the pointer to be set to null if // the count drops to zero, but will not cause deletion of the Renderbuffer. Renderbuffer *mColorbufferProxy; unsigned int mProxyRefs; }; class Texture2DArray : public Texture3D { public: explicit Texture2DArray(GLuint name); GLenum getTarget() const override; void generateMipmaps() override; protected: ~Texture2DArray() override; }; class TextureExternal : public Texture2D { public: explicit TextureExternal(GLuint name); GLenum getTarget() const override; protected: ~TextureExternal() override; }; } #endif // LIBGLESV2_TEXTURE_H_
[ "xzwang2005@gmail.com" ]
xzwang2005@gmail.com
d0131ba8aa9e0dbb163859db3b6053ed344b5690
ec6eb51ad222f490555744617ef8fda1a08a8f33
/ppc_simd.h
1efd2030ca8a9e08eb520eb4eca3eebff62b1297
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0", "LicenseRef-scancode-public-domain" ]
permissive
bobsayshilol/cryptopp
f2162a18e2427c7a813f5daedad402ec2b6a2f4d
fc1e98e70d425bc8fd3780c237a43f2facfc1460
refs/heads/master
2020-04-06T12:35:34.928740
2018-11-13T19:02:40
2018-11-13T19:02:40
157,461,742
0
0
NOASSERTION
2018-11-13T23:37:32
2018-11-13T23:37:32
null
UTF-8
C++
false
false
28,668
h
// ppc_simd.h - written and placed in public domain by Jeffrey Walton /// \file ppc_simd.h /// \brief Support functions for PowerPC and vector operations /// \details This header provides an agnostic interface into GCC and /// IBM XL C/C++ compilers modulo their different built-in functions /// for accessing vector intructions. /// \details The abstractions are necesssary to support back to GCC 4.8. /// GCC 4.8 and 4.9 are still popular, and they are the default /// compiler for GCC112, GCC118 and others on the compile farm. Older /// IBM XL C/C++ compilers also experience it due to lack of /// <tt>vec_xl_be</tt> support on some platforms. Modern compilers /// provide best support and don't need many of the little hacks below. /// \since Crypto++ 6.0 #ifndef CRYPTOPP_PPC_CRYPTO_H #define CRYPTOPP_PPC_CRYPTO_H #include "config.h" #include "misc.h" // We are boxed into undefining macros like CRYPTOPP_POWER8_AVAILABLE. // We set CRYPTOPP_POWER8_AVAILABLE based on compiler versions because // we needed them for the SIMD and non-SIMD files. When the SIMD file is // compiled it may only get -mcpu=power4 or -mcpu=power7, so the POWER7 // or POWER8 stuff is not actually available when this header is included. // We also need to handle the case of -DCRYPTOPP_ALTIVEC_AVAILABLE=0. #if !defined(__ALTIVEC__) # undef CRYPTOPP_ALTIVEC_AVAILABLE #endif #if !defined(_ARCH_PWR7) # undef CRYPTOPP_POWER7_AVAILABLE #endif #if !(defined(_ARCH_PWR8) || defined(_ARCH_PWR9) || defined(__CRYPTO) || defined(__CRYPTO__)) # undef CRYPTOPP_POWER8_AVAILABLE # undef CRYPTOPP_POWER8_AES_AVAILABLE # undef CRYPTOPP_POWER8_VMULL_AVAILABLE # undef CRYPTOPP_POWER8_SHA_AVAILABLE #endif #if (CRYPTOPP_ALTIVEC_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) # include <altivec.h> # undef vector # undef pixel # undef bool #endif #if !(CRYPTOPP_ALTIVEC_AVAILABLE) # undef CRYPTOPP_POWER7_AVAILABLE # undef CRYPTOPP_POWER8_AVAILABLE # undef CRYPTOPP_POWER8_AES_AVAILABLE # undef CRYPTOPP_POWER8_VMULL_AVAILABLE # undef CRYPTOPP_POWER8_SHA_AVAILABLE #endif NAMESPACE_BEGIN(CryptoPP) // Wrap everything in this file based on CRYPTOPP_ALTIVEC_AVAILABLE #if (CRYPTOPP_ALTIVEC_AVAILABLE) // Datatypes #if (CRYPTOPP_ALTIVEC_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) typedef __vector unsigned char uint8x16_p; typedef __vector unsigned short uint16x8_p; typedef __vector unsigned int uint32x4_p; #if (CRYPTOPP_POWER8_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) typedef __vector unsigned long long uint64x2_p; #endif // POWER8 datatypes #endif // ALTIVEC datatypes // Applies to all POWER machines #if (CRYPTOPP_ALTIVEC_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) /// \brief Reverse a vector /// \tparam T vector type /// \param src the vector /// \returns vector /// \details Reverse() endian swaps the bytes in a vector /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 template <class T> inline T Reverse(const T& src) { const uint8x16_p mask = {15,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0}; return (T)vec_perm(src, src, mask); } /// \brief Permutes a vector /// \tparam T vector type /// \param vec the vector /// \param mask vector mask /// \returns vector /// \details VectorPermute returns a new vector from vec based on /// mask. mask is an uint8x16_p type vector. The return /// vector is the same type as vec. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorPermute(const T1& vec, const T2& mask) { return (T1)vec_perm(vec, vec, (uint8x16_p)mask); } /// \brief Permutes two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \param mask vector mask /// \returns vector /// \details VectorPermute returns a new vector from vec1 and vec2 /// based on mask. mask is an uint8x16_p type vector. The return /// vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorPermute(const T1& vec1, const T1& vec2, const T2& mask) { return (T1)vec_perm(vec1, vec2, (uint8x16_p)mask); } /// \brief AND two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns vector /// \details VectorAnd returns a new vector from vec1 and vec2. The return /// vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorAnd(const T1& vec1, const T2& vec2) { return (T1)vec_and(vec1, (T1)vec2); } /// \brief OR two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns vector /// \details VectorOr returns a new vector from vec1 and vec2. The return /// vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorOr(const T1& vec1, const T2& vec2) { return (T1)vec_or(vec1, (T1)vec2); } /// \brief XOR two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns vector /// \details VectorXor returns a new vector from vec1 and vec2. The return /// vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorXor(const T1& vec1, const T2& vec2) { return (T1)vec_xor(vec1, (T1)vec2); } /// \brief Add two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns vector /// \details VectorAdd returns a new vector from vec1 and vec2. /// vec2 is cast to the same type as vec1. The return vector /// is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorAdd(const T1& vec1, const T2& vec2) { return (T1)vec_add(vec1, (T1)vec2); } /// \brief Subtract two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \details VectorSub returns a new vector from vec1 and vec2. /// vec2 is cast to the same type as vec1. The return vector /// is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorSub(const T1& vec1, const T2& vec2) { return (T1)vec_sub(vec1, (T1)vec2); } /// \brief Shift a vector left /// \tparam C shift byte count /// \tparam T vector type /// \param vec the vector /// \returns vector /// \details VectorShiftLeft() returns a new vector after shifting the /// concatenation of the zero vector and the source vector by the specified /// number of bytes. The return vector is the same type as vec. /// \details On big endian machines VectorShiftLeft() is <tt>vec_sld(a, z, /// c)</tt>. On little endian machines VectorShiftLeft() is translated to /// <tt>vec_sld(z, a, 16-c)</tt>. You should always call the function as /// if on a big endian machine as shown below. /// <pre> /// uint8x16_p r1 = VectorLoad(ptr); /// uint8x16_p r5 = VectorShiftLeft<12>(r1); /// </pre> /// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld /// endian sensitive?</A> on Stack Overflow /// \since Crypto++ 6.0 template <unsigned int C, class T> inline T VectorShiftLeft(const T& vec) { const T zero = {0}; if (C >= 16) { // Out of range return zero; } else if (C == 0) { // Noop return vec; } else { #if (CRYPTOPP_BIG_ENDIAN) return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); #else return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); #endif } } /// \brief Shift a vector right /// \tparam C shift byte count /// \tparam T vector type /// \param vec the vector /// \returns vector /// \details VectorShiftRight() returns a new vector after shifting the /// concatenation of the zero vector and the source vector by the specified /// number of bytes. The return vector is the same type as vec. /// \details On big endian machines VectorShiftRight() is <tt>vec_sld(a, z, /// c)</tt>. On little endian machines VectorShiftRight() is translated to /// <tt>vec_sld(z, a, 16-c)</tt>. You should always call the function as /// if on a big endian machine as shown below. /// <pre> /// uint8x16_p r1 = VectorLoad(ptr); /// uint8x16_p r5 = VectorShiftRight<12>(r1); /// </pre> /// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld /// endian sensitive?</A> on Stack Overflow /// \since Crypto++ 6.0 template <unsigned int C, class T> inline T VectorShiftRight(const T& vec) { const T zero = {0}; if (C >= 16) { // Out of range return zero; } else if (C == 0) { // Noop return vec; } else { #if (CRYPTOPP_BIG_ENDIAN) return (T)vec_sld((uint8x16_p)zero, (uint8x16_p)vec, 16-C); #else return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)zero, C); #endif } } /// \brief Rotate a vector left /// \tparam C shift byte count /// \tparam T vector type /// \param vec the vector /// \returns vector /// \details VectorRotateLeft() returns a new vector after rotating the /// concatenation of the source vector with itself by the specified /// number of bytes. The return vector is the same type as vec. /// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld /// endian sensitive?</A> on Stack Overflow /// \since Crypto++ 6.0 template <unsigned int C, class T> inline T VectorRotateLeft(const T& vec) { enum { R = C&0xf }; #if (CRYPTOPP_BIG_ENDIAN) return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R); #else return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, 16-R); #endif } /// \brief Rotate a vector right /// \tparam C shift byte count /// \tparam T vector type /// \param vec the vector /// \returns vector /// \details VectorRotateRight() returns a new vector after rotating the /// concatenation of the source vector with itself by the specified /// number of bytes. The return vector is the same type as vec. /// \sa <A HREF="https://stackoverflow.com/q/46341923/608639">Is vec_sld /// endian sensitive?</A> on Stack Overflow /// \since Crypto++ 6.0 template <unsigned int C, class T> inline T VectorRotateRight(const T& vec) { enum { R = C&0xf }; #if (CRYPTOPP_BIG_ENDIAN) return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, 16-R); #else return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, R); #endif } /// \brief Exchange high and low double words /// \tparam T vector type /// \param vec the vector /// \returns vector /// \since Crypto++ 7.0 template <class T> inline T VectorSwapWords(const T& vec) { return (T)vec_sld((uint8x16_p)vec, (uint8x16_p)vec, 8); } /// \brief Extract a dword from a vector /// \tparam T vector type /// \param val the vector /// \returns vector created from low dword /// \details VectorGetLow() extracts the low dword from a vector. The low dword /// is composed of the least significant bits and occupies bytes 8 through 15 /// when viewed as a big endian array. The return vector is the same type as /// the original vector and padded with 0's in the most significant bit positions. template <class T> inline T VectorGetLow(const T& val) { //const T zero = {0}; //const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 8,9,10,11, 12,13,14,15 }; //return (T)vec_perm(zero, val, mask); return VectorShiftRight<8>(VectorShiftLeft<8>(val)); } /// \brief Extract a dword from a vector /// \tparam T vector type /// \param val the vector /// \returns vector created from high dword /// \details VectorGetHigh() extracts the high dword from a vector. The high dword /// is composed of the most significant bits and occupies bytes 0 through 7 /// when viewed as a big endian array. The return vector is the same type as /// the original vector and padded with 0's in the most significant bit positions. template <class T> inline T VectorGetHigh(const T& val) { //const T zero = {0}; //const uint8x16_p mask = {16,16,16,16, 16,16,16,16, 0,1,2,3, 4,5,6,7 }; //return (T)vec_perm(zero, val, mask); return VectorShiftRight<8>(val); } /// \brief Compare two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns true if vec1 equals vec2, false otherwise template <class T1, class T2> inline bool VectorEqual(const T1& vec1, const T2& vec2) { return 1 == vec_all_eq((uint32x4_p)vec1, (uint32x4_p)vec2); } /// \brief Compare two vectors /// \tparam T1 vector type /// \tparam T2 vector type /// \param vec1 the first vector /// \param vec2 the second vector /// \returns true if vec1 does not equal vec2, false otherwise template <class T1, class T2> inline bool VectorNotEqual(const T1& vec1, const T2& vec2) { return 0 == vec_all_eq((uint32x4_p)vec1, (uint32x4_p)vec2); } #endif // POWER4 and above // POWER7/POWER4 load and store #if (CRYPTOPP_POWER7_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) /// \brief Loads a vector from a byte array /// \param src the byte array /// \details Loads a vector in big endian format from a byte array. /// VectorLoadBE will swap endianess on little endian systems. /// \note VectorLoadBE() does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoadBE(const byte src[16]) { #if defined(CRYPTOPP_XLC_VERSION) return (uint32x4_p)vec_xl_be(0, (byte*)src); #else # if (CRYPTOPP_BIG_ENDIAN) return (uint32x4_p)vec_vsx_ld(0, src); # else return (uint32x4_p)Reverse(vec_vsx_ld(0, src)); # endif #endif } /// \brief Loads a vector from a byte array /// \param src the byte array /// \param off offset into the src byte array /// \details Loads a vector in big endian format from a byte array. /// VectorLoadBE will swap endianess on little endian systems. /// \note VectorLoadBE does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoadBE(int off, const byte src[16]) { #if defined(CRYPTOPP_XLC_VERSION) return (uint32x4_p)vec_xl_be(off, (byte*)src); #else # if (CRYPTOPP_BIG_ENDIAN) return (uint32x4_p)vec_vsx_ld(off, (byte*)src); # else return (uint32x4_p)Reverse(vec_vsx_ld(off, (byte*)src)); # endif #endif } /// \brief Loads a vector from a byte array /// \param src the byte array /// \details Loads a vector in native endian format from a byte array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(const byte src[16]) { #if defined(CRYPTOPP_XLC_VERSION) return (uint32x4_p)vec_xl(0, (byte*)src); #else return (uint32x4_p)vec_vsx_ld(0, (byte*)src); #endif } /// \brief Loads a vector from a byte array /// \param src the byte array /// \param off offset into the src byte array /// \details Loads a vector in native endian format from a byte array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(int off, const byte src[16]) { #if defined(CRYPTOPP_XLC_VERSION) return (uint32x4_p)vec_xl(off, (byte*)src); #else return (uint32x4_p)vec_vsx_ld(off, (byte*)src); #endif } /// \brief Loads a vector from a word array /// \param src the word array /// \details Loads a vector in native endian format from a word array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(const word32 src[4]) { return VectorLoad((const byte*)src); } /// \brief Loads a vector from a word array /// \param src the word array /// \param off offset into the src word array /// \details Loads a vector in native endian format from a word array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(int off, const word32 src[4]) { return VectorLoad(off, (const byte*)src); } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param dest the byte array /// \details Stores a vector in big endian format to a byte array. /// VectorStoreBE will swap endianess on little endian systems. /// \note VectorStoreBE does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 template <class T> inline void VectorStoreBE(const T& src, byte dest[16]) { #if defined(CRYPTOPP_XLC_VERSION) vec_xst_be((uint8x16_p)src, 0, (byte*)dest); #else # if (CRYPTOPP_BIG_ENDIAN) vec_vsx_st((uint8x16_p)src, 0, (byte*)dest); # else vec_vsx_st((uint8x16_p)Reverse(src), 0, (byte*)dest); # endif #endif } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param off offset into the dest byte array /// \param dest the byte array /// \details Stores a vector in big endian format to a byte array. /// VectorStoreBE will swap endianess on little endian systems. /// \note VectorStoreBE does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 template <class T> inline void VectorStoreBE(const T& src, int off, byte dest[16]) { #if defined(CRYPTOPP_XLC_VERSION) vec_xst_be((uint8x16_p)src, off, (byte*)dest); #else # if (CRYPTOPP_BIG_ENDIAN) vec_vsx_st((uint8x16_p)src, off, (byte*)dest); # else vec_vsx_st((uint8x16_p)Reverse(src), off, (byte*)dest); # endif #endif } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param dest the byte array /// \details Stores a vector in native endian format to a byte array. /// \note VectorStore does not require an aligned array. /// \since Crypto++ 6.0 template<class T> inline void VectorStore(const T& src, byte dest[16]) { #if defined(CRYPTOPP_XLC_VERSION) vec_xst((uint8x16_p)src, 0, (byte*)dest); #else vec_vsx_st((uint8x16_p)src, 0, (byte*)dest); #endif } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param dest the byte array /// \details Stores a vector in native endian format to a byte array. /// \note VectorStore does not require an aligned array. /// \since Crypto++ 6.0 template<class T> inline void VectorStore(byte dest[16], const T& src) { #if defined(CRYPTOPP_XLC_VERSION) vec_xst((uint8x16_p)src, 0, (byte*)dest); #else vec_vsx_st((uint8x16_p)src, 0, (byte*)dest); #endif } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param off offset into the dest byte array /// \param dest the byte array /// \details Stores a vector in native endian format to a byte array. /// \note VectorStore does not require an aligned array. /// \since Crypto++ 6.0 template<class T> inline void VectorStore(const T& src, int off, byte dest[16]) { #if defined(CRYPTOPP_XLC_VERSION) vec_xst((uint8x16_p)src, off, (byte*)dest); #else vec_vsx_st((uint8x16_p)src, off, (byte*)dest); #endif } #else // ########## Not CRYPTOPP_POWER7_AVAILABLE ########## /// \brief Loads a vector from a byte array /// \param src the byte array /// \details Loads a vector in native endian format from a byte array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(const byte src[16]) { if (IsAlignedOn(src, 16)) { return (uint32x4_p)vec_ld(0, src); } else { // http://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf const uint8x16_p perm = vec_lvsl(0, src); const uint8x16_p low = vec_ld(0, src); const uint8x16_p high = vec_ld(15, src); return (uint32x4_p)vec_perm(low, high, perm); } } /// \brief Loads a vector from a byte array /// \param src the byte array /// \param off offset into the src byte array /// \details Loads a vector in native endian format from a byte array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(int off, const byte src[16]) { if (IsAlignedOn(src, 16)) { return (uint32x4_p)vec_ld(off, src); } else { // http://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf const uint8x16_p perm = vec_lvsl(off, src); const uint8x16_p low = vec_ld(off, src); const uint8x16_p high = vec_ld(15, src); return (uint32x4_p)vec_perm(low, high, perm); } } /// \brief Loads a vector from a word array /// \param src the word array /// \details Loads a vector in native endian format from a word array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(const word32 src[4]) { return VectorLoad((const byte*)src); } /// \brief Loads a vector from a word array /// \param src the word array /// \param off offset into the src word array /// \details Loads a vector in native endian format from a word array. /// \note VectorLoad does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoad(int off, const word32 src[4]) { return VectorLoad(off, (const byte*)src); } /// \brief Loads a vector from a byte array /// \param src the byte array /// \details Loads a vector in big endian format from a byte array. /// VectorLoadBE will swap endianess on little endian systems. /// \note VectorLoadBE() does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 inline uint32x4_p VectorLoadBE(const byte src[16]) { #if (CRYPTOPP_BIG_ENDIAN) return (uint32x4_p)VectorLoad(src); #else return (uint32x4_p)Reverse(VectorLoad(src)); #endif } template<class T> inline void VectorStore(const T& data, byte dest[16]) { if (IsAlignedOn(dest, 16)) { vec_st((uint8x16_p)data, 0, dest); } else { // http://www.nxp.com/docs/en/reference-manual/ALTIVECPEM.pdf uint8x16_p perm = (uint8x16_p)vec_perm(data, data, vec_lvsr(0, dest)); vec_ste((uint8x16_p) perm, 0, (unsigned char*) dest); vec_ste((uint16x8_p) perm, 1, (unsigned short*)dest); vec_ste((uint32x4_p) perm, 3, (unsigned int*) dest); vec_ste((uint32x4_p) perm, 4, (unsigned int*) dest); vec_ste((uint32x4_p) perm, 8, (unsigned int*) dest); vec_ste((uint32x4_p) perm, 12, (unsigned int*) dest); vec_ste((uint16x8_p) perm, 14, (unsigned short*)dest); vec_ste((uint8x16_p) perm, 15, (unsigned char*) dest); } } /// \brief Stores a vector to a byte array /// \tparam T vector type /// \param src the vector /// \param dest the byte array /// \details Stores a vector in big endian format to a byte array. /// VectorStoreBE will swap endianess on little endian systems. /// \note VectorStoreBE does not require an aligned array. /// \sa Reverse(), VectorLoadBE(), VectorLoad() /// \since Crypto++ 6.0 template <class T> inline void VectorStoreBE(const T& src, byte dest[16]) { #if (CRYPTOPP_BIG_ENDIAN) VectorStore(src, dest); #else VectorStore(Reverse(src), dest); #endif } #endif // POWER4/POWER7 load and store // POWER8 crypto #if (CRYPTOPP_POWER8_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) /// \brief One round of AES encryption /// \tparam T1 vector type /// \tparam T2 vector type /// \param state the state vector /// \param key the subkey vector /// \details VectorEncrypt performs one round of AES encryption of state /// using subkey key. The return vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorEncrypt(const T1& state, const T2& key) { #if defined(CRYPTOPP_XLC_VERSION) return (T1)__vcipher((uint8x16_p)state, (uint8x16_p)key); #elif defined(CRYPTOPP_GCC_VERSION) return (T1)__builtin_crypto_vcipher((uint64x2_p)state, (uint64x2_p)key); #else CRYPTOPP_ASSERT(0); #endif } /// \brief Final round of AES encryption /// \tparam T1 vector type /// \tparam T2 vector type /// \param state the state vector /// \param key the subkey vector /// \details VectorEncryptLast performs the final round of AES encryption /// of state using subkey key. The return vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorEncryptLast(const T1& state, const T2& key) { #if defined(CRYPTOPP_XLC_VERSION) return (T1)__vcipherlast((uint8x16_p)state, (uint8x16_p)key); #elif defined(CRYPTOPP_GCC_VERSION) return (T1)__builtin_crypto_vcipherlast((uint64x2_p)state, (uint64x2_p)key); #else CRYPTOPP_ASSERT(0); #endif } /// \brief One round of AES decryption /// \tparam T1 vector type /// \tparam T2 vector type /// \param state the state vector /// \param key the subkey vector /// \details VectorDecrypt performs one round of AES decryption of state /// using subkey key. The return vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorDecrypt(const T1& state, const T2& key) { #if defined(CRYPTOPP_XLC_VERSION) return (T1)__vncipher((uint8x16_p)state, (uint8x16_p)key); #elif defined(CRYPTOPP_GCC_VERSION) return (T1)__builtin_crypto_vncipher((uint64x2_p)state, (uint64x2_p)key); #else CRYPTOPP_ASSERT(0); #endif } /// \brief Final round of AES decryption /// \tparam T1 vector type /// \tparam T2 vector type /// \param state the state vector /// \param key the subkey vector /// \details VectorDecryptLast performs the final round of AES decryption /// of state using subkey key. The return vector is the same type as vec1. /// \since Crypto++ 6.0 template <class T1, class T2> inline T1 VectorDecryptLast(const T1& state, const T2& key) { #if defined(CRYPTOPP_XLC_VERSION) return (T1)__vncipherlast((uint8x16_p)state, (uint8x16_p)key); #elif defined(CRYPTOPP_GCC_VERSION) return (T1)__builtin_crypto_vncipherlast((uint64x2_p)state, (uint64x2_p)key); #else CRYPTOPP_ASSERT(0); #endif } #endif // POWER8 crypto #if (CRYPTOPP_POWER8_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) /// \brief SHA256 Sigma functions /// \tparam func function /// \tparam subfunc sub-function /// \tparam T vector type /// \param vec the block to transform /// \details VectorSHA256 selects sigma0, sigma1, Sigma0, Sigma1 based on /// func and subfunc. The return vector is the same type as vec. /// \since Crypto++ 6.0 template <int func, int subfunc, class T> inline T VectorSHA256(const T& vec) { #if defined(CRYPTOPP_XLC_VERSION) return (T)__vshasigmaw((uint32x4_p)vec, func, subfunc); #elif defined(CRYPTOPP_GCC_VERSION) return (T)__builtin_crypto_vshasigmaw((uint32x4_p)vec, func, subfunc); #else CRYPTOPP_ASSERT(0); #endif } /// \brief SHA512 Sigma functions /// \tparam func function /// \tparam subfunc sub-function /// \tparam T vector type /// \param vec the block to transform /// \details VectorSHA512 selects sigma0, sigma1, Sigma0, Sigma1 based on /// func and subfunc. The return vector is the same type as vec. /// \since Crypto++ 6.0 template <int func, int subfunc, class T> inline T VectorSHA512(const T& vec) { #if defined(CRYPTOPP_XLC_VERSION) return (T)__vshasigmad((uint64x2_p)vec, func, subfunc); #elif defined(CRYPTOPP_GCC_VERSION) return (T)__builtin_crypto_vshasigmad((uint64x2_p)vec, func, subfunc); #else CRYPTOPP_ASSERT(0); #endif } #endif // POWER8 crypto #endif // CRYPTOPP_ALTIVEC_AVAILABLE NAMESPACE_END #endif // CRYPTOPP_PPC_CRYPTO_H
[ "noloader@gmail.com" ]
noloader@gmail.com
c1b484ab171c5555fc7f6780596f4e47ba23364f
0e2b9243fd5d36e8724893aada5eb9205edb8893
/DSA-wangdao/7.cpp
4f8c713afd63390f568cc4b52ea2bcaf5f5c5938
[]
no_license
songcs/ky-code
80edb4abf13bf154d1f6e4c6815e26cdbab4a3f9
62322532fdfd94c5f252b28aef31b11076c7ed70
refs/heads/master
2021-01-01T18:40:40.680472
2017-08-18T03:38:49
2017-08-18T03:38:49
98,404,161
0
0
null
null
null
null
UTF-8
C++
false
false
9,879
cpp
/*直接插入排序*/ void InsertSort(ElemType A[], int n) { int i, j; for (i = 2; i <= n; i++)//依次将A[2]~A[n]插入到前面已排序序列 if (A[i].key < A[i - 1].key) {//若A[i]的关键码小于前驱,需将A[i]插入有序表 A[0] = A[i];//复制为哨兵,A[0]不存放元素 for (j = i - 1; A[0].key < A[j].key; --j)//从后往前查找待插入位置 A[j + 1] = A[j];//向后挪位 A[j + 1] = A[0];//复制到插入位置 } } /*折半插入排序*/ void InsertSort(ElemType A[], int n) { int i, j, low, high, mid; for (i = 2; i <= n; i++) {//依次将A[2]~A[n]插入到前面已排序序列 A[0] = A[i]; low = 1; high = i - 1; while (low <= high) { mid = (low + high) / 2; if (A[mid].key > A[0].key) high = mid - 1; else low = mid + 1; } for (j = i - 1; j >= high + 1; j--) A[j + 1] = A[j]; A[high + 1] = A[0]; } } /*希尔排序*/ void ShellSort(ElemType A[], int n) { //A[0]只是暂存元素,不是哨兵,当j<0时,插入位置已到 //前后记录位置的增量时dk for (dk = n / 2; dk >= 1; dk = dk / 2) for (i = dk + 1; i <= n; i++) if (A[i].key < A[i - dk].key) { A[0] = A[i]; for (j = i - dk; j > 0 && A[0].key < A[j].key; j -= dk) A[j + dk] = A[j]; A[j + dk] = A[0]; } } /*冒泡排序*/ void BubbleSort(ElemType a, int n) { //从小到大排序 for (i = 0; i < n - 1; i++) { flag = false;//表示本堂冒泡是否发生交换的标志 for (j = n - 1; j > i; j--) if (a[j - 1] > a[j]) { swap(a[j - 1], a[j]); flag = true; } if (flag == false) return;//本趟遍历没有发生交换,说明表已有序 } } /*快速排序*/ void QuickSort(ElemType a[], int low, int high) { if (low < high) { //Partition就是划分操作,将表a划分为满足上述条件的两个子表 int pivotpos = Partition(a, low, high); QuickSort(a, low, pivotpos - 1); QuickSort(a, pivotpos + 1, high); } } int Partition(ElemType a[], int low, int high) { ElemType pivot = a[low];//将当前表中第一个元素设为枢轴值,对表进行划分 while (low < high) { while (low < high && a[high] >= pivot) --high; a[low] = a[high];//将比枢轴值小的元素移动到左端 while (low < high && a[low] <= pivot) ++low; a[high] = a[low];//将比枢轴值大的元素移动到右端 } a[low] = pivot;//枢轴值元素存放到最终位置 return low;//返回存放枢轴的最终位置 } /*双向冒泡*/ void DoubleBubbleSort(ElemType a[], int n) { int low = 0, high = n - 1; bool flag = true; while (low < high && flag) { flag = false; for (i = low; i < high; i++) if (a[i] > a[i + 1]) { swap(a[i], a[i + 1]); flag = true; } high--; for (i = high; i > low; i--) if (a[i] < a[i - 1]) { swap(a[i], a[i - 1]); flag = true; } low++; } } /*把所有奇数移动到所有偶数前面去*/ /*利用快排思想,先从前往后找到一个偶数元素,再从后向前找到一个奇数,交换*/ void move(ElemType a[], int len) { int i = 0, j = len - 1; while (i < j) { while (i < j && a[i] % 2 != 0) i++;//从前向后找到偶 while (i < j && a[j] % 2 != 1) j--;//从后向前找到奇 if (i < j) swap(a[i], a[j]); i++; j--; } } /*编写算法,使之能够再数组中找到第k小元素,即从小到大排序后处于第k个位置的元素*/ /*先排序,再直接提取第k个元素,平均复杂度O(nlogn);用小顶堆,复杂度O(n+klogn)*/ /*这里采用快排划分来做*/ /*从数组l[1...n]中选择枢轴pivot,进行和快排一样的划分操作后,表l[1..n]被划分为l[1...m-1]和l[m+1...n],其中l[m]=pivot * 讨论m和k的大小关系 * 1)m=k时,显然pivot就是要找的元素 * 2)m<k时,则要寻找的元素一定落在l[m+1...n]中,从而可以对l[m+1...n]递归查找第m-k小的元素 * 3)m>k时,则要寻找的元素一定落在l[1...m-1]中,从而可以对l[1...m-1]递归查找第m-k小的元素 *该算法平均复杂度O(n)*/ int kth_elem(int a[], int low, int high, int k) { int pivot = a[low]; int low_temp = low; int high_temp = high; while (low < high) { while (low < high && a[high] >= pivot) --high; a[low] = a[high]; while (low < high && a[low] <= pivot)++low; a[high] = a[low]; } a[low] = pivot; //上面即为快排中的划分算法 if (low == k) return a[low]; else if (low > k)//在前一部分表中递归查找 return kth_elem(a, low_temp, low - 1, k); else//在后一部分表中查找 return kth_elem(a, low + 1, high_temp, m - k); } /*将红白蓝三色乱序的条块,在O(n)时间复杂度下排序成红白蓝顺序*/ /*三个指针,j为工作指针表示当前扫描的元素,i以前的元素全部为红色,k以后的元素全部为蓝色。*/ typedef enum { RED, WHITE, BLUE } color; void Color_Arrange(color a[], int n) { int i = 0, j = 0, k = n - 1; while (j <= k) switch (a[j]) { case RED://红色,则和i交换 swap(a[i], a[j]); i++; j++; break; case WHITE: j++; break; case BLUE: swap(a[j], a[k]); k--; //蓝色,和k交换 //这里没有j++语句以防止a[j]仍为蓝色的情况 } } /*简单选择排序*/ void SelectSort(ElemType a[], int n) { for (i = 0; i < n - 1; i++) { min = i; for (j = i + 1; j < n; j++) if (a[j] < a[min]) min = j; if (min != i)swap(a[i], a[min]); } } /*建立大根堆的算法*/ void BuildMaxHeap(ElemType a[], int len) { for (int i = len / 2; i > 0; i--)//从⌊n/2⌋~1,反复调整堆 AdjustDown(a, i, len); } void AdjustDown(ElemType a[], int k, int len) { //函数将元素k向下调整 a[0] = a[k];//a[0]暂存 for (i = 2 * k; i <= len; i *= 2) { if (i < len && a[i] < a[i + 1]) i++;//取k较大的子结点的下标 if (a[0] >= a[i]) break; else { a[k] = a[i];//将较大子树根调整到k的位置 k = i;//k下降到,原来k的位置变成了较大子树根,原来较大子树根位置还是原来元素 }// } a[k] = a[0]; } /*堆排序算法*/ void HeapSort(ElemType a[], int len) { BuildMaxHeap(a, len); for (i = len; i > 1; i--) {//n-1趟的交换和建堆过程 swap(a[i], a[1]);//输出堆顶元素,并和堆底元素交换 AdjustDown(a, 1, i - 1);//整理,把剩余的i-1个元素整理成堆 } } /*堆向上调整操作*/ void AdjustUp(ElemType a[], int k) { //参数k为向上调整的结点,也为堆的元素个数 a[0] = a[k]; int i = k / 2;//若结点大于双亲结点,则将双亲向下调整,并继续向上比较 while (i > 0 && a[i] < a[0]) { a[k] = a[i]; k = i; i = k / 2; } a[k] = a[0]; } /*在基于单链表表示的待排序关键字序列上进行简单选择排序*/ void selectSort(LinkedList &l) { //对不带头节点的单链表l进行简单选择排序 LinkNode *h = l, *p, *q, *r, *s; l = NULL; while (h != NULL) { p = s = h; q = r = NULL; //指针s和r记忆最大结点和其前驱;p为工作指针,q为其前驱 while (p != NULL) {//扫描原链表寻找最大结点s if (p->data > s->data) {//找到更大的,记忆它和它的前驱 s = p; r = q; } q = p; p = p->link;//继续寻找 } if (s == h)//最大结点在原链表前端 h = h->link; else//最大结点在原链表表内 r->rlink = s->link; s->link = l;//结点s插入到结果链前端 l = s; } } /*判断一个数据序列是否构成一个小顶堆*/ bool IsMinHeap(ElemType a[], int len) { if (len % 2 == 0) {//len为偶数,有一个单分支结点 if (a[len / 2] > a[len])//判断单分支结点 return false; for (i = len / 2 - 1; i >= 1; i--)//判断所有双分支结点 if (a[i] > a[i * 2] || a[i] > a[2 * i + 1]) return false; } else {//len为奇数,没有单分支结点 for (i = len / 2; i >= 1; i--) if (a[i] > a[i * 2] || a[i] > a[2 * i + 1]) return false; } return true; } /*归并排序*/ ElemType *b = (ElemType *) malloc((n + 1) * sizeof(ElemType)); void Merge(ElemType a[], int low, int mid, int high) { //表a的两段a[low...mid],a[mid+1...high]各自有序,将他们合并成一个有序表 for (int k = low; k <= high; k++) b[k] = a[k]; for (i = low, j = mid + 1, k = i; i <= mid && j <= high; k++) if (b[i] <= b[j])//比较b的左右两段中的元素 a[k] = b[i++];//将较小值复制到a else a[k] = b[j++]; while (i <= mid) a[k++] = b[i++]; while (j <= high) a[k++] = b[j++]; } void MergeSort(ElemType a[], int low, int high) { if (low < high) { int mid = (low + high) / 2; MergeSort(a, low, mid); MergeSort(a, mid + 1, high); Merge(a, low, mid, high); } }
[ "songcs@live.com" ]
songcs@live.com
a8ad67d0427c86fad1c2529efc624b615ba13627
17f37b79643b9c6acd181c55c43a3ab4c889433e
/cavity/34.9/p
7b7f2c435c065a0370c0999e5ffddd83bfdd5d3c
[]
no_license
aashay201297/OpenFOAM-simulations
5208b766ab1e715178e42c73d028cc43d17ec4c9
273f60ef66e6f5b0c99a53ac52de406be0e876a2
refs/heads/master
2021-01-23T06:34:17.044650
2017-06-04T19:02:27
2017-06-04T19:02:27
86,373,858
0
0
null
null
null
null
UTF-8
C++
false
false
5,137
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "34.9"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 400 ( -8.54222e-10 -0.00582998 -0.0129685 -0.018421 -0.0204388 -0.0182452 -0.0117807 -0.00149053 0.0118306 0.0271426 0.043238 0.0588168 0.0725725 0.0833023 0.0900467 0.0922608 0.0900197 0.0842377 0.0768744 0.0710609 0.00577609 -0.000223585 -0.00580974 -0.00954861 -0.0106052 -0.00843919 -0.00297655 0.00546744 0.0162962 0.0287051 0.0417433 0.0543796 0.0655802 0.0744038 0.0801141 0.0823096 0.081071 0.0770485 0.0712678 0.0653115 0.0133298 0.00502809 -0.00100116 -0.00442918 -0.00527917 -0.00327032 0.00159582 0.00902095 0.0184954 0.0293426 0.0407588 0.0518632 0.0617622 0.0696301 0.0748008 0.0768718 0.0758353 0.0720795 0.065799 0.057529 0.020134 0.00869028 0.00121996 -0.00267464 -0.00372838 -0.00189169 0.0027248 0.009778 0.0187737 0.0290883 0.0399853 0.0506475 0.0602265 0.0679096 0.0729969 0.0749952 0.0737594 0.0694496 0.0615964 0.0500959 0.0244965 0.00976741 0.000583871 -0.00399301 -0.00530849 -0.00351371 0.00116828 0.00832803 0.0174554 0.0279424 0.0390783 0.0500633 0.0600423 0.0681586 0.07362 0.0757913 0.0743625 0.0692833 0.0595189 0.0445304 0.0251723 0.00714431 -0.0038079 -0.00906325 -0.0105184 -0.00850632 -0.00336324 0.00442294 0.0143068 0.0256724 0.0378072 0.0498966 0.0610415 0.0702965 0.0767281 0.0795104 0.0781324 0.072327 0.0605326 0.0418832 0.0210878 -0.000268161 -0.0129404 -0.0187153 -0.020036 -0.0174202 -0.0113248 -0.00232614 0.00898394 0.0219697 0.0359031 0.0499377 0.0631055 0.0743386 0.0825153 0.0865629 0.0857142 0.0794405 0.0656137 0.043065 0.0111369 -0.0136241 -0.027881 -0.0338602 -0.0346096 -0.0308637 -0.0232192 -0.0123516 0.0010984 0.0164774 0.033046 0.0499271 0.0660768 0.0802833 0.0911941 0.0974234 0.0978637 0.0916295 0.0758897 0.0491099 -0.00597322 -0.0342725 -0.0498761 -0.0555546 -0.0550962 -0.0495207 -0.0395997 -0.0261197 -0.00976352 0.00881656 0.0288945 0.049587 0.069791 0.088148 0.103041 0.112695 0.115544 0.110185 0.0928277 0.0614049 -0.0318633 -0.0638823 -0.0804231 -0.0850133 -0.0824262 -0.0740844 -0.0609871 -0.0440429 -0.0239579 -0.0013433 0.0231392 0.0486546 0.0740892 0.0979659 0.11839 0.133119 0.139982 0.136812 0.118434 0.0819274 -0.0686735 -0.10461 -0.121351 -0.123596 -0.117522 -0.105133 -0.0877244 -0.0663317 -0.0416433 -0.0141619 0.0155992 0.0469469 0.0788494 0.109787 0.137617 0.159579 0.172721 0.173772 0.155514 0.113565 -0.119408 -0.159363 -0.174921 -0.172763 -0.161154 -0.142935 -0.119765 -0.092783 -0.0625835 -0.0294538 0.00636691 0.0444673 0.0840489 0.123697 0.16113 0.19308 0.215662 0.224071 0.208044 0.160626 -0.188634 -0.232248 -0.243945 -0.233954 -0.2137 -0.18716 -0.156378 -0.122507 -0.0859038 -0.0464781 -0.00402041 0.0415328 0.0898362 0.139823 0.189313 0.234683 0.271069 0.291658 0.281737 0.22977 -0.28398 -0.32931 -0.331837 -0.308286 -0.274714 -0.236445 -0.19577 -0.153616 -0.109846 -0.0637507 -0.0144434 0.0388578 0.0965487 0.158271 0.222369 0.285282 0.341392 0.381569 0.384908 0.331829 -0.419324 -0.459676 -0.442356 -0.395797 -0.342134 -0.287745 -0.234621 -0.182935 -0.131614 -0.07899 -0.0232191 0.0374702 0.104548 0.178833 0.259856 0.344965 0.428611 0.499695 0.52967 0.485386 -0.620537 -0.636748 -0.578682 -0.494198 -0.411245 -0.335663 -0.267785 -0.205982 -0.147541 -0.0893875 -0.0284306 0.0383438 0.113802 0.200467 0.29997 0.41202 0.533025 0.65177 0.732767 0.722391 -0.935928 -0.878519 -0.741746 -0.597953 -0.474397 -0.372663 -0.288872 -0.217767 -0.153957 -0.092468 -0.0287215 0.0416915 0.123259 0.220714 0.338922 0.48215 0.651992 0.841337 1.01527 1.0975 -1.47643 -1.20663 -0.920507 -0.691392 -0.517309 -0.387548 -0.290065 -0.213341 -0.148128 -0.0872194 -0.0245816 0.0454535 0.128933 0.233067 0.367099 0.542674 0.771289 1.05931 1.40328 1.73014 -2.53965 -1.63055 -1.04444 -0.710962 -0.495754 -0.352097 -0.254534 -0.183587 -0.126173 -0.073599 -0.019273 0.0427829 0.119208 0.218779 0.354808 0.54798 0.826389 1.23658 1.91167 2.92419 -4.36667 -2.04464 -0.973546 -0.563184 -0.35785 -0.24015 -0.170123 -0.123787 -0.087485 -0.0535141 -0.0166584 0.0276566 0.0846034 0.161725 0.272407 0.442095 0.718215 1.2257 2.41103 4.84853 ) ; boundaryField { movingWall { type zeroGradient; } fixedWalls { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
[ "aashay225@gmail.com" ]
aashay225@gmail.com
a86f1836933a7659853fccb654257ec4446da6c4
88f1f55b92f40b057228b7c5449066e860847683
/882.cpp
364a129424c4ab00fb9560b38ccd4048ef718ae9
[]
no_license
sotirisnik/uva
661a6622dc71a4653b14111190b57338218f8bfd
5815a06dcc83fb99d015028c7f64b51984eda9cc
refs/heads/master
2021-01-10T21:19:39.403356
2015-04-25T18:28:06
2015-04-25T18:28:06
23,332,276
0
0
null
null
null
null
UTF-8
C++
false
false
423
cpp
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> using namespace std; int t, n; char text[22]; int main( ) { //freopen("in.txt","r",stdin); scanf( "%d", &t ); while ( t-- ) { scanf( "%s %d", text, &n ); int len = strlen( text ); for ( int i = 0; i < n; ++i ) next_permutation( text, text+len ); printf( "%s\n", text ); } return 0; }
[ "sotirisnik@gmail.com" ]
sotirisnik@gmail.com
419da137524a4040d95a82497a0ddd04917b96a0
08670697d53d1a2964fd033f7797194a10d6bbb2
/http_conn.h
7f4e8242aa05c9653694b186fe949fd16dfbb9e4
[]
no_license
lengender/HPServer
db7eb89879f96657f7cc6955455c5db15e804c8b
3e0a555ff0293e1a390c40f2ea8a1712ebd0f072
refs/heads/master
2021-01-11T03:04:27.666883
2016-10-14T06:58:10
2016-10-14T06:58:10
70,882,729
0
0
null
null
null
null
UTF-8
C++
false
false
4,540
h
/************************************************************************* > File Name: http_conn.h > Author: > Mail: > Created Time: 2016年10月11日 星期二 11时37分46秒 ************************************************************************/ #ifndef _HTTP_CONN_H #define _HTTP_CONN_H #include<unistd.h> #include<signal.h> #include<sys/types.h> #include<sys/epoll.h> #include<fcntl.h> #include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> #include<assert.h> #include<sys/stat.h> #include<string.h> #include<pthread.h> #include<stdio.h> #include<stdlib.h> #include<sys/mman.h> #include<stdarg.h> #include<errno.h> #include"locker.h" class http_conn { public: //文件名的最大长度 static const int FILENAME_LEN = 200; //读缓冲区的大小 static const int READ_BUFFER_SIZE = 2048; //写缓冲区的大小 static const int WRITE_BUFFER_SIZE = 1024; //http请求方法,但我们只支持GET enum METHOD { GET = 0, POST, HEAD, PUT, DELETE, TRACE, OPTIONS, CONNECT, PATCH }; //解析客户请求时,主状态机所处的状态 enum CHECK_STATE { CHECK_STATE_REQUESTLINE = 0, CHECK_STATE_HEADER, CHECK_STATE_CONTENT }; //服务器处理http请求的可能结果 enum HTTP_CODE { NO_REQUEST, GET_REQUEST, BAD_REQUEST, NO_RESOURCE, FORBIDDEN_REQUEST, FILE_REQUEST, INTERNAL_ERROR, CLOSED_CONNECTION }; //行的读取状态 enum LINE_STATUS { LINE_OK = 0, LINE_BAD, LINE_OPEN }; public: http_conn(){} ~http_conn(){} public: //初始化新接受的连接 void init(int sockfd, const sockaddr_in& addr); //关闭连接 void close_conn(bool real_close = true); //处理客户请求 void process(); //非阻塞读操作 bool read(); //非阻塞写操作 bool write(); private: //初始化连接 void init(); //解析http请求 HTTP_CODE process_read(); //填充http应答 bool process_write(HTTP_CODE ret); //下面这一组函数被process_read调用以分析HTTP请求 HTTP_CODE parse_request_line(char *text); HTTP_CODE parse_headers(char* text); HTTP_CODE parse_content(char* text); HTTP_CODE do_request(); char *get_line() { return m_read_buf + m_start_line; } LINE_STATUS parse_line(); //下面这一组函数被process_write调用以填充http应答 void unmap(); bool add_response(const char* format, ...); bool add_content(const char* content); bool add_status_line(int status, const char* title); bool add_headers(int content_length); bool add_content_length(int content_length); bool add_linger(); bool add_blank_line(); public: //soket上的事件都被注册到同一个epoll内核事件表中,所有将epoll文件描述符设置为静态的 static int m_epollfd; //统计用户数量 static int m_user_count; private: //该Http连接的socket和对方的socket地址 int m_sockfd; sockaddr_in m_address; //读缓冲区 char m_read_buf[READ_BUFFER_SIZE]; //标识读缓冲区已经读入的客户数据的最后一个字符的下一个位置 int m_read_idx; //当前正在分析的字符在读缓冲区中的位置 int m_checked_idx; //当前正在解析的行的起始位置 int m_start_line; //写缓冲区 char m_write_buf[WRITE_BUFFER_SIZE]; //写缓冲区中待发送的字节数 int m_write_idx; //主状态机当前所处的状态 CHECK_STATE m_check_state; //请求方法 METHOD m_method; //客户请求的目标文件的完整路径,其内容等于doc_root + m_url,doc_root是网站根目录 char m_real_file[FILENAME_LEN]; //客户请求的目标文件的文件名 char* m_url; //HTTP协议版本号,仅支持http/1.1 char *m_version; //主机名 char *m_host; //http请求的消息体的长度 int m_content_length; //http请求是否要求保持连接 bool m_linger; //客户请求的目标文件被mmap到内存中的起始位置 char* m_file_address; //目标文件的状态,通过它我们可以判断文件是否存在,是否为目录,是否可读,并获取文件 //大小等信息 struct stat m_file_stat; //我们将采用writev来执行写操作,所以定义下面两个成员,其中m_iv_count表示被写内存块 //的数量 struct iovec m_iv[2]; int m_iv_count; }; #endif
[ "laijfown@126.com" ]
laijfown@126.com
a83f6ec86327789f293e5d54e9f2a107cf2ca1e9
0da89bb043ebb15f4da644d14812b858042b431c
/trunk/Net7/Mutex.h
bf0dd80aff2f44195ccae7aa7e4e6f8de53c2208
[]
no_license
CyberSys/Earth-and-Beyond-server
1c66c474aafb89efaac2a010de53da1a2a0ab7e2
3b46ad7c8baecca61adf8a0bedd2b23cb1936b9d
refs/heads/master
2021-08-27T15:16:37.988861
2014-05-11T21:03:53
2014-05-11T21:03:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
545
h
// Mutex.h #ifndef _MUTEX_H_INCLUDED_ #define _MUTEX_H_INCLUDED_ #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif #include <windows.h> #else #include <pthread.h> #endif class Mutex { public: Mutex(); virtual ~Mutex(); public: void Lock(); void Unlock(); private: #ifdef WIN32 CRITICAL_SECTION m_Mutex; #else pthread_mutex_t m_Mutex; pthread_t m_ThreadID; int m_LockCount; #endif }; #endif // _MUTEX_H_INCLUDED_
[ "kyp@mailinator.com" ]
kyp@mailinator.com
c81b8a5ed4688452df544a60d68da7a85a220219
1ec55de30cbb2abdbaed005bc756b37eafcbd467
/Nacro/SDK/FN_SM_FloorBigRampSplit_02_classes.hpp
c34d9f3b20a690feb370e0e99791d8c10d47d9e8
[ "BSD-2-Clause" ]
permissive
GDBOI101/Nacro
6e91dc63af27eaddd299b25351c82e4729013b0b
eebabf662bbce6d5af41820ea0342d3567a0aecc
refs/heads/master
2023-07-01T04:55:08.740931
2021-08-09T13:52:43
2021-08-09T13:52:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
660
hpp
#pragma once // Fortnite (1.8) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass SM_FloorBigRampSplit_02.SM_FloorBigRampSplit_02_C // 0x0000 (0x0FD0 - 0x0FD0) class ASM_FloorBigRampSplit_02_C : public ABuildingFloor { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass SM_FloorBigRampSplit_02.SM_FloorBigRampSplit_02_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "68667854+Pakchunk@users.noreply.github.com" ]
68667854+Pakchunk@users.noreply.github.com
069192be7a4b6a184ce112b4b82bd652a8dc46f3
a2fc6e3bcc00ad0dea08526df930ce14c298fa12
/nth_fib_recursion.cc
fecc6de732090d51da773e5fe0af3d7a66b15361
[]
no_license
rohangiriraj/classic-problems-in-cs
1bc40007be977004c74c15af172238c84c81ad07
8b7b53fdbcf55c472dad19228cb7370f225c69e0
refs/heads/master
2023-08-11T02:24:57.634125
2021-09-27T09:18:38
2021-09-27T09:18:38
147,810,710
0
0
null
null
null
null
UTF-8
C++
false
false
420
cc
/* * Program to find the nth fibonacci number using recursion. * Author of this crappy code - Rohan Giriraj */ #include<iostream> using namespace std; int fibo(int); int main() { int n; cout<<"Please enter the nth number."<<endl; cin>>n; cout<<"The nth fibonacci number is: "<< fibo(n)<<endl; return 0; } int fibo(int n) { if(n==1 || n==0) return n; else return (fibo(n-1)+fibo(n-2)); }
[ "rohangiriraj@gmail.com" ]
rohangiriraj@gmail.com
5975dead2d3fe6f02de2c690a9e4e2dc997ea692
18c3f6f94c85e138440f3cf4f119d6755a366c66
/BOJ_10000.cpp
20be574551f4036cfd3d4d75ed0c197e20de2dbb
[]
no_license
Amel-CYDF/BOJ
11643ce3a441e6fd4f6955eb7ca8470dd01a0a1b
3557a7e755034ecfe28d3892694ea3c4c1d58304
refs/heads/master
2021-07-13T20:00:40.497828
2021-01-30T11:29:41
2021-01-30T11:29:41
229,370,263
0
0
null
null
null
null
UTF-8
C++
false
false
746
cpp
#include <bits/stdc++.h> using namespace std; int n,ans; struct circle { int x,r,lf,rg,mid; }a[300010]; stack<circle*> st; void stpop() { int toplf=st.top()->lf,toprg=st.top()->rg; if(st.top()->mid==toprg) ans++; st.pop(); if(!st.empty()&&st.top()->mid==toplf) st.top()->mid=toprg; } int main(){ scanf("%d",&n); ans=n+1; for(int i=0;i<n;i++) scanf("%d %d",&a[i].x,&a[i].r),a[i].lf=a[i].mid=a[i].x-a[i].r,a[i].rg=a[i].x+a[i].r; sort(a,a+n,[](circle lhs,circle rhs){return lhs.lf==rhs.lf?lhs.rg>rhs.rg:lhs.lf<rhs.lf;}); for(int i=0;i<n;i++) { while(!st.empty()&&st.top()->rg<=a[i].lf) stpop(); st.push(a+i); } while(!st.empty()) stpop(); printf("%d",ans); return 0; }
[ "taehoon1310@korea.ac.kr" ]
taehoon1310@korea.ac.kr
8672a4c2567f6f7640be4953510f9f0273261fd5
4b36d33da779f0b8a8e1b2ec0347edf607bf2c62
/epollWait.hpp
e7f1914d0894e94539b1de8719e9c04841058ad3
[]
no_license
LiiuKingming/http-airdrop
b9a7dcec673cd6f1bcb0a363a94562f44ca574f1
fff3d911f9f358ccea91d6f57f6f519be4ce17d4
refs/heads/master
2021-03-10T17:18:41.908650
2020-03-10T05:45:31
2020-03-10T05:48:52
246,470,320
0
0
null
null
null
null
UTF-8
C++
false
false
1,687
hpp
#ifndef __M_EPOLL_H__ #define __M_EPOLL_H__ #include <iostream> #include <string> #include <vector> #include <sys/epoll.h> #include "tcpSocket.hpp" #define MAX_EPOLL 1024 class Epoll{ int m_epfd; public: Epoll():m_epfd(-1){ } ~Epoll(){ } bool Init() { m_epfd = epoll_create(MAX_EPOLL); if (m_epfd < 0) { std::cerr << "create epoll error\n"; return false; } return true; } bool Add(TcpSocket &sock) { struct epoll_event ev; int fd = sock.GetFd(); ev.events = EPOLLIN;// | EPOLLET ev.data.fd = fd; int ret = epoll_ctl(m_epfd, EPOLL_CTL_ADD, fd, &ev); if (ret < 0) { std::cerr << "append monitor error\n"; return false; } return true; } bool Del(TcpSocket &sock) { int fd = sock.GetFd(); int ret = epoll_ctl(m_epfd, EPOLL_CTL_DEL, fd, NULL); if (ret < 0) { std::cerr << "remove monitor error\n"; return false; } return true; } bool Wait(std::vector<TcpSocket> &v, int timeout = 3000) { struct epoll_event evs[MAX_EPOLL]; int nfds = epoll_wait(m_epfd, evs, MAX_EPOLL, timeout); if (nfds < 0) { std::cerr << "epoll monitor error\n"; return false; }else if (nfds == 0) { std::cerr << "epoll wait timeout\n"; return false; } for (int i = 0; i < nfds; i++) { int fd = evs[i].data.fd; TcpSocket sock; sock.SetFd(fd); v.push_back(sock); } return true; } }; #endif
[ "289437926@qq.com" ]
289437926@qq.com
7bd0090fc2ad01312e9b19875a4151a12a4fa913
9ef88cf6a334c82c92164c3f8d9f232d07c37fc3
/Libraries/Boost/include/boost/mpl/advance.hpp
9656186780127277216de3b9f212765fc6340e2a
[]
no_license
Gussoh/bismuthengine
eba4f1d6c2647d4b73d22512405da9d7f4bde88a
4a35e7ae880cebde7c557bd8c8f853a9a96f5c53
refs/heads/master
2016-09-05T11:28:11.194130
2010-01-10T14:09:24
2010-01-10T14:09:24
33,263,368
0
0
null
null
null
null
UTF-8
C++
false
false
2,081
hpp
#ifndef BOOST_MPL_ADVANCE_HPP_INCLUDED #define BOOST_MPL_ADVANCE_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // 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) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /home/shared/backups/ogre/cvs/ogreaddons/ogrenewt/OgreNewt_Main/inc/boost/mpl/advance.hpp,v $ // $Date: 2006-04-17 23:47:07 $ // $Revision: 1.1 $ #include <boost/mpl/advance_fwd.hpp> #include <boost/mpl/less.hpp> #include <boost/mpl/negate.hpp> #include <boost/mpl/long.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/tag.hpp> #include <boost/mpl/apply_wrap.hpp> #include <boost/mpl/aux_/advance_forward.hpp> #include <boost/mpl/aux_/advance_backward.hpp> #include <boost/mpl/aux_/value_wknd.hpp> #include <boost/mpl/aux_/na_spec.hpp> #include <boost/mpl/aux_/nttp_decl.hpp> namespace boost { namespace mpl { // default implementation for forward/bidirectional iterators template< typename Tag > struct advance_impl { template< typename Iterator, typename N > struct apply { typedef typename less< N,long_<0> >::type backward_; typedef typename if_< backward_, negate<N>, N >::type offset_; typedef typename if_< backward_ , aux::advance_backward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value > , aux::advance_forward< BOOST_MPL_AUX_VALUE_WKND(offset_)::value > >::type f_; typedef typename apply_wrap1<f_,Iterator>::type type; }; }; template< typename BOOST_MPL_AUX_NA_PARAM(Iterator) , typename BOOST_MPL_AUX_NA_PARAM(N) > struct advance : advance_impl< typename tag<Iterator>::type > ::template apply<Iterator,N> { }; template< typename Iterator , BOOST_MPL_AUX_NTTP_DECL(long, N) > struct advance_c : advance_impl< typename tag<Iterator>::type > ::template apply<Iterator,long_<N> > { }; BOOST_MPL_AUX_NA_SPEC(2, advance) }} #endif // BOOST_MPL_ADVANCE_HPP_INCLUDED
[ "andreas.duchen@aefdbfa2-c794-11de-8410-e5b1e99fc78e" ]
andreas.duchen@aefdbfa2-c794-11de-8410-e5b1e99fc78e
0617210080bc628bf7c613b248b4842d4759a45c
536656cd89e4fa3a92b5dcab28657d60d1d244bd
/content/common/input/event_with_latency_info_unittest.cc
006e05e1e88f89563ed01f20585ec03d1bd0c00f
[ "BSD-3-Clause" ]
permissive
ECS-251-W2020/chromium
79caebf50443f297557d9510620bf8d44a68399a
ac814e85cb870a6b569e184c7a60a70ff3cb19f9
refs/heads/master
2022-08-19T17:42:46.887573
2020-03-18T06:08:44
2020-03-18T06:08:44
248,141,336
7
8
BSD-3-Clause
2022-07-06T20:32:48
2020-03-18T04:52:18
null
UTF-8
C++
false
false
15,452
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/common/input/event_with_latency_info.h" #include <limits> #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/input/web_input_event.h" using blink::WebGestureEvent; using blink::WebInputEvent; using blink::WebMouseEvent; using blink::WebMouseWheelEvent; using blink::WebTouchEvent; using blink::WebTouchPoint; using std::numeric_limits; namespace content { namespace { using EventWithLatencyInfoTest = testing::Test; TouchEventWithLatencyInfo CreateTouchEvent(WebInputEvent::Type type, double timestamp, unsigned touch_count = 1) { TouchEventWithLatencyInfo touch( type, WebInputEvent::kNoModifiers, base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), ui::LatencyInfo()); touch.event.touches_length = touch_count; return touch; } MouseEventWithLatencyInfo CreateMouseEvent(WebInputEvent::Type type, double timestamp) { return MouseEventWithLatencyInfo( type, WebInputEvent::kNoModifiers, base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), ui::LatencyInfo()); } MouseWheelEventWithLatencyInfo CreateMouseWheelEvent( double timestamp, float deltaX = 0.0f, float deltaY = 0.0f, int modifiers = WebInputEvent::kNoModifiers) { MouseWheelEventWithLatencyInfo mouse_wheel( WebInputEvent::kMouseWheel, modifiers, base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), ui::LatencyInfo()); mouse_wheel.event.delta_x = deltaX; mouse_wheel.event.delta_y = deltaY; return mouse_wheel; } GestureEventWithLatencyInfo CreateGestureEvent(WebInputEvent::Type type, double timestamp, float x = 0.0f, float y = 0.0f) { GestureEventWithLatencyInfo gesture( type, WebInputEvent::kNoModifiers, base::TimeTicks() + base::TimeDelta::FromSecondsD(timestamp), ui::LatencyInfo()); gesture.event.SetPositionInWidget(gfx::PointF(x, y)); return gesture; } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseEvent) { MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(WebInputEvent::kMouseMove, 5.0); MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(WebInputEvent::kMouseMove, 10.0); ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1)); mouse_0.CoalesceWith(mouse_1); // Coalescing WebMouseEvent preserves newer timestamp. EXPECT_EQ(10.0, mouse_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForMouseWheelEvent) { MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheelEvent(5.0); MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheelEvent(10.0); ASSERT_TRUE(mouse_wheel_0.CanCoalesceWith(mouse_wheel_1)); mouse_wheel_0.CoalesceWith(mouse_wheel_1); // Coalescing WebMouseWheelEvent preserves newer timestamp. EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForTouchEvent) { TouchEventWithLatencyInfo touch_0 = CreateTouchEvent(WebInputEvent::kTouchMove, 5.0); TouchEventWithLatencyInfo touch_1 = CreateTouchEvent(WebInputEvent::kTouchMove, 10.0); ASSERT_TRUE(touch_0.CanCoalesceWith(touch_1)); touch_0.CoalesceWith(touch_1); // Coalescing WebTouchEvent preserves newer timestamp. EXPECT_EQ(10.0, touch_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, TimestampCoalescingForGestureEvent) { GestureEventWithLatencyInfo scroll_0 = CreateGestureEvent(WebInputEvent::kGestureScrollUpdate, 5.0); GestureEventWithLatencyInfo scroll_1 = CreateGestureEvent(WebInputEvent::kGestureScrollUpdate, 10.0); ASSERT_TRUE(scroll_0.CanCoalesceWith(scroll_1)); scroll_0.CoalesceWith(scroll_1); // Coalescing WebGestureEvent preserves newer timestamp. EXPECT_EQ(10.0, scroll_0.event.TimeStamp().since_origin().InSecondsF()); } TEST_F(EventWithLatencyInfoTest, LatencyInfoCoalescing) { MouseEventWithLatencyInfo mouse_0 = CreateMouseEvent(WebInputEvent::kMouseMove, 5.0); mouse_0.latency.AddLatencyNumberWithTimestamp( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, base::TimeTicks()); MouseEventWithLatencyInfo mouse_1 = CreateMouseEvent(WebInputEvent::kMouseMove, 10.0); ASSERT_TRUE(mouse_0.CanCoalesceWith(mouse_1)); EXPECT_FALSE(mouse_1.latency.FindLatency( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, nullptr)); mouse_0.CoalesceWith(mouse_1); // Coalescing WebMouseEvent preservers older LatencyInfo. EXPECT_TRUE(mouse_1.latency.FindLatency( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, nullptr)); } WebTouchPoint CreateTouchPoint(WebTouchPoint::State state, int id) { WebTouchPoint touch; touch.state = state; touch.id = id; return touch; } TouchEventWithLatencyInfo CreateTouch(WebInputEvent::Type type, unsigned touch_count = 1) { return CreateTouchEvent(type, 0.0, touch_count); } GestureEventWithLatencyInfo CreateGesture(WebInputEvent::Type type, float x, float y) { return CreateGestureEvent(type, 0.0, x, y); } MouseWheelEventWithLatencyInfo CreateMouseWheel(float deltaX, float deltaY) { return CreateMouseWheelEvent(0.0, deltaX, deltaY); } template <class T> bool CanCoalesce(const T& event_to_coalesce, const T& event) { return event.CanCoalesceWith(event_to_coalesce); } template <class T> void Coalesce(const T& event_to_coalesce, T* event) { return event->CoalesceWith(event_to_coalesce); } TEST_F(EventWithLatencyInfoTest, TouchEventCoalescing) { TouchEventWithLatencyInfo touch0 = CreateTouch(WebInputEvent::kTouchStart); TouchEventWithLatencyInfo touch1 = CreateTouch(WebInputEvent::kTouchMove); // Non touch-moves won't coalesce. EXPECT_FALSE(CanCoalesce(touch0, touch0)); // Touches of different types won't coalesce. EXPECT_FALSE(CanCoalesce(touch0, touch1)); // Touch moves with idential touch lengths and touch ids should coalesce. EXPECT_TRUE(CanCoalesce(touch1, touch1)); // Touch moves with different touch ids should not coalesce. touch0 = CreateTouch(WebInputEvent::kTouchMove); touch1 = CreateTouch(WebInputEvent::kTouchMove); touch0.event.touches[0].id = 7; EXPECT_FALSE(CanCoalesce(touch0, touch1)); touch0 = CreateTouch(WebInputEvent::kTouchMove, 2); touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.touches[0].id = 1; touch1.event.touches[0].id = 0; EXPECT_FALSE(CanCoalesce(touch0, touch1)); // Touch moves with different touch lengths should not coalesce. touch0 = CreateTouch(WebInputEvent::kTouchMove, 1); touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); EXPECT_FALSE(CanCoalesce(touch0, touch1)); // Touch moves with identical touch ids in different orders should coalesce. touch0 = CreateTouch(WebInputEvent::kTouchMove, 2); touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.touches[0] = touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1); touch0.event.touches[1] = touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 0); EXPECT_TRUE(CanCoalesce(touch0, touch1)); // Pointers with the same ID's should coalesce. touch0 = CreateTouch(WebInputEvent::kTouchMove, 2); touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.touches[0] = touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1); Coalesce(touch0, &touch1); ASSERT_EQ(1, touch1.event.touches[0].id); ASSERT_EQ(0, touch1.event.touches[1].id); EXPECT_EQ(WebTouchPoint::kStateUndefined, touch1.event.touches[1].state); EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[0].state); // Movement from now-stationary pointers should be preserved. touch0 = touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1); touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateStationary, 1); touch0.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateStationary, 0); touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 0); Coalesce(touch0, &touch1); ASSERT_EQ(1, touch1.event.touches[0].id); ASSERT_EQ(0, touch1.event.touches[1].id); EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[0].state); EXPECT_EQ(WebTouchPoint::kStateMoved, touch1.event.touches[1].state); // Touch moves with different dispatchTypes coalesce. touch0 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.dispatch_type = WebInputEvent::DispatchType::kBlocking; touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch1.event.dispatch_type = WebInputEvent::DispatchType::kEventNonBlocking; touch0.event.touches[0] = touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1); touch0.event.touches[1] = touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 0); EXPECT_TRUE(CanCoalesce(touch0, touch1)); Coalesce(touch0, &touch1); ASSERT_EQ(WebInputEvent::DispatchType::kBlocking, touch1.event.dispatch_type); touch0 = CreateTouch(WebInputEvent::kTouchMove, 2); touch0.event.dispatch_type = WebInputEvent::DispatchType::kListenersForcedNonBlockingDueToFling; touch1 = CreateTouch(WebInputEvent::kTouchMove, 2); touch1.event.dispatch_type = WebInputEvent::DispatchType::kListenersNonBlockingPassive; touch0.event.touches[0] = touch1.event.touches[1] = CreateTouchPoint(WebTouchPoint::kStateMoved, 1); touch0.event.touches[1] = touch1.event.touches[0] = CreateTouchPoint(WebTouchPoint::kStateMoved, 0); EXPECT_TRUE(CanCoalesce(touch0, touch1)); Coalesce(touch0, &touch1); ASSERT_EQ(WebInputEvent::DispatchType::kListenersNonBlockingPassive, touch1.event.dispatch_type); } TEST_F(EventWithLatencyInfoTest, PinchEventCoalescing) { GestureEventWithLatencyInfo pinch0 = CreateGesture(WebInputEvent::kGesturePinchBegin, 1, 1); GestureEventWithLatencyInfo pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 2, 2); // Only GesturePinchUpdate's coalesce. EXPECT_FALSE(CanCoalesce(pinch0, pinch0)); // Pinch gestures of different types should not coalesce. EXPECT_FALSE(CanCoalesce(pinch0, pinch1)); // Pinches with different focal points should not coalesce. pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 2, 2); EXPECT_FALSE(CanCoalesce(pinch0, pinch1)); EXPECT_TRUE(CanCoalesce(pinch0, pinch0)); // Coalesced scales are multiplicative. pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch0.event.data.pinch_update.scale = 2.f; pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch1.event.data.pinch_update.scale = 3.f; EXPECT_TRUE(CanCoalesce(pinch0, pinch0)); Coalesce(pinch0, &pinch1); EXPECT_EQ(2.f * 3.f, pinch1.event.data.pinch_update.scale); // Scales have a minimum value and can never reach 0. ASSERT_GT(numeric_limits<float>::min(), 0); pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch0.event.data.pinch_update.scale = numeric_limits<float>::min() * 2.0f; pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch1.event.data.pinch_update.scale = numeric_limits<float>::min() * 5.0f; EXPECT_TRUE(CanCoalesce(pinch0, pinch1)); Coalesce(pinch0, &pinch1); EXPECT_EQ(numeric_limits<float>::min(), pinch1.event.data.pinch_update.scale); // Scales have a maximum value and can never reach Infinity. pinch0 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch0.event.data.pinch_update.scale = numeric_limits<float>::max() / 2.0f; pinch1 = CreateGesture(WebInputEvent::kGesturePinchUpdate, 1, 1); pinch1.event.data.pinch_update.scale = 10.0f; EXPECT_TRUE(CanCoalesce(pinch0, pinch1)); Coalesce(pinch0, &pinch1); EXPECT_EQ(numeric_limits<float>::max(), pinch1.event.data.pinch_update.scale); } TEST_F(EventWithLatencyInfoTest, WebMouseWheelEventCoalescing) { MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheel(1, 1); MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheel(2, 2); // WebMouseWheelEvent objects with same values except different deltaX and // deltaY should coalesce. EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); // WebMouseWheelEvent objects with different modifiers should not coalesce. mouse_wheel_0 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::kControlKey); mouse_wheel_1 = CreateMouseWheelEvent(2.0, 1, 1, WebInputEvent::kShiftKey); EXPECT_FALSE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); // Coalesce old and new events. mouse_wheel_0 = CreateMouseWheel(1, 1); mouse_wheel_0.event.SetPositionInWidget(1, 1); mouse_wheel_1 = CreateMouseWheel(2, 2); mouse_wheel_1.event.SetPositionInWidget(2, 2); MouseWheelEventWithLatencyInfo mouse_wheel_1_copy = mouse_wheel_1; EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); EXPECT_EQ(mouse_wheel_0.event.GetModifiers(), mouse_wheel_1.event.GetModifiers()); EXPECT_EQ(mouse_wheel_0.event.delta_units, mouse_wheel_1.event.delta_units); EXPECT_EQ(mouse_wheel_0.event.phase, mouse_wheel_1.event.phase); EXPECT_EQ(mouse_wheel_0.event.momentum_phase, mouse_wheel_1.event.momentum_phase); Coalesce(mouse_wheel_0, &mouse_wheel_1); // Coalesced event has the position of the most recent event. EXPECT_EQ(1, mouse_wheel_1.event.PositionInWidget().x()); EXPECT_EQ(1, mouse_wheel_1.event.PositionInWidget().y()); // deltaX/Y, wheelTicksX/Y, and movementX/Y of the coalesced event are // calculated properly. EXPECT_EQ(mouse_wheel_1_copy.event.delta_x + mouse_wheel_0.event.delta_x, mouse_wheel_1.event.delta_x); EXPECT_EQ(mouse_wheel_1_copy.event.delta_y + mouse_wheel_0.event.delta_y, mouse_wheel_1.event.delta_y); EXPECT_EQ(mouse_wheel_1_copy.event.wheel_ticks_x + mouse_wheel_0.event.wheel_ticks_x, mouse_wheel_1.event.wheel_ticks_x); EXPECT_EQ(mouse_wheel_1_copy.event.wheel_ticks_y + mouse_wheel_0.event.wheel_ticks_y, mouse_wheel_1.event.wheel_ticks_y); EXPECT_EQ( mouse_wheel_1_copy.event.movement_x + mouse_wheel_0.event.movement_x, mouse_wheel_1.event.movement_x); EXPECT_EQ( mouse_wheel_1_copy.event.movement_y + mouse_wheel_0.event.movement_y, mouse_wheel_1.event.movement_y); } // Coalescing preserves the newer timestamp. TEST_F(EventWithLatencyInfoTest, TimestampCoalescing) { MouseWheelEventWithLatencyInfo mouse_wheel_0 = CreateMouseWheelEvent(5.0, 1, 1); MouseWheelEventWithLatencyInfo mouse_wheel_1 = CreateMouseWheelEvent(10.0, 2, 2); EXPECT_TRUE(CanCoalesce(mouse_wheel_0, mouse_wheel_1)); Coalesce(mouse_wheel_1, &mouse_wheel_0); EXPECT_EQ(10.0, mouse_wheel_0.event.TimeStamp().since_origin().InSecondsF()); } } // namespace } // namespace content
[ "pcding@ucdavis.edu" ]
pcding@ucdavis.edu
f8a5fc42f761ef8f6c54038de1b8f5da42da16d2
6d1d231061dbc0d685cce462f0c25d508bb8e395
/SaverScreen/win95/src/FlyingReverseCondomBitmap.h
6e06bd762e53f34e9678a6ce9d8b22ce3881d425
[]
no_license
freegroup/ScreenSaver
cae66f67c48ba56e625794e0246920312d5a442a
94cb5b4377307711f87075e9817c0e001b6abdfa
refs/heads/master
2021-01-10T11:08:03.527540
2015-05-24T13:44:27
2015-05-24T13:47:26
36,174,206
1
1
null
null
null
null
UTF-8
C++
false
false
688
h
/** * Title: SaverScreen * Description: Simple ScreenSaver for windows * Copyright: Copyright (c) 2001 * Company: FreeGroup (www.FreeGroup.de) * Author: Andreas Herz (a.herz@FreeGroup.de) * Version: 1.0 */ #if !defined(AFX_CFLYINGREVERSECONDOMBITMAP_H__08BA6EB3_DB4C_11D1_8A89_0040052E2D91__INCLUDED_) #define AFX_CFLYINGREVERSECONDOMBITMAP_H__08BA6EB3_DB4C_11D1_8A89_0040052E2D91__INCLUDED_ #include "AnimatedObject.h" class FlyingReverseCondomBitmap : public AnimatedObject { public: FlyingReverseCondomBitmap(int screenWidth, int screenHeight); virtual ~FlyingReverseCondomBitmap(); virtual bool move(); }; #endif
[ "a.herz@freegroup.de" ]
a.herz@freegroup.de
6af94d845e4a7e809b456a61618d0974140900f8
cbbee6f20d0a3ab2b8e6c42262dc6deb85de8f02
/the folder/cambialo/src/main.cpp
b47136290396f0be43dc9094bad875e4b64e890d
[]
no_license
danielRolon/projectosviejos
fdc96b341eacd5ec539690b81872b0171c67212a
5f9160128430227f30e25d864f9e6780f90d4af9
refs/heads/master
2023-02-12T14:35:21.021837
2021-01-12T00:42:51
2021-01-12T00:42:51
329,041,322
0
0
null
null
null
null
UTF-8
C++
false
false
1,627
cpp
#include <iostream> #include <std/console.h> #include <std/input.h> #include <man/RenderManager.h> #include <man/EntityManager.h> int main() { bool running = true; ECS::EntityManager em; const size_t idPlayer = em.addEntity(); const size_t idEnt00 = em.addEntity(); em.addType<RenderManager>(); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); em.addComponent<RenderComponent>(idPlayer); auto& component = em.getComponentByIdEntity<RenderComponent>(idPlayer); component.x = 20; component.y = 20; //em.destroyComponent<RenderComponent>(idPlayer); em.destroyEntity(idPlayer); LOG "components: " << em.managers[0]->components.size() END; exit(0); while(running) { Console::clearConsole(); component.x += Input::isKeyPressed('D') - Input::isKeyPressed('A'); em.update(); if (Input::isKeyPressed(VK_ESCAPE)) running = false; } return 0; } // IMPORTANTE /* Che admin, desbaneame mi cuenta "Darth Vader#2583"pls fui baneado por un bot de manera injusta. Yo estaba poniendo muchas 'A' para seguir el "chiste" y me baneo ;( */
[ "matiasdanielesquivelrolon@gmail.com" ]
matiasdanielesquivelrolon@gmail.com
2890d21822c09a5c0214c8ef0d4c91da4156161e
d6258ae3c0fd9f36efdd859a2c93ab489da2aa9b
/fulldocset/add/codesnippet/CPP/e-system.deployment.appl_3_1.cpp
5b32a3b2dd60c5aa38b5d13d4de434bb61688023
[ "CC-BY-4.0", "MIT" ]
permissive
OpenLocalizationTestOrg/ECMA2YamlTestRepo2
ca4d3821767bba558336b2ef2d2a40aa100d67f6
9a577bbd8ead778fd4723fbdbce691e69b3b14d4
refs/heads/master
2020-05-26T22:12:47.034527
2017-03-07T07:07:15
2017-03-07T07:07:15
82,508,764
1
0
null
2017-02-28T02:14:26
2017-02-20T02:36:59
Visual Basic
UTF-8
C++
false
false
4,095
cpp
private: long sizeOfUpdate; private: void Form1_Load(Object^ sender, System::EventArgs^ e) { DoUpdate(); } public: void DoUpdate() { if (ApplicationDeployment::IsNetworkDeployed) { ApplicationDeployment^ currentAppDeployment = ApplicationDeployment::CurrentDeployment; currentAppDeployment->CheckForUpdateCompleted += gcnew CheckForUpdateCompletedEventHandler( this, &Form1::currentDeploy_CheckForUpdateCompleted); currentAppDeployment->CheckForUpdateAsync(); } } // If update is available, fetch it. void currentDeploy_CheckForUpdateCompleted(Object^ sender, CheckForUpdateCompletedEventArgs^ e) { if (nullptr != e->Error) { // Log error. return; } if (e->UpdateAvailable) { sizeOfUpdate = (long) e->UpdateSizeBytes; if (!e->IsUpdateRequired) { System::Windows::Forms::DialogResult updateDialogueResult = MessageBox::Show( "An update is available.Would you like to update the" + " application now?", "Update Available", MessageBoxButtons::OKCancel); if (System::Windows::Forms::DialogResult::OK == updateDialogueResult) { BeginUpdate(); } } else { BeginUpdate(); } } } void BeginUpdate() { ApplicationDeployment^ ad = ApplicationDeployment::CurrentDeployment; ad->UpdateCompleted += gcnew AsyncCompletedEventHandler( this, &Form1::CurrentDeployment_UpdateCompleted); // Indicate progress in the application's status bar. ad->UpdateProgressChanged += gcnew DeploymentProgressChangedEventHandler(this, &Form1::ad_ProgressChanged); ad->UpdateAsync(); } void CurrentDeployment_UpdateCompleted(Object^ sender, AsyncCompletedEventArgs^ e) { if (!e->Cancelled) { if (nullptr != e->Error) { System::Windows::Forms::DialogResult restartDialogueResult = MessageBox::Show( "The application has been updated. Restart?", "Restart Application", MessageBoxButtons::OKCancel); if (System::Windows::Forms::DialogResult::OK == restartDialogueResult) { Application::Restart(); } } else { // Replace with your own error reporting or logging. MessageBox::Show( "The application encountered an error in downloading" + " the latest update. Error: {0}", e->Error->Message); } } else { // Replace with your own error reporting or logging. MessageBox::Show("The update of the application's latest" + " version was cancelled."); } } void ad_ProgressChanged(Object^ sender, DeploymentProgressChangedEventArgs^ e) { String^ progressText = String::Format( "{0:D}K out of {1:D}K downloaded - {2:D}% complete", e->BytesCompleted / 1024, e->BytesTotal / 1024, e->ProgressPercentage); statusStrip1->Text = progressText; }
[ "tianzh@microsoft.com" ]
tianzh@microsoft.com
f00d1ef1e76533bee65451197993ad1189d43a1e
e7a1264e6b7aa267e24c7f5e439ccc6b2fd15a40
/test/pixel-c.cc
e2572b3d1b13a10b465741d0344469d1a517ab7f
[ "BSD-2-Clause" ]
permissive
renbozqin/cpuinfo
924f6a9f4f6b16e372b594a3698cdfd17352243f
085e027583ce43e6322b439576b2b27c0fe647ec
refs/heads/master
2021-06-27T03:16:01.884331
2017-09-14T23:41:32
2017-09-14T23:41:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,194
cc
#include <gtest/gtest.h> #include <cpuinfo.h> #include <cpuinfo-mock.h> TEST(PROCESSORS, count) { ASSERT_EQ(4, cpuinfo_processors_count); } TEST(PROCESSORS, non_null) { ASSERT_TRUE(cpuinfo_processors); } TEST(PROCESSORS, vendor) { for (uint32_t i = 0; i < cpuinfo_processors_count; i++) { ASSERT_EQ(cpuinfo_vendor_arm, cpuinfo_processors[i].vendor); } } TEST(PROCESSORS, uarch) { for (uint32_t i = 0; i < cpuinfo_processors_count; i++) { ASSERT_EQ(cpuinfo_uarch_cortex_a57, cpuinfo_processors[i].uarch); } } TEST(PROCESSORS, linux_id) { for (uint32_t i = 0; i < cpuinfo_processors_count; i++) { ASSERT_EQ(i, cpuinfo_processors[i].linux_id); } } TEST(PACKAGES, count) { ASSERT_EQ(1, cpuinfo_packages_count); } TEST(PACKAGES, name) { for (uint32_t i = 0; i < cpuinfo_packages_count; i++) { ASSERT_EQ("nVidia Tegra T210", std::string(cpuinfo_packages[i].name, strnlen(cpuinfo_packages[i].name, CPUINFO_PACKAGE_NAME_MAX))); } } TEST(PACKAGES, processor_start) { for (uint32_t i = 0; i < cpuinfo_packages_count; i++) { ASSERT_EQ(0, cpuinfo_packages[i].processor_start); } } TEST(PACKAGES, processor_count) { for (uint32_t i = 0; i < cpuinfo_packages_count; i++) { ASSERT_EQ(4, cpuinfo_packages[i].processor_count); } } TEST(PACKAGES, core_start) { for (uint32_t i = 0; i < cpuinfo_packages_count; i++) { ASSERT_EQ(0, cpuinfo_packages[i].core_start); } } TEST(PACKAGES, core_count) { for (uint32_t i = 0; i < cpuinfo_packages_count; i++) { ASSERT_EQ(4, cpuinfo_packages[i].core_count); } } #if CPUINFO_ARCH_ARM TEST(ISA, thumb) { ASSERT_TRUE(cpuinfo_isa.thumb); } TEST(ISA, thumb2) { ASSERT_TRUE(cpuinfo_isa.thumb2); } TEST(ISA, thumbee) { ASSERT_FALSE(cpuinfo_isa.thumbee); } TEST(ISA, jazelle) { ASSERT_FALSE(cpuinfo_isa.jazelle); } TEST(ISA, armv5e) { ASSERT_TRUE(cpuinfo_isa.armv5e); } TEST(ISA, armv6) { ASSERT_TRUE(cpuinfo_isa.armv6); } TEST(ISA, armv6k) { ASSERT_TRUE(cpuinfo_isa.armv6k); } TEST(ISA, armv7) { ASSERT_TRUE(cpuinfo_isa.armv7); } TEST(ISA, armv7mp) { ASSERT_TRUE(cpuinfo_isa.armv7mp); } TEST(ISA, idiv) { ASSERT_TRUE(cpuinfo_isa.idiv); } TEST(ISA, vfpv2) { ASSERT_FALSE(cpuinfo_isa.vfpv2); } TEST(ISA, vfpv3) { ASSERT_TRUE(cpuinfo_isa.vfpv3); } TEST(ISA, d32) { ASSERT_TRUE(cpuinfo_isa.d32); } TEST(ISA, fp16) { ASSERT_TRUE(cpuinfo_isa.fp16); } TEST(ISA, fma) { ASSERT_TRUE(cpuinfo_isa.fma); } TEST(ISA, wmmx) { ASSERT_FALSE(cpuinfo_isa.wmmx); } TEST(ISA, wmmx2) { ASSERT_FALSE(cpuinfo_isa.wmmx2); } TEST(ISA, neon) { ASSERT_TRUE(cpuinfo_isa.neon); } #endif /* CPUINFO_ARCH_ARM */ TEST(ISA, aes) { ASSERT_TRUE(cpuinfo_isa.aes); } TEST(ISA, sha1) { ASSERT_TRUE(cpuinfo_isa.sha1); } TEST(ISA, sha2) { ASSERT_TRUE(cpuinfo_isa.sha2); } TEST(ISA, pmull) { ASSERT_TRUE(cpuinfo_isa.pmull); } TEST(ISA, crc32) { ASSERT_TRUE(cpuinfo_isa.crc32); } #if CPUINFO_ARCH_ARM64 TEST(ISA, atomics) { ASSERT_FALSE(cpuinfo_isa.atomics); } TEST(ISA, rdm) { ASSERT_FALSE(cpuinfo_isa.rdm); } TEST(ISA, fp16arith) { ASSERT_FALSE(cpuinfo_isa.fp16arith); } TEST(ISA, jscvt) { ASSERT_FALSE(cpuinfo_isa.jscvt); } TEST(ISA, fcma) { ASSERT_FALSE(cpuinfo_isa.fcma); } #endif /* CPUINFO_ARCH_ARM64 */ TEST(L1I, count) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); ASSERT_EQ(4, l1i.count); } TEST(L1I, non_null) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); ASSERT_TRUE(l1i.instances); } TEST(L1I, size) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(48 * 1024, l1i.instances[k].size); } } TEST(L1I, associativity) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(3, l1i.instances[k].associativity); } } TEST(L1I, sets) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(l1i.instances[k].size, l1i.instances[k].sets * l1i.instances[k].line_size * l1i.instances[k].partitions * l1i.instances[k].associativity); } } TEST(L1I, partitions) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(1, l1i.instances[k].partitions); } } TEST(L1I, line_size) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(64, l1i.instances[k].line_size); } } TEST(L1I, flags) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(0, l1i.instances[k].flags); } } TEST(L1I, processors) { cpuinfo_caches l1i = cpuinfo_get_l1i_cache(); for (uint32_t k = 0; k < l1i.count; k++) { ASSERT_EQ(k, l1i.instances[k].processor_start); ASSERT_EQ(1, l1i.instances[k].processor_count); } } TEST(L1D, count) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); ASSERT_EQ(4, l1d.count); } TEST(L1D, non_null) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); ASSERT_TRUE(l1d.instances); } TEST(L1D, size) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(32 * 1024, l1d.instances[k].size); } } TEST(L1D, associativity) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(2, l1d.instances[k].associativity); } } TEST(L1D, sets) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(l1d.instances[k].size, l1d.instances[k].sets * l1d.instances[k].line_size * l1d.instances[k].partitions * l1d.instances[k].associativity); } } TEST(L1D, partitions) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(1, l1d.instances[k].partitions); } } TEST(L1D, line_size) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(64, l1d.instances[k].line_size); } } TEST(L1D, flags) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(0, l1d.instances[k].flags); } } TEST(L1D, processors) { cpuinfo_caches l1d = cpuinfo_get_l1d_cache(); for (uint32_t k = 0; k < l1d.count; k++) { ASSERT_EQ(k, l1d.instances[k].processor_start); ASSERT_EQ(1, l1d.instances[k].processor_count); } } TEST(L2, count) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); ASSERT_EQ(1, l2.count); } TEST(L2, non_null) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); ASSERT_TRUE(l2.instances); } TEST(L2, size) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(2 * 1024 * 1024, l2.instances[k].size); } } TEST(L2, associativity) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(16, l2.instances[k].associativity); } } TEST(L2, sets) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(l2.instances[k].size, l2.instances[k].sets * l2.instances[k].line_size * l2.instances[k].partitions * l2.instances[k].associativity); } } TEST(L2, partitions) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(1, l2.instances[k].partitions); } } TEST(L2, line_size) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(64, l2.instances[k].line_size); } } TEST(L2, flags) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(CPUINFO_CACHE_INCLUSIVE, l2.instances[k].flags); } } TEST(L2, processors) { cpuinfo_caches l2 = cpuinfo_get_l2_cache(); for (uint32_t k = 0; k < l2.count; k++) { ASSERT_EQ(0, l2.instances[k].processor_start); ASSERT_EQ(4, l2.instances[k].processor_count); } } TEST(L3, none) { cpuinfo_caches l3 = cpuinfo_get_l3_cache(); ASSERT_EQ(0, l3.count); ASSERT_FALSE(l3.instances); } TEST(L4, none) { cpuinfo_caches l4 = cpuinfo_get_l4_cache(); ASSERT_EQ(0, l4.count); ASSERT_FALSE(l4.instances); } #include <pixel-c.h> int main(int argc, char* argv[]) { cpuinfo_mock_filesystem(filesystem); #ifdef __ANDROID__ cpuinfo_mock_android_properties(properties); #endif cpuinfo_initialize(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
[ "marat@fb.com" ]
marat@fb.com
be4c7bd4c62f06b046797007f523aa5d7cae85f4
539e9562c1fe0e13773147bb7d66e494c8779406
/8_consecdigits/8_consecdigits.cpp
695be82330d0c11a2a0155352216932340246264
[]
no_license
davidshepherd7/project-euler
c985cc1a40ee2ecbcc7e20193190a74df1d29f1e
cf8bf489a0b78ddeffe433c4bd35570343d30d63
refs/heads/master
2021-01-22T11:55:20.147121
2011-06-30T10:34:13
2011-06-30T10:34:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,197
cpp
/* Find the greatest product of five consecutive digits in the 1000-digit number stored in file longnumber. */ // Note that no checking is done on the file for non-numeric characters (e.g. newline) #include<fstream> #include<iostream> #include<vector> #include<string> #include<cstdlib> using namespace std; int main() { unsigned long temp_prod = 0; unsigned long largest = 1; int a; // Open file "longnumber" for input ifstream longnum("longnumber"); if(!longnum) cerr << "Failed to open file" << endl; // Store first 5 digits from longnum in vector temp vector<int> temp(5); for(int i=0; i< temp.size(); i++) temp[i] = (longnum.get() - 48); // ASCII to int: subtract 48 // While file has not ended while(longnum) { // Compare product of temp with largest found so far temp_prod = 1; for(int i=0; i < temp.size(); i++) temp_prod *= temp[i]; if(temp_prod > largest) largest = temp_prod; // Delete first digit in temp read in next digit from longnum temp.erase(temp.begin()); a = longnum.get() - 48; temp.push_back(a); // Output for testing: //for(int i=0; i < temp.size(); i++) cout << temp[i] << ","; //cout << endl; } cout << largest << endl; }
[ "davidshepherd7@gmail.com" ]
davidshepherd7@gmail.com
04edc91bf0834bd96dd49898b20a29f1481e7b43
2d0e78bd40dc91b8b92c94fb6bebf8236603bc53
/output/Parser/Distributed/src/pe/BeJwzCc7My44HAAcAAIp.h
89bbbef020ecf5392482259eba576833c33f20a9
[]
no_license
gostevv/Lr1SimpleParser
adfe68ae99835626ba31ab772bb3a52f17f99ba4
e047277e18a34dd36dae783458078ea2e25d2672
refs/heads/master
2020-06-01T23:11:04.962972
2014-12-17T20:48:23
2014-12-17T20:48:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
484
h
// eJwzYHQsLclnNGQMzszLBgAWcgOT #ifndef BEJWZCC7MY44HAACAAIP_H_ #define BEJWZCC7MY44HAACAAIP_H_ #include <SPL/Runtime/ProcessingElement/PE.h> #define MYPE BeJwzCc7My44HAAcAAIp namespace SPL { class MYPE : public SPL::PE { public: MYPE(bool isStandalone=false); virtual void registerResources(const std::string & applicationDir, const std::string & streamsInstallDir); }; } // end namespace SPL #undef MYPE #endif // BEJWZCC7MY44HAACAAIP_H_
[ "timelimit@mail.ru" ]
timelimit@mail.ru
1988f3dbef95afc30c12b7073f4a33885f0ade16
f0df022c4ea84e9edb194b2c7188a42f85cdedae
/Controller/WorkerOriSave.h
cee541270cea5c6b8abf26a1587b703fcaeb9fba
[]
no_license
Leroy888/String-chuzhLeye
399a639e5588137d9e78048e0c622d5b1e84d17b
c1c585515283f5c24216ff67574d8969505cb648
refs/heads/master
2020-07-03T23:27:11.797006
2019-08-15T14:40:12
2019-08-15T14:40:12
202,084,857
0
0
null
null
null
null
UTF-8
C++
false
false
427
h
#ifndef WORKERORISAVE_H #define WORKERORISAVE_H #include <QThread> class LogicController; class WorkerOriSave : public QThread { Q_OBJECT public: explicit WorkerOriSave(LogicController * pLogic, bool bEL); virtual void run(); private: QString GetPath(bool EL); private: LogicController * m_pLogic; bool m_bEL; QString strcode; signals: public slots: }; #endif // WORKERORISAVE_H
[ "leroy8li@163.com" ]
leroy8li@163.com
08c6e93c42e9b286bae32098a00170d0aaa6c649
4ea6a61aef7ddd8785d75513a8ea73576f103d1e
/runtime/xthread.cpp
c5ae78ffe7caf6239c9efbbe0ba8a33ac4b8a35c
[]
no_license
probertool/Prober
287190a03b6d6a40ba77295ccef132226f800420
c75047af835ba7ddf60fb3f72f686ea4c56a08b5
refs/heads/master
2020-09-09T07:45:33.005153
2019-11-13T05:39:15
2019-11-13T05:39:15
221,385,993
0
0
null
null
null
null
UTF-8
C++
false
false
1,007
cpp
/* * @file xthread.cpp * @brief Handle Thread related information. */ #include "xthread.hh" inline int getThreadIndex() { return current->index; } // This is a really slow procedure and is only called in the pthread_join // Fortunately, there are not too many alive threads (128 in our setting) thread_t * xthread::getThread(pthread_t thread) { // Search through the active list to find this thread. // Holding the global lock to check the thread_t to avoid race. thread_t* iterthread; thread_t* current = NULL; acquireGlobalRLock(); iterthread = (thread_t*)nextEntry(&_aliveThreadsList); while(true) { if(iterthread->pthreadt == thread) { // Got the thread current = iterthread; break; } // if the thread is the tail of the alive list, exit if(isListTail(&iterthread->listentry, &_aliveThreadsList) == true) { break; } iterthread = (thread_t *)nextEntry(&iterthread->listentry); } releaseGlobalLock(); return current; }
[ "hongyuliu@salsa2.it.utsa.edu" ]
hongyuliu@salsa2.it.utsa.edu
2e15bf38f4aefc4227254cda275a47eaae09dbdf
4dd5d885768d911484954e084592efe369724637
/Include/Engine/CascadeShadowMappingTechnique.hpp
99ce1add9216842ba78805d037c85f8ccca4c5a3
[ "MIT" ]
permissive
glowing-chemist/Bell
d160f71b905da0629fb67378352ad1a0fd014057
610078a36c831f11c923f34f3e72be0009fcf6a6
refs/heads/master
2022-01-16T22:59:59.179596
2021-12-23T11:28:16
2021-12-23T11:28:16
160,046,575
18
4
null
null
null
null
UTF-8
C++
false
false
3,273
hpp
#ifndef CASCADE_SHADOW_MAPPING_TECHNIQUE_HPP #define CASCADE_SHADOW_MAPPING_TECHNIQUE_HPP #include "Engine/Technique.hpp" #include "RenderGraph/GraphicsTask.hpp" #include "Engine/DefaultResourceSlots.hpp" #include "Core/PerFrameResource.hpp" static constexpr char kCascadeShadowMapRaw0[] = "CascadeShadowMapRaw0"; static constexpr char kCascadeShadowMapRaw1[] = "CascadeShadowMapRaw1"; static constexpr char kCascadeShadowMapRaw2[] = "CascadeShadowMapRaw2"; static constexpr char kCascadeShadowMapBlurIntermediate0[] = "cascadeShadowMapBlurIntermediate0"; static constexpr char kCascadeShadowMapBlurIntermediate1[] = "cascadeShadowMapBlurIntermediate1"; static constexpr char kCascadeShadowMapBlurIntermediate2[] = "cascadeShadowMapBlurIntermediate2"; static constexpr char kCascadeShadowMapBlured0[] = "CascadeShadowMapBlured0"; static constexpr char kCascadeShadowMapBlured1[] = "CascadeShadowMapBlured1"; static constexpr char kCascadeShadowMapBlured2[] = "CascadeShadowMapBlured2"; static constexpr char kCascadesInfo[] = "CascadesInfo"; class CascadeShadowMappingTechnique : public Technique { public: CascadeShadowMappingTechnique(RenderEngine*, RenderGraph&); ~CascadeShadowMappingTechnique() = default; virtual PassType getPassType() const override { return PassType::CascadingShadow; } virtual void render(RenderGraph&, RenderEngine* eng) override; virtual void bindResources(RenderGraph& graph) override { if(!graph.isResourceSlotBound(kShadowMap)) { graph.bindImage(kCascadeShadowMapRaw0, mCascadeShaowMapsViewMip0); graph.bindImage(kCascadeShadowMapRaw1, mCascadeShaowMapsViewMip1); graph.bindImage(kCascadeShadowMapRaw2, mCascadeShaowMapsViewMip2); graph.bindImage(kShadowMap, mResolvedShadowMapView); graph.bindImage(kCascadeShadowMapBlurIntermediate0, mIntermediateShadowMapViewMip0); graph.bindImage(kCascadeShadowMapBlurIntermediate1, mIntermediateShadowMapViewMip1); graph.bindImage(kCascadeShadowMapBlurIntermediate2, mIntermediateShadowMapViewMip2); graph.bindImage(kCascadeShadowMapBlured0, mBluredShadowMapViewMip0); graph.bindImage(kCascadeShadowMapBlured1, mBluredShadowMapViewMip1); graph.bindImage(kCascadeShadowMapBlured2, mBluredShadowMapViewMip2); } graph.bindBuffer(kCascadesInfo, *mCascadesBuffer); } private: Shader mBlurXShader; Shader mBlurYShader; Shader mResolveShader; TaskID mRenderCascade0; TaskID mRenderCascade1; TaskID mRenderCascade2; Image mCascadeShadowMaps; ImageView mCascadeShaowMapsViewMip0; ImageView mCascadeShaowMapsViewMip1; ImageView mCascadeShaowMapsViewMip2; Image mResolvedShadowMap; ImageView mResolvedShadowMapView; Image mIntermediateShadowMap; ImageView mIntermediateShadowMapViewMip0; ImageView mIntermediateShadowMapViewMip1; ImageView mIntermediateShadowMapViewMip2; Image mBluredShadowMap; ImageView mBluredShadowMapViewMip0; ImageView mBluredShadowMapViewMip1; ImageView mBluredShadowMapViewMip2; PerFrameResource<Buffer> mCascadesBuffer; PerFrameResource<BufferView> mCascadesBufferView; }; #endif
[ "olie.smit0@gmail.com" ]
olie.smit0@gmail.com
68bf93e712a2a59e4a7dd169f410f0f8770bc14c
fa4232a6eadc3406a21994d851ef6731780e6cac
/src/Subsets II.cpp
3735b7970be7fed3d153c4fe3d19af1e09c7a254
[]
no_license
freezer-glp/leetcode-submit
8244bfcda0729bd24218e94a5fd8471763373ac0
e3e8ff335b86a039df6ca2e5a9e7ed3ca8a05eb0
refs/heads/master
2021-09-20T09:03:00.515440
2021-09-09T14:20:22
2021-09-09T14:20:22
26,519,223
0
0
null
null
null
null
UTF-8
C++
false
false
1,024
cpp
/*Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,2], a solution is: [ [2], [1], [1,2,2], [2,2], [1,2], [] ] Subscribe to see which companies asked this question Hide Tags Array Backtracking */ class Solution { public: vector<vector<int>> subsetsWithDup(vector<int>& nums) { vector<vector<int>> res; if(nums.size() == 0) return res; sort(nums.begin(), nums.end()); vector<int> curv; dfs(nums, 0, res, curv); return res; } void dfs(vector<int>& nums, int index, vector<vector<int>>& res, vector<int>& curv) { res.push_back(curv); for(int i = index; i < nums.size(); i++) { if(i > index && nums[i] == nums[i - 1]) continue; curv.push_back(nums[i]); dfs(nums, i + 1, res, curv); curv.pop_back(); } } };
[ "gonglingpu@foxmail.com" ]
gonglingpu@foxmail.com
37388cd93ebbbfa67acf02d4aa0d30173cb0c32d
8242d218808b8cc5734a27ec50dbf1a7a7a4987a
/Intermediate/Build/Win64/Netshoot/Inc/Chaos/PhysicsCoreTypes.gen.cpp
0a3df139eb0bbbf4336c64a5ce0fa4eaf163551d
[]
no_license
whyhhr/homework2
a2e75b494a962eab4fb0a740f83dc8dc27f8f6ee
9808107fcc983c998d8601920aba26f96762918c
refs/heads/main
2023-08-29T08:14:39.581638
2021-10-22T16:47:11
2021-10-22T16:47:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,509
cpp
// Copyright Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "Chaos/Public/PhysicsCoreTypes.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodePhysicsCoreTypes() {} // Cross Module References CHAOS_API UEnum* Z_Construct_UEnum_Chaos_EChaosBufferMode(); UPackage* Z_Construct_UPackage__Script_Chaos(); CHAOS_API UEnum* Z_Construct_UEnum_Chaos_EChaosThreadingMode(); CHAOS_API UEnum* Z_Construct_UEnum_Chaos_EChaosSolverTickMode(); // End Cross Module References static UEnum* EChaosBufferMode_StaticEnum() { static UEnum* Singleton = nullptr; if (!Singleton) { Singleton = GetStaticEnum(Z_Construct_UEnum_Chaos_EChaosBufferMode, Z_Construct_UPackage__Script_Chaos(), TEXT("EChaosBufferMode")); } return Singleton; } template<> CHAOS_API UEnum* StaticEnum<EChaosBufferMode>() { return EChaosBufferMode_StaticEnum(); } static FCompiledInDeferEnum Z_CompiledInDeferEnum_UEnum_EChaosBufferMode(EChaosBufferMode_StaticEnum, TEXT("/Script/Chaos"), TEXT("EChaosBufferMode"), false, nullptr, nullptr); uint32 Get_Z_Construct_UEnum_Chaos_EChaosBufferMode_Hash() { return 3255907050U; } UEnum* Z_Construct_UEnum_Chaos_EChaosBufferMode() { #if WITH_HOT_RELOAD UPackage* Outer = Z_Construct_UPackage__Script_Chaos(); static UEnum* ReturnEnum = FindExistingEnumIfHotReloadOrDynamic(Outer, TEXT("EChaosBufferMode"), 0, Get_Z_Construct_UEnum_Chaos_EChaosBufferMode_Hash(), false); #else static UEnum* ReturnEnum = nullptr; #endif // WITH_HOT_RELOAD if (!ReturnEnum) { static const UE4CodeGen_Private::FEnumeratorParam Enumerators[] = { { "EChaosBufferMode::Double", (int64)EChaosBufferMode::Double }, { "EChaosBufferMode::Triple", (int64)EChaosBufferMode::Triple }, { "EChaosBufferMode::Num", (int64)EChaosBufferMode::Num }, { "EChaosBufferMode::Invalid", (int64)EChaosBufferMode::Invalid }, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Enum_MetaDataParams[] = { { "Double.Name", "EChaosBufferMode::Double" }, { "Invalid.Hidden", "" }, { "Invalid.Name", "EChaosBufferMode::Invalid" }, { "ModuleRelativePath", "Public/PhysicsCoreTypes.h" }, { "Num.Hidden", "" }, { "Num.Name", "EChaosBufferMode::Num" }, { "Triple.Name", "EChaosBufferMode::Triple" }, }; #endif static const UE4CodeGen_Private::FEnumParams EnumParams = { (UObject*(*)())Z_Construct_UPackage__Script_Chaos, nullptr, "EChaosBufferMode", "EChaosBufferMode", Enumerators, UE_ARRAY_COUNT(Enumerators), RF_Public|RF_Transient|RF_MarkAsNative, EEnumFlags::None, UE4CodeGen_Private::EDynamicType::NotDynamic, (uint8)UEnum::ECppForm::EnumClass, METADATA_PARAMS(Enum_MetaDataParams, UE_ARRAY_COUNT(Enum_MetaDataParams)) }; UE4CodeGen_Private::ConstructUEnum(ReturnEnum, EnumParams); } return ReturnEnum; } static UEnum* EChaosThreadingMode_StaticEnum() { static UEnum* Singleton = nullptr; if (!Singleton) { Singleton = GetStaticEnum(Z_Construct_UEnum_Chaos_EChaosThreadingMode, Z_Construct_UPackage__Script_Chaos(), TEXT("EChaosThreadingMode")); } return Singleton; } template<> CHAOS_API UEnum* StaticEnum<EChaosThreadingMode>() { return EChaosThreadingMode_StaticEnum(); } static FCompiledInDeferEnum Z_CompiledInDeferEnum_UEnum_EChaosThreadingMode(EChaosThreadingMode_StaticEnum, TEXT("/Script/Chaos"), TEXT("EChaosThreadingMode"), false, nullptr, nullptr); uint32 Get_Z_Construct_UEnum_Chaos_EChaosThreadingMode_Hash() { return 111734735U; } UEnum* Z_Construct_UEnum_Chaos_EChaosThreadingMode() { #if WITH_HOT_RELOAD UPackage* Outer = Z_Construct_UPackage__Script_Chaos(); static UEnum* ReturnEnum = FindExistingEnumIfHotReloadOrDynamic(Outer, TEXT("EChaosThreadingMode"), 0, Get_Z_Construct_UEnum_Chaos_EChaosThreadingMode_Hash(), false); #else static UEnum* ReturnEnum = nullptr; #endif // WITH_HOT_RELOAD if (!ReturnEnum) { static const UE4CodeGen_Private::FEnumeratorParam Enumerators[] = { { "EChaosThreadingMode::DedicatedThread", (int64)EChaosThreadingMode::DedicatedThread }, { "EChaosThreadingMode::TaskGraph", (int64)EChaosThreadingMode::TaskGraph }, { "EChaosThreadingMode::SingleThread", (int64)EChaosThreadingMode::SingleThread }, { "EChaosThreadingMode::Num", (int64)EChaosThreadingMode::Num }, { "EChaosThreadingMode::Invalid", (int64)EChaosThreadingMode::Invalid }, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Enum_MetaDataParams[] = { { "DedicatedThread.Hidden", "" }, { "DedicatedThread.Name", "EChaosThreadingMode::DedicatedThread" }, { "Invalid.Hidden", "" }, { "Invalid.Name", "EChaosThreadingMode::Invalid" }, { "ModuleRelativePath", "Public/PhysicsCoreTypes.h" }, { "Num.Hidden", "" }, { "Num.Name", "EChaosThreadingMode::Num" }, { "SingleThread.Name", "EChaosThreadingMode::SingleThread" }, { "TaskGraph.Name", "EChaosThreadingMode::TaskGraph" }, }; #endif static const UE4CodeGen_Private::FEnumParams EnumParams = { (UObject*(*)())Z_Construct_UPackage__Script_Chaos, nullptr, "EChaosThreadingMode", "EChaosThreadingMode", Enumerators, UE_ARRAY_COUNT(Enumerators), RF_Public|RF_Transient|RF_MarkAsNative, EEnumFlags::None, UE4CodeGen_Private::EDynamicType::NotDynamic, (uint8)UEnum::ECppForm::EnumClass, METADATA_PARAMS(Enum_MetaDataParams, UE_ARRAY_COUNT(Enum_MetaDataParams)) }; UE4CodeGen_Private::ConstructUEnum(ReturnEnum, EnumParams); } return ReturnEnum; } static UEnum* EChaosSolverTickMode_StaticEnum() { static UEnum* Singleton = nullptr; if (!Singleton) { Singleton = GetStaticEnum(Z_Construct_UEnum_Chaos_EChaosSolverTickMode, Z_Construct_UPackage__Script_Chaos(), TEXT("EChaosSolverTickMode")); } return Singleton; } template<> CHAOS_API UEnum* StaticEnum<EChaosSolverTickMode>() { return EChaosSolverTickMode_StaticEnum(); } static FCompiledInDeferEnum Z_CompiledInDeferEnum_UEnum_EChaosSolverTickMode(EChaosSolverTickMode_StaticEnum, TEXT("/Script/Chaos"), TEXT("EChaosSolverTickMode"), false, nullptr, nullptr); uint32 Get_Z_Construct_UEnum_Chaos_EChaosSolverTickMode_Hash() { return 2466289469U; } UEnum* Z_Construct_UEnum_Chaos_EChaosSolverTickMode() { #if WITH_HOT_RELOAD UPackage* Outer = Z_Construct_UPackage__Script_Chaos(); static UEnum* ReturnEnum = FindExistingEnumIfHotReloadOrDynamic(Outer, TEXT("EChaosSolverTickMode"), 0, Get_Z_Construct_UEnum_Chaos_EChaosSolverTickMode_Hash(), false); #else static UEnum* ReturnEnum = nullptr; #endif // WITH_HOT_RELOAD if (!ReturnEnum) { static const UE4CodeGen_Private::FEnumeratorParam Enumerators[] = { { "EChaosSolverTickMode::Fixed", (int64)EChaosSolverTickMode::Fixed }, { "EChaosSolverTickMode::Variable", (int64)EChaosSolverTickMode::Variable }, { "EChaosSolverTickMode::VariableCapped", (int64)EChaosSolverTickMode::VariableCapped }, { "EChaosSolverTickMode::VariableCappedWithTarget", (int64)EChaosSolverTickMode::VariableCappedWithTarget }, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Enum_MetaDataParams[] = { { "Fixed.Name", "EChaosSolverTickMode::Fixed" }, { "ModuleRelativePath", "Public/PhysicsCoreTypes.h" }, { "Variable.Name", "EChaosSolverTickMode::Variable" }, { "VariableCapped.Name", "EChaosSolverTickMode::VariableCapped" }, { "VariableCappedWithTarget.Name", "EChaosSolverTickMode::VariableCappedWithTarget" }, }; #endif static const UE4CodeGen_Private::FEnumParams EnumParams = { (UObject*(*)())Z_Construct_UPackage__Script_Chaos, nullptr, "EChaosSolverTickMode", "EChaosSolverTickMode", Enumerators, UE_ARRAY_COUNT(Enumerators), RF_Public|RF_Transient|RF_MarkAsNative, EEnumFlags::None, UE4CodeGen_Private::EDynamicType::NotDynamic, (uint8)UEnum::ECppForm::EnumClass, METADATA_PARAMS(Enum_MetaDataParams, UE_ARRAY_COUNT(Enum_MetaDataParams)) }; UE4CodeGen_Private::ConstructUEnum(ReturnEnum, EnumParams); } return ReturnEnum; } PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
[ "49893309+whyhhr@users.noreply.github.com" ]
49893309+whyhhr@users.noreply.github.com
6a00f31ec70533e47488b18193f4908aeb2be6a2
bfc88535fa1495c64672f048a5559e8bb6de1ae1
/E-Olymp/armyofmages.cpp
77c531eda99d0b308e8b0ee5ae66e3ec49c077f4
[]
no_license
famus2310/CP
59839ffe23cf74019e2f655f49af224390846776
d8a77572830fb3927de92f1e913ee729d04865e1
refs/heads/master
2021-07-05T00:23:31.113026
2020-08-07T22:28:24
2020-08-07T22:28:24
144,426,214
1
1
null
null
null
null
UTF-8
C++
false
false
1,158
cpp
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int, int> pii; typedef pair<int, pair<int, int> > piii; #define pb push_back #define debug(x) cout << x << endl #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define PI acos(-1) #define all(c) c.begin(), c.end() #define SET(x, y) memset((x), y, sizeof(x)) const int MOD = 1e9 + 7; const int INF = 1e9; const LL INF64 = 1e18; const int N = 1e5 + 5; struct point { int x, y; }; point arr[25005]; bool ok[25005]; vector<pii> ans; bool check(int a, int b) { int dx = abs(arr[a].x - arr[b].x); int dy = abs(arr[a].y - arr[b].y); return __gcd(dx, dy) != 1; } int main() { int n; scanf("%d", &n); for (int i = 0; i < 5 * n; i++) { int x, y; scanf("%d %d", &x, &y); arr[i] = {x, y}; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (ok[i] || ok[j]) continue; if (check(i, j)) { cout << i << j << endl; ok[i] = 1; ok[j] = 1; ans.pb({i + 1, j + 1}); } } } if (ans.size() >= n) { puts("OK"); for (auto it : ans) printf("%d %d\n", it.first, it.second); } else puts("IMPOSSIBLE"); return 0; }
[ "fadhilmusaad@gmail.com" ]
fadhilmusaad@gmail.com
c1a57186c42dd2944a39b3e9b2d12d6a18e370af
1e02ed3f3369d36379be725a6b4cec6b155e97c9
/stringify/main.cpp
f7612bcbf6fea48e18622d4f164dea105732ff0c
[]
no_license
dormon/prj
0f803287f316606ff4e0f475930a6f9e7a6b3bb9
7ab62eedccd8153ac905fc27f74adcaf634771c7
refs/heads/master
2023-08-04T04:23:12.785661
2023-07-20T23:19:45
2023-07-20T23:19:45
89,816,202
4
0
null
null
null
null
UTF-8
C++
false
false
354
cpp
#include<iostream> #include<memory> #include<set> #include<vector> #include<map> #define BODY_OF_DO\ int a;\ a=32;\ a*=2;\ std::cout<<a<<std::endl #define STRINGIFY(...) #__VA_ARGS__ //#define STRINGIFY(S) STRINGIFY2(S) //#define STRINGIFY2(S) #S int main(){ BODY_OF_DO; std::cout<<STRINGIFY(BODY_OF_DO)<<std::endl; return 0; }
[ "imilet@fit.vutbr.cz" ]
imilet@fit.vutbr.cz
ae74da25bf5f8f35905b85dbf49c6b245bb29cc2
f38352736856c6ed18267be24e3e89e476e76c45
/16397.cpp
8f92a3cf693ab1b47118f89875a98f21be8dec08
[]
no_license
qornwh/BOJ
5e01d489f17426734fd6fdbc604bb13e64e079e0
b04d3e3b268e9f0c99631eeb980c1fbb9a648738
refs/heads/main
2023-08-04T21:03:38.131493
2021-09-25T11:08:17
2021-09-25T11:08:17
302,886,825
0
0
null
null
null
null
UTF-8
C++
false
false
1,504
cpp
#include <iostream> #include <string> #include <vector> #include <cmath> #include <algorithm> #include <queue> #define MAX 100000 using namespace std; char a = 'a'; char b = 'b'; int N = 0; int T = 0; int G = 0; int result = 0; string ANG = "ANG"; queue<pair<int, int>> q; int visit[MAX]; int B(int); void bfs() { visit[N] = 1; q.push({N, 0}); while(!q.empty()) { int value = q.front().first; int idx = q.front().second; q.pop(); if(idx > T) { // 인덱스초과 return; } if(value == G) { // 결과 result = idx; return; } if (value*2 < MAX) { int _value = B(value * 2); if (visit[_value] == 0 && _value > -2) { visit[_value] = 1; // 너비우선탐색 최단이라서 다음에 같은수가 나타나면 인덱스가 커져서 방문할 필요없다. 이게 됨 깊이우선은 안된다. q.push({_value, idx + 1}); } } if (value + 1 < MAX) { int _value = value + 1; if (visit[_value] == 0) { visit[_value] = 1; q.push({_value, idx + 1}); } } } } int B(int N2) { int temp = N2; int _ten = 1; while(1) { if (temp / 10 == 0) break; temp /= 10; _ten *= 10; } N2 -= _ten; return N2; } int main() { cin >> N; cin >> T; cin >> G; if (N == G) { cout << result << endl; return 0; } bfs(); if(result == 0) { cout << ANG << endl; } else { cout << result << endl; } return 0; }
[ "qornwh@gmail.com" ]
qornwh@gmail.com
2735298fac89684b070363a5c367ad205aa24540
94d747b1378dcaec9fd07a3935f6961967be2a12
/3주차_실습/[4-8] GLUT Modeling.cpp
28eb036b6a2265d3d267ed1408119814c9274e4d
[]
no_license
XIOZ119/ComputerGraphics
73683546e99ba30012b4bda5f36b5bcc5179dadd
1a9489f61248863de5e891a55bacbd66fb2345a0
refs/heads/master
2022-12-22T11:20:50.900977
2020-10-08T18:09:57
2020-10-08T18:09:57
296,326,256
0
0
null
null
null
null
UTF-8
C++
false
false
1,492
cpp
#include <stdlib.h> #include <gl/glut.h> void MyInit() { GLfloat mat_ambient[] = { 0.5, 0.4, 0.3, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; GLfloat light_position[] = { -1.0, 1.0, 0.5, 0.0 }; GLfloat model_ambient[] = { 0.5, 0.4, 0.3, 1.0 }; glClearColor(0.0, 0.0, 0.0, 0.0); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular); glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, model_ambient); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_DEPTH_TEST); } void MyDisplay() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(20.0, 1.0, 0.0, 0.0); glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); glutSolidTeapot(1.0); glutSwapBuffers(); } void MyReshape(int w, int h) { glViewport(0, 0, (GLsizei)w, (GLsizei)h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.5, 2.5, -2.5 * (GLfloat)h / (GLfloat)w, 2.5 * (GLfloat)h / (GLfloat)w, -10.0, 10.0); glLoadIdentity(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition(0, 0); glutCreateWindow("Graphics Primitives"); MyInit(); glutDisplayFunc(MyDisplay); glutReshapeFunc(MyReshape); glutMainLoop(); return 0; }
[ "tjwns53@naver.com" ]
tjwns53@naver.com
4b8bc3583729e416d463ab6a6097a68d86cb99b7
f16f4c77f2cd2c3c487ee59f68881c46ddd0b3c7
/AAVM/AAVM_EOL_VS2015/AAVM_EOL_Program/pcan_auto_tx.h
01f5cc3c38157ca4ded2d084ecee38a02fea56e3
[]
no_license
poormanY/plk_bk2
439f2e6251310aa794a3dc46676d31088dbae4c2
a70db2867ca6ec994ac8b851cd7135de5474b863
refs/heads/master
2021-06-12T12:10:58.169560
2017-02-06T01:48:32
2017-02-06T01:48:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
368
h
#ifndef _PCAN_AUTO_TX_H_ #define _PCAN_AUTO_TX_H_ #include "CanProtocol.h" class CPcanAutoTx { public: CPcanAutoTx(U32 a_wID, U32 a_wIntervalMsec, void (*a_pfCallBack)(CAN_MSG* a_pCanMsg)); void CallBack(void); CAN_MSG m_CanMsg; void (*m_pfCallBack)(CAN_MSG* a_pCanMsg); U32 m_wIntervalMsec; TOF m_tPause; }; #endif // _PCAN_AUTO_TX_H_
[ "ysw@plk.co.kr" ]
ysw@plk.co.kr
d7329dcc7b6e00092d7218be12427bf903698039
8554cc7ea5c79355cf74e1722762d1961ebf2439
/main.cpp
a1c138b24395c150d0c3403e9b9caee31d57a4cb
[]
no_license
marczis/mastermind
96f799d287652419183150b542557c922bc93579
917e2cf2307c815e694d9504f311d5924b24bf30
refs/heads/master
2020-04-04T21:55:45.302694
2018-11-06T15:59:59
2018-11-06T15:59:59
156,303,606
0
0
null
null
null
null
UTF-8
C++
false
false
105
cpp
#include "Game.h" int main(const int argc, const char *argv[]) { Game game; game.play(); return 0; }
[ "peterm@unity3d.com" ]
peterm@unity3d.com
45c44eb7485024d8a357f20d013547911770a060
fefebea3de45192c29149980efc1430244fae426
/NWN2MathLib/MathOps.h
7a03155ced15b6a0cfabedfdc161f22847e63a6c
[]
no_license
fantasydr/nwn2dev
4ba8f02ec39a7a6155a9bc9018170fdd359e9059
be9b06435beb04e385c0b032426e3915f4de2271
refs/heads/master
2020-05-16T18:25:24.169263
2014-02-16T03:35:53
2014-02-16T03:35:53
16,663,693
3
0
null
null
null
null
UTF-8
C++
false
false
59,082
h
/*++ Copyright (c) Ken Johnson (Skywing). All rights reserved. Module Name: MathOps.h Abstract: This module houses the interface to various useful mathematical operators, such as used by pathfinding logic. --*/ #ifndef _PROGRAMS_NWN2MATHLIB_MATHOPS_H #define _PROGRAMS_NWN2MATHLIB_MATHOPS_H #ifdef _MSC_VER #pragma once #endif typedef std::vector< NWN::Vector2 > Vector2Vec; typedef std::vector< NWN::Vector3 > Vector3Vec; namespace Math { // // Define the precision of floating point operations. // const float Epsilon = 0.00001f; // // Define the fixed-point precision for the math library. // const unsigned int FixedPointShift = 1 << 6; struct RectFP { unsigned int left; unsigned int top; unsigned int right; unsigned int bottom; }; struct Vector2FP { unsigned int x; unsigned int y; }; typedef std::vector< Vector2FP > Vector2FPVec; inline long Round( __in float F ) { return (long) floor( F + 0.5f ); } // // Calculate the dot product of two vectors. // inline float DotProduct( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { return (v1.x * v2.x) + (v1.y * v2.y); } // // Calculate the dot product of two vectors. // inline float DotProduct( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); } inline float LengthVector( __in const NWN::Vector3 & v ) { return sqrtf( DotProduct( v, v ) ); } inline float Magnitude( __in const NWN::Vector3 & v ) { return LengthVector( v ); } // // Calculate the cross product of two vectors. // inline NWN::Vector3 CrossProduct( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { NWN::Vector3 v3; v3.x = v1.y * v2.z - v2.y * v1.z; v3.y = v1.z * v2.x - v2.z * v1.x; v3.z = v1.x * v2.y - v2.x * v1.y; return v3; } // // Add two vectors. // inline NWN::Vector2 Add( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { NWN::Vector2 v3; v3.x = v1.x + v2.x; v3.y = v1.y + v2.y; return v3; } inline NWN::Vector3 Add( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { NWN::Vector3 v3; v3.x = v1.x + v2.x; v3.y = v1.y + v2.y; v3.z = v1.z + v2.z; return v3; } // // Subtract two vectors. // inline NWN::Vector2 Subtract( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { NWN::Vector2 v3; v3.x = v1.x - v2.x; v3.y = v1.y - v2.y; return v3; } inline NWN::Vector3 Subtract( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { NWN::Vector3 v3; v3.x = v1.x - v2.x; v3.y = v1.y - v2.y; v3.z = v1.z - v2.z; return v3; } // // Multiply a vector by a scalar. // inline NWN::Vector3 Multiply( __in const NWN::Vector3 & v1, __in float f ) { NWN::Vector3 v0; v0.x = v1.x * f; v0.y = v1.y * f; v0.z = v1.z * f; return v0; } // // Calculate the cross product of two vectors. // inline float CrossProduct( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { return v1.x * v2.y - v2.x * v2.y; } // // Normalize a vector (to unit length). // inline NWN::Vector2 NormalizeVector( __in const NWN::Vector2 & v ) { NWN::Vector2 vn; float M; M = sqrtf( (v.x * v.x) + (v.y * v.y) ); if (M == 0.0f) return v; vn.x = v.x / M; vn.y = v.y / M; return vn; } // // Normalize a vector (to unit length). // inline NWN::Vector3 NormalizeVector( __in const NWN::Vector3 & v ) { NWN::Vector3 vn; float M; M = sqrtf( (v.x * v.x) + (v.y * v.y) + (v.z * v.z) ); if (M <= Epsilon) { vn.x = 1.0f; vn.y = 0.0f; vn.z = 0.0f; return vn; } vn.x = v.x / M; vn.y = v.y / M; vn.z = v.z / M; return vn; } // // Convert a Matrix44 to a Matrix33. // inline NWN::Matrix33 CreateMatrix33FromMatrix44( __in const NWN::Matrix44 & M1 ) { NWN::Matrix33 M0; M0._00 = M1._00; M0._01 = M1._01; M0._02 = M1._02; M0._10 = M1._10; M0._11 = M1._11; M0._12 = M1._12; M0._20 = M1._20; M0._21 = M1._21; M0._22 = M1._22; return M0; } // // Convert a Matrix33 to a Matrix44. // inline NWN::Matrix44 CreateMatrix44FromMatrix33( __in const NWN::Matrix33 & M1 ) { NWN::Matrix44 M0; M0._00 = M1._00; M0._01 = M1._01; M0._02 = M1._02; M0._03 = 0.0f; M0._10 = M1._10; M0._11 = M1._11; M0._12 = M1._12; M0._13 = 0.0f; M0._20 = M1._20; M0._21 = M1._21; M0._22 = M1._22; M0._23 = 0.0f; M0._30 = 0.0f; M0._31 = 0.0f; M0._32 = 0.0f; M0._33 = 1.0f; return M0; } // // Multiply two 4x4 matricies together. // inline NWN::Matrix44 Multiply( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2 ) { NWN::Matrix44 M0 = { ( M1._00 * M2._00 ) + ( M1._01 * M2._10 ) + ( M1._02 * M2._20 ) + ( M1._03 * M2._30 ), // _00 ( M1._00 * M2._01 ) + ( M1._01 * M2._11 ) + ( M1._02 * M2._21 ) + ( M1._03 * M2._31 ), // _01 ( M1._00 * M2._02 ) + ( M1._01 * M2._12 ) + ( M1._02 * M2._22 ) + ( M1._03 * M2._32 ), // _02 ( M1._00 * M2._03 ) + ( M1._01 * M2._13 ) + ( M1._02 * M2._23 ) + ( M1._03 * M2._33 ), // _03 ( M1._10 * M2._00 ) + ( M1._11 * M2._10 ) + ( M1._12 * M2._20 ) + ( M1._13 * M2._30 ), // _10 ( M1._10 * M2._01 ) + ( M1._11 * M2._11 ) + ( M1._12 * M2._21 ) + ( M1._13 * M2._31 ), // _11 ( M1._10 * M2._02 ) + ( M1._11 * M2._12 ) + ( M1._12 * M2._22 ) + ( M1._13 * M2._32 ), // _12 ( M1._10 * M2._03 ) + ( M1._11 * M2._13 ) + ( M1._12 * M2._23 ) + ( M1._13 * M2._33 ), // _13 ( M1._20 * M2._00 ) + ( M1._21 * M2._10 ) + ( M1._22 * M2._20 ) + ( M1._23 * M2._30 ), // _20 ( M1._20 * M2._01 ) + ( M1._21 * M2._11 ) + ( M1._22 * M2._21 ) + ( M1._23 * M2._31 ), // _21 ( M1._20 * M2._02 ) + ( M1._21 * M2._12 ) + ( M1._22 * M2._22 ) + ( M1._23 * M2._32 ), // _22 ( M1._20 * M2._03 ) + ( M1._21 * M2._13 ) + ( M1._22 * M2._23 ) + ( M1._23 * M2._33 ), // _23 ( M1._30 * M2._00 ) + ( M1._31 * M2._10 ) + ( M1._32 * M2._20 ) + ( M1._33 * M2._30 ), // _30 ( M1._30 * M2._01 ) + ( M1._31 * M2._11 ) + ( M1._32 * M2._21 ) + ( M1._33 * M2._31 ), // _31 ( M1._30 * M2._02 ) + ( M1._31 * M2._12 ) + ( M1._32 * M2._22 ) + ( M1._33 * M2._32 ), // _32 ( M1._30 * M2._03 ) + ( M1._31 * M2._13 ) + ( M1._32 * M2._23 ) + ( M1._33 * M2._33 ) // _33 }; return M0; } // // Multiply two 4x4 matricies together with improved intermediate precision. // inline NWN::Matrix44 Multiply_Double( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2 ) { NWN::Matrix44 M0 = { (float) ( ( (double) M1._00 * (double) M2._00 ) + ( (double) M1._01 * (double) M2._10 ) + ( (double) M1._02 * (double) M2._20 ) + ( (double) M1._03 * (double) M2._30 ) ), // _00 (float) ( ( (double) M1._00 * (double) M2._01 ) + ( (double) M1._01 * (double) M2._11 ) + ( (double) M1._02 * (double) M2._21 ) + ( (double) M1._03 * (double) M2._31 ) ), // _01 (float) ( ( (double) M1._00 * (double) M2._02 ) + ( (double) M1._01 * (double) M2._12 ) + ( (double) M1._02 * (double) M2._22 ) + ( (double) M1._03 * (double) M2._32 ) ), // _02 (float) ( ( (double) M1._00 * (double) M2._03 ) + ( (double) M1._01 * (double) M2._13 ) + ( (double) M1._02 * (double) M2._23 ) + ( (double) M1._03 * (double) M2._33 ) ), // _03 (float) ( ( (double) M1._10 * (double) M2._00 ) + ( (double) M1._11 * (double) M2._10 ) + ( (double) M1._12 * (double) M2._20 ) + ( (double) M1._13 * (double) M2._30 ) ), // _10 (float) ( ( (double) M1._10 * (double) M2._01 ) + ( (double) M1._11 * (double) M2._11 ) + ( (double) M1._12 * (double) M2._21 ) + ( (double) M1._13 * (double) M2._31 ) ), // _11 (float) ( ( (double) M1._10 * (double) M2._02 ) + ( (double) M1._11 * (double) M2._12 ) + ( (double) M1._12 * (double) M2._22 ) + ( (double) M1._13 * (double) M2._32 ) ), // _12 (float) ( ( (double) M1._10 * (double) M2._03 ) + ( (double) M1._11 * (double) M2._13 ) + ( (double) M1._12 * (double) M2._23 ) + ( (double) M1._13 * (double) M2._33 ) ), // _13 (float) ( ( (double) M1._20 * (double) M2._00 ) + ( (double) M1._21 * (double) M2._10 ) + ( (double) M1._22 * (double) M2._20 ) + ( (double) M1._23 * (double) M2._30 ) ), // _20 (float) ( ( (double) M1._20 * (double) M2._01 ) + ( (double) M1._21 * (double) M2._11 ) + ( (double) M1._22 * (double) M2._21 ) + ( (double) M1._23 * (double) M2._31 ) ), // _21 (float) ( ( (double) M1._20 * (double) M2._02 ) + ( (double) M1._21 * (double) M2._12 ) + ( (double) M1._22 * (double) M2._22 ) + ( (double) M1._23 * (double) M2._32 ) ), // _22 (float) ( ( (double) M1._20 * (double) M2._03 ) + ( (double) M1._21 * (double) M2._13 ) + ( (double) M1._22 * (double) M2._23 ) + ( (double) M1._23 * (double) M2._33 ) ), // _23 (float) ( ( (double) M1._30 * (double) M2._00 ) + ( (double) M1._31 * (double) M2._10 ) + ( (double) M1._32 * (double) M2._20 ) + ( (double) M1._33 * (double) M2._30 ) ), // _30 (float) ( ( (double) M1._30 * (double) M2._01 ) + ( (double) M1._31 * (double) M2._11 ) + ( (double) M1._32 * (double) M2._21 ) + ( (double) M1._33 * (double) M2._31 ) ), // _31 (float) ( ( (double) M1._30 * (double) M2._02 ) + ( (double) M1._31 * (double) M2._12 ) + ( (double) M1._32 * (double) M2._22 ) + ( (double) M1._33 * (double) M2._32 ) ), // _32 (float) ( ( (double) M1._30 * (double) M2._03 ) + ( (double) M1._31 * (double) M2._13 ) + ( (double) M1._32 * (double) M2._23 ) + ( (double) M1._33 * (double) M2._33 ) ) // _33 }; return M0; } // // Multiply two 4x4 matricies together as a 3x4 with 0, 0, // inline NWN::Matrix44 Multiply33_44( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2 ) { NWN::Matrix44 M0 = { ( M1._00 * M2._00 ) + ( M1._01 * M2._10 ) + ( M1._02 * M2._20 ), // _00 ( M1._00 * M2._01 ) + ( M1._01 * M2._11 ) + ( M1._02 * M2._21 ), // _01 ( M1._00 * M2._02 ) + ( M1._01 * M2._12 ) + ( M1._02 * M2._22 ), // _02 0.0f , // _03 ( M1._10 * M2._00 ) + ( M1._11 * M2._10 ) + ( M1._12 * M2._20 ), // _10 ( M1._10 * M2._01 ) + ( M1._11 * M2._11 ) + ( M1._12 * M2._21 ), // _11 ( M1._10 * M2._02 ) + ( M1._11 * M2._12 ) + ( M1._12 * M2._22 ), // _12 0.0f , // _13 ( M1._20 * M2._00 ) + ( M1._21 * M2._10 ) + ( M1._22 * M2._20 ), // _20 ( M1._20 * M2._01 ) + ( M1._21 * M2._11 ) + ( M1._22 * M2._21 ), // _21 ( M1._20 * M2._02 ) + ( M1._21 * M2._12 ) + ( M1._22 * M2._22 ), // _22 0.0f , // _23 ( M1._30 * M2._00 ) + ( M1._31 * M2._10 ) + ( M1._32 * M2._20 ) + M2._30 , // _30 ( M1._30 * M2._01 ) + ( M1._31 * M2._11 ) + ( M1._32 * M2._21 ) + M2._31 , // _31 ( M1._30 * M2._02 ) + ( M1._31 * M2._12 ) + ( M1._32 * M2._22 ) + M2._32 , // _32 1.0f // _33 }; return M0; } // // Multiply two 4x4 matricies, but treat them as 3x3. // // The _3x rows are taken from M3. // inline NWN::Matrix44 Multiply33_33( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2, __in const NWN::Matrix44 & M3 ) { NWN::Matrix44 M0 = { ( M1._00 * M2._00 ) + ( M1._01 * M2._10 ) + ( M1._02 * M2._20 ), // _00 ( M1._00 * M2._01 ) + ( M1._01 * M2._11 ) + ( M1._02 * M2._21 ), // _01 ( M1._00 * M2._02 ) + ( M1._01 * M2._12 ) + ( M1._02 * M2._22 ), // _02 M3._03 , // _03 ( M1._10 * M2._00 ) + ( M1._11 * M2._10 ) + ( M1._12 * M2._20 ), // _10 ( M1._10 * M2._01 ) + ( M1._11 * M2._11 ) + ( M1._12 * M2._21 ), // _11 ( M1._10 * M2._02 ) + ( M1._11 * M2._12 ) + ( M1._12 * M2._22 ), // _12 M3._13 , // _13 ( M1._20 * M2._00 ) + ( M1._21 * M2._10 ) + ( M1._22 * M2._20 ), // _20 ( M1._20 * M2._01 ) + ( M1._21 * M2._11 ) + ( M1._22 * M2._21 ), // _21 ( M1._20 * M2._02 ) + ( M1._21 * M2._12 ) + ( M1._22 * M2._22 ), // _22 M3._23 , // _23 M3._30 , // _30 M3._31 , // _31 M3._32 , // _32 M3._33 // _33 }; return M0; } // // Multiply a 4x4 matrix by a scalar. // inline void Multiply( __in NWN::Matrix44 & M1, __in float F ) { M1._00 *= F; M1._01 *= F; M1._02 *= F; M1._03 *= F; M1._10 *= F; M1._11 *= F; M1._12 *= F; M1._13 *= F; M1._20 *= F; M1._21 *= F; M1._22 *= F; M1._23 *= F; M1._30 *= F; M1._31 *= F; M1._32 *= F; M1._33 *= F; } // // Multiply a 4x4 matrix by a scalar. // inline void Multiply( __in NWN::Matrix44 & M1, __in double F ) { M1._00 = (float) ((double) M1._00 * F); M1._01 = (float) ((double) M1._01 * F); M1._02 = (float) ((double) M1._02 * F); M1._03 = (float) ((double) M1._03 * F); M1._10 = (float) ((double) M1._10 * F); M1._11 = (float) ((double) M1._11 * F); M1._12 = (float) ((double) M1._12 * F); M1._13 = (float) ((double) M1._13 * F); M1._20 = (float) ((double) M1._20 * F); M1._21 = (float) ((double) M1._21 * F); M1._22 = (float) ((double) M1._22 * F); M1._23 = (float) ((double) M1._23 * F); M1._30 = (float) ((double) M1._30 * F); M1._31 = (float) ((double) M1._31 * F); M1._32 = (float) ((double) M1._32 * F); M1._33 = (float) ((double) M1._33 * F); } // // Add two 4x4 matricies. // inline NWN::Matrix44 Add( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2 ) { NWN::Matrix44 M0 = { M1._00 + M2._00, M1._01 + M2._01, M1._02 + M2._02, M1._03 + M2._03, // _00 .. _03 M1._10 + M2._10, M1._11 + M2._11, M1._12 + M2._12, M1._13 + M2._13, // _10 .. _13 M1._20 + M2._20, M1._21 + M2._21, M1._22 + M2._22, M1._23 + M2._23, // _20 .. _23 M1._30 + M2._30, M1._31 + M2._31, M1._32 + M2._32, M1._33 + M2._33 // _30 .. _33 }; return M0; } // // Subtract two 4x4 matricies. // inline NWN::Matrix44 Subtract( __in const NWN::Matrix44 & M1, __in const NWN::Matrix44 & M2 ) { NWN::Matrix44 M0 = { M1._00 - M2._00, M1._01 - M2._01, M1._02 - M2._02, M1._03 - M2._03, // _00 .. _03 M1._10 - M2._10, M1._11 - M2._11, M1._12 - M2._12, M1._13 - M2._13, // _10 .. _13 M1._20 - M2._20, M1._21 - M2._21, M1._22 - M2._22, M1._23 - M2._23, // _20 .. _23 M1._30 - M2._30, M1._31 - M2._31, M1._32 - M2._32, M1._33 - M2._33 // _30 .. _33 }; return M0; } // // Multiply a vector by a matrix. // inline NWN::Vector3 Multiply( __in const NWN::Matrix44 & M, __in const NWN::Vector3 & V1 ) { NWN::Vector3 V0; V0.x = M._00 * V1.x + M._10 * V1.y + M._20 * V1.z + M._30; V0.y = M._01 * V1.x + M._11 * V1.y + M._21 * V1.z + M._31; V0.z = M._02 * V1.x + M._12 * V1.y + M._22 * V1.z + M._32; return V0; } // // Multiply a vector by a matrix. // inline NWN::Vector3 MultiplyNormal( __in const NWN::Matrix44 & M, __in const NWN::Vector3 & V1 ) { NWN::Vector3 V0; V0.x = M._00 * V1.x + M._10 * V1.y + M._20 * V1.z; V0.y = M._01 * V1.x + M._11 * V1.y + M._21 * V1.z; V0.z = M._02 * V1.x + M._12 * V1.y + M._22 * V1.z; return V0; } // // Return the determinant of a 4x4 matrix. // inline float Determinant( __in const NWN::Matrix44 & M1 ) { return ( M1._03 * M1._12 * M1._21 * M1._30 - M1._02 * M1._13 * M1._21 * M1._30 - M1._03 * M1._11 * M1._22 * M1._30 + M1._01 * M1._13 * M1._22 * M1._30 + M1._02 * M1._11 * M1._23 * M1._30 - M1._01 * M1._12 * M1._23 * M1._30 - M1._03 * M1._12 * M1._20 * M1._31 + M1._02 * M1._13 * M1._20 * M1._31 + M1._03 * M1._10 * M1._22 * M1._31 - M1._00 * M1._13 * M1._22 * M1._31 - M1._02 * M1._10 * M1._23 * M1._31 + M1._00 * M1._12 * M1._23 * M1._31 + M1._03 * M1._11 * M1._20 * M1._32 - M1._01 * M1._13 * M1._20 * M1._32 - M1._03 * M1._10 * M1._21 * M1._32 + M1._00 * M1._13 * M1._21 * M1._32 + M1._01 * M1._10 * M1._23 * M1._32 - M1._00 * M1._11 * M1._23 * M1._32 - M1._02 * M1._11 * M1._20 * M1._33 + M1._01 * M1._12 * M1._20 * M1._33 + M1._02 * M1._10 * M1._21 * M1._33 - M1._00 * M1._12 * M1._21 * M1._33 - M1._01 * M1._10 * M1._22 * M1._33 + M1._00 * M1._11 * M1._22 * M1._33 ); } // // Return the determinant of a 4x4 matrix, using double-precision // intermediate calculations. // inline double Determinant_Double( __in const NWN::Matrix44 & M1 ) { return ( (double) M1._03 * (double) M1._12 * (double) M1._21 * (double) M1._30 - (double) M1._02 * (double) M1._13 * (double) M1._21 * (double) M1._30 - (double) M1._03 * (double) M1._11 * (double) M1._22 * (double) M1._30 + (double) M1._01 * (double) M1._13 * (double) M1._22 * (double) M1._30 + (double) M1._02 * (double) M1._11 * (double) M1._23 * (double) M1._30 - (double) M1._01 * (double) M1._12 * (double) M1._23 * (double) M1._30 - (double) M1._03 * (double) M1._12 * (double) M1._20 * (double) M1._31 + (double) M1._02 * (double) M1._13 * (double) M1._20 * (double) M1._31 + (double) M1._03 * (double) M1._10 * (double) M1._22 * (double) M1._31 - (double) M1._00 * (double) M1._13 * (double) M1._22 * (double) M1._31 - (double) M1._02 * (double) M1._10 * (double) M1._23 * (double) M1._31 + (double) M1._00 * (double) M1._12 * (double) M1._23 * (double) M1._31 + (double) M1._03 * (double) M1._11 * (double) M1._20 * (double) M1._32 - (double) M1._01 * (double) M1._13 * (double) M1._20 * (double) M1._32 - (double) M1._03 * (double) M1._10 * (double) M1._21 * (double) M1._32 + (double) M1._00 * (double) M1._13 * (double) M1._21 * (double) M1._32 + (double) M1._01 * (double) M1._10 * (double) M1._23 * (double) M1._32 - (double) M1._00 * (double) M1._11 * (double) M1._23 * (double) M1._32 - (double) M1._02 * (double) M1._11 * (double) M1._20 * (double) M1._33 + (double) M1._01 * (double) M1._12 * (double) M1._20 * (double) M1._33 + (double) M1._02 * (double) M1._10 * (double) M1._21 * (double) M1._33 - (double) M1._00 * (double) M1._12 * (double) M1._21 * (double) M1._33 - (double) M1._01 * (double) M1._10 * (double) M1._22 * (double) M1._33 + (double) M1._00 * (double) M1._11 * (double) M1._22 * (double) M1._33 ); } // // Return the inverse of a matrix. // inline NWN::Matrix44 Inverse( __in const NWN::Matrix44 & M1 ) { NWN::Matrix44 M0 = { M1._12 * M1._23 * M1._31 - M1._13 * M1._22 * M1._31 + M1._13 * M1._21 * M1._32 - M1._11 * M1._23 * M1._32 - M1._12 * M1._21 * M1._33 + M1._11 * M1._22 * M1._33, M1._03 * M1._22 * M1._31 - M1._02 * M1._23 * M1._31 - M1._03 * M1._21 * M1._32 + M1._01 * M1._23 * M1._32 + M1._02 * M1._21 * M1._33 - M1._01 * M1._22 * M1._33, M1._02 * M1._13 * M1._31 - M1._03 * M1._12 * M1._31 + M1._03 * M1._11 * M1._32 - M1._01 * M1._13 * M1._32 - M1._02 * M1._11 * M1._33 + M1._01 * M1._12 * M1._33, M1._03 * M1._12 * M1._21 - M1._02 * M1._13 * M1._21 - M1._03 * M1._11 * M1._22 + M1._01 * M1._13 * M1._22 + M1._02 * M1._11 * M1._23 - M1._01 * M1._12 * M1._23, M1._13 * M1._22 * M1._30 - M1._12 * M1._23 * M1._30 - M1._13 * M1._20 * M1._32 + M1._10 * M1._23 * M1._32 + M1._12 * M1._20 * M1._33 - M1._10 * M1._22 * M1._33, M1._02 * M1._23 * M1._30 - M1._03 * M1._22 * M1._30 + M1._03 * M1._20 * M1._32 - M1._00 * M1._23 * M1._32 - M1._02 * M1._20 * M1._33 + M1._00 * M1._22 * M1._33, M1._03 * M1._12 * M1._30 - M1._02 * M1._13 * M1._30 - M1._03 * M1._10 * M1._32 + M1._00 * M1._13 * M1._32 + M1._02 * M1._10 * M1._33 - M1._00 * M1._12 * M1._33, M1._02 * M1._13 * M1._20 - M1._03 * M1._12 * M1._20 + M1._03 * M1._10 * M1._22 - M1._00 * M1._13 * M1._22 - M1._02 * M1._10 * M1._23 + M1._00 * M1._12 * M1._23, M1._11 * M1._23 * M1._30 - M1._13 * M1._21 * M1._30 + M1._13 * M1._20 * M1._31 - M1._10 * M1._23 * M1._31 - M1._11 * M1._20 * M1._33 + M1._10 * M1._21 * M1._33, M1._03 * M1._21 * M1._30 - M1._01 * M1._23 * M1._30 - M1._03 * M1._20 * M1._31 + M1._00 * M1._23 * M1._31 + M1._01 * M1._20 * M1._33 - M1._00 * M1._21 * M1._33, M1._01 * M1._13 * M1._30 - M1._03 * M1._11 * M1._30 + M1._03 * M1._10 * M1._31 - M1._00 * M1._13 * M1._31 - M1._01 * M1._10 * M1._33 + M1._00 * M1._11 * M1._33, M1._03 * M1._11 * M1._20 - M1._01 * M1._13 * M1._20 - M1._03 * M1._10 * M1._21 + M1._00 * M1._13 * M1._21 + M1._01 * M1._10 * M1._23 - M1._00 * M1._11 * M1._23, M1._12 * M1._21 * M1._30 - M1._11 * M1._22 * M1._30 - M1._12 * M1._20 * M1._31 + M1._10 * M1._22 * M1._31 + M1._11 * M1._20 * M1._32 - M1._10 * M1._21 * M1._32, M1._01 * M1._22 * M1._30 - M1._02 * M1._21 * M1._30 + M1._02 * M1._20 * M1._31 - M1._00 * M1._22 * M1._31 - M1._01 * M1._20 * M1._32 + M1._00 * M1._21 * M1._32, M1._02 * M1._11 * M1._30 - M1._01 * M1._12 * M1._30 - M1._02 * M1._10 * M1._31 + M1._00 * M1._12 * M1._31 + M1._01 * M1._10 * M1._32 - M1._00 * M1._11 * M1._32, M1._01 * M1._12 * M1._20 - M1._02 * M1._11 * M1._20 + M1._02 * M1._10 * M1._21 - M1._00 * M1._12 * M1._21 - M1._01 * M1._10 * M1._22 + M1._00 * M1._11 * M1._22 }; Multiply( M0, 1 / Determinant( M1 ) ); return M0; } // // Return the inverse of a matrix, using double-precision intermediate // calculations. // inline NWN::Matrix44 Inverse_Double( __in const NWN::Matrix44 & M1 ) { NWN::Matrix44 M0 = { (float) ( (double) M1._12 * (double) M1._23 * (double) M1._31 - (double) M1._13 * (double) M1._22 * (double) M1._31 + (double) M1._13 * (double) M1._21 * (double) M1._32 - (double) M1._11 * (double) M1._23 * (double) M1._32 - (double) M1._12 * (double) M1._21 * (double) M1._33 + (double) M1._11 * (double) M1._22 * (double) M1._33 ), (float) ( (double) M1._03 * (double) M1._22 * (double) M1._31 - (double) M1._02 * (double) M1._23 * (double) M1._31 - (double) M1._03 * (double) M1._21 * (double) M1._32 + (double) M1._01 * (double) M1._23 * (double) M1._32 + (double) M1._02 * (double) M1._21 * (double) M1._33 - (double) M1._01 * (double) M1._22 * (double) M1._33 ), (float) ( (double) M1._02 * (double) M1._13 * (double) M1._31 - (double) M1._03 * (double) M1._12 * (double) M1._31 + (double) M1._03 * (double) M1._11 * (double) M1._32 - (double) M1._01 * (double) M1._13 * (double) M1._32 - (double) M1._02 * (double) M1._11 * (double) M1._33 + (double) M1._01 * (double) M1._12 * (double) M1._33 ), (float) ( (double) M1._03 * (double) M1._12 * (double) M1._21 - (double) M1._02 * (double) M1._13 * (double) M1._21 - (double) M1._03 * (double) M1._11 * (double) M1._22 + (double) M1._01 * (double) M1._13 * (double) M1._22 + (double) M1._02 * (double) M1._11 * (double) M1._23 - (double) M1._01 * (double) M1._12 * (double) M1._23 ), (float) ( (double) M1._13 * (double) M1._22 * (double) M1._30 - (double) M1._12 * (double) M1._23 * (double) M1._30 - (double) M1._13 * (double) M1._20 * (double) M1._32 + (double) M1._10 * (double) M1._23 * (double) M1._32 + (double) M1._12 * (double) M1._20 * (double) M1._33 - (double) M1._10 * (double) M1._22 * (double) M1._33 ), (float) ( (double) M1._02 * (double) M1._23 * (double) M1._30 - (double) M1._03 * (double) M1._22 * (double) M1._30 + (double) M1._03 * (double) M1._20 * (double) M1._32 - (double) M1._00 * (double) M1._23 * (double) M1._32 - (double) M1._02 * (double) M1._20 * (double) M1._33 + (double) M1._00 * (double) M1._22 * (double) M1._33 ), (float) ( (double) M1._03 * (double) M1._12 * (double) M1._30 - (double) M1._02 * (double) M1._13 * (double) M1._30 - (double) M1._03 * (double) M1._10 * (double) M1._32 + (double) M1._00 * (double) M1._13 * (double) M1._32 + (double) M1._02 * (double) M1._10 * (double) M1._33 - (double) M1._00 * (double) M1._12 * (double) M1._33 ), (float) ( (double) M1._02 * (double) M1._13 * (double) M1._20 - (double) M1._03 * (double) M1._12 * (double) M1._20 + (double) M1._03 * (double) M1._10 * (double) M1._22 - (double) M1._00 * (double) M1._13 * (double) M1._22 - (double) M1._02 * (double) M1._10 * (double) M1._23 + (double) M1._00 * (double) M1._12 * (double) M1._23 ), (float) ( (double) M1._11 * (double) M1._23 * (double) M1._30 - (double) M1._13 * (double) M1._21 * (double) M1._30 + (double) M1._13 * (double) M1._20 * (double) M1._31 - (double) M1._10 * (double) M1._23 * (double) M1._31 - (double) M1._11 * (double) M1._20 * (double) M1._33 + (double) M1._10 * (double) M1._21 * (double) M1._33 ), (float) ( (double) M1._03 * (double) M1._21 * (double) M1._30 - (double) M1._01 * (double) M1._23 * (double) M1._30 - (double) M1._03 * (double) M1._20 * (double) M1._31 + (double) M1._00 * (double) M1._23 * (double) M1._31 + (double) M1._01 * (double) M1._20 * (double) M1._33 - (double) M1._00 * (double) M1._21 * (double) M1._33 ), (float) ( (double) M1._01 * (double) M1._13 * (double) M1._30 - (double) M1._03 * (double) M1._11 * (double) M1._30 + (double) M1._03 * (double) M1._10 * (double) M1._31 - (double) M1._00 * (double) M1._13 * (double) M1._31 - (double) M1._01 * (double) M1._10 * (double) M1._33 + (double) M1._00 * (double) M1._11 * (double) M1._33 ), (float) ( (double) M1._03 * (double) M1._11 * (double) M1._20 - (double) M1._01 * (double) M1._13 * (double) M1._20 - (double) M1._03 * (double) M1._10 * (double) M1._21 + (double) M1._00 * (double) M1._13 * (double) M1._21 + (double) M1._01 * (double) M1._10 * (double) M1._23 - (double) M1._00 * (double) M1._11 * (double) M1._23 ), (float) ( (double) M1._12 * (double) M1._21 * (double) M1._30 - (double) M1._11 * (double) M1._22 * (double) M1._30 - (double) M1._12 * (double) M1._20 * (double) M1._31 + (double) M1._10 * (double) M1._22 * (double) M1._31 + (double) M1._11 * (double) M1._20 * (double) M1._32 - (double) M1._10 * (double) M1._21 * (double) M1._32 ), (float) ( (double) M1._01 * (double) M1._22 * (double) M1._30 - (double) M1._02 * (double) M1._21 * (double) M1._30 + (double) M1._02 * (double) M1._20 * (double) M1._31 - (double) M1._00 * (double) M1._22 * (double) M1._31 - (double) M1._01 * (double) M1._20 * (double) M1._32 + (double) M1._00 * (double) M1._21 * (double) M1._32 ), (float) ( (double) M1._02 * (double) M1._11 * (double) M1._30 - (double) M1._01 * (double) M1._12 * (double) M1._30 - (double) M1._02 * (double) M1._10 * (double) M1._31 + (double) M1._00 * (double) M1._12 * (double) M1._31 + (double) M1._01 * (double) M1._10 * (double) M1._32 - (double) M1._00 * (double) M1._11 * (double) M1._32 ), (float) ( (double) M1._01 * (double) M1._12 * (double) M1._20 - (double) M1._02 * (double) M1._11 * (double) M1._20 + (double) M1._02 * (double) M1._10 * (double) M1._21 - (double) M1._00 * (double) M1._12 * (double) M1._21 - (double) M1._01 * (double) M1._10 * (double) M1._22 + (double) M1._00 * (double) M1._11 * (double) M1._22 ) }; Multiply( M0, 1 / Determinant_Double( M1 ) ); return M0; } // // Return the inverse of a 3x3 matrix. // inline NWN::Matrix33 Inverse( __in const NWN::Matrix33 & M1 ) { return CreateMatrix33FromMatrix44( Inverse( CreateMatrix44FromMatrix33( M1 ) ) ); } // // Transpose a matrix. // inline NWN::Matrix44 Transpose( __in const NWN::Matrix44 & M1 ) { NWN::Matrix44 M0 = { M1._00, M1._10, M1._20, M1._30, M1._01, M1._11, M1._21, M1._31, M1._02, M1._12, M1._22, M1._32, M1._03, M1._13, M1._23, M1._33 }; return M0; } // // Return the affine inverse of a matrix. // NWN::Matrix44 InverseAffine( __in const NWN::Matrix44 & M1 ); // // Create an identity matrix. // inline void CreateIdentityMatrix( __out NWN::Matrix44 & M ) { memcpy( &M, &NWN::Matrix44::IDENTITY, sizeof( M ) ); } // // Set the scale parameters in a matrix. // inline void SetScale( __inout NWN::Matrix44 & M, __in const NWN::Vector3 & Scale ) { M._00 = Scale.x; M._11 = Scale.y; M._22 = Scale.z; M._33 = 1.0f; } // // Get the scale parameters in a matrix. // inline NWN::Vector3 GetScale( __in const NWN::Matrix44 & M ) { NWN::Vector3 Scale; Scale.x = M._00; Scale.y = M._11; Scale.z = M._22; return Scale; } // // Create a scale matrix. // inline void CreateScaleMatrix( __out NWN::Matrix44 & M, __in const NWN::Vector3 & Scale ) { CreateIdentityMatrix( M ); M._00 = Scale.x; M._11 = Scale.y; M._22 = Scale.z; M._33 = 1.0f; } // // Set the translation parameters in a matrix. // inline void SetTranslation( __inout NWN::Matrix44 & M, __in const NWN::Vector3 & Position ) { M._03 = Position.x; M._13 = Position.y; M._23 = Position.z; M._33 = 1.0f; } // // Set the position parameters in a matrix. // inline void SetPosition( __inout NWN::Matrix44 & M, __in const NWN::Vector3 & Position ) { M._30 = Position.x; M._31 = Position.y; M._32 = Position.z; M._33 = 1.0f; } // // Get the position parameters in a matrix. // inline NWN::Vector3 GetPosition( __in const NWN::Matrix44 & M ) { NWN::Vector3 v; v.x = M._30; v.y = M._31; v.z = M._32; return v; } // // Perform the inverse rotation function on a Vector3 with a 4x4 matrix. // inline NWN::Vector3 InverseRotate( __in const NWN::Vector3 & v, __in const NWN::Matrix44 & M ) { NWN::Vector3 vt; vt.x = v.x * M._00 + v.y * M._10 + v.z * M._20; vt.y = v.x * M._01 + v.y * M._11 + v.z * M._21; vt.z = v.x * M._02 + v.y * M._12 + v.z * M._22; return vt; } // // Perform the inverse transform function on a Vector3 with a 4x4 matrix. // inline NWN::Vector3 InverseTransform( __in const NWN::Vector3 & v, __in const NWN::Matrix44 & M ) { NWN::Vector3 vt; vt.x = v.x - M._03; vt.y = v.y - M._13; vt.z = v.z - M._23; return Math::InverseRotate( vt, M ); } // // Create a translation matrix. // inline void CreateTranslationMatrix( __out NWN::Matrix44 & M, __in const NWN::Vector3 & Position ) { CreateIdentityMatrix( M ); SetTranslation( M, Position ); } // // Create a look-at matrix (right-handed). // inline void CreateLookAtMatrixRH( __out NWN::Matrix44 & M, __in const NWN::Vector3 & Eye, __in const NWN::Vector3 & At, __in const NWN::Vector3 & Up ) { NWN::Vector3 xaxis; NWN::Vector3 yaxis; NWN::Vector3 zaxis; zaxis = NormalizeVector( Subtract( Eye, At ) ); xaxis = NormalizeVector( CrossProduct( Up, zaxis ) ); yaxis = CrossProduct( zaxis, xaxis ); M._00 = +xaxis.x; M._10 = +xaxis.y; M._20 = +xaxis.z; M._30 = -DotProduct( xaxis, Eye ); M._01 = +yaxis.x; M._11 = +yaxis.y; M._21 = +yaxis.z; M._31 = -DotProduct( yaxis, Eye ); M._02 = +zaxis.x; M._12 = +zaxis.y; M._22 = +zaxis.z; M._32 = -DotProduct( zaxis, Eye ); M._03 = 0.0f; M._13 = 0.0f; M._23 = 0.0f; M._33 = 1.0f; } // // Create a look-at matrix (left-handed). // inline void CreateLookAtMatrixLH( __out NWN::Matrix44 & M, __in const NWN::Vector3 & Eye, __in const NWN::Vector3 & At, __in const NWN::Vector3 & Up ) { NWN::Vector3 xaxis; NWN::Vector3 yaxis; NWN::Vector3 zaxis; zaxis = NormalizeVector( Subtract( At, Eye ) ); xaxis = NormalizeVector( CrossProduct( Up, zaxis ) ); yaxis = CrossProduct( zaxis, xaxis ); M._00 = +xaxis.x; M._10 = +xaxis.y; M._20 = +xaxis.z; M._30 = -DotProduct( xaxis, Eye ); M._01 = +yaxis.x; M._11 = +yaxis.y; M._21 = +yaxis.z; M._31 = -DotProduct( yaxis, Eye ); M._02 = +zaxis.x; M._12 = +zaxis.y; M._22 = +zaxis.z; M._32 = -DotProduct( zaxis, Eye ); M._03 = 0.0f; M._13 = 0.0f; M._23 = 0.0f; M._33 = 1.0f; } // // Create a rotation matrix (right-handed). // inline NWN::Matrix44 CreateRotationXMatrixRH( __out NWN::Matrix44 & M, __in float A ) { M._00 = 1.0f; M._01 = 0.0f; M._02 = 0.0f; M._03 = 0.0f; M._10 = 0.0f; M._11 = +cosf( A ); M._12 = +sinf( A ); M._13 = 0.0f; M._20 = 0.0f; M._21 = -sinf( A ); M._22 = +cosf( A ); M._23 = 0.0f; M._30 = 0.0f; M._31 = 0.0f; M._32 = 0.0f; M._33 = 1.0f; return M; } inline NWN::Matrix44 CreateRotationYMatrixRH( __out NWN::Matrix44 & M, __in float A ) { M._00 = +cosf( A ); M._01 = 0.0f; M._02 = -sinf( A ); M._03 = 0.0f; M._10 = 0.0f; M._11 = 1.0f; M._12 = 0.0f; M._13 = 0.0f; M._20 = +sinf( A ); M._21 = 0.0f; M._22 = +cosf( A ); M._23 = 0.0f; M._30 = 0.0f; M._31 = 0.0f; M._32 = 0.0f; M._33 = 1.0f; return M; } inline NWN::Matrix44 CreateRotationZMatrixRH( __out NWN::Matrix44 & M, __in float A ) { M._00 = +cosf( A ); M._01 = +sinf( A ); M._02 = 0.0f; M._03 = 0.0f; M._10 = -sinf( A ); M._11 = +cosf( A ); M._12 = 0.0f; M._13 = 0.0f; M._20 = 0.0f; M._21 = 0.0f; M._22 = 1.0f; M._23 = 0.0f; M._30 = 0.0f; M._31 = 0.0f; M._32 = 0.0f; M._33 = 1.0f; return M; } // // Create a rotation matrix about an arbitrary axis. // inline NWN::Matrix44 CreateRotationAxisMatrix( __out NWN::Matrix44 & M, __in const NWN::Vector3 & V, __in float A ) { NWN::Vector3 VN; float A_cos; float A_sin; CreateIdentityMatrix( M ); VN = Math::NormalizeVector( V ); A_cos = cos( A ); A_sin = sin( A ); M._00 = (1.0f - A_cos) * VN.x * VN.x + A_cos; M._10 = (1.0f - A_cos) * VN.x * VN.y - A_sin * VN.z; M._20 = (1.0f - A_cos) * VN.x * VN.z + A_sin * VN.y; M._01 = (1.0f - A_cos) * VN.y * VN.x + A_sin * VN.z; M._11 = (1.0f - A_cos) * VN.y * VN.y + A_cos; M._21 = (1.0f - A_cos) * VN.y * VN.z - A_sin * VN.x; M._02 = (1.0f - A_cos) * VN.z * VN.x - A_sin * VN.y; M._12 = (1.0f - A_cos) * VN.z * VN.y + A_sin * VN.x; M._22 = (1.0f - A_cos) * VN.z * VN.z + A_cos; return M; } // // Create a field of view perspective matrix (right-handed). // inline void CreatePerspectiveFovMatrixRH( __out NWN::Matrix44 & M, __in float fovy, __in float Aspect, __in float zn, __in float zf ) { NWN::Vector2 Scale; Scale.y = 1.0f / tan( fovy / 2.0f); Scale.x = Scale.y / Aspect; M._00 = Scale.x; M._01 = 0.0f; M._02 = 0.0f; M._03 = 0.0f; M._10 = 0.0f; M._11 = Scale.y; M._12 = 0.0f; M._13 = 0.0f; M._20 = 0.0f; M._21 = 0.0f; M._22 = zf / (zn - zf); M._23 = -1.0f; M._30 = 0.0f; M._31 = 0.0f; M._32 = (zn * zf) / (zn - zf); M._33 = 0.0f; } inline void CreatePerspectiveFovMatrixLH( __inout NWN::Matrix44 & M, __in float fovy, __in float Aspect, __in float zn, __in float zf ) { NWN::Vector2 Scale; Scale.y = 1.0f / tan( fovy / 2.0f); Scale.x = Scale.y / Aspect; M._00 = Scale.x; M._01 = 0.0f; M._02 = 0.0f; M._03 = 0.0f; M._10 = 0.0f; M._11 = Scale.y; M._12 = 0.0f; M._13 = 0.0f; M._20 = 0.0f; M._21 = 0.0f; M._22 = zf / (zn - zf); M._23 = 1.0f; M._30 = 0.0f; M._31 = 0.0f; M._32 = -zn * M._22; M._33 = 0.0f; } // http://www.j3d.org/matrix_faq/matrfaq_latest.html // // Retrieve the conjugate of a quaternion. // inline NWN::Quaternion Conjugate( __in const NWN::Quaternion & Q1 ) { NWN::Quaternion Q0; Q0.w = +Q1.w; Q0.x = -Q1.x; Q0.y = -Q1.y; Q0.z = -Q1.z; return Q0; } // // Return the magnitude of a quaternion. // inline float Magnitude( __in const NWN::Quaternion & Q ) { return sqrtf( Q.w * Q.w + Q.x * Q.x + Q.y * Q.y + Q.z * Q.z); } // // Normalize a quaternion. // inline NWN::Quaternion Normalize( __in const NWN::Quaternion & Q1 ) { NWN::Quaternion Q0; float M; Q0 = Q1; M = Magnitude( Q1 ); if (M <= Math::Epsilon) M = 1.0f; Q0.x /= M; Q0.y /= M; Q0.z /= M; Q0.w /= M; return Q0; } // // Return the inverse of a quaternion. // inline NWN::Quaternion Inverse( __in const NWN::Quaternion & Q1 ) { return Math::Normalize( Math::Conjugate( Q1 ) ); } // // Multiply a vector by a quaternion. // inline NWN::Vector3 Multiply( __in const NWN::Vector3 & V, __in const NWN::Quaternion & Q ) { NWN::Vector3 uv; NWN::Vector3 uuv; NWN::Vector3 qv; qv.x = Q.x; qv.y = Q.y; qv.z = Q.z; uv = Math::CrossProduct( qv, V ); uuv = Math::CrossProduct( qv, uv ); uv = Math::Multiply( uv, 2.0f * Q.w ); uuv = Math::Multiply( uuv, 2.0f ); return Math::Add( Math::Add( V, uv ), uuv ); } // // Convert a quaternion to a rotational matrix. // // As per http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToMatrix/index.htm // inline void SetRotationMatrix( __inout NWN::Matrix44 & M, __in const NWN::Quaternion & Q ) { float sqw = Q.w * Q.w; float sqx = Q.x * Q.x; float sqy = Q.y * Q.y; float sqz = Q.z * Q.z; float invs; float t1; float t2; // // invs (inverse square lnegth) is only required if quaternion is not // already normalied. // invs = 1 / (sqx + sqy + sqz + sqw); M._00 = ( sqx - sqy - sqz + sqw) * invs; // since sqw + sqx + sqy + sqz =1/invs*invs M._11 = (-sqx + sqy - sqz + sqw) * invs; M._22 = (-sqx - sqy + sqz + sqw) * invs; t1 = Q.x * Q.y; t2 = Q.z * Q.w; M._10 = 2.0f * (t1 + t2) * invs; M._01 = 2.0f * (t1 - t2) * invs; t1 = Q.x * Q.z; t2 = Q.y * Q.w; M._20 = 2.0f * (t1 - t2) * invs; M._02 = 2.0f * (t1 + t2) * invs; t1 = Q.y * Q.z; t2 = Q.x * Q.w; M._21 = 2.0f * (t1 + t2) * invs; M._12 = 2.0f * (t1 - t2) * invs; } // // Convert a rotational matrix to a quaternion. // // As per http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm // and: http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/christian.htm // inline NWN::Quaternion CreateRotationQuaternion( __in const NWN::Matrix44 & M ) { NWN::Quaternion Q; #if 0 float trace = M._00 + M._11 + M._22; if( trace > 0 ) { float s = 0.5f / sqrtf(trace+ 1.0f); Q.w = 0.25f / s; Q.x = ( M._21 - M._12 ) * s; Q.y = ( M._02 - M._20 ) * s; Q.z = ( M._10 - M._01 ) * s; } else { if ( M._00 > M._11 && M._00 > M._22 ) { float s = 2.0f * sqrtf( 1.0f + M._00 - M._11 - M._22); Q.w = (M._21 - M._12 ) / s; Q.x = 0.25f * s; Q.y = (M._01 + M._10 ) / s; Q.z = (M._02 + M._20 ) / s; } else if (M._11 > M._22) { float s = 2.0f * sqrtf( 1.0f + M._11 - M._00 - M._22); Q.w = (M._02 - M._20 ) / s; Q.x = (M._01 + M._10 ) / s; Q.y = 0.25f * s; Q.z = (M._12 + M._21 ) / s; } else { float s = 2.0f * sqrtf( 1.0f + M._22 - M._00 - M._11 ); Q.w = (M._10 - M._01 ) / s; Q.x = (M._02 + M._20 ) / s; Q.y = (M._12 + M._21 ) / s; Q.z = 0.25f * s; } } #else Q.w = sqrtf( max( 0, 1 + M._00 + M._11 + M._22 ) ) / 2; Q.x = sqrtf( max( 0, 1 + M._00 - M._11 - M._22 ) ) / 2; Q.y = sqrtf( max( 0, 1 - M._00 + M._11 - M._22 ) ) / 2; Q.z = sqrtf( max( 0, 1 - M._00 - M._11 + M._22 ) ) / 2; Q.x = (float) _copysign( Q.x, M._21 - M._12 ); Q.y = (float) _copysign( Q.y, M._02 - M._20 ); Q.z = (float) _copysign( Q.z, M._10 - M._01 ); #endif return Q; } // // Decompose a scale/rotation/translation matrix into its components. // void Matrix44SRTDecompose( __in const NWN::Matrix44 & WorldTrans, __out NWN::Vector3 & Scale, __out NWN::Vector3 & Translation, __out NWN::Matrix44 & Rotation ); // // Decompose a scale/rotation/translation matrix into its components. // void Matrix44SRTDecompose( __in const NWN::Matrix44 & WorldTrans, __out NWN::Vector3 & Scale, __out NWN::Vector3 & Translation, __out NWN::Quaternion & Rotation ); // // Return a direction vector from a quaternion. // inline NWN::Vector3 DirectionVectorFromQuaternion( __in const NWN::Quaternion & Q ) { NWN::Matrix44 RotationMatrix; NWN::Vector3 v; SetRotationMatrix( RotationMatrix, Q ); v.x = 0.0f; v.y = 1.0f; v.z = 0.0f; return Math::Multiply( RotationMatrix, v ); } // // Calculate whether a point resides within a bounding box. // inline bool PointInRect( __in const NWN::Rect & Rect, __in const NWN::Vector2 & pt ) { if ((pt.x - Rect.left < Epsilon) || (pt.x - Rect.right > Epsilon) || (pt.y - Rect.top < Epsilon) || (pt.y - Rect.bottom > Epsilon)) { return false; } return true; } // // Calculate whether a point resides within a bounding box. // inline bool PointInRect( __in const RectFP & Rect, __in const Vector2FP & pt ) { if ((pt.x < Rect.left) || (pt.x > Rect.right) || (pt.y < Rect.top) || (pt.y > Rect.bottom)) { return false; } return true; } // // Calculate whether a point is on the left side of a line drawn infinitely // into the distance of a plane. // inline bool PointInLeftHalfspace( __in const NWN::Vector2 & Start, __in const NWN::Vector2 & End, __in const NWN::Vector2 & pt ) { NWN::Vector2 Line; NWN::Vector2 Line90; NWN::Vector2 v; Line.x = End.x - Start.x; Line.y = End.y - Start.y; v.x = pt.x - Start.x; v.y = pt.y - Start.y; // // Rotate 90 degrees clockwise. // Line90.x = Line.y; Line90.y = -Line.x; return DotProduct( Line90, v ) <= 0.0f; } // // Calculate whether a triangle is spun clockwise. // inline bool TriangleSpunClockwise( __in_ecount(3) const NWN::Vector2 * Tri ) { return PointInLeftHalfspace( Tri[ 1 ], Tri[ 0 ], Tri[ 2 ] ); } // // Calculate whether a point resides within a triangle. // inline bool PointInTriangle( __in_ecount(3) const NWN::Vector2 * Tri, __in const NWN::Vector2 & pt, __in bool Clockwise ) { if (Clockwise) { return ((PointInLeftHalfspace( Tri[ 1 ], Tri[ 0 ], pt )) && (PointInLeftHalfspace( Tri[ 2 ], Tri[ 1 ], pt )) && (PointInLeftHalfspace( Tri[ 0 ], Tri[ 2 ], pt ))); } else { return ((PointInLeftHalfspace( Tri[ 0 ], Tri[ 1 ], pt )) && (PointInLeftHalfspace( Tri[ 1 ], Tri[ 2 ], pt )) && (PointInLeftHalfspace( Tri[ 2 ], Tri[ 0 ], pt ))); } } // // Return the normal of a triangle. // inline NWN::Vector3 ComputeNormalTriangle( __in_ecount(3) const NWN::Vector3 * Tri ) { NWN::Vector3 v1; NWN::Vector3 v2; v1.x = Tri[ 1 ].x - Tri[ 0 ].x; v1.y = Tri[ 1 ].y - Tri[ 0 ].y; v1.z = Tri[ 1 ].z - Tri[ 0 ].z; v2.x = Tri[ 2 ].x - Tri[ 0 ].x; v2.y = Tri[ 2 ].y - Tri[ 0 ].y; v2.z = Tri[ 2 ].z - Tri[ 0 ].z; return Math::NormalizeVector( Math::CrossProduct( v1, v2 ) ); } // // Return the coordinates of a point given its distance along the path of // a ray. // inline NWN::Vector3 PointFromRayDistance( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & NormDir, __in float Distance ) { NWN::Vector3 v; v.x = Origin.x + (NormDir.x * Distance); v.y = Origin.y + (NormDir.y * Distance); v.z = Origin.z + (NormDir.z * Distance); return v; } // // Return the coordinates of a point given its distance along the path of // a ray. // inline NWN::Vector2 PointFromRayDistance( __in const NWN::Vector2 & Origin, __in const NWN::Vector2 & NormDir, __in float Distance ) { NWN::Vector2 v; v.x = Origin.x + (NormDir.x * Distance); v.y = Origin.y + (NormDir.y * Distance); return v; } inline double PlaneHeightAtPoint( __in const NWN::Vector3 & Normal, __in float D, __in const NWN::Vector2 & Pt ) { NWN::Vector2 Normal2; if (Normal.z == 0.0f) return 0.0f; Normal2.x = Normal.x; Normal2.y = Normal.y; return -((DotProduct( Normal2, Pt ) + D) / Normal.z); } // // Calculate the distance from a ray origin towards a plane, should the ray // intersect the plane. Should the ray not intersect the plane, a negative // distance is returned. // inline float RayPlaneDistance( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & NormDir, __in const NWN::Vector3 & PlaneNormal, __in float PlaneD ) { float cA; float dD; cA = DotProduct( NormDir, PlaneNormal ); // // If we're parallel, there's no intersection. // if (fabsf( cA ) <= Math::Epsilon) return -1.0f; dD = PlaneD - DotProduct( Origin, PlaneNormal ); return dD / cA; } template< class T > inline T GCD( __in T a, __in T b ) { T t; while (b != 0) { t = b; b = a % b; a = t; } return a; } // // Distance calculation helper. // inline float Distance( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { double d; d = (v2.x - v1.x) * (v2.x - v1.x) + (v2.y - v1.y) * (v2.y - v1.y) + (v2.z - v1.z) * (v2.z - v1.z); return (float) sqrt( d ); } inline float Distance( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { double d; d = (v2.x - v1.x) * (v2.x - v1.x) + (v2.y - v1.y) * (v2.y - v1.y); return (float) sqrt( d ); } inline float DistanceSq( __in const NWN::Vector3 & v1, __in const NWN::Vector3 & v2 ) { double d; d = (v2.x - v1.x) * (v2.x - v1.x) + (v2.y - v1.y) * (v2.y - v1.y) + (v2.z - v1.z) * (v2.z - v1.z); return (float) d; } inline float DistanceSq( __in const NWN::Vector2 & v1, __in const NWN::Vector2 & v2 ) { double d; d = (v2.x - v1.x) * (v2.x - v1.x) + (v2.y - v1.y) * (v2.y - v1.y); return (float) d; } // // Return the 2D centroid of a polygon. // NWN::Vector2 PolygonCentroid2( __in const Vector2Vec & Polygon ); // // Test if a point resides within a 2D polygon. // bool PointInPolygonRegion( __in const NWN::Vector2 & v, __in const Vector2Vec & Polygon, __in const unsigned int FixedPointShift = Math::FixedPointShift ); // // Test if a point resides within a 2D polygon (Z coordinate ignored). // bool PointInPolygonRegion( __in const NWN::Vector3 & v, __in const Vector3Vec & Polygon, __in const unsigned int FixedPointShift = Math::FixedPointShift ); // // Test if a point resides within a 2D polygon. // bool PointInPolygonRegion( __in const Vector2FP & v, __in const Vector2FPVec & Polygon ); // // Intersect a ray with a triangle and return the distance to the // intersection point on successful intersection. // bool IntersectRayTri( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & NormDir, __in_ecount(3) const NWN::Vector3 * Tri, __out float & T ); // // Intersect a ray with a triangle and return the distance to the // intersection point on successful intersection. // // Backfaces are not considered intersecting. // bool IntersectRayTriRejectBackface( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & NormDir, __in_ecount(3) const NWN::Vector3 * Tri, __out float & T ); // // Intersect a ray with a sphere. // bool IntersectRaySphere( __in const NWN::Vector3 & RayOrigin, __in const NWN::Vector3 & RayNormDir, __in const NWN::Vector3 & SphereOrigin, __in const float SphereRadiusSq, __out float & T ); // // Intersect two line segments and return whether they actually crossed or // not. The routine also calculates whether the line segments are parallel // and returns the parallel status via the Parallel argument. // bool IntersectSegments2( __in const NWN::Vector2 & s1_p1, __in const NWN::Vector2 & s1_p2, __in const NWN::Vector2 & s2_p1, __in const NWN::Vector2 & s2_p2, __out NWN::Vector2 & IntersectionPoint, __out bool & Parallel ); // // Intersect a line segment and a polygon, and return the intersection // segment (if any). // bool IntersectSegmentPolygon( __in const NWN::Vector2 & s_p1, __in const NWN::Vector2 & s_p2, __in_ecount( NumPoints ) const NWN::Vector2 * PolygonPoints, __in size_t NumPoints, __out NWN::Vector2 & I_p1, __out NWN::Vector2 & I_p2 ); // // Determine whether a line segment bounded by two points intersects with // a single point. bool PointInSegment( __in const NWN::Vector2 & s_p1, __in const NWN::Vector2 & s_p2, __in const NWN::Vector2 & pt ); // // Line projection. // inline NWN::Vector3 LineProject3( __in const NWN::Vector3 & P0, __in const NWN::Vector3 & P1, __in const NWN::Vector3 & A ) { NWN::Vector3 W; float T; float D; W = Math::Subtract( P1, P0 ); D = (sqrtf( W.x ) + sqrtf( W.y ) + sqrtf( W.z )); T = Math::DotProduct( W, Math::Subtract( A, P0 ) ); if (fabsf( D ) > Math::Epsilon) T /= D; return Math::Add( P0, Math::Multiply( W, T ) ); } // // Fast ray / box intersection. // // Courtesy http://people.csail.mit.edu/amy/papers/box-jgt.pdf // class QuickRay { public: inline QuickRay( __in const NWN::Vector3 & o, __in const NWN::Vector3 & d ) : m_origin( o ), m_direction( d ) { m_origin = o; m_direction = d; m_inv_direction.x = 1.0f / d.x; m_inv_direction.y = 1.0f / d.y; m_inv_direction.z = 1.0f / d.z; m_sign[ 0 ] = (m_inv_direction.x < 0.0f); m_sign[ 1 ] = (m_inv_direction.y < 0.0f); m_sign[ 2 ] = (m_inv_direction.z < 0.0f); } NWN::Vector3 m_origin; NWN::Vector3 m_direction; NWN::Vector3 m_inv_direction; int m_sign[ 3 ]; }; class QuickBox { public: inline QuickBox( __in const NWN::Vector3 & min, __in const NWN::Vector3 & max ) { m_bounds[ 0 ] = min; m_bounds[ 1 ] = max; } inline bool IntersectRay( __in const QuickRay & r, __in float t0 = 0.0f, __in float t1 = FLT_MAX ) const { float tmin; float tmax; float tymin; float tymax; float tzmin; float tzmax; tmin = (m_bounds[ r.m_sign[ 0 ] ].x - r.m_origin.x) * r.m_inv_direction.x; tmax = (m_bounds[ 1-r.m_sign[ 0 ] ].x - r.m_origin.x) * r.m_inv_direction.x; tymin = (m_bounds[ r.m_sign[ 1 ] ].y - r.m_origin.y) * r.m_inv_direction.y; tymax = (m_bounds[ 1-r.m_sign[ 1 ] ].y - r.m_origin.y) * r.m_inv_direction.y; if ( (tmin > tymax) || (tymin > tmax) ) return false; if (tymin > tmin) tmin = tymin; if (tymax < tmax) tmax = tymax; tzmin = (m_bounds[ r.m_sign[ 2 ] ].z - r.m_origin.z) * r.m_inv_direction.z; tzmax = (m_bounds[ 1-r.m_sign[ 2 ] ].z - r.m_origin.z) * r.m_inv_direction.z; if ( (tmin > tzmax) || (tzmin > tmax) ) return false; if (tzmin > tmin) tmin = tzmin; if (tzmax < tmax) tmax = tzmax; return ( (tmin < t1) && (tmax > t0) ); } inline void SetBounds( __in const NWN::Vector3 & MinBound, __in const NWN::Vector3 & MaxBound ) { m_bounds[ 0 ] = MinBound; m_bounds[ 1 ] = MaxBound; } inline bool IntersectPoint( __in const NWN::Vector3 & Point ) const { return Point.x >= m_bounds[ 0 ].x && Point.x <= m_bounds[ 1 ].x && Point.y >= m_bounds[ 0 ].y && Point.y <= m_bounds[ 1 ].y && Point.z >= m_bounds[ 0 ].z && Point.z <= m_bounds[ 1 ].z; } private: NWN::Vector3 m_bounds[ 2 ]; }; // // Define a simple 2D bounding box. // class BoundBox2 { public: inline BoundBox2( __in const NWN::Vector2 & BoundMin, __in const NWN::Vector2 & BoundMax ) : m_MinBound( BoundMin ), m_MaxBound( BoundMax ) { } inline ~BoundBox2( ) { } // // Check if a point resides within the bounded region. // inline bool PointIntersect( __in const NWN::Vector2 & v ) const { if ((v.x >= m_MinBound.x) && (v.x <= m_MaxBound.x) && (v.y >= m_MinBound.y) && (v.y <= m_MaxBound.y)) { return true; } return false; } inline void SetBounds( __in const NWN::Vector2 & MinBound, __in const NWN::Vector2 & MaxBound ) { m_MinBound = MinBound; m_MaxBound = MaxBound; } private: NWN::Vector2 m_MinBound; NWN::Vector2 m_MaxBound; }; // // Optimized 3D sphere collision testing object. // class QuickSphere { public: QuickSphere( __in const NWN::Vector3 & Origin, __in float Radius ) : m_Origin( Origin ), m_RadiusSq( Radius * Radius ) { } inline bool IntersectPoint( __in const NWN::Vector3 & Point ) const { return (Math::DistanceSq( m_Origin, Point ) <= m_RadiusSq); } private: NWN::Vector3 m_Origin; float m_RadiusSq; }; // // Optimized 3D cylinder collision testing object (allows for arbitrary // orientations). // // Courtesy Greg James - gjames@nvidia.com // class QuickCylinder { public: QuickCylinder( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & Terminator, __in float Length, __in float Radius ) : m_Origin( Origin ), m_OriginToTerm( Math::Subtract( Terminator, Origin ) ), m_LengthSq( Length * Length ), m_RadiusSq( Radius * Radius ) { } // // Determine whether a point lies within the cylinder. If the point is // outside the cylinder, -1.0f is returned, else the distance squared // from the cylinder center is returned. // inline float IntersectPoint( __in const NWN::Vector3 & Point ) const { NWN::Vector3 pd; float dot; float dsq; // // Dot the m_OriginToTerm and pd vectors to see if the point lies // behind the cylinder cap at m_Origin. // pd = Math::Subtract( Point, m_Origin ); dot = Math::DotProduct( m_OriginToTerm, pd ); // // If dot is less than zero, then the point is behind the m_Origin // cap. // If dot is greater than the cylinder axis line segment length, // then the point is outside the other end cap at m_Terminator. // if ((dot < 0.0f) || (dot > m_LengthSq)) return -1.0f; // // The point resides within the parallel caps, so find the distance // squared from point to line, using the fact that sin^2 + cos^2 // = 1. // // dot = cos * |d||pd|, and cross*cross = sin^2 | |d|^2 * |pd|^2 // // (* -> multiply for scalars and dotproduct for vectors) // // In short, where dist is the point distance to cylinder axis: // // dist = sin( pd to d ) * |pd| // distsq = dsq = (1 - cos^2( pd to d)) * |pd|^2 // dsq = pd * pd - dot * dot / m_LengthSq // dsq = (Math::DotProduct( pd, pd )) - dot * dot / m_LengthSq; if (dsq > m_RadiusSq) return -1.0f; else return dsq; } private: NWN::Vector3 m_Origin; NWN::Vector3 m_OriginToTerm; float m_LengthSq; float m_RadiusSq; }; // // Optimized cone collision testing object (allows for arbitrary // orientations). // class QuickCone { public: QuickCone( __in const NWN::Vector3 & Origin, __in const NWN::Vector3 & Terminator, __in float Length, __in float Radius ) : m_Origin( Origin ), m_OriginToTerm( Math::Subtract( Terminator, Origin ) ), m_LengthSq( Length * Length ), m_RadiusSq( Radius * Radius ) { } // // Determine whether a point lies within the cylinder. If the point is // outside the cylinder, -1.0f is returned, else the distance squared // from the cylinder center is returned. // inline float IntersectPoint( __in const NWN::Vector3 & Point ) const { NWN::Vector3 pd; float dot; float dsq; float T; // // Dot the m_OriginToTerm and pd vectors to see if the point lies // behind the cylinder cap at m_Origin. // pd = Math::Subtract( Point, m_Origin ); dot = Math::DotProduct( m_OriginToTerm, pd ); // // If dot is less than zero, then the point is behind the m_Origin // cap. // If dot is greater than the cylinder axis line segment length, // then the point is outside the other end cap at m_Terminator. // if ((dot < 0.0f) || (dot > m_LengthSq)) return -1.0f; T = dot / m_LengthSq; // // The point resides within the parallel caps, so find the distance // squared from point to line, using the fact that sin^2 + cos^2 // = 1. // // dot = cos * |d||pd|, and cross*cross = sin^2 | |d|^2 * |pd|^2 // // (* -> multiply for scalars and dotproduct for vectors) // // In short, where dist is the point distance to cylinder axis: // // dist = sin( pd to d ) * |pd| // distsq = dsq = (1 - cos^2( pd to d)) * |pd|^2 // dsq = pd * pd - dot * dot / m_LengthSq // dsq = (Math::DotProduct( pd, pd )) - dot * dot / m_LengthSq; if (dsq > m_RadiusSq * (T * T)) return -1.0f; else return dsq; } private: NWN::Vector3 m_Origin; NWN::Vector3 m_OriginToTerm; float m_LengthSq; float m_RadiusSq; }; } #endif
[ "fantasydr.gg@gmail.com" ]
fantasydr.gg@gmail.com
5436c53fa9d11021ca27d8e168ddb731c43866f4
fbcbbcf05334b4c7310a9d6ed6aa925f1f9dd9a8
/export/release/windows/obj/include/OptionsMenu.h
fd1212cef10c9a8b2892c263c99dc1be7586db08
[ "Apache-2.0" ]
permissive
Schizine/Keigo-modGame
bff5e75fd3c7c3793a037608dc53b29cc3d1429d
36cef5a3b44208625980caea5a85c978872a2dbd
refs/heads/master
2023-07-03T11:24:37.604635
2021-08-05T19:50:28
2021-08-05T19:50:28
393,148,973
0
0
null
null
null
null
UTF-8
C++
false
true
3,229
h
// Generated by Haxe 4.1.5 #ifndef INCLUDED_OptionsMenu #define INCLUDED_OptionsMenu #ifndef HXCPP_H #include <hxcpp.h> #endif #ifndef INCLUDED_MusicBeatState #include <MusicBeatState.h> #endif HX_DECLARE_CLASS0(MusicBeatState) HX_DECLARE_CLASS0(OptionCategory) HX_DECLARE_CLASS0(OptionsMenu) HX_DECLARE_CLASS1(flixel,FlxBasic) HX_DECLARE_CLASS1(flixel,FlxObject) HX_DECLARE_CLASS1(flixel,FlxSprite) HX_DECLARE_CLASS1(flixel,FlxState) HX_DECLARE_CLASS3(flixel,addons,transition,FlxTransitionableState) HX_DECLARE_CLASS3(flixel,addons,transition,TransitionData) HX_DECLARE_CLASS3(flixel,addons,ui,FlxUIState) HX_DECLARE_CLASS4(flixel,addons,ui,interfaces,IEventGetter) HX_DECLARE_CLASS4(flixel,addons,ui,interfaces,IFlxUIState) HX_DECLARE_CLASS2(flixel,group,FlxTypedGroup) HX_DECLARE_CLASS2(flixel,text,FlxText) HX_DECLARE_CLASS2(flixel,util,IFlxDestroyable) class HXCPP_CLASS_ATTRIBUTES OptionsMenu_obj : public ::MusicBeatState_obj { public: typedef ::MusicBeatState_obj super; typedef OptionsMenu_obj OBJ_; OptionsMenu_obj(); public: enum { _hx_ClassId = 0x109e893d }; void __construct( ::flixel::addons::transition::TransitionData TransIn, ::flixel::addons::transition::TransitionData TransOut); inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="OptionsMenu") { return ::hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return ::hx::Object::operator new(inSize+extra,true,"OptionsMenu"); } static ::hx::ObjectPtr< OptionsMenu_obj > __new( ::flixel::addons::transition::TransitionData TransIn, ::flixel::addons::transition::TransitionData TransOut); static ::hx::ObjectPtr< OptionsMenu_obj > __alloc(::hx::Ctx *_hx_ctx, ::flixel::addons::transition::TransitionData TransIn, ::flixel::addons::transition::TransitionData TransOut); static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(::hx::DynamicArray inArgs); //~OptionsMenu_obj(); HX_DO_RTTI_ALL; ::hx::Val __Field(const ::String &inString, ::hx::PropertyAccess inCallProp); static bool __GetStatic(const ::String &inString, Dynamic &outValue, ::hx::PropertyAccess inCallProp); ::hx::Val __SetField(const ::String &inString,const ::hx::Val &inValue, ::hx::PropertyAccess inCallProp); static bool __SetStatic(const ::String &inString, Dynamic &ioValue, ::hx::PropertyAccess inCallProp); void __GetFields(Array< ::String> &outFields); static void __register(); void __Mark(HX_MARK_PARAMS); void __Visit(HX_VISIT_PARAMS); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_("OptionsMenu",fd,43,a3,5d); } static ::OptionsMenu instance; static ::flixel::text::FlxText versionShit; ::flixel::text::FlxText selector; int curSelected; ::Array< ::Dynamic> options; bool acceptInput; ::String currentDescription; ::flixel::group::FlxTypedGroup grpControls; ::OptionCategory currentSelectedCat; ::flixel::FlxSprite blackBorder; void create(); bool isCat; void update(Float elapsed); bool isSettingControl; void changeSelection(::hx::Null< int > change); ::Dynamic changeSelection_dyn(); }; #endif /* INCLUDED_OptionsMenu */
[ "dasharseniy@gmail.com" ]
dasharseniy@gmail.com
174b8262e21da010993820177f6fa2e05e1af2d7
58017c1a2a7b2d2f53a5e6492912960d3ac7a7d9
/Intermediate/Build/Win64/UE4Editor/Inc/SecondProject/Potion.gen.cpp
c9a805fee52844e34876b5edfdbb746618cee666
[]
no_license
uni20141612/UnrealProject
02bd24dbae2c0d54b904e7e280216ea02ef31042
3bdc1447f126f6d9e6177796e55b255ffaeec49b
refs/heads/master
2023-05-21T10:38:54.618648
2021-06-08T11:13:21
2021-06-08T11:13:21
368,225,635
2
0
null
null
null
null
UTF-8
C++
false
false
3,070
cpp
// Copyright Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "SecondProject/Public/Item/Potion.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodePotion() {} // Cross Module References SECONDPROJECT_API UClass* Z_Construct_UClass_APotion_NoRegister(); SECONDPROJECT_API UClass* Z_Construct_UClass_APotion(); SECONDPROJECT_API UClass* Z_Construct_UClass_AItemActor(); UPackage* Z_Construct_UPackage__Script_SecondProject(); // End Cross Module References void APotion::StaticRegisterNativesAPotion() { } UClass* Z_Construct_UClass_APotion_NoRegister() { return APotion::StaticClass(); } struct Z_Construct_UClass_APotion_Statics { static UObject* (*const DependentSingletons[])(); #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[]; #endif static const FCppClassTypeInfoStatic StaticCppClassTypeInfo; static const UE4CodeGen_Private::FClassParams ClassParams; }; UObject* (*const Z_Construct_UClass_APotion_Statics::DependentSingletons[])() = { (UObject* (*)())Z_Construct_UClass_AItemActor, (UObject* (*)())Z_Construct_UPackage__Script_SecondProject, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_APotion_Statics::Class_MetaDataParams[] = { { "Comment", "/**\n * \n */" }, { "IncludePath", "Item/Potion.h" }, { "ModuleRelativePath", "Public/Item/Potion.h" }, }; #endif const FCppClassTypeInfoStatic Z_Construct_UClass_APotion_Statics::StaticCppClassTypeInfo = { TCppClassTypeTraits<APotion>::IsAbstract, }; const UE4CodeGen_Private::FClassParams Z_Construct_UClass_APotion_Statics::ClassParams = { &APotion::StaticClass, "Engine", &StaticCppClassTypeInfo, DependentSingletons, nullptr, nullptr, nullptr, UE_ARRAY_COUNT(DependentSingletons), 0, 0, 0, 0x009000A4u, METADATA_PARAMS(Z_Construct_UClass_APotion_Statics::Class_MetaDataParams, UE_ARRAY_COUNT(Z_Construct_UClass_APotion_Statics::Class_MetaDataParams)) }; UClass* Z_Construct_UClass_APotion() { static UClass* OuterClass = nullptr; if (!OuterClass) { UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_APotion_Statics::ClassParams); } return OuterClass; } IMPLEMENT_CLASS(APotion, 4215811411); template<> SECONDPROJECT_API UClass* StaticClass<APotion>() { return APotion::StaticClass(); } static FCompiledInDefer Z_CompiledInDefer_UClass_APotion(Z_Construct_UClass_APotion, &APotion::StaticClass, TEXT("/Script/SecondProject"), TEXT("APotion"), false, nullptr, nullptr, nullptr); DEFINE_VTABLE_PTR_HELPER_CTOR(APotion); PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
[ "hansu1115@gmail.com" ]
hansu1115@gmail.com
6cb60d2bb5a093698ab9f7a11ced4798248340ce
b2044fd674883b0de63803fff5183d7ce79bcb88
/src/parsers/parser/parser.cc
819e7c242bba024d2d96757e434e604b54acfd34
[ "Apache-2.0" ]
permissive
JackLiar/moloch-parser-plugin
c75d029563a62e37ad9a99d14f9f7714c059750b
d57336f836ade8507440b37f20d0dbd1e3dedac5
refs/heads/master
2020-07-28T04:10:24.998505
2019-11-26T11:41:22
2019-11-26T11:41:22
209,305,004
0
0
null
null
null
null
UTF-8
C++
false
false
57
cc
#include "parsers/parser.h" void moloch_parser_init() {}
[ "" ]
e8a0608d0ba8e590f5a0dd1e5bd78d616521cc9a
70c858b6e818600331bc5f499ece8dc240c76d4a
/Source Code/ARGO/src/AchievementScreen.cpp
1ab13cc9b27030a27a3ae4293630eb111603a8e5
[]
no_license
SeanAbnerNash/SwarmGame
7e72d5b0482c72e456a6cb60ba718c86c0b7c759
c6b164a0f9a0feb9ece5193701e453950a0430a2
refs/heads/master
2023-01-28T18:30:57.469133
2020-12-09T16:01:48
2020-12-09T16:01:48
320,007,264
0
0
null
null
null
null
UTF-8
C++
false
false
10,994
cpp
#include "stdafx.h" #include "AchievementScreen.h" #include "..\include\AchievementScreen.h" AchievementScreen::AchievementScreen(EventManager& t_eventManager, CommandSystem& t_commandSystem, InputSystem& t_inputSystem, RenderSystem& t_renderSystem) : m_eventManager{ t_eventManager }, m_commandSystem{ t_commandSystem }, m_inputSystem{ t_inputSystem }, m_renderSystem{ t_renderSystem } { } AchievementScreen::~AchievementScreen() { } void AchievementScreen::update(float t_deltaTime) { m_inputSystem.update(m_inputEntity); m_commandSystem.update(m_inputEntity, m_eventManager, t_deltaTime); } void AchievementScreen::render(SDL_Renderer* t_renderer) { m_renderSystem.render(t_renderer, m_background); for (int index = 0; index < NUMBER_OF_ACHIEVEMENTS; index++) { m_renderSystem.render(t_renderer, m_checkboxes[static_cast<int>(CheckBoxParts::Box)][index]); if (m_hasAchievements[index]) { m_renderSystem.render(t_renderer, m_checkboxes[static_cast<int>(CheckBoxParts::Check)][index]); } } for (int index = 0; index < NUMBER_OF_ACHV_PARTS; index++) { for (int index2 = 0; index2 < NUMBER_OF_ACHIEVEMENTS; index2++) { m_renderSystem.render(t_renderer, m_achievementBoxes[index][index2]); } } } void AchievementScreen::reset() { checkStats(); m_screenActive = true; m_renderSystem.setFocus(glm::vec2(Utilities::SCREEN_WIDTH / 2.0f, Utilities::SCREEN_HEIGHT / 2.0f)); } void AchievementScreen::initialise(SDL_Renderer* t_renderer, Controller& t_controller) { for (bool& hasAchievement : m_hasAchievements) { hasAchievement = false; } checkStats(); m_hiddenAchvString = "Win 10 Games and Kill 1000 Enemies"; setControllerButtonMaps(); m_screenActive = true; createBackground(t_renderer); createInputEntity(t_controller); createAchievementEntities(t_renderer); createCheckBoxEntities(t_renderer); m_renderSystem.setFocus(glm::vec2(Utilities::SCREEN_WIDTH / 2.0f, Utilities::SCREEN_HEIGHT / 2.0f)); m_eventManager.subscribeToEvent<UpdateAchievement>(std::bind(&AchievementScreen::updateAchievement, this, std::placeholders::_1)); m_eventManager.subscribeToEvent<MenuButtonPressed>(std::bind(&AchievementScreen::buttonPressed, this, std::placeholders::_1)); } void AchievementScreen::setControllerButtonMaps() { using ButtonCommandPair = std::pair<ButtonType, Command*>; m_controllerButtonMaps[static_cast<int>(ButtonState::Pressed)] = { ButtonCommandPair(ButtonType::B, new MenuCancelCommand()), }; m_controllerButtonMaps[static_cast<int>(ButtonState::Held)]; m_controllerButtonMaps[static_cast<int>(ButtonState::Released)]; } void AchievementScreen::createBackground(SDL_Renderer* t_renderer) { m_background.addComponent(new VisualComponent("Menu_Background.png", t_renderer)); m_background.addComponent(new TransformComponent(0, 0)); } void AchievementScreen::createInputEntity(Controller& t_controller) { m_inputEntity.addComponent(new InputComponent(t_controller, m_controllerButtonMaps[static_cast<int>(ButtonState::Pressed)], m_controllerButtonMaps[static_cast<int>(ButtonState::Held)], m_controllerButtonMaps[static_cast<int>(ButtonState::Released)])); m_inputEntity.addComponent(new CommandComponent()); } void AchievementScreen::createAchievementEntities(SDL_Renderer* t_renderer) { std::string AchievmentStrings[NUMBER_OF_ACHIEVEMENTS][2] { {"Win a Game","The First Step"}, {"Kill 50 Enemies","All Those Poor Defenseless Aliens"}, {"??????????","Surpassing The Endless Horde"} }; for (int index = 0; index < NUMBER_OF_ACHV_PARTS; index++) { m_achievementBoxes[static_cast<int>(AchievmentParts::Box)][index].addComponent(new VisualComponent((index == NUMBER_OF_ACHV_PARTS - 1) ? "AchvBoxHidden.png" : "AchvBox.png", t_renderer)); m_achievementBoxes[static_cast<int>(AchievmentParts::Box)][index].addComponent(new TransformComponent(glm::vec2(Utilities::SCREEN_WIDTH * (1 / 20.0f), Utilities::SCREEN_HEIGHT / 4.0f * (index + 1)))); VisualComponent* boxVisual = static_cast<VisualComponent*>(m_achievementBoxes[static_cast<int>(AchievmentParts::Box)][index].getComponent(ComponentType::Visual)); glm::vec2 boxSize = glm::vec2(boxVisual->getWidth(), boxVisual->getHeight()); glm::vec2 boxPos = static_cast<TransformComponent*>(m_achievementBoxes[static_cast<int>(AchievmentParts::Box)][index].getComponent(ComponentType::Transform))->getPos(); m_achievementBoxes[static_cast<int>(AchievmentParts::MainText)][index].addComponent(new TextComponent("ariblk.ttf", t_renderer, Utilities::MEDIUM_FONT, true, (index == NUMBER_OF_ACHV_PARTS - 1 && m_showHiddenAchv) ? m_hiddenAchvString : AchievmentStrings[index][0], Utilities::UI_COLOUR.x, Utilities::UI_COLOUR.y, Utilities::UI_COLOUR.z)); TextComponent* mainTextComp = static_cast<TextComponent*>(m_achievementBoxes[static_cast<int>(AchievmentParts::MainText)][index].getComponent(ComponentType::Text)); glm::vec2 mainTextSize = glm::vec2(mainTextComp->getWidth(), mainTextComp->getHeight()); m_achievementBoxes[static_cast<int>(AchievmentParts::MainText)][index].addComponent(new TransformComponent(glm::vec2(boxPos.x + (boxSize.x / 40.0f), boxPos.y + (boxSize.y / 3.0f) - mainTextSize.y / 2.0f))); m_achievementBoxes[static_cast<int>(AchievmentParts::SubText)][index].addComponent(new TextComponent("ariblk.ttf", t_renderer, Utilities::SMALL_FONT, true, AchievmentStrings[index][1], 0, 0, 0)); TextComponent* subTextComp = static_cast<TextComponent*>(m_achievementBoxes[static_cast<int>(AchievmentParts::SubText)][index].getComponent(ComponentType::Text)); glm::vec2 subTextSize = glm::vec2(subTextComp->getWidth(), subTextComp->getHeight()); m_achievementBoxes[static_cast<int>(AchievmentParts::SubText)][index].addComponent(new TransformComponent(glm::vec2(boxPos.x + (boxSize.x / 40.0f), boxPos.y + (boxSize.y * 2.0f / 3.0f) - subTextSize.y / 2.0f))); } } void AchievementScreen::createCheckBoxEntities(SDL_Renderer* t_renderer) { for (int index = 0; index < NUMBER_OF_ACHIEVEMENTS; index++) { m_checkboxes[static_cast<int>(CheckBoxParts::Box)][index].addComponent(new VisualComponent("Checkbox.png", t_renderer)); m_checkboxes[static_cast<int>(CheckBoxParts::Box)][index].addComponent(new TransformComponent(glm::vec2(Utilities::SCREEN_WIDTH * (5.0f / 6.0f), Utilities::SCREEN_HEIGHT / 4.0f * (index + 1)))); VisualComponent* boxVisual = static_cast<VisualComponent*>(m_checkboxes[static_cast<int>(CheckBoxParts::Box)][index].getComponent(ComponentType::Visual)); glm::vec2 boxSize = glm::vec2(boxVisual->getWidth(), boxVisual->getHeight()); glm::vec2 boxPos = static_cast<TransformComponent*>(m_checkboxes[static_cast<int>(CheckBoxParts::Box)][index].getComponent(ComponentType::Transform))->getPos(); m_checkboxes[static_cast<int>(CheckBoxParts::Check)][index].addComponent(new VisualComponent("CheckMark.png", t_renderer)); VisualComponent* checkVisual = static_cast<VisualComponent*>(m_checkboxes[static_cast<int>(CheckBoxParts::Check)][index].getComponent(ComponentType::Visual)); glm::vec2 checkSize = glm::vec2(checkVisual->getWidth(), checkVisual->getHeight()); m_checkboxes[static_cast<int>(CheckBoxParts::Check)][index].addComponent(new TransformComponent(boxPos + boxSize / 2.0f - checkSize / 2.0f)); } } void AchievementScreen::buttonPressed(const MenuButtonPressed& t_event) { if (m_screenActive && ButtonType::B == t_event.buttonPressed) { m_screenActive = false; m_eventManager.emitEvent<ChangeScreen>(ChangeScreen{ MenuStates::MainMenu }); } } void AchievementScreen::updateAchievement(const UpdateAchievement& t_event) { std::string fullPath = SDL_GetBasePath(); // get it to point at assets folder inside argo folder if (fullPath.find("\Debug") != std::string::npos) { fullPath.replace(fullPath.find("\Debug"), std::string("\Debug").length(), "\ARGO"); } else if (fullPath.find("\Release") != std::string::npos) { fullPath.replace(fullPath.find("\Release"), std::string("\Release").length(), "\ARGO"); } fullPath.append(Utilities::FILES_PATH + "achievements.txt"); std::ifstream achievementsFileRead; achievementsFileRead.open(fullPath); std::string lineContents; int gamesWonValue = 0; int enemiesKilled = 0; if (achievementsFileRead.is_open()) { while (std::getline(achievementsFileRead, lineContents)) { if (lineContents.find("GamesWon:") != std::string::npos) { gamesWonValue = std::stoi(lineContents.substr(lineContents.find(":") + 1)); } if (lineContents.find("EnemiesKilled:") != std::string::npos) { enemiesKilled = std::stoi(lineContents.substr(lineContents.find(":") + 1)); } } } enemiesKilled += t_event.enemiesKilled; gamesWonValue += t_event.gamesWon; achievementsFileRead.close(); std::ofstream achievementsFileWrite; achievementsFileWrite.open(fullPath); achievementsFileWrite.clear(); achievementsFileWrite << "GamesWon:" + std::to_string(gamesWonValue) + "\n"; achievementsFileWrite << "EnemiesKilled:" + std::to_string(enemiesKilled); achievementsFileWrite.close(); handleAchievements(enemiesKilled, gamesWonValue); } void AchievementScreen::handleAchievements(int t_enemiesKilled, int t_gamesWon) { if (!m_hasAchievements[static_cast<int>(AchievmentsType::EnemiesKilled)]) { if (t_enemiesKilled >= 50) { m_hasAchievements[static_cast<int>(AchievmentsType::EnemiesKilled)] = true; Utilities::Achievements::numberOfUnlockedAchv++; } } if (!m_hasAchievements[static_cast<int>(AchievmentsType::GameWon)]) { if (t_gamesWon > 0) { m_hasAchievements[static_cast<int>(AchievmentsType::GameWon)] = true; Utilities::Achievements::numberOfUnlockedAchv++; } } if (!m_hasAchievements[static_cast<int>(AchievmentsType::Hidden)]) { if (t_enemiesKilled >= 1000 && t_gamesWon >= 10) { m_hasAchievements[static_cast<int>(AchievmentsType::Hidden)] = true; Utilities::Achievements::numberOfUnlockedAchv++; } } } void AchievementScreen::checkStats() { std::string fullPath = SDL_GetBasePath(); // get it to point at assets folder inside argo folder if (fullPath.find("\Debug") != std::string::npos) { fullPath.replace(fullPath.find("\Debug"), std::string("\Debug").length(), "\ARGO"); } else if (fullPath.find("\Release") != std::string::npos) { fullPath.replace(fullPath.find("\Release"), std::string("\Release").length(), "\ARGO"); } fullPath.append(Utilities::FILES_PATH + "achievements.txt"); std::ifstream achievementsFileRead; achievementsFileRead.open(fullPath); std::string lineContents; int gamesWonValue = 0; int enemiesKilled = 0; if (achievementsFileRead.is_open()) { while (std::getline(achievementsFileRead, lineContents)) { if (lineContents.find("GamesWon:") != std::string::npos) { gamesWonValue = std::stoi(lineContents.substr(lineContents.find(":") + 1)); } if (lineContents.find("EnemiesKilled:") != std::string::npos) { enemiesKilled = std::stoi(lineContents.substr(lineContents.find(":") + 1)); } } } handleAchievements(enemiesKilled, gamesWonValue); }
[ "c00217019@itcarlow.ie" ]
c00217019@itcarlow.ie
5ccc4e91b4213a66d76b1ef2e4479fa5224e63ff
c0b3f99438378b259bd5f427451d41bf7fb09a68
/main.cpp
0ebc55de54aa1064f58edbe183a94d7923ce20de
[]
no_license
baoxuanqiu/Comparison-of-sorting-algorithms
c03966c9719b01d5c9c000557a0cbc50be1b930e
6a7587c70bd5358b472c4f44c899ae426d87b995
refs/heads/main
2023-03-08T17:55:51.132305
2021-02-23T10:31:04
2021-02-23T10:31:04
341,506,065
0
0
null
null
null
null
GB18030
C++
false
false
984
cpp
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<stdbool.h> extern void BIS(); extern void Shell(); extern void Bubble(); extern void Quick(); extern void Heap(); extern void Merge(); extern int write_file1(); int g_n; int g_r[10000]; clock_t start,stop; double duration; bool test(int *r){ bool flag=true; for(int i=0;i<g_n-1;i++){ if(r[i]>r[i+1]){ flag=false; break; } } return flag; } int main() { srand(time(NULL)); printf("请输入你要排序的数值的数量"); scanf("%d",&g_n); for(int i=0;i<g_n;i++){ int x=rand(); int y=rand(); int z=x*y; while(z<20000){ x=rand(); y=rand(); z=x*y; } g_r[i]=z; } write_file1(); BIS();//折半插入排序 Shell();//希尔排序 Bubble();//冒泡排序 Quick();//快速排序 Heap();//堆排序 Merge();//归并排序 return 0; }
[ "957272844@qq.com" ]
957272844@qq.com
2cb2e6aa02a3031f6864e2c2a1cef6ea0dd9fe26
f634727735d721c0198ab136d3bda6e9fa8a17c9
/src/rf/util/Log.hpp
2eb5c89d2937bc0f3620f2e710e5a889ccbba99e
[]
no_license
lowquark/cavedoggorl
435ab12fe90eaaf1c81d418764e401bb0d445cd4
449b923bc74725581418ba3be8d0acf587762a9b
refs/heads/master
2021-01-22T16:10:32.778237
2017-09-20T17:37:20
2017-09-20T17:37:20
102,391,524
2
0
null
null
null
null
UTF-8
C++
false
false
3,869
hpp
#ifndef RF_UTIL_LOG_HPP #define RF_UTIL_LOG_HPP #include <cstdio> #include <cstdarg> #include <ctime> namespace rf { class Log { public: Log() : file(stdout) {} Log(FILE * f) : file(f) {} virtual ~Log() = default; void get_timestr(char (*str)[10]) { time_t t = time(NULL); struct tm time_val; localtime_r(&t, &time_val); strftime(*str, 10, "%H:%M:%S ", &time_val); } virtual void logvf(const char * fmt, va_list args) { char timestr[10]; get_timestr(&timestr); fputs(timestr, file); vfprintf(file, fmt, args); fputs("\n", file); } virtual void logf(const char * fmt, ...) { va_list args; va_start(args, fmt); logvf(fmt, args); va_end(args); } virtual void log(const char * str) { char timestr[10]; get_timestr(&timestr); fputs(timestr, file); fputs(str, file); fputs("\n", file); } virtual void warnvf(const char * fmt, va_list args) { char timestr[10]; get_timestr(&timestr); fputs("\x1b[33m", file); fputs(timestr, file); fputs("\x1b[33;1mWARNING:\x1b[0;33m ", file); vfprintf(file, fmt, args); fputs("\x1b[0m\n", file); } virtual void warnf(const char * fmt, ...) { va_list args; va_start(args, fmt); warnvf(fmt, args); va_end(args); } virtual void warn(const char * str) { char timestr[10]; get_timestr(&timestr); fputs("\x1b[33m", file); fputs(timestr, file); fputs("\x1b[33;1mWARNING:\x1b[0;33m ", file); fputs(str, file); fputs("\x1b[0m\n", file); } void flush() { fflush(file); } protected: FILE * file; }; class LogTopic : public Log { public: LogTopic(const char * topic) : Log(stdout), topic(topic) {} LogTopic(const char * topic, FILE * f) : Log(f), topic(topic) {} virtual void logvf(const char * fmt, va_list args) { char timestr[10]; get_timestr(&timestr); fputs(timestr, file); fputs("[", file); fputs(topic, file); fputs("] ", file); vfprintf(file, fmt, args); fputs("\n", file); } virtual void logf(const char * fmt, ...) { va_list args; va_start(args, fmt); logvf(fmt, args); va_end(args); } virtual void log(const char * str) { char timestr[10]; get_timestr(&timestr); fputs(timestr, file); fputs("[", file); fputs(topic, file); fputs("] ", file); fputs(str, file); fputs("\n", file); } virtual void warnvf(const char * fmt, va_list args) { char timestr[10]; get_timestr(&timestr); fputs("\x1b[33m", file); fputs(timestr, file); fputs("[", file); fputs(topic, file); fputs("] \x1b[33;1mWARNING:\x1b[0;33m ", file); vfprintf(file, fmt, args); fputs("\x1b[0m\n", file); } virtual void warnf(const char * fmt, ...) { va_list args; va_start(args, fmt); warnvf(fmt, args); va_end(args); } virtual void warn(const char * str) { char timestr[10]; get_timestr(&timestr); fputs("\x1b[33m", file); fputs(timestr, file); fputs("[", file); fputs(topic, file); fputs("] \x1b[33;1mWARNING:\x1b[0;33m ", file); fputs(str, file); fputs("\x1b[0m\n", file); } private: const char * topic; }; LogTopic & logtopic(const char * topic); void logf(const char * fmt, ...); void log(const char * str); void warnf(const char * fmt, ...); void warn(const char * str); } /* rf::warn("hi"); rf::log("hi"); rf::warnf("hi %d", 5); rf::logf("hi %d", 5); rf::logtopic("topic!").log("hi"); rf::logtopic("topic!").warn("hi"); rf::logtopic("topic!").logf("hi %d", 5); rf::logtopic("topic!").warnf("hi %d", 5); */ #endif
[ "dpetrizze@gmail.com" ]
dpetrizze@gmail.com
2adf4d5b2a53984e6f47113476bf92819cfdc05f
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/components/policy/test_support/remote_commands_state.cc
34f9bae61c420b9b18d435c95a98e01d6b513754
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
2,164
cc
// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/policy/test_support/remote_commands_state.h" #include "components/policy/proto/device_management_backend.pb.h" namespace em = enterprise_management; namespace policy { RemoteCommandsState::RemoteCommandsState() : observer_list_( base::MakeRefCounted<base::ObserverListThreadSafe<Observer>>()) { ResetState(); } RemoteCommandsState::~RemoteCommandsState() = default; void RemoteCommandsState::AddObserver(Observer* observer) { base::AutoLock lock(lock_); observer_list_->AddObserver(observer); } void RemoteCommandsState::RemoveObserver(Observer* observer) { base::AutoLock lock(lock_); observer_list_->RemoveObserver(observer); } void RemoteCommandsState::ResetState() { base::AutoLock lock(lock_); command_results_.clear(); pending_commands_.clear(); } void RemoteCommandsState::AddPendingRemoteCommand( const em::RemoteCommand& command) { base::AutoLock lock(lock_); pending_commands_.push_back(command); } void RemoteCommandsState::AddRemoteCommandResult( const em::RemoteCommandResult& result) { base::AutoLock lock(lock_); command_results_[result.command_id()] = result; observer_list_->Notify( FROM_HERE, &RemoteCommandsState::Observer::OnRemoteCommandResultAvailable, result.command_id()); } std::vector<em::RemoteCommand> RemoteCommandsState::ExtractPendingRemoteCommands() { base::AutoLock lock(lock_); std::vector<em::RemoteCommand> pending_commands_tmp( std::move(pending_commands_)); pending_commands_.clear(); return pending_commands_tmp; } bool RemoteCommandsState::GetRemoteCommandResult( int64_t id, em::RemoteCommandResult* result) { base::AutoLock lock(lock_); if (command_results_.count(id) == 0) { return false; } *result = command_results_.at(id); return true; } bool RemoteCommandsState::IsRemoteCommandResultAvailable(int64_t id) { base::AutoLock lock(lock_); if (command_results_.count(id) == 0) { return false; } return true; } } // namespace policy
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
b616322b12bf50e7c15531b32dbdc82921923943
644398337f359cabfb3d19acbb6e901558852bda
/cyckicQuadri.cpp
aec9e31258ea33f193ef91c7c57bbc6a9c5100fa
[]
no_license
Sriramkk123/Codechef-GFG
c4d46dbb66d0c6c661a3ecef49d1890b0f8e83ed
6eefdff628aed0f15d3f6a34228df3a26f6306dc
refs/heads/master
2023-06-25T05:50:19.117266
2021-07-22T09:28:07
2021-07-22T09:28:07
365,255,187
0
0
null
null
null
null
UTF-8
C++
false
false
246
cpp
#include <bits/stdc++.h> using namespace std; void solve() { int a, b, c, d; cin >> a >> b >> c >> d; if (a + c == 180) cout << "YES\n"; else cout << "NO\n"; } int main() { int t = 1; cin >> t; while (t--) solve(); return 0; }
[ "sriramkk999@gmail.com" ]
sriramkk999@gmail.com
576ad44c4bd453f733c659687551fdb593c3e618
ecc17788f3a3303a8be47fb577587d5ed4a82706
/SDLEntity.cpp
381815a96af01d04544b96b5203148c3ef621c65
[]
no_license
wartek69/pacman
796d92a3c17c2e97ddb0564f7dfcc7de81f189b2
9c50c05cd1b9367963d0b0484f19d7d91f323047
refs/heads/master
2020-04-07T09:08:13.162196
2019-04-08T17:52:27
2019-04-08T17:52:27
124,198,950
1
0
null
2018-03-26T13:02:43
2018-03-07T07:47:56
C++
UTF-8
C++
false
false
1,226
cpp
/* * SDLEntity.cpp * * Created on: 1 mrt. 2018 * Author: Alex */ #include "SDLEntity.h" #include <SDL2\SDL.h> #include <iostream> #include "Types.h" using namespace std; namespace SDL { Size SDLEntity::tileDimensions = {}; SDLEntity::SDLEntity(Config::Data data, SDL_Renderer* gRenderer, SDL_Texture* spriteSheet) { this-> data = data; //gets the coordinates to get the right sprite from the spritesheet SDL_Rect clip ; clip.x = data.getData(0).x; clip.y = data.getData(0).y; clip.w = data.getData(0).w; clip.h = data.getData(0).h; //TODO ?? SDLX = 200; SDLY = 200; //initializes the renderer and sprite sheet this->gRenderer = gRenderer; this->spriteSheet = spriteSheet; this->currentSprite = clip; } SDLEntity::~SDLEntity() { } void SDLEntity::visualize() { //SDL_RenderSetScale(gRenderer,1.5,1.5); //Set rendering space and render to screen SDL_Rect renderQuad = {SDLX, SDLY, tileDimensions.width, tileDimensions.height}; SDL_RenderCopy(gRenderer, spriteSheet, &currentSprite, &renderQuad); } void SDLEntity::setTileDimensions(int width, int height) { cout << width << " " << height << endl; SDLEntity::tileDimensions.width = width; SDLEntity::tileDimensions.height = height; } }
[ "alextcher@hotmail.com" ]
alextcher@hotmail.com
9f70f617f31fbc00edd7bef4c09e16502b8919c6
378e01aacdf7e01d90aeb7e3e234165dcda4b11a
/zero judge/b965.cpp
69e5a1028eaac7987a464028a5f75d758f69d8f9
[]
no_license
930727fre/cpp_repo
bbe62ab49d51ad81bca4890137be67301a5ca8df
8790f800111186d7dec53d7aed8d11a5cb7e071a
refs/heads/master
2023-05-06T11:08:33.686797
2021-05-31T11:48:01
2021-05-31T11:48:01
null
0
0
null
null
null
null
BIG5
C++
false
false
821
cpp
#include <iostream> #include <cstdlib> using namespace std; void rotate(void); void turn(void);void check(void); int j,k,temp,vec[10][10],vec2[10[10]]; int r,c,m,tokenm; int main(void) {while(scanf("%d%d%d",&r,&c,&m)!=EOF){ for(j=0;j<r;j++){ for(k=0;k<c;k++){ cin>>vec[j][k]; } } int yp; for(tokenm=0;tokenm<m;tokenm++){ cout<<"input陣列後面的判斷數字"; cin>>yp; if(yp==0){ rotate(); } else if (yp==1){ turn(); } else {cout<<"error 這裡1"; } } r=0;c=0;m=0;tokenm=0;yp=0; } cout<<j+1<<k+1; system("pause"); return 0; } void rotate(void){ cout<<"rotate() start"<<"\n"; int x,y; for(x=0;x<j;x++){ for(x=0;x<k;x++){ [x+2][]=vec[] } } temp=j; /* j k要互換*/ j=k; k=temp; } void turn(void){ cout<<"turn() start"; } void check(void){/*把vec2處存回vec*/ }
[ "930727fre@gmail.com" ]
930727fre@gmail.com
282ed1c89c36a4c70ab1c4ac33692e442bda5ae3
b7717939bbfc0a9e64b0512c6de4fa7f407cf3d7
/Source/Engine/LightObject.cpp
94b97c9ffaa6da6d8e716470f5e6bfff4780fb8c
[]
no_license
Lichtso/Olypsum
691fc388a6202adc3a7b36f27044016e4a1c189b
800bba2db72eda90ced30c488e3551be6baadd7f
refs/heads/master
2021-01-01T22:18:13.090914
2014-07-29T10:59:08
2014-07-29T10:59:08
239,363,863
1
0
null
null
null
null
UTF-8
C++
false
false
19,556
cpp
// // LightObject.cpp // Olypsum // // Created by Alexander Meißner on 20.04.12. // Copyright (c) 2014 Gamefortec. All rights reserved. // #include "Scripting/ScriptManager.h" LightBoxVolume lightBox(btVector3(1, 1, 1)); LightSphereVolume lightSphere(1, 10, 6); LightParabolidVolume lightCone(1, 12, 0); LightParabolidVolume lightParabolid(1, 10, 4); void initLightVolumes() { lightBox.init(); lightSphere.init(); lightCone.init(); lightParabolid.init(); } void LightObject::setPhysicsShape(btCollisionShape* shape) { if(body->getCollisionShape()) delete body->getCollisionShape(); body->setCollisionShape(shape); } LightObject::LightObject() { objectManager.lightObjects.push_back(this); body = new btCollisionObject(); body->setCollisionShape(new btSphereShape(1.0)); body->setUserPointer(this); body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE); objectManager.physicsWorld->addCollisionObject(body, CollisionMask_Light, 0); shadowMap = NULL; color = Color4(1.0); } LightObject::~LightObject() { if(shadowMap) delete shadowMap; } void LightObject::removeClean() { for(int i = 0; i < objectManager.lightObjects.size(); i ++) if(objectManager.lightObjects[i] == this) { objectManager.lightObjects.erase(objectManager.lightObjects.begin()+i); break; } VisualObject::removeClean(); } btTransform LightObject::getTransformation() { return shadowCam.getTransformation(); } float LightObject::getRange() { return shadowCam.farPlane; } bool LightObject::updateShadowMap(bool shadowActive) { if(!shadowActive) { if(shadowMap) deleteShadowMap(); return false; } if(!shadowMap) shadowMap = new ColorBuffer(true, optionsState.cubemapsEnabled && dynamic_cast<PositionalLight*>(this), mainFBO.shadowMapSize, mainFBO.shadowMapSize); shadowCam.use(); objectManager.currentShadowLight = this; return VisualObject::gameTick(); } void LightObject::draw() { currentShaderProgram->setUniformF("lInvRange", 1.0/shadowCam.farPlane); currentShaderProgram->setUniformVec3("lColor", color.getVector()); bool reflection = dynamic_cast<PlaneReflective*>(objectManager.currentReflective); if(currentCam->testInverseNearPlaneHit(static_cast<btDbvtProxy*>(body->getBroadphaseHandle()))) { //PART IN FRUSTUM glDisable(GL_DEPTH_TEST); glFrontFace((reflection) ? GL_CCW : GL_CW); }else{ //ALL IN FRUSTUM glEnable(GL_DEPTH_TEST); glFrontFace((reflection) ? GL_CW : GL_CCW); } GLuint buffersLight[] = { mainFBO.gBuffers[positionDBuffer], mainFBO.gBuffers[normalDBuffer], mainFBO.gBuffers[materialDBuffer], mainFBO.gBuffers[diffuseDBuffer], mainFBO.gBuffers[specularDBuffer] }; mainFBO.renderInBuffers(false, buffersLight, 3, &buffersLight[3], 2); } void LightObject::init(rapidxml::xml_node<xmlUsedCharType>* node, LevelLoader* levelLoader) { BaseObject::init(node, levelLoader); node = node->first_node("Color"); if(!node) { log(error_log, "Tried to construct LightObject without \"Color\"-node."); return; } XMLValueArray<float> vecData; vecData.readString(node->value(), "%f"); color = Color4(vecData.data[0], vecData.data[1], vecData.data[2]); } rapidxml::xml_node<xmlUsedCharType>* LightObject::write(rapidxml::xml_document<xmlUsedCharType>& doc, LevelSaver* levelSaver) { rapidxml::xml_node<xmlUsedCharType>* node = BaseObject::write(doc, levelSaver); node->name("LightObject"); rapidxml::xml_attribute<xmlUsedCharType>* attribute = doc.allocate_attribute(); attribute->name("type"); node->append_attribute(attribute); rapidxml::xml_node<xmlUsedCharType>* colorNode = doc.allocate_node(rapidxml::node_element); colorNode->name("Color"); char buffer[64]; sprintf(buffer, "%f %f %f", color.r, color.g, color.b); colorNode->value(doc.allocate_string(buffer)); node->append_node(colorNode); return node; } void LightObject::deleteShadowMap() { if(shadowMap) delete shadowMap; shadowMap = NULL; } DirectionalLight::DirectionalLight() { shadowCam.nearPlane = 1.0; } DirectionalLight::DirectionalLight(btTransform _transformation, btVector3 bounds) :DirectionalLight() { setTransformation(_transformation); setBounds(bounds); } DirectionalLight::DirectionalLight(rapidxml::xml_node<xmlUsedCharType>* node, LevelLoader* levelLoader) :DirectionalLight() { rapidxml::xml_node<xmlUsedCharType>* bounds = node->first_node("Bounds"); if(!node) { log(error_log, "Tried to construct DirectionalLight without \"Bounds\"-node."); return; } XMLValueArray<float> vecData; vecData.readString(bounds->value(), "%f"); setBounds(vecData.getVector3()); LightObject::init(node, levelLoader); ScriptInstance(DirectionalLight); } void DirectionalLight::setTransformation(const btTransform& transformation) { shadowCam.setTransformation(transformation); btTransform shiftMat; shiftMat.setIdentity(); shiftMat.setOrigin(btVector3(0, 0, -shadowCam.farPlane*0.5)); body->setWorldTransform(transformation * shiftMat); } void DirectionalLight::setBounds(const btVector3& bounds) { shadowCam.fov = -bounds.y(); shadowCam.aspect = bounds.x()/bounds.y(); shadowCam.farPlane = bounds.z(); shadowCam.nearPlane = bounds.z()*0.01; setPhysicsShape(new btBoxShape(btVector3(bounds.x(), bounds.y(), bounds.z()*0.5))); } btVector3 DirectionalLight::getBounds() { return btVector3(-shadowCam.fov*shadowCam.aspect, -shadowCam.fov, shadowCam.farPlane); } bool DirectionalLight::updateShadowMap(bool shadowActive) { shadowCam.updateViewMat(); if(!LightObject::updateShadowMap(shadowActive)) return true; objectManager.currentShadowIsParabolid = false; mainFBO.renderInTexture(shadowMap, GL_TEXTURE_2D); objectManager.drawShadowCasters(); return true; } void DirectionalLight::draw() { modelMat.setIdentity(); modelMat.setBasis(modelMat.getBasis().scaled(btVector3(-shadowCam.fov*shadowCam.aspect, -shadowCam.fov, shadowCam.farPlane*0.5))); modelMat.setOrigin(btVector3(0.0, 0.0, -shadowCam.farPlane*0.5)); modelMat = shadowCam.getTransformation()*modelMat; if(shadowMap) { shaderPrograms[directionalShadowLightSP]->use(); Matrix4 shadowMat = shadowCam.viewMat; shadowMat.makeTextureMat(); currentShaderProgram->setUniformMatrix4("lShadowMat", &shadowMat); shadowMap->use(3); }else shaderPrograms[directionalLightSP]->use(); currentShaderProgram->setUniformVec3("lDirection", shadowCam.getTransformation().getBasis().getColumn(2)); LightObject::draw(); lightBox.draw(); } float DirectionalLight::getPriority(const btVector3& position) { return 2.0; } rapidxml::xml_node<xmlUsedCharType>* DirectionalLight::write(rapidxml::xml_document<xmlUsedCharType>& doc, LevelSaver* levelSaver) { rapidxml::xml_node<xmlUsedCharType>* node = LightObject::write(doc, levelSaver); node->first_attribute("type")->value("directional"); rapidxml::xml_node<xmlUsedCharType>* boundsNode = doc.allocate_node(rapidxml::node_element); boundsNode->name("Bounds"); char buffer[64]; sprintf(buffer, "%f %f %f", -shadowCam.fov*shadowCam.aspect, -shadowCam.fov, shadowCam.farPlane); boundsNode->value(doc.allocate_string(buffer)); node->append_node(boundsNode); return node; } PositionalLight::PositionalLight() :shadowMapB(NULL) { shadowCam.nearPlane = 0.1; } PositionalLight::PositionalLight(btTransform _transformation, bool omniDirectional, float range) :PositionalLight() { setTransformation(_transformation); setBounds(omniDirectional, range); } PositionalLight::PositionalLight(rapidxml::xml_node<xmlUsedCharType>* node, LevelLoader* levelLoader) :PositionalLight() { rapidxml::xml_node<xmlUsedCharType>* bounds = node->first_node("Bounds"); if(!node) { log(error_log, "Tried to construct PositionalLight without \"Bounds\"-node."); return; } rapidxml::xml_attribute<xmlUsedCharType>* attribute = bounds->first_attribute("range"); if(!attribute) { log(error_log, "Tried to construct PositionalLight without \"range\"-attribute."); return; } float range; sscanf(attribute->value(), "%f", &range); attribute = bounds->first_attribute("omniDirectional"); if(!attribute) { log(error_log, "Tried to construct PositionalLight without \"omniDirectional\"-attribute."); return; } setBounds(strcmp(attribute->value(), "true") == 0, range); LightObject::init(node, levelLoader); ScriptInstance(PositionalLight); } PositionalLight::~PositionalLight() { if(shadowMapB) delete shadowMapB; } void PositionalLight::setTransformation(const btTransform& transformation) { shadowCam.setTransformation(transformation); if(getOmniDirectional()) body->setWorldTransform(transformation); else{ btTransform shiftMat; shiftMat.setIdentity(); shiftMat.setOrigin(btVector3(0, 0, -shadowCam.farPlane*0.5)); body->setWorldTransform(transformation * shiftMat); } } void PositionalLight::setBounds(bool omniDirectional, float range) { shadowCam.fov = (omniDirectional) ? M_PI*2.0 : M_PI; shadowCam.farPlane = range; if(omniDirectional) setPhysicsShape(new btSphereShape(range)); else setPhysicsShape(new btCylinderShape(btVector3(range, range, range*0.5))); } bool PositionalLight::getOmniDirectional() { return abs(shadowCam.fov-M_PI*2.0) < 0.001; } bool PositionalLight::updateShadowMap(bool shadowActive) { if(!LightObject::updateShadowMap(shadowActive)) return true; shadowCam.updateViewMat(); Matrix4 viewMat = shadowCam.viewMat; if(optionsState.cubemapsEnabled) { objectManager.currentShadowIsParabolid = false; float fov = shadowCam.fov; shadowCam.fov = M_PI_2; btTransform camMat = shadowCam.getTransformation(); for(GLenum side = GL_TEXTURE_CUBE_MAP_POSITIVE_X; side <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; side ++) { btQuaternion rotation; switch(side) { case GL_TEXTURE_CUBE_MAP_POSITIVE_X: rotation.setEulerZYX(M_PI, M_PI_2, 0.0); break; case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: rotation.setEulerZYX(M_PI, -M_PI_2, 0.0); break; case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: rotation.setEulerZYX(0.0, 0.0, M_PI_2); break; case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: rotation.setEulerZYX(0.0, 0.0, -M_PI_2); break; case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: rotation.setEulerZYX(M_PI, M_PI, 0.0); break; case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: rotation.setEulerZYX(M_PI, 0.0, 0.0); break; } btTransform rotTransform = btTransform::getIdentity(); rotTransform.setRotation(rotation); shadowCam.setTransformation(camMat * rotTransform); shadowCam.updateViewMat(); mainFBO.renderInTexture(shadowMap, side); objectManager.drawShadowCasters(); } shadowCam.setTransformation(camMat); shadowCam.viewMat = viewMat; shadowCam.fov = fov; }else{ if(getOmniDirectional() && !shadowMapB) shadowMapB = new ColorBuffer(true, false, mainFBO.shadowMapSize, mainFBO.shadowMapSize); glEnable(GL_CLIP_DISTANCE0); objectManager.currentShadowIsParabolid = true; shaderPrograms[solidParabolidShadowSP]->use(); shaderPrograms[solidParabolidShadowSP]->setUniformF("lRange", shadowCam.farPlane); shaderPrograms[skeletalParabolidShadowSP]->use(); shaderPrograms[skeletalParabolidShadowSP]->setUniformF("lRange", shadowCam.farPlane); mainFBO.renderInTexture(shadowMap, GL_TEXTURE_2D); objectManager.drawShadowCasters(); if(shadowMapB) { shadowCam.viewMat.scale(btVector3(-1.0, 1.0, -1.0)); mainFBO.renderInTexture(shadowMapB, GL_TEXTURE_2D); objectManager.drawShadowCasters(); shadowCam.viewMat = viewMat; } glDisable(GL_CLIP_DISTANCE0); } return true; } void PositionalLight::draw() { modelMat.setIdentity(); btMatrix3x3 basis(btQuaternion(btVector3(0.0, 1.0, 0.0), M_PI)); modelMat.setBasis(basis.scaled(btVector3(shadowCam.farPlane*1.05, shadowCam.farPlane*1.05, shadowCam.farPlane*1.05))); modelMat = shadowCam.getTransformation()*modelMat; if(shadowMap) { shadowMap->use(3); if(shadowMapB) { shadowMapB->use(4); shaderPrograms[positionalShadowDualLightSP]->use(); }else shaderPrograms[positionalShadowLightSP]->use(); }else shaderPrograms[positionalLightSP]->use(); currentShaderProgram->setUniformMatrix4("lShadowMat", &shadowCam.viewMat); currentShaderProgram->setUniformF("lCutoff", (getOmniDirectional()) ? 1.0 : 0.0); currentShaderProgram->setUniformVec3("lPosition", shadowCam.getTransformation().getOrigin()); currentShaderProgram->setUniformVec3("lDirection", shadowCam.getTransformation().getBasis().getColumn(2)*-1.0); if(optionsState.cubemapsEnabled) currentShaderProgram->setUniformVec2("shadowDepthTransform", (shadowCam.farPlane+shadowCam.nearPlane)/(shadowCam.farPlane-shadowCam.nearPlane)*0.5+0.5, -(shadowCam.farPlane*shadowCam.nearPlane)/(shadowCam.farPlane-shadowCam.nearPlane)*1.005); LightObject::draw(); if(abs(shadowCam.fov-M_PI) < 0.001) lightParabolid.draw(); else lightSphere.draw(); } void PositionalLight::deleteShadowMap() { LightObject::deleteShadowMap(); if(shadowMapB) delete shadowMapB; shadowMapB = NULL; } float PositionalLight::getPriority(const btVector3& position) { return 1.0-(position-shadowCam.getTransformation().getOrigin()).length()/shadowCam.farPlane; } rapidxml::xml_node<xmlUsedCharType>* PositionalLight::write(rapidxml::xml_document<xmlUsedCharType>& doc, LevelSaver* levelSaver) { rapidxml::xml_node<xmlUsedCharType>* node = LightObject::write(doc, levelSaver); node->first_attribute("type")->value("positional"); rapidxml::xml_node<xmlUsedCharType>* boundsNode = doc.allocate_node(rapidxml::node_element); boundsNode->name("Bounds"); node->append_node(boundsNode); rapidxml::xml_attribute<xmlUsedCharType>* attribute = doc.allocate_attribute(); attribute->name("omniDirectional"); if(getOmniDirectional()) attribute->value("true"); else attribute->value("false"); boundsNode->append_attribute(attribute); attribute = doc.allocate_attribute(); attribute->name("range"); attribute->value(doc.allocate_string(stringOf(shadowCam.farPlane).c_str())); boundsNode->append_attribute(attribute); return node; } SpotLight::SpotLight() { shadowCam.nearPlane = 0.1; } SpotLight::SpotLight(btTransform _transformation, float cutoff, float range) :SpotLight() { setTransformation(_transformation); setBounds(cutoff, range); } SpotLight::SpotLight(rapidxml::xml_node<xmlUsedCharType>* node, LevelLoader* levelLoader) :SpotLight() { rapidxml::xml_node<xmlUsedCharType>* bounds = node->first_node("Bounds"); if(!node) { log(error_log, "Tried to construct SpotLight without \"Bounds\"-node."); return; } float cutoff, range; rapidxml::xml_attribute<xmlUsedCharType>* attribute = bounds->first_attribute("range"); if(!attribute) { log(error_log, "Tried to construct SpotLight without \"range\"-attribute."); return; } sscanf(attribute->value(), "%f", &range); attribute = bounds->first_attribute("cutoff"); if(!attribute) { log(error_log, "Tried to construct SpotLight without \"cutoff\"-attribute."); return; } sscanf(attribute->value(), "%f", &cutoff); setBounds(cutoff, range); LightObject::init(node, levelLoader); ScriptInstance(SpotLight); } void SpotLight::setTransformation(const btTransform& transformation) { shadowCam.setTransformation(transformation); btTransform shiftMat; shiftMat.setIdentity(); shiftMat.setOrigin(btVector3(0, 0, -shadowCam.farPlane*0.5)); body->setWorldTransform(transformation * shiftMat); } void SpotLight::setBounds(float cutoff, float range) { shadowCam.fov = cutoff; shadowCam.farPlane = range; setPhysicsShape(new btConeShapeZ(tan(shadowCam.fov*0.5)*shadowCam.farPlane, shadowCam.farPlane)); } float SpotLight::getCutoff() { return shadowCam.fov*0.5; } bool SpotLight::updateShadowMap(bool shadowActive) { if(!LightObject::updateShadowMap(shadowActive)) return true; objectManager.currentShadowIsParabolid = false; shadowCam.updateViewMat(); mainFBO.renderInTexture(shadowMap, GL_TEXTURE_2D); //Render circle mask shaderPrograms[genCircleMaskSP]->use(); rectVAO.draw(); objectManager.drawShadowCasters(); return true; } void SpotLight::draw() { float radius = tan(shadowCam.fov*0.5)*shadowCam.farPlane; modelMat.setIdentity(); modelMat.setBasis(modelMat.getBasis().scaled(btVector3(radius*1.05, radius*1.05, shadowCam.farPlane))); modelMat.setOrigin(btVector3(0.0, 0.0, -shadowCam.farPlane)); modelMat = shadowCam.getTransformation()*modelMat; if(shadowMap) { shaderPrograms[spotShadowLightSP]->use(); Matrix4 shadowMat = shadowCam.viewMat; shadowMat.makeTextureMat(); currentShaderProgram->setUniformMatrix4("lShadowMat", &shadowMat); shadowMap->use(3); }else shaderPrograms[spotLightSP]->use(); currentShaderProgram->setUniformF("lCutoff", -cos(shadowCam.fov*0.5)); currentShaderProgram->setUniformVec3("lPosition", shadowCam.getTransformation().getOrigin()); currentShaderProgram->setUniformVec3("lDirection", shadowCam.getTransformation().getBasis().getColumn(2)*-1.0); LightObject::draw(); lightCone.draw(); } float SpotLight::getPriority(const btVector3& position) { return 1.0; } rapidxml::xml_node<xmlUsedCharType>* SpotLight::write(rapidxml::xml_document<xmlUsedCharType>& doc, LevelSaver* levelSaver) { rapidxml::xml_node<xmlUsedCharType>* node = LightObject::write(doc, levelSaver); node->first_attribute("type")->value("spot"); rapidxml::xml_node<xmlUsedCharType>* boundsNode = doc.allocate_node(rapidxml::node_element); boundsNode->name("Bounds"); node->append_node(boundsNode); rapidxml::xml_attribute<xmlUsedCharType>* attribute = doc.allocate_attribute(); attribute->name("cutoff"); attribute->value(doc.allocate_string(stringOf(shadowCam.fov).c_str())); boundsNode->append_attribute(attribute); attribute = doc.allocate_attribute(); attribute->name("range"); attribute->value(doc.allocate_string(stringOf(shadowCam.farPlane).c_str())); boundsNode->append_attribute(attribute); return node; }
[ "AlexanderMeissner@gmx.net" ]
AlexanderMeissner@gmx.net
912cc335347830d11a642fed5a2eb7191e21c5b0
d1d7fc2827210f51bd418a59a0244a61a96a1bd5
/LoadPicture/DisplayLUT.h
0bd40e8725eabdc456e1c63cfcc53c4ca2c051d9
[]
no_license
nnnonly/DicomViewer
126cda457f8f4419855dcbd2ab577ddba082e401
de2213037bb50ebc253be75d14033d3acf2eb475
refs/heads/master
2022-12-07T11:21:03.806834
2020-08-27T10:50:29
2020-08-27T10:50:29
290,744,528
0
0
null
null
null
null
UTF-8
C++
false
false
202
h
#pragma once #include "CoreInclude.h" #include "AppDocument.h" #include<string> namespace DisplayLUT { void loadPixel(int windowWidth, int windowCenter, const cv::Mat&img, cv::Mat & outputImage); }
[ "camnhunga4k49@gmail.com" ]
camnhunga4k49@gmail.com
1f456007379cbc3faf979be786a3f02a448f4263
ac21faa74fe324bb84cc71fa1508abeff73e1ebf
/test_sketches/navkeys/navkeys.ino
914712f3e09c0f7f81990fd7783aaf4e0da1cad9
[]
no_license
billieblaze/BBlazeSEQ
ef8dd3c8970808b85daf1de340ec1ee16f8e0181
54966866654b88a0c119d8822e0a8267c66754ae
refs/heads/master
2020-04-05T04:12:21.081964
2013-10-09T02:16:56
2013-10-09T02:16:56
4,207,978
2
1
null
null
null
null
UTF-8
C++
false
false
2,539
ino
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display // shiftout /* How many shift register chips are daisy-chained. */ #define NUMBER_OF_SHIFT_CHIPS 4 /* Width of data (how many ext lines). */ #define DATA_WIDTH NUMBER_OF_SHIFT_CHIPS * 8 /* Width of pulse to trigger the shift register to read and latch. */ #define PULSE_WIDTH_USEC 5 /* Optional delay between shift register reads. */ #define POLL_DELAY_MSEC 1 int ploadPin = 26; // Connects to Parallel load pin the 165 int dataPin = 22; // Connects to the Q7 pin the 165 int clockPin = 24; // Connects to the Clock pin the 165 unsigned int pinValues_1; /* This function is essentially a "shift-in" routine reading the * serial Data from the shift register chips and representing * the state of those pins in an unsigned integer (or long). */ unsigned int read_shift_regs() { byte bitVal; unsigned int bytesVal = 0; /* Trigger a parallel Load to latch the state of the data lines, */ digitalWrite(ploadPin, LOW); delayMicroseconds(PULSE_WIDTH_USEC); digitalWrite(ploadPin, HIGH); /* Loop to read each bit value from the serial out line * of the SN74HC165N. */ for(int i = 0; i < DATA_WIDTH; i++) { bitVal = digitalRead(dataPin); if (i == 0){ lcd.setCursor(0,0); } if (i == 8){ lcd.setCursor(0,1); } if (i == 16){ lcd.setCursor(0,2);} if (i == 24){ lcd.setCursor(0,3);} lcd.print(bitVal); /* Set the corresponding bit in bytesVal. */ bytesVal |= (bitVal << ((DATA_WIDTH-1) - i)); /* Pulse the Clock (rising edge shifts the next bit). */ digitalWrite(clockPin, HIGH); delayMicroseconds(PULSE_WIDTH_USEC); digitalWrite(clockPin, LOW); } lcd.setCursor(10,1); lcd.print(bytesVal); lcd.setCursor(10,2); lcd.print(~bytesVal); return(bytesVal); } void setup() { lcd.init(); // initialize the lcd lcd.backlight(); lcd.clear(); lcd.print("keypad test"); /* Initialize our digital pins... */ pinMode(ploadPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, INPUT); digitalWrite(clockPin, LOW); digitalWrite(ploadPin, HIGH); delay(1500); } void loop() { lcd.clear(); pinValues_1 = read_shift_regs(); delay(500); }
[ "bill@socialcloudz.com" ]
bill@socialcloudz.com
490b681c21c9f715402050ce7139da69849d9f34
2bff140cebbb2ecf1de6714958e85f27950c1245
/Deck.h
cabfc54b48ec80b2c27b13b68c5605401ddc73fa
[]
no_license
PineHub/cat-game
39029645a40c4b8b6e236859f8c43bc867cdc1ed
4903c20941feecb5ec4c9f5e7faa4e15067bf89d
refs/heads/master
2021-06-28T17:14:23.392225
2017-09-18T04:15:46
2017-09-18T04:15:46
103,889,334
0
0
null
null
null
null
UTF-8
C++
false
false
1,236
h
/********************************************************************* ** Program Filename: Deck.h ** Author: Clarence Pine ** Date: 3/15/16 ** Description: Deck class header ** Input: various ** Output: various *********************************************************************/ #ifndef FINAL_DECK_H #define FINAL_DECK_H #include "Space.h" class Deck : public Space { protected: std::string name; std::string description; std::string wantedDance; std::string itemWanted; std::string item; public: Deck(); Deck(std::string string, std::string string1, std::string string2, std::string string3, std::string string4); virtual std::string getName(); virtual std::string getDescription(); virtual void setName(std::string &); virtual void addDestination(Space *); virtual Space *transport(); std::string getCatchange(); virtual void setDescription(std::string); virtual std::string getItem(); virtual bool setItem(std::string); virtual std::string getItemWanted(); virtual std::string ending(); virtual std::string getDanceWanted(); }; #endif //FINAL_DECK_H
[ "pinec@flip2.engr.oregonstate.edu" ]
pinec@flip2.engr.oregonstate.edu
e4fcb8a5eb4b3e0a6641c7d938def4fa4732bba4
64fe4f897f21a075e27b3c05b736b2fd70329e6b
/ConstructBinaryTreeFromPreorderAndInorderTraversal.cpp
2a4abb4eea0b327584c3eba5bd2ff60cc5c67b41
[]
no_license
re3el/LeetCode
ec70383adc0455b7582674aa95695251ce5b5854
82a4ba979cc7cb3d3ddb726a5084a3362d2d6993
refs/heads/master
2023-06-09T15:45:52.804579
2018-01-27T22:07:05
2018-01-27T22:07:05
104,426,137
1
0
null
null
null
null
UTF-8
C++
false
false
1,138
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { int n; public: TreeNode* computeTree(vector<int>& preorder, vector<int>& inorder, int lowP, int lowI, int highI) { if(lowI > highI || lowP == n) return NULL; TreeNode* root = new TreeNode(preorder[lowP]); int cnt = 0; for(int i=lowI; i<highI; i++) { if(inorder[i] == preorder[lowP]) break; cnt++; } root->left = computeTree(preorder,inorder,lowP+1,lowI,lowI+cnt-1); root->right = computeTree(preorder,inorder,lowP+1+cnt,lowI+cnt+1,highI); return root; } TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) { // assuming tree structure to be valid; preorder && inorder size to be same; n = preorder.size(); if(n == 0) return NULL; return computeTree(preorder,inorder,0,0,n-1); } };
[ "re3el@users.noreply.github.com" ]
re3el@users.noreply.github.com
a3bcf9ab964fdbf130879977a22e3e8a32d062e7
fd4d96c3d60039223e5d9f99d8e8b1875f1d0c37
/Gearmo 16/src/Commands/AutoSimple.cpp
e2285320c2173c13e425592056133620d0880583
[]
no_license
Team-931/gearmo-16
89c16cd8dd609b57f323d40918ab080696b395bb
1414e1c28ae58a2eaf1df78172e32b66b97f1a64
refs/heads/master
2021-01-11T16:46:30.882617
2018-02-14T22:05:43
2018-02-14T22:05:43
79,669,745
0
0
null
null
null
null
UTF-8
C++
false
false
422
cpp
#include "AutoSimple.h" #include "Subsystems/SwerveDrive.h" AutoSimple::AutoSimple() { // Use Requires() here to declare subsystem dependencies Requires(swerveDrive); } // Called just before this Command runs the first time void AutoSimple::Initialize() { swerveDrive->Drive(.125, -.25, 0); } // Make this return true when this Command no longer needs to run execute() bool AutoSimple::IsFinished() { return true; }
[ "rharrington.170@gmail.com" ]
rharrington.170@gmail.com
2d53652ab0d27c5207571a7c3033c89e8655c292
801edd06b4712fc76f0458ec9864d629b634f8af
/tic-tac-toe/gmbrd.hpp
4808bead6f2b7986c1b75cfbc39779500caec821
[]
no_license
sunsidi/TicTacToe
9de87b1dc2e0ce923a06fe5678b16410f47a908b
9f620eaedad13234f43bb8bf047a362b2b949270
refs/heads/master
2016-09-14T06:09:52.931398
2016-05-11T15:40:32
2016-05-11T15:40:32
58,556,255
0
0
null
null
null
null
UTF-8
C++
false
false
1,083
hpp
/******************************************************** gmbrd.hpp Class definitions for 10 x 10 board for 5 in-a-row tic-tac-toe *********************************************************/ #ifndef GMBRD_HPP #define GMBRD_HPP #include <string> #include <vector> using namespace std; static const int DIM = 10, //*** DIMENSION OF THE SQUARE BOARD NUMDIAGS = 11; //*** NUMBER OF DIAGONALS IN A GIVEN DIRECTION /**************************************** struct location *****************************************/ struct location { int r, c; }; /**************************************** class board *****************************************/ class board { string brd[DIM]; public: board(char c = ' '); void fillAll(char c); string &operator[](int idx){return brd[idx];} void getRow(int row, string &str); void getCol(int col, string &str); void getDiagRD(int diagIdx, string &str); void getDiagLD(int diagIdx, string &str); int victoryCheck(const string &c1, const string &c2); void getEmptySquares(vector <location> &eSquares, char eVal); }; #endif
[ "ssd0418@163.com" ]
ssd0418@163.com
e7b8011a632dbaa47cea9f429dcd32b0a0868177
ade91e5daa25dc33f03bc991b8bab55a8a87c840
/tensorflow/tsl/profiler/utils/xplane_schema.h
72833792e0e9e95f34c2677b246c04256283ea47
[ "Apache-2.0", "LicenseRef-scancode-generic-cla", "BSD-2-Clause" ]
permissive
penpornk/tensorflow
2df96018ece6a5104b64280fb5e609ea7ee17b5d
dc370aeb6373b3224b112e5e476b339186e6cc45
refs/heads/master
2023-01-27T23:13:00.308224
2023-01-25T19:59:16
2023-01-25T19:59:16
152,667,418
1
2
null
null
null
null
UTF-8
C++
false
false
11,594
h
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_TSL_PROFILER_UTILS_XPLANE_SCHEMA_H_ #define TENSORFLOW_TSL_PROFILER_UTILS_XPLANE_SCHEMA_H_ #include <atomic> #include <cstdint> #include <string> #include "absl/hash/hash.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" #include "tensorflow/tsl/platform/logging.h" #include "tensorflow/tsl/platform/macros.h" #include "tensorflow/tsl/platform/types.h" #include "tensorflow/tsl/profiler/lib/context_types.h" namespace tsl { namespace profiler { // Name of XPlane that contains TraceMe events. TF_CONST_INIT extern const absl::string_view kHostThreadsPlaneName; // Name prefix of XPlane that contains GPU events. TF_CONST_INIT extern const absl::string_view kGpuPlanePrefix; // Name prefix of XPlane that contains TPU events. TF_CONST_INIT extern const absl::string_view kTpuPlanePrefix; // Regex for XPlanes that contain TensorCore planes. TF_CONST_INIT extern const char kTpuPlaneRegex[]; // Name prefix of XPlane that contains custom device events. TF_CONST_INIT extern const absl::string_view kCustomPlanePrefix; // Name prefix of XPlane that contains TPU runtime events. TF_CONST_INIT extern const absl::string_view kTpuRuntimePlaneName; // Name of XPlane that contains CUPTI driver API generated events. TF_CONST_INIT extern const absl::string_view kCuptiDriverApiPlaneName; // Name of XPlane that contains Roctracer API generated events. TF_CONST_INIT extern const absl::string_view kRoctracerApiPlaneName; // Name of XPlane that contains profile metadata such as XLA debug info. TF_CONST_INIT extern const absl::string_view kMetadataPlaneName; // Name of XPlane that contains kpi related metrics. TF_CONST_INIT extern const absl::string_view kTFStreamzPlaneName; // Name of XPlane that contains events from python tracer. TF_CONST_INIT extern const absl::string_view kPythonTracerPlaneName; // Names of XLines that contain ML-level events. TF_CONST_INIT extern const absl::string_view kStepLineName; TF_CONST_INIT extern const absl::string_view kTensorFlowNameScopeLineName; TF_CONST_INIT extern const absl::string_view kTensorFlowOpLineName; TF_CONST_INIT extern const absl::string_view kXlaModuleLineName; TF_CONST_INIT extern const absl::string_view kXlaOpLineName; TF_CONST_INIT extern const absl::string_view kXlaAsyncOpLineName; TF_CONST_INIT extern const absl::string_view kKernelLaunchLineName; TF_CONST_INIT extern const absl::string_view kSourceLineName; // GPU device vendors. TF_CONST_INIT extern const absl::string_view kDeviceVendorNvidia; TF_CONST_INIT extern const absl::string_view kDeviceVendorAMD; // Interesting event types (i.e., TraceMe names). enum HostEventType { kFirstHostEventType = 0, kUnknownHostEventType = kFirstHostEventType, kTraceContext, kSessionRun, kFunctionRun, kRunGraph, kRunGraphDone, kTfOpRun, kEagerKernelExecute, kExecutorStateProcess, kExecutorDoneCallback, kMemoryAllocation, kMemoryDeallocation, // Performance counter related. kRemotePerf, // tf.data captured function events. kTfDataCapturedFunctionRun, kTfDataCapturedFunctionRunWithBorrowedArgs, kTfDataCapturedFunctionRunInstantiated, kTfDataCapturedFunctionRunAsync, // Loop ops. kParallelForOp, kForeverOp, kWhileOpEvalCond, kWhileOpStartBody, kForOp, // tf.data related. kIteratorGetNextOp, kIteratorGetNextAsOptionalOp, kIterator, kDeviceInputPipelineSecondIterator, kPrefetchProduce, kPrefetchConsume, kParallelInterleaveProduce, kParallelInterleaveConsume, kParallelInterleaveInitializedInput, kParallelMapProduce, kParallelMapConsume, kMapAndBatchProduce, kMapAndBatchConsume, kParseExampleProduce, kParseExampleConsume, kParallelBatchProduce, kParallelBatchConsume, // Batching related. kBatchingSessionRun, kProcessBatch, kConcatInputTensors, kMergeInputTensors, kScheduleWithoutSplit, kScheduleWithSplit, kScheduleWithEagerSplit, kASBSQueueSchedule, // TFRT related. kTfrtModelRun, // GPU related. kKernelLaunch, kKernelExecute, // TPU related kEnqueueRequestLocked, kRunProgramRequest, kHostCallbackRequest, kTransferH2DRequest, kTransferPreprocessedH2DRequest, kTransferD2HRequest, kOnDeviceSendRequest, kOnDeviceRecvRequest, kOnDeviceSendRecvLocalRequest, kCustomWait, kOnDeviceSendRequestMulti, kOnDeviceRecvRequestMulti, kPjrtAsyncWait, kDoEnqueueProgram, kDoEnqueueContinuationProgram, kWriteHbm, kReadHbm, kTpuExecuteOp, kCompleteCallbacks, kTransferToDeviceIssueEvent, kTransferToDeviceDone, kTransferFromDeviceIssueEvent, kTransferFromDeviceDone, kTpuSystemExecute, kTpuPartitionedCallOpInitializeVarOnTpu, kTpuPartitionedCallOpExecuteRemote, kTpuPartitionedCallOpExecuteLocal, kLinearize, kDelinearize, kTransferBufferFromDeviceFastPath, kLastHostEventType = kTransferBufferFromDeviceFastPath, }; enum StatType { kFirstStatType = 0, kUnknownStatType = kFirstStatType, // TraceMe arguments. kStepId, kDeviceOrdinal, kChipOrdinal, kNodeOrdinal, kModelId, kQueueId, kQueueAddr, kRequestId, kRunId, kReplicaId, kGraphType, kStepNum, kIterNum, kIndexOnHost, kAllocatorName, kBytesReserved, kBytesAllocated, kBytesAvailable, kFragmentation, kPeakBytesInUse, kRequestedBytes, kAllocationBytes, kAddress, kRegionType, kDataType, kTensorShapes, kTensorLayout, kKpiName, kKpiValue, kElementId, kParentId, // XPlane semantics related. kProducerType, kConsumerType, kProducerId, kConsumerId, kIsRoot, kIsAsync, // Device trace arguments. kDeviceId, kDeviceTypeString, kContextId, kCorrelationId, // TODO(b/176137043): These "details" should differentiate between activity // and API event sources. kMemcpyDetails, kMemallocDetails, kMemFreeDetails, kMemsetDetails, kMemoryResidencyDetails, kNVTXRange, kKernelDetails, kStream, // Stats added when processing traces. kGroupId, kFlow, kStepName, kTfOp, kHloOp, kHloCategory, kHloModule, kProgramId, kEquation, kIsEager, kIsFunc, kTfFunctionCall, kTfFunctionTracingCount, kFlops, kBytesAccessed, kSourceInfo, kModelName, kModelVersion, kBytesTransferred, kDmaQueue, // Performance counter related. kRawValue, kScaledValue, kThreadId, kMatrixUnitUtilizationPercent, // XLA metadata map related. kHloProto, // Device capability related. kDevCapClockRateKHz, kDevCapCoreCount, kDevCapMemoryBandwidth, kDevCapMemorySize, kDevCapComputeCapMajor, kDevCapComputeCapMinor, kDevCapPeakTeraflopsPerSecond, kDevCapPeakHbmBwGigabytesPerSecond, kDevCapPeakSramRdBwGigabytesPerSecond, kDevCapPeakSramWrBwGigabytesPerSecond, kDevVendor, // Batching related. kBatchSizeAfterPadding, kPaddingAmount, kBatchingInputTaskSize, // GPU occupancy metrics kTheoreticalOccupancyPct, kOccupancyMinGridSize, kOccupancySuggestedBlockSize, // Aggregrated Stats kSelfDurationPs, kMinDurationPs, kTotalProfileDurationPs, kMaxIterationNum, kDeviceType, kUsesMegaCore, kSymbolId, kTfOpName, kDmaStallDurationPs, kLastStatType = kDmaStallDurationPs }; inline std::string TpuPlaneName(int32_t device_ordinal) { return absl::StrCat(kTpuPlanePrefix, device_ordinal); } inline std::string GpuPlaneName(int32_t device_ordinal) { return absl::StrCat(kGpuPlanePrefix, device_ordinal); } absl::string_view GetHostEventTypeStr(HostEventType event_type); bool IsHostEventType(HostEventType event_type, absl::string_view event_name); inline bool IsHostEventType(HostEventType event_type, absl::string_view event_name) { return GetHostEventTypeStr(event_type) == event_name; } absl::optional<int64_t> FindHostEventType(absl::string_view event_name); absl::optional<int64_t> FindTfOpEventType(absl::string_view event_name); absl::string_view GetStatTypeStr(StatType stat_type); bool IsStatType(StatType stat_type, absl::string_view stat_name); inline bool IsStatType(StatType stat_type, absl::string_view stat_name) { return GetStatTypeStr(stat_type) == stat_name; } absl::optional<int64_t> FindStatType(absl::string_view stat_name); // Returns true if the given event shouldn't be shown in the trace viewer. bool IsInternalEvent(absl::optional<int64_t> event_type); // Returns true if the given stat shouldn't be shown in the trace viewer. bool IsInternalStat(absl::optional<int64_t> stat_type); // Support for flow events: // This class enables encoding/decoding the flow id and direction, stored as // XStat value. The flow id are limited to 56 bits. class XFlow { public: enum FlowDirection { kFlowUnspecified = 0x0, kFlowIn = 0x1, kFlowOut = 0x2, kFlowInOut = 0x3, }; XFlow(uint64_t flow_id, FlowDirection direction, ContextType category = ContextType::kGeneric) { DCHECK_NE(direction, kFlowUnspecified); encoded_.parts.direction = direction; encoded_.parts.flow_id = flow_id; encoded_.parts.category = static_cast<uint64_t>(category); } // Encoding uint64 ToStatValue() const { return encoded_.whole; } // Decoding static XFlow FromStatValue(uint64_t encoded) { return XFlow(encoded); } /* NOTE: absl::HashOf is not consistent across processes (some process level * salt is added), even different executions of the same program. * However we are not tracking cross-host flows, i.e. A single flow's * participating events are from the same XSpace. On the other hand, * events from the same XSpace is always processed in the same profiler * process. Flows from different hosts are unlikely to collide because of * 2^56 hash space. Therefore, we can consider this is good for now. We should * revisit the hash function when cross-hosts flows became more popular. */ template <typename... Args> static uint64_t GetFlowId(Args&&... args) { return absl::HashOf(std::forward<Args>(args)...) & kFlowMask; } uint64_t Id() const { return encoded_.parts.flow_id; } ContextType Category() const { return GetSafeContextType(encoded_.parts.category); } FlowDirection Direction() const { return FlowDirection(encoded_.parts.direction); } static uint64_t GetUniqueId() { // unique in current process. return next_flow_id_.fetch_add(1); } private: explicit XFlow(uint64_t encoded) { encoded_.whole = encoded; } static constexpr uint64_t kFlowMask = (1ULL << 56) - 1; static std::atomic<uint64_t> next_flow_id_; union { // Encoded representation. uint64_t whole; struct { uint64_t direction : 2; uint64_t flow_id : 56; uint64_t category : 6; } parts; } encoded_ ABSL_ATTRIBUTE_PACKED; static_assert(sizeof(encoded_) == sizeof(uint64_t), "Must be 64 bits."); }; } // namespace profiler } // namespace tsl #endif // TENSORFLOW_TSL_PROFILER_UTILS_XPLANE_SCHEMA_H_
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
600b54687490a4c99f89b541f39085242d867942
b4297dbcdc34ea0294fa4b0b140448dcb215e939
/ConvexHull/SideLine.h
fb0e1fb65c0d5466322864c4c8147895993c414b
[]
no_license
shadtome/Computational-Geometry
171281957b77b1bae2156467be734881c6bf0e47
6cf7ecd3abd6bc4d4d38013fe90c06a3d5027c75
refs/heads/master
2020-04-17T01:40:59.455547
2019-04-21T08:27:53
2019-04-21T08:27:53
166,088,594
0
0
null
null
null
null
UTF-8
C++
false
false
678
h
#ifndef SIDEOFLINE_H #define SIDEOFLINE_H //---------------------------------------------------------- enum Side { LEFT=1, RIGHT=0, COLINEAR=1 }; //Determines which side the point R is with respect to the line segment PQ Side Side_of_line(std::vector<float> P,std::vector<float> Q,std::vector<float> R) { float result=(Q[0]*R[1]-Q[1]*R[0])-(P[0]*R[1]-P[1]*R[0])+(P[0]*Q[1]-P[1]*Q[0]); if(result>0) return LEFT; //This means that R is on the left side of the line segment from P to Q if(result<0) return RIGHT; //This means that R is on the right side of the line Segment from P to Q return COLINEAR; // meaning they are on the same line } #endif
[ "codytipton@Codys-MacBook-Air.local" ]
codytipton@Codys-MacBook-Air.local
e115d2d5a37ea86046d483dfb9d3f75747f67be4
93fbf65a76bbeb5d8e915c14e5601ae363b3057f
/2nd sem C++/Unary operator1.cpp
a7a09a6dba5a9e0db1c4446c83b9490737f888cf
[]
no_license
sauravjaiswa/Coding-Problems
fd864a7678a961a422902eef42a29218cdd2367f
cb978f90d7dcaec75af84cba05d141fdf4f243a0
refs/heads/master
2023-04-14T11:34:03.138424
2021-03-25T17:46:47
2021-03-25T17:46:47
309,085,423
0
0
null
null
null
null
UTF-8
C++
false
false
543
cpp
//Operator Overloading-Unary Operator #include<iostream> using namespace std; class check_count { public: int count_plus,count_minus; check_count() { count_plus=0; count_minus=2; } void operator ++() { ++count_plus; }//count increment void operator --() { --count_minus; }//count decrement }; int main() { check_count x,y; cout<<"x="<<x.count_plus<<"\n"; cout<<"y="<<y.count_minus<<"\n"; ++x; --y; cout<<"After increm and decre=<<\n"; cout<<"x="<<x.count_plus<<"\n"; cout<<"y="<<y.count_minus<<"\n"; }
[ "41826172+sauravjaiswa@users.noreply.github.com" ]
41826172+sauravjaiswa@users.noreply.github.com
664ffc0912edc249a440fb2010fa6dfbd47b99e2
9dc21dc52cba61932aafb5d422ed825aafce9e22
/src/appleseed.bench/utility/formatrendertime.h
633879c9dedf520f24f91192cf58778ed33291e0
[ "MIT" ]
permissive
MarcelRaschke/appleseed
c8613a0e0c268d77e83367fef2d5f22f68568480
802dbf67bdf3a53c983bbb638e7f08a2c90323db
refs/heads/master
2023-07-19T05:48:06.415165
2020-01-18T15:28:31
2020-01-19T11:52:15
236,110,136
2
0
MIT
2023-04-03T23:00:15
2020-01-25T01:12:57
null
UTF-8
C++
false
false
1,679
h
// // This source file is part of appleseed. // Visit https://appleseedhq.net/ for additional information and resources. // // This software is released under the MIT license. // // Copyright (c) 2019 Francois Beaune, The appleseedhq Organization // // 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. // #pragma once // Qt headers. #include <QChar> #include <QString> namespace appleseed { namespace bench { inline QString format_render_time(const int seconds) { return QString("%1:%2") .arg(seconds / 60, 2, 10, QChar('0')) .arg(seconds % 60, 2, 10, QChar('0')); } } // namespace bench } // namespace appleseed
[ "franz@appleseedhq.net" ]
franz@appleseedhq.net
7054f1c46d77cf4d8491598ce025e458eb65fee5
9c9e8fa145e8c36493bb7465ddbf7af98b684ea1
/Templates/Main.cpp
926240b3d9190431f10203f1e4ef9a7170324dc6
[]
no_license
amandaevans18/ConstructorsAndDestructors
410572478d2470c8310ae6a1948162d87c329ce7
397a6f5a14ebaaaa3fc64e0b575d780678faba4b
refs/heads/master
2020-03-31T19:33:50.458921
2018-11-09T01:55:33
2018-11-09T01:55:33
152,502,859
0
0
null
null
null
null
UTF-8
C++
false
false
243
cpp
#include<iostream> template<class T> int Min(T a, T b) { if (a < b) { return a; } else { return b; } } template<class T> int Max(T a, T b) { if (a > b ) { return a; } else { return b; } } int main() { return 0; }
[ "s189068@students.aie.edu" ]
s189068@students.aie.edu
77478e7a93cfe0367abb2d961a763620bba047f6
8890eb05a38d5fc91c9bf5d1fe5ba825d6d8fbdc
/lib/obj_loader.cpp
6bb7e8bcbd0061e1757502b054190ef651fbdf8f
[]
no_license
KrupsonSVK/Stop-The-Bombers
70ebb1c1e7fceafe27ed1096fb833be252e55065
c3e305083de08c50ae292501418b6cc7bb3e98d5
refs/heads/master
2021-01-18T15:39:17.925902
2017-03-23T22:56:27
2017-03-23T22:56:27
85,998,470
0
0
null
null
null
null
UTF-8
C++
false
false
27,126
cpp
// // Copyright 2012-2015, Syoyo Fujita. // // Licensed under 2-clause BSD liecense. // // // version 0.9.14: Support specular highlight, bump, displacement and alpha // map(#53) // version 0.9.13: Report "Material file not found message" in `err`(#46) // version 0.9.12: Fix groups being ignored if they have 'usemtl' just before // 'g' (#44) // version 0.9.11: Invert `Tr` parameter(#43) // version 0.9.10: Fix seg fault on windows. // version 0.9.9 : Replace atof() with custom parser. // version 0.9.8 : Fix multi-materials(per-face material ID). // version 0.9.7 : Support multi-materials(per-face material ID) per // object/group. // version 0.9.6 : Support Ni(index of refraction) mtl parameter. // Parse transmittance material parameter correctly. // version 0.9.5 : Parse multiple group name. // Add support of specifying the base path to load material // file. // version 0.9.4 : Initial suupport of group tag(g) // version 0.9.3 : Fix parsing triple 'x/y/z' // version 0.9.2 : Add more .mtl load support // version 0.9.1 : Add initial .mtl load support // version 0.9.0 : Initial // #include <cstdlib> #include <cstring> #include <cassert> #include <cmath> #include <cstddef> #include <cctype> #include <string> #include <vector> #include <map> #include <fstream> #include <sstream> #include "obj_loader.h" namespace tinyobj { #define TINYOBJ_SSCANF_BUFFER_SIZE (4096) struct vertex_index { int v_idx, vt_idx, vn_idx; vertex_index(){}; vertex_index(int idx) : v_idx(idx), vt_idx(idx), vn_idx(idx){}; vertex_index(int vidx, int vtidx, int vnidx) : v_idx(vidx), vt_idx(vtidx), vn_idx(vnidx){}; }; // for std::map static inline bool operator<(const vertex_index &a, const vertex_index &b) { if (a.v_idx != b.v_idx){ return (a.v_idx < b.v_idx); } if (a.vn_idx != b.vn_idx){ return (a.vn_idx < b.vn_idx); } if (a.vt_idx != b.vt_idx){ return (a.vt_idx < b.vt_idx); } return false; } struct obj_shape { std::vector<float> v; std::vector<float> vn; std::vector<float> vt; }; static inline bool isSpace(const char c) { return (c == ' ') || (c == '\t'); } static inline bool isNewLine(const char c) { return (c == '\r') || (c == '\n') || (c == '\0'); } // Make index zero-base, and also support relative index. static inline int fixIndex(int idx, int n) { if (idx > 0){ return idx - 1; } if (idx == 0){ return 0; } return n + idx; // negative value = relative } static inline std::string parseString(const char *&token) { std::string s; token += strspn(token, " \t"); size_t e = strcspn(token, " \t\r"); s = std::string(token, &token[e]); token += e; return s; } static inline int parseInt(const char *&token) { token += strspn(token, " \t"); int i = atoi(token); token += strcspn(token, " \t\r"); return i; } // Tries to parse a floating point number located at s. // // s_end should be a location in the string where reading should absolutely // stop. For example at the end of the string, to prevent buffer overflows. // // Parses the following EBNF grammar: // sign = "+" | "-" ; // END = ? anything not in digit ? // digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ; // integer = [sign] , digit , {digit} ; // decimal = integer , ["." , integer] ; // float = ( decimal , END ) | ( decimal , ("E" | "e") , integer , END ) ; // // Valid strings are for example: // -0 +3.1417e+2 -0.0E-3 1.0324 -1.41 11e2 // // If the parsing is a success, result is set to the parsed value and true // is returned. // // The function is greedy and will parse until any of the following happens: // - a non-conforming character is encountered. // - s_end is reached. // // The following situations triggers a failure: // - s >= s_end. // - parse failure. // static bool tryParseDouble(const char *s, const char *s_end, double *result) { if (s >= s_end) { return false; } double mantissa = 0.0; // This exponent is base 2 rather than 10. // However the exponent we parse is supposed to be one of ten, // thus we must take care to convert the exponent/and or the // mantissa to a * 2^E, where a is the mantissa and E is the // exponent. // To get the final double we will use ldexp, it requires the // exponent to be in base 2. int exponent = 0; // NOTE: THESE MUST BE DECLARED HERE SINCE WE ARE NOT ALLOWED // TO JUMP OVER DEFINITIONS. char sign = '+'; char exp_sign = '+'; char const *curr = s; // How many characters were read in a loop. int read = 0; // Tells whether a loop terminated due to reaching s_end. bool end_not_reached = false; /* BEGIN PARSING. */ // Find out what sign we've got. if (*curr == '+' || *curr == '-') { sign = *curr; curr++; } else if (isdigit(*curr)) { /* Pass through. */ } else { goto fail; } // Read the integer part. while ((end_not_reached = (curr != s_end)) && isdigit(*curr)) { mantissa *= 10; mantissa += static_cast<int>(*curr - 0x30); curr++; read++; } // We must make sure we actually got something. if (read == 0) goto fail; // We allow numbers of form "#", "###" etc. if (!end_not_reached) goto assemble; // Read the decimal part. if (*curr == '.') { curr++; read = 1; while ((end_not_reached = (curr != s_end)) && isdigit(*curr)) { // NOTE: Don't use powf here, it will absolutely murder precision. mantissa += static_cast<int>(*curr - 0x30) * pow(10.0, -read); read++; curr++; } } else if (*curr == 'e' || *curr == 'E') { } else { goto assemble; } if (!end_not_reached) goto assemble; // Read the exponent part. if (*curr == 'e' || *curr == 'E') { curr++; // Figure out if a sign is present and if it is. if ((end_not_reached = (curr != s_end)) && (*curr == '+' || *curr == '-')) { exp_sign = *curr; curr++; } else if (isdigit(*curr)) { /* Pass through. */ } else { // Empty E is not allowed. goto fail; } read = 0; while ((end_not_reached = (curr != s_end)) && isdigit(*curr)) { exponent *= 10; exponent += static_cast<int>(*curr - 0x30); curr++; read++; } exponent *= (exp_sign == '+' ? 1 : -1); if (read == 0) goto fail; } assemble: *result = (sign == '+' ? 1 : -1) * ldexp(mantissa * pow(5.0, exponent), exponent); return true; fail: return false; } static inline float parseFloat(const char *&token) { token += strspn(token, " \t"); #ifdef TINY_OBJ_LOADER_OLD_FLOAT_PARSER float f = (float)atof(token); token += strcspn(token, " \t\r"); #else const char *end = token + strcspn(token, " \t\r"); double val = 0.0; tryParseDouble(token, end, &val); float f = static_cast<float>(val); token = end; #endif return f; } static inline void parseFloat2(float &x, float &y, const char *&token) { x = parseFloat(token); y = parseFloat(token); } static inline void parseFloat3(float &x, float &y, float &z, const char *&token) { x = parseFloat(token); y = parseFloat(token); z = parseFloat(token); } // Parse triples: i, i/j/k, i//k, i/j static vertex_index parseTriple(const char *&token, int vsize, int vnsize, int vtsize) { vertex_index vi(-1); vi.v_idx = fixIndex(atoi(token), vsize); token += strcspn(token, "/ \t\r"); if (token[0] != '/') { return vi; } token++; // i//k if (token[0] == '/') { token++; vi.vn_idx = fixIndex(atoi(token), vnsize); token += strcspn(token, "/ \t\r"); return vi; } // i/j/k or i/j vi.vt_idx = fixIndex(atoi(token), vtsize); token += strcspn(token, "/ \t\r"); if (token[0] != '/') { return vi; } // i/j/k token++; // skip '/' vi.vn_idx = fixIndex(atoi(token), vnsize); token += strcspn(token, "/ \t\r"); return vi; } static unsigned int updateVertex(std::map<vertex_index, unsigned int> &vertexCache, std::vector<float> &positions, std::vector<float> &normals, std::vector<float> &texcoords, const std::vector<float> &in_positions, const std::vector<float> &in_normals, const std::vector<float> &in_texcoords, const vertex_index &i) { const std::map<vertex_index, unsigned int>::iterator it = vertexCache.find(i); if (it != vertexCache.end()) { // found cache return it->second; } assert(in_positions.size() > (unsigned int)(3 * i.v_idx + 2)); positions.push_back(in_positions[3 * i.v_idx + 0]); positions.push_back(in_positions[3 * i.v_idx + 1]); positions.push_back(in_positions[3 * i.v_idx + 2]); if (i.vn_idx >= 0) { normals.push_back(in_normals[3 * i.vn_idx + 0]); normals.push_back(in_normals[3 * i.vn_idx + 1]); normals.push_back(in_normals[3 * i.vn_idx + 2]); } if (i.vt_idx >= 0) { texcoords.push_back(in_texcoords[2 * i.vt_idx + 0]); texcoords.push_back(in_texcoords[2 * i.vt_idx + 1]); } unsigned int idx = static_cast<unsigned int>(positions.size() / 3 - 1); vertexCache[i] = idx; return idx; } void InitMaterial(material_t &material) { material.name = ""; material.ambient_texname = ""; material.diffuse_texname = ""; material.specular_texname = ""; material.specular_highlight_texname = ""; material.bump_texname = ""; material.displacement_texname = ""; material.alpha_texname = ""; for (int i = 0; i < 3; i++) { material.ambient[i] = 0.f; material.diffuse[i] = 0.f; material.specular[i] = 0.f; material.transmittance[i] = 0.f; material.emission[i] = 0.f; } material.illum = 0; material.dissolve = 1.f; material.shininess = 1.f; material.ior = 1.f; material.unknown_parameter.clear(); } static bool exportFaceGroupToShape( shape_t &shape, std::map<vertex_index, unsigned int> vertexCache, const std::vector<float> &in_positions, const std::vector<float> &in_normals, const std::vector<float> &in_texcoords, const std::vector<std::vector<vertex_index>> &faceGroup, const int material_id, const std::string &name, bool clearCache) { if (faceGroup.empty()) { return false; } // Flatten vertices and indices for (size_t i = 0; i < faceGroup.size(); i++) { const std::vector<vertex_index> &face = faceGroup[i]; vertex_index i0 = face[0]; vertex_index i1(-1); vertex_index i2 = face[1]; size_t npolys = face.size(); // Polygon -> triangle fan conversion for (size_t k = 2; k < npolys; k++) { i1 = i2; i2 = face[k]; unsigned int v0 = updateVertex( vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i0); unsigned int v1 = updateVertex( vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i1); unsigned int v2 = updateVertex( vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i2); shape.mesh.indices.push_back(v0); shape.mesh.indices.push_back(v1); shape.mesh.indices.push_back(v2); shape.mesh.material_ids.push_back(material_id); } } shape.name = name; if (clearCache) vertexCache.clear(); return true; } std::string LoadMtl(std::map<std::string, int> &material_map, std::vector<material_t> &materials, std::istream &inStream) { std::stringstream err; // Create a default material anyway. material_t material; InitMaterial(material); int maxchars = 8192; // Alloc enough size. std::vector<char> buf(maxchars); // Alloc enough size. while (inStream.peek() != -1) { inStream.getline(&buf[0], maxchars); std::string linebuf(&buf[0]); // Trim newline '\r\n' or '\n' if (linebuf.size() > 0) { if (linebuf[linebuf.size() - 1] == '\n') linebuf.erase(linebuf.size() - 1); } if (linebuf.size() > 0) { if (linebuf[linebuf.size() - 1] == '\r') linebuf.erase(linebuf.size() - 1); } // Skip if empty line. if (linebuf.empty()) { continue; } // Skip leading space. const char *token = linebuf.c_str(); token += strspn(token, " \t"); assert(token); if (token[0] == '\0') continue; // empty line if (token[0] == '#') continue; // comment line // new mtl if ((0 == strncmp(token, "newmtl", 6)) && isSpace((token[6]))) { // flush previous material. if (!material.name.empty()) { material_map.insert(std::pair<std::string, int>( material.name, static_cast<int>(materials.size()))); materials.push_back(material); } // initial temporary material InitMaterial(material); // set new mtl name char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; token += 7; #ifdef _MSC_VER sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); #else sscanf(token, "%s", namebuf); #endif material.name = namebuf; continue; } // ambient if (token[0] == 'K' && token[1] == 'a' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.ambient[0] = r; material.ambient[1] = g; material.ambient[2] = b; continue; } // diffuse if (token[0] == 'K' && token[1] == 'd' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.diffuse[0] = r; material.diffuse[1] = g; material.diffuse[2] = b; continue; } // specular if (token[0] == 'K' && token[1] == 's' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.specular[0] = r; material.specular[1] = g; material.specular[2] = b; continue; } // transmittance if (token[0] == 'K' && token[1] == 't' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.transmittance[0] = r; material.transmittance[1] = g; material.transmittance[2] = b; continue; } // ior(index of refraction) if (token[0] == 'N' && token[1] == 'i' && isSpace((token[2]))) { token += 2; material.ior = parseFloat(token); continue; } // emission if (token[0] == 'K' && token[1] == 'e' && isSpace(token[2])) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.emission[0] = r; material.emission[1] = g; material.emission[2] = b; continue; } // shininess if (token[0] == 'N' && token[1] == 's' && isSpace(token[2])) { token += 2; material.shininess = parseFloat(token); continue; } // illum model if (0 == strncmp(token, "illum", 5) && isSpace(token[5])) { token += 6; material.illum = parseInt(token); continue; } // dissolve if ((token[0] == 'd' && isSpace(token[1]))) { token += 1; material.dissolve = parseFloat(token); continue; } if (token[0] == 'T' && token[1] == 'r' && isSpace(token[2])) { token += 2; // Invert value of Tr(assume Tr is in range [0, 1]) material.dissolve = 1.0f - parseFloat(token); continue; } // ambient texture if ((0 == strncmp(token, "map_Ka", 6)) && isSpace(token[6])) { token += 7; material.ambient_texname = token; continue; } // diffuse texture if ((0 == strncmp(token, "map_Kd", 6)) && isSpace(token[6])) { token += 7; material.diffuse_texname = token; continue; } // specular texture if ((0 == strncmp(token, "map_Ks", 6)) && isSpace(token[6])) { token += 7; material.specular_texname = token; continue; } // specular highlight texture if ((0 == strncmp(token, "map_Ns", 6)) && isSpace(token[6])) { token += 7; material.specular_highlight_texname = token; continue; } // bump texture if ((0 == strncmp(token, "map_bump", 8)) && isSpace(token[8])) { token += 9; material.bump_texname = token; continue; } // alpha texture if ((0 == strncmp(token, "map_d", 5)) && isSpace(token[5])) { token += 6; material.alpha_texname = token; continue; } // bump texture if ((0 == strncmp(token, "bump", 4)) && isSpace(token[4])) { token += 5; material.bump_texname = token; continue; } // displacement texture if ((0 == strncmp(token, "disp", 4)) && isSpace(token[4])) { token += 5; material.displacement_texname = token; continue; } // unknown parameter const char *_space = strchr(token, ' '); if (!_space) { _space = strchr(token, '\t'); } if (_space) { std::ptrdiff_t len = _space - token; std::string key(token, len); std::string value = _space + 1; material.unknown_parameter.insert( std::pair<std::string, std::string>(key, value)); } } // flush last material. material_map.insert(std::pair<std::string, int>( material.name, static_cast<int>(materials.size()))); materials.push_back(material); return err.str(); } std::string MaterialFileReader::operator()(const std::string &matId, std::vector<material_t> &materials, std::map<std::string, int> &matMap) { std::string filepath; if (!m_mtlBasePath.empty()) { filepath = std::string(m_mtlBasePath) + matId; } else { filepath = matId; } std::ifstream matIStream(filepath.c_str()); std::string err = LoadMtl(matMap, materials, matIStream); if (!matIStream) { std::stringstream ss; // ss << "WARN: Material file [ " << filepath << " ] not found. Created a // default material."; // err += ss.str(); } return err; } std::string LoadObj(std::vector<shape_t> &shapes, std::vector<material_t> &materials, // [output] const char *filename, const char *mtl_basepath) { shapes.clear(); std::stringstream err; std::ifstream ifs(filename); if (!ifs) { err << "Cannot open file [" << filename << "]" << std::endl; return err.str(); } std::string basePath; if (mtl_basepath) { basePath = mtl_basepath; } MaterialFileReader matFileReader(basePath); return LoadObj(shapes, materials, ifs, matFileReader); } std::string LoadObj(std::vector<shape_t> &shapes, std::vector<material_t> &materials, // [output] std::istream &inStream, MaterialReader &readMatFn) { std::stringstream err; std::vector<float> v; std::vector<float> vn; std::vector<float> vt; std::vector<std::vector<vertex_index>> faceGroup; std::string name; // material std::map<std::string, int> material_map; std::map<vertex_index, unsigned int> vertexCache; int material = -1; shape_t shape; int maxchars = 8192; // Alloc enough size. std::vector<char> buf(maxchars); // Alloc enough size. while (inStream.peek() != -1) { inStream.getline(&buf[0], maxchars); std::string linebuf(&buf[0]); // Trim newline '\r\n' or '\n' if (linebuf.size() > 0) { if (linebuf[linebuf.size() - 1] == '\n') linebuf.erase(linebuf.size() - 1); } if (linebuf.size() > 0) { if (linebuf[linebuf.size() - 1] == '\r') linebuf.erase(linebuf.size() - 1); } // Skip if empty line. if (linebuf.empty()) { continue; } // Skip leading space. const char *token = linebuf.c_str(); token += strspn(token, " \t"); assert(token); if (token[0] == '\0') continue; // empty line if (token[0] == '#') continue; // comment line // vertex if (token[0] == 'v' && isSpace((token[1]))) { token += 2; float x, y, z; parseFloat3(x, y, z, token); v.push_back(x); v.push_back(y); v.push_back(z); continue; } // normal if (token[0] == 'v' && token[1] == 'n' && isSpace((token[2]))) { token += 3; float x, y, z; parseFloat3(x, y, z, token); vn.push_back(x); vn.push_back(y); vn.push_back(z); continue; } // texcoord if (token[0] == 'v' && token[1] == 't' && isSpace((token[2]))) { token += 3; float x, y; parseFloat2(x, y, token); vt.push_back(x); vt.push_back(y); continue; } // face if (token[0] == 'f' && isSpace((token[1]))) { token += 2; token += strspn(token, " \t"); std::vector<vertex_index> face; while (!isNewLine(token[0])) { vertex_index vi = parseTriple(token, static_cast<int>(v.size() / 3), static_cast<int>(vn.size() / 3), static_cast<int>(vt.size() / 2)); face.push_back(vi); size_t n = strspn(token, " \t\r"); token += n; } faceGroup.push_back(face); continue; } // use mtl if ((0 == strncmp(token, "usemtl", 6)) && isSpace((token[6]))) { char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; token += 7; #ifdef _MSC_VER sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); #else sscanf(token, "%s", namebuf); #endif // Create face group per material. bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } shape = shape_t(); faceGroup.clear(); if (material_map.find(namebuf) != material_map.end()) { material = material_map[namebuf]; } else { // { error!! material not found } material = -1; } continue; } // load mtl if ((0 == strncmp(token, "mtllib", 6)) && isSpace((token[6]))) { char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; token += 7; #ifdef _MSC_VER sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); #else sscanf(token, "%s", namebuf); #endif std::string err_mtl = readMatFn(namebuf, materials, material_map); if (!err_mtl.empty()) { faceGroup.clear(); // for safety return err_mtl; } continue; } // group name if (token[0] == 'g' && isSpace((token[1]))) { // flush previous face group. bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } shape = shape_t(); // material = -1; faceGroup.clear(); std::vector<std::string> names; while (!isNewLine(token[0])) { std::string str = parseString(token); names.push_back(str); token += strspn(token, " \t\r"); // skip tag } assert(names.size() > 0); // names[0] must be 'g', so skip the 0th element. if (names.size() > 1) { name = names[1]; } else { name = ""; } continue; } // object name if (token[0] == 'o' && isSpace((token[1]))) { // flush previous face group. bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } // material = -1; faceGroup.clear(); shape = shape_t(); // @todo { multiple object name? } char namebuf[TINYOBJ_SSCANF_BUFFER_SIZE]; token += 2; #ifdef _MSC_VER sscanf_s(token, "%s", namebuf, (unsigned)_countof(namebuf)); #else sscanf(token, "%s", namebuf); #endif name = std::string(namebuf); continue; } // Ignore unknown command. } bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } faceGroup.clear(); // for safety return err.str(); } }
[ "krup.son@azet.sk" ]
krup.son@azet.sk
021a27211fdefb248fbefa6699dd5672eedc7099
80e56bdfceac35462afcb394d1a3e0a2d97b87a2
/Test/src/MemsetTest.h
11b035c780b437da3ab0a658e35c51fa0a1ab41b
[]
no_license
dimitarpg13/cpp_testcode
8c6f338b5a831c35d813f13e5d2c83064accf253
9c1a5f2299a8c04cc5cb3dedc8a374063ac65cff
refs/heads/master
2021-06-06T05:56:10.556943
2016-02-27T15:45:57
2016-02-27T15:45:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
414
h
/* * MemsetTest.h * * Created on: Oct 12, 2014 * Author: root */ #ifndef MEMSETTEST_H_ #define MEMSETTEST_H_ #include <iostream> #include <string.h> #include "IndustryTree.h" namespace Algorithms { class MemsetTest { public: MemsetTest(); private: int a; float f; char str[35]; long *lp; // IndustryTree tree; }; } /* namespace Algorithms */ #endif /* MEMSETTEST_H_ */
[ "dimitar_pg13@hotmail.com" ]
dimitar_pg13@hotmail.com
cf8ad44638913b0bb441fdfc2f28f723c84fe741
196cd3d729c135ed0718c023ecc4f79211240d51
/message.h
599effacf781f154b3d6cebb2d1852d3ac72e981
[]
no_license
0Nightfall0/homework1
2fc2af13b4f95dca6eab86a8a16445b0a469181d
b4a696c0b30a2e5fe777421aa488e7f0a145d234
refs/heads/master
2023-04-12T13:41:43.218660
2021-04-25T09:46:57
2021-04-25T09:46:57
361,361,482
0
0
null
null
null
null
UTF-8
C++
false
false
88
h
#ifndef MESSAGE_H #define MESSAGE_H class message{ public: void print(); }; #endif
[ "night.tittania@gmail.com" ]
night.tittania@gmail.com
10a52671f71b7c1682f8e2c1195ff6a1b3c68008
97b7333782a0d75ad66a4fa8f21d836d6fafe000
/src/MCPhoton.hpp
4ffaac86bd8763756b423cf493578210973557c9
[]
no_license
lkersting/MCPhoton
9f7e1878edb9a45cf85b8aa227a263e4bc903f60
17eb12191764f7c1fd810501fd1ef7accb0a0ebe
refs/heads/master
2020-04-05T23:30:10.512700
2014-08-13T18:44:54
2014-08-13T18:44:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,055
hpp
//---------------------------------------------------------------------------// //! //! \file MCPhoton.hpp //! \author Luke Kersting //! \brief Monte Carlo Photon transport forward declaration header //! //---------------------------------------------------------------------------// #ifndef MC_PHOTON_HPP #define MC_PHOTON_HPP // Linear Interpolation //#define INTERPOLATOR2 getLinearInterpolation2 //#define INTERPOLATOR3 getLinearInterpolation3 // Log Interpolation //#define INTERPOLATOR2 getLogInterpolation2 //#define INTERPOLATOR3 getLogInterpolation3 // Define home directory #define xstr(s) str(s) #define str(s) #s //#define DIR "/home/lujoke/Documents/CPP/MCPhoton/data" #include <iostream> #include <fstream> #include "PhotonTransport.hpp" #include "PhotonScatter.hpp" #include "Interpolate.hpp" #include "RingDetector.hpp" #endif // end MC_PHOTON_HPP //---------------------------------------------------------------------------// // end MCPhoton.hpp //---------------------------------------------------------------------------//
[ "lkersting@wisc.edu" ]
lkersting@wisc.edu
8d41f2bebf4f9fa38d10ea4769d85cdf16f4c86c
30773b649ebd89ffadd16d30fd62740b77ca7865
/SDK/OceanCrawlers_functions.cpp
638592bff89636bc4071c2ae0b865f457a1329a3
[]
no_license
The-Jani/Sot-SDK
7f2772fb5df421e02b8fec237248af407cb2540b
2a158a461c697cca8db67aa28ffe3e43677dcf11
refs/heads/main
2023-07-09T07:17:56.972569
2021-08-18T23:45:06
2021-08-18T23:45:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,161
cpp
// Name: S, Version: 2.2.1 #include "../SDK.h" /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Functions //--------------------------------------------------------------------------- // Function OceanCrawlers.OceanCrawlerAudioBroadcaster.Multicast_PlayBuffAudio // (Final, Net, Native, Event, NetMulticast, Private) // Parameters: // struct FEventOceanCrawlerAIBuffAudioRequest InRequest (ConstParm, Parm, ReferenceParm) void UOceanCrawlerAudioBroadcaster::Multicast_PlayBuffAudio(const struct FEventOceanCrawlerAIBuffAudioRequest& InRequest) { static UFunction* fn = UObject::FindObject<UFunction>("Function OceanCrawlers.OceanCrawlerAudioBroadcaster.Multicast_PlayBuffAudio"); UOceanCrawlerAudioBroadcaster_Multicast_PlayBuffAudio_Params params; params.InRequest = InRequest; auto flags = fn->FunctionFlags; fn->FunctionFlags |= 0x00000400; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } // Function OceanCrawlers.OceanCrawlerAudioBroadcaster.Multicast_PlayAudio // (Final, Net, Native, Event, NetMulticast, Private) // Parameters: // TEnumAsByte<AthenaAI_EOceanCrawlerAbilityAudioKey> InAudioKey (ConstParm, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) // float InAudioDelay (ConstParm, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) void UOceanCrawlerAudioBroadcaster::Multicast_PlayAudio(TEnumAsByte<AthenaAI_EOceanCrawlerAbilityAudioKey> InAudioKey, float InAudioDelay) { static UFunction* fn = UObject::FindObject<UFunction>("Function OceanCrawlers.OceanCrawlerAudioBroadcaster.Multicast_PlayAudio"); UOceanCrawlerAudioBroadcaster_Multicast_PlayAudio_Params params; params.InAudioKey = InAudioKey; params.InAudioDelay = InAudioDelay; auto flags = fn->FunctionFlags; fn->FunctionFlags |= 0x00000400; UObject::ProcessEvent(fn, &params); fn->FunctionFlags = flags; } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "ploszjanos9844@gmail.com" ]
ploszjanos9844@gmail.com
3717fae9c560ca2d8cffe20df7c26276afa7a851
4046c9de0de17299224e5af824db9c3e8ac60c1f
/ReactCommon/fabric/mounting/ShadowView.cpp
0cd8eee83101e51952f52ac80f3d9c303a1e32e3
[ "CC-BY-4.0", "MIT", "CC-BY-SA-4.0", "CC-BY-NC-SA-4.0" ]
permissive
RoJoHub/react-native
808de5a19ff3d954cb2879321b95e990a14b9845
6dd226da7734ccaab30e037369e0df56b921c948
refs/heads/master
2023-04-13T02:32:32.109145
2019-03-13T05:33:24
2019-03-13T05:33:24
168,518,588
1
0
MIT
2023-04-03T23:05:43
2019-01-31T12:04:21
JavaScript
UTF-8
C++
false
false
1,878
cpp
// Copyright (c) Facebook, Inc. and its affiliates. // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. #include "ShadowView.h" #include <react/core/LayoutableShadowNode.h> namespace facebook { namespace react { static LayoutMetrics layoutMetricsFromShadowNode(const ShadowNode &shadowNode) { auto layoutableShadowNode = dynamic_cast<const LayoutableShadowNode *>(&shadowNode); return layoutableShadowNode ? layoutableShadowNode->getLayoutMetrics() : EmptyLayoutMetrics; } ShadowView::ShadowView(const ShadowNode &shadowNode) : componentName(shadowNode.getComponentName()), componentHandle(shadowNode.getComponentHandle()), tag(shadowNode.getTag()), props(shadowNode.getProps()), eventEmitter(shadowNode.getEventEmitter()), layoutMetrics(layoutMetricsFromShadowNode(shadowNode)), localData(shadowNode.getLocalData()), state(shadowNode.getState()) {} bool ShadowView::operator==(const ShadowView &rhs) const { return std::tie( this->tag, this->componentName, this->props, this->eventEmitter, this->layoutMetrics, this->localData, this->state) == std::tie( rhs.tag, rhs.componentName, rhs.props, rhs.eventEmitter, rhs.layoutMetrics, rhs.localData, rhs.state); } bool ShadowView::operator!=(const ShadowView &rhs) const { return !(*this == rhs); } bool ShadowViewNodePair::operator==(const ShadowViewNodePair &rhs) const { return this->shadowNode == rhs.shadowNode; } bool ShadowViewNodePair::operator!=(const ShadowViewNodePair &rhs) const { return !(*this == rhs); } } // namespace react } // namespace facebook
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
7db1c8d164023934bb9926a6307bdb8928d6af3c
5794a8dd399a0b6b8bede7884cca5ec1d1a7986d
/051315/main/main.cc
cdf82ccc47851526f548ca5ed9c2e27fa62d3184
[]
no_license
AntonGerasimov/optics
c368088d5994fc19b6e061f728d6753969283c97
8cdfe820ea7eba7cd966e9c27513e9d79391fbd5
refs/heads/master
2016-09-05T14:30:42.950367
2015-05-20T21:25:38
2015-05-20T21:25:38
33,084,707
0
1
null
2015-05-17T18:24:38
2015-03-29T18:55:14
C++
UTF-8
C++
false
false
9,469
cc
#include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <signal.h> #include <stdlib.h> //#include "ray.h" //was included in "device.h" #include <string.h> #include <pthread.h> #include "first.h" int h; void handler(int nsig){ if(nsig==SIGINT){ close(h); printf("\nShutting down\n"); exit(0); } } void *func(void *arg); int main() { (void)signal(SIGINT, handler); h = socket(PF_INET, SOCK_STREAM, 0); if (h < 0){ perror("Creating socket"); } const int PORT = 5678; struct sockaddr_in local; local.sin_family = PF_INET; local.sin_port = htons(PORT); if(bind(h, (sockaddr *)&local, sizeof(local)) < 0){ perror("Binding"); close(h); return 1; } if (listen(h, 10) < 0){ perror("Listening"); close(h); return 2; } while(1) { struct sockaddr_in remote; unsigned remoteLen=sizeof(remote); int cs; if((cs=accept(h, (sockaddr *)&remote, &remoteLen))<0){ perror("Accepting"); } pthread_t thread; if(pthread_create(&thread, NULL, func, &cs)<0) { perror("Thread: "); } } close(h); } void *func(void* arg) { int rd; char buf[512]; int cs=*(int *)arg; char buf_[512]; vector <Device*> my_device; vector <SCREEN *> my_screen; vector<LASER*> my_laser; vector<SOURCE*> my_source; if(send(cs, "1", 1, MSG_NOSIGNAL)==-1) { perror("Can't send:"); return NULL; } while((rd=recv(cs, buf, sizeof(buf), 0))>0){ buf[rd]=0; printf("%s\n", buf); int check; if ((buf[1]>='0')&&(buf[1]<='9')){ int check_10 = buf[0] - '0'; check_10 = check_10 * 10; int check_1 = buf[1] - '0'; check = check_10 + check_1; printf("check = %d\n", check); } else{ check = buf[0] - '0'; } switch(check){ case 0: //source { float a1,x,y; sscanf(buf, "%f %f %f", &a1, &x, &y); SOURCE* d=new SOURCE(x,y); my_source.push_back(d); printf("New source was created\n"); break; } case 1: //screen { float a1, x1, y1, x2, y2; sscanf(buf, "%f %f %f %f %f", &a1, &x1, &y1, &x2, &y2); SCREEN *my_scr = new SCREEN(x1, y1, x2, y2); my_screen.push_back(my_scr); printf("Screen was created\n"); break; } case 2: //lens f>0 { float a1, x, y, l, deg, f; sscanf(buf, "%f %f %f %f %f %f",&a1,&x, &y, &l, &deg, &f); Device *d = new Lens(x, y, l, deg, f); my_device.push_back(d); printf("New lens f>0 was created\n"); break; } case 3: //mirror == PlainRefl { float a1, x, y, l, deg; sscanf(buf, "%f %f %f %f %f",&a1,&x, &y, &l, &deg); Device *d = new PlainRefl(x, y, l, deg); my_device.push_back(d); printf("New mirror was created\n"); break; } case 4: //ploskoparallell plastinka == disc { float a1, x, y, len, wid, deg, n; sscanf(buf, "%f %f %f %f %f %f %f",&a1,&x, &y, &len, &wid, &deg, &n); Device *d = new Disc(x, y, len, wid, deg, n); my_device.push_back(d); printf("New ploskoparallell plastinka was created\n"); break; } case 5: //Laser { float a1, x, y, deg; sscanf(buf, "%f %f %f %f", &a1,&x, &y, &deg); my_laser.push_back(new LASER(x,y,deg)); printf("New laser was created\n"); break; } case 6: //triangle prism { float a1, x1, y1, x2, y2, x3, y3, n; sscanf(buf, "%f %f %f %f %f %f %f %f",&a1,&x1, &y1, &x2, &y2, &x3, &y3, &n); int num = 1; Device *d = new Prism(num,x1, y1, x2, y2, x3, y3, n); my_device.push_back(d); printf("New triangle prism was created\n"); break; } case 7: //sphere mirror { float a1, x, y, r0, deg_1, deg_2; sscanf(buf, "%f %f %f %f %f %f",&a1, &x, &y, &deg_1, &deg_2, &r0); Device *d = new SphereRefl(x, y, r0, deg_1-90, deg_2-90); my_device.push_back(d); printf("New sphere mirror was created\n"); break; } case 8: //wide length { float a1, x, y, l, deg, r1, r2, n, de; sscanf(buf, "%f %f %f %f %f %f %f %f %f",&a1, &x, &y, &r1, &r2, &deg, &n, &l, &de); Device *d = new Lens_wide(x, y, l, deg, r1, r2, n, de); my_device.push_back(d); printf("New triangle prism was created\n"); break; } } fflush(stdout); if (strcmp(buf, "FINISH\0")!=0){ buf[0]=0; if(send(cs, "1", 1, MSG_NOSIGNAL)==-1) { perror("Can't send:"); return NULL; } } else{ break; } } point *cross = NULL; int k = 0; //номер девайса bool q = false; //true, если пересечения есть char temp[1]; vector<RAY*>my_laser_ray; for(int i=0; i<my_laser.size(); i++) { my_laser_ray.push_back(my_laser[i]->rays_create()); } //RAY *my_laser_ray=my_laser->rays_create(); for(int i=0; i<my_source.size(); i++) { RAY** rt=my_source[i]->rays_create(); for(int j=0; j<NUMBER; j++) { my_laser_ray.push_back(rt[j]); } } //let's work with laser first for(int I=0; I<my_laser_ray.size(); I++) { int num = first(my_device, my_laser_ray[I]); while(num != -1){ int num = first(my_device, my_laser_ray[I]); if (num != -1){ cross = my_device[num]->cross_point(my_laser_ray[I]); sprintf(buf_, "%f %f %f %f %c", my_laser_ray[I]->x, my_laser_ray[I]->y, cross->x, cross->y, '\0');//new dot if(send(cs, buf_, strlen(buf_)+1, MSG_NOSIGNAL)==-1){ perror("Can't send:"); return NULL; } recv(cs, temp, 1, 0); float tx=cross->x; float ty=cross->y; my_device[num]->change_direction(my_laser_ray[I], cross); if(my_device[num]->getID()==4){ sprintf(buf_, "%f %f %f %f %c", tx, ty, my_laser_ray[I]->x, my_laser_ray[I]->y, 0); if(send(cs, buf_, strlen(buf_)+1, MSG_NOSIGNAL)==-1){ perror("Can't send:"); return NULL; } recv(cs, temp, 1, 0); } } else{ break; } } //cross screen float tx, ty, tdeg; tx=my_laser_ray[I]->x; ty=my_laser_ray[I]->y; tdeg=my_laser_ray[I]->deg; int s_num = first_s(my_screen, my_laser_ray[I]); if (s_num == -1){ //find граница, куда дойдет луч float retx, rety; retx = my_laser_ray[I]->x + 2000 * cos(GradToRad(tdeg)); rety = my_laser_ray[I]->y - 2000 * sin(GradToRad(tdeg)); sprintf(buf_, "%f %f %f %f %c", my_laser_ray[I]->x, my_laser_ray[I]->y, retx, rety, '\0'); if(send(cs, buf_, strlen(buf_)+1, MSG_NOSIGNAL)==-1) { perror("Can't send:"); return NULL; } recv(cs, temp, 1, 0); } else{ cross = my_screen[s_num]->cross_point(my_laser_ray[I]); sprintf(buf_, "%f %f %f %f %c", tx, ty, crossing->x, crossing->y, '\0'); if(send(cs, buf_, strlen(buf_)+1, MSG_NOSIGNAL)==-1) { perror("Can't send:"); return NULL; } recv(cs, temp, 1, 0); } } if(send(cs, "FINISH\0", 7, MSG_NOSIGNAL)==-1) { perror("Can't send:"); return NULL; } while(recv(cs, buf_, sizeof(buf_)+1, 0)>0); close(cs); return NULL; }
[ "antoshkasg@gmail.com" ]
antoshkasg@gmail.com
c423d36e0039a2cd3220c9dfe725236e41e0f69d
b39712068af8193a6da4cac5855a108f066d320b
/arduino_library_php/arduino_library_php.ino
563591564e39713214fc7102523aa318b7c84828
[]
no_license
JohanDuran/Arduino-Projects
0e5542eaa8ede85fe248c55089b080ebeac20370
ff2c2f458163c7c3f10770a20b95c9dc4d72489c
refs/heads/master
2021-01-19T13:27:22.231891
2018-06-14T04:05:36
2018-06-14T04:05:36
88,090,264
0
0
null
null
null
null
UTF-8
C++
false
false
2,196
ino
#include <ESP8266WiFi.h> #include <ArduinoJson.h> const char* ssid = "mywifi"; const char* password = "mywifipassword"; const char* host = "192.168.1.10"; // Your domain String path = "/wifiarduino/light.json"; const int pin = 2; void setup() { pinMode(pin, OUTPUT); pinMode(pin, HIGH); Serial.begin(115200); delay(10); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); int wifi_ctr = 0; while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println("WiFi connected"); Serial.println("IP address: " + WiFi.localIP()); } void loop() { Serial.print("connecting to "); Serial.println(host); WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println("connection failed"); return; } client.print(String("GET ") + path + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: keep-alive\r\n\r\n"); delay(500); // wait for server to respond // read response String section="header"; while(client.available()){ String line = client.readStringUntil('\r'); // Serial.print(line); // we’ll parse the HTML body here if (section=="header") { // headers.. Serial.print("."); if (line=="\n") { // skips the empty space at the beginning section="json"; } } else if (section=="json") { // print the good stuff section="ignore"; String result = line.substring(1); // Parse JSON int size = result.length() + 1; char json[size]; result.toCharArray(json, size); StaticJsonBuffer<200> jsonBuffer; JsonObject& json_parsed = jsonBuffer.parseObject(json); if (!json_parsed.success()) { Serial.println("parseObject() failed"); return; } // Make the decision to turn off or on the LED if (strcmp(json_parsed["light"], "on") == 0) { digitalWrite(pin, HIGH); Serial.println("LED ON"); } else { digitalWrite(pin, LOW); Serial.println("led off"); } } } Serial.print("closing connection. "); }
[ "johan.durancerdas@gmail.com" ]
johan.durancerdas@gmail.com
19d602e46ff50432bca594c8133cb057be7cd716
93496367f4dd6870f1616f8354fe71e393f71e82
/tools/mkscncd.cpp
0af1e95d092fd07d2509d42048396c5eba26ed1a
[]
no_license
DTidd/OpenRDAAPI
5fa858474ec54335033adb37e3c4f4c22772e55d
78eee4201b2fbd938824ade81b6eaaa4b88cacaa
refs/heads/master
2021-01-21T23:28:49.291394
2014-06-25T15:26:29
2014-06-25T15:26:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,234
cpp
/* makescrncode.c - Generate Screen C Code for speed of development*/ #ifndef WIN32 #define __NAM__ "mkscncd.lnx" #endif #ifdef WIN32 #define __NAM__ "mkscncd.exe" #endif #include <app.hpp> #include <rptgen.hpp> #include <mkmsc.hpp> #include <packlib.hpp> /*ADDLIB tool */ /*ADDLIB mklib */ /*ADDLIB rpt */ /*ADDLIB mix */ /*ADDLIB olh */ /*ADDLIB sec */ /*ADDLIB trans */ /*ADDLIB gui */ /*ADDLIB nrd */ /*ADDLIB misc */ APPlib *scr_libs=NULL,*scr_defs=NULL,*dir_libs=NULL; static void getscreenlist(RDArsrc *); char *module=NULL; RDArsrc *mrsrc=NULL; static void quit_printRDAscrncode(RDArsrc *prsrc) { if(diaggui) { prterr("DIAG quit_printRDAscrncode Quitting Print RDA Screen Code"); } free_rsrc(prsrc); ShutdownSubsystems(); } static void printRDAscrncode(RDArsrc *prsrc,RDAscrn *scrn) { char *outdevice=NULL; FILE *fp=NULL; char *dirname=NULL,*libname=NULL,*scrnname=NULL; int l=0,s=0; if(scrn!=NULL) { readwidget(prsrc,"DEVICE"); FINDRSCGETSTRING(prsrc,"DEVICE",&outdevice); if(outdevice!=NULL) { if(FINDRSCGETSTRING(mrsrc,"DIRECTORY",&dirname)) { return; } if(FINDRSCGETINT(mrsrc,"LIBRARY LIST",&l)) { return; } if(FINDRSCGETINT(mrsrc,"SCREEN LIST",&s)) { return; } #ifndef WIN32 fp=popen(outdevice,"w"); #endif #ifdef WIN32 fp=fopen(outdevice,"a+"); #endif if(fp!=NULL) { if(outdevice!=NULL) Rfree(outdevice); libname=stralloc(scr_libs->libs[l]); scrnname=stralloc(scr_defs->libs[s]); stoupper(scrnname); stoupper(scrn->name); makescrncode(scrn,fp,dirname,libname,scrnname); #ifndef WIN32 pclose(fp); #endif #ifdef WIN32 fclose(fp); #endif if(scrn!=NULL) Rfree(scrn); } else { ERRORDIALOG("OUTPUT DEVICE COMMUNICATIONS FAILED!","The output device failed to open and will not receive output.",NULL,FALSE); prterr("Error PrintRDAscrn popen call for output device [%s] failed.",(outdevice!=NULL?outdevice:"")); if(dirname!=NULL) dirname=NULL; if(outdevice!=NULL) Rfree(outdevice); } } else { ERRORDIALOG("OUTPUT DEVICE FAILURE!","There was no output device specified.",NULL,FALSE); } } else { ERRORDIALOG("SCREEN ERROR!","The attempt to retrieve the screen definition failed.",NULL,FALSE); prterr("SCREEN RETRIVAL ERROR: The attempt to retrieve the screen definition failed.",NULL,FALSE); } if(dirname!=NULL) dirname=NULL; if(libname!=NULL) libname=NULL; if(scrnname!=NULL) scrnname=NULL; } static void GetDevicePrintRDAscrncode(RDAscrn *scrn) { RDArsrc *prsrc=NULL; char *defaultprinter=NULL; prsrc=RDArsrcNEW("GUI","PACKAGE BINARY"); defaultprinter=DefaultPrinter(); addstdrsrc(prsrc,"DEVICE",VARIABLETEXT,0,defaultprinter,TRUE); if(defaultprinter!=NULL) Rfree(defaultprinter); addrfkwrsrc(prsrc,"PRINT",TRUE,printRDAscrncode,scrn); addrfkwrsrc(prsrc,"QUIT",TRUE,quit_printRDAscrncode,NULL); addbtnrsrc(prsrc,"HELP",TRUE,screenhelp,NULL); addbtnrsrc(prsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL); addbtnrsrc(prsrc,"DEFAULTS",TRUE,SaveDefaults,NULL); DefaultScreens(prsrc); if(ADVmakescrn(prsrc,TRUE)) { ERRORDIALOG("MAKESCRN FAILED","The Make Screen function failed for the custom screen PACKAGE BINARY. Check to see the screen is available. If it is, call your installer.",NULL,FALSE); free_rsrc(prsrc); } } void okscreencb(RDArsrc *mainrsrc) { RDAscrn *scrn=NULL; int l=0,s=0; char *libname=NULL,*scrnname=NULL,*dirname=NULL; if(FINDRSCGETSTRING(mrsrc,"DIRECTORY",&dirname)) { return; } if(FINDRSCGETINT(mrsrc,"LIBRARY LIST",&l)) { return; } else { libname=stralloc(scr_libs->libs[l]); } if(FINDRSCGETINT(mrsrc,"SCREEN LIST",&s)) { return; } else { scrnname=stralloc(scr_defs->libs[s]); } scrn=okscreen(dirname,libname,scrnname); if(scrn!=NULL) { GetDevicePrintRDAscrncode(scrn); } if(dirname!=NULL) Rfree(dirname); if(libname!=NULL) Rfree(libname); if(scrnname!=NULL) Rfree(scrnname); } static void doliblist(RDArsrc *mainrsrc) { int l=0,s=0; char *libx=NULL; char *dirx=NULL; if(FINDRSCGETSTRING(mainrsrc,"DIRECTORY",&dirx)) return; if(FINDRSCGETINT(mainrsrc,"LIBRARY LIST",&l)) return; FINDRSCGETINT(mainrsrc,"SCREEN LIST",&s); freeapplib(scr_defs); if(!RDAstrcmp(scr_libs->libs[l],"Directory Contains No Libraries")) { scr_defs=APPlibNEW(); addAPPlib(scr_defs,"Contains No Screen Definitions"); s=0; } else { libx=Rmalloc(RDAstrlen(dirx)+RDAstrlen(scr_libs->libs[l])+6); sprintf(libx,"%s/%s.SCN",dirx,scr_libs->libs[l]); scr_defs=getlibnames(libx,FALSE); if(scr_defs==NULL) { scr_defs=APPlibNEW(); addAPPlib(scr_defs,"Contains No Screen Definitions"); s=0; } } if(dirx!=NULL) Rfree(dirx); if(libx!=NULL) Rfree(libx); if(s>=scr_defs->numlibs) s=0; if(!FINDRSCLISTAPPlib(mainrsrc,"SCREEN LIST",s,scr_defs)) { updatersrc(mainrsrc,"SCREEN LIST"); } } static void getscreenlist(RDArsrc *mainrsrc) { int l=0,x=0; char *dirname=NULL; char *tmp=NULL,*dirx=NULL; if(FINDRSCGETSTRING(mainrsrc,"DIRECTORY",&dirname)) { return; } if(FINDRSCGETINT(mainrsrc,"LIBRARY LIST",&l)) { l=0; } if(scr_libs!=NULL) freeapplib(scr_libs); scr_libs=APPlibNEW(); dirx=Rmalloc(RDAstrlen(dirname)+2); sprintf(dirx,"%s/",dirname); for(x=0;findfile(dirx,"*.SCN",&tmp,(int)x+1);++x) { tmp[RDAstrlen(tmp)-4]=0; addAPPlib(scr_libs,tmp); } if(scr_libs->numlibs<1) { addAPPlib(scr_libs,"Directory Contains No Libraries"); } else { SORTAPPlib(scr_libs); } if(tmp!=NULL) Rfree(tmp); if(dirx!=NULL) Rfree(dirx); if(l>=scr_libs->numlibs) l=0; if(!FINDRSCLISTAPPlib(mainrsrc,"LIBRARY LIST",l,scr_libs)) { updatersrc(mainrsrc,"LIBRARY LIST"); } doliblist(mainrsrc); if(dirname!=NULL) Rfree(dirname); } static void setdirlist(RDArsrc *mainrsrc) { int x=0; char *directory=NULL; char inlist=FALSE; readwidget(mainrsrc,"DIRECTORY"); if(FINDRSCGETSTRING(mainrsrc,"DIRECTORY",&directory)) return; inlist=FALSE; for(x=0;x<dir_libs->numlibs;++x) { if(!RDAstrcmp(dir_libs->libs[x],directory)) { inlist=TRUE; break; } } if(inlist!=TRUE) { addAPPlib(dir_libs,directory); x=dir_libs->numlibs-1; } if(directory!=NULL) Rfree(directory); FINDRSCLISTAPPlib(mainrsrc,"DIRECTORY LIST",x,dir_libs); updatersrc(mainrsrc,"DIRECTORY LIST"); getscreenlist(mainrsrc); } static void getdir(RDArsrc *mainrsrc) { int s=0; char *dirstr=NULL; if(FINDRSCGETSTRING(mainrsrc,"DIRECTORY",&dirstr)) return; if(FINDRSCGETINT(mainrsrc,"DIRECTORY LIST",&s)) return; if(RDAstrcmp(dirstr,dir_libs->libs[s])) { if(FINDRSCSETSTRING(mainrsrc,"DIRECTORY",dir_libs->libs[s])) return; updatersrc(mainrsrc,"DIRECTORY"); } if(dirstr!=NULL) Rfree(dirstr); getscreenlist(mainrsrc); } void quitscrncode(RDArsrc *r) { if(r!=NULL) free_rsrc(r); if(scr_libs!=NULL) freeapplib(scr_libs); if(scr_defs!=NULL) freeapplib(scr_defs); if(dir_libs!=NULL) freeapplib(dir_libs); ShutdownSubsystems(); } #ifdef CPPMAIN int c_main(int argc,char **argv) #else int main(int argc,char **argv) #endif { int d=2,l=0,s=0; char *dirname=NULL,*libname=NULL,*scrnname=NULL; char *defdir=NULL; RDAscrn *scrn=NULL; if(argc>2) { if(argc>3) { if(InitializeSubsystems(argc,argv,argv[2],"MAKE SCREEN CODE")) { RDAAPPMAINLOOP(); return; } } else if(argc==3) { if(InitializeSubsystems(argc,argv,argv[1],"MAKE SCREEN CODE")) { RDAAPPMAINLOOP(); return; } } if(argc==3) { dirname=Rmalloc(RDAstrlen(CURRENTDIRECTORY)+5); #ifndef WIN32 sprintf(dirname,"%s/rda",CURRENTDIRECTORY); #endif #ifdef WIN32 sprintf(dirname,"%s\\rda",CURRENTDIRECTORY); #endif libname=stralloc(argv[1]); scrnname=stralloc(argv[2]); } else { dirname=stralloc(argv[1]); libname=stralloc(argv[2]); scrnname=stralloc(argv[3]); } scrn=okscreen(dirname,libname,scrnname); if(scrn!=NULL) { makescrncode(scrn,stdout,dirname,libname,scrnname); } if(scrn!=NULL) Rfree(scrn); if(dirname!=NULL) Rfree(dirname); if(libname!=NULL) Rfree(libname); if(scrnname!=NULL) Rfree(scrnname); ShutdownSubsystems(); } else { if(InitializeSubsystems(argc,argv,"UTILITIES","MAKE SCREEN CODE")) { ShutdownSubsystems(); return; } mrsrc=RDArsrcNEW("TOOLS","MAKE SCREEN CODE"); scr_libs=APPlibNEW(); scr_defs=APPlibNEW(); dir_libs=APPlibNEW(); defdir=Rmalloc(RDAstrlen(CURRENTDIRECTORY)+RDAstrlen(USERLOGIN)+2); #ifndef WIN32 sprintf(defdir,"%s/%s",CURRENTDIRECTORY,USERLOGIN); #endif #ifdef WIN32 sprintf(defdir,"%s\\%s",CURRENTDIRECTORY,USERLOGIN); #endif addAPPlib(dir_libs,defdir); if(defdir!=NULL) Rfree(defdir); defdir=Rmalloc(RDAstrlen(CURRENTDIRECTORY)+6); #ifndef WIN32 sprintf(defdir,"%s/site",CURRENTDIRECTORY); #endif #ifdef WIN32 sprintf(defdir,"%s\\site",CURRENTDIRECTORY); #endif addAPPlib(dir_libs,defdir); if(defdir!=NULL) Rfree(defdir); defdir=Rmalloc(RDAstrlen(CURRENTDIRECTORY)+5); #ifndef WIN32 sprintf(defdir,"%s/rda",CURRENTDIRECTORY); #endif #ifdef WIN32 sprintf(defdir,"%s\\rda",CURRENTDIRECTORY); #endif addAPPlib(dir_libs,defdir); if(defdir!=NULL) Rfree(defdir); addlstrsrc(mrsrc,"DIRECTORY LIST",&d,TRUE,getdir,dir_libs->numlibs,&dir_libs->libs,NULL); addstdrsrc(mrsrc,"DIRECTORY",VARIABLETEXT,0,dir_libs->libs[0],TRUE); if(defdir!=NULL) Rfree(defdir); FINDRSCLISTAPPlib(mrsrc,"DIRECTORY LIST",d,dir_libs); FINDRSCSETFUNC(mrsrc,"DIRECTORY",setdirlist,NULL); addlstrsrc(mrsrc,"LIBRARY LIST",&l,TRUE,doliblist,scr_libs->numlibs,&scr_libs->libs,NULL); addlstrsrc(mrsrc,"SCREEN LIST",&s,TRUE,NULL,scr_defs->numlibs,&scr_defs->libs,NULL); getdir(mrsrc); if(argc>1) { for(l=0;l<scr_libs->numlibs;++l) { if(!RDAstrcmp(argv[1],scr_libs->libs[l])) break; } if(l>=scr_libs->numlibs) { l=0; } } FINDRSCLISTAPPlib(mrsrc,"LIBRARY LIST",l,scr_libs); doliblist(mrsrc); FINDRSCLISTAPPlib(mrsrc,"SCREEN LIST",s,scr_defs); addrfcbrsrc(mrsrc,"SELECT",TRUE,okscreencb,NULL); addrfexrsrc(mrsrc,"QUIT",TRUE,quitscrncode,NULL); addrfcbrsrc(mrsrc,"HELP",TRUE,screenhelp,NULL); addrfcbrsrc(mrsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL); FINDRSCSETINPUTFOCUS(mrsrc,"LIBRARY LIST"); APPmakescrn(mrsrc,TRUE,quitscrncode,NULL,TRUE); RDAAPPMAINLOOP(); } }
[ "tiddbits@comcast.net" ]
tiddbits@comcast.net
23d293816a681a10bbd1af3e366d8d1e8bb361b9
2fcf372234b1bac022f6f659a0ed06e1430d5df5
/Cpp/reference/array_asReference.cpp
be1e920156efea7109c4679f175b49ae2b9cba86
[]
no_license
Apoorve73/Space_For-MathAlgo
8b446aabf60688db26f62ab1312c52012a0e88ab
e41fd6b3145e13948c9fe1add4e6f2ba9b4108aa
refs/heads/master
2023-01-21T06:26:52.491383
2020-11-28T06:10:02
2020-11-28T06:10:02
296,862,637
1
0
null
2020-09-26T16:46:28
2020-09-19T12:20:24
C
UTF-8
C++
false
false
351
cpp
#include <iostream> using namespace std; //Alias of a char[5] using FiveCharCode = char[5]; //'code' is a char(&)[5] void Bar(const FiveCharCode& code) { for(char c : code) { //range-based-for loop works cout << c << "\n"; } } int main() { char code[5] = {'A','B','C','D','E'}; //Call Bar Bar(code); //No explicit length passed return 0; }
[ "apoorve73@gmail.com" ]
apoorve73@gmail.com
d816e2f0aeac397ed1e5a7f231e53eefef9f22dd
b7f3edb5b7c62174bed808079c3b21fb9ea51d52
/third_party/blink/renderer/core/css/cssom/computed_style_property_map_test.cc
946ad25258d42e9712f34edc27e28087fd0b0a8c
[ "LGPL-2.0-or-later", "GPL-1.0-or-later", "MIT", "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause" ]
permissive
otcshare/chromium-src
26a7372773b53b236784c51677c566dc0ad839e4
64bee65c921db7e78e25d08f1e98da2668b57be5
refs/heads/webml
2023-03-21T03:20:15.377034
2020-11-16T01:40:14
2020-11-16T01:40:14
209,262,645
18
21
BSD-3-Clause
2023-03-23T06:20:07
2019-09-18T08:52:07
null
UTF-8
C++
false
false
2,189
cc
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/core/css/cssom/computed_style_property_map.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/renderer/core/html/html_element.h" #include "third_party/blink/renderer/core/testing/page_test_base.h" namespace blink { class ComputedStylePropertyMapTest : public PageTestBase { public: ComputedStylePropertyMapTest() = default; protected: ComputedStylePropertyMap* SetBodyStyle(const AtomicString& style) { GetDocument().body()->setAttribute(html_names::kStyleAttr, style); UpdateAllLifecyclePhasesForTest(); return MakeGarbageCollected<ComputedStylePropertyMap>(GetDocument().body()); } }; TEST_F(ComputedStylePropertyMapTest, TransformMatrixZoom) { ComputedStylePropertyMap* map = SetBodyStyle("transform:matrix(1, 0, 0, 1, 100, 100);zoom:2"); CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(), "transform", ASSERT_NO_EXCEPTION); ASSERT_TRUE(style_value); EXPECT_EQ("matrix(1, 0, 0, 1, 100, 100)", style_value->toString()); } TEST_F(ComputedStylePropertyMapTest, TransformMatrix3DZoom) { ComputedStylePropertyMap* map = SetBodyStyle( "transform:matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, " "1);zoom:2"); CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(), "transform", ASSERT_NO_EXCEPTION); ASSERT_TRUE(style_value); EXPECT_EQ("matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 100, 100, 1)", style_value->toString()); } TEST_F(ComputedStylePropertyMapTest, TransformPerspectiveZoom) { ComputedStylePropertyMap* map = SetBodyStyle("transform:perspective(100px);zoom:2"); CSSStyleValue* style_value = map->get(GetDocument().GetExecutionContext(), "transform", ASSERT_NO_EXCEPTION); ASSERT_TRUE(style_value); EXPECT_EQ("perspective(100px)", style_value->toString()); } } // namespace blink
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
92ee7f30cff47c18b6b1084370ddfe75b8a10a19
2d0bada349646b801a69c542407279cc7bc25013
/examples/waa/apps/resnet50/build_flow/DPUCADF8H_u200/scripts/libs/logger/logger.h
4d9a0f4fb6bbf3433927891585a42a5a83b65993
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "BSD-3-Clause-Open-MPI", "LicenseRef-scancode-free-unknown", "Libtool-exception", "GCC-exception-3.1", "LicenseRef-scancode-mit-old-style", "OFL-1.1", "JSON", "LGPL-2.1-only", "LGPL-2.0-or-later", "ICU", "LicenseRef-scancode-other-permissive...
permissive
Xilinx/Vitis-AI
31e664f7adff0958bb7d149883ab9c231efb3541
f74ddc6ed086ba949b791626638717e21505dba2
refs/heads/master
2023-08-31T02:44:51.029166
2023-07-27T06:50:28
2023-07-27T06:50:28
215,649,623
1,283
683
Apache-2.0
2023-08-17T09:24:55
2019-10-16T21:41:54
Python
UTF-8
C++
false
false
2,932
h
/********** Copyright (c) 2018, Xilinx, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 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 name of the copyright holder 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. **********/ #ifndef LOGGER_H_ #define LOGGER_H_ #include <iomanip> #include <iostream> #include <string> #include <vector> #define ENABLE_LOG_TOFILE 1 #define ENABLE_LOG_TIME 1 //global logging #define LogInfo(desc, ...) sda::LogWrapper(0, __FILE__, __LINE__, desc, ##__VA_ARGS__) #define LogWarn(desc, ...) sda::LogWrapper(1, __FILE__, __LINE__, desc, ##__VA_ARGS__) #define LogError(desc, ...) sda::LogWrapper(2, __FILE__, __LINE__, desc, ##__VA_ARGS__) using namespace std; namespace sda { enum LOGTYPE {etInfo, etWarning, etError}; //string string& ltrim(string& s); string& rtrim(string& s); string& trim(string& s); string GetFileExt(const string& s); string GetFileTitleOnly(const string& s); string ToLower(const string& s); string ToUpper(const string& s); //time string GetTimeStamp(); //paths string GetApplicationPath(); //debug template<typename T> void PrintPOD(const vector<T>& pod, size_t display_count = 0, const int precision = 4) { size_t count = pod.size(); if(display_count > 0) count = std::min<size_t>(pod.size(), display_count); for(size_t i = 0; i < count; i++) { cout << std::setprecision(precision) << pod[i] << ", "; } cout << endl; } //logging void LogWrapper(int etype, const char* file, int line, const char* desc, ...); } #endif /* LOGGER_H_ */
[ "hanxue.lee@xilinx.com" ]
hanxue.lee@xilinx.com
d59255a80837371802863c449171c012c0b0ef6a
330d1e60e0402cfc685d469b44f4a6674614f681
/Src/iberbar/Gui/Widgets/CheckBox.cpp
ba396eedd9eef79a6f07672f8cf0150a9ae29d47
[]
no_license
berbar/iberbarEngine
abeeb7e714f44867c2cf8bc55a2f699a5462e294
87b4d45eca444c34ad6f71326f8fa2063a62ca5d
refs/heads/master
2023-01-23T08:28:12.872280
2022-05-01T16:52:47
2022-05-01T16:52:47
299,245,571
5
1
null
null
null
null
UTF-8
C++
false
false
6,200
cpp
#include <iberbar/Gui/Widgets/CheckBox.h> #include <iberbar/Gui/RenderElement.h> #include <iberbar/Utility/Input.h> iberbar::Gui::CCheckBox::CCheckBox( void ) : m_nCheckState( UCheckState::CheckedFalse ) , m_pRenderElementCheckFalse( nullptr ) , m_pRenderElementCheckTrue( nullptr ) , m_pRenderElementCheckIndeterminate( nullptr ) { } iberbar::Gui::CCheckBox::CCheckBox( const CCheckBox& checkbox ) : CButton( checkbox ) , m_nCheckState( checkbox.m_nCheckState ) , m_pRenderElementCheckFalse( nullptr ) , m_pRenderElementCheckTrue( nullptr ) , m_pRenderElementCheckIndeterminate( nullptr ) { if ( checkbox.m_pRenderElementCheckFalse ) { this->SetRenderElementFalse( checkbox.m_pRenderElementCheckFalse->GetId().c_str() ); } if ( checkbox.m_pRenderElementCheckTrue ) { this->SetRenderElementTrue( checkbox.m_pRenderElementCheckTrue->GetId().c_str() ); } if ( checkbox.m_pRenderElementCheckIndeterminate ) { this->SetRenderElementIndeterminate( checkbox.m_pRenderElementCheckIndeterminate->GetId().c_str() ); } } iberbar::Gui::CCheckBox* iberbar::Gui::CCheckBox::Clone() const { return new CCheckBox( *this ); } iberbar::Gui::UHandleMessageResult iberbar::Gui::CCheckBox::HandleMouse( const UMouseEventData* EventData ) { if ( IsEnable() == false || IsVisible() == false ) return UHandleMessageResult::Ignore; switch ( EventData->nMouseEvent ) { case UMouseEvent::LDoubleClick: case UMouseEvent::LDown: { if ( HitTest( EventData->MousePoint ) == true ) { if ( m_bFocus == false ) { RequestFocus(); } m_bPressed = true; return UHandleMessageResult::Succeed; } break; } // end case case UMouseEvent::LUp: { if ( m_bPressed == true ) { m_bPressed = false; if ( HitTest( EventData->MousePoint ) == true ) { if ( m_nCheckState == UCheckState::CheckedFalse || m_nCheckState == UCheckState::CheckedIndeterminate ) SetCheckedInternal( UCheckState::CheckedTrue, true ); else SetCheckedInternal( UCheckState::CheckedFalse, true ); } return UHandleMessageResult::Succeed; } // end if pressed break; } // end case default:break; } return UHandleMessageResult::Ignore; } iberbar::Gui::UHandleMessageResult iberbar::Gui::CCheckBox::HandleKeyboard( const UKeyboardEventData* EventData ) { if ( IsEnable() == false || IsVisible() == false ) return UHandleMessageResult::Ignore; #if defined(WIN32) switch ( EventData->nEvent ) { case UKeyboardEvent::KeyDown: { if ( m_nHotKey == EventData->nKeyCode ) { RequestFocus(); if ( m_nCheckState == UCheckState::CheckedFalse || m_nCheckState == UCheckState::CheckedIndeterminate ) SetCheckedInternal( UCheckState::CheckedTrue, true ); else SetCheckedInternal( UCheckState::CheckedFalse, true ); return UHandleMessageResult::Succeed; } } break; case UKeyboardEvent::KeyUp: break; default: break; } #endif return UHandleMessageResult::Ignore; } void iberbar::Gui::CCheckBox::SetCheckedInternal( UCheckState nState, bool bInternal ) { if ( nState != m_nCheckState ) { m_nCheckState = nState; if ( bInternal ) SendEvent( BaseEvent::nValueChanged ); } } //----------------------------------------------------------------------------------------- void iberbar::Gui::CCheckBox::Update( float nElapsedTime ) { UWidgetState lc_stateOrdi = UWidgetState::Normal; if ( IsVisible() == false ) lc_stateOrdi = UWidgetState::Hidden; else if ( IsEnable() == false ) lc_stateOrdi = UWidgetState::Disabled; if ( m_pRenderElementDefault ) m_pRenderElementDefault->SetState( (int)lc_stateOrdi ); UWidgetState lc_state = UWidgetState::Normal; if ( IsVisible() == false ) lc_state = UWidgetState::Hidden; else if ( IsEnable() == false ) lc_state = UWidgetState::Disabled; else if ( IsPressed() == true ) lc_state = UWidgetState::Pressed; else if ( GetFocus() == true ) lc_state = UWidgetState::Focus; else if ( GetMouseOver() == true ) lc_state = UWidgetState::MouseOver; if ( m_pRenderElementDefault ) m_pRenderElementDefault->SetState( (int)lc_state ); UWidgetState nStateCheck; if ( m_pRenderElementCheckFalse != nullptr ) { nStateCheck = lc_state; if ( GetChecked() != UCheckState::CheckedFalse ) nStateCheck = UWidgetState::Hidden; m_pRenderElementCheckFalse->SetState( (int)nStateCheck ); } if ( m_pRenderElementCheckTrue != nullptr ) { nStateCheck = lc_state; if ( GetChecked() != UCheckState::CheckedTrue ) nStateCheck = UWidgetState::Hidden; else int s = 0; m_pRenderElementCheckTrue->SetState( (int)nStateCheck ); } if ( m_pRenderElementCheckIndeterminate != nullptr ) { nStateCheck = lc_state; if ( GetChecked() != UCheckState::CheckedIndeterminate ) nStateCheck = UWidgetState::Hidden; m_pRenderElementCheckIndeterminate->SetState( (int)nStateCheck ); } CWidget::Update( nElapsedTime ); } void iberbar::Gui::CCheckBox::SetRenderElementFalse( const char* strElementId ) { if ( m_pRenderElementDefault == nullptr ) { return; } if ( m_pRenderElementDefault->FindElement( strElementId, &m_pRenderElementCheckFalse ) == false ) { UNKNOWN_SAFE_RELEASE_NULL( m_pRenderElementCheckFalse ); } else { m_pRenderElementCheckFalse->GetTransform()->SetParentTransform( this->GetTransform() ); } } void iberbar::Gui::CCheckBox::SetRenderElementTrue( const char* strElementId ) { if ( m_pRenderElementDefault == nullptr ) { return; } if ( m_pRenderElementDefault->FindElement( strElementId, &m_pRenderElementCheckTrue ) == false ) { UNKNOWN_SAFE_RELEASE_NULL( m_pRenderElementCheckTrue ); } else { m_pRenderElementCheckTrue->GetTransform()->SetParentTransform( this->GetTransform() ); } } void iberbar::Gui::CCheckBox::SetRenderElementIndeterminate( const char* strElementId ) { if ( m_pRenderElementDefault == nullptr ) { return; } if ( m_pRenderElementDefault->FindElement( strElementId, &m_pRenderElementCheckIndeterminate ) == false ) { UNKNOWN_SAFE_RELEASE_NULL( m_pRenderElementCheckIndeterminate ); } else { m_pRenderElementCheckIndeterminate->GetTransform()->SetParentTransform( this->GetTransform() ); } }
[ "bigbigbir@hotmail.com" ]
bigbigbir@hotmail.com
e1f287862d1883c033121f368863f9cefe56ab5a
e6084b1f40d1af03ed9fefdf79b540424b44f8bf
/osd.cpp
3a4077304343ad5bcb824805e60b46d69b3d756c
[]
no_license
axnjaxn/sand2
2284a563d5bc56ef722027a41aa1d70a49918fab
7a3d7d5c8fab3ec3b1f972f7a10154f61335ca59
refs/heads/master
2020-05-31T15:42:29.508454
2014-03-05T19:34:16
2014-03-05T19:34:16
16,933,501
1
0
null
null
null
null
UTF-8
C++
false
false
1,495
cpp
/* * osd.cpp * On Screen Display by Brian Jackson * Developed as part of BlameGear: Brian's Lame Game Gear Emulator * Last updated: 3 March 2014 */ #include "osd.h" BBC_Font OSD::font; OSD::OSD() {start = end = 0; setColor(255, 255, 255); setTime(3000); fade = vanish = 0; enabled = 1;} void OSD::setText(const std::string& text) { this->text = text; start = SDL_GetTicks(); end = start + fadetime; } void OSD::setTextf(const char* str, ...) { va_list args; va_start(args, str); char buf[1024]; vsprintf(buf, str, args); setText(buf); } void OSD::setColor(Uint8 r, Uint8 g, Uint8 b) {this->r = r; this->g = g; this->b = b;} void OSD::setTime(Uint32 fadetime) {this->fadetime = fadetime;} void OSD::setVisible(bool enable) {enabled = enable;} void OSD::enableFade(bool enable) {fade = enable;} void OSD::enableVanish(bool enable) {vanish = enable;} bool OSD::isVisible() const { return SDL_GetTicks() < end; } void OSD::render(SDL_Renderer* render, int x, int y, int scale) const { if (!enabled) return; Uint32 t = SDL_GetTicks(); if (t >= end) return; float f = 1.0 - (float)(t - start) / (end - start); if (fade) SDL_SetRenderDrawColor(render, r, g, b, (Uint8)(255.0 * f)); else if (!vanish) SDL_SetRenderDrawColor(render, (Uint8)(f * r), Uint8(f * g), Uint8 (f * b), 255); else SDL_SetRenderDrawColor(render, r, g, b, 255); SDL_Rect rect; rect.x = x; rect.y = y; font.renderString(text.c_str(), render, rect, scale); }
[ "axnjaxn@axnjaxn.com" ]
axnjaxn@axnjaxn.com
9373a91c2864927cb5710b2092aa6333e41c7372
1a885e6e630a7bdc1091d2438e78eb4c8f96c564
/Firmware/FirmwareSource/Remora-OS5/modules/digitalPin/digitalPin.cpp
268786d349a0e01b8f27b8ecfa32ae143bbf3e30
[]
no_license
dlarue/Remora
35b831d226e1282bfc3183fb08eafdfd696d044d
86ea6cdf9666df034138edf6dae2bd15b6f66d6c
refs/heads/main
2023-06-01T03:30:11.913505
2021-03-31T20:11:29
2021-03-31T20:11:29
343,650,960
0
0
null
2021-03-02T04:59:43
2021-03-02T04:59:42
null
UTF-8
C++
false
false
1,037
cpp
#include "digitalPin.h" DigitalPin::DigitalPin(volatile uint8_t &ptrData, int mode, std::string portAndPin, int bitNumber, bool invert) : ptrData(&ptrData), mode(mode), portAndPin(portAndPin), bitNumber(bitNumber), invert(invert) { this->pin = new Pin(this->portAndPin, this->mode); // Input 0x0, Output 0x1 this->mask = 1 << this->bitNumber; } void DigitalPin::update() { bool pinState; if (this->mode == 0) // the pin is configured as an input { pinState = this->pin->get(); if(this->invert) { pinState = !pinState; } if (pinState == 1) // input is high { *(this->ptrData) |= this->mask; } else // input is low { *(this->ptrData) &= ~this->mask; } } else // the pin is configured as an output { pinState = *(this->ptrData) & this->mask; // get the value of the bit in the data source if(this->invert) { pinState = !pinState; } this->pin->set(pinState); // simple conversion to boolean } } void DigitalPin::slowUpdate() { return; }
[ "tanyascottalex@gmail.com" ]
tanyascottalex@gmail.com
6c97e4d60ed5269ea894d95e602db84e3df842af
98410335456794507c518e361c1c52b6a13b0b39
/sprayMASCOTTELAM2/0.18/sprayCloud:UCoeff
42480cec0cc4d30ec3612d21b6aeffa4cfe4d245
[]
no_license
Sebvi26/MASCOTTE
d3d817563f09310dfc8c891d11b351ec761904f3
80241928adec6bcaad85dca1f2159f6591483986
refs/heads/master
2022-10-21T03:19:24.725958
2020-06-14T21:19:38
2020-06-14T21:19:38
270,176,043
0
0
null
null
null
null
UTF-8
C++
false
false
943
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 4.0 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format binary; class volScalarField::Internal; location "0.18"; object sprayCloud:UCoeff; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 0 0 0 0 0 0]; value uniform 0; // ************************************************************************* //
[ "sebastianvi26@gmail.com" ]
sebastianvi26@gmail.com
093ad8e5a721dfeba64f40c1df3251bc968006cc
c9490e5024890764dc9a449e21170d5e816f38cc
/Greedy/IsSubsequence.cpp
3ea35216b92c8f15394947a2ba5c3f8c701ee5db
[]
no_license
Andyato/LeetCode-Note
68b3b5c457bd2950440586971b33ad12abac7c04
fa928c0c9375264a2d386668a624a1da45fa9878
refs/heads/master
2020-03-26T23:09:24.135957
2019-01-29T07:32:03
2019-01-29T07:32:03
145,515,652
0
0
null
null
null
null
UTF-8
C++
false
false
396
cpp
/* leetcode-392 */ #include<string> using namespace std; class Solution { public: bool isSubsequence(string s, string t) { int si = 0, ti = 0; while( si < s.size() && ti < t.size() ) { if(s[si] == t[ti]) { ++si; ++ti; } else ++ti; } return si == s.size(); } };
[ "Andyato@163.com" ]
Andyato@163.com
93ed0a9f7392b6046ab0b179c73866f966dbd449
73ee941896043f9b3e2ab40028d24ddd202f695f
/external/chromium_org/chrome/browser/translate/translate_prefs.cc
303fb213c12c884fffba9487dc01f51851793351
[ "BSD-3-Clause" ]
permissive
CyFI-Lab-Public/RetroScope
d441ea28b33aceeb9888c330a54b033cd7d48b05
276b5b03d63f49235db74f2c501057abb9e79d89
refs/heads/master
2022-04-08T23:11:44.482107
2016-09-22T20:15:43
2016-09-22T20:15:43
58,890,600
5
3
null
null
null
null
UTF-8
C++
false
false
18,005
cc
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/translate/translate_prefs.h" #include "base/command_line.h" #include "base/prefs/pref_service.h" #include "base/strings/string_split.h" #include "base/strings/string_util.h" #include "chrome/browser/prefs/scoped_user_pref_update.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/translate/translate_accept_languages.h" #include "chrome/browser/translate/translate_manager.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/translate/translate_util.h" #include "components/user_prefs/pref_registry_syncable.h" const char TranslatePrefs::kPrefTranslateLanguageBlacklist[] = "translate_language_blacklist"; const char TranslatePrefs::kPrefTranslateSiteBlacklist[] = "translate_site_blacklist"; const char TranslatePrefs::kPrefTranslateWhitelists[] = "translate_whitelists"; const char TranslatePrefs::kPrefTranslateDeniedCount[] = "translate_denied_count"; const char TranslatePrefs::kPrefTranslateAcceptedCount[] = "translate_accepted_count"; const char TranslatePrefs::kPrefTranslateBlockedLanguages[] = "translate_blocked_languages"; namespace { void GetBlacklistedLanguages(const PrefService* prefs, std::vector<std::string>* languages) { DCHECK(languages->empty()); const char* key = TranslatePrefs::kPrefTranslateLanguageBlacklist; const ListValue* list = prefs->GetList(key); for (ListValue::const_iterator it = list->begin(); it != list->end(); ++it) { std::string lang; (*it)->GetAsString(&lang); languages->push_back(lang); } } } // namespace namespace { void AppendLanguageToAcceptLanguages(PrefService* prefs, const std::string& language) { if (!TranslateAcceptLanguages::CanBeAcceptLanguage(language)) return; std::string accept_language = language; TranslateUtil::ToChromeLanguageSynonym(&accept_language); std::string accept_languages_str = prefs->GetString(prefs::kAcceptLanguages); std::vector<std::string> accept_languages; base::SplitString(accept_languages_str, ',', &accept_languages); if (std::find(accept_languages.begin(), accept_languages.end(), accept_language) == accept_languages.end()) { accept_languages.push_back(accept_language); } accept_languages_str = JoinString(accept_languages, ','); prefs->SetString(prefs::kAcceptLanguages, accept_languages_str); } } // namespace // TranslatePrefs: public: ----------------------------------------------------- TranslatePrefs::TranslatePrefs(PrefService* user_prefs) : prefs_(user_prefs) { } bool TranslatePrefs::IsBlockedLanguage( const std::string& original_language) const { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) { return IsValueBlacklisted(kPrefTranslateBlockedLanguages, original_language); } else { return IsValueBlacklisted(kPrefTranslateLanguageBlacklist, original_language); } } void TranslatePrefs::BlockLanguage( const std::string& original_language) { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) { BlacklistValue(kPrefTranslateBlockedLanguages, original_language); AppendLanguageToAcceptLanguages(prefs_, original_language); } else { BlacklistValue(kPrefTranslateLanguageBlacklist, original_language); } } void TranslatePrefs::UnblockLanguage( const std::string& original_language) { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) { RemoveValueFromBlacklist(kPrefTranslateBlockedLanguages, original_language); } else { RemoveValueFromBlacklist(kPrefTranslateLanguageBlacklist, original_language); } } void TranslatePrefs::RemoveLanguageFromLegacyBlacklist( const std::string& original_language) { RemoveValueFromBlacklist(kPrefTranslateLanguageBlacklist, original_language); } bool TranslatePrefs::IsSiteBlacklisted(const std::string& site) const { return IsValueBlacklisted(kPrefTranslateSiteBlacklist, site); } void TranslatePrefs::BlacklistSite(const std::string& site) { BlacklistValue(kPrefTranslateSiteBlacklist, site); } void TranslatePrefs::RemoveSiteFromBlacklist(const std::string& site) { RemoveValueFromBlacklist(kPrefTranslateSiteBlacklist, site); } bool TranslatePrefs::IsLanguagePairWhitelisted( const std::string& original_language, const std::string& target_language) { const DictionaryValue* dict = prefs_->GetDictionary(kPrefTranslateWhitelists); if (dict && !dict->empty()) { std::string auto_target_lang; if (dict->GetString(original_language, &auto_target_lang) && auto_target_lang == target_language) return true; } return false; } void TranslatePrefs::WhitelistLanguagePair( const std::string& original_language, const std::string& target_language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateWhitelists); DictionaryValue* dict = update.Get(); if (!dict) { NOTREACHED() << "Unregistered translate whitelist pref"; return; } dict->SetString(original_language, target_language); } void TranslatePrefs::RemoveLanguagePairFromWhitelist( const std::string& original_language, const std::string& target_language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateWhitelists); DictionaryValue* dict = update.Get(); if (!dict) { NOTREACHED() << "Unregistered translate whitelist pref"; return; } dict->Remove(original_language, NULL); } bool TranslatePrefs::HasBlacklistedLanguages() const { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) return !IsListEmpty(kPrefTranslateBlockedLanguages); else return !IsListEmpty(kPrefTranslateLanguageBlacklist); } void TranslatePrefs::ClearBlacklistedLanguages() { CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) prefs_->ClearPref(kPrefTranslateBlockedLanguages); else prefs_->ClearPref(kPrefTranslateLanguageBlacklist); } bool TranslatePrefs::HasBlacklistedSites() const { return !IsListEmpty(kPrefTranslateSiteBlacklist); } void TranslatePrefs::ClearBlacklistedSites() { prefs_->ClearPref(kPrefTranslateSiteBlacklist); } bool TranslatePrefs::HasWhitelistedLanguagePairs() const { return !IsDictionaryEmpty(kPrefTranslateWhitelists); } void TranslatePrefs::ClearWhitelistedLanguagePairs() { prefs_->ClearPref(kPrefTranslateWhitelists); } int TranslatePrefs::GetTranslationDeniedCount( const std::string& language) const { const DictionaryValue* dict = prefs_->GetDictionary(kPrefTranslateDeniedCount); int count = 0; return dict->GetInteger(language, &count) ? count : 0; } void TranslatePrefs::IncrementTranslationDeniedCount( const std::string& language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateDeniedCount); DictionaryValue* dict = update.Get(); int count = 0; dict->GetInteger(language, &count); dict->SetInteger(language, count + 1); } void TranslatePrefs::ResetTranslationDeniedCount(const std::string& language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateDeniedCount); update.Get()->SetInteger(language, 0); } int TranslatePrefs::GetTranslationAcceptedCount(const std::string& language) { const DictionaryValue* dict = prefs_->GetDictionary(kPrefTranslateAcceptedCount); int count = 0; return dict->GetInteger(language, &count) ? count : 0; } void TranslatePrefs::IncrementTranslationAcceptedCount( const std::string& language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateAcceptedCount); DictionaryValue* dict = update.Get(); int count = 0; dict->GetInteger(language, &count); dict->SetInteger(language, count + 1); } void TranslatePrefs::ResetTranslationAcceptedCount( const std::string& language) { DictionaryPrefUpdate update(prefs_, kPrefTranslateAcceptedCount); update.Get()->SetInteger(language, 0); } // TranslatePrefs: public, static: --------------------------------------------- // static bool TranslatePrefs::CanTranslateLanguage(Profile* profile, const std::string& language) { TranslatePrefs translate_prefs(profile->GetPrefs()); bool blocked = translate_prefs.IsBlockedLanguage(language); CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kEnableTranslateSettings)) { bool is_accept_language = TranslateManager::IsAcceptLanguage(profile, language); bool can_be_accept_language = TranslateAcceptLanguages::CanBeAcceptLanguage(language); // Don't translate any user black-listed languages. Checking // |is_accept_language| is necessary because if the user eliminates the // language from the preference, it is natural to forget whether or not // the language should be translated. Checking |cannot_be_accept_language| // is also necessary because some minor languages can't be selected in the // language preference even though the language is available in Translate // server. if (blocked && (is_accept_language || !can_be_accept_language)) return false; } else { // Don't translate any user user selected language. if (blocked) return false; } return true; } // static bool TranslatePrefs::ShouldAutoTranslate(PrefService* user_prefs, const std::string& original_language, std::string* target_language) { TranslatePrefs prefs(user_prefs); return prefs.IsLanguageWhitelisted(original_language, target_language); } // static void TranslatePrefs::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { registry->RegisterListPref(kPrefTranslateLanguageBlacklist, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterListPref(kPrefTranslateSiteBlacklist, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterDictionaryPref( kPrefTranslateWhitelists, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterDictionaryPref( kPrefTranslateDeniedCount, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterDictionaryPref( kPrefTranslateAcceptedCount, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); registry->RegisterListPref(kPrefTranslateBlockedLanguages, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); } // static void TranslatePrefs::MigrateUserPrefs(PrefService* user_prefs) { // Old format of kPrefTranslateWhitelists // - original language -> list of target langs to auto-translate // - list of langs is in order of being enabled i.e. last in list is the // most recent language that user enabled via // Always translate |source_lang| to |target_lang|" // - this results in a one-to-n relationship between source lang and target // langs. // New format: // - original language -> one target language to auto-translate // - each time that the user enables the "Always translate..." option, that // target lang overwrites the previous one. // - this results in a one-to-one relationship between source lang and target // lang // - we replace old list of target langs with the last target lang in list, // assuming the last (i.e. most recent) target lang is what user wants to // keep auto-translated. DictionaryPrefUpdate update(user_prefs, kPrefTranslateWhitelists); DictionaryValue* dict = update.Get(); if (dict && !dict->empty()) { DictionaryValue::Iterator iter(*dict); while (!iter.IsAtEnd()) { const ListValue* list = NULL; if (!iter.value().GetAsList(&list) || !list) break; // Dictionary has either been migrated or new format. std::string key = iter.key(); // Advance the iterator before removing the current element. iter.Advance(); std::string target_lang; if (list->empty() || !list->GetString(list->GetSize() - 1, &target_lang) || target_lang.empty()) { dict->Remove(key, NULL); } else { dict->SetString(key, target_lang); } } } // Get the union of the blacklist and the Accept languages, and set this to // the new language set 'translate_blocked_languages'. This is used for the // settings UI for Translate and configration to determine which langauage // should be translated instead of the blacklist. The blacklist is no longer // used after launching the settings UI. // After that, Set 'translate_languages_not_translate' to Accept languages to // enable settings for users. bool merged = user_prefs->HasPrefPath(kPrefTranslateBlockedLanguages); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); bool enabled_translate_settings = command_line.HasSwitch(switches::kEnableTranslateSettings); if (!merged && enabled_translate_settings) { std::vector<std::string> blacklisted_languages; GetBlacklistedLanguages(user_prefs, &blacklisted_languages); std::string accept_languages_str = user_prefs->GetString(prefs::kAcceptLanguages); std::vector<std::string> accept_languages; base::SplitString(accept_languages_str, ',', &accept_languages); std::vector<std::string> blocked_languages; CreateBlockedLanguages(&blocked_languages, blacklisted_languages, accept_languages); // Create the new preference kPrefTranslateBlockedLanguages. { ListValue* blocked_languages_list = new ListValue(); for (std::vector<std::string>::const_iterator it = blocked_languages.begin(); it != blocked_languages.end(); ++it) { blocked_languages_list->Append(new StringValue(*it)); } ListPrefUpdate update(user_prefs, kPrefTranslateBlockedLanguages); ListValue* list = update.Get(); DCHECK(list != NULL); list->Swap(blocked_languages_list); } // Update kAcceptLanguages for (std::vector<std::string>::const_iterator it = blocked_languages.begin(); it != blocked_languages.end(); ++it) { std::string lang = *it; TranslateUtil::ToChromeLanguageSynonym(&lang); bool not_found = std::find(accept_languages.begin(), accept_languages.end(), lang) == accept_languages.end(); if (not_found) accept_languages.push_back(lang); } std::string new_accept_languages_str = JoinString(accept_languages, ","); user_prefs->SetString(prefs::kAcceptLanguages, new_accept_languages_str); } } // TranslatePrefs: private: ---------------------------------------------------- // static void TranslatePrefs::CreateBlockedLanguages( std::vector<std::string>* blocked_languages, const std::vector<std::string>& blacklisted_languages, const std::vector<std::string>& accept_languages) { DCHECK(blocked_languages->empty()); std::set<std::string> result; for (std::vector<std::string>::const_iterator it = blacklisted_languages.begin(); it != blacklisted_languages.end(); ++it) { result.insert(*it); } for (std::vector<std::string>::const_iterator it = accept_languages.begin(); it != accept_languages.end(); ++it) { std::string lang = *it; TranslateUtil::ToTranslateLanguageSynonym(&lang); result.insert(lang); } blocked_languages->insert(blocked_languages->begin(), result.begin(), result.end()); } bool TranslatePrefs::IsValueInList(const ListValue* list, const std::string& in_value) const { for (size_t i = 0; i < list->GetSize(); ++i) { std::string value; if (list->GetString(i, &value) && value == in_value) return true; } return false; } bool TranslatePrefs::IsValueBlacklisted(const char* pref_id, const std::string& value) const { const ListValue* blacklist = prefs_->GetList(pref_id); return (blacklist && !blacklist->empty() && IsValueInList(blacklist, value)); } void TranslatePrefs::BlacklistValue(const char* pref_id, const std::string& value) { { ListPrefUpdate update(prefs_, pref_id); ListValue* blacklist = update.Get(); if (!blacklist) { NOTREACHED() << "Unregistered translate blacklist pref"; return; } blacklist->Append(new StringValue(value)); } } void TranslatePrefs::RemoveValueFromBlacklist(const char* pref_id, const std::string& value) { ListPrefUpdate update(prefs_, pref_id); ListValue* blacklist = update.Get(); if (!blacklist) { NOTREACHED() << "Unregistered translate blacklist pref"; return; } StringValue string_value(value); blacklist->Remove(string_value, NULL); } bool TranslatePrefs::IsLanguageWhitelisted( const std::string& original_language, std::string* target_language) const { const DictionaryValue* dict = prefs_->GetDictionary(kPrefTranslateWhitelists); if (dict && dict->GetString(original_language, target_language)) { DCHECK(!target_language->empty()); return !target_language->empty(); } return false; } bool TranslatePrefs::IsListEmpty(const char* pref_id) const { const ListValue* blacklist = prefs_->GetList(pref_id); return (blacklist == NULL || blacklist->empty()); } bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { const DictionaryValue* dict = prefs_->GetDictionary(pref_id); return (dict == NULL || dict->empty()); }
[ "ProjectRetroScope@gmail.com" ]
ProjectRetroScope@gmail.com
37f10f8dc42a9f4c337d1b866e522e0eda3dc0ec
94e5a9e157d3520374d95c43fe6fec97f1fc3c9b
/UVA/13086.cpp
3cd562da79a52141e93cdfb964bf8961a778c621
[ "MIT" ]
permissive
dipta007/Competitive-Programming
0127c550ad523884a84eb3ea333d08de8b4ba528
998d47f08984703c5b415b98365ddbc84ad289c4
refs/heads/master
2021-01-21T14:06:40.082553
2020-07-06T17:40:46
2020-07-06T17:40:46
54,851,014
8
4
null
2020-05-02T13:14:41
2016-03-27T22:30:02
C++
UTF-8
C++
false
false
4,885
cpp
//#include <algorithm> //#include <bitset> //#include <cassert> //#include <cctype> //#include <climits> //#include <cmath> //#include <cstdio> //#include <cstdlib> //#include <cstring> //#include <fstream> //#include <iostream> //#include <iomanip> //#include <iterator> //#include <list> //#include <map> //#include <numeric> //#include <queue> //#include <set> //#include <sstream> //#include <stack> //#include <string> //#include <utility> //#include <vector> #include <bits/stdc++.h> using namespace std; //#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define READ(f) freopen(f, "r", stdin) #define WRITE(f) freopen(f, "w", stdout) #define MP(x, y) make_pair(x, y) #define PB(x) push_back(x) #define FOR(i,L,R) for (int i = (int)(L); i <= (int)(R); i++) #define ROF(i,L,R) for (int i = (int)(L); i >= (int)(R); i--) #define ALL(p) p.begin(),p.end() #define ALLR(p) p.rbegin(),p.rend() #define SET(p) memset(p, -1, sizeof(p)) #define CLR(p) memset(p, 0, sizeof(p)) #define getI(a) scanf("%d", &a) #define getII(a,b) scanf("%d%d", &a, &b) #define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c) #define getL(a) scanf("%lld",&a) #define getLL(a,b) scanf("%lld%lld",&a,&b) #define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define getF(n) scanf("%lf",&n) #define bitCheck(N,in) ((bool)(N&(1<<(in)))) #define bitOn(N,in) (N|(1<<(in))) #define bitOff(N,in) (N&(~(1<<(in)))) #define bitFlip(a,k) (a^(1<<(k))) #define bitCount(a) __builtin_popcount(a) #define bitCountLL(a) __builtin_popcountll(a) #define bitLeftMost(a) (63-__builtin_clzll((a))) #define bitRightMost(a) (__builtin_ctzll(a)) #define ranL(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a)) #define ranI(a, b) ((((ll)rand() * rand()) % ((b) - (a) + 1)) + (a)) #define ranF(a, b) (((double)rand()/RAND_MAX)*((b) - (a)) + (a)) #define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end()) #define setInf(ar) memset(ar,126,sizeof ar) #define ff first #define ss second #define sf scanf #define pf printf typedef long long ll; typedef unsigned long long ull; typedef vector < int > vi; typedef vector < vi > vii; typedef pair < int, int> pii; #define FMT(...) (sprintf(CRTBUFF, __VA_ARGS__)?CRTBUFF:0) char CRTBUFF[30000]; #ifdef dipta007 #define debug(args...) {cerr<<"Debug: "; dbg,args; cerr<<endl;} #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__) template <typename Arg1> void __f(const char* name, Arg1&& arg1){ cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...); } #else #define debug(args...) /// Just strip off all debug tokens #define trace(...) ///yeeeee #endif struct debugger{ template<typename T> debugger& operator , (const T& v){ cerr<<v<<" "; return *this; } }dbg; const double EPS = 1e-9; const int INF = 0x3f3f3f3f; const double PI = 2.0 * acos(0.0); ll MIN() { return INF; } template <typename T, typename... Args > inline T MIN(T a, Args... args) { return min(a, (T)MIN(args...)); } ll MAX() { return -INF; } template <typename T, typename... Args > inline T MAX(T a, Args... args) { return max(a, (T)MAX(args...)); } // g++ -g -O2 -std=gnu++11 A.cpp // ./a.out ///****************** template ends here **************** ll a[100004]; ll mark[100004]; int main() { #ifdef dipta007 //READ("in.txt"); //WRITE("out.txt"); #endif // dipta007 ios_base::sync_with_stdio(0);cin.tie(0); int t; cin >> t; FOR(ci,1,t) { ll n, m; cin >> n >> m; ll p, q, r, x, y, z; cin >> p >> q >> r >> x >> y >> z; FOR(i,1,n) a[i] = (p * i * i + q * i + r) % 1000007; FOR(i,1,n) trace(a[i]); CLR(mark); FOR(i,1,m) { ll now = (x * i * i + y * i + z)%n; mark[now+1] = 1; trace(now); } ll sum = 0; ll mn = LLONG_MAX; FOR(i,1,n) { sum += a[i]; if(!mark[i]) mn = min(mn, a[i]); trace(mn); } sum -= mn; cout << "Case " << ci << ": "; cout << sum * mn << endl; } return 0; }
[ "iamdipta@gmail.com" ]
iamdipta@gmail.com
3d9bdc7b2e0d6c3c61489749f33d282fe3acc650
0e7164d7ab0f00d5e896abb6103bd6dae45b682f
/src/JsonParser.h
e40a2691d7f6f9ec7fa426030d517e251b99f233
[ "MIT" ]
permissive
ndongmo/DroneLib
02189afb771ab1e1dc7f87a7e94d66d23a9af04a
494f3c94be58ba1eb2310961abb15e82bdc68531
refs/heads/master
2020-04-29T09:53:22.726387
2019-03-17T14:01:03
2019-03-17T14:01:03
176,042,145
4
0
null
null
null
null
UTF-8
C++
false
false
417
h
/*! * \file JsonParser.h * \brief Json parser class. * \author Ndongmo Silatsa Fabrice * \date 09-03-2019 * \version 1.0 */ #pragma once #include <map> #include <string> class JsonParser { public: JsonParser& add(const std::string& key, const std::string& value); int decode(char* json); std::string get(const std::string& key); std::string getJson(); private: std::map<std::string, std::string> m_data; };
[ "barosndongmo@yahoo.fr" ]
barosndongmo@yahoo.fr
1f86b3cd2006633e304bfb83cd8aa4bff00b946d
2939270daa498d290ded456e7f684bd8f1a02711
/Dont Touch The Spike v2.0/include/Texture.h
a7e6dc3009638cb7c531e351d2c205b01b2bd92a
[]
no_license
tuananhlai/dont_touch_the_spike
bd95cecfee62cc47bfdcfa53919c34403f1cf8cc
52f6a11a1f8606479e2ef88af98982d6f3a49d51
refs/heads/master
2022-01-08T08:19:55.329484
2019-05-08T14:23:49
2019-05-08T14:23:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,019
h
#ifndef TEXTURE_H #define TEXTURE_H #include <iostream> #include <string> #include <vector> #include <SDL.h> #include <SDL_image.h> #include <SDL_ttf.h> #include <SDL_mixer.h> using namespace std; //đây là base class cho mấy cái class kia class Texture { public: void logSDLError(ostream& os, const string &msg, bool fatal); //hàm báo lỗi void free(SDL_Texture*); //hàm giải phóng tài nguyên SDL_Texture* loadFromFile(string path, SDL_Renderer*); //hàm load file ảnh void render(int, int, int, int, int, SDL_Renderer*, double, SDL_Point*, SDL_RendererFlip); //hàm render (dùng đc trong mọi điều kiện) int getWidth(int i); int getHeight(int i); float getX(int i); float getY(int i); protected: vector <int> width, height; vector <float> x, y; vector <SDL_Texture*> texture; private: }; #endif // TEXTURE_H
[ "laituananh1711@gmail.com" ]
laituananh1711@gmail.com
02891e7541816576b0e489588de152567b72bc44
cfa65bb0d577efd427f4aa86b57f8f0dcd909aca
/AADC/src/adtfUser/dev/src/signalSenderFilter/signal_sender_filter.cpp
8eaf6d629b27be0f49ccc17fea862d0690b4b939
[ "BSD-2-Clause" ]
permissive
AADC-Fruit/AADC_2015_FRUIT
33f61d87f75763b3e8c4c943715d93ba2e28f33c
88bd18871228cb48c46a3bd803eded6f14dbac08
refs/heads/master
2021-01-18T13:51:33.907328
2015-10-05T10:32:31
2015-10-05T10:32:31
41,482,833
1
0
null
null
null
null
UTF-8
C++
false
false
4,640
cpp
#include "stdafx.h" #include "signal_sender_filter.h" #include <template_data.h> // ------------------------------------------------------------------------------------------------- ADTF_FILTER_PLUGIN("FRUIT Sender Filter Signal", OID_ADTF_SIGNAL_SENDER_FILTER, SignalSenderFilter); // ------------------------------------------------------------------------------------------------- // ------------------------------------------------------------------------------------------------- SignalSenderFilter::SignalSenderFilter(const tChar* __info) : adtf::cTimeTriggeredFilter(__info) { // ------------------------------------------------------------------------------------------------- SetPropertyInt("value", 1); SetPropertyInt("start_delay", 10); SetPropertyInt("interval_ms", 100); SetPropertyBool("debug", false); } // ------------------------------------------------------------------------------------------------- SignalSenderFilter::~SignalSenderFilter() { // ------------------------------------------------------------------------------------------------- } // ------------------------------------------------------------------------------------------------- tResult SignalSenderFilter::Init(tInitStage eStage, __exception) { // ------------------------------------------------------------------------------------------------- // never miss calling the parent implementation!! RETURN_IF_FAILED(cFilter::Init(eStage, __exception_ptr)) // Initialize the descriptors and media type stuff here cObjectPtr<IMediaDescriptionManager> description_manager; RETURN_IF_FAILED(_runtime->GetObject(OID_ADTF_MEDIA_DESCRIPTION_MANAGER, IID_ADTF_MEDIA_DESCRIPTION_MANAGER,(tVoid**)&description_manager,__exception_ptr)); if (eStage == StageFirst) { // Create and register the output pin tChar const * stream_description = description_manager->GetMediaDescription("tSignalValue"); RETURN_IF_POINTER_NULL(stream_description); cObjectPtr<IMediaType> output_type = new cMediaType(0, 0, 0, "tSignalValue", stream_description,IMediaDescription::MDF_DDL_DEFAULT_VERSION); RETURN_IF_FAILED(output_type->GetInterface(IID_ADTF_MEDIA_TYPE_DESCRIPTION, (tVoid**)&output_stream_description_)); RETURN_IF_FAILED(data_.Create("signal", output_type, NULL)); RETURN_IF_FAILED(RegisterPin(&data_)); } else if (eStage == StageNormal) { // In this stage you would do further initialisation and/or create your dynamic pins. // Please take a look at the demo_dynamicpin example for further reference. } else if (eStage == StageGraphReady) { // All pin connections have been established in this stage so you can query your pins // about their media types and additional meta data. // Please take a look at the demo_imageproc example for further reference. this->SetInterval(GetPropertyInt("interval_ms") * 1000); counter_ = 0; debug_ = GetPropertyBool("debug"); } RETURN_NOERROR; } // ------------------------------------------------------------------------------------------------- tResult SignalSenderFilter::Shutdown(tInitStage eStage, __exception) { // ------------------------------------------------------------------------------------------------- // Call the base class implementation return cFilter::Shutdown(eStage, __exception_ptr); } // ------------------------------------------------------------------------------------------------- tResult SignalSenderFilter::Cycle(__exception) { // ------------------------------------------------------------------------------------------------- if (counter_ < GetPropertyInt("start_delay") * (1000.0f / GetPropertyInt("interval_ms"))) { counter_++; RETURN_NOERROR; } cObjectPtr<IMediaSample> pMediaSample; AllocMediaSample((tVoid**)&pMediaSample); //allocate memory with the size given by the descriptor cObjectPtr<IMediaSerializer> pSerializer; output_stream_description_->GetMediaSampleSerializer(&pSerializer); tInt nSize = pSerializer->GetDeserializedSize(); pMediaSample->AllocBuffer(nSize); tFloat32 value = (tFloat32) GetPropertyInt("value"); tUInt32 timeStamp = 0; { __adtf_sample_write_lock_mediadescription(output_stream_description_, pMediaSample, coder); coder->Set("f32Value", (tVoid*) &value); coder->Set("ui32ArduinoTimestamp", (tVoid*) &timeStamp); } //transmit media sample over output pin pMediaSample->SetTime(_clock->GetStreamTime()); if (debug_) LOG_INFO(cString::Format("Sending value: %f", value)); data_.Transmit(pMediaSample); RETURN_NOERROR; }
[ "riestern@fp-10-126-42-205.eduroam-fp.privat" ]
riestern@fp-10-126-42-205.eduroam-fp.privat
f4946a0bd84327aa39e373bbf22e2a405b901a04
e7856715c0551a4ab1f1a67d3a98a7d9ea4f0d00
/projectDMiTI/NaturalNumbera/MUL_ND_N.h
dfef94ff956e8a8920374f466df5f57f419ac6fa
[]
no_license
Linoliumer/com-Alg-Sys
ccd3c05953897370052b786809e3f8b668837322
11310264b5618c636033e2d19c151c7f29b2bdc8
refs/heads/main
2023-06-11T19:45:25.658453
2021-07-02T23:29:22
2021-07-02T23:29:22
382,426,294
0
0
null
null
null
null
UTF-8
C++
false
false
165
h
#pragma once #include <vector> #include "generalNatNum.h" /*Multiplication of natural number on digit*/ NaturalNumber MUL_ND_N(NaturalNumber& number, int& digit);
[ "54356735+Linoliumer@users.noreply.github.com" ]
54356735+Linoliumer@users.noreply.github.com
ddc43383db93cc3b9d1f0ee5ca383e4e75cc2597
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
/Engine/Source/ThirdParty/IntelTBB/IntelTBB-4.0/src/tbb/tbb_main.cpp
b7a3219062581326837c2a59f30f5bb6a44a7e44
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
windystrife/UnrealEngine_NVIDIAGameWorks
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
b50e6338a7c5b26374d66306ebc7807541ff815e
refs/heads/4.18-GameWorks
2023-03-11T02:50:08.471040
2022-01-13T20:50:29
2022-01-13T20:50:29
124,100,479
262
179
MIT
2022-12-16T05:36:38
2018-03-06T15:44:09
C++
UTF-8
C++
false
false
8,946
cpp
/* Copyright 2005-2012 Intel Corporation. All Rights Reserved. The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material is protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intel's prior express written permission. No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing. */ #include "tbb/tbb_config.h" #include "tbb_main.h" #include "governor.h" #include "tbb_misc.h" #include "itt_notify.h" namespace tbb { namespace internal { //------------------------------------------------------------------------ // Begin shared data layout. // The following global data items are mostly read-only after initialization. //------------------------------------------------------------------------ //! Padding in order to prevent false sharing. static const char _pad[NFS_MaxLineSize - sizeof(int)] = {}; //------------------------------------------------------------------------ // governor data basic_tls<generic_scheduler*> governor::theTLS; unsigned governor::DefaultNumberOfThreads; rml::tbb_factory governor::theRMLServerFactory; bool governor::UsePrivateRML; //------------------------------------------------------------------------ // market data market* market::theMarket; market::global_market_mutex_type market::theMarketMutex; //------------------------------------------------------------------------ // One time initialization data //! Counter of references to global shared resources such as TLS. atomic<int> __TBB_InitOnce::count; __TBB_atomic_flag __TBB_InitOnce::InitializationLock; //! Flag that is set to true after one-time initializations are done. bool __TBB_InitOnce::InitializationDone; #if DO_ITT_NOTIFY static bool ITT_Present; static bool ITT_InitializationDone; #endif #if !(_WIN32||_WIN64) || __TBB_SOURCE_DIRECTLY_INCLUDED static __TBB_InitOnce __TBB_InitOnceHiddenInstance; #endif //------------------------------------------------------------------------ // generic_scheduler data //! Pointer to the scheduler factory function generic_scheduler* (*AllocateSchedulerPtr)( arena*, size_t index ); //! Table of primes used by fast random-number generator (FastRandom). /** Also serves to keep anything else from being placed in the same cache line as the global data items preceding it. */ static const unsigned Primes[] = { 0x9e3779b1, 0xffe6cc59, 0x2109f6dd, 0x43977ab5, 0xba5703f5, 0xb495a877, 0xe1626741, 0x79695e6b, 0xbc98c09f, 0xd5bee2b3, 0x287488f9, 0x3af18231, 0x9677cd4d, 0xbe3a6929, 0xadc6a877, 0xdcf0674b, 0xbe4d6fe9, 0x5f15e201, 0x99afc3fd, 0xf3f16801, 0xe222cfff, 0x24ba5fdb, 0x0620452d, 0x79f149e3, 0xc8b93f49, 0x972702cd, 0xb07dd827, 0x6c97d5ed, 0x085a3d61, 0x46eb5ea7, 0x3d9910ed, 0x2e687b5b, 0x29609227, 0x6eb081f1, 0x0954c4e1, 0x9d114db9, 0x542acfa9, 0xb3e6bd7b, 0x0742d917, 0xe9f3ffa7, 0x54581edb, 0xf2480f45, 0x0bb9288f, 0xef1affc7, 0x85fa0ca7, 0x3ccc14db, 0xe6baf34b, 0x343377f7, 0x5ca19031, 0xe6d9293b, 0xf0a9f391, 0x5d2e980b, 0xfc411073, 0xc3749363, 0xb892d829, 0x3549366b, 0x629750ad, 0xb98294e5, 0x892d9483, 0xc235baf3, 0x3d2402a3, 0x6bdef3c9, 0xbec333cd, 0x40c9520f }; //------------------------------------------------------------------------ // End of shared data layout //------------------------------------------------------------------------ //------------------------------------------------------------------------ // Shared data accessors //------------------------------------------------------------------------ unsigned GetPrime ( unsigned seed ) { return Primes[seed%(sizeof(Primes)/sizeof(Primes[0]))]; } //------------------------------------------------------------------------ // __TBB_InitOnce //------------------------------------------------------------------------ void __TBB_InitOnce::add_ref() { if( ++count==1 ) governor::acquire_resources(); } void __TBB_InitOnce::remove_ref() { int k = --count; __TBB_ASSERT(k>=0,"removed __TBB_InitOnce ref that was not added?"); if( k==0 ) governor::release_resources(); } //------------------------------------------------------------------------ // One-time Initializations //------------------------------------------------------------------------ //! Defined in cache_aligned_allocator.cpp void initialize_cache_aligned_allocator(); //! Defined in scheduler.cpp void Scheduler_OneTimeInitialization ( bool itt_present ); #if DO_ITT_NOTIFY /** Thread-unsafe lazy one-time initialization of tools interop. Used by both dummy handlers and general TBB one-time initialization routine. **/ void ITT_DoUnsafeOneTimeInitialization () { if ( !ITT_InitializationDone ) { ITT_Present = (__TBB_load_ittnotify()!=0); ITT_InitializationDone = true; ITT_SYNC_CREATE(&market::theMarketMutex, SyncType_GlobalLock, SyncObj_SchedulerInitialization); } } /** Thread-safe lazy one-time initialization of tools interop. Used by dummy handlers only. **/ extern "C" void ITT_DoOneTimeInitialization() { __TBB_InitOnce::lock(); ITT_DoUnsafeOneTimeInitialization(); __TBB_InitOnce::unlock(); } #endif /* DO_ITT_NOTIFY */ //! Performs thread-safe lazy one-time general TBB initialization. void DoOneTimeInitializations() { __TBB_InitOnce::lock(); // No fence required for load of InitializationDone, because we are inside a critical section. if( !__TBB_InitOnce::InitializationDone ) { __TBB_InitOnce::add_ref(); if( GetBoolEnvironmentVariable("TBB_VERSION") ) PrintVersion(); bool itt_present = false; #if DO_ITT_NOTIFY ITT_DoUnsafeOneTimeInitialization(); itt_present = ITT_Present; #endif /* DO_ITT_NOTIFY */ initialize_cache_aligned_allocator(); governor::initialize_rml_factory(); Scheduler_OneTimeInitialization( itt_present ); // Force processor groups support detection governor::default_num_threads(); // Dump version data governor::print_version_info(); PrintExtraVersionInfo( "Tools support", itt_present ? "enabled" : "disabled" ); __TBB_InitOnce::InitializationDone = true; } __TBB_InitOnce::unlock(); } #if (_WIN32||_WIN64) && !__TBB_SOURCE_DIRECTLY_INCLUDED && !__TBB_BUILD_LIB__ //! Windows "DllMain" that handles startup and shutdown of dynamic library. extern "C" bool WINAPI DllMain( HANDLE /*hinstDLL*/, DWORD reason, LPVOID /*lpvReserved*/ ) { switch( reason ) { case DLL_PROCESS_ATTACH: __TBB_InitOnce::add_ref(); break; case DLL_PROCESS_DETACH: __TBB_InitOnce::remove_ref(); // It is assumed that InitializationDone is not set after DLL_PROCESS_DETACH, // and thus no race on InitializationDone is possible. if( __TBB_InitOnce::initialization_done() ) { // Remove reference that we added in DoOneTimeInitializations. __TBB_InitOnce::remove_ref(); } break; case DLL_THREAD_DETACH: governor::terminate_auto_initialized_scheduler(); break; } return true; } #endif /* (_WIN32||_WIN64) && !__TBB_SOURCE_DIRECTLY_INCLUDED && !__TBB_BUILD_LIB__ */ void itt_store_pointer_with_release_v3( void* dst, void* src ) { ITT_NOTIFY(sync_releasing, dst); __TBB_store_with_release(*static_cast<void**>(dst),src); } void* itt_load_pointer_with_acquire_v3( const void* src ) { void* result = __TBB_load_with_acquire(*static_cast<void*const*>(src)); ITT_NOTIFY(sync_acquired, const_cast<void*>(src)); return result; } #if DO_ITT_NOTIFY void call_itt_notify_v5(int t, void *ptr) { switch (t) { case 0: ITT_NOTIFY(sync_prepare, ptr); break; case 1: ITT_NOTIFY(sync_cancel, ptr); break; case 2: ITT_NOTIFY(sync_acquired, ptr); break; case 3: ITT_NOTIFY(sync_releasing, ptr); break; } } #else void call_itt_notify_v5(int /*t*/, void* /*ptr*/) {} #endif void* itt_load_pointer_v3( const void* src ) { void* result = *static_cast<void*const*>(src); return result; } void itt_set_sync_name_v3( void* obj, const tchar* name) { ITT_SYNC_RENAME(obj, name); suppress_unused_warning(obj && name); } } // namespace internal } // namespace tbb
[ "tungnt.rec@gmail.com" ]
tungnt.rec@gmail.com
86936c3880594064f6ee0877a42f3ab4131d83a5
664708a11be33ae5679579cfc689c1784a438e88
/src/core/primitives/mc-loader/Model.hpp
455bfc2d39dcc2a9309c0469c87785c4ccfa5323
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "Zlib", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-3-Clause", "Unlicense", "LicenseRef-scancode-unknown-license-reference" ]
permissive
westlicht/tungsten
b432481395d1821e3c9675bf9743830ad0427292
457c65226734784cb4d03a0d4846bc6797ab9bb7
refs/heads/master
2021-01-15T17:20:59.092867
2016-02-27T18:29:43
2016-02-27T18:29:43
31,969,536
2
0
null
2015-03-10T16:50:33
2015-03-10T16:50:33
null
UTF-8
C++
false
false
1,718
hpp
#ifndef MODEL_HPP_ #define MODEL_HPP_ #include "CubicElement.hpp" #include "TexturedQuad.hpp" #include "io/JsonUtils.hpp" #include <utility> #include <string> #include <vector> namespace Tungsten { namespace MinecraftLoader { class ModelResolver; class Model { std::string _name; std::string _parent; bool _ambientOcclusion; std::vector<std::pair<std::string, std::string>> _textures; std::vector<CubicElement> _elements; void loadTextures(const rapidjson::Value &textures) { for (auto i = textures.MemberBegin(); i != textures.MemberEnd(); ++i) if (i->value.IsString()) _textures.emplace_back(i->name.GetString(), i->value.GetString()); } void loadElements(const rapidjson::Value &elements) { for (rapidjson::SizeType i = 0; i < elements.Size(); ++i) if (elements[i].IsObject()) _elements.emplace_back(elements[i]); } public: Model(const std::string &name, const rapidjson::Value &v) : _name(name), _ambientOcclusion(true) { JsonUtils::fromJson(v, "parent", _parent); JsonUtils::fromJson(v, "ambientocclusion", _ambientOcclusion); auto textures = v.FindMember("textures"); auto elements = v.FindMember("elements"); if (textures != v.MemberEnd() && textures->value.IsObject()) loadTextures(textures->value); if (elements != v.MemberEnd() && elements->value.IsArray()) loadElements(elements->value); } const std::string &name() const { return _name; } void instantiateQuads(std::vector<TexturedQuad> &dst, ModelResolver &resolver) const; }; } } #endif /* MODEL_HPP_ */
[ "mail@noobody.org" ]
mail@noobody.org
b4a1208366b99859ec3cf40d69cf1f9755455dfc
a430483e9b08beb65652525556669ee6659b1f99
/keyence2020/C.cpp
04788a7aaa8f620969fb0dfbd87adc0b8f18115d
[]
no_license
yago-10/atcoder
11689ce52be511a5fc8138614334dc7f6ca361fd
4c2218de674ace03fe11f7941d63f7c4977b86a2
refs/heads/main
2023-06-04T08:40:59.893604
2021-06-22T05:48:35
2021-06-22T05:48:35
379,140,444
0
0
null
null
null
null
UTF-8
C++
false
false
573
cpp
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0; i < n; i++) #define REPR(i, n) for(int i = n; i >= 0; i--) #define FOR(i, m, n) for(int i = m; i < n; i++) #define INF 2e9 #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; int main() { ll N,K,S; cin >> N >> K >> S; for(ll i = 0; i<N ; i++){ if(i < K){ cout << S; }else if(S!=1000000000){ cout << S+1; }else{ cout << 1; } if(i != N-1) cout << ' '; } cout << endl; return 0; }
[ "ctronronron@gmail.com" ]
ctronronron@gmail.com
55381e19769912b2951fabbfa6b0b7139eaad966
7973d931d7f2476b448afb5ebf227977dacdf3a4
/Assignment-3/StackImplementation.cpp
430ec90d679624ac98be0ed986e941b57cd18103
[]
no_license
abhi2425/4th-sem-assignmets-cpp
86398787d277329a7cea8ec454257efb0a8f595b
5aa754e28b0d0961297aeeaf1d42b91b947b1f4c
refs/heads/master
2023-05-23T06:45:18.170795
2021-05-31T17:14:55
2021-05-31T17:14:55
356,195,055
0
0
null
null
null
null
UTF-8
C++
false
false
2,301
cpp
#include <stdio.h> #include <iostream> using namespace std; const int SIZE = 20; class Stack { int top_of_stack; int arr[SIZE]; public: Stack() { top_of_stack = -1; } void push(); void pop(); void displayStack(); bool isStackEmpty(); bool isStackFull(); void checkArray(); }; bool Stack::isStackEmpty() { return (top_of_stack == (-1) ? true : false); } bool Stack::isStackFull() { return (top_of_stack == 4 ? true : false); } void Stack::push() { if (isStackFull()) { cout << "\nSTACK IS FULL { OVERFLOW }"; } else { int i; cout << "\nEnter an element :: "; cin >> i; ++top_of_stack; arr[top_of_stack] = i; cout << "\nInsertion successful.\n"; } } void Stack::pop() { int num; if (isStackEmpty()) { cout << "\n STACK IS EMPTY--> [ UNDERFLOW ] " << endl; } else { cout << "\n Popped item is : " << arr[top_of_stack] << "\n"; top_of_stack--; } } void Stack::displayStack() { if (isStackEmpty()) { cout << "\n STACK IS EMPTY--> [ UNDERFLOW ] " << endl; } else { cout << "\nSTACK :\n"; for (int i = top_of_stack; i >= 0; i--) { cout << arr[i] << "\n"; } } } void Stack::checkArray() { for (int i = 0; i < SIZE; i++) { cout << arr[i] << " "; } } int main() { Stack s; char choice; choice = 0; cout << endl; cout << "*****STACK IMPLEMENTATION USING ARRAYS*******" << endl; while (choice != 4) { cout << "\n1. Push In To Stack\n"; cout << "2. Pop From Stack\n"; cout << "3. Display The Stack\n"; cout << "4. Quit\n"; cout << "\nEnter your Choice :: "; cin >> choice; switch (choice) { case '1': s.push(); break; case '2': s.pop(); break; case '3': s.displayStack(); break; case '4': exit(0); case '5': s.checkArray(); break; default: cout << "\nWrong Choice!! \n"; break; } } return 0; }
[ "abhi.mount.26@gmail.com" ]
abhi.mount.26@gmail.com
7f0b23a23f037ec57571f5852dd3a015ddb4d12e
e1c9e90e9d89b627a5280bcca456d1cec950beb3
/src/RaZ/Utils/Ray.cpp
dddcc58a38385c2b5030df51fb73fefd75d1e481
[ "MIT" ]
permissive
REMqb/RaZ
42aa6d60f79b5525608af67b9e8dddeaaae0b967
5c5c2d0dec282b092d5cf49125b82ac54fe9ab17
refs/heads/master
2020-08-02T16:01:28.104621
2020-04-26T13:04:19
2020-04-26T13:23:25
211,420,231
0
0
MIT
2019-09-28T00:15:08
2019-09-28T00:15:08
null
UTF-8
C++
false
false
6,139
cpp
#include "RaZ/Utils/FloatUtils.hpp" #include "RaZ/Utils/Ray.hpp" #include "RaZ/Utils/Shape.hpp" namespace Raz { namespace { constexpr bool solveQuadratic(float a, float b, float c, float& firstHitDist, float& secondHitDist) { const float discriminant = b * b - 4.f * a * c; if (discriminant < 0.f) { return false; } else if (discriminant > 0.f) { const float q = -0.5f * ((b > 0) ? b + std::sqrt(discriminant) : b - std::sqrt(discriminant)); firstHitDist = q / a; secondHitDist = c / q; } else { // discriminant == 0 const float hitDist = -0.5f * b / a; firstHitDist = hitDist; secondHitDist = hitDist; } if (firstHitDist > secondHitDist) std::swap(firstHitDist, secondHitDist); return true; } } // namespace bool Ray::intersects(const Vec3f& point, RayHit* hit) const { if (point == m_origin) { if (hit) { hit->position = point; hit->distance = 0.f; } return true; } const Vec3f pointDir = point - m_origin; const Vec3f normedPointDir = pointDir.normalize(); if (!FloatUtils::areNearlyEqual(normedPointDir.dot(m_direction), 1.f)) return false; if (hit) { hit->position = point; hit->normal = -normedPointDir; hit->distance = pointDir.computeLength(); } return true; } bool Ray::intersects(const Plane& plane, RayHit* hit) const { const float dirAngle = m_direction.dot(plane.getNormal()); if (dirAngle >= 0.f) // The plane is facing in the same direction as the ray return false; const float origAngle = m_origin.dot(plane.getNormal()); const float hitDist = (plane.getDistance() - origAngle) / dirAngle; if (hitDist <= 0.f) // The plane is behind the ray return false; if (hit) { hit->position = m_origin + m_direction * hitDist; hit->normal = plane.getNormal(); hit->distance = hitDist; } return true; } bool Ray::intersects(const Sphere& sphere, RayHit* hit) const { const Vec3f sphereDir = m_origin - sphere.getCenter(); const float raySqLength = m_direction.dot(m_direction); const float rayDiff = 2.f * m_direction.dot(sphereDir); const float sphereDiff = sphereDir.computeSquaredLength() - sphere.getRadius() * sphere.getRadius(); float firstHitDist {}; float secondHitDist {}; if (!solveQuadratic(raySqLength, rayDiff, sphereDiff, firstHitDist, secondHitDist)) return false; // If the hit distances are negative, we've hit a sphere located behind the ray's origin if (firstHitDist < 0.f) { firstHitDist = secondHitDist; if (firstHitDist < 0.f) return false; } if (hit) { const Vec3f hitPos = m_origin + m_direction * firstHitDist; hit->position = hitPos; hit->normal = (hitPos - sphere.getCenter()).normalize(); hit->distance = firstHitDist; } return true; } bool Ray::intersects(const Triangle& triangle, RayHit* hit) const { const Vec3f firstEdge = triangle.getSecondPos() - triangle.getFirstPos(); const Vec3f secondEdge = triangle.getThirdPos() - triangle.getFirstPos(); const Vec3f pVec = m_direction.cross(secondEdge); const float determinant = firstEdge.dot(pVec); if (FloatUtils::areNearlyEqual(std::abs(determinant), 0.f)) return false; const float invDeterm = 1.f / determinant; const Vec3f invPlaneDir = m_origin - triangle.getFirstPos(); const float firstBaryCoord = invPlaneDir.dot(pVec) * invDeterm; if (firstBaryCoord < 0.f || firstBaryCoord > 1.f) return false; const Vec3f qVec = invPlaneDir.cross(firstEdge); const float secondBaryCoord = qVec.dot(m_direction) * invDeterm; if (secondBaryCoord < 0.f || firstBaryCoord + secondBaryCoord > 1.f) return false; const float hitDist = secondEdge.dot(qVec) * invDeterm; if (hitDist <= 0.f) return false; if (hit) { hit->position = m_origin + m_direction * hitDist; const Vec3f normal = firstEdge.cross(secondEdge).normalize(); // We want the normal facing the ray, not the opposite direction (no culling) // This may not be the ideal behavior; this may change when a real use case will be available hit->normal = (normal.dot(m_direction) > 0.f ? -normal : normal); hit->distance = hitDist; } return true; } bool Ray::intersects(const AABB& aabb, RayHit* hit) const { // Branchless algorithm based on Tavianator's: // - https://tavianator.com/fast-branchless-raybounding-box-intersections/ // - https://tavianator.com/cgit/dimension.git/tree/libdimension/bvh/bvh.c#n196 const Vec3f minDist = (aabb.getLeftBottomBackPos() - m_origin) * m_invDirection; const Vec3f maxDist = (aabb.getRightTopFrontPos() - m_origin) * m_invDirection; const float minDistX = std::min(minDist[0], maxDist[0]); const float maxDistX = std::max(minDist[0], maxDist[0]); const float minDistY = std::min(minDist[1], maxDist[1]); const float maxDistY = std::max(minDist[1], maxDist[1]); const float minDistZ = std::min(minDist[2], maxDist[2]); const float maxDistZ = std::max(minDist[2], maxDist[2]); const float minHitDist = std::max(minDistX, std::max(minDistY, minDistZ)); const float maxHitDist = std::min(maxDistX, std::min(maxDistY, maxDistZ)); if (maxHitDist < std::max(minHitDist, 0.f)) return false; // If reaching here with a negative distance (minHitDist < 0), this means that the ray's origin is inside the box // Currently, in this case, the computed hit position represents the intersection behind the ray if (hit) { hit->position = m_origin + m_direction * minHitDist; // Normal computing method based on John Novak's: http://blog.johnnovak.net/2016/10/22/the-nim-raytracer-project-part-4-calculating-box-normals/ const Vec3f hitDir = (hit->position - aabb.computeCentroid()) / aabb.computeHalfExtents(); hit->normal = Vec3f(std::trunc(hitDir[0]), std::trunc(hitDir[1]), std::trunc(hitDir[2])).normalize(); hit->distance = minHitDist; } return true; } Vec3f Ray::computeProjection(const Vec3f& point) const { const float pointDist = m_direction.dot(point - m_origin); return (m_origin + m_direction * std::max(pointDist, 0.f)); } } // namespace Raz
[ "romain.milbert@gmail.com" ]
romain.milbert@gmail.com
84262b5b30b3403c048ed2aeb8aaeedc19279a1f
44c4112054233bd6e6fb021d1053fcf5c5bcc487
/src/client/pathsrenderer.cpp
3b1c85fe52ee9d2fba6448786226932496e6657c
[]
no_license
giuliom95/gatherer
76d74cedec376bad5f3dcf2f05d1e1ef1f5a1ff0
7eeb558c1fd9e765463a98728df2d736727ed03f
refs/heads/master
2023-01-31T23:07:21.135315
2020-12-13T15:58:39
2020-12-13T15:58:39
282,305,831
4
1
null
null
null
null
UTF-8
C++
false
false
6,046
cpp
#include "pathsrenderer.hpp" void PathsRenderer::init() { glGenVertexArrays(1, &vaoidx); glBindVertexArray(vaoidx); glGenBuffers(1, &posvboidx); glGenBuffers(1, &ssboidx); glEnableVertexAttribArray(0); LOG(info) << "Created VAO"; enablerendering = true; enabledepth = true; pathsalpha = PATHSRENDERER_DEFPATHSALPHA; glGenFramebuffers(1, &fbo_id); glBindFramebuffer(GL_FRAMEBUFFER, fbo_id); glGenTextures(1, &texid_above); glBindTexture(GL_TEXTURE_2D, texid_above); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glGenTextures(1, &texid_below); glBindTexture(GL_TEXTURE_2D, texid_below); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); setframesize({DEF_WINDOW_W, DEF_WINDOW_H}); glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texid_above, 0 ); glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, texid_below, 0 ); if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) LOG(error) << "Paths framebuffer is not complete!"; glBindFramebuffer(GL_FRAMEBUFFER, 0); shaprog1_idx = disk_load_shader_program( "../src/client/shaders/paths1.vert.glsl", "../src/client/shaders/paths1.frag.glsl" ); locid1_camvpmat = glGetUniformLocation(shaprog1_idx, "vpmat"); locid1_pathsalpha = glGetUniformLocation(shaprog1_idx, "pathsalpha"); locid1_enabledepth = glGetUniformLocation(shaprog1_idx, "enabledepth"); locid1_enableradiance = glGetUniformLocation(shaprog1_idx, "enableradiance"); locid1_opaquedepth = glGetUniformLocation(shaprog1_idx, "opaquedepth"); locid1_transdepth = glGetUniformLocation(shaprog1_idx, "transdepth"); shaprog2_idx = disk_load_shader_program( "../src/client/shaders/screenquad.vert.glsl", "../src/client/shaders/paths2.frag.glsl" ); locid2_opaquebeauty = glGetUniformLocation(shaprog2_idx, "opaquebeauty"); locid2_transbeauty = glGetUniformLocation(shaprog2_idx, "transbeauty"); locid2_above = glGetUniformLocation(shaprog2_idx, "above"); locid2_below = glGetUniformLocation(shaprog2_idx, "below"); } void PathsRenderer::render( Camera& cam, GLuint finalfbo, GLuint opaquebeautytex, GLuint transbeautytex, GLuint opaquedepthtex, GLuint transdepthtex, GatheredData& gd ) { glBindFramebuffer(GL_FRAMEBUFFER, fbo_id); GLenum buf1[]{GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1}; glDrawBuffers(2, buf1); glClear(GL_COLOR_BUFFER_BIT); glUseProgram(shaprog1_idx); glBindVertexArray(vaoidx); glLineWidth(1); //glBlendFunc(GL_ONE_MINUS_SRC_COLOR, GL_SRC_COLOR); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); const Mat4f vpmat = cam.w2c()*cam.persp(); glUniformMatrix4fv( locid1_camvpmat, 1, GL_FALSE, reinterpret_cast<const GLfloat*>(&vpmat) ); glUniform1f(locid1_pathsalpha, pathsalpha); glUniform1i(locid1_enabledepth, enabledepth); glUniform1i(locid1_enableradiance, enableradiance); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, opaquedepthtex); glUniform1i(locid1_opaquedepth, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, transdepthtex); glUniform1i(locid1_transdepth, 1); glMultiDrawArrays( GL_LINE_STRIP, paths_firsts.data(), paths_lengths.data(), gd.selectedpaths.size() ); glDisable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBindFramebuffer(GL_FRAMEBUFFER, finalfbo); GLenum buf2[]{GL_COLOR_ATTACHMENT0}; glDrawBuffers(1, buf2); glUseProgram(shaprog2_idx); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, opaquebeautytex); glUniform1i(locid2_opaquebeauty, 0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, transbeautytex); glUniform1i(locid2_transbeauty, 1); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, texid_above); glUniform1i(locid2_above, 2); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, texid_below); glUniform1i(locid2_below, 3); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } void PathsRenderer::setframesize(Vec2i size) { glBindTexture(GL_TEXTURE_2D, texid_above); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16F, size[0], size[1], 0, GL_RGBA, GL_HALF_FLOAT, nullptr ); glBindTexture(GL_TEXTURE_2D, texid_below); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA16F, size[0], size[1], 0, GL_RGBA, GL_HALF_FLOAT, nullptr ); } void PathsRenderer::updaterenderlist(GatheredData& gd) { glBindVertexArray(vaoidx); const unsigned npaths = gd.selectedpaths.size(); paths_firsts = std::vector<GLint>(npaths); paths_lengths = std::vector<GLsizei>(npaths); if(npaths == 0) { glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_DYNAMIC_DRAW); return; } std::vector<Vec3h*> offset_ptrs(npaths); std::vector<float> pathsenergy(npaths); unsigned off = 0; unsigned i = 0; for(unsigned pi : gd.selectedpaths) { const unsigned firstbounce = gd.firstbounceindexes[pi]; const unsigned len = gd.pathslength[pi]; paths_firsts[i] = off; paths_lengths[i] = len; offset_ptrs[i] = &(gd.bouncesposition[firstbounce]); const Vec3h radiance = gd.pathsradiance[pi]; const float pathenergy = radiance[0] + radiance[1] + radiance[2]; pathsenergy[i] = pathenergy; off += len; i++; } const unsigned nvtx = off; const unsigned totalvtxbytes = nvtx * sizeof(Vec3h); glBindBuffer(GL_ARRAY_BUFFER, posvboidx); glBufferData(GL_ARRAY_BUFFER, totalvtxbytes, NULL, GL_STATIC_DRAW); for(unsigned i = 0; i < npaths; ++i) { glBufferSubData( GL_ARRAY_BUFFER, paths_firsts[i] * sizeof(Vec3h), paths_lengths[i] * sizeof(Vec3h), offset_ptrs[i] ); } glVertexAttribPointer( 0, 3, GL_HALF_FLOAT, GL_FALSE, 3 * sizeof(half), (void*)0 ); glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssboidx); glBufferData( GL_SHADER_STORAGE_BUFFER, sizeof(float)*npaths, pathsenergy.data(), GL_STATIC_DRAW ); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssboidx); glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); }
[ "giuliomartella1995@gmail.com" ]
giuliomartella1995@gmail.com
5d8a2686c4220b2d12bf11a0ab330a14ccbec388
78d40e21667abc6777cae876ea2b905c1e93261a
/codes/src/Sample.cpp
2d11440bcdeac12250fb2cfba3673629b44b45b2
[]
no_license
LuizFelipeLemon/Modular-robotic-manipulator
222d9935d6eec9675ff0d228db7e8cf47a313d20
46c36c0b644608edabe280f0a7cb9a481e8d18f5
refs/heads/master
2021-06-06T22:08:53.033648
2021-05-25T16:14:49
2021-05-25T16:14:49
160,433,724
0
0
null
null
null
null
UTF-8
C++
false
false
3,141
cpp
/* * File: Sample.cpp * Author: oriva * * Created on 10 de Outubro de 2014, 14:20 */ #include "Sample.h" #include <cmath> #include <exception> #include "utils.h" Sample::Sample() { label = "*"; } Sample::Sample(int s) { for (int i = 0; i < s; i++) { information.push_back(0); } } Sample::Sample(std::vector<double>& info) { information = info; } Sample::Sample(std::vector<double>& info, std::string l) { information = info; label = l; } Sample::Sample(const Sample& orig) { information = orig.information; } Sample Sample::operator+(Sample& sIn) { int size = information.size(); Sample r(size); for (int i = 0; i < size; i++) { r.information[i] = this->information[i] + sIn.information[i]; } return r; } Sample Sample::operator-(Sample& sIn) { int size = information.size(); Sample r(size); for (int i = 0; i < size; i++) { r.information[i] = this->information[i] - sIn.information[i]; } return r; } Sample Sample::operator/(double d) { int size = information.size(); Sample r(size); for (int i = 0; i < size; i++) { r.information[i] = this->information[i] / d; } return r; } double Sample::distance(Sample& sIn) { double sum = 0; std::vector<double>::iterator itB; std::vector<double>::iterator itA; itB = sIn.information.begin(); for (itA = information.begin(); (itA < information.end()) and (itB < sIn.information.end()); itA++) { sum += (*itA - *itB) * (*itA - *itB); // (ai - bi)^2 itB++; } return sqrt(sum); } std::string Sample::toString() { std::stringstream result; for (int i = 0; i < information.size(); i++) { result << information.at(i) << " "; } result << label; std::string s = result.str(); return s; } std::string Sample::toShortString() { std::stringstream result; for (int i = 0; i < information.size(); i++) { result << information.at(i) << " "; } std::string s = result.str(); return s; } void Sample::print() { std::cout << " [" << toString() << "] "; } void Sample::getFeatures(std::vector<double>& info) { // std::copy(info.begin(), info.end(), back_inserter(information)); // info = information; info.clear(); for (int i = 0; i < information.size(); i++) info.push_back(information[i]); } void Sample::getFeaturesRange(int iStart, int iEnd, std::vector<double>& info) { info.clear(); if ((iEnd < information.size()) && (iEnd > iStart)) for (int i = iStart; i <= iEnd; i++) info.push_back(information[i]); } double Sample::getFeature(int index) { double v = 0; try { v = information.at(index); } catch (exception& e) { std::cout << " Erro ao acessar índice do vetor de características: " << e.what() << std::endl; } return v; } int Sample::getSize() { return information.size(); } std::string Sample::getClass() { return label; } void Sample::putNormalNoise(double s) { for (std::vector<double>::iterator itI = information.begin(); itI != information.end(); itI++) { *itI += Utils::normalDistribution(0, s); } } void Sample::setFeatures(std::vector<double>& info) { information = info; } Sample::~Sample() {}
[ "luizfelipeplm@ufrn.edu.br" ]
luizfelipeplm@ufrn.edu.br
6d5d7ec16f3459f8743571fc2a921c3f903f59bd
944c6d723c5dccc39416e501341e8d943f1bdb8e
/C++VS/Exersice/Lessons7/4/moveCahrXYZ/move/move/Source.cpp
0a99b13f87c634590181dd3eae3fea2b0eb288c8
[]
no_license
UserNT/JoinISD
75176ce790635ed77415ab4c7dee0e49321edaf4
18a4367eac38347ac6b6611afa009e359767d42b
refs/heads/master
2021-01-09T06:10:02.426103
2017-10-29T16:44:05
2017-10-29T16:44:05
80,913,329
0
0
null
null
null
null
UTF-8
C++
false
false
1,583
cpp
#include<iostream> #include<conio.h> #include<cstring> /* #define _CRT_SECURE_NO_WARNINGS #pragma warning(disable : 4996) #define _CRT_SECURE_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE */ using std::cout; using std::cin; using std::endl; int main() { setlocale(LC_ALL, "Russian"); const int N = 1000; char str[N][N] = { { "" },{ "" } }; char temp[N] = ""; int index = 0; int indexY = 0; char c = '|', c1; do { c1 = (char)_getch(); system("cls"); if (c1 == 'd' || c1 == 'D') { for (int i(0); (i <= index) && (i < N); i++) if (i != index) str[indexY][i] = ' '; else str[indexY][i] = c; str[indexY][index + 1] = '\0'; index++; strcpy_s(temp, str[indexY]); } if (c1 == 'a' || c1 == 'A') { for (int i(0); (i < index) && (i < N); i++) if (i != index - 1) str[indexY][i] = ' '; else str[indexY][i] = c; str[indexY][index] = '\0'; index--; strcpy_s(temp, str[indexY]); } if (c1 == 's' || c1 == 'S') { indexY++; for (int i(0); (i <= indexY) && (i < N); i++) if (i != indexY) { strcpy_s(str[i], "\n\0"); } else strcpy_s(str[i], temp); strcpy_s(temp, str[indexY]); } if (c1 == 'w' || c1 == 'W') { indexY--; for (int i(0); (i <= indexY) && (i < N); i++) if (i != indexY) { strcpy_s(str[i], "\n\0"); } else strcpy_s(str[i], temp); strcpy_s(temp, str[indexY]); strcpy_s(str[indexY+1], "\0"); } for (int i(0); i <= indexY; i++) cout << str[i]; } while (c1 != 'q'); _getch(); return 0; }
[ "vitalikfmne@mail.ru" ]
vitalikfmne@mail.ru
56f17a2a8d34c21b74e7b2541a4ee536f9b3a8f9
a701420c7d30d62bb974c21d6450c02212819208
/constructor/paramaterize constructor/main.cpp
91b6f5168a6ec0520924993d0389f9b898936f3d
[ "MIT" ]
permissive
techmuses/learn.cpp
5f95e27841e88e3cd862ed0a547c3149c9dc6d54
3476010bd1a63bc1221491a97ac38a14c5a52c57
refs/heads/master
2020-04-08T00:39:31.784931
2019-01-23T20:41:26
2019-01-23T20:41:26
158,860,904
0
1
MIT
2019-10-24T11:25:19
2018-11-23T17:24:53
C++
UTF-8
C++
false
false
184
cpp
#include<iostream> using namespace std; class constr { public: int value; constr(int x) { value=x; } }; int main() { constr c1(10); cout << c1.value; }
[ "aks28id@gmail.com" ]
aks28id@gmail.com
8b56e94996bf01748f749fe67b003f5649d61033
eb6b3348da7f404e531821b096a95d073631e899
/src/utility/gpu/cublas.hpp
ed242271d8e79a2643fa99c0c8870dc02955aa45
[ "Apache-2.0" ]
permissive
LaplaceKorea/OpenJij
a714b2459ea883cbf40aa7d19c2bdcec6058a01d
0fe03f07af947f519a32ad58fe20423919651634
refs/heads/master
2023-03-28T17:47:30.439868
2020-10-22T09:50:22
2020-10-22T09:50:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,954
hpp
// Copyright 2019 Jij Inc. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef OPENJIJ_UTILITY_GPU_CUBLAS_HPP__ #define OPENJIJ_UTILITY_GPU_CUBLAS_HPP__ #ifdef USE_CUDA #include <cuda_runtime.h> #include <utility/gpu/handle_error.hpp> #include <utility/gpu/memory.hpp> #include "cublas_v2.h" namespace openjij { namespace utility { namespace cuda { //cuda datatype template<typename FloatType> struct cudaDataType_impl; template<> struct cudaDataType_impl<float>{ constexpr static cudaDataType_t type = CUDA_R_32F; }; template<> struct cudaDataType_impl<double>{ constexpr static cudaDataType_t type = CUDA_R_64F; }; //cublas get maximal value template<typename FloatType> inline cublasStatus_t cublas_Iamax_impl(cublasHandle_t handle, int n, const FloatType *x, int incx, int *result); template<> inline cublasStatus_t cublas_Iamax_impl(cublasHandle_t handle, int n, const float *x, int incx, int *result){ return cublasIsamax(handle, n, x, incx, result); } template<> inline cublasStatus_t cublas_Iamax_impl(cublasHandle_t handle, int n, const double *x, int incx, int *result){ return cublasIdamax(handle, n, x, incx, result); } //cublas dot product template<typename FloatType> inline cublasStatus_t cublas_dot_impl(cublasHandle_t handle, int n, const FloatType* x, int incx, const FloatType* y, int incy, FloatType* result); template<> inline cublasStatus_t cublas_dot_impl(cublasHandle_t handle, int n, const float* x, int incx, const float* y, int incy, float* result){ return cublasSdot(handle, n, x, incx, y, incy, result); } template<> inline cublasStatus_t cublas_dot_impl(cublasHandle_t handle, int n, const double* x, int incx, const double* y, int incy, double* result){ return cublasDdot(handle, n, x, incx, y, incy, result); } /** * @brief cuBLAS wrapper */ class CuBLASWrapper{ public: CuBLASWrapper(){ //generate cuBLAS instance HANDLE_ERROR_CUBLAS(cublasCreate(&_handle)); //use tensor core if possible HANDLE_ERROR_CUBLAS(cublasSetMathMode(_handle, CUBLAS_TENSOR_OP_MATH)); } CuBLASWrapper(CuBLASWrapper&& obj) noexcept { //move cuBLAS handler this->_handle = obj._handle; obj._handle = NULL; } ~CuBLASWrapper(){ //destroy generator if(_handle != NULL) HANDLE_ERROR_CUBLAS(cublasDestroy(_handle)); } template<typename FloatType> inline void SgemmEx( cublasOperation_t transa, cublasOperation_t transb, int m, int n, int k, const float *alpha, const utility::cuda::unique_dev_ptr<FloatType>& A, int lda, const utility::cuda::unique_dev_ptr<FloatType>& B, int ldb, const float *beta, utility::cuda::unique_dev_ptr<FloatType>& C, int ldc){ cublasPointerMode_t mode; HANDLE_ERROR_CUBLAS(cublasGetPointerMode(_handle, &mode)); HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, CUBLAS_POINTER_MODE_HOST)); HANDLE_ERROR_CUBLAS(cublasSgemmEx( _handle, transa, transb, m, n, k, alpha, A.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, lda, B.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, ldb, beta, C.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, ldc) ); HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, mode)); } /** * @brief matrix multiplication * C_mn = A_mk B_kn * * @tparam FloatType * @param m * @param k * @param n * @param A * @param B * @param C */ template<typename FloatType> inline void matmul( int m, int k, int n, const utility::cuda::unique_dev_ptr<FloatType>& A, const utility::cuda::unique_dev_ptr<FloatType>& B, utility::cuda::unique_dev_ptr<FloatType>& C, cublasOperation_t transa = CUBLAS_OP_N, cublasOperation_t transb = CUBLAS_OP_N ){ typename std::remove_extent<FloatType>::type alpha = 1.0; typename std::remove_extent<FloatType>::type beta = 0; cublasPointerMode_t mode; HANDLE_ERROR_CUBLAS(cublasGetPointerMode(_handle, &mode)); HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, CUBLAS_POINTER_MODE_HOST)); HANDLE_ERROR_CUBLAS(cublasSgemmEx( _handle, transa, transb, m, n, k, &alpha, A.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, m, B.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, k, &beta, C.get(), cudaDataType_impl<typename std::remove_extent<FloatType>::type>::type, m) ); HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, mode)); } /** * @brief wrap function of cublasIsamax * Note: returned value will be 1-indexed! * * @tparam FloatType * @param n * @param x * @param incx * @param result */ template<typename FloatType> inline void Iamax(int n, const FloatType* x, int incx, int* result){ cublasPointerMode_t mode; HANDLE_ERROR_CUBLAS(cublasGetPointerMode(_handle, &mode)); //set pointermode to device HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, CUBLAS_POINTER_MODE_DEVICE)); HANDLE_ERROR_CUBLAS(cublas_Iamax_impl(_handle, n, x, incx, result)); //reset pointermode HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, mode)); } /** * @brief return the index of maximal element * Note: returned value will be 1-indexed! * * @tparam FloatType * @param n * @param x * @param result */ template<typename FloatType> inline void absmax_val_index(int n, const utility::cuda::unique_dev_ptr<FloatType[]>& x, utility::cuda::unique_dev_ptr<int[]>& result){ Iamax(n, x.get(), 1, result.get()); } /** * @brief wrap function of cublasXdot * * @tparam FloatType * @param n * @param x * @param incx * @param y * @param incy * @param result */ template<typename FloatType> inline void dot(int n, const FloatType* x, int incx, const FloatType* y, int incy, FloatType* result){ cublasPointerMode_t mode; HANDLE_ERROR_CUBLAS(cublasGetPointerMode(_handle, &mode)); HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, CUBLAS_POINTER_MODE_DEVICE)); //set pointermode to device HANDLE_ERROR_CUBLAS(cublas_dot_impl(_handle, n, x, incx, y, incy, result)); //reset pointermode HANDLE_ERROR_CUBLAS(cublasSetPointerMode(_handle, mode)); } /** * @brief return the dot product of x and y * * @tparam FloatType * @param n * @param x * @param y * @param result */ template<typename FloatType> inline void dot(int n, const utility::cuda::unique_dev_ptr<FloatType[]>& x, const utility::cuda::unique_dev_ptr<FloatType[]>& y, utility::cuda::unique_dev_ptr<FloatType[]>& result){ dot(n, x.get(), 1, y.get(), 1, result.get()); } private: cublasHandle_t _handle; }; }// namespace cuda } // namespace utility } // namespace openjij #endif #endif
[ "jiko.rogy@gmail.com" ]
jiko.rogy@gmail.com
ad11dcb381b9263bd0bbedda2110f5e253846366
305e76eaaefa1d0e11e640d53983fa610ef078df
/cpp_sandbox/arduino_all/_180415_servo_help/_180415_servo_help.ino
84472fd58d22c8af3abfa6d8bd942e7460181183
[ "MIT" ]
permissive
kjgonzalez/codefiles
ec6c16edca3d12be065659e03bd35c31b71c2d55
87a6ce221e7210f73b360f4e9642d7ccbdebb94b
refs/heads/master
2023-08-26T14:35:15.820085
2023-08-05T08:47:47
2023-08-05T08:47:47
151,092,223
0
0
null
null
null
null
UTF-8
C++
false
false
755
ino
/* Author: Kris Gonzalez Date Created: 180415 Objective: help figure out why another microcontroller having issues driving a servo. */ #include <Servo.h> Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object Serial.begin(9600); Serial.println("serial port open"); } void loop() { int comvalue = 0; if(Serial.available() > 0) { comvalue = Serial.parseInt(); Serial.print("received (microseconds): "); Serial.println(comvalue); myservo.writeMicroseconds(comvalue); } //if new value received }//mainloop
[ "kg-171971@hs-weingarten.de" ]
kg-171971@hs-weingarten.de