text
string
size
int64
token_count
int64
#pragma warning(disable:4996) #include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { int rope; int weight[100000]; int result[100000]; int n = 1; int max; scanf("%d", &rope); for (int i = 0; i < rope; i++) { scanf("%d", &weight[i]); } sort(weight, weight + rope); for (int j = rope - 1; j >= 0; j--) { result[j] = weight[j] * n; n++; } sort(result, result + rope); max = result[rope - 1]; printf("%d", max); return 0; }
526
253
#include <Parsers/MySQL/ASTDeclareColumn.h> #include <Parsers/ASTIdentifier.h> #include <Parsers/ParserDataType.h> #include <Parsers/ExpressionListParsers.h> #include <Parsers/ExpressionElementParsers.h> #include <Parsers/MySQL/ASTDeclareOption.h> #include <Parsers/MySQL/ASTDeclareReference.h> #include <Parsers/MySQL/ASTDeclareConstraint.h> namespace DB { namespace MySQLParser { ASTPtr ASTDeclareColumn::clone() const { auto res = std::make_shared<ASTDeclareColumn>(*this); res->children.clear(); if (data_type) { res->data_type = data_type->clone(); res->children.emplace_back(res->data_type); } if (column_options) { res->column_options = column_options->clone(); res->children.emplace_back(res->column_options); } return res; } static inline bool parseColumnDeclareOptions(IParser::Pos & pos, ASTPtr & node, Expected & expected) { ParserDeclareOptions p_non_generate_options{ { OptionDescribe("ZEROFILL", "zero_fill", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("SIGNED", "is_unsigned", std::make_unique<ParserAlwaysFalse>()), OptionDescribe("UNSIGNED", "is_unsigned", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("NULL", "is_null", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("NOT NULL", "is_null", std::make_unique<ParserAlwaysFalse>()), OptionDescribe("DEFAULT", "default", std::make_unique<ParserExpression>()), OptionDescribe("ON UPDATE", "on_update", std::make_unique<ParserExpression>()), OptionDescribe("AUTO_INCREMENT", "auto_increment", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("UNIQUE KEY", "unique_key", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("PRIMARY KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("UNIQUE", "unique_key", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("KEY", "primary_key", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("COMMENT", "comment", std::make_unique<ParserStringLiteral>()), OptionDescribe("CHARACTER SET", "charset_name", std::make_unique<ParserCharsetName>()), OptionDescribe("COLLATE", "collate", std::make_unique<ParserCharsetName>()), OptionDescribe("COLUMN_FORMAT", "column_format", std::make_unique<ParserIdentifier>()), OptionDescribe("STORAGE", "storage", std::make_unique<ParserIdentifier>()), OptionDescribe("AS", "generated", std::make_unique<ParserExpression>()), OptionDescribe("GENERATED ALWAYS AS", "generated", std::make_unique<ParserExpression>()), OptionDescribe("STORED", "is_stored", std::make_unique<ParserAlwaysTrue>()), OptionDescribe("VIRTUAL", "is_stored", std::make_unique<ParserAlwaysFalse>()), OptionDescribe("", "reference", std::make_unique<ParserDeclareReference>()), OptionDescribe("", "constraint", std::make_unique<ParserDeclareConstraint>()), } }; return p_non_generate_options.parse(pos, node, expected); } bool ParserDeclareColumn::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { ASTPtr column_name; ASTPtr column_data_type; ASTPtr column_options; ParserExpression p_expression; ParserIdentifier p_identifier; if (!p_identifier.parse(pos, column_name, expected)) return false; if (!ParserDataType().parse(pos, column_data_type, expected)) return false; parseColumnDeclareOptions(pos, column_options, expected); auto declare_column = std::make_shared<ASTDeclareColumn>(); declare_column->name = getIdentifierName(column_name); declare_column->data_type = column_data_type; declare_column->column_options = column_options; if (declare_column->data_type) declare_column->children.emplace_back(declare_column->data_type); if (declare_column->column_options) declare_column->children.emplace_back(declare_column->column_options); node = declare_column; return true; } } }
4,149
1,266
// ReSharper disable All #include <AIO/Search/SearchEngine.hpp> #include <AIO/Network/FakeNetwork.hpp> #include <AIO/Network/TrtNetwork.hpp> #include <AIO/Utils/Utils.hpp> #include <effolkronium/random.hpp> #include <iomanip> #include <iostream> #include <numeric> #include <random> #include <spdlog/spdlog.h> namespace AIO::Search { SearchEngine::SearchEngine(SearchOptions option) : option_(option), manager_(option.NumSearchThreads) { const std::size_t numOfGpus = option.Gpus.size(); networkBarrier_.Init(option_.NumEvalThreads); for (int threadId = 0; threadId < option_.NumEvalThreads; ++threadId) { std::unique_ptr<Network::Network> network; #ifdef BUILD_WITH_TRT network = std::make_unique<Network::TrtNetwork>( option, option.Gpus[threadId % numOfGpus]); #else network = std::make_unique<Network::FakeNetwork>(); #endif evalThreads_.emplace_back(&SearchEngine::evalThread, this, threadId, std::move(network)); } for (int threadId = 0; threadId < option_.NumSearchThreads; ++threadId) { searchThreads_.emplace_back(&SearchEngine::searchThread, this, threadId); } deleteThread_ = std::thread(&SearchEngine::deleteThread, this); networkBarrier_.Wait(); updateRoot(nullptr); if (option_.Verbose) spdlog::info("search engine initialize done"); } SearchEngine::~SearchEngine() { manager_.Terminate(); for (auto& t : searchThreads_) if (t.joinable()) t.join(); runningEvalThread_ = false; for (auto& t : evalThreads_) if (t.joinable()) t.join(); { std::lock_guard<std::mutex> lock(deleteMutex_); deleteTasks_.emplace_back(root_); } // maybe root is deleted during this time std::this_thread::sleep_for(std::chrono::milliseconds(100)); runningDeleteThread_ = false; if (deleteThread_.joinable()) deleteThread_.join(); } void SearchEngine::Search() { resumeSearch(); bool stopFlag = false; while (!stopFlag) { stopFlag |= (numOfSimulations_ >= option_.MaxSimulations); } pauseSearch(); } void SearchEngine::Play(Game::Point pt) { pauseSearch(); mainBoard_.Play(pt); TreeNode* newRoot = nullptr; for (TreeNode* tempNowNode = root_->mostLeftChildNode; tempNowNode != nullptr; tempNowNode = tempNowNode->rightSiblingNode) { if (tempNowNode->action == pt) { newRoot = tempNowNode; break; } } updateRoot(newRoot); } void SearchEngine::Undo() { pauseSearch(); mainBoard_.Undo(); updateRoot(nullptr); } void SearchEngine::DumpStats() const { std::vector<TreeNode*> children; for (TreeNode* tempNowNode = root_->mostLeftChildNode; tempNowNode != nullptr; tempNowNode = tempNowNode->rightSiblingNode) { children.emplace_back(tempNowNode); } std::sort(children.begin(), children.end(), [](TreeNode* a, TreeNode* b) { return a->visits > b->visits; }); std::cerr << "root value: " << (1.f + -(root_->values / root_->visits)) / 2.f << '\n' << "total simulation: " << numOfSimulations_ << '\n' << "root visits: " << root_->visits << '\n'; for (const TreeNode* child : children) { if (child->visits == 0) break; std::cerr << std::right << std::setw(5) << Game::PointUtil::PointStr(child->action) << " : (N: " << child->visits << ") (Q: " << ((1.f + child->values / child->visits) / 2.f) << ") (P: " << child->policy << ") -> "; while (true) { std::cerr << Game::PointUtil::PointStr(child->action) << ' '; if (child->state == ExpandState::EXPANDED) child = child->GetMaxVisitedChild(); else break; } std::cerr << '\n'; } } Game::Point SearchEngine::GetBestMove() const { const TreeNode* bestNode = getBestNode(); if (bestNode == nullptr) return Game::PASS; return getBestNode()->action; } const TreeNode* SearchEngine::GetRoot() const noexcept { return root_; } TreeNode* SearchEngine::getBestNode() { return const_cast<TreeNode*>(std::as_const(*this).getBestNode()); } const TreeNode* SearchEngine::getBestNode() const { if (root_ == nullptr) return nullptr; return root_->GetMaxVisitedChild(); } void SearchEngine::updateRoot(TreeNode* newNode) { TreeNode* node; if (newNode == nullptr) { node = new TreeNode; node->color = mainBoard_.Opponent(); } else { node = new TreeNode(std::move(*newNode)); for (TreeNode* tempNowNode = node->mostLeftChildNode; tempNowNode != nullptr; tempNowNode = tempNowNode->rightSiblingNode) tempNowNode->parentNode = node; node->parentNode = nullptr; } if (root_ != nullptr) enqDelete(root_); root_ = node; } void SearchEngine::initRoot() { if (root_->state == ExpandState::UNEXPANDED) { Network::Tensor policy; [[maybe_unused]] float value; evaluate(mainBoard_, policy, value); root_->Expand(mainBoard_, policy); } if (option_.EnableDirichletNoise) { std::gamma_distribution<float> dist(option_.DirichletNoiseAlpha); std::array<float, Game::BOARD_SIZE> noise; for (std::size_t i = 0; i < Game::BOARD_SIZE; ++i) noise[i] = effolkronium::random_thread_local::get(dist); const float noiseSum = std::accumulate( noise.begin(), noise.begin() + root_->numChildren, 1e-10f); float total = 1e-10f; std::size_t idx = 0; for (TreeNode* child = root_->mostLeftChildNode; child != nullptr; child = child->rightSiblingNode, ++idx) { child->policy = (option_.DirichletNoiseEps) * child->policy + (1.f - option_.DirichletNoiseEps) * noise[idx] / noiseSum; total += child->policy; } for (TreeNode* child = root_->mostLeftChildNode; child != nullptr; child = child->rightSiblingNode) child->policy /= total; } } void SearchEngine::pauseSearch() { if (manager_.GetState() == SearchState::SEARCHING) { manager_.Pause(); if (option_.Verbose) spdlog::info("pause search"); } } void SearchEngine::resumeSearch() { if (manager_.GetState() == SearchState::PAUSE) { numOfSimulations_ = 0; initRoot(); manager_.Resume(); if (option_.Verbose) spdlog::info("resume search"); } } void SearchEngine::evaluate(const Game::Board& state, Network::Tensor& policy, float& value) { EvalTask task; task.state = Network::StateToTensor(state); auto fut = task.task.get_future(); { std::lock_guard<std::mutex> lock(evalMutex_); evalTasks_.emplace_back(std::move(task)); } auto [predPolicy, predValue] = fut.get(); policy = std::move(predPolicy); value = predValue; } void SearchEngine::enqDelete(TreeNode* node) { std::lock_guard<std::mutex> lock(deleteMutex_); deleteTasks_.emplace_back(node); } void SearchEngine::evalThread(int threadId, std::unique_ptr<Network::Network> network) { if (option_.Verbose) spdlog::info("[eval thread {}] initialize start", threadId); network->Initialize(option_.WeightFileName); if (option_.Verbose) spdlog::info("[eval thread {}] initialize ended", threadId); networkBarrier_.Done(); while (runningEvalThread_) { std::vector<Network::Tensor> inputs; std::vector<std::promise<NetEval>> results; std::size_t batchSize; { std::lock_guard<std::mutex> lock(evalMutex_); batchSize = std::min<std::size_t>(option_.BatchSize, evalTasks_.size()); for (std::size_t batch = 0; batch < batchSize; ++batch) { EvalTask task = std::move(evalTasks_.front()); evalTasks_.pop_front(); inputs.emplace_back(std::move(task.state)); results.emplace_back(std::move(task.task)); } } if (batchSize == 0) continue; std::vector<Network::Tensor> policy(batchSize); Network::Tensor value(batchSize); network->Evaluate(inputs, policy, value); for (std::size_t batch = 0; batch < batchSize; ++batch) { results[batch].set_value( { std::move(policy[batch]), value[batch] }); } } if (option_.Verbose) spdlog::info("[eval thread {}] shutdown", threadId); } void SearchEngine::searchThread(int threadId) { if (!manager_.WaitResume()) { if (option_.Verbose) spdlog::info("[search thread {}] shutdown", threadId); return; } if (option_.Verbose) spdlog::info("[search thread {}] start searching loop", threadId); while (true) { if (manager_.GetState() != SearchState::SEARCHING) { manager_.AckPause(); if (!manager_.WaitResume()) { break; } } // Searching routine Game::Board bd(mainBoard_); TreeNode* tempNowNode = root_; while (tempNowNode->state == ExpandState::EXPANDED) { tempNowNode = tempNowNode->Select(option_); bd.Play(tempNowNode->action); Utils::AtomicAdd(tempNowNode->virtualLoss, option_.VirtualLoss); } const Game::StoneColor current = bd.Opponent(); float valueToUpdate = 0; if (bd.IsEnd()) { const Game::StoneColor winner = bd.GetWinner(); if (winner == current) valueToUpdate = 1; else if (winner != Game::P_NONE) valueToUpdate = -1; } else { Network::Tensor policy; evaluate(bd, policy, valueToUpdate); valueToUpdate *= -1; tempNowNode->Expand(bd, policy); } while (tempNowNode != nullptr) { Utils::AtomicAdd(tempNowNode->values, valueToUpdate); ++tempNowNode->visits; if (tempNowNode != root_) Utils::AtomicAdd(tempNowNode->virtualLoss, -option_.VirtualLoss); tempNowNode = tempNowNode->parentNode; valueToUpdate = -valueToUpdate; } ++numOfSimulations_; } if (option_.Verbose) spdlog::info("[search thread {}] shutdown", threadId); } void SearchEngine::deleteThread() { const auto& deleteNode = [](TreeNode* node) { static void (*impl)(TreeNode*) = [](TreeNode* node) { for (TreeNode* tempNowNode = node->mostLeftChildNode; tempNowNode != nullptr; tempNowNode = tempNowNode->rightSiblingNode) impl(tempNowNode); TreeNode* tempNowNode = node->mostLeftChildNode; TreeNode* nodeToDelete = nullptr; while (tempNowNode != nullptr) { nodeToDelete = tempNowNode; tempNowNode = tempNowNode->rightSiblingNode; delete nodeToDelete; } node->mostLeftChildNode = nullptr; }; impl(node); }; if (option_.Verbose) spdlog::info("[delete thread] start deleting loop"); while (runningDeleteThread_) { std::lock_guard<std::mutex> lock(deleteMutex_); if (deleteTasks_.empty()) continue; TreeNode* nodeToDelete = deleteTasks_.front(); deleteTasks_.pop_front(); deleteNode(nodeToDelete); delete nodeToDelete; } if (option_.Verbose) spdlog::info("[delete thread] shutdown"); } } // namespace AIO::Search
12,236
3,799
/** * Copyright © 2020 IBM Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "zone.hpp" #include "dbus_zone.hpp" #include "fan.hpp" #include "sdbusplus.hpp" #include <nlohmann/json.hpp> #include <phosphor-logging/log.hpp> #include <sdeventplus/event.hpp> #include <algorithm> #include <chrono> #include <iterator> #include <map> #include <memory> #include <numeric> #include <utility> #include <vector> namespace phosphor::fan::control::json { using json = nlohmann::json; using namespace phosphor::logging; const std::map< std::string, std::map<std::string, std::function<std::function<void(DBusZone&, Zone&)>( const json&, bool)>>> Zone::_intfPropHandlers = { {DBusZone::thermalModeIntf, {{DBusZone::supportedProp, zone::property::supported}, {DBusZone::currentProp, zone::property::current}}}}; Zone::Zone(const json& jsonObj, const sdeventplus::Event& event, Manager* mgr) : ConfigBase(jsonObj), _dbusZone{}, _manager(mgr), _defaultFloor(0), _incDelay(0), _decInterval(0), _floor(0), _target(0), _incDelta(0), _decDelta(0), _requestTargetBase(0), _isActive(true), _incTimer(event, std::bind(&Zone::incTimerExpired, this)), _decTimer(event, std::bind(&Zone::decTimerExpired, this)) { // Increase delay is optional, defaults to 0 if (jsonObj.contains("increase_delay")) { _incDelay = std::chrono::seconds(jsonObj["increase_delay"].get<uint64_t>()); } // Poweron target is required setPowerOnTarget(jsonObj); // Default ceiling is optional, defaults to poweron target _defaultCeiling = _poweronTarget; if (jsonObj.contains("default_ceiling")) { _defaultCeiling = jsonObj["default_ceiling"].get<uint64_t>(); } // Start with the current ceiling set as the default ceiling _ceiling = _defaultCeiling; // Default floor is optional, defaults to 0 if (jsonObj.contains("default_floor")) { _defaultFloor = jsonObj["default_floor"].get<uint64_t>(); // Start with the current floor set as the default _floor = _defaultFloor; } // Decrease interval is optional, defaults to 0 // A decrease interval of 0sec disables the decrease timer if (jsonObj.contains("decrease_interval")) { _decInterval = std::chrono::seconds(jsonObj["decrease_interval"].get<uint64_t>()); } // Setting properties on interfaces to be served are optional if (jsonObj.contains("interfaces")) { setInterfaces(jsonObj); } } void Zone::enable() { // Create thermal control dbus object _dbusZone = std::make_unique<DBusZone>(*this); // Init all configured dbus interfaces' property states for (const auto& func : _propInitFunctions) { // Only call non-null init property functions if (func) { func(*_dbusZone, *this); } } // TODO - Restore any persisted properties in init function // Restore thermal control current mode state, if exists _dbusZone->restoreCurrentMode(); // Emit object added for this zone's associated dbus object _dbusZone->emit_object_added(); // A decrease interval of 0sec disables the decrease timer if (_decInterval != std::chrono::seconds::zero()) { // Start timer for fan target decreases _decTimer.restart(_decInterval); } } void Zone::addFan(std::unique_ptr<Fan> fan) { _fans.emplace_back(std::move(fan)); } void Zone::setTarget(uint64_t target) { if (_isActive) { _target = target; for (auto& fan : _fans) { fan->setTarget(_target); } } } void Zone::setActiveAllow(const std::string& ident, bool isActiveAllow) { _active[ident] = isActiveAllow; if (!isActiveAllow) { _isActive = false; } else { // Check all entries are set to allow active fan control auto actPred = [](const auto& entry) { return entry.second; }; _isActive = std::all_of(_active.begin(), _active.end(), actPred); } } void Zone::setFloor(uint64_t target) { // Check all entries are set to allow floor to be set auto pred = [](const auto& entry) { return entry.second; }; if (std::all_of(_floorChange.begin(), _floorChange.end(), pred)) { _floor = target; // Floor above target, update target to floor if (_target < _floor) { requestIncrease(_floor - _target); } } } void Zone::requestIncrease(uint64_t targetDelta) { // Only increase when delta is higher than the current increase delta for // the zone and currently under ceiling if (targetDelta > _incDelta && _target < _ceiling) { auto requestTarget = getRequestTargetBase(); requestTarget = (targetDelta - _incDelta) + requestTarget; _incDelta = targetDelta; // Target can not go above a current ceiling if (requestTarget > _ceiling) { requestTarget = _ceiling; } setTarget(requestTarget); // Restart timer countdown for fan target increase _incTimer.restartOnce(_incDelay); } } void Zone::incTimerExpired() { // Clear increase delta when timer expires allowing additional target // increase requests or target decreases to occur _incDelta = 0; } void Zone::requestDecrease(uint64_t targetDelta) { // Only decrease the lowest target delta requested if (_decDelta == 0 || targetDelta < _decDelta) { _decDelta = targetDelta; } } void Zone::decTimerExpired() { // Check all entries are set to allow a decrease auto pred = [](auto const& entry) { return entry.second; }; auto decAllowed = std::all_of(_decAllowed.begin(), _decAllowed.end(), pred); // Only decrease targets when allowed, a requested decrease target delta // exists, where no requested increases exist and the increase timer is not // running (i.e. not in the middle of increasing) if (decAllowed && _decDelta != 0 && _incDelta == 0 && !_incTimer.isEnabled()) { auto requestTarget = getRequestTargetBase(); // Request target should not start above ceiling if (requestTarget > _ceiling) { requestTarget = _ceiling; } // Target can not go below the defined floor if ((requestTarget < _decDelta) || (requestTarget - _decDelta < _floor)) { requestTarget = _floor; } else { requestTarget = requestTarget - _decDelta; } setTarget(requestTarget); } // Clear decrease delta when timer expires _decDelta = 0; // Decrease timer is restarted since its repeating } void Zone::setPersisted(const std::string& intf, const std::string& prop) { if (std::find_if(_propsPersisted[intf].begin(), _propsPersisted[intf].end(), [&prop](const auto& p) { return prop == p; }) == _propsPersisted[intf].end()) { _propsPersisted[intf].emplace_back(prop); } } bool Zone::isPersisted(const std::string& intf, const std::string& prop) const { auto it = _propsPersisted.find(intf); if (it == _propsPersisted.end()) { return false; } return std::any_of(it->second.begin(), it->second.end(), [&prop](const auto& p) { return prop == p; }); } void Zone::setPowerOnTarget(const json& jsonObj) { if (!jsonObj.contains("poweron_target")) { auto msg = "Missing required zone's poweron target"; log<level::ERR>(msg, entry("JSON=%s", jsonObj.dump().c_str())); throw std::runtime_error(msg); } _poweronTarget = jsonObj["poweron_target"].get<uint64_t>(); } void Zone::setInterfaces(const json& jsonObj) { for (const auto& interface : jsonObj["interfaces"]) { if (!interface.contains("name") || !interface.contains("properties")) { log<level::ERR>("Missing required zone interface attributes", entry("JSON=%s", interface.dump().c_str())); throw std::runtime_error( "Missing required zone interface attributes"); } auto propFuncs = _intfPropHandlers.find(interface["name"].get<std::string>()); if (propFuncs == _intfPropHandlers.end()) { // Construct list of available configurable interfaces auto intfs = std::accumulate( std::next(_intfPropHandlers.begin()), _intfPropHandlers.end(), _intfPropHandlers.begin()->first, [](auto list, auto intf) { return std::move(list) + ", " + intf.first; }); log<level::ERR>("Configured interface not available", entry("JSON=%s", interface.dump().c_str()), entry("AVAILABLE_INTFS=%s", intfs.c_str())); throw std::runtime_error("Configured interface not available"); } for (const auto& property : interface["properties"]) { if (!property.contains("name")) { log<level::ERR>( "Missing required interface property attributes", entry("JSON=%s", property.dump().c_str())); throw std::runtime_error( "Missing required interface property attributes"); } // Attribute "persist" is optional, defaults to `false` auto persist = false; if (property.contains("persist")) { persist = property["persist"].get<bool>(); } // Property name from JSON must exactly match supported // index names to functions in property namespace auto propFunc = propFuncs->second.find(property["name"].get<std::string>()); if (propFunc == propFuncs->second.end()) { // Construct list of available configurable properties auto props = std::accumulate( std::next(propFuncs->second.begin()), propFuncs->second.end(), propFuncs->second.begin()->first, [](auto list, auto prop) { return std::move(list) + ", " + prop.first; }); log<level::ERR>("Configured property not available", entry("JSON=%s", property.dump().c_str()), entry("AVAILABLE_PROPS=%s", props.c_str())); throw std::runtime_error( "Configured property function not available"); } _propInitFunctions.emplace_back( propFunc->second(property, persist)); } } } /** * Properties of interfaces supported by the zone configuration that return * a handler function that sets the zone's property value(s) and persist * state. */ namespace zone::property { // Get a set property handler function for the configured values of the // "Supported" property std::function<void(DBusZone&, Zone&)> supported(const json& jsonObj, bool persist) { std::vector<std::string> values; if (!jsonObj.contains("values")) { log<level::ERR>("No 'values' found for \"Supported\" property, " "using an empty list", entry("JSON=%s", jsonObj.dump().c_str())); } else { for (const auto& value : jsonObj["values"]) { if (!value.contains("value")) { log<level::ERR>("No 'value' found for \"Supported\" property " "entry, skipping", entry("JSON=%s", value.dump().c_str())); } else { values.emplace_back(value["value"].get<std::string>()); } } } return Zone::setProperty<std::vector<std::string>>( DBusZone::thermalModeIntf, DBusZone::supportedProp, &DBusZone::supported, std::move(values), persist); } // Get a set property handler function for a configured value of the // "Current" property std::function<void(DBusZone&, Zone&)> current(const json& jsonObj, bool persist) { // Use default value for "Current" property if no "value" entry given if (!jsonObj.contains("value")) { log<level::INFO>("No 'value' found for \"Current\" property, " "using default", entry("JSON=%s", jsonObj.dump().c_str())); // Set persist state of property return Zone::setPropertyPersist(DBusZone::thermalModeIntf, DBusZone::currentProp, persist); } return Zone::setProperty<std::string>( DBusZone::thermalModeIntf, DBusZone::currentProp, &DBusZone::current, jsonObj["value"].get<std::string>(), persist); } } // namespace zone::property } // namespace phosphor::fan::control::json
13,666
3,864
#ifndef MPLLIBS_METAMONAD_TYPECLASS_HPP #define MPLLIBS_METAMONAD_TYPECLASS_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <mpllibs/metamonad/v1/typeclass.hpp> #include <mpllibs/metamonad/typeclass_expect.hpp> #include <mpllibs/metamonad/typeclass_expectations.hpp> #endif
467
199
 #include "astronomy/time_scales.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "quantities/astronomy.hpp" #include "testing_utilities/almost_equals.hpp" #include "testing_utilities/approximate_quantity.hpp" #include "testing_utilities/is_near.hpp" #include "testing_utilities/numerics.hpp" namespace principia { namespace astronomy { namespace internal_time_scales { using quantities::astronomy::JulianYear; using quantities::si::Day; using quantities::si::Degree; using quantities::si::Hour; using quantities::si::Micro; using quantities::si::Milli; using quantities::si::Minute; using quantities::si::Nano; using testing_utilities::AbsoluteError; using testing_utilities::AlmostEquals; using testing_utilities::IsNear; using testing_utilities::operator""_⑴; using ::testing::AllOf; using ::testing::Eq; using ::testing::Gt; using ::testing::Lt; constexpr Instant j2000_week = "1999-W52-6T12:00:00"_TT; constexpr Instant j2000_from_tt = "2000-01-01T12:00:00"_TT; constexpr Instant j2000_from_tai = "2000-01-01T11:59:27,816"_TAI; constexpr Instant j2000_from_utc = "2000-01-01T11:58:55,816"_UTC; constexpr Instant j2000_tai = "2000-01-01T12:00:00"_TAI; constexpr Instant j2000_tai_from_tt = "2000-01-01T12:00:32,184"_TT; class TimeScalesTest : public testing::Test { protected: static constexpr bool OneMicrosecondApart(Instant const& t1, Instant const& t2) { return t1 - t2 <= 1 * Micro(Second) && t1 - t2 >= - 1 * Micro(Second); } }; using TimeScalesDeathTest = TimeScalesTest; // The checks are giant boolean expressions which are entirely repeated in the // error message; we try to match the relevant part. TEST_F(TimeScalesDeathTest, LeaplessScales) { EXPECT_DEATH("2015-06-30T23:59:60"_TT, "!tt.time...is_leap_second.."); EXPECT_DEATH("2015-06-30T23:59:60"_TAI, "!tai.time...is_leap_second.."); EXPECT_DEATH("2015-06-30T23:59:60"_UT1, "!ut1.time...is_leap_second.."); } TEST_F(TimeScalesDeathTest, BeforeRange) { EXPECT_DEATH("1960-12-31T23:59:59,999"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1830-04-10T23:59:59,999"_UT1, "mjd.TimeSince20000101T120000Z.ut1.. >= " "experimental_eop_c02.front...ut1_mjd"); } TEST_F(TimeScalesDeathTest, WarWasBeginning) { EXPECT_DEATH("2101-01-01T00:00:00"_UTC, "leap_seconds.size"); EXPECT_DEATH("2101-01-01T00:00:00"_UT1, "TimeSince20000101T120000Z.ut1. < eop_c04.back...ut1.."); } TEST_F(TimeScalesDeathTest, FirstUnknownUTC) { EXPECT_DEATH("2021-12-31T23:59:60"_UTC, "leap_seconds.size"); EXPECT_DEATH("2021-12-31T24:00:00"_UTC, "leap_seconds.size"); EXPECT_DEATH("2022-01-01T00:00:00"_UTC, "leap_seconds.size"); } TEST_F(TimeScalesDeathTest, StretchyLeaps) { EXPECT_DEATH("1961-07-31T23:59:59,950"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1963-10-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-03-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-08-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-12-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-02-28T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-06-30T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-08-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1968-01-31T23:59:59,900"_UTC, "IsValidStretchyUTC"); } TEST_F(TimeScalesDeathTest, ModernLeaps) { EXPECT_DEATH("2015-12-31T23:59:60"_UTC, "IsValidModernUTC"); } TEST_F(TimeScalesTest, ConstexprJ2000) { static_assert(j2000_week == J2000); static_assert(j2000_from_tt == J2000); static_assert(j2000_from_tai == J2000); static_assert(j2000_from_utc == J2000); static_assert(j2000_tai == j2000_tai_from_tt); static_assert(j2000_tai - J2000 == 32.184 * Second); } TEST_F(TimeScalesTest, ConstexprWeeks) { // Check that week dates that go to the previous year work. static_assert("1914-W01-1T00:00:00"_TT == "19131229T000000"_TT); } TEST_F(TimeScalesTest, ConstexprMJD2000) { constexpr Instant mjd51544_utc = "2000-01-01T00:00:00"_UTC; constexpr Instant mjd51544_utc_from_ut1 = "2000-01-01T00:00:00,355"_UT1 + 388.0 * Micro(Second); static_assert(mjd51544_utc - mjd51544_utc_from_ut1 < 1 * Nano(Second)); static_assert(mjd51544_utc - mjd51544_utc_from_ut1 > -1 * Nano(Second)); } TEST_F(TimeScalesTest, ReferenceDates) { EXPECT_THAT("1858-11-17T00:00:00"_TT, Eq("MJD0"_TT)); EXPECT_THAT(j2000_week, Eq(J2000)); EXPECT_THAT(j2000_from_tt, Eq(J2000)); EXPECT_THAT(j2000_from_tai, Eq(J2000)); EXPECT_THAT(j2000_from_utc, Eq(J2000)); EXPECT_THAT(j2000_tai, Eq(j2000_tai_from_tt)); EXPECT_THAT(j2000_tai - J2000, Eq(32.184 * Second)); // Besselian epochs. constexpr Instant B1900 = "1899-12-31T00:00:00"_TT + 0.8135 * Day; Instant const JD2415020_3135 = "JD2415020.3135"_TT; EXPECT_THAT(B1900, AlmostEquals(JD2415020_3135, 1)); EXPECT_THAT(testing_utilities::AbsoluteError(JD2415020_3135, B1900), IsNear(0.5_⑴ * Micro(Second))); constexpr Instant B1950 = "1949-12-31T00:00:00"_TT + 0.9235 * Day; Instant const JD2433282_4235 = "JD2433282.4235"_TT; EXPECT_THAT(B1950, AlmostEquals(JD2433282_4235, 0)); } TEST_F(TimeScalesTest, LeapSecond) { Instant const eleven_fifty_nine_and_fifty_eight_seconds = "2015-06-30T23:59:58"_UTC; EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 1 * Second, Eq("2015-06-30T23:59:59"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 1.5 * Second, Eq("2015-06-30T23:59:59,5"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 2 * Second, Eq("2015-06-30T23:59:60"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 2.5 * Second, Eq("2015-06-30T23:59:60,5"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 3 * Second, Eq("2015-06-30T24:00:00"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 3 * Second, Eq("2015-07-01T00:00:00"_UTC)); constexpr Instant end_of_december_2016 = "2016-12-31T24:00:00"_UTC; EXPECT_THAT(end_of_december_2016 - 2 * Second, Eq("2016-12-31T23:59:59"_UTC)); EXPECT_THAT(end_of_december_2016 - 1 * Second, Eq("2016-12-31T23:59:60"_UTC)); EXPECT_THAT(end_of_december_2016 - 0 * Second, Eq("2017-01-01T00:00:00"_UTC)); EXPECT_THAT("2016-12-31T23:59:59"_UTC - "2016-12-31T23:59:59"_TAI, Eq(36 * Second)); EXPECT_THAT("2017-01-01T00:00:00"_UTC - "2017-01-01T00:00:00"_TAI, Eq(37 * Second)); } // See the list of steps at // https://hpiers.obspm.fr/iers/bul/bulc/TimeSteps.history. // Note that while the same file is used to check that the date string is valid // with respect to positive or negative leap seconds, the actual conversion is // based exclusively on https://hpiers.obspm.fr/iers/bul/bulc/UTC-TAI.history, // so this provides some sort of cross-checking. TEST_F(TimeScalesTest, StretchyLeaps) { EXPECT_THAT(AbsoluteError("1961-07-31T24:00:00,000"_UTC - 0.050 * Second, "1961-07-31T23:59:59,900"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1961-08-01T00:00:00"_UTC, "1961-08-01T00:00:01,648"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1963-10-31T24:00:00,000"_UTC - 0.100 * Second, "1963-10-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1963-11-01T00:00:00"_UTC, "1963-11-01T00:00:02,697"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T24:00:00,000"_UTC - 0.100 * Second, "1964-03-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1964-04-01T00:00:00"_UTC, "1964-04-01T00:00:02,984"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-08-31T24:00:00,000"_UTC - 0.100 * Second, "1964-08-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1964-09-01T00:00:00"_UTC, "1964-09-01T00:00:03,282"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-12-31T24:00:00,000"_UTC - 0.100 * Second, "1964-12-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-01-01T00:00:00"_UTC, "1965-01-01T00:00:03,540"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-02-28T24:00:00,000"_UTC - 0.100 * Second, "1965-02-28T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-03-01T00:00:00"_UTC, "1965-03-01T00:00:03,717"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-06-30T24:00:00,000"_UTC - 0.100 * Second, "1965-06-30T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-07-01T00:00:00"_UTC, "1965-07-01T00:00:03,975"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-08-31T24:00:00,000"_UTC - 0.100 * Second, "1965-08-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-09-01T00:00:00"_UTC, "1965-09-01T00:00:04,155"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1968-01-31T24:00:00,000"_UTC - 0.100 * Second, "1968-01-31T23:59:59,800"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1968-02-01T00:00:00"_UTC, "1968-02-01T00:00:06,186"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1971-12-31T24:00:00,000"_UTC - 0.107'7580 * Second, "1971-12-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1972-01-01T00:00:00"_UTC, "1972-01-01T00:00:10,000"_TAI), Lt(0.5 * Milli(Second))); } TEST_F(TimeScalesTest, StretchyRates) { // Check that cancellations aren't destroying the test. EXPECT_NE("1961-01-01T00:00:00"_UTC + 1 * Minute / (1 - 150e-10), "1961-01-01T00:00:00"_UTC + 1 * Minute / (1 - 130e-10)); quantities::Time utc_minute; utc_minute = 1 * Minute / (1 - 150e-10); EXPECT_THAT("1961-01-01T00:00:00"_UTC + utc_minute, Eq("1961-01-01T00:01:00"_UTC)); EXPECT_THAT("1961-12-31T23:59:00"_UTC + utc_minute, Eq("1961-12-31T24:00:00"_UTC)); utc_minute = 1 * Minute / (1 - 130e-10); EXPECT_THAT("1962-01-01T00:00:00"_UTC + utc_minute, Eq("1962-01-01T00:01:00"_UTC)); EXPECT_THAT("1963-12-31T23:59:00"_UTC + utc_minute, Eq("1963-12-31T24:00:00"_UTC)); utc_minute = 1 * Minute / (1 - 150e-10); EXPECT_THAT("1964-01-01T00:00:00"_UTC + utc_minute, Eq("1964-01-01T00:01:00"_UTC)); EXPECT_THAT("1965-12-31T23:59:00"_UTC + utc_minute, AlmostEquals("1965-12-31T24:00:00"_UTC, 1)); utc_minute = 1 * Minute / (1 - 300e-10); EXPECT_THAT("1966-01-01T00:00:00"_UTC + utc_minute, Eq("1966-01-01T00:01:00"_UTC)); EXPECT_THAT("1971-12-31T23:58:00"_UTC + utc_minute, Eq("1971-12-31T23:59:00"_UTC)); utc_minute = 1 * Minute; EXPECT_THAT("1972-01-01T00:00:00"_UTC + utc_minute, Eq("1972-01-01T00:01:00"_UTC)); EXPECT_THAT("2000-01-01T00:00:00"_UTC + utc_minute, Eq("2000-01-01T00:01:00"_UTC)); } TEST_F(TimeScalesTest, UT1Continuity) { // Continuity with TAI. We have a fairly low resolution for UT1 at that time, // as well as high errors (~20 ms), and TAI was synchronized with UT2 anyway, // so it's not going to get much better than 100 ms. EXPECT_THAT( AbsoluteError("1958-01-01T00:00:00"_UT1, "1958-01-01T00:00:00"_TAI), Lt(100 * Milli(Second))); // Continuity at the beginning of the EOP C02 series. EXPECT_THAT(AbsoluteError("1961-12-31T23:59:59,000"_UT1, "1961-12-31T23:59:58,967"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:00,000"_UT1, "1961-12-31T23:59:59,967"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:00,033"_UT1, "1962-01-01T00:00:00,000"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:01,033"_UT1, "1962-01-01T00:00:01,000"_UTC), Lt(0.5 * Milli(Second))); // Continuity across a stretchy UTC leap. EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,000"_UT1, "1964-03-31T23:59:59,160"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,900"_UT1, "1964-03-31T23:59:60,060"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,940"_UT1, "1964-04-01T00:00:00,000"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-04-01T00:00:00,000"_UT1, "1964-04-01T00:00:00,060"_UTC), Lt(0.5 * Milli(Second))); } // Check the times of the lunar eclipses in LunarEclipseTest. TEST_F(TimeScalesTest, LunarEclipses) { EXPECT_THAT(AbsoluteError("1950-04-02T20:44:34.0"_TT, "1950-04-02T20:44:04.8"_UT1), Lt(14 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-04-02T20:49:16.7"_TT, "1950-04-02T20:48:47.5"_UT1), Lt(14 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-09-26T04:17:11.4"_TT, "1950-09-26T04:16:42.1"_UT1), Lt(86 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-09-26T04:21:55.5"_TT, "1950-09-26T04:21:26.1"_UT1), Lt(15 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-03-23T10:37:33.2"_TT, "1951-03-23T10:37:03.7"_UT1), Lt(92 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-03-23T10:50:16.8"_TT, "1951-03-23T10:49:47.3"_UT1), Lt(92 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-09-15T12:27:06.3"_TT, "1951-09-15T12:26:36.6"_UT1), Lt(99 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-09-15T12:38:51.5"_TT, "1951-09-15T12:38:21.8"_UT1), Lt(99 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-02-11T00:28:39.9"_TT, "1952-02-11T00:28:10.0"_UT1), Lt(69 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-02-11T00:39:47.6"_TT, "1952-02-11T00:39:17.7"_UT1), Lt(69 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-08-05T19:40:29.4"_TT, "1952-08-05T19:39:59.3"_UT1), Lt(57 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-08-05T19:47:54.8"_TT, "1952-08-05T19:47:24.7"_UT1), Lt(57 * Milli(Second))); EXPECT_THAT(AbsoluteError("2000-01-21T04:41:30.5"_TT, "2000-01-21T04:40:26.7"_UT1), Lt(45 * Milli(Second))); EXPECT_THAT(AbsoluteError("2000-01-21T04:44:34.5"_TT, "2000-01-21T04:43:30.6"_UT1), Lt(56 * Milli(Second))); EXPECT_THAT("2048-01-01T06:53:54.8"_TT - "2048-01-01T06:52:23.6"_TT, AlmostEquals(91.2 * Second, 3e6, 4e6)); EXPECT_THAT("2048-01-01T06:58:19.8"_TT - "2048-01-01T06:56:48.6"_TT, AlmostEquals(91.2 * Second, 3e6, 4e6)); } TEST_F(TimeScalesTest, JulianDate) { static_assert("2010-01-04T00:00:00.108"_TT == "JD2455200.50000125"_TT, "Dates differ"); static_assert("2010-01-04T00:00:00.000"_TT == "JD2455200.50000"_TT, "Dates differ"); static_assert("2010-01-04T12:00:00.000"_TT == "JD2455201.00000"_TT, "Dates differ"); static_assert("2010-01-04T18:00:00.000"_TT == "JD2455201.25000"_TT, "Dates differ"); static_assert(OneMicrosecondApart("2010-01-04T02:57:46.659"_TT, "JD2455200.623456701388"_TT), "Dates differ"); static_assert("2000-01-01T00:00:00"_TT == "JD2451544.5"_TT, "Dates differ"); static_assert("2000-01-01T12:00:00"_TT == "JD2451545"_TT, "Dates differ"); EXPECT_THAT("JD2451545"_TT, Eq(j2000_week)); EXPECT_THAT("JD2455201.00000"_TT, Eq("2010-01-04T12:00:00.000"_TT)); double const jd = 2457662.55467; Instant const date = Instant() + (jd - 2451545.0) * Day; EXPECT_THAT("JD2457662.55467"_TT, AllOf(Lt(date + 1.0 * Second), Gt(date - 1.0 * Second))) << date - "JD2457662.55467"_TT; } TEST_F(TimeScalesTest, ModifiedJulianDate) { static_assert("2010-01-04T00:00:00.123"_TT == "MJD55200.0000014236111"_TT, "Dates differ"); static_assert("2010-01-04T00:00:00.000"_TT == "MJD55200.00000"_TT, "Dates differ"); static_assert("2010-01-04T12:00:00.000"_TT == "MJD55200.50000"_TT, "Dates differ"); static_assert("2010-01-04T18:00:00.000"_TT == "MJD55200.75000"_TT, "Dates differ"); static_assert(OneMicrosecondApart("2010-01-04T02:57:46.659"_TT, "MJD55200.123456701388"_TT), "Dates differ"); EXPECT_THAT("MJD0.0"_TT, Eq("1858-11-17T00:00:00"_TT)); EXPECT_THAT("MJD55200.0000"_TT, Eq("2010-01-04T00:00:00.000"_TT)); EXPECT_THAT("MJD55200.0000014236111"_TT, Eq("2010-01-04T00:00:00.123"_TT)); } TEST_F(TimeScalesDeathTest, JulianDateUTC) { EXPECT_DEATH("JD2451545"_UTC, "size > 0"); EXPECT_DEATH("MJD55200.123"_UTC, "size > 0"); } TEST_F(TimeScalesTest, EarthRotationAngle) { constexpr double revolutions_at_j2000_ut1 = 0.7790572732640; constexpr double excess_revolutions_per_ut1_day = 0.00273781191135448; // Round-trip from UT1, comparing with the direct computation from UT1. static_assert(EarthRotationAngle("JD2451545.0"_UT1) == 2 * π * Radian * revolutions_at_j2000_ut1, "Angles differ"); EXPECT_THAT( EarthRotationAngle("JD2455200.0"_UT1), AlmostEquals(2 * π * Radian * (revolutions_at_j2000_ut1 + excess_revolutions_per_ut1_day * (2455200 - 2451545)), 142)); EXPECT_THAT( EarthRotationAngle("JD2455200.623456701388"_UT1), AlmostEquals( 2 * π * Radian * (0.623456701388 + revolutions_at_j2000_ut1 + excess_revolutions_per_ut1_day * (5200.623456701388 - 1545) - 1), 134)); // Compare with the WGCCRE 2009 elements. EXPECT_THAT( (EarthRotationAngle(J2000) - π / 2 * Radian) - 190.147 * Degree, IsNear(0.0469_⑴ * Degree)); EXPECT_THAT((EarthRotationAngle("2000-01-01T23:00:00"_TT) - EarthRotationAngle("2000-01-01T01:00:00"_TT)) / (22 * Hour) - 360.9856235 * (Degree / Day), IsNear(-0.0000149_⑴ * Degree / Day)); EXPECT_THAT((EarthRotationAngle("2010-01-01T23:00:00"_TT) - EarthRotationAngle("2010-01-01T01:00:00"_TT)) / (22 * Hour) - 360.9856235 * (Degree / Day), IsNear(-0.0000137_⑴ * Degree / Day)); } TEST_F(TimeScalesTest, GNSS) { // BeiDou Navigation Satellite System // Signal In Space Interface Control Document // Open Service Signals B1C and B2a (Test Version), // 3.3 Time System. // The start epoch of BDT is 00:00:00 on January 1, 2006 of Coordinated // Universal Time (UTC). EXPECT_THAT("2006-01-01T00:00:00"_北斗, Eq("2006-01-01T00:00:00"_UTC)); // Galileo OS SIS ICD, Issue 1.1. // 5.1.2. Galileo System Time (GST). // The GST start epoch shall be 00:00 UT on Sunday 22nd August 1999 (midnight // between 21st and 22nd August). At the start epoch, GST shall be ahead of // UTC by thirteen (13) leap seconds. EXPECT_THAT("1999-08-22T00:00:13"_GPS, Eq("1999-08-22T00:00:00"_UTC)); } } // namespace internal_time_scales } // namespace astronomy } // namespace principia
20,317
10,925
#include <iostream> #include "include/CCustomEngineListener.h" #include <TDEngine2.h> #include <thread> #if defined (TDE2_USE_WIN32PLATFORM) #pragma comment(lib, "TDEngine2.lib") #endif using namespace TDEngine2; int main(int argc, char** argv) { E_RESULT_CODE result = RC_OK; IEngineCoreBuilder* pEngineCoreBuilder = CreateConfigFileEngineCoreBuilder(CreateEngineCore, "settings.cfg", result); if (result != RC_OK) { return -1; } IEngineCore* pEngineCore = pEngineCoreBuilder->GetEngineCore(); pEngineCoreBuilder->Free(); IEngineListener* pCustomListener = new CCustomEngineListener(); pEngineCore->RegisterListener(pCustomListener); pEngineCore->Run(); pEngineCore->Free(); delete pCustomListener; return 0; }
744
271
#ifndef CONFIGURATION_FILES_PREPARER #define CONFIGURATION_FILES_PREPARER #include <vector> #include <string> #include <map> #include <set> #include <algorithm> #include <iterator> #include "Chain.h" #include "MorphologicalDictionary.h" #include "DisambiguatorSettingsRus.h" #include "FileReader.h" #include "FileWriter.h" #include "IDisambiguatorSettings.h" #include "OpenCorporaToSynagrusConverter.h" #include "SchemaFeatureCalculatorRus.h" #include "Token.h" #include "Tools.h" using std::vector; using std::wstring; using std::map; using std::set; using std::string; namespace Disambiguation { const int FREQUENT_TOKENS_THRESHOLD = 300; struct SentenceItem : public Tokenization::Token { wstring label; vector<wstring> possibleStates; }; class ConfigPreparerRus { typedef vector<SentenceItem> Sentence; typedef unordered_map<wstring, unordered_map<wstring, int> > MapMapInt; typedef TagsetConverting::OpenCorporaToSynagrusConverter ConverterType; public: ConfigPreparerRus( shared_ptr<IDisambiguatorSettings> settings); void PrepareConfigurationFiles(); private: MapMapInt tokenLabelFrequencyDistribution; map<wstring, int> unitedLabels; map<wstring, int> unitedPOSs; MapMapInt translationsForUntranslatedTokens; vector<Sentence> sentences; shared_ptr<MorphologicalDictionary> dictionary; shared_ptr<ConverterType> converter; shared_ptr<DataFunctor> trainingSetFunctor; void readSentences(); void findPossibleStates(); void getTokenFrequency(); void getUnitedLabelsFrequency(); void getUnitedPOSFrequency(); void getTranslationsForUntranslatedTokens(); void prepareFileWithTranslationsForFeatureCalculatorRus(); wstring translateInputToOutputProperty( const wstring& prop) const; }; ConfigPreparerRus::ConfigPreparerRus( shared_ptr<IDisambiguatorSettings> settings) : dictionary(settings->GetDictionary()) , converter(dynamic_pointer_cast<DisambiguatorSettingsRus>(settings)->GetOpenCorporaToSynTagRusConverter()) , trainingSetFunctor(settings->GetTrainingFunctor()) { } void ConfigPreparerRus::PrepareConfigurationFiles() { wcout << L"Reading sentences..." << std::endl; readSentences(); wcout << L"\nFinding possible states using dictionary..." << std::endl; findPossibleStates(); wcout << L"\nFinding token frequency..." << std::endl; getTokenFrequency(); wcout << L"\nGet united labels frequency..." << std::endl; getUnitedLabelsFrequency(); wcout << L"\nGet united POS frequency..." << std::endl; getUnitedPOSFrequency(); wcout << L"\nGet translations for untranslated sentences..." << std::endl; getTranslationsForUntranslatedTokens(); wcout << L"\nPrepare file for feature calculator..." << std::endl; prepareFileWithTranslationsForFeatureCalculatorRus(); } void ConfigPreparerRus::readSentences() { sentences.clear(); wifstream in(string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/Token_Label.txt"); Tools::SetLocale(in); wstring line; vector<wstring> splitted; int enumerator = 0; int sentenceEnumerator = 0; sentences.emplace_back(Sentence()); while (getline(in, line)) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } splitted = Tools::Split(line, L"\t"); if (splitted.size() != 2) { ++sentenceEnumerator; if (!(*trainingSetFunctor)(sentenceEnumerator)) { continue; } else { sentences.emplace_back(Sentence()); continue; } } else if (!(*trainingSetFunctor)(sentenceEnumerator)) { continue; } SentenceItem token; token.label = splitted[1]; splitted = Tools::Split(wstring(splitted[0]), L"|"); token.content = splitted[0]; token.punctuation.push_back(splitted.size() > 1 ? splitted[1] : L""); sentences.back().push_back(token); } in.close(); } void ConfigPreparerRus::findPossibleStates() { size_t enumerator = 0; // Iterate over sentences for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { Sentence& sentence = sentences[sentenceIndex]; // Iterate over tokens in sentence for (size_t tokenIndex = 0; tokenIndex < sentence.size(); ++tokenIndex) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } SentenceItem& sentenceItem = sentence[tokenIndex]; wstring& token = sentenceItem.content; vector<wstring>& labels = sentenceItem.possibleStates; // Create labels if (Tools::IsNumber(token)) { labels.push_back(L"NUM"); } else if (Tools::ContainsLatin(token)) { labels.push_back(L"NID"); } else { shared_ptr<vector<shared_ptr<Morphology> > > morphology = std::make_shared<vector<shared_ptr<Morphology> > >(); dictionary->getMorphology(token, morphology); for (size_t morphIndex = 0; morphIndex < morphology->size(); ++morphIndex) { vector<shared_ptr<wstring> >& opFeatures = (*morphology)[morphIndex]->features; if (opFeatures.size() == 0) { continue; } wstring opLabel = *(opFeatures[0]); for (size_t iter = 1; iter < opFeatures.size(); ++iter) { opLabel += L" - " + *(opFeatures[iter]); } vector<wstring> syntagLabel = converter->PartialConvert(opLabel); labels.insert(labels.end(), syntagLabel.begin(), syntagLabel.end()); } } if (labels.size() == 0) { labels.push_back(L"UNKNOWN"); } // Unique labels vector<wstring> uniqueLabels = labels; std::sort(uniqueLabels.begin(), uniqueLabels.end()); labels.clear(); std::unique_copy(uniqueLabels.begin(), uniqueLabels.end(), std::back_inserter(labels)); } } } void ConfigPreparerRus::getTokenFrequency() { size_t enumerator = 0; // Iterate over sentences for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { Sentence& sentence = sentences[sentenceIndex]; // Iterate over tokens in sentence for (size_t tokenIndex = 0; tokenIndex < sentence.size(); ++tokenIndex) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } const SentenceItem& sentenceItem = sentence[tokenIndex]; const wstring& token = sentenceItem.content; const wstring& label = sentenceItem.label; if (tokenLabelFrequencyDistribution.find(token) == tokenLabelFrequencyDistribution.end()) { tokenLabelFrequencyDistribution[token] = unordered_map<wstring, int>(); } unordered_map<wstring, int>& currentDistribution = tokenLabelFrequencyDistribution[token]; if (currentDistribution.find(label) != currentDistribution.end()) { ++currentDistribution[label]; } else { currentDistribution[label] = 1; } } } FileManager::Write(string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/Token_LabelFrequencyDistribution.txt" , tokenLabelFrequencyDistribution, L'\t', L',', L'~'); } void ConfigPreparerRus::getUnitedLabelsFrequency() { size_t enumerator = 0; // Iterate over sentences for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { Sentence& sentence = sentences[sentenceIndex]; // Iterate over tokens in sentence for (size_t tokenIndex = 0; tokenIndex < sentence.size(); ++tokenIndex) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } const SentenceItem& sentenceItem = sentence[tokenIndex]; const vector<wstring>& possibleLabels = sentenceItem.possibleStates; const wstring& label = sentenceItem.label; wstring unitedLabel = GetUnitedLabel(possibleLabels); if (unitedLabel.size() == 0) { unitedLabel = label; } if (unitedLabels.find(unitedLabel) != unitedLabels.end()) { ++unitedLabels[unitedLabel]; } else { unitedLabels[unitedLabel] = 1; } } } FileManager::Write( string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/UnitedLabels.csv", unitedLabels, L','); } void ConfigPreparerRus::getUnitedPOSFrequency() { size_t enumerator = 0; // Iterate over sentences for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { Sentence& sentence = sentences[sentenceIndex]; // Iterate over tokens in sentence for (size_t tokenIndex = 0; tokenIndex < sentence.size(); ++tokenIndex) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } const SentenceItem& sentenceItem = sentence[tokenIndex]; const vector<wstring>& possibleLabels = sentenceItem.possibleStates; wstring unitedLabel = GetUnitedPOS(possibleLabels); if (unitedPOSs.find(unitedLabel) != unitedPOSs.end()) { ++unitedPOSs[unitedLabel]; } else { unitedPOSs[unitedLabel] = 1; } } } FileManager::Write( string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/UnitedPOS.csv", unitedPOSs, L','); } void ConfigPreparerRus::getTranslationsForUntranslatedTokens() { size_t enumerator = 0; // Construct untranslated tokens unordered_set<wstring> untranslatedTokens; for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { for (size_t tokenIndex = 0; tokenIndex < sentences[sentenceIndex].size() ; ++tokenIndex) { ++enumerator; if (enumerator % 100 == 0) { wcout << L"\r" << enumerator; } const SentenceItem& item = sentences[sentenceIndex][tokenIndex]; const wstring& token = item.content; const wstring& label = item.label; const vector<wstring>& possibleStates = item.possibleStates; bool found = false; for (size_t stateIndex = 0; stateIndex < possibleStates.size(); ++stateIndex) { if (translateInputToOutputProperty(possibleStates[stateIndex]) == label) { found = true; break; } } if (!found) { untranslatedTokens.insert(token); } } } // Fill untranslated tokens for (size_t sentenceIndex = 0; sentenceIndex < sentences.size() ; ++sentenceIndex) { for (size_t tokenIndex = 0; tokenIndex < sentences[sentenceIndex].size() ; ++tokenIndex) { const SentenceItem& item = sentences[sentenceIndex][tokenIndex]; const wstring& token = item.content; const wstring& label = item.label; if (untranslatedTokens.find(token) == untranslatedTokens.end()) { continue; } if (translationsForUntranslatedTokens.find(token) == translationsForUntranslatedTokens.end()) { translationsForUntranslatedTokens[token] = unordered_map<wstring, int>(); } unordered_map<wstring, int>& currentDistribution = translationsForUntranslatedTokens[token]; if (currentDistribution.find(label) != currentDistribution.end()) { ++currentDistribution[label]; } else { currentDistribution[label] = 1; } } } FileManager::Write( string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/UntranslatedTokens.txt" , translationsForUntranslatedTokens, L'\t', L',', L'~'); } void ConfigPreparerRus::prepareFileWithTranslationsForFeatureCalculatorRus() { wofstream out( string(DISAMBIGUATOR_CONFIG_FOLDER_STRING) + "RU/FileTranslationsForFeatureCalculatorRus.txt"); Tools::SetLocale(out); for (auto iter = tokenLabelFrequencyDistribution.begin() ; iter != tokenLabelFrequencyDistribution.end(); ++iter) { const wstring& token = iter->first; const unordered_map<wstring, int>& current = iter->second; int frequency = 0; for (auto iter1 = current.begin(); iter1 != current.end(); ++iter1) { frequency += iter1->second; } if (frequency >= FREQUENT_TOKENS_THRESHOLD) { out << token << L"\t"; auto translationIterator = current.begin(); while (translationIterator != current.end()) { if (static_cast<double>(translationIterator->second) / static_cast<double>(frequency) > 0.001) { out << translationIterator->first; ++translationIterator; if (translationIterator != current.end()) { out << L","; } } else { ++translationIterator; } } out << std::endl; } } out.close(); } wstring ConfigPreparerRus::translateInputToOutputProperty( const wstring& prop) const { return Tools::Replace(Tools::Replace(prop, L"@PEREH", L""), L"@NEPEREH", L""); } } #endif // CONFIGURATION_FILES_PREPARER
14,440
4,224
/*========================== begin_copyright_notice ============================ Copyright (c) 2017-2021 Intel Corporation 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. ============================= end_copyright_notice ===========================*/ #ifndef _IGA_IR_DUANALYSIS_HPP #define _IGA_IR_DUANALYSIS_HPP #include "../IR/RegSet.hpp" #include "../IR/Kernel.hpp" #include <ostream> #include <string> #include <vector> namespace iga { // A live range is a path from a definition of some register values to // a use. The use may be a read (typical case) or a write (since we need // to be able to track WAW dependencies). struct Dep { // If the use is a read, this will be READ. // WRITE indicates that bytes are being redefined. // E.g. // mov r0 ... // mul r1:q .. r0 // RAW dependency (on the add) // add r0 ... // WAR dependency // add r1:d ... // WAW enum Type {RAW, WAR, WAW} useType = RAW; // // The producer instruction; // this can be nullptr if the value is a program input Instruction *def = nullptr; // // The consumer instruction; // this can be nullptr if the value is a program output Instruction *use = nullptr; // or write (redef) // // The register values that are live in this path RegSet values; // // This is number of in-order instructions this path covers // We determine in-orderness via OpSpec::isFixedLatency int minInOrderDist = 0; // // indicates if the dependency crosses a branch (JEU) // N.b. this will false for fallthrough since that isn't a branch // mov r1 ... // (f0.0) jmpi TARGET // add ... r1 // crossesBranch = false here // TARGET: // mul ... r1 // crossesBranch = true here bool crossesBranch = false; Dep(const Model &m) : values(m) { } Dep(Type t, Instruction *_use) : useType(t) , def(nullptr) , use(_use) , values(*Model::LookupModel(_use->platform())) , minInOrderDist(0) , crossesBranch(false) { } Dep(const Dep &) = default; Dep &operator=(const Dep &) = default; bool operator==(const Dep &p) const; bool operator!=(const Dep &p) const { return !(*this == p); } // for debug void str(std::ostream &os) const; std::string str() const; }; struct BlockInfo { Block *block; std::vector<Dep> liveDefsIn; std::vector<Dep> liveDefsOut; BlockInfo(Block *blk) : block(blk) { } BlockInfo(const BlockInfo &) = default; // BlockInfo(BlockInfo &&) = default; }; struct DepAnalysis { // information on each block std::vector<BlockInfo> blockInfo; // // relation of definitions and uses std::vector<Dep> deps; }; // the primary entry point for the live analysis DepAnalysis ComputeDepAnalysis(Kernel *k); } // namespace IGA #endif // _IGA_IR_ANALYSIS_HPP
4,304
1,289
// Eggs.SD-6 // // Copyright Agustin K-ballo Berge, Fusion Fenix 2015 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <iterator> void test_make_reverse_iterator() { std::reverse_iterator<int*> p{std::make_reverse_iterator((int*)0)}; } int main() { test_make_reverse_iterator(); }
404
158
#include "amuse/AudioGroup.hpp" #include <regex> #include <sstream> #include "amuse/AudioGroupData.hpp" #include <athena/FileReader.hpp> #include <fmt/ostream.h> using namespace std::literals; namespace amuse { void AudioGroup::assign(const AudioGroupData& data) { m_pool = AudioGroupPool::CreateAudioGroupPool(data); m_proj = AudioGroupProject::CreateAudioGroupProject(data); m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(data); m_samp = data.getSamp(); } void AudioGroup::assign(SystemStringView groupPath) { /* Reverse order when loading intermediates */ m_groupPath = groupPath; m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(groupPath); m_pool = AudioGroupPool::CreateAudioGroupPool(groupPath); m_proj = AudioGroupProject::CreateAudioGroupProject(groupPath); m_samp = nullptr; } void AudioGroup::assign(const AudioGroup& data, SystemStringView groupPath) { /* Reverse order when loading intermediates */ m_groupPath = groupPath; m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(groupPath); m_pool = AudioGroupPool::CreateAudioGroupPool(groupPath); m_proj = AudioGroupProject::CreateAudioGroupProject(data.getProj()); m_samp = nullptr; } const SampleEntry* AudioGroup::getSample(SampleId sfxId) const { auto search = m_sdir.m_entries.find(sfxId); if (search == m_sdir.m_entries.cend()) return nullptr; return search->second.get(); } SystemString AudioGroup::getSampleBasePath(SampleId sfxId) const { #if _WIN32 return m_groupPath + _SYS_STR('/') + athena::utility::utf8ToWide(SampleId::CurNameDB->resolveNameFromId(sfxId)); #else return m_groupPath + _SYS_STR('/') + SampleId::CurNameDB->resolveNameFromId(sfxId).data(); #endif } std::pair<ObjToken<SampleEntryData>, const unsigned char*> AudioGroup::getSampleData(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); const_cast<SampleEntry*>(sample)->loadLooseData(basePath); return {sample->m_data, sample->m_data->m_looseData.get()}; } return {sample->m_data, m_samp + sample->m_data->m_sampleOff}; } SampleFileState AudioGroup::getSampleFileState(SampleId sfxId, const SampleEntry* sample, SystemString* pathOut) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); return sample->getFileState(basePath, pathOut); } if (sample->m_data->isFormatDSP() || sample->m_data->getSampleFormat() == SampleFormat::N64) return SampleFileState::MemoryOnlyCompressed; return SampleFileState::MemoryOnlyWAV; } void AudioGroup::patchSampleMetadata(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); sample->patchSampleMetadata(basePath); } } void AudioGroup::makeWAVVersion(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { m_sdir._extractWAV(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get()); } } void AudioGroup::makeCompressedVersion(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { m_sdir._extractCompressed(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get(), true); } } void AudioGroupDatabase::renameSample(SampleId id, std::string_view str) { SystemString oldBasePath = getSampleBasePath(id); SampleId::CurNameDB->rename(id, str); SystemString newBasePath = getSampleBasePath(id); Rename((oldBasePath + _SYS_STR(".wav")).c_str(), (newBasePath + _SYS_STR(".wav")).c_str()); Rename((oldBasePath + _SYS_STR(".dsp")).c_str(), (newBasePath + _SYS_STR(".dsp")).c_str()); Rename((oldBasePath + _SYS_STR(".vadpcm")).c_str(), (newBasePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::deleteSample(SampleId id) { SystemString basePath = getSampleBasePath(id); Unlink((basePath + _SYS_STR(".wav")).c_str()); Unlink((basePath + _SYS_STR(".dsp")).c_str()); Unlink((basePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::copySampleInto(const SystemString& basePath, const SystemString& newBasePath) { Copy((basePath + _SYS_STR(".wav")).c_str(), (newBasePath + _SYS_STR(".wav")).c_str()); Copy((basePath + _SYS_STR(".dsp")).c_str(), (newBasePath + _SYS_STR(".dsp")).c_str()); Copy((basePath + _SYS_STR(".vadpcm")).c_str(), (newBasePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::_recursiveRenameMacro(SoundMacroId id, std::string_view str, int& macroIdx, std::unordered_set<SoundMacroId>& renamedIds) { if (renamedIds.find(id) != renamedIds.cend()) return; if (const SoundMacro* macro = getPool().soundMacro(id)) { if (!strncmp(SoundMacroId::CurNameDB->resolveNameFromId(id).data(), "macro", 5)) { std::string macroName("macro"sv); if (macroIdx) macroName += fmt::format(FMT_STRING("{}"), macroIdx); macroName += '_'; macroName += str; ++macroIdx; SoundMacroId::CurNameDB->rename(id, macroName); renamedIds.insert(id); int sampleIdx = 0; for (const auto& cmd : macro->m_cmds) { switch (cmd->Isa()) { case SoundMacro::CmdOp::StartSample: { SoundMacro::CmdStartSample* ss = static_cast<SoundMacro::CmdStartSample*>(cmd.get()); if (!strncmp(SampleId::CurNameDB->resolveNameFromId(ss->sample.id).data(), "sample", 6)) { std::string sampleName("sample"sv); if (sampleIdx) sampleName += fmt::format(FMT_STRING("{}"), sampleIdx); sampleName += '_'; sampleName += macroName; ++sampleIdx; renameSample(ss->sample.id, sampleName); } break; } case SoundMacro::CmdOp::SplitKey: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitKey*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitVel: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitVel*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::Goto: _recursiveRenameMacro(static_cast<SoundMacro::CmdGoto*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::PlayMacro: _recursiveRenameMacro(static_cast<SoundMacro::CmdPlayMacro*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitMod: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitMod*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitRnd: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitRnd*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::GoSub: _recursiveRenameMacro(static_cast<SoundMacro::CmdGoSub*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::TrapEvent: _recursiveRenameMacro(static_cast<SoundMacro::CmdTrapEvent*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SendMessage: _recursiveRenameMacro(static_cast<SoundMacro::CmdSendMessage*>(cmd.get())->macro, str, macroIdx, renamedIds); break; default: break; } } } } } static const std::regex DefineGRPEntry(R"(#define\s+GRP(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); static const std::regex DefineSNGEntry(R"(#define\s+SNG(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); static const std::regex DefineSFXEntry(R"(#define\s+SFX(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); void AudioGroupDatabase::importCHeader(std::string_view header) { std::match_results<std::string_view::const_iterator> dirMatch; auto begin = header.cbegin(); auto end = header.cend(); while (std::regex_search(begin, end, dirMatch, DefineGRPEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; GroupId::CurNameDB->rename(id, key); begin = dirMatch.suffix().first; } begin = header.cbegin(); end = header.cend(); while (std::regex_search(begin, end, dirMatch, DefineSNGEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; SongId::CurNameDB->rename(id, key); begin = dirMatch.suffix().first; } begin = header.cbegin(); end = header.cend(); std::unordered_set<SoundMacroId> renamedMacroIDs; while (std::regex_search(begin, end, dirMatch, DefineSFXEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; SFXId::CurNameDB->rename(id, key); int macroIdx = 0; for (auto& sfxGrp : getProj().sfxGroups()) { for (auto& sfx : sfxGrp.second->m_sfxEntries) { if (sfx.first == id) { ObjectId sfxObjId = sfx.second.objId; if (sfxObjId == ObjectId() || sfxObjId.id & 0xc000) continue; _recursiveRenameMacro(sfxObjId, key, macroIdx, renamedMacroIDs); } } } begin = dirMatch.suffix().first; } } static void WriteDefineLine(std::stringstream& ret, std::string_view typeStr, std::string_view name, ObjectId id) { fmt::print(ret, FMT_STRING("#define {}{} 0x{}\n"), typeStr, name, id); } std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std::string_view groupName) const { std::stringstream ret; ret << "/* Auto-generated Amuse Defines\n" " *\n" " * Project: "sv; ret << projectName; ret << "\n" " * Subproject: "sv; ret << groupName; ret << "\n" " * Date: "sv; time_t curTime = time(nullptr); #ifndef _WIN32 struct tm curTm; localtime_r(&curTime, &curTm); char curTmStr[26]; asctime_r(&curTm, curTmStr); #else struct tm curTm; localtime_s(&curTm, &curTime); char curTmStr[26]; asctime_s(curTmStr, &curTm); #endif if (char* ch = strchr(curTmStr, '\n')) *ch = '\0'; ret << curTmStr; ret << "\n" " */\n\n\n"sv; bool addLF = false; for (const auto& sg : SortUnorderedMap(getProj().songGroups())) { auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first); WriteDefineLine(ret, "GRP"sv, name, sg.first); addLF = true; } for (const auto& sg : SortUnorderedMap(getProj().sfxGroups())) { auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first); WriteDefineLine(ret, "GRP"sv, name, sg.first); addLF = true; } if (addLF) ret << "\n\n"sv; addLF = false; std::unordered_set<amuse::SongId> songIds; for (const auto& sg : getProj().songGroups()) for (const auto& song : sg.second->m_midiSetups) songIds.insert(song.first); for (amuse::SongId id : SortUnorderedSet(songIds)) { auto name = amuse::SongId::CurNameDB->resolveNameFromId(id); WriteDefineLine(ret, "SNG"sv, name, id); addLF = true; } if (addLF) ret << "\n\n"sv; addLF = false; for (const auto& sg : SortUnorderedMap(getProj().sfxGroups())) { for (const auto& sfx : SortUnorderedMap(sg.second.get()->m_sfxEntries)) { auto name = amuse::SFXId::CurNameDB->resolveNameFromId(sfx.first); WriteDefineLine(ret, "SFX"sv, name, sfx.first.id); addLF = true; } } if (addLF) ret << "\n\n"sv; return ret.str(); } } // namespace amuse
12,004
4,269
// Copyright Mark H. Spatz 2021-present // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at // https://www.boost.org/LICENSE_1_0.txt) #pragma once #include <array> #include <cassert> #include <cstddef> #include <cstdint> #include <wmr/vendor_hid_interface.hpp> #include "hid_device.hpp" namespace wmr { class HpReverbHid : public VendorHidInterface { public: HpReverbHid(std::unique_ptr<HidDevice> hid_dev); void WakeDisplay() final; private: // set then get as feature 4x at startup struct __attribute__((packed)) MyteryReport80 { static constexpr uint8_t kReportId = 0x50; static constexpr std::size_t kReportSize = 64; uint8_t report_id; uint8_t mystery_byte_1; std::array<uint8_t, 62> data; }; static_assert(sizeof(MyteryReport80) == MyteryReport80::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport9 { static constexpr uint8_t kReportId = 0x09; static constexpr std::size_t kReportSize = 64; uint8_t report_id; std::array<uint8_t, 63> data; }; static_assert(sizeof(MyteryReport9) == MyteryReport9::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport8 { static constexpr uint8_t kReportId = 0x08; static constexpr std::size_t kReportSize = 64; uint8_t report_id; std::array<uint8_t, 63> data; }; static_assert(sizeof(MyteryReport8) == MyteryReport8::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport6 { static constexpr uint8_t kReportId = 0x06; static constexpr std::size_t kReportSize = 2; uint8_t report_id; uint8_t value; }; static_assert(sizeof(MyteryReport6) == MyteryReport6::kReportSize); // Set as feature to 0x01 once at startup struct __attribute__((packed)) MyteryReport4 { static constexpr uint8_t kReportId = 0x04; static constexpr std::size_t kReportSize = 2; uint8_t report_id; uint8_t value; }; static_assert(sizeof(MyteryReport4) == MyteryReport4::kReportSize); // Read as interrupt during operation struct __attribute__((packed)) MyteryReport5 { static constexpr uint8_t kReportId = 0x05; static constexpr std::size_t kReportSize = 33; uint8_t report_id; std::array<uint8_t, 32> data; }; static_assert(sizeof(MyteryReport5) == MyteryReport5::kReportSize); struct MysteryReport5Reader : HidDevice::ReportReader { void Update(Report report) final; }; // Read as interrupt during operation struct __attribute__((packed)) MyteryReport1 { static constexpr uint8_t kReportId = 0x01; static constexpr std::size_t kReportSize = 4; uint8_t report_id; uint8_t unknown_8; uint16_t unknown_16; }; static_assert(sizeof(MyteryReport1) == MyteryReport1::kReportSize); struct MysteryReport1Reader : HidDevice::ReportReader { void Update(Report report) final; }; std::unique_ptr<HidDevice> hid_dev_; std::shared_ptr<HidDevice::ReportReader> reader_5_; std::shared_ptr<HidDevice::ReportReader> reader_1_; }; } // namespace wmr
3,141
1,142
#include <iostream> #include <set> using namespace std; int main() { set<int> numbers; int Q; cin >> Q; while(Q--) { int type, x; cin >> type >> x; if(1 == type) numbers.insert(x); if(2 == type) numbers.erase(x); if(3 == type) { cout << (((numbers.count(x)) > 0) ? "Yes" : "No") << endl; } } return 0; }
415
151
#pragma once #include "Forward.hh" struct SDK::ClientModeShared { PAD(0x28); int m_nRootSize[2]; };
104
47
// This file is part of the QuantumGate project. For copyright and // licensing information refer to the license file(s) in the project root. #include "pch.h" #include "IPAddress.h" #include "..\Common\Endian.h" #include <regex> namespace QuantumGate::Implementation::Network { bool IPAddress::TryParse(const WChar* ipaddr_str, IPAddress& ipaddr) noexcept { try { IPAddress temp_ip(ipaddr_str); ipaddr = std::move(temp_ip); return true; } catch (...) {} return false; } bool IPAddress::TryParse(const String& ipaddr_str, IPAddress& ipaddr) noexcept { return TryParse(ipaddr_str.c_str(), ipaddr); } bool IPAddress::TryParse(const BinaryIPAddress& bin_ipaddr, IPAddress& ipaddr) noexcept { try { IPAddress temp_ip(bin_ipaddr); ipaddr = std::move(temp_ip); return true; } catch (...) {} return false; } bool IPAddress::TryParseMask(const IPAddress::Family af, const WChar* mask_str, IPAddress& ipmask) noexcept { try { if (std::wcslen(mask_str) <= IPAddress::MaxIPAddressStringLength) { // Looks for mask bits specified in the format // "/999" in the mask string used in CIDR notations // such as "192.168.0.0/16" std::wregex r(LR"bits(^\s*\/(\d+)\s*$)bits"); std::wcmatch m; if (std::regex_search(mask_str, m, r)) { auto cidr_lbits = std::stoi(m[1].str()); return CreateMask(af, cidr_lbits, ipmask); } else { // Treats the mask string as an IP address mask // e.g. "255.255.255.255" IPAddress temp_ip; if (TryParse(mask_str, temp_ip) && temp_ip.GetFamily() == af && temp_ip.IsMask()) { ipmask = std::move(temp_ip); return true; } } } } catch (...) {} return false; } bool IPAddress::TryParseMask(const IPAddress::Family af, const String& mask_str, IPAddress& ipmask) noexcept { return TryParseMask(af, mask_str.c_str(), ipmask); } void IPAddress::SetAddress(const WChar* ipaddr_str) { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in6_addr), "IP Address length mismatch"); if (std::wcslen(ipaddr_str) <= IPAddress::MaxIPAddressStringLength) { BinaryIPAddress baddr; if (InetPton(AF_INET, ipaddr_str, &baddr.Bytes) == 1) { m_BinaryAddress = baddr; m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv4; return; } else { const WChar* ipaddr_ptr = ipaddr_str; std::array<WChar, IPAddress::MaxIPAddressStringLength + 1> ipaddr_str2{ 0 }; // Remove link-local address zone index for IPv6 addresses; // starts with % on Windows. InetPton does not accept it. const auto pos = std::wcsstr(ipaddr_str, L"%"); if (pos != nullptr) { std::memcpy(ipaddr_str2.data(), ipaddr_str, (pos - ipaddr_str) * sizeof(WChar)); ipaddr_ptr = ipaddr_str2.data(); } if (InetPton(AF_INET6, ipaddr_ptr, &baddr.Bytes) == 1) { m_BinaryAddress = baddr; m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv6; return; } } } throw std::invalid_argument("Invalid IP address"); return; } void IPAddress::SetAddress(const sockaddr_storage* saddr) { assert(saddr != nullptr); switch (saddr->ss_family) { case AF_INET: { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in_addr), "IP Address length mismatch"); m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv4; auto ip4 = reinterpret_cast<const sockaddr_in*>(saddr); std::memcpy(&m_BinaryAddress.Bytes, &ip4->sin_addr, sizeof(ip4->sin_addr)); break; } case AF_INET6: { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in6_addr), "IP Address length mismatch"); m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv6; auto ip6 = reinterpret_cast<const sockaddr_in6*>(saddr); std::memcpy(&m_BinaryAddress.Bytes, &ip6->sin6_addr, sizeof(ip6->sin6_addr)); break; } default: { throw std::invalid_argument("Unsupported internetwork address family"); } } return; } String IPAddress::GetString() const noexcept { try { auto afws = AF_UNSPEC; switch (m_BinaryAddress.AddressFamily) { case BinaryIPAddress::Family::IPv4: afws = AF_INET; break; case BinaryIPAddress::Family::IPv6: afws = AF_INET6; break; default: return {}; } std::array<WChar, IPAddress::MaxIPAddressStringLength> ipstr{ 0 }; const auto ip = InetNtop(afws, &m_BinaryAddress.Bytes, reinterpret_cast<PWSTR>(ipstr.data()), ipstr.size()); if (ip != NULL) { return ipstr.data(); } } catch (...) {} return {}; } std::ostream& operator<<(std::ostream& stream, const IPAddress& ipaddr) { stream << Util::ToStringA(ipaddr.GetString()); return stream; } std::wostream& operator<<(std::wostream& stream, const IPAddress& ipaddr) { stream << ipaddr.GetString(); return stream; } }
4,886
2,118
/* Copyright of Ashikul Hosen Solution of C++ Primer ex 12.33 */ #include "StrBlob.h" #include "StrBlobPtr.h" #include "ConstStrBlobPtr.h" StrBlob::StrBlob() : data(std::make_shared<std::vector<std::string>>()) {} StrBlob::StrBlob(std::initializer_list<std::string> il) : data(std::make_shared<std::vector<std::string>>(il)) {} void StrBlob::check(size_type pos, const std::string &msg) const { if (pos >= data->size()) throw std::out_of_range(msg); } void StrBlob::pop_back() { check(0, "pop_back on empty StrBlob"); data->pop_back(); } std::string &StrBlob::front() { check(0, "front on empty StrBlob"); return data->front(); } const std::string &StrBlob::front() const { check(0, "front on empty StrBlob"); return data->front(); } std::string &StrBlob::back() { check(0, "back on empty StrBlob"); return data->back(); } const std::string &StrBlob::back() const { check(0, "back on empty StrBlob"); return data->back(); } StrBlobPtr StrBlob::begin() { return StrBlobPtr(*this); } StrBlobPtr StrBlob::end() { return StrBlobPtr(*this, data->size()); } ConstStrBlobPtr StrBlob::cbegin() const { return ConstStrBlobPtr(*this); } ConstStrBlobPtr StrBlob::cend() const { return ConstStrBlobPtr(*this, data->size()); }
1,267
485
#include <iostream> using namespace std; int main() { double num01, sqr; cout << "Calculador de sqrt" << endl; cout << "Digite um número: "; cin >> num01; sqr = num01 * num01; cout << "O resultado é: " << sqr << endl; } // This is a commentary
274
103
//////////////////////////////////////////////////////////////////////////// // Module : agent_manager.cpp // Created : 24.05.2004 // Modified : 24.05.2004 // Author : Dmitriy Iassenev // Description : Agent manager //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "agent_manager.h" #include "agent_corpse_manager.h" #include "agent_enemy_manager.h" #include "agent_explosive_manager.h" #include "agent_location_manager.h" #include "agent_member_manager.h" #include "agent_memory_manager.h" #include "agent_manager_planner.h" //#include "profiler.h" CAgentManager::CAgentManager() { init_scheduler(); init_components(); } CAgentManager::~CAgentManager() { VERIFY(member().members().empty()); #ifdef USE_SCHEDULER_IN_AGENT_MANAGER remove_scheduler(); #endif // USE_SCHEDULER_IN_AGENT_MANAGER remove_components(); } void CAgentManager::init_scheduler() { #ifdef USE_SCHEDULER_IN_AGENT_MANAGER shedule.t_min = 1000; shedule.t_max = 1000; shedule_register(); #else // USE_SCHEDULER_IN_AGENT_MANAGER m_last_update_time = 0; m_update_rate = 1000; #endif // USE_SCHEDULER_IN_AGENT_MANAGER } void CAgentManager::init_components() { m_corpse = xr_new<CAgentCorpseManager>(this); m_enemy = xr_new<CAgentEnemyManager>(this); m_explosive = xr_new<CAgentExplosiveManager>(this); m_location = xr_new<CAgentLocationManager>(this); m_member = xr_new<CAgentMemberManager>(this); m_memory = xr_new<CAgentMemoryManager>(this); m_brain = xr_new<CAgentManagerPlanner>(); brain().setup(this); } #ifdef USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::remove_scheduler() { shedule_unregister(); } #endif // USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::remove_components() { xr_delete(m_corpse); xr_delete(m_enemy); xr_delete(m_explosive); xr_delete(m_location); xr_delete(m_member); xr_delete(m_memory); xr_delete(m_brain); } void CAgentManager::remove_links(CObject* object) { corpse().remove_links(object); enemy().remove_links(object); explosive().remove_links(object); location().remove_links(object); member().remove_links(object); memory().remove_links(object); brain().remove_links(object); } void CAgentManager::update_impl() { VERIFY(!member().members().empty()); memory().update(); corpse().update(); enemy().update(); explosive().update(); location().update(); member().update(); brain().update(); } #ifdef USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::shedule_Update(u32 time_delta) { START_PROFILE("Agent_Manager") ISheduled::shedule_Update(time_delta); update_impl(); STOP_PROFILE } float CAgentManager::shedule_Scale() { return (.5f); } #else // USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::update() { if (Device.dwTimeGlobal <= m_last_update_time) return; if (Device.dwTimeGlobal - m_last_update_time < m_update_rate) return; m_last_update_time = Device.dwTimeGlobal; update_impl(); } #endif // USE_SCHEDULER_IN_AGENT_MANAGER
3,129
1,172
#include "Test_HVACController.h" Test_HVACController::Test_HVACController(QObject *parent) : QObject(parent) { }
115
46
// Copyright 2019 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 "base/test/bind.h" #include <string> #include "base/bind.h" #include "base/callback.h" #include "base/location.h" #include "testing/gtest/include/gtest/gtest.h" namespace base { namespace { // A helper class for MakeExpectedRunClosure() that fails if it is // destroyed without Run() having been called. This class may be used // from multiple threads as long as Run() is called at most once // before destruction. class RunChecker { public: explicit RunChecker(const Location& location, StringPiece message, bool is_repeating) : location_(location), message_(message.as_string()), is_repeating_(is_repeating) {} ~RunChecker() { if (!called_) { ADD_FAILURE_AT(location_.file_name(), location_.line_number()) << message_; } } void Run() { DCHECK(is_repeating_ || !called_); called_ = true; } private: const Location location_; const std::string message_; const bool is_repeating_; bool called_ = false; }; } // namespace OnceClosure MakeExpectedRunClosure(const Location& location, StringPiece message) { return BindOnce(&RunChecker::Run, Owned(new RunChecker(location, message, false))); } RepeatingClosure MakeExpectedRunAtLeastOnceClosure(const Location& location, StringPiece message) { return BindRepeating(&RunChecker::Run, Owned(new RunChecker(location, message, true))); } RepeatingClosure MakeExpectedNotRunClosure(const Location& location, StringPiece message) { return BindRepeating( [](const Location& location, StringPiece message) { ADD_FAILURE_AT(location.file_name(), location.line_number()) << message; }, location, message.as_string()); } } // namespace base
2,086
622
// SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2020-2021, The Monero Project. // Copyright (c) 2012 thomasv@gitorious #include "ColorScheme.h" #include <QDebug> bool ColorScheme::darkScheme = false; ColorSchemeItem ColorScheme::GREEN = ColorSchemeItem("#117c11", "#8af296"); ColorSchemeItem ColorScheme::YELLOW = ColorSchemeItem("#897b2a", "#ffff00"); ColorSchemeItem ColorScheme::RED = ColorSchemeItem("#7c1111", "#f18c8c"); ColorSchemeItem ColorScheme::BLUE = ColorSchemeItem("#123b7c", "#8cb3f2"); ColorSchemeItem ColorScheme::DEFAULT = ColorSchemeItem("black", "white"); ColorSchemeItem ColorScheme::GRAY = ColorSchemeItem("gray", "gray"); bool ColorScheme::hasDarkBackground(QWidget *widget) { int r, g, b; widget->palette().color(QPalette::Background).getRgb(&r, &g, &b); auto brightness = r + g + b; return brightness < (255*3/2); } void ColorScheme::updateFromWidget(QWidget *widget, bool forceDark) { darkScheme = forceDark || ColorScheme::hasDarkBackground(widget); } QString ColorSchemeItem::asStylesheet(bool background) { auto cssPrefix = background ? "background-" : ""; auto color = this->getColor(background); return QString("QWidget { %1color : %2; }").arg(cssPrefix, color); } QColor ColorSchemeItem::asColor(bool background) { auto color = this->getColor(background); return QColor(color); } QString ColorSchemeItem::getColor(bool background) { return m_colors[(int(background) + int(ColorScheme::darkScheme)) % 2]; }
1,511
546
// Copyright 2018 Phyronnaz #include "VoxelWorldEditor.h" #include "VoxelInvokerComponent.h" #include "VoxelWorld.h" #include "Components/CapsuleComponent.h" #include "LevelEditorViewport.h" #include "Editor.h" #include "VoxelWorldDetails.h" AVoxelWorldEditor::AVoxelWorldEditor() { PrimaryActorTick.bCanEverTick = true; Invoker = CreateDefaultSubobject<UVoxelInvokerComponent>(FName("Editor Invoker")); Invoker->DistanceOffset = 5000; auto TouchCapsule = CreateDefaultSubobject<UCapsuleComponent>(FName("Capsule")); TouchCapsule->InitCapsuleSize(0.1f, 0.1f); TouchCapsule->SetCollisionEnabled(ECollisionEnabled::NoCollision); TouchCapsule->SetCollisionResponseToAllChannels(ECR_Ignore); RootComponent = TouchCapsule; } TWeakObjectPtr<UVoxelInvokerComponent> AVoxelWorldEditor::GetInvoker() { return TWeakObjectPtr<UVoxelInvokerComponent>(Invoker); } void AVoxelWorldEditor::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (!World.IsValid()) { Destroy(); return; } if (GetWorld()->WorldType == EWorldType::Editor) { auto Client = static_cast<FLevelEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient()); if (Client) { FVector CameraPosition = Client->GetViewLocation(); SetActorLocation(CameraPosition); } else { UE_LOG(LogTemp, Error, TEXT("Cannot find editor camera")); } } } #if WITH_EDITOR bool AVoxelWorldEditor::ShouldTickIfViewportsOnly() const { return true; } void AVoxelWorldEditor::Init(TWeakObjectPtr<AVoxelWorld> NewWorld) { World = NewWorld; } #endif
1,534
582
#ifndef BIGVECTOR_H #define BIGVECTOR_H #include <assert.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <omp.h> #include <thread> #include "core/filesystem.hpp" #include "core/partition.hpp" template <typename T> class BigVector { std::string path; bool is_open; bool in_memory = false; size_t begin_i = 0, end_i = 0; T * data_in_memory = NULL; static const long PAGESIZE = 4096; public: int fd; T * data; size_t length; BigVector() { is_open = false; data = NULL; length = 0; } BigVector(std::string path, size_t length) { init(path, length); } BigVector(std::string path) { init(path); } ~BigVector() { if (is_open && file_exists(path)) { close_mmap(); } } void init(std::string path) { assert(file_exists(path)); assert(file_size(path) % sizeof(T) == 0); init(path, file_size(path) / sizeof(T)); } void init(std::string path, size_t length) { this->path = path; this->length = length; if (!file_exists(path)) { FILE * fout = fopen(path.c_str(), "wb"); fclose(fout); } if (file_size(path) != sizeof(T) * length) { long file_length = sizeof(T) * length; assert(truncate(path.c_str(), file_length)!=-1); int fout = open(path.c_str(), O_WRONLY); void * buffer = memalign(PAGESIZE, PAGESIZE); for (long offset=0;offset<file_length;) { if (file_length - offset > PAGESIZE) { assert(write(fout, buffer, PAGESIZE)==PAGESIZE); offset += PAGESIZE; } else { assert(write(fout, buffer, file_length - offset)==file_length - offset); offset += file_length - offset; } } close(fout); } fd = open(path.c_str(), O_RDWR | O_DIRECT); assert(fd!=-1); open_mmap(); } void open_mmap() { int ret = posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL); assert(ret==0); data = (T *)mmap(NULL, sizeof(T) * length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); assert(data!=MAP_FAILED); is_open = true; } void close_mmap() { is_open = false; int ret = munmap(data, sizeof(T) * length); assert(ret==0); } void fill(const T & value) { int parallelism = std::thread::hardware_concurrency(); #pragma omp parallel num_threads(parallelism) { size_t begin_i, end_i; std::tie(begin_i, end_i) = get_partition_range(length, omp_get_num_threads(), omp_get_thread_num()); for (size_t i=begin_i;i<end_i;i++) { data[i] = value; } } #pragma omp barrier } T & operator[](size_t i) { if (in_memory) { if (!(i >= begin_i && i <= end_i)) { printf("%s %lu %lu %lu\n", path.c_str(), begin_i, i, end_i); exit(-1); } return data_in_memory[i - begin_i]; } else { return data[i]; } } void sync() { assert(msync(data, sizeof(T) * length, MS_SYNC)==0); } void lock(size_t begin_i, size_t end_i) { assert(mlock(data + begin_i, (end_i - begin_i) * sizeof(T))==0); } void unlock(size_t begin_i, size_t end_i) { assert(munlock(data + begin_i, (end_i - begin_i) * sizeof(T))==0); } void load(size_t begin_i, size_t end_i) { close_mmap(); begin_i = begin_i * sizeof(T) / PAGESIZE * PAGESIZE / sizeof(T); this->begin_i = begin_i; this->end_i = end_i; in_memory = true; // data_in_memory = (T *)memalign(PAGESIZE, (end_i - begin_i) * sizeof(T) + PAGESIZE); // assert(data_in_memory!=NULL); data_in_memory = (T *)mmap(0, (end_i - begin_i) * sizeof(T) + PAGESIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); assert(data_in_memory!=MAP_FAILED); long end_offset = end_i * sizeof(T); long offset = begin_i * sizeof(T); long bytes; while (offset < end_offset) { bytes = pread(fd, data_in_memory + (offset / sizeof(T) - begin_i), (end_offset - offset + PAGESIZE - 1) / PAGESIZE * PAGESIZE, offset); if (bytes==-1) { printf("%ld %ld\n", offset, end_offset); printf("%s\n", strerror(errno)); getchar(); exit(-1); } offset += bytes; } } void save() { long end_offset = end_i * sizeof(T); long offset = begin_i * sizeof(T); long bytes; while (offset < end_offset) { bytes = pwrite(fd, data_in_memory + (offset / sizeof(T) - begin_i), (end_offset - offset + PAGESIZE - 1) / PAGESIZE * PAGESIZE, offset); if (bytes==-1) { printf("%ld %ld\n", offset, end_offset); printf("%s\n", strerror(errno)); getchar(); exit(-1); } offset += bytes; } int ret = munmap(data_in_memory, (end_i - begin_i) * sizeof(T) + PAGESIZE); assert(ret==0); in_memory = false; begin_i = 0; end_i = 0; open_mmap(); } }; #endif
4,489
2,065
/*! * \copyright Copyright (c) 2014-2019 Governikus GmbH & Co. KG, Germany */ #include "CommandApdu.h" #include <QLoggingCategory> #include <QtEndian> using namespace governikus; Q_DECLARE_LOGGING_CATEGORY(card) CommandApdu::CommandApdu(const QByteArray& pBuffer) : Apdu(pBuffer) { } bool CommandApdu::isExtendedLength() const { // no data, no le: size == 4 // no data, short le: size == 5 // no data, extended le: size == 7, high order le byte == 0 // data, with/without le: high order size byte == 0 <=> extended data length return length() > 5 && mBuffer.at(4) == '\0'; } bool CommandApdu::isExtendedLength(const QByteArray& pData, int pLe) { return pData.size() > SHORT_MAX_LC || pLe > SHORT_MAX_LE; } bool CommandApdu::isSecureMessaging(const QByteArray& pCommandBuffer) { return !pCommandBuffer.isEmpty() && ((pCommandBuffer.at(0) & 0x0F) == CLA_SECURE_MESSAGING); } CommandApdu::CommandApdu(const QByteArray& pHeader, const QByteArray& pData, int pLe) : CommandApdu(pHeader.at(0), pHeader.at(1), pHeader.at(2), pHeader.at(3), pData, pLe) { } CommandApdu::CommandApdu(char pCla, char pIns, char pP1, char pP2, const QByteArray& pData, int pLe) : Apdu(QByteArray()) { if (pData.size() > EXTENDED_MAX_LC) { qCCritical(card) << "Command data exceeds maximum of 0xFFFF bytes"; return; } if (pLe > EXTENDED_MAX_LE) { qCCritical(card) << "Expected length exceeds maximum value of 0x010000"; return; } mBuffer += pCla; mBuffer += pIns; mBuffer += pP1; mBuffer += pP2; // // according to ISO 7816 Part 4, chapter 5.1 // if (pData.size() > 0) // withPayload { if (CommandApdu::isExtendedLength(pData, pLe)) { mBuffer += '\0'; mBuffer += static_cast<char>(pData.size() >> 8 & 0xff); mBuffer += static_cast<char>(pData.size() & 0xff); } else { mBuffer += static_cast<char>(pData.size() & 0xff); } mBuffer += pData; } if (pLe > 0) { if (CommandApdu::isExtendedLength(pData, pLe)) { if (pData.isEmpty()) { mBuffer += '\0'; } mBuffer += static_cast<char>(pLe >> 8 & 0xff); } mBuffer += static_cast<char>(pLe & 0xff); } } char CommandApdu::getCLA() const { return length() > 0 ? mBuffer.at(0) : '\0'; } char CommandApdu::getINS() const { return length() > 1 ? mBuffer.at(1) : '\0'; } char CommandApdu::getP1() const { return length() > 2 ? mBuffer.at(2) : '\0'; } char CommandApdu::getP2() const { return mBuffer.size() > 3 ? mBuffer.at(3) : '\0'; } static inline int readLength(const QByteArray& pByteArray, int pOffset) { Q_ASSERT(pByteArray.size() >= pOffset + 2); return qFromBigEndian<quint16>(pByteArray.mid(pOffset, 2).data()); } int CommandApdu::getLc() const { if (length() <= 5) { return 0; } if (!isExtendedLength()) { // short command apdu return static_cast<uchar>(mBuffer.at(4)); } // extended length command apdu if (length() <= 6) { qCCritical(card) << "Cannot determine Lc, returning 0"; return 0; } return readLength(mBuffer, 5); } int CommandApdu::getLe() const { int lc = getLc(); if (isExtendedLength()) { // no data (so lc==0): we have 4 bytes header and the le field is prefixed with 0 byte // with data: we have 4 bytes header, lc field encoded in 3 bytes and the data field int offset = (lc == 0 ? 5 : 7 + lc); if (length() < offset + 2) { return 0; } int le = readLength(mBuffer, offset); return le == 0 ? EXTENDED_MAX_LE : le; } // no data (so lc==0): we have 4 bytes header // with data: we have 4 bytes header, lc field encoded in 1 byte and the data field int offset = lc == 0 ? 4 : 5 + lc; if (length() < offset + 1) { return 0; } int le = static_cast<uchar>(mBuffer.at(offset)); return le == 0 ? SHORT_MAX_LE : le; } QByteArray CommandApdu::getData() const { int lc = getLc(); if (lc == 0) { return QByteArray(); } if (isExtendedLength()) { // 4 bytes header + 3 bytes length return mBuffer.mid(7, lc); } // 4 bytes header + 1 bytes length return mBuffer.mid(5, lc); }
3,992
1,733
// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #include <stdio.h> //#include "leveldb/expiry.h" #include "db/dbformat.h" #include "db/version_set.h" #include "port/port.h" #include "util/coding.h" namespace leveldb { static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) { assert(seq <= kMaxSequenceNumber); // assert(t <= kValueTypeForSeek); requires revisit once expiry live assert(t <= kTypeValueExplicitExpiry); // temp replacement for above return (seq << 8) | t; } void AppendInternalKey(std::string* result, const ParsedInternalKey& key) { result->append(key.user_key.data(), key.user_key.size()); if (IsExpiryKey(key.type)) PutFixed64(result, key.expiry); PutFixed64(result, PackSequenceAndType(key.sequence, key.type)); } std::string ParsedInternalKey::DebugString() const { char buf[50]; if (IsExpiryKey(type)) snprintf(buf, sizeof(buf), "' @ %llu %llu : %d", (unsigned long long) expiry, (unsigned long long) sequence, int(type)); else snprintf(buf, sizeof(buf), "' @ %llu : %d", (unsigned long long) sequence, int(type)); std::string result = "'"; result += HexString(user_key.ToString()); result += buf; return result; } std::string ParsedInternalKey::DebugStringHex() const { char buf[50]; if (IsExpiryKey(type)) snprintf(buf, sizeof(buf), "' @ %llu %llu : %d", (unsigned long long) expiry, (unsigned long long) sequence, int(type)); else snprintf(buf, sizeof(buf), "' @ %llu : %d", (unsigned long long) sequence, int(type)); std::string result = "'"; result += HexString(user_key); result += buf; return result; } const char * KeyTypeString(ValueType val_type) { const char * ret_ptr; switch(val_type) { case kTypeDeletion: ret_ptr="kTypeDelete"; break; case kTypeValue: ret_ptr="kTypeValue"; break; case kTypeValueWriteTime: ret_ptr="kTypeValueWriteTime"; break; case kTypeValueExplicitExpiry: ret_ptr="kTypeValueExplicitExpiry"; break; default: ret_ptr="(unknown ValueType)"; break; } // switch return(ret_ptr); } std::string InternalKey::DebugString() const { std::string result; ParsedInternalKey parsed; if (ParseInternalKey(rep_, &parsed)) { result = parsed.DebugString(); } else { result = "(bad)"; result.append(EscapeString(rep_)); } return result; } const char* InternalKeyComparator::Name() const { return "leveldb.InternalKeyComparator"; } int InternalKeyComparator::Compare(const Slice& akey, const Slice& bkey) const { // Order by: // increasing user key (according to user-supplied comparator) // decreasing sequence number // decreasing type (though sequence# should be enough to disambiguate) int r = user_comparator_->Compare(ExtractUserKey(akey), ExtractUserKey(bkey)); if (r == 0) { uint64_t anum = DecodeFixed64(akey.data() + akey.size() - 8); uint64_t bnum = DecodeFixed64(bkey.data() + bkey.size() - 8); if (IsExpiryKey((ValueType)*(unsigned char *)&anum)) *(unsigned char*)&anum=(unsigned char)kTypeValue; if (IsExpiryKey((ValueType)*(unsigned char *)&bnum)) *(unsigned char*)&bnum=(unsigned char)kTypeValue; if (anum > bnum) { r = -1; } else if (anum < bnum) { r = +1; } } return r; } void InternalKeyComparator::FindShortestSeparator( std::string* start, const Slice& limit) const { // Attempt to shorten the user portion of the key Slice user_start = ExtractUserKey(*start); Slice user_limit = ExtractUserKey(limit); std::string tmp(user_start.data(), user_start.size()); user_comparator_->FindShortestSeparator(&tmp, user_limit); if (tmp.size() < user_start.size() && user_comparator_->Compare(user_start, tmp) < 0) { // User key has become shorter physically, but larger logically. // Tack on the earliest possible number to the shortened user key. PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); assert(this->Compare(*start, tmp) < 0); assert(this->Compare(tmp, limit) < 0); start->swap(tmp); } } void InternalKeyComparator::FindShortSuccessor(std::string* key) const { Slice user_key = ExtractUserKey(*key); std::string tmp(user_key.data(), user_key.size()); user_comparator_->FindShortSuccessor(&tmp); if (tmp.size() < user_key.size() && user_comparator_->Compare(user_key, tmp) < 0) { // User key has become shorter physically, but larger logically. // Tack on the earliest possible number to the shortened user key. PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); assert(this->Compare(*key, tmp) < 0); key->swap(tmp); } } const char* InternalFilterPolicy::Name() const { return user_policy_->Name(); } void InternalFilterPolicy::CreateFilter(const Slice* keys, int n, std::string* dst) const { // We rely on the fact that the code in table.cc does not mind us // adjusting keys[]. Slice* mkey = const_cast<Slice*>(keys); for (int i = 0; i < n; i++) { mkey[i] = ExtractUserKey(keys[i]); // TODO(sanjay): Suppress dups? } user_policy_->CreateFilter(keys, n, dst); } bool InternalFilterPolicy::KeyMayMatch(const Slice& key, const Slice& f) const { return user_policy_->KeyMayMatch(ExtractUserKey(key), f); } LookupKey::LookupKey(const Slice& user_key, SequenceNumber s, KeyMetaData * meta) { meta_=meta; size_t usize = user_key.size(); size_t needed = usize + 13; // A conservative estimate char* dst; if (needed <= sizeof(space_)) { dst = space_; } else { dst = new char[needed]; } start_ = dst; dst = EncodeVarint32(dst, usize + 8); kstart_ = dst; memcpy(dst, user_key.data(), usize); dst += usize; EncodeFixed64(dst, PackSequenceAndType(s, kValueTypeForSeek)); dst += 8; end_ = dst; } KeyRetirement::KeyRetirement( const Comparator * Comparator, SequenceNumber SmallestSnapshot, const Options * Opts, Compaction * const Compaction) : has_current_user_key(false), last_sequence_for_key(kMaxSequenceNumber), user_comparator(Comparator), smallest_snapshot(SmallestSnapshot), options(Opts), compaction(Compaction), valid(false), dropped(0), expired(0) { // NULL is ok for compaction valid=(NULL!=user_comparator); return; } // KeyRetirement::KeyRetirement KeyRetirement::~KeyRetirement() { if (0!=expired) gPerfCounters->Add(ePerfExpiredKeys, expired); } // KeyRetirement::~KeyRetirement bool KeyRetirement::operator()( Slice & key) { ParsedInternalKey ikey; bool drop = false, expire_flag; if (valid) { if (!ParseInternalKey(key, &ikey)) { // Do not hide error keys current_user_key.clear(); has_current_user_key = false; last_sequence_for_key = kMaxSequenceNumber; } // else else { if (!has_current_user_key || user_comparator->Compare(ikey.user_key, Slice(current_user_key)) != 0) { // First occurrence of this user key current_user_key.assign(ikey.user_key.data(), ikey.user_key.size()); has_current_user_key = true; last_sequence_for_key = kMaxSequenceNumber; } // if if (last_sequence_for_key <= smallest_snapshot) { // Hidden by an newer entry for same user key drop = true; // (A) } // if else { expire_flag=false; if (NULL!=options && options->ExpiryActivated()) expire_flag=options->expiry_module->KeyRetirementCallback(ikey); if ((ikey.type == kTypeDeletion || expire_flag) && ikey.sequence <= smallest_snapshot && NULL!=compaction // mem to level0 ignores this test && compaction->IsBaseLevelForKey(ikey.user_key)) { // For this user key: // (1) there is no data in higher levels // (2) data in lower levels will have larger sequence numbers // (3) data in layers that are being compacted here and have // smaller sequence numbers will be dropped in the next // few iterations of this loop (by rule (A) above). // Therefore this deletion marker is obsolete and can be dropped. drop = true; if (expire_flag) ++expired; else ++dropped; } // if } // else last_sequence_for_key = ikey.sequence; } // else } // if #if 0 // needs clean up to be used again Log(options_.info_log, " Compact: %s, seq %d, type: %d %d, drop: %d, is_base: %d, " "%d smallest_snapshot: %d", ikey.user_key.ToString().c_str(), (int)ikey.sequence, ikey.type, kTypeValue, drop, compact->compaction->IsBaseLevelForKey(ikey.user_key), (int)last_sequence_for_key, (int)compact->smallest_snapshot); #endif return(drop); } // KeyRetirement::operator(Slice & ) } // namespace leveldb
9,656
3,108
#include "goinghome_remote.h" //debug 확인용 #define DEBUG //move_base action_client //amcl x,y 좌표 //static double amcl_x,amcl_y; //orientation //static double amcl_w; //static double arg_x,arg_y; //sector 영역 구분 bool nevi_sev_callback(nevi_srv::Request &req,nevi_srv::Response &res){ //action_clinet 객체 생성 "move_base"에게 요청을 보냄 true spin_thread 허용여부 (boost를 이용한) MoveBase_Client ac ("move_base", true); //액션 서버(move_base가 작동할때까지 대기) while(!ac.waitForServer(ros::Duration(5.0))){ ROS_INFO("Waiting for the move_base action server to come up"); } move_base_msgs::MoveBaseGoal goal_msg; // 상대 좌표 메세지 객체 // move_base_msgs::MoveBaseGoal //메세지 객체 header goal_msg.target_pose.header.frame_id = "map"; goal_msg.target_pose.header.stamp = ros::Time::now(); /*sector 에 따른 좌표 이동 필요 */ //메세지 객체 pose goal_msg.target_pose.pose.position.x = req.px; goal_msg.target_pose.pose.position.y = req.py; goal_msg.target_pose.pose.orientation.w =req.ow; #ifdef DEBUG //변위값 ROS_INFO("send pose.position.x %f",goal_msg.target_pose.pose.position.x); ROS_INFO("send pose.position.y %f",goal_msg.target_pose.pose.position.y); ROS_INFO("send pose.orientation.w %f",goal_msg.target_pose.pose.orientation.w); #endif ROS_INFO("Sending goal"); //메세지 전송 ac.sendGoal(goal_msg); //응답 대기 ac.waitForResult(); //응답 여부 판단 if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED){ //ac.getState() 로 상태 리턴 move_base_msgs/MoveBaseActionResult.msg ROS_INFO("the base moved at x=%f y=%f!!",req.px,req.py); res.result=true; return true; } else{ ROS_INFO("The base failed to move forward"); res.result=false; return false; } } //msg 받기 위한 callback 함수 /* void callback(const geometry_msgs::PoseWithCovarianceStamped& msg){ ROS_INFO("%f:x %f:y\n",msg.pose.pose.position.x,msg.pose.pose.position.y); amcl_x=msg.pose.pose.position.x; amcl_y=msg.pose.pose.position.y; } */ int main(int argc, char* argv[]){ //ros 초기화 ros::init(argc, argv, "remote_nevi"); //노드 관리를 위한 객체 생성 ros::NodeHandle remote_nevi; ros::ServiceServer nevi_sev_server=remote_nevi.advertiseService("nevi_service",nevi_sev_callback); ROS_INFO("nevi service server start"); ros::spin(); return 0; /* 타이머를 이용하여 일정 시간마다 amcl 값을 받도록 할 예정 ros::Subscriber amcl_sub=nh.subscribe("amcl_pose",100,callback); ROS_INFO("subscriber start and waiting"); //topic 받는걸 한번만 하도록한다. amcl_x 와 amcl_y 값이 0 일경우에는 다시 토픽을 받도록함. while ((amcl_x==0)&&(amcl_y==0)) ros::spinOnce();\ */ }
2,560
1,312
/* * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <inttypes.h> //#define LOG_NDEBUG 0 #define LOG_TAG "OMX" #include <utils/Log.h> #include <dlfcn.h> #include "../include/OMX.h" #include "../include/OMXNodeInstance.h" #include <binder/IMemory.h> #include <media/stagefright/foundation/ADebug.h> #include <utils/threads.h> #include "OMXMaster.h" #include <OMX_Component.h> namespace android { //////////////////////////////////////////////////////////////////////////////// // This provides the underlying Thread used by CallbackDispatcher. // Note that deriving CallbackDispatcher from Thread does not work. struct OMX::CallbackDispatcherThread : public Thread { CallbackDispatcherThread(CallbackDispatcher *dispatcher) : mDispatcher(dispatcher) { } private: CallbackDispatcher *mDispatcher; bool threadLoop(); CallbackDispatcherThread(const CallbackDispatcherThread &); CallbackDispatcherThread &operator=(const CallbackDispatcherThread &); }; //////////////////////////////////////////////////////////////////////////////// struct OMX::CallbackDispatcher : public RefBase { CallbackDispatcher(OMXNodeInstance *owner); void post(const omx_message &msg); bool loop(); protected: virtual ~CallbackDispatcher(); private: Mutex mLock; OMXNodeInstance *mOwner; bool mDone; Condition mQueueChanged; List<omx_message> mQueue; sp<CallbackDispatcherThread> mThread; void dispatch(const omx_message &msg); CallbackDispatcher(const CallbackDispatcher &); CallbackDispatcher &operator=(const CallbackDispatcher &); }; OMX::CallbackDispatcher::CallbackDispatcher(OMXNodeInstance *owner) : mOwner(owner), mDone(false) { mThread = new CallbackDispatcherThread(this); mThread->run("OMXCallbackDisp", ANDROID_PRIORITY_FOREGROUND); } OMX::CallbackDispatcher::~CallbackDispatcher() { { Mutex::Autolock autoLock(mLock); mDone = true; mQueueChanged.signal(); } // A join on self can happen if the last ref to CallbackDispatcher // is released within the CallbackDispatcherThread loop status_t status = mThread->join(); if (status != WOULD_BLOCK) { // Other than join to self, the only other error return codes are // whatever readyToRun() returns, and we don't override that CHECK_EQ(status, (status_t)NO_ERROR); } } void OMX::CallbackDispatcher::post(const omx_message &msg) { Mutex::Autolock autoLock(mLock); mQueue.push_back(msg); mQueueChanged.signal(); } void OMX::CallbackDispatcher::dispatch(const omx_message &msg) { if (mOwner == NULL) { ALOGV("Would have dispatched a message to a node that's already gone."); return; } mOwner->onMessage(msg); } bool OMX::CallbackDispatcher::loop() { for (;;) { omx_message msg; { Mutex::Autolock autoLock(mLock); while (!mDone && mQueue.empty()) { mQueueChanged.wait(mLock); } if (mDone) { break; } msg = *mQueue.begin(); mQueue.erase(mQueue.begin()); } dispatch(msg); } return false; } //////////////////////////////////////////////////////////////////////////////// bool OMX::CallbackDispatcherThread::threadLoop() { return mDispatcher->loop(); } //////////////////////////////////////////////////////////////////////////////// OMX::OMX() : mMaster(new OMXMaster), mNodeCounter(0) { } OMX::~OMX() { delete mMaster; mMaster = NULL; } void OMX::binderDied(const wp<IBinder> &the_late_who) { OMXNodeInstance *instance; { Mutex::Autolock autoLock(mLock); ssize_t index = mLiveNodes.indexOfKey(the_late_who); CHECK(index >= 0); instance = mLiveNodes.editValueAt(index); mLiveNodes.removeItemsAt(index); index = mDispatchers.indexOfKey(instance->nodeID()); CHECK(index >= 0); mDispatchers.removeItemsAt(index); invalidateNodeID_l(instance->nodeID()); } instance->onObserverDied(mMaster); } bool OMX::livesLocally(node_id /* node */, pid_t pid) { return pid == getpid(); } status_t OMX::listNodes(List<ComponentInfo> *list) { list->clear(); OMX_U32 index = 0; char componentName[256]; while (mMaster->enumerateComponents( componentName, sizeof(componentName), index) == OMX_ErrorNone) { list->push_back(ComponentInfo()); ComponentInfo &info = *--list->end(); info.mName = componentName; Vector<String8> roles; OMX_ERRORTYPE err = mMaster->getRolesOfComponent(componentName, &roles); if (err == OMX_ErrorNone) { for (OMX_U32 i = 0; i < roles.size(); ++i) { info.mRoles.push_back(roles[i]); } } ++index; } return OK; } status_t OMX::allocateNode( const char *name, const sp<IOMXObserver> &observer, node_id *node) { Mutex::Autolock autoLock(mLock); *node = 0; OMXNodeInstance *instance = new OMXNodeInstance(this, observer, name); OMX_COMPONENTTYPE *handle; OMX_ERRORTYPE err = mMaster->makeComponentInstance( name, &OMXNodeInstance::kCallbacks, instance, &handle); if (err != OMX_ErrorNone) { ALOGE("FAILED to allocate omx component '%s'", name); instance->onGetHandleFailed(); return UNKNOWN_ERROR; } *node = makeNodeID(instance); mDispatchers.add(*node, new CallbackDispatcher(instance)); instance->setHandle(*node, handle); mLiveNodes.add(observer->asBinder(), instance); observer->asBinder()->linkToDeath(this); return OK; } status_t OMX::freeNode(node_id node) { OMXNodeInstance *instance = findInstance(node); { Mutex::Autolock autoLock(mLock); ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder()); if (index < 0) { // This could conceivably happen if the observer dies at roughly the // same time that a client attempts to free the node explicitly. return OK; } mLiveNodes.removeItemsAt(index); } instance->observer()->asBinder()->unlinkToDeath(this); status_t err = instance->freeNode(mMaster); { Mutex::Autolock autoLock(mLock); ssize_t index = mDispatchers.indexOfKey(node); CHECK(index >= 0); mDispatchers.removeItemsAt(index); } return err; } status_t OMX::sendCommand( node_id node, OMX_COMMANDTYPE cmd, OMX_S32 param) { return findInstance(node)->sendCommand(cmd, param); } status_t OMX::getParameter( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { ALOGV("getParameter(%u %#x %p %zd)", node, index, params, size); return findInstance(node)->getParameter( index, params, size); } status_t OMX::setParameter( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { ALOGV("setParameter(%u %#x %p %zd)", node, index, params, size); return findInstance(node)->setParameter( index, params, size); } status_t OMX::getConfig( node_id node, OMX_INDEXTYPE index, void *params, size_t size) { return findInstance(node)->getConfig( index, params, size); } status_t OMX::setConfig( node_id node, OMX_INDEXTYPE index, const void *params, size_t size) { return findInstance(node)->setConfig( index, params, size); } status_t OMX::getState( node_id node, OMX_STATETYPE* state) { return findInstance(node)->getState( state); } status_t OMX::enableGraphicBuffers( node_id node, OMX_U32 port_index, OMX_BOOL enable) { return findInstance(node)->enableGraphicBuffers(port_index, enable); } status_t OMX::getGraphicBufferUsage( node_id node, OMX_U32 port_index, OMX_U32* usage) { return findInstance(node)->getGraphicBufferUsage(port_index, usage); } status_t OMX::storeMetaDataInBuffers( node_id node, OMX_U32 port_index, OMX_BOOL enable) { return findInstance(node)->storeMetaDataInBuffers(port_index, enable); } status_t OMX::prepareForAdaptivePlayback( node_id node, OMX_U32 portIndex, OMX_BOOL enable, OMX_U32 maxFrameWidth, OMX_U32 maxFrameHeight) { return findInstance(node)->prepareForAdaptivePlayback( portIndex, enable, maxFrameWidth, maxFrameHeight); } status_t OMX::configureVideoTunnelMode( node_id node, OMX_U32 portIndex, OMX_BOOL tunneled, OMX_U32 audioHwSync, native_handle_t **sidebandHandle) { return findInstance(node)->configureVideoTunnelMode( portIndex, tunneled, audioHwSync, sidebandHandle); } status_t OMX::useBuffer( node_id node, OMX_U32 port_index, const sp<IMemory> &params, buffer_id *buffer) { return findInstance(node)->useBuffer( port_index, params, buffer); } status_t OMX::useGraphicBuffer( node_id node, OMX_U32 port_index, const sp<GraphicBuffer> &graphicBuffer, buffer_id *buffer) { return findInstance(node)->useGraphicBuffer( port_index, graphicBuffer, buffer); } status_t OMX::updateGraphicBufferInMeta( node_id node, OMX_U32 port_index, const sp<GraphicBuffer> &graphicBuffer, buffer_id buffer) { return findInstance(node)->updateGraphicBufferInMeta( port_index, graphicBuffer, buffer); } status_t OMX::createInputSurface( node_id node, OMX_U32 port_index, sp<IGraphicBufferProducer> *bufferProducer) { return findInstance(node)->createInputSurface( port_index, bufferProducer); } status_t OMX::signalEndOfInputStream(node_id node) { return findInstance(node)->signalEndOfInputStream(); } status_t OMX::allocateBuffer( node_id node, OMX_U32 port_index, size_t size, buffer_id *buffer, void **buffer_data) { return findInstance(node)->allocateBuffer( port_index, size, buffer, buffer_data); } status_t OMX::allocateBufferWithBackup( node_id node, OMX_U32 port_index, const sp<IMemory> &params, buffer_id *buffer) { return findInstance(node)->allocateBufferWithBackup( port_index, params, buffer); } status_t OMX::freeBuffer(node_id node, OMX_U32 port_index, buffer_id buffer) { return findInstance(node)->freeBuffer( port_index, buffer); } status_t OMX::fillBuffer(node_id node, buffer_id buffer) { return findInstance(node)->fillBuffer(buffer); } status_t OMX::emptyBuffer( node_id node, buffer_id buffer, OMX_U32 range_offset, OMX_U32 range_length, OMX_U32 flags, OMX_TICKS timestamp) { return findInstance(node)->emptyBuffer( buffer, range_offset, range_length, flags, timestamp); } status_t OMX::getExtensionIndex( node_id node, const char *parameter_name, OMX_INDEXTYPE *index) { return findInstance(node)->getExtensionIndex( parameter_name, index); } status_t OMX::setInternalOption( node_id node, OMX_U32 port_index, InternalOptionType type, const void *data, size_t size) { return findInstance(node)->setInternalOption(port_index, type, data, size); } OMX_ERRORTYPE OMX::OnEvent( node_id node, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR /* pEventData */) { ALOGV("OnEvent(%d, %" PRIu32", %" PRIu32 ")", eEvent, nData1, nData2); // Forward to OMXNodeInstance. findInstance(node)->onEvent(eEvent, nData1, nData2); omx_message msg; msg.type = omx_message::EVENT; msg.node = node; msg.u.event_data.event = eEvent; msg.u.event_data.data1 = nData1; msg.u.event_data.data2 = nData2; findDispatcher(node)->post(msg); return OMX_ErrorNone; } OMX_ERRORTYPE OMX::OnEmptyBufferDone( node_id node, buffer_id buffer, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { ALOGV("OnEmptyBufferDone buffer=%p", pBuffer); omx_message msg; msg.type = omx_message::EMPTY_BUFFER_DONE; msg.node = node; msg.u.buffer_data.buffer = buffer; findDispatcher(node)->post(msg); return OMX_ErrorNone; } OMX_ERRORTYPE OMX::OnFillBufferDone( node_id node, buffer_id buffer, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { ALOGV("OnFillBufferDone buffer=%p", pBuffer); omx_message msg; msg.type = omx_message::FILL_BUFFER_DONE; msg.node = node; msg.u.extended_buffer_data.buffer = buffer; msg.u.extended_buffer_data.range_offset = pBuffer->nOffset; msg.u.extended_buffer_data.range_length = pBuffer->nFilledLen; msg.u.extended_buffer_data.flags = pBuffer->nFlags; msg.u.extended_buffer_data.timestamp = pBuffer->nTimeStamp; findDispatcher(node)->post(msg); return OMX_ErrorNone; } OMX::node_id OMX::makeNodeID(OMXNodeInstance *instance) { // mLock is already held. node_id node = (node_id)++mNodeCounter; mNodeIDToInstance.add(node, instance); return node; } OMXNodeInstance *OMX::findInstance(node_id node) { Mutex::Autolock autoLock(mLock); ssize_t index = mNodeIDToInstance.indexOfKey(node); return index < 0 ? NULL : mNodeIDToInstance.valueAt(index); } sp<OMX::CallbackDispatcher> OMX::findDispatcher(node_id node) { Mutex::Autolock autoLock(mLock); ssize_t index = mDispatchers.indexOfKey(node); return index < 0 ? NULL : mDispatchers.valueAt(index); } void OMX::invalidateNodeID(node_id node) { Mutex::Autolock autoLock(mLock); invalidateNodeID_l(node); } void OMX::invalidateNodeID_l(node_id node) { // mLock is held. mNodeIDToInstance.removeItem(node); } } // namespace android
14,437
4,799
#include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <iostream> #include <string> #include <fstream> #include "grammar/CspProblemGrammar.h" #include "utils/utils.h" #include "csp_problem/CspProblem.h" #include "solvers/BacktrackingSolver.h" #include "solvers/ForwardCheckingSolver.h" using namespace std; using namespace csp; void print_solutions(std::vector<Environment> solutions) { cout << "Solutions: " << solutions.size() << endl; for(auto solution : solutions) { cout << to_string(solution) << endl; } } int main(int argc, char** args) { if (argc != 2) { cout << "Input file must be specified" << endl; exit(1); } string inputFilePath(args[1]); ifstream file(inputFilePath); string cspProblemString((istreambuf_iterator<char>(file)), istreambuf_iterator<char>()); CspProblemGrammar cspProblemGrammar; CspProblemDefinition cspProblemDefinition; std::string::const_iterator iter = cspProblemString.cbegin(); std::string::const_iterator inputEnd = cspProblemString.cend(); bool success = phrase_parse(iter, inputEnd, cspProblemGrammar, boost::spirit::ascii::blank, cspProblemDefinition); if (!success) { std::string rest(iter, inputEnd); cout << "Parsing error: "<< endl; cout << "stopped at: \"" << rest << "\"\n"; exit(1); } cout << "Parsing successful." << endl; CspProblem cspProblem(cspProblemDefinition, ExpressionFactory()); cout << cspProblem.describe(); cout << "Forward checking: " << endl; ForwardCheckingSolver fcsolver(false); auto start = std::chrono::system_clock::now(); print_solutions(fcsolver.solve(cspProblem)); auto end = std::chrono::system_clock::now(); cout << "Time elapsed " << chrono::duration_cast<chrono::seconds>(end - start).count() << " seconds" << endl; cout << "Backtracking: " << endl; BacktrackingSolver btsolver(false); start = std::chrono::system_clock::now(); print_solutions(btsolver.solve(cspProblem)); end = std::chrono::system_clock::now(); cout << "Time elapsed " << chrono::duration_cast<chrono::seconds>(end - start).count() << " seconds" << endl; return 0; }
2,294
756
#include "stdio.h" #include <string.h> #include <vector> #include <stdlib.h> #include <conio.h> #include <iostream> #include <istream> #include <fstream> #include <sstream> #include "Player.h" #include "MilitarGround.h" #include "World.h" #include "Item.h" using namespace std; /*Inicio Zork*/ Player* player = nullptr; Item* it = nullptr; MilitaryGround* ground2 = nullptr; //Afegim World World world; int main() { string input_command; char key; int ending = 0; vector<string> args; it->initZones(); player->Init(); cout << endl; cout << "-->"; while (true) { if (!kbhit() != 0) { key = _getch(); if (key == '\b') { if(input_command.length()>0){ input_command.pop_back(); cout << '\b'; cout << " "; cout << '\b'; } } else if (key != '\r') { input_command += key; cout << key; } else { //convert. cout << endl; /*Instructions*/ world.convertToVector(input_command, args); world.worldInterpret(args); cout << endl; } } if (args.size() > 0 && input_command == "quit") { cout << "Bye! See you next time"; return 0; } /*Reset Params*/ if (args.size()>0) { args.clear(); input_command = ""; cout << "-->"; } } return 0; }
1,253
575
/*============================================================================= Spirit v1.6.0 Copyright (c) 2001-2003 Joel de Guzman http://spirit.sourceforge.net/ Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. =============================================================================*/ #ifndef BOOST_SPIRIT_CHSET_OPERATORS_IPP #define BOOST_SPIRIT_CHSET_OPERATORS_IPP /////////////////////////////////////////////////////////////////////////////// #if !defined(BOOST_LIMITS_HPP) #include "boost/limits.hpp" #endif /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////////// // // chset free operators implementation // /////////////////////////////////////////////////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) |= b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) -= b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator~(chset<CharT> const& a) { return chset<CharT>(a).inverse(); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) &= b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) ^= b; } /////////////////////////////////////////////////////////////////////////////// // // range <--> chset free operators implementation // /////////////////////////////////////////////////////////////////////////////// namespace impl { ////////////////////////////////// template <typename CharT> inline CharT decr(CharT v) { return v == std::numeric_limits<CharT>::min() ? v : v-1; } ////////////////////////////////// template <typename CharT> inline CharT incr(CharT v) { return v == std::numeric_limits<CharT>::max() ? v : v+1; } } template <typename CharT> inline chset<CharT> operator~(range<CharT> const& a) { chset<CharT> a_; a_.set(range<CharT>(std::numeric_limits<CharT>::min(), impl::decr(a.first))); a_.set(range<CharT>(impl::incr(a.last), std::numeric_limits<CharT>::max())); return a_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const& a, range<CharT> const& b) { chset<CharT> a_(a); a_.set(b); return a_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& a, range<CharT> const& b) { chset<CharT> a_(a); a_.clear(range<CharT>(std::numeric_limits<CharT>::min(), impl::decr(b.first))); a_.clear(range<CharT>(impl::incr(b.last), std::numeric_limits<CharT>::max())); return a_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const& a, range<CharT> const& b) { chset<CharT> a_(a); a_.clear(b); return a_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, range<CharT> const& b) { return a ^ chset<CharT>(b); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(range<CharT> const& a, chset<CharT> const& b) { chset<CharT> b_(b); b_.set(a); return b_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(range<CharT> const& a, chset<CharT> const& b) { chset<CharT> b_(b); b_.clear(range<CharT>(std::numeric_limits<CharT>::min(), impl::decr(a.first))); b_.clear(range<CharT>(impl::incr(a.last), std::numeric_limits<CharT>::max())); return b_; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(range<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) - b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(range<CharT> const& a, chset<CharT> const& b) { return chset<CharT>(a) ^ b; } /////////////////////////////////////////////////////////////////////////////// // // literal primitives <--> chset free operators implementation // /////////////////////////////////////////////////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const& a, CharT b) { return a | range<CharT>(b, b); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& a, CharT b) { return a & range<CharT>(b, b); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const& a, CharT b) { return a - range<CharT>(b, b); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, CharT b) { return a ^ range<CharT>(b, b); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(CharT a, chset<CharT> const& b) { return range<CharT>(a, a) | b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(CharT a, chset<CharT> const& b) { return range<CharT>(a, a) & b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(CharT a, chset<CharT> const& b) { return range<CharT>(a, a) - b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(CharT a, chset<CharT> const& b) { return range<CharT>(a, a) ^ b; } /////////////////////////////////////////////////////////////////////////////// // // chlit <--> chset free operators implementation // /////////////////////////////////////////////////////////////////////////////// template <typename CharT> inline chset<CharT> operator~(chlit<CharT> const& a) { return ~range<CharT>(a.ch, a.ch); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const& a, chlit<CharT> const& b) { return a | b.ch; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& a, chlit<CharT> const& b) { return a & b.ch; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const& a, chlit<CharT> const& b) { return a - b.ch; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, chlit<CharT> const& b) { return a ^ b.ch; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chlit<CharT> const& a, chset<CharT> const& b) { return a.ch | b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chlit<CharT> const& a, chset<CharT> const& b) { return a.ch & b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chlit<CharT> const& a, chset<CharT> const& b) { return a.ch - b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chlit<CharT> const& a, chset<CharT> const& b) { return a.ch ^ b; } /////////////////////////////////////////////////////////////////////////////// // // anychar_parser <--> chset free operators // // Where a is chset and b is a anychar_parser, and vice-versa, implements: // // a | b, a & b, a - b, a ^ b // // Where a is a chlit, implements: // // ~a // /////////////////////////////////////////////////////////////////////////////// namespace impl { template <typename CharT> inline boost::spirit::range<CharT> const& full() { static boost::spirit::range<CharT> full_( std::numeric_limits<CharT>::min(), std::numeric_limits<CharT>::max()); return full_; } template <typename CharT> inline boost::spirit::range<CharT> const& empty() { static boost::spirit::range<CharT> empty_; return empty_; } } ////////////////////////////////// inline nothing_parser operator~(anychar_parser) { return nothing_p; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const&, anychar_parser) { return chset<CharT>(impl::full<CharT>()); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& a, anychar_parser) { return a; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const&, anychar_parser) { return chset<CharT>(); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, anychar_parser) { return ~a; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(anychar_parser, chset<CharT> const& /*b*/) { return chset<CharT>(impl::full<CharT>()); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(anychar_parser, chset<CharT> const& b) { return b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(anychar_parser, chset<CharT> const& b) { return ~b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(anychar_parser, chset<CharT> const& b) { return ~b; } /////////////////////////////////////////////////////////////////////////////// // // nothing_parser <--> chset free operators implementation // /////////////////////////////////////////////////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(chset<CharT> const& a, nothing_parser) { return a; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(chset<CharT> const& /*a*/, nothing_parser) { return impl::empty<CharT>(); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(chset<CharT> const& a, nothing_parser) { return a; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(chset<CharT> const& a, nothing_parser) { return a; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator|(nothing_parser, chset<CharT> const& b) { return b; } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator&(nothing_parser, chset<CharT> const& /*b*/) { return impl::empty<CharT>(); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator-(nothing_parser, chset<CharT> const& /*b*/) { return impl::empty<CharT>(); } ////////////////////////////////// template <typename CharT> inline chset<CharT> operator^(nothing_parser, chset<CharT> const& b) { return b; } /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #endif
12,154
3,804
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of the copyright holders may not 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 Intel Corporation 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. // //M*/ #pragma once #ifndef OPENCV_CUDEV_FUNCTIONAL_COLOR_CVT_DETAIL_HPP #define OPENCV_CUDEV_FUNCTIONAL_COLOR_CVT_DETAIL_HPP #include "../../common.hpp" #include "../../util/vec_traits.hpp" #include "../../util/saturate_cast.hpp" #include "../../util/limits.hpp" #include "../functional.hpp" namespace cv { namespace cudev { namespace color_cvt_detail { // utility #define CV_CUDEV_DESCALE(x, n) (((x) + (1 << ((n)-1))) >> (n)) template <typename T> struct ColorChannel { __device__ __forceinline__ static T max() { return numeric_limits<T>::max(); } __device__ __forceinline__ static T half() { return (T)(max()/2 + 1); } }; template <> struct ColorChannel<float> { __device__ __forceinline__ static float max() { return 1.f; } __device__ __forceinline__ static float half() { return 0.5f; } }; template <typename T> __device__ __forceinline__ void setAlpha(typename MakeVec<T, 3>::type& vec, T val) { } template <typename T> __device__ __forceinline__ void setAlpha(typename MakeVec<T, 4>::type& vec, T val) { vec.w = val; } template <typename T> __device__ __forceinline__ T getAlpha(const typename MakeVec<T, 3>::type& vec) { return ColorChannel<T>::max(); } template <typename T> __device__ __forceinline__ T getAlpha(const typename MakeVec<T, 4>::type& vec) { return vec.w; } enum { rgb_shift = 15, yuv_shift = 14, xyz_shift = 12, R2Y = 4899, G2Y = 9617, B2Y = 1868, RY15 = 9798, GY15 = 19235, BY15 = 3735, BLOCK_SIZE = 256 }; // Various 3/4-channel to 3/4-channel RGB transformations template <typename T, int scn, int dcn, int bidx> struct RGB2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { typename MakeVec<T, dcn>::type dst; dst.x = bidx == 0 ? src.x : src.z; dst.y = src.y; dst.z = bidx == 0 ? src.z : src.x; setAlpha(dst, getAlpha<T>(src)); return dst; } }; // 24/32-bit RGB to 16-bit (565 or 555) RGB template <int scn, int bidx, int green_bits> struct RGB2RGB5x5; template <int scn, int bidx> struct RGB2RGB5x5<scn, bidx, 6> : unary_function<typename MakeVec<uchar, scn>::type, ushort> { __device__ ushort operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (ushort) ((b >> 3) | ((g & ~3) << 3) | ((r & ~7) << 8)); } }; template <int bidx> struct RGB2RGB5x5<3, bidx, 5> : unary_function<uchar3, ushort> { __device__ ushort operator ()(const uchar3& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (ushort) ((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7)); } }; template <int bidx> struct RGB2RGB5x5<4, bidx, 5> : unary_function<uchar4, ushort> { __device__ ushort operator ()(const uchar4& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int a = src.w; return (ushort) ((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7) | (a ? 0x8000 : 0)); } }; // 16-bit (565 or 555) RGB to 24/32-bit RGB template <int dcn, int bidx, int green_bits> struct RGB5x52RGB; template <int bidx> struct RGB5x52RGB<3, bidx, 5> : unary_function<ushort, uchar3> { __device__ uchar3 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 7) & ~7; uchar3 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 2) & ~7; dst.z = bidx == 0 ? r : b; return dst; } }; template <int bidx> struct RGB5x52RGB<4, bidx, 5> : unary_function<ushort, uchar4> { __device__ uchar4 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 7) & ~7; uchar4 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 2) & ~7; dst.z = bidx == 0 ? r : b; dst.w = (src & 0x8000) * 0xffu; return dst; } }; template <int bidx> struct RGB5x52RGB<3, bidx, 6> : unary_function<ushort, uchar3> { __device__ uchar3 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 8) & ~7; uchar3 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 3) & ~3; dst.z = bidx == 0 ? r : b; return dst; } }; template <int bidx> struct RGB5x52RGB<4, bidx, 6> : unary_function<ushort, uchar4> { __device__ uchar4 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 8) & ~7; uchar4 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 3) & ~3; dst.z = bidx == 0 ? r : b; dst.w = 255; return dst; } }; // Grayscale to RGB template <typename T, int dcn> struct Gray2RGB : unary_function<T, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(T src) const { typename MakeVec<T, dcn>::type dst; dst.z = dst.y = dst.x = src; setAlpha(dst, ColorChannel<T>::max()); return dst; } }; // Grayscale to 16-bit (565 or 555) RGB template <int green_bits> struct Gray2RGB5x5; template <> struct Gray2RGB5x5<5> : unary_function<uchar, ushort> { __device__ ushort operator ()(uchar src) const { const int t = src >> 3; return (ushort)(t | (t << 5) | (t << 10)); } }; template <> struct Gray2RGB5x5<6> : unary_function<uchar, ushort> { __device__ ushort operator ()(uchar src) const { const int t = src; return (ushort)((t >> 3) | ((t & ~3) << 3) | ((t & ~7) << 8)); } }; // 16-bit (565 or 555) RGB to Grayscale template <int green_bits> struct RGB5x52Gray; template <> struct RGB5x52Gray<5> : unary_function<ushort, uchar> { __device__ uchar operator ()(ushort src) const { return (uchar) CV_CUDEV_DESCALE(((src << 3) & 0xf8) * B2Y + ((src >> 2) & 0xf8) * G2Y + ((src >> 7) & 0xf8) * R2Y, yuv_shift); } }; template <> struct RGB5x52Gray<6> : unary_function<ushort, uchar> { __device__ uchar operator ()(ushort src) const { return (uchar) CV_CUDEV_DESCALE(((src << 3) & 0xf8) * B2Y + ((src >> 3) & 0xfc) * G2Y + ((src >> 8) & 0xf8) * R2Y, yuv_shift); } }; // RGB to Grayscale template <typename T, int scn, int bidx> struct RGB2Gray : unary_function<typename MakeVec<T, scn>::type, T> { __device__ T operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (T) CV_CUDEV_DESCALE(b * B2Y + g * G2Y + r * R2Y, yuv_shift); } }; template <int scn, int bidx> struct RGB2Gray<uchar, scn, bidx> : unary_function<typename MakeVec<uchar, scn>::type, uchar> { __device__ uchar operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (uchar)CV_CUDEV_DESCALE(b * BY15 + g * GY15 + r * RY15, rgb_shift); } }; template <int scn, int bidx> struct RGB2Gray<float, scn, bidx> : unary_function<typename MakeVec<float, scn>::type, float> { __device__ float operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; return b * 0.114f + g * 0.587f + r * 0.299f; } }; // RGB to YUV static __constant__ float c_RGB2YUVCoeffs_f[5] = { 0.114f, 0.587f, 0.299f, 0.492f, 0.877f }; static __constant__ int c_RGB2YUVCoeffs_i[5] = { B2Y, G2Y, R2Y, 8061, 14369 }; template <typename T, int scn, int dcn, int bidx> struct RGB2YUV : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int delta = ColorChannel<T>::half() * (1 << yuv_shift); const int Y = CV_CUDEV_DESCALE(b * c_RGB2YUVCoeffs_i[0] + g * c_RGB2YUVCoeffs_i[1] + r * c_RGB2YUVCoeffs_i[2], yuv_shift); const int Cb = CV_CUDEV_DESCALE((b - Y) * c_RGB2YUVCoeffs_i[3] + delta, yuv_shift); const int Cr = CV_CUDEV_DESCALE((r - Y) * c_RGB2YUVCoeffs_i[4] + delta, yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(Y); dst.y = saturate_cast<T>(Cb); dst.z = saturate_cast<T>(Cr); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2YUV<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = b * c_RGB2YUVCoeffs_f[0] + g * c_RGB2YUVCoeffs_f[1] + r * c_RGB2YUVCoeffs_f[2]; dst.y = (b - dst.x) * c_RGB2YUVCoeffs_f[3] + ColorChannel<float>::half(); dst.z = (r - dst.x) * c_RGB2YUVCoeffs_f[4] + ColorChannel<float>::half(); return dst; } }; // YUV to RGB static __constant__ float c_YUV2RGBCoeffs_f[5] = { 2.032f, -0.395f, -0.581f, 1.140f }; static __constant__ int c_YUV2RGBCoeffs_i[5] = { 33292, -6472, -9519, 18678 }; template <typename T, int scn, int dcn, int bidx> struct YUV2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int r = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); const int g = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[2] + (src.y - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); const int b = src.x + CV_CUDEV_DESCALE((src.y - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct YUV2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float r = src.x + (src.z - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[3]; const float g = src.x + (src.z - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[2] + (src.y - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[1]; const float b = src.x + (src.y - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[0]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to YCrCb static __constant__ float c_RGB2YCrCbCoeffs_f[5] = { 0.299f, 0.587f, 0.114f, 0.713f, 0.564f }; static __constant__ int c_RGB2YCrCbCoeffs_i[5] = { R2Y, G2Y, B2Y, 11682, 9241 }; template <typename T, int scn, int dcn, int bidx> struct RGB2YCrCb : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int delta = ColorChannel<T>::half() * (1 << yuv_shift); const int Y = CV_CUDEV_DESCALE(b * c_RGB2YCrCbCoeffs_i[2] + g * c_RGB2YCrCbCoeffs_i[1] + r * c_RGB2YCrCbCoeffs_i[0], yuv_shift); const int Cr = CV_CUDEV_DESCALE((r - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); const int Cb = CV_CUDEV_DESCALE((b - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(Y); dst.y = saturate_cast<T>(Cr); dst.z = saturate_cast<T>(Cb); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2YCrCb<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = b * c_RGB2YCrCbCoeffs_f[2] + g * c_RGB2YCrCbCoeffs_f[1] + r * c_RGB2YCrCbCoeffs_f[0]; dst.y = (r - dst.x) * c_RGB2YCrCbCoeffs_f[3] + ColorChannel<float>::half(); dst.z = (b - dst.x) * c_RGB2YCrCbCoeffs_f[4] + ColorChannel<float>::half(); return dst; } }; // YCrCb to RGB static __constant__ float c_YCrCb2RGBCoeffs_f[5] = {1.403f, -0.714f, -0.344f, 1.773f}; static __constant__ int c_YCrCb2RGBCoeffs_i[5] = {22987, -11698, -5636, 29049}; template <typename T, int scn, int dcn, int bidx> struct YCrCb2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); const int g = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[2] + (src.y - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); const int r = src.x + CV_CUDEV_DESCALE((src.y - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct YCrCb2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = src.x + (src.z - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[3]; const float g = src.x + (src.z - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[2] + (src.y - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[1]; const float r = src.x + (src.y - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[0]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to XYZ static __constant__ float c_RGB2XYZ_D65f[9] = { 0.412453f, 0.357580f, 0.180423f, 0.212671f, 0.715160f, 0.072169f, 0.019334f, 0.119193f, 0.950227f }; static __constant__ int c_RGB2XYZ_D65i[9] = { 1689, 1465, 739, 871, 2929, 296, 79, 488, 3892 }; template <typename T, int scn, int dcn, int bidx> struct RGB2XYZ : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; typename MakeVec<T, dcn>::type dst; dst.z = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[6] + g * c_RGB2XYZ_D65i[7] + b * c_RGB2XYZ_D65i[8], xyz_shift)); dst.x = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[0] + g * c_RGB2XYZ_D65i[1] + b * c_RGB2XYZ_D65i[2], xyz_shift)); dst.y = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[3] + g * c_RGB2XYZ_D65i[4] + b * c_RGB2XYZ_D65i[5], xyz_shift)); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2XYZ<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = r * c_RGB2XYZ_D65f[0] + g * c_RGB2XYZ_D65f[1] + b * c_RGB2XYZ_D65f[2]; dst.y = r * c_RGB2XYZ_D65f[3] + g * c_RGB2XYZ_D65f[4] + b * c_RGB2XYZ_D65f[5]; dst.z = r * c_RGB2XYZ_D65f[6] + g * c_RGB2XYZ_D65f[7] + b * c_RGB2XYZ_D65f[8]; return dst; } }; // XYZ to RGB static __constant__ float c_XYZ2sRGB_D65f[9] = { 3.240479f, -1.53715f, -0.498535f, -0.969256f, 1.875991f, 0.041556f, 0.055648f, -0.204043f, 1.057311f }; static __constant__ int c_XYZ2sRGB_D65i[9] = { 13273, -6296, -2042, -3970, 7684, 170, 228, -836, 4331 }; template <typename T, int scn, int dcn, int bidx> struct XYZ2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[6] + src.y * c_XYZ2sRGB_D65i[7] + src.z * c_XYZ2sRGB_D65i[8], xyz_shift); const int g = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[3] + src.y * c_XYZ2sRGB_D65i[4] + src.z * c_XYZ2sRGB_D65i[5], xyz_shift); const int r = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[0] + src.y * c_XYZ2sRGB_D65i[1] + src.z * c_XYZ2sRGB_D65i[2], xyz_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct XYZ2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = src.x * c_XYZ2sRGB_D65f[6] + src.y * c_XYZ2sRGB_D65f[7] + src.z * c_XYZ2sRGB_D65f[8]; const float g = src.x * c_XYZ2sRGB_D65f[3] + src.y * c_XYZ2sRGB_D65f[4] + src.z * c_XYZ2sRGB_D65f[5]; const float r = src.x * c_XYZ2sRGB_D65f[0] + src.y * c_XYZ2sRGB_D65f[1] + src.z * c_XYZ2sRGB_D65f[2]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to HSV static __constant__ int c_HsvDivTable [256] = {0, 1044480, 522240, 348160, 261120, 208896, 174080, 149211, 130560, 116053, 104448, 94953, 87040, 80345, 74606, 69632, 65280, 61440, 58027, 54973, 52224, 49737, 47476, 45412, 43520, 41779, 40172, 38684, 37303, 36017, 34816, 33693, 32640, 31651, 30720, 29842, 29013, 28229, 27486, 26782, 26112, 25475, 24869, 24290, 23738, 23211, 22706, 22223, 21760, 21316, 20890, 20480, 20086, 19707, 19342, 18991, 18651, 18324, 18008, 17703, 17408, 17123, 16846, 16579, 16320, 16069, 15825, 15589, 15360, 15137, 14921, 14711, 14507, 14308, 14115, 13926, 13743, 13565, 13391, 13221, 13056, 12895, 12738, 12584, 12434, 12288, 12145, 12006, 11869, 11736, 11605, 11478, 11353, 11231, 11111, 10995, 10880, 10768, 10658, 10550, 10445, 10341, 10240, 10141, 10043, 9947, 9854, 9761, 9671, 9582, 9495, 9410, 9326, 9243, 9162, 9082, 9004, 8927, 8852, 8777, 8704, 8632, 8561, 8492, 8423, 8356, 8290, 8224, 8160, 8097, 8034, 7973, 7913, 7853, 7795, 7737, 7680, 7624, 7569, 7514, 7461, 7408, 7355, 7304, 7253, 7203, 7154, 7105, 7057, 7010, 6963, 6917, 6872, 6827, 6782, 6739, 6695, 6653, 6611, 6569, 6528, 6487, 6447, 6408, 6369, 6330, 6292, 6254, 6217, 6180, 6144, 6108, 6073, 6037, 6003, 5968, 5935, 5901, 5868, 5835, 5803, 5771, 5739, 5708, 5677, 5646, 5615, 5585, 5556, 5526, 5497, 5468, 5440, 5412, 5384, 5356, 5329, 5302, 5275, 5249, 5222, 5196, 5171, 5145, 5120, 5095, 5070, 5046, 5022, 4998, 4974, 4950, 4927, 4904, 4881, 4858, 4836, 4813, 4791, 4769, 4748, 4726, 4705, 4684, 4663, 4642, 4622, 4601, 4581, 4561, 4541, 4522, 4502, 4483, 4464, 4445, 4426, 4407, 4389, 4370, 4352, 4334, 4316, 4298, 4281, 4263, 4246, 4229, 4212, 4195, 4178, 4161, 4145, 4128, 4112, 4096}; static __constant__ int c_HsvDivTable180[256] = {0, 122880, 61440, 40960, 30720, 24576, 20480, 17554, 15360, 13653, 12288, 11171, 10240, 9452, 8777, 8192, 7680, 7228, 6827, 6467, 6144, 5851, 5585, 5343, 5120, 4915, 4726, 4551, 4389, 4237, 4096, 3964, 3840, 3724, 3614, 3511, 3413, 3321, 3234, 3151, 3072, 2997, 2926, 2858, 2793, 2731, 2671, 2614, 2560, 2508, 2458, 2409, 2363, 2318, 2276, 2234, 2194, 2156, 2119, 2083, 2048, 2014, 1982, 1950, 1920, 1890, 1862, 1834, 1807, 1781, 1755, 1731, 1707, 1683, 1661, 1638, 1617, 1596, 1575, 1555, 1536, 1517, 1499, 1480, 1463, 1446, 1429, 1412, 1396, 1381, 1365, 1350, 1336, 1321, 1307, 1293, 1280, 1267, 1254, 1241, 1229, 1217, 1205, 1193, 1182, 1170, 1159, 1148, 1138, 1127, 1117, 1107, 1097, 1087, 1078, 1069, 1059, 1050, 1041, 1033, 1024, 1016, 1007, 999, 991, 983, 975, 968, 960, 953, 945, 938, 931, 924, 917, 910, 904, 897, 890, 884, 878, 871, 865, 859, 853, 847, 842, 836, 830, 825, 819, 814, 808, 803, 798, 793, 788, 783, 778, 773, 768, 763, 759, 754, 749, 745, 740, 736, 731, 727, 723, 719, 714, 710, 706, 702, 698, 694, 690, 686, 683, 679, 675, 671, 668, 664, 661, 657, 654, 650, 647, 643, 640, 637, 633, 630, 627, 624, 621, 617, 614, 611, 608, 605, 602, 599, 597, 594, 591, 588, 585, 582, 580, 577, 574, 572, 569, 566, 564, 561, 559, 556, 554, 551, 549, 546, 544, 541, 539, 537, 534, 532, 530, 527, 525, 523, 521, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 497, 495, 493, 492, 490, 488, 486, 484, 482}; static __constant__ int c_HsvDivTable256[256] = {0, 174763, 87381, 58254, 43691, 34953, 29127, 24966, 21845, 19418, 17476, 15888, 14564, 13443, 12483, 11651, 10923, 10280, 9709, 9198, 8738, 8322, 7944, 7598, 7282, 6991, 6722, 6473, 6242, 6026, 5825, 5638, 5461, 5296, 5140, 4993, 4855, 4723, 4599, 4481, 4369, 4263, 4161, 4064, 3972, 3884, 3799, 3718, 3641, 3567, 3495, 3427, 3361, 3297, 3236, 3178, 3121, 3066, 3013, 2962, 2913, 2865, 2819, 2774, 2731, 2689, 2648, 2608, 2570, 2533, 2497, 2461, 2427, 2394, 2362, 2330, 2300, 2270, 2241, 2212, 2185, 2158, 2131, 2106, 2081, 2056, 2032, 2009, 1986, 1964, 1942, 1920, 1900, 1879, 1859, 1840, 1820, 1802, 1783, 1765, 1748, 1730, 1713, 1697, 1680, 1664, 1649, 1633, 1618, 1603, 1589, 1574, 1560, 1547, 1533, 1520, 1507, 1494, 1481, 1469, 1456, 1444, 1432, 1421, 1409, 1398, 1387, 1376, 1365, 1355, 1344, 1334, 1324, 1314, 1304, 1295, 1285, 1276, 1266, 1257, 1248, 1239, 1231, 1222, 1214, 1205, 1197, 1189, 1181, 1173, 1165, 1157, 1150, 1142, 1135, 1128, 1120, 1113, 1106, 1099, 1092, 1085, 1079, 1072, 1066, 1059, 1053, 1046, 1040, 1034, 1028, 1022, 1016, 1010, 1004, 999, 993, 987, 982, 976, 971, 966, 960, 955, 950, 945, 940, 935, 930, 925, 920, 915, 910, 906, 901, 896, 892, 887, 883, 878, 874, 869, 865, 861, 857, 853, 848, 844, 840, 836, 832, 828, 824, 820, 817, 813, 809, 805, 802, 798, 794, 791, 787, 784, 780, 777, 773, 770, 767, 763, 760, 757, 753, 750, 747, 744, 741, 737, 734, 731, 728, 725, 722, 719, 716, 713, 710, 708, 705, 702, 699, 696, 694, 691, 688, 685}; template <typename T, int scn, int dcn, int bidx, int hr> struct RGB2HSV; template <int scn, int dcn, int bidx, int hr> struct RGB2HSV<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int hsv_shift = 12; const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; int h, s, v = b; int vmin = b, diff; int vr, vg; v = ::max(v, g); v = ::max(v, r); vmin = ::min(vmin, g); vmin = ::min(vmin, r); diff = v - vmin; vr = (v == r) * -1; vg = (v == g) * -1; s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; h += (h < 0) * hr; typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(h); dst.y = saturate_cast<uchar>(s); dst.z = saturate_cast<uchar>(v); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct RGB2HSV<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = hr * (1.f / 360.f); const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; float h, s, v; float vmin, diff; v = vmin = r; v = ::fmax(v, g); v = ::fmax(v, b); vmin = ::fmin(vmin, g); vmin = ::fmin(vmin, b); diff = v - vmin; s = diff / (float)(::fabs(v) + numeric_limits<float>::epsilon()); diff = (float)(60. / (diff + numeric_limits<float>::epsilon())); h = (v == r) * (g - b) * diff; h += (v != r && v == g) * ((b - r) * diff + 120.f); h += (v != r && v != g) * ((r - g) * diff + 240.f); h += (h < 0) * 360.f; typename MakeVec<float, dcn>::type dst; dst.x = h * hscale; dst.y = s; dst.z = v; return dst; } }; // HSV to RGB static __constant__ int c_HsvSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; template <typename T, int scn, int dcn, int bidx, int hr> struct HSV2RGB; template <int scn, int dcn, int bidx, int hr> struct HSV2RGB<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = 6.f / hr; float h = src.x, s = src.y, v = src.z; float b = v, g = v, r = v; if (s != 0) { h *= hscale; if( h < 0 ) do h += 6; while( h < 0 ); else if( h >= 6 ) do h -= 6; while( h >= 6 ); int sector = __float2int_rd(h); h -= sector; if ( (unsigned)sector >= 6u ) { sector = 0; h = 0.f; } float tab[4]; tab[0] = v; tab[1] = v * (1.f - s); tab[2] = v * (1.f - s * h); tab[3] = v * (1.f - s * (1.f - h)); b = tab[c_HsvSectorData[sector][0]]; g = tab[c_HsvSectorData[sector][1]]; r = tab[c_HsvSectorData[sector][2]]; } typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct HSV2RGB<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x; buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); HSV2RGB<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to HLS template <typename T, int scn, int dcn, int bidx, int hr> struct RGB2HLS; template <int scn, int dcn, int bidx, int hr> struct RGB2HLS<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = hr * (1.f / 360.f); const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; float h = 0.f, s = 0.f, l; float vmin, vmax, diff; vmax = vmin = r; vmax = ::fmax(vmax, g); vmax = ::fmax(vmax, b); vmin = ::fmin(vmin, g); vmin = ::fmin(vmin, b); diff = vmax - vmin; l = (vmax + vmin) * 0.5f; if (diff > numeric_limits<float>::epsilon()) { s = l < 0.5f ? diff / (vmax + vmin) : diff / (2 - vmax - vmin); diff = 60.f / diff; h = (vmax == r) * (g - b) * diff; h += (vmax != r && vmax == g) * ((b - r) * diff + 120.f); h += (vmax != r && vmax != g) * ((r - g) * diff + 240.f); h += (h < 0.f) * 360.f; } typename MakeVec<float, dcn>::type dst; dst.x = h * hscale; dst.y = l; dst.z = s; return dst; } }; template <int scn, int dcn, int bidx, int hr> struct RGB2HLS<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (1.f / 255.f); buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); RGB2HLS<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); return dst; } }; // HLS to RGB static __constant__ int c_HlsSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; template <typename T, int scn, int dcn, int bidx, int hr> struct HLS2RGB; template <int scn, int dcn, int bidx, int hr> struct HLS2RGB<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = 6.0f / hr; float h = src.x, l = src.y, s = src.z; float b = l, g = l, r = l; if (s != 0) { float p2 = (l <= 0.5f) * l * (1 + s); p2 += (l > 0.5f) * (l + s - l * s); float p1 = 2 * l - p2; h *= hscale; if( h < 0 ) do h += 6; while( h < 0 ); else if( h >= 6 ) do h -= 6; while( h >= 6 ); int sector; sector = __float2int_rd(h); h -= sector; float tab[4]; tab[0] = p2; tab[1] = p1; tab[2] = p1 + (p2 - p1) * (1 - h); tab[3] = p1 + (p2 - p1) * h; b = tab[c_HlsSectorData[sector][0]]; g = tab[c_HlsSectorData[sector][1]]; r = tab[c_HlsSectorData[sector][2]]; } typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct HLS2RGB<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x; buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); HLS2RGB<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to Lab enum { LAB_CBRT_TAB_SIZE = 1024, GAMMA_TAB_SIZE = 1024, lab_shift = xyz_shift, gamma_shift = 3, lab_shift2 = (lab_shift + gamma_shift), LAB_CBRT_TAB_SIZE_B = (256 * 3 / 2 * (1 << gamma_shift)) }; static __constant__ ushort c_sRGBGammaTab_b[] = {0,1,1,2,2,3,4,4,5,6,6,7,8,8,9,10,11,11,12,13,14,15,16,17,19,20,21,22,24,25,26,28,29,31,33,34,36,38,40,41,43,45,47,49,51,54,56,58,60,63,65,68,70,73,75,78,81,83,86,89,92,95,98,101,105,108,111,115,118,121,125,129,132,136,140,144,147,151,155,160,164,168,172,176,181,185,190,194,199,204,209,213,218,223,228,233,239,244,249,255,260,265,271,277,282,288,294,300,306,312,318,324,331,337,343,350,356,363,370,376,383,390,397,404,411,418,426,433,440,448,455,463,471,478,486,494,502,510,518,527,535,543,552,560,569,578,586,595,604,613,622,631,641,650,659,669,678,688,698,707,717,727,737,747,757,768,778,788,799,809,820,831,842,852,863,875,886,897,908,920,931,943,954,966,978,990,1002,1014,1026,1038,1050,1063,1075,1088,1101,1113,1126,1139,1152,1165,1178,1192,1205,1218,1232,1245,1259,1273,1287,1301,1315,1329,1343,1357,1372,1386,1401,1415,1430,1445,1460,1475,1490,1505,1521,1536,1551,1567,1583,1598,1614,1630,1646,1662,1678,1695,1711,1728,1744,1761,1778,1794,1811,1828,1846,1863,1880,1897,1915,1933,1950,1968,1986,2004,2022,2040}; static __constant__ float c_sRGBGammaTab[] = {0,7.55853e-05,0.,-7.51331e-13,7.55853e-05,7.55853e-05,-2.25399e-12,3.75665e-12,0.000151171,7.55853e-05,9.01597e-12,-6.99932e-12,0.000226756,7.55853e-05,-1.1982e-11,2.41277e-12,0.000302341,7.55853e-05,-4.74369e-12,1.19001e-11,0.000377927,7.55853e-05,3.09568e-11,-2.09095e-11,0.000453512,7.55853e-05,-3.17718e-11,1.35303e-11,0.000529097,7.55853e-05,8.81905e-12,-4.10782e-12,0.000604683,7.55853e-05,-3.50439e-12,2.90097e-12,0.000680268,7.55853e-05,5.19852e-12,-7.49607e-12,0.000755853,7.55853e-05,-1.72897e-11,2.70833e-11,0.000831439,7.55854e-05,6.39602e-11,-4.26295e-11,0.000907024,7.55854e-05,-6.39282e-11,2.70193e-11,0.000982609,7.55853e-05,1.71298e-11,-7.24017e-12,0.00105819,7.55853e-05,-4.59077e-12,1.94137e-12,0.00113378,7.55853e-05,1.23333e-12,-5.25291e-13,0.00120937,7.55853e-05,-3.42545e-13,1.59799e-13,0.00128495,7.55853e-05,1.36852e-13,-1.13904e-13,0.00136054,7.55853e-05,-2.04861e-13,2.95818e-13,0.00143612,7.55853e-05,6.82594e-13,-1.06937e-12,0.00151171,7.55853e-05,-2.52551e-12,3.98166e-12,0.00158729,7.55853e-05,9.41946e-12,-1.48573e-11,0.00166288,7.55853e-05,-3.51523e-11,5.54474e-11,0.00173846,7.55854e-05,1.3119e-10,-9.0517e-11,0.00181405,7.55854e-05,-1.40361e-10,7.37899e-11,0.00188963,7.55853e-05,8.10085e-11,-8.82272e-11,0.00196522,7.55852e-05,-1.83673e-10,1.62704e-10,0.0020408,7.55853e-05,3.04438e-10,-2.13341e-10,0.00211639,7.55853e-05,-3.35586e-10,2.25e-10,0.00219197,7.55853e-05,3.39414e-10,-2.20997e-10,0.00226756,7.55853e-05,-3.23576e-10,1.93326e-10,0.00234315,7.55853e-05,2.564e-10,-8.66446e-11,0.00241873,7.55855e-05,-3.53328e-12,-7.9578e-11,0.00249432,7.55853e-05,-2.42267e-10,1.72126e-10,0.0025699,7.55853e-05,2.74111e-10,-1.43265e-10,0.00264549,7.55854e-05,-1.55683e-10,-6.47292e-11,0.00272107,7.55849e-05,-3.4987e-10,8.67842e-10,0.00279666,7.55868e-05,2.25366e-09,-3.8723e-09,0.00287224,7.55797e-05,-9.36325e-09,1.5087e-08,0.00294783,7.56063e-05,3.58978e-08,-5.69415e-08,0.00302341,7.55072e-05,-1.34927e-07,2.13144e-07,0.003099,7.58768e-05,5.04507e-07,1.38713e-07,0.00317552,7.7302e-05,9.20646e-07,-1.55186e-07,0.00325359,7.86777e-05,4.55087e-07,4.26813e-08,0.00333276,7.97159e-05,5.83131e-07,-1.06495e-08,0.00341305,8.08502e-05,5.51182e-07,3.87467e-09,0.00349446,8.19642e-05,5.62806e-07,-1.92586e-10,0.00357698,8.30892e-05,5.62228e-07,1.0866e-09,0.00366063,8.4217e-05,5.65488e-07,5.02818e-10,0.00374542,8.53494e-05,5.66997e-07,8.60211e-10,0.00383133,8.6486e-05,5.69577e-07,7.13044e-10,0.00391839,8.76273e-05,5.71716e-07,4.78527e-10,0.00400659,8.87722e-05,5.73152e-07,1.09818e-09,0.00409594,8.99218e-05,5.76447e-07,2.50964e-10,0.00418644,9.10754e-05,5.772e-07,1.15762e-09,0.00427809,9.22333e-05,5.80672e-07,2.40865e-10,0.0043709,9.33954e-05,5.81395e-07,1.13854e-09,0.00446488,9.45616e-05,5.84811e-07,3.27267e-10,0.00456003,9.57322e-05,5.85792e-07,8.1197e-10,0.00465635,9.69062e-05,5.88228e-07,6.15823e-10,0.00475384,9.80845e-05,5.90076e-07,9.15747e-10,0.00485252,9.92674e-05,5.92823e-07,3.778e-10,0.00495238,0.000100454,5.93956e-07,8.32623e-10,0.00505343,0.000101645,5.96454e-07,4.82695e-10,0.00515567,0.000102839,5.97902e-07,9.61904e-10,0.00525911,0.000104038,6.00788e-07,3.26281e-10,0.00536375,0.00010524,6.01767e-07,9.926e-10,0.00546959,0.000106447,6.04745e-07,3.59933e-10,0.00557664,0.000107657,6.05824e-07,8.2728e-10,0.0056849,0.000108871,6.08306e-07,5.21898e-10,0.00579438,0.00011009,6.09872e-07,8.10492e-10,0.00590508,0.000111312,6.12303e-07,4.27046e-10,0.00601701,0.000112538,6.13585e-07,7.40878e-10,0.00613016,0.000113767,6.15807e-07,8.00469e-10,0.00624454,0.000115001,6.18209e-07,2.48178e-10,0.00636016,0.000116238,6.18953e-07,1.00073e-09,0.00647702,0.000117479,6.21955e-07,4.05654e-10,0.00659512,0.000118724,6.23172e-07,6.36192e-10,0.00671447,0.000119973,6.25081e-07,7.74927e-10,0.00683507,0.000121225,6.27406e-07,4.54975e-10,0.00695692,0.000122481,6.28771e-07,6.64841e-10,0.00708003,0.000123741,6.30765e-07,6.10972e-10,0.00720441,0.000125004,6.32598e-07,6.16543e-10,0.00733004,0.000126271,6.34448e-07,6.48204e-10,0.00745695,0.000127542,6.36392e-07,5.15835e-10,0.00758513,0.000128816,6.3794e-07,5.48103e-10,0.00771458,0.000130094,6.39584e-07,1.01706e-09,0.00784532,0.000131376,6.42635e-07,4.0283e-11,0.00797734,0.000132661,6.42756e-07,6.84471e-10,0.00811064,0.000133949,6.4481e-07,9.47144e-10,0.00824524,0.000135241,6.47651e-07,1.83472e-10,0.00838112,0.000136537,6.48201e-07,1.11296e-09,0.00851831,0.000137837,6.5154e-07,2.13163e-11,0.0086568,0.00013914,6.51604e-07,6.64462e-10,0.00879659,0.000140445,6.53598e-07,1.04613e-09,0.00893769,0.000141756,6.56736e-07,-1.92377e-10,0.0090801,0.000143069,6.56159e-07,1.58601e-09,0.00922383,0.000144386,6.60917e-07,-5.63754e-10,0.00936888,0.000145706,6.59226e-07,1.60033e-09,0.00951524,0.000147029,6.64027e-07,-2.49543e-10,0.00966294,0.000148356,6.63278e-07,1.26043e-09,0.00981196,0.000149687,6.67059e-07,-1.35572e-10,0.00996231,0.00015102,6.66653e-07,1.14458e-09,0.010114,0.000152357,6.70086e-07,2.13864e-10,0.010267,0.000153698,6.70728e-07,7.93856e-10,0.0104214,0.000155042,6.73109e-07,3.36077e-10,0.0105771,0.000156389,6.74118e-07,6.55765e-10,0.0107342,0.000157739,6.76085e-07,7.66211e-10,0.0108926,0.000159094,6.78384e-07,4.66116e-12,0.0110524,0.000160451,6.78398e-07,1.07775e-09,0.0112135,0.000161811,6.81631e-07,3.41023e-10,0.011376,0.000163175,6.82654e-07,3.5205e-10,0.0115398,0.000164541,6.8371e-07,1.04473e-09,0.0117051,0.000165912,6.86844e-07,1.25757e-10,0.0118717,0.000167286,6.87222e-07,3.14818e-10,0.0120396,0.000168661,6.88166e-07,1.40886e-09,0.012209,0.000170042,6.92393e-07,-3.62244e-10,0.0123797,0.000171425,6.91306e-07,9.71397e-10,0.0125518,0.000172811,6.9422e-07,2.02003e-10,0.0127253,0.0001742,6.94826e-07,1.01448e-09,0.0129002,0.000175593,6.97869e-07,3.96653e-10,0.0130765,0.00017699,6.99059e-07,1.92927e-10,0.0132542,0.000178388,6.99638e-07,6.94305e-10,0.0134333,0.00017979,7.01721e-07,7.55108e-10,0.0136138,0.000181195,7.03986e-07,1.05918e-11,0.0137957,0.000182603,7.04018e-07,1.06513e-09,0.013979,0.000184015,7.07214e-07,3.85512e-10,0.0141637,0.00018543,7.0837e-07,1.86769e-10,0.0143499,0.000186848,7.0893e-07,7.30116e-10,0.0145374,0.000188268,7.11121e-07,6.17983e-10,0.0147264,0.000189692,7.12975e-07,5.23282e-10,0.0149168,0.000191119,7.14545e-07,8.28398e-11,0.0151087,0.000192549,7.14793e-07,1.0081e-09,0.0153019,0.000193981,7.17817e-07,5.41244e-10,0.0154966,0.000195418,7.19441e-07,-3.7907e-10,0.0156928,0.000196856,7.18304e-07,1.90641e-09,0.0158903,0.000198298,7.24023e-07,-7.27387e-10,0.0160893,0.000199744,7.21841e-07,1.00317e-09,0.0162898,0.000201191,7.24851e-07,4.39949e-10,0.0164917,0.000202642,7.2617e-07,9.6234e-10,0.0166951,0.000204097,7.29057e-07,-5.64019e-10,0.0168999,0.000205554,7.27365e-07,1.29374e-09,0.0171062,0.000207012,7.31247e-07,9.77025e-10,0.017314,0.000208478,7.34178e-07,-1.47651e-09,0.0175232,0.000209942,7.29748e-07,3.06636e-09,0.0177338,0.00021141,7.38947e-07,-1.47573e-09,0.017946,0.000212884,7.3452e-07,9.7386e-10,0.0181596,0.000214356,7.37442e-07,1.30562e-09,0.0183747,0.000215835,7.41358e-07,-6.08376e-10,0.0185913,0.000217315,7.39533e-07,1.12785e-09,0.0188093,0.000218798,7.42917e-07,-1.77711e-10,0.0190289,0.000220283,7.42384e-07,1.44562e-09,0.0192499,0.000221772,7.46721e-07,-1.68825e-11,0.0194724,0.000223266,7.4667e-07,4.84533e-10,0.0196964,0.000224761,7.48124e-07,-5.85298e-11,0.0199219,0.000226257,7.47948e-07,1.61217e-09,0.0201489,0.000227757,7.52785e-07,-8.02136e-10,0.0203775,0.00022926,7.50378e-07,1.59637e-09,0.0206075,0.000230766,7.55167e-07,4.47168e-12,0.020839,0.000232276,7.55181e-07,2.48387e-10,0.021072,0.000233787,7.55926e-07,8.6474e-10,0.0213066,0.000235302,7.5852e-07,1.78299e-11,0.0215426,0.000236819,7.58573e-07,9.26567e-10,0.0217802,0.000238339,7.61353e-07,1.34529e-12,0.0220193,0.000239862,7.61357e-07,9.30659e-10,0.0222599,0.000241387,7.64149e-07,1.34529e-12,0.0225021,0.000242915,7.64153e-07,9.26567e-10,0.0227458,0.000244447,7.66933e-07,1.76215e-11,0.022991,0.00024598,7.66986e-07,8.65536e-10,0.0232377,0.000247517,7.69582e-07,2.45677e-10,0.023486,0.000249057,7.70319e-07,1.44193e-11,0.0237358,0.000250598,7.70363e-07,1.55918e-09,0.0239872,0.000252143,7.7504e-07,-6.63173e-10,0.0242401,0.000253691,7.73051e-07,1.09357e-09,0.0244946,0.000255241,7.76331e-07,1.41919e-11,0.0247506,0.000256793,7.76374e-07,7.12248e-10,0.0250082,0.000258348,7.78511e-07,8.62049e-10,0.0252673,0.000259908,7.81097e-07,-4.35061e-10,0.025528,0.000261469,7.79792e-07,8.7825e-10,0.0257902,0.000263031,7.82426e-07,6.47181e-10,0.0260541,0.000264598,7.84368e-07,2.58448e-10,0.0263194,0.000266167,7.85143e-07,1.81558e-10,0.0265864,0.000267738,7.85688e-07,8.78041e-10,0.0268549,0.000269312,7.88322e-07,3.15102e-11,0.027125,0.000270889,7.88417e-07,8.58525e-10,0.0273967,0.000272468,7.90992e-07,2.59812e-10,0.02767,0.000274051,7.91772e-07,-3.5224e-11,0.0279448,0.000275634,7.91666e-07,1.74377e-09,0.0282212,0.000277223,7.96897e-07,-1.35196e-09,0.0284992,0.000278813,7.92841e-07,1.80141e-09,0.0287788,0.000280404,7.98246e-07,-2.65629e-10,0.0290601,0.000281999,7.97449e-07,1.12374e-09,0.0293428,0.000283598,8.0082e-07,-5.04106e-10,0.0296272,0.000285198,7.99308e-07,8.92764e-10,0.0299132,0.000286799,8.01986e-07,6.58379e-10,0.0302008,0.000288405,8.03961e-07,1.98971e-10,0.0304901,0.000290014,8.04558e-07,4.08382e-10,0.0307809,0.000291624,8.05783e-07,3.01839e-11,0.0310733,0.000293236,8.05874e-07,1.33343e-09,0.0313673,0.000294851,8.09874e-07,2.2419e-10,0.031663,0.000296472,8.10547e-07,-3.67606e-10,0.0319603,0.000298092,8.09444e-07,1.24624e-09,0.0322592,0.000299714,8.13182e-07,-8.92025e-10,0.0325597,0.000301338,8.10506e-07,2.32183e-09,0.0328619,0.000302966,8.17472e-07,-9.44719e-10,0.0331657,0.000304598,8.14638e-07,1.45703e-09,0.0334711,0.000306232,8.19009e-07,-1.15805e-09,0.0337781,0.000307866,8.15535e-07,3.17507e-09,0.0340868,0.000309507,8.2506e-07,-4.09161e-09,0.0343971,0.000311145,8.12785e-07,5.74079e-09,0.0347091,0.000312788,8.30007e-07,-3.97034e-09,0.0350227,0.000314436,8.18096e-07,2.68985e-09,0.035338,0.00031608,8.26166e-07,6.61676e-10,0.0356549,0.000317734,8.28151e-07,-1.61123e-09,0.0359734,0.000319386,8.23317e-07,2.05786e-09,0.0362936,0.000321038,8.29491e-07,8.30388e-10,0.0366155,0.0003227,8.31982e-07,-1.65424e-09,0.036939,0.000324359,8.27019e-07,2.06129e-09,0.0372642,0.000326019,8.33203e-07,8.59719e-10,0.0375911,0.000327688,8.35782e-07,-1.77488e-09,0.0379196,0.000329354,8.30458e-07,2.51464e-09,0.0382498,0.000331023,8.38002e-07,-8.33135e-10,0.0385817,0.000332696,8.35502e-07,8.17825e-10,0.0389152,0.00033437,8.37956e-07,1.28718e-09,0.0392504,0.00033605,8.41817e-07,-2.2413e-09,0.0395873,0.000337727,8.35093e-07,3.95265e-09,0.0399258,0.000339409,8.46951e-07,-2.39332e-09,0.0402661,0.000341095,8.39771e-07,1.89533e-09,0.040608,0.000342781,8.45457e-07,-1.46271e-09,0.0409517,0.000344467,8.41069e-07,3.95554e-09,0.041297,0.000346161,8.52936e-07,-3.18369e-09,0.041644,0.000347857,8.43385e-07,1.32873e-09,0.0419927,0.000349548,8.47371e-07,1.59402e-09,0.0423431,0.000351248,8.52153e-07,-2.54336e-10,0.0426952,0.000352951,8.5139e-07,-5.76676e-10,0.043049,0.000354652,8.4966e-07,2.56114e-09,0.0434045,0.000356359,8.57343e-07,-2.21744e-09,0.0437617,0.000358067,8.50691e-07,2.58344e-09,0.0441206,0.000359776,8.58441e-07,-6.65826e-10,0.0444813,0.000361491,8.56444e-07,7.99218e-11,0.0448436,0.000363204,8.56684e-07,3.46063e-10,0.0452077,0.000364919,8.57722e-07,2.26116e-09,0.0455734,0.000366641,8.64505e-07,-1.94005e-09,0.045941,0.000368364,8.58685e-07,1.77384e-09,0.0463102,0.000370087,8.64007e-07,-1.43005e-09,0.0466811,0.000371811,8.59717e-07,3.94634e-09,0.0470538,0.000373542,8.71556e-07,-3.17946e-09,0.0474282,0.000375276,8.62017e-07,1.32104e-09,0.0478043,0.000377003,8.6598e-07,1.62045e-09,0.0481822,0.00037874,8.70842e-07,-3.52297e-10,0.0485618,0.000380481,8.69785e-07,-2.11211e-10,0.0489432,0.00038222,8.69151e-07,1.19716e-09,0.0493263,0.000383962,8.72743e-07,-8.52026e-10,0.0497111,0.000385705,8.70187e-07,2.21092e-09,0.0500977,0.000387452,8.76819e-07,-5.41339e-10,0.050486,0.000389204,8.75195e-07,-4.5361e-11,0.0508761,0.000390954,8.75059e-07,7.22669e-10,0.0512679,0.000392706,8.77227e-07,8.79936e-10,0.0516615,0.000394463,8.79867e-07,-5.17048e-10,0.0520568,0.000396222,8.78316e-07,1.18833e-09,0.0524539,0.000397982,8.81881e-07,-5.11022e-10,0.0528528,0.000399744,8.80348e-07,8.55683e-10,0.0532534,0.000401507,8.82915e-07,8.13562e-10,0.0536558,0.000403276,8.85356e-07,-3.84603e-10,0.05406,0.000405045,8.84202e-07,7.24962e-10,0.0544659,0.000406816,8.86377e-07,1.20986e-09,0.0548736,0.000408592,8.90006e-07,-1.83896e-09,0.0552831,0.000410367,8.84489e-07,2.42071e-09,0.0556944,0.000412143,8.91751e-07,-3.93413e-10,0.0561074,0.000413925,8.90571e-07,-8.46967e-10,0.0565222,0.000415704,8.8803e-07,3.78122e-09,0.0569388,0.000417491,8.99374e-07,-3.1021e-09,0.0573572,0.000419281,8.90068e-07,1.17658e-09,0.0577774,0.000421064,8.93597e-07,2.12117e-09,0.0581993,0.000422858,8.99961e-07,-2.21068e-09,0.0586231,0.000424651,8.93329e-07,2.9961e-09,0.0590486,0.000426447,9.02317e-07,-2.32311e-09,0.059476,0.000428244,8.95348e-07,2.57122e-09,0.0599051,0.000430043,9.03062e-07,-5.11098e-10,0.0603361,0.000431847,9.01528e-07,-5.27166e-10,0.0607688,0.000433649,8.99947e-07,2.61984e-09,0.0612034,0.000435457,9.07806e-07,-2.50141e-09,0.0616397,0.000437265,9.00302e-07,3.66045e-09,0.0620779,0.000439076,9.11283e-07,-4.68977e-09,0.0625179,0.000440885,8.97214e-07,7.64783e-09,0.0629597,0.000442702,9.20158e-07,-7.27499e-09,0.0634033,0.000444521,8.98333e-07,6.55113e-09,0.0638487,0.000446337,9.17986e-07,-4.02844e-09,0.0642959,0.000448161,9.05901e-07,2.11196e-09,0.064745,0.000449979,9.12236e-07,3.03125e-09,0.0651959,0.000451813,9.2133e-07,-6.78648e-09,0.0656486,0.000453635,9.00971e-07,9.21375e-09,0.0661032,0.000455464,9.28612e-07,-7.71684e-09,0.0665596,0.000457299,9.05462e-07,6.7522e-09,0.0670178,0.00045913,9.25718e-07,-4.3907e-09,0.0674778,0.000460968,9.12546e-07,3.36e-09,0.0679397,0.000462803,9.22626e-07,-1.59876e-09,0.0684034,0.000464644,9.1783e-07,3.0351e-09,0.068869,0.000466488,9.26935e-07,-3.09101e-09,0.0693364,0.000468333,9.17662e-07,1.8785e-09,0.0698057,0.000470174,9.23298e-07,3.02733e-09,0.0702768,0.00047203,9.3238e-07,-6.53722e-09,0.0707497,0.000473875,9.12768e-07,8.22054e-09,0.0712245,0.000475725,9.37429e-07,-3.99325e-09,0.0717012,0.000477588,9.2545e-07,3.01839e-10,0.0721797,0.00047944,9.26355e-07,2.78597e-09,0.0726601,0.000481301,9.34713e-07,-3.99507e-09,0.0731423,0.000483158,9.22728e-07,5.7435e-09,0.0736264,0.000485021,9.39958e-07,-4.07776e-09,0.0741123,0.000486888,9.27725e-07,3.11695e-09,0.0746002,0.000488753,9.37076e-07,-9.39394e-10,0.0750898,0.000490625,9.34258e-07,6.4055e-10,0.0755814,0.000492495,9.3618e-07,-1.62265e-09,0.0760748,0.000494363,9.31312e-07,5.84995e-09,0.0765701,0.000496243,9.48861e-07,-6.87601e-09,0.0770673,0.00049812,9.28233e-07,6.75296e-09,0.0775664,0.000499997,9.48492e-07,-5.23467e-09,0.0780673,0.000501878,9.32788e-07,6.73523e-09,0.0785701,0.000503764,9.52994e-07,-6.80514e-09,0.0790748,0.000505649,9.32578e-07,5.5842e-09,0.0795814,0.000507531,9.49331e-07,-6.30583e-10,0.0800899,0.000509428,9.47439e-07,-3.0618e-09,0.0806003,0.000511314,9.38254e-07,5.4273e-09,0.0811125,0.000513206,9.54536e-07,-3.74627e-09,0.0816267,0.000515104,9.43297e-07,2.10713e-09,0.0821427,0.000516997,9.49618e-07,2.76839e-09,0.0826607,0.000518905,9.57924e-07,-5.73006e-09,0.0831805,0.000520803,9.40733e-07,5.25072e-09,0.0837023,0.0005227,9.56486e-07,-3.71718e-10,0.084226,0.000524612,9.5537e-07,-3.76404e-09,0.0847515,0.000526512,9.44078e-07,7.97735e-09,0.085279,0.000528424,9.6801e-07,-5.79367e-09,0.0858084,0.000530343,9.50629e-07,2.96268e-10,0.0863397,0.000532245,9.51518e-07,4.6086e-09,0.0868729,0.000534162,9.65344e-07,-3.82947e-09,0.087408,0.000536081,9.53856e-07,3.25861e-09,0.087945,0.000537998,9.63631e-07,-1.7543e-09,0.088484,0.00053992,9.58368e-07,3.75849e-09,0.0890249,0.000541848,9.69644e-07,-5.82891e-09,0.0895677,0.00054377,9.52157e-07,4.65593e-09,0.0901124,0.000545688,9.66125e-07,2.10643e-09,0.0906591,0.000547627,9.72444e-07,-5.63099e-09,0.0912077,0.000549555,9.55551e-07,5.51627e-09,0.0917582,0.000551483,9.721e-07,-1.53292e-09,0.0923106,0.000553422,9.67501e-07,6.15311e-10,0.092865,0.000555359,9.69347e-07,-9.28291e-10,0.0934213,0.000557295,9.66562e-07,3.09774e-09,0.0939796,0.000559237,9.75856e-07,-4.01186e-09,0.0945398,0.000561177,9.6382e-07,5.49892e-09,0.095102,0.000563121,9.80317e-07,-3.08258e-09,0.0956661,0.000565073,9.71069e-07,-6.19176e-10,0.0962321,0.000567013,9.69212e-07,5.55932e-09,0.0968001,0.000568968,9.8589e-07,-6.71704e-09,0.09737,0.00057092,9.65738e-07,6.40762e-09,0.0979419,0.00057287,9.84961e-07,-4.0122e-09,0.0985158,0.000574828,9.72925e-07,2.19059e-09,0.0990916,0.000576781,9.79496e-07,2.70048e-09,0.0996693,0.000578748,9.87598e-07,-5.54193e-09,0.100249,0.000580706,9.70972e-07,4.56597e-09,0.100831,0.000582662,9.8467e-07,2.17923e-09,0.101414,0.000584638,9.91208e-07,-5.83232e-09,0.102,0.000586603,9.73711e-07,6.24884e-09,0.102588,0.000588569,9.92457e-07,-4.26178e-09,0.103177,0.000590541,9.79672e-07,3.34781e-09,0.103769,0.00059251,9.89715e-07,-1.67904e-09,0.104362,0.000594485,9.84678e-07,3.36839e-09,0.104958,0.000596464,9.94783e-07,-4.34397e-09,0.105555,0.000598441,9.81751e-07,6.55696e-09,0.106155,0.000600424,1.00142e-06,-6.98272e-09,0.106756,0.000602406,9.80474e-07,6.4728e-09,0.107359,0.000604386,9.99893e-07,-4.00742e-09,0.107965,0.000606374,9.8787e-07,2.10654e-09,0.108572,0.000608356,9.9419e-07,3.0318e-09,0.109181,0.000610353,1.00329e-06,-6.7832e-09,0.109793,0.00061234,9.82936e-07,9.1998e-09,0.110406,0.000614333,1.01054e-06,-7.6642e-09,0.111021,0.000616331,9.87543e-07,6.55579e-09,0.111639,0.000618326,1.00721e-06,-3.65791e-09,0.112258,0.000620329,9.96236e-07,6.25467e-10,0.112879,0.000622324,9.98113e-07,1.15593e-09,0.113503,0.000624323,1.00158e-06,2.20158e-09,0.114128,0.000626333,1.00819e-06,-2.51191e-09,0.114755,0.000628342,1.00065e-06,3.95517e-10,0.115385,0.000630345,1.00184e-06,9.29807e-10,0.116016,0.000632351,1.00463e-06,3.33599e-09,0.116649,0.00063437,1.01463e-06,-6.82329e-09,0.117285,0.000636379,9.94163e-07,9.05595e-09,0.117922,0.000638395,1.02133e-06,-7.04862e-09,0.118562,0.000640416,1.00019e-06,4.23737e-09,0.119203,0.000642429,1.0129e-06,-2.45033e-09,0.119847,0.000644448,1.00555e-06,5.56395e-09,0.120492,0.000646475,1.02224e-06,-4.9043e-09,0.121139,0.000648505,1.00753e-06,-8.47952e-10,0.121789,0.000650518,1.00498e-06,8.29622e-09,0.122441,0.000652553,1.02987e-06,-9.98538e-09,0.123094,0.000654582,9.99914e-07,9.2936e-09,0.12375,0.00065661,1.02779e-06,-4.83707e-09,0.124407,0.000658651,1.01328e-06,2.60411e-09,0.125067,0.000660685,1.0211e-06,-5.57945e-09,0.125729,0.000662711,1.00436e-06,1.22631e-08,0.126392,0.000664756,1.04115e-06,-1.36704e-08,0.127058,0.000666798,1.00014e-06,1.26161e-08,0.127726,0.000668836,1.03798e-06,-6.99155e-09,0.128396,0.000670891,1.01701e-06,4.48836e-10,0.129068,0.000672926,1.01836e-06,5.19606e-09,0.129742,0.000674978,1.03394e-06,-6.3319e-09,0.130418,0.000677027,1.01495e-06,5.2305e-09,0.131096,0.000679073,1.03064e-06,3.11123e-10,0.131776,0.000681135,1.03157e-06,-6.47511e-09,0.132458,0.000683179,1.01215e-06,1.06882e-08,0.133142,0.000685235,1.04421e-06,-6.47519e-09,0.133829,0.000687304,1.02479e-06,3.11237e-10,0.134517,0.000689355,1.02572e-06,5.23035e-09,0.135207,0.000691422,1.04141e-06,-6.3316e-09,0.1359,0.000693486,1.02242e-06,5.19484e-09,0.136594,0.000695546,1.038e-06,4.53497e-10,0.137291,0.000697623,1.03936e-06,-7.00891e-09,0.137989,0.000699681,1.01834e-06,1.2681e-08,0.13869,0.000701756,1.05638e-06,-1.39128e-08,0.139393,0.000703827,1.01464e-06,1.31679e-08,0.140098,0.000705896,1.05414e-06,-8.95659e-09,0.140805,0.000707977,1.02727e-06,7.75742e-09,0.141514,0.000710055,1.05055e-06,-7.17182e-09,0.142225,0.000712135,1.02903e-06,6.02862e-09,0.142938,0.000714211,1.04712e-06,-2.04163e-09,0.143653,0.000716299,1.04099e-06,2.13792e-09,0.144371,0.000718387,1.04741e-06,-6.51009e-09,0.14509,0.000720462,1.02787e-06,9.00123e-09,0.145812,0.000722545,1.05488e-06,3.07523e-10,0.146535,0.000724656,1.0558e-06,-1.02312e-08,0.147261,0.000726737,1.02511e-06,1.0815e-08,0.147989,0.000728819,1.05755e-06,-3.22681e-09,0.148719,0.000730925,1.04787e-06,2.09244e-09,0.14945,0.000733027,1.05415e-06,-5.143e-09,0.150185,0.00073512,1.03872e-06,3.57844e-09,0.150921,0.000737208,1.04946e-06,5.73027e-09,0.151659,0.000739324,1.06665e-06,-1.15983e-08,0.152399,0.000741423,1.03185e-06,1.08605e-08,0.153142,0.000743519,1.06443e-06,-2.04106e-09,0.153886,0.000745642,1.05831e-06,-2.69642e-09,0.154633,0.00074775,1.05022e-06,-2.07425e-09,0.155382,0.000749844,1.044e-06,1.09934e-08,0.156133,0.000751965,1.07698e-06,-1.20972e-08,0.156886,0.000754083,1.04069e-06,7.59288e-09,0.157641,0.000756187,1.06347e-06,-3.37305e-09,0.158398,0.000758304,1.05335e-06,5.89921e-09,0.159158,0.000760428,1.07104e-06,-5.32248e-09,0.159919,0.000762554,1.05508e-06,4.8927e-10,0.160683,0.000764666,1.05654e-06,3.36547e-09,0.161448,0.000766789,1.06664e-06,9.50081e-10,0.162216,0.000768925,1.06949e-06,-7.16568e-09,0.162986,0.000771043,1.04799e-06,1.28114e-08,0.163758,0.000773177,1.08643e-06,-1.42774e-08,0.164533,0.000775307,1.0436e-06,1.44956e-08,0.165309,0.000777438,1.08708e-06,-1.39025e-08,0.166087,0.00077957,1.04538e-06,1.13118e-08,0.166868,0.000781695,1.07931e-06,-1.54224e-09,0.167651,0.000783849,1.07468e-06,-5.14312e-09,0.168436,0.000785983,1.05925e-06,7.21381e-09,0.169223,0.000788123,1.0809e-06,-8.81096e-09,0.170012,0.000790259,1.05446e-06,1.31289e-08,0.170803,0.000792407,1.09385e-06,-1.39022e-08,0.171597,0.000794553,1.05214e-06,1.26775e-08,0.172392,0.000796695,1.09018e-06,-7.00557e-09,0.17319,0.000798855,1.06916e-06,4.43796e-10,0.17399,0.000800994,1.07049e-06,5.23031e-09,0.174792,0.000803151,1.08618e-06,-6.46397e-09,0.175596,0.000805304,1.06679e-06,5.72444e-09,0.176403,0.000807455,1.08396e-06,-1.53254e-09,0.177211,0.000809618,1.07937e-06,4.05673e-10,0.178022,0.000811778,1.08058e-06,-9.01916e-11,0.178835,0.000813939,1.08031e-06,-4.49821e-11,0.17965,0.000816099,1.08018e-06,2.70234e-10,0.180467,0.00081826,1.08099e-06,-1.03603e-09,0.181286,0.000820419,1.07788e-06,3.87392e-09,0.182108,0.000822587,1.0895e-06,4.41522e-10,0.182932,0.000824767,1.09083e-06,-5.63997e-09,0.183758,0.000826932,1.07391e-06,7.21707e-09,0.184586,0.000829101,1.09556e-06,-8.32718e-09,0.185416,0.000831267,1.07058e-06,1.11907e-08,0.186248,0.000833442,1.10415e-06,-6.63336e-09,0.187083,0.00083563,1.08425e-06,4.41484e-10,0.187919,0.0008378,1.08557e-06,4.86754e-09,0.188758,0.000839986,1.10017e-06,-5.01041e-09,0.189599,0.000842171,1.08514e-06,2.72811e-10,0.190443,0.000844342,1.08596e-06,3.91916e-09,0.191288,0.000846526,1.09772e-06,-1.04819e-09,0.192136,0.000848718,1.09457e-06,2.73531e-10,0.192985,0.000850908,1.0954e-06,-4.58916e-11,0.193837,0.000853099,1.09526e-06,-9.01158e-11,0.194692,0.000855289,1.09499e-06,4.06506e-10,0.195548,0.00085748,1.09621e-06,-1.53595e-09,0.196407,0.000859668,1.0916e-06,5.73717e-09,0.197267,0.000861869,1.10881e-06,-6.51164e-09,0.19813,0.000864067,1.08928e-06,5.40831e-09,0.198995,0.000866261,1.1055e-06,-2.20401e-10,0.199863,0.000868472,1.10484e-06,-4.52652e-09,0.200732,0.000870668,1.09126e-06,3.42508e-09,0.201604,0.000872861,1.10153e-06,5.72762e-09,0.202478,0.000875081,1.11872e-06,-1.14344e-08,0.203354,0.000877284,1.08441e-06,1.02076e-08,0.204233,0.000879484,1.11504e-06,4.06355e-10,0.205113,0.000881715,1.11626e-06,-1.18329e-08,0.205996,0.000883912,1.08076e-06,1.71227e-08,0.206881,0.000886125,1.13213e-06,-1.19546e-08,0.207768,0.000888353,1.09626e-06,8.93465e-10,0.208658,0.000890548,1.09894e-06,8.38062e-09,0.209549,0.000892771,1.12408e-06,-4.61353e-09,0.210443,0.000895006,1.11024e-06,-4.82756e-09,0.211339,0.000897212,1.09576e-06,9.02245e-09,0.212238,0.00089943,1.12283e-06,-1.45997e-09,0.213138,0.000901672,1.11845e-06,-3.18255e-09,0.214041,0.000903899,1.1089e-06,-7.11073e-10,0.214946,0.000906115,1.10677e-06,6.02692e-09,0.215853,0.000908346,1.12485e-06,-8.49548e-09,0.216763,0.00091057,1.09936e-06,1.30537e-08,0.217675,0.000912808,1.13852e-06,-1.3917e-08,0.218588,0.000915044,1.09677e-06,1.28121e-08,0.219505,0.000917276,1.13521e-06,-7.5288e-09,0.220423,0.000919523,1.11262e-06,2.40205e-09,0.221344,0.000921756,1.11983e-06,-2.07941e-09,0.222267,0.000923989,1.11359e-06,5.91551e-09,0.223192,0.000926234,1.13134e-06,-6.68149e-09,0.224119,0.000928477,1.11129e-06,5.90929e-09,0.225049,0.000930717,1.12902e-06,-2.05436e-09,0.22598,0.000932969,1.12286e-06,2.30807e-09,0.226915,0.000935222,1.12978e-06,-7.17796e-09,0.227851,0.00093746,1.10825e-06,1.15028e-08,0.228789,0.000939711,1.14276e-06,-9.03083e-09,0.22973,0.000941969,1.11566e-06,9.71932e-09,0.230673,0.00094423,1.14482e-06,-1.49452e-08,0.231619,0.000946474,1.09998e-06,2.02591e-08,0.232566,0.000948735,1.16076e-06,-2.13879e-08,0.233516,0.000950993,1.0966e-06,2.05888e-08,0.234468,0.000953247,1.15837e-06,-1.62642e-08,0.235423,0.000955515,1.10957e-06,1.46658e-08,0.236379,0.000957779,1.15357e-06,-1.25966e-08,0.237338,0.000960048,1.11578e-06,5.91793e-09,0.238299,0.000962297,1.13353e-06,3.82602e-09,0.239263,0.000964576,1.14501e-06,-6.3208e-09,0.240229,0.000966847,1.12605e-06,6.55613e-09,0.241197,0.000969119,1.14572e-06,-5.00268e-09,0.242167,0.000971395,1.13071e-06,-1.44659e-09,0.243139,0.000973652,1.12637e-06,1.07891e-08,0.244114,0.000975937,1.15874e-06,-1.19073e-08,0.245091,0.000978219,1.12302e-06,7.03782e-09,0.246071,0.000980486,1.14413e-06,-1.34276e-09,0.247052,0.00098277,1.1401e-06,-1.66669e-09,0.248036,0.000985046,1.1351e-06,8.00935e-09,0.249022,0.00098734,1.15913e-06,-1.54694e-08,0.250011,0.000989612,1.11272e-06,2.4066e-08,0.251002,0.000991909,1.18492e-06,-2.11901e-08,0.251995,0.000994215,1.12135e-06,1.08973e-09,0.25299,0.000996461,1.12462e-06,1.68311e-08,0.253988,0.000998761,1.17511e-06,-8.8094e-09,0.254987,0.00100109,1.14868e-06,-1.13958e-08,0.25599,0.00100335,1.1145e-06,2.45902e-08,0.256994,0.00100565,1.18827e-06,-2.73603e-08,0.258001,0.00100795,1.10618e-06,2.52464e-08,0.25901,0.00101023,1.18192e-06,-1.40207e-08,0.260021,0.00101256,1.13986e-06,1.03387e-09,0.261035,0.00101484,1.14296e-06,9.8853e-09,0.262051,0.00101715,1.17262e-06,-1.07726e-08,0.263069,0.00101947,1.1403e-06,3.40272e-09,0.26409,0.00102176,1.15051e-06,-2.83827e-09,0.265113,0.00102405,1.142e-06,7.95039e-09,0.266138,0.00102636,1.16585e-06,8.39047e-10,0.267166,0.00102869,1.16836e-06,-1.13066e-08,0.268196,0.00103099,1.13444e-06,1.4585e-08,0.269228,0.00103331,1.1782e-06,-1.72314e-08,0.270262,0.00103561,1.1265e-06,2.45382e-08,0.271299,0.00103794,1.20012e-06,-2.13166e-08,0.272338,0.00104028,1.13617e-06,1.12364e-09,0.273379,0.00104255,1.13954e-06,1.68221e-08,0.274423,0.00104488,1.19001e-06,-8.80736e-09,0.275469,0.00104723,1.16358e-06,-1.13948e-08,0.276518,0.00104953,1.1294e-06,2.45839e-08,0.277568,0.00105186,1.20315e-06,-2.73361e-08,0.278621,0.00105418,1.12114e-06,2.51559e-08,0.279677,0.0010565,1.19661e-06,-1.36832e-08,0.280734,0.00105885,1.15556e-06,-2.25706e-10,0.281794,0.00106116,1.15488e-06,1.45862e-08,0.282857,0.00106352,1.19864e-06,-2.83167e-08,0.283921,0.00106583,1.11369e-06,3.90759e-08,0.284988,0.00106817,1.23092e-06,-3.85801e-08,0.286058,0.00107052,1.11518e-06,2.58375e-08,0.287129,0.00107283,1.19269e-06,-5.16498e-09,0.288203,0.0010752,1.1772e-06,-5.17768e-09,0.28928,0.00107754,1.16167e-06,-3.92671e-09,0.290358,0.00107985,1.14988e-06,2.08846e-08,0.29144,0.00108221,1.21254e-06,-2.00072e-08,0.292523,0.00108458,1.15252e-06,-4.60659e-10,0.293609,0.00108688,1.15114e-06,2.18499e-08,0.294697,0.00108925,1.21669e-06,-2.73343e-08,0.295787,0.0010916,1.13468e-06,2.78826e-08,0.29688,0.00109395,1.21833e-06,-2.45915e-08,0.297975,0.00109632,1.14456e-06,1.08787e-08,0.299073,0.00109864,1.17719e-06,1.08788e-08,0.300172,0.00110102,1.20983e-06,-2.45915e-08,0.301275,0.00110337,1.13605e-06,2.78828e-08,0.302379,0.00110573,1.2197e-06,-2.73348e-08,0.303486,0.00110808,1.1377e-06,2.18518e-08,0.304595,0.00111042,1.20325e-06,-4.67556e-10,0.305707,0.00111283,1.20185e-06,-1.99816e-08,0.306821,0.00111517,1.14191e-06,2.07891e-08,0.307937,0.00111752,1.20427e-06,-3.57026e-09,0.309056,0.00111992,1.19356e-06,-6.50797e-09,0.310177,0.00112228,1.17404e-06,-2.00165e-10,0.3113,0.00112463,1.17344e-06,7.30874e-09,0.312426,0.001127,1.19536e-06,7.67424e-10,0.313554,0.00112939,1.19767e-06,-1.03784e-08,0.314685,0.00113176,1.16653e-06,1.09437e-08,0.315818,0.00113412,1.19936e-06,-3.59406e-09,0.316953,0.00113651,1.18858e-06,3.43251e-09,0.318091,0.0011389,1.19888e-06,-1.0136e-08,0.319231,0.00114127,1.16847e-06,7.30915e-09,0.320374,0.00114363,1.1904e-06,1.07018e-08,0.321518,0.00114604,1.2225e-06,-2.03137e-08,0.322666,0.00114842,1.16156e-06,1.09484e-08,0.323815,0.00115078,1.19441e-06,6.32224e-09,0.324967,0.00115319,1.21337e-06,-6.43509e-09,0.326122,0.00115559,1.19407e-06,-1.03842e-08,0.327278,0.00115795,1.16291e-06,1.81697e-08,0.328438,0.00116033,1.21742e-06,-2.6901e-09,0.329599,0.00116276,1.20935e-06,-7.40939e-09,0.330763,0.00116515,1.18713e-06,2.52533e-09,0.331929,0.00116754,1.1947e-06,-2.69191e-09,0.333098,0.00116992,1.18663e-06,8.24218e-09,0.334269,0.00117232,1.21135e-06,-4.74377e-10,0.335443,0.00117474,1.20993e-06,-6.34471e-09,0.336619,0.00117714,1.1909e-06,-3.94922e-09,0.337797,0.00117951,1.17905e-06,2.21417e-08,0.338978,0.00118193,1.24547e-06,-2.50128e-08,0.340161,0.00118435,1.17043e-06,1.8305e-08,0.341346,0.00118674,1.22535e-06,-1.84048e-08,0.342534,0.00118914,1.17013e-06,2.55121e-08,0.343725,0.00119156,1.24667e-06,-2.40389e-08,0.344917,0.00119398,1.17455e-06,1.10389e-08,0.346113,0.00119636,1.20767e-06,9.68574e-09,0.34731,0.0011988,1.23673e-06,-1.99797e-08,0.34851,0.00120122,1.17679e-06,1.06284e-08,0.349713,0.0012036,1.20867e-06,7.26868e-09,0.350917,0.00120604,1.23048e-06,-9.90072e-09,0.352125,0.00120847,1.20078e-06,2.53177e-09,0.353334,0.00121088,1.20837e-06,-2.26199e-10,0.354546,0.0012133,1.20769e-06,-1.62705e-09,0.355761,0.00121571,1.20281e-06,6.73435e-09,0.356978,0.00121813,1.22302e-06,4.49207e-09,0.358197,0.00122059,1.23649e-06,-2.47027e-08,0.359419,0.00122299,1.16238e-06,3.47142e-08,0.360643,0.00122542,1.26653e-06,-2.47472e-08,0.36187,0.00122788,1.19229e-06,4.66965e-09,0.363099,0.00123028,1.20629e-06,6.06872e-09,0.36433,0.00123271,1.2245e-06,8.57729e-10,0.365564,0.00123516,1.22707e-06,-9.49952e-09,0.366801,0.00123759,1.19858e-06,7.33792e-09,0.36804,0.00124001,1.22059e-06,9.95025e-09,0.369281,0.00124248,1.25044e-06,-1.73366e-08,0.370525,0.00124493,1.19843e-06,-2.08464e-10,0.371771,0.00124732,1.1978e-06,1.81704e-08,0.373019,0.00124977,1.25232e-06,-1.28683e-08,0.37427,0.00125224,1.21371e-06,3.50042e-09,0.375524,0.00125468,1.22421e-06,-1.1335e-09,0.37678,0.00125712,1.22081e-06,1.03345e-09,0.378038,0.00125957,1.22391e-06,-3.00023e-09,0.379299,0.00126201,1.21491e-06,1.09676e-08,0.380562,0.00126447,1.24781e-06,-1.10676e-08,0.381828,0.00126693,1.21461e-06,3.50042e-09,0.383096,0.00126937,1.22511e-06,-2.93403e-09,0.384366,0.00127181,1.21631e-06,8.23574e-09,0.385639,0.00127427,1.24102e-06,-2.06607e-10,0.386915,0.00127675,1.2404e-06,-7.40935e-09,0.388193,0.00127921,1.21817e-06,4.1761e-11,0.389473,0.00128165,1.21829e-06,7.24223e-09,0.390756,0.0012841,1.24002e-06,7.91564e-10,0.392042,0.00128659,1.2424e-06,-1.04086e-08,0.393329,0.00128904,1.21117e-06,1.10405e-08,0.39462,0.0012915,1.24429e-06,-3.951e-09,0.395912,0.00129397,1.23244e-06,4.7634e-09,0.397208,0.00129645,1.24673e-06,-1.51025e-08,0.398505,0.0012989,1.20142e-06,2.58443e-08,0.399805,0.00130138,1.27895e-06,-2.86702e-08,0.401108,0.00130385,1.19294e-06,2.92318e-08,0.402413,0.00130632,1.28064e-06,-2.86524e-08,0.403721,0.0013088,1.19468e-06,2.57731e-08,0.405031,0.00131127,1.272e-06,-1.48355e-08,0.406343,0.00131377,1.2275e-06,3.76652e-09,0.407658,0.00131623,1.23879e-06,-2.30784e-10,0.408976,0.00131871,1.2381e-06,-2.84331e-09,0.410296,0.00132118,1.22957e-06,1.16041e-08,0.411618,0.00132367,1.26438e-06,-1.37708e-08,0.412943,0.00132616,1.22307e-06,1.36768e-08,0.41427,0.00132865,1.2641e-06,-1.1134e-08,0.4156,0.00133114,1.2307e-06,1.05714e-09,0.416933,0.00133361,1.23387e-06,6.90538e-09,0.418267,0.00133609,1.25459e-06,1.12372e-09,0.419605,0.00133861,1.25796e-06,-1.14002e-08,0.420945,0.00134109,1.22376e-06,1.46747e-08,0.422287,0.00134358,1.26778e-06,-1.7496e-08,0.423632,0.00134606,1.21529e-06,2.5507e-08,0.424979,0.00134857,1.29182e-06,-2.49272e-08,0.426329,0.00135108,1.21703e-06,1.45972e-08,0.427681,0.00135356,1.26083e-06,-3.65935e-09,0.429036,0.00135607,1.24985e-06,4.00178e-11,0.430393,0.00135857,1.24997e-06,3.49917e-09,0.431753,0.00136108,1.26047e-06,-1.40366e-08,0.433116,0.00136356,1.21836e-06,2.28448e-08,0.43448,0.00136606,1.28689e-06,-1.77378e-08,0.435848,0.00136858,1.23368e-06,1.83043e-08,0.437218,0.0013711,1.28859e-06,-2.56769e-08,0.43859,0.0013736,1.21156e-06,2.47987e-08,0.439965,0.0013761,1.28595e-06,-1.39133e-08,0.441342,0.00137863,1.24421e-06,1.05202e-09,0.442722,0.00138112,1.24737e-06,9.70507e-09,0.444104,0.00138365,1.27649e-06,-1.00698e-08,0.445489,0.00138617,1.24628e-06,7.72123e-10,0.446877,0.00138867,1.24859e-06,6.98132e-09,0.448267,0.00139118,1.26954e-06,1.10477e-09,0.449659,0.00139373,1.27285e-06,-1.14003e-08,0.451054,0.00139624,1.23865e-06,1.4694e-08,0.452452,0.00139876,1.28273e-06,-1.75734e-08,0.453852,0.00140127,1.23001e-06,2.5797e-08,0.455254,0.00140381,1.3074e-06,-2.60097e-08,0.456659,0.00140635,1.22937e-06,1.86371e-08,0.458067,0.00140886,1.28529e-06,-1.8736e-08,0.459477,0.00141137,1.22908e-06,2.65048e-08,0.46089,0.00141391,1.30859e-06,-2.76784e-08,0.462305,0.00141645,1.22556e-06,2.46043e-08,0.463722,0.00141897,1.29937e-06,-1.11341e-08,0.465143,0.00142154,1.26597e-06,-9.87033e-09,0.466565,0.00142404,1.23636e-06,2.08131e-08,0.467991,0.00142657,1.2988e-06,-1.37773e-08,0.469419,0.00142913,1.25746e-06,4.49378e-09,0.470849,0.00143166,1.27094e-06,-4.19781e-09,0.472282,0.00143419,1.25835e-06,1.22975e-08,0.473717,0.00143674,1.29524e-06,-1.51902e-08,0.475155,0.00143929,1.24967e-06,1.86608e-08,0.476596,0.00144184,1.30566e-06,-2.96506e-08,0.478039,0.00144436,1.2167e-06,4.03368e-08,0.479485,0.00144692,1.33771e-06,-4.22896e-08,0.480933,0.00144947,1.21085e-06,3.94148e-08,0.482384,0.00145201,1.32909e-06,-2.59626e-08,0.483837,0.00145459,1.2512e-06,4.83124e-09,0.485293,0.0014571,1.2657e-06,6.63757e-09,0.486751,0.00145966,1.28561e-06,-1.57911e-09,0.488212,0.00146222,1.28087e-06,-3.21468e-10,0.489676,0.00146478,1.27991e-06,2.86517e-09,0.491142,0.00146735,1.2885e-06,-1.11392e-08,0.49261,0.00146989,1.25508e-06,1.18893e-08,0.494081,0.00147244,1.29075e-06,-6.61574e-09,0.495555,0.001475,1.27091e-06,1.45736e-08,0.497031,0.00147759,1.31463e-06,-2.18759e-08,0.49851,0.00148015,1.249e-06,1.33252e-08,0.499992,0.00148269,1.28897e-06,-1.62277e-09,0.501476,0.00148526,1.28411e-06,-6.83421e-09,0.502962,0.00148781,1.2636e-06,2.89596e-08,0.504451,0.00149042,1.35048e-06,-4.93997e-08,0.505943,0.00149298,1.20228e-06,4.94299e-08,0.507437,0.00149553,1.35057e-06,-2.91107e-08,0.508934,0.00149814,1.26324e-06,7.40848e-09,0.510434,0.00150069,1.28547e-06,-5.23187e-10,0.511936,0.00150326,1.2839e-06,-5.31585e-09,0.51344,0.00150581,1.26795e-06,2.17866e-08,0.514947,0.00150841,1.33331e-06,-2.22257e-08,0.516457,0.00151101,1.26663e-06,7.51178e-09,0.517969,0.00151357,1.28917e-06,-7.82128e-09,0.519484,0.00151613,1.2657e-06,2.37733e-08,0.521002,0.00151873,1.33702e-06,-2.76674e-08,0.522522,0.00152132,1.25402e-06,2.72917e-08,0.524044,0.00152391,1.3359e-06,-2.18949e-08,0.525569,0.00152652,1.27021e-06,6.83372e-10,0.527097,0.00152906,1.27226e-06,1.91613e-08,0.528628,0.00153166,1.32974e-06,-1.77241e-08,0.53016,0.00153427,1.27657e-06,-7.86963e-09,0.531696,0.0015368,1.25296e-06,4.92027e-08,0.533234,0.00153945,1.40057e-06,-6.9732e-08,0.534775,0.00154204,1.19138e-06,5.09114e-08,0.536318,0.00154458,1.34411e-06,-1.4704e-08,0.537864,0.00154722,1.3e-06,7.9048e-09,0.539413,0.00154984,1.32371e-06,-1.69152e-08,0.540964,0.00155244,1.27297e-06,1.51355e-10,0.542517,0.00155499,1.27342e-06,1.63099e-08,0.544074,0.00155758,1.32235e-06,-5.78647e-09,0.545633,0.00156021,1.30499e-06,6.83599e-09,0.547194,0.00156284,1.3255e-06,-2.15575e-08,0.548758,0.00156543,1.26083e-06,1.97892e-08,0.550325,0.00156801,1.32019e-06,2.00525e-09,0.551894,0.00157065,1.32621e-06,-2.78103e-08,0.553466,0.00157322,1.24278e-06,4.96314e-08,0.555041,0.00157586,1.39167e-06,-5.1506e-08,0.556618,0.00157849,1.23716e-06,3.71835e-08,0.558198,0.00158107,1.34871e-06,-3.76233e-08,0.55978,0.00158366,1.23584e-06,5.37052e-08,0.561365,0.00158629,1.39695e-06,-5.79884e-08,0.562953,0.00158891,1.22299e-06,5.90392e-08,0.564543,0.00159153,1.4001e-06,-5.89592e-08,0.566136,0.00159416,1.22323e-06,5.7588e-08,0.567731,0.00159678,1.39599e-06,-5.21835e-08,0.569329,0.00159941,1.23944e-06,3.19369e-08,0.57093,0.00160199,1.33525e-06,-1.59594e-08,0.572533,0.00160461,1.28737e-06,3.19006e-08,0.574139,0.00160728,1.38307e-06,-5.20383e-08,0.575748,0.00160989,1.22696e-06,5.70431e-08,0.577359,0.00161251,1.39809e-06,-5.69247e-08,0.578973,0.00161514,1.22731e-06,5.14463e-08,0.580589,0.00161775,1.38165e-06,-2.9651e-08,0.582208,0.00162042,1.2927e-06,7.55339e-09,0.58383,0.00162303,1.31536e-06,-5.62636e-10,0.585455,0.00162566,1.31367e-06,-5.30281e-09,0.587081,0.00162827,1.29776e-06,2.17738e-08,0.588711,0.00163093,1.36309e-06,-2.21875e-08,0.590343,0.00163359,1.29652e-06,7.37164e-09,0.591978,0.00163621,1.31864e-06,-7.29907e-09,0.593616,0.00163882,1.29674e-06,2.18247e-08,0.595256,0.00164148,1.36221e-06,-2.03952e-08,0.596899,0.00164414,1.30103e-06,1.51241e-10,0.598544,0.00164675,1.30148e-06,1.97902e-08,0.600192,0.00164941,1.36085e-06,-1.97074e-08,0.601843,0.00165207,1.30173e-06,-5.65175e-10,0.603496,0.00165467,1.30004e-06,2.1968e-08,0.605152,0.00165734,1.36594e-06,-2.77024e-08,0.606811,0.00165999,1.28283e-06,2.92369e-08,0.608472,0.00166264,1.37054e-06,-2.96407e-08,0.610136,0.00166529,1.28162e-06,2.97215e-08,0.611803,0.00166795,1.37079e-06,-2.96408e-08,0.613472,0.0016706,1.28186e-06,2.92371e-08,0.615144,0.00167325,1.36957e-06,-2.77031e-08,0.616819,0.00167591,1.28647e-06,2.19708e-08,0.618496,0.00167855,1.35238e-06,-5.75407e-10,0.620176,0.00168125,1.35065e-06,-1.9669e-08,0.621858,0.00168389,1.29164e-06,1.96468e-08,0.623544,0.00168653,1.35058e-06,6.86403e-10,0.625232,0.00168924,1.35264e-06,-2.23924e-08,0.626922,0.00169187,1.28547e-06,2.92788e-08,0.628615,0.00169453,1.3733e-06,-3.51181e-08,0.630311,0.00169717,1.26795e-06,5.15889e-08,0.63201,0.00169987,1.42272e-06,-5.2028e-08,0.633711,0.00170255,1.26663e-06,3.73139e-08,0.635415,0.0017052,1.37857e-06,-3.76227e-08,0.637121,0.00170784,1.2657e-06,5.35722e-08,0.63883,0.00171054,1.42642e-06,-5.74567e-08,0.640542,0.00171322,1.25405e-06,5.70456e-08,0.642257,0.0017159,1.42519e-06,-5.15163e-08,0.643974,0.00171859,1.27064e-06,2.98103e-08,0.645694,0.00172122,1.36007e-06,-8.12016e-09,0.647417,0.00172392,1.33571e-06,2.67039e-09,0.649142,0.0017266,1.34372e-06,-2.56152e-09,0.65087,0.00172928,1.33604e-06,7.57571e-09,0.6526,0.00173197,1.35876e-06,-2.77413e-08,0.654334,0.00173461,1.27554e-06,4.3785e-08,0.65607,0.00173729,1.40689e-06,-2.81896e-08,0.657808,0.00174002,1.32233e-06,9.36893e-09,0.65955,0.00174269,1.35043e-06,-9.28617e-09,0.661294,0.00174536,1.32257e-06,2.77757e-08,0.66304,0.00174809,1.4059e-06,-4.2212e-08,0.66479,0.00175078,1.27926e-06,2.1863e-08,0.666542,0.0017534,1.34485e-06,1.43648e-08,0.668297,0.00175613,1.38795e-06,-1.97177e-08,0.670054,0.00175885,1.3288e-06,4.90115e-09,0.671814,0.00176152,1.3435e-06,1.13232e-10,0.673577,0.00176421,1.34384e-06,-5.3542e-09,0.675343,0.00176688,1.32778e-06,2.13035e-08,0.677111,0.0017696,1.39169e-06,-2.02553e-08,0.678882,0.00177232,1.33092e-06,1.13005e-10,0.680656,0.00177499,1.33126e-06,1.98031e-08,0.682432,0.00177771,1.39067e-06,-1.97211e-08,0.684211,0.00178043,1.33151e-06,-5.2349e-10,0.685993,0.00178309,1.32994e-06,2.18151e-08,0.687777,0.00178582,1.39538e-06,-2.71325e-08,0.689564,0.00178853,1.31398e-06,2.71101e-08,0.691354,0.00179124,1.39531e-06,-2.17035e-08,0.693147,0.00179396,1.3302e-06,9.92865e-11,0.694942,0.00179662,1.3305e-06,2.13063e-08,0.69674,0.00179935,1.39442e-06,-2.57198e-08,0.698541,0.00180206,1.31726e-06,2.19682e-08,0.700344,0.00180476,1.38317e-06,-2.54852e-09,0.70215,0.00180752,1.37552e-06,-1.17741e-08,0.703959,0.00181023,1.3402e-06,-9.95999e-09,0.705771,0.00181288,1.31032e-06,5.16141e-08,0.707585,0.00181566,1.46516e-06,-7.72869e-08,0.709402,0.00181836,1.2333e-06,7.87197e-08,0.711222,0.00182106,1.46946e-06,-5.87781e-08,0.713044,0.00182382,1.29312e-06,3.71834e-08,0.714869,0.00182652,1.40467e-06,-3.03511e-08,0.716697,0.00182924,1.31362e-06,2.46161e-08,0.718528,0.00183194,1.38747e-06,-8.5087e-09,0.720361,0.00183469,1.36194e-06,9.41892e-09,0.722197,0.00183744,1.3902e-06,-2.91671e-08,0.724036,0.00184014,1.3027e-06,4.76448e-08,0.725878,0.00184288,1.44563e-06,-4.22028e-08,0.727722,0.00184565,1.31902e-06,1.95682e-09,0.729569,0.00184829,1.3249e-06,3.43754e-08,0.731419,0.00185104,1.42802e-06,-2.0249e-08,0.733271,0.00185384,1.36727e-06,-1.29838e-08,0.735126,0.00185654,1.32832e-06,1.25794e-08,0.736984,0.00185923,1.36606e-06,2.22711e-08,0.738845,0.00186203,1.43287e-06,-4.20594e-08,0.740708,0.00186477,1.3067e-06,2.67571e-08,0.742574,0.00186746,1.38697e-06,-5.36424e-09,0.744443,0.00187022,1.37087e-06,-5.30023e-09,0.746315,0.00187295,1.35497e-06,2.65653e-08,0.748189,0.00187574,1.43467e-06,-4.13564e-08,0.750066,0.00187848,1.3106e-06,1.9651e-08,0.751946,0.00188116,1.36955e-06,2.23572e-08,0.753828,0.00188397,1.43663e-06,-4.9475e-08,0.755714,0.00188669,1.2882e-06,5.63335e-08,0.757602,0.00188944,1.4572e-06,-5.66499e-08,0.759493,0.00189218,1.28725e-06,5.10567e-08,0.761386,0.00189491,1.44042e-06,-2.83677e-08,0.763283,0.00189771,1.35532e-06,2.80962e-09,0.765182,0.00190042,1.36375e-06,1.71293e-08,0.767083,0.0019032,1.41513e-06,-1.17221e-08,0.768988,0.001906,1.37997e-06,-2.98453e-08,0.770895,0.00190867,1.29043e-06,7.14987e-08,0.772805,0.00191146,1.50493e-06,-7.73354e-08,0.774718,0.00191424,1.27292e-06,5.90292e-08,0.776634,0.00191697,1.45001e-06,-3.9572e-08,0.778552,0.00191975,1.33129e-06,3.9654e-08,0.780473,0.00192253,1.45026e-06,-5.94395e-08,0.782397,0.00192525,1.27194e-06,7.88945e-08,0.784324,0.00192803,1.50862e-06,-7.73249e-08,0.786253,0.00193082,1.27665e-06,5.15913e-08,0.788185,0.00193352,1.43142e-06,-9.83099e-09,0.79012,0.00193636,1.40193e-06,-1.22672e-08,0.792058,0.00193912,1.36513e-06,-7.05275e-10,0.793999,0.00194185,1.36301e-06,1.50883e-08,0.795942,0.00194462,1.40828e-06,-4.33147e-11,0.797888,0.00194744,1.40815e-06,-1.49151e-08,0.799837,0.00195021,1.3634e-06,9.93244e-11,0.801788,0.00195294,1.3637e-06,1.45179e-08,0.803743,0.00195571,1.40725e-06,1.43363e-09,0.8057,0.00195853,1.41155e-06,-2.02525e-08,0.80766,0.00196129,1.35079e-06,1.99718e-08,0.809622,0.00196405,1.41071e-06,-3.01649e-11,0.811588,0.00196687,1.41062e-06,-1.9851e-08,0.813556,0.00196964,1.35107e-06,1.98296e-08,0.815527,0.0019724,1.41056e-06,1.37485e-10,0.817501,0.00197522,1.41097e-06,-2.03796e-08,0.819477,0.00197798,1.34983e-06,2.17763e-08,0.821457,0.00198074,1.41516e-06,-7.12085e-09,0.823439,0.00198355,1.3938e-06,6.70707e-09,0.825424,0.00198636,1.41392e-06,-1.97074e-08,0.827412,0.00198913,1.35479e-06,1.25179e-08,0.829402,0.00199188,1.39235e-06,2.92405e-08,0.831396,0.00199475,1.48007e-06,-6.98755e-08,0.833392,0.0019975,1.27044e-06,7.14477e-08,0.835391,0.00200026,1.48479e-06,-3.71014e-08,0.837392,0.00200311,1.37348e-06,1.73533e-08,0.839397,0.00200591,1.42554e-06,-3.23118e-08,0.841404,0.00200867,1.32861e-06,5.2289e-08,0.843414,0.00201148,1.48547e-06,-5.76348e-08,0.845427,0.00201428,1.31257e-06,5.9041e-08,0.847443,0.00201708,1.48969e-06,-5.93197e-08,0.849461,0.00201988,1.31173e-06,5.90289e-08,0.851482,0.00202268,1.48882e-06,-5.75864e-08,0.853507,0.00202549,1.31606e-06,5.21075e-08,0.855533,0.00202828,1.47238e-06,-3.16344e-08,0.857563,0.00203113,1.37748e-06,1.48257e-08,0.859596,0.00203393,1.42196e-06,-2.76684e-08,0.861631,0.00203669,1.33895e-06,3.62433e-08,0.863669,0.00203947,1.44768e-06,1.90463e-09,0.86571,0.00204237,1.45339e-06,-4.38617e-08,0.867754,0.00204515,1.32181e-06,5.43328e-08,0.8698,0.00204796,1.48481e-06,-5.42603e-08,0.87185,0.00205076,1.32203e-06,4.34989e-08,0.873902,0.00205354,1.45252e-06,-5.26029e-10,0.875957,0.00205644,1.45095e-06,-4.13949e-08,0.878015,0.00205922,1.32676e-06,4.68962e-08,0.880075,0.00206201,1.46745e-06,-2.69807e-08,0.882139,0.00206487,1.38651e-06,1.42181e-09,0.884205,0.00206764,1.39077e-06,2.12935e-08,0.886274,0.00207049,1.45465e-06,-2.69912e-08,0.888346,0.00207332,1.37368e-06,2.70664e-08,0.890421,0.00207615,1.45488e-06,-2.16698e-08,0.892498,0.00207899,1.38987e-06,8.14756e-12,0.894579,0.00208177,1.38989e-06,2.16371e-08,0.896662,0.00208462,1.45481e-06,-2.6952e-08,0.898748,0.00208744,1.37395e-06,2.65663e-08,0.900837,0.00209027,1.45365e-06,-1.97084e-08,0.902928,0.00209312,1.39452e-06,-7.33731e-09,0.905023,0.00209589,1.37251e-06,4.90578e-08,0.90712,0.00209878,1.51968e-06,-6.96845e-08,0.90922,0.00210161,1.31063e-06,5.08664e-08,0.911323,0.00210438,1.46323e-06,-1.45717e-08,0.913429,0.00210727,1.41952e-06,7.42038e-09,0.915538,0.00211013,1.44178e-06,-1.51097e-08,0.917649,0.00211297,1.39645e-06,-6.58618e-09,0.919764,0.00211574,1.37669e-06,4.14545e-08,0.921881,0.00211862,1.50105e-06,-4.00222e-08,0.924001,0.0021215,1.38099e-06,-5.7518e-10,0.926124,0.00212426,1.37926e-06,4.23229e-08,0.92825,0.00212714,1.50623e-06,-4.9507e-08,0.930378,0.00213001,1.35771e-06,3.64958e-08,0.93251,0.00213283,1.4672e-06,-3.68713e-08,0.934644,0.00213566,1.35658e-06,5.13848e-08,0.936781,0.00213852,1.51074e-06,-4.94585e-08,0.938921,0.0021414,1.36236e-06,2.72399e-08,0.941064,0.0021442,1.44408e-06,1.0372e-10,0.943209,0.00214709,1.44439e-06,-2.76547e-08,0.945358,0.0021499,1.36143e-06,5.09106e-08,0.947509,0.00215277,1.51416e-06,-5.67784e-08,0.949663,0.00215563,1.34382e-06,5.69935e-08,0.95182,0.00215849,1.5148e-06,-5.19861e-08,0.95398,0.00216136,1.35885e-06,3.17417e-08,0.956143,0.00216418,1.45407e-06,-1.53758e-08,0.958309,0.00216704,1.40794e-06,2.97615e-08,0.960477,0.00216994,1.49723e-06,-4.40657e-08,0.962649,0.00217281,1.36503e-06,2.72919e-08,0.964823,0.00217562,1.44691e-06,-5.49729e-09,0.967,0.0021785,1.43041e-06,-5.30273e-09,0.96918,0.00218134,1.41451e-06,2.67084e-08,0.971363,0.00218425,1.49463e-06,-4.19265e-08,0.973548,0.00218711,1.36885e-06,2.17881e-08,0.975737,0.00218992,1.43422e-06,1.43789e-08,0.977928,0.00219283,1.47735e-06,-1.96989e-08,0.980122,0.00219572,1.41826e-06,4.81221e-09,0.98232,0.00219857,1.43269e-06,4.50048e-10,0.98452,0.00220144,1.43404e-06,-6.61237e-09,0.986722,0.00220429,1.41421e-06,2.59993e-08,0.988928,0.0022072,1.4922e-06,-3.77803e-08,0.991137,0.00221007,1.37886e-06,5.9127e-09,0.993348,0.00221284,1.3966e-06,1.33339e-07,0.995563,0.00221604,1.79662e-06,-5.98872e-07,0.99778,0.00222015,0.,0.}; __device__ static int LabCbrt_b(int i) { float x = i * (1.f / (255.f * (1 << gamma_shift))); return (1 << lab_shift2) * (x < 0.008856f ? x * 7.787f + 0.13793103448275862f : ::cbrtf(x)); } __device__ static float splineInterpolate(float x, const float* tab, int n) { int ix = ::min(::max(int(x), 0), n-1); x -= ix; tab += ix * 4; return ((tab[3] * x + tab[2]) * x + tab[1]) * x + tab[0]; } template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int Lscale = (116 * 255 + 50) / 100; const int Lshift = -((16 * 255 * (1 << lab_shift2) + 50) / 100); int B = blueIdx == 0 ? src.x : src.z; int G = src.y; int R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = c_sRGBGammaTab_b[B]; G = c_sRGBGammaTab_b[G]; R = c_sRGBGammaTab_b[R]; } else { B <<= 3; G <<= 3; R <<= 3; } int fX = LabCbrt_b(CV_CUDEV_DESCALE(B * 778 + G * 1541 + R * 1777, lab_shift)); int fY = LabCbrt_b(CV_CUDEV_DESCALE(B * 296 + G * 2929 + R * 871, lab_shift)); int fZ = LabCbrt_b(CV_CUDEV_DESCALE(B * 3575 + G * 448 + R * 73, lab_shift)); int L = CV_CUDEV_DESCALE(Lscale * fY + Lshift, lab_shift2); int a = CV_CUDEV_DESCALE(500 * (fX - fY) + 128 * (1 << lab_shift2), lab_shift2); int b = CV_CUDEV_DESCALE(200 * (fY - fZ) + 128 * (1 << lab_shift2), lab_shift2); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(L); dst.y = saturate_cast<uchar>(a); dst.z = saturate_cast<uchar>(b); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _1_3 = 1.0f / 3.0f; const float _a = 16.0f / 116.0f; float B = blueIdx == 0 ? src.x : src.z; float G = src.y; float R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); } float X = B * 0.189828f + G * 0.376219f + R * 0.433953f; float Y = B * 0.072169f + G * 0.715160f + R * 0.212671f; float Z = B * 0.872766f + G * 0.109477f + R * 0.017758f; float FX = X > 0.008856f ? ::powf(X, _1_3) : (7.787f * X + _a); float FY = Y > 0.008856f ? ::powf(Y, _1_3) : (7.787f * Y + _a); float FZ = Z > 0.008856f ? ::powf(Z, _1_3) : (7.787f * Z + _a); float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); float a = 500.f * (FX - FY); float b = 200.f * (FY - FZ); typename MakeVec<float, dcn>::type dst; dst.x = L; dst.y = a; dst.z = b; return dst; } }; // Lab to RGB static __constant__ float c_sRGBInvGammaTab[] = {0,0.0126255,0.,-8.33961e-06,0.0126172,0.0126005,-2.50188e-05,4.1698e-05,0.0252344,0.0126756,0.000100075,-0.000158451,0.0378516,0.0124004,-0.000375277,-0.000207393,0.0496693,0.0110276,-0.000997456,0.00016837,0.0598678,0.00953783,-0.000492346,2.07235e-05,0.068934,0.00861531,-0.000430176,3.62876e-05,0.0771554,0.00786382,-0.000321313,1.87625e-05,0.0847167,0.00727748,-0.000265025,1.53594e-05,0.0917445,0.00679351,-0.000218947,1.10545e-05,0.0983301,0.00638877,-0.000185784,8.66984e-06,0.104542,0.00604322,-0.000159774,6.82996e-06,0.110432,0.00574416,-0.000139284,5.51008e-06,0.116042,0.00548212,-0.000122754,4.52322e-06,0.121406,0.00525018,-0.000109184,3.75557e-06,0.126551,0.00504308,-9.79177e-05,3.17134e-06,0.131499,0.00485676,-8.84037e-05,2.68469e-06,0.13627,0.004688,-8.03496e-05,2.31725e-06,0.14088,0.00453426,-7.33978e-05,2.00868e-06,0.145343,0.00439349,-6.73718e-05,1.74775e-06,0.149671,0.00426399,-6.21286e-05,1.53547e-06,0.153875,0.00414434,-5.75222e-05,1.364e-06,0.157963,0.00403338,-5.34301e-05,1.20416e-06,0.161944,0.00393014,-4.98177e-05,1.09114e-06,0.165825,0.00383377,-4.65443e-05,9.57987e-07,0.169613,0.00374356,-4.36703e-05,8.88359e-07,0.173314,0.00365888,-4.10052e-05,7.7849e-07,0.176933,0.00357921,-3.86697e-05,7.36254e-07,0.180474,0.00350408,-3.6461e-05,6.42534e-07,0.183942,0.00343308,-3.45334e-05,6.12614e-07,0.187342,0.00336586,-3.26955e-05,5.42894e-07,0.190675,0.00330209,-3.10669e-05,5.08967e-07,0.193947,0.00324149,-2.954e-05,4.75977e-07,0.197159,0.00318383,-2.8112e-05,4.18343e-07,0.200315,0.00312887,-2.6857e-05,4.13651e-07,0.203418,0.00307639,-2.5616e-05,3.70847e-07,0.206469,0.00302627,-2.45035e-05,3.3813e-07,0.209471,0.00297828,-2.34891e-05,3.32999e-07,0.212426,0.0029323,-2.24901e-05,2.96826e-07,0.215336,0.00288821,-2.15996e-05,2.82736e-07,0.218203,0.00284586,-2.07514e-05,2.70961e-07,0.221029,0.00280517,-1.99385e-05,2.42744e-07,0.223814,0.00276602,-1.92103e-05,2.33277e-07,0.226561,0.0027283,-1.85105e-05,2.2486e-07,0.229271,0.00269195,-1.78359e-05,2.08383e-07,0.231945,0.00265691,-1.72108e-05,1.93305e-07,0.234585,0.00262307,-1.66308e-05,1.80687e-07,0.237192,0.00259035,-1.60888e-05,1.86632e-07,0.239766,0.00255873,-1.55289e-05,1.60569e-07,0.24231,0.00252815,-1.50472e-05,1.54566e-07,0.244823,0.00249852,-1.45835e-05,1.59939e-07,0.247307,0.00246983,-1.41037e-05,1.29549e-07,0.249763,0.00244202,-1.3715e-05,1.41429e-07,0.252191,0.00241501,-1.32907e-05,1.39198e-07,0.254593,0.00238885,-1.28731e-05,1.06444e-07,0.256969,0.00236342,-1.25538e-05,1.2048e-07,0.25932,0.00233867,-1.21924e-05,1.26892e-07,0.261647,0.00231467,-1.18117e-05,8.72084e-08,0.26395,0.00229131,-1.15501e-05,1.20323e-07,0.26623,0.00226857,-1.11891e-05,8.71514e-08,0.268487,0.00224645,-1.09276e-05,9.73165e-08,0.270723,0.00222489,-1.06357e-05,8.98259e-08,0.272937,0.00220389,-1.03662e-05,7.98218e-08,0.275131,0.00218339,-1.01267e-05,9.75254e-08,0.277304,0.00216343,-9.83416e-06,6.65195e-08,0.279458,0.00214396,-9.63461e-06,8.34313e-08,0.281592,0.00212494,-9.38431e-06,7.65919e-08,0.283708,0.00210641,-9.15454e-06,5.7236e-08,0.285805,0.00208827,-8.98283e-06,8.18939e-08,0.287885,0.00207055,-8.73715e-06,6.2224e-08,0.289946,0.00205326,-8.55047e-06,5.66388e-08,0.291991,0.00203633,-8.38056e-06,6.88491e-08,0.294019,0.00201978,-8.17401e-06,5.53955e-08,0.296031,0.00200359,-8.00782e-06,6.71971e-08,0.298027,0.00198778,-7.80623e-06,3.34439e-08,0.300007,0.00197227,-7.7059e-06,6.7248e-08,0.301971,0.00195706,-7.50416e-06,5.51915e-08,0.303921,0.00194221,-7.33858e-06,3.98124e-08,0.305856,0.00192766,-7.21915e-06,5.37795e-08,0.307776,0.00191338,-7.05781e-06,4.30919e-08,0.309683,0.00189939,-6.92853e-06,4.20744e-08,0.311575,0.00188566,-6.80231e-06,5.68321e-08,0.313454,0.00187223,-6.63181e-06,2.86195e-08,0.31532,0.00185905,-6.54595e-06,3.73075e-08,0.317172,0.00184607,-6.43403e-06,6.05684e-08,0.319012,0.00183338,-6.25233e-06,1.84426e-08,0.320839,0.00182094,-6.197e-06,4.44757e-08,0.322654,0.00180867,-6.06357e-06,4.20729e-08,0.324456,0.00179667,-5.93735e-06,2.56511e-08,0.326247,0.00178488,-5.8604e-06,3.41368e-08,0.328026,0.00177326,-5.75799e-06,4.64177e-08,0.329794,0.00176188,-5.61874e-06,1.86107e-08,0.33155,0.0017507,-5.5629e-06,2.81511e-08,0.333295,0.00173966,-5.47845e-06,4.75987e-08,0.335029,0.00172884,-5.33565e-06,1.98726e-08,0.336753,0.00171823,-5.27604e-06,2.19226e-08,0.338466,0.00170775,-5.21027e-06,4.14483e-08,0.340169,0.00169745,-5.08592e-06,2.09017e-08,0.341861,0.00168734,-5.02322e-06,2.39561e-08,0.343543,0.00167737,-4.95135e-06,3.22852e-08,0.345216,0.00166756,-4.85449e-06,2.57173e-08,0.346878,0.00165793,-4.77734e-06,1.38569e-08,0.348532,0.00164841,-4.73577e-06,3.80634e-08,0.350175,0.00163906,-4.62158e-06,1.27043e-08,0.35181,0.00162985,-4.58347e-06,3.03279e-08,0.353435,0.00162078,-4.49249e-06,1.49961e-08,0.355051,0.00161184,-4.4475e-06,2.88977e-08,0.356659,0.00160303,-4.3608e-06,1.84241e-08,0.358257,0.00159436,-4.30553e-06,1.6616e-08,0.359848,0.0015858,-4.25568e-06,3.43218e-08,0.361429,0.00157739,-4.15272e-06,-4.89172e-09,0.363002,0.00156907,-4.16739e-06,4.48498e-08,0.364567,0.00156087,-4.03284e-06,4.30676e-09,0.366124,0.00155282,-4.01992e-06,2.73303e-08,0.367673,0.00154486,-3.93793e-06,5.58036e-09,0.369214,0.001537,-3.92119e-06,3.97554e-08,0.370747,0.00152928,-3.80193e-06,-1.55904e-08,0.372272,0.00152163,-3.8487e-06,5.24081e-08,0.37379,0.00151409,-3.69147e-06,-1.52272e-08,0.375301,0.00150666,-3.73715e-06,3.83028e-08,0.376804,0.0014993,-3.62225e-06,1.10278e-08,0.378299,0.00149209,-3.58916e-06,6.99326e-09,0.379788,0.00148493,-3.56818e-06,2.06038e-08,0.381269,0.00147786,-3.50637e-06,2.98009e-08,0.382744,0.00147093,-3.41697e-06,-2.05978e-08,0.384211,0.00146404,-3.47876e-06,5.25899e-08,0.385672,0.00145724,-3.32099e-06,-1.09471e-08,0.387126,0.00145056,-3.35383e-06,2.10009e-08,0.388573,0.00144392,-3.29083e-06,1.63501e-08,0.390014,0.00143739,-3.24178e-06,3.00641e-09,0.391448,0.00143091,-3.23276e-06,3.12282e-08,0.392875,0.00142454,-3.13908e-06,-8.70932e-09,0.394297,0.00141824,-3.16521e-06,3.34114e-08,0.395712,0.00141201,-3.06497e-06,-5.72754e-09,0.397121,0.00140586,-3.08215e-06,1.9301e-08,0.398524,0.00139975,-3.02425e-06,1.7931e-08,0.39992,0.00139376,-2.97046e-06,-1.61822e-09,0.401311,0.00138781,-2.97531e-06,1.83442e-08,0.402696,0.00138192,-2.92028e-06,1.76485e-08,0.404075,0.00137613,-2.86733e-06,4.68617e-10,0.405448,0.00137039,-2.86593e-06,1.02794e-08,0.406816,0.00136469,-2.83509e-06,1.80179e-08,0.408178,0.00135908,-2.78104e-06,7.05594e-09,0.409534,0.00135354,-2.75987e-06,1.33633e-08,0.410885,0.00134806,-2.71978e-06,-9.04568e-10,0.41223,0.00134261,-2.72249e-06,2.0057e-08,0.41357,0.00133723,-2.66232e-06,1.00841e-08,0.414905,0.00133194,-2.63207e-06,-7.88835e-10,0.416234,0.00132667,-2.63444e-06,2.28734e-08,0.417558,0.00132147,-2.56582e-06,-1.29785e-09,0.418877,0.00131633,-2.56971e-06,1.21205e-08,0.420191,0.00131123,-2.53335e-06,1.24202e-08,0.421499,0.0013062,-2.49609e-06,-2.19681e-09,0.422803,0.0013012,-2.50268e-06,2.61696e-08,0.424102,0.00129628,-2.42417e-06,-1.30747e-08,0.425396,0.00129139,-2.46339e-06,2.6129e-08,0.426685,0.00128654,-2.38501e-06,-2.03454e-09,0.427969,0.00128176,-2.39111e-06,1.18115e-08,0.429248,0.00127702,-2.35567e-06,1.43932e-08,0.430523,0.00127235,-2.31249e-06,-9.77965e-09,0.431793,0.00126769,-2.34183e-06,2.47253e-08,0.433058,0.00126308,-2.26766e-06,2.85278e-10,0.434319,0.00125855,-2.2668e-06,3.93614e-09,0.435575,0.00125403,-2.25499e-06,1.37722e-08,0.436827,0.00124956,-2.21368e-06,5.79803e-10,0.438074,0.00124513,-2.21194e-06,1.37112e-08,0.439317,0.00124075,-2.1708e-06,4.17973e-09,0.440556,0.00123642,-2.15826e-06,-6.27703e-10,0.44179,0.0012321,-2.16015e-06,2.81332e-08,0.44302,0.00122787,-2.07575e-06,-2.24985e-08,0.444246,0.00122365,-2.14324e-06,3.20586e-08,0.445467,0.00121946,-2.04707e-06,-1.6329e-08,0.446685,0.00121532,-2.09605e-06,3.32573e-08,0.447898,0.00121122,-1.99628e-06,-2.72927e-08,0.449107,0.00120715,-2.07816e-06,4.6111e-08,0.450312,0.00120313,-1.93983e-06,-3.79416e-08,0.451514,0.00119914,-2.05365e-06,4.60507e-08,0.452711,0.00119517,-1.9155e-06,-2.7052e-08,0.453904,0.00119126,-1.99666e-06,3.23551e-08,0.455093,0.00118736,-1.89959e-06,-1.29613e-08,0.456279,0.00118352,-1.93848e-06,1.94905e-08,0.45746,0.0011797,-1.88e-06,-5.39588e-09,0.458638,0.00117593,-1.89619e-06,2.09282e-09,0.459812,0.00117214,-1.88991e-06,2.68267e-08,0.460982,0.00116844,-1.80943e-06,-1.99925e-08,0.462149,0.00116476,-1.86941e-06,2.3341e-08,0.463312,0.00116109,-1.79939e-06,-1.37674e-08,0.464471,0.00115745,-1.84069e-06,3.17287e-08,0.465627,0.00115387,-1.7455e-06,-2.37407e-08,0.466779,0.00115031,-1.81673e-06,3.34315e-08,0.467927,0.00114677,-1.71643e-06,-2.05786e-08,0.469073,0.00114328,-1.77817e-06,1.90802e-08,0.470214,0.00113978,-1.72093e-06,3.86247e-09,0.471352,0.00113635,-1.70934e-06,-4.72759e-09,0.472487,0.00113292,-1.72352e-06,1.50478e-08,0.473618,0.00112951,-1.67838e-06,4.14108e-09,0.474746,0.00112617,-1.66595e-06,-1.80986e-09,0.47587,0.00112283,-1.67138e-06,3.09816e-09,0.476991,0.0011195,-1.66209e-06,1.92198e-08,0.478109,0.00111623,-1.60443e-06,-2.03726e-08,0.479224,0.00111296,-1.66555e-06,3.2468e-08,0.480335,0.00110973,-1.56814e-06,-2.00922e-08,0.481443,0.00110653,-1.62842e-06,1.80983e-08,0.482548,0.00110333,-1.57413e-06,7.30362e-09,0.48365,0.0011002,-1.55221e-06,-1.75107e-08,0.484749,0.00109705,-1.60475e-06,3.29373e-08,0.485844,0.00109393,-1.50594e-06,-2.48315e-08,0.486937,0.00109085,-1.58043e-06,3.65865e-08,0.488026,0.0010878,-1.47067e-06,-3.21078e-08,0.489112,0.00108476,-1.56699e-06,3.22397e-08,0.490195,0.00108172,-1.47027e-06,-7.44391e-09,0.491276,0.00107876,-1.49261e-06,-2.46428e-09,0.492353,0.00107577,-1.5e-06,1.73011e-08,0.493427,0.00107282,-1.4481e-06,-7.13552e-09,0.494499,0.0010699,-1.4695e-06,1.1241e-08,0.495567,0.001067,-1.43578e-06,-8.02637e-09,0.496633,0.0010641,-1.45986e-06,2.08645e-08,0.497695,0.00106124,-1.39726e-06,-1.58271e-08,0.498755,0.0010584,-1.44475e-06,1.26415e-08,0.499812,0.00105555,-1.40682e-06,2.48655e-08,0.500866,0.00105281,-1.33222e-06,-5.24988e-08,0.501918,0.00104999,-1.48972e-06,6.59206e-08,0.502966,0.00104721,-1.29196e-06,-3.237e-08,0.504012,0.00104453,-1.38907e-06,3.95479e-09,0.505055,0.00104176,-1.3772e-06,1.65509e-08,0.506096,0.00103905,-1.32755e-06,-1.05539e-08,0.507133,0.00103637,-1.35921e-06,2.56648e-08,0.508168,0.00103373,-1.28222e-06,-3.25007e-08,0.509201,0.00103106,-1.37972e-06,4.47336e-08,0.51023,0.00102844,-1.24552e-06,-2.72245e-08,0.511258,0.00102587,-1.32719e-06,4.55952e-09,0.512282,0.00102323,-1.31352e-06,8.98645e-09,0.513304,0.00102063,-1.28656e-06,1.90992e-08,0.514323,0.00101811,-1.22926e-06,-2.57786e-08,0.51534,0.00101557,-1.30659e-06,2.44104e-08,0.516355,0.00101303,-1.23336e-06,-1.22581e-08,0.517366,0.00101053,-1.27014e-06,2.4622e-08,0.518376,0.00100806,-1.19627e-06,-2.66253e-08,0.519383,0.00100559,-1.27615e-06,2.22744e-08,0.520387,0.00100311,-1.20932e-06,-2.8679e-09,0.521389,0.00100068,-1.21793e-06,-1.08029e-08,0.522388,0.000998211,-1.25034e-06,4.60795e-08,0.523385,0.000995849,-1.1121e-06,-5.4306e-08,0.52438,0.000993462,-1.27502e-06,5.19354e-08,0.525372,0.000991067,-1.11921e-06,-3.42262e-08,0.526362,0.000988726,-1.22189e-06,2.53646e-08,0.52735,0.000986359,-1.14579e-06,-7.62782e-09,0.528335,0.000984044,-1.16868e-06,5.14668e-09,0.529318,0.000981722,-1.15324e-06,-1.29589e-08,0.530298,0.000979377,-1.19211e-06,4.66888e-08,0.531276,0.000977133,-1.05205e-06,-5.45868e-08,0.532252,0.000974865,-1.21581e-06,5.24495e-08,0.533226,0.000972591,-1.05846e-06,-3.60019e-08,0.534198,0.000970366,-1.16647e-06,3.19537e-08,0.535167,0.000968129,-1.07061e-06,-3.2208e-08,0.536134,0.000965891,-1.16723e-06,3.72738e-08,0.537099,0.000963668,-1.05541e-06,2.32205e-09,0.538061,0.000961564,-1.04844e-06,-4.65618e-08,0.539022,0.000959328,-1.18813e-06,6.47159e-08,0.53998,0.000957146,-9.93979e-07,-3.3488e-08,0.540936,0.000955057,-1.09444e-06,9.63166e-09,0.54189,0.000952897,-1.06555e-06,-5.03871e-09,0.542842,0.000950751,-1.08066e-06,1.05232e-08,0.543792,0.000948621,-1.04909e-06,2.25503e-08,0.544739,0.000946591,-9.81444e-07,-4.11195e-08,0.545685,0.000944504,-1.1048e-06,2.27182e-08,0.546628,0.000942363,-1.03665e-06,9.85146e-09,0.54757,0.000940319,-1.00709e-06,-2.51938e-09,0.548509,0.000938297,-1.01465e-06,2.25858e-10,0.549446,0.000936269,-1.01397e-06,1.61598e-09,0.550381,0.000934246,-1.00913e-06,-6.68983e-09,0.551315,0.000932207,-1.0292e-06,2.51434e-08,0.552246,0.000930224,-9.53765e-07,-3.42793e-08,0.553175,0.000928214,-1.0566e-06,5.23688e-08,0.554102,0.000926258,-8.99497e-07,-5.59865e-08,0.555028,0.000924291,-1.06746e-06,5.23679e-08,0.555951,0.000922313,-9.10352e-07,-3.42763e-08,0.556872,0.00092039,-1.01318e-06,2.51326e-08,0.557792,0.000918439,-9.37783e-07,-6.64954e-09,0.558709,0.000916543,-9.57732e-07,1.46554e-09,0.559625,0.000914632,-9.53335e-07,7.87281e-10,0.560538,0.000912728,-9.50973e-07,-4.61466e-09,0.56145,0.000910812,-9.64817e-07,1.76713e-08,0.56236,0.000908935,-9.11804e-07,-6.46564e-09,0.563268,0.000907092,-9.312e-07,8.19121e-09,0.564174,0.000905255,-9.06627e-07,-2.62992e-08,0.565078,0.000903362,-9.85524e-07,3.74007e-08,0.565981,0.000901504,-8.73322e-07,-4.0942e-09,0.566882,0.000899745,-8.85605e-07,-2.1024e-08,0.56778,0.00089791,-9.48677e-07,2.85854e-08,0.568677,0.000896099,-8.62921e-07,-3.3713e-08,0.569573,0.000894272,-9.64059e-07,4.6662e-08,0.570466,0.000892484,-8.24073e-07,-3.37258e-08,0.571358,0.000890734,-9.25251e-07,2.86365e-08,0.572247,0.00088897,-8.39341e-07,-2.12155e-08,0.573135,0.000887227,-9.02988e-07,-3.37913e-09,0.574022,0.000885411,-9.13125e-07,3.47319e-08,0.574906,0.000883689,-8.08929e-07,-1.63394e-08,0.575789,0.000882022,-8.57947e-07,-2.8979e-08,0.57667,0.00088022,-9.44885e-07,7.26509e-08,0.57755,0.000878548,-7.26932e-07,-8.28106e-08,0.578427,0.000876845,-9.75364e-07,7.97774e-08,0.579303,0.000875134,-7.36032e-07,-5.74849e-08,0.580178,0.00087349,-9.08486e-07,3.09529e-08,0.58105,0.000871765,-8.15628e-07,-6.72206e-09,0.581921,0.000870114,-8.35794e-07,-4.06451e-09,0.582791,0.00086843,-8.47987e-07,2.29799e-08,0.583658,0.000866803,-7.79048e-07,-2.82503e-08,0.584524,0.00086516,-8.63799e-07,3.04167e-08,0.585388,0.000863524,-7.72548e-07,-3.38119e-08,0.586251,0.000861877,-8.73984e-07,4.52264e-08,0.587112,0.000860265,-7.38305e-07,-2.78842e-08,0.587972,0.000858705,-8.21958e-07,6.70567e-09,0.58883,0.000857081,-8.01841e-07,1.06161e-09,0.589686,0.000855481,-7.98656e-07,-1.09521e-08,0.590541,0.00085385,-8.31512e-07,4.27468e-08,0.591394,0.000852316,-7.03272e-07,-4.08257e-08,0.592245,0.000850787,-8.25749e-07,1.34677e-09,0.593095,0.000849139,-8.21709e-07,3.54387e-08,0.593944,0.000847602,-7.15393e-07,-2.38924e-08,0.59479,0.0008461,-7.8707e-07,5.26143e-10,0.595636,0.000844527,-7.85491e-07,2.17879e-08,0.596479,0.000843021,-7.20127e-07,-2.80733e-08,0.597322,0.000841497,-8.04347e-07,3.09005e-08,0.598162,0.000839981,-7.11646e-07,-3.5924e-08,0.599002,0.00083845,-8.19418e-07,5.3191e-08,0.599839,0.000836971,-6.59845e-07,-5.76307e-08,0.600676,0.000835478,-8.32737e-07,5.81227e-08,0.60151,0.000833987,-6.58369e-07,-5.56507e-08,0.602344,0.000832503,-8.25321e-07,4.52706e-08,0.603175,0.000830988,-6.89509e-07,-6.22236e-09,0.604006,0.000829591,-7.08176e-07,-2.03811e-08,0.604834,0.000828113,-7.6932e-07,2.8142e-08,0.605662,0.000826659,-6.84894e-07,-3.25822e-08,0.606488,0.000825191,-7.8264e-07,4.25823e-08,0.607312,0.000823754,-6.54893e-07,-1.85376e-08,0.608135,0.000822389,-7.10506e-07,-2.80365e-08,0.608957,0.000820883,-7.94616e-07,7.1079e-08,0.609777,0.000819507,-5.81379e-07,-7.74655e-08,0.610596,0.000818112,-8.13775e-07,5.9969e-08,0.611413,0.000816665,-6.33868e-07,-4.32013e-08,0.612229,0.000815267,-7.63472e-07,5.32313e-08,0.613044,0.0008139,-6.03778e-07,-5.05148e-08,0.613857,0.000812541,-7.55323e-07,2.96187e-08,0.614669,0.000811119,-6.66466e-07,-8.35545e-09,0.615479,0.000809761,-6.91533e-07,3.80301e-09,0.616288,0.00080839,-6.80124e-07,-6.85666e-09,0.617096,0.000807009,-7.00694e-07,2.36237e-08,0.617903,0.000805678,-6.29822e-07,-2.80336e-08,0.618708,0.000804334,-7.13923e-07,2.8906e-08,0.619511,0.000802993,-6.27205e-07,-2.79859e-08,0.620314,0.000801655,-7.11163e-07,2.34329e-08,0.621114,0.000800303,-6.40864e-07,-6.14108e-09,0.621914,0.000799003,-6.59287e-07,1.13151e-09,0.622712,0.000797688,-6.55893e-07,1.61507e-09,0.62351,0.000796381,-6.51048e-07,-7.59186e-09,0.624305,0.000795056,-6.73823e-07,2.87524e-08,0.6251,0.000793794,-5.87566e-07,-4.7813e-08,0.625893,0.000792476,-7.31005e-07,4.32901e-08,0.626685,0.000791144,-6.01135e-07,-6.13814e-09,0.627475,0.000789923,-6.19549e-07,-1.87376e-08,0.628264,0.000788628,-6.75762e-07,2.14837e-08,0.629052,0.000787341,-6.11311e-07,-7.59265e-09,0.629839,0.000786095,-6.34089e-07,8.88692e-09,0.630625,0.000784854,-6.07428e-07,-2.7955e-08,0.631409,0.000783555,-6.91293e-07,4.33285e-08,0.632192,0.000782302,-5.61307e-07,-2.61497e-08,0.632973,0.000781101,-6.39757e-07,1.6658e-09,0.633754,0.000779827,-6.34759e-07,1.94866e-08,0.634533,0.000778616,-5.76299e-07,-2.00076e-08,0.635311,0.000777403,-6.36322e-07,9.39091e-10,0.636088,0.000776133,-6.33505e-07,1.62512e-08,0.636863,0.000774915,-5.84751e-07,-6.33937e-09,0.637638,0.000773726,-6.03769e-07,9.10609e-09,0.638411,0.000772546,-5.76451e-07,-3.00849e-08,0.639183,0.000771303,-6.66706e-07,5.1629e-08,0.639953,0.000770125,-5.11819e-07,-5.7222e-08,0.640723,0.000768929,-6.83485e-07,5.80497e-08,0.641491,0.000767736,-5.09336e-07,-5.57674e-08,0.642259,0.000766551,-6.76638e-07,4.58105e-08,0.643024,0.000765335,-5.39206e-07,-8.26541e-09,0.643789,0.000764231,-5.64002e-07,-1.27488e-08,0.644553,0.000763065,-6.02249e-07,-3.44168e-10,0.645315,0.00076186,-6.03281e-07,1.41254e-08,0.646077,0.000760695,-5.60905e-07,3.44727e-09,0.646837,0.000759584,-5.50563e-07,-2.79144e-08,0.647596,0.000758399,-6.34307e-07,4.86057e-08,0.648354,0.000757276,-4.88489e-07,-4.72989e-08,0.64911,0.000756158,-6.30386e-07,2.13807e-08,0.649866,0.000754961,-5.66244e-07,2.13808e-08,0.65062,0.000753893,-5.02102e-07,-4.7299e-08,0.651374,0.000752746,-6.43999e-07,4.86059e-08,0.652126,0.000751604,-4.98181e-07,-2.79154e-08,0.652877,0.000750524,-5.81927e-07,3.45089e-09,0.653627,0.000749371,-5.71575e-07,1.41119e-08,0.654376,0.00074827,-5.29239e-07,-2.93748e-10,0.655123,0.00074721,-5.3012e-07,-1.29368e-08,0.65587,0.000746111,-5.68931e-07,-7.56355e-09,0.656616,0.000744951,-5.91621e-07,4.3191e-08,0.65736,0.000743897,-4.62048e-07,-4.59911e-08,0.658103,0.000742835,-6.00022e-07,2.15642e-08,0.658846,0.0007417,-5.35329e-07,1.93389e-08,0.659587,0.000740687,-4.77312e-07,-3.93152e-08,0.660327,0.000739615,-5.95258e-07,1.87126e-08,0.661066,0.00073848,-5.3912e-07,2.40695e-08,0.661804,0.000737474,-4.66912e-07,-5.53859e-08,0.662541,0.000736374,-6.33069e-07,7.82648e-08,0.663277,0.000735343,-3.98275e-07,-7.88593e-08,0.664012,0.00073431,-6.34853e-07,5.83585e-08,0.664745,0.000733215,-4.59777e-07,-3.53656e-08,0.665478,0.000732189,-5.65874e-07,2.34994e-08,0.66621,0.000731128,-4.95376e-07,9.72743e-10,0.66694,0.00073014,-4.92458e-07,-2.73903e-08,0.66767,0.000729073,-5.74629e-07,4.89839e-08,0.668398,0.000728071,-4.27677e-07,-4.93359e-08,0.669126,0.000727068,-5.75685e-07,2.91504e-08,0.669853,0.000726004,-4.88234e-07,-7.66109e-09,0.670578,0.000725004,-5.11217e-07,1.49392e-09,0.671303,0.000723986,-5.06735e-07,1.68533e-09,0.672026,0.000722978,-5.01679e-07,-8.23525e-09,0.672749,0.00072195,-5.26385e-07,3.12556e-08,0.67347,0.000720991,-4.32618e-07,-5.71825e-08,0.674191,0.000719954,-6.04166e-07,7.8265e-08,0.67491,0.00071898,-3.69371e-07,-7.70634e-08,0.675628,0.00071801,-6.00561e-07,5.11747e-08,0.676346,0.000716963,-4.47037e-07,-8.42615e-09,0.677062,0.000716044,-4.72315e-07,-1.747e-08,0.677778,0.000715046,-5.24725e-07,1.87015e-08,0.678493,0.000714053,-4.68621e-07,2.26856e-09,0.679206,0.000713123,-4.61815e-07,-2.77758e-08,0.679919,0.000712116,-5.45142e-07,4.92298e-08,0.68063,0.000711173,-3.97453e-07,-4.99339e-08,0.681341,0.000710228,-5.47255e-07,3.12967e-08,0.682051,0.000709228,-4.53365e-07,-1.56481e-08,0.68276,0.000708274,-5.00309e-07,3.12958e-08,0.683467,0.000707367,-4.06422e-07,-4.99303e-08,0.684174,0.000706405,-5.56213e-07,4.9216e-08,0.68488,0.00070544,-4.08565e-07,-2.77245e-08,0.685585,0.00070454,-4.91738e-07,2.07748e-09,0.686289,0.000703562,-4.85506e-07,1.94146e-08,0.686992,0.00070265,-4.27262e-07,-2.01314e-08,0.687695,0.000701735,-4.87656e-07,1.50616e-09,0.688396,0.000700764,-4.83137e-07,1.41067e-08,0.689096,0.00069984,-4.40817e-07,1.67168e-09,0.689795,0.000698963,-4.35802e-07,-2.07934e-08,0.690494,0.000698029,-4.98182e-07,2.18972e-08,0.691192,0.000697099,-4.32491e-07,-7.19092e-09,0.691888,0.000696212,-4.54064e-07,6.86642e-09,0.692584,0.000695325,-4.33464e-07,-2.02747e-08,0.693279,0.000694397,-4.94288e-07,1.46279e-08,0.693973,0.000693452,-4.50405e-07,2.13678e-08,0.694666,0.000692616,-3.86301e-07,-4.04945e-08,0.695358,0.000691721,-5.07785e-07,2.14009e-08,0.696049,0.00069077,-4.43582e-07,1.44955e-08,0.69674,0.000689926,-4.00096e-07,-1.97783e-08,0.697429,0.000689067,-4.5943e-07,5.01296e-09,0.698118,0.000688163,-4.44392e-07,-2.73521e-10,0.698805,0.000687273,-4.45212e-07,-3.91893e-09,0.699492,0.000686371,-4.56969e-07,1.59493e-08,0.700178,0.000685505,-4.09121e-07,-2.73351e-10,0.700863,0.000684686,-4.09941e-07,-1.4856e-08,0.701548,0.000683822,-4.54509e-07,9.25979e-11,0.702231,0.000682913,-4.54231e-07,1.44855e-08,0.702913,0.000682048,-4.10775e-07,1.56992e-09,0.703595,0.000681231,-4.06065e-07,-2.07652e-08,0.704276,0.000680357,-4.68361e-07,2.18864e-08,0.704956,0.000679486,-4.02701e-07,-7.17595e-09,0.705635,0.000678659,-4.24229e-07,6.81748e-09,0.706313,0.000677831,-4.03777e-07,-2.0094e-08,0.70699,0.000676963,-4.64059e-07,1.39538e-08,0.707667,0.000676077,-4.22197e-07,2.38835e-08,0.708343,0.000675304,-3.50547e-07,-4.98831e-08,0.709018,0.000674453,-5.00196e-07,5.64395e-08,0.709692,0.000673622,-3.30878e-07,-5.66657e-08,0.710365,0.00067279,-5.00875e-07,5.1014e-08,0.711037,0.000671942,-3.47833e-07,-2.81809e-08,0.711709,0.000671161,-4.32376e-07,2.10513e-09,0.712379,0.000670303,-4.2606e-07,1.97604e-08,0.713049,0.00066951,-3.66779e-07,-2.15422e-08,0.713718,0.000668712,-4.31406e-07,6.8038e-09,0.714387,0.000667869,-4.10994e-07,-5.67295e-09,0.715054,0.00066703,-4.28013e-07,1.5888e-08,0.715721,0.000666222,-3.80349e-07,1.72576e-09,0.716387,0.000665467,-3.75172e-07,-2.27911e-08,0.717052,0.000664648,-4.43545e-07,2.9834e-08,0.717716,0.00066385,-3.54043e-07,-3.69401e-08,0.718379,0.000663031,-4.64864e-07,5.83219e-08,0.719042,0.000662277,-2.89898e-07,-7.71382e-08,0.719704,0.000661465,-5.21313e-07,7.14171e-08,0.720365,0.000660637,-3.07061e-07,-2.97161e-08,0.721025,0.000659934,-3.96209e-07,-1.21575e-08,0.721685,0.000659105,-4.32682e-07,1.87412e-08,0.722343,0.000658296,-3.76458e-07,-3.2029e-09,0.723001,0.000657533,-3.86067e-07,-5.9296e-09,0.723659,0.000656743,-4.03856e-07,2.69213e-08,0.724315,0.000656016,-3.23092e-07,-4.21511e-08,0.724971,0.000655244,-4.49545e-07,2.24737e-08,0.725625,0.000654412,-3.82124e-07,1.18611e-08,0.726279,0.000653683,-3.46541e-07,-1.03132e-08,0.726933,0.000652959,-3.7748e-07,-3.02128e-08,0.727585,0.000652114,-4.68119e-07,7.15597e-08,0.728237,0.000651392,-2.5344e-07,-7.72119e-08,0.728888,0.000650654,-4.85075e-07,5.8474e-08,0.729538,0.000649859,-3.09654e-07,-3.74746e-08,0.730188,0.000649127,-4.22077e-07,3.18197e-08,0.730837,0.000648379,-3.26618e-07,-3.01997e-08,0.731485,0.000647635,-4.17217e-07,2.93747e-08,0.732132,0.000646888,-3.29093e-07,-2.76943e-08,0.732778,0.000646147,-4.12176e-07,2.17979e-08,0.733424,0.000645388,-3.46783e-07,1.07292e-10,0.734069,0.000644695,-3.46461e-07,-2.22271e-08,0.734713,0.000643935,-4.13142e-07,2.91963e-08,0.735357,0.000643197,-3.25553e-07,-3.49536e-08,0.736,0.000642441,-4.30414e-07,5.10133e-08,0.736642,0.000641733,-2.77374e-07,-4.98904e-08,0.737283,0.000641028,-4.27045e-07,2.93392e-08,0.737924,0.000640262,-3.39028e-07,-7.86156e-09,0.738564,0.000639561,-3.62612e-07,2.10703e-09,0.739203,0.000638842,-3.56291e-07,-5.6653e-10,0.739842,0.000638128,-3.57991e-07,1.59086e-10,0.740479,0.000637412,-3.57513e-07,-6.98321e-11,0.741116,0.000636697,-3.57723e-07,1.20214e-10,0.741753,0.000635982,-3.57362e-07,-4.10987e-10,0.742388,0.000635266,-3.58595e-07,1.5237e-09,0.743023,0.000634553,-3.54024e-07,-5.68376e-09,0.743657,0.000633828,-3.71075e-07,2.12113e-08,0.744291,0.00063315,-3.07441e-07,-1.95569e-08,0.744924,0.000632476,-3.66112e-07,-2.58816e-09,0.745556,0.000631736,-3.73877e-07,2.99096e-08,0.746187,0.000631078,-2.84148e-07,-5.74454e-08,0.746818,0.000630337,-4.56484e-07,8.06629e-08,0.747448,0.000629666,-2.14496e-07,-8.63922e-08,0.748077,0.000628978,-4.73672e-07,8.60918e-08,0.748706,0.000628289,-2.15397e-07,-7.91613e-08,0.749334,0.000627621,-4.5288e-07,5.17393e-08,0.749961,0.00062687,-2.97663e-07,-8.58662e-09,0.750588,0.000626249,-3.23422e-07,-1.73928e-08,0.751214,0.00062555,-3.75601e-07,1.85532e-08,0.751839,0.000624855,-3.19941e-07,2.78479e-09,0.752463,0.000624223,-3.11587e-07,-2.96923e-08,0.753087,0.000623511,-4.00664e-07,5.63799e-08,0.75371,0.000622879,-2.31524e-07,-7.66179e-08,0.754333,0.000622186,-4.61378e-07,7.12778e-08,0.754955,0.000621477,-2.47545e-07,-2.96794e-08,0.755576,0.000620893,-3.36583e-07,-1.21648e-08,0.756196,0.000620183,-3.73077e-07,1.87339e-08,0.756816,0.000619493,-3.16875e-07,-3.16622e-09,0.757435,0.00061885,-3.26374e-07,-6.0691e-09,0.758054,0.000618179,-3.44581e-07,2.74426e-08,0.758672,0.000617572,-2.62254e-07,-4.40968e-08,0.759289,0.000616915,-3.94544e-07,2.97352e-08,0.759906,0.000616215,-3.05338e-07,-1.52393e-08,0.760522,0.000615559,-3.51056e-07,3.12221e-08,0.761137,0.000614951,-2.5739e-07,-5.00443e-08,0.761751,0.000614286,-4.07523e-07,4.9746e-08,0.762365,0.00061362,-2.58285e-07,-2.97303e-08,0.762979,0.000613014,-3.47476e-07,9.57079e-09,0.763591,0.000612348,-3.18764e-07,-8.55287e-09,0.764203,0.000611685,-3.44422e-07,2.46407e-08,0.764815,0.00061107,-2.705e-07,-3.04053e-08,0.765426,0.000610437,-3.61716e-07,3.73759e-08,0.766036,0.000609826,-2.49589e-07,-5.94935e-08,0.766645,0.000609149,-4.28069e-07,8.13889e-08,0.767254,0.000608537,-1.83902e-07,-8.72483e-08,0.767862,0.000607907,-4.45647e-07,8.87901e-08,0.76847,0.000607282,-1.79277e-07,-8.90983e-08,0.769077,0.000606656,-4.46572e-07,8.87892e-08,0.769683,0.000606029,-1.80204e-07,-8.72446e-08,0.770289,0.000605407,-4.41938e-07,8.13752e-08,0.770894,0.000604768,-1.97812e-07,-5.94423e-08,0.771498,0.000604194,-3.76139e-07,3.71848e-08,0.772102,0.000603553,-2.64585e-07,-2.96922e-08,0.772705,0.000602935,-3.53661e-07,2.19793e-08,0.773308,0.000602293,-2.87723e-07,1.37955e-09,0.77391,0.000601722,-2.83585e-07,-2.74976e-08,0.774512,0.000601072,-3.66077e-07,4.9006e-08,0.775112,0.000600487,-2.19059e-07,-4.93171e-08,0.775712,0.000599901,-3.67011e-07,2.90531e-08,0.776312,0.000599254,-2.79851e-07,-7.29081e-09,0.776911,0.000598673,-3.01724e-07,1.10077e-10,0.777509,0.00059807,-3.01393e-07,6.85053e-09,0.778107,0.000597487,-2.80842e-07,-2.75123e-08,0.778704,0.000596843,-3.63379e-07,4.35939e-08,0.779301,0.000596247,-2.32597e-07,-2.7654e-08,0.779897,0.000595699,-3.15559e-07,7.41741e-09,0.780492,0.00059509,-2.93307e-07,-2.01562e-09,0.781087,0.000594497,-2.99354e-07,6.45059e-10,0.781681,0.000593901,-2.97418e-07,-5.64635e-10,0.782275,0.000593304,-2.99112e-07,1.61347e-09,0.782868,0.000592711,-2.94272e-07,-5.88926e-09,0.78346,0.000592105,-3.1194e-07,2.19436e-08,0.784052,0.000591546,-2.46109e-07,-2.22805e-08,0.784643,0.000590987,-3.1295e-07,7.57368e-09,0.785234,0.000590384,-2.90229e-07,-8.01428e-09,0.785824,0.00058978,-3.14272e-07,2.44834e-08,0.786414,0.000589225,-2.40822e-07,-3.03148e-08,0.787003,0.000588652,-3.31766e-07,3.7171e-08,0.787591,0.0005881,-2.20253e-07,-5.87646e-08,0.788179,0.000587483,-3.96547e-07,7.86782e-08,0.788766,0.000586926,-1.60512e-07,-7.71342e-08,0.789353,0.000586374,-3.91915e-07,5.10444e-08,0.789939,0.000585743,-2.38782e-07,-7.83422e-09,0.790524,0.000585242,-2.62284e-07,-1.97076e-08,0.791109,0.000584658,-3.21407e-07,2.70598e-08,0.791693,0.000584097,-2.40228e-07,-2.89269e-08,0.792277,0.000583529,-3.27008e-07,2.90431e-08,0.792861,0.000582963,-2.39879e-07,-2.76409e-08,0.793443,0.0005824,-3.22802e-07,2.1916e-08,0.794025,0.00058182,-2.57054e-07,-4.18368e-10,0.794607,0.000581305,-2.58309e-07,-2.02425e-08,0.795188,0.000580727,-3.19036e-07,2.17838e-08,0.795768,0.000580155,-2.53685e-07,-7.28814e-09,0.796348,0.000579625,-2.75549e-07,7.36871e-09,0.796928,0.000579096,-2.53443e-07,-2.21867e-08,0.797506,0.000578523,-3.20003e-07,2.17736e-08,0.798085,0.000577948,-2.54683e-07,-5.30296e-09,0.798662,0.000577423,-2.70592e-07,-5.61698e-10,0.799239,0.00057688,-2.72277e-07,7.54977e-09,0.799816,0.000576358,-2.49627e-07,-2.96374e-08,0.800392,0.00057577,-3.38539e-07,5.1395e-08,0.800968,0.000575247,-1.84354e-07,-5.67335e-08,0.801543,0.000574708,-3.54555e-07,5.63297e-08,0.802117,0.000574168,-1.85566e-07,-4.93759e-08,0.802691,0.000573649,-3.33693e-07,2.19646e-08,0.803264,0.000573047,-2.678e-07,2.1122e-08,0.803837,0.000572575,-2.04433e-07,-4.68482e-08,0.804409,0.000572026,-3.44978e-07,4.70613e-08,0.804981,0.000571477,-2.03794e-07,-2.21877e-08,0.805552,0.000571003,-2.70357e-07,-1.79153e-08,0.806123,0.000570408,-3.24103e-07,3.42443e-08,0.806693,0.000569863,-2.2137e-07,1.47556e-10,0.807263,0.000569421,-2.20928e-07,-3.48345e-08,0.807832,0.000568874,-3.25431e-07,1.99812e-08,0.808401,0.000568283,-2.65487e-07,1.45143e-08,0.808969,0.000567796,-2.21945e-07,-1.84338e-08,0.809536,0.000567297,-2.77246e-07,-3.83608e-10,0.810103,0.000566741,-2.78397e-07,1.99683e-08,0.81067,0.000566244,-2.18492e-07,-1.98848e-08,0.811236,0.000565747,-2.78146e-07,-3.38976e-11,0.811801,0.000565191,-2.78248e-07,2.00204e-08,0.812366,0.000564695,-2.18187e-07,-2.04429e-08,0.812931,0.000564197,-2.79516e-07,2.1467e-09,0.813495,0.000563644,-2.73076e-07,1.18561e-08,0.814058,0.000563134,-2.37507e-07,1.00334e-08,0.814621,0.000562689,-2.07407e-07,-5.19898e-08,0.815183,0.000562118,-3.63376e-07,7.87163e-08,0.815745,0.000561627,-1.27227e-07,-8.40616e-08,0.816306,0.000561121,-3.79412e-07,7.87163e-08,0.816867,0.000560598,-1.43263e-07,-5.19898e-08,0.817428,0.000560156,-2.99233e-07,1.00335e-08,0.817988,0.000559587,-2.69132e-07,1.18559e-08,0.818547,0.000559085,-2.33564e-07,2.14764e-09,0.819106,0.000558624,-2.27122e-07,-2.04464e-08,0.819664,0.000558108,-2.88461e-07,2.00334e-08,0.820222,0.000557591,-2.28361e-07,-8.24277e-11,0.820779,0.000557135,-2.28608e-07,-1.97037e-08,0.821336,0.000556618,-2.87719e-07,1.92925e-08,0.821893,0.000556101,-2.29841e-07,2.13831e-09,0.822448,0.000555647,-2.23427e-07,-2.78458e-08,0.823004,0.000555117,-3.06964e-07,4.96402e-08,0.823559,0.000554652,-1.58043e-07,-5.15058e-08,0.824113,0.000554181,-3.12561e-07,3.71737e-08,0.824667,0.000553668,-2.0104e-07,-3.75844e-08,0.82522,0.000553153,-3.13793e-07,5.35592e-08,0.825773,0.000552686,-1.53115e-07,-5.74431e-08,0.826326,0.000552207,-3.25444e-07,5.7004e-08,0.826878,0.000551728,-1.54433e-07,-5.13635e-08,0.827429,0.000551265,-3.08523e-07,2.92406e-08,0.82798,0.000550735,-2.20801e-07,-5.99424e-09,0.828531,0.000550276,-2.38784e-07,-5.26363e-09,0.829081,0.000549782,-2.54575e-07,2.70488e-08,0.82963,0.000549354,-1.73429e-07,-4.33268e-08,0.83018,0.000548878,-3.03409e-07,2.7049e-08,0.830728,0.000548352,-2.22262e-07,-5.26461e-09,0.831276,0.000547892,-2.38056e-07,-5.99057e-09,0.831824,0.000547397,-2.56027e-07,2.92269e-08,0.832371,0.000546973,-1.68347e-07,-5.13125e-08,0.832918,0.000546482,-3.22284e-07,5.68139e-08,0.833464,0.000546008,-1.51843e-07,-5.67336e-08,0.83401,0.000545534,-3.22043e-07,5.09113e-08,0.834555,0.000545043,-1.6931e-07,-2.77022e-08,0.8351,0.000544621,-2.52416e-07,2.92924e-10,0.835644,0.000544117,-2.51537e-07,2.65305e-08,0.836188,0.000543694,-1.71946e-07,-4.68105e-08,0.836732,0.00054321,-3.12377e-07,4.15021e-08,0.837275,0.000542709,-1.87871e-07,1.13355e-11,0.837817,0.000542334,-1.87837e-07,-4.15474e-08,0.838359,0.000541833,-3.12479e-07,4.69691e-08,0.838901,0.000541349,-1.71572e-07,-2.71196e-08,0.839442,0.000540925,-2.52931e-07,1.90462e-09,0.839983,0.000540425,-2.47217e-07,1.95011e-08,0.840523,0.000539989,-1.88713e-07,-2.03045e-08,0.841063,0.00053955,-2.49627e-07,2.11216e-09,0.841602,0.000539057,-2.4329e-07,1.18558e-08,0.842141,0.000538606,-2.07723e-07,1.00691e-08,0.842679,0.000538221,-1.77516e-07,-5.21324e-08,0.843217,0.00053771,-3.33913e-07,7.92513e-08,0.843755,0.00053728,-9.6159e-08,-8.60587e-08,0.844292,0.000536829,-3.54335e-07,8.61696e-08,0.844828,0.000536379,-9.58263e-08,-7.98057e-08,0.845364,0.000535948,-3.35243e-07,5.42394e-08,0.8459,0.00053544,-1.72525e-07,-1.79426e-08,0.846435,0.000535041,-2.26353e-07,1.75308e-08,0.84697,0.000534641,-1.73761e-07,-5.21806e-08,0.847505,0.000534137,-3.30302e-07,7.19824e-08,0.848038,0.000533692,-1.14355e-07,-5.69349e-08,0.848572,0.000533293,-2.8516e-07,3.65479e-08,0.849105,0.000532832,-1.75516e-07,-2.96519e-08,0.849638,0.000532392,-2.64472e-07,2.2455e-08,0.85017,0.000531931,-1.97107e-07,-5.63451e-10,0.850702,0.000531535,-1.98797e-07,-2.02011e-08,0.851233,0.000531077,-2.59401e-07,2.17634e-08,0.851764,0.000530623,-1.94111e-07,-7.24794e-09,0.852294,0.000530213,-2.15854e-07,7.22832e-09,0.852824,0.000529803,-1.94169e-07,-2.16653e-08,0.853354,0.00052935,-2.59165e-07,1.98283e-08,0.853883,0.000528891,-1.9968e-07,1.95678e-09,0.854412,0.000528497,-1.9381e-07,-2.76554e-08,0.85494,0.000528027,-2.76776e-07,4.90603e-08,0.855468,0.00052762,-1.29596e-07,-4.93764e-08,0.855995,0.000527213,-2.77725e-07,2.92361e-08,0.856522,0.000526745,-1.90016e-07,-7.96341e-09,0.857049,0.000526341,-2.13907e-07,2.61752e-09,0.857575,0.000525922,-2.06054e-07,-2.50665e-09,0.8581,0.000525502,-2.13574e-07,7.40906e-09,0.858626,0.000525097,-1.91347e-07,-2.71296e-08,0.859151,0.000524633,-2.72736e-07,4.15048e-08,0.859675,0.000524212,-1.48221e-07,-1.96802e-08,0.860199,0.000523856,-2.07262e-07,-2.23886e-08,0.860723,0.000523375,-2.74428e-07,4.96299e-08,0.861246,0.000522975,-1.25538e-07,-5.69216e-08,0.861769,0.000522553,-2.96303e-07,5.88473e-08,0.862291,0.000522137,-1.19761e-07,-5.92584e-08,0.862813,0.00052172,-2.97536e-07,5.8977e-08,0.863334,0.000521301,-1.20605e-07,-5.74403e-08,0.863855,0.000520888,-2.92926e-07,5.15751e-08,0.864376,0.000520457,-1.38201e-07,-2.96506e-08,0.864896,0.000520091,-2.27153e-07,7.42277e-09,0.865416,0.000519659,-2.04885e-07,-4.05057e-11,0.865936,0.00051925,-2.05006e-07,-7.26074e-09,0.866455,0.000518818,-2.26788e-07,2.90835e-08,0.866973,0.000518451,-1.39538e-07,-4.94686e-08,0.867492,0.000518024,-2.87944e-07,4.95814e-08,0.868009,0.000517597,-1.39199e-07,-2.96479e-08,0.868527,0.000517229,-2.28143e-07,9.40539e-09,0.869044,0.000516801,-1.99927e-07,-7.9737e-09,0.86956,0.000516378,-2.23848e-07,2.24894e-08,0.870077,0.000515997,-1.5638e-07,-2.23793e-08,0.870592,0.000515617,-2.23517e-07,7.42302e-09,0.871108,0.000515193,-2.01248e-07,-7.31283e-09,0.871623,0.000514768,-2.23187e-07,2.18283e-08,0.872137,0.000514387,-1.57702e-07,-2.03959e-08,0.872652,0.000514011,-2.1889e-07,1.50711e-10,0.873165,0.000513573,-2.18437e-07,1.97931e-08,0.873679,0.000513196,-1.59058e-07,-1.97183e-08,0.874192,0.000512819,-2.18213e-07,-5.24324e-10,0.874704,0.000512381,-2.19786e-07,2.18156e-08,0.875217,0.000512007,-1.54339e-07,-2.71336e-08,0.875728,0.000511616,-2.3574e-07,2.71141e-08,0.87624,0.000511226,-1.54398e-07,-2.17182e-08,0.876751,0.000510852,-2.19552e-07,1.54131e-10,0.877262,0.000510414,-2.1909e-07,2.11017e-08,0.877772,0.000510039,-1.55785e-07,-2.49562e-08,0.878282,0.000509652,-2.30654e-07,1.91183e-08,0.878791,0.000509248,-1.73299e-07,8.08751e-09,0.8793,0.000508926,-1.49036e-07,-5.14684e-08,0.879809,0.000508474,-3.03441e-07,7.85766e-08,0.880317,0.000508103,-6.77112e-08,-8.40242e-08,0.880825,0.000507715,-3.19784e-07,7.87063e-08,0.881333,0.000507312,-8.36649e-08,-5.19871e-08,0.88184,0.000506988,-2.39626e-07,1.00327e-08,0.882346,0.000506539,-2.09528e-07,1.18562e-08,0.882853,0.000506156,-1.73959e-07,2.14703e-09,0.883359,0.000505814,-1.67518e-07,-2.04444e-08,0.883864,0.000505418,-2.28851e-07,2.00258e-08,0.88437,0.00050502,-1.68774e-07,-5.42855e-11,0.884874,0.000504682,-1.68937e-07,-1.98087e-08,0.885379,0.000504285,-2.28363e-07,1.96842e-08,0.885883,0.000503887,-1.6931e-07,6.76342e-10,0.886387,0.000503551,-1.67281e-07,-2.23896e-08,0.88689,0.000503149,-2.3445e-07,2.92774e-08,0.887393,0.000502768,-1.46618e-07,-3.51152e-08,0.887896,0.00050237,-2.51963e-07,5.15787e-08,0.888398,0.00050202,-9.72271e-08,-5.19903e-08,0.8889,0.00050167,-2.53198e-07,3.71732e-08,0.889401,0.000501275,-1.41678e-07,-3.70978e-08,0.889902,0.00050088,-2.52972e-07,5.16132e-08,0.890403,0.000500529,-9.81321e-08,-5.01459e-08,0.890903,0.000500183,-2.4857e-07,2.9761e-08,0.891403,0.000499775,-1.59287e-07,-9.29351e-09,0.891903,0.000499428,-1.87167e-07,7.41301e-09,0.892402,0.000499076,-1.64928e-07,-2.03585e-08,0.892901,0.000498685,-2.26004e-07,1.44165e-08,0.893399,0.000498276,-1.82754e-07,2.22974e-08,0.893898,0.000497978,-1.15862e-07,-4.40013e-08,0.894395,0.000497614,-2.47866e-07,3.44985e-08,0.894893,0.000497222,-1.44371e-07,-3.43882e-08,0.89539,0.00049683,-2.47535e-07,4.34497e-08,0.895886,0.000496465,-1.17186e-07,-2.02012e-08,0.896383,0.00049617,-1.7779e-07,-2.22497e-08,0.896879,0.000495748,-2.44539e-07,4.95952e-08,0.897374,0.000495408,-9.57532e-08,-5.69217e-08,0.89787,0.000495045,-2.66518e-07,5.88823e-08,0.898364,0.000494689,-8.98713e-08,-5.93983e-08,0.898859,0.000494331,-2.68066e-07,5.95017e-08,0.899353,0.000493973,-8.95613e-08,-5.9399e-08,0.899847,0.000493616,-2.67758e-07,5.8885e-08,0.90034,0.000493257,-9.11033e-08,-5.69317e-08,0.900833,0.000492904,-2.61898e-07,4.96326e-08,0.901326,0.000492529,-1.13001e-07,-2.23893e-08,0.901819,0.000492236,-1.80169e-07,-1.968e-08,0.902311,0.000491817,-2.39209e-07,4.15047e-08,0.902802,0.000491463,-1.14694e-07,-2.71296e-08,0.903293,0.000491152,-1.96083e-07,7.409e-09,0.903784,0.000490782,-1.73856e-07,-2.50645e-09,0.904275,0.000490427,-1.81376e-07,2.61679e-09,0.904765,0.000490072,-1.73525e-07,-7.96072e-09,0.905255,0.000489701,-1.97407e-07,2.92261e-08,0.905745,0.000489394,-1.09729e-07,-4.93389e-08,0.906234,0.000489027,-2.57746e-07,4.89204e-08,0.906723,0.000488658,-1.10985e-07,-2.71333e-08,0.907211,0.000488354,-1.92385e-07,8.30861e-12,0.907699,0.00048797,-1.9236e-07,2.71001e-08,0.908187,0.000487666,-1.1106e-07,-4.88041e-08,0.908675,0.000487298,-2.57472e-07,4.89069e-08,0.909162,0.000486929,-1.10751e-07,-2.76143e-08,0.909649,0.000486625,-1.93594e-07,1.9457e-09,0.910135,0.000486244,-1.87757e-07,1.98315e-08,0.910621,0.000485928,-1.28262e-07,-2.16671e-08,0.911107,0.000485606,-1.93264e-07,7.23216e-09,0.911592,0.000485241,-1.71567e-07,-7.26152e-09,0.912077,0.000484877,-1.93352e-07,2.18139e-08,0.912562,0.000484555,-1.2791e-07,-2.03895e-08,0.913047,0.000484238,-1.89078e-07,1.39494e-10,0.913531,0.000483861,-1.8866e-07,1.98315e-08,0.914014,0.000483543,-1.29165e-07,-1.98609e-08,0.914498,0.000483225,-1.88748e-07,7.39912e-12,0.914981,0.000482847,-1.88726e-07,1.98313e-08,0.915463,0.000482529,-1.29232e-07,-1.9728e-08,0.915946,0.000482212,-1.88416e-07,-5.24035e-10,0.916428,0.000481833,-1.89988e-07,2.18241e-08,0.916909,0.000481519,-1.24516e-07,-2.71679e-08,0.917391,0.000481188,-2.06019e-07,2.72427e-08,0.917872,0.000480858,-1.24291e-07,-2.21985e-08,0.918353,0.000480543,-1.90886e-07,1.94644e-09,0.918833,0.000480167,-1.85047e-07,1.44127e-08,0.919313,0.00047984,-1.41809e-07,7.39438e-12,0.919793,0.000479556,-1.41787e-07,-1.44423e-08,0.920272,0.000479229,-1.85114e-07,-1.84291e-09,0.920751,0.000478854,-1.90642e-07,2.18139e-08,0.92123,0.000478538,-1.25201e-07,-2.58081e-08,0.921708,0.00047821,-2.02625e-07,2.18139e-08,0.922186,0.00047787,-1.37183e-07,-1.84291e-09,0.922664,0.00047759,-1.42712e-07,-1.44423e-08,0.923141,0.000477262,-1.86039e-07,7.34701e-12,0.923618,0.00047689,-1.86017e-07,1.44129e-08,0.924095,0.000476561,-1.42778e-07,1.94572e-09,0.924572,0.000476281,-1.36941e-07,-2.21958e-08,0.925048,0.000475941,-2.03528e-07,2.72327e-08,0.925523,0.000475615,-1.2183e-07,-2.71304e-08,0.925999,0.00047529,-2.03221e-07,2.16843e-08,0.926474,0.000474949,-1.38168e-07,-2.16005e-12,0.926949,0.000474672,-1.38175e-07,-2.16756e-08,0.927423,0.000474331,-2.03202e-07,2.71001e-08,0.927897,0.000474006,-1.21902e-07,-2.71201e-08,0.928371,0.000473681,-2.03262e-07,2.17757e-08,0.928845,0.00047334,-1.37935e-07,-3.78028e-10,0.929318,0.000473063,-1.39069e-07,-2.02636e-08,0.929791,0.000472724,-1.9986e-07,2.18276e-08,0.930263,0.000472389,-1.34377e-07,-7.44231e-09,0.930736,0.000472098,-1.56704e-07,7.94165e-09,0.931208,0.000471809,-1.32879e-07,-2.43243e-08,0.931679,0.00047147,-2.05851e-07,2.97508e-08,0.932151,0.000471148,-1.16599e-07,-3.50742e-08,0.932622,0.000470809,-2.21822e-07,5.09414e-08,0.933092,0.000470518,-6.89976e-08,-4.94821e-08,0.933563,0.000470232,-2.17444e-07,2.77775e-08,0.934033,0.00046988,-1.34111e-07,-2.02351e-09,0.934502,0.000469606,-1.40182e-07,-1.96835e-08,0.934972,0.000469267,-1.99232e-07,2.11529e-08,0.935441,0.000468932,-1.35774e-07,-5.32332e-09,0.93591,0.000468644,-1.51743e-07,1.40413e-10,0.936378,0.000468341,-1.51322e-07,4.76166e-09,0.936846,0.000468053,-1.37037e-07,-1.9187e-08,0.937314,0.000467721,-1.94598e-07,1.23819e-08,0.937782,0.000467369,-1.57453e-07,2.92642e-08,0.938249,0.000467142,-6.96601e-08,-6.98342e-08,0.938716,0.000466793,-2.79163e-07,7.12586e-08,0.939183,0.000466449,-6.53869e-08,-3.63863e-08,0.939649,0.000466209,-1.74546e-07,1.46818e-08,0.940115,0.000465904,-1.305e-07,-2.2341e-08,0.940581,0.000465576,-1.97523e-07,1.50774e-08,0.941046,0.000465226,-1.52291e-07,2.16359e-08,0.941511,0.000464986,-8.73832e-08,-4.20162e-08,0.941976,0.000464685,-2.13432e-07,2.72198e-08,0.942441,0.00046434,-1.31773e-07,-7.2581e-09,0.942905,0.000464055,-1.53547e-07,1.81263e-09,0.943369,0.000463753,-1.48109e-07,7.58386e-12,0.943832,0.000463457,-1.48086e-07,-1.84298e-09,0.944296,0.000463155,-1.53615e-07,7.36433e-09,0.944759,0.00046287,-1.31522e-07,-2.76143e-08,0.945221,0.000462524,-2.14365e-07,4.34883e-08,0.945684,0.000462226,-8.39003e-08,-2.71297e-08,0.946146,0.000461977,-1.65289e-07,5.42595e-09,0.946608,0.000461662,-1.49012e-07,5.42593e-09,0.947069,0.000461381,-1.32734e-07,-2.71297e-08,0.94753,0.000461034,-2.14123e-07,4.34881e-08,0.947991,0.000460736,-8.36585e-08,-2.76134e-08,0.948452,0.000460486,-1.66499e-07,7.36083e-09,0.948912,0.000460175,-1.44416e-07,-1.82993e-09,0.949372,0.000459881,-1.49906e-07,-4.11073e-11,0.949832,0.000459581,-1.50029e-07,1.99434e-09,0.950291,0.000459287,-1.44046e-07,-7.93627e-09,0.950751,0.000458975,-1.67855e-07,2.97507e-08,0.951209,0.000458728,-7.86029e-08,-5.1462e-08,0.951668,0.000458417,-2.32989e-07,5.6888e-08,0.952126,0.000458121,-6.2325e-08,-5.68806e-08,0.952584,0.000457826,-2.32967e-07,5.14251e-08,0.953042,0.000457514,-7.86914e-08,-2.96107e-08,0.953499,0.000457268,-1.67523e-07,7.41296e-09,0.953956,0.000456955,-1.45285e-07,-4.11262e-11,0.954413,0.000456665,-1.45408e-07,-7.24847e-09,0.95487,0.000456352,-1.67153e-07,2.9035e-08,0.955326,0.000456105,-8.00484e-08,-4.92869e-08,0.955782,0.000455797,-2.27909e-07,4.89032e-08,0.956238,0.000455488,-8.11994e-08,-2.71166e-08,0.956693,0.000455244,-1.62549e-07,-4.13678e-11,0.957148,0.000454919,-1.62673e-07,2.72821e-08,0.957603,0.000454675,-8.0827e-08,-4.94824e-08,0.958057,0.000454365,-2.29274e-07,5.14382e-08,0.958512,0.000454061,-7.49597e-08,-3.7061e-08,0.958965,0.0004538,-1.86143e-07,3.72013e-08,0.959419,0.000453539,-7.45389e-08,-5.21396e-08,0.959873,0.000453234,-2.30958e-07,5.21476e-08,0.960326,0.000452928,-7.45146e-08,-3.72416e-08,0.960778,0.000452667,-1.8624e-07,3.72143e-08,0.961231,0.000452407,-7.45967e-08,-5.20109e-08,0.961683,0.000452101,-2.30629e-07,5.16199e-08,0.962135,0.000451795,-7.57696e-08,-3.52595e-08,0.962587,0.000451538,-1.81548e-07,2.98133e-08,0.963038,0.000451264,-9.2108e-08,-2.43892e-08,0.963489,0.000451007,-1.65276e-07,8.13892e-09,0.96394,0.000450701,-1.40859e-07,-8.16647e-09,0.964391,0.000450394,-1.65358e-07,2.45269e-08,0.964841,0.000450137,-9.17775e-08,-3.03367e-08,0.965291,0.000449863,-1.82787e-07,3.7215e-08,0.965741,0.000449609,-7.11424e-08,-5.89188e-08,0.96619,0.00044929,-2.47899e-07,7.92509e-08,0.966639,0.000449032,-1.01462e-08,-7.92707e-08,0.967088,0.000448773,-2.47958e-07,5.90181e-08,0.967537,0.000448455,-7.0904e-08,-3.75925e-08,0.967985,0.0004482,-1.83681e-07,3.17471e-08,0.968433,0.000447928,-8.84401e-08,-2.97913e-08,0.968881,0.000447662,-1.77814e-07,2.78133e-08,0.969329,0.000447389,-9.4374e-08,-2.18572e-08,0.969776,0.000447135,-1.59946e-07,1.10134e-11,0.970223,0.000446815,-1.59913e-07,2.18132e-08,0.97067,0.000446561,-9.44732e-08,-2.76591e-08,0.971116,0.000446289,-1.7745e-07,2.92185e-08,0.971562,0.000446022,-8.97948e-08,-2.96104e-08,0.972008,0.000445753,-1.78626e-07,2.96185e-08,0.972454,0.000445485,-8.97706e-08,-2.92588e-08,0.972899,0.000445218,-1.77547e-07,2.78123e-08,0.973344,0.000444946,-9.41103e-08,-2.23856e-08,0.973789,0.000444691,-1.61267e-07,2.12559e-09,0.974233,0.000444374,-1.5489e-07,1.38833e-08,0.974678,0.000444106,-1.13241e-07,1.94591e-09,0.975122,0.000443886,-1.07403e-07,-2.16669e-08,0.975565,0.000443606,-1.72404e-07,2.5117e-08,0.976009,0.000443336,-9.70526e-08,-1.91963e-08,0.976452,0.000443085,-1.54642e-07,-7.93627e-09,0.976895,0.000442752,-1.7845e-07,5.09414e-08,0.977338,0.000442548,-2.56262e-08,-7.66201e-08,0.97778,0.000442266,-2.55486e-07,7.67249e-08,0.978222,0.000441986,-2.53118e-08,-5.14655e-08,0.978664,0.000441781,-1.79708e-07,9.92773e-09,0.979106,0.000441451,-1.49925e-07,1.17546e-08,0.979547,0.000441186,-1.14661e-07,2.65868e-09,0.979988,0.000440965,-1.06685e-07,-2.23893e-08,0.980429,0.000440684,-1.73853e-07,2.72939e-08,0.980869,0.000440419,-9.19716e-08,-2.71816e-08,0.98131,0.000440153,-1.73516e-07,2.18278e-08,0.98175,0.000439872,-1.08033e-07,-5.24833e-10,0.982189,0.000439654,-1.09607e-07,-1.97284e-08,0.982629,0.000439376,-1.68793e-07,1.98339e-08,0.983068,0.000439097,-1.09291e-07,-2.62901e-12,0.983507,0.000438879,-1.09299e-07,-1.98234e-08,0.983946,0.000438601,-1.68769e-07,1.96916e-08,0.984384,0.000438322,-1.09694e-07,6.6157e-10,0.984823,0.000438105,-1.0771e-07,-2.23379e-08,0.985261,0.000437823,-1.74723e-07,2.90855e-08,0.985698,0.00043756,-8.74669e-08,-3.43992e-08,0.986136,0.000437282,-1.90665e-07,4.89068e-08,0.986573,0.000437048,-4.39442e-08,-4.20188e-08,0.98701,0.000436834,-1.7e-07,-4.11073e-11,0.987446,0.000436494,-1.70124e-07,4.21832e-08,0.987883,0.00043628,-4.35742e-08,-4.94824e-08,0.988319,0.000436044,-1.92021e-07,3.6537e-08,0.988755,0.00043577,-8.24102e-08,-3.70611e-08,0.989191,0.000435494,-1.93593e-07,5.21026e-08,0.989626,0.000435263,-3.72855e-08,-5.21402e-08,0.990061,0.000435032,-1.93706e-07,3.7249e-08,0.990496,0.000434756,-8.19592e-08,-3.72512e-08,0.990931,0.000434481,-1.93713e-07,5.21511e-08,0.991365,0.00043425,-3.72595e-08,-5.21439e-08,0.991799,0.000434019,-1.93691e-07,3.72152e-08,0.992233,0.000433743,-8.20456e-08,-3.71123e-08,0.992667,0.000433468,-1.93382e-07,5.16292e-08,0.9931,0.000433236,-3.84947e-08,-5.01953e-08,0.993533,0.000433008,-1.89081e-07,2.99427e-08,0.993966,0.00043272,-9.92525e-08,-9.9708e-09,0.994399,0.000432491,-1.29165e-07,9.94051e-09,0.994831,0.000432263,-9.93434e-08,-2.97912e-08,0.995263,0.000431975,-1.88717e-07,4.96198e-08,0.995695,0.000431746,-3.98578e-08,-4.94785e-08,0.996127,0.000431518,-1.88293e-07,2.9085e-08,0.996558,0.000431229,-1.01038e-07,-7.25675e-09,0.996989,0.000431005,-1.22809e-07,-5.79945e-11,0.99742,0.000430759,-1.22983e-07,7.48873e-09,0.997851,0.000430536,-1.00516e-07,-2.98969e-08,0.998281,0.000430245,-1.90207e-07,5.24942e-08,0.998711,0.000430022,-3.27246e-08,-6.08706e-08,0.999141,0.000429774,-2.15336e-07,7.17788e-08,0.999571,0.000429392,0.,0.}; template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB; template <int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float lThresh = 0.008856f * 903.3f; const float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f; float Y, fy; if (src.x <= lThresh) { Y = src.x / 903.3f; fy = 7.787f * Y + 16.0f / 116.0f; } else { fy = (src.x + 16.0f) / 116.0f; Y = fy * fy * fy; } float X = src.y / 500.0f + fy; float Z = fy - src.z / 200.0f; if (X <= fThresh) X = (X - 16.0f / 116.0f) / 7.787f; else X = X * X * X; if (Z <= fThresh) Z = (Z - 16.0f / 116.0f) / 7.787f; else Z = Z * Z * Z; float B = 0.052891f * X - 0.204043f * Y + 1.151152f * Z; float G = -0.921235f * X + 1.875991f * Y + 0.045244f * Z; float R = 3.079933f * X - 1.537150f * Y - 0.542782f * Z; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); } typename MakeVec<float, dcn>::type dst; dst.x = blueIdx == 0 ? B : R; dst.y = G; dst.z = blueIdx == 0 ? R : B; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (100.f / 255.f); buf.y = src.y - 128; buf.z = src.z - 128; Lab2RGB<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to Luv static __constant__ float c_LabCbrtTab[] = {0.137931,0.0114066,0.,1.18859e-07,0.149338,0.011407,3.56578e-07,-5.79396e-07,0.160745,0.0114059,-1.38161e-06,2.16892e-06,0.172151,0.0114097,5.12516e-06,-8.0814e-06,0.183558,0.0113957,-1.9119e-05,3.01567e-05,0.194965,0.0114479,7.13509e-05,-0.000112545,0.206371,0.011253,-0.000266285,-0.000106493,0.217252,0.0104009,-0.000585765,7.32149e-05,0.22714,0.00944906,-0.00036612,1.21917e-05,0.236235,0.0087534,-0.000329545,2.01753e-05,0.244679,0.00815483,-0.000269019,1.24435e-05,0.252577,0.00765412,-0.000231689,1.05618e-05,0.26001,0.00722243,-0.000200003,8.26662e-06,0.267041,0.00684723,-0.000175203,6.76746e-06,0.27372,0.00651712,-0.000154901,5.61192e-06,0.280088,0.00622416,-0.000138065,4.67009e-06,0.286179,0.00596204,-0.000124055,3.99012e-06,0.292021,0.0057259,-0.000112085,3.36032e-06,0.297638,0.00551181,-0.000102004,2.95338e-06,0.30305,0.00531666,-9.31435e-05,2.52875e-06,0.308277,0.00513796,-8.55572e-05,2.22022e-06,0.313331,0.00497351,-7.88966e-05,1.97163e-06,0.318228,0.00482163,-7.29817e-05,1.7248e-06,0.322978,0.00468084,-6.78073e-05,1.55998e-06,0.327593,0.0045499,-6.31274e-05,1.36343e-06,0.332081,0.00442774,-5.90371e-05,1.27136e-06,0.336451,0.00431348,-5.5223e-05,1.09111e-06,0.34071,0.00420631,-5.19496e-05,1.0399e-06,0.344866,0.00410553,-4.88299e-05,9.18347e-07,0.348923,0.00401062,-4.60749e-05,8.29942e-07,0.352889,0.00392096,-4.35851e-05,7.98478e-07,0.356767,0.00383619,-4.11896e-05,6.84917e-07,0.360562,0.00375586,-3.91349e-05,6.63976e-07,0.36428,0.00367959,-3.7143e-05,5.93086e-07,0.367923,0.00360708,-3.53637e-05,5.6976e-07,0.371495,0.00353806,-3.36544e-05,4.95533e-07,0.375,0.00347224,-3.21678e-05,4.87951e-07,0.378441,0.00340937,-3.0704e-05,4.4349e-07,0.38182,0.00334929,-2.93735e-05,4.20297e-07,0.38514,0.0032918,-2.81126e-05,3.7872e-07,0.388404,0.00323671,-2.69764e-05,3.596e-07,0.391614,0.00318384,-2.58976e-05,3.5845e-07,0.394772,0.00313312,-2.48223e-05,2.92765e-07,0.397881,0.00308435,-2.3944e-05,3.18232e-07,0.400942,0.00303742,-2.29893e-05,2.82046e-07,0.403957,0.00299229,-2.21432e-05,2.52315e-07,0.406927,0.00294876,-2.13862e-05,2.58416e-07,0.409855,0.00290676,-2.0611e-05,2.33939e-07,0.412741,0.00286624,-1.99092e-05,2.36342e-07,0.415587,0.00282713,-1.92001e-05,1.916e-07,0.418396,0.00278931,-1.86253e-05,2.1915e-07,0.421167,0.00275271,-1.79679e-05,1.83498e-07,0.423901,0.00271733,-1.74174e-05,1.79343e-07,0.426602,0.00268303,-1.68794e-05,1.72013e-07,0.429268,0.00264979,-1.63633e-05,1.75686e-07,0.431901,0.00261759,-1.58363e-05,1.3852e-07,0.434503,0.00258633,-1.54207e-05,1.64304e-07,0.437074,0.00255598,-1.49278e-05,1.28136e-07,0.439616,0.00252651,-1.45434e-05,1.57618e-07,0.442128,0.0024979,-1.40705e-05,1.0566e-07,0.444612,0.00247007,-1.37535e-05,1.34998e-07,0.447068,0.00244297,-1.33485e-05,1.29207e-07,0.449498,0.00241666,-1.29609e-05,9.32347e-08,0.451902,0.00239102,-1.26812e-05,1.23703e-07,0.45428,0.00236603,-1.23101e-05,9.74072e-08,0.456634,0.0023417,-1.20179e-05,1.12518e-07,0.458964,0.002318,-1.16803e-05,7.83681e-08,0.46127,0.00229488,-1.14452e-05,1.10452e-07,0.463554,0.00227232,-1.11139e-05,7.58719e-08,0.465815,0.00225032,-1.08863e-05,9.2699e-08,0.468055,0.00222882,-1.06082e-05,8.97738e-08,0.470273,0.00220788,-1.03388e-05,5.4845e-08,0.47247,0.00218736,-1.01743e-05,1.0808e-07,0.474648,0.00216734,-9.85007e-06,4.9277e-08,0.476805,0.00214779,-9.70224e-06,8.22408e-08,0.478943,0.00212863,-9.45551e-06,6.87942e-08,0.481063,0.00210993,-9.24913e-06,5.98144e-08,0.483163,0.00209161,-9.06969e-06,7.93789e-08,0.485246,0.00207371,-8.83155e-06,3.99032e-08,0.487311,0.00205616,-8.71184e-06,8.88325e-08,0.489358,0.002039,-8.44534e-06,2.20004e-08,0.491389,0.00202218,-8.37934e-06,9.13872e-08,0.493403,0.0020057,-8.10518e-06,2.96829e-08,0.495401,0.00198957,-8.01613e-06,5.81028e-08,0.497382,0.00197372,-7.84183e-06,6.5731e-08,0.499348,0.00195823,-7.64463e-06,3.66019e-08,0.501299,0.00194305,-7.53483e-06,2.62811e-08,0.503234,0.00192806,-7.45598e-06,9.66907e-08,0.505155,0.00191344,-7.16591e-06,4.18928e-09,0.507061,0.00189912,-7.15334e-06,6.53665e-08,0.508953,0.00188501,-6.95724e-06,3.23686e-08,0.510831,0.00187119,-6.86014e-06,4.35774e-08,0.512696,0.0018576,-6.72941e-06,3.17406e-08,0.514547,0.00184424,-6.63418e-06,6.78785e-08,0.516384,0.00183117,-6.43055e-06,-5.23126e-09,0.518209,0.0018183,-6.44624e-06,7.22562e-08,0.520021,0.00180562,-6.22947e-06,1.42292e-08,0.52182,0.0017932,-6.18679e-06,4.9641e-08,0.523607,0.00178098,-6.03786e-06,2.56259e-08,0.525382,0.00176898,-5.96099e-06,2.66696e-08,0.527145,0.00175714,-5.88098e-06,4.65094e-08,0.528897,0.00174552,-5.74145e-06,2.57114e-08,0.530637,0.00173411,-5.66431e-06,2.94588e-08,0.532365,0.00172287,-5.57594e-06,3.52667e-08,0.534082,0.00171182,-5.47014e-06,8.28868e-09,0.535789,0.00170091,-5.44527e-06,5.07871e-08,0.537484,0.00169017,-5.29291e-06,2.69817e-08,0.539169,0.00167967,-5.21197e-06,2.01009e-08,0.540844,0.0016693,-5.15166e-06,1.18237e-08,0.542508,0.00165903,-5.11619e-06,5.18135e-08,0.544162,0.00164896,-4.96075e-06,1.9341e-08,0.545806,0.00163909,-4.90273e-06,-9.96867e-09,0.54744,0.00162926,-4.93263e-06,8.01382e-08,0.549064,0.00161963,-4.69222e-06,-1.25601e-08,0.550679,0.00161021,-4.7299e-06,2.97067e-08,0.552285,0.00160084,-4.64078e-06,1.29426e-08,0.553881,0.0015916,-4.60195e-06,3.77327e-08,0.555468,0.00158251,-4.48875e-06,1.49412e-08,0.557046,0.00157357,-4.44393e-06,2.17118e-08,0.558615,0.00156475,-4.3788e-06,1.74206e-08,0.560176,0.00155605,-4.32653e-06,2.78152e-08,0.561727,0.00154748,-4.24309e-06,-9.47239e-09,0.563271,0.00153896,-4.27151e-06,6.9679e-08,0.564805,0.00153063,-4.06247e-06,-3.08246e-08,0.566332,0.00152241,-4.15494e-06,5.36188e-08,0.56785,0.00151426,-3.99409e-06,-4.83594e-09,0.56936,0.00150626,-4.00859e-06,2.53293e-08,0.570863,0.00149832,-3.93261e-06,2.27286e-08,0.572357,0.00149052,-3.86442e-06,2.96541e-09,0.573844,0.0014828,-3.85552e-06,2.50147e-08,0.575323,0.00147516,-3.78048e-06,1.61842e-08,0.576794,0.00146765,-3.73193e-06,2.94582e-08,0.578258,0.00146028,-3.64355e-06,-1.48076e-08,0.579715,0.00145295,-3.68798e-06,2.97724e-08,0.581164,0.00144566,-3.59866e-06,1.49272e-08,0.582606,0.00143851,-3.55388e-06,2.97285e-08,0.584041,0.00143149,-3.46469e-06,-1.46323e-08,0.585469,0.00142451,-3.50859e-06,2.88004e-08,0.58689,0.00141758,-3.42219e-06,1.864e-08,0.588304,0.00141079,-3.36627e-06,1.58482e-08,0.589712,0.00140411,-3.31872e-06,-2.24279e-08,0.591112,0.00139741,-3.38601e-06,7.38639e-08,0.592507,0.00139085,-3.16441e-06,-3.46088e-08,0.593894,0.00138442,-3.26824e-06,4.96675e-09,0.595275,0.0013779,-3.25334e-06,7.4346e-08,0.59665,0.00137162,-3.0303e-06,-6.39319e-08,0.598019,0.00136536,-3.2221e-06,6.21725e-08,0.599381,0.00135911,-3.03558e-06,-5.94423e-09,0.600737,0.00135302,-3.05341e-06,2.12091e-08,0.602087,0.00134697,-2.98979e-06,-1.92876e-08,0.603431,0.00134094,-3.04765e-06,5.5941e-08,0.604769,0.00133501,-2.87983e-06,-2.56622e-08,0.606101,0.00132917,-2.95681e-06,4.67078e-08,0.607427,0.0013234,-2.81669e-06,-4.19592e-08,0.608748,0.00131764,-2.94257e-06,6.15243e-08,0.610062,0.00131194,-2.75799e-06,-2.53244e-08,0.611372,0.00130635,-2.83397e-06,3.97739e-08,0.612675,0.0013008,-2.71465e-06,-1.45618e-08,0.613973,0.00129533,-2.75833e-06,1.84733e-08,0.615266,0.00128986,-2.70291e-06,2.73606e-10,0.616553,0.00128446,-2.70209e-06,4.00367e-08,0.617835,0.00127918,-2.58198e-06,-4.12113e-08,0.619111,0.00127389,-2.70561e-06,6.52039e-08,0.620383,0.00126867,-2.51e-06,-4.07901e-08,0.621649,0.00126353,-2.63237e-06,3.83516e-08,0.62291,0.00125838,-2.51732e-06,6.59315e-09,0.624166,0.00125337,-2.49754e-06,-5.11939e-09,0.625416,0.00124836,-2.5129e-06,1.38846e-08,0.626662,0.00124337,-2.47124e-06,9.18514e-09,0.627903,0.00123846,-2.44369e-06,8.97952e-09,0.629139,0.0012336,-2.41675e-06,1.45012e-08,0.63037,0.00122881,-2.37325e-06,-7.37949e-09,0.631597,0.00122404,-2.39538e-06,1.50169e-08,0.632818,0.00121929,-2.35033e-06,6.91648e-09,0.634035,0.00121461,-2.32958e-06,1.69219e-08,0.635248,0.00121,-2.27882e-06,-1.49997e-08,0.636455,0.0012054,-2.32382e-06,4.30769e-08,0.637659,0.00120088,-2.19459e-06,-3.80986e-08,0.638857,0.00119638,-2.30888e-06,4.97134e-08,0.640051,0.00119191,-2.15974e-06,-4.15463e-08,0.641241,0.00118747,-2.28438e-06,5.68667e-08,0.642426,0.00118307,-2.11378e-06,-7.10641e-09,0.643607,0.00117882,-2.1351e-06,-2.8441e-08,0.644784,0.00117446,-2.22042e-06,6.12658e-08,0.645956,0.00117021,-2.03663e-06,-3.78083e-08,0.647124,0.00116602,-2.15005e-06,3.03627e-08,0.648288,0.00116181,-2.05896e-06,-2.40379e-08,0.649448,0.00115762,-2.13108e-06,6.57887e-08,0.650603,0.00115356,-1.93371e-06,-6.03028e-08,0.651755,0.00114951,-2.11462e-06,5.62134e-08,0.652902,0.00114545,-1.94598e-06,-4.53417e-08,0.654046,0.00114142,-2.082e-06,6.55489e-08,0.655185,0.00113745,-1.88536e-06,-3.80396e-08,0.656321,0.00113357,-1.99948e-06,2.70049e-08,0.657452,0.00112965,-1.91846e-06,-1.03755e-08,0.65858,0.00112578,-1.94959e-06,1.44973e-08,0.659704,0.00112192,-1.9061e-06,1.1991e-08,0.660824,0.00111815,-1.87012e-06,-2.85634e-09,0.66194,0.0011144,-1.87869e-06,-5.65782e-10,0.663053,0.00111064,-1.88039e-06,5.11947e-09,0.664162,0.0011069,-1.86503e-06,3.96924e-08,0.665267,0.00110328,-1.74595e-06,-4.46795e-08,0.666368,0.00109966,-1.87999e-06,1.98161e-08,0.667466,0.00109596,-1.82054e-06,2.502e-08,0.66856,0.00109239,-1.74548e-06,-6.86593e-10,0.669651,0.0010889,-1.74754e-06,-2.22739e-08,0.670738,0.00108534,-1.81437e-06,3.01776e-08,0.671821,0.0010818,-1.72383e-06,2.07732e-08,0.672902,0.00107841,-1.66151e-06,-5.36658e-08,0.673978,0.00107493,-1.82251e-06,7.46802e-08,0.675051,0.00107151,-1.59847e-06,-6.62411e-08,0.676121,0.00106811,-1.79719e-06,7.10748e-08,0.677188,0.00106473,-1.58397e-06,-3.92441e-08,0.678251,0.00106145,-1.7017e-06,2.62973e-08,0.679311,0.00105812,-1.62281e-06,-6.34035e-09,0.680367,0.00105486,-1.64183e-06,-9.36249e-10,0.68142,0.00105157,-1.64464e-06,1.00854e-08,0.68247,0.00104831,-1.61438e-06,2.01995e-08,0.683517,0.00104514,-1.55378e-06,-3.1279e-08,0.68456,0.00104194,-1.64762e-06,4.53114e-08,0.685601,0.00103878,-1.51169e-06,-3.07573e-08,0.686638,0.00103567,-1.60396e-06,1.81133e-08,0.687672,0.00103251,-1.54962e-06,1.79085e-08,0.688703,0.00102947,-1.49589e-06,-3.01428e-08,0.689731,0.00102639,-1.58632e-06,4.30583e-08,0.690756,0.00102334,-1.45715e-06,-2.28814e-08,0.691778,0.00102036,-1.52579e-06,-1.11373e-08,0.692797,0.00101727,-1.5592e-06,6.74305e-08,0.693812,0.00101436,-1.35691e-06,-7.97709e-08,0.694825,0.0010114,-1.59622e-06,7.28391e-08,0.695835,0.00100843,-1.37771e-06,-3.27715e-08,0.696842,0.00100558,-1.47602e-06,-1.35807e-09,0.697846,0.00100262,-1.48009e-06,3.82037e-08,0.698847,0.000999775,-1.36548e-06,-3.22474e-08,0.699846,0.000996948,-1.46223e-06,3.11809e-08,0.700841,0.000994117,-1.36868e-06,-3.28714e-08,0.701834,0.000991281,-1.4673e-06,4.07001e-08,0.702824,0.000988468,-1.3452e-06,-1.07197e-08,0.703811,0.000985746,-1.37736e-06,2.17866e-09,0.704795,0.000982998,-1.37082e-06,2.00521e-09,0.705777,0.000980262,-1.3648e-06,-1.01996e-08,0.706756,0.000977502,-1.3954e-06,3.87931e-08,0.707732,0.000974827,-1.27902e-06,-2.57632e-08,0.708706,0.000972192,-1.35631e-06,4.65513e-09,0.709676,0.000969493,-1.34235e-06,7.14257e-09,0.710645,0.00096683,-1.32092e-06,2.63791e-08,0.71161,0.000964267,-1.24178e-06,-5.30543e-08,0.712573,0.000961625,-1.40095e-06,6.66289e-08,0.713533,0.000959023,-1.20106e-06,-3.46474e-08,0.714491,0.000956517,-1.305e-06,1.23559e-08,0.715446,0.000953944,-1.26793e-06,-1.47763e-08,0.716399,0.000951364,-1.31226e-06,4.67494e-08,0.717349,0.000948879,-1.17201e-06,-5.3012e-08,0.718297,0.000946376,-1.33105e-06,4.60894e-08,0.719242,0.000943852,-1.19278e-06,-1.21366e-08,0.720185,0.00094143,-1.22919e-06,2.45673e-09,0.721125,0.000938979,-1.22182e-06,2.30966e-09,0.722063,0.000936543,-1.21489e-06,-1.16954e-08,0.722998,0.000934078,-1.24998e-06,4.44718e-08,0.723931,0.000931711,-1.11656e-06,-4.69823e-08,0.724861,0.000929337,-1.25751e-06,2.4248e-08,0.725789,0.000926895,-1.18477e-06,9.5949e-09,0.726715,0.000924554,-1.15598e-06,-3.02286e-09,0.727638,0.000922233,-1.16505e-06,2.49649e-09,0.72856,0.00091991,-1.15756e-06,-6.96321e-09,0.729478,0.000917575,-1.17845e-06,2.53564e-08,0.730395,0.000915294,-1.10238e-06,-3.48578e-08,0.731309,0.000912984,-1.20695e-06,5.44704e-08,0.732221,0.000910734,-1.04354e-06,-6.38144e-08,0.73313,0.000908455,-1.23499e-06,8.15781e-08,0.734038,0.00090623,-9.90253e-07,-8.3684e-08,0.734943,0.000903999,-1.2413e-06,7.43441e-08,0.735846,0.000901739,-1.01827e-06,-3.48787e-08,0.736746,0.000899598,-1.12291e-06,5.56596e-09,0.737645,0.000897369,-1.10621e-06,1.26148e-08,0.738541,0.000895194,-1.06837e-06,3.57935e-09,0.739435,0.000893068,-1.05763e-06,-2.69322e-08,0.740327,0.000890872,-1.13842e-06,4.45448e-08,0.741217,0.000888729,-1.00479e-06,-3.20376e-08,0.742105,0.000886623,-1.1009e-06,2.40011e-08,0.74299,0.000884493,-1.0289e-06,-4.36209e-09,0.743874,0.000882422,-1.04199e-06,-6.55268e-09,0.744755,0.000880319,-1.06164e-06,3.05728e-08,0.745634,0.000878287,-9.69926e-07,-5.61338e-08,0.746512,0.000876179,-1.13833e-06,7.4753e-08,0.747387,0.000874127,-9.14068e-07,-6.40644e-08,0.74826,0.000872106,-1.10626e-06,6.22955e-08,0.749131,0.000870081,-9.19375e-07,-6.59083e-08,0.75,0.000868044,-1.1171e-06,8.21284e-08,0.750867,0.000866056,-8.70714e-07,-8.37915e-08,0.751732,0.000864064,-1.12209e-06,7.42237e-08,0.752595,0.000862042,-8.99418e-07,-3.42894e-08,0.753456,0.00086014,-1.00229e-06,3.32955e-09,0.754315,0.000858146,-9.92297e-07,2.09712e-08,0.755173,0.000856224,-9.29384e-07,-2.76096e-08,0.756028,0.000854282,-1.01221e-06,2.98627e-08,0.756881,0.000852348,-9.22625e-07,-3.22365e-08,0.757733,0.000850406,-1.01933e-06,3.94786e-08,0.758582,0.000848485,-9.00898e-07,-6.46833e-09,0.75943,0.000846664,-9.20303e-07,-1.36052e-08,0.760275,0.000844783,-9.61119e-07,1.28447e-09,0.761119,0.000842864,-9.57266e-07,8.4674e-09,0.761961,0.000840975,-9.31864e-07,2.44506e-08,0.762801,0.000839185,-8.58512e-07,-4.6665e-08,0.763639,0.000837328,-9.98507e-07,4.30001e-08,0.764476,0.00083546,-8.69507e-07,-6.12609e-09,0.76531,0.000833703,-8.87885e-07,-1.84959e-08,0.766143,0.000831871,-9.43372e-07,2.05052e-08,0.766974,0.000830046,-8.81857e-07,-3.92026e-09,0.767803,0.000828271,-8.93618e-07,-4.82426e-09,0.768631,0.000826469,-9.0809e-07,2.32172e-08,0.769456,0.000824722,-8.38439e-07,-2.84401e-08,0.77028,0.00082296,-9.23759e-07,3.09386e-08,0.771102,0.000821205,-8.30943e-07,-3.57099e-08,0.771922,0.000819436,-9.38073e-07,5.22963e-08,0.772741,0.000817717,-7.81184e-07,-5.42658e-08,0.773558,0.000815992,-9.43981e-07,4.55579e-08,0.774373,0.000814241,-8.07308e-07,-8.75656e-09,0.775186,0.0008126,-8.33578e-07,-1.05315e-08,0.775998,0.000810901,-8.65172e-07,-8.72188e-09,0.776808,0.000809145,-8.91338e-07,4.54191e-08,0.777616,0.000807498,-7.5508e-07,-5.37454e-08,0.778423,0.000805827,-9.16317e-07,5.03532e-08,0.779228,0.000804145,-7.65257e-07,-2.84584e-08,0.780031,0.000802529,-8.50632e-07,3.87579e-09,0.780833,0.00080084,-8.39005e-07,1.29552e-08,0.781633,0.0007992,-8.00139e-07,3.90804e-09,0.782432,0.000797612,-7.88415e-07,-2.85874e-08,0.783228,0.000795949,-8.74177e-07,5.0837e-08,0.784023,0.000794353,-7.21666e-07,-5.55513e-08,0.784817,0.000792743,-8.8832e-07,5.21587e-08,0.785609,0.000791123,-7.31844e-07,-3.38744e-08,0.786399,0.000789558,-8.33467e-07,2.37342e-08,0.787188,0.000787962,-7.62264e-07,-1.45775e-09,0.787975,0.000786433,-7.66638e-07,-1.79034e-08,0.788761,0.000784846,-8.20348e-07,1.34665e-08,0.789545,0.000783246,-7.79948e-07,2.3642e-08,0.790327,0.000781757,-7.09022e-07,-4.84297e-08,0.791108,0.000780194,-8.54311e-07,5.08674e-08,0.791888,0.000778638,-7.01709e-07,-3.58303e-08,0.792666,0.000777127,-8.092e-07,3.28493e-08,0.793442,0.000775607,-7.10652e-07,-3.59624e-08,0.794217,0.000774078,-8.1854e-07,5.13959e-08,0.79499,0.000772595,-6.64352e-07,-5.04121e-08,0.795762,0.000771115,-8.15588e-07,3.10431e-08,0.796532,0.000769577,-7.22459e-07,-1.41557e-08,0.797301,0.00076809,-7.64926e-07,2.55795e-08,0.798069,0.000766636,-6.88187e-07,-2.85578e-08,0.798835,0.000765174,-7.73861e-07,2.90472e-08,0.799599,0.000763714,-6.86719e-07,-2.80262e-08,0.800362,0.000762256,-7.70798e-07,2.34531e-08,0.801123,0.000760785,-7.00438e-07,-6.18144e-09,0.801884,0.000759366,-7.18983e-07,1.27263e-09,0.802642,0.000757931,-7.15165e-07,1.09101e-09,0.803399,0.000756504,-7.11892e-07,-5.63675e-09,0.804155,0.000755064,-7.28802e-07,2.14559e-08,0.80491,0.00075367,-6.64434e-07,-2.05821e-08,0.805663,0.00075228,-7.26181e-07,1.26812e-09,0.806414,0.000750831,-7.22377e-07,1.55097e-08,0.807164,0.000749433,-6.75848e-07,-3.70216e-09,0.807913,0.00074807,-6.86954e-07,-7.0105e-10,0.80866,0.000746694,-6.89057e-07,6.5063e-09,0.809406,0.000745336,-6.69538e-07,-2.53242e-08,0.810151,0.000743921,-7.45511e-07,3.51858e-08,0.810894,0.000742535,-6.39953e-07,3.79034e-09,0.811636,0.000741267,-6.28582e-07,-5.03471e-08,0.812377,0.000739858,-7.79624e-07,7.83886e-08,0.813116,0.000738534,-5.44458e-07,-8.43935e-08,0.813854,0.000737192,-7.97638e-07,8.03714e-08,0.81459,0.000735838,-5.56524e-07,-5.82784e-08,0.815325,0.00073455,-7.31359e-07,3.35329e-08,0.816059,0.000733188,-6.3076e-07,-1.62486e-08,0.816792,0.000731878,-6.79506e-07,3.14614e-08,0.817523,0.000730613,-5.85122e-07,-4.99925e-08,0.818253,0.000729293,-7.35099e-07,4.92994e-08,0.818982,0.000727971,-5.87201e-07,-2.79959e-08,0.819709,0.000726712,-6.71189e-07,3.07959e-09,0.820435,0.000725379,-6.6195e-07,1.56777e-08,0.82116,0.000724102,-6.14917e-07,-6.18564e-09,0.821883,0.000722854,-6.33474e-07,9.06488e-09,0.822606,0.000721614,-6.06279e-07,-3.00739e-08,0.823327,0.000720311,-6.96501e-07,5.16262e-08,0.824046,0.000719073,-5.41623e-07,-5.72214e-08,0.824765,0.000717818,-7.13287e-07,5.80503e-08,0.825482,0.000716566,-5.39136e-07,-5.57703e-08,0.826198,0.00071532,-7.06447e-07,4.58215e-08,0.826912,0.000714045,-5.68983e-07,-8.30636e-09,0.827626,0.000712882,-5.93902e-07,-1.25961e-08,0.828338,0.000711656,-6.3169e-07,-9.13985e-10,0.829049,0.00071039,-6.34432e-07,1.62519e-08,0.829759,0.00070917,-5.85676e-07,-4.48904e-09,0.830468,0.000707985,-5.99143e-07,1.70418e-09,0.831175,0.000706792,-5.9403e-07,-2.32768e-09,0.831881,0.000705597,-6.01014e-07,7.60648e-09,0.832586,0.000704418,-5.78194e-07,-2.80982e-08,0.83329,0.000703177,-6.62489e-07,4.51817e-08,0.833993,0.000701988,-5.26944e-07,-3.34192e-08,0.834694,0.000700834,-6.27201e-07,2.88904e-08,0.835394,0.000699666,-5.4053e-07,-2.25378e-08,0.836093,0.000698517,-6.08143e-07,1.65589e-09,0.836791,0.000697306,-6.03176e-07,1.59142e-08,0.837488,0.000696147,-5.55433e-07,-5.70801e-09,0.838184,0.000695019,-5.72557e-07,6.91792e-09,0.838878,0.000693895,-5.51803e-07,-2.19637e-08,0.839571,0.000692725,-6.17694e-07,2.13321e-08,0.840263,0.000691554,-5.53698e-07,-3.75996e-09,0.840954,0.000690435,-5.64978e-07,-6.29219e-09,0.841644,0.000689287,-5.83855e-07,2.89287e-08,0.842333,0.000688206,-4.97068e-07,-4.98181e-08,0.843021,0.000687062,-6.46523e-07,5.11344e-08,0.843707,0.000685922,-4.9312e-07,-3.55102e-08,0.844393,0.00068483,-5.9965e-07,3.13019e-08,0.845077,0.000683724,-5.05745e-07,-3.00925e-08,0.84576,0.000682622,-5.96022e-07,2.94636e-08,0.846442,0.000681519,-5.07631e-07,-2.81572e-08,0.847123,0.000680419,-5.92103e-07,2.35606e-08,0.847803,0.000679306,-5.21421e-07,-6.48045e-09,0.848482,0.000678243,-5.40863e-07,2.36124e-09,0.849159,0.000677169,-5.33779e-07,-2.96461e-09,0.849836,0.000676092,-5.42673e-07,9.49728e-09,0.850512,0.000675035,-5.14181e-07,-3.50245e-08,0.851186,0.000673902,-6.19254e-07,7.09959e-08,0.851859,0.000672876,-4.06267e-07,-7.01453e-08,0.852532,0.000671853,-6.16703e-07,3.07714e-08,0.853203,0.000670712,-5.24388e-07,6.66423e-09,0.853873,0.000669684,-5.04396e-07,2.17629e-09,0.854542,0.000668681,-4.97867e-07,-1.53693e-08,0.855211,0.000667639,-5.43975e-07,-3.03752e-10,0.855878,0.000666551,-5.44886e-07,1.65844e-08,0.856544,0.000665511,-4.95133e-07,-6.42907e-09,0.857209,0.000664501,-5.1442e-07,9.13195e-09,0.857873,0.0006635,-4.87024e-07,-3.00987e-08,0.858536,0.000662435,-5.7732e-07,5.16584e-08,0.859198,0.000661436,-4.22345e-07,-5.73255e-08,0.859859,0.000660419,-5.94322e-07,5.84343e-08,0.860518,0.000659406,-4.19019e-07,-5.72022e-08,0.861177,0.000658396,-5.90626e-07,5.11653e-08,0.861835,0.000657368,-4.3713e-07,-2.82495e-08,0.862492,0.000656409,-5.21878e-07,2.22788e-09,0.863148,0.000655372,-5.15195e-07,1.9338e-08,0.863803,0.0006544,-4.5718e-07,-1.99754e-08,0.864457,0.000653425,-5.17107e-07,9.59024e-10,0.86511,0.000652394,-5.1423e-07,1.61393e-08,0.865762,0.000651414,-4.65812e-07,-5.91149e-09,0.866413,0.000650465,-4.83546e-07,7.50665e-09,0.867063,0.00064952,-4.61026e-07,-2.4115e-08,0.867712,0.000648526,-5.33371e-07,2.93486e-08,0.86836,0.000647547,-4.45325e-07,-3.36748e-08,0.869007,0.000646555,-5.4635e-07,4.57461e-08,0.869653,0.0006456,-4.09112e-07,-3.01002e-08,0.870298,0.000644691,-4.99412e-07,1.50501e-08,0.870942,0.000643738,-4.54262e-07,-3.01002e-08,0.871585,0.000642739,-5.44563e-07,4.57461e-08,0.872228,0.000641787,-4.07324e-07,-3.36748e-08,0.872869,0.000640871,-5.08349e-07,2.93486e-08,0.873509,0.000639943,-4.20303e-07,-2.4115e-08,0.874149,0.00063903,-4.92648e-07,7.50655e-09,0.874787,0.000638067,-4.70128e-07,-5.91126e-09,0.875425,0.000637109,-4.87862e-07,1.61385e-08,0.876062,0.000636182,-4.39447e-07,9.61961e-10,0.876697,0.000635306,-4.36561e-07,-1.99863e-08,0.877332,0.000634373,-4.9652e-07,1.93785e-08,0.877966,0.000633438,-4.38384e-07,2.07697e-09,0.878599,0.000632567,-4.32153e-07,-2.76864e-08,0.879231,0.00063162,-5.15212e-07,4.90641e-08,0.879862,0.000630737,-3.6802e-07,-4.93606e-08,0.880493,0.000629852,-5.16102e-07,2.9169e-08,0.881122,0.000628908,-4.28595e-07,-7.71083e-09,0.881751,0.000628027,-4.51727e-07,1.6744e-09,0.882378,0.000627129,-4.46704e-07,1.01317e-09,0.883005,0.000626239,-4.43665e-07,-5.72703e-09,0.883631,0.000625334,-4.60846e-07,2.1895e-08,0.884255,0.000624478,-3.95161e-07,-2.22481e-08,0.88488,0.000623621,-4.61905e-07,7.4928e-09,0.885503,0.00062272,-4.39427e-07,-7.72306e-09,0.886125,0.000621818,-4.62596e-07,2.33995e-08,0.886746,0.000620963,-3.92398e-07,-2.62704e-08,0.887367,0.000620099,-4.71209e-07,2.20775e-08,0.887987,0.000619223,-4.04976e-07,-2.43496e-09,0.888605,0.000618406,-4.12281e-07,-1.23377e-08,0.889223,0.000617544,-4.49294e-07,-7.81876e-09,0.88984,0.000616622,-4.72751e-07,4.36128e-08,0.890457,0.000615807,-3.41912e-07,-4.7423e-08,0.891072,0.000614981,-4.84181e-07,2.68698e-08,0.891687,0.000614093,-4.03572e-07,-4.51384e-10,0.8923,0.000613285,-4.04926e-07,-2.50643e-08,0.892913,0.0006124,-4.80119e-07,4.11038e-08,0.893525,0.000611563,-3.56808e-07,-2.01414e-08,0.894136,0.000610789,-4.17232e-07,-2.01426e-08,0.894747,0.000609894,-4.7766e-07,4.11073e-08,0.895356,0.000609062,-3.54338e-07,-2.50773e-08,0.895965,0.000608278,-4.2957e-07,-4.02954e-10,0.896573,0.000607418,-4.30779e-07,2.66891e-08,0.89718,0.000606636,-3.50711e-07,-4.67489e-08,0.897786,0.000605795,-4.90958e-07,4.10972e-08,0.898391,0.000604936,-3.67666e-07,1.56948e-09,0.898996,0.000604205,-3.62958e-07,-4.73751e-08,0.8996,0.000603337,-5.05083e-07,6.87214e-08,0.900202,0.000602533,-2.98919e-07,-4.86966e-08,0.900805,0.000601789,-4.45009e-07,6.85589e-09,0.901406,0.00060092,-4.24441e-07,2.1273e-08,0.902007,0.000600135,-3.60622e-07,-3.23434e-08,0.902606,0.000599317,-4.57652e-07,4.84959e-08,0.903205,0.000598547,-3.12164e-07,-4.24309e-08,0.903803,0.000597795,-4.39457e-07,2.01844e-09,0.904401,0.000596922,-4.33402e-07,3.43571e-08,0.904997,0.000596159,-3.30331e-07,-2.02374e-08,0.905593,0.000595437,-3.91043e-07,-1.30123e-08,0.906188,0.000594616,-4.3008e-07,1.26819e-08,0.906782,0.000593794,-3.92034e-07,2.18894e-08,0.907376,0.000593076,-3.26366e-07,-4.06349e-08,0.907968,0.000592301,-4.4827e-07,2.1441e-08,0.90856,0.000591469,-3.83947e-07,1.44754e-08,0.909151,0.000590744,-3.40521e-07,-1.97379e-08,0.909742,0.000590004,-3.99735e-07,4.87161e-09,0.910331,0.000589219,-3.8512e-07,2.51532e-10,0.91092,0.00058845,-3.84366e-07,-5.87776e-09,0.911508,0.000587663,-4.01999e-07,2.32595e-08,0.912096,0.000586929,-3.3222e-07,-2.75554e-08,0.912682,0.000586182,-4.14887e-07,2.73573e-08,0.913268,0.000585434,-3.32815e-07,-2.22692e-08,0.913853,0.000584702,-3.99622e-07,2.11486e-09,0.914437,0.000583909,-3.93278e-07,1.38098e-08,0.915021,0.000583164,-3.51848e-07,2.25042e-09,0.915604,0.000582467,-3.45097e-07,-2.28115e-08,0.916186,0.000581708,-4.13531e-07,2.93911e-08,0.916767,0.000580969,-3.25358e-07,-3.51481e-08,0.917348,0.000580213,-4.30803e-07,5.15967e-08,0.917928,0.000579506,-2.76012e-07,-5.20296e-08,0.918507,0.000578798,-4.32101e-07,3.73124e-08,0.919085,0.000578046,-3.20164e-07,-3.76154e-08,0.919663,0.000577293,-4.3301e-07,5.35447e-08,0.92024,0.000576587,-2.72376e-07,-5.7354e-08,0.920816,0.000575871,-4.44438e-07,5.66621e-08,0.921391,0.000575152,-2.74452e-07,-5.00851e-08,0.921966,0.000574453,-4.24707e-07,2.4469e-08,0.92254,0.000573677,-3.513e-07,1.18138e-08,0.923114,0.000573009,-3.15859e-07,-1.21195e-08,0.923686,0.000572341,-3.52217e-07,-2.29403e-08,0.924258,0.000571568,-4.21038e-07,4.4276e-08,0.924829,0.000570859,-2.8821e-07,-3.49546e-08,0.9254,0.000570178,-3.93074e-07,3.59377e-08,0.92597,0.000569499,-2.85261e-07,-4.91915e-08,0.926539,0.000568781,-4.32835e-07,4.16189e-08,0.927107,0.00056804,-3.07979e-07,1.92523e-09,0.927675,0.00056743,-3.02203e-07,-4.93198e-08,0.928242,0.000566678,-4.50162e-07,7.61447e-08,0.928809,0.000566006,-2.21728e-07,-7.6445e-08,0.929374,0.000565333,-4.51063e-07,5.08216e-08,0.929939,0.000564583,-2.98599e-07,-7.63212e-09,0.930503,0.000563963,-3.21495e-07,-2.02931e-08,0.931067,0.000563259,-3.82374e-07,2.92001e-08,0.93163,0.000562582,-2.94774e-07,-3.69025e-08,0.932192,0.000561882,-4.05482e-07,5.88053e-08,0.932754,0.000561247,-2.29066e-07,-7.91094e-08,0.933315,0.000560552,-4.66394e-07,7.88184e-08,0.933875,0.000559856,-2.29939e-07,-5.73501e-08,0.934434,0.000559224,-4.01989e-07,3.13727e-08,0.934993,0.000558514,-3.07871e-07,-8.53611e-09,0.935551,0.000557873,-3.33479e-07,2.77175e-09,0.936109,0.000557214,-3.25164e-07,-2.55091e-09,0.936666,0.000556556,-3.32817e-07,7.43188e-09,0.937222,0.000555913,-3.10521e-07,-2.71766e-08,0.937778,0.00055521,-3.92051e-07,4.167e-08,0.938333,0.000554551,-2.67041e-07,-2.02941e-08,0.938887,0.000553956,-3.27923e-07,-2.00984e-08,0.93944,0.00055324,-3.88218e-07,4.10828e-08,0.939993,0.000552587,-2.6497e-07,-2.50237e-08,0.940546,0.000551982,-3.40041e-07,-5.92583e-10,0.941097,0.0005513,-3.41819e-07,2.7394e-08,0.941648,0.000550698,-2.59637e-07,-4.93788e-08,0.942199,0.000550031,-4.07773e-07,5.09119e-08,0.942748,0.000549368,-2.55038e-07,-3.50595e-08,0.943297,0.000548753,-3.60216e-07,2.97214e-08,0.943846,0.000548122,-2.71052e-07,-2.42215e-08,0.944394,0.000547507,-3.43716e-07,7.55985e-09,0.944941,0.000546842,-3.21037e-07,-6.01796e-09,0.945487,0.000546182,-3.3909e-07,1.65119e-08,0.946033,0.000545553,-2.89555e-07,-4.2498e-10,0.946578,0.000544973,-2.9083e-07,-1.4812e-08,0.947123,0.000544347,-3.35266e-07,6.83068e-11,0.947667,0.000543676,-3.35061e-07,1.45388e-08,0.94821,0.00054305,-2.91444e-07,1.38123e-09,0.948753,0.000542471,-2.87301e-07,-2.00637e-08,0.949295,0.000541836,-3.47492e-07,1.92688e-08,0.949837,0.000541199,-2.89685e-07,2.59298e-09,0.950378,0.000540628,-2.81906e-07,-2.96407e-08,0.950918,0.000539975,-3.70829e-07,5.63652e-08,0.951458,0.000539402,-2.01733e-07,-7.66107e-08,0.951997,0.000538769,-4.31565e-07,7.12638e-08,0.952535,0.00053812,-2.17774e-07,-2.96305e-08,0.953073,0.000537595,-3.06665e-07,-1.23464e-08,0.95361,0.000536945,-3.43704e-07,1.94114e-08,0.954147,0.000536316,-2.8547e-07,-5.69451e-09,0.954683,0.000535728,-3.02554e-07,3.36666e-09,0.955219,0.000535133,-2.92454e-07,-7.77208e-09,0.955753,0.000534525,-3.1577e-07,2.77216e-08,0.956288,0.000533976,-2.32605e-07,-4.35097e-08,0.956821,0.00053338,-3.63134e-07,2.7108e-08,0.957354,0.000532735,-2.8181e-07,-5.31772e-09,0.957887,0.000532156,-2.97764e-07,-5.83718e-09,0.958419,0.000531543,-3.15275e-07,2.86664e-08,0.95895,0.000530998,-2.29276e-07,-4.9224e-08,0.959481,0.000530392,-3.76948e-07,4.90201e-08,0.960011,0.000529785,-2.29887e-07,-2.76471e-08,0.96054,0.000529243,-3.12829e-07,1.96385e-09,0.961069,0.000528623,-3.06937e-07,1.97917e-08,0.961598,0.000528068,-2.47562e-07,-2.15261e-08,0.962125,0.000527508,-3.1214e-07,6.70795e-09,0.962653,0.000526904,-2.92016e-07,-5.30573e-09,0.963179,0.000526304,-3.07934e-07,1.4515e-08,0.963705,0.000525732,-2.64389e-07,6.85048e-09,0.964231,0.000525224,-2.43837e-07,-4.19169e-08,0.964756,0.00052461,-3.69588e-07,4.1608e-08,0.96528,0.000523996,-2.44764e-07,-5.30598e-09,0.965804,0.000523491,-2.60682e-07,-2.03841e-08,0.966327,0.000522908,-3.21834e-07,2.72378e-08,0.966849,0.000522346,-2.40121e-07,-2.89625e-08,0.967371,0.000521779,-3.27008e-07,2.90075e-08,0.967893,0.000521212,-2.39986e-07,-2.74629e-08,0.968414,0.00052065,-3.22374e-07,2.12396e-08,0.968934,0.000520069,-2.58656e-07,2.10922e-09,0.969454,0.000519558,-2.52328e-07,-2.96765e-08,0.969973,0.000518964,-3.41357e-07,5.6992e-08,0.970492,0.000518452,-1.70382e-07,-7.90821e-08,0.97101,0.000517874,-4.07628e-07,8.05224e-08,0.971528,0.000517301,-1.66061e-07,-6.41937e-08,0.972045,0.000516776,-3.58642e-07,5.70429e-08,0.972561,0.00051623,-1.87513e-07,-4.47686e-08,0.973077,0.00051572,-3.21819e-07,2.82237e-09,0.973593,0.000515085,-3.13352e-07,3.34792e-08,0.974108,0.000514559,-2.12914e-07,-1.75298e-08,0.974622,0.000514081,-2.65503e-07,-2.29648e-08,0.975136,0.000513481,-3.34398e-07,4.97843e-08,0.975649,0.000512961,-1.85045e-07,-5.6963e-08,0.976162,0.00051242,-3.55934e-07,5.88585e-08,0.976674,0.000511885,-1.79359e-07,-5.92616e-08,0.977185,0.000511348,-3.57143e-07,5.89785e-08,0.977696,0.000510811,-1.80208e-07,-5.74433e-08,0.978207,0.000510278,-3.52538e-07,5.15854e-08,0.978717,0.000509728,-1.97781e-07,-2.9689e-08,0.979226,0.000509243,-2.86848e-07,7.56591e-09,0.979735,0.000508692,-2.64151e-07,-5.74649e-10,0.980244,0.000508162,-2.65875e-07,-5.26732e-09,0.980752,0.000507615,-2.81677e-07,2.16439e-08,0.981259,0.000507116,-2.16745e-07,-2.17037e-08,0.981766,0.000506618,-2.81856e-07,5.56636e-09,0.982272,0.000506071,-2.65157e-07,-5.61689e-10,0.982778,0.000505539,-2.66842e-07,-3.31963e-09,0.983283,0.000504995,-2.76801e-07,1.38402e-08,0.983788,0.000504483,-2.3528e-07,7.56339e-09,0.984292,0.000504035,-2.1259e-07,-4.40938e-08,0.984796,0.000503478,-3.44871e-07,4.96026e-08,0.985299,0.000502937,-1.96064e-07,-3.51071e-08,0.985802,0.000502439,-3.01385e-07,3.12212e-08,0.986304,0.00050193,-2.07721e-07,-3.0173e-08,0.986806,0.000501424,-2.9824e-07,2.9866e-08,0.987307,0.000500917,-2.08642e-07,-2.96865e-08,0.987808,0.000500411,-2.97702e-07,2.92753e-08,0.988308,0.000499903,-2.09876e-07,-2.78101e-08,0.988807,0.0004994,-2.93306e-07,2.23604e-08,0.989307,0.000498881,-2.26225e-07,-2.02681e-09,0.989805,0.000498422,-2.32305e-07,-1.42531e-08,0.990303,0.000497915,-2.75065e-07,-5.65232e-10,0.990801,0.000497363,-2.76761e-07,1.65141e-08,0.991298,0.000496859,-2.27218e-07,-5.88639e-09,0.991795,0.000496387,-2.44878e-07,7.0315e-09,0.992291,0.000495918,-2.23783e-07,-2.22396e-08,0.992787,0.000495404,-2.90502e-07,2.23224e-08,0.993282,0.00049489,-2.23535e-07,-7.44543e-09,0.993776,0.000494421,-2.45871e-07,7.45924e-09,0.994271,0.000493951,-2.23493e-07,-2.23915e-08,0.994764,0.000493437,-2.90668e-07,2.25021e-08,0.995257,0.000492923,-2.23161e-07,-8.01218e-09,0.99575,0.000492453,-2.47198e-07,9.54669e-09,0.996242,0.000491987,-2.18558e-07,-3.01746e-08,0.996734,0.000491459,-3.09082e-07,5.1547e-08,0.997225,0.000490996,-1.54441e-07,-5.68039e-08,0.997716,0.000490517,-3.24853e-07,5.64594e-08,0.998206,0.000490036,-1.55474e-07,-4.98245e-08,0.998696,0.000489576,-3.04948e-07,2.36292e-08,0.999186,0.000489037,-2.3406e-07,1.49121e-08,0.999674,0.000488613,-1.89324e-07,-2.3673e-08,1.00016,0.000488164,-2.60343e-07,2.01754e-08,1.00065,0.000487704,-1.99816e-07,-5.70288e-08,1.00114,0.000487133,-3.70903e-07,8.87303e-08,1.00162,0.000486657,-1.04712e-07,-5.94737e-08,1.00211,0.000486269,-2.83133e-07,2.99553e-08,1.0026,0.000485793,-1.93267e-07,-6.03474e-08,1.00308,0.000485225,-3.74309e-07,9.2225e-08,1.00357,0.000484754,-9.76345e-08,-7.0134e-08,1.00405,0.000484348,-3.08036e-07,6.91016e-08,1.00454,0.000483939,-1.00731e-07,-8.70633e-08,1.00502,0.000483476,-3.61921e-07,4.07328e-08,1.0055,0.000482875,-2.39723e-07,4.33413e-08,1.00599,0.000482525,-1.09699e-07,-9.48886e-08,1.00647,0.000482021,-3.94365e-07,9.77947e-08,1.00695,0.000481526,-1.00981e-07,-5.78713e-08,1.00743,0.00048115,-2.74595e-07,1.44814e-08,1.00791,0.000480645,-2.31151e-07,-5.42665e-11,1.00839,0.000480182,-2.31314e-07,-1.42643e-08,1.00887,0.000479677,-2.74106e-07,5.71115e-08,1.00935,0.0004793,-1.02772e-07,-9.49724e-08,1.00983,0.000478809,-3.87689e-07,8.43596e-08,1.01031,0.000478287,-1.3461e-07,-4.04755e-09,1.01079,0.000478006,-1.46753e-07,-6.81694e-08,1.01127,0.000477508,-3.51261e-07,3.83067e-08,1.01174,0.00047692,-2.36341e-07,3.41521e-08,1.01222,0.00047655,-1.33885e-07,-5.57058e-08,1.0127,0.000476115,-3.01002e-07,6.94616e-08,1.01317,0.000475721,-9.26174e-08,-1.02931e-07,1.01365,0.000475227,-4.01412e-07,1.03846e-07,1.01412,0.000474736,-8.98751e-08,-7.40321e-08,1.0146,0.000474334,-3.11971e-07,7.30735e-08,1.01507,0.00047393,-9.27508e-08,-9.90527e-08,1.01554,0.000473447,-3.89909e-07,8.47188e-08,1.01602,0.000472921,-1.35753e-07,-1.40381e-09,1.01649,0.000472645,-1.39964e-07,-7.91035e-08,1.01696,0.000472128,-3.77275e-07,7.93993e-08,1.01744,0.000471612,-1.39077e-07,-7.52607e-11,1.01791,0.000471334,-1.39302e-07,-7.90983e-08,1.01838,0.000470818,-3.76597e-07,7.80499e-08,1.01885,0.000470299,-1.42448e-07,5.31733e-09,1.01932,0.00047003,-1.26496e-07,-9.93193e-08,1.01979,0.000469479,-4.24453e-07,1.53541e-07,1.02026,0.00046909,3.617e-08,-1.57217e-07,1.02073,0.000468691,-4.35482e-07,1.177e-07,1.02119,0.000468173,-8.23808e-08,-7.51659e-08,1.02166,0.000467783,-3.07878e-07,6.37538e-08,1.02213,0.000467358,-1.16617e-07,-6.064e-08,1.0226,0.000466943,-2.98537e-07,5.9597e-08,1.02306,0.000466525,-1.19746e-07,-5.85386e-08,1.02353,0.00046611,-2.95362e-07,5.53482e-08,1.024,0.000465685,-1.29317e-07,-4.36449e-08,1.02446,0.000465296,-2.60252e-07,2.20268e-11,1.02493,0.000464775,-2.60186e-07,4.35568e-08,1.02539,0.000464386,-1.29516e-07,-5.50398e-08,1.02586,0.000463961,-2.94635e-07,5.73932e-08,1.02632,0.000463544,-1.22456e-07,-5.53236e-08,1.02678,0.000463133,-2.88426e-07,4.46921e-08,1.02725,0.000462691,-1.5435e-07,-4.23534e-09,1.02771,0.000462369,-1.67056e-07,-2.77507e-08,1.02817,0.000461952,-2.50308e-07,-3.97101e-09,1.02863,0.000461439,-2.62221e-07,4.36348e-08,1.02909,0.000461046,-1.31317e-07,-5.13589e-08,1.02955,0.000460629,-2.85394e-07,4.25913e-08,1.03001,0.000460186,-1.5762e-07,2.0285e-10,1.03047,0.000459871,-1.57011e-07,-4.34027e-08,1.03093,0.000459427,-2.87219e-07,5.41987e-08,1.03139,0.000459015,-1.24623e-07,-5.4183e-08,1.03185,0.000458604,-2.87172e-07,4.33239e-08,1.03231,0.000458159,-1.572e-07,9.65817e-11,1.03277,0.000457845,-1.56911e-07,-4.37103e-08,1.03323,0.0004574,-2.88041e-07,5.55351e-08,1.03368,0.000456991,-1.21436e-07,-5.9221e-08,1.03414,0.00045657,-2.99099e-07,6.21394e-08,1.0346,0.000456158,-1.1268e-07,-7.01275e-08,1.03505,0.000455723,-3.23063e-07,9.91614e-08,1.03551,0.000455374,-2.55788e-08,-8.80996e-08,1.03596,0.000455058,-2.89878e-07,1.48184e-08,1.03642,0.000454523,-2.45422e-07,2.88258e-08,1.03687,0.000454119,-1.58945e-07,-1.09125e-08,1.03733,0.000453768,-1.91682e-07,1.48241e-08,1.03778,0.000453429,-1.4721e-07,-4.83838e-08,1.03823,0.00045299,-2.92361e-07,5.95019e-08,1.03869,0.000452584,-1.13856e-07,-7.04146e-08,1.03914,0.000452145,-3.25099e-07,1.02947e-07,1.03959,0.000451803,-1.62583e-08,-1.02955e-07,1.04004,0.000451462,-3.25123e-07,7.04544e-08,1.04049,0.000451023,-1.1376e-07,-5.96534e-08,1.04094,0.000450616,-2.9272e-07,4.89499e-08,1.04139,0.000450178,-1.45871e-07,-1.69369e-08,1.04184,0.000449835,-1.96681e-07,1.87977e-08,1.04229,0.000449498,-1.40288e-07,-5.82539e-08,1.04274,0.000449043,-3.1505e-07,9.50087e-08,1.04319,0.000448698,-3.00238e-08,-8.33623e-08,1.04364,0.000448388,-2.80111e-07,2.20363e-11,1.04409,0.000447828,-2.80045e-07,8.32742e-08,1.04454,0.000447517,-3.02221e-08,-9.47002e-08,1.04498,0.000447173,-3.14323e-07,5.7108e-08,1.04543,0.000446716,-1.42999e-07,-1.45225e-08,1.04588,0.000446386,-1.86566e-07,9.82022e-10,1.04632,0.000446016,-1.8362e-07,1.05944e-08,1.04677,0.00044568,-1.51837e-07,-4.33597e-08,1.04721,0.000445247,-2.81916e-07,4.36352e-08,1.04766,0.000444814,-1.51011e-07,-1.19717e-08,1.0481,0.000444476,-1.86926e-07,4.25158e-09,1.04855,0.000444115,-1.74171e-07,-5.03461e-09,1.04899,0.000443751,-1.89275e-07,1.58868e-08,1.04944,0.00044342,-1.41614e-07,-5.85127e-08,1.04988,0.000442961,-3.17152e-07,9.89548e-08,1.05032,0.000442624,-2.0288e-08,-9.88878e-08,1.05076,0.000442287,-3.16951e-07,5.81779e-08,1.05121,0.000441827,-1.42418e-07,-1.46144e-08,1.05165,0.000441499,-1.86261e-07,2.79892e-10,1.05209,0.000441127,-1.85421e-07,1.34949e-08,1.05253,0.000440797,-1.44937e-07,-5.42594e-08,1.05297,0.000440344,-3.07715e-07,8.43335e-08,1.05341,0.000439982,-5.47146e-08,-4.46558e-08,1.05385,0.000439738,-1.88682e-07,-2.49193e-08,1.05429,0.000439286,-2.6344e-07,2.5124e-08,1.05473,0.000438835,-1.88068e-07,4.36328e-08,1.05517,0.000438589,-5.71699e-08,-8.04459e-08,1.05561,0.000438234,-2.98508e-07,3.97324e-08,1.05605,0.000437756,-1.79311e-07,4.07258e-08,1.05648,0.000437519,-5.71332e-08,-8.34263e-08,1.05692,0.000437155,-3.07412e-07,5.45608e-08,1.05736,0.000436704,-1.4373e-07,-1.56078e-08,1.05779,0.000436369,-1.90553e-07,7.87043e-09,1.05823,0.000436012,-1.66942e-07,-1.58739e-08,1.05867,0.00043563,-2.14563e-07,5.56251e-08,1.0591,0.000435368,-4.76881e-08,-8.74172e-08,1.05954,0.000435011,-3.0994e-07,5.56251e-08,1.05997,0.000434558,-1.43064e-07,-1.58739e-08,1.06041,0.000434224,-1.90686e-07,7.87042e-09,1.06084,0.000433866,-1.67075e-07,-1.56078e-08,1.06127,0.000433485,-2.13898e-07,5.45609e-08,1.06171,0.000433221,-5.02157e-08,-8.34263e-08,1.06214,0.00043287,-3.00495e-07,4.07258e-08,1.06257,0.000432391,-1.78317e-07,3.97325e-08,1.063,0.000432154,-5.91198e-08,-8.04464e-08,1.06344,0.000431794,-3.00459e-07,4.36347e-08,1.06387,0.000431324,-1.69555e-07,2.5117e-08,1.0643,0.000431061,-9.42041e-08,-2.48934e-08,1.06473,0.000430798,-1.68884e-07,-4.47527e-08,1.06516,0.000430326,-3.03142e-07,8.46951e-08,1.06559,0.000429973,-4.90573e-08,-5.56089e-08,1.06602,0.000429708,-2.15884e-07,1.85314e-08,1.06645,0.000429332,-1.6029e-07,-1.85166e-08,1.06688,0.000428956,-2.1584e-07,5.5535e-08,1.06731,0.000428691,-4.92347e-08,-8.44142e-08,1.06774,0.000428339,-3.02477e-07,4.37032e-08,1.06816,0.000427865,-1.71368e-07,2.88107e-08,1.06859,0.000427609,-8.49356e-08,-3.97367e-08,1.06902,0.00042732,-2.04146e-07,1.09267e-08,1.06945,0.000426945,-1.71365e-07,-3.97023e-09,1.06987,0.00042659,-1.83276e-07,4.9542e-09,1.0703,0.000426238,-1.68414e-07,-1.58466e-08,1.07073,0.000425854,-2.15953e-07,5.84321e-08,1.07115,0.000425597,-4.0657e-08,-9.86725e-08,1.07158,0.00042522,-3.36674e-07,9.78392e-08,1.072,0.00042484,-4.31568e-08,-5.42658e-08,1.07243,0.000424591,-2.05954e-07,1.45377e-11,1.07285,0.000424179,-2.0591e-07,5.42076e-08,1.07328,0.00042393,-4.32877e-08,-9.76357e-08,1.0737,0.00042355,-3.36195e-07,9.79165e-08,1.07412,0.000423172,-4.24451e-08,-5.56118e-08,1.07455,0.00042292,-2.09281e-07,5.32143e-09,1.07497,0.000422518,-1.93316e-07,3.43261e-08,1.07539,0.000422234,-9.0338e-08,-2.34165e-08,1.07581,0.000421983,-1.60588e-07,-5.98692e-08,1.07623,0.000421482,-3.40195e-07,1.43684e-07,1.07666,0.000421233,9.08574e-08,-1.5724e-07,1.07708,0.000420943,-3.80862e-07,1.27647e-07,1.0775,0.000420564,2.0791e-09,-1.1493e-07,1.07792,0.000420223,-3.4271e-07,9.36534e-08,1.07834,0.000419819,-6.17499e-08,-2.12653e-08,1.07876,0.000419632,-1.25546e-07,-8.59219e-09,1.07918,0.000419355,-1.51322e-07,-6.35752e-08,1.0796,0.000418861,-3.42048e-07,1.43684e-07,1.08002,0.000418608,8.90034e-08,-1.53532e-07,1.08043,0.000418326,-3.71593e-07,1.12817e-07,1.08085,0.000417921,-3.31414e-08,-5.93184e-08,1.08127,0.000417677,-2.11097e-07,5.24697e-09,1.08169,0.00041727,-1.95356e-07,3.83305e-08,1.0821,0.000416995,-8.03642e-08,-3.93597e-08,1.08252,0.000416716,-1.98443e-07,-1.0094e-10,1.08294,0.000416319,-1.98746e-07,3.97635e-08,1.08335,0.00041604,-7.94557e-08,-3.97437e-08,1.08377,0.000415762,-1.98687e-07,1.94215e-12,1.08419,0.000415365,-1.98681e-07,3.97359e-08,1.0846,0.000415087,-7.94732e-08,-3.97362e-08,1.08502,0.000414809,-1.98682e-07,-4.31063e-13,1.08543,0.000414411,-1.98683e-07,3.97379e-08,1.08584,0.000414133,-7.94694e-08,-3.97418e-08,1.08626,0.000413855,-1.98695e-07,2.00563e-11,1.08667,0.000413458,-1.98635e-07,3.96616e-08,1.08709,0.000413179,-7.965e-08,-3.9457e-08,1.0875,0.000412902,-1.98021e-07,-1.04281e-09,1.08791,0.000412502,-2.01149e-07,4.36282e-08,1.08832,0.000412231,-7.02648e-08,-5.42608e-08,1.08874,0.000411928,-2.33047e-07,5.42057e-08,1.08915,0.000411624,-7.04301e-08,-4.33527e-08,1.08956,0.000411353,-2.00488e-07,-4.07378e-12,1.08997,0.000410952,-2.005e-07,4.3369e-08,1.09038,0.000410681,-7.03934e-08,-5.42627e-08,1.09079,0.000410378,-2.33182e-07,5.44726e-08,1.0912,0.000410075,-6.97637e-08,-4.44186e-08,1.09161,0.000409802,-2.03019e-07,3.99235e-09,1.09202,0.000409408,-1.91042e-07,2.84491e-08,1.09243,0.000409111,-1.05695e-07,1.42043e-09,1.09284,0.000408904,-1.01434e-07,-3.41308e-08,1.09325,0.000408599,-2.03826e-07,1.58937e-08,1.09366,0.000408239,-1.56145e-07,-2.94438e-08,1.09406,0.000407838,-2.44476e-07,1.01881e-07,1.09447,0.000407655,6.11676e-08,-1.39663e-07,1.09488,0.000407358,-3.57822e-07,9.91432e-08,1.09529,0.00040694,-6.03921e-08,-1.84912e-08,1.09569,0.000406764,-1.15866e-07,-2.51785e-08,1.0961,0.000406457,-1.91401e-07,-4.03115e-12,1.09651,0.000406074,-1.91413e-07,2.51947e-08,1.09691,0.000405767,-1.15829e-07,1.84346e-08,1.09732,0.00040559,-6.05254e-08,-9.89332e-08,1.09772,0.000405172,-3.57325e-07,1.3888e-07,1.09813,0.000404874,5.93136e-08,-9.8957e-08,1.09853,0.000404696,-2.37557e-07,1.853e-08,1.09894,0.000404277,-1.81968e-07,2.48372e-08,1.09934,0.000403987,-1.07456e-07,1.33047e-09,1.09975,0.000403776,-1.03465e-07,-3.01591e-08,1.10015,0.000403479,-1.93942e-07,9.66054e-11,1.10055,0.000403091,-1.93652e-07,2.97727e-08,1.10096,0.000402793,-1.04334e-07,2.19273e-11,1.10136,0.000402585,-1.04268e-07,-2.98604e-08,1.10176,0.000402287,-1.93849e-07,2.10325e-10,1.10216,0.0004019,-1.93218e-07,2.90191e-08,1.10256,0.0004016,-1.06161e-07,2.92264e-09,1.10297,0.000401397,-9.73931e-08,-4.07096e-08,1.10337,0.00040108,-2.19522e-07,4.07067e-08,1.10377,0.000400763,-9.7402e-08,-2.90783e-09,1.10417,0.000400559,-1.06126e-07,-2.90754e-08,1.10457,0.00040026,-1.93352e-07,9.00021e-14,1.10497,0.000399873,-1.93351e-07,2.9075e-08,1.10537,0.000399574,-1.06126e-07,2.90902e-09,1.10577,0.00039937,-9.73992e-08,-4.07111e-08,1.10617,0.000399053,-2.19533e-07,4.07262e-08,1.10657,0.000398736,-9.73541e-08,-2.98424e-09,1.10697,0.000398533,-1.06307e-07,-2.87892e-08,1.10736,0.000398234,-1.92674e-07,-1.06824e-09,1.10776,0.000397845,-1.95879e-07,3.30622e-08,1.10816,0.000397552,-9.66926e-08,-1.19712e-08,1.10856,0.000397323,-1.32606e-07,1.48225e-08,1.10895,0.000397102,-8.81387e-08,-4.73187e-08,1.10935,0.000396784,-2.30095e-07,5.52429e-08,1.10975,0.00039649,-6.4366e-08,-5.44437e-08,1.11014,0.000396198,-2.27697e-07,4.33226e-08,1.11054,0.000395872,-9.77293e-08,3.62656e-10,1.11094,0.000395678,-9.66414e-08,-4.47732e-08,1.11133,0.00039535,-2.30961e-07,5.95208e-08,1.11173,0.000395067,-5.23985e-08,-7.41008e-08,1.11212,0.00039474,-2.74701e-07,1.17673e-07,1.11252,0.000394543,7.83181e-08,-1.58172e-07,1.11291,0.000394225,-3.96199e-07,1.57389e-07,1.1133,0.000393905,7.59679e-08,-1.13756e-07,1.1137,0.000393716,-2.653e-07,5.92165e-08,1.11409,0.000393363,-8.76507e-08,-3.90074e-09,1.11449,0.000393176,-9.93529e-08,-4.36136e-08,1.11488,0.000392846,-2.30194e-07,5.91457e-08,1.11527,0.000392563,-5.27564e-08,-7.376e-08,1.11566,0.000392237,-2.74037e-07,1.16685e-07,1.11606,0.000392039,7.60189e-08,-1.54562e-07,1.11645,0.000391727,-3.87667e-07,1.43935e-07,1.11684,0.000391384,4.4137e-08,-6.35487e-08,1.11723,0.000391281,-1.46509e-07,-8.94896e-09,1.11762,0.000390961,-1.73356e-07,-1.98647e-08,1.11801,0.000390555,-2.3295e-07,8.8408e-08,1.1184,0.000390354,3.22736e-08,-9.53486e-08,1.11879,0.000390133,-2.53772e-07,5.45677e-08,1.11918,0.000389789,-9.0069e-08,-3.71296e-09,1.11957,0.000389598,-1.01208e-07,-3.97159e-08,1.11996,0.000389276,-2.20355e-07,4.33671e-08,1.12035,0.000388966,-9.02542e-08,-1.45431e-08,1.12074,0.000388741,-1.33883e-07,1.48052e-08,1.12113,0.000388518,-8.94678e-08,-4.46778e-08,1.12152,0.000388205,-2.23501e-07,4.46966e-08,1.12191,0.000387892,-8.94114e-08,-1.48992e-08,1.12229,0.000387669,-1.34109e-07,1.49003e-08,1.12268,0.000387445,-8.94082e-08,-4.47019e-08,1.12307,0.000387132,-2.23514e-07,4.4698e-08,1.12345,0.000386819,-8.942e-08,-1.48806e-08,1.12384,0.000386596,-1.34062e-07,1.48245e-08,1.12423,0.000386372,-8.95885e-08,-4.44172e-08,1.12461,0.00038606,-2.2284e-07,4.36351e-08,1.125,0.000385745,-9.19348e-08,-1.09139e-08,1.12539,0.000385528,-1.24677e-07,2.05584e-11,1.12577,0.000385279,-1.24615e-07,1.08317e-08,1.12616,0.000385062,-9.21198e-08,-4.33473e-08,1.12654,0.000384748,-2.22162e-07,4.33481e-08,1.12693,0.000384434,-9.21174e-08,-1.08356e-08,1.12731,0.000384217,-1.24624e-07,-5.50907e-12,1.12769,0.000383968,-1.24641e-07,1.08577e-08,1.12808,0.000383751,-9.20679e-08,-4.34252e-08,1.12846,0.000383437,-2.22343e-07,4.36337e-08,1.12884,0.000383123,-9.14422e-08,-1.19005e-08,1.12923,0.000382904,-1.27144e-07,3.96813e-09,1.12961,0.000382662,-1.15239e-07,-3.97207e-09,1.12999,0.000382419,-1.27155e-07,1.19201e-08,1.13038,0.000382201,-9.1395e-08,-4.37085e-08,1.13076,0.000381887,-2.2252e-07,4.37046e-08,1.13114,0.000381573,-9.14068e-08,-1.19005e-08,1.13152,0.000381355,-1.27108e-07,3.89734e-09,1.1319,0.000381112,-1.15416e-07,-3.68887e-09,1.13228,0.00038087,-1.26483e-07,1.08582e-08,1.13266,0.00038065,-9.39083e-08,-3.97438e-08,1.13304,0.000380343,-2.1314e-07,2.89076e-08,1.13342,0.000380003,-1.26417e-07,4.33225e-08,1.1338,0.00037988,3.55072e-09,-8.29883e-08,1.13418,0.000379638,-2.45414e-07,5.0212e-08,1.13456,0.000379298,-9.47781e-08,1.34964e-09,1.13494,0.000379113,-9.07292e-08,-5.56105e-08,1.13532,0.000378764,-2.57561e-07,1.01883e-07,1.1357,0.000378555,4.80889e-08,-1.13504e-07,1.13608,0.000378311,-2.92423e-07,1.13713e-07,1.13646,0.000378067,4.87176e-08,-1.02931e-07,1.13683,0.000377856,-2.60076e-07,5.95923e-08,1.13721,0.000377514,-8.12988e-08,-1.62288e-08,1.13759,0.000377303,-1.29985e-07,5.32278e-09,1.13797,0.000377059,-1.14017e-07,-5.06237e-09,1.13834,0.000376816,-1.29204e-07,1.49267e-08,1.13872,0.000376602,-8.44237e-08,-5.46444e-08,1.1391,0.000376269,-2.48357e-07,8.44417e-08,1.13947,0.000376026,4.96815e-09,-4.47039e-08,1.13985,0.000375902,-1.29143e-07,-2.48355e-08,1.14023,0.000375569,-2.0365e-07,2.48368e-08,1.1406,0.000375236,-1.2914e-07,4.46977e-08,1.14098,0.000375112,4.95341e-09,-8.44184e-08,1.14135,0.000374869,-2.48302e-07,5.45572e-08,1.14173,0.000374536,-8.463e-08,-1.46013e-08,1.1421,0.000374323,-1.28434e-07,3.8478e-09,1.14247,0.000374077,-1.1689e-07,-7.89941e-10,1.14285,0.000373841,-1.1926e-07,-6.88042e-10,1.14322,0.0003736,-1.21324e-07,3.54213e-09,1.1436,0.000373368,-1.10698e-07,-1.34805e-08,1.14397,0.000373107,-1.51139e-07,5.03798e-08,1.14434,0.000372767,0.,0.}; template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); const float _un = 13 * (4 * 0.950456f * _d); const float _vn = 13 * (9 * _d); float B = blueIdx == 0 ? src.x : src.z; float G = src.y; float R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); } float X = R * 0.412453f + G * 0.357580f + B * 0.180423f; float Y = R * 0.212671f + G * 0.715160f + B * 0.072169f; float Z = R * 0.019334f + G * 0.119193f + B * 0.950227f; float L = splineInterpolate(Y * (LAB_CBRT_TAB_SIZE / 1.5f), c_LabCbrtTab, LAB_CBRT_TAB_SIZE); L = 116.f * L - 16.f; const float d = (4 * 13) / ::fmaxf(X + 15 * Y + 3 * Z, numeric_limits<float>::epsilon()); float u = L * (X * d - _un); float v = L * ((9 * 0.25f) * Y * d - _vn); typename MakeVec<float, dcn>::type dst; dst.x = L; dst.y = u; dst.z = v; return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (1.f / 255.f); buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); RGB2Luv<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 2.55f); dst.y = saturate_cast<uchar>(buf.y * 0.72033898305084743f + 96.525423728813564f); dst.z = saturate_cast<uchar>(buf.z * 0.9732824427480916f + 136.259541984732824f); return dst; } }; // Luv to RGB template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB; template <int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); const float _un = 13 * 4 * 0.950456f * _d; const float _vn = 13 * 9 * _d; float L = src.x; float u = src.y; float v = src.z; float Y1 = (L + 16.f) * (1.f / 116.f); Y1 = Y1 * Y1 * Y1; float Y0 = L * (1.f / 903.3f); float Y = L <= 8.f ? Y0 : Y1; u = (u + _un * L) * 3.f; v = (v + _vn * L) * 4.f; float iv = 1.f / v; iv = ::fmaxf(-0.25f, ::fminf(0.25f, iv)); float X = 3.f * u * iv; float Z = (12.f * 13.f * L - u) * iv - 5.f; float B = (0.055648f * X - 0.204043f + 1.057311f * Z) * Y; float G = (-0.969256f * X + 1.875991f + 0.041556f * Z) * Y; float R = (3.240479f * X - 1.537150f - 0.498535f * Z) * Y; R = ::fminf(::fmaxf(R, 0.f), 1.f); G = ::fminf(::fmaxf(G, 0.f), 1.f); B = ::fminf(::fmaxf(B, 0.f), 1.f); if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); } typename MakeVec<float, dcn>::type dst; dst.x = blueIdx == 0 ? B : R; dst.y = G; dst.z = blueIdx == 0 ? R : B; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (100.f / 255.f); buf.y = src.y * 1.388235294117647f - 134.f; buf.z = src.z * 1.027450980392157f - 140.f; Luv2RGB<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; #undef CV_CUDEV_DESCALE } }} #endif
192,492
160,449
#include "Product.h" #include <iostream> #include <string> using namespace std; template <class T> Product<T>::Product() {} template<class T> Product<T>::Product(T i, string n, float p, string c, T si, T q, bool s) { id = i; name = n; price = p; category = c; sellerId = si; quantity = q; state = s; } template<class T> Product<T> Product<T>::addProduct(T sId) { T Id, Quantity; string Name, Category; float Price; bool State = false; cout << "Enter Id: "; cin >> Id; cout << "Enter Name: "; cin >> Name; cout << "Enter Price: $"; cin >> Price; cout << "Enter Category: "; cin >> Category; cout << "Enter Quantity: "; cin >> Quantity; cout << endl; Product<T> p(Id, Name, Price, Category, sId, Quantity, State); return p; } template<class T> bool Product<T>::searchName(string Name) { if (name == Name) return true; return false; } template<class T> bool Product<T>::searchId(T Id) { if (id == Id) return true; return false; } template<class T> bool Product<T>::searchCategory(string Category) { if (category == Category) return true; return false; } template<class T> void Product<T>::display(bool prodStatus) { if (!prodStatus || (prodStatus && state)) { cout << "Id: " << id << "\tName: " << name << "\tPrice: $" << price << "\tCategory: " << category << "\tSeller Id: " << sellerId << "\tQuantity: " << quantity; if (!prodStatus) { cout << "\tStatus: "; if (state) cout << "Accepted"; else cout << "Rejected"; } cout << endl; } } template<class T> void Product<T>::changeState(string State) { if (State == "Accept" || State == "accept" || State == "1") { state = true; cout << "\tAccepted\n"; } else { state = false; cout << "\tRejected\n"; } } template<class T> float Product<T>::getPrice() { return price; } template<class T> bool Product<T>::checkQuantity(T Required) { if (quantity - Required >= 0) return true; return false; } template<class T> bool Product<T>::checkSellerId(T sId) { if (sellerId == sId) return true; return false; } template<class T> void Product<T>::updateQuantity(T Quantity) { quantity -= Quantity; } template <class T> Product<T>::~Product() {}
2,200
860
#include "Delphi/Syntax/DelphiCaseElseClauseSyntax.hpp" #include <cassert> #include "interlinck/Core/Syntax/ISyntaxToken.hpp" #include "interlinck/Core/Syntax/SyntaxKinds.hpp" #include "Core/Support/SyntaxFactory.hpp" namespace interlinck::Delphi::Syntax { using Core::Support::SyntaxFactory; using namespace Core::Syntax; DelphiCaseElseClauseSyntax::DelphiCaseElseClauseSyntax(const ISyntaxToken* elseKeyword, const DelphiStatementListSyntax* statements) noexcept : DelphiSyntaxNode{SyntaxKind::CaseElseClause}, _elseKeyword{elseKeyword}, _statements{statements} { setPosition(_elseKeyword->position()); adjustWidthAndFlags(_elseKeyword); adjustWidthAndFlags(_statements); } SyntaxVariant DelphiCaseElseClauseSyntax::child(il_size index) const noexcept { assert(index < childCount()); switch (index) { case 0: return SyntaxVariant::asToken(_elseKeyword); case 1: return SyntaxVariant::asNode(_statements); default: return SyntaxVariant::empty(); } } const DelphiCaseElseClauseSyntax* DelphiCaseElseClauseSyntax::create(SyntaxFactory& syntaxFactory, const ISyntaxToken* elseKeyword, const DelphiStatementListSyntax* statements) noexcept { assert(elseKeyword != nullptr); assert(elseKeyword->syntaxKind() == SyntaxKind::ElseKeyword); assert(statements != nullptr); return syntaxFactory.syntaxNode<DelphiCaseElseClauseSyntax>(elseKeyword, statements); } } // end namespace interlinck::Delphi::Syntax
1,694
458
#pragma once #include "shiva/shivadef.hpp" #include "shiva/DirectoryTree.hpp" #include "../../../src/editor/windows/AssetGui.hpp" #include "ari/en/gui/DockableWindow.hpp" #include "DockWindow.hpp" namespace ari { class Button; class Dock; class DockSpace; } namespace shiva { class AssetGui; class SHIVA_API AssetBrowser : public DockWindow { public: ~AssetBrowser(); void Init(ari::World* p_world); private: void UpdateAssets(const DirectoryTree& _tree); static DirectoryTree* FindPathTree(DirectoryTree* _tree, const std::string& _path); void OnDblClick(AssetGui* _sender); void OnRightClick(AssetGui* _sender); std::vector<AssetGui*> m_vAssets; }; // AssetBrowser } // shiva
748
286
#include "../../common/resource/CResourceLock.h" #include "../../common/CException.h" #include "../../common/sphereproto.h" #include "../chars/CChar.h" #include "../clients/CClient.h" #include "../CServer.h" #include "../CWorldMap.h" #include "../triggers.h" #include "CItemMulti.h" #include "CItemShip.h" #include "CItemContainer.h" #include <algorithm> ///////////////////////////////////////////////////////////////////////////// CItemMulti::CItemMulti(ITEMID_TYPE id, CItemBase * pItemDef, bool fTurnable) : // CItemBaseMulti CTimedObject(PROFILE_MULTIS), CItem(id, pItemDef), CCMultiMovable(fTurnable) { CItemBaseMulti * pItemBase = static_cast<CItemBaseMulti*>(Base_GetDef()); _shipSpeed.period = pItemBase->_shipSpeed.period; _shipSpeed.tiles = pItemBase->_shipSpeed.tiles; _eSpeedMode = pItemBase->m_SpeedMode; m_pRegion = nullptr; _iHouseType = HOUSE_PRIVATE; _iMultiCount = pItemBase->_iMultiCount; _uiBaseStorage = pItemBase->_iBaseStorage; _uiBaseVendors = pItemBase->_iBaseVendors; _uiLockdownsPercent = pItemBase->_iLockdownsPercent; _uiIncreasedStorage = 0; _fIsAddon = false; } CItemMulti::~CItemMulti() { EXC_TRY("Cleanup in destructor"); ADDTOCALLSTACK("CItemMulti::~CItemMulti"); if (!m_pRegion) { return; } if (_uidGuild.IsValidUID()) { SetGuild(CUID()); } if (_uidOwner.IsValidUID()) { SetOwner(CUID()); } RemoveAllKeys(); if (!_lCoowners.empty()) { for (const CUID& charUID : _lCoowners) { DeleteCoowner(charUID, false); } } if (!_lFriends.empty()) { for (const CUID& charUID : _lFriends) { DeleteFriend(charUID, false); } } if (!_lVendors.empty()) { for (const CUID& charUID : _lVendors) { DeleteVendor(charUID, false); } } if (!_lLockDowns.empty()) { UnlockAllItems(); } if (!_lComps.empty()) { for (const CUID& itemUID : _lComps) { DeleteComponent(itemUID, false); } _lComps.clear(); } if (!_lSecureContainers.empty()) { for (const CUID& itemUID : _lSecureContainers) { Release(itemUID, false); } _lSecureContainers.clear(); } if (!_lAddons.empty()) { /* for (const CUID& itemUID : _lAddons) { CItemMulti *pItem = static_cast<CItemMulti*>(itemUID.ItemFind()); if (pItem) { DeleteAddon(itemUID); } } */ _lAddons.clear(); } CItemContainer *pMovingCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); if (pMovingCrate) { SetMovingCrate(CUID()); } MultiUnRealizeRegion(); // unrealize before removed from ground. // Must remove early because virtuals will fail in child destructor. // Attempt to remove all the accessory junk. // NOTE: assume we have already been removed from Top Level DeletePrepare(); delete m_pRegion; EXC_CATCH; } bool CItemMulti::Delete(bool fForce) { RemoveAllComponents(); return CObjBase::Delete(fForce); } const CItemBaseMulti * CItemMulti::Multi_GetDef() const noexcept { return static_cast <const CItemBaseMulti *>(Base_GetDef()); } CRegion * CItemMulti::GetRegion() const noexcept { return m_pRegion; } int CItemMulti::GetSideDistanceFromCenter(DIR_TYPE dir) const { ADDTOCALLSTACK("CItemMulti::GetSideDistanceFromCenter"); const CItemBaseMulti* pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); return pMultiDef->GetDistanceDir(dir); } int CItemMulti::Multi_GetDistanceMax() const { ADDTOCALLSTACK("CItemMulti::Multi_GetDistanceMax"); const CItemBaseMulti * pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); return pMultiDef->GetDistanceMax(); } const CItemBaseMulti * CItemMulti::Multi_GetDefByID(ITEMID_TYPE id) // static { ADDTOCALLSTACK("CItemMulti::Multi_GetDefByID"); const CItemBase * pItemBase = CItemBase::FindItemBase(id); return dynamic_cast <const CItemBaseMulti *>(pItemBase); } bool CItemMulti::MultiRealizeRegion() { ADDTOCALLSTACK("CItemMulti::MultiRealizeRegion"); // Add/move a region for the multi so we know when we are in it. // RETURN: ignored. if (!IsTopLevel() || IsType(IT_MULTI_ADDON)) { return false; } const CItemBaseMulti * pMultiDef = Multi_GetDef(); if (pMultiDef == nullptr) { g_Log.EventError("Bad Multi type 0%x, uid=0%x.\n", GetID(), (dword)GetUID()); return false; } if (m_pRegion == nullptr) { const CResourceID rid(GetUID().GetPrivateUID(), 0); m_pRegion = new CRegionWorld(rid); } // Get Background region. const CPointMap& pt = GetTopPoint(); const CRegionWorld * pRegionBack = dynamic_cast <CRegionWorld*> (pt.GetRegion(REGION_TYPE_AREA)); if (!pRegionBack) { g_Log.EventError("Can't realize multi region at invalid P=%hd,%hd,%hhd,%hhu. Multi uid=0%x.\n", pt.m_x, pt.m_y, pt.m_z, pt.m_map, (dword)GetUID()); return false; } ASSERT(pRegionBack != m_pRegion); // Create the new region rectangle. CRectMap rect = pMultiDef->m_rect; rect.m_map = pt.m_map; rect.OffsetRect(pt.m_x, pt.m_y); m_pRegion->SetRegionRect(rect); m_pRegion->m_pt = pt; dword dwFlags = pMultiDef->m_dwRegionFlags; if (IsType(IT_SHIP)) { dwFlags |= REGION_FLAG_SHIP; } else { dwFlags |= pRegionBack->GetRegionFlags(); // Houses get some of the attribs of the land around it. } m_pRegion->SetRegionFlags(dwFlags); tchar *pszTemp = Str_GetTemp(); snprintf(pszTemp, SCRIPT_MAX_LINE_LEN, "%s (%s)", pRegionBack->GetName(), GetName()); m_pRegion->SetName(pszTemp); m_pRegion->_pMultiLink = this; return m_pRegion->RealizeRegion(); } void CItemMulti::MultiUnRealizeRegion() { ADDTOCALLSTACK("CItemMulti::MultiUnRealizeRegion"); if (m_pRegion == nullptr) { return; } m_pRegion->_pMultiLink = nullptr; m_pRegion->UnRealizeRegion(); // find all creatures in the region and remove this from them. CWorldSearch Area(m_pRegion->m_pt, Multi_GetDistanceMax()); Area.SetSearchSquare(true); for (;;) { CChar * pChar = Area.GetChar(); if (pChar == nullptr) { break; } if (pChar->m_pArea != m_pRegion) { continue; } pChar->MoveToRegionReTest(REGION_TYPE_AREA); } } bool CItemMulti::Multi_CreateComponent(ITEMID_TYPE id, short dx, short dy, char dz, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::Multi_CreateComponent"); CItem * pItem = CreateTemplate(id); ASSERT(pItem); CPointMap pt(GetTopPoint()); pt.m_x += dx; pt.m_y += dy; pt.m_z += dz; bool fNeedKey = false; switch (pItem->GetType()) { case IT_SIGN_GUMP: case IT_SHIP_TILLER: pItem->m_uidLink = GetUID(); FALLTHROUGH; case IT_KEY: // it will get locked down with the house ? pItem->m_itKey.m_UIDLock.SetPrivateUID(dwKeyCode); // Set the key id for the key/sign. m_uidLink.SetPrivateUID(pItem->GetUID()); // Do not break, those need fNeedKey set to true. FALLTHROUGH; case IT_DOOR: case IT_CONTAINER: fNeedKey = true; break; default: break; } pItem->SetAttr(ATTR_MOVE_NEVER | (m_Attr&(ATTR_MAGIC | ATTR_INVIS))); pItem->m_uidLink = GetUID(); // lock it down with the structure. if (pItem->IsTypeLockable() || pItem->IsTypeLocked()) { pItem->m_itContainer.m_UIDLock.SetPrivateUID(dwKeyCode); // Set the key id for the door/key/sign. pItem->m_itContainer.m_dwLockComplexity = 10000; // never pickable. } pItem->r_ExecSingle("EVENTS +ei_house_component"); pItem->MoveToUpdate(pt); OnComponentCreate(pItem, false); // TODO: how do i know if that's an addon? AddComponent(pItem->GetUID()); if (IsType(IT_MULTI_ADDON)) { fNeedKey = false; } return fNeedKey; } void CItemMulti::Multi_Setup(CChar *pChar, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::Multi_Setup"); // Create house or Ship extra stuff. // ARGS: // dwKeyCode = set the key code for the doors/sides to this in case it's a drydocked ship. // NOTE: // This can only be done after the house is given location. const CItemBaseMulti * pMultiDef = Multi_GetDef(); // We are top level. if (pMultiDef == nullptr || !IsTopLevel()) { return; } if (dwKeyCode == UID_CLEAR) { dwKeyCode = GetUID(); } // ??? SetTimeout( GetDecayTime()); house decay ? bool fNeedKey = false; GenerateBaseComponents(&fNeedKey, dwKeyCode); if (IsType(IT_MULTI_ADDON)) // Addons doesn't require keys and are not added to any list. { return; } Multi_GetSign(); // set the m_uidLink if (pChar) { SetOwner(pChar->GetUID()); if (fNeedKey) { m_itShip.m_UIDCreator = pChar->GetUID(); if (IsType(IT_SHIP)) { if (g_Cfg._fAutoShipKeys) { GenerateKey(pChar->GetUID(), true); } } else { if (g_Cfg._fAutoHouseKeys) { GenerateKey(pChar->GetUID(), true); } } } } pChar->r_Call("f_multi_setup", pChar, nullptr, nullptr, nullptr); } bool CItemMulti::Multi_IsPartOf(const CItem * pItem) const { ADDTOCALLSTACK("CItemMulti::Multi_IsPartOf"); // Assume it is in my area test already. // IT_MULTI // IT_SHIP if (!pItem) { return false; } if (pItem == this) { return true; } if (pItem->m_uidLink == GetUID()) { return true; } const CUID uidItem = pItem->GetUID(); if (GetLockedItemIndex(uidItem) != -1) { return true; } if (GetSecuredContainerIndex(uidItem) != -1) { return true; } if (GetAddonIndex(uidItem) != -1) { return true; } if (GetComponentIndex(uidItem) != -1) { return true; } return false; } CItem * CItemMulti::Multi_FindItemComponent(int iComp) const { ADDTOCALLSTACK("CItemMulti::Multi_FindItemComponent"); if ((int)_lComps.size() > iComp) { return _lComps[(size_t)iComp].ItemFind(); } return nullptr; } CItem * CItemMulti::Multi_FindItemType(IT_TYPE type) const { ADDTOCALLSTACK("CItemMulti::Multi_FindItemType"); // Find a part of this multi nearby. if (!IsTopLevel()) { return nullptr; } CWorldSearch Area(GetTopPoint(), Multi_GetDistanceMax()); Area.SetSearchSquare(true); for (;;) { CItem * pItem = Area.GetItem(); if (pItem == nullptr) { return nullptr; } if (!Multi_IsPartOf(pItem)) { continue; } if (pItem->IsType(type)) { return(pItem); } } } bool CItemMulti::_OnTick() { if (!CCMultiMovable::_OnTick()) { return CItem::_OnTick(); } return true; } void CItemMulti::OnMoveFrom() { ADDTOCALLSTACK("CItemMulti::OnMoveFrom"); // Being removed from the top level. // Might just be moving. if (IsType(IT_MULTI_ADDON)) // Addons doesn't have region, don't try to unrealize it. { CItemMulti *pMulti = m_pRegion->_pMultiLink; if (pMulti) { pMulti->DeleteAddon(GetUID()); } m_pRegion = nullptr; } else { ASSERT(m_pRegion); m_pRegion->UnRealizeRegion(); } } bool CItemMulti::MoveTo(const CPointMap& pt, bool fForceFix) // Put item on the ground here. { ADDTOCALLSTACK("CItemMulti::MoveTo"); // Move this item to it's point in the world. (ground/top level) if (!CItem::MoveTo(pt, fForceFix)) { return false; } // Multis need special region info to track when u are inside them. // Add new region info. if (IsType(IT_MULTI_ADDON)) // Addons doesn't have region, don't try to realize it. { const CPointMap& ptTop = GetTopPoint(); CRegionWorld *pRegion = dynamic_cast<CRegionWorld*>(ptTop.GetRegion(REGION_TYPE_HOUSE)); if (!pRegion) { pRegion = dynamic_cast<CRegionWorld*>(ptTop.GetRegion(REGION_TYPE_AREA)); } ASSERT(pRegion); m_pRegion = pRegion; CItemMulti *pMulti = m_pRegion->_pMultiLink; if (pMulti) { pMulti->AddAddon(GetUID()); } } else { if (m_pRegion) { m_pRegion->UnRealizeRegion(); } MultiRealizeRegion(); } return true; } CItem * CItemMulti::Multi_GetSign() { ADDTOCALLSTACK("CItemMulti::Multi_GetSign"); // Get my sign or tiller link. CItem * pTiller = m_uidLink.ItemFind(); if (pTiller == nullptr) { pTiller = Multi_FindItemType(IsType(IT_SHIP) ? IT_SHIP_TILLER : IT_SIGN_GUMP); if (pTiller == nullptr) { return(this); } m_uidLink = pTiller->GetUID(); // Link the multi to it's sign/tiller } return pTiller; } void CItemMulti::OnHearRegion(lpctstr pszCmd, CChar * pSrc) { ADDTOCALLSTACK("CItemMulti::OnHearRegion"); // IT_SHIP or IT_MULTI const CItemBaseMulti * pMultiDef = Multi_GetDef(); if (pMultiDef == nullptr) return; TALKMODE_TYPE mode = TALKMODE_SAY; for (size_t i = 0; i < pMultiDef->m_Speech.size(); ++i) { CResourceLink * pLink = pMultiDef->m_Speech[i].GetRef(); ASSERT(pLink); CResourceLock s; if (!pLink->ResourceLock(s)) continue; TRIGRET_TYPE iRet = OnHearTrigger(s, pszCmd, pSrc, mode); if (iRet == TRIGRET_ENDIF || iRet == TRIGRET_RET_FALSE) continue; break; } } void CItemMulti::RevokePrivs(const CUID& uidSrc) { ADDTOCALLSTACK("CItemMulti::RevokePrivs"); if (!uidSrc.IsValidUID()) { return; } if (IsOwner(uidSrc)) { SetOwner(CUID()); } else if (GetCoownerIndex(uidSrc) >= 0) { DeleteCoowner(uidSrc, true); } else if (GetFriendIndex(uidSrc) >= 0) { DeleteFriend(uidSrc, true); } else if (GetBanIndex(uidSrc) >= 0) { DeleteBan(uidSrc, true); } else if (GetAccessIndex(uidSrc) >= 0) { DeleteAccess(uidSrc, true); } else if (GetVendorIndex(uidSrc) >= 0) { DeleteVendor(uidSrc, true); } } void CItemMulti::SetOwner(const CUID& uidOwner) { ADDTOCALLSTACK("CItemMulti::SetOwner"); CChar *pOldOwner = _uidOwner.CharFind(); _uidOwner.InitUID(); if (pOldOwner) // Old Owner may not exist, was removed? { if (!pOldOwner->m_pPlayer) { g_Log.EventWarn("Multi (UID 0%x) owned by a NPC (UID 0%x)?\n", (dword)GetUID(), (dword)pOldOwner->GetUID()); } else { CMultiStorage* pMultiStorage = pOldOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } RemoveKeys(pOldOwner->GetUID()); } if (!uidOwner.IsValidUID()) { return; } RevokePrivs(uidOwner); CChar *pOwner = uidOwner.CharFind(); if (pOwner) { if (!pOwner->m_pPlayer) { g_Log.EventWarn("Multi (UID 0%x): trying to set owner to a non-playing character (UID 0%x)?\n", (dword)GetUID(), (dword)uidOwner); } else { CMultiStorage* pMultiStorage = pOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->AddMulti(GetUID(), HP_OWNER); } } } _uidOwner = uidOwner; } bool CItemMulti::IsOwner(const CUID& uidTarget) const { return (_uidOwner == uidTarget); } CUID CItemMulti::GetOwner() const { if (_uidOwner.IsValidUID()) { return _uidOwner; } return {}; } void CItemMulti::SetGuild(const CUID& uidGuild) { ADDTOCALLSTACK("CItemMulti::SetGuild"); CItemStone *pGuildStone = static_cast<CItemStone*>(GetGuildStone().ItemFind()); _uidGuild.InitUID(); if (pGuildStone) // Old Guild may not exist, was it removed...? { CMultiStorage* pMultiStorage = pGuildStone->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); // ... if not, unlink it from this multi. } } if (!uidGuild.IsValidUID()) // Just clearing it { return; } _uidGuild = uidGuild; // Set the Guild* to a new guildstone. pGuildStone = static_cast<CItemStone*>(uidGuild.ItemFind()); CMultiStorage* pMultiStorage = pGuildStone->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_GUILD); } bool CItemMulti::IsGuild(const CUID& uidTarget) const { return (_uidGuild == uidTarget); } CUID CItemMulti::GetGuildStone() const { if (_uidGuild.IsValidUID()) { return _uidGuild; } return {}; } void CItemMulti::AddCoowner(const CUID& uidCoowner) { ADDTOCALLSTACK("CItemMulti::AddCoowner"); if (!uidCoowner.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetCoownerIndex(uidCoowner) >= 0) { return; } } CChar *pCoowner = uidCoowner.CharFind(); if (!pCoowner || !pCoowner->m_pPlayer) { return; } RevokePrivs(uidCoowner); CMultiStorage* pMultiStorage = pCoowner->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_COOWNER); _lCoowners.emplace_back(uidCoowner); } void CItemMulti::DeleteCoowner(const CUID& uidCoowner, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteCoowner"); for (size_t i = 0; i < _lCoowners.size(); ++i) { const CUID& uid = _lCoowners[i]; if (uid == uidCoowner) { if (fRemoveFromList) { _lCoowners.erase(_lCoowners.begin() + i); } CChar *pCoowner = uidCoowner.CharFind(); if (!pCoowner || !pCoowner->m_pPlayer) { continue; } CMultiStorage* pMultiStorage = pCoowner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } RemoveKeys(uid); return; } } } size_t CItemMulti::GetCoownerCount() const { return _lCoowners.size(); } int CItemMulti::GetCoownerIndex(const CUID& uidTarget) const { ADDTOCALLSTACK("CItemMulti::GetCoownerIndex"); if (_lCoowners.empty()) { return -1; } for (size_t i = 0; i < _lCoowners.size(); ++i) { if (_lCoowners[i] == uidTarget) { return (int)i; } } return -1; } void CItemMulti::AddFriend(const CUID& uidFriend) { ADDTOCALLSTACK("CItemMulti::AddFriend"); if (!uidFriend.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetFriendIndex(uidFriend) >= 0) { return; } } CChar *pFriend = uidFriend.CharFind(); if (!pFriend || !pFriend->m_pPlayer) { return; } RevokePrivs(uidFriend); CMultiStorage* pMultiStorage = pFriend->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_FRIEND); _lFriends.emplace_back(uidFriend); } void CItemMulti::DeleteFriend(const CUID& uidFriend, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteFriend"); for (size_t i = 0; i < _lFriends.size(); ++i) { if (_lFriends[i] == uidFriend) { if (fRemoveFromList) { _lFriends.erase(_lFriends.begin() + i); } CChar *pFriend = uidFriend.CharFind(); if (!pFriend || !pFriend->m_pPlayer) { continue; } CMultiStorage* pMultiStorage = pFriend->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } RemoveKeys(uidFriend); return; } } } size_t CItemMulti::GetFriendCount() const { return _lFriends.size(); } int CItemMulti::GetFriendIndex(const CUID& uidFriend) const { ADDTOCALLSTACK("CItemMulti::GetFriendIndex"); if (_lFriends.empty()) { return -1; } for (size_t i = 0; i < _lFriends.size(); ++i) { if (_lFriends[i] == uidFriend) { return (int)i; } } return -1; } void CItemMulti::AddBan(const CUID& uidBan) { ADDTOCALLSTACK("CItemMulti::AddBan"); if (!uidBan.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetBanIndex(uidBan) >= 0) { return; } } CChar *pBan = uidBan.CharFind(); if (!pBan || !pBan->m_pPlayer) { return; } RevokePrivs(uidBan); CMultiStorage* pMultiStorage = pBan->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_BAN); _lBans.emplace_back(uidBan); } void CItemMulti::DeleteBan(const CUID& uidBan, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteBan"); for (size_t i = 0; i < _lBans.size(); ++i) { if (_lBans[i] == uidBan) { if (fRemoveFromList) { _lBans.erase(_lBans.begin() + i); } CChar *pBan = uidBan.CharFind(); if (pBan && pBan->m_pPlayer) { CMultiStorage* pMultiStorage = pBan->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } return; } } } size_t CItemMulti::GetBanCount() const { return _lBans.size(); } int CItemMulti::GetBanIndex(const CUID& uidBan) const { ADDTOCALLSTACK("CItemMulti::GetBanIndex"); if (_lBans.empty()) { return -1; } for (size_t i = 0; i < _lBans.size(); ++i) { if (_lBans[i] == uidBan) { return (int)i; } } return -1; } void CItemMulti::AddAccess(const CUID& uidAccess) { ADDTOCALLSTACK("CItemMulti::AddAccess"); if (!uidAccess.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetAccessIndex(uidAccess) >= 0) { return; } } CChar *pAccess = uidAccess.CharFind(); if (!pAccess || !pAccess->m_pPlayer) { return; } RevokePrivs(uidAccess); CMultiStorage* pMultiStorage = pAccess->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_ACCESSONLY); _lAccesses.emplace_back(uidAccess); } void CItemMulti::DeleteAccess(const CUID& uidAccess, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteAccess"); for (size_t i = 0; i < _lAccesses.size(); ++i) { if (_lAccesses[i] == uidAccess) { if (fRemoveFromList) { _lAccesses.erase(_lAccesses.begin() + i); } CChar *pAccess = uidAccess.CharFind(); if (pAccess && pAccess->m_pPlayer) { CMultiStorage* pMultiStorage = pAccess->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } return; } } } size_t CItemMulti::GetAccessCount() const { return _lAccesses.size(); } int CItemMulti::GetAccessIndex(const CUID& uidAccess) const { if (_lAccesses.empty()) { return -1; } for (size_t i = 0; i < _lAccesses.size(); ++i) { if (_lAccesses[i] == uidAccess) { return (int)i; } } return -1; } void CItemMulti::Eject(const CUID& uidChar) { if (!uidChar.IsValidUID()) { return; } CChar *pChar = uidChar.CharFind(); ASSERT(pChar); pChar->Spell_Teleport(m_uidLink.ItemFind()->GetTopPoint(), true, false); } void CItemMulti::EjectAll(CUID uidCharNoTp) { CWorldSearch Area(m_pRegion->m_pt, Multi_GetDistanceMax()); Area.SetSearchSquare(true); CChar *pCharNoTp = uidCharNoTp.CharFind(); for (;;) { CChar * pChar = Area.GetChar(); if (pChar == nullptr) { break; } if (pChar->m_pArea != m_pRegion) { continue; } if (pChar == pCharNoTp) // Eject all but owner? ie enter customize { continue; } Eject(pChar->GetUID()); } } CItem *CItemMulti::GenerateKey(const CUID& uidTarget, bool fDupeOnBank) { ADDTOCALLSTACK("CItemMulti::GenerateKey"); if (!uidTarget.IsValidUID()) { return nullptr; } CChar *pTarget = uidTarget.CharFind(); if (!pTarget) { return nullptr; } // Create the key to the door. ITEMID_TYPE id = IsAttr(ATTR_MAGIC) ? ITEMID_KEY_MAGIC : ITEMID_KEY_COPPER; CItem *pKey = CreateScript(id, pTarget); ASSERT(pKey); pKey->SetType(IT_KEY); if (g_Cfg.m_fAutoNewbieKeys) { pKey->SetAttr(ATTR_NEWBIE); } pKey->SetAttr(m_Attr&ATTR_MAGIC); pKey->m_itKey.m_UIDLock.SetPrivateUID(GetUID()); pKey->m_uidLink = GetUID(); if (fDupeOnBank) { // Put in your bankbox CItem* pKeyDupe = CItem::CreateDupeItem(pKey); CItemContainer* pContBank = pTarget->GetBank(); pContBank->ContentAdd(pKeyDupe); pTarget->SysMessageDefault(DEFMSG_MSG_KEY_DUPEBANK); } // Put in your pack CItemContainer* pContPack = pTarget->GetPackSafe(); pContPack->ContentAdd(pKey); return pKey; } void CItemMulti::RemoveKeys(const CUID& uidTarget) { ADDTOCALLSTACK("CItemMulti::RemoveKeys"); if (!uidTarget.IsValidUID()) { return; } CChar* pTarget = uidTarget.CharFind(); if (!pTarget) { return; } const CUID uidHouse(GetUID()); CItemContainer* pTargPack = pTarget->GetPack(); if (pTargPack) { for (CSObjContRec* pObjRec : pTargPack->GetIterationSafeCont()) { CItem* pItemKey = static_cast<CItem*>(pObjRec); if (pItemKey->m_uidLink == uidHouse) { pItemKey->Delete(); } } } } void CItemMulti::RemoveAllKeys() { ADDTOCALLSTACK("CItemMulti::RemoveAllKeys"); if (g_Cfg._fAutoHouseKeys == 0) // Only when AutoHouseKeys != 0 { return; } RemoveKeys(GetOwner()); if (!_lCoowners.empty()) { for (const CUID& itCoowner : _lCoowners) { RemoveKeys(itCoowner); } } if (!_lFriends.empty()) { for (const CUID& itFriend : _lFriends) { RemoveKeys(itFriend); } } if (!_lAccesses.empty()) { for (const CUID& itAccess : _lAccesses) { RemoveKeys(itAccess); } } } int16 CItemMulti::GetMultiCount() const { return _iMultiCount; } void CItemMulti::Redeed(bool fDisplayMsg, bool fMoveToBank, CUID uidChar) { ADDTOCALLSTACK("CItemMulti::Redeed"); if (GetKeyNum("REMOVED") > 0) // Just don't pass from here again, to avoid duplicated deeds. { return; } TRIGRET_TYPE tRet = TRIGRET_RET_FALSE; bool fTransferAll = false; ITEMID_TYPE itDeed = IsType(IT_SHIP) ? ITEMID_SHIP_PLANS1 : ITEMID_DEED1; CItem *pDeed = CItem::CreateBase(itDeed); ASSERT(pDeed); tchar *pszName = Str_GetTemp(); const CItemBaseMulti * pItemBase = static_cast<const CItemBaseMulti*>(Base_GetDef()); snprintf(pszName, STR_TEMPLENGTH, g_Cfg.GetDefaultMsg(DEFMSG_DEED_NAME), pItemBase->GetName()); pDeed->SetName(pszName); bool fIsAddon = IsType(IT_MULTI_ADDON); if (fIsAddon) { CItemMulti *pMulti = static_cast<CItemMulti*>(m_uidLink.ItemFind()); if (pMulti) { pMulti->DeleteAddon(GetUID()); } } CScriptTriggerArgs args(pDeed); args.m_iN1 = itDeed; args.m_iN2 = 1; // Transfer / Redeed all items to the moving crate. args.m_iN3 = fMoveToBank; // Transfer the Moving Crate to the owner's bank. if (IsTrigUsed(TRIGGER_REDEED)) { tRet = OnTrigger(ITRIG_Redeed, uidChar.CharFind(), &args); if (args.m_iN2 == 0) { fMoveToBank = false; } else { fTransferAll = true; fMoveToBank = args.m_iN3 ? true : false; } } RemoveAllComponents(); if (!fIsAddon) // Addons doesn't have to transfer anything but themselves. { if (fTransferAll) { TransferAllItemsToMovingCrate(TRANSFER_ALL); // Whatever is left unlisted. } } CChar* pOwner = GetOwner().CharFind(); if (!pOwner || !pOwner->m_pPlayer) { return; } if (!fIsAddon) { if (fMoveToBank) { TransferMovingCrateToBank(); } CMultiStorage* pMultiStorage = pOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } if (tRet == TRIGRET_RET_TRUE) { pDeed->Delete(); return; } pDeed->SetHue(GetHue()); pDeed->m_itDeed.m_Type = GetID(); if (m_Attr & ATTR_MAGIC) { pDeed->SetAttr(ATTR_MAGIC); } if (fMoveToBank) { pOwner->GetBank(LAYER_BANKBOX)->ContentAdd(pDeed); } else { pOwner->ItemBounce(pDeed, fDisplayMsg); } SetKeyNum("REMOVED", 1); Delete(); } void CItemMulti::SetMovingCrate(const CUID& uidCrate) { ADDTOCALLSTACK("CItemMulti::SetMovingCrate"); CItemContainer *pCurrentCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); CItemContainer *pNewCrate = static_cast<CItemContainer*>(uidCrate.ItemFind()); if (!uidCrate.IsValidUID() || !pNewCrate) { _uidMovingCrate.InitUID(); return; } if (pCurrentCrate && !pCurrentCrate->IsContainerEmpty()) { pCurrentCrate->SetCrateOfMulti(CUID()); pNewCrate->ContentsTransfer(pCurrentCrate, false); pCurrentCrate->Delete(); } _uidMovingCrate = uidCrate; pNewCrate->m_uidLink = GetUID(); pNewCrate->r_ExecSingle("EVENTS +ei_moving_crate"); pNewCrate->SetCrateOfMulti(GetUID()); } CUID CItemMulti::GetMovingCrate(bool fCreate) { ADDTOCALLSTACK("CItemMulti::GetMovingCrate"); if (_uidMovingCrate.IsValidUID()) { return _uidMovingCrate; } if (!fCreate) { return CUID(); } CItemContainer *pCrate = static_cast<CItemContainer*>(CItem::CreateBase(ITEMID_CRATE1)); ASSERT(pCrate); const CUID& uidCrate = pCrate->GetUID(); CPointMap pt = GetTopPoint(); pt.m_z -= 20; pCrate->MoveTo(pt); // Move the crate to z -20 pCrate->Update(); SetMovingCrate(uidCrate); return uidCrate; } void CItemMulti::TransferAllItemsToMovingCrate(TRANSFER_TYPE iType) { ADDTOCALLSTACK("CItemMulti::TransferAllItemsToMovingCrate"); CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); ASSERT(pCrate); //Transfer Types const bool fTransferAddons = ((iType & TRANSFER_ADDONS) || (iType & TRANSFER_ALL)); const bool fTransferAll = (iType & TRANSFER_ALL); const bool fTransferLockDowns = ((iType & TRANSFER_LOCKDOWNS) || (iType & TRANSFER_ALL)); const bool fTransferSecuredContainers = ((iType &TRANSFER_SECURED) || (iType & TRANSFER_ALL)); if (fTransferLockDowns) // Try to move locked down items, also to reduce the CWorldSearch impact. { TransferLockdownsToMovingCrate(); } if (fTransferSecuredContainers) { TransferSecuredToMovingCrate(); } if (fTransferAddons) { RedeedAddons(); } CPointMap ptArea; if (IsType(IT_MULTI_ADDON)) { ptArea = GetTopPoint().GetRegion(REGION_TYPE_HOUSE)->m_pt; // Addons doesnt have Area, search in the above region. } else { ptArea = m_pRegion->m_pt; } CWorldSearch Area(ptArea, Multi_GetDistanceMax()); // largest area. Area.SetSearchSquare(true); for (;;) { CItem * pItem = Area.GetItem(); if (pItem == nullptr) { break; } if (pItem->GetTopPoint().GetRegion(REGION_TYPE_HOUSE) != GetTopPoint().GetRegion(REGION_TYPE_HOUSE)) { continue; } if (pItem->IsType(IT_STONE_GUILD)) { continue; } if (pItem->GetUID() == GetUID() || pItem->GetUID() == pCrate->GetUID()) // Multi itself or the Moving Crate, neither is not handled here. { continue; } if (GetComponentIndex(pItem->GetUID()) != -1) // Components should never be transfered. { continue; } if (!fTransferAll) { if (!fTransferLockDowns && pItem->IsAttr(ATTR_LOCKEDDOWN)) // Skip this item if its locked down and we don't want to TRANSFER_LOCKDOWNS. { continue; } else if (!fTransferSecuredContainers && pItem->IsAttr(ATTR_SECURE)) // Skip this item if it's secured (container) and we don't want to TRANSFER_SECURED. { continue; } else if (pItem->IsType(IT_MULTI_ADDON) || pItem->IsType(IT_MULTI)) // If the item is a house Addon, redeed it. { if (fTransferAddons) // Shall be transfered, but addons needs an special transfer code by redeeding. { static_cast<CItemMulti*>(pItem)->Redeed(false, false); Area.RestartSearch(); // we removed an item and this will mess the search loop, so restart to fix it. continue; } else { continue; } } else if (!Multi_IsPartOf(pItem)) // Items not linked to, or listed on, this multi. { continue; } } pItem->RemoveFromView(); pCrate->ContentAdd(pItem); } if (pCrate->IsContainerEmpty()) { pCrate->Delete(); } } void CItemMulti::TransferLockdownsToMovingCrate() { ADDTOCALLSTACK("CItemMulti::TransferLockdownsToMovingCrate"); if (_lLockDowns.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } for (size_t i = 0; i < _lLockDowns.size(); ++i) { CItem *pItem = _lLockDowns[i].ItemFind(); if (pItem) // Move all valid items. { pItem->r_ExecSingle("EVENTS -ei_house_lockdown"); pCrate->ContentAdd(pItem); pItem->ClrAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink.InitUID(); } } _lLockDowns.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::TransferSecuredToMovingCrate() { ADDTOCALLSTACK("CItemMulti::TransferSecuredToMovingCrate"); if (_lSecureContainers.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } for (size_t i = 0; i < _lSecureContainers.size(); ++i) { CItemContainer *pItem = static_cast<CItemContainer*>(_lSecureContainers[i].ItemFind()); if (pItem) // Move all valid items. { pItem->r_ExecSingle("EVENTS -ei_house_secure"); pCrate->ContentAdd(pItem); pItem->ClrAttr(ATTR_SECURE); pItem->m_uidLink.InitUID(); } } _lLockDowns.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::RedeedAddons() { ADDTOCALLSTACK("CItemMulti::RedeedAddons"); if (_lAddons.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } std::vector<CUID> vAddons = _lAddons; for (size_t i = 0; i < vAddons.size(); ++i) { CItemMulti *pAddon = static_cast<CItemMulti*>(vAddons[i].ItemFind()); if (pAddon) // Move all valid items. { pAddon->Redeed(false, false); } } vAddons.clear(); _lAddons.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::TransferMovingCrateToBank() { ADDTOCALLSTACK("CItemMulti::TransferMovingCrateToBank"); CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); CChar *pOwner = GetOwner().CharFind(); if (pCrate && pOwner) { if (!pCrate->IsContainerEmpty()) { if (pOwner) { pCrate->RemoveFromView(); CItemContainer *pBank = pOwner->GetBank(); ASSERT(pBank); pBank->ContentAdd(pCrate); } } else { pCrate->Delete(); } } } void CItemMulti::AddAddon(const CUID& uidAddon) { ADDTOCALLSTACK("CItemMulti::AddAddon"); if (!uidAddon.IsValidUID()) { return; } CItemMulti *pAddon = static_cast<CItemMulti*>(uidAddon.ItemFind()); if (!pAddon) { return; } if (!g_Serv.IsLoading()) { if (!pAddon->IsType(IT_MULTI_ADDON)) { return; } if (GetAddonIndex(uidAddon) >= 0) { return; } } _lAddons.emplace_back(uidAddon); } void CItemMulti::DeleteAddon(const CUID& uidAddon) { ADDTOCALLSTACK("CItemMulti::DeleteAddon"); for (size_t i = 0; i < _lAddons.size(); ++i) { if (_lAddons[i] == uidAddon) { _lAddons.erase(_lAddons.begin() + i); return; } } } int CItemMulti::GetAddonIndex(const CUID& uidAddon) const { if (_lAddons.empty()) { return -1; } for (size_t i = 0; i < _lAddons.size(); ++i) { if (_lAddons[i] == uidAddon) { return (int)i; } } return -1; } size_t CItemMulti::GetAddonCount() const { return _lAddons.size(); } void CItemMulti::AddComponent(const CUID& uidComponent) { ADDTOCALLSTACK("CItemMulti::AddComponent"); if (!uidComponent.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetComponentIndex(uidComponent) >= 0) { return; } } CItem *pComp = uidComponent.ItemFind(); if (pComp) { pComp->SetComponentOfMulti(GetUID()); } _lComps.emplace_back(uidComponent); } void CItemMulti::DeleteComponent(const CUID& uidComponent, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteComponent"); if (fRemoveFromList) { _lComps.erase(std::find(_lComps.begin(), _lComps.end(), uidComponent)); } if (!uidComponent.IsValidUID()) // Doing this after the erase to force check the vector, just in case... { return; } CItem *pComp = uidComponent.ItemFind(); if (pComp) { pComp->SetComponentOfMulti(CUID()); } } int CItemMulti::GetComponentIndex(const CUID& uidComponent) const { if (_lComps.empty()) { return -1; } for (size_t i = 0; i < _lComps.size(); ++i) { if (_lComps[i] == uidComponent) { return (int)i; } } return -1; } size_t CItemMulti::GetComponentCount() const { return _lComps.size(); } void CItemMulti::RemoveAllComponents() { ADDTOCALLSTACK("CItemMulti::RemoveAllComponents"); if (_lComps.empty()) { return; } const std::vector<CUID> lCopy(_lComps); for (size_t i = 0; i < lCopy.size(); ++i) { CItem *pComp = lCopy[i].ItemFind(); if (pComp) { pComp->Delete(); } } _lComps.clear(); } void CItemMulti::GenerateBaseComponents(bool *pfNeedKey, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::GenerateBaseComponents"); const CItemBaseMulti * pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); for (size_t i = 0; i < pMultiDef->m_Components.size(); ++i) { const CItemBaseMulti::CMultiComponentItem &component = pMultiDef->m_Components[i]; *pfNeedKey |= Multi_CreateComponent(component.m_id, component.m_dx, component.m_dy, component.m_dz, dwKeyCode); } } void CItemMulti::SetBaseStorage(uint16 iLimit) { _uiBaseStorage = iLimit; } uint16 CItemMulti::GetBaseStorage() const { return _uiBaseStorage; } void CItemMulti::SetIncreasedStorage(uint16 uiIncrease) { _uiIncreasedStorage = uiIncrease; } uint16 CItemMulti::GetIncreasedStorage() const { return _uiIncreasedStorage; } uint16 CItemMulti::GetMaxStorage() const { return _uiBaseStorage + ((_uiBaseStorage * _uiIncreasedStorage) / 100); } uint16 CItemMulti::GetCurrentStorage() const { return (int16)(_lLockDowns.size() + _lSecureContainers.size()); } void CItemMulti::SetBaseVendors(uint8 iLimit) { _uiBaseVendors = iLimit; } uint8 CItemMulti::GetBaseVendors() const { return _uiBaseVendors; } uint8 CItemMulti::GetMaxVendors() const { return (uint8)(_uiBaseVendors + (_uiBaseVendors * GetIncreasedStorage()) / 100); } uint16 CItemMulti::GetMaxLockdowns() const { uint16 uiMaxStorage = GetMaxStorage(); return (uiMaxStorage - (uiMaxStorage - (uiMaxStorage * (uint16)GetLockdownsPercent()) / 100)); } uint8 CItemMulti::GetLockdownsPercent() const { return _uiLockdownsPercent; } void CItemMulti::SetLockdownsPercent(uint8 iPercent) { _uiLockdownsPercent = iPercent; } void CItemMulti::LockItem(const CUID& uidItem) { ADDTOCALLSTACK("CItemMulti::LockItem"); if (!uidItem.IsValidUID()) { return; } CItem *pItem = uidItem.ItemFind(); ASSERT(pItem); if (!g_Serv.IsLoading()) { if (GetLockedItemIndex(uidItem) >= 0) { return; } pItem->SetAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink = GetUID(); pItem->r_ExecSingle("EVENTS +ei_house_lockdown"); } pItem->SetLockDownOfMulti(uidItem); _lLockDowns.emplace_back(uidItem); } void CItemMulti::UnlockItem(const CUID& uidItem, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::UnlockItem"); if (fRemoveFromList) { _lLockDowns.erase(std::find(_lLockDowns.begin(), _lLockDowns.end(), uidItem)); } CItem *pItem = uidItem.ItemFind(); if (!pItem) { return; } pItem->ClrAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink.InitUID(); pItem->r_ExecSingle("EVENTS -ei_house_lockdown"); pItem->SetLockDownOfMulti(CUID()); } void CItemMulti::UnlockAllItems() { ADDTOCALLSTACK("CItemMulti::UnlockAllItems"); for (const CUID& uidLockeddown : _lLockDowns) { CItem *pItem = uidLockeddown.ItemFind(true); if (!pItem) continue; UnlockItem(uidLockeddown, false); } _lLockDowns.clear(); } int CItemMulti::GetLockedItemIndex(const CUID& uidItem) const { if (_lLockDowns.empty()) { return -1; } for (size_t i = 0; i < _lLockDowns.size(); ++i) { if (_lLockDowns[i] == uidItem) { return (int)i; } } return -1; } size_t CItemMulti::GetLockdownCount() const { return _lLockDowns.size() + _lSecureContainers.size(); } void CItemMulti::Secure(const CUID& uidContainer) { ADDTOCALLSTACK("CItemMulti::Secure"); if (!uidContainer.IsValidUID()) { return; } CItemContainer *pContainer = static_cast<CItemContainer*>(uidContainer.ItemFind()); ASSERT(pContainer); if (!g_Serv.IsLoading()) { if (GetSecuredContainerIndex(uidContainer) >= 0) { return; } pContainer->SetAttr(ATTR_SECURE); pContainer->m_uidLink = GetUID(); pContainer->r_ExecSingle("EVENTS +ei_house_secure"); } pContainer->SetSecuredOfMulti(GetUID()); _lSecureContainers.emplace_back(uidContainer); } void CItemMulti::Release(const CUID& uidContainer, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::Release"); if (fRemoveFromList) { _lLockDowns.erase(std::remove(_lLockDowns.begin(), _lLockDowns.end(), uidContainer)); } CItemContainer *pContainer = static_cast<CItemContainer*>(uidContainer.ItemFind()); if (!pContainer) { return; } pContainer->ClrAttr(ATTR_SECURE); pContainer->m_uidLink.InitUID(); pContainer->r_ExecSingle("EVENTS -ei_house_secure"); pContainer->SetSecuredOfMulti(CUID()); } int CItemMulti::GetSecuredContainerIndex(const CUID& uidContainer) const { ADDTOCALLSTACK("CItemMulti::GetSecuredContainerIndex"); if (_lSecureContainers.empty()) { return -1; } for (size_t i = 0; i < _lSecureContainers.size(); ++i) { if (_lSecureContainers[i] == uidContainer) { return (int)i; } } return -1; } int16 CItemMulti::GetSecuredItemsCount() const { ADDTOCALLSTACK("CItemMulti::GetSecuredItemsCount"); size_t iCount = 0; for (size_t i = 0; i < _lSecureContainers.size(); ++i) { CItemContainer *pContainer = static_cast<CItemContainer*>(_lSecureContainers[i].ItemFind()); if (pContainer) { iCount += pContainer->GetContentCount(); } } return (int16)iCount; } size_t CItemMulti::GetSecuredContainersCount() const { return _lSecureContainers.size(); } void CItemMulti::AddVendor(const CUID& uidVendor) { ADDTOCALLSTACK("CItemMulti::AddVendor"); if (!uidVendor.IsValidUID()) { return; } if ((g_Serv.IsLoading() == false) && (GetVendorIndex(uidVendor) >= 0)) { return; } CChar *pVendor = uidVendor.CharFind(); if (!pVendor || !pVendor->m_pPlayer) { return; } RevokePrivs(uidVendor); CMultiStorage* pMultiStorage = pVendor->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_VENDOR); _lVendors.emplace_back(uidVendor); } void CItemMulti::DeleteVendor(const CUID& uidVendor, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteVendor"); for (size_t i = 0; i < _lVendors.size(); ++i) { if (_lVendors[i] == uidVendor) { if (fRemoveFromList) { _lVendors.erase(_lVendors.begin() + i); } CChar *pVendor = uidVendor.CharFind(); if (pVendor && pVendor->m_pPlayer) { CMultiStorage* pMultiStorage = pVendor->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } break; } } } int CItemMulti::GetVendorIndex(const CUID& uidVendor) const { ADDTOCALLSTACK("CItemMulti::GetVendorIndex"); if (_lVendors.empty()) { return -1; } for (size_t i = 0; i < _lVendors.size(); ++i) { if (_lVendors[i] == uidVendor) { return (int)i; } } return -1; } size_t CItemMulti::GetVendorCount() { return _lVendors.size(); } enum MULTIREF_REF { SHR_ACCESS, SHR_ADDON, SHR_BAN, SHR_COMP, SHR_COOWNER, SHR_FRIEND, SHR_GUILD, SHR_LOCKDOWN, SHR_MOVINGCRATE, SHR_OWNER, SHR_REGION, SHR_SECURED, SHR_VENDOR, SHR_QTY }; lpctstr const CItemMulti::sm_szRefKeys[SHR_QTY + 1] = { "ACCESS", "ADDON", "BAN", "COMP", "COOWNER", "FRIEND", "GUILD", "LOCKDOWN", "MOVINGCRATE", "OWNER", "REGION", "SECURED", "VENDOR", nullptr }; bool CItemMulti::r_GetRef(lpctstr & ptcKey, CScriptObj * & pRef) { ADDTOCALLSTACK("CItemMulti::r_GetRef"); int iCmd = FindTableHeadSorted(ptcKey, sm_szRefKeys, CountOf(sm_szRefKeys) - 1); if (iCmd >= 0) { ptcKey += strlen(sm_szRefKeys[iCmd]); } switch (iCmd) { case SHR_ACCESS: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lAccesses.size() > idx) { CChar *pAccess = _lAccesses[idx].CharFind(); if (pAccess) { pRef = pAccess; return true; } } return false; } case SHR_ADDON: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lAddons.size() > idx) { CItemMulti *pAddon = static_cast<CItemMulti*>(_lAddons[idx].ItemFind()); if (pAddon) { pRef = pAddon; return true; } } return false; } case SHR_BAN: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lBans.size() > idx) { CChar *pBan = _lBans[idx].CharFind(); if (pBan) { pRef = pBan; return true; } } return false; } case SHR_COMP: { const int idx = Exp_GetVal(ptcKey); SKIP_SEPARATORS(ptcKey); CItem *pComp = Multi_FindItemComponent(idx); if (pComp) { pRef = pComp; return true; } return false; } case SHR_COOWNER: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lCoowners.size() > idx) { CChar *pCoowner = _lCoowners[idx].CharFind(); if (pCoowner) { pRef = pCoowner; return true; } } return false; } case SHR_FRIEND: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lFriends.size() > idx) { CChar *pFriend = _lFriends[idx].CharFind(); if (pFriend) { pRef = pFriend; return true; } } return false; } case SHR_LOCKDOWN: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lLockDowns.size() > idx) { CItem *plockdown = _lLockDowns[idx].ItemFind(); if (plockdown) { pRef = plockdown; return true; } } return false; } case SHR_MOVINGCRATE: { SKIP_SEPARATORS(ptcKey); pRef = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); return true; } case SHR_OWNER: { SKIP_SEPARATORS(ptcKey); pRef = _uidOwner.CharFind(); return true; } case SHR_GUILD: { SKIP_SEPARATORS(ptcKey); pRef = static_cast<CItemStone*>(_uidGuild.ItemFind()); return true; } case SHR_REGION: { SKIP_SEPARATORS(ptcKey); if (m_pRegion != nullptr) { pRef = m_pRegion; // Addons do not have region so return it only when not nullptr. return true; } return false; } case SHR_SECURED: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lSecureContainers.size() > idx) { CItem *pItem = _lSecureContainers[idx].ItemFind(); if (pItem) { CItemContainer *pCont = static_cast<CItemContainer*>(pItem); pRef = pCont; return true; } } return false; } case SHR_VENDOR: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lVendors.size() > idx) { CChar *pVendor = _lVendors[idx].CharFind(); if (pVendor) { pRef = pVendor; return true; } } return false; } default: break; } return(CItem::r_GetRef(ptcKey, pRef)); } enum { SHV_DELACCESS, SHV_DELADDON, SHV_DELBAN, SHV_DELCOMPONENT, SHV_DELCOOWNER, SHV_DELFRIEND, SHV_DELVENDOR, SHV_GENERATEBASECOMPONENTS, SHV_MOVEALLTOCRATE, SHV_MOVELOCKSTOCRATE, SHV_MULTICREATE, SHV_REDEED, SHV_RELEASE, SHV_REMOVEALLCOMPS, SHV_REMOVEKEYS, SHV_UNLOCKITEM, SHV_QTY }; lpctstr const CItemMulti::sm_szVerbKeys[SHV_QTY + 1] = { "DELACCESS", "DELADDON", "DELBAN", "DELCOMPONENT", "DELCOOWNER", "DELFRIEND", "DELVENDOR", "GENERATEBASECOMPONENTS", "MOVEALLTOCRATE", "MOVELOCKSTOCRATE", "MULTICREATE", "REDEED", "RELEASE", "REMOVEALLCOMPS", "REMOVEKEYS", "UNLOCKITEM", nullptr }; bool CItemMulti::r_Verb(CScript & s, CTextConsole * pSrc) // Execute command from script { ADDTOCALLSTACK("CItemMulti::r_Verb"); EXC_TRY("Verb"); // Speaking in this multis region. // return: true = command for the multi. if (CCMultiMovable::r_Verb(s, pSrc)) { return true; } const int iCmd = FindTableSorted(s.GetKey(), sm_szVerbKeys, CountOf(sm_szVerbKeys) - 1); switch (iCmd) { case SHV_DELACCESS: { const CUID uidAccess(s.GetArgDWVal()); if (!uidAccess.IsValidUID()) { _lAccesses.clear(); } else { DeleteAccess(uidAccess, true); } break; } case SHV_DELADDON: { const CUID uidAddon(s.GetArgDWVal()); if (!uidAddon.IsValidUID()) { _lAddons.clear(); } else { DeleteAddon(uidAddon); } break; } case SHV_DELBAN: { const CUID uidBan(s.GetArgDWVal()); if (!uidBan.IsValidUID()) { _lBans.clear(); } else { DeleteBan(uidBan, true); } break; } case SHV_DELCOMPONENT: { const CUID uidComp(s.GetArgDWVal()); if (!uidComp.IsValidUID()) { _lComps.clear(); } else { DeleteComponent(uidComp, true); } break; } case SHV_DELCOOWNER: { const CUID uidCoowner(s.GetArgDWVal()); if (!uidCoowner.IsValidUID()) { _lCoowners.clear(); } else { DeleteCoowner(uidCoowner, true); } break; } case SHV_DELFRIEND: { const CUID uidFriend(s.GetArgDWVal()); if (!uidFriend.IsValidUID()) { _lFriends.clear(); } else { DeleteFriend(uidFriend, true); } break; } case SHV_DELVENDOR: { const CUID uidVendor(s.GetArgDWVal()); if (!uidVendor.IsValidUID()) { _lVendors.clear(); } else { DeleteVendor(uidVendor, true); } break; } case SHV_UNLOCKITEM: { const CUID uidItem(s.GetArgDWVal()); if (!uidItem.IsValidUID()) { UnlockAllItems(); } else { UnlockItem(uidItem, true); } break; } case SHV_MOVEALLTOCRATE: { TransferAllItemsToMovingCrate((TRANSFER_TYPE)s.GetArgDWVal()); break; } case SHV_MOVELOCKSTOCRATE: { TransferLockdownsToMovingCrate(); break; } case SHV_MULTICREATE: { CUID uidChar(s.GetArgDWVal()); CChar *pCharSrc = uidChar.CharFind(); Multi_Setup(pCharSrc, 0); break; } case SHV_REDEED: { int64 piCmd[2]; Str_ParseCmds(s.GetArgStr(), piCmd, CountOf(piCmd)); const bool fShowMsg = piCmd[0] ? true : false; const bool fMoveToBank = piCmd[1] ? true : false; CUID charUID; if (pSrc && pSrc->GetChar()) { charUID.SetPrivateUID(pSrc->GetChar()->GetUID()); } else if (GetOwner().CharFind()) { charUID.SetPrivateUID(GetOwner()); } else { g_Log.EventError("Trying to redeed %s (0x%" PRIx32 ") with no redeed target, removing it instead.\n", GetName(), (dword)GetUID()); Delete(); return true; } Redeed(fShowMsg, fMoveToBank, charUID); break; } case SHV_RELEASE: { const CUID uidRelease(s.GetArgDWVal()); if (!uidRelease.IsValidUID()) { _lAccesses.clear(); } else { Release(uidRelease, true); } break; } case SHV_REMOVEKEYS: { const CUID uidChar(s.GetArgDWVal()); RemoveKeys(uidChar); break; } case SHV_REMOVEALLCOMPS: { RemoveAllComponents(); break; } case SHV_GENERATEBASECOMPONENTS: { bool fNeedKey = false; GenerateBaseComponents(&fNeedKey, UID_CLEAR); break; } default: { return CItem::r_Verb(s, pSrc); } } EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPTSRC; EXC_DEBUG_END; return true; } enum SHL_TYPE { SHL_ACCESSES, SHL_ADDACCESS, SHL_ADDADDON, SHL_ADDBAN, SHL_ADDCOMP, SHL_ADDCOOWNER, SHL_ADDFRIEND, SHL_ADDKEY, SHL_ADDONS, SHL_ADDVENDOR, SHL_BANS, SHL_BASESTORAGE, SHL_BASEVENDORS, SHL_COMPS, SHL_COOWNERS, SHL_CURRENTSTORAGE, SHL_FRIENDS, SHL_GETACCESSPOS, SHL_GETADDONPOS, SHL_GETBANPOS, SHL_GETCOMPPOS, SHL_GETCOOWNERPOS, SHL_GETFRIENDPOS, SHL_GETHOUSEVENDORPOS, SHL_GETLOCKEDITEMPOS, SHL_GETSECUREDCONTAINERPOS, SHL_GETSECUREDCONTAINERS, SHL_GETSECUREDITEMS, SHL_GUILD, SHL_HOUSETYPE, SHL_INCREASEDSTORAGE, SHL_ISOWNER, SHL_LOCKDOWNS, SHL_LOCKDOWNSPERCENT, SHL_LOCKITEM, SHL_MAXLOCKDOWNS, SHL_MAXSTORAGE, SHL_MAXVENDORS, SHL_MOVINGCRATE, SHL_OWNER, SHL_PRIV, SHL_REGION, SHL_REMOVEKEYS, SHL_SECURE, SHL_VENDORS, SHL_QTY }; const lpctstr CItemMulti::sm_szLoadKeys[SHL_QTY + 1] = { "ACCESSES", "ADDACCESS", "ADDADDON", "ADDBAN", "ADDCOMP", "ADDCOOWNER", "ADDFRIEND", "ADDKEY", "ADDONS", "ADDVENDOR", "BANS", "BASESTORAGE", "BASEVENDORS", "COMPS", "COOWNERS", "CURRENTSTORAGE", "FRIENDS", "GETACCESSPOS", "GETADDONPOS", "GETBANPOS", "GETCOMPPOS", "GETCOOWNERPOS", "GETFRIENDPOS", "GETHOUSEVENDORPOS", "GETLOCKEDITEMPOS", "GETSECUREDCONTAINERPOS", "GETSECUREDCONTAINERS", "GETSECUREDITEMS", "GUILD", "HOUSETYPE", "INCREASEDSTORAGE", "ISOWNER", "LOCKDOWNS", "LOCKDOWNSPERCENT", "LOCKITEM", "MAXLOCKDOWNS", "MAXSTORAGE", "MAXVENDORS", "MOVINGCRATE", "OWNER", "PRIV", "REGION", "REMOVEKEYS", "SECURE", "VENDORS", nullptr }; void CItemMulti::r_Write(CScript & s) { ADDTOCALLSTACK_INTENSIVE("CItemMulti::r_Write"); CItem::r_Write(s); if (m_pRegion) { m_pRegion->r_WriteBody(s, "REGION."); } if (_uidGuild.IsValidUID()) { s.WriteKeyHex("GUILD", (dword)_uidGuild); } if (_uidOwner.IsValidUID()) { s.WriteKeyHex("OWNER", (dword)_uidOwner); } // House general if (_iHouseType) { s.WriteKeyHex("HOUSETYPE", (dword)_iHouseType); } if (!_lCoowners.empty()) { for (const CUID& uid : _lCoowners) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDCOOWNER", (dword)uid); } } } if (!_lFriends.empty()) { for (const CUID& uid : _lFriends) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDFRIEND", (dword)uid); } } } if (!_lComps.empty()) { for (const CUID& uid : _lComps) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDCOMP", (dword)uid); } } } if (!_lAddons.empty()) { for (const CUID& uid : _lAddons) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDADDON", (dword)uid); } } } if (!_lSecureContainers.empty()) { for (const CUID& uid : _lSecureContainers) { if (uid.IsValidUID()) { s.WriteKeyHex("SECURE", (dword)uid); } } } if (!_lLockDowns.empty()) { for (const CUID& uid : _lLockDowns) { if (uid.IsValidUID()) { s.WriteKeyHex("LOCKITEM", (dword)uid); } } } if (auto val = GetLockdownsPercent()) { s.WriteKeyVal("LOCKDOWNSPERCENT", val); } const CUID uidCrate = GetMovingCrate(false); if (uidCrate.IsValidUID()) { s.WriteKeyHex("MOVINGCRATE", uidCrate.GetObjUID()); } // House vendors if (!_lVendors.empty()) { for (const CUID& uid : _lVendors) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDVENDOR", (dword)uid); } } } if (auto val = GetBaseVendors()) { s.WriteKeyVal("BASEVENDORS", val); } // House Storage if (auto val = GetBaseStorage()) { s.WriteKeyVal("BASESTORAGE", val); } if (auto val = GetIncreasedStorage()) { s.WriteKeyVal("INCREASEDSTORAGE", val); } } bool CItemMulti::r_WriteVal(lpctstr ptcKey, CSString & sVal, CTextConsole * pSrc, bool fNoCallParent, bool fNoCallChildren) { UNREFERENCED_PARAMETER(fNoCallChildren); ADDTOCALLSTACK("CItemMulti::r_WriteVal"); if (CCMultiMovable::r_WriteVal(ptcKey, sVal, pSrc)) { return true; } int iCmd = FindTableHeadSorted(ptcKey, sm_szLoadKeys, CountOf(sm_szLoadKeys) - 1); if (iCmd >= 0) { ptcKey += strlen(sm_szLoadKeys[iCmd]); } SKIP_SEPARATORS(ptcKey); switch (iCmd) { // House Permissions case SHL_PRIV: { ASSERT(pSrc); if (CChar* pSrcChar = pSrc->GetChar()) { if (pSrcChar->m_pPlayer) { CMultiStorage* pMultiStorage = pSrcChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); sVal.FormatU8Val((uint8)pMultiStorage->GetPriv(GetUID())); break; } } sVal.FormatVal(0); break; } case SHL_OWNER: { CChar *pOwner = GetOwner().CharFind(); if (!IsStrEmpty(ptcKey)) { if (pOwner) { return pOwner->r_WriteVal(ptcKey, sVal, pSrc); } } if (pOwner) { sVal.FormatDWVal(pOwner->GetUID()); } else { sVal.FormatDWVal(0); } break; } case SHL_GUILD: { CItemStone *pGuild = static_cast<CItemStone*>(GetGuildStone().ItemFind()); if (!IsStrEmpty(ptcKey)) { if (pGuild) { return pGuild->r_WriteVal(ptcKey, sVal, pSrc); } } if (pGuild) { sVal.FormatDWVal(pGuild->GetUID()); } else { sVal.FormatDWVal(0); } break; } case SHL_ISOWNER: { CUID uidOwner(Exp_GetVal(ptcKey)); sVal.FormatBVal(IsOwner(uidOwner)); break; } case SHL_GETCOOWNERPOS: { CUID uidCoowner(Exp_GetVal(ptcKey)); sVal.FormatVal(GetCoownerIndex(uidCoowner)); break; } case SHL_COOWNERS: { sVal.FormatSTVal(GetCoownerCount()); break; } case SHL_GETFRIENDPOS: { CUID uidFriend(Exp_GetVal(ptcKey)); sVal.FormatVal(GetFriendIndex(uidFriend)); break; } case SHL_FRIENDS: { sVal.FormatSTVal(GetFriendCount()); break; } case SHL_ACCESSES: { sVal.FormatSTVal(GetAccessCount()); break; } case SHL_GETACCESSPOS: { CUID uidAccess(Exp_GetVal(ptcKey)); sVal.FormatVal(GetAccessIndex(uidAccess)); break; } case SHL_ADDONS: { sVal.FormatSTVal(GetAddonCount()); break; } case SHL_GETADDONPOS: { CUID uidAddon(Exp_GetVal(ptcKey)); sVal.FormatVal(GetAddonIndex(uidAddon)); break; } case SHL_BANS: { sVal.FormatSTVal(GetBanCount()); break; } case SHL_GETBANPOS: { CUID uidBan(Exp_GetVal(ptcKey)); sVal.FormatVal(GetBanIndex(uidBan)); break; } // House General case SHL_HOUSETYPE: { sVal.FormatU8Val((uint8)_iHouseType); break; } case SHL_GETCOMPPOS: { CUID uidComp(Exp_GetVal(ptcKey)); sVal.FormatVal(GetComponentIndex(uidComp)); break; } case SHL_MOVINGCRATE: { bool fCreate = false; if (strlen(ptcKey) <= 2) // check for <MovingCrate 0/1> (whitespace + number = 2 len) { fCreate = Exp_GetVal(ptcKey); } else if (!IsStrEmpty(ptcKey) && _uidMovingCrate.IsValidUID()) // If there's an already existing Moving Crate and args len is greater than 1, it should have a keyword to send to the crate. { CItemContainer *pCrate = static_cast<CItemContainer*>(_uidMovingCrate.ItemFind()); ASSERT(pCrate); // Removed crates should init _uidMovingCrate's uid? return pCrate->r_WriteVal(ptcKey, sVal, pSrc); } if (fCreate) { GetMovingCrate(true); } if (_uidMovingCrate.IsValidUID()) { sVal.FormatDWVal(_uidMovingCrate); } else { sVal.FormatDWVal(0); } break; } case SHL_ADDKEY: { ptcKey += 6; CUID uidOwner(Exp_GetVal(ptcKey)); bool fDupeOnBank = Exp_GetVal(ptcKey) ? 1 : 0; CChar *pCharOwner = uidOwner.CharFind(); CItem *pKey = nullptr; if (pCharOwner) { pKey = GenerateKey(uidOwner, fDupeOnBank); if (pKey) { sVal.FormatDWVal(pKey->GetUID()); break; } } sVal.FormatDWVal(0); break; } // House Storage case SHL_COMPS: { sVal.FormatSTVal(GetComponentCount()); break; } case SHL_LOCKDOWNS: { sVal.FormatSTVal(GetLockdownCount()); break; } case SHL_GETSECUREDCONTAINERPOS: { CUID uidCont(Exp_GetDWVal(ptcKey)); if (uidCont.IsValidUID()) { sVal.FormatVal(GetSecuredContainerIndex(uidCont)); break; } return false; } case SHL_GETSECUREDCONTAINERS: { sVal.FormatSTVal(GetSecuredContainersCount()); break; } case SHL_GETSECUREDITEMS: { sVal.Format16Val(GetSecuredItemsCount()); break; } case SHL_VENDORS: { sVal.FormatSTVal(GetVendorCount()); break; } case SHL_BASESTORAGE: { sVal.FormatU16Val(GetBaseStorage()); break; } case SHL_BASEVENDORS: { sVal.FormatU8Val(GetBaseVendors()); break; } case SHL_CURRENTSTORAGE: { sVal.FormatU16Val(GetCurrentStorage()); break; } case SHL_INCREASEDSTORAGE: { sVal.FormatU16Val(GetIncreasedStorage()); break; } case SHL_GETHOUSEVENDORPOS: { sVal.FormatVal(GetVendorIndex(CUID(Exp_GetVal(ptcKey)))); break; } case SHL_GETLOCKEDITEMPOS: { sVal.FormatVal(GetLockedItemIndex(CUID(Exp_GetVal(ptcKey)))); break; } case SHL_LOCKDOWNSPERCENT: { sVal.FormatU8Val(GetLockdownsPercent()); break; } case SHL_MAXLOCKDOWNS: { sVal.FormatU16Val(GetMaxLockdowns()); break; } case SHL_MAXSTORAGE: { sVal.FormatU16Val(GetMaxStorage()); break; } case SHL_MAXVENDORS: { sVal.FormatU16Val(GetMaxVendors()); break; } default: return (fNoCallParent ? false : CItem::r_WriteVal(ptcKey, sVal, pSrc)); } return true; } bool CItemMulti::r_LoadVal(CScript & s) { ADDTOCALLSTACK("CItemMulti::r_LoadVal"); EXC_TRY("LoadVal"); if (CCMultiMovable::r_LoadVal(s)) { return true; } int iCmd = FindTableHeadSorted(s.GetKey(), sm_szLoadKeys, CountOf(sm_szLoadKeys) - 1); switch (iCmd) { case SHL_REGION: { if (!IsTopLevel()) { MoveTo(GetTopPoint()); // Put item on the ground here. Update(); } ASSERT(m_pRegion); CScript script(s.GetKey() + 7, s.GetArgStr()); script.CopyParseState(s); return m_pRegion->r_LoadVal(script); } // misc case SHL_HOUSETYPE: { _iHouseType = (HOUSE_TYPE)s.GetArgU8Val(); break; } case SHL_MOVINGCRATE: { CUID uidCrate(s.GetArgDWVal()); if (uidCrate.IsValidUID()) { if (uidCrate.GetPrivateUID() == 1) // fix for 'movingcrate 1' { GetMovingCrate(true); } else { SetMovingCrate(uidCrate); } } else { SetMovingCrate(CUID()); } break; } case SHL_ADDKEY: { int64 piCmd[2]; int iLen = Str_ParseCmds(s.GetArgStr(), piCmd, CountOf(piCmd)); CUID uidOwner((dword)piCmd[0]); bool fDupeOnBank = false; if (iLen > 1) { fDupeOnBank = piCmd[1]; } CChar *pCharOwner = uidOwner.CharFind(); if (pCharOwner) { GenerateKey(uidOwner, fDupeOnBank); } break; } // House Permissions. case SHL_OWNER: { lpctstr ptcKey = s.GetKey(); ptcKey += 5; if (*ptcKey == '.') { CChar *pOwner = GetOwner().CharFind(); if (pOwner) { return pOwner->r_LoadVal(s); } return false; } CUID uid(s.GetArgDWVal()); if (!uid.IsValidUID()) { SetOwner(CUID()); } else { SetOwner(uid); } break; } case SHL_GUILD: { lpctstr ptcKey = s.GetKey(); ptcKey += 5; if (*ptcKey == '.') { CItemStone *pGuild = static_cast<CItemStone*>(GetGuildStone().ItemFind()); if (pGuild) { return pGuild->r_LoadVal(s); } return false; } CUID uid(s.GetArgDWVal()); if (!uid.IsValidUID()) { SetGuild(CUID()); break; } const CItem *pItem = uid.ItemFind(); if (pItem) { if (pItem->IsType(IT_STONE_GUILD)) { SetGuild(uid); return true; } else { return false; } } break; } case SHL_ADDCOOWNER: { AddCoowner(CUID(s.GetArgDWVal())); break; } case SHL_ADDFRIEND: { AddFriend(CUID(s.GetArgDWVal())); break; } case SHL_ADDBAN: { AddBan(CUID(s.GetArgDWVal())); break; } case SHL_ADDACCESS: { AddAccess(CUID(s.GetArgDWVal())); break; } case SHL_ADDADDON: { AddAddon(CUID(s.GetArgDWVal())); break; } // House Storage case SHL_ADDCOMP: { AddComponent(CUID(s.GetArgDWVal())); break; } case SHL_ADDVENDOR: { AddVendor(CUID(s.GetArgDWVal())); break; } case SHL_BASESTORAGE: { SetBaseStorage(s.GetArgU16Val()); break; } case SHL_BASEVENDORS: { SetBaseVendors(s.GetArgU8Val()); break; } case SHL_INCREASEDSTORAGE: { SetIncreasedStorage(s.GetArgU16Val()); break; } case SHL_LOCKDOWNSPERCENT: { SetLockdownsPercent(s.GetArgU8Val()); break; } case SHL_LOCKITEM: { CUID uidLock(s.GetArgDWVal()); if (uidLock.IsValidUID()) { LockItem(uidLock); } break; } case SHL_SECURE: { CUID uidSecured(s.GetArgDWVal()); CItem *pItem = uidSecured.ItemFind(); if (pItem && (pItem->IsType(IT_CONTAINER) || pItem->IsType(IT_CONTAINER_LOCKED))) { CItemContainer *pSecured = dynamic_cast<CItemContainer*>(pItem); //ensure it's a container. if (pSecured) { Secure(uidSecured); break; } } return false; } default: return CItem::r_LoadVal(s); } EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPT; EXC_DEBUG_END; return true; } void CItemMulti::DupeCopy(const CItem * pItem) { ADDTOCALLSTACK("CItemMulti::DupeCopy"); CItem::DupeCopy(pItem); } CItem *CItemMulti::Multi_Create(CChar *pChar, const CItemBase * pItemDef, CPointMap & pt, CItem *pDeed) { if (!pChar || !pChar->m_pPlayer) { return nullptr; } ASSERT(pItemDef); const bool fShip = pItemDef->IsType(IT_SHIP); // must be in water. // pMultiDef can be nullptr, because we can also add simple items with a deed, not only multis. const CItemBaseMulti* pMultiDef = dynamic_cast <const CItemBaseMulti*> (pItemDef); /* * First thing to do is to check if the character creating the multi is allowed to have it */ if (fShip) { ASSERT(pMultiDef); CMultiStorage* pMultiStorage = pChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); if (!pMultiStorage->CanAddShip(pChar->GetUID(), pMultiDef->_iMultiCount)) { return nullptr; } } else if (pItemDef->IsType(IT_MULTI) || pItemDef->IsType(IT_MULTI_CUSTOM)) { ASSERT(pMultiDef); CMultiStorage* pMultiStorage = pChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); if (!pMultiStorage->CanAddHouse(pChar->GetUID(), pMultiDef->_iMultiCount)) { return nullptr; } } CScriptTriggerArgs args; args.m_VarsLocal.SetStrNew("check_blockradius", "-1, -1, 1, 1"); // Values are West, Norht, East, South args.m_VarsLocal.SetStrNew("check_multiradius", "0, -5, 0, 5"); args.m_VarsLocal.SetStrNew("id", g_Cfg.ResourceGetName(CResourceID(RES_ITEMDEF, pItemDef->GetID()))); args.m_VarsLocal.SetStrNew("p", pt.WriteUsed()); TRIGRET_TYPE tRet; pChar->r_Call("f_multi_onplacement_check", pChar, &args, nullptr, &tRet); if (tRet == TRIGRET_RET_TRUE) { return nullptr; } /* * There is a small difference in the coordinates where the mouse is in the screen and the ones received, * let's remove that difference. * Note: this fix is added here, before GM check, because otherwise they will place houses on wrong position. */ if (pMultiDef && (CItemBase::IsID_Multi(pItemDef->GetID()) || pItemDef->IsType(IT_MULTI_ADDON))) // or is this happening only for houses? if (CItemBase::IsID_House(pItemDef->GetID())) { pt.m_y -= (short)(pMultiDef->m_rect.m_bottom - 1); } if (!pChar->IsPriv(PRIV_GM) && tRet != TRIGRET_RET_HALFBAKED) { CRect rectBlockRadius; rectBlockRadius.Read(args.m_VarsLocal.GetKeyStr("check_blockradius")); CRect rectMultiRadius; rectMultiRadius.Read(args.m_VarsLocal.GetKeyStr("check_multiradius")); if (!pDeed->IsAttr(ATTR_MAGIC)) { CRect rect; CRect baseRect; if (pMultiDef) { baseRect = pMultiDef->m_rect; // Create a rect equal to the multi's one. } else { baseRect.OffsetRect(1, 1); // Guildstones pass through here, also other non multi items placed from deeds. } baseRect.m_map = pt.m_map; // set it's map to the current map. baseRect.OffsetRect(pt.m_x, pt.m_y);// fill the rect. rect = baseRect; CPointMap ptn = pt; // A copy to work on. // Check for chars in the way, just search for any char in the house area, no extra tiles, it's enough for them to do not be inside the house. CWorldSearch Area(pt, std::max(rect.GetWidth(), rect.GetHeight())); Area.SetSearchSquare(true); for (;;) { CChar * pCharSearch = Area.GetChar(); if (pCharSearch == nullptr) { break; } if (!rect.IsInside2d(pCharSearch->GetTopPoint())) // if the char is not inside the rec, ignore him. { continue; } if (pCharSearch->IsPriv(PRIV_GM) && !pChar->CanSee(pCharSearch)) // There is a GM in my way? get through him! { continue; } pChar->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_MULTI_INTWAY), pCharSearch->GetName()); // Did not met any of the above exceptions so i'm blocking the placement, return. return nullptr; } /* Char's check passed. * Intensive checks are done now: * - The area of search gets increased by 1* tile: There must be no blocking items from a 1x1* gap outside the house. * - All coord points inside that rect must be valid and have, as much, a Z difference of +-4. * * *1 tile by default, values can be overriden with local.check_BlockRadius in the f_house_onplacement_check function. */ rect += rectBlockRadius; int x = rect.m_left; /* * Loop through all the positions of the rect. */ for (; x < rect.m_right; ++x) // X loop { // Setting the Top-Left point of the CRect* ptn.m_x = (short)x; // *point Left int y = rect.m_top; // Reset North for each loop. for (; y < rect.m_bottom; ++y) // Y loop { ptn.m_y = (short)y; // *point North if (!ptn.IsValidPoint()) // Invalid point (out of map bounds). { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_FAIL); return nullptr; } dword dwBlockFlags = (fShip) ? CAN_C_SWIM : CAN_C_WALK; // Flags to check: Ships should check for swimable tiles. /* * Intensive check returning the top Z point of the given X, Y coords * It uses the dwBlockBlacks passed to check the new Z level. * Also update those dwBlockFlags with all the flags found at the given location. * 3rd param is set to also update Z with any house component found in the proccess. */ ptn.m_z = CWorldMap::GetHeightPoint2(ptn, dwBlockFlags, true); if (abs(ptn.m_z - pt.m_z) > 4) // Difference of Z > 4? so much, stop. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_BUMP); return nullptr; } if (fShip) { if (!(dwBlockFlags & CAN_I_WATER)) // Ships must be placed on water. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_SHIPW); return nullptr; } } else if (dwBlockFlags & (CAN_I_WATER | CAN_I_BLOCK | CAN_I_CLIMB)) // Did the intensive check find some undesired flags? Stop. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_BLOCKED); return nullptr; } } } /* * The above loop did not find any blocking item/char, now another loop is done to check for another multis with extended limitations: * You can't place your house within a range of 5* tiles bottom of the stairs of any house. * Additionally your house can't have it's bottom blocked by another multi in a 5* tiles margin. * Simplifying it: the Rect must have an additional +5* tiles of radius on both TOP and BOTTOM points. * * *5 North & South tiles by default, values can be overriden with local.check_MultiRadius in the f_house_onplacement_check function. */ rect = baseRect; rect += rectMultiRadius; x = rect.m_left; for (; x < rect.m_right; ++x) { ptn.m_x = (short)x; int y = rect.m_top; for (; y < rect.m_bottom; ++y) { ptn.m_y = (short)y; /* * Search for any multi region on that point. */ CRegion * pRegion = ptn.GetRegion(REGION_TYPE_MULTI | REGION_TYPE_AREA | REGION_TYPE_ROOM); /* * If there is no region on that point (invalid point?) or the region has the NOBUILDING flag, stop * Ships are allowed to bypass this check?? */ if ((pRegion == nullptr) || (pRegion->IsFlag(REGION_FLAG_NOBUILDING) && !fShip)) { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_FAIL); return nullptr; } } } } } CItem * pItemNew = CItem::CreateTemplate(pItemDef->GetID(), nullptr, pChar); if (pItemNew == nullptr) { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_COLLAPSE); return nullptr; } pItemNew->SetAttr(ATTR_MOVE_NEVER | (pDeed->m_Attr & (ATTR_MAGIC | ATTR_INVIS))); pItemNew->SetHue(pDeed->GetHue()); pItemNew->MoveToUpdate(pt); CItemMulti * pMultiItem = dynamic_cast <CItemMulti*>(pItemNew); if (pMultiItem) { pMultiItem->Multi_Setup(pChar, UID_CLEAR); } if (pItemDef->IsType(IT_STONE_GUILD)) { // Now name the guild CItemStone * pStone = dynamic_cast <CItemStone*>(pItemNew); ASSERT(pStone); pStone->AddRecruit(pChar, STONEPRIV_MASTER); if (CClient* pClient = pChar->GetClientActive()) { pClient->addPromptConsole(CLIMODE_PROMPT_STONE_NAME, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_GUILDSTONE_NEW), pItemNew->GetUID()); } } else if (pItemDef->IsType(IT_SHIP)) { pItemNew->Sound(Calc_GetRandVal(2) ? 0x12 : 0x13); } return pItemNew; } void CItemMulti::OnComponentCreate(CItem * pComponent, bool fIsAddon) { UNREFERENCED_PARAMETER(fIsAddon); CScript eComponent("+t_house_component"); pComponent->m_OEvents.r_LoadVal(eComponent, RES_EVENTS); switch (pComponent->GetType()) { case IT_DOOR: { pComponent->r_ExecSingle("EVENTS +ei_house_door"); pComponent->SetType(IT_DOOR_LOCKED); break; } case IT_CONTAINER: { pComponent->r_ExecSingle("EVENTS +ei_house_container"); pComponent->SetType(IT_CONTAINER_LOCKED); break; } case IT_SHIP_SIDE: { pComponent->SetType(IT_SHIP_SIDE_LOCKED); break; } case IT_SHIP_HOLD: { pComponent->SetType(IT_SHIP_HOLD_LOCK); break; } case IT_TELEPAD: { pComponent->r_ExecSingle("EVENTS +ei_house_telepad"); break; } default: break; } if (pComponent->GetHue() == HUE_DEFAULT) { pComponent->SetHue(GetHue()); } } CMultiStorage::CMultiStorage(const CUID& uidSrc) { _uidSrc = uidSrc; _iShipsTotal = 0; _iHousesTotal = 0; } CMultiStorage::~CMultiStorage() { for (auto& pair : _lHouses) { const CUID& uid = pair.first; CItemMulti *pMulti = static_cast<CItemMulti*>(uid.ItemFind()); if (!pMulti) continue; if (_uidSrc.IsChar()) { pMulti->RevokePrivs(_uidSrc); } else if (_uidSrc.IsItem()) //Only guild/town stones { pMulti->SetGuild(CUID()); } } for (auto& pair : _lShips) { const CUID& uid = pair.first; CItemShip *pShip = static_cast<CItemShip*>(uid.ItemFind()); if (!pShip) continue; if (_uidSrc.IsChar()) { pShip->RevokePrivs(_uidSrc); } else if (_uidSrc.IsItem()) //Only guild/town stones { pShip->SetGuild(CUID()); } } _uidSrc.InitUID(); } void CMultiStorage::AddMulti(const CUID& uidMulti, HOUSE_PRIV ePriv) { if (!uidMulti.IsValidUID()) { return; } const CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); if (!pMulti) { return; } CObjBase *pSrc = _uidSrc.ObjFind(); const bool isChar = pSrc && pSrc->IsChar(); if (pMulti->IsType(IT_SHIP)) { if (_lShips.empty() && isChar) { pSrc->r_ExecSingle("EVENTS +e_ship_priv"); } AddShip(uidMulti, ePriv); } else { if (_lHouses.empty() && isChar) { pSrc->r_ExecSingle("EVENTS +e_house_priv"); } AddHouse(uidMulti, ePriv); } } void CMultiStorage::DelMulti(const CUID& uidMulti) { CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); CObjBase *pSrc = _uidSrc.ObjFind(); if (pMulti->IsType(IT_SHIP)) { DelShip(uidMulti); if (_lShips.empty() && pSrc) { pSrc->r_ExecSingle("EVENTS -e_ship_priv"); } } else { DelHouse(uidMulti); if (_lHouses.empty() && pSrc) { pSrc->r_ExecSingle("EVENTS -e_house_priv"); } } pMulti->RevokePrivs(_uidSrc); } void CMultiStorage::AddHouse(const CUID& uidHouse, HOUSE_PRIV ePriv) { ADDTOCALLSTACK("CMultiStorage::AddHouse"); if (!uidHouse.IsValidUID()) { return; } if (GetHousePos(uidHouse) >= 0) { return; } const CItemMulti *pMulti = static_cast<CItemMulti*>(uidHouse.ItemFind()); _iHousesTotal += pMulti->GetMultiCount(); _lHouses[uidHouse] = ePriv; } void CMultiStorage::DelHouse(const CUID& uidHouse) { ADDTOCALLSTACK("CMultiStorage::DelHouse"); if (_lHouses.empty()) { return; } if (_lHouses.find(uidHouse) != _lHouses.end()) { const CItemMulti *pMulti = static_cast<CItemMulti*>(uidHouse.ItemFind()); _iHousesTotal -= pMulti->GetMultiCount(); _lHouses.erase(uidHouse); return; } } HOUSE_PRIV CMultiStorage::GetPriv(const CUID& uidMulti) { ADDTOCALLSTACK("CMultiStorage::GetPrivMulti"); const CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); if (pMulti->IsType(IT_MULTI)) { return _lHouses[uidMulti]; } else if (pMulti->IsType(IT_SHIP)) { return _lShips[uidMulti]; } return HP_NONE; } bool CMultiStorage::CanAddHouse(const CUID& uidChar, int16 iHouseCount) const { ADDTOCALLSTACK("CMultiStorage::CanAddHouse"); if (uidChar.IsItem()) { return true; // Guilds can have unlimited houses atm. } const CChar *pChar = uidChar.CharFind(); if (!pChar || !pChar->m_pPlayer) { return false; } if (iHouseCount == 0 || pChar->IsPriv(PRIV_GM)) { return true; } uint8 iMaxHouses = pChar->m_pPlayer->_iMaxHouses; if (iMaxHouses == 0) { if (pChar->GetClientActive()) { iMaxHouses = pChar->GetClientActive()->GetAccount()->_iMaxHouses; } } if (iMaxHouses == 0) { return true; } if (GetHouseCountTotal() + iHouseCount <= iMaxHouses) { return true; } pChar->SysMessageDefault(DEFMSG_HOUSE_ADD_LIMIT); return false; } int16 CMultiStorage::GetHousePos(const CUID& uidHouse) const { ADDTOCALLSTACK("CMultiStorage::GetHousePos"); if (_lHouses.empty()) { return -1; } int16 i = 0; for (MultiOwnedCont::const_iterator it = _lHouses.begin(); it != _lHouses.end(); ++it) { if (it->first == uidHouse) { return i; } ++i; } return -1; } int16 CMultiStorage::GetHouseCountTotal() const { return _iHousesTotal; } int16 CMultiStorage::GetHouseCountReal() const { return (int16)_lHouses.size(); } CUID CMultiStorage::GetHouseAt(int16 iPos) const { MultiOwnedCont::const_iterator it = _lHouses.begin(); std::advance(it, iPos); return it->first; } void CMultiStorage::ClearHouses() { _lHouses.clear(); } void CMultiStorage::r_Write(CScript & s) const { ADDTOCALLSTACK("CMultiStorage::r_Write"); UNREFERENCED_PARAMETER(s); } void CMultiStorage::AddShip(const CUID& uidShip, HOUSE_PRIV ePriv) { ADDTOCALLSTACK("CMultiStorage::AddShip"); if (!uidShip.IsValidUID()) { return; } if (GetShipPos(uidShip) >= 0) { return; } const CItemShip *pShip = static_cast<CItemShip*>(uidShip.ItemFind()); if (!pShip) { return; } _iShipsTotal += pShip->GetMultiCount(); _lShips[uidShip] = ePriv; } void CMultiStorage::DelShip(const CUID& uidShip) { ADDTOCALLSTACK("CMultiStorage::DelShip"); if (_lShips.empty()) { return; } if (_lShips.find(uidShip) != _lShips.end()) { const CItemShip *pShip = static_cast<CItemShip*>(uidShip.ItemFind()); if (pShip) { _iShipsTotal -= pShip->GetMultiCount(); } _lShips.erase(uidShip); return; } } bool CMultiStorage::CanAddShip(const CUID& uidChar, int16 iShipCount) { ADDTOCALLSTACK("CMultiStorage::CanAddShip"); if (uidChar.IsItem()) { return true; // Guilds can have unlimited ships atm. } const CChar *pChar = uidChar.CharFind(); if (!pChar || !pChar->m_pPlayer) { return false; } if (iShipCount == 0 || pChar->IsPriv(PRIV_GM)) { return true; } uint8 iMaxShips = pChar->m_pPlayer->_iMaxShips; if (iMaxShips == 0) { if (pChar->GetClientActive()) { iMaxShips = pChar->GetClientActive()->GetAccount()->_iMaxShips; } } if (iMaxShips == 0) { return true; } if (GetShipCountTotal() + iShipCount <= iMaxShips) { return true; } pChar->SysMessageDefault(DEFMSG_HOUSE_ADD_LIMIT); return false; } int16 CMultiStorage::GetShipPos(const CUID& uidShip) { if (_lShips.empty()) { return -1; } int16 i = 0; for (MultiOwnedCont::iterator it = _lShips.begin(); it != _lShips.end(); ++it) { if (it->first == uidShip) { return i; } ++i; } return -1; } int16 CMultiStorage::GetShipCountTotal() { return _iShipsTotal; } int16 CMultiStorage::GetShipCountReal() { return (int16)_lShips.size(); } CUID CMultiStorage::GetShipAt(int16 iPos) { MultiOwnedCont::const_iterator it = _lShips.begin(); std::advance(it, iPos); return it->first; } void CMultiStorage::ClearShips() { _lShips.clear(); }
96,411
33,312
#include "xmltags.h" #include "NetworkArchitecture.h" #include "Parameter.h" #include "Chain.h" #include "Link.h" #include "Network.h" #include "Parameter.h" #include "ParameterValues.h" #include "Exceptions.h" #include "CNTKWrapperInternals.h" Chain::Chain() { m_chainLinks = std::vector<Link*>(); } Chain::~Chain() { } Chain::Chain(tinyxml2::XMLElement* pParentNode) : Chain() { //read name m_name = CNTKWrapper::Internal::string2wstring((pParentNode->Attribute(XML_ATTRIBUTE_Name))); if (m_name.empty()) m_name = L"Chain"; //read links tinyxml2::XMLElement *pNode = pParentNode->FirstChildElement(XML_TAG_ChainLinks); if (pNode == nullptr) throw ProblemParserElementNotFound(XML_TAG_ChainLinks); loadChildren<Link>(pNode, XML_TAG_LinkBase, m_chainLinks); for (auto var : m_chainLinks) { var->setParentChain(this); } } const Link* Chain::getLinkById(const wstring id) const { for (auto item : m_chainLinks) { if (item->getId()==id) return item; } return nullptr; }
1,002
402
#include <cstdio> #include <cstdlib> #include <cstring> /************************************************ This is for post processing RAM or VRAM dump taken from emulator or reconstructed from picture, of running M68k Opcode Sizes Test ROM. The reason is that some of opcodes are skipped, and some of them are reported wrong. Several options provided, just check them out. ************************************************/ void usage() { printf( "Usage:\n" " m68k_opcode_sizes [command] RAM_file output\n" "\n" " command:\n" " fix - fix wrong lengths and outputs result\n" " sizes - prints all lengths\n" " valid - dumps all valid opcodes\n" " including illegal opcode\n" " all - dumps all opcodes including bad ones\n" "\n" " valid_print - same as \"valid\" but prints offsets\n" " all_print - same as \"all\" but prints offsets\n" "\n" " WARNING: all outputs will be overwriten!\n" "\n" " Author: r57shell@uralweb.ru\n" " Last update: 01.09.2017\n" ); exit(0); } // override size of opcode // returns -1 if no override, and words count else int over(int x) { if ((x & 0xF1F8) == 0x51C8) // dbcc return 2; if ((x & 0xFE00) == 0x6000 // bra, bsr || (x & 0xF100) == 0x6000) // bcc { if (x & 0xFF) return 1; else return 2; } if ((x & 0xFF80) == 0x4E80) // jsr, jmp { if ((x & 0x38) == 0x10) // (an) return 1; if ((x & 0x38) == 0x28) // (d16,An) return 2; if ((x & 0x38) == 0x30) // (d8,An,Xn) return 2; if ((x & 0x3F) == 0x38 // (xxx).w || (x & 0x3F) == 0x3A // (d16,pc) || (x & 0x3F) == 0x3B) // (d8,pc) return 2; if ((x & 0x3F) == 0x39) // (xxx).l return 3; } if ((x & 0xE1C0) == 0x2040) // movea { if ((x & 0x3F) < 5*8) // mode return 1; if ((x & 0x3F) == 0x39) // (xxx).l return 3; if ((x & 0x3F) < 0x3C) return 2; if ((x & 0x3F) == 0x3C) // #imm { if (x & 0x1000) return 2; else return 3; } } if (x == 0x4E72) // stop return 2; if (x == 0x4FF9) // lea (xxx).l,a7 return 3; if (x == 0xDFFC) // adda (xxx).l,a7 return 3; return -1; } // constructs opcode almost same as in test ROM // the difference is in some opcodes // with byte access mode and immediate operand // and those immediate has high byte equal to zero here // but in test ROM they all have value #$F000 void make(FILE *f, int op, int len, bool print) { if (!len) return; unsigned char buff[0x100]; if (print) printf("%X: %X\n", ftell(f), op); buff[0] = op>>8; buff[1] = op; for (int i=1; i<len; ++i) { buff[i*2] = 0xF0; buff[i*2+1] = 0; } if (((op & 0xFF) == 0x3C && (op >> 8) < 0x10) // btst, bchg, bset, bclr || (op & 0xFF00) == 0x0800) buff[2] = 0; // overwrite high byte of immediate value if (fwrite(buff, 1, 2*len, f) != 2*len) { fclose(f); printf("Unable to write file\nPerhaps disk is full?\n"); exit(4); } } unsigned char RAM[0x8000]; // reads RAM from file and applies override of opcode sizes void fix(const char *in) { FILE *f = fopen(in, "rb"); if (!f) { printf("Can't open file %s\n", in); exit(1); } if (fread(RAM, 1, 0x8000, f) != 0x8000) { fclose(f); printf("RAM file has size less than %d\n", 0x8000); exit(2); } fclose(f); for (int op=0; op<0x10000; ++op) { int v = over(op); if (v >= 0) { if (op&1) RAM[op>>1] = (RAM[op>>1]&(~0xF))|v; else RAM[op>>1] = (RAM[op>>1]&(~0xF0))|(v<<4); } } } int get_len(int opcode) { return (opcode & 1) ?(RAM[opcode>>1] & 0xF) : (RAM[opcode>>1] >> 4); } void make_fix(const char *in, const char *out) { fix(in); FILE *f = fopen(out, "wb"); if (!f) { printf("Can't open file %s\n", out); exit(3); } if (fwrite(RAM, 1, 0x8000, f) != 0x8000) { fclose(f); printf("Unable to write file %s\nPerhaps disk is full?\n", out); exit(4); } fclose(f); } void make_sizes(const char *in, const char *out) { fix(in); FILE *f = fopen(out, "w+"); if (!f) { printf("Can't open file %s\n", out); exit(3); } for (int op=0; op<0x10000; ++op) { fprintf(f, "%04X: %d\n", op, get_len(op)); } fclose(f); } void make_valid(const char *in, const char *out, bool print) { fix(in); FILE *f = fopen(out, "wb"); if (!f) { printf("Can't open file %s\n", out); exit(3); } for (int op=0; op<0x10000; ++op) { int len = get_len(op); if (op == 0x4AFC) // illegal len = 1; make(f, op, len, print); } fclose(f); } void make_all(const char *in, const char *out, bool print) { fix(in); FILE *f = fopen(out, "wb"); if (!f) { printf("Can't open file %s\n", out); exit(3); } for (int op=0; op<0x10000; ++op) { int len = get_len(op); if (len < 1) len = 1; make(f, op, len, print); } fclose(f); } int main(int argc, char**args) { if (argc != 4) usage(); if (!strcmp(args[1], "fix")) return make_fix(args[2], args[3]); if (!strcmp(args[1], "sizes")) return make_sizes(args[2], args[3]); if (!strcmp(args[1], "valid")) return make_valid(args[2], args[3], false); if (!strcmp(args[1], "valid_print")) return make_valid(args[2], args[3], true); if (!strcmp(args[1], "all")) return make_all(args[2], args[3], false); if (!strcmp(args[1], "all_print")) return make_all(args[2], args[3], true); printf("Unrecognized command: %s\n", args[1]); usage(); return 0; }
5,259
2,636
// Filter.C -- hacked version (by BGG) for RTcmix from Perry/Gary's STK // original head/comment: /***************************************************/ /*! \class Filter \brief STK filter class. This class implements a generic structure which can be used to create a wide range of filters. It can function independently or be subclassed to provide more specific controls based on a particular filter type. In particular, this class implements the standard difference equation: a[0]*y[n] = b[0]*x[n] + ... + b[nb]*x[n-nb] - a[1]*y[n-1] - ... - a[na]*y[n-na] If a[0] is not equal to 1, the filter coeffcients are normalized by a[0]. The \e gain parameter is applied at the filter input and does not affect the coefficient values. The default gain value is 1.0. This structure results in one extra multiply per computed sample, but allows easy control of the overall filter gain. by Perry R. Cook and Gary P. Scavone, 1995 - 2002. */ /***************************************************/ #include "Filter.h" #include <stdio.h> Filter :: Filter() { // The default constructor should setup for pass-through. gain = 1.0; nB = 1; nA = 1; b = new MY_FLOAT[nB]; b[0] = 1.0; a = new MY_FLOAT[nA]; a[0] = 1.0; inputs = new MY_FLOAT[nB]; outputs = new MY_FLOAT[nA]; this->clear(); } Filter :: Filter(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients) { char message[256]; // Check the arguments. if ( nb < 1 || na < 1 ) { sprintf(message, "Filter: nb (%d) and na (%d) must be >= 1!", nb, na); handleError( message, StkError::FUNCTION_ARGUMENT ); } if ( aCoefficients[0] == 0.0 ) { sprintf(message, "Filter: a[0] coefficient cannot == 0!"); handleError( message, StkError::FUNCTION_ARGUMENT ); } gain = 1.0; nB = nb; nA = na; b = new MY_FLOAT[nB]; a = new MY_FLOAT[nA]; inputs = new MY_FLOAT[nB]; outputs = new MY_FLOAT[nA]; this->clear(); this->setCoefficients(nB, bCoefficients, nA, aCoefficients); } Filter :: ~Filter() { delete [] b; delete [] a; delete [] inputs; delete [] outputs; } void Filter :: clear(void) { int i; for (i=0; i<nB; i++) inputs[i] = 0.0; for (i=0; i<nA; i++) outputs[i] = 0.0; } void Filter :: setCoefficients(int nb, MY_FLOAT *bCoefficients, int na, MY_FLOAT *aCoefficients) { int i; char message[256]; // Check the arguments. if ( nb < 1 || na < 1 ) { sprintf(message, "Filter: nb (%d) and na (%d) must be >= 1!", nb, na); handleError( message, StkError::FUNCTION_ARGUMENT ); } if ( aCoefficients[0] == 0.0 ) { sprintf(message, "Filter: a[0] coefficient cannot == 0!"); handleError( message, StkError::FUNCTION_ARGUMENT ); } if (nb != nB) { delete [] b; delete [] inputs; nB = nb; b = new MY_FLOAT[nB]; inputs = new MY_FLOAT[nB]; for (i=0; i<nB; i++) inputs[i] = 0.0; } if (na != nA) { delete [] a; delete [] outputs; nA = na; a = new MY_FLOAT[nA]; outputs = new MY_FLOAT[nA]; for (i=0; i<nA; i++) outputs[i] = 0.0; } for (i=0; i<nB; i++) b[i] = bCoefficients[i]; for (i=0; i<nA; i++) a[i] = aCoefficients[i]; // scale coefficients by a[0] if necessary if (a[0] != 1.0) { for (i=0; i<nB; i++) b[i] /= a[0]; for (i=0; i<nA; i++) a[i] /= a[0]; } } void Filter :: setNumerator(int nb, MY_FLOAT *bCoefficients) { int i; char message[256]; // Check the arguments. if ( nb < 1 ) { sprintf(message, "Filter: nb (%d) must be >= 1!", nb); handleError( message, StkError::FUNCTION_ARGUMENT ); } if (nb != nB) { delete [] b; delete [] inputs; nB = nb; b = new MY_FLOAT[nB]; inputs = new MY_FLOAT[nB]; for (i=0; i<nB; i++) inputs[i] = 0.0; } for (i=0; i<nB; i++) b[i] = bCoefficients[i]; } void Filter :: setDenominator(int na, MY_FLOAT *aCoefficients) { int i; char message[256]; // Check the arguments. if ( na < 1 ) { sprintf(message, "Filter: na (%d) must be >= 1!", na); handleError( message, StkError::FUNCTION_ARGUMENT ); } if ( aCoefficients[0] == 0.0 ) { sprintf(message, "Filter: a[0] coefficient cannot == 0!"); handleError( message, StkError::FUNCTION_ARGUMENT ); } if (na != nA) { delete [] a; delete [] outputs; nA = na; a = new MY_FLOAT[nA]; outputs = new MY_FLOAT[nA]; for (i=0; i<nA; i++) outputs[i] = 0.0; } for (i=0; i<nA; i++) a[i] = aCoefficients[i]; // scale coefficients by a[0] if necessary if (a[0] != 1.0) { for (i=0; i<nB; i++) b[i] /= a[0]; for (i=0; i<nA; i++) a[i] /= a[0]; } } void Filter :: setGain(MY_FLOAT theGain) { gain = theGain; } MY_FLOAT Filter :: getGain(void) const { return gain; } MY_FLOAT Filter :: lastOut(void) const { return outputs[0]; } MY_FLOAT Filter :: tick(MY_FLOAT sample) { int i; outputs[0] = 0.0; inputs[0] = gain * sample; for (i=nB-1; i>0; i--) { outputs[0] += b[i] * inputs[i]; inputs[i] = inputs[i-1]; } outputs[0] += b[0] * inputs[0]; for (i=nA-1; i>0; i--) { outputs[0] += -a[i] * outputs[i]; outputs[i] = outputs[i-1]; } return outputs[0]; } MY_FLOAT *Filter :: tick(MY_FLOAT *vector, unsigned int vectorSize) { for (unsigned int i=0; i<vectorSize; i++) vector[i] = tick(vector[i]); return vector; }
5,417
2,329
#include "ZFImpl_sys_Qt_ZFUIKit_impl.h" #include "ZFUIKit/protocol/ZFProtocolZFUITextEdit.h" #if ZF_ENV_sys_Qt #include <QLineEdit> #include <QEvent> #include <QKeyEvent> #include <QGraphicsDropShadowEffect> #include <QGraphicsProxyWidget> class _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit : public QLineEdit { Q_OBJECT public: ZFUITextEdit *ownerZFUITextEdit; zfindex textEditEventOverrideFlag; zfbool textEditSecured; QLineEdit::EchoMode textEditEchoModeSaved; Qt::InputMethodHints textEditInputMethodHintsSaved; zfstring textEditTextSaved; public: _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit(ZF_IN ZFUITextEdit *ownerZFUITextEdit) : QLineEdit() , ownerZFUITextEdit(ownerZFUITextEdit) , textEditEventOverrideFlag(0) , textEditSecured(zffalse) , textEditEchoModeSaved(this->echoMode()) , textEditInputMethodHintsSaved(this->inputMethodHints()) , textEditTextSaved() { this->connect(this, SIGNAL(textChanged(QString)), this, SLOT(_ZFP_textChanged(QString))); this->connect(this, SIGNAL(cursorPositionChanged(int,int)), this, SLOT(_ZFP_textSelectRangeOnChange(int,int))); this->_ZFP_textColor(ZFUIColorBlack()); this->setFrame(false); this->setAttribute(Qt::WA_MacShowFocusRect, false); QPalette palette = this->palette(); palette.setColor(QPalette::Base, Qt::transparent); palette.setColor(QPalette::Window, Qt::transparent); this->setPalette(palette); } public: void _ZFP_textSize(ZF_IN zffloat v) { QFont font = this->font(); font.setPixelSize((int)v); this->setFont(font); } void _ZFP_textColor(ZF_IN ZFUIColor v) { QPalette palette = this->palette(); palette.setColor(QPalette::Text, ZFImpl_sys_Qt_ZFUIColorToQColor(v)); this->setPalette(palette); } void _ZFP_textShadowUpdate(ZF_IN const ZFUIColor &textShadowColor, ZF_IN const ZFUISize &textShadowOffset) { if(textShadowColor == ZFUIColorZero()) { this->setGraphicsEffect(zfnull); } else { QGraphicsDropShadowEffect *effect = qobject_cast<QGraphicsDropShadowEffect *>(this->graphicsEffect()); if(effect == zfnull) { effect = new QGraphicsDropShadowEffect(this); this->setGraphicsEffect(effect); } effect->setBlurRadius(0); effect->setColor(ZFImpl_sys_Qt_ZFUIColorToQColor(textShadowColor)); effect->setOffset(textShadowOffset.width, textShadowOffset.height); } } void _ZFP_textEditSecured(ZF_IN zfbool textEditSecured) { if(this->textEditSecured == textEditSecured) { return ; } this->textEditSecured = textEditSecured; if(this->textEditSecured) { this->textEditEchoModeSaved = this->echoMode(); this->textEditInputMethodHintsSaved = this->inputMethodHints(); this->setEchoMode(QLineEdit::Password); this->setInputMethodHints(Qt::ImhHiddenText | Qt::ImhNoPredictiveText | Qt::ImhNoAutoUppercase); } else { this->setEchoMode(this->textEditEchoModeSaved); this->setInputMethodHints(this->textEditInputMethodHintsSaved); } } void _ZFP_text(const zfchar *text, zfbool needNotify) { if(this->textEditTextSaved.compare(text) == 0) { return ; } int cursor = this->cursorPosition(); if(ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyCheckTextShouldChange(this->ownerZFUITextEdit, text)) { int positionSaved = this->cursorPosition(); int textLengthOld = this->text().length(); this->textEditTextSaved = text; this->setText(ZFImpl_sys_Qt_zfstringToQString(text)); zfindex len = zfslen(text); if(len >= textLengthOld) { cursor = positionSaved + len - textLengthOld; } this->setCursorPosition(cursor); } else { this->setText(ZFImpl_sys_Qt_zfstringToQString(this->textEditTextSaved)); this->setCursorPosition(cursor); } if(needNotify) { ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyTextChange(this->ownerZFUITextEdit, text); } } public: virtual bool event(QEvent *event) { if(this->textEditEventOverrideFlag > 0) { return true; } bool ret = false; switch(event->type()) { case QEvent::FocusIn: ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyTextEditBegin(this->ownerZFUITextEdit); ret = QLineEdit::event(event); break; case QEvent::FocusOut: ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyTextEditEnd(this->ownerZFUITextEdit); ret = QLineEdit::event(event); break; case QEvent::KeyPress: { QKeyEvent *keyEvent = (QKeyEvent *)event; if(keyEvent->key() == Qt::Key_Return) { ret = true; } else { ret = QLineEdit::event(event); } } break; case QEvent::KeyRelease: { QKeyEvent *keyEvent = (QKeyEvent *)event; if(keyEvent->key() == Qt::Key_Return) { ret = true; ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyTextReturnClicked(this->ownerZFUITextEdit); } else { ret = QLineEdit::event(event); } } break; default: ret = QLineEdit::event(event); break; } return ret; } public slots: void _ZFP_textChanged(const QString &text) { if(this->textEditEventOverrideFlag > 0) { return ; } ++(this->textEditEventOverrideFlag); this->_ZFP_text(ZFImpl_sys_Qt_zfstringFromQString(text), zftrue); --(this->textEditEventOverrideFlag); } void _ZFP_textSelectRangeOnChange(int posOld, int posNew) { ZFPROTOCOL_ACCESS(ZFUITextEdit)->notifyTextSelectRangeChange(this->ownerZFUITextEdit); } }; ZF_NAMESPACE_GLOBAL_BEGIN ZFPROTOCOL_IMPLEMENTATION_BEGIN(ZFUITextEditImpl_sys_Qt, ZFUITextEdit, ZFProtocolLevel::e_SystemHigh) ZFPROTOCOL_IMPLEMENTATION_PLATFORM_HINT("Qt:QGraphicsProxyWidget:QLineEdit") public: virtual void *nativeTextEditCreate(ZF_IN ZFUITextEdit *textEdit) { QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(); proxy->setWidget(new _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit(textEdit)); return proxy; } virtual void nativeTextEditDestroy(ZF_IN ZFUITextEdit *textEdit, ZF_IN void *nativeTextEdit) { QGraphicsProxyWidget *proxy = ZFCastStatic(QGraphicsProxyWidget *, nativeTextEdit); delete proxy; } private: _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *getNativeImplView(ZF_IN ZFUITextEdit *textEdit) { QGraphicsProxyWidget *proxy = ZFCastStatic(QGraphicsProxyWidget *, textEdit->nativeImplView()); return qobject_cast<_ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *>(proxy->widget()); } // ============================================================ // properties public: virtual void textEditEnable(ZF_IN ZFUITextEdit *textEdit, ZF_IN zfbool textEditEnable) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->setReadOnly(!textEditEnable); } virtual void textEditSecure(ZF_IN ZFUITextEdit *textEdit, ZF_IN zfbool textEditSecured) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_textEditSecured(textEditSecured); } virtual void textEditKeyboardType(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUITextEditKeyboardTypeEnum textEditKeyboardType) { // not supported } virtual void textEditKeyboardReturnType(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUITextEditKeyboardReturnTypeEnum textEditKeyboardReturnType) { // not supported } virtual void textSelectRange(ZF_IN ZFUITextEdit *textEdit, ZF_OUT ZFIndexRange &textSelectRange) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); if(nativeImplView->hasSelectedText()) { textSelectRange.start = nativeImplView->selectionStart(); textSelectRange.count = nativeImplView->selectedText().length(); } else { textSelectRange.start = nativeImplView->cursorPosition(); textSelectRange.count = 0; } } virtual void textSelectRange(ZF_IN ZFUITextEdit *textEdit, ZF_IN const ZFIndexRange &textSelectRange) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); if(textSelectRange.count != 0) { nativeImplView->setSelection(textSelectRange.start, textSelectRange.count); } else { nativeImplView->setCursorPosition(textSelectRange.start); } } public: virtual void text(ZF_IN ZFUITextEdit *textEdit, ZF_IN const zfchar *text) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_text(text, zffalse); } virtual void textAppearance(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUITextAppearanceEnum const &textAppearance) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); QFont font = nativeImplView->font(); switch(textAppearance) { case ZFUITextAppearance::e_Normal: font.setBold(false); font.setItalic(false); break; case ZFUITextAppearance::e_Bold: font.setBold(true); font.setItalic(false); break; case ZFUITextAppearance::e_Italic: font.setBold(false); font.setItalic(true); break; case ZFUITextAppearance::e_BoldItalic: font.setBold(true); font.setItalic(true); break; default: zfCoreCriticalShouldNotGoHere(); return ; } nativeImplView->setFont(font); } virtual void textAlign(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUIAlignFlags const &textAlign) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->setAlignment(ZFImpl_sys_Qt_ZFUIAlignFlagsToQAlignment(textAlign)); } virtual void textColor(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUIColor const &textColor) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_textColor(textColor); } virtual void textShadowColor(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUIColor const &textShadowColor) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_textShadowUpdate(textShadowColor, textEdit->textShadowOffset()); } virtual void textShadowOffset(ZF_IN ZFUITextEdit *textEdit, ZF_IN ZFUISize const &textShadowOffset) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_textShadowUpdate(textEdit->textShadowColor(), textShadowOffset); } virtual void textSize(ZF_IN ZFUITextEdit *textEdit, ZF_IN zffloat textSize) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->_ZFP_textSize(textSize); } // ============================================================ // layout public: virtual ZFUISize measureNativeTextEdit(ZF_IN ZFUITextEdit *textEdit, ZF_IN const ZFUISize &sizeHint, ZF_IN zffloat textSize) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); QFont font = nativeImplView->font(); font.setPixelSize(textSize); QFontMetrics fm(font); QRect rect = fm.boundingRect(nativeImplView->text()); int padding = 8; return ZFUISizeMake(rect.width() + padding, rect.height() + padding); } public: virtual void textEditBegin(ZF_IN ZFUITextEdit *textEdit) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->setFocus(); } virtual void textEditEnd(ZF_IN ZFUITextEdit *textEdit) { _ZFP_ZFUITextEditImpl_sys_Qt_TextEdit *nativeImplView = getNativeImplView(textEdit); nativeImplView->clearFocus(); } ZFPROTOCOL_IMPLEMENTATION_END(ZFUITextEditImpl_sys_Qt) ZFPROTOCOL_IMPLEMENTATION_REGISTER(ZFUITextEditImpl_sys_Qt) ZF_NAMESPACE_GLOBAL_END #include "ZFProtocolZFUITextEdit_sys_Qt.moc" #endif // #if ZF_ENV_sys_Qt
13,807
4,284
#include <bits/stdc++.h> using namespace std; template<typename T> struct Edge { public: T weight, capacity; Edge( T weight=1, T capacity=1 ) : weight(weight), capacity(capacity) {} }; template<typename T> struct Node {}; template<typename T> struct Graph { public: Graph(int n=0) : edges(n), nodes(n) {} void add_edge( int u, int v, T weight=1, T capacity=1 ) { edges[u].emplace( v, Edge<T>(weight, capacity) ); } vector<map<int, Edge<T>>> edges; vector<Node<T>> nodes; vector<int> level; void bfs(int source=0) { int n = (int)nodes.size(); level = vector<int>(n, -1); level[source] = 0; queue<int> que; que.push(source); while (!que.empty()) { int u = que.front(); que.pop(); for ( const auto& p: edges[u]) { int v = p.first; Edge<T> e = p.second; if (level[v] != -1) { continue; } level[v] = level[u] + 1; que.push(v); } } } }; class Solver { int r, c, sy, sx, gy, gx, n; vector<char> maze; void prepare() { cin >> r >> c >> sy >> sx >> gy >> gx; sy--; sx--; gy--; gx--; n = r * c; maze = vector<char>(n); for (int i = 0; i < n; i++) { cin >> maze[i]; } } void solve() { int src = sy * c + sx; int dst = gy * c + gx; Graph<int> g(n); for (int i = 0; i < n; i++) { if (maze[i] == '#') { continue; } vector<int> nx; if (i >= c) { nx.push_back(i - c); } if (i <= n-c) { nx.push_back(i + c); } if (i%c != 0) { nx.push_back(i - 1); } if (i%c != c-1) { nx.push_back(i + 1); } for (const int& j: nx) { if (maze[j] == '#') { continue; } g.add_edge(i, j); } } g.bfs(src); cout << g.level[dst] << '\n'; } public: void run() { prepare(); solve(); } }; int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; while (t--) { Solver solver; solver.run(); } return 0; }
2,161
974
#include <iostream> #include <conio.h> #include <string.h> #include <fstream> #include <list> #include <vector> #include <stack> #include <string> #include <set> #include <queue> #include <stdlib.h> #include <time.h> //clockwise=1 //anticlockwise=0 using namespace std; class Gnode { private: int node[6][3][3]; //holds the cube entries list<Gnode> adjacencylist; //used to store successors of each state of cube int depthLevel; string rotation; //rotation applied to get to the state Gnode* parent; int f, g, h; //f for storing the value of g+h; g being the UCS and h being the heuristic value public: Gnode() {} Gnode(int temp[6][3][3]) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { node[i][j][k] = temp[i][j][k]; } } } parent = 0; } ~Gnode() { if (parent != 0) parent = 0; } void setDepthLevel(int level) { this->depthLevel = level; } int getDepth() { return this->depthLevel; } void setRotation(string temp) { this->rotation = temp; } string getRotation() { return this->rotation; } void addChild(Gnode temp) { this->adjacencylist.push_back(temp); } void printAdjacencyList() { int i = 1; list<Gnode>::iterator it; for (it = this->adjacencylist.begin(); it != this->adjacencylist.end(); it++) { Gnode temp = it->node; cout << "Child " << i << endl; temp.printNode(); i++; } } static Gnode clone(Gnode src) //returns a copy of passed parameter { return Gnode(src); } int getFValue() const { return this->f; } void setParent(Gnode parent) { this->parent = new Gnode(parent); } void printNode() { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { cout << this->node[i][j][k] << " "; } cout << endl; } cout << endl; } } static bool compareNode(Gnode temp, Gnode target) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { if (temp.node[i][j][k] != target.node[i][j][k]) return false; } } } return true; } static void runDFS(Gnode start, int depth, Gnode target) //This function is called from int main() to run IDS { bool temp = false; int numOfNodes = 0; stack<string> moves; //stores moves taken to get target/goal state if (depth >= 0) { time_t my_time = time(NULL); printf("Start Time: %s", ctime(&my_time)); for (int i = 0; i <= depth; i++) { cout << "Depth " << i << "\n"; temp = utilDFS(start, i, target, moves, numOfNodes); //recursively calls the DFS for each level of depth if (temp == true) { cout << "Nodes traversed: " << numOfNodes << endl << endl; cout << "Goal found.. :)\n\n"; time_t my_time = time(NULL); printf("End Time: %s", ctime(&my_time)); int total_moves = moves.size(); for (int k = 0; k < total_moves; k++) //printing moves taken to solve the cube { cout << moves.top(); moves.pop(); } return; } cout << "Nodes traversed: " << numOfNodes << endl << endl; numOfNodes = 0; } } } static bool utilDFS(Gnode start, int depth, Gnode target, stack<string>& moves, int& num) { if (compareNode(start, target)) { num++; return true; } if (depth == 0) { return false; } int j = 1; if (depth > 0) { if (start.adjacencylist.size() == 0) { Gnode successor[12]; for (int i = 0; i < 12; i++) { successor[i] = clone(start); } callRotation(successor, 12); for (int i = 0; i < 12; i++) { start.addChild(successor[i]); } } for (auto i = start.adjacencylist.begin(); i != start.adjacencylist.end(); i++) { Gnode temp = *i; num++; bool found = utilDFS(temp, depth - 1, target, moves, num); if (found == true) { moves.push(temp.rotation); return true; } j++; } } return false; } static void callRotation(Gnode* arr, int n) //applies all 12 rotations to current state of cube { int j = 0; for (int i = 0; i < n / 2; i++) { arr[i].rotateNode(j, 1); arr[i].rotation = "Move face "; arr[i].rotation.append(to_string(j)); arr[i].rotation.append(" Clockwise\n"); j++; } j = 0; for (int i = n / 2; i < n; i++) { arr[i].rotateNode(j, 0); arr[i].rotation = "Move face "; arr[i].rotation.append(to_string(j)); arr[i].rotation.append(" AntiClockwise\n"); j++; } } void rotateNode(int face, int direction) //takes a face and type of rotations to rotate the face { rotateCube(this->node, face, direction); } void rotateCube(int arr[6][3][3], int face, int move) //applies rotations to 3D array holding cube entries { int i = 0, j = 0, z = 0; int a1[3], a2[3], a3[3], a4[4], store[2], tran[3][3], k1 = 0, k2 = 0; if (move == 1) { if (face == 0) { for (i = 0; i < 3; i++) { a1[i] = arr[1][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[3][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[3][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[1][2][i] = a4[i]; } } if (face == 1) { for (i = 0; i < 3; i++) { a1[i] = arr[2][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[0][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[0][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[2][2][i] = a4[i]; } } if (face == 2) { for (i = 0; i < 3; i++) { a1[i] = arr[3][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[1][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[1][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[3][2][i] = a4[i]; } } if (face == 3) { for (i = 0; i < 3; i++) { a1[i] = arr[0][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[2][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[2][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[0][2][i] = a4[i]; } } if (face == 4) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][2]; a2[i] = arr[2][i][2]; a3[i] = arr[3][i][2]; a4[i] = arr[0][i][2]; } for (i = 0; i < 3; i++) { arr[2][i][2] = a1[i]; arr[3][i][2] = a2[i]; arr[0][i][2] = a3[i]; arr[1][i][2] = a4[i]; } } if (face == 5) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][0]; a2[i] = arr[0][i][0]; a3[i] = arr[3][i][0]; a4[i] = arr[2][i][0]; } for (i = 0; i < 3; i++) { arr[0][i][0] = a1[i]; arr[3][i][0] = a2[i]; arr[2][i][0] = a3[i]; arr[1][i][0] = a4[i]; } } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { tran[j][i] = arr[face][i][j]; } } k1 = 2, k2 = 0; for (j = 0; j < 3; j++) { store[0] = tran[j][k2]; store[1] = tran[j][k1]; tran[j][k2] = store[1]; tran[j][k1] = store[0]; } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { arr[face][i][j] = tran[i][j]; } } } //----------------------------------------------------------------------------------------------------------------- if (move == 0) { if (face == 0) { for (i = 0; i < 3; i++) { a1[i] = arr[1][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[3][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[3][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[1][2][i] = a2[i]; } } if (face == 1) { for (i = 0; i < 3; i++) { a1[i] = arr[2][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[0][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[0][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[2][2][i] = a2[i]; } } if (face == 2) { for (i = 0; i < 3; i++) { a1[i] = arr[3][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[1][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[1][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[3][2][i] = a2[i]; } } if (face == 3) { for (i = 0; i < 3; i++) { a1[i] = arr[0][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[2][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[2][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[0][2][i] = a2[i]; } } if (face == 4) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][2]; a2[i] = arr[2][i][2]; a3[i] = arr[3][i][2]; a4[i] = arr[0][i][2]; } for (i = 0; i < 3; i++) { arr[2][i][2] = a3[i]; arr[3][i][2] = a4[i]; arr[0][i][2] = a1[i]; arr[1][i][2] = a2[i]; } } if (face == 5) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][0]; a2[i] = arr[0][i][0]; a3[i] = arr[3][i][0]; a4[i] = arr[2][i][0]; } for (i = 0; i < 3; i++) { arr[0][i][0] = a3[i]; arr[3][i][0] = a4[i]; arr[2][i][0] = a1[i]; arr[1][i][0] = a2[i]; } } //swap elements to rotate 90 degree k1 = 2, k2 = 0; for (j = 0; j < 3; j++) { swap(arr[face][j][0], arr[face][j][2]); } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { tran[j][i] = arr[face][i][j]; } } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { arr[face][i][j] = tran[i][j]; } } } } //////////////////////////////////////////////////////////////////////// A* from here downwards static void runAStarPQ(Gnode start, Gnode target) { stack<Gnode> closed; priority_queue<Gnode> open; bool foundDest = false; int j = 0; start.f = 0; start.g = 0; start.h = 0; time_t my_time = time(NULL); printf("Start Time A*: %s", ctime(&my_time)); open.push(start); Gnode q; while (!open.empty()) { q = open.top(); open.pop(); j++; if (compareNode(q, target)) { cout << "Goal Found\n"; q.printNode(); time_t my_time = time(NULL); printf("End Time A*: %s\n", ctime(&my_time)); closed.push(q); cout << "Nodes traversed: " << j << endl << endl; cout << q.rotation << endl; //Printing moves from the stack taken to solve cube. Gnode* curr = q.parent; //This follows bottom up approach. while (curr != 0) { //Starting from goal and going to the top/initial state. cout << curr->rotation << endl; curr = curr->parent; } break; } //if (q.adjacencylist.size() == 0) { Gnode child[12]; for (int i = 0; i < 12; i++) { child[i] = clone(q); child[i].setParent(q); } callRotation(child, 12); bool temp[6][3][3]; clear_bool(temp); for (int i = 0; i < 12; i++) { child[i].g = q.g + 1; //setting g(n) child[i].h = Heuristic(child[i].node, temp, target.node); //setting h(n) child[i].f = child[i].g + child[i].h; bool found = findMatch(child[i], open); //checks if a node of same cube state and smaller f value already exists in the 'open' queue if (found == true) { open.push(child[i]); //push child to 'open' queue } } } closed.push(q); //pushing visited nodes in the 'closed' stack } } static void clear_bool(bool v[6][3][3]) //sets all bool values to true { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { v[i][j][k] = true; } } } } static int Return_Num(int phase, int i) //supplementary function to check faces of cube while computing heuristic { int st = 0; if (phase == 0) { if (i == 0) { st = 0; } else if (i == 1 || i == 3 || i == 4 || i == 5) { st = 1; } else { st = 2; } } else if (phase == 1) { if (i == 1) { st = 0; } else if (i == 2 || i == 0 || i == 4 || i == 5) { st = 1; } else { st = 2; } } else if (phase == 2) { if (i == 2) { st = 0; } else if (i == 1 || i == 3 || i == 4 || i == 5) { st = 1; } else { st = 2; } } else if (phase == 3) { if (i == 3) { st = 0; } else if (i == 0 || i == 2 || i == 4 || i == 5) { st = 1; } else { st = 2; } } else if (phase == 4) { if (i == 4) { st = 0; } else if (i == 0 || i == 1 || i == 2 || i == 3) { st = 1; } else { st = 2; } } else if (phase == 5) { if (i == 5) { st = 0; } else if (i == 0 || i == 1 || i == 2 || i == 3) { st = 1; } else { st = 2; } } return st; } //supplementary function to check faces of cube while computing heuristic static int Calculate(int arr[6][3][3], int goal[6][3][3], bool vis[6][3][3], int temp, int r, int c) { int i = 0, j = 0, k = 0, temp1 = 0; int sum = 0, st = 0; bool flag1 = true, flag2 = true, flag3 = true; temp1 = temp; for (i = 0; i < 6 && flag1 == true; i++) { for (j = 0; j < 3 && flag2 == true; j++) { for (k = 0; k < 3 && flag3 == true; k++) { //vis[temp1][r][c] = false; if (arr[temp1][j][k] == goal[temp][r][c] && vis[temp1][j][k] != false) { st = Return_Num(temp, temp1); sum += abs(r - j) + abs(c - k) + st; vis[temp1][j][k] = false; flag1 = false; flag2 = false; flag3 = false; } } } temp1 = (temp1 + 1) % 6; } return sum; } static int Heuristic(int arr[6][3][3], bool vis[6][3][3], int goal[6][3][3]) //Heuristic function { int phase = 0; clear_bool(vis); int r = 0, c = 0, sum = 0, i = 0, j = 0, k = 0; double h = 0; bool flag1 = true, flag2 = true, flag3 = true; int st = 0; int temp = 0, temp1 = 0; for (phase = 0; phase < 6; phase++) //loop for each phase to calculate { for (r = 0; r < 3; r++) { for (c = 0; c < 3; c++) { if (arr[temp][r][c] != goal[temp][r][c]) { sum += Calculate(arr, goal, vis, temp, r, c); } else { sum += 0; } } } temp++; } //cout << "Inline: " << h / 8 << endl; sum /= 12; int h1 = sum; //sum = 0; //clear_bool(vis); //for (phase = 0; phase < 6; phase++) //loop for each phase to calculate //{ // for (r = 0; r < 3; r++) // { // for (c = 0; c < 3; c++) // { // for (i = 0; i < 6 && flag1 == true; i++) // { // for (j = 0; j < 3 && flag2 == true; j++) // { // for (k = 0; k < 3 && flag3 == true; k++) // { // if ((r + c) == 1 || (r + c) == 3) // { // vis[phase][1][1] = false; //to avoid check itself in same phase // if (arr[phase][1][1] != arr[phase][r][c]) // { // if (arr[phase][1][1] == arr[i][j][k] && vis[i][j][k] != false) // { // st = Return_Num(phase, i); // sum += abs(r - j) + abs(c - k) + st; // vis[i][j][k] = false; // flag1 = false; // flag2 = false; // flag3 = false; // } // } // } // } // } // } // flag1 = true; // flag2 = true; // flag3 = true; // } // } // clear_bool(vis); //} ////cout << "Inline: " << h / 8 << endl; //sum /= 4; //int h2 = sum; /*if (h2>h1) return h1;*/ return h1; } static bool findMatch(Gnode src, priority_queue<Gnode> ls) //checks if a node of same cube state and smaller f value already exists in the 'open' queue { for (int i = 0; i < ls.size(); i++) { Gnode temp = ls.top(); ls.pop(); if (compareNode(src, temp) == true) { if (src.f > temp.f) { return false; } } } return true; } }; bool operator<(const Gnode& p1, const Gnode& p2) //operator overloaded for priority queue to sort on basis of f-value { return p1.getFValue() > p2.getFValue(); } void readFile(int init[6][3][3], int final[6][3][3]) { ifstream fin; fin.open("file.txt"); if (fin.is_open()) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { fin >> init[i][j][k]; //cout << init[i][j][k]; } } } for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { fin >> final[i][j][k]; //cout << final[i][j][k]; } } } } fin.close(); } void printCube(int arr[6][3][3]) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { cout << arr[i][j][k] << " "; } cout << endl; } cout << endl; } } void rotateCubee(int arr[6][3][3], int face, int move) { int i = 0, j = 0, z = 0; int a1[3], a2[3], a3[3], a4[4], store[2], tran[3][3], k1 = 0, k2 = 0; if (move == 1) { if (face == 0) { for (i = 0; i < 3; i++) { a1[i] = arr[1][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[3][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[3][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[1][2][i] = a4[i]; } } if (face == 1) { for (i = 0; i < 3; i++) { a1[i] = arr[2][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[0][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[0][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[2][2][i] = a4[i]; } } if (face == 2) { for (i = 0; i < 3; i++) { a1[i] = arr[3][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[1][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[1][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[3][2][i] = a4[i]; } } if (face == 3) { for (i = 0; i < 3; i++) { a1[i] = arr[0][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[2][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a1[i]; arr[2][0][i] = a2[i]; arr[5][i][2] = a3[i]; arr[0][2][i] = a4[i]; } } if (face == 4) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][2]; a2[i] = arr[2][i][2]; a3[i] = arr[3][i][2]; a4[i] = arr[0][i][2]; } for (i = 0; i < 3; i++) { arr[2][i][2] = a1[i]; arr[3][i][2] = a2[i]; arr[0][i][2] = a3[i]; arr[1][i][2] = a4[i]; } } if (face == 5) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][0]; a2[i] = arr[0][i][0]; a3[i] = arr[3][i][0]; a4[i] = arr[2][i][0]; } for (i = 0; i < 3; i++) { arr[0][i][0] = a1[i]; arr[3][i][0] = a2[i]; arr[2][i][0] = a3[i]; arr[1][i][0] = a4[i]; } } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { tran[j][i] = arr[face][i][j]; } } k1 = 2, k2 = 0; for (j = 0; j < 3; j++) { store[0] = tran[j][k2]; store[1] = tran[j][k1]; tran[j][k2] = store[1]; tran[j][k1] = store[0]; } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { arr[face][i][j] = tran[i][j]; } } } //----------------------------------------------------------------------------------------------------------------- if (move == 0) { if (face == 0) { for (i = 0; i < 3; i++) { a1[i] = arr[1][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[3][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[3][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[1][2][i] = a2[i]; } } if (face == 1) { for (i = 0; i < 3; i++) { a1[i] = arr[2][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[0][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[0][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[2][2][i] = a2[i]; } } if (face == 2) { for (i = 0; i < 3; i++) { a1[i] = arr[3][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[1][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[1][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[3][2][i] = a2[i]; } } if (face == 3) { for (i = 0; i < 3; i++) { a1[i] = arr[0][2][i]; a2[i] = arr[4][i][0]; a3[i] = arr[2][0][i]; a4[i] = arr[5][i][2]; } for (i = 0; i < 3; i++) { arr[4][i][0] = a3[i]; arr[2][0][i] = a4[i]; arr[5][i][2] = a1[i]; arr[0][2][i] = a2[i]; } } if (face == 4) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][2]; a2[i] = arr[2][i][2]; a3[i] = arr[3][i][2]; a4[i] = arr[0][i][2]; } for (i = 0; i < 3; i++) { arr[2][i][2] = a3[i]; arr[3][i][2] = a4[i]; arr[0][i][2] = a1[i]; arr[1][i][2] = a2[i]; } } if (face == 5) { for (i = 0; i < 3; i++) { a1[i] = arr[1][i][0]; a2[i] = arr[0][i][0]; a3[i] = arr[3][i][0]; a4[i] = arr[2][i][0]; } for (i = 0; i < 3; i++) { arr[0][i][0] = a3[i]; arr[3][i][0] = a4[i]; arr[2][i][0] = a1[i]; arr[1][i][0] = a2[i]; } } //swap elements to rotate 90 degree k1 = 2, k2 = 0; for (j = 0; j < 3; j++) { swap(arr[face][j][0], arr[face][j][2]); } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { tran[j][i] = arr[face][i][j]; } } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { arr[face][i][j] = tran[i][j]; } } } } int main() { int init[6][3][3], final[6][3][3]; readFile(init, final); bool temp[6][3][3]; //rotateCubee(init, 3, 1); //rotateCubee(init, 1, 1); //rotateCubee(init, 5, 0); //rotateCubee(init, 2, 0); //rotateCubee(init, 4, 0); //rotateCubee(init, 1, 0); //rotateCubee(init, 0, 1); //rotateCubee(init, 4, 1); //rotateCubee(init, 1, 0); Gnode start(init); Gnode target(final); cout << "Init state:\n"; start.printNode(); start.setDepthLevel(0); cout << "Goal state:\n"; target.printNode(); Gnode::runDFS(start, 15, target); //Calling IDS cout << "\n\nIDS exited..\n\n"; Gnode::runAStarPQ(start, target); //Calling A* cout << "A* exited..\n"; _getch(); }
23,130
13,552
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: TMPro.TMP_TextUtilities #include "TMPro/TMP_TextUtilities.hpp" // Including type: System.ValueType #include "System/ValueType.hpp" // Including type: UnityEngine.Vector3 #include "UnityEngine/Vector3.hpp" // Completed includes #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(::TMPro::TMP_TextUtilities::LineSegment, "TMPro", "TMP_TextUtilities/LineSegment"); // Type namespace: TMPro namespace TMPro { // Size: 0x18 #pragma pack(push, 1) // WARNING Layout: Sequential may not be correctly taken into account! // Autogenerated type: TMPro.TMP_TextUtilities/TMPro.LineSegment // [TokenAttribute] Offset: FFFFFFFF struct TMP_TextUtilities::LineSegment/*, public ::System::ValueType*/ { public: public: // public UnityEngine.Vector3 Point1 // Size: 0xC // Offset: 0x0 ::UnityEngine::Vector3 Point1; // Field size check static_assert(sizeof(::UnityEngine::Vector3) == 0xC); // public UnityEngine.Vector3 Point2 // Size: 0xC // Offset: 0xC ::UnityEngine::Vector3 Point2; // Field size check static_assert(sizeof(::UnityEngine::Vector3) == 0xC); public: // Creating value type constructor for type: LineSegment constexpr LineSegment(::UnityEngine::Vector3 Point1_ = {}, ::UnityEngine::Vector3 Point2_ = {}) noexcept : Point1{Point1_}, Point2{Point2_} {} // Creating interface conversion operator: operator ::System::ValueType operator ::System::ValueType() noexcept { return *reinterpret_cast<::System::ValueType*>(this); } // Get instance field reference: public UnityEngine.Vector3 Point1 ::UnityEngine::Vector3& dyn_Point1(); // Get instance field reference: public UnityEngine.Vector3 Point2 ::UnityEngine::Vector3& dyn_Point2(); // public System.Void .ctor(UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) // Offset: 0x1247E70 // ABORTED: conflicts with another method. LineSegment(::UnityEngine::Vector3 p1, ::UnityEngine::Vector3 p2); }; // TMPro.TMP_TextUtilities/TMPro.LineSegment #pragma pack(pop) static check_size<sizeof(TMP_TextUtilities::LineSegment), 12 + sizeof(::UnityEngine::Vector3)> __TMPro_TMP_TextUtilities_LineSegmentSizeCheck; static_assert(sizeof(TMP_TextUtilities::LineSegment) == 0x18); } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: TMPro::TMP_TextUtilities::LineSegment::LineSegment // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead!
2,862
953
#ifndef NODE_CLUTTER_TEXT_H_ #define NODE_CLUTTER_TEXT_H_ #include <clutter/clutter.h> #include <v8.h> #include <node.h> namespace clutter { class Text : public Actor { public: static void Initialize(v8::Handle<v8::Object> target); protected: Text(); static v8::Handle<v8::Value> New(const v8::Arguments& args); static v8::Handle<v8::Value> SetColor(const v8::Arguments& args); static v8::Handle<v8::Value> GetColor(const v8::Arguments& args); static v8::Handle<v8::Value> SetText(const v8::Arguments& args); static v8::Handle<v8::Value> GetText(const v8::Arguments& args); static v8::Handle<v8::Value> SetFontName(const v8::Arguments& args); static v8::Handle<v8::Value> GetFontName(const v8::Arguments& args); }; } #endif
740
284
/** * Connected Vision - https://github.com/ConnectedVision * MIT License */ #ifndef OutputPin_PNG_code #define OutputPin_PNG_code #include "OutputPin_PNG.h" #include <HTTP/HTTPTools.h> namespace ConnectedVision { namespace OutputPins { template <class TDataClass> OutputPin_PNG<TDataClass>::OutputPin_PNG(ConnectedVision::shared_ptr< ConnectedVision::DataHandling::IStore_Manager<TDataClass> > dataStoreManager, std::string (*getPNGImage)(const TDataClass&) ) : OutputPin_Generic<TDataClass>( dataStoreManager ), getPNGImage( getPNGImage ) { } template <class TDataClass> OutputPin_PNG<TDataClass>::~OutputPin_PNG(void) { } template <class TDataClass> ConnectedVision::HTTP::EnumHTTPStatus OutputPin_PNG<TDataClass>::packSingleObject(const ConnectedVision::shared_ptr<const TDataClass> &obj, ConnectedVisionResponse &response) { if ( obj ) { response.setContentType("image/png"); // return PNG as string response.setContent( getPNGImage(*obj) ); // use selector function return ConnectedVision::HTTP::HTTP_Status_OK; } else { // not found return writeErrorResponse(response, ConnectedVision::HTTP::HTTP_Status_NOT_FOUND, id_t("OutputPin<>"), "not found"); } } template <class TDataClass> ConnectedVision::HTTP::EnumHTTPStatus OutputPin_PNG<TDataClass>::packMultipleObjects(const std::vector<ConnectedVision::shared_ptr<const TDataClass>> &objs, ConnectedVisionResponse &response) { if ( !objs.size() ) { // not found return writeErrorResponse(response, ConnectedVision::HTTP::HTTP_Status_NOT_FOUND, id_t("OutputPin<>"), "not found"); } return this->packSingleObject(objs.at(0), response); } } // namespace OutputPins } // namespace ConnectedVision #endif // OutputPin_PNG_code
1,716
615
#include "AddPersonDialog.hpp" #include "ui_AddPersonDialog.h" AddPersonDialog::AddPersonDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AddPersonDialog) { ui->setupUi(this); } AddPersonDialog::~AddPersonDialog() { delete ui; } bool AddPersonDialog::isPersonCreated() const { return personCreated; } Person AddPersonDialog::getPerson() const { return person; } void AddPersonDialog::on_diedCheckBox_toggled(bool checked) { if (checked) ui->actualPlaceLabel->setText("Miejsce pochówku"); else ui->actualPlaceLabel->setText("Miejsce zamieszkania"); ui->diedDateEdit->setEnabled(checked); } void AddPersonDialog::on_buttonBox_accepted() { auto name = ui->nameLineEdit->text().toStdString(); auto surname = ui->surnameLineEdit->text().toStdString(); auto place = ui->actualPlaceLineEdit->text().toStdString(); auto born = ui->bornDateEdit->value(); auto died = ui->diedCheckBox->isChecked(); auto death = ui->diedDateEdit->value(); person.setName(name); person.setSurname(surname); person.setPlace(place); person.setBirthdate(born); person.setIsAlive(!died); person.setDeathdate(death); personCreated = true; }
1,255
413
/* * Copyright (c) 2003-2006, National ICT Australia (NICTA) */ /* * Copyright (c) 2007 Open Kernel Labs, Inc. (Copyright Holder). * All rights reserved. * * 1. Redistribution and use of OKL4 (Software) in source and binary * forms, with or without modification, are permitted provided that the * following conditions are met: * * (a) Redistributions of source code must retain this clause 1 * (including paragraphs (a), (b) and (c)), clause 2 and clause 3 * (Licence Terms) and the above copyright notice. * * (b) Redistributions in binary form must reproduce the above * copyright notice and the Licence Terms in the documentation and/or * other materials provided with the distribution. * * (c) Redistributions in any form must be accompanied by information on * how to obtain complete source code for: * (i) the Software; and * (ii) all accompanying software that uses (or is intended to * use) the Software whether directly or indirectly. Such source * code must: * (iii) either be included in the distribution or be available * for no more than the cost of distribution plus a nominal fee; * and * (iv) be licensed by each relevant holder of copyright under * either the Licence Terms (with an appropriate copyright notice) * or the terms of a licence which is approved by the Open Source * Initative. For an executable file, "complete source code" * means the source code for all modules it contains and includes * associated build and other files reasonably required to produce * the executable. * * 2. THIS SOFTWARE IS PROVIDED ``AS IS'' AND, TO THE EXTENT PERMITTED BY * LAW, ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED. WHERE ANY WARRANTY IS * IMPLIED AND IS PREVENTED BY LAW FROM BEING DISCLAIMED THEN TO THE * EXTENT PERMISSIBLE BY LAW: (A) THE WARRANTY IS READ DOWN IN FAVOUR OF * THE COPYRIGHT HOLDER (AND, IN THE CASE OF A PARTICIPANT, THAT * PARTICIPANT) AND (B) ANY LIMITATIONS PERMITTED BY LAW (INCLUDING AS TO * THE EXTENT OF THE WARRANTY AND THE REMEDIES AVAILABLE IN THE EVENT OF * BREACH) ARE DEEMED PART OF THIS LICENCE IN A FORM MOST FAVOURABLE TO * THE COPYRIGHT HOLDER (AND, IN THE CASE OF A PARTICIPANT, THAT * PARTICIPANT). IN THE LICENCE TERMS, "PARTICIPANT" INCLUDES EVERY * PERSON WHO HAS CONTRIBUTED TO THE SOFTWARE OR WHO HAS BEEN INVOLVED IN * THE DISTRIBUTION OR DISSEMINATION OF THE SOFTWARE. * * 3. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ANY OTHER PARTICIPANT 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. */ /* * Description: ARMv5 syscall and page fault handlers */ #include <l4.h> #include <debug.h> #include <space.h> #include <tcb.h> #include <tracebuffer.h> #include <kdb/tracepoints.h> /* ARM program counter fixup - LSB used for context frame type */ #define PC(x) (x & (~1UL)) #if !defined(CONFIG_ENABLE_FASS) #error ARMv5 requires FASS enabled #endif DECLARE_TRACEPOINT(ARM_PAGE_FAULT); DECLARE_TRACEPOINT(ARM_DATA_ABORT); /* Function declarations */ CONTINUATION_FUNCTION(finish_arm_memory_abort); bool fass_sync_address (space_t * space, addr_t fault_addr, bool * is_valid = NULL); void fass_update_pds (space_t * space, pgent_t cpg, pgent_t spg, word_t fault_section); extern "C" NORETURN void send_exception_ipc (word_t exc_no, word_t exc_code, arm_irq_context_t *context, continuation_t continuation); /* * ARM data/instruction abort handler * * This function handles ARM pagefaults including domain faults, * data and prefetch aborts and alignment faults. */ extern "C" void arm_memory_abort(word_t fault_status, addr_t fault_addr, arm_irq_context_t *context, word_t data_abt) { /* Note, fs = 0 for execute fault */ word_t fs = fault_status & 0xf; tcb_t * current = get_current_tcb(); TRACEPOINT(ARM_DATA_ABORT, space_t *_s = current->get_space(); word_t _pid = (word_t)fault_addr; if (_s && ((word_t)fault_addr < PID_AREA_SIZE)) { _pid = _s->get_pid(); _pid = (word_t)fault_addr + (_pid << 25); } printf("DABT @ %p [%p], pc = %p, tcb = %p, fs = %x\n", (addr_t)_pid, fault_addr, (addr_t)PC(context->pc), current, data_abt ? fs : 0x10) ); /* See ARM ARM B3-19 - only deal with prefetch aborts, translation, * domain and permission data aborts. Alignment and external aborts are * not currently recoverable. */ if (data_abt) { switch(fs) { /* Allowed abort exception types */ case 7: case 5: case 15: case 13: case 9: case 11: break; case 2: /* Terminal exception, not recoverable */ default: /* Unhandled exception */ { bool is_kernel = ((context->cpsr & CPSR_MODE_MASK) != CPSR_USER_MODE); if (is_kernel) { panic("kernel raised data abort exception: @ %p, ip = %p, fs = %ld\n", fault_addr, (addr_t)context->pc, fs); } current->arch.misc.exception.exception_continuation = ASM_CONTINUATION; current->arch.misc.exception.exception_context = context; send_exception_ipc(0x100 + fs, (word_t)fault_addr, context, ASM_CONTINUATION); } } } space_t *space = current->get_space(); if (EXPECT_FALSE(space == NULL)) { space = get_kernel_space(); } else { /* PID relocation */ if ((word_t)fault_addr < PID_AREA_SIZE) { word_t pid = space->get_pid(); fault_addr = (addr_t)((word_t)fault_addr + (pid << 25)); //printf("pid relocated %d -> %p\n", pid, fault_addr); } } bool is_kernel = ((context->cpsr & CPSR_MODE_MASK) != CPSR_USER_MODE); word_t fault_section = (word_t)fault_addr >> PAGE_BITS_1M; if (EXPECT_FALSE(is_kernel)) { /* Special case when UTCB sections faulted on */ if (((word_t)fault_addr >= UTCB_AREA_START) && ((word_t)fault_addr < UTCB_AREA_END)) { pgent_t cpd_entry = get_cpd()[fault_section]; // TRACEF("utcb space = %p\n", utcb_space); if (cpd_entry.raw && ((cpd_entry.raw & 0xf0000003) == 0xf0000000)) { space_t * utcb_space = (space_t*)cpd_entry.raw; get_arm_fass()->activate_other_domain(utcb_space); /* NB. We don't add utcb domain's section to dirty set */ return; } TRACEF("utcb fault, addr = %p, tcb = %p, space = %p\n", fault_addr, current, space); TRACEF(" entry = %lx (%lx), currdomain = %lx\n", cpd_entry.raw, cpd_entry.get_domain(), current_domain); TRACEF(" * pc = %p, fs = %x, fdomain = %lx\n", (addr_t)PC(context->pc), fs, (fault_status & 0xf0) >> 4); return; } } bool is_valid = false; if (space->is_user_area(fault_addr)) { arm_domain_t fault_domain; /* * Cases -= Shrd domains: * Fault since thread no access to domain * Fault since page not mapped * - Valid domain * - No domain */ pgent_t cpd_entry = get_cpd()[fault_section]; fault_domain = cpd_entry.get_domain(); if (fault_domain != current_domain) { /* if a domain fault */ if (!(space->get_domain_mask() & (3UL << (fault_domain*2)))) { space_t *share_space = get_arm_fass()->get_space(fault_domain); //printf("check domain is shared: %p (me %p, dspc %p)\n", fault_addr, space, share_space); if (share_space && share_space->is_client_space(space)) { //printf(" - fault at %p in spc %p ip = %p\n", fault_addr, // space, (addr_t)PC(context->pc)); //printf(" - ### share space %p! fs = %d (%lx - %d:%d)\n", share_space, fs, // space->get_domain_mask(), space->get_domain(), share_space->get_domain()); bool manager = space->is_manager_of_domain(share_space); space->add_domain_access(fault_domain, manager); current_domain_mask = space->get_domain_mask(); domain_dirty |= current_domain_mask; return; } } pgent_t *pg = space->pgent((word_t)fault_addr >> PAGE_BITS_TOP_LEVEL); //printf("check for shared domain: %p, -- %p/%lx\n", fault_addr, pg, pg->raw); if (pg->is_valid(space, pgent_t::size_level0)) { pgent_t section = *(pg->subtree(space, pgent_t::size_level0)->next( space, pgent_t::size_1m, ((word_t)fault_addr & (PAGE_SIZE_TOP_LEVEL-1)) >> PAGE_BITS_1M)); //printf(" - look for spc: %p = %lx\n", pg->subtree(space, pgent_t::size_level0)->next( // space, pgent_t::size_1m, // ((word_t)fault_addr & (PAGE_SIZE_TOP_LEVEL-1)) >> PAGE_BITS_1M), section.raw); if (EXPECT_FALSE(section.is_window(space, pgent_t::size_1m))) { space_t *share_space = (space_t*)section.get_window(space); pgent_t *share_pg = share_space->pgent((word_t)fault_addr >> PAGE_BITS_TOP_LEVEL); //printf(" - fault at %p in spc %p ip = %p shr : %p\n", fault_addr, // space, (addr_t)PC(context->pc), share_space); if (share_pg->is_valid(share_space, pgent_t::size_level0)) { pgent_t share_sec = *(share_pg->subtree(share_space, pgent_t::size_level0)->next( share_space, pgent_t::size_1m, ((word_t)fault_addr & (PAGE_SIZE_TOP_LEVEL-1)) >> PAGE_BITS_1M)); if (share_sec.is_valid(share_space, pgent_t::size_1m)) { arm_domain_t share_domain = share_space->get_domain(); bool manager = space->is_manager_of_domain(share_space); if (share_domain == INVALID_DOMAIN) { //printf(" -- shr domain activate\n"); get_arm_fass()->activate_other_domain(share_space); /* get domain again if we activate_other_domain */ share_domain = share_space->get_domain(); space->add_domain_access(share_domain, manager); current_domain_mask = space->get_domain_mask(); domain_dirty |= current_domain_mask; /* Update the faulter domain's set of sections in the CPD */ get_arm_fass()->add_set(share_domain, fault_section); /* Update the CPD */ share_sec.set_domain(share_domain); /* keep TLB in sync if replacing entries */ if (get_cpd()[fault_section].is_valid(space, pgent_t::size_1m)) { arm_cache::tlb_flush(); } get_cpd()[fault_section] = share_sec; return; } //printf(" -- handle dm flt\n"); if (fault_domain != share_domain) { space->add_domain_access(share_domain, manager); current_domain_mask = space->get_domain_mask(); domain_dirty |= current_domain_mask; current_domain = share_domain; fass_update_pds(share_space, cpd_entry, share_sec, fault_section); current_domain = space->get_domain(); return; } } is_valid = true; } /* translation fault in shared area */ if (section.is_callback()) { current->set_preempted_ip( current->get_user_ip() ); current->get_utcb()->share_fault_addr = (word_t)fault_addr; //printf(" - restart ip = %p\n", (void*)current->get_preempt_callback_ip()); current->set_user_ip( current->get_preempt_callback_ip() ); return; } goto handle_fault; } } } } if (fass_sync_address(space, fault_addr, &is_valid)) return; handle_fault: current->arch.misc.fault.fault_addr = fault_addr; current->arch.misc.fault.page_fault_continuation = ASM_CONTINUATION; TRACEPOINT(ARM_PAGE_FAULT, space_t *_s = current->get_space(); word_t _pid = (word_t)fault_addr; if (_s && ((word_t)fault_addr < PID_AREA_SIZE)) { _pid = _s->get_pid(); _pid = (word_t)fault_addr + (_pid << 25); } printf("PF @ %p [%p], pc = %p, tcb = %p, fs = %x\n", (addr_t)_pid, fault_addr, (addr_t)PC(context->pc), current, fs) ); space->handle_pagefault(fault_addr, (addr_t)PC(context->pc), data_abt ? (is_valid ? space_t::write : space_t::read) : space_t::execute, is_kernel, finish_arm_memory_abort); /* * We only return from space->handle_pagefault() on a kernel fault * where fault_addr != user_address. Otherwise, continuation * finish_arm_memory_abort() is called. */ /* return value is ignored here since we return anyway */ (void)fass_sync_address(space, fault_addr); return; } /* Continue after handling a user pagefault (from arm_memory_abort) */ CONTINUATION_FUNCTION(finish_arm_memory_abort) { tcb_t * current = get_current_tcb(); space_t * space = current->get_space(); addr_t fault_addr = current->arch.misc.fault.fault_addr; if (!space) { space = get_kernel_space(); } /* return value is ignored here since we return anyway */ (void)fass_sync_address(space, fault_addr); ACTIVATE_CONTINUATION(current->arch.misc.fault.page_fault_continuation); } void fass_update_pds (space_t * space, pgent_t cpg, pgent_t spg, word_t fault_section) { bool cpd_section_valid = cpg.is_valid(get_kernel_space(), pgent_t::size_1m); arm_domain_t cpd_section_domain = cpg.get_domain(); /* Clean the kernel's UTCB synonym if necessary */ bool need_flush = (cpd_section_valid && TEST_DOMAIN(domain_dirty, cpd_section_domain)); /* If there is an existing mapping in the CPD for this section, * remove it from the owner domain's set of sections in the CPD */ if (cpd_section_valid) get_arm_fass()->remove_set(cpd_section_domain, fault_section); /* Update the faulter domain's set of sections in the CPD */ get_arm_fass()->add_set(current_domain, fault_section); /* Update the CPD */ spg.set_domain(current_domain); get_cpd()[fault_section] = spg; if (need_flush) { bool flush = 1; space_t *old_space = get_arm_fass()->get_space(cpd_section_domain); if (old_space) { word_t old_vspace = old_space->get_vspace(); if (old_vspace && (space->get_vspace() == old_vspace)) flush = 0; } get_arm_fass()->clean_all(flush); domain_dirty |= current_domain_mask; } else { // need to remove all entries corresponding to fault section // from TLB. Cheaper to flush than to iterate over section // on SA-1100 (FIXME - check other archs' MMU). arm_cache::tlb_flush(); } } bool fass_sync_address (space_t * space, addr_t fault_addr, bool * is_valid) { /* Try lookup the mapping */ pgent_t *pg = space->pgent((word_t)fault_addr >> PAGE_BITS_TOP_LEVEL); if (EXPECT_FALSE(!pg->is_valid(space, pgent_t::size_level0))) return false; pgent_t section = *(pg->subtree(space, pgent_t::size_level0)->next( space, pgent_t::size_1m, ((word_t)fault_addr & (PAGE_SIZE_TOP_LEVEL-1)) >> PAGE_BITS_1M)); if (EXPECT_FALSE(!section.is_valid(space, pgent_t::size_1m))) return false; if (section.is_subtree(space, pgent_t::size_1m)) { pgent_t& leaf = *section.subtree(space, pgent_t::size_1m)->next( space, pgent_t::size_min, ((word_t)fault_addr & (PAGE_SIZE_1M-1)) >> ARM_PAGE_BITS); if (leaf.l2.fault.zero == 0) return false; } /* Does the faulter's space's section match that in the CPD for the fault * address? */ word_t fault_section = (word_t)fault_addr >> PAGE_BITS_1M; pgent_t cpg = get_cpd()[fault_section]; if (EXPECT_TRUE((cpg.get_domain() != current_domain) && space->is_user_area(fault_addr))) { fass_update_pds(space, cpg, section, fault_section); return true; } /* this is the uncommon case so take the performance hit (dereferencing the pointer) here */ if (is_valid) *is_valid = true; return false; }
18,600
6,016
/** * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ #include "backend/protobuf/query_responses/proto_error_query_response.hpp" #include "utils/variant_deserializer.hpp" namespace shared_model { namespace proto { ErrorQueryResponse::ErrorQueryResponse( iroha::protocol::QueryResponse &query_response) : error_response_(*query_response.mutable_error_response()), variant_{[this] { auto &ar = error_response_; unsigned which = ar.GetDescriptor() ->FindFieldByName("reason") ->enum_type() ->FindValueByNumber(ar.reason()) ->index(); return shared_model::detail:: variant_impl<ProtoQueryErrorResponseListType>::template load< ProtoQueryErrorResponseVariantType>(ar, which); }()}, ivariant_{QueryErrorResponseVariantType{variant_}} {} const ErrorQueryResponse::QueryErrorResponseVariantType & ErrorQueryResponse::get() const { return ivariant_; } const ErrorQueryResponse::ErrorMessageType & ErrorQueryResponse::errorMessage() const { return error_response_.message(); } ErrorQueryResponse::ErrorCodeType ErrorQueryResponse::errorCode() const { return error_response_.error_code(); } } // namespace proto } // namespace shared_model
1,494
385
#include "pch.h" #include "../include/state/state.h" #include "../include/application.h" Empaerior::State::State() = default;
133
54
/****************************************************************/ /* */ /* SecurityPage.cpp */ /* */ /* Implementation of the CSecurityPage class. */ /* This class is a part of the FTP Server. */ /* */ /* Programmed by xingyun86 */ /* Copyright @2017 */ /* http://www.ppsbbs.tech */ /* */ /* Last updated: 10 july 2002 */ /* */ /****************************************************************/ #include "stdafx.h" #include "FTPServerApp.h" #include "ftpserver.h" #include "SecurityPage.h" #include "AddIPDlg.h" extern CFTPServer theServer; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CSecurityPage::CSecurityPage(CWnd* pParent /*=NULL*/) : CDialogResize(CSecurityPage::IDD, pParent) { //{{AFX_DATA_INIT(CSecurityPage) m_bBlockAll = FALSE; //}}AFX_DATA_INIT } void CSecurityPage::DoDataExchange(CDataExchange* pDX) { CDialogResize::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSecurityPage) DDX_Control(pDX, IDC_BLOCKEDLIST, m_BlockedList); DDX_Control(pDX, IDC_NONBLOCKEDLIST, m_NonBlockedList); DDX_Check(pDX, IDC_BLOCK_ALL, m_bBlockAll); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSecurityPage, CDialogResize) //{{AFX_MSG_MAP(CSecurityPage) ON_BN_CLICKED(IDC_BLOCK_ALL, OnBlockAll) ON_WM_DESTROY() ON_BN_CLICKED(IDC_ADD_BLOCK, OnAddBlock) ON_BN_CLICKED(IDC_EDIT_BLOCK, OnEditBlock) ON_BN_CLICKED(IDC_ADD_NONBLOCK, OnAddNonblock) ON_BN_CLICKED(IDC_EDIT_NONBLOCK, OnEditNonblock) ON_BN_CLICKED(IDC_REMOVE_BLOCK, OnRemoveBlock) ON_BN_CLICKED(IDC_REMOVE_NONBLOCK, OnRemoveNonblock) ON_LBN_DBLCLK(IDC_BLOCKEDLIST, OnDblclkBlockedlist) ON_LBN_DBLCLK(IDC_NONBLOCKEDLIST, OnDblclkNonblockedlist) //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DLGRESIZE_MAP(CSecurityPage) DLGRESIZE_CONTROL(IDC_BLOCKEDLIST, DLSZ_SIZE_X) DLGRESIZE_CONTROL(IDC_NONBLOCKEDLIST, DLSZ_SIZE_X) END_DLGRESIZE_MAP() /********************************************************************/ /* */ /* Function name : OnInitDialog */ /* Description : Initialize dialog */ /* */ /********************************************************************/ BOOL CSecurityPage::OnInitDialog() { CDialogResize::OnInitDialog(); InitResizing(FALSE, FALSE, WS_CLIPCHILDREN); m_bBlockAll = AfxGetApp()->GetProfileInt("Settings", "BlockAll", 0); GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll); UpdateData(FALSE); CStringArray strArray; theServer.m_SecurityManager.GetBlockedList(strArray); for (int i=0; i < strArray.GetSize(); i++) { m_BlockedList.AddString(strArray[i]); } theServer.m_SecurityManager.GetNonBlockedList(strArray); for (int j=0; j < strArray.GetSize(); j++) { m_NonBlockedList.AddString(strArray[j]); } // get list of all ip addresses in use by this system (only show first two...) char szHostName[128]; HOSTENT *lpHost=NULL; struct sockaddr_in sock; gethostname(szHostName, sizeof(szHostName)); lpHost = gethostbyname(szHostName); if (lpHost != NULL) { for(int i=0; lpHost->h_addr_list[i] != NULL ;i++) { memcpy(&(sock.sin_addr), lpHost->h_addr_list[i], lpHost->h_length); if (i == 0) { SetDlgItemText(IDC_IPADDRESS1, inet_ntoa(sock.sin_addr)); } else if (i == 1) { SetDlgItemText(IDC_IPADDRESS2, inet_ntoa(sock.sin_addr)); } } } return TRUE; } /********************************************************************/ /* */ /* Function name : OnDestroy */ /* Description : Dialog is about to be destroyed. */ /* */ /********************************************************************/ void CSecurityPage::OnDestroy() { UpdateData(); AfxGetApp()->WriteProfileInt("Settings", "BlockAll", m_bBlockAll); CDialogResize::OnDestroy(); } /********************************************************************/ /* */ /* Function name : OnBlockAll */ /* Description : Block all except... has been clicked. */ /* */ /********************************************************************/ void CSecurityPage::OnBlockAll() { UpdateData(); GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll); theServer.SetSecurityMode(!m_bBlockAll); } /********************************************************************/ /* */ /* Function name : OnAddBlock */ /* Description : Add IP address to blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnAddBlock() { CAddIPDlg dlg; if (dlg.DoModal() == IDOK) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } int nIndex = m_BlockedList.AddString(dlg.m_strIPaddress); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } } /********************************************************************/ /* */ /* Function name : OnEditBlock */ /* Description : Edit IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnEditBlock() { int nIndex = m_BlockedList.GetCurSel(); if (nIndex == -1) return; CAddIPDlg dlg; dlg.m_strTitle = "Edit IP address"; m_BlockedList.GetText(nIndex, dlg.m_strIPaddress); if (dlg.DoModal() == IDOK) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } m_BlockedList.DeleteString(nIndex); nIndex = m_BlockedList.AddString(dlg.m_strIPaddress); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } } /********************************************************************/ /* */ /* Function name : OnRemoveBlock */ /* Description : Remove IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnRemoveBlock() { int nIndex = m_BlockedList.GetCurSel(); if (nIndex == -1) return; m_BlockedList.DeleteString(nIndex); m_BlockedList.SetCurSel(0); UpdateSecurityData(0); } /********************************************************************/ /* */ /* Function name : OnAddNonblock */ /* Description : Add IP address to non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnAddNonblock() { CAddIPDlg dlg; if (dlg.DoModal() == IDOK) { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } int nIndex = m_NonBlockedList.AddString(dlg.m_strIPaddress); m_NonBlockedList.SetCurSel(nIndex); UpdateSecurityData(1); } } /********************************************************************/ /* */ /* Function name : OnEditNonblock */ /* Description : Edit IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnEditNonblock() { int nIndex = m_NonBlockedList.GetCurSel(); if (nIndex == -1) return; CAddIPDlg dlg; dlg.m_strTitle = "Edit IP address"; m_NonBlockedList.GetText(nIndex, dlg.m_strIPaddress); if (dlg.DoModal() == IDOK) { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } m_NonBlockedList.DeleteString(nIndex); nIndex = m_NonBlockedList.AddString(dlg.m_strIPaddress); m_NonBlockedList.SetCurSel(nIndex); UpdateSecurityData(1); } } /********************************************************************/ /* */ /* Function name : OnRemoveNonblock */ /* Description : Remove IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnRemoveNonblock() { int nIndex = m_NonBlockedList.GetCurSel(); if (nIndex == -1) return; m_NonBlockedList.DeleteString(nIndex); m_NonBlockedList.SetCurSel(0); UpdateSecurityData(1); } /********************************************************************/ /* */ /* Function name : UpdateSecurityData */ /* Description : Update security data. */ /* */ /********************************************************************/ void CSecurityPage::UpdateSecurityData(int nType) { CStringArray strArray; if (nType == 0) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); strArray.Add(strText); } theServer.m_SecurityManager.UpdateBlockedList(strArray); } else { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); strArray.Add(strText); } theServer.m_SecurityManager.UpdateNonBlockedList(strArray); } } /********************************************************************/ /* */ /* Function name : AddIPToBlockList */ /* Description : Add IP address to blocked list. */ /* */ /********************************************************************/ void CSecurityPage::AddIPToBlockList(LPCTSTR lpszIP) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(lpszIP) == 0) { // already exists ! return; } } int nIndex = m_BlockedList.AddString(lpszIP); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } /********************************************************************/ /* */ /* Function name : OnDblclkBlockedlist */ /* Description : Edit IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnDblclkBlockedlist() { OnEditBlock(); } /********************************************************************/ /* */ /* Function name : OnDblclkNonblockedlist */ /* Description : Edit IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnDblclkNonblockedlist() { OnEditNonblock(); }
12,226
5,097
/* * Copyright (c) 2017-2018 CelePixel Technology Co. Ltd. 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. */ #include <opencv2/opencv.hpp> #include <celex5/celex5.h> #include <celex5/celex5datamanager.h> #define MAT_ROWS 800 #define MAT_COLS 1280 #define FPN_PATH "../Samples/config/FPN_3.txt" #ifdef _WIN32 #include <windows.h> #else #include<unistd.h> #endif using namespace std; using namespace cv; CeleX5 *pCeleX5 = new CeleX5; class SensorDataObserver : public CeleX5DataManager { public: SensorDataObserver(CX5SensorDataServer* pServer) { m_pServer = pServer; m_pServer->registerData(this, CeleX5DataManager::CeleX_Frame_Data); } ~SensorDataObserver() { m_pServer->registerData(this, CeleX5DataManager::CeleX_Frame_Data); } virtual void onFrameDataUpdated(CeleX5ProcessedData* pSensorData);//overrides Observer operation CX5SensorDataServer* m_pServer; }; void SensorDataObserver::onFrameDataUpdated(CeleX5ProcessedData* pSensorData) { if (NULL == pSensorData) return; if (CeleX5::Event_Address_Only_Mode == pSensorData->getSensorMode() || CeleX5::Event_Intensity_Mode == pSensorData->getSensorMode()) { std::vector<EventData> vecEvent; uint64_t frameNo = 0; pCeleX5->getEventDataVector(vecEvent, frameNo); cout << "vec no: " << frameNo << endl; if (vecEvent.size() > 0) { vector<IMUData> imu; if (pCeleX5->getIMUData(imu) > 0) { for (int i = 0; i < imu.size(); i++) { cout << "imu no: " << imu[i].frameNo << endl; cout << "x_ACC = " << imu[i].x_ACC << ", y_ACC = " << imu[i].y_ACC << ", z_ACC = " << imu[i].z_ACC << endl; } } } } } int main() { std::string ipAddress = "192.168.1.11"; int ipPort = 1234; if (NULL == pCeleX5) return 0; pCeleX5->openSensor(CeleX5::CeleX5_ZYNQ); pCeleX5->connectToZYNQServer(ipAddress, ipPort); //socket connect pCeleX5->setFpnFile(FPN_PATH); pCeleX5->setSensorFixedMode(CeleX5::Event_Address_Only_Mode); SensorDataObserver* pSensorData = new SensorDataObserver(pCeleX5->getSensorDataServer()); while (true) { #ifdef _WIN32 Sleep(1); #else usleep(1000 * 10); #endif } return 1; }
2,642
1,126
// // Created by Vitali Kurlovich on 12/16/15. // #ifndef RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP #define RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP #include "../TMatrix4x3_def.hpp" namespace rmmath { namespace matrix { template<typename T> inline bool operator==(const TMatrix4x3 <T> &a, const TMatrix4x3 <T> &b) { return &a == &b || (a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m10 == b.m10 && a.m11 == b.m11 && a.m12 == b.m12 && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22 && a.m30 == b.m30 && a.m31 == b.m31 && a.m32 == b.m32 ); } template<typename T> inline bool operator!=(const TMatrix4x3 <T> &a, const TMatrix4x3 <T> &b) { return !(a == b); } } } #endif //RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP
1,065
436
/* * Copyright 2010 Erik Gilling * * 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 __Sequence_hh__ #define __Sequence_hh__ #include <string> using namespace std; #include <State.hh> class Sequence { private: unsigned refCount; string name; public: virtual void start(void) = 0; virtual void stop(void) = 0; virtual bool handleFrame(uint32_t *frame, unsigned len, float timeCode) = 0; void get(void) { refCount++; } int put(void) { return --refCount; } string getName(void) { return this->name; } void setName(string name) { this->name = name; } }; #endif /* __Sequence_hh__ */
1,127
383
/* The MIT License (MIT) Copyright (c) 2012-2021 Ivan Gagis <igagis@gmail.com> 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. */ /* ================ LICENSE END ================ */ #pragma once #include <string_view> #include <utki/span.hpp> #include <papki/file.hpp> #include "extra_info.hpp" /** * treeml is a very simple markup language. It is used to describe object * hierarchies. The only kind of objects present in treeml are strings. * Objects (which are strings) can have arbitrary number of child objects. */ namespace tml{ /** * @brief Listener interface for treeml parser. * During the treeml document parsing the Parser notifies this listener object * about parsed tokens. */ class listener{ public: /** * @brief A string token has been parsed. * This method is called by Parser when String token has been parsed. * @param str - parsed string. * @param info - extra information, like line:offset position in original text file. */ virtual void on_string_parsed(std::string_view str, const extra_info& info) = 0; /** * @brief Children list parsing started. * This method is called by Parser when '{' token has been parsed. */ virtual void on_children_parse_started(location loc) = 0; /** * @brief Children list parsing finished. * This method is called by Parser when '}' token has been parsed. */ virtual void on_children_parse_finished(location loc) = 0; virtual ~listener()noexcept{} }; /** * @brief treeml parser. * This is a class of treeml parser. It is used for event-based parsing of treeml * documents. */ class parser{ std::vector<char> buf; // buffer for current string being parsed // used for raw string open/close sequences, unicode sequences etc. std::string sequence; size_t sequence_index; // This variable is used for tracking current nesting level to make checks for detecting malformed treeml document unsigned nesting_level; enum class state{ initial, // state before parsing the first node idle, string_parsed, quoted_string, escape_sequence, unicode_sequence, unquoted_string, comment_seqence, single_line_comment, multiline_comment, raw_cpp_string_opening_sequence, raw_cpp_string_closing_sequence, raw_cpp_string, raw_python_string_opening_sequence, raw_python_string_closing_sequence, raw_python_string, } cur_state; state previous_state; void handle_string_parsed(tml::listener& listener); void process_char(char c, tml::listener& listener); void process_char_in_initial(char c, tml::listener& listener); void process_char_in_idle(char c, tml::listener& listener); void process_char_in_string_parsed(char c, tml::listener& listener); void process_char_in_unquoted_string(char c, tml::listener& listener); void process_char_in_quoted_string(char c, tml::listener& listener); void process_char_in_escape_sequence(char c, tml::listener& listener); void process_char_in_unicode_sequence(char c, tml::listener& listener); void process_char_in_comment_sequence(char c, tml::listener& listener); void process_char_in_single_line_comment(char c, tml::listener& listener); void process_char_in_multiline_comment(char c, tml::listener& listener); void process_char_in_raw_cpp_string_opening_sequence(char c, tml::listener& listener); void process_char_in_raw_cpp_string(char c, tml::listener& listener); void process_char_in_raw_cpp_string_closing_sequence(char c, tml::listener& listener); void process_char_in_raw_python_string_opening_sequence(char c, tml::listener& listener); void process_char_in_raw_python_string(char c, tml::listener& listener); void process_char_in_raw_python_string_closing_sequence(char c, tml::listener& listener); location cur_loc = {1, 1}; // offset starts with 1 void next_line(); extra_info info = { {}, tml::flag::first_on_line }; void set_string_start_pos(); public: /** * @brief Constructor. * Creates an initially reset Parser object. */ parser(){ this->reset(); } /** * @brief Reset parser. * Resets the parser to initial state, discarding all the temporary parsed data and state. */ void reset(); /** * @brief Parse chunk of treeml data. * Use this method to feed the treeml data to the parser. * @param chunk - data chunk to parse. * @param listener - listener object which will receive notifications about parsed tokens. */ void parse_data_chunk(utki::span<const char> chunk, listener& listener); void parse_data_chunk(utki::span<const uint8_t> chunk, listener& listener){ this->parse_data_chunk( utki::make_span( reinterpret_cast<const char*>(chunk.data()), chunk.size() ), listener ); } /** * @brief Finalize parsing. * Call this method to finalize parsing after all the available treeml data has been fed to the parser. * This will tell parser that there will be no more data and the temporary stored data should be interpreted as it is. * @param listener - listener object which will receive notifications about parsed tokens. */ void end_of_data(listener& listener); }; /** * @brief Parse treeml document provided by given file interface. * Use this function to parse the treeml document from file. * @param fi - file interface to use for getting the data to parse. * @param listener - listener object which will receive notifications about parsed tokens. */ void parse(const papki::file& fi, listener& listener); }
6,420
2,056
#include "apecs.hpp" #include <gtest/gtest.h> TEST(sparse_set, set_and_get) { apx::sparse_set<int> set; set.insert(2, 5); ASSERT_TRUE(set.has(2)); ASSERT_EQ(set[2], 5); } TEST(sparse_set, erase) { apx::sparse_set<int> set; set.insert(2, 5); ASSERT_TRUE(set.has(2)); set.erase(2); ASSERT_FALSE(set.has(2)); } TEST(sparse_set, fast_with_one_element) { apx::sparse_set<int> set; set.insert(2, 5); for (auto [key, value] : set.fast()) { ASSERT_EQ(key, 2); ASSERT_EQ(value, 5); } }
551
267
/** * \file imperative/src/impl/ops/utility.cpp * MegEngine is Licensed under the Apache License, Version 2.0 (the "License") * * Copyright (c) 2014-2021 Megvii Inc. All rights reserved. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include <queue> #include "megbrain/imperative/ops/autogen.h" #include "megbrain/imperative/ops/utility.h" #include "megbrain/imperative/ops/opr_attr.h" #include "megbrain/imperative/graph_cache.h" #include "megbrain/imperative/subgraph_detail.h" #include "megbrain/imperative/opr_utility.h" #include "megbrain/opr/utility.h" #include "megbrain/opr/tensor_gen.h" #include "megbrain/opr/tensor_manip.h" #include "megbrain/opr/io.h" #include "../op_trait.h" namespace mgb::imperative { MGB_DYN_TYPE_OBJ_FINAL_IMPL(GenericPyOp); OP_TRAIT_REG(GenericPyOp, GenericPyOp).fallback(); namespace { namespace fastpathcopy { auto apply_on_var_node( const OpDef& def, const VarNodeArray& inputs) { return inputs; } OP_TRAIT_REG(FastpathCopy,FastpathCopy) .apply_on_var_node(apply_on_var_node) .fallback(); }} // fastpathcopy namespace { namespace shape_infer { auto apply_on_physical_tensor( const OpDef& def, const SmallVector<TensorPtr>& inputs) { auto& op = def.cast_final_safe<ShapeInfer>(); size_t nr_inputs = inputs.size(); mgb_assert(nr_inputs > 0, "no inputs for ShapeInfer"); SmallVector<LogicalTensorDesc> input_descs; for (size_t i = 0; i < nr_inputs; ++i) { auto input = inputs[i]->get_value(); TensorLayout layout; layout.ndim = input.shape(0); for (size_t i = 0; i < layout.ndim; ++i) { layout[i] = input.ptr<int32_t>()[i]; } layout.dtype = op.dtypes[i]; layout.init_contiguous_stride(); input_descs.push_back({layout, op.devices[i]}); } auto [output_descs, valid] = OpDef::infer_output_attrs_fallible(*op.op, input_descs); mgb_assert(valid, "shape inference incomplete"); SmallVector<TensorPtr> outputs; for (auto&& output_desc: output_descs) { HostTensorND shape_tensor{output_desc.comp_node, {output_desc.layout.ndim}, dtype::Int32()}; for (size_t i = 0; i < output_desc.layout.ndim; ++i) { shape_tensor.ptr<int32_t>()[i] = output_desc.layout[i]; } auto output = Tensor::make(shape_tensor); outputs.push_back(output); } return outputs; } auto apply_on_var_node( const OpDef& def, const VarNodeArray& inputs) { auto& op = def.cast_final_safe<ShapeInfer>(); size_t nr_inputs = inputs.size(); VarNodeArray input_values, outputs; mgb_assert(nr_inputs > 0, "no inputs for ShapeInfer"); for (size_t i = 0; i < nr_inputs; ++i) { auto input_value = opr::Alloc::make(SymbolVar(inputs[i]), op.dtypes[i], {op.devices[i]}); input_values.push_back(input_value.node()); } auto output_values = OpDef::apply_on_var_node(*op.op, input_values); for (auto&& output_value: output_values) { outputs.push_back(opr::GetVarShape::make(output_value).node()); } return outputs; } auto infer_output_attrs_fallible( const OpDef& def, const SmallVector<LogicalTensorDesc>& input_descs) { auto& op = def.cast_final_safe<ShapeInfer>(); SmallVector<LogicalTensorDesc> input_shape_descs; size_t nr_inputs = op.devices.size(); mgb_assert(op.dtypes.size() == nr_inputs, "number of input devices and dtypes mismatch"); for (size_t i = 0; i < nr_inputs; ++i) { LogicalTensorDesc input_shape_desc; input_shape_desc.comp_node = op.devices[i]; input_shape_desc.layout.ndim = 0; input_shape_desc.layout.dtype = op.dtypes[i]; input_shape_descs.push_back(input_shape_desc); } auto [output_shape_descs, _] = OpDef::infer_output_attrs_fallible(*op.op, input_shape_descs); SmallVector<LogicalTensorDesc> output_descs; for (auto&& output_shape_desc: output_shape_descs) { LogicalTensorDesc output_desc; output_desc.comp_node = output_shape_desc.comp_node; output_desc.layout.ndim = 1; output_desc.layout.dtype = dtype::Int32(); output_descs.push_back(output_desc); } return std::make_tuple(output_descs, false); } auto props(const OpDef& def) { auto& op = def.cast_final_safe<ShapeInfer>(); return OpDef::props(*op.op); } auto make_name(const OpDef& def) { auto& op = def.cast_final_safe<ShapeInfer>(); MGB_MARK_USED_VAR(op); return ssprintf("ShapeInfer[%s]", op.op->make_name().c_str()); } auto hash(const OpDef& def) { auto& op = def.cast_final_safe<ShapeInfer>(); return op.op->hash(); } auto is_same_st(const OpDef& def, const OpDef& another) { if (!another.same_type<ShapeInfer>()) { return false; } auto& lhs = def.cast_final_safe<ShapeInfer>(); auto& rhs = another.cast_final_safe<ShapeInfer>(); if (!lhs.op->is_same(*rhs.op)) { return false; } return std::tie(lhs.devices, lhs.dtypes) == std::tie(rhs.devices, rhs.dtypes); } OP_TRAIT_REG(ShapeInfer,ShapeInfer) .apply_on_var_node(apply_on_var_node) .apply_on_physical_tensor(apply_on_physical_tensor) .infer_output_attrs_fallible(infer_output_attrs_fallible) .make_name(make_name) .props(props) .hash(hash) .is_same_st(is_same_st) .fallback(); }} MGB_DYN_TYPE_OBJ_FINAL_IMPL(ShapeInfer); namespace { namespace identity { auto apply_on_var_node( const OpDef& def, const VarNodeArray& inputs) { auto&& op = def.cast_final_safe<Identity>(); mgb_assert(inputs.size() == 1); OperatorNodeConfig config{op.make_name()}; return opr::Identity::make(inputs[0], config); } auto apply_on_physical_tensor( const OpDef& def, const SmallVector<TensorPtr>& inputs) { return SmallVector<TensorPtr>{inputs[0]}; } OP_TRAIT_REG(Identity, Identity) .apply_on_var_node(apply_on_var_node) .apply_on_physical_tensor(apply_on_physical_tensor) .fallback(); }} // identity namespace { namespace subgraph { EncodedSubgraph make_forward_graph(const OpDef& def, SmallVector<LogicalTensorDesc> inputs) { return EncodedSubgraph::make(*def.cast_final_safe<SubgraphOp>().graph); } EncodedSubgraph make_backward_graph( const OpDef& def, const SmallVector<LogicalTensorDesc>& inputs, const SmallVector<bool>& input_requires_grad, SmallVector<bool> output_has_grad) { auto& op = def.cast_final_safe<SubgraphOp>(); mgb_assert(output_has_grad.size() == op.output_grad_mask.size()); for (size_t i = 0; i < output_has_grad.size(); ++i) { if (!op.output_grad_mask[i]) { output_has_grad[i] = false; } } auto bgraph = subgraph_detail::make_backward_graph(def, inputs, input_requires_grad, output_has_grad); return EncodedSubgraph::make_single( SubgraphOp::make(op.name + "Grad", std::make_shared<Subgraph>(bgraph.graph)), bgraph.input_mask, bgraph.output_mask); } std::vector<std::pair<const char*, std::string>> props(const OpDef& def) { auto& op = def.cast_final_safe<SubgraphOp>(); return { {"name", op.name}, {"inputs", mgb::imperative::to_string(op.graph->inputs)}, {"exprs", mgb::imperative::to_string(op.graph->exprs)}, {"outputs", mgb::imperative::to_string(op.graph->outputs)}, }; } std::string make_name(const OpDef& def) { auto& op = def.cast_final_safe<SubgraphOp>(); if (op.name.empty()) { return "SubgraphOp"; } else { return op.name; } } auto hash(const OpDef& def) { auto& op = def.cast_final_safe<SubgraphOp>(); if (!op.graph_key) { return (size_t)reinterpret_cast<uintptr_t>(op.graph.get()); } return op.graph_key->hash(); } auto is_same_st(const OpDef& def, const OpDef& another) { if (!another.same_type<SubgraphOp>()) { return false; } auto& lhs = def.cast_final_safe<SubgraphOp>(); auto& rhs = another.cast_final_safe<SubgraphOp>(); auto has_graph_key = bool(lhs.graph_key); bool graph_same = false; if (has_graph_key) { graph_same = rhs.graph_key && lhs.graph_key->is_same(*rhs.graph_key); } else { graph_same = !rhs.graph_key && lhs.graph.get() == rhs.graph.get(); } return graph_same; } OP_TRAIT_REG(SubgraphOp, SubgraphOp) .make_forward_graph(make_forward_graph) .make_backward_graph(make_backward_graph) .props(props) .make_name(make_name) .hash(hash) .is_same_st(is_same_st) .fallback(); }} namespace { namespace compiled_op { struct DeviceMemoryAllocatorImpl: cg::DeviceMemoryAllocator { std::shared_ptr<OpDef> current_op; void alloc_static(ComputingGraph* graph, DeviceTensorStorage& dest, size_t size) override { mgb_assert(0, "alloc_static is not allowed in CompiledOp"); } void alloc_dynamic(VarNode* var, DeviceTensorStorage& dest, size_t size) override { auto comp_node = var->comp_node(); auto storage = current_op->allocate(comp_node, size); dest.reset(comp_node, size, storage); } }; struct ComputingGraphHolder { std::shared_ptr<ComputingGraph> graph; std::unique_ptr<cg::AsyncExecutable> executable; SmallVector<std::shared_ptr<DeviceTensorND>> inputs; SmallVector<std::shared_ptr<DeviceTensorND>> outputs; std::shared_ptr<DeviceMemoryAllocatorImpl> allocator; SmallVector<std::unique_ptr<CompNode::Event>> events; }; ComputingGraphHolder& get_computing_graph(std::shared_ptr<OpDef> compiled_op, SmallVector<LogicalTensorDesc> descs) { using ComputingGraphHolderCache = OpMethResultCache<std::queue<std::unique_ptr<ComputingGraphHolder>>>; thread_local ComputingGraphHolderCache cache; thread_local size_t nr_cg_holders = 0; ComputingGraphHolderCache::key_t cache_key = {compiled_op, descs}; auto& cg_holder_queue = cache[cache_key]; std::unique_ptr<ComputingGraphHolder> holder; if(!cg_holder_queue.empty()) { // pick one std::swap(cg_holder_queue.front(), holder); // check all events finished for (auto&& event: holder->events) { if (!event->finished()) { bool queue_limited = event->comp_node().contain_flag(CompNode::Flag::QUEUE_LIMITED); bool many_graph = cg_holder_queue.size() > 10; if (queue_limited || !many_graph) { std::swap(cg_holder_queue.front(), holder); break; } else { // graph limit mgb_log_debug("computing graph limit for compiled op exceeded, waiting for prev graph"); event->host_wait(); } } } if (holder) { cg_holder_queue.pop(); } } if (!holder) { // create new computing graph holder = std::make_unique<ComputingGraphHolder>(); auto& cg_holder = *holder; cg_holder.allocator = std::make_shared<DeviceMemoryAllocatorImpl>(); cg_holder.graph = ComputingGraph::make(); cg_holder.graph->options().force_dynamic_alloc = true; cg_holder.graph->options().async_exec_level = 0; cg_holder.graph->options().graph_opt_level = compiled_op->cast_final_safe<CompiledOp>().gopt_level; cg_holder.graph->options().enable_var_mem_defragment = false; cg_holder.graph->options().comp_seq_sync_device = false; // set allocator for DTR support cg_holder.graph->set_device_memory_allocator(cg_holder.allocator); VarNodeArray input_vars; for (auto&& desc: descs) { auto input_device_nd = std::make_shared<DeviceTensorND>(); input_device_nd->dtype(desc.layout.dtype); input_device_nd->comp_node(desc.comp_node); input_device_nd->resize(desc.layout); cg_holder.inputs.push_back(input_device_nd); auto callback = [input_device_nd]{ return *input_device_nd; }; auto* input_var = opr::InputCallback::make(*cg_holder.graph, callback, desc.comp_node, desc.layout.dtype, TensorShape())[0].node(); input_vars.push_back(input_var); } // forward to inner op auto output_vars = OpDef::apply_on_var_node(*compiled_op, input_vars); ComputingGraph::OutputSpec output_spec; size_t nr_outputs = output_vars.size(); for (size_t i = 0; i < nr_outputs; ++i) { auto* output_var = output_vars[i]; auto output_ptr = std::make_shared<DeviceTensorND>(); auto callback = [output_ptr](DeviceTensorND output){ output_ptr->reset(output.storage(), output.layout()); }; output_spec.push_back({output_var, callback}); cg_holder.outputs.push_back(output_ptr); } cg_holder.executable = cg_holder.graph->compile(output_spec); CompNode::UnorderedSet comp_nodes; for (auto&& output_var: output_vars) { comp_nodes.insert(output_var->comp_node()); } for (auto&& comp_node: comp_nodes) { cg_holder.events.push_back(comp_node.create_event()); cg_holder.events.back()->record(); } nr_cg_holders++; mgb_log_debug("add new computing graph for compiled op, now %zu graphs", nr_cg_holders); } cg_holder_queue.push(std::move(holder)); return *cg_holder_queue.back(); } auto apply_on_physical_tensor( const OpDef& def, const SmallVector<TensorPtr>& inputs) { SmallVector<LogicalTensorDesc> input_descs; for (auto&& input: inputs) { input_descs.push_back({input->layout(), input->comp_node()}); } size_t nr_inputs = inputs.size(); auto shared_def = const_cast<OpDef&>(def).shared_from_this(); auto& cg_holder = get_computing_graph(shared_def, input_descs); // wait for last execution cg_holder.executable->wait(); for (size_t i = 0; i < nr_inputs; ++i) { auto input_dev_tensor = inputs[i]->dev_tensor(); cg_holder.inputs[i]->reset(input_dev_tensor.storage(), input_dev_tensor.layout()); } cg_holder.allocator->current_op = shared_def; cg_holder.executable->execute(); for (auto&& event: cg_holder.events) { event->record(); } SmallVector<TensorPtr> outputs; for (auto input_nd: cg_holder.inputs) { *input_nd = {}; } for (auto output_nd: cg_holder.outputs) { outputs.push_back(Tensor::make(*output_nd)); *output_nd = {}; } cg_holder.executable->clear_device_memory(); cg_holder.allocator->current_op = nullptr; return outputs; } auto apply_on_var_node( const OpDef& def, const VarNodeArray& inputs) { auto& op = def.cast_final_safe<CompiledOp>(); op.op->set_scope(op.scope()); return OpDef::apply_on_var_node(*op.op, inputs); } auto infer_output_attrs_fallible( const OpDef& def, const SmallVector<LogicalTensorDesc>& input_descs) { return OpDef::infer_output_attrs_fallible(*def.cast_final_safe<CompiledOp>().op, input_descs); } auto props(const OpDef& def) { return OpDef::props(*def.cast_final_safe<CompiledOp>().op); } auto make_name(const OpDef& def) { auto& op = def.cast_final_safe<CompiledOp>(); MGB_MARK_USED_VAR(op); return ssprintf("CompiledOp[%s]", op.op->make_name().c_str()); } std::tuple<SmallVector<MemoryDesc>, SmallVector<MemoryDesc>> infer_output_mem_desc( const OpDef& def, const SmallVector<TensorPtr>& inputs_tensors, const SmallVector<MemoryDesc>& inputs_mems) { return {}; } EncodedSubgraph make_backward_graph( const OpDef& def, const SmallVector<LogicalTensorDesc>& inputs, const SmallVector<bool>& input_requires_grad, const SmallVector<bool>& output_has_grad) { auto& op = def.cast_final_safe<CompiledOp>(); auto backward_graph = OpDef::make_backward_graph(*op.op, inputs, input_requires_grad, output_has_grad); auto name = def.trait()->make_name(def); auto key = std::make_shared<BackwardOpKey>(); key->op = op.op; key->inputs = inputs; key->extras = {input_requires_grad, output_has_grad}; SmallVector<bool> grad_outputs_has_grad(backward_graph.graph.outputs.size(), true); std::shared_ptr<OpDef> bgraph_op; if (backward_graph.graph.is_single()) { bgraph_op = backward_graph.graph.as_single(); } else { bgraph_op = SubgraphOp::make( name + "Grad", std::make_shared<Subgraph>(backward_graph.graph), grad_outputs_has_grad, key); } auto compiled_op = CompiledOp::make(bgraph_op, op.gopt_level); auto encoded_graph = EncodedSubgraph::make_single(compiled_op, backward_graph.input_mask, backward_graph.output_mask); return encoded_graph; } auto hash(const OpDef& def) { auto& op = def.cast_final_safe<CompiledOp>(); return mgb::hash_pair_combine(op.op->hash(), op.gopt_level); } auto is_same_st(const OpDef& def, const OpDef& another) { if (!another.same_type<CompiledOp>()) { return false; } auto& lhs = def.cast_final_safe<CompiledOp>(); auto& rhs = another.cast_final_safe<CompiledOp>(); return lhs.op->is_same(*rhs.op) && lhs.gopt_level == rhs.gopt_level; } OP_TRAIT_REG(CompiledOp, CompiledOp) .apply_on_var_node(apply_on_var_node) .apply_on_physical_tensor(apply_on_physical_tensor) .infer_output_attrs_fallible(infer_output_attrs_fallible) .make_backward_graph(make_backward_graph) .make_name(make_name) .infer_output_mem_desc(infer_output_mem_desc) .props(props) .hash(hash) .is_same_st(is_same_st) .fallback(); }} MGB_DYN_TYPE_OBJ_FINAL_IMPL(UniqueKey); MGB_DYN_TYPE_OBJ_FINAL_IMPL(SubgraphOp); MGB_DYN_TYPE_OBJ_FINAL_IMPL(BackwardOpKey); MGB_DYN_TYPE_OBJ_FINAL_IMPL(CompiledOp); } // namespace mgb::imperative
18,186
6,349
#pragma once #include "headers.hpp" class Player : public Obstacle { public: bool active; std::string nickname; std::string ID; sf::IpAddress address; unsigned short port; unsigned short slot; float crosshair_distance; int speed; std::array<Item*, 6> items; Player(int map_size, int speed, std::string ID, sf::IpAddress address, unsigned short port, std::string nickname); void interact(); void fire(); void move(sf::Int16 x_, sf::Int16 y_); };
557
166
// -*- Mode: c++ -*- #pragma once #include "karabiner_virtual_hid_device.hpp" #include <IOKit/IOKitLib.h> namespace pqrs { class karabiner_virtual_hid_device_methods final { public: // VirtualHIDKeyboard static IOReturn initialize_virtual_hid_keyboard(mach_port_t connection, const karabiner_virtual_hid_device::properties::keyboard_initialization& properties) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::initialize_virtual_hid_keyboard), &properties, sizeof(properties), nullptr, 0); } static IOReturn terminate_virtual_hid_keyboard(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::terminate_virtual_hid_keyboard), nullptr, 0, nullptr, 0); } static IOReturn dispatch_keyboard_event(mach_port_t connection, const karabiner_virtual_hid_device::hid_event_service::keyboard_event& keyboard_event) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::dispatch_keyboard_event), &keyboard_event, sizeof(keyboard_event), nullptr, 0); } static IOReturn post_keyboard_input_report(mach_port_t connection, const karabiner_virtual_hid_device::hid_report::keyboard_input& report) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::post_keyboard_input_report), &report, sizeof(report), nullptr, 0); } static IOReturn reset_virtual_hid_keyboard(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::reset_virtual_hid_keyboard), nullptr, 0, nullptr, 0); } // VirtualHIDPointing static IOReturn initialize_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::initialize_virtual_hid_pointing), nullptr, 0, nullptr, 0); } static IOReturn terminate_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::terminate_virtual_hid_pointing), nullptr, 0, nullptr, 0); } static IOReturn post_pointing_input_report(mach_port_t connection, const karabiner_virtual_hid_device::hid_report::pointing_input& report) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::post_pointing_input_report), &report, sizeof(report), nullptr, 0); } static IOReturn reset_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::reset_virtual_hid_pointing), nullptr, 0, nullptr, 0); } }; }
3,919
1,114
/** ** Copyright (c) 2014 Illumina, Inc. ** ** This file is part of Illumina's Enhanced Artificial Genome Engine (EAGLE), ** covered by the "BSD 2-Clause License" (see accompanying LICENSE file) ** ** \description Declaration of the skeleton of all c++ programs. ** ** \author Mauricio Varea **/ #ifndef EAGLE_COMMON_PROGRAM_HH #define EAGLE_COMMON_PROGRAM_HH #include <string> #include <iostream> #include <fstream> #include <cstdlib> #include <limits> #include <typeinfo> #include <boost/program_options.hpp> #include <boost/noncopyable.hpp> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <boost/format.hpp> #include "common/Exceptions.hh" #include "common/Logger.hh" namespace eagle { namespace common { namespace bpo = boost::program_options; namespace bfs = boost::filesystem; typedef std::pair<bfs::path *, std::string> PathOption; struct ProgramInfo { ProgramInfo(std::string arg, unsigned int width) : tool(arg), toolName(tool.leaf().string()), project(EAGLE_NAME), version(EAGLE_VERSION), copyright(EAGLE_COPYRIGHT), optionsWidth(width) {} bfs::path tool; std::string toolName; std::string project; std::string version; std::string copyright; unsigned int optionsWidth; friend std::ostream& operator<< (std::ostream& os, ProgramInfo pi); }; std::string naiveDemangling(const char *type); /** ** Encapsulation of the processing of the command line options. ** ** TODO: add config file and environment options **/ class Options: boost::noncopyable { public: enum Action { RUN, HELP, VERSION, ABORT }; Options( bool anyOutput = true ); virtual ~Options() { } Action parse(int argc, char *argv[]); std::string usage(bool full = false) const; unsigned int width() const {return bpo::options_description::m_default_line_length;} protected: bpo::options_description parameters_; bpo::options_description namedOptions_; bpo::options_description unnamedOptions_; bpo::positional_options_description positionalOptions_; bpo::options_description general_; private: virtual std::string usagePrefix() const = 0; virtual std::string usageSuffix() const { return ""; } virtual void postProcess(bpo::variables_map &) { } }; class OptionsHelper : bpo::variables_map { public: OptionsHelper(bpo::variables_map vm) : bpo::variables_map(vm) {} void requiredOptions(std::vector<std::string> requiredOptionList); std::string mutuallyExclusiveOptions(std::vector<std::string> mutuallyExclusiveList); void inputPathsExist(); void outputFilesWriteable(); void outputDirsWriteable(); void addPathOptions(std::vector<bfs::path>& pathOptions, std::string label); void addPathOptions(bfs::path& pathOption, std::string label); void clearPathOptions() {pathOptions_.clear();} template<typename T> void inRange(std::pair<T,std::string> option, T minValue = std::numeric_limits<T>::min(), T maxValue = std::numeric_limits<T>::max()) { if( minValue > option.first || option.first >= maxValue ) { std::string t = naiveDemangling(typeid(T).name()); const boost::format message = boost::format("\n *** The '%s' option is out of range. Please specify a%s '%s' within [%s,%s)") % option.second % ((t[0] == 'a' || t[0] == 'e' || t[0] == 'i' || t[0] == 'o' || t[0] == 'u') ? "n" : "") % t % boost::lexical_cast<std::string>(minValue) % boost::lexical_cast<std::string>(maxValue); BOOST_THROW_EXCEPTION(InvalidOptionException(message.str())); } } private: std::vector<PathOption> pathOptions_; }; /** ** Unified behavior of all programs. **/ template<class O> void run(void(*callback)(const O &), int argc, char *argv[]) { #ifdef EAGLE_DEBUG_MODE std::cout << "Command-line invocation:\n "; for (int i = 0; i < argc; i++) { std::cout << std::string(argv[i]) << " "; } std::cout << std::endl; #endif try { O options; ProgramInfo info( std::string(argv[0]), options.width() ); const typename O::Action action = options.parse(argc, argv); if (O::RUN == action) { callback(options); } else { if (O::HELP == action || O::VERSION == action) { std::clog << info << std::endl; if (O::VERSION == action) exit(0); } std::clog << options.usage(O::HELP == action); exit(O::HELP != action); } } catch (const eagle::common::ExceptionData &exception) { std::clog << "Error: " << exception.getContext() << ": " << exception.getMessage() << std::endl; exit(1); } catch (const boost::exception &e) { std::clog << "Error: boost::exception: " << boost::diagnostic_information(e) << std::endl; exit(2); } catch (const std::bad_alloc &e) { std::clog << "memory allocation error: " << e.what() << std::endl; std::ifstream proc("/proc/self/status"); std::string s; while(std::getline(proc, s), !proc.fail()) { std::clog << "\t" << s << std::endl; } std::clog << "*** abandoned execution! ***" << std::endl; exit(3); } catch (const std::runtime_error &e) { std::clog << "runtime error: " << e.what() << std::endl; exit(4); } catch (const std::logic_error &e) { std::clog << "logic error: " << e.what() << std::endl; exit(5); } } } // namespace common } // namespace eagle #endif // EAGLE_COMMON_PROGRAM_HH
5,892
1,858
class cnstrct { file = "support\modules\rmm_cnstrct"; class functions { class create {}; class handler {}; class open {}; class refresh {}; class sell {}; class update {}; }; };
192
69
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 // <chrono> // class month; // constexpr month& operator--() noexcept; // constexpr month operator--(int) noexcept; #include <chrono> #include <type_traits> #include <cassert> #include "test_macros.h" template <typename M> constexpr bool testConstexpr() { M m1{10}; if (static_cast<unsigned>(--m1) != 9) return false; if (static_cast<unsigned>(m1--) != 9) return false; if (static_cast<unsigned>(m1) != 8) return false; return true; } int main(int, char**) { using month = std::chrono::month; ASSERT_NOEXCEPT(--(std::declval<month&>()) ); ASSERT_NOEXCEPT( (std::declval<month&>())--); ASSERT_SAME_TYPE(month , decltype( std::declval<month&>()--)); ASSERT_SAME_TYPE(month&, decltype(--std::declval<month&>() )); static_assert(testConstexpr<month>(), ""); for (unsigned i = 10; i <= 20; ++i) { month month(i); assert(static_cast<unsigned>(--month) == i - 1); assert(static_cast<unsigned>(month--) == i - 1); assert(static_cast<unsigned>(month) == i - 2); } return 0; }
1,498
540
#ifndef ACE_TIMEPROBE_T_CPP #define ACE_TIMEPROBE_T_CPP #include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined (ACE_COMPILE_TIMEPROBES) #include "ace/Timeprobe.h" #include "ace/High_Res_Timer.h" #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (u_long size) : timeprobes_ (0), lock_ (), max_size_ (size), current_size_ (0), report_buffer_full_ (0), allocator_ (0) { ACE_timeprobe_t *temp; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_*sizeof(ACE_timeprobe_t)), ACE_timeprobe_t, this->max_size_); //FUZZ: enable check_for_lack_ACE_OS this->timeprobes_ = temp; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>:: ACE_Timeprobe_Ex (ALLOCATOR *allocator, u_long size) : timeprobes_ (0), lock_ (), max_size_ (size), current_size_ (0), report_buffer_full_ (0), allocator_ (allocator) { ACE_timeprobe_t *temp = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_*sizeof(ACE_timeprobe_t)), ACE_timeprobe_t, this->max_size_); //FUZZ: enable check_for_lack_ACE_OS this->timeprobes_ = temp; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> &) { // // Stupid MSVC is forcing me to define this; please don't use it. // ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE_NOTSUP: %N, line %l\n"))); errno = ENOTSUP; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::~ACE_Timeprobe_Ex (void) { ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *) (this->timeprobes_), this->max_size_, this->allocator ()->free, ACE_timeprobe_t); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (u_long event) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->timeprobes_[this->current_size_].event_.event_number_ = event; this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::NUMBER; this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); ++this->current_size_; #if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) // wrap around to the beginning on overflow if (this->current_size_ >= this->max_size_) { this->current_size_ = 0; this->report_buffer_full_ = 1; } #endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ ACE_ASSERT (this->current_size_ < this->max_size_); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (const char *event) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->timeprobes_[this->current_size_].event_.event_description_ = event; this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::STRING; this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); ++this->current_size_; #if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) // wrap around to the beginning on overflow if (this->current_size_ >= this->max_size_) { this->current_size_ = 0; this->report_buffer_full_ = 1; } #endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ ACE_ASSERT (this->current_size_ < this->max_size_); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::reset (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->current_size_ = 0; this->report_buffer_full_ = 0; } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::increase_size (u_long size) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); if (size > this->max_size_) { ACE_timeprobe_t *temp = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_ * sizeof (ACE_timeprobe_t)), ACE_timeprobe_t, size); //FUZZ: enable check_for_lack_ACE_OS if (this->max_size_ > 0) { ACE_OS::memcpy (temp, this->timeprobes_, this->max_size_ * sizeof (ACE_timeprobe_t)); // Iterates over the array explicitly calling the destructor for // each probe instance, then deallocates the memory ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *)(this->timeprobes_), this->max_size_, this->allocator ()->free, ACE_timeprobe_t); } this->timeprobes_ = temp; this->max_size_ = size; } } template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (void) { return this->event_descriptions_; } template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sorted_event_descriptions (void) { return this->sorted_event_descriptions_; } template <class ACE_LOCK, class ALLOCATOR> ACE_timeprobe_t * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobes (void) { return this->timeprobes_; } template <class ACE_LOCK, class ALLOCATOR> ACE_LOCK & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::lock (void) { return this->lock_; } template <class ACE_LOCK, class ALLOCATOR> u_long ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::max_size (void) { return this->max_size_; } template <class ACE_LOCK, class ALLOCATOR> u_long ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::current_size (void) { return this->current_size_; } template <class ACE_LOCK, class ALLOCATOR> int ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (const char **descriptions, u_long minimum_id) { ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); ACE_Event_Descriptions events; events.descriptions_ = descriptions; events.minimum_id_ = minimum_id; this->event_descriptions_.insert (events); return 0; } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_times (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); // Sort the event descriptions this->sort_event_descriptions_i (); u_long size = this->report_buffer_full_ ? this->max_size_ : this->current_size_; ACELIB_DEBUG ((LM_DEBUG, "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", size)); if (size == 0) return; ACELIB_DEBUG ((LM_DEBUG, "\n%-50.50s %8.8s %13.13s\n\n", "Event", "thread", "usec")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); u_long i, j; // First element i = this->report_buffer_full_ ? this->current_size_ : 0; ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %13.13s\n", this->find_description_i (i), this->timeprobes_[i].thread_, "START")); if (size == 1) return; bool has_timestamp_inversion = false; j = i; i = (i + 1) % this->max_size_; do { // When reusing the same ACE_Timeprobe from multiple threads // with Linux on Intel SMP, it sometimes happens that the // recorded times go backward in time if they are recorded from // different threads (see bugzilla #2342). To obtain the // correct signed difference between consecutive recorded times, // one has to cast the time difference to an intermediate signed // integral type of the same size as ACE_hrtime_t. double time_difference = (ACE_INT64) (this->timeprobes_[i].time_ - this->timeprobes_[j].time_); if (time_difference < 0) has_timestamp_inversion = true; // Convert to microseconds. time_difference /= gsf; ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %14.3f\n", this->find_description_i (i), this->timeprobes_[i].thread_, time_difference)); j = i; i = (i + 1) % this->max_size_; } while (i != this->current_size_); static bool inversion_warning_printed = false; if (!inversion_warning_printed && has_timestamp_inversion) { inversion_warning_printed = true; ACELIB_DEBUG ((LM_DEBUG, "\nWARNING: The timestamps recorded by gethrtime() on" " this platform are\n" "not monotonic across different threads.\n")); } } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_absolute_times (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); // Sort the event descriptions this->sort_event_descriptions_i (); u_long size = this->report_buffer_full_ ? this->max_size_ : this->current_size_; ACELIB_DEBUG ((LM_DEBUG, "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", size)); if (size == 0) return; ACELIB_DEBUG ((LM_DEBUG, "\n%-50.50s %8.8s %13.13s\n\n", "Event", "thread", "stamp")); u_long i = this->report_buffer_full_ ? this->current_size_ : 0; ACE_Time_Value tv; // to convert ACE_hrtime_t do { ACE_High_Res_Timer::hrtime_to_tv (tv, this->timeprobes_ [i].time_); ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %12.12u\n", this->find_description_i (i), this->timeprobes_ [i].thread_, tv.sec () * 1000000 + tv.usec ())); // Modulus increment: loops around at the end. i = (i + 1) % this->max_size_; } while (i != this->current_size_); } template <class ACE_LOCK, class ALLOCATOR> const char * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::find_description_i (u_long i) { if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING) return this->timeprobes_[i].event_.event_description_; else { EVENT_DESCRIPTIONS::iterator iterator = this->sorted_event_descriptions_.begin (); for (u_long j = 0; j < this->sorted_event_descriptions_.size () - 1; iterator++, j++) { EVENT_DESCRIPTIONS::iterator next_event_descriptions = iterator; ++next_event_descriptions; if (this->timeprobes_[i].event_.event_number_ < (*next_event_descriptions).minimum_id_) break; } return (*iterator).descriptions_[this->timeprobes_[i].event_.event_number_ - (*iterator).minimum_id_]; } } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sort_event_descriptions_i (void) { size_t total_elements = this->event_descriptions_.size (); for (size_t i = 0; i < total_elements; i++) { EVENT_DESCRIPTIONS::iterator iterator = this->event_descriptions_.begin (); ACE_Event_Descriptions min_entry = *iterator; for (; iterator != this->event_descriptions_.end (); iterator++) if ((*iterator).minimum_id_ < min_entry.minimum_id_) min_entry = *iterator; this->sorted_event_descriptions_.insert (min_entry); this->event_descriptions_.remove (min_entry); } } template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::allocator (void) { return allocator_ ? allocator_ : ACE_Singleton<ALLOCATOR, ACE_LOCK>::instance (); } template <class Timeprobe> ACE_Function_Timeprobe<Timeprobe>::ACE_Function_Timeprobe (Timeprobe &timeprobe, u_long event) : timeprobe_ (timeprobe), event_ (event) { this->timeprobe_.timeprobe (this->event_); } template <class Timeprobe> ACE_Function_Timeprobe<Timeprobe>::~ACE_Function_Timeprobe (void) { this->timeprobe_.timeprobe (this->event_ + 1); } ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_COMPILE_TIMEPROBES */ #endif /* ACE_TIMEPROBE_T_CPP */
13,223
4,893
/* Copyright 2016 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. ==============================================================================*/ #include "tensorflow/core/lib/io/snappy/snappy_outputbuffer.h" namespace tensorflow { namespace io { SnappyOutputBuffer::SnappyOutputBuffer(WritableFile* file, int32_t input_buffer_bytes, int32_t output_buffer_bytes) : file_(file), input_buffer_(new char[input_buffer_bytes]), input_buffer_capacity_(input_buffer_bytes), next_in_(input_buffer_.get()), output_buffer_(new char[output_buffer_bytes]), output_buffer_capacity_(output_buffer_bytes), next_out_(output_buffer_.get()), avail_out_(output_buffer_bytes) {} SnappyOutputBuffer::~SnappyOutputBuffer() { size_t bytes_to_write = output_buffer_capacity_ - avail_out_; if (bytes_to_write > 0) { LOG(WARNING) << "There is still data in the output buffer. " << "Possible data loss has occurred."; } } Status SnappyOutputBuffer::Append(StringPiece data) { return Write(data); } #if defined(TF_CORD_SUPPORT) Status SnappyOutputBuffer::Append(const absl::Cord& cord) { for (absl::string_view fragment : cord.Chunks()) { TF_RETURN_IF_ERROR(Append(fragment)); } return OkStatus(); } #endif Status SnappyOutputBuffer::Close() { // Given that we do not own `file`, we don't close it. return Flush(); } Status SnappyOutputBuffer::Name(StringPiece* result) const { return file_->Name(result); } Status SnappyOutputBuffer::Sync() { TF_RETURN_IF_ERROR(Flush()); return file_->Sync(); } Status SnappyOutputBuffer::Tell(int64_t* position) { return file_->Tell(position); } Status SnappyOutputBuffer::Write(StringPiece data) { // // The deflated output is accumulated in output_buffer_ and gets written to // file as and when needed. size_t bytes_to_write = data.size(); // If there is sufficient free space in input_buffer_ to fit data we // add it there and return. if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) { AddToInputBuffer(data); return OkStatus(); } // If there isn't enough available space in the input_buffer_ we empty it // by uncompressing its contents. If data now fits in input_buffer_ // we add it there else we directly deflate it. TF_RETURN_IF_ERROR(DeflateBuffered()); // input_buffer_ should be empty at this point. if (static_cast<int32>(bytes_to_write) <= AvailableInputSpace()) { AddToInputBuffer(data); return OkStatus(); } // `data` is too large to fit in input buffer so we deflate it directly. // Note that at this point we have already deflated all existing input so // we do not need to backup next_in and avail_in. next_in_ = const_cast<char*>(data.data()); avail_in_ = bytes_to_write; TF_RETURN_IF_ERROR(Deflate()); DCHECK_EQ(avail_in_, 0); // All input will be used up. next_in_ = input_buffer_.get(); return OkStatus(); } Status SnappyOutputBuffer::Flush() { TF_RETURN_IF_ERROR(DeflateBuffered()); TF_RETURN_IF_ERROR(FlushOutputBufferToFile()); return OkStatus(); } int32 SnappyOutputBuffer::AvailableInputSpace() const { return input_buffer_capacity_ - avail_in_; } void SnappyOutputBuffer::AddToInputBuffer(StringPiece data) { size_t bytes_to_write = data.size(); DCHECK_LE(bytes_to_write, AvailableInputSpace()); // Input stream -> // [....................input_buffer_capacity_...............] // [<...read_bytes...><...avail_in...>......empty space......] // ^ ^ // | | // input_buffer_ next_in // // Data in the input stream is sharded as shown above. next_in_ could // be pointing to some byte in the buffer with avail_in number of bytes // available to be read. // // In order to avoid shifting the avail_in bytes at next_in to the head of // the buffer we try to fit `data` in the empty space at the tail of the // input stream. // TODO(srbs): This could be avoided if we had a circular buffer. // If it doesn't fit we free the space at the head of the stream and then // append `data` at the end of existing data. const int32_t read_bytes = next_in_ - input_buffer_.get(); const int32_t unread_bytes = avail_in_; const int32_t free_tail_bytes = input_buffer_capacity_ - (read_bytes + unread_bytes); if (static_cast<int32>(bytes_to_write) > free_tail_bytes) { memmove(input_buffer_.get(), next_in_, avail_in_); next_in_ = input_buffer_.get(); } memcpy(next_in_ + avail_in_, data.data(), bytes_to_write); avail_in_ += bytes_to_write; } Status SnappyOutputBuffer::AddToOutputBuffer(const char* data, size_t length) { while (length > 0) { size_t bytes_to_copy = std::min(length, avail_out_); memcpy(next_out_, data, bytes_to_copy); data += bytes_to_copy; next_out_ += bytes_to_copy; avail_out_ -= bytes_to_copy; length -= bytes_to_copy; if (avail_out_ == 0) { TF_RETURN_IF_ERROR(FlushOutputBufferToFile()); } } return OkStatus(); } Status SnappyOutputBuffer::DeflateBuffered() { TF_RETURN_IF_ERROR(Deflate()); DCHECK_EQ(avail_in_, 0); next_in_ = input_buffer_.get(); return OkStatus(); } Status SnappyOutputBuffer::FlushOutputBufferToFile() { size_t bytes_to_write = output_buffer_capacity_ - avail_out_; if (bytes_to_write > 0) { Status s = file_->Append(StringPiece( reinterpret_cast<char*>(output_buffer_.get()), bytes_to_write)); if (s.ok()) { next_out_ = output_buffer_.get(); avail_out_ = output_buffer_capacity_; } return s; } return OkStatus(); } Status SnappyOutputBuffer::Deflate() { if (avail_in_ == 0) { return OkStatus(); } string output; if (!port::Snappy_Compress(next_in_, avail_in_, &output)) { return errors::DataLoss("Snappy_Compress failed"); } // Write length of compressed block to output buffer. char compressed_length_array[4]; std::fill(compressed_length_array, compressed_length_array + 4, 0); for (int i = 0; i < 4; i++) { // Little endian. compressed_length_array[i] = output.size() >> (8 * (3 - i)); } TF_RETURN_IF_ERROR(AddToOutputBuffer(compressed_length_array, 4)); // Write compressed output to buffer. TF_RETURN_IF_ERROR(AddToOutputBuffer(output.data(), output.size())); next_in_ += avail_in_; avail_in_ = 0; return OkStatus(); } } // namespace io } // namespace tensorflow
7,000
2,350
#ifndef SPLIT_FLUXES_HPP #define SPLIT_FLUXES_HPP #include "point.hpp" void flux_Gyn(codi::RealReverse Gyn[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gyp(codi::RealReverse Gyp[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gxp(codi::RealReverse Gxp[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gxn(codi::RealReverse Gxn[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gx(codi::RealReverse Gx[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gy(codi::RealReverse Gy[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); #endif
1,124
469
#include "Axes.h" Axes::Axes(void){ anzVertex = 4; anzIndex = 6; indices = AxeIndices; vertices = AxeVertices; colors = AxeColor; } void Axes::render(){ glBindVertexArray(vao); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glDrawElements(GL_LINES,6,GL_UNSIGNED_INT,indices); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glBindVertexArray(0); } Axes::~Axes(void){ }
435
187
#include "models/filename.h" #include <QCollator> #include <QJSEngine> #include <QRegularExpression> #include <QSettings> #include <algorithm> #include "filename/ast/filename-node-variable.h" #include "filename/ast-filename.h" #include "filename/filename-cache.h" #include "filename/filename-execution-visitor.h" #include "functions.h" #include "loader/token.h" #include "models/api/api.h" #include "models/filtering/post-filter.h" #include "models/image.h" #include "models/profile.h" #include "models/site.h" Filename::Filename() : Filename("") {} Filename::Filename(QString format) : m_format(std::move(format)) { m_ast = FilenameCache::Get(m_format); } QList<Token> Filename::getReplace(const QString &key, const Token &token, QSettings *settings) const { QList<Token> ret; QStringList value = token.value().toStringList(); if (token.whatToDoDefault().isEmpty()) { ret.append(Token(value)); return ret; } settings->beginGroup("Save"); const QString sort = settings->value(key + "_sort", "original").toString(); if (sort == QLatin1String("name")) { value.sort(); } if (value.isEmpty()) { ret.append(Token(settings->value(key + "_empty", token.emptyDefault()).toString())); } else if (value.size() > settings->value(key + "_multiple_limit", 1).toInt()) { const QString &whatToDo = settings->value(key + "_multiple", token.whatToDoDefault()).toString(); if (whatToDo == QLatin1String("keepAll")) { ret.append(Token(value)); } else if (whatToDo == QLatin1String("multiple")) { ret.reserve(ret.count() + value.count()); for (const QString &val : value) { ret.append(Token(val)); } } else if (whatToDo == QLatin1String("keepN")) { const int keepN = settings->value(key + "_multiple_keepN", 1).toInt(); ret.append(Token(QStringList(value.mid(0, qMax(1, keepN))))); } else if (whatToDo == QLatin1String("keepNThenAdd")) { const int keepN = settings->value(key + "_multiple_keepNThenAdd_keep", 1).toInt(); QString thenAdd = settings->value(key + "_multiple_keepNThenAdd_add", " (+ %count%)").toString(); thenAdd.replace("%total%", QString::number(value.size())); thenAdd.replace("%count%", QString::number(value.size() - keepN)); QStringList keptValues = value.mid(0, qMax(1, keepN)); if (value.size() > keepN) { ret.append(Token(keptValues.join(' ') + thenAdd)); } else { ret.append(Token(keptValues)); } } else { ret.append(Token(settings->value(key + "_value", token.multipleDefault()).toString())); } } else { ret.append(Token(value)); } settings->endGroup(); return ret; } QList<QMap<QString, Token>> Filename::expandTokens(QMap<QString, Token> tokens, QSettings *settings) const { QList<QMap<QString, Token>> ret; ret.append(tokens); const bool isJavascript = m_format.startsWith(QLatin1String("javascript:")); for (const QString &key : tokens.keys()) { const Token &token = tokens[key]; if (token.value().type() != QVariant::StringList) { continue; } const bool hasToken = !isJavascript && m_ast->tokens().contains(key); const bool hasVar = isJavascript && m_format.contains(key); if (!hasToken && !hasVar) { continue; } QList<Token> reps = getReplace(key, token, settings); const int cnt = ret.count(); for (int i = 0; i < cnt; ++i) { ret[i].insert(key, reps[0]); for (int j = 1; j < reps.count(); ++j) { tokens = ret[i]; tokens.insert(key, reps[j]); ret.append(tokens); } } } return ret; } QStringList Filename::path(const Image &img, Profile *profile, const QString &pth, int counter, PathFlags flags) const { return path(img.tokens(profile), profile, pth, counter, flags); } QStringList Filename::path(QMap<QString, Token> tokens, Profile *profile, QString folder, int counter, PathFlags flags) const { QSettings *settings = profile->getSettings(); // Computed tokens tokens.insert("count", Token(counter)); tokens.insert("current_date", Token(QDateTime::currentDateTime())); // Conditional filenames if (flags.testFlag(PathFlag::ConditionalFilenames)) { QList<ConditionalFilename> filenames = getFilenames(settings); for (const auto &fn : filenames) { if (fn.matches(tokens, settings)) { if (!fn.path.isEmpty()) { folder = fn.path; } if (!fn.filename.format().isEmpty()) { return fn.filename.path(tokens, profile, folder, counter, flags & (~PathFlag::ConditionalFilenames)); } } } } QStringList fns; if (m_format.isEmpty()) { return fns; } // Expand tokens into multiple filenames QList<QMap<QString, Token>> replacesList = expandTokens(tokens, settings); for (const auto &replaces : replacesList) { FilenameExecutionVisitor executionVisitor(replaces, settings); executionVisitor.setEscapeMethod(m_escapeMethod); executionVisitor.setKeepInvalidTokens(flags.testFlag(PathFlag::KeepInvalidTokens)); // TODO(Bionus): PathFlag::ExpandConditionals QString cFilename = executionVisitor.run(*m_ast->ast()); // Something wrong happened (JavaScript error...) if (cFilename.isEmpty()) { continue; } // "num" special token QRegularExpression rxNum("%num(?::.+)?%"); auto numMatch = rxNum.match(cFilename); if (numMatch.hasMatch()) { FilenameParser parser(numMatch.captured()); FilenameNodeVariable *var = parser.parseVariable(); int num = 1; const QString hasNum = numMatch.captured(); const bool noExt = var->opts.contains("noext"); const int mid = QDir::toNativeSeparators(cFilename).lastIndexOf(QDir::separator()); QDir dir(folder + (mid >= 0 ? QDir::separator() + cFilename.left(mid) : QString())); const QString cRight = mid >= 0 ? cFilename.right(cFilename.length() - mid - 1) : cFilename; QString filter = QString(cRight).replace(hasNum, "*"); if (noExt) { const QString ext = replaces["ext"].toString(); if (filter.endsWith("." + ext)) { filter = filter.left(filter.length() - ext.length()) + "*"; } } QFileInfoList files = dir.entryInfoList(QStringList() << filter, QDir::Files, QDir::NoSort); if (!files.isEmpty()) { // Get last file QCollator collator; collator.setNumericMode(true); const QFileInfo highest = noExt ? *std::max_element( files.begin(), files.end(), [&collator](const QFileInfo &a, const QFileInfo &b) { return collator.compare(a.completeBaseName(), b.completeBaseName()) < 0; } ) : *std::max_element( files.begin(), files.end(), [&collator](const QFileInfo &a, const QFileInfo &b) { return collator.compare(a.fileName(), b.fileName()) < 0; } ); const QString last = highest.fileName(); const int pos = cRight.indexOf(hasNum); const int len = last.length() - cRight.length() + hasNum.length(); num = last.midRef(pos, len).toInt() + 1; } QString val = executionVisitor.variableToString(var->name, num, var->opts); cFilename.replace(numMatch.capturedStart(), numMatch.capturedLength(), val); } fns.append(cFilename); } const int cnt = fns.count(); for (int i = 0; i < cnt; ++i) { if (flags.testFlag(PathFlag::Fix)) { // Trim directory names fns[i] = fns[i].trimmed(); fns[i].replace(QRegularExpression(" */ *"), "/"); // Max filename size option const int limit = !flags.testFlag(PathFlag::CapLength) ? 0 : settings->value("Save/limit").toInt(); fns[i] = fixFilename(fns[i], folder, limit); } // Include directory in result if (flags.testFlag(PathFlag::IncludeFolder)) { fns[i] = folder + "/" + fns[i]; } if (flags.testFlag(PathFlag::Fix)) { // Native separators fns[i] = QDir::toNativeSeparators(fns[i]); // We remove empty directory names const QChar sep = QDir::separator(); fns[i].replace(QRegularExpression("(.)" + QRegularExpression::escape(sep) + "{2,}"), QString("\\1") + sep); } } return fns; } QString Filename::format() const { return m_format; } void Filename::setFormat(const QString &format) { m_format = format; m_ast = FilenameCache::Get(format); } void Filename::setEscapeMethod(QString (*escapeMethod)(const QVariant &)) { m_escapeMethod = escapeMethod; } bool Filename::returnError(const QString &msg, QString *error) const { if (error != nullptr) { *error = msg; } return false; } bool Filename::isValid(Profile *profile, QString *error) const { static const QString red = QStringLiteral("<span style=\"color:red\">%1</span>"); static const QString orange = QStringLiteral("<span style=\"color:orange\">%1</span>"); static const QString green = QStringLiteral("<span style=\"color:green\">%1</span>"); // Field must be filled if (m_format.isEmpty()) { return returnError(red.arg(QObject::tr("Filename must not be empty!")), error); } // Can't validate javascript expressions if (m_format.startsWith("javascript:")) { returnError(orange.arg(QObject::tr("Can't validate Javascript expressions.")), error); return true; } // Can't validate invalid grammar if (!m_ast->error().isEmpty()) { returnError(red.arg(QObject::tr("Can't compile your filename: %1").arg(m_ast->error())), error); } const auto &toks = m_ast->tokens(); // Field must end by an extension if (!m_format.endsWith(".%ext%")) { return returnError(orange.arg(QObject::tr("Your filename doesn't ends by an extension, symbolized by %ext%! You may not be able to open saved files.")), error); } // Field must contain an unique token if (!toks.contains("md5") && !toks.contains("id") && !toks.contains("num")) { return returnError(orange.arg(QObject::tr("Your filename is not unique to each image and an image may overwrite a previous one at saving! You should use%md5%, which is unique to each image, to avoid this inconvenience.")), error); } // Looking for unknown tokens QStringList tokens = QStringList() << "tags" << "artist" << "general" << "copyright" << "character" << "model" << "photo_set" << "species" << "meta" << "filename" << "rating" << "md5" << "website" << "websitename" << "ext" << "all" << "id" << "search" << "search_(\\d+)" << "allo" << "date" << "score" << "count" << "width" << "height" << "pool" << "url_file" << "url_page" << "num" << "name" << "position" << "current_date"; if (profile != nullptr) { tokens.append(profile->getAdditionalTokens()); tokens.append(getCustoms(profile->getSettings()).keys()); } static const QRegularExpression rx("%(.+?)%"); auto matches = rx.globalMatch(m_format); while (matches.hasNext()) { auto match = matches.next(); bool found = false; for (const QString &token : tokens) { if (QRegularExpression("%(?:gallery\\.)?" + token + "(?::[^%]+)?%").match(match.captured(0)).hasMatch()) { found = true; } } if (!found) { return returnError(orange.arg(QObject::tr("The %%1% token does not exist and will not be replaced.").arg(match.captured(1))), error); } } // Check for invalid windows characters #ifdef Q_OS_WIN QString txt = QString(m_format).remove(rx); if (txt.contains(':') || txt.contains('*') || txt.contains('?') || (txt.contains('"') && txt.count('<') == 0) || txt.count('<') != txt.count('>') || txt.contains('|')) { return returnError(red.arg(QObject::tr("Your format contains characters forbidden on Windows! Forbidden characters: * ? \" : < > |")), error); } #endif // Check if code is unique if (!toks.contains("md5") && !toks.contains("website") && !toks.contains("websitename") && !toks.contains("count") && toks.contains("id")) { return returnError(green.arg(QObject::tr("You have chosen to use the %id% token. Know that it is only unique for a selected site. The same ID can identify different images depending on the site.")), error); } // All tests passed returnError(green.arg(QObject::tr("Valid filename!")), error); return true; } bool Filename::needTemporaryFile(const QMap<QString, Token> &tokens) const { if (m_format.startsWith("javascript:")) { return false; } const auto &toks = m_ast->tokens(); return ( (toks.contains("md5") && (!tokens.contains("md5") || tokens["md5"].value().toString().isEmpty())) || (toks.contains("filesize") && (!tokens.contains("filesize") || tokens["filesize"].value().toInt() <= 0)) || (toks.contains("width") && (!tokens.contains("width") || tokens["width"].value().toInt() <= 0)) || (toks.contains("height") && (!tokens.contains("height") || tokens["height"].value().toInt() <= 0)) ); } int Filename::needExactTags(Site *site, const QString &api) const { Q_UNUSED(api); QStringList forcedTokens = site != nullptr ? site->getApis().first()->forcedTokens() : QStringList(); if (forcedTokens.contains("*")) { return 2; } return needExactTags(forcedTokens); } int Filename::needExactTags(const QStringList &forcedTokens) const { // Javascript filenames always need tags as we don't know what they might do if (m_format.startsWith("javascript:")) { return 2; } const auto &toks = m_ast->tokens(); // If we need the filename and it is returned from the details page if (toks.contains("filename") && forcedTokens.contains("filename")) { return 2; } // If we need the date and it is returned from the details page if (toks.contains("date") && forcedTokens.contains("date")) { return 2; } // The filename contains one of the special tags QStringList forbidden = QStringList() << "artist" << "copyright" << "character" << "model" << "photo_set" << "species" << "meta" << "general"; for (const QString &token : forbidden) { if (toks.contains(token)) { return 1; } } // Namespaces come from detailed tags if (m_format.contains("includenamespace")) { return 1; } return 0; }
13,540
4,996
// https://www.hackerrank.com/challenges/dijkstrashortreach #include "common/graph/graph_ei.h" #include "common/graph/graph_ei/distance_positive_cost.h" #include "common/stl/base.h" int main_dijkstra_shortest_reach_2() { unsigned T, max_cost = -1u; cin >> T; for (unsigned it = 0; it < T; ++it) { unsigned n, m, k; cin >> n >> m; UndirectedGraphEI<unsigned> g(n); g.ReadEdges(m); cin >> k; auto vd = DistanceFromSourcePositiveCost(g, k - 1, max_cost); for (unsigned i = 0; i < n; ++i) { if (i == k - 1) continue; cout << ((vd[i] == max_cost) ? -1 : int(vd[i])) << " "; } cout << endl; } return 0; }
659
279
#include <ros/ros.h> #include <simple_velocity_controller/controller_node.h> #include <tuw_nav_msgs/ControllerState.h> #include <tf/transform_datatypes.h> #define NSEC_2_SECS(A) ((float)A / 1000000000.0) int main(int argc, char** argv) { std::string name("pid_controller"); if (argc >= 2) { name = argv[1]; } ros::init(argc, argv, argv[1]); /// initializes the ros node with default name ros::NodeHandle n; velocity_controller::ControllerNode ctrl(n); return 0; } namespace velocity_controller { ControllerNode::ControllerNode(ros::NodeHandle& n) : Controller(), n_(n), n_param_("~") { max_vel_v_ = 0.8; n_param_.getParam("max_v", max_vel_v_); max_vel_w_ = 1.0; n_param_.getParam("max_w", max_vel_w_); setSpeedParams(max_vel_v_, max_vel_w_); goal_r_ = 0.2; n_param_.getParam("goal_radius", goal_r_); setGoalRadius(goal_r_); Kp_val_ = 5.0; n_param_.getParam("Kp", Kp_val_); Ki_val_ = 0.0; n_param_.getParam("Ki", Ki_val_); Kd_val_ = 1.0; n_param_.getParam("Kd", Kd_val_); setPID(Kp_val_, Ki_val_, Kd_val_); double loop_rate; n_param_.param<double>("loop_rate", loop_rate, 5); pubCmdVel_ = n.advertise<geometry_msgs::Twist>("cmd_vel", 1000); pubState_ = n.advertise<tuw_nav_msgs::ControllerState>("state_trajectory_ctrl", 10); subPose_ = n.subscribe("pose", 1000, &ControllerNode::subPoseCb, this); subPath_ = n.subscribe("path", 1000, &ControllerNode::subPathCb, this); subCtrl_ = n.subscribe("ctrl", 1000, &ControllerNode::subCtrlCb, this); ros::Rate r(loop_rate); while (ros::ok()) { ros::spinOnce(); publishState(); r.sleep(); } } void ControllerNode::subPoseCb(const geometry_msgs::PoseWithCovarianceStampedConstPtr &_pose) { PathPoint pt; pt.x = _pose->pose.pose.position.x; pt.y = _pose->pose.pose.position.y; tf::Quaternion q(_pose->pose.pose.orientation.x, _pose->pose.pose.orientation.y, _pose->pose.pose.orientation.z, _pose->pose.pose.orientation.w); tf::Matrix3x3 m(q); double roll, pitch, yaw; m.getRPY(roll, pitch, yaw); pt.theta = yaw; ros::Time time = ros::Time::now(); ros::Duration d = time - last_update_; float delta_t = d.sec + NSEC_2_SECS(d.nsec); update(pt, delta_t); float v, w; getSpeed(&v, &w); cmd_.linear.x = v; cmd_.angular.z = w; pubCmdVel_.publish(cmd_); } void ControllerNode::publishState() { ctrl_state_.header.stamp = ros::Time::now(); ctrl_state_.progress = getProgress(); if(isActive()) { ctrl_state_.state = ctrl_state_.STATE_DRIVING; } else { ctrl_state_.state = ctrl_state_.STATE_IDLE; } pubState_.publish(ctrl_state_); } void ControllerNode::subPathCb(const nav_msgs::Path_<std::allocator<void>>::ConstPtr& _path) { ctrl_state_.progress_in_relation_to = _path->header.seq; ctrl_state_.header.frame_id = _path->header.frame_id; if (_path->poses.size() == 0) return; // start at nearest point on path to pose // behavior controller resends full paths, therefore // it is important to start from the robots location float nearest_dist = std::numeric_limits<float>::max(); float dist = 0; auto it = _path->poses.begin(); bool changed = true; while (it != _path->poses.end() && changed) { dist = pow(current_pose_.x - it->pose.position.x, 2) + pow(current_pose_.y - it->pose.position.y, 2); if (dist < nearest_dist) { nearest_dist = dist; changed = true; it++; } else { changed = false; } } std::vector<PathPoint> path; for (; it != _path->poses.end(); ++it) { PathPoint pt; tf::Quaternion q(it->pose.orientation.x, it->pose.orientation.y, it->pose.orientation.z, it->pose.orientation.w); tf::Matrix3x3 m(q); double roll, pitch, yaw; m.getRPY(roll, pitch, yaw); pt.x = it->pose.position.x; pt.y = it->pose.position.y; pt.theta = yaw; path.push_back(pt); } setPath(std::make_shared<std::vector<PathPoint>>(path)); } void ControllerNode::subCtrlCb(const std_msgs::String _cmd) { std::string s = _cmd.data; ROS_INFO("Multi Robot Controller: received %s", s.c_str()); if (s.compare("run") == 0) { setState(run); } else if (s.compare("stop") == 0) { setState(stop); } else if (s.compare("step") == 0) { setState(step); } else { setState(run); } } }
4,428
1,795
#include "YamlParser.h" YamlParser::YamlParser() { } YamlParser::~YamlParser() { } void YamlParser::loadLaPredefinedPositions(std::string file) { std::cout << "YamlParser.->Trying to parse file: " << file << std::endl; nodeLaPredefined = YAML::LoadFile(file); } void YamlParser::loadRaPredefinedPositions(std::string file) { std::cout << "YamlParser.->Trying to parse file: " << file << std::endl; nodeRaPredefined = YAML::LoadFile(file); } void YamlParser::loadHdPredefinedPositions(std::string file) { std::cout << "YamlParser.->Trying to parse file: " << file << std::endl; nodeHdPredefined = YAML::LoadFile(file); }
649
236
#include "LookWhereYoureGoing.h" #include "Entity.h" LookWhereYoureGoing::LookWhereYoureGoing(EntityActor* character) :Align(character, nullptr) { } bool LookWhereYoureGoing::getSteering(SteeringOutput* output) { EntityActor target; m_pTarget = &target; auto velocity = vx::loadFloat4(&m_pCharacter->m_velocity); vx::float4a len = vx::length3(velocity); if (len.x == 0.0f) return false; auto vz = _mm_load_ss(&m_pCharacter->m_velocity.z); auto orientation = vx::atan2(velocity, vz); target.m_orientation.x = orientation.m128_f32[0];// -1.5f;//atan2(m_pCharacter->m_velocity.x, m_pCharacter->m_velocity.z) - 1.5f; output->angular = vx::scalarModAngle(target.m_orientation.x); //return Align::getSteering(output); return true; }
748
313
#include "rtt_interface.h" #include <string.h> #include <entry.h> #include "AP_Show.h" #include "AP_Buffer.h" extern vel_target vel; extern AP_Show* show; extern AP_Buffer* buffer; extern uint8_t key_value; extern ap_t mav_data; extern uint8_t mode_changed; extern int8_t car_mode; extern "C"{ char global_buf[4][16]; } rt_thread_t show_thread = RT_NULL; extern "C" void show_thread_entry(void* parameter) { char line[3][15]; char head[16]; char mode_page[16]; int8_t page_num = 0; uint8_t page_max = 2; while(1) { // Switch page if(key_value == 2 && page_num != 1){ page_num--; if(page_num < 0) page_num = 0; show->show_now(page_num); key_value = 0; } else if(key_value == 12){ page_num--; if(page_num < 0) page_num = 0; show->show_now(page_num); key_value = 0; } if(key_value == 1){ page_num++; if(page_num > page_max) page_num = page_max; show->show_now(page_num); key_value = 0; } // Show page show->show_page(page_num); // Page 0 sprintf (line[0], "vel_x:%.3f", vel.vel_x); sprintf (line[1], "vel_y:%.3f", vel.vel_y); sprintf (line[2], "rad_z:%.3f", vel.rad_z); for(uint8_t i=0; i<3; i++){ show->page_write(0, i, line[i], "rc output"); } // Page 1 sprintf(head, "%s \r\n", "key monitor"); show->page_write(1, 0, global_buf[0], head); show->page_write(1, 2, global_buf[2], head); if(key_value == 15){ memset(global_buf[2], 0, 16); } // Page 2 static int8_t prev_mode; char mode_name[6]; switch(mav_data.mode){ case 0:{ sprintf (mode_name, "%s", "Manual"); break; } case 1:{ sprintf (mode_name, "%s", "Auto"); break; } case 2:{ sprintf (mode_name, "%s", "ROS"); break; } } sprintf (mode_page, "Mode:%s", mode_name); show->page_write(2, 0, mode_page, "car mode"); if(page_num == 2){ switch(key_value){ case 3:{ car_mode++; if(car_mode > 2) car_mode = 2; break; } case 4:{ car_mode--; if(car_mode < 0) car_mode = 0; break; } default:{ break; } } if(prev_mode != car_mode){ mode_changed = 1; prev_mode = car_mode; } } // update screen rt_enter_critical(); show->update(); rt_exit_critical(); rt_thread_delay(500); } }
2,493
1,045
// // Created by kaiser on 2020/4/18. // #include <iostream> #include <string> #include <utility> int main() { // 当基于范围的 for 循环被用于一个具有写时复制语义的(非 // const)对象时, 它可能会通过(隐式)调用非 const 的 begin() // 成员函数触发深层复制 // 如果想要避免这种行为(比如循环实际上不会修改这个对象), 可以使用 // std::as_const // 假设是写时复制的字符串 std::string cow_string{"str"}; // for(auto x : str) { /* ... */ } // 可能会导致深层复制 for (auto c : std::as_const(cow_string)) { std::cout << c; } std::cout << '\n'; }
463
297
// // main.cpp // 114_flatten // // Created by Bella Yang on 2019/10/11. // Copyright © 2019 Bella Yang. All rights reserved. // #include <iostream> #include <vector> #include <stack> #include <queue> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; TreeNode* createTree(vector<int>& vec){ if (vec.empty()) { return NULL; } TreeNode* root = new TreeNode(vec[0]); TreeNode* parentNode = root; TreeNode* newNode; queue<TreeNode*> que; que.push(root); for (int i = 1; i < vec.size(); ++i) { if (vec[i] == NULL) { if (i% 2 == 0) { que.pop(); parentNode = que.front(); } continue; } newNode = new TreeNode(vec[i]); if (i % 2 == 1) { parentNode->left = newNode; que.push(newNode); }else{ parentNode->right = newNode; que.push(newNode); que.pop(); parentNode = que.front(); } } return root; } class Solution { public: void flatten(TreeNode* root) { if (!root || (!(root->left) && !(root->right))) { return; } stack<TreeNode*>subtree; if (root->right) { subtree.push(root->right); } if (root->left) { subtree.push(root->left); } TreeNode* node; TreeNode* p = root; while (!subtree.empty()) { node = subtree.top(); subtree.pop(); p->left = NULL; p->right = node; p = node; if (node->right) { subtree.push(node->right); } if (node->left) { subtree.push(node->left); } } } }; int main(int argc, const char * argv[]) { const int LEN = 7; int array[LEN] = {1,2,5,3,4,NULL,6}; vector<int> vec(array, array + LEN); Solution s; s.flatten(createTree(vec)); return 0; }
2,095
700
/* * Original work: Copyright (c) 2014, Oculus VR, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * RakNet License.txt file in the licenses directory of this source tree. An additional grant * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. */ #include "RPC3.h" #include "slikenet/memoryoverride.h" #include "slikenet/assert.h" #include "slikenet/StringCompressor.h" #include "slikenet/BitStream.h" #include "slikenet/peerinterface.h" #include "slikenet/MessageIdentifiers.h" #include "slikenet/NetworkIDManager.h" #include <stdlib.h> using namespace SLNet; // int RPC3::RemoteRPCFunctionComp( const RPC3::RPCIdentifier &key, const RemoteRPCFunction &data ) // { // return strcmp(key.C_String(), data.identifier.C_String()); // } int SLNet::RPC3::LocalSlotObjectComp( const LocalSlotObject &key, const LocalSlotObject &data ) { if (key.callPriority>data.callPriority) return -1; if (key.callPriority==data.callPriority) { if (key.registrationCount<data.registrationCount) return -1; if (key.registrationCount==data.registrationCount) return 0; return 1; } return 1; } RPC3::RPC3() { currentExecution[0]=0; networkIdManager=0; outgoingTimestamp=0; outgoingPriority=HIGH_PRIORITY; outgoingReliability=RELIABLE_ORDERED; outgoingOrderingChannel=0; outgoingBroadcast=true; incomingTimeStamp=0; nextSlotRegistrationCount=0; } RPC3::~RPC3() { Clear(); } void RPC3::SetNetworkIDManager(NetworkIDManager *idMan) { networkIdManager=idMan; } bool RPC3::UnregisterFunction(const char *uniqueIdentifier) { return false; } bool RPC3::IsFunctionRegistered(const char *uniqueIdentifier) { DataStructures::HashIndex i = GetLocalFunctionIndex(uniqueIdentifier); return i.IsInvalid()==false; } void RPC3::SetTimestamp(SLNet::Time timeStamp) { outgoingTimestamp=timeStamp; } void RPC3::SetSendParams(PacketPriority priority, PacketReliability reliability, char orderingChannel) { outgoingPriority=priority; outgoingReliability=reliability; outgoingOrderingChannel=orderingChannel; } void RPC3::SetRecipientAddress(const SystemAddress &systemAddress, bool broadcast) { outgoingSystemAddress=systemAddress; outgoingBroadcast=broadcast; } void RPC3::SetRecipientObject(NetworkID networkID) { outgoingNetworkID=networkID; } SLNet::Time RPC3::GetLastSenderTimestamp(void) const { return incomingTimeStamp; } SystemAddress RPC3::GetLastSenderAddress(void) const { return incomingSystemAddress; } RakPeerInterface *RPC3::GetRakPeer(void) const { return rakPeerInterface; } const char *RPC3::GetCurrentExecution(void) const { return (const char *) currentExecution; } bool RPC3::SendCallOrSignal(RakString uniqueIdentifier, char parameterCount, SLNet::BitStream *serializedParameters, bool isCall) { SystemAddress systemAddr; // unsigned int outerIndex; // unsigned int innerIndex; if (uniqueIdentifier.IsEmpty()) return false; SLNet::BitStream bs; if (outgoingTimestamp!=0) { bs.Write((MessageID)ID_TIMESTAMP); bs.Write(outgoingTimestamp); } bs.Write((MessageID)ID_RPC_PLUGIN); bs.Write(parameterCount); if (outgoingNetworkID!=UNASSIGNED_NETWORK_ID && isCall) { bs.Write(true); bs.Write(outgoingNetworkID); } else { bs.Write(false); } bs.Write(isCall); // This is so the call SetWriteOffset works bs.AlignWriteToByteBoundary(); BitSize_t writeOffset = bs.GetWriteOffset(); if (outgoingBroadcast) { unsigned systemIndex; for (systemIndex=0; systemIndex < rakPeerInterface->GetMaximumNumberOfPeers(); systemIndex++) { systemAddr=rakPeerInterface->GetSystemAddressFromIndex(systemIndex); if (systemAddr!= SLNet::UNASSIGNED_SYSTEM_ADDRESS && systemAddr!=outgoingSystemAddress) { // if (GetRemoteFunctionIndex(systemAddr, uniqueIdentifier, &outerIndex, &innerIndex, isCall)) // { // // Write a number to identify the function if possible, for faster lookup and less bandwidth // bs.Write(true); // if (isCall) // bs.WriteCompressed(remoteFunctions[outerIndex]->operator [](innerIndex).functionIndex); // else // bs.WriteCompressed(remoteSlots[outerIndex]->operator [](innerIndex).functionIndex); // } // else // { // bs.Write(false); StringCompressor::Instance()->EncodeString(uniqueIdentifier, 512, &bs, 0); // } bs.WriteCompressed(serializedParameters->GetNumberOfBitsUsed()); // serializedParameters->PrintBits(); bs.WriteAlignedBytes((const unsigned char*) serializedParameters->GetData(), serializedParameters->GetNumberOfBytesUsed()); SendUnified(&bs, outgoingPriority, outgoingReliability, outgoingOrderingChannel, systemAddr, false); // Start writing again after ID_AUTO_RPC_CALL bs.SetWriteOffset(writeOffset); } } } else { systemAddr = outgoingSystemAddress; if (systemAddr!= SLNet::UNASSIGNED_SYSTEM_ADDRESS) { // if (GetRemoteFunctionIndex(systemAddr, uniqueIdentifier, &outerIndex, &innerIndex, isCall)) // { // // Write a number to identify the function if possible, for faster lookup and less bandwidth // bs.Write(true); // if (isCall) // bs.WriteCompressed(remoteFunctions[outerIndex]->operator [](innerIndex).functionIndex); // else // bs.WriteCompressed(remoteSlots[outerIndex]->operator [](innerIndex).functionIndex); // } // else // { // bs.Write(false); StringCompressor::Instance()->EncodeString(uniqueIdentifier, 512, &bs, 0); // } bs.WriteCompressed(serializedParameters->GetNumberOfBitsUsed()); bs.WriteAlignedBytes((const unsigned char*) serializedParameters->GetData(), serializedParameters->GetNumberOfBytesUsed()); SendUnified(&bs, outgoingPriority, outgoingReliability, outgoingOrderingChannel, systemAddr, false); } else return false; } return true; } void RPC3::OnAttach(void) { outgoingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; outgoingNetworkID=UNASSIGNED_NETWORK_ID; incomingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; } PluginReceiveResult RPC3::OnReceive(Packet *packet) { SLNet::Time timestamp=0; unsigned char packetIdentifier, packetDataOffset; if ( ( unsigned char ) packet->data[ 0 ] == ID_TIMESTAMP ) { if ( packet->length > sizeof( unsigned char ) + sizeof(SLNet::Time ) ) { packetIdentifier = ( unsigned char ) packet->data[ sizeof( unsigned char ) + sizeof(SLNet::Time ) ]; // Required for proper endian swapping SLNet::BitStream tsBs(packet->data+sizeof(MessageID),packet->length-1,false); tsBs.Read(timestamp); packetDataOffset=sizeof( unsigned char )*2 + sizeof(SLNet::Time ); } else return RR_STOP_PROCESSING_AND_DEALLOCATE; } else { packetIdentifier = ( unsigned char ) packet->data[ 0 ]; packetDataOffset=sizeof( unsigned char ); } switch (packetIdentifier) { case ID_RPC_PLUGIN: incomingTimeStamp=timestamp; incomingSystemAddress=packet->systemAddress; OnRPC3Call(packet->systemAddress, packet->data+packetDataOffset, packet->length-packetDataOffset); return RR_STOP_PROCESSING_AND_DEALLOCATE; // case ID_AUTO_RPC_REMOTE_INDEX: // OnRPCRemoteIndex(packet->systemAddress, packet->data+packetDataOffset, packet->length-packetDataOffset); // return RR_STOP_PROCESSING_AND_DEALLOCATE; } return RR_CONTINUE_PROCESSING; } void RPC3::OnRPC3Call(const SystemAddress &systemAddress, unsigned char *data, unsigned int lengthInBytes) { SLNet::BitStream bs(data,lengthInBytes,false); DataStructures::HashIndex functionIndex; LocalRPCFunction *lrpcf; bool hasParameterCount=false; char parameterCount; NetworkIDObject *networkIdObject; NetworkID networkId; bool hasNetworkId=false; // bool hasFunctionIndex=false; // unsigned int functionIndex; BitSize_t bitsOnStack; char strIdentifier[512]; incomingExtraData.Reset(); bs.Read(parameterCount); bs.Read(hasNetworkId); if (hasNetworkId) { bool readSuccess = bs.Read(networkId); RakAssert(readSuccess); RakAssert(networkId!=UNASSIGNED_NETWORK_ID); if (networkIdManager==0) { // Failed - Tried to call object member, however, networkIDManager system was never registered SendError(systemAddress, RPC_ERROR_NETWORK_ID_MANAGER_UNAVAILABLE, ""); return; } networkIdObject = networkIdManager->GET_OBJECT_FROM_ID<NetworkIDObject*>(networkId); if (networkIdObject==0) { // Failed - Tried to call object member, object does not exist (deleted?) SendError(systemAddress, RPC_ERROR_OBJECT_DOES_NOT_EXIST, ""); return; } } else { networkIdObject=0; } bool isCall; bs.Read(isCall); bs.AlignReadToByteBoundary(); // bs.Read(hasFunctionIndex); // if (hasFunctionIndex) // bs.ReadCompressed(functionIndex); // else StringCompressor::Instance()->DecodeString(strIdentifier,512,&bs,0); bs.ReadCompressed(bitsOnStack); SLNet::BitStream serializedParameters; if (bitsOnStack>0) { serializedParameters.AddBitsAndReallocate(bitsOnStack); // BITS_TO_BYTES is correct, why did I change this? bs.ReadAlignedBytes(serializedParameters.GetData(), BITS_TO_BYTES(bitsOnStack)); serializedParameters.SetWriteOffset(bitsOnStack); } // if (hasFunctionIndex) // { // if ( // (isCall==true && functionIndex>localFunctions.Size()) || // (isCall==false && functionIndex>localSlots.Size()) // ) // { // // Failed - other system specified a totally invalid index // // Possible causes: Bugs, attempts to crash the system, requested function not registered // SendError(systemAddress, RPC_ERROR_FUNCTION_INDEX_OUT_OF_RANGE, ""); // return; // } // } // else { // Find the registered function with this str if (isCall) { // for (functionIndex=0; functionIndex < localFunctions.Size(); functionIndex++) // { // bool isObjectMember = boost::fusion::get<0>(localFunctions[functionIndex].functionPointer); // // boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<0>(localFunctions[functionIndex].functionPointer); // // if (isObjectMember == (networkIdObject!=0) && // strcmp(localFunctions[functionIndex].identifier.C_String(), strIdentifier)==0) // { // // SEND RPC MAPPING // SLNet::BitStream outgoingBitstream; // outgoingBitstream.Write((MessageID)ID_AUTO_RPC_REMOTE_INDEX); // outgoingBitstream.Write(hasNetworkId); // outgoingBitstream.WriteCompressed(functionIndex); // StringCompressor::Instance()->EncodeString(strIdentifier,512,&outgoingBitstream,0); // outgoingBitstream.Write(isCall); // SendUnified(&outgoingBitstream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemAddress, false); // break; // } // } functionIndex = localFunctions.GetIndexOf(strIdentifier); if (functionIndex.IsInvalid()) { SendError(systemAddress, RPC_ERROR_FUNCTION_NOT_REGISTERED, strIdentifier); return; } lrpcf = localFunctions.ItemAtIndex(functionIndex); bool isObjectMember = boost::fusion::get<0>(lrpcf->functionPointer); if (isObjectMember==true && networkIdObject==0) { // Failed - Calling C++ function as C function SendError(systemAddress, RPC_ERROR_CALLING_CPP_AS_C, strIdentifier); return; } if (isObjectMember==false && networkIdObject!=0) { // Failed - Calling C function as C++ function SendError(systemAddress, RPC_ERROR_CALLING_C_AS_CPP, strIdentifier); return; } } else { functionIndex = localSlots.GetIndexOf(strIdentifier); if (functionIndex.IsInvalid()) { SendError(systemAddress, RPC_ERROR_FUNCTION_NOT_REGISTERED, strIdentifier); return; } } } if (isCall) { bool isObjectMember = boost::fusion::get<0>(lrpcf->functionPointer); boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<1>(lrpcf->functionPointer); // int arity = boost::fusion::get<2>(localFunctions[functionIndex].functionPointer); // if (isObjectMember) // arity--; // this pointer if (functionPtr==0) { // Failed - Function was previously registered, but isn't registered any longer SendError(systemAddress, RPC_ERROR_FUNCTION_NO_LONGER_REGISTERED, strIdentifier); return; } // Boost doesn't support this for class members // if (arity!=parameterCount) // { // // Failed - The number of parameters that this function has was explicitly specified, and does not match up. // SendError(systemAddress, RPC_ERROR_INCORRECT_NUMBER_OF_PARAMETERS, localFunctions[functionIndex].identifier); // return; // } _RPC3::InvokeArgs functionArgs; functionArgs.bitStream=&serializedParameters; functionArgs.networkIDManager=networkIdManager; functionArgs.caller=this; functionArgs.thisPtr=networkIdObject; // serializedParameters.PrintBits(); _RPC3::InvokeResultCodes res2 = functionPtr(functionArgs); } else { InvokeSignal(functionIndex, &serializedParameters, false); } } void RPC3::InterruptSignal(void) { interruptSignal=true; } void RPC3::InvokeSignal(DataStructures::HashIndex functionIndex, SLNet::BitStream *serializedParameters, bool temporarilySetUSA) { if (functionIndex.IsInvalid()) return; SystemAddress lastIncomingAddress=incomingSystemAddress; if (temporarilySetUSA) incomingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; interruptSignal=false; LocalSlot *localSlot = localSlots.ItemAtIndex(functionIndex); unsigned int i; _RPC3::InvokeArgs functionArgs; functionArgs.bitStream=serializedParameters; functionArgs.networkIDManager=networkIdManager; functionArgs.caller=this; i=0; while (i < localSlot->slotObjects.Size()) { if (localSlot->slotObjects[i].associatedObject!=UNASSIGNED_NETWORK_ID) { functionArgs.thisPtr = networkIdManager->GET_OBJECT_FROM_ID<NetworkIDObject*>(localSlot->slotObjects[i].associatedObject); if (functionArgs.thisPtr==0) { localSlot->slotObjects.RemoveAtIndex(i); continue; } } else functionArgs.thisPtr=0; functionArgs.bitStream->ResetReadPointer(); bool isObjectMember = boost::fusion::get<0>(localSlot->slotObjects[i].functionPointer); boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<1>(localSlot->slotObjects[i].functionPointer); if (functionPtr==0) { if (temporarilySetUSA==false) { // Failed - Function was previously registered, but isn't registered any longer SendError(lastIncomingAddress, RPC_ERROR_FUNCTION_NO_LONGER_REGISTERED, localSlots.KeyAtIndex(functionIndex).C_String()); } return; } _RPC3::InvokeResultCodes res2 = functionPtr(functionArgs); // Not threadsafe if (interruptSignal==true) break; i++; } if (temporarilySetUSA) incomingSystemAddress=lastIncomingAddress; } // void RPC3::OnRPCRemoteIndex(const SystemAddress &systemAddress, unsigned char *data, unsigned int lengthInBytes) // { // // A remote system has given us their internal index for a particular function. // // Store it and use it from now on, to save bandwidth and search time // bool objectExists; // RakString strIdentifier; // unsigned int insertionIndex; // unsigned int remoteIndex; // RemoteRPCFunction newRemoteFunction; // SLNet::BitStream bs(data,lengthInBytes,false); // RPCIdentifier identifier; // bool isObjectMember; // bool isCall; // bs.Read(isObjectMember); // bs.ReadCompressed(remoteIndex); // bs.Read(strIdentifier); // bs.Read(isCall); // // if (strIdentifier.IsEmpty()) // return; // // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList; // if ( // (isCall==true && remoteFunctions.Has(systemAddress)) || // (isCall==false && remoteSlots.Has(systemAddress)) // ) // { // if (isCall==true) // theList = remoteFunctions.Get(systemAddress); // else // theList = remoteSlots.Get(systemAddress); // insertionIndex=theList->GetIndexFromKey(identifier, &objectExists); // if (objectExists==false) // { // newRemoteFunction.functionIndex=remoteIndex; // newRemoteFunction.identifier = strIdentifier; // theList->InsertAtIndex(newRemoteFunction, insertionIndex, _FILE_AND_LINE_ ); // } // } // else // { // theList = SLNet::OP_NEW<DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> >(_FILE_AND_LINE_); // // newRemoteFunction.functionIndex=remoteIndex; // newRemoteFunction.identifier = strIdentifier; // theList->InsertAtEnd(newRemoteFunction, _FILE_AND_LINE_ ); // // if (isCall==true) // remoteFunctions.SetNew(systemAddress,theList); // else // remoteSlots.SetNew(systemAddress,theList); // } // } void RPC3::OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ) { // if (remoteFunctions.Has(systemAddress)) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions.Get(systemAddress); // delete theList; // remoteFunctions.Delete(systemAddress); // } // // if (remoteSlots.Has(systemAddress)) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots.Get(systemAddress); // delete theList; // remoteSlots.Delete(systemAddress); // } } void RPC3::OnShutdown(void) { // Not needed, and if the user calls Shutdown inadvertantly, it unregisters his functions // Clear(); } void RPC3::Clear(void) { unsigned j; // for (j=0; j < remoteFunctions.Size(); j++) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions[j]; // SLNet::OP_DELETE(theList,_FILE_AND_LINE_); // } // for (j=0; j < remoteSlots.Size(); j++) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots[j]; // SLNet::OP_DELETE(theList,_FILE_AND_LINE_); // } DataStructures::List<SLNet::RakString> keyList; DataStructures::List<LocalSlot*> outputList; localSlots.GetAsList(outputList,keyList,_FILE_AND_LINE_); for (j=0; j < outputList.Size(); j++) { SLNet::OP_DELETE(outputList[j],_FILE_AND_LINE_); } localSlots.Clear(_FILE_AND_LINE_); DataStructures::List<LocalRPCFunction*> outputList2; localFunctions.GetAsList(outputList2,keyList,_FILE_AND_LINE_); for (j=0; j < outputList2.Size(); j++) { SLNet::OP_DELETE(outputList2[j],_FILE_AND_LINE_); } localFunctions.Clear(_FILE_AND_LINE_); // remoteFunctions.Clear(); // remoteSlots.Clear(); outgoingExtraData.Reset(); incomingExtraData.Reset(); } void RPC3::SendError(SystemAddress target, unsigned char errorCode, const char *functionName) { SLNet::BitStream bs; bs.Write((MessageID)ID_RPC_REMOTE_ERROR); bs.Write(errorCode); bs.WriteAlignedBytes((const unsigned char*) functionName,(const unsigned int) strlen(functionName)+1); SendUnified(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, target, false); } // bool RPC3::GetRemoteFunctionIndex(const SystemAddress &systemAddress, RPC3::RPCIdentifier identifier, unsigned int *outerIndex, unsigned int *innerIndex, bool isCall) // { // bool objectExists=false; // if (isCall) // { // if (remoteFunctions.Has(systemAddress)) // { // *outerIndex = remoteFunctions.GetIndexAtKey(systemAddress); // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions[*outerIndex]; // *innerIndex = theList->GetIndexFromKey(identifier, &objectExists); // } // } // else // { // if (remoteSlots.Has(systemAddress)) // { // *outerIndex = remoteFunctions.GetIndexAtKey(systemAddress); // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots[*outerIndex]; // *innerIndex = theList->GetIndexFromKey(identifier, &objectExists); // } // } // return objectExists; // } DataStructures::HashIndex RPC3::GetLocalSlotIndex(const char *sharedIdentifier) { return localSlots.GetIndexOf(sharedIdentifier); } DataStructures::HashIndex RPC3::GetLocalFunctionIndex(RPC3::RPCIdentifier identifier) { return localFunctions.GetIndexOf(identifier.C_String()); }
20,363
7,563
#include "staticcube.h" namespace edan { namespace graphics{ StaticCube::StaticCube(float x, float y, float z, float sideLength, const math::vec4 &color, Shader &shader) : Renderable3D(math::vec3(x, y, 0), sideLength, color), m_Shader(shader) { m_VertexArray = new VertexArray(); GLfloat vertices[] = { 0, 0, sideLength, sideLength, 0, sideLength, sideLength, sideLength, sideLength, 0, sideLength, sideLength, 0, 0, 0, sideLength, 0, 0, sideLength, sideLength, 0, 0, sideLength, 0 }; GLfloat normals[] = { -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f }; GLfloat colors[] = { color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w }; m_VertexArray->addBuffer(new Buffer(vertices, 8 * 3, 3), 0); m_VertexArray->addBuffer(new Buffer(colors, 8 * 4, 4), 1); m_VertexArray->addBuffer(new Buffer(normals, 8 * 3, 3), 2); GLushort indices[] = { 0, 1, 2, 2, 3, 0, 3, 2, 6, 6, 7, 3, 7, 6, 5, 5, 4, 7, 4, 0, 3, 3, 7, 4, 0, 1, 5, 5, 4, 0, 1, 5, 6, 6, 2, 1 }; m_IndexBuffer = new IndexBuffer(indices, 36); } StaticCube::~StaticCube() { delete m_VertexArray; delete m_IndexBuffer; } } }
1,617
939
// Problem Code: 228A #include <iostream> #include <vector> #include <set> using namespace std; int is_your_horseshoe_on_the_other_hoof(vector<int>& s) { set<int> seen(s.begin(), s.end()); return s.size() - seen.size(); } int main() { vector<int> s(4); for (int& x: s) cin >> x; cout << is_your_horseshoe_on_the_other_hoof(s); return 0; }
351
161
/* Copyright (C) 2018 Quaternion Risk Management Ltd All rights reserved. This file is part of ORE, a free-software/open-source library for transparent pricing and risk analysis - http://opensourcerisk.org ORE is free software: you can redistribute it and/or modify it under the terms of the Modified BSD License. You should have received a copy of the license along with this program. The license is also available online at <http://opensourcerisk.org> This program is distributed on the basis that it will form a useful contribution to risk analytics and model standardisation, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file qle/termstructures/yoyoptionletvolatilitysurface.hpp \brief YoY Inflation volatility surface - extends QuantLib YoYOptionletVolatilitySurface to include a volatility type and displacement \ingroup termstructures */ #ifndef quantext_yoy_optionlet_volatility_surface_hpp #define quantext_yoy_optionlet_volatility_surface_hpp #include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp> #include <ql/termstructures/volatility/volatilitytype.hpp> namespace QuantExt { using namespace QuantLib; //! YoY Inflation volatility surface /*! \ingroup termstructures */ class YoYOptionletVolatilitySurface : public QuantLib::TermStructure { public: //! \name Constructor //! calculate the reference date based on the global evaluation date YoYOptionletVolatilitySurface(boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> referenceVolSurface, VolatilityType volType = ShiftedLognormal, Real displacement = 0.0) : TermStructure(), referenceVolSurface_(referenceVolSurface), volType_(volType), displacement_(displacement) { referenceVolSurface->enableExtrapolation(); } Volatility volatility(const Date& maturityDate, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; Volatility volatility(const Period& optionTenor, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Volatility totalVariance(const Date& exerciseDate, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Volatility totalVariance(const Period& optionTenor, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Period observationLag() const { return referenceVolSurface_->observationLag(); } virtual Frequency frequency() const { return referenceVolSurface_->frequency(); } virtual bool indexIsInterpolated() const { return referenceVolSurface_->indexIsInterpolated(); } virtual Date baseDate() const { return referenceVolSurface_->baseDate(); } virtual Time timeFromBase(const Date& date, const Period& obsLag = Period(-1, Days)) const { return referenceVolSurface_->timeFromBase(date, obsLag); } virtual Date maxDate() const { return referenceVolSurface_->maxDate(); } virtual Real minStrike() const { return referenceVolSurface_->minStrike(); } virtual Real maxStrike() const { return referenceVolSurface_->maxStrike(); } virtual VolatilityType volatilityType() const; virtual Real displacement() const; virtual Volatility baseLevel() const { return referenceVolSurface_->baseLevel(); } boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> yoyVolSurface() const { return referenceVolSurface_; } protected: boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> referenceVolSurface_; VolatilityType volType_; Real displacement_; Rate minStrike_, maxStrike_; }; inline Volatility YoYOptionletVolatilitySurface::volatility(const Date& maturityDate, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->volatility(maturityDate, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::volatility(const Period& optionTenor, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->volatility(optionTenor, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::totalVariance(const Date& exerciseDate, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->totalVariance(exerciseDate, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::totalVariance(const Period& optionTenor, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->totalVariance(optionTenor, strike, obsLag, extrapolate); } inline VolatilityType YoYOptionletVolatilitySurface::volatilityType() const { return volType_; } inline Real YoYOptionletVolatilitySurface::displacement() const { return displacement_; } } // namespace QuantExt #endif
5,334
1,503
#pragma once #include <string> namespace easy2d { using string = std::string; } // -- easy2d
98
35
// Copyright (c) 2018 Hartmut Kaiser // // 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) // Fixing #509: Empty list defined inside Phylanx function has an issue #include <phylanx/phylanx.hpp> #include <hpx/hpx_main.hpp> #include <hpx/include/iostreams.hpp> #include <hpx/util/lightweight_test.hpp> #include <string> #include <sstream> std::string const hstack = "block(hstack())"; std::string const vstack = "block(vstack())"; int main(int argc, char* argv[]) { auto arg = phylanx::ir::node_data<double>{41.0}; phylanx::execution_tree::compiler::function_list snippets; auto const& hstack_f_code = phylanx::execution_tree::compile(hstack, snippets); auto hstack_f = hstack_f_code.run(); auto hstack_data = phylanx::execution_tree::extract_numeric_value(hstack_f(arg, arg)); HPX_TEST(hstack_data.num_dimensions() == 1); HPX_TEST(hstack_data.dimension(0) == 0); HPX_TEST(hstack_data.size() == 0); auto const& vstack_f_code = phylanx::execution_tree::compile(vstack, snippets); auto vstack_f = vstack_f_code.run(); auto vstack_data = phylanx::execution_tree::extract_numeric_value(vstack_f(arg, arg)); HPX_TEST(vstack_data.num_dimensions() == 2); HPX_TEST(vstack_data.dimension(0) == 0); HPX_TEST(vstack_data.dimension(1) == 1); HPX_TEST(vstack_data.size() == 0); return hpx::util::report_errors(); }
1,517
598
/* Description : Given a pointer/ reference to the node which is to be deleted from the linked list of N number nodes. The task is to delete the node. Pointer/ reference to head node is not given. */ #include <bitset/stdc++.h> using namespace std; struct Node { int data; struct Node *next; Node(int x) { data = x; next = NULL; } } * head; // function used to search the data which is given by user Node *search_node(Node *head, int search_for_data) { Node *current = head; while (current != NULL) { // if data found then break if (current->data == search_for_data) { break; } current = current->next; } return current; } //function used for the inserting the data into the tree. void insert_node() { // n= number of nodes in tree int n, i, value; Node *temp; cout << "Enter the number of nodes : " << endl; scanf("%d", &n); cout << "Enter the data : " << endl; for (i = 0; i < n; i++) { scanf("%d", &value); if (i == 0) { head = new Node(value); temp = head; continue; } else { temp->next = new Node(value); temp = temp->next; temp->next = NULL; } } } // function used for the printing the data of the tree void print_tree(Node *node) { while (node != NULL) { cout << node->data << " "; node = node->next; } cout << endl; } // another class class Solution { public: // function used to delete the data given by user // head pointer is not given // reference given of the node to be deleted void to_delete_node(Node *del) { if (del->next == NULL) { return; } Node *temp_1 = del->next; del->data = temp_1->data; del->next = del->next->next; delete (temp_1); } }; int main() { // k = storing data to be deleted int k; insert_node(); cout << "Enter data to delete : " << endl; scanf("%d", &k); Node *del = search_node(head, k); Solution obj; //deleting the given data by user if (del != NULL && del->next != NULL) { obj.to_delete_node(del); } cout << "Tree after deleting " << k << " : " << endl; print_tree(head); return 0; } /* Time complexity : O(n) Space complexity : O(n) */ /* Test Case : Input : Enter the number of nodes : 4 Enter the data : 1 2 3 4 Enter data to delete : 3 Output : Tree after deleting 3 : 1 2 4 */
2,678
851
/* Copyright (c) 2014-2016, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/resolve_links.hpp" #include "libtorrent/torrent_info.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" #include <boost/shared_ptr.hpp> #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS resolve_links::resolve_links(const boost::shared_ptr<torrent_info>& ti) : m_torrent_file(ti) { TORRENT_ASSERT(ti); int piece_size = ti->piece_length(); file_storage const& fs = ti->files(); m_file_sizes.reserve(fs.num_files()); for (int i = 0; i < fs.num_files(); ++i) { // don't match pad-files, and don't match files that aren't aligned to // ieces. Files are matched by comparing piece hashes, so pieces must // be aligned and the same size if (fs.pad_file_at(i)) continue; if ((fs.file_offset(i) % piece_size) != 0) continue; m_file_sizes.insert(std::make_pair(fs.file_size(i), i)); } m_links.resize(m_torrent_file->num_files()); } void resolve_links::match(boost::shared_ptr<const torrent_info> const& ti , std::string const& save_path) { if (!ti) return; if (!ti->is_valid()) return; // only torrents with the same if (ti->piece_length() != m_torrent_file->piece_length()) return; int piece_size = ti->piece_length(); file_storage const& fs = ti->files(); m_file_sizes.reserve(fs.num_files()); for (int i = 0; i < fs.num_files(); ++i) { // for every file in the other torrent, see if we have one that match // it in m_torrent_file // if the file base is not aligned to pieces, we're not going to match // it anyway (we only compare piece hashes) if ((fs.file_offset(i) % piece_size) != 0) continue; if (fs.pad_file_at(i)) continue; boost::int64_t file_size = fs.file_size(i); typedef boost::unordered_multimap<boost::int64_t, int>::iterator iterator; typedef std::pair<iterator, iterator> range_iterator; range_iterator range = m_file_sizes.equal_range(file_size); for (iterator iter = range.first; iter != range.second; ++iter) { TORRENT_ASSERT(iter->second < m_torrent_file->files().num_files()); TORRENT_ASSERT(iter->second >= 0); // if we already have found a duplicate for this file, no need // to keep looking if (m_links[iter->second].ti) continue; // files are aligned and have the same size, now start comparing // piece hashes, to see if the files are identical // the pieces of the incoming file int their_piece = fs.map_file(i, 0, 0).piece; // the pieces of "this" file (from m_torrent_file) int our_piece = m_torrent_file->files().map_file( iter->second, 0, 0).piece; int num_pieces = (file_size + piece_size - 1) / piece_size; bool match = true; for (int p = 0; p < num_pieces; ++p, ++their_piece, ++our_piece) { if (m_torrent_file->hash_for_piece(our_piece) != ti->hash_for_piece(their_piece)) { match = false; break; } } if (!match) continue; m_links[iter->second].ti = ti; m_links[iter->second].save_path = save_path; m_links[iter->second].file_idx = i; // since we have a duplicate for this file, we may as well remove // it from the file-size map, so we won't find it again. m_file_sizes.erase(iter); break; } } } #endif // TORRENT_DISABLE_MUTABLE_TORRENTS } // namespace libtorrent
4,803
1,845
#include "ApprovalTests.v.10.0.0.hpp"
37
20
/** * \file src/opr/test/dnn/local.cpp * MegEngine is Licensed under the Apache License, Version 2.0 (the "License") * * Copyright (c) 2014-2020 Megvii Inc. All rights reserved. * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ #include "./legacy_checker.h" #include "megbrain/opr/dnn/local.h" #include "megbrain/test/autocheck.h" using namespace mgb; namespace { using Param = opr::Local::Param; using Mode = Param::Mode; Mode modes_to_check[] = {Mode::CONVOLUTION, Mode::CROSS_CORRELATION}; void local_brute(const std::vector<std::shared_ptr<HostTensorND>> &in_tensor, std::shared_ptr<HostTensorND> &out_tensor, const Param &param) { ASSERT_EQ(2u, in_tensor.size()); auto in = in_tensor[0], filter = in_tensor[1]; ASSERT_EQ(4u, in->shape().ndim); ASSERT_EQ(6u, filter->shape().ndim); int batch_size = in->shape().shape[0]; int ic = in->shape().shape[1]; int ih = in->shape().shape[2]; int iw = in->shape().shape[3]; int fh = filter->shape().shape[3]; int fw = filter->shape().shape[4]; int ph = param.pad_h; int pw = param.pad_w; int sh = param.stride_h; int sw = param.stride_w; ASSERT_GE(ih + 2*ph, fh); ASSERT_GE(iw + 2*pw, fw); int oh = (ih + 2*ph - fh) / sh + 1; int ow = (iw + 2*pw - fw) / sw + 1; ASSERT_EQ(static_cast<size_t>(ic), filter->shape().shape[2]); int oc = filter->shape().shape[5]; out_tensor = std::make_shared<HostTensorND>(CompNode::load("xpu0"), TensorShape{ static_cast<size_t>(batch_size), static_cast<size_t>(oc), static_cast<size_t>(oh), static_cast<size_t>(ow)}); int pn, poc, poh, pow, pih, piw, pic, pfh, pfw; for (pn = 0; pn < batch_size; ++pn) for (poc = 0; poc < oc; ++poc) for (poh = 0, pih = -ph; poh < oh; ++poh, pih += sh) for (pow = 0, piw = -pw; pow < ow; ++pow, piw += sw) { float &target = out_tensor->ptr<float>({ static_cast<size_t>(pn), static_cast<size_t>(poc), static_cast<size_t>(poh), static_cast<size_t>(pow)})[0]; target = 0; for (pic = 0; pic < ic; ++pic) for (pfh = 0; pfh < fh; ++pfh) for (pfw = 0; pfw < fw; ++pfw) { int prih, priw; float img_data, filter_data; if (param.mode == Param::Mode::CONVOLUTION) { prih = pih + fh - pfh - 1; priw = piw + fw - pfw - 1; } else { mgb_assert(param.mode == Param::Mode::CROSS_CORRELATION); prih = pih + pfh; priw = piw + pfw; } if (prih >= 0 && prih < ih && priw >= 0 && priw < iw) { img_data = in_tensor[0]->ptr<float>({ static_cast<size_t>(pn), static_cast<size_t>(pic), static_cast<size_t>(prih), static_cast<size_t>(priw)})[0]; } else { img_data = 0; } filter_data = filter->ptr<float>({ static_cast<size_t>(poh), static_cast<size_t>(pow), static_cast<size_t>(pic), static_cast<size_t>(pfh), static_cast<size_t>(pfw), static_cast<size_t>(poc)})[0]; target += img_data * filter_data; } } } } // anonymous namespace TEST(TestOprDNN, LocalForward) { uint32_t ih = 10, ic = 16, oc = 32, ph = 0, sh = 1, fh = 2; for (auto mode: modes_to_check) { uint32_t iw = ih, fw = fh, pw = ph, sw = sh; uint32_t oh = (ih+2*ph-fh)/sh+1, ow = (iw+2*pw-fw)/sw+1; Param param{mode, ph, pw, sh, sw}; size_t batch_size = 32; opr::test::ForwardChecker<opr::Local, 2> forward_checker({ {batch_size, ic, ih, iw}, {oh, ow, ic, fh, fw, oc}}, local_brute, param); forward_checker.run(); } } TEST(TestOprDNN, LocalBackward) { uint32_t ih = 10, ic = 16, oc = 32, ph = 0, sh = 1, fh = 2; uint32_t iw = ih, fw = fh, pw = ph, sw = sh; uint32_t oh = (ih+2*ph-fh)/sh+1, ow = (iw+2*pw-fw)/sw+1; Param param{Mode::CROSS_CORRELATION, ph, pw, sh, sw}; size_t batch_size = 32; opr::test::BackwardChecker<opr::Local, 2> backward_checker({ {batch_size, ic, ih, iw}, {oh, ow, ic, fh, fw, oc}}, param, 1e-2, 1); backward_checker.run(); } TEST(TestOprDNN, GroupLocal) { using Checker = AutoOprChecker<2, 1>; opr::GroupLocal::Param param; auto make_graph = [&]( const Checker::SymInpArray &inputs) -> Checker::SymOutArray { return {opr::GroupLocal::make(inputs[0], inputs[1], param)}; }; auto fwd = [&](Checker::NumOutArray &dest, Checker::NumInpArray inp) { auto &&out = dest[0]; auto inp0 = std::make_shared<HostTensorND>(), inp1 = std::make_shared<HostTensorND>(); auto sl = inp[0]->layout(), fl = inp[1]->layout().remove_axis(0); TensorLayout ol; auto group = inp[1]->layout()[0]; sl.shape[1] /= group; for (size_t i = 0; i < group; ++ i) { inp0->copy_from(inp[0]->sub(SubTensorSpec::make_from_offset_elem( sl, i * sl[1] * sl[2] * sl[3]))); inp1->copy_from(inp[1]->sub(SubTensorSpec::make_from_offset_elem( fl, i * fl.total_nr_elems()))); std::shared_ptr<HostTensorND> cur_out; local_brute({inp0, inp1}, cur_out, {}); if (!i) { auto oshp = cur_out->shape(); oshp[1] *= group; out.resize(oshp); ol = out.layout(); ol[1] /= group; } out.sub(SubTensorSpec::make_from_offset_elem( ol, i * ol[1] * ol[2] * ol[3])).copy_from_fixlayout( *cur_out); } }; Checker::RunOptions opt; opt.numdiff_eps = 1; opt.outputs_max_err = 5e-5; Checker checker{make_graph, fwd}; auto run = [&](const TensorShape &ishp, size_t fs, size_t oc, size_t group) { size_t ic = ishp[1], ih = ishp[2], iw = ishp[3]; TensorShape flt{group, ih-fs+1, iw-fs+1, ic/group, fs, fs, oc/group}; checker.run({ishp, flt}, opt); }; run({32, 9, 2, 2}, 1, 96, 3); run({32, 4, 2, 3}, 2, 32, 2); run({32, 3, 4, 3}, 3, 16, 1); } // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
6,800
2,637
#pragma once #include <immintrin.h> struct v4sf; struct v8sf; struct v2df; struct v4df; struct v4sf { typedef float _v4sf __attribute__((vector_size(16))) __attribute__((aligned(16))); _v4sf val; static int getVectorLength() { return 4; } v4sf(const v4sf & rhs) : val(rhs.val) {} v4sf operator = (const v4sf rhs) { val = rhs.val; return (*this); } v4sf() : val(_mm_setzero_ps()) {} v4sf(const float x) : val(_mm_set_ps(x, x, x, x)) {} v4sf(const float x, const float y, const float z, const float w) : val(_mm_set_ps(w, z, y, x)) {} v4sf(const _v4sf _val) : val(_val) {} operator _v4sf() {return val;} v4sf operator + (const v4sf rhs) const { return v4sf(val + rhs.val); } v4sf operator - (const v4sf rhs) const { return v4sf(val - rhs.val); } v4sf operator * (const v4sf rhs) const { return v4sf(val * rhs.val); } v4sf operator / (const v4sf rhs) const { return v4sf(_mm_div_ps(val, rhs.val)); } static v4sf madd(const v4sf c, const v4sf a, const v4sf b) { return v4sf(_mm_fmadd_ps(a.val, b.val, c.val)); } static v4sf nmadd(const v4sf c, const v4sf a, const v4sf b) { return v4sf(_mm_fnmadd_ps(a.val, b.val, c.val)); } v4sf operator += (const v4sf rhs) { val = val + rhs.val; return (*this); } v4sf operator -= (const v4sf rhs) { val = val - rhs.val; return (*this); } v4sf operator *= (const v4sf rhs) { val = val * rhs.val; return (*this); } v4sf operator /= (const v4sf rhs) { val = _mm_div_ps(val, rhs.val); return (*this); } v4df cvtps2pd(); static v4sf rcp_0th(const v4sf rhs) { return _mm_rcp_ps(rhs.val); } static v4sf rcp_1st(const v4sf rhs) { v4sf x0 = _mm_rcp_ps(rhs.val); v4sf h = v4sf(1.) - rhs * x0; return x0 + h * x0; } static v4sf sqrt(const v4sf rhs) { return v4sf(_mm_sqrt_ps(rhs.val)); } static v4sf rsqrt_0th(const v4sf rhs) { return v4sf(_mm_rsqrt_ps(rhs.val)); } static v4sf rsqrt_1st(const v4sf rhs) { v4sf x0 = v4sf(_mm_rsqrt_ps(rhs.val)); v4sf h = v4sf(1.) - rhs * x0 * x0; return x0 + v4sf(0.5) * h * x0; } static v4sf rsqrt_1st_phantom(const v4sf rhs) { v4sf x0 = v4sf(_mm_rsqrt_ps(rhs.val)); return v4sf(x0 * (rhs * x0 * x0 - v4sf(3.))); } void store(float *p) const { _mm_store_ps(p, val); } void load(float const *p) { val = _mm_load_ps(p); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n") const { int vl = getVectorLength(); float a[vl]; store(a); fprintf(fp, fmt, a[0], a[1], a[2], a[3]); } }; struct v8sf { typedef float _v8sf __attribute__((vector_size(32))) __attribute__((aligned(32))); _v8sf val; static int getVectorLength() { return 8; } v8sf(const v8sf & rhs) : val(rhs.val) {} v8sf operator = (const v8sf rhs) { val = rhs.val; return (*this); } v8sf() : val(_mm256_setzero_ps()) {} v8sf(const float x) : val(_mm256_set_ps(x, x, x, x, x, x, x, x)) {} v8sf(const float x0, const float y0, const float z0, const float w0, const float x1, const float y1, const float z1, const float w1) : val(_mm256_set_ps(w1, z1, y1, x1, w0, z0, y0, x0)) {} v8sf(const _v8sf _val) : val(_val) {} operator _v8sf() {return val;} v8sf(const v4sf rhs) { float buf[8]; rhs.store(&buf[0]); rhs.store(&buf[4]); load(buf); } v8sf(const v4sf x0, const v4sf x1) { float buf[8]; x0.store(&buf[0]); x1.store(&buf[4]); load(buf); } v8sf operator + (const v8sf rhs) const { //return v8sf(_mm256_add_ps(val, rhs.val)); return val + rhs.val; } v8sf operator - (const v8sf rhs) const { //return v8sf(_mm256_sub_ps(val, rhs.val)); return val - rhs.val; } v8sf operator * (const v8sf rhs) const { //return v8sf(_mm256_mul_ps(val, rhs.val)); return val * rhs.val; } v8sf operator / (const v8sf rhs) const { return v8sf(_mm256_div_ps(val, rhs.val)); } static v8sf madd(const v8sf c, const v8sf a, const v8sf b) { return v8sf(_mm256_fmadd_ps(a.val, b.val, c.val)); } static v8sf nmadd(const v8sf c, const v8sf a, const v8sf b) { return v8sf(_mm256_fnmadd_ps(a.val, b.val, c.val)); } static v8sf max(const v8sf a, const v8sf b) { return v8sf(_mm256_max_ps(a.val, b.val)); } static v8sf min(const v8sf a, const v8sf b) { return v8sf(_mm256_min_ps(a.val, b.val)); } v8sf operator += (const v8sf rhs) { //val = _mm256_add_ps(val, rhs.val); val = val + rhs.val; return (*this); } v8sf operator -= (const v8sf rhs) { //val = _mm256_sub_ps(val, rhs.val); val = val - rhs.val; return (*this); } v8sf operator *= (const v8sf rhs) { //val = _mm256_mul_ps(val, rhs.val); val = val * rhs.val; return (*this); } v8sf operator /= (const v8sf rhs) { val = _mm256_div_ps(val, rhs.val); return (*this); } v8sf operator & (const v8sf rhs) { return v8sf(_mm256_and_ps(val, rhs.val)); } v8sf operator != (const v8sf rhs) { return v8sf(_mm256_cmp_ps(val, rhs.val, _CMP_NEQ_UQ)); } v8sf operator < (const v8sf rhs) { return v8sf(_mm256_cmp_ps(val, rhs.val, _CMP_LT_OS)); } static v8sf rcp_0th(const v8sf rhs) { return _mm256_rcp_ps(rhs.val); } static v8sf rcp_1st(const v8sf rhs) { v8sf x0 = _mm256_rcp_ps(rhs.val); v8sf h = v8sf(1.) - rhs * x0; return x0 + h * x0; } static v8sf sqrt(const v8sf rhs) { return v8sf(_mm256_sqrt_ps(rhs.val)); } static v8sf rsqrt_0th(const v8sf rhs) { return v8sf(_mm256_rsqrt_ps(rhs.val)); } static v8sf rsqrt_1st(const v8sf rhs) { v8sf x0 = v8sf(_mm256_rsqrt_ps(rhs.val)); v8sf h = v8sf(1.) - rhs * x0 * x0; return x0 + v8sf(0.5) * h * x0; } static v8sf rsqrt_1st_phantom(const v8sf rhs) { v8sf x0 = v8sf(_mm256_rsqrt_ps(rhs.val)); return v8sf(x0 * (rhs * x0 * x0 - v8sf(3.))); } static v8sf hadd(v8sf x0, v8sf x1) { return _mm256_hadd_ps(x0, x1); } void store(float *p) const { _mm256_store_ps(p, val); } void load(float const *p) { val = _mm256_load_ps(p); } void cvtpd2ps(v4df & x0, v4df & x1); void extractf128(v4sf & x0, v4sf & x1) { x0 = _mm256_extractf128_ps(val, 0); x1 = _mm256_extractf128_ps(val, 1); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n%+e %+e %+e %+e\n\n") const { int vl = getVectorLength(); float a[vl]; store(a); fprintf(fp, fmt, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); } static v8sf shuffle0(v8sf rhs) { return _mm256_permute_ps(rhs, 0x00); } static v8sf shuffle1(v8sf rhs) { return _mm256_permute_ps(rhs, 0x55); } static v8sf shuffle2(v8sf rhs) { return _mm256_permute_ps(rhs, 0xaa); } static v8sf shuffle3(v8sf rhs) { return _mm256_permute_ps(rhs, 0xff); } static v4sf reduce(const v8sf rhs) { int nv = getVectorLength(); float buf[nv]; rhs.store(buf); v4sf x0(buf[0], buf[1], buf[2], buf[3]); v4sf x1(buf[4], buf[5], buf[6], buf[7]); return v4sf(x0 + x1); } }; struct v2df { typedef double _v2df __attribute__((vector_size(16))) __attribute__((aligned(16))); _v2df val; static int getVectorLength() { return 2; } v2df(const v2df & rhs) : val(rhs.val) {} v2df operator = (const v2df rhs) { val = rhs.val; return (*this); } v2df() : val(_mm_setzero_pd()) {} v2df(const double x) : val(_mm_set_pd(x, x)) {} v2df(const double x, const double y) : val(_mm_set_pd(y, x)) {} v2df(const _v2df _val) : val(_val) {} operator _v2df() {return val;} v2df operator + (const v2df rhs) const { //return v2df(_mm_add_pd(val, rhs.val)); return val + rhs.val; } v2df operator - (const v2df rhs) const { //return v2df(_mm_sub_pd(val, rhs.val)); return val - rhs.val; } v2df operator * (const v2df rhs) const { //return v2df(_mm_mul_pd(val, rhs.val)); return val * rhs.val; } v2df operator / (const v2df rhs) const { return v2df(_mm_div_pd(val, rhs.val)); } static v2df madd(const v2df c, const v2df a, const v2df b) { return v2df(_mm_fmadd_pd(a.val, b.val, c.val)); } static v2df nmadd(const v2df c, const v2df a, const v2df b) { return v2df(_mm_fnmadd_pd(a.val, b.val, c.val)); } static v2df max(const v2df a, const v2df b) { return v2df(_mm_max_pd(a.val, b.val)); } static v2df min(const v2df a, const v2df b) { return v2df(_mm_min_pd(a.val, b.val)); } v2df operator += (const v2df rhs) { //val = _mm_add_pd(val, rhs.val); val = val + rhs.val; return (*this); } v2df operator -= (const v2df rhs) { //val = _mm_sub_pd(val, rhs.val); val = val - rhs.val; return (*this); } v2df operator *= (const v2df rhs) { //val = _mm_mul_pd(val, rhs.val); val = val * rhs.val; return (*this); } v2df operator /= (const v2df rhs) { val = _mm_div_pd(val, rhs.val); return (*this); } v2df operator & (const v2df rhs) { return v2df(_mm_and_pd(val, rhs.val)); } v2df operator != (const v2df rhs) { return v2df(_mm_cmp_pd(val, rhs.val, _CMP_NEQ_UQ)); } v2df operator < (const v2df rhs) { return v2df(_mm_cmp_pd(val, rhs.val, _CMP_LT_OS)); } static v2df sqrt(const v2df rhs) { return v2df(_mm_sqrt_pd(rhs.val)); } static v2df hadd(v2df x0, v2df x1) { return _mm_hadd_pd(x0, x1); } void store(double *p) const { _mm_store_pd(p, val); } void storel(double *p) const { _mm_storel_pd(p, val); } void storeh(double *p) const { _mm_storeh_pd(p, val); } void load(double const *p) { val = _mm_load_pd(p); } v4sf cvtpd2ps() { return _mm_cvtpd_ps(val); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e\n") const { int vl = getVectorLength(); double a[vl]; _mm_store_pd(a, val); fprintf(fp, fmt, a[0], a[1]); } }; struct v4df { typedef double _v4df __attribute__((vector_size(32))) __attribute__((aligned(32))); _v4df val; static int getVectorLength() { return 4; } v4df(const v4df & rhs) : val(rhs.val) {} v4df operator = (const v4df rhs) { val = rhs.val; return (*this); } v4df() : val(_mm256_setzero_pd()) {} v4df(const double x) : val(_mm256_set_pd(x, x, x, x)) {} v4df(const double x, const double y, const double z, const double w) : val(_mm256_set_pd(w, z, y, x)) {} v4df(const _v4df _val) : val(_val) {} operator _v4df() {return val;} //~v4df() {} v4df operator + (const v4df rhs) const { //return v4df(_mm256_add_pd(val, rhs.val)); return val + rhs.val; } v4df operator - (const v4df rhs) const { //return v4df(_mm256_sub_pd(val, rhs.val)); return val - rhs.val; } v4df operator * (const v4df rhs) const { //return v4df(_mm256_mul_pd(val, rhs.val)); return val * rhs.val; } v4df operator / (const v4df rhs) const { return v4df(_mm256_div_pd(val, rhs.val)); } static v4df madd(const v4df c, const v4df a, const v4df b) { return v4df(_mm256_fmadd_pd(a.val, b.val, c.val)); } static v4df nmadd(const v4df c, const v4df a, const v4df b) { return v4df(_mm256_fnmadd_pd(a.val, b.val, c.val)); } static v4df max(const v4df a, const v4df b) { return v4df(_mm256_max_pd(a.val, b.val)); } static v4df min(const v4df a, const v4df b) { return v4df(_mm256_min_pd(a.val, b.val)); } v4df operator += (const v4df rhs) { //val = _mm256_add_pd(val, rhs.val); val = val + rhs.val; return (*this); } v4df operator -= (const v4df rhs) { //val = _mm256_sub_pd(val, rhs.val); val = val - rhs.val; return (*this); } v4df operator *= (const v4df rhs) { //val = _mm256_mul_pd(val, rhs.val); val = val * rhs.val; return (*this); } v4df operator /= (const v4df rhs) { val = _mm256_div_pd(val, rhs.val); return (*this); } v4df operator & (const v4df rhs) { return v4df(_mm256_and_pd(val, rhs.val)); } v4df operator != (const v4df rhs) { return v4df(_mm256_cmp_pd(val, rhs.val, _CMP_NEQ_UQ)); } v4df operator < (const v4df rhs) { return v4df(_mm256_cmp_pd(val, rhs.val, _CMP_LT_OS)); } void store(double *p) const { _mm256_store_pd(p, val); } void load(double const *p) { val = _mm256_load_pd(p); } v4sf cvtpd2ps() { return _mm256_cvtpd_ps(val); } void extractf128(v2df & x0, v2df & x1) { x0 = _mm256_extractf128_pd(val, 0); x1 = _mm256_extractf128_pd(val, 1); } static v4df rcp_0th(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); return x0; } static v4df rcp_1st(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0; return x0 + h * x0; } static v4df rcp_4th(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0; return (v4df(1.) + h) * (v4df(1.) + h * h) * x0; } static v4df sqrt(const v4df rhs) { return v4df(_mm256_sqrt_pd(rhs.val)); } static v4df rsqrt_0th(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); return x0; } static v4df rsqrt_1st(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + v4df(0.5) * h * x0; } static v4df rsqrt_2nd(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + v4df(0.375) * h) * h * x0; } static v4df rsqrt_3rd(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + (v4df(0.375) + v4df(0.3125) * h) * h) * h * x0; } static v4df rsqrt_4th(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + (v4df(0.375) + (v4df(0.3125) + v4df(0.2734375) * h) * h) * h) * h * x0; } static v4df rsqrt_1st_phantom(v4df rhs) { v4sf x1 = v4sf::rsqrt_1st_phantom(rhs.cvtpd2ps()); return x1.cvtps2pd(); } static v4df fabs(v4df rhs) { v4df signmask(-0.0); return _mm256_andnot_pd(signmask, rhs); } static v4df hadd(v4df x0, v4df x1) { return _mm256_hadd_pd(x0, x1); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n") const { int vl = getVectorLength(); double a[vl]; _mm256_store_pd(a, val); fprintf(fp, fmt, a[0], a[1], a[2], a[3]); } }; void v8sf::cvtpd2ps(v4df & x0, v4df & x1) { x0 = _mm256_cvtps_pd(_mm256_extractf128_ps(val, 0)); x1 = _mm256_cvtps_pd(_mm256_extractf128_ps(val, 1)); } v4df v4sf::cvtps2pd() { return _mm256_cvtps_pd(val); }
16,133
7,036
/****************************************************************************** * Copyright (c) 2021, 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. * *******************************************************************************/ /****************************************************************************** * * Authors: Timoteo Garcia Bertoa <timoteog@xilinx.com> * * \file tmrcheck.hpp * * Library of templated HLS functions for BNN deployment. * This file performs error checks to triplicated channels of an OFM * *****************************************************************************/ #ifndef TMR_HPP #define TMR_HPP #include "hls_stream.h" /** * \brief Smart TMR block * * The function receives an OFM from the MVTU, with triplicated channels. It outputs a single channel for each triplication, * being this channel one which contains valid data. A flag is also available to watch the character of the error detected, * either all channels in a triplication are different, or just one. * * \tparam InW Input data width, activation precision * \tparam OFMChannels Number of Output Feature Map channels, including triplications * \tparam NUM_RED Number of redundancies (or triplicated channels) * \tparam REDF Redundancy factor (3 to triplicate) * \tparam OFMDim Width and Height of the Output Feature Map (assumed square) * \tparam MAX_CH_WIDTH Value to determine the precision of channel indexes * * \param in Input stream * \param out Output stream * \param errortype Flag to inform redundancy check results. 0 if no faults, LSB set if one PE is faulty, MSB set if all differ * \param channel_mask Value with binary channel masks (1 if channel is triplicated, 0 otherwise) * \param red_ch_index Array of redundant triplets' indexes. Each position stores the first triplicated channel index of a triplet */ template<unsigned int InW, unsigned int OFMChannels, unsigned int NUM_RED, unsigned int REDF, unsigned int OFMDim, unsigned int MAX_CH_WIDTH> void TMRCheck(hls::stream<ap_uint<InW*OFMChannels>> &in, hls::stream<ap_uint<InW*(OFMChannels-NUM_RED*(REDF-1))>> &out, ap_uint<2> &errortype, ap_uint<OFMChannels> channel_mask, ap_uint<MAX_CH_WIDTH> red_ch_index[NUM_RED]) { #pragma HLS ARRAY_PARTITION variable=red_ch_index complete dim=0 ap_uint<InW*OFMChannels> input; // Number of channels without triplications constexpr unsigned int OFMChannelsTMR = (OFMChannels-NUM_RED*(REDF-1)); errortype = 0; // CheckLoop: iterates over all OFM positions for(unsigned int pos = 0; pos < (OFMDim * OFMDim); pos++){ #pragma HLS pipeline II=1 // Read input stream input = in.read(); ap_uint<InW*NUM_RED> tmr_out = {0}; ap_uint<InW*OFMChannelsTMR> out_aux = {0}; ap_uint<2> numerrors[NUM_RED]; #pragma HLS ARRAY_PARTITION variable=numerrors complete dim=0 // Check triplicated channel indexes and store the corresponding data to perform TMR check for(unsigned int i = 0; i < NUM_RED; i++){ #pragma HLS UNROLL numerrors[i] = 0; // TMR CHECK: start // Store index of triplicated channel unsigned int idx = red_ch_index[i]; // CompareLoop: performs comparisons between PE0, PE1, PE2 for(unsigned int y = 0; y < REDF; y++){ for(unsigned int x = y+1; x < REDF; x++){ if( (input((idx+y+1)*InW-1, (idx+y)*InW)) == (input((idx+x+1)*InW-1, (idx+x)*InW)) ){ tmr_out((i+1)*InW-1, i*InW) = input((idx+x+1)*InW-1, (idx+x)*InW); } else { numerrors[i]++; if(numerrors[i] == REDF){ errortype |= (ap_uint<2>)0b10; } else { errortype |= (ap_uint<2>)0b1; } tmr_out((i+1)*InW-1, i*InW) = input((idx+1)*InW-1, idx*InW); } } } // end CompareLoop } // end Check triplicated channel indexes ap_uint<OFMChannels> unitL = 1; ap_uint<1> compute[OFMChannels]; #pragma HLS ARRAY_PARTITION variable=compute complete dim=0 // ChannelLoop: iterates over all OFM channels (including triplications), and outputs either: TMR check output/input/nothing for(unsigned int k = 0; k < OFMChannels; k++){ #pragma HLS UNROLL compute[k] = 0; // Check if current channel is any of the FIRST triplicated for(unsigned int i = 0; i < NUM_RED; i++){ // Store index of triplicated channel unsigned int idx = red_ch_index[i]; if(k == idx){ compute[k] = 1; } } // If it is one of the first triplicated, forward the TMR check output, which contains valid data if(compute[k]){ out_aux = out_aux >> InW; out_aux(OFMChannelsTMR*InW-1, (OFMChannelsTMR-1)*InW) = tmr_out(InW-1, 0); tmr_out = tmr_out >> InW; // If it is not a first triplicated channel, check if it is a triplicated or not using mask } else if((channel_mask & (unitL << k)) != 0){ ; // Nothing to do, skip triplicated channel // If it is a not triplicated channel, forward the input data } else { out_aux = out_aux >> InW; out_aux(OFMChannelsTMR*InW-1, (OFMChannelsTMR-1)*InW) = input((k+1)*InW-1, k*InW); } } // end ChannelLoop out.write(out_aux); } // end CheckLoop } // end TMRCheck /** * \brief Smart TMR block (batch) * * The function receives an OFM from the MVTU, with triplicated channels. It outputs a single channel for each triplication, * being this channel one which contains valid data. A flag is also available to watch the character of the error detected, * either all channels in a triplication are different, or just one. * * \tparam InW Input data width, activation precision * \tparam OFMChannels Number of Output Feature Map channels, including triplications * \tparam NUM_RED Number of redundancies (or triplicated channels) * \tparam REDF Redundancy factor (3 to triplicate) * \tparam OFMDim Width and Height of the Output Feature Map (assumed square) * \tparam MAX_CH_WIDTH Value to determine the precision of channel indexes * * \param in Input stream * \param out Output stream * \param errortype Flag to inform redundancy check results. 0 if no faults, LSB set if one PE is faulty, MSB set if all differ * \param channel_mask Value with binary channel masks (1 if channel is triplicated, 0 otherwise) * \param red_ch_index Array of redundant triplets' indexes. Each position stores the first triplicated channel index of a triplet * \param numReps Number of time the function has to be repeatedly executed (e.g. number of images) */ template<unsigned int InW, unsigned int OFMChannels, unsigned int NUM_RED, unsigned int REDF, unsigned int OFMDim, unsigned int MAX_CH_WIDTH> void TMRCheck_Batch(hls::stream<ap_uint<InW*OFMChannels>> &in, hls::stream<ap_uint<InW*(OFMChannels-NUM_RED*(REDF-1))>> &out, ap_uint<2> &errortype, ap_uint<OFMChannels> channel_mask, ap_uint<MAX_CH_WIDTH> red_ch_index[NUM_RED], unsigned int numReps) { for (unsigned int rep = 0; rep < numReps; rep++) { TMRCheck<InW, OFMChannels, NUM_RED, REDF, OFMDim, MAX_CH_WIDTH>(in, out, errortype, channel_mask, red_ch_index); } } #endif
9,611
2,896
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B" #include <bits/stdc++.h> using namespace std; #include "utility/fast-pow.hpp" const long long MOD = 1e9 + 7; int main() { long long M, N; cin >> M >> N; cout << fast_pow(M, N, MOD) << '\n'; }
282
131
//----------------------------------------------------------------------------- // boost variant/detail/std_hash.hpp header file // See http://www.boost.org for updates, documentation, and revision history. //----------------------------------------------------------------------------- // // Copyright (c) 2018-2019 Antony Polukhin // // 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) #ifndef BOOST_VARIANT_DETAIL_STD_HASH_HPP #define BOOST_VARIANT_DETAIL_STD_HASH_HPP #include <boost/config.hpp> #ifdef BOOST_HAS_PRAGMA_ONCE # pragma once #endif #include <boost/variant/variant_fwd.hpp> #include <boost/variant/detail/hash_variant.hpp> /////////////////////////////////////////////////////////////////////////////// // macro BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH // // Define this macro if you do not with to have a std::hash specialization for // boost::variant. #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) #include <functional> // for std::hash namespace std { template < BOOST_VARIANT_ENUM_PARAMS(typename T) > struct hash<boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) > > { std::size_t operator()(const boost::variant< BOOST_VARIANT_ENUM_PARAMS(T) >& val) const { return ::boost::hash_value(val); } }; } #endif // #if !defined(BOOST_VARIANT_DO_NOT_SPECIALIZE_STD_HASH) && !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL) #endif // BOOST_VARIANT_DETAIL_STD_HASH_HPP
1,575
569
#if 0 // Call from DrawableObjectAndValues::Draw() DrawableObjectAndValues::Draw() { ... DrawingCanvas::RawPixels rawPixels = drawingCanvas.GetRawPixels(); std::vector<Edge> edges = { {0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,0}, {8,9},{9,10},{10,11},{11,8}, {12,13},{13,14},{14,15},{15,12} }; std::vector<PointI> points = { {100,100},{150,0},{250,150},{250,0},{300,100},{250,200},{150,50},{150,200}, {400,150},{600,200},{350,350},{300,250}, {400,200},{450,250},{400,275},{350,250} }; FillPolyline(rawPixels, canvasTransform, points, IN OUT edges, 0xFFE080C0); DrawLineTransformed( rawPixels, canvasTransform, 100, 100, 100, 200, 0xFFE080C0 ); } namespace { struct PointI // There is no D2D_POINT_2I, just D2D_POINT_2F, D2D_POINT_2F, D2D_POINT_2L. { int32_t x, y; }; struct Intersection { int32_t x; // Current x coordinate. int32_t dx; // Delta x per y, where x += dx each row. uint32_t modulusAccumulator; // Current accumulator. If it exceeds limit, wrap and add +1 to x. uint32_t modulusIncrement; // Amount to increase the accumulator each uint32_t modulusLimit; // Upper limit, which actually just equals the line's height. int32_t yEnd; // Ending y coordinate where this intersection stops. }; bool operator < (Intersection const& intersection1, Intersection const& intersection2) noexcept { return intersection1.x < intersection2.x; } using Edge = std::pair<uint32_t,uint32_t>; void OrderEdgesDownThenRight(array_ref<PointI const> points, _Inout_ array_ref<Edge> edges) { // Ensure all edges are ordered pointing downward, with the top y coordinate first. for (auto& edge : edges) { assert(edge.first < points.size()); assert(edge.second < points.size()); auto const& pt1 = points[edge.first]; auto const& pt2 = points[edge.second]; if (pt1.y > pt2.y) { std::swap(edge.first, edge.second); } } // Order points top to bottom, then left to right for any points on the // same row. Order is based on the first point, ignoring the second. std::sort( edges.begin(), edges.end(), [&, points](Edge const& edge1, Edge const& edge2) { auto const& pt1 = points[edge1.first]; auto const& pt2 = points[edge2.first]; if (pt1.y < pt2.y) return true; if (pt1.y > pt2.y) return false; if (pt1.x < pt2.x) return true; if (pt1.x > pt2.x) return false; return edge1.first < edge2.first; } ); } void DrawEdgeListSingleRow( array_ref<uint32_t> pixelRow, array_ref<Intersection const> intersectionList, uint32_t color ) { // Draw a single horizontal row of alternating spans between intersection point pairs. int32_t parity = 0; int32_t previousX = INT_MAX; int32_t maxX = int32_t(pixelRow.size()); for (auto& intersection : intersectionList) { auto nextX = intersection.x; if (previousX < maxX) { // Color the x-span pixels while the crossing parity is odd. if (parity && nextX > 0) { auto pixelSpan = pixelRow.clamped_slice(previousX, nextX); for (uint32_t& pixel : pixelSpan) { pixel = color; } } } parity ^= 1; previousX = nextX; } } void InitializeIntersectionFromEdge( array_ref<PointI const> points, Edge edge, int32_t y, _Out_ Intersection& intersection ) { // Set initial x and final y. auto const& pt1 = points[edge.first]; auto const& pt2 = points[edge.second]; intersection.x = pt1.x; intersection.yEnd = pt2.y; intersection.modulusAccumulator = 0; // Determine the fractional x delta each row. auto dy = pt2.y - pt1.y; auto dx = pt2.x - pt1.x; if (dy > 0) { intersection.dx = dx / dy; intersection.modulusIncrement = abs(dx) % dy; intersection.modulusLimit = dy; // Handle negative dx values by reversing the increment fraction. // That way advancing each row requires no special logic for negative. if (dx < 0) { --intersection.dx; intersection.modulusIncrement = intersection.modulusLimit - intersection.modulusIncrement; } // For the case where a line is partly clipped and starts above screen, // advance the intersection point. It would be equivalent but slower to // loop calling AdvanceIntersectionsXCoordinateOneRowDown. if (y > pt1.y) { auto leadingClippedHeight = y - pt1.y; intersection.x += intersection.dx * leadingClippedHeight; uint64_t extendedAccumulator = uint64_t(intersection.modulusIncrement) * leadingClippedHeight; intersection.x += uint32_t(extendedAccumulator / intersection.modulusLimit); intersection.modulusAccumulator += uint32_t(extendedAccumulator % intersection.modulusLimit); } } else // Just use zeroes for a zero width line or perfectly horizontal line. { intersection.dx = 0; intersection.modulusIncrement = 0; intersection.modulusLimit = INT_MAX; } } void AdvanceIntersectionsXCoordinateOneRowDown(_Inout_ array_ref<Intersection> intersectionList) { // Nudge the edge intersection's current x pixel by the delta per single y pixel. for (auto& intersection : intersectionList) { intersection.x += intersection.dx; // If the accumulator overflows, move an extra pixel. intersection.modulusAccumulator += intersection.modulusIncrement; if (intersection.modulusAccumulator >= intersection.modulusLimit) { intersection.modulusAccumulator -= intersection.modulusLimit; // modulus operation. ++intersection.x; } } } void OrderIntersectionListByXCoordinate(_Inout_ array_ref<Intersection> intersectionList) { // Check whether it's still in order, reordering if stale. if (!std::is_sorted(intersectionList.begin(), intersectionList.end())) { std::sort(intersectionList.begin(), intersectionList.end()); } } void FillPolyline( DrawingCanvas::RawPixels rawPixels, DX_MATRIX_3X2F const& canvasTransform, array_ref<PointI> points, _Inout_ array_ref<Edge> edges, uint32_t fillColor ); void DrawLineTransformed( DrawingCanvas::RawPixels rawPixels, DX_MATRIX_3X2F const& canvasTransform, int32_t x1, int32_t y1, int32_t x2, int32_t y2, uint32_t color ) throw() { // Transform points first. PointI ends[2] = {{x1,y1}, {x2,y2}}; for (auto& point : ends) { auto x = int32_t(point.x * canvasTransform.xx + point.y * canvasTransform.yx + canvasTransform.dx); auto y = int32_t(point.x * canvasTransform.xy + point.y * canvasTransform.yy + canvasTransform.dy); point.x = x; point.y = y; } PointI points[4] = {ends[0],ends[0],ends[1],ends[1]}; auto dx = ends[1].x - ends[0].x; auto dy = ends[1].y - ends[0].y; if (abs(dx) >= abs(dy)) // More horizontal than vertical. { points[0].y += 1; points[3].y += 1; } else // More vertical than horizontal. { points[1].x += 1; points[2].x += 1; } Edge edges[4] = {{0,1},{1,2},{2,3},{3,0}}; FillPolyline(rawPixels, canvasTransform, points, IN OUT edges, color); } void FillPolyline( DrawingCanvas::RawPixels rawPixels, DX_MATRIX_3X2F const& canvasTransform, array_ref<PointI> points, _Inout_ array_ref<Edge> edges, uint32_t fillColor ) { assert(rawPixels.bitsPerPixel == 32); if (edges.empty()) return; std::vector<Intersection> intersections; intersections.reserve(edges.size()); // Rhombus //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,0}}; //std::vector<PointI> points = {{100,100},{300,150},{50,300},{0,200}}; // Diamond //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,0}}; //std::vector<PointI> points = {{100,100},{300,200},{100,300},{0,200}}; // Mountains //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,0}}; //std::vector<PointI> points = {{100,100},{150,0},{200,50},{250,0},{300,100}}; // Two mountains //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,0}}; //std::vector<PointI> points = {{100,100},{150,0},{200,100},{250,0},{300,100}}; // Crossing //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,0}}; //std::vector<PointI> points = {{100,100},{150,0},{200,200},{250,0},{300,100}}; // Coincident edge test. //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,0}}; //std::vector<PointI> points = {{100,100},{150,0},{250,150},{250,0},{300,100},{250,200},{150,0}}; // Inset shape. //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,0}}; //std::vector<PointI> points = {{100,100},{150,0},{250,150},{250,0},{300,100},{250,200},{150,50},{150,200}}; // Inset shape plus rhombus. //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,0}, {8,9},{9,10},{10,11},{11,8}, {12,13},{13,14},{14,15},{15,12}}; //std::vector<PointI> points = {{100,100},{150,0},{250,150},{250,0},{300,100},{250,200},{150,50},{150,200}, {400,150},{600,200},{350,350},{300,250}, {400,200},{450,250},{400,275},{350,250}}; // Single pixel thick sheared line. //std::vector<Edge> edges = {{0,1},{1,2},{2,3},{3,0}, {4,5},{5,6},{6,7},{7,4}, {8,9},{9,10},{10,11},{11,8}}; //std::vector<PointI> points = {{100,100},{101,100},{201,300},{200,300}, {150,100},{151,100},{251,200},{250,200}, {200,101},{200,100},{400,200},{400,201}}; #if 1 static float a = 0, b = 0; int i = 0; for (auto& point : points) { auto c = cos(b), s = sin(b); //auto x = int32_t((point.x - 200) * c + (point.y - 200) * s) + 200; //auto y = int32_t((point.x - 200) * -s + (point.y - 200) * c) + 200; //point.x = x; //point.y = y; point.x = int32_t((point.x - 200) * c + (point.y - 200) * s) + 300; point.y = int32_t((point.x - 200) * -s + (point.y - 200) * c);// +300; //point.x += int32_t(cos(a + i) * 40.0f); //point.y += int32_t(sin(a + i) * 40.0f); ++i; } a += 0.1f; b -= 0.01f; #endif #if 1 for (auto& point : points) { auto x = int32_t(point.x * canvasTransform.xx + point.y * canvasTransform.yx + canvasTransform.dx); auto y = int32_t(point.x * canvasTransform.xy + point.y * canvasTransform.yy + canvasTransform.dy); point.x = x; point.y = y; } #endif OrderEdgesDownThenRight(points, IN OUT edges); auto pixelRow = array_ref<uint32_t>(reinterpret_cast<uint32_t*>(rawPixels.pixels), rawPixels.width); // Find top and bottom to reduce number of scanlines. // Then clamp to drawing surface. int32_t yStart = INT_MAX; int32_t yEnd = -INT_MAX; for (auto const& point : points) { yStart = std::min(yStart, point.y); yEnd = std::max(yEnd, point.y); } yStart = std::max(yStart, 0); yEnd = std::min(yEnd, int32_t(rawPixels.height)); pixelRow.offset_by_bytes(rawPixels.byteStride * yStart); auto currentEdge = edges.begin(); int32_t nextSignificantY = 0; for (int32_t y = yStart; y < yEnd; ++y) { // Find any new line segments that start at this row. Otherwise skip over several rows // until reaching another edge rather than check every time through the loop. if (y >= nextSignificantY) { nextSignificantY = yEnd; for (; currentEdge != edges.end(); ++currentEdge) { auto& edge = *currentEdge; auto edgeStartingY = points[edge.first].y; if (edgeStartingY <= y && points[edge.second].y > y) { // Add new intersection point to the active list, initializing the slope and other vars. intersections.resize(intersections.size() + 1); InitializeIntersectionFromEdge(points, edge, y, OUT intersections.back()); } else if (edgeStartingY > y) { // This edge begins beyond the current row (as do all edges after it, since they are sorted). // So just store this row as significant for future row loops. nextSignificantY = std::min(nextSignificantY, edgeStartingY); break; } } // Delete old intersections upon reaching their last y coordinate. auto intersectionsEnd = std::remove_if(intersections.begin(), intersections.end(), [y](Intersection const& intersection) {return intersection.yEnd == y; }); intersections.erase(intersectionsEnd, intersections.end()); std::for_each(intersections.begin(), intersections.end(), [&](auto const& intersection) {nextSignificantY = std::min(nextSignificantY, intersection.yEnd); }); } // Ensure the intersections are still in ascending x order after adding any new ones or deleting old ones. // Even if none were added, just advancing the intersection lines can cross each other. OrderIntersectionListByXCoordinate(IN OUT intersections); DrawEdgeListSingleRow(pixelRow, intersections, fillColor); AdvanceIntersectionsXCoordinateOneRowDown(IN OUT intersections); pixelRow.offset_by_bytes(rawPixels.byteStride); } } } #endif
15,470
5,250
//============================================================================ // Name : // Author : Avi // Revision : $Revision: #5 $ // // Copyright 2009-2017 ECMWF. // This software is licensed under the terms of the Apache Licence version 2.0 // which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. // In applying this licence, ECMWF does not waive the privileges and immunities // granted to it by virtue of its status as an intergovernmental organisation // nor does it submit to any jurisdiction. // // Description //============================================================================ #include <iostream> #include <boost/test/unit_test.hpp> #include "boost/filesystem/operations.hpp" #include "SerializationTest.hpp" using namespace ecf; using namespace boost; using namespace std; namespace fs = boost::filesystem; class MyClass { public: enum State { UNKNOWN =0, COMPLETE=1, QUEUED=2, ABORTED=3, SUBMITTED=4, ACTIVE=5, SUSPENDED=6}; MyClass() = default; bool operator==(const MyClass & rhs) const { return x == rhs.x && y == rhs.y && state_ == rhs.state_;} void print(std::ostream &os) const { os << "MyClass: x("<< x << ") y(" << y << ") state(" << state_ << ")"; } private: // This method lets cereal know which data members to serialize friend class cereal::access; template<class Archive> void serialize(Archive & archive, std::uint32_t const version) { archive( CEREAL_NVP(x), CEREAL_NVP(y), CEREAL_NVP(state_) ); } int x{2}, y{2}; State state_{State::SUSPENDED}; }; CEREAL_CLASS_VERSION(MyClass , 1); class MyTop : public MyClass { public: MyTop() = default; void set(int x,int y,int z) { x_ = x; y_ = y; z_=z;} bool operator==(const MyTop& rhs) const { return (MyClass::operator==(rhs)) && x_ == rhs.x_ && y_ == rhs.y_ && z_ == rhs.z_;} void print(std::ostream &os) const { os << "MyTop:"; MyClass::print(os); os << ": x("<< x_ << ") y(" << y_ << ") z(" << z_ << ")"; } private: // This method lets cereal know which data members to serialize friend class cereal::access; template<class Archive> void serialize(Archive & archive, std::uint32_t const version) { archive( cereal::base_class<MyClass>( this ), CEREAL_NVP(x_), CEREAL_NVP(y_), CEREAL_NVP(z_) ); } int x_{1}, y_{1}, z_{1}; }; CEREAL_CLASS_VERSION(MyTop , 1); std::ostream& operator<<(std::ostream &os, MyTop const &m) { m.print(os); return os; } // ================================================================================= BOOST_AUTO_TEST_SUITE( CoreTestSuite ) BOOST_AUTO_TEST_CASE( test_cereal_json ) { cout << "ACore:: ...test_cereal_json \n" ; std::string path = "test_cereal_json"; { std::ofstream os(path); cereal::JSONOutputArchive oarchive(os); // Create an output archive MyTop m1, m2, m3; oarchive(cereal::make_nvp("MyTop",m1), m2, m3); // Write the data to the archive } // archive goes out of scope, ensuring all contents are flushed { BOOST_CHECK_MESSAGE(fs::exists(path)," Expected file to exist"); std::ifstream is(path); cereal::JSONInputArchive iarchive(is); // Create an input archive MyTop m1, m2, m3; iarchive(m1, m2, m3); // Read the data from the archive fs::remove(path); // Remove the file. Comment out for debugging } } BOOST_AUTO_TEST_CASE( test_cereal_json2 ) { cout << "ACore:: ...test_cereal_json2\n" ; MyTop m1; m1.set(10,10,10); std::string path = "test_cereal_json2"; { ecf::doSave(path,m1); } { ecf::doRestore(path,m1); } { ecf::doSaveAndRestore<MyTop>(path); } } BOOST_AUTO_TEST_SUITE_END()
3,770
1,331
template <class B> force_inline void AString<B>::Insert(int pos, const char *s) { Insert(pos, s, strlen__(s)); } template <class B> void AString<B>::Cat(int c, int count) { tchar *s = B::Insert(GetLength(), count, NULL); while(count--) *s++ = c; } template <class B> force_inline void AString<B>::Cat(const tchar *s) { Cat(s, strlen__(s)); } template <class B> int AString<B>::Compare(const tchar *b) const { const tchar *a = B::Begin(); const tchar *ae = End(); for(;;) { if(a >= ae) return *b == 0 ? 0 : -1; if(*b == 0) return 1; int q = cmpval__(*a++) - cmpval__(*b++); if(q) return q; } } template <class B> typename AString<B>::String AString<B>::Mid(int from, int count) const { int l = GetLength(); if(from > l) from = l; if(from < 0) from = 0; if(count < 0) count = 0; if(from + count > l) count = l - from; return String(B::Begin() + from, count); } template <class B> int AString<B>::Find(int chr, int from) const { ASSERT(from >= 0 && from <= GetLength()); const tchar *e = End(); const tchar *ptr = B::Begin(); for(const tchar *s = ptr + from; s < e; s++) if(*s == chr) return (int)(s - ptr); return -1; } template <class B> int AString<B>::ReverseFind(int chr, int from) const { ASSERT(from >= 0 && from <= GetLength()); if(from < GetLength()) { const tchar *ptr = B::Begin(); for(const tchar *s = ptr + from; s >= ptr; s--) if(*s == chr) return (int)(s - ptr); } return -1; } template <class B> int AString<B>::ReverseFind(int len, const tchar *s, int from) const { ASSERT(from >= 0 && from <= GetLength()); if(from < GetLength()) { const tchar *ptr = B::Begin(); const tchar *p = ptr + from - len + 1; len *= sizeof(tchar); while(p >= ptr) { if(*s == *p && memcmp(s, p, len) == 0) return (int)(p - ptr); p--; } } return -1; } template <class B> int AString<B>::ReverseFindAfter(int len, const tchar *s, int from) const { int q = ReverseFind(len, s, from); return q >= 0 ? q + len : -1; } template <class B> void AString<B>::Replace(const tchar *find, int findlen, const tchar *replace, int replacelen) { if(findlen == 0) return; String r; int i = 0; const tchar *p = B::Begin(); for(;;) { int j = Find(findlen, find, i); if(j < 0) break; r.Cat(p + i, j - i); r.Cat(replace, replacelen); i = j + findlen; } r.Cat(p + i, B::GetCount() - i); B::Free(); B::Set0(r); } template <class B> int AString<B>::ReverseFind(const tchar *s, int from) const { return ReverseFind(strlen__(s), s, from); } template <class B> int AString<B>::ReverseFindAfter(const tchar *s, int from) const { return ReverseFindAfter(strlen__(s), s, from); } template <class B> int AString<B>::ReverseFind(int chr) const { return B::GetCount() ? ReverseFind(chr, B::GetCount() - 1) : -1; } template <class B> void AString<B>::Replace(const String& find, const String& replace) { Replace(~find, find.GetCount(), ~replace, replace.GetCount()); } template <class B> force_inline void AString<B>::Replace(const tchar *find, const tchar *replace) { Replace(find, (int)strlen__(find), replace, (int)strlen__(replace)); } template <class B> force_inline void AString<B>::Replace(const String& find, const tchar *replace) { Replace(~find, find.GetCount(), replace, (int)strlen__(replace)); } template <class B> force_inline void AString<B>::Replace(const tchar *find, const String& replace) { Replace(find, (int)strlen__(find), ~replace, replace.GetCount()); } template <class B> bool AString<B>::StartsWith(const tchar *s, int len) const { if(len > GetLength()) return false; return memcmp(s, B::Begin(), len * sizeof(tchar)) == 0; } template <class B> force_inline bool AString<B>::StartsWith(const tchar *s) const { return StartsWith(s, strlen__(s)); } template <class B> bool AString<B>::EndsWith(const tchar *s, int len) const { int l = GetLength(); if(len > l) return false; return memcmp(s, B::Begin() + l - len, len * sizeof(tchar)) == 0; } template <class B> force_inline bool AString<B>::EndsWith(const tchar *s) const { return EndsWith(s, strlen__(s)); } template <class B> int AString<B>::FindFirstOf(int len, const tchar *s, int from) const { ASSERT(from >= 0 && from <= GetLength()); const tchar *ptr = B::Begin(); const tchar *e = B::End(); const tchar *se = s + len; if(len == 1) { tchar c1 = s[0]; for(const tchar *bs = ptr + from; bs < e; bs++) { if(*bs == c1) return (int)(bs - ptr); } return -1; } if(len == 2) { tchar c1 = s[0]; tchar c2 = s[1]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2) return (int)(bs - ptr); } return -1; } if(len == 3) { tchar c1 = s[0]; tchar c2 = s[1]; tchar c3 = s[2]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2 || ch == c3) return (int)(bs - ptr); } return -1; } if(len == 4) { tchar c1 = s[0]; tchar c2 = s[1]; tchar c3 = s[2]; tchar c4 = s[3]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2 || ch == c3 || ch == c4) return (int)(bs - ptr); } return -1; } for(const tchar *bs = ptr + from; bs < e; bs++) for(const tchar *ss = s; ss < se; ss++) if(*bs == *ss) return (int)(bs - ptr); return -1; } inline int String0::Compare(const String0& s) const { #ifdef FAST_STRING_COMPARE if((chr[KIND] | s.chr[KIND]) == 0) { #ifdef CPU_64 uint64 a64 = q[0]; uint64 b64 = s.q[0]; if(a64 != b64) return SwapEndian64(a64) < SwapEndian64(b64) ? -1 : 1; uint32 a32 = w[2]; uint32 b32 = s.w[2]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; #else uint32 a32 = w[0]; uint32 b32 = s.w[0]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; a32 = w[1]; b32 = s.w[1]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; a32 = w[2]; b32 = s.w[2]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; #endif uint16 a16 = v[6]; uint16 b16 = s.v[6]; if(a16 != b16) return SwapEndian16(a16) < SwapEndian16(b16) ? -1 : 1; return 0; } #endif return LCompare(s); } force_inline void String0::Set(const char *s, int len) { Clear(); if(len < 14) { SVO_MEMCPY(chr, s, len); SLen() = len; Dsyn(); return; } SetL(s, len); Dsyn(); } force_inline String& String::operator=(const char *s) { AssignLen(s, strlen__(s)); return *this; } force_inline String::String(const char *s) { String0::Set0(s, strlen__(s)); } force_inline void StringBuffer::Strlen() { SetLength((int)strlen__(pbegin)); } force_inline void StringBuffer::Cat(const char *s) { Cat(s, (int)strlen__(s)); }
6,708
3,081
#include "DX9ShareContainer.hpp" #include <d3dx9.h> namespace dx9 { namespace resource { bool DX9ShareContainer::isResCreated = false; size_t DX9ShareContainer::topLayerPos = 0; LogManager* DX9ShareContainer::log; CComPtr<IDirect3D9> DX9ShareContainer::d3d9; CComPtr<IDirect3DDevice9> DX9ShareContainer::d3ddev9; D3DCAPS9 DX9ShareContainer::d3dcaps9; D3DPRESENT_PARAMETERS DX9ShareContainer::d3dpresent; CComPtr<IDirect3DVertexBuffer9> DX9ShareContainer::vertex_rect; CComPtr<IDirect3DVertexBuffer9> DX9ShareContainer::vertex_circle; CComPtr<ID3DXEffect> DX9ShareContainer::effect; // シェーダ CComPtr<IDirect3DVertexDeclaration9> DX9ShareContainer::verDecl; // 頂点宣言 D3DXMATRIX DX9ShareContainer::projMat; BLENDMODE DX9ShareContainer::blendMode = BLENDMODE::NORMAL; bool DX9ShareContainer::isDrawStarted = false; bool DX9ShareContainer::isLost = false; bool DX9ShareContainer::isRightHand = false; unsigned long DX9ShareContainer::clearColor = 0xffffff; TextureFilter DX9ShareContainer::texFilter = TextureFilter::LINEAR; } }
1,167
582
#include "MengeCore/PluginEngine/CorePluginEngine.h" #include "MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.h" #include "MengeCore/Agents/Elevations/ElevationDatabase.h" #include "MengeCore/Agents/Events/EventEffectDB.h" #include "MengeCore/Agents/Events/EventTargetDB.h" #include "MengeCore/Agents/Events/EventTriggerDB.h" #include "MengeCore/Agents/ObstacleSets/ObstacleSetDatabase.h" #include "MengeCore/Agents/ProfileSelectors/ProfileSelectorDatabase.h" #include "MengeCore/Agents/SpatialQueries/SpatialQueryDatabase.h" #include "MengeCore/Agents/StateSelectors/StateSelectorDatabase.h" #include "MengeCore/BFSM/Actions/ActionDatabase.h" #include "MengeCore/BFSM/Goals/GoalDatabase.h" #include "MengeCore/BFSM/GoalSelectors/GoalSelectorDatabase.h" #include "MengeCore/BFSM/Tasks/TaskDatabase.h" #include "MengeCore/BFSM/Transitions/ConditionDatabase.h" #include "MengeCore/BFSM/Transitions/TargetDatabase.h" #include "MengeCore/BFSM/VelocityComponents/VelComponentDatabase.h" #include "MengeCore/BFSM/VelocityModifiers/VelModifierDatabase.h" #include "MengeCore/Orca/ORCADBEntry.h" #include "MengeCore/PedVO/PedVODBEntry.h" #include "MengeCore/Runtime/SimulatorDB.h" namespace Menge { namespace PluginEngine { ///////////////////////////////////////////////////////////////////// // Implementation of CorePluginEngine ///////////////////////////////////////////////////////////////////// CorePluginEngine::CorePluginEngine( SimulatorDB * simDB ) : BasePluginEngine< CorePluginEngine, Plugin<CorePluginEngine> >(), _simDB( simDB ) { registerModelDBEntry( new ORCA::DBEntry() ); registerModelDBEntry( new PedVO::DBEntry() ); BFSM::ActionDB::initialize(); BFSM::ConditionDB::initialize(); BFSM::TargetDB::initialize(); BFSM::VelCompDB::initialize(); BFSM::VelModDB::initialize(); BFSM::TaskDB::initialize(); BFSM::GoalDB::initialize(); BFSM::GoalSelectorDB::initialize(); Agents::ElevationDB::initialize(); Agents::SpatialQueryDB::initialize(); Agents::AgentGeneratorDB::initialize(); Agents::ObstacleSetDB::initialize(); Agents::ProfileSelectorDB::initialize(); Agents::StateSelectorDB::initialize(); EventEffectDB::initialize(); EventTriggerDB::initialize(); EventTargetDB::initialize(); } ///////////////////////////////////////////////////////////////////// CorePluginEngine::~CorePluginEngine() { } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerModelDBEntry( SimulatorDBEntry * dbEntry ) { _simDB->registerEntry( dbEntry ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerActionFactory( BFSM::ActionFactory * factory ) { BFSM::ActionDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerConditionFactory( BFSM::ConditionFactory * factory ) { BFSM::ConditionDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerTargetFactory( BFSM::TargetFactory * factory ) { BFSM::TargetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerVelCompFactory( BFSM::VelCompFactory * factory ) { BFSM::VelCompDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerVelModFactory( BFSM::VelModFactory * factory ) { BFSM::VelModDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerTaskFactory( BFSM::TaskFactory * factory ) { BFSM::TaskDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerGoalFactory( BFSM::GoalFactory * factory ) { BFSM::GoalDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerGoalSelectorFactory( BFSM::GoalSelectorFactory * factory ) { BFSM::GoalSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerElevationFactory( Agents::ElevationFactory * factory ) { Agents::ElevationDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerSpatialQueryFactory( Agents::SpatialQueryFactory * factory ) { Agents::SpatialQueryDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerAgentGeneratorFactory( Agents::AgentGeneratorFactory * factory ) { Agents::AgentGeneratorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerObstacleSetFactory( Agents::ObstacleSetFactory * factory ) { Agents::ObstacleSetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerProfileSelectorFactory( Agents::ProfileSelectorFactory * factory ) { Agents::ProfileSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerStateSelectorFactory( Agents::StateSelectorFactory * factory ) { Agents::StateSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventEffectFactory( EventEffectFactory * factory ) { EventEffectDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventTriggerFactory( EventTriggerFactory * factory ) { EventTriggerDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventTargetFactory( EventTargetFactory * factory ) { EventTargetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// std::string CorePluginEngine::getIntroMessage() { return "Loading Menge core-simulation plugins..."; } ///////////////////////////////////////////////////////////////////// // Implementation of CorePluginEngine ///////////////////////////////////////////////////////////////////// #ifndef DOXYGEN_SHOULD_SKIP_THIS template<> const char * Plugin< CorePluginEngine >::getRegisterName() const { return "registerCorePlugin"; } } #endif // DOXYGEN_SHOULD_SKIP_THIS } // namespace Menge
6,803
1,998
#include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> #include <SDL2/SDL_image.h> #include <cstdlib> #include <ctime> #include <map> #include <fstream> #include <iostream> #include "Simulation.hpp" #include "speed.hpp" Simulation::Simulation(Settings const& settings): m_settings(settings) { srand(time(0)); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER); if(m_settings.hide) m_window = SDL_CreateWindow("SimuWorld", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_HIDDEN); else m_window = SDL_CreateWindow("SimuWorld", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_RESIZABLE); SDL_GetWindowSize(m_window, &m_winsize.x, &m_winsize.y); m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); IMG_Init(IMG_INIT_JPG|IMG_INIT_PNG); SDL_SetWindowIcon(m_window, IMG_Load("icone.png")); TTF_Init(); m_map = new Map(m_renderer); m_population = new Population(m_renderer); m_camera = new Camera(); m_stats = new Stats(); m_leftclick = false; m_render = true; m_paused = false; m_map->generate(); m_population->generate(); set_simulation_speed(m_settings.speed); } Simulation::~Simulation() { SDL_DestroyRenderer(m_renderer); SDL_DestroyWindow(m_window); delete m_map; delete m_camera; delete m_population; delete m_stats; TTF_Quit(); IMG_Quit(); SDL_Quit(); } bool Simulation::get_error() const { if(m_map->get_error() || m_population->get_error() || m_stats->get_error()) return true; return false; } void Simulation::execute() { while(process_events() && check_status()) { update(); if(!m_settings.hide) render(); } } void Simulation::update() { if(!m_paused) { m_map->update(); m_population->update(*m_map); m_stats->update(*m_population, *m_map); } } void Simulation::render() { SDL_SetRenderDrawColor(m_renderer, 128, 128, 128, 255); SDL_RenderClear(m_renderer); if(m_render) { m_camera->update(*m_population, m_winsize); m_map->render(m_renderer, m_winsize, *m_camera); m_population->render(m_renderer, m_winsize, *m_camera); } m_stats->render(m_renderer, m_winsize); SDL_RenderPresent(m_renderer); } bool Simulation::process_events() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: if(event.window.event == SDL_WINDOWEVENT_CLOSE) { if(confirm_exit()) return false; } else if(event.window.event == SDL_WINDOWEVENT_RESIZED) m_winsize = {event.window.data1, event.window.data2}; break; case SDL_MOUSEBUTTONDOWN: if(event.button.button == SDL_BUTTON_LEFT) { m_camera->focus_on_animal(*m_population, *m_stats, m_mousepos); m_leftclick = true; } else if(event.button.button == SDL_BUTTON_RIGHT) { if(event.button.x < 100) m_stats->select_graph(m_mousepos); } break; case SDL_MOUSEBUTTONUP: if(event.button.button == SDL_BUTTON_LEFT) m_leftclick = false; break; case SDL_MOUSEWHEEL: if(event.wheel.y < 0) m_camera->zoom(m_mousepos, false); else if(event.wheel.y > 0) m_camera->zoom(m_mousepos, true); break; case SDL_MOUSEMOTION: if(m_leftclick) m_camera->move(event.motion.x - m_mousepos.x, event.motion.y - m_mousepos.y); m_mousepos = {event.motion.x, event.motion.y}; break; case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_i) m_stats->show_hide_data(); else if(event.key.keysym.sym == SDLK_g) m_stats->show_hide_graph(); else if(event.key.keysym.sym == SDLK_r) m_render = !m_render; else if(event.key.keysym.sym == SDLK_p) m_paused = !m_paused; else if(event.key.keysym.sym == SDLK_b) m_population->show_hide_bubble(); else if(event.key.keysym.sym == SDLK_KP_PLUS || event.key.keysym.sym == SDLK_UP) change_simulation_speed(true); else if(event.key.keysym.sym == SDLK_KP_MINUS || event.key.keysym.sym == SDLK_DOWN) change_simulation_speed(false); else if(event.key.keysym.sym == SDLK_DELETE) m_stats->hide_all_graph(); else if(event.key.keysym.sym == SDLK_s) m_population->show_hide_blood(); break; } } return true; } bool Simulation::confirm_exit() { const SDL_MessageBoxButtonData buttons[] = { { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "annuler" }, { 0, 1, "non" }, { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 2, "oui" }, }; const SDL_MessageBoxData messageboxdata = { SDL_MESSAGEBOX_INFORMATION, NULL, "Fermeture de la simulation", "Voulez-vous sauvegarder les resultats ?", SDL_arraysize(buttons), buttons, NULL }; int selection; SDL_ShowMessageBox(&messageboxdata, &selection); switch(selection) { case -1: case 0: return false; case 2: if(!m_stats->save(m_settings.directory, m_settings.id)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fermeture impossible", "Une erreur est survenue durant la sauvegarde", NULL); return false; } } return true; } bool Simulation::check_status() { if(m_settings.id == 0) //the programm has been launched from simuworld and not the launcher return true; bool has_finished = m_stats->has_finished(m_settings.duration); bool has_failed = m_stats->has_failed(); int percent = m_stats->get_percent(m_settings.duration); save_status(percent, has_failed); if((m_settings.stopOnFailure && has_failed) || has_finished) //simulation failure or completed { if((m_settings.saveOnFailure && has_failed && (percent > m_settings.minFailureSave)) || has_finished) //failure and save still or completed { while(!m_stats->save(m_settings.directory, m_settings.id)) SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fermeture impossible", "Une erreur est survenue durant la sauvegarde", NULL); } return false; } return true; } void Simulation::save_status(int percent, bool has_failed) { std::ofstream file("status_" + std::to_string(m_settings.id) + ".txt"); if(file) { file << percent << ";" << has_failed << std::endl; } file.close(); }
7,274
2,603
/** * \file WdbeMtpModbscbuZynq_ip_AXI_v1_0.cpp * Wdbe operation processor - add pin substitute signals (implementation) * \copyright (C) 2016-2020 MPSI Technologies GmbH * \author Alexander Wirthmueller (auto-generation) * \date created: 28 Nov 2020 */ // IP header --- ABOVE #ifdef WDBECMBD #include <Wdbecmbd.h> #else #include <Wdbeopd.h> #endif #include "WdbeMtpModbscbuZynq_ip_AXI_v1_0.h" using namespace std; using namespace Sbecore; using namespace Xmlio; using namespace WdbeMtpModbscbu; // IP ns.cust --- INSERT /****************************************************************************** namespace WdbeMtpModbscbuZynq_ip_AXI_v1_0 ******************************************************************************/ DpchRetWdbe* WdbeMtpModbscbuZynq_ip_AXI_v1_0::run( XchgWdbe* xchg , DbsWdbe* dbswdbe , DpchInvWdbeMtpModbscbu* dpchinv ) { ubigint refWdbeMModule = dpchinv->refWdbeMModule; utinyint ixOpVOpres = VecOpVOpres::SUCCESS; // IP run --- IBEGIN ubigint ref, refC; WdbeMModule* mdl = NULL; uint mdlNum; if (dbswdbe->tblwdbemmodule->loadRecByRef(refWdbeMModule, &mdl)) { mdlNum = 1; refC = dbswdbe->tblwdbecsignal->getNewRef(); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "enTx", false, "sl", 1, "", "", "", "0", false, 0, ""); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "tx", false, "slvdn", 32, "", "", "", "0", false, 0, ""); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "strbTx", false, "sl", 1, "", "", "", "0", false, 0, ""); refC = dbswdbe->tblwdbecsignal->getNewRef(); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "enRx", false, "sl", 1, "", "", "", "0", false, 0, ""); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "rx", false, "slvdn", 32, "", "", "", "0", false, 0, ""); dbswdbe->tblwdbemsignal->insertNewRec(NULL, VecWdbeVMSignalBasetype::PSB, refC, refWdbeMModule, mdlNum++, VecWdbeVMSignalMgeTbl::VOID, 0, 0, "strbRx", false, "sl", 1, "", "", "", "0", false, 0, ""); }; // IP run --- IEND return(new DpchRetWdbe(VecWdbeVDpch::DPCHRETWDBE, "", "", ixOpVOpres, 100)); }; // IP cust --- INSERT
2,566
1,187
// Copyright 2008 by BBN Technologies Corp. // All Rights Reserved. #include "Generic/common/leak_detection.h" #include "Generic/common/UTF8InputStream.h" #include "Generic/common/ParamReader.h" #include <iostream> using namespace std; int main (int argc, char *argv[]) { if (argc != 2) { cerr << "ArabicSerif.exe sould be invoked with a single argument, which provides a\n" << "path to the parameter file.\n"; return -1; } ParamReader::readParamFile(argv[1]); cout << "So far so good....\n"; return 0; }
555
212
#ifndef _ARINDEXBUFFER_HPP #define _ARINDEXBUFFER_HPP #include "common.hpp" #include "RenderResource.hpp" #include "RenderDefinitions.hpp" #ifndef GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES #endif #include <GLFW/glfw3.h> namespace ar { class IndexBuffer : public RenderResource { public: virtual ~IndexBuffer() = default; virtual void BufferData() = 0; }; /* Index buffer. */ class GenericIndexBuffer : public IndexBuffer { public: GenericIndexBuffer() = default; GenericIndexBuffer(BufferUsage usage) : _usage(usage) { } virtual void InitResource() override { glGenBuffers(1, &_vio); } virtual void ReleaseResource() override { glDeleteBuffers(1, &_vio); } int AddIndices(const Vector<GLuint>& indices) { size_t offset = _indices.size(); // append new indices to the end of our existing list _indices.insert(std::end(_indices), std::begin(indices), std::end(indices)); _dirty = true; return (int)offset; } void SetIndices(const Vector<GLuint>& indices) { _indices = indices; _dirty = true; } virtual void BufferData() override { if (!_initialized) throw std::runtime_error("The index buffer was not initialized."); if (!_dirty) return; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vio); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * _indices.size(), &_indices[0], GetGLUsage(_usage)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); _dirty = false; } void ClearAll() { _indices.clear(); _dirty = true; } bool _dirty = false; BufferUsage _usage = BufferUsage::Static; GLuint _vio; Vector<GLuint> _indices; }; } // namespace ar #endif // _ARINDEXBUFFER_HPP
1,714
636
#include "sampler.h" #include "types.h" namespace opencl { #ifndef CL_VERSION_2_0 // /* Sampler APIs */ // extern CL_API_ENTRY cl_sampler CL_API_CALL // clCreateSampler(cl_context /* context */, // cl_bool /* normalized_coords */, // cl_addressing_mode /* addressing_mode */, // cl_filter_mode /* filter_mode */, // cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0; NAN_METHOD(CreateSampler) { Nan::HandleScope scope; REQ_ARGS(4); // Arg 0 NOCL_UNWRAP(context, NoCLContext, info[0]); // Arg 1 cl_bool normalized_coords = Nan::To<bool>(info[1]).FromJust() ? CL_TRUE : CL_FALSE; // Arg 2 cl_addressing_mode addressing_mode = Nan::To<uint32_t>(info[2]).FromJust(); // Arg 3 cl_filter_mode filter_mode = Nan::To<uint32_t>(info[3]).FromJust(); cl_int ret=CL_SUCCESS; cl_sampler sw = ::clCreateSampler( context->getRaw(), normalized_coords, addressing_mode, filter_mode, &ret); CHECK_ERR(ret); info.GetReturnValue().Set(NOCL_WRAP(NoCLSampler, sw)); } #else // extern CL_API_ENTRY cl_sampler CL_API_CALL // clCreateSamplerWithProperties(cl_context /* context */, // const cl_sampler_properties * /* normalized_coords */, // cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_2_0; // NAN_METHOD(CreateSamplerWithProperties) { Nan::HandleScope scope; REQ_ARGS(2); // Arg 0 NOCL_UNWRAP(context, NoCLContext, info[0]); Local<Array> properties = Local<Array>::Cast(info[1]); vector<cl_sampler_properties> cl_properties; for (uint32_t i=0; i < properties->Length(); i+=2) { cl_uint prop_id = Nan::To<int32_t>(Nan::Get(properties, i).ToLocalChecked()).FromJust(); cl_properties.push_back(prop_id); if(prop_id == CL_SAMPLER_NORMALIZED_COORDS) { if (!Nan::Get(properties, i+1).ToLocalChecked()->IsBoolean()) { THROW_ERR(CL_INVALID_VALUE); } cl_bool norm = Nan::To<bool>(Nan::Get(properties, i+1).ToLocalChecked()).FromJust() ? 1 : 0; cl_properties.push_back(norm); } else if (prop_id == CL_SAMPLER_ADDRESSING_MODE) { if (!Nan::Get(properties, i+1).ToLocalChecked()->IsNumber()) { THROW_ERR(CL_INVALID_VALUE); } cl_addressing_mode addr = Nan::To<int32_t>(Nan::Get(properties, i+1).ToLocalChecked()).FromJust(); cl_properties.push_back(addr); } else if (prop_id == CL_SAMPLER_FILTER_MODE) { if (!Nan::Get(properties, i+1).ToLocalChecked()->IsNumber()) { THROW_ERR(CL_INVALID_VALUE); } cl_filter_mode fil = Nan::To<int32_t>(Nan::Get(properties, i+1).ToLocalChecked()).FromJust(); cl_properties.push_back(fil); } else { THROW_ERR(CL_INVALID_VALUE) } } cl_properties.push_back(0); /*cl_sampler_properties pp [] = {CL_SAMPLER_NORMALIZED_COORDS, true, CL_SAMPLER_ADDRESSING_MODE, CL_ADDRESS_NONE, CL_SAMPLER_FILTER_MODE, CL_FILTER_LINEAR, 0};*/ cl_int err = CL_SUCCESS; cl_sampler sw = ::clCreateSamplerWithProperties( context->getRaw(), cl_properties.data(), &err); CHECK_ERR(err); info.GetReturnValue().Set(NOCL_WRAP(NoCLSampler, sw)); } #endif // extern CL_API_ENTRY cl_int CL_API_CALL // clRetainSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; NAN_METHOD(RetainSampler) { Nan::HandleScope scope; REQ_ARGS(1); NOCL_UNWRAP(sampler, NoCLSampler, info[0]); cl_int err=sampler->acquire(); CHECK_ERR(err) info.GetReturnValue().Set(JS_INT(err)); } // extern CL_API_ENTRY cl_int CL_API_CALL // clReleaseSampler(cl_sampler /* sampler */) CL_API_SUFFIX__VERSION_1_0; NAN_METHOD(ReleaseSampler) { Nan::HandleScope scope; REQ_ARGS(1); NOCL_UNWRAP(sampler, NoCLSampler, info[0]); cl_int err=sampler->release(); CHECK_ERR(err) info.GetReturnValue().Set(JS_INT(err)); } // extern CL_API_ENTRY cl_int CL_API_CALL // clGetSamplerInfo(cl_sampler /* sampler */, // cl_sampler_info /* param_name */, // size_t /* param_value_size */, // void * /* param_value */, // size_t * /* param_value_size_ret */) CL_API_SUFFIX__VERSION_1_0; NAN_METHOD(GetSamplerInfo) { Nan::HandleScope scope; REQ_ARGS(2); NOCL_UNWRAP(sampler, NoCLSampler, info[0]); cl_sampler_info param_name = Nan::To<uint32_t>(info[1]).FromJust(); switch(param_name) { case CL_SAMPLER_REFERENCE_COUNT: { cl_uint val; CHECK_ERR(::clGetSamplerInfo(sampler->getRaw(),param_name,sizeof(cl_uint), &val, NULL)) info.GetReturnValue().Set(JS_INT(val)); return; } case CL_SAMPLER_CONTEXT: { cl_context val; CHECK_ERR(::clGetSamplerInfo(sampler->getRaw(),param_name,sizeof(cl_context), &val, NULL)) return; } case CL_SAMPLER_NORMALIZED_COORDS: { cl_bool val; CHECK_ERR(::clGetSamplerInfo(sampler->getRaw(),param_name,sizeof(cl_bool), &val, NULL)) info.GetReturnValue().Set(val==CL_TRUE ? Nan::True() : Nan::False()); return; } case CL_SAMPLER_ADDRESSING_MODE: { cl_addressing_mode val; CHECK_ERR(::clGetSamplerInfo(sampler->getRaw(),param_name,sizeof(cl_addressing_mode), &val, NULL)) info.GetReturnValue().Set(JS_INT(val)); return; } case CL_SAMPLER_FILTER_MODE: { cl_filter_mode val; CHECK_ERR(::clGetSamplerInfo(sampler->getRaw(),param_name,sizeof(cl_filter_mode), &val, NULL)) info.GetReturnValue().Set(JS_INT(val)); return; } } THROW_ERR(CL_INVALID_VALUE); } namespace Sampler { NAN_MODULE_INIT(init) { Nan::SetMethod(target, "retainSampler", RetainSampler); Nan::SetMethod(target, "releaseSampler", ReleaseSampler); Nan::SetMethod(target, "getSamplerInfo", GetSamplerInfo); #ifndef CL_VERSION_2_0 Nan::SetMethod(target, "createSampler", CreateSampler); #else Nan::SetMethod(target, "createSamplerWithProperties", CreateSamplerWithProperties); #endif } } // namespace Sampler } // namespace opencl
6,209
2,320
#include "MapInfo.h" using namespace BWAPI; using namespace Boris; namespace Boris { void MapInfo::onStart() { } }
120
48
/* * chronotest.cpp * * Created on: 24 марта 2017 г. * Author: dmitry */ #include <iostream> #include <chrono> #include <thread> #include <ratio> #include <ctime> #include "chronotest.h" namespace chronotest { //duration test void test01(){ std::chrono::duration<int, std::ratio<60,1>> dminutes {1}; std::chrono::duration<int, std::ratio<1,1>> dseconds {1}; std::chrono::duration<int, std::ratio<1,1000>> dmiliseconds {500}; typedef std::chrono::duration<uint64_t, std::ratio<1,1000000>> microsec_t; while(1){ //std::this_thread::sleep_for(std::chrono::seconds(1)); //std::this_thread::sleep_for(std::chrono::hours(1)); //std::this_thread::sleep_for(dseconds); //std::this_thread::sleep_for(dmiliseconds); //auto dur = std::chrono::microseconds {500000}; //dmiliseconds = 100; нельзя //dseconds = std::chrono::duration<int, std::ratio<1,1>> {2}; //auto dur = dseconds; //auto dur = std::chrono::duration<double, std::ratio<1,1000>> {507.8}; //std::chrono::duration<double, std::ratio<1,1000>> dur {509.8}; //std::chrono::milliseconds dur {607}; microsec_t dur {807}; std::this_thread::sleep_for(dur); std::cout << dur.count() << " period passed\n"; } } //time_point and clock test void test02(){ std::chrono::system_clock::time_point tp_epoch; // epoch value std::chrono::time_point <std::chrono::system_clock, std::chrono::duration<int>> tp_seconds (std::chrono::duration<int>(1)); std::chrono::system_clock::time_point tp {tp_seconds}; std::cout << "1 second since system_clock epoch = "; std::cout << tp.time_since_epoch().count(); std::cout << " system_clock periods." << std::endl; // display time_point: std::time_t tt = std::chrono::system_clock::to_time_t(tp); std::cout << "time_point tp is: " << ctime(&tt); std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now(); // с компилятором 4.7 строки ниже работали с 4.9 нет // std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<int, std::ratio<1,1000000 >>> t11 = std::chrono::steady_clock::now(); // std::time_t tt1 = std::chrono::steady_clock::to_time_t(t11); // std::cout << "time_point tp is: " << ctime(&tt1); std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now(); //auto dur = std::chrono::duration<int, std::ratio<1,1000000>>(t2-t1); std::chrono::duration<int, std::ratio<1,1000000 > > dur = std::chrono::duration_cast < std::chrono::duration < int, std::ratio<1,1000000 > > >(t2 - t1); //std::chrono::microseconds dur = std::chrono::duration_cast< std::chrono::microseconds> (t2 - t1); std::cout << dur.count() << " us time interval\n"; typedef std::chrono::duration<int,std::ratio<60*60*24*7>> weeks_type; std::chrono::time_point<std::chrono::system_clock,weeks_type> today =std::chrono::time_point_cast<weeks_type>(std::chrono::system_clock::now()); std::cout << today.time_since_epoch().count() << " weeks since epoch" << std::endl; } void chronotest_run(){ // test01(); test02(); } }
3,204
1,252
/*************************************************************************** * * Project _____ __ ____ _ _ * ( _ ) /__\ (_ _)_| |_ _| |_ * )(_)( /(__)\ )( (_ _)(_ _) * (_____)(__)(__)(__) |_| |_| * * * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com> * * 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 oatpp_netword_server_SimpleTCPConnectionProvider_hpp #define oatpp_netword_server_SimpleTCPConnectionProvider_hpp #include "oatpp/network/ConnectionProvider.hpp" #include "oatpp/network/Connection.hpp" #include "oatpp/core/Types.hpp" namespace oatpp { namespace network { namespace server { /** * Simple provider of TCP connections. */ class SimpleTCPConnectionProvider : public base::Countable, public ServerConnectionProvider { public: /** * Connection with extra data - ex.: peer address. */ class ExtendedConnection : public oatpp::network::Connection { public: static const char* const PROPERTY_PEER_ADDRESS; static const char* const PROPERTY_PEER_ADDRESS_FORMAT; static const char* const PROPERTY_PEER_PORT; protected: data::stream::DefaultInitializedContext m_context; public: /** * Constructor. * @param handle - &id:oatpp::v_io_handle;. * @param properties - &id:oatpp::data::stream::Context::Properties;. */ ExtendedConnection(v_io_handle handle, data::stream::Context::Properties&& properties); /** * Get output stream context. * @return - &id:oatpp::data::stream::Context;. */ oatpp::data::stream::Context& getOutputStreamContext() override; /** * Get input stream context. <br> * @return - &id:oatpp::data::stream::Context;. */ oatpp::data::stream::Context& getInputStreamContext() override; }; private: v_uint16 m_port; std::atomic<bool> m_closed; oatpp::v_io_handle m_serverHandle; bool m_useExtendedConnections; private: oatpp::v_io_handle instantiateServer(); private: bool prepareConnectionHandle(oatpp::v_io_handle handle); std::shared_ptr<IOStream> getDefaultConnection(); std::shared_ptr<IOStream> getExtendedConnection(); public: /** * Constructor. * @param port - port to listen for incoming connections. * @param useExtendedConnections - set `true` to use &l:SimpleTCPConnectionProvider::ExtendedConnection;. * `false` to use &id:oatpp::network::Connection;. */ SimpleTCPConnectionProvider(v_uint16 port, bool useExtendedConnections = false); /** * Constructor. * @param host - host name without schema and port. Ex.: "oatpp.io", "127.0.0.1", "localhost". * @param port - port to listen for incoming connections. * @param useExtendedConnections - set `true` to use &l:SimpleTCPConnectionProvider::ExtendedConnection;. * `false` to use &id:oatpp::network::Connection;. */ SimpleTCPConnectionProvider(const oatpp::String& host, v_uint16 port, bool useExtendedConnections = false); public: /** * Create shared SimpleTCPConnectionProvider. * @param port - port to listen for incoming connections. * @param port * @return - `std::shared_ptr` to SimpleTCPConnectionProvider. */ static std::shared_ptr<SimpleTCPConnectionProvider> createShared(v_uint16 port, bool useExtendedConnections = false){ return std::make_shared<SimpleTCPConnectionProvider>(port, useExtendedConnections); } /** * Create shared SimpleTCPConnectionProvider. * @param host - host name without schema and port. Ex.: "oatpp.io", "127.0.0.1", "localhost". * @param port - port to listen for incoming connections. * @param port * @return - `std::shared_ptr` to SimpleTCPConnectionProvider. */ static std::shared_ptr<SimpleTCPConnectionProvider> createShared(const oatpp::String& host, v_uint16 port, bool useExtendedConnections = false){ return std::make_shared<SimpleTCPConnectionProvider>(host, port, useExtendedConnections); } /** * Virtual destructor. */ ~SimpleTCPConnectionProvider(); /** * Close accept-socket. */ void close() override; /** * Get incoming connection. * @return &id:oatpp::data::stream::IOStream;. */ std::shared_ptr<IOStream> getConnection() override; /** * No need to implement this.<br> * For Asynchronous IO in oatpp it is considered to be a good practice * to accept connections in a seperate thread with the blocking accept() * and then process connections in Asynchronous manner with non-blocking read/write. * <br> * *It may be implemented later* */ oatpp::async::CoroutineStarterForResult<const std::shared_ptr<oatpp::data::stream::IOStream>&> getConnectionAsync() override { /* * No need to implement this. * For Asynchronous IO in oatpp it is considered to be a good practice * to accept connections in a seperate thread with the blocking accept() * and then process connections in Asynchronous manner with non-blocking read/write * * It may be implemented later */ throw std::runtime_error("[oatpp::network::server::SimpleTCPConnectionProvider::getConnectionAsync()]: Error. Not implemented."); } /** * Call shutdown read and write on an underlying file descriptor. * `connection` **MUST** be an object previously obtained from **THIS** connection provider. * @param connection */ void invalidateConnection(const std::shared_ptr<IOStream>& connection) override; /** * Get port. * @return */ v_uint16 getPort(){ return m_port; } }; }}} #endif /* oatpp_netword_server_SimpleTCPConnectionProvider_hpp */
6,226
1,887
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #include <Box2D/Box2D.h> #include <moaicore/MOAISim.h> #include <moaicore/MOAIBox2DArbiter.h> #include <moaicore/MOAIBox2DBody.h> #include <moaicore/MOAIBox2DPrismaticJoint.h> #include <moaicore/MOAIBox2DWorld.h> #include <moaicore/MOAILogMessages.h> SUPPRESS_EMPTY_FILE_WARNING #if USE_BOX2D //================================================================// // local //================================================================// //----------------------------------------------------------------// /** @name getJointSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number jointSpeed in units/s, converted from m/s */ int MOAIBox2DPrismaticJoint::_getJointSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetJointSpeed () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getJointTranslation @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number jointTranslation in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getJointTranslation ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetJointTranslation () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getLowerLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number lowerLimit in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getLowerLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetLowerLimit () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getMotorForce @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number motorForce in kg * units / s^2, converted from N [kg * m / s^2] */ int MOAIBox2DPrismaticJoint::_getMotorForce ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; float step = ( float )( 1.0 / MOAISim::Get ().GetStep ()); state.Push ( joint->GetMotorForce (step) / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getMotorSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number motorSpeed in units/s, converted from m/s */ int MOAIBox2DPrismaticJoint::_getMotorSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetMotorSpeed () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getUpperLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number upperLimit in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getUpperLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetUpperLimit () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name isLimitEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out boolean limitEnabled */ int MOAIBox2DPrismaticJoint::_isLimitEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->IsLimitEnabled ()); return 1; } //----------------------------------------------------------------// /** @name isMotorEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out boolean motorEnabled */ int MOAIBox2DPrismaticJoint::_isMotorEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->IsMotorEnabled ()); return 1; } //----------------------------------------------------------------// /** @name setLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number lower in units, converted to meters. Default value is 0. @opt number upper in units, converted to meters. Default value is 0. @out nil */ int MOAIBox2DPrismaticJoint::_setLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float lower = state.GetValue < float >( 2, 0.0f ); float upper = state.GetValue < float >( 3, 0.0f ); float unitsToMeters = self->GetUnitsToMeters (); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetLimits ( lower * unitsToMeters, upper * unitsToMeters ); joint->EnableLimit ( true ); return 0; } //----------------------------------------------------------------// /** @name setLimitEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt boolean enabled Default value is 'true' @out nil */ int MOAIBox2DPrismaticJoint::_setLimitEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } bool enabled = state.GetValue < bool >( 2, true ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->EnableLimit ( enabled ); return 0; } //----------------------------------------------------------------// /** @name setMaxMotorForce @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number maxMotorForce in kg * units / s^2, converted to N [kg * m / s^2]. Default value is 0. @out nil */ int MOAIBox2DPrismaticJoint::_setMaxMotorForce ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float maxMotorForce = state.GetValue < float >( 2, 0.0f ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMaxMotorForce ( maxMotorForce * unitsToMeters ); return 0; } //----------------------------------------------------------------// /** @name setMotor @text See Box2D documentation. If speed is determined to be zero, the motor is disabled, unless forceEnable is set. @in MOAIBox2DPrismaticJoint self @opt number speed in units/s converted to m/s. Default value is 0. @opt number maxForce in kg * units / s^2, converted to N [kg * m / s^2]. Default value is 0. @opt boolean forceEnable Default value is false. @out nil */ int MOAIBox2DPrismaticJoint::_setMotor ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float speed = state.GetValue < float >( 2, 0.0f ); float max = state.GetValue < float >( 3, 0.0f ); bool forceEnable = state.GetValue < bool >( 4, false ); float unitsToMeters = self->GetUnitsToMeters (); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMotorSpeed ( speed * unitsToMeters ); joint->SetMaxMotorForce ( max * unitsToMeters ); joint->EnableMotor ( forceEnable ? true : ( speed != 0.0f ) ); return 0; } //----------------------------------------------------------------// /** @name setMotorEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt boolean enabled Default value is 'true' @out nil */ int MOAIBox2DPrismaticJoint::_setMotorEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } bool enabled = state.GetValue < bool >( 2, true ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->EnableMotor ( enabled ); return 0; } //----------------------------------------------------------------// /** @name setMotorSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number motorSpeed in units/s, converted to m/s. Default value is 0. */ int MOAIBox2DPrismaticJoint::_setMotorSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float unitsToMeters = self->GetUnitsToMeters (); float speed = state.GetValue < float >( 2, 0.0f ) * unitsToMeters; b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMotorSpeed ( speed ); return 0; } //================================================================// // MOAIBox2DPrismaticJoint //================================================================// //----------------------------------------------------------------// MOAIBox2DPrismaticJoint::MOAIBox2DPrismaticJoint () { RTTI_BEGIN RTTI_EXTEND ( MOAIBox2DJoint ) RTTI_END } //----------------------------------------------------------------// MOAIBox2DPrismaticJoint::~MOAIBox2DPrismaticJoint () { } //----------------------------------------------------------------// void MOAIBox2DPrismaticJoint::RegisterLuaClass ( MOAILuaState& state ) { MOAIBox2DJoint::RegisterLuaClass ( state ); } //----------------------------------------------------------------// void MOAIBox2DPrismaticJoint::RegisterLuaFuncs ( MOAILuaState& state ) { MOAIBox2DJoint::RegisterLuaFuncs ( state ); luaL_Reg regTable [] = { { "getJointSpeed", _getJointSpeed }, { "getJointTranslation", _getJointTranslation }, { "getLowerLimit", _getLowerLimit }, { "getMotorForce", _getMotorForce }, { "getMotorSpeed", _getMotorSpeed }, { "getUpperLimit", _getUpperLimit }, { "isLimitEnabled", _isLimitEnabled }, { "isMotorEnabled", _isMotorEnabled }, { "setLimit", _setLimit }, { "setLimitEnabled", _setLimitEnabled }, { "setMaxMotorForce", _setMaxMotorForce }, { "setMotor", _setMotor }, { "setMotorSpeed", _setMotorSpeed }, { "setMotorEnabled", _setMotorEnabled }, { NULL, NULL } }; luaL_register ( state, 0, regTable ); } #endif
11,752
4,598