hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 109 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 48.5k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1a3bccad1ad3d1786610dd85c77794be9d17408b | 5,254 | hpp | C++ | smartenum.hpp | therocode/smartenum | aba73929deb45d53ae2bb6cfccddbad080c365bd | [
"MIT"
] | 65 | 2015-10-06T15:56:25.000Z | 2022-02-22T09:57:35.000Z | src/Smartenum.hpp | dalyl-zero/prAIg | de1184873424e72c94ad463f24b5744769b791de | [
"MIT"
] | 4 | 2015-10-06T18:14:04.000Z | 2018-03-06T11:24:54.000Z | src/Smartenum.hpp | dalyl-zero/prAIg | de1184873424e72c94ad463f24b5744769b791de | [
"MIT"
] | 14 | 2015-10-06T16:58:02.000Z | 2020-05-09T09:21:30.000Z | #pragma once
#include <string>
#include <unordered_map>
#include <vector>
#include <cstdint>
#include <iostream>
namespace smart_enum
{
inline std::string trimWhitespace(std::string str)
{
// trim trailing whitespace
size_t endPos = str.find_last_not_of(" \t");
if(std::string::npos != endPos)
{
str = str.substr(0, endPos + 1);
}
// trim leading spaces
size_t startPos = str.find_first_not_of(" \t");
if(std::string::npos != startPos)
{
str = str.substr(startPos);
}
return str;
}
inline std::string extractEntry(std::string& valuesString)
{
std::string result;
size_t nextCommaPos = valuesString.find(',');
if(nextCommaPos != std::string::npos)
{
std::string segment = valuesString.substr(0, nextCommaPos);
valuesString.erase(0, nextCommaPos + 1);
result = trimWhitespace(segment);
}
else
{
result = trimWhitespace(valuesString);
valuesString = "";
};
return result;
};
inline std::unordered_map<int32_t, std::string> makeEnumNameMap(std::string enumValuesString)
{
std::unordered_map<int32_t, std::string> nameMap;
int32_t currentEnumValue = 0;
while(enumValuesString != "")
{
std::string currentEnumEntry = extractEntry(enumValuesString);
size_t equalSignPos = currentEnumEntry.find('=');
if(equalSignPos != std::string::npos)
{
std::string rightHandSide = currentEnumEntry.substr(equalSignPos + 1);
currentEnumValue = std::stoi(rightHandSide, 0, 0);
currentEnumEntry.erase(equalSignPos);
}
currentEnumEntry = trimWhitespace(currentEnumEntry);
nameMap[currentEnumValue] = currentEnumEntry;
currentEnumValue++;
}
return nameMap;
}
template<typename Type>
std::vector<Type> makeEnumList(std::string enumValuesString)
{
std::vector<Type> enumList;
int32_t currentEnumValue = 0;
while(enumValuesString != "")
{
std::string currentEnumEntry = extractEntry(enumValuesString);
size_t equalSignPos = currentEnumEntry.find('=');
if(equalSignPos != std::string::npos)
{
std::string rightHandSide = currentEnumEntry.substr(equalSignPos + 1);
currentEnumValue = std::stoi(rightHandSide, 0, 0);
currentEnumEntry.erase(equalSignPos);
}
currentEnumEntry = trimWhitespace(currentEnumEntry);
enumList.push_back(static_cast<Type>(currentEnumValue));
currentEnumValue++;
}
return enumList;
}
inline std::unordered_map<std::string, int32_t> makeEnumValuesMap(std::string enumValuesString)
{
std::unordered_map<std::string, int32_t> nameMap;
int32_t currentEnumValue = 0;
while(enumValuesString != "")
{
std::string currentEnumEntry = extractEntry(enumValuesString);
size_t equalSignPos = currentEnumEntry.find('=');
if(equalSignPos != std::string::npos)
{
std::string rightHandSide = currentEnumEntry.substr(equalSignPos + 1);
currentEnumValue = std::stoi(rightHandSide);
currentEnumEntry.erase(equalSignPos);
}
currentEnumEntry = trimWhitespace(currentEnumEntry);
nameMap[currentEnumEntry] = currentEnumValue;
currentEnumValue++;
}
return nameMap;
}
}
#define smart_enum(Type, ...) enum Type { __VA_ARGS__}; \
static std::unordered_map<int32_t, std::string> Type##_enum_names = smart_enum::makeEnumNameMap(#__VA_ARGS__);\
static std::vector<Type> Type##_list = smart_enum::makeEnumList<Type>(#__VA_ARGS__);\
static std::unordered_map<std::string, int32_t> Type##_enum_values = smart_enum::makeEnumValuesMap(#__VA_ARGS__);\
\
inline const std::string& Type##_to_string(Type value) \
{ \
return Type##_enum_names.at((int32_t)value);\
} \
\
inline const Type Type##_to_enum(const std::string& name)\
{\
return static_cast<Type>(Type##_enum_values.at(name));\
}\
#define smart_enum_class(Type, ...) enum class Type { __VA_ARGS__}; \
static std::unordered_map<int32_t, std::string> Type##_enum_names = smart_enum::makeEnumNameMap(#__VA_ARGS__);\
static std::vector<Type> Type##_list = smart_enum::makeEnumList<Type>(#__VA_ARGS__);\
static std::unordered_map<std::string, int32_t> Type##_enum_values = smart_enum::makeEnumValuesMap(#__VA_ARGS__);\
\
inline const std::string& to_string(Type value) \
{ \
return Type##_enum_names.at((int32_t)value);\
} \
\
inline std::ostream& operator<<(std::ostream& outStream, Type value)\
{\
outStream << to_string(value);\
return outStream;\
}\
\
inline const Type Type##_to_enum_class(const std::string& name)\
{\
return static_cast<Type>(Type##_enum_values.at(name));\
}
| 31.650602 | 118 | 0.606585 | therocode |
1a3bed8cf05e05d2b2bbc5c1da0cb75f6d255c46 | 27,836 | hpp | C++ | alpaka/include/alpaka/pltf/PltfGenericSycl.hpp | ComputationalRadiationPhysics/mallocMC | bb2b32a4a56f7c892e14454bf6aa373a4870c32c | [
"MIT"
] | 25 | 2015-01-30T12:19:48.000Z | 2020-10-30T07:52:45.000Z | alpaka/include/alpaka/pltf/PltfGenericSycl.hpp | ComputationalRadiationPhysics/mallocMC | bb2b32a4a56f7c892e14454bf6aa373a4870c32c | [
"MIT"
] | 101 | 2015-01-06T11:31:26.000Z | 2020-11-09T13:51:19.000Z | alpaka/include/alpaka/pltf/PltfGenericSycl.hpp | ComputationalRadiationPhysics/mallocMC | bb2b32a4a56f7c892e14454bf6aa373a4870c32c | [
"MIT"
] | 10 | 2015-06-10T07:54:30.000Z | 2020-05-06T10:07:39.000Z | /* Copyright 2022 Jan Stephan
*
* This file is part of Alpaka.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#pragma once
#ifdef ALPAKA_ACC_SYCL_ENABLED
# include <alpaka/core/Concepts.hpp>
# include <alpaka/core/Sycl.hpp>
# include <alpaka/dev/Traits.hpp>
# include <alpaka/pltf/Traits.hpp>
# include <CL/sycl.hpp>
# include <iostream>
# include <sstream>
# include <stdexcept>
# include <vector>
namespace alpaka::experimental
{
//! The SYCL device manager.
class PltfGenericSycl : public concepts::Implements<ConceptPltf, PltfGenericSycl>
{
public:
PltfGenericSycl() = delete;
};
} // namespace alpaka::experimental
namespace alpaka::trait
{
//! The SYCL platform device count get trait specialization.
template<typename TPltf>
struct GetDevCount<TPltf, std::enable_if_t<std::is_base_of_v<experimental::PltfGenericSycl, TPltf>>>
{
static auto getDevCount() -> std::size_t
{
ALPAKA_DEBUG_FULL_LOG_SCOPE;
static auto dev_num = []
{
auto platform = sycl::platform{typename TPltf::selector{}};
auto devices = platform.get_devices();
return devices.size();
}();
return dev_num;
}
};
//! The SYCL platform device get trait specialization.
template<typename TPltf>
struct GetDevByIdx<TPltf, std::enable_if_t<std::is_base_of_v<experimental::PltfGenericSycl, TPltf>>>
{
static auto getDevByIdx(std::size_t const& devIdx)
{
ALPAKA_DEBUG_FULL_LOG_SCOPE;
auto exception_handler = [](sycl::exception_list exceptions)
{
auto ss_err = std::stringstream{};
ss_err << "Caught asynchronous SYCL exception(s):\n";
for(std::exception_ptr e : exceptions)
{
try
{
std::rethrow_exception(e);
}
catch(sycl::exception const& err)
{
ss_err << err.what() << " (" << err.code() << ")\n";
}
}
throw std::runtime_error(ss_err.str());
};
static auto pf = sycl::platform{typename TPltf::selector{}};
static auto devices = pf.get_devices();
static auto ctx = sycl::context{devices, exception_handler};
if(devIdx >= devices.size())
{
auto ss_err = std::stringstream{};
ss_err << "Unable to return device handle for device " << devIdx << ". There are only "
<< devices.size() << " SYCL devices!";
throw std::runtime_error(ss_err.str());
}
auto sycl_dev = devices.at(devIdx);
// Log this device.
# if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
printDeviceProperties(sycl_dev);
# elif ALPAKA_DEBUG >= ALPAKA_DEBUG_MINIMAL
std::cout << __func__ << sycl_dev.get_info<info::device::name>() << '\n';
# endif
return typename DevType<TPltf>::type{sycl_dev, ctx};
}
private:
# if ALPAKA_DEBUG >= ALPAKA_DEBUG_FULL
//! Prints all the device properties to std::cout.
static auto printDeviceProperties(sycl::device const& device) -> void
{
ALPAKA_DEBUG_FULL_LOG_SCOPE;
constexpr auto KiB = std::size_t{1024};
constexpr auto MiB = KiB * KiB;
std::cout << "Device type: ";
switch(device.get_info<sycl::info::device::device_type>())
{
case sycl::info::device_type::cpu:
std::cout << "CPU";
break;
case sycl::info::device_type::gpu:
std::cout << "GPU";
break;
case sycl::info::device_type::accelerator:
std::cout << "Accelerator";
break;
case sycl::info::device_type::custom:
std::cout << "Custom";
break;
case sycl::info::device_type::automatic:
std::cout << "Automatic";
break;
case sycl::info::device_type::host:
std::cout << "Host";
break;
// The SYCL spec forbids the return of device_type::all
// Including this here to prevent warnings because of
// missing cases
case sycl::info::device_type::all:
std::cout << "All";
break;
}
std::cout << '\n';
std::cout << "Name: " << device.get_info<sycl::info::device::name>() << '\n';
std::cout << "Vendor: " << device.get_info<sycl::info::device::vendor>() << '\n';
std::cout << "Vendor ID: " << device.get_info<sycl::info::device::vendor_id>() << '\n';
std::cout << "Driver version: " << device.get_info<sycl::info::device::driver_version>() << '\n';
std::cout << "SYCL version: " << device.get_info<sycl::info::device::version>() << '\n';
std::cout << "Backend version: " << device.get_info<sycl::info::device::backend_version>() << '\n';
std::cout << "Aspects: " << '\n';
const auto aspects = device.get_info<sycl::info::device::aspects>();
for(const auto& asp : aspects)
{
switch(asp)
{
// Ignore the hardware types - we already have queried this info above
case sycl::aspect::cpu:
case sycl::aspect::gpu:
case sycl::aspect::accelerator:
case sycl::aspect::custom:
break;
case sycl::aspect::emulated:
std::cout << "\t* emulated\n";
break;
case sycl::aspect::host_debugabble:
std::cout << "\t* debugabble using standard debuggers\n";
break;
case sycl::aspect::fp16:
std::cout << "\t* supports sycl::half precision\n";
break;
case sycl::aspect::fp64:
std::cout << "\t* supports double precision\n";
break;
case sycl::aspect::atomic64:
std::cout << "\t* supports 64-bit atomics\n";
break;
case sycl::aspect::image:
std::cout << "\t* supports images\n";
break;
case sycl::aspect::online_compiler:
std::cout << "\t* supports online compilation of device code\n";
break;
case sycl::aspect::online_linker:
std::cout << "\t* supports online linking of device code\n";
break;
case sycl::aspect::queue_profiling:
std::cout << "\t* supports queue profiling\n";
break;
case sycl::aspect::usm_device_allocations:
std::cout << "\t* supports explicit USM allocations\n";
break;
case sycl::aspect::usm_host_allocations:
std::cout << "\t* can access USM memory allocated by sycl::usm::alloc::host\n";
break;
case sycl::aspect::usm_atomic_host_allocations:
std::cout << "\t* can access USM memory allocated by sycl::usm::alloc::host atomically\n";
break;
case sycl::aspect::usm_shared_allocations:
std::cout << "\t* can access USM memory allocated by sycl::usm::alloc::shared\n";
break;
case sycl::aspect::usm_atomic_shared_allocations:
std::cout << "\t* can access USM memory allocated by sycl::usm::alloc::shared atomically\n";
break;
case sycl::aspect::usm_system_allocations:
std::cout << "\t* can access memory allocated by the system allocator\n";
break;
}
}
std::cout << "Available compute units: " << device.get_info<sycl::info::device::max_compute_units>()
<< '\n';
std::cout << "Maximum work item dimensions: ";
auto dims = device.get_info<sycl::info::device::max_work_item_dimensions>();
std::cout << dims << std::endl;
std::cout << "Maximum number of work items:\n";
const auto wi_1D = device.get_info<sycl::info::device::max_work_item_sizes<1>>();
const auto wi_2D = device.get_info<sycl::info::device::max_work_item_sizes<2>>();
const auto wi_3D = device.get_info<sycl::info::device::max_work_item_sizes<3>>();
std::cout << "\t* 1D: (" << wi_1D.get(0) << ")\n";
std::cout << "\t* 2D: (" << wi_2D.get(0) << ", " << wi_2D.get(1) << ")\n";
std::cout << "\t* 3D: (" << wi_3D.get(0) << ", " << wi_3D.get(1) << ", " << wi_3D.get(2) << ")\n";
std::cout << "Maximum number of work items per work-group: "
<< device.get_info<sycl::info::device::max_work_group_size>() << '\n';
std::cout << "Maximum number of sub-groups per work-group: "
<< device.get_info<sycl::info::device::max_num_sub_groups>() << '\n';
std::cout << "Supported sub-group sizes: ";
auto const sg_sizes = device.get_info<sycl::info::device::sub_group_sizes>();
for(auto const& sz : sg_sizes)
std::cout << sz << ", ";
std::cout << '\n';
std::cout << "Preferred native vector width (char): "
<< device.get_info<sycl::info::device::preferred_vector_width_char>() << '\n';
std::cout << "Native ISA vector width (char): "
<< device.get_info<sycl::info::device::native_vector_width_char>() << '\n';
std::cout << "Preferred native vector width (short): "
<< device.get_info<sycl::info::device::preferred_vector_width_short>() << '\n';
std::cout << "Native ISA vector width (short): "
<< device.get_info<sycl::info::device::native_vector_width_short>() << '\n';
std::cout << "Preferred native vector width (int): "
<< device.get_info<sycl::info::device::preferred_vector_width_int>() << '\n';
std::cout << "Native ISA vector width (int): "
<< device.get_info<sycl::info::device::native_vector_width_int>() << '\n';
std::cout << "Preferred native vector width (long): "
<< device.get_info<sycl::info::device::preferred_vector_width_long>() << '\n';
std::cout << "Native ISA vector width (long): "
<< device.get_info<sycl::info::device::native_vector_width_long>() << '\n';
std::cout << "Preferred native vector width (float): "
<< device.get_info<sycl::info::device::preferred_vector_width_float>() << '\n';
std::cout << "Native ISA vector width (float): "
<< device.get_info<sycl::info::device::native_vector_width_float>() << '\n';
if(device.has_aspect(sycl::aspect::fp64))
{
std::cout << "Preferred native vector width (double): "
<< device.get_info<sycl::info::device::preferred_vector_width_double>() << '\n';
std::cout << "Native ISA vector width (double): "
<< device.get_info<sycl::info::device::native_vector_width_double>() << '\n';
}
if(device.has_aspect(sycl::aspect::fp16))
{
std::cout << "Preferred native vector width (half): "
<< device.get_info<sycl::info::device::preferred_vector_width_half>() << '\n';
std::cout << "Native ISA vector width (half): "
<< device.get_info<sycl::info::device::native_vector_width_half>() << '\n';
}
std::cout << "Maximum clock frequency: " << device.get_info<sycl::info::device::max_clock_frequency>()
<< " MHz\n";
std::cout << "Address space size: " << device.get_info<sycl::info::device::address_bits>() << "-bit\n";
std::cout << "Maximum size of memory object allocation: "
<< device.get_info<sycl::info::device::max_mem_alloc_size>() << " bytes\n";
if(device.has_aspect(sycl::aspect::image))
{
std::cout << "Maximum number of simultaneous image object reads per kernel: "
<< device.get_info<sycl::info::device::max_read_image_args>() << '\n';
std::cout << "Maximum number of simultaneous image writes per kernel: "
<< device.get_info<sycl::info::device::max_write_image_args>() << '\n';
std::cout << "Maximum 1D/2D image width: " << device.get_info<sycl::info::device::image2d_max_width>()
<< " px\n";
std::cout << "Maximum 2D image height: " << device.get_info<sycl::info::device::image2d_max_height>()
<< " px\n";
std::cout << "Maximum 3D image width: " << device.get_info<sycl::info::device::image3d_max_width>()
<< " px\n";
std::cout << "Maximum 3D image height: " << device.get_info<sycl::info::device::image3d_max_height>()
<< " px\n";
std::cout << "Maximum 3D image depth: " << device.get_info<sycl::info::device::image3d_max_depth>()
<< " px\n";
std::cout << "Maximum number of samplers per kernel: "
<< device.get_info<sycl::info::device::max_samplers>() << '\n';
}
std::cout << "Maximum kernel argument size: " << device.get_info<sycl::info::device::max_parameter_size>()
<< " bytes\n";
std::cout << "Memory base address alignment: "
<< device.get_info<sycl::info::device::mem_base_addr_align>() << " bit\n";
auto print_fp_config = [](std::string const& fp, std::vector<sycl::info::fp_config> const& conf)
{
std::cout << fp << " precision floating-point capabilities:\n";
auto find_and_print = [&](sycl::info::fp_config val)
{
auto it = std::find(begin(conf), end(conf), val);
std::cout << (it == std::end(conf) ? "No" : "Yes") << '\n';
};
std::cout << "\t* denorm support: ";
find_and_print(sycl::info::fp_config::denorm);
std::cout << "\t* INF & quiet NaN support: ";
find_and_print(sycl::info::fp_config::inf_nan);
std::cout << "\t* round to nearest even support: ";
find_and_print(sycl::info::fp_config::round_to_nearest);
std::cout << "\t* round to zero support: ";
find_and_print(sycl::info::fp_config::round_to_zero);
std::cout << "\t* round to infinity support: ";
find_and_print(sycl::info::fp_config::round_to_inf);
std::cout << "\t* IEEE754-2008 FMA support: ";
find_and_print(sycl::info::fp_config::fma);
std::cout << "\t* correctly rounded divide/sqrt support: ";
find_and_print(sycl::info::fp_config::correctly_rounded_divide_sqrt);
std::cout << "\t* software-implemented floating point operations: ";
find_and_print(sycl::info::fp_config::soft_float);
};
if(device.has_aspect(sycl::aspect::fp16))
{
const auto fp16_conf = device.get_info<sycl::info::device::half_fp_config>();
print_fp_config("Half", fp16_conf);
}
const auto fp32_conf = device.get_info<sycl::info::device::single_fp_config>();
print_fp_config("Single", fp32_conf);
if(device.has_aspect(sycl::aspect::fp64))
{
const auto fp64_conf = device.get_info<sycl::info::device::double_fp_config>();
print_fp_config("Double", fp64_conf);
}
std::cout << "Global memory cache type: ";
auto has_global_mem_cache = false;
switch(device.get_info<sycl::info::device::global_mem_cache_type>())
{
case sycl::info::global_mem_cache_type::none:
std::cout << "none";
break;
case sycl::info::global_mem_cache_type::read_only:
std::cout << "read-only";
has_global_mem_cache = true;
break;
case sycl::info::global_mem_cache_type::read_write:
std::cout << "read-write";
has_global_mem_cache = true;
break;
}
std::cout << '\n';
if(has_global_mem_cache)
{
std::cout << "Global memory cache line size: "
<< device.get_info<sycl::info::device::global_mem_cache_line_size>() << " bytes\n";
std::cout << "Global memory cache size: "
<< device.get_info<sycl::info::device::global_mem_cache_size>() / KiB << " KiB\n"
}
std::cout << "Global memory size: " << device.get_info<sycl::info::device::global_mem_size>() / MiB
<< " MiB" << std::endl;
std::cout << "Local memory type: ";
auto has_local_memory = false;
switch(device.get_info<sycl::info::device::local_mem_type>())
{
case sycl::info::local_mem_type::none:
std::cout << "none";
break;
case sycl::info::local_mem_type::local:
std::cout << "local";
has_local_memory = true;
break;
case sycl::info::local_mem_type::global:
std::cout << "global";
has_local_memory = true;
break;
}
std::cout << '\n';
if(has_local_memory)
std::cout << "Local memory size: " << device.get_info<sycl::info::device::local_mem_size>() / KiB
<< " KiB\n";
std::cout << "Error correction support: "
<< (device.get_info<sycl::info::device::error_correction_support>() ? "Yes" : "No") << '\n';
auto print_memory_orders = [](std::vector<sycl::memory_order> const& mem_orders)
{
for(auto const& cap : mem_orders)
{
switch(cap)
{
case sycl::memory_order::relaxed:
std::cout << "relaxed";
break;
case sycl::memory_order::acquire:
std::cout << "acquire";
break;
case sycl::memory_order::release:
std::cout << "release";
break;
case sycl::memory_order::acq_rel:
std::cout << "acq_rel";
break;
case sycl::memory_order::seq_cst:
std::cout << "seq_cst";
break;
}
std::cout << ", ";
}
std::cout << '\n';
};
std::cout << "Supported memory orderings for atomic operations: ";
auto const mem_orders = device.get_info<sycl::info::device::atomic_memory_order_capabilities>();
print_memory_orders(mem_orders);
std::cout << "Supported memory orderings for sycl::atomic_fence: ";
auto const fence_orders = device.get_info<sycl::info::device::atomic_fence_order_capabilities>();
print_memory_orders(fence_orders);
auto print_memory_scopes = [](std::vector<sycl::memory_scope> const& mem_scopes)
{
for(auto const& cap : mem_scopes)
{
switch(cap)
{
case sycl::memory_scope::work_item:
std::cout << "work-item";
break;
case sycl::memory_scope::sub_group:
std::cout << "sub-group";
break;
case sycl::memory_scope::work_group:
std::cout << "work-group";
break;
case sycl::memory_scope::device:
std::cout << "device";
break;
case sycl::memory_scope::system:
std::cout << "system";
break;
}
std::cout << ", ";
}
std::cout << '\n';
};
std::cout << "Supported memory scopes for atomic operations: ";
auto const mem_scopes = device.get_info<sycl::info::device::atomic_memory_scope_capabilities>();
print_memory_scopes(mem_scopes);
std::cout << "Supported memory scopes for sycl::atomic_fence: ";
auto const fence_scopes = device.get_info<sycl::info::device::atomic_fence_scope_capabilities>();
print_memory_scopes(fence_scopes);
std::cout << "Device timer resolution: "
<< device.get_info<sycl::info::device::profiling_timer_resolution>() << " ns\n";
std::cout << "Built-in kernels: ";
auto const builtins = device.get_info<sycl::info::device::built_in_kernel_ids>();
for(auto const& b : builtins)
std::cout << b.get_name() << ", ";
std::cout << '\n';
std::cout << "Maximum number of subdevices: ";
auto const max_subs = device.get_info<sycl::info::device::partition_max_sub_devices>();
std::cout << max_subs << '\n';
if(max_subs > 1)
{
std::cout << "Supported partition properties: ";
auto const part_props = device.get_info<sycl::info::device::partition_properties>();
auto has_affinity_domains = false;
for(auto const& prop : part_props)
{
switch(prop)
{
case sycl::info::partition_property::no_partition:
std::cout << "no partition";
break;
case sycl::info::partition_property::partition_equally:
std::cout << "equally";
break;
case sycl::info::partition_property::partition_by_counts:
std::cout << "by counts";
break;
case sycl::info::partition_property::partition_by_affinity_domain:
std::cout << "by affinity domain";
has_affinity_domains = true;
break;
}
std::cout << ", ";
}
std::cout << '\n';
if(has_affinity_domains)
{
std::cout << "Supported partition affinity domains: ";
auto const aff_doms = device.get_info<sycl::info::device::partition_affinity_domains>();
for(auto const& dom : aff_doms)
{
switch(dom)
{
case sycl::info::partition_affinity_domain::not_applicable:
std::cout << "not applicable";
break;
case sycl::info::partition_affinity_domain::numa:
std::cout << "NUMA";
break;
case sycl::info::partition_affinity_domain::L4_cache:
std::cout << "L4 cache";
break;
case sycl::info::partition_affinity_domain::L3_cache:
std::cout << "L3 cache";
break;
case sycl::info::partition_affinity_domain::L2_cache:
std::cout << "L2 cache";
break;
case sycl::info::partition_affinity_domain::L1_cache:
std::cout << "L1 cache";
break;
case sycl::info::partition_affinity_domain::next_partitionable:
std::cout << "next partitionable";
break;
}
std::cout << ", ";
}
std::cout << '\n';
}
std::cout << "Current partition property: ";
switch(device.get_info<sycl::info::device::partition_type_property>())
{
case sycl::info::partition_property::no_partition:
std::cout << "no partition";
break;
case sycl::info::partition_property::partition_equally:
std::cout << "partitioned equally";
break;
case sycl::info::partition_property::partition_by_counts:
std::cout << "partitioned by counts";
break;
case sycl::info::partition_property::partition_by_affinity_domain:
std::cout << "partitioned by affinity domain";
break;
}
std::cout << '\n';
std::cout << "Current partition affinity domain: ";
switch(device.get_info<sycl::info::device::partition_type_affinity_domain>())
{
case sycl::info::partition_affinity_domain::not_applicable:
std::cout << "not applicable";
break;
case sycl::info::partition_affinity_domain::numa:
std::cout << "NUMA";
break;
case sycl::info::partition_affinity_domain::L4_cache:
std::cout << "L4 cache";
break;
case sycl::info::partition_affinity_domain::L3_cache:
std::cout << "L3 cache";
break;
case sycl::info::partition_affinity_domain::L2_cache:
std::cout << "L2 cache";
break;
case sycl::info::partition_affinity_domain::L1_cache:
std::cout << "L1 cache";
break;
case sycl::info::partition_affinity_domain::next_partitionable:
std::cout << "next partitionable";
break;
}
std::cout << '\n';
}
std::cout.flush();
}
# endif
};
} // namespace alpaka::trait
#endif
| 40.459302 | 118 | 0.48854 | ComputationalRadiationPhysics |
1a3c09925f96cbafc46b55a1d1437f6f778604a1 | 2,218 | inl | C++ | src/Point.inl | Leon0402/Project-Hexapod | 98aebd80282560fb7ac86d72b78a798e78f86ab1 | [
"MIT"
] | 6 | 2018-08-10T14:29:16.000Z | 2022-03-31T12:53:28.000Z | src/Point.inl | Leon0402/Project-Hexapod | 98aebd80282560fb7ac86d72b78a798e78f86ab1 | [
"MIT"
] | null | null | null | src/Point.inl | Leon0402/Project-Hexapod | 98aebd80282560fb7ac86d72b78a798e78f86ab1 | [
"MIT"
] | 1 | 2020-06-18T17:23:14.000Z | 2020-06-18T17:23:14.000Z | #ifndef POINT_INL
#define POINT_INL
#ifndef X86_64
#include <math.h>
#else
#include <cmath>
#endif
template <typename T>
Point<T>::Point(T x, T y , T z)
: x {x}, y {y}, z {z} {}
template <typename T>
void Point<T>::rotateX(T angle) {
T y0 = this->y;
T z0 = this->z;
this->y = y0*cos(angle*M_PI/180.0f) - z0*sin(angle*M_PI/180.0f);
this->z = y0*sin(angle*M_PI/180.0f) + z0*cos(angle*M_PI/180.0f);
}
template <typename T>
void Point<T>::rotateY(T angle) {
T x0 = this->x;
T z0 = this->z;
this->x = x0*cos(angle*M_PI/180.0f) + z0*sin(angle*M_PI/180.0f);
this->z = x0*-sin(angle*M_PI/180.0f) + z0*cos(angle*M_PI/180.0f);
}
template <typename T>
void Point<T>::rotateZ(T angle) {
T x0 = this->x;
T y0 = this->y;
this->x = x0*cos(angle*M_PI/180.0f) - y0*sin(angle*M_PI/180.0f);
this->y = x0*sin(angle*M_PI/180.0f) + y0*cos(angle*M_PI/180.0f);
}
template <typename T>
void Point<T>::rotateXYZ(T yawAngle, T pitchAngle, T rollAngle) {
T x0 = this->x;
T y0 = this->y;
T z0 = this->z;
this->x = x0*cos(yawAngle*M_PI/180.0f)*cos(pitchAngle*M_PI/180.0f)
+ y0*(cos(yawAngle*M_PI/180.0f)*sin(pitchAngle*M_PI/180.0f)*sin(rollAngle*M_PI/180.0f) - sin(yawAngle*M_PI/180.0f)*cos(rollAngle*M_PI/180.0f))
+ z0*(cos(yawAngle*M_PI/180.0f)*sin(pitchAngle*M_PI/180.0f)*cos(rollAngle*M_PI/180.0f) + sin(yawAngle*M_PI/180.0f)*sin(rollAngle*M_PI/180.0f));
this->y = x0*sin(yawAngle*M_PI/180.0f)*cos(pitchAngle*M_PI/180.0f)
+ y0*(sin(yawAngle*M_PI/180.0f)*sin(pitchAngle*M_PI/180.0f)*sin(rollAngle*M_PI/180.0f) + cos(yawAngle*M_PI/180.0f)*cos(rollAngle*M_PI/180.0f))
+ z0*(sin(yawAngle*M_PI/180.0f)*sin(pitchAngle*M_PI/180.0f)*cos(rollAngle*M_PI/180.0f) - cos(yawAngle*M_PI/180.0f)*sin(rollAngle*M_PI/180.0f));
this->z = x0*-sin(pitchAngle*M_PI/180.0f)
+ y0*cos(pitchAngle*M_PI/180.0f)*sin(rollAngle*M_PI/180.0f)
+ z0*cos(pitchAngle*M_PI/180.0f)*cos(rollAngle*M_PI/180.0f);
}
template <typename T>
T Point<T>::distanceTo(const Point<T>& point) const {
return sqrt((this->x - point.x)*(this->x - point.x)
+ (this->y - point.y)*(this->y - point.y)
+ (this->z - point.z)*(this->z - point.z));
}
#endif //POINT_INL
| 35.774194 | 153 | 0.638864 | Leon0402 |
1a3fa08aa466b6184c7583bef0b7cef7f17b41fc | 967 | cpp | C++ | Rosewood/src/Rosewood/Benchmark/Benchmark.cpp | dovker/Rosewood | 5131a061632732222ce68e5da5a257b8bda36ea5 | [
"Apache-2.0"
] | 1 | 2020-10-02T15:59:00.000Z | 2020-10-02T15:59:00.000Z | Rosewood/src/Rosewood/Benchmark/Benchmark.cpp | dovker/Rosewood | 5131a061632732222ce68e5da5a257b8bda36ea5 | [
"Apache-2.0"
] | null | null | null | Rosewood/src/Rosewood/Benchmark/Benchmark.cpp | dovker/Rosewood | 5131a061632732222ce68e5da5a257b8bda36ea5 | [
"Apache-2.0"
] | null | null | null | #include "rwpch.h"
#include "Benchmark.h"
namespace Rosewood
{
static std::vector<std::pair<std::string, double>> s_Benchmarks;
void Benchmark::Init()
{
s_Benchmarks = std::vector<std::pair<std::string, double>>();
s_Benchmarks.reserve(20);
}
void Benchmark::Reset()
{
s_Benchmarks.clear();
s_Benchmarks.reserve(20);
}
void Benchmark::Add(std::pair<std::string, double> benchmarkPair)
{
auto t = std::find_if( s_Benchmarks.begin(), s_Benchmarks.end(), [benchmarkPair](std::pair<std::string, double> element){
return element.first == benchmarkPair.first;
});
if(t != s_Benchmarks.end())
{
t->second += benchmarkPair.second;
}
else
{
s_Benchmarks.push_back(benchmarkPair);
}
}
std::vector<std::pair<std::string, double>> Benchmark::GetData()
{
return s_Benchmarks;
}
}
| 24.794872 | 129 | 0.574974 | dovker |
1a4146d8664e6013d2c5eee9254de4306392b91d | 7,685 | cpp | C++ | src/App.cpp | GabrielRavier/nx-fontgen | c9af580a22a3e12deb2746cd61a384f9de39c28a | [
"MIT"
] | 1 | 2021-07-14T11:16:05.000Z | 2021-07-14T11:16:05.000Z | src/App.cpp | GabrielRavier/nx-fontgen | c9af580a22a3e12deb2746cd61a384f9de39c28a | [
"MIT"
] | null | null | null | src/App.cpp | GabrielRavier/nx-fontgen | c9af580a22a3e12deb2746cd61a384f9de39c28a | [
"MIT"
] | 1 | 2018-08-13T16:06:15.000Z | 2018-08-13T16:06:15.000Z | #include "App.h"
#include "ProgramOptions.h"
#include <SDL.h>
#include <string>
#include <fstream>
#include <array>
#include <limits>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include "sdlSavePng/savepng.h"
#include "FontInfo.h"
std::vector<rbp::RectSize> App::getSrcRects(const Glyphs &glyphs, int additionalWidth, int additionalHeight)
{
std::vector<rbp::RectSize> result;
for (auto& kv : glyphs)
{
const GlyphInfo& glyphInfo = kv.second;
if (!glyphInfo.isEmpty())
{
rbp::RectSize rs;
rs.width = glyphInfo.getWidth() + additionalHeight;
rs.height = glyphInfo.getHeight() + additionalWidth;
rs.tag = kv.first;
result.push_back(rs);
}
}
return result;
}
App::Glyphs App::collectGlyphInfo(TTF_Font *font,
const std::set<uint32_t> &codes,
uint32_t maxTextureSizeX,
uint32_t maxTextureSizeY)
{
int fontAscent = TTF_FontAscent(font);
Glyphs glyphs;
for (auto& id : codes)
{
if ((id > 0xFFFF) || (TTF_GlyphIsProvided(font, static_cast<Uint16>(id))==0))
{
std::cout << "warning: glyph " << id << " not found " << std::endl;
continue;
}
GlyphInfo glyphInfo;
TTF_GlyphMetrics(font, static_cast<Uint16>(id),
&glyphInfo.minx,
&glyphInfo.maxx,
&glyphInfo.miny,
&glyphInfo.maxy,
&glyphInfo.advance);
if (fontAscent < glyphInfo.maxy)
std::cerr << "Warning: invalid glyph (maxy > ascent)" << std::endl;
if ( (glyphInfo.getWidth() > static_cast<int>(maxTextureSizeX)) || (glyphInfo.getHeight() > static_cast<int>(maxTextureSizeY)))
throw std::runtime_error("no room for glyph");
//TODO: add more checks for glyph.
if (glyphInfo.isInvalid())
throw std::runtime_error("invalid glyph (zero or negative width or height)");
//TODO: emplace.
glyphs[id] = glyphInfo;
}
return glyphs;
}
uint16_t App::arrangeGlyphs(Glyphs& glyphs, const Config& config)
{
std::vector< rbp::RectSize > srcRects = getSrcRects(glyphs, config.spacing.hor,
config.spacing.ver);
rbp::MaxRectsBinPack mrbp;
uint16_t pageCount = 0;
for (;;)
{
//TODO: check negative dimension.
mrbp.Init(config.textureSize.w - config.spacing.hor, config.textureSize.h - config.spacing.ver);
std::vector<rbp::Rect> readyRects;
mrbp.Insert( srcRects, readyRects, rbp::MaxRectsBinPack::RectBestAreaFit );
if ( readyRects.empty() )
{
if ( !srcRects.empty() )
throw std::runtime_error("can not fit glyphs to texture");
break;
}
for ( auto r: readyRects )
{
glyphs[r.tag].x = r.x + config.spacing.hor;
glyphs[r.tag].y = r.y + config.spacing.ver;
glyphs[r.tag].page = pageCount;
}
pageCount++;
}
return pageCount;
}
int App::getDigitCount(uint16_t x)
{
return (x < 10 ? 1 :
(x < 100 ? 2 :
(x < 1000 ? 3 :
(x < 10000 ? 4 :
5))));
}
void App::execute(int argc, char* argv[])
{
const Config config = helpers::parseCommandLine(argc, const_cast<const char**>(argv));
const std::string dataFilePath = config.output + ".fnt";
const std::string outputName = config.output;
// boost::filesystem::create_directory(outputDirPath);
// SDL_Init(0);
TTF_Init();
TTF_Font *font = TTF_OpenFont(config.fontFile.c_str(), config.fontSize);
if (!font)
throw std::runtime_error("font file not found");
Glyphs glyphs = collectGlyphInfo(font, config.chars, config.textureSize.w, config.textureSize.h);
const uint16_t pageCount = arrangeGlyphs(glyphs, config);
const int fontAscent = TTF_FontAscent(font);
/////////////////////////////////////////////////////////////
std::vector<std::string> pageNames;
//TODO: should we decrement pageCount before calcualte?
int pageNameDigits = getDigitCount(pageCount);
for (size_t page = 0; page < pageCount; ++page)
{
SDL_Surface* outputSurface = SDL_CreateRGBSurface(0, config.textureSize.w, config.textureSize.h, 32,
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
// If the color value contains an alpha component then the destination is simply
// filled with that alpha information, no blending takes place.
// SDL_FillRect(outputSurface, NULL, 0);
for (auto kv: glyphs)
{
const GlyphInfo& glyph = kv.second;
if (glyph.page != static_cast<int>(page))
continue;
SDL_Surface *glyphSurface;
if (config.antialias)
glyphSurface = TTF_RenderGlyph_Blended(font, kv.first, SDL_Color{255,255,255,255});
else
glyphSurface = TTF_RenderGlyph_Solid(font, kv.first, SDL_Color{255,255,255,255});
int x = glyph.x - glyph.minx;
int y = glyph.y - (fontAscent - glyph.maxy);
if (!glyph.isEmpty())
{
SDL_Rect dstRect{x, y, glyph.getWidth(), glyph.getHeight()};
SDL_BlitSurface(glyphSurface, NULL, outputSurface, &dstRect);
}
SDL_FreeSurface(glyphSurface);
}
std::stringstream ss;
ss << outputName << "_" << std::setfill ('0') << std::setw(pageNameDigits) << page << ".png";
std::string pageName = ss.str();
std::string baseName = pageName.substr(pageName.rfind('/')+1);
pageNames.push_back(baseName);
SDL_SavePNG(outputSurface, pageName.c_str());
}
/////////////////////////////////////////////////////////////
FontInfo f;
f.info.face = TTF_FontFaceFamilyName(font);
f.info.size = config.fontSize;
f.info.unicode = true;
f.info.aa = static_cast<uint8_t>(config.antialias);
f.info.padding.up = 0;
f.info.padding.right = 0;
f.info.padding.down = 0;
f.info.padding.left = 0;
f.info.spacing.horizontal = static_cast<uint8_t>(config.spacing.hor);
f.info.spacing.vertical = static_cast<uint8_t>(config.spacing.ver);
f.common.lineHeight = static_cast<uint16_t>(TTF_FontLineSkip(font));
f.common.base = static_cast<uint16_t>(fontAscent);
f.common.scaleW = static_cast<uint16_t>(config.textureSize.w);
f.common.scaleH = static_cast<uint16_t>(config.textureSize.h);
f.common.pages = pageCount;
for (size_t i = 0; i < pageCount; ++i )
f.pages.push_back(pageNames.at(i));
for (auto kv: glyphs)
{
//TODO: page = 0 for empty flyphs.
const GlyphInfo &glyph = kv.second;
FontInfo::Char c;
c.id = kv.first;
if (!glyph.isEmpty())
{
c.x = static_cast<uint16_t>(glyph.x);
c.y = static_cast<uint16_t>(glyph.y);
c.width = static_cast<uint16_t>(glyph.getWidth());
c.height = static_cast<uint16_t>(glyph.getHeight());
c.page = static_cast<uint8_t>(glyph.page);
c.xoffset = static_cast<int16_t>(glyph.minx);
c.yoffset = static_cast<int16_t>(fontAscent - glyph.maxy);
}
c.xadvance = static_cast<int16_t>(glyph.advance);
c.chnl = 15;
f.chars.push_back(c);
}
f.writeToJsonFile(dataFilePath);
}
| 32.702128 | 135 | 0.572154 | GabrielRavier |
1a426c9d20ce8d13da6473e2d49c68acc0c96fc3 | 282 | hpp | C++ | src/service/parse/abstract_object_parser.hpp | JustSlavic/gl2 | 1b4752d3273a1e401c970e18ae7151bba004a4ec | [
"MIT"
] | null | null | null | src/service/parse/abstract_object_parser.hpp | JustSlavic/gl2 | 1b4752d3273a1e401c970e18ae7151bba004a4ec | [
"MIT"
] | 2 | 2021-05-29T20:34:50.000Z | 2021-05-29T20:39:25.000Z | src/service/parse/abstract_object_parser.hpp | JustSlavic/gl2 | 1b4752d3273a1e401c970e18ae7151bba004a4ec | [
"MIT"
] | null | null | null | #pragma once
#include <defines.h>
#include <service/abstract_object.hpp>
namespace service {
struct abstract_object_parser {
void* impl = nullptr;
void initialize (const char* text, size_t size);
void terminate ();
abstract_object parse ();
};
} // service
| 13.428571 | 52 | 0.684397 | JustSlavic |
1a4601e614ca78c5835226f8de71526bee8eae00 | 5,039 | cpp | C++ | src/vk/device.cpp | fur-id/sample | 8c68498ad14cc5f8869df2b9ea4ff2a91be9b558 | [
"MIT"
] | null | null | null | src/vk/device.cpp | fur-id/sample | 8c68498ad14cc5f8869df2b9ea4ff2a91be9b558 | [
"MIT"
] | null | null | null | src/vk/device.cpp | fur-id/sample | 8c68498ad14cc5f8869df2b9ea4ff2a91be9b558 | [
"MIT"
] | null | null | null | #include "vk_private.h"
#include <set>
void createDevice(std::function<void(VkPhysicalDevice pdev, VkPhysicalDeviceFeatures& enabledFeatures)> validator) {
uint32_t count;
vkcall(vkEnumeratePhysicalDevices(ctx.instance, &count, nullptr));
std::vector<VkPhysicalDevice> physicalDevices(count);
vkcall(vkEnumeratePhysicalDevices(ctx.instance, &count, physicalDevices.data()));
struct SuitableDevice {
VkPhysicalDevice physicalDevice;
uint32_t renderQueueFamilyIndex;
uint32_t transferQueueFamilyIndex;
std::vector<const char*> enabledExtensionNames;
VkPhysicalDeviceFeatures features{};
};
std::vector<SuitableDevice> suitableDevices;
suitableDevices.reserve(count);
for (VkPhysicalDevice pdev : physicalDevices) {
SuitableDevice sd{};
sd.physicalDevice = pdev;
try {
vkcall(vkEnumerateDeviceExtensionProperties(pdev, nullptr, &count, nullptr));
std::vector<VkExtensionProperties> availableExtensions(count);
vkcall(vkEnumerateDeviceExtensionProperties(pdev, nullptr, &count, availableExtensions.data()));
std::vector<const char*> requiredExtensionNames{
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
};
for (const char* name : requiredExtensionNames) {
bool found = false;
for (VkExtensionProperties& props : availableExtensions) {
if (std::string(name) == props.extensionName) {
found = true;
sd.enabledExtensionNames.push_back(name);
break;
}
}
expect(found);
}
validator(pdev, sd.features);
vkGetPhysicalDeviceQueueFamilyProperties(pdev, &count, nullptr);
std::vector<VkQueueFamilyProperties> queueProps(count);
vkGetPhysicalDeviceQueueFamilyProperties(pdev, &count, queueProps.data());
for (uint32_t index = 0; index < count; index++) {
if ((queueProps[index].queueFlags & VK_QUEUE_GRAPHICS_BIT) == 0)
continue;
if ((queueProps[index].queueFlags & VK_QUEUE_COMPUTE_BIT) == 0)
continue;
VkBool32 p;
vkcall(vkGetPhysicalDeviceSurfaceSupportKHR(pdev, index, ctx.surface, &p));
if (!p)
continue;
sd.renderQueueFamilyIndex = index;
break;
}
sd.transferQueueFamilyIndex = sd.renderQueueFamilyIndex;
for (uint32_t index = 0; index < count; index++) {
if (sd.renderQueueFamilyIndex == index)
continue;
if ((queueProps[index].queueFlags & VK_QUEUE_TRANSFER_BIT) == 0)
continue;
sd.transferQueueFamilyIndex = index;
break;
}
suitableDevices.push_back(sd);
} catch (...) {
}
}
expect(!suitableDevices.empty());
SuitableDevice& sd = suitableDevices[0];
std::set<uint32_t> indices{
sd.renderQueueFamilyIndex,
sd.transferQueueFamilyIndex,
};
std::vector<VkDeviceQueueCreateInfo> qci(indices.size());
uint32_t i = 0;
float prio = 1.0f;
for (uint32_t index : indices) {
qci[i].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
qci[i].queueCount = 1;
qci[i].queueFamilyIndex = index;
qci[i].pQueuePriorities = &prio;
i++;
}
std::vector<const char*> enabledLayerNames {
#if !defined(NDEBUG)
"VK_LAYER_LUNARG_standard_validation",
#endif
};
VkDeviceCreateInfo createInfo{};
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
createInfo.enabledLayerCount = static_cast<uint32_t>(enabledLayerNames.size());
createInfo.ppEnabledLayerNames = enabledLayerNames.data();
createInfo.enabledExtensionCount = static_cast<uint32_t>(sd.enabledExtensionNames.size());
createInfo.ppEnabledExtensionNames = sd.enabledExtensionNames.data();
createInfo.pEnabledFeatures = &sd.features;
createInfo.queueCreateInfoCount = static_cast<uint32_t>(qci.size());
createInfo.pQueueCreateInfos = qci.data();
vkcall(vkCreateDevice(sd.physicalDevice, &createInfo, nullptr, &ctx.device));
#define VKF_DEVICE(func) \
func = reinterpret_cast<PFN_##func>(vkGetDeviceProcAddr(ctx.device, #func)); \
expect(func != nullptr);
#include "device.inl"
ctx.physicalDevice = sd.physicalDevice;
ctx.renderQueueFamilyIndex = sd.renderQueueFamilyIndex;
ctx.transferQueueFamilyIndex = sd.transferQueueFamilyIndex;
vkGetDeviceQueue(ctx.device, ctx.renderQueueFamilyIndex, 0, &ctx.renderQueue);
vkGetDeviceQueue(ctx.device, ctx.transferQueueFamilyIndex, 0, &ctx.transferQueue);
}
void destroyDevice() {
if (ctx.device) {
vkDestroyDevice(ctx.device, nullptr);
}
}
| 42.70339 | 116 | 0.631078 | fur-id |
1a4696dd04340b3c8f7c672dd53fd73cfb828e81 | 8,556 | cc | C++ | src/cards.cc | thomasmarsh/monkey | de79536cad78371cf25ea0c26a492f700e2c92f8 | [
"MIT"
] | 6 | 2016-08-31T06:26:32.000Z | 2022-02-10T23:28:29.000Z | src/cards.cc | thomasmarsh/monkey | de79536cad78371cf25ea0c26a492f700e2c92f8 | [
"MIT"
] | 1 | 2017-04-26T16:37:35.000Z | 2017-04-26T16:37:35.000Z | src/cards.cc | thomasmarsh/monkey | de79536cad78371cf25ea0c26a492f700e2c92f8 | [
"MIT"
] | null | null | null | #include "cards.h"
#include "log.h"
#include <json11.hpp>
#include <fstream>
using namespace json11;
using CardTable = std::vector<Card>;
std::map<Action,std::string> CARD_ACTION_DESC;
CardTable CARD_TABLE_PROTO;
CardTable CARD_TABLE;
const Card& Card::Get(CardRef card) {
return CARD_TABLE[card];
}
std::string ActionDescription(Action a) {
auto it = CARD_ACTION_DESC.find(a);
assert(it != CARD_ACTION_DESC.end());
return it->second;
}
static void ExpandCardTable() {
assert(CARD_TABLE.empty());
CARD_TABLE.reserve(NUM_CARDS);
CardRef id = 0;
CardRef prototype = 0;
for (auto &e : CARD_TABLE_PROTO) {
for (CardRef i=0; i < e.quantity; ++i) {
auto copy = e;
copy.id = id;
copy.prototype = prototype;
CARD_TABLE.push_back(copy);
++id;
}
CARD_TABLE_PROTO[prototype].prototype = prototype;
++prototype;
}
if (CARD_TABLE.size() != NUM_CARDS) {
ERROR("CARD_TABLE.size() = {} (expected {})", CARD_TABLE.size(), NUM_CARDS);
}
}
static Affinity ParseAffinity(const std::string &s) {
if (s == "NONE") { return Affinity::NONE; }
else if (s == "MONK") { return Affinity::MONK; }
else if (s == "CLAN") { return Affinity::CLAN; }
ERROR("unexpected value: {}", s);
}
static CardType ParseCardType(const std::string &s) {
if (s == "CHARACTER") { return CardType::CHARACTER; }
else if (s == "STYLE") { return CardType::STYLE; }
else if (s == "WEAPON") { return CardType::WEAPON; }
else if (s == "WRENCH") { return CardType::WRENCH; }
else if (s == "EVENT") { return CardType::EVENT; }
ERROR("unexpected value: {}", s);
}
static ArgType ParseArgType(const std::string &s) {
if (s == "NONE") { return ArgType::NONE; }
else if (s == "VISIBLE") { return ArgType::VISIBLE; }
else if (s == "RECV_STYLE") { return ArgType::RECV_STYLE; }
else if (s == "RECV_WEAPON") { return ArgType::RECV_WEAPON; }
else if (s == "EXPOSED_CHAR") { return ArgType::EXPOSED_CHAR; }
else if (s == "EXPOSED_STYLE") { return ArgType::EXPOSED_STYLE; }
else if (s == "EXPOSED_WEAPON") { return ArgType::EXPOSED_WEAPON; }
else if (s == "VISIBLE_CHAR_OR_HOLD") { return ArgType::VISIBLE_CHAR_OR_HOLD; }
else if (s == "OPPONENT") { return ArgType::OPPONENT; }
else if (s == "OPPONENT_HAND") { return ArgType::OPPONENT_HAND; }
else if (s == "HAND") { return ArgType::HAND; }
else if (s == "DRAW_PILE") { return ArgType::DRAW_PILE; }
ERROR("unexpected value: {}", s);
}
static Special ParseSpecial(const std::string &s) {
if (s == "NONE") { return Special::NONE; }
else if (s == "IMMUNE") { return Special::IMMUNE; }
else if (s == "DOUBLE_STYLES") { return Special::DOUBLE_STYLES; }
else if (s == "STYLE_PLUS_ONE") { return Special::STYLE_PLUS_ONE; }
else if (s == "TWO_WEAPONS") { return Special::TWO_WEAPONS; }
else if (s == "DOUBLE_WEAPON_VALUE") { return Special::DOUBLE_WEAPON_VALUE; }
else if (s == "IGNORE_AFFINITY") { return Special::IGNORE_AFFINITY; }
else if (s == "NO_STYLES") { return Special::NO_STYLES; }
else if (s == "NO_WEAPONS") { return Special::NO_WEAPONS; }
ERROR("unexpected value: {}", s);
}
static Action ParseAction(const std::string &s) {
if (s == "NONE") { return Action::NONE; }
else if (s == "PASS") { return Action::PASS; }
else if (s == "CONCEDE") { return Action::CONCEDE; }
else if (s == "CLEAR_FIELD") { return Action::CLEAR_FIELD; }
else if (s == "STEAL_CARD") { return Action::STEAL_CARD; }
else if (s == "TRADE_HAND") { return Action::TRADE_HAND; }
else if (s == "DISCARD_ONE") { return Action::DISCARD_ONE; }
else if (s == "DRAW_CARD") { return Action::DRAW_CARD; }
else if (s == "PLAY_WEAPON") { return Action::PLAY_WEAPON; }
else if (s == "PLAY_STYLE") { return Action::PLAY_STYLE; }
else if (s == "DISARM_CHARACTER") { return Action::DISARM_CHARACTER; }
else if (s == "KNOCKOUT_CHARACTER") { return Action::KNOCKOUT_CHARACTER; }
else if (s == "KNOCKOUT_STYLE") { return Action::KNOCKOUT_STYLE; }
else if (s == "KNOCKOUT_WEAPON") { return Action::KNOCKOUT_WEAPON; }
else if (s == "PLAY_WEAPON_RETAIN") { return Action::PLAY_WEAPON_RETAIN; }
else if (s == "CAPTURE_WEAPON") { return Action::CAPTURE_WEAPON; }
else if (s == "PLAY_CHARACTER") { return Action::PLAY_CHARACTER; }
else if (s == "E_DRAW_TWO_SKILLS") { return Action::E_DRAW_TWO_SKILLS; }
else if (s == "E_NO_STYLES") { return Action::E_NO_STYLES; }
else if (s == "E_DRAW_ONE_CHAR") { return Action::E_DRAW_ONE_CHAR; }
else if (s == "E_NO_WEAPONS") { return Action::E_NO_WEAPONS; }
else if (s == "E_RANDOM_STEAL") { return Action::E_RANDOM_STEAL; }
else if (s == "E_DISCARD_TWO") { return Action::E_DISCARD_TWO; }
else if (s == "E_CHAR_BONUS") { return Action::E_CHAR_BONUS; }
else if (s == "E_INVERT_VALUE") { return Action::E_INVERT_VALUE; }
ERROR("unexpected value: {}", s);
}
static std::string LoadFile(const std::string &fname) {
std::ifstream t(fname);
std::string str;
if (!t.is_open()) {
return str;
}
t.seekg(0, std::ios::end);
str.reserve(t.tellg());
t.seekg(0, std::ios::beg);
str.assign(std::istreambuf_iterator<char>(t),
std::istreambuf_iterator<char>());
return str;
}
static std::string LoadCardsJson() {
auto jsonStr = LoadFile("resources/cards.json");
if (jsonStr.empty()) {
jsonStr = LoadFile("../resources/cards.json");
}
assert(!jsonStr.empty());
return jsonStr;
}
static void ValidateCardJson(const Json &json) {
#ifndef NDEBUG
assert(json.is_object());
std::string error;
bool has_shape = json.has_shape({
{ "quantity", Json::NUMBER },
{ "type", Json::STRING },
{ "affinity", Json::STRING },
{ "special", Json::STRING },
{ "action", Json::STRING },
{ "arg_type", Json::STRING },
//{ "isUber", Json::BOOL },
{ "face_value", Json::NUMBER },
//{ "inverted_value", Json::NUMBER },
{ "label", Json::STRING },
{ "description", Json::STRING },
}, error);
if (!error.empty()) {
WARN("has_shape error: {}", error);
}
assert(has_shape);
#endif
}
static void SetInverseValue(Card &c) {
if (c.type == CHARACTER) {
if (c.face_value != 6) {
switch (c.affinity) {
case Affinity::CLAN:
c.inverted_value = 5-c.face_value;
return;
case Affinity::MONK:
c.inverted_value = 7-c.face_value;
return;
default:
break;
}
}
}
c.inverted_value = c.face_value;
}
static void ParseCard(const Json &json) {
ValidateCardJson(json);
Card proto;
proto.quantity = json["quantity"].int_value();
proto.type = ParseCardType(json["type"].string_value());
proto.affinity = ParseAffinity(json["affinity"].string_value());
proto.special = ParseSpecial(json["special"].string_value());
proto.action = ParseAction(json["action"].string_value());
proto.arg_type = ParseArgType(json["arg_type"].string_value());
//proto.isUber = json["isUber"].bool_value();
proto.face_value = json["face_value"].int_value();
proto.label = json["label"].string_value();
SetInverseValue(proto);
CARD_TABLE_PROTO.push_back(proto);
CARD_ACTION_DESC[proto.action] = json["description"].string_value();
}
static void ParseJson(const Json &json) {
assert(json.is_array());
auto cards = json.array_items();
assert(!cards.empty());
CARD_TABLE_PROTO.clear();
CARD_TABLE_PROTO.reserve(cards.size());
for (const auto &card : cards) {
ParseCard(card);
}
}
static void LoadCardTableProto() {
std::string error;
auto json = Json::parse(LoadCardsJson(), error);
if (!error.empty()) {
ERROR("JSON parse error: {}", error);
}
ParseJson(json);
}
void LoadCards() {
LoadCardTableProto();
ExpandCardTable();
assert(CARD_TABLE.size() == NUM_CARDS);
}
| 35.65 | 84 | 0.584385 | thomasmarsh |
1a477ec810c4ef21fd2a882989d812e1ddbfa0af | 1,048 | cpp | C++ | test/unit/property_map.cpp | hotgloupi/configure | 888cf725c93df5a1cf01794cc0a581586a82855c | [
"BSD-3-Clause"
] | 1 | 2015-11-13T10:37:35.000Z | 2015-11-13T10:37:35.000Z | test/unit/property_map.cpp | hotgloupi/configure | 888cf725c93df5a1cf01794cc0a581586a82855c | [
"BSD-3-Clause"
] | 19 | 2015-02-10T17:18:58.000Z | 2015-07-11T11:31:08.000Z | test/unit/property_map.cpp | hotgloupi/configure | 888cf725c93df5a1cf01794cc0a581586a82855c | [
"BSD-3-Clause"
] | null | null | null |
#include <configure/PropertyMap.hpp>
BOOST_AUTO_TEST_CASE(dirtyness)
{
configure::PropertyMap m;
BOOST_CHECK_EQUAL(m.dirty(), false);
m.set<std::string>("test", "lol");
BOOST_CHECK_EQUAL(m.dirty(), true);
m.mark_clean();
BOOST_CHECK_EQUAL(m.dirty(), false);
m.set<std::string>("test", "lol");
BOOST_CHECK_EQUAL(m.dirty(), false);
m.set<std::string>("test", "lol2");
BOOST_CHECK_EQUAL(m.dirty(), true);
}
BOOST_AUTO_TEST_CASE(dirty_key)
{
configure::PropertyMap m;
BOOST_CHECK_EQUAL(m.dirty("test"), false);
m.set<std::string>("test", "lol");
BOOST_CHECK_EQUAL(m.dirty("test"), true);
BOOST_CHECK_EQUAL(m.dirty("TEST"), true);
m.mark_clean();
BOOST_CHECK_EQUAL(m.dirty("TEST"), false);
BOOST_CHECK_EQUAL(m.dirty("test"), false);
m.set<std::string>("tesT", "lol");
BOOST_CHECK_EQUAL(m.dirty("TEST"), false);
BOOST_CHECK_EQUAL(m.dirty("test"), false);
m.set<std::string>("TesT", "lol2");
BOOST_CHECK_EQUAL(m.dirty("test"), true);
BOOST_CHECK_EQUAL(m.dirty("Test"), true);
BOOST_CHECK_EQUAL(m.dirty("tesT"), true);
}
| 24.372093 | 43 | 0.693702 | hotgloupi |
1a47b95dfd18ccdecdf8f894674599ae22fcf099 | 61,234 | cpp | C++ | src/ciyam_files.cpp | Aloz1/ciyam | 424b47fd73fa1f6a1a076f8908ae7086eeeeedc5 | [
"MIT"
] | null | null | null | src/ciyam_files.cpp | Aloz1/ciyam | 424b47fd73fa1f6a1a076f8908ae7086eeeeedc5 | [
"MIT"
] | null | null | null | src/ciyam_files.cpp | Aloz1/ciyam | 424b47fd73fa1f6a1a076f8908ae7086eeeeedc5 | [
"MIT"
] | null | null | null | // Copyright (c) 2013-2018 CIYAM Developers
//
// Distributed under the MIT/X11 software license, please refer to the file license.txt
// in the root project directory or http://www.opensource.org/licenses/mit-license.php.
#ifdef PRECOMPILE_H
# include "precompile.h"
#endif
#pragma hdrstop
#ifndef HAS_PRECOMPILED_STD_HEADERS
# include <cstring>
# include <map>
# include <set>
# include <memory>
# include <fstream>
# include <stdexcept>
# ifdef __GNUG__
# include <unistd.h>
# endif
#endif
#define CIYAM_BASE_IMPL
#include "ciyam_files.h"
#include "ods.h"
#include "sio.h"
#include "regex.h"
#include "base64.h"
#include "config.h"
#include "format.h"
#include "sha256.h"
#include "sockets.h"
#include "threads.h"
#include "progress.h"
#include "date_time.h"
#include "utilities.h"
#include "ciyam_base.h"
#include "file_utils.h"
#include "fs_iterator.h"
#include "ciyam_variables.h"
#include "ods_file_system.h"
#ifdef ZLIB_SUPPORT
# include <zlib.h>
#endif
using namespace std;
namespace
{
const int c_status_info_pad_len = 10;
const char* const c_timestamp_tag_prefix = "ts.";
const char* const c_important_file_suffix = "!";
const char* const c_file_archive_path = "path";
const char* const c_file_archive_size_avail = "size_avail";
const char* const c_file_archive_size_limit = "size_limit";
const char* const c_file_archive_status_info = "status_info";
const char* const c_folder_archive_files_folder = "files";
const char* const c_file_archive_status_is_full = "is full";
const char* const c_file_archive_status_bad_write = "bad write";
const char* const c_file_archive_status_bad_access = "bad access";
const char* const c_file_archive_status_status_bad_create = "bad create";
#include "ciyam_constants.h"
mutex g_mutex;
map< string, string > g_tag_hashes;
multimap< string, string > g_hash_tags;
size_t g_total_files = 0;
int64_t g_total_bytes = 0;
void create_directory_if_not_exists( const string& dir_name )
{
string cwd( get_cwd( ) );
bool rc;
set_cwd( dir_name, &rc );
if( !rc )
{
create_dir( dir_name, &rc, ( dir_perms )c_directory_perm_val );
if( !rc )
throw runtime_error( "unable to create directory '" + dir_name + "'" );
}
else
set_cwd( cwd );
}
string construct_file_name_from_hash( const string& hash,
bool create_directory = false, bool check_hash_pattern = true )
{
if( check_hash_pattern )
{
regex expr( c_regex_hash_256 );
if( expr.search( hash ) == string::npos )
throw runtime_error( "unexpected hash '" + hash + "'" );
}
string filename( c_files_directory );
filename += '/';
filename += lower( hash.substr( 0, 2 ) );
if( create_directory )
create_directory_if_not_exists( filename );
filename += '/';
filename += lower( hash.substr( 2 ) );
return filename;
}
void validate_list( const string& data, bool* p_rc = 0 )
{
vector< string > list_items;
split( data, list_items, '\n' );
for( size_t i = 0; i < list_items.size( ); i++ )
{
string next_list_item( list_items[ i ] );
string::size_type pos = next_list_item.find( ' ' );
if( !has_file( next_list_item.substr( 0, pos ) ) )
{
if( p_rc )
{
*p_rc = false;
return;
}
else
throw runtime_error( "file '" + next_list_item.substr( 0, pos ) + "' does not exist" );
}
}
if( p_rc )
*p_rc = true;
}
void validate_hash_with_uncompressed_content( const string& hash, unsigned char* p_data, unsigned long length )
{
bool okay = false;
if( length )
{
// NOTE: Although the compressed bit flag could be still set it is
// required that the data checked here will have been uncompressed
// first.
bool is_compressed = ( p_data[ 0 ] & c_file_type_val_compressed );
if( is_compressed )
p_data[ 0 ] &= ~c_file_type_val_compressed;
sha256 test_hash;
test_hash.update( p_data, length );
if( lower( hash ) == test_hash.get_digest_as_string( ) )
okay = true;
if( is_compressed )
p_data[ 0 ] |= c_file_type_val_compressed;
}
if( !okay )
throw runtime_error( "invalid content for file hash '" + hash + "'" );
}
string get_archive_status( const string& path )
{
string retval( c_okay );
string cwd( get_cwd( ) );
string tmp_filename( "~" + uuid( ).as_string( ) );
try
{
bool rc;
set_cwd( path, &rc );
if( !rc )
retval = string( c_file_archive_status_bad_access );
else
{
ofstream outf( tmp_filename.c_str( ), ios::out );
if( !outf )
retval = string( c_file_archive_status_status_bad_create );
else
{
outf << "." << endl;
outf.flush( );
if( !outf.good( ) )
retval = string( c_file_archive_status_bad_write );
}
}
file_remove( tmp_filename );
set_cwd( cwd );
return retval;
}
catch( ... )
{
file_remove( tmp_filename );
set_cwd( cwd );
throw;
}
}
bool path_already_used_in_archive( const string& path )
{
bool retval = false;
vector< string > paths;
list_file_archives( true, &paths );
for( size_t i = 0; i < paths.size( ); i++ )
{
if( paths[ i ] == path )
{
retval = true;
break;
}
}
return retval;
}
bool has_archived_file( ods_file_system& ods_fs, const string& hash, string* p_archive = 0 )
{
bool retval = false;
temporary_set_folder tmp_folder( ods_fs, "/" );
vector< string > paths;
string all_archives( list_file_archives( true, &paths ) );
string archive;
vector< string > archives;
split( all_archives, archives, '\n' );
if( paths.size( ) != archives.size( ) )
throw runtime_error( "unexpected paths.size( ) != archives.size( )" );
for( size_t i = 0; i < archives.size( ); i++ )
{
archive = archives[ i ];
if( p_archive && !p_archive->empty( ) && archive != *p_archive )
continue;
ods_fs.set_root_folder( c_file_archives_folder );
ods_fs.set_folder( archive );
ods_fs.set_folder( c_folder_archive_files_folder );
if( ods_fs.has_file( hash ) )
{
retval = true;
if( p_archive )
*p_archive = archive;
break;
}
}
return retval;
}
}
void list_mutex_lock_ids_for_ciyam_files( ostream& outs )
{
outs << "ciyam_files::g_mutex = " << g_mutex.get_lock_id( ) << '\n';
}
size_t get_total_files( )
{
guard g( g_mutex );
return g_total_files;
}
int64_t get_total_bytes( )
{
guard g( g_mutex );
return g_total_bytes;
}
string get_file_stats( )
{
guard g( g_mutex );
string s;
size_t max_num = get_files_area_item_max_num( );
size_t max_size = get_files_area_item_max_size( );
int64_t max_bytes = ( int64_t )max_num * ( int64_t )max_size;
s = '[' + to_string( g_total_files ) + '/' + to_string( max_num )
+ ']' + format_bytes( g_total_bytes ) + '/' + format_bytes( max_bytes );
s += " ";
s += to_string( g_hash_tags.size( ) );
s += " tag(s)";
return s;
}
void init_files_area( vector< string >* p_untagged )
{
string cwd( get_cwd( ) );
try
{
bool rc;
set_cwd( c_files_directory, &rc );
if( !rc )
create_dir( c_files_directory, &rc, ( dir_perms )c_directory_perm_val );
else
{
directory_filter df;
fs_iterator dfsi( ".", &df );
bool is_first = true;
do
{
size_t max_num = get_files_area_item_max_num( );
size_t max_size = get_files_area_item_max_size( );
file_filter ff;
fs_iterator fs( dfsi.get_path_name( ), &ff );
vector< string > files_to_delete;
while( fs.has_next( ) )
{
if( is_first )
{
string data( buffer_file( fs.get_full_name( ) ) );
string filename( construct_file_name_from_hash( data, false, false ) );
if( !file_exists( "../" + filename ) )
file_remove( fs.get_full_name( ) );
g_hash_tags.insert( make_pair( data, fs.get_name( ) ) );
g_tag_hashes.insert( make_pair( fs.get_name( ), data ) );
}
else
{
string file_path( fs.get_full_name( ) );
if( file_size( file_path ) > max_size )
files_to_delete.push_back( file_path );
else if( g_total_files >= max_num )
files_to_delete.push_back( file_path );
else
{
++g_total_files;
g_total_bytes += file_size( file_path );
if( p_untagged )
{
string::size_type pos = file_path.find_last_of( "/\\" );
if( pos != string::npos && pos >= 2 )
{
string hash( file_path.substr( pos - 2, 2 ) );
hash += file_path.substr( pos + 1 );
if( !g_hash_tags.count( hash ) )
p_untagged->push_back( hash );
}
}
}
}
}
is_first = false;
for( size_t i = 0; i < files_to_delete.size( ); i++ )
file_remove( files_to_delete[ i ] );
} while( dfsi.has_next( ) );
}
set_cwd( cwd );
}
catch( ... )
{
set_cwd( cwd );
throw;
}
}
void resync_files_area( vector< string >* p_untagged )
{
guard g( g_mutex );
g_hash_tags.clear( );
g_tag_hashes.clear( );
g_total_bytes = g_total_files = 0;
init_files_area( p_untagged );
}
void term_files_area( )
{
// FUTURE: Implementation to be added.
}
string current_timestamp_tag( bool truncated, size_t days_ahead )
{
string retval( c_timestamp_tag_prefix );
string dummy_timestamp( get_session_variable( get_special_var_name( e_special_var_dummy_timestamp ) ) );
if( !dummy_timestamp.empty( ) )
{
retval += dummy_timestamp;
set_session_variable( get_special_var_name( e_special_var_dummy_timestamp ), "" );
}
else
{
date_time dt( date_time::local( ) );
dt += ( days )days_ahead;
if( truncated )
retval += dt.as_string( e_time_format_hhmmssth, false );
else
retval += dt.as_string( e_time_format_hhmmsstht, false ) + "00000000";
}
return retval;
}
bool has_tag( const string& name )
{
guard g( g_mutex );
string::size_type pos = name.rfind( '*' );
map< string, string >::iterator i = g_tag_hashes.lower_bound( name.substr( 0, pos ) );
if( i == g_tag_hashes.end( ) || ( pos == string::npos && i->first != name ) )
return false;
else
return true;
}
bool has_file( const string& hash, bool check_is_hash )
{
guard g( g_mutex );
string filename( construct_file_name_from_hash( hash, false, check_is_hash ) );
return file_exists( filename );
}
int64_t file_bytes( const string& hash )
{
guard g( g_mutex );
string filename( construct_file_name_from_hash( hash ) );
return file_size( filename );
}
string file_type_info( const string& tag_or_hash,
file_expansion expansion, int max_depth, int indent, bool add_size )
{
guard g( g_mutex );
string hash, filename;
if( file_exists( string( c_files_directory ) + '/' + tag_or_hash ) )
{
hash = tag_file_hash( tag_or_hash );
filename = construct_file_name_from_hash( hash );
}
else
{
bool is_base64 = false;
if( tag_or_hash.length( ) != 64 )
base64::validate( tag_or_hash, &is_base64 );
hash = !is_base64 ? tag_or_hash : base64_to_hex( tag_or_hash );
filename = construct_file_name_from_hash( hash, false, false );
}
if( !file_exists( filename ) )
throw runtime_error( "file '" + tag_or_hash + "' was not found" );
string data( buffer_file( filename ) );
if( data.empty( ) )
throw runtime_error( "unexpected empty file" );
unsigned char file_type = ( data[ 0 ] & c_file_type_val_mask );
bool is_core = ( data[ 0 ] & c_file_type_val_extra_core );
bool is_compressed = ( data[ 0 ] & c_file_type_val_compressed );
if( file_type != c_file_type_val_blob && file_type != c_file_type_val_list )
throw runtime_error( "invalid file type '0x" + hex_encode( &file_type, 1 ) + "' for raw file creation" );
if( !is_compressed )
{
sha256 test_hash( data );
if( hash != test_hash.get_digest_as_string( ) )
throw runtime_error( "invalid content for '" + tag_or_hash + "' (hash does not match hashed data)" );
}
string final_data( data );
#ifdef ZLIB_SUPPORT
if( is_compressed )
{
session_file_buffer_access file_buffer;
unsigned long size = data.size( ) - 1;
unsigned long usize = file_buffer.get_size( ) - size;
if( uncompress( ( Bytef * )file_buffer.get_buffer( ),
&usize, ( Bytef * )&data[ 1 ], size ) != Z_OK )
throw runtime_error( "invalid content for '" + tag_or_hash + "' (bad compressed or uncompressed too large)" );
final_data.erase( 1 );
final_data += string( ( const char* )file_buffer.get_buffer( ), usize );
validate_hash_with_uncompressed_content( hash, ( unsigned char* )final_data.data( ), final_data.length( ) );
}
#endif
string retval;
// NOTE: As other functions rely upon the output format care should be taken to not alter this
// without the use of additional function arguments (that default to keeping the format as is).
if( expansion != e_file_expansion_recursive_hashes )
{
retval += string( indent, ' ' );
retval += '[';
if( is_core )
retval += "core-";
if( file_type == c_file_type_val_blob )
retval += "blob]";
else if( file_type == c_file_type_val_list )
retval += "list]";
}
string size_info( "(" + format_bytes( final_data.size( ) ) + ")" );
if( expansion == e_file_expansion_none )
{
retval += " " + lower( hash );
if( add_size )
retval += " " + size_info;
if( is_core )
{
string::size_type pos = final_data.find( ':' );
if( pos != string::npos )
retval += " " + final_data.substr( 1, pos - 1 );
}
}
else
{
if( file_type == c_file_type_val_blob )
{
if( expansion == e_file_expansion_recursive_hashes )
retval += lower( hash );
else
{
string blob_info( final_data.substr( 1 ) );
if( is_valid_utf8( blob_info ) )
{
retval += " " + lower( hash );
if( add_size )
retval += " " + size_info;
if( max_depth && indent >= max_depth )
retval += "\n" + string( indent, ' ' ) + "...";
else
{
retval += " [utf8]";
retval += "\n" + utf8_replace( blob_info, "\r", "" );
}
}
else
{
retval += " " + lower( hash );
if( add_size )
retval += " " + size_info;
if( max_depth && indent >= max_depth )
retval += "\n" + string( indent, ' ' ) + "...";
else
{
retval += " [base64]";
retval += "\n" + base64::encode( blob_info );
}
}
}
}
else if( file_type == c_file_type_val_list )
{
string list_info( final_data.substr( 1 ) );
vector< string > list_items;
split( list_info, list_items, '\n' );
if( expansion == e_file_expansion_recursive_hashes )
retval += lower( hash );
else
{
retval += " " + lower( hash );
if( add_size )
retval += " " + size_info;
}
for( size_t i = 0; i < list_items.size( ); i++ )
{
string next_list_item( list_items[ i ] );
if( expansion == e_file_expansion_content )
retval += "\n" + string( indent, ' ' ) + next_list_item;
else if( max_depth && indent >= max_depth
&& expansion != e_file_expansion_recursive_hashes )
{
if( i == 0 )
retval += "\n" + string( indent, ' ' ) + "...";
}
else
{
string::size_type pos = next_list_item.find( ' ' );
if( pos != string::npos && expansion != e_file_expansion_recursive_hashes )
retval += "\n" + string( indent, ' ' ) + next_list_item.substr( pos + 1 );
retval += "\n" + file_type_info( next_list_item.substr( 0, pos ), expansion, max_depth, indent + 1, add_size );
}
}
}
}
return retval;
}
string create_raw_file( const string& data, bool compress, const char* p_tag, bool* p_is_existing )
{
guard g( g_mutex );
if( data.empty( ) )
throw runtime_error( "cannot create a raw file empty data" );
bool file_extra_is_core = false;
unsigned char file_type = ( data[ 0 ] & c_file_type_val_mask );
unsigned char file_extra = ( data[ 0 ] & c_file_type_val_extra_mask );
if( file_extra & c_file_type_val_extra_core )
file_extra_is_core = true;
if( file_type != c_file_type_val_blob && file_type != c_file_type_val_list )
throw runtime_error( "invalid file type '0x" + hex_encode( &file_type, 1 ) + "' for raw file creation" );
string final_data( data );
bool is_compressed = ( data[ 0 ] & c_file_type_val_compressed );
#ifdef ZLIB_SUPPORT
session_file_buffer_access file_buffer;
if( is_compressed )
{
unsigned long size = final_data.size( ) - 1;
unsigned long usize = file_buffer.get_size( ) - size;
size_t offset = 1;
if( uncompress( ( Bytef * )file_buffer.get_buffer( ),
&usize, ( Bytef * )&final_data[ offset ], size ) != Z_OK )
throw runtime_error( "invalid content for create_raw_file (bad compressed or uncompressed too large)" );
compress = true;
is_compressed = false;
final_data = string( ( const char* )file_buffer.get_buffer( ) );
}
#else
if( is_compressed )
throw runtime_error( "create_raw_file doesn't support compressed files (without ZLIB support)" );
#endif
string hash( sha256( final_data ).get_digest_as_string( ) );
string filename( construct_file_name_from_hash( hash, true ) );
if( file_type != c_file_type_val_blob )
validate_list( final_data.substr( 1 ) );
#ifdef ZLIB_SUPPORT
if( compress && !is_compressed && data.size( ) > 32 ) // i.e. don't even bother trying to compress tiny files
{
unsigned long size = data.size( ) - 1;
unsigned long csize = file_buffer.get_size( );
size_t offset = 1;
if( compress2( ( Bytef * )file_buffer.get_buffer( ),
&csize, ( Bytef * )&data[ offset ], size, 9 ) != Z_OK ) // i.e. 9 is for maximum compression
throw runtime_error( "invalid content in create_raw_file (bad compress or buffer too small)" );
if( csize + offset < data.size( ) )
{
final_data[ 0 ] |= c_file_type_val_compressed;
final_data.erase( offset );
final_data += string( ( const char* )file_buffer.get_buffer( ), csize );
is_compressed = true;
}
}
#endif
bool was_existing( file_exists( filename ) );
if( !was_existing )
{
if( p_is_existing )
*p_is_existing = false;
if( g_total_files >= get_files_area_item_max_num( ) )
throw runtime_error( "maximum file area item limit has been reached" );
size_t max_num = get_files_area_item_max_num( );
size_t max_size = get_files_area_item_max_size( );
if( final_data.size( ) > max_size )
throw runtime_error( "maximum file area item size limit cannot be exceeded" );
int64_t max_bytes = ( int64_t )max_num * ( int64_t )max_size;
if( g_total_bytes + final_data.size( ) > max_bytes )
throw runtime_error( "maximum file area size limit cannot be exceeded" );
#ifndef _WIN32
int um = umask( 077 );
#endif
ofstream outf( filename.c_str( ), ios::out | ios::binary );
#ifndef _WIN32
umask( um );
#endif
if( !outf )
throw runtime_error( "unable to create output file '" + filename + "'" );
outf << final_data;
++g_total_files;
g_total_bytes += final_data.size( );
}
else if( p_is_existing )
*p_is_existing = true;
string tag_name;
if( p_tag )
tag_name = string( p_tag );
if( !tag_name.empty( )
&& tag_name != string( c_important_file_suffix ) )
tag_file( tag_name, hash );
else if( !was_existing && !file_extra_is_core )
tag_file( current_timestamp_tag( ) + tag_name, hash );
return hash;
}
string create_raw_file_with_extras( const string& data,
vector< pair< string, string > >& extras, bool compress, const char* p_tag )
{
guard g( g_mutex );
string retval;
if( g_total_files + !data.empty( ) + extras.size( ) >= get_files_area_item_max_num( ) )
throw runtime_error( "maximum file area item limit has been reached" );
bool is_existing = false;
if( !data.empty( ) )
retval = create_raw_file( data, compress, p_tag, &is_existing );
// NOTE: It is being assumed that "extras" should not be larger than the main file
// so that assuming the main file is created there should be no risk that the max.
// file storage capacity will be exceeded creating the extra files.
if( !is_existing )
{
vector< string > all_hashes;
all_hashes.push_back( retval );
for( size_t i = 0; i < extras.size( ); i++ )
{
if( extras[ i ].first.empty( ) )
delete_file( extras[ i ].second );
else
{
// NOTE: If a core blob or list is being added then the hash of the
// main file being added can be expanded using @0 as well as hashes
// of other extra files using @1..@n.
if( extras[ i ].first[ 0 ] == c_file_type_char_core_blob
|| extras[ i ].first[ 0 ] == c_file_type_char_core_list )
{
string details( extras[ i ].first.substr( 1 ) );
if( details.find( '@' ) != string::npos )
{
for( size_t j = all_hashes.size( ) - 1; ; j-- )
{
string str( "@" );
str += to_string( j );
replace( details, str, all_hashes[ j ] );
if( j == 0 || details.find( '@' ) == string::npos )
break;
}
}
extras[ i ].first.erase( 1 );
extras[ i ].first += details;
}
regex expr( c_regex_hash_256 );
// NOTE: If the first part of the extra is a file hash then
// the second part is split up and applied as tags for this
// file (which is expected to exist).
if( expr.search( extras[ i ].first ) == 0 )
{
vector< string > tags;
split( extras[ i ].second, tags, '\n' );
for( size_t j = 0; j < tags.size( ); j++ )
tag_file( tags[ j ], extras[ i ].first );
}
else
{
string tag( extras[ i ].second );
string secondary_tags;
string::size_type pos = tag.find( '\n' );
if( pos != string::npos )
{
secondary_tags = tag.substr( pos + 1 );
tag.erase( pos );
}
string next_hash = create_raw_file( extras[ i ].first, compress, tag.c_str( ) );
all_hashes.push_back( next_hash );
if( !secondary_tags.empty( ) )
{
vector< string > all_secondary_tags;
split( secondary_tags, all_secondary_tags, '\n' );
for( size_t i = 0; i < all_secondary_tags.size( ); i++ )
tag_file( all_secondary_tags[ i ], next_hash );
}
}
}
}
}
return retval;
}
void tag_del( const string& name, bool unlink )
{
guard g( g_mutex );
string::size_type pos = name.find_first_of( "*?" );
if( pos == string::npos )
{
string tag_filename( c_files_directory );
tag_filename += "/" + name;
file_remove( tag_filename );
if( g_tag_hashes.count( name ) )
{
string hash = g_tag_hashes[ name ];
g_tag_hashes.erase( name );
// NOTE: Need to also remove the matching entry in the hash tags multimap.
multimap< string, string >::iterator i;
for( i = g_hash_tags.lower_bound( hash ); i != g_hash_tags.end( ); ++i )
{
if( i->first != hash )
break;
if( i->second == name )
{
g_hash_tags.erase( i );
break;
}
}
if( unlink && !g_hash_tags.count( hash ) )
delete_file( hash );
}
}
else
{
if( name == "*" )
throw runtime_error( "invalid attempt to delete all file system tags (use ** if really wanting to do this)" );
string prefix( name.substr( 0, pos ) );
map< string, string >::iterator i = g_tag_hashes.lower_bound( prefix );
vector< string > matching_tag_names;
for( ; i != g_tag_hashes.end( ); ++i )
{
if( wildcard_match( name, i->first ) )
matching_tag_names.push_back( i->first );
if( i->first.length( ) < prefix.length( ) || i->first.substr( 0, prefix.length( ) ) != prefix )
break;
}
for( size_t i = 0; i < matching_tag_names.size( ); i++ )
tag_del( matching_tag_names[ i ], unlink );
}
}
void tag_file( const string& name, const string& hash )
{
guard g( g_mutex );
if( name != get_special_var_name( e_special_var_none ) )
{
string filename( construct_file_name_from_hash( hash ) );
if( !file_exists( filename ) )
throw runtime_error( hash + " was not found" );
string tag_name;
// NOTE: If an asterisk is included in the name then existing tags matching
// the wildcard expression will be removed first then if the asterisk is at
// the very end no new tag will be added unless two asterisks were used for
// the name suffix in which case the new tag name will become the truncated
// version.
string::size_type pos = name.rfind( '*' );
if( pos == string::npos )
{
tag_del( name );
tag_name = name;
}
else
{
// NOTE: If a question mark preceeds the asterisk then only the exact tag
// will be removed.
if( pos > 1 && name[ pos - 1 ] == '?' )
remove_file_tags( hash, name.substr( 0, pos - 1 ) );
else
remove_file_tags( hash, name.substr( 0, pos + 1 ) );
if( pos != name.length( ) - 1 )
tag_name = name.substr( 0, pos ) + name.substr( pos + 1 );
else if( pos > 1 && name[ pos - 1 ] == '*' )
tag_name = name.substr( 0, pos - 1 );
// NOTE: If a question mark as found at the end then the tag will become
// instead a "current time stamp" tag.
if( tag_name.length( ) && tag_name[ tag_name.length( ) - 1 ] == '?' )
tag_name = current_timestamp_tag( );
}
if( !tag_name.empty( ) )
{
string tag_filename( c_files_directory );
tag_filename += "/" + tag_name;
ofstream outf( tag_filename.c_str( ) );
if( !outf )
throw runtime_error( "unable to open file '" + tag_filename + "' for output" );
outf << hash;
outf.flush( );
if( !outf.good( ) )
throw runtime_error( "unexpected bad output stream" );
g_hash_tags.insert( make_pair( hash, tag_name ) );
g_tag_hashes.insert( make_pair( tag_name, hash ) );
}
}
}
string get_hash_tags( const string& hash )
{
guard g( g_mutex );
string retval;
set< string > tags_found;
multimap< string, string >::iterator i = g_hash_tags.lower_bound( hash );
for( ; i != g_hash_tags.end( ); ++i )
{
if( i->first != hash )
break;
tags_found.insert( i->second );
}
for( set< string >::iterator si = tags_found.begin( ); si != tags_found.end( ); ++si )
{
if( !retval.empty( ) )
retval += '\n';
retval += *si;
}
return retval;
}
string tag_file_hash( const string& name )
{
guard g( g_mutex );
string retval;
// NOTE: If the name is just "*" then return the hashes of all files that have been tagged or
// if is just "?" then will instead return all the hashes of files that have not been tagged.
if( name == "*" )
{
set< string > hashes;
for( map< string, string >::iterator i = g_tag_hashes.begin( ); i != g_tag_hashes.end( ); ++i )
hashes.insert( i->second );
for( set< string >::iterator i = hashes.begin( ); i != hashes.end( ); ++i )
{
if( i != hashes.begin( ) )
retval += '\n';
retval += *i;
}
}
else if( name == "?" )
{
vector< string > untagged_hashes;
resync_files_area( &untagged_hashes );
for( size_t i = 0; i < untagged_hashes.size( ); i++ )
{
if( i > 0 )
retval += '\n';
retval += untagged_hashes[ i ];
}
}
else
{
string::size_type pos = name.rfind( '*' );
map< string, string >::iterator i = g_tag_hashes.lower_bound( name.substr( 0, pos ) );
if( i == g_tag_hashes.end( ) || ( pos == string::npos && i->first != name ) )
throw runtime_error( "tag '" + name + "' not found" );
retval = i->second;
}
return retval;
}
string list_file_tags( const string& pat,
size_t max_tags, int64_t max_bytes, int64_t* p_min_bytes, deque< string >* p_hashes )
{
guard g( g_mutex );
string retval;
size_t num_tags = 0;
int64_t min_bytes = 0;
int64_t num_bytes = 0;
if( !pat.empty( ) )
{
string::size_type pos = pat.find_first_of( "*?" );
string prefix = pat.substr( 0, pos );
map< string, string >::iterator i = g_tag_hashes.lower_bound( prefix );
for( ; i != g_tag_hashes.end( ); ++i )
{
if( wildcard_match( pat, i->first ) )
{
++num_tags;
int64_t next_bytes = file_bytes( i->second );
if( max_bytes && num_bytes + next_bytes > max_bytes )
continue;
if( !min_bytes || next_bytes < min_bytes )
min_bytes = next_bytes;
num_bytes += next_bytes;
if( !retval.empty( ) )
retval += "\n";
retval += i->first;
if( p_hashes )
p_hashes->push_back( i->second );
}
if( max_tags && num_tags >= max_tags )
break;
if( i->first.length( ) < prefix.length( ) || i->first.substr( 0, prefix.length( ) ) != prefix )
break;
}
}
else
{
for( map< string, string >::iterator i = g_tag_hashes.begin( ); i != g_tag_hashes.end( ); ++i )
{
++num_tags;
int64_t next_bytes = file_bytes( i->second );
if( max_bytes && num_bytes + next_bytes > max_bytes )
break;
if( !min_bytes || next_bytes < min_bytes )
min_bytes = next_bytes;
num_bytes += next_bytes;
if( !retval.empty( ) )
retval += "\n";
retval += i->first;
if( p_hashes )
p_hashes->push_back( i->second );
if( max_tags && num_tags >= max_tags )
break;
}
}
return retval;
}
void remove_file_tags( const string& hash, const string& pat )
{
string tags( get_hash_tags( hash ) );
if( !tags.empty( ) )
{
vector< string > all_tags;
split( tags, all_tags, '\n' );
for( size_t i = 0; i < all_tags.size( ); i++ )
{
if( wildcard_match( pat, all_tags[ i ] ) )
tag_del( all_tags[ i ] );
}
}
}
string hash_with_nonce( const string& hash, const string& nonce )
{
string filename( construct_file_name_from_hash( hash ) );
sha256 temp_hash;
if( !nonce.empty( ) )
temp_hash.update( nonce );
temp_hash.update( filename, true );
return temp_hash.get_digest_as_string( );
}
void fetch_file( const string& hash, tcp_socket& socket, progress* p_progress )
{
string tmp_filename( "~" + uuid( ).as_string( ) );
string filename( construct_file_name_from_hash( hash, false, false ) );
#ifndef _WIN32
int um = umask( 077 );
#endif
try
{
// NOTE: As the file may end up being deleted whilst it is being
// transferred it is copied to a temporary file which is instead
// used for the transfer (and deleted afterwards).
if( !filename.empty( ) )
{
guard g( g_mutex );
if( !file_exists( filename ) )
throw runtime_error( "file '" + hash + "' was not found" );
file_copy( filename, tmp_filename );
}
file_transfer( tmp_filename, socket,
e_ft_direction_send, get_files_area_item_max_size( ),
c_response_okay_more, c_file_transfer_initial_timeout,
c_file_transfer_line_timeout, c_file_transfer_max_line_size, 0, 0, 0, p_progress );
#ifndef _WIN32
umask( um );
#endif
file_remove( tmp_filename );
}
catch( ... )
{
#ifndef _WIN32
umask( um );
#endif
file_remove( tmp_filename );
throw;
}
}
void store_file( const string& hash, tcp_socket& socket,
const char* p_tag, progress* p_progress, bool allow_core_file, size_t max_bytes )
{
string tmp_filename( "~" + uuid( ).as_string( ) );
string filename( construct_file_name_from_hash( hash, true ) );
bool existing = false;
int64_t existing_bytes = 0;
bool is_in_blacklist = false;
bool file_extra_is_core = false;
if( !max_bytes || max_bytes > get_files_area_item_max_size( ) )
max_bytes = get_files_area_item_max_size( );
if( !filename.empty( ) )
{
guard g( g_mutex );
existing = file_exists( filename );
if( existing )
existing_bytes = file_size( filename );
}
#ifndef _WIN32
int um = umask( 077 );
#endif
try
{
session_file_buffer_access file_buffer;
file_transfer( tmp_filename, socket, e_ft_direction_recv, max_bytes,
c_response_okay_more, c_file_transfer_initial_timeout, c_file_transfer_line_timeout,
c_file_transfer_max_line_size, 0, file_buffer.get_buffer( ), file_buffer.get_size( ), p_progress );
unsigned char file_type = ( file_buffer.get_buffer( )[ 0 ] & c_file_type_val_mask );
unsigned char file_extra = ( file_buffer.get_buffer( )[ 0 ] & c_file_type_val_extra_mask );
if( file_type != c_file_type_val_blob && file_type != c_file_type_val_list )
throw runtime_error( "invalid file type '0x" + hex_encode( &file_type, 1 ) + "' for store_file" );
if( file_extra & c_file_type_val_extra_core )
{
if( allow_core_file )
file_extra_is_core = true;
else
throw runtime_error( "core file not allowed for this store_file" );
}
bool is_compressed = ( file_buffer.get_buffer( )[ 0 ] & c_file_type_val_compressed );
#ifdef ZLIB_SUPPORT
if( is_compressed )
{
unsigned long size = file_size( tmp_filename ) - 1;
unsigned long usize = file_buffer.get_size( ) - size;
if( uncompress( ( Bytef * )&file_buffer.get_buffer( )[ size + 1 ],
&usize, ( Bytef * )&file_buffer.get_buffer( )[ 1 ], size ) != Z_OK )
throw runtime_error( "invalid content for '" + hash + "' (bad compressed or uncompressed too large)" );
file_buffer.get_buffer( )[ size ] = file_buffer.get_buffer( )[ 0 ];
validate_hash_with_uncompressed_content( hash, &file_buffer.get_buffer( )[ size ], usize + 1 );
bool rc = true;
if( file_type != c_file_type_val_blob )
validate_list( ( const char* )&file_buffer.get_buffer( )[ size ], &rc );
if( !rc )
throw runtime_error( "invalid 'list' file" );
}
#endif
bool rc = true;
if( !is_compressed && file_type != c_file_type_val_blob )
validate_list( ( const char* )file_buffer.get_buffer( ), &rc );
if( !rc )
throw runtime_error( "invalid 'list' file" );
if( !is_compressed )
{
sha256 test_hash;
test_hash.update( tmp_filename, true );
if( hash != test_hash.get_digest_as_string( ) )
throw runtime_error( "invalid content for '" + hash + "' (hash does not match hashed data)" );
}
#ifndef _WIN32
umask( um );
#endif
if( rc )
{
guard g( g_mutex );
if( !existing )
is_in_blacklist = file_has_been_blacklisted( hash );
if( !existing && !is_in_blacklist && g_total_files >= get_files_area_item_max_num( ) )
{
// NOTE: First attempt to relegate an existing file in order to make room.
relegate_timestamped_files( "", "", 1, 0, true );
if( g_total_files >= get_files_area_item_max_num( ) )
throw runtime_error( "maximum file area item limit has been reached" );
}
if( !is_in_blacklist )
file_copy( tmp_filename, filename );
file_remove( tmp_filename );
if( !existing && !is_in_blacklist )
++g_total_files;
if( !is_in_blacklist )
{
g_total_bytes -= existing_bytes;
g_total_bytes += file_size( filename );
}
}
}
catch( ... )
{
#ifndef _WIN32
umask( um );
#endif
file_remove( tmp_filename );
throw;
}
if( !is_in_blacklist )
{
string tag_name;
if( p_tag )
tag_name = string( p_tag );
if( !tag_name.empty( )
&& tag_name != string( c_important_file_suffix ) )
tag_file( tag_name, hash );
else if( !existing && !file_extra_is_core )
tag_file( current_timestamp_tag( ) + tag_name, hash );
}
}
void delete_file( const string& hash, bool even_if_tagged )
{
guard g( g_mutex );
string tags( get_hash_tags( hash ) );
string filename( construct_file_name_from_hash( hash ) );
if( tags.empty( ) || even_if_tagged )
{
if( !file_exists( filename ) )
throw runtime_error( "file '" + filename + "' not found" );
if( !tags.empty( ) )
{
vector< string > all_tags;
split( tags, all_tags, '\n' );
for( size_t i = 0; i < all_tags.size( ); i++ )
tag_del( all_tags[ i ] );
}
int64_t existing_bytes = file_size( filename );
file_remove( filename );
--g_total_files;
g_total_bytes -= existing_bytes;
}
}
void delete_file_tree( const string& hash )
{
string all_hashes( file_type_info( hash, e_file_expansion_recursive_hashes ) );
vector< string > hashes;
split( all_hashes, hashes, '\n' );
for( size_t i = 0; i < hashes.size( ); i++ )
delete_file( hashes[ i ] );
}
void delete_files_for_tags( const string& pat )
{
guard g( g_mutex );
string tags( list_file_tags( pat ) );
if( !tags.empty( ) )
{
vector< string > all_tags;
split( tags, all_tags, '\n' );
set< string > hashes;
for( size_t i = 0; i < all_tags.size( ); i++ )
hashes.insert( tag_file_hash( all_tags[ i ] ) );
for( set< string >::iterator i = hashes.begin( ); i != hashes.end( ); ++i )
delete_file( *i );
}
}
void copy_raw_file( const string& hash, const string& dest_filename )
{
guard g( g_mutex );
string filename( construct_file_name_from_hash( hash ) );
if( !file_exists( filename ) )
throw runtime_error( "file '" + filename + "' not found" );
file_copy( filename, dest_filename );
}
void fetch_temp_file( const string& name, tcp_socket& socket, progress* p_progress )
{
file_transfer( name, socket,
e_ft_direction_send, get_files_area_item_max_size( ),
c_response_okay_more, c_file_transfer_initial_timeout,
c_file_transfer_line_timeout, c_file_transfer_max_line_size, 0, 0, 0, p_progress );
}
void store_temp_file( const string& name, tcp_socket& socket, progress* p_progress )
{
#ifndef _WIN32
int um = umask( 077 );
#endif
try
{
file_transfer( name, socket,
e_ft_direction_recv, get_files_area_item_max_size( ),
c_response_okay_more, c_file_transfer_initial_timeout,
c_file_transfer_line_timeout, c_file_transfer_max_line_size, 0, 0, 0, p_progress );
#ifndef _WIN32
umask( um );
#endif
}
catch( ... )
{
#ifndef _WIN32
umask( um );
#endif
throw;
}
}
bool temp_file_is_identical( const string& temp_name, const string& hash )
{
string filename( construct_file_name_from_hash( hash ) );
return files_are_identical( temp_name, filename );
}
string extract_file( const string& hash, const string& dest_filename, unsigned char check_file_type_and_extra )
{
guard g( g_mutex );
string filename( construct_file_name_from_hash( hash ) );
string data( buffer_file( filename ) );
if( !data.empty( ) )
{
if( check_file_type_and_extra )
{
if( data[ 0 ] & check_file_type_and_extra != check_file_type_and_extra )
throw runtime_error( "unexpected file type/extra" );
}
unsigned char file_type = ( data[ 0 ] & c_file_type_val_mask );
unsigned char file_extra = ( data[ 0 ] & c_file_type_val_extra_mask );
bool is_compressed = ( data[ 0 ] & c_file_type_val_compressed );
session_file_buffer_access file_buffer;
unsigned long size = file_size( filename ) - 1;
size_t offset = 1;
#ifdef ZLIB_SUPPORT
if( is_compressed )
{
unsigned long usize = file_buffer.get_size( ) - size;
if( uncompress( ( Bytef * )&file_buffer.get_buffer( )[ 0 ],
&usize, ( Bytef * )&data[ offset ], size ) != Z_OK )
throw runtime_error( "invalid content for '" + hash + "' (bad compressed or uncompressed too large)" );
size = usize;
}
#endif
if( !is_compressed )
memcpy( file_buffer.get_buffer( ), &data[ offset ], size );
if( !dest_filename.empty( ) )
write_file( dest_filename, file_buffer.get_buffer( ), size );
data = string( ( const char* )file_buffer.get_buffer( ), size );
}
return data;
}
void add_file_archive( const string& name, const string& path, int64_t size_limit )
{
guard g( g_mutex );
if( size_limit < 0 )
throw runtime_error( "unexpected negative size_limit provided to add_file_archive" );
string cwd( get_cwd( ) );
string tmp_filename( "~" + uuid( ).as_string( ) );
if( path.empty( )
|| path[ path.length( ) - 1 ] == '\\' || path[ path.length( ) - 1 ] == '/' )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "invalid path '" + path + "' for add_file_archive" );
if( path_already_used_in_archive( path ) )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "an archive with the path '" + path + "' already exists" );
int64_t min_limit = get_files_area_item_max_size( ) * 10;
if( size_limit < min_limit )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "archive minimum size must be at least " + to_string( min_limit ) + " bytes" );
string status_info( get_archive_status( path ) );
ods::bulk_write bulk_write( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods::transaction ods_tx( ciyam_ods_instance( ) );
ods_fs.set_root_folder( c_file_archives_folder );
if( ods_fs.has_folder( name ) )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "archive '" + name + "' already exists" );
ods_fs.add_folder( name );
ods_fs.set_folder( name );
ods_fs.store_as_text_file( c_file_archive_path, path );
ods_fs.store_as_text_file( c_file_archive_size_avail, size_limit );
ods_fs.store_as_text_file( c_file_archive_size_limit, size_limit );
ods_fs.store_as_text_file( c_file_archive_status_info, status_info, c_status_info_pad_len );
ods_fs.add_folder( c_folder_archive_files_folder );
ods_tx.commit( );
}
void remove_file_archive( const string& name, bool destroy_files )
{
guard g( g_mutex );
ods::bulk_write bulk_write( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods_fs.set_root_folder( c_file_archives_folder );
if( !ods_fs.has_folder( name ) )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "archive '" + name + "' not found" );
else
{
ods::transaction ods_tx( ciyam_ods_instance( ) );
if( destroy_files )
{
ods_fs.set_folder( name );
string path;
ods_fs.fetch_from_text_file( c_file_archive_path, path );
string status_info;
ods_fs.fetch_from_text_file( c_file_archive_status_info, status_info );
string new_status_info( get_archive_status( path ) );
if( trim( status_info ) != new_status_info )
ods_fs.store_as_text_file( c_file_archive_status_info, new_status_info, c_status_info_pad_len );
if( new_status_info == string( c_okay ) )
{
ods_fs.set_folder( c_folder_archive_files_folder );
vector< string > file_names;
ods_fs.list_files( file_names );
for( size_t i = 0; i < file_names.size( ); i++ )
file_remove( path + '/' + file_names[ i ] );
ods_fs.set_root_folder( c_file_archives_folder );
}
}
ods_fs.remove_folder( name, 0, true );
ods_tx.commit( );
}
}
void repair_file_archive( const string& name )
{
guard g( g_mutex );
ods::bulk_write bulk_write( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods_fs.set_root_folder( c_file_archives_folder );
if( !ods_fs.has_folder( name ) )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "archive '" + name + "' not found" );
else
{
ods::transaction ods_tx( ciyam_ods_instance( ) );
ods_fs.set_folder( name );
string path;
ods_fs.fetch_from_text_file( c_file_archive_path, path );
int64_t size_used = 0;
int64_t size_avail = 0;
int64_t size_limit = 0;
ods_fs.fetch_from_text_file( c_file_archive_size_limit, size_limit );
string status_info;
ods_fs.fetch_from_text_file( c_file_archive_status_info, status_info );
string new_status_info( get_archive_status( path ) );
if( trim( status_info ) != new_status_info )
ods_fs.store_as_text_file( c_file_archive_status_info, new_status_info, c_status_info_pad_len );
if( new_status_info == string( c_okay ) )
{
ods_fs.remove_folder( c_folder_archive_files_folder, 0, true );
ods_fs.add_folder( c_folder_archive_files_folder );
ods_fs.set_folder( c_folder_archive_files_folder );
// NOTE: Iterate through the files in the path adding all
// that have names that appear to be valid SHA256 hashes.
file_filter ff;
fs_iterator fs( path, &ff );
while( fs.has_next( ) )
{
string name( fs.get_name( ) );
regex expr( c_regex_hash_256 );
if( expr.search( name ) == 0 )
{
ods_fs.add_file( name, c_file_zero_length );
size_used += file_size( fs.get_full_name( ) );
}
}
ods_fs.set_folder( ".." );
if( size_used > size_limit )
size_limit = size_used;
else
size_avail = size_limit - size_used;
ods_fs.store_as_text_file( c_file_archive_size_avail, size_avail );
ods_fs.store_as_text_file( c_file_archive_size_limit, size_limit );
}
ods_tx.commit( );
}
}
void archives_status_update( const string& name )
{
guard g( g_mutex );
ods::bulk_write bulk_write( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods_fs.set_root_folder( c_file_archives_folder );
vector< string > names;
ods_fs.list_folders( names );
ods::transaction ods_tx( ciyam_ods_instance( ) );
for( size_t i = 0; i < names.size( ); i++ )
{
string next( names[ i ] );
if( !name.empty( ) && next != name )
continue;
ods_fs.set_folder( next );
string path;
ods_fs.fetch_from_text_file( c_file_archive_path, path );
int64_t avail = 0;
ods_fs.fetch_from_text_file( c_file_archive_size_avail, avail );
string status_info;
ods_fs.fetch_from_text_file( c_file_archive_status_info, status_info );
string new_status_info;
if( avail == 0 )
new_status_info = string( c_file_archive_status_is_full );
else
new_status_info = get_archive_status( path );
if( trim( status_info ) != new_status_info )
ods_fs.store_as_text_file( c_file_archive_status_info, new_status_info, c_status_info_pad_len );
ods_fs.set_folder( ".." );
}
ods_tx.commit( );
}
bool file_has_been_blacklisted( const string& hash )
{
guard g( g_mutex );
bool retval = false;
ods::bulk_read bulk_read( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods_fs.set_root_folder( c_file_blacklist_folder );
if( ods_fs.has_file( hash ) )
retval = true;
return retval;
}
string list_file_archives( bool minimal, vector< string >* p_paths, int64_t min_avail, bool stop_after_first )
{
guard g( g_mutex );
string retval;
vector< string > names;
auto_ptr< ods::bulk_read > ap_bulk;
if( !ciyam_ods_instance( ).is_bulk_locked( ) )
ap_bulk.reset( new ods::bulk_read( ciyam_ods_instance( ) ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods_fs.set_root_folder( c_file_archives_folder );
ods_fs.list_folders( names );
for( size_t i = 0; i < names.size( ); i++ )
{
string next( names[ i ] );
if( !retval.empty( ) )
retval += '\n';
ods_fs.set_folder( next );
string path;
ods_fs.fetch_from_text_file( c_file_archive_path, path );
int64_t avail = 0;
int64_t limit = 0;
string status_info;
ods_fs.fetch_from_text_file( c_file_archive_size_avail, avail );
ods_fs.fetch_from_text_file( c_file_archive_size_limit, limit );
ods_fs.fetch_from_text_file( c_file_archive_status_info, status_info );
if( min_avail <= 0 || avail >= min_avail )
{
retval += next;
if( !minimal )
retval += " [" + status_info + "] ("
+ format_bytes( limit - avail ) + '/' + format_bytes( limit ) + ") " + path;
if( p_paths )
p_paths->push_back( path );
if( stop_after_first )
break;
}
ods_fs.set_folder( ".." );
}
return retval;
}
string relegate_timestamped_files( const string& hash,
const string& archive, uint32_t max_files, int64_t max_bytes, bool delete_files_always )
{
guard g( g_mutex );
string retval;
vector< string > paths;
set< string > importants;
deque< string > file_hashes;
int64_t min_bytes = 0;
if( !hash.empty( ) )
file_hashes.push_back( hash );
else
{
string timestamp_expr( c_timestamp_tag_prefix );
timestamp_expr += "*";
string all_tags( list_file_tags( timestamp_expr, max_files, max_bytes, &min_bytes, &file_hashes ) );
vector< string > tags;
split( all_tags, tags, '\n' );
if( tags.size( ) != file_hashes.size( ) )
throw runtime_error( "unexpected tags.size( ) != file_hashes.size( )" );
for( size_t i = 0; i < tags.size( ); i++ )
{
if( tags[ i ].find( c_important_file_suffix ) != string::npos )
importants.insert( file_hashes[ i ] );
}
}
int64_t num_bytes = hash.empty( ) ? min_bytes : file_bytes( hash );
string all_archives( list_file_archives( true, &paths, num_bytes ) );
if( !file_hashes.empty( ) && !all_archives.empty( ) )
{
vector< string > archives;
split( all_archives, archives, '\n' );
if( paths.size( ) != archives.size( ) )
throw runtime_error( "unexpected paths.size( ) != archives.size( )" );
ods::bulk_write bulk_write( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
ods::transaction ods_tx( ciyam_ods_instance( ) );
for( size_t i = 0; i < archives.size( ); i++ )
{
if( !archive.empty( ) && archives[ i ] != archive )
continue;
string next_archive( archives[ i ] );
ods_fs.set_root_folder( c_file_archives_folder );
ods_fs.set_folder( next_archive );
int64_t avail = 0;
ods_fs.fetch_from_text_file( c_file_archive_size_avail, avail );
while( !file_hashes.empty( ) )
{
string next_hash( file_hashes.front( ) );
if( has_archived_file( ods_fs, next_hash, &next_archive ) )
{
// NOTE: If the file had been tagged as "important" then even if
// it was already archived it will be archived again (which will
// ensure that if such files are retrieved and later re-archived
// several times then multiple archived copies will exist).
if( i < archives.size( ) - 1 && importants.count( next_hash ) )
break;
delete_file( next_hash, true );
if( !retval.empty( ) )
retval += '\n';
retval = next_hash + ' ' + next_archive;
if( importants.count( next_hash ) )
importants.erase( next_hash );
file_hashes.pop_front( );
continue;
}
num_bytes = file_bytes( next_hash );
if( num_bytes > avail )
break;
string dest( paths[ i ] + "/" + next_hash );
copy_raw_file( next_hash, dest );
if( !temp_file_is_identical( dest, next_hash ) )
{
file_remove( dest );
break;
}
else
{
avail -= num_bytes;
ods_fs.store_as_text_file( c_file_archive_size_avail, avail );
ods_fs.set_folder( c_folder_archive_files_folder );
ods_fs.add_file( next_hash, c_file_zero_length );
delete_file( next_hash, true );
ods_fs.set_folder( ".." );
if( !retval.empty( ) )
retval += '\n';
retval += next_hash + ' ' + next_archive;
if( importants.count( next_hash ) )
importants.erase( next_hash );
file_hashes.pop_front( );
}
}
}
ods_tx.commit( );
}
// NOTE: If "delete_files_always" is set true then delete the entire
// file list regardless of whether any were relegated to an archive.
if( !file_hashes.empty( ) && delete_files_always )
{
while( !file_hashes.empty( ) )
{
string next_hash( file_hashes.front( ) );
delete_file( next_hash, true );
file_hashes.pop_front( );
}
}
return retval;
}
string retrieve_file_from_archive( const string& hash, const string& tag, size_t days_ahead )
{
guard g( g_mutex );
string retval;
if( !has_file( hash ) )
{
vector< string > paths;
string all_archives( list_file_archives( true, &paths ) );
string archive;
vector< string > archives;
if( !all_archives.empty( ) )
{
split( all_archives, archives, '\n' );
if( paths.size( ) != archives.size( ) )
throw runtime_error( "unexpected paths.size( ) != archives.size( )" );
ods::bulk_read bulk_read( ciyam_ods_instance( ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
for( size_t i = 0; i < archives.size( ); i++ )
{
archive = archives[ i ];
ods_fs.set_root_folder( c_file_archives_folder );
ods_fs.set_folder( archive );
ods_fs.set_folder( c_folder_archive_files_folder );
if( ods_fs.has_file( hash ) )
{
retval = archive;
string src_file( paths[ i ] + "/" + hash );
if( file_exists( src_file ) )
{
string file_data( buffer_file( src_file ) );
string tag_for_file( tag );
if( tag_for_file.empty( ) )
tag_for_file = current_timestamp_tag( false, days_ahead );
create_raw_file( file_data, false, tag_for_file.c_str( ) );
break;
}
}
}
}
if( retval.empty( ) )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "unable to retrieve file " + hash + " from archival" );
}
return retval;
}
void delete_file_from_archive( const string& hash, const string& archive, bool add_to_blacklist )
{
guard g( g_mutex );
regex expr( c_regex_hash_256 );
if( expr.search( hash ) == string::npos )
// FUTURE: This message should be handled as a server string message.
throw runtime_error( "invalid file hash '" + hash + "'" );
vector< string > paths;
vector< string > archives;
string all_archives( list_file_archives( true, &paths ) );
auto_ptr< ods::bulk_write > ap_bulk_write;
if( !ciyam_ods_instance( ).is_bulk_locked( ) )
ap_bulk_write.reset( new ods::bulk_write( ciyam_ods_instance( ) ) );
ods_file_system& ods_fs( ciyam_ods_file_system( ) );
auto_ptr< ods::transaction > ap_ods_tx;
if( !ciyam_ods_instance( ).is_in_transaction( ) )
ap_ods_tx.reset( new ods::transaction( ciyam_ods_instance( ) ) );
if( !all_archives.empty( ) )
{
split( all_archives, archives, '\n' );
if( paths.size( ) != archives.size( ) )
throw runtime_error( "unexpected paths.size( ) != archives.size( )" );
for( size_t i = 0; i < archives.size( ); i++ )
{
string next_archive( archives[ i ] );
if( !archive.empty( ) && archive != next_archive )
continue;
ods_fs.set_root_folder( c_file_archives_folder );
ods_fs.set_folder( next_archive );
int64_t avail = 0;
ods_fs.fetch_from_text_file( c_file_archive_size_avail, avail );
int64_t limit = 0;
ods_fs.fetch_from_text_file( c_file_archive_size_limit, limit );
ods_fs.set_folder( c_folder_archive_files_folder );
if( ods_fs.has_file( hash ) )
{
ods_fs.remove_file( hash );
string src_file( paths[ i ] + "/" + hash );
if( file_exists( src_file ) )
{
avail += file_size( src_file );
file_remove( src_file );
if( avail > limit )
avail = 0;
ods_fs.set_folder( ".." );
ods_fs.store_as_text_file( c_file_archive_size_avail, avail );
}
}
}
}
// NOTE: If no archive was specified then will also remove
// the file from the files area.
if( archive.empty( ) && has_file( hash ) )
delete_file( hash, true );
if( add_to_blacklist )
{
ods_fs.set_root_folder( c_file_blacklist_folder );
ods_fs.add_file( hash, c_file_zero_length );
// NOTE: If a matching repository entry is found then will
// delete it along with removing the equivalent local file
// from all archives and the files area.
ods_fs.set_root_folder( c_file_repository_folder );
if( ods_fs.has_file( hash ) )
{
stringstream sio_data;
ods_fs.get_file( hash, &sio_data, true );
sio_reader reader( sio_data );
string local_hash( reader.read_opt_attribute( c_file_repository_local_hash_attribute ) );
ods_fs.remove_file( hash );
if( !local_hash.empty( ) )
delete_file_from_archive( local_hash, "" );
}
}
if( ap_ods_tx.get( ) )
ap_ods_tx->commit( );
}
| 27.833636 | 126 | 0.58461 | Aloz1 |
1a4b7ecf70b457d612bc520e986269c3a6a51fab | 1,285 | cpp | C++ | src/scene/controls/scroll_pane.cpp | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | src/scene/controls/scroll_pane.cpp | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | src/scene/controls/scroll_pane.cpp | tralf-strues/simple-gui-library | cf72b11d0d245d1a1fefbae10e4aa7fb9e763bff | [
"MIT"
] | null | null | null | /**
* @author Nikita Mochalov (github.com/tralf-strues)
* @file scroll_pane.cpp
* @date 2021-12-13
*
* @copyright Copyright (c) 2021
*/
#include "scene/controls/scroll_pane.h"
#include "scene/style/default_skins.h"
using namespace Sgl;
ScrollPane::ScrollPane()
{
m_DefaultSkin = new DefaultSkins::ScrollPaneSkin(this);
setSkin(m_DefaultSkin);
}
Component* ScrollPane::getContent() { return m_Content; }
void ScrollPane::setContent(Component* content) { assert(content); m_Content = content; }
const Sml::Rectangle<int32_t>& ScrollPane::getViewport() const { return m_Viewport; }
void ScrollPane::setViewport(const Sml::Rectangle<int32_t>& viewport) { m_Viewport = viewport; }
int32_t ScrollPane::getViewportX() const { return m_Viewport.pos.x; }
void ScrollPane::setViewportX(int32_t x) { m_Viewport.pos.x = x; }
int32_t ScrollPane::getViewportY() const { return m_Viewport.pos.y; }
void ScrollPane::setViewportY(int32_t y) { m_Viewport.pos.y = y; }
int32_t ScrollPane::getViewportWidth() const { return m_Viewport.width; }
void ScrollPane::setViewportWidth(int32_t width) { m_Viewport.width = width; }
int32_t ScrollPane::getViewportHeight() const { return m_Viewport.height; }
void ScrollPane::setViewportHeight(int32_t height) { m_Viewport.height = height; } | 35.694444 | 96 | 0.752529 | tralf-strues |
1a4e5fc1e6a911d08568bddefbaeb8fad7302c39 | 1,139 | cpp | C++ | Engine/src/platform/OpenGL/OpenGLContext.cpp | PalliativeX/GameEngine | 704cf5f3ebc81fdf5e3e514908c3ac47305ccd33 | [
"Apache-2.0"
] | null | null | null | Engine/src/platform/OpenGL/OpenGLContext.cpp | PalliativeX/GameEngine | 704cf5f3ebc81fdf5e3e514908c3ac47305ccd33 | [
"Apache-2.0"
] | null | null | null | Engine/src/platform/OpenGL/OpenGLContext.cpp | PalliativeX/GameEngine | 704cf5f3ebc81fdf5e3e514908c3ac47305ccd33 | [
"Apache-2.0"
] | null | null | null | #include "enginepch.h"
#include "OpenGLContext.h"
#include "GLFW/glfw3.h"
#include "glad/glad.h"
namespace Engine
{
OpenGLContext::OpenGLContext(GLFWwindow* WindowHandle) :
windowHandle(WindowHandle)
{
ENGINE_ASSERT(windowHandle, "Window Handle is null!");
}
void OpenGLContext::init()
{
ENGINE_PROFILE_FUNCTION();
glfwMakeContextCurrent(windowHandle);
int status = gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
ENGINE_ASSERT(status, "Failed to initialize Glad!");
ENGINE_LOG_INFO("OpenGL Info:");
ENGINE_LOG_INFO(" Vendor: {0}", glGetString(GL_VENDOR));
ENGINE_LOG_INFO(" Renderer: {0}", glGetString(GL_RENDERER));
ENGINE_LOG_INFO(" Version: {0}", glGetString(GL_VERSION));
#ifdef ENGINE_ENABLE_ASSERTS
int versionMajor;
int versionMinor;
glGetIntegerv(GL_MAJOR_VERSION, &versionMajor);
glGetIntegerv(GL_MINOR_VERSION, &versionMinor);
ENGINE_ASSERT(versionMajor > 4 || (versionMajor == 4 && versionMinor >= 5), "Engine requires at least OpenGL version 4.5!");
#endif
}
void OpenGLContext::swapBuffers()
{
ENGINE_PROFILE_FUNCTION();
glfwSwapBuffers(windowHandle);
}
} | 23.729167 | 127 | 0.738367 | PalliativeX |
1a4f344a2f2171bbd28f19018eefcb49febfbce1 | 195 | cpp | C++ | source/procedural_objects/unknown_operation.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 12 | 2019-04-16T17:35:53.000Z | 2020-04-12T14:37:27.000Z | source/procedural_objects/unknown_operation.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | 47 | 2019-05-27T15:24:43.000Z | 2020-04-27T17:54:54.000Z | source/procedural_objects/unknown_operation.cpp | diegoarjz/selector | 976abd0d9e721639e6314e2599ef7e6f3dafdc4f | [
"MIT"
] | null | null | null | #include "unknown_operation.h"
namespace pagoda
{
UnknownOperation::UnknownOperation(const std::string operationName) : Exception("Unknown operation " + operationName) {}
} // namespace pagoda
| 27.857143 | 120 | 0.779487 | diegoarjz |
1a53556f26b6c5c800edb92945b3ebba9cc99c43 | 2,935 | cpp | C++ | TestCases/TestCase_007-Input/InputEffect.cpp | freehyan/Cooler | 4940cec6f98730187cf5131f0c523ff8bbb3f8c1 | [
"MIT"
] | 12 | 2017-07-05T11:45:44.000Z | 2019-03-27T11:43:50.000Z | TestCases/TestCase_007-Input/InputEffect.cpp | freehyan/Cooler | 4940cec6f98730187cf5131f0c523ff8bbb3f8c1 | [
"MIT"
] | null | null | null | TestCases/TestCase_007-Input/InputEffect.cpp | freehyan/Cooler | 4940cec6f98730187cf5131f0c523ff8bbb3f8c1 | [
"MIT"
] | null | null | null | #include "InputEffect.h"
#include <GLM/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <SOIL/SOIL.h>
#include "../../Cooler/Cooler/ProductFactory.h"
#include "../../Cooler/Cooler/GraphicsInterface.h"
#include "../../Cooler/Cooler/InputTransformer.h"
Cooler::CProductFactory<CInputEffect> theCreater("INPUT_EFFECT");
CInputEffect::CInputEffect()
{
}
CInputEffect::~CInputEffect()
{
}
//***********************************************************
//FUNCTION:
void CInputEffect::_initEffectV()
{
__initSceneData();
m_pInputTransformer = Cooler::fetchInputTransformer();
m_pInputTransformer->setTranslationVec(glm::vec3(0.0f, -5.0f, -50.0f));
m_pInputTransformer->setScale(0.1f);
// m_pInputTransformer->setTranslationVec(glm::vec3(0.0f, 0.0f, -2.2f));
// m_pInputTransformer->setRotationVec(glm::vec3(glm::pi<float>()*0.35f, 0.0f, 0.0f));
// m_pInputTransformer->setMotionMode(Cooler::SCameraMotionType::FIRST_PERSON);
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glEnable(GL_DEPTH_TEST);
}
//***********************************************************
//FUNCTION::
void CInputEffect::_renderEffectV()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
__inputPass();
}
//***********************************************************
//FUNCTION::
void CInputEffect::__inputPass()
{
_ASSERTE(glGetError() == GL_NO_ERROR);
_enableShader("INPUT_SHADER");
glm::mat4 ViewMatrix = m_pInputTransformer->getModelViewMat();
_updateShaderUniform("uViewMatrix", ViewMatrix);
glm::mat4 ModelMatrix;// = glm::scale(glm::mat4(1.0), glm::vec3(0.1f));;
_updateShaderUniform("uModelMatrix", ModelMatrix);
glm::mat4 ProjectionMatrix = glm::perspective(3.14f * 0.25f, 1280 / (float)720, 0.1f, 1000.0f);
_updateShaderUniform("uProjectionMatrix", ProjectionMatrix);
Cooler::graphicsRenderModel("CHESS");
//glBindVertexArray(m_VAO);
//glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
_disableShader("INPUT_SHADER");
_ASSERTE(glGetError() == GL_NO_ERROR);
}
//***********************************************************
//FUNCTION:
void CInputEffect::__initSceneData()
{
GLfloat Vertices[] = {
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
};
glGenVertexArrays(1, &m_VAO);
glGenBuffers(1, &m_VBO);
glBindVertexArray(m_VAO);
glBindBuffer(GL_ARRAY_BUFFER, m_VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0);
glEnableVertexAttribArray(0);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
glEnableVertexAttribArray(2);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindVertexArray(0);
}
//***********************************************************
//FUNCTION:
void CInputEffect::_destoryEffectV()
{
glDeleteBuffers(1, &m_VBO);
glDeleteVertexArrays(1, &m_VAO);
} | 29.35 | 102 | 0.649404 | freehyan |
1a58b353db84ada41094f87d7595a143ed0b1794 | 8,325 | hpp | C++ | include/tudocomp/compressors/lz78/CedarTrie.hpp | JZentgraf/tudocomp | 3a4522e3089716e4483b935e74aaae56cc547589 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | include/tudocomp/compressors/lz78/CedarTrie.hpp | JZentgraf/tudocomp | 3a4522e3089716e4483b935e74aaae56cc547589 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | include/tudocomp/compressors/lz78/CedarTrie.hpp | JZentgraf/tudocomp | 3a4522e3089716e4483b935e74aaae56cc547589 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | #pragma once
#include <vector>
#include <tudocomp/compressors/lz78/LZ78Trie.hpp>
#include <tudocomp/Algorithm.hpp>
#include "cedar.hpp"
namespace tdc {
namespace lz78 {
using cedar_factorid_t = lz78::factorid_t;
using cedar_t = cedar::da<cedar_factorid_t>;
const cedar_factorid_t CEDAR_NO_VALUE = static_cast<cedar_factorid_t>(cedar_t::error_code::CEDAR_NO_VALUE);
const cedar_factorid_t CEDAR_NO_PATH = static_cast<cedar_factorid_t>(cedar_t::error_code::CEDAR_NO_PATH);
struct CedarSearchPos {
size_t from;
};
template<>
class TrieNode<CedarSearchPos> {
factorid_t m_id;
CedarSearchPos m_search_pos;
public:
TrieNode(const factorid_t& id, const CedarSearchPos& search_pos):
m_id(id),
m_search_pos(search_pos) {
//DCHECK(id != CEDAR_NO_VALUE && id != CEDAR_NO_PATH);
}
TrieNode(): TrieNode(0, CedarSearchPos { 0 }) {}
inline const factorid_t& id() const { return m_id; }
inline const CedarSearchPos& search_pos() const { return m_search_pos; }
};
class LzwRootSearchPosMap {
std::array<CedarSearchPos, 256> m_array;
public:
inline CedarSearchPos get(uliteral_t c) {
DCHECK(0 <= c);
DCHECK(c < m_array.size());
return m_array[c];
}
inline void set(uliteral_t c, CedarSearchPos v) {
DCHECK(0 <= c);
DCHECK(c < m_array.size());
m_array[c] = v;
}
};
const uint8_t NULL_ESCAPE_ESCAPE_BYTE = 255;
const uint8_t NULL_ESCAPE_REPLACEMENT_BYTE = 254;
const cedar_factorid_t HIDDEN_ESCAPE_ID = -3; // NOTE: May not be -1 or -2
class CedarTrie: public Algorithm, public LZ78Trie<CedarSearchPos> {
// unique_ptr only needed for reassignment
std::unique_ptr<cedar_t> m_trie;
cedar_factorid_t m_ids = 0;
LzwRootSearchPosMap m_roots;
inline node_t _find_or_insert(const node_t& parent, uliteral_t c, bool incr_id) {
auto search_pos = parent.search_pos();
auto letter = (const char*) &c;
auto& from = search_pos.from;
cedar_factorid_t searchResult;
{
size_t pos = 0;
searchResult = m_trie->traverse(letter, from, pos, 1);
}
node_t r;
if(searchResult != CEDAR_NO_VALUE && searchResult != CEDAR_NO_PATH) {
r = node_t {
searchResult - 1,
search_pos,
};
} else {
{
size_t pos = 0;
if (incr_id) {
m_trie->update(letter, from, pos, 1, ++m_ids);
} else {
m_trie->update(letter, from, pos, 1, HIDDEN_ESCAPE_ID);
}
}
r = node_t {
lz78::undef_id,
search_pos,
};
}
return r;
}
inline void _print(size_t from, size_t ind) {
cedar_t& t = *m_trie;
bool prev_empty = false;
size_t prev_empty_min = 1;
size_t prev_empty_max = 1;
auto print_prev_empty = [&]() {
if (prev_empty) {
DLOG(INFO)
<< std::setfill(' ')
<< std::setw(ind)
<< ""
<< "["
<< std::setfill('0')
<< std::setw(3)
<< prev_empty_min
<< "]: "
<< "-"
<< "\n";
if (prev_empty_min != prev_empty_max) {
DLOG(INFO)
<< std::setfill(' ')
<< std::setw(ind)
<< ""
<< "[...]\n";
DLOG(INFO)
<< std::setfill(' ')
<< std::setw(ind)
<< ""
<< "["
<< std::setfill('0')
<< std::setw(3)
<< prev_empty_max
<< "]: "
<< "-"
<< "\n";
}
prev_empty = false;
}
};
for (size_t i = 1; i < 256; i++) {
auto child_from = from;
const char c = uint8_t(i);
size_t pos = 0;
auto r = t.traverse(&c, child_from, pos, 1);
if (r != CEDAR_NO_PATH && r != CEDAR_NO_VALUE) {
print_prev_empty();
prev_empty_min = i + 1;
DLOG(INFO)
<< std::setfill(' ')
<< std::setw(ind)
<< ""
<< "["
<< std::setfill('0')
<< std::setw(3)
<< i
<< std::setfill(' ')
<< "]: "
<< r
<< "\n";
_print(child_from, ind + 4);
} else {
prev_empty = true;
prev_empty_max = i;
}
}
print_prev_empty();
}
inline void print() {
DLOG(INFO) << "\n";
_print(0, 0);
DLOG(INFO) << "\n";
}
public:
inline static Meta meta() {
Meta m("lz78trie", "cedar", "Lempel-Ziv 78 Cedar Trie");
return m;
}
inline CedarTrie(Env&& env, factorid_t reserve = 0):
Algorithm(std::move(env)),
m_trie(std::make_unique<cedar_t>()) {}
inline node_t add_rootnode(const uliteral_t c) override final {
cedar_factorid_t ids = c;
DCHECK(m_ids == ids);
m_ids++;
CedarSearchPos search_pos;
if (c != 0 && c != NULL_ESCAPE_ESCAPE_BYTE) {
const char* letter = (const char*) &c;
size_t from = 0;
size_t pos = 0;
m_trie->update(letter, from, pos, 1, ids);
DCHECK(pos == 1);
search_pos = CedarSearchPos{ from };
} else {
const char* letter;
size_t from = 0;
size_t pos;
pos = 0;
letter = (const char*) &NULL_ESCAPE_ESCAPE_BYTE;
auto res = m_trie->traverse(letter, from, pos, 1);
if (res == CEDAR_NO_PATH || res == CEDAR_NO_VALUE) {
DCHECK(pos == 0);
m_trie->update(letter, from, pos, 1, cedar_factorid_t(HIDDEN_ESCAPE_ID));
DCHECK(pos == 1);
}
pos = 0;
char c2 = c;
if (c == 0) c2 = NULL_ESCAPE_REPLACEMENT_BYTE;
letter = (const char*) &c2;
m_trie->update(letter, from, pos, 1, ids);
DCHECK(pos == 1);
search_pos = CedarSearchPos{ from };
}
auto r = node_t(ids, search_pos);
m_roots.set(c, search_pos);
/*
DLOG(INFO) << "add rootnode "
<< "char: " << int(c)
<< ", factor id: "
<< r.id() << ", from: "
<< r.search_pos().from;
print();
*/
return r;
}
inline node_t get_rootnode(uliteral_t c) override final {
return node_t(c, m_roots.get(c));
}
inline void clear() override final {
// TODO: cedar seems to have a clear() method, but also
// seems to have bugs in its implementation
m_trie = std::make_unique<cedar_t>();
m_ids = 0;
m_roots = LzwRootSearchPosMap();
}
inline node_t find_or_insert(const node_t& parent, uliteral_t c) override final {
node_t r;
/*
DLOG(INFO) << "find or insert "
<< "char: " << int(c)
<< ", factor id: "
<< parent.id() << ", from: "
<< parent.search_pos().from;
*/
if (c == 0) {
auto r1 = _find_or_insert(parent, NULL_ESCAPE_ESCAPE_BYTE, false);
auto r2 = _find_or_insert(r1, NULL_ESCAPE_REPLACEMENT_BYTE, true);
r = r2;
} else if (c == NULL_ESCAPE_ESCAPE_BYTE) {
auto r1 = _find_or_insert(parent, NULL_ESCAPE_ESCAPE_BYTE, false);
auto r2 = _find_or_insert(r1, NULL_ESCAPE_ESCAPE_BYTE, true);
r = r2;
} else {
r = _find_or_insert(parent, c, true);
}
//print();
return r;
}
inline factorid_t size() const override final {
return m_ids;
}
};
}} //ns
| 29.521277 | 107 | 0.476637 | JZentgraf |
1a5e1fb6c203da8aced8c0df7630596f2d06bc90 | 1,662 | hpp | C++ | modules/NVS/prefs.hpp | tobozo/ESP32-SIDView | 51e6ba7fee6cb6dcda2bf6c78ac7cb235cf3dc3a | [
"MIT"
] | 7 | 2020-06-02T13:04:46.000Z | 2021-03-27T18:09:19.000Z | modules/NVS/prefs.hpp | tobozo/ESP32-SIDView | 51e6ba7fee6cb6dcda2bf6c78ac7cb235cf3dc3a | [
"MIT"
] | null | null | null | modules/NVS/prefs.hpp | tobozo/ESP32-SIDView | 51e6ba7fee6cb6dcda2bf6c78ac7cb235cf3dc3a | [
"MIT"
] | null | null | null | /*\
ESP32-SIDView
https://github.com/tobozo/ESP32-SIDView
MIT License
Copyright (c) 2020 tobozo
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-----------------------------------------------------------------------------
\*/
#ifndef _SID_PREFS_H_
#define _SID_PREFS_H_
Preferences prefs;
class NVSPrefs
{
public:
loopmode getLoopMode();
uint8_t getVolume();
void getLastPath( char* path );
void setLoopMode( loopmode mode );
void setVolume( uint8_t volume );
void setLastPath( const char* path );
};
// dafuq Arduino IDE ???
#ifdef ARDUINO
#include "prefs.cpp"
#endif
#endif
| 28.169492 | 80 | 0.700361 | tobozo |
1a62e4c119256e49870fad3695d4d353e091dd2d | 761 | hpp | C++ | Video/VideoMode.hpp | Phles/PhlesOSPlayground | ab19eb1293a452bf73a6289f3e1198ce90444be9 | [
"MIT"
] | 2 | 2021-03-03T05:11:09.000Z | 2021-03-03T05:11:19.000Z | Video/VideoMode.hpp | Phles/PhlesOSPlayground | ab19eb1293a452bf73a6289f3e1198ce90444be9 | [
"MIT"
] | null | null | null | Video/VideoMode.hpp | Phles/PhlesOSPlayground | ab19eb1293a452bf73a6289f3e1198ce90444be9 | [
"MIT"
] | null | null | null | //Information about VideoModes
#ifndef VIDEOMODE
#define VIDEOMODE
//Class for the video mode of the monitor
enum class VideoMode{
EGA, //Enhanced Grahpics Adapter Standard Text Mode(console color mode with ASCII text)
RGB, //Direct Red Green Blue Color mode
Palette //Color mode using a color palette
};
struct ScreenProperties{
//Monitor Video Mode
VideoMode mode;
int frameDepth; //aka bpp, Number of bits in a single pixel, or in EGA mode 16(bits per character)
//Width and Height in pixels(or characters in EGA mode)
int frameWidth, frameHeight;
//Bytes per row on the screen
int framePitch;
ScreenProperties();
ScreenProperties(VideoMode vMode,int depth, int pitch, int width, int height);
};
#endif | 31.708333 | 103 | 0.725361 | Phles |
1a67246c8def15bb0ccafc32bc38f04e05835cd4 | 254 | hpp | C++ | poo_basic/methods/TestObject_destrutores/TestObject.hpp | stemDaniel/ufmg-pds2 | 4dbb536a0926b617d04d133cbd3f7a5a223e113e | [
"MIT"
] | null | null | null | poo_basic/methods/TestObject_destrutores/TestObject.hpp | stemDaniel/ufmg-pds2 | 4dbb536a0926b617d04d133cbd3f7a5a223e113e | [
"MIT"
] | null | null | null | poo_basic/methods/TestObject_destrutores/TestObject.hpp | stemDaniel/ufmg-pds2 | 4dbb536a0926b617d04d133cbd3f7a5a223e113e | [
"MIT"
] | null | null | null | #ifndef TESTOBJECT
#define TESTOBJECT
#include <iostream>
using namespace std;
class TestObject {
int atributo;
public:
TestObject(int valor) : atributo(valor) {}
~TestObject() {
cout << "~TestObject" << atributo << endl;
}
};
#endif | 13.368421 | 45 | 0.661417 | stemDaniel |
1a685bc4b1a6e5e39a3c6a99ca76ae11b8296a57 | 2,383 | cpp | C++ | Day_07/03_Trapping_Rain_Water.cpp | premnaaath/SDE-180 | 6d7cc2404d310600a81adaa652049172f2e10ed8 | [
"MIT"
] | null | null | null | Day_07/03_Trapping_Rain_Water.cpp | premnaaath/SDE-180 | 6d7cc2404d310600a81adaa652049172f2e10ed8 | [
"MIT"
] | null | null | null | Day_07/03_Trapping_Rain_Water.cpp | premnaaath/SDE-180 | 6d7cc2404d310600a81adaa652049172f2e10ed8 | [
"MIT"
] | null | null | null | // Problem Link:
// https://leetcode.com/problems/trapping-rain-water/
// Approach 1: (Brute Force)
// TC: O(n^2)
// SC: O(1)
// Approach 2: (PrefixMax SuffixMax)
// TC: O(n)
// SC: O(n)
// Approach 3: (2 Pointer)
// TC: O(n)
// SC: O(1)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << ": " << x << "\n"
// Brute Force
int trap1(vector<int> &height)
{
int n = height.size();
int res{};
for (int i = 0; i < n; ++i)
{
int left{}, right{};
for (int j = 0; j <= i; ++j)
if (height[j] > left)
left = height[j];
for (int j = i; j < n; ++j)
if (height[j] > right)
right = height[j];
res += min(left, right) - height[i];
}
return res;
}
// PrefixMax SuffixMax
int trap2(vector<int> &height)
{
int n = height.size();
vector<int> prefixMax(n);
vector<int> suffixMax(n);
prefixMax[0] = height[0];
suffixMax[n - 1] = height[n - 1];
for (int i = 1; i < n; ++i)
{
prefixMax[i] = max(height[i], prefixMax[i - 1]);
suffixMax[n - 1 - i] = max(height[n - 1 - i], suffixMax[n - i]);
}
int res{};
for (int i = 0; i < n; ++i)
res += min(prefixMax[i], suffixMax[i]) - height[i];
return res;
}
// 2 Pointer
// Intuition: res += min(leftMax, rightMax) - height[i]; (Brute Force + Optimization)
int trap3(vector<int> &height)
{
int n = height.size();
int leftMax{}, rightMax{};
int left{}, right{n - 1};
int res{};
while (left < right)
{
if (height[left] < height[right])
{
if (height[left] > leftMax)
leftMax = height[left];
else
res += leftMax - height[left];
left++;
}
else
{
if (height[right] > rightMax)
rightMax = height[right];
else
res += rightMax - height[right];
right--;
}
}
return res;
}
void solve()
{
vector<int> height{0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; // 6
// cout << trap1(height) << endl;
// cout << trap2(height) << endl;
cout << trap3(height) << endl;
}
int main()
{
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t{1};
// cin >> t;
while (t--)
solve();
return 0;
} | 20.543103 | 85 | 0.480067 | premnaaath |
1a6be117bcc32e34e93f90d0e3723ceaa8fdcf7d | 2,248 | hpp | C++ | src/utils/safe_queue.hpp | pashinov/falcon2 | 08a7e5973b23927fc686ff73423099d00f14bf58 | [
"MIT"
] | 1 | 2021-05-07T06:32:45.000Z | 2021-05-07T06:32:45.000Z | src/utils/safe_queue.hpp | pashinov/falcon2 | 08a7e5973b23927fc686ff73423099d00f14bf58 | [
"MIT"
] | 5 | 2019-04-29T12:45:35.000Z | 2019-05-01T14:10:53.000Z | src/utils/safe_queue.hpp | pashinov/amsp | 08a7e5973b23927fc686ff73423099d00f14bf58 | [
"MIT"
] | null | null | null | //
// Created by Alexey Pashinov on 20/08/20
//
#pragma once
#include <chrono>
#include <condition_variable>
#include <mutex>
#include <queue>
/// Thread Safe Queue
template <typename T>
class safe_queue
{
public:
///
/// \brief Push a new instance of T at the back of the deque
/// \param value
void push(T&& value)
{
data_protected([&] { collection_.emplace(value); });
}
///
/// \brief Push a new instance of T at the back of the deque
/// \param value
void push(const T& value)
{
data_protected([&] { collection_.emplace(value); });
}
///
/// \brief Returns the front element and removes it from the collection
/// \return
T pop(void) noexcept
{
std::unique_lock<std::mutex> lock{ mutex_ };
while (collection_.empty())
{
cond_.wait(lock);
}
auto elem = collection_.front();
collection_.pop();
return elem;
}
///
/// \brief Returns the front element and removes it from the collection with timeout
/// \param ms
/// \return
T pop_for(std::uint32_t ms) noexcept
{
std::unique_lock<std::mutex> lock{ mutex_ };
while (collection_.empty())
{
if (cond_.wait_for(lock, std::chrono::milliseconds(ms)) == std::cv_status::timeout)
{
return {};
}
}
auto elem = collection_.front();
collection_.pop();
return elem;
}
typename std::queue<T>::size_type size() const noexcept
{
std::lock_guard<std::mutex> lock{ mutex_ };
return collection_.size();
}
/// Check if queue is empty (volatile state)
/// \return
bool empty() const noexcept
{
std::lock_guard<std::mutex> lock{ mutex_ };
return collection_.empty();
}
private:
///
/// \brief Protects the deque
/// \tparam C
/// \param callback
template <class C>
void data_protected(C&& callback)
{
std::lock_guard<std::mutex> lock{ mutex_ };
callback();
cond_.notify_one();
}
std::queue<T> collection_;
mutable std::mutex mutex_;
std::condition_variable cond_;
};
| 22.938776 | 95 | 0.558719 | pashinov |
2b3ae58eaa4c31cf472573ce0710920085137b2c | 2,092 | cpp | C++ | src/gamelib/main/checkentcfg.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | 1 | 2020-02-17T09:53:36.000Z | 2020-02-17T09:53:36.000Z | src/gamelib/main/checkentcfg.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | null | null | null | src/gamelib/main/checkentcfg.cpp | mall0c/GameLib | df4116b53c39be7b178dd87f7eb0fe32a94d00d3 | [
"MIT"
] | null | null | null | #include <iostream>
#include <cstring>
#include "gamelib/core/ecs/serialization.hpp"
#include "gamelib/Engine.hpp"
#include "gamelib/core/Game.hpp"
#include "gamelib/json/json-file.hpp"
#include "gamelib/json/json-utils.hpp"
using namespace std;
int main(int argc, char *argv[])
{
if (argc <= 1)
{
cout<<"Checks and optionally fixes entity config files."<<endl;
cout<<"Prints the normalized config to stdout or writes it to outfile, if specified."<<endl;
cout<<"Usage: checkentcfg <config file> [outfile]"<<endl;
cout<<"Finds differences between two files"<<endl;
cout<<"Prints the differences to stdout or writes it to outfile, if specified."<<endl;
cout<<"Usage: checkentcfg -d <a> <b> [outfile]"<<endl;
return 0;
}
if (argc < 2)
{
LOG_ERROR("No file given");
return 1;
}
if (strcmp(argv[1], "-d") == 0)
{
if (argc < 4)
{
LOG_ERROR("Not enough arguments");
return 1;
}
Json::Value a, b, diff;
if (!gamelib::loadJsonFromFile(argv[2], a))
return 1;
if (!gamelib::loadJsonFromFile(argv[3], b))
return 1;
gamelib::diffJson(a, b, &diff);
cout<<diff.toStyledString()<<endl;
if (argc >= 5 && strlen(argv[4]) > 0)
gamelib::writeJsonToFile(argv[4], diff);
return 0;
}
else if (strlen(argv[1]) > 0)
{
Json::Value cfg;
if (!gamelib::loadJsonFromFile(argv[1], cfg))
return 1;
gamelib::Game game;
game.pushState(gamelib::GameStatePtr(new gamelib::Engine(false)));
auto factory = gamelib::EntityFactory::getActive();
Json::Value normalized;
bool good = gamelib::normalizeConfig(cfg, &normalized, *factory);
cout<<normalized.toStyledString()<<endl;
if (argc >= 3 && strlen(argv[2]) > 0)
gamelib::writeJsonToFile(argv[2], normalized);
return !good;
}
else
{
LOG_ERROR("No file given");
return 1;
}
}
| 26.481013 | 100 | 0.5674 | mall0c |
2b3df9f569e2b721d87ed8283126713bc6bc4f99 | 1,468 | cpp | C++ | Ejercicios_basicos_Agen/main.cpp | Zayk01/Arboles-Generales | 4854d5c0fa9e5e6e2c09fe25d56f6a1d2766417f | [
"MIT"
] | null | null | null | Ejercicios_basicos_Agen/main.cpp | Zayk01/Arboles-Generales | 4854d5c0fa9e5e6e2c09fe25d56f6a1d2766417f | [
"MIT"
] | null | null | null | Ejercicios_basicos_Agen/main.cpp | Zayk01/Arboles-Generales | 4854d5c0fa9e5e6e2c09fe25d56f6a1d2766417f | [
"MIT"
] | null | null | null | #include <iostream>
#include "../I-O_Agen/I_O_Agen.hpp"
#include "Ejercicios_basicos_Agen.hpp"
using namespace std;
typedef char T_elem;
T_elem fin='#';
int main() {
Agen<T_elem> A,B;
/*********************************************Leer Arbol General en agen.dat***************************************/
ifstream f_input("..//..//I-O_Agen//agen.dat");
rellenarAgen(f_input,A);
f_input.close();
cout <<"Caracteristicas del Arbol Binario A************************************:\n"<<endl;
imprimirAgen(A);
cout<<"\n\n";
T_elem elem =A.elemento(A.hijoIzqdo(A.hermDrcho(A.hijoIzqdo(A.raiz()))));
cout<<"El elemento "<<elem<<" es hijo?"<<is_sheet(A,A.hijoIzqdo(A.hermDrcho(A.hijoIzqdo(A.raiz())))) <<endl;
cout<<"El grado del Arbol General es: "<<grade(A)<<endl;
cout<<"La profundidad del nodo "<<elem<<" es :"<<deep(A,A.hijoIzqdo(A.hermDrcho(A.hijoIzqdo(A.raiz())))) <<endl;
cout<<"El Desequilibrio del Arbol General es: "<<disequilibrium(A) <<endl;
/********************************************Leer Arbol General en agen2.dat***************************************/
ifstream f_input2("..//..//I-O_Agen//agen2.dat");
rellenarAgen(f_input2,B);
f_input2.close();
cout <<"\n\nCaracteristicas del Arbol Binario B************************************:\n"<<endl;
imprimirAgen(B);
cout<<"\n\n";
cout<<"El Desequilibrio del Arbol General es: "<<disequilibrium(B) <<endl;
return 0;
}
| 33.363636 | 120 | 0.536104 | Zayk01 |
2b3fd7f7ecfe4d98aaece49b4f8b3139eae7275c | 2,077 | cpp | C++ | src/backend/benchmark/ycsb/ycsb.cpp | saurabhkadekodi/peloton-p3 | e0d84cdf59c0724850ad2d6b187fdb2ef1730369 | [
"Apache-2.0"
] | 1 | 2021-02-28T19:37:04.000Z | 2021-02-28T19:37:04.000Z | src/backend/benchmark/ycsb/ycsb.cpp | saurabhkadekodi/peloton-p3 | e0d84cdf59c0724850ad2d6b187fdb2ef1730369 | [
"Apache-2.0"
] | 1 | 2016-05-06T05:07:37.000Z | 2016-05-09T23:40:50.000Z | src/backend/benchmark/ycsb/ycsb.cpp | saurabhkadekodi/peloton-p3 | e0d84cdf59c0724850ad2d6b187fdb2ef1730369 | [
"Apache-2.0"
] | null | null | null | //===----------------------------------------------------------------------===//
//
// PelotonDB
//
// ycsb.cpp
//
// Identification: benchmark/ycsb/ycsb.cpp
//
// Copyright (c) 2015, Carnegie Mellon University Database Group
//
//===----------------------------------------------------------------------===//
#include <iostream>
#include <fstream>
#include <iomanip>
#include "backend/common/logger.h"
#include "backend/benchmark/ycsb/ycsb_configuration.h"
#include "backend/benchmark/ycsb/ycsb_loader.h"
#include "backend/benchmark/ycsb/ycsb_workload.h"
namespace peloton {
namespace benchmark {
namespace ycsb {
configuration state;
std::ofstream out("outputfile.summary", std::ofstream::out);
static void WriteOutput() {
LOG_INFO("----------------------------------------------------------");
LOG_INFO("%lf %d %d :: %lf tps, %lf", state.update_ratio, state.scale_factor,
state.column_count, state.throughput, state.abort_rate);
out << state.update_ratio << " ";
out << state.scale_factor << " ";
out << state.column_count << "\n";
for (size_t round_id = 0; round_id < state.snapshot_throughput.size();
++round_id) {
out << "[" << std::setw(3) << std::left
<< state.snapshot_duration * round_id << " - " << std::setw(3)
<< std::left << state.snapshot_duration * (round_id + 1)
<< " s]: " << state.snapshot_throughput[round_id] << " "
<< state.snapshot_abort_rate[round_id] << "\n";
}
out << state.throughput << " ";
out << state.abort_rate << "\n";
out.flush();
out.close();
}
// Main Entry Point
void RunBenchmark() {
// Create and load the user table
CreateYCSBDatabase();
LoadYCSBDatabase();
// Run the workload
RunWorkload();
WriteOutput();
}
} // namespace ycsb
} // namespace benchmark
} // namespace peloton
int main(int argc, char **argv) {
peloton::benchmark::ycsb::ParseArguments(argc, argv,
peloton::benchmark::ycsb::state);
peloton::benchmark::ycsb::RunBenchmark();
return 0;
}
| 25.329268 | 80 | 0.564275 | saurabhkadekodi |
2b40b95e243e4965aa8ce0d4ba9a228dfa885871 | 2,114 | hpp | C++ | src/arkesia_plugins.hpp | zerotri/arkesia | a5105a93dab18ab3c40dc8dc06b801797155d1c1 | [
"MIT"
] | null | null | null | src/arkesia_plugins.hpp | zerotri/arkesia | a5105a93dab18ab3c40dc8dc06b801797155d1c1 | [
"MIT"
] | null | null | null | src/arkesia_plugins.hpp | zerotri/arkesia | a5105a93dab18ab3c40dc8dc06b801797155d1c1 | [
"MIT"
] | null | null | null | #include <dlfcn.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <functional>
#include <iostream>
namespace ark {
namespace plugin {
template <typename Signature>
Signature* dl_cast(void* f)
{
return reinterpret_cast<Signature*>(f);
}
struct plugin_t {
void* dynamic_library;
// standard
void (*initialize)( );
void (*shutdown)( );
void (*update)( float dt );
void (*draw)( );
void* (*get_api)( uint32_t );
};
plugin_t load( std::string filename ) {
char working_directory[1024];
getcwd( working_directory, 1024 );
filename.insert(0, working_directory);
plugin_t plugin = {};
plugin.dynamic_library = dlopen( filename.c_str() , RTLD_NOW|RTLD_GLOBAL);
if (!plugin.dynamic_library) {
fprintf(stderr, "%s\n", dlerror());
}
if( plugin.dynamic_library != nullptr) {
plugin.initialize = dl_cast<void()>( dlsym( plugin.dynamic_library, "initialize" ) );
plugin.shutdown = dl_cast<void()>( dlsym( plugin.dynamic_library, "shutdown" ) );
plugin.update = dl_cast<void( float )>( dlsym( plugin.dynamic_library, "update" ) );
plugin.draw = dl_cast<void()>( dlsym( plugin.dynamic_library, "draw" ) );
plugin.get_api = dl_cast<void*( uint32_t )>( dlsym( plugin.dynamic_library, "get_api" ) );
}
else {
std::cout << "Could not load plugin " << filename << std::endl;
std::cout << "working directory: " << working_directory << std::endl;
}
return plugin;
}
void* request_api( plugin_t plugin, uint32_t api ) {
//plugin.get_api
}
template<typename _T>
_T request_api( plugin_t plugin ) {
}
void close_plugin( plugin_t plugin ) {
dlclose( plugin.dynamic_library );
}
}
} | 36.448276 | 109 | 0.529801 | zerotri |
2b44c08828f91cadc9068071366c9c5a8e6edb8c | 5,259 | cpp | C++ | States/settingsstate.cpp | lukasz-bielerzewski/Project-Arena-Fighter | 15e4cac998020256cf9e131ff140d0b8a2f6b72e | [
"MIT"
] | null | null | null | States/settingsstate.cpp | lukasz-bielerzewski/Project-Arena-Fighter | 15e4cac998020256cf9e131ff140d0b8a2f6b72e | [
"MIT"
] | null | null | null | States/settingsstate.cpp | lukasz-bielerzewski/Project-Arena-Fighter | 15e4cac998020256cf9e131ff140d0b8a2f6b72e | [
"MIT"
] | null | null | null | #include "Source_Files/precompiled_header.h"
#include "settingsstate.h"
//Initialzer functions
void SettingsState::initVariables()
{
this->modes = sf::VideoMode::getFullscreenModes();
}
void SettingsState::initBackground()
{
this->background.setSize(sf::Vector2f
(static_cast<float>(this->window->getSize().x),
static_cast<float>(this->window->getSize().y)));
if(!this->backgroundTexture.loadFromFile("Resources/Images/Backgrounds/menu_background.jpg"))
{
throw"ERROR::MAIN_MENU_STATE::FAILED_TO_LOAD_BACKGROUND_TEXTURE";
}
this->background.setTexture(&this->backgroundTexture);
}
void SettingsState::initFonts()
{
if(!this->font.loadFromFile("Resources/Fonts/PressStart2P-Regular.ttf"))
{
throw("ERROR::MAIN_MENU_STATE::COULD_NOT_LOAD_FONT");
}
}
void SettingsState::initKeybinds()
{
std::ifstream ifs("Config/mainmenustate_keybinds.ini");
if(ifs.is_open())
{
std::string key = "";
std::string key2 = "";
while(ifs >> key >> key2)
{
this->keybinds[key] = this->supportedKeys->at(key2);
}
}
ifs.close();
}
void SettingsState::initGui()
{
this->buttons["BACK_TO_MAIN_MENU"] = new gui::Button(
525.f, 900.f, 350.f, 70.f,
&this->font, "Back to main menu", 14,
sf::Color(240, 240, 240, 255), sf::Color(255, 255, 255, 255), sf::Color(100, 100, 100, 255),
sf::Color(70, 70, 70, 200), sf::Color(150, 150, 250, 255), sf::Color(20, 20, 20, 200)
);
this->buttons["APPLY_SETTINGS"] = new gui::Button(
125.f, 900.f, 350.f, 70.f,
&this->font, "Apply settings", 14,
sf::Color(240, 240, 240, 255), sf::Color(255, 255, 255, 255), sf::Color(100, 100, 100, 255),
sf::Color(70, 70, 70, 200), sf::Color(150, 150, 250, 255), sf::Color(20, 20, 20, 200)
);
std::vector<std::string> modes_str;
for(auto &i : this->modes)
{
modes_str.push_back(std::to_string(i.width) + " x " + std::to_string(i.height));
}
this->dropDownLists["RESOLUTION"] = new gui::DropDownList(575.f, 285.f, 250.f, 50.f, font, modes_str.data(), modes_str.size());
}
void SettingsState::initText()
{
this->optionsText.setFont(this->font);
this->optionsText.setPosition(sf::Vector2f(125.f, 300.f));
this->optionsText.setCharacterSize(30.f);
this->optionsText.setFillColor(sf::Color(255, 255, 255, 200));
this->optionsText.setString(
"Resolution \n\n\nFullscreen \n\n\nVsync \n\n\nAntialiasing"
);
}
//Constructors / Destructors
SettingsState::SettingsState(StateData *state_data)
: State(state_data)
{
this->initVariables();
this->initBackground();
this->initFonts();
this->initKeybinds();
this->initGui();
this->initText();
}
SettingsState::~SettingsState()
{
auto it = this->buttons.begin();
for(it = this->buttons.begin(); it != this->buttons.end(); ++it)
{
delete it->second;
}
auto it2 = this->dropDownLists.begin();
for(it2 = this->dropDownLists.begin(); it2 != this->dropDownLists.end(); ++it2)
{
delete it2->second;
}
}
//Accessors
//Functions
void SettingsState::updateInput(const float &dt)
{
}
void SettingsState::updateGui(const float &dt)
{
//Updates all the gui elements and theirs functionality
//Buttons
for(auto &it : this->buttons)
{
it.second->update(this->mousePosView);
}
//Buttons functionality
//Quit the game
if(this->buttons["BACK_TO_MAIN_MENU"]->isPressed())
{
this->endState();
}
//Apply selected settings
if(this->buttons["APPLY_SETTINGS"]->isPressed())
{
this->stateData->graphicsSettings->resolution = modes[this->dropDownLists["RESOLUTION"]->getActiveElementId()];
//TEST TO BE REMOVED LATER
this->window->create(this->stateData->graphicsSettings->resolution, this->stateData->graphicsSettings->title, sf::Style::Default);
}
//Dropdown lists
for(auto &it : this->dropDownLists)
{
it.second->update(this->mousePosView, dt);
}
//Dropdown lists functionality
}
void SettingsState::update(const float &dt)
{
this->updateMousePositions();
this->updateInput(dt);
this->updateGui(dt);
}
void SettingsState::renderGui(sf::RenderTarget &target)
{
//Render buttons
for(auto &it : this->buttons)
{
it.second->render(target);
}
//Render dropdown lits
for(auto &it : this->dropDownLists)
{
it.second->render(target);
}
}
void SettingsState::render(sf::RenderTarget *target)
{
if(!target)
{
target = this->window;
}
target->draw(this->background);
this->renderGui(*target);
target->draw(this->optionsText);
//Tool for positioning buttons, to be removed later!
sf::Text mouseText;
mouseText.setPosition(this->mousePosView.x + 10.f, this->mousePosView.y);
mouseText.setFont(this->font);
mouseText.setCharacterSize(10);
std::stringstream ss;
ss << this->mousePosView.x << " " << this->mousePosView.y;
mouseText.setString(ss.str());
target->draw(mouseText);
}
| 25.779412 | 138 | 0.618939 | lukasz-bielerzewski |
2b46d3ae6243a148d96656b8f18b87c19dd7d2a8 | 118 | cpp | C++ | src/terrain/mountain.cpp | JoiNNewtany/LETI-Game | 51d31a2b0b212f8bbd11c1562af4ef23d34437b6 | [
"Unlicense"
] | 2 | 2021-11-15T19:27:32.000Z | 2021-12-10T20:51:37.000Z | src/terrain/mountain.cpp | JoiNNewtany/LETI-Game | 51d31a2b0b212f8bbd11c1562af4ef23d34437b6 | [
"Unlicense"
] | null | null | null | src/terrain/mountain.cpp | JoiNNewtany/LETI-Game | 51d31a2b0b212f8bbd11c1562af4ef23d34437b6 | [
"Unlicense"
] | null | null | null | #include "mountain.hpp"
#include "unit/unit.hpp"
void Mountain::affect(Unit&) { }
void Mountain::restore(Unit&) { }
| 16.857143 | 33 | 0.686441 | JoiNNewtany |
2b48739a8eeb34b9fc41a8b70b4c9cd1ed83ff93 | 3,735 | cpp | C++ | main.cpp | Yveh/Compiler-Mx_star | e00164537528858ed128dbc5a5c4cf7006d6276e | [
"MIT"
] | 1 | 2020-01-23T14:34:11.000Z | 2020-01-23T14:34:11.000Z | main.cpp | Yveh/Compiler-Mx_star | e00164537528858ed128dbc5a5c4cf7006d6276e | [
"MIT"
] | null | null | null | main.cpp | Yveh/Compiler-Mx_star | e00164537528858ed128dbc5a5c4cf7006d6276e | [
"MIT"
] | null | null | null | #include <iostream>
#include <DominatorTree.h>
#include <cstring>
#include "antlr4-runtime.h"
#include "Mx_starLexer.h"
#include "Mx_starParser.h"
#include "ASTBuilder.h"
#include "TypeChecker.h"
#include "SemanticIssue.h"
#include "Builtin.h"
#include "IRBuilder.h"
#include "IRProgram.h"
#include "RVProgram.h"
#include "InstSelector.h"
#include "SSAConstructor.h"
#include "SSADestructor.h"
#include "RegAllocation.h"
int main(int argc, char *argv[]){
bool codegen = true;
bool optimize = true;
if (argc == 2) {
if (strcmp(argv[1], "-s") == 0) {
codegen = false;
optimize = false;
}
else if (strcmp(argv[1], "-c") == 0) {
optimize = false;
}
}
// const std::string filepath("../local-judge/testcase/optim/lca.mx");
//// const std::string filepath("../test.mx");
// std::ifstream ifs;
// ifs.open(filepath);
// if (!ifs.good()) {
// std::cerr << "bad" << std::endl;
// }
// antlr4::ANTLRInputStream input(ifs);
antlr4::ANTLRInputStream input(std::cin);
Mx_starLexer lexer(&input);
antlr4::CommonTokenStream tokens(&lexer);
tokens.fill();
Mx_starParser parser(&tokens);
antlr4::tree::ParseTree *tree = parser.prog();
if (lexer.getNumberOfSyntaxErrors() + parser.getNumberOfSyntaxErrors() > 0)
return -1;
ASTBuilder ASTbuilder;
auto root = ASTbuilder.build(tree);
std::shared_ptr<SemanticIssue> issues = std::make_shared<SemanticIssue>();
std::shared_ptr<Env> env = std::make_shared<Env>();
Builtin::init(env);
std::shared_ptr<TypeChecker> checker = std::make_shared<TypeChecker>(issues, env);
checker->createEnv(root);
if (issues->count() > 0) {
issues->print();
return -1;
}
checker->typeCheck(root);
if (issues->count() > 0) {
issues->print();
return -1;
}
if (!codegen)
return 0;
std::shared_ptr<IRProgram> IRProg = std::make_shared<IRProgram>();
std::shared_ptr<IRBuilder> IRbuilder = std::make_shared<IRBuilder>(IRProg);
IRbuilder->createIR(root);
IRProg->getAllBlocks();
// IRProg->outputIR(std::cout);
std::shared_ptr<DominatorTree> Domtree = std::make_shared<DominatorTree>();
Domtree->createDomTree(IRProg);
std::shared_ptr<SSAConstructor> SSAconstructor = std::make_shared<SSAConstructor>();
SSAconstructor->run(IRProg);
// IRProg->outputIR(std::cout);
// const std::string SSAFilePath2 = std::string("../beforeopt.ll");
// std::ofstream ofsSSA2(SSAFilePath2);
// IRProg->outputIR(ofsSSA2);
if (optimize) {
// IRProg->jumpErase();
IRProg->constantPropagation();
}
// const std::string SSAFilePath = std::string("../SSA.ll");
// std::ofstream ofsSSA(SSAFilePath);
// IRProg->outputIR(ofsSSA);
std::shared_ptr<SSADestructor> SSAdestructor = std::make_shared<SSADestructor>();
SSAdestructor->run(IRProg);
// IRProg->outputIR(std::cout);
if (optimize)
IRProg->optimize();
std::shared_ptr<RVProgram> RVProg = std::make_shared<RVProgram>();
std::shared_ptr<InstSelector> RVbuilder = std::make_shared<InstSelector>(IRProg, RVProg);
RVbuilder->run();
// RVProg->outputIR(std::cout);
// const std::string RVFilePath("../RV.s");
// std::ofstream ofsRV(RVFilePath);
// RVProg->outputIR(ofsRV);
std::shared_ptr<RegAllocation> RegAllocator = std::make_shared<RegAllocation>(RVProg);
RegAllocator->run();
if (optimize)
RVProg->optimize();
RVProg->outputIR(std::cout);
const std::string FinalFilePath = std::string("./output.s");
std::ofstream ofsFinal(FinalFilePath);
RVProg->outputIR(ofsFinal);
return 0;
} | 28.730769 | 93 | 0.637216 | Yveh |
2b4a4bb097547d2ee9abf66b282121323f00209c | 1,329 | cpp | C++ | benchmark/storage/dispatch.single.cpp | BRevzin/dyno | 76dcd0cc29cfa0e48f893e1ac32b6380b35437e0 | [
"BSL-1.0"
] | 739 | 2017-03-17T15:02:08.000Z | 2022-03-29T03:25:32.000Z | benchmark/storage/dispatch.single.cpp | BRevzin/dyno | 76dcd0cc29cfa0e48f893e1ac32b6380b35437e0 | [
"BSL-1.0"
] | 41 | 2017-03-09T07:04:13.000Z | 2021-05-27T20:05:24.000Z | benchmark/storage/dispatch.single.cpp | BRevzin/dyno | 76dcd0cc29cfa0e48f893e1ac32b6380b35437e0 | [
"BSL-1.0"
] | 43 | 2017-04-08T07:23:33.000Z | 2021-08-20T14:20:49.000Z | // Copyright Louis Dionne 2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include "model.hpp"
#include <dyno.hpp>
#include <benchmark/benchmark.h>
#include <cstddef>
#include <type_traits>
#include <utility>
// This benchmark measures the overhead of dispatching methods through a
// type-erased wrapper with different storage policies.
template <typename StoragePolicy, typename T>
static void BM_dispatch_single(benchmark::State& state) {
model<StoragePolicy> m{T{}};
benchmark::DoNotOptimize(m);
while (state.KeepRunning()) {
m.f1();
m.f2();
m.f3();
}
}
template <std::size_t Bytes>
using WithSize = std::aligned_storage_t<Bytes>;
BENCHMARK_TEMPLATE(BM_dispatch_single, inheritance_tag, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::remote_storage, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::sbo_storage<4>, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::sbo_storage<8>, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::sbo_storage<16>, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::sbo_storage<32>, WithSize<8>);
BENCHMARK_TEMPLATE(BM_dispatch_single, dyno::local_storage<32>, WithSize<8>);
BENCHMARK_MAIN();
| 32.414634 | 81 | 0.756208 | BRevzin |
2b4e3e809af4fcfbb8e3cf4dacb73652e6c34cf4 | 2,124 | cpp | C++ | code-demo/tree/bst_k19lesson15.cpp | kzhereb/knu-is-progr2019 | 6a85b3659103800d8ec4a8097df2a547d6c8dda4 | [
"MIT"
] | null | null | null | code-demo/tree/bst_k19lesson15.cpp | kzhereb/knu-is-progr2019 | 6a85b3659103800d8ec4a8097df2a547d6c8dda4 | [
"MIT"
] | null | null | null | code-demo/tree/bst_k19lesson15.cpp | kzhereb/knu-is-progr2019 | 6a85b3659103800d8ec4a8097df2a547d6c8dda4 | [
"MIT"
] | null | null | null | #include <iostream>
#include <cassert>
using std::cout;
using std::endl;
struct TreeNode {
int value;
TreeNode* left;
TreeNode* right;
TreeNode(int val, TreeNode* lef=nullptr, TreeNode* rig=nullptr) {
value = val;
left = lef;
right = rig;
}
};
bool insert(TreeNode** root, int val) {
if (*root == nullptr) {
*root = new TreeNode(val);
return true;
}
if (val<(*root)->value) {
return insert(&((*root)->left),val);
} else if (val>(*root)->value) {
return insert(&((*root)->right),val);
}
return false;
}
TreeNode** find_prev(TreeNode* root) {
assert(root!=nullptr);
assert(root->left!=nullptr);
TreeNode** cur = &(root->left);
while((*cur)->right) {
cur = &((*cur)->right);
}
return cur;
}
void remove(TreeNode** root, int val) {
if(*root==nullptr) {
return;
}
if (val<(*root)->value) {
remove(&((*root)->left),val);
} else if (val>(*root)->value) {
remove(&((*root)->right),val);
} else {
if ((*root)->left) {
if ((*root)->right) { //both children
TreeNode** prev_node = find_prev(*root);
(*root)->value = (*prev_node)->value;
TreeNode* tmp = (*prev_node)->left;
delete * prev_node;
*prev_node = tmp;
} else { //only left child
TreeNode* tmp = (*root)->left;
delete *root;
*root = tmp;
}
} else {
if ((*root)->right) { //only right child
TreeNode* tmp = (*root)->right;
delete *root;
*root = tmp;
} else { //no children
delete *root;
*root = nullptr;
}
}
}
}
void print_inorder(const TreeNode * root, bool is_top=true) {
if (!root) {
if (is_top) {cout<<"Empty tree"<<endl;}
return;
}
print_inorder(root->left,false);
cout<<root->value<<" ";
print_inorder(root->right,false);
if (is_top) {cout<<endl;}
}
int main() {
TreeNode* root = nullptr;
insert(&root,5);
insert(&root,8);
insert(&root,1);
insert(&root,16);
insert(&root,0);
insert(&root,7);
print_inorder(root);
remove(&root,5);
print_inorder(root);
remove(&root,8);
print_inorder(root);
return 0;
}
| 19.135135 | 67 | 0.564972 | kzhereb |
2b554c72c9fdc4a063e68a30251f0e9cdd51b183 | 2,860 | cc | C++ | deps/winpty/misc/IsNewConsole.cc | qualityhackrunner/node-pty | 027d972e714c3ad65ab5d7cf55a8c14a3eaa1f77 | [
"MIT"
] | 1,090 | 2015-01-03T19:33:27.000Z | 2022-03-29T01:20:10.000Z | deps/winpty/misc/IsNewConsole.cc | qualityhackrunner/node-pty | 027d972e714c3ad65ab5d7cf55a8c14a3eaa1f77 | [
"MIT"
] | 213 | 2019-05-07T03:12:13.000Z | 2022-03-31T21:11:52.000Z | node_modules_native/node_modules_forked/node-pty/deps/winpty/misc/IsNewConsole.cc | atlsecsrv-com/B82B787C-E596 | 4e3e58a84e5a5ffb4bf1b6e88a12d06be953e450 | [
"MIT"
] | 147 | 2015-01-06T22:14:29.000Z | 2022-03-03T09:31:53.000Z | // Determines whether this is a new console by testing whether MARK moves the
// cursor.
//
// WARNING: This test program may behave erratically if run under winpty.
//
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "TestUtil.cc"
const int SC_CONSOLE_MARK = 0xFFF2;
const int SC_CONSOLE_SELECT_ALL = 0xFFF5;
static COORD getWindowPos(HANDLE conout) {
CONSOLE_SCREEN_BUFFER_INFO info = {};
BOOL ret = GetConsoleScreenBufferInfo(conout, &info);
ASSERT(ret && "GetConsoleScreenBufferInfo failed");
return { info.srWindow.Left, info.srWindow.Top };
}
static COORD getWindowSize(HANDLE conout) {
CONSOLE_SCREEN_BUFFER_INFO info = {};
BOOL ret = GetConsoleScreenBufferInfo(conout, &info);
ASSERT(ret && "GetConsoleScreenBufferInfo failed");
return {
static_cast<short>(info.srWindow.Right - info.srWindow.Left + 1),
static_cast<short>(info.srWindow.Bottom - info.srWindow.Top + 1)
};
}
static COORD getCursorPos(HANDLE conout) {
CONSOLE_SCREEN_BUFFER_INFO info = {};
BOOL ret = GetConsoleScreenBufferInfo(conout, &info);
ASSERT(ret && "GetConsoleScreenBufferInfo failed");
return info.dwCursorPosition;
}
static void setCursorPos(HANDLE conout, COORD pos) {
BOOL ret = SetConsoleCursorPosition(conout, pos);
ASSERT(ret && "SetConsoleCursorPosition failed");
}
int main() {
const HANDLE conout = openConout();
const HWND hwnd = GetConsoleWindow();
ASSERT(hwnd != NULL && "GetConsoleWindow() returned NULL");
// With the legacy console, the Mark command moves the the cursor to the
// top-left cell of the visible console window. Determine whether this
// is the new console by seeing if the cursor moves.
const auto windowSize = getWindowSize(conout);
if (windowSize.X <= 1) {
printf("Error: console window must be at least 2 columns wide\n");
trace("Error: console window must be at least 2 columns wide");
return 1;
}
bool cursorMoved = false;
const auto initialPos = getCursorPos(conout);
const auto windowPos = getWindowPos(conout);
setCursorPos(conout, { static_cast<short>(windowPos.X + 1), windowPos.Y });
{
const auto posA = getCursorPos(conout);
SendMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_MARK, 0);
const auto posB = getCursorPos(conout);
cursorMoved = memcmp(&posA, &posB, sizeof(posA)) != 0;
SendMessage(hwnd, WM_CHAR, 27, 0x00010001); // Send ESCAPE
}
setCursorPos(conout, initialPos);
if (cursorMoved) {
printf("Legacy console (i.e. MARK moved cursor)\n");
trace("Legacy console (i.e. MARK moved cursor)");
} else {
printf("Windows 10 new console (i.e MARK did not move cursor)\n");
trace("Windows 10 new console (i.e MARK did not move cursor)");
}
return 0;
}
| 32.5 | 79 | 0.682517 | qualityhackrunner |
2b5f06bd8c2dc78435339639ef6469dd97a202f6 | 2,393 | cpp | C++ | vpc/src/v2/model/ListVpcRoutesResponse.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | 5 | 2021-03-03T08:23:43.000Z | 2022-02-16T02:16:39.000Z | vpc/src/v2/model/ListVpcRoutesResponse.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | null | null | null | vpc/src/v2/model/ListVpcRoutesResponse.cpp | yangzhaofeng/huaweicloud-sdk-cpp-v3 | 4f3caac5ba9a9b75b4e5fd61683d1c4d57ec1c23 | [
"Apache-2.0"
] | 7 | 2021-02-26T13:53:35.000Z | 2022-03-18T02:36:43.000Z |
#include "huaweicloud/vpc/v2/model/ListVpcRoutesResponse.h"
namespace HuaweiCloud {
namespace Sdk {
namespace Vpc {
namespace V2 {
namespace Model {
ListVpcRoutesResponse::ListVpcRoutesResponse()
{
routesIsSet_ = false;
routesLinksIsSet_ = false;
}
ListVpcRoutesResponse::~ListVpcRoutesResponse() = default;
void ListVpcRoutesResponse::validate()
{
}
web::json::value ListVpcRoutesResponse::toJson() const
{
web::json::value val = web::json::value::object();
if(routesIsSet_) {
val[utility::conversions::to_string_t("routes")] = ModelBase::toJson(routes_);
}
if(routesLinksIsSet_) {
val[utility::conversions::to_string_t("routes_links")] = ModelBase::toJson(routesLinks_);
}
return val;
}
bool ListVpcRoutesResponse::fromJson(const web::json::value& val)
{
bool ok = true;
if(val.has_field(utility::conversions::to_string_t("routes"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("routes"));
if(!fieldValue.is_null())
{
std::vector<VpcRoute> refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setRoutes(refVal);
}
}
if(val.has_field(utility::conversions::to_string_t("routes_links"))) {
const web::json::value& fieldValue = val.at(utility::conversions::to_string_t("routes_links"));
if(!fieldValue.is_null())
{
std::vector<NeutronPageLink> refVal;
ok &= ModelBase::fromJson(fieldValue, refVal);
setRoutesLinks(refVal);
}
}
return ok;
}
std::vector<VpcRoute>& ListVpcRoutesResponse::getRoutes()
{
return routes_;
}
void ListVpcRoutesResponse::setRoutes(const std::vector<VpcRoute>& value)
{
routes_ = value;
routesIsSet_ = true;
}
bool ListVpcRoutesResponse::routesIsSet() const
{
return routesIsSet_;
}
void ListVpcRoutesResponse::unsetroutes()
{
routesIsSet_ = false;
}
std::vector<NeutronPageLink>& ListVpcRoutesResponse::getRoutesLinks()
{
return routesLinks_;
}
void ListVpcRoutesResponse::setRoutesLinks(const std::vector<NeutronPageLink>& value)
{
routesLinks_ = value;
routesLinksIsSet_ = true;
}
bool ListVpcRoutesResponse::routesLinksIsSet() const
{
return routesLinksIsSet_;
}
void ListVpcRoutesResponse::unsetroutesLinks()
{
routesLinksIsSet_ = false;
}
}
}
}
}
}
| 20.808696 | 103 | 0.678646 | yangzhaofeng |
2b5f111ea9d499fccf486d2ecad2f3d75ec7441b | 2,459 | cpp | C++ | src/meta/processors/admin/ClearSpaceProcessor.cpp | wenhaocs/nebula | 326b856cdf44fcaf67d3883073dc9412a9e3eebd | [
"Apache-2.0"
] | null | null | null | src/meta/processors/admin/ClearSpaceProcessor.cpp | wenhaocs/nebula | 326b856cdf44fcaf67d3883073dc9412a9e3eebd | [
"Apache-2.0"
] | null | null | null | src/meta/processors/admin/ClearSpaceProcessor.cpp | wenhaocs/nebula | 326b856cdf44fcaf67d3883073dc9412a9e3eebd | [
"Apache-2.0"
] | null | null | null | /* Copyright (c) 2022 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/
#include "meta/processors/admin/ClearSpaceProcessor.h"
namespace nebula {
namespace meta {
void ClearSpaceProcessor::process(const cpp2::ClearSpaceReq& req) {
GraphSpaceID spaceId;
std::vector<HostAddr> hosts;
{
folly::SharedMutex::ReadHolder holder(LockUtils::lock());
// 1. Fetch spaceId
const auto& spaceName = req.get_space_name();
auto spaceRet = getSpaceId(spaceName);
if (!nebula::ok(spaceRet)) {
auto retCode = nebula::error(spaceRet);
if (retCode == nebula::cpp2::ErrorCode::E_SPACE_NOT_FOUND) {
if (req.get_if_exists()) {
retCode = nebula::cpp2::ErrorCode::SUCCEEDED;
} else {
LOG(WARNING) << "Clear space Failed, space " << spaceName << " not existed.";
}
} else {
LOG(ERROR) << "Clear space Failed, space " << spaceName
<< " error: " << apache::thrift::util::enumNameSafe(retCode);
}
handleErrorCode(retCode);
onFinished();
return;
}
spaceId = nebula::value(spaceRet);
// 2. Fetch all parts info accroding the spaceId.
auto ret = getAllParts(spaceId);
if (!nebula::ok(ret)) {
handleErrorCode(nebula::error(ret));
onFinished();
return;
}
// 3. Determine which hosts the space is distributed on.
std::unordered_set<HostAddr> distributedOnHosts;
for (auto& partEntry : nebula::value(ret)) {
for (auto& host : partEntry.second) {
distributedOnHosts.insert(host);
}
}
// 4. select the active hosts.
auto activeHostsRet = ActiveHostsMan::getActiveHosts(kvstore_);
if (!nebula::ok(activeHostsRet)) {
handleErrorCode(nebula::error(activeHostsRet));
onFinished();
return;
}
auto activeHosts = std::move(nebula::value(activeHostsRet));
for (auto& host : distributedOnHosts) {
if (std::find(activeHosts.begin(), activeHosts.end(), host) != activeHosts.end()) {
hosts.push_back(host);
}
}
if (hosts.size() == 0) {
handleErrorCode(nebula::cpp2::ErrorCode::E_NO_HOSTS);
onFinished();
return;
}
}
// 5. Delete the space data on the corresponding hosts.
auto clearRet = adminClient_->clearSpace(spaceId, hosts).get();
handleErrorCode(clearRet);
onFinished();
return;
}
} // namespace meta
} // namespace nebula
| 29.626506 | 89 | 0.629931 | wenhaocs |
2b609e13786eea05ea2896d4b25c08a18f48da32 | 449 | cpp | C++ | 10-19/15. Lattice paths.cpp | swapagarwal/ProjectEuler | 34465b5a87166942e4bad3ce815a79a88567d3fd | [
"MIT"
] | 1 | 2018-02-24T07:52:10.000Z | 2018-02-24T07:52:10.000Z | 10-19/15. Lattice paths.cpp | swapagarwal/ProjectEuler | 34465b5a87166942e4bad3ce815a79a88567d3fd | [
"MIT"
] | null | null | null | 10-19/15. Lattice paths.cpp | swapagarwal/ProjectEuler | 34465b5a87166942e4bad3ce815a79a88567d3fd | [
"MIT"
] | 3 | 2015-03-27T17:23:16.000Z | 2021-06-07T15:44:10.000Z | /* Project Euler Problem 15: Lattice paths
* Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
* How many such routes are there through a 20×20 grid?
*/
#include <iostream>
using namespace std;
int main()
{
long long ans=1;
for(int i=0;i<20;i++)
{
ans*=(40-i);
ans/=(i+1);
}
cout<<ans<<endl;
return 0;
}
| 21.380952 | 155 | 0.632517 | swapagarwal |
2b62850ee36c124fbe7f261764d45039547620d5 | 746 | hpp | C++ | src/MemoryManager.hpp | zwimer/Memory-Management-Simulator | 9aacfd962459a62ca878dbf5370fdda4bf770bb6 | [
"MIT"
] | null | null | null | src/MemoryManager.hpp | zwimer/Memory-Management-Simulator | 9aacfd962459a62ca878dbf5370fdda4bf770bb6 | [
"MIT"
] | null | null | null | src/MemoryManager.hpp | zwimer/Memory-Management-Simulator | 9aacfd962459a62ca878dbf5370fdda4bf770bb6 | [
"MIT"
] | null | null | null | /* Operating Systems Project 2
* Alex Slanski, Owen Stenson, Zac Wimer
*/
#ifndef MEMORY_MANAGER_HPP
#define MEMORY_MANAGER_HPP
#include "main.hpp"
#include "HardDrive.hpp"
#include <string>
//An abstract class to represent a MemoryManager
class Contiguous::MemoryManager {
public:
//Constructor
MemoryManager(const std::string& s);
virtual ~MemoryManager();
//User Interface methods
//Reserve n memory units for process p
//addProc returns true if the process was added
bool addProc(char p, int n);
void removeProc(char p);
protected:
//Add or remove process p
virtual void removeProcP(char p) = 0;
virtual void addProcP(char p, int n) = 0;
//Representation
const std::string name;
HardDrive m;
};
#endif
| 18.65 | 51 | 0.723861 | zwimer |
2b64503e1a0f06d18f83d931281ee2cb34563dea | 518 | cpp | C++ | 2-Structural/11.Flyweight/src/Flyweight/LandMine.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | 21 | 2017-11-08T11:32:48.000Z | 2021-03-29T08:58:04.000Z | 2-Structural/11.Flyweight/src/Flyweight/LandMine.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | null | null | null | 2-Structural/11.Flyweight/src/Flyweight/LandMine.cpp | gfa99/gof_design_patterns | a33ee7f344f8e382bb9fc676b77b22a5a123bca0 | [
"Apache-2.0"
] | 8 | 2017-11-26T13:57:50.000Z | 2021-08-23T06:52:57.000Z | #include <iostream>
#include "Flyweight/LandMine.h"
namespace GoF {
namespace Flyweight {
LandMine::LandMine()
: AbstractItem('@')
{
std::cout << "\nCreating a LandMine .." << std::endl;
}
void LandMine::display(const Point & point)
{
std::cout << "displaying LandMine (" << symbol << ") at "
"Y = " << point.getVerticalAxis() <<
" X = " << point.getHorizontalAxis() << std::endl;
}
}
}
| 20.72 | 69 | 0.478764 | gfa99 |
2b6711798e3e3c57d83fe480b8420e0deddfc0b2 | 1,054 | cpp | C++ | PhysicsEngine/ModuleSceneIntro.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | 1 | 2021-12-27T15:12:27.000Z | 2021-12-27T15:12:27.000Z | PhysicsEngine/ModuleSceneIntro.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | null | null | null | PhysicsEngine/ModuleSceneIntro.cpp | bielrabasa/PhysicsEngine | ef3bc64c419a6da4ae234873e3d9da8c196197ec | [
"MIT"
] | null | null | null | #include "Globals.h"
#include "Application.h"
#include "ModuleSceneIntro.h"
ModuleSceneIntro::ModuleSceneIntro(Application* app, bool start_enabled) : Module(app, start_enabled)
{
}
ModuleSceneIntro::~ModuleSceneIntro()
{}
// Load assets
bool ModuleSceneIntro::Start()
{
LOG("Loading Intro assets");
bool ret = true;
App->renderer->camera.x = App->renderer->camera.y = 0;
//Colliders
App->physics->CreateRectangleCollider(0, floor, 1024, 60);
App->physics->CreateRectangleCollider(700, 400, 50, 300);
App->physics->CreateRectangleCollider(300, 600, 50, 100);
//App->physics->CreateRectangleCollider(100, 300, 100, 100);
//App->physics->CreateCircleCollider(725, 320, 100);
App->physics->CreateCircleCollider(500, 500, 100);
return ret;
}
// Load assets
bool ModuleSceneIntro::CleanUp()
{
LOG("Unloading Intro scene");
return true;
}
// Update: draw background
update_status ModuleSceneIntro::Update()
{
SDL_Rect floor_rect = { 0, floor, 1024, 60 };
App->renderer->DrawQuad(floor_rect, 0, 200, 250);
return UPDATE_CONTINUE;
} | 21.510204 | 101 | 0.724858 | bielrabasa |
2b6cd4d2bfd05e2134970ed07e8e1ca76f7409d9 | 2,086 | cpp | C++ | src/ConfigParser.cpp | mpajkowski/puzzle_solver | 9d145cb42f46f4eea6be2f0219f47d573e51d0bc | [
"MIT"
] | 2 | 2018-10-23T22:16:36.000Z | 2018-12-18T23:41:21.000Z | src/ConfigParser.cpp | mpajkowski/puzzle_solver | 9d145cb42f46f4eea6be2f0219f47d573e51d0bc | [
"MIT"
] | 5 | 2018-10-22T23:03:30.000Z | 2018-11-05T20:11:54.000Z | src/ConfigParser.cpp | mpajkowski/puzzle_solver | 9d145cb42f46f4eea6be2f0219f47d573e51d0bc | [
"MIT"
] | null | null | null | #include "ConfigParser.hpp"
#include "State.hpp"
#include <stdexcept>
#include <unordered_set>
ConfigParser::ConfigParser(int argc, char** argv)
{
for (int i = 0; i < argc; ++i) {
envs.push_back(argv[i]);
}
}
auto ConfigParser::createConfig() -> Config
{
auto cfg = Config{};
auto envIterator = ++std::begin(envs);
cfg.strategy = parseStrategy(*envIterator++);
if (cfg.strategy == Constants::Strategy::ASTR) {
cfg.strategyParam = parseHeuristic(*envIterator);
} else {
cfg.strategyParam = parseOrder(*envIterator);
}
++envIterator;
cfg.firstStateFileName = *envIterator++;
cfg.solutionFileName = *envIterator++;
cfg.additionalInfoFileName = *envIterator++;
return cfg;
}
auto ConfigParser::parseStrategy(std::string const& env) -> Constants::Strategy
{
for (auto const& it : Constants::strategy2string) {
if (it.second == env) {
return it.first;
}
}
throw std::invalid_argument{ "Bad strategy variable" };
}
auto ConfigParser::parseHeuristic(std::string const& env) -> Constants::Heuristic
{
for (auto const& it : Constants::heuristic2string) {
if (it.second == env) {
return it.first;
}
}
throw std::invalid_argument{ "Bad heuristic variable" };
}
auto ConfigParser::parseOrder(std::string const& env) -> std::vector<State::Operator>
{
auto orderVec = std::vector<State::Operator>{};
auto uniqueValidator = std::unordered_set<char>{};
for (char ch : env) {
if (uniqueValidator.find(ch) != std::end(uniqueValidator)) {
throw std::invalid_argument{ "Typed same number twice" };
}
uniqueValidator.insert(ch);
switch (ch) {
case 'L':
orderVec.push_back(State::Operator::Left);
break;
case 'R':
orderVec.push_back(State::Operator::Right);
break;
case 'U':
orderVec.push_back(State::Operator::Up);
break;
case 'D':
orderVec.push_back(State::Operator::Down);
break;
default:
throw std::invalid_argument{ "wrong char for move sequence" };
}
}
return orderVec;
}
| 23.704545 | 85 | 0.644295 | mpajkowski |
2b772e9251f0600bb9a059d9521ff8c2dd21a2a8 | 7,589 | cpp | C++ | fbpcf/scheduler/test/benchmarks/SchedulerBenchmark.cpp | SumitKT31/fbpcf | 75f1edc939684d1ac29824cbc3e519d689b01377 | [
"MIT"
] | null | null | null | fbpcf/scheduler/test/benchmarks/SchedulerBenchmark.cpp | SumitKT31/fbpcf | 75f1edc939684d1ac29824cbc3e519d689b01377 | [
"MIT"
] | null | null | null | fbpcf/scheduler/test/benchmarks/SchedulerBenchmark.cpp | SumitKT31/fbpcf | 75f1edc939684d1ac29824cbc3e519d689b01377 | [
"MIT"
] | null | null | null | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <folly/Benchmark.h>
#include "common/init/Init.h"
#include "fbpcf/engine/communication/IPartyCommunicationAgentFactory.h"
#include "fbpcf/engine/util/test/benchmarks/BenchmarkHelper.h"
#include "fbpcf/engine/util/test/benchmarks/NetworkedBenchmark.h"
#include "fbpcf/scheduler/SchedulerHelper.h"
#include "fbpcf/scheduler/test/benchmarks/AllocatorBenchmark.h"
#include "fbpcf/scheduler/test/benchmarks/WireKeeperBenchmark.h"
namespace fbpcf::scheduler {
// IAllocator benchmarks
BENCHMARK(VectorArenaAllocator_allocate, n) {
benchmarkAllocate<int64_t>(
std::make_unique<VectorArenaAllocator<int64_t, unsafe>>(), n);
}
BENCHMARK(VectorArenaAllocator_free, n) {
benchmarkFree<int64_t>(
std::make_unique<VectorArenaAllocator<int64_t, unsafe>>(), n);
}
BENCHMARK(VectorArenaAllocator_get, n) {
benchmarkGet<int64_t>(
std::make_unique<VectorArenaAllocator<int64_t, unsafe>>(), n);
}
BENCHMARK(UnorderedMapAllocator_allocate, n) {
benchmarkAllocate<int64_t>(
std::make_unique<UnorderedMapAllocator<int64_t>>(), n);
}
BENCHMARK(UnorderedMapAllocator_free, n) {
benchmarkFree<int64_t>(std::make_unique<UnorderedMapAllocator<int64_t>>(), n);
}
BENCHMARK(UnorderedMapAllocator_get, n) {
benchmarkGet<int64_t>(std::make_unique<UnorderedMapAllocator<int64_t>>(), n);
}
// WireKeeper benchmarks
BENCHMARK(WireKeeperBenchmark_allocateBooleanValue, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->allocateBooleanValue();
}
}
BENCHMARK(WireKeeperBenchmark_getBooleanValue, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->getBooleanValue(wireIds.at(n));
}
}
BENCHMARK(WireKeeperBenchmark_setBooleanValue, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->setBooleanValue(wireIds.at(n), n & 1);
}
}
BENCHMARK(WireKeeperBenchmark_getFirstAvailableLevel, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->getFirstAvailableLevel(wireIds.at(n));
}
}
BENCHMARK(WireKeeperBenchmark_setFirstAvailableLevel, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->setFirstAvailableLevel(wireIds.at(n), n);
}
}
BENCHMARK(WireKeeperBenchmark_increaseReferenceCount, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->increaseReferenceCount(wireIds.at(n));
}
}
BENCHMARK(WireKeeperBenchmark_decreaseReferenceCount, n) {
BENCHMARK_WIREKEEPER {
wireKeeper->decreaseReferenceCount(wireIds.at(n));
}
}
// Scheduler benchmarks
class SchedulerBenchmark : public engine::util::NetworkedBenchmark {
public:
void setup() override {
auto [agentFactory0, agentFactory1] =
engine::util::getSocketAgentFactories();
agentFactory0_ = std::move(agentFactory0);
agentFactory1_ = std::move(agentFactory1);
// Set up randomized inputs
batchInput0_ = engine::util::getRandomBoolVector(batchSize_);
batchInput1_ = engine::util::getRandomBoolVector(batchSize_);
input0_ = batchInput0_.at(0);
input1_ = batchInput1_.at(0);
randomParty_ = batchInput0_.at(1);
}
protected:
void initSender() override {
sender_ = getScheduler(0, *agentFactory0_);
}
void runSender() override {
runMethod(sender_);
}
void initReceiver() override {
receiver_ = getScheduler(1, *agentFactory1_);
}
void runReceiver() override {
runMethod(receiver_);
}
std::pair<uint64_t, uint64_t> getTrafficStatistics() override {
return sender_->getTrafficStatistics();
}
virtual std::unique_ptr<IScheduler> getScheduler(
int myId,
engine::communication::IPartyCommunicationAgentFactory&
communicationAgentFactory) = 0;
virtual void runMethod(std::unique_ptr<IScheduler>& scheduler) = 0;
size_t batchSize_ = 1000;
std::vector<bool> batchInput0_;
std::vector<bool> batchInput1_;
bool input0_;
bool input1_;
int randomParty_;
private:
std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
agentFactory0_;
std::unique_ptr<engine::communication::IPartyCommunicationAgentFactory>
agentFactory1_;
std::unique_ptr<IScheduler> sender_;
std::unique_ptr<IScheduler> receiver_;
};
class LazySchedulerBenchmark : virtual public SchedulerBenchmark {
protected:
std::unique_ptr<IScheduler> getScheduler(
int myId,
engine::communication::IPartyCommunicationAgentFactory&
communicationAgentFactory) override {
return createLazySchedulerWithInsecureEngine<unsafe>(
myId, communicationAgentFactory);
}
};
class EagerSchedulerBenchmark : virtual public SchedulerBenchmark {
protected:
std::unique_ptr<IScheduler> getScheduler(
int myId,
engine::communication::IPartyCommunicationAgentFactory&
communicationAgentFactory) override {
return createEagerSchedulerWithInsecureEngine<unsafe>(
myId, communicationAgentFactory);
}
};
class NonFreeGatesBenchmark : virtual public SchedulerBenchmark {
protected:
void runMethod(std::unique_ptr<IScheduler>& scheduler) override {
auto wire1 = scheduler->privateBooleanInput(input0_, randomParty_);
auto wire2 = scheduler->privateBooleanInput(input1_, 1 - randomParty_);
IScheduler::WireId<IScheduler::Boolean> wire3;
for (auto level = 0; level < 10; level++) {
for (auto i = 0; i < 200; i++) {
wire3 = scheduler->privateAndPrivate(wire1, wire2);
}
wire2 = wire3;
}
scheduler->getBooleanValue(
scheduler->openBooleanValueToParty(wire3, randomParty_));
}
};
class NonFreeGatesBatchBenchmark : virtual public SchedulerBenchmark {
protected:
void runMethod(std::unique_ptr<IScheduler>& scheduler) override {
auto wire1 =
scheduler->privateBooleanInputBatch(batchInput0_, randomParty_);
auto wire2 =
scheduler->privateBooleanInputBatch(batchInput1_, 1 - randomParty_);
IScheduler::WireId<IScheduler::Boolean> wire3;
for (auto level = 0; level < 10; level++) {
for (auto i = 0; i < 200; i++) {
wire3 = scheduler->privateAndPrivateBatch(wire1, wire2);
}
wire2 = wire3;
}
scheduler->getBooleanValueBatch(
scheduler->openBooleanValueToPartyBatch(wire3, randomParty_));
}
};
class LazyScheduler_NonFreeGates_Benchmark : public LazySchedulerBenchmark,
public NonFreeGatesBenchmark {};
BENCHMARK_COUNTERS(LazyScheduler_NonFreeGates, counters) {
LazyScheduler_NonFreeGates_Benchmark benchmark;
benchmark.runBenchmark(counters);
}
class EagerScheduler_NonFreeGates_Benchmark : public EagerSchedulerBenchmark,
public NonFreeGatesBenchmark {};
BENCHMARK_COUNTERS(EagerScheduler_NonFreeGates, counters) {
EagerScheduler_NonFreeGates_Benchmark benchmark;
benchmark.runBenchmark(counters);
}
class LazyScheduler_NonFreeGatesBatch_Benchmark
: public LazySchedulerBenchmark,
public NonFreeGatesBatchBenchmark {};
BENCHMARK_COUNTERS(LazyScheduler_NonFreeGatesBatch, counters) {
LazyScheduler_NonFreeGatesBatch_Benchmark benchmark;
benchmark.runBenchmark(counters);
}
class EagerScheduler_NonFreeGatesBatch_Benchmark
: public EagerSchedulerBenchmark,
public NonFreeGatesBatchBenchmark {};
BENCHMARK_COUNTERS(EagerScheduler_NonFreeGatesBatch, counters) {
EagerScheduler_NonFreeGatesBatch_Benchmark benchmark;
benchmark.runBenchmark(counters);
}
} // namespace fbpcf::scheduler
int main(int argc, char* argv[]) {
facebook::initFacebook(&argc, &argv);
folly::runBenchmarks();
return 0;
}
| 29.188462 | 80 | 0.742786 | SumitKT31 |
2b79768fdc76b175932865656b702963e755b973 | 2,835 | cpp | C++ | src/main.cpp | Wittmaxi/baumhaus | 1474a39414691253c8340e95f8b43d043bc56b74 | [
"Apache-2.0"
] | 1 | 2018-10-02T21:47:13.000Z | 2018-10-02T21:47:13.000Z | src/main.cpp | Wittmaxi/baumhaus | 1474a39414691253c8340e95f8b43d043bc56b74 | [
"Apache-2.0"
] | null | null | null | src/main.cpp | Wittmaxi/baumhaus | 1474a39414691253c8340e95f8b43d043bc56b74 | [
"Apache-2.0"
] | null | null | null | #include "baumhausengine.h" //the actual engine
#include "CPipe.h" //the pipe between the engine and the UI
#include <iostream>
#include <cstring>
/*
Baumhaus Engine 2017
By publishing this engine, you agree to publish the code with it.
This code comes with no warranty at all; not even the warranty to work properly and comercially
*/
bool evaluateArgs(int argc, char** argv);
void showHelp();
void optionError(char* long_option);
void optionError(char short_option);
void noOptionError();
bool debugMode= false;
int main (int argc, char** argv) {
if(!evaluateArgs(argc, argv)) {
return 0;
}
// initialize the CPipe now, and set debugMode.
pipe->init(debugMode);
// now start up the engine
CBaumhausengine *engine = new CBaumhausengine();
engine->startRoutine();
return 0;
}
bool evaluateArgs(int argc, char** argv) {
if(argc <= 1) {
return true;
}
// evaluate each argument
for(int i = 1; i < argc; ++i) {
if(strlen(argv[i]) <= 1) {
return false;
}
if(argv[i][0] == '-') { // option detected
if(argv[i][1] == '-') { // long option, simple match
if(strcmp(argv[i], "--debug") == 0) {
debugMode = true;
}
else if(strcmp(argv[i], "--help") == 0) {
showHelp();
return false;
}
else {
optionError(argv[i]);
return false;
}
continue;
}
// otherwise, we have some short options, which may be concatenated
int j = 1;
if(argv[i][j] == '\0') {
noOptionError();
return false;
}
// iterate over remaining short flags
while(argv[i][j] != '\0') {
// if 'h' flag found just show help and terminate.
if (argv[i][j] == 'h') {
showHelp();
return false;
}
if (argv[i][j] == 'd') {
debugMode = true;
}
else {
optionError(argv[i][j]);
return false;
}
++j; // very important
}
}
}
return true;
}
void showHelp() {
std::cout << "Usage: baumhaus [OPTIONS]" << std::endl;
std::cout << "Baumhaus is a chess engine designed to run with xboard protocols." << std::endl << std::endl;
std::cout << "OPTIONS" << std::endl;
std::cout << "\t" << "-d, --debug" << "\t" << "Turn on debug console output. May interfere w/ XBoard responses." << std::endl;
std::cout << "\t" << "-h, --help" << "\t" << "Show this helpful information." << std::endl;
std::cout << "We are a small team maintaining the baumhaus engine. If you want to, help us on github. Contact: wittmaxi@outlook.de" << std::endl;
// add more lines as needed. Perhaps link to git repo.
}
void optionError(char* long_option) {
std::cout << "Error: Invalid option '" << long_option << "'" << std::endl;
}
void optionError(char short_option) {
std::cout << "Error: Invalid option '-" << short_option << "'" << std::endl;
}
void noOptionError() {
std::cout << "Error: no option provided" << std::endl;
}
| 24.230769 | 146 | 0.613051 | Wittmaxi |
2b7da6bd42ac068071496ce9914262738fd6a99d | 10,921 | cpp | C++ | gameSource/musicPlayer2.cpp | Valaras/OneLife | 0f83ffb8edf8362ff3bf0ca87a73bba21be20446 | [
"Linux-OpenIB"
] | 69 | 2018-10-05T23:29:10.000Z | 2022-03-29T22:34:24.000Z | gameSource/musicPlayer2.cpp | Valaras/OneLife | 0f83ffb8edf8362ff3bf0ca87a73bba21be20446 | [
"Linux-OpenIB"
] | 62 | 2018-11-08T14:14:40.000Z | 2022-03-01T20:38:01.000Z | gameSource/musicPlayer2.cpp | Valaras/OneLife | 0f83ffb8edf8362ff3bf0ca87a73bba21be20446 | [
"Linux-OpenIB"
] | 24 | 2018-10-11T09:20:27.000Z | 2021-11-06T19:23:17.000Z | #include "minorGems/game/game.h"
#include <math.h>
#include "ageControl.h"
// loudness of music that we're currently playing at
static double musicLoudnessLive = 0;
static double musicTargetLoudness = 0;
extern double musicHeadroom;
// set so that a full 0-to-1 loudness transition happens
// in 1 second
static double loudnessChangePerSample;
#include "ogg.h"
static OGGHandle musicOGG = NULL;
static double musicLengthSeconds = -1;
static char musicOGGReady = false;
static char musicOGGPlaying = false;
static unsigned char *oggData = NULL;
static int asyncLoadHandle = -1;
static char musicStarted = false;
static char forceStartNow = false;
static double age = -1;
static double ageRate = -1;
static double ageSetTime = -1;
static int samplesSeenSinceAgeSet = 0;
static char soundEffectsFaded = false;
static double ageNextMusicDone = -1;
static double getCurrentAge() {
double timePassed = game_getCurrentTime() - ageSetTime;
return age + ageRate * timePassed;
}
// one per chunk
// the crossFadeSamples samples that occur BEFORE the coresponding chunk
void initMusicPlayer() {
int sampleRate = getSampleRate();
loudnessChangePerSample = 1.0 / sampleRate;
}
// returns an asynch file read handle, or -1 on failure
static int startNextAgeFileRead( double inAge ) {
int nextFiveBlock = ceil( inAge / 5 );
// too close to that age transition,
// start on next
if( nextFiveBlock * 5 < inAge + 60 * ageRate ) {
nextFiveBlock += 1;
}
ageNextMusicDone = nextFiveBlock * 5;
if( ageNextMusicDone == age_death ) {
// special case, end of life
// have music end 5 seconds after end of life
// so there's an ubrupt cut off of the music with the YOU DIED
// screen
ageNextMusicDone += 10 * ageRate;
}
char *searchString = autoSprintf( "_%02d.ogg", nextFiveBlock );
File musicDir( NULL, "music" );
int handle = -1;
if( musicDir.exists() && musicDir.isDirectory() ) {
int numChildren;
File **childFiles = musicDir.getChildFiles( &numChildren );
for( int i=0; i<numChildren; i++ ) {
char *fileName = childFiles[i]->getFileName();
char match = ( strstr( fileName, searchString ) != NULL );
delete [] fileName;
if( match ) {
char *fullName = childFiles[i]->getFullFileName();
handle = startAsyncFileRead( fullName );
delete [] fullName;
break;
}
}
for( int i=0; i<numChildren; i++ ) {
delete childFiles[i];
}
delete [] childFiles;
}
delete [] searchString;
return handle;
}
void restartMusic( double inAge, double inAgeRate, char inForceNow ) {
// for testing
//inAge = 0;
ageSetTime = game_getCurrentTime();
lockAudio();
musicStarted = false;
forceStartNow = inForceNow;
age = inAge;
ageRate = inAgeRate;
samplesSeenSinceAgeSet = 0;
unlockAudio();
printf( "Starting music at age %f\n", inAge );
// clear last-loaded OGG
if( musicOGG != NULL ) {
closeOGG( musicOGG );
musicOGG = NULL;
delete [] oggData;
oggData = NULL;
musicOGGReady = false;
}
musicOGGPlaying = false;
asyncLoadHandle = startNextAgeFileRead( inAge );
musicStarted = true;
// no fade in at start of music (music not playing at start)
musicLoudnessLive = musicLoudnessLive;
}
void instantStopMusic() {
musicStarted = false;
}
void stepMusicPlayer() {
// no lock needed when checking this flag
if( musicOGGReady ) {
// already have next one loaded and possibly playing
return;
}
// else our audio callback, running in the audio thread
// isn't doing anything until we say ready (with a lock around it)
// we can safely manipulate the shared data now
if( musicOGG != NULL ) {
if( soundEffectsFaded ) {
soundEffectsFaded = false;
resumePlayingSoundSprites();
}
closeOGG( musicOGG );
musicOGG = NULL;
delete [] oggData;
oggData = NULL;
asyncLoadHandle = startNextAgeFileRead( getCurrentAge() );
}
if( oggData == NULL && asyncLoadHandle != -1 ) {
if( checkAsyncFileReadDone( asyncLoadHandle ) ) {
int oggDataLength;
oggData = getAsyncFileData( asyncLoadHandle, &oggDataLength );
asyncLoadHandle = -1;
if( oggData != NULL ) {
musicOGG = openOGG( oggData, oggDataLength );
if( musicOGG != NULL ) {
musicLengthSeconds =
(double) getOGGTotalSamples( musicOGG ) /
(double) getSampleRate();
// need lock here to prevent operation re-ordering, even
// though setting the flag may be atomic
// flag being set implies other shared data are in
// a correct state
lockAudio();
musicOGGReady = true;
unlockAudio();
}
}
}
}
}
static float *samplesL = NULL;
static float *samplesR = NULL;
static int hintedLengthInBytes = -1;
void freeHintedBuffers() {
if( samplesL != NULL ) {
delete [] samplesL;
samplesL = NULL;
}
if( samplesR != NULL ) {
delete [] samplesR;
samplesR = NULL;
}
hintedLengthInBytes = -1;
}
void freeMusicPlayer() {
if( musicOGG != NULL ) {
closeOGG( musicOGG );
musicOGG = NULL;
delete [] oggData;
oggData = NULL;
}
freeHintedBuffers();
}
void hintBufferSize( int inLengthToFillInBytes ) {
// 2 bytes for each channel of stereo sample
int numSamples = inLengthToFillInBytes / 4;
freeHintedBuffers();
samplesL = new float[ numSamples ];
samplesR = new float[ numSamples ];
for( int i=0; i<numSamples; i++ ) {
samplesL[i] = 0;
samplesR[i] = 0;
}
hintedLengthInBytes = inLengthToFillInBytes;
}
// called by platform to get more samples
void getSoundSamples( Uint8 *inBuffer, int inLengthToFillInBytes ) {
// 2 bytes for each channel of stereo sample
int numSamples = inLengthToFillInBytes / 4;
double sampleComputedAge =
( samplesSeenSinceAgeSet / (double)getSampleRate() ) * ageRate
+ age;
samplesSeenSinceAgeSet += numSamples;
if( !musicOGGReady || !musicStarted ) {
memset( inBuffer, 0, inLengthToFillInBytes );
return;
}
if( !musicOGGPlaying ) {
// determine if we should start playing it
double startAge = ageNextMusicDone - musicLengthSeconds * ageRate;
double fadeSeconds = 1.0;
if( startAge < sampleComputedAge || forceStartNow ) {
musicOGGPlaying = true;
forceStartNow = false;
}
else if( ! soundEffectsFaded &&
startAge - fadeSeconds * ageRate < sampleComputedAge ) {
//soundEffectsFaded = true;
//fadeSoundSprites( fadeSeconds );
}
}
if( ! musicOGGPlaying ) {
// wait until later to start it
memset( inBuffer, 0, inLengthToFillInBytes );
return;
}
if( samplesL == NULL || inLengthToFillInBytes != hintedLengthInBytes ) {
// never got hint
// or hinted wrong size
hintBufferSize( inLengthToFillInBytes );
}
int numRead = readNextSamplesOGG( musicOGG, numSamples,
samplesL, samplesR );
if( numRead != numSamples ) {
// hit end of file
musicOGGReady = false;
musicOGGPlaying = false;
}
if( getOGGChannels( musicOGG ) == 1 ) {
// mono
// coercion rules don't apply to float samples
// SO, what we get is just L samples and all zero R samples
memcpy( samplesR, samplesL, numRead * sizeof( float ) );
}
// now copy samples into Uint8 buffer
// while also adjusting loudness of whole mix
char loudnessChanging = false;
if( musicLoudnessLive != musicTargetLoudness ) {
loudnessChanging = true;
}
int streamPosition = 0;
for( int i=0; i != numRead; i++ ) {
samplesL[i] *= musicLoudnessLive * musicHeadroom;
samplesR[i] *= musicLoudnessLive * musicHeadroom;
if( loudnessChanging ) {
if( musicLoudnessLive < musicTargetLoudness ) {
musicLoudnessLive += loudnessChangePerSample;
if( musicLoudnessLive > musicTargetLoudness ) {
musicLoudnessLive = musicTargetLoudness;
loudnessChanging = false;
}
}
else if( musicLoudnessLive > musicTargetLoudness ) {
musicLoudnessLive -= loudnessChangePerSample;
if( musicLoudnessLive < musicTargetLoudness ) {
musicLoudnessLive = musicTargetLoudness;
loudnessChanging = false;
}
}
}
Sint16 intSampleL = (Sint16)( lrint( 32767 * samplesL[i] ) );
Sint16 intSampleR = (Sint16)( lrint( 32767 * samplesR[i] ) );
inBuffer[ streamPosition ] = (Uint8)( intSampleL & 0xFF );
inBuffer[ streamPosition + 1 ] = (Uint8)( ( intSampleL >> 8 ) & 0xFF );
inBuffer[ streamPosition + 2 ] = (Uint8)( intSampleR & 0xFF );
inBuffer[ streamPosition + 3 ] = (Uint8)( ( intSampleR >> 8 ) & 0xFF );
streamPosition += 4;
}
// if we hit end of song before the end of the buffer
// fill rest with 0
while( streamPosition < inLengthToFillInBytes ) {
inBuffer[ streamPosition ] = 0;
streamPosition++;
}
}
// need to synch these with audio thread
void setMusicLoudness( double inLoudness, char inForce ) {
lockAudio();
musicTargetLoudness = inLoudness;
if( inForce ) {
// no fade-up to target loudness
musicLoudnessLive = musicTargetLoudness;
}
unlockAudio();
}
double getMusicLoudness() {
return musicLoudnessLive;
}
| 23.638528 | 79 | 0.558008 | Valaras |
2b816c429398620c1f893ca77b4f034380aab27a | 1,650 | hpp | C++ | include/boost/numpy/python/make_tuple_from_container.hpp | IceCube-SPNO/BoostNumpy | 66538c0b6e38e2f985e0b44d8191c878cea0332d | [
"BSL-1.0"
] | 6 | 2015-01-07T17:29:40.000Z | 2019-03-28T15:18:27.000Z | include/boost/numpy/python/make_tuple_from_container.hpp | IceCube-SPNO/BoostNumpy | 66538c0b6e38e2f985e0b44d8191c878cea0332d | [
"BSL-1.0"
] | 2 | 2017-04-12T19:01:21.000Z | 2017-04-14T16:18:38.000Z | include/boost/numpy/python/make_tuple_from_container.hpp | IceCube-SPNO/BoostNumpy | 66538c0b6e38e2f985e0b44d8191c878cea0332d | [
"BSL-1.0"
] | 2 | 2018-01-15T07:32:24.000Z | 2020-10-14T02:55:55.000Z | /**
* $Id$
*
* Copyright (C)
* 2015 - $Date$
* Martin Wolf <boostnumpy@martin-wolf.org>
*
* @file boost/numpy/python/make_tuple_from_container.hpp
* @version $Revision$
* @date $Date$
* @author Martin Wolf <boostnumpy@martin-wolf.org>
*
* @brief This file defines the boost::python::make_tuple_from_container
* template for constructing a boost::python::tuple object from a given
* STL container, that implements the iterator interface.
*
* This file is distributed under the Boost Software License,
* Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt).
*/
#ifndef BOOST_NUMPY_PYTHON_MAKE_TUPLE_FROM_CONTAINER_HPP_INCLUDED
#define BOOST_NUMPY_PYTHON_MAKE_TUPLE_FROM_CONTAINER_HPP_INCLUDED
#include <iterator>
#include <boost/python.hpp>
#include <boost/python/tuple.hpp>
namespace boost {
namespace python {
template <typename IterT>
tuple
make_tuple_from_container(
IterT const & begin
, IterT const & end
)
{
typename IterT::difference_type const n = std::distance(begin, end);
if(n < 0)
{
PyErr_SetString(PyExc_RuntimeError,
"The distance between the begin and end iterators must be >=0!");
throw_error_already_set();
}
tuple result((detail::new_reference)::PyTuple_New((n>=0 ? n : -n)));
IterT it(begin);
for(size_t idx=0; it!=end; ++idx, ++it)
{
PyTuple_SET_ITEM(result.ptr(), idx, incref(object(*it).ptr()));
}
return result;
}
}//namespace python
}//namespace boost
#endif // ! BOOST_NUMPY_PYTHON_MAKE_TUPLE_FROM_CONTAINER_HPP_INCLUDED
| 27.04918 | 78 | 0.689091 | IceCube-SPNO |
2b82335a60e9e9a7b8510c376830084946961a54 | 932 | cpp | C++ | EOlymp/00009.cpp | vdshk/algos | 8896c9edd30225acbdb51fa2e9760c0cc4adf307 | [
"MIT"
] | null | null | null | EOlymp/00009.cpp | vdshk/algos | 8896c9edd30225acbdb51fa2e9760c0cc4adf307 | [
"MIT"
] | null | null | null | EOlymp/00009.cpp | vdshk/algos | 8896c9edd30225acbdb51fa2e9760c0cc4adf307 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(a) (int)a.size()
using namespace std;
typedef vector<int> vint;
typedef long double ld;
typedef long long ll;
typedef string str;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
switch (n) {
case 1:
return cout << "10 0", 0;
case 2:
return cout << "1 22", 0;
case 3:
return cout << "6 123", 0;
case 4:
return cout << "12 1124", 0;
case 5:
return cout << "40 11125", 0;
case 6:
return cout << "30 111126", 0;
case 7:
return cout << "84 1111127", 0;
case 8:
return cout << "224 11111128", 0;
case 9:
return cout << "144 111111129", 0;
}
} | 22.190476 | 46 | 0.504292 | vdshk |
2b82dd7976887f9783be5baba9ea1e08b0f9c5d8 | 1,860 | hpp | C++ | include/boost/sweater/threading/futex.hpp | microblink/sweater | f64e68a086c1748690b928108511b4eb692f152b | [
"MIT"
] | 1 | 2017-11-21T22:48:30.000Z | 2017-11-21T22:48:30.000Z | include/boost/sweater/threading/futex.hpp | microblink/sweater | f64e68a086c1748690b928108511b4eb692f152b | [
"MIT"
] | null | null | null | include/boost/sweater/threading/futex.hpp | microblink/sweater | f64e68a086c1748690b928108511b4eb692f152b | [
"MIT"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////
///
/// \file futex.hpp
/// ---------------
///
/// (c) Copyright Domagoj Saric 2021.
///
/// Use, modification and distribution are subject to the
/// Boost Software License, Version 1.0. (See accompanying file
/// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
///
/// See http://www.boost.org for most recent version.
///
////////////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------------
#pragma once
//------------------------------------------------------------------------------
#include "hardware_concurrency.hpp"
#include <atomic>
//------------------------------------------------------------------------------
namespace boost
{
//------------------------------------------------------------------------------
namespace thrd_lite
{
//------------------------------------------------------------------------------
// https://www.remlab.net/op/futex-misc.shtml
// https://dept-info.labri.fr/~denis/Enseignement/2008-IR/Articles/01-futex.pdf
struct futex : std::atomic
<
#ifdef _WIN32
hardware_concurrency_t
#else
std::uint32_t
#endif
>
{
void wake_one( ) const noexcept;
void wake ( hardware_concurrency_t waiters_to_wake ) const noexcept;
void wake_all( ) const noexcept;
void wait_if_equal( value_type desired_value ) const noexcept;
}; // struct futex
//------------------------------------------------------------------------------
} // namespace thrd_lite
//------------------------------------------------------------------------------
} // namespace boost
//------------------------------------------------------------------------------
| 35.09434 | 80 | 0.363441 | microblink |
2b8dbb67bc7e32410bdf3a1faea3f665f1aaf6ba | 2,691 | cpp | C++ | with_qt/qtsource/qtmain.cpp | vladsopen/umon1stl | c1e7d9b198c6ce493ca1dcf31d778d633be48f88 | [
"MIT"
] | null | null | null | with_qt/qtsource/qtmain.cpp | vladsopen/umon1stl | c1e7d9b198c6ce493ca1dcf31d778d633be48f88 | [
"MIT"
] | null | null | null | with_qt/qtsource/qtmain.cpp | vladsopen/umon1stl | c1e7d9b198c6ce493ca1dcf31d778d633be48f88 | [
"MIT"
] | null | null | null | /**
* MIT license:
*
* Copyright (c) 2019 vlads
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include <QApplication>
#include <QDir>
#include <QPainter>
#include <QWidget>
#include "application.h"
#include "qtui.h"
#include "qttesthelpers.h"
#include "storage.h"
static void prepareCurrentDir()
{
const QString resourceDir = "public/resources";
QString exeDir = QCoreApplication::applicationDirPath();
// search for resource directory when starting from build dir
// change the current directory to a top level directory containing
// our resource dir
QString goUp = "";
bool isFound = false;
for (int i NOTUSED : FromTo(0, 10)) // some reasonable limit
{
QString tryResources = exeDir + "/" + goUp + resourceDir;
if (QFileInfo::exists(tryResources))
{
QDir::setCurrent(tryResources);
Io::Os::say(qPrintable("Current dir: " + QDir::currentPath() + "\n"));
// read the original log from file
//std::ifstream file("all.testlog", std::ios::binary);
//if (file.is_open())
// Io::Os::say("Open!\n");
rASSERT(QFileInfo::exists("about-dir.txt"));
isFound = true;
break;
}
goUp += "../";
}
rASSERT(isFound);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
prepareCurrentDir();
App::runFromMain();
/*
QWidget* floater = new QWidget(NULL);
floater->show();
QPushButton* playButton = new QPushButton("Direct QT test", floater);
UNUSED(playButton);
playButton->show();
*/
return a.exec();
}
| 30.235955 | 82 | 0.662207 | vladsopen |
2b8f7f7f0e914ea8c5b5e7a7fe141c3b39274bc5 | 4,007 | cpp | C++ | src/tile.cpp | plefebvre91/puzzle | a97f7d3384fad616cb99d390861a6e8be804cf21 | [
"MIT"
] | null | null | null | src/tile.cpp | plefebvre91/puzzle | a97f7d3384fad616cb99d390861a6e8be804cf21 | [
"MIT"
] | null | null | null | src/tile.cpp | plefebvre91/puzzle | a97f7d3384fad616cb99d390861a6e8be804cf21 | [
"MIT"
] | null | null | null | /* MIT License
Copyright (c) 2019 Pierre Lefebvre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. */
#include "tile.hpp"
#include "constants.hpp"
tile::tile(sf::RenderWindow* w, const std::string& path, const sf::Vector2f& v):
position(v),texture(),sprite(),thread(), mutex()
{
window = w;
texture.loadFromFile(path);
sprite.setTexture(texture, true);
sprite.setPosition(position);
thread.push_back(new sf::Thread(&tile::move_thread_up, this));
thread.push_back(new sf::Thread(&tile::move_thread_down, this));
thread.push_back(new sf::Thread(&tile::move_thread_left, this));
thread.push_back(new sf::Thread(&tile::move_thread_right, this));
}
void tile::display() const
{
window->draw(sprite);
}
int interp(int a, int b, int dt, int t_max)
{
float dm = (float)dt / (float)t_max;
return (float)(b-a)*dm;
}
void tile::move_thread_up()
{
sf::Clock clock;
sf::Int32 now = clock.getElapsedTime().asMilliseconds();
sf::Int32 after;
int t_max = PUZZLE_ANIM_DURATION;
int old = position.y;
int a;
mutex.lock();
do
{
after = clock.getElapsedTime().asMilliseconds();
a = interp(position.y,position.y -200, after - now, t_max);
position.y = old+a;
sprite.setPosition(position);
} while(position.y > (old - 200));
mutex.unlock();
position.y = old - 200;
}
void tile::move_thread_down()
{
sf::Clock clock; // démarre le chrono
sf::Int32 now = clock.getElapsedTime().asMilliseconds();
sf::Int32 after;
int t_max = PUZZLE_ANIM_DURATION;
int old = position.y;
int a;
mutex.lock();
do
{
after = clock.getElapsedTime().asMilliseconds();
a = interp(position.y,position.y +200, after - now, t_max);
position.y = old+a;
sprite.setPosition(position);
} while(position.y < old + 200);
position.y = old + 200;
mutex.unlock();
}
void tile::move_thread_left()
{
sf::Clock clock; // démarre le chrono
sf::Int32 now = clock.getElapsedTime().asMilliseconds();
sf::Int32 after;
int t_max = PUZZLE_ANIM_DURATION;
int old = position.x;
int a;
mutex.lock();
do
{
after = clock.getElapsedTime().asMilliseconds();
a = interp(position.x,position.x - 200, after - now, t_max);
position.x = old+a;
sprite.setPosition(position);
} while(position.x > (old - 200));
position.x = old - 200;
mutex.unlock();
}
void tile::move_thread_right()
{
sf::Clock clock; // démarre le chrono
sf::Int32 now = clock.getElapsedTime().asMilliseconds();
sf::Int32 after;
int t_max = PUZZLE_ANIM_DURATION;
int old = position.x;
int a;
mutex.lock();
do
{
after = clock.getElapsedTime().asMilliseconds();
a = interp(position.x,position.x +200, after - now, t_max);
position.x = old+a;
sprite.setPosition(position);
} while(position.x < old + 200);
position.x = old + 200;
mutex.unlock();
}
void tile::move(direction d)
{
int dir = (int)d;
mutex.lock();
thread[dir]->launch();
mutex.unlock();
}
| 25.04375 | 80 | 0.681807 | plefebvre91 |
2b97f75ab9a727612f3c52a05ee9d2b6f03e9756 | 1,388 | cpp | C++ | src/transport/impl/upgrader_session.cpp | Alexey-N-Chernyshov/cpp-libp2p | 8b52253f9658560a4b1311b3ba327f02284a42a6 | [
"Apache-2.0",
"MIT"
] | 135 | 2020-06-13T08:57:36.000Z | 2022-03-27T05:26:11.000Z | src/transport/impl/upgrader_session.cpp | igor-egorov/cpp-libp2p | 7c9d83bf0760a5f653d86ddbb00645414c61d4fc | [
"Apache-2.0",
"MIT"
] | 41 | 2020-06-12T15:45:05.000Z | 2022-03-07T23:10:33.000Z | src/transport/impl/upgrader_session.cpp | igor-egorov/cpp-libp2p | 7c9d83bf0760a5f653d86ddbb00645414c61d4fc | [
"Apache-2.0",
"MIT"
] | 43 | 2020-06-15T10:12:45.000Z | 2022-03-21T03:04:50.000Z | /**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#include <libp2p/transport/impl/upgrader_session.hpp>
namespace libp2p::transport {
UpgraderSession::UpgraderSession(
std::shared_ptr<transport::Upgrader> upgrader,
std::shared_ptr<connection::RawConnection> raw,
UpgraderSession::HandlerFunc handler)
: upgrader_(std::move(upgrader)),
raw_(std::move(raw)),
handler_(std::move(handler)) {}
void UpgraderSession::secureOutbound(const peer::PeerId &remoteId) {
auto self{shared_from_this()};
upgrader_->upgradeToSecureOutbound(raw_, remoteId, [self](auto &&r) {
self->onSecured(std::forward<decltype(r)>(r));
});
}
void UpgraderSession::secureInbound() {
upgrader_->upgradeToSecureInbound(
raw_, [self{shared_from_this()}](auto &&r) {
self->onSecured(std::forward<decltype(r)>(r));
});
}
void UpgraderSession::onSecured(
outcome::result<std::shared_ptr<connection::SecureConnection>> rsecure) {
if (!rsecure) {
return handler_(rsecure.error());
}
upgrader_->upgradeToMuxed(rsecure.value(),
[self{shared_from_this()}](auto &&r) {
self->handler_(std::forward<decltype(r)>(r));
});
}
} // namespace libp2p::transport
| 31.545455 | 79 | 0.62464 | Alexey-N-Chernyshov |
2b98e6bdfc82f840ebaaa5d76fdf641b27ea151d | 4,296 | hpp | C++ | include/UnityEngine/Light.hpp | darknight1050/BeatSaber-Quest-Codegen | a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032 | [
"Unlicense"
] | null | null | null | include/UnityEngine/Light.hpp | darknight1050/BeatSaber-Quest-Codegen | a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032 | [
"Unlicense"
] | null | null | null | include/UnityEngine/Light.hpp | darknight1050/BeatSaber-Quest-Codegen | a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032 | [
"Unlicense"
] | null | null | null | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "extern/beatsaber-hook/shared/utils/typedefs.h"
// Including type: UnityEngine.Behaviour
#include "UnityEngine/Behaviour.hpp"
// Completed includes
// Begin forward declares
// Forward declaring namespace: UnityEngine
namespace UnityEngine {
// Forward declaring type: LightType
struct LightType;
// Forward declaring type: Color
struct Color;
// Forward declaring type: LightShadows
struct LightShadows;
}
// Forward declaring namespace: UnityEngine::Rendering
namespace UnityEngine::Rendering {
// Forward declaring type: LightEvent
struct LightEvent;
// Forward declaring type: CommandBuffer
class CommandBuffer;
// Forward declaring type: ShadowMapPass
struct ShadowMapPass;
}
// Completed forward declares
// Type namespace: UnityEngine
namespace UnityEngine {
// Size: 0x1C
#pragma pack(push, 1)
// Autogenerated type: UnityEngine.Light
// [RequireComponent] Offset: D8EF2C
// [NativeHeaderAttribute] Offset: D8EF2C
// [NativeHeaderAttribute] Offset: D8EF2C
// [RequireComponent] Offset: D8EF2C
class Light : public UnityEngine::Behaviour {
public:
// private System.Int32 m_BakedIndex
// Size: 0x4
// Offset: 0x18
int m_BakedIndex;
// Field size check
static_assert(sizeof(int) == 0x4);
// Creating value type constructor for type: Light
Light(int m_BakedIndex_ = {}) noexcept : m_BakedIndex{m_BakedIndex_} {}
// Deleting conversion operator: operator System::IntPtr
constexpr operator System::IntPtr() const noexcept = delete;
// public UnityEngine.LightType get_type()
// Offset: 0x1BEE604
UnityEngine::LightType get_type();
// public System.Single get_spotAngle()
// Offset: 0x1BEE644
float get_spotAngle();
// public UnityEngine.Color get_color()
// Offset: 0x1BEE684
UnityEngine::Color get_color();
// public System.Void set_color(UnityEngine.Color value)
// Offset: 0x1BEE730
void set_color(UnityEngine::Color value);
// public System.Single get_intensity()
// Offset: 0x1BEE7D8
float get_intensity();
// public System.Void set_intensity(System.Single value)
// Offset: 0x1BEE818
void set_intensity(float value);
// public System.Single get_bounceIntensity()
// Offset: 0x1BEE868
float get_bounceIntensity();
// public System.Single get_range()
// Offset: 0x1BEE8A8
float get_range();
// public UnityEngine.LightShadows get_shadows()
// Offset: 0x1BEE8E8
UnityEngine::LightShadows get_shadows();
// public System.Void AddCommandBuffer(UnityEngine.Rendering.LightEvent evt, UnityEngine.Rendering.CommandBuffer buffer)
// Offset: 0x1BEE928
void AddCommandBuffer(UnityEngine::Rendering::LightEvent evt, UnityEngine::Rendering::CommandBuffer* buffer);
// public System.Void AddCommandBuffer(UnityEngine.Rendering.LightEvent evt, UnityEngine.Rendering.CommandBuffer buffer, UnityEngine.Rendering.ShadowMapPass shadowPassMask)
// Offset: 0x1BEE984
void AddCommandBuffer(UnityEngine::Rendering::LightEvent evt, UnityEngine::Rendering::CommandBuffer* buffer, UnityEngine::Rendering::ShadowMapPass shadowPassMask);
// public System.Void RemoveCommandBuffer(UnityEngine.Rendering.LightEvent evt, UnityEngine.Rendering.CommandBuffer buffer)
// Offset: 0x1BEE9EC
void RemoveCommandBuffer(UnityEngine::Rendering::LightEvent evt, UnityEngine::Rendering::CommandBuffer* buffer);
// private System.Void get_color_Injected(out UnityEngine.Color ret)
// Offset: 0x1BEE6E0
void get_color_Injected(UnityEngine::Color& ret);
// private System.Void set_color_Injected(ref UnityEngine.Color value)
// Offset: 0x1BEE788
void set_color_Injected(UnityEngine::Color& value);
}; // UnityEngine.Light
#pragma pack(pop)
static check_size<sizeof(Light), 24 + sizeof(int)> __UnityEngine_LightSizeCheck;
static_assert(sizeof(Light) == 0x1C);
}
#include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
DEFINE_IL2CPP_ARG_TYPE(UnityEngine::Light*, "UnityEngine", "Light");
| 42.96 | 177 | 0.716248 | darknight1050 |
2ba1271d0ceb854b465475cc82f34ef39149eb72 | 282 | cpp | C++ | infowindow/InfoWindow.cpp | Kollos2k/fnfTagReader | d3e0b841299d2ee568a6c160acd75a0e9c605d39 | [
"MIT"
] | null | null | null | infowindow/InfoWindow.cpp | Kollos2k/fnfTagReader | d3e0b841299d2ee568a6c160acd75a0e9c605d39 | [
"MIT"
] | null | null | null | infowindow/InfoWindow.cpp | Kollos2k/fnfTagReader | d3e0b841299d2ee568a6c160acd75a0e9c605d39 | [
"MIT"
] | null | null | null | #include "InfoWindow.h"
#include "ui_InfoWindow.h"
InfoWindow::InfoWindow(QWidget *parent) : QDialog(parent), ui(new Ui::InfoWindow){
ui->setupUi(this);
}
InfoWindow::~InfoWindow(){
delete ui;
}
void InfoWindow::on_buttonClose_clicked(){
this->close();
}
| 20.142857 | 83 | 0.666667 | Kollos2k |
2ba1a76ee72ce737d8e3c5895b63b04957c52d02 | 1,368 | cpp | C++ | source/unittest/main_yaml.cpp | nahzz/EliteQuant_Cpp | 4ff6f493f36b87a590b715e245e12399ae04d4fa | [
"Apache-2.0"
] | 10 | 2020-08-16T06:26:19.000Z | 2022-03-16T07:24:02.000Z | source/unittest/main_yaml.cpp | saminfante/EliteQuant_Cpp | 4ff6f493f36b87a590b715e245e12399ae04d4fa | [
"Apache-2.0"
] | null | null | null | source/unittest/main_yaml.cpp | saminfante/EliteQuant_Cpp | 4ff6f493f36b87a590b715e245e12399ae04d4fa | [
"Apache-2.0"
] | 4 | 2020-10-11T03:55:07.000Z | 2021-04-24T13:13:46.000Z | #include <yaml-cpp/yaml.h>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
{
YAML::Node node; // starts out as null
node["key"] = "value"; // it now is a map node
node["seq"].push_back("first element"); // node["seq"] automatically becomes a sequence
node["seq"].push_back("second element");
node["mirror"] = node["seq"][0]; // this creates an alias
node["seq"][0] = "1st element"; // this also changes node["mirror"]
node["mirror"] = "element #1"; // and this changes node["seq"][0] - they're really the "same" node
node["self"] = node; // you can even create self-aliases
node[node["mirror"]] = node["seq"]; // and strange loops :)
//node["tickers"] = "tickers";
node["tickers"].push_back("AAPL STK SMART");
node["tickers"].push_back("SPY STK SMART");
std::ofstream fout("c:\\workspace\\EliteQuant\\Source\\cerealtest\\config.yaml");
fout << node;
}
{
//YAML::Node config = YAML::LoadFile("c:\\workspace\\EliteQuant\\Source\\cerealtest\\config.yaml");
YAML::Node config = YAML::LoadFile("c:\\workspace\\EliteQuant\\Source\\cerealtest\\sample.yaml");
const std::string username = config["name"].as<std::string>();
const int password = config["invoice"].as<int>();
const std::vector<string> tickers = config["tickers"].as<std::vector<string>>();
}
} | 34.2 | 101 | 0.650585 | nahzz |
2ba37712e886e3f5824f3fd0cce1e2b272f59881 | 2,224 | cpp | C++ | src/Plaszczyzna.cpp | KPO-2020-2021/zad5_3-jmeko1214 | 6c59e182b409c39e02c5a0e37d3e983ed1b3e0ba | [
"Unlicense"
] | null | null | null | src/Plaszczyzna.cpp | KPO-2020-2021/zad5_3-jmeko1214 | 6c59e182b409c39e02c5a0e37d3e983ed1b3e0ba | [
"Unlicense"
] | null | null | null | src/Plaszczyzna.cpp | KPO-2020-2021/zad5_3-jmeko1214 | 6c59e182b409c39e02c5a0e37d3e983ed1b3e0ba | [
"Unlicense"
] | null | null | null | #include "Plaszczyzna.hh"
/******************************************************************************
| Konstruktor parametryczny klasy Plaszczyzna. |
| Argumenty: |
| dlugosc - dlugosc plaszczyzny |
| szerokosc - szerokosc plaszczyzny |
| wysokosc - wysokosc plaszczyzny |
| sNazwaPliku - przechowuje nazwe pliku zawierajacego wspolrzedne |
*/
Plaszczyzna::Plaszczyzna(double dlugosc, double szerokosc, double wysokosc, std::string sNazwaPliku)
{
this->sNazwaPliku = sNazwaPliku;
Wektor3D wek;
ilosc = 0;
for(int i=-dlugosc/2; i<=dlugosc/2; i+=20)
{
for(int j=-szerokosc/2; j<=szerokosc/2; j+=20)
{
wek[0] = i;
wek[1] = j;
wek[2] = wysokosc;
siatka.push_back(wek);
}
ilosc++;
}
}
/******************************************************************************
| Realizuje zapis wspolrzednych Plaszczyzna do pliku |
| Argumenty: |
| sNazwaPliku - nazwa pliku, do ktorego sa zapisywane wspolrzedne |
| plaszczyzny |
| Zwraca: |
| True lub False |
*/
bool Plaszczyzna::Zapisz_do_pliku()
{
std::ofstream StrmPlikowy;
StrmPlikowy.open(sNazwaPliku, std::ios::out);
if(!StrmPlikowy.is_open())
{
std::cerr << ":( Operacja otwarcia do zapisu \"" << sNazwaPliku << "\"" << std::endl
<< ":( nie powiodla sie." << std::endl;
return false;
}
for(int i=0; i<(int)siatka.size(); i++)
{
if(i%ilosc==0)
{
StrmPlikowy << std::endl;
}
StrmPlikowy << siatka[i] << std::endl;
}
StrmPlikowy.close();
return !StrmPlikowy.fail();
}
| 36.459016 | 126 | 0.392086 | KPO-2020-2021 |
2ba3a418618538fce91e880a2f86582a7228ff61 | 335 | cpp | C++ | video_media_metadata.cpp | mexicowilly/Espadin | f33580d2c77c5efe92c05de0816ec194e87906f0 | [
"Apache-2.0"
] | null | null | null | video_media_metadata.cpp | mexicowilly/Espadin | f33580d2c77c5efe92c05de0816ec194e87906f0 | [
"Apache-2.0"
] | null | null | null | video_media_metadata.cpp | mexicowilly/Espadin | f33580d2c77c5efe92c05de0816ec194e87906f0 | [
"Apache-2.0"
] | null | null | null | #include <espadin/video_media_metadata.hpp>
#include "cjson_util.hpp"
namespace espadin
{
video_media_metadata::video_media_metadata(const cJSON& json)
{
cjson::util ju(const_cast<cJSON&>(json));
ju.set_number("width", width_);
ju.set_number("height", height_);
ju.set_number("durationMillis", duration_millis_);
}
} | 22.333333 | 61 | 0.737313 | mexicowilly |
ad93762e548f55ea8b703ab4a80950d09d3953a3 | 345 | hpp | C++ | src/Headers/Exception.hpp | guiteixeirapimentel/NQueens | aab4ecd14b82eafc3fa8de509803a8e25181942f | [
"MIT"
] | null | null | null | src/Headers/Exception.hpp | guiteixeirapimentel/NQueens | aab4ecd14b82eafc3fa8de509803a8e25181942f | [
"MIT"
] | null | null | null | src/Headers/Exception.hpp | guiteixeirapimentel/NQueens | aab4ecd14b82eafc3fa8de509803a8e25181942f | [
"MIT"
] | null | null | null | #pragma once
#include <exception>
#include <string>
class Exception : public std::exception
{
public:
Exception(const std::string &msg)
: cMsg(msg){};
~Exception() {}
Exception(std::string &&msg)
: cMsg(msg){};
inline std::string getMsg() const
{
return cMsg;
}
private:
std::string cMsg;
}; | 17.25 | 39 | 0.588406 | guiteixeirapimentel |
ad9b68b033c2497eb8b19aacf81a29202d3c0442 | 241 | cpp | C++ | models/wallet/Wallet.cpp | Mateus-Franceschina/cpp-stocks-wallet | 71969491938e166d6b5053b9c6b0d27d55320fa3 | [
"MIT"
] | null | null | null | models/wallet/Wallet.cpp | Mateus-Franceschina/cpp-stocks-wallet | 71969491938e166d6b5053b9c6b0d27d55320fa3 | [
"MIT"
] | null | null | null | models/wallet/Wallet.cpp | Mateus-Franceschina/cpp-stocks-wallet | 71969491938e166d6b5053b9c6b0d27d55320fa3 | [
"MIT"
] | null | null | null | #pragma once
#include "Wallet.hpp"
#include <iostream>
using namespace std;
Wallet :: Wallet() {
string test = this->getString();
cout << test << " ou ola mundo" << endl;
}
string Wallet :: getString() {
return this->hello;
}
| 16.066667 | 44 | 0.626556 | Mateus-Franceschina |
ada0d3eff0c163d659d896f81ac5c484dadf0410 | 315 | cxx | C++ | CSES/1094_Increasing_Array.cxx | daniel-cr/CProgramming | 3ce8a134c18258e28eb3ce610da21309f6e01b53 | [
"MIT"
] | null | null | null | CSES/1094_Increasing_Array.cxx | daniel-cr/CProgramming | 3ce8a134c18258e28eb3ce610da21309f6e01b53 | [
"MIT"
] | null | null | null | CSES/1094_Increasing_Array.cxx | daniel-cr/CProgramming | 3ce8a134c18258e28eb3ce610da21309f6e01b53 | [
"MIT"
] | null | null | null | #include <iostream>
#include <string>
using namespace std;
int main(){
int n; cin >> n;
long long res = 0;
int m = 0;
while(n--) {
int x; cin >> x;
m = max(m, x);
if (x < m) {
res += m - x;
}
}
cout << res << "\n";
return 0;
}
| 15 | 25 | 0.384127 | daniel-cr |
ada6e74a0bd8814b73d1fe6faa7ded7913f12d77 | 875 | hpp | C++ | 028. Implement strStr()/Solution.hpp | husy8/LeetCode | 49aab298a4bbf36434a414e64486ed8f842a1556 | [
"MIT"
] | null | null | null | 028. Implement strStr()/Solution.hpp | husy8/LeetCode | 49aab298a4bbf36434a414e64486ed8f842a1556 | [
"MIT"
] | null | null | null | 028. Implement strStr()/Solution.hpp | husy8/LeetCode | 49aab298a4bbf36434a414e64486ed8f842a1556 | [
"MIT"
] | null | null | null | #include <string>
class Solution {
public:
int strStr(const std::string &haystack, const std::string &needle)
{
if (haystack.empty() && needle.empty())
{
return 0;
}
if (haystack.size() < needle.size())
{
return -1;
}
for (auto i = haystack.begin(); i != haystack.end() - needle.size() + 1; ++i)
{
auto needle_pointer = needle.begin(), haystack_pointer = i;
while (*needle_pointer == *haystack_pointer && haystack_pointer != haystack.end() &&
needle_pointer != needle.end())
{
++needle_pointer;
++haystack_pointer;
}
if (needle_pointer == needle.end())
{
return i - haystack.begin();
}
}
return -1;
}
}; | 25 | 96 | 0.462857 | husy8 |
ada9c8f9c20f331df19d7fb0745913c3cf7cf8cf | 736 | cc | C++ | main.cc | jerrytfleung/Ctor | 96637d136d32b3e06f39fb018281948a5480c622 | [
"Apache-2.0"
] | null | null | null | main.cc | jerrytfleung/Ctor | 96637d136d32b3e06f39fb018281948a5480c622 | [
"Apache-2.0"
] | null | null | null | main.cc | jerrytfleung/Ctor | 96637d136d32b3e06f39fb018281948a5480c622 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <initializer_list>
using namespace std;
template<class T>
class object {
public:
object() { cout << "Default ctor!" << endl; }
object(T size, T default_value) { cout << "Parameterized ctor!" << endl; }
object(initializer_list<T> init) { cout << "Initializer list ctor!" << endl; }
void print() { cout << "print() is called!" << endl; }
};
int main() {
object<int> o1;
o1.print();
object<int> o2(10, 1);
o2.print();
object<int> o3{10, 1};
o3.print();
object<int> o4{};
o4.print();
object<int> o5();
// o5.print(); compile error
/**
* error: request for member ‘print’ in ‘o5’, which is of non-class type ‘object<int>()’
* o5.print();
* ^~~~~
*/
return 0;
}
| 23 | 90 | 0.589674 | jerrytfleung |
adaa16e4739a43ebc4771d2f94f4122350e63069 | 10,562 | cpp | C++ | src/lib/operators/insert.cpp | IanJamesMcKay/InMemoryDB | a267d9522926eca9add2ad4512f8ce352daac879 | [
"MIT"
] | 1 | 2021-04-14T11:16:52.000Z | 2021-04-14T11:16:52.000Z | src/lib/operators/insert.cpp | IanJamesMcKay/InMemoryDB | a267d9522926eca9add2ad4512f8ce352daac879 | [
"MIT"
] | null | null | null | src/lib/operators/insert.cpp | IanJamesMcKay/InMemoryDB | a267d9522926eca9add2ad4512f8ce352daac879 | [
"MIT"
] | 1 | 2020-11-30T13:11:04.000Z | 2020-11-30T13:11:04.000Z | #include "insert.hpp"
#include <algorithm>
#include <memory>
#include <string>
#include <vector>
#include "concurrency/transaction_context.hpp"
#include "resolve_type.hpp"
#include "storage/base_encoded_column.hpp"
#include "storage/storage_manager.hpp"
#include "storage/value_column.hpp"
#include "type_cast.hpp"
#include "utils/assert.hpp"
namespace opossum {
// We need these classes to perform the dynamic cast into a templated ValueColumn
class AbstractTypedColumnProcessor {
public:
virtual ~AbstractTypedColumnProcessor() = default;
virtual void resize_vector(std::shared_ptr<BaseColumn> column, size_t new_size) = 0;
virtual void copy_data(std::shared_ptr<const BaseColumn> source, size_t source_start_index,
std::shared_ptr<BaseColumn> target, size_t target_start_index, size_t length) = 0;
};
template <typename T>
class TypedColumnProcessor : public AbstractTypedColumnProcessor {
public:
void resize_vector(std::shared_ptr<BaseColumn> column, size_t new_size) override {
auto val_column = std::dynamic_pointer_cast<ValueColumn<T>>(column);
DebugAssert(static_cast<bool>(val_column), "Type mismatch");
auto& values = val_column->values();
values.resize(new_size);
if (val_column->is_nullable()) {
val_column->null_values().resize(new_size);
}
}
// this copies
void copy_data(std::shared_ptr<const BaseColumn> source, size_t source_start_index,
std::shared_ptr<BaseColumn> target, size_t target_start_index, size_t length) override {
auto casted_target = std::dynamic_pointer_cast<ValueColumn<T>>(target);
DebugAssert(static_cast<bool>(casted_target), "Type mismatch");
auto& values = casted_target->values();
auto target_is_nullable = casted_target->is_nullable();
if (auto casted_source = std::dynamic_pointer_cast<const ValueColumn<T>>(source)) {
std::copy_n(casted_source->values().begin() + source_start_index, length, values.begin() + target_start_index);
if (casted_source->is_nullable()) {
// Values to insert contain null, copy them
if (target_is_nullable) {
std::copy_n(casted_source->null_values().begin() + source_start_index, length,
casted_target->null_values().begin() + target_start_index);
} else {
for (const auto null_value : casted_source->null_values()) {
Assert(!null_value, "Trying to insert NULL into non-NULL column");
}
}
}
} else if (auto casted_dummy_source = std::dynamic_pointer_cast<const ValueColumn<int32_t>>(source)) {
// We use the column type of the Dummy table used to insert a single null value.
// A few asserts are needed to guarantee correct behaviour.
Assert(length == 1, "Cannot insert multiple unknown null values at once.");
Assert(casted_dummy_source->size() == 1, "Source column is of wrong type.");
Assert(casted_dummy_source->null_values().front() == true, "Only value in dummy table must be NULL!");
Assert(target_is_nullable, "Cannot insert NULL into NOT NULL target.");
// Ignore source value and only set null to true
casted_target->null_values()[target_start_index] = true;
} else {
// } else if(auto casted_source = std::dynamic_pointer_cast<ReferenceColumn>(source)){
// since we have no guarantee that a referenceColumn references only a single other column,
// this would require us to find out the referenced column's type for each single row.
// instead, we just use the slow path below.
for (auto i = 0u; i < length; i++) {
auto ref_value = (*source)[source_start_index + i];
if (variant_is_null(ref_value)) {
Assert(target_is_nullable, "Cannot insert NULL into NOT NULL target");
values[target_start_index + i] = T{};
casted_target->null_values()[target_start_index + i] = true;
} else {
values[target_start_index + i] = type_cast<T>(ref_value);
}
}
}
}
};
Insert::Insert(const std::string& target_table_name, const std::shared_ptr<AbstractOperator>& values_to_insert)
: AbstractReadWriteOperator(OperatorType::Insert, values_to_insert), _target_table_name(target_table_name) {}
const std::string Insert::name() const { return "Insert"; }
std::shared_ptr<const Table> Insert::_on_execute(std::shared_ptr<TransactionContext> context) {
context->register_read_write_operator(std::static_pointer_cast<AbstractReadWriteOperator>(shared_from_this()));
_target_table = StorageManager::get().get_table(_target_table_name);
// These TypedColumnProcessors kind of retrieve the template parameter of the columns.
auto typed_column_processors = std::vector<std::unique_ptr<AbstractTypedColumnProcessor>>();
for (const auto& column_type : _target_table->column_data_types()) {
typed_column_processors.emplace_back(
make_unique_by_data_type<AbstractTypedColumnProcessor, TypedColumnProcessor>(column_type));
}
auto total_rows_to_insert = static_cast<uint32_t>(input_table_left()->row_count());
// First, allocate space for all the rows to insert. Do so while locking the table to prevent multiple threads
// modifying the table's size simultaneously.
auto start_index = 0u;
auto start_chunk_id = ChunkID{0};
auto total_chunks_inserted = 0u;
{
auto scoped_lock = _target_table->acquire_append_mutex();
start_chunk_id = _target_table->chunk_count() - 1;
auto last_chunk = _target_table->get_chunk(start_chunk_id);
start_index = last_chunk->size();
// If last chunk is compressed, add a new uncompressed chunk
if (!last_chunk->is_mutable()) {
_target_table->append_mutable_chunk();
total_chunks_inserted++;
}
auto remaining_rows = total_rows_to_insert;
while (remaining_rows > 0) {
auto current_chunk = _target_table->get_chunk(static_cast<ChunkID>(_target_table->chunk_count() - 1));
auto rows_to_insert_this_loop = std::min(_target_table->max_chunk_size() - current_chunk->size(), remaining_rows);
// Resize MVCC vectors.
current_chunk->mvcc_columns()->grow_by(rows_to_insert_this_loop, MvccColumns::MAX_COMMIT_ID);
// Resize current chunk to full size.
auto old_size = current_chunk->size();
for (ColumnID column_id{0}; column_id < current_chunk->column_count(); ++column_id) {
typed_column_processors[column_id]->resize_vector(current_chunk->get_mutable_column(column_id),
old_size + rows_to_insert_this_loop);
}
remaining_rows -= rows_to_insert_this_loop;
// Create new chunk if necessary.
if (remaining_rows > 0) {
_target_table->append_mutable_chunk();
total_chunks_inserted++;
}
}
}
// TODO(all): make compress chunk thread-safe; if it gets called here by another thread, things will likely break.
// Then, actually insert the data.
auto input_offset = 0u;
auto source_chunk_id = ChunkID{0};
auto source_chunk_start_index = 0u;
for (auto target_chunk_id = start_chunk_id; target_chunk_id <= start_chunk_id + total_chunks_inserted;
target_chunk_id++) {
auto target_chunk = _target_table->get_chunk(target_chunk_id);
const auto current_num_rows_to_insert =
std::min(target_chunk->size() - start_index, total_rows_to_insert - input_offset);
auto target_start_index = start_index;
auto still_to_insert = current_num_rows_to_insert;
// while target chunk is not full
while (target_start_index != target_chunk->size()) {
const auto source_chunk = input_table_left()->get_chunk(source_chunk_id);
auto num_to_insert = std::min(source_chunk->size() - source_chunk_start_index, still_to_insert);
for (ColumnID column_id{0}; column_id < target_chunk->column_count(); ++column_id) {
const auto& source_column = source_chunk->get_column(column_id);
typed_column_processors[column_id]->copy_data(source_column, source_chunk_start_index,
target_chunk->get_mutable_column(column_id), target_start_index,
num_to_insert);
}
still_to_insert -= num_to_insert;
target_start_index += num_to_insert;
source_chunk_start_index += num_to_insert;
bool source_chunk_depleted = source_chunk_start_index == source_chunk->size();
if (source_chunk_depleted) {
source_chunk_id++;
source_chunk_start_index = 0u;
}
}
for (auto i = start_index; i < start_index + current_num_rows_to_insert; i++) {
// we do not need to check whether other operators have locked the rows, we have just created them
// and they are not visible for other operators.
// the transaction IDs are set here and not during the resize, because
// tbb::concurrent_vector::grow_to_at_least(n, t)" does not work with atomics, since their copy constructor is
// deleted.
target_chunk->mvcc_columns()->tids[i] = context->transaction_id();
_inserted_rows.emplace_back(RowID{target_chunk_id, i});
}
input_offset += current_num_rows_to_insert;
start_index = 0u;
}
return nullptr;
}
void Insert::_on_commit_records(const CommitID cid) {
for (auto row_id : _inserted_rows) {
auto chunk = _target_table->get_chunk(row_id.chunk_id);
auto mvcc_columns = chunk->mvcc_columns();
mvcc_columns->begin_cids[row_id.chunk_offset] = cid;
mvcc_columns->tids[row_id.chunk_offset] = 0u;
}
}
void Insert::_on_rollback_records() {
for (auto row_id : _inserted_rows) {
auto chunk = _target_table->get_chunk(row_id.chunk_id);
// We set the begin and end cids to 0 (effectively making it invisible for everyone) so that the ChunkCompression
// does not think that this row is still incomplete. We need to make sure that the end is written before the begin.
chunk->mvcc_columns()->end_cids[row_id.chunk_offset] = 0u;
std::atomic_thread_fence(std::memory_order_release);
chunk->mvcc_columns()->begin_cids[row_id.chunk_offset] = 0u;
chunk->mvcc_columns()->tids[row_id.chunk_offset] = 0u;
}
}
std::shared_ptr<AbstractOperator> Insert::_on_recreate(
const std::vector<AllParameterVariant>& args, const std::shared_ptr<AbstractOperator>& recreated_input_left,
const std::shared_ptr<AbstractOperator>& recreated_input_right) const {
return std::make_shared<Insert>(_target_table_name, recreated_input_left);
}
} // namespace opossum
| 44.008333 | 120 | 0.708862 | IanJamesMcKay |
adb258c3e8d37724ae9b3f84fd51d3ab9becc6c8 | 7,787 | cpp | C++ | test/AST/expression/or_expr_test.cpp | przestaw/vecc_SimpleLanguage | a48bb8c0e53cc5f256c926cdb28cf39b107d66ee | [
"MIT"
] | null | null | null | test/AST/expression/or_expr_test.cpp | przestaw/vecc_SimpleLanguage | a48bb8c0e53cc5f256c926cdb28cf39b107d66ee | [
"MIT"
] | null | null | null | test/AST/expression/or_expr_test.cpp | przestaw/vecc_SimpleLanguage | a48bb8c0e53cc5f256c926cdb28cf39b107d66ee | [
"MIT"
] | null | null | null | //
// Created by przemek on 27.03.2020.
//
#include <AST/expression/base_math_expr.h>
#include <AST/expression/or_logic_expr.h>
#include <boost/test/unit_test.hpp>
#include <error/exeception.h>
using namespace vecc;
using namespace vecc::ast;
using std::make_unique;
using std::move;
using std::unique_ptr;
BOOST_AUTO_TEST_SUITE(AST_Test_Suite)
BOOST_AUTO_TEST_SUITE(Or_Logic_Expr_Test_Suite)
BOOST_AUTO_TEST_CASE(GivenMathExpr_ValueIsCorrect) {
Variable var = Variable({1, 2, 3});
OrLogicExpr expr(make_unique<BaseMathExpr>(var));
BOOST_CHECK_EQUAL(expr.calculate(), var);
}
BOOST_AUTO_TEST_CASE(GivenTrueAndFalse_ValueIsCorrect) {
Variable trueVar = Variable({1, 2, 3});
Variable falseVar = Variable({0, 0});
BOOST_REQUIRE_EQUAL(true, trueVar);
BOOST_REQUIRE_EQUAL(false, falseVar);
OrLogicExpr expr(make_unique<BaseMathExpr>(trueVar));
expr.addOperand(make_unique<BaseMathExpr>(falseVar));
BOOST_CHECK_EQUAL(true, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenFalseAndFalse_ValueIsCorrect) {
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
OrLogicExpr expr(make_unique<BaseMathExpr>(falseVar1));
expr.addOperand(make_unique<BaseMathExpr>(falseVar2));
BOOST_CHECK_EQUAL(false, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenTrueAndTrue_ValueIsCorrect) {
Variable trueVar1 = Variable({1, 1, 0});
Variable trueVar2 = Variable({1, 0});
BOOST_REQUIRE_EQUAL(true, trueVar1);
BOOST_REQUIRE_EQUAL(true, trueVar2);
OrLogicExpr expr(make_unique<BaseMathExpr>(trueVar1));
expr.addOperand(make_unique<BaseMathExpr>(trueVar2));
BOOST_CHECK_EQUAL(true, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenThreeVals_ValueIsCorrect_1) {
Variable trueVar1 = Variable({5, 1, 0});
Variable trueVar2 = Variable({1, -9});
Variable falseVar1 = Variable({0, 0});
BOOST_REQUIRE_EQUAL(true, trueVar1);
BOOST_REQUIRE_EQUAL(true, trueVar2);
BOOST_REQUIRE_EQUAL(false, falseVar1);
OrLogicExpr expr1(make_unique<BaseMathExpr>(trueVar1));
expr1.addOperand(make_unique<BaseMathExpr>(trueVar2));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar1));
OrLogicExpr expr2(make_unique<BaseMathExpr>(trueVar2));
expr2.addOperand(make_unique<BaseMathExpr>(falseVar1));
expr2.addOperand(make_unique<BaseMathExpr>(trueVar1));
OrLogicExpr expr3(make_unique<BaseMathExpr>(falseVar1));
expr3.addOperand(make_unique<BaseMathExpr>(trueVar2));
expr3.addOperand(make_unique<BaseMathExpr>(trueVar1));
BOOST_CHECK_EQUAL(true, expr1.calculate());
BOOST_CHECK_EQUAL(true, expr2.calculate());
BOOST_CHECK_EQUAL(true, expr3.calculate());
}
BOOST_AUTO_TEST_CASE(GivenThreeVals_ValueIsCorrect_2) {
Variable trueVar1 = Variable({5, 1, 0});
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
BOOST_REQUIRE_EQUAL(true, trueVar1);
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
OrLogicExpr expr1(make_unique<BaseMathExpr>(trueVar1));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar1));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar2));
OrLogicExpr expr2(make_unique<BaseMathExpr>(falseVar2));
expr2.addOperand(make_unique<BaseMathExpr>(falseVar1));
expr2.addOperand(make_unique<BaseMathExpr>(trueVar1));
OrLogicExpr expr3(make_unique<BaseMathExpr>(falseVar1));
expr3.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr3.addOperand(make_unique<BaseMathExpr>(trueVar1));
BOOST_CHECK_EQUAL(true, expr1.calculate());
BOOST_CHECK_EQUAL(true, expr2.calculate());
BOOST_CHECK_EQUAL(true, expr3.calculate());
}
BOOST_AUTO_TEST_CASE(GivenThreeVals_ValueIsCorrect_3) {
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
Variable falseVar3 = Variable({0});
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
BOOST_REQUIRE_EQUAL(false, falseVar3);
OrLogicExpr expr1(make_unique<BaseMathExpr>(falseVar1));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar3));
OrLogicExpr expr2(make_unique<BaseMathExpr>(falseVar3));
expr2.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr2.addOperand(make_unique<BaseMathExpr>(falseVar1));
OrLogicExpr expr3(make_unique<BaseMathExpr>(falseVar2));
expr3.addOperand(make_unique<BaseMathExpr>(falseVar3));
expr3.addOperand(make_unique<BaseMathExpr>(falseVar1));
BOOST_CHECK_EQUAL(false, expr1.calculate());
BOOST_CHECK_EQUAL(false, expr2.calculate());
BOOST_CHECK_EQUAL(false, expr3.calculate());
}
BOOST_AUTO_TEST_CASE(GivenFiveValues_ValueIsCorrect_1) {
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
Variable falseVar3 = Variable({0});
Variable trueVar4 = Variable({1, 7});
Variable trueVar5 = Variable({19, -5});
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
BOOST_REQUIRE_EQUAL(false, falseVar3);
BOOST_REQUIRE_EQUAL(true, trueVar4);
BOOST_REQUIRE_EQUAL(true, trueVar5);
OrLogicExpr expr(make_unique<BaseMathExpr>(falseVar1));
expr.addOperand(make_unique<BaseMathExpr>(trueVar4));
expr.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr.addOperand(make_unique<BaseMathExpr>(falseVar3));
expr.addOperand(make_unique<BaseMathExpr>(trueVar5));
BOOST_CHECK_EQUAL(true, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenFiveValues_ValueIsCorrect_2) {
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
Variable falseVar3 = Variable({0});
Variable trueVar1 = Variable({1, 7});
Variable falseVar4 = Variable({0, 0});
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
BOOST_REQUIRE_EQUAL(false, falseVar3);
BOOST_REQUIRE_EQUAL(true, trueVar1);
BOOST_REQUIRE_EQUAL(false, falseVar4);
OrLogicExpr expr(make_unique<BaseMathExpr>(falseVar1));
expr.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr.addOperand(make_unique<BaseMathExpr>(falseVar3));
expr.addOperand(make_unique<BaseMathExpr>(trueVar1));
expr.addOperand(make_unique<BaseMathExpr>(falseVar4));
BOOST_CHECK_EQUAL(true, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenFiveValues_ValueIsCorrect_3) {
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
Variable falseVar3 = Variable({0});
Variable falseVar4 = Variable({0, 0, 0});
Variable falseVar5 = Variable({0, 0});
BOOST_REQUIRE_EQUAL(false, falseVar1);
BOOST_REQUIRE_EQUAL(false, falseVar2);
BOOST_REQUIRE_EQUAL(false, falseVar3);
BOOST_REQUIRE_EQUAL(false, falseVar4);
BOOST_REQUIRE_EQUAL(false, falseVar5);
OrLogicExpr expr(make_unique<BaseMathExpr>(falseVar1));
expr.addOperand(make_unique<BaseMathExpr>(falseVar2));
expr.addOperand(make_unique<BaseMathExpr>(falseVar3));
expr.addOperand(make_unique<BaseMathExpr>(falseVar4));
expr.addOperand(make_unique<BaseMathExpr>(falseVar5));
BOOST_CHECK_EQUAL(false, expr.calculate());
}
BOOST_AUTO_TEST_CASE(GivenVal_ToStringCorrect) {
Variable var = Variable({1, 2});
OrLogicExpr expr(make_unique<BaseMathExpr>(var));
BOOST_CHECK_EQUAL(expr.toString(), "vec(1, 2)");
}
BOOST_AUTO_TEST_CASE(GivenThreeVals_ToStringCorrect) {
Variable trueVar1 = Variable({5, 1, 0});
Variable falseVar1 = Variable({0, 0, 0});
Variable falseVar2 = Variable({0, 0});
OrLogicExpr expr1(make_unique<BaseMathExpr>(trueVar1));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar1));
expr1.addOperand(make_unique<BaseMathExpr>(falseVar2));
BOOST_CHECK_EQUAL(expr1.toString(),
"(vec(5, 1, 0) or vec(0, 0, 0) or vec(0, 0))");
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END() | 33.277778 | 67 | 0.766791 | przestaw |
adb52401b7c370bdb1a9bd60e1b2319590a5c63c | 1,344 | cpp | C++ | solved-uva/12700.cpp | Maruf-Tuhin/Online_Judge | cf9b2a522e8b1a9623d3996a632caad7fd67f751 | [
"MIT"
] | 1 | 2019-03-31T05:47:30.000Z | 2019-03-31T05:47:30.000Z | solved-uva/12700.cpp | the-redback/competitive-programming | cf9b2a522e8b1a9623d3996a632caad7fd67f751 | [
"MIT"
] | null | null | null | solved-uva/12700.cpp | the-redback/competitive-programming | cf9b2a522e8b1a9623d3996a632caad7fd67f751 | [
"MIT"
] | null | null | null | #include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
using namespace std;
main()
{
char a[10000];
int tc,t=1;
scanf("%d",&tc);
while(tc--)
{
int i,j,k,l,m,n;
scanf("%d",&l);
getchar();
gets(a);
sort(a,a+l);
printf("Case %d: ",t++);
k=0;
n=0;
int dr=0;
int ab=0;
for(i=0;i<l;i++)
{
if(a[i]=='B')
k++;
else if(a[i]=='W')
n++;
else if(a[i]=='T')
dr++;
else if(a[i]=='A')
ab++;
}
if(ab==l)
puts("ABANDONED");
else if(n>k && k>0 || n>k && dr>0)
printf("WWW %d - %d\n",n,k);
else if(k>n && n>0 || k>n && dr>0)
printf("BANGLADESH %d - %d\n",k,n);
else if(k+ab==l)
puts("BANGLAWASH");
else if(n+ab==l)
puts("WHITEWASH");
else if(n==k)
printf("DRAW %d %d\n",n,dr);
}
return 0;
}
| 22.4 | 51 | 0.385417 | Maruf-Tuhin |
adbdac9bd89cc32f2ea168461c2e7726a776d24c | 671 | cpp | C++ | common/tests/MathTest.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | 3 | 2021-07-01T14:31:06.000Z | 2022-03-29T20:41:21.000Z | common/tests/MathTest.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | common/tests/MathTest.cpp | alexandru-andronache/adventofcode | ee41d82bae8b705818fda5bd43e9962bb0686fec | [
"Apache-2.0"
] | null | null | null | #include "MathTest.h"
#include "math_util.h"
using namespace math;
TEST_F(MathTest, modular_inverse) {
ASSERT_EQ(modularInverse(75, 119315717514047), 106588707645882);
ASSERT_EQ(modularInverse(33, 119315717514047), 3615627803456);
}
TEST_F(MathTest, power_test) {
ASSERT_EQ(modular_power(41443368465112, 101741582076661, 119315717514047), 96656040088959);
ASSERT_EQ(modular_power(2, 10, 1000), 24);
}
TEST_F(MathTest, mod_test) {
ASSERT_EQ(mod(-7249, 10007), 2758);
ASSERT_EQ(mod(305760, 10007), 5550);
}
TEST_F(MathTest, modular_divide_test) {
ASSERT_EQ(modular_divide(96656040088958, 41443368465111, 119315717514047), 98841558257567);
} | 29.173913 | 95 | 0.76006 | alexandru-andronache |
adc3810adafa5d197de88f793d8c0a885ecf474d | 3,210 | cpp | C++ | datastructures/singlylinkedlists/clone_random_ptr.cpp | oishikm12/cpp-collection | 4a454a6ed5b24570c7df0d4f0b692ae98c1ffa97 | [
"MIT"
] | 5 | 2021-05-17T12:32:42.000Z | 2021-12-12T21:09:55.000Z | datastructures/singlylinkedlists/clone_random_ptr.cpp | oishikm12/cpp-collection | 4a454a6ed5b24570c7df0d4f0b692ae98c1ffa97 | [
"MIT"
] | null | null | null | datastructures/singlylinkedlists/clone_random_ptr.cpp | oishikm12/cpp-collection | 4a454a6ed5b24570c7df0d4f0b692ae98c1ffa97 | [
"MIT"
] | 1 | 2021-05-13T20:29:57.000Z | 2021-05-13T20:29:57.000Z | #include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Node {
public:
int data;
Node *next, *arb;
Node(int val = 0, Node *lfwd = NULL, Node *larb = NULL) : data(val), next(lfwd), arb(larb) {};
~Node() { delete arb, delete next; }
};
int main() {
/**
* In order to clone a linked list with arbitary pointer
* we will maintain a map that will store the current
* addresses with old adresses, this will allow us to join
* random nodes
*/
cout << "\nThis program clones a singly linked list with arbitary pointers.\n" << endl;
cout << "Enter size of the List: ";
int n;
cin >> n;
cout << endl << "Enter space seperated elements of the list" << endl;
vector<int> elems(n);
for (int i = 0; i < n; i += 1) cin >> elems[i];
cout << "Enter number of pairs in the list: ";
int k;
cin >> k;
cout << "Enter space seperated line delimited pairs of arbitary links" << endl;
vector<pair<int, int>> links(k);
for (int i = 0; i < k; i += 1) cin >> links[i].first >> links[i].second;
Node *head = NULL;
head = build(head, elems, links);
cout << "\nThe list is: " << endl;
print(head);
Node *newHead = copyList(head);
cout << "\nThe copied list is," << endl;
print(newHead);
cout << endl;
delete head;
return 0;
}
Node* build(Node *head, vector<int> &elems, vector<pair<int, int>> &links) {
int n = elems.size();
int m = links.size();
// We will store all the node in a vector to create arb links
vector<Node*> ptrs;
head = new Node(elems[0]);
Node *temp = head;
ptrs.push_back(temp);
for (int i = 1; i < n; i += 1) {
// Iterating the elements and pushing them onto vector
temp->next = new Node(elems[i]);
temp = temp->next;
ptrs.push_back(temp);
}
for (int i = 0; i < m; i += 1) {
// Simply connect their arbitary pointers
pair<int, int> link = links[i];
ptrs[link.first - 1]->arb = ptrs[link.second - 1];
}
return head;
}
void print(Node *head) {
while (head != NULL) {
cout << head->data;
// Print data if connected to arbitary
if (head->arb) cout << "(" << head->arb->data << ")";
// Printing connector b/w nodes
if (head->next != NULL) cout << " > ";
head = head->next;
}
cout << endl;
}
Node *copyList(Node *head) {
// Creating the new node
Node *newHead = new Node(head->data);
Node *tHead = head;
Node *tnHead = newHead;
// This will allow us to map old pointers to new pointers
unordered_map<Node*, Node*> link;
link[tHead] = tnHead;
while (tHead->next) {
// Copying and placing pointers in map
tnHead->next = new Node(tHead->next->data);
link[tHead->next] = tnHead->next;
tHead = tHead->next;
tnHead = tnHead->next;
}
tnHead = newHead;
tHead = head;
while (tHead) {
// Fixing arbitary pointers
tnHead->arb = link[tHead->arb];
tHead = tHead->next;
tnHead = tnHead->next;
}
return newHead;
}
| 26.097561 | 102 | 0.557009 | oishikm12 |
adc4ce449c1d15228c35f8504c32441ade82be89 | 177 | hpp | C++ | shared/detail/no_move.hpp | playday3008/herby | 3ab4594588c4776182f18edf89d461adef583614 | [
"MIT"
] | null | null | null | shared/detail/no_move.hpp | playday3008/herby | 3ab4594588c4776182f18edf89d461adef583614 | [
"MIT"
] | null | null | null | shared/detail/no_move.hpp | playday3008/herby | 3ab4594588c4776182f18edf89d461adef583614 | [
"MIT"
] | null | null | null | #pragma once
namespace shared::detail
{
class NoMove
{
protected:
NoMove() = default;
NoMove(NoMove&&) = delete;
protected:
NoMove& operator=(NoMove&&) = delete;
};
} | 14.75 | 39 | 0.661017 | playday3008 |
ade4684b84d7d892ff5d6739af7c577cd02999b6 | 735 | cpp | C++ | Remixed/Win32Window.cpp | LukeRoss00/Revive | 09b1c59dfbff8abc06194809ec680b990b2cf21c | [
"MIT"
] | 1 | 2021-10-18T19:43:06.000Z | 2021-10-18T19:43:06.000Z | Remixed/Win32Window.cpp | LukeRoss00/Revive | 09b1c59dfbff8abc06194809ec680b990b2cf21c | [
"MIT"
] | null | null | null | Remixed/Win32Window.cpp | LukeRoss00/Revive | 09b1c59dfbff8abc06194809ec680b990b2cf21c | [
"MIT"
] | 1 | 2020-02-03T22:45:41.000Z | 2020-02-03T22:45:41.000Z | #include "Win32Window.h"
#include <Windows.h>
#include <thread>
extern HMODULE revModule;
static LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProcW(hWnd, Msg, wParam, lParam);
}
Win32Window::Win32Window()
{
WNDCLASSW wc;
memset(&wc, 0, sizeof(wc));
wc.hInstance = revModule;
wc.lpszClassName = L"Remixed";
wc.lpfnWndProc = WindowProc;
_ASSERT(RegisterClassW(&wc));
m_hWnd = CreateWindowW(wc.lpszClassName, L"Remixed", 0, 0, 0, 0, 0, 0, 0, revModule, 0);
}
Win32Window::~Win32Window()
{
DestroyWindow(m_hWnd);
UnregisterClassW(L"Remixed", revModule);
}
void Win32Window::Show(bool show)
{
ShowWindow(m_hWnd, show ? SW_SHOWNORMAL : SW_HIDE);
UpdateWindow(m_hWnd);
}
| 20.416667 | 89 | 0.727891 | LukeRoss00 |
ade655eac7a18a742a4cdeaa2ccab5583b49ab04 | 1,224 | cpp | C++ | Util/NameValuePair.cpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 1 | 2019-08-30T02:34:29.000Z | 2019-08-30T02:34:29.000Z | Util/NameValuePair.cpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | Util/NameValuePair.cpp | okean/cpputils | 812cf41f04d66c28a5eb46dedab6e782c49e0f7a | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | #include "stdafx.h"
#include "NameValuePair.h"
#include <Util/Text.h>
using namespace Util;
NameValuePair::NameValuePair(
const std::string & name,
const std::string & value)
: _name(name)
, _value(value)
{
}
NameValuePair::NameValuePair(
const std::string &str,
const char & separator,
bool trim)
{
split(_name, _value, str, separator);
if (trim)
{
Text::trimInPlace(_name);
Text::trimInPlace(_value);
}
}
NameValuePair::~NameValuePair()
{
}
// interface
const std::string & NameValuePair::name() const
{
return _name;
}
const std::string & NameValuePair::value() const
{
return _value;
}
std::string NameValuePair::toString(const char & separator) const
{
return _name + separator + _value;
}
// internal static helpers
void NameValuePair::split(
std::string &name,
std::string &value,
const std::string &str,
const char & separator)
{
std::string namevalue{ str };
auto pos = namevalue.find(separator);
if (pos != std::string::npos)
{
name = namevalue.substr(0, pos);
value = namevalue.substr(pos + 1);
}
else
{
name = namevalue;
value.clear();
}
}
| 17 | 65 | 0.615196 | okean |
adec19b875bb6aca9e652cbc18c3112b711967d0 | 766 | cpp | C++ | comp/cses/intro/g_knights.cpp | imbush/practice | 05116375a7361fb0acc477a22ff0745e41aad825 | [
"MIT"
] | null | null | null | comp/cses/intro/g_knights.cpp | imbush/practice | 05116375a7361fb0acc477a22ff0745e41aad825 | [
"MIT"
] | null | null | null | comp/cses/intro/g_knights.cpp | imbush/practice | 05116375a7361fb0acc477a22ff0745e41aad825 | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n;
ll sum = 0;
cin >> n;
cout << sum << "\n";
for (ll i = 2; i <= n; i ++) {
sum += (2 * i - 1) * (2 * i - 2) / 2; // The outside interactions
if (i > 2) {
sum -= 4;
}
sum += (2 * i - 1) * (i * i - 2 * i + 1); // Inner pairs with top left
for (ll j = 0; j < i - 1; j ++) {
sum -= 8;
if (j == 0) {
sum += 4;
} else if (j == 1) {
sum += 2;
}
if (j == i - 2) {
sum += 4;
} else if (j == i - 3) {
sum += 2;
}
}
cout << sum << "\n";
}
} | 23.212121 | 78 | 0.292428 | imbush |
adec9a93e349f2f3f7fd0bce130dac2c0a0b65de | 8,350 | cpp | C++ | lib/MatrixClasses/IndexMatrix.cpp | xschrodingerscat/kspaceFirstOrder | 99f326d420a5488693bcf9fdd633d2eff7447cca | [
"RSA-MD"
] | null | null | null | lib/MatrixClasses/IndexMatrix.cpp | xschrodingerscat/kspaceFirstOrder | 99f326d420a5488693bcf9fdd633d2eff7447cca | [
"RSA-MD"
] | null | null | null | lib/MatrixClasses/IndexMatrix.cpp | xschrodingerscat/kspaceFirstOrder | 99f326d420a5488693bcf9fdd633d2eff7447cca | [
"RSA-MD"
] | null | null | null | /**
* @file IndexMatrix.cpp
*
* @author Jiri Jaros \n
* Faculty of Information Technology \n
* Brno University of Technology \n
* jarosjir@fit.vutbr.cz
*
* @brief The implementation file containing the class for 64b integer index matrices.
*
* @version kspaceFirstOrder 2.17
*
* @date 26 July 2011, 15:16 (created) \n
* 11 February 2020, 14:43 (revised)
*
* @copyright Copyright (C) 2011 - 2020 SC\@FIT Research Group, Brno University of Technology, Brno, CZ.
*
* This file is part of the C++ extension of the [k-Wave Toolbox](http://www.k-wave.org).
*
* k-Wave is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
* more details.
*
* You should have received a copy of the GNU Lesser General Public License along with k-Wave.
* If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
*/
#include <MatrixClasses/IndexMatrix.h>
#include <Logger/Logger.h>
//--------------------------------------------------------------------------------------------------------------------//
//------------------------------------------------- Public methods ---------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------------//
/**
* Constructor allocating memory.
*/
IndexMatrix::IndexMatrix(const DimensionSizes& dimensionSizes)
: BaseIndexMatrix()
{
initDimensions(dimensionSizes);
allocateMemory();
}// end of IndexMatrix
//----------------------------------------------------------------------------------------------------------------------
/**
* Destructor.
*/
IndexMatrix::~IndexMatrix()
{
freeMemory();
}// end of ~IndexMatrix
//----------------------------------------------------------------------------------------------------------------------
void
IndexMatrix::readData(KMatrixCached& cached, const MatrixName& matrixName)
{
size_t idx = 0;
auto &mat = *static_cast<KMatrix<size_t>*>(cached[matrixName].get());
for (size_t j = 0; j < mat.colSize(); ++ j)
for (size_t i = 0; i < mat.rowSize(); ++ i)
mData[idx ++] = mat[i][j];
}
/**
* Read data from HDF5 file (only from the root group).
*/
void IndexMatrix::readData(Hdf5File& file,
const MatrixName& matrixName)
{
// Check the datatype
if (file.readMatrixDataType(file.getRootGroup(), matrixName) != Hdf5File::MatrixDataType::kIndex)
{
throw std::ios::failure(Logger::formatMessage(kErrFmtMatrixNotIndex, matrixName.c_str()));
}
// Check the domain type
if (file.readMatrixDomainType(file.getRootGroup(), matrixName) != Hdf5File::MatrixDomainType::kReal)
{
throw std::ios::failure(Logger::formatMessage(kErrFmtMatrixNotReal,matrixName.c_str()));
}
// Read data
file.readCompleteDataset(file.getRootGroup(), matrixName, mDimensionSizes, mData);
}// end of readData
//----------------------------------------------------------------------------------------------------------------------
/**
* Write data to HDF5 file.
*/
void IndexMatrix::writeData(Hdf5File& file,
const MatrixName& matrixName,
const size_t compressionLevel)
{
// Set chunks - may be necessary for long index based sensor masks
DimensionSizes chunks = mDimensionSizes;
chunks.nz = 1;
// 1D matrices - chunk sizes were empirically set.
if ((mDimensionSizes.ny == 1) && (mDimensionSizes.nz == 1))
{
if (mDimensionSizes.nx > 4 * kChunkSize1D8MB)
{ // Chunk = 8MB for big matrices (> 32MB).
chunks.nx = kChunkSize1D8MB;
}
else if (mDimensionSizes.nx > 4 * kChunkSize1D1MB)
{ // Chunk = 1MB for big matrices (> 4 - 32MB).
chunks.nx = kChunkSize1D1MB;
}
else if (mDimensionSizes.nx > 4 * kChunkSize1D128kB)
{ // Chunk = 128kB for big matrices (< 1MB).
chunks.nx = kChunkSize1D128kB;
}
}
// Create dataset and write a slab
hid_t dataset = file.createDataset(file.getRootGroup(),
matrixName,
mDimensionSizes,
chunks,
Hdf5File::MatrixDataType::kIndex,
compressionLevel);
// Write at position [0,0,0].
file.writeHyperSlab(dataset, DimensionSizes(0, 0, 0), mDimensionSizes, mData);
file.closeDataset(dataset);
// Write data and domain types
file.writeMatrixDataType(file.getRootGroup(), matrixName, Hdf5File::MatrixDataType::kIndex);
file.writeMatrixDomainType(file.getRootGroup(), matrixName, Hdf5File::MatrixDomainType::kReal);
}// end of writeData
//----------------------------------------------------------------------------------------------------------------------
/**
* Get the top left corner of the index-th cuboid.\n
* Cuboids are stored as 6-tuples (two 3D coordinates). This gives the first three coordinates.
*/
DimensionSizes IndexMatrix::getTopLeftCorner(const size_t& index) const
{
size_t x = mData[6 * index ];
size_t y = mData[6 * index + 1];
size_t z = mData[6 * index + 2];
return DimensionSizes(x, y, z);
}// end of getTopLeftCorner
//----------------------------------------------------------------------------------------------------------------------
/**
* Get the top bottom right of the index-th cuboid. \n
* Cuboids are stored as 6-tuples (two 3D coordinates). This gives the first three coordinates.
*/
DimensionSizes IndexMatrix::getBottomRightCorner(const size_t& index) const
{
size_t x = mData[6 * index + 3];
size_t y = mData[6 * index + 4];
size_t z = mData[6 * index + 5];
return DimensionSizes(x, y, z);
}// end of GetBottomRightCorner
//----------------------------------------------------------------------------------------------------------------------
/**
* Recompute indeces, MATLAB -> C++.
*/
void IndexMatrix::recomputeIndicesToCPP()
{
#pragma omp parallel for simd schedule(simd:static)
for (size_t i = 0; i < mSize; i++)
{
mData[i]--;
}
}// end of recomputeIndicesToCPP
//----------------------------------------------------------------------------------------------------------------------
/**
* Recompute indeces, C++ -> MATLAB.
*/
void IndexMatrix::recomputeIndicesToMatlab()
{
#pragma omp parallel for simd schedule(simd:static)
for (size_t i = 0; i < mSize; i++)
{
mData[i]++;
}
}// end of recomputeIndicesToMatlab
//----------------------------------------------------------------------------------------------------------------------
/**
* Get total number of elements in all cuboids to be able to allocate output file.
*/
size_t IndexMatrix::getSizeOfAllCuboids() const
{
size_t elementSum = 0;
for (size_t cuboidIdx = 0; cuboidIdx < mDimensionSizes.ny; cuboidIdx++)
{
elementSum += (getBottomRightCorner(cuboidIdx) - getTopLeftCorner(cuboidIdx)).nElements();
}
return elementSum;
}// end of getSizeOfAllCuboids
//----------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------//
//------------------------------------------------ Protected methods -------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------------//
//------------------------------------------------- Private methods --------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------------//
/**
* Set necessary dimensions and auxiliary variables.
*/
void IndexMatrix::initDimensions(const DimensionSizes& dimensionSizes)
{
mDimensionSizes = dimensionSizes;
mSize = dimensionSizes.nx * dimensionSizes.ny * dimensionSizes.nz;
mCapacity = mSize;
}// end of initDimensions
//----------------------------------------------------------------------------------------------------------------------
| 36.462882 | 120 | 0.513293 | xschrodingerscat |
aded5e6bfc57c45c06c80910e053eb380b33da18 | 208 | cpp | C++ | Source/MultiplayerLab/MultiplayerLab.cpp | AnupamSahu/UnrealMultiplayerLab | fae050ffa1589154e3a073de34e95988f569e105 | [
"MIT"
] | null | null | null | Source/MultiplayerLab/MultiplayerLab.cpp | AnupamSahu/UnrealMultiplayerLab | fae050ffa1589154e3a073de34e95988f569e105 | [
"MIT"
] | null | null | null | Source/MultiplayerLab/MultiplayerLab.cpp | AnupamSahu/UnrealMultiplayerLab | fae050ffa1589154e3a073de34e95988f569e105 | [
"MIT"
] | null | null | null | // Copyright Epic Games, Inc. All Rights Reserved.
#include "MultiplayerLab.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MultiplayerLab, "MultiplayerLab" );
| 29.714286 | 90 | 0.802885 | AnupamSahu |
adef6dd29f07ea7b0e0f5acb5072ee99d2e3cee6 | 6,307 | cpp | C++ | Plugins/org.mitk.lancet.robot/src/api/vega/capisample/CAPIcommon/src/SystemAlert.cpp | zhaomengxiao/MITK | a09fd849a4328276806008bfa92487f83a9e2437 | [
"BSD-3-Clause"
] | null | null | null | Plugins/org.mitk.lancet.robot/src/api/vega/capisample/CAPIcommon/src/SystemAlert.cpp | zhaomengxiao/MITK | a09fd849a4328276806008bfa92487f83a9e2437 | [
"BSD-3-Clause"
] | 1 | 2021-12-22T10:19:02.000Z | 2021-12-22T10:19:02.000Z | Plugins/org.mitk.lancet.robot/src/api/vega/capisample/CAPIcommon/src/SystemAlert.cpp | zhaomengxiao/MITK_lancet | a09fd849a4328276806008bfa92487f83a9e2437 | [
"BSD-3-Clause"
] | null | null | null | //----------------------------------------------------------------------------
//
// Copyright (C) 2017, Northern Digital Inc. All rights reserved.
//
// All Northern Digital Inc. ("NDI") Media and/or Sample Code and/or Sample Code
// Documentation (collectively referred to as "Sample Code") is licensed and provided "as
// is" without warranty of any kind. The licensee, by use of the Sample Code, warrants to
// NDI that the Sample Code is fit for the use and purpose for which the licensee intends to
// use the Sample Code. NDI makes no warranties, express or implied, that the functions
// contained in the Sample Code will meet the licensee's requirements or that the operation
// of the programs contained therein will be error free. This warranty as expressed herein is
// exclusive and NDI expressly disclaims any and all express and/or implied, in fact or in
// law, warranties, representations, and conditions of every kind pertaining in any way to
// the Sample Code licensed and provided by NDI hereunder, including without limitation,
// each warranty and/or condition of quality, merchantability, description, operation,
// adequacy, suitability, fitness for particular purpose, title, interference with use or
// enjoyment, and/or non infringement, whether express or implied by statute, common law,
// usage of trade, course of dealing, custom, or otherwise. No NDI dealer, distributor, agent
// or employee is authorized to make any modification or addition to this warranty.
// In no event shall NDI nor any of its employees be liable for any direct, indirect,
// incidental, special, exemplary, or consequential damages, sundry damages or any
// damages whatsoever, including, but not limited to, procurement of substitute goods or
// services, loss of use, data or profits, or business interruption, however caused. In no
// event shall NDI's liability to the licensee exceed the amount paid by the licensee for the
// Sample Code or any NDI products that accompany the Sample Code. The said limitations
// and exclusions of liability shall apply whether or not any such damages are construed as
// arising from a breach of a representation, warranty, guarantee, covenant, obligation,
// condition or fundamental term or 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
// the Sample Code even if advised of the possibility of such damage. In no event shall
// NDI be liable for any claims, losses, damages, judgments, costs, awards, expenses or
// liabilities of any kind whatsoever arising directly or indirectly from any injury to person
// or property, arising from the Sample Code or any use thereof
//
//----------------------------------------------------------------------------
#include <iomanip>
#include <sstream>
#include "SystemAlert.h"
std::string SystemAlert::toString() const
{
// Lookup the appropriate toString() method based on its type
switch (conditionType)
{
case SystemAlertType::Fault:
return std::string("Fault::").append(SystemFaultEnum::toString(conditionCode));
case SystemAlertType::Alert:
return std::string("Alert::").append(SystemAlertEnum::toString(conditionCode));
case SystemAlertType::Event:
return std::string("Event::").append(SystemEventEnum::toString(conditionCode));
default:
break; // do nothing
};
// Print the unrecognized alert types in hex
std::stringstream stream;
stream << std::hex << std::setfill('0');
stream << "UnrecognizedAlertType: " << std::setw(4) << conditionType;
return stream.str();
}
std::string SystemFaultEnum::toString(uint16_t conditionCode)
{
switch (conditionCode)
{
case SystemFaultEnum::Ok:
return "Ok";
case SystemFaultEnum::FatalParameter:
return "FatalParameter";
case SystemFaultEnum::SensorParameter:
return "SensorParameter";
case SystemFaultEnum::MainVoltage:
return "MainVoltage";
case SystemFaultEnum::SensorVoltage:
return "SensorVoltage";
case SystemFaultEnum::IlluminatorCurrent:
return "IlluminatorCurrent";
case SystemFaultEnum::IlluminatorVoltage:
return "IlluminatorVoltage";
case SystemFaultEnum::Sensor0Temp:
return "Sensor0Temp";
case SystemFaultEnum::Sensor1Temp:
return "Sensor1Temp";
case SystemFaultEnum::MainTemp:
return "MainTemp";
case SystemFaultEnum::SensorMalfunction:
return "SensorMalfunction";
default:
break; // do nothing
};
// Print the unrecognized fault types in hex
std::stringstream stream;
stream << std::hex << std::setfill('0');
stream << "UnrecognizedFault: " << std::setw(4) << conditionCode;
return stream.str();
}
std::string SystemAlertEnum::toString(uint16_t conditionCode)
{
switch (conditionCode)
{
case SystemAlertEnum::Ok:
return "Ok";
case SystemAlertEnum::BatteryLow:
return "BatteryLow";
case SystemAlertEnum::BumpDetected:
return "BumpDetected";
case SystemAlertEnum::IncompatibleFirmware:
return "IncompatibleFirmware";
case SystemAlertEnum::NonFatalParameter:
return "NonFatalParameter";
case SystemAlertEnum::FlashMemoryFull:
return "FlashMemoryFull";
case SystemAlertEnum::StorageTempExceeded:
return "StorageTempExceeded";
case SystemAlertEnum::TempHigh:
return "TempHigh";
case SystemAlertEnum::TempLow:
return "TempLow";
case SystemAlertEnum::ScuDisconnected:
return "ScuDisconnected";
case SystemAlertEnum::PtpClockSynch:
return "PtpClockSynch";
default:
break;
};
// Print the unrecognized alert types in hex
std::stringstream stream;
stream << std::hex << std::setfill('0');
stream << "UnrecognizedAlert: " << std::setw(4) << conditionCode;
return stream.str();
}
std::string SystemEventEnum::toString(uint16_t conditionCode)
{
switch (conditionCode)
{
case SystemEventEnum::Ok:
return "Ok";
case SystemEventEnum::ToolPluggedIn:
return "ToolPluggedIn";
case SystemEventEnum::ToolUnplugged:
return "ToolUnplugged";
case SystemEventEnum::SiuPluggedIn:
return "SiuPluggedIn";
case SystemEventEnum::SiuUnplugged:
return "SiuUnplugged";
default:
return "UnrecognizedEvent";
};
// Print the unrecognized event types in hex
std::stringstream stream;
stream << std::hex << std::setfill('0');
stream << "UnrecognizedEvent: " << std::setw(4) << conditionCode;
return stream.str();
} | 39.173913 | 95 | 0.738386 | zhaomengxiao |
adf2be6fccab7a20a6f7bfe7eaa3ed009a3b2420 | 8,223 | cc | C++ | tutorial/4_graphics/transparency.cc | tdelame/Graphics-Origin | 27b7d6ac72c4cb1858fc85dc18fe864de1496c6d | [
"MIT"
] | null | null | null | tutorial/4_graphics/transparency.cc | tdelame/Graphics-Origin | 27b7d6ac72c4cb1858fc85dc18fe864de1496c6d | [
"MIT"
] | null | null | null | tutorial/4_graphics/transparency.cc | tdelame/Graphics-Origin | 27b7d6ac72c4cb1858fc85dc18fe864de1496c6d | [
"MIT"
] | null | null | null | /* Created on: May 22, 2016
* Author: T. Delame (tdelame@gmail.com) */
/**
* The main differences between the files of this application and the one of
* the tutorial 3_simple_gl_applications are:
* - the definition of a transparent windows renderable, that we will use to
* have some transparency in the scene (see transparency/transparent_windows_renderable.h)
* - the definition of a window frames renderable to add a frame around the
* transparent windows (see transparency/window_frames_renderable.h)
* - the definition of a transparency_gl_renderer, which is basically the
* simple_gl_renderer with another list for transparent windows renderables.
* Those renderables are rendered last, after all opaque objects had been
* rendered on the GPU.
* - the definition of a transparency_gl_window, which only difference with
* simple_gl_window is the initialization of a default scene in the
* constructor.
* - the definition of a camera that cannot be controlled by the user but
* that will rotate around the scene (see transparency/rotating_camera.h)
*/
// to write window/draw code
# include "../../graphics-origin/application/camera.h"
# include "../../graphics-origin/application/gl_helper.h"
# include "../../graphics-origin/application/window.h"
# include "../../graphics-origin/application/renderer.h"
# include "../../graphics-origin/application/shader_program.h"
# include <GL/glew.h>
// to use renderables in the scene
# include "../../graphics-origin/application/renderables/textured_mesh_renderable.h"
# include "transparency/window_frames_renderable.h"
# include "transparency/transparent_windows_renderable.h"
// utilities
# include "../../graphics-origin/tools/resources.h"
# include "../../graphics-origin/tools/log.h"
namespace graphics_origin {
namespace application {
class transparency_gl_renderer
: public graphics_origin::application::renderer {
public:
~transparency_gl_renderer(){}
transparency_gl_renderer() :
m_windows{ nullptr }
{}
private:
void do_add( graphics_origin::application::renderable* r ) override
{
// check if the renderable is a transparent window
transparent_windows_renderable* windows = dynamic_cast< transparent_windows_renderable* >( r );
if( windows )
{
if( m_windows )
{
LOG( info, "cannot have more than one set of windows. Deleting previous one.");
delete m_windows;
m_windows = nullptr;
}
m_windows = windows;
}
// otherwise, add it to the list of opaque objects
else m_renderables.push_back( r );
}
void do_render() override
{
gl_camera->update();
// render opaque objects, i.e. the central mesh and the window frames.
for( auto& r : m_renderables )
{
r->get_shader_program()->bind();
r->render();
}
// render transparent windows (if any)
if( m_windows )
{
// Activate blending with the right interpolation function. [1]
glcheck(glEnable(GL_BLEND));
glcheck(glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
// bind the program and draw our windows
m_windows->get_shader_program()->bind();
m_windows->render();
// remember to disable blending to not mess with other parts of the code [1]
glcheck(glDisable(GL_BLEND));
//[1] Typically, those lines should be included inside the do_render()
// function of transparent_windows_renderable. I let them here to insist
// on their importance in the main source file of the demo.
}
}
void do_shut_down() override
{
while( !m_renderables.empty() )
{
auto r = m_renderables.front();
delete r;
m_renderables.pop_front();
}
if( m_windows )
{
delete m_windows;
m_windows = nullptr;
}
}
std::list< graphics_origin::application::renderable* > m_renderables;
graphics_origin::application::transparent_windows_renderable* m_windows;
};
class simple_gl_window
: public window {
public:
simple_gl_window( QQuickItem* parent = nullptr )
: window( parent )
{
initialize_renderer( new transparency_gl_renderer );
std::string texture_directory = tools::get_path_manager().get_resource_directory( "textures" );
std::string shader_directory = tools::get_path_manager().get_resource_directory( "shaders" );
std::string mesh_directory = tools::get_path_manager().get_resource_directory( "meshes" );
shader_program_ptr mesh_program =
std::make_shared<shader_program>( std::list<std::string>{
shader_directory + "textured_mesh.vert",
shader_directory + "textured_mesh.frag"});
shader_program_ptr transparent_program =
std::make_shared<shader_program>( std::list<std::string>{
shader_directory + "transparent_window.vert",
shader_directory + "transparent_window.geom",
shader_directory + "transparent_window.frag"
});
shader_program_ptr frame_program =
std::make_shared<shader_program>( std::list<std::string>{
shader_directory + "window_frame.vert",
shader_directory + "window_frame.geom",
shader_directory + "window_frame.frag"
});
auto mesh = new textured_mesh_renderable( mesh_program );
mesh->load_mesh( mesh_directory + "Bunny.obj" );
mesh->load_texture( texture_directory + "TexturedBunny.png" );
mesh->set_model_matrix( glm::rotate( gl_real(M_PI_2), gl_vec3{0,0,1}) * glm::rotate( gl_real(M_PI_2), gl_vec3{1,0,0}));
add_renderable( mesh );
const unsigned int angle_divisions = 16;
const gl_real angle_step = 2.0 * M_PI / gl_real{16};
gl_real angle = 0;
auto windows = new transparent_windows_renderable( transparent_program, angle_divisions );
auto frames = new window_frames_renderable( frame_program, angle_divisions );
for( unsigned int i = 0; i < angle_divisions; ++ i, angle += angle_step )
{
auto rotation = glm::rotate( angle, gl_vec3{0,0,1} );
auto position = gl_vec3{rotation * gl_vec4{2,0,0,1.0}};
auto v1 = gl_vec3{rotation * gl_vec4{0,0.4,-0.3,0}};
auto v2 = gl_vec3{rotation * gl_vec4{0,-0.4,-0.3,0}};
// add a transparent window with a color based on its position
windows->add(
position, v1, v2,
gl_vec4{0.5 + position.x / 4.0, 0.5 + position.y / 4.0, 0.5 + position.z / 4.0, 0.2 + gl_real(i) / gl_real(angle_divisions)*0.4} );
// add a frame around that window with a dimension that depends on its position
frames->add(
position, v1, v2, 0.01 + 0.02 * gl_real(i)/gl_real(angle_divisions), 0.02 );
}
add_renderable( windows );
add_renderable( frames );
}
};
}}
// launching our Qt/QtQuick + OpenGL application
# include "common/simple_qml_application.h"
# include "transparency/rotating_camera.h"
# include <QGuiApplication>
int main( int argc, char* argv[] )
{
// This is typically the place where you will analyze command-line arguments
// such as to set a resources root directory.
// Initialize the GUI application.
QGuiApplication qgui( argc, argv );
// Register C++ types to the QML engine: we would then be able to use those types in qml scripts.
qmlRegisterType<graphics_origin::application::simple_gl_window>( "GraphicsOrigin", 1, 0, "GLWindow" );
qmlRegisterType<graphics_origin::application::rotating_camera >( "GraphicsOrigin", 1, 0, "GLCamera" );
// Load the main QML describing the main window into the simple QML application.
std::string input_qml = graphics_origin::tools::get_path_manager().get_resource_directory( "qml" ) + "4_transparency.qml";
graphics_origin::application::simple_qml_application app;
app.setSource(QUrl::fromLocalFile( input_qml.c_str()));
// This ensure that the application is running and visible, you do not have to worry about those 3 lines.
app.show();
app.raise();
return qgui.exec();
}
| 39.917476 | 143 | 0.670801 | tdelame |
adf6aec19503004f072eefc7932978ecd9b307fc | 1,328 | cpp | C++ | Prova di Esame/TerzoFile/main.cpp | LucaMazzei88/CefiCourse | 1ed516b6cdbd72fd5197c7fe876005fbb27dea71 | [
"Apache-2.0"
] | null | null | null | Prova di Esame/TerzoFile/main.cpp | LucaMazzei88/CefiCourse | 1ed516b6cdbd72fd5197c7fe876005fbb27dea71 | [
"Apache-2.0"
] | null | null | null | Prova di Esame/TerzoFile/main.cpp | LucaMazzei88/CefiCourse | 1ed516b6cdbd72fd5197c7fe876005fbb27dea71 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;
vector<int>* leggiFile(FILE* id);
int main()
{
FILE* dato1=fopen("dato1.txt","r");
FILE* dato2=fopen("dato2.txt","r");
if(dato1==NULL ||dato2==NULL){
cout<<"File non trovato"<<endl;
exit(0);
}
FILE* dato3=fopen("dato3.txt","w");
set<int>* lista=new set<int>();
vector<int>* vecDato1=new vector<int>();
vector<int>* vecDato2=new vector<int>();
vecDato1=leggiFile(dato1);
vecDato2=leggiFile(dato2);
vector<int>::iterator itDato1;
vector<int>::iterator itDato2;
set<int>::iterator itSet;
for(itDato1=vecDato1->begin();itDato1!=vecDato1->end();itDato1++){
for(itDato2=vecDato2->begin();itDato2!=vecDato2->end();itDato2++){
if(*itDato1==*itDato2){
lista->insert(*itDato1);
}
}
}
for(itSet=lista->begin();itSet!=lista->end();itSet++){
fprintf(dato3,"%d\n",*itSet);
}
fclose(dato1);
fclose(dato2);
fclose(dato3);
return 0;
}
vector<int>* leggiFile(FILE* id){
char* numeri=new char[10];
vector<int>* vec=new vector<int>();
int i=0;
while((numeri=fgets(numeri,10 ,id))!=NULL){
vec->push_back(atoi(numeri));
}
return vec;
}
| 24.592593 | 74 | 0.584337 | LucaMazzei88 |
adf6bd3fa78b9c2fb46fc743bbbaf44636634a9c | 518 | cpp | C++ | src/gamebase/src/impl/geom/Intersection.cpp | TheMrButcher/opengl_lessons | 76ac96c45773a54a85d49c6994770b0c3496303f | [
"MIT"
] | 1 | 2016-10-25T21:15:16.000Z | 2016-10-25T21:15:16.000Z | src/gamebase/src/impl/geom/Intersection.cpp | TheMrButcher/gamebase | 76ac96c45773a54a85d49c6994770b0c3496303f | [
"MIT"
] | 375 | 2016-06-04T11:27:40.000Z | 2019-04-14T17:11:09.000Z | src/gamebase/src/impl/geom/Intersection.cpp | TheMrButcher/gamebase | 76ac96c45773a54a85d49c6994770b0c3496303f | [
"MIT"
] | null | null | null | /**
* Copyright (c) 2018 Slavnejshev Filipp
* This file is licensed under the terms of the MIT license.
*/
#include <stdafx.h>
#include <gamebase/impl/geom/Intersection.h>
namespace gamebase { namespace impl {
bool isPointInTriangle(const Vec2& point,
const Vec2& p1, const Vec2& p2, const Vec2& p3)
{
float a = cross(point - p1, p2 - p1);
float b = cross(point - p2, p3 - p2);
float c = cross(point - p3, p1 - p3);
return (a >= 0 && b >= 0 && c >= 0) || (a <= 0 && b <= 0 && c <= 0);
}
} }
| 24.666667 | 72 | 0.596525 | TheMrButcher |
adfa7dbafd88f6becdb57d74e732da0f1d411aaa | 484 | cxx | C++ | source/opengl/vao.cxx | bjadamson/BoomHS | 60b5d8ddc2490ec57e8f530ba7ce3135221e2ec4 | [
"MIT"
] | 2 | 2016-07-22T10:09:21.000Z | 2017-09-16T06:50:01.000Z | source/opengl/vao.cxx | bjadamson/BoomHS | 60b5d8ddc2490ec57e8f530ba7ce3135221e2ec4 | [
"MIT"
] | 14 | 2016-08-13T22:45:56.000Z | 2018-12-16T03:56:36.000Z | source/opengl/vao.cxx | bjadamson/BoomHS | 60b5d8ddc2490ec57e8f530ba7ce3135221e2ec4 | [
"MIT"
] | null | null | null | #include <extlibs/fmt.hpp>
#include <opengl/vao.hpp>
namespace opengl
{
VAO&
VAO::operator=(VAO&& other)
{
vao_ = other.vao_;
debug_check = MOVE(other.debug_check);
other.vao_ = 0;
return *this;
}
std::string
VAO::to_string() const
{
return fmt::sprintf("(VAO) NUM_BUFFERS: %li, raw: %u", VAO::NUM_BUFFERS, gl_raw_value());
}
std::ostream&
operator<<(std::ostream& stream, VAO const& vao)
{
stream << vao.to_string();
return stream;
}
} // namespace opengl
| 15.612903 | 91 | 0.657025 | bjadamson |
adfabe803f73d3dd23e56d1cfe6923e2a641435b | 4,415 | cpp | C++ | tests/comm/interface/component/BroadcastTests.cpp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 3 | 2021-06-24T10:20:12.000Z | 2021-07-18T14:43:19.000Z | tests/comm/interface/component/BroadcastTests.cpp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 2 | 2021-07-22T15:31:03.000Z | 2021-07-28T14:27:28.000Z | tests/comm/interface/component/BroadcastTests.cpp | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 1 | 2021-07-22T15:24:24.000Z | 2021-07-22T15:24:24.000Z | /*
* @file
* @author University of Warwick
* @version 1.0
*
* @section LICENSE
*
* @section DESCRIPTION
*
*/
#define BOOST_TEST_MODULE Broadcast
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
#include <stdexcept>
#include "Broadcast.h"
#include "mpi.h"
#include <iostream>
#include <cstring>
// Setup MPI
BOOST_AUTO_TEST_CASE(setup)
{
int argc = boost::unit_test::framework::master_test_suite().argc;
char ** argv = boost::unit_test::framework::master_test_suite().argv;
MPI_Init(&argc, &argv);
}
// Namespace
using namespace cupcfd::comm;
// === Broadcast1 ===
// Broadcast and storage of buffer, passing send pointer only
// Test1: Test an integer broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast1_test1)
{
Communicator comm(MPI_COMM_WORLD);
int buf[6] = {0, 0, 0, 0, 0, 0};
int nBuf = 6;
int cmp[6] = {102, 7, 9, 2, 11, 13};
if(comm.rank == 0)
{
std::memcpy(buf, cmp, sizeof(int) * 6);
}
cupcfd::error::eCodes status = Broadcast(buf, nBuf, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL_COLLECTIONS(buf, buf + nBuf, cmp, cmp + nBuf);
}
// Test2: Test a double broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast1_test2)
{
Communicator comm(MPI_COMM_WORLD);
double buf[6] = {0, 0, 0, 0, 0, 0};
int nBuf = 6;
double cmp[6] = {102.23, 7.10, 9.95, 2.682, 11.111, 13.73003};
if(comm.rank == 0)
{
std::memcpy(buf, cmp, sizeof(double) * 6);
}
cupcfd::error::eCodes status = Broadcast(buf, nBuf, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL_COLLECTIONS(buf, buf + nBuf, cmp, cmp + nBuf);
}
// === Broadcast2 ===
// Broadcast and storage of buffer, copying to recv buffer
// Test1: Test an integer broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast2_test1)
{
Communicator comm(MPI_COMM_WORLD);
int send[6] = {0, 0, 0, 0, 0, 0};
int nSend = 6;
int recv[6] = {0, 0, 0, 0, 0, 0};
int nRecv = 6;
int cmp[6] = {102, 7, 9, 2, 11, 13};
if(comm.rank == 0)
{
std::memcpy(send, cmp, sizeof(int) * 6);
}
cupcfd::error::eCodes status = Broadcast(send, nSend, recv, nRecv, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL_COLLECTIONS(recv, recv + nRecv, cmp, cmp + 6);
}
// Test2: Test a double broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast2_test2)
{
Communicator comm(MPI_COMM_WORLD);
double send[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
int nSend = 6;
double recv[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
int nRecv = 6;
double cmp[6] = {102.23, 7.10, 9.95, 2.682, 11.111, 13.73003};
if(comm.rank == 0)
{
std::memcpy(send, cmp, sizeof(double) * 6);
}
cupcfd::error::eCodes status = Broadcast(send, nSend, recv, nRecv, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL_COLLECTIONS(recv, recv + nRecv, cmp, cmp + 6);
}
// === Broadcast3 ===
// Broadcast and storage of buffer, creating the recv buffer of
// an appropriate size
// Test1: Test an integer broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast3_test1)
{
Communicator comm(MPI_COMM_WORLD);
int send[6] = {0, 0, 0, 0, 0, 0};
int nSend = 6;
int * recv;
int nRecv;
int cmp[6] = {102, 7, 9, 2, 11, 13};
if(comm.rank == 0)
{
std::memcpy(send, cmp, sizeof(int) * 6);
}
cupcfd::error::eCodes status = Broadcast(send, nSend, &recv, &nRecv, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL(nRecv, 6);
BOOST_CHECK_EQUAL_COLLECTIONS(recv, recv + nRecv, cmp, cmp + 6);
free(recv);
}
// Test2: Test a double broadcast from rank 0 of a buffer
BOOST_AUTO_TEST_CASE(broadcast3_test2)
{
Communicator comm(MPI_COMM_WORLD);
double send[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
int nSend = 6;
double * recv;
int nRecv;
double cmp[6] = {102.23, 7.10, 9.95, 2.682, 11.111, 13.73003};
if(comm.rank == 0)
{
std::memcpy(send, cmp, sizeof(double) * 6);
}
cupcfd::error::eCodes status = Broadcast(send, nSend, &recv, &nRecv, 0, comm);
BOOST_CHECK_EQUAL(status, cupcfd::error::E_SUCCESS);
BOOST_CHECK_EQUAL(nRecv, 6);
BOOST_CHECK_EQUAL_COLLECTIONS(recv, recv + nRecv, cmp, cmp + 6);
free(recv);
}
BOOST_AUTO_TEST_CASE(cleanup)
{
// Cleanup MPI Environment
MPI_Finalize();
}
| 23.994565 | 79 | 0.655266 | thorbenlouw |
adfc8d2d3a732dcc06a337515b55c77d75e36db1 | 9,701 | cpp | C++ | thermal/main.cpp | naohaq/pezy-mokumoku | aede78653c401db30cccf1b891e27587098c8b55 | [
"BSD-3-Clause"
] | null | null | null | thermal/main.cpp | naohaq/pezy-mokumoku | aede78653c401db30cccf1b891e27587098c8b55 | [
"BSD-3-Clause"
] | null | null | null | thermal/main.cpp | naohaq/pezy-mokumoku | aede78653c401db30cccf1b891e27587098c8b55 | [
"BSD-3-Clause"
] | null | null | null | /*!
* @author Naoyuki MORITA
* @date 2019
* @copyright BSD-3-Clause
*/
#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <cassert>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <random>
#include <sstream>
#include <stdexcept>
#include <vector>
#include "sim_conf.hh"
#include "matrix.hh"
#include "gettime.hh"
namespace {
class CLenv_t {
private:
std::vector<cl::Platform> m_platforms;
std::vector<cl::Device> m_devices;
cl::Context m_context;
cl::CommandQueue m_command_queue;
public:
CLenv_t( void ) {
cl::Platform::get(&m_platforms);
m_platforms[0].getDevices(CL_DEVICE_TYPE_DEFAULT, &m_devices);
m_context = cl::Context(m_devices[0]);
m_command_queue = cl::CommandQueue(m_context, m_devices[0], 0);
}
inline cl::Context & context( void ) {
return m_context;
}
inline cl::CommandQueue & command_queue( void ) {
return m_command_queue;
}
inline cl::Platform & platform( void ) {
return m_platforms[0];
}
inline cl::Device & device( void ) {
return m_devices[0];
}
};
void
init_state(std::vector<FLOAT_t>& enths)
{
for (int i=0; i<(NX*NY*NZ); i+=1) {
enths[i] = T_melt * Cv_SUS304 + H_melt + 100.0;
}
}
inline size_t getFileSize(std::ifstream& file)
{
file.seekg(0, std::ios::end);
size_t ret = file.tellg();
file.seekg(0, std::ios::beg);
return ret;
}
inline void loadFile(std::ifstream& file, std::vector<char>& d, size_t size)
{
d.resize(size);
file.read(reinterpret_cast<char*>(d.data()), size);
}
cl::Program createProgram(cl::Context& context, const std::vector<cl::Device>& devices, const std::string& filename)
{
std::ifstream file;
file.open(filename, std::ios::in | std::ios::binary);
if (file.fail()) {
throw "can not open kernel file";
}
size_t filesize = getFileSize(file);
std::vector<char> binary_data;
loadFile(file, binary_data, filesize);
cl::Program::Binaries binaries;
binaries.push_back(std::make_pair(&binary_data[0], filesize));
return cl::Program(context, devices, binaries, nullptr, nullptr);
}
cl::Program createProgram(cl::Context& context, const cl::Device& device, const std::string& filename)
{
std::vector<cl::Device> devices { device };
return createProgram(context, devices, filename);
}
void
output_temperature(int k, const std::vector<uint8_t>& pixels)
{
char buf[128];
std::ofstream file;
std::snprintf(buf, 128, "result/%05d.pnm", k);
file.open(buf, std::ios::out | std::ios::binary);
file << "P6" << std::endl;
file << NX << " " << NY << std::endl;
file << "255" << std::endl;
file.write((char *)&(pixels[0]), NX*NY*3);
file.close( );
}
void calc_differential(CLenv_t & clenv, size_t num, SparseMatrix_t & mtx,
std::vector<FLOAT_t>& enths,
std::vector<int>& perm_fwd,
std::vector<int>& perm_rev,
int nsteps)
{
try {
std::vector<uint8_t> pixels(NX*NY*3);
auto & context = clenv.context( );
auto & device = clenv.device( );
auto & command_queue = clenv.command_queue( );
// Create Program.
// Load compiled binary file and create cl::Program object.
auto program = createProgram(clenv.context( ), clenv.device( ), "kernel/kernel.pz");
// Create Kernel.
// Give kernel name without pzc_ prefix.
auto kernel0 = cl::Kernel(program, "calcDiffuse");
auto kernel1 = cl::Kernel(program, "enth2temp");
auto kernel2 = cl::Kernel(program, "extractrgb");
// Create Buffers.
auto device_rowptr = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(int) * (num+1));
auto device_idxs = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(int) * num * 8);
auto device_rows = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(FLOAT_t) * num * 8);
auto device_enths = cl::Buffer(context, CL_MEM_READ_WRITE, sizeof(FLOAT_t) * num);
auto device_temps = cl::Buffer(context, CL_MEM_READ_WRITE, sizeof(FLOAT_t) * num);
auto device_perm_fwd = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(int) * num);
auto device_perm_rev = cl::Buffer(context, CL_MEM_READ_ONLY, sizeof(int) * num);
auto device_pixels = cl::Buffer(context, CL_MEM_READ_WRITE, sizeof(uint8_t) * NX * NY * 3);
// Send src.
command_queue.enqueueWriteBuffer(device_rowptr , true, 0, sizeof(int) * (num + 1), &(mtx.m_rowptr[0]));
command_queue.enqueueWriteBuffer(device_idxs , true, 0, sizeof(int) * num * 8, &(mtx.m_idxs[0]));
command_queue.enqueueWriteBuffer(device_rows , true, 0, sizeof(FLOAT_t) * num * 8, &(mtx.m_elems[0]));
command_queue.enqueueWriteBuffer(device_enths , true, 0, sizeof(FLOAT_t) * num, &enths[0]);
command_queue.enqueueWriteBuffer(device_perm_fwd, true, 0, sizeof(int) * num, &(perm_fwd[0]));
command_queue.enqueueWriteBuffer(device_perm_rev, true, 0, sizeof(int) * num, &(perm_rev[0]));
// Set kernel args.
kernel0.setArg(0, num);
kernel0.setArg(1, device_enths);
kernel0.setArg(2, device_temps);
kernel0.setArg(3, device_rowptr);
kernel0.setArg(4, device_idxs);
kernel0.setArg(5, device_rows);
kernel0.setArg(6, device_perm_fwd);
kernel1.setArg(0, num);
kernel1.setArg(1, device_temps);
kernel1.setArg(2, device_enths);
kernel2.setArg(0, (size_t)NX*NY);
kernel2.setArg(1, (int)8);
kernel2.setArg(2, device_pixels);
kernel2.setArg(3, device_enths);
kernel2.setArg(4, device_perm_rev);
// Get workitem size.
// sc1-64: 8192 (1024 PEs * 8 threads)
// sc2 : 15782 (1984 PEs * 8 threads)
size_t global_work_size = 0;
{
std::string device_name;
device.getInfo(CL_DEVICE_NAME, &device_name);
size_t global_work_size_[3] = { 0 };
device.getInfo(CL_DEVICE_MAX_WORK_ITEM_SIZES, &global_work_size_);
global_work_size = global_work_size_[0];
if (device_name.find("PEZY-SC2") != std::string::npos) {
global_work_size = std::min(global_work_size, (size_t)15872);
}
std::cout << "Use device : " << device_name << std::endl;
std::cout << "workitem : " << global_work_size << std::endl;
}
// Run device kernel.
// Enthalpy to temperature
command_queue.enqueueNDRangeKernel(kernel1, cl::NullRange, cl::NDRange(global_work_size), cl::NullRange, nullptr, nullptr);
// Convert enthalpy to RGB
command_queue.enqueueNDRangeKernel(kernel2, cl::NullRange, cl::NDRange(global_work_size), cl::NullRange, nullptr, nullptr);
// Get temperature map as an image.
command_queue.enqueueReadBuffer(device_pixels, true, 0, sizeof(uint8_t) * NX*NY*3, &pixels[0]);
for (int k=0; k<nsteps; k+=1) {
for (int i=0; i<96; i+=1) {
// Calculate diffusion
command_queue.enqueueNDRangeKernel(kernel0, cl::NullRange, cl::NDRange(global_work_size), cl::NullRange, nullptr, nullptr);
// Enthalpy to temperature
command_queue.enqueueNDRangeKernel(kernel1, cl::NullRange, cl::NDRange(global_work_size), cl::NullRange, nullptr, nullptr);
}
// Convert enthalpy to RGB
command_queue.enqueueNDRangeKernel(kernel2, cl::NullRange, cl::NDRange(global_work_size), cl::NullRange, nullptr, nullptr);
output_temperature(k, pixels);
// Get temperature map as an image.
command_queue.enqueueReadBuffer(device_pixels, true, 0, sizeof(uint8_t) * NX*NY*3, &pixels[0]);
}
// Finish all commands.
command_queue.flush();
command_queue.finish();
output_temperature(nsteps, pixels);
} catch (const cl::Error& e) {
std::stringstream msg;
msg << "CL Error : " << e.what() << " " << e.err();
throw std::runtime_error(msg.str());
}
}
}
int main(int argc, char** argv)
{
size_t num = NX*NY*NZ;
std::cout << "int: " << sizeof(int) << std::endl;
std::cout << "cl_int: " << sizeof(cl_int) << std::endl;
std::cout << "num " << num << std::endl;
std::vector<FLOAT_t> enths(num);
std::vector<int> rowptr(num+1);
std::vector<int> idxs(num*7);
std::vector<FLOAT_t> rows(num*7);
std::vector<int> perm_c(num, 0);
std::vector<int> perm_r(num, 0);
auto mtx = SparseMatrix_t(rowptr, idxs, rows);
double t0 = gettime( );
{
std::vector<int> tmp_rowptr(num+1);
std::vector<int> tmp_idxs(num*7);
std::vector<FLOAT_t> tmp_rows(num*7);
auto tmp_mtx = SparseMatrix_t(tmp_rowptr, tmp_idxs, tmp_rows);
init_differential_matrix(tmp_mtx);
matrix_reorder_CuthillMckee(mtx, tmp_mtx, perm_c, perm_r);
}
init_state(enths);
double t1 = gettime( );
std::cout << "Elapsed time: " << (t1 - t0) << " sec." << std::endl;
// run device add
try {
auto clenv = CLenv_t( );
calc_differential(clenv, num, mtx, enths, perm_c, perm_r, 2048);
} catch (const cl::Error& e) {
std::stringstream msg;
msg << "CL Error : " << e.what() << " " << e.err();
throw std::runtime_error(msg.str());
}
double t2 = gettime( );
std::cout << "Elapsed time: " << (t2 - t1) << " sec." << std::endl;
return 0;
}
// Local Variables:
// indent-tabs-mode: nil
// End:
| 32.122517 | 139 | 0.608082 | naohaq |
adfd79ba9cd318052834c7a076229dd164210e01 | 3,386 | cpp | C++ | Problemas/Problemas de programacion dinamica/Atravesar_Cuadracity/Solucion/Atravesar_Cuadracity_OPT.cpp | AlexCabezas2018/Algoritmia | 12b2b20168e598852ac66e01a6004a0701cf9c95 | [
"MIT"
] | 4 | 2019-01-26T11:14:14.000Z | 2019-10-28T19:16:12.000Z | Problemas/Problemas de programacion dinamica/Atravesar_Cuadracity/Solucion/Atravesar_Cuadracity_OPT.cpp | AlexCabezas2018/Algoritmia | 12b2b20168e598852ac66e01a6004a0701cf9c95 | [
"MIT"
] | null | null | null | Problemas/Problemas de programacion dinamica/Atravesar_Cuadracity/Solucion/Atravesar_Cuadracity_OPT.cpp | AlexCabezas2018/Algoritmia | 12b2b20168e598852ac66e01a6004a0701cf9c95 | [
"MIT"
] | 1 | 2019-10-28T23:21:16.000Z | 2019-10-28T23:21:16.000Z | // Alejandro Cabezas Garriguez
// TAIS26
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
/*
El problema consiste en encontrar el numero de caminos que logran llevar desde el punto de inicio
que se encuentra en la esquina superior izquierda, al final que se encuentra en el otro extremo.
Como no encontramos una estrategia voraz, optaremos por explorar todo el arbol de opciones.
Para optimizar costes en espacio adicional, hemos decidido usar programacion dinamica.
Llamaremos camino(i, j) al numero de caminos que hay desde el inicio hasta la posicion i y j del
mapa. En cada paso, decidimos qué camino escoger dependiendo de la casilla en la que nos encontremos
en cada situacion.
Diferenciaremos dos situaciones: si encontramos un pasadizo o no. Por tanto, tenemos que:
camino(i, j) = 0 si mapa[i][j] = "PASADIZO"
Si por el contrario, no nos encontramos sobre un pasadizo, entonces el numero de caminos que hay
en dicha posicion son, tanto los que vienen de encima suya como los que viene de su izquierda. Por tanto:
camino(i, j) = camino(i, j - 1) + camino(i - 1, j) si mapa[i][j] != "PASADIZO"
El unico caso base que necesitamos es que el numero de caminos que hay es 1, por tanto camino(0, 1) = 1.
---VERSION SIN OPTIMIZAR---
Para este caso, optaremos por una matriz de tamaño (M + 1) * (N + 1) con M y N dados. Recorreremos entera
dicha matriz, rellenandola como es debido (y siguiendo las ecuaciones antes descritas).
-La complejidad, por tanto, del algoritmo que resuelve el problema es, en terminos de complejidad
en tiempo, O(M * N) donde N el el numero de manzanas de norte a sur y M las de este a oeste.
-La complejidad en espacio adicional es del orden de O(M * N) tambien.
---VERSION OPTIMIZADA---
En este caso, optamos por un vector de tamaño M + 1, y observar el mapa de la misma forma. En este caso, la comple
jidad del algoritmo en tiempo es la misma, pero es espacio adicional es solo O(M), con M descrito anteriormente.
*/
// función que resuelve el problema
int max_paths(const std::vector<std::string> &mapa) {
int N = mapa.size();
int M = mapa[0].size();
std::vector<int> vector(M + 1, 0);
vector[1] = 1;
for (int i = 1; i <= N; i++){
for (int j = 1; j <= M; j++){
if (mapa[i - 1][j - 1] != 'P'){
vector[j] = vector[j] + vector[j - 1];
}
else vector[j] = 0;
}
}
return vector[M];
}
// Resuelve un caso de prueba, leyendo de la entrada la
// configuración, y escribiendo la respuesta
bool resuelveCaso() {
// leer los datos de la entrada
int N, M;
std::cin >> N >> M;
if (! std::cin)
return false;
std::vector<std::string> mapa;
for (int i = 0; i < N; i++){
std::string aux;
std::cin >> aux;
mapa.push_back(aux);
}
std::cout << max_paths(mapa) << "\n";
return true;
}
int main() {
// Para la entrada por fichero.
// Comentar para acepta el reto
#ifndef DOMJUDGE
std::ifstream in("datos.txt");
auto cinbuf = std::cin.rdbuf(in.rdbuf()); //save old buf and redirect std::cin to casos.txt
#endif
while (resuelveCaso())
;
// Para restablecer entrada. Comentar para acepta el reto
#ifndef DOMJUDGE // para dejar todo como estaba al principio
std::cin.rdbuf(cinbuf);
system("PAUSE");
#endif
return 0;
} | 32.247619 | 115 | 0.676019 | AlexCabezas2018 |
bc0634f0d6a1b93ce95416974212c5e847037331 | 1,647 | cpp | C++ | os/arch/i386/gdt.cpp | akiszka/anthrax-os | 2d7f1e88041b4f381240fdcd4b7888eada393738 | [
"MIT"
] | null | null | null | os/arch/i386/gdt.cpp | akiszka/anthrax-os | 2d7f1e88041b4f381240fdcd4b7888eada393738 | [
"MIT"
] | null | null | null | os/arch/i386/gdt.cpp | akiszka/anthrax-os | 2d7f1e88041b4f381240fdcd4b7888eada393738 | [
"MIT"
] | null | null | null | #include <string.hpp>
#include <stdio.hpp>
#include "gdt.hpp"
struct gdt::descriptor _gdt [gdt::MAX_DESCRIPTORS];
struct gdt::gdtr _gdtr;
void gdt::set_descriptor(u16 i, u32 base, u32 limit, u8 access, u8 flags) {
if (i > MAX_DESCRIPTORS)
return;
// null out the descriptor
memset ((void*)&_gdt[i], 0, sizeof (struct descriptor));
// set limit and base addresses
_gdt[i].baseLo = base & 0xffff;
_gdt[i].baseMid = (base >> 16) & 0xff;
_gdt[i].baseHi = (base >> 24) & 0xff;
_gdt[i].limitLo = limit & 0xffff;
// set flags and grandularity bytes
_gdt[i].access = access;
_gdt[i].limitHi_flags = (limit >> 16) & 0x0f;
_gdt[i].limitHi_flags |= (flags & 0x0f) << 4;
}
void gdt::initialize() {
_gdtr.m_limit = (sizeof (struct descriptor) * MAX_DESCRIPTORS)-1;
_gdtr.m_base = (u32)(address) _gdt;
debug_printf("GDTR limit: 0x%x base: 0x%x\n", _gdtr.m_limit, _gdtr.m_base);
set_descriptor(0, 0, 0, 0, 0); // null descriptor
set_descriptor(1, 0, 0xffffffff,
ACCESS_RW | ACCESS_DC | ACCESS_Ex | ACCESS_S | ACCESS_Present,
FLAG_32_BIT | FLAG_4_KiB_LIMIT); // code descriptor
set_descriptor(2, 0, 0xffffffff,
ACCESS_RW | ACCESS_S | ACCESS_Present,
FLAG_4_KiB_LIMIT | FLAG_32_BIT); // data descriptor
install();
}
__attribute__ ((optimize("O0"))) // I think I found a bug in GCC and this fixes it.
void gdt::install() {
asm volatile (
"lgdt _gdtr;" // load the GDT
"mov %0, %%ds;" // load data segments
"mov %0, %%es;"
"mov %0, %%fs;"
"mov %0, %%gs;"
"mov %0, %%ss;"
"ljmp %1, $reload_cs;" // load code segment
"reload_cs:"
:
: "r"(get_selector(2, 0)),
"i"(get_selector(1, 0))
);
}
| 27 | 83 | 0.649666 | akiszka |
bc0726d090d95743a93a458774f400b7d2276d54 | 2,064 | hpp | C++ | Source/opennwa/details/Configuration.hpp | jusito/WALi-OpenNWA | 2bb4aca02c5a5d444fd038e8aa3eecd7d1ccbb99 | [
"MIT"
] | 15 | 2015-03-07T17:25:57.000Z | 2022-02-04T20:17:00.000Z | src/wpds/Source/opennwa/details/Configuration.hpp | ucd-plse/mpi-error-prop | 4367df88bcdc4d82c9a65b181d0e639d04962503 | [
"BSD-3-Clause"
] | 1 | 2018-03-03T05:58:55.000Z | 2018-03-03T12:26:10.000Z | src/wpds/Source/opennwa/details/Configuration.hpp | ucd-plse/mpi-error-prop | 4367df88bcdc4d82c9a65b181d0e639d04962503 | [
"BSD-3-Clause"
] | 15 | 2015-09-25T17:44:35.000Z | 2021-07-18T18:25:38.000Z | #ifndef wali_nwa_CONFIGURATION_HPP
#define wali_nwa_CONFIGURATION_HPP
#include "opennwa/NwaFwd.hpp"
#include <ios>
#include <vector>
namespace opennwa
{
namespace details
{
struct Configuration {
State state;
std::vector<State> callPredecessors;
Configuration(State s) : state(s) {}
Configuration(Configuration const & c)
: state(c.state)
, callPredecessors(c.callPredecessors) {}
bool operator< (Configuration const & other) const {
if (state < other.state) return true;
if (state > other.state) return false;
if (callPredecessors.size() < other.callPredecessors.size()) return true;
if (callPredecessors.size() > other.callPredecessors.size()) return false;
// Iterate in parallel over the two callPredecessors
for (std::vector<State>::const_iterator i = callPredecessors.begin(), j = other.callPredecessors.begin();
i!=callPredecessors.end(); ++i, ++j)
{
assert (j!=other.callPredecessors.end());
if (*i < *j) return true;
if (*i > *j) return false;
}
return false;
}
bool operator== (Configuration const & other) const {
// If neither A < B nor B < A, then A == B
return !(*this < other || other < *this);
}
};
inline
std::ostream &
operator << (std::ostream & os, Configuration const & configuration)
{
os << wali::key2str(configuration.state) << " [";
for (size_t i=0; i<configuration.callPredecessors.size(); ++i) {
os << wali::key2str(configuration.callPredecessors[i]) << " ";
}
os << "]";
return os;
}
}
}
#endif
| 32.25 | 121 | 0.492248 | jusito |
bc07c94749494a504e4323ca678a90a6227c25d9 | 503 | cpp | C++ | HackerRank/November/WeekOfCode1/ArmyGame.cpp | seeva92/Competitive-Programming | 69061c5409bb806148616fe7d86543e94bf76edd | [
"Apache-2.0"
] | null | null | null | HackerRank/November/WeekOfCode1/ArmyGame.cpp | seeva92/Competitive-Programming | 69061c5409bb806148616fe7d86543e94bf76edd | [
"Apache-2.0"
] | null | null | null | HackerRank/November/WeekOfCode1/ArmyGame.cpp | seeva92/Competitive-Programming | 69061c5409bb806148616fe7d86543e94bf76edd | [
"Apache-2.0"
] | null | null | null | #include <bits/stdc++.h>
typedef long long ll;
const int mod = 1e9 + 7;
const int MAX = 1e5 + 7;
using namespace std;
typedef vector<int> vi;
int n, m;
int main() {
#ifndef ONLINE_JUDGE
freopen("/Users/seeva92/Workspace/Contests/1.txt", "r", stdin);
freopen("/Users/seeva92/Workspace/Contests/2.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
int cnt = 0;
int i, j;
for (i = 0; i < n; i += 2) {
for (j = 0; j < m; j += 2) {
cnt++;
}
}
cout << cnt;
}
| 19.346154 | 65 | 0.59841 | seeva92 |
bc0e84aca9c719b8018288132238535ebbd65f30 | 1,424 | cpp | C++ | message-broker/src/user-cache.cpp | Spheniscida/cHaTTP | 6f8cdb2a466bc83af5e0e0e8ddd764aba6ff6747 | [
"MIT"
] | 4 | 2015-03-14T10:17:31.000Z | 2020-08-08T17:53:54.000Z | message-broker/src/user-cache.cpp | Spheniscida/cHaTTP | 6f8cdb2a466bc83af5e0e0e8ddd764aba6ff6747 | [
"MIT"
] | null | null | null | message-broker/src/user-cache.cpp | Spheniscida/cHaTTP | 6f8cdb2a466bc83af5e0e0e8ddd764aba6ff6747 | [
"MIT"
] | 2 | 2016-04-08T15:56:06.000Z | 2018-12-08T21:03:50.000Z | # include "user-cache.hpp"
# include "error.hpp"
void UserCache::addForUser(const std::string& user_name, const chattp::PersistenceResponse::UserLocation& loc)
{
if ( global_broker_settings.getClusteredMode() )
return;
lock_guard<mutex> lock(map_mutex);
if ( debugging_mode )
debug_log("Added user location: ",loc.DebugString());
(cache[user_name]).push_back(loc);
}
void UserCache::removeForUser(const std::string& user_name, const std::string& channel_id)
{
if ( global_broker_settings.getClusteredMode() )
return;
lock_guard<mutex> lock(map_mutex);
std::list<chattp::PersistenceResponse::UserLocation>& locs = cache[user_name];
if ( debugging_mode )
debug_log("Removed user_location: ", channel_id);
locs.remove_if([&channel_id](const chattp::PersistenceResponse::UserLocation& loc) -> bool { return loc.channel_id() == channel_id; });
}
void UserCache::clearForUser(const string& user_name)
{
if ( global_broker_settings.getClusteredMode() )
return;
lock_guard<mutex> lock(map_mutex);
(cache[user_name]).clear();
}
const std::list<chattp::PersistenceResponse::UserLocation>& UserCache::getLocations(const string& user_name)
{
if ( global_broker_settings.getClusteredMode() )
return empty_list;
lock_guard<mutex> lock(map_mutex);
return cache[user_name];
}
const std::list<chattp::PersistenceResponse::UserLocation> UserCache::empty_list;
| 26.867925 | 139 | 0.734551 | Spheniscida |
bc153dedf9c9b8c6c95512f5d2b97654370fdac0 | 200,671 | inl | C++ | 2d_samples/pmj02_175.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | 1 | 2021-12-10T23:35:04.000Z | 2021-12-10T23:35:04.000Z | 2d_samples/pmj02_175.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | 2d_samples/pmj02_175.inl | st-ario/rayme | 315c57c23f4aa4934a8a80e84e3243acd3400808 | [
"MIT"
] | null | null | null | {std::array<float,2>{0.929466844f, 0.574518383f},
std::array<float,2>{0.479066133f, 0.436022788f},
std::array<float,2>{0.140452042f, 0.855014622f},
std::array<float,2>{0.690937757f, 0.108673006f},
std::array<float,2>{0.548150361f, 0.988475919f},
std::array<float,2>{0.00603156351f, 0.245992929f},
std::array<float,2>{0.34466508f, 0.736628652f},
std::array<float,2>{0.751968563f, 0.364232242f},
std::array<float,2>{0.869360149f, 0.750667632f},
std::array<float,2>{0.282423884f, 0.00839261897f},
std::array<float,2>{0.0814579129f, 0.542701423f},
std::array<float,2>{0.592356265f, 0.444277197f},
std::array<float,2>{0.628381968f, 0.627461731f},
std::array<float,2>{0.211145774f, 0.297217488f},
std::array<float,2>{0.4295398f, 0.935462236f},
std::array<float,2>{0.937627256f, 0.146352753f},
std::array<float,2>{0.810775995f, 0.705770314f},
std::array<float,2>{0.332807124f, 0.31615001f},
std::array<float,2>{0.0417302772f, 0.953335166f},
std::array<float,2>{0.512212932f, 0.207331061f},
std::array<float,2>{0.732230246f, 0.829333305f},
std::array<float,2>{0.171270981f, 0.0842502117f},
std::array<float,2>{0.463222146f, 0.61973244f},
std::array<float,2>{0.896907389f, 0.389922351f},
std::array<float,2>{0.98271656f, 0.897273958f},
std::array<float,2>{0.39114666f, 0.186071575f},
std::array<float,2>{0.22687532f, 0.673737645f},
std::array<float,2>{0.66403091f, 0.262155294f},
std::array<float,2>{0.619683444f, 0.501490116f},
std::array<float,2>{0.115017541f, 0.490452021f},
std::array<float,2>{0.25924167f, 0.801279783f},
std::array<float,2>{0.813785851f, 0.0422002785f},
std::array<float,2>{0.959760904f, 0.658106506f},
std::array<float,2>{0.408123314f, 0.271730244f},
std::array<float,2>{0.193046033f, 0.876278937f},
std::array<float,2>{0.655027628f, 0.171570182f},
std::array<float,2>{0.572845638f, 0.789667964f},
std::array<float,2>{0.066521503f, 0.0502549447f},
std::array<float,2>{0.29979676f, 0.518868983f},
std::array<float,2>{0.848829448f, 0.46949932f},
std::array<float,2>{0.771367908f, 0.948783755f},
std::array<float,2>{0.374224514f, 0.198126897f},
std::array<float,2>{0.0299607553f, 0.693675101f},
std::array<float,2>{0.545457423f, 0.334505677f},
std::array<float,2>{0.705129147f, 0.602302611f},
std::array<float,2>{0.143651068f, 0.395256072f},
std::array<float,2>{0.498765558f, 0.816657245f},
std::array<float,2>{0.914097011f, 0.0654440448f},
std::array<float,2>{0.831001401f, 0.55098325f},
std::array<float,2>{0.270122737f, 0.460673481f},
std::array<float,2>{0.0986383334f, 0.76654762f},
std::array<float,2>{0.60349822f, 0.0164989065f},
std::array<float,2>{0.684608996f, 0.914136291f},
std::array<float,2>{0.245375127f, 0.127485737f},
std::array<float,2>{0.376963496f, 0.645442247f},
std::array<float,2>{0.985414743f, 0.285010368f},
std::array<float,2>{0.888480425f, 0.864561558f},
std::array<float,2>{0.441440076f, 0.11074359f},
std::array<float,2>{0.17706345f, 0.592335165f},
std::array<float,2>{0.749337018f, 0.415147007f},
std::array<float,2>{0.52904135f, 0.734309196f},
std::array<float,2>{0.0479453467f, 0.357092083f},
std::array<float,2>{0.317393243f, 0.977313399f},
std::array<float,2>{0.793122232f, 0.225057766f},
std::array<float,2>{0.998836517f, 0.52958858f},
std::array<float,2>{0.385498494f, 0.483433366f},
std::array<float,2>{0.237190261f, 0.785164475f},
std::array<float,2>{0.672953784f, 0.0624843277f},
std::array<float,2>{0.596904218f, 0.890322983f},
std::array<float,2>{0.102108084f, 0.160099253f},
std::array<float,2>{0.275475502f, 0.666562855f},
std::array<float,2>{0.837570786f, 0.278854191f},
std::array<float,2>{0.783174634f, 0.823642552f},
std::array<float,2>{0.321864665f, 0.0719391555f},
std::array<float,2>{0.0557281338f, 0.598903298f},
std::array<float,2>{0.518246353f, 0.398844868f},
std::array<float,2>{0.73464334f, 0.700819433f},
std::array<float,2>{0.186672509f, 0.343578905f},
std::array<float,2>{0.450057566f, 0.944709599f},
std::array<float,2>{0.881575882f, 0.188494951f},
std::array<float,2>{0.852597177f, 0.655292988f},
std::array<float,2>{0.305640906f, 0.290644228f},
std::array<float,2>{0.0754636228f, 0.908709466f},
std::array<float,2>{0.567386031f, 0.13537173f},
std::array<float,2>{0.646945536f, 0.780225217f},
std::array<float,2>{0.198811203f, 0.0257415101f},
std::array<float,2>{0.415467858f, 0.561006725f},
std::array<float,2>{0.962009251f, 0.46305263f},
std::array<float,2>{0.911762178f, 0.973268092f},
std::array<float,2>{0.488764465f, 0.23261261f},
std::array<float,2>{0.155212805f, 0.722879887f},
std::array<float,2>{0.71675849f, 0.348632514f},
std::array<float,2>{0.535300791f, 0.579272807f},
std::array<float,2>{0.0222256109f, 0.41151467f},
std::array<float,2>{0.367013991f, 0.871798098f},
std::array<float,2>{0.779333591f, 0.120753661f},
std::array<float,2>{0.905841112f, 0.747946203f},
std::array<float,2>{0.457847029f, 0.368862778f},
std::array<float,2>{0.160090238f, 0.992265522f},
std::array<float,2>{0.719182253f, 0.239255354f},
std::array<float,2>{0.507162631f, 0.84395957f},
std::array<float,2>{0.0313621871f, 0.10010238f},
std::array<float,2>{0.343025863f, 0.565964818f},
std::array<float,2>{0.8005867f, 0.42792058f},
std::array<float,2>{0.822090507f, 0.922738969f},
std::array<float,2>{0.25460574f, 0.15318954f},
std::array<float,2>{0.121747024f, 0.638301015f},
std::array<float,2>{0.61215663f, 0.308206022f},
std::array<float,2>{0.669694543f, 0.53357774f},
std::array<float,2>{0.218771115f, 0.445718884f},
std::array<float,2>{0.402121782f, 0.762152374f},
std::array<float,2>{0.970943332f, 0.00211181818f},
std::array<float,2>{0.764490843f, 0.615941703f},
std::array<float,2>{0.356754601f, 0.376470715f},
std::array<float,2>{0.00808554981f, 0.843055844f},
std::array<float,2>{0.557314098f, 0.0862264484f},
std::array<float,2>{0.697469056f, 0.962242365f},
std::array<float,2>{0.126013488f, 0.211979046f},
std::array<float,2>{0.469832003f, 0.715384066f},
std::array<float,2>{0.935886443f, 0.32420069f},
std::array<float,2>{0.950611532f, 0.809175372f},
std::array<float,2>{0.433338702f, 0.0363239273f},
std::array<float,2>{0.204258487f, 0.513459682f},
std::array<float,2>{0.637426019f, 0.497681797f},
std::array<float,2>{0.580833435f, 0.687412024f},
std::array<float,2>{0.0892892182f, 0.257799506f},
std::array<float,2>{0.295521855f, 0.899753392f},
std::array<float,2>{0.862325907f, 0.177813128f},
std::array<float,2>{0.942328095f, 0.597524464f},
std::array<float,2>{0.421884865f, 0.406199366f},
std::array<float,2>{0.215415627f, 0.828119814f},
std::array<float,2>{0.632180572f, 0.0744195357f},
std::array<float,2>{0.587067008f, 0.93965286f},
std::array<float,2>{0.0836306959f, 0.192673206f},
std::array<float,2>{0.285188109f, 0.697688639f},
std::array<float,2>{0.873361766f, 0.339499444f},
std::array<float,2>{0.756551683f, 0.782699943f},
std::array<float,2>{0.350323141f, 0.0564880632f},
std::array<float,2>{0.00366148097f, 0.524523556f},
std::array<float,2>{0.553996623f, 0.477777094f},
std::array<float,2>{0.692856312f, 0.668003857f},
std::array<float,2>{0.136082947f, 0.274089783f},
std::array<float,2>{0.481194437f, 0.884543538f},
std::array<float,2>{0.925643504f, 0.160713643f},
std::array<float,2>{0.818667293f, 0.721041322f},
std::array<float,2>{0.263286233f, 0.343881845f},
std::array<float,2>{0.11174047f, 0.972144127f},
std::array<float,2>{0.622800589f, 0.227007553f},
std::array<float,2>{0.658161163f, 0.869334698f},
std::array<float,2>{0.233297169f, 0.121595755f},
std::array<float,2>{0.397136182f, 0.582903862f},
std::array<float,2>{0.978661299f, 0.407636821f},
std::array<float,2>{0.891026497f, 0.912169099f},
std::array<float,2>{0.46716404f, 0.138331175f},
std::array<float,2>{0.167842239f, 0.648911476f},
std::array<float,2>{0.727963865f, 0.296725363f},
std::array<float,2>{0.510900974f, 0.556502342f},
std::array<float,2>{0.0443623178f, 0.468130708f},
std::array<float,2>{0.328857332f, 0.776198924f},
std::array<float,2>{0.807740986f, 0.0277723819f},
std::array<float,2>{0.918701172f, 0.633904696f},
std::array<float,2>{0.495266825f, 0.309515357f},
std::array<float,2>{0.146733567f, 0.927019179f},
std::array<float,2>{0.710497499f, 0.149580091f},
std::array<float,2>{0.539064169f, 0.757981062f},
std::array<float,2>{0.0244071838f, 0.00521459989f},
std::array<float,2>{0.371008724f, 0.537816107f},
std::array<float,2>{0.767200112f, 0.451406926f},
std::array<float,2>{0.847645581f, 0.999363542f},
std::array<float,2>{0.30094704f, 0.23727347f},
std::array<float,2>{0.0632653832f, 0.746060669f},
std::array<float,2>{0.575406075f, 0.372272611f},
std::array<float,2>{0.649019837f, 0.567308009f},
std::array<float,2>{0.18889451f, 0.423061073f},
std::array<float,2>{0.411359936f, 0.848110795f},
std::array<float,2>{0.955439866f, 0.0948966071f},
std::array<float,2>{0.789238274f, 0.50924468f},
std::array<float,2>{0.315992028f, 0.494220287f},
std::array<float,2>{0.0537115f, 0.806526899f},
std::array<float,2>{0.525175929f, 0.0345104225f},
std::array<float,2>{0.742193997f, 0.905535638f},
std::array<float,2>{0.174726874f, 0.174821272f},
std::array<float,2>{0.437584043f, 0.681441545f},
std::array<float,2>{0.884684324f, 0.252189755f},
std::array<float,2>{0.990512967f, 0.837955475f},
std::array<float,2>{0.382459164f, 0.0929687321f},
std::array<float,2>{0.246160582f, 0.61313051f},
std::array<float,2>{0.681080043f, 0.381151199f},
std::array<float,2>{0.608814001f, 0.713001728f},
std::array<float,2>{0.0969542488f, 0.325120836f},
std::array<float,2>{0.266322285f, 0.966487467f},
std::array<float,2>{0.832209527f, 0.215905055f},
std::array<float,2>{0.875406325f, 0.545811772f},
std::array<float,2>{0.44613108f, 0.438376546f},
std::array<float,2>{0.182437584f, 0.755452991f},
std::array<float,2>{0.741217256f, 0.0142855439f},
std::array<float,2>{0.52289629f, 0.932410657f},
std::array<float,2>{0.0605518818f, 0.144370049f},
std::array<float,2>{0.327391714f, 0.630521655f},
std::array<float,2>{0.786968291f, 0.301788896f},
std::array<float,2>{0.842862964f, 0.858619094f},
std::array<float,2>{0.277855903f, 0.102556266f},
std::array<float,2>{0.107175313f, 0.572954118f},
std::array<float,2>{0.597859442f, 0.430328161f},
std::array<float,2>{0.678884029f, 0.741199672f},
std::array<float,2>{0.239289448f, 0.360219091f},
std::array<float,2>{0.387420863f, 0.986517906f},
std::array<float,2>{0.993239224f, 0.249861136f},
std::array<float,2>{0.774028242f, 0.67736578f},
std::array<float,2>{0.359496236f, 0.259223133f},
std::array<float,2>{0.0187300202f, 0.891809404f},
std::array<float,2>{0.532207668f, 0.183223769f},
std::array<float,2>{0.714542508f, 0.800424874f},
std::array<float,2>{0.15000464f, 0.046012789f},
std::array<float,2>{0.487910002f, 0.504631162f},
std::array<float,2>{0.908177555f, 0.485497892f},
std::array<float,2>{0.96770674f, 0.959461927f},
std::array<float,2>{0.418014348f, 0.20418328f},
std::array<float,2>{0.202643856f, 0.710125148f},
std::array<float,2>{0.643942833f, 0.31777516f},
std::array<float,2>{0.56527096f, 0.62263757f},
std::array<float,2>{0.0710764378f, 0.385295719f},
std::array<float,2>{0.31079784f, 0.834095418f},
std::array<float,2>{0.858679414f, 0.0789663866f},
std::array<float,2>{0.976301789f, 0.691264987f},
std::array<float,2>{0.40397501f, 0.331833214f},
std::array<float,2>{0.223385751f, 0.951934397f},
std::array<float,2>{0.665750861f, 0.20073992f},
std::array<float,2>{0.616842508f, 0.813092947f},
std::array<float,2>{0.117877416f, 0.0668869466f},
std::array<float,2>{0.250003576f, 0.608779967f},
std::array<float,2>{0.827425718f, 0.393900692f},
std::array<float,2>{0.803279221f, 0.881734431f},
std::array<float,2>{0.336982071f, 0.166799858f},
std::array<float,2>{0.0385261215f, 0.66253531f},
std::array<float,2>{0.500222504f, 0.267517626f},
std::array<float,2>{0.726250648f, 0.520898521f},
std::array<float,2>{0.163897336f, 0.47497052f},
std::array<float,2>{0.455995262f, 0.794544339f},
std::array<float,2>{0.898515642f, 0.0543704256f},
std::array<float,2>{0.866197526f, 0.5884642f},
std::array<float,2>{0.289150506f, 0.418536663f},
std::array<float,2>{0.0928933844f, 0.861750782f},
std::array<float,2>{0.585890651f, 0.115852699f},
std::array<float,2>{0.633932769f, 0.982858062f},
std::array<float,2>{0.208591208f, 0.222469047f},
std::array<float,2>{0.436604142f, 0.728904188f},
std::array<float,2>{0.948055148f, 0.351669371f},
std::array<float,2>{0.929803848f, 0.770700574f},
std::array<float,2>{0.474954724f, 0.0217137747f},
std::array<float,2>{0.129916281f, 0.549469292f},
std::array<float,2>{0.701472759f, 0.454908729f},
std::array<float,2>{0.559551716f, 0.642682016f},
std::array<float,2>{0.0121155046f, 0.286989629f},
std::array<float,2>{0.354274392f, 0.918786287f},
std::array<float,2>{0.75978297f, 0.130992174f},
std::array<float,2>{0.89620924f, 0.61750406f},
std::array<float,2>{0.461602122f, 0.387072086f},
std::array<float,2>{0.168602243f, 0.83023864f},
std::array<float,2>{0.733778596f, 0.0825630352f},
std::array<float,2>{0.515238762f, 0.956582248f},
std::array<float,2>{0.0397481956f, 0.209366545f},
std::array<float,2>{0.334000885f, 0.704714656f},
std::array<float,2>{0.809857607f, 0.313373744f},
std::array<float,2>{0.815082788f, 0.803710103f},
std::array<float,2>{0.261154979f, 0.040191371f},
std::array<float,2>{0.1154119f, 0.502705991f},
std::array<float,2>{0.61888212f, 0.489595801f},
std::array<float,2>{0.66098386f, 0.675233603f},
std::array<float,2>{0.229150787f, 0.264416009f},
std::array<float,2>{0.393717736f, 0.896134198f},
std::array<float,2>{0.980780602f, 0.183666095f},
std::array<float,2>{0.750187635f, 0.734619439f},
std::array<float,2>{0.346260726f, 0.365843087f},
std::array<float,2>{0.00474468898f, 0.991490781f},
std::array<float,2>{0.549484074f, 0.242728323f},
std::array<float,2>{0.689049244f, 0.853391111f},
std::array<float,2>{0.138363793f, 0.106560647f},
std::array<float,2>{0.476903141f, 0.576879978f},
std::array<float,2>{0.926190197f, 0.433917284f},
std::array<float,2>{0.939857721f, 0.936558902f},
std::array<float,2>{0.42695123f, 0.146768987f},
std::array<float,2>{0.213727936f, 0.6268062f},
std::array<float,2>{0.625941098f, 0.299759299f},
std::array<float,2>{0.590930462f, 0.54044199f},
std::array<float,2>{0.0796966106f, 0.441993713f},
std::array<float,2>{0.28399092f, 0.752076924f},
std::array<float,2>{0.868551075f, 0.011318625f},
std::array<float,2>{0.987380385f, 0.647119105f},
std::array<float,2>{0.375827372f, 0.282849669f},
std::array<float,2>{0.242653549f, 0.917105615f},
std::array<float,2>{0.687453985f, 0.126665488f},
std::array<float,2>{0.60515821f, 0.768994093f},
std::array<float,2>{0.0997236148f, 0.0190149285f},
std::array<float,2>{0.271588862f, 0.553368568f},
std::array<float,2>{0.828199148f, 0.457774699f},
std::array<float,2>{0.795536458f, 0.978855073f},
std::array<float,2>{0.319344878f, 0.223131344f},
std::array<float,2>{0.0496637411f, 0.730801582f},
std::array<float,2>{0.530109406f, 0.35824737f},
std::array<float,2>{0.74802649f, 0.590786755f},
std::array<float,2>{0.178594723f, 0.41677168f},
std::array<float,2>{0.443480372f, 0.866423428f},
std::array<float,2>{0.889180303f, 0.112488329f},
std::array<float,2>{0.849664152f, 0.517424405f},
std::array<float,2>{0.298115999f, 0.472082466f},
std::array<float,2>{0.0687168539f, 0.792957485f},
std::array<float,2>{0.571813345f, 0.0483952649f},
std::array<float,2>{0.654036045f, 0.877524614f},
std::array<float,2>{0.194949061f, 0.169413745f},
std::array<float,2>{0.409597278f, 0.65929991f},
std::array<float,2>{0.957145274f, 0.269814432f},
std::array<float,2>{0.916864157f, 0.819542587f},
std::array<float,2>{0.496789426f, 0.0639763251f},
std::array<float,2>{0.14072077f, 0.603542626f},
std::array<float,2>{0.703950167f, 0.397998005f},
std::array<float,2>{0.544210196f, 0.691805303f},
std::array<float,2>{0.0282545481f, 0.333713889f},
std::array<float,2>{0.371854067f, 0.946230292f},
std::array<float,2>{0.772473097f, 0.196291059f},
std::array<float,2>{0.964547396f, 0.559725821f},
std::array<float,2>{0.416215599f, 0.461927623f},
std::array<float,2>{0.196725667f, 0.77917707f},
std::array<float,2>{0.645845652f, 0.0249865018f},
std::array<float,2>{0.568878055f, 0.907513857f},
std::array<float,2>{0.0776945278f, 0.134473324f},
std::array<float,2>{0.307695717f, 0.652916014f},
std::array<float,2>{0.854880929f, 0.291737735f},
std::array<float,2>{0.778931916f, 0.873761415f},
std::array<float,2>{0.364880681f, 0.118039854f},
std::array<float,2>{0.020371655f, 0.580769062f},
std::array<float,2>{0.538150609f, 0.412929475f},
std::array<float,2>{0.716966867f, 0.725252509f},
std::array<float,2>{0.154258996f, 0.349915087f},
std::array<float,2>{0.490279913f, 0.97498703f},
std::array<float,2>{0.912329376f, 0.231678203f},
std::array<float,2>{0.839493811f, 0.664140582f},
std::array<float,2>{0.274653405f, 0.280157775f},
std::array<float,2>{0.104081482f, 0.888114691f},
std::array<float,2>{0.594724417f, 0.157081783f},
std::array<float,2>{0.674259722f, 0.788730025f},
std::array<float,2>{0.234821647f, 0.0590560772f},
std::array<float,2>{0.384664387f, 0.528461814f},
std::array<float,2>{0.996182442f, 0.48219344f},
std::array<float,2>{0.880096734f, 0.942994654f},
std::array<float,2>{0.451999187f, 0.190421939f},
std::array<float,2>{0.183971047f, 0.702619791f},
std::array<float,2>{0.736484885f, 0.340111345f},
std::array<float,2>{0.515643775f, 0.600008547f},
std::array<float,2>{0.0580254048f, 0.401167691f},
std::array<float,2>{0.322546452f, 0.821143329f},
std::array<float,2>{0.783618331f, 0.0734525248f},
std::array<float,2>{0.935484171f, 0.717888057f},
std::array<float,2>{0.470718145f, 0.321804702f},
std::array<float,2>{0.12708424f, 0.963861227f},
std::array<float,2>{0.696021914f, 0.214734495f},
std::array<float,2>{0.555874884f, 0.840021253f},
std::array<float,2>{0.0100848898f, 0.0894972757f},
std::array<float,2>{0.358123034f, 0.614563465f},
std::array<float,2>{0.762151122f, 0.377951682f},
std::array<float,2>{0.861255646f, 0.901148379f},
std::array<float,2>{0.293371916f, 0.176777169f},
std::array<float,2>{0.0878408775f, 0.684339106f},
std::array<float,2>{0.579072595f, 0.255509287f},
std::array<float,2>{0.640124917f, 0.515569568f},
std::array<float,2>{0.20611304f, 0.498727083f},
std::array<float,2>{0.431418538f, 0.811465085f},
std::array<float,2>{0.95162636f, 0.0380455554f},
std::array<float,2>{0.797438085f, 0.563342333f},
std::array<float,2>{0.341071576f, 0.42717573f},
std::array<float,2>{0.0338670276f, 0.845710456f},
std::array<float,2>{0.504114449f, 0.099539198f},
std::array<float,2>{0.722199798f, 0.994810402f},
std::array<float,2>{0.157391563f, 0.240957245f},
std::array<float,2>{0.459478587f, 0.748808801f},
std::array<float,2>{0.90262568f, 0.370841652f},
std::array<float,2>{0.969241142f, 0.76533705f},
std::array<float,2>{0.399110556f, 0.000777708425f},
std::array<float,2>{0.221381292f, 0.532273233f},
std::array<float,2>{0.670171261f, 0.449035913f},
std::array<float,2>{0.611309946f, 0.640480518f},
std::array<float,2>{0.123612508f, 0.306092024f},
std::array<float,2>{0.256099492f, 0.924951136f},
std::array<float,2>{0.822993815f, 0.155888617f},
std::array<float,2>{0.977757752f, 0.584067166f},
std::array<float,2>{0.396030903f, 0.408390492f},
std::array<float,2>{0.231688425f, 0.868394732f},
std::array<float,2>{0.658556521f, 0.123447575f},
std::array<float,2>{0.624889016f, 0.968826711f},
std::array<float,2>{0.111144267f, 0.228565559f},
std::array<float,2>{0.264386892f, 0.72026974f},
std::array<float,2>{0.818076968f, 0.345903307f},
std::array<float,2>{0.805129766f, 0.773996711f},
std::array<float,2>{0.330492795f, 0.02957418f},
std::array<float,2>{0.0456507541f, 0.557429671f},
std::array<float,2>{0.507918298f, 0.466311514f},
std::array<float,2>{0.730377674f, 0.651467979f},
std::array<float,2>{0.165909693f, 0.293187022f},
std::array<float,2>{0.466074049f, 0.911183417f},
std::array<float,2>{0.893454134f, 0.140280709f},
std::array<float,2>{0.87132144f, 0.696279049f},
std::array<float,2>{0.287625313f, 0.337562144f},
std::array<float,2>{0.085487403f, 0.938966274f},
std::array<float,2>{0.589265049f, 0.193876684f},
std::array<float,2>{0.630350053f, 0.825909376f},
std::array<float,2>{0.217556015f, 0.0778623298f},
std::array<float,2>{0.424033433f, 0.594469786f},
std::array<float,2>{0.944975972f, 0.404236674f},
std::array<float,2>{0.922118962f, 0.885853827f},
std::array<float,2>{0.4840976f, 0.162443325f},
std::array<float,2>{0.133673698f, 0.670099199f},
std::array<float,2>{0.693491936f, 0.276552916f},
std::array<float,2>{0.552399218f, 0.525940537f},
std::array<float,2>{0.00100903516f, 0.478548259f},
std::array<float,2>{0.348312616f, 0.784273863f},
std::array<float,2>{0.755755603f, 0.0580482483f},
std::array<float,2>{0.885858834f, 0.682452083f},
std::array<float,2>{0.440300494f, 0.251742691f},
std::array<float,2>{0.172337949f, 0.903739095f},
std::array<float,2>{0.744395196f, 0.172619998f},
std::array<float,2>{0.527100325f, 0.807843089f},
std::array<float,2>{0.0508406721f, 0.0320671797f},
std::array<float,2>{0.313502848f, 0.510742009f},
std::array<float,2>{0.791801095f, 0.493545413f},
std::array<float,2>{0.834561646f, 0.967784464f},
std::array<float,2>{0.268971324f, 0.218228653f},
std::array<float,2>{0.0950775295f, 0.712036788f},
std::array<float,2>{0.60604471f, 0.326691955f},
std::array<float,2>{0.682690859f, 0.611178279f},
std::array<float,2>{0.249486566f, 0.379833549f},
std::array<float,2>{0.379677147f, 0.837474585f},
std::array<float,2>{0.989900351f, 0.090657264f},
std::array<float,2>{0.76906538f, 0.535996675f},
std::array<float,2>{0.3677423f, 0.45002836f},
std::array<float,2>{0.0264028087f, 0.761667132f},
std::array<float,2>{0.541902244f, 0.00765534444f},
std::array<float,2>{0.708435535f, 0.929608285f},
std::array<float,2>{0.14501068f, 0.150490507f},
std::array<float,2>{0.493535995f, 0.635368228f},
std::array<float,2>{0.919989109f, 0.310968757f},
std::array<float,2>{0.953687191f, 0.850503922f},
std::array<float,2>{0.412667453f, 0.0969670936f},
std::array<float,2>{0.190442026f, 0.569527924f},
std::array<float,2>{0.652168691f, 0.425534487f},
std::array<float,2>{0.576847136f, 0.743679106f},
std::array<float,2>{0.0660770312f, 0.374473214f},
std::array<float,2>{0.303955883f, 0.997191608f},
std::array<float,2>{0.843890667f, 0.236209542f},
std::array<float,2>{0.909176111f, 0.506096423f},
std::array<float,2>{0.484784007f, 0.487967461f},
std::array<float,2>{0.15163134f, 0.797269642f},
std::array<float,2>{0.712841392f, 0.0437473468f},
std::array<float,2>{0.534356773f, 0.893870473f},
std::array<float,2>{0.0157447252f, 0.179861039f},
std::array<float,2>{0.362076223f, 0.67914623f},
std::array<float,2>{0.776984572f, 0.261333376f},
std::array<float,2>{0.855998695f, 0.832970977f},
std::array<float,2>{0.310191691f, 0.0818673596f},
std::array<float,2>{0.0729660988f, 0.624521852f},
std::array<float,2>{0.562829971f, 0.383110732f},
std::array<float,2>{0.641777277f, 0.708757937f},
std::array<float,2>{0.200838283f, 0.319574147f},
std::array<float,2>{0.421547025f, 0.958389103f},
std::array<float,2>{0.965588272f, 0.20583345f},
std::array<float,2>{0.787658274f, 0.632296264f},
std::array<float,2>{0.324777901f, 0.303968012f},
std::array<float,2>{0.0602859035f, 0.930440962f},
std::array<float,2>{0.520099938f, 0.141951263f},
std::array<float,2>{0.739547372f, 0.756596148f},
std::array<float,2>{0.181255475f, 0.013252019f},
std::array<float,2>{0.448689193f, 0.544603884f},
std::array<float,2>{0.877718091f, 0.440162599f},
std::array<float,2>{0.995118141f, 0.985940516f},
std::array<float,2>{0.389463663f, 0.246378168f},
std::array<float,2>{0.241706997f, 0.739337027f},
std::array<float,2>{0.677111506f, 0.363254696f},
std::array<float,2>{0.600182295f, 0.570390046f},
std::array<float,2>{0.108168967f, 0.432798356f},
std::array<float,2>{0.280695111f, 0.855733454f},
std::array<float,2>{0.841599822f, 0.105063096f},
std::array<float,2>{0.947144687f, 0.726709366f},
std::array<float,2>{0.434331834f, 0.353616595f},
std::array<float,2>{0.209369272f, 0.98160243f},
std::array<float,2>{0.635073483f, 0.219807789f},
std::array<float,2>{0.582744956f, 0.860391557f},
std::array<float,2>{0.0916704088f, 0.114648722f},
std::array<float,2>{0.29224053f, 0.586190224f},
std::array<float,2>{0.864381671f, 0.420751065f},
std::array<float,2>{0.758973956f, 0.921147466f},
std::array<float,2>{0.352590114f, 0.129617855f},
std::array<float,2>{0.0149866696f, 0.642106175f},
std::array<float,2>{0.561576486f, 0.288270742f},
std::array<float,2>{0.699918747f, 0.547663271f},
std::array<float,2>{0.131979704f, 0.455602348f},
std::array<float,2>{0.473841518f, 0.7723822f},
std::array<float,2>{0.932727933f, 0.0209481046f},
std::array<float,2>{0.826077044f, 0.605791688f},
std::array<float,2>{0.252614915f, 0.391942084f},
std::array<float,2>{0.121061504f, 0.815766394f},
std::array<float,2>{0.614614725f, 0.0687253773f},
std::array<float,2>{0.666313708f, 0.949889541f},
std::array<float,2>{0.225465789f, 0.202351987f},
std::array<float,2>{0.404579014f, 0.689330339f},
std::array<float,2>{0.972897768f, 0.329544812f},
std::array<float,2>{0.900399983f, 0.796403229f},
std::array<float,2>{0.45463714f, 0.0517404415f},
std::array<float,2>{0.161760345f, 0.523179829f},
std::array<float,2>{0.72377646f, 0.473889083f},
std::array<float,2>{0.502956212f, 0.661717296f},
std::array<float,2>{0.0362727009f, 0.267837465f},
std::array<float,2>{0.339261264f, 0.880143702f},
std::array<float,2>{0.80241257f, 0.165690616f},
std::array<float,2>{0.915377676f, 0.604643524f},
std::array<float,2>{0.499952048f, 0.397231251f},
std::array<float,2>{0.143204167f, 0.819111943f},
std::array<float,2>{0.706447244f, 0.0625812188f},
std::array<float,2>{0.54628998f, 0.946366847f},
std::array<float,2>{0.0307631847f, 0.195410863f},
std::array<float,2>{0.373691916f, 0.692509472f},
std::array<float,2>{0.770129502f, 0.332541287f},
std::array<float,2>{0.847801745f, 0.791260779f},
std::array<float,2>{0.300391138f, 0.0469203852f},
std::array<float,2>{0.0676570535f, 0.516166151f},
std::array<float,2>{0.573951662f, 0.471620202f},
std::array<float,2>{0.655641019f, 0.659179628f},
std::array<float,2>{0.191975668f, 0.270767063f},
std::array<float,2>{0.406871289f, 0.878492057f},
std::array<float,2>{0.960005999f, 0.168796107f},
std::array<float,2>{0.794641614f, 0.732350051f},
std::array<float,2>{0.316944093f, 0.359064728f},
std::array<float,2>{0.0472218618f, 0.979646444f},
std::array<float,2>{0.528320014f, 0.223857284f},
std::array<float,2>{0.748523355f, 0.865935206f},
std::array<float,2>{0.175821453f, 0.111406863f},
std::array<float,2>{0.442643762f, 0.591117024f},
std::array<float,2>{0.887433887f, 0.417521417f},
std::array<float,2>{0.985175431f, 0.91672343f},
std::array<float,2>{0.378633767f, 0.125223294f},
std::array<float,2>{0.244786844f, 0.648233056f},
std::array<float,2>{0.684315503f, 0.282152086f},
std::array<float,2>{0.60195291f, 0.554056168f},
std::array<float,2>{0.0986259505f, 0.4587906f},
std::array<float,2>{0.271189451f, 0.767749548f},
std::array<float,2>{0.831669748f, 0.0185349528f},
std::array<float,2>{0.938608468f, 0.625483751f},
std::array<float,2>{0.427876741f, 0.300152928f},
std::array<float,2>{0.212408751f, 0.936198711f},
std::array<float,2>{0.627767026f, 0.14816089f},
std::array<float,2>{0.593142688f, 0.753520548f},
std::array<float,2>{0.080827333f, 0.0104713216f},
std::array<float,2>{0.281503052f, 0.539347887f},
std::array<float,2>{0.870904088f, 0.44330439f},
std::array<float,2>{0.753537416f, 0.990591824f},
std::array<float,2>{0.34548077f, 0.243750051f},
std::array<float,2>{0.00768070621f, 0.735969961f},
std::array<float,2>{0.547430813f, 0.367033273f},
std::array<float,2>{0.689539135f, 0.57804507f},
std::array<float,2>{0.139365882f, 0.435266316f},
std::array<float,2>{0.479515791f, 0.851831615f},
std::array<float,2>{0.927848816f, 0.105605327f},
std::array<float,2>{0.813453794f, 0.50380671f},
std::array<float,2>{0.258425593f, 0.489150584f},
std::array<float,2>{0.114149347f, 0.804094791f},
std::array<float,2>{0.620240033f, 0.0396424085f},
std::array<float,2>{0.662342846f, 0.895428121f},
std::array<float,2>{0.228495672f, 0.185140207f},
std::array<float,2>{0.39217028f, 0.674444854f},
std::array<float,2>{0.983602464f, 0.264748126f},
std::array<float,2>{0.898103237f, 0.831375003f},
std::array<float,2>{0.46483627f, 0.0832687318f},
std::array<float,2>{0.170252815f, 0.619068503f},
std::array<float,2>{0.730713248f, 0.387728095f},
std::array<float,2>{0.513618112f, 0.703557253f},
std::array<float,2>{0.0427154638f, 0.313799143f},
std::array<float,2>{0.333462387f, 0.955825925f},
std::array<float,2>{0.811773419f, 0.210006818f},
std::array<float,2>{0.972599208f, 0.532101154f},
std::array<float,2>{0.400399655f, 0.447663695f},
std::array<float,2>{0.220601052f, 0.76452446f},
std::array<float,2>{0.668864846f, 0.00101042876f},
std::array<float,2>{0.612373412f, 0.924649417f},
std::array<float,2>{0.123033904f, 0.154355437f},
std::array<float,2>{0.255032003f, 0.63875097f},
std::array<float,2>{0.821152806f, 0.305317491f},
std::array<float,2>{0.798908412f, 0.84695828f},
std::array<float,2>{0.342380762f, 0.0977901444f},
std::array<float,2>{0.0324859172f, 0.563604534f},
std::array<float,2>{0.506830871f, 0.425808847f},
std::array<float,2>{0.719962537f, 0.749124527f},
std::array<float,2>{0.158909947f, 0.369169801f},
std::array<float,2>{0.458356053f, 0.996056259f},
std::array<float,2>{0.904986501f, 0.241647765f},
std::array<float,2>{0.861819625f, 0.684948206f},
std::array<float,2>{0.296608835f, 0.254546613f},
std::array<float,2>{0.0885281935f, 0.901399255f},
std::array<float,2>{0.581402838f, 0.176329225f},
std::array<float,2>{0.638208032f, 0.811952949f},
std::array<float,2>{0.203471959f, 0.0386946313f},
std::array<float,2>{0.432366639f, 0.513855398f},
std::array<float,2>{0.949505687f, 0.499658614f},
std::array<float,2>{0.937439203f, 0.964246511f},
std::array<float,2>{0.469340622f, 0.213314116f},
std::array<float,2>{0.125898942f, 0.717771351f},
std::array<float,2>{0.698794961f, 0.320990503f},
std::array<float,2>{0.558257759f, 0.613690853f},
std::array<float,2>{0.00937580224f, 0.377447426f},
std::array<float,2>{0.355906546f, 0.841477513f},
std::array<float,2>{0.76469779f, 0.0879616886f},
std::array<float,2>{0.882642269f, 0.701956749f},
std::array<float,2>{0.450560838f, 0.341252565f},
std::array<float,2>{0.18624498f, 0.942077875f},
std::array<float,2>{0.73604697f, 0.191030577f},
std::array<float,2>{0.519304097f, 0.821773767f},
std::array<float,2>{0.0551848002f, 0.0727170259f},
std::array<float,2>{0.320681542f, 0.600652575f},
std::array<float,2>{0.781480014f, 0.401583284f},
std::array<float,2>{0.836227417f, 0.887205005f},
std::array<float,2>{0.276493549f, 0.15776214f},
std::array<float,2>{0.102675691f, 0.666000664f},
std::array<float,2>{0.595971763f, 0.280456036f},
std::array<float,2>{0.67201364f, 0.52784431f},
std::array<float,2>{0.237630159f, 0.480885595f},
std::array<float,2>{0.386453748f, 0.787739813f},
std::array<float,2>{0.999746919f, 0.0603294261f},
std::array<float,2>{0.780499399f, 0.581510663f},
std::array<float,2>{0.365861088f, 0.413871616f},
std::array<float,2>{0.0229265001f, 0.874058306f},
std::array<float,2>{0.536359787f, 0.11912977f},
std::array<float,2>{0.715714395f, 0.975654423f},
std::array<float,2>{0.155680701f, 0.231115744f},
std::array<float,2>{0.489712834f, 0.725627661f},
std::array<float,2>{0.910173714f, 0.351372957f},
std::array<float,2>{0.961843789f, 0.778308332f},
std::array<float,2>{0.414569765f, 0.0241981689f},
std::array<float,2>{0.197960734f, 0.558634102f},
std::array<float,2>{0.648081839f, 0.461133122f},
std::array<float,2>{0.566471994f, 0.654216647f},
std::array<float,2>{0.0743133947f, 0.292874426f},
std::array<float,2>{0.305925161f, 0.906553447f},
std::array<float,2>{0.852261364f, 0.132935241f},
std::array<float,2>{0.956989586f, 0.56890589f},
std::array<float,2>{0.410393685f, 0.424446315f},
std::array<float,2>{0.188130125f, 0.851030648f},
std::array<float,2>{0.650151908f, 0.0960330963f},
std::array<float,2>{0.574829698f, 0.99705255f},
std::array<float,2>{0.0637419745f, 0.234875515f},
std::array<float,2>{0.301973522f, 0.74255985f},
std::array<float,2>{0.846588731f, 0.373062491f},
std::array<float,2>{0.7661286f, 0.760093808f},
std::array<float,2>{0.369508296f, 0.00599102164f},
std::array<float,2>{0.0252989177f, 0.536533475f},
std::array<float,2>{0.540076494f, 0.451117247f},
std::array<float,2>{0.709098697f, 0.63617146f},
std::array<float,2>{0.147487223f, 0.311756641f},
std::array<float,2>{0.494631112f, 0.927969694f},
std::array<float,2>{0.919640064f, 0.151593283f},
std::array<float,2>{0.833504677f, 0.711905122f},
std::array<float,2>{0.266634911f, 0.327729076f},
std::array<float,2>{0.0957661495f, 0.967496574f},
std::array<float,2>{0.608025253f, 0.217420563f},
std::array<float,2>{0.680039823f, 0.835945666f},
std::array<float,2>{0.247424245f, 0.0911668241f},
std::array<float,2>{0.381635249f, 0.609809756f},
std::array<float,2>{0.991834164f, 0.38054812f},
std::array<float,2>{0.88286382f, 0.90321064f},
std::array<float,2>{0.438967049f, 0.173217162f},
std::array<float,2>{0.175667256f, 0.682952762f},
std::array<float,2>{0.743440747f, 0.250477701f},
std::array<float,2>{0.524326086f, 0.511695266f},
std::array<float,2>{0.0531307012f, 0.492370397f},
std::array<float,2>{0.314918905f, 0.807455063f},
std::array<float,2>{0.79035145f, 0.0326743573f},
std::array<float,2>{0.924388885f, 0.671299815f},
std::array<float,2>{0.48222661f, 0.275606662f},
std::array<float,2>{0.1347868f, 0.885581553f},
std::array<float,2>{0.691968262f, 0.163187087f},
std::array<float,2>{0.55347681f, 0.783630371f},
std::array<float,2>{0.00273610675f, 0.0568071678f},
std::array<float,2>{0.350846231f, 0.526872873f},
std::array<float,2>{0.757727206f, 0.480417073f},
std::array<float,2>{0.874951959f, 0.937524021f},
std::array<float,2>{0.286732316f, 0.194907293f},
std::array<float,2>{0.0821555033f, 0.6969347f},
std::array<float,2>{0.586359859f, 0.336192667f},
std::array<float,2>{0.630949497f, 0.5950495f},
std::array<float,2>{0.215922236f, 0.402534813f},
std::array<float,2>{0.423066467f, 0.824509025f},
std::array<float,2>{0.943047702f, 0.0764693692f},
std::array<float,2>{0.807117999f, 0.558330476f},
std::array<float,2>{0.329961717f, 0.465603113f},
std::array<float,2>{0.0434487462f, 0.775332153f},
std::array<float,2>{0.509942114f, 0.0310884751f},
std::array<float,2>{0.727030694f, 0.910177171f},
std::array<float,2>{0.166815206f, 0.139393166f},
std::array<float,2>{0.467999101f, 0.651170731f},
std::array<float,2>{0.892420173f, 0.294906735f},
std::array<float,2>{0.980191767f, 0.868106127f},
std::array<float,2>{0.397982359f, 0.124995239f},
std::array<float,2>{0.234315276f, 0.58526206f},
std::array<float,2>{0.656317413f, 0.409764618f},
std::array<float,2>{0.621628523f, 0.718841136f},
std::array<float,2>{0.112406932f, 0.347396344f},
std::array<float,2>{0.26203686f, 0.970459461f},
std::array<float,2>{0.820126235f, 0.230205119f},
std::array<float,2>{0.899968565f, 0.521680772f},
std::array<float,2>{0.45683983f, 0.473258197f},
std::array<float,2>{0.162863404f, 0.795136034f},
std::array<float,2>{0.72489953f, 0.0525298305f},
std::array<float,2>{0.501388609f, 0.879321218f},
std::array<float,2>{0.037979424f, 0.164511651f},
std::array<float,2>{0.336628675f, 0.660705626f},
std::array<float,2>{0.804576278f, 0.269388199f},
std::array<float,2>{0.827100992f, 0.814744115f},
std::array<float,2>{0.251113296f, 0.0700819939f},
std::array<float,2>{0.118723705f, 0.606470466f},
std::array<float,2>{0.615782559f, 0.391230255f},
std::array<float,2>{0.664923251f, 0.68802458f},
std::array<float,2>{0.223758593f, 0.328477472f},
std::array<float,2>{0.403176159f, 0.950550258f},
std::array<float,2>{0.9753443f, 0.201345608f},
std::array<float,2>{0.761077702f, 0.640650928f},
std::array<float,2>{0.354539245f, 0.287554383f},
std::array<float,2>{0.0130022466f, 0.920691431f},
std::array<float,2>{0.559616268f, 0.130463392f},
std::array<float,2>{0.702486813f, 0.773061275f},
std::array<float,2>{0.129764885f, 0.0204559695f},
std::array<float,2>{0.476539582f, 0.548535228f},
std::array<float,2>{0.931101859f, 0.456783772f},
std::array<float,2>{0.948580384f, 0.981414378f},
std::array<float,2>{0.435670882f, 0.219112933f},
std::array<float,2>{0.207823992f, 0.728363097f},
std::array<float,2>{0.632971764f, 0.354518324f},
std::array<float,2>{0.584952176f, 0.587819695f},
std::array<float,2>{0.0923524424f, 0.42094785f},
std::array<float,2>{0.290147722f, 0.859921455f},
std::array<float,2>{0.866347551f, 0.113471068f},
std::array<float,2>{0.992389798f, 0.739252746f},
std::array<float,2>{0.388287425f, 0.361738443f},
std::array<float,2>{0.239088133f, 0.984907448f},
std::array<float,2>{0.677836001f, 0.24781698f},
std::array<float,2>{0.598837793f, 0.857342899f},
std::array<float,2>{0.106366284f, 0.103832915f},
std::array<float,2>{0.278340399f, 0.571470678f},
std::array<float,2>{0.84206295f, 0.432068825f},
std::array<float,2>{0.785966277f, 0.930894792f},
std::array<float,2>{0.326354235f, 0.140951753f},
std::array<float,2>{0.0618142597f, 0.631279469f},
std::array<float,2>{0.521685243f, 0.303604335f},
std::array<float,2>{0.741183698f, 0.543864012f},
std::array<float,2>{0.183138251f, 0.440448403f},
std::array<float,2>{0.446387529f, 0.757776678f},
std::array<float,2>{0.876112938f, 0.0117989471f},
std::array<float,2>{0.857578397f, 0.623312354f},
std::array<float,2>{0.311716557f, 0.384015918f},
std::array<float,2>{0.071864292f, 0.833167493f},
std::array<float,2>{0.565622509f, 0.0801316574f},
std::array<float,2>{0.643314898f, 0.957309127f},
std::array<float,2>{0.201437026f, 0.206327274f},
std::array<float,2>{0.419394821f, 0.707468152f},
std::array<float,2>{0.968456447f, 0.319094151f},
std::array<float,2>{0.907032609f, 0.798575997f},
std::array<float,2>{0.486459643f, 0.0445869565f},
std::array<float,2>{0.148680717f, 0.507062912f},
std::array<float,2>{0.713473916f, 0.487084061f},
std::array<float,2>{0.532243967f, 0.678171039f},
std::array<float,2>{0.0182168558f, 0.259904176f},
std::array<float,2>{0.36059919f, 0.892683506f},
std::array<float,2>{0.774489343f, 0.180973008f},
std::array<float,2>{0.889743388f, 0.592895567f},
std::array<float,2>{0.445185274f, 0.414377064f},
std::array<float,2>{0.178902f, 0.863447666f},
std::array<float,2>{0.746787906f, 0.10995084f},
std::array<float,2>{0.530730546f, 0.977913678f},
std::array<float,2>{0.0507789627f, 0.22619766f},
std::array<float,2>{0.318553329f, 0.733101189f},
std::array<float,2>{0.796215177f, 0.35547331f},
std::array<float,2>{0.829647362f, 0.766681194f},
std::array<float,2>{0.272998482f, 0.0173068009f},
std::array<float,2>{0.100779735f, 0.552000463f},
std::array<float,2>{0.604491115f, 0.459735632f},
std::array<float,2>{0.685681641f, 0.645677686f},
std::array<float,2>{0.243386269f, 0.28346321f},
std::array<float,2>{0.376585305f, 0.915593386f},
std::array<float,2>{0.986728847f, 0.128292054f},
std::array<float,2>{0.77206099f, 0.694448769f},
std::array<float,2>{0.372206628f, 0.335269451f},
std::array<float,2>{0.0288577378f, 0.947277606f},
std::array<float,2>{0.543936074f, 0.198691502f},
std::array<float,2>{0.70422101f, 0.817479253f},
std::array<float,2>{0.14243488f, 0.0646788031f},
std::array<float,2>{0.497524112f, 0.602564991f},
std::array<float,2>{0.917111397f, 0.396271437f},
std::array<float,2>{0.95826292f, 0.875305772f},
std::array<float,2>{0.408945292f, 0.170461342f},
std::array<float,2>{0.194305047f, 0.656743824f},
std::array<float,2>{0.653299928f, 0.272741854f},
std::array<float,2>{0.570919633f, 0.51771456f},
std::array<float,2>{0.0697215199f, 0.469956934f},
std::array<float,2>{0.297242045f, 0.790861964f},
std::array<float,2>{0.850638092f, 0.048911538f},
std::array<float,2>{0.981540382f, 0.6726349f},
std::array<float,2>{0.393465519f, 0.263130993f},
std::array<float,2>{0.229759023f, 0.897714138f},
std::array<float,2>{0.661998153f, 0.186862752f},
std::array<float,2>{0.617959678f, 0.801909089f},
std::array<float,2>{0.116601996f, 0.0412568524f},
std::array<float,2>{0.259925663f, 0.500151277f},
std::array<float,2>{0.815918148f, 0.491220862f},
std::array<float,2>{0.809085429f, 0.954648733f},
std::array<float,2>{0.335519463f, 0.208796173f},
std::array<float,2>{0.0401929058f, 0.706733346f},
std::array<float,2>{0.513754487f, 0.31467396f},
std::array<float,2>{0.732569218f, 0.620212376f},
std::array<float,2>{0.169207796f, 0.389098972f},
std::array<float,2>{0.461914539f, 0.829048336f},
std::array<float,2>{0.895164847f, 0.0856137276f},
std::array<float,2>{0.867452443f, 0.541279495f},
std::array<float,2>{0.28467828f, 0.444934815f},
std::array<float,2>{0.0784494877f, 0.751180589f},
std::array<float,2>{0.58998096f, 0.00959385931f},
std::array<float,2>{0.626210093f, 0.933953702f},
std::array<float,2>{0.214317441f, 0.144680887f},
std::array<float,2>{0.42654115f, 0.627941251f},
std::array<float,2>{0.9405092f, 0.298164248f},
std::array<float,2>{0.927338779f, 0.854438722f},
std::array<float,2>{0.47814998f, 0.108320177f},
std::array<float,2>{0.136776686f, 0.575943589f},
std::array<float,2>{0.687752247f, 0.436764777f},
std::array<float,2>{0.549938262f, 0.737489939f},
std::array<float,2>{0.00564671587f, 0.365056723f},
std::array<float,2>{0.347151786f, 0.990207016f},
std::array<float,2>{0.751001835f, 0.244375825f},
std::array<float,2>{0.952203453f, 0.511903465f},
std::array<float,2>{0.43019864f, 0.497050017f},
std::array<float,2>{0.205920383f, 0.809869587f},
std::array<float,2>{0.6391747f, 0.0359604731f},
std::array<float,2>{0.579116523f, 0.899028003f},
std::array<float,2>{0.0860842019f, 0.179075316f},
std::array<float,2>{0.294905245f, 0.686509907f},
std::array<float,2>{0.860340714f, 0.256766975f},
std::array<float,2>{0.763621628f, 0.842750132f},
std::array<float,2>{0.358803302f, 0.0872656554f},
std::array<float,2>{0.0110541815f, 0.616709232f},
std::array<float,2>{0.555430353f, 0.375062197f},
std::array<float,2>{0.696442008f, 0.716530323f},
std::array<float,2>{0.128153488f, 0.322775781f},
std::array<float,2>{0.472405165f, 0.961325824f},
std::array<float,2>{0.93426919f, 0.21095252f},
std::array<float,2>{0.823771834f, 0.637091517f},
std::array<float,2>{0.257612467f, 0.306707203f},
std::array<float,2>{0.124828026f, 0.923800886f},
std::array<float,2>{0.610311866f, 0.15355289f},
std::array<float,2>{0.671656549f, 0.763194621f},
std::array<float,2>{0.22220847f, 0.00299739372f},
std::array<float,2>{0.399639755f, 0.534193993f},
std::array<float,2>{0.970022976f, 0.447231621f},
std::array<float,2>{0.903905749f, 0.993990004f},
std::array<float,2>{0.460215092f, 0.239538163f},
std::array<float,2>{0.157152086f, 0.747024417f},
std::array<float,2>{0.721373498f, 0.367753297f},
std::array<float,2>{0.505155385f, 0.564850748f},
std::array<float,2>{0.0349399894f, 0.429116398f},
std::array<float,2>{0.340077192f, 0.845125854f},
std::array<float,2>{0.798261404f, 0.101043426f},
std::array<float,2>{0.913172781f, 0.723702073f},
std::array<float,2>{0.492028236f, 0.348986596f},
std::array<float,2>{0.152916878f, 0.973707676f},
std::array<float,2>{0.718497574f, 0.234118029f},
std::array<float,2>{0.537794352f, 0.872405529f},
std::array<float,2>{0.020600358f, 0.119731002f},
std::array<float,2>{0.363983363f, 0.578215718f},
std::array<float,2>{0.777841628f, 0.410627991f},
std::array<float,2>{0.853789032f, 0.909844398f},
std::array<float,2>{0.306844205f, 0.136162654f},
std::array<float,2>{0.0762804896f, 0.654413462f},
std::array<float,2>{0.570097804f, 0.290035278f},
std::array<float,2>{0.645017326f, 0.562337279f},
std::array<float,2>{0.196094513f, 0.464379758f},
std::array<float,2>{0.417045653f, 0.780512333f},
std::array<float,2>{0.963686883f, 0.0268402714f},
std::array<float,2>{0.785090327f, 0.597784698f},
std::array<float,2>{0.323448896f, 0.399528921f},
std::array<float,2>{0.0573089495f, 0.823235929f},
std::array<float,2>{0.517227709f, 0.0712057799f},
std::array<float,2>{0.73826015f, 0.944223106f},
std::array<float,2>{0.184743226f, 0.188452512f},
std::array<float,2>{0.452286452f, 0.699426889f},
std::array<float,2>{0.879645824f, 0.34273392f},
std::array<float,2>{0.997197449f, 0.786772013f},
std::array<float,2>{0.383422047f, 0.0612440668f},
std::array<float,2>{0.235974148f, 0.530564249f},
std::array<float,2>{0.675709486f, 0.48268342f},
std::array<float,2>{0.594796598f, 0.667042613f},
std::array<float,2>{0.10489849f, 0.278099656f},
std::array<float,2>{0.27428773f, 0.889438987f},
std::array<float,2>{0.838645041f, 0.158320785f},
std::array<float,2>{0.988962471f, 0.611616254f},
std::array<float,2>{0.380805433f, 0.382719785f},
std::array<float,2>{0.248224735f, 0.839084923f},
std::array<float,2>{0.68165648f, 0.0927332193f},
std::array<float,2>{0.607189655f, 0.965754688f},
std::array<float,2>{0.0940760896f, 0.215154663f},
std::array<float,2>{0.267590374f, 0.714000881f},
std::array<float,2>{0.835788667f, 0.325777113f},
std::array<float,2>{0.792244077f, 0.805484235f},
std::array<float,2>{0.313406378f, 0.0335494876f},
std::array<float,2>{0.052164305f, 0.508638561f},
std::array<float,2>{0.525535166f, 0.495666325f},
std::array<float,2>{0.74604708f, 0.680508435f},
std::array<float,2>{0.173349574f, 0.253853679f},
std::array<float,2>{0.440920234f, 0.904755175f},
std::array<float,2>{0.885639787f, 0.174230501f},
std::array<float,2>{0.844804227f, 0.74503386f},
std::array<float,2>{0.303040236f, 0.371443927f},
std::array<float,2>{0.0645530969f, 0.998732924f},
std::array<float,2>{0.577890515f, 0.237940535f},
std::array<float,2>{0.65064472f, 0.849071622f},
std::array<float,2>{0.190427184f, 0.0947066918f},
std::array<float,2>{0.413758129f, 0.567509055f},
std::array<float,2>{0.954609573f, 0.421880811f},
std::array<float,2>{0.921502709f, 0.925981283f},
std::array<float,2>{0.492556572f, 0.148945928f},
std::array<float,2>{0.145667493f, 0.632995248f},
std::array<float,2>{0.707249224f, 0.309613764f},
std::array<float,2>{0.542613983f, 0.538368881f},
std::array<float,2>{0.0259565245f, 0.452600807f},
std::array<float,2>{0.36872372f, 0.759344637f},
std::array<float,2>{0.768137634f, 0.00465670787f},
std::array<float,2>{0.893838227f, 0.65038991f},
std::array<float,2>{0.465586066f, 0.295654982f},
std::array<float,2>{0.164671734f, 0.913150072f},
std::array<float,2>{0.729073107f, 0.137037322f},
std::array<float,2>{0.509162545f, 0.77707684f},
std::array<float,2>{0.0466149785f, 0.0292415526f},
std::array<float,2>{0.332014352f, 0.555077672f},
std::array<float,2>{0.806414902f, 0.466947436f},
std::array<float,2>{0.816952229f, 0.97159946f},
std::array<float,2>{0.265027165f, 0.227920264f},
std::array<float,2>{0.109736376f, 0.722163975f},
std::array<float,2>{0.62315774f, 0.344770402f},
std::array<float,2>{0.659850955f, 0.583468318f},
std::array<float,2>{0.231109977f, 0.407077372f},
std::array<float,2>{0.394842446f, 0.870918751f},
std::array<float,2>{0.977179706f, 0.122904986f},
std::array<float,2>{0.754543841f, 0.523510873f},
std::array<float,2>{0.349578917f, 0.476634771f},
std::array<float,2>{0.000749754254f, 0.781649232f},
std::array<float,2>{0.551118255f, 0.0556556545f},
std::array<float,2>{0.695157528f, 0.883595884f},
std::array<float,2>{0.134611577f, 0.161210328f},
std::array<float,2>{0.482582957f, 0.66897434f},
std::array<float,2>{0.923111737f, 0.274889082f},
std::array<float,2>{0.943707466f, 0.826261461f},
std::array<float,2>{0.425650835f, 0.0755989477f},
std::array<float,2>{0.217978612f, 0.596118629f},
std::array<float,2>{0.62972486f, 0.404633582f},
std::array<float,2>{0.587981224f, 0.69912976f},
std::array<float,2>{0.0845708996f, 0.338001609f},
std::array<float,2>{0.288562924f, 0.94077903f},
std::array<float,2>{0.872772634f, 0.191666871f},
std::array<float,2>{0.932413042f, 0.550027668f},
std::array<float,2>{0.473173141f, 0.454038322f},
std::array<float,2>{0.131791726f, 0.769655824f},
std::array<float,2>{0.700791001f, 0.0226916894f},
std::array<float,2>{0.561472714f, 0.919095516f},
std::array<float,2>{0.0146233831f, 0.132151678f},
std::array<float,2>{0.352256924f, 0.644375801f},
std::array<float,2>{0.75818187f, 0.285571516f},
std::array<float,2>{0.864006281f, 0.862348676f},
std::array<float,2>{0.291332185f, 0.1167771f},
std::array<float,2>{0.0898638517f, 0.589765787f},
std::array<float,2>{0.583782196f, 0.419140369f},
std::array<float,2>{0.636660874f, 0.729577243f},
std::array<float,2>{0.210155323f, 0.353251487f},
std::array<float,2>{0.434882045f, 0.984065533f},
std::array<float,2>{0.945471823f, 0.220932499f},
std::array<float,2>{0.801156998f, 0.66383034f},
std::array<float,2>{0.338293791f, 0.266179711f},
std::array<float,2>{0.0356203988f, 0.882751644f},
std::array<float,2>{0.502163053f, 0.16775018f},
std::array<float,2>{0.722659767f, 0.793044686f},
std::array<float,2>{0.160813481f, 0.0536735579f},
std::array<float,2>{0.453560054f, 0.519724607f},
std::array<float,2>{0.90157187f, 0.476359963f},
std::array<float,2>{0.973704219f, 0.952691257f},
std::array<float,2>{0.405275196f, 0.199672207f},
std::array<float,2>{0.225885317f, 0.690184772f},
std::array<float,2>{0.66759485f, 0.330548495f},
std::array<float,2>{0.614238679f, 0.607899427f},
std::array<float,2>{0.120027132f, 0.392640322f},
std::array<float,2>{0.25388661f, 0.813843071f},
std::array<float,2>{0.824240327f, 0.0678467378f},
std::array<float,2>{0.966355383f, 0.709035993f},
std::array<float,2>{0.420146555f, 0.316818595f},
std::array<float,2>{0.199896708f, 0.960245252f},
std::array<float,2>{0.640960574f, 0.203381136f},
std::array<float,2>{0.564254642f, 0.835827768f},
std::array<float,2>{0.0734061152f, 0.0793121383f},
std::array<float,2>{0.309487402f, 0.621594012f},
std::array<float,2>{0.85691607f, 0.386150002f},
std::array<float,2>{0.775780678f, 0.891156197f},
std::array<float,2>{0.362655818f, 0.182182699f},
std::array<float,2>{0.0167384949f, 0.676322997f},
std::array<float,2>{0.533558786f, 0.25781399f},
std::array<float,2>{0.711501122f, 0.505606174f},
std::array<float,2>{0.150681421f, 0.484897822f},
std::array<float,2>{0.486319661f, 0.799008548f},
std::array<float,2>{0.909281969f, 0.0454930998f},
std::array<float,2>{0.839931428f, 0.574071765f},
std::array<float,2>{0.280075222f, 0.43074739f},
std::array<float,2>{0.10937012f, 0.858033717f},
std::array<float,2>{0.601195395f, 0.102080725f},
std::array<float,2>{0.676066995f, 0.98745203f},
std::array<float,2>{0.240310892f, 0.248184144f},
std::array<float,2>{0.389991462f, 0.741985798f},
std::array<float,2>{0.994685531f, 0.360817164f},
std::array<float,2>{0.878113151f, 0.754532039f},
std::array<float,2>{0.447359145f, 0.0151682291f},
std::array<float,2>{0.179919064f, 0.546735764f},
std::array<float,2>{0.739013612f, 0.439333469f},
std::array<float,2>{0.520679832f, 0.629677892f},
std::array<float,2>{0.0591875911f, 0.301308572f},
std::array<float,2>{0.325609565f, 0.933539689f},
std::array<float,2>{0.788680434f, 0.143495217f},
std::array<float,2>{0.910843551f, 0.578827024f},
std::array<float,2>{0.490121514f, 0.411000073f},
std::array<float,2>{0.155877113f, 0.872580647f},
std::array<float,2>{0.714940071f, 0.119519718f},
std::array<float,2>{0.537062585f, 0.97417295f},
std::array<float,2>{0.0230233315f, 0.23341009f},
std::array<float,2>{0.365512639f, 0.724413037f},
std::array<float,2>{0.780787706f, 0.349132091f},
std::array<float,2>{0.851723075f, 0.780998051f},
std::array<float,2>{0.306366175f, 0.0270292815f},
std::array<float,2>{0.0750221908f, 0.561606526f},
std::array<float,2>{0.567282915f, 0.464267552f},
std::array<float,2>{0.64784205f, 0.654800296f},
std::array<float,2>{0.197433308f, 0.289394557f},
std::array<float,2>{0.414106965f, 0.909316778f},
std::array<float,2>{0.961124182f, 0.136349395f},
std::array<float,2>{0.781851888f, 0.699862599f},
std::array<float,2>{0.321030706f, 0.342188895f},
std::array<float,2>{0.055008322f, 0.943371892f},
std::array<float,2>{0.518718183f, 0.187672406f},
std::array<float,2>{0.735674322f, 0.822355449f},
std::array<float,2>{0.185846463f, 0.0705809444f},
std::array<float,2>{0.45093286f, 0.598580062f},
std::array<float,2>{0.881944239f, 0.399990976f},
std::array<float,2>{0.999073803f, 0.888976336f},
std::array<float,2>{0.385815114f, 0.159117281f},
std::array<float,2>{0.237924233f, 0.667904735f},
std::array<float,2>{0.672392011f, 0.277499974f},
std::array<float,2>{0.596231699f, 0.531020403f},
std::array<float,2>{0.103042878f, 0.483093321f},
std::array<float,2>{0.277012855f, 0.786456168f},
std::array<float,2>{0.836736143f, 0.0609939173f},
std::array<float,2>{0.949974179f, 0.686011493f},
std::array<float,2>{0.431670874f, 0.255987257f},
std::array<float,2>{0.203888312f, 0.898857653f},
std::array<float,2>{0.637976706f, 0.179388002f},
std::array<float,2>{0.58175528f, 0.810432017f},
std::array<float,2>{0.0881107077f, 0.0354772694f},
std::array<float,2>{0.296124786f, 0.512513697f},
std::array<float,2>{0.861799896f, 0.496419162f},
std::array<float,2>{0.765428424f, 0.96162951f},
std::array<float,2>{0.356129557f, 0.211671755f},
std::array<float,2>{0.00910092238f, 0.716243029f},
std::array<float,2>{0.557896078f, 0.322321713f},
std::array<float,2>{0.698360741f, 0.616421402f},
std::array<float,2>{0.125032172f, 0.375779569f},
std::array<float,2>{0.469010741f, 0.841904104f},
std::array<float,2>{0.936943293f, 0.0875363648f},
std::array<float,2>{0.820386052f, 0.534805477f},
std::array<float,2>{0.255812556f, 0.446507275f},
std::array<float,2>{0.122125499f, 0.762889802f},
std::array<float,2>{0.613059878f, 0.00356389279f},
std::array<float,2>{0.668173432f, 0.922988355f},
std::array<float,2>{0.219876722f, 0.154115915f},
std::array<float,2>{0.40117541f, 0.637238443f},
std::array<float,2>{0.971914887f, 0.307330668f},
std::array<float,2>{0.904522121f, 0.845549226f},
std::array<float,2>{0.458901584f, 0.101357721f},
std::array<float,2>{0.158232644f, 0.56524384f},
std::array<float,2>{0.720408499f, 0.429337651f},
std::array<float,2>{0.506165087f, 0.746243715f},
std::array<float,2>{0.0327807553f, 0.367510766f},
std::array<float,2>{0.341888368f, 0.993627369f},
std::array<float,2>{0.799491286f, 0.239909634f},
std::array<float,2>{0.984198093f, 0.500659823f},
std::array<float,2>{0.391858041f, 0.491710603f},
std::array<float,2>{0.227614462f, 0.802319527f},
std::array<float,2>{0.662842155f, 0.0416357405f},
std::array<float,2>{0.620907605f, 0.89807725f},
std::array<float,2>{0.113290414f, 0.18743743f},
std::array<float,2>{0.258085787f, 0.672138035f},
std::array<float,2>{0.812675953f, 0.263647139f},
std::array<float,2>{0.812162936f, 0.828509033f},
std::array<float,2>{0.33367455f, 0.0852363929f},
std::array<float,2>{0.0424256809f, 0.620905697f},
std::array<float,2>{0.512978196f, 0.389433414f},
std::array<float,2>{0.730995655f, 0.706208527f},
std::array<float,2>{0.170560583f, 0.314975172f},
std::array<float,2>{0.464131117f, 0.954359412f},
std::array<float,2>{0.897634447f, 0.208256915f},
std::array<float,2>{0.870270133f, 0.628611743f},
std::array<float,2>{0.281793267f, 0.298437357f},
std::array<float,2>{0.0805472657f, 0.934157133f},
std::array<float,2>{0.593332887f, 0.145248741f},
std::array<float,2>{0.626971662f, 0.751524925f},
std::array<float,2>{0.2121225f, 0.00917599536f},
std::array<float,2>{0.428410977f, 0.541801989f},
std::array<float,2>{0.939378142f, 0.444549799f},
std::array<float,2>{0.928545117f, 0.989582181f},
std::array<float,2>{0.480383128f, 0.24476026f},
std::array<float,2>{0.138994902f, 0.738185227f},
std::array<float,2>{0.6901474f, 0.364328414f},
std::array<float,2>{0.547139466f, 0.575259447f},
std::array<float,2>{0.00696878182f, 0.437469929f},
std::array<float,2>{0.345024645f, 0.853806973f},
std::array<float,2>{0.752951026f, 0.107521735f},
std::array<float,2>{0.886977851f, 0.732472479f},
std::array<float,2>{0.442949116f, 0.35597679f},
std::array<float,2>{0.176496357f, 0.978329659f},
std::array<float,2>{0.74869734f, 0.225627556f},
std::array<float,2>{0.527529657f, 0.863826692f},
std::array<float,2>{0.0475805886f, 0.109524176f},
std::array<float,2>{0.316412866f, 0.593348086f},
std::array<float,2>{0.794368029f, 0.414841145f},
std::array<float,2>{0.831278861f, 0.915217757f},
std::array<float,2>{0.2705158f, 0.12864168f},
std::array<float,2>{0.0978078544f, 0.646261215f},
std::array<float,2>{0.602335095f, 0.28399539f},
std::array<float,2>{0.68389684f, 0.552358925f},
std::array<float,2>{0.244343162f, 0.458987087f},
std::array<float,2>{0.378181666f, 0.767296553f},
std::array<float,2>{0.984428942f, 0.0166149642f},
std::array<float,2>{0.769945383f, 0.603433371f},
std::array<float,2>{0.37305069f, 0.395949721f},
std::array<float,2>{0.0306941159f, 0.818346083f},
std::array<float,2>{0.546424031f, 0.0652861446f},
std::array<float,2>{0.706848323f, 0.94795841f},
std::array<float,2>{0.142824844f, 0.19877103f},
std::array<float,2>{0.499255925f, 0.694928229f},
std::array<float,2>{0.915842831f, 0.335570991f},
std::array<float,2>{0.960578322f, 0.790337324f},
std::array<float,2>{0.406698138f, 0.0493374281f},
std::array<float,2>{0.191575021f, 0.518458009f},
std::array<float,2>{0.65610373f, 0.470701784f},
std::array<float,2>{0.57333231f, 0.65662533f},
std::array<float,2>{0.0680562034f, 0.273066193f},
std::array<float,2>{0.299900174f, 0.875891268f},
std::array<float,2>{0.84827435f, 0.170178145f},
std::array<float,2>{0.968063772f, 0.621516883f},
std::array<float,2>{0.419579566f, 0.386712909f},
std::array<float,2>{0.201749101f, 0.835333824f},
std::array<float,2>{0.643018901f, 0.0796428919f},
std::array<float,2>{0.566081703f, 0.960829377f},
std::array<float,2>{0.0717613026f, 0.203764588f},
std::array<float,2>{0.312122047f, 0.709804296f},
std::array<float,2>{0.858019352f, 0.317095429f},
std::array<float,2>{0.775118113f, 0.799711108f},
std::array<float,2>{0.361126602f, 0.0450378135f},
std::array<float,2>{0.0176363867f, 0.505210459f},
std::array<float,2>{0.532761097f, 0.48452571f},
std::array<float,2>{0.713093638f, 0.676192284f},
std::array<float,2>{0.148963705f, 0.258630365f},
std::array<float,2>{0.487114429f, 0.891068161f},
std::array<float,2>{0.906310618f, 0.181736976f},
std::array<float,2>{0.84239912f, 0.741228402f},
std::array<float,2>{0.278855056f, 0.361305356f},
std::array<float,2>{0.10552679f, 0.988193512f},
std::array<float,2>{0.599323094f, 0.248737022f},
std::array<float,2>{0.678349197f, 0.857657254f},
std::array<float,2>{0.238617346f, 0.101977706f},
std::array<float,2>{0.387975067f, 0.573691845f},
std::array<float,2>{0.99267596f, 0.431467563f},
std::array<float,2>{0.87691164f, 0.932726622f},
std::array<float,2>{0.446998507f, 0.142821565f},
std::array<float,2>{0.182647765f, 0.629374921f},
std::array<float,2>{0.740553498f, 0.300881892f},
std::array<float,2>{0.522026241f, 0.545922875f},
std::array<float,2>{0.0621555485f, 0.438680977f},
std::array<float,2>{0.326941997f, 0.754100323f},
std::array<float,2>{0.785268068f, 0.0149944779f},
std::array<float,2>{0.931447685f, 0.64402163f},
std::array<float,2>{0.475950003f, 0.286021948f},
std::array<float,2>{0.129264161f, 0.91983819f},
std::array<float,2>{0.703077137f, 0.132490411f},
std::array<float,2>{0.560185313f, 0.770035744f},
std::array<float,2>{0.0135888532f, 0.0229632221f},
std::array<float,2>{0.355011463f, 0.550614059f},
std::array<float,2>{0.761266947f, 0.45314303f},
std::array<float,2>{0.866728604f, 0.983722866f},
std::array<float,2>{0.290687263f, 0.221558198f},
std::array<float,2>{0.0920265391f, 0.730426788f},
std::array<float,2>{0.584339738f, 0.352711767f},
std::array<float,2>{0.633334279f, 0.589100122f},
std::array<float,2>{0.207409725f, 0.419502527f},
std::array<float,2>{0.436050624f, 0.86288327f},
std::array<float,2>{0.948841691f, 0.116446055f},
std::array<float,2>{0.803762913f, 0.520079732f},
std::array<float,2>{0.336025983f, 0.47599709f},
std::array<float,2>{0.037131615f, 0.793911159f},
std::array<float,2>{0.501553476f, 0.0529457517f},
std::array<float,2>{0.725396574f, 0.882272899f},
std::array<float,2>{0.16224502f, 0.167409673f},
std::array<float,2>{0.456116915f, 0.663169265f},
std::array<float,2>{0.899707377f, 0.266025871f},
std::array<float,2>{0.974827945f, 0.814191222f},
std::array<float,2>{0.402609557f, 0.0679266229f},
std::array<float,2>{0.224367112f, 0.608348131f},
std::array<float,2>{0.664341271f, 0.393486381f},
std::array<float,2>{0.615257919f, 0.689892113f},
std::array<float,2>{0.118629739f, 0.330568403f},
std::array<float,2>{0.251829535f, 0.952361345f},
std::array<float,2>{0.826306283f, 0.199779421f},
std::array<float,2>{0.891687512f, 0.555341303f},
std::array<float,2>{0.468396187f, 0.467732549f},
std::array<float,2>{0.16643019f, 0.776805758f},
std::array<float,2>{0.727528811f, 0.0283763334f},
std::array<float,2>{0.510491669f, 0.914040327f},
std::array<float,2>{0.0436504073f, 0.137381569f},
std::array<float,2>{0.329241455f, 0.649460673f},
std::array<float,2>{0.807209134f, 0.295259148f},
std::array<float,2>{0.819478333f, 0.870163798f},
std::array<float,2>{0.262555718f, 0.122450195f},
std::array<float,2>{0.112950273f, 0.583773553f},
std::array<float,2>{0.621523321f, 0.406439424f},
std::array<float,2>{0.657006502f, 0.722559154f},
std::array<float,2>{0.233571574f, 0.345634103f},
std::array<float,2>{0.397635639f, 0.970796525f},
std::array<float,2>{0.97965318f, 0.22816363f},
std::array<float,2>{0.757277131f, 0.669889748f},
std::array<float,2>{0.351275861f, 0.275367469f},
std::array<float,2>{0.0024079124f, 0.882861435f},
std::array<float,2>{0.55295223f, 0.161636785f},
std::array<float,2>{0.691861391f, 0.781895101f},
std::array<float,2>{0.135409027f, 0.0550366789f},
std::array<float,2>{0.4815346f, 0.524018705f},
std::array<float,2>{0.924160838f, 0.477375269f},
std::array<float,2>{0.94261229f, 0.941078067f},
std::array<float,2>{0.423589945f, 0.191975221f},
std::array<float,2>{0.216485798f, 0.698656678f},
std::array<float,2>{0.631358683f, 0.338762373f},
std::array<float,2>{0.586750269f, 0.596649766f},
std::array<float,2>{0.0828287601f, 0.404851526f},
std::array<float,2>{0.286567986f, 0.827082753f},
std::array<float,2>{0.874412179f, 0.0761341453f},
std::array<float,2>{0.99140358f, 0.714767754f},
std::array<float,2>{0.380996019f, 0.325501561f},
std::array<float,2>{0.247895092f, 0.964874744f},
std::array<float,2>{0.680450439f, 0.215680167f},
std::array<float,2>{0.607903838f, 0.839737296f},
std::array<float,2>{0.0964409709f, 0.0919036642f},
std::array<float,2>{0.267213792f, 0.612260938f},
std::array<float,2>{0.833068132f, 0.381909013f},
std::array<float,2>{0.790918291f, 0.90490526f},
std::array<float,2>{0.315206736f, 0.174321398f},
std::array<float,2>{0.0532307327f, 0.680111229f},
std::array<float,2>{0.523771286f, 0.253052175f},
std::array<float,2>{0.74398917f, 0.50799495f},
std::array<float,2>{0.174878299f, 0.49532637f},
std::array<float,2>{0.438845575f, 0.80501914f},
std::array<float,2>{0.883396387f, 0.0339570269f},
std::array<float,2>{0.84572047f, 0.568083823f},
std::array<float,2>{0.302470148f, 0.422574848f},
std::array<float,2>{0.0643470064f, 0.849133074f},
std::array<float,2>{0.574683428f, 0.094186388f},
std::array<float,2>{0.649539292f, 0.998460829f},
std::array<float,2>{0.187674597f, 0.237450123f},
std::array<float,2>{0.411118448f, 0.744300842f},
std::array<float,2>{0.956252933f, 0.371892184f},
std::array<float,2>{0.919305027f, 0.758962691f},
std::array<float,2>{0.494342208f, 0.0041527953f},
std::array<float,2>{0.148152426f, 0.538941681f},
std::array<float,2>{0.709481597f, 0.453068018f},
std::array<float,2>{0.540758967f, 0.633758664f},
std::array<float,2>{0.0246169381f, 0.310319215f},
std::array<float,2>{0.369918615f, 0.926560819f},
std::array<float,2>{0.76609093f, 0.148552135f},
std::array<float,2>{0.879241467f, 0.60112673f},
std::array<float,2>{0.45303154f, 0.402011842f},
std::array<float,2>{0.185443461f, 0.822003603f},
std::array<float,2>{0.737550855f, 0.0727550089f},
std::array<float,2>{0.516722322f, 0.941435099f},
std::array<float,2>{0.0567998774f, 0.190786958f},
std::array<float,2>{0.324089319f, 0.70139271f},
std::array<float,2>{0.784346819f, 0.34169209f},
std::array<float,2>{0.837956071f, 0.787438095f},
std::array<float,2>{0.273620069f, 0.0596012324f},
std::array<float,2>{0.105026677f, 0.52779299f},
std::array<float,2>{0.595580935f, 0.481008172f},
std::array<float,2>{0.675115228f, 0.665255845f},
std::array<float,2>{0.235729307f, 0.281145215f},
std::array<float,2>{0.383295774f, 0.887683511f},
std::array<float,2>{0.997912347f, 0.157454893f},
std::array<float,2>{0.77744174f, 0.726202548f},
std::array<float,2>{0.363535881f, 0.350954741f},
std::array<float,2>{0.0210794993f, 0.976076484f},
std::array<float,2>{0.53735137f, 0.230565712f},
std::array<float,2>{0.717857122f, 0.874829531f},
std::array<float,2>{0.15248242f, 0.118475854f},
std::array<float,2>{0.491491795f, 0.58193928f},
std::array<float,2>{0.913626432f, 0.413252443f},
std::array<float,2>{0.963306487f, 0.90679884f},
std::array<float,2>{0.41770184f, 0.133635014f},
std::array<float,2>{0.195403069f, 0.653677285f},
std::array<float,2>{0.645299971f, 0.292041272f},
std::array<float,2>{0.569551945f, 0.559143662f},
std::array<float,2>{0.0767118633f, 0.461849838f},
std::array<float,2>{0.307268262f, 0.777665913f},
std::array<float,2>{0.854278922f, 0.0238417853f},
std::array<float,2>{0.970587909f, 0.639643788f},
std::array<float,2>{0.400171876f, 0.305116415f},
std::array<float,2>{0.221851081f, 0.924081266f},
std::array<float,2>{0.671232164f, 0.155012473f},
std::array<float,2>{0.609663129f, 0.763967037f},
std::array<float,2>{0.124363616f, 0.00148433167f},
std::array<float,2>{0.257007778f, 0.531641662f},
std::array<float,2>{0.823623836f, 0.447976142f},
std::array<float,2>{0.798682988f, 0.99536252f},
std::array<float,2>{0.340774059f, 0.242007166f},
std::array<float,2>{0.034452036f, 0.749830127f},
std::array<float,2>{0.505735636f, 0.369714171f},
std::array<float,2>{0.72097671f, 0.564217448f},
std::array<float,2>{0.156589016f, 0.426437527f},
std::array<float,2>{0.460801482f, 0.847432494f},
std::array<float,2>{0.903550804f, 0.0983455032f},
std::array<float,2>{0.859786272f, 0.514522076f},
std::array<float,2>{0.294265151f, 0.49927932f},
std::array<float,2>{0.0866197124f, 0.812229216f},
std::array<float,2>{0.579669774f, 0.0383880027f},
std::array<float,2>{0.639039576f, 0.901976824f},
std::array<float,2>{0.205290943f, 0.175944671f},
std::array<float,2>{0.430091649f, 0.6852144f},
std::array<float,2>{0.952985346f, 0.254141927f},
std::array<float,2>{0.933893502f, 0.841211855f},
std::array<float,2>{0.471956491f, 0.0886199772f},
std::array<float,2>{0.12852402f, 0.614246249f},
std::array<float,2>{0.697209775f, 0.377176464f},
std::array<float,2>{0.554909825f, 0.717045844f},
std::array<float,2>{0.0116528487f, 0.320538163f},
std::array<float,2>{0.359243721f, 0.964602888f},
std::array<float,2>{0.762715995f, 0.213689372f},
std::array<float,2>{0.941244721f, 0.539799809f},
std::array<float,2>{0.425797462f, 0.44283691f},
std::array<float,2>{0.21442315f, 0.753159821f},
std::array<float,2>{0.626630545f, 0.0101517905f},
std::array<float,2>{0.590363801f, 0.935695171f},
std::array<float,2>{0.0790465623f, 0.147493839f},
std::array<float,2>{0.284424812f, 0.625556052f},
std::array<float,2>{0.867906988f, 0.300696909f},
std::array<float,2>{0.751606047f, 0.852159679f},
std::array<float,2>{0.347636491f, 0.106127076f},
std::array<float,2>{0.00513550499f, 0.577237546f},
std::array<float,2>{0.550374985f, 0.434728295f},
std::array<float,2>{0.688060522f, 0.73581326f},
std::array<float,2>{0.137338996f, 0.366651326f},
std::array<float,2>{0.477731735f, 0.990973473f},
std::array<float,2>{0.926876128f, 0.243189961f},
std::array<float,2>{0.815570176f, 0.674146712f},
std::array<float,2>{0.260576397f, 0.265410364f},
std::array<float,2>{0.116938166f, 0.894650102f},
std::array<float,2>{0.617421687f, 0.184843183f},
std::array<float,2>{0.661471963f, 0.804450095f},
std::array<float,2>{0.230040535f, 0.0392147563f},
std::array<float,2>{0.392692655f, 0.503212154f},
std::array<float,2>{0.982221484f, 0.488569647f},
std::array<float,2>{0.894848704f, 0.955370247f},
std::array<float,2>{0.462816983f, 0.210633039f},
std::array<float,2>{0.169522271f, 0.703963399f},
std::array<float,2>{0.73300463f, 0.314433515f},
std::array<float,2>{0.514402092f, 0.618383944f},
std::array<float,2>{0.0406807885f, 0.38839978f},
std::array<float,2>{0.335272163f, 0.831847131f},
std::array<float,2>{0.808752716f, 0.0836304575f},
std::array<float,2>{0.917573333f, 0.693357587f},
std::array<float,2>{0.497714818f, 0.332195878f},
std::array<float,2>{0.141826078f, 0.94699353f},
std::array<float,2>{0.704606473f, 0.19598648f},
std::array<float,2>{0.543134868f, 0.818796396f},
std::array<float,2>{0.0285211895f, 0.063457042f},
std::array<float,2>{0.372736692f, 0.605452597f},
std::array<float,2>{0.771885693f, 0.396930248f},
std::array<float,2>{0.851482868f, 0.877991676f},
std::array<float,2>{0.297630847f, 0.168267161f},
std::array<float,2>{0.0700165108f, 0.658248484f},
std::array<float,2>{0.570542991f, 0.271163702f},
std::array<float,2>{0.652683616f, 0.51565659f},
std::array<float,2>{0.193509072f, 0.471009403f},
std::array<float,2>{0.408295542f, 0.791854262f},
std::array<float,2>{0.958980441f, 0.0474606976f},
std::array<float,2>{0.796639562f, 0.591464698f},
std::array<float,2>{0.319006592f, 0.417273551f},
std::array<float,2>{0.0501269773f, 0.865296543f},
std::array<float,2>{0.530975521f, 0.112227336f},
std::array<float,2>{0.746142447f, 0.980022192f},
std::array<float,2>{0.179586977f, 0.224348992f},
std::array<float,2>{0.444482684f, 0.731661558f},
std::array<float,2>{0.890567482f, 0.358570367f},
std::array<float,2>{0.987268388f, 0.768324852f},
std::array<float,2>{0.375991493f, 0.018048726f},
std::array<float,2>{0.244034395f, 0.55452913f},
std::array<float,2>{0.686259627f, 0.458365351f},
std::array<float,2>{0.603628457f, 0.64751327f},
std::array<float,2>{0.101242281f, 0.281401694f},
std::array<float,2>{0.272846311f, 0.916049302f},
std::array<float,2>{0.829583287f, 0.125925362f},
std::array<float,2>{0.994309187f, 0.572131395f},
std::array<float,2>{0.390365005f, 0.432540596f},
std::array<float,2>{0.240972161f, 0.856671154f},
std::array<float,2>{0.676370144f, 0.104242161f},
std::array<float,2>{0.600765347f, 0.984592915f},
std::array<float,2>{0.108697817f, 0.247173995f},
std::array<float,2>{0.279303253f, 0.738478303f},
std::array<float,2>{0.840565801f, 0.362197906f},
std::array<float,2>{0.788539588f, 0.757019341f},
std::array<float,2>{0.325731903f, 0.0124496631f},
std::array<float,2>{0.0586060137f, 0.543444157f},
std::array<float,2>{0.521332264f, 0.441114694f},
std::array<float,2>{0.738475502f, 0.631419003f},
std::array<float,2>{0.180425629f, 0.303148836f},
std::array<float,2>{0.447835445f, 0.931188047f},
std::array<float,2>{0.878486216f, 0.141195819f},
std::array<float,2>{0.857283771f, 0.707567334f},
std::array<float,2>{0.308945596f, 0.318618238f},
std::array<float,2>{0.0738116726f, 0.957568705f},
std::array<float,2>{0.563747406f, 0.206574664f},
std::array<float,2>{0.641143262f, 0.833670795f},
std::array<float,2>{0.199441075f, 0.0810146183f},
std::array<float,2>{0.420745075f, 0.623776495f},
std::array<float,2>{0.966089189f, 0.384550393f},
std::array<float,2>{0.910111725f, 0.893186867f},
std::array<float,2>{0.485560596f, 0.181452826f},
std::array<float,2>{0.151244566f, 0.678488672f},
std::array<float,2>{0.711239815f, 0.260409653f},
std::array<float,2>{0.533989966f, 0.507434964f},
std::array<float,2>{0.017228473f, 0.486332357f},
std::array<float,2>{0.362893194f, 0.797994971f},
std::array<float,2>{0.776259482f, 0.0442253202f},
std::array<float,2>{0.902104616f, 0.660479605f},
std::array<float,2>{0.453998983f, 0.26857096f},
std::array<float,2>{0.160617501f, 0.879418314f},
std::array<float,2>{0.723329425f, 0.164927483f},
std::array<float,2>{0.50259614f, 0.795847118f},
std::array<float,2>{0.0358439982f, 0.0520074293f},
std::array<float,2>{0.338818073f, 0.522441089f},
std::array<float,2>{0.801660359f, 0.47278899f},
std::array<float,2>{0.824884355f, 0.950972795f},
std::array<float,2>{0.253159732f, 0.201711282f},
std::array<float,2>{0.1192699f, 0.687695503f},
std::array<float,2>{0.613558352f, 0.329081833f},
std::array<float,2>{0.667455792f, 0.607186317f},
std::array<float,2>{0.22642684f, 0.391106278f},
std::array<float,2>{0.406092495f, 0.815028012f},
std::array<float,2>{0.974476278f, 0.0695705712f},
std::array<float,2>{0.758772492f, 0.547949374f},
std::array<float,2>{0.351821899f, 0.456279933f},
std::array<float,2>{0.0139140273f, 0.772844136f},
std::array<float,2>{0.56091851f, 0.0199453775f},
std::array<float,2>{0.70053786f, 0.920217574f},
std::array<float,2>{0.130983844f, 0.129953802f},
std::array<float,2>{0.472695857f, 0.64157927f},
std::array<float,2>{0.931684732f, 0.287670135f},
std::array<float,2>{0.946187019f, 0.859862924f},
std::array<float,2>{0.435427278f, 0.114201702f},
std::array<float,2>{0.210649356f, 0.587010384f},
std::array<float,2>{0.636226416f, 0.421785444f},
std::array<float,2>{0.58337611f, 0.727681518f},
std::array<float,2>{0.0906432942f, 0.35507223f},
std::array<float,2>{0.291721493f, 0.98090589f},
std::array<float,2>{0.863358021f, 0.219430432f},
std::array<float,2>{0.923658788f, 0.526438653f},
std::array<float,2>{0.483374417f, 0.479730159f},
std::array<float,2>{0.134201422f, 0.78409791f},
std::array<float,2>{0.694686472f, 0.0572901741f},
std::array<float,2>{0.551693916f, 0.884934902f},
std::array<float,2>{0.000479954411f, 0.164014876f},
std::array<float,2>{0.34907946f, 0.671481073f},
std::array<float,2>{0.753987074f, 0.27600494f},
std::array<float,2>{0.872473598f, 0.824813783f},
std::array<float,2>{0.288775504f, 0.0769573078f},
std::array<float,2>{0.0840472877f, 0.595578611f},
std::array<float,2>{0.588856161f, 0.402921647f},
std::array<float,2>{0.629069865f, 0.696726799f},
std::array<float,2>{0.218534559f, 0.336729735f},
std::array<float,2>{0.424815714f, 0.93811965f},
std::array<float,2>{0.944027662f, 0.194632336f},
std::array<float,2>{0.80587554f, 0.650466383f},
std::array<float,2>{0.3311252f, 0.29417628f},
std::array<float,2>{0.0459317006f, 0.910799146f},
std::array<float,2>{0.509305835f, 0.138800353f},
std::array<float,2>{0.728670657f, 0.774697721f},
std::array<float,2>{0.164192051f, 0.0304079466f},
std::array<float,2>{0.465148181f, 0.557888329f},
std::array<float,2>{0.89411217f, 0.465197623f},
std::array<float,2>{0.976752937f, 0.969896376f},
std::array<float,2>{0.395183384f, 0.229543909f},
std::array<float,2>{0.230941325f, 0.719553947f},
std::array<float,2>{0.659367323f, 0.34687236f},
std::array<float,2>{0.623962641f, 0.585480392f},
std::array<float,2>{0.109940581f, 0.409569055f},
std::array<float,2>{0.265374511f, 0.867505491f},
std::array<float,2>{0.816504955f, 0.12444862f},
std::array<float,2>{0.954586446f, 0.743068099f},
std::array<float,2>{0.413571656f, 0.373547494f},
std::array<float,2>{0.189737737f, 0.996374965f},
std::array<float,2>{0.650968254f, 0.234394506f},
std::array<float,2>{0.577169836f, 0.851272285f},
std::array<float,2>{0.0651043579f, 0.0965242609f},
std::array<float,2>{0.303413451f, 0.568494976f},
std::array<float,2>{0.845589101f, 0.424174577f},
std::array<float,2>{0.767955065f, 0.928396702f},
std::array<float,2>{0.368592143f, 0.15194869f},
std::array<float,2>{0.0254326705f, 0.636348128f},
std::array<float,2>{0.542352498f, 0.31248495f},
std::array<float,2>{0.707675755f, 0.536644459f},
std::array<float,2>{0.146373808f, 0.450361192f},
std::array<float,2>{0.492792159f, 0.760591984f},
std::array<float,2>{0.921127856f, 0.00644100271f},
std::array<float,2>{0.835097849f, 0.610294163f},
std::array<float,2>{0.268255442f, 0.38014257f},
std::array<float,2>{0.0944168195f, 0.836656511f},
std::array<float,2>{0.606612027f, 0.091784887f},
std::array<float,2>{0.682514727f, 0.967133224f},
std::array<float,2>{0.248986185f, 0.217056587f},
std::array<float,2>{0.380206168f, 0.711293519f},
std::array<float,2>{0.988717675f, 0.327336222f},
std::array<float,2>{0.884924293f, 0.806670487f},
std::array<float,2>{0.440661073f, 0.033010412f},
std::array<float,2>{0.173123002f, 0.511166513f},
std::array<float,2>{0.745218813f, 0.49268198f},
std::array<float,2>{0.526354551f, 0.683574259f},
std::array<float,2>{0.0526662581f, 0.250536621f},
std::array<float,2>{0.312845409f, 0.902344167f},
std::array<float,2>{0.7925843f, 0.173563778f},
std::array<float,2>{0.936272025f, 0.614832103f},
std::array<float,2>{0.470340699f, 0.378792971f},
std::array<float,2>{0.126763165f, 0.840731442f},
std::array<float,2>{0.698065221f, 0.0893064588f},
std::array<float,2>{0.557067871f, 0.963317573f},
std::array<float,2>{0.00874258857f, 0.214263469f},
std::array<float,2>{0.357142746f, 0.718748569f},
std::array<float,2>{0.763930202f, 0.321542412f},
std::array<float,2>{0.863074481f, 0.810820222f},
std::array<float,2>{0.295159429f, 0.0374598689f},
std::array<float,2>{0.0894320533f, 0.514679253f},
std::array<float,2>{0.580464423f, 0.498093635f},
std::array<float,2>{0.636814237f, 0.684055507f},
std::array<float,2>{0.204725862f, 0.254938453f},
std::array<float,2>{0.432853937f, 0.900834858f},
std::array<float,2>{0.951108217f, 0.177353665f},
std::array<float,2>{0.800253332f, 0.748451769f},
std::array<float,2>{0.343691409f, 0.370539129f},
std::array<float,2>{0.0321844257f, 0.994361281f},
std::array<float,2>{0.507418215f, 0.24036622f},
std::array<float,2>{0.719673038f, 0.846650004f},
std::array<float,2>{0.159212917f, 0.0986882523f},
std::array<float,2>{0.457202673f, 0.562579215f},
std::array<float,2>{0.905594826f, 0.427393645f},
std::array<float,2>{0.97137481f, 0.925662637f},
std::array<float,2>{0.401676655f, 0.15556109f},
std::array<float,2>{0.219499305f, 0.639668822f},
std::array<float,2>{0.66942966f, 0.306578934f},
std::array<float,2>{0.61162442f, 0.532743931f},
std::array<float,2>{0.121279471f, 0.448335201f},
std::array<float,2>{0.253994375f, 0.765085638f},
std::array<float,2>{0.82172513f, 0.000228410747f},
std::array<float,2>{0.962884486f, 0.652543604f},
std::array<float,2>{0.416012824f, 0.29145655f},
std::array<float,2>{0.198411852f, 0.907782614f},
std::array<float,2>{0.647139549f, 0.133817703f},
std::array<float,2>{0.567964196f, 0.778478146f},
std::array<float,2>{0.0758983716f, 0.0247903615f},
std::array<float,2>{0.304760665f, 0.560515285f},
std::array<float,2>{0.853508472f, 0.462546289f},
std::array<float,2>{0.780096412f, 0.975229979f},
std::array<float,2>{0.366320282f, 0.232120216f},
std::array<float,2>{0.021554647f, 0.724976361f},
std::array<float,2>{0.535907269f, 0.350257844f},
std::array<float,2>{0.716087759f, 0.580086946f},
std::array<float,2>{0.154407412f, 0.412387788f},
std::array<float,2>{0.489122331f, 0.873182356f},
std::array<float,2>{0.911601961f, 0.117673129f},
std::array<float,2>{0.83711803f, 0.528824151f},
std::array<float,2>{0.276165128f, 0.481787503f},
std::array<float,2>{0.101723656f, 0.788532615f},
std::array<float,2>{0.597329676f, 0.0591281243f},
std::array<float,2>{0.673732162f, 0.888265312f},
std::array<float,2>{0.236332163f, 0.156258911f},
std::array<float,2>{0.3850528f, 0.665003538f},
std::array<float,2>{0.998148739f, 0.279324859f},
std::array<float,2>{0.881002963f, 0.820771158f},
std::array<float,2>{0.44967398f, 0.0741979256f},
std::array<float,2>{0.187018618f, 0.600337029f},
std::array<float,2>{0.735068858f, 0.400525004f},
std::array<float,2>{0.518027723f, 0.70270735f},
std::array<float,2>{0.0566015281f, 0.340446413f},
std::array<float,2>{0.321685225f, 0.942391992f},
std::array<float,2>{0.782514036f, 0.189838484f},
std::array<float,2>{0.986190319f, 0.55288285f},
std::array<float,2>{0.37788862f, 0.457083762f},
std::array<float,2>{0.245652974f, 0.769528151f},
std::array<float,2>{0.685527027f, 0.0195149053f},
std::array<float,2>{0.602793813f, 0.917524755f},
std::array<float,2>{0.0995475203f, 0.126008347f},
std::array<float,2>{0.269855946f, 0.646676242f},
std::array<float,2>{0.83033824f, 0.28264311f},
std::array<float,2>{0.793889403f, 0.866743863f},
std::array<float,2>{0.318215042f, 0.112850256f},
std::array<float,2>{0.0488213226f, 0.589967668f},
std::array<float,2>{0.528714597f, 0.416097969f},
std::array<float,2>{0.74972105f, 0.731434822f},
std::array<float,2>{0.177709132f, 0.357521504f},
std::array<float,2>{0.442298055f, 0.979417264f},
std::array<float,2>{0.887980163f, 0.223624647f},
std::array<float,2>{0.84953618f, 0.660070598f},
std::array<float,2>{0.298874766f, 0.270274103f},
std::array<float,2>{0.0671889782f, 0.877122819f},
std::array<float,2>{0.572628736f, 0.1695088f},
std::array<float,2>{0.654428482f, 0.792066038f},
std::array<float,2>{0.192727625f, 0.0479274951f},
std::array<float,2>{0.407495677f, 0.517060876f},
std::array<float,2>{0.959056377f, 0.472226024f},
std::array<float,2>{0.914780259f, 0.94573164f},
std::array<float,2>{0.498098135f, 0.196892291f},
std::array<float,2>{0.144092128f, 0.692338705f},
std::array<float,2>{0.706054211f, 0.333173335f},
std::array<float,2>{0.545150697f, 0.604058444f},
std::array<float,2>{0.0294580534f, 0.397601813f},
std::array<float,2>{0.374838352f, 0.820249915f},
std::array<float,2>{0.770544529f, 0.0636710897f},
std::array<float,2>{0.897363245f, 0.704574108f},
std::array<float,2>{0.463409066f, 0.31272167f},
std::array<float,2>{0.17142424f, 0.956502557f},
std::array<float,2>{0.731540084f, 0.209859297f},
std::array<float,2>{0.512026489f, 0.830738485f},
std::array<float,2>{0.0411067382f, 0.0820994377f},
std::array<float,2>{0.33232671f, 0.617727518f},
std::array<float,2>{0.811452568f, 0.38764149f},
std::array<float,2>{0.814304769f, 0.895573974f},
std::array<float,2>{0.259392112f, 0.184403136f},
std::array<float,2>{0.114288211f, 0.675402939f},
std::array<float,2>{0.619407296f, 0.26386258f},
std::array<float,2>{0.663242936f, 0.502195299f},
std::array<float,2>{0.227387294f, 0.490081519f},
std::array<float,2>{0.390830547f, 0.802897513f},
std::array<float,2>{0.983288109f, 0.0407639779f},
std::array<float,2>{0.752616286f, 0.57665813f},
std::array<float,2>{0.343831301f, 0.434533745f},
std::array<float,2>{0.00636494579f, 0.852711797f},
std::array<float,2>{0.548779964f, 0.10712596f},
std::array<float,2>{0.690791965f, 0.992072344f},
std::array<float,2>{0.140016139f, 0.242189273f},
std::array<float,2>{0.478901744f, 0.735153377f},
std::array<float,2>{0.928993642f, 0.36556524f},
std::array<float,2>{0.9382146f, 0.75284487f},
std::array<float,2>{0.429151982f, 0.0111891739f},
std::array<float,2>{0.211467788f, 0.540977001f},
std::array<float,2>{0.628780782f, 0.441521198f},
std::array<float,2>{0.591847003f, 0.626342654f},
std::array<float,2>{0.0816342384f, 0.298924237f},
std::array<float,2>{0.282738447f, 0.937388539f},
std::array<float,2>{0.869645238f, 0.147156224f},
std::array<float,2>{0.947506905f, 0.586655259f},
std::array<float,2>{0.437013656f, 0.420310467f},
std::array<float,2>{0.208163664f, 0.86094594f},
std::array<float,2>{0.634548724f, 0.114762925f},
std::array<float,2>{0.585372806f, 0.982242107f},
std::array<float,2>{0.093533434f, 0.220565796f},
std::array<float,2>{0.28960833f, 0.727113307f},
std::array<float,2>{0.865712166f, 0.35420391f},
std::array<float,2>{0.76027745f, 0.771604836f},
std::array<float,2>{0.353663802f, 0.0211596172f},
std::array<float,2>{0.0126825087f, 0.547189653f},
std::array<float,2>{0.558772445f, 0.455483764f},
std::array<float,2>{0.701868415f, 0.641836226f},
std::array<float,2>{0.130583763f, 0.288694113f},
std::array<float,2>{0.475562334f, 0.921691477f},
std::array<float,2>{0.930388093f, 0.12890932f},
std::array<float,2>{0.827854335f, 0.688581526f},
std::array<float,2>{0.250863582f, 0.329604864f},
std::array<float,2>{0.117498197f, 0.949562728f},
std::array<float,2>{0.616246998f, 0.202684864f},
std::array<float,2>{0.665334523f, 0.816069722f},
std::array<float,2>{0.223144159f, 0.0689937025f},
std::array<float,2>{0.403595507f, 0.60604465f},
std::array<float,2>{0.975694895f, 0.392160863f},
std::array<float,2>{0.899283171f, 0.880848408f},
std::array<float,2>{0.45522815f, 0.165349215f},
std::array<float,2>{0.163311034f, 0.661554277f},
std::array<float,2>{0.725785375f, 0.268473446f},
std::array<float,2>{0.500880539f, 0.522797108f},
std::array<float,2>{0.0389760882f, 0.474172413f},
std::array<float,2>{0.337439448f, 0.796105623f},
std::array<float,2>{0.803014636f, 0.051191207f},
std::array<float,2>{0.907491505f, 0.679547429f},
std::array<float,2>{0.487415016f, 0.261089981f},
std::array<float,2>{0.149743676f, 0.894329906f},
std::array<float,2>{0.713928521f, 0.180236101f},
std::array<float,2>{0.531399667f, 0.797811866f},
std::array<float,2>{0.0194904152f, 0.0434367135f},
std::array<float,2>{0.360211164f, 0.506502748f},
std::array<float,2>{0.773709118f, 0.487733722f},
std::array<float,2>{0.859321296f, 0.958902538f},
std::array<float,2>{0.3113527f, 0.205502763f},
std::array<float,2>{0.0706558451f, 0.708027184f},
std::array<float,2>{0.564884126f, 0.320291072f},
std::array<float,2>{0.644314051f, 0.624440253f},
std::array<float,2>{0.202362061f, 0.383392036f},
std::array<float,2>{0.418864429f, 0.832162976f},
std::array<float,2>{0.966800272f, 0.0813766792f},
std::array<float,2>{0.786314726f, 0.544354141f},
std::array<float,2>{0.327882916f, 0.439688474f},
std::array<float,2>{0.0614423491f, 0.756090164f},
std::array<float,2>{0.523305893f, 0.0130125359f},
std::array<float,2>{0.741883874f, 0.929694414f},
std::array<float,2>{0.181936845f, 0.142530203f},
std::array<float,2>{0.445635617f, 0.63265121f},
std::array<float,2>{0.875498652f, 0.304679394f},
std::array<float,2>{0.993725061f, 0.856168926f},
std::array<float,2>{0.387100458f, 0.104953147f},
std::array<float,2>{0.240080044f, 0.571192801f},
std::array<float,2>{0.679358065f, 0.433287263f},
std::array<float,2>{0.598314643f, 0.739967704f},
std::array<float,2>{0.106512181f, 0.362425804f},
std::array<float,2>{0.277507871f, 0.985383391f},
std::array<float,2>{0.843440771f, 0.246871755f},
std::array<float,2>{0.883890212f, 0.50985837f},
std::array<float,2>{0.438132048f, 0.493715465f},
std::array<float,2>{0.173843637f, 0.808417439f},
std::array<float,2>{0.742862225f, 0.0313736834f},
std::array<float,2>{0.524438024f, 0.903967142f},
std::array<float,2>{0.05428572f, 0.172257632f},
std::array<float,2>{0.315800726f, 0.681716919f},
std::array<float,2>{0.789790392f, 0.250993997f},
std::array<float,2>{0.832771957f, 0.837012529f},
std::array<float,2>{0.265777647f, 0.0902145579f},
std::array<float,2>{0.097469233f, 0.610468209f},
std::array<float,2>{0.609001696f, 0.379170865f},
std::array<float,2>{0.681462646f, 0.712705016f},
std::array<float,2>{0.246866748f, 0.32641688f},
std::array<float,2>{0.381925017f, 0.96859324f},
std::array<float,2>{0.990759432f, 0.218273893f},
std::array<float,2>{0.766855359f, 0.634913445f},
std::array<float,2>{0.370334834f, 0.311515063f},
std::array<float,2>{0.0238466393f, 0.929082334f},
std::array<float,2>{0.539855123f, 0.150995091f},
std::array<float,2>{0.710274339f, 0.760873616f},
std::array<float,2>{0.147103786f, 0.00691457791f},
std::array<float,2>{0.496064484f, 0.535495162f},
std::array<float,2>{0.918097794f, 0.44953531f},
std::array<float,2>{0.956021249f, 0.997815728f},
std::array<float,2>{0.411656946f, 0.235595033f},
std::array<float,2>{0.189216852f, 0.743186653f},
std::array<float,2>{0.648544788f, 0.374512732f},
std::array<float,2>{0.575973213f, 0.569893956f},
std::array<float,2>{0.062955223f, 0.425030679f},
std::array<float,2>{0.301315993f, 0.84979856f},
std::array<float,2>{0.846872449f, 0.0974186584f},
std::array<float,2>{0.979247153f, 0.720100045f},
std::array<float,2>{0.396638662f, 0.346591026f},
std::array<float,2>{0.23268564f, 0.969360232f},
std::array<float,2>{0.657692313f, 0.229059502f},
std::array<float,2>{0.6222139f, 0.868782043f},
std::array<float,2>{0.112032637f, 0.123690128f},
std::array<float,2>{0.262804657f, 0.584813058f},
std::array<float,2>{0.818962991f, 0.409056544f},
std::array<float,2>{0.808369279f, 0.911770642f},
std::array<float,2>{0.328509837f, 0.139937505f},
std::array<float,2>{0.0447684117f, 0.652114034f},
std::array<float,2>{0.511410534f, 0.293875694f},
std::array<float,2>{0.728074074f, 0.557115316f},
std::array<float,2>{0.167102754f, 0.466255158f},
std::array<float,2>{0.467532307f, 0.773671985f},
std::array<float,2>{0.891369462f, 0.0301295165f},
std::array<float,2>{0.873862624f, 0.594104946f},
std::array<float,2>{0.285885692f, 0.403513253f},
std::array<float,2>{0.083445251f, 0.825577736f},
std::array<float,2>{0.587524295f, 0.0776079148f},
std::array<float,2>{0.632734776f, 0.938824415f},
std::array<float,2>{0.21517089f, 0.193481162f},
std::array<float,2>{0.422556758f, 0.695375919f},
std::array<float,2>{0.941469908f, 0.337056816f},
std::array<float,2>{0.925032794f, 0.785110593f},
std::array<float,2>{0.480643541f, 0.0582740419f},
std::array<float,2>{0.136407599f, 0.525716007f},
std::array<float,2>{0.692888141f, 0.479415864f},
std::array<float,2>{0.554212451f, 0.670757592f},
std::array<float,2>{0.00324188871f, 0.277162075f},
std::array<float,2>{0.349679917f, 0.886311233f},
std::array<float,2>{0.75618577f, 0.163078532f},
std::array<float,2>{0.90283519f, 0.565839767f},
std::array<float,2>{0.459459901f, 0.428555459f},
std::array<float,2>{0.158078954f, 0.84467411f},
std::array<float,2>{0.721886575f, 0.0997586176f},
std::array<float,2>{0.504606426f, 0.992998481f},
std::array<float,2>{0.0332584605f, 0.238380417f},
std::array<float,2>{0.341706634f, 0.747102559f},
std::array<float,2>{0.797323585f, 0.368553936f},
std::array<float,2>{0.822400272f, 0.762617946f},
std::array<float,2>{0.256800622f, 0.00247471617f},
std::array<float,2>{0.12319953f, 0.534101605f},
std::array<float,2>{0.610558867f, 0.446234703f},
std::array<float,2>{0.670561075f, 0.638066947f},
std::array<float,2>{0.220755607f, 0.307946473f},
std::array<float,2>{0.398772269f, 0.922187805f},
std::array<float,2>{0.969111383f, 0.152381986f},
std::array<float,2>{0.762320578f, 0.715254188f},
std::array<float,2>{0.357796103f, 0.323622376f},
std::array<float,2>{0.0105327526f, 0.962710023f},
std::array<float,2>{0.556152463f, 0.212774128f},
std::array<float,2>{0.695402384f, 0.843608379f},
std::array<float,2>{0.127650321f, 0.0865200609f},
std::array<float,2>{0.471391857f, 0.615310311f},
std::array<float,2>{0.934612393f, 0.376073211f},
std::array<float,2>{0.951975226f, 0.900123596f},
std::array<float,2>{0.430832148f, 0.178239703f},
std::array<float,2>{0.206907988f, 0.687008321f},
std::array<float,2>{0.640452445f, 0.257166535f},
std::array<float,2>{0.578163266f, 0.512738764f},
std::array<float,2>{0.0872437283f, 0.497499466f},
std::array<float,2>{0.293806851f, 0.808903873f},
std::array<float,2>{0.860460877f, 0.0369685516f},
std::array<float,2>{0.996893823f, 0.666375756f},
std::array<float,2>{0.38387394f, 0.278535873f},
std::array<float,2>{0.235020801f, 0.889715731f},
std::array<float,2>{0.674787343f, 0.159480333f},
std::array<float,2>{0.593896866f, 0.785937071f},
std::array<float,2>{0.103537522f, 0.0616959892f},
std::array<float,2>{0.27492097f, 0.530255079f},
std::array<float,2>{0.839180171f, 0.484088629f},
std::array<float,2>{0.783939421f, 0.944980085f},
std::array<float,2>{0.322939843f, 0.189198002f},
std::array<float,2>{0.0584357977f, 0.700292826f},
std::array<float,2>{0.51644522f, 0.342880338f},
std::array<float,2>{0.736995459f, 0.599573612f},
std::array<float,2>{0.18450585f, 0.399092287f},
std::array<float,2>{0.451246262f, 0.824104667f},
std::array<float,2>{0.880711377f, 0.0716264471f},
std::array<float,2>{0.855463147f, 0.561438084f},
std::array<float,2>{0.308501065f, 0.463814795f},
std::array<float,2>{0.0774049163f, 0.779458582f},
std::array<float,2>{0.568421423f, 0.026285952f},
std::array<float,2>{0.646270514f, 0.90824616f},
std::array<float,2>{0.196787491f, 0.135083959f},
std::array<float,2>{0.416695029f, 0.655778408f},
std::array<float,2>{0.96433866f, 0.290147156f},
std::array<float,2>{0.912636042f, 0.871525347f},
std::array<float,2>{0.491068006f, 0.120504402f},
std::array<float,2>{0.153487861f, 0.579621434f},
std::array<float,2>{0.717687428f, 0.411929369f},
std::array<float,2>{0.538902283f, 0.723629773f},
std::array<float,2>{0.0197889879f, 0.348030627f},
std::array<float,2>{0.364258111f, 0.972864032f},
std::array<float,2>{0.778781772f, 0.232933849f},
std::array<float,2>{0.957608163f, 0.519517481f},
std::array<float,2>{0.410054952f, 0.468795389f},
std::array<float,2>{0.194498748f, 0.789349794f},
std::array<float,2>{0.65369916f, 0.0507577956f},
std::array<float,2>{0.571752429f, 0.876649439f},
std::array<float,2>{0.0692964867f, 0.171383888f},
std::array<float,2>{0.298406899f, 0.657604218f},
std::array<float,2>{0.850485265f, 0.272219211f},
std::array<float,2>{0.773199499f, 0.817067802f},
std::array<float,2>{0.371461272f, 0.0661933869f},
std::array<float,2>{0.0277756136f, 0.601935923f},
std::array<float,2>{0.544752896f, 0.394565642f},
std::array<float,2>{0.703199685f, 0.694097638f},
std::array<float,2>{0.141417667f, 0.33430472f},
std::array<float,2>{0.496295422f, 0.948657334f},
std::array<float,2>{0.91646421f, 0.197719619f},
std::array<float,2>{0.828880668f, 0.644609451f},
std::array<float,2>{0.272327065f, 0.284359843f},
std::array<float,2>{0.100261107f, 0.914764881f},
std::array<float,2>{0.60492909f, 0.127084538f},
std::array<float,2>{0.68660146f, 0.765825987f},
std::array<float,2>{0.242823571f, 0.0158706903f},
std::array<float,2>{0.375177205f, 0.551414788f},
std::array<float,2>{0.988272965f, 0.459981889f},
std::array<float,2>{0.889146924f, 0.97702831f},
std::array<float,2>{0.443905056f, 0.225493267f},
std::array<float,2>{0.178187236f, 0.733827472f},
std::array<float,2>{0.747458756f, 0.356737107f},
std::array<float,2>{0.529584229f, 0.59224683f},
std::array<float,2>{0.0489628166f, 0.415896446f},
std::array<float,2>{0.320081294f, 0.865180671f},
std::array<float,2>{0.795196593f, 0.110995777f},
std::array<float,2>{0.92628938f, 0.737038553f},
std::array<float,2>{0.477238178f, 0.363549054f},
std::array<float,2>{0.138024196f, 0.988888562f},
std::array<float,2>{0.688844323f, 0.245286375f},
std::array<float,2>{0.549039185f, 0.854938924f},
std::array<float,2>{0.00426907837f, 0.109235682f},
std::array<float,2>{0.345869631f, 0.574785173f},
std::array<float,2>{0.750590622f, 0.436304808f},
std::array<float,2>{0.868768334f, 0.934809506f},
std::array<float,2>{0.283314556f, 0.145810112f},
std::array<float,2>{0.0792480111f, 0.627056777f},
std::array<float,2>{0.591538489f, 0.297778845f},
std::array<float,2>{0.625013113f, 0.542077005f},
std::array<float,2>{0.213345066f, 0.443402529f},
std::array<float,2>{0.427355707f, 0.750353932f},
std::array<float,2>{0.940099478f, 0.00793190766f},
std::array<float,2>{0.810065389f, 0.619200766f},
std::array<float,2>{0.3346982f, 0.390371442f},
std::array<float,2>{0.0393962301f, 0.830056846f},
std::array<float,2>{0.514674127f, 0.0847209468f},
std::array<float,2>{0.733889878f, 0.953643441f},
std::array<float,2>{0.168224096f, 0.207601279f},
std::array<float,2>{0.461061388f, 0.705374777f},
std::array<float,2>{0.895946622f, 0.31550613f},
std::array<float,2>{0.981122315f, 0.80088222f},
std::array<float,2>{0.394354731f, 0.0426126681f},
std::array<float,2>{0.228774548f, 0.50124383f},
std::array<float,2>{0.660533249f, 0.491012633f},
std::array<float,2>{0.61853236f, 0.673092663f},
std::array<float,2>{0.116208859f, 0.262471855f},
std::array<float,2>{0.261620194f, 0.896953881f},
std::array<float,2>{0.814838231f, 0.185767487f},
std::array<float,2>{0.973578691f, 0.609240532f},
std::array<float,2>{0.404887021f, 0.394087911f},
std::array<float,2>{0.225068524f, 0.812772274f},
std::array<float,2>{0.666617095f, 0.0671844855f},
std::array<float,2>{0.615208268f, 0.951332569f},
std::array<float,2>{0.120513521f, 0.200364217f},
std::array<float,2>{0.252060294f, 0.690843046f},
std::array<float,2>{0.825496137f, 0.331310719f},
std::array<float,2>{0.801940799f, 0.794153869f},
std::array<float,2>{0.339787781f, 0.0538185239f},
std::array<float,2>{0.0367762223f, 0.521369994f},
std::array<float,2>{0.50365001f, 0.475171387f},
std::array<float,2>{0.724148929f, 0.662685513f},
std::array<float,2>{0.161342859f, 0.266971052f},
std::array<float,2>{0.454412252f, 0.881032348f},
std::array<float,2>{0.901035845f, 0.166410863f},
std::array<float,2>{0.864793599f, 0.729426205f},
std::array<float,2>{0.292488128f, 0.352401733f},
std::array<float,2>{0.0909711272f, 0.983059645f},
std::array<float,2>{0.582380176f, 0.221690729f},
std::array<float,2>{0.635584712f, 0.861908853f},
std::array<float,2>{0.209857926f, 0.115407102f},
std::array<float,2>{0.433802009f, 0.588233173f},
std::array<float,2>{0.946513534f, 0.418235958f},
std::array<float,2>{0.933277309f, 0.918318689f},
std::array<float,2>{0.474281043f, 0.131658733f},
std::array<float,2>{0.132653326f, 0.643415868f},
std::array<float,2>{0.699466288f, 0.286457658f},
std::array<float,2>{0.562056959f, 0.549114227f},
std::array<float,2>{0.0152163114f, 0.454519421f},
std::array<float,2>{0.35339886f, 0.771069765f},
std::array<float,2>{0.759615123f, 0.0221079662f},
std::array<float,2>{0.877379775f, 0.630316257f},
std::array<float,2>{0.449014246f, 0.302659154f},
std::array<float,2>{0.180756941f, 0.931707203f},
std::array<float,2>{0.739760697f, 0.143600926f},
std::array<float,2>{0.519545972f, 0.755093873f},
std::array<float,2>{0.0599030443f, 0.0137678254f},
std::array<float,2>{0.324538052f, 0.54492712f},
std::array<float,2>{0.787182212f, 0.437930822f},
std::array<float,2>{0.841055989f, 0.987145722f},
std::array<float,2>{0.281087339f, 0.249193892f},
std::array<float,2>{0.107511565f, 0.740253091f},
std::array<float,2>{0.600048304f, 0.35963434f},
std::array<float,2>{0.677551031f, 0.572740853f},
std::array<float,2>{0.241332948f, 0.430150867f},
std::array<float,2>{0.388855278f, 0.858998477f},
std::array<float,2>{0.995688796f, 0.103092268f},
std::array<float,2>{0.776747048f, 0.504152656f},
std::array<float,2>{0.361333877f, 0.485845089f},
std::array<float,2>{0.0165137611f, 0.79980582f},
std::array<float,2>{0.535110533f, 0.0467040427f},
std::array<float,2>{0.71196872f, 0.892245054f},
std::array<float,2>{0.151982844f, 0.18299593f},
std::array<float,2>{0.485043168f, 0.677076399f},
std::array<float,2>{0.908217549f, 0.259420931f},
std::array<float,2>{0.965240777f, 0.834642828f},
std::array<float,2>{0.42090705f, 0.0782870874f},
std::array<float,2>{0.200329408f, 0.622442007f},
std::array<float,2>{0.642371058f, 0.385241091f},
std::array<float,2>{0.563331127f, 0.710822642f},
std::array<float,2>{0.0723269209f, 0.31810075f},
std::array<float,2>{0.309694588f, 0.959894121f},
std::array<float,2>{0.855741084f, 0.20492585f},
std::array<float,2>{0.920669198f, 0.537113547f},
std::array<float,2>{0.493902892f, 0.452040434f},
std::array<float,2>{0.145288676f, 0.758396029f},
std::array<float,2>{0.708781064f, 0.00574908033f},
std::array<float,2>{0.541137457f, 0.927365661f},
std::array<float,2>{0.0273306444f, 0.150007144f},
std::array<float,2>{0.367230177f, 0.634533226f},
std::array<float,2>{0.768954635f, 0.308753043f},
std::array<float,2>{0.844316959f, 0.848338783f},
std::array<float,2>{0.304670572f, 0.095416382f},
std::array<float,2>{0.0658798367f, 0.566795349f},
std::array<float,2>{0.576232255f, 0.423552662f},
std::array<float,2>{0.651681423f, 0.745150149f},
std::array<float,2>{0.191338688f, 0.372570425f},
std::array<float,2>{0.412227392f, 0.999998391f},
std::array<float,2>{0.953251243f, 0.236588299f},
std::array<float,2>{0.79148525f, 0.680960536f},
std::array<float,2>{0.314180881f, 0.252518058f},
std::array<float,2>{0.0513494499f, 0.905902445f},
std::array<float,2>{0.526619792f, 0.175329536f},
std::array<float,2>{0.744952142f, 0.805916786f},
std::array<float,2>{0.172655553f, 0.0347998366f},
std::array<float,2>{0.439772725f, 0.509299994f},
std::array<float,2>{0.88654685f, 0.49473238f},
std::array<float,2>{0.98937571f, 0.96590215f},
std::array<float,2>{0.378978819f, 0.216668248f},
std::array<float,2>{0.24995102f, 0.713392913f},
std::array<float,2>{0.683579206f, 0.324509978f},
std::array<float,2>{0.605533838f, 0.612687945f},
std::array<float,2>{0.0953565687f, 0.381446004f},
std::array<float,2>{0.26925987f, 0.838422477f},
std::array<float,2>{0.834255278f, 0.0933164507f},
std::array<float,2>{0.94439131f, 0.697814107f},
std::array<float,2>{0.424387217f, 0.339245319f},
std::array<float,2>{0.216927066f, 0.940243065f},
std::array<float,2>{0.630463004f, 0.193276554f},
std::array<float,2>{0.589547396f, 0.827601373f},
std::array<float,2>{0.0850996003f, 0.0751772895f},
std::array<float,2>{0.287324727f, 0.596765637f},
std::array<float,2>{0.871686399f, 0.405749798f},
std::array<float,2>{0.755227029f, 0.883875489f},
std::array<float,2>{0.347660542f, 0.160198838f},
std::array<float,2>{0.00168672169f, 0.66866672f},
std::array<float,2>{0.552232325f, 0.273567319f},
std::array<float,2>{0.693947792f, 0.525114119f},
std::array<float,2>{0.132922083f, 0.478231043f},
std::array<float,2>{0.483507484f, 0.782787263f},
std::array<float,2>{0.922502518f, 0.0557880104f},
std::array<float,2>{0.817750037f, 0.582309544f},
std::array<float,2>{0.263900787f, 0.407731682f},
std::array<float,2>{0.110633932f, 0.869668007f},
std::array<float,2>{0.624191701f, 0.121400081f},
std::array<float,2>{0.65900892f, 0.972475708f},
std::array<float,2>{0.231933802f, 0.22740069f},
std::array<float,2>{0.395695955f, 0.721309662f},
std::array<float,2>{0.978483796f, 0.344271302f},
std::array<float,2>{0.89277333f, 0.775682926f},
std::array<float,2>{0.466615885f, 0.0279284567f},
std::array<float,2>{0.165209666f, 0.555696189f},
std::array<float,2>{0.729564428f, 0.468602836f},
std::array<float,2>{0.50864625f, 0.649326861f},
std::array<float,2>{0.0452848077f, 0.29618448f},
std::array<float,2>{0.330631524f, 0.912973583f},
std::array<float,2>{0.805432677f, 0.137886301f},
std::array<float,2>{0.919713557f, 0.566412508f},
std::array<float,2>{0.495000869f, 0.423651397f},
std::array<float,2>{0.147823229f, 0.848590314f},
std::array<float,2>{0.70936197f, 0.0955991f},
std::array<float,2>{0.540510654f, 0.999619722f},
std::array<float,2>{0.0249237865f, 0.236421183f},
std::array<float,2>{0.369276762f, 0.745565295f},
std::array<float,2>{0.766581833f, 0.372980356f},
std::array<float,2>{0.846280813f, 0.758548558f},
std::array<float,2>{0.302138865f, 0.0055760988f},
std::array<float,2>{0.0636121407f, 0.537459791f},
std::array<float,2>{0.574985981f, 0.451672524f},
std::array<float,2>{0.650071979f, 0.634421885f},
std::array<float,2>{0.188448563f, 0.308895737f},
std::array<float,2>{0.410571188f, 0.927719116f},
std::array<float,2>{0.956694126f, 0.150189504f},
std::array<float,2>{0.790218949f, 0.713816047f},
std::array<float,2>{0.314536482f, 0.324412882f},
std::array<float,2>{0.052801732f, 0.966254294f},
std::array<float,2>{0.524161458f, 0.216543153f},
std::array<float,2>{0.743370235f, 0.838657677f},
std::array<float,2>{0.175452083f, 0.0937269405f},
std::array<float,2>{0.439230829f, 0.612381876f},
std::array<float,2>{0.883232772f, 0.381810755f},
std::array<float,2>{0.991957009f, 0.906130075f},
std::array<float,2>{0.381575942f, 0.175659761f},
std::array<float,2>{0.247109741f, 0.680830479f},
std::array<float,2>{0.679926455f, 0.252838671f},
std::array<float,2>{0.608390808f, 0.509757876f},
std::array<float,2>{0.0960728452f, 0.494911462f},
std::array<float,2>{0.266862124f, 0.805761039f},
std::array<float,2>{0.833982289f, 0.0351311602f},
std::array<float,2>{0.943259776f, 0.668831468f},
std::array<float,2>{0.423272699f, 0.273831487f},
std::array<float,2>{0.216226786f, 0.884203494f},
std::array<float,2>{0.631196201f, 0.160594314f},
std::array<float,2>{0.585982859f, 0.783116102f},
std::array<float,2>{0.0823496506f, 0.0560284778f},
std::array<float,2>{0.286893666f, 0.525327504f},
std::array<float,2>{0.874546826f, 0.47844106f},
std::array<float,2>{0.757365763f, 0.940019786f},
std::array<float,2>{0.350696087f, 0.192963973f},
std::array<float,2>{0.00268208212f, 0.698211074f},
std::array<float,2>{0.553231537f, 0.338964015f},
std::array<float,2>{0.692211986f, 0.596942186f},
std::array<float,2>{0.135094166f, 0.405424654f},
std::array<float,2>{0.482176572f, 0.827274442f},
std::array<float,2>{0.924763322f, 0.0747396797f},
std::array<float,2>{0.819956601f, 0.555949986f},
std::array<float,2>{0.261751711f, 0.468262762f},
std::array<float,2>{0.112671472f, 0.775523007f},
std::array<float,2>{0.621830761f, 0.0282573123f},
std::array<float,2>{0.656689465f, 0.912678242f},
std::array<float,2>{0.234038249f, 0.138104498f},
std::array<float,2>{0.398291856f, 0.649127305f},
std::array<float,2>{0.980408788f, 0.295913994f},
std::array<float,2>{0.892294347f, 0.870114684f},
std::array<float,2>{0.468213469f, 0.121282935f},
std::array<float,2>{0.166651815f, 0.582228661f},
std::array<float,2>{0.726764023f, 0.40819186f},
std::array<float,2>{0.510166347f, 0.721566498f},
std::array<float,2>{0.0431879573f, 0.344671696f},
std::array<float,2>{0.329681754f, 0.972295582f},
std::array<float,2>{0.806800544f, 0.227178231f},
std::array<float,2>{0.975229681f, 0.521011114f},
std::array<float,2>{0.402874887f, 0.475554794f},
std::array<float,2>{0.224100932f, 0.794290066f},
std::array<float,2>{0.66459614f, 0.0540005043f},
std::array<float,2>{0.616066396f, 0.881128848f},
std::array<float,2>{0.118923016f, 0.166135535f},
std::array<float,2>{0.25135088f, 0.663073421f},
std::array<float,2>{0.826787174f, 0.266613901f},
std::array<float,2>{0.804432392f, 0.812517941f},
std::array<float,2>{0.336864293f, 0.0669622049f},
std::array<float,2>{0.0377643928f, 0.609027863f},
std::array<float,2>{0.501042426f, 0.394309551f},
std::array<float,2>{0.724793911f, 0.690651596f},
std::array<float,2>{0.162747607f, 0.331268311f},
std::array<float,2>{0.456596643f, 0.951602936f},
std::array<float,2>{0.900380611f, 0.20052129f},
std::array<float,2>{0.86651206f, 0.64314419f},
std::array<float,2>{0.290524483f, 0.2862477f},
std::array<float,2>{0.0926457793f, 0.918207586f},
std::array<float,2>{0.584511876f, 0.13141796f},
std::array<float,2>{0.633182168f, 0.771422565f},
std::array<float,2>{0.207599625f, 0.0222856086f},
std::array<float,2>{0.435997128f, 0.549049914f},
std::array<float,2>{0.948257565f, 0.454267561f},
std::array<float,2>{0.930720448f, 0.983305395f},
std::array<float,2>{0.476219952f, 0.222025812f},
std::array<float,2>{0.129408598f, 0.729024291f},
std::array<float,2>{0.702298045f, 0.352200955f},
std::array<float,2>{0.559981346f, 0.587999344f},
std::array<float,2>{0.0129294321f, 0.417977452f},
std::array<float,2>{0.354745567f, 0.862065017f},
std::array<float,2>{0.760747135f, 0.115717746f},
std::array<float,2>{0.876304209f, 0.740667701f},
std::array<float,2>{0.446717709f, 0.359581739f},
std::array<float,2>{0.183577701f, 0.98682338f},
std::array<float,2>{0.74080658f, 0.249338791f},
std::array<float,2>{0.521834791f, 0.859229207f},
std::array<float,2>{0.0617308542f, 0.103403464f},
std::array<float,2>{0.32652843f, 0.572276652f},
std::array<float,2>{0.785820305f, 0.429775178f},
std::array<float,2>{0.841800392f, 0.931898296f},
std::array<float,2>{0.27859661f, 0.143992513f},
std::array<float,2>{0.106035993f, 0.629889011f},
std::array<float,2>{0.598954201f, 0.302338332f},
std::array<float,2>{0.678060412f, 0.54519707f},
std::array<float,2>{0.23884815f, 0.437736958f},
std::array<float,2>{0.388442785f, 0.755363166f},
std::array<float,2>{0.992527485f, 0.0139950952f},
std::array<float,2>{0.774892271f, 0.622127116f},
std::array<float,2>{0.36045593f, 0.384781241f},
std::array<float,2>{0.0184565075f, 0.834784865f},
std::array<float,2>{0.532618701f, 0.0784134045f},
std::array<float,2>{0.713623166f, 0.95954144f},
std::array<float,2>{0.148758858f, 0.20471023f},
std::array<float,2>{0.486772448f, 0.710662484f},
std::array<float,2>{0.90683651f, 0.318138748f},
std::array<float,2>{0.968622386f, 0.800111413f},
std::array<float,2>{0.419137299f, 0.0464225076f},
std::array<float,2>{0.201286092f, 0.504064143f},
std::array<float,2>{0.643148959f, 0.48612386f},
std::array<float,2>{0.565816402f, 0.676982462f},
std::array<float,2>{0.0722117275f, 0.259610653f},
std::array<float,2>{0.311937928f, 0.892489672f},
std::array<float,2>{0.857875824f, 0.182763293f},
std::array<float,2>{0.960231304f, 0.601672649f},
std::array<float,2>{0.407107979f, 0.394818932f},
std::array<float,2>{0.192366317f, 0.817229807f},
std::array<float,2>{0.655356169f, 0.0660827756f},
std::array<float,2>{0.574057758f, 0.948456466f},
std::array<float,2>{0.0676009357f, 0.197286978f},
std::array<float,2>{0.300751746f, 0.693870485f},
std::array<float,2>{0.84803462f, 0.334033549f},
std::array<float,2>{0.770434439f, 0.789097607f},
std::array<float,2>{0.373879969f, 0.0503688045f},
std::array<float,2>{0.0310447421f, 0.519104123f},
std::array<float,2>{0.545904696f, 0.469079047f},
std::array<float,2>{0.706222773f, 0.657444715f},
std::array<float,2>{0.143415198f, 0.272199452f},
std::array<float,2>{0.499622524f, 0.876897395f},
std::array<float,2>{0.915248573f, 0.171061456f},
std::array<float,2>{0.831812024f, 0.733638108f},
std::array<float,2>{0.271335214f, 0.356517762f},
std::array<float,2>{0.0981565863f, 0.976605356f},
std::array<float,2>{0.601569772f, 0.225220054f},
std::array<float,2>{0.684465885f, 0.864750624f},
std::array<float,2>{0.244923323f, 0.111164056f},
std::array<float,2>{0.378666341f, 0.592014074f},
std::array<float,2>{0.98488611f, 0.415621698f},
std::array<float,2>{0.887460351f, 0.91483891f},
std::array<float,2>{0.442579746f, 0.127215222f},
std::array<float,2>{0.176192209f, 0.644833684f},
std::array<float,2>{0.748120487f, 0.284605652f},
std::array<float,2>{0.528009117f, 0.551713884f},
std::array<float,2>{0.0469697863f, 0.460341722f},
std::array<float,2>{0.317200154f, 0.765976608f},
std::array<float,2>{0.794882476f, 0.0156607945f},
std::array<float,2>{0.928138316f, 0.62719959f},
std::array<float,2>{0.479765415f, 0.29744795f},
std::array<float,2>{0.139499947f, 0.93491751f},
std::array<float,2>{0.689786971f, 0.14574188f},
std::array<float,2>{0.547807097f, 0.750037134f},
std::array<float,2>{0.00741693377f, 0.00821428467f},
std::array<float,2>{0.345368385f, 0.542292655f},
std::array<float,2>{0.753684223f, 0.44369176f},
std::array<float,2>{0.870647192f, 0.989181995f},
std::array<float,2>{0.281445324f, 0.245424479f},
std::array<float,2>{0.0806020275f, 0.737077951f},
std::array<float,2>{0.592831492f, 0.363482982f},
std::array<float,2>{0.627476335f, 0.575149179f},
std::array<float,2>{0.212714732f, 0.436091363f},
std::array<float,2>{0.42810303f, 0.854513168f},
std::array<float,2>{0.938842356f, 0.109016344f},
std::array<float,2>{0.811647356f, 0.501165569f},
std::array<float,2>{0.333094269f, 0.490763694f},
std::array<float,2>{0.0427762195f, 0.801173508f},
std::array<float,2>{0.513337255f, 0.0428294092f},
std::array<float,2>{0.730669498f, 0.896570265f},
std::array<float,2>{0.169978365f, 0.185962796f},
std::array<float,2>{0.464513272f, 0.673285484f},
std::array<float,2>{0.898224771f, 0.262387335f},
std::array<float,2>{0.983837008f, 0.829806149f},
std::array<float,2>{0.392460495f, 0.0846482068f},
std::array<float,2>{0.228265032f, 0.619621336f},
std::array<float,2>{0.662416518f, 0.390395015f},
std::array<float,2>{0.620384574f, 0.705194771f},
std::array<float,2>{0.113843285f, 0.315771759f},
std::array<float,2>{0.258776397f, 0.954024434f},
std::array<float,2>{0.813128889f, 0.207943872f},
std::array<float,2>{0.905040562f, 0.533850789f},
std::array<float,2>{0.458029032f, 0.446024537f},
std::array<float,2>{0.159102723f, 0.76239711f},
std::array<float,2>{0.720191479f, 0.00270408043f},
std::array<float,2>{0.506505311f, 0.922012985f},
std::array<float,2>{0.032266207f, 0.152760908f},
std::array<float,2>{0.342660636f, 0.637935042f},
std::array<float,2>{0.79913801f, 0.307726026f},
std::array<float,2>{0.820898354f, 0.844354451f},
std::array<float,2>{0.255193204f, 0.100067534f},
std::array<float,2>{0.122592971f, 0.565547168f},
std::array<float,2>{0.612786412f, 0.42839697f},
std::array<float,2>{0.668478727f, 0.747472107f},
std::array<float,2>{0.22036621f, 0.368310124f},
std::array<float,2>{0.400811553f, 0.992701232f},
std::array<float,2>{0.972197413f, 0.238696396f},
std::array<float,2>{0.765099108f, 0.68652463f},
std::array<float,2>{0.355590433f, 0.256960511f},
std::array<float,2>{0.00964605529f, 0.900334358f},
std::array<float,2>{0.558396995f, 0.178572178f},
std::array<float,2>{0.699012876f, 0.808703423f},
std::array<float,2>{0.125527263f, 0.0366796926f},
std::array<float,2>{0.469667733f, 0.513166666f},
std::array<float,2>{0.937075973f, 0.49708873f},
std::array<float,2>{0.94922775f, 0.962540925f},
std::array<float,2>{0.432598621f, 0.21263431f},
std::array<float,2>{0.203157753f, 0.714861929f},
std::array<float,2>{0.638481677f, 0.323388517f},
std::array<float,2>{0.581127644f, 0.615610003f},
std::array<float,2>{0.0887769684f, 0.376431882f},
std::array<float,2>{0.296687931f, 0.843496025f},
std::array<float,2>{0.862300694f, 0.0867074579f},
std::array<float,2>{0.999808073f, 0.70061475f},
std::array<float,2>{0.386639744f, 0.343127728f},
std::array<float,2>{0.237534523f, 0.94512254f},
std::array<float,2>{0.672255516f, 0.189361513f},
std::array<float,2>{0.595862746f, 0.82383281f},
std::array<float,2>{0.102791943f, 0.0714007169f},
std::array<float,2>{0.27670908f, 0.599291325f},
std::array<float,2>{0.836140215f, 0.399258852f},
std::array<float,2>{0.781573713f, 0.889926255f},
std::array<float,2>{0.320549905f, 0.159288272f},
std::array<float,2>{0.0555354692f, 0.66621232f},
std::array<float,2>{0.519057989f, 0.278724343f},
std::array<float,2>{0.736296296f, 0.529940426f},
std::array<float,2>{0.186405301f, 0.484253198f},
std::array<float,2>{0.450407118f, 0.785789609f},
std::array<float,2>{0.882383525f, 0.0619221553f},
std::array<float,2>{0.852352321f, 0.579976022f},
std::array<float,2>{0.30586049f, 0.411790639f},
std::array<float,2>{0.0745021254f, 0.871098936f},
std::array<float,2>{0.566831946f, 0.120330557f},
std::array<float,2>{0.648385823f, 0.973066449f},
std::array<float,2>{0.198034912f, 0.233309641f},
std::array<float,2>{0.414851934f, 0.723270953f},
std::array<float,2>{0.961601317f, 0.347817659f},
std::array<float,2>{0.910568714f, 0.779635787f},
std::array<float,2>{0.48944211f, 0.0260822717f},
std::array<float,2>{0.155287817f, 0.561163008f},
std::array<float,2>{0.71552819f, 0.463453412f},
std::array<float,2>{0.536596f, 0.656124294f},
std::array<float,2>{0.0224665012f, 0.29036817f},
std::array<float,2>{0.365974128f, 0.908624291f},
std::array<float,2>{0.780692816f, 0.134881705f},
std::array<float,2>{0.88542074f, 0.610658348f},
std::array<float,2>{0.44126904f, 0.379131138f},
std::array<float,2>{0.17382364f, 0.837351978f},
std::array<float,2>{0.745799065f, 0.0899165794f},
std::array<float,2>{0.525875449f, 0.968395829f},
std::array<float,2>{0.0518749245f, 0.218523011f},
std::array<float,2>{0.313110948f, 0.712541103f},
std::array<float,2>{0.792173505f, 0.32618317f},
std::array<float,2>{0.835540593f, 0.808343828f},
std::array<float,2>{0.267992556f, 0.0316509306f},
std::array<float,2>{0.0939163715f, 0.51008755f},
std::array<float,2>{0.606975138f, 0.493985653f},
std::array<float,2>{0.682007015f, 0.681934059f},
std::array<float,2>{0.248397648f, 0.251368821f},
std::array<float,2>{0.380401492f, 0.904231966f},
std::array<float,2>{0.989032745f, 0.17199111f},
std::array<float,2>{0.768322289f, 0.743557096f},
std::array<float,2>{0.369131774f, 0.374768168f},
std::array<float,2>{0.0262409151f, 0.997628629f},
std::array<float,2>{0.542913318f, 0.235635594f},
std::array<float,2>{0.707343936f, 0.850059688f},
std::array<float,2>{0.145945296f, 0.0972609371f},
std::array<float,2>{0.492307782f, 0.570094466f},
std::array<float,2>{0.921742916f, 0.425092071f},
std::array<float,2>{0.954990447f, 0.928784966f},
std::array<float,2>{0.413903326f, 0.15123491f},
std::array<float,2>{0.19010441f, 0.63508445f},
std::array<float,2>{0.650460541f, 0.311047256f},
std::array<float,2>{0.577862203f, 0.535222411f},
std::array<float,2>{0.0649373904f, 0.449419022f},
std::array<float,2>{0.302949935f, 0.761054814f},
std::array<float,2>{0.845177948f, 0.00723584741f},
std::array<float,2>{0.977519929f, 0.651990592f},
std::array<float,2>{0.394569665f, 0.293488026f},
std::array<float,2>{0.231267214f, 0.912105799f},
std::array<float,2>{0.660105109f, 0.13977854f},
std::array<float,2>{0.623440742f, 0.773775518f},
std::array<float,2>{0.109564736f, 0.029923398f},
std::array<float,2>{0.264719874f, 0.556766272f},
std::array<float,2>{0.817143857f, 0.465862751f},
std::array<float,2>{0.806244016f, 0.969632447f},
std::array<float,2>{0.331704617f, 0.229301199f},
std::array<float,2>{0.0467851274f, 0.719738066f},
std::array<float,2>{0.508976102f, 0.346248031f},
std::array<float,2>{0.729455888f, 0.58454597f},
std::array<float,2>{0.164867863f, 0.408749312f},
std::array<float,2>{0.465370059f, 0.868960321f},
std::array<float,2>{0.893735051f, 0.124014094f},
std::array<float,2>{0.87299937f, 0.525451601f},
std::array<float,2>{0.288108081f, 0.479128957f},
std::array<float,2>{0.0849574506f, 0.784671605f},
std::array<float,2>{0.58822155f, 0.05835649f},
std::array<float,2>{0.629555583f, 0.886714458f},
std::array<float,2>{0.218071654f, 0.162716985f},
std::array<float,2>{0.425326198f, 0.67056489f},
std::array<float,2>{0.943361044f, 0.276981741f},
std::array<float,2>{0.92300427f, 0.82538712f},
std::array<float,2>{0.482853442f, 0.077354148f},
std::array<float,2>{0.134396598f, 0.593945026f},
std::array<float,2>{0.695039392f, 0.403713077f},
std::array<float,2>{0.550794184f, 0.695711315f},
std::array<float,2>{0.000686494983f, 0.337292552f},
std::array<float,2>{0.349328279f, 0.938487589f},
std::array<float,2>{0.754783094f, 0.193703711f},
std::array<float,2>{0.9456985f, 0.547093749f},
std::array<float,2>{0.434687972f, 0.455164522f},
std::array<float,2>{0.210322365f, 0.771962941f},
std::array<float,2>{0.636275947f, 0.0213000346f},
std::array<float,2>{0.583525717f, 0.921599329f},
std::array<float,2>{0.090328373f, 0.129186317f},
std::array<float,2>{0.29104051f, 0.641864657f},
std::array<float,2>{0.864249408f, 0.288874328f},
std::array<float,2>{0.757932007f, 0.861286879f},
std::array<float,2>{0.352367967f, 0.115089282f},
std::array<float,2>{0.0143767344f, 0.586893559f},
std::array<float,2>{0.561221063f, 0.420127809f},
std::array<float,2>{0.701020956f, 0.72734201f},
std::array<float,2>{0.131412297f, 0.354415268f},
std::array<float,2>{0.47353363f, 0.981952429f},
std::array<float,2>{0.932328045f, 0.220310807f},
std::array<float,2>{0.82455945f, 0.661274374f},
std::array<float,2>{0.253648609f, 0.268224567f},
std::array<float,2>{0.11964488f, 0.880557656f},
std::array<float,2>{0.613969147f, 0.165197715f},
std::array<float,2>{0.667930245f, 0.796364427f},
std::array<float,2>{0.22561428f, 0.0507932603f},
std::array<float,2>{0.405581176f, 0.522626996f},
std::array<float,2>{0.973936856f, 0.474386901f},
std::array<float,2>{0.901702583f, 0.949265778f},
std::array<float,2>{0.453134418f, 0.202887014f},
std::array<float,2>{0.160936102f, 0.688836873f},
std::array<float,2>{0.722982109f, 0.329945117f},
std::array<float,2>{0.502359569f, 0.606238365f},
std::array<float,2>{0.0353230461f, 0.392354548f},
std::array<float,2>{0.337999105f, 0.816391051f},
std::array<float,2>{0.800821066f, 0.0692710429f},
std::array<float,2>{0.909560084f, 0.708396494f},
std::array<float,2>{0.485977232f, 0.319923401f},
std::array<float,2>{0.150543988f, 0.958681405f},
std::array<float,2>{0.711819768f, 0.205106556f},
std::array<float,2>{0.53326714f, 0.832416058f},
std::array<float,2>{0.0168483648f, 0.0812914371f},
std::array<float,2>{0.362400323f, 0.62409693f},
std::array<float,2>{0.775630832f, 0.38362968f},
std::array<float,2>{0.85662663f, 0.894278288f},
std::array<float,2>{0.309280246f, 0.18053332f},
std::array<float,2>{0.0735546127f, 0.67941606f},
std::array<float,2>{0.564195454f, 0.260783046f},
std::array<float,2>{0.640708387f, 0.50683409f},
std::array<float,2>{0.200193316f, 0.487473935f},
std::array<float,2>{0.420364916f, 0.79743731f},
std::array<float,2>{0.966621995f, 0.043196898f},
std::array<float,2>{0.788868129f, 0.57084012f},
std::array<float,2>{0.325298876f, 0.433365643f},
std::array<float,2>{0.0593672357f, 0.856442451f},
std::array<float,2>{0.520821214f, 0.104500964f},
std::array<float,2>{0.739175022f, 0.985759139f},
std::array<float,2>{0.180055648f, 0.246593043f},
std::array<float,2>{0.447700381f, 0.740069628f},
std::array<float,2>{0.878342271f, 0.362708569f},
std::array<float,2>{0.994997442f, 0.756309748f},
std::array<float,2>{0.389822692f, 0.012867298f},
std::array<float,2>{0.240480438f, 0.544031918f},
std::array<float,2>{0.67596817f, 0.439844787f},
std::array<float,2>{0.601459742f, 0.632387996f},
std::array<float,2>{0.108927056f, 0.304329276f},
std::array<float,2>{0.279786885f, 0.929968953f},
std::array<float,2>{0.840295553f, 0.142275274f},
std::array<float,2>{0.98635304f, 0.590141892f},
std::array<float,2>{0.376944333f, 0.416310221f},
std::array<float,2>{0.243622854f, 0.867147982f},
std::array<float,2>{0.685874581f, 0.113224208f},
std::array<float,2>{0.604191363f, 0.979210734f},
std::array<float,2>{0.100913711f, 0.223304302f},
std::array<float,2>{0.273371875f, 0.731197119f},
std::array<float,2>{0.83003974f, 0.357908815f},
std::array<float,2>{0.796034813f, 0.769152939f},
std::array<float,2>{0.318681628f, 0.0190582238f},
std::array<float,2>{0.0505295955f, 0.553079545f},
std::array<float,2>{0.530362248f, 0.457311392f},
std::array<float,2>{0.746989429f, 0.646870553f},
std::array<float,2>{0.179134831f, 0.282397032f},
std::array<float,2>{0.444880158f, 0.917872608f},
std::array<float,2>{0.88996613f, 0.126222923f},
std::array<float,2>{0.850934505f, 0.691903055f},
std::array<float,2>{0.296963215f, 0.333295405f},
std::array<float,2>{0.0695731416f, 0.945510745f},
std::array<float,2>{0.57115525f, 0.197123855f},
std::array<float,2>{0.652892828f, 0.82006371f},
std::array<float,2>{0.193953082f, 0.063948907f},
std::array<float,2>{0.408788979f, 0.604346514f},
std::array<float,2>{0.958163261f, 0.39792347f},
std::array<float,2>{0.917419553f, 0.877407491f},
std::array<float,2>{0.49717629f, 0.169754073f},
std::array<float,2>{0.142192349f, 0.659786165f},
std::array<float,2>{0.704431593f, 0.270068973f},
std::array<float,2>{0.543547869f, 0.516739428f},
std::array<float,2>{0.0291540772f, 0.472603172f},
std::array<float,2>{0.372516125f, 0.792422891f},
std::array<float,2>{0.772432566f, 0.0483326688f},
std::array<float,2>{0.895322919f, 0.675688028f},
std::array<float,2>{0.46228376f, 0.263988107f},
std::array<float,2>{0.168972179f, 0.895786107f},
std::array<float,2>{0.732826054f, 0.184260741f},
std::array<float,2>{0.514095366f, 0.803179979f},
std::array<float,2>{0.040388599f, 0.0409098491f},
std::array<float,2>{0.335780412f, 0.502386749f},
std::array<float,2>{0.809558094f, 0.489989609f},
std::array<float,2>{0.816351831f, 0.956120849f},
std::array<float,2>{0.260102987f, 0.209609896f},
std::array<float,2>{0.116370186f, 0.704209805f},
std::array<float,2>{0.617783725f, 0.312812358f},
std::array<float,2>{0.661633074f, 0.617956698f},
std::array<float,2>{0.229673386f, 0.387393177f},
std::array<float,2>{0.393135041f, 0.830929637f},
std::array<float,2>{0.981792808f, 0.0824499577f},
std::array<float,2>{0.751400173f, 0.540690422f},
std::array<float,2>{0.346729547f, 0.441851169f},
std::array<float,2>{0.0056137396f, 0.752679884f},
std::array<float,2>{0.550120711f, 0.0107707437f},
std::array<float,2>{0.687526047f, 0.937139511f},
std::array<float,2>{0.137008309f, 0.147352159f},
std::array<float,2>{0.478310764f, 0.626146793f},
std::array<float,2>{0.927563787f, 0.299114227f},
std::array<float,2>{0.940709293f, 0.852894664f},
std::array<float,2>{0.42634505f, 0.107193366f},
std::array<float,2>{0.214069918f, 0.576231837f},
std::array<float,2>{0.626408279f, 0.434152752f},
std::array<float,2>{0.590187967f, 0.734941125f},
std::array<float,2>{0.0781908557f, 0.365242749f},
std::array<float,2>{0.285147786f, 0.991701961f},
std::array<float,2>{0.867295086f, 0.242664397f},
std::array<float,2>{0.934447169f, 0.51510793f},
std::array<float,2>{0.472578526f, 0.498297423f},
std::array<float,2>{0.128322721f, 0.810669601f},
std::array<float,2>{0.696660221f, 0.0372484811f},
std::array<float,2>{0.555397928f, 0.900618315f},
std::array<float,2>{0.0108733177f, 0.177550733f},
std::array<float,2>{0.358579695f, 0.683722258f},
std::array<float,2>{0.763273954f, 0.255240142f},
std::array<float,2>{0.85991323f, 0.840478361f},
std::array<float,2>{0.294564843f, 0.0890789926f},
std::array<float,2>{0.0863096863f, 0.615046382f},
std::array<float,2>{0.579437912f, 0.378628671f},
std::array<float,2>{0.639530718f, 0.718402088f},
std::array<float,2>{0.205743834f, 0.32153213f},
std::array<float,2>{0.430619836f, 0.963115871f},
std::array<float,2>{0.952596843f, 0.213892028f},
std::array<float,2>{0.798005402f, 0.639964402f},
std::array<float,2>{0.340119839f, 0.306267262f},
std::array<float,2>{0.0347515829f, 0.925316036f},
std::array<float,2>{0.504989862f, 0.155381322f},
std::array<float,2>{0.721437752f, 0.764665186f},
std::array<float,2>{0.156741709f, 0.000384125975f},
std::array<float,2>{0.460077345f, 0.533135176f},
std::array<float,2>{0.904138744f, 0.448516607f},
std::array<float,2>{0.969897389f, 0.994608283f},
std::array<float,2>{0.399866819f, 0.240508124f},
std::array<float,2>{0.222626135f, 0.748288035f},
std::array<float,2>{0.671586752f, 0.370265096f},
std::array<float,2>{0.609873891f, 0.562876105f},
std::array<float,2>{0.124668553f, 0.427548289f},
std::array<float,2>{0.257429689f, 0.846258283f},
std::array<float,2>{0.823984027f, 0.0990742669f},
std::array<float,2>{0.963384688f, 0.724679291f},
std::array<float,2>{0.417446107f, 0.350363135f},
std::array<float,2>{0.195985779f, 0.975406826f},
std::array<float,2>{0.644657552f, 0.232414305f},
std::array<float,2>{0.569958448f, 0.873412192f},
std::array<float,2>{0.0766509995f, 0.117424771f},
std::array<float,2>{0.306978315f, 0.580532491f},
std::array<float,2>{0.853696525f, 0.412135214f},
std::array<float,2>{0.778194249f, 0.908137023f},
std::array<float,2>{0.364124328f, 0.134249926f},
std::array<float,2>{0.0209536999f, 0.652679443f},
std::array<float,2>{0.538081169f, 0.291227579f},
std::array<float,2>{0.718517363f, 0.560281754f},
std::array<float,2>{0.153089494f, 0.462720037f},
std::array<float,2>{0.491730779f, 0.778618813f},
std::array<float,2>{0.913362265f, 0.0246068407f},
std::array<float,2>{0.838469148f, 0.600346684f},
std::array<float,2>{0.274015129f, 0.400672615f},
std::array<float,2>{0.104698971f, 0.820533812f},
std::array<float,2>{0.595019639f, 0.0738614276f},
std::array<float,2>{0.675306261f, 0.942799687f},
std::array<float,2>{0.236323044f, 0.18954815f},
std::array<float,2>{0.383685738f, 0.702936053f},
std::array<float,2>{0.997338653f, 0.340777606f},
std::array<float,2>{0.879578471f, 0.788252115f},
std::array<float,2>{0.452395171f, 0.05946704f},
std::array<float,2>{0.184871435f, 0.529181838f},
std::array<float,2>{0.73780477f, 0.481579304f},
std::array<float,2>{0.517539263f, 0.664678574f},
std::array<float,2>{0.0574955009f, 0.279759765f},
std::array<float,2>{0.323641419f, 0.888620317f},
std::array<float,2>{0.784867048f, 0.15668419f},
std::array<float,2>{0.925472736f, 0.595299482f},
std::array<float,2>{0.481356114f, 0.403196603f},
std::array<float,2>{0.135914236f, 0.825124919f},
std::array<float,2>{0.692549646f, 0.0767659098f},
std::array<float,2>{0.55372113f, 0.938318014f},
std::array<float,2>{0.00373156741f, 0.194465324f},
std::array<float,2>{0.350555748f, 0.696524382f},
std::array<float,2>{0.756822944f, 0.336470872f},
std::array<float,2>{0.873197973f, 0.783854842f},
std::array<float,2>{0.285434335f, 0.0574140437f},
std::array<float,2>{0.0837802514f, 0.52676326f},
std::array<float,2>{0.587300897f, 0.47979185f},
std::array<float,2>{0.631897151f, 0.671762824f},
std::array<float,2>{0.215706646f, 0.276271075f},
std::array<float,2>{0.422122627f, 0.885208905f},
std::array<float,2>{0.942062616f, 0.163580522f},
std::array<float,2>{0.808010995f, 0.719301224f},
std::array<float,2>{0.328868628f, 0.346991897f},
std::array<float,2>{0.0441065319f, 0.970132589f},
std::array<float,2>{0.511073411f, 0.229847208f},
std::array<float,2>{0.727608562f, 0.867258489f},
std::array<float,2>{0.167624071f, 0.124048144f},
std::array<float,2>{0.466817409f, 0.585826218f},
std::array<float,2>{0.890805125f, 0.409291476f},
std::array<float,2>{0.978811502f, 0.911129475f},
std::array<float,2>{0.397325218f, 0.139141694f},
std::array<float,2>{0.233138874f, 0.650637448f},
std::array<float,2>{0.657835901f, 0.294427782f},
std::array<float,2>{0.622843862f, 0.557839513f},
std::array<float,2>{0.111400969f, 0.464918405f},
std::array<float,2>{0.263511062f, 0.774592876f},
std::array<float,2>{0.818586469f, 0.0306158867f},
std::array<float,2>{0.955086231f, 0.636628866f},
std::array<float,2>{0.411480486f, 0.312235653f},
std::array<float,2>{0.188483685f, 0.928709447f},
std::array<float,2>{0.649357975f, 0.152269334f},
std::array<float,2>{0.575600743f, 0.760386169f},
std::array<float,2>{0.0630840883f, 0.00681593036f},
std::array<float,2>{0.301266909f, 0.536885619f},
std::array<float,2>{0.847352922f, 0.450631529f},
std::array<float,2>{0.767408431f, 0.996231496f},
std::array<float,2>{0.3708148f, 0.23484312f},
std::array<float,2>{0.0239859428f, 0.742770433f},
std::array<float,2>{0.539483845f, 0.373806596f},
std::array<float,2>{0.710902691f, 0.568795919f},
std::array<float,2>{0.146718413f, 0.424039572f},
std::array<float,2>{0.495503753f, 0.851466894f},
std::array<float,2>{0.918940127f, 0.0963248983f},
std::array<float,2>{0.832417071f, 0.51083833f},
std::array<float,2>{0.266411304f, 0.493144304f},
std::array<float,2>{0.0967608988f, 0.806935906f},
std::array<float,2>{0.608510494f, 0.0327443555f},
std::array<float,2>{0.680737317f, 0.902780294f},
std::array<float,2>{0.246443301f, 0.173802912f},
std::array<float,2>{0.382692486f, 0.683343351f},
std::array<float,2>{0.990357935f, 0.250901341f},
std::array<float,2>{0.884384871f, 0.836773515f},
std::array<float,2>{0.437767923f, 0.0913985297f},
std::array<float,2>{0.174527913f, 0.60991776f},
std::array<float,2>{0.742573857f, 0.379994929f},
std::array<float,2>{0.525031567f, 0.711139858f},
std::array<float,2>{0.0540079176f, 0.327455521f},
std::array<float,2>{0.316272944f, 0.966965497f},
std::array<float,2>{0.789322197f, 0.217035577f},
std::array<float,2>{0.993596375f, 0.543071508f},
std::array<float,2>{0.387609273f, 0.441277415f},
std::array<float,2>{0.239634871f, 0.757215083f},
std::array<float,2>{0.678988278f, 0.0126281409f},
std::array<float,2>{0.597928822f, 0.931533873f},
std::array<float,2>{0.107341334f, 0.141373023f},
std::array<float,2>{0.278297096f, 0.631736755f},
std::array<float,2>{0.843081415f, 0.302900344f},
std::array<float,2>{0.786687911f, 0.856789231f},
std::array<float,2>{0.32760343f, 0.104333535f},
std::array<float,2>{0.0608144253f, 0.571788073f},
std::array<float,2>{0.522562385f, 0.432147712f},
std::array<float,2>{0.741533935f, 0.738566995f},
std::array<float,2>{0.182317615f, 0.361857474f},
std::array<float,2>{0.445904523f, 0.984791338f},
std::array<float,2>{0.875164628f, 0.247435242f},
std::array<float,2>{0.858623028f, 0.678435385f},
std::array<float,2>{0.310691386f, 0.260650992f},
std::array<float,2>{0.0708682686f, 0.893452883f},
std::array<float,2>{0.564956784f, 0.181310669f},
std::array<float,2>{0.643704414f, 0.798292816f},
std::array<float,2>{0.20290482f, 0.0440103188f},
std::array<float,2>{0.418366939f, 0.507600963f},
std::array<float,2>{0.96741277f, 0.486589968f},
std::array<float,2>{0.907724321f, 0.957877696f},
std::array<float,2>{0.488123298f, 0.206990063f},
std::array<float,2>{0.150163546f, 0.707926393f},
std::array<float,2>{0.714603841f, 0.318539679f},
std::array<float,2>{0.531880498f, 0.62400192f},
std::array<float,2>{0.0190308653f, 0.384490192f},
std::array<float,2>{0.359844923f, 0.833848476f},
std::array<float,2>{0.77428323f, 0.0808088928f},
std::array<float,2>{0.898880422f, 0.687749624f},
std::array<float,2>{0.455785662f, 0.32882905f},
std::array<float,2>{0.163646802f, 0.950841367f},
std::array<float,2>{0.726335645f, 0.202113628f},
std::array<float,2>{0.500350535f, 0.815297842f},
std::array<float,2>{0.0383145213f, 0.0697617829f},
std::array<float,2>{0.337244451f, 0.607002199f},
std::array<float,2>{0.803612232f, 0.390761614f},
std::array<float,2>{0.827235341f, 0.879665792f},
std::array<float,2>{0.250356674f, 0.164649099f},
std::array<float,2>{0.11796052f, 0.660393059f},
std::array<float,2>{0.617078185f, 0.268859088f},
std::array<float,2>{0.665967822f, 0.522214532f},
std::array<float,2>{0.223598555f, 0.473029524f},
std::array<float,2>{0.404127032f, 0.795526445f},
std::array<float,2>{0.976416051f, 0.0518167019f},
std::array<float,2>{0.760210991f, 0.587387204f},
std::array<float,2>{0.354210705f, 0.421395093f},
std::array<float,2>{0.0119323833f, 0.859451175f},
std::array<float,2>{0.559127867f, 0.113778226f},
std::array<float,2>{0.70127815f, 0.980688691f},
std::array<float,2>{0.130213052f, 0.219544679f},
std::array<float,2>{0.474821895f, 0.727929235f},
std::array<float,2>{0.930103004f, 0.355291545f},
std::array<float,2>{0.947898448f, 0.772581577f},
std::array<float,2>{0.436900973f, 0.0196345225f},
std::array<float,2>{0.208765507f, 0.548168898f},
std::array<float,2>{0.634169459f, 0.456388384f},
std::array<float,2>{0.585638046f, 0.641290367f},
std::array<float,2>{0.0931235999f, 0.287935853f},
std::array<float,2>{0.289492011f, 0.9201563f},
std::array<float,2>{0.865935326f, 0.130154461f},
std::array<float,2>{0.937746942f, 0.57754451f},
std::array<float,2>{0.429310977f, 0.434835851f},
std::array<float,2>{0.211296782f, 0.85239327f},
std::array<float,2>{0.627974391f, 0.106396005f},
std::array<float,2>{0.592532694f, 0.990913868f},
std::array<float,2>{0.0812103674f, 0.243549481f},
std::array<float,2>{0.282576889f, 0.735407889f},
std::array<float,2>{0.869581819f, 0.36636889f},
std::array<float,2>{0.752396286f, 0.753311336f},
std::array<float,2>{0.344288319f, 0.00995272025f},
std::array<float,2>{0.00628179312f, 0.539712787f},
std::array<float,2>{0.547908545f, 0.442543477f},
std::array<float,2>{0.691299081f, 0.625834584f},
std::array<float,2>{0.140285864f, 0.300502688f},
std::array<float,2>{0.479488403f, 0.935982406f},
std::array<float,2>{0.929393768f, 0.147745892f},
std::array<float,2>{0.81363827f, 0.703771114f},
std::array<float,2>{0.258841008f, 0.314133316f},
std::array<float,2>{0.114875555f, 0.955095351f},
std::array<float,2>{0.619976938f, 0.21081984f},
std::array<float,2>{0.663770497f, 0.831701219f},
std::array<float,2>{0.226609349f, 0.083817631f},
std::array<float,2>{0.391385943f, 0.618554533f},
std::array<float,2>{0.982613683f, 0.38845849f},
std::array<float,2>{0.896533132f, 0.894886732f},
std::array<float,2>{0.46291399f, 0.184771895f},
std::array<float,2>{0.171041697f, 0.674055696f},
std::array<float,2>{0.731934071f, 0.265276343f},
std::array<float,2>{0.512493551f, 0.503084123f},
std::array<float,2>{0.041893892f, 0.48835808f},
std::array<float,2>{0.332645684f, 0.80438745f},
std::array<float,2>{0.8109231f, 0.0394052379f},
std::array<float,2>{0.914474845f, 0.658672571f},
std::array<float,2>{0.498823792f, 0.27143839f},
std::array<float,2>{0.143851399f, 0.878181159f},
std::array<float,2>{0.705558777f, 0.168168351f},
std::array<float,2>{0.545713365f, 0.791676104f},
std::array<float,2>{0.030228015f, 0.0477911085f},
std::array<float,2>{0.374395698f, 0.515888989f},
std::array<float,2>{0.771133065f, 0.470712274f},
std::array<float,2>{0.848946631f, 0.947243929f},
std::array<float,2>{0.299533993f, 0.196115196f},
std::array<float,2>{0.0667013973f, 0.692919791f},
std::array<float,2>{0.573150098f, 0.332443118f},
std::array<float,2>{0.655096531f, 0.605161846f},
std::array<float,2>{0.193151936f, 0.396628916f},
std::array<float,2>{0.407778651f, 0.818519533f},
std::array<float,2>{0.959554553f, 0.0630619749f},
std::array<float,2>{0.793352723f, 0.554222465f},
std::array<float,2>{0.31783095f, 0.458139271f},
std::array<float,2>{0.048258692f, 0.768211544f},
std::array<float,2>{0.529165208f, 0.0177978165f},
std::array<float,2>{0.749241352f, 0.916386187f},
std::array<float,2>{0.176825747f, 0.125697106f},
std::array<float,2>{0.441664606f, 0.64786166f},
std::array<float,2>{0.888421774f, 0.281654447f},
std::array<float,2>{0.985649526f, 0.865485966f},
std::array<float,2>{0.377237886f, 0.111823589f},
std::array<float,2>{0.245280907f, 0.591640174f},
std::array<float,2>{0.684895337f, 0.417197794f},
std::array<float,2>{0.603248835f, 0.731933534f},
std::array<float,2>{0.0989162102f, 0.358837605f},
std::array<float,2>{0.270307899f, 0.980370939f},
std::array<float,2>{0.830753803f, 0.22441341f},
std::array<float,2>{0.881623387f, 0.52740854f},
std::array<float,2>{0.44987911f, 0.481318325f},
std::array<float,2>{0.186842769f, 0.787345648f},
std::array<float,2>{0.734524429f, 0.0598609f},
std::array<float,2>{0.518531799f, 0.887291789f},
std::array<float,2>{0.0559601896f, 0.157546148f},
std::array<float,2>{0.322113544f, 0.665458143f},
std::array<float,2>{0.782806277f, 0.280920833f},
std::array<float,2>{0.837663591f, 0.822129667f},
std::array<float,2>{0.27567789f, 0.0731839165f},
std::array<float,2>{0.102341741f, 0.601356924f},
std::array<float,2>{0.596979916f, 0.402193606f},
std::array<float,2>{0.673160613f, 0.701493859f},
std::array<float,2>{0.23694326f, 0.34131223f},
std::array<float,2>{0.385380387f, 0.941793382f},
std::array<float,2>{0.998570561f, 0.190524355f},
std::array<float,2>{0.779660165f, 0.653473735f},
std::array<float,2>{0.36673224f, 0.292402118f},
std::array<float,2>{0.0221355986f, 0.907149494f},
std::array<float,2>{0.53542012f, 0.133509427f},
std::array<float,2>{0.716475129f, 0.777429461f},
std::array<float,2>{0.154990911f, 0.0234556198f},
std::array<float,2>{0.488406956f, 0.559337437f},
std::array<float,2>{0.911868691f, 0.461576074f},
std::array<float,2>{0.962325156f, 0.976528823f},
std::array<float,2>{0.415156931f, 0.230815545f},
std::array<float,2>{0.199093461f, 0.726382613f},
std::array<float,2>{0.6466465f, 0.350684613f},
std::array<float,2>{0.567736983f, 0.581594229f},
std::array<float,2>{0.0751967728f, 0.413425952f},
std::array<float,2>{0.305223167f, 0.874579489f},
std::array<float,2>{0.852952242f, 0.118365876f},
std::array<float,2>{0.971033692f, 0.749583781f},
std::array<float,2>{0.402082294f, 0.369884908f},
std::array<float,2>{0.219195798f, 0.995253682f},
std::array<float,2>{0.669553757f, 0.241746604f},
std::array<float,2>{0.612046897f, 0.84720695f},
std::array<float,2>{0.121918641f, 0.0984022841f},
std::array<float,2>{0.254666507f, 0.563983798f},
std::array<float,2>{0.822012544f, 0.426543981f},
std::array<float,2>{0.800462425f, 0.923899651f},
std::array<float,2>{0.342944771f, 0.155045912f},
std::array<float,2>{0.0315342546f, 0.639165998f},
std::array<float,2>{0.506894171f, 0.304821938f},
std::array<float,2>{0.718899965f, 0.531442285f},
std::array<float,2>{0.159817964f, 0.448012084f},
std::array<float,2>{0.457536817f, 0.763694406f},
std::array<float,2>{0.906030238f, 0.00175136828f},
std::array<float,2>{0.86270678f, 0.613867044f},
std::array<float,2>{0.295862138f, 0.377364993f},
std::array<float,2>{0.0890388712f, 0.84087348f},
std::array<float,2>{0.580687702f, 0.0886410698f},
std::array<float,2>{0.637582302f, 0.964410901f},
std::array<float,2>{0.204443753f, 0.213620886f},
std::array<float,2>{0.433399767f, 0.716957629f},
std::array<float,2>{0.950252473f, 0.320766449f},
std::array<float,2>{0.93563503f, 0.812481523f},
std::array<float,2>{0.470085382f, 0.0381940864f},
std::array<float,2>{0.126304761f, 0.514202058f},
std::array<float,2>{0.697729468f, 0.4992401f},
std::array<float,2>{0.557394624f, 0.685376406f},
std::array<float,2>{0.0079208333f, 0.254179686f},
std::array<float,2>{0.356503129f, 0.902338922f},
std::array<float,2>{0.764370203f, 0.176256195f},
std::array<float,2>{0.893130004f, 0.583714962f},
std::array<float,2>{0.465911031f, 0.406524777f},
std::array<float,2>{0.165755853f, 0.870473444f},
std::array<float,2>{0.730010569f, 0.122155353f},
std::array<float,2>{0.508070052f, 0.970980108f},
std::array<float,2>{0.0456575267f, 0.228452861f},
std::array<float,2>{0.330220908f, 0.72226578f},
std::array<float,2>{0.804818392f, 0.345225513f},
std::array<float,2>{0.818285465f, 0.776411593f},
std::array<float,2>{0.264457673f, 0.0287686381f},
std::array<float,2>{0.11102128f, 0.555648267f},
std::array<float,2>{0.624661028f, 0.467306107f},
std::array<float,2>{0.658231378f, 0.64975822f},
std::array<float,2>{0.231805056f, 0.29498446f},
std::array<float,2>{0.396264344f, 0.913797617f},
std::array<float,2>{0.97786665f, 0.137545407f},
std::array<float,2>{0.75554353f, 0.698245406f},
std::array<float,2>{0.348451763f, 0.338392973f},
std::array<float,2>{0.00123129936f, 0.941317856f},
std::array<float,2>{0.552702963f, 0.19231914f},
std::array<float,2>{0.693648875f, 0.826690912f},
std::array<float,2>{0.133416563f, 0.0758727714f},
std::array<float,2>{0.484370023f, 0.596386909f},
std::array<float,2>{0.922251523f, 0.405072182f},
std::array<float,2>{0.945245206f, 0.883287549f},
std::array<float,2>{0.424193114f, 0.161966205f},
std::array<float,2>{0.217445433f, 0.669557452f},
std::array<float,2>{0.629892707f, 0.275057554f},
std::array<float,2>{0.588975668f, 0.524178207f},
std::array<float,2>{0.0859190747f, 0.477125585f},
std::array<float,2>{0.28799516f, 0.78222543f},
std::array<float,2>{0.871442556f, 0.0549260229f},
std::array<float,2>{0.990211725f, 0.679696739f},
std::array<float,2>{0.379501969f, 0.253403127f},
std::array<float,2>{0.249192193f, 0.905139029f},
std::array<float,2>{0.682993054f, 0.174672395f},
std::array<float,2>{0.606287837f, 0.804835856f},
std::array<float,2>{0.094773896f, 0.0339029618f},
std::array<float,2>{0.26856035f, 0.508059561f},
std::array<float,2>{0.834770083f, 0.4955073f},
std::array<float,2>{0.791541815f, 0.965313196f},
std::array<float,2>{0.313786894f, 0.215417698f},
std::array<float,2>{0.0511749983f, 0.714571118f},
std::array<float,2>{0.526997983f, 0.325213552f},
std::array<float,2>{0.744201183f, 0.611956716f},
std::array<float,2>{0.171920702f, 0.382083148f},
std::array<float,2>{0.440176666f, 0.839378536f},
std::array<float,2>{0.886017323f, 0.0922206119f},
std::array<float,2>{0.84402138f, 0.538629174f},
std::array<float,2>{0.303751528f, 0.452676147f},
std::array<float,2>{0.0662308559f, 0.759142995f},
std::array<float,2>{0.576958179f, 0.00412372127f},
std::array<float,2>{0.651949942f, 0.926478744f},
std::array<float,2>{0.190864712f, 0.148715988f},
std::array<float,2>{0.412888885f, 0.63353157f},
std::array<float,2>{0.953963578f, 0.310168058f},
std::array<float,2>{0.920388699f, 0.849395096f},
std::array<float,2>{0.493399084f, 0.0937670544f},
std::array<float,2>{0.144685298f, 0.568246603f},
std::array<float,2>{0.708139479f, 0.422792971f},
std::array<float,2>{0.54174614f, 0.744580925f},
std::array<float,2>{0.0266245175f, 0.371716946f},
std::array<float,2>{0.368049532f, 0.998241842f},
std::array<float,2>{0.769503355f, 0.237693653f},
std::array<float,2>{0.965561986f, 0.505096614f},
std::array<float,2>{0.421692044f, 0.484675705f},
std::array<float,2>{0.200976491f, 0.799376249f},
std::array<float,2>{0.641934872f, 0.0453133918f},
std::array<float,2>{0.562505305f, 0.890777528f},
std::array<float,2>{0.0731850713f, 0.181977272f},
std::array<float,2>{0.31038928f, 0.675903559f},
std::array<float,2>{0.8563326f, 0.258384556f},
std::array<float,2>{0.777213514f, 0.835174739f},
std::array<float,2>{0.362019509f, 0.0798471272f},
std::array<float,2>{0.0160719771f, 0.62128526f},
std::array<float,2>{0.534583628f, 0.386414349f},
std::array<float,2>{0.712641835f, 0.709587216f},
std::array<float,2>{0.151500672f, 0.31732592f},
std::array<float,2>{0.484435707f, 0.960550368f},
std::array<float,2>{0.908848822f, 0.203895807f},
std::array<float,2>{0.841493666f, 0.629013062f},
std::array<float,2>{0.280356109f, 0.301154613f},
std::array<float,2>{0.108045876f, 0.933060825f},
std::array<float,2>{0.600470483f, 0.142974988f},
std::array<float,2>{0.676942229f, 0.754302919f},
std::array<float,2>{0.242030814f, 0.0148702404f},
std::array<float,2>{0.38937676f, 0.546163797f},
std::array<float,2>{0.99546361f, 0.438758403f},
std::array<float,2>{0.877671599f, 0.987948f},
std::array<float,2>{0.448415011f, 0.24890472f},
std::array<float,2>{0.18141602f, 0.741698563f},
std::array<float,2>{0.73933208f, 0.360848069f},
std::array<float,2>{0.52046448f, 0.573446929f},
std::array<float,2>{0.060490869f, 0.431206793f},
std::array<float,2>{0.325068653f, 0.857729495f},
std::array<float,2>{0.787910819f, 0.101638079f},
std::array<float,2>{0.932896435f, 0.729993641f},
std::array<float,2>{0.47397697f, 0.35298264f},
std::array<float,2>{0.132272854f, 0.983526349f},
std::array<float,2>{0.7000525f, 0.221319795f},
std::array<float,2>{0.561987102f, 0.863139033f},
std::array<float,2>{0.0148174427f, 0.116675511f},
std::array<float,2>{0.352894902f, 0.589238703f},
std::array<float,2>{0.759185433f, 0.419806331f},
std::array<float,2>{0.864589572f, 0.919648111f},
std::array<float,2>{0.29204905f, 0.132713929f},
std::array<float,2>{0.0914418325f, 0.643669903f},
std::array<float,2>{0.582805812f, 0.285773158f},
std::array<float,2>{0.634836316f, 0.550507963f},
std::array<float,2>{0.209030032f, 0.453529418f},
std::array<float,2>{0.434233546f, 0.770355821f},
std::array<float,2>{0.946966946f, 0.0232223347f},
std::array<float,2>{0.802705586f, 0.608068109f},
std::array<float,2>{0.338941097f, 0.393299103f},
std::array<float,2>{0.0365465395f, 0.814287305f},
std::array<float,2>{0.503271818f, 0.0683235079f},
std::array<float,2>{0.723940074f, 0.952439845f},
std::array<float,2>{0.16197522f, 0.20010139f},
std::array<float,2>{0.455010533f, 0.689652443f},
std::array<float,2>{0.900723338f, 0.330952823f},
std::array<float,2>{0.972909093f, 0.793672025f},
std::array<float,2>{0.4044514f, 0.0531686097f},
std::array<float,2>{0.225181699f, 0.520379841f},
std::array<float,2>{0.666147292f, 0.475627393f},
std::array<float,2>{0.614491045f, 0.66345793f},
std::array<float,2>{0.120826155f, 0.265801698f},
std::array<float,2>{0.252895534f, 0.882002652f},
std::array<float,2>{0.825800538f, 0.167231336f},
std::array<float,2>{0.980680346f, 0.620730042f},
std::array<float,2>{0.393867403f, 0.389175802f},
std::array<float,2>{0.229413778f, 0.828211129f},
std::array<float,2>{0.66087234f, 0.0851167068f},
std::array<float,2>{0.619065225f, 0.954209745f},
std::array<float,2>{0.115522042f, 0.208250374f},
std::array<float,2>{0.260811806f, 0.706341922f},
std::array<float,2>{0.815319955f, 0.315382808f},
std::array<float,2>{0.809730768f, 0.802621841f},
std::array<float,2>{0.33432731f, 0.0417602062f},
std::array<float,2>{0.0398131423f, 0.500830233f},
std::array<float,2>{0.515394449f, 0.492053658f},
std::array<float,2>{0.73362726f, 0.672064185f},
std::array<float,2>{0.168780491f, 0.263315231f},
std::array<float,2>{0.461897254f, 0.898257375f},
std::array<float,2>{0.896291733f, 0.187219173f},
std::array<float,2>{0.868260562f, 0.738001108f},
std::array<float,2>{0.283721834f, 0.364532262f},
std::array<float,2>{0.079862088f, 0.989280403f},
std::array<float,2>{0.591285765f, 0.245012775f},
std::array<float,2>{0.625570714f, 0.853537679f},
std::array<float,2>{0.213411435f, 0.107897654f},
std::array<float,2>{0.427099705f, 0.575629652f},
std::array<float,2>{0.939620912f, 0.437167764f},
std::array<float,2>{0.925949693f, 0.93455869f},
std::array<float,2>{0.476758987f, 0.145342618f},
std::array<float,2>{0.138487294f, 0.628789127f},
std::array<float,2>{0.689347029f, 0.298607498f},
std::array<float,2>{0.549663663f, 0.541691244f},
std::array<float,2>{0.00449777022f, 0.444782287f},
std::array<float,2>{0.346627295f, 0.751752377f},
std::array<float,2>{0.750353634f, 0.00899324566f},
std::array<float,2>{0.889466166f, 0.646239936f},
std::array<float,2>{0.443687767f, 0.283863395f},
std::array<float,2>{0.17835243f, 0.915477216f},
std::array<float,2>{0.747745454f, 0.128727123f},
std::array<float,2>{0.529827714f, 0.767363548f},
std::array<float,2>{0.0494869761f, 0.0169637036f},
std::array<float,2>{0.319788843f, 0.55259198f},
std::array<float,2>{0.795693159f, 0.459414721f},
std::array<float,2>{0.828423202f, 0.978048205f},
std::array<float,2>{0.271783739f, 0.226024941f},
std::array<float,2>{0.0999282822f, 0.732781291f},
std::array<float,2>{0.605364621f, 0.356209427f},
std::array<float,2>{0.687035441f, 0.593727469f},
std::array<float,2>{0.242375165f, 0.414684504f},
std::array<float,2>{0.375497699f, 0.864021122f},
std::array<float,2>{0.987620831f, 0.109810628f},
std::array<float,2>{0.772817612f, 0.518238306f},
std::array<float,2>{0.371731937f, 0.470444113f},
std::array<float,2>{0.0278561004f, 0.79022342f},
std::array<float,2>{0.544053018f, 0.0496818982f},
std::array<float,2>{0.703852654f, 0.875579834f},
std::array<float,2>{0.141056538f, 0.170031443f},
std::array<float,2>{0.496841073f, 0.656385422f},
std::array<float,2>{0.916715443f, 0.273279756f},
std::array<float,2>{0.957384884f, 0.818032742f},
std::array<float,2>{0.409250468f, 0.0651384518f},
std::array<float,2>{0.195124939f, 0.603080928f},
std::array<float,2>{0.654285133f, 0.395562768f},
std::array<float,2>{0.572097838f, 0.695214212f},
std::array<float,2>{0.0685555637f, 0.335818082f},
std::array<float,2>{0.298082411f, 0.948141634f},
std::array<float,2>{0.849987388f, 0.199053764f},
std::array<float,2>{0.912546337f, 0.56185323f},
std::array<float,2>{0.490700841f, 0.464098424f},
std::array<float,2>{0.153890088f, 0.781032085f},
std::array<float,2>{0.717205524f, 0.0272144321f},
std::array<float,2>{0.538432777f, 0.909598589f},
std::array<float,2>{0.0202524625f, 0.136583149f},
std::array<float,2>{0.365209013f, 0.65524286f},
std::array<float,2>{0.779228032f, 0.289269835f},
std::array<float,2>{0.854535162f, 0.872822583f},
std::array<float,2>{0.307940871f, 0.119309843f},
std::array<float,2>{0.078032814f, 0.57901901f},
std::array<float,2>{0.569118857f, 0.410875082f},
std::array<float,2>{0.64554435f, 0.724272132f},
std::array<float,2>{0.196349695f, 0.349439174f},
std::array<float,2>{0.416389734f, 0.974541128f},
std::array<float,2>{0.964604914f, 0.233737439f},
std::array<float,2>{0.78335458f, 0.667488575f},
std::array<float,2>{0.322337031f, 0.277609527f},
std::array<float,2>{0.0578456894f, 0.888841569f},
std::array<float,2>{0.515966892f, 0.158923507f},
std::array<float,2>{0.736704826f, 0.7862252f},
std::array<float,2>{0.183689833f, 0.0607689582f},
std::array<float,2>{0.451755673f, 0.53084439f},
std::array<float,2>{0.880204737f, 0.483230919f},
std::array<float,2>{0.99638921f, 0.943767071f},
std::array<float,2>{0.384344786f, 0.18782036f},
std::array<float,2>{0.234521851f, 0.700020492f},
std::array<float,2>{0.674066305f, 0.341954589f},
std::array<float,2>{0.594353676f, 0.598342419f},
std::array<float,2>{0.104287162f, 0.400283962f},
std::array<float,2>{0.274900079f, 0.822520614f},
std::array<float,2>{0.839811862f, 0.0704905242f},
std::array<float,2>{0.951234639f, 0.715990424f},
std::array<float,2>{0.431293786f, 0.322686255f},
std::array<float,2>{0.206383646f, 0.961896122f},
std::array<float,2>{0.639817834f, 0.211512208f},
std::array<float,2>{0.578724325f, 0.842118084f},
std::array<float,2>{0.0876185596f, 0.0878710002f},
std::array<float,2>{0.293013513f, 0.616599739f},
std::array<float,2>{0.860876739f, 0.375510573f},
std::array<float,2>{0.761750162f, 0.898553967f},
std::array<float,2>{0.358349532f, 0.179581597f},
std::array<float,2>{0.00979968812f, 0.685610116f},
std::array<float,2>{0.556101263f, 0.256213367f},
std::array<float,2>{0.696229458f, 0.512303412f},
std::array<float,2>{0.127429128f, 0.496235162f},
std::array<float,2>{0.47104007f, 0.810229182f},
std::array<float,2>{0.935166836f, 0.0351885706f},
std::array<float,2>{0.823235333f, 0.56517458f},
std::array<float,2>{0.256246954f, 0.42966938f},
std::array<float,2>{0.123850085f, 0.845438838f},
std::array<float,2>{0.610850394f, 0.10108614f},
std::array<float,2>{0.670122504f, 0.993251204f},
std::array<float,2>{0.221563697f, 0.240045175f},
std::array<float,2>{0.399319589f, 0.746435046f},
std::array<float,2>{0.969696999f, 0.367391169f},
std::array<float,2>{0.902527571f, 0.763133883f},
std::array<float,2>{0.459793389f, 0.00378388586f},
std::array<float,2>{0.15771018f, 0.534963429f},
std::array<float,2>{0.722561955f, 0.44665283f},
std::array<float,2>{0.504221559f, 0.637458563f},
std::array<float,2>{0.0340422951f, 0.307433069f},
std::array<float,2>{0.340823501f, 0.923268616f},
std::array<float,2>{0.797688067f, 0.153891042f},
std::array<float,2>{0.930511415f, 0.589559317f},
std::array<float,2>{0.475267798f, 0.419229656f},
std::array<float,2>{0.130765378f, 0.862650692f},
std::array<float,2>{0.702100873f, 0.116994165f},
std::array<float,2>{0.559080482f, 0.984182119f},
std::array<float,2>{0.0123620797f, 0.220997036f},
std::array<float,2>{0.353795767f, 0.729902089f},
std::array<float,2>{0.760653079f, 0.353512436f},
std::array<float,2>{0.865300655f, 0.769802272f},
std::array<float,2>{0.289877295f, 0.0227699559f},
std::array<float,2>{0.0932617411f, 0.550273478f},
std::array<float,2>{0.58496511f, 0.45377335f},
std::array<float,2>{0.634289682f, 0.644047976f},
std::array<float,2>{0.208253935f, 0.285351932f},
std::array<float,2>{0.437416822f, 0.91936487f},
std::array<float,2>{0.947664142f, 0.131853029f},
std::array<float,2>{0.802736402f, 0.690238714f},
std::array<float,2>{0.337664127f, 0.330198675f},
std::array<float,2>{0.0387975983f, 0.953052342f},
std::array<float,2>{0.500621319f, 0.199303895f},
std::array<float,2>{0.726033866f, 0.813705802f},
std::array<float,2>{0.163375467f, 0.0676207244f},
std::array<float,2>{0.45549193f, 0.60756129f},
std::array<float,2>{0.899105966f, 0.392989725f},
std::array<float,2>{0.976016104f, 0.882478237f},
std::array<float,2>{0.403558969f, 0.167490274f},
std::array<float,2>{0.222818047f, 0.663766861f},
std::array<float,2>{0.665146649f, 0.266518325f},
std::array<float,2>{0.616492808f, 0.519847333f},
std::array<float,2>{0.117381617f, 0.476195455f},
std::array<float,2>{0.250684738f, 0.793366492f},
std::array<float,2>{0.82806778f, 0.0532695763f},
std::array<float,2>{0.96722436f, 0.67671895f},
std::array<float,2>{0.418503761f, 0.258139968f},
std::array<float,2>{0.202596128f, 0.891399741f},
std::array<float,2>{0.644225121f, 0.182581007f},
std::array<float,2>{0.56460011f, 0.799226999f},
std::array<float,2>{0.0703323334f, 0.0457684882f},
std::array<float,2>{0.311196804f, 0.505680442f},
std::array<float,2>{0.859029293f, 0.48525539f},
std::array<float,2>{0.773543f, 0.960030735f},
std::array<float,2>{0.359933019f, 0.2031755f},
std::array<float,2>{0.0192400627f, 0.709374666f},
std::array<float,2>{0.531652391f, 0.316525191f},
std::array<float,2>{0.714198887f, 0.622053444f},
std::array<float,2>{0.149421901f, 0.385810643f},
std::array<float,2>{0.487658203f, 0.835688531f},
std::array<float,2>{0.907402933f, 0.0793471187f},
std::array<float,2>{0.843567431f, 0.546457767f},
std::array<float,2>{0.277785718f, 0.439192563f},
std::array<float,2>{0.106820598f, 0.754680634f},
std::array<float,2>{0.598488748f, 0.0154351564f},
std::array<float,2>{0.679588854f, 0.933180988f},
std::array<float,2>{0.239827439f, 0.143307641f},
std::array<float,2>{0.386800438f, 0.629627585f},
std::array<float,2>{0.993978441f, 0.301678389f},
std::array<float,2>{0.87591809f, 0.858268738f},
std::array<float,2>{0.445336461f, 0.102444574f},
std::array<float,2>{0.181721732f, 0.573876083f},
std::array<float,2>{0.742047489f, 0.431018293f},
std::array<float,2>{0.523186862f, 0.741712332f},
std::array<float,2>{0.0612217151f, 0.360540211f},
std::array<float,2>{0.327753335f, 0.987763941f},
std::array<float,2>{0.786599278f, 0.248359859f},
std::array<float,2>{0.991032422f, 0.508322537f},
std::array<float,2>{0.382246464f, 0.495879173f},
std::array<float,2>{0.24672623f, 0.805226386f},
std::array<float,2>{0.68137598f, 0.0333646685f},
std::array<float,2>{0.609140038f, 0.904363453f},
std::array<float,2>{0.097302869f, 0.174023107f},
std::array<float,2>{0.266038865f, 0.680374861f},
std::array<float,2>{0.832615316f, 0.253578335f},
std::array<float,2>{0.789868474f, 0.839132607f},
std::array<float,2>{0.315484464f, 0.0923539102f},
std::array<float,2>{0.054514695f, 0.611471534f},
std::array<float,2>{0.524776042f, 0.382517219f},
std::array<float,2>{0.743002236f, 0.714228034f},
std::array<float,2>{0.174272224f, 0.326064825f},
std::array<float,2>{0.438407063f, 0.965357006f},
std::array<float,2>{0.884195983f, 0.21501264f},
std::array<float,2>{0.847084224f, 0.63317734f},
std::array<float,2>{0.301629096f, 0.310005456f},
std::array<float,2>{0.062593326f, 0.926071644f},
std::array<float,2>{0.575735033f, 0.149361968f},
std::array<float,2>{0.64883244f, 0.759608507f},
std::array<float,2>{0.189166203f, 0.00456456607f},
std::array<float,2>{0.411917686f, 0.53810966f},
std::array<float,2>{0.955755353f, 0.452226758f},
std::array<float,2>{0.91833359f, 0.998782694f},
std::array<float,2>{0.495841771f, 0.238198966f},
std::array<float,2>{0.14734368f, 0.744865835f},
std::array<float,2>{0.710198998f, 0.371289372f},
std::array<float,2>{0.539604187f, 0.567859173f},
std::array<float,2>{0.0235920697f, 0.422139227f},
std::array<float,2>{0.370426238f, 0.848721027f},
std::array<float,2>{0.76671344f, 0.0943353623f},
std::array<float,2>{0.891121209f, 0.721825719f},
std::array<float,2>{0.467360824f, 0.345005393f},
std::array<float,2>{0.167454392f, 0.971206903f},
std::array<float,2>{0.728426874f, 0.227635011f},
std::array<float,2>{0.511685848f, 0.870809436f},
std::array<float,2>{0.0444343649f, 0.122739553f},
std::array<float,2>{0.32817772f, 0.583226681f},
std::array<float,2>{0.808145463f, 0.406751752f},
std::array<float,2>{0.819121957f, 0.913442969f},
std::array<float,2>{0.263097912f, 0.136726648f},
std::array<float,2>{0.112273254f, 0.650063097f},
std::array<float,2>{0.622368991f, 0.295514882f},
std::array<float,2>{0.657418132f, 0.554691076f},
std::array<float,2>{0.232582644f, 0.467243105f},
std::array<float,2>{0.396873891f, 0.777323604f},
std::array<float,2>{0.979460657f, 0.0288908482f},
std::array<float,2>{0.755973935f, 0.595756292f},
std::array<float,2>{0.34987253f, 0.404363871f},
std::array<float,2>{0.00312712975f, 0.826488197f},
std::array<float,2>{0.554497063f, 0.0753923282f},
std::array<float,2>{0.693286836f, 0.940462232f},
std::array<float,2>{0.13656345f, 0.191551849f},
std::array<float,2>{0.480830103f, 0.698739231f},
std::array<float,2>{0.925095737f, 0.338328451f},
std::array<float,2>{0.941877604f, 0.781474113f},
std::array<float,2>{0.422709346f, 0.0553527512f},
std::array<float,2>{0.214896739f, 0.523881495f},
std::array<float,2>{0.63245213f, 0.47687611f},
std::array<float,2>{0.587713599f, 0.669412017f},
std::array<float,2>{0.0830828249f, 0.274465263f},
std::array<float,2>{0.286067694f, 0.883416831f},
std::array<float,2>{0.87361753f, 0.161409542f},
std::array<float,2>{0.950848341f, 0.61700362f},
std::array<float,2>{0.432977706f, 0.375467807f},
std::array<float,2>{0.205061972f, 0.842517853f},
std::array<float,2>{0.637009501f, 0.0869728327f},
std::array<float,2>{0.580263495f, 0.961172342f},
std::array<float,2>{0.0896114185f, 0.211183652f},
std::array<float,2>{0.2952151f, 0.71676147f},
std::array<float,2>{0.86295563f, 0.323096067f},
std::array<float,2>{0.763888001f, 0.809790432f},
std::array<float,2>{0.357213795f, 0.0356920995f},
std::array<float,2>{0.00845064037f, 0.512128651f},
std::array<float,2>{0.556760371f, 0.496792436f},
std::array<float,2>{0.69797498f, 0.686244369f},
std::array<float,2>{0.126547754f, 0.256498367f},
std::array<float,2>{0.470693737f, 0.899294615f},
std::array<float,2>{0.936462522f, 0.178955004f},
std::array<float,2>{0.821389675f, 0.746609628f},
std::array<float,2>{0.2541852f, 0.368062705f},
std::array<float,2>{0.121470079f, 0.993817031f},
std::array<float,2>{0.611397266f, 0.239306971f},
std::array<float,2>{0.669024944f, 0.844969571f},
std::array<float,2>{0.219338611f, 0.100817099f},
std::array<float,2>{0.401494503f, 0.564564109f},
std::array<float,2>{0.97150892f, 0.428948641f},
std::array<float,2>{0.905430257f, 0.923465669f},
std::array<float,2>{0.457487077f, 0.15362522f},
std::array<float,2>{0.159569979f, 0.636801779f},
std::array<float,2>{0.719328821f, 0.307115585f},
std::array<float,2>{0.507741868f, 0.534642577f},
std::array<float,2>{0.0317670256f, 0.446856886f},
std::array<float,2>{0.343281835f, 0.763429821f},
std::array<float,2>{0.800003767f, 0.00335921533f},
std::array<float,2>{0.911250174f, 0.654607654f},
std::array<float,2>{0.48890081f, 0.289577723f},
std::array<float,2>{0.154762805f, 0.909936488f},
std::array<float,2>{0.715873778f, 0.135778651f},
std::array<float,2>{0.535887182f, 0.780522943f},
std::array<float,2>{0.0218944754f, 0.0265511051f},
std::array<float,2>{0.366597503f, 0.562082171f},
std::array<float,2>{0.779913545f, 0.464795083f},
std::array<float,2>{0.85326463f, 0.973915279f},
std::array<float,2>{0.305033445f, 0.234185562f},
std::array<float,2>{0.0760045424f, 0.723902285f},
std::array<float,2>{0.568334579f, 0.348684251f},
std::array<float,2>{0.647364855f, 0.578478694f},
std::array<float,2>{0.198692083f, 0.410386086f},
std::array<float,2>{0.415702581f, 0.872237802f},
std::array<float,2>{0.962616324f, 0.119898953f},
std::array<float,2>{0.782358229f, 0.530291677f},
std::array<float,2>{0.321394712f, 0.482624859f},
std::array<float,2>{0.0563719161f, 0.78700453f},
std::array<float,2>{0.517809927f, 0.0614978261f},
std::array<float,2>{0.73517859f, 0.889310002f},
std::array<float,2>{0.187265113f, 0.158524439f},
std::array<float,2>{0.449259341f, 0.667431116f},
std::array<float,2>{0.881295919f, 0.277852595f},
std::array<float,2>{0.998532772f, 0.82281673f},
std::array<float,2>{0.384952992f, 0.0709791631f},
std::array<float,2>{0.236579031f, 0.597988009f},
std::array<float,2>{0.673526168f, 0.399901658f},
std::array<float,2>{0.597627163f, 0.699534595f},
std::array<float,2>{0.101923563f, 0.34251672f},
std::array<float,2>{0.276009619f, 0.944057703f},
std::array<float,2>{0.837171853f, 0.18820107f},
std::array<float,2>{0.887797713f, 0.552199364f},
std::array<float,2>{0.441975355f, 0.459568173f},
std::array<float,2>{0.177437887f, 0.767060161f},
std::array<float,2>{0.7499457f, 0.017544603f},
std::array<float,2>{0.528359652f, 0.915904343f},
std::array<float,2>{0.0484014153f, 0.128113434f},
std::array<float,2>{0.318090618f, 0.645809412f},
std::array<float,2>{0.793462515f, 0.283294022f},
std::array<float,2>{0.830123961f, 0.863684237f},
std::array<float,2>{0.269613355f, 0.110135436f},
std::array<float,2>{0.0992582813f, 0.593210459f},
std::array<float,2>{0.602747142f, 0.41426146f},
std::array<float,2>{0.685093284f, 0.733189106f},
std::array<float,2>{0.24589549f, 0.355885208f},
std::array<float,2>{0.377612919f, 0.977729023f},
std::array<float,2>{0.98598063f, 0.226450562f},
std::array<float,2>{0.770982563f, 0.657058477f},
std::array<float,2>{0.374647558f, 0.272663713f},
std::array<float,2>{0.0296981819f, 0.875089824f},
std::array<float,2>{0.545231938f, 0.170737728f},
std::array<float,2>{0.705740571f, 0.790618777f},
std::array<float,2>{0.144369051f, 0.0491739027f},
std::array<float,2>{0.498295248f, 0.517896473f},
std::array<float,2>{0.914831042f, 0.470085502f},
std::array<float,2>{0.959291816f, 0.947659373f},
std::array<float,2>{0.407228649f, 0.198296398f},
std::array<float,2>{0.192618683f, 0.694594145f},
std::array<float,2>{0.654727221f, 0.335000455f},
std::array<float,2>{0.57234931f, 0.602951646f},
std::array<float,2>{0.0669923574f, 0.396084994f},
std::array<float,2>{0.299284846f, 0.817837715f},
std::array<float,2>{0.849325716f, 0.0646998435f},
std::array<float,2>{0.983139098f, 0.706799746f},
std::array<float,2>{0.390952706f, 0.314727575f},
std::array<float,2>{0.227112427f, 0.954951406f},
std::array<float,2>{0.663412333f, 0.208560303f},
std::array<float,2>{0.619359255f, 0.828745127f},
std::array<float,2>{0.114741109f, 0.0858841315f},
std::array<float,2>{0.259765446f, 0.620402575f},
std::array<float,2>{0.814200938f, 0.388788342f},
std::array<float,2>{0.811035991f, 0.897485554f},
std::array<float,2>{0.332066178f, 0.186578423f},
std::array<float,2>{0.0414790139f, 0.672476411f},
std::array<float,2>{0.511941493f, 0.26283592f},
std::array<float,2>{0.731808186f, 0.500308514f},
std::array<float,2>{0.17177777f, 0.491613328f},
std::array<float,2>{0.463668972f, 0.802017987f},
std::array<float,2>{0.897151172f, 0.0414132401f},
std::array<float,2>{0.870106161f, 0.575722873f},
std::array<float,2>{0.283033222f, 0.436807752f},
std::array<float,2>{0.0820111036f, 0.854242265f},
std::array<float,2>{0.592246771f, 0.108023398f},
std::array<float,2>{0.628509521f, 0.989863813f},
std::array<float,2>{0.211705685f, 0.244511262f},
std::array<float,2>{0.428937912f, 0.737677157f},
std::array<float,2>{0.938360989f, 0.364968389f},
std::array<float,2>{0.928722978f, 0.75139159f},
std::array<float,2>{0.478757888f, 0.0093905339f},
std::array<float,2>{0.13987571f, 0.541089058f},
std::array<float,2>{0.690589011f, 0.445210546f},
std::array<float,2>{0.548405886f, 0.628269196f},
std::array<float,2>{0.006646981f, 0.297916889f},
std::array<float,2>{0.344210178f, 0.933648586f},
std::array<float,2>{0.752805531f, 0.144891515f},
std::array<float,2>{0.901232064f, 0.606890023f},
std::array<float,2>{0.45420596f, 0.391375989f},
std::array<float,2>{0.161620796f, 0.814685881f},
std::array<float,2>{0.724516451f, 0.070045799f},
std::array<float,2>{0.50368911f, 0.950269818f},
std::array<float,2>{0.0369141027f, 0.201556236f},
std::array<float,2>{0.339422643f, 0.688467801f},
std::array<float,2>{0.802111089f, 0.328211039f},
std::array<float,2>{0.825260758f, 0.795263469f},
std::array<float,2>{0.252407432f, 0.0523662865f},
std::array<float,2>{0.120118961f, 0.521938622f},
std::array<float,2>{0.614751399f, 0.473422706f},
std::array<float,2>{0.666871488f, 0.660963178f},
std::array<float,2>{0.224808291f, 0.269272327f},
std::array<float,2>{0.40524593f, 0.879029274f},
std::array<float,2>{0.973372519f, 0.1641379f},
std::array<float,2>{0.75930208f, 0.728043258f},
std::array<float,2>{0.353114128f, 0.354822487f},
std::array<float,2>{0.0154467598f, 0.981084168f},
std::array<float,2>{0.562498391f, 0.218755111f},
std::array<float,2>{0.699310005f, 0.860264838f},
std::array<float,2>{0.132538632f, 0.113623202f},
std::array<float,2>{0.474550188f, 0.587644637f},
std::array<float,2>{0.933417499f, 0.421144605f},
std::array<float,2>{0.946606696f, 0.920421124f},
std::array<float,2>{0.433947444f, 0.130707204f},
std::array<float,2>{0.209676802f, 0.640948772f},
std::array<float,2>{0.63547641f, 0.287247628f},
std::array<float,2>{0.582093954f, 0.548628867f},
std::array<float,2>{0.0910867825f, 0.456928581f},
std::array<float,2>{0.292913139f, 0.773301363f},
std::array<float,2>{0.865132511f, 0.0202267449f},
std::array<float,2>{0.996074915f, 0.631087959f},
std::array<float,2>{0.389116675f, 0.303453982f},
std::array<float,2>{0.241570875f, 0.931040823f},
std::array<float,2>{0.677250624f, 0.140847191f},
std::array<float,2>{0.599622488f, 0.757330418f},
std::array<float,2>{0.107866466f, 0.0121313361f},
std::array<float,2>{0.280801177f, 0.543655753f},
std::array<float,2>{0.841282845f, 0.440722287f},
std::array<float,2>{0.787584186f, 0.985154152f},
std::array<float,2>{0.324388236f, 0.247695163f},
std::array<float,2>{0.0597943142f, 0.738774836f},
std::array<float,2>{0.519974172f, 0.361421645f},
std::array<float,2>{0.740024924f, 0.571734309f},
std::array<float,2>{0.18104279f, 0.43183744f},
std::array<float,2>{0.44880721f, 0.856956363f},
std::array<float,2>{0.877144694f, 0.103616312f},
std::array<float,2>{0.855549455f, 0.507288575f},
std::array<float,2>{0.310053736f, 0.486880213f},
std::array<float,2>{0.072541289f, 0.798639476f},
std::array<float,2>{0.563002944f, 0.0448356569f},
std::array<float,2>{0.642143965f, 0.8928352f},
std::array<float,2>{0.200664371f, 0.180715442f},
std::array<float,2>{0.421224266f, 0.677736878f},
std::array<float,2>{0.964901149f, 0.260249257f},
std::array<float,2>{0.908639312f, 0.833381414f},
std::array<float,2>{0.485166252f, 0.0804735944f},
std::array<float,2>{0.152290091f, 0.623178482f},
std::array<float,2>{0.712371826f, 0.384197891f},
std::array<float,2>{0.534859836f, 0.707043946f},
std::array<float,2>{0.0162609518f, 0.318933934f},
std::array<float,2>{0.361799985f, 0.957075417f},
std::array<float,2>{0.77642566f, 0.206108689f},
std::array<float,2>{0.953399837f, 0.536367118f},
std::array<float,2>{0.412572533f, 0.450709313f},
std::array<float,2>{0.191003487f, 0.759974301f},
std::array<float,2>{0.651597559f, 0.00622288696f},
std::array<float,2>{0.576552689f, 0.928031623f},
std::array<float,2>{0.0654457137f, 0.151676089f},
std::array<float,2>{0.304273874f, 0.635928154f},
std::array<float,2>{0.844498277f, 0.311888486f},
std::array<float,2>{0.768697679f, 0.85080725f},
std::array<float,2>{0.367558122f, 0.0958753005f},
std::array<float,2>{0.0270325504f, 0.569119275f},
std::array<float,2>{0.541280687f, 0.424785912f},
std::array<float,2>{0.708599091f, 0.742315531f},
std::array<float,2>{0.145070806f, 0.373509586f},
std::array<float,2>{0.493873626f, 0.996662736f},
std::array<float,2>{0.920418501f, 0.235158548f},
std::array<float,2>{0.834224284f, 0.68276149f},
std::array<float,2>{0.269423842f, 0.250048548f},
std::array<float,2>{0.0954793394f, 0.902934968f},
std::array<float,2>{0.605762184f, 0.172889724f},
std::array<float,2>{0.683210254f, 0.807309031f},
std::array<float,2>{0.249728739f, 0.0323705636f},
std::array<float,2>{0.379217088f, 0.511419237f},
std::array<float,2>{0.98955673f, 0.492620438f},
std::array<float,2>{0.886318028f, 0.967572808f},
std::array<float,2>{0.439633995f, 0.217544839f},
std::array<float,2>{0.1723921f, 0.711596131f},
std::array<float,2>{0.744860411f, 0.327946782f},
std::array<float,2>{0.526542962f, 0.60940218f},
std::array<float,2>{0.0516182743f, 0.38066712f},
std::array<float,2>{0.314392596f, 0.836336255f},
std::array<float,2>{0.791227341f, 0.090825431f},
std::array<float,2>{0.922687411f, 0.697069824f},
std::array<float,2>{0.483656108f, 0.336109608f},
std::array<float,2>{0.133285075f, 0.937794805f},
std::array<float,2>{0.694272816f, 0.195219681f},
std::array<float,2>{0.551931858f, 0.824449658f},
std::array<float,2>{0.00191892521f, 0.0762058124f},
std::array<float,2>{0.348060489f, 0.594838083f},
std::array<float,2>{0.755032837f, 0.402829498f},
std::array<float,2>{0.871869147f, 0.885344148f},
std::array<float,2>{0.287564993f, 0.163359791f},
std::array<float,2>{0.0854152367f, 0.670907497f},
std::array<float,2>{0.589743257f, 0.275719225f},
std::array<float,2>{0.630725503f, 0.527179003f},
std::array<float,2>{0.217173189f, 0.480097145f},
std::array<float,2>{0.424699128f, 0.783238053f},
std::array<float,2>{0.944753051f, 0.0569431372f},
std::array<float,2>{0.805300713f, 0.584990978f},
std::array<float,2>{0.331023663f, 0.410000592f},
std::array<float,2>{0.045145385f, 0.867879212f},
std::array<float,2>{0.508412182f, 0.124634802f},
std::array<float,2>{0.729823411f, 0.970366895f},
std::array<float,2>{0.165350437f, 0.230340004f},
std::array<float,2>{0.466537178f, 0.719104528f},
std::array<float,2>{0.892892122f, 0.347533137f},
std::array<float,2>{0.97812438f, 0.775040686f},
std::array<float,2>{0.395832956f, 0.0310054291f},
std::array<float,2>{0.232222766f, 0.558467448f},
std::array<float,2>{0.658852518f, 0.465356857f},
std::array<float,2>{0.624290228f, 0.650883436f},
std::array<float,2>{0.110501572f, 0.294499964f},
std::array<float,2>{0.26396066f, 0.910580933f},
std::array<float,2>{0.817625105f, 0.139510766f},
std::array<float,2>{0.968955278f, 0.563871503f},
std::array<float,2>{0.3985596f, 0.426068276f},
std::array<float,2>{0.221171543f, 0.846788704f},
std::array<float,2>{0.670818329f, 0.0980568752f},
std::array<float,2>{0.610793173f, 0.99569577f},
std::array<float,2>{0.123298757f, 0.241378084f},
std::array<float,2>{0.256416678f, 0.749508321f},
std::array<float,2>{0.822536886f, 0.369460791f},
std::array<float,2>{0.797012389f, 0.764330149f},
std::array<float,2>{0.341412306f, 0.00136374659f},
std::array<float,2>{0.0336627215f, 0.531824529f},
std::array<float,2>{0.504876912f, 0.447491676f},
std::array<float,2>{0.722096562f, 0.639083445f},
std::array<float,2>{0.157878652f, 0.305613905f},
std::array<float,2>{0.459152609f, 0.924318969f},
std::array<float,2>{0.903206229f, 0.154682487f},
std::array<float,2>{0.860708416f, 0.717342317f},
std::array<float,2>{0.293640286f, 0.321183652f},
std::array<float,2>{0.087080054f, 0.964015722f},
std::array<float,2>{0.578608513f, 0.213077903f},
std::array<float,2>{0.640370131f, 0.841786087f},
std::array<float,2>{0.206733108f, 0.0883723497f},
std::array<float,2>{0.431146383f, 0.613421261f},
std::array<float,2>{0.951898217f, 0.377765894f},
std::array<float,2>{0.935048699f, 0.901707768f},
std::array<float,2>{0.471507847f, 0.176688939f},
std::array<float,2>{0.127896652f, 0.684668601f},
std::array<float,2>{0.695695341f, 0.254691035f},
std::array<float,2>{0.556430757f, 0.513966262f},
std::array<float,2>{0.0102723837f, 0.499950647f},
std::array<float,2>{0.357664645f, 0.811758637f},
std::array<float,2>{0.762552202f, 0.0389046259f},
std::array<float,2>{0.880496919f, 0.665599048f},
std::array<float,2>{0.451422811f, 0.280732065f},
std::array<float,2>{0.184189633f, 0.886902869f},
std::array<float,2>{0.737160325f, 0.158014968f},
std::array<float,2>{0.516158164f, 0.787931144f},
std::array<float,2>{0.0581282191f, 0.0602596961f},
std::array<float,2>{0.323131949f, 0.528249562f},
std::array<float,2>{0.783815145f, 0.480597317f},
std::array<float,2>{0.838944674f, 0.942375958f},
std::array<float,2>{0.27526769f, 0.191306502f},
std::array<float,2>{0.103801899f, 0.70170635f},
std::array<float,2>{0.594219923f, 0.340895027f},
std::array<float,2>{0.674548328f, 0.600898027f},
std::array<float,2>{0.235111475f, 0.401755482f},
std::array<float,2>{0.384230494f, 0.821486831f},
std::array<float,2>{0.996622324f, 0.0725077763f},
std::array<float,2>{0.778464675f, 0.558852792f},
std::array<float,2>{0.364564508f, 0.461418509f},
std::array<float,2>{0.0196358245f, 0.777999461f},
std::array<float,2>{0.538700819f, 0.0241276212f},
std::array<float,2>{0.717501342f, 0.906474411f},
std::array<float,2>{0.153639227f, 0.133186758f},
std::array<float,2>{0.490830481f, 0.653966963f},
std::array<float,2>{0.913061082f, 0.292660356f},
std::array<float,2>{0.963935256f, 0.874318004f},
std::array<float,2>{0.416864663f, 0.118680768f},
std::array<float,2>{0.197172672f, 0.581090868f},
std::array<float,2>{0.646214068f, 0.413780659f},
std::array<float,2>{0.568603933f, 0.725852013f},
std::array<float,2>{0.0771492496f, 0.351152807f},
std::array<float,2>{0.308172047f, 0.976020038f},
std::array<float,2>{0.85507673f, 0.231350377f},
std::array<float,2>{0.916042447f, 0.516501784f},
std::array<float,2>{0.496561855f, 0.471260607f},
std::array<float,2>{0.141335785f, 0.791126251f},
std::array<float,2>{0.70355916f, 0.0472090207f},
std::array<float,2>{0.544623256f, 0.878850102f},
std::array<float,2>{0.0275339428f, 0.168693498f},
std::array<float,2>{0.37110433f, 0.658932328f},
std::array<float,2>{0.773113072f, 0.27061829f},
std::array<float,2>{0.850261271f, 0.819017231f},
std::array<float,2>{0.298615664f, 0.0627464503f},
std::array<float,2>{0.0690251663f, 0.604954541f},
std::array<float,2>{0.571494758f, 0.397088468f},
std::array<float,2>{0.653420091f, 0.692656398f},
std::array<float,2>{0.194702536f, 0.332835317f},
std::array<float,2>{0.409905434f, 0.946686804f},
std::array<float,2>{0.957957149f, 0.195753083f},
std::array<float,2>{0.795119882f, 0.64809376f},
std::array<float,2>{0.319984645f, 0.281916231f},
std::array<float,2>{0.0492529944f, 0.916862309f},
std::array<float,2>{0.529437959f, 0.125469565f},
std::array<float,2>{0.747128546f, 0.767849028f},
std::array<float,2>{0.177874804f, 0.0181258805f},
std::array<float,2>{0.444305301f, 0.553905308f},
std::array<float,2>{0.888695776f, 0.458668351f},
std::array<float,2>{0.987936676f, 0.979750931f},
std::array<float,2>{0.375476897f, 0.224045843f},
std::array<float,2>{0.242995039f, 0.732110202f},
std::array<float,2>{0.686779857f, 0.359262496f},
std::array<float,2>{0.604536593f, 0.591007054f},
std::array<float,2>{0.100406326f, 0.417944521f},
std::array<float,2>{0.272028744f, 0.865993381f},
std::array<float,2>{0.828849614f, 0.111736774f},
std::array<float,2>{0.940410078f, 0.736094832f},
std::array<float,2>{0.427693218f, 0.366770357f},
std::array<float,2>{0.213131011f, 0.990329504f},
std::array<float,2>{0.625470996f, 0.244014993f},
std::array<float,2>{0.591587842f, 0.85156709f},
std::array<float,2>{0.0793749988f, 0.105881125f},
std::array<float,2>{0.283505201f, 0.577786803f},
std::array<float,2>{0.868927956f, 0.435424745f},
std::array<float,2>{0.750930846f, 0.936429977f},
std::array<float,2>{0.345959246f, 0.148239687f},
std::array<float,2>{0.00403523911f, 0.62515986f},
std::array<float,2>{0.549262524f, 0.300001949f},
std::array<float,2>{0.688600779f, 0.539234519f},
std::array<float,2>{0.137860432f, 0.442973584f},
std::array<float,2>{0.477315903f, 0.753694057f},
std::array<float,2>{0.926550567f, 0.0106102489f},
std::array<float,2>{0.814603567f, 0.618718505f},
std::array<float,2>{0.261338323f, 0.388105482f},
std::array<float,2>{0.115804516f, 0.831182539f},
std::array<float,2>{0.618235588f, 0.0831342191f},
std::array<float,2>{0.660230935f, 0.955735505f},
std::array<float,2>{0.228565529f, 0.210269883f},
std::array<float,2>{0.394054592f, 0.703319311f},
std::array<float,2>{0.981298149f, 0.313585371f},
std::array<float,2>{0.895565033f, 0.803872645f},
std::array<float,2>{0.461350054f, 0.0398412384f},
std::array<float,2>{0.168211699f, 0.503583729f},
std::array<float,2>{0.734240949f, 0.488921046f},
std::array<float,2>{0.51502198f, 0.67462796f},
std::array<float,2>{0.0392327681f, 0.264968753f},
std::array<float,2>{0.334931016f, 0.89508456f},
std::array<float,2>{0.810489237f, 0.185460702f},
std::array<float,2>{0.906677604f, 0.624981344f},
std::array<float,2>{0.48703301f, 0.382937074f},
std::array<float,2>{0.149336576f, 0.832665861f},
std::array<float,2>{0.713344038f, 0.0815625563f},
std::array<float,2>{0.533007026f, 0.9581514f},
std::array<float,2>{0.0180039238f, 0.20557633f},
std::array<float,2>{0.360855699f, 0.708613217f},
std::array<float,2>{0.775278151f, 0.319742233f},
std::array<float,2>{0.858326793f, 0.797033072f},
std::array<float,2>{0.312263936f, 0.043643374f},
std::array<float,2>{0.0713932961f, 0.506248176f},
std::array<float,2>{0.56628859f, 0.488268405f},
std::array<float,2>{0.642799318f, 0.678723872f},
std::array<float,2>{0.20213519f, 0.261651188f},
std::array<float,2>{0.419798046f, 0.893760979f},
std::array<float,2>{0.967855155f, 0.18004702f},
std::array<float,2>{0.7854141f, 0.739567637f},
std::array<float,2>{0.326802045f, 0.362816602f},
std::array<float,2>{0.0623048507f, 0.98610127f},
std::array<float,2>{0.522412181f, 0.246096507f},
std::array<float,2>{0.740395069f, 0.855662167f},
std::array<float,2>{0.182967961f, 0.105263837f},
std::array<float,2>{0.447034031f, 0.570604444f},
std::array<float,2>{0.876635015f, 0.432876676f},
std::array<float,2>{0.993152082f, 0.930208981f},
std::array<float,2>{0.387934923f, 0.141836479f},
std::array<float,2>{0.238404632f, 0.632018805f},
std::array<float,2>{0.678589404f, 0.303747982f},
std::array<float,2>{0.599428475f, 0.544733226f},
std::array<float,2>{0.105750687f, 0.440283865f},
std::array<float,2>{0.27919957f, 0.756388426f},
std::array<float,2>{0.842601478f, 0.0135673648f},
std::array<float,2>{0.948994935f, 0.642407179f},
std::array<float,2>{0.436344534f, 0.288444668f},
std::array<float,2>{0.207085639f, 0.920919716f},
std::array<float,2>{0.633545339f, 0.129738048f},
std::array<float,2>{0.584211349f, 0.772104561f},
std::array<float,2>{0.0922098607f, 0.0206314735f},
std::array<float,2>{0.290885597f, 0.547579348f},
std::array<float,2>{0.866987288f, 0.455922574f},
std::array<float,2>{0.761593342f, 0.981812358f},
std::array<float,2>{0.355430126f, 0.220054612f},
std::array<float,2>{0.0132199731f, 0.727034569f},
std::array<float,2>{0.560335994f, 0.353898883f},
std::array<float,2>{0.702808857f, 0.586086035f},
std::array<float,2>{0.129053861f, 0.42062071f},
std::array<float,2>{0.475784481f, 0.86082077f},
std::array<float,2>{0.931211174f, 0.114307798f},
std::array<float,2>{0.826564074f, 0.523322642f},
std::array<float,2>{0.251550555f, 0.473719627f},
std::array<float,2>{0.118278384f, 0.79671663f},
std::array<float,2>{0.615652978f, 0.0513115562f},
std::array<float,2>{0.664144754f, 0.880066574f},
std::array<float,2>{0.224185795f, 0.165871486f},
std::array<float,2>{0.402346402f, 0.662050009f},
std::array<float,2>{0.975046873f, 0.267764539f},
std::array<float,2>{0.89945066f, 0.815457046f},
std::array<float,2>{0.456461072f, 0.0684529468f},
std::array<float,2>{0.162358969f, 0.605677664f},
std::array<float,2>{0.725308836f, 0.391768694f},
std::array<float,2>{0.501754761f, 0.68912214f},
std::array<float,2>{0.0374203734f, 0.329345703f},
std::array<float,2>{0.336211413f, 0.950158477f},
std::array<float,2>{0.804096341f, 0.20241636f},
std::array<float,2>{0.979809701f, 0.557319164f},
std::array<float,2>{0.397808105f, 0.466739178f},
std::array<float,2>{0.233839542f, 0.77418977f},
std::array<float,2>{0.656888306f, 0.0295229387f},
std::array<float,2>{0.621114671f, 0.911612153f},
std::array<float,2>{0.113046184f, 0.140456274f},
std::array<float,2>{0.262333035f, 0.651827514f},
std::array<float,2>{0.81976223f, 0.293405801f},
std::array<float,2>{0.80745101f, 0.868551493f},
std::array<float,2>{0.32937181f, 0.123057187f},
std::array<float,2>{0.0437345803f, 0.584402502f},
std::array<float,2>{0.510720551f, 0.408520818f},
std::array<float,2>{0.727136374f, 0.720496535f},
std::array<float,2>{0.166124001f, 0.346047729f},
std::array<float,2>{0.468599379f, 0.96906656f},
std::array<float,2>{0.891933799f, 0.228770614f},
std::array<float,2>{0.874032319f, 0.670244694f},
std::array<float,2>{0.286256373f, 0.276793003f},
std::array<float,2>{0.0825664029f, 0.886195123f},
std::array<float,2>{0.586487472f, 0.162266836f},
std::array<float,2>{0.631818354f, 0.784608901f},
std::array<float,2>{0.216559112f, 0.05778189f},
std::array<float,2>{0.423373729f, 0.526349187f},
std::array<float,2>{0.942832589f, 0.478835225f},
std::array<float,2>{0.923904896f, 0.939384162f},
std::array<float,2>{0.481723994f, 0.194206297f},
std::array<float,2>{0.135734886f, 0.695984602f},
std::array<float,2>{0.691438496f, 0.337770611f},
std::array<float,2>{0.553099692f, 0.59455049f},
std::array<float,2>{0.00200417917f, 0.403817236f},
std::array<float,2>{0.351444602f, 0.826104581f},
std::array<float,2>{0.75687933f, 0.077905342f},
std::array<float,2>{0.8835482f, 0.712169051f},
std::array<float,2>{0.438483715f, 0.32700485f},
std::array<float,2>{0.175053f, 0.968221486f},
std::array<float,2>{0.743683636f, 0.21785596f},
std::array<float,2>{0.523491621f, 0.837836981f},
std::array<float,2>{0.0535788275f, 0.0903988481f},
std::array<float,2>{0.314941764f, 0.610861778f},
std::array<float,2>{0.790768921f, 0.379545659f},
std::array<float,2>{0.833399713f, 0.903434992f},
std::array<float,2>{0.267543852f, 0.172550023f},
std::array<float,2>{0.0963935852f, 0.682265699f},
std::array<float,2>{0.607574701f, 0.251669079f},
std::array<float,2>{0.680197239f, 0.510304928f},
std::array<float,2>{0.247607231f, 0.493391365f},
std::array<float,2>{0.381325901f, 0.808039606f},
std::array<float,2>{0.991635919f, 0.0319542661f},
std::array<float,2>{0.765711188f, 0.569678903f},
std::array<float,2>{0.369768173f, 0.425686747f},
std::array<float,2>{0.0246827882f, 0.850113451f},
std::array<float,2>{0.541012764f, 0.0967152864f},
std::array<float,2>{0.709810078f, 0.997480214f},
std::array<float,2>{0.148374602f, 0.235935271f},
std::array<float,2>{0.494575769f, 0.744002283f},
std::array<float,2>{0.919044614f, 0.374073476f},
std::array<float,2>{0.956308186f, 0.761317909f},
std::array<float,2>{0.41078645f, 0.00744898384f},
std::array<float,2>{0.18786779f, 0.535705864f},
std::array<float,2>{0.649879158f, 0.449878544f},
std::array<float,2>{0.574399829f, 0.63558048f},
std::array<float,2>{0.0641417727f, 0.310765147f},
std::array<float,2>{0.30262363f, 0.929209054f},
std::array<float,2>{0.845998168f, 0.150638476f},
std::array<float,2>{0.961290002f, 0.580846429f},
std::array<float,2>{0.414497286f, 0.412835598f},
std::array<float,2>{0.197610691f, 0.8740049f},
std::array<float,2>{0.647660911f, 0.117779836f},
std::array<float,2>{0.567126989f, 0.974736333f},
std::array<float,2>{0.0748928562f, 0.231921583f},
std::array<float,2>{0.306420326f, 0.725554824f},
std::array<float,2>{0.851901293f, 0.349794269f},
std::array<float,2>{0.781189203f, 0.778915584f},
std::array<float,2>{0.365357131f, 0.0253582299f},
std::array<float,2>{0.0232505053f, 0.560001671f},
std::array<float,2>{0.536711037f, 0.462333441f},
std::array<float,2>{0.715263724f, 0.653201938f},
std::array<float,2>{0.15609625f, 0.291785955f},
std::array<float,2>{0.489936084f, 0.907388091f},
std::array<float,2>{0.911132514f, 0.13462688f},
std::array<float,2>{0.836514533f, 0.702297807f},
std::array<float,2>{0.277278513f, 0.339919001f},
std::array<float,2>{0.103471309f, 0.943229377f},
std::array<float,2>{0.596605062f, 0.190130666f},
std::array<float,2>{0.67263633f, 0.821038663f},
std::array<float,2>{0.238167316f, 0.0736933872f},
std::array<float,2>{0.386225671f, 0.599650264f},
std::array<float,2>{0.999465466f, 0.4009296f},
std::array<float,2>{0.88231492f, 0.887849033f},
std::array<float,2>{0.450810671f, 0.156740174f},
std::array<float,2>{0.185607016f, 0.664438367f},
std::array<float,2>{0.735534191f, 0.279801697f},
std::array<float,2>{0.518892705f, 0.528664649f},
std::array<float,2>{0.0549042933f, 0.482146025f},
std::array<float,2>{0.321093053f, 0.789030313f},
std::array<float,2>{0.782217205f, 0.058656048f},
std::array<float,2>{0.936729193f, 0.684249461f},
std::array<float,2>{0.468871295f, 0.255721122f},
std::array<float,2>{0.125481099f, 0.901016712f},
std::array<float,2>{0.698534906f, 0.177055582f},
std::array<float,2>{0.557740152f, 0.811251104f},
std::array<float,2>{0.00881420355f, 0.0378382578f},
std::array<float,2>{0.356410384f, 0.51513958f},
std::array<float,2>{0.765320897f, 0.49893409f},
std::array<float,2>{0.861361802f, 0.963453829f},
std::array<float,2>{0.296247423f, 0.21438314f},
std::array<float,2>{0.0881787315f, 0.718185127f},
std::array<float,2>{0.58190757f, 0.322151244f},
std::array<float,2>{0.637731493f, 0.614425004f},
std::array<float,2>{0.203619093f, 0.378417969f},
std::array<float,2>{0.431993306f, 0.840227485f},
std::array<float,2>{0.949831545f, 0.0896113515f},
std::array<float,2>{0.799566865f, 0.53254199f},
std::array<float,2>{0.342154205f, 0.448849797f},
std::array<float,2>{0.033085268f, 0.76561296f},
std::array<float,2>{0.5060215f, 0.000652751944f},
std::array<float,2>{0.720621109f, 0.925197005f},
std::array<float,2>{0.158460945f, 0.156226382f},
std::array<float,2>{0.458576173f, 0.640233576f},
std::array<float,2>{0.904601812f, 0.3057639f},
std::array<float,2>{0.972016037f, 0.846075952f},
std::array<float,2>{0.401077867f, 0.0992814898f},
std::array<float,2>{0.220050201f, 0.563040793f},
std::array<float,2>{0.668436885f, 0.426941365f},
std::array<float,2>{0.612873912f, 0.74865365f},
std::array<float,2>{0.122449026f, 0.370942265f},
std::array<float,2>{0.255612999f, 0.994989634f},
std::array<float,2>{0.820719957f, 0.241003066f},
std::array<float,2>{0.89771986f, 0.502648473f},
std::array<float,2>{0.463948786f, 0.489434987f},
std::array<float,2>{0.170748085f, 0.803351939f},
std::array<float,2>{0.73128289f, 0.0405121818f},
std::array<float,2>{0.512784064f, 0.896360099f},
std::array<float,2>{0.0422056131f, 0.183843613f},
std::array<float,2>{0.333891392f, 0.674881697f},
std::array<float,2>{0.812296987f, 0.264366537f},
std::array<float,2>{0.812876403f, 0.830447614f},
std::array<float,2>{0.257867277f, 0.0828803927f},
std::array<float,2>{0.113561682f, 0.617429197f},
std::array<float,2>{0.62061739f, 0.386909008f},
std::array<float,2>{0.662732124f, 0.704925358f},
std::array<float,2>{0.227790549f, 0.31316945f},
std::array<float,2>{0.391627133f, 0.956788421f},
std::array<float,2>{0.984105885f, 0.209189191f},
std::array<float,2>{0.753398478f, 0.626572371f},
std::array<float,2>{0.344735473f, 0.299390316f},
std::array<float,2>{0.00728525408f, 0.936969042f},
std::array<float,2>{0.547022879f, 0.146559104f},
std::array<float,2>{0.690360248f, 0.752380669f},
std::array<float,2>{0.138870254f, 0.0114803277f},
std::array<float,2>{0.480047226f, 0.540100336f},
std::array<float,2>{0.928315043f, 0.442259192f},
std::array<float,2>{0.93913579f, 0.991269112f},
std::array<float,2>{0.428536117f, 0.243151531f},
std::array<float,2>{0.212197706f, 0.734615266f},
std::array<float,2>{0.62722224f, 0.366207093f},
std::array<float,2>{0.593623102f, 0.577114165f},
std::array<float,2>{0.0801056176f, 0.433790237f},
std::array<float,2>{0.28218025f, 0.853065014f},
std::array<float,2>{0.870388687f, 0.106851369f},
std::array<float,2>{0.984679699f, 0.730643034f},
std::array<float,2>{0.378062516f, 0.35798198f},
std::array<float,2>{0.244574025f, 0.97852242f},
std::array<float,2>{0.683784664f, 0.222765312f},
std::array<float,2>{0.602293193f, 0.866540074f},
std::array<float,2>{0.0980106816f, 0.112778626f},
std::array<float,2>{0.270777345f, 0.590451896f},
std::array<float,2>{0.831391871f, 0.4166722f},
std::array<float,2>{0.794153571f, 0.917261541f},
std::array<float,2>{0.316775322f, 0.126835942f},
std::array<float,2>{0.0476458073f, 0.647389054f},
std::array<float,2>{0.527681231f, 0.282960653f},
std::array<float,2>{0.749017715f, 0.553527653f},
std::array<float,2>{0.176742151f, 0.457724988f},
std::array<float,2>{0.443166882f, 0.768733323f},
std::array<float,2>{0.886890352f, 0.0187474545f},
std::array<float,2>{0.848405898f, 0.603869617f},
std::array<float,2>{0.300275266f, 0.398303777f},
std::array<float,2>{0.0683478117f, 0.819583356f},
std::array<float,2>{0.573649228f, 0.0642526373f},
std::array<float,2>{0.655948699f, 0.945900202f},
std::array<float,2>{0.191711798f, 0.196763456f},
std::array<float,2>{0.406344861f, 0.691626191f},
std::array<float,2>{0.960765064f, 0.333943337f},
std::array<float,2>{0.915763617f, 0.792542338f},
std::array<float,2>{0.499360442f, 0.0487823635f},
std::array<float,2>{0.14265728f, 0.517143607f},
std::array<float,2>{0.706681013f, 0.471754581f},
std::array<float,2>{0.546659529f, 0.659433246f},
std::array<float,2>{0.0304940436f, 0.269622087f},
std::array<float,2>{0.373406142f, 0.87785995f},
std::array<float,2>{0.769532204f, 0.169002756f},
std::array<float,2>{0.878889084f, 0.573185802f},
std::array<float,2>{0.448052526f, 0.430616349f},
std::array<float,2>{0.180353165f, 0.85871774f},
std::array<float,2>{0.73868382f, 0.102885574f},
std::array<float,2>{0.521194577f, 0.986575067f},
std::array<float,2>{0.0588447638f, 0.249608204f},
std::array<float,2>{0.326017529f, 0.740828931f},
std::array<float,2>{0.788322091f, 0.359967828f},
std::array<float,2>{0.840772867f, 0.755783498f},
std::array<float,2>{0.279628336f, 0.0145344948f},
std::array<float,2>{0.10855674f, 0.545585036f},
std::array<float,2>{0.600908875f, 0.438017964f},
std::array<float,2>{0.676524758f, 0.63084203f},
std::array<float,2>{0.240948498f, 0.302003503f},
std::array<float,2>{0.390410244f, 0.932264686f},
std::array<float,2>{0.994462371f, 0.144098684f},
std::array<float,2>{0.776087821f, 0.710442722f},
std::array<float,2>{0.363253564f, 0.317601651f},
std::array<float,2>{0.0173773561f, 0.959106326f},
std::array<float,2>{0.533693433f, 0.204571769f},
std::array<float,2>{0.711107731f, 0.834259808f},
std::array<float,2>{0.151073322f, 0.0787119791f},
std::array<float,2>{0.485633463f, 0.622878373f},
std::array<float,2>{0.909696043f, 0.385741562f},
std::array<float,2>{0.965837538f, 0.892075598f},
std::array<float,2>{0.420493752f, 0.183367863f},
std::array<float,2>{0.199476078f, 0.677569866f},
std::array<float,2>{0.641510308f, 0.259013951f},
std::array<float,2>{0.563682079f, 0.504681826f},
std::array<float,2>{0.0741469413f, 0.485794038f},
std::array<float,2>{0.308821052f, 0.800539613f},
std::array<float,2>{0.856974721f, 0.0463747308f},
std::array<float,2>{0.974137545f, 0.662198782f},
std::array<float,2>{0.405975789f, 0.267123163f},
std::array<float,2>{0.226096421f, 0.881466269f},
std::array<float,2>{0.667139053f, 0.166607931f},
std::array<float,2>{0.613400578f, 0.794713795f},
std::array<float,2>{0.11956846f, 0.0545117073f},
std::array<float,2>{0.25332737f, 0.520674825f},
std::array<float,2>{0.824954748f, 0.474720508f},
std::array<float,2>{0.801483691f, 0.951899052f},
std::array<float,2>{0.338406563f, 0.20100674f},
std::array<float,2>{0.0360864885f, 0.690944433f},
std::array<float,2>{0.502779007f, 0.331726789f},
std::array<float,2>{0.723594129f, 0.608454585f},
std::array<float,2>{0.160274506f, 0.393762022f},
std::array<float,2>{0.453753263f, 0.813305497f},
std::array<float,2>{0.901867032f, 0.0664561912f},
std::array<float,2>{0.86368072f, 0.549744487f},
std::array<float,2>{0.29198873f, 0.454612225f},
std::array<float,2>{0.0903421864f, 0.77092135f},
std::array<float,2>{0.583224058f, 0.0217911471f},
std::array<float,2>{0.635827482f, 0.918665171f},
std::array<float,2>{0.2108282f, 0.131320968f},
std::array<float,2>{0.435138017f, 0.642927289f},
std::array<float,2>{0.945898294f, 0.286779851f},
std::array<float,2>{0.931890249f, 0.861515105f},
std::array<float,2>{0.472952694f, 0.116028264f},
std::array<float,2>{0.131272197f, 0.588755071f},
std::array<float,2>{0.700365722f, 0.418795377f},
std::array<float,2>{0.560733616f, 0.728718579f},
std::array<float,2>{0.0141326701f, 0.352008194f},
std::array<float,2>{0.351752967f, 0.98265475f},
std::array<float,2>{0.758527756f, 0.222318277f},
std::array<float,2>{0.944150269f, 0.524675488f},
std::array<float,2>{0.425133526f, 0.477898091f},
std::array<float,2>{0.218290806f, 0.782266378f},
std::array<float,2>{0.629309177f, 0.0562127195f},
std::array<float,2>{0.58837992f, 0.88449955f},
std::array<float,2>{0.0843816325f, 0.161086664f},
std::array<float,2>{0.288909078f, 0.668353915f},
std::array<float,2>{0.872279048f, 0.274224371f},
std::array<float,2>{0.754204273f, 0.827772796f},
std::array<float,2>{0.348703563f, 0.0746995807f},
std::array<float,2>{0.000100352729f, 0.597289443f},
std::array<float,2>{0.551281691f, 0.405964375f},
std::array<float,2>{0.694545627f, 0.697407424f},
std::array<float,2>{0.133995712f, 0.339799732f},
std::array<float,2>{0.483070254f, 0.939909756f},
std::array<float,2>{0.923443854f, 0.192496091f},
std::array<float,2>{0.816865325f, 0.648610473f},
std::array<float,2>{0.265473366f, 0.296592325f},
std::array<float,2>{0.110198505f, 0.912436128f},
std::array<float,2>{0.62376684f, 0.138444871f},
std::array<float,2>{0.659609735f, 0.776042819f},
std::array<float,2>{0.230577663f, 0.0273944754f},
std::array<float,2>{0.395457834f, 0.556261897f},
std::array<float,2>{0.976849556f, 0.467971504f},
std::array<float,2>{0.894305706f, 0.971819878f},
std::array<float,2>{0.464868546f, 0.226626083f},
std::array<float,2>{0.16452615f, 0.72091645f},
std::array<float,2>{0.728947341f, 0.344140977f},
std::array<float,2>{0.509640276f, 0.582626879f},
std::array<float,2>{0.0463262163f, 0.407399625f},
std::array<float,2>{0.331471354f, 0.869445264f},
std::array<float,2>{0.805986226f, 0.122000307f},
std::array<float,2>{0.921246111f, 0.745789826f},
std::array<float,2>{0.493122011f, 0.372449785f},
std::array<float,2>{0.146020725f, 0.999046445f},
std::array<float,2>{0.707790911f, 0.236919463f},
std::array<float,2>{0.542165577f, 0.847746313f},
std::array<float,2>{0.025825683f, 0.0950258896f},
std::array<float,2>{0.368181199f, 0.567033291f},
std::array<float,2>{0.767747879f, 0.423110336f},
std::array<float,2>{0.845405757f, 0.926904202f},
std::array<float,2>{0.303631961f, 0.149683401f},
std::array<float,2>{0.0653279126f, 0.634173512f},
std::array<float,2>{0.577440441f, 0.309116781f},
std::array<float,2>{0.651258469f, 0.537958443f},
std::array<float,2>{0.189581096f, 0.451646239f},
std::array<float,2>{0.41310662f, 0.758210599f},
std::array<float,2>{0.954218864f, 0.00505943783f},
std::array<float,2>{0.792776525f, 0.612948239f},
std::array<float,2>{0.312712371f, 0.380981833f},
std::array<float,2>{0.0524161421f, 0.838206232f},
std::array<float,2>{0.525917113f, 0.0931135491f},
std::array<float,2>{0.745541811f, 0.966662765f},
std::array<float,2>{0.173001856f, 0.21621421f},
std::array<float,2>{0.4408077f, 0.713333666f},
std::array<float,2>{0.885184228f, 0.324950337f},
std::array<float,2>{0.988296747f, 0.806335807f},
std::array<float,2>{0.379994154f, 0.0343432575f},
std::array<float,2>{0.248694524f, 0.508889735f},
std::array<float,2>{0.68233484f, 0.494513959f},
std::array<float,2>{0.606759787f, 0.681363463f},
std::array<float,2>{0.0946417302f, 0.252335757f},
std::array<float,2>{0.268461049f, 0.905382514f},
std::array<float,2>{0.835321724f, 0.175118983f},
std::array<float,2>{0.997785389f, 0.598709285f},
std::array<float,2>{0.382886738f, 0.398513556f},
std::array<float,2>{0.235481173f, 0.823252797f},
std::array<float,2>{0.674883664f, 0.0721514374f},
std::array<float,2>{0.595456302f, 0.944524765f},
std::array<float,2>{0.105444737f, 0.188741535f},
std::array<float,2>{0.273756564f, 0.701052308f},
std::array<float,2>{0.838153899f, 0.343333423f},
std::array<float,2>{0.784575522f, 0.785575449f},
std::array<float,2>{0.323894769f, 0.0621948466f},
std::array<float,2>{0.057033401f, 0.529536545f},
std::array<float,2>{0.516997933f, 0.483833015f},
std::array<float,2>{0.737482488f, 0.666836441f},
std::array<float,2>{0.185130849f, 0.27912575f},
std::array<float,2>{0.45264861f, 0.890572071f},
std::array<float,2>{0.878982246f, 0.159736574f},
std::array<float,2>{0.854112983f, 0.723029673f},
std::array<float,2>{0.307502031f, 0.348210335f},
std::array<float,2>{0.0770745873f, 0.973555326f},
std::array<float,2>{0.569690168f, 0.232730657f},
std::array<float,2>{0.645116925f, 0.872029543f},
std::array<float,2>{0.195782587f, 0.121077254f},
std::array<float,2>{0.417916447f, 0.579529345f},
std::array<float,2>{0.963102281f, 0.411176682f},
std::array<float,2>{0.913980067f, 0.909073591f},
std::array<float,2>{0.491224945f, 0.135723308f},
std::array<float,2>{0.152775466f, 0.655603588f},
std::array<float,2>{0.718203962f, 0.290836692f},
std::array<float,2>{0.537454247f, 0.560787916f},
std::array<float,2>{0.0213842671f, 0.463349253f},
std::array<float,2>{0.363437533f, 0.779961646f},
std::array<float,2>{0.777671635f, 0.0254923012f},
std::array<float,2>{0.903776288f, 0.638528287f},
std::array<float,2>{0.460464448f, 0.308466464f},
std::array<float,2>{0.156434819f, 0.92260325f},
std::array<float,2>{0.720705509f, 0.15304625f},
std::array<float,2>{0.50558418f, 0.761738777f},
std::array<float,2>{0.0343791768f, 0.00237194728f},
std::array<float,2>{0.340383381f, 0.533221483f},
std::array<float,2>{0.798510432f, 0.445340663f},
std::array<float,2>{0.823386788f, 0.992661774f},
std::array<float,2>{0.257246882f, 0.238770515f},
std::array<float,2>{0.124244638f, 0.747751176f},
std::array<float,2>{0.609528899f, 0.369006008f},
std::array<float,2>{0.671023607f, 0.5663445f},
std::array<float,2>{0.222057834f, 0.428132296f},
std::array<float,2>{0.400090516f, 0.84416312f},
std::array<float,2>{0.970353305f, 0.10054221f},
std::array<float,2>{0.762966752f, 0.513226569f},
std::array<float,2>{0.358948886f, 0.497815967f},
std::array<float,2>{0.0113618914f, 0.809358001f},
std::array<float,2>{0.555077672f, 0.0365187451f},
std::array<float,2>{0.696870565f, 0.899544656f},
std::array<float,2>{0.128693938f, 0.178127587f},
std::array<float,2>{0.471792102f, 0.687084138f},
std::array<float,2>{0.933714211f, 0.257509112f},
std::array<float,2>{0.952832282f, 0.842921913f},
std::array<float,2>{0.429920167f, 0.086077027f},
std::array<float,2>{0.205385476f, 0.6160326f},
std::array<float,2>{0.638896704f, 0.376755744f},
std::array<float,2>{0.579851925f, 0.715710402f},
std::array<float,2>{0.0868180022f, 0.323868096f},
std::array<float,2>{0.294058621f, 0.961994886f},
std::array<float,2>{0.859559596f, 0.212323651f},
std::array<float,2>{0.927147567f, 0.542846859f},
std::array<float,2>{0.477952629f, 0.443986535f},
std::array<float,2>{0.137590602f, 0.750866711f},
std::array<float,2>{0.688345194f, 0.00869440474f},
std::array<float,2>{0.550696194f, 0.935162187f},
std::array<float,2>{0.00497616315f, 0.146081045f},
std::array<float,2>{0.347264796f, 0.627778113f},
std::array<float,2>{0.751764834f, 0.296906978f},
std::array<float,2>{0.868066072f, 0.855263054f},
std::array<float,2>{0.284227043f, 0.10855338f},
std::array<float,2>{0.078855291f, 0.574237645f},
std::array<float,2>{0.590769827f, 0.435670525f},
std::array<float,2>{0.626878083f, 0.736406922f},
std::array<float,2>{0.21467635f, 0.363879383f},
std::array<float,2>{0.426033914f, 0.988716125f},
std::array<float,2>{0.941016734f, 0.245634794f},
std::array<float,2>{0.808883667f, 0.673419833f},
std::array<float,2>{0.335115582f, 0.261732727f},
std::array<float,2>{0.040840771f, 0.89697659f},
std::array<float,2>{0.514504075f, 0.186421394f},
std::array<float,2>{0.733383298f, 0.801722705f},
std::array<float,2>{0.169901013f, 0.0424175039f},
std::array<float,2>{0.462456167f, 0.501821399f},
std::array<float,2>{0.894760013f, 0.490663111f},
std::array<float,2>{0.982172906f, 0.953603745f},
std::array<float,2>{0.392899513f, 0.207106635f},
std::array<float,2>{0.230435178f, 0.705987155f},
std::array<float,2>{0.661247551f, 0.316270441f},
std::array<float,2>{0.617465496f, 0.620089054f},
std::array<float,2>{0.116945811f, 0.389873207f},
std::array<float,2>{0.260454357f, 0.829445779f},
std::array<float,2>{0.815694749f, 0.0841590613f},
std::array<float,2>{0.958606362f, 0.693445265f},
std::array<float,2>{0.408649832f, 0.334909439f},
std::array<float,2>{0.193738759f, 0.949080348f},
std::array<float,2>{0.65237093f, 0.197939023f},
std::array<float,2>{0.570679843f, 0.816610098f},
std::array<float,2>{0.0702176541f, 0.065857783f},
std::array<float,2>{0.29754436f, 0.602118552f},
std::array<float,2>{0.851103842f, 0.395303816f},
std::array<float,2>{0.771518826f, 0.876034558f},
std::array<float,2>{0.372833669f, 0.171697602f},
std::array<float,2>{0.0287192483f, 0.657828987f},
std::array<float,2>{0.543304801f, 0.27164647f},
std::array<float,2>{0.70489198f, 0.518696606f},
std::array<float,2>{0.142067209f, 0.469280392f},
std::array<float,2>{0.49794805f, 0.789820611f},
std::array<float,2>{0.917772532f, 0.0498279221f},
std::array<float,2>{0.8292858f, 0.592671037f},
std::array<float,2>{0.272486329f, 0.415398479f},
std::array<float,2>{0.101541415f, 0.86430639f},
std::array<float,2>{0.603859723f, 0.11036849f},
std::array<float,2>{0.686308026f, 0.977249205f},
std::array<float,2>{0.243806183f, 0.224815458f},
std::array<float,2>{0.37641263f, 0.734012723f},
std::array<float,2>{0.986973464f, 0.357202828f},
std::array<float,2>{0.890172422f, 0.766272247f},
std::array<float,2>{0.444813341f, 0.0163415521f},
std::array<float,2>{0.179268166f, 0.551176548f},
std::array<float,2>{0.746535242f, 0.460717857f},
std::array<float,2>{0.531159043f, 0.645111263f},
std::array<float,2>{0.0498968847f, 0.284821808f},
std::array<float,2>{0.319235951f, 0.914377689f},
std::array<float,2>{0.796445489f, 0.127862081f}} | 48.991943 | 52 | 0.73465 | st-ario |
bc154cb2af5e2d832e892627f11e6c4338a213ad | 1,010 | hpp | C++ | src/exception/ih/exc_exception_impl.hpp | lpea/cppinclude | dc126c6057d2fe30569e6e86f66d2c8eebb50212 | [
"MIT"
] | 177 | 2020-08-24T19:20:35.000Z | 2022-03-27T01:58:04.000Z | src/exception/ih/exc_exception_impl.hpp | lpea/cppinclude | dc126c6057d2fe30569e6e86f66d2c8eebb50212 | [
"MIT"
] | 15 | 2020-08-30T17:59:42.000Z | 2022-01-12T11:14:10.000Z | src/exception/ih/exc_exception_impl.hpp | lpea/cppinclude | dc126c6057d2fe30569e6e86f66d2c8eebb50212 | [
"MIT"
] | 11 | 2020-09-17T23:31:10.000Z | 2022-03-04T13:15:21.000Z | #pragma once
#include "exception/api/exc_exception.hpp"
#include <string>
//------------------------------------------------------------------------------
namespace exception
{
//------------------------------------------------------------------------------
template< class _BaseException > class ExceptionImpl : public _BaseException
{
public:
ExceptionImpl( std::string_view _module, std::string_view _code )
: m_module{ _module }
, m_code{ _code }
{
}
std::string getModuleName() const noexcept override
{
return this->m_module;
}
std::string getCode() const noexcept override
{
return this->m_code;
}
const char * what() const noexcept override
{
if( m_msg.empty() )
{
m_msg = this->getModuleName() + '-' + this->getCode() + ": " +
this->getMessage();
}
return m_msg.c_str();
}
private:
mutable std::string m_msg;
const std::string m_module;
const std::string m_code;
};
//------------------------------------------------------------------------------
}
| 19.056604 | 80 | 0.513861 | lpea |
bc23277ac662ec37d8fd672d602836d87bcdfcc8 | 963 | cpp | C++ | Week 4/practise/seven.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | null | null | null | Week 4/practise/seven.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | null | null | null | Week 4/practise/seven.cpp | sugamkarki/NAMI-Year-II-Term-I-Software_Engineering | 39182816b670dcb75ec322e24b346a4cfeb80be0 | [
"Apache-2.0"
] | null | null | null | #include <iostream>
using namespace std;
bool sameSet(int[], int[]);
int main()
{
int a[] = {1,12,15,18, 4,16, 9, 7, 4};
int b[] = { 7, 9, 16, 4, 1};
bool isSame = sameSet(a, b);
// if(isSame){
// cout<<"the arrays are identical"<<endl;
// }
// else{
// cout<<"the arrays are not identical"<<endl;
// }
return 0;
}
bool sameSet(int a[], int b[])
{
// int nA =sizeof(a)/sizeof(a[0]);
// int nB = sizeof(b)/sizeof(b[0]);
cout<<sizeof(a)/sizeof(b[0])<<endl;
// bool isSame = true;
// for (int i = 0; i < nA; i++)
// {
// bool matchingElement=false;
// for (int j = 0; j < nB; j++)
// {
// if(a[i]==b[j]){
// matchingElement=true;
// break;
// }
// }
// if(matchingElement==false){
// isSame=false;
// break;
// }
// }
// return isSame;
return false;
}
| 22.395349 | 54 | 0.433022 | sugamkarki |
bc243bbf7fc9f745bffffab32bd1666691158c6f | 743 | cpp | C++ | 900C.cpp | basuki57/Codeforces | 5227c3deecf13d90e5ea45dab0dfc16b44bd028c | [
"MIT"
] | null | null | null | 900C.cpp | basuki57/Codeforces | 5227c3deecf13d90e5ea45dab0dfc16b44bd028c | [
"MIT"
] | null | null | null | 900C.cpp | basuki57/Codeforces | 5227c3deecf13d90e5ea45dab0dfc16b44bd028c | [
"MIT"
] | 2 | 2020-10-03T04:52:14.000Z | 2020-10-03T05:19:12.000Z | #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
ll n;
cin >> n;
ll a[n], cnt[n+1] = {0};
for(ll i = 0; i < n; ++i) cin >> a[i];
set<ll> s;
for(ll i = 0; i < n; ++i){
s.insert(a[i]);
auto x = s.upper_bound(a[i]);
ll k = *s.rbegin();
// cout << *x << " " << k << endl;
if(x == s.end()) cnt[a[i]]--;
else if(*x == k) cnt[k]++;
}
ll ma = -1, indx = 1;
for(ll i = 1; i <= n; i++) {
// cout << i << " " << cnt[i] << endl;
if(cnt[i] > ma) ma = cnt[i], indx = i;
}
cout << indx << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
// ll t;cin>>t;while(t--)
solve();
return 0;
} | 22.515152 | 46 | 0.421265 | basuki57 |
bc26de50827ca6bb101e9e58fa8300b9d9b94441 | 519 | cpp | C++ | lib/src/Utils/Platform.cpp | ProjectPhysX/OpenCL-SDK | f3e8600cfb6c0266c121d7e1f8b2e5dba9c5fab1 | [
"Apache-2.0"
] | null | null | null | lib/src/Utils/Platform.cpp | ProjectPhysX/OpenCL-SDK | f3e8600cfb6c0266c121d7e1f8b2e5dba9c5fab1 | [
"Apache-2.0"
] | 1 | 2021-11-16T16:30:14.000Z | 2021-11-19T13:01:43.000Z | lib/src/Utils/Platform.cpp | ProjectPhysX/OpenCL-SDK | f3e8600cfb6c0266c121d7e1f8b2e5dba9c5fab1 | [
"Apache-2.0"
] | null | null | null | #include <CL/Utils/Platform.hpp>
bool cl::util::supports_extension(const cl::Platform& platform,
const cl::string& extension)
{
return platform.getInfo<CL_PLATFORM_EXTENSIONS>().find(extension)
!= cl::string::npos;
}
bool cl::util::platform_version_contains(const cl::Platform& platform,
const cl::string& version_fragment)
{
return platform.getInfo<CL_PLATFORM_VERSION>().find(version_fragment)
!= cl::string::npos;
} | 34.6 | 76 | 0.626204 | ProjectPhysX |
bc2a6f7aa29e5b6bf350b84a196514ed9cf3182a | 3,080 | hpp | C++ | include/owlcpp/rdf/map_node_literal_crtpb.hpp | GreyMerlin/owl_cpp | ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6 | [
"BSL-1.0"
] | 10 | 2017-12-21T05:20:40.000Z | 2021-09-18T05:14:01.000Z | include/owlcpp/rdf/map_node_literal_crtpb.hpp | GreyMerlin/owl_cpp | ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6 | [
"BSL-1.0"
] | 2 | 2017-12-21T07:31:54.000Z | 2021-06-23T08:52:35.000Z | include/owlcpp/rdf/map_node_literal_crtpb.hpp | GreyMerlin/owl_cpp | ccc6128dbd08dcf7fcbe6679ec6acd714732bbb6 | [
"BSL-1.0"
] | 7 | 2016-02-17T13:20:31.000Z | 2021-11-08T09:30:43.000Z | /** @file "/owlcpp/include/owlcpp/rdf/map_node_literal_crtpb.hpp"
part of owlcpp project.
@n @n Distributed under the Boost Software License, Version 1.0; see doc/license.txt.
@n Copyright Mikhail K Levin 2012
*******************************************************************************/
#ifndef MAP_NODE_LITERAL_CRTPB_HPP_
#define MAP_NODE_LITERAL_CRTPB_HPP_
#include "boost/assert.hpp"
#include "boost/foreach.hpp"
#include "owlcpp/detail/map_traits.hpp"
#include "owlcpp/rdf/store_concepts.hpp"
namespace owlcpp{
/**Enable interface for literal nodes.
Base for CRTP (Curiously Recurring Template Pattern).
*******************************************************************************/
template<class Super> class Map_node_literal_crtpb {
typedef detail::Map_traits<Super> traits;
typedef typename traits::map_node_type map_node_type;
map_node_type const& _map_node() const {
return static_cast<Super const&>(*this).map_node_;
}
map_node_type& _map_node() {
return static_cast<Super&>(*this).map_node_;
}
public:
/** @brief find literal node
@param value literal node value
@param dt_iri datatype IRI
@param lang language
*/
Node_id const* find_literal(
std::string const& value,
std::string const& dt_iri,
std::string const& lang = ""
) const {
Node_id const* dt = static_cast<Super const&>(*this).find_node_iri(dt_iri);
if( ! dt ) return 0;
return _map_node().find_literal(value, *dt, lang);
}
/**@brief Insert literal node
@param value
@param dt_id datatype node ID
@param lang language tag string for the literal node or
"" if the language is not defined.
The tag string format SHOULD be according to RFC 5646
(http://tools.ietf.org/html/rfc5646).
This is not, however, currently enforced by the library.
@return node ID
*/
Node_id insert_literal(
std::string const& value,
const Node_id dt_id,
std::string const& lang = ""
) {
BOOST_CONCEPT_ASSERT((Iri_node_store<Super>));
BOOST_ASSERT(
static_cast<Super const&>(*this).find(dt_id) &&
"invalid datatype ID"
);
return _map_node().insert_literal(value, dt_id, lang);
}
/**@brief Insert literal node
@param value
@param dt_iri datatype IRI or empty string
@param lang language tag string for the literal node or
"" if the language is not defined.
The tag string format SHOULD be according to RFC 5646
(http://tools.ietf.org/html/rfc5646).
This is not, however, currently enforced by the library.
@return node ID
*/
Node_id insert_literal(
std::string const& value,
std::string const& dt_iri,
std::string const& lang = ""
) {
BOOST_CONCEPT_ASSERT((Ns_iri_node_store<Super>));
const Node_id dt_id = static_cast<Super&>(*this).insert_node_iri(dt_iri);
return insert_literal(value, dt_id, lang);
}
};
}//namespace owlcpp
#endif /* MAP_NODE_LITERAL_CRTPB_HPP_ */
| 32.421053 | 85 | 0.637338 | GreyMerlin |
bc2c61975a9bcad5f5af9b7607ec4b46f24d92cf | 110,302 | cc | C++ | test/smoke/issue_apps_001/lulesh.cc | illuhad/aomp | 94078df8f6f1eb9ff54dd535a8c980b21526e74a | [
"Apache-2.0"
] | 13 | 2016-12-17T03:13:09.000Z | 2020-11-17T17:32:14.000Z | test/smoke/issue_apps_001/lulesh.cc | illuhad/aomp | 94078df8f6f1eb9ff54dd535a8c980b21526e74a | [
"Apache-2.0"
] | 2 | 2019-12-09T16:24:26.000Z | 2019-12-09T16:27:55.000Z | test/smoke/issue_apps_001/lulesh.cc | illuhad/aomp | 94078df8f6f1eb9ff54dd535a8c980b21526e74a | [
"Apache-2.0"
] | 1 | 2016-12-21T22:59:03.000Z | 2016-12-21T22:59:03.000Z | /*******************************************************************************
Copyright (c) 2016 Advanced Micro Devices, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
/*
This is a Version 2.0 MPI + OpenMP implementation of LULESH
Copyright (c) 2010-2013.
Lawrence Livermore National Security, LLC.
Produced at the Lawrence Livermore National Laboratory.
LLNL-CODE-461231
All rights reserved.
This file is part of LULESH, Version 2.0.
Please also read this link -- http://www.opensource.org/licenses/index.php
//////////////
DIFFERENCES BETWEEN THIS VERSION (2.x) AND EARLIER VERSIONS:
* Addition of regions to make work more representative of multi-material codes
* Default size of each domain is 30^3 (27000 elem) instead of 45^3. This is
more representative of our actual working set sizes
* Single source distribution supports pure serial, pure OpenMP, MPI-only,
and MPI+OpenMP
* Addition of ability to visualize the mesh using VisIt
https://wci.llnl.gov/codes/visit/download.html
* Various command line options (see ./lulesh2.0 -h)
-q : quiet mode - suppress stdout
-i <iterations> : number of cycles to run
-s <size> : length of cube mesh along side
-r <numregions> : Number of distinct regions (def: 11)
-b <balance> : Load balance between regions of a domain (def: 1)
-c <cost> : Extra cost of more expensive regions (def: 1)
-f <filepieces> : Number of file parts for viz output (def: np/9)
-p : Print out progress
-v : Output viz file (requires compiling with -DVIZ_MESH
-h : This message
printf("Usage: %s [opts]\n", execname);
printf(" where [opts] is one or more of:\n");
printf(" -q : quiet mode - suppress all stdout\n");
printf(" -i <iterations> : number of cycles to run\n");
printf(" -s <size> : length of cube mesh along side\n");
printf(" -r <numregions> : Number of distinct regions (def: 11)\n");
printf(" -b <balance> : Load balance between regions of a domain (def: 1)\n");
printf(" -c <cost> : Extra cost of more expensive regions (def: 1)\n");
printf(" -f <numfiles> : Number of files to split viz dump into (def: (np+10)/9)\n");
printf(" -p : Print out progress\n");
printf(" -v : Output viz file (requires compiling with -DVIZ_MESH\n");
printf(" -h : This message\n");
printf("\n\n");
*Notable changes in LULESH 2.0
* Split functionality into different files
lulesh.cc - where most (all?) of the timed functionality lies
lulesh-comm.cc - MPI functionality
lulesh-init.cc - Setup code
lulesh-viz.cc - Support for visualization option
lulesh-util.cc - Non-timed functions
*
* The concept of "regions" was added, although every region is the same ideal
* gas material, and the same sedov blast wave problem is still the only
* problem its hardcoded to solve.
* Regions allow two things important to making this proxy app more representative:
* Four of the LULESH routines are now performed on a region-by-region basis,
* making the memory access patterns non-unit stride
* Artificial load imbalances can be easily introduced that could impact
* parallelization strategies.
* The load balance flag changes region assignment. Region number is raised to
* the power entered for assignment probability. Most likely regions changes
* with MPI process id.
* The cost flag raises the cost of ~45% of the regions to evaluate EOS by the
* entered multiple. The cost of 5% is 10x the entered multiple.
* MPI and OpenMP were added, and coalesced into a single version of the source
* that can support serial builds, MPI-only, OpenMP-only, and MPI+OpenMP
* Added support to write plot files using "poor mans parallel I/O" when linked
* with the silo library, which in turn can be read by VisIt.
* Enabled variable timestep calculation by default (courant condition), which
* results in an additional reduction.
* Default domain (mesh) size reduced from 45^3 to 30^3
* Command line options to allow numerous test cases without needing to recompile
* Performance optimizations and code cleanup beyond LULESH 1.0
* Added a "Figure of Merit" calculation (elements solved per microsecond) and
* output in support of using LULESH 2.0 for the 2017 CORAL procurement
*
* Possible Differences in Final Release (other changes possible)
*
* High Level mesh structure to allow data structure transformations
* Different default parameters
* Minor code performance changes and cleanup
TODO in future versions
* Add reader for (truly) unstructured meshes, probably serial only
* CMake based build system
//////////////
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 disclaimer below.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the disclaimer (as noted below)
in the documentation and/or other materials provided with the
distribution.
* Neither the name of the LLNS/LLNL 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 LAWRENCE LIVERMORE NATIONAL SECURITY, LLC,
THE U.S. DEPARTMENT OF ENERGY 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.
Additional BSD Notice
1. This notice is required to be provided under our contract with the U.S.
Department of Energy (DOE). This work was produced at Lawrence Livermore
National Laboratory under Contract No. DE-AC52-07NA27344 with the DOE.
2. Neither the United States Government nor Lawrence Livermore National
Security, LLC nor any of their employees, makes any warranty, express
or implied, or assumes any liability or responsibility for the accuracy,
completeness, or usefulness of any information, apparatus, product, or
process disclosed, or represents that its use would not infringe
privately-owned rights.
3. Also, reference herein to any specific commercial products, process, or
services by trade name, trademark, manufacturer or otherwise does not
necessarily constitute or imply its endorsement, recommendation, or
favoring by the United States Government or Lawrence Livermore National
Security, LLC. The views and opinions of authors expressed herein do not
necessarily state or reflect those of the United States Government or
Lawrence Livermore National Security, LLC, and shall not be used for
advertising or product endorsement purposes.
*/
#include <climits>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys/time.h>
#include <iostream>
#include <unistd.h>
#include <iomanip>
#include <sstream>
#include <limits>
#include <fstream>
#include <string>
#if _OPENMP
# include <omp.h>
#endif
#include "lulesh.h"
#define EPSILON 1e-7
#if !defined(TEAMS)
#define TEAMS 128
#define THREADS 64
#endif
#if !defined(USE_GPU)
#define USE_GPU 1
#endif
/*********************************/
/* Data structure implementation */
/*********************************/
/* might want to add access methods so that memory can be */
/* better managed, as in luleshFT */
template <typename T>
T *Allocate(size_t size)
{
return static_cast<T *>(malloc(sizeof(T)*size)) ;
}
template <typename T>
void Release(T **ptr)
{
if (*ptr != NULL) {
free(*ptr) ;
*ptr = NULL ;
}
}
/******************************************/
/* Work Routines */
static inline
void TimeIncrement(Domain& domain)
{
Real_t targetdt = domain.stoptime() - domain.time() ;
if ((domain.dtfixed() <= Real_t(0.0)) && (domain.cycle() != Int_t(0))) {
Real_t ratio ;
Real_t olddt = domain.deltatime() ;
/* This will require a reduction in parallel */
Real_t gnewdt = Real_t(1.0e+20) ;
Real_t newdt ;
if (domain.dtcourant() < gnewdt) {
gnewdt = domain.dtcourant() / Real_t(2.0) ;
}
if (domain.dthydro() < gnewdt) {
gnewdt = domain.dthydro() * Real_t(2.0) / Real_t(3.0) ;
}
#if USE_MPI
MPI_Allreduce(&gnewdt, &newdt, 1,
((sizeof(Real_t) == 4) ? MPI_FLOAT : MPI_DOUBLE),
MPI_MIN, MPI_COMM_WORLD) ;
#else
newdt = gnewdt;
#endif
ratio = newdt / olddt ;
if (ratio >= Real_t(1.0)) {
if (ratio < domain.deltatimemultlb()) {
newdt = olddt ;
}
else if (ratio > domain.deltatimemultub()) {
newdt = olddt*domain.deltatimemultub() ;
}
}
if (newdt > domain.dtmax()) {
newdt = domain.dtmax() ;
}
domain.deltatime() = newdt ;
}
/* TRY TO PREVENT VERY SMALL SCALING ON THE NEXT CYCLE */
if ((targetdt > domain.deltatime()) &&
(targetdt < (Real_t(4.0) * domain.deltatime() / Real_t(3.0))) ) {
targetdt = Real_t(2.0) * domain.deltatime() / Real_t(3.0) ;
}
if (targetdt < domain.deltatime()) {
domain.deltatime() = targetdt ;
}
domain.time() += domain.deltatime() ;
++domain.cycle() ;
}
/******************************************/
static inline
void CollectDomainNodesToElemNodes(Domain &domain,
const Index_t* elemToNode,
Real_t elemX[8],
Real_t elemY[8],
Real_t elemZ[8])
{
Index_t nd0i = elemToNode[0] ;
Index_t nd1i = elemToNode[1] ;
Index_t nd2i = elemToNode[2] ;
Index_t nd3i = elemToNode[3] ;
Index_t nd4i = elemToNode[4] ;
Index_t nd5i = elemToNode[5] ;
Index_t nd6i = elemToNode[6] ;
Index_t nd7i = elemToNode[7] ;
elemX[0] = domain.x(nd0i);
elemX[1] = domain.x(nd1i);
elemX[2] = domain.x(nd2i);
elemX[3] = domain.x(nd3i);
elemX[4] = domain.x(nd4i);
elemX[5] = domain.x(nd5i);
elemX[6] = domain.x(nd6i);
elemX[7] = domain.x(nd7i);
elemY[0] = domain.y(nd0i);
elemY[1] = domain.y(nd1i);
elemY[2] = domain.y(nd2i);
elemY[3] = domain.y(nd3i);
elemY[4] = domain.y(nd4i);
elemY[5] = domain.y(nd5i);
elemY[6] = domain.y(nd6i);
elemY[7] = domain.y(nd7i);
elemZ[0] = domain.z(nd0i);
elemZ[1] = domain.z(nd1i);
elemZ[2] = domain.z(nd2i);
elemZ[3] = domain.z(nd3i);
elemZ[4] = domain.z(nd4i);
elemZ[5] = domain.z(nd5i);
elemZ[6] = domain.z(nd6i);
elemZ[7] = domain.z(nd7i);
}
/******************************************/
static inline
void InitStressTermsForElems(Domain &domain,
Real_t *sigxx, Real_t *sigyy, Real_t *sigzz,
Index_t numElem)
{
//
// pull in the stresses appropriate to the hydro integration
//
Real_t *p = &domain.m_p[0];
Real_t *q = &domain.m_q[0];
//### No 2
#pragma omp target data map(to: p[:numElem], q[:numElem]) \
map(alloc: sigxx[:numElem], sigyy[:numElem], sigzz[:numElem]) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (Index_t i = 0 ; i < numElem ; ++i){
sigxx[i] = sigyy[i] = sigzz[i] = - p[i] - q[i] ;
}
}
}
/******************************************/
#pragma omp declare target
static inline
void CalcElemShapeFunctionDerivatives( Real_t const x[],
Real_t const y[],
Real_t const z[],
Real_t b[][8],
Real_t* const volume )
{
const Real_t x0 = x[0] ; const Real_t x1 = x[1] ;
const Real_t x2 = x[2] ; const Real_t x3 = x[3] ;
const Real_t x4 = x[4] ; const Real_t x5 = x[5] ;
const Real_t x6 = x[6] ; const Real_t x7 = x[7] ;
const Real_t y0 = y[0] ; const Real_t y1 = y[1] ;
const Real_t y2 = y[2] ; const Real_t y3 = y[3] ;
const Real_t y4 = y[4] ; const Real_t y5 = y[5] ;
const Real_t y6 = y[6] ; const Real_t y7 = y[7] ;
const Real_t z0 = z[0] ; const Real_t z1 = z[1] ;
const Real_t z2 = z[2] ; const Real_t z3 = z[3] ;
const Real_t z4 = z[4] ; const Real_t z5 = z[5] ;
const Real_t z6 = z[6] ; const Real_t z7 = z[7] ;
Real_t fjxxi, fjxet, fjxze;
Real_t fjyxi, fjyet, fjyze;
Real_t fjzxi, fjzet, fjzze;
Real_t cjxxi, cjxet, cjxze;
Real_t cjyxi, cjyet, cjyze;
Real_t cjzxi, cjzet, cjzze;
fjxxi = Real_t(.125) * ( (x6-x0) + (x5-x3) - (x7-x1) - (x4-x2) );
fjxet = Real_t(.125) * ( (x6-x0) - (x5-x3) + (x7-x1) - (x4-x2) );
fjxze = Real_t(.125) * ( (x6-x0) + (x5-x3) + (x7-x1) + (x4-x2) );
fjyxi = Real_t(.125) * ( (y6-y0) + (y5-y3) - (y7-y1) - (y4-y2) );
fjyet = Real_t(.125) * ( (y6-y0) - (y5-y3) + (y7-y1) - (y4-y2) );
fjyze = Real_t(.125) * ( (y6-y0) + (y5-y3) + (y7-y1) + (y4-y2) );
fjzxi = Real_t(.125) * ( (z6-z0) + (z5-z3) - (z7-z1) - (z4-z2) );
fjzet = Real_t(.125) * ( (z6-z0) - (z5-z3) + (z7-z1) - (z4-z2) );
fjzze = Real_t(.125) * ( (z6-z0) + (z5-z3) + (z7-z1) + (z4-z2) );
/* compute cofactors */
cjxxi = (fjyet * fjzze) - (fjzet * fjyze);
cjxet = - (fjyxi * fjzze) + (fjzxi * fjyze);
cjxze = (fjyxi * fjzet) - (fjzxi * fjyet);
cjyxi = - (fjxet * fjzze) + (fjzet * fjxze);
cjyet = (fjxxi * fjzze) - (fjzxi * fjxze);
cjyze = - (fjxxi * fjzet) + (fjzxi * fjxet);
cjzxi = (fjxet * fjyze) - (fjyet * fjxze);
cjzet = - (fjxxi * fjyze) + (fjyxi * fjxze);
cjzze = (fjxxi * fjyet) - (fjyxi * fjxet);
/* calculate partials :
this need only be done for l = 0,1,2,3 since , by symmetry ,
(6,7,4,5) = - (0,1,2,3) .
*/
b[0][0] = - cjxxi - cjxet - cjxze;
b[0][1] = cjxxi - cjxet - cjxze;
b[0][2] = cjxxi + cjxet - cjxze;
b[0][3] = - cjxxi + cjxet - cjxze;
b[0][4] = -b[0][2];
b[0][5] = -b[0][3];
b[0][6] = -b[0][0];
b[0][7] = -b[0][1];
b[1][0] = - cjyxi - cjyet - cjyze;
b[1][1] = cjyxi - cjyet - cjyze;
b[1][2] = cjyxi + cjyet - cjyze;
b[1][3] = - cjyxi + cjyet - cjyze;
b[1][4] = -b[1][2];
b[1][5] = -b[1][3];
b[1][6] = -b[1][0];
b[1][7] = -b[1][1];
b[2][0] = - cjzxi - cjzet - cjzze;
b[2][1] = cjzxi - cjzet - cjzze;
b[2][2] = cjzxi + cjzet - cjzze;
b[2][3] = - cjzxi + cjzet - cjzze;
b[2][4] = -b[2][2];
b[2][5] = -b[2][3];
b[2][6] = -b[2][0];
b[2][7] = -b[2][1];
/* calculate jacobian determinant (volume) */
*volume = Real_t(8.) * ( fjxet * cjxet + fjyet * cjyet + fjzet * cjzet);
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void SumElemFaceNormal(Real_t *normalX0, Real_t *normalY0, Real_t *normalZ0,
Real_t *normalX1, Real_t *normalY1, Real_t *normalZ1,
Real_t *normalX2, Real_t *normalY2, Real_t *normalZ2,
Real_t *normalX3, Real_t *normalY3, Real_t *normalZ3,
const Real_t x0, const Real_t y0, const Real_t z0,
const Real_t x1, const Real_t y1, const Real_t z1,
const Real_t x2, const Real_t y2, const Real_t z2,
const Real_t x3, const Real_t y3, const Real_t z3)
{
Real_t bisectX0 = Real_t(0.5) * (x3 + x2 - x1 - x0);
Real_t bisectY0 = Real_t(0.5) * (y3 + y2 - y1 - y0);
Real_t bisectZ0 = Real_t(0.5) * (z3 + z2 - z1 - z0);
Real_t bisectX1 = Real_t(0.5) * (x2 + x1 - x3 - x0);
Real_t bisectY1 = Real_t(0.5) * (y2 + y1 - y3 - y0);
Real_t bisectZ1 = Real_t(0.5) * (z2 + z1 - z3 - z0);
Real_t areaX = Real_t(0.25) * (bisectY0 * bisectZ1 - bisectZ0 * bisectY1);
Real_t areaY = Real_t(0.25) * (bisectZ0 * bisectX1 - bisectX0 * bisectZ1);
Real_t areaZ = Real_t(0.25) * (bisectX0 * bisectY1 - bisectY0 * bisectX1);
*normalX0 += areaX;
*normalX1 += areaX;
*normalX2 += areaX;
*normalX3 += areaX;
*normalY0 += areaY;
*normalY1 += areaY;
*normalY2 += areaY;
*normalY3 += areaY;
*normalZ0 += areaZ;
*normalZ1 += areaZ;
*normalZ2 += areaZ;
*normalZ3 += areaZ;
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void CalcElemNodeNormals(Real_t pfx[8],
Real_t pfy[8],
Real_t pfz[8],
const Real_t x[8],
const Real_t y[8],
const Real_t z[8])
{
for (Index_t i = 0 ; i < 8 ; ++i) {
pfx[i] = Real_t(0.0);
pfy[i] = Real_t(0.0);
pfz[i] = Real_t(0.0);
}
/* evaluate face one: nodes 0, 1, 2, 3 */
SumElemFaceNormal(&pfx[0], &pfy[0], &pfz[0],
&pfx[1], &pfy[1], &pfz[1],
&pfx[2], &pfy[2], &pfz[2],
&pfx[3], &pfy[3], &pfz[3],
x[0], y[0], z[0], x[1], y[1], z[1],
x[2], y[2], z[2], x[3], y[3], z[3]);
/* evaluate face two: nodes 0, 4, 5, 1 */
SumElemFaceNormal(&pfx[0], &pfy[0], &pfz[0],
&pfx[4], &pfy[4], &pfz[4],
&pfx[5], &pfy[5], &pfz[5],
&pfx[1], &pfy[1], &pfz[1],
x[0], y[0], z[0], x[4], y[4], z[4],
x[5], y[5], z[5], x[1], y[1], z[1]);
/* evaluate face three: nodes 1, 5, 6, 2 */
SumElemFaceNormal(&pfx[1], &pfy[1], &pfz[1],
&pfx[5], &pfy[5], &pfz[5],
&pfx[6], &pfy[6], &pfz[6],
&pfx[2], &pfy[2], &pfz[2],
x[1], y[1], z[1], x[5], y[5], z[5],
x[6], y[6], z[6], x[2], y[2], z[2]);
/* evaluate face four: nodes 2, 6, 7, 3 */
SumElemFaceNormal(&pfx[2], &pfy[2], &pfz[2],
&pfx[6], &pfy[6], &pfz[6],
&pfx[7], &pfy[7], &pfz[7],
&pfx[3], &pfy[3], &pfz[3],
x[2], y[2], z[2], x[6], y[6], z[6],
x[7], y[7], z[7], x[3], y[3], z[3]);
/* evaluate face five: nodes 3, 7, 4, 0 */
SumElemFaceNormal(&pfx[3], &pfy[3], &pfz[3],
&pfx[7], &pfy[7], &pfz[7],
&pfx[4], &pfy[4], &pfz[4],
&pfx[0], &pfy[0], &pfz[0],
x[3], y[3], z[3], x[7], y[7], z[7],
x[4], y[4], z[4], x[0], y[0], z[0]);
/* evaluate face six: nodes 4, 7, 6, 5 */
SumElemFaceNormal(&pfx[4], &pfy[4], &pfz[4],
&pfx[7], &pfy[7], &pfz[7],
&pfx[6], &pfy[6], &pfz[6],
&pfx[5], &pfy[5], &pfz[5],
x[4], y[4], z[4], x[7], y[7], z[7],
x[6], y[6], z[6], x[5], y[5], z[5]);
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void SumElemStressesToNodeForces( const Real_t B[][8],
const Real_t stress_xx,
const Real_t stress_yy,
const Real_t stress_zz,
Real_t fx[], Real_t fy[], Real_t fz[] )
{
for(Index_t i = 0; i < 8; i++) {
fx[i] = -( stress_xx * B[0][i] );
fy[i] = -( stress_yy * B[1][i] );
fz[i] = -( stress_zz * B[2][i] );
}
}
#pragma omp end declare target
/******************************************/
static inline
void IntegrateStressForElems( Domain &domain,
Real_t *sigxx, Real_t *sigyy, Real_t *sigzz,
Real_t *determ, Index_t numElem, Index_t numNode)
{
#if _OPENMP
Index_t numthreads = omp_get_max_threads();
#else
Index_t numthreads = 1;
#endif
Index_t numElem8 = numElem * 8 ;
Real_t *fx_elem;
Real_t *fy_elem;
Real_t *fz_elem;
Real_t fx_local[8] ;
Real_t fy_local[8] ;
Real_t fz_local[8] ;
if (numthreads > 1) {
fx_elem = Allocate<Real_t>(numElem8) ;
fy_elem = Allocate<Real_t>(numElem8) ;
fz_elem = Allocate<Real_t>(numElem8) ;
}
// loop over all elements
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
Real_t *fx = &domain.m_fx[0];
Real_t *fy = &domain.m_fy[0];
Real_t *fz = &domain.m_fz[0];
Index_t *nodelist = &domain.m_nodelist[0];
Index_t *nodeElemStart = &domain.m_nodeElemStart[0];
Index_t len1 = numNode + 1;
Index_t *nodeElemCornerList = &domain.m_nodeElemCornerList[0];
Index_t len2 = nodeElemStart[numNode];
//### No 5
#pragma omp target enter data map(alloc:fx[:numNode],fy[:numNode],fz[:numNode]) \
map(alloc:fx_elem[:numElem8], fy_elem[:numElem8], fz_elem[:numElem8]) if(USE_GPU == 1)
#pragma omp target data map(alloc: x[:numNode], y[:numNode], z[:numNode]) \
map(alloc: nodelist[:numElem8]) \
map(alloc: sigxx[:numElem], sigyy[:numElem], sigzz[:numElem], determ[:numElem]) \
map(alloc: fx_local[:8], fy_local[:8], fz_local[:8]) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for( Index_t k=0 ; k<numElem ; ++k )
{
const Index_t* const elemToNode = &nodelist[Index_t(8)*k];
Real_t B[3][8] ;// shape function derivatives
Real_t x_local[8] ;
Real_t y_local[8] ;
Real_t z_local[8] ;
determ[k] = Real_t(10.0);
// get nodal coordinates from global arrays and copy into local arrays.
// CollectDomainNodesToElemNodes(domain, elemToNode, x_local, y_local, z_local);
// inline the function to get rid of references to domain.
Index_t nd0i = elemToNode[0] ;
Index_t nd1i = elemToNode[1] ;
Index_t nd2i = elemToNode[2] ;
Index_t nd3i = elemToNode[3] ;
Index_t nd4i = elemToNode[4] ;
Index_t nd5i = elemToNode[5] ;
Index_t nd6i = elemToNode[6] ;
Index_t nd7i = elemToNode[7] ;
x_local[0] = x[nd0i];
x_local[1] = x[nd1i];
x_local[2] = x[nd2i];
x_local[3] = x[nd3i];
x_local[4] = x[nd4i];
x_local[5] = x[nd5i];
x_local[6] = x[nd6i];
x_local[7] = x[nd7i];
y_local[0] = y[nd0i];
y_local[1] = y[nd1i];
y_local[2] = y[nd2i];
y_local[3] = y[nd3i];
y_local[4] = y[nd4i];
y_local[5] = y[nd5i];
y_local[6] = y[nd6i];
y_local[7] = y[nd7i];
z_local[0] = z[nd0i];
z_local[1] = z[nd1i];
z_local[2] = z[nd2i];
z_local[3] = z[nd3i];
z_local[4] = z[nd4i];
z_local[5] = z[nd5i];
z_local[6] = z[nd6i];
z_local[7] = z[nd7i];
// Volume calculation involves extra work for numerical consistency
CalcElemShapeFunctionDerivatives(x_local, y_local, z_local,
B, &determ[k]);
CalcElemNodeNormals( B[0] , B[1], B[2],
x_local, y_local, z_local );
if (numthreads > 1) {
// Eliminate thread writing conflicts at the nodes by giving
// each element its own copy to write to
SumElemStressesToNodeForces( B, sigxx[k], sigyy[k], sigzz[k],
&fx_elem[k*8],
&fy_elem[k*8],
&fz_elem[k*8] ) ;
}
else {
SumElemStressesToNodeForces( B, sigxx[k], sigyy[k], sigzz[k],
fx_local, fy_local, fz_local ) ;
// copy nodal force contributions to global force arrray.
for( Index_t lnode=0 ; lnode<8 ; ++lnode ) {
Index_t gnode = elemToNode[lnode];
fx[gnode] += fx_local[lnode];
fy[gnode] += fy_local[lnode];
fz[gnode] += fz_local[lnode];
}
}
}
}
if (numthreads > 1) {
// If threaded, then we need to copy the data out of the temporary
// arrays used above into the final forces field
#pragma omp target data map(to: nodeElemStart[:len1], nodeElemCornerList[:len2]) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for( Index_t gnode=0 ; gnode<numNode ; ++gnode )
{
// element count
Index_t count = nodeElemStart[gnode+1] - nodeElemStart[gnode];//domain.nodeElemCount(gnode) ;
// list of all corners
Index_t *cornerList = &nodeElemCornerList[nodeElemStart[gnode]];//domain.nodeElemCornerList(gnode) ;
Real_t fx_tmp = Real_t(0.0) ;
Real_t fy_tmp = Real_t(0.0) ;
Real_t fz_tmp = Real_t(0.0) ;
for (Index_t i=0 ; i < count ; ++i) {
Index_t elem = cornerList[i] ;
fx_tmp += fx_elem[elem] ;
fy_tmp += fy_elem[elem] ;
fz_tmp += fz_elem[elem] ;
}
fx[gnode] = fx_tmp ;
fy[gnode] = fy_tmp ;
fz[gnode] = fz_tmp ;
}
}
#pragma omp target exit data map(delete:fx_elem[:numElem8], fy_elem[:numElem8], fz_elem[:numElem8]) if(USE_GPU == 1)
Release(&fz_elem) ;
Release(&fy_elem) ;
Release(&fx_elem) ;
}
}
/******************************************/
#pragma omp declare target
static inline
void VoluDer(const Real_t x0, const Real_t x1, const Real_t x2,
const Real_t x3, const Real_t x4, const Real_t x5,
const Real_t y0, const Real_t y1, const Real_t y2,
const Real_t y3, const Real_t y4, const Real_t y5,
const Real_t z0, const Real_t z1, const Real_t z2,
const Real_t z3, const Real_t z4, const Real_t z5,
Real_t* dvdx, Real_t* dvdy, Real_t* dvdz)
{
const Real_t twelfth = Real_t(1.0) / Real_t(12.0) ;
*dvdx =
(y1 + y2) * (z0 + z1) - (y0 + y1) * (z1 + z2) +
(y0 + y4) * (z3 + z4) - (y3 + y4) * (z0 + z4) -
(y2 + y5) * (z3 + z5) + (y3 + y5) * (z2 + z5);
*dvdy =
- (x1 + x2) * (z0 + z1) + (x0 + x1) * (z1 + z2) -
(x0 + x4) * (z3 + z4) + (x3 + x4) * (z0 + z4) +
(x2 + x5) * (z3 + z5) - (x3 + x5) * (z2 + z5);
*dvdz =
- (y1 + y2) * (x0 + x1) + (y0 + y1) * (x1 + x2) -
(y0 + y4) * (x3 + x4) + (y3 + y4) * (x0 + x4) +
(y2 + y5) * (x3 + x5) - (y3 + y5) * (x2 + x5);
*dvdx *= twelfth;
*dvdy *= twelfth;
*dvdz *= twelfth;
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void CalcElemVolumeDerivative(Real_t dvdx[8],
Real_t dvdy[8],
Real_t dvdz[8],
const Real_t x[8],
const Real_t y[8],
const Real_t z[8])
{
VoluDer(x[1], x[2], x[3], x[4], x[5], x[7],
y[1], y[2], y[3], y[4], y[5], y[7],
z[1], z[2], z[3], z[4], z[5], z[7],
&dvdx[0], &dvdy[0], &dvdz[0]);
VoluDer(x[0], x[1], x[2], x[7], x[4], x[6],
y[0], y[1], y[2], y[7], y[4], y[6],
z[0], z[1], z[2], z[7], z[4], z[6],
&dvdx[3], &dvdy[3], &dvdz[3]);
VoluDer(x[3], x[0], x[1], x[6], x[7], x[5],
y[3], y[0], y[1], y[6], y[7], y[5],
z[3], z[0], z[1], z[6], z[7], z[5],
&dvdx[2], &dvdy[2], &dvdz[2]);
VoluDer(x[2], x[3], x[0], x[5], x[6], x[4],
y[2], y[3], y[0], y[5], y[6], y[4],
z[2], z[3], z[0], z[5], z[6], z[4],
&dvdx[1], &dvdy[1], &dvdz[1]);
VoluDer(x[7], x[6], x[5], x[0], x[3], x[1],
y[7], y[6], y[5], y[0], y[3], y[1],
z[7], z[6], z[5], z[0], z[3], z[1],
&dvdx[4], &dvdy[4], &dvdz[4]);
VoluDer(x[4], x[7], x[6], x[1], x[0], x[2],
y[4], y[7], y[6], y[1], y[0], y[2],
z[4], z[7], z[6], z[1], z[0], z[2],
&dvdx[5], &dvdy[5], &dvdz[5]);
VoluDer(x[5], x[4], x[7], x[2], x[1], x[3],
y[5], y[4], y[7], y[2], y[1], y[3],
z[5], z[4], z[7], z[2], z[1], z[3],
&dvdx[6], &dvdy[6], &dvdz[6]);
VoluDer(x[6], x[5], x[4], x[3], x[2], x[0],
y[6], y[5], y[4], y[3], y[2], y[0],
z[6], z[5], z[4], z[3], z[2], z[0],
&dvdx[7], &dvdy[7], &dvdz[7]);
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void CalcElemFBHourglassForce(Real_t *xd, Real_t *yd, Real_t *zd, Real_t hourgam[][4],
Real_t coefficient,
Real_t *hgfx, Real_t *hgfy, Real_t *hgfz )
{
Real_t hxx[4];
for(Index_t i = 0; i < 4; i++) {
hxx[i] = hourgam[0][i] * xd[0] + hourgam[1][i] * xd[1] +
hourgam[2][i] * xd[2] + hourgam[3][i] * xd[3] +
hourgam[4][i] * xd[4] + hourgam[5][i] * xd[5] +
hourgam[6][i] * xd[6] + hourgam[7][i] * xd[7];
}
for(Index_t i = 0; i < 8; i++) {
hgfx[i] = coefficient *
(hourgam[i][0] * hxx[0] + hourgam[i][1] * hxx[1] +
hourgam[i][2] * hxx[2] + hourgam[i][3] * hxx[3]);
}
for(Index_t i = 0; i < 4; i++) {
hxx[i] = hourgam[0][i] * yd[0] + hourgam[1][i] * yd[1] +
hourgam[2][i] * yd[2] + hourgam[3][i] * yd[3] +
hourgam[4][i] * yd[4] + hourgam[5][i] * yd[5] +
hourgam[6][i] * yd[6] + hourgam[7][i] * yd[7];
}
for(Index_t i = 0; i < 8; i++) {
hgfy[i] = coefficient *
(hourgam[i][0] * hxx[0] + hourgam[i][1] * hxx[1] +
hourgam[i][2] * hxx[2] + hourgam[i][3] * hxx[3]);
}
for(Index_t i = 0; i < 4; i++) {
hxx[i] = hourgam[0][i] * zd[0] + hourgam[1][i] * zd[1] +
hourgam[2][i] * zd[2] + hourgam[3][i] * zd[3] +
hourgam[4][i] * zd[4] + hourgam[5][i] * zd[5] +
hourgam[6][i] * zd[6] + hourgam[7][i] * zd[7];
}
for(Index_t i = 0; i < 8; i++) {
hgfz[i] = coefficient *
(hourgam[i][0] * hxx[0] + hourgam[i][1] * hxx[1] +
hourgam[i][2] * hxx[2] + hourgam[i][3] * hxx[3]);
}
}
#pragma omp end declare target
/******************************************/
static inline
void CalcFBHourglassForceForElems( Domain &domain,
Real_t *determ,
Real_t *x8n, Real_t *y8n, Real_t *z8n,
Real_t *dvdx, Real_t *dvdy, Real_t *dvdz,
Real_t hourg, Index_t numElem,
Index_t numNode)
{
/*************************************************
*
* FUNCTION: Calculates the Flanagan-Belytschko anti-hourglass
* force.
*
*************************************************/
#if _OPENMP
Index_t numthreads = omp_get_max_threads();
#else
Index_t numthreads = 1;
#endif
Index_t numElem8 = numElem * 8 ;
Real_t *fx_elem;
Real_t *fy_elem;
Real_t *fz_elem;
if(numthreads > 1) {
fx_elem = Allocate<Real_t>(numElem8) ;
fy_elem = Allocate<Real_t>(numElem8) ;
fz_elem = Allocate<Real_t>(numElem8) ;
}
/*************************************************/
/* compute the hourglass modes */
Index_t *nodelist = &domain.m_nodelist[0];
Real_t *ss = &domain.m_ss[0];
Real_t *elemMass = &domain.m_elemMass[0];
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
Real_t *fx = &domain.m_fx[0];
Real_t *fy = &domain.m_fy[0];
Real_t *fz = &domain.m_fz[0];
Index_t *nodeElemStart = &domain.m_nodeElemStart[0];
Index_t len1 = numNode + 1;
Index_t *nodeElemCornerList = &domain.m_nodeElemCornerList[0];
Index_t len2 = nodeElemStart[numNode];
#pragma omp target enter data map(alloc:fx_elem[:numElem8], fy_elem[:numElem8], fz_elem[:numElem8]) \
map(alloc:fx[:numNode], fy[:numNode], fz[:numNode]) if (USE_GPU == 1)
/* start loop over elements */
#pragma omp target data map(alloc: dvdx[:numElem8], dvdy[:numElem8], dvdz[:numElem8], \
x8n[:numElem8], y8n[:numElem8], z8n[:numElem8], \
determ[:numElem], \
xd[:numNode], yd[:numNode], zd[:numNode], \
nodelist[:numElem8] ) \
map(to: ss[:numElem], elemMass[:numElem], \
hourg, numthreads) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for(Index_t i2=0;i2<numElem;++i2){
Real_t gamma[4][8];
gamma[0][0] = Real_t( 1.);
gamma[0][1] = Real_t( 1.);
gamma[0][2] = Real_t(-1.);
gamma[0][3] = Real_t(-1.);
gamma[0][4] = Real_t(-1.);
gamma[0][5] = Real_t(-1.);
gamma[0][6] = Real_t( 1.);
gamma[0][7] = Real_t( 1.);
gamma[1][0] = Real_t( 1.);
gamma[1][1] = Real_t(-1.);
gamma[1][2] = Real_t(-1.);
gamma[1][3] = Real_t( 1.);
gamma[1][4] = Real_t(-1.);
gamma[1][5] = Real_t( 1.);
gamma[1][6] = Real_t( 1.);
gamma[1][7] = Real_t(-1.);
gamma[2][0] = Real_t( 1.);
gamma[2][1] = Real_t(-1.);
gamma[2][2] = Real_t( 1.);
gamma[2][3] = Real_t(-1.);
gamma[2][4] = Real_t( 1.);
gamma[2][5] = Real_t(-1.);
gamma[2][6] = Real_t( 1.);
gamma[2][7] = Real_t(-1.);
gamma[3][0] = Real_t(-1.);
gamma[3][1] = Real_t( 1.);
gamma[3][2] = Real_t(-1.);
gamma[3][3] = Real_t( 1.);
gamma[3][4] = Real_t( 1.);
gamma[3][5] = Real_t(-1.);
gamma[3][6] = Real_t( 1.);
gamma[3][7] = Real_t(-1.);
Real_t *fx_local, *fy_local, *fz_local ;
Real_t hgfx[8], hgfy[8], hgfz[8] ;
Real_t coefficient;
Real_t hourgam[8][4];
Real_t xd1[8], yd1[8], zd1[8] ;
// const Index_t *elemToNode = domain.nodelist(i2);
Index_t* elemToNode = &nodelist[Index_t(8)*i2];
Index_t i3=8*i2;
Real_t volinv=Real_t(1.0)/determ[i2];
Real_t ss1, mass1, volume13 ;
for(Index_t i1=0;i1<4;++i1){
Real_t hourmodx =
x8n[i3] * gamma[i1][0] + x8n[i3+1] * gamma[i1][1] +
x8n[i3+2] * gamma[i1][2] + x8n[i3+3] * gamma[i1][3] +
x8n[i3+4] * gamma[i1][4] + x8n[i3+5] * gamma[i1][5] +
x8n[i3+6] * gamma[i1][6] + x8n[i3+7] * gamma[i1][7];
Real_t hourmody =
y8n[i3] * gamma[i1][0] + y8n[i3+1] * gamma[i1][1] +
y8n[i3+2] * gamma[i1][2] + y8n[i3+3] * gamma[i1][3] +
y8n[i3+4] * gamma[i1][4] + y8n[i3+5] * gamma[i1][5] +
y8n[i3+6] * gamma[i1][6] + y8n[i3+7] * gamma[i1][7];
Real_t hourmodz =
z8n[i3] * gamma[i1][0] + z8n[i3+1] * gamma[i1][1] +
z8n[i3+2] * gamma[i1][2] + z8n[i3+3] * gamma[i1][3] +
z8n[i3+4] * gamma[i1][4] + z8n[i3+5] * gamma[i1][5] +
z8n[i3+6] * gamma[i1][6] + z8n[i3+7] * gamma[i1][7];
hourgam[0][i1] = gamma[i1][0] - volinv*(dvdx[i3 ] * hourmodx +
dvdy[i3 ] * hourmody +
dvdz[i3 ] * hourmodz );
hourgam[1][i1] = gamma[i1][1] - volinv*(dvdx[i3+1] * hourmodx +
dvdy[i3+1] * hourmody +
dvdz[i3+1] * hourmodz );
hourgam[2][i1] = gamma[i1][2] - volinv*(dvdx[i3+2] * hourmodx +
dvdy[i3+2] * hourmody +
dvdz[i3+2] * hourmodz );
hourgam[3][i1] = gamma[i1][3] - volinv*(dvdx[i3+3] * hourmodx +
dvdy[i3+3] * hourmody +
dvdz[i3+3] * hourmodz );
hourgam[4][i1] = gamma[i1][4] - volinv*(dvdx[i3+4] * hourmodx +
dvdy[i3+4] * hourmody +
dvdz[i3+4] * hourmodz );
hourgam[5][i1] = gamma[i1][5] - volinv*(dvdx[i3+5] * hourmodx +
dvdy[i3+5] * hourmody +
dvdz[i3+5] * hourmodz );
hourgam[6][i1] = gamma[i1][6] - volinv*(dvdx[i3+6] * hourmodx +
dvdy[i3+6] * hourmody +
dvdz[i3+6] * hourmodz );
hourgam[7][i1] = gamma[i1][7] - volinv*(dvdx[i3+7] * hourmodx +
dvdy[i3+7] * hourmody +
dvdz[i3+7] * hourmodz );
}
/* compute forces */
/* store forces into h arrays (force arrays) */
ss1 = ss[i2];
mass1 = elemMass[i2];
volume13 = cbrt(determ[i2]);
Index_t n0si2 = elemToNode[0];
Index_t n1si2 = elemToNode[1];
Index_t n2si2 = elemToNode[2];
Index_t n3si2 = elemToNode[3];
Index_t n4si2 = elemToNode[4];
Index_t n5si2 = elemToNode[5];
Index_t n6si2 = elemToNode[6];
Index_t n7si2 = elemToNode[7];
xd1[0] = xd[n0si2];
xd1[1] = xd[n1si2];
xd1[2] = xd[n2si2];
xd1[3] = xd[n3si2];
xd1[4] = xd[n4si2];
xd1[5] = xd[n5si2];
xd1[6] = xd[n6si2];
xd1[7] = xd[n7si2];
yd1[0] = yd[n0si2];
yd1[1] = yd[n1si2];
yd1[2] = yd[n2si2];
yd1[3] = yd[n3si2];
yd1[4] = yd[n4si2];
yd1[5] = yd[n5si2];
yd1[6] = yd[n6si2];
yd1[7] = yd[n7si2];
zd1[0] = zd[n0si2];
zd1[1] = zd[n1si2];
zd1[2] = zd[n2si2];
zd1[3] = zd[n3si2];
zd1[4] = zd[n4si2];
zd1[5] = zd[n5si2];
zd1[6] = zd[n6si2];
zd1[7] = zd[n7si2];
coefficient = - hourg * Real_t(0.01) * ss1 * mass1 / volume13;
CalcElemFBHourglassForce(xd1,yd1,zd1,
hourgam,
coefficient, hgfx, hgfy, hgfz);
// With the threaded version, we write into local arrays per elem
// so we don't have to worry about race conditions
if (numthreads > 1) {
fx_local = &fx_elem[i3] ;
fx_local[0] = hgfx[0];
fx_local[1] = hgfx[1];
fx_local[2] = hgfx[2];
fx_local[3] = hgfx[3];
fx_local[4] = hgfx[4];
fx_local[5] = hgfx[5];
fx_local[6] = hgfx[6];
fx_local[7] = hgfx[7];
fy_local = &fy_elem[i3] ;
fy_local[0] = hgfy[0];
fy_local[1] = hgfy[1];
fy_local[2] = hgfy[2];
fy_local[3] = hgfy[3];
fy_local[4] = hgfy[4];
fy_local[5] = hgfy[5];
fy_local[6] = hgfy[6];
fy_local[7] = hgfy[7];
fz_local = &fz_elem[i3] ;
fz_local[0] = hgfz[0];
fz_local[1] = hgfz[1];
fz_local[2] = hgfz[2];
fz_local[3] = hgfz[3];
fz_local[4] = hgfz[4];
fz_local[5] = hgfz[5];
fz_local[6] = hgfz[6];
fz_local[7] = hgfz[7];
}
else {
fx[n0si2] += hgfx[0];
fy[n0si2] += hgfy[0];
fz[n0si2] += hgfz[0];
fx[n1si2] += hgfx[1];
fy[n1si2] += hgfy[1];
fz[n1si2] += hgfz[1];
fx[n2si2] += hgfx[2];
fy[n2si2] += hgfy[2];
fz[n2si2] += hgfz[2];
fx[n3si2] += hgfx[3];
fy[n3si2] += hgfy[3];
fz[n3si2] += hgfz[3];
fx[n4si2] += hgfx[4];
fy[n4si2] += hgfy[4];
fz[n4si2] += hgfz[4];
fx[n5si2] += hgfx[5];
fy[n5si2] += hgfy[5];
fz[n5si2] += hgfz[5];
fx[n6si2] += hgfx[6];
fy[n6si2] += hgfy[6];
fz[n6si2] += hgfz[6];
fx[n7si2] += hgfx[7];
fy[n7si2] += hgfy[7];
fz[n7si2] += hgfz[7];
}
}
}
if (numthreads > 1) {
// Collect the data from the local arrays into the final force arrays
#pragma omp target data map(to: nodeElemStart[:len1], nodeElemCornerList[:len2]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for( Index_t gnode=0 ; gnode<numNode ; ++gnode )
{
// element count
Index_t count = nodeElemStart[gnode+1] - nodeElemStart[gnode];//domain.nodeElemCount(gnode) ;
// list of all corners
Index_t *cornerList = &nodeElemCornerList[nodeElemStart[gnode]];//domain.nodeElemCornerList(gnode) ;
Real_t fx_tmp = Real_t(0.0) ;
Real_t fy_tmp = Real_t(0.0) ;
Real_t fz_tmp = Real_t(0.0) ;
for (Index_t i=0 ; i < count ; ++i) {
Index_t elem = cornerList[i] ;
fx_tmp += fx_elem[elem] ;
fy_tmp += fy_elem[elem] ;
fz_tmp += fz_elem[elem] ;
}
fx[gnode] += fx_tmp ;
fy[gnode] += fy_tmp ;
fz[gnode] += fz_tmp ;
}
}
#pragma omp target exit data map(delete:fx_elem[:numElem8], fy_elem[:numElem8], fz_elem[:numElem8]) if(USE_GPU == 1)
Release(&fz_elem) ;
Release(&fy_elem) ;
Release(&fx_elem) ;
}
}
/******************************************/
static inline
void CalcHourglassControlForElems(Domain& domain,
Real_t determ[], Real_t hgcoef)
{
Index_t numElem = domain.numElem() ;
Index_t numNode = domain.numNode() ;
Index_t numElem8 = numElem * 8 ;
Real_t *dvdx = Allocate<Real_t>(numElem8) ;
Real_t *dvdy = Allocate<Real_t>(numElem8) ;
Real_t *dvdz = Allocate<Real_t>(numElem8) ;
Real_t *x8n = Allocate<Real_t>(numElem8) ;
Real_t *y8n = Allocate<Real_t>(numElem8) ;
Real_t *z8n = Allocate<Real_t>(numElem8) ;
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
Real_t *volo = &domain.m_volo[0];
Real_t *v = &domain.m_v[0];
Index_t *nodelist = &domain.m_nodelist[0];
int vol_error = -1;
#pragma omp target enter data map(alloc:dvdx[:numElem8], dvdy[:numElem8], dvdz[:numElem8], \
x8n[:numElem8], y8n[:numElem8], z8n[:numElem8], \
determ[:numElem]) if(USE_GPU == 1)
/* start loop over elements */
#pragma omp target data map(alloc: x[:numNode], y[:numNode], z[:numNode], \
nodelist[:numElem8]) \
map(to: volo[:numElem], v[:numElem]) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (Index_t i=0 ; i<numElem ; ++i){
Real_t x1[8], y1[8], z1[8] ;
Real_t pfx[8], pfy[8], pfz[8] ;
// Index_t* elemToNode = domain.nodelist(i);
Index_t* elemToNode = &nodelist[Index_t(8)*i];
// CollectDomainNodesToElemNodes(domain, elemToNode, x1, y1, z1);
// inline the function manually
Index_t nd0i = elemToNode[0] ;
Index_t nd1i = elemToNode[1] ;
Index_t nd2i = elemToNode[2] ;
Index_t nd3i = elemToNode[3] ;
Index_t nd4i = elemToNode[4] ;
Index_t nd5i = elemToNode[5] ;
Index_t nd6i = elemToNode[6] ;
Index_t nd7i = elemToNode[7] ;
x1[0] = x[nd0i];
x1[1] = x[nd1i];
x1[2] = x[nd2i];
x1[3] = x[nd3i];
x1[4] = x[nd4i];
x1[5] = x[nd5i];
x1[6] = x[nd6i];
x1[7] = x[nd7i];
y1[0] = y[nd0i];
y1[1] = y[nd1i];
y1[2] = y[nd2i];
y1[3] = y[nd3i];
y1[4] = y[nd4i];
y1[5] = y[nd5i];
y1[6] = y[nd6i];
y1[7] = y[nd7i];
z1[0] = z[nd0i];
z1[1] = z[nd1i];
z1[2] = z[nd2i];
z1[3] = z[nd3i];
z1[4] = z[nd4i];
z1[5] = z[nd5i];
z1[6] = z[nd6i];
z1[7] = z[nd7i];
CalcElemVolumeDerivative(pfx, pfy, pfz, x1, y1, z1);
/* load into temporary storage for FB Hour Glass control */
for(Index_t ii=0;ii<8;++ii){
Index_t jj=8*i+ii;
dvdx[jj] = pfx[ii];
dvdy[jj] = pfy[ii];
dvdz[jj] = pfz[ii];
x8n[jj] = x1[ii];
y8n[jj] = y1[ii];
z8n[jj] = z1[ii];
}
determ[i] = volo[i] * v[i];
/* Do a check for negative volumes */
if ( v[i] <= Real_t(0.0) ) {
vol_error = i;
}
}
}
if (vol_error >= 0){
#if USE_MPI
MPI_Abort(MPI_COMM_WORLD, VolumeError) ; //how to terminate safely if computing on GPU ?
#else
exit(VolumeError);
#endif
}
if ( hgcoef > Real_t(0.) ) {
CalcFBHourglassForceForElems( domain,
determ, x8n, y8n, z8n, dvdx, dvdy, dvdz,
hgcoef, numElem, domain.numNode()) ;
}
#pragma omp target exit data map(delete: dvdx[:numElem8], dvdy[:numElem8], dvdz[:numElem8], \
x8n[:numElem8], y8n[:numElem8], z8n[:numElem8]) if(USE_GPU == 1)
Release(&z8n) ;
Release(&y8n) ;
Release(&x8n) ;
Release(&dvdz) ;
Release(&dvdy) ;
Release(&dvdx) ;
return ;
}
/******************************************/
static inline
void CalcVolumeForceForElems(Domain& domain)
{
Index_t numElem = domain.numElem() ;
Index_t numNode = domain.numNode();
if (numElem != 0) {
Real_t hgcoef = domain.hgcoef() ;
Real_t *sigxx = Allocate<Real_t>(numElem) ;
Real_t *sigyy = Allocate<Real_t>(numElem) ;
Real_t *sigzz = Allocate<Real_t>(numElem) ;
Real_t *determ = Allocate<Real_t>(numElem) ;
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
#pragma omp target enter data map(alloc:sigxx[:numElem], sigyy[:numElem], sigzz[:numElem]) if (USE_GPU == 1)
/* Sum contributions to total stress tensor */
InitStressTermsForElems(domain, sigxx, sigyy, sigzz, numElem);
// call elemlib stress integration loop to produce nodal forces from
// material stresses.
#pragma omp target enter data map(alloc:determ[:numElem]) if(USE_GPU == 1)
#pragma omp target enter data map(alloc:x[:numNode], y[:numNode], z[:numNode]) if(USE_GPU == 1)
IntegrateStressForElems( domain,
sigxx, sigyy, sigzz, determ, numElem,
domain.numNode()) ;
// check for negative element volume
#pragma omp target update from(determ[:numElem]) if(USE_GPU == 1)
#pragma omp parallel for firstprivate(numElem)
for ( Index_t k=0 ; k<numElem ; ++k ) {
if (determ[k] <= Real_t(0.0)) {
#if USE_MPI
MPI_Abort(MPI_COMM_WORLD, VolumeError) ;
#else
exit(VolumeError);
#endif
}
}
#pragma omp target exit data map(delete:sigxx[:numElem], sigyy[:numElem], sigzz[:numElem]) if(USE_GPU == 1)
CalcHourglassControlForElems(domain, determ, hgcoef) ;
#pragma omp target exit data map(delete:determ[:numElem]) if(USE_GPU == 1)
Release(&determ) ;
Release(&sigzz) ;
Release(&sigyy) ;
Release(&sigxx) ;
}
}
/******************************************/
static inline void CalcForceForNodes(Domain& domain)
{
Index_t numNode = domain.numNode() ;
#if USE_MPI
CommRecv(domain, MSG_COMM_SBN, 3,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
true, false) ;
#endif
Real_t *fx = &domain.m_fx[0];
Real_t *fy = &domain.m_fy[0];
Real_t *fz = &domain.m_fz[0];
# pragma omp target data map(alloc: fx[:numNode], fy[:numNode], fz[:numNode]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (int i=0; i<numNode; ++i) {
fx[i] = double(0.0);
fy[i] = double(0.0);
fz[i] = double(0.0);
}
}
/* Calcforce calls partial, force, hourq */
CalcVolumeForceForElems(domain) ;
#if USE_MPI
Domain_member fieldData[3] ;
fieldData[0] = &Domain::fx ;
fieldData[1] = &Domain::fy ;
fieldData[2] = &Domain::fz ;
CommSend(domain, MSG_COMM_SBN, 3, fieldData,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
true, false) ;
CommSBN(domain, 3, fieldData) ;
#endif
}
/******************************************/
static inline
void CalcAccelerationForNodes(Domain &domain, Index_t numNode)
{
Real_t *xdd = &domain.m_xdd[0];
Real_t *ydd = &domain.m_ydd[0];
Real_t *zdd = &domain.m_zdd[0];
Real_t *fx = &domain.m_fx[0];
Real_t *fy = &domain.m_fy[0];
Real_t *fz = &domain.m_fz[0];
Real_t *nodalMass = &domain.m_nodalMass[0];
#pragma omp target data map(alloc: fx[:numNode], fy[:numNode], fz[:numNode]) \
map(to: nodalMass[:numNode]) \
map(alloc: xdd[:numNode], ydd[:numNode], zdd[:numNode]) if(USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (Index_t i = 0; i < numNode; ++i) {
Real_t one_over_nMass = Real_t(1.) / nodalMass[i];
xdd[i] = fx[i] * one_over_nMass;
ydd[i] = fy[i] * one_over_nMass;
zdd[i] = fz[i] * one_over_nMass;
}
}
}
/******************************************/
static inline
void ApplyAccelerationBoundaryConditionsForNodes(Domain& domain)
{
Index_t size = domain.sizeX();
Index_t numNodeBC = (size+1)*(size+1) ;
Index_t numNode = domain.numNode() ;
Real_t *xdd = &domain.m_xdd[0];
Real_t *ydd = &domain.m_ydd[0];
Real_t *zdd = &domain.m_zdd[0];
Index_t *symmX = &domain.m_symmX[0];
Index_t *symmY = &domain.m_symmY[0];
Index_t *symmZ = &domain.m_symmZ[0];
Index_t s1 = domain.symmXempty();
Index_t s2 = domain.symmYempty();
Index_t s3 = domain.symmZempty();
# pragma omp target data map(to: symmX[:numNodeBC], symmY[:numNodeBC], symmZ[:numNodeBC]) \
map(alloc: xdd[:numNode], ydd[:numNode], zdd[:numNode]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for(Index_t i=0 ; i<numNodeBC ; ++i){
if ((!s1) != 0)
xdd[symmX[i]] = Real_t(0.0) ;
if ((!s2) != 0)
ydd[symmY[i]] = Real_t(0.0) ;
if ((!s3) != 0)
zdd[symmZ[i]] = Real_t(0.0) ;
}
}
}
/******************************************/
static inline
void CalcVelocityForNodes(Domain &domain, const Real_t dt, const Real_t u_cut,
Index_t numNode)
{
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
Real_t *xdd = &domain.m_xdd[0];
Real_t *ydd = &domain.m_ydd[0];
Real_t *zdd = &domain.m_zdd[0];
# pragma omp target data map(alloc: xdd[:numNode], ydd[:numNode], zdd[:numNode]) \
map(to: dt, u_cut) \
map(alloc: xd[:numNode], yd[:numNode], zd[:numNode]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for ( Index_t i = 0 ; i < numNode ; ++i )
{
Real_t xdtmp, ydtmp, zdtmp ;
xdtmp = xd[i] + xdd[i] * dt ;
// FABS is not compiled with target regions in mind
// To get around this, compute the absolute value manually:
// if( xdtmp > Real_t(0.0) && xdtmp < u_cut || Real_t(-1.0) * xdtmp < u_cut)
if( FABS(xdtmp) < u_cut ) xdtmp = Real_t(0.0);
xd[i] = xdtmp ;
ydtmp = yd[i] + ydd[i] * dt ;
if( FABS(ydtmp) < u_cut ) ydtmp = Real_t(0.0);
yd[i] = ydtmp ;
zdtmp = zd[i] + zdd[i] * dt ;
if( FABS(zdtmp) < u_cut ) zdtmp = Real_t(0.0);
zd[i] = zdtmp ;
}
}
}
/******************************************/
static inline
void CalcPositionForNodes(Domain &domain, const Real_t dt, Index_t numNode)
{
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
#pragma omp target data map(alloc: xd[:numNode], yd[:numNode], zd[:numNode]) \
map(to: dt) \
map(alloc: x[:numNode], y[:numNode], z[:numNode]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for ( Index_t i = 0 ; i < numNode ; ++i )
{
x[i] += xd[i] * dt ;
y[i] += yd[i] * dt ;
z[i] += zd[i] * dt ;
}
}
}
/******************************************/
static inline
void LagrangeNodal(Domain& domain)
{
#ifdef SEDOV_SYNC_POS_VEL_EARLY
Domain_member fieldData[6] ;
#endif
//bool USE_GPU=true;
const Real_t delt = domain.deltatime() ;
Real_t u_cut = domain.u_cut() ;
Index_t numNode = domain.numNode() ;
/* time of boundary condition evaluation is beginning of step for force and
* acceleration boundary conditions. */
CalcForceForNodes(domain);
#if USE_MPI
#ifdef SEDOV_SYNC_POS_VEL_EARLY
CommRecv(domain, MSG_SYNC_POS_VEL, 6,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
false, false) ;
#endif
#endif
double t_start = 0;//omp_get_wtime();
Real_t *xdd = &domain.m_xdd[0];
Real_t *ydd = &domain.m_ydd[0];
Real_t *zdd = &domain.m_zdd[0];
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
CalcAccelerationForNodes(domain, domain.numNode()); // IN: fx OUT: m_xdd
//LG try to overlap ApplyAccelerationBoundaryConditionsForNodes and moving "xd" to GPU
ApplyAccelerationBoundaryConditionsForNodes(domain); // uses m_xdd
CalcVelocityForNodes( domain, delt, u_cut, domain.numNode()) ; //uses m_xd and m_xdd
CalcPositionForNodes( domain, delt, domain.numNode() ); //uses m_xd and m_x
#if USE_MPI
#ifdef SEDOV_SYNC_POS_VEL_EARLY
fieldData[0] = &Domain::x ;
fieldData[1] = &Domain::y ;
fieldData[2] = &Domain::z ;
fieldData[3] = &Domain::xd ;
fieldData[4] = &Domain::yd ;
fieldData[5] = &Domain::zd ;
CommSend(domain, MSG_SYNC_POS_VEL, 6, fieldData,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
false, false) ;
CommSyncPosVel(domain) ;
#endif
#endif
return;
}
/******************************************/
#pragma omp declare target
static inline
Real_t CalcElemVolume( const Real_t x0, const Real_t x1,
const Real_t x2, const Real_t x3,
const Real_t x4, const Real_t x5,
const Real_t x6, const Real_t x7,
const Real_t y0, const Real_t y1,
const Real_t y2, const Real_t y3,
const Real_t y4, const Real_t y5,
const Real_t y6, const Real_t y7,
const Real_t z0, const Real_t z1,
const Real_t z2, const Real_t z3,
const Real_t z4, const Real_t z5,
const Real_t z6, const Real_t z7 )
{
Real_t twelveth = Real_t(1.0)/Real_t(12.0);
Real_t dx61 = x6 - x1;
Real_t dy61 = y6 - y1;
Real_t dz61 = z6 - z1;
Real_t dx70 = x7 - x0;
Real_t dy70 = y7 - y0;
Real_t dz70 = z7 - z0;
Real_t dx63 = x6 - x3;
Real_t dy63 = y6 - y3;
Real_t dz63 = z6 - z3;
Real_t dx20 = x2 - x0;
Real_t dy20 = y2 - y0;
Real_t dz20 = z2 - z0;
Real_t dx50 = x5 - x0;
Real_t dy50 = y5 - y0;
Real_t dz50 = z5 - z0;
Real_t dx64 = x6 - x4;
Real_t dy64 = y6 - y4;
Real_t dz64 = z6 - z4;
Real_t dx31 = x3 - x1;
Real_t dy31 = y3 - y1;
Real_t dz31 = z3 - z1;
Real_t dx72 = x7 - x2;
Real_t dy72 = y7 - y2;
Real_t dz72 = z7 - z2;
Real_t dx43 = x4 - x3;
Real_t dy43 = y4 - y3;
Real_t dz43 = z4 - z3;
Real_t dx57 = x5 - x7;
Real_t dy57 = y5 - y7;
Real_t dz57 = z5 - z7;
Real_t dx14 = x1 - x4;
Real_t dy14 = y1 - y4;
Real_t dz14 = z1 - z4;
Real_t dx25 = x2 - x5;
Real_t dy25 = y2 - y5;
Real_t dz25 = z2 - z5;
#define TRIPLE_PRODUCT(x1, y1, z1, x2, y2, z2, x3, y3, z3) \
((x1)*((y2)*(z3) - (z2)*(y3)) + (x2)*((z1)*(y3) - (y1)*(z3)) + (x3)*((y1)*(z2) - (z1)*(y2)))
Real_t volume =
TRIPLE_PRODUCT(dx31 + dx72, dx63, dx20,
dy31 + dy72, dy63, dy20,
dz31 + dz72, dz63, dz20) +
TRIPLE_PRODUCT(dx43 + dx57, dx64, dx70,
dy43 + dy57, dy64, dy70,
dz43 + dz57, dz64, dz70) +
TRIPLE_PRODUCT(dx14 + dx25, dx61, dx50,
dy14 + dy25, dy61, dy50,
dz14 + dz25, dz61, dz50);
#undef TRIPLE_PRODUCT
volume *= twelveth;
return volume ;
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
//inline
Real_t CalcElemVolume( const Real_t x[8], const Real_t y[8], const Real_t z[8] )
{
return CalcElemVolume( x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7],
y[0], y[1], y[2], y[3], y[4], y[5], y[6], y[7],
z[0], z[1], z[2], z[3], z[4], z[5], z[6], z[7]);
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
Real_t AreaFace( const Real_t x0, const Real_t x1,
const Real_t x2, const Real_t x3,
const Real_t y0, const Real_t y1,
const Real_t y2, const Real_t y3,
const Real_t z0, const Real_t z1,
const Real_t z2, const Real_t z3)
{
Real_t fx = (x2 - x0) - (x3 - x1);
Real_t fy = (y2 - y0) - (y3 - y1);
Real_t fz = (z2 - z0) - (z3 - z1);
Real_t gx = (x2 - x0) + (x3 - x1);
Real_t gy = (y2 - y0) + (y3 - y1);
Real_t gz = (z2 - z0) + (z3 - z1);
Real_t area =
(fx * fx + fy * fy + fz * fz) *
(gx * gx + gy * gy + gz * gz) -
(fx * gx + fy * gy + fz * gz) *
(fx * gx + fy * gy + fz * gz);
return area ;
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
#define max(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
static inline
Real_t CalcElemCharacteristicLength( const Real_t x[8],
const Real_t y[8],
const Real_t z[8],
const Real_t volume)
{
Real_t a, charLength = Real_t(0.0);
a = AreaFace(x[0],x[1],x[2],x[3],
y[0],y[1],y[2],y[3],
z[0],z[1],z[2],z[3]) ;
charLength = max(a,charLength) ;
a = AreaFace(x[4],x[5],x[6],x[7],
y[4],y[5],y[6],y[7],
z[4],z[5],z[6],z[7]) ;
charLength = max(a,charLength) ;
a = AreaFace(x[0],x[1],x[5],x[4],
y[0],y[1],y[5],y[4],
z[0],z[1],z[5],z[4]) ;
charLength = max(a,charLength) ;
a = AreaFace(x[1],x[2],x[6],x[5],
y[1],y[2],y[6],y[5],
z[1],z[2],z[6],z[5]) ;
charLength = max(a,charLength) ;
a = AreaFace(x[2],x[3],x[7],x[6],
y[2],y[3],y[7],y[6],
z[2],z[3],z[7],z[6]) ;
charLength = max(a,charLength) ;
a = AreaFace(x[3],x[0],x[4],x[7],
y[3],y[0],y[4],y[7],
z[3],z[0],z[4],z[7]) ;
charLength = max(a,charLength) ;
charLength = Real_t(4.0) * volume / SQRT(charLength);
return charLength;
}
#pragma omp end declare target
/******************************************/
#pragma omp declare target
static inline
void CalcElemVelocityGradient( const Real_t* const xvel,
const Real_t* const yvel,
const Real_t* const zvel,
const Real_t b[][8],
const Real_t detJ,
Real_t* const d )
{
const Real_t inv_detJ = Real_t(1.0) / detJ ;
Real_t dyddx, dxddy, dzddx, dxddz, dzddy, dyddz;
const Real_t* const pfx = b[0];
const Real_t* const pfy = b[1];
const Real_t* const pfz = b[2];
d[0] = inv_detJ * ( pfx[0] * (xvel[0]-xvel[6])
+ pfx[1] * (xvel[1]-xvel[7])
+ pfx[2] * (xvel[2]-xvel[4])
+ pfx[3] * (xvel[3]-xvel[5]) );
d[1] = inv_detJ * ( pfy[0] * (yvel[0]-yvel[6])
+ pfy[1] * (yvel[1]-yvel[7])
+ pfy[2] * (yvel[2]-yvel[4])
+ pfy[3] * (yvel[3]-yvel[5]) );
d[2] = inv_detJ * ( pfz[0] * (zvel[0]-zvel[6])
+ pfz[1] * (zvel[1]-zvel[7])
+ pfz[2] * (zvel[2]-zvel[4])
+ pfz[3] * (zvel[3]-zvel[5]) );
dyddx = inv_detJ * ( pfx[0] * (yvel[0]-yvel[6])
+ pfx[1] * (yvel[1]-yvel[7])
+ pfx[2] * (yvel[2]-yvel[4])
+ pfx[3] * (yvel[3]-yvel[5]) );
dxddy = inv_detJ * ( pfy[0] * (xvel[0]-xvel[6])
+ pfy[1] * (xvel[1]-xvel[7])
+ pfy[2] * (xvel[2]-xvel[4])
+ pfy[3] * (xvel[3]-xvel[5]) );
dzddx = inv_detJ * ( pfx[0] * (zvel[0]-zvel[6])
+ pfx[1] * (zvel[1]-zvel[7])
+ pfx[2] * (zvel[2]-zvel[4])
+ pfx[3] * (zvel[3]-zvel[5]) );
dxddz = inv_detJ * ( pfz[0] * (xvel[0]-xvel[6])
+ pfz[1] * (xvel[1]-xvel[7])
+ pfz[2] * (xvel[2]-xvel[4])
+ pfz[3] * (xvel[3]-xvel[5]) );
dzddy = inv_detJ * ( pfy[0] * (zvel[0]-zvel[6])
+ pfy[1] * (zvel[1]-zvel[7])
+ pfy[2] * (zvel[2]-zvel[4])
+ pfy[3] * (zvel[3]-zvel[5]) );
dyddz = inv_detJ * ( pfz[0] * (yvel[0]-yvel[6])
+ pfz[1] * (yvel[1]-yvel[7])
+ pfz[2] * (yvel[2]-yvel[4])
+ pfz[3] * (yvel[3]-yvel[5]) );
d[5] = Real_t( .5) * ( dxddy + dyddx );
d[4] = Real_t( .5) * ( dxddz + dzddx );
d[3] = Real_t( .5) * ( dzddy + dyddz );
}
#pragma omp end declare target
/******************************************/
//static inline
void CalcKinematicsForElems( Domain &domain, Real_t *vnew,
Real_t deltaTime, Index_t numElem )
{
Index_t numNode = domain.numNode();
Index_t numElem8 = Index_t(8) * numElem;
Index_t *nodelist = &domain.m_nodelist[0];
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
Real_t *dxx = &domain.m_dxx[0];
Real_t *dyy = &domain.m_dyy[0];
Real_t *dzz = &domain.m_dzz[0];
Real_t *delv = &domain.m_delv[0];
Real_t *v = &domain.m_v[0];
Real_t *volo = &domain.m_volo[0];
Real_t *arealg = &domain.m_arealg[0];
// loop over all elements
# pragma omp target data map(alloc: xd[:numNode], yd[:numNode], zd[:numNode]) \
map(alloc: x[:numNode], y[:numNode], z[:numNode], \
nodelist[:numElem8]) \
map(to: volo[:numElem], v[:numElem], deltaTime) \
map(from: delv[:numElem], arealg[:numElem]) \
map(alloc: dxx[:numElem], dyy[:numElem], dzz[:numElem]) \
map(alloc: vnew[:numElem]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for( Index_t k=0 ; k<numElem ; ++k )
{
Real_t B[3][8] ; /** shape function derivatives */
Real_t D[6] ;
Real_t x_local[8] ;
Real_t y_local[8] ;
Real_t z_local[8] ;
Real_t xd_local[8] ;
Real_t yd_local[8] ;
Real_t zd_local[8] ;
Real_t detJ = Real_t(0.0) ;
Real_t volume ;
Real_t relativeVolume ;
// const Index_t* const elemToNode = domain.nodelist(k) ;
const Index_t* elemToNode = &nodelist[Index_t(8)*k];
// get nodal coordinates from global arrays and copy into local arrays.
// CollectDomainNodesToElemNodes(domain, elemToNode, x_local, y_local, z_local);
Index_t nd0i = elemToNode[0] ;
Index_t nd1i = elemToNode[1] ;
Index_t nd2i = elemToNode[2] ;
Index_t nd3i = elemToNode[3] ;
Index_t nd4i = elemToNode[4] ;
Index_t nd5i = elemToNode[5] ;
Index_t nd6i = elemToNode[6] ;
Index_t nd7i = elemToNode[7] ;
x_local[0] = x[nd0i];
x_local[1] = x[nd1i];
x_local[2] = x[nd2i];
x_local[3] = x[nd3i];
x_local[4] = x[nd4i];
x_local[5] = x[nd5i];
x_local[6] = x[nd6i];
x_local[7] = x[nd7i];
y_local[0] = y[nd0i];
y_local[1] = y[nd1i];
y_local[2] = y[nd2i];
y_local[3] = y[nd3i];
y_local[4] = y[nd4i];
y_local[5] = y[nd5i];
y_local[6] = y[nd6i];
y_local[7] = y[nd7i];
z_local[0] = z[nd0i];
z_local[1] = z[nd1i];
z_local[2] = z[nd2i];
z_local[3] = z[nd3i];
z_local[4] = z[nd4i];
z_local[5] = z[nd5i];
z_local[6] = z[nd6i];
z_local[7] = z[nd7i];
// volume calculations
volume = CalcElemVolume(x_local, y_local, z_local );
relativeVolume = volume / volo[k] ;
vnew[k] = relativeVolume ;
delv[k] = relativeVolume - v[k] ;
// set characteristic length
arealg[k] = CalcElemCharacteristicLength(x_local, y_local, z_local,
volume);
// get nodal velocities from global array and copy into local arrays.
for( Index_t lnode=0 ; lnode<8 ; ++lnode )
{
Index_t gnode = elemToNode[lnode];
xd_local[lnode] = xd[gnode];
yd_local[lnode] = yd[gnode];
zd_local[lnode] = zd[gnode];
}
Real_t dt2 = Real_t(0.5) * deltaTime;
for ( Index_t j=0 ; j<8 ; ++j )
{
x_local[j] -= dt2 * xd_local[j];
y_local[j] -= dt2 * yd_local[j];
z_local[j] -= dt2 * zd_local[j];
}
CalcElemShapeFunctionDerivatives( x_local, y_local, z_local,
B, &detJ );
CalcElemVelocityGradient( xd_local, yd_local, zd_local,
B, detJ, D );
// put velocity gradient quantities into their global arrays.
dxx[k] = D[0];
dyy[k] = D[1];
dzz[k] = D[2];
}
}
}
/******************************************/
static inline
void CalcLagrangeElements(Domain& domain, Real_t* vnew)
{
Index_t numElem = domain.numElem() ;
if (numElem > 0) {
const Real_t deltatime = domain.deltatime() ;
domain.AllocateStrains(numElem);
Real_t *dxx = &domain.m_dxx[0];
Real_t *dyy = &domain.m_dyy[0];
Real_t *dzz = &domain.m_dzz[0];
#pragma omp target enter data map (alloc:dxx[:numElem], dyy[:numElem], dzz[:numElem]) if (USE_GPU == 1)
CalcKinematicsForElems(domain, vnew, deltatime, numElem) ;
Real_t *vdov = &domain.m_vdov[0];
int vol_error = -1;
// element loop to do some stuff not included in the elemlib function.
# pragma omp target data map(from: vdov[:numElem]) \
map(alloc: vnew[:numElem]) \
map(alloc: dxx[:numElem], dyy[:numElem], dzz[:numElem]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for ( Index_t k=0 ; k<numElem ; ++k )
{
// calc strain rate and apply as constraint (only done in FB element)
Real_t vvdov = dxx[k] + dyy[k] + dzz[k] ;
Real_t vdovthird = vvdov/Real_t(3.0) ;
// make the rate of deformation tensor deviatoric
vdov[k] = vvdov;
dxx[k] -= vdovthird ; //LG: why to update dxx? it is deallocated right after
dyy[k] -= vdovthird ;
dzz[k] -= vdovthird ;
// See if any volumes are negative, and take appropriate action.
if (vnew[k] <= Real_t(0.0))
{
vol_error = k;
}
}
}
if (vol_error >= 0){
#if USE_MPI
MPI_Abort(MPI_COMM_WORLD, VolumeError) ;
#else
printf("VolumeError Exit....\n");
exit(VolumeError);
#endif
}
domain.DeallocateStrains();
#pragma omp target exit data map (delete:dxx[:numElem], dyy[:numElem], dzz[:numElem]) if (USE_GPU == 1)
}
}
/******************************************/
// 10
static inline
void CalcMonotonicQGradientsForElems(Domain& domain, Real_t vnew[])
{
Index_t numElem = domain.numElem();
Int_t allElem = numElem + /* local elem */
2*domain.sizeX()*domain.sizeY() + /* plane ghosts */
2*domain.sizeX()*domain.sizeZ() + /* row ghosts */
2*domain.sizeY()*domain.sizeZ() ; /* col ghosts */
Index_t numNode = domain.numNode();
Index_t numElem8 = Index_t(8) * numElem;
Index_t *nodelist = &domain.m_nodelist[0];
Real_t *x = &domain.m_x[0];
Real_t *y = &domain.m_y[0];
Real_t *z = &domain.m_z[0];
Real_t *xd = &domain.m_xd[0];
Real_t *yd = &domain.m_yd[0];
Real_t *zd = &domain.m_zd[0];
Real_t *volo = &domain.m_volo[0];
Real_t *delv_zeta = &domain.m_delv_zeta[0];
Real_t *delx_zeta = &domain.m_delx_zeta[0];
Real_t *delv_xi = &domain.m_delv_xi[0];
Real_t *delx_xi = &domain.m_delx_xi[0];
Real_t *delv_eta = &domain.m_delv_eta[0];
Real_t *delx_eta = &domain.m_delx_eta[0];
// loop over all elements
# pragma omp target data map(alloc: xd[:numNode], yd[:numNode], zd[:numNode]) \
map(alloc: x[:numNode], y[:numNode], z[:numNode], \
nodelist[:numElem8]) \
map(to: volo[:numElem]) \
map(alloc: delv_zeta[:allElem], delx_zeta[:numElem], \
delv_eta[:allElem], delx_eta[:numElem], delv_xi[:allElem], delx_xi[:numElem]) \
map(alloc: vnew[:numElem]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (Index_t i = 0 ; i < numElem ; ++i ) {
const Real_t ptiny = Real_t(1.e-36) ;
Real_t ax,ay,az ;
Real_t dxv,dyv,dzv ;
const Index_t *elemToNode = &nodelist[Index_t(8.0) * i];
Index_t n0 = elemToNode[0] ;
Index_t n1 = elemToNode[1] ;
Index_t n2 = elemToNode[2] ;
Index_t n3 = elemToNode[3] ;
Index_t n4 = elemToNode[4] ;
Index_t n5 = elemToNode[5] ;
Index_t n6 = elemToNode[6] ;
Index_t n7 = elemToNode[7] ;
Real_t x0 = x[n0] ;
Real_t x1 = x[n1] ;
Real_t x2 = x[n2] ;
Real_t x3 = x[n3] ;
Real_t x4 = x[n4] ;
Real_t x5 = x[n5] ;
Real_t x6 = x[n6] ;
Real_t x7 = x[n7] ;
Real_t y0 = y[n0] ;
Real_t y1 = y[n1] ;
Real_t y2 = y[n2] ;
Real_t y3 = y[n3] ;
Real_t y4 = y[n4] ;
Real_t y5 = y[n5] ;
Real_t y6 = y[n6] ;
Real_t y7 = y[n7] ;
Real_t z0 = z[n0] ;
Real_t z1 = z[n1] ;
Real_t z2 = z[n2] ;
Real_t z3 = z[n3] ;
Real_t z4 = z[n4] ;
Real_t z5 = z[n5] ;
Real_t z6 = z[n6] ;
Real_t z7 = z[n7] ;
Real_t xv0 = xd[n0] ;
Real_t xv1 = xd[n1] ;
Real_t xv2 = xd[n2] ;
Real_t xv3 = xd[n3] ;
Real_t xv4 = xd[n4] ;
Real_t xv5 = xd[n5] ;
Real_t xv6 = xd[n6] ;
Real_t xv7 = xd[n7] ;
Real_t yv0 = yd[n0] ;
Real_t yv1 = yd[n1] ;
Real_t yv2 = yd[n2] ;
Real_t yv3 = yd[n3] ;
Real_t yv4 = yd[n4] ;
Real_t yv5 = yd[n5] ;
Real_t yv6 = yd[n6] ;
Real_t yv7 = yd[n7] ;
Real_t zv0 = zd[n0] ;
Real_t zv1 = zd[n1] ;
Real_t zv2 = zd[n2] ;
Real_t zv3 = zd[n3] ;
Real_t zv4 = zd[n4] ;
Real_t zv5 = zd[n5] ;
Real_t zv6 = zd[n6] ;
Real_t zv7 = zd[n7] ;
Real_t vol = volo[i] * vnew[i] ;
Real_t norm = Real_t(1.0) / ( vol + ptiny ) ;
Real_t dxj = Real_t(-0.25)*((x0+x1+x5+x4) - (x3+x2+x6+x7)) ;
Real_t dyj = Real_t(-0.25)*((y0+y1+y5+y4) - (y3+y2+y6+y7)) ;
Real_t dzj = Real_t(-0.25)*((z0+z1+z5+z4) - (z3+z2+z6+z7)) ;
Real_t dxi = Real_t( 0.25)*((x1+x2+x6+x5) - (x0+x3+x7+x4)) ;
Real_t dyi = Real_t( 0.25)*((y1+y2+y6+y5) - (y0+y3+y7+y4)) ;
Real_t dzi = Real_t( 0.25)*((z1+z2+z6+z5) - (z0+z3+z7+z4)) ;
Real_t dxk = Real_t( 0.25)*((x4+x5+x6+x7) - (x0+x1+x2+x3)) ;
Real_t dyk = Real_t( 0.25)*((y4+y5+y6+y7) - (y0+y1+y2+y3)) ;
Real_t dzk = Real_t( 0.25)*((z4+z5+z6+z7) - (z0+z1+z2+z3)) ;
/* find delvk and delxk ( i cross j ) */
ax = dyi*dzj - dzi*dyj ;
ay = dzi*dxj - dxi*dzj ;
az = dxi*dyj - dyi*dxj ;
delx_zeta[i] = vol / SQRT(ax*ax + ay*ay + az*az + ptiny) ;
ax *= norm ;
ay *= norm ;
az *= norm ;
dxv = Real_t(0.25)*((xv4+xv5+xv6+xv7) - (xv0+xv1+xv2+xv3)) ;
dyv = Real_t(0.25)*((yv4+yv5+yv6+yv7) - (yv0+yv1+yv2+yv3)) ;
dzv = Real_t(0.25)*((zv4+zv5+zv6+zv7) - (zv0+zv1+zv2+zv3)) ;
delv_zeta[i] = ax*dxv + ay*dyv + az*dzv ;
/* find delxi and delvi ( j cross k ) */
ax = dyj*dzk - dzj*dyk ;
ay = dzj*dxk - dxj*dzk ;
az = dxj*dyk - dyj*dxk ;
delx_xi[i] = vol / SQRT(ax*ax + ay*ay + az*az + ptiny) ;
ax *= norm ;
ay *= norm ;
az *= norm ;
dxv = Real_t(0.25)*((xv1+xv2+xv6+xv5) - (xv0+xv3+xv7+xv4)) ;
dyv = Real_t(0.25)*((yv1+yv2+yv6+yv5) - (yv0+yv3+yv7+yv4)) ;
dzv = Real_t(0.25)*((zv1+zv2+zv6+zv5) - (zv0+zv3+zv7+zv4)) ;
delv_xi[i] = ax*dxv + ay*dyv + az*dzv ;
/* find delxj and delvj ( k cross i ) */
ax = dyk*dzi - dzk*dyi ;
ay = dzk*dxi - dxk*dzi ;
az = dxk*dyi - dyk*dxi ;
delx_eta[i] = vol / SQRT(ax*ax + ay*ay + az*az + ptiny) ;
ax *= norm ;
ay *= norm ;
az *= norm ;
dxv = Real_t(-0.25)*((xv0+xv1+xv5+xv4) - (xv3+xv2+xv6+xv7)) ;
dyv = Real_t(-0.25)*((yv0+yv1+yv5+yv4) - (yv3+yv2+yv6+yv7)) ;
dzv = Real_t(-0.25)*((zv0+zv1+zv5+zv4) - (zv3+zv2+zv6+zv7)) ;
delv_eta[i] = ax*dxv + ay*dyv + az*dzv ;
}
}
}
/******************************************/
// 14
static inline
void CalcMonotonicQRegionForElems(Domain &domain, Real_t vnew[], Real_t ptiny)
{
Real_t monoq_limiter_mult = domain.monoq_limiter_mult();
Real_t monoq_max_slope = domain.monoq_max_slope();
Real_t qlc_monoq = domain.qlc_monoq();
Real_t qqc_monoq = domain.qqc_monoq();
Index_t numElem = domain.numElem();
Index_t numNode = domain.numNode();
Index_t numElem8 = Index_t(8) * numElem;
Index_t * __restrict__ nodelist = &domain.m_nodelist[0];
Index_t * __restrict__ elemBC = &domain.m_elemBC[0];
Index_t * __restrict__ lxim = &domain.m_lxim[0];
Index_t * __restrict__ lxip = &domain.m_lxip[0];
Index_t * __restrict__ letam = &domain.m_letam[0];
Index_t * __restrict__ letap = &domain.m_letap[0];
Index_t * __restrict__ lzetam = &domain.m_lzetam[0];
Index_t * __restrict__ lzetap = &domain.m_lzetap[0];
Real_t * __restrict__ volo = &domain.m_volo[0];
Real_t * __restrict__ delv_zeta = &domain.m_delv_zeta[0];
Real_t * __restrict__ delx_zeta = &domain.m_delx_zeta[0];
Real_t * __restrict__ delv_xi = &domain.m_delv_xi[0];
Real_t * __restrict__ delx_xi = &domain.m_delx_xi[0];
Real_t * __restrict__ delv_eta = &domain.m_delv_eta[0];
Real_t * __restrict__ delx_eta = &domain.m_delx_eta[0];
Real_t * __restrict__ elemMass = &domain.m_elemMass[0];
Real_t * __restrict__ ql = &domain.m_ql[0];
Real_t * __restrict__ qq = &domain.m_qq[0];
Real_t * __restrict__ vdov = &domain.m_vdov[0];
// loop over all elements
# pragma omp target data map(to: vdov[:numElem], elemMass[:numElem], volo[:numElem]) \
map(alloc: delx_xi[:numElem], delx_zeta[:numElem], delx_eta[:numElem], delv_xi[:numElem], \
delv_zeta[:numElem], delv_eta[:numElem]) \
map(to: lzetam[:numElem], lzetap[:numElem], \
letam[:numElem], letap[:numElem], lxip[:numElem], lxim[:numElem], \
elemBC[:numElem], qlc_monoq, qqc_monoq, monoq_limiter_mult, monoq_max_slope, ptiny) \
map(tofrom: ql[:numElem], qq[:numElem]) map(alloc:vnew[:numElem]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for ( Index_t ielem = 0 ; ielem < numElem; ++ielem ) {
Index_t i = ielem;
Real_t qlin, qquad ;
Real_t phixi, phieta, phizeta ;
Int_t bcMask = elemBC[i] ;
Real_t delvm = 0.0, delvp =0.0;
/* phixi */
Real_t norm = Real_t(1.) / (delv_xi[i]+ ptiny ) ;
switch (bcMask & XI_M) {
case XI_M_COMM: /* needs comm data */
case 0: delvm = delv_xi[lxim[i]]; break ;
case XI_M_SYMM: delvm = delv_xi[i] ; break ;
case XI_M_FREE: delvm = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvm = 0; /* ERROR - but quiets the compiler */
break;
}
switch (bcMask & XI_P) {
case XI_P_COMM: /* needs comm data */
case 0: delvp = delv_xi[lxip[i]] ; break ;
case XI_P_SYMM: delvp = delv_xi[i] ; break ;
case XI_P_FREE: delvp = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvp = 0; /* ERROR - but quiets the compiler */
break;
}
delvm = delvm * norm ;
delvp = delvp * norm ;
phixi = Real_t(.5) * ( delvm + delvp ) ;
delvm *= monoq_limiter_mult ;
delvp *= monoq_limiter_mult ;
if ( delvm < phixi ) phixi = delvm ;
if ( delvp < phixi ) phixi = delvp ;
if ( phixi < Real_t(0.)) phixi = Real_t(0.) ;
if ( phixi > monoq_max_slope) phixi = monoq_max_slope;
/* phieta */
norm = Real_t(1.) / ( delv_eta[i] + ptiny ) ;
switch (bcMask & ETA_M) {
case ETA_M_COMM: /* needs comm data */
case 0: delvm = delv_eta[letam[i]] ; break ;
case ETA_M_SYMM: delvm = delv_eta[i] ; break ;
case ETA_M_FREE: delvm = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvm = 0; /* ERROR - but quiets the compiler */
break;
}
switch (bcMask & ETA_P) {
case ETA_P_COMM: /* needs comm data */
case 0: delvp = delv_eta[letap[i]] ; break ;
case ETA_P_SYMM: delvp = delv_eta[i] ; break ;
case ETA_P_FREE: delvp = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvp = 0; /* ERROR - but quiets the compiler */
break;
}
delvm = delvm * norm ;
delvp = delvp * norm ;
phieta = Real_t(.5) * ( delvm + delvp ) ;
delvm *= monoq_limiter_mult ;
delvp *= monoq_limiter_mult ;
if ( delvm < phieta ) phieta = delvm ;
if ( delvp < phieta ) phieta = delvp ;
if ( phieta < Real_t(0.)) phieta = Real_t(0.) ;
if ( phieta > monoq_max_slope) phieta = monoq_max_slope;
/* phizeta */
norm = Real_t(1.) / ( delv_zeta[i] + ptiny ) ;
switch (bcMask & ZETA_M) {
case ZETA_M_COMM: /* needs comm data */
case 0: delvm = delv_zeta[lzetam[i]] ; break ;
case ZETA_M_SYMM: delvm = delv_zeta[i] ; break ;
case ZETA_M_FREE: delvm = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvm = 0; /* ERROR - but quiets the compiler */
break;
}
switch (bcMask & ZETA_P) {
case ZETA_P_COMM: /* needs comm data */
case 0: delvp = delv_zeta[lzetap[i]] ; break ;
case ZETA_P_SYMM: delvp = delv_zeta[i] ; break ;
case ZETA_P_FREE: delvp = Real_t(0.0) ; break ;
default: //fprintf(stderr, "Error in switch at %s line %d\n", __FILE__, __LINE__);
delvp = 0; /* ERROR - but quiets the compiler */
break;
}
delvm = delvm * norm ;
delvp = delvp * norm ;
phizeta = Real_t(.5) * ( delvm + delvp ) ;
delvm *= monoq_limiter_mult ;
delvp *= monoq_limiter_mult ;
if ( delvm < phizeta ) phizeta = delvm ;
if ( delvp < phizeta ) phizeta = delvp ;
if ( phizeta < Real_t(0.)) phizeta = Real_t(0.);
if ( phizeta > monoq_max_slope ) phizeta = monoq_max_slope;
/* Remove length scale */
if ( vdov[i] > Real_t(0.) ) {
qlin = Real_t(0.) ;
qquad = Real_t(0.) ;
}
else {
Real_t delvxxi = delv_xi[i] * delx_xi[i] ;
Real_t delvxeta = delv_eta[i] * delx_eta[i] ;
Real_t delvxzeta = delv_zeta[i] * delx_zeta[i] ;
if ( delvxxi > Real_t(0.) ) delvxxi = Real_t(0.) ;
if ( delvxeta > Real_t(0.) ) delvxeta = Real_t(0.) ;
if ( delvxzeta > Real_t(0.) ) delvxzeta = Real_t(0.) ;
Real_t rho = elemMass[i] / (volo[i] * vnew[i]) ;
qlin = -qlc_monoq * rho *
( delvxxi * (Real_t(1.) - phixi) +
delvxeta * (Real_t(1.) - phieta) +
delvxzeta * (Real_t(1.) - phizeta) ) ;
qquad = qqc_monoq * rho *
( delvxxi*delvxxi * (Real_t(1.) - phixi*phixi) +
delvxeta*delvxeta * (Real_t(1.) - phieta*phieta) +
delvxzeta*delvxzeta * (Real_t(1.) - phizeta*phizeta) ) ;
}
qq[i] = qquad ;
ql[i] = qlin ;
}
}
}
/******************************************/
static inline
void CalcMonotonicQForElems(Domain& domain, Real_t vnew[])
{
//
// initialize parameters
//
const Real_t ptiny = Real_t(1.e-36) ;
//
// calculate the monotonic q for all regions
//
CalcMonotonicQRegionForElems(domain, vnew, ptiny) ;
}
/******************************************/
static inline
void CalcQForElems(Domain& domain, Real_t vnew[])
{
//
// MONOTONIC Q option
//
Index_t numElem = domain.numElem() ;
if (numElem != 0) {
Int_t allElem = numElem + /* local elem */
2*domain.sizeX()*domain.sizeY() + /* plane ghosts */
2*domain.sizeX()*domain.sizeZ() + /* row ghosts */
2*domain.sizeY()*domain.sizeZ() ; /* col ghosts */
domain.AllocateGradients(numElem, allElem);
Real_t *delv_xi = &domain.m_delv_xi[0];
Real_t *delx_xi = &domain.m_delx_xi[0];
Real_t *delv_eta = &domain.m_delv_eta[0];
Real_t *delx_eta = &domain.m_delx_eta[0];
Real_t *delv_zeta = &domain.m_delv_zeta[0];
Real_t *delx_zeta = &domain.m_delx_zeta[0];
#pragma omp target enter data map (alloc:delv_xi[0:allElem], delx_xi[0:numElem], \
delv_eta[0:allElem], delx_eta[0:numElem], \
delv_zeta[0:allElem], delx_zeta[0:numElem] ) if (USE_GPU == 1)
#if USE_MPI
CommRecv(domain, MSG_MONOQ, 3,
domain.sizeX(), domain.sizeY(), domain.sizeZ(),
true, true) ;
#endif
/* Calculate velocity gradients */
CalcMonotonicQGradientsForElems(domain, vnew);
#if USE_MPI
Domain_member fieldData[3] ;
/* Transfer veloctiy gradients in the first order elements */
/* problem->commElements->Transfer(CommElements::monoQ) ; */
fieldData[0] = &Domain::delv_xi ;
fieldData[1] = &Domain::delv_eta ;
fieldData[2] = &Domain::delv_zeta ;
CommSend(domain, MSG_MONOQ, 3, fieldData,
domain.sizeX(), domain.sizeY(), domain.sizeZ(),
true, true) ;
CommMonoQ(domain) ;
#endif
CalcMonotonicQForElems(domain, vnew) ;
// Free up memory
#pragma omp target exit data map (delete:delv_xi[0:allElem], delx_xi[0:numElem], \
delv_eta[0:allElem], delx_eta[0:numElem], \
delv_zeta[0:allElem], delx_zeta[0:numElem] ) if (USE_GPU == 1)
domain.DeallocateGradients();
/* Don't allow excessive artificial viscosity */
Index_t idx = -1;
for (Index_t i=0; i<numElem; ++i) {
if ( domain.q(i) > domain.qstop() ) {
idx = i ;
break ;
}
}
if(idx >= 0) {
#if USE_MPI
MPI_Abort(MPI_COMM_WORLD, QStopError) ;
#else
exit(QStopError);
#endif
}
}
}
/******************************************/
/* Some functions were deleted because now they have manualy been inlined. */
/******************************************/
static inline
void UpdateVolumesForElems(Domain &domain, Real_t *vnew,
Real_t v_cut, Index_t length)
{
if (length != 0) {
Index_t numElem = domain.numElem() ;
Real_t *v = &domain.m_v[0];
# pragma omp target data map(to: vnew[:numElem], length, v_cut) \
map(tofrom: v[:numElem]) if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for(Index_t i=0 ; i<length ; ++i) {
Real_t tmpV = vnew[i] ;
if ( FABS(tmpV - Real_t(1.0)) < v_cut )
tmpV = Real_t(1.0) ;
v[i] = tmpV ;
}
}
}
return ;
}
/******************************************/
// 13
static inline
void EvalEOSForElems(Domain& domain, Real_t *vnewc)
{
Index_t numElem = domain.numElem();
Index_t numNode = domain.numNode();
Index_t numElem8 = Index_t(8) * numElem;
Index_t numElemReg = numElem;
Real_t e_cut = domain.e_cut() ;
Real_t p_cut = domain.p_cut() ;
Real_t ss4o3 = domain.ss4o3() ;
Real_t q_cut = domain.q_cut() ;
Real_t v_cut = domain.v_cut() ;
Real_t eosvmax = domain.eosvmax() ;
Real_t eosvmin = domain.eosvmin() ;
Real_t pmin = domain.pmin() ;
Real_t emin = domain.emin() ;
Real_t rho0 = domain.refdens() ;
Real_t *e = &domain.m_e[0];
Real_t *delv = &domain.m_delv[0];
Real_t *p = &domain.m_p[0];
Real_t *q = &domain.m_q[0];
Real_t *qq = &domain.m_qq[0];
Real_t *ql = &domain.m_ql[0];
Real_t *ss = &domain.m_ss[0];
Index_t *elemRep = &domain.m_elemRep[0];
Index_t *elemElem = &domain.m_elemElem[0];
Real_t *v = &domain.m_v[0];
# pragma omp target data map(to: ql[:numElem], qq[:numElem], delv[:numElem], elemRep[:numElem], elemElem[:numElem], \
e_cut, p_cut, ss4o3, q_cut, eosvmin, eosvmax, pmin, emin, rho0, v_cut) \
map(tofrom: q[:numElem], p[:numElem], e[:numElem], ss[:numElem], v[:numElem]) map(alloc:vnewc[:numElem]) \
if (USE_GPU == 1)
{
# pragma omp target teams num_teams(TEAMS) thread_limit(THREADS) if (USE_GPU == 1)
# pragma omp distribute parallel for
for (Index_t i=0; i<numElem; ++i) {
Index_t elem = i;
Index_t rep = elemRep[elem];
Real_t e_old, delvc, p_old, q_old, qq_old, ql_old;
Real_t p_new, q_new, e_new;
Real_t work, compression, compHalfStep, bvc, pbvc, pHalfStep;
Real_t vchalf ;
const Real_t c1s = Real_t(2.0) / Real_t(3.0) ;
Real_t vhalf ;
Real_t ssc ;
const Real_t sixth = Real_t(1.0) / Real_t(6.0) ;
Real_t q_tilde ;
Real_t ssTmp ;
if (eosvmin != Real_t(0.)) {
if (vnewc[elem] < eosvmin)
vnewc[elem] = eosvmin ;
}
if (eosvmax != Real_t(0.)) {
if (vnewc[elem] > eosvmax)
vnewc[elem] = eosvmax ;
}
// This check may not make perfect sense in LULESH, but
// it's representative of something in the full code -
// just leave it in, please
Real_t vc = v[i] ;
if (eosvmin != Real_t(0.)) {
if (vc < eosvmin)
vc = eosvmin ;
}
if (eosvmax != Real_t(0.)) {
if (vc > eosvmax)
vc = eosvmax ;
}
// if (vc > 0.) {
// exit(VolumeError);
// i = numElem;
Real_t vnewc_t = vnewc[elem];
Real_t e_temp = e[elem];
Real_t delv_temp = delv[elem];
Real_t p_temp = p[elem];
Real_t q_temp = q[elem];
Real_t qq_temp = qq[elem];
Real_t ql_temp = ql[elem];
for(Index_t j = 0; j < rep; j++) {
e_old = e_temp ;
delvc = delv_temp ;
p_old = p_temp ;
q_old = q_temp ;
qq_old = qq_temp ;
ql_old = ql_temp ;
compression = Real_t(1.) / vnewc_t - Real_t(1.);
vchalf = vnewc_t - delvc * Real_t(.5);
compHalfStep = Real_t(1.) / vchalf - Real_t(1.);
if (vnewc_t <= eosvmin) { /* impossible due to calling func? */
compHalfStep = compression ;
}
if (vnewc_t >= eosvmax) { /* impossible due to calling func? */
p_old = Real_t(0.) ;
compression = Real_t(0.) ;
compHalfStep = Real_t(0.) ;
}
work = Real_t(0.) ;
e_new = e_old - Real_t(0.5) * delvc * (p_old + q_old)
+ Real_t(0.5) * work;
if (e_new < emin ) {
e_new = emin ;
}
bvc = c1s * (compHalfStep + Real_t(1.));
pbvc = c1s;
pHalfStep = bvc * e_new ;
if (FABS(pHalfStep) < p_cut )
pHalfStep = Real_t(0.0) ;
if ( vnewc_t >= eosvmax ) /* impossible condition here? */
pHalfStep = Real_t(0.0) ;
if (pHalfStep < pmin)
pHalfStep = pmin ;
vhalf = Real_t(1.) / (Real_t(1.) + compHalfStep) ;
if ( delvc > Real_t(0.) ) {
q_new /* = qq_old[i] = ql_old[i] */ = Real_t(0.) ;
} else {
ssc = ( pbvc * e_new + vhalf * vhalf * bvc * pHalfStep ) / rho0 ;
if ( ssc <= Real_t(.1111111e-36) ) {
ssc = Real_t(.3333333e-18) ;
} else {
ssc = SQRT(ssc) ;
}
q_new = (ssc*ql_old + qq_old) ;
}
e_new = e_new + Real_t(0.5) * delvc
* (Real_t(3.0)*(p_old + q_old)
- Real_t(4.0)*(pHalfStep + q_new)) ;
e_new += Real_t(0.5) * work;
if (FABS(e_new) < e_cut) {
e_new = Real_t(0.) ;
}
if ( e_new < emin ) {
e_new = emin ;
}
bvc = c1s * (compression + Real_t(1.));
pbvc = c1s;
p_new = bvc * e_new ;
if (FABS(p_new) < p_cut )
p_new = Real_t(0.0) ;
if ( vnewc_t >= eosvmax ) /* impossible condition here? */
p_new = Real_t(0.0) ;
if (p_new < pmin)
p_new = pmin ;
if (delvc > Real_t(0.)) {
q_tilde = Real_t(0.) ;
}
else {
Real_t ssc = ( pbvc * e_new + vnewc_t * vnewc_t * bvc * p_new ) / rho0 ;
if ( ssc <= Real_t(.1111111e-36) ) {
ssc = Real_t(.3333333e-18) ;
} else {
ssc = SQRT(ssc) ;
}
q_tilde = (ssc * ql_old + qq_old) ;
}
e_new = e_new - ( Real_t(7.0)*(p_old + q_old)
- Real_t(8.0)*(pHalfStep + q_new)
+ (p_new + q_tilde)) * delvc*sixth ;
if (FABS(e_new) < e_cut) {
e_new = Real_t(0.) ;
}
if (e_new < emin) {
e_new = emin ;
}
bvc = c1s * (compression + Real_t(1.));
pbvc = c1s;
p_new = bvc * e_new ;
if ( FABS(p_new) < p_cut )
p_new = Real_t(0.0) ;
if ( vnewc_t >= eosvmax ) /* impossible condition here? */
p_new = Real_t(0.0) ;
if (p_new < pmin)
p_new = pmin ;
if ( delvc <= Real_t(0.) ) {
ssc = ( pbvc * e_new + vnewc_t * vnewc_t * bvc * p_new ) / rho0 ;
if ( ssc <= Real_t(.1111111e-36) ) {
ssc = Real_t(.3333333e-18) ;
} else {
ssc = SQRT(ssc) ;
}
q_new = (ssc*ql_old + qq_old) ;
if (FABS(q_new) < q_cut) q_new = Real_t(0.) ;
}
} //this is the end of the rep loop
p[elem] = p_new ;
e[elem] = e_new ;
q[elem] = q_new ;
ssTmp = (pbvc * e_new + vnewc_t * vnewc_t * bvc * p_new) / rho0;
if (ssTmp <= Real_t(.1111111e-36)) {
ssTmp = Real_t(.3333333e-18);
} else {
ssTmp = SQRT(ssTmp);
}
ss[elem] = ssTmp ;
if ( FABS(vnewc_t - Real_t(1.0)) < v_cut )
vnewc_t = Real_t(1.0) ;
v[i] = vnewc_t ;
// }// this is from vc > 0.
} // this is the NEW end of the distribute parallel for
} // this is the end of the target data block
}
/******************************************/
static inline
void ApplyMaterialPropertiesForElems(Domain& domain, Real_t vnew[])
{
Index_t numElem = domain.numElem() ;
if (numElem > 0) {
EvalEOSForElems(domain, vnew);
}
}
/******************************************/
static inline
void LagrangeElements(Domain& domain, Index_t numElem)
{
Real_t *vnew = Allocate<Real_t>(numElem) ; /* new relative vol -- temp */
#pragma omp target enter data map (alloc:vnew[0:numElem]) if (USE_GPU == 1)
CalcLagrangeElements(domain, vnew) ;
/* Calculate Q. (Monotonic q option requires communication) */
CalcQForElems(domain, vnew) ;
ApplyMaterialPropertiesForElems(domain, vnew) ;
#pragma omp target exit data map (delete:vnew[0:numElem]) if (USE_GPU == 1)
Release(&vnew);
}
/******************************************/
static inline
void CalcCourantConstraintForElems(Domain &domain, Index_t length,
Index_t *regElemlist,
Real_t qqc, Real_t& dtcourant)
{
#if _OPENMP
Index_t threads = omp_get_max_threads();
static Index_t *courant_elem_per_thread;
static Real_t *dtcourant_per_thread;
static bool first = true;
if (first) {
courant_elem_per_thread = new Index_t[threads];
dtcourant_per_thread = new Real_t[threads];
first = false;
}
#else
Index_t threads = 1;
Index_t courant_elem_per_thread[1];
Real_t dtcourant_per_thread[1];
#endif
#pragma omp parallel firstprivate(length, qqc)
{
Real_t qqc2 = Real_t(64.0) * qqc * qqc ;
Real_t dtcourant_tmp = dtcourant;
Index_t courant_elem = -1 ;
#if _OPENMP
Index_t thread_num = omp_get_thread_num();
#else
Index_t thread_num = 0;
#endif
#pragma omp for
for (Index_t i = 0 ; i < length ; ++i) {
Index_t indx = regElemlist[i] ;
Real_t dtf = domain.ss(indx) * domain.ss(indx) ;
if ( domain.vdov(indx) < Real_t(0.) ) {
dtf = dtf
+ qqc2 * domain.arealg(indx) * domain.arealg(indx)
* domain.vdov(indx) * domain.vdov(indx) ;
}
dtf = SQRT(dtf) ;
dtf = domain.arealg(indx) / dtf ;
if (domain.vdov(indx) != Real_t(0.)) {
if ( dtf < dtcourant_tmp ) {
dtcourant_tmp = dtf ;
courant_elem = indx ;
}
}
}
dtcourant_per_thread[thread_num] = dtcourant_tmp ;
courant_elem_per_thread[thread_num] = courant_elem ;
}
for (Index_t i = 1; i < threads; ++i) {
if (dtcourant_per_thread[i] < dtcourant_per_thread[0] ) {
dtcourant_per_thread[0] = dtcourant_per_thread[i];
courant_elem_per_thread[0] = courant_elem_per_thread[i];
}
}
if (courant_elem_per_thread[0] != -1) {
dtcourant = dtcourant_per_thread[0] ;
}
return ;
}
/******************************************/
static inline
void CalcHydroConstraintForElems(Domain &domain, Index_t length,
Index_t *regElemlist, Real_t dvovmax, Real_t& dthydro)
{
#if _OPENMP
Index_t threads = omp_get_max_threads();
static Index_t *hydro_elem_per_thread;
static Real_t *dthydro_per_thread;
static bool first = true;
if (first) {
hydro_elem_per_thread = new Index_t[threads];
dthydro_per_thread = new Real_t[threads];
first = false;
}
#else
Index_t threads = 1;
Index_t hydro_elem_per_thread[1];
Real_t dthydro_per_thread[1];
#endif
#pragma omp parallel firstprivate(length, dvovmax)
{
Real_t dthydro_tmp = dthydro ;
Index_t hydro_elem = -1 ;
#if _OPENMP
Index_t thread_num = omp_get_thread_num();
#else
Index_t thread_num = 0;
#endif
#pragma omp for
for (Index_t i = 0 ; i < length ; ++i) {
Index_t indx = regElemlist[i] ;
if (domain.vdov(indx) != Real_t(0.)) {
Real_t dtdvov = dvovmax / (FABS(domain.vdov(indx))+Real_t(1.e-20)) ;
if ( dthydro_tmp > dtdvov ) {
dthydro_tmp = dtdvov ;
hydro_elem = indx ;
}
}
}
dthydro_per_thread[thread_num] = dthydro_tmp ;
hydro_elem_per_thread[thread_num] = hydro_elem ;
}
for (Index_t i = 1; i < threads; ++i) {
if(dthydro_per_thread[i] < dthydro_per_thread[0]) {
dthydro_per_thread[0] = dthydro_per_thread[i];
hydro_elem_per_thread[0] = hydro_elem_per_thread[i];
}
}
if (hydro_elem_per_thread[0] != -1) {
dthydro = dthydro_per_thread[0] ;
}
return ;
}
/******************************************/
static inline
void CalcTimeConstraintsForElems(Domain& domain) {
// Initialize conditions to a very large value
domain.dtcourant() = 1.0e+20;
domain.dthydro() = 1.0e+20;
for (Index_t r=0 ; r < domain.numReg() ; ++r) {
/* evaluate time constraint */
CalcCourantConstraintForElems(domain, domain.regElemSize(r),
domain.regElemlist(r),
domain.qqc(),
domain.dtcourant()) ;
/* check hydro constraint */
CalcHydroConstraintForElems(domain, domain.regElemSize(r),
domain.regElemlist(r),
domain.dvovmax(),
domain.dthydro()) ;
}
}
/******************************************/
static inline
void LagrangeLeapFrog(Domain& domain)
{
#ifdef SEDOV_SYNC_POS_VEL_LATE
Domain_member fieldData[6];
#endif
/* calculate nodal forces, accelerations, velocities, positions, with
* applied boundary conditions and slide surface considerations */
LagrangeNodal(domain);
#ifdef SEDOV_SYNC_POS_VEL_LATE
#endif
/* calculate element quantities (i.e. velocity gradient & q), and update
* material states */
LagrangeElements(domain, domain.numElem());
#if USE_MPI
#ifdef SEDOV_SYNC_POS_VEL_LATE
CommRecv(domain, MSG_SYNC_POS_VEL, 6,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
false, false) ;
fieldData[0] = &Domain::x ;
fieldData[1] = &Domain::y ;
fieldData[2] = &Domain::z ;
fieldData[3] = &Domain::xd ;
fieldData[4] = &Domain::yd ;
fieldData[5] = &Domain::zd ;
CommSend(domain, MSG_SYNC_POS_VEL, 6, fieldData,
domain.sizeX() + 1, domain.sizeY() + 1, domain.sizeZ() + 1,
false, false) ;
#endif
#endif
CalcTimeConstraintsForElems(domain);
#if USE_MPI
#ifdef SEDOV_SYNC_POS_VEL_LATE
CommSyncPosVel(domain) ;
#endif
#endif
}
/******************************************/
int main(int argc, char *argv[])
{
Domain *locDom ;
Int_t numRanks ;
Int_t myRank ;
struct cmdLineOpts opts;
#if USE_MPI
Domain_member fieldData ;
MPI_Init(&argc, &argv) ;
MPI_Comm_size(MPI_COMM_WORLD, &numRanks) ;
MPI_Comm_rank(MPI_COMM_WORLD, &myRank) ;
#else
numRanks = 1;
myRank = 0;
#endif
/* Set defaults that can be overridden by command line opts */
opts.its = 9999999;
opts.nx = 30;
opts.numReg = 11;
opts.numFiles = (int)(numRanks+10)/9;
opts.showProg = 1;
opts.quiet = 0;
opts.viz = 0;
opts.balance = 1;
opts.cost = 1;
opts.iteration_cap = 0;
ParseCommandLineOptions(argc, argv, myRank, &opts);
if ((myRank == 0) && (opts.quiet == 0)) {
printf("Running problem size %d^3 per domain until completion\n", opts.nx);
printf("Num processors: %d\n", numRanks);
#if _OPENMP
printf("Num threads: %d\n", omp_get_max_threads());
#endif
printf("Total number of elements: %lld\n\n", (long long int)(numRanks*opts.nx*opts.nx*opts.nx));
printf("To run other sizes, use -s <integer>.\n");
printf("To run a fixed number of iterations, use -i <integer>.\n");
printf("To run a more or less balanced region set, use -b <integer>.\n");
printf("To change the relative costs of regions, use -c <integer>.\n");
printf("To print out progress, use -p\n");
printf("To write an output file for VisIt, use -v\n");
printf("To only execute the first iteration, use -z (used when profiling: nvprof --metrics all)\n");
printf("See help (-h) for more options\n\n");
}
// Set up the mesh and decompose. Assumes regular cubes for now
Int_t col, row, plane, side;
InitMeshDecomp(numRanks, myRank, &col, &row, &plane, &side);
// Build the main data structure and initialize it
locDom = new Domain(numRanks, col, row, plane, opts.nx,
side, opts.numReg, opts.balance, opts.cost) ;
#if USE_MPI
fieldData = &Domain::nodalMass ;
// Initial domain boundary communication
CommRecv(*locDom, MSG_COMM_SBN, 1,
locDom->sizeX() + 1, locDom->sizeY() + 1, locDom->sizeZ() + 1,
true, false) ;
CommSend(*locDom, MSG_COMM_SBN, 1, &fieldData,
locDom->sizeX() + 1, locDom->sizeY() + 1, locDom->sizeZ() + 1,
true, false) ;
CommSBN(*locDom, 1, &fieldData) ;
// End initialization
MPI_Barrier(MPI_COMM_WORLD);
#endif
// BEGIN timestep to solution */
#if USE_MPI
double start = MPI_Wtime();
#else
timeval start;
gettimeofday(&start, NULL) ;
#endif
// Compute elem to reglist correspondence
Index_t k = 0;
for (Int_t r=0 ; r<locDom->numReg() ; r++) {
Index_t numElemReg = locDom->regElemSize(r);
Index_t *regElemList = locDom->regElemlist(r);
Index_t rep;
//Determine load imbalance for this region
//round down the number with lowest cost
if(r < locDom->numReg()/2)
rep = 1;
//you don't get an expensive region unless you at least have 5 regions
else if(r < (locDom->numReg() - (locDom->numReg()+15)/20))
rep = 1 + locDom->cost();
//very expensive regions
else
rep = 10 * (1+ locDom->cost());
// std::cout << "Elems: " << numElemReg << " Reps: " << rep << "\n";
for (Index_t e=0 ; e<numElemReg ; e++){
locDom->m_elemRep[regElemList[e]] = rep;
locDom->m_elemElem[k] = regElemList[e];
k++;
}
}
//export persistent data to GPU
Index_t numNode = locDom->numNode();
Index_t numElem = locDom->numElem() ;
Index_t numElem8 = numElem * 8;
Real_t *x = &locDom->m_x[0];
Real_t *y = &locDom->m_y[0];
Real_t *z = &locDom->m_z[0];
Real_t *fx = &locDom->m_fx[0];
Real_t *fy = &locDom->m_fy[0];
Real_t *fz = &locDom->m_fz[0];
Real_t *xd = &locDom->m_xd[0];
Real_t *yd = &locDom->m_yd[0];
Real_t *zd = &locDom->m_zd[0];
Real_t *xdd = &locDom->m_xdd[0];
Real_t *ydd = &locDom->m_ydd[0];
Real_t *zdd = &locDom->m_zdd[0];
Index_t *nodelist = &locDom->m_nodelist[0];
#pragma omp target enter data map(to:x[0:numNode],y[0:numNode],z[0:numNode], \
fx[0:numNode],fy[0:numNode],fz[0:numNode], \
xd[0:numNode],yd[0:numNode],zd[0:numNode], \
xdd[0:numNode],ydd[0:numNode],zdd[0:numNode], \
nodelist[:numElem8]) \
if (USE_GPU == 1)
while((locDom->time() < locDom->stoptime()) && (locDom->cycle() < opts.its)) {
TimeIncrement(*locDom) ;
LagrangeLeapFrog(*locDom) ;
if ((opts.showProg != 0) && (opts.quiet == 0) && (myRank == 0)) {
printf("cycle = %d, time = %e, dt=%e\n",
locDom->cycle(), double(locDom->time()), double(locDom->deltatime()) ) ;
}
if (opts.iteration_cap == 1){
break;
}
opts.iteration_cap -= 1;
}
#pragma omp target exit data map(from:x[0:numNode],y[0:numNode],z[0:numNode], \
fx[0:numNode],fy[0:numNode],fz[0:numNode], \
xd[0:numNode],yd[0:numNode],zd[0:numNode], \
xdd[0:numNode],ydd[0:numNode],zdd[0:numNode]) \
map(delete:nodelist[:numElem8]) if (USE_GPU == 1)
// Use reduced max elapsed time
double elapsed_time;
#if USE_MPI
elapsed_time = MPI_Wtime() - start;
#else
timeval end;
gettimeofday(&end, NULL) ;
elapsed_time = (double)(end.tv_sec - start.tv_sec) + ((double)(end.tv_usec - start.tv_usec))/1000000 ;
#endif
double elapsed_timeG;
#if USE_MPI
MPI_Reduce(&elapsed_time, &elapsed_timeG, 1, MPI_DOUBLE,
MPI_MAX, 0, MPI_COMM_WORLD);
#else
elapsed_timeG = elapsed_time;
#endif
// Write out final viz file */
if (opts.viz) {
DumpToVisit(*locDom, opts.numFiles, myRank, numRanks) ;
}
if ((myRank == 0) && (opts.quiet == 0)) {
VerifyAndWriteFinalOutput(elapsed_timeG, *locDom, opts.nx, numRanks);
}
#if USE_MPI
MPI_Finalize() ;
#endif
return 0 ;
}
| 33.323867 | 134 | 0.522701 | illuhad |
bc2efaaec69fe78cba8e47f7a322b20769a42df5 | 1,659 | cpp | C++ | leetcode/leetcode101.cpp | KevinYang515/C-Projects | 1bf95a09a0ffc18102f12263c9163619ce6dba55 | [
"MIT"
] | null | null | null | leetcode/leetcode101.cpp | KevinYang515/C-Projects | 1bf95a09a0ffc18102f12263c9163619ce6dba55 | [
"MIT"
] | null | null | null | leetcode/leetcode101.cpp | KevinYang515/C-Projects | 1bf95a09a0ffc18102f12263c9163619ce6dba55 | [
"MIT"
] | null | null | null | #include "TreeNode.h"
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
bool isSymmetric_r(TreeNode* root);
bool helper_r(TreeNode* left, TreeNode* right);
bool isSymmetric_i(TreeNode* root);
int main(){
vector<TreeNode*> root_v = {new TreeNode(1, new TreeNode(2, new TreeNode(3), new TreeNode(4)), new TreeNode(2, new TreeNode(4), new TreeNode(3))),
new TreeNode(1, new TreeNode(2, NULL, new TreeNode(3)), new TreeNode(2, NULL, new TreeNode(3)))};
for (TreeNode* root : root_v){
printf("%s, ", isSymmetric_r(root)?"true":"false");
}
return 0;
}
// Recursive
// Time Complexity: O(n)
// Space Complexity: O(n)
bool isSymmetric_r(TreeNode* root) {
return helper_r(root, root);
}
bool helper_r(TreeNode* left, TreeNode* right){
if (left == NULL && right == NULL) return true;
if (left == NULL || right == NULL) return false;
return (left->val == right->val) &&
helper_r(left->left, right->right) &&
helper_r(left->right, right->left);
}
// Iterative
// Time Complexity: O(n)
// Space Complexity: O(n)
bool isSymmetric_i(TreeNode* root) {
queue<TreeNode*> q;
q.push(root);
q.push(root);
while (!q.empty()){
TreeNode* left = q.front();
q.pop();
TreeNode* right = q.front();
q.pop();
if (left == NULL && right == NULL) continue;
if (left == NULL || right == NULL) return false;
if (left->val != right->val) return false;
q.push(left->right);
q.push(right->left);
q.push(left->left);
q.push(right->right);
}
return true;
}
| 27.65 | 151 | 0.590717 | KevinYang515 |
bc2fec11cba95a1405674cf6de30b8a67e523a78 | 267 | hpp | C++ | Algorithm_C/Algorithm_C/First/TwoNumbersWithSum/TwoNumbersWithSum.hpp | chm994483868/HMDailyLearningRecord | 95ff0a5347927ce4527bcdd70374e5be22bfc60d | [
"MIT"
] | 2 | 2021-06-26T08:07:04.000Z | 2021-08-03T06:05:40.000Z | Algorithm_C/Algorithm_C/First/TwoNumbersWithSum/TwoNumbersWithSum.hpp | chm994483868/HMDailyLearningRecord | 95ff0a5347927ce4527bcdd70374e5be22bfc60d | [
"MIT"
] | null | null | null | Algorithm_C/Algorithm_C/First/TwoNumbersWithSum/TwoNumbersWithSum.hpp | chm994483868/HMDailyLearningRecord | 95ff0a5347927ce4527bcdd70374e5be22bfc60d | [
"MIT"
] | null | null | null | //
// TwoNumbersWithSum.hpp
// Algorithm_C
//
// Created by HM C on 2020/7/25.
// Copyright © 2020 CHM. All rights reserved.
//
#ifndef TwoNumbersWithSum_hpp
#define TwoNumbersWithSum_hpp
#include <stdio.h>
#include <cstdio>
#endif /* TwoNumbersWithSum_hpp */
| 16.6875 | 46 | 0.715356 | chm994483868 |
bc3179909b54464c1c9f35348232bd976393a55f | 1,711 | cpp | C++ | src/lib/file.cpp | bunsanorg/bacs_system | 22149ecfaac913b820dbda52933bf8ea9fecd723 | [
"Apache-2.0"
] | null | null | null | src/lib/file.cpp | bunsanorg/bacs_system | 22149ecfaac913b820dbda52933bf8ea9fecd723 | [
"Apache-2.0"
] | null | null | null | src/lib/file.cpp | bunsanorg/bacs_system | 22149ecfaac913b820dbda52933bf8ea9fecd723 | [
"Apache-2.0"
] | null | null | null | #include <bacs/system/file.hpp>
#include <bunsan/filesystem/fstream.hpp>
namespace bacs {
namespace system {
namespace file {
std::string read(const boost::filesystem::path &path,
const bacs::file::Range &range) {
std::string data;
bunsan::filesystem::ifstream fin(path, std::ios::binary);
BUNSAN_FILESYSTEM_FSTREAM_WRAP_BEGIN(fin) {
switch (range.whence()) {
case bacs::file::Range::BEGIN:
fin.seekg(range.offset(), std::ios::beg);
break;
case bacs::file::Range::END:
fin.seekg(range.offset(), std::ios::end);
break;
}
char buf[4096];
while (fin && data.size() < range.size()) {
fin.read(buf,
std::min(static_cast<std::size_t>(sizeof(buf)),
static_cast<std::size_t>(range.size() - data.size())));
data.insert(data.end(), buf, buf + fin.gcount());
}
} BUNSAN_FILESYSTEM_FSTREAM_WRAP_END(fin)
fin.close();
return data;
}
static std::string read(const boost::filesystem::path &path,
const bacs::file::Range::Whence whence,
const std::int64_t offset, const std::uint64_t size) {
bacs::file::Range range;
range.set_whence(whence);
range.set_offset(offset);
range.set_size(size);
return read(path, range);
}
std::string read_first(const boost::filesystem::path &path,
const std::uint64_t size) {
return read(path, bacs::file::Range::BEGIN, 0, size);
}
std::string read_last(const boost::filesystem::path &path,
const std::uint64_t size) {
return read(path, bacs::file::Range::END, 0, size);
}
} // namespace file
} // namespace system
} // namespace bacs
| 30.017544 | 79 | 0.611923 | bunsanorg |
bc336cc94eac64bb0476caa4d364444886e37ec1 | 2,140 | cpp | C++ | src/MapGenerator/randomMine.cpp | KujouRinka/minesweeper | c75fdbb874283c5440d534102fed6f894070a873 | [
"MIT"
] | 3 | 2021-04-24T02:45:36.000Z | 2021-05-31T16:05:17.000Z | src/MapGenerator/randomMine.cpp | KujouRinka/minesweeper | c75fdbb874283c5440d534102fed6f894070a873 | [
"MIT"
] | null | null | null | src/MapGenerator/randomMine.cpp | KujouRinka/minesweeper | c75fdbb874283c5440d534102fed6f894070a873 | [
"MIT"
] | null | null | null | //
// Created by KujouRinka on 2021/4/5.
//
#include <random>
#include <ctime>
#include "MapGenerator.h"
/**
* Use random library to generate some mines.
* Write a totally initialize map to Controller::minefield
*
* @param emptyField
* A pointer of MField which just initialize map size.
* */
void MapGenerator::generateMine(MinefieldPtr emptyField) {
std::default_random_engine generator(static_cast<uint_fast32_t>(time(nullptr)));
std::uniform_int_distribution<uint16_t> forRow(0, emptyField->GetRow() - 1);
std::uniform_int_distribution<uint16_t> forLine(0, emptyField->GetLine() - 1);
uint16_t mines = emptyField->GetMines();
uint16_t generated = 0;
MapGenerator::MField::Map *map = emptyField->GetMap();
while (generated < mines) {
uint16_t row = forRow(generator);
uint16_t line = forLine(generator);
if ((*map)[row][line] != 0)
continue;
(*map)[row][line] = 99;
generated++;
}
for (int i = 0; i < emptyField->GetRow(); ++i) {
for (int j = 0; j < emptyField->GetLine(); ++j) {
if ((*map)[i][j] != 99)
(*map)[i][j] = typeAround(i, j, emptyField, BLOCKTYPE::MINE);
}
}
}
/**
* This function is used to calculate specific block around a block.
*/
uint8_t MapGenerator::typeAround(const uint16_t &row, const uint16_t &line,
MinefieldPtr emptyField, BLOCKTYPE blockType) {
MField::Map *map = emptyField->GetMap();
int blocks = 0;
for (int i = row - 1; i <= row + 1; ++i)
for (int j = line - 1; j <= line + 1; ++j) {
if (i >= 0 && j >= 0 && i < emptyField->GetRow() && j < emptyField->GetLine()) {
if (!(i == row && j == line) && (*map)[i][j] == blockType) {
++blocks;
}
}
}
return blocks;
}
void MapGenerator::pictureMap(MinefieldPtr minedField) {
/* calculate quantity of mines around a block */
}
MapGenerator::MinefieldPtr
MapGenerator::coveredMap(MinefieldPtr minefield) {
/* generate map that is shown to user */
return nullptr;
} | 31.940299 | 92 | 0.589252 | KujouRinka |
bc40e87e6b3b8780161cd36ad72967eb7340391d | 318 | cpp | C++ | src/color.cpp | rubot813/wsp_solver | a2918ad2eb37c083d1af405f298bc014303c62aa | [
"Apache-2.0"
] | null | null | null | src/color.cpp | rubot813/wsp_solver | a2918ad2eb37c083d1af405f298bc014303c62aa | [
"Apache-2.0"
] | null | null | null | src/color.cpp | rubot813/wsp_solver | a2918ad2eb37c083d1af405f298bc014303c62aa | [
"Apache-2.0"
] | 1 | 2021-01-04T20:19:47.000Z | 2021-01-04T20:19:47.000Z | #include "color.h"
std::string color_to_string( color_e c ) {
std::string str;
switch ( c ) {
case empty:
str = "empty";
break;
case red:
str = "red";
break;
case green:
str = "green";
break;
case blue:
str = "blue";
break;
default:
str = "unknown. add to color_to_string";
}
return str;
}
| 13.826087 | 42 | 0.603774 | rubot813 |
bc4327620163a0bcda1c9ed1d07c09220c0fdc3c | 127 | hpp | C++ | shared/shared.hpp | Binary-Song/MetaParser | fb59cecfd11aef81d1afad1261a6c58c8ef11d6b | [
"MIT"
] | null | null | null | shared/shared.hpp | Binary-Song/MetaParser | fb59cecfd11aef81d1afad1261a6c58c8ef11d6b | [
"MIT"
] | null | null | null | shared/shared.hpp | Binary-Song/MetaParser | fb59cecfd11aef81d1afad1261a6c58c8ef11d6b | [
"MIT"
] | null | null | null | #ifndef _SHARED_H_
#define _SHARED_H_
#include "rules.hpp"
#include "utils.hpp"
#include "local_path.hpp"
#endif // _SHARED_H_ | 18.142857 | 25 | 0.76378 | Binary-Song |
a4b946cafcc06834e5d16d00cb773748aa7e5198 | 494 | cpp | C++ | Bit Manipulation/AllRepeatingExcept2.cpp | Ankitlenka26/IP2021 | 99322c9c84a8a9c9178a505afbffdcebd312b059 | [
"MIT"
] | null | null | null | Bit Manipulation/AllRepeatingExcept2.cpp | Ankitlenka26/IP2021 | 99322c9c84a8a9c9178a505afbffdcebd312b059 | [
"MIT"
] | null | null | null | Bit Manipulation/AllRepeatingExcept2.cpp | Ankitlenka26/IP2021 | 99322c9c84a8a9c9178a505afbffdcebd312b059 | [
"MIT"
] | null | null | null | #include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
int n ;
cin >> n ;
int *arr = new int[n];
int xxory = 0;
for(int i=0 ;i<n ;i++){
cin >> arr[i];
xxory ^= arr[i];
}
int rmsb = xxory & (-xxory);
int x =0 , y=0 ;
for(int i=0 ;i<n ;i++){
if((arr[i] & rmsb) == 0){
x ^= arr[i];
}else{
y ^= arr[i];
}
}
if(x < y){
cout << x << endl;
cout << y << endl;
}else{
cout << y << endl ;
cout << x << endl ;
}
return 0;
} | 14.529412 | 30 | 0.47166 | Ankitlenka26 |
a4c3b43bdd7f9e3a1ce9eff51400362eb8ad8ca4 | 624 | cxx | C++ | attic/src/tests/compose_test.cxx | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | null | null | null | attic/src/tests/compose_test.cxx | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | 8 | 2017-09-28T14:39:37.000Z | 2021-03-09T22:55:55.000Z | attic/src/tests/compose_test.cxx | yamasdais/asaki-yumemishi | d6220e489da613a634e6ce474a869f5d2932f89d | [
"BSL-1.0"
] | null | null | null | #include <utility>
#include <type_traits>
#include <gtest/gtest.h>
#include <fmp/primitive.hpp>
#include <fmp/values.hpp>
#include <fmp_test.hpp>
using namespace fmp;
using cr0 = curry<noarg>;
using cr1 = curry<id>;
using cr2 = curry<std::add_const>;
using ComposeTypeTarget = ::testing::Types<
p<true_type, apply_t<compose<cr1, cr1>, true_type>>,
p<true_type, apply_t<compose<cr1, cr1, cr1>, true_type>>,
p<true_type, apply_t<compose<cr1, cr1, cr1, cr1>, true_type>>,
p<const int, apply_t<compose<cr1, cr2>, int>>
>;
INSTANTIATE_TYPED_TEST_CASE_P(ComposeType, TypeTest, ComposeTypeTarget);
// ComposeType
| 23.111111 | 72 | 0.724359 | yamasdais |
a4c66ffbdfb868b312f1fa8cfaea023e1e8d26d4 | 115 | hpp | C++ | Include/FishEngine/Internal/LogType.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | 240 | 2017-02-17T10:08:19.000Z | 2022-03-25T14:45:29.000Z | Include/FishEngine/Internal/LogType.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | 2 | 2016-10-12T07:08:38.000Z | 2017-04-05T01:56:30.000Z | Include/FishEngine/Internal/LogType.hpp | yushroom/FishEngine_-Experiment | 81e4c06f20f6b94dc561b358f8a11a092678aeeb | [
"MIT"
] | 39 | 2017-03-02T09:40:07.000Z | 2021-12-04T07:28:53.000Z | #pragma once
namespace FishEngine
{
enum class LogType
{
Error,
Assert,
Warning,
Log,
Exception
};
}
| 8.214286 | 20 | 0.652174 | yushroom |
a4c8656abe5470fe626dc0f7c71adec0637a2076 | 1,343 | cpp | C++ | 00057_insert-interval/191231-1.cpp | yanlinlin82/leetcode | ddcc0b9606d951cff9c08d1f7dfbc202067c8d65 | [
"MIT"
] | 6 | 2019-10-23T01:07:29.000Z | 2021-12-05T01:51:16.000Z | 00057_insert-interval/191231-1.cpp | yanlinlin82/leetcode | ddcc0b9606d951cff9c08d1f7dfbc202067c8d65 | [
"MIT"
] | null | null | null | 00057_insert-interval/191231-1.cpp | yanlinlin82/leetcode | ddcc0b9606d951cff9c08d1f7dfbc202067c8d65 | [
"MIT"
] | 1 | 2021-12-03T06:54:57.000Z | 2021-12-03T06:54:57.000Z | // https://leetcode-cn.com/problems/insert-interval/
#include <cstdio>
#include <vector>
using namespace std;
class Solution {
public:
vector<vector<int>> insert(vector<vector<int>>& intervals, vector<int>& newInterval) {
insert(intervals, newInterval[0], newInterval[1]);
return intervals;
}
private:
void insert(vector<vector<int>>& a, int start, int end) {
for (int i = 0; i < a.size(); ++i) {
if (end < a[i][0]) {
a.insert(a.begin() + i, vector<int>{start, end});
return;
} else if (start <= a[i][1]) {
if (a[i][0] > start) { a[i][0] = start; }
if (a[i][1] < end) { a[i][1] = end; }
while (i + 1 < a.size() && a[i][1] >= a[i + 1][0]) {
if (a[i][1] < a[i + 1][1]) { a[i][1] = a[i + 1][1]; }
a.erase(a.begin() + i + 1);
}
return;
}
}
a.push_back(vector<int>{start, end});
}
};
void print(const vector<vector<int>>& a)
{
printf("[");
for (int i = 0; i < a.size(); ++i) {
if (i > 0) printf(",");
printf("[%d,%d]", a[i][0], a[i][1]);
}
printf("]\n");
}
int main()
{
Solution s;
{
vector<vector<int>> a = {{1,3},{6,9}};
vector<int> b = {2,5};
print(s.insert(a, b)); // answer: [[1,5],[6,9]]
}
{
vector<vector<int>> a = {{1,2},{3,5},{6,7},{8,10},{12,16}};
vector<int> b = {4,8};
print(s.insert(a, b)); // answer: [[1,2],[3,10],[12,16]]
}
return 0;
}
| 23.561404 | 90 | 0.511541 | yanlinlin82 |
a4cc9162e73775f0d512cd6923e17ada0ff79bfb | 141 | hpp | C++ | linux/include/common.hpp | BaronKhan/gitgudcommit | cfc5f20339c61f3928871bea375608f7eefb8138 | [
"MIT"
] | 1 | 2021-02-22T15:06:39.000Z | 2021-02-22T15:06:39.000Z | linux/include/common.hpp | BaronKhan/gitgudcommit | cfc5f20339c61f3928871bea375608f7eefb8138 | [
"MIT"
] | null | null | null | linux/include/common.hpp | BaronKhan/gitgudcommit | cfc5f20339c61f3928871bea375608f7eefb8138 | [
"MIT"
] | 1 | 2021-02-22T15:06:41.000Z | 2021-02-22T15:06:41.000Z | #ifndef GITGUD_COMMON_HPP_
#define GITGUD_COMMON_HPP_
#include <string>
namespace GitGud
{
std::string exec(const char* cmd);
}
#endif | 10.846154 | 36 | 0.751773 | BaronKhan |
a4ccacded3b5dc2f4c41430e27fdadb755ac6598 | 2,081 | cpp | C++ | mod/memlite/watcher/watcher.cpp | kniz/wrd | a8c9e8bd2f7b240ff64a3b80e7ebc7aff2775ba6 | [
"MIT"
] | 7 | 2019-03-12T03:04:32.000Z | 2021-12-26T04:33:44.000Z | mod/memlite/watcher/watcher.cpp | kniz/wrd | a8c9e8bd2f7b240ff64a3b80e7ebc7aff2775ba6 | [
"MIT"
] | 25 | 2016-09-23T16:36:19.000Z | 2019-02-12T14:14:32.000Z | mod/memlite/watcher/watcher.cpp | kniz/World | 13b0c8c7fdc6280efcb2135dc3902754a34e6d06 | [
"MIT"
] | null | null | null | #include "watcher.hpp"
namespace wrd {
WRD_DEF_ME(watcher, chunk)
me::watcher() : chunk(sizeof(watchCell), false) {}
watchCell& me::operator[](widx n) { return get(n); }
watchCell& me::operator[](id newId) { return get(newId); }
watchCell& me::get(widx n) { return *(watchCell*)_get(n); }
watchCell& me::get(id newId) {
watchCell& got = get(newId.tagN);
if(nul(got)) return nulOf<watchCell>();
id gotId = got.blk.getId();
if(gotId.tagN != newId.tagN) {
WRD_W("bindTag was corrupted! watchCell.id(%d.%d.%d) != id(%d.%d.%d)",
gotId.tagN, gotId.chkN, gotId.serial, newId.tagN, newId.chkN, newId.serial);
return nulOf<watchCell>();
}
if(gotId.chkN != newId.chkN || gotId.serial != newId.serial)
// bindTag has been changed its instance to bind.
return nulOf<watchCell>();
return got;
}
void* me::new1() {
if(isFull())
if(!_resize(size()*2 + 1))
return WRD_E("resize watcher failed! this damage system seriously !!!!"), nullptr;
watchCell* res = (watchCell*)super::new1();
if(!res)
return res;
::new (&res->blk) bindTag(_genId(res));
return res;
}
wbool me::del(void* used, wcnt sz) {
watchCell& cell = *((watchCell*) used);
cell.~watchCell();
return super::del(used, sz);
}
id me::_genId(void* pt) const {
static wcnt serial = 0;
// watcher concern about bkl_n at Id. on the other hand, chunk is chkN.
// eventually, if Instance was born from heap, first it take chkN from chunk when it borns.
// and take tagN from watcher when user try to access its Block instance.
return id(_getIdx(pt), WRD_INDEX_ERROR, ++serial);
}
widx me::_getIdx(void* it) const {
if(!has(*(instance*)it)) // "has" func will treat it as void*, too.
return -1;
widx ret = ((wuchar*)it - _getHeap()) / getBlkSize();
return ret;
}
}
| 31.059701 | 99 | 0.560308 | kniz |
a4d21d9bd36d3a10c25892080190fbccf0e3438b | 5,643 | cpp | C++ | src/direct_method/mask.cpp | pariasm/estadeo-seq | 2198df08b50cc7f4fc1fdbf43387eb166e3627ac | [
"BSD-2-Clause"
] | null | null | null | src/direct_method/mask.cpp | pariasm/estadeo-seq | 2198df08b50cc7f4fc1fdbf43387eb166e3627ac | [
"BSD-2-Clause"
] | null | null | null | src/direct_method/mask.cpp | pariasm/estadeo-seq | 2198df08b50cc7f4fc1fdbf43387eb166e3627ac | [
"BSD-2-Clause"
] | null | null | null | // This program is free software: you can use, modify and/or redistribute it
// under the terms of the simplified BSD License. You should have received a
// copy of this license along this program. If not, see
// <http://www.opensource.org/licenses/bsd-license.html>.
//
// Copyright (C) 2015, Javier Sánchez Pérez <jsanchez@ulpgc.es>
// Copyright (C) 2014, Nelson Monzón López <nmonzon@ctim.es>
// All rights reserved.
#include "mask.h"
#include <math.h>
#include <stdio.h>
/**
*
* Function to compute the gradient with centered differences
*
**/
void gradient(
float *input, //input image
float *dx, //computed x derivative
float *dy, //computed y derivative
const int nx, //image width
const int ny //image height
)
{
//#pragma omp parallel
{
//apply the gradient to the center body of the image
//#pragma omp for schedule(dynamic) nowait
for(int i = 1; i < ny-1; i++)
{
for(int j = 1; j < nx-1; j++)
{
const int k = i * nx + j;
dx[k] = 0.5*(input[k+1] - input[k-1]);
dy[k] = 0.5*(input[k+nx] - input[k-nx]);
}
}
//apply the gradient to the first and last rows
//#pragma omp for schedule(dynamic) nowait
for(int j = 1; j < nx-1; j++)
{
dx[j] = 0.5*(input[j+1] - input[j-1]);
dy[j] = 0.5*(input[j+nx] - input[j]);
const int k = (ny - 1) * nx + j;
dx[k] = 0.5*(input[k+1] - input[k-1]);
dy[k] = 0.5*(input[k] - input[k-nx]);
}
//apply the gradient to the first and last columns
//#pragma omp for schedule(dynamic) nowait
for(int i = 1; i < ny-1; i++)
{
const int p = i * nx;
dx[p] = 0.5*(input[p+1] - input[p]);
dy[p] = 0.5*(input[p+nx] - input[p-nx]);
const int k = (i+1) * nx - 1;
dx[k] = 0.5*(input[k] - input[k-1]);
dy[k] = 0.5*(input[k+nx] - input[k-nx]);
}
//apply the gradient to the four corners
dx[0] = 0.5*(input[1] - input[0]);
dy[0] = 0.5*(input[nx] - input[0]);
dx[nx-1] = 0.5*(input[nx-1] - input[nx-2]);
dy[nx-1] = 0.5*(input[2*nx-1] - input[nx-1]);
dx[(ny-1)*nx] = 0.5*(input[(ny-1)*nx + 1] - input[(ny-1)*nx]);
dy[(ny-1)*nx] = 0.5*(input[(ny-1)*nx] - input[(ny-2)*nx]);
dx[ny*nx-1] = 0.5*(input[ny*nx-1] - input[ny*nx-1-1]);
dy[ny*nx-1] = 0.5*(input[ny*nx-1] - input[(ny-1)*nx-1]);
}
}
/**
*
* Convolution with a Gaussian
*
*/
void
gaussian (
float *I, //input/output image
int xdim, //image width
int ydim, //image height
float sigma, //Gaussian sigma
int bc, //boundary condition
int precision //defines the size of the window
)
{
int i, j, k;
float den = 2 * sigma * sigma;
int size = (int) (precision * sigma) + 1;
int bdx = xdim + size;
int bdy = ydim + size;
if (bc && size > xdim){
printf("GaussianSmooth: sigma too large for this bc\n");
throw 1;
}
//compute the coefficients of the 1D convolution kernel
float *B = new float [size];
for (int i = 0; i < size; i++)
B[i] = 1 / (sigma * sqrt (2.0 * 3.1415926)) * exp (-i * i / den);
float norm = 0;
//normalize the 1D convolution kernel
for (int i = 0; i < size; i++)
norm += B[i];
norm *= 2;
norm -= B[0];
for (int i = 0; i < size; i++)
B[i] /= norm;
float *R = new float[size + xdim + size];
float *T = new float[size + ydim + size];
//convolution of each line of the input image
for (k = 0; k < ydim; k++)
{
for (i = size; i < bdx; i++)
R[i] = I[(k * xdim + i - size) ];
switch (bc)
{
case 0: //Dirichlet boundary conditions
for (i = 0, j = bdx; i < size; i++, j++)
R[i] = R[j] = 0;
break;
case 1: //Reflecting boundary conditions
for (i = 0, j = bdx; i < size; i++, j++)
{
R[i] = I[(k * xdim + size - i ) ];
R[j] = I[(k * xdim + xdim - i - 1) ];
}
break;
case 2: //Periodic boundary conditions
for (i = 0, j = bdx; i < size; i++, j++)
{
R[i] = I[(k * xdim + xdim - size + i) ];
R[j] = I[(k * xdim + i) ];
}
break;
}
for (i = size; i < bdx; i++)
{
float sum = B[0] * R[i];
for (int j = 1; j < size; j++)
sum += B[j] * (R[i - j] + R[i + j]);
I[(k * xdim + i - size) ] = sum;
}
}
//convolution of each column of the input image
for (k = 0; k < xdim; k++)
{
for (i = size; i < bdy; i++)
T[i] = I[((i - size) * xdim + k) ];
switch (bc)
{
case 0: // Dirichlet boundary conditions
for (i = 0, j = bdy; i < size; i++, j++)
T[i] = T[j] = 0;
break;
case 1: // Reflecting boundary conditions
for (i = 0, j = bdy; i < size; i++, j++)
{
T[i] = I[((size - i) * xdim + k) ];
T[j] = I[((ydim - i - 1) * xdim + k) ];
}
break;
case 2: // Periodic boundary conditions
for (i = 0, j = bdx; i < size; i++, j++)
{
T[i] = I[((ydim - size + i) * xdim + k) ];
T[j] = I[(i * xdim + k) ];
}
break;
}
for (i = size; i < bdy; i++)
{
float sum = B[0] * T[i];
for (j = 1; j < size; j++)
sum += B[j] * (T[i - j] + T[i + j]);
I[((i - size) * xdim + k) ] = sum;
}
}
delete[]B;
delete[]R;
delete[]T;
}
| 25.65 | 76 | 0.460748 | pariasm |
a4d276c676749f1e6f8f89edc865fc560d5578e9 | 4,337 | cpp | C++ | src/ioHandler.cpp | JonasRock/ARXML_LanguageServer | f31cc0b2ca9233ac544cf10aee6d799ea9e55320 | [
"Apache-2.0"
] | 1 | 2021-09-11T06:28:35.000Z | 2021-09-11T06:28:35.000Z | src/ioHandler.cpp | JonasRock/ARXML_LanguageServer | f31cc0b2ca9233ac544cf10aee6d799ea9e55320 | [
"Apache-2.0"
] | 1 | 2022-01-27T08:47:22.000Z | 2022-01-27T12:23:57.000Z | src/ioHandler.cpp | JonasRock/ARXML_LanguageServer | f31cc0b2ca9233ac544cf10aee6d799ea9e55320 | [
"Apache-2.0"
] | null | null | null | #include "ioHandler.hpp"
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include "boost/asio.hpp"
#include "boost/lexical_cast.hpp"
using namespace boost;
lsp::IOHandler::IOHandler(const std::string &address, uint32_t port)
: ioc_(), endpoint_(asio::ip::address::from_string(address), port), socket_(ioc_, endpoint_.protocol())
{
std::cout << "Connecting to " << address << ":" << port << "...\n";
socket_.connect(endpoint_);
std::cout << "Connection established\n";
}
void lsp::IOHandler::addMessageToSend(const std::string &message)
{
sendStack_.emplace(message);
}
std::string lsp::IOHandler::readNextMessage()
{
std::string ret;
if (read_(ret))
{
#ifndef NO_TERMINAL_OUTPUT
std::cout << " >> Receiving Message:\n" << ret << "\n\n";
#endif
return ret;
}
else
{
return "";
}
}
void lsp::IOHandler::writeAllMessages()
{
while(!sendStack_.empty())
{
std::string toSend = sendStack_.top();
sendStack_.pop();
write_(toSend);
#ifndef NO_TERMINAL_OUTPUT
if(toSend.size() > (1024*5)) //5kb write limit to console
std::cout << " >> Sending Message:\n" << toSend.substr(0, 1024*5) << "\n>> Console Write limit reached. The write to the socket was unaffected, this is to prevent the console from crashing.\n\n";
else
std::cout << " >> Sending Message:\n" << toSend << "\n\n";
#endif
}
}
std::size_t lsp::IOHandler::read_(std::string &message)
{
while(socket_.available() < 30)
{
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
/////////////////////////// Header ///////////////////////////
//read_until() and read() are incompatible, as read_until can read over the delimiter, when calling consecutive
//read_until()s, it looks into the buffer first if the condition is already met, so it does not read from the socket in that case
//read does not look at the buffer, so it will probably miss a majority of the content, as that is in the buffer.
//for this reason, the streambuffer for the header is limited to 30 characters, 20 for the "Content-Lenght: " and "\r\n\r\n"
//and 10 characters for the number, as requests should not be bigger than that anyways.
//This is necessary because the header is delimited by a string delimiter, while the body is delmitited by the provided length
//read_until() for the delimiter, read() for the fixed length
asio::streambuf headerbuf(30);
boost::system::error_code ec;
std::size_t headerLength = asio::read_until(socket_, headerbuf, "\r\n\r\n", ec);
if (ec) { std::cerr << ec.message() << std::endl; }
size_t contentLength = lexical_cast<size_t>(std::string{
// Remove the "Content-Length: "
asio::buffers_begin(headerbuf.data()) + 16,
// Remove the "\r\n\r\n"
asio::buffers_begin(headerbuf.data()) + headerLength - 4
});
headerbuf.consume(headerLength);
//We didn't know how big the header was before, so we have probably had too much space in the streambuffer, some of the content might still be here
//We can extract that now and continue reading with read, since we know exactly how much read_until() read.
std::istream headerStream(&headerbuf);
std::string contentInHeader;
headerStream >> contentInHeader;
/////////////////////////// Content //////////////////////////
asio::streambuf contentbuf(contentLength - contentInHeader.size());
//read the rest
asio::read(socket_, contentbuf, asio::transfer_exactly(contentLength - contentInHeader.size()), ec);
if (ec) { std::cerr << ec.message() << std::endl;}
message.reserve(contentLength);
message = contentInHeader + std::string{
asio::buffers_begin(contentbuf.data()),
asio::buffers_end(contentbuf.data())
};
contentbuf.consume(contentLength);
return headerLength + contentLength;
}
std::size_t lsp::IOHandler::write_(const std::string &message)
{
asio::streambuf sendBuf;
std::ostream sendStream(&sendBuf);
sendStream << "Content-Length: ";
sendStream << lexical_cast<std::string>(message.length());
sendStream << "\r\n\r\n";
sendStream << message;
size_t sentBytes = asio::write(socket_, sendBuf);
return sentBytes;
} | 34.696 | 207 | 0.646991 | JonasRock |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.