blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
34c5cf2f39e610a6e1b4253910b816df0ff3609d
b970b54403e209e4bff058430c9ee9e8f5c0d8ba
/src/test/sighash_tests.cpp
48ed97368997b71d3c1ca69330d4743c7d161bbb
[ "MIT" ]
permissive
onexnet/onexcore
4f6324bb8e2e7422a3128282deba1a8bb02e1db8
86fbcd6d0e24832b175c7bba3134896843cd8d49
refs/heads/master
2021-09-05T01:55:13.385261
2018-01-23T16:11:35
2018-01-23T16:11:35
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,353
cpp
// Copyright (c) 2013-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "consensus/validation.h" #include "data/sighash.json.h" #include "hash.h" #include "main.h" // For CheckTransaction #include "random.h" #include "script/interpreter.h" #include "script/script.h" #include "serialize.h" #include "streams.h" #include "test/test_onex.h" #include "util.h" #include "utilstrencodings.h" #include "version.h" #include <iostream> #include <boost/test/unit_test.hpp> #include <univalue.h> extern UniValue read_json(const std::string& jsondata); // Old script.cpp SignatureHash function uint256 static SignatureHashOld(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType) { static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001")); if (nIn >= txTo.vin.size()) { printf("ERROR: SignatureHash(): nIn=%d out of range\n", nIn); return one; } CMutableTransaction txTmp(txTo); // In case concatenating two scripts ends up with two codeseparators, // or an extra one at the end, this prevents all those possible incompatibilities. scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR)); // Blank out other inputs' signatures for (unsigned int i = 0; i < txTmp.vin.size(); i++) txTmp.vin[i].scriptSig = CScript(); txTmp.vin[nIn].scriptSig = scriptCode; // Blank out some of the outputs if ((nHashType & 0x1f) == SIGHASH_NONE) { // Wildcard payee txTmp.vout.clear(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } else if ((nHashType & 0x1f) == SIGHASH_SINGLE) { // Only lock-in the txout payee at same index as txin unsigned int nOut = nIn; if (nOut >= txTmp.vout.size()) { printf("ERROR: SignatureHash(): nOut=%d out of range\n", nOut); return one; } txTmp.vout.resize(nOut+1); for (unsigned int i = 0; i < nOut; i++) txTmp.vout[i].SetNull(); // Let the others update at will for (unsigned int i = 0; i < txTmp.vin.size(); i++) if (i != nIn) txTmp.vin[i].nSequence = 0; } // Blank out other inputs completely, not recommended for open transactions if (nHashType & SIGHASH_ANYONECANPAY) { txTmp.vin[0] = txTmp.vin[nIn]; txTmp.vin.resize(1); } // Serialize and hash CHashWriter ss(SER_GETHASH, 0); ss << txTmp << nHashType; return ss.GetHash(); } void static RandomScript(CScript &script) { static const opcodetype oplist[] = {OP_FALSE, OP_1, OP_2, OP_3, OP_CHECKSIG, OP_IF, OP_VERIF, OP_RETURN, OP_CODESEPARATOR}; script = CScript(); int ops = (insecure_rand() % 10); for (int i=0; i<ops; i++) script << oplist[insecure_rand() % (sizeof(oplist)/sizeof(oplist[0]))]; } void static RandomTransaction(CMutableTransaction &tx, bool fSingle) { tx.nVersion = insecure_rand(); tx.vin.clear(); tx.vout.clear(); tx.nLockTime = (insecure_rand() % 2) ? insecure_rand() : 0; int ins = (insecure_rand() % 4) + 1; int outs = fSingle ? ins : (insecure_rand() % 4) + 1; for (int in = 0; in < ins; in++) { tx.vin.push_back(CTxIn()); CTxIn &txin = tx.vin.back(); txin.prevout.hash = GetRandHash(); txin.prevout.n = insecure_rand() % 4; RandomScript(txin.scriptSig); txin.nSequence = (insecure_rand() % 2) ? insecure_rand() : (unsigned int)-1; } for (int out = 0; out < outs; out++) { tx.vout.push_back(CTxOut()); CTxOut &txout = tx.vout.back(); txout.nValue = insecure_rand() % 100000000; RandomScript(txout.scriptPubKey); } } BOOST_FIXTURE_TEST_SUITE(sighash_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(sighash_test) { seed_insecure_rand(false); #if defined(PRINT_SIGHASH_JSON) std::cout << "[\n"; std::cout << "\t[\"raw_transaction, script, input_index, hashType, signature_hash (result)\"],\n"; #endif int nRandomTests = 50000; #if defined(PRINT_SIGHASH_JSON) nRandomTests = 500; #endif for (int i=0; i<nRandomTests; i++) { int nHashType = insecure_rand(); CMutableTransaction txTo; RandomTransaction(txTo, (nHashType & 0x1f) == SIGHASH_SINGLE); CScript scriptCode; RandomScript(scriptCode); int nIn = insecure_rand() % txTo.vin.size(); uint256 sh, sho; sho = SignatureHashOld(scriptCode, txTo, nIn, nHashType); sh = SignatureHash(scriptCode, txTo, nIn, nHashType); #if defined(PRINT_SIGHASH_JSON) CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << txTo; std::cout << "\t[\"" ; std::cout << HexStr(ss.begin(), ss.end()) << "\", \""; std::cout << HexStr(scriptCode) << "\", "; std::cout << nIn << ", "; std::cout << nHashType << ", \""; std::cout << sho.GetHex() << "\"]"; if (i+1 != nRandomTests) { std::cout << ","; } std::cout << "\n"; #endif BOOST_CHECK(sh == sho); } #if defined(PRINT_SIGHASH_JSON) std::cout << "]\n"; #endif } // Goal: check that SignatureHash generates correct hash BOOST_AUTO_TEST_CASE(sighash_from_data) { UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + sizeof(json_tests::sighash))); for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 1) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } if (test.size() == 1) continue; // comment std::string raw_tx, raw_script, sigHashHex; int nIn, nHashType; uint256 sh; CTransaction tx; CScript scriptCode = CScript(); try { // deserialize test data raw_tx = test[0].get_str(); raw_script = test[1].get_str(); nIn = test[2].get_int(); nHashType = test[3].get_int(); sigHashHex = test[4].get_str(); uint256 sh; CDataStream stream(ParseHex(raw_tx), SER_NETWORK, PROTOCOL_VERSION); stream >> tx; CValidationState state; BOOST_CHECK_MESSAGE(CheckTransaction(tx, state), strTest); BOOST_CHECK(state.IsValid()); std::vector<unsigned char> raw = ParseHex(raw_script); scriptCode.insert(scriptCode.end(), raw.begin(), raw.end()); } catch (...) { BOOST_ERROR("Bad test, couldn't deserialize data: " << strTest); continue; } sh = SignatureHash(scriptCode, tx, nIn, nHashType); BOOST_CHECK_MESSAGE(sh.GetHex() == sigHashHex, strTest); } } BOOST_AUTO_TEST_SUITE_END()
[ "reactnet@gmail.com" ]
reactnet@gmail.com
276d4cd38bcf9be231037cfdacf49b7e620eb531
e7a3f7458a31f28c578207fafd5f26b014809458
/src/detail/camera/gstcameraimpl.cpp
26f73bba9be1366d6159fc7309ff623b378d086b
[ "Apache-2.0" ]
permissive
joshua-henderson/egt
50ca128625935b3c99be5d32c6d0a32f9f1f60ac
1b7fbdc4f440fd31ea31c5e65ead7ab66f54a40d
refs/heads/master
2020-08-27T14:24:17.237133
2020-05-27T01:13:10
2020-05-27T01:13:37
217,404,295
0
0
Apache-2.0
2019-10-24T22:13:47
2019-10-24T22:13:46
null
UTF-8
C++
false
false
17,873
cpp
/* * Copyright (C) 2018 Microchip Technology Inc. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "detail/camera/gstcameraimpl.h" #include "detail/video/gstmeta.h" #include "egt/app.h" #ifdef HAVE_LIBPLANES #include "egt/detail/screen/kmsoverlay.h" #include "egt/detail/screen/kmsscreen.h" #endif #include "egt/types.h" #include "egt/video.h" #include <exception> #include <gst/gst.h> #include <spdlog/fmt/ostr.h> #include <spdlog/spdlog.h> namespace egt { inline namespace v1 { namespace detail { CameraImpl::CameraImpl(CameraWindow& interface, const Rect& rect, // NOLINTNEXTLINE(modernize-pass-by-value) const std::string& device) : m_interface(interface), m_devnode(device), m_rect(rect) { GError* err = nullptr; if (!gst_init_check(nullptr, nullptr, &err)) { std::ostringstream ss; ss << "failed to initialize gstreamer: "; if (err && err->message) { ss << err->message; g_error_free(err); } else { ss << "unknown error"; } throw std::runtime_error(ss.str()); } /** * check for cache file by finding a playback plugin. * if gst_registry_find_plugin returns NULL, then no * cache file present and assume GSTREAMER1_PLUGIN_REGISTRY * is disabled in gstreamer package. */ if (!gst_registry_find_plugin(gst_registry_get(), "playback")) { SPDLOG_DEBUG("manually loading gstreamer plugins"); auto plugins = { "/usr/lib/gstreamer-1.0/libgstcoreelements.so", "/usr/lib/gstreamer-1.0/libgsttypefindfunctions.so", "/usr/lib/gstreamer-1.0/libgstplayback.so", "/usr/lib/gstreamer-1.0/libgstapp.so", "/usr/lib/gstreamer-1.0/libgstvideo4linux2.so", "/usr/lib/gstreamer-1.0/libgstvideoscale.so", "/usr/lib/gstreamer-1.0/libgstvideoconvert.so", "/usr/lib/gstreamer-1.0/libgstlibav.so", "/usr/lib/gstreamer-1.0/libgstvideoparsersbad.so", }; for (auto& plugin : plugins) { GError* error = nullptr; gst_plugin_load_file(plugin, &error); if (error) { if (error->message) spdlog::error("load plugin error: {}", error->message); g_error_free(error); } } } m_gmain_loop = g_main_loop_new(nullptr, FALSE); m_gmain_thread = std::thread(g_main_loop_run, m_gmain_loop); } gboolean CameraImpl::bus_callback(GstBus* bus, GstMessage* message, gpointer data) { ignoreparam(bus); auto impl = static_cast<CameraImpl*>(data); SPDLOG_TRACE("gst message: {}", GST_MESSAGE_TYPE_NAME(message)); switch (GST_MESSAGE_TYPE(message)) { case GST_MESSAGE_ERROR: { GstErrorHandle error; GstStringHandle debug; gst_message_parse(gst_message_parse_error, message, error, debug); if (error) { SPDLOG_DEBUG("gst error: {} {}", error->message, debug ? debug.get() : ""); if (Application::check_instance()) { asio::post(Application::instance().event().io(), [impl, error = std::move(error)]() { impl->m_interface.on_error.invoke(error->message); }); } } break; } case GST_MESSAGE_WARNING: { GstErrorHandle error; GstStringHandle debug; gst_message_parse(gst_message_parse_warning, message, error, debug); if (error) { SPDLOG_DEBUG("gst warning: {} {}", error->message, debug ? debug.get() : ""); } break; } case GST_MESSAGE_INFO: { GstErrorHandle error; GstStringHandle debug; gst_message_parse(gst_message_parse_info, message, error, debug); if (error) { SPDLOG_DEBUG("gst info: {} {}", error->message, debug ? debug.get() : ""); } break; } case GST_MESSAGE_DEVICE_ADDED: { GstDevice* device; gst_message_parse_device_added(message, &device); std::string devnode; GstStructure* props = gst_device_get_properties(device); if (props) { SPDLOG_DEBUG("device properties: {}", gst_structure_to_string(props)); devnode = gst_structure_get_string(props, "device.path"); gst_structure_free(props); } if (Application::check_instance()) { asio::post(Application::instance().event().io(), [impl, devnode]() { impl->m_interface.on_connect.invoke(devnode); }); } break; } case GST_MESSAGE_DEVICE_REMOVED: { GstDevice* device; gst_message_parse_device_removed(message, &device); std::string devnode; GstStructure* props = gst_device_get_properties(device); if (props) { SPDLOG_DEBUG("device properties: {}", gst_structure_to_string(props)); devnode = gst_structure_get_string(props, "device.path"); gst_structure_free(props); } asio::post(Application::instance().event().io(), [impl, devnode]() { /** * invoke disconnect only if current device is * disconnected. */ if (devnode == impl->m_devnode) impl->m_interface.on_disconnect.invoke(devnode); }); break; } default: break; } /* we want to be notified again if there is a message on the bus, so * returning true (false means we want to stop watching for messages * on the bus and our callback should not be called again) */ return true; } /* * Its a Basic window: copying buffer to cairo surface. */ void CameraImpl::draw(Painter& painter, const Rect& rect) { ignoreparam(rect); if (m_camerasample) { GstCaps* caps = gst_sample_get_caps(m_camerasample); GstStructure* capsStruct = gst_caps_get_structure(caps, 0); int width = 0; int height = 0; gst_structure_get_int(capsStruct, "width", &width); gst_structure_get_int(capsStruct, "height", &height); SPDLOG_TRACE("videowidth = {} videoheight = {}", width, height); gst_sample_ref(m_camerasample); GstBuffer* buffer = gst_sample_get_buffer(m_camerasample); GstMapInfo map; if (gst_buffer_map(buffer, &map, GST_MAP_READ)) { const auto box = m_interface.content_area(); const auto surface = unique_cairo_surface_t( cairo_image_surface_create_for_data(map.data, CAIRO_FORMAT_RGB16_565, width, height, cairo_format_stride_for_width(CAIRO_FORMAT_RGB16_565, width))); if (cairo_surface_status(surface.get()) == CAIRO_STATUS_SUCCESS) { auto cr = painter.context().get(); if (width != box.width() || height != box.height()) { double scalex = static_cast<double>(box.width()) / width; double scaley = static_cast<double>(box.height()) / height; cairo_scale(cr, scalex, scaley); } cairo_set_source_surface(cr, surface.get(), box.x(), box.y()); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_paint(cr); } gst_buffer_unmap(buffer, &map); } gst_sample_unref(m_camerasample); } } GstFlowReturn CameraImpl::on_new_buffer(GstElement* elt, gpointer data) { auto impl = static_cast<CameraImpl*>(data); GstSample* sample; g_signal_emit_by_name(elt, "pull-sample", &sample); if (sample) { #ifdef HAVE_LIBPLANES // TODO: this is not thread safe accessing impl here if (impl->m_interface.plane_window()) { GstBuffer* buffer = gst_sample_get_buffer(sample); if (buffer) { GstMapInfo map; if (gst_buffer_map(buffer, &map, GST_MAP_READ)) { auto screen = reinterpret_cast<detail::KMSOverlay*>(impl->m_interface.screen()); assert(screen); if (screen) { memcpy(screen->raw(), map.data, map.size); screen->schedule_flip(); gst_buffer_unmap(buffer, &map); } } } gst_sample_unref(sample); } else #endif { if (Application::check_instance()) { asio::post(Application::instance().event().io(), [impl, sample]() { if (impl->m_camerasample) gst_sample_unref(impl->m_camerasample); impl->m_camerasample = sample; impl->m_interface.damage(); }); } } return GST_FLOW_OK; } return GST_FLOW_ERROR; } void CameraImpl::get_camera_device_caps() { std::tuple<std::string, std::string, std::string, std::vector<std::tuple<int, int>>> caps = detail::get_camera_device_caps(m_devnode, &bus_callback, this); m_devnode = std::get<0>(caps); m_caps_name = std::get<1>(caps); m_caps_format = std::get<2>(caps); m_resolutions = std::get<3>(caps); } bool CameraImpl::start() { std::string pipe; get_camera_device_caps(); auto box = m_interface.content_area(); SPDLOG_DEBUG("box = {}", box); /* * if user constructs a default constructor, then size of * the camerawindow is zero for BasicWindow and 32x32 for * plane window. due to which pipeline initialization fails * incase of BasicWindow. as a fix resize the camerawindow * to 32x32. */ if ((box.width() < 32) && (box.height() < 32)) { m_interface.resize(Size(32, 32)); m_rect.size(Size(32, 32)); box = m_interface.content_area(); } /* * Here we try to match camera resolution with camerawindow size * and add scaling to pipeline if size does not match. * note: adding scaling to may effects performance and this way * now users can set any size for camera window. */ auto w = box.width(); auto h = box.height(); if (!m_resolutions.empty()) { auto index = std::distance(m_resolutions.begin(), std::lower_bound(m_resolutions.begin(), m_resolutions.end(), std::make_tuple(box.width(), box.height()))); w = std::get<0>(m_resolutions.at(index)); h = std::get<1>(m_resolutions.at(index)); SPDLOG_DEBUG("closest match of camerawindow : {} is {} ", box.size(), Size(w, h)); } std::string vscale; if ((w != box.width()) || (h != box.height())) { vscale = fmt::format(" videoscale ! video/x-raw,width={},height={} !", box.width(), box.height()); SPDLOG_DEBUG("scaling video: {} to {} ", Size(w, h), box.size()); } const auto format = detail::gstreamer_format(m_interface.format()); SPDLOG_DEBUG("format: {} ", format); static constexpr auto appsink_pipe = "v4l2src device={} ! videoconvert ! video/x-raw,width={},height={},format={} ! {} " \ "appsink name=appsink async=false enable-last-sample=false sync=true"; pipe = fmt::format(appsink_pipe, m_devnode, w, h, format, vscale); SPDLOG_DEBUG(pipe); /* Make sure we don't leave orphan references */ stop(); GError* error = nullptr; m_pipeline = gst_parse_launch(pipe.c_str(), &error); if (!m_pipeline) { m_interface.on_error.invoke(fmt::format("failed to create pipeline: {}", error->message)); return false; } // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) m_appsink = gst_bin_get_by_name(GST_BIN(m_pipeline), "appsink"); if (!m_appsink) { m_interface.on_error.invoke("failed to get app sink element"); return false; } // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) g_object_set(G_OBJECT(m_appsink), "emit-signals", TRUE, "sync", TRUE, nullptr); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) g_signal_connect(m_appsink, "new-sample", G_CALLBACK(on_new_buffer), this); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast) GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_pipeline)); gst_bus_add_watch(bus, &bus_callback, this); gst_object_unref(bus); int ret = gst_element_set_state(m_pipeline, GST_STATE_PLAYING); if (ret == GST_STATE_CHANGE_FAILURE) { m_interface.on_error.invoke("failed to set pipeline to play state"); stop(); return false; } return true; } void CameraImpl::scale(float scalex, float scaley) { m_interface.resize(Size(m_rect.width() * scalex, m_rect.height() * scaley)); } void CameraImpl::stop() { if (m_pipeline) { GstStateChangeReturn ret = gst_element_set_state(m_pipeline, GST_STATE_NULL); if (GST_STATE_CHANGE_FAILURE == ret) { spdlog::error("set pipeline to NULL state failed"); } g_object_unref(m_pipeline); m_pipeline = nullptr; } } CameraImpl::~CameraImpl() { if (m_gmain_loop) { /* * check loop is running to avoid race condition when stop is called too early */ if (g_main_loop_is_running(m_gmain_loop)) { //stop loop and wait g_main_loop_quit(m_gmain_loop); } m_gmain_thread.join(); g_main_loop_unref(m_gmain_loop); } } std::tuple<std::string, std::string, std::string, std::vector<std::tuple<int, int>>> get_camera_device_caps(const std::string& dev_name, BusCallback bus_callback, void* instance) { std::string devnode; GstDeviceMonitor* monitor = gst_device_monitor_new(); GstBus* bus = gst_device_monitor_get_bus(monitor); gst_bus_add_watch(bus, bus_callback, instance); gst_object_unref(bus); GstCaps* caps = gst_caps_new_empty_simple("video/x-raw"); gst_device_monitor_add_filter(monitor, "Video/Source", caps); gst_caps_unref(caps); std::string caps_name; std::string caps_format; std::vector<std::tuple<int, int>> resolutions; if (gst_device_monitor_start(monitor)) { GList* devlist = gst_device_monitor_get_devices(monitor); for (GList* i = g_list_first(devlist); i; i = g_list_next(i)) { auto device = static_cast<GstDevice*>(i->data); if (device == nullptr) continue; // Probe all device properties and store them internally: GstStringHandle display_name{gst_device_get_display_name(device)}; SPDLOG_DEBUG("name : {}", display_name.get()); GstStringHandle dev_string{gst_device_get_device_class(device)}; SPDLOG_DEBUG("class : {}", dev_string.get()); GstCaps* caps = gst_device_get_caps(device); if (caps) { resolutions.clear(); int size = gst_caps_get_size(caps); SPDLOG_DEBUG("caps : "); for (int j = 0; j < size; ++j) { GstStructure* s = gst_caps_get_structure(caps, j); std::string name = std::string(gst_structure_get_name(s)); if (name == "video/x-raw") { int width = 0; int height = 0; caps_name = name; gst_structure_get_int(s, "width", &width); gst_structure_get_int(s, "height", &height); caps_format = std::string(gst_structure_get_string(s, "format")); resolutions.emplace_back(std::make_tuple(width, height)); SPDLOG_DEBUG("{}, format=(string){}, width=(int){}, " "height=(int){}", caps_name, caps_format, width, height); } } if (!resolutions.empty()) { // sort by camera width std::sort(resolutions.begin(), resolutions.end(), []( std::tuple<int, int>& t1, std::tuple<int, int>& t2) { return std::get<0>(t1) < std::get<0>(t2); }); } gst_caps_unref(caps); } GstStructure* props = gst_device_get_properties(device); if (props) { SPDLOG_DEBUG("device properties: {}", gst_structure_to_string(props)); devnode = std::string(gst_structure_get_string(props, "device.path")); gst_structure_free(props); if (devnode == dev_name) break; } } g_list_free(devlist); } SPDLOG_DEBUG("camera device node : {}", devnode); return std::make_tuple(devnode, caps_name, caps_format, resolutions); } } } }
[ "joshua.henderson@microchip.com" ]
joshua.henderson@microchip.com
2f9185fb2113e3cb2cc1f8807c3431ba78cdc16b
79c9ab2cf119c106c3c42353e766750bbcf497fa
/hdu/4734.cpp
8730185795f41d64d3c5922d5607ea371078d687
[]
no_license
cen5bin/Algorithm-Problem
12e17dd300f69fd8121ea3f5be2f1d1a61cb3485
00099428c1b4199f3a6dc286c43e91acf94c58b0
refs/heads/master
2021-01-17T13:35:00.819979
2016-11-30T03:05:49
2016-11-30T03:05:49
22,202,801
1
1
null
null
null
null
UTF-8
C++
false
false
1,063
cpp
#include <cstdio> #include <cstring> int dp[12][5000]; int digit[12]; int A, B; void init() { memset(dp, -1, sizeof(dp)); } int dfs(int pos, int pre, bool limit) { if (pos == -1) return pre >= 0 ? 1 : 0; if (pre < 0) return 0; if (!limit && dp[pos][pre] != -1) return dp[pos][pre]; int end = limit ? digit[pos] : 9; int ret = 0; for (int i = 0; i <= end; ++i) ret += dfs(pos-1, pre - (1<<pos) * i, limit && i == end); if (!limit) dp[pos][pre] = ret; return ret; } int solve(int n) { int fa = 0; int tmp = 1; while (A) { fa += A % 10 * tmp; A /= 10; tmp <<= 1; } A = fa; //printf("%d\n", A); memset(digit, 0, sizeof(digit)); int len = 0; while (n) { digit[len++] = n % 10; n /= 10; } return dfs(len-1, A, 1); } int main() { init(); int T; scanf("%d", &T); while (T--) { scanf("%d%d", &A, &B); static int cas = 1; printf("Case #%d: %d\n", cas++, solve(B)); } return 0; }
[ "cen5bin@163.com" ]
cen5bin@163.com
22931e0fc056883f0c7038dff3b528ed09f27abf
de6a5f131933fd8bcc49d02f351ddc0ffcf2c279
/StealthGameTest/Source/FPSGame/Public/FPSAIGuard.h
d215153d29fb6634ffa941427a9dfd0659aeadce
[]
no_license
GabrieleAncona/StealthGameTest
79402784e419957b7aa68e696656378453df621e
0b2bd1ddb4e82eb7b6d6f75f333455b518919b49
refs/heads/master
2023-08-28T06:21:02.990406
2021-10-21T01:05:02
2021-10-21T01:05:02
408,923,939
1
0
null
null
null
null
UTF-8
C++
false
false
1,837
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Character.h" #include "FPSAIGuard.generated.h" class UPawnSensingComponent; UENUM(BlueprintType) enum class EAIState : uint8 { Idle, Suspicious, Alerted }; UCLASS() class FPSGAME_API AFPSAIGuard : public ACharacter { GENERATED_BODY() public: // Sets default values for this character's properties AFPSAIGuard(); protected: // Called when the game starts or when spawned virtual void BeginPlay() override; UPROPERTY(VisibleAnywhere, Category = "Components") UPawnSensingComponent* PawnSensingComp; UFUNCTION() void OnPawnSeen(APawn* SeenPawn); UFUNCTION() void OnNoiseHeard(APawn* NoiseInstigator, const FVector& Location, float Volume); FRotator OriginalRotation; UFUNCTION() void ResetOrientation(); FTimerHandle TimerHandle_ResetOrientation; UPROPERTY(ReplicatedUsing=OnRep_GuardState) EAIState GuardState; UFUNCTION() void OnRep_GuardState(); void SetGuardState(EAIState NewState); UFUNCTION(BlueprintImplementableEvent, Category = "AI") void OnStateChanged(EAIState NewState); public: // Called every frame virtual void Tick(float DeltaTime) override; protected: // CHALLENGE CODE /* Let the guard go on patrol */ UPROPERTY(EditInstanceOnly, Category = "AI") bool bPatrol; /* First of two patrol points to patrol between */ UPROPERTY(EditInstanceOnly, Category = "AI", meta = (EditCondition="bPatrol")) AActor* FirstPatrolPoint; /* Second of two patrol points to patrol between */ UPROPERTY(EditInstanceOnly, Category = "AI", meta = (EditCondition = "bPatrol")) AActor* SecondPatrolPoint; // The current point the actor is either moving to or standing at AActor* CurrentPatrolPoint; void MoveToNextPatrolPoint(); };
[ "gabry.ancona@gmail.com" ]
gabry.ancona@gmail.com
16fd3dca7b1347f279d052bbd52cc9c5165c1c83
3a25498190f3d30b67220df5ae52988802d70070
/engine/core/RMObject.hpp
14c4982c006fdf840817253967534025d0b0cb2a
[ "MIT" ]
permissive
vitali-kurlovich/RMPropeller
c80108ddeab9e8df74da87a33fbafc65490b266c
6b914957000dc5bd35319828b7e2608ceb2c92ca
refs/heads/master
2020-04-03T22:43:01.203168
2017-03-13T22:20:52
2017-03-13T22:20:52
56,176,234
0
0
null
null
null
null
UTF-8
C++
false
false
1,188
hpp
// // Created by Vitali Kurlovich on 8/24/16. // #ifndef RMPROPELLER_RMOBJECT_HPP #define RMPROPELLER_RMOBJECT_HPP #include "../common/RMType.hpp" namespace rmengine { class RMObject { private: int32 _refCount{1}; //uint32 _uid{0}; public: inline friend void rmRetain(RMObject** object) noexcept { (*object)->_refCount++; } inline friend void rmRetain(RMObject* object) noexcept { object->_refCount++; } inline friend void rmRelease(RMObject** object) { if ((*object)->_refCount != 1) { (*object)->_refCount--; } else { delete (*object); (*object) = nullptr; } } inline friend void rmRelease(RMObject* object) { if ((object)->_refCount != 1) { (object)->_refCount--; } else { delete (object); } } constexpr friend uint32 rmRetainCount(const RMObject* object) noexcept { return object->_refCount; } }; } #endif //RMPROPELLER_RMOBJECT_HPP
[ "vitalikurlovich@gmail.com" ]
vitalikurlovich@gmail.com
043331e5f5764b54fdd6f194cfab2e7687922686
21d6b37c5c55b5f8f712b8455224854bdeafd3b2
/twib/ResultError.hpp
9c767a59474d8c8d2c409822549601bdaa94f5af
[]
no_license
npdmfixup/twili
95418f93c49286750760ab7eccb00cba762eafde
8a3694116e269422e2534fd9683be7cb4bca155f
refs/heads/master
2020-03-30T05:20:43.886771
2018-09-24T01:05:21
2018-09-24T01:05:21
150,793,531
0
0
null
2018-09-28T20:54:02
2018-09-28T20:54:01
null
UTF-8
C++
false
false
335
hpp
#pragma once #include<stdexcept> #include<string> namespace twili { namespace twib { class ResultError : public std::runtime_error { public: ResultError(uint32_t result); virtual const char *what() const noexcept override; const uint32_t code; private: std::string description; }; } // namespace twib } // namespace twili
[ "xenotoad@xenotoad.net" ]
xenotoad@xenotoad.net
90e1470327c9dc3ac6a9c63201c27dec02315802
c62e654417f64705fc54aca4759b54c73ac756f1
/sources/codeforces/practice/579/A.cpp
f8e19f08aee3b51e3eef87ad1fecdd9d23eebeb7
[]
no_license
miguelmartin75/cp-problems
9c56b14e61808650c5ad103ec1024223cfbfc26b
fbafdf7c4e70c18f003e54d4f657980e6e2948e3
refs/heads/master
2021-08-17T21:46:31.237678
2021-04-03T17:59:08
2021-04-03T17:59:08
80,083,158
0
0
null
null
null
null
UTF-8
C++
false
false
238
cpp
#include <iostream> using namespace std; int main() { int x; cin >> x; int result = 0; while(x > 0) { if(x & 1) { ++result; } x >>= 1; } cout << result << endl; }
[ "miguel@miguel-martin.com" ]
miguel@miguel-martin.com
2aa695d0d8af69e8c7c2d4affa8b6e4d756c7cac
7cd1e7ea85736a930416909e6b9e82a7d5f3c346
/New Project-20161129/Newfile.cpp
0f7ad56d9861b11099a859de20e0395bf20689a3
[]
no_license
vkharlamov/codingground
6be34cf70633381880f4469d34743022e9babd9f
3bf0fc2f536e63d4af64818a3d9a9d1e053c8bab
refs/heads/master
2020-06-16T16:14:46.922486
2016-11-29T13:41:37
2016-11-29T13:41:37
75,085,082
0
0
null
null
null
null
UTF-8
C++
false
false
4,507
cpp
/* 24.12.2008 last modification: 26.06.2013 Copyright (c) 2008-2013 by Siegfried Koepf This file is distributed under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. For information on usage and redistribution and for a disclaimer of all warranties, see the file COPYING in this distribution. testing gen_comb_norep_lex_init() and gen_comb_norep_lex_next() compile gcc -o comb_norep_lex_example comb_norep_lex_example.c comb_norep_lex.c */ #include "string.h" #include "stdio.h" #include <algorithm> #include <vector> #include <stack> #include <stdlib.h> using namespace std; //include "_generate.h" /* Combinatorial generation functions public interfaces */ #ifndef _GENERATE_H #define _GENERATE_H //return values of generation functions #define GEN_NEXT 0 //ok, print and continue #define GEN_TERM 1 //ok, terminate #define GEN_EMPTY 2 //ok, print EMPTY SET and continue #define GEN_ERROR 3 //an error occured, print an error message and terminate //combinatorial generation functions int gen_comb_norep_init(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_comb_norep_next(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_comb_rep_init(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_comb_rep_next(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_perm_rep_init(const unsigned char n); int gen_perm_rep_next(unsigned char *vector, const unsigned char n); int gen_vari_rep_init(unsigned char *vector, const unsigned char m, const unsigned char n); int gen_vari_rep_next(unsigned char *vector, const unsigned char m, const unsigned char n); int gen_neck_init(unsigned char *vector, const unsigned char m, const unsigned char n); int gen_neck_next(unsigned char *vector, const unsigned char m, const unsigned char n); int gen_part_init(unsigned char *vector, const unsigned char n, unsigned char *k); int gen_part_next(unsigned char *vector, unsigned char *k); int gen_k_part_init(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_k_part_next(unsigned char *vector, const unsigned char k); int gen_k_comp_init(unsigned char *vector, const unsigned char n, const unsigned char k); int gen_k_comp_next(unsigned char *vector, const unsigned char k); #endif int gen_comb_norep_lex_init(unsigned char *vector, const unsigned char n, const unsigned char k) { int j; //index //test for special cases if(k > n) return(GEN_ERROR); if(k == 0) return(GEN_EMPTY); //initialize: vector[0, ..., k - 1] are 0, ..., k - 1 for(j = 0; j < k; j++) vector[j] = j; return(GEN_NEXT); } int gen_comb_norep_lex_next(unsigned char *vector, const unsigned char n, const unsigned char k) { int j; //index //easy case, increase rightmost element if(vector[k - 1] < n - 1) { vector[k - 1]++; return(GEN_NEXT); } //find rightmost element to increase for(j = k - 2; j >= 0; j--) if(vector[j] < n - k + j) break; //terminate if vector[0] == n - k if(j < 0) return(GEN_TERM); //increase vector[j]++; //set right-hand elements while(j < k - 1) { vector[j + 1] = vector[j] + 1; j++; } return(GEN_NEXT); } int main(void) { unsigned char n = 5; //length of alphabet unsigned char k = 3; //length of figures unsigned char *vector = NULL; //where the current figure is stored int gen_result; //return value of generation functions unsigned int set_counter; //counting generated sequences int x; //iterator //alloc memory for vector vector = (unsigned char *)malloc(sizeof(unsigned char) * k); if(vector == NULL) { fprintf(stderr, "error: insufficient memory\n"); exit(EXIT_FAILURE); } set_counter = 0; printf("comb_norep_lex(%u, %u)\n", n, k); //initialize gen_result = gen_comb_norep_lex_init(vector, n, k); if(gen_result == GEN_ERROR) { fprintf(stderr, "error: couldn't initialize\n"); return(EXIT_FAILURE); } if(gen_result == GEN_EMPTY) { set_counter++; printf("{} (%u)\n", set_counter); } //generate all successors while(gen_result == GEN_NEXT) { set_counter++; for(x = 0; x < k; x++) printf("%u ", vector[x]); printf("(%u)\n", set_counter); gen_result = gen_comb_norep_lex_next(vector, n, k); } return(EXIT_SUCCESS); }
[ "vladimir.sevastopol@gmail.com" ]
vladimir.sevastopol@gmail.com
d630af31d6c2b8819e010eb4bb880813c3be631e
33f0b5041dd2dd40200d03ecbca65131a13cf15b
/mnum_bissection/mnum_bissection/mnum_bissection.cpp
904067feb4feaba5cf57598582b0d16020b032de
[]
no_license
ricardoleitee/MNUM
a51a34edf2ef88e7b13b626801917b4e03f22fe7
f55da6abfa53ab424f2ae5322fca886076ee3051
refs/heads/master
2021-01-23T07:20:34.020532
2014-11-16T19:57:38
2014-11-16T19:57:38
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
1,937
cpp
#include <iostream> #include <iomanip> #include <time.h> #include <cmath> using namespace std; //Problema da pag. 128, falling parachutist problem //Resolvido via método da bissecção float fx(float x){ //return 667.38/x * (1-exp(-0.146843*x))-40; return x*x*x*x + 2*x*x*x - x - 1; } float xu(float xl){ do { float fxl = fx(xl); float fxu = fx(xl+1); if (fxl*fxu<0) return xl; else xl++; } while (true); } float bissection(float xl, float xu){ return (xl+xu)/2; } /*A função stop contém o critério de paragem definido no livro, utilizando a função |Ea| = | (xroot(new) - xroot(old)) / xroot(new) | * 100% no entanto, nas aulas foi utilizado o método dif(x) = | f(xroot(old)) - f(xroot(new)) | < 1e-7 cujo resultado da aproximação não é tão próximo do valor real da raiz como o da primeira função, podendo até ser definido um erro aproximado (Ea) de 0, obtendo uma aproximação correcta da raiz a n casas decimais */ float stop(float xrn, float xro){ return abs((xrn-xro)/xrn)*100; } int main(){ float xl=0,xup=0,xr=0,xro=0; xl = 0; xup = 1; cout << "xl = " << xl << endl; unsigned int i=0; do { cout << "Iteration: " << i << endl; i++; xr = bissection(xl,xup); cout << "|Ea| = " << setprecision(4) << fixed << stop(xr,xro) << endl; float et = abs(((0.86674-xr)/0.86674)*100); cout << "Et = " << setprecision(4) << fixed << et << endl; if (stop(xr,xro)==0) break; xro = xr; cout << "xl = " << setprecision(4) << fixed << xl << endl; cout << "xu = " << setprecision(4) << fixed << xup << endl; cout << "xr = " << setprecision(4) << fixed << xr << endl; cout << "----- End Iteration -----" << endl; if (fx(xl)*fx(xr)<0) xup = xr; if (fx(xl)*fx(xr)>0) xl = xr; } while (/*abs(fx(xl)-fx(xr))<1e-7*/ true); cout << "Root: " << setprecision(4) << fixed << xr <<endl; int t = clock(); cout << "Time Elapsed: " << t; cin.get(); cin.ignore(); return 0; }
[ "ricardo.leitee12@gmail.com" ]
ricardo.leitee12@gmail.com
6e2e761ddfaa55fc2965adae2eed28dc41d70279
900e651d100f8130d93cf7378feba2df3447f8b9
/C++Version/Dog.h
a60a563a7f2b49d7ec37da701c889297313d3d98
[]
no_license
xy008areshsu/Design-Pattern-Project
85d1abba1994f1cbe5e82358bb071129dabb2dac
63f24fd38268190fcb8abd2300db4f89aa2b6efa
refs/heads/master
2020-04-14T22:27:14.217343
2015-04-05T04:21:45
2015-04-05T04:21:45
29,419,467
0
0
null
null
null
null
UTF-8
C++
false
false
647
h
#ifndef DOG_H #define DOG_H #include "Animal.h" #include <string> #include <iostream> class Dog : public Animal { public: Dog(const std::string name, double height, int weight, const std::string& dog_stuff): Animal{name, height, weight}, _dog_stuff {dog_stuff} {} // Dog(const Dog& rhs): // Animal {rhs.get_name(), rhs.get_height(), rhs.get_weight()}, _dog_stuff {rhs.get_stuff()} // {} void dig_hole() const{ std::cout << "Dug a hole" << std::endl; } void set_stuff(const std::string& dog_stuff) { _dog_stuff = dog_stuff; } std::string get_stuff() const {return _dog_stuff;} private: std::string _dog_stuff; }; #endif
[ "xy008areshsu@gmail" ]
xy008areshsu@gmail
97f75e5fad3eaeed8a7d2c32466a09eddaf625e1
3059e62977233086c566b668cd9821986eb44dad
/3dmath/math3d.cpp
96ef8b09d8c2a3ebd13a6efaa33d33af606a44e4
[]
no_license
xandrock/xandrock-common-library
f3c015d181d210617ebfca0175cf417bc9f4bec2
192e5e2e13a903748fa6ac699a588751efaff5e3
refs/heads/master
2021-01-01T16:12:32.175249
2015-01-21T03:33:38
2015-01-21T03:33:38
32,298,042
0
0
null
null
null
null
UTF-8
C++
false
false
36,966
cpp
// Math3d.c // Implementation of non-inlined functions in the Math3D Library // Richard S. Wright Jr. // These are pretty portable #include <math.h> #include "math3d.h" float ReciprocalSqrt( float x ) { long i; float y, r; y = x * 0.5f; i = *(long *)( &x ); i = 0x5f3759df - ( i >> 1 ); r = *(float *)( &i ); r = r * ( 1.5f - r * r * y ); return r; } void m3dMatToQuat( float q[4], const M3DMatrix44f m) { if ( m[0] + m[1*4+1] + m[2*4+2] > 0.0f ) { float t = + m[0] + m[1*4+1] + m[2*4+2] + 1.0f; float s = ReciprocalSqrt( t ) * 0.5f; q[3] = s * t; q[2] = ( m[1*4+0] - m[0*4+1] ) * s; q[1] = ( m[0*4+2] - m[2*4+0] ) * s; q[0] = ( m[2*4+1] - m[1*4+2] ) * s; }else if( m[0*4+0] > m[1*4+1] && m[0*4+0] > m[2*4+2] ) { float t = + m[0+0*4] - m[1+1*4] - m[2+2*4] + 1.0f; float s = ReciprocalSqrt( t ) * 0.5f; q[0] = s * t; q[1] = ( m[1*4+0] + m[0*4+1] ) * s; q[2] = ( m[0*4+2] + m[2*4+0] ) * s; q[3] = ( m[2*4+1] - m[1*4+2] ) * s; }else if( m[1*4+1] > m[2*4+2] ) { float t = - m[0*4+0] + m[1*4+1] - m[2*4+2] + 1.0f; float s = ReciprocalSqrt( t ) * 0.5f; q[1] = s * t; q[0] = ( m[1*4+0] + m[0*4+1] ) * s; q[3] = ( m[0*4+2] - m[2*4+0] ) * s; q[2] = ( m[2*4+1] + m[1*4+2] ) * s; } else { float t = - m[0*4+0] - m[1*4+1] + m[2*4+2] + 1.0f; float s = ReciprocalSqrt( t ) * 0.5f; q[2] = s * t; q[3] = ( m[1*4+0] - m[0*4+1] ) * s; q[0] = ( m[0*4+2] + m[2*4+0] ) * s; q[1] = ( m[2*4+1] + m[1*4+2] ) * s; } } void m3dRotationMatrix44(M3DMatrix44f m, M3DVector3f angles) { float angle; float sr, sp, sy, cr, cp, cy; angle = angles[2]; sy = sin(angle); cy = cos(angle); angle = angles[1]; sp = sin(angle); cp = cos(angle); angle = angles[0]; sr = sin(angle); cr = cos(angle); // matrix = (Z * Y) * X m[0] = cp*cy; m[4] = cp*sy; m[8] = -sp; m[12] = 0.0f; m[1] = sr*sp*cy+cr*-sy; m[5] = sr*sp*sy+cr*cy; m[9] = sr*cp; m[13] = 0.0f; m[2] = (cr*sp*cy+-sr*-sy); m[6] = (cr*sp*sy+-sr*cy); m[10] = cr*cp; m[14] = 0.0f; m[3] = 0.0; m[7] = 0.0; m[11] = 0.0; m[15] = 1.0f; } void m3dRotationMatrix44(M3DMatrix44d m, M3DVector3d angles) { float angle; float sr, sp, sy, cr, cp, cy; angle = angles[2]; sy = sin(angle); cy = cos(angle); angle = angles[1]; sp = sin(angle); cp = cos(angle); angle = angles[0]; sr = sin(angle); cr = cos(angle); // matrix = (Z * Y) * X m[0] = cp*cy; m[4] = cp*sy; m[8] = -sp; m[12] = 0.0f; m[1] = sr*sp*cy+cr*-sy; m[5] = sr*sp*sy+cr*cy; m[9] = sr*cp; m[13] = 0.0f; m[2] = (cr*sp*cy+-sr*-sy); m[6] = (cr*sp*sy+-sr*cy); m[10] = cr*cp; m[14] = 0.0f; m[3] = 0.0; m[7] = 0.0; m[11] = 0.0; m[15] = 1.0f; } void m3dQuaternionMatrix( const float quaternion[4], M3DMatrix44f matrix ) { matrix[0] = 1.0f - 2.0f * quaternion[1] * quaternion[1] - 2.0f * quaternion[2] * quaternion[2]; matrix[4] = 2.0f * quaternion[0] * quaternion[1] + 2.0f * quaternion[3] * quaternion[2]; matrix[8] = 2.0f * quaternion[0] * quaternion[2] - 2.0f * quaternion[3] * quaternion[1]; matrix[1] = 2.0f * quaternion[0] * quaternion[1] - 2.0f * quaternion[3] * quaternion[2]; matrix[5] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[2] * quaternion[2]; matrix[9] = 2.0f * quaternion[1] * quaternion[2] + 2.0f * quaternion[3] * quaternion[0]; matrix[2] = 2.0f * quaternion[0] * quaternion[2] + 2.0f * quaternion[3] * quaternion[1]; matrix[6] = 2.0f * quaternion[1] * quaternion[2] - 2.0f * quaternion[3] * quaternion[0]; matrix[10] = 1.0f - 2.0f * quaternion[0] * quaternion[0] - 2.0f * quaternion[1] * quaternion[1]; } //////////////////////////////////////////////////////////// // LoadIdentity // For 3x3 and 4x4 float and double matricies. // 3x3 float void m3dLoadIdentity33(M3DMatrix33f m) { // Don't be fooled, this is still column major static M3DMatrix33f identity = { 1.0f, 0.0f, 0.0f , 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; memcpy(m, identity, sizeof(M3DMatrix33f)); } // 3x3 double void m3dLoadIdentity33(M3DMatrix33d m) { // Don't be fooled, this is still column major static M3DMatrix33d identity = { 1.0, 0.0, 0.0 , 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }; memcpy(m, identity, sizeof(M3DMatrix33d)); } // 4x4 float void m3dLoadIdentity44(M3DMatrix44f m) { // Don't be fooled, this is still column major static M3DMatrix44f identity = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }; memcpy(m, identity, sizeof(M3DMatrix44f)); } // 4x4 double void m3dLoadIdentity44(M3DMatrix44d m) { static M3DMatrix44d identity = { 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; memcpy(m, identity, sizeof(M3DMatrix44d)); } //////////////////////////////////////////////////////////////////////// // Return the square of the distance between two points // Should these be inlined...? float m3dGetDistanceSquared(const M3DVector3f u, const M3DVector3f v) { float x = u[0] - v[0]; x = x*x; float y = u[1] - v[1]; y = y*y; float z = u[2] - v[2]; z = z*z; return (x + y + z); } // Ditto above, but for doubles double m3dGetDistanceSquared(const M3DVector3d u, const M3DVector3d v) { double x = u[0] - v[0]; x = x*x; double y = u[1] - v[1]; y = y*y; double z = u[2] - v[2]; z = z*z; return (x + y + z); } #define A(row,col) a[(col<<2)+row] #define B(row,col) b[(col<<2)+row] #define P(row,col) product[(col<<2)+row] /////////////////////////////////////////////////////////////////////////////// // Multiply two 4x4 matricies void m3dMatrixMultiply44(M3DMatrix44f product, const M3DMatrix44f a, const M3DMatrix44f b ) { for (int i = 0; i < 4; i++) { float ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); } } // Ditto above, but for doubles void m3dMatrixMultiply44(M3DMatrix44d product, const M3DMatrix44d a, const M3DMatrix44d b ) { for (int i = 0; i < 4; i++) { double ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3); P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0); P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1); P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2); P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3); } } #undef A #undef B #undef P #define A33(row,col) a[(col*3)+row] #define B33(row,col) b[(col*3)+row] #define P33(row,col) product[(col*3)+row] /////////////////////////////////////////////////////////////////////////////// // Multiply two 3x3 matricies void m3dMatrixMultiply33(M3DMatrix33f product, const M3DMatrix33f a, const M3DMatrix33f b ) { for (int i = 0; i < 3; i++) { float ai0=A33(i,0), ai1=A33(i,1), ai2=A33(i,2); P33(i,0) = ai0 * B33(0,0) + ai1 * B33(1,0) + ai2 * B33(2,0); P33(i,1) = ai0 * B33(0,1) + ai1 * B33(1,1) + ai2 * B33(2,1); P33(i,2) = ai0 * B33(0,2) + ai1 * B33(1,2) + ai2 * B33(2,2); } } // Ditto above, but for doubles void m3dMatrixMultiply33(M3DMatrix33d product, const M3DMatrix33d a, const M3DMatrix33d b ) { for (int i = 0; i < 3; i++) { double ai0=A33(i,0), ai1=A33(i,1), ai2=A33(i,2); P33(i,0) = ai0 * B33(0,0) + ai1 * B33(1,0) + ai2 * B33(2,0); P33(i,1) = ai0 * B33(0,1) + ai1 * B33(1,1) + ai2 * B33(2,1); P33(i,2) = ai0 * B33(0,2) + ai1 * B33(1,2) + ai2 * B33(2,2); } } #undef A33 #undef B33 #undef P33 #define M33(row,col) m[col*3+row] /////////////////////////////////////////////////////////////////////////////// // Creates a 3x3 rotation matrix, takes radians NOT degrees void m3dRotationMatrix33(M3DMatrix33f m, float angle, float x, float y, float z) { float mag, s, c; float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = float(sin(angle)); c = float(cos(angle)); mag = float(sqrt( x*x + y*y + z*z )); // Identity matrix if (mag == 0.0f) { m3dLoadIdentity33(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M33(0,0) = (one_c * xx) + c; M33(0,1) = (one_c * xy) - zs; M33(0,2) = (one_c * zx) + ys; M33(1,0) = (one_c * xy) + zs; M33(1,1) = (one_c * yy) + c; M33(1,2) = (one_c * yz) - xs; M33(2,0) = (one_c * zx) - ys; M33(2,1) = (one_c * yz) + xs; M33(2,2) = (one_c * zz) + c; } #undef M33 /////////////////////////////////////////////////////////////////////////////// // Creates a 4x4 rotation matrix, takes radians NOT degrees void m3dRotationMatrix44(M3DMatrix44f m, float angle, float x, float y, float z) { float mag, s, c; float xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = float(sin(angle)); c = float(cos(angle)); mag = float(sqrt( x*x + y*y + z*z )); // Identity matrix if (mag == 0.0f) { m3dLoadIdentity44(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*4+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(0,3) = 0.0f; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(1,3) = 0.0f; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; M(2,3) = 0.0f; M(3,0) = 0.0f; M(3,1) = 0.0f; M(3,2) = 0.0f; M(3,3) = 1.0f; #undef M } /////////////////////////////////////////////////////////////////////////////// // Ditto above, but for doubles void m3dRotationMatrix33(M3DMatrix33d m, double angle, double x, double y, double z) { double mag, s, c; double xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = sin(angle); c = cos(angle); mag = sqrt( x*x + y*y + z*z ); // Identity matrix if (mag == 0.0) { m3dLoadIdentity33(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*3+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0 - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; #undef M } /////////////////////////////////////////////////////////////////////////////// // Creates a 4x4 rotation matrix, takes radians NOT degrees void m3dRotationMatrix44(M3DMatrix44d m, double angle, double x, double y, double z) { double mag, s, c; double xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c; s = sin(angle); c = cos(angle); mag = sqrt( x*x + y*y + z*z ); // Identity matrix if (mag == 0.0) { m3dLoadIdentity44(m); return; } // Rotation matrix is normalized x /= mag; y /= mag; z /= mag; #define M(row,col) m[col*4+row] xx = x * x; yy = y * y; zz = z * z; xy = x * y; yz = y * z; zx = z * x; xs = x * s; ys = y * s; zs = z * s; one_c = 1.0f - c; M(0,0) = (one_c * xx) + c; M(0,1) = (one_c * xy) - zs; M(0,2) = (one_c * zx) + ys; M(0,3) = 0.0; M(1,0) = (one_c * xy) + zs; M(1,1) = (one_c * yy) + c; M(1,2) = (one_c * yz) - xs; M(1,3) = 0.0; M(2,0) = (one_c * zx) - ys; M(2,1) = (one_c * yz) + xs; M(2,2) = (one_c * zz) + c; M(2,3) = 0.0; M(3,0) = 0.0; M(3,1) = 0.0; M(3,2) = 0.0; M(3,3) = 1.0; #undef M } // Lifted from Mesa /* * Compute inverse of 4x4 transformation matrix. * Code contributed by Jacques Leroy jle@star.be * Return GL_TRUE for success, GL_FALSE for failure (singular matrix) */ bool m3dInvertMatrix44(M3DMatrix44f dst, const M3DMatrix44f src ) { #define SWAP_ROWS(a, b) { float *_tmp = a; (a)=(b); (b)=_tmp; } #define MAT(m,r,c) (m)[(c)*4+(r)] float wtmp[4][8]; float m0, m1, m2, m3, s; float *r0, *r1, *r2, *r3; r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; r0[0] = MAT(src,0,0), r0[1] = MAT(src,0,1), r0[2] = MAT(src,0,2), r0[3] = MAT(src,0,3), r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, r1[0] = MAT(src,1,0), r1[1] = MAT(src,1,1), r1[2] = MAT(src,1,2), r1[3] = MAT(src,1,3), r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, r2[0] = MAT(src,2,0), r2[1] = MAT(src,2,1), r2[2] = MAT(src,2,2), r2[3] = MAT(src,2,3), r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, r3[0] = MAT(src,3,0), r3[1] = MAT(src,3,1), r3[2] = MAT(src,3,2), r3[3] = MAT(src,3,3), r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; /* choose pivot - or die */ if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return false; /* eliminate first variable */ m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; s = r0[4]; if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r0[5]; if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r0[6]; if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r0[7]; if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return false; /* eliminate second variable */ m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return false; /* eliminate third variable */ m3 = r3[2]/r2[2]; r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7]; /* last check */ if (0.0 == r3[3]) return false; s = 1.0f/r3[3]; /* now back substitute row 3 */ r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; m2 = r2[3]; /* now back substitute row 2 */ s = 1.0f/r2[2]; r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); m1 = r1[3]; r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; m0 = r0[3]; r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; m1 = r1[2]; /* now back substitute row 1 */ s = 1.0f/r1[1]; r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); m0 = r0[2]; r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; m0 = r0[1]; /* now back substitute row 0 */ s = 1.0f/r0[0]; r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); MAT(dst,0,0) = r0[4]; MAT(dst,0,1) = r0[5], MAT(dst,0,2) = r0[6]; MAT(dst,0,3) = r0[7], MAT(dst,1,0) = r1[4]; MAT(dst,1,1) = r1[5], MAT(dst,1,2) = r1[6]; MAT(dst,1,3) = r1[7], MAT(dst,2,0) = r2[4]; MAT(dst,2,1) = r2[5], MAT(dst,2,2) = r2[6]; MAT(dst,2,3) = r2[7], MAT(dst,3,0) = r3[4]; MAT(dst,3,1) = r3[5], MAT(dst,3,2) = r3[6]; MAT(dst,3,3) = r3[7]; return true; #undef MAT #undef SWAP_ROWS } // Ditto above, but for doubles bool m3dInvertMatrix44(M3DMatrix44d dst, const M3DMatrix44d src) { #define SWAP_ROWS(a, b) { double *_tmp = a; (a)=(b); (b)=_tmp; } #define MAT(m,r,c) (m)[(c)*4+(r)] double wtmp[4][8]; double m0, m1, m2, m3, s; double *r0, *r1, *r2, *r3; r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3]; r0[0] = MAT(src,0,0), r0[1] = MAT(src,0,1), r0[2] = MAT(src,0,2), r0[3] = MAT(src,0,3), r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0, r1[0] = MAT(src,1,0), r1[1] = MAT(src,1,1), r1[2] = MAT(src,1,2), r1[3] = MAT(src,1,3), r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0, r2[0] = MAT(src,2,0), r2[1] = MAT(src,2,1), r2[2] = MAT(src,2,2), r2[3] = MAT(src,2,3), r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0, r3[0] = MAT(src,3,0), r3[1] = MAT(src,3,1), r3[2] = MAT(src,3,2), r3[3] = MAT(src,3,3), r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; // choose pivot - or die if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2); if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1); if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return false; // eliminate first variable m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0]; s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s; s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s; s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s; s = r0[4]; if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r0[5]; if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r0[6]; if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r0[7]; if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } // choose pivot - or die if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2); if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return false; // eliminate second variable m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1]; r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2]; r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3]; s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; } s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; } s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; } s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } // choose pivot - or die if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return false; // eliminate third variable m3 = r3[2]/r2[2]; r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4], r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6], r3[7] -= m3 * r2[7]; // last check if (0.0 == r3[3]) return false; s = 1.0f/r3[3]; // now back substitute row 3 r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s; m2 = r2[3]; // now back substitute row 2 s = 1.0f/r2[2]; r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2), r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2); m1 = r1[3]; r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1, r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1; m0 = r0[3]; r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0, r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0; m1 = r1[2]; // now back substitute row 1 s = 1.0f/r1[1]; r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1), r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1); m0 = r0[2]; r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0, r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0; m0 = r0[1]; // now back substitute row 0 s = 1.0f/r0[0]; r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0), r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0); MAT(dst,0,0) = r0[4]; MAT(dst,0,1) = r0[5], MAT(dst,0,2) = r0[6]; MAT(dst,0,3) = r0[7], MAT(dst,1,0) = r1[4]; MAT(dst,1,1) = r1[5], MAT(dst,1,2) = r1[6]; MAT(dst,1,3) = r1[7], MAT(dst,2,0) = r2[4]; MAT(dst,2,1) = r2[5], MAT(dst,2,2) = r2[6]; MAT(dst,2,3) = r2[7], MAT(dst,3,0) = r3[4]; MAT(dst,3,1) = r3[5], MAT(dst,3,2) = r3[6]; MAT(dst,3,3) = r3[7]; return true; #undef MAT #undef SWAP_ROWS return true; } /////////////////////////////////////////////////////////////////////////////////////// // Get Window coordinates, discard Z... void m3dProjectXY(const M3DMatrix44f mModelView, const M3DMatrix44f mProjection, const int iViewPort[4], const M3DVector3f vPointIn, M3DVector2f vPointOut) { M3DVector4f vBack, vForth; memcpy(vBack, vPointIn, sizeof(float)*3); vBack[3] = 1.0f; m3dTransformVector4(vForth, vBack, mModelView); m3dTransformVector4(vBack, vForth, mProjection); if(!m3dCloseEnough(vBack[3], 0.0f, 0.000001f)) { float div = 1.0f / vBack[3]; vBack[0] *= div; vBack[1] *= div; } vPointOut[0] = vBack[0] * 0.5f + 0.5f; vPointOut[1] = vBack[1] * 0.5f + 0.5f; /* Map x,y to viewport */ vPointOut[0] = (vPointOut[0] * iViewPort[2]) + iViewPort[0]; vPointOut[1] = (vPointOut[1] * iViewPort[3]) + iViewPort[1]; } /////////////////////////////////////////////////////////////////////////////////////// // Get window coordinates, we also want Z.... void m3dProjectXYZ(M3DVector3f vPointOut, const M3DMatrix44f mModelView, const M3DMatrix44f mProjection, const int iViewPort[4], const M3DVector3f vPointIn) { M3DVector4f vBack, vForth; memcpy(vBack, vPointIn, sizeof(float)*3); vBack[3] = 1.0f; m3dTransformVector4(vForth, vBack, mModelView); m3dTransformVector4(vBack, vForth, mProjection); if(!m3dCloseEnough(vBack[3], 0.0f, 0.000001f)) { float div = 1.0f / vBack[3]; vBack[0] *= div; vBack[1] *= div; vBack[2] *= div; } vPointOut[0] = vBack[0] * 0.5f + 0.5f; vPointOut[1] = vBack[1] * 0.5f + 0.5f; vPointOut[2] = vBack[2] * 0.5f + 0.5f; /* Map x,y to viewport */ vPointOut[0] = (vPointOut[0] * iViewPort[2]) + iViewPort[0]; vPointOut[1] = (vPointOut[1] * iViewPort[3]) + iViewPort[1]; } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // Misc. Utilities /////////////////////////////////////////////////////////////////////////////// // Calculates the normal of a triangle specified by the three points // p1, p2, and p3. Each pointer points to an array of three floats. The // triangle is assumed to be wound counter clockwise. void m3dFindNormal(M3DVector3f result, const M3DVector3f point1, const M3DVector3f point2, const M3DVector3f point3) { M3DVector3f v1,v2; // Temporary vectors // Calculate two vectors from the three points. Assumes counter clockwise // winding! v1[0] = point1[0] - point2[0]; v1[1] = point1[1] - point2[1]; v1[2] = point1[2] - point2[2]; v2[0] = point2[0] - point3[0]; v2[1] = point2[1] - point3[1]; v2[2] = point2[2] - point3[2]; // Take the cross product of the two vectors to get // the normal vector. m3dCrossProduct(result, v1, v2); } // Ditto above, but for doubles void m3dFindNormal(M3DVector3d result, const M3DVector3d point1, const M3DVector3d point2, const M3DVector3d point3) { M3DVector3d v1,v2; // Temporary vectors // Calculate two vectors from the three points. Assumes counter clockwise // winding! v1[0] = point1[0] - point2[0]; v1[1] = point1[1] - point2[1]; v1[2] = point1[2] - point2[2]; v2[0] = point2[0] - point3[0]; v2[1] = point2[1] - point3[1]; v2[2] = point2[2] - point3[2]; // Take the cross product of the two vectors to get // the normal vector. m3dCrossProduct(result, v1, v2); } ///////////////////////////////////////////////////////////////////////////////////////// // Calculate the plane equation of the plane that the three specified points lay in. The // points are given in clockwise winding order, with normal pointing out of clockwise face // planeEq contains the A,B,C, and D of the plane equation coefficients void m3dGetPlaneEquation(M3DVector4f planeEq, const M3DVector3f p1, const M3DVector3f p2, const M3DVector3f p3) { // Get two vectors... do the cross product M3DVector3f v1, v2; // V1 = p3 - p1 v1[0] = p3[0] - p1[0]; v1[1] = p3[1] - p1[1]; v1[2] = p3[2] - p1[2]; // V2 = P2 - p1 v2[0] = p2[0] - p1[0]; v2[1] = p2[1] - p1[1]; v2[2] = p2[2] - p1[2]; // Unit normal to plane - Not sure which is the best way here m3dCrossProduct(planeEq, v1, v2); m3dNormalizeVector(planeEq); // Back substitute to get D planeEq[3] = -(planeEq[0] * p3[0] + planeEq[1] * p3[1] + planeEq[2] * p3[2]); } // Ditto above, but for doubles void m3dGetPlaneEquation(M3DVector4d planeEq, const M3DVector3d p1, const M3DVector3d p2, const M3DVector3d p3) { // Get two vectors... do the cross product M3DVector3d v1, v2; // V1 = p3 - p1 v1[0] = p3[0] - p1[0]; v1[1] = p3[1] - p1[1]; v1[2] = p3[2] - p1[2]; // V2 = P2 - p1 v2[0] = p2[0] - p1[0]; v2[1] = p2[1] - p1[1]; v2[2] = p2[2] - p1[2]; // Unit normal to plane - Not sure which is the best way here m3dCrossProduct(planeEq, v1, v2); m3dNormalizeVector(planeEq); // Back substitute to get D planeEq[3] = -(planeEq[0] * p3[0] + planeEq[1] * p3[1] + planeEq[2] * p3[2]); } ////////////////////////////////////////////////////////////////////////////////////////////////// // This function does a three dimensional Catmull-Rom curve interpolation. Pass four points, and a // floating point number between 0.0 and 1.0. The curve is interpolated between the middle two points. // Coded by RSW // http://www.mvps.org/directx/articles/catmull/ void m3dCatmullRom3(M3DVector3f vOut, M3DVector3f vP0, M3DVector3f vP1, M3DVector3f vP2, M3DVector3f vP3, float t) { // Unrolled loop to speed things up a little bit... float t2 = t * t; float t3 = t2 * t; // X vOut[0] = 0.5f * ( ( 2.0f * vP1[0]) + (-vP0[0] + vP2[0]) * t + (2.0f * vP0[0] - 5.0f *vP1[0] + 4.0f * vP2[0] - vP3[0]) * t2 + (-vP0[0] + 3.0f*vP1[0] - 3.0f *vP2[0] + vP3[0]) * t3); // Y vOut[1] = 0.5f * ( ( 2.0f * vP1[1]) + (-vP0[1] + vP2[1]) * t + (2.0f * vP0[1] - 5.0f *vP1[1] + 4.0f * vP2[1] - vP3[1]) * t2 + (-vP0[1] + 3.0f*vP1[1] - 3.0f *vP2[1] + vP3[1]) * t3); // Z vOut[2] = 0.5f * ( ( 2.0f * vP1[2]) + (-vP0[2] + vP2[2]) * t + (2.0f * vP0[2] - 5.0f *vP1[2] + 4.0f * vP2[2] - vP3[2]) * t2 + (-vP0[2] + 3.0f*vP1[2] - 3.0f *vP2[2] + vP3[2]) * t3); } ////////////////////////////////////////////////////////////////////////////////////////////////// // This function does a three dimensional Catmull-Rom curve interpolation. Pass four points, and a // floating point number between 0.0 and 1.0. The curve is interpolated between the middle two points. // Coded by RSW // http://www.mvps.org/directx/articles/catmull/ void m3dCatmullRom3(M3DVector3d vOut, M3DVector3d vP0, M3DVector3d vP1, M3DVector3d vP2, M3DVector3d vP3, double t) { // Unrolled loop to speed things up a little bit... double t2 = t * t; double t3 = t2 * t; // X vOut[0] = 0.5 * ( ( 2.0 * vP1[0]) + (-vP0[0] + vP2[0]) * t + (2.0 * vP0[0] - 5.0 *vP1[0] + 4.0 * vP2[0] - vP3[0]) * t2 + (-vP0[0] + 3.0*vP1[0] - 3.0 *vP2[0] + vP3[0]) * t3); // Y vOut[1] = 0.5 * ( ( 2.0 * vP1[1]) + (-vP0[1] + vP2[1]) * t + (2.0 * vP0[1] - 5.0 *vP1[1] + 4.0 * vP2[1] - vP3[1]) * t2 + (-vP0[1] + 3*vP1[1] - 3.0 *vP2[1] + vP3[1]) * t3); // Z vOut[2] = 0.5 * ( ( 2.0 * vP1[2]) + (-vP0[2] + vP2[2]) * t + (2.0 * vP0[2] - 5.0 *vP1[2] + 4.0 * vP2[2] - vP3[2]) * t2 + (-vP0[2] + 3.0*vP1[2] - 3.0 *vP2[2] + vP3[2]) * t3); } /////////////////////////////////////////////////////////////////////////////// // Determine if the ray (starting at point) intersects the sphere centered at // sphereCenter with radius sphereRadius // Return value is < 0 if the ray does not intersect // Return value is 0.0 if ray is tangent // Positive value is distance to the intersection point // Algorithm from "3D Math Primer for Graphics and Game Development" double m3dRaySphereTest(const M3DVector3d point, const M3DVector3d ray, const M3DVector3d sphereCenter, double sphereRadius) { //m3dNormalizeVector(ray); // Make sure ray is unit length M3DVector3d rayToCenter; // Ray to center of sphere rayToCenter[0] = sphereCenter[0] - point[0]; rayToCenter[1] = sphereCenter[1] - point[1]; rayToCenter[2] = sphereCenter[2] - point[2]; // Project rayToCenter on ray to test double a = m3dDotProduct(rayToCenter, ray); // Distance to center of sphere double distance2 = m3dDotProduct(rayToCenter, rayToCenter); // Or length double dRet = (sphereRadius * sphereRadius) - distance2 + (a*a); if(dRet > 0.0) // Return distance to intersection dRet = a - sqrt(dRet); return dRet; } /////////////////////////////////////////////////////////////////////////////// // Determine if the ray (starting at point) intersects the sphere centered at // ditto above, but uses floating point math float m3dRaySphereTest(const M3DVector3f point, const M3DVector3f ray, const M3DVector3f sphereCenter, float sphereRadius) { //m3dNormalizeVectorf(ray); // Make sure ray is unit length M3DVector3f rayToCenter; // Ray to center of sphere rayToCenter[0] = sphereCenter[0] - point[0]; rayToCenter[1] = sphereCenter[1] - point[1]; rayToCenter[2] = sphereCenter[2] - point[2]; // Project rayToCenter on ray to test float a = m3dDotProduct(rayToCenter, ray); // Distance to center of sphere float distance2 = m3dDotProduct(rayToCenter, rayToCenter); // Or length float dRet = (sphereRadius * sphereRadius) - distance2 + (a*a); if(dRet > 0.0) // Return distance to intersection dRet = a - sqrtf(dRet); return dRet; } /////////////////////////////////////////////////////////////////////////////////////////////////// // Calculate the tangent basis for a triangle on the surface of a model // This vector is needed for most normal mapping shaders void m3dCalculateTangentBasis(const M3DVector3f vTriangle[3], const M3DVector2f vTexCoords[3], const M3DVector3f N, M3DVector3f vTangent) { M3DVector3f dv2v1, dv3v1; float dc2c1t, dc2c1b, dc3c1t, dc3c1b; float M; m3dSubtractVectors3(dv2v1, vTriangle[1], vTriangle[0]); m3dSubtractVectors3(dv3v1, vTriangle[2], vTriangle[0]); dc2c1t = vTexCoords[1][0] - vTexCoords[0][0]; dc2c1b = vTexCoords[1][1] - vTexCoords[0][1]; dc3c1t = vTexCoords[2][0] - vTexCoords[0][0]; dc3c1b = vTexCoords[2][1] - vTexCoords[0][1]; M = (dc2c1t * dc3c1b) - (dc3c1t * dc2c1b); M = 1.0f / M; m3dScaleVector3(dv2v1, dc3c1b); m3dScaleVector3(dv3v1, dc2c1b); m3dSubtractVectors3(vTangent, dv2v1, dv3v1); m3dScaleVector3(vTangent, M); // This potentially changes the direction of the vector m3dNormalizeVector(vTangent); M3DVector3f B; m3dCrossProduct(B, N, vTangent); m3dCrossProduct(vTangent, B, N); m3dNormalizeVector(vTangent); } //////////////////////////////////////////////////////////////////////////// // Smoothly step between 0 and 1 between edge1 and edge 2 double m3dSmoothStep(double edge1, double edge2, double x) { double t; t = (x - edge1) / (edge2 - edge1); if(t > 1.0) t = 1.0; if(t < 0.0) t = 0.0f; return t * t * ( 3.0 - 2.0 * t); } //////////////////////////////////////////////////////////////////////////// // Smoothly step between 0 and 1 between edge1 and edge 2 float m3dSmoothStep(float edge1, float edge2, float x) { float t; t = (x - edge1) / (edge2 - edge1); if(t > 1.0f) t = 1.0f; if(t < 0.0) t = 0.0f; return t * t * ( 3.0f - 2.0f * t); } /////////////////////////////////////////////////////////////////////////// // Creae a projection to "squish" an object into the plane. // Use m3dGetPlaneEquationf(planeEq, point1, point2, point3); // to get a plane equation. void m3dMakePlanarShadowMatrix(M3DMatrix44f proj, const M3DVector4f planeEq, const M3DVector3f vLightPos) { // These just make the code below easier to read. They will be // removed by the optimizer. float a = planeEq[0]; float b = planeEq[1]; float c = planeEq[2]; float d = planeEq[3]; float dx = -vLightPos[0]; float dy = -vLightPos[1]; float dz = -vLightPos[2]; // Now build the projection matrix proj[0] = b * dy + c * dz; proj[1] = -a * dy; proj[2] = -a * dz; proj[3] = 0.0; proj[4] = -b * dx; proj[5] = a * dx + c * dz; proj[6] = -b * dz; proj[7] = 0.0; proj[8] = -c * dx; proj[9] = -c * dy; proj[10] = a * dx + b * dy; proj[11] = 0.0; proj[12] = -d * dx; proj[13] = -d * dy; proj[14] = -d * dz; proj[15] = a * dx + b * dy + c * dz; // Shadow matrix ready } /////////////////////////////////////////////////////////////////////////// // Creae a projection to "squish" an object into the plane. // Use m3dGetPlaneEquationd(planeEq, point1, point2, point3); // to get a plane equation. void m3dMakePlanarShadowMatrix(M3DMatrix44d proj, const M3DVector4d planeEq, const M3DVector3f vLightPos) { // These just make the code below easier to read. They will be // removed by the optimizer. double a = planeEq[0]; double b = planeEq[1]; double c = planeEq[2]; double d = planeEq[3]; double dx = -vLightPos[0]; double dy = -vLightPos[1]; double dz = -vLightPos[2]; // Now build the projection matrix proj[0] = b * dy + c * dz; proj[1] = -a * dy; proj[2] = -a * dz; proj[3] = 0.0; proj[4] = -b * dx; proj[5] = a * dx + c * dz; proj[6] = -b * dz; proj[7] = 0.0; proj[8] = -c * dx; proj[9] = -c * dy; proj[10] = a * dx + b * dy; proj[11] = 0.0; proj[12] = -d * dx; proj[13] = -d * dy; proj[14] = -d * dz; proj[15] = a * dx + b * dy + c * dz; // Shadow matrix ready } ///////////////////////////////////////////////////////////////////////////// // I want to know the point on a ray, closest to another given point in space. // As a bonus, return the distance squared of the two points. // In: vRayOrigin is the origin of the ray. // In: vUnitRayDir is the unit vector of the ray // In: vPointInSpace is the point in space // Out: vPointOnRay is the poing on the ray closest to vPointInSpace // Return: The square of the distance to the ray double m3dClosestPointOnRay(M3DVector3d vPointOnRay, const M3DVector3d vRayOrigin, const M3DVector3d vUnitRayDir, const M3DVector3d vPointInSpace) { M3DVector3d v; m3dSubtractVectors3(v, vPointInSpace, vRayOrigin); double t = m3dDotProduct(vUnitRayDir, v); // This is the point on the ray vPointOnRay[0] = vRayOrigin[0] + (t * vUnitRayDir[0]); vPointOnRay[1] = vRayOrigin[1] + (t * vUnitRayDir[1]); vPointOnRay[2] = vRayOrigin[2] + (t * vUnitRayDir[2]); return m3dGetDistanceSquared(vPointOnRay, vPointInSpace); } // ditto above... but with floats float m3dClosestPointOnRay(M3DVector3f vPointOnRay, const M3DVector3f vRayOrigin, const M3DVector3f vUnitRayDir, const M3DVector3f vPointInSpace) { M3DVector3f v; m3dSubtractVectors3(v, vPointInSpace, vRayOrigin); float t = m3dDotProduct(vUnitRayDir, v); // This is the point on the ray vPointOnRay[0] = vRayOrigin[0] + (t * vUnitRayDir[0]); vPointOnRay[1] = vRayOrigin[1] + (t * vUnitRayDir[1]); vPointOnRay[2] = vRayOrigin[2] + (t * vUnitRayDir[2]); return m3dGetDistanceSquared(vPointOnRay, vPointInSpace); }
[ "drindking@gmail.com@0f1f08ab-4ab0-9d7d-a974-823501e1538f" ]
drindking@gmail.com@0f1f08ab-4ab0-9d7d-a974-823501e1538f
6d029f53d82e2a52ace2d7572d636300e13cd885
641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2
/chrome/browser/chromeos/customization/customization_wallpaper_downloader_browsertest.cc
63becc1c65a0737c6394bf5fddea20790d12db9c
[ "BSD-3-Clause" ]
permissive
massnetwork/mass-browser
7de0dfc541cbac00ffa7308541394bac1e945b76
67526da9358734698c067b7775be491423884339
refs/heads/master
2022-12-07T09:01:31.027715
2017-01-19T14:29:18
2017-01-19T14:29:18
73,799,690
4
4
BSD-3-Clause
2022-11-26T11:53:23
2016-11-15T09:49:29
null
UTF-8
C++
false
false
11,596
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <stddef.h> #include <vector> #include "ash/common/wallpaper/wallpaper_controller.h" #include "ash/common/wm_shell.h" #include "base/command_line.h" #include "base/files/scoped_temp_dir.h" #include "base/macros.h" #include "base/run_loop.h" #include "base/time/time.h" #include "chrome/browser/chromeos/customization/customization_document.h" #include "chrome/browser/chromeos/customization/customization_wallpaper_downloader.h" #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager_test_utils.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/testing_browser_process.h" #include "chromeos/chromeos_switches.h" #include "net/http/http_response_headers.h" #include "net/http/http_status_code.h" #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_fetcher_impl.h" #include "testing/gtest/include/gtest/gtest.h" namespace chromeos { namespace { const char kOEMWallpaperURL[] = "http://somedomain.com/image.png"; const char kServicesManifest[] = "{" " \"version\": \"1.0\"," " \"default_wallpaper\": \"http://somedomain.com/image.png\",\n" " \"default_apps\": [\n" " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n" " ],\n" " \"localized_content\": {\n" " \"en-US\": {\n" " \"default_apps_folder_name\": \"EN-US OEM Name\"\n" " },\n" " \"en\": {\n" " \"default_apps_folder_name\": \"EN OEM Name\"\n" " },\n" " \"default\": {\n" " \"default_apps_folder_name\": \"Default OEM Name\"\n" " }\n" " }\n" "}"; // Expected minimal wallpaper download retry interval in milliseconds. const int kDownloadRetryIntervalMS = 100; class TestWallpaperObserver : public WallpaperManager::Observer { public: explicit TestWallpaperObserver(WallpaperManager* wallpaper_manager) : finished_(false), wallpaper_manager_(wallpaper_manager) { DCHECK(wallpaper_manager_); wallpaper_manager_->AddObserver(this); } ~TestWallpaperObserver() override { wallpaper_manager_->RemoveObserver(this); } void OnWallpaperAnimationFinished(const AccountId&) override { finished_ = true; base::MessageLoop::current()->QuitWhenIdle(); } void WaitForWallpaperAnimationFinished() { while (!finished_) base::RunLoop().Run(); } private: bool finished_; WallpaperManager* wallpaper_manager_; DISALLOW_COPY_AND_ASSIGN(TestWallpaperObserver); }; } // namespace // This is helper class for net::FakeURLFetcherFactory. class TestWallpaperImageURLFetcherCallback { public: TestWallpaperImageURLFetcherCallback( const GURL& url, const size_t require_retries, const std::vector<unsigned char>& jpeg_data_raw) : url_(url), require_retries_(require_retries), factory_(nullptr) { jpeg_data_.resize(jpeg_data_raw.size()); std::copy(jpeg_data_raw.begin(), jpeg_data_raw.end(), jpeg_data_.begin()); } std::unique_ptr<net::FakeURLFetcher> CreateURLFetcher( const GURL& url, net::URLFetcherDelegate* delegate, const std::string& response_data, net::HttpStatusCode response_code, net::URLRequestStatus::Status status) { chromeos::ServicesCustomizationDocument* customization = chromeos::ServicesCustomizationDocument::GetInstance(); customization->wallpaper_downloader_for_testing() ->set_retry_delay_for_testing( base::TimeDelta::FromMilliseconds(kDownloadRetryIntervalMS)); attempts_.push_back(base::TimeTicks::Now()); if (attempts_.size() > 1) { const int retry = num_attempts() - 1; const base::TimeDelta current_delay = customization->wallpaper_downloader_for_testing() ->retry_current_delay_for_testing(); const double base_interval = base::TimeDelta::FromMilliseconds( kDownloadRetryIntervalMS).InSecondsF(); EXPECT_GE(current_delay, base::TimeDelta::FromSecondsD(base_interval * retry * retry)) << "Retry too fast. Actual interval " << current_delay.InSecondsF() << " seconds, but expected at least " << base_interval << " * (retry=" << retry << " * retry)= " << base_interval * retry * retry << " seconds."; } if (attempts_.size() > require_retries_) { response_code = net::HTTP_OK; status = net::URLRequestStatus::SUCCESS; factory_->SetFakeResponse(url, response_data, response_code, status); } std::unique_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher( url, delegate, response_data, response_code, status)); scoped_refptr<net::HttpResponseHeaders> download_headers = new net::HttpResponseHeaders(std::string()); download_headers->AddHeader("Content-Type: image/jpeg"); fetcher->set_response_headers(download_headers); return fetcher; } void Initialize(net::FakeURLFetcherFactory* factory) { factory_ = factory; factory_->SetFakeResponse(url_, jpeg_data_, net::HTTP_INTERNAL_SERVER_ERROR, net::URLRequestStatus::FAILED); } size_t num_attempts() const { return attempts_.size(); } private: const GURL url_; // Respond with OK on required retry attempt. const size_t require_retries_; net::FakeURLFetcherFactory* factory_; std::vector<base::TimeTicks> attempts_; std::string jpeg_data_; DISALLOW_COPY_AND_ASSIGN(TestWallpaperImageURLFetcherCallback); }; // This implements fake remote source for wallpaper image. // JPEG image is created here and served to CustomizationWallpaperDownloader // via net::FakeURLFetcher. class WallpaperImageFetcherFactory { public: WallpaperImageFetcherFactory(const GURL& url, int width, int height, SkColor color, const size_t require_retries) { // ASSERT_TRUE() cannot be directly used in constructor. Initialize(url, width, height, color, require_retries); } ~WallpaperImageFetcherFactory() { fetcher_factory_.reset(); net::URLFetcherImpl::set_factory(fallback_fetcher_factory_.get()); fallback_fetcher_factory_.reset(); } size_t num_attempts() const { return url_callback_->num_attempts(); } private: void Initialize(const GURL& url, int width, int height, SkColor color, const size_t require_retries) { std::vector<unsigned char> oem_wallpaper_; ASSERT_TRUE(wallpaper_manager_test_utils::CreateJPEGImage( width, height, color, &oem_wallpaper_)); url_callback_.reset(new TestWallpaperImageURLFetcherCallback( url, require_retries, oem_wallpaper_)); fallback_fetcher_factory_.reset(new net::TestURLFetcherFactory); net::URLFetcherImpl::set_factory(nullptr); fetcher_factory_.reset(new net::FakeURLFetcherFactory( fallback_fetcher_factory_.get(), base::Bind(&TestWallpaperImageURLFetcherCallback::CreateURLFetcher, base::Unretained(url_callback_.get())))); url_callback_->Initialize(fetcher_factory_.get()); } std::unique_ptr<TestWallpaperImageURLFetcherCallback> url_callback_; // Use a test factory as a fallback so we don't have to deal with other // requests. std::unique_ptr<net::TestURLFetcherFactory> fallback_fetcher_factory_; std::unique_ptr<net::FakeURLFetcherFactory> fetcher_factory_; DISALLOW_COPY_AND_ASSIGN(WallpaperImageFetcherFactory); }; class CustomizationWallpaperDownloaderBrowserTest : public InProcessBrowserTest { public: CustomizationWallpaperDownloaderBrowserTest() {} ~CustomizationWallpaperDownloaderBrowserTest() override {} void SetUpCommandLine(base::CommandLine* command_line) override { command_line->AppendSwitch(chromeos::switches::kLoginManager); command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); } protected: void CreateCmdlineWallpapers() { cmdline_wallpaper_dir_.reset(new base::ScopedTempDir); ASSERT_TRUE(cmdline_wallpaper_dir_->CreateUniqueTempDir()); wallpaper_manager_test_utils::CreateCmdlineWallpapers( *cmdline_wallpaper_dir_, &wallpaper_manager_command_line_); } std::unique_ptr<base::CommandLine> wallpaper_manager_command_line_; // Directory created by CreateCmdlineWallpapersAndSetFlags() to store default // wallpaper images. std::unique_ptr<base::ScopedTempDir> cmdline_wallpaper_dir_; private: DISALLOW_COPY_AND_ASSIGN(CustomizationWallpaperDownloaderBrowserTest); }; IN_PROC_BROWSER_TEST_F(CustomizationWallpaperDownloaderBrowserTest, OEMWallpaperIsPresent) { CreateCmdlineWallpapers(); WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(), wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); WallpaperImageFetcherFactory url_factory( GURL(kOEMWallpaperURL), wallpaper_manager_test_utils::kWallpaperSize, wallpaper_manager_test_utils::kWallpaperSize, wallpaper_manager_test_utils::kCustomWallpaperColor, 0 /* require_retries */); TestWallpaperObserver observer(WallpaperManager::Get()); chromeos::ServicesCustomizationDocument* customization = chromeos::ServicesCustomizationDocument::GetInstance(); EXPECT_TRUE( customization->LoadManifestFromString(std::string(kServicesManifest))); observer.WaitForWallpaperAnimationFinished(); EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(), wallpaper_manager_test_utils::kCustomWallpaperColor)); EXPECT_EQ(1U, url_factory.num_attempts()); } IN_PROC_BROWSER_TEST_F(CustomizationWallpaperDownloaderBrowserTest, OEMWallpaperRetryFetch) { CreateCmdlineWallpapers(); WallpaperManager::Get()->SetDefaultWallpaperNow(EmptyAccountId()); wallpaper_manager_test_utils::WaitAsyncWallpaperLoadFinished(); EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(), wallpaper_manager_test_utils::kSmallDefaultWallpaperColor)); WallpaperImageFetcherFactory url_factory( GURL(kOEMWallpaperURL), wallpaper_manager_test_utils::kWallpaperSize, wallpaper_manager_test_utils::kWallpaperSize, wallpaper_manager_test_utils::kCustomWallpaperColor, 1 /* require_retries */); TestWallpaperObserver observer(WallpaperManager::Get()); chromeos::ServicesCustomizationDocument* customization = chromeos::ServicesCustomizationDocument::GetInstance(); EXPECT_TRUE( customization->LoadManifestFromString(std::string(kServicesManifest))); observer.WaitForWallpaperAnimationFinished(); EXPECT_TRUE(wallpaper_manager_test_utils::ImageIsNearColor( ash::WmShell::Get()->wallpaper_controller()->GetWallpaper(), wallpaper_manager_test_utils::kCustomWallpaperColor)); EXPECT_EQ(2U, url_factory.num_attempts()); } } // namespace chromeos
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
f43c14f22fe2e1c8ddb79aeedc375204914c5ada
c489a7536d9ab501a817173731ce3c23ec055274
/28-Lec21/EditDistance.cpp
6fffc0913a9c6ad65ec076abef30677add66552a
[]
no_license
netbits/MIT-6.006-Introduction-to-Algorithms
ac5e721dec31b67b709a370b5adc4515de160647
d24026c426d2c5cbb00103ad1139ec65ee136134
refs/heads/main
2023-07-13T13:55:34.071992
2021-08-14T14:09:05
2021-08-14T14:09:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,207
cpp
#include <iostream> #include <string> #include <vector> #include <list> #include <algorithm> using namespace std; // using recursion class Solution_Recursion { public: int minDistance(string word1, string word2) { return minDistance(word1,word2,0,0); } int minDistance(string word1, string word2,int i,int j){ if(i==word1.size()||j==word2.size()) return word1.size()+word2.size()-i-j; if(word1[i]==word2[j]) return minDistance(word1,word2,i+1,j+1); int insert_cost = 1+minDistance(word1,word2,i,j+1); int delete_cost = 1+minDistance(word1,word2,i+1,j); int replace_cost = 1+minDistance(word1,word2,i+1,j+1); return min(insert_cost,min(delete_cost,replace_cost)); } }; // bottom-up 2-d array class Solution_Iteration { public: int minDistance(string word1, string word2) { int len1 = word1.size(),len2 = word2.size(); if(len1*len2==0) return len1+len2; // initialisation int dp[len1+1][len2+1]; // todo : replace 2-d array with last 2 rows or columns for(int i = 0;i<=len1;i++) { dp[i][len2] = len1-i; } for(int j = 0; j<=len2;j++) { dp[len1][j] = len2-j; } // bottom->up & right->left for(int i = len1-1; i>=0; i--) { for(int j = len2-1; j>=0; j--) { if(word1[i]==word2[j]) dp[i][j] = dp[i+1][j+1]; else dp[i][j] = 1 + min(dp[i][j+1],min(dp[i+1][j+1],dp[i+1][j])); } } return dp[0][0]; } }; // only keep last 2 rows class Solution_Itration_Better { public: int minDistance(string word1, string word2) { int len1 = word1.size(),len2 = word2.size(); if(len1*len2==0) return len1+len2; // initialisation // only need to keep last 2 rows (or last 2 columns) vector<int> current_row(len2+1),last_row(len2+1); for(int j = 0; j<=len2;j++) { last_row[j] = len2-j; } // bottom->up & right->left int i = len1-1; int j = len2-1; for( i = len1-1; i>=0; i--) { current_row[len2] = len1-i; for(j = len2-1; j>=0; j--) { if(word1[i]==word2[j]) current_row[j] = last_row[j+1]; else current_row[j] = 1+min(current_row[j+1],min(last_row[j],last_row[j+1])); } last_row = current_row; } return current_row[0]; } }; int main() { string s1("hieroglyphology"); string s2("michaelangelo"); string s3("dinitrophenylhydrazine"); string s4("acetylphenylhydrazine"); Solution_Recursion solution_r; Solution_Iteration solution_i; Solution_Itration_Better solution_ib; // cout<< solution_r.minDistance(s1,s2)<<endl; // 46 seconds! // cout<< solution_i.minDistance(s1,s2)<<endl; // 0.873 seconds! cout<< solution_ib.minDistance(s1,s2)<<endl; // 0.873 seconds! // cout<< solution_i.minDistance(s2,s3)<<endl; // cout<< solution_i.minDistance(s3,s4)<<endl; }
[ "valentinmu@outlook.com" ]
valentinmu@outlook.com
9f0f0ffbb5f2fe641876d5c5bc9c7d3cc579a0b4
cccd77053ce93010420e72a9cb98bbcde3441c76
/level1/p08_hanoi/hanoi.cpp
6ede4ad6341c2b921ff86a3bf73f1ef44d2ceee7
[ "MIT" ]
permissive
liaohui-2002/c2020
e02d8e8fc6534ec6217c26465d70413de5e600a5
be2d1437260c0c9f096d9580afd72452087b1f2a
refs/heads/master
2022-04-09T21:23:25.988797
2020-03-24T14:24:11
2020-03-24T14:24:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
454
cpp
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define For(x,a,b) for(x=a;x<=b;x++) int i,i1,i2; void hanoi(int n,char a,char b,char c); int main(void) { int n; printf("Please input the number of the disk:\n"); scanf("%d",&n); hanoi(n,'a','b','c'); return 0; } void hanoi(int n,char a,char b,char c) { if(n==1)printf("%c --> %c\n",a,b); else{ hanoi(n-1,a,c,b); printf("%c --> %c\n",a,b); hanoi(n-1,c,b,a); } }
[ "15091591733@126.com" ]
15091591733@126.com
e00f401b29f6ff458390090a86d9b53f192c9088
3762e1e9dcc74653eefc35010768a32fd2ab00d5
/execs/partition_pointcloud_levels/src/process/export_data.h
7347a642de08f69a9f9985ab5b92ebd3aed1cb96
[]
no_license
HollisJoe/geometry-1
6d5d8ba69b006b2d0bb5b9128b94fdcbd4af3b82
1e1f3c3b0aec35e80313d9d1124a77f1e439f53e
refs/heads/master
2021-06-14T16:38:37.744499
2017-02-02T14:20:26
2017-02-02T14:20:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,749
h
#ifndef EXPORT_DATA_H #define EXPORT_DATA_H /* export_data.h: * * This file contains functions * used to export the level partitioning * data, including partitioning the point * cloud and exporting the level values */ #include <vector> #include "../io/config.h" #include "../structs/point.h" #include "../structs/histogram.h" using namespace std; /* export_data: * * Will export the given data to the specified files, * which includes partitioning scans into xyz files * by floor, which requires the input scans files to * be read. * * arguments: * * floor_heights - The list of floors and their heights * ceil_heights - The list of ceilings and their heights, * must be the same length as floor_heights * floor_hist - The floors histogram * ceil_hist - The ceilings histogram * conf - The configuration file * * return value: * * Returns zero on success, non-zero on failure. */ int export_data(vector<double>& floor_heights, vector<double>& ceil_heights, histogram_t& floor_hist, histogram_t& ceil_hist, config_t& conf); /********************** Helper Functions ****************************/ /* export_matlab_script: * * Will attempt to export a matlab script that contains all * relevant information about the level partitioning computed. * * arguments: * * floor_heights - The list of floors and their heights * ceil_heights - The list of ceilings and their heights, * must be the same length as floor_heights * floor_hist - The floors histogram * ceil_hist - The ceilings histogram * conf - The configuration file * * return value: * * Returns zero on success, non-zero on failure. */ int export_matlab_script(vector<double>& floor_heights, vector<double>& ceil_heights, histogram_t& floor_hist, histogram_t& ceil_hist, config_t& conf); /* partition_scans: * * Will read in the scans, and rewrite the points to the specified * output locations, partitioning the points based on which level * they are in. * * arguments: * * floor_heights - The list of floors and their heights * ceil_heights - The list of ceilings and their heights, * must be the same length as floor_heights * conf - The configuration file * * return value: * * Returns zero on success, non-zero on failure. */ int partition_scans(vector<double>& floor_heights, vector<double>& ceil_heights, config_t& conf); /* level_of_point: * * Will specify the level index for the given point. * * arguments: * * p - The point to analyze * floor_heights, ceil_heights - The level heights to use * * return value: * * Returns the level of the point p. */ int level_of_point(point_t& p, vector<double>& floor_heights, vector<double>& ceil_heights); #endif
[ "elturner@eecs.berkeley.edu" ]
elturner@eecs.berkeley.edu
50dc01c100021b654cf3506164a280f801190fbe
641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2
/third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.cpp
a3cc1da8182c721b93b902f67c7778c802ccabcd
[ "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
massnetwork/mass-browser
7de0dfc541cbac00ffa7308541394bac1e945b76
67526da9358734698c067b7775be491423884339
refs/heads/master
2022-12-07T09:01:31.027715
2017-01-19T14:29:18
2017-01-19T14:29:18
73,799,690
4
4
BSD-3-Clause
2022-11-26T11:53:23
2016-11-15T09:49:29
null
UTF-8
C++
false
false
11,607
cpp
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "core/dom/DOMMatrixReadOnly.h" #include "bindings/core/v8/V8ObjectBuilder.h" #include "core/dom/DOMMatrix.h" #include "core/dom/DOMMatrixInit.h" #include "core/dom/DOMPoint.h" #include "core/dom/DOMPointInit.h" namespace blink { namespace { void setDictionaryMembers(DOMMatrixInit& other) { if (!other.hasM11()) other.setM11(other.hasA() ? other.a() : 1); if (!other.hasM12()) other.setM12(other.hasB() ? other.b() : 0); if (!other.hasM21()) other.setM21(other.hasC() ? other.c() : 0); if (!other.hasM22()) other.setM22(other.hasD() ? other.d() : 1); if (!other.hasM41()) other.setM41(other.hasE() ? other.e() : 0); if (!other.hasM42()) other.setM42(other.hasF() ? other.f() : 0); } String getErrorMessage(const char* a, const char* b) { return String::format("The '%s' property should equal the '%s' property.", a, b); } } // namespace bool DOMMatrixReadOnly::validateAndFixup(DOMMatrixInit& other, ExceptionState& exceptionState) { if (other.hasA() && other.hasM11() && other.a() != other.m11()) { exceptionState.throwTypeError(getErrorMessage("a", "m11")); return false; } if (other.hasB() && other.hasM12() && other.b() != other.m12()) { exceptionState.throwTypeError(getErrorMessage("b", "m12")); return false; } if (other.hasC() && other.hasM21() && other.c() != other.m21()) { exceptionState.throwTypeError(getErrorMessage("c", "m21")); return false; } if (other.hasD() && other.hasM22() && other.d() != other.m22()) { exceptionState.throwTypeError(getErrorMessage("d", "m22")); return false; } if (other.hasE() && other.hasM41() && other.e() != other.m41()) { exceptionState.throwTypeError(getErrorMessage("e", "m41")); return false; } if (other.hasF() && other.hasM42() && other.f() != other.m42()) { exceptionState.throwTypeError(getErrorMessage("f", "m42")); return false; } if (other.hasIs2D() && other.is2D() && (other.m31() || other.m32() || other.m13() || other.m23() || other.m43() || other.m14() || other.m24() || other.m34() || other.m33() != 1 || other.m44() != 1)) { exceptionState.throwTypeError( "The is2D member is set to true but the input matrix is 3d matrix."); return false; } setDictionaryMembers(other); if (!other.hasIs2D()) { bool is2D = !(other.m31() || other.m32() || other.m13() || other.m23() || other.m43() || other.m14() || other.m24() || other.m34() || other.m33() != 1 || other.m44() != 1); other.setIs2D(is2D); } return true; } DOMMatrixReadOnly* DOMMatrixReadOnly::create(ExceptionState& exceptionState) { return new DOMMatrixReadOnly(TransformationMatrix()); } DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionState& exceptionState) { if (sequence.size() != 6 && sequence.size() != 16) { exceptionState.throwTypeError( "The sequence must contain 6 elements for a 2D matrix or 16 elements " "for a 3D matrix."); return nullptr; } return new DOMMatrixReadOnly(sequence, sequence.size()); } DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( DOMFloat32Array* float32Array, ExceptionState& exceptionState) { if (float32Array->length() != 6 && float32Array->length() != 16) { exceptionState.throwTypeError( "The sequence must contain 6 elements for a 2D matrix or 16 elements a " "for 3D matrix."); return nullptr; } return new DOMMatrixReadOnly(float32Array->data(), float32Array->length()); } DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array( DOMFloat64Array* float64Array, ExceptionState& exceptionState) { if (float64Array->length() != 6 && float64Array->length() != 16) { exceptionState.throwTypeError( "The sequence must contain 6 elements for a 2D matrix or 16 elements " "for a 3D matrix."); return nullptr; } return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); } DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( DOMMatrixInit& other, ExceptionState& exceptionState) { if (!validateAndFixup(other, exceptionState)) { DCHECK(exceptionState.hadException()); return nullptr; } if (other.is2D()) { double args[] = {other.m11(), other.m12(), other.m21(), other.m22(), other.m41(), other.m42()}; return new DOMMatrixReadOnly(args, 6); } double args[] = {other.m11(), other.m12(), other.m13(), other.m14(), other.m21(), other.m22(), other.m23(), other.m24(), other.m31(), other.m32(), other.m33(), other.m34(), other.m41(), other.m42(), other.m43(), other.m44()}; return new DOMMatrixReadOnly(args, 16); } DOMMatrixReadOnly::~DOMMatrixReadOnly() {} bool DOMMatrixReadOnly::is2D() const { return m_is2D; } bool DOMMatrixReadOnly::isIdentity() const { return m_matrix->isIdentity(); } DOMMatrix* DOMMatrixReadOnly::multiply(DOMMatrixInit& other, ExceptionState& exceptionState) { return DOMMatrix::create(this)->multiplySelf(other, exceptionState); } DOMMatrix* DOMMatrixReadOnly::translate(double tx, double ty, double tz) { return DOMMatrix::create(this)->translateSelf(tx, ty, tz); } DOMMatrix* DOMMatrixReadOnly::scale(double sx) { return scale(sx, sx); } DOMMatrix* DOMMatrixReadOnly::scale(double sx, double sy, double sz, double ox, double oy, double oz) { return DOMMatrix::create(this)->scaleSelf(sx, sy, sz, ox, oy, oz); } DOMMatrix* DOMMatrixReadOnly::scale3d(double scale, double ox, double oy, double oz) { return DOMMatrix::create(this)->scale3dSelf(scale, ox, oy, oz); } DOMMatrix* DOMMatrixReadOnly::rotate(double rotX) { return DOMMatrix::create(this)->rotateSelf(rotX); } DOMMatrix* DOMMatrixReadOnly::rotate(double rotX, double rotY) { return DOMMatrix::create(this)->rotateSelf(rotX, rotY); } DOMMatrix* DOMMatrixReadOnly::rotate(double rotX, double rotY, double rotZ) { return DOMMatrix::create(this)->rotateSelf(rotX, rotY, rotZ); } DOMMatrix* DOMMatrixReadOnly::rotateFromVector(double x, double y) { return DOMMatrix::create(this)->rotateFromVectorSelf(x, y); } DOMMatrix* DOMMatrixReadOnly::rotateAxisAngle(double x, double y, double z, double angle) { return DOMMatrix::create(this)->rotateAxisAngleSelf(x, y, z, angle); } DOMMatrix* DOMMatrixReadOnly::skewX(double sx) { return DOMMatrix::create(this)->skewXSelf(sx); } DOMMatrix* DOMMatrixReadOnly::skewY(double sy) { return DOMMatrix::create(this)->skewYSelf(sy); } DOMMatrix* DOMMatrixReadOnly::flipX() { DOMMatrix* flipX = DOMMatrix::create(this); flipX->setM11(-this->m11()); flipX->setM12(-this->m12()); flipX->setM13(-this->m13()); flipX->setM14(-this->m14()); return flipX; } DOMMatrix* DOMMatrixReadOnly::flipY() { DOMMatrix* flipY = DOMMatrix::create(this); flipY->setM21(-this->m21()); flipY->setM22(-this->m22()); flipY->setM23(-this->m23()); flipY->setM24(-this->m24()); return flipY; } DOMMatrix* DOMMatrixReadOnly::inverse() { return DOMMatrix::create(this)->invertSelf(); } DOMPoint* DOMMatrixReadOnly::transformPoint(const DOMPointInit& point) { if (is2D() && point.z() == 0 && point.w() == 1) { double x = point.x() * m11() + point.y() * m12() + m41(); double y = point.x() * m12() + point.y() * m22() + m42(); return DOMPoint::create(x, y, 0, 1); } double x = point.x() * m11() + point.y() * m21() + point.z() * m31() + point.w() * m41(); double y = point.x() * m12() + point.y() * m22() + point.z() * m32() + point.w() * m42(); double z = point.x() * m13() + point.y() * m23() + point.z() * m33() + point.w() * m43(); double w = point.x() * m14() + point.y() * m24() + point.z() * m34() + point.w() * m44(); return DOMPoint::create(x, y, z, w); } DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix, bool is2D) { m_matrix = TransformationMatrix::create(matrix); m_is2D = is2D; } DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { float array[] = { static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; return DOMFloat32Array::create(array, 16); } DOMFloat64Array* DOMMatrixReadOnly::toFloat64Array() const { double array[] = { m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44()}; return DOMFloat64Array::create(array, 16); } const String DOMMatrixReadOnly::toString() const { std::stringstream stream; if (is2D()) { stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d() << ", " << e() << ", " << f(); } else { stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " << m44(); } stream << ")"; return String(stream.str().c_str()); } ScriptValue DOMMatrixReadOnly::toJSONForBinding( ScriptState* scriptState) const { V8ObjectBuilder result(scriptState); result.addNumber("a", a()); result.addNumber("b", b()); result.addNumber("c", c()); result.addNumber("d", d()); result.addNumber("e", e()); result.addNumber("f", f()); result.addNumber("m11", m11()); result.addNumber("m12", m12()); result.addNumber("m13", m13()); result.addNumber("m14", m14()); result.addNumber("m21", m21()); result.addNumber("m22", m22()); result.addNumber("m23", m23()); result.addNumber("m24", m24()); result.addNumber("m31", m31()); result.addNumber("m32", m32()); result.addNumber("m33", m33()); result.addNumber("m34", m34()); result.addNumber("m41", m41()); result.addNumber("m42", m42()); result.addNumber("m43", m43()); result.addNumber("m44", m44()); result.addBoolean("is2D", is2D()); result.addBoolean("isIdentity", isIdentity()); return result.scriptValue(); } } // namespace blink
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
601f6e2cc0c87784ac59e95234b74e0fc76ea5db
6097e7cd1cd311ef13bd166d6323bbb749385291
/CCI/cci/cci/URLify.cpp
11f1f8243ba212248f3c9d7e20f07abf3c7b7836
[]
no_license
ysripath/CPP
a9a33f6d89c759b68def91df084915cf78f525fd
009bb94561b267c87b5ab5b38fbddcd1670a42a5
refs/heads/master
2020-03-26T09:57:47.602806
2019-04-07T01:33:01
2019-04-07T01:33:01
144,774,285
0
0
null
null
null
null
UTF-8
C++
false
false
599
cpp
#include <bits/stdc++.h> using namespace std; void util(string& str) { int l = str.length(); l--; int i = l; while (i >= 0) { if (str[i] == ' ') i--; else break; } while (i >= 0) { if (str[i] != ' ') { str[l--] = str[i--]; continue; } else { str[l--] = '0'; str[l--] = '2'; str[l--] = '%'; i--; continue; } } } int main() { //ios::sync_with_stdio(false); //cin.tie(NULL); cout << "Enter string \n"; string str = ""; char c; while (cin.get(c)) { if (c == '\n') break; str += c; } util(str); cout << str << "\n"; return 0; }
[ "yuvarajsripathi91@gmail.com" ]
yuvarajsripathi91@gmail.com
0f7800e97a9c6320a7ca1146acb63132880a4650
b90e5696800d2b8a944cdf9f61fac0bda0019aca
/src/devices/atmega32/aspects/debug.cpp
3c72c1c72a7cac7ade4936b8d29642501c08eb3b
[]
no_license
goc9000/megas2
7031024fc8c190c09f787f3e1679b80025f59453
2cdc4ed193732322f1d79aa7c742c07a7e3057c5
refs/heads/master
2021-12-25T13:55:34.947943
2013-05-21T00:11:15
2013-05-21T00:11:15
4,712,374
0
0
null
null
null
null
UTF-8
C++
false
false
3,792
cpp
#include <inttypes.h> #include <cstdio> #include <cstring> #include <cstdlib> #include <ctype.h> #include <algorithm> #include <fcntl.h> #include <unistd.h> #include "utils/bit_macros.h" #include "utils/fail.h" #include "devices/atmega32/atmega32.h" #include "devices/atmega32/defs.h" using namespace std; void Atmega32::_dumpRegisters() { char const *SREG_REP = "ithsvnzc"; char sreg_rep[9]; printf("--- Registers ---\n"); for (int i=0; i<IO_BASE; i++) { printf("%c%02d", i ? ' ' : 'r', i); } printf("\n"); for (int i=0; i<IO_BASE; i++) { printf(" %02x", this->core.ram[i]); } printf("\n"); uint8_t sreg = this->core.ram[REG_SREG]; for (int i=0; i<8; i++) sreg_rep[i] = bit_is_set(sreg, 7-i) ? toupper(SREG_REP[i]) : SREG_REP[i]; sreg_rep[8] = 0; printf("X=%04x Y=%04x Z=%04x SP=%04x SREG=%02x (%s)\n", this->_get16BitReg(REG16_X), this->_get16BitReg(REG16_Y), this->_get16BitReg(REG16_Z), this->_get16BitReg(REG16_SP), sreg, sreg_rep); printf("Last fetch @PC=%04x (in bytes: %04x)\n", this->core.last_inst_pc, 2*this->core.last_inst_pc); } void Atmega32::_dumpSram() { const int BYTES_PER_BLOCK = 32; int size = RAM_SIZE - SRAM_BASE; int blocks = (size + BYTES_PER_BLOCK-1) / BYTES_PER_BLOCK; printf("--- SRAM contents ---\n"); printf(" "); for (int i = 0; i < BYTES_PER_BLOCK; i++) printf("%c%02x", i ? ' ' : '+', i); printf("\n"); for (int i = 0; i < blocks; i++) { int addr = i * BYTES_PER_BLOCK; printf("%04x:", addr); int count = min(size - addr, BYTES_PER_BLOCK); for (int j = 0; j < count; j++) printf(" %02x", this->core.ram[SRAM_BASE + addr + j]); for (int j = BYTES_PER_BLOCK; j < count; j++) printf(" "); printf(" | "); for (int j = 0; j < count; j++) { uint8_t byte = this->core.ram[SRAM_BASE + addr + j]; printf("%c", ((byte >= 32) && (byte <= 126)) ? byte : '.'); } printf("\n"); } } void Atmega32::_dumpPortRead(const char *header, uint8_t port, int8_t bit, uint8_t &value) { char buffer[1024]; int len = 0; len += sprintf(buffer + len, "%04x: ", this->core.last_inst_pc * 2); if (header) { len += sprintf(buffer + len, "%s: ", header); } len += sprintf(buffer + len, "READ from %s", PORT_NAMES[port]); if (bit != -1) { len += sprintf(buffer + len, ":%d", bit); } len += sprintf(buffer + len, " = "); if (bit == -1) { len += sprintf(buffer + len, "%02x", value); } else { len += sprintf(buffer + len, "%d (full: %02x)", bit_is_set(value, bit), value); } buffer[len] = 0; printf("%s\n", buffer); } void Atmega32::_dumpPortWrite(const char *header, uint8_t port, int8_t bit, uint8_t value, uint8_t prev_val, uint8_t cleared) { char buffer[1024]; int len = 0; len += sprintf(buffer + len, "%04x: ", this->core.last_inst_pc * 2); if (header) { len += sprintf(buffer + len, "%s: ", header); } len += sprintf(buffer + len, "WRITE to %s", PORT_NAMES[port]); if (bit != -1) { len += sprintf(buffer + len, ":%d", bit); } len += sprintf(buffer + len, " : "); if (bit == -1) { len += sprintf(buffer + len, "%02x->%02x", prev_val, value); } else { len += sprintf(buffer + len, "%d->%d (full: %02x->%02x)", bit_is_set(prev_val, bit), bit_is_set(value, bit), prev_val, value); } if (cleared) { len += sprintf(buffer + len, " cleared:%02x", cleared); } buffer[len] = 0; printf("%s\n", buffer); }
[ "goc9000@gmail.com" ]
goc9000@gmail.com
c3c8ccf28d77065447e2d3587095ebeaec8e7032
94db0bd95a58fabfd47517ed7d7d819a542693cd
/client/ClientRes/IOSAPI/Classes/Native/mscorlib_System_Collections_Generic_Dictionary_2_T1638887798.h
7babf58bdbc0ef9de48a0b885c44c0d203fbefe7
[]
no_license
Avatarchik/card
9fc6efa058085bd25f2b8831267816aa12b24350
d18dbc9c7da5cf32c963458ac13731ecfbf252fa
refs/heads/master
2020-06-07T07:01:00.444233
2017-12-11T10:52:17
2017-12-11T10:52:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,019
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> // Spine.BoundingBoxAttachment struct BoundingBoxAttachment_t1898929740; // UnityEngine.PolygonCollider2D struct PolygonCollider2D_t3220183178; // System.IAsyncResult struct IAsyncResult_t1999651008; // System.AsyncCallback struct AsyncCallback_t163412349; // System.Object struct Il2CppObject; #include "mscorlib_System_MulticastDelegate3201952435.h" #include "mscorlib_System_Collections_DictionaryEntry3048875398.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // System.Collections.Generic.Dictionary`2/Transform`1<Spine.BoundingBoxAttachment,UnityEngine.PolygonCollider2D,System.Collections.DictionaryEntry> struct Transform_1_t1638887798 : public MulticastDelegate_t3201952435 { public: public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "1" ]
1
fe047f98933efe6113ed62a8707a2c5303ddbb00
535e44e24d60879d5d654aada6d48f1d932a1e9f
/desiredimpl/01-basic-scenario/timer_proxy.cpp
24a8016cb2ef5e162b8bb7ef75ef025c6dc2bd6c
[]
no_license
glucktv/dboost
6ff4c93d3e509c52b0a4eb44319f2f0b3ddae6c4
d1a0eb1b4ec1c2af2ad2b29ffa23157f845b39ab
refs/heads/master
2016-09-06T11:15:00.377118
2015-03-27T05:07:29
2015-03-27T05:07:29
17,452,491
1
0
null
null
null
null
UTF-8
C++
false
false
2,081
cpp
#include <timer_proxy.h> #include <dbus/dbus.h> #include <exception.h> #include <iostream> #include <serializer.h> namespace dboost_test { const char* timer_proxy::s_ifc_name = "org.dboost.timer"; const int TIMEOUT_MS = 5000; timer_proxy::timer_proxy(dboost::dbus_ptr<DBusConnection> conn, const std::string& bus_name, const std::string& obj_name) : m_connection(conn), m_bus_name(bus_name), m_obj_name(obj_name) { } // here arguments are called a0 .. aN to avoid naming clashes, result is called r long timer_proxy::add_timer(const long a0) { // create caller (name, arguments) dboost::dbus_ptr<DBusMessage> msg(DBOOST_CHECK(dbus_message_new_method_call(m_bus_name.c_str(), m_obj_name.c_str(), s_ifc_name, "add_timer"))); dboost::oserializer os(msg.get()); os & a0; // call synchronously dboost::error err; dboost::dbus_ptr<DBusMessage> reply(dbus_connection_send_with_reply_and_block(m_connection.get(), msg.get(), TIMEOUT_MS, &err)); // check if there was an error DBOOST_CHECK_WITH_ERR(reply, err); if (dbus_message_get_type(reply.get()) == DBUS_MESSAGE_TYPE_ERROR) { throw dboost::exception(dbus_message_get_error_name(reply.get())); } // unpack output parameters dboost::iserializer is(reply.get()); long r; is & r; return r; } void timer_proxy::remove_timer(const long a0) { // create caller (name, arguments) dboost::dbus_ptr<DBusMessage> msg(DBOOST_CHECK(dbus_message_new_method_call(m_bus_name.c_str(), m_obj_name.c_str(), s_ifc_name, "remove_timer"))); dboost::oserializer os(msg.get()); os & a0; // call synchronously dboost::error err; dboost::dbus_ptr<DBusMessage> reply(dbus_connection_send_with_reply_and_block(m_connection.get(), msg.get(), TIMEOUT_MS, &err)); // check if there was an error DBOOST_CHECK_WITH_ERR(reply, err); if (dbus_message_get_type(reply.get()) == DBUS_MESSAGE_TYPE_ERROR) { throw dboost::exception(dbus_message_get_error_name(reply.get())); } } } // namespace dboost
[ "yu_stas@hotbox.ru" ]
yu_stas@hotbox.ru
8511193ee147fa83e17a9c52dfb659a87628737f
9aee810d0d9d72d3dca7920447872216a3af49fe
/AtCoder/ABC/100-199/ABC141/abc141_e.cpp
d73963e78363014bf6c03049ad80c8c4b69ffbca
[]
no_license
pulcherriman/Programming_Contest
37d014a414d473607a11c2edcb25764040edd686
715308628fc19843b8231526ad95dbe0064597a8
refs/heads/master
2023-08-04T00:36:36.540090
2023-07-30T18:31:32
2023-07-30T18:31:32
163,375,122
3
0
null
2023-01-24T11:02:11
2018-12-28T06:33:16
C++
UTF-8
C++
false
false
4,531
cpp
#include <bits/stdc++.h> #if defined(ONLINE_JUDGE) || defined(_DEBUG) #include <atcoder/all> using namespace atcoder; #endif using namespace std; using ll=long long; using ull=unsigned long long; using vb=vector<bool>; using vvb=vector<vb>; using vd=vector<double>; using vvd=vector<vd>; using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; using pll=pair<ll,ll>; using tll=tuple<ll,ll>; using tlll=tuple<ll,ll,ll>; using vs=vector<string>; #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define rep(i,n) range(i,0,n) #define rrep(i,n) rrange(i,0,n) #define range(i,a,n) for(ll i=((ll)a);i<((ll)n);++i) #define rrange(i,a,n) for(ll i=((ll)n-1);i>=((ll)a);--i) #define repsq(i,n) for(ll i=0;i*i<=n;++i) #define LINF ((ll)1ll<<60) #define INF ((int)1<<30) #define EPS (1e-9) #define MOD (1000000007ll) #define fcout(a) cout<<setprecision(a)<<fixed #define PI (3.1415926535897932384) int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1}; template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;} template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;} template<class S>S sum(vector<S>&a){return accumulate(all(a),S());} template<class S>S max(vector<S>&a){return *max_element(all(a));} template<class S>S min(vector<S>&a){return *min_element(all(a));} //output template<class T>struct hasItr{ template<class U>static constexpr true_type check(class U::iterator*); template<class U>static constexpr false_type check(...); static constexpr bool v=decltype(check<T>(nullptr))::value; }; template<>struct hasItr<string>{static constexpr bool v=false;}; template<class T>void puta(T&t,false_type,ostream&os,char el){os<<t;} template<class T>void puta(T&t,true_type,ostream&os,char el){ constexpr bool h=hasItr<typename T::value_type>::v; bool F=true,I; for(auto&i:t){ if(!F)os<<' '; puta(i,bool_constant<h>(),os,el); F=I=h; } if(!I)os<<el; } template<class T>void puta(const T&t, ostream&os=cout, char el='\n'){ puta(t,bool_constant<hasItr<T>::v>(),os,el); if(!hasItr<T>::v)os<<el; } template<class H,class...T>void puta(const H&h,const T&...t){cout<<h<<' ';puta(t...);} template<size_t i,class...T>void puta(tuple<T...>const&t, ostream&os){ if constexpr(i==sizeof...(T)-1)puta(get<i>(t),os); else{os<<get<i>(t)<<' ';puta<i+1>(t,os);} } template<class...T>void puta(tuple<T...>const&t, ostream&os=cout){puta<0>(t,os);} template<class T>void dump(const T&t){puta(t,cerr);} template<class H,class...T>void dump(const H&h,const T&...t){cerr<<h<<' ';dump(t...);} template<class...T>void dump(tuple<T...>const&t){puta(t,cerr);} template<class S,class T>constexpr ostream&operator<<(ostream&os,pair<S,T>p){ os<<'['<<p.first<<", "; if constexpr(hasItr<T>::v)puta(p.second,bool_constant<true>(),os,']'); else os<<p.second<<']'; return os; }; template<class...T>constexpr ostream&operator<<(ostream&os,tuple<T...>t){ puta(t,os); return os; } void YN(bool b){puta(b?"YES":"NO");} void Yn(bool b){puta(b?"Yes":"No");} #ifndef _DEBUG #define dump(...) #endif //input template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;} // #define geta(t,n,...) t n;cin>>n;geta(t,__VA_ARGS__) // #define vec(t,a,h,...) vector<t>a(h);rep(i,n)a[i]=t(__VA_ARGS__);rep(i,n)cin>>a[i] template<typename...S>void geta_(S&...s){((cin>>s),...);} #define geta(t,...) t __VA_ARGS__;geta_(__VA_ARGS__) class RollingHash{ using u64=uint_fast64_t; using i128=__int128_t; public: string str; RollingHash(const string&str):str(str){ h.resize(str.size()+1,0); p.resize(str.size()+1,1); rep(i,str.size()){ p[i+1]=mul(p[i],base); h[i+1]=mul(h[i],base)+xorshift(str[i]+1); if(h[i+1]>=mod)h[i+1]-=mod; } } u64 get()const{return h.back();} u64 get(int l,int r)const{u64 v=mod+h[r]-mul(h[l],p[r-l]);return v<mod?v:v-mod;} private: vector<u64> h,p; static constexpr u64 mod=(1ull<<61)-1; static constexpr u64 base=36000*__TIME__[0]+3600*__TIME__[1]+600*__TIME__[3]+60*__TIME__[4]+10*__TIME__[6]+__TIME__[7]; static constexpr u64 mul(i128 a,i128 b){i128 t=a*b;t=(t>>61)+(t&mod);return t<mod?t:t-mod;} static constexpr int xorshift(int x){x^=x<<13;x^=x>>17;return x^=x<<5;} }; int main(){ cin.tie(0); ios::sync_with_stdio(false); geta(ll, n); geta(string,s); ll ans=0; RollingHash hash(s); rep(i,s.size()){ range(j,i,s.size()){ while(i + ans < j and j + ans < n) { if(hash.get(i, i + ans + 1) != hash.get(j, j + ans + 1)) break; ans++; } } } puta(ans); return 0; }
[ "tsukasawa_agu@yahoo.co.jp" ]
tsukasawa_agu@yahoo.co.jp
1659c0fadf15126da87ada072e243a2b77292272
15c3c9dfcb69a534c5c392c2983b0158aa809dd7
/InputManager.cpp
db864be61311d3e4f06973f6fc7e56b43af98cf3
[]
no_license
adrianhartanto0/AE2CPP
5389b257514515de74ab430b0025beb329b0c2bc
e45398bffff287a8d334bb6fd79124093ffef548
refs/heads/master
2021-01-10T14:52:23.603115
2016-05-09T06:16:21
2016-05-09T06:16:21
54,475,510
0
0
null
null
null
null
UTF-8
C++
false
false
832
cpp
// // InputManager.cpp // Space // // Created by Ericko Hartanto on 4/29/16. // Copyright © 2016 adrian. All rights reserved. // #include "InputManager.h" InputManager::InputManager(){ this->mouseX = 0; this->mouseY = 0; this->key = nullptr; } void InputManager::setMouseX(int val){ this->mouseX = val; } void InputManager::setMouseY(int val){ this->mouseY = val; } void InputManager::setKey(const char *k){ this->key = k; } int InputManager::getMouseX(){ return this->mouseX; } int InputManager::getMouseY(){ return this->mouseY; } const char * InputManager::getKey(){ return this->key; } void InputManager::clearKey(){ this->key = nullptr; } void InputManager::setClickedMouse(bool val){ this->clicked = val; } bool InputManager::getClick(){ return this->clicked; }
[ "erickohartanto@Erickos-MacBook-Pro.local" ]
erickohartanto@Erickos-MacBook-Pro.local
27940e4b21f3ca69109feb6deab118700e13be7f
c3f781286ebf1832ee4809678c1eda1f4755442a
/HashTable.h
ff86645c5c13575177a06e6a1a486060ab08bb99
[]
no_license
shunjizhan/Social-Network
faffe94cbcbf9c1c654dde6d34e17167a7e56c6e
725c95bf653aa8b6247d3d29a68e8212fd010bfc
refs/heads/master
2021-06-15T17:45:33.569851
2017-03-29T01:44:56
2017-03-29T01:44:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
493
h
#include <vector> #include "Node.h" using namespace std; class HashTable { public: const static int TABLE_SIZE = 211; HashTable(); void insert(string name, int index, vector<string> friends); int search(string name); // find index in the hash table int hash(string name); void addFriend(string friend1, string friend2); void printAll(); int getUserIndex(string name); void printUser(vector<string> info); Node* getNode(int index); private: Node** table; };
[ "shunjizhan@umail.ucsb.edu" ]
shunjizhan@umail.ucsb.edu
2f7e24c165d1e8a72feaefcd23ae68fb88189787
389f92dc3a47bed51466cb1106b8e12852b9f79c
/ isoftstone/src/hmi/edcc/resource.h
c0bb3aae284258e90c1931f04a518933af4c2b9d
[]
no_license
radtek/isoftstone
4dc99ea83c26c802e1eded1ce23aa7ebdce29a86
e1abede2913885a6374dfe9d1ab54aa85ed8e61f
refs/heads/master
2021-01-06T20:46:17.654521
2013-08-24T01:49:57
2013-08-24T01:49:57
41,403,225
3
4
null
null
null
null
GB18030
C++
false
false
1,555
h
#ifndef RESOURCE_H #define RESOURCE_H #include <string> #include <vector> #include <map> #include <QVector> #include <QVariant> #include <QMutex> #include <QMutexLocker> /* 用于保存内存数据 对于界面数据的显示,有两种策略: 其一:接收线程根据规约处理完报文数据后直接Post给主界面,这样可以节省内存操作,但是此操作不易保存历史数据。 其二:接收线程根据规约处理完报文数据后放到内存保存,由主界面定时器主动去获取数据并显示,此处不需要另外线程。 另外,历史线程也会定时去获取内存数据并保存到文件中,并且根据时间进行各类统计。 还有一个线程负责处理上位机实时数据请求,并且将数据打包发给上位机。 */ struct SMeasureInfo { SMeasureInfo() { resourceID = 0; type = -1; } quint64 resourceID; float upper; float lower; QString name; int type; QVariant value; }; class CResource { public : static CResource* instance(); void init(); SMeasureInfo getInfo(quint64 id); QVariant getValue(quint64 id); QMap<quint64,QVariant> getValues(const QList<quint64>& vecIDs); void setValue(quint64 id ,const QVariant& value); QMap<quint64,SMeasureInfo> getValues(); QList<quint64> getResourceIDs(); void clear(); private: CResource(){}; private: QMap<quint64,SMeasureInfo> m_MeaInfoMap; QMutex m_Mutex; static CResource* s_Resource; }; #endif
[ "liuruigong@gmail.com" ]
liuruigong@gmail.com
361f1c9dab7700fdc399a4846a72f80fdc9a1f3b
988f74fd1f5e04811c19137a239e9c2fecdae6be
/segmentation/GridMap.h
93a32afee56ece50d68ae485dffb2718d4c8d1b8
[]
no_license
aemarkov/lidar-road-segmentation
fadf9d1c915341bf3ddad07dc1a7593582dd818e
6643ebe7eb0cd54d84d00c4c8515b561ae031583
refs/heads/master
2023-09-01T07:09:58.583045
2020-08-03T08:55:43
2020-08-03T08:55:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,805
h
// // Created by garrus on 13.12.18. // #ifndef ROAD_SEGMENTATION_GRIDMAP_H #define ROAD_SEGMENTATION_GRIDMAP_H #include <vector> #include <pcl/common/common_headers.h> #include <GridCoord.h> #include <Grid.h> enum Obstacle { UNKNOW = 0, FREE, OBSTACLE }; /** * \brief 2D Occupancy Grid with some additional information * * - Store 2D occupancy grid * - Store original point cloud * - Store 2D grid coordinate of each point in point cloud * (e.g. for visualization purposes) * - Store size, cell size, min/max of bounding box * * @tparam TPoint pcl::PointCloud template argument */ template <class TPoint> class GridMap { public: /** * \brief Initialize the empty grid map of given PointCloud * * Calculate the required grid size based on cell size and point cloud size. * Do not perform placing points into the cells. * * @param cloud * @param cell_size */ GridMap(const typename pcl::PointCloud<TPoint>::ConstPtr& cloud, float cell_size, TPoint min, TPoint max) : CELL_SIZE(cell_size), _min(min), _max(max), _rows((size_t)ceil((max.x - min.x) / cell_size)), _cols((size_t)ceil((max.y - min.y) / cell_size)), _cloud(cloud), _point_cells(cloud->points.size()), _obstacles(_rows, _cols) { } GridMap(GridMap&& grid) : CELL_SIZE(grid.CELL_SIZE), _rows(grid._rows), _cols(grid._cols), _min(grid._min), _max(grid._max), _cloud(grid._cloud), _point_cells(std::move(grid._point_cells)), _obstacles(std::move(grid._obstacles)) { } ~GridMap() { } Grid<Obstacle>& obstacles() { return _obstacles; } const Grid<Obstacle>& obstacles() const { return _obstacles; } TPoint& cloud_at(size_t index) { return _cloud->at(index); } const TPoint& cloud_at(size_t index) const { return _cloud->at(index); } typename pcl::PointCloud<TPoint>::Ptr cloud(){ return _cloud; } size_t cloud_size() const {return _cloud->points.size(); } GridCoord& point_cell(size_t index) { return _point_cells[index]; } GridCoord point_cell(size_t index) const { return _point_cells[index]; } const TPoint& min() const { return _min; } const TPoint& max() const { return _max; } size_t rows() const { return _rows; } size_t cols() const { return _cols; } GridCoord size() const { return GridCoord(_rows, _cols); } float cell_size() const { return CELL_SIZE; } private: const float CELL_SIZE; const TPoint _min, _max; const size_t _rows, _cols; typename pcl::PointCloud<TPoint>::ConstPtr _cloud; std::vector<GridCoord> _point_cells; // coord of cell for each point Grid<Obstacle> _obstacles; }; #endif //ROAD_SEGMENTATION_GRIDMAP_H
[ "markovalex95@gmail.com" ]
markovalex95@gmail.com
8c39665e4e03fa38f1c72c4d27e5785937deda25
ac75560a56c0698ff098251f8d4bc5bf2a0dc3db
/examples/FlashErase/FlashErase.ino
16af96fa62f5790da6b83d37865d79e04dc31ee7
[ "MIT" ]
permissive
Hansen0314/Seeed_Arduino_SFUD
e0fdc58f356dfea9a4a0b7c5b0a39ca439b12d4a
d2a3a1776b3f54a71452051daa7ff97d811dc4bd
refs/heads/master
2022-07-17T13:33:27.460560
2020-05-13T08:14:41
2020-05-13T08:14:41
259,585,337
1
0
MIT
2020-04-28T09:03:35
2020-04-28T09:03:34
null
UTF-8
C++
false
false
896
ino
#include <sfud.h> #define SFUD_DEMO_TEST_BUFFER_SIZE 1024 static uint8_t sfud_demo_test_buf[SFUD_DEMO_TEST_BUFFER_SIZE]; static void sfud_demo(uint32_t addr, size_t size, uint8_t *data); #define SERIAL Serial #ifdef ARDUINO_ARCH_SAMD #undef SERIAL Serial #define SERIAL SerialUSB #endif void setup() { SERIAL.begin(115200); while(!SERIAL) {}; while(!(sfud_init() == SFUD_SUCCESS)); /* erase test */ const sfud_flash *flash = sfud_get_device_table() + 0; uint32_t addr = 0; size_t size = sizeof(sfud_demo_test_buf); uint8_t result = sfud_erase(flash, addr, size); if (result == SFUD_SUCCESS) { printf("Erase the %s flash data finish. Start from 0x%08X, size is %ld.\r\n", flash->name, addr, size); } else { printf("Erase the %s flash data failed.\r\n", flash->name); } } void loop() { }
[ "595355940@qq.com" ]
595355940@qq.com
4d8de2ce86702aab7ff29e81ad448c332b3ef220
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-ec2/source/model/DescribeReservedInstancesRequest.cpp
11ce500c9ddbdff07c4535f8d551756c09402b70
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
2,259
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/ec2/model/DescribeReservedInstancesRequest.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> using namespace Aws::EC2::Model; using namespace Aws::Utils; DescribeReservedInstancesRequest::DescribeReservedInstancesRequest() : m_dryRun(false), m_dryRunHasBeenSet(false), m_reservedInstancesIdsHasBeenSet(false), m_filtersHasBeenSet(false), m_offeringType(OfferingTypeValues::NOT_SET), m_offeringTypeHasBeenSet(false), m_offeringClass(OfferingClassType::NOT_SET), m_offeringClassHasBeenSet(false) { } Aws::String DescribeReservedInstancesRequest::SerializePayload() const { Aws::StringStream ss; ss << "Action=DescribeReservedInstances&"; if(m_dryRunHasBeenSet) { ss << "DryRun=" << std::boolalpha << m_dryRun << "&"; } if(m_reservedInstancesIdsHasBeenSet) { unsigned reservedInstancesIdsCount = 1; for(auto& item : m_reservedInstancesIds) { ss << "ReservedInstancesId." << reservedInstancesIdsCount << "=" << StringUtils::URLEncode(item.c_str()) << "&"; reservedInstancesIdsCount++; } } if(m_filtersHasBeenSet) { unsigned filtersCount = 1; for(auto& item : m_filters) { item.OutputToStream(ss, "Filter.", filtersCount, ""); filtersCount++; } } if(m_offeringTypeHasBeenSet) { ss << "OfferingType=" << OfferingTypeValuesMapper::GetNameForOfferingTypeValues(m_offeringType) << "&"; } if(m_offeringClassHasBeenSet) { ss << "OfferingClass=" << OfferingClassTypeMapper::GetNameForOfferingClassType(m_offeringClass) << "&"; } ss << "Version=2016-11-15"; return ss.str(); }
[ "henso@amazon.com" ]
henso@amazon.com
70011f1ff16ef3aca267296a94a6d92ff5c1cc63
9ba354f2dfb6755864560e258d1a6e9970641b0c
/TCore/dllmain.cpp
0d81e05b5d05895ebe6fee5da03d9540ef39f02c
[ "MIT" ]
permissive
thirty30/Muffin
b808d75b1b5bb78dc463c64ab159d889cc873e79
06db87761be740408457728a40d95cdc8ec05108
refs/heads/master
2020-08-04T02:02:34.009543
2020-04-14T19:56:58
2020-04-14T19:56:58
211,962,180
5
0
null
null
null
null
UTF-8
C++
false
false
269
cpp
#include "stdafx.h" BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
[ "402050805@qq.com" ]
402050805@qq.com
151f7625adf5a148b23df572275d53dee59f434e
6e09bfc1f306d1ea8aff2464ab001d45dd4a996b
/ElectionCopy2/DistrictResult.cpp
fe824a867c50511796c340a4d006f9de695b2219
[]
no_license
avivmor2103/ElectionSystemProject
ac95815e406af45a04c65a6d02ac2e9588b544de
7dd8b25a6f4869dcfe73ac4dae297a6fb424b102
refs/heads/master
2023-04-04T21:02:15.438448
2021-04-20T17:54:40
2021-04-20T17:54:40
356,373,503
0
0
null
null
null
null
UTF-8
C++
false
false
3,606
cpp
#include "DistrictResult.h" DistrictResult::DistrictResult() { this->lSize = 0; this->phSize = 1; try { result = new DistrictVotes[phSize]; } catch (std::bad_alloc& ex) { cout << ex.what() << endl; exit(1); } } DistrictResult::~DistrictResult() { delete[] result; } DistrictResult::DistrictResult(const DistrictResult& res) { this->lSize = res.lSize; this->phSize = res.phSize; this->result = res.result; } int DistrictResult::getNumOfVotes(int partyId) const { return result[partyId].numberOfVoters; } int DistrictResult::getLSize() const { return this->lSize; } void DistrictResult::addParty(const Party* party) { if (lSize == phSize) { phSize *= 2; DistrictVotes* temp = nullptr; try { temp = new DistrictVotes[phSize]; } catch (std::bad_alloc& ex) { cout << ex.what() << endl; exit(1); } memcpy(temp, result, lSize * sizeof(DistrictVotes)); delete[]result; result = temp; } result[lSize].party = party; lSize++; } void DistrictResult::saveResults(ofstream& file)const { int partyid; for (int i = 0; i < lSize; i++) { partyid = result[i].party->getPartyID(); file.write(rcastcc(&partyid), sizeof(int)); file.write(rcastcc(&(result[i].numberOfVoters)), sizeof(int)); file.write(rcastcc(&(result[i].numOfReps)), sizeof(int)); if (!file.good()) throw "problem occurred while loading data from the file"; } } void DistrictResult::loadDistricResults(ifstream& file, const PartyArr& partyList) { int size; file.read(rcastc(&size), sizeof(int)); if (!file.good()) throw "problem occurred while loading data from the file"; delete[]result; try { result = new DistrictVotes[size]; } catch (std::bad_alloc& ex) { cout << ex.what() << endl; exit(1); } DistrictVotes* newDisVotes = nullptr; for (int i = 0; i < size; i++) { try { newDisVotes = new DistrictVotes(file, partyList); } catch (bad_alloc& ex) { cout << "Error:" << ex.what() << endl; exit(1); } if (!file.good()) throw "problem occurred while loading data from the file"; result[i].party = newDisVotes->party; result[i].numberOfVoters = newDisVotes->numberOfVoters; result[i].numOfReps = newDisVotes->numOfReps; newDisVotes = nullptr; } lSize = size; phSize = size; delete newDisVotes; } DistrictResult::DistrictVotes::DistrictVotes(ifstream& file, const PartyArr& partyList) { int paryId, numOfVotes, numOfReps; file.read(rcastc(&paryId), sizeof(int)); file.read(rcastc(&numOfVotes), sizeof(int)); file.read(rcastc(&numOfReps), sizeof(int)); if (!file.good()) { throw "problem occurred while loading data from the file"; } this->party = &partyList.getParty(paryId); this->numberOfVoters = numOfVotes; this->numOfReps = numOfReps; } const DistrictResult& DistrictResult::operator=(const DistrictResult& origin) { this->lSize = origin.lSize; this->phSize = origin.phSize; delete[]result; result = new DistrictVotes[phSize]; for (int i = 0; i < lSize; i++) { result[i].numberOfVoters = origin.result[i].numberOfVoters; result[i].numOfReps = origin.result[i].numOfReps; result[i].party = origin.result[i].party; } return *this; }
[ "avivmore88@gmail.com" ]
avivmore88@gmail.com
10cc70b1993d525716563a9e8c27d233bf2f2e51
f7f6602e4b64c3cb45eab943bdba226a6e4efaf0
/include/Propitious/Memory/allocator.hpp
432f2a8cfa62cfb6c26c3c9f861a6b01aec5e0df
[]
no_license
SleepyAkubi/PropitiousPrivate
8dd87dc8ce182021dae2fb25387b1bb84c825634
e801f567a08d54ce643f457f079a3c3059079169
refs/heads/master
2022-10-02T12:09:17.388756
2016-02-27T19:12:50
2016-02-27T19:12:50
44,257,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,363
hpp
#ifndef PROPITIOUS_MEMORY_ALLOCATOR_HPP #define PROPITIOUS_MEMORY_ALLOCATOR_HPP #include <Propitious/Common.hpp> #include <new> #include <utility> namespace Propitious { class PROPITIOUS_EXPORT Allocator : private NonCopyable { public: using vol = usize; static const vol defaultAlignment = 4; static const vol notTracked = (vol)(-1); Allocator() {} virtual ~Allocator() {} virtual void* allocate(vol size, vol alignment = defaultAlignment) = 0; virtual void deallocate(void* pointer) = 0; virtual vol allocatedSize(void* pointer) = 0; template <typename T, typename... Args> T* spawn(Args&&... args) { return new (allocate(sizeof(T), alignof(T))) T(std::forward<Args>(args...)); } template <typename T> void murder(T* ptr) { if (ptr) { ptr->~T(); deallocate(ptr); } } }; namespace EndOf { const Allocator::vol Vol = (Allocator::vol)(-1); } PROPITIOUS_EXPORT Allocator& defaultAllocator(); } /* #ifndef PROPITIOUS_DONT_MANAGE_MEMORY inline void* operator new(Propitious::usize size) { Propitious::Allocator& allocator = Propitious::defaultAllocator(); return allocator.allocate((Propitious::Allocator::vol) size); } inline void operator delete(void* size) { Propitious::Allocator& allocator = Propitious::defaultAllocator(); return allocator.deallocate(size); } #endif */ #endif
[ "thewarpdimension@gmail.com" ]
thewarpdimension@gmail.com
74be42ba426c1650f995de4a5ddaed1ffc04f073
d4b733f2e00b5d0ab103ea0df6341648d95c993b
/src/c-cpp/lib/sst/private/guts/windows_socket_core/native_so_reuseport.cpp
3c11a25fee80bb679223c19ab226d966ccd8ce97
[ "MIT" ]
permissive
stealthsoftwareinc/sst
ad6117a3d5daf97d947862674336e6938c0bc699
f828f77db0ab27048b3204e10153ee8cfc1b2081
refs/heads/master
2023-04-06T15:21:14.371804
2023-03-24T08:30:48
2023-03-24T08:30:48
302,539,309
1
0
null
null
null
null
UTF-8
C++
false
false
1,638
cpp
// // Copyright (C) 2012-2023 Stealth Software Technologies, Inc. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: // // The above copyright notice and this permission notice (including // the next paragraph) shall be included in all copies or // substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // // SPDX-License-Identifier: MIT // // Include first to test independence. #include <sst/private/guts/windows_socket_core.hpp> // Include twice to test idempotence. #include <sst/private/guts/windows_socket_core.hpp> // #include <sst/config.h> #if SST_WITH_WINDOWS_WS2_32 namespace sst { namespace guts { int windows_socket_core::native_so_reuseport() { return 0; } } // namespace guts } // namespace sst #endif // #if SST_WITH_WINDOWS_WS2_32
[ "sst@stealthsoftwareinc.com" ]
sst@stealthsoftwareinc.com
90960cf1843f505379f46931651c6f5738cad984
682b27ef061c6aa0f4ad22a3d9c28350110682b7
/quickPing/quickPing/widget.cpp
0fb018e8982d4ed1c1b652a772897ca9d17115a8
[]
no_license
tangston/quickPing
48a43120573102330b28dd16311f168ead6c8b61
f0263d3749c70fda7b0feb35acae7ec5508ee3c3
refs/heads/master
2020-04-13T14:19:41.103154
2018-12-27T06:58:58
2018-12-27T06:58:58
163,259,213
1
0
null
null
null
null
UTF-8
C++
false
false
1,064
cpp
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } void Widget::on_startButton_clicked() { myPing mp =myPing(); // QString ip="10.1.11.70"; QString ip=ui->ipEdit->toPlainText();//获取文本框的函数 if(ip==NULL){ QMessageBox box; box.setText(tr("please type your message")); box.exec(); } else{ QStringList list=ip.split("."); QString str=list[3]; int m=str.toInt( ); for(int i=m;i< m+10;++i) { mp.ipCount(ip,i); if( mp.ping(ip) ){ ui->listWidget->addItem(ip+": on "); qDebug()<<"ping yes"; } else { ui->listWidget->addItem(ip+": offline"); qDebug()<<"ping no"; } } } } void Widget::autoScroll()//自动滚屏 { } void Widget::on_exitButton_clicked() { ::exit(0); }
[ "37773841+tangston@users.noreply.github.com" ]
37773841+tangston@users.noreply.github.com
19042bee0ea3b594fc4ba400bc5e0dae4dacc814
385314c17cabc082aa54d97c2693d66bb0976a64
/lib/tao/tao/json/external/pegtl/internal/star.hpp
6986c043cb09c53a432d244c45877a27ba27f137
[ "MIT" ]
permissive
21doublenexus/contemplative-game
dd835e66f928ddecc4bd3ab267a04a9058856ac8
cadf92c1b44d226bf97a87f738ea3aad3e7dd376
refs/heads/main
2023-02-15T08:55:55.187533
2021-01-05T17:15:37
2021-01-05T17:15:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,514
hpp
// Copyright (c) 2014-2018 Dr. Colin Hirsch and Daniel Frey // Please see LICENSE for license or visit https://github.com/taocpp/PEGTL/ #ifndef TAO_JSON_PEGTL_INTERNAL_STAR_HPP #define TAO_JSON_PEGTL_INTERNAL_STAR_HPP #include <type_traits> #include "../config.hpp" #include "duseltronik.hpp" #include "seq.hpp" #include "skip_control.hpp" #include "../apply_mode.hpp" #include "../rewind_mode.hpp" #include "../analysis/generic.hpp" namespace tao { namespace TAO_JSON_PEGTL_NAMESPACE { namespace internal { template< typename Rule, typename... Rules > struct star { using analyze_t = analysis::generic< analysis::rule_type::OPT, Rule, Rules..., star >; template< apply_mode A, rewind_mode, template< typename... > class Action, template< typename... > class Control, typename Input, typename... States > static bool match( Input& in, States&&... st ) { while( seq< Rule, Rules... >::template match< A, rewind_mode::REQUIRED, Action, Control >( in, st... ) ) { } return true; } }; template< typename Rule, typename... Rules > struct skip_control< star< Rule, Rules... > > : std::true_type { }; } // namespace internal } // namespace TAO_JSON_PEGTL_NAMESPACE } // namespace tao #endif
[ "vscavinner@gmail.com" ]
vscavinner@gmail.com
df5ba23233690846709f5c047670e85f48714833
fa6b818e06c5b97ddb131e18bca14ead19091a7f
/Goblim-Student/Core/Engine/Base/Light.hpp
31a927beb4dd1627d7e4fba7705fd8941e2990b6
[]
no_license
nathmotion/Moteur-3D
2bcd2f4624071cda0a4f1d6e510843bf6908dc8b
df6222ba62f92958874677510dfef9473eb1c459
refs/heads/master
2021-07-23T01:33:18.183697
2017-11-01T06:32:18
2017-11-01T06:32:18
107,647,261
0
0
null
null
null
null
UTF-8
C++
false
false
245
hpp
#ifndef _GOBLIM_LIGHT_ #define _GOBLIM_LIGHT_ #include <glm/glm.hpp> #include <string.h> class Light { public: Light(std::string name,glm::vec3 color = glm::vec3(1.0f)); private: glm::vec4 m_Color; std::string m_Name; } #endif
[ "mallet.nathanael@hotmail.fr" ]
mallet.nathanael@hotmail.fr
79d5df9ebdb532a0ca8cb3478651e5ee4377b6ca
afe5e1d8ca27d3465abd0770de11714d78830310
/runtime/stdlib/llambda/list/list.cpp
6c380520104e06891ade12f25219eadd07dab3fe
[ "Apache-2.0" ]
permissive
8l/llambda
8a0c62b744ab0a45d7dd86355823fc70ee93b924
a8624ddb1c8ae1e7ba55d0f853050798892daa58
refs/heads/master
2020-12-25T23:57:24.994389
2015-04-14T10:34:08
2015-04-14T10:34:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,810
cpp
#include <vector> #include <sstream> #include "binding/ListElementCell.h" #include "binding/BooleanCell.h" #include "binding/ProperList.h" #include "binding/TypedProcedureCell.h" #include "binding/FlonumCell.h" #include "binding/ExactIntegerCell.h" #include "alloc/StrongRefVector.h" #include "core/error.h" using namespace lliby; namespace { struct SplitResult { ProperList<AnyCell> *head; AnyCell *tail; }; SplitResult splitList(World &world, const char *procName, AnyCell *obj, std::uint32_t count) { AnyCell *tail = obj; alloc::StrongRefVector<AnyCell> headElements(world); while(count--) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { std::ostringstream message; message << procName << " on list of insufficient length"; signalError(world, ErrorCategory::Range, message.str()); } headElements.push_back(pairTail->car()); tail = cell_unchecked_cast<AnyCell>(pairTail->cdr()); } // Root our tail while we allocate the head list alloc::StrongRoot<AnyCell> tailRoot(world, &tail); // Build the head list ProperList<AnyCell> *head = ProperList<AnyCell>::create(world, headElements); return {head, tail}; } struct SpanResult { ProperList<AnyCell> *head; ProperList<AnyCell> *tail; }; template<typename T> SpanResult spanList(World &world, const char *procName, ProperList<AnyCell> *list, T predicate) { alloc::StrongRef<ProperList<AnyCell>> tail(world, list); alloc::StrongRefVector<AnyCell> headElements(world); while(true) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { // Ran out of list break; } if (!predicate(pairTail->car())) { // Predicate failed break; } headElements.push_back(pairTail->car()); tail = cell_unchecked_cast<ProperList<AnyCell>>(pairTail->cdr()); } // Build the head list ProperList<AnyCell> *head = ProperList<AnyCell>::create(world, headElements); return {head, tail}; } /** * Applies a procedure with the head values from a series of input lists and advances the lists * * If any of the lists have reached their end then this will return false and not apply the procedure. The input * lists are of type AnyCell to reflect that this function and its callers should be prepared to have its input * lists mutated to improper lists by the passed procedure. * * @param world World to apply the procedure in * @param firstList Reference to the first proper list of values. This will be advanced to the next element. * @param restLists Vector of other value proper lists. These will be advanced to their next elements. * @param proc Procedure to apply. This will be passed one argument from each of the input lists. * @param result Pointer to a location to store the result value. If this function returns false then the * result will not be written to. * @return Boolean indicating if all of the input lists were non-empty and the procedure was invoked. */ template<typename T> bool consumeInputLists(World &world, alloc::StrongRef<AnyCell> &firstList, alloc::StrongRefVector<AnyCell> &restLists, alloc::StrongRef<TypedProcedureCell<T, AnyCell*, RestValues<AnyCell>*>> proc, T* result) { auto firstPair = cell_cast<PairCell>(firstList); if (firstPair == nullptr) { // Reached end of the first list return false; } // Advance the list and store the head value firstList.setData(cell_unchecked_cast<ProperList<AnyCell>>(firstPair->cdr())); AnyCell *firstValue = firstPair->car(); std::vector<AnyCell*> restValues(restLists.size()); for(std::size_t i = 0; i < restLists.size(); i++) { auto restPair = cell_cast<PairCell>(restLists[i]); if (restPair == nullptr) { return false; } // Advance the list and store the head value restLists[i] = cell_unchecked_cast<ProperList<AnyCell>>(restPair->cdr()); restValues[i] = restPair->car(); } // Build the rest argument list RestValues<AnyCell> *restArgList = RestValues<AnyCell>::create(world, restValues); // Apply the function *result = proc->apply(world, firstValue, restArgList); return true; } } extern "C" { using PredicateProc = TypedProcedureCell<bool, AnyCell*>; using FoldProc = TypedProcedureCell<AnyCell*, AnyCell*, AnyCell*, RestValues<AnyCell>*>; using TabulateProc = TypedProcedureCell<AnyCell*, std::int64_t>; using AppendMapProc = TypedProcedureCell<ProperList<AnyCell>*, AnyCell*, RestValues<AnyCell>*>; using FilterMapProc = TypedProcedureCell<AnyCell*, AnyCell*, RestValues<AnyCell>*>; using AnyProc = TypedProcedureCell<AnyCell*, AnyCell*, RestValues<AnyCell>*>; using EveryProc = AnyProc; using CountProc = AnyProc; AnyCell *lllist_cons_star(World &world, AnyCell *headValue, RestValues<AnyCell> *tailValues) { const auto elementCount = tailValues->size() + 1; if (elementCount == 1) { // This is easy return headValue; } std::vector<AnyCell*> nonTerminalElements(elementCount - 1); nonTerminalElements[0] = headValue; auto tailArgIt = tailValues->begin(); for(RestValues<AnyCell>::size_type i = 1; i < (elementCount - 1); i++) { nonTerminalElements[i] = *(tailArgIt++); } return ListElementCell::createList(world, nonTerminalElements, *tailArgIt); } AnyCell* lllist_fold(World &world, FoldProc *foldProcRaw, AnyCell *initialValue, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<FoldProc> foldProc(world, foldProcRaw); alloc::StrongRef<AnyCell> accum(world, initialValue); // Collect our input lists alloc::StrongRefVector<ListElementCell> inputLists(world); inputLists.push_back(firstListRaw); for(auto restList : *restListsRaw) { // Create the strong ref for the rest list inputLists.push_back(restList); } const auto inputListCount = inputLists.size(); std::vector<AnyCell*> inputVector(inputListCount + 1); std::vector<AnyCell*> restArgVector(inputListCount - 1); while(true) { // Collect our input from out input lists for(size_t i = 0; i < inputListCount; i++) { if (inputLists[i] == EmptyListCell::instance()) { // Reached the end of the list return accum; } auto inputListPair = cell_unchecked_cast<PairCell>(inputLists[i]); inputVector[i] = inputListPair->car(); // Move this forward to the next element inputLists[i] = cell_checked_cast<ListElementCell>(world, inputListPair->cdr(), "Input list mutated during (fold)"); } inputVector[inputListCount] = accum; // Create the rest argument list - the first two input values are passed explicitly std::copy(inputVector.begin() + 2, inputVector.end(), restArgVector.begin()); RestValues<AnyCell> *restArgList = RestValues<AnyCell>::create(world, restArgVector); auto resultValue = foldProc->apply(world, inputVector[0], inputVector[1], restArgList); accum.setData(resultValue); } } ReturnValues<ProperList<AnyCell>>* lllist_partition(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *listHeadRaw) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<ListElementCell> listHead(world, listHeadRaw); alloc::StrongRefVector<AnyCell> trueValues(world); alloc::StrongRefVector<AnyCell> falseValues(world); while(listHead != EmptyListCell::instance()) { // This must be a pair if we're not the empty list and the predicate hasn't been called yet auto headPair = cell_unchecked_cast<PairCell>(listHead); AnyCell *headValue = headPair->car(); if (predicateProc->apply(world, headValue)) { trueValues.push_back(headValue); } else { falseValues.push_back(headValue); } auto *nextHead = cell_checked_cast<ListElementCell>(world, headPair->cdr(), "Input list mutated during (partition)"); listHead.setData(nextHead); } alloc::StrongRef<ProperList<AnyCell>> trueList(world, ProperList<AnyCell>::create(world, trueValues)); ProperList<AnyCell> *falseList(ProperList<AnyCell>::create(world, falseValues)); return ReturnValues<ProperList<AnyCell>>::create(world, {trueList, falseList}); } ProperList<AnyCell>* lllist_list_tabulate(World &world, std::uint32_t count, TabulateProc *initProcRaw) { alloc::StrongRef<TabulateProc> initProc(world, initProcRaw); alloc::StrongRefVector<AnyCell> resultVec(world); for(std::uint32_t i = 0; i < count; i++) { resultVec.push_back(initProc->apply(world, i)); } return ProperList<AnyCell>::create(world, resultVec); } ProperList<AnyCell>* lllist_take(World &world, AnyCell *obj, std::uint32_t count) { return splitList(world, "(take)", obj, count).head; } AnyCell *lllist_drop(World &world, AnyCell *obj, std::uint32_t count) { // Avoid splitList because it will allocate the head list which we don't use AnyCell *tail = obj; while(count--) { auto pairTail = cell_cast<PairCell>(tail); if (pairTail == nullptr) { signalError(world, ErrorCategory::Range, "(drop) on list of insufficient length"); } tail = cell_unchecked_cast<AnyCell>(pairTail->cdr()); } return tail; } ReturnValues<AnyCell>* lllist_split_at(World &world, AnyCell *obj, std::uint32_t count) { SplitResult result = splitList(world, "(split-at)", obj, count); return ReturnValues<AnyCell>::create(world, {result.head, result.tail}); } ReturnValues<ProperList<AnyCell>>* lllist_span(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *list) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); SpanResult result = spanList(world, "(span)", list, [&] (AnyCell *datum) { return predicateProc->apply(world, datum); }); return ReturnValues<ProperList<AnyCell>>::create(world, {result.head, result.tail}); } ReturnValues<ProperList<AnyCell>>* lllist_break(World &world, PredicateProc *predicateProcRaw, ProperList<AnyCell> *list) { alloc::StrongRef<PredicateProc> predicateProc(world, predicateProcRaw); SpanResult result = spanList(world, "(break)", list, [&] (AnyCell *datum) { return !predicateProc->apply(world, datum); }); return ReturnValues<ProperList<AnyCell>>::create(world, {result.head, result.tail}); } AnyCell* lllist_any(World &world, AnyProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { // GC root everything alloc::StrongRef<AnyProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); // Run until we get a truth-y value while(true) { AnyCell *resultValue; if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Ran out of lists return BooleanCell::falseInstance(); } if (resultValue != BooleanCell::falseInstance()) { // Found a non-false value return resultValue; } } } AnyCell* lllist_every(World &world, EveryProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<EveryProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); // If all lists are empty we should return #t AnyCell *resultValue = BooleanCell::trueInstance(); // Run until we get a false value while(true) { if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Ran out of lists - return the last result value // This depends on consumeInputLists not modifying resultValue when it returns false return resultValue; } if (resultValue == BooleanCell::falseInstance()) { // Found a false value - we're false return BooleanCell::falseInstance(); } } } std::int64_t lllist_count(World &world, CountProc *predicateProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<CountProc> predicateProc(world, predicateProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); std::int64_t counter = 0; while(true) { AnyCell *resultValue; if (!consumeInputLists<AnyCell*>(world, firstList, restLists, predicateProc, &resultValue)) { // Out of lists return counter; } if (resultValue != BooleanCell::falseInstance()) { counter++; } } } ProperList<AnyCell>* lllist_append_map(World &world, AppendMapProc *mapProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<AppendMapProc> mapProc(world, mapProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); alloc::StrongRefVector<AnyCell> resultValues(world); ProperList<AnyCell> *resultList; while(consumeInputLists(world, firstList, restLists, mapProc, &resultList)) { // Splice this list on to the results resultValues.insert(resultValues.end(), resultList->begin(), resultList->end()); } return ProperList<AnyCell>::create(world, resultValues); } ProperList<AnyCell>* lllist_filter_map(World &world, FilterMapProc *mapProcRaw, ProperList<AnyCell> *firstListRaw, RestValues<ProperList<AnyCell>> *restListsRaw) { alloc::StrongRef<FilterMapProc> mapProc(world, mapProcRaw); alloc::StrongRef<AnyCell> firstList(world, firstListRaw); alloc::StrongRefVector<AnyCell> restLists(world, restListsRaw->begin(), restListsRaw->end()); alloc::StrongRefVector<AnyCell> resultValues(world); AnyCell *resultValue; while(consumeInputLists(world, firstList, restLists, mapProc, &resultValue)) { if (resultValue != BooleanCell::falseInstance()) { // Add this value to the results resultValues.push_back(resultValue); } } return ProperList<AnyCell>::create(world, resultValues); } ListElementCell* lllist_iota(World &world, std::uint32_t count, NumberCell *startCell, NumberCell *stepCell) { if (auto startExactIntCell = cell_cast<ExactIntegerCell>(startCell)) { if (auto stepExactIntCell = cell_cast<ExactIntegerCell>(stepCell)) { std::uint32_t start = startExactIntCell->value(); std::uint32_t step = stepExactIntCell->value(); std::vector<std::uint32_t> values(count); for(std::uint32_t i = 0; i < count; i++) { values[i] = start + (step * i); } return ProperList<ExactIntegerCell>::emplaceValues(world, values); } } double start = startCell->toDouble(); double step = stepCell->toDouble(); std::vector<double> values(count); for(std::uint32_t i = 0; i < count; i++) { values[i] = start + (step * i); } return ProperList<FlonumCell>::emplaceValues(world, values); } }
[ "etaoins@gmail.com" ]
etaoins@gmail.com
4598f3ac3e28b6a6c9258d192f14ce928b2e5695
83bab97601870553188e19700027457c8b0aaa34
/include/myslam/camera.h
7bbb23df5a0ca27fad1e0600c568efb8a992fcd3
[]
no_license
yxtwl94/Slam_demo
d31149df72a2db95c79dd7146e368e98e220226e
10b39352c8237b4d91d63c36b0a45af904b22822
refs/heads/master
2020-05-27T00:36:10.989504
2019-05-24T13:32:58
2019-05-24T13:32:58
183,479,015
0
0
null
null
null
null
UTF-8
C++
false
false
918
h
#ifndef CAMERA_H #define CAMERA_H #include "myslam/common_include.h" namespace myslam{ using namespace std; class Camera{ public: typedef shared_ptr<Camera> Ptr; float fx_, fy_, cx_, cy_,depth_scale_; Camera(); Camera( float fx ,float fy,float cx,float cy,float depth_scale=0): fx_(fx),fy_(fy),cx_(cx),cy_(cy),depth_scale_(depth_scale) {}; Vector3d world2camera( const Vector3d& p_w, const SE3& T_c_w ); Vector3d camera2world( const Vector3d& p_c, const SE3& T_c_w ); Vector2d camera2pixel( const Vector3d& p_c ); Vector3d pixel2camera( const Vector2d& p_p, double depth=1 ); Vector3d pixel2world ( const Vector2d& p_p, const SE3& T_c_w, double depth=1 ); Vector2d world2pixel ( const Vector3d& p_w, const SE3& T_c_w ); }; } #endif
[ "yxtwl95@hotmail.com" ]
yxtwl95@hotmail.com
4f646b096b384b1cd1cc8ffe7201644d9f7bd0d3
b9b17fcfac43774e730ecf221bc26164598010b6
/src/TXFaceWnd.h
69ea5625bd09efa522d09cda7ab49fb2f37ba43e
[ "BSD-3-Clause" ]
permissive
taviso/mpgravity
e2334e77e9d5e9769e05d24609e4bbed00f23b5c
f6a2a7a02014b19047e44db76ae551bd689c16ac
refs/heads/master
2023-07-26T00:49:37.297106
2020-04-24T06:15:10
2020-04-24T06:15:10
251,759,803
13
0
null
null
null
null
UTF-8
C++
false
false
3,200
h
/*****************************************************************************/ /* SOURCE CONTROL VERSIONS */ /*---------------------------------------------------------------------------*/ /* */ /* Version Date Time Author / Comment (optional) */ /* */ /* $Log: TXFaceWnd.h,v $ /* Revision 1.1 2010/07/21 17:14:56 richard_wood /* Initial checkin of V3.0.0 source code and other resources. /* Initial code builds V3.0.0 RC1 /* /* Revision 1.2 2009/08/25 20:04:25 richard_wood /* Updates for 2.9.9 /* /* Revision 1.1 2009/06/09 13:21:28 richard_wood /* *** empty log message *** /* /* Revision 1.2 2008/09/19 14:51:08 richard_wood /* Updated for VS 2005 /* /* */ /*****************************************************************************/ /********************************************************************************** Copyright (c) 2003, Albert M. Choy All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Microplanet, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************************/ #pragma once // TXFaceWnd.h : header file // ///////////////////////////////////////////////////////////////////////////// // TXFaceWnd window class TXFaceWnd : public CWnd { public: TXFaceWnd(); void SetXFace (LPCTSTR pszLine) ; virtual ~TXFaceWnd(); protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); DECLARE_MESSAGE_MAP() CStatic wndStatic; private: void *m_pixels; HBITMAP m_DIB; };
[ "taviso@gmail.com" ]
taviso@gmail.com
edc05d56ef306794323e488f09cc6b2b826c7bfb
8f50c262f89d3dc4f15f2f67eb76e686b8f808f5
/TestBeam/TBMonitoring/TBMonitoring/TBADCRawMonTool.h
c81d8d5186b118ef287c12b0f9f8c1d96a741c7c
[ "Apache-2.0" ]
permissive
strigazi/athena
2d099e6aab4a94ab8b636ae681736da4e13ac5c9
354f92551294f7be678aebcd7b9d67d2c4448176
refs/heads/master
2022-12-09T02:05:30.632208
2020-09-03T14:03:18
2020-09-03T14:03:18
292,587,480
0
1
null
null
null
null
UTF-8
C++
false
false
1,343
h
//Dear emacs, this is -*- c++ -*- /* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ #ifndef TBMONITORING_TBADCRAWMONTOOL_H #define TBMONITORING_TBADCRAWMONTOOL_H #include "AthenaMonitoring/MonitorToolBase.h" #include "GaudiKernel/IHistogramSvc.h" #include "AIDA/IHistogram1D.h" #include "AIDA/IHistogram2D.h" #include "StoreGate/StoreGateSvc.h" #include <string> #include <vector> /** @class TBADCRawMonTool TBADCRawMonTool.h "TBMonitoring/TBADCRawMonTool.h" This tool is used to create histograms of tdc data @author Malachi Schram */ class TBADCRawMonTool: public MonitorToolBase { public: TBADCRawMonTool(const std::string & type, const std::string & name, const IInterface* parent); ~TBADCRawMonTool(); StatusCode initialize(); StatusCode bookHists(); // this is called before 1st event StatusCode mybookHists(); // called at 1st event StatusCode fillHists(); // Test method void FillRandomDetect(); private: //std::string m_path; //Declared properties bool m_monitor_adc; bool m_testTool; bool m_isBooked; // ADC histograms IHistogram1D** m_histo_adc; // Histos ranges float m_posMax,m_posMin; int m_numBin; int m_adcNum; std::vector<std::string> m_adcNames; }; #endif // not TBMONITORING_TBADCRAWMONTOOL_H
[ "graemes.cern@gmail.com" ]
graemes.cern@gmail.com
4632c82ecc687a200a720fc5d88d5d6ac9ad436f
c509ec170f31580895c457c29e78463866397c17
/offline/Simulation/DetSim/ARRAY/LHAASOSim/include/LHAASOEventAction.hh
2931c74c3204f585a660a39e334847b8a21160c3
[]
no_license
feipengsy/lodestar
9e2c35cdbb6edf7ce31eff5fcf05412ff7f8453e
e05c01f15d8b3aeed265210a910e475beb11d9b6
refs/heads/master
2021-01-09T21:47:12.332609
2015-06-24T14:54:59
2015-06-24T14:54:59
36,277,481
0
0
null
null
null
null
UTF-8
C++
false
false
2,126
hh
// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // #ifndef LHAASO_EVENT_ACTION_HH #define LHAASO_EVENT_ACTION_HH 1 #include "G4UserEventAction.hh" #include "LHAASOUserAction.h" #include "globals.hh" class G4Event; class LHAASOEventAction : public G4UserEventAction, public LHAASOUserAction { public: LHAASOEventAction(); ~LHAASOEventAction(); void BeginOfEventAction(const G4Event* anEvent); void EndOfEventAction(const G4Event* anEvent); }; #endif
[ "liteng_shiyan@163.com" ]
liteng_shiyan@163.com
0dfaefddf7dacfeca8bfd45a08faf8dd56ae8343
8dc84558f0058d90dfc4955e905dab1b22d12c08
/components/viz/service/display/gl_renderer.h
1cd981c9d718f26cb57795628e1b1ce40c8ced5f
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
17,581
h
// Copyright 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_ #define COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_ #include <unordered_map> #include <vector> #include "base/cancelable_callback.h" #include "base/containers/circular_deque.h" #include "base/macros.h" #include "components/viz/common/gpu/context_cache_controller.h" #include "components/viz/common/quads/debug_border_draw_quad.h" #include "components/viz/common/quads/render_pass_draw_quad.h" #include "components/viz/common/quads/solid_color_draw_quad.h" #include "components/viz/common/quads/tile_draw_quad.h" #include "components/viz/common/quads/yuv_video_draw_quad.h" #include "components/viz/service/display/color_lut_cache.h" #include "components/viz/service/display/direct_renderer.h" #include "components/viz/service/display/gl_renderer_copier.h" #include "components/viz/service/display/gl_renderer_draw_cache.h" #include "components/viz/service/display/program_binding.h" #include "components/viz/service/display/scoped_gpu_memory_buffer_texture.h" #include "components/viz/service/display/sync_query_collection.h" #include "components/viz/service/display/texture_deleter.h" #include "components/viz/service/viz_service_export.h" #include "ui/gfx/geometry/quad_f.h" #include "ui/latency/latency_info.h" namespace base { class SingleThreadTaskRunner; } namespace gpu { namespace gles2 { class GLES2Interface; } } // namespace gpu namespace viz { class DynamicGeometryBinding; class GLRendererShaderTest; class OutputSurface; class ScopedRenderPassTexture; class StaticGeometryBinding; class StreamVideoDrawQuad; class TextureDrawQuad; // Class that handles drawing of composited render layers using GL. class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { public: class ScopedUseGrContext; GLRenderer(const RendererSettings* settings, OutputSurface* output_surface, DisplayResourceProvider* resource_provider, scoped_refptr<base::SingleThreadTaskRunner> current_task_runner); ~GLRenderer() override; bool use_swap_with_bounds() const { return use_swap_with_bounds_; } void SwapBuffers(std::vector<ui::LatencyInfo> latency_info, bool need_presentation_feedback) override; void SwapBuffersComplete() override; void DidReceiveTextureInUseResponses( const gpu::TextureInUseResponses& responses) override; virtual bool IsContextLost(); protected: void DidChangeVisibility() override; const gfx::QuadF& SharedGeometryQuad() const { return shared_geometry_quad_; } const StaticGeometryBinding* SharedGeometry() const { return shared_geometry_.get(); } // Returns the format to use for storage if copying from the current // framebuffer. If the root renderpass is current, it uses the best matching // format from the OutputSurface, otherwise it uses the best matching format // from the texture being drawn to as the backbuffer. GLenum GetFramebufferCopyTextureFormat(); void ReleaseRenderPassTextures(); enum BoundGeometry { NO_BINDING, SHARED_BINDING, CLIPPED_BINDING }; void PrepareGeometry(BoundGeometry geometry_to_bind); void SetStencilEnabled(bool enabled); bool stencil_enabled() const { return stencil_shadow_; } void SetBlendEnabled(bool enabled); bool blend_enabled() const { return blend_shadow_; } bool CanPartialSwap() override; void UpdateRenderPassTextures( const RenderPassList& render_passes_in_draw_order, const base::flat_map<RenderPassId, RenderPassRequirements>& render_passes_in_frame) override; void AllocateRenderPassResourceIfNeeded( const RenderPassId& render_pass_id, const RenderPassRequirements& requirements) override; bool IsRenderPassResourceAllocated( const RenderPassId& render_pass_id) const override; gfx::Size GetRenderPassBackingPixelSize( const RenderPassId& render_pass_id) override; void BindFramebufferToOutputSurface() override; void BindFramebufferToTexture(const RenderPassId render_pass_id) override; void SetScissorTestRect(const gfx::Rect& scissor_rect) override; void PrepareSurfaceForPass(SurfaceInitializationMode initialization_mode, const gfx::Rect& render_pass_scissor) override; void DoDrawQuad(const class DrawQuad*, const gfx::QuadF* draw_region) override; void BeginDrawingFrame() override; void FinishDrawingFrame() override; bool FlippedFramebuffer() const override; bool FlippedRootFramebuffer() const; void EnsureScissorTestEnabled() override; void EnsureScissorTestDisabled() override; void CopyDrawnRenderPass(std::unique_ptr<CopyOutputRequest> request) override; void SetEnableDCLayers(bool enable) override; void FinishDrawingQuadList() override; void GenerateMipmap() override; // Returns true if quad requires antialiasing and false otherwise. static bool ShouldAntialiasQuad(const gfx::QuadF& device_layer_quad, bool clipped, bool force_aa); // Inflate the quad and fill edge array for fragment shader. // |local_quad| is set to inflated quad. |edge| array is filled with // inflated quad's edge data. static void SetupQuadForClippingAndAntialiasing( const gfx::Transform& device_transform, const DrawQuad* quad, const gfx::QuadF* device_layer_quad, const gfx::QuadF* clip_region, gfx::QuadF* local_quad, float edge[24]); static void SetupRenderPassQuadForClippingAndAntialiasing( const gfx::Transform& device_transform, const RenderPassDrawQuad* quad, const gfx::QuadF* device_layer_quad, const gfx::QuadF* clip_region, gfx::QuadF* local_quad, float edge[24]); private: friend class GLRendererCopierPixelTest; friend class GLRendererShaderPixelTest; friend class GLRendererShaderTest; friend class GLRendererTest; using OverlayResourceLock = std::unique_ptr<DisplayResourceProvider::ScopedReadLockGL>; using OverlayResourceLockList = std::vector<OverlayResourceLock>; // If a RenderPass is used as an overlay, we render the RenderPass with any // effects into a texture for overlay use. We must keep the texture alive past // the execution of SwapBuffers, and such textures are more expensive to make // so we want to reuse them. struct OverlayTexture { RenderPassId render_pass_id; ScopedGpuMemoryBufferTexture texture; int frames_waiting_for_reuse = 0; }; struct DrawRenderPassDrawQuadParams; // If any of the following functions returns false, then it means that drawing // is not possible. bool InitializeRPDQParameters(DrawRenderPassDrawQuadParams* params); void UpdateRPDQShadersForBlending(DrawRenderPassDrawQuadParams* params); bool UpdateRPDQWithSkiaFilters(DrawRenderPassDrawQuadParams* params); void UpdateRPDQTexturesForSampling(DrawRenderPassDrawQuadParams* params); void UpdateRPDQBlendMode(DrawRenderPassDrawQuadParams* params); void ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, const gfx::ColorSpace& target_color_space); void UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params); void DrawRPDQ(const DrawRenderPassDrawQuadParams& params); static void ToGLMatrix(float* gl_matrix, const gfx::Transform& transform); void DiscardPixels(); void ClearFramebuffer(); void SetViewport(); void DrawDebugBorderQuad(const DebugBorderDrawQuad* quad); static bool IsDefaultBlendMode(SkBlendMode blend_mode) { return blend_mode == SkBlendMode::kSrcOver; } bool CanApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); void ApplyBlendModeUsingBlendFunc(SkBlendMode blend_mode); void RestoreBlendFuncToDefault(SkBlendMode blend_mode); gfx::Rect GetBackdropBoundingBoxForRenderPassQuad( const RenderPassDrawQuad* quad, const gfx::Transform& contents_device_transform, const cc::FilterOperations* filters, const cc::FilterOperations* background_filters, const gfx::QuadF* clip_region, bool use_aa, gfx::Rect* unclipped_rect); // Allocates and returns a texture id that contains a copy of the contents // of the current RenderPass being drawn. uint32_t GetBackdropTexture(const gfx::Rect& window_rect); static bool ShouldApplyBackgroundFilters( const RenderPassDrawQuad* quad, const cc::FilterOperations* background_filters); sk_sp<SkImage> ApplyBackgroundFilters( const RenderPassDrawQuad* quad, const cc::FilterOperations& background_filters, uint32_t background_texture, const gfx::Rect& rect, const gfx::Rect& unclipped_rect); const TileDrawQuad* CanPassBeDrawnDirectly(const RenderPass* pass) override; void DrawRenderPassQuad(const RenderPassDrawQuad* quadi, const gfx::QuadF* clip_region); void DrawRenderPassQuadInternal(DrawRenderPassDrawQuadParams* params); void DrawSolidColorQuad(const SolidColorDrawQuad* quad, const gfx::QuadF* clip_region); void DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, const gfx::QuadF* clip_region); void EnqueueTextureQuad(const TextureDrawQuad* quad, const gfx::QuadF* clip_region); void FlushTextureQuadCache(BoundGeometry flush_binding); void DrawTileQuad(const TileDrawQuad* quad, const gfx::QuadF* clip_region); void DrawContentQuad(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::QuadF* clip_region); void DrawContentQuadAA(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::Transform& device_transform, const gfx::QuadF& aa_quad, const gfx::QuadF* clip_region); void DrawContentQuadNoAA(const ContentDrawQuadBase* quad, ResourceId resource_id, const gfx::QuadF* clip_region); void DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, const gfx::QuadF* clip_region); void DrawOverlayCandidateQuadBorder(float* gl_matrix); void SetShaderOpacity(float opacity); void SetShaderQuadF(const gfx::QuadF& quad); void SetShaderMatrix(const gfx::Transform& transform); void SetShaderColor(SkColor color, float opacity); void DrawQuadGeometryClippedByQuadF(const gfx::Transform& draw_transform, const gfx::RectF& quad_rect, const gfx::QuadF& clipping_region_quad, const float uv[8]); void DrawQuadGeometry(const gfx::Transform& projection_matrix, const gfx::Transform& draw_transform, const gfx::RectF& quad_rect); void DrawQuadGeometryWithAA(const DrawQuad* quad, gfx::QuadF* local_quad, const gfx::Rect& tile_rect); // If |dst_color_space| is invalid, then no color conversion (apart from // YUV to RGB conversion) is performed. This explicit argument is available // so that video color conversion can be enabled separately from general color // conversion. void SetUseProgram(const ProgramKey& program_key, const gfx::ColorSpace& src_color_space, const gfx::ColorSpace& dst_color_space); bool MakeContextCurrent(); void InitializeSharedObjects(); void CleanupSharedObjects(); void ReinitializeGLState(); void RestoreGLState(); void ScheduleCALayers(); void ScheduleDCLayers(); void ScheduleOverlays(); // Copies the contents of the render pass draw quad, including filter effects, // to a GL texture, returned in |overlay_texture|. The resulting texture may // be larger than the RenderPassDrawQuad's output, in order to reuse existing // textures. The new size and position is placed in |new_bounds|. void CopyRenderPassDrawQuadToOverlayResource( const CALayerOverlay* ca_layer_overlay, std::unique_ptr<OverlayTexture>* overlay_texture, gfx::RectF* new_bounds); std::unique_ptr<OverlayTexture> FindOrCreateOverlayTexture( const RenderPassId& render_pass_id, int width, int height, const gfx::ColorSpace& color_space); void ReduceAvailableOverlayTextures( const std::vector<std::unique_ptr<OverlayTexture>>& most_recent); // Schedules the |ca_layer_overlay|, which is guaranteed to have a non-null // |rpdq| parameter. Returns ownership of a GL texture that contains the // output of the RenderPassDrawQuad. std::unique_ptr<OverlayTexture> ScheduleRenderPassDrawQuad( const CALayerOverlay* ca_layer_overlay); // Setup/flush all pending overdraw feedback to framebuffer. void SetupOverdrawFeedback(); void FlushOverdrawFeedback(const gfx::Rect& output_rect); // Process overdraw feedback from query. using OverdrawFeedbackCallback = base::Callback<void(unsigned, int)>; void ProcessOverdrawFeedback(std::vector<int>* overdraw, size_t num_expected_results, int max_result, unsigned query, int multiplier); ResourceFormat BackbufferFormat() const; // A map from RenderPass id to the texture used to draw the RenderPass from. base::flat_map<RenderPassId, ScopedRenderPassTexture> render_pass_textures_; // OverlayTextures that are free to be used in the next frame. std::vector<std::unique_ptr<OverlayTexture>> available_overlay_textures_; // OverlayTextures that have been set up for use but are waiting for // SwapBuffers. std::vector<std::unique_ptr<OverlayTexture>> awaiting_swap_overlay_textures_; // OverlayTextures that have been swapped for display on the gpu. Each vector // represents a single frame, and may be empty if none were used in that // frame. Ordered from oldest to most recent frame. std::vector<std::vector<std::unique_ptr<OverlayTexture>>> displayed_overlay_textures_; // OverlayTextures that we have replaced on the gpu but are awaiting // confirmation that we can reuse them. std::vector<std::unique_ptr<OverlayTexture>> awaiting_release_overlay_textures_; // Resources that have been sent to the GPU process, but not yet swapped. OverlayResourceLockList pending_overlay_resources_; // Resources that should be shortly swapped by the GPU process. base::circular_deque<OverlayResourceLockList> swapping_overlay_resources_; // Resources that the GPU process has finished swapping. The key is the // texture id of the resource. std::map<unsigned, OverlayResourceLock> swapped_and_acked_overlay_resources_; unsigned offscreen_framebuffer_id_ = 0u; std::unique_ptr<StaticGeometryBinding> shared_geometry_; std::unique_ptr<DynamicGeometryBinding> clipped_geometry_; gfx::QuadF shared_geometry_quad_; // This will return nullptr if the requested program has not yet been // initialized. const Program* GetProgramIfInitialized(const ProgramKey& key) const; std::unordered_map<ProgramKey, std::unique_ptr<Program>, ProgramKeyHash> program_cache_; const gfx::ColorTransform* GetColorTransform(const gfx::ColorSpace& src, const gfx::ColorSpace& dst); std::map<gfx::ColorSpace, std::map<gfx::ColorSpace, std::unique_ptr<gfx::ColorTransform>>> color_transform_cache_; gpu::gles2::GLES2Interface* gl_; gpu::ContextSupport* context_support_; std::unique_ptr<ContextCacheController::ScopedVisibility> context_visibility_; TextureDeleter texture_deleter_; GLRendererCopier copier_; gfx::Rect swap_buffer_rect_; std::vector<gfx::Rect> swap_content_bounds_; gfx::Rect scissor_rect_; bool is_scissor_enabled_ = false; bool stencil_shadow_ = false; bool blend_shadow_ = false; const Program* current_program_ = nullptr; TexturedQuadDrawCache draw_cache_; int highp_threshold_cache_ = 0; ScopedRenderPassTexture* current_framebuffer_texture_; SyncQueryCollection sync_queries_; bool use_discard_framebuffer_ = false; bool use_sync_query_ = false; bool use_blend_equation_advanced_ = false; bool use_blend_equation_advanced_coherent_ = false; bool use_occlusion_query_ = false; bool use_swap_with_bounds_ = false; // If true, tints all the composited content to red. bool tint_gl_composited_content_ = true; // The method FlippedFramebuffer determines whether the framebuffer associated // with a DrawingFrame is flipped. It makes the assumption that the // DrawingFrame is being used as part of a render pass. If a DrawingFrame is // not being used as part of a render pass, setting it here forces // FlippedFramebuffer to return |true|. bool force_drawing_frame_framebuffer_unflipped_ = false; BoundGeometry bound_geometry_; ColorLUTCache color_lut_cache_; unsigned offscreen_stencil_renderbuffer_id_ = 0; gfx::Size offscreen_stencil_renderbuffer_size_; unsigned num_triangles_drawn_ = 0; // This may be null if the compositor is run on a thread without a // MessageLoop. scoped_refptr<base::SingleThreadTaskRunner> current_task_runner_; base::WeakPtrFactory<GLRenderer> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(GLRenderer); }; } // namespace viz #endif // COMPONENTS_VIZ_SERVICE_DISPLAY_GL_RENDERER_H_
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
2e69c1176540d78a9457666963e6e3e4a16847bd
6f0445ac23b230232358d71ff08802e47416c9d1
/Source/QuickNote/ListTag.h
683b6c006f8134c1b70ca3d3af56e6451d816da3
[]
no_license
vuquangkhtn/QuickNote
0e26cc30cae4bbd9381550bcc7b1689bc3009d63
21ec89f5cb20d1bcaff5bc8ebc4f92c46d608810
refs/heads/master
2021-01-22T10:47:05.017294
2017-02-15T08:48:56
2017-02-15T08:48:56
82,039,753
1
0
null
null
null
null
UTF-8
C++
false
false
509
h
#pragma once #include "Tag.h" #include "Note.h" #include <fstream> #include <string> #include <locale> #include <codecvt> #include <vector> class CListTag { public: vector<CTag> listTags; public: CListTag(); void docDSTagTuFile(string filename); void ghiDSTagVaoFile(string filename); void themTag(CTag tag); void xoaTag(int pos); void findNewTags(CNote); void eraseTags(CNote oldNote); void increaseCountnotes(CNote note); bool isTrueList(); vector<CTag> DecreaseListTags(); int totalNotes(); };
[ "vuquangkhtn@gmail.com" ]
vuquangkhtn@gmail.com
c04b490026f20356954cf19840634ae8da364894
e36c670344356f3fad4a6322ac23e1da6520e7ce
/src/Output/Output_PreparedPatch_Fluid.cpp
db09887861fd23dbfcff52e47c937d6c9e26cc29
[ "BSD-3-Clause" ]
permissive
Aabhash007/gamer
7934c49bc2023403fcb46c4873252a180f2d8f90
62769fe4f680eeb504f84f0aae199012f728492e
refs/heads/master
2022-12-26T13:14:31.279184
2020-09-30T19:58:50
2020-09-30T19:58:50
300,045,686
0
0
NOASSERTION
2020-09-30T19:56:52
2020-09-30T19:56:51
null
UTF-8
C++
false
false
7,787
cpp
#include "GAMER.h" //------------------------------------------------------------------------------------------------------- // Function : Output_PreparedPatch_Fluid // Description : Output the fluid data of a "single patch" plus its ghost zones prepared by Flu_Prepare() // // Note : This function should be placed after invoking Prepare_PatchData() in Flu_Prepare() // // Example: // Prepare_PatchData( ... ); // // const int TLv = 1; // const int TPID = 12; // char comment[10]; // sprintf( comment, "Step%ld", AdvanceCounter[TLv] ); // Output_PreparedPatch_Fluid( TLv, TPID, h_Flu_Array_F_In, h_Mag_Array_F_In, // NPG, PID0_List, lv, comment ); // // Paremeter : TLv : Level you want to output the prepared patch // TPID : Target patch ID // h_Flu_Array : Input fluid array // h_Mag_Array : Input B field array (for MHD onlhy) // NPG : Number of patch groups to be prepared at a time // PID0_List : List recording the patch indices with LocalID==0 to be udpated // CLv : Level of data currently stored in h_Flu_Array // comment : String to attach to the end of the file name //------------------------------------------------------------------------------------------------------- void Output_PreparedPatch_Fluid( const int TLv, const int TPID, const real h_Flu_Array[][FLU_NIN][ CUBE(FLU_NXT) ], const real h_Mag_Array[][NCOMP_MAG][ FLU_NXT_P1*SQR(FLU_NXT) ], const int NPG, const int *PID0_List, const int CLv, const char *comment ) { // nothing to do if the current level is not the target level if ( TLv != CLv ) return; const int LocalID = TPID % 8; const int TPID0 = TPID - LocalID; for (int TID=0; TID<NPG; TID++) { // check if the target patch is within the current patch group if ( TPID0 != PID0_List[TID] ) continue; // begin to output the prepared data patch_t *Relation = amr->patch[0][TLv][TPID]; char FileName[100]; sprintf( FileName, "PrePatch_Fluid_r%d_lv%d_p%d", MPI_Rank, TLv, TPID ); if ( comment != NULL ) { strcat( FileName, "_" ); strcat( FileName, comment ); } if ( Aux_CheckFileExist(FileName) ) Aux_Message( stderr, "WARNING : file \"%s\" already exists and will be overwritten !!\n", FileName ); // header FILE *File = fopen( FileName, "w" ); fprintf( File, "Rank %d Lv %d PID %d Local ID %d Time %13.7e Step %ld Counter %ld\n", MPI_Rank, TLv, TPID, LocalID, Time[TLv], Step, AdvanceCounter[TLv] ); fprintf( File, "Father %d Son %d Corner (%10d,%10d,%10d)\n\n", Relation->father, Relation->son, Relation->corner[0], Relation->corner[1], Relation->corner[2] ); fprintf( File, "Sibling, Sibling->Son, and Father->Sibling Lists :\n" ); int Sib, FaSib, SibSon; for (int S=0; S<26; S++) { Sib = Relation->sibling[S]; FaSib = ( TLv == 0 ) ? -1 : amr->patch[0][TLv-1][Relation->father]->sibling[S]; SibSon = ( Sib < 0 ) ? Sib : amr->patch[0][TLv][Sib]->son; fprintf( File, "Sib[%2d] = %6d Sib_Son = %6d Fa_Sib[%2d] = %6d\n", S, Sib, SibSon, S, FaSib ); } fprintf( File, "\n" ); // output cell-centered fluid data fprintf( File, "\n" ); fprintf( File, "===========================\n" ); fprintf( File, "== FLUID (cell-centered) == \n" ); fprintf( File, "===========================\n" ); fprintf( File, "\n" ); // header fprintf( File, "(%3s,%3s,%3s )", "i", "j", "k" ); # if ( MODEL == ELBDM ) fprintf( File, "%16s%16s", FieldLabel[REAL], FieldLabel[IMAG] ); # else for (int v=0; v<FLU_NIN; v++) fprintf( File, "%16s", FieldLabel[v] ); # if ( MODEL == HYDRO ) fprintf( File, "%16s", "Pressure" ); # endif # endif // MODEL fprintf( File, "\n" ); const int Disp_i = TABLE_02( LocalID, 'x', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); const int Disp_j = TABLE_02( LocalID, 'y', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); const int Disp_k = TABLE_02( LocalID, 'z', FLU_GHOST_SIZE, FLU_GHOST_SIZE+PS1 ); int K, J, I, Idx; real u[FLU_NIN]; for (int k=-FLU_GHOST_SIZE; k<FLU_GHOST_SIZE+PS1; k++) { K = k + Disp_k; for (int j=-FLU_GHOST_SIZE; j<FLU_GHOST_SIZE+PS1; j++) { J = j + Disp_j; for (int i=-FLU_GHOST_SIZE; i<FLU_GHOST_SIZE+PS1; i++) { I = i + Disp_i; Idx = K*FLU_NXT*FLU_NXT + J*FLU_NXT + I; for (int v=0; v<FLU_NIN; v++) u[v] = h_Flu_Array[TID][v][Idx]; // cell indices fprintf( File, "(%3d,%3d,%3d )", i, j, k ); // all variables in the prepared fluid array for (int v=0; v<FLU_NIN; v++) fprintf( File, " %14.7e", u[v] ); // pressure in HYDRO # if ( MODEL == HYDRO ) const bool CheckMinPres_No = false; # ifdef MHD const real Emag = MHD_GetCellCenteredBEnergy( h_Mag_Array[TID][MAGX], h_Mag_Array[TID][MAGY], h_Mag_Array[TID][MAGZ], FLU_NXT, FLU_NXT, FLU_NXT, I, J, K ); # else const real Emag = NULL_REAL; # endif fprintf( File, " %14.7e", Hydro_Con2Pres(u[DENS],u[MOMX],u[MOMY],u[MOMZ],u[ENGY],u+NCOMP_FLUID, CheckMinPres_No,NULL_REAL,Emag, EoS_DensEint2Pres_CPUPtr, EoS_AuxArray, NULL) ); # endif // #if ( MODEL == HYDRO ) fprintf( File, "\n" ); }}} // output face-centered magnetic field # ifdef MHD fprintf( File, "\n" ); fprintf( File, "====================================\n" ); fprintf( File, "== MAGNETIC FIELD (face-centered) == \n" ); fprintf( File, "====================================\n" ); fprintf( File, "\n" ); // header fprintf( File, "(%3s,%3s,%3s )", "i", "j", "k" ); for (int v=0; v<NCOMP_MAG; v++) fprintf( File, "%16s", MagLabel[v] ); fprintf( File, "\n" ); for (int k=-FLU_GHOST_SIZE; k<FLU_GHOST_SIZE+PS1P1; k++) { K = k + Disp_k; for (int j=-FLU_GHOST_SIZE; j<FLU_GHOST_SIZE+PS1P1; j++) { J = j + Disp_j; for (int i=-FLU_GHOST_SIZE; i<FLU_GHOST_SIZE+PS1P1; i++) { I = i + Disp_i; // cell indices fprintf( File, "(%3d,%3d,%3d )", i, j, k ); // B_X if ( j != FLU_GHOST_SIZE+PS1 && k != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGX][ IDX321_BX(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); // B_Y if ( i != FLU_GHOST_SIZE+PS1 && k != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGY][ IDX321_BY(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); // B_Z if ( i != FLU_GHOST_SIZE+PS1 && j != FLU_GHOST_SIZE+PS1 ) fprintf( File, " %14.7e", h_Mag_Array[TID][MAGZ][ IDX321_BZ(I,J,K,FLU_NXT,FLU_NXT) ] ); else fprintf( File, " %14s", "" ); fprintf( File, "\n" ); }}} // i,j,k # endif // #ifdef MHD fclose( File ); break; } // for (int TID=0; TID<NPG; TID++) } // FUNCTION : Output_PreparedPatch_Fluid
[ "hyschive@gmail.com" ]
hyschive@gmail.com
780fef91bf8124cfcd5610367e8278a026ebfac7
bc1d68d7a7c837b8a99e516050364a7254030727
/src/URAL/URAL1019 Line Painting.cpp
67b516a451ae66a09e957b5a55833b26e273a159
[]
no_license
kester-lin/acm_backup
1e86b0b4699f8fa50a526ce091f242ee75282f59
a4850379c6c67a42da6b5aea499306e67edfc9fd
refs/heads/master
2021-05-28T20:01:31.044690
2013-05-16T03:27:21
2013-05-16T03:27:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,004
cpp
/******************************************************************************* # Author : Neo Fung # Email : neosfung@gmail.com # Last modified: 2012-01-20 21:28 # Filename: URAL1019 Line Painting.cpp # Description : ******************************************************************************/ #ifdef _MSC_VER // #define DEBUG #endif #include <fstream> #include <stdio.h> #include <iostream> #include <string.h> #include <string> #include <limits.h> #include <algorithm> #include <math.h> #include <numeric> #include <functional> #include <ctype.h> #define L(x) (x<<1) #define R(x) (x<<1|1) #define MAX 100010 using namespace std; struct NODE { int l,r, val; }node[MAX*4],order[MAX]; int color[MAX]; void init() { memset(node,'\0',sizeof(node)); memset(order,'\0',sizeof(order)); memset(color,0,sizeof(color)); } void build(const int &t , const int &l,const int &r) { if(l>=r) return; node[t].l=l; node[t].r=r; node[t].val=-1; if(l==r-1) return; int mid=(l+r)>>1; build(L(t),l,mid); build(R(t),mid,r); } void update(const int &t,const int &l,const int &r,const int &val) { if(node[t].l==l && node[t].r==r) { node[t].val=val; return; } if(node[t].val>=0 && node[t].val !=val) { node[R(t)].val = node[t].val; node[L(t)].val = node[t].val; node[t].val=-1; } int mid=(node[t].l+node[t].r)>>1; if(l>=mid) update(R(t),l,r,val); else if(r<=mid) update(L(t),l,r,val); else { update(L(t),l,mid,val); update(R(t),mid,r,val); } } void query(const int &t,const int &l,const int &r) { if(node[t].val>=0) { for(int i=node[t].l;i<node[t].r;++i) color[i] = node[t].val; return; } int mid = (node[t].l+node[t].r)>>1; if(l>=mid) query(R(t),l,r); else if(r<=mid) query(L(t),l,r); else { query(L(t),l,mid); query(R(t),mid,r); } } void func(int *len,const int &cnt,const int &n) { build(1,0,cnt); for(int i=0;i<n;++i) { int x = lower_bound(len,len+cnt,order[i].l) - len; int y = lower_bound(len,len+cnt,order[i].r) - len; update(1,x,y,order[i].val); } query(1,0,cnt); color[cnt]=0; len[cnt]=1000000000; int s = 0,e = 0,te,ts; color[cnt] = !color[cnt-1]; len[cnt] = 1000000000; for(int i=0; i<cnt;++i) { ts = len[i]; while( color[i] == 0 ) i++; te = len[i]; if( te - ts > e - s ) { e = te; s = ts; } } printf("%d %d\n",s,e); } int main(void) { #ifdef DEBUG freopen("../stdin.txt","r",stdin); freopen("../stdout.txt","w",stdout); #endif int n; int x,y; char ch; int len[MAX]; while(~scanf("%d",&n)) { int cnt=0; init(); order[0].l=0; order[0].r=1000000000; order[0].val=0;; len[cnt++]=0; len[cnt++]=order[0].r; for(int i=1;i<=n;++i) { scanf("%d %d %c",&order[i].l,&order[i].r,&ch); len[cnt++]=order[i].l; len[cnt++]=order[i].r; if(ch=='b') order[i].val=1; } sort(len,len+cnt); cnt = unique(len,len+cnt)-len; func(len,cnt,n+1); } return 0; }
[ "neosfung@gmail.com" ]
neosfung@gmail.com
53376d181f4bc713552f08afdd2b26394bc94216
86b55c5bfd3cbce99db30907ecc63c0038b0f1e2
/components/exo/text_input.cc
50e272f09892f5f1efc85eec3712e7c0da6e22fa
[ "BSD-3-Clause" ]
permissive
Claw-Lang/chromium
3ed8160ea3f2b5d51fdc2a7d764aadd5b443eb3f
651cebac57fcd0ce2c7c974494602cc098fe7348
refs/heads/master
2022-11-19T07:46:03.573023
2020-07-28T06:45:27
2020-07-28T06:45:27
283,134,740
1
0
BSD-3-Clause
2020-07-28T07:26:49
2020-07-28T07:26:48
null
UTF-8
C++
false
false
11,181
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/exo/text_input.h" #include <algorithm> #include "ash/keyboard/ui/keyboard_ui_controller.h" #include "base/strings/utf_string_conversions.h" #include "components/exo/surface.h" #include "components/exo/wm_helper.h" #include "third_party/icu/source/common/unicode/uchar.h" #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/base/ime/input_method.h" #include "ui/events/event.h" namespace exo { namespace { ui::InputMethod* GetInputMethod(aura::Window* window) { if (!window || !window->GetHost()) return nullptr; return window->GetHost()->GetInputMethod(); } } // namespace size_t OffsetFromUTF8Offset(const base::StringPiece& text, uint32_t offset) { return base::UTF8ToUTF16(text.substr(0, offset)).size(); } size_t OffsetFromUTF16Offset(const base::StringPiece16& text, uint32_t offset) { return base::UTF16ToUTF8(text.substr(0, offset)).size(); } TextInput::TextInput(std::unique_ptr<Delegate> delegate) : delegate_(std::move(delegate)) {} TextInput::~TextInput() { if (keyboard_ui_controller_) keyboard_ui_controller_->RemoveObserver(this); if (input_method_) Deactivate(); } void TextInput::Activate(Surface* surface) { DLOG_IF(ERROR, window_) << "Already activated with " << window_; DCHECK(surface); window_ = surface->window(); AttachInputMethod(); } void TextInput::Deactivate() { DetachInputMethod(); window_ = nullptr; } void TextInput::ShowVirtualKeyboardIfEnabled() { // Some clients may ask showing virtual keyboard before sending activation. if (!input_method_) { pending_vk_visible_ = true; return; } input_method_->ShowVirtualKeyboardIfEnabled(); } void TextInput::HideVirtualKeyboard() { if (keyboard_ui_controller_) keyboard_ui_controller_->HideKeyboardByUser(); pending_vk_visible_ = false; } void TextInput::Resync() { if (input_method_) input_method_->OnCaretBoundsChanged(this); } void TextInput::SetSurroundingText(const base::string16& text, uint32_t cursor_pos, uint32_t anchor) { surrounding_text_ = text; cursor_pos_ = gfx::Range(cursor_pos); if (anchor < cursor_pos) cursor_pos_->set_start(anchor); else cursor_pos_->set_end(anchor); } void TextInput::SetTypeModeFlags(ui::TextInputType type, ui::TextInputMode mode, int flags, bool should_do_learning) { if (!input_method_) return; bool changed = (input_type_ != type); input_type_ = type; input_mode_ = mode; flags_ = flags; should_do_learning_ = should_do_learning; if (changed) input_method_->OnTextInputTypeChanged(this); } void TextInput::SetCaretBounds(const gfx::Rect& bounds) { if (caret_bounds_ == bounds) return; caret_bounds_ = bounds; if (!input_method_) return; input_method_->OnCaretBoundsChanged(this); } void TextInput::SetCompositionText(const ui::CompositionText& composition) { composition_ = composition; delegate_->SetCompositionText(composition); } void TextInput::ConfirmCompositionText(bool keep_selection) { // TODO(b/134473433) Modify this function so that when keep_selection is // true, the selection is not changed when text committed if (keep_selection) { NOTIMPLEMENTED_LOG_ONCE(); } delegate_->Commit(composition_.text); } void TextInput::ClearCompositionText() { composition_ = ui::CompositionText(); delegate_->SetCompositionText(composition_); } void TextInput::InsertText(const base::string16& text) { delegate_->Commit(text); } void TextInput::InsertChar(const ui::KeyEvent& event) { base::char16 ch = event.GetCharacter(); if (u_isprint(ch)) { InsertText(base::string16(1, ch)); return; } delegate_->SendKey(event); } ui::TextInputType TextInput::GetTextInputType() const { return input_type_; } ui::TextInputMode TextInput::GetTextInputMode() const { return input_mode_; } base::i18n::TextDirection TextInput::GetTextDirection() const { return direction_; } int TextInput::GetTextInputFlags() const { return flags_; } bool TextInput::CanComposeInline() const { return true; } gfx::Rect TextInput::GetCaretBounds() const { return caret_bounds_ + window_->GetBoundsInScreen().OffsetFromOrigin(); } bool TextInput::GetCompositionCharacterBounds(uint32_t index, gfx::Rect* rect) const { return false; } bool TextInput::HasCompositionText() const { return !composition_.text.empty(); } ui::TextInputClient::FocusReason TextInput::GetFocusReason() const { NOTIMPLEMENTED_LOG_ONCE(); return ui::TextInputClient::FOCUS_REASON_OTHER; } bool TextInput::GetTextRange(gfx::Range* range) const { if (!cursor_pos_) return false; range->set_start(0); if (composition_.text.empty()) { range->set_end(surrounding_text_.size()); } else { range->set_end(surrounding_text_.size() - cursor_pos_->length() + composition_.text.size()); } return true; } bool TextInput::GetCompositionTextRange(gfx::Range* range) const { if (!cursor_pos_ || composition_.text.empty()) return false; range->set_start(cursor_pos_->start()); range->set_end(cursor_pos_->start() + composition_.text.size()); return true; } bool TextInput::GetEditableSelectionRange(gfx::Range* range) const { if (!cursor_pos_) return false; range->set_start(cursor_pos_->start()); range->set_end(cursor_pos_->end()); return true; } bool TextInput::SetEditableSelectionRange(const gfx::Range& range) { if (surrounding_text_.size() < range.GetMax()) return false; delegate_->SetCursor( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, range.start()), OffsetFromUTF16Offset(surrounding_text_, range.end()))); return true; } bool TextInput::DeleteRange(const gfx::Range& range) { if (surrounding_text_.size() < range.GetMax()) return false; delegate_->DeleteSurroundingText( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, range.start()), OffsetFromUTF16Offset(surrounding_text_, range.end()))); return true; } bool TextInput::GetTextFromRange(const gfx::Range& range, base::string16* text) const { gfx::Range text_range; if (!GetTextRange(&text_range) || !text_range.Contains(range)) return false; if (composition_.text.empty() || range.GetMax() <= cursor_pos_->GetMin()) { text->assign(surrounding_text_, range.GetMin(), range.length()); return true; } size_t composition_end = cursor_pos_->GetMin() + composition_.text.size(); if (range.GetMin() >= composition_end) { size_t start = range.GetMin() - composition_.text.size() + cursor_pos_->length(); text->assign(surrounding_text_, start, range.length()); return true; } size_t start_in_composition = 0; if (range.GetMin() <= cursor_pos_->GetMin()) { text->assign(surrounding_text_, range.GetMin(), cursor_pos_->GetMin() - range.GetMin()); } else { start_in_composition = range.GetMin() - cursor_pos_->GetMin(); } if (range.GetMax() <= composition_end) { text->append(composition_.text, start_in_composition, range.GetMax() - cursor_pos_->GetMin() - start_in_composition); } else { text->append(composition_.text, start_in_composition, composition_.text.size() - start_in_composition); text->append(surrounding_text_, cursor_pos_->GetMax(), range.GetMax() - composition_end); } return true; } void TextInput::OnInputMethodChanged() { ui::InputMethod* input_method = GetInputMethod(window_); if (input_method == input_method_) return; input_method_->DetachTextInputClient(this); input_method_ = input_method; input_method_->SetFocusedTextInputClient(this); } bool TextInput::ChangeTextDirectionAndLayoutAlignment( base::i18n::TextDirection direction) { if (direction == direction_) return true; direction_ = direction; delegate_->OnTextDirectionChanged(direction_); return true; } void TextInput::ExtendSelectionAndDelete(size_t before, size_t after) { if (!cursor_pos_) return; uint32_t start = (cursor_pos_->GetMin() < before) ? 0 : (cursor_pos_->GetMin() - before); uint32_t end = std::min(cursor_pos_->GetMax() + after, surrounding_text_.size()); delegate_->DeleteSurroundingText( gfx::Range(OffsetFromUTF16Offset(surrounding_text_, start), OffsetFromUTF16Offset(surrounding_text_, end))); } void TextInput::EnsureCaretNotInRect(const gfx::Rect& rect) {} bool TextInput::IsTextEditCommandEnabled(ui::TextEditCommand command) const { return false; } void TextInput::SetTextEditCommandForNextKeyEvent(ui::TextEditCommand command) { } ukm::SourceId TextInput::GetClientSourceForMetrics() const { NOTIMPLEMENTED_LOG_ONCE(); return ukm::kInvalidSourceId; } bool TextInput::ShouldDoLearning() { return should_do_learning_; } bool TextInput::SetCompositionFromExistingText( const gfx::Range& range, const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) { // TODO(https://crbug.com/952757): Implement this method. NOTIMPLEMENTED_LOG_ONCE(); return false; } gfx::Rect TextInput::GetAutocorrectCharacterBounds() const { // TODO(https://crbug.com/952757): Implement this method. NOTIMPLEMENTED_LOG_ONCE(); return gfx::Rect(); } // TODO(crbug.com/1091088) Implement setAutocorrectRange bool TextInput::SetAutocorrectRange(const base::string16& autocorrect_text, const gfx::Range& range) { NOTIMPLEMENTED_LOG_ONCE(); return false; } void TextInput::OnKeyboardVisibilityChanged(bool is_visible) { delegate_->OnVirtualKeyboardVisibilityChanged(is_visible); } void TextInput::AttachInputMethod() { DCHECK(!input_method_); ui::InputMethod* input_method = GetInputMethod(window_); if (!input_method) { LOG(ERROR) << "input method not found"; return; } input_mode_ = ui::TEXT_INPUT_MODE_TEXT; input_type_ = ui::TEXT_INPUT_TYPE_TEXT; input_method_ = input_method; input_method_->SetFocusedTextInputClient(this); delegate_->Activated(); if (!keyboard_ui_controller_ && keyboard::KeyboardUIController::HasInstance()) { auto* keyboard_ui_controller = keyboard::KeyboardUIController::Get(); if (keyboard_ui_controller->IsEnabled()) { keyboard_ui_controller_ = keyboard_ui_controller; keyboard_ui_controller_->AddObserver(this); } } if (pending_vk_visible_) { input_method_->ShowVirtualKeyboardIfEnabled(); pending_vk_visible_ = false; } } void TextInput::DetachInputMethod() { if (!input_method_) { DLOG(ERROR) << "input method already detached"; return; } input_mode_ = ui::TEXT_INPUT_MODE_DEFAULT; input_type_ = ui::TEXT_INPUT_TYPE_NONE; input_method_->DetachTextInputClient(this); input_method_ = nullptr; delegate_->Deactivated(); } } // namespace exo
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
fd5546e3a6b05228535a82dd84269c1026c837d1
643f3dc3c970684ed835bbfa1b3cb31e0b8661be
/src/netbase.cpp
97fc6507d6b4329a9e88c74fcaf6ea52c08d6dd1
[ "MIT" ]
permissive
Aviator-Coding/abet
cf61aeadae2cab51a19bc036dba8d8d8af739ad6
8bee2012deb998d0fbaaad9fbbcdf83a0c84c0d6
refs/heads/master
2020-04-18T21:58:03.380823
2019-01-27T07:07:38
2019-01-27T07:07:38
167,780,598
1
0
MIT
2019-01-27T07:00:56
2019-01-27T07:00:54
null
UTF-8
C++
false
false
39,481
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifdef HAVE_CONFIG_H #include "config/altbet-config.h" #endif #include "netbase.h" #include "hash.h" #include "sync.h" #include "uint256.h" #include "util.h" #include "utilstrencodings.h" #ifdef HAVE_GETADDRINFO_A #include <netdb.h> #endif #ifndef WIN32 #if HAVE_INET_PTON #include <arpa/inet.h> #endif #include <fcntl.h> #endif #include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith() #include <boost/thread.hpp> #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 #endif using namespace std; // Settings static proxyType proxyInfo[NET_MAX]; static CService nameProxy; static CCriticalSection cs_proxyInfos; int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT; bool fNameLookup = false; static const unsigned char pchIPv4[12] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff}; // Need ample time for negotiation for very slow proxies such as Tor (milliseconds) static const int SOCKS5_RECV_TIMEOUT = 20 * 1000; enum Network ParseNetwork(std::string net) { boost::to_lower(net); if (net == "ipv4") return NET_IPV4; if (net == "ipv6") return NET_IPV6; if (net == "tor" || net == "onion") return NET_TOR; return NET_UNROUTABLE; } std::string GetNetworkName(enum Network net) { switch (net) { case NET_IPV4: return "ipv4"; case NET_IPV6: return "ipv6"; case NET_TOR: return "onion"; default: return ""; } } void SplitHostPort(std::string in, int& portOut, std::string& hostOut) { size_t colon = in.find_last_of(':'); // if a : is found, and it either follows a [...], or no other : is in the string, treat it as port separator bool fHaveColon = colon != in.npos; bool fBracketed = fHaveColon && (in[0] == '[' && in[colon - 1] == ']'); // if there is a colon, and in[0]=='[', colon is not 0, so in[colon-1] is safe bool fMultiColon = fHaveColon && (in.find_last_of(':', colon - 1) != in.npos); if (fHaveColon && (colon == 0 || fBracketed || !fMultiColon)) { int32_t n; if (ParseInt32(in.substr(colon + 1), &n) && n > 0 && n < 0x10000) { in = in.substr(0, colon); portOut = n; } } if (in.size() > 0 && in[0] == '[' && in[in.size() - 1] == ']') hostOut = in.substr(1, in.size() - 2); else hostOut = in; } bool static LookupIntern(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup) { vIP.clear(); { CNetAddr addr; if (addr.SetSpecial(std::string(pszName))) { vIP.push_back(addr); return true; } } #ifdef HAVE_GETADDRINFO_A struct in_addr ipv4_addr; #ifdef HAVE_INET_PTON if (inet_pton(AF_INET, pszName, &ipv4_addr) > 0) { vIP.push_back(CNetAddr(ipv4_addr)); return true; } struct in6_addr ipv6_addr; if (inet_pton(AF_INET6, pszName, &ipv6_addr) > 0) { vIP.push_back(CNetAddr(ipv6_addr)); return true; } #else ipv4_addr.s_addr = inet_addr(pszName); if (ipv4_addr.s_addr != INADDR_NONE) { vIP.push_back(CNetAddr(ipv4_addr)); return true; } #endif #endif struct addrinfo aiHint; memset(&aiHint, 0, sizeof(struct addrinfo)); aiHint.ai_socktype = SOCK_STREAM; aiHint.ai_protocol = IPPROTO_TCP; aiHint.ai_family = AF_UNSPEC; #ifdef WIN32 aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST; #else aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST; #endif struct addrinfo* aiRes = NULL; #ifdef HAVE_GETADDRINFO_A struct gaicb gcb, *query = &gcb; memset(query, 0, sizeof(struct gaicb)); gcb.ar_name = pszName; gcb.ar_request = &aiHint; int nErr = getaddrinfo_a(GAI_NOWAIT, &query, 1, NULL); if (nErr) return false; do { // Should set the timeout limit to a resonable value to avoid // generating unnecessary checking call during the polling loop, // while it can still response to stop request quick enough. // 2 seconds looks fine in our situation. struct timespec ts = {2, 0}; gai_suspend(&query, 1, &ts); boost::this_thread::interruption_point(); nErr = gai_error(query); if (0 == nErr) aiRes = query->ar_result; } while (nErr == EAI_INPROGRESS); #else int nErr = getaddrinfo(pszName, NULL, &aiHint, &aiRes); #endif if (nErr) return false; struct addrinfo* aiTrav = aiRes; while (aiTrav != NULL && (nMaxSolutions == 0 || vIP.size() < nMaxSolutions)) { if (aiTrav->ai_family == AF_INET) { assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in)); vIP.push_back(CNetAddr(((struct sockaddr_in*)(aiTrav->ai_addr))->sin_addr)); } if (aiTrav->ai_family == AF_INET6) { assert(aiTrav->ai_addrlen >= sizeof(sockaddr_in6)); vIP.push_back(CNetAddr(((struct sockaddr_in6*)(aiTrav->ai_addr))->sin6_addr)); } aiTrav = aiTrav->ai_next; } freeaddrinfo(aiRes); return (vIP.size() > 0); } bool LookupHost(const char* pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup) { std::string strHost(pszName); if (strHost.empty()) return false; if (boost::algorithm::starts_with(strHost, "[") && boost::algorithm::ends_with(strHost, "]")) { strHost = strHost.substr(1, strHost.size() - 2); } return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup); } bool Lookup(const char* pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions) { if (pszName[0] == 0) return false; int port = portDefault; std::string hostname = ""; SplitHostPort(std::string(pszName), port, hostname); std::vector<CNetAddr> vIP; bool fRet = LookupIntern(hostname.c_str(), vIP, nMaxSolutions, fAllowLookup); if (!fRet) return false; vAddr.resize(vIP.size()); for (unsigned int i = 0; i < vIP.size(); i++) vAddr[i] = CService(vIP[i], port); return true; } bool Lookup(const char* pszName, CService& addr, int portDefault, bool fAllowLookup) { std::vector<CService> vService; bool fRet = Lookup(pszName, vService, portDefault, fAllowLookup, 1); if (!fRet) return false; addr = vService[0]; return true; } bool LookupNumeric(const char* pszName, CService& addr, int portDefault) { return Lookup(pszName, addr, portDefault, false); } /** * Convert milliseconds to a struct timeval for select. */ struct timeval static MillisToTimeval(int64_t nTimeout) { struct timeval timeout; timeout.tv_sec = nTimeout / 1000; timeout.tv_usec = (nTimeout % 1000) * 1000; return timeout; } /** * Read bytes from socket. This will either read the full number of bytes requested * or return False on error or timeout. * This function can be interrupted by boost thread interrupt. * * @param data Buffer to receive into * @param len Length of data to receive * @param timeout Timeout in milliseconds for receive operation * * @note This function requires that hSocket is in non-blocking mode. */ bool static InterruptibleRecv(char* data, size_t len, int timeout, SOCKET& hSocket) { int64_t curTime = GetTimeMillis(); int64_t endTime = curTime + timeout; // Maximum time to wait in one select call. It will take up until this time (in millis) // to break off in case of an interruption. const int64_t maxWait = 1000; while (len > 0 && curTime < endTime) { ssize_t ret = recv(hSocket, data, len, 0); // Optimistically try the recv first if (ret > 0) { len -= ret; data += ret; } else if (ret == 0) { // Unexpected disconnection return false; } else { // Other error or blocking int nErr = WSAGetLastError(); if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) { if (!IsSelectableSocket(hSocket)) { return false; } struct timeval tval = MillisToTimeval(std::min(endTime - curTime, maxWait)); fd_set fdset; FD_ZERO(&fdset); FD_SET(hSocket, &fdset); int nRet = select(hSocket + 1, &fdset, NULL, NULL, &tval); if (nRet == SOCKET_ERROR) { return false; } } else { return false; } } boost::this_thread::interruption_point(); curTime = GetTimeMillis(); } return len == 0; } bool static Socks5(string strDest, int port, SOCKET& hSocket) { LogPrintf("SOCKS5 connecting %s\n", strDest); if (strDest.size() > 255) { CloseSocket(hSocket); return error("Hostname too long"); } char pszSocks5Init[] = "\5\1\0"; ssize_t nSize = sizeof(pszSocks5Init) - 1; ssize_t ret = send(hSocket, pszSocks5Init, nSize, MSG_NOSIGNAL); if (ret != nSize) { CloseSocket(hSocket); return error("Error sending to proxy"); } char pchRet1[2]; if (!InterruptibleRecv(pchRet1, 2, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading proxy response"); } if (pchRet1[0] != 0x05 || pchRet1[1] != 0x00) { CloseSocket(hSocket); return error("Proxy failed to initialize"); } string strSocks5("\5\1"); strSocks5 += '\000'; strSocks5 += '\003'; strSocks5 += static_cast<char>(std::min((int)strDest.size(), 255)); strSocks5 += strDest; strSocks5 += static_cast<char>((port >> 8) & 0xFF); strSocks5 += static_cast<char>((port >> 0) & 0xFF); ret = send(hSocket, strSocks5.data(), strSocks5.size(), MSG_NOSIGNAL); if (ret != (ssize_t)strSocks5.size()) { CloseSocket(hSocket); return error("Error sending to proxy"); } char pchRet2[4]; if (!InterruptibleRecv(pchRet2, 4, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading proxy response"); } if (pchRet2[0] != 0x05) { CloseSocket(hSocket); return error("Proxy failed to accept request"); } if (pchRet2[1] != 0x00) { CloseSocket(hSocket); switch (pchRet2[1]) { case 0x01: return error("Proxy error: general failure"); case 0x02: return error("Proxy error: connection not allowed"); case 0x03: return error("Proxy error: network unreachable"); case 0x04: return error("Proxy error: host unreachable"); case 0x05: return error("Proxy error: connection refused"); case 0x06: return error("Proxy error: TTL expired"); case 0x07: return error("Proxy error: protocol error"); case 0x08: return error("Proxy error: address type not supported"); default: return error("Proxy error: unknown"); } } if (pchRet2[2] != 0x00) { CloseSocket(hSocket); return error("Error: malformed proxy response"); } char pchRet3[256]; switch (pchRet2[3]) { case 0x01: ret = InterruptibleRecv(pchRet3, 4, SOCKS5_RECV_TIMEOUT, hSocket); break; case 0x04: ret = InterruptibleRecv(pchRet3, 16, SOCKS5_RECV_TIMEOUT, hSocket); break; case 0x03: { ret = InterruptibleRecv(pchRet3, 1, SOCKS5_RECV_TIMEOUT, hSocket); if (!ret) { CloseSocket(hSocket); return error("Error reading from proxy"); } int nRecv = pchRet3[0]; ret = InterruptibleRecv(pchRet3, nRecv, SOCKS5_RECV_TIMEOUT, hSocket); break; } default: CloseSocket(hSocket); return error("Error: malformed proxy response"); } if (!ret) { CloseSocket(hSocket); return error("Error reading from proxy"); } if (!InterruptibleRecv(pchRet3, 2, SOCKS5_RECV_TIMEOUT, hSocket)) { CloseSocket(hSocket); return error("Error reading from proxy"); } LogPrintf("SOCKS5 connected %s\n", strDest); return true; } bool static ConnectSocketDirectly(const CService& addrConnect, SOCKET& hSocketRet, int nTimeout) { hSocketRet = INVALID_SOCKET; struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); if (!addrConnect.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { LogPrintf("Cannot connect to %s: unsupported network\n", addrConnect.ToString()); return false; } SOCKET hSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); if (hSocket == INVALID_SOCKET) return false; #ifdef SO_NOSIGPIPE int set = 1; // Different way of disabling SIGPIPE on BSD setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif // Set to non-blocking if (!SetSocketNonBlocking(hSocket, true)) return error("ConnectSocketDirectly: Setting socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError())); if (connect(hSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) { int nErr = WSAGetLastError(); // WSAEINVAL is here because some legacy version of winsock uses it if (nErr == WSAEINPROGRESS || nErr == WSAEWOULDBLOCK || nErr == WSAEINVAL) { struct timeval timeout = MillisToTimeval(nTimeout); fd_set fdset; FD_ZERO(&fdset); FD_SET(hSocket, &fdset); int nRet = select(hSocket + 1, NULL, &fdset, NULL, &timeout); if (nRet == 0) { LogPrint("net", "connection to %s timeout\n", addrConnect.ToString()); CloseSocket(hSocket); return false; } if (nRet == SOCKET_ERROR) { LogPrintf("select() for %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } socklen_t nRetSize = sizeof(nRet); #ifdef WIN32 if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, (char*)(&nRet), &nRetSize) == SOCKET_ERROR) #else if (getsockopt(hSocket, SOL_SOCKET, SO_ERROR, &nRet, &nRetSize) == SOCKET_ERROR) #endif { LogPrintf("getsockopt() for %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } if (nRet != 0) { LogPrintf("connect() to %s failed after select(): %s\n", addrConnect.ToString(), NetworkErrorString(nRet)); CloseSocket(hSocket); return false; } } #ifdef WIN32 else if (WSAGetLastError() != WSAEISCONN) #else else #endif { LogPrintf("connect() to %s failed: %s\n", addrConnect.ToString(), NetworkErrorString(WSAGetLastError())); CloseSocket(hSocket); return false; } } hSocketRet = hSocket; return true; } bool SetProxy(enum Network net, CService addrProxy) { assert(net >= 0 && net < NET_MAX); if (!addrProxy.IsValid()) return false; LOCK(cs_proxyInfos); proxyInfo[net] = addrProxy; return true; } bool GetProxy(enum Network net, proxyType& proxyInfoOut) { assert(net >= 0 && net < NET_MAX); LOCK(cs_proxyInfos); if (!proxyInfo[net].IsValid()) return false; proxyInfoOut = proxyInfo[net]; return true; } bool SetNameProxy(CService addrProxy) { if (!addrProxy.IsValid()) return false; LOCK(cs_proxyInfos); nameProxy = addrProxy; return true; } bool GetNameProxy(CService& nameProxyOut) { LOCK(cs_proxyInfos); if (!nameProxy.IsValid()) return false; nameProxyOut = nameProxy; return true; } bool HaveNameProxy() { LOCK(cs_proxyInfos); return nameProxy.IsValid(); } bool IsProxy(const CNetAddr& addr) { LOCK(cs_proxyInfos); for (int i = 0; i < NET_MAX; i++) { if (addr == (CNetAddr)proxyInfo[i]) return true; } return false; } bool ConnectSocket(const CService& addrDest, SOCKET& hSocketRet, int nTimeout, bool* outProxyConnectionFailed) { proxyType proxy; if (outProxyConnectionFailed) *outProxyConnectionFailed = false; // no proxy needed (none set for target network) if (!GetProxy(addrDest.GetNetwork(), proxy)) return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout); SOCKET hSocket = INVALID_SOCKET; // first connect to proxy server if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) { if (outProxyConnectionFailed) *outProxyConnectionFailed = true; return false; } // do socks negotiation if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket)) return false; hSocketRet = hSocket; return true; } bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed) { string strDest; int port = portDefault; if (outProxyConnectionFailed) *outProxyConnectionFailed = false; SplitHostPort(string(pszDest), port, strDest); SOCKET hSocket = INVALID_SOCKET; CService nameProxy; GetNameProxy(nameProxy); CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port); if (addrResolved.IsValid()) { addr = addrResolved; return ConnectSocket(addr, hSocketRet, nTimeout); } addr = CService("0.0.0.0:0"); if (!HaveNameProxy()) return false; // first connect to name proxy server if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout)) { if (outProxyConnectionFailed) *outProxyConnectionFailed = true; return false; } // do socks negotiation if (!Socks5(strDest, (unsigned short)port, hSocket)) return false; hSocketRet = hSocket; return true; } void CNetAddr::Init() { memset(ip, 0, sizeof(ip)); } void CNetAddr::SetIP(const CNetAddr& ipIn) { memcpy(ip, ipIn.ip, sizeof(ip)); } void CNetAddr::SetRaw(Network network, const uint8_t* ip_in) { switch (network) { case NET_IPV4: memcpy(ip, pchIPv4, 12); memcpy(ip + 12, ip_in, 4); break; case NET_IPV6: memcpy(ip, ip_in, 16); break; default: assert(!"invalid network"); } } static const unsigned char pchOnionCat[] = {0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43}; bool CNetAddr::SetSpecial(const std::string& strName) { if (strName.size() > 6 && strName.substr(strName.size() - 6, 6) == ".onion") { std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str()); if (vchAddr.size() != 16 - sizeof(pchOnionCat)) return false; memcpy(ip, pchOnionCat, sizeof(pchOnionCat)); for (unsigned int i = 0; i < 16 - sizeof(pchOnionCat); i++) ip[i + sizeof(pchOnionCat)] = vchAddr[i]; return true; } return false; } CNetAddr::CNetAddr() { Init(); } CNetAddr::CNetAddr(const struct in_addr& ipv4Addr) { SetRaw(NET_IPV4, (const uint8_t*)&ipv4Addr); } CNetAddr::CNetAddr(const struct in6_addr& ipv6Addr) { SetRaw(NET_IPV6, (const uint8_t*)&ipv6Addr); } CNetAddr::CNetAddr(const char* pszIp, bool fAllowLookup) { Init(); std::vector<CNetAddr> vIP; if (LookupHost(pszIp, vIP, 1, fAllowLookup)) *this = vIP[0]; } CNetAddr::CNetAddr(const std::string& strIp, bool fAllowLookup) { Init(); std::vector<CNetAddr> vIP; if (LookupHost(strIp.c_str(), vIP, 1, fAllowLookup)) *this = vIP[0]; } unsigned int CNetAddr::GetByte(int n) const { return ip[15 - n]; } bool CNetAddr::IsIPv4() const { return (memcmp(ip, pchIPv4, sizeof(pchIPv4)) == 0); } bool CNetAddr::IsIPv6() const { return (!IsIPv4() && !IsTor()); } bool CNetAddr::IsRFC1918() const { return IsIPv4() && (GetByte(3) == 10 || (GetByte(3) == 192 && GetByte(2) == 168) || (GetByte(3) == 172 && (GetByte(2) >= 16 && GetByte(2) <= 31))); } bool CNetAddr::IsRFC2544() const { return IsIPv4() && GetByte(3) == 198 && (GetByte(2) == 18 || GetByte(2) == 19); } bool CNetAddr::IsRFC3927() const { return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); } bool CNetAddr::IsRFC6598() const { return IsIPv4() && GetByte(3) == 100 && GetByte(2) >= 64 && GetByte(2) <= 127; } bool CNetAddr::IsRFC5737() const { return IsIPv4() && ((GetByte(3) == 192 && GetByte(2) == 0 && GetByte(1) == 2) || (GetByte(3) == 198 && GetByte(2) == 51 && GetByte(1) == 100) || (GetByte(3) == 203 && GetByte(2) == 0 && GetByte(1) == 113)); } bool CNetAddr::IsRFC3849() const { return GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x0D && GetByte(12) == 0xB8; } bool CNetAddr::IsRFC3964() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x02); } bool CNetAddr::IsRFC6052() const { static const unsigned char pchRFC6052[] = {0, 0x64, 0xFF, 0x9B, 0, 0, 0, 0, 0, 0, 0, 0}; return (memcmp(ip, pchRFC6052, sizeof(pchRFC6052)) == 0); } bool CNetAddr::IsRFC4380() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0 && GetByte(12) == 0); } bool CNetAddr::IsRFC4862() const { static const unsigned char pchRFC4862[] = {0xFE, 0x80, 0, 0, 0, 0, 0, 0}; return (memcmp(ip, pchRFC4862, sizeof(pchRFC4862)) == 0); } bool CNetAddr::IsRFC4193() const { return ((GetByte(15) & 0xFE) == 0xFC); } bool CNetAddr::IsRFC6145() const { static const unsigned char pchRFC6145[] = {0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0}; return (memcmp(ip, pchRFC6145, sizeof(pchRFC6145)) == 0); } bool CNetAddr::IsRFC4843() const { return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); } bool CNetAddr::IsTor() const { return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); } bool CNetAddr::IsLocal() const { // IPv4 loopback if (IsIPv4() && (GetByte(3) == 127 || GetByte(3) == 0)) return true; // IPv6 loopback (::1/128) static const unsigned char pchLocal[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (memcmp(ip, pchLocal, 16) == 0) return true; return false; } bool CNetAddr::IsMulticast() const { return (IsIPv4() && (GetByte(3) & 0xF0) == 0xE0) || (GetByte(15) == 0xFF); } bool CNetAddr::IsValid() const { // Cleanup 3-byte shifted addresses caused by garbage in size field // of addr messages from versions before 0.2.9 checksum. // Two consecutive addr messages look like this: // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... // so if the first length field is garbled, it reads the second batch // of addr misaligned by 3 bytes. if (memcmp(ip, pchIPv4 + 3, sizeof(pchIPv4) - 3) == 0) return false; // unspecified IPv6 address (::/128) unsigned char ipNone[16] = {}; if (memcmp(ip, ipNone, 16) == 0) return false; // documentation IPv6 address if (IsRFC3849()) return false; if (IsIPv4()) { // INADDR_NONE uint32_t ipNone = INADDR_NONE; if (memcmp(ip + 12, &ipNone, 4) == 0) return false; // 0 ipNone = 0; if (memcmp(ip + 12, &ipNone, 4) == 0) return false; } return true; } bool CNetAddr::IsRoutable() const { return IsValid() && !(IsRFC1918() || IsRFC2544() || IsRFC3927() || IsRFC4862() || IsRFC6598() || IsRFC5737() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal()); } enum Network CNetAddr::GetNetwork() const { if (!IsRoutable()) return NET_UNROUTABLE; if (IsIPv4()) return NET_IPV4; if (IsTor()) return NET_TOR; return NET_IPV6; } std::string CNetAddr::ToStringIP() const { if (IsTor()) return EncodeBase32(&ip[6], 10) + ".onion"; CService serv(*this, 0); struct sockaddr_storage sockaddr; socklen_t socklen = sizeof(sockaddr); if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) { char name[1025] = ""; if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST)) return std::string(name); } if (IsIPv4()) return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); else return strprintf("%x:%x:%x:%x:%x:%x:%x:%x", GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12), GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8), GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4), GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0)); } std::string CNetAddr::ToString() const { return ToStringIP(); } bool operator==(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) == 0); } bool operator!=(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) != 0); } bool operator<(const CNetAddr& a, const CNetAddr& b) { return (memcmp(a.ip, b.ip, 16) < 0); } bool CNetAddr::GetInAddr(struct in_addr* pipv4Addr) const { if (!IsIPv4()) return false; memcpy(pipv4Addr, ip + 12, 4); return true; } bool CNetAddr::GetIn6Addr(struct in6_addr* pipv6Addr) const { memcpy(pipv6Addr, ip, 16); return true; } // get canonical identifier of an address' group // no two connections will be attempted to addresses with the same group std::vector<unsigned char> CNetAddr::GetGroup() const { std::vector<unsigned char> vchRet; int nClass = NET_IPV6; int nStartByte = 0; int nBits = 16; // all local addresses belong to the same group if (IsLocal()) { nClass = 255; nBits = 0; } // all unroutable addresses belong to the same group if (!IsRoutable()) { nClass = NET_UNROUTABLE; nBits = 0; } // for IPv4 addresses, '1' + the 16 higher-order bits of the IP // includes mapped IPv4, SIIT translated IPv4, and the well-known prefix else if (IsIPv4() || IsRFC6145() || IsRFC6052()) { nClass = NET_IPV4; nStartByte = 12; } // for 6to4 tunnelled addresses, use the encapsulated IPv4 address else if (IsRFC3964()) { nClass = NET_IPV4; nStartByte = 2; } // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 address else if (IsRFC4380()) { vchRet.push_back(NET_IPV4); vchRet.push_back(GetByte(3) ^ 0xFF); vchRet.push_back(GetByte(2) ^ 0xFF); return vchRet; } else if (IsTor()) { nClass = NET_TOR; nStartByte = 6; nBits = 4; } // for he.net, use /36 groups else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70) nBits = 36; // for the rest of the IPv6 network, use /32 groups else nBits = 32; vchRet.push_back(nClass); while (nBits >= 8) { vchRet.push_back(GetByte(15 - nStartByte)); nStartByte++; nBits -= 8; } if (nBits > 0) vchRet.push_back(GetByte(15 - nStartByte) | ((1 << nBits) - 1)); return vchRet; } uint64_t CNetAddr::GetHash() const { uint256 hash = Hash(&ip[0], &ip[16]); uint64_t nRet; memcpy(&nRet, &hash, sizeof(nRet)); return nRet; } // private extensions to enum Network, only returned by GetExtNetwork, // and only used in GetReachabilityFrom static const int NET_UNKNOWN = NET_MAX + 0; static const int NET_TEREDO = NET_MAX + 1; int static GetExtNetwork(const CNetAddr* addr) { if (addr == NULL) return NET_UNKNOWN; if (addr->IsRFC4380()) return NET_TEREDO; return addr->GetNetwork(); } /** Calculates a metric for how reachable (*this) is from a given partner */ int CNetAddr::GetReachabilityFrom(const CNetAddr* paddrPartner) const { enum Reachability { REACH_UNREACHABLE, REACH_DEFAULT, REACH_TEREDO, REACH_IPV6_WEAK, REACH_IPV4, REACH_IPV6_STRONG, REACH_PRIVATE }; if (!IsRoutable()) return REACH_UNREACHABLE; int ourNet = GetExtNetwork(this); int theirNet = GetExtNetwork(paddrPartner); bool fTunnel = IsRFC3964() || IsRFC6052() || IsRFC6145(); switch (theirNet) { case NET_IPV4: switch (ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; } case NET_IPV6: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV4: return REACH_IPV4; case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled } case NET_TOR: switch (ourNet) { default: return REACH_DEFAULT; case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well case NET_TOR: return REACH_PRIVATE; } case NET_TEREDO: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; } case NET_UNKNOWN: case NET_UNROUTABLE: default: switch (ourNet) { default: return REACH_DEFAULT; case NET_TEREDO: return REACH_TEREDO; case NET_IPV6: return REACH_IPV6_WEAK; case NET_IPV4: return REACH_IPV4; case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address } } } void CService::Init() { port = 0; } CService::CService() { Init(); } CService::CService(const CNetAddr& cip, unsigned short portIn) : CNetAddr(cip), port(portIn) { } CService::CService(const struct in_addr& ipv4Addr, unsigned short portIn) : CNetAddr(ipv4Addr), port(portIn) { } CService::CService(const struct in6_addr& ipv6Addr, unsigned short portIn) : CNetAddr(ipv6Addr), port(portIn) { } CService::CService(const struct sockaddr_in& addr) : CNetAddr(addr.sin_addr), port(ntohs(addr.sin_port)) { assert(addr.sin_family == AF_INET); } CService::CService(const struct sockaddr_in6& addr) : CNetAddr(addr.sin6_addr), port(ntohs(addr.sin6_port)) { assert(addr.sin6_family == AF_INET6); } bool CService::SetSockAddr(const struct sockaddr* paddr) { switch (paddr->sa_family) { case AF_INET: *this = CService(*(const struct sockaddr_in*)paddr); return true; case AF_INET6: *this = CService(*(const struct sockaddr_in6*)paddr); return true; default: return false; } } CService::CService(const char* pszIpPort, bool fAllowLookup) { Init(); CService ip; if (Lookup(pszIpPort, ip, 0, fAllowLookup)) *this = ip; } CService::CService(const char* pszIpPort, int portDefault, bool fAllowLookup) { Init(); CService ip; if (Lookup(pszIpPort, ip, portDefault, fAllowLookup)) *this = ip; } CService::CService(const std::string& strIpPort, bool fAllowLookup) { Init(); CService ip; if (Lookup(strIpPort.c_str(), ip, 0, fAllowLookup)) *this = ip; } CService::CService(const std::string& strIpPort, int portDefault, bool fAllowLookup) { Init(); CService ip; if (Lookup(strIpPort.c_str(), ip, portDefault, fAllowLookup)) *this = ip; } unsigned short CService::GetPort() const { return port; } bool operator==(const CService& a, const CService& b) { return (CNetAddr)a == (CNetAddr)b && a.port == b.port; } bool operator!=(const CService& a, const CService& b) { return (CNetAddr)a != (CNetAddr)b || a.port != b.port; } bool operator<(const CService& a, const CService& b) { return (CNetAddr)a < (CNetAddr)b || ((CNetAddr)a == (CNetAddr)b && a.port < b.port); } bool CService::GetSockAddr(struct sockaddr* paddr, socklen_t* addrlen) const { if (IsIPv4()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in)) return false; *addrlen = sizeof(struct sockaddr_in); struct sockaddr_in* paddrin = (struct sockaddr_in*)paddr; memset(paddrin, 0, *addrlen); if (!GetInAddr(&paddrin->sin_addr)) return false; paddrin->sin_family = AF_INET; paddrin->sin_port = htons(port); return true; } if (IsIPv6()) { if (*addrlen < (socklen_t)sizeof(struct sockaddr_in6)) return false; *addrlen = sizeof(struct sockaddr_in6); struct sockaddr_in6* paddrin6 = (struct sockaddr_in6*)paddr; memset(paddrin6, 0, *addrlen); if (!GetIn6Addr(&paddrin6->sin6_addr)) return false; paddrin6->sin6_family = AF_INET6; paddrin6->sin6_port = htons(port); return true; } return false; } std::vector<unsigned char> CService::GetKey() const { std::vector<unsigned char> vKey; vKey.resize(18); memcpy(&vKey[0], ip, 16); vKey[16] = port / 0x100; vKey[17] = port & 0x0FF; return vKey; } std::string CService::ToStringPort() const { return strprintf("%u", port); } std::string CService::ToStringIPPort() const { if (IsIPv4() || IsTor()) { return ToStringIP() + ":" + ToStringPort(); } else { return "[" + ToStringIP() + "]:" + ToStringPort(); } } std::string CService::ToString() const { return ToStringIPPort(); } void CService::SetPort(unsigned short portIn) { port = portIn; } CSubNet::CSubNet() : valid(false) { memset(netmask, 0, sizeof(netmask)); } CSubNet::CSubNet(const std::string& strSubnet, bool fAllowLookup) { size_t slash = strSubnet.find_last_of('/'); std::vector<CNetAddr> vIP; valid = true; // Default to /32 (IPv4) or /128 (IPv6), i.e. match single address memset(netmask, 255, sizeof(netmask)); std::string strAddress = strSubnet.substr(0, slash); if (LookupHost(strAddress.c_str(), vIP, 1, fAllowLookup)) { network = vIP[0]; if (slash != strSubnet.npos) { std::string strNetmask = strSubnet.substr(slash + 1); int32_t n; // IPv4 addresses start at offset 12, and first 12 bytes must match, so just offset n const int astartofs = network.IsIPv4() ? 12 : 0; if (ParseInt32(strNetmask, &n)) // If valid number, assume /24 symtex { if (n >= 0 && n <= (128 - astartofs * 8)) // Only valid if in range of bits of address { n += astartofs * 8; // Clear bits [n..127] for (; n < 128; ++n) netmask[n >> 3] &= ~(1 << (7 - (n & 7))); } else { valid = false; } } else // If not a valid number, try full netmask syntax { if (LookupHost(strNetmask.c_str(), vIP, 1, false)) // Never allow lookup for netmask { // Copy only the *last* four bytes in case of IPv4, the rest of the mask should stay 1's as // we don't want pchIPv4 to be part of the mask. for (int x = astartofs; x < 16; ++x) netmask[x] = vIP[0].ip[x]; } else { valid = false; } } } } else { valid = false; } // Normalize network according to netmask for (int x = 0; x < 16; ++x) network.ip[x] &= netmask[x]; } bool CSubNet::Match(const CNetAddr& addr) const { if (!valid || !addr.IsValid()) return false; for (int x = 0; x < 16; ++x) if ((addr.ip[x] & netmask[x]) != network.ip[x]) return false; return true; } std::string CSubNet::ToString() const { std::string strNetmask; if (network.IsIPv4()) strNetmask = strprintf("%u.%u.%u.%u", netmask[12], netmask[13], netmask[14], netmask[15]); else strNetmask = strprintf("%x:%x:%x:%x:%x:%x:%x:%x", netmask[0] << 8 | netmask[1], netmask[2] << 8 | netmask[3], netmask[4] << 8 | netmask[5], netmask[6] << 8 | netmask[7], netmask[8] << 8 | netmask[9], netmask[10] << 8 | netmask[11], netmask[12] << 8 | netmask[13], netmask[14] << 8 | netmask[15]); return network.ToString() + "/" + strNetmask; } bool CSubNet::IsValid() const { return valid; } bool operator==(const CSubNet& a, const CSubNet& b) { return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16); } bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); } #ifdef WIN32 std::string NetworkErrorString(int err) { char buf[256]; buf[0] = 0; if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buf, sizeof(buf), NULL)) { return strprintf("%s (%d)", buf, err); } else { return strprintf("Unknown error (%d)", err); } } #else std::string NetworkErrorString(int err) { char buf[256]; const char* s = buf; buf[0] = 0; /* Too bad there are two incompatible implementations of the * thread-safe strerror. */ #ifdef STRERROR_R_CHAR_P /* GNU variant can return a pointer outside the passed buffer */ s = strerror_r(err, buf, sizeof(buf)); #else /* POSIX variant always returns message in buffer */ if (strerror_r(err, buf, sizeof(buf))) buf[0] = 0; #endif return strprintf("%s (%d)", s, err); } #endif bool CloseSocket(SOCKET& hSocket) { if (hSocket == INVALID_SOCKET) return false; #ifdef WIN32 int ret = closesocket(hSocket); #else int ret = close(hSocket); #endif hSocket = INVALID_SOCKET; return ret != SOCKET_ERROR; } bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking) { if (fNonBlocking) { #ifdef WIN32 u_long nOne = 1; if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) { #else int fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) { #endif CloseSocket(hSocket); return false; } } else { #ifdef WIN32 u_long nZero = 0; if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) { #else int fFlags = fcntl(hSocket, F_GETFL, 0); if (fcntl(hSocket, F_SETFL, fFlags & ~O_NONBLOCK) == SOCKET_ERROR) { #endif CloseSocket(hSocket); return false; } } return true; }
[ "office@altbet.io" ]
office@altbet.io
987cbe02ee804c40cb79d269855a8b7749d6f226
a61eac4c44c1021e9125e91c137b0eab670c5e14
/src/protocol.h
54361c5ca61bc3c63bed6d5d0d727da0ce4f3a78
[ "MIT" ]
permissive
valeo-2/anncoin
c0a1effed01e453e8e1077ed9d3c429c9a65b8e1
eed94fd7f7e8463ed0f2b2333cbbc10818779ca6
refs/heads/master
2020-05-18T04:15:25.667359
2014-06-23T07:32:45
2014-06-23T07:32:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,424
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2011-2012 Litecoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __cplusplus # error This header can only be compiled as C++. #endif #ifndef __INCLUDED_PROTOCOL_H__ #define __INCLUDED_PROTOCOL_H__ #include "serialize.h" #include "netbase.h" #include <string> #include "uint256.h" extern bool fTestNet; static inline unsigned short GetDefaultPort(const bool testnet = fTestNet) { return testnet ? 45883 : 19001; } extern unsigned char pchMessageStart[4]; /** Message header. * (4) message start. * (12) command. * (4) size. * (4) checksum. */ class CMessageHeader { public: CMessageHeader(); CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn); std::string GetCommand() const; bool IsValid() const; IMPLEMENT_SERIALIZE ( READWRITE(FLATDATA(pchMessageStart)); READWRITE(FLATDATA(pchCommand)); READWRITE(nMessageSize); READWRITE(nChecksum); ) // TODO: make private (improves encapsulation) public: enum { MESSAGE_START_SIZE=sizeof(::pchMessageStart), COMMAND_SIZE=12, MESSAGE_SIZE_SIZE=sizeof(int), CHECKSUM_SIZE=sizeof(int), MESSAGE_SIZE_OFFSET=MESSAGE_START_SIZE+COMMAND_SIZE, CHECKSUM_OFFSET=MESSAGE_SIZE_OFFSET+MESSAGE_SIZE_SIZE }; char pchMessageStart[MESSAGE_START_SIZE]; char pchCommand[COMMAND_SIZE]; unsigned int nMessageSize; unsigned int nChecksum; }; /** nServices flags */ enum { NODE_NETWORK = (1 << 0), }; /** A CService with information about it as peer */ class CAddress : public CService { public: CAddress(); explicit CAddress(CService ipIn, uint64 nServicesIn=NODE_NETWORK); void Init(); IMPLEMENT_SERIALIZE ( CAddress* pthis = const_cast<CAddress*>(this); CService* pip = (CService*)pthis; if (fRead) pthis->Init(); if (nType & SER_DISK) READWRITE(nVersion); if ((nType & SER_DISK) || (nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH))) READWRITE(nTime); READWRITE(nServices); READWRITE(*pip); ) void print() const; // TODO: make private (improves encapsulation) public: uint64 nServices; // disk and network only unsigned int nTime; // memory only int64 nLastTry; }; /** inv message data */ class CInv { public: CInv(); CInv(int typeIn, const uint256& hashIn); CInv(const std::string& strType, const uint256& hashIn); IMPLEMENT_SERIALIZE ( READWRITE(type); READWRITE(hash); ) friend bool operator<(const CInv& a, const CInv& b); bool IsKnownType() const; const char* GetCommand() const; std::string ToString() const; void print() const; // TODO: make private (improves encapsulation) public: int type; uint256 hash; }; #endif // __INCLUDED_PROTOCOL_H__
[ "root@debian" ]
root@debian
29234affa0240f1d846f5f831a27879eba371020
3460665d25f912e76cf23a2cdf40fb825728f18d
/div2/168/2.1.cpp
3645bb2b259201a7aba2facf85d9787e350011e5
[]
no_license
Morphinity/Codeforces
376340d6971ed193895473a1b3abf63f4dcd350d
82c1f769ae9df9d15f053f8d1718998470cec355
refs/heads/master
2016-09-06T01:33:37.834377
2015-01-17T12:39:14
2015-01-17T12:39:14
29,390,614
1
0
null
null
null
null
UTF-8
C++
false
false
351
cpp
#include<iostream> using namespace std; char grid[51][51]; int main(){ int n,m; cin >> n >> m; int black = 0; for(int i=0; i<n; i++) for(int j=0; j<m; j++){ cin >> grid[i][j]; if(grid[i][j] == 'B') black++; } // check for connectivity if(black > 1){ for(int i=0; i<n; i++){ for(int j=0; j<m; j++){
[ "mbakshi@adobe.com" ]
mbakshi@adobe.com
72e97f4dd13e4323fa6411fa4b3e77b4b1bd346c
2561dba6586c3d2a3fcd62d29dd6be89cd893855
/code/LaneDetection/src/LaneDetectionAccessories/ContourSplineHelper.cpp
b54e17021a253c2015613f3f7e42f231247bc874
[]
no_license
Yueeeeeeee/SLAMParking
4c5503f46233b4e011775070458e18c49f49fdec
e58190181be8b3758cc26d3f316c9bb8c2ca72a0
refs/heads/master
2020-06-24T18:25:14.778746
2019-07-26T16:05:01
2019-07-26T16:05:01
199,043,789
1
0
null
null
null
null
UTF-8
C++
false
false
3,736
cpp
/* * ContourHelper.cpp * * Created on: Jun 21, 2018 * Author: martin */ #include <opencv2/opencv.hpp> #include <iterator> ////////////////////////// // Note: Opencv coordinate system: (0,0) is at the upper left corner of the image //////////////////////// using namespace std; using namespace cv; namespace csh { void getSplines(vector<vector<Point>> &contours, vector<vector<Point>> &splines); void cleanSpline(vector<Point> &spline); int getLowestPoint(vector<Point2i> &contour); int getHighestPoint(vector<Point2i> &contour); float slope(Vec4i line); float slope(Point p1, Point p2); double meanX(vector<Point2i> &spline); const int SPLINE_DISTANCE = 10; /** * Finds a spline for every contour by following both "sides" from the bottom to the top */ void getSplines(vector<vector<Point>> &contours, vector<vector<Point>> &splines) { splines.clear(); for (vector<Point> vec : contours) { int lowest = getHighestPoint(vec); //lowest point in the image has highest coordinate int side1 = lowest; int side2 = lowest; int currentY = vec[lowest].y; int nextStep = SPLINE_DISTANCE / 2; Point prevPoint = vec[lowest]; vector<Point> spline; while (true) { currentY -= nextStep; if (side1 >= (int) vec.size()) { side1 = 0; } do { side1++; } while (side1 < (int) vec.size() && vec[side1].y > currentY); if (side2 < 0) { side2 = vec.size() - 1; } do { side2--; } while (side2 >= 0 && vec[side2].y > currentY); if (side1 >= (int) vec.size() || side2 < 0) { goto end; } int centerX = (vec[side1].x + vec[side2].x) / 2; int centerY = (vec[side1].y + vec[side2].y) / 2; Point newPoint = Point(centerX, centerY); spline.push_back(newPoint); nextStep = SPLINE_DISTANCE * sin( slope( Vec4i(prevPoint.x, prevPoint.y, newPoint.x, newPoint.y))); prevPoint = newPoint; } end: Point highest = vec[getLowestPoint(vec)]; spline.push_back(highest); cleanSpline(spline); if (spline.size() > 4) { splines.push_back(spline); } } } /** * Not particularly useful, but might break everything if removed */ void cleanSpline(vector<Point> &spline) { if (spline.size() < 3) { return; } vector<float> angle; vector<float> derivative; float avgDerivative = 0.0; for (uint i = 0; i < spline.size() - 1; i++) { angle.push_back( slope( Vec4i(spline[i + 1].x, spline[i + 1].y, spline[i].x, spline[i].y))); } for (uint i = 0; i < spline.size() - 2; i++) { derivative.push_back(angle[i + 1] - angle[i]); avgDerivative += derivative[i]; } if (abs(derivative[0]) > (abs(derivative[1]) + abs(derivative[2])) / 2 - 20) { spline.erase(spline.begin()); angle.erase(angle.begin()); avgDerivative -= derivative[0]; derivative.erase(derivative.begin()); } } int getLowestPoint(vector<Point2i> &contour) { int index = 0; int lowest = 0; for (uint i = 0; i < contour.size(); i++) { if (contour[i].y < lowest) { lowest = contour[i].y; index = i; } } return index; } int getHighestPoint(vector<Point2i> &contour) { int index = 0; int highest = 0; for (uint i = 0; i < contour.size(); i++) { if (contour[i].y > highest) { highest = contour[i].y; index = i; } } return index; } float slope(Vec4i line) { if (line[1] < line[3]) { return atan2(line[3] - line[1], line[2] - line[0]); } else { return atan2(line[1] - line[3], line[0] - line[2]); } } float slope(Point p1, Point p2) { if (p1.y < p2.y) { return atan2(p2.y - p1.y, p2.x - p1.x); } else { return atan2(p1.y - p2.y, p1.x - p2.x); } } double meanX(vector<Point2i> &spline) { int sum = 0; for (Point2i &p : spline) { sum += p.x; } return sum / spline.size(); } }
[ "yuezrhb@gmail.com" ]
yuezrhb@gmail.com
14761b64adf45e5f10f4a4bcca2c179fc76f5992
d0c5d89a7a7192f5b4ca65f02d93755f7c144c68
/server/inc/Servers.hpp
91db2ab62b82b6c8e0050df744148b45275411d9
[]
no_license
Rhuancpq/FSE_Trabalho_2
42ba25cb232970adc0d913f73e32ec14d686db26
5d27df1a869253f3e9ec5b3dd11e876635154afb
refs/heads/main
2023-08-14T05:57:24.635764
2021-10-07T01:46:34
2021-10-07T01:46:34
410,285,960
0
1
null
null
null
null
UTF-8
C++
false
false
867
hpp
#ifndef __SERVERS_HPP__ #define __SERVERS_HPP__ #include <unordered_map> #include <algorithm> #include <iostream> #include <mutex> using namespace std; #include "Types.hpp" #include "EventQueue.hpp" // this is a singleton class class Servers { public: static Servers* getInstance(); static void destroyInstance(); void addServer(const DistServers & server); void removeServer(const string & name); DistServers getServer(const string& name); vector<DistServers> getServers(); bool hasServer(const string& name); void updateTemperature(const string & name, const double & temperature, const double & humidity); void updateData(const string& name, Data data); private: Servers() = default; ~Servers(); static Servers* instance; mutex servers_mtx; unordered_map<string, DistServers> servers; }; #endif
[ "rhuancarlos.queiroz@gmail.com" ]
rhuancarlos.queiroz@gmail.com
d5fb81be84d44be5b025011437562f8041d171ea
7da7ee1ed863d4cd4cadef835b16d8950c6952d6
/AOJ/contest_practice/2/A.cpp
80e9987400b01cf31ea1af94b18d7868224051bc
[]
no_license
rikuya6/ICPC_learning
8fd226bcd9f13f37a4d55d6de57702d0ed7182b8
d01e4c764f93f0330cc687365e3ac397e46f9559
refs/heads/master
2022-06-04T10:12:57.981280
2020-05-06T04:58:15
2020-05-06T04:58:15
52,092,562
0
0
null
2018-09-23T13:29:19
2016-02-19T14:20:22
C++
UTF-8
C++
false
false
1,453
cpp
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2012 #include <iostream> using namespace std; #define REP(i, n) for(int i = 0; i < (int)(n); i++ ) long long table[3][1000000]; int main() { int x, y, z, m; int idx, idx2; int data; int size = 500; table[0][0] = 0; table[1][0] = 0; table[2][0] = 0; table[0][1] = 1; table[1][1] = 1; table[2][1] = 1; for(int i = 2; i < size; i++){ table[0][i] = i; //cout << "table[0][" << i << "]:" << table[0][i] << endl; } for(int i = 2; i < size; i++){ table[1][i] = i * i; } for(int i = 2; i < size; i++){ table[2][i] = i * i * i; //cout << "table[2][" << i << "]:" << table[2][i] << endl; } while(cin >> data, data){ z = data; //cout << "z:" << z << endl; m = size + 500; for(int i = size - 1; i >= 0; i--){ if(table[2][i] == data){ m = i; break; } if(z >= table[2][i]){ z = table[2][i]; idx = i; //cout << "z:" << z << " table[2][" << i << "]:" << table[2][i] << endl; }else{ continue; } y = data - z; for(int k = size - 1; k >= 0; k--){ if(y >= table[1][k]){ y = table[1][k]; idx2 = k; x = data - z - y; if(m > (idx + idx2 + x)) m = idx + idx2 + x; //cout << m << " = " << idx << " + " << idx2 << " + " << x << endl; } } } cout << m << endl; } }
[ "rikuya6@gmail.com" ]
rikuya6@gmail.com
d7768827b482fb62285ec1a9dde3e8c737254b75
2de859cf5e8a4e7c0e6b4804495a2dae7404d226
/GeometricTools/Graphics/FontArialW400H12.cpp
0b1c6ab5a510678a697858a2de37df2d0e367215
[]
no_license
thecsapprentice/world-builder-dependencies
ac20734b9b9f5305f5342b0b737d7e34aa6a3bb6
9528ad27fc35f953e1e446fbd9493e291c92aaa8
refs/heads/master
2020-08-27T16:52:39.356801
2019-10-26T20:36:00
2019-10-26T20:36:00
217,438,016
1
0
null
null
null
null
UTF-8
C++
false
false
106,172
cpp
// David Eberly, Geometric Tools, Redmond WA 98052 // Copyright (c) 1998-2019 // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt // Version: 4.0.2019.08.13 #include <Graphics/GTGraphicsPCH.h> #include <Graphics/FontArialW400H12.h> using namespace gte; FontArialW400H12::FontArialW400H12(std::shared_ptr<ProgramFactory> const& factory, int maxMessageLength) : Font(factory, msWidth, msHeight, reinterpret_cast<unsigned char const*>(msTexels), msCharacterData, maxMessageLength) { } int FontArialW400H12::msWidth = 1666; int FontArialW400H12::msHeight = 12; unsigned char FontArialW400H12::msTexels[19992] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 0, 255, 0, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 0, 255, 255, 0, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 255, 255, 0, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 0, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 0, 255, 0, 255, 255, 255, 0, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, }; float FontArialW400H12::msCharacterData[257] = { 0.000300f, 0.005102f, 0.009904f, 0.014706f, 0.019508f, 0.024310f, 0.029112f, 0.033914f, 0.038715f, 0.043517f, 0.048319f, 0.053121f, 0.057923f, 0.062725f, 0.067527f, 0.072329f, 0.077131f, 0.081933f, 0.086735f, 0.091537f, 0.096339f, 0.101140f, 0.105942f, 0.110744f, 0.115546f, 0.120348f, 0.125150f, 0.129952f, 0.134754f, 0.139556f, 0.144358f, 0.149160f, 0.153962f, 0.156363f, 0.158763f, 0.161164f, 0.164766f, 0.168367f, 0.173770f, 0.177971f, 0.179772f, 0.182173f, 0.184574f, 0.187575f, 0.191176f, 0.193577f, 0.195978f, 0.198379f, 0.200780f, 0.204382f, 0.207983f, 0.211585f, 0.215186f, 0.218788f, 0.222389f, 0.225990f, 0.229592f, 0.233193f, 0.236795f, 0.239196f, 0.241597f, 0.245198f, 0.248800f, 0.252401f, 0.256002f, 0.262005f, 0.266206f, 0.270408f, 0.275210f, 0.280012f, 0.284214f, 0.288415f, 0.293217f, 0.298019f, 0.300420f, 0.304022f, 0.308223f, 0.311825f, 0.316627f, 0.321429f, 0.326230f, 0.330432f, 0.335234f, 0.340036f, 0.344238f, 0.347839f, 0.352641f, 0.356843f, 0.362845f, 0.366447f, 0.371248f, 0.375450f, 0.377851f, 0.380252f, 0.382653f, 0.385054f, 0.388655f, 0.391056f, 0.394658f, 0.398259f, 0.401861f, 0.405462f, 0.409064f, 0.412065f, 0.415666f, 0.419268f, 0.421068f, 0.422869f, 0.426471f, 0.428271f, 0.433673f, 0.437275f, 0.440876f, 0.444478f, 0.448079f, 0.450480f, 0.454082f, 0.456483f, 0.460084f, 0.464286f, 0.468487f, 0.472089f, 0.476290f, 0.479292f, 0.481693f, 0.484094f, 0.486495f, 0.490096f, 0.494898f, 0.499700f, 0.504502f, 0.509304f, 0.514106f, 0.518908f, 0.523709f, 0.528511f, 0.533313f, 0.538115f, 0.542917f, 0.547719f, 0.552521f, 0.557323f, 0.562125f, 0.566927f, 0.571729f, 0.576531f, 0.581333f, 0.586134f, 0.590936f, 0.595738f, 0.600540f, 0.605342f, 0.610144f, 0.614946f, 0.619748f, 0.624550f, 0.629352f, 0.634154f, 0.638956f, 0.643757f, 0.648559f, 0.650960f, 0.653361f, 0.656963f, 0.660564f, 0.664166f, 0.667767f, 0.670168f, 0.673769f, 0.676170f, 0.680972f, 0.683373f, 0.686975f, 0.690576f, 0.692977f, 0.697779f, 0.701381f, 0.704382f, 0.707983f, 0.710384f, 0.712785f, 0.715186f, 0.718787f, 0.722389f, 0.724790f, 0.727191f, 0.729592f, 0.731993f, 0.735594f, 0.740996f, 0.746399f, 0.751801f, 0.756002f, 0.760204f, 0.764406f, 0.768607f, 0.772809f, 0.777011f, 0.781212f, 0.787215f, 0.791417f, 0.795618f, 0.799820f, 0.804022f, 0.808223f, 0.810624f, 0.813025f, 0.815426f, 0.817827f, 0.822029f, 0.826230f, 0.831032f, 0.835834f, 0.840636f, 0.845438f, 0.850240f, 0.853841f, 0.858643f, 0.862845f, 0.867047f, 0.871248f, 0.875450f, 0.879652f, 0.883853f, 0.888055f, 0.891657f, 0.895258f, 0.898860f, 0.902461f, 0.906062f, 0.909664f, 0.915066f, 0.918667f, 0.922269f, 0.925870f, 0.929472f, 0.933073f, 0.935474f, 0.937875f, 0.940276f, 0.942677f, 0.946278f, 0.949880f, 0.953481f, 0.957083f, 0.960684f, 0.964286f, 0.967887f, 0.971489f, 0.975090f, 0.978691f, 0.982293f, 0.985894f, 0.989496f, 0.993097f, 0.996699f, 1.000300f, };
[ "nmitchel@cs.wisc.edu" ]
nmitchel@cs.wisc.edu
6fa0650f293920f9effac81baabe75c4d59056cc
5470644b5f0834b9646649da365c96101a2f9b2a
/Sources/Elastos/LibCore/inc/elastos/io/Int32ArrayBuffer.h
9e2ccf8080d49844073ba1bfe8f47354929463c1
[]
no_license
dothithuy/ElastosRDK5_0
42372da3c749170581b5ee9b3884f4a27ae81608
2cf231e9f09f8b3b8bcacb11080b4a87d047833f
refs/heads/master
2021-05-13T15:02:22.363934
2015-05-25T01:54:38
2015-05-25T01:54:38
116,755,452
1
0
null
2018-01-09T02:33:06
2018-01-09T02:33:06
null
UTF-8
C++
false
false
1,348
h
#ifndef __INT32ARRAYBUFFER_H__ #define __INT32ARRAYBUFFER_H__ #include "Int32Buffer.h" namespace Elastos { namespace IO { /** * IntArrayBuffer, ReadWriteIntArrayBuffer and ReadOnlyIntArrayBuffer compose * the implementation of array based int buffers. * <p> * IntArrayBuffer implements all the shared readonly methods and is extended by * the other two classes. * </p> * <p> * All methods are marked final for runtime performance. * </p> * */ class Int32ArrayBuffer : public Int32Buffer { public: Int32ArrayBuffer( /* [in] */ ArrayOf<Int32>* array); Int32ArrayBuffer( /* [in] */ Int32 capacity); Int32ArrayBuffer( /* [in] */ Int32 capacity, /* [in] */ ArrayOf<Int32>* backingArray, /* [in] */ Int32 offset); CARAPI GetInt32( /* [out] */ Int32* value); CARAPI GetInt32Ex( /* [in] */ Int32 index, /* [out] */ Int32* value); CARAPI GetInt32sEx( /* [out] */ ArrayOf<Int32>* dst, /* [in] */ Int32 dstOffset, /* [in] */ Int32 int32Count); CARAPI IsDirect( /* [out] */ Boolean* isDirect); CARAPI GetOrder( /* [out] */ ByteOrder* byteOrder); public: AutoPtr< ArrayOf<Int32> > mBackingArray; Int32 mOffset; }; } // namespace IO } // namespace Elastos #endif // __INT32ARRAYBUFFER_H__
[ "chen.yunzhi@kortide.com" ]
chen.yunzhi@kortide.com
787c352f7133d9852e9c5e8cc5830f40ba56ad7a
a1f1e7dee2b84d07d6b28c4ff9c6e909c7c7feb2
/src/filter.cpp
c0df61b6b0639a181d2f531005b51d0845a9385e
[ "BSD-3-Clause" ]
permissive
khurrumsaleem/OpenBPS
5e0cff64b213a83aae9a4b390427e35878fe667d
8b674ba810be36d863d261024330f271e6b31ed9
refs/heads/master
2023-03-21T19:09:57.008769
2020-10-20T16:22:13
2020-10-20T16:22:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,354
cpp
#include "openbps/filter.h" #include <sstream> #include <iostream> #include <memory> #include <algorithm> #include "../extern/pugiData/pugixml.h" #include "openbps/parse.h" namespace openbps { //============================================================================== // Global variables //============================================================================== std::vector<Filter> filters; std::unique_ptr<MaterialFilter> materialfilter; std::unique_ptr<TimeFilter> timefilter; //============================================================================== // Filters class implementation //============================================================================== Filter::Filter(pugi::xml_node node) { type = node.attribute("type").value(); bins_ = get_node_array<std::string>(node, "filter"); } //! Apply filter to results void Filter::apply(const std::vector<std::string>&input, std::vector<int>& indices) { for (int i = 0; i < input.size(); i++) { auto search = std::find_if(bins_.begin(), bins_.end(), [&input, i](const std::string& bname) { return bname == input[i]; }); if (search != bins_.end()) { indices.push_back(i); } } } MaterialFilter::MaterialFilter(pugi::xml_node node) { type = "material"; bins_ = get_node_array<std::string>(node, "filter"); } //! Apply filter to results void MaterialFilter::apply(const std::string &matname, bool& isValid) { auto search = std::find_if(bins_.begin(), bins_.end(), [&matname](const std::string& bname) { return bname == matname; }); isValid = (search != bins_.end()); } TimeFilter::TimeFilter(pugi::xml_node node) { type = "time"; bins_ = get_node_array<double>(node, "filter"); if (bins_.size() % 2 == 1) { std::cout << "Intervals number should be even" << std::endl; bins_.erase(bins_.begin() + bins_.size() - 1, bins_.end()); } } //! Apply filter to results void TimeFilter::apply(double dt, int numstep, std::vector<int>& indices) { size_t j = 0; for (size_t k = 0; k < bins_.size() / 2; k++) while(j < numstep) { if ((j + 1) * dt <= bins_[2 * k + 1] && (j + 1) * dt > bins_[2 * k]) { indices.push_back(j); } if ((j + 1) * dt > bins_[2 * k + 1]) break; j++; } } //============================================================================== // Non - class methods implementation //============================================================================== //! Reading data from configure.xml void read_fitlers_from_xml(pugi::xml_node root_node) { // Proceed all filters for (pugi::xml_node tool : root_node.children("filter")) { std::string current_type; current_type = tool.attribute("type").value(); if (current_type == "time") { timefilter = std::unique_ptr<TimeFilter>(new TimeFilter(tool)); } else if (current_type == "material") { materialfilter = std::unique_ptr<MaterialFilter>(new MaterialFilter(tool)); } else { Filter f(tool); filters.push_back(f); } } } } //namespace openbps
[ "dr.yuri92@gmail.com" ]
dr.yuri92@gmail.com
4d8aa540f4961617df280eaa9ea88af4850376ab
ac8e27210d8ae1c79e7d0d9db1bcf4e31c737718
/projects/compiler-rt/lib/scudo/standalone/quarantine.h
bac36e01c1ddcbc72e6f91cf19a8486aa6416423
[ "NCSA", "MIT", "LLVM-exception", "Apache-2.0" ]
permissive
steleman/flang9
d583d619bfb67d27a995274e30c8c1a642696ec1
4ad7c213b30422e1e0fcb3ac826640d576977d04
refs/heads/master
2020-11-27T09:50:18.644313
2020-03-07T14:37:32
2020-03-07T14:37:32
229,387,867
0
0
Apache-2.0
2019-12-21T06:35:35
2019-12-21T06:35:34
null
UTF-8
C++
false
false
9,524
h
//===-- quarantine.h --------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef SCUDO_QUARANTINE_H_ #define SCUDO_QUARANTINE_H_ #include "list.h" #include "mutex.h" #include "string_utils.h" namespace scudo { struct QuarantineBatch { // With the following count, a batch (and the header that protects it) occupy // 4096 bytes on 32-bit platforms, and 8192 bytes on 64-bit. static const u32 MaxCount = 1019; QuarantineBatch *Next; uptr Size; u32 Count; void *Batch[MaxCount]; void init(void *Ptr, uptr Size) { Count = 1; Batch[0] = Ptr; this->Size = Size + sizeof(QuarantineBatch); // Account for the Batch Size. } // The total size of quarantined nodes recorded in this batch. uptr getQuarantinedSize() const { return Size - sizeof(QuarantineBatch); } void push_back(void *Ptr, uptr Size) { DCHECK_LT(Count, MaxCount); Batch[Count++] = Ptr; this->Size += Size; } bool canMerge(const QuarantineBatch *const From) const { return Count + From->Count <= MaxCount; } void merge(QuarantineBatch *const From) { DCHECK_LE(Count + From->Count, MaxCount); DCHECK_GE(Size, sizeof(QuarantineBatch)); for (uptr I = 0; I < From->Count; ++I) Batch[Count + I] = From->Batch[I]; Count += From->Count; Size += From->getQuarantinedSize(); From->Count = 0; From->Size = sizeof(QuarantineBatch); } void shuffle(u32 State) { ::scudo::shuffle(Batch, Count, &State); } }; COMPILER_CHECK(sizeof(QuarantineBatch) <= (1U << 13)); // 8Kb. // Per-thread cache of memory blocks. template <typename Callback> class QuarantineCache { public: void initLinkerInitialized() {} void init() { memset(this, 0, sizeof(*this)); initLinkerInitialized(); } // Total memory used, including internal accounting. uptr getSize() const { return atomic_load_relaxed(&Size); } // Memory used for internal accounting. uptr getOverheadSize() const { return List.size() * sizeof(QuarantineBatch); } void enqueue(Callback Cb, void *Ptr, uptr Size) { if (List.empty() || List.back()->Count == QuarantineBatch::MaxCount) { QuarantineBatch *B = reinterpret_cast<QuarantineBatch *>(Cb.allocate(sizeof(*B))); DCHECK(B); B->init(Ptr, Size); enqueueBatch(B); } else { List.back()->push_back(Ptr, Size); addToSize(Size); } } void transfer(QuarantineCache *From) { List.append_back(&From->List); addToSize(From->getSize()); atomic_store_relaxed(&From->Size, 0); } void enqueueBatch(QuarantineBatch *B) { List.push_back(B); addToSize(B->Size); } QuarantineBatch *dequeueBatch() { if (List.empty()) return nullptr; QuarantineBatch *B = List.front(); List.pop_front(); subFromSize(B->Size); return B; } void mergeBatches(QuarantineCache *ToDeallocate) { uptr ExtractedSize = 0; QuarantineBatch *Current = List.front(); while (Current && Current->Next) { if (Current->canMerge(Current->Next)) { QuarantineBatch *Extracted = Current->Next; // Move all the chunks into the current batch. Current->merge(Extracted); DCHECK_EQ(Extracted->Count, 0); DCHECK_EQ(Extracted->Size, sizeof(QuarantineBatch)); // Remove the next batch From the list and account for its Size. List.extract(Current, Extracted); ExtractedSize += Extracted->Size; // Add it to deallocation list. ToDeallocate->enqueueBatch(Extracted); } else { Current = Current->Next; } } subFromSize(ExtractedSize); } void printStats() const { uptr BatchCount = 0; uptr TotalOverheadBytes = 0; uptr TotalBytes = 0; uptr TotalQuarantineChunks = 0; for (const QuarantineBatch &Batch : List) { BatchCount++; TotalBytes += Batch.Size; TotalOverheadBytes += Batch.Size - Batch.getQuarantinedSize(); TotalQuarantineChunks += Batch.Count; } const uptr QuarantineChunksCapacity = BatchCount * QuarantineBatch::MaxCount; const uptr ChunksUsagePercent = (QuarantineChunksCapacity == 0) ? 0 : TotalQuarantineChunks * 100 / QuarantineChunksCapacity; const uptr TotalQuarantinedBytes = TotalBytes - TotalOverheadBytes; const uptr MemoryOverheadPercent = (TotalQuarantinedBytes == 0) ? 0 : TotalOverheadBytes * 100 / TotalQuarantinedBytes; Printf("Global quarantine stats: batches: %zd; bytes: %zd (user: %zd); " "chunks: %zd (capacity: %zd); %zd%% chunks used; %zd%% memory " "overhead\n", BatchCount, TotalBytes, TotalQuarantinedBytes, TotalQuarantineChunks, QuarantineChunksCapacity, ChunksUsagePercent, MemoryOverheadPercent); } private: IntrusiveList<QuarantineBatch> List; atomic_uptr Size; void addToSize(uptr add) { atomic_store_relaxed(&Size, getSize() + add); } void subFromSize(uptr sub) { atomic_store_relaxed(&Size, getSize() - sub); } }; // The callback interface is: // void Callback::recycle(Node *Ptr); // void *Callback::allocate(uptr Size); // void Callback::deallocate(void *Ptr); template <typename Callback, typename Node> class GlobalQuarantine { public: typedef QuarantineCache<Callback> CacheT; void initLinkerInitialized(uptr Size, uptr CacheSize) { // Thread local quarantine size can be zero only when global quarantine size // is zero (it allows us to perform just one atomic read per put() call). CHECK((Size == 0 && CacheSize == 0) || CacheSize != 0); atomic_store_relaxed(&MaxSize, Size); atomic_store_relaxed(&MinSize, Size / 10 * 9); // 90% of max size. atomic_store_relaxed(&MaxCacheSize, CacheSize); Cache.initLinkerInitialized(); } void init(uptr Size, uptr CacheSize) { memset(this, 0, sizeof(*this)); initLinkerInitialized(Size, CacheSize); } uptr getMaxSize() const { return atomic_load_relaxed(&MaxSize); } uptr getCacheSize() const { return atomic_load_relaxed(&MaxCacheSize); } void put(CacheT *C, Callback Cb, Node *Ptr, uptr Size) { C->enqueue(Cb, Ptr, Size); if (C->getSize() > getCacheSize()) drain(C, Cb); } void NOINLINE drain(CacheT *C, Callback Cb) { { ScopedLock L(CacheMutex); Cache.transfer(C); } if (Cache.getSize() > getMaxSize() && RecyleMutex.tryLock()) recycle(atomic_load_relaxed(&MinSize), Cb); } void NOINLINE drainAndRecycle(CacheT *C, Callback Cb) { { ScopedLock L(CacheMutex); Cache.transfer(C); } RecyleMutex.lock(); recycle(0, Cb); } void printStats() const { // It assumes that the world is stopped, just as the allocator's printStats. Printf("Quarantine limits: global: %zdM; thread local: %zdK\n", getMaxSize() >> 20, getCacheSize() >> 10); Cache.printStats(); } private: // Read-only data. alignas(SCUDO_CACHE_LINE_SIZE) HybridMutex CacheMutex; CacheT Cache; alignas(SCUDO_CACHE_LINE_SIZE) HybridMutex RecyleMutex; atomic_uptr MinSize; atomic_uptr MaxSize; alignas(SCUDO_CACHE_LINE_SIZE) atomic_uptr MaxCacheSize; void NOINLINE recycle(uptr MinSize, Callback Cb) { CacheT Tmp; Tmp.init(); { ScopedLock L(CacheMutex); // Go over the batches and merge partially filled ones to // save some memory, otherwise batches themselves (since the memory used // by them is counted against quarantine limit) can overcome the actual // user's quarantined chunks, which diminishes the purpose of the // quarantine. const uptr CacheSize = Cache.getSize(); const uptr OverheadSize = Cache.getOverheadSize(); DCHECK_GE(CacheSize, OverheadSize); // Do the merge only when overhead exceeds this predefined limit (might // require some tuning). It saves us merge attempt when the batch list // quarantine is unlikely to contain batches suitable for merge. constexpr uptr OverheadThresholdPercents = 100; if (CacheSize > OverheadSize && OverheadSize * (100 + OverheadThresholdPercents) > CacheSize * OverheadThresholdPercents) { Cache.mergeBatches(&Tmp); } // Extract enough chunks from the quarantine to get below the max // quarantine size and leave some leeway for the newly quarantined chunks. while (Cache.getSize() > MinSize) Tmp.enqueueBatch(Cache.dequeueBatch()); } RecyleMutex.unlock(); doRecycle(&Tmp, Cb); } void NOINLINE doRecycle(CacheT *C, Callback Cb) { while (QuarantineBatch *B = C->dequeueBatch()) { const u32 Seed = static_cast<u32>( (reinterpret_cast<uptr>(B) ^ reinterpret_cast<uptr>(C)) >> 4); B->shuffle(Seed); constexpr uptr NumberOfPrefetch = 8UL; CHECK(NumberOfPrefetch <= ARRAY_SIZE(B->Batch)); for (uptr I = 0; I < NumberOfPrefetch; I++) PREFETCH(B->Batch[I]); for (uptr I = 0, Count = B->Count; I < Count; I++) { if (I + NumberOfPrefetch < Count) PREFETCH(B->Batch[I + NumberOfPrefetch]); Cb.recycle(reinterpret_cast<Node *>(B->Batch[I])); } Cb.deallocate(B); } } }; } // namespace scudo #endif // SCUDO_QUARANTINE_H_
[ "stefan.teleman@cavium.com" ]
stefan.teleman@cavium.com
54a3553fb55b67f6c6be579bc194aba07b679926
83ed1e2f176133c03a5f6dfa504b8df15ae71efb
/cpp/Heavy_atom_code/decapeptide_utils/txt2txt.cpp
327fde3574477f6e65061609e20cc100f0b66e95
[]
no_license
jmborr/code
319db14f28e1dea27f9fc703be629f171e6bd95f
32720b57699bf01803367566cdc5fff2b6bce810
refs/heads/master
2022-03-09T16:11:07.455402
2019-10-28T15:03:01
2019-10-28T15:03:01
23,627,627
0
0
null
null
null
null
UTF-8
C++
false
false
10,493
cpp
#include<iostream> using namespace std; #include<fstream> #include<string> #include <cstdlib> #include<fstream> #include"pdbClasses2.h" #include"atom_param.h" #include"amino_acid_param.h" #include"miscellanea.h" #include"random.h" /*=====================================================*/ void printSYS_SIZE( ifstream &RLX, ofstream &DMD ){ DMD << txtKeyWords[SYS_SIZE] << endl; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line ; double box[3] ; char cbuf[128] ; while( getline( RLX, line ) ){ if( line.find(txtKeyWords[SYS_SIZE]) != string::npos ){ break ; } } RLX >> box[ 0 ] >> box[ 1 ] >> box[ 2 ] ; sprintf( cbuf, "%9.4f %9.4f %9.4f\n", box[0], box[1], box[2]) ; DMD << cbuf ; RLX.seekg( pos ) ; cout << "SYS_SIZE ...\n" ; } /*=====================================================*/ void printNUM_ATOMS( PDBchain& chain, ofstream &DMD ){ cout << "NUM_ATOMS ...\n" ; DMD << txtKeyWords[NUM_ATOMS] << endl ; DMD << chain.numberOfAtoms( ) << endl ; } /*=====================================================*/ void printATOM_TYPE( ifstream &DAT, ostream& DMD, double *hcr_list ){ cout << "ATOM_TYPE ...\n" ; DMD << txtKeyWords[TYPE_ATOMS] << endl; dmd_atom_t type ; string amino_and_atom ; char cbuf[300] ; for( int i=1; i<=n_dmd_atom_t; i++){ sprintf( cbuf, "%3d ", i ) ; DMD << cbuf ; type = static_cast<dmd_atom_t>( i ) ;/*amino_param.h*/ amino_and_atom = dmd_atom_t2string( type ) ;/*amino_param.cpp*/ print_atom_type_line( cbuf, DAT, amino_and_atom ) ;/*atom_param.cpp*/ hcr_list[ i ] = out_hard_core_radius( DAT, amino_and_atom ) ; DMD << cbuf ; } } /*=====================================================*/ void printNONEL_COL( ifstream &DAT, ostream& DMD, double *hcr_list ){ cout << "NONEL_COL ...\n" ; DMD << txtKeyWords[NONEL_COL] << endl; string nonel_col[n_dmd_atom_t+1][n_dmd_atom_t+1] ; dmd_atom_t type1, type2 ; string stype1, stype2 ; char cbuf[256], cbuf2[256] ; for( int i=1; i<=n_dmd_atom_t; i++ ){ for( int j=i; j<=n_dmd_atom_t; j++ ){ type1 = static_cast<dmd_atom_t>( i ); stype1=dmd_atom_t2string( type1 ) ; type2 = static_cast<dmd_atom_t>( j ); stype2=dmd_atom_t2string( type2 ) ; /*cout<<"stype1=|"<<stype1<<"| stype2=|"<<stype2<<"|\n";*/ get_default_Van_der_Waals( stype1, stype2, nonel_col[i][j], DAT ) ; get_default_hydrophobicity( stype1, stype2, nonel_col[i][j], DAT ) ; get_default_electrostatics( stype1, stype2, nonel_col[i][j], DAT ) ; get_signal_Hydrogen_Bond( stype1, stype2, nonel_col[i][j], DAT ) ; string2char( nonel_col[i][j], cbuf2 ) ; sprintf( cbuf, "%3d %3d %s\n", i, j, cbuf2 ) ; DMD << cbuf ; } } } /*=====================================================*/ void printLINKED_PAIRS( ifstream &DAT, ofstream &DMD ){ cout << "LINKED_PAIRS ...\n" ; DMD << txtKeyWords[LINK_PAIRS] << endl; int i, j, pos = DAT.tellg( ) ; DAT.seekg( 0 ) ; double HBstrength = get_HB_strength( DAT ) ; string link, aa_at1, aa_at2 ; char cbuf[256], cbuf2[256] ; dmd_atom_t type1, type2 ; /*output hydrogen bond links*/ goto_dat_key( DAT, LINK_HB_DAT ) ; getline( DAT, link ) ; while( !is_end( link, LINK_HB_DAT ) ){ /*cout<<"link=|"<<link<<"|\n";*/ if( !is_comment(link) ){ rescale_barriers_of_link_by_factor( link, HBstrength ) ; } if( out_linked_pair( link, aa_at1, aa_at2, cbuf ) ){ type1 = string2dmd_atom_t( aa_at1 ) ; i = static_cast<int>( type1 ) ; type2 = string2dmd_atom_t( aa_at2 ) ; j = static_cast<int>( type2 ) ; if( i==0 ){ cout <<"|"<<aa_at1<<"| has no type!\n"; exit(1); } if( j==0 ){ cout <<"|"<<aa_at2<<"| has no type!\n"; exit(1); } sprintf( cbuf2, "%3d %3d %s\n", i, j, cbuf ) ; DMD << cbuf2 ; } getline( DAT, link ) ; } DAT.seekg( 0 ) ; /*output permanent links*/ goto_dat_key( DAT, LINK_PAIRS_DAT ) ; getline( DAT, link ) ; while( !is_end( link, LINK_PAIRS_DAT ) ){ if( out_linked_pair( link, aa_at1, aa_at2, cbuf ) ){ type1 = string2dmd_atom_t( aa_at1 ) ; i = static_cast<int>( type1 ) ; type2 = string2dmd_atom_t( aa_at2 ) ; j = static_cast<int>( type2 ) ; if( i==0 ){ cout <<"|"<<aa_at1<<"| has no type!\n"; exit(1); } if( j==0 ){ cout <<"|"<<aa_at2<<"| has no type!\n"; exit(1); } if( have_rotamers( DAT, aa_at1, aa_at2 ) ){ /*the default_rotamer_barrier function works only if "link" is only a torsion bond, ie, no mixture of angle and torsion bonds.*/ default_rotamer_barrier( DAT, link, cbuf ) ; } sprintf( cbuf2, "%3d %3d %s\n", i, j, cbuf ) ; DMD << cbuf2 ; } getline( DAT, link ) ; /*cout<<"link=|"<<link<<"|\n" ;*/ } DAT.seekg( pos ) ; } /*=====================================================*/ void printREACT( ifstream &DAT, ofstream &DMD ){ cout << "REACT ...\n" ; string line, sold1, sold2, snew1, snew2 ; dmd_atom_t told1, told2, tnew1, tnew2 ; char cbuf[ 128 ] ; DMD << txtKeyWords[REACT] << endl; goto_dat_key( DAT, REACT_DAT ) ; getline( DAT, line ) ; while( !is_end( line, REACT_DAT ) ){ if( get_reactants_products( line, sold1, sold2, snew1, snew2 ) ){ told1 = string2dmd_atom_t( sold1 ) ; told2 = string2dmd_atom_t( sold2 ) ; tnew1 = string2dmd_atom_t( snew1 ) ; tnew2 = string2dmd_atom_t( snew2 ) ; sprintf( cbuf, "%3d %3d %3d %3d 1\n", static_cast<int>( told1 ), static_cast<int>( told2 ), static_cast<int>( tnew1 ), static_cast<int>( tnew2 ) ) ; DMD << cbuf ; } getline( DAT, line ) ; } } /*===================================================== In the relaxed conformations, there are no hydrogen bonds formed, thus all bonds are permanent bonds */ void printLIST_ATOMS_LIST_OF_BONDS( ifstream &RLX, ofstream &DMD ){ cout << "LIST_ATOMS ...\n" ; cout << "LIST_BONDS ...\n" ; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line ; goto_txt_key( RLX, LIST_ATOMS ) ; DMD << txtKeyWords[LIST_ATOMS] << endl ; while( getline( RLX, line ) ){ DMD << line << endl ; } RLX.clear( ios::goodbit ) ; RLX.seekg( pos ) ; } /*=====================================================*/ void printLIST_PERM_BONDS( ifstream &RLX, PDBchain& chain, ofstream &DMD ){ cout << "LIST_PERM_BONDS ...\n" ; int pos = RLX.tellg( ) ; RLX.seekg( 0 ) ; string line, aa_at1, aa_at2 ; dmd_atom_t type1, type2 ; int *ids = NULL, n=0 ; char cbuf[32] ; PDBatom at1, at2 ; /*no list of permanent bonds in the prerelaxed conformation, thus go to list of bonds*/ goto_txt_key( RLX, LIST_BONDS ) ; DMD << txtKeyWords[LIST_PERM_BONDS] << endl ; while( getline( RLX, line ) ){ /*DMD <<"line="<<line<<"\n" ;*/ if(line.find("//") == string::npos){/*line is not a comment*/ ids = split_line2ints( line, n ); /*cout<<"line=|"<<line<<"|, n="<<n<<endl;*/ if( n==2 && ids ){ at1=chain.getAtomWithIndex(ids[0]) ; at2=chain.getAtomWithIndex(ids[1]); aa_at1 = at1.get_resName_nameII( ); aa_at2 = at2.get_resName_nameII( ); type1 = string2dmd_atom_t( aa_at1 ); type2 = string2dmd_atom_t( aa_at2 ); sprintf( cbuf, "%4d %4d %3d %3d\n",ids[0], ids[1], static_cast<int>(type1), static_cast<int>(type2) ) ; DMD << cbuf ; delete [] ids ; ids = NULL ; n = 0 ; } } } RLX.clear( ios::goodbit ) ; RLX.seekg( pos ) ; } /*=====================================================*/ void printHBA_LIST( ifstream &DAT, PDBchain& chain, ofstream &DMD ){ cout << "HB_LIST ...\n" ; string line, *associates=NULL, *atoms=NULL, sbuf, sbuf2 ; int *rel_index=NULL, n=0, l = chain.length( ), ix ; bool flag ; char cbuf[64] ; DMD << txtKeyWords[HB_LIST] << endl ; goto_dat_key( DAT, HB_LIST_DAT ) ; getline( DAT, line ) ; while( !is_end( line, HB_LIST_DAT ) ){ if( get_associates( line, associates, rel_index, atoms, n ) ){ for( int i=1; i<=l; i++ ){/*go through all amino acids in chain*/ flag = true ; for( int j=0; j<n; j++ ){/*check presence of all associates*/ if(!chain.is_there_resName_name_at_resIndexII( associates[j], i+rel_index[j]) ){ flag = false ; break ; } } if( flag ){/*all associates present. Retrieve their atom indexes*/ sbuf.assign("") ; ix=chain.getSerialNumberOfAtomNameAtIndex(atoms[0],i+rel_index[0]); /*below, "-1" indicates amino acid index for DMD simulations is shifted*/ sprintf( cbuf, "%3d %4d ", ix, i+rel_index[0]-1 ) ; sbuf2.assign( cbuf ) ; sbuf += sbuf2 ; for( int j=1; j<n; j++ ){/*get atom serial of all associates*/ ix=chain.getSerialNumberOfAtomNameAtIndex(atoms[j],i+rel_index[j]); sprintf( cbuf, "%3d ", ix ) ; sbuf2.assign( cbuf ) ; sbuf += sbuf2 ; } DMD << sbuf << endl ; } } } getline( DAT, line ) ; } } /*=====================================================*/ bool test_input(int argc, char ** argv ){ int number_of_arguments = argc -1 ; if( number_of_arguments != 4 ){ system("clear"); cout << "Usage: ./txt2txt.x relaxed.txt model.pdb force_field init.txt\n" ; cout << "relaxed.txt: DMD conformation with no hydrogen bond formed and with all permanent bonds present (outcome of a relaxation procedure).\n"; cout << "model.pdb: any conformation of the protein in PDB format\n"; cout << "force_field: file with info on atoms (mass, radius, bonded and nonbonded interactions)\n"; cout << "init.txt: output conformation where we include hydrogen bonds in the backbone and physical interactions.\n"; return false ; } else return true ; } /*=====================================================*/ int main( int argc, char ** argv ){ /*check number of arguments*/ if( test_input(argc, argv) == false ) { return 1 ; } /*retrieve input*/ int n_arg = argc -1 ; ifstream RLX( argv[ 1 ] ) ; ifstream PDB( argv[ 2 ] ) ; PDBchain chain ; PDB >> chain ; PDB.close( ) ; ifstream DAT( argv[ 3 ] ) ; ofstream DMD( argv[ 4 ] ) ; chain.remove_all_hydrogens( ) ; chain.renumberFully( 1 ) ; chain.renumberFullyAtomSerialNumber( 1 ) ; double *hcr_list = new double[ n_dmd_atom_t + 1] ; printSYS_SIZE( RLX, DMD ) ; printNUM_ATOMS( chain, DMD ) ; printATOM_TYPE( DAT, DMD, hcr_list ) ; printNONEL_COL( DAT, DMD, hcr_list ) ; printLINKED_PAIRS( DAT, DMD ) ; printREACT( DAT, DMD ) ; printLIST_ATOMS_LIST_OF_BONDS( RLX, DMD ) ; printLIST_PERM_BONDS( RLX, chain, DMD ) ; printHBA_LIST( DAT, chain, DMD ) ; return 0 ; }
[ "borreguero@gmail.com" ]
borreguero@gmail.com
f9456ac51971b9b76d72caf4bc7c38d669beb077
b3039bd708590128db3113e2df799f65f3690f0c
/SP_4/SP_4/SP_4.cpp
3e46a6ddb6c1e83f09a7e4aee934ae6aaafa6177
[]
no_license
degarem/system_programs
2c5816dd18ee0ed9a686b6cf85ca7330b12599d1
d075eec16dd1633eeb615816ae2f468b53e69831
refs/heads/master
2021-01-02T18:46:18.628336
2020-05-20T16:39:37
2020-05-20T16:39:37
239,749,207
0
0
null
null
null
null
UTF-8
C++
false
false
1,057
cpp
#include "stdafx.h" #include <string> #include <iostream> #include <Windows.h> using namespace std; #define MAX_PATH_SYMBOL_COUNT 260 #define MAX_COMMANMD_SYMBOL_COUNT 10 void perfrom_command(wstring command, wstring parameter); bool is_file_exists(wstring path); int wmain(int argc, wchar_t *argv[]) { printf("\n* Archivator *\n\n"); wstring command, parameter; WCHAR input[MAX_PATH_SYMBOL_COUNT + MAX_COMMANMD_SYMBOL_COUNT + 2]; do { wcin.getline(input, sizeof input); wstring input_wstr = input; int end_command_index = input_wstr.find(L" "); command = input_wstr.substr(0, end_command_index); parameter = input_wstr.substr(end_command_index + 1); perfrom_command(command, parameter); } while (command.compare(L"exit") != 0); return 0; } void perfrom_command(wstring command, wstring parameter) { wprintf(L"\n"); if (command.compare(L"zip") == 0) { zip_file() } else if (command.compare(L"unzip") == 0) { } else { wprintf(L"Incorrect command. Use:\nzip <path> for zipping\nunzip<path> for unzipping\n"); } }
[ "40548809+degarem@users.noreply.github.com" ]
40548809+degarem@users.noreply.github.com
030b79c12c8e894700ff65bc26fc134493a5d57d
58026475b343b937fcb94e8adeded69ef693e82b
/tools/json-ast-exporter/src/Options.cpp
e4b6c4e41be1c119ad107709e0bdf4ed9a5cf73d
[ "MIT" ]
permissive
plast-lab/cclyzer
ca6107e968579c5ae1156db6556940c65730b5f8
470b614ff26a348d5d9bde1cabe52cf668ec48b9
refs/heads/master
2021-01-16T18:05:18.515778
2020-10-02T11:37:55
2020-10-02T11:37:55
15,769,661
74
15
MIT
2020-10-02T11:37:57
2014-01-09T14:59:04
Python
UTF-8
C++
false
false
5,160
cpp
#include <assert.h> #include <iostream> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <boost/program_options.hpp> #include <boost/program_options/options_description.hpp> #include <boost/program_options/parsers.hpp> #include <boost/program_options/variables_map.hpp> #include "Options.hpp" namespace fs = boost::filesystem; namespace po = boost::program_options; using cclyzer::ast_exporter::Options; using boost::to_lower; Options::Options(int argc, char* argv[]) { const std::string appName = fs::basename(argv[0]); fs::path outdir; // Define and parse the program options po::options_description genericOpts("Options"); genericOpts.add_options() ("help,h", "Print help message") ("out-dir,o", po::value<fs::path>(&outdir), "Output directory for AST in JSON form") ("recursive,r", "Recurse into input directories") ("force,f", "Remove existing contents of output directory"); // hidden options group - don't show in help po::options_description hiddenOpts("hidden options"); hiddenOpts.add_options() ("input-files", po::value<std::vector<fs::path> >()->required(), "C/C++ source input files"); po::options_description cmdline_options; cmdline_options.add(genericOpts).add(hiddenOpts); // positional arguments po::positional_options_description positionalOptions; positionalOptions.add("input-files", -1); po::variables_map vm; try { po::store( po::command_line_parser(argc, argv) .options(cmdline_options) .positional(positionalOptions) .run(), vm); // --help option if (vm.count("help")) { std::cout << "Usage: " << appName << " [OPTIONS] INPUT_FILE...\n\n" << genericOpts; throw EXIT_SUCCESS; } // may throw error po::notify(vm); } catch(boost::program_options::required_option& e) { std::cerr << e.what() << " from option: " << e.get_option_name() << std::endl; throw ERROR_IN_COMMAND_LINE; } catch(boost::program_options::error& e) { std::cerr << e.what() << std::endl; throw ERROR_IN_COMMAND_LINE; } // Sanity checks assert(vm.count("input-files")); // Compute input files and create output directories std::vector<fs::path> paths = vm["input-files"].as<std::vector<fs::path> >(); set_input_files(paths.begin(), paths.end(), vm.count("recursive")); if (vm.count("out-dir")) { set_output_dir(outdir, vm.count("force")); } } template<typename FileIt> void Options::set_input_files(FileIt file_begin, FileIt file_end, bool shouldRecurse) { // Delete old contents inputFiles.clear(); // Iterate over every given path for (FileIt it = file_begin; it != file_end; ++it) { fs::path path = *it; // Check for existence if (!fs::exists(path)) { std::cerr << "Path does not exist: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Add normal files if (!fs::is_directory(path)) { inputFiles.push_back(path); continue; } if (!shouldRecurse) { std::cerr << "Input directory given, without -r option: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Recurse into directories for (fs::recursive_directory_iterator iter(path), end; iter != end; ++iter) { const fs::path& p = iter->path(); // Skip directories if (fs::is_directory(p)) continue; // Skip non C/C++ files if (!p.has_extension()) continue; std::string extension = p.extension().string(); // Downcase extension to_lower(extension); if (extension != ".c" && extension != ".cc" && extension != ".cp" && extension != ".cpp" && extension != ".cxx" && extension != ".c++" && extension != ".h" && extension != ".hpp") { continue; } inputFiles.push_back(iter->path()); } } } void Options::set_output_dir(fs::path path, bool shouldForce) { // Create non-existing directory if (!fs::exists(path)) fs::create_directory(path); if (!fs::is_directory(path)) { std::cerr << "Not a directory: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Remove old contents if (shouldForce) { for (fs::directory_iterator end, it(path); it != end; ++it) remove_all(it->path()); } // Ensure output directory is empty if (!fs::is_empty(path)) { std::cerr << "Directory not empty: " << path << std::endl; throw ERROR_IN_COMMAND_LINE; } // Store output directory (CHECK: should we canonicalize path) outdir = path; }
[ "gbalats@gmail.com" ]
gbalats@gmail.com
064c4d6e412580c3b37908b2a19f8243a5c4c7f6
3f5022154cbec1bb4643a50316e297f979b53184
/gcc-7.4.0-amd64/usr/x86_64-astraeus-linux-gnu/include/c++/7.4.0/bits/sstream.tcc
5c0e9993e85aa3c84890a9d8e416dad3780481a3
[]
no_license
ahyangyi/astraeus-toolchain-binary
45b011d3a247e67fa86f0572a183dca3fbf6abd5
4c56bf133c52ddba4e357d39fc13b2755dce0583
refs/heads/master
2020-07-31T06:35:10.026719
2019-09-25T15:12:19
2019-09-25T15:12:19
210,516,474
0
0
null
null
null
null
UTF-8
C++
false
false
130
tcc
version https://git-lfs.github.com/spec/v1 oid sha256:f331fe4c0ec14855eb0e4b41ed1a8be4f020faa1dd3d3e74706a4eb43f12be66 size 10115
[ "ahyangyi@gmail.com" ]
ahyangyi@gmail.com
57db5926af38920f85257567f1ad2c59ad40ea3f
1af656c548d631368638f76d30a74bf93550b1d3
/chrome/browser/chromeos/power/auto_screen_brightness/als_reader.h
4cc31004eccd9763152cff85ab9171f41948eab8
[ "BSD-3-Clause" ]
permissive
pineal/chromium
8d246c746141ef526a55a0b387ea48cd4e7d42e8
e6901925dd5b37d55accbac55564f639bf4f788a
refs/heads/master
2023-03-17T05:50:14.231220
2018-10-24T20:11:12
2018-10-24T20:11:12
154,564,128
1
0
NOASSERTION
2018-10-24T20:20:43
2018-10-24T20:20:43
null
UTF-8
C++
false
false
1,519
h
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_ #define CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_ #include "base/observer_list_types.h" namespace chromeos { namespace power { namespace auto_screen_brightness { // Interface to ambient light reader. class AlsReader { public: // Status of AlsReader initialization. // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class AlsInitStatus { kSuccess = 0, kInProgress = 1, kDisabled = 2, kIncorrectConfig = 3, kMissingPath = 4, kMaxValue = kMissingPath }; // AlsReader must outlive the observers. class Observer : public base::CheckedObserver { public: Observer() = default; ~Observer() override = default; virtual void OnAmbientLightUpdated(int lux) = 0; virtual void OnAlsReaderInitialized(AlsInitStatus status) = 0; private: DISALLOW_COPY_AND_ASSIGN(Observer); }; virtual ~AlsReader() = default; // Adds or removes an observer. virtual void AddObserver(Observer* observer) = 0; virtual void RemoveObserver(Observer* observer) = 0; }; } // namespace auto_screen_brightness } // namespace power } // namespace chromeos #endif // CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_ALS_READER_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
aa4dfad1b72468809b3d5e951bd26fd143896241
6cf49b15039dbe8c65af72d044ef28c7d6170db9
/ITAK/main.cpp
d97b45fb93aed5037790b2358ff62700a29e8fdb
[]
no_license
drakeaharper/cs1440
cd0d529d049d010b1a41cda7687d5d65b3b82df6
373d65ffbb6214f12b13dec58e4b64f47e78b737
refs/heads/master
2021-01-11T14:54:02.260140
2017-04-30T00:43:17
2017-04-30T00:43:17
80,245,002
0
0
null
null
null
null
UTF-8
C++
false
false
1,185
cpp
#include <iostream> #include <fstream> #include <string> #include "Dictionary.h" #include "Utils.h" #include "Analyzer.h" #include "DenialOfServiceAnalyzer.h" #include "PortScanAnalyzer.h" int main() { Configuration go; return 0; } /* Dictionary<std::string, KeyValue<std::string, KeyValue<std::string, std::string>>> baseDictionary; Utils lyndsee; std::string fileName = "SampleData.csv"; std::ifstream fileIn; fileIn.open(fileName); if (!fileIn) { std::cout << "File not opened." << std::endl; } lyndsee.buildDictionary(baseDictionary, fileIn); // ghetto test Utils::buildDictionary() because I can't get the tester config to work std::ofstream out("testBuilder.txt"); for (unsigned int index = 0; index < baseDictionary.getTotalEntries(); index++) { out << baseDictionary.getByIndex(index).getKey() << ", " << baseDictionary.getByIndex(index).getValue().getKey() << ", " << baseDictionary.getByIndex(index).getValue().getValue().getKey() << ", " << baseDictionary.getByIndex(index).getValue().getValue().getValue() << std::endl; } */
[ "drakeaharper@gmail.com" ]
drakeaharper@gmail.com
fb164e40cc1d4ad6e31c7a7725b327dec9d2a3ae
57a61c7ea1cc0a2e7686a07f3430121597043dab
/irrlicht-1.7.3/source/Irrlicht/CFileList.h
d8213e4c52b4c358f144e781f40ab3df6ea7f51f
[]
no_license
dg8fv2010/WonderLandNet
8c3b85a5abc813dba6407cdc5b72cfea4a8caaaf
22f7aeef8c676c56f49c7c6854c0a469c29bdb91
refs/heads/master
2021-01-10T12:03:31.853501
2015-06-06T12:15:49
2015-06-06T12:15:49
36,978,516
3
0
null
null
null
null
UTF-8
C++
false
false
3,616
h
// Copyright (C) 2002-2010 Nikolaus Gebhardt // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __C_FILE_LIST_H_INCLUDED__ #define __C_FILE_LIST_H_INCLUDED__ #include "IFileList.h" #include "irrString.h" #include "irrArray.h" namespace irr { namespace io { //! An entry in a list of files, can be a folder or a file. struct SFileListEntry { //! The name of the file /** If this is a file or folder in the virtual filesystem and the archive was created with the ignoreCase flag then the file name will be lower case. */ io::path Name; //! The name of the file including the path /** If this is a file or folder in the virtual filesystem and the archive was created with the ignoreDirs flag then it will be the same as Name. */ io::path FullName; //! The size of the file in bytes u32 Size; //! The ID of the file in an archive /** This is used to link the FileList entry to extra info held about this file in an archive, which can hold things like data offset and CRC. */ u32 ID; //! True if this is a folder, false if not. bool IsDirectory; //! The == operator is provided so that CFileList can slowly search the list! bool operator ==(const struct SFileListEntry& other) const { if (IsDirectory != other.IsDirectory) return false; return FullName.equals_ignore_case(other.FullName); } //! The < operator is provided so that CFileList can sort and quickly search the list. bool operator <(const struct SFileListEntry& other) const { if (IsDirectory != other.IsDirectory) return IsDirectory; return FullName.lower_ignore_case(other.FullName); } }; //! Implementation of a file list class CFileList : public IFileList { public: // CFileList methods //! Constructor /** \param path The path of this file archive */ CFileList(const io::path& path, bool ignoreCase, bool ignorePaths); //! Destructor virtual ~CFileList(); //! Add as a file or folder to the list /** \param fullPath The file name including path, up to the root of the file list. \param isDirectory True if this is a directory rather than a file. \param size The size of the file in bytes. \param id The ID of the file in the archive which owns it */ virtual u32 addItem(const io::path& fullPath, u32 size, bool isDirectory, u32 id=0); //! Sorts the file list. You should call this after adding any items to the file list virtual void sort(); //! Returns the amount of files in the filelist. virtual u32 getFileCount() const; //! Gets the name of a file in the list, based on an index. virtual const io::path& getFileName(u32 index) const; //! Gets the full name of a file in the list, path included, based on an index. virtual const io::path& getFullFileName(u32 index) const; //! Returns the ID of a file in the file list, based on an index. virtual u32 getID(u32 index) const; //! Returns true if the file is a directory virtual bool isDirectory(u32 index) const; //! Returns the size of a file virtual u32 getFileSize(u32 index) const; //! Searches for a file or folder within the list, returns the index virtual s32 findFile(const io::path& filename, bool isFolder) const; //! Returns the base path of the file list virtual const io::path& getPath() const; protected: //! Ignore paths when adding or searching for files bool IgnorePaths; //! Ignore case when adding or searching for files bool IgnoreCase; //! Path to the file list io::path Path; //! List of files core::array<SFileListEntry> Files; }; } // end namespace irr } // end namespace io #endif
[ "xuewentao@zheng-exp.lab" ]
xuewentao@zheng-exp.lab
2987d2dba0e2536fcfd078571b3d66b3038e988a
4c85c3017c86b66f203e46bd7785cb34af9e7eb8
/include/KeyFrameDataBase.h
4180552daeaf3a5de23b1aa5d47f7cda1b265d76
[]
no_license
StanleyYake/Kinect_SLAM
f2481abeaf21999e3fcae8d2e5b201c61537257c
016640c9da5aded6399b4dd95cc7cc68b9696cd1
refs/heads/master
2022-03-14T02:45:37.436040
2018-07-05T13:52:03
2018-07-05T13:56:16
469,284,731
1
0
null
2022-03-13T06:01:43
2022-03-13T06:01:42
null
UTF-8
C++
false
false
1,793
h
/** * This file is part of ORB-SLAM2. * * Copyright (C) 2014-2016 Raúl Mur-Artal <raulmur at unizar dot es> (University of Zaragoza) * For more information see <https://github.com/raulmur/ORB_SLAM2> * * ORB-SLAM2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ORB-SLAM2 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ORB-SLAM2. If not, see <http://www.gnu.org/licenses/>. */ #ifndef KEYFRAMEDATABASE_H #define KEYFRAMEDATABASE_H #include <vector> #include <list> #include <set> #include "KeyFrame.h" #include "Frame.h" #include "ORBVocabulary.h" #include<QMutex> namespace KINECT_SLAM { class KeyFrame; class Frame; class KeyFrameDatabase { public: KeyFrameDatabase(const ORBVocabulary &voc); void add(KeyFrame* pKF); void erase(KeyFrame* pKF); void clear(); // Loop Detection std::vector<KeyFrame *> DetectLoopCandidates(KeyFrame* pKF, float minScore); // Relocalization std::vector<KeyFrame*> DetectRelocalizationCandidates(Frame* F); protected: // Associated vocabulary const ORBVocabulary* mpVoc; ///< 预先训练好的词典 TemplatedVocabulary<DBoW2::FORB::TDescriptor, DBoW2::FORB>// Mat嘛 // Inverted file std::vector<list<KeyFrame*> > mvInvertedFile; ///< 倒排索引,mvInvertedFile[i]表示包含了第i个word id的所有关键帧 // Mutex QMutex mMutex; }; } #endif
[ "mysita@vip.qq.com" ]
mysita@vip.qq.com
ee9ef0215f9d55114a321f34cf3fb93045b30a01
fbfa70577946bc5ee45cfd20b8937be098ae2837
/Particle_1D_Mechanics.cpp
0a7ba6c176b6fe44af7b8bcb45402b70606699f0
[]
no_license
srankli/MPM
a26c018c8f6c21a4bc2a0b01aa02dc268e5535a1
4511f6bdd0c01dad2318a5adfb061bd94e1d17a5
refs/heads/master
2020-04-05T15:54:16.235628
2018-11-21T08:13:05
2018-11-21T08:13:05
156,989,019
0
0
null
null
null
null
UTF-8
C++
false
false
1,567
cpp
#include "Particle_1D_Mechanics.h" int ObjectByParticle_1D_Mechanics::addParticle( ParticleParam_1D_Mechanics *pcl_param, ConstitutiveModelParam *pcl_cm) { Particle_1D_Mechanics *pcl; if (!pcl_param || !pcl_cm) return -1; ++particleNum; pcl = static_cast<Particle_1D_Mechanics *>(particles_mem.alloc()); pcl->index = ++curParticleIndex; pcl->object = this; pcl->x = pcl_param->x; pcl->mass = pcl_param->mass; pcl->density = pcl_param->density; pcl->momentum1 = pcl_param->momentum1; pcl->stress11 = pcl_param->stress11; pcl->strain11 = pcl_param->strain11; pcl->estrain11 = pcl_param->estrain11; pcl->pstrain11 = pcl_param->pstrain11; constitutiveModels_mem.add_model(pcl_cm); return 0; } void ObjectByParticle_1D_Mechanics::finish_init() { ObjectByParticle::finish_init(); particles = static_cast<Particle_1D_Mechanics *>(particles_mem.get_mem()); /* // print the whole object size_t i; std::cout << "Particle info:" << std::endl; for (i = 0; i < particleNum; i++) { std::cout << "No.: " << particles[i].index << " CM: " << (unsigned int)(particles[i].cm->getType()) << std::endl; } std::cout << "Mass force BC:" << std::endl; for (i = 0; i < massForceBCNum; i++) { std::cout << "Pcl_id:" << massForceBCs[i].particle->index << " Value: " << massForceBCs[i].bodyForce1 << std::endl; } std::cout << "Surface force BC:" << std::endl; for (i = 0; i < surfaceForceBCNum; i++) { std::cout << "Pcl_id:" << surfaceForceBCs[i].particle->index << " Value: " << surfaceForceBCs[i].surfaceForce1 << std::endl; } */ }
[ "yimingli0802@foxmail.com" ]
yimingli0802@foxmail.com
99e753d63f42d129b194c3ca790139a3a635581d
56faa945655349a2c529b5076139ad823db2e516
/leetcode/medium/307.cpp
65a5cfed9044090c9b201803c680ca30fc4eb871
[]
no_license
lijinpei/leetcode
61e3fec4ec935ec0d3a8048e5df6c022b3663545
9833469506f4802009398b6217e510e35b188c95
refs/heads/master
2018-10-17T08:28:08.716683
2018-08-02T16:30:50
2018-08-02T16:30:50
120,696,376
0
0
null
null
null
null
UTF-8
C++
false
false
901
cpp
#include <vector> #include <cstdint> uint32_t LOWBITS(uint32_t v) { return v & -v; } class NumArray { uint32_t s; std::vector<int> bit, nums; int sum(uint32_t p) { int ret = 0; while (p) { ret += bit[p]; p -= LOWBITS(p); } return ret; } public: NumArray(const std::vector<int> & nums) : s(nums.size()), bit(s + 1), nums(s) { for (uint32_t i = 0; i < s; ++i) { update(i, nums[i]); } } void update(int i, int val) { int d = val - nums[i]; uint32_t p = i + 1; while (p <= s) { bit[p] += d; p += LOWBITS(p); } nums[i] = val; } int sumRange(int i, int j) { return sum(j + 1) - sum(i); } }; /** * Your NumArray object will be instantiated and called as such: * NumArray obj = new NumArray(nums); * obj.update(i,val); * int param_2 = obj.sumRange(i,j); */
[ "leekingp1994@163.com" ]
leekingp1994@163.com
e77552ec65a438a6ad053575e1b57cded2cdffa4
c0c93e8f0112f9cbfd6333b23749bb429505312a
/crane-common/overlay/hardware/libhardware/gralloc/mapper.cpp
d9f25bbd86cc1838957d27a0386b307e195ea231
[]
no_license
stelios97/allwinner_board_files
2e2a8ca414dfd6f29b4cfa67182dfb7f461dbc18
bf9248c55ce7d878a7ab74bc7bb9ca2c758b4d55
refs/heads/master
2021-01-24T01:10:36.407815
2012-03-13T16:36:16
2012-03-13T16:36:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,212
cpp
/* * Copyright (C) 2008 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <limits.h> #include <errno.h> #include <pthread.h> #include <unistd.h> #include <string.h> #include <sys/mman.h> #include <sys/stat.h> #include <sys/types.h> #include <cutils/log.h> #include <cutils/atomic.h> #include <hardware/hardware.h> #include <hardware/gralloc.h> #include "gralloc_priv.h" // we need this for now because pmem cannot mmap at an offset #define PMEM_HACK 1 /* desktop Linux needs a little help with gettid() */ #if defined(ARCH_X86) && !defined(HAVE_ANDROID_OS) #define __KERNEL__ # include <linux/unistd.h> pid_t gettid() { return syscall(__NR_gettid);} #undef __KERNEL__ #endif /*****************************************************************************/ static int gralloc_map(gralloc_module_t const* module, buffer_handle_t handle, void** vaddr) { private_handle_t* hnd = (private_handle_t*)handle; if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { size_t size = hnd->size; #if PMEM_HACK size += hnd->offset; #endif void* mappedAddress = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0); if (mappedAddress == MAP_FAILED) { LOGE("Could not mmap %s", strerror(errno)); return -errno; } hnd->base = intptr_t(mappedAddress) + hnd->offset; //LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p", // hnd->fd, hnd->offset, hnd->size, mappedAddress); } *vaddr = (void*)hnd->base; return 0; } static int gralloc_unmap(gralloc_module_t const* module, buffer_handle_t handle) { private_handle_t* hnd = (private_handle_t*)handle; if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) { void* base = (void*)hnd->base; size_t size = hnd->size; #if PMEM_HACK base = (void*)(intptr_t(base) - hnd->offset); size += hnd->offset; #endif //LOGD("unmapping from %p, size=%d", base, size); if (munmap(base, size) < 0) { LOGE("Could not unmap %s", strerror(errno)); } } hnd->base = 0; return 0; } /*****************************************************************************/ static pthread_mutex_t sMapLock = PTHREAD_MUTEX_INITIALIZER; /*****************************************************************************/ int gralloc_register_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; // In this implementation, we don't need to do anything here /* NOTE: we need to initialize the buffer as not mapped/not locked * because it shouldn't when this function is called the first time * in a new process. Ideally these flags shouldn't be part of the * handle, but instead maintained in the kernel or at least * out-of-line */ // if this handle was created in this process, then we keep it as is. private_handle_t* hnd = (private_handle_t*)handle; if (hnd->pid != getpid()) { hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; } return 0; } int gralloc_unregister_buffer(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. * NOTE: the framebuffer is handled differently and is never unmapped. */ private_handle_t* hnd = (private_handle_t*)handle; LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[unregister] handle %p still locked (state=%08x)", hnd, hnd->lockState); // never unmap buffers that were created in this process if (hnd->pid != getpid()) { if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { gralloc_unmap(module, handle); } hnd->base = 0; hnd->lockState = 0; hnd->writeOwner = 0; } return 0; } int terminateBuffer(gralloc_module_t const* module, private_handle_t* hnd) { /* * If the buffer has been mapped during a lock operation, it's time * to un-map it. It's an error to be here with a locked buffer. */ LOGE_IF(hnd->lockState & private_handle_t::LOCK_STATE_READ_MASK, "[terminate] handle %p still locked (state=%08x)", hnd, hnd->lockState); if (hnd->lockState & private_handle_t::LOCK_STATE_MAPPED) { // this buffer was mapped, unmap it now if ((hnd->flags & private_handle_t::PRIV_FLAGS_USES_PMEM) && (hnd->pid == getpid())) { // ... unless it's a "master" pmem buffer, that is a buffer // mapped in the process it's been allocated. // (see gralloc_alloc_buffer()) } else { gralloc_unmap(module, hnd); } } return 0; } int gralloc_lock(gralloc_module_t const* module, buffer_handle_t handle, int usage, int l, int t, int w, int h, void** vaddr) { if (private_handle_t::validate(handle) < 0) return -EINVAL; int err = 0; private_handle_t* hnd = (private_handle_t*)handle; int32_t current_value, new_value; int retry; do { current_value = hnd->lockState; new_value = current_value; if (current_value & private_handle_t::LOCK_STATE_WRITE) { // already locked for write LOGE("handle %p already locked for write", handle); return -EBUSY; } else if (current_value & private_handle_t::LOCK_STATE_READ_MASK) { // already locked for read if (usage & (GRALLOC_USAGE_SW_WRITE_MASK | GRALLOC_USAGE_HW_RENDER)) { LOGE("handle %p already locked for read", handle); return -EBUSY; } else { // this is not an error //LOGD("%p already locked for read... count = %d", // handle, (current_value & ~(1<<31))); } } // not currently locked if (usage & (GRALLOC_USAGE_SW_WRITE_MASK | GRALLOC_USAGE_HW_RENDER)) { // locking for write new_value |= private_handle_t::LOCK_STATE_WRITE; } new_value++; retry = android_atomic_cmpxchg(current_value, new_value, (volatile int32_t*)&hnd->lockState); } while (retry); if (new_value & private_handle_t::LOCK_STATE_WRITE) { // locking for write, store the tid hnd->writeOwner = gettid(); } if (usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { if (!(current_value & private_handle_t::LOCK_STATE_MAPPED)) { // we need to map for real pthread_mutex_t* const lock = &sMapLock; pthread_mutex_lock(lock); if (!(hnd->lockState & private_handle_t::LOCK_STATE_MAPPED)) { err = gralloc_map(module, handle, vaddr); if (err == 0) { android_atomic_or(private_handle_t::LOCK_STATE_MAPPED, (volatile int32_t*)&(hnd->lockState)); } } pthread_mutex_unlock(lock); } *vaddr = (void*)hnd->base; } return err; } int gralloc_unlock(gralloc_module_t const* module, buffer_handle_t handle) { if (private_handle_t::validate(handle) < 0) return -EINVAL; private_handle_t* hnd = (private_handle_t*)handle; int32_t current_value, new_value; do { current_value = hnd->lockState; new_value = current_value; if (current_value & private_handle_t::LOCK_STATE_WRITE) { // locked for write if (hnd->writeOwner == gettid()) { hnd->writeOwner = 0; new_value &= ~private_handle_t::LOCK_STATE_WRITE; } } if ((new_value & private_handle_t::LOCK_STATE_READ_MASK) == 0) { LOGE("handle %p not locked", handle); return -EINVAL; } new_value--; } while (android_atomic_cmpxchg(current_value, new_value, (volatile int32_t*)&hnd->lockState)); return 0; }
[ "contact@arpandeb.com" ]
contact@arpandeb.com
0c353113d49dde5026498454055f1cb171dd194e
6848723448cc22474863f6506f30bdbac2b6293e
/tools/mosesdecoder-master/phrase-extract/syntax-common/tree_test.cc
8e689f0000e50e8ddc0ea7d55fd8bb43950d70af
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LGPL-2.1-or-later", "LicenseRef-scancode-other-copyleft", "GPL-2.0-only" ]
permissive
Pangeamt/nectm
74b3052ba51f227cd508b89d3c565feccc0d2f4f
6b84f048698f2530b9fdbb30695f2e2217c3fbfe
refs/heads/master
2022-04-09T11:21:56.646469
2020-03-30T07:37:41
2020-03-30T07:37:41
250,306,101
1
0
Apache-2.0
2020-03-26T16:05:11
2020-03-26T16:05:10
null
UTF-8
C++
false
false
4,375
cc
#include "tree.h" #define BOOST_TEST_MODULE TreeTest #include <boost/test/unit_test.hpp> #include <boost/scoped_ptr.hpp> namespace MosesTraining { namespace Syntax { namespace { // Test Tree<>::PreOrderIterator with a trivial, single-node tree. BOOST_AUTO_TEST_CASE(pre_order_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(123)); Tree<int>::PreOrderIterator p(*root); BOOST_REQUIRE(p != Tree<int>::PreOrderIterator()); BOOST_REQUIRE(p->value() == 123); ++p; BOOST_REQUIRE(p == Tree<int>::PreOrderIterator()); } // Test Tree<>::PreOrderIterator on this tree: (1 (2 3) (4) (5 6 (7 8))) BOOST_AUTO_TEST_CASE(pre_order_2) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children().push_back(new Tree<int>(4)); root->children().push_back(new Tree<int>(5)); root->children()[2]->children().push_back(new Tree<int>(6)); root->children()[2]->children().push_back(new Tree<int>(7)); root->children()[2]->children()[1]->children().push_back(new Tree<int>(8)); root->SetParents(); Tree<int>::PreOrderIterator p(*root); Tree<int>::PreOrderIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 1); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 2); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 5); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 7); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 8); ++p; BOOST_REQUIRE(p == end); } // Test Tree<>::ConstPreOrderIterator on this tree: (1 (2 (3 (4 (5) (6)))) (7)) BOOST_AUTO_TEST_CASE(const_pre_order_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children()[0]->children()[0]->children().push_back(new Tree<int>(4)); root->children()[0]->children()[0]->children()[0]->children().push_back( new Tree<int>(5)); root->children()[0]->children()[0]->children()[0]->children().push_back( new Tree<int>(6)); root->children().push_back(new Tree<int>(7)); root->SetParents(); Tree<int>::ConstPreOrderIterator p(*root); Tree<int>::ConstPreOrderIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 1); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 2); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 5); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 7); ++p; BOOST_REQUIRE(p == end); } // Test Tree<>::LeafIterator with a trivial, single-node tree. BOOST_AUTO_TEST_CASE(leaf_1) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(123)); Tree<int>::LeafIterator p(*root); BOOST_REQUIRE(p != Tree<int>::LeafIterator()); BOOST_REQUIRE(p->value() == 123); ++p; BOOST_REQUIRE(p == Tree<int>::LeafIterator()); } // Test Tree<>::LeafIterator on this tree: (1 (2 3) (4) (5 6 (7 8))) BOOST_AUTO_TEST_CASE(leaf_2) { boost::scoped_ptr<Tree<int> > root(new Tree<int>(1)); root->children().push_back(new Tree<int>(2)); root->children()[0]->children().push_back(new Tree<int>(3)); root->children().push_back(new Tree<int>(4)); root->children().push_back(new Tree<int>(5)); root->children()[2]->children().push_back(new Tree<int>(6)); root->children()[2]->children().push_back(new Tree<int>(7)); root->children()[2]->children()[1]->children().push_back(new Tree<int>(8)); root->SetParents(); Tree<int>::LeafIterator p(*root); Tree<int>::LeafIterator end; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 3); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 4); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 6); ++p; BOOST_REQUIRE(p != end); BOOST_REQUIRE(p->value() == 8); ++p; BOOST_REQUIRE(p == end); } } // namespace } // namespace Syntax } // namespace MosesTraining
[ "alexander.raginsky@gmail.com" ]
alexander.raginsky@gmail.com
0bc16a5e72ff7144a2f809280d3e69bea38c4c23
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/abc053/B/4715497.cpp
74ab4429dd3c740a35ce24dc57ed00d97f86f87c
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
571
cpp
#include <iostream> #include <string> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int a_pos = 0; int z_pos = 0; for (auto itr = s.begin(); itr != s.end(); ++itr, ++a_pos) { if (*itr == 'A') { break; } } for (auto itr = s.end(); itr != s.begin(); --itr, ++z_pos) { if (*itr == 'Z') { break; } } cout << s.length() - a_pos - z_pos + 1 << endl; return 0; }
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
4016c5721be33e808eaebf73d6d96970dd4b2d78
95ae7dfa9ee578f1b24a65986ff78bf77ceca0c5
/Engine/lib/opcode/OPC_TreeCollider.h
a887983c34ba3c921c9ebc821bd1b7aeec0bcece
[ "MIT", "LicenseRef-scancode-unknown" ]
permissive
TorqueGameEngines/Torque3D
4e1f6a05cc0928980c8c7c20bcdd680eaa6dcee8
a445a4364664e299196bd551d213844486080145
refs/heads/development
2023-09-03T12:40:40.658487
2023-08-24T14:44:43
2023-08-24T14:44:43
267,440,108
1,192
178
MIT
2023-09-13T14:28:16
2020-05-27T22:35:54
C++
UTF-8
C++
false
false
13,417
h
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* * OPCODE - Optimized Collision Detection * Copyright (C) 2001 Pierre Terdiman * Homepage: http://www.codercorner.com/Opcode.htm */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Contains code for a tree collider. * \file OPC_TreeCollider.h * \author Pierre Terdiman * \date March, 20, 2001 */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Include Guard #ifndef __OPC_TREECOLLIDER_H__ #define __OPC_TREECOLLIDER_H__ //! This structure holds cached information used by the algorithm. //! Two model pointers and two colliding primitives are cached. Model pointers are assigned //! to their respective meshes, and the pair of colliding primitives is used for temporal //! coherence. That is, in case temporal coherence is enabled, those two primitives are //! tested for overlap before everything else. If they still collide, we're done before //! even entering the recursive collision code. struct OPCODE_API BVTCache : Pair { //! Constructor inline_ BVTCache() { ResetCache(); ResetCountDown(); } void ResetCache() { Model0 = null; Model1 = null; id0 = 0; id1 = 1; #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! HullTest = true; SepVector.pid = 0; SepVector.qid = 0; SepVector.SV = Point(1.0f, 0.0f, 0.0f); #endif // __MESHMERIZER_H__ } inline_ void ResetCountDown() { #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! CountDown = 50; #endif // __MESHMERIZER_H__ } const Model* Model0; //!< Model for first object const Model* Model1; //!< Model for second object #ifdef __MESHMERIZER_H__ // Collision hulls only supported within ICE ! SVCache SepVector; udword CountDown; bool HullTest; #endif // __MESHMERIZER_H__ }; class OPCODE_API AABBTreeCollider : public Collider { public: // Constructor / Destructor AABBTreeCollider(); virtual ~AABBTreeCollider(); // Generic collision query /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Generic collision query for generic OPCODE models. After the call, access the results with: * - GetContactStatus() * - GetNbPairs() * - GetPairs() * * \param cache [in] collision cache for model pointers and a colliding pair of primitives * \param world0 [in] world matrix for first object, or null * \param world1 [in] world matrix for second object, or null * \return true if success * \warning SCALE NOT SUPPORTED. The matrices must contain rotation & translation parts only. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool Collide(BVTCache& cache, const Matrix4x4* world0=null, const Matrix4x4* world1=null); // Collision queries bool Collide(const AABBCollisionTree* tree0, const AABBCollisionTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBNoLeafTree* tree0, const AABBNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBQuantizedTree* tree0, const AABBQuantizedTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); bool Collide(const AABBQuantizedNoLeafTree* tree0, const AABBQuantizedNoLeafTree* tree1, const Matrix4x4* world0=null, const Matrix4x4* world1=null, Pair* cache=null); // Settings /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Settings: selects between full box-box tests or "SAT-lite" tests (where Class III axes are discarded) * \param flag [in] true for full tests, false for coarse tests * \see SetFullPrimBoxTest(bool flag) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ void SetFullBoxBoxTest(bool flag) { mFullBoxBoxTest = flag; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Settings: selects between full triangle-box tests or "SAT-lite" tests (where Class III axes are discarded) * \param flag [in] true for full tests, false for coarse tests * \see SetFullBoxBoxTest(bool flag) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ void SetFullPrimBoxTest(bool flag) { mFullPrimBoxTest = flag; } // Stats /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of BV-BV overlap tests after a collision query. * \see GetNbPrimPrimTests() * \see GetNbBVPrimTests() * \return the number of BV-BV tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbBVBVTests() const { return mNbBVBVTests; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of Triangle-Triangle overlap tests after a collision query. * \see GetNbBVBVTests() * \see GetNbBVPrimTests() * \return the number of Triangle-Triangle tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbPrimPrimTests() const { return mNbPrimPrimTests; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Stats: gets the number of BV-Triangle overlap tests after a collision query. * \see GetNbBVBVTests() * \see GetNbPrimPrimTests() * \return the number of BV-Triangle tests performed during last query */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbBVPrimTests() const { return mNbBVPrimTests; } // Data access /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Gets the number of contacts after a collision query. * \see GetContactStatus() * \see GetPairs() * \return the number of contacts / colliding pairs. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ udword GetNbPairs() const { return mPairs.GetNbEntries()>>1; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Gets the pairs of colliding triangles after a collision query. * \see GetContactStatus() * \see GetNbPairs() * \return the list of colliding pairs (triangle indices) */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ const Pair* GetPairs() const { return (const Pair*)mPairs.GetEntries(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Validates current settings. You should call this method after all the settings and callbacks have been defined for a collider. * \return null if everything is ok, else a string describing the problem */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// override(Collider) const char* ValidateSettings(); protected: // Colliding pairs OPC_Container mPairs; //!< Pairs of colliding primitives // User mesh interfaces const MeshInterface* mIMesh0; //!< User-defined mesh interface for object0 const MeshInterface* mIMesh1; //!< User-defined mesh interface for object1 // Stats udword mNbBVBVTests; //!< Number of BV-BV tests udword mNbPrimPrimTests; //!< Number of Primitive-Primitive tests udword mNbBVPrimTests; //!< Number of BV-Primitive tests // Precomputed data Matrix3x3 mAR; //!< Absolute rotation matrix Matrix3x3 mR0to1; //!< Rotation from object0 to object1 Matrix3x3 mR1to0; //!< Rotation from object1 to object0 Point mT0to1; //!< Translation from object0 to object1 Point mT1to0; //!< Translation from object1 to object0 // Dequantization coeffs Point mCenterCoeff0; Point mExtentsCoeff0; Point mCenterCoeff1; Point mExtentsCoeff1; // Leaf description Point mLeafVerts[3]; //!< Triangle vertices udword mLeafIndex; //!< Triangle index // Settings bool mFullBoxBoxTest; //!< Perform full BV-BV tests (true) or SAT-lite tests (false) bool mFullPrimBoxTest; //!< Perform full Primitive-BV tests (true) or SAT-lite tests (false) // Internal methods // Standard AABB trees void _Collide(const AABBCollisionNode* b0, const AABBCollisionNode* b1); // Quantized AABB trees void _Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const Point& a, const Point& Pa, const Point& b, const Point& Pb); // No-leaf AABB trees void _CollideTriBox(const AABBNoLeafNode* b); void _CollideBoxTri(const AABBNoLeafNode* b); void _Collide(const AABBNoLeafNode* a, const AABBNoLeafNode* b); // Quantized no-leaf AABB trees void _CollideTriBox(const AABBQuantizedNoLeafNode* b); void _CollideBoxTri(const AABBQuantizedNoLeafNode* b); void _Collide(const AABBQuantizedNoLeafNode* a, const AABBQuantizedNoLeafNode* b); // Overlap tests void PrimTest(udword id0, udword id1); inline_ void PrimTestTriIndex(udword id1); inline_ void PrimTestIndexTri(udword id0); inline_ BOOL BoxBoxOverlap(const Point& ea, const Point& ca, const Point& eb, const Point& cb); inline_ BOOL TriBoxOverlap(const Point& center, const Point& extents); inline_ BOOL TriTriOverlap(const Point& V0, const Point& V1, const Point& V2, const Point& U0, const Point& U1, const Point& U2); // Init methods void InitQuery(const Matrix4x4* world0=null, const Matrix4x4* world1=null); bool CheckTemporalCoherence(Pair* cache); inline_ BOOL Setup(const MeshInterface* mi0, const MeshInterface* mi1) { mIMesh0 = mi0; mIMesh1 = mi1; if(!mIMesh0 || !mIMesh1) return FALSE; return TRUE; } }; #endif // __OPC_TREECOLLIDER_H__
[ "davew@garagegames.com" ]
davew@garagegames.com
2bd23cab16a03352e21d9446f50e310cea2a78b2
9618aeab5df07ffd1d4f204c8cc3af1a2345d420
/chrome/browser/chromeos/login/login_ui_keyboard_browsertest.cc
23c814f59235b138670e940ad2ff12214cd9f337
[ "BSD-3-Clause" ]
permissive
dmt3o/chromium
3709c0c73e37aec82dc44d2bbe234d1f1829c32f
d368d5937f235033bd495a57005587ab275536b4
refs/heads/master
2022-12-19T04:43:33.801508
2020-10-02T02:56:57
2020-10-02T02:56:57
279,344,900
0
0
BSD-3-Clause
2020-10-02T02:50:00
2020-07-13T15:43:43
null
UTF-8
C++
false
false
18,941
cc
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/public/cpp/login_screen_test_api.h" #include "base/command_line.h" #include "base/location.h" #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/chromeos/input_method/input_method_persistence.h" #include "chrome/browser/chromeos/language_preferences.h" #include "chrome/browser/chromeos/login/lock/screen_locker_tester.h" #include "chrome/browser/chromeos/login/lock_screen_utils.h" #include "chrome/browser/chromeos/login/login_manager_test.h" #include "chrome/browser/chromeos/login/startup_utils.h" #include "chrome/browser/chromeos/login/test/js_checker.h" #include "chrome/browser/chromeos/login/test/login_manager_mixin.h" #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" #include "chrome/browser/chromeos/login/ui/login_display_host.h" #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" #include "chrome/browser/chromeos/login/wizard_controller.h" #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" #include "chrome/browser/chromeos/settings/scoped_testing_cros_settings.h" #include "chrome/browser/chromeos/settings/stub_cros_settings_provider.h" #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" #include "chrome/common/pref_names.h" #include "chromeos/constants/chromeos_switches.h" #include "chromeos/login/auth/user_context.h" #include "components/prefs/pref_service.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_utils.h" namespace em = enterprise_management; namespace chromeos { namespace { constexpr char kTestUser1[] = "test-user1@gmail.com"; constexpr char kTestUser1NonCanonicalDisplayEmail[] = "test-us.e.r1@gmail.com"; constexpr char kTestUser1GaiaId[] = "1111111111"; constexpr char kTestUser2[] = "test-user2@gmail.com"; constexpr char kTestUser2GaiaId[] = "2222222222"; constexpr char kTestUser3[] = "test-user3@gmail.com"; constexpr char kTestUser3GaiaId[] = "3333333333"; void Append_en_US_InputMethod(std::vector<std::string>* out) { out->push_back("xkb:us::eng"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods(out); } void Append_en_US_InputMethods(std::vector<std::string>* out) { out->push_back("xkb:us::eng"); out->push_back("xkb:us:intl:eng"); #if BUILDFLAG(GOOGLE_CHROME_BRANDING) out->push_back("xkb:us:intl_pc:eng"); #endif out->push_back("xkb:us:altgr-intl:eng"); out->push_back("xkb:us:dvorak:eng"); out->push_back("xkb:us:dvp:eng"); out->push_back("xkb:us:colemak:eng"); out->push_back("xkb:us:workman:eng"); out->push_back("xkb:us:workman-intl:eng"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods(out); } } // anonymous namespace class LoginUIKeyboardTest : public chromeos::LoginManagerTest { public: LoginUIKeyboardTest() : LoginManagerTest() { test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)); test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId)); } ~LoginUIKeyboardTest() override {} void SetUpOnMainThread() override { user_input_methods.push_back("xkb:fr::fra"); user_input_methods.push_back("xkb:de::ger"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &user_input_methods); LoginManagerTest::SetUpOnMainThread(); } // Should be called from PRE_ test so that local_state is saved to disk, and // reloaded in the main test. void InitUserLastInputMethod() { input_method::SetUserLastInputMethodPreferenceForTesting( test_users_[0], user_input_methods[0]); input_method::SetUserLastInputMethodPreferenceForTesting( test_users_[1], user_input_methods[1]); } protected: std::vector<std::string> user_input_methods; std::vector<AccountId> test_users_; }; class LoginUIUserAddingKeyboardTest : public LoginUIKeyboardTest { public: LoginUIUserAddingKeyboardTest() { test_users_.push_back( AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId)); } protected: void FocusUserPod(const AccountId& account_id) { test::ExecuteOobeJS( base::StringPrintf(R"($('pod-row').focusPod($('pod-row'))" R"(.getPodWithUsername_('%s'), true))", account_id.Serialize().c_str())); } }; IN_PROC_BROWSER_TEST_F(LoginUIUserAddingKeyboardTest, PRE_CheckPODSwitches) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); RegisterUser(test_users_[2]); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIUserAddingKeyboardTest, CheckPODSwitches) { EXPECT_EQ(lock_screen_utils::GetUserLastInputMethod(test_users_[2]), std::string()); LoginUser(test_users_[2]); const std::string logged_user_input_method = lock_screen_utils::GetUserLastInputMethod(test_users_[2]); UserAddingScreen::Get()->Start(); OobeScreenWaiter(OobeScreen::SCREEN_ACCOUNT_PICKER).Wait(); std::vector<std::string> expected_input_methods; expected_input_methods.push_back(user_input_methods[0]); // Append just one. Append_en_US_InputMethod(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); FocusUserPod(test_users_[1]); EXPECT_EQ(user_input_methods[1], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); FocusUserPod(test_users_[0]); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); // Check that logged in user settings did not change. EXPECT_EQ(lock_screen_utils::GetUserLastInputMethod(test_users_[2]), logged_user_input_method); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, PRE_CheckPODScreenDefault) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); StartupUtils::MarkOobeCompleted(); } // Check default IME initialization, when there is no IME configuration in // local_state. IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, CheckPODScreenDefault) { EXPECT_EQ(2, ash::LoginScreenTestApi::GetUsersCount()); EXPECT_EQ(test_users_[0], ash::LoginScreenTestApi::GetFocusedUser()); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, PRE_CheckPODScreenWithUsers) { RegisterUser(test_users_[0]); RegisterUser(test_users_[1]); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTest, CheckPODScreenWithUsers) { EXPECT_EQ(2, ash::LoginScreenTestApi::GetUsersCount()); EXPECT_EQ(test_users_[0], ash::LoginScreenTestApi::GetFocusedUser()); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); // Active IM for the first user (active user POD). expected_input_methods.push_back(user_input_methods[0]); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); EXPECT_TRUE(ash::LoginScreenTestApi::FocusUser(test_users_[1])); EXPECT_EQ(user_input_methods[1], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); EXPECT_TRUE(ash::LoginScreenTestApi::FocusUser(test_users_[0])); EXPECT_EQ(user_input_methods[0], input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetCurrentInputMethod() .id()); } class LoginUIKeyboardTestWithUsersAndOwner : public chromeos::LoginManagerTest { public: LoginUIKeyboardTestWithUsersAndOwner() = default; ~LoginUIKeyboardTestWithUsersAndOwner() override {} void SetUpOnMainThread() override { user_input_methods.push_back("xkb:fr::fra"); user_input_methods.push_back("xkb:de::ger"); user_input_methods.push_back("xkb:pl::pol"); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &user_input_methods); scoped_testing_cros_settings_.device_settings()->Set( kDeviceOwner, base::Value(kTestUser3)); LoginManagerTest::SetUpOnMainThread(); } // Should be called from PRE_ test so that local_state is saved to disk, and // reloaded in the main test. void InitUserLastInputMethod() { input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId), user_input_methods[0]); input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId), user_input_methods[1]); input_method::SetUserLastInputMethodPreferenceForTesting( AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId), user_input_methods[2]); PrefService* local_state = g_browser_process->local_state(); local_state->SetString(language_prefs::kPreferredKeyboardLayout, user_input_methods[2]); } void CheckGaiaKeyboard(); protected: std::vector<std::string> user_input_methods; ScopedTestingCrosSettings scoped_testing_cros_settings_; }; void LoginUIKeyboardTestWithUsersAndOwner::CheckGaiaKeyboard() { std::vector<std::string> expected_input_methods; // kPreferredKeyboardLayout is now set to last focused POD. expected_input_methods.push_back(user_input_methods[0]); // Locale default input methods (the first one also is hardware IM). Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTestWithUsersAndOwner, PRE_CheckPODScreenKeyboard) { RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)); RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser2, kTestUser2GaiaId)); RegisterUser(AccountId::FromUserEmailGaiaId(kTestUser3, kTestUser3GaiaId)); InitUserLastInputMethod(); StartupUtils::MarkOobeCompleted(); } IN_PROC_BROWSER_TEST_F(LoginUIKeyboardTestWithUsersAndOwner, CheckPODScreenKeyboard) { EXPECT_EQ(3, ash::LoginScreenTestApi::GetUsersCount()); std::vector<std::string> expected_input_methods; // Owner input method. expected_input_methods.push_back(user_input_methods[2]); // Locale default input methods (the first one also is hardware IM). Append_en_US_InputMethods(&expected_input_methods); // Active IM for the first user (active user POD). expected_input_methods.push_back(user_input_methods[0]); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); // Switch to Gaia. ASSERT_TRUE(ash::LoginScreenTestApi::ClickAddUserButton()); OobeScreenWaiter(GaiaView::kScreenId).Wait(); CheckGaiaKeyboard(); // Switch back. test::ExecuteOobeJS("$('gaia-signin').cancel()"); const auto update_count = ash::LoginScreenTestApi::GetUiUpdateCount(); ash::LoginScreenTestApi::WaitForUiUpdate(update_count); EXPECT_FALSE(ash::LoginScreenTestApi::IsOobeDialogVisible()); EXPECT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } class LoginUIKeyboardPolicy : public LoginManagerTest { protected: policy::DevicePolicyBuilder* device_policy() { return policy_helper_.device_policy(); } void SetAllowedInputMethod(const std::string& method) { em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); proto.mutable_login_screen_input_methods()->add_login_screen_input_methods( method); policy_helper_.RefreshPolicyAndWaitUntilDeviceSettingsUpdated( {chromeos::kDeviceLoginScreenInputMethods}); } LoginManagerMixin login_manager_{&mixin_host_}; DeviceStateMixin device_state_{ &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_CLOUD_ENROLLED}; policy::DevicePolicyCrosTestHelper policy_helper_; }; IN_PROC_BROWSER_TEST_F(LoginUIKeyboardPolicy, RestrictInputMethods) { input_method::InputMethodManager* imm = input_method::InputMethodManager::Get(); ASSERT_TRUE(imm); // Check that input methods are default when policy is not set. ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 0U); std::vector<std::string> expected_input_methods; Append_en_US_InputMethods(&expected_input_methods); EXPECT_EQ(input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds(), expected_input_methods); std::vector<std::string> allowed_input_method{"xkb:de::ger"}; SetAllowedInputMethod(allowed_input_method.front()); ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 1U); ASSERT_EQ(imm->GetActiveIMEState()->GetNumActiveInputMethods(), 1U); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &allowed_input_method); ASSERT_EQ(imm->GetActiveIMEState()->GetCurrentInputMethod().id(), allowed_input_method.front()); // The policy method stored to language_prefs::kPreferredKeyboardLayout. So // it will be there after the policy is gone. expected_input_methods.insert( expected_input_methods.begin(), imm->GetActiveIMEState()->GetActiveInputMethodIds()[0]); // Remove the policy again em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); proto.mutable_login_screen_input_methods() ->clear_login_screen_input_methods(); policy_helper_.RefreshPolicyAndWaitUntilDeviceSettingsUpdated( {chromeos::kDeviceLoginScreenInputMethods}); ASSERT_EQ(imm->GetActiveIMEState()->GetAllowedInputMethods().size(), 0U); ASSERT_EQ(expected_input_methods, input_method::InputMethodManager::Get() ->GetActiveIMEState() ->GetActiveInputMethodIds()); } class LoginUIDevicePolicyUserAdding : public LoginUIKeyboardPolicy { public: LoginUIDevicePolicyUserAdding() { // Need at least two to run user adding screen. login_manager_.AppendRegularUsers(2); } }; IN_PROC_BROWSER_TEST_F(LoginUIDevicePolicyUserAdding, PolicyNotHonored) { const AccountId primary_account_id = login_manager_.users()[0].account_id; LoginUser(primary_account_id); input_method::InputMethodManager* input_manager = input_method::InputMethodManager::Get(); auto user_ime_state = input_manager->GetActiveIMEState(); std::vector<std::string> allowed_input_method{"xkb:de::ger"}; SetAllowedInputMethod(allowed_input_method.front()); chromeos::input_method::InputMethodManager::Get()->MigrateInputMethods( &allowed_input_method); UserAddingScreen::Get()->Start(); OobeScreenWaiter(OobeScreen::SCREEN_ACCOUNT_PICKER).Wait(); auto user_adding_ime_state = input_manager->GetActiveIMEState(); EXPECT_NE(user_ime_state, user_adding_ime_state); std::vector<std::string> default_input_methods; Append_en_US_InputMethods(&default_input_methods); // Input methods should be default because the other user (which is focused) // does not have saved last input method. EXPECT_EQ(user_adding_ime_state->GetActiveInputMethodIds(), default_input_methods); EXPECT_EQ(user_adding_ime_state->GetAllowedInputMethods().size(), 0u); EXPECT_FALSE(base::Contains(user_adding_ime_state->GetActiveInputMethodIds(), allowed_input_method.front())); } class FirstLoginKeyboardTest : public LoginManagerTest { public: FirstLoginKeyboardTest() = default; ~FirstLoginKeyboardTest() override = default; protected: AccountId test_user_{ AccountId::FromUserEmailGaiaId(kTestUser1, kTestUser1GaiaId)}; DeviceStateMixin device_state_{ &mixin_host_, DeviceStateMixin::State::OOBE_COMPLETED_UNOWNED}; }; // Tests that user input method correctly propagated after session start or // session unlock. IN_PROC_BROWSER_TEST_F(FirstLoginKeyboardTest, UsersLastInputMethodPersistsOnLoginOrUnlock) { EXPECT_TRUE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); WizardController::SkipPostLoginScreensForTesting(); // Non canonical display email (typed) should not affect input method storage. LoginDisplayHost::default_host()->SetDisplayEmail( kTestUser1NonCanonicalDisplayEmail); LoginUser(test_user_); // Last input method should be stored. EXPECT_FALSE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); ScreenLockerTester locker_tester; locker_tester.Lock(); // Clear user input method. input_method::SetUserLastInputMethodPreferenceForTesting(test_user_, std::string()); EXPECT_TRUE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); locker_tester.UnlockWithPassword(test_user_, "password"); locker_tester.WaitForUnlock(); // Last input method should be stored. EXPECT_FALSE(lock_screen_utils::GetUserLastInputMethod(test_user_).empty()); } } // namespace chromeos
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
f844974909f7ecb127696d2b93920b1a575e48bd
671ef594c3a043b32900864b3f5bf13bbcdab0aa
/src/training/elapsedtimecondition.h
6762d33480632129600dea9b89a5f45cf7cef28c
[ "MIT" ]
permissive
VSitoianu/Allegiance
bae7206b874d02fdbf4c9c746e9834c7ef93154e
6f3213b78f793c6f77fd397c280cd2dd80c46396
refs/heads/master
2021-05-07T17:15:01.811214
2017-10-22T18:18:44
2017-10-22T18:18:44
108,667,678
1
0
null
2017-10-28T17:02:26
2017-10-28T17:02:26
null
UTF-8
C++
false
false
795
h
/* ** Copyright (C) 1999 Microsoft Corporation. All Rights Reserved. ** ** File: elapsedtimecondition.h ** ** Author: ** ** Description: ** Header file for the training library "elapsedtimecondition" interface. ** ** History: */ #ifndef _ELAPSED_TIME_CONDITION_H_ #define _ELAPSED_TIME_CONDITION_H_ #ifndef _PERIODIC_CONDITION_H_ #include "PeriodicCondition.h" #endif //_PERIODIC_CONDITION_H_ #ifndef _N_TIMES_CONDITION_H_ #include "NTimesCondition.h" #endif //_N_TIMES_CONDITION_H_ #ifndef _TRUE_CONDITION_H_ #include "TrueCondition.h" #endif //_TRUE_CONDITION_H_ namespace Training { #define ElapsedTimeCondition(fTime) NTimesCondition (new PeriodicCondition (new TrueCondition, fTime), 2, true) } #endif //_ELAPSED_TIME_CONDITION_H_
[ "Administrator@svn-alleg.net" ]
Administrator@svn-alleg.net
dc020678e8d813dc327663a5419e1e27c9740900
75596988cf42a9cf443cdcc77feaa056f29181e6
/ASTAR/Classes/SceneMapWalk.cpp
60e16bc66329281ff0c5c16512c825185b99adaf
[]
no_license
ndlwill1020/AStar
67882cb0f41f605c6a1e41140ee7186b65cf55ca
5dc09943d6be902dfa2b30e3a8d59b1ed873e38d
refs/heads/master
2021-01-19T04:02:12.303495
2016-07-11T04:05:50
2016-07-11T04:05:50
47,319,863
1
0
null
null
null
null
UTF-8
C++
false
false
664
cpp
#include "SceneMapWalk.h" #include "LayerHudControl.h" bool SceneMapWalk::init(){ if(!Scene::init()){ return false; } p_LayerMapWalk=LayerMapWalk::create(); //log("LayerMapWalk->size:%f:%f",p_LayerMapWalk->getContentSize().width,p_LayerMapWalk->getContentSize().height); this->addChild(p_LayerMapWalk); auto p_LayerHudControl=LayerHudControl::create(); //log("LayerHudControl->size:%f:%f",p_LayerHudControl->getContentSize().width,p_LayerHudControl->getContentSize().height); this->addChild(p_LayerHudControl); p_LayerHudControl->p_LayerMapWalk=p_LayerMapWalk; p_LayerMapWalk->m_LayerHudControl=p_LayerHudControl; return true; }
[ "ndl_mac1020@126.com" ]
ndl_mac1020@126.com
9a68ddb48a81753dc27dcd793647a216f920ec6e
a8a29de75dd6ad07dd75c4e3ffa2d3da807d4250
/include/fastformat/sinks/null.hpp
eaa9e506ed75d98b98fbe0f6669c99afcd926ba3
[ "BSD-2-Clause" ]
permissive
moteus/FastFormat
3dbcdc33359f0d68db3db9f50f56b3f5d9296cdc
acd894848a5c4a6f9f21ccdd15aa80cc0a079496
refs/heads/master
2021-01-17T17:12:18.812317
2015-09-28T12:15:05
2015-09-28T12:15:05
63,425,872
1
1
null
2016-07-15T13:58:11
2016-07-15T13:58:10
null
UTF-8
C++
false
false
5,314
hpp
/* ///////////////////////////////////////////////////////////////////////// * File: fastformat/sinks/null.hpp * * Purpose: A class that acts as a bit-bucket sink. * * Created: 3rd December 2008 * Updated: 14th September 2010 * * Home: http://www.fastformat.org/ * * Copyright (c) 2008-2010, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - Neither the names of Matthew Wilson and Synesis Software nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////// */ /** \file fastformat/sinks/null.hpp * * [C++ only] A class that acts as a bit-bucket sink. */ #ifndef FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL #define FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL /* ///////////////////////////////////////////////////////////////////////// * Version information */ #ifndef FASTFORMAT_DOCUMENTATION_SKIP_SECTION # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_MAJOR 1 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_MINOR 1 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_REVISION 2 # define FASTFORMAT_VER_FASTFORMAT_SINK_HPP_NULL_EDIT 6 #endif /* !FASTFORMAT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * Language */ #ifndef __cplusplus # error This file can only be included in C++ compilation units #endif /* !__cplusplus */ /* ///////////////////////////////////////////////////////////////////////// * Includes */ #include <fastformat/fastformat.h> #include <fastformat/format/standard_flags.hpp> #include <fastformat/quality/contract.h> /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #if !defined(FASTFORMAT_NO_NAMESPACE) namespace fastformat { namespace sinks { #endif /* !FASTFORMAT_NO_NAMESPACE */ /* ///////////////////////////////////////////////////////////////////////// * Classes */ /** A class that acts as a bit-bucket sink * * \ingroup group__sinks */ struct null_sink { size_t numWrites; /*!< The number of times fmt_slices() was invoked on the instance */ size_t numSlices; /*!< The total number of slices passed in all invocations of fmt_slices() */ size_t cchTotal; /*!< The total number of characters passed in all invocations of fmt_slices() */ public: // Construction /** Initialises all statistics members to zero */ null_sink() : numWrites(0u) , numSlices(0u) , cchTotal(0u) {} }; /* ///////////////////////////////////////////////////////////////////////// * Action Shims */ /** Writes an array of string slices into a <code>null_sink</code> sink. * * \ingroup group__sinks */ inline null_sink& fmt_slices( null_sink& sink , int /* flags */ , size_t cchTotal , size_t numResults , ff_string_slice_t const* results ) { if(NULL == results) { FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(0u == cchTotal, "Cannot have non-zero size if the results array pointer is null"); FASTFORMAT_CONTRACT_ENFORCE_PRECONDITION_PARAMS_INTERNAL(0u == numResults, "Cannot have non-zero array elements if the results array pointer is null"); } else { ++sink.numWrites; sink.numSlices += numResults; sink.cchTotal += cchTotal; } return sink; } /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #if !defined(FASTFORMAT_NO_NAMESPACE) } /* namespace sinks */ } /* namespace fastformat */ #endif /* !FASTFORMAT_NO_NAMESPACE */ /* ////////////////////////////////////////////////////////////////////// */ #endif /* FASTFORMAT_INCL_FASTFORMAT_SINK_HPP_NULL */ /* ///////////////////////////// end of file //////////////////////////// */
[ "matthew@synesis.com.au" ]
matthew@synesis.com.au
3d711433719fb800b61d79e3634d870eb56683b5
5884451df714e76b8725fa2c68fdce8c782b9bf0
/libcore/src/network/Frame.cpp
92a40f6b0c4369545e3ad843ff1c306c1ec119c6
[ "BSD-3-Clause" ]
permissive
khoshino/sirikata
933a0736161ae561be7c0d9ab306f222d8663a02
f4c1838a4cf7f3aa96752f4c3001c5190908c245
refs/heads/master
2021-01-21T00:25:53.201796
2011-06-22T20:45:05
2011-06-22T20:58:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,079
cpp
/* Sirikata * Frame.cpp * * Copyright (c) 2010, Ewen Cheslack-Postava. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of Sirikata nor the names of its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <sirikata/core/util/Standard.hh> #include <sirikata/core/network/Frame.hpp> // htonl, ntohl #include <sirikata/core/network/Asio.hpp> namespace Sirikata { namespace Network { /** Writes the data to the stream as a message. */ std::string Frame::write(const void* data, uint32 len) { std::string result(len + sizeof(uint32), '\0'); uint32 encoded_len = htonl(len); memcpy(&(result[0]), &encoded_len, sizeof(uint32)); memcpy(&(result[sizeof(uint32)]), data, len); return result; } std::string Frame::write(const std::string& data) { return Frame::write(&(data[0]), data.size()); } std::string Frame::parse(std::string& data) { std::string result; if (data.size() < sizeof(uint32)) return result; // Try to parse the length uint32 len; memcpy(&len, &(data[0]), sizeof(uint32)); len = ntohl(len); // Make sure we have the full packet if (data.size() < sizeof(uint32) + len) return result; // Extract it result = data.substr(sizeof(uint32), len); // Remove it data = data.substr(sizeof(uint32) + len); return result; } std::string Frame::parse(std::stringstream& data) { std::string so_far = data.str(); std::string result = parse(so_far); if (!result.empty()) { // Read off the right amount of data from the stringstream data.ignore( sizeof(uint32) + result.size() ); } return result; } } // namespace Network } // namespace Frame
[ "ewencp@cs.stanford.edu" ]
ewencp@cs.stanford.edu
acb71b1d30c41624b4d569aa43e55dd99ea019f3
7a433f33264d0ad90c14254797a58649c012ce0d
/25.1/p11361/p11361/main.cpp
1cfc9c66fe2ba548190e8e7dc5181445fcc4b76b
[ "Apache-2.0" ]
permissive
Qvocha/Grisha
dc1a2d797bbdfe59b01abe03565cd483599148c0
f7a8ce32c3abe5f57c00bdef28c19bf62d1fee28
refs/heads/master
2020-06-09T22:29:17.639576
2019-06-24T15:42:23
2019-06-24T15:42:23
193,518,874
0
0
null
null
null
null
UTF-8
C++
false
false
110
cpp
#include <iostream> #include "task25.h" using namespace std; int main() { fipi2018(); return 0; }
[ "pineappletoe@gmail.com" ]
pineappletoe@gmail.com
c8dc701235155a9caac9d92bf68379fd38f7567c
10341b14f0528b0f4a6449f9a3d8dc70e9044143
/codeforces/1180-A.cpp
2a54cd127fbff35e1f6174dd4071b5d78bc20e00
[]
no_license
ayu16/CodeSolutions
e78fe8ec4c9b322b0071e20313f3b4c6e0185272
503845f6c5956507dbf8e033207ab074dc1d5ad4
refs/heads/main
2023-08-25T12:18:23.496152
2021-10-21T05:56:19
2021-10-21T05:56:19
419,598,280
0
0
null
2021-10-21T05:56:19
2021-10-21T05:53:10
null
UTF-8
C++
false
false
1,193
cpp
// https://codeforces.com/contest/1180/problem/A #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define pb push_back #define mp make_pair #define vi vector<int> #define vll vector<ll> #define pii pair<int, int> #define pll pair<ll, ll> #define F first #define S second #define pn printf("\n") #define si(n) scanf("%d", &n) #define sl(n) scanf("%lld", &n) #define all(c) (c).begin(), (c).end() #define tra(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) ll strtoll(string s) { stringstream str(s); ll number=0; str>>number; return number; } string lltostr(ll n){ stringstream ss; ss<<n; return ss.str(); } const int MOD = 1e9 + 7; ll solve(ll n) { ll ans = 0; for(int i = 0 ; i < n - 1 ; i++) { ans += 2 *((2 * i) + 1); } ans += (2 * (n - 1)) + 1; return ans; } void wrapper() { int n; cin >> n; cout << solve(n) << "\n"; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); // clock_t tStart = clock(); /*******/ int t = 1; // cin >> t; while(t--) { wrapper(); } /*******/ // printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC); return 0; }
[ "ankurcharan98@gmail.com" ]
ankurcharan98@gmail.com
2d26a6b0187e8ac52e7969028a31b44e3de25b89
8f29bbdbc1b29365eca840b72d61f63abe8f829f
/Semester2/3001/AI midterm/SDLGameEngine/Align.h
d7800e496cb46097c91e1b8ada52797d677fda36
[]
no_license
CccrizzZ/GBC01
d294f01aab97de37f2b70bcf325ae713e4eed740
c44130872f609e5778992d8a6dad09caed29ff71
refs/heads/master
2022-02-22T11:32:54.720661
2019-10-14T00:07:50
2019-10-14T00:07:50
158,318,882
0
0
null
null
null
null
UTF-8
C++
false
false
304
h
#pragma once #include "SteeringBehaviour.h" class Align : public SteeringBehaviour { public: Align(); Align(GameObject* go); ~Align(); void Update(); float orientation; float maxAngularAccelaration = 0.1f; float targetRadius = 0.5f; float slowRadius = 1.0f; float timeToTarget = 0.1f; };
[ "ccccrizzzz@gmail.com" ]
ccccrizzzz@gmail.com
bdb0ea1bfd29fb2e90f269251480495f9b95072a
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-clouddirectory/source/model/UpdateSchemaResult.cpp
2212eb21df8632de13d62bed3387d048b8bfa2ce
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
1,354
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/clouddirectory/model/UpdateSchemaResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/UnreferencedParam.h> #include <utility> using namespace Aws::CloudDirectory::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; using namespace Aws; UpdateSchemaResult::UpdateSchemaResult() { } UpdateSchemaResult::UpdateSchemaResult(const AmazonWebServiceResult<JsonValue>& result) { *this = result; } UpdateSchemaResult& UpdateSchemaResult::operator =(const AmazonWebServiceResult<JsonValue>& result) { const JsonValue& jsonValue = result.GetPayload(); if(jsonValue.ValueExists("SchemaArn")) { m_schemaArn = jsonValue.GetString("SchemaArn"); } return *this; }
[ "henso@amazon.com" ]
henso@amazon.com
920893112aa418d630c07859c9776a9561b602a5
9621b172b8d01dd9d275537293b3d1e9a19ef4ce
/src/chrono_vehicle/cosim/terrain/ChVehicleCosimTerrainNodeSCM.cpp
4582e4919edd167c214b6ef80fa5ab0ed31809ae
[ "BSD-3-Clause" ]
permissive
jmange/chrono
c72173d06824405c958be0914e41db70540b84e8
f25c40d0eccfe30b5a6cdec3148e26d5c393015b
refs/heads/main
2023-07-09T20:03:16.294624
2023-07-05T18:13:27
2023-07-05T18:13:27
629,678,854
0
0
null
2023-04-18T20:03:19
2023-04-18T20:03:18
null
UTF-8
C++
false
false
15,679
cpp
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2020 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban // ============================================================================= // // Definition of the SCM deformable TERRAIN NODE. // // The global reference frame has Z up, X towards the front of the vehicle, and // Y pointing to the left. // // ============================================================================= #include <algorithm> #include <cmath> #include <set> #include "chrono/utils/ChUtilsCreators.h" #include "chrono/utils/ChUtilsGenerators.h" #include "chrono/utils/ChUtilsInputOutput.h" #include "chrono/assets/ChTriangleMeshShape.h" #include "chrono/physics/ChSystemSMC.h" #include "chrono/physics/ChSystemNSC.h" #include "chrono_vehicle/cosim/terrain/ChVehicleCosimTerrainNodeSCM.h" #ifdef CHRONO_IRRLICHT #include "chrono_irrlicht/ChVisualSystemIrrlicht.h" #endif #ifdef CHRONO_VSG #include "chrono_vsg/ChVisualSystemVSG.h" #endif using std::cout; using std::endl; using namespace rapidjson; namespace chrono { namespace vehicle { // Maximum sinkage for rendering static const double max_sinkage = 0.15; // ----------------------------------------------------------------------------- // Construction of the terrain node: // - create the Chrono system and set solver parameters // - create the Irrlicht visualization window // ----------------------------------------------------------------------------- ChVehicleCosimTerrainNodeSCM::ChVehicleCosimTerrainNodeSCM(double length, double width) : ChVehicleCosimTerrainNodeChrono(Type::SCM, length, width, ChContactMethod::SMC), m_radius_p(5e-3), m_use_checkpoint(false) { // Create system and set default method-specific solver settings m_system = new ChSystemSMC; // Solver settings independent of method type m_system->Set_G_acc(ChVector<>(0, 0, m_gacc)); // Set default number of threads m_system->SetNumThreads(1, 1, 1); } ChVehicleCosimTerrainNodeSCM::ChVehicleCosimTerrainNodeSCM(const std::string& specfile) : ChVehicleCosimTerrainNodeChrono(Type::SCM, 0, 0, ChContactMethod::SMC), m_use_checkpoint(false) { // Create system and set default method-specific solver settings m_system = new ChSystemSMC; // Solver settings independent of method type m_system->Set_G_acc(ChVector<>(0, 0, m_gacc)); // Read SCM parameters from provided specfile SetFromSpecfile(specfile); } ChVehicleCosimTerrainNodeSCM::~ChVehicleCosimTerrainNodeSCM() { delete m_terrain; delete m_system; } // ----------------------------------------------------------------------------- //// TODO: error checking void ChVehicleCosimTerrainNodeSCM::SetFromSpecfile(const std::string& specfile) { Document d; ReadSpecfile(specfile, d); m_dimX = d["Patch dimensions"]["Length"].GetDouble(); m_dimY = d["Patch dimensions"]["Width"].GetDouble(); m_spacing = d["Grid spacing"].GetDouble(); m_Bekker_Kphi = d["Soil parameters"]["Bekker Kphi"].GetDouble(); m_Bekker_Kc = d["Soil parameters"]["Bekker Kc"].GetDouble(); m_Bekker_n = d["Soil parameters"]["Bekker n exponent"].GetDouble(); m_Mohr_cohesion = d["Soil parameters"]["Mohr cohesive limit"].GetDouble(); m_Mohr_friction = d["Soil parameters"]["Mohr friction limit"].GetDouble(); m_Janosi_shear = d["Soil parameters"]["Janosi shear coefficient"].GetDouble(); m_elastic_K = d["Soil parameters"]["Elastic stiffness"].GetDouble(); m_damping_R = d["Soil parameters"]["Damping"].GetDouble(); m_radius_p = d["Simulation settings"]["Proxy contact radius"].GetDouble(); m_fixed_proxies = d["Simulation settings"]["Fix proxies"].GetBool(); } void ChVehicleCosimTerrainNodeSCM::SetPropertiesSCM(double spacing, double Bekker_Kphi, double Bekker_Kc, double Bekker_n, double Mohr_cohesion, double Mohr_friction, double Janosi_shear, double elastic_K, double damping_R) { m_spacing = spacing; m_Bekker_Kphi = Bekker_Kphi; m_Bekker_Kc = Bekker_Kc; m_Bekker_n = Bekker_n; m_Mohr_cohesion = Mohr_cohesion; m_Mohr_friction = Mohr_friction; m_Janosi_shear = Janosi_shear; m_elastic_K = elastic_K; m_damping_R = damping_R; } void ChVehicleCosimTerrainNodeSCM::SetInputFromCheckpoint(const std::string& filename) { m_use_checkpoint = true; m_checkpoint_filename = filename; } void ChVehicleCosimTerrainNodeSCM::SetNumThreads(int num_threads) { m_system->SetNumThreads(num_threads, 1, 1); } // ----------------------------------------------------------------------------- // Complete construction of the mechanical system. // This function is invoked automatically from Initialize. // - adjust system settings // - create the container body // - if specified, create the granular material // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::Construct() { if (m_verbose) cout << "[Terrain node] SCM " << endl; // Create the SCM patch (default center at origin) m_terrain = new SCMTerrain(m_system); m_terrain->SetSoilParameters(m_Bekker_Kphi, m_Bekker_Kc, m_Bekker_n, // m_Mohr_cohesion, m_Mohr_friction, m_Janosi_shear, // m_elastic_K, m_damping_R); m_terrain->SetPlotType(vehicle::SCMTerrain::PLOT_SINKAGE, 0, max_sinkage); m_terrain->Initialize(m_dimX, m_dimY, m_spacing); // If indicated, set node heights from checkpoint file if (m_use_checkpoint) { // Open input file stream std::string checkpoint_filename = m_node_out_dir + "/" + m_checkpoint_filename; std::ifstream ifile(checkpoint_filename); if (!ifile.is_open()) { cout << "ERROR: could not open checkpoint file " << checkpoint_filename << endl; MPI_Abort(MPI_COMM_WORLD, 1); } std::string line; // Read and discard line with current time std::getline(ifile, line); // Read number of modified nodes int num_nodes; std::getline(ifile, line); std::istringstream iss(line); iss >> num_nodes; std::vector<SCMTerrain::NodeLevel> nodes(num_nodes); for (int i = 0; i < num_nodes; i++) { std::getline(ifile, line); std::istringstream iss1(line); int x, y; double h; iss1 >> x >> y >> h; nodes[i] = std::make_pair(ChVector2<>(x, y), h); } m_terrain->SetModifiedNodes(nodes); if (m_verbose) cout << "[Terrain node] read " << checkpoint_filename << " num. nodes = " << num_nodes << endl; } // Add all rigid obstacles for (auto& b : m_obstacles) { auto mat = b.m_contact_mat.CreateMaterial(m_system->GetContactMethod()); auto trimesh = geometry::ChTriangleMeshConnected::CreateFromWavefrontFile(GetChronoDataFile(b.m_mesh_filename), true, true); double mass; ChVector<> baricenter; ChMatrix33<> inertia; trimesh->ComputeMassProperties(true, mass, baricenter, inertia); auto body = std::shared_ptr<ChBody>(m_system->NewBody()); body->SetPos(b.m_init_pos); body->SetRot(b.m_init_rot); body->SetMass(mass * b.m_density); body->SetInertia(inertia * b.m_density); body->SetBodyFixed(false); body->SetCollide(true); body->GetCollisionModel()->ClearModel(); body->GetCollisionModel()->AddTriangleMesh(mat, trimesh, false, false, ChVector<>(0), ChMatrix33<>(1), m_radius_p); body->GetCollisionModel()->SetFamily(2); body->GetCollisionModel()->BuildModel(); auto trimesh_shape = chrono_types::make_shared<ChTriangleMeshShape>(); trimesh_shape->SetMesh(trimesh); body->AddVisualShape(trimesh_shape, ChFrame<>()); // Add corresponding moving patch to SCM terrain m_terrain->AddMovingPatch(body, b.m_oobb_center, b.m_oobb_dims); m_system->AddBody(body); } // Write file with terrain node settings std::ofstream outf; outf.open(m_node_out_dir + "/settings.info", std::ios::out); outf << "System settings" << endl; outf << " Integration step size = " << m_step_size << endl; outf << "Patch dimensions" << endl; outf << " X = " << m_dimX << " Y = " << m_dimY << endl; outf << " spacing = " << m_spacing << endl; outf << "Terrain material properties" << endl; outf << " Kphi = " << m_Bekker_Kphi << endl; outf << " Kc = " << m_Bekker_Kc << endl; outf << " n = " << m_Bekker_n << endl; outf << " c = " << m_Mohr_cohesion << endl; outf << " mu = " << m_Mohr_friction << endl; outf << " J = " << m_Janosi_shear << endl; outf << " Ke = " << m_elastic_K << endl; outf << " Rd = " << m_damping_R << endl; } // Create bodies with triangular contact geometry as proxies for the mesh faces. // Used for flexible bodies. // Assign to each body an identifier equal to the index of its corresponding mesh face. // Maintain a list of all bodies associated with the object. // Add all proxy bodies to the same collision family and disable collision between any // two members of this family. void ChVehicleCosimTerrainNodeSCM::CreateMeshProxy(unsigned int i) { //// TODO } void ChVehicleCosimTerrainNodeSCM::CreateRigidProxy(unsigned int i) { // Get shape associated with the given object int i_shape = m_obj_map[i]; // Create wheel proxy body auto body = std::shared_ptr<ChBody>(m_system->NewBody()); body->SetIdentifier(0); body->SetMass(m_load_mass[i_shape]); ////body->SetInertiaXX(); //// TODO body->SetBodyFixed(false); // Cannot fix the proxies with SCM body->SetCollide(true); // Create visualization asset (use collision shapes) m_geometry[i_shape].CreateVisualizationAssets(body, VisualizationType::PRIMITIVES, true); // Create collision shapes for (auto& mesh : m_geometry[i_shape].m_coll_meshes) mesh.m_radius = m_radius_p; m_geometry[i_shape].CreateCollisionShapes(body, 1, m_method); body->GetCollisionModel()->SetFamily(1); body->GetCollisionModel()->SetFamilyMaskNoCollisionWithFamily(1); m_system->AddBody(body); m_proxies[i].push_back(ProxyBody(body, 0)); // Add corresponding moving patch to SCM terrain //// RADU TODO: this may be overkill for tracked vehicles! m_terrain->AddMovingPatch(body, m_aabb[i_shape].m_center, m_aabb[i_shape].m_dims); } // Once all proxy bodies are created, complete construction of the underlying system. void ChVehicleCosimTerrainNodeSCM::OnInitialize(unsigned int num_objects) { ChVehicleCosimTerrainNodeChrono::OnInitialize(num_objects); // Create the visualization window if (m_renderRT) { #if defined(CHRONO_VSG) auto vsys_vsg = chrono_types::make_shared<vsg3d::ChVisualSystemVSG>(); vsys_vsg->AttachSystem(m_system); vsys_vsg->SetWindowTitle("Terrain Node (SCM)"); vsys_vsg->SetWindowSize(ChVector2<int>(1280, 720)); vsys_vsg->SetWindowPosition(ChVector2<int>(100, 100)); vsys_vsg->SetUseSkyBox(true); vsys_vsg->AddCamera(m_cam_pos, ChVector<>(0, 0, 0)); vsys_vsg->SetCameraAngleDeg(40); vsys_vsg->SetLightIntensity(1.0f); vsys_vsg->AddGuiColorbar("Sinkage (m)", 0.0, 0.1); vsys_vsg->Initialize(); m_vsys = vsys_vsg; #elif defined(CHRONO_IRRLICHT) auto vsys_irr = chrono_types::make_shared<irrlicht::ChVisualSystemIrrlicht>(); vsys_irr->AttachSystem(m_system); vsys_irr->SetWindowTitle("Terrain Node (SCM)"); vsys_irr->SetCameraVertical(CameraVerticalDir::Z); vsys_irr->SetWindowSize(1280, 720); vsys_irr->Initialize(); vsys_irr->AddLogo(); vsys_irr->AddSkyBox(); vsys_irr->AddTypicalLights(); vsys_irr->AddCamera(m_cam_pos, ChVector<>(0, 0, 0)); m_vsys = vsys_irr; #endif } } // Set position, orientation, and velocity of proxy bodies based on mesh faces. void ChVehicleCosimTerrainNodeSCM::UpdateMeshProxy(unsigned int i, MeshState& mesh_state) { //// TODO } // Set state of proxy rigid body. void ChVehicleCosimTerrainNodeSCM::UpdateRigidProxy(unsigned int i, BodyState& rigid_state) { auto& proxies = m_proxies[i]; // proxies for the i-th rigid proxies[0].m_body->SetPos(rigid_state.pos); proxies[0].m_body->SetPos_dt(rigid_state.lin_vel); proxies[0].m_body->SetRot(rigid_state.rot); proxies[0].m_body->SetWvel_par(rigid_state.ang_vel); } // Collect contact forces on the (face) proxy bodies that are in contact. // Load mesh vertex forces and corresponding indices. void ChVehicleCosimTerrainNodeSCM::GetForceMeshProxy(unsigned int i, MeshContact& mesh_contact) { //// TODO } // Collect resultant contact force and torque on rigid proxy body. void ChVehicleCosimTerrainNodeSCM::GetForceRigidProxy(unsigned int i, TerrainForce& rigid_contact) { const auto& proxies = m_proxies[i]; // proxies for the i-th rigid rigid_contact = m_terrain->GetContactForce(proxies[0].m_body); } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::OnRender() { if (!m_vsys) return; if (!m_vsys->Run()) MPI_Abort(MPI_COMM_WORLD, 1); if (m_track) { const auto& proxies = m_proxies[0]; // proxies for first object ChVector<> cam_point = proxies[0].m_body->GetPos(); m_vsys->UpdateCamera(m_cam_pos, cam_point); } m_vsys->BeginScene(); m_vsys->Render(); m_vsys->EndScene(); } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::OnOutputData(int frame) { //// TODO } // ----------------------------------------------------------------------------- void ChVehicleCosimTerrainNodeSCM::WriteCheckpoint(const std::string& filename) const { utils::CSV_writer csv(" "); // Get all SCM grid nodes modified from start of simulation const auto& nodes = m_terrain->GetModifiedNodes(true); // Write current time and total number of modified grid nodes. csv << m_system->GetChTime() << endl; csv << nodes.size() << endl; // Write node locations and heights for (const auto& node : nodes) { csv << node.first.x() << node.first.y() << node.second << endl; } std::string checkpoint_filename = m_node_out_dir + "/" + filename; csv.write_to_file(checkpoint_filename); if (m_verbose) cout << "[Terrain node] write checkpoint ===> " << checkpoint_filename << endl; } } // end namespace vehicle } // end namespace chrono
[ "serban@wisc.edu" ]
serban@wisc.edu
e3b1a27d67e621f8ee6951038f95d5a57c408e16
76fe0a0404ca1d71779fc6c1122b87e0d7a7aa1b
/Treinos equipe/xv de piracikobus/2018/10-26 2017 X Samara/h.cpp
eedda1e77f17931dd15d2b513306f0f900131b8c
[]
no_license
vitorguidi/Competitive-Programming
905dd835671275284418c5885a4a1fae2160f451
823a9299dce7b7f662ea741f31b4687f854bb963
refs/heads/master
2021-06-25T06:58:53.670233
2020-12-19T16:53:15
2020-12-19T16:53:15
133,260,248
3
0
null
2018-05-13T17:46:43
2018-05-13T17:40:24
null
UTF-8
C++
false
false
1,900
cpp
#include "bits/stdc++.h" using namespace std; #define pb push_back #define mp make_pair #define fst first #define snd second #define fr(i,n) for(int i=0;i<n;i++) #define frr(i,n) for(int i=1;i<=n;i++) #define ms(x,i) memset(x,i,sizeof(x)) #define dbg(x) cout << #x << " = " << x << endl #define all(x) x.begin(),x.end() #define gnl cout << endl #define olar cout << "olar" << endl #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) typedef long long int ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef pair<ll,ll> pll; const int INF = 0x3f3f3f3f; const ll llINF = 0x3f3f3f3f3f3f3f; const int MOD = 1e9+7; int main(){ fastio; int n,m; cin >> n >> m; int grid[1010][1010]; vi out; int x,y; int mx = -INF; fr(i,n){ fr(j,m){ cin >> grid[i][j]; if(grid[i][j]>mx){ mx=grid[i][j]; x=i; y=j; } } } //fixa linha x pra tirar e acha a melhor coluna int ans1 = -INF; int idc; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(i==x) continue; if(grid[i][j]>ans1){ ans1=grid[i][j]; idc=j; } } } ans1=-INF; //fixada a linha (x) e escolhida a coluna (idc), pego o max q n ta la for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(i==x || j == idc) continue; ans1=max(ans1,grid[i][j]); } } out.pb(ans1); int idl; ans1=-INF; //exclui coluna y e tenta achar a melhor linha pra excluir for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j==y) continue; if(grid[i][j]>ans1){ ans1=grid[i][j]; idl=i; } } } //acha maior cara excluindo linha idl e coluna y ans1=-INF; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j==y || i==idl) continue; ans1=max(ans1,grid[i][j]); } } out.pb(ans1); x++;y++;idl++;idc++; if(out[0]<=out[1]) cout << x << " " << idc << endl; else cout << idl << " " << y << endl; }
[ "vitorguidi@gmail.com" ]
vitorguidi@gmail.com
05abe423e121cf25f5c743a9703a7d0adba5c41c
3bbad6f1f610ad8cc4edec00aae854f27e9abf73
/cpp/扩展欧几里得算法/扩展欧几里得算法/main.cpp
3b59ef57402de92dfa2b8ede859c9957e36eaffd
[]
no_license
torresng/Algorithms_practice
c765e6e60c4e2a84486a1a88fb6d42503629876a
dae0eaa1dd0663fb428a0002dc5fa8528ff4204f
refs/heads/master
2021-08-07T08:57:16.690536
2020-04-15T06:24:12
2020-04-15T06:24:12
152,349,445
0
0
null
null
null
null
UTF-8
C++
false
false
422
cpp
#include <iostream> using namespace std; int exgcd(int a, int b, int &x, int &y) { if (!b) { x = 1, y = 0; return a; } int d = exgcd(b, a % b, y, x); y -= a / b * x; return d; } int main() { int n; scanf("%d", &n); while (n--) { int a, b, x, y; scanf("%d%d", &a, &b); exgcd(a, b, x, y); printf("%d %d\n", x, y); } return 0; }
[ "torresng2684cte@gmail.com" ]
torresng2684cte@gmail.com
2d770f576753e2f5480f4c2f3fc9d984f995238e
52e74962932b8f41d56c8228269183623d51693d
/Count Univalue Subtrees.cpp
8545c0e00186ba3ee1a79d1e1a79665ba3be09b1
[]
no_license
huston66/Leetcode
be63bab22216c62a69281e6955d214e017099241
9d807a2de1257a8a7fe9001db73bba76adeecbbf
refs/heads/master
2021-01-18T23:52:48.242920
2016-10-17T09:06:24
2016-10-17T09:06:24
50,390,668
0
0
null
null
null
null
UTF-8
C++
false
false
623
cpp
class Solution { public: int countUnivalSubtrees(TreeNode* root) { int count=0; dfs(root,count); return count; } bool dfs(TreeNode* root,int &count){ if(root==NULL) return 1; bool left=dfs(root->left,count); bool right=dfs(root->right,count); if((left&&right)&&(root->left==NULL||root->left->val==root->val) &&(root->right==NULL||root->right->val==root->val)) { count++; return 1; } return 0; } };
[ "zhenli@Zhens-MacBook-Pro.local" ]
zhenli@Zhens-MacBook-Pro.local
d738b7df9aeea6d2243526f948c614223cced24b
6f6bbab251671ddcdac118b6e730aaecda463e9e
/polynomial_plus.cpp
033259c674b96d50b938967ce71964d8ec6ebba2
[]
no_license
jc3939/Coursera-PKU-Data-Structures
192696c786c171045001bbb35745b80cd47c90d5
12304715c7fcee82b92a885852a48d6ca060f5f5
refs/heads/master
2021-01-21T13:56:43.504598
2016-05-14T23:54:14
2016-05-14T23:54:14
45,805,699
0
0
null
null
null
null
UTF-8
C++
false
false
5,814
cpp
#include <iostream> #include <fstream> #include <string> #include <sstream> using namespace std; template<typename T> class Node{ public: T indx; T coeff; Node<T> * next; Node(T _indx, T _coeff, Node<T> * nextValue=NULL){ //cout<<"construct index"<<_indx<<endl; indx = _indx; coeff = _coeff; next = nextValue; } }; template<typename T> class linkedList{ public: Node<T> *_pHead; Node<T> *_pTail; int len; linkedList(T heaIndx, T heaCoeff); //Constructors ~linkedList(); void clear(); bool isEmpty(); int length(); bool insert( int i, T Indx, T Coeff); bool Sort(); bool RemoveDup(); bool append(T indx, T coeff); Node<T> *setPos(int p); }; template<typename T> linkedList<T>::linkedList(T heaIndx, T heaCoeff){ _pHead = new Node<T>(heaIndx, heaCoeff); _pHead->next = _pTail; len=0; } template<typename T> bool linkedList<T>::isEmpty(){ if (len == 0) { return true; } else return false; } template<typename T> int linkedList<T>::length(){ return len; } template<typename T> bool linkedList<T>::append(T indx, T coeff){ Node<T> *p = new Node<T>(indx, coeff); //cout<<"append index"<<p->indx<<endl; _pTail = p; int i = 0; Node<T> *pfinder = _pHead; while(i<len){ pfinder=pfinder->next; i++; } pfinder->next = p; len++; return true; } //Sort linked list by indx in descending order. template<typename T> bool linkedList<T>::Sort(){ Node<T> *p = _pHead->next; Node<T> *q; if (p == NULL){ cout<<"Cannot sort an empty List!!!"<<endl; return false; } int tempIndex=0; int tempCoeff = 0; while(p!=NULL){ q = p->next; while(q!=NULL){ if(q->indx>p->indx){ //Swap indx and coeff values tempIndex = q->indx; q->indx = p->indx; p->indx = tempIndex; tempCoeff = q->coeff; q->coeff = p->coeff; p->coeff=tempCoeff; } q = q->next; } p=p->next; } return true; } template<typename T> bool linkedList<T>::RemoveDup(){ Node<T> *p = _pHead->next; if(p==NULL){ cout<<"Cannot operate an empty List!!!"<<endl; return false; } Node<T> *q = p->next; while(p!=NULL && q!=NULL){ while(p->indx==q->indx){ p->coeff+=q->coeff; q = q->next; if(q==NULL){ p->next=NULL; return true; } if(p->indx!=q->indx){ p->next = q; break; } } p = p->next; if(p==NULL) return true; q = p->next; } return true; } int main(){ ifstream infile("/Users/jianjun_chen/Documents/Coursera-PKU-Data-Structures/input.txt"); int coeff, indx; int n; string line; getline(infile, line); stringstream linestream(line); linestream>>n; cout<<n<<"&&&&"<<endl; while(n!=0){ //construct new linked list array1 and array2 with //-1 as header and -2 as tail. linkedList<int> *array1 = new linkedList<int>(-1, 0); linkedList<int> *array2 = new linkedList<int>(-1, 0); getline(infile, line); stringstream linestream1(line); //cout<<line<<endl; //linestream>>coeff>>indx; while(linestream1>>coeff>>indx){ cout<<coeff<<" "<<indx<<endl; if(indx<0){ break;//as each line will end with an negative index } array1->append(indx, coeff); } getline(infile, line); stringstream linestream2(line); while(linestream2>>coeff>>indx){ if(indx<0){ break; } array2->append(indx, coeff); } //sort each linked list large to small by their index. array1->Sort(); array2->Sort(); //merge nodes with same index. array1->RemoveDup(); array2->RemoveDup(); //Start from the first node of linked lists. Node<int> *p1 = array1->_pHead->next; Node<int> *p2 = array2->_pHead->next; Node<int> *p1a = array1->_pHead;//p1a to store previous node of p1 Node<int> *p1r; Node<int> *p2r; while(p1!=NULL || p2!=NULL){ //p1r and p2r store next node of p1, p2. if(p1==NULL){ p1a->next=p2; //cout<<"Now p1a->next->indx is "<<p1a->next->indx<<endl; break; } else if(p2==NULL){ break; } p1r = p1->next; p2r = p2->next; if(p1->indx==p2->indx){ //if p1 has same index with p2, then p1.index+p2.index //delete p2. p1->coeff+=p2->coeff; p1a = p1; p1 = p1r; p2 = p2r; }else if(p1->indx < p2->indx){ //if p1.index>p2.index, then insert p2 into //p1 and p1.next(p1r) p1a->next = p2; p2->next = p1; p1a = p2; p2 = p2r; }else{ //if p1.index<p2.index, then insert p2 into //p1 and p1's previous node. p1a = p1; p1 = p1->next; } } p1 = array1->_pHead->next; while(p1!=NULL){ //cout<<p1->coeff<<" "<<p1->indx<<endl; if(p1->coeff!=0){ cout << "[ "<<p1->coeff<<" "<<p1->indx<<" ] "; } p1 = p1->next; } cout << endl; n--; } }
[ "jianjun_chen@Jianjun-Chens-MacBook-Pro.local" ]
jianjun_chen@Jianjun-Chens-MacBook-Pro.local
87be81184c9e1ce8364f8b7da2df8c8dd0811783
7dd45eec6918a7c63e8ae87a5f22f8be7f313356
/numeric_simple.cpp
436d6a700cdf067eb16f74e9289f877c96452c93
[]
no_license
yazevnul/yzw2v
f89188d62416bb24ac6833c6dab7b961767f7b48
cc52fa5d0108d255c9b41bb1a282790dcdfeeb60
refs/heads/master
2021-01-21T12:59:09.972976
2016-04-19T15:53:08
2016-04-19T15:53:08
54,340,419
1
0
null
null
null
null
UTF-8
C++
false
false
1,456
cpp
#include "numeric.h" void yzw2v::num::Prefetch(const float* v) noexcept { (void)v; } void yzw2v::num::Fill(float* v, const uint32_t v_size, const float value) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] = value; } } void yzw2v::num::Zeroize(float* v, const uint32_t v_size) noexcept { Fill(v, v_size, 0.0f); } void yzw2v::num::DivideVector(float* v, const uint32_t v_size, const float divisor) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] /= divisor; } } void yzw2v::num::MultiplyVector(float* v, const uint32_t v_size, const float multiple) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] *= multiple; } } void yzw2v::num::AddVector(float* v, const uint32_t v_size, const float* const summand) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] += summand[i]; } } void yzw2v::num::AddVector(float* v, const uint32_t v_size, const float* const summand, const float summand_multiple) noexcept { for (auto i = uint32_t{}; i < v_size; ++i) { v[i] += summand_multiple * summand[i]; } } float yzw2v::num::ScalarProduct(const float* lhs, const uint32_t lhs_size, const float* rhs) noexcept { auto res = float{}; for (auto i = uint32_t{}; i < lhs_size; ++i) { res += lhs[i] * rhs[i]; } return res; }
[ "kostyabazhanov@mail.ru" ]
kostyabazhanov@mail.ru
e5ffa7dfed0312035fc9dd42a983b72834e88f12
9177984cb1cd5843df94a93846367db5dd45daf0
/src/cs/geolib/csTimeStretch.cc
f3b77bc2fc8a58eb241889f46cce7bf58aed1ba2
[]
no_license
fccoguz/OpenSeaSeis
001f8a9d4258ce033ad5e2fa27f719c1f6a5d0a8
eb09a7ed115eaff4b055df25a60e975650635cda
refs/heads/master
2023-03-18T20:11:24.133298
2020-02-18T15:20:58
2020-02-18T15:20:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,380
cc
/* Copyright (c) Colorado School of Mines, 2013.*/ /* All rights reserved. */ #include <cmath> #include <cstring> #include "csTimeStretch.h" #include "csInterpolation.h" #include "geolib_methods.h" #include "csException.h" #include <iostream> #include <cstdio> #include <cstdlib> using namespace cseis_geolib; csTimeStretch::csTimeStretch( double sampleInt_ms, int numSamples ) { init( sampleInt_ms, numSamples, csTimeStretch::SAMPLE_INTERPOL_SINC ); } csTimeStretch::csTimeStretch( double sampleInt_ms, int numSamples, int methodSampleInterpolation ) { init( sampleInt_ms, numSamples, methodSampleInterpolation ); } void csTimeStretch::init( double sampleInt_ms, int numSamples, int methodSampleInterpolation ) { myIsBottomStretch = false; myLayerInterpolationMethod = csTimeStretch::LAYER_INTERPOL_LIN; mySampleInt = sampleInt_ms; myNumSamples = numSamples; myTimeOfLastSample = (myNumSamples-1)*mySampleInt; mySampleInterpolationMethod = methodSampleInterpolation; myIndexBufferOut = NULL; myTimeDepthFunc = NULL; myInterpol_timeDepthConversion = NULL; if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_SINC ) { mySampleInterpolation = new csInterpolation( numSamples, (float)sampleInt_ms ); } else { mySampleInterpolation = NULL; } } csTimeStretch::~csTimeStretch() { if( mySampleInterpolation != NULL ) { delete mySampleInterpolation; mySampleInterpolation = NULL; } if( myIndexBufferOut != NULL ) { delete [] myIndexBufferOut; myIndexBufferOut = NULL; } if( myTimeDepthFunc != NULL ) { delete [] myTimeDepthFunc; myTimeDepthFunc = NULL; } if( myInterpol_timeDepthConversion != NULL ) { delete myInterpol_timeDepthConversion; myInterpol_timeDepthConversion = NULL; } } void csTimeStretch::setLayerInterpolationMethod( int method ) { myLayerInterpolationMethod = method; } //-------------------------------------------------------------------- // // void csTimeStretch::applyStretchFunction( float const* samplesIn, float const* tIn_ms, float const* stretch_ms, int numTimes, float* samplesOut ) { int numLayers = numTimes - 1; float* tOut_ms = new float[numTimes]; tOut_ms[0] = tIn_ms[0]; double stretchSumDbl = 0.0; for( int ilay = 0; ilay < numLayers; ilay++ ) { stretchSumDbl += (double)stretch_ms[ilay]; tOut_ms[ilay+1] = tIn_ms[ilay+1] + (float)stretchSumDbl; } // for( int ilay = 0; ilay < numLayers+1; ilay++ ) { // fprintf(stderr,"STRETCH %.4f %.4f\n", tIn_ms[ilay], tOut_ms[ilay]); // } applyTimeInterval( samplesIn, tIn_ms, tOut_ms, numTimes, samplesOut ); delete [] tOut_ms; } void csTimeStretch::applyTimeInterval( float const* samplesIn, float const* tIn, float const* tOut, int numTimes, float* samplesOut ) { int numLayers = numTimes - 1; int ilay = 0; // Traces always start at time = 0.0. First layer to stretch may start further down. If that is the case, don't stretch the top, just copy. float tTopIn = 0.0; float tTopOut = 0.0; float tBotIn = tIn[ilay]; float tBotOut = tOut[ilay]; float dtIn = tBotIn - tTopIn; // Input layer thickness in [ms] float dtOut = tBotOut - tTopOut; // Output layer thickness in [ms] float timeLast = (float)((myNumSamples-1) * mySampleInt); // fprintf(stdout,"TIMEIO START %f %f %f %f %d\n", tBotIn, tBotOut,dtIn,dtOut,ilay); for( int isamp = 0; isamp < myNumSamples; isamp++ ) { float timeOut = (float)(isamp * mySampleInt); float timeIn = timeOut; while( ilay <= numLayers && timeOut > tBotOut ) { ilay += 1; tTopIn = tBotIn; tTopOut = tBotOut; if( ilay <= numLayers ) { tBotIn = tIn[ilay]; tBotOut = tOut[ilay]; dtIn = tBotIn - tTopIn; // Input layer thickness in [ms] dtOut = tBotOut - tTopOut; // Output layer thickness in [ms] } else { // For bottom of data beyond bottom of last layer: Make stretch ratio = dtIN/dtOut = 1.0 = no stretching, just static shift if( !myIsBottomStretch ) { dtOut = dtIn; } // ..otherwise, keep stretch factor from last specified layer } } if( dtOut != 0.0 ) { timeIn = tTopIn + (dtIn/dtOut) * ( timeOut - tTopOut ); if( timeIn < 0.0 ) timeIn = 0.0; else if( timeIn > timeLast ) timeIn = timeLast; } // fprintf(stdout,"TIMEIO %f %f %f %f %d %f %f\n", timeIn, timeOut,dtIn,dtOut,ilay,tBotIn,tBotOut); if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_SINC ) { samplesOut[isamp] = mySampleInterpolation->valueAt( timeIn, samplesIn ); } else if( mySampleInterpolationMethod == csTimeStretch::SAMPLE_INTERPOL_QUAD ) { samplesOut[isamp] = getQuadAmplitudeAtSample( samplesIn, timeIn/mySampleInt, myNumSamples ); } else { samplesOut[isamp] = getLinAmplitudeAtSample( samplesIn, timeIn/mySampleInt, myNumSamples ); } } } //void csTimeStretch::applyDepthTimeConversion( float* samplesInOut, float const* velFunc, float sampleInt_velFunc_m, int numSamp_velFunc, float sampleInt_out ) { void csTimeStretch::initialize_timeDepthConversion( int numSamplesOut, float sampleIntOut ) { if( myIndexBufferOut != NULL ) { delete [] myIndexBufferOut; } if( myTimeDepthFunc != NULL ) { delete [] myTimeDepthFunc; } myNumSamplesOut = numSamplesOut; mySampleIntOut = sampleIntOut; myIndexBufferOut = new float[myNumSamplesOut]; myTimeDepthFunc = new float[myNumSamplesOut]; if( myInterpol_timeDepthConversion != NULL ) { delete myInterpol_timeDepthConversion; } myInterpol_timeDepthConversion = new csInterpolation( myNumSamples, csInterpolation::METHOD_SINC, mySampleInt ); } void csTimeStretch::apply_timeDepthConversion( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut, bool isTime2Depth ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::apply_timeDepthConversion(%d):: Function not initialized. This is a bug in the calling function", isTime2Depth) ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); if( isTime2Depth ) { for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { float time = interpol.valueAt( isampOut*mySampleIntOut, depthTimeFunc ); myIndexBufferOut[isampOut] = time/mySampleInt; } } else { interpol.timeAt_lin( depthTimeFunc, mySampleIntOut, myNumSamplesOut, myTimeDepthFunc ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { myIndexBufferOut[isampOut] = myTimeDepthFunc[isampOut]/mySampleInt; } } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } /* void csTimeStretch::convert_depth2time( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::convert_depth2time:: Function not initialized. This is a bug in the calling function") ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol_timeDepth( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); interpol_timeDepth.timeAt_lin( depthTimeFunc, mySampleIntOut, myNumSamplesOut, myTimeDepthFunc ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { myIndexBufferOut[isampOut] = myTimeDepthFunc[isampOut]/mySampleInt; } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } void csTimeStretch::convert_time2depth( float const* samplesIn, float const* velFunc, float sampleIntVel_m, int numSamplesVel, float* samplesOut ) { if( myIndexBufferOut == NULL ) { throw( csException("csTimeStretch::convert_time2depth:: Function not initialized. This is a bug in the calling function") ); } float* depthTimeFunc = new float[numSamplesVel]; // 1) Compute time-depth function from velocity-depth function depthTimeFunc[0] = 0; for( int isamp = 1; isamp < numSamplesVel; isamp++ ) { depthTimeFunc[isamp] = depthTimeFunc[isamp-1] + 2.0 * 1000.0 * sampleIntVel_m / velFunc[isamp-1]; // 2x for TWT } csInterpolation interpol_depthTime( numSamplesVel, csInterpolation::METHOD_LIN, sampleIntVel_m ); for( int isampOut = 0; isampOut < myNumSamplesOut; isampOut++ ) { float time = interpol_depthTime.valueAt( isampOut*mySampleIntOut, depthTimeFunc ); myIndexBufferOut[isampOut] = time/mySampleInt; } myInterpol_timeDepthConversion->process( 1.0, 0.0, samplesIn, myIndexBufferOut, samplesOut, myNumSamplesOut ); delete [] depthTimeFunc; } */
[ "john.19071969@gmail.com" ]
john.19071969@gmail.com
9254d769384a8ea2417fbb2a7db4ce39bed55ed9
fbbef987934e34d3163864008bd6e32008532662
/TechDeMMO/GameObjectFactory.cpp
c582784770b3f045532568314d7953f6c28ce927
[]
no_license
Lugswo/TechDeMMO
bb07f9dc02526b75f971032a283844a679a5cda2
2d50b6355d5fa4abb7876523f990a0ad7c555201
refs/heads/master
2020-06-01T00:23:29.565161
2019-09-05T19:23:16
2019-09-05T19:23:16
190,555,665
0
0
null
null
null
null
UTF-8
C++
false
false
2,152
cpp
#include "GameObjectFactory.h" #include "TraceLog.h" #include "TransformComponent.h" #include "SpriteComponent.h" #include "PlayerComponent.h" #include "RandomEngine.h" std::map<unsigned, GameObject *> GameObjectFactory::archetypeList, GameObjectFactory::objectList, GameObjectFactory::playerList; unsigned GameObjectFactory::id; GameObjectFactory::~GameObjectFactory() { for (auto itr = objectList.begin(); itr != objectList.end(); ++itr) { delete (*itr).second; } for (auto itr = archetypeList.begin(); itr != archetypeList.end(); ++itr) { delete (*itr).second; } } void GameObjectFactory::Init() { id = 0; } void GameObjectFactory::Update(float dt) { for (auto itr = objectList.begin(); itr != objectList.end(); ++itr) { (*itr).second->Update(dt); } } void GameObjectFactory::CreatePlayer(bool t, glm::vec2 pos, unsigned i) { GameObject *obj = new GameObject(); TransformComponent *trans = new TransformComponent(); SpriteComponent *sprite = new SpriteComponent("ArtAssets/bub.png"); PlayerComponent *player = new PlayerComponent(t, pos); obj->AddComponent(trans); obj->AddComponent(sprite); obj->AddComponent(player); glm::vec3 a = trans->GetTranslation(); a.x = pos.x; a.y = pos.y; trans->SetTranslation(a); AddPlayer(obj, i); } void GameObjectFactory::DeletePlayer(unsigned i) { GameObject *temp = playerList[i]; if (temp) { objectList.erase(temp->GetID()); playerList.erase(i); } delete temp; } GameObject * GameObjectFactory::GetPlayer(unsigned i) { auto it = playerList.find(i); if (it == playerList.end()) { TraceLog::Log(TRACE_LEVEL::ERR, "Cannot find player with given id " + std::to_string(i) + "!"); return nullptr; } return playerList[i]; } void GameObjectFactory::AddObject(GameObject *obj) { ++id; obj->SetID(id); objectList.insert(std::pair<unsigned, GameObject*>(id, obj)); obj->Init(); } void GameObjectFactory::AddPlayer(GameObject *obj, unsigned i) { AddObject(obj); playerList.insert(std::pair<unsigned, GameObject *>(i, obj)); } void GameObjectFactory::RemoveObject(unsigned i) { objectList.erase(i); }
[ "spencer.park@digipen.edu" ]
spencer.park@digipen.edu
d2ee9c42388a25df746ce19290d8aff732da086f
7f86aa1f4533a3845dbb7379f4b4d24ac9ed8496
/src/LocalFit.cpp
b43016b9c0d66d63e064d697b8b95d475083a645
[]
no_license
wagenadl/salpa
33cd5e89556bc0913add37e7718cba6822cbba6a
2d9195b21f321fd0913fd3794fee4f59e0ed1ca4
refs/heads/master
2023-03-02T07:17:06.713341
2023-02-28T18:04:14
2023-02-28T18:04:14
271,944,219
1
0
null
null
null
null
UTF-8
C++
false
false
9,964
cpp
/* artifilt/LocalFit.C: part of meabench, an MEA recording and analysis tool ** Copyright (C) 2000-2003 Daniel Wagenaar (wagenaar@caltech.edu) ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // LocalFit.C #include "LocalFit.h" #include <iostream> #include <cmath> #include <cstdlib> //-------------------------------------------------------------------- // inline functions // inline void LocalFit::update_X012() { int_t y_new = source[t_stream+tau]; int_t y_old = source[t_stream-tau-1]; X0 += y_new - y_old; X1 += tau_plus_1*y_new - minus_tau*y_old - X0; X2 += tau_plus_1_squared*y_new - minus_tau_squared*y_old - X0 - 2*X1; } inline void LocalFit::calc_alpha0() { alpha0 = real_t(T4*X0 - T2*X2) / real_t(T0*T4-T2*T2); } //-------------------------------------------------------------------- // Other LocalFit methods // LocalFit::LocalFit(CyclBuf<raw_t> const &source0, CyclBuf<raw_t> &dest0, timeref_t t_start, raw_t threshold0, timeref_t tau0, timeref_t t_blankdepeg0, timeref_t t_ahead0, timeref_t t_chi20): source(source0), dest(dest0), y_threshold(threshold0), tau(tau0), t_blankdepeg(t_blankdepeg0), t_ahead(t_ahead0), t_chi2(t_chi20) { usenegv = true; state = State::PEGGED; // t_peg = t_start; t_stream = t_start; init_T(); rail1=RAIL1; rail2=RAIL2; debug_name = -1; } void LocalFit::setusenegv(bool t) { usenegv = t; } void LocalFit::reset(timeref_t t_start) { // t_peg = t_start; t_stream = t_start; state = State::PEGGED; } void LocalFit::init_T() { my_thresh = 3.92 * t_chi2 * y_threshold*y_threshold; // 95% conf limit tau_plus_1 = tau+1; tau_plus_1_squared = tau_plus_1 * tau_plus_1; tau_plus_1_cubed = tau_plus_1_squared * tau_plus_1; minus_tau = -tau; minus_tau_squared = minus_tau * minus_tau; minus_tau_cubed = minus_tau_squared * minus_tau; T0=T2=T4=T6=0; for (int t=-tau; t<=tau; t++) { int_t t2=t*t; int_t t4=t2*t2; int_t t6=t4*t2; T0+=1; T2+=t2; T4+=t4; T6+=t6; } } timeref_t LocalFit::process(timeref_t t_limit) { state=statemachine(t_limit, state); return t_stream; } timeref_t LocalFit::forcepeg(timeref_t t_from, timeref_t t_to) { state = statemachine(t_from - tau, state); if (state==State::OK) { // goto state PEGGING t0 = t_stream - 1; calc_X3(); calc_alpha0123(); state = statemachine(t_from, State::PEGGING); } t0 = t_to; state = statemachine(t_to, State::FORCEPEG); return t_stream; } LocalFit::State LocalFit::statemachine(timeref_t t_limit, State s) { /* This is a straightforward implementation of the statemachine I described on 9/9/01. * //// mark boundaries program flow does not pass through. * On exit, t_stream == t_limit. */ // timeref_t t_check=0; //DBG switch (s) { case State::OK: goto l_OK; case State::PEGGED: goto l_PEGGED; case State::PEGGING: goto l_PEGGING; case State::TOOPOOR: goto l_TOOPOOR; case State::DEPEGGING: goto l_DEPEGGING; case State::FORCEPEG: goto l_FORCEPEG; case State::BLANKDEPEG: goto l_BLANKDEPEG; default: crash("Bad State"); } ////////////////////////////////////////////////// l_PEGGED: { if (t_stream>=t_limit) return State::PEGGED; if (ispegged(source[t_stream])) { dest[t_stream]=0; t_stream++; goto l_PEGGED; } for (int dt=1; dt<=2*tau; dt++) if (ispegged(source[t_stream+dt])) { t0 = t_stream+dt; goto l_FORCEPEG; } t0 = t_stream + tau; calc_X012(); calc_X3(); calc_alpha0123(); toopoorcnt=TOOPOORCNT; goto l_TOOPOOR; } crash("Code breach"); ////////////////////////////////////////////////// l_TOOPOOR: { if (t_stream>=t_limit) return State::TOOPOOR; real_t asym=0; real_t sig=0; for (int i=0; i<t_chi2; i++) { int t_i = t_stream+i; int dt = t_i - t0; int dt2=dt*dt; int dt3=dt*dt2; real_t dy = alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3 - source[t_i]; asym += dy; sig += dy*dy; } asym *= asym; if (asym<my_thresh) toopoorcnt--; else toopoorcnt = TOOPOORCNT; if (toopoorcnt<=0 && asym < my_thresh/3.92) { if (usenegv) { int dt = t_stream - t0; int dt2=dt*dt; int dt3=dt*dt2; negv = source[t_stream] < raw_t(alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3); } calc_X012(); calc_X3(); // for numerical stability problem! goto l_BLANKDEPEG; } dest[t_stream] = 0; t_stream++; t0++; if (ispegged(source[t0+tau])) { t0=t0+tau; goto l_FORCEPEG; } update_X0123(); calc_X012(); calc_X3(); // for numerical stability problem! calc_alpha0123(); goto l_TOOPOOR; } crash("Code breach"); ////////////////////////////////////////////////// l_FORCEPEG: { if (t_stream>=t_limit) return State::FORCEPEG; if (t_stream>=t0) goto l_PEGGED; dest[t_stream++] = 0; goto l_FORCEPEG; } crash("Code breach"); ////////////////////////////////////////////////// l_BLANKDEPEG: { if (t_stream>=t_limit) return State::BLANKDEPEG; if (t_stream >= t0-tau+t_blankdepeg) goto l_DEPEGGING; if (usenegv) { int dt=t_stream-t0; int dt2=dt*dt; int dt3=dt*dt2; raw_t y = source[t_stream]; y -= alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3; if ((y<0) != negv) { dest[t_stream] = y; t_stream++; goto l_DEPEGGING; } } dest[t_stream] = 0; t_stream++; goto l_BLANKDEPEG; } crash("Code breach"); ////////////////////////////////////////////////// l_DEPEGGING: { if (t_stream>=t_limit) return State::DEPEGGING; if (t_stream==t0) goto l_OK; int dt = t_stream - t0; int dt2 = dt*dt; int dt3 = dt*dt2; raw_t y = source[t_stream]; y -= (alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3); dest[t_stream++] = y; goto l_DEPEGGING; } crash("Code breach"); ////////////////////////////////////////////////// l_PEGGING: { if (t_stream >= t_limit) return State::PEGGING; if (t_stream >= t0 + tau) { // t_peg = t_stream; goto l_PEGGED; } int dt = t_stream - t0; int dt2 = dt*dt; int dt3 = dt*dt2; raw_t y = source[t_stream]; y -= alpha0 + alpha1*dt + alpha2*dt2 + alpha3*dt3; dest[t_stream++] = y; goto l_PEGGING; } crash("Code breach"); ////////////////////////////////////////////////// l_OK: { if (t_stream>=t_limit) return State::OK; calc_alpha0(); raw_t y = source[t_stream]; y -= alpha0; dest[t_stream++] = y; if (ispegged(source[t_stream+tau+t_ahead])) { if (debug_name==0) std::cerr << "salpa " << debug_name << " going from OK to pegging at " << t_stream+tau+t_ahead << " because " << source[t_stream+tau+t_ahead] << "\n"; t0 = t_stream-1; calc_X3(); calc_alpha0123(); goto l_PEGGING; } update_X012(); goto l_OK; } crash("Code breach"); ////////////////////////////////////////////////// } void LocalFit::calc_X012() { X0 = X1 = X2 = 0; for (int t=-tau; t<=tau; t++) { int_t t2 = t*t; int_t y = source[t0+t]; X0 += y; X1 += t*y; X2 += t2*y; } } void LocalFit::calc_X3() { X3 = 0; for (int t=-tau; t<=tau; t++) { int_t t3 = t*t*t; int_t y = source[t0+t]; X3 += t3*y; } } void LocalFit::update_X0123() { int_t y_new = source[t0+tau]; int_t y_old = source[t0-tau-1]; X0 += y_new - y_old; X1 += tau_plus_1*y_new - minus_tau*y_old - X0; X2 += tau_plus_1_squared*y_new - minus_tau_squared*y_old - X0 - 2*X1; X3 += tau_plus_1_cubed*y_new - minus_tau_cubed*y_old - X0 - 3*X1 - 3*X2; } void LocalFit::calc_alpha0123() { real_t fact02 = 1./(T0*T4-T2*T2); alpha0 = fact02*(T4*X0 - T2*X2); alpha2 = fact02*(T0*X2 - T2*X0); real_t fact13 = 1./(T2*T6-T4*T4); alpha1 = fact13*(T6*X1 - T4*X3); alpha3 = fact13*(T2*X3 - T4*X1); //// report(); } //-------------------------------------------------------------------- // debug // #include <iostream> char const *LocalFit::stateName(State s) { switch (s) { case State::OK: return "OK"; case State::PEGGING: return "Pegging"; case State::PEGGED: return "Pegged"; case State::TOOPOOR: return "TooPoor"; case State::DEPEGGING: return "Depegging"; case State::FORCEPEG: return "ForcePeg"; case State::BLANKDEPEG: return "BlankDepeg"; default: return "???"; } } void LocalFit::report() { std::cerr << "state=" << stateName(state); std::cerr << " t_stream=" << t_stream; std::cerr << " t0=" << t0; std::cerr << " y[t]=" << source[t_stream]; std::cerr << " alpha=" << alpha0 << " " << alpha1 << " " << alpha2 << " " << alpha3; std::cerr << " X=" << X0 << " " << X1 << " " << X2 << " " << X3; std::cerr << "\n"; } void LocalFit::inirep() { std::cerr << "tau=" << tau; std::cerr << " T0/2/4/6=" << T0 << " " << T2 << " " << T4 << " " << T6; std::cerr << "\n"; } void LocalFit::crash(char const *msg) { std::cerr << "LocalFit: " << msg << "\n"; std::exit(1); } void LocalFit::condreport() { if (t_stream < 45000) report(); }
[ "daw@caltech.edu" ]
daw@caltech.edu
eac7417b955cb0b9b30e96636949fe736ff46fb1
fb3c1e036f18193d6ffe59f443dad8323cb6e371
/src/flash/core/avmfeatures.cpp
6e3da6e98960af994aa3ea184c8b53c9516ea775
[]
no_license
playbar/nstest
a61aed443af816fdc6e7beab65e935824dcd07b2
d56141912bc2b0e22d1652aa7aff182e05142005
refs/heads/master
2021-06-03T21:56:17.779018
2016-08-01T03:17:39
2016-08-01T03:17:39
64,627,195
3
1
null
null
null
null
UTF-8
C++
false
false
5,033
cpp
// DO NOT EDIT THIS FILE // // This file has been generated by the script core/avmfeatures.as, // from a set of configuration parameters in that file. // // If you feel you need to make changes below, instead edit the configuration // file and rerun it to get a new version of this file. // // ***** BEGIN LICENSE BLOCK ***** // Version: MPL 1.1/GPL 2.0/LGPL 2.1 // // The contents of this file are subject to the Mozilla Public License Version // 1.1 (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // http://www.mozilla.org/MPL/ // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the // License. // // The Original Code is [Open Source Virtual Machine.]. // // The Initial Developer of the Original Code is // Adobe System Incorporated. // Portions created by the Initial Developer are Copyright (C) 2009 // the Initial Developer. All Rights Reserved. // // Contributor(s): // Adobe AS3 Team // // Alternatively, the contents of this file may be used under the terms of // either the GNU General Public License Version 2 or later (the "GPL"), or // the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), // in which case the provisions of the GPL or the LGPL are applicable instead // of those above. If you wish to allow use of your version of this file only // under the terms of either the GPL or the LGPL, and not to allow others to // use your version of this file under the terms of the MPL, indicate your // decision by deleting the provisions above and replace them with the notice // and other provisions required by the GPL or the LGPL. If you do not delete // the provisions above, a recipient may use your version of this file under // the terms of any one of the MPL, the GPL or the LGPL. // // ***** END LICENSE BLOCK **** #include "avmplus.h" #ifdef AVMSHELL_BUILD // The string avmfeatures contains the names of all features that were enabled // when the program was compiled. Each feature name is terminated by a semicolon. const char * const avmfeatures = "" #if AVMSYSTEM_32BIT "AVMSYSTEM_32BIT;" #endif #if AVMSYSTEM_64BIT "AVMSYSTEM_64BIT;" #endif #if AVMSYSTEM_BIG_ENDIAN "AVMSYSTEM_BIG_ENDIAN;" #endif #if AVMSYSTEM_LITTLE_ENDIAN "AVMSYSTEM_LITTLE_ENDIAN;" #endif #if AVMSYSTEM_DOUBLE_MSW_FIRST "AVMSYSTEM_DOUBLE_MSW_FIRST;" #endif #if AVMSYSTEM_ARM_FPU "AVMSYSTEM_ARM_FPU;" #endif #if AVMSYSTEM_IA32 "AVMSYSTEM_IA32;" #endif #if AVMSYSTEM_AMD64 "AVMSYSTEM_AMD64;" #endif #if AVMSYSTEM_ARM "AVMSYSTEM_ARM;" #endif #if AVMSYSTEM_PPC "AVMSYSTEM_PPC;" #endif #if AVMSYSTEM_SPARC "AVMSYSTEM_SPARC;" #endif #if AVMSYSTEM_MIPS "AVMSYSTEM_MIPS;" #endif #if AVMSYSTEM_UNIX "AVMSYSTEM_UNIX;" #endif #if AVMSYSTEM_MAC "AVMSYSTEM_MAC;" #endif #if AVMSYSTEM_WIN32 "AVMSYSTEM_WIN32;" #endif #if AVMSYSTEM_SYMBIAN "AVMSYSTEM_SYMBIAN;" #endif #if AVMFEATURE_DEBUGGER "AVMFEATURE_DEBUGGER;" #endif #if AVMFEATURE_ALLOCATION_SAMPLER "AVMFEATURE_ALLOCATION_SAMPLER;" #endif #if AVMFEATURE_VTUNE "AVMFEATURE_VTUNE;" #endif #if AVMFEATURE_JIT "AVMFEATURE_JIT;" #endif #if AVMFEATURE_AOT "AVMFEATURE_AOT;" #endif #if AVMFEATURE_ABC_INTERP "AVMFEATURE_ABC_INTERP;" #endif #if AVMFEATURE_WORDCODE_INTERP "AVMFEATURE_WORDCODE_INTERP;" #endif #if AVMFEATURE_THREADED_INTERP "AVMFEATURE_THREADED_INTERP;" #endif #if AVMFEATURE_SELFTEST "AVMFEATURE_SELFTEST;" #endif #if AVMFEATURE_EVAL "AVMFEATURE_EVAL;" #endif #if AVMFEATURE_PROTECT_JITMEM "AVMFEATURE_PROTECT_JITMEM;" #endif #if AVMFEATURE_SHARED_GCHEAP "AVMFEATURE_SHARED_GCHEAP;" #endif #if AVMFEATURE_USE_SYSTEM_MALLOC "AVMFEATURE_USE_SYSTEM_MALLOC;" #endif #if AVMFEATURE_CPP_EXCEPTIONS "AVMFEATURE_CPP_EXCEPTIONS;" #endif #if AVMFEATURE_INTERIOR_POINTERS "AVMFEATURE_INTERIOR_POINTERS;" #endif #if AVMFEATURE_JNI "AVMFEATURE_JNI;" #endif #if AVMFEATURE_HEAP_ALLOCA "AVMFEATURE_HEAP_ALLOCA;" #endif #if AVMFEATURE_STATIC_FUNCTION_PTRS "AVMFEATURE_STATIC_FUNCTION_PTRS;" #endif #if AVMFEATURE_INDIRECT_NATIVE_THUNKS "AVMFEATURE_INDIRECT_NATIVE_THUNKS;" #endif #if AVMFEATURE_OVERRIDE_GLOBAL_NEW "AVMFEATURE_OVERRIDE_GLOBAL_NEW;" #endif #if AVMFEATURE_MEMORY_PROFILER "AVMFEATURE_MEMORY_PROFILER;" #endif #if AVMFEATURE_CACHE_GQCN "AVMFEATURE_CACHE_GQCN;" #endif #if AVMFEATURE_API_VERSIONING "AVMFEATURE_API_VERSIONING;" #endif ; #endif // AVMSHELL_BUILD
[ "hgl868@126.com" ]
hgl868@126.com
a04f59337ff272d0381e299706acc9aacc444582
cca59ed6978ee5e6f6f440da63e14eedd28e76d7
/DSA/tpW-QB4ATMqVvkAeAHzKtw_df9ba297ee0745fb8e40b00bde601ded_course1_2020_05_28/week3_greedy_algorithms/1_money_change/change.cpp
2f7e0453aeaf3fcd84dec9da3eacb661b10a1489
[]
no_license
ach-in/moocs
f0d4ab06443442f48df66dad738077c4e13ee66d
6799041ced3506818bf70a5a68b9c283db465808
refs/heads/master
2022-12-01T05:11:59.214070
2020-08-25T21:27:48
2020-08-25T21:27:48
287,500,318
1
0
null
null
null
null
UTF-8
C++
false
false
296
cpp
#include <iostream> int get_change(int m) { //write your code here int n = 0; while(m!=0){ if(m>=10){ m-=10; n++; } else if(m>=5){ m-=5; n++; } else{ m-=1; n++; } } return n; } int main() { int m; std::cin >> m; std::cout << get_change(m) << '\n'; }
[ "achinparashar1000@gmail.com" ]
achinparashar1000@gmail.com
5122e75cb244dd1b11bdf28da2502db735e41b69
68c1cc3785e2794a527ff949e30e8fea30f2f44d
/llap/Example/LLAPfly/llapfly/PublicUtility/CABundleLocker.cpp
2161be7447c8988343fc447f3019733690e68f45
[ "MIT" ]
permissive
jswny/LLAP
d9dc1bfe30ed83e685681791473941ed5b26a8ac
e191e7e051b0646648dce0639d429fb5676acadc
refs/heads/master
2022-04-24T13:28:07.055354
2020-04-25T05:36:36
2020-04-25T05:36:36
256,833,518
0
0
MIT
2020-04-18T19:14:49
2020-04-18T19:14:48
null
UTF-8
C++
false
false
3,312
cpp
/* File: CABundleLocker.cpp Abstract: CABundleLocker.h Version: 1.1 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. ("Apple") in consideration of your agreement to the following terms, and your use, installation, modification or redistribution of this Apple software constitutes acceptance of these terms. If you do not agree with these terms, please do not use, install, modify or redistribute this Apple software. In consideration of your agreement to abide by the following terms, and subject to these terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in this original Apple software (the "Apple Software"), to use, reproduce, modify and redistribute the Apple Software, with or without modifications, in source and/or binary forms; provided that if you redistribute the Apple Software in its entirety and without modifications, you must retain this notice and the following text and disclaimers in all such redistributions of the Apple Software. Neither the name, trademarks, service marks or logos of Apple Inc. may be used to endorse or promote products derived from the Apple Software without specific prior written permission from Apple. Except as expressly stated in this notice, no other rights or licenses, express or implied, are granted by Apple herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the Apple Software may be incorporated. The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Copyright (C) 2014 Apple Inc. All Rights Reserved. */ #include "CABundleLocker.h" #include <pthread.h> /* some bundle operations are not thread safe, notably CFCopyLocalizedStringFromTableInBundle */ static pthread_mutex_t sCABundleLocker = PTHREAD_MUTEX_INITIALIZER; #define RECURSIVE_LOCK 0 #if RECURSIVE_LOCK static pthread_once_t sOnce = PTHREAD_ONCE_INIT; static void InitCABundleLocker() { // have to do this because OS X lacks PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&sCABundleLocker, &attr); pthread_mutexattr_destroy(&attr); } #endif CABundleLocker::CABundleLocker() { #if RECURSIVE_LOCK pthread_once(&sOnce, InitCABundleLocker); #endif pthread_mutex_lock(&sCABundleLocker); } CABundleLocker::~CABundleLocker() { pthread_mutex_unlock(&sCABundleLocker); }
[ "sk461236626@163.com" ]
sk461236626@163.com
9fea3960960f63ce4479f6546ebcc96584345cbc
b350b1193f350c349923e0a7baeed08ddf6d8cfd
/Cpp_Algorithms/BinaryTreeInorderTraversal/inorder_traversal.cc
7f589dd337262197322fc5d7a989deb291b02df3
[]
no_license
Oscarchoi/CodeExamples
98c326f56cc403679e1a463895acb23d2e8384ee
716a6ac2a6549068fd109f0a36f8abcbf44f1cf9
refs/heads/master
2023-09-01T06:18:09.427283
2021-11-03T16:30:46
2021-11-03T16:30:46
262,495,049
0
0
null
null
null
null
UTF-8
C++
false
false
684
cc
#include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} }; class Solution { public: vector<int> inorderTraversal(TreeNode *root) { vector<int> res; inOrder(root, res); return res; } void inOrder(TreeNode *node, vector<int> &res) { if (!node) return; if (node->left) inOrder(node->left, res); res.push_back(node->val); if (node->right) inOrder(node->right, res); } };
[ "wychoi502@gmail.com" ]
wychoi502@gmail.com
ae6f282ef705101cf4eb36c21886e246d3361d9b
9037aae803aa3b42e73bcb137410d24dd064d450
/service-api/src/thrift/gen-cpp/User_types.cpp
10ffe270f45e5120a54b12cc8fa3f69eb95e4a59
[]
no_license
Vann7/xjll_service
c0a626ab9ef11653fa08038355bc2c96e6a3cc63
8815f204e7e5b89a6bcdbc27667e636f40676769
refs/heads/master
2020-03-27T14:46:33.542499
2018-09-06T06:36:19
2018-09-06T06:36:19
146,678,172
1
0
null
null
null
null
UTF-8
C++
false
true
4,000
cpp
/** * Autogenerated by Thrift Compiler (0.11.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "User_types.h" #include <algorithm> #include <ostream> #include <thrift/TToString.h> namespace com { namespace test { User::~User() throw() { } void User::__set_id(const int32_t val) { this->id = val; } void User::__set_name(const std::string& val) { this->name = val; } void User::__set_age(const int32_t val) { this->age = val; } void User::__set_home(const std::string& val) { this->home = val; } std::ostream& operator<<(std::ostream& out, const User& obj) { obj.printTo(out); return out; } uint32_t User::read(::apache::thrift::protocol::TProtocol* iprot) { ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot); uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { xfer += iprot->readI32(this->id); this->__isset.id = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->name); this->__isset.name = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_I32) { xfer += iprot->readI32(this->age); this->__isset.age = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->home); this->__isset.home = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t User::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot); xfer += oprot->writeStructBegin("User"); xfer += oprot->writeFieldBegin("id", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32(this->id); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->name); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("age", ::apache::thrift::protocol::T_I32, 3); xfer += oprot->writeI32(this->age); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldBegin("home", ::apache::thrift::protocol::T_STRING, 4); xfer += oprot->writeString(this->home); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(User &a, User &b) { using ::std::swap; swap(a.id, b.id); swap(a.name, b.name); swap(a.age, b.age); swap(a.home, b.home); swap(a.__isset, b.__isset); } User::User(const User& other0) { id = other0.id; name = other0.name; age = other0.age; home = other0.home; __isset = other0.__isset; } User& User::operator=(const User& other1) { id = other1.id; name = other1.name; age = other1.age; home = other1.home; __isset = other1.__isset; return *this; } void User::printTo(std::ostream& out) const { using ::apache::thrift::to_string; out << "User("; out << "id=" << to_string(id); out << ", " << "name=" << to_string(name); out << ", " << "age=" << to_string(age); out << ", " << "home=" << to_string(home); out << ")"; } }} // namespace
[ "272921161@qq.com" ]
272921161@qq.com
71748b243672ce83f903dc31c0a8534aab5ada9d
54590b39d4710d32bc129e0e9bf59fd5f56ac32d
/SDK/SoT_bsp_plm_cluster_03_d_functions.cpp
79f0df12248339931c20448987c728460c60c612
[]
no_license
DDan1l232/SoT-SDK
bb3bb85fa813963655288d6fa2747d316ce57af8
cda078f3b8bca304759f05cc71ca55d31878e8e5
refs/heads/master
2023-03-17T13:16:11.076040
2020-09-09T15:19:09
2020-09-09T15:19:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
756
cpp
// Sea of Thieves (1.4.16) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SoT_bsp_plm_cluster_03_d_parameters.hpp" namespace SDK { //--------------------------------------------------------------------------- //Functions //--------------------------------------------------------------------------- // Function bsp_plm_cluster_03_d.bsp_plm_cluster_03_d_C.UserConstructionScript // (Event, Public, BlueprintCallable, BlueprintEvent) void Absp_plm_cluster_03_d_C::UserConstructionScript() { static auto fn = UObject::FindObject<UFunction>(_xor_("Function bsp_plm_cluster_03_d.bsp_plm_cluster_03_d_C.UserConstructionScript")); struct { } params; UObject::ProcessEvent(fn, &params); } } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "53855178+Shat-sky@users.noreply.github.com" ]
53855178+Shat-sky@users.noreply.github.com
e7213cc85e18a8d1b5777847b00fbd6df595a936
2a13ef8aac640723d81f8dc28d7a9f9b9481cf17
/Kernel/FileSystem/AnonymousFile.cpp
a0fa76fd426fb0a7710b629595e5ad7abce12873
[ "BSD-2-Clause" ]
permissive
gchenfly/serenity
e2eee85c1445269a8790afe76d597b54879abea6
02cca9276315ac4e92083e1e25edf3e760f433ff
refs/heads/master
2023-02-23T07:07:20.514241
2021-01-24T21:01:39
2021-01-24T21:24:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,060
cpp
/* * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <Kernel/FileSystem/AnonymousFile.h> #include <Kernel/Process.h> #include <Kernel/VM/AnonymousVMObject.h> namespace Kernel { AnonymousFile::AnonymousFile(NonnullRefPtr<AnonymousVMObject> vmobject) : m_vmobject(move(vmobject)) { } AnonymousFile::~AnonymousFile() { } KResultOr<Region*> AnonymousFile::mmap(Process& process, FileDescription&, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot, bool shared) { if (offset != 0) return EINVAL; if (size != m_vmobject->size()) return EINVAL; return process.allocate_region_with_vmobject(preferred_vaddr, size, m_vmobject, offset, {}, prot, shared); } }
[ "kling@serenityos.org" ]
kling@serenityos.org
0a585c6cf2ec3350c6aeee747399fa8d716b9403
2cb3e1435380226bc019f9c4970be871fd54288e
/opencv/build/modules/core/stat.simd_declarations.hpp
5b7be13473b1fb5376736af6201415deb0a2397e
[ "Apache-2.0" ]
permissive
35048542/opencv-contrib-ARM64
0db9f49721055f8597dd766ee8749be68054c526
25386df773f88a071532ec69ff541c31e62ec8f2
refs/heads/main
2023-07-20T10:43:13.265246
2021-08-24T13:55:38
2021-08-24T13:55:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
170
hpp
#define CV_CPU_SIMD_FILENAME "/home/epasholl/opencv/opencv-master/modules/core/src/stat.simd.hpp" #define CV_CPU_DISPATCH_MODES_ALL BASELINE #undef CV_CPU_SIMD_FILENAME
[ "epasholl@umich.edu" ]
epasholl@umich.edu
2ce081233676c972cc8885fcb26c9b7e5a52fdee
c057e033602e465adfa3d84d80331a3a21cef609
/C/testcases/CWE127_Buffer_Underread/s03/CWE127_Buffer_Underread__new_wchar_t_loop_32.cpp
5878a9f24605c668c008ee9f7c0e5ab95bef60e9
[]
no_license
Anzsley/My_Juliet_Test_Suite_v1.3_for_C_Cpp
12c2796ae7e580d89e4e7b8274dddf920361c41c
f278f1464588ffb763b7d06e2650fda01702148f
refs/heads/main
2023-04-11T08:29:22.597042
2021-04-09T11:53:16
2021-04-09T11:53:16
356,251,613
1
0
null
null
null
null
UTF-8
C++
false
false
3,946
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE127_Buffer_Underread__new_wchar_t_loop_32.cpp Label Definition File: CWE127_Buffer_Underread__new.label.xml Template File: sources-sink-32.tmpl.cpp */ /* * @description * CWE: 127 Buffer Under-read * BadSource: Set data pointer to before the allocated memory buffer * GoodSource: Set data pointer to the allocated memory buffer * Sink: loop * BadSink : Copy data to string using a loop * Flow Variant: 32 Data flow using two pointers to the same value within the same function * * */ #include "std_testcase.h" #include <wchar.h> namespace CWE127_Buffer_Underread__new_wchar_t_loop_32 { #ifndef OMITBAD void bad() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; { wchar_t * data = *dataPtr1; { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FLAW: Set data pointer to before the allocated memory buffer */ data = dataBuffer - 8; } *dataPtr1 = data; } { wchar_t * data = *dataPtr2; { size_t i; wchar_t dest[100]; wmemset(dest, L'C', 100-1); /* fill with 'C's */ dest[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ for (i = 0; i < 100; i++) { dest[i] = data[i]; } /* Ensure null termination */ dest[100-1] = L'\0'; printWLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by new [] so can't safely call delete [] on it */ } } } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2B() { wchar_t * data; wchar_t * *dataPtr1 = &data; wchar_t * *dataPtr2 = &data; data = NULL; { wchar_t * data = *dataPtr1; { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FIX: Set data pointer to the allocated memory buffer */ data = dataBuffer; } *dataPtr1 = data; } { wchar_t * data = *dataPtr2; { size_t i; wchar_t dest[100]; wmemset(dest, L'C', 100-1); /* fill with 'C's */ dest[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ for (i = 0; i < 100; i++) { dest[i] = data[i]; } /* Ensure null termination */ dest[100-1] = L'\0'; printWLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by new [] so can't safely call delete [] on it */ } } } void good() { goodG2B(); } #endif /* OMITGOOD */ } /* close namespace */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN using namespace CWE127_Buffer_Underread__new_wchar_t_loop_32; /* so that we can use good and bad easily */ int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
[ "65642214+Anzsley@users.noreply.github.com" ]
65642214+Anzsley@users.noreply.github.com
f9c23d0d8bb0b24e415c44057753d70719c03925
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/windows/richedit/re30/_ime.h
381c6669f83c87732a6fdd0d23f929668b4fcfd3
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
10,825
h
/* * @doc INTERNAL * * @module _ime.h -- support for IME APIs | * * Purpose: * Most everything to do with FE composition string editing passes * through here. * * Authors: <nl> * Jon Matousek <nl> * Justin Voskuhl <nl> * Hon Wah Chan <nl> * * History: <nl> * 10/18/1995 jonmat Cleaned up level 2 code and converted it into * a class hierarchy supporting level 3. * * Copyright (c) 1995-1996 Microsoft Corporation. All rights reserved. * */ #ifndef _IME_H #define _IME_H class CTextMsgFilter; // defines for IME Level 2 and 3 #define IME_LEVEL_2 2 #define IME_LEVEL_3 3 #define IME_PROTECTED 4 /* * IME * * @class base class for IME support. * * @devnote * For level 2, at caret IMEs, the IME will draw a window directly over the text giving the * impression that the text is being processed by the application--this is called pseudo inline. * All UI is handled by the IME. This mode is currenlty bypassed in favor of level 3 true inline (TI); * however, it would be trivial to allow a user preference to select this mode. Some IMEs may have * a "special" UI, in which case level 3 TI is *NOT* used, necessitating level 2. * * For level 2, near caret IMEs, the IME will draw a very small and obvious window near the current * caret position in the document. This currently occurs for PRC(?) and Taiwan. * All UI is handled by the IME. * * For level 3, at caret IMEs, the composition string is drawn by the application, which is called * true inline, bypassing the level 2 "composition window". * Currently, we allow the IME to support all remaining UI *except* drawing of the composition string. */ class CIme { friend LRESULT OnGetIMECompositionMode ( CTextMsgFilter &TextMsgFilter ); friend HRESULT CompositionStringGlue ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); friend HRESULT EndCompositionGlue ( CTextMsgFilter &TextMsgFilter, BOOL fForceDelete); friend void CheckDestroyIME ( CTextMsgFilter &TextMsgFilter ); //@access Protected data protected: short _imeLevel; //@cmember IME Level 2 or 3 short _cIgnoreIMECharMsg; //@cmember Level 2 IME use to eat WM_IME_CHAR message short _fIgnoreEndComposition; //@cmember ignore the next End Composition message short _fIMETerminated; //@cmember indicate this IME has been terminated short _fSkipFirstOvertype; //@cmember skip first overtype if selection is // deleted on StartComposition //@access Public methods public: virtual ~CIme() {}; INT _compMessageRefCount; //@cmember so as not to delete if recursed. short _fDestroy; //@cmember set when object wishes to be deleted. //@cmember Handle WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle WM_IME_COMPOSITION and WM_IME_ENDCOMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ) = 0; //@cmember Handle WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fCCompWindow ) = 0; virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) = 0; enum TerminateMode { TERMINATE_NORMAL = 1, TERMINATE_FORCECANCEL = 2 }; void TerminateIMEComposition(CTextMsgFilter &TextMsgFilter, CIme::TerminateMode mode); //@cmember Terminate current IME composition session. //@cmember check if we need to ignore WM_IME_CHAR messages BOOL IgnoreIMECharMsg() { return _cIgnoreIMECharMsg > 0; } //@cmember skip WM_IME_CHAR message void SkipIMECharMsg() { _cIgnoreIMECharMsg--; } //@cmember accept WM_IME_CHAR message void AcceptIMECharMsg() { _cIgnoreIMECharMsg = 0; } static void CheckKeyboardFontMatching ( long cp, CTextMsgFilter &TextMsgFilter, ITextFont *pTextFont ); //@cmember Check current font/keyboard matching. BOOL IsTerminated () //@cmember Return _fIMETerminated { return _fIMETerminated; } INT GetIMELevel () //@cmember Return the current IME level. { return _imeLevel; } //@access Protected methods protected: //@cmember Get composition string, convert to unicode. static INT GetCompositionStringInfo( HIMC hIMC, DWORD dwIndex, WCHAR *uniCompStr, INT cchUniCompStr, BYTE *attrib, INT cbAttrib, LONG *cursorCP, LONG *cchAttrib, UINT kbCodePage, BOOL bUnicodeIME, BOOL bUsingAimm ); static HRESULT CheckInsertResultString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter, short *pcch = NULL ); void SetCompositionFont ( CTextMsgFilter &TextMsgFilter, ITextFont *pTextFont ); //@cmember Setup for level 2 and 3 composition and candidate window's font. void SetCompositionForm ( CTextMsgFilter &TextMsgFilter ); //@cmember Setup for level 2 IME composition window's position. }; /* * IME_Lev2 * * @class Level 2 IME support. * */ class CIme_Lev2 : public CIme { //@access Public methods public: //@cmember Handle level 2 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 2 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 2 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fIgnore ); virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} CIme_Lev2( CTextMsgFilter &TextMsgFilter ); virtual ~CIme_Lev2(); ITextFont *_pTextFont; //@cmember base format }; /* * IME_PROTECTED * * @class IME_PROTECTED * */ class CIme_Protected : public CIme { //@access Public methods public: //@cmember Handle level 2 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ) {_imeLevel = IME_PROTECTED; return S_OK;} //@cmember Handle level 2 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle post WM_IME_CHAR to update comp window. virtual void PostIMEChar( CTextMsgFilter &TextMsgFilter ) {} //@cmember Handle level 2 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fIgnore ) {return S_FALSE;} virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} }; /* * IME_Lev3 * * @class Level 3 IME support. * */ class CIme_Lev3 : public CIme_Lev2 { //@access Private data private: //@access Protected data protected: long _ichStart; //@cmember maintain starting ich. long _cchCompStr; //@cmember maintain composition string's cch. short _sIMESuportMouse; //@cmember IME mouse support WPARAM _wParamBefore; //@cmember Previous wParam sent to IME HWND _hwndIME; //@cmember current IME hWnd long _crTextColor; //@cmember current font text color long _crBkColor; //@cmember current font background color // Helper function //@cmember get imeshare color for the attribute COLORREF GetIMEShareColor(CIMEShare *pIMEShare, DWORD dwAttribute, DWORD dwProperty); //@access Public methods public: //@cmember Handle level 3 WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 3 WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); //@cmember Handle level 3 WM_IME_NOTIFY virtual HRESULT IMENotify (const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter, BOOL fCCompWindow ); void SetCompositionStyle ( CTextMsgFilter &TextMsgFilter, UINT attribute, ITextFont *pTextFont ); CIme_Lev3( CTextMsgFilter &TextMsgFilter ); virtual ~CIme_Lev3() {}; virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ); virtual BOOL IMESupportMouse ( CTextMsgFilter &TextMsgFilter ); public: short _fUpdateWindow; //@cmember Update Window after closing CandidateWindow long GetIMECompositionStart() { return _ichStart; } long GetIMECompositionLen() { return _cchCompStr; } }; /* * Special IME_Lev3 for Korean Hangeul -> Hanja conversion * * @class Hangual IME support. * */ class CIme_HangeulToHanja : public CIme_Lev3 { //@access Private data private: public: CIme_HangeulToHanja( CTextMsgFilter &TextMsgFilter ); //@cmember Handle Hangeul WM_IME_STARTCOMPOSITION virtual HRESULT StartComposition ( CTextMsgFilter &TextMsgFilter ); //@cmember Handle Hangeul WM_IME_COMPOSITION virtual HRESULT CompositionString ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); virtual BOOL IMEMouseOperation ( CTextMsgFilter &TextMsgFilter, UINT msg ) {return FALSE;} }; // Glue functions to call the respective methods of an IME object stored in the ed. HRESULT StartCompositionGlue ( CTextMsgFilter &TextMsgFilter ); HRESULT CompositionStringGlue ( const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); HRESULT EndCompositionGlue ( CTextMsgFilter &TextMsgFilter, BOOL fForceDelete); void PostIMECharGlue ( CTextMsgFilter &TextMsgFilter ); HRESULT IMENotifyGlue ( const WPARAM wparam, const LPARAM lparam, CTextMsgFilter &TextMsgFilter ); // @parm the containing text edit. HRESULT IMEMouseCheck(CTextMsgFilter &TextMsgFilter, UINT *pmsg, WPARAM *pwparam, LPARAM *plparam, LRESULT *plres); // IME helper functions. void IMECompositionFull ( CTextMsgFilter &TextMsgFilter ); LRESULT OnGetIMECompositionMode ( CTextMsgFilter &TextMsgFilter ); BOOL IMECheckGetInvertRange(CTextMsgFilter *ed, LONG &, LONG &); void CheckDestroyIME ( CTextMsgFilter &TextMsgFilter ); BOOL IMEHangeulToHanja ( CTextMsgFilter &TextMsgFilter ); BOOL IMEMessage ( CTextMsgFilter &TextMsgFilter, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL bPostMessage ); HIMC LocalGetImmContext ( CTextMsgFilter &TextMsgFilter ); void LocalReleaseImmContext ( CTextMsgFilter &TextMsgFilter, HIMC hIMC ); long IMEShareToTomUL ( UINT ulID ); #endif // define _IME_H
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
1929dc6e742d2a9a900cc6eb6c5c44e626f1fa88
4c7c9592e056c80f3499cdcbe16be8fa49321ad1
/Game/MissileManager.cpp
bb8e1d4be3cb8a1218892c6804c4156ebbf0570f
[]
no_license
Karrietje/Galaga
00646c2983c189943b7872c686884d2a3cd52c40
a4b5fe2de5bfebb372179b94d924a8c25d5e9710
refs/heads/main
2023-07-09T05:40:10.434977
2021-08-23T02:56:15
2021-08-23T02:56:15
397,385,490
0
0
null
null
null
null
UTF-8
C++
false
false
1,364
cpp
#include "MissileManager.h" #include "GameObject.h" #include "Components.h" #include "GalagaComponents.h" #include "SceneManager.h" #include "Scene.h" void dae::MissileManager::SubscribeGameObject(Scene* pScene, GameObject* pGameObject, bool isEnemy) { if (m_pMissiles.find(pGameObject) != m_pMissiles.end()) return; m_pMissiles.insert(std::make_pair(pGameObject, std::vector<MissileComponent*>())); for (int i{}; i < 2; i++) { GameObject* pMissile = new GameObject(); MissileComponent* pMissileComponent = new MissileComponent(isEnemy); pMissile->AddComponent(ComponentType::MissileComponent, pMissileComponent); m_pMissiles.at(pGameObject).push_back(pMissileComponent); pScene->Add(pMissile, 3); } } bool dae::MissileManager::ShootMissile(GameObject* pGameObject) { for (MissileComponent* pMissile : m_pMissiles.at(pGameObject)) { GameObject* pMissileObject{ pMissile->GetGameObject() }; if (!pMissileObject->IsActive()) { pMissileObject->GetTransform()->SetPosition(pGameObject->GetTransform()->GetPosition()); pMissileObject->SetActive(true); return true; } } return false; } void dae::MissileManager::Reset() { for (std::pair<GameObject*, std::vector<MissileComponent*>> missiles : m_pMissiles) { for (MissileComponent* pMissile : missiles.second) { pMissile->GetGameObject()->SetActive(false); } } }
[ "44691800+Karrietje@users.noreply.github.com" ]
44691800+Karrietje@users.noreply.github.com
b8fb6b1611a86c1e0a30e6929c9e3b6bcca5e044
67f988dedfd8ae049d982d1a8213bb83233d90de
/external/chromium/ui/gfx/rect_f.cc
d7b1089c96de6c556d3fc08b85ebc2e1fe86c4cd
[ "BSD-3-Clause" ]
permissive
opensourceyouthprogramming/h5vcc
94a668a9384cc3096a365396b5e4d1d3e02aacc4
d55d074539ba4555e69e9b9a41e5deb9b9d26c5b
refs/heads/master
2020-04-20T04:57:47.419922
2019-02-12T00:56:14
2019-02-12T00:56:14
168,643,719
1
1
null
2019-02-12T00:49:49
2019-02-01T04:47:32
C++
UTF-8
C++
false
false
2,013
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/gfx/rect_f.h" #include <algorithm> #include "base/logging.h" #include "base/stringprintf.h" #include "ui/gfx/insets_f.h" #include "ui/gfx/rect_base_impl.h" #include "ui/gfx/safe_integer_conversions.h" namespace gfx { template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; typedef class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float> RectBaseT; bool RectF::IsExpressibleAsRect() const { return IsExpressibleAsInt(x()) && IsExpressibleAsInt(y()) && IsExpressibleAsInt(width()) && IsExpressibleAsInt(height()) && IsExpressibleAsInt(right()) && IsExpressibleAsInt(bottom()); } std::string RectF::ToString() const { return base::StringPrintf("%s %s", origin().ToString().c_str(), size().ToString().c_str()); } RectF operator+(const RectF& lhs, const Vector2dF& rhs) { RectF result(lhs); result += rhs; return result; } RectF operator-(const RectF& lhs, const Vector2dF& rhs) { RectF result(lhs); result -= rhs; return result; } RectF IntersectRects(const RectF& a, const RectF& b) { RectF result = a; result.Intersect(b); return result; } RectF UnionRects(const RectF& a, const RectF& b) { RectF result = a; result.Union(b); return result; } RectF SubtractRects(const RectF& a, const RectF& b) { RectF result = a; result.Subtract(b); return result; } RectF ScaleRect(const RectF& r, float x_scale, float y_scale) { RectF result = r; result.Scale(x_scale, y_scale); return result; } RectF BoundingRect(const PointF& p1, const PointF& p2) { float rx = std::min(p1.x(), p2.x()); float ry = std::min(p1.y(), p2.y()); float rr = std::max(p1.x(), p2.x()); float rb = std::max(p1.y(), p2.y()); return RectF(rx, ry, rr - rx, rb - ry); } } // namespace gfx
[ "rjogrady@google.com" ]
rjogrady@google.com
b34513dae9dd5334c3394686f4ed7b36ff54b905
f77d436de9db3ec3d0b9cba8baf90895409f5b89
/Term 2/CarND-PID-Control-Project-master/src/PID.h
64d1b974950b75f645b131a37e94eff0fab7d81a
[]
no_license
markusmeyerhofer/SelfDrivingCarND
ecea9f13b018db0df8a718a6c0a8f52818ba04ea
9421fc46b2a05fb9ca5c7aebd18ca4101d019d4c
refs/heads/master
2020-07-04T06:10:21.617199
2019-08-13T16:17:43
2019-08-13T16:17:43
202,181,551
0
0
null
null
null
null
UTF-8
C++
false
false
564
h
#ifndef PID_H #define PID_H class PID { public: /* * Errors */ //private: double p_error; double i_error; double d_error; /* * Coefficients */ double Kp; double Ki; double Kd; public: /* * Constructor */ PID(); /* * Destructor. */ virtual ~PID(); /* * Initialize PID. */ void Init(double Kp, double Ki, double Kd); /* * Update the PID error variables given cross track error. */ void UpdateError(double cte); /* * Calculate the total PID error. */ double TotalError(); }; #endif /* PID_H */
[ "markus.meyerhofer@me.com" ]
markus.meyerhofer@me.com
fc62baef2c89a66328a8bc5b3567ade5cc684a84
11b9965933d407ed3708a252aebcdafc21c98664
/FEM/include/refel.h
33dfba0cc0667353effded3c3189aaab4b572abe
[ "BSD-3-Clause" ]
permissive
lanl/Dendro-GRCA
a265131e2a5d8327eba49e2133257d553826a41e
8a475b1abd8832c3dfc19d00cc0ec4b9e2789c8a
refs/heads/master
2023-05-31T06:25:06.113867
2020-09-23T18:00:13
2020-09-23T18:00:13
297,793,620
1
1
null
null
null
null
UTF-8
C++
false
false
23,737
h
// // Created by milinda on 12/25/16. // /** * @author Milinda Fernando * @author Hari Sundar * @breif Contains data structures to store the reference element information. * * @refference: Based of HOMG code written in matlab. * */ #ifndef SFCSORTBENCH_REFERENCEELEMENT_H #define SFCSORTBENCH_REFERENCEELEMENT_H #ifdef WITH_BLAS_LAPACK #include "basis.h" #endif #include "tensor.h" #include <fstream> #include <iostream> #include <vector> #include <iomanip> #include <math.h> #include <cstring> #include <assert.h> #include "interpMatrices.h" #include "binUtils.h" template<typename T> void dump_binary(const T* in, unsigned int n, const char* fPrefix) { char fName[256]; sprintf(fName,"%s.bin",fPrefix); std::ofstream ofile(fName,std::ios::binary); ofile.write((char*)&n, sizeof(int)); ofile.write((char*)&in[0], sizeof(T)*n); ofile.close(); return ; } template <typename T> void printArray_1D(const T *a, int length) { for (int i = 0; i < length; i++) { std::cout<<a[i]<<" "; } std::cout<<std::endl; } template <typename T> void printArray_2D(const T *a, int length1,int length2) { for (int i = 0; i < length1; i++) { for (int j = 0; j < length2; j++) { std::cout << a[i * length2 + j] << " "; } std::cout<<std::endl; } std::cout<<std::endl; } class RefElement{ private : /** Dimension */ int m_uiDimension; /** Polynomial Order */ int m_uiOrder; /** Number of 3D interpolation points on the element */ int m_uiNp; /** Number of 2D face interpolation points */ int m_uiNfp; /** Number of 1D interpolation points */ int m_uiNrp; /** reference element volume */ unsigned int m_uiVol; /** 1D reference coordinates of the interpolation nodes (uniform nodal points) */ std::vector<double> u; /** 1D reference coordinates of the interpolation nodes (gll points)*/ std::vector<double> r; /** 1D regular points corresponding to child 0 of u*/ std::vector<double> u_0; /** 1D regular points corresponding to child 1 of u*/ std::vector<double> u_1; /** 1D Gauss points (used for quadrature)*/ std::vector<double> g; /** 1D weights for gauss quadrature */ std::vector<double> w; /** 1D weights for gll quadrature*/ std::vector<double> wgll; /** 1D interpolation matrix for child 0 */ std::vector<double> ip_1D_0; /** 1D interpolation matrix for child 1*/ std::vector<double> ip_1D_1; /** 1D interpolation matrix for child 0 (transpose) */ std::vector<double> ipT_1D_0; /** 1D interpolation matrix for child 1 (transpose)*/ std::vector<double> ipT_1D_1; /**Vandermonde matrix for interpolation points r. */ std::vector<double> Vr; /**Vandermonde matrix for interpolation points u. */ std::vector<double> Vu; /**Vandermonde matrix for polynomial at gauss points */ std::vector<double> Vg; /**gradient of the vandermonde for polynomial eval at points u*/ std::vector<double> gradVu; /**gradient of the vandermonde for polynomial eval at points r*/ std::vector<double> gradVr; /**gradient of the vandermonde for polynomial eval at points g*/ std::vector<double> gradVg; /**derivative of the pol. eval at points r. */ std::vector<double> Dr; /** derivative of the pol. eval at the gauss points. */ std::vector<double> Dg; /** derivative of the pol. eval at the gauss points. (transpose) */ std::vector<double> DgT; /** 1D quadrature matrix*/ std::vector<double> quad_1D; /** 1D quadrature matrix transpose*/ std::vector<double> quadT_1D; /**Vandermonde matrix for interpolation points of child 0 */ std::vector<double> Vu_0; /**Vandermonde matrix for interpolation points of child 1 */ std::vector<double> Vu_1; /**intermidiate vec 1 needed during interploation */ std::vector<double> im_vec1; /**intermidiate vec 1 needed during interploation */ std::vector<double> im_vec2; /**filter matrix for to cutoff high frequency terms. */ std::vector<double> Fr; /**@brief unzip intergrid transwer*/ std::vector<double> gridT; /**@brief unzip intergrid transwer out*/ std::vector<double> out_p2c; public: /**@brief: default constructor for the reference element*/ RefElement(); /**@brief: constructs a reference element * @param dim: dimension of the reference element. * @param order: element order */ RefElement(unsigned int dim, unsigned int order); /**@brief: distructor for the reference element. */ ~RefElement(); /**@brief: Get reference element order*/ inline int getOrder() const {return m_uiOrder;} /**@brief: get reference element dimension*/ inline int getDim() const {return m_uiDimension;} /**@brief: size of the interpolation points 1D*/ inline int get1DNumInterpolationPoints(){return m_uiNrp;} /**@brief: parent to child 0 interpolation operator*/ inline const double * getIMChild0() const {return &(*(ip_1D_0.begin()));} /**@brief: parent to child 1 interpolation operator*/ inline const double * getIMChild1() const {return &(*(ip_1D_1.begin()));} /**@brief: parent to child 0 interpolation operator (transpose)*/ inline const double * getIMTChild0() const { return &(*(ipT_1D_0.begin()));} /**@brief: parent to child 1 interpolation operator (transpose)*/ inline const double * getIMTChild1() const {return &(*(ipT_1D_1.begin()));} /**@brief: get the quadrature points*/ inline const double * getQ1d() const {return &(*(quad_1D.begin()));} /**@brief: get the quadrature points (transpose)*/ inline const double * getQT1d()const {return &(*(quadT_1D.begin()));} /**@brief: derivative of the basis functions evaluated at the quadrature points. */ inline const double * getDg1d()const {return &(*(Dg.begin()));} /**@brief: derivative of the basis functions evaluated at the quadrature points (Transpose) */ inline const double * getDgT1d()const {return &(*(DgT.begin()));} /**@brief: derivative of the basis functions evaluated at the nodal locations points */ inline const double * getDr1d()const {return &(*(Dr.begin()));} inline const double * getFr1D() const {return &(*(Fr.begin()));} inline double * getImVec1() {return &(*(im_vec1.begin()));} inline double * getImVec2() {return &(*(im_vec2.begin()));} inline const double * getWgq()const {return &(*(w.begin()));} inline const double * getWgll()const {return &(*(wgll.begin()));} inline const double getElementSz()const {return (u.back()-u.front());} /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: interpolated values. * * @brief This is computed in way that 3d coordinates changes in the order of z, y, x * Which means first we need to fill all the z values in plane(x=0,y=0) then all the z values in plane (x=0,y=0+h) and so forth. * */ inline void I3D_Parent2Child(const double * in, double* out, unsigned int childNum ) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 1: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 2: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 3: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im2,out); // along z break; case 4: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 5: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 6: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; case 7: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ip_1D_1.begin())),im2,out); // along z break; default: std::cout<<"[refel][error]: invalid child number specified for 3D interpolation."<<std::endl; break; } } /** * @brief performs parent to child interpolation in FD stencil. * @param in : input values of the parent. with 3 point padding on each x,y,z direction * @param out: values of the child. * @param cnum: child number * @param pwdith: padding width */ inline void I3D_Parent2Child_FD(const double* in, double* out,unsigned int pw=3) const { assert(pw < m_uiNrp); assert(m_uiNrp>2); // only works for higher order (hard coded) const unsigned int nx = m_uiNrp; const unsigned int ny = m_uiNrp; const unsigned int nz = m_uiNrp; const unsigned int sz_p[3] = {nx + 2*pw , ny + 2*pw , nz + 2*pw}; const unsigned int sz_c[3] = {2*m_uiNrp-1 + 2*pw,2*m_uiNrp-1 + 2*pw,2*m_uiNrp-1 + 2*pw}; const unsigned int c1d = 2*m_uiNrp-1; const unsigned int pp1 = sz_p[0]; const unsigned int pp2 = sz_p[0]*sz_p[1]; const unsigned int pp3 = sz_p[0]*sz_p[1]*sz_p[2]; const unsigned int cc1 = sz_c[0]; const unsigned int cc2 = sz_c[0]*sz_c[1]; const unsigned int cc3 = sz_c[0]*sz_c[1]*sz_c[2]; const unsigned int p2c1 = (pp1*2-1); const unsigned int p2c2 = (pp1*2-1)*p2c1; const unsigned int p2c3 = (pp1*2-1)*p2c2; const unsigned int fd_1d = gridT.size(); const double * c = gridT.data(); // const unsigned int fd_1d=4; // const double c[fd_1d] = {-1/16.0 , 9/16.0,9/16.0, -1/16.0}; // replacement array for p2c resolution. double * out_p = (double *)&(*(out_p2c.begin())); for(unsigned int k=0; k < sz_p[2]; k++) for(unsigned int j=0; j < sz_p[1]; j++) for(unsigned int i=0; i< sz_p[0]; i++) { out_p[ (k<<1u) * p2c2 + (j<<1u)*p2c1 + (i<<1u) ] = in[ k*pp2 + j*pp1 + i]; } const unsigned int N =p2c1; const unsigned int pw2 = pw<<1u; // along x direction. for(unsigned int k=0; k < N; k+=2) for(unsigned int j=0; j < N; j+=2) for(unsigned int i=pw2; i< N-pw2-2; i+=2) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ k*p2c2 + j * p2c1 + (i-4) + 2*m ]; out_p[ k * p2c2 + j*p2c1 + (i+1) ] =s; } // along y direction. for(unsigned int k=0; k < N; k+=2) for(unsigned int j=pw2; j < N-pw2-2; j+=2) for(unsigned int i=pw2; i< N-pw2; i+=1) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ k * p2c2 + (j-4 + 2*m)* p2c1 + i ]; out_p[ k * p2c2 + (j+1)*p2c1 + (i) ] =s; } // along z direction. for(unsigned int k=pw2; k < N-pw2-2; k+=2) for(unsigned int j=pw2; j < N-pw2; j+=1) for(unsigned int i=pw2; i< N-pw2; i+=1) { double s =0; for(unsigned int m=0; m < fd_1d ; m++) s+= c[m]*out_p[ (k-4 + 2*m) * p2c2 + (j)* p2c1 + i ]; out_p[ (k+1)* p2c2 + (j)*p2c1 + (i) ] =s; } for(unsigned int k=pw2; k < N-pw2; k+=1) for(unsigned int j=pw2; j < N-pw2; j+=1) for(unsigned int i=pw2; i< N-pw2; i+=1) out[ (k-pw2)*c1d*c1d + (j-pw2)*c1d + (i-pw2)] = out_p[ k* p2c2 + j* p2c1 + i]; return ; } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the contribution needed to be computed. * @param[out] out: child to parent contribution values. (used in FEM integral ivaluation) * * @brief This is computed in way that 3d coordinates changes in the order of z, y, x * Which means first we need to fill all the z values in plane(x=0,y=0) then all the z values in plane (x=0,y=0+h) and so forth. * */ inline void I3D_Child2Parent(const double * in, double* out, unsigned int childNum ) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 1: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 2: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 3: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im2,out); // along z break; case 4: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 5: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 6: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; case 7: DENDRO_TENSOR_IIAX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_IAIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im1,im2); // along y DENDRO_TENSOR_AIIX_APPLY_ELEM(m_uiNrp,&(*(ipT_1D_1.begin())),im2,out); // along z break; default: std::cout<<"[refel][error]: invalid child number specified for 3D interpolation."<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp*m_uiNrp*m_uiNrp);node++) out[node]=1.0; #endif } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: interpolated values. * */ inline void I2D_Parent2Child(const double * in, double* out, unsigned int childNum) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),im1,out); // along y (in 3d z) break; case 1: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),im1,out); // along y (in 3d z) break; case 2: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),im1,out); // along y (in 3d z) break; case 3: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ip_1D_1.begin())),im1,out); // along y (in 3d z) break; default: std::cout<<"[refel][error]: invalid child number specified for 2D interpolation."<<std::endl; break; } } /** * @param[in] in: input function values. * @param[in] childNum: Morton ID of the child number where the interpolation is needed. * @param[out] out: child to parent contribution values. (used in FEM integral ivaluation) * */ inline void I2D_Child2Parent(const double * in, double* out, unsigned int childNum) const { double * im1=(double *)&(*(im_vec1.begin())); double * im2=(double *)&(*(im_vec2.begin())); switch (childNum) { case 0: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),im1,out); // along y (in 3d z) break; case 1: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),im1,out); // along y (in 3d z) break; case 2: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_0.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),im1,out); // along y (in 3d z) break; case 3: DENDRO_TENSOR_IAX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),in,im1); // along x DENDRO_TENSOR_AIX_APPLY_ELEM_2D(m_uiNrp,&(*(ipT_1D_1.begin())),im1,out); // along y (in 3d z) break; default: std::cout<<"[refel][error]: invalid child number specified for 2D interpolation."<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp*m_uiNrp);node++) out[node]=1.0; #endif } /** * @param [in] in input function values * @param [in] childNum Morton ID of the child number * @param [out] interpolated values from parent to child. * */ inline void I1D_Parent2Child(const double * in,double * out,unsigned int childNUm) const { switch (childNUm) { case 0: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ip_1D_0[j*m_uiNrp+i]*in[j]; } } break; case 1: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ip_1D_1[j*m_uiNrp+i]*in[j]; } } break; default: std::cout<<"[refel][error]: Invalid child number specified for 1D interpolation. "<<std::endl; break; } } /** * @param [in] in input function values * @param [in] childNum Morton ID of the child number * @param [out] child to parent contribution values. (used in FEM integral ivaluation) * */ inline void I1D_Child2Parent(const double * in,double * out,unsigned int childNUm) const { switch (childNUm) { case 0: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ipT_1D_0[j*m_uiNrp+i]*in[j]; } } break; case 1: for(unsigned int i=0;i<m_uiNrp;i++) { out[i]=0.0; for(unsigned int j=0;j<m_uiNrp;j++) { out[i]+=ipT_1D_1[j*m_uiNrp+i]*in[j]; } } break; default: std::cout<<"[refel][error]: Invalid child number specified for 1D interpolation. "<<std::endl; break; } #ifdef FEM_ACCUMILATE_ONES_TEST for(unsigned int node=0;node<(m_uiNrp);node++) out[node]=1.0; #endif } void generateHeaderFile(char * fName); void computeFilterOp(unsigned int nc, unsigned int s); }; #endif //SFCSORTBENCH_REFERENCEELEMENT_H
[ "hylim1988@gmail.com" ]
hylim1988@gmail.com