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
sequencelengths
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
sequencelengths
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
sequencelengths
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
f3d050ec97a6e657e2d1e97828d0134d2540e995
2,353
hpp
C++
grad_computer.hpp
auckland-cosmo/pspectre
c9114411bc9db0c353324c0f7c5ce2977daab452
[ "BSD-2-Clause" ]
1
2019-03-07T13:17:43.000Z
2019-03-07T13:17:43.000Z
grad_computer.hpp
auckland-cosmo/pspectre
c9114411bc9db0c353324c0f7c5ce2977daab452
[ "BSD-2-Clause" ]
1
2019-08-21T01:08:43.000Z
2019-08-21T01:08:43.000Z
grad_computer.hpp
auckland-cosmo/pspectre
c9114411bc9db0c353324c0f7c5ce2977daab452
[ "BSD-2-Clause" ]
4
2019-03-07T13:17:46.000Z
2020-06-05T07:00:50.000Z
/* * SpectRE - A Spectral Code for Reheating * Copyright (C) 2009-2010 Hal Finkel, Nathaniel Roth and Richard Easther * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED ``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 AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * @file * @brief Computation of the gradient in Fourier space. */ #ifndef GRAD_COMPUTER_HPP #define GRAD_COMPUTER_HPP #include "field_size.hpp" #include "model_params.hpp" #include "field.hpp" template <typename R> class grad_computer { public: grad_computer(field_size &fs_, model_params<R> &mp_, field<R> &phi_, field<R> &chi_) : fs(fs_), upfs(fs_.n), mp(mp_), phi(phi_), chi(chi_), phigradx("phigradx"), chigradx("chigradx"), phigrady("phigrady"), chigrady("chigrady"), phigradz("phigradz"), chigradz("chigradz") { phigradx.construct(upfs); chigradx.construct(upfs); phigrady.construct(upfs); chigrady.construct(upfs); phigradz.construct(upfs); chigradz.construct(upfs); } public: void compute(field_state final_state = position); protected: field_size &fs, upfs; model_params<R> &mp; field<R> &phi, &chi; public: field<R> phigradx, chigradx; field<R> phigrady, chigrady; field<R> phigradz, chigradz; }; #endif // GRAD_COMPUTER_HPP
32.232877
85
0.740756
auckland-cosmo
f3d234bbf34a00d7ee88677f1fee56a2095e917b
695
hpp
C++
src/backend/opencl/solve.hpp
JuliaComputing/arrayfire
93427f09ff928f97df29c0e358c3fcf6b478bec6
[ "BSD-3-Clause" ]
1
2018-06-14T23:49:18.000Z
2018-06-14T23:49:18.000Z
src/backend/opencl/solve.hpp
JuliaComputing/arrayfire
93427f09ff928f97df29c0e358c3fcf6b478bec6
[ "BSD-3-Clause" ]
1
2015-07-02T15:53:02.000Z
2015-07-02T15:53:02.000Z
src/backend/opencl/solve.hpp
JuliaComputing/arrayfire
93427f09ff928f97df29c0e358c3fcf6b478bec6
[ "BSD-3-Clause" ]
1
2018-02-26T17:11:03.000Z
2018-02-26T17:11:03.000Z
/******************************************************* * Copyright (c) 2014, ArrayFire * All rights reserved. * * This file is distributed under 3-clause BSD license. * The complete license agreement can be obtained at: * http://arrayfire.com/licenses/BSD-3-Clause ********************************************************/ #include <af/array.h> #include <Array.hpp> namespace opencl { template<typename T> Array<T> solve(const Array<T> &a, const Array<T> &b, const af_mat_prop options = AF_MAT_NONE); template<typename T> Array<T> solveLU(const Array<T> &a, const Array<int> &pivot, const Array<T> &b, const af_mat_prop options = AF_MAT_NONE); }
31.590909
98
0.569784
JuliaComputing
f3d9e15089af8235aca90e3dcc8bc194a1584881
9,769
hpp
C++
Code/Engine/Renderer/DebugObjectProperties.hpp
pronaypeddiraju/Engine
0ca9720a00f51340c6eb6bba07d70972489663e8
[ "Unlicense" ]
1
2021-01-25T23:53:44.000Z
2021-01-25T23:53:44.000Z
Code/Engine/Renderer/DebugObjectProperties.hpp
pronaypeddiraju/Engine
0ca9720a00f51340c6eb6bba07d70972489663e8
[ "Unlicense" ]
null
null
null
Code/Engine/Renderer/DebugObjectProperties.hpp
pronaypeddiraju/Engine
0ca9720a00f51340c6eb6bba07d70972489663e8
[ "Unlicense" ]
1
2021-01-25T23:53:46.000Z
2021-01-25T23:53:46.000Z
//------------------------------------------------------------------------------------------------------------------------------ #pragma once //Engine Systems #include "Engine/Commons/EngineCommon.hpp" #include "Engine/Math/AABB2.hpp" #include "Engine/Math/AABB3.hpp" #include "Engine/Math/Capsule3D.hpp" #include "Engine/Math/Disc2D.hpp" #include "Engine/Renderer/CPUMesh.hpp" #include "Engine/Renderer/GPUMesh.hpp" #include "Engine/Renderer/Rgba.hpp" //------------------------------------------------------------------------------------------------------------------------------ class TextureView; //------------------------------------------------------------------------------------------------------------------------------ enum eDebugRenderObject { DEBUG_RENDER_POINT, DEBUG_RENDER_POINT3D, DEBUG_RENDER_LINE, DEBUG_RENDER_LINE3D, DEBUG_RENDER_QUAD, DEBUG_RENDER_WIRE_QUAD, DEBUG_RENDER_QUAD3D, DEBUG_RENDER_DISC, DEBUG_RENDER_RING, DEBUG_RENDER_SPHERE, DEBUG_RENDER_WIRE_SPHERE, //This has to be an icoSphere DEBUG_RENDER_BOX, DEBUG_RENDER_WIRE_BOX, DEBUG_RENDER_ARROW, DEBUG_RENDER_ARROW3D, DEBUG_RENDER_CAPSULE, DEBUG_RENDER_WIRE_CAPSULE, DEBUG_RENDER_BASIS, DEBUG_RENDER_TEXT, DEBUG_RENDER_TEXT3D, DEBUG_RENDER_LOG }; //------------------------------------------------------------------------------------------------------------------------------ class ObjectProperties { public: virtual ~ObjectProperties(); eDebugRenderObject m_renderObjectType; float m_durationSeconds = 0.0f; // show for a single frame float m_startDuration = 0.f; Rgba m_currentColor = Rgba::WHITE; CPUMesh* m_mesh; }; //------------------------------------------------------------------------------------------------------------------------------ // 2D Render Objects //------------------------------------------------------------------------------------------------------------------------------ // Point //------------------------------------------------------------------------------------------------------------------------------ class Point2DProperties : public ObjectProperties { public: explicit Point2DProperties(eDebugRenderObject renderObject, const Vec2& screenPosition, float durationSeconds = 0.f, float size = DEFAULT_POINT_SIZE); virtual ~Point2DProperties(); public: Vec2 m_screenPosition = Vec2::ZERO; float m_size = DEFAULT_POINT_SIZE; }; // Line //------------------------------------------------------------------------------------------------------------------------------ class Line2DProperties : public ObjectProperties { public: explicit Line2DProperties(eDebugRenderObject renderObject, const Vec2& startPos, const Vec2& endPos, float durationSeconds = 0.f, float lineWidth = DEFAULT_LINE_WIDTH); virtual ~Line2DProperties(); public: Vec2 m_startPos = Vec2::ZERO; Vec2 m_endPos = Vec2::ZERO; float m_lineWidth = DEFAULT_LINE_WIDTH; }; // Arrow //------------------------------------------------------------------------------------------------------------------------------ class Arrow2DProperties : public ObjectProperties { public: explicit Arrow2DProperties(eDebugRenderObject renderObject, const Vec2& start, const Vec2& end, float durationSeconds = 0.f, float lineWidth = DEFAULT_LINE_WIDTH); virtual ~Arrow2DProperties(); public: Vec2 m_startPos = Vec2::ZERO; Vec2 m_endPos = Vec2::ZERO; float m_lineWidth = DEFAULT_LINE_WIDTH; Vec2 m_lineEnd = Vec2::ZERO; Vec2 m_arrowTip = Vec2::ZERO; Vec2 m_lineNorm = Vec2::ZERO; }; // Quad //------------------------------------------------------------------------------------------------------------------------------ class Quad2DProperties : public ObjectProperties { public: explicit Quad2DProperties( eDebugRenderObject renderObject, const AABB2& quad, float durationSeconds = 0.f, float thickness = DEFAULT_WIRE_WIDTH_2D, TextureView* texture = nullptr ); virtual ~Quad2DProperties(); public: TextureView* m_texture = nullptr; float m_thickness = DEFAULT_WIRE_WIDTH_2D; //Only used when rendering as a wire box AABB2 m_quad; }; // Disc //------------------------------------------------------------------------------------------------------------------------------ class Disc2DProperties : public ObjectProperties { public: explicit Disc2DProperties( eDebugRenderObject renderObject, const Disc2D& disc, float thickness, float durationSeconds = 0.f); virtual ~Disc2DProperties(); public: Disc2D m_disc; float m_thickness; //Only used when rendering it as a ring }; //------------------------------------------------------------------------------------------------------------------------------ // 3D Render Objects //------------------------------------------------------------------------------------------------------------------------------ // Point //------------------------------------------------------------------------------------------------------------------------------ class Point3DProperties : public ObjectProperties { public: explicit Point3DProperties( eDebugRenderObject renderObject, const Vec3& position, float size = DEFAULT_POINT_SIZE_3D, float durationSeconds = 0.f, TextureView* texture = nullptr); virtual ~Point3DProperties(); public: Vec3 m_position = Vec3::ZERO; TextureView* m_texture = nullptr; float m_size = DEFAULT_POINT_SIZE_3D; AABB2 m_point; }; // Line //------------------------------------------------------------------------------------------------------------------------------ class Line3DProperties : public ObjectProperties { public: explicit Line3DProperties( eDebugRenderObject renderObject, const Vec3& startPos, const Vec3& endPos, float durationSeconds = 0.f, float lineWidth = DEFAULT_LINE_WIDTH); virtual ~Line3DProperties(); public: Vec3 m_startPos = Vec3::ZERO; Vec3 m_endPos = Vec3::ZERO; Vec3 m_center = Vec3::ZERO; float m_lineWidth = DEFAULT_LINE_WIDTH; AABB2 m_line; }; // Quad //------------------------------------------------------------------------------------------------------------------------------ class Quad3DProperties : public ObjectProperties { public: explicit Quad3DProperties( eDebugRenderObject renderObject, const AABB2& quad, const Vec3& position, float durationSeconds = 0.f, TextureView* texture = nullptr, bool billBoarded = true ); virtual ~Quad3DProperties(); public: Vec3 m_position = Vec3::ZERO; TextureView* m_texture = nullptr; bool m_billBoarded = true; AABB2 m_quad; }; // Sphere //------------------------------------------------------------------------------------------------------------------------------ class SphereProperties : public ObjectProperties { public: explicit SphereProperties( eDebugRenderObject renderObject, const Vec3& center, float radius, float durationSeconds = 0.f, TextureView* texture = nullptr); virtual ~SphereProperties(); public: Vec3 m_center = Vec3::ZERO; float m_radius = 0.f; TextureView* m_texture = nullptr; }; // Capsule //------------------------------------------------------------------------------------------------------------------------------ class CapsuleProperties : public ObjectProperties { public: explicit CapsuleProperties( eDebugRenderObject renderObject, const Capsule3D& capsule, const Vec3& position, float durationSeconds = 0.f, TextureView* texture = nullptr); virtual ~CapsuleProperties(); public: Vec3 m_position = Vec3::ZERO; TextureView* m_texture = nullptr; Capsule3D m_capsule; }; // Box //------------------------------------------------------------------------------------------------------------------------------ class BoxProperties : public ObjectProperties { public: explicit BoxProperties( eDebugRenderObject renderObject, const AABB3& box, const Vec3& position, float durationSeconds = 0.f, TextureView* texture = nullptr); virtual ~BoxProperties(); public: Vec3 m_position = Vec3::ZERO; TextureView* m_texture = nullptr; AABB3 m_box; }; //------------------------------------------------------------------------------------------------------------------------------ // Text Render Objects //------------------------------------------------------------------------------------------------------------------------------ class TextProperties : public ObjectProperties { public: explicit TextProperties( eDebugRenderObject renderObject, const Vec3& position, const Vec2& pivot, const std::string& text, float fontHeight, float durationSeconds = 0.f, bool isBillboarded = true); explicit TextProperties( eDebugRenderObject renderObject, const Vec2& startPosition, const Vec2& endPosition, const std::string& text, float fontHeight, float durationSeconds = 0.f); virtual ~TextProperties(); public: //For 3D Vec3 m_position = Vec3::ZERO; Vec2 m_pivot = Vec2::ZERO; bool m_isBillboarded = true; //For 2D Vec2 m_startPosition = Vec2::ZERO; Vec2 m_endPosition = Vec2::ZERO; float m_fontHeight = DEFAULT_TEXT_HEIGHT_3D; std::string m_string; }; //------------------------------------------------------------------------------------------------------------------------------ // Text Log Entry //------------------------------------------------------------------------------------------------------------------------------ class LogProperties : public ObjectProperties { public: explicit LogProperties(eDebugRenderObject renderObject, const Rgba& printColor, const std::string& printString, float durationSeconds = 0.f); virtual ~LogProperties(); public: Rgba m_printColor = Rgba::WHITE; std::string m_string; };
33.686207
142
0.518784
pronaypeddiraju
f3dc8bbe8a15638956e6cfeb0799afbcdad66bcb
1,199
cpp
C++
test/common/test_timestamp.cpp
mweisgut/duckdb
4cff1d7957ce895dd9984a87aa20aef67f5986e6
[ "MIT" ]
1
2019-08-01T08:21:33.000Z
2019-08-01T08:21:33.000Z
test/common/test_timestamp.cpp
mweisgut/duckdb
4cff1d7957ce895dd9984a87aa20aef67f5986e6
[ "MIT" ]
null
null
null
test/common/test_timestamp.cpp
mweisgut/duckdb
4cff1d7957ce895dd9984a87aa20aef67f5986e6
[ "MIT" ]
null
null
null
#include "catch.hpp" #include "common/types/timestamp.hpp" #include <vector> using namespace duckdb; using namespace std; static void VerifyTimestamp(date_t date, dtime_t time, int64_t epoch) { // create the timestamp from the string timestamp_t stamp = Timestamp::FromString(Date::ToString(date) + " " + Time::ToString(time)); // verify that we can get the date and time back REQUIRE(Timestamp::GetDate(stamp) == date); REQUIRE(Timestamp::GetTime(stamp) == time); // verify that the individual extract functions work int32_t hour, min, sec, msec; Time::Convert(time, hour, min, sec, msec); REQUIRE(Timestamp::GetHours(stamp) == hour); REQUIRE(Timestamp::GetMinutes(stamp) == min); REQUIRE(Timestamp::GetSeconds(stamp) == sec); // verify that the epoch is correct REQUIRE(epoch == (Date::Epoch(date) + time / 1000)); REQUIRE(Timestamp::GetEpoch(stamp) == epoch); } TEST_CASE("Verify that timestamp functions work", "[timestamp]") { VerifyTimestamp(Date::FromDate(2019, 8, 26), Time::FromTime(8, 52, 6), 1566809526); VerifyTimestamp(Date::FromDate(1970, 1, 1), Time::FromTime(0, 0, 0), 0); VerifyTimestamp(Date::FromDate(2000, 10, 10), Time::FromTime(10, 10, 10), 971172610); }
37.46875
94
0.717264
mweisgut
f3dcbbf606ae0721591c03266e840dbe96590b76
1,024
cc
C++
src/board/position.cc
wotulong/FoolGo
0d18e78b0812f89eb55a19f67ee280d7dd74bb8e
[ "MIT" ]
null
null
null
src/board/position.cc
wotulong/FoolGo
0d18e78b0812f89eb55a19f67ee280d7dd74bb8e
[ "MIT" ]
null
null
null
src/board/position.cc
wotulong/FoolGo
0d18e78b0812f89eb55a19f67ee280d7dd74bb8e
[ "MIT" ]
1
2020-03-23T12:51:41.000Z
2020-03-23T12:51:41.000Z
#include "position.h" #include <boost/format.hpp> namespace foolgo { namespace board { using boost::format; using std::string; const BoardLen Position::STRAIGHT_ORNTTIONS[4][2] = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } }; const BoardLen Position::OBLIQUE_ORNTTIONS[4][2] = { { 1, -1 }, { 1, 1 }, { -1, 1 }, { -1, -1 } }; string PositionToString(const Position &position) { return (boost::format("{%1%, %2%}") % static_cast<int>(position.x) % static_cast<int>(position.y)).str(); } std::ostream &operator<<(std::ostream &os, const Position &position) { return os << PositionToString(position); } Position AdjacentPosition(const Position & position, int i) { return Position(position.x + Position::STRAIGHT_ORNTTIONS[i][0], position.y + Position::STRAIGHT_ORNTTIONS[i][1]); } Position ObliquePosition(const Position &position, int i) { return Position(position.x + Position::OBLIQUE_ORNTTIONS[i][0], position.y + Position::OBLIQUE_ORNTTIONS[i][1]); } } }
26.947368
79
0.642578
wotulong
f3dd15e76204984345697029ec31b4d838c80eeb
13,823
cpp
C++
3rdparty/spirv-tools/test/val/val_function_test.cpp
bencoyote/bgfx
feb453025d7d5ba423b1bbd11a33816a86644023
[ "BSD-2-Clause" ]
1
2019-07-30T09:37:27.000Z
2019-07-30T09:37:27.000Z
3rdparty/spirv-tools/test/val/val_function_test.cpp
Vaiklol/bgfx
1196825aebc4b4cdf9acc6c632d002d3c91ba095
[ "BSD-2-Clause" ]
null
null
null
3rdparty/spirv-tools/test/val/val_function_test.cpp
Vaiklol/bgfx
1196825aebc4b4cdf9acc6c632d002d3c91ba095
[ "BSD-2-Clause" ]
2
2020-03-07T17:59:02.000Z
2021-04-16T17:22:59.000Z
// Copyright (c) 2019 Google LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include <sstream> #include <string> #include <tuple> #include "gmock/gmock.h" #include "test/test_fixture.h" #include "test/unit_spirv.h" #include "test/val/val_fixtures.h" namespace spvtools { namespace val { namespace { using ::testing::Combine; using ::testing::HasSubstr; using ::testing::Values; using ValidateFunctionCall = spvtest::ValidateBase<std::string>; std::string GenerateShader(const std::string& storage_class, const std::string& capabilities, const std::string& extensions) { std::string spirv = R"( OpCapability Shader OpCapability Linkage OpCapability AtomicStorage )" + capabilities + R"( OpExtension "SPV_KHR_storage_buffer_storage_class" )" + extensions + R"( OpMemoryModel Logical GLSL450 OpName %var "var" %void = OpTypeVoid %int = OpTypeInt 32 0 %ptr = OpTypePointer )" + storage_class + R"( %int %caller_ty = OpTypeFunction %void %callee_ty = OpTypeFunction %void %ptr )"; if (storage_class != "Function") { spirv += "%var = OpVariable %ptr " + storage_class; } spirv += R"( %caller = OpFunction %void None %caller_ty %1 = OpLabel )"; if (storage_class == "Function") { spirv += "%var = OpVariable %ptr Function"; } spirv += R"( %call = OpFunctionCall %void %callee %var OpReturn OpFunctionEnd %callee = OpFunction %void None %callee_ty %param = OpFunctionParameter %ptr %2 = OpLabel OpReturn OpFunctionEnd )"; return spirv; } std::string GenerateShaderParameter(const std::string& storage_class, const std::string& capabilities, const std::string& extensions) { std::string spirv = R"( OpCapability Shader OpCapability Linkage OpCapability AtomicStorage )" + capabilities + R"( OpExtension "SPV_KHR_storage_buffer_storage_class" )" + extensions + R"( OpMemoryModel Logical GLSL450 OpName %p "p" %void = OpTypeVoid %int = OpTypeInt 32 0 %ptr = OpTypePointer )" + storage_class + R"( %int %func_ty = OpTypeFunction %void %ptr %caller = OpFunction %void None %func_ty %p = OpFunctionParameter %ptr %1 = OpLabel %call = OpFunctionCall %void %callee %p OpReturn OpFunctionEnd %callee = OpFunction %void None %func_ty %param = OpFunctionParameter %ptr %2 = OpLabel OpReturn OpFunctionEnd )"; return spirv; } std::string GenerateShaderAccessChain(const std::string& storage_class, const std::string& capabilities, const std::string& extensions) { std::string spirv = R"( OpCapability Shader OpCapability Linkage OpCapability AtomicStorage )" + capabilities + R"( OpExtension "SPV_KHR_storage_buffer_storage_class" )" + extensions + R"( OpMemoryModel Logical GLSL450 OpName %var "var" OpName %gep "gep" %void = OpTypeVoid %int = OpTypeInt 32 0 %int2 = OpTypeVector %int 2 %int_0 = OpConstant %int 0 %ptr = OpTypePointer )" + storage_class + R"( %int2 %ptr2 = OpTypePointer )" + storage_class + R"( %int %caller_ty = OpTypeFunction %void %callee_ty = OpTypeFunction %void %ptr2 )"; if (storage_class != "Function") { spirv += "%var = OpVariable %ptr " + storage_class; } spirv += R"( %caller = OpFunction %void None %caller_ty %1 = OpLabel )"; if (storage_class == "Function") { spirv += "%var = OpVariable %ptr Function"; } spirv += R"( %gep = OpAccessChain %ptr2 %var %int_0 %call = OpFunctionCall %void %callee %gep OpReturn OpFunctionEnd %callee = OpFunction %void None %callee_ty %param = OpFunctionParameter %ptr2 %2 = OpLabel OpReturn OpFunctionEnd )"; return spirv; } TEST_P(ValidateFunctionCall, VariableNoVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShader(storage_class, "", ""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); if (storage_class == "StorageBuffer") { EXPECT_THAT(getDiagnosticString(), HasSubstr("StorageBuffer pointer operand 1[%var] requires a " "variable pointers capability")); } else { EXPECT_THAT( getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%var]")); } } } TEST_P(ValidateFunctionCall, VariableVariablePointersStorageClass) { const std::string storage_class = GetParam(); std::string spirv = GenerateShader( storage_class, "OpCapability VariablePointersStorageBuffer", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%var]")); } } TEST_P(ValidateFunctionCall, VariableVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShader(storage_class, "OpCapability VariablePointers", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%var]")); } } TEST_P(ValidateFunctionCall, ParameterNoVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderParameter(storage_class, "", ""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); if (storage_class == "StorageBuffer") { EXPECT_THAT(getDiagnosticString(), HasSubstr("StorageBuffer pointer operand 1[%p] requires a " "variable pointers capability")); } else { EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%p]")); } } } TEST_P(ValidateFunctionCall, ParameterVariablePointersStorageBuffer) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderParameter( storage_class, "OpCapability VariablePointersStorageBuffer", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%p]")); } } TEST_P(ValidateFunctionCall, ParameterVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderParameter(storage_class, "OpCapability VariablePointers", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); if (valid) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); EXPECT_THAT(getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 1[%p]")); } } TEST_P(ValidateFunctionCall, NonMemoryObjectDeclarationNoVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderAccessChain(storage_class, "", ""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "AtomicCounter"}; bool valid_sc = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); CompileSuccessfully(spirv); EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); if (valid_sc) { EXPECT_THAT( getDiagnosticString(), HasSubstr( "Pointer operand 2[%gep] must be a memory object declaration")); } else { if (storage_class == "StorageBuffer") { EXPECT_THAT(getDiagnosticString(), HasSubstr("StorageBuffer pointer operand 2[%gep] requires a " "variable pointers capability")); } else { EXPECT_THAT( getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 2[%gep]")); } } } TEST_P(ValidateFunctionCall, NonMemoryObjectDeclarationVariablePointersStorageBuffer) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderAccessChain( storage_class, "OpCapability VariablePointersStorageBuffer", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid_sc = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); bool validate = storage_class == "StorageBuffer"; CompileSuccessfully(spirv); if (validate) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); if (valid_sc) { EXPECT_THAT( getDiagnosticString(), HasSubstr( "Pointer operand 2[%gep] must be a memory object declaration")); } else { EXPECT_THAT( getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 2[%gep]")); } } } TEST_P(ValidateFunctionCall, NonMemoryObjectDeclarationVariablePointers) { const std::string storage_class = GetParam(); std::string spirv = GenerateShaderAccessChain(storage_class, "OpCapability VariablePointers", "OpExtension \"SPV_KHR_variable_pointers\""); const std::vector<std::string> valid_storage_classes = { "UniformConstant", "Function", "Private", "Workgroup", "StorageBuffer", "AtomicCounter"}; bool valid_sc = std::find(valid_storage_classes.begin(), valid_storage_classes.end(), storage_class) != valid_storage_classes.end(); bool validate = storage_class == "StorageBuffer" || storage_class == "Workgroup"; CompileSuccessfully(spirv); if (validate) { EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); } else { EXPECT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions()); if (valid_sc) { EXPECT_THAT( getDiagnosticString(), HasSubstr( "Pointer operand 2[%gep] must be a memory object declaration")); } else { EXPECT_THAT( getDiagnosticString(), HasSubstr("Invalid storage class for pointer operand 2[%gep]")); } } } INSTANTIATE_TEST_SUITE_P(StorageClass, ValidateFunctionCall, Values("UniformConstant", "Input", "Uniform", "Output", "Workgroup", "Private", "Function", "PushConstant", "Image", "StorageBuffer", "AtomicCounter")); } // namespace } // namespace val } // namespace spvtools
32.524706
80
0.669826
bencoyote
f3df7bf456716f6b3bd615f217e86def5818eea8
1,455
hpp
C++
include/crisp/interpreter/InterpretUserDefinedAST.hpp
pzque/crisp
4c53db12a0cca5a0c4165b6333e2cdc574daaa4e
[ "Apache-2.0" ]
3
2021-12-31T09:03:46.000Z
2022-03-29T02:40:30.000Z
include/crisp/interpreter/InterpretUserDefinedAST.hpp
pzque/crisp
4c53db12a0cca5a0c4165b6333e2cdc574daaa4e
[ "Apache-2.0" ]
null
null
null
include/crisp/interpreter/InterpretUserDefinedAST.hpp
pzque/crisp
4c53db12a0cca5a0c4165b6333e2cdc574daaa4e
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2019 by Crisp Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef CRISP_INTERPRETUSERDEFINEDAST_HPP #define CRISP_INTERPRETUSERDEFINEDAST_HPP #include "Common.hpp" #include "CrispFunction.hpp" namespace crisp { template <typename Environ, typename F, typename... Args> struct CallCrispFunction { using type = Interpret<Call<typename F::__name__, Args...>, Environ>; }; template <template <typename...> class F, typename Environ, typename... Args> struct Interpret<F<Args...>, Environ> { using FApply = F<Args...>; using FApplyInterp = typename ConditionalApply< When<Bool<is_base_of<CrispFunction, FApply>::value>, DeferApply<CallCrispFunction, Environ, FApply, Args...>>, Else<DeferConstruct<Id, FApply>>>::type; using env = Environ; using type = typename FApplyInterp::type; }; } // namespace crisp #endif // CRISP_INTERPRETUSERDEFINEDAST_HPP
31.630435
77
0.720275
pzque
f3dfd78c5a2b822873fff33ac7e1c2b1e17312be
11,055
hh
C++
include/maxscale/protocol2.hh
Daniel-Xu/MaxScale
35d12c0c9b75c4571dbbeb983c740de098661de6
[ "BSD-3-Clause" ]
null
null
null
include/maxscale/protocol2.hh
Daniel-Xu/MaxScale
35d12c0c9b75c4571dbbeb983c740de098661de6
[ "BSD-3-Clause" ]
null
null
null
include/maxscale/protocol2.hh
Daniel-Xu/MaxScale
35d12c0c9b75c4571dbbeb983c740de098661de6
[ "BSD-3-Clause" ]
null
null
null
/* * Copyright (c) 2019 MariaDB Corporation Ab * * Use of this software is governed by the Business Source License included * in the LICENSE.TXT file and at www.mariadb.com/bsl11. * * Change Date: 2025-04-28 * * On the date above, in accordance with the Business Source License, use * of this software will be governed by version 2 or later of the General * Public License. */ #pragma once #include <maxscale/ccdefs.hh> #include <maxscale/protocol.hh> #include <maxscale/authenticator.hh> class BackendDCB; class ClientDCB; class DCB; class SERVICE; namespace maxscale { class BackendConnection; class ClientConnection; class ConfigParameters; class UserAccountManager; class ProtocolModule { public: using AuthenticatorList = std::vector<mxs::SAuthenticatorModule>; virtual ~ProtocolModule() = default; enum Capabilities { CAP_AUTHDATA = (1u << 0), // Protocol implements a user account manager CAP_BACKEND = (1u << 1), // Protocol supports backend communication CAP_AUTH_MODULES = (1u << 2), // Protocol uses authenticator modules and does not integrate one }; /** * Allocate new client protocol session * * @param session The session to which the connection belongs to * @param component The component to use for routeQuery * * @return New protocol session or null on error */ virtual std::unique_ptr<mxs::ClientConnection> create_client_protocol(MXS_SESSION* session, mxs::Component* component) = 0; /** * Allocate new backend protocol session * * @param session The session to which the connection belongs to * @param server Server where the connection is made * * @return New protocol session or null on error */ virtual std::unique_ptr<BackendConnection> create_backend_protocol(MXS_SESSION* session, SERVER* server, mxs::Component* component) { mxb_assert(!true); return nullptr; } /** * Get the default authenticator for the protocol. * * @return The default authenticator for the protocol or empty if the protocol * does not provide one */ virtual std::string auth_default() const = 0; /** * Get rejection message. The protocol should return an error indicating that access to MaxScale * has been temporarily suspended. * * @param host The host that is blocked * @return A buffer containing the error message */ virtual GWBUF* reject(const std::string& host) { return nullptr; } /** * Get protocol module name. * * @return Module name */ virtual std::string name() const = 0; /** * Print a list of authenticator users to json. This should only be implemented by protocols without * CAP_AUTHDATA. * * @return JSON user list */ virtual json_t* print_auth_users_json() { return nullptr; } /** * Create a user account manager. Will be only called for protocols with CAP_AUTHDATA. * * @return New user account manager. Will be shared between all listeners of the service. */ virtual std::unique_ptr<UserAccountManager> create_user_data_manager() { mxb_assert(!true); return nullptr; } virtual uint64_t capabilities() const { return 0; } /** * The protocol module should read the listener parameters for the list of authenticators and their * options and generate authenticator modules. This is only called if CAP_AUTH_MODULES is enabled. * * @param params Listener and authenticator settings * @return An array of authenticators. Empty on error. */ virtual AuthenticatorList create_authenticators(const ConfigParameters& params) { mxb_assert(!true); return {}; } }; /** * Client protocol connection interface. All protocols must implement this. */ class ClientConnection : public ProtocolConnection { public: virtual ~ClientConnection() = default; /** * Initialize a connection. * * @return True, if the connection could be initialized, false otherwise. */ virtual bool init_connection() = 0; /** * Finalize a connection. Called right before the DCB itself is closed. */ virtual void finish_connection() = 0; /** * Handle connection limits. Currently the return value is ignored. * * @param limit Maximum number of connections * @return 1 on success, 0 on error */ virtual int32_t connlimit(int limit) { return 0; } /** * Return current database. Only required by query classifier. * * @return Current database */ virtual std::string current_db() const { return ""; } virtual ClientDCB* dcb() = 0; virtual const ClientDCB* dcb() const = 0; virtual void wakeup() { // Should not be called for non-supported protocols. mxb_assert(!true); } /** * Called when the session starts to stop * * This can be used to do any preparatory work that needs to be done before the actual shutdown is * started. At this stage the session is still valid and routing works normally. * * The default implementation does nothing. */ virtual void kill() { } }; /** * Partial client protocol implementation. More fields and functions may be added later. */ class ClientConnectionBase : public ClientConnection { public: json_t* diagnostics() const override; void set_dcb(DCB* dcb) override; ClientDCB* dcb() override; const ClientDCB* dcb() const override; protected: ClientDCB* m_dcb {nullptr}; /**< Dcb used by this protocol connection */ }; /** * Backend protocol connection interface. Only protocols with backend support need to implement this. */ class BackendConnection : public mxs::ProtocolConnection { public: virtual ~BackendConnection() = default; /** * Initialize a connection. * * @return True, if the connection could be initialized, false otherwise. */ virtual bool init_connection() = 0; /** * Finalize a connection. Called right before the DCB itself is closed. */ virtual void finish_connection() = 0; /** * Reuse a connection. The connection was in the persistent pool * and will now be taken into use again. * * @param dcb The connection to be reused. * @param upstream The upstream component. * * @return True, if the connection can be reused, false otherwise. * If @c false is returned, the @c dcb should be closed. */ virtual bool reuse_connection(BackendDCB* dcb, mxs::Component* upstream) = 0; /** * Check if the connection has been fully established, used by connection pooling * * @return True if the connection is fully established and can be pooled */ virtual bool established() = 0; /** * Ping a backend connection * * The backend connection should perform an action that keeps the connection alive if it is currently * idle. The idleness of a connection is determined at the protocol level and any actions taken at the * protocol level should not propagate upwards. * * What this means in practice is that if a query is used to ping a backend, the result should be * discarded and the pinging should not interrupt ongoing queries. */ virtual void ping() = 0; /** * Check if the connection can be closed in a controlled manner * * @return True if the connection can be closed without interruping anything */ virtual bool can_close() const = 0; /** * How many seconds has the connection been idle * * @return Number of seconds the connection has been idle */ virtual int64_t seconds_idle() const = 0; virtual const BackendDCB* dcb() const = 0; virtual BackendDCB* dcb() = 0; }; class UserAccountCache; /** * An interface which a user account manager must implement. The instance is shared between all threads. */ class UserAccountManager { public: virtual ~UserAccountManager() = default; /** * Start the user account manager. Should be called after creation. */ virtual void start() = 0; /** * Stop the user account manager. Should be called before destruction. */ virtual void stop() = 0; /** * Notify the manager that its data should be updated. The updating may happen * in a separate thread. */ virtual void update_user_accounts() = 0; /** * Set the username and password the manager should use when accessing backends. * * @param user Username * @param pw Password, possibly encrypted */ virtual void set_credentials(const std::string& user, const std::string& pw) = 0; virtual void set_backends(const std::vector<SERVER*>& backends) = 0; virtual void set_union_over_backends(bool union_over_backends) = 0; virtual void set_strip_db_esc(bool strip_db_esc) = 0; /** * Which protocol this manager can be used with. Currently, it's assumed that the user data managers * do not have listener-specific settings. If multiple listeners with the same protocol name feed * the same service, only one manager is required. */ virtual std::string protocol_name() const = 0; /** * Create a thread-local account cache linked to this account manager. * * @return A new user account cache */ virtual std::unique_ptr<UserAccountCache> create_user_account_cache() = 0; /** * Set owning service. * * @param service */ virtual void set_service(SERVICE* service) = 0; /** * Print contents to a json array. * * @return Users as json */ virtual json_t* users_to_json() const = 0; }; class UserAccountCache { public: virtual ~UserAccountCache() = default; virtual void update_from_master() = 0; }; template<class ProtocolImplementation> class ProtocolApiGenerator { public: ProtocolApiGenerator() = delete; ProtocolApiGenerator(const ProtocolApiGenerator&) = delete; ProtocolApiGenerator& operator=(const ProtocolApiGenerator&) = delete; static mxs::ProtocolModule* create_protocol_module() { // If protocols require non-authentication-related settings, add passing them here. // The unsolved issue is how to separate listener, protocol and authenticator-settings from // each other. Currently this is mostly a non-issue as the only authenticator with a setting // is gssapi. return ProtocolImplementation::create(); } static MXS_PROTOCOL_API s_api; }; template<class ProtocolImplementation> MXS_PROTOCOL_API ProtocolApiGenerator<ProtocolImplementation>::s_api = { &ProtocolApiGenerator<ProtocolImplementation>::create_protocol_module, }; }
28.565891
106
0.66332
Daniel-Xu
f3e15d6b4923bd907532dd59b3ffb3cca232094f
4,325
cxx
C++
Modules/IO/Base/src/itkRegularExpressionSeriesFileNames.cxx
CapeDrew/DCMTK-ITK
440bf8ed100445396912cfd0aa72f36d4cdefe0c
[ "Apache-2.0" ]
2
2015-06-19T07:18:36.000Z
2019-04-18T07:28:23.000Z
Modules/IO/Base/src/itkRegularExpressionSeriesFileNames.cxx
CapeDrew/DCMTK-ITK
440bf8ed100445396912cfd0aa72f36d4cdefe0c
[ "Apache-2.0" ]
null
null
null
Modules/IO/Base/src/itkRegularExpressionSeriesFileNames.cxx
CapeDrew/DCMTK-ITK
440bf8ed100445396912cfd0aa72f36d4cdefe0c
[ "Apache-2.0" ]
2
2017-05-02T07:18:49.000Z
2020-04-30T01:37:35.000Z
/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef _itkRegularExpressionSeriesFileNames_cxx #define _itkRegularExpressionSeriesFileNames_cxx #include <vector> #include <string.h> #include <stdlib.h> #include <algorithm> #include "itksys/SystemTools.hxx" #include "itksys/Directory.hxx" #include "itksys/RegularExpression.hxx" #include "itkRegularExpressionSeriesFileNames.h" struct lt_pair_numeric_string_string { bool operator()(const std::pair< std::string, std::string > s1, const std::pair< std::string, std::string > s2) const { return atof( s1.second.c_str() ) < atof( s2.second.c_str() ); } }; struct lt_pair_alphabetic_string_string { bool operator()(const std::pair< std::string, std::string > s1, const std::pair< std::string, std::string > s2) const { return s1.second < s2.second; } }; namespace itk { const std::vector< std::string > & RegularExpressionSeriesFileNames ::GetFileNames() { // Validate the ivars if ( m_Directory == "" ) { itkExceptionMacro (<< "No directory defined!"); } itksys::RegularExpression reg; if ( !reg.compile( m_RegularExpression.c_str() ) ) { itkExceptionMacro(<< "Error compiling regular expression " << m_RegularExpression); } // Process all files in the directory itksys::Directory fileDir; if ( !fileDir.Load ( m_Directory.c_str() ) ) { itkExceptionMacro (<< "Directory " << m_Directory.c_str() << " cannot be read!"); } std::vector< std::pair< std::string, std::string > > sortedBySubMatch; // Scan directory for files. Each file is checked to see if it // matches the m_RegularExpression. for ( unsigned long i = 0; i < fileDir.GetNumberOfFiles(); i++ ) { // Only read files if ( itksys::SystemTools::FileIsDirectory( ( m_Directory + "/" + fileDir.GetFile(i) ).c_str() ) ) { continue; } if ( reg.find( fileDir.GetFile(i) ) ) { // Store the full filename and the selected sub expression match std::pair< std::string, std::string > fileNameMatch; fileNameMatch.first = m_Directory + "/" + fileDir.GetFile(i); fileNameMatch.second = reg.match(m_SubMatch); sortedBySubMatch.push_back(fileNameMatch); } } // Sort the files. The files are sorted by the sub match defined by // m_SubMatch. Sorting can be alpahbetic or numeric. if ( m_NumericSort ) { std::sort( sortedBySubMatch.begin(), sortedBySubMatch.end(), lt_pair_numeric_string_string() ); } else { std::sort( sortedBySubMatch.begin(), sortedBySubMatch.end(), lt_pair_alphabetic_string_string() ); } // Now, store the sorted names in a vector m_FileNames.clear(); std::vector< std::pair< std::string, std::string > >::iterator siter; for ( siter = sortedBySubMatch.begin(); siter != sortedBySubMatch.end(); siter++ ) { m_FileNames.push_back( ( *siter ).first ); } return m_FileNames; } void RegularExpressionSeriesFileNames ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); os << indent << "Directory: " << m_Directory << std::endl; os << indent << "SubMatch: " << m_SubMatch << std::endl; os << indent << "NumericSort: " << m_NumericSort << std::endl; os << indent << "RegularExpression: " << m_RegularExpression << std::endl; for ( unsigned int i = 0; i < m_FileNames.size(); i++ ) { os << indent << "Filenames[" << i << "]: " << m_FileNames[i] << std::endl; } } } //namespace ITK #endif
30.457746
101
0.631445
CapeDrew
f3e1a955c90fa3020065005b71c325296758dea0
1,822
hpp
C++
libs/fnd/cmath/include/bksge/fnd/cmath/detail/sph_neumann_impl.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
4
2018-06-10T13:35:32.000Z
2021-06-03T14:27:41.000Z
libs/fnd/cmath/include/bksge/fnd/cmath/detail/sph_neumann_impl.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
566
2017-01-31T05:36:09.000Z
2022-02-09T05:04:37.000Z
libs/fnd/cmath/include/bksge/fnd/cmath/detail/sph_neumann_impl.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
1
2018-07-05T04:40:53.000Z
2018-07-05T04:40:53.000Z
/** * @file sph_neumann_impl.hpp * * @brief sph_neumann 関数の実装 * * @author myoukaku */ #ifndef BKSGE_FND_CMATH_DETAIL_SPH_NEUMANN_IMPL_HPP #define BKSGE_FND_CMATH_DETAIL_SPH_NEUMANN_IMPL_HPP #include <bksge/fnd/cmath/isnan.hpp> #include <bksge/fnd/cmath/detail/sph_bessel_jn.hpp> #include <bksge/fnd/type_traits/float_promote.hpp> #include <bksge/fnd/config.hpp> #include <cmath> #include <limits> namespace bksge { namespace detail { #if defined(__cpp_lib_math_special_functions) && (__cpp_lib_math_special_functions >= 201603) inline /*BKSGE_CONSTEXPR*/ double sph_neumann_unchecked(unsigned int n, double x) { return std::sph_neumann(n, x); } inline /*BKSGE_CONSTEXPR*/ float sph_neumann_unchecked(unsigned int n, float x) { return std::sph_neumannf(n, x); } inline /*BKSGE_CONSTEXPR*/ long double sph_neumann_unchecked(unsigned int n, long double x) { return std::sph_neumannl(n, x); } #else template <typename T> inline BKSGE_CXX14_CONSTEXPR T sph_neumann_unchecked_2(unsigned int n, T x) { T j_n, n_n, jp_n, np_n; bksge::detail::sph_bessel_jn(n, x, j_n, n_n, jp_n, np_n); return n_n; } template <typename T> inline BKSGE_CXX14_CONSTEXPR T sph_neumann_unchecked(unsigned int n, T x) { using value_type = bksge::float_promote_t<double, T>; return static_cast<T>(sph_neumann_unchecked_2(n, static_cast<value_type>(x))); } #endif template <typename T> inline BKSGE_CXX14_CONSTEXPR T sph_neumann_impl(unsigned int n, T x) { if (bksge::isnan(x)) { return std::numeric_limits<T>::quiet_NaN(); } if (x == T(0)) { return -std::numeric_limits<T>::infinity(); } return sph_neumann_unchecked(n, x); } } // namespace detail } // namespace bksge #endif // BKSGE_FND_CMATH_DETAIL_SPH_NEUMANN_IMPL_HPP
20.704545
94
0.716246
myoukaku
f3e5e1b8f97aef49070a35dc7a03dac8f4816e6d
495
cpp
C++
examples/example3.cpp
waqqas/boost_sqlite
5946f1d91a71e1bbc94da9270caef78d104873af
[ "BSD-3-Clause" ]
2
2021-04-12T05:49:15.000Z
2021-06-22T06:40:13.000Z
examples/example3.cpp
waqqas/boost_sqlite
5946f1d91a71e1bbc94da9270caef78d104873af
[ "BSD-3-Clause" ]
null
null
null
examples/example3.cpp
waqqas/boost_sqlite
5946f1d91a71e1bbc94da9270caef78d104873af
[ "BSD-3-Clause" ]
1
2020-11-09T10:09:07.000Z
2020-11-09T10:09:07.000Z
#include "sqliter/sqliter.h" #include <iostream> #include <string> using namespace sqliter::asio; int main(int argc, char *argv[]) { boost::asio::io_service io; sqlite db(io); if (argc != 2) { std::cout << argv[0] << " <sqlite db file>" << std::endl; return -1; } db.open(argv[1]); boost::system::error_code ec; db.query("SELECT * from app", ec); std::cout << "Result: " << ec.message() << std::endl; io.run(); db.close(ec); return 0; }
15.967742
61
0.563636
waqqas
f3e63b07283666bfe6aacb4e9e2fbb7fd86d626f
1,025
cpp
C++
Pdf/pdfix_sdk_example_cpp-master/src/StandardLicenseDeactivate.cpp
laoola/ProjectCode
498a66cb9274f6bb7cca0d6e6052304d61740ba2
[ "Unlicense" ]
1
2021-08-23T05:56:09.000Z
2021-08-23T05:56:09.000Z
Pdf/pdfix_sdk_example_cpp-master/src/StandardLicenseDeactivate.cpp
laoola/ProjectCode
498a66cb9274f6bb7cca0d6e6052304d61740ba2
[ "Unlicense" ]
null
null
null
Pdf/pdfix_sdk_example_cpp-master/src/StandardLicenseDeactivate.cpp
laoola/ProjectCode
498a66cb9274f6bb7cca0d6e6052304d61740ba2
[ "Unlicense" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////////////////////////// // StandardLicenseDeactivate.cpp // Copyright (c) 2019 Pdfix. All Rights Reserved. //////////////////////////////////////////////////////////////////////////////////////////////////// #include "pdfixsdksamples/StandardLicenseDeactivate.h" // system #include <string> #include <iostream> // other libraries #include "Pdfix.h" using namespace PDFixSDK; namespace StandardLicenseDeactivate { // Adds a new text annotation. void Run() { // initialize Pdfix if (!Pdfix_init(Pdfix_MODULE_NAME)) throw std::runtime_error("Pdfix initialization fail"); Pdfix* pdfix = GetPdfix(); if (!pdfix) throw std::runtime_error("GetPdfix fail"); auto authorization = pdfix->GetStandardAuthorization(); if (!authorization) throw PdfixException(); if (!authorization->Deactivate()) throw PdfixException(); pdfix->Destroy(); } } //! [StandardLicenseDeactivate_cpp]
26.973684
100
0.555122
laoola
f3ed2cfa2c8d264ea5ee1ea206ca9e13f3b1e6c1
1,405
hpp
C++
player/playerlib/android/render/MemcopyRender.hpp
zhenfei2016/FFL-v2
376c79a0611af580d4767a4bbb05822f1a4fd454
[ "MIT" ]
null
null
null
player/playerlib/android/render/MemcopyRender.hpp
zhenfei2016/FFL-v2
376c79a0611af580d4767a4bbb05822f1a4fd454
[ "MIT" ]
null
null
null
player/playerlib/android/render/MemcopyRender.hpp
zhenfei2016/FFL-v2
376c79a0611af580d4767a4bbb05822f1a4fd454
[ "MIT" ]
null
null
null
/* * This file is part of FFL project. * * The MIT License (MIT) * Copyright (C) 2017-2018 zhufeifei All rights reserved. * * MemcopyRender.hpp * Created by zhufeifei(34008081@qq.com) on 2018/06/28 * https://github.com/zhenfei2016/FFL-v2.git * android ANativewindow数据拷贝显示方式 * */ #include "RenderInterface.hpp" #include "VideoFormat.hpp" namespace android{ class MemcopyRender : public RenderInterface{ public: MemcopyRender(); ~MemcopyRender(); public: // 获取支持的格式 // wanted: 如果为nUll则返回所有支持的格式 // 非null 返回跟他匹配的 // fmtList: 返回支持的格式list // virtual void getSupportFormat(player::VideoSurface* surface,const player::VideoFormat* wanted,FFL::List<player::VideoFormat>& fmtList); virtual bool getOptimalFormat(player::VideoSurface* surface,const player::VideoFormat* wanted,player::VideoFormat* optinal); virtual bool isSupportFormat(player::VideoSurface* surface,const player::VideoFormat* wanted); // // 创建这个render ,arg自定义的参数 // virtual status_t create(player::VideoSurface* surface,const player::VideoFormat* arg); // // 绘制图片tex到 surface上面 // virtual status_t draw(player::VideoSurface* surface,player::VideoTexture* tex); // // 释放这个render,释放后这个render就不可用了 // virtual void destroy(); }; }
33.452381
143
0.649822
zhenfei2016
f3f04d0fe9e13ec4f724e2c3d44bd42d5425d784
804
cpp
C++
sa2-battle-network/OnGameState.cpp
michael-fadely/sa2-battle-network
c8391dc5fdc9f1b6fc6c0c5020bbe4baabbb0aff
[ "MIT" ]
13
2019-06-29T19:38:46.000Z
2022-01-27T07:52:15.000Z
sa2-battle-network/OnGameState.cpp
SonicFreak94/sa2-battle-network
c8391dc5fdc9f1b6fc6c0c5020bbe4baabbb0aff
[ "MIT" ]
37
2015-10-17T08:33:42.000Z
2018-03-11T03:10:04.000Z
sa2-battle-network/OnGameState.cpp
SonicFreak94/sa2-battle-network
c8391dc5fdc9f1b6fc6c0c5020bbe4baabbb0aff
[ "MIT" ]
1
2021-09-17T06:50:34.000Z
2021-09-17T06:50:34.000Z
#include "stdafx.h" #include <SA2ModLoader.h> // for everything #include "Networking.h" // for MessageID #include "globals.h" #include "OnGameState.h" DataPointer(uint, dword_174B058, 0x174B058); // Note that the name is misleading. This only happens when the gamestate changes to Ingame. // TODO: Real OnGameState // TODO: Consider removing since PoseEffect2PStartMan is now synchronized static void __stdcall OnGameState() { using namespace nethax; using namespace globals; // This is here because we overwrite its assignment with a call // in the original code. dword_174B058 = 0; if (!is_connected()) { return; } broker->send_ready_and_wait(MessageID::S_GameState); } // TODO: Make revertible void nethax::events::InitOnGameState() { WriteCall((void*)0x0043AAEE, OnGameState); }
22.333333
92
0.748756
michael-fadely
f3f15b4488dabbd980c8a269c993305fe37e475f
34,525
hpp
C++
src/include/sweet/sphere/SphereData_Spectral.hpp
valentinaschueller/sweet
27e99c7a110c99deeadee70688c186d82b39ac90
[ "MIT" ]
6
2017-11-20T08:12:46.000Z
2021-03-11T15:32:36.000Z
src/include/sweet/sphere/SphereData_Spectral.hpp
valentinaschueller/sweet
27e99c7a110c99deeadee70688c186d82b39ac90
[ "MIT" ]
4
2018-02-02T21:46:33.000Z
2022-01-11T11:10:27.000Z
src/include/sweet/sphere/SphereData_Spectral.hpp
valentinaschueller/sweet
27e99c7a110c99deeadee70688c186d82b39ac90
[ "MIT" ]
12
2016-03-01T18:33:34.000Z
2022-02-08T22:20:31.000Z
/* * SphereData.hpp * * Created on: 9 Aug 2016 * Author: Martin Schreiber <schreiberx@gmail.com> */ #ifndef SWEET_SPHERE_DATA_SPECTRAL_HPP_ #define SWEET_SPHERE_DATA_SPECTRAL_HPP_ #include <complex> #include <functional> #include <array> #include <cstring> #include <iostream> #include <fstream> #include <iomanip> #include <cassert> #include <limits> #include <utility> #include <functional> #include <cmath> #include <sweet/parmemcpy.hpp> #include <sweet/MemBlockAlloc.hpp> #include <sweet/openmp_helper.hpp> #include <sweet/sphere/SphereData_Config.hpp> #include <sweet/sphere/SphereData_Physical.hpp> #include <sweet/sphere/SphereData_PhysicalComplex.hpp> #include <sweet/SWEETError.hpp> class SphereData_Spectral { friend class SphereData_SpectralComplex; typedef std::complex<double> Tcomplex; public: const SphereData_Config *sphereDataConfig = nullptr; public: std::complex<double> *spectral_space_data = nullptr; std::complex<double>& operator[](std::size_t i) { return spectral_space_data[i]; } const std::complex<double>& operator[](std::size_t i) const { return spectral_space_data[i]; } void swap( SphereData_Spectral &i_sphereData ) { assert(sphereDataConfig == i_sphereData.sphereDataConfig); std::swap(spectral_space_data, i_sphereData.spectral_space_data); } public: SphereData_Spectral( const SphereData_Config *i_sphereDataConfig ) : sphereDataConfig(i_sphereDataConfig), spectral_space_data(nullptr) { assert(i_sphereDataConfig != 0); setup(i_sphereDataConfig); } public: SphereData_Spectral( const SphereData_Config *i_sphereDataConfig, const std::complex<double> &i_value ) : sphereDataConfig(i_sphereDataConfig), spectral_space_data(nullptr) { assert(i_sphereDataConfig != 0); setup(i_sphereDataConfig); spectral_set_value(i_value); } public: SphereData_Spectral( const SphereData_Config *i_sphereDataConfig, double &i_value ) : sphereDataConfig(i_sphereDataConfig), spectral_space_data(nullptr) { assert(i_sphereDataConfig != 0); setup(i_sphereDataConfig); spectral_set_value(i_value); } public: SphereData_Spectral() : sphereDataConfig(nullptr), spectral_space_data(nullptr) { } public: SphereData_Spectral( const SphereData_Spectral &i_sph_data ) : sphereDataConfig(i_sph_data.sphereDataConfig), spectral_space_data(nullptr) { if (i_sph_data.sphereDataConfig == nullptr) return; alloc_data(); operator=(i_sph_data); } public: SphereData_Spectral( SphereData_Spectral &&i_sph_data ) : sphereDataConfig(i_sph_data.sphereDataConfig), spectral_space_data(nullptr) { if (i_sph_data.sphereDataConfig == nullptr) return; alloc_data(); spectral_space_data = i_sph_data.spectral_space_data; } /** * Run validation checks to make sure that the physical and spectral spaces match in size */ public: inline void check( const SphereData_Config *i_sphereDataConfig ) const { assert(sphereDataConfig->physical_num_lat == i_sphereDataConfig->physical_num_lat); assert(sphereDataConfig->physical_num_lon == i_sphereDataConfig->physical_num_lon); assert(sphereDataConfig->spectral_modes_m_max == i_sphereDataConfig->spectral_modes_m_max); assert(sphereDataConfig->spectral_modes_n_max == i_sphereDataConfig->spectral_modes_n_max); } public: SphereData_Spectral& operator=( const SphereData_Spectral &i_sph_data ) { if (i_sph_data.sphereDataConfig == nullptr) return *this; if (sphereDataConfig == nullptr) setup(i_sph_data.sphereDataConfig); parmemcpy(spectral_space_data, i_sph_data.spectral_space_data, sizeof(Tcomplex)*sphereDataConfig->spectral_array_data_number_of_elements); return *this; } /** * This function implements copying the spectral data only. * * This becomes handy if coping with data which should be only transformed without dealiasing. */ public: SphereData_Spectral& load_nodealiasing( const SphereData_Spectral &i_sph_data ///< data to be converted to sphereDataConfig_nodealiasing ) { if (sphereDataConfig == nullptr) SWEETError("sphereDataConfig not initialized"); parmemcpy(spectral_space_data, i_sph_data.spectral_space_data, sizeof(Tcomplex)*sphereDataConfig->spectral_array_data_number_of_elements); return *this; } public: SphereData_Spectral& operator=( SphereData_Spectral &&i_sph_data ) { if (sphereDataConfig == nullptr) setup(i_sph_data.sphereDataConfig); std::swap(spectral_space_data, i_sph_data.spectral_space_data); return *this; } public: SphereData_Spectral spectral_returnWithDifferentModes( const SphereData_Config *i_sphereDataConfig ) const { SphereData_Spectral out(i_sphereDataConfig); /* * 0 = invalid * -1 = scale down * 1 = scale up */ int scaling_mode = 0; if (sphereDataConfig->spectral_modes_m_max < out.sphereDataConfig->spectral_modes_m_max) { scaling_mode = 1; } else if (sphereDataConfig->spectral_modes_m_max > out.sphereDataConfig->spectral_modes_m_max) { scaling_mode = -1; } if (sphereDataConfig->spectral_modes_n_max < out.sphereDataConfig->spectral_modes_n_max) { assert(scaling_mode != -1); scaling_mode = 1; } else if (sphereDataConfig->spectral_modes_n_max > out.sphereDataConfig->spectral_modes_n_max) { assert(scaling_mode != 1); scaling_mode = -1; } if (scaling_mode == 0) { // Just copy the data out = *this; return out; } if (scaling_mode == -1) { /* * more modes -> less modes */ SWEET_THREADING_SPACE_PARALLEL_FOR for (int m = 0; m <= out.sphereDataConfig->spectral_modes_m_max; m++) { Tcomplex *dst = &out.spectral_space_data[out.sphereDataConfig->getArrayIndexByModes(m, m)]; Tcomplex *src = &spectral_space_data[sphereDataConfig->getArrayIndexByModes(m, m)]; std::size_t size = sizeof(Tcomplex)*(out.sphereDataConfig->spectral_modes_n_max-m+1); memcpy(dst, src, size); } } else { /* * less modes -> more modes */ // zero all values out.spectral_set_zero(); SWEET_THREADING_SPACE_PARALLEL_FOR for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { Tcomplex *dst = &out.spectral_space_data[out.sphereDataConfig->getArrayIndexByModes(m, m)]; Tcomplex *src = &spectral_space_data[sphereDataConfig->getArrayIndexByModes(m, m)]; std::size_t size = sizeof(Tcomplex)*(sphereDataConfig->spectral_modes_n_max-m+1); memcpy(dst, src, size); } } return out; } /* * Setup spectral sphere data based on data in physical space */ void loadSphereDataPhysical( const SphereData_Physical &i_sphereDataPhysical ) { /** * Warning: The sphat_to_SH function is an in-situ operation. * Therefore, the data in the source array will be destroyed. * Hence, we create a copy */ SphereData_Physical tmp(i_sphereDataPhysical); spat_to_SH(sphereDataConfig->shtns, tmp.physical_space_data, spectral_space_data); } /* * Return the data converted to physical space */ SphereData_Physical getSphereDataPhysical() const { /** * Warning: This is an in-situ operation. * Therefore, the data in the source array will be destroyed. */ SphereData_Spectral tmp(*this); SphereData_Physical retval(sphereDataConfig); SH_to_spat(sphereDataConfig->shtns, tmp.spectral_space_data, retval.physical_space_data); return retval; } /* * Return the data converted to physical space * * alias for "getSphereDataPhysical" */ SphereData_Physical toPhys() const { /** * Warning: This is an in-situ operation. * Therefore, the data in the source array will be destroyed. */ SphereData_Spectral tmp(*this); SphereData_Physical retval(sphereDataConfig); SH_to_spat(sphereDataConfig->shtns, tmp.spectral_space_data, retval.physical_space_data); return retval; } SphereData_PhysicalComplex getSphereDataPhysicalComplex() const { SphereData_PhysicalComplex out(sphereDataConfig); /* * WARNING: * We have to use a temporary array here because of destructive SH transformations */ SphereData_Spectral tmp_spectral(*this); SphereData_Physical tmp_physical(sphereDataConfig); SH_to_spat(sphereDataConfig->shtns, tmp_spectral.spectral_space_data, tmp_physical.physical_space_data); parmemcpy(out.physical_space_data, tmp_physical.physical_space_data, sizeof(double)*sphereDataConfig->physical_array_data_number_of_elements); return out; } SphereData_Spectral( const SphereData_Physical &i_sphere_data_physical ) { setup(i_sphere_data_physical.sphereDataConfig); loadSphereDataPhysical(i_sphere_data_physical); } SphereData_Spectral operator+( const SphereData_Spectral &i_sph_data ) const { check(i_sph_data.sphereDataConfig); SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = spectral_space_data[idx] + i_sph_data.spectral_space_data[idx]; return out; } SphereData_Spectral& operator+=( const SphereData_Spectral &i_sph_data ) { check(i_sph_data.sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) spectral_space_data[idx] += i_sph_data.spectral_space_data[idx]; return *this; } SphereData_Spectral& operator-=( const SphereData_Spectral &i_sph_data ) { check(i_sph_data.sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) spectral_space_data[idx] -= i_sph_data.spectral_space_data[idx]; return *this; } SphereData_Spectral operator-( const SphereData_Spectral &i_sph_data ) const { check(i_sph_data.sphereDataConfig); SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = spectral_space_data[idx] - i_sph_data.spectral_space_data[idx]; return out; } SphereData_Spectral operator-() const { SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = -spectral_space_data[idx]; return out; } SphereData_Spectral operator*( const SphereData_Spectral &i_sph_data ) const { check(i_sph_data.sphereDataConfig); SphereData_Physical a = getSphereDataPhysical(); SphereData_Physical b = i_sph_data.toPhys(); SphereData_Physical mul(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (std::size_t i = 0; i < sphereDataConfig->physical_array_data_number_of_elements; i++) mul.physical_space_data[i] = a.physical_space_data[i]*b.physical_space_data[i]; SphereData_Spectral out(mul); return out; } SphereData_Spectral operator/( const SphereData_Spectral &i_sph_data ) const { check(i_sph_data.sphereDataConfig); SphereData_Physical a = getSphereDataPhysical(); SphereData_Physical b = i_sph_data.toPhys(); SphereData_Physical div(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (std::size_t i = 0; i < sphereDataConfig->physical_array_data_number_of_elements; i++) div.physical_space_data[i] = a.physical_space_data[i]/b.physical_space_data[i]; SphereData_Spectral out(div); return out; } SphereData_Spectral operator*( double i_value ) const { SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = spectral_space_data[idx]*i_value; return out; } const SphereData_Spectral& operator*=( double i_value ) const { SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) spectral_space_data[idx] *= i_value; return *this; } const SphereData_Spectral& operator/=( double i_value ) const { SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) spectral_space_data[idx] /= i_value; return *this; } const SphereData_Spectral& operator*=( const std::complex<double> &i_value ) const { SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) spectral_space_data[idx] *= i_value; return *this; } SphereData_Spectral operator/( double i_value ) const { SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = spectral_space_data[idx]/i_value; return out; } SphereData_Spectral operator+( double i_value ) const { SphereData_Spectral out(*this); out.spectral_space_data[0] += i_value*std::sqrt(4.0*M_PI); return out; } SphereData_Spectral operator_scalar_sub_this( double i_value ) const { SphereData_Spectral out(sphereDataConfig); SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int idx = 0; idx < sphereDataConfig->spectral_array_data_number_of_elements; idx++) out.spectral_space_data[idx] = -spectral_space_data[idx]; out.spectral_space_data[0] = i_value*std::sqrt(4.0*M_PI) + out.spectral_space_data[0]; return out; } const SphereData_Spectral& operator+=( double i_value ) const { spectral_space_data[0] += i_value*std::sqrt(4.0*M_PI); return *this; } SphereData_Spectral operator-( double i_value ) const { SphereData_Spectral out(*this); out.spectral_space_data[0] -= i_value*std::sqrt(4.0*M_PI); return out; } SphereData_Spectral& operator-=( double i_value ) { spectral_space_data[0] -= i_value*std::sqrt(4.0*M_PI); return *this; } public: void setup( const SphereData_Config *i_sphereDataConfig ) { sphereDataConfig = i_sphereDataConfig; alloc_data(); } public: void setup( const SphereData_Config *i_sphereDataConfig, double i_value ) { sphereDataConfig = i_sphereDataConfig; alloc_data(); spectral_set_value(i_value); } private: void alloc_data() { assert(spectral_space_data == nullptr); spectral_space_data = MemBlockAlloc::alloc<Tcomplex>(sphereDataConfig->spectral_array_data_number_of_elements * sizeof(Tcomplex)); } public: void setup_if_required( const SphereData_Config *i_sphereDataConfig ) { if (sphereDataConfig != nullptr) return; setup(i_sphereDataConfig); } public: void free() { if (spectral_space_data != nullptr) { MemBlockAlloc::free(spectral_space_data, sphereDataConfig->spectral_array_data_number_of_elements * sizeof(Tcomplex)); spectral_space_data = nullptr; sphereDataConfig = nullptr; } } public: ~SphereData_Spectral() { free(); } /** * Solve a Helmholtz problem given by * * (a + b D^2) x = rhs */ inline SphereData_Spectral spectral_solve_helmholtz( const double &i_a, const double &i_b, double r ) { SphereData_Spectral out(*this); const double a = i_a; const double b = i_b/(r*r); out.spectral_update_lambda( [&]( int n, int m, std::complex<double> &io_data ) { io_data /= (a + (-b*(double)n*((double)n+1.0))); } ); return out; } /** * Solve a Laplace problem given by * * (D^2) x = rhs */ inline SphereData_Spectral spectral_solve_laplace( double r ) { SphereData_Spectral out(*this); const double b = 1.0/(r*r); out.spectral_update_lambda( [&]( int n, int m, std::complex<double> &io_data ) { if (n == 0) io_data = 0; else io_data /= (-b*(double)n*((double)n+1.0)); } ); return out; } /** * Truncate modes which are not representable in spectral space */ const SphereData_Spectral& spectral_truncate() const { SphereData_Physical tmp(sphereDataConfig); SH_to_spat(sphereDataConfig->shtns, spectral_space_data, tmp.physical_space_data); spat_to_SH(sphereDataConfig->shtns, tmp.physical_space_data, spectral_space_data); return *this; } void spectral_update_lambda( std::function<void(int,int,Tcomplex&)> i_lambda ) { SWEET_THREADING_SPACE_PARALLEL_FOR for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max; n++) { i_lambda(n, m, spectral_space_data[idx]); idx++; } } } const std::complex<double>& spectral_get_DEPRECATED( int i_n, int i_m ) const { static const std::complex<double> zero = {0,0}; if (i_n < 0 || i_m < 0) return zero; if (i_n > sphereDataConfig->spectral_modes_n_max) return zero; if (i_m > sphereDataConfig->spectral_modes_m_max) return zero; if (i_m > i_n) return zero; assert (i_m <= sphereDataConfig->spectral_modes_m_max); return spectral_space_data[sphereDataConfig->getArrayIndexByModes(i_n, i_m)]; } const std::complex<double>& spectral_get_( int i_n, int i_m ) const { assert(i_n >= 0 && i_m >= 0); assert(i_n <= sphereDataConfig->spectral_modes_n_max); assert(i_m <= sphereDataConfig->spectral_modes_m_max); assert(i_m <= i_n); return spectral_space_data[sphereDataConfig->getArrayIndexByModes(i_n, i_m)]; } void spectral_set( int i_n, int i_m, const std::complex<double> &i_data ) const { #if SWEET_DEBUG if (i_n < 0 || i_m < 0) SWEETError("Out of boundary a"); if (i_n > sphereDataConfig->spectral_modes_n_max) SWEETError("Out of boundary b"); if (i_m > sphereDataConfig->spectral_modes_m_max) SWEETError("Out of boundary c"); if (i_m > i_n) SWEETError("Out of boundary d"); assert (i_m <= sphereDataConfig->spectral_modes_m_max); #endif spectral_space_data[sphereDataConfig->getArrayIndexByModes(i_n, i_m)] = i_data; } /* * Set all values to zero */ void spectral_set_zero() { SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int i = 0; i < sphereDataConfig->spectral_array_data_number_of_elements; i++) spectral_space_data[i] = {0,0}; } /* * Set all values to value */ void spectral_set_value( const std::complex<double> &i_value ) { SWEET_THREADING_SPACE_PARALLEL_FOR_SIMD for (int i = 0; i < sphereDataConfig->spectral_array_data_number_of_elements; i++) spectral_space_data[i] = i_value; } /* * Add a constant in physical space by adding the corresponding value in spectral space */ void spectral_add_physical_constant( double i_value ) const { this->spectral_space_data[0] += i_value*std::sqrt(4.0*M_PI); } /** * return the maximum of all absolute values, use quad precision for reduction */ std::complex<double> spectral_reduce_sum_quad_increasing() const { std::complex<double> sum = 0; std::complex<double> c = 0; #if SWEET_THREADING_SPACE //#pragma omp parallel for PROC_BIND_CLOSE reduction(+:sum,c) #endif for (int i = 0; i < sphereDataConfig->spectral_array_data_number_of_elements; i++) { std::complex<double> value = spectral_space_data[i]*(double)i; // Use Kahan summation std::complex<double> y = value - c; std::complex<double> t = sum + y; c = (t - sum) - y; sum = t; } sum -= c; return sum; } /** * return the sum of all values, use quad precision for reduction */ std::complex<double> spectral_reduce_sum_quad() const { std::complex<double> sum = 0; std::complex<double> c = 0; #if SWEET_THREADING_SPACE //#pragma omp parallel for PROC_BIND_CLOSE reduction(+:sum,c) #endif for (int i = 0; i < sphereDataConfig->spectral_array_data_number_of_elements; i++) { std::complex<double> value = spectral_space_data[i]; // Use Kahan summation std::complex<double> y = value - c; std::complex<double> t = sum + y; c = (t - sum) - y; sum = t; } sum -= c; return sum; } /** * return the sum of squares of all values, use quad precision for reduction * Important: Since m=0 modes appear only once and m>0 appear twice in the full spectrum */ double spectral_reduce_sum_sqr_quad() const { std::complex<double> sum = 0; //std::complex<double> c = 0; //m=0 case - weight 1 std::size_t idx = sphereDataConfig->getArrayIndexByModes(0, 0); for (int n = 0; n <= sphereDataConfig->spectral_modes_n_max; n++) { sum += spectral_space_data[idx]*std::conj(spectral_space_data[idx]); idx++; } //m>0 case - weight 2, as they appear twice for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max; n++) { sum += 2.0*spectral_space_data[idx]*std::conj(spectral_space_data[idx]); idx++; } } return sum.real(); } /** * Return the minimum value */ std::complex<double> spectral_reduce_min() const { std::complex<double> error = std::numeric_limits<double>::infinity(); for (int j = 0; j < sphereDataConfig->spectral_array_data_number_of_elements; j++) { error.real(std::min(spectral_space_data[j].real(), error.real())); error.imag(std::min(spectral_space_data[j].imag(), error.imag())); } return error; } /** * Return the max value */ std::complex<double> spectral_reduce_max() const { std::complex<double> error = -std::numeric_limits<double>::infinity(); for (int j = 0; j < sphereDataConfig->spectral_array_data_number_of_elements; j++) { error.real(std::max(spectral_space_data[j].real(), error.real())); error.imag(std::max(spectral_space_data[j].imag(), error.imag())); } return error; } /** * Return the max abs value */ double spectral_reduce_max_abs() const { double error = -std::numeric_limits<double>::infinity(); std::complex<double> w = {0,0}; for (int j = 0; j < sphereDataConfig->spectral_array_data_number_of_elements; j++) { w = spectral_space_data[j]*std::conj(spectral_space_data[j]); error = std::max(std::abs(w), error); } return error; } /** * Return the minimum abs value */ double spectral_reduce_min_abs() const { double error = std::numeric_limits<double>::infinity(); std::complex<double> w = {0,0}; for (int j = 0; j < sphereDataConfig->spectral_array_data_number_of_elements; j++) { w = spectral_space_data[j]*std::conj(spectral_space_data[j]); error = std::min(std::abs(w), error); } return error; } bool spectral_reduce_is_any_nan_or_inf() const { bool retval = false; #if SWEET_THREADING_SPACE #pragma omp parallel for simd reduction(|:retval) #endif for (int j = 0; j < sphereDataConfig->spectral_array_data_number_of_elements; j++) { retval |= std::isnan(spectral_space_data[j].real()); retval |= std::isinf(spectral_space_data[j].real()); retval |= std::isnan(spectral_space_data[j].imag()); retval |= std::isinf(spectral_space_data[j].imag()); } return retval; } bool spectral_is_first_nan_or_inf() const { bool retval = false; retval |= std::isnan(spectral_space_data[0].real()); retval |= std::isinf(spectral_space_data[0].real()); retval |= std::isnan(spectral_space_data[0].imag()); retval |= std::isinf(spectral_space_data[0].imag()); return retval; } void spectral_print( int i_precision = 16, double i_abs_threshold = -1 ) const { std::cout << std::setprecision(i_precision); std::cout << "m \\ n ----->" << std::endl; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max; n++) { if (std::abs(spectral_space_data[idx]) < i_abs_threshold) std::cout << 0 << "\t"; else std::cout << spectral_space_data[idx] << "\t"; idx++; } std::cout << std::endl; } } void spectral_structure_print( int i_precision = 16, double i_abs_threshold = -1 ) const { std::cout << std::setprecision(i_precision); std::cout << "m \\ n ----->" << std::endl; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { //std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max; n++) { std::cout << "(" << m <<"," << n <<")" << "\t"; } std::cout << std::endl; } } void spectrum_file_write( const std::string &i_filename, const char *i_title = "", int i_precision = 20 ) const { std::ofstream file(i_filename, std::ios_base::trunc); file << std::setprecision(i_precision); file << "#SWEET_SPHERE_SPECTRAL_DATA_ASCII" << std::endl; file << "#TI " << i_title << std::endl; // Use 0 to make it processable by python file << "0\t"; std::complex<double> w = {0,0}; std::vector<double> sum(sphereDataConfig->spectral_modes_n_max+1,0); std::vector<double> sum_squared(sphereDataConfig->spectral_modes_n_max+1,0); std::vector<double> max(sphereDataConfig->spectral_modes_n_max+1,0); for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max; n++) { w = spectral_space_data[idx]; idx++; sum[n] += std::abs(w); sum_squared[n] += std::abs(w * w); if (std::abs(w) >= max[n]) max[n] = std::abs(w); } } file << sphereDataConfig->spectral_modes_m_max << " " << sphereDataConfig->spectral_modes_n_max << std::endl; for (int n = 0; n <= sphereDataConfig->spectral_modes_n_max; n++) file << n << " " << sum[n] << " " << max[n] << " " << std::sqrt(sum_squared[n]) << std::endl; file.close(); } void spectrum_abs_file_write_line( const std::string &i_filename, const char *i_title = "", const double i_time = 0.0, int i_precision = 20, double i_abs_threshold = -1, int i_reduce_mode_factor = 1 ) const { std::ofstream file; if(i_time == 0.0){ file.open(i_filename, std::ios_base::trunc); file << std::setprecision(i_precision); file << "#SWEET_SPHERE_SPECTRAL_ABS_EVOL_ASCII" << std::endl; file << "#TI " << i_title << std::endl; file << "0\t"<< std::endl; // Use 0 to make it processable by python file << "(n_max="<<sphereDataConfig->spectral_modes_n_max << " m_max=" << sphereDataConfig->spectral_modes_n_max << ")" << std::endl; file << "timestamp\t" ; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max/i_reduce_mode_factor; m++) { //std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max/i_reduce_mode_factor; n++) { file << "(" << n << ";" << m << ")\t" ; } } file<< "SpectralSum" <<std::endl; } else{ file.open(i_filename, std::ios_base::app); file << std::setprecision(i_precision); } std::complex<double> w = {0,0}; double wabs = 0.0; double sum = 0.0; //std::cout << "n" << " " << "m" << " " << "norm" <<std::endl; file << i_time << "\t"; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max/i_reduce_mode_factor; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max/i_reduce_mode_factor; n++) { w = spectral_space_data[idx]; wabs = std::abs(w * std::conj(w)); if ( m > 0 ) sum += 2*wabs; //term appears twice in the spectrum else sum += wabs; // term appears only once if ( wabs < i_abs_threshold){ //file << "(" << n << "," << m << ")\t"<<std::endl; file << 0 << "\t"; //<<std::endl; } else{ //file << "(" << n << "," << m << ")\t"<<std::endl; file << wabs << "\t"; //<<std::endl;; //std::cout << n << " " << m << " " << wabs <<std::endl; } idx++; } } file<< sum << std::endl; file.close(); } void spectrum_phase_file_write_line( const std::string &i_filename, const char *i_title = "", const double i_time = 0.0, int i_precision = 20, double i_abs_threshold = -1, int i_reduce_mode_factor = 1 ) const { std::ofstream file; if(i_time == 0.0){ file.open(i_filename, std::ios_base::trunc); file << std::setprecision(i_precision); file << "#SWEET_SPHERE_SPECTRAL_PHASE_EVOL_ASCII" << std::endl; file << "#TI " << i_title << std::endl; file << "0\t"<< std::endl; // Use 0 to make it processable by python file << "(n_max="<<sphereDataConfig->spectral_modes_n_max << " m_max=" << sphereDataConfig->spectral_modes_n_max << ")" << std::endl; file << "timestamp\t" ; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max/i_reduce_mode_factor; m++) { //std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max/i_reduce_mode_factor; n++) { file << "(" << n << ";" << m << ")\t" ; } } file << std::endl; } else{ file.open(i_filename, std::ios_base::app); file << std::setprecision(i_precision); } std::complex<double> w = {0,0}; double wphase = 0.0; //std::cout << "n" << " " << "m" << " " << "norm" <<std::endl; file << i_time << "\t"; for (int m = 0; m <= sphereDataConfig->spectral_modes_m_max/i_reduce_mode_factor; m++) { std::size_t idx = sphereDataConfig->getArrayIndexByModes(m, m); for (int n = m; n <= sphereDataConfig->spectral_modes_n_max/i_reduce_mode_factor; n++) { w = spectral_space_data[idx]; wphase = std::arg(w); // std::abs(w * std::conj(w)); //file << "(" << n << "," << m << ")\t"<<std::endl; file << wphase << "\t"; //<<std::endl;; //std::cout << n << " " << m << " " << wabs <<std::endl; idx++; } } file<< std::endl; file.close(); } /** * Write the spectral data to a file in binary format */ void file_write_binary_spectral( const std::string &i_filename ) const { std::ofstream file(i_filename, std::ios_base::trunc | std::ios_base::binary); if (!file.is_open()) SWEETError("Error while opening file"); file << "SWEET" << std::endl; file << "DATA_TYPE SH_DATA" << std::endl; file << "MODES_M_MAX " << sphereDataConfig->spectral_modes_m_max << std::endl; file << "MODES_N_MAX " << sphereDataConfig->spectral_modes_n_max << std::endl; file << "GRID_TYPE GAUSSIAN" << std::endl; file << "NUM_ELEMENTS " << sphereDataConfig->spectral_array_data_number_of_elements << std::endl; file << "FIN" << std::endl; file.write((const char*)spectral_space_data, sizeof(std::complex<double>)*sphereDataConfig->spectral_array_data_number_of_elements); file.close(); } void file_read_binary_spectral( const std::string &i_filename ) { std::ifstream file(i_filename, std::ios_base::binary); if (!file.is_open()) SWEETError("Error while opening file"); std::string magic; std::getline(file, magic); if (magic != "SWEET") SWEETError("Magic code 'SWEET' not found"); std::string data_type; int num_lon = -1; int num_lat = -1; int size = -1; while (true) { std::string buf; file >> buf; if (buf == "FIN") break; if (buf == "DATA_TYPE") { // load data type file >> data_type; std::cout << data_type << std::endl; continue; } if (buf == "NUM_LON") { file >> buf; num_lon = std::stoi(buf); std::cout << num_lon << std::endl; continue; } if (buf == "NUM_LAT") { file >> buf; num_lat = std::stoi(buf); std::cout << num_lat << std::endl; continue; } if (buf == "SIZE") { file >> buf; size = std::stoi(buf); std::cout << size << std::endl; continue; } SWEETError("Unknown Tag '"+buf+"'"); } // read last newline char nl; file.read(&nl, 1); std::cout << file.tellg() << std::endl; if (data_type != "SH_DATA") SWEETError("Unknown data type '"+data_type+"'"); if (num_lon != sphereDataConfig->spectral_modes_m_max) SWEETError("NUM_LON "+std::to_string(num_lon)+" doesn't match SphereDataConfig"); if (num_lat != sphereDataConfig->spectral_modes_n_max) SWEETError("NUM_LAT "+std::to_string(num_lat)+" doesn't match SphereDataConfig"); file.read((char*)spectral_space_data, sizeof(std::complex<double>)*sphereDataConfig->spectral_array_data_number_of_elements); file.close(); } void normalize( const std::string &normalization = "" ) { if (normalization == "avg_zero") { // move average value to 0 double phi_min = getSphereDataPhysical().physical_reduce_min(); double phi_max = getSphereDataPhysical().physical_reduce_max(); double avg = 0.5*(phi_max+phi_min); operator-=(avg); } else if (normalization == "min_zero") { // move minimum value to zero double phi_min = getSphereDataPhysical().physical_reduce_min(); operator-=(phi_min); } else if (normalization == "max_zero") { // move maximum value to zero double phi_max = getSphereDataPhysical().physical_reduce_max(); operator-=(phi_max); } else if (normalization == "") { } else { SWEETError("Normalization not supported!"); } } }; /** * operator to support operations such as: * * 1.5 * arrayData; * * Otherwise, we'd have to write it as arrayData*1.5 * */ inline static SphereData_Spectral operator*( double i_value, const SphereData_Spectral &i_array_data ) { return ((SphereData_Spectral&)i_array_data)*i_value; } /** * operator to support operations such as: * * 1.5 + arrayData * */ inline static SphereData_Spectral operator+( double i_value, const SphereData_Spectral &i_array_data ) { return ((SphereData_Spectral&)i_array_data)+i_value; } /** * operator to support operations such as: * * 1.5 - arrayData * */ inline static SphereData_Spectral operator-( double i_value, const SphereData_Spectral &i_array_data ) { return i_array_data.operator_scalar_sub_this(i_value); } #endif /* SWEET_SPHERE_DATA_HPP_ */
22.894562
144
0.683852
valentinaschueller
f3f1aca35572a63cf1ee1c3582a44a241b834d5a
478
cpp
C++
Algorithm_BaekJoon/1110.cpp
dongdong97/TIL
22fab3bc5509ac46510071cb6a7ce390fd4df75a
[ "MIT" ]
null
null
null
Algorithm_BaekJoon/1110.cpp
dongdong97/TIL
22fab3bc5509ac46510071cb6a7ce390fd4df75a
[ "MIT" ]
null
null
null
Algorithm_BaekJoon/1110.cpp
dongdong97/TIL
22fab3bc5509ac46510071cb6a7ce390fd4df75a
[ "MIT" ]
null
null
null
//// //// 1110.cpp //// Algorithm //// //// Created by 동균 on 2018. 6. 1.. //// Copyright © 2018년 동균. All rights reserved. //// // //#include <iostream> //using namespace std; // //int main() { // // int number, number2 , tmp1, tmp2, tmp3; // int cnt =0; // // cin >> number; // number2 = number; // // tmp1 = number2/10; // tmp2 = number2%10; // tmp3 = (tmp1+tmp2) % 10; // // number2 = tmp2 *10 + tmp3; // // return 0; // //}
16.482759
48
0.476987
dongdong97
f3f6941492d8fd5bd7965764ff995ac2282c7fad
12,739
cpp
C++
avs/vis_avs/r_videodelay.cpp
czeskij/vis_avs
10cbc47adbc128f17505c695535d8cbec243410e
[ "Unlicense" ]
null
null
null
avs/vis_avs/r_videodelay.cpp
czeskij/vis_avs
10cbc47adbc128f17505c695535d8cbec243410e
[ "Unlicense" ]
null
null
null
avs/vis_avs/r_videodelay.cpp
czeskij/vis_avs
10cbc47adbc128f17505c695535d8cbec243410e
[ "Unlicense" ]
null
null
null
/* LICENSE ------- Copyright 2005 Nullsoft, 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: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Nullsoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // video delay // copyright tom holden, 2002 // mail: cfp@myrealbox.com #include "r_defs.h" #include "resource.h" #include <windows.h> #ifndef LASER #define MOD_NAME "Trans / Video Delay" #define C_DELAY C_VideoDelayClass class C_DELAY : public C_RBASE { protected: public: // standard ape members C_DELAY(); virtual ~C_DELAY(); virtual int render(char visdata[2][2][576], int isBeat, int* framebuffer, int* fbout, int w, int h); virtual HWND conf(HINSTANCE hInstance, HWND hwndParent); virtual char* get_desc(); virtual void load_config(unsigned char* data, int len); virtual int save_config(unsigned char* data); // saved members bool enabled; bool usebeats; unsigned int delay; // unsaved members LPVOID buffer; LPVOID inoutpos; unsigned long buffersize; unsigned long virtualbuffersize; unsigned long oldvirtualbuffersize; unsigned long framessincebeat; unsigned long framedelay; unsigned long framemem; unsigned long oldframemem; }; // global configuration dialog pointer static C_DELAY* g_Delay; // global DLL instance pointer static HINSTANCE g_hDllInstance; // configuration screen static BOOL CALLBACK g_DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { char value[16]; int val; unsigned int objectcode, objectmessage; HWND hwndEdit; switch (uMsg) { case WM_INITDIALOG: //init CheckDlgButton(hwndDlg, IDC_CHECK1, g_Delay->enabled); CheckDlgButton(hwndDlg, IDC_RADIO1, g_Delay->usebeats); CheckDlgButton(hwndDlg, IDC_RADIO2, !g_Delay->usebeats); hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT1); _itoa(g_Delay->delay, value, 10); SetWindowText(hwndEdit, value); return 1; case WM_COMMAND: objectcode = LOWORD(wParam); objectmessage = HIWORD(wParam); // see if enable checkbox is checked if (objectcode == IDC_CHECK1) { g_Delay->enabled = IsDlgButtonChecked(hwndDlg, IDC_CHECK1) == 1; return 0; } // see if beats radiobox is checked if (objectcode == IDC_RADIO1) { if (IsDlgButtonChecked(hwndDlg, IDC_RADIO1) == 1) { g_Delay->usebeats = true; CheckDlgButton(hwndDlg, IDC_RADIO2, BST_UNCHECKED); g_Delay->framedelay = 0; g_Delay->framessincebeat = 0; hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT1); //new if (g_Delay->delay > 16) { //new g_Delay->delay = 16; //new SetWindowText(hwndEdit, "16"); //new } //new } else g_Delay->usebeats = false; return 0; } // see if frames radiobox is checked if (objectcode == IDC_RADIO2) { if (IsDlgButtonChecked(hwndDlg, IDC_RADIO2) == 1) { g_Delay->usebeats = false; CheckDlgButton(hwndDlg, IDC_RADIO1, BST_UNCHECKED); g_Delay->framedelay = g_Delay->delay; } else g_Delay->usebeats = true; return 0; } //get and put data from the delay box if (objectcode == IDC_EDIT1) { hwndEdit = GetDlgItem(hwndDlg, IDC_EDIT1); if (objectmessage == EN_CHANGE) { GetWindowText(hwndEdit, value, 16); val = atoi(value); if (g_Delay->usebeats) { if (val > 16) val = 16; } //new else { if (val > 200) val = 200; } //new g_Delay->delay = val; g_Delay->framedelay = g_Delay->usebeats ? 0 : g_Delay->delay; } else if (objectmessage == EN_KILLFOCUS) { _itoa(g_Delay->delay, value, 10); SetWindowText(hwndEdit, value); } return 0; } } return 0; } // set up default configuration C_DELAY::C_DELAY() { // enable enabled = true; usebeats = false; delay = 10; framedelay = 10; framessincebeat = 0; buffersize = 1; virtualbuffersize = 1; oldvirtualbuffersize = 1; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); inoutpos = buffer; } // virtual destructor C_DELAY::~C_DELAY() { VirtualFree(buffer, buffersize, MEM_DECOMMIT); } // RENDER FUNCTION: // render should return 0 if it only used framebuffer, or 1 if the new output data is in fbout // w and h are the-width and height of the screen, in pixels. // isBeat is 1 if a beat has been detected. // visdata is in the format of [spectrum:0,wave:1][channel][band]. int C_DELAY::render(char visdata[2][2][576], int isBeat, int* framebuffer, int* fbout, int w, int h) { if (isBeat & 0x80000000) return 0; framemem = w * h * 4; if (usebeats) { if (isBeat) { framedelay = framessincebeat * delay; //changed if (framedelay > 400) framedelay = 400; //new framessincebeat = 0; } framessincebeat++; } if (enabled && framedelay != 0) { virtualbuffersize = framedelay * framemem; if (framemem == oldframemem) { if (virtualbuffersize != oldvirtualbuffersize) { if (virtualbuffersize > oldvirtualbuffersize) { if (virtualbuffersize > buffersize) { // allocate new memory if (!VirtualFree(buffer, buffersize, MEM_DECOMMIT)) return 0; if (usebeats) { buffersize = 2 * virtualbuffersize; if (buffersize > framemem * 400) buffersize = framemem * 400; //new buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); if (buffer == NULL) { buffersize = virtualbuffersize; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); } } else { buffersize = virtualbuffersize; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); } inoutpos = buffer; if (buffer == NULL) { framedelay = 0; framessincebeat = 0; return 0; } } else { unsigned long size = (((unsigned long)buffer) + oldvirtualbuffersize) - ((unsigned long)inoutpos); unsigned long l = ((unsigned long)buffer) + virtualbuffersize; unsigned long d = l - size; MoveMemory((LPVOID)d, inoutpos, size); for (l = (unsigned long)inoutpos; l < d; l += framemem) CopyMemory((LPVOID)l, (LPVOID)d, framemem); } } else { // virtualbuffersize < oldvirtualbuffersize unsigned long presegsize = ((unsigned long)inoutpos) - ((unsigned long)buffer) + framemem; if (presegsize > virtualbuffersize) { MoveMemory(buffer, (LPVOID)(((unsigned long)buffer) + presegsize - virtualbuffersize), virtualbuffersize); inoutpos = (LPVOID)(((unsigned long)buffer) + virtualbuffersize - framemem); } else if (presegsize < virtualbuffersize) MoveMemory((LPVOID)(((unsigned long)inoutpos) + framemem), (LPVOID)(((unsigned long)buffer) + oldvirtualbuffersize + presegsize - virtualbuffersize), virtualbuffersize - presegsize); } oldvirtualbuffersize = virtualbuffersize; } } else { // allocate new memory if (!VirtualFree(buffer, buffersize, MEM_DECOMMIT)) return 0; if (usebeats) { buffersize = 2 * virtualbuffersize; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); if (buffer == NULL) { buffersize = virtualbuffersize; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); } } else { buffersize = virtualbuffersize; buffer = VirtualAlloc(NULL, buffersize, MEM_COMMIT, PAGE_READWRITE); } inoutpos = buffer; if (buffer == NULL) { framedelay = 0; framessincebeat = 0; return 0; } oldvirtualbuffersize = virtualbuffersize; } oldframemem = framemem; CopyMemory(fbout, inoutpos, framemem); CopyMemory(inoutpos, framebuffer, framemem); inoutpos = (LPVOID)(((unsigned long)inoutpos) + framemem); if ((unsigned long)inoutpos >= ((unsigned long)buffer) + virtualbuffersize) inoutpos = buffer; return 1; } else return 0; } HWND C_DELAY::conf(HINSTANCE hInstance, HWND hwndParent) // return NULL if no config dialog possible { g_Delay = this; return CreateDialog(hInstance, MAKEINTRESOURCE(IDD_CFG_VIDEODELAY), hwndParent, g_DlgProc); } char* C_DELAY::get_desc(void) { return MOD_NAME; } // load_/save_config are called when saving and loading presets (.avs files) #define GET_INT() (data[pos] | (data[pos + 1] << 8) | (data[pos + 2] << 16) | (data[pos + 3] << 24)) void C_DELAY::load_config(unsigned char* data, int len) // read configuration of max length "len" from data. { int pos = 0; // always ensure there is data to be loaded if (len - pos >= 4) { // load activation toggle enabled = (GET_INT() == 1); pos += 4; } if (len - pos >= 4) { // load beats toggle usebeats = (GET_INT() == 1); pos += 4; } if (len - pos >= 4) { // load delay delay = GET_INT(); if (usebeats) { if (delay > 16) delay = 16; } //new else { if (delay > 200) delay = 200; } //new pos += 4; } } // write configuration to data, return length. config data should not exceed 64k. #define PUT_INT(y) \ data[pos] = (y)&255; \ data[pos + 1] = (y >> 8) & 255; \ data[pos + 2] = (y >> 16) & 255; \ data[pos + 3] = (y >> 24) & 255 int C_DELAY::save_config(unsigned char* data) { int pos = 0; PUT_INT((int)enabled); pos += 4; PUT_INT((int)usebeats); pos += 4; PUT_INT((unsigned int)delay); pos += 4; return pos; } // export stuff C_RBASE* R_VideoDelay(char* desc) // creates a new effect object if desc is NULL, otherwise fills in desc with description { if (desc) { strcpy(desc, MOD_NAME); return NULL; } return (C_RBASE*)new C_DELAY(); } #endif
36.606322
206
0.572886
czeskij
f3f97d9dda48b76df6f48b20bf558d7a52b13fd9
933
cpp
C++
client/public_key.cpp
irl-game/irl
ba507a93371ab172b705c1ede8cd062123fc96f5
[ "MIT" ]
null
null
null
client/public_key.cpp
irl-game/irl
ba507a93371ab172b705c1ede8cd062123fc96f5
[ "MIT" ]
6
2020-02-16T21:25:21.000Z
2020-03-11T07:42:00.000Z
client/public_key.cpp
irl-game/irl
ba507a93371ab172b705c1ede8cd062123fc96f5
[ "MIT" ]
null
null
null
#include "public_key.hpp" extern const RsaPublicKey PublicKey = { 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xe0, 0x15, 0x69, 0x00, 0x55, 0x3c, 0x6a, 0x56, 0x35, 0x6d, 0x3c, 0x2a, 0x3d, 0xd6, 0xdc, 0x7a, 0xe2, 0x72, 0x3f, 0x87, 0xa3, 0x13, 0x26, 0x86, 0x75, 0x75, 0x79, 0x45, 0xbe, 0xc8, 0xb5, 0x57, 0xaa, 0x4a, 0x9a, 0xff, 0x3a, 0x30, 0xd7, 0xa2, 0x33, 0xa0, 0x64, 0x1e, 0xbf, 0x3b, 0x13, 0x2c, 0x01, 0x57, 0x90, 0xc1, 0x78, 0xf7, 0x6d, 0x6c, 0x41, 0x87, 0xe2, 0x53, 0x77, 0x77, 0x28, 0x27, 0xf4, 0x56, 0xf2, 0x85, 0x5f, 0x79, 0xa8, 0xc6, 0x84, 0x5e, 0x75, 0x45, 0x77, 0x47, 0x0c, 0x51, 0x3d, 0xab, 0xf4, 0xbe, 0xe4, 0xb1, 0x54, 0x8b, 0x88, 0x39, 0xe6, 0x3a, 0x03, 0x69, 0x71, 0x25, 0x5e, 0xcc, 0x6b, 0x38, 0xfa, 0xfc, 0x80, 0x15, 0xf9, 0x90, 0x4e, 0xe4, 0x52, 0x31, 0xe5, 0x26, 0xa2, 0xc7, 0x88, 0xc8, 0x30, 0x64, 0xdd, 0x86, 0x22, 0xbb, 0xe0, 0x79, 0xe1, 0x50, 0x66, 0x6d, 0x02, 0x03, 0x01, 0x00, 0x01 };
54.882353
73
0.655949
irl-game
f3fd26e46f21b6ecfb8fa6ef072ce98546c474fa
48,543
hpp
C++
runtime.Kokkos.NET/Analyzes/RadialBasisFunctionInterp2D.hpp
trmcnealy/Kokkos.NET
d81aa03d720c7d8a089fdb42da18b240f127758c
[ "MIT" ]
null
null
null
runtime.Kokkos.NET/Analyzes/RadialBasisFunctionInterp2D.hpp
trmcnealy/Kokkos.NET
d81aa03d720c7d8a089fdb42da18b240f127758c
[ "MIT" ]
null
null
null
runtime.Kokkos.NET/Analyzes/RadialBasisFunctionInterp2D.hpp
trmcnealy/Kokkos.NET
d81aa03d720c7d8a089fdb42da18b240f127758c
[ "MIT" ]
null
null
null
#include <cmath> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> using namespace std; #include "r8lib/r8lib.hpp" #pragma once //void daxpy ( int n, double da, double dx[], int incx, double dy[], int incy ); //double ddot ( int n, double dx[], int incx, double dy[], int incy ); //double dnrm2 ( int n, double x[], int incx ); //void drot ( int n, double x[], int incx, double y[], int incy, double c, double s ); //void drotg ( double *sa, double *sb, double *c, double *s ); //void dscal ( int n, double sa, double x[], int incx ); int dsvdc ( double a[], int lda, int m, int n, double s[], double e[], double u[], int ldu, double v[], int ldv, double work[], int job ); //void dswap ( int n, double x[], int incx, double y[], int incy ); void phi1 ( int n, double r[], double r0, double v[] ); void phi2 ( int n, double r[], double r0, double v[] ); void phi3 ( int n, double r[], double r0, double v[] ); void phi4 ( int n, double r[], double r0, double v[] ); double *r8mat_solve_svd ( int m, int n, double a[], double b[] ); double *rbf_interp ( int m, int nd, double xd[], double r0, void (*phi) ( int n, double r[], double r0, double v[] ), double w[], int ni, double xi[] ); double *rbf_weight ( int m, int nd, double xd[], double r0, void (*phi) ( int n, double r[], double r0, double v[] ), double fd[] ); #include <mkl.h> #define CBLAS #ifdef CBLAS #define BLASFunc(name) cblas_ ## name #else #define BLASFunc(name) name #endif //// //// Purpose: //// //// DAXPY computes constant times a vector plus a vector. //// //// Discussion: //// //// This routine uses unrolled loops for increments equal to one. //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of elements in DX and DY. //// //// Input, double DA, the multiplier of DX. //// //// Input, double DX[*], the first vector. //// //// Input, int INCX, the increment between successive entries of DX. //// //// Input/output, double DY[*], the second vector. //// On output, DY[*] has been replaced by DY[*] + DA * DX[*]. //// //// Input, int INCY, the increment between successive entries of DY. //// //void daxpy(int n, double da, double dx[], int incx, double dy[], int incy) //{ // int i; // int ix; // int iy; // int m; // // if (n <= 0) // { // return; // } // // if (da == 0.0) // { // return; // } // // // // Code for unequal increments or equal increments // // not equal to 1. // // // if (incx != 1 || incy != 1) // { // if (0 <= incx) // { // ix = 0; // } // else // { // ix = (-n + 1) * incx; // } // // if (0 <= incy) // { // iy = 0; // } // else // { // iy = (-n + 1) * incy; // } // // for (i = 0; i < n; ++i) // { // dy[iy] = dy[iy] + da * dx[ix]; // ix = ix + incx; // iy = iy + incy; // } // } // // // // Code for both increments equal to 1. // // // else // { // m = n % 4; // // for (i = 0; i < m; ++i) // { // dy[i] = dy[i] + da * dx[i]; // } // // for (i = m; i < n; i = i + 4) // { // dy[i] = dy[i] + da * dx[i]; // dy[i + 1] = dy[i + 1] + da * dx[i + 1]; // dy[i + 2] = dy[i + 2] + da * dx[i + 2]; // dy[i + 3] = dy[i + 3] + da * dx[i + 3]; // } // } // // return; //} // //// //// Purpose: //// //// DDOT forms the dot product of two vectors. //// //// Discussion: //// //// This routine uses unrolled loops for increments equal to one. //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of entries in the vectors. //// //// Input, double DX[*], the first vector. //// //// Input, int INCX, the increment between successive entries in DX. //// //// Input, double DY[*], the second vector. //// //// Input, int INCY, the increment between successive entries in DY. //// //// Output, double DDOT, the sum of the product of the corresponding //// entries of DX and DY. //// //double ddot(int n, double dx[], int incx, double dy[], int incy) //{ // double dtemp; // int i; // int ix; // int iy; // int m; // // dtemp = 0.0; // // if (n <= 0) // { // return dtemp; // } // // // // Code for unequal increments or equal increments // // not equal to 1. // // // if (incx != 1 || incy != 1) // { // if (0 <= incx) // { // ix = 0; // } // else // { // ix = (-n + 1) * incx; // } // // if (0 <= incy) // { // iy = 0; // } // else // { // iy = (-n + 1) * incy; // } // // for (i = 0; i < n; ++i) // { // dtemp = dtemp + dx[ix] * dy[iy]; // ix = ix + incx; // iy = iy + incy; // } // } // // // // Code for both increments equal to 1. // // // else // { // m = n % 5; // // for (i = 0; i < m; ++i) // { // dtemp = dtemp + dx[i] * dy[i]; // } // // for (i = m; i < n; i = i + 5) // { // dtemp = dtemp + dx[i] * dy[i] + dx[i + 1] * dy[i + 1] + // dx[i + 2] * dy[i + 2] + dx[i + 3] * dy[i + 3] + // dx[i + 4] * dy[i + 4]; // } // } // // return dtemp; //} // //// //// Purpose: //// //// DNRM2 returns the euclidean norm of a vector. //// //// Discussion: //// //// DNRM2 ( X ) = sqrt ( X' * X ) //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of entries in the vector. //// //// Input, double X[*], the vector whose norm is to be computed. //// //// Input, int INCX, the increment between successive entries of X. //// //// Output, double DNRM2, the Euclidean norm of X. //// //double dnrm2(int n, double x[], int incx) //{ // double absxi; // int i; // int ix; // double norm; // double scale; // double ssq; // double value; // // if (n < 1 || incx < 1) // { // norm = 0.0; // } // else if (n == 1) // { // norm = r8_abs(x[0]); // } // else // { // scale = 0.0; // ssq = 1.0; // ix = 0; // // for (i = 0; i < n; ++i) // { // if (x[ix] != 0.0) // { // absxi = r8_abs(x[ix]); // if (scale < absxi) // { // ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi); // scale = absxi; // } // else // { // ssq = ssq + (absxi / scale) * (absxi / scale); // } // } // ix = ix + incx; // } // // norm = scale * sqrt(ssq); // } // // return norm; //} // //// //// Purpose: //// //// DROT applies a plane rotation. //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of entries in the vectors. //// //// Input/output, double X[*], one of the vectors to be rotated. //// //// Input, int INCX, the increment between successive entries of X. //// //// Input/output, double Y[*], one of the vectors to be rotated. //// //// Input, int INCY, the increment between successive elements of Y. //// //// Input, double C, S, parameters (presumably the cosine and //// sine of some angle) that define a plane rotation. //// //void drot(int n, double x[], int incx, double y[], int incy, double c, double s) //{ // int i; // int ix; // int iy; // double stemp; // // if (n <= 0) // { // } // else if (incx == 1 && incy == 1) // { // for (i = 0; i < n; ++i) // { // stemp = c * x[i] + s * y[i]; // y[i] = c * y[i] - s * x[i]; // x[i] = stemp; // } // } // else // { // if (0 <= incx) // { // ix = 0; // } // else // { // ix = (-n + 1) * incx; // } // // if (0 <= incy) // { // iy = 0; // } // else // { // iy = (-n + 1) * incy; // } // // for (i = 0; i < n; ++i) // { // stemp = c * x[ix] + s * y[iy]; // y[iy] = c * y[iy] - s * x[ix]; // x[ix] = stemp; // ix = ix + incx; // iy = iy + incy; // } // } // // return; //} // //// //// Purpose: //// //// DROTG constructs a Givens plane rotation. //// //// Discussion: //// //// Given values A and B, this routine computes //// //// SIGMA = sign ( A ) if abs ( A ) > abs ( B ) //// = sign ( B ) if abs ( A ) <= abs ( B ); //// //// R = SIGMA * ( A * A + B * B ); //// //// C = A / R if R is not 0 //// = 1 if R is 0; //// //// S = B / R if R is not 0, //// 0 if R is 0. //// //// The computed numbers then satisfy the equation //// //// ( C S ) ( A ) = ( R ) //// ( -S C ) ( B ) = ( 0 ) //// //// The routine also computes //// //// Z = S if abs ( A ) > abs ( B ), //// = 1 / C if abs ( A ) <= abs ( B ) and C is not 0, //// = 1 if C is 0. //// //// The single value Z encodes C and S, and hence the rotation: //// //// If Z = 1, set C = 0 and S = 1; //// If abs ( Z ) < 1, set C = sqrt ( 1 - Z * Z ) and S = Z; //// if abs ( Z ) > 1, set C = 1/ Z and S = sqrt ( 1 - C * C ); //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 15 May 2006 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input/output, double *SA, *SB, On input, SA and SB are the values //// A and B. On output, SA is overwritten with R, and SB is //// overwritten with Z. //// //// Output, double *C, *S, the cosine and sine of the Givens rotation. //// //void drotg(double *sa, double *sb, double *c, double *s) //{ // double r; // double roe; // double scale; // double z; // // if (r8_abs(*sb) < r8_abs(*sa)) // { // roe = *sa; // } // else // { // roe = *sb; // } // // scale = r8_abs(*sa) + r8_abs(*sb); // // if (scale == 0.0) // { // *c = 1.0; // *s = 0.0; // r = 0.0; // } // else // { // r = scale * // sqrt((*sa / scale) * (*sa / scale) + (*sb / scale) * (*sb / scale)); // r = r8_sign(roe) * r; // *c = *sa / r; // *s = *sb / r; // } // // if (0.0 < r8_abs(*c) && r8_abs(*c) <= *s) // { // z = 1.0 / *c; // } // else // { // z = *s; // } // // *sa = r; // *sb = z; // // return; //} // //// //// Purpose: //// //// DSCAL scales a vector by a constant. //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of entries in the vector. //// //// Input, double SA, the multiplier. //// //// Input/output, double X[*], the vector to be scaled. //// //// Input, int INCX, the increment between successive entries of X. //// //void dscal(int n, double sa, double x[], int incx) //{ // int i; // int ix; // int m; // // if (n <= 0) // { // } // else if (incx == 1) // { // m = n % 5; // // for (i = 0; i < m; ++i) // { // x[i] = sa * x[i]; // } // // for (i = m; i < n; i = i + 5) // { // x[i] = sa * x[i]; // x[i + 1] = sa * x[i + 1]; // x[i + 2] = sa * x[i + 2]; // x[i + 3] = sa * x[i + 3]; // x[i + 4] = sa * x[i + 4]; // } // } // else // { // if (0 <= incx) // { // ix = 0; // } // else // { // ix = (-n + 1) * incx; // } // // for (i = 0; i < n; ++i) // { // x[ix] = sa * x[ix]; // ix = ix + incx; // } // } // // return; //} // // Purpose: // // DSVDC computes the singular value decomposition of a real rectangular // matrix. // // Discussion: // // This routine reduces an M by N matrix A to diagonal form by orthogonal // transformations U and V. The diagonal elements S(I) are the singular // values of A. The columns of U are the corresponding left singular // vectors, and the columns of V the right singular vectors. // // The form of the singular value decomposition is then // // A(MxN) = U(MxM) * S(MxN) * V(NxN)' // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 03 May 2007 // // Author: // // Original FORTRAN77 version by Jack Dongarra, Cleve Moler, Jim Bunch, // Pete Stewart. // C++ version by John Burkardt. // // Reference: // // Jack Dongarra, Cleve Moler, Jim Bunch, Pete Stewart, // LINPACK User's Guide, // SIAM, (Society for Industrial and Applied Mathematics), // 3600 University City Science Center, // Philadelphia, PA, 19104-2688. // ISBN 0-89871-172-X // // Parameters: // // Input/output, double A[LDA*N]. On input, the M by N matrix whose // singular value decomposition is to be computed. On output, the matrix // has been destroyed. Depending on the user's requests, the matrix may // contain other useful information. // // Input, int LDA, the leading dimension of the array A. // LDA must be at least M. // // Input, int M, the number of rows of the matrix. // // Input, int N, the number of columns of the matrix A. // // Output, double S[MM], where MM = min(M+1,N). The first // min(M,N) entries of S contain the singular values of A arranged in // descending order of magnitude. // // Output, double E[MM], where MM = min(M+1,N), ordinarily contains zeros. // However see the discussion of INFO for exceptions. // // Output, double U[LDU*K]. If JOBA = 1 then K = M; // if 2 <= JOBA, then K = min(M,N). U contains the M by M matrix of left // singular vectors. U is not referenced if JOBA = 0. If M <= N or if JOBA // = 2, then U may be identified with A in the subroutine call. // // Input, int LDU, the leading dimension of the array U. // LDU must be at least M. // // Output, double V[LDV*N], the N by N matrix of right singular vectors. // V is not referenced if JOB is 0. If N <= M, then V may be identified // with A in the subroutine call. // // Input, int LDV, the leading dimension of the array V. // LDV must be at least N. // // Workspace, double WORK[M]. // // Input, int JOB, controls the computation of the singular // vectors. It has the decimal expansion AB with the following meaning: // A = 0, do not compute the left singular vectors. // A = 1, return the M left singular vectors in U. // A >= 2, return the first min(M,N) singular vectors in U. // B = 0, do not compute the right singular vectors. // B = 1, return the right singular vectors in V. // // Output, int *DSVDC, status indicator INFO. // The singular values (and their corresponding singular vectors) // S(*INFO+1), S(*INFO+2),...,S(MN) are correct. Here MN = min ( M, N ). // Thus if *INFO is 0, all the singular values and their vectors are // correct. In any event, the matrix B = U' * A * V is the bidiagonal // matrix with the elements of S on its diagonal and the elements of E on // its superdiagonal. Thus the singular values of A and B are the same. // int dsvdc(double a[], int lda, int m, int n, double s[], double e[], double u[], int ldu, double v[], int ldv, double work[], int job) { double b; double c; double cs; double el; double emm1; double f; double g; int i; int info; int iter; int j; int jobu; int k; int kase; int kk; int l; int ll; int lls; int ls; int lu; int maxit = 30; int mm; int mm1; int mn; int mp1; int nct; int nctp1; int ncu; int nrt; int nrtp1; double scale; double shift; double sl; double sm; double smm1; double sn; double t; double t1; double test; bool wantu; bool wantv; double ztest; // // Determine what is to be computed. // info = 0; wantu = false; wantv = false; jobu = (job % 100) / 10; if (1 < jobu) { ncu = i4_min(m, n); } else { ncu = m; } if (jobu != 0) { wantu = true; } if ((job % 10) != 0) { wantv = true; } // // Reduce A to bidiagonal form, storing the diagonal elements // in S and the super-diagonal elements in E. // nct = i4_min(m - 1, n); nrt = i4_max(0, i4_min(m, n - 2)); lu = i4_max(nct, nrt); for (l = 1; l <= lu; l++) { // // Compute the transformation for the L-th column and // place the L-th diagonal in S(L). // if (l <= nct) { s[l - 1] = BLASFunc(dnrm2)(m - l + 1, a + l - 1 + (l - 1) * lda, 1); if (s[l - 1] != 0.0) { if (a[l - 1 + (l - 1) * lda] != 0.0) { s[l - 1] = r8_sign(a[l - 1 + (l - 1) * lda]) * r8_abs(s[l - 1]); } BLASFunc(dscal)(m - l + 1, 1.0 / s[l - 1], a + l - 1 + (l - 1) * lda, 1); a[l - 1 + (l - 1) * lda] = 1.0 + a[l - 1 + (l - 1) * lda]; } s[l - 1] = -s[l - 1]; } for (j = l + 1; j <= n; ++j) { // // Apply the transformation. // if (l <= nct && s[l - 1] != 0.0) { t = -BLASFunc(ddot)(m - l + 1, a + l - 1 + (l - 1) * lda, 1, a + l - 1 + (j - 1) * lda, 1) / a[l - 1 + (l - 1) * lda]; BLASFunc(daxpy)(m - l + 1, t, a + l - 1 + (l - 1) * lda, 1, a + l - 1 + (j - 1) * lda, 1); } // // Place the L-th row of A into E for the // subsequent calculation of the row transformation. // e[j - 1] = a[l - 1 + (j - 1) * lda]; } // // Place the transformation in U for subsequent back multiplication. // if (wantu && l <= nct) { for (i = l; i <= m; ++i) { u[i - 1 + (l - 1) * ldu] = a[i - 1 + (l - 1) * lda]; } } if (l <= nrt) { // // Compute the L-th row transformation and place the // L-th superdiagonal in E(L). // e[l - 1] = BLASFunc(dnrm2)(n - l, e + l, 1); if (e[l - 1] != 0.0) { if (e[l] != 0.0) { e[l - 1] = r8_sign(e[l]) * r8_abs(e[l - 1]); } BLASFunc(dscal)(n - l, 1.0 / e[l - 1], e + l, 1); e[l] = 1.0 + e[l]; } e[l - 1] = -e[l - 1]; // // Apply the transformation. // if (l + 1 <= m && e[l - 1] != 0.0) { for (j = l + 1; j <= m; ++j) { work[j - 1] = 0.0; } for (j = l + 1; j <= n; ++j) { BLASFunc(daxpy)(m - l, e[j - 1], a + l + (j - 1) * lda, 1, work + l, 1); } for (j = l + 1; j <= n; ++j) { BLASFunc(daxpy)(m - l, -e[j - 1] / e[l], work + l, 1, a + l + (j - 1) * lda, 1); } } // // Place the transformation in V for subsequent back multiplication. // if (wantv) { for (j = l + 1; j <= n; ++j) { v[j - 1 + (l - 1) * ldv] = e[j - 1]; } } } } // // Set up the final bidiagonal matrix of order MN. // mn = i4_min(m + 1, n); nctp1 = nct + 1; nrtp1 = nrt + 1; if (nct < n) { s[nctp1 - 1] = a[nctp1 - 1 + (nctp1 - 1) * lda]; } if (m < mn) { s[mn - 1] = 0.0; } if (nrtp1 < mn) { e[nrtp1 - 1] = a[nrtp1 - 1 + (mn - 1) * lda]; } e[mn - 1] = 0.0; // // If required, generate U. // if (wantu) { for (i = 1; i <= m; ++i) { for (j = nctp1; j <= ncu; ++j) { u[(i - 1) + (j - 1) * ldu] = 0.0; } } for (j = nctp1; j <= ncu; ++j) { u[j - 1 + (j - 1) * ldu] = 1.0; } for (ll = 1; ll <= nct; ll++) { l = nct - ll + 1; if (s[l - 1] != 0.0) { for (j = l + 1; j <= ncu; ++j) { t = -BLASFunc(ddot)(m - l + 1, u + (l - 1) + (l - 1) * ldu, 1, u + (l - 1) + (j - 1) * ldu, 1) / u[l - 1 + (l - 1) * ldu]; BLASFunc(daxpy)(m - l + 1, t, u + (l - 1) + (l - 1) * ldu, 1, u + (l - 1) + (j - 1) * ldu, 1); } BLASFunc(dscal)(m - l + 1, -1.0, u + (l - 1) + (l - 1) * ldu, 1); u[l - 1 + (l - 1) * ldu] = 1.0 + u[l - 1 + (l - 1) * ldu]; for (i = 1; i <= l - 1; ++i) { u[i - 1 + (l - 1) * ldu] = 0.0; } } else { for (i = 1; i <= m; ++i) { u[i - 1 + (l - 1) * ldu] = 0.0; } u[l - 1 + (l - 1) * ldu] = 1.0; } } } // // If it is required, generate V. // if (wantv) { for (ll = 1; ll <= n; ll++) { l = n - ll + 1; if (l <= nrt && e[l - 1] != 0.0) { for (j = l + 1; j <= n; ++j) { t = -BLASFunc(ddot)(n - l, v + l + (l - 1) * ldv, 1, v + l + (j - 1) * ldv, 1) / v[l + (l - 1) * ldv]; BLASFunc(daxpy)(n - l, t, v + l + (l - 1) * ldv, 1, v + l + (j - 1) * ldv, 1); } } for (i = 1; i <= n; ++i) { v[i - 1 + (l - 1) * ldv] = 0.0; } v[l - 1 + (l - 1) * ldv] = 1.0; } } // // Main iteration loop for the singular values. // mm = mn; iter = 0; while (0 < mn) { // // If too many iterations have been performed, set flag and return. // if (maxit <= iter) { info = mn; return info; } // // This section of the program inspects for // negligible elements in the S and E arrays. // // On completion the variables KASE and L are set as follows: // // KASE = 1 if S(MN) and E(L-1) are negligible and L < MN // KASE = 2 if S(L) is negligible and L < MN // KASE = 3 if E(L-1) is negligible, L < MN, and // S(L), ..., S(MN) are not negligible (QR step). // KASE = 4 if E(MN-1) is negligible (convergence). // for (ll = 1; ll <= mn; ll++) { l = mn - ll; if (l == 0) { break; } test = r8_abs(s[l - 1]) + r8_abs(s[l]); ztest = test + r8_abs(e[l - 1]); if (ztest == test) { e[l - 1] = 0.0; break; } } if (l == mn - 1) { kase = 4; } else { mp1 = mn + 1; for (lls = l + 1; lls <= mn + 1; lls++) { ls = mn - lls + l + 1; if (ls == l) { break; } test = 0.0; if (ls != mn) { test = test + r8_abs(e[ls - 1]); } if (ls != l + 1) { test = test + r8_abs(e[ls - 2]); } ztest = test + r8_abs(s[ls - 1]); if (ztest == test) { s[ls - 1] = 0.0; break; } } if (ls == l) { kase = 3; } else if (ls == mn) { kase = 1; } else { kase = 2; l = ls; } } l = l + 1; // // Deflate negligible S(MN). // if (kase == 1) { mm1 = mn - 1; f = e[mn - 2]; e[mn - 2] = 0.0; for (kk = 1; kk <= mm1; kk++) { k = mm1 - kk + l; t1 = s[k - 1]; BLASFunc(drotg)(&t1, &f, &cs, &sn); s[k - 1] = t1; if (k != l) { f = -sn * e[k - 2]; e[k - 2] = cs * e[k - 2]; } if (wantv) { BLASFunc(drot)(n, v + 0 + (k - 1) * ldv, 1, v + 0 + (mn - 1) * ldv, 1, cs, sn); } } } // // Split at negligible S(L). // else if (kase == 2) { f = e[l - 2]; e[l - 2] = 0.0; for (k = l; k <= mn; k++) { t1 = s[k - 1]; BLASFunc(drotg)(&t1, &f, &cs, &sn); s[k - 1] = t1; f = -sn * e[k - 1]; e[k - 1] = cs * e[k - 1]; if (wantu) { BLASFunc(drot)(m, u + 0 + (k - 1) * ldu, 1, u + 0 + (l - 2) * ldu, 1, cs, sn); } } } // // Perform one QR step. // else if (kase == 3) { // // Calculate the shift. // scale = r8_max(r8_abs(s[mn - 1]), r8_max(r8_abs(s[mn - 2]), r8_max(r8_abs(e[mn - 2]), r8_max(r8_abs(s[l - 1]), r8_abs(e[l - 1]))))); sm = s[mn - 1] / scale; smm1 = s[mn - 2] / scale; emm1 = e[mn - 2] / scale; sl = s[l - 1] / scale; el = e[l - 1] / scale; b = ((smm1 + sm) * (smm1 - sm) + emm1 * emm1) / 2.0; c = (sm * emm1) * (sm * emm1); shift = 0.0; if (b != 0.0 || c != 0.0) { shift = sqrt(b * b + c); if (b < 0.0) { shift = -shift; } shift = c / (b + shift); } f = (sl + sm) * (sl - sm) - shift; g = sl * el; // // Chase zeros. // mm1 = mn - 1; for (k = l; k <= mm1; k++) { BLASFunc(drotg)(&f, &g, &cs, &sn); if (k != l) { e[k - 2] = f; } f = cs * s[k - 1] + sn * e[k - 1]; e[k - 1] = cs * e[k - 1] - sn * s[k - 1]; g = sn * s[k]; s[k] = cs * s[k]; if (wantv) { BLASFunc(drot)(n, v + 0 + (k - 1) * ldv, 1, v + 0 + k * ldv, 1, cs, sn); } BLASFunc(drotg)(&f, &g, &cs, &sn); s[k - 1] = f; f = cs * e[k - 1] + sn * s[k]; s[k] = -sn * e[k - 1] + cs * s[k]; g = sn * e[k]; e[k] = cs * e[k]; if (wantu && k < m) { BLASFunc(drot)(m, u + 0 + (k - 1) * ldu, 1, u + 0 + k * ldu, 1, cs, sn); } } e[mn - 2] = f; iter = iter + 1; } // // Convergence. // else if (kase == 4) { // // Make the singular value nonnegative. // if (s[l - 1] < 0.0) { s[l - 1] = -s[l - 1]; if (wantv) { BLASFunc(dscal)(n, -1.0, v + 0 + (l - 1) * ldv, 1); } } // // Order the singular value. // for (;;) { if (l == mm) { break; } if (s[l] <= s[l - 1]) { break; } t = s[l - 1]; s[l - 1] = s[l]; s[l] = t; if (wantv && l < n) { BLASFunc(dswap)(n, v + 0 + (l - 1) * ldv, 1, v + 0 + l * ldv, 1); } if (wantu && l < m) { BLASFunc(dswap)(m, u + 0 + (l - 1) * ldu, 1, u + 0 + l * ldu, 1); } l = l + 1; } iter = 0; mn = mn - 1; } } return info; } //// //// Purpose: //// //// DSWAP interchanges two vectors. //// //// Licensing: //// //// This code is distributed under the GNU LGPL license. //// //// Modified: //// //// 02 May 2005 //// //// Author: //// //// Original FORTRAN77 version by Charles Lawson, Richard Hanson, //// David Kincaid, Fred Krogh. //// C++ version by John Burkardt. //// //// Reference: //// //// Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart, //// LINPACK User's Guide, //// SIAM, 1979, //// ISBN13: 978-0-898711-72-1, //// LC: QA214.L56. //// //// Charles Lawson, Richard Hanson, David Kincaid, Fred Krogh, //// Basic Linear Algebra Subprograms for Fortran Usage, //// Algorithm 539, //// ACM Transactions on Mathematical Software, //// Volume 5, Number 3, September 1979, pages 308-323. //// //// Parameters: //// //// Input, int N, the number of entries in the vectors. //// //// Input/output, double X[*], one of the vectors to swap. //// //// Input, int INCX, the increment between successive entries of X. //// //// Input/output, double Y[*], one of the vectors to swap. //// //// Input, int INCY, the increment between successive elements of Y. //// //void dswap(int n, double x[], int incx, double y[], int incy) //{ // int i; // int ix; // int iy; // int m; // double temp; // // if (n <= 0) // { // } // else if (incx == 1 && incy == 1) // { // m = n % 3; // // for (i = 0; i < m; ++i) // { // temp = x[i]; // x[i] = y[i]; // y[i] = temp; // } // // for (i = m; i < n; i = i + 3) // { // temp = x[i]; // x[i] = y[i]; // y[i] = temp; // // temp = x[i + 1]; // x[i + 1] = y[i + 1]; // y[i + 1] = temp; // // temp = x[i + 2]; // x[i + 2] = y[i + 2]; // y[i + 2] = temp; // } // } // else // { // if (0 <= incx) // { // ix = 0; // } // else // { // ix = (-n + 1) * incx; // } // // if (0 <= incy) // { // iy = 0; // } // else // { // iy = (-n + 1) * incy; // } // // for (i = 0; i < n; ++i) // { // temp = x[ix]; // x[ix] = y[iy]; // y[iy] = temp; // ix = ix + incx; // iy = iy + incy; // } // } // // return; //} // // Purpose: // // PHI1 evaluates the multiquadric radial basis function. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int N, the number of points. // // Input, double R[N], the radial separation. // 0 < R. // // Input, double R0, a scale factor. // // Output, double V[N], the value of the radial basis function. // void phi1(int n, double r[], double r0, double v[]) { int i; for (i = 0; i < n; ++i) { v[i] = sqrt(r[i] * r[i] + r0 * r0); } return; } // // Purpose: // // PHI2 evaluates the inverse multiquadric radial basis function. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int N, the number of points. // // Input, double R[N], the radial separation. // 0 < R. // // Input, double R0, a scale factor. // // Output, double V[N], the value of the radial basis function. // void phi2(int n, double r[], double r0, double v[]) { int i; for (i = 0; i < n; ++i) { v[i] = 1.0 / sqrt(r[i] * r[i] + r0 * r0); } return; } // // Purpose: // // PHI3 evaluates the thin-plate spline radial basis function. // // Discussion: // // Note that PHI3(R,R0) is negative if R < R0. Thus, for this basis // function, it may be desirable to choose a value of R0 smaller than any // possible R. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int N, the number of points. // // Input, double R[N], the radial separation. // 0 < R. // // Input, double R0, a scale factor. // // Output, double V[N], the value of the radial basis function. // void phi3(int n, double r[], double r0, double v[]) { int i; for (i = 0; i < n; ++i) { if (r[i] <= 0.0) { v[i] = 0.0; } else { v[i] = r[i] * r[i] * log(r[i] / r0); } } return; } // // Purpose: // // PHI4 evaluates the gaussian radial basis function. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int N, the number of points. // // Input, double R[N], the radial separation. // 0 < R. // // Input, double R0, a scale factor. // // Output, double V[N], the value of the radial basis function. // void phi4(int n, double r[], double r0, double v[]) { int i; for (i = 0; i < n; ++i) { v[i] = exp(-0.5 * r[i] * r[i] / r0 / r0); } return; } // // Purpose: // // R8MAT_SOLVE_SVD solves a linear system A*x=b using the SVD. // // Discussion: // // When the system is determined, the solution is the solution in the // ordinary sense, and A*x = b. // // When the system is overdetermined, the solution minimizes the // L2 norm of the residual ||A*x-b||. // // When the system is underdetermined, ||A*x-b|| should be zero, and // the solution is the solution of minimum L2 norm, ||x||. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Parameters: // // Input, int M, N, the number of rows and columns // in the matrix A. // // Input, double A[M,*N], the matrix. // // Input, double B[M], the right hand side. // // Output, double R8MAT_SOLVE_SVD[N], the solution. // double *r8mat_solve_svd(int m, int n, double a[], double b[]) { double *a_copy; double *a_pseudo; double *e; int i; int info; int j; int k; int l; int lda; int ldu; int ldv; int job; int lwork; double *s; double *sp; double *sdiag; double *u; double *v; double *work; double *x; // // Compute the SVD decomposition. // a_copy = r8mat_copy_new(m, n, a); lda = m; sdiag = new double[i4_max(m + 1, n)]; e = new double[i4_max(m + 1, n)]; u = new double[m * m]; ldu = m; v = new double[n * n]; ldv = n; work = new double[m]; job = 11; //void dgesvd(const char* jobu, const char* jobvt, const MKL_INT* m, // const MKL_INT* n, double* a, const MKL_INT* lda, double* s, // double* u, const MKL_INT* ldu, double* vt, const MKL_INT* ldvt, // double* work, const MKL_INT* lwork, MKL_INT* info); info = dsvdc(a_copy, lda, m, n, sdiag, e, u, ldu, v, ldv, work, job); if (info != 0) { cerr << std::endl; cerr << "R8MAT_SOLVE_SVD - Fatal error!\n"; cerr << " The SVD could not be calculated.\n"; cerr << " LINPACK routine DSVDC returned a nonzero\n"; cerr << " value of the error flag, INFO = " << info << std::endl; exit(1); } s = new double[m * n]; for (j = 0; j < n; ++j) { for (i = 0; i < m; ++i) { s[i + j * m] = 0.0; } } for (i = 0; i < i4_min(m, n); ++i) { s[i + i * m] = sdiag[i]; } // // Compute the pseudo inverse. // sp = new double[n * m]; for (j = 0; j < m; ++j) { for (i = 0; i < n; ++i) { sp[i + j * m] = 0.0; } } for (i = 0; i < i4_min(m, n); ++i) { if (s[i + i * m] != 0.0) { sp[i + i * n] = 1.0 / s[i + i * m]; } } a_pseudo = new double[n * m]; for (j = 0; j < m; ++j) { for (i = 0; i < n; ++i) { a_pseudo[i + j * n] = 0.0; for (k = 0; k < n; k++) { for (l = 0; l < m; l++) { a_pseudo[i + j * n] = a_pseudo[i + j * n] + v[i + k * n] * sp[k + l * n] * u[j + l * m]; } } } } // // Compute x = A_pseudo * b. // x = r8mat_mv_new(n, m, a_pseudo, b); delete[] a_copy; delete[] a_pseudo; delete[] e; delete[] s; delete[] sdiag; delete[] sp; delete[] u; delete[] v; delete[] work; return x; } // // Purpose: // // RBF_INTERP_ND evaluates a radial basis function interpolant. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int M, the spatial dimension. // // Input, int ND, the number of data points. // // Input, double XD[M*ND], the data points. // // Input, double R0, a scale factor. R0 should be larger than the typical // separation between points, but smaller than the maximum separation. // The value of R0 has a significant effect on the resulting interpolant. // // Input, void PHI ( int N, double R[], double R0, double V[] ), a // function to evaluate the radial basis functions. // // Input, double W[ND], the weights, as computed by RBF_WEIGHTS. // // Input, int NI, the number of interpolation points. // // Input, double XI[M*NI], the interpolation points. // // Output, double RBF_INTERP_ND[NI], the interpolated values. // double *rbf_interp(int m, int nd, double xd[], double r0, void(*phi)(int n, double r[], double r0, double v[]), double w[], int ni, double xi[]) { double *fi; int i; int j; int k; double *r; double *v; fi = new double[ni]; r = new double[nd]; v = new double[nd]; for (i = 0; i < ni; ++i) { for (j = 0; j < nd; ++j) { r[j] = 0.0; for (k = 0; k < m; k++) { r[j] = r[j] + pow(xi[k + i * m] - xd[k + j * m], 2); } r[j] = sqrt(r[j]); } phi(nd, r, r0, v); fi[i] = r8vec_dot_product(nd, v, w); } delete[] r; delete[] v; return fi; } // // Purpose: // // RBF_WEIGHT computes weights for radial basis function interpolation. // // Discussion: // // We assume that there are N (nonsingular) equations in N unknowns. // // However, it should be clear that, if we are willing to do some kind // of least squares calculation, we could allow for singularity, // inconsistency, or underdetermine systems. This could be associated // with data points that are very close or repeated, a smaller number // of data points than function values, or some other ill-conditioning // of the system arising from a peculiarity in the point spacing. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 30 June 2012 // // Author: // // John Burkardt // // Reference: // // William Press, Brian Flannery, Saul Teukolsky, William Vetterling, // Numerical Recipes in FORTRAN: The Art of Scientific Computing, // Third Edition, // Cambridge University Press, 2007, // ISBN13: 978-0-521-88068-8, // LC: QA297.N866. // // Parameters: // // Input, int M, the spatial dimension. // // Input, int ND, the number of data points. // // Input, double XD[M*ND], the data points. // // Input, double R0, a scale factor. R0 should be larger than the typical // separation between points, but smaller than the maximum separation. // The value of R0 has a significant effect on the resulting interpolant. // // Input, void PHI ( int N, double R[], double R0, double V[] ), a // function to evaluate the radial basis functions. // // Input, double FD[ND], the function values at the data points. // // Output, double RBF_WEIGHT[ND], the weights. // double *rbf_weight(int m, int nd, double xd[], double r0, void(*phi)(int n, double r[], double r0, double v[]), double fd[]) { double *a; int i; int j; int k; double *r; double *v; double *w; a = new double[nd * nd]; r = new double[nd]; v = new double[nd]; for (i = 0; i < nd; ++i) { for (j = 0; j < nd; ++j) { r[j] = 0.0; for (k = 0; k < m; k++) { r[j] = r[j] + pow(xd[k + i * m] - xd[k + j * m], 2); } r[j] = sqrt(r[j]); } phi(nd, r, r0, v); for (j = 0; j < nd; ++j) { a[i + j * nd] = v[j]; } } // // Solve for the weights. // w = r8mat_solve_svd(nd, nd, a, fd); delete[] a; delete[] r; delete[] v; return w; }
24.198903
152
0.434378
trmcnealy
6d00895d14c5f6f9a4a3f7953782bd1c93a46107
1,806
cpp
C++
10. DP/Q_stair-case.cpp
bhavinvirani/Competitive-Programming-coding-ninjas
5e50ae7ad3fc969a4970f91f8d895c986353bb71
[ "MIT" ]
null
null
null
10. DP/Q_stair-case.cpp
bhavinvirani/Competitive-Programming-coding-ninjas
5e50ae7ad3fc969a4970f91f8d895c986353bb71
[ "MIT" ]
null
null
null
10. DP/Q_stair-case.cpp
bhavinvirani/Competitive-Programming-coding-ninjas
5e50ae7ad3fc969a4970f91f8d895c986353bb71
[ "MIT" ]
null
null
null
/* StairCase Problem Send Feedback A child is running up a staircase with n steps and can hop either 1 step, 2 steps or 3 steps at a time. Implement a method to count how many possible ways the child can run up to the stairs. You need to return all possible number of ways. Time complexity of your code should be O(n). Since the answer can be pretty large print the answer % mod(10^9 +7) Input Format: First line will contain T (number of test case). Each test case is consists of a single line containing an integer N. Output Format: For each test case print the answer in new line Constraints : 1 <= T < = 10 1 <= N <= 10^5 */ #include <bits/stdc++.h> using namespace std; int steps(int n) { if (n == 0) return 1; if (n == 1) return 1; if (n == 2) return 2; return steps(n - 1) + steps(n - 2) + steps(n - 3); } int steps_memo(int n, long memo[]) { if (n == 0) return 1; if (n == 1) return 1; if (n == 2) return 2; if(memo[n] > 0){ return memo[n]; } int output = steps_memo(n-1, memo) + steps_memo(n-2, memo) + steps_memo(n-3, memo); memo[n] = output; return output; } int steps_iter(int n){ int arr[n+1]; arr[0] = 0; arr[1] = 1; arr[2] = 2; arr[3] = 3; for(int i = 4; i <= n; i++){ arr[i] = arr[i-1] + arr[i-2] + arr[i-3]; } return arr[n]; } int main() { freopen("/home/spy/Desktop/input.txt", "r", stdin); freopen("/home/spy/Desktop/output.txt", "w", stdout); int t; cin >> t; while (t--) { int n; cin >> n; // int ans = steps(n); // long memo[10000000] = {0}; // int ans = steps_memo(n, memo); int ans = steps_iter(n); cout << ans << endl; } return 0; }
22.02439
238
0.555925
bhavinvirani
6d00f970a8e31c0262c67ea67b7b2442ae81fd8f
1,269
hpp
C++
Systems/Physics/EllipsoidCollider.hpp
RachelWilSingh/ZeroCore
e9a2f82d395e5c89fb98eceac44ce60d016dbff3
[ "MIT" ]
52
2018-09-11T17:18:35.000Z
2022-03-13T15:28:21.000Z
Systems/Physics/EllipsoidCollider.hpp
RachelWilSingh/ZeroCore
e9a2f82d395e5c89fb98eceac44ce60d016dbff3
[ "MIT" ]
1,409
2018-09-19T18:03:43.000Z
2021-06-09T08:33:33.000Z
Systems/Physics/EllipsoidCollider.hpp
RachelWilSingh/ZeroCore
e9a2f82d395e5c89fb98eceac44ce60d016dbff3
[ "MIT" ]
26
2018-09-11T17:16:32.000Z
2021-11-22T06:21:19.000Z
/////////////////////////////////////////////////////////////////////////////// /// /// Authors: Joshua Claeys, Joshua Davis /// Copyright 2010-2017, DigiPen Institute of Technology /// /////////////////////////////////////////////////////////////////////////////// #pragma once namespace Zero { /// Defines the collision volume for an ellipsoid (3 dimensional ellipse) defined by three radius values. class EllipsoidCollider : public Collider { public: ZilchDeclareType(TypeCopyMode::ReferenceType); EllipsoidCollider(); // Component interface void Serialize(Serializer& stream) override; void DebugDraw() override; // Collider Interface void ComputeWorldAabbInternal() override; void ComputeWorldBoundingSphereInternal() override; real ComputeWorldVolumeInternal() override; void ComputeLocalInverseInertiaTensor(real mass, Mat3Ref localInvInertia) override; void Support(Vec3Param direction, Vec3Ptr support) const override; /// The x, y, and z radius of the ellipsoid. Vec3 GetRadii() const; void SetRadii(Vec3Param radii); /// The radii of the ellipsoid after transform is applied (scale and rotation). Vec3 GetWorldRadii() const; private: Vec3 mRadii; }; }//namespace Zero
28.840909
106
0.638298
RachelWilSingh
6d0282d543b2fffb53690d952166994781812219
347
cpp
C++
arc/arc038/b/main.cpp
wotsushi/competitive-programming
17ec8fd5e1c23aee626aee70b1c0da8d7f8b8c86
[ "MIT" ]
3
2019-06-25T06:17:38.000Z
2019-07-13T15:18:51.000Z
arc/arc038/b/main.cpp
wotsushi/competitive-programming
17ec8fd5e1c23aee626aee70b1c0da8d7f8b8c86
[ "MIT" ]
null
null
null
arc/arc038/b/main.cpp
wotsushi/competitive-programming
17ec8fd5e1c23aee626aee70b1c0da8d7f8b8c86
[ "MIT" ]
null
null
null
#include "template.hpp" int main() { ll(H, W); vin(string, S, H); auto dp = vecv(bool, H + 1, W + 1, true); rrep(i, H) { rrep(j, W) { if (S[i][j] == '#') { dp[i][j] = true; } else { dp[i][j] = not(dp[i + 1][j] and dp[i][j + 1] and dp[i + 1][j + 1]); } } } yes(dp[0][0], "First", "Second"); }
19.277778
75
0.397695
wotsushi
6d09abf8e4aa4b5966027c71f956344eb12a758d
4,778
cpp
C++
allegro-5.0/examples/ex_audio_props.cpp
fsande/PFC-2012-2013-EMIR-PedroHernandez
2387a8e97ee399ae453f3f9e43e2dd1cb4c0cd4c
[ "MIT" ]
null
null
null
allegro-5.0/examples/ex_audio_props.cpp
fsande/PFC-2012-2013-EMIR-PedroHernandez
2387a8e97ee399ae453f3f9e43e2dd1cb4c0cd4c
[ "MIT" ]
null
null
null
allegro-5.0/examples/ex_audio_props.cpp
fsande/PFC-2012-2013-EMIR-PedroHernandez
2387a8e97ee399ae453f3f9e43e2dd1cb4c0cd4c
[ "MIT" ]
null
null
null
/* * Example program for the Allegro library, by Peter Wang. * * Test audio properties (gain and panning, for now). */ #include "allegro5/allegro.h" #include "allegro5/allegro_image.h" #include "allegro5/allegro_font.h" #include "allegro5/allegro_primitives.h" #include "allegro5/allegro_audio.h" #include "allegro5/allegro_acodec.h" #include "nihgui.hpp" #include <cstdio> #include "common.c" ALLEGRO_FONT *font_gui; ALLEGRO_SAMPLE *sample; ALLEGRO_SAMPLE_INSTANCE *sample_inst; class Prog { private: Dialog d; ToggleButton pan_button; HSlider pan_slider; Label speed_label; HSlider speed_slider; ToggleButton bidir_button; Label gain_label; VSlider gain_slider; Label mixer_gain_label; VSlider mixer_gain_slider; Label two_label; Label one_label; Label zero_label; public: Prog(const Theme & theme, ALLEGRO_DISPLAY *display); void run(); void update_properties(); }; Prog::Prog(const Theme & theme, ALLEGRO_DISPLAY *display) : d(Dialog(theme, display, 40, 20)), pan_button(ToggleButton("Pan")), pan_slider(HSlider(1000, 2000)), speed_label(Label("Speed")), speed_slider(HSlider(1000, 5000)), bidir_button(ToggleButton("Bidir")), gain_label(Label("Gain")), gain_slider(VSlider(1000, 2000)), mixer_gain_label(Label("Mixer gain")), mixer_gain_slider(VSlider(1000, 2000)), two_label(Label("2.0")), one_label(Label("1.0")), zero_label(Label("0.0")) { pan_button.set_pushed(true); d.add(pan_button, 2, 10, 4, 1); d.add(pan_slider, 6, 10, 22, 1); d.add(speed_label, 2, 12, 4, 1); d.add(speed_slider, 6, 12, 22, 1); d.add(bidir_button, 2, 14, 4, 1); d.add(gain_label, 29, 1, 2, 1); d.add(gain_slider, 29, 2, 2, 17); d.add(mixer_gain_label, 33, 1, 6, 1); d.add(mixer_gain_slider, 35, 2, 2, 17); d.add(two_label, 32, 2, 2, 1); d.add(one_label, 32, 10, 2, 1); d.add(zero_label, 32, 18, 2, 1); } void Prog::run() { d.prepare(); while (!d.is_quit_requested()) { if (d.is_draw_requested()) { update_properties(); al_clear_to_color(al_map_rgb(128, 128, 128)); d.draw(); al_flip_display(); } d.run_step(true); } } void Prog::update_properties() { float pan; float speed; float gain; float mixer_gain; if (pan_button.get_pushed()) pan = pan_slider.get_cur_value() / 1000.0f - 1.0f; else pan = ALLEGRO_AUDIO_PAN_NONE; al_set_sample_instance_pan(sample_inst, pan); speed = speed_slider.get_cur_value() / 1000.0f; al_set_sample_instance_speed(sample_inst, speed); if (bidir_button.get_pushed()) al_set_sample_instance_playmode(sample_inst, ALLEGRO_PLAYMODE_BIDIR); else al_set_sample_instance_playmode(sample_inst, ALLEGRO_PLAYMODE_LOOP); gain = gain_slider.get_cur_value() / 1000.0f; al_set_sample_instance_gain(sample_inst, gain); mixer_gain = mixer_gain_slider.get_cur_value() / 1000.0f; al_set_mixer_gain(al_get_default_mixer(), mixer_gain); } int main(int argc, char **argv) { ALLEGRO_DISPLAY *display; const char *filename; if (argc >= 2) { filename = argv[1]; } else { filename = "data/testing.ogg"; } if (!al_init()) { abort_example("Could not init Allegro\n"); return 1; } al_install_keyboard(); al_install_mouse(); al_init_image_addon(); al_init_font_addon(); al_init_primitives_addon(); al_init_acodec_addon(); if (!al_install_audio()) { abort_example("Could not init sound!\n"); return 1; } if (!al_reserve_samples(1)) { abort_example("Could not set up voice and mixer.\n"); return 1; } sample = al_load_sample(filename); if (!sample) { abort_example("Could not load sample from '%s'!\n", filename); } al_set_new_display_flags(ALLEGRO_GENERATE_EXPOSE_EVENTS); display = al_create_display(640, 480); if (!display) { abort_example("Unable to create display\n"); return 1; } font_gui = al_load_font("data/fixed_font.tga", 0, 0); if (!font_gui) { abort_example("Failed to load data/fixed_font.tga\n"); return 1; } /* Loop the sample. */ sample_inst = al_create_sample_instance(sample); al_set_sample_instance_playmode(sample_inst, ALLEGRO_PLAYMODE_LOOP); al_attach_sample_instance_to_mixer(sample_inst, al_get_default_mixer()); al_play_sample_instance(sample_inst); /* Don't remove these braces. */ { Theme theme(font_gui); Prog prog(theme, display); prog.run(); } al_destroy_sample_instance(sample_inst); al_destroy_sample(sample); al_uninstall_audio(); al_destroy_font(font_gui); return 0; (void)argc; (void)argv; } /* vim: set sts=3 sw=3 et: */
23.653465
75
0.66869
fsande
6d09f3888fd57c69b14fae18c602bf3b1c68a260
2,698
hh
C++
src/windows/kernel/nt/types/registry/HIVE_IMPL.hh
srpape/IntroVirt
fe553221c40b8ef71f06e79c9d54d9e123a06c89
[ "Apache-2.0" ]
null
null
null
src/windows/kernel/nt/types/registry/HIVE_IMPL.hh
srpape/IntroVirt
fe553221c40b8ef71f06e79c9d54d9e123a06c89
[ "Apache-2.0" ]
null
null
null
src/windows/kernel/nt/types/registry/HIVE_IMPL.hh
srpape/IntroVirt
fe553221c40b8ef71f06e79c9d54d9e123a06c89
[ "Apache-2.0" ]
null
null
null
/* * Copyright 2021 Assured Information Security, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "HBASE_BLOCK_IMPL.hh" #include "windows/kernel/nt/structs/structs.hh" #include <introvirt/core/memory/guest_ptr.hh> #include <introvirt/fwd.hh> #include <introvirt/windows/kernel/nt/types/registry/CM_KEY_NODE.hh> #include <introvirt/windows/kernel/nt/types/registry/HIVE.hh> #include <memory> #include <optional> namespace introvirt { namespace windows { namespace nt { template <typename PtrType> class NtKernelImpl; template <typename PtrType> class CM_KEY_NODE_IMPL; template <typename PtrType> class HIVE_IMPL final : public HIVE { public: const std::string& FileFullPath() const override; const std::string& FileUserName() const override; const std::string& HiveRootPath() const override; const HBASE_BLOCK& BaseBlock() const override; const CM_KEY_NODE* RootKeyNode() const override; const CM_KEY_NODE* KeyNode(uint32_t KeyIndex) const override; GuestVirtualAddress CellAddress(uint32_t KeyIndex) const override; const HIVE* PreviousHive() const override; const HIVE* NextHive() const override; uint32_t HiveFlags() const override; GuestVirtualAddress address() const override; HIVE_IMPL(const NtKernelImpl<PtrType>& kernel, const GuestVirtualAddress& gva); ~HIVE_IMPL() override; private: GuestVirtualAddress getBlockAddress(GuestVirtualAddress pEntry) const; const NtKernelImpl<PtrType>& kernel_; const GuestVirtualAddress gva_; const structs::CMHIVE* cmhive_; const structs::DUAL* dual_; const structs::HMAP_ENTRY* hmap_entry_; guest_ptr<char[]> cmhive_buffer_; mutable std::unordered_map<uint32_t, std::unique_ptr<CM_KEY_NODE_IMPL<PtrType>>> KeyIndexNodeMap_; mutable std::optional<HBASE_BLOCK_IMPL<PtrType>> BaseBlock_; mutable std::string FileFullPath_; mutable std::string FileUserName_; mutable std::string HiveRootPath_; mutable std::unique_ptr<HIVE_IMPL<PtrType>> PreviousHive_; mutable std::unique_ptr<HIVE_IMPL<PtrType>> NextHive_; }; } // namespace nt } // namespace windows } // namespace introvirt
32.506024
84
0.752039
srpape
6d0e9d9ba5800bc7279128bb9514268c45937e64
70
cpp
C++
Source/RenderSettings.cpp
historyme/MineCraft-One-Week-Challenge
7053beef10f841f52879e025026d08e4c26c4b62
[ "Apache-2.0" ]
1
2020-04-21T18:47:09.000Z
2020-04-21T18:47:09.000Z
Source/RenderSettings.cpp
UglySwedishFish/MineCraft-One-Week-Challenge
2d8859a977224c1f3d184ab8f2d50f17e43ce6ba
[ "Apache-2.0" ]
null
null
null
Source/RenderSettings.cpp
UglySwedishFish/MineCraft-One-Week-Challenge
2d8859a977224c1f3d184ab8f2d50f17e43ce6ba
[ "Apache-2.0" ]
1
2018-09-14T09:01:50.000Z
2018-09-14T09:01:50.000Z
#include "RenderSettings.h" RenderSettings g_renderSettings = {0, 0};
23.333333
41
0.771429
historyme
6d0f175c01af31d5bfb0c5bea4d8f9ce695de2c7
7,129
cpp
C++
chocChipChess/search.cpp
GenericCinnamon/chocchipchess
793ea775b6b96df1157c9e712a420add7d21f89b
[ "MIT" ]
null
null
null
chocChipChess/search.cpp
GenericCinnamon/chocchipchess
793ea775b6b96df1157c9e712a420add7d21f89b
[ "MIT" ]
null
null
null
chocChipChess/search.cpp
GenericCinnamon/chocchipchess
793ea775b6b96df1157c9e712a420add7d21f89b
[ "MIT" ]
null
null
null
#include "search.h" #include <math.h> Search::Search() { } //function negamax(node, depth, α, β, color) int Search::negamax(Position& position, int depth, int alpha, int beta) { if (stopThinking) throw exit_search(); // From https://en.wikipedia.org/wiki/Negamax //alphaOrig : = α int alpha_original = alpha; // Transposition Table Lookup; node is the lookup key for ttEntry //ttEntry : = TranspositionTableLookup(node) auto tt_entry = tt->retrieve(zobristHash); //if ttEntry is valid and ttEntry.depth ≥ depth if (tt_entry != NULL && tt_entry->depth >= depth) { // Add depth punishment if there's a checkmate coming up int retrieved_eval = tt_entry->eval; //if ttEntry.Flag = EXACT if (tt_entry->flag == TranspositionTable::EntryType::EXACT) //return ttEntry.Value return retrieved_eval; //else if ttEntry.Flag = LOWERBOUND else if (tt_entry->flag == TranspositionTable::EntryType::LOWER) //α : = max(α, ttEntry.Value) alpha = max(alpha, retrieved_eval); //else if ttEntry.Flag = UPPERBOUND else if (tt_entry->flag == TranspositionTable::EntryType::UPPER) //β : = min(β, ttEntry.Value) beta = min(beta, retrieved_eval); //if α ≥ β if (alpha >= beta) //return ttEntry.Value return tt_entry->eval; } //if depth = 0 or node is a terminal node if (depth == 0) //return color * the heuristic value of node return sideSign(sideToMove) * calculateStaticEval(); //bestValue : = -∞ int best_value = -CHECKMATE_VALUE; //childNodes : = GenerateMoves(node) auto move_list = genMoves(); // If this is a terminal node return the checkmate or stalemate score if (move_list.size() == 0) { int ending_value = checkCheck(sideToMove) ? -CHECKMATE_VALUE : 0; tt->insert(zobristHash, ending_value, depth, TranspositionTable::EntryType::EXACT); return ending_value; } //childNodes : = OrderMoves(childNodes) sort(move_list.begin(), move_list.end(), Move::greater); //foreach child in childNodes for (auto move : move_list) { performMove(&move); //v : = -negamax(child, depth - 1, -β, -α, -color) int value = -negamax(depth - 1, -beta, -alpha); undoMove(&move); //bestValue : = max(bestValue, v) best_value = max(best_value, value); //α : = max(α, v) alpha = max(alpha, value); //if α ≥ β if (alpha >= beta) //break break; } // Transposition Table Store; node is the lookup key for ttEntry TranspositionTable::EntryType entry_type; //ttEntry.Value : = bestValue //if bestValue ≤ alphaOrig if (best_value <= alpha_original) //ttEntry.Flag : = UPPERBOUND entry_type = TranspositionTable::EntryType::UPPER; //else if bestValue ≥ β else if (best_value >= beta) //ttEntry.Flag : = LOWERBOUND entry_type = TranspositionTable::EntryType::LOWER; //else else //ttEntry.Flag : = EXACT entry_type = TranspositionTable::EntryType::EXACT; //endif //ttEntry.depth : = depth //TranspositionTableStore(node, ttEntry) tt->insert(zobristHash, best_value, depth, entry_type); //return bestValue return best_value; } int Search::terminateSearch(int alpha, int beta) { if (stopThinking) throw exit_search(); vector<Move> move_list = genMoves(); move_list.erase(remove_if(move_list.begin(), move_list.end(), Move::isNotCapture), move_list.end()); if (move_list.size() == 0) return calculateStaticEval(); int best_value = sideToMove == WHITE ? INT_MIN : INT_MAX; sort(move_list.begin(), move_list.end(), sideToMove == WHITE ? Move::greater : Move::lesser); for (auto& move : move_list) { int eval; performMove(&move); auto tt_entry = tt->retrieve(zobristHash); if (tt_entry == NULL) { eval = terminateSearch(alpha, beta); tt->insert(zobristHash, eval, 1, TranspositionTable::EntryType::EXACT); } else eval = tt_entry->eval; undoMove(&move); best_value = sideToMove == WHITE ? max(best_value, eval) : min(best_value, eval); sideToMove == WHITE ? alpha = max(alpha, eval) : beta = min(beta, eval); if (beta <= alpha) break; } return best_value; } /* ponder - analyse the position without care for depth of the search */ void Search::ponderPosition(Position& position) { ponderPosition(position, 0); } /* ponder - analyse the position without care for depth of the search */ void Search::ponderPosition(Position& position, int depth) { if (stopThinking) return; try { string send = "info score cp "; int score = sideSign(sideToMove) * negamax(depth, INT_MIN, INT_MAX); send += to_string(score) + " depth " + to_string(depth) + " pv"; auto pvs = new vector<Move>(); getPV(pvs, depth); for (auto it : *pvs) send += " " + it.getName(); output->output(send); } catch (exit_search e) {} vector<Move> move_list = genMoves(); if (move_list.size() == 0) return; sort(move_list.begin(), move_list.end(), Move::greater); auto best_move = move_list.at(0); if (abs(best_move.eval) > CHECKMATE_THRESHOLD) output->debug("Found a checkmate in " + to_string(best_move.depth) + " starting with " + best_move.getName()); int padding = 10; string debugStringMoveName = "Move |"; string debugStringEval = "Eval |"; string debugStringDepth = "Depth |"; for (auto move : move_list) { string move_name = move.getName(); string move_eval = to_string(move.eval); string move_depth = to_string(move.depth); debugStringMoveName += " " + string(10 - move_name.length(), ' ') + move.getName() + " |"; debugStringEval += " " + string(10 - move_eval.length(), ' ') + to_string(move.eval) + " |"; debugStringDepth += " " + string(10 - move_depth.length(), ' ') + to_string(move.depth) + " |"; } output->debug("Debug: move list\n" + debugStringMoveName + "\n" + debugStringEval + "\n" + debugStringDepth + "\n"); output->debug("Debug: bestmove " + best_move.getName()); ponder(depth + 1); } /* getPV - return what the engine considers the best line for the given depth */ void Search::getPV(vector<Move>* move_list, int depth) { Move* pv = topMove(); if (pv == NULL) return; move_list->push_back(Move(*pv)); performMove(pv); if (depth > 0) getPV(move_list, depth - 1); undoMove(pv); } /* topMove - Return the current top move */ Move* Search::topMove() { // Evaluate each move vector<Move> move_list = genMoves(); sort(move_list.begin(), move_list.end(), Move::greater); if (move_list.size() == 0) return NULL; return new Move(move_list[0]); }
29.217213
120
0.605695
GenericCinnamon
6d11c34c4c0f95e44b6fd6706510363a865d813d
4,839
cpp
C++
src/aimp_dotnet/SDK/MusicLibrary/DataFilter/AimpDataFilterGroup.cpp
Smartoteka/aimp_dotnet
544502b8d080c9280ba11917ef0cc3e8dec44234
[ "Apache-2.0" ]
52
2015-04-14T14:39:30.000Z
2022-02-07T07:16:05.000Z
src/aimp_dotnet/SDK/MusicLibrary/DataFilter/AimpDataFilterGroup.cpp
Smartoteka/aimp_dotnet
544502b8d080c9280ba11917ef0cc3e8dec44234
[ "Apache-2.0" ]
11
2015-04-02T10:45:55.000Z
2022-02-03T07:21:53.000Z
src/aimp_dotnet/SDK/MusicLibrary/DataFilter/AimpDataFilterGroup.cpp
Smartoteka/aimp_dotnet
544502b8d080c9280ba11917ef0cc3e8dec44234
[ "Apache-2.0" ]
9
2015-04-05T18:25:57.000Z
2022-02-07T07:20:23.000Z
// ---------------------------------------------------- // AIMP DotNet SDK // Copyright (c) 2014 - 2020 Evgeniy Bogdan // https://github.com/martin211/aimp_dotnet // Mail: mail4evgeniy@gmail.com // ---------------------------------------------------- #include "Stdafx.h" #include "AimpDataFilterGroup.h" #include "AimpDataFieldFilter.h" #include "AimpDataFieldFilterByArray.h" using namespace AIMP::SDK; // TODO: #18 AimpDataFilterGroup::AimpDataFilterGroup(IAIMPMLDataFilterGroup* filterGroup) : AimpObject(filterGroup, false) { } FilterGroupOperationType AimpDataFilterGroup::Operation::get() { return FilterGroupOperationType(PropertyListExtension::GetInt32(InternalAimpObject, AIMPML_FILTERGROUP_OPERATION)); } void AimpDataFilterGroup::Operation::set(FilterGroupOperationType val) { PropertyListExtension::SetInt32(InternalAimpObject, AIMPML_FILTERGROUP_OPERATION, static_cast<int>(val)); } AimpActionResult<IAimpDataFieldFilter^>^ AimpDataFilterGroup::Add( String^ field, Object^ value1, Object^ value2, FieldFilterOperationType operation) { IAimpDataFieldFilter^ filter = nullptr; IAIMPMLDataFieldFilter* nativeFilter = nullptr; ActionResultType result = ActionResultType::Fail; VARIANT val1 = AimpConverter::ToNativeVariant(value1); VARIANT val2 = AimpConverter::ToNativeVariant(value2); VARIANT v1; VariantInit(&v1); auto sField = AimpConverter::ToAimpString(field); try { result = CheckResult(InternalAimpObject->Add( sField, &val1, &val2, static_cast<int>(operation), &nativeFilter)); if (result == ActionResultType::OK && nativeFilter != nullptr) { filter = gcnew AimpDataFieldFilter(nativeFilter); } } finally { if (sField != nullptr) { sField->Release(); sField = nullptr; } } return gcnew AimpActionResult<IAimpDataFieldFilter^>(result, filter); } AimpActionResult<IAimpDataFieldFilterByArray^>^ AimpDataFilterGroup::Add( String^ field, array<Object^>^ values, int count) { IAIMPMLDataFieldFilterByArray* nativeObj = nullptr; auto cnt = values->Length; VARIANT* variants = new VARIANT[cnt]; IAimpDataFieldFilterByArray^ filter = nullptr; for (int i = 0; i < values->Length; i++) { variants[i] = AimpConverter::ToNativeVariant(values[i]); } const auto result = CheckResult(InternalAimpObject->Add2( AimpConverter::ToAimpString(field), &variants[0], count, &nativeObj)); if (result == ActionResultType::OK && nativeObj != nullptr) { filter = gcnew AimpDataFieldFilterByArray(nativeObj); } return gcnew AimpActionResult<IAimpDataFieldFilterByArray^>(result, filter); } AimpActionResult<IAimpDataFilterGroup^>^ AimpDataFilterGroup::AddGroup() { IAIMPMLDataFilterGroup* nativeGroup = nullptr; const ActionResultType result = CheckResult(InternalAimpObject->AddGroup(&nativeGroup)); IAimpDataFilterGroup^ group = nullptr; if (result == ActionResultType::OK && nativeGroup != nullptr) { group = gcnew AimpDataFilterGroup(nativeGroup); } return gcnew AimpActionResult<IAimpDataFilterGroup^>(result, group); } ActionResult AimpDataFilterGroup::Clear() { return ACTION_RESULT(CheckResult(InternalAimpObject->Clear())); } ActionResult AimpDataFilterGroup::Delete(int index) { return ACTION_RESULT(CheckResult(InternalAimpObject->Delete(index))); } int AimpDataFilterGroup::GetChildCount() { return InternalAimpObject->GetChildCount(); } AimpActionResult<IAimpDataFilterGroup^>^ AimpDataFilterGroup::GetFilterGroup(int index) { IAimpDataFilterGroup^ group = nullptr; IAIMPMLDataFilterGroup* child = nullptr; const auto result = CheckResult( InternalAimpObject->GetChild(index, IID_IAIMPMLDataFilterGroup, reinterpret_cast<void**>(&child))); if (result == ActionResultType::OK && child != nullptr) { group = gcnew AimpDataFilterGroup(child); } return gcnew AimpActionResult<IAimpDataFilterGroup^>(result, group); } AimpActionResult<IAimpDataFieldFilter^>^ AimpDataFilterGroup::GetFieldFilter(int index) { IAimpDataFieldFilter^ fieldFilter = nullptr; IAIMPMLDataFieldFilter* child = nullptr; const auto result = CheckResult( InternalAimpObject->GetChild(index, IID_IAIMPMLDataFieldFilter, reinterpret_cast<void**>(&child))); if (result == ActionResultType::OK && child != nullptr) { fieldFilter = gcnew AimpDataFieldFilter(child); } return gcnew AimpActionResult<IAimpDataFieldFilter^>(result, fieldFilter); } void AimpDataFilterGroup::BeginUpdate() { InternalAimpObject->BeginUpdate(); } void AimpDataFilterGroup::EndUpdate() { InternalAimpObject->EndUpdate(); }
32.695946
119
0.701178
Smartoteka
6d17b72637d5643b6b1ef7724ba53c07b8f67c4e
9,369
hpp
C++
externals/stlsoft-1.9.118/include/inetstl/error/exceptions.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
17
2015-03-26T14:10:25.000Z
2022-02-09T20:55:04.000Z
externals/stlsoft-1.9.118/include/inetstl/error/exceptions.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
null
null
null
externals/stlsoft-1.9.118/include/inetstl/error/exceptions.hpp
betasheet/diffingo
285d21b16c118155e5c149b20fcb20a20276f3d7
[ "MIT" ]
3
2019-05-05T22:10:56.000Z
2019-08-22T22:24:23.000Z
/* ///////////////////////////////////////////////////////////////////////// * File: inetstl/error/exceptions.hpp * * Purpose: Contains the internet_exception class. * * Created: 25th April 2004 * Updated: 10th August 2009 * * Home: http://stlsoft.org/ * * Copyright (c) 2004-2009, Matthew Wilson and Synesis Software * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of * any contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * ////////////////////////////////////////////////////////////////////// */ /** \file inetstl/error/exceptions.hpp * * \brief [C++ only] Definition of the inetstl::internet_exception and * exception class and the inetstl::throw_internet_exception_policy * exception policy class * (\ref group__library__error "Error" Library). */ #ifndef INETSTL_INCL_INETSTL_ERROR_HPP_EXCEPTIONS #define INETSTL_INCL_INETSTL_ERROR_HPP_EXCEPTIONS #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION # define INETSTL_VER_INETSTL_ERROR_HPP_EXCEPTIONS_MAJOR 4 # define INETSTL_VER_INETSTL_ERROR_HPP_EXCEPTIONS_MINOR 2 # define INETSTL_VER_INETSTL_ERROR_HPP_EXCEPTIONS_REVISION 1 # define INETSTL_VER_INETSTL_ERROR_HPP_EXCEPTIONS_EDIT 42 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ /* ///////////////////////////////////////////////////////////////////////// * Compatibility */ /* [DocumentationStatus:Ready] */ /* ///////////////////////////////////////////////////////////////////////// * Includes */ #ifndef INETSTL_INCL_INETSTL_H_INETSTL # include <inetstl/inetstl.h> #endif /* !INETSTL_INCL_INETSTL_H_INETSTL */ #ifndef STLSOFT_INCL_STLSOFT_ERROR_HPP_EXCEPTIONS # include <stlsoft/error/exceptions.hpp> #endif /* !STLSOFT_INCL_STLSOFT_ERROR_HPP_EXCEPTIONS */ #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_EXCEPTION_STRING # include <stlsoft/util/exception_string.hpp> #endif /* !STLSOFT_INCL_STLSOFT_UTIL_HPP_EXCEPTION_STRING */ #ifndef INETSTL_OS_IS_WINDOWS # include <errno.h> #endif /* !INETSTL_OS_IS_WINDOWS */ #ifndef STLSOFT_CF_EXCEPTION_SUPPORT # error This file cannot be included when exception-handling is not supported #endif /* !STLSOFT_CF_EXCEPTION_SUPPORT */ /* ///////////////////////////////////////////////////////////////////////// * Namespace */ #ifndef _INETSTL_NO_NAMESPACE # if defined(_STLSOFT_NO_NAMESPACE) || \ defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) /* There is no stlsoft namespace, so must define ::inetstl */ namespace inetstl { # else /* Define stlsoft::inetstl_project */ namespace stlsoft { namespace inetstl_project { # endif /* _STLSOFT_NO_NAMESPACE */ #endif /* !_INETSTL_NO_NAMESPACE */ /* ///////////////////////////////////////////////////////////////////////// * Classes */ /** \brief General exception class for internet-related failures. * * \ingroup group__library__error * */ class internet_exception : public os_exception { /// \name Types /// @{ protected: typedef stlsoft_ns_qual(exception_string) string_type; public: typedef os_exception parent_class_type; #ifdef INETSTL_OS_IS_WINDOWS typedef is_dword_t error_code_type; #else /* ? INETSTL_OS_IS_WINDOWS */ typedef int error_code_type; #endif /* INETSTL_OS_IS_WINDOWS */ typedef internet_exception class_type; /// @} /// \name Construction /// @{ public: ss_explicit_k internet_exception(error_code_type err) : m_reason() , m_errorCode(err) {} internet_exception(class_type const& rhs) : m_reason(rhs.m_reason) , m_errorCode(rhs.m_errorCode) {} internet_exception(char const* reason, error_code_type err) : m_reason(class_type::create_reason_(reason, err)) , m_errorCode(err) {} protected: internet_exception(string_type const& reason, error_code_type err) : m_reason(reason) , m_errorCode(err) {} public: /// Destructor /// /// \note This does not do have any implementation, but is required to placate /// the Comeau and GCC compilers, which otherwise complain about mismatched /// exception specifications between this class and its parent virtual ~internet_exception() stlsoft_throw_0() {} /// @} /// \name Accessors /// @{ public: virtual char const* what() const stlsoft_throw_0() { if(!m_reason.empty()) { return m_reason.c_str(); } else { return "internet failure"; } } /// The error code associated with the exception error_code_type get_error_code() const stlsoft_throw_0() { return m_errorCode; } /// [DEPRECATED] The error code associated with the exception /// /// \deprecated Use get_error_code() instead. error_code_type last_error() const stlsoft_throw_0() { return get_error_code(); } /// [DEPRECATED] The error code associated with the exception /// /// \deprecated Use get_error_code() instead. error_code_type error() const stlsoft_throw_0() { return get_error_code(); } /// @} /// \name Implementation /// @{ private: static string_type create_reason_(char const* reason, error_code_type err) { #ifdef INETSTL_OS_IS_WINDOWS if( err == static_cast<error_code_type>(E_OUTOFMEMORY) || err == static_cast<error_code_type>(ERROR_OUTOFMEMORY) || NULL == reason || '\0' == reason[0]) { return string_type(); } else #endif /* INETSTL_OS_IS_WINDOWS */ { return string_type(reason); } } /// @} /// \name Members /// @{ private: const string_type m_reason; error_code_type m_errorCode; /// @} /// \name Not to be implemented /// @{ private: class_type& operator =(class_type const&); /// @} }; /* ///////////////////////////////////////////////////////////////////////// * Policies */ /** \brief The policy class, which throws a internet_exception class. * * \ingroup group__library__error * */ // [[synesis:class:exception-policy: throw_internet_exception_policy]] struct throw_internet_exception_policy { /// \name Member Types /// @{ public: /// The thrown type typedef internet_exception thrown_type; typedef internet_exception::error_code_type error_code_type; /// @} /// \name Operators /// @{ public: /// Function call operator, taking no parameters void operator ()() const { #ifdef INETSTL_OS_IS_WINDOWS STLSOFT_THROW_X(thrown_type(::GetLastError())); #else /* ? INETSTL_OS_IS_WINDOWS */ STLSOFT_THROW_X(thrown_type(errno)); #endif /* INETSTL_OS_IS_WINDOWS */ } /// Function call operator, taking one parameter void operator ()(error_code_type err) const { STLSOFT_THROW_X(thrown_type(err)); } /// Function call operator, taking two parameters void operator ()(char const* reason, error_code_type err) const { STLSOFT_THROW_X(thrown_type(reason, err)); } /// @} }; /* ////////////////////////////////////////////////////////////////////// */ #ifndef _INETSTL_NO_NAMESPACE # if defined(_STLSOFT_NO_NAMESPACE) || \ defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) } // namespace inetstl # else } // namespace inetstl_project } // namespace stlsoft # endif /* _STLSOFT_NO_NAMESPACE */ #endif /* !_INETSTL_NO_NAMESPACE */ /* ////////////////////////////////////////////////////////////////////// */ #endif /* INETSTL_INCL_INETSTL_ERROR_HPP_EXCEPTIONS */ /* ///////////////////////////// end of file //////////////////////////// */
31.23
83
0.62045
betasheet
6d1843e5d96480fee0262275e9f376e0f8684137
792
cpp
C++
snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
2
2020-03-12T19:26:36.000Z
2022-01-10T21:45:33.000Z
snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
555
2019-09-23T22:22:58.000Z
2021-07-15T18:51:12.000Z
snippets/cpp/VS_Snippets_CLR_System/system.Decimal.ConvFrom.SInts/CPP/cfromint16.cpp
BohdanMosiyuk/samples
59d435ba9e61e0fc19f5176c96b1cdbd53596142
[ "CC-BY-4.0", "MIT" ]
3
2020-01-29T16:31:15.000Z
2021-08-24T07:00:15.000Z
//<Snippet3> using namespace System; void main() { // Define an array of 16-bit integer values. array<Int16>^ values = { Int16::MinValue, Int16::MaxValue, 0xFFF, 12345, -10000 }; // Convert each value to a Decimal. for each (Int16 value in values) { Decimal decValue = value; Console::WriteLine("{0} ({1}) --> {2} ({3})", value, value.GetType()->Name, decValue, decValue.GetType()->Name); } } // The example displays the following output: // -32768 (Int16) --> -32768 (Decimal) // 32767 (Int16) --> 32767 (Decimal) // 4095 (Int16) --> 4095 (Decimal) // 12345 (Int16) --> 12345 (Decimal) // -10000 (Int16) --> -10000 (Decimal) //</Snippet3>
33
64
0.526515
BohdanMosiyuk
6d18e091c4fb941c97454f0a7a5347699a590586
3,434
cpp
C++
Source/PanelConfiguration.cpp
solidajenjo/Engine
409516f15e0f083e79b749b9c9184f2f04184325
[ "MIT" ]
10
2019-02-25T11:36:23.000Z
2021-11-03T22:51:30.000Z
Source/PanelConfiguration.cpp
solidajenjo/Engine
409516f15e0f083e79b749b9c9184f2f04184325
[ "MIT" ]
146
2019-02-05T13:57:33.000Z
2019-11-07T16:21:31.000Z
Source/PanelConfiguration.cpp
FractalPuppy/Engine
409516f15e0f083e79b749b9c9184f2f04184325
[ "MIT" ]
3
2019-11-17T20:49:12.000Z
2020-04-19T17:28:28.000Z
#include "PanelConfiguration.h" #include "Application.h" #include "ModuleWindow.h" #include "ModuleRender.h" #include "ModuleCamera.h" #include "ModuleInput.h" #include "ModuleTextures.h" #include "ModuleScene.h" #include "ModuleScript.h" #include "ModuleUI.h" #include "ModuleAudioManager.h" #include "imgui.h" #include "Math/MathConstants.h" #define NUMFPS 100 PanelConfiguration::PanelConfiguration() { fps.reserve(NUMFPS); ms.reserve(NUMFPS); } PanelConfiguration::~PanelConfiguration() { } void PanelConfiguration::Draw() { if (!ImGui::Begin("Configuration", &enabled)) { ImGui::End(); return; } if (ImGui::CollapsingHeader("Application")) { UpdateExtrems(); DrawFPSgraph(); DrawMSgraph(); DrawMemoryStats(); } if (ImGui::CollapsingHeader("Window")) { App->window->DrawGUI(); } if (ImGui::CollapsingHeader("Camera")) { App->camera->DrawGUI(); } if (ImGui::CollapsingHeader("Render")) { App->renderer->DrawGUI(); } if (ImGui::CollapsingHeader("Input")) { App->input->DrawGUI(); } if (ImGui::CollapsingHeader("Textures")) { App->textures->DrawGUI(); } if (ImGui::CollapsingHeader("Scene")) { App->scene->DrawGUI(); } if (ImGui::CollapsingHeader("UI")) { App->ui->DrawGUI(); } if (ImGui::CollapsingHeader("Audio")) { App->audioManager->DrawGUI(); } if (ImGui::CollapsingHeader("Scripts")) { App->scripting->DrawGUI(); } if (ImGui::CollapsingHeader("Skybox")) { App->renderer->DrawSkyboxGUI(); } ImGui::End(); } void PanelConfiguration::DrawFPSgraph() const { if (fps.size() == 0) return; char avg[32]; char showmin[32]; sprintf_s(avg, "%s%.2f", "avg:", totalfps / fps.size()); sprintf_s(showmin, "%s%.2f", "min:", minfps); ImGui::PlotHistogram("FPS", &fps[0], fps.size(), 0, avg, 0.0f, 300.0f, ImVec2(0, 80)); ImGui::Text(showmin); } void PanelConfiguration::DrawMSgraph() const { if (ms.size() == 0) return; char avg[32]; char showmax[32]; sprintf_s(avg, "%s%.2f", "avg:", totalms / ms.size()); sprintf_s(showmax, "%s%.2f", "max:", maxms); ImGui::PlotHistogram("MS", &ms[0], ms.size(), 0, avg, 0.0f, 20.0f, ImVec2(0, 80)); ImGui::Text(showmax); } void PanelConfiguration::AddFps(float dt) { if (dt == 0.0f) return; if (fps.size() == NUMFPS) { totalfps -= fps.back(); fps.pop_back(); totalms -= ms.back(); ms.pop_back(); } float newfps = 1 / dt; float newms = dt * 1000; fps.insert(fps.begin(), newfps); ms.insert(ms.begin(), newms); totalfps += newfps; totalms += newms; } void PanelConfiguration::UpdateExtrems() { minfps = 1000.f; maxms = 0.f; for (unsigned i = 0; i < fps.size(); i++) { minfps = MIN(minfps, fps[i]); maxms = MAX(maxms, ms[i]); } } void PanelConfiguration::DrawMemoryStats() const { //sMStats stats = m_getMemoryStatistics(); //ImGui::Text("Total Reported Mem: %u", stats.totalReportedMemory); //ImGui::Text("Total Actual Mem: %u", stats.totalActualMemory); //ImGui::Text("Peak Reported Mem: %u", stats.peakReportedMemory); //ImGui::Text("Peak Actual Mem: %u", stats.peakActualMemory); //ImGui::Text("Accumulated Reported Mem: %u", stats.accumulatedReportedMemory); //ImGui::Text("Accumulated Actual Mem: %u", stats.accumulatedActualMemory); //ImGui::Text("Accumulated Alloc Unit Count: %u", stats.accumulatedAllocUnitCount); //ImGui::Text("Total Alloc Unit Count: %u", stats.totalAllocUnitCount); //ImGui::Text("Peak Alloc Unit Count: %u", stats.peakAllocUnitCount); }
21.872611
88
0.665987
solidajenjo
6d1b9b18b88dc475a7eabcaebe64ba38556ca48c
5,324
cpp
C++
thorlcr/activities/spill/thspill.cpp
davidarcher/HPCC-Platform
fa817ab9ea7d8154ac08bc780ce9ce673f3e51e3
[ "Apache-2.0" ]
286
2015-01-03T12:45:17.000Z
2022-03-25T18:12:57.000Z
thorlcr/activities/spill/thspill.cpp
davidarcher/HPCC-Platform
fa817ab9ea7d8154ac08bc780ce9ce673f3e51e3
[ "Apache-2.0" ]
9,034
2015-01-02T08:49:19.000Z
2022-03-31T20:34:44.000Z
thorlcr/activities/spill/thspill.cpp
cloLN/HPCC-Platform
42ffb763a1cdcf611d3900831973d0a68e722bbe
[ "Apache-2.0" ]
208
2015-01-02T03:27:28.000Z
2022-02-11T05:54:52.000Z
/*############################################################################## HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ############################################################################## */ #include "jiface.hpp" #include "dadfs.hpp" #include "eclhelper.hpp" #include "thspill.ipp" class SpillActivityMaster : public CMasterActivity { Owned<IFileDescriptor> fileDesc; StringArray clusters; __int64 recordsProcessed; Owned<IDistributedFile> file; StringAttr fileName; public: SpillActivityMaster(CMasterGraphElement *info) : CMasterActivity(info) { recordsProcessed = 0; } virtual void init() { CMasterActivity::init(); IHThorSpillArg *helper = (IHThorSpillArg *)queryHelper(); IArrayOf<IGroup> groups; OwnedRoxieString helperFileName = helper->getFileName(); StringBuffer expandedFileName; queryThorFileManager().addScope(container.queryJob(), helperFileName, expandedFileName, true); fileName.set(expandedFileName); fillClusterArray(container.queryJob(), fileName, clusters, groups); fileDesc.setown(queryThorFileManager().create(container.queryJob(), fileName, clusters, groups, true, TDWnoreplicate+TDXtemporary)); IPropertyTree &props = fileDesc->queryProperties(); bool blockCompressed=false; void *ekey; size32_t ekeylen; helper->getEncryptKey(ekeylen,ekey); if (ekeylen) { memset(ekey,0,ekeylen); free(ekey); props.setPropBool("@encrypted", true); blockCompressed = true; } else if (0 != (helper->getFlags() & TDWnewcompress) || 0 != (helper->getFlags() & TDXcompress)) blockCompressed = true; if (blockCompressed) props.setPropBool("@blockCompressed", true); if (0 != (helper->getFlags() & TDXgrouped)) fileDesc->queryProperties().setPropBool("@grouped", true); props.setProp("@kind", "flat"); if (container.queryOwner().queryOwner() && (!container.queryOwner().isGlobal())) // I am in a child query { // do early, because this will be local act. and will not come back to master until end of owning graph. container.queryTempHandler()->registerFile(fileName, container.queryOwner().queryGraphId(), helper->getTempUsageCount(), TDXtemporary & helper->getFlags(), getDiskOutputKind(helper->getFlags()), &clusters); queryThorFileManager().publish(container.queryJob(), fileName, *fileDesc); } } virtual void serializeSlaveData(MemoryBuffer &dst, unsigned slave) { IHThorSpillArg *helper = (IHThorSpillArg *)queryHelper(); IPartDescriptor *partDesc = fileDesc->queryPart(slave); partDesc->serialize(dst); dst.append(helper->getTempUsageCount()); } virtual void done() { CMasterActivity::done(); if (!container.queryOwner().queryOwner() || container.queryOwner().isGlobal()) // I am in a child query { IHThorSpillArg *helper = (IHThorSpillArg *)queryHelper(); container.queryTempHandler()->registerFile(fileName, container.queryOwner().queryGraphId(), helper->getTempUsageCount(), TDXtemporary & helper->getFlags(), getDiskOutputKind(helper->getFlags()), &clusters); IPropertyTree &props = fileDesc->queryProperties(); props.setPropInt64("@recordCount", recordsProcessed); queryThorFileManager().publish(container.queryJob(), fileName, *fileDesc); } } virtual void slaveDone(size32_t slaveIdx, MemoryBuffer &mb) { if (mb.length()) // if 0 implies aborted out from this slave. { rowcount_t slaveProcessed; mb.read(slaveProcessed); recordsProcessed += slaveProcessed; offset_t size, physicalSize; mb.read(size); mb.read(physicalSize); unsigned fileCrc; mb.read(fileCrc); CDateTime modifiedTime(mb); StringBuffer timeStr; modifiedTime.getString(timeStr); IPartDescriptor *partDesc = fileDesc->queryPart(slaveIdx); IPropertyTree &props = partDesc->queryProperties(); props.setPropInt64("@size", size); props.setPropInt64("@recordCount", slaveProcessed); if (fileDesc->isCompressed()) props.setPropInt64("@compressedSize", physicalSize); props.setPropInt("@fileCrc", fileCrc); props.setProp("@modified", timeStr.str()); } } }; CActivityBase *createSpillActivityMaster(CMasterGraphElement *info) { return new SpillActivityMaster(info); }
41.92126
218
0.632231
davidarcher
6d1bcbf3b374bc4f703da7b15ae733094579c15f
1,102
cpp
C++
2_variables_and_assignments/Code_Examples/prob4.cpp
AhsanAyub/tntech_csc_1300_fall_2021
a96794e9800adccb71abaf83ecf5409ad4c25b3e
[ "MIT" ]
2
2022-02-02T05:25:46.000Z
2022-02-17T17:42:08.000Z
2_variables_and_assignments/Code_Examples/prob4.cpp
AhsanAyub/tntech_csc_1300_fall_2021
a96794e9800adccb71abaf83ecf5409ad4c25b3e
[ "MIT" ]
null
null
null
2_variables_and_assignments/Code_Examples/prob4.cpp
AhsanAyub/tntech_csc_1300_fall_2021
a96794e9800adccb71abaf83ecf5409ad4c25b3e
[ "MIT" ]
null
null
null
/* * Problem: If a three-digit number is input through the keyboard, write a program to * calculate the sum of its digits. (Hint: Use the modulus operator %) * * Example * Case (1) * i/p: 369 * o/p: 18 * * Case (2) * i/p: 999 * o/p: 27 */ #include <iostream> using namespace std; int main() { // Declare all the variables int threeDigitNumber; int singleDigit, sum = 0; // Take the inputs from the user cin >> threeDigitNumber; // Extract the last most digit singleDigit = threeDigitNumber % 10; sum += singleDigit; // Add it to the sum // Remove the last most digit // Three digit number -> two digit number threeDigitNumber /= 10; // This is extracting the 2nd digit from the two digit number singleDigit = threeDigitNumber % 10; sum += singleDigit; // Add it to the sum // Remove the last most digit // Two digit number -> one digit number threeDigitNumber /= 10; sum += threeDigitNumber; // Add it to the sum // Print the values of the variables on display cout << sum << endl; return 0; }
22.958333
85
0.636116
AhsanAyub
6d1bd2021b11058a7de9ef707e03732e661c7995
526
cpp
C++
2217.cpp
Wookhwang/BaekJun
1dfc9783a70318b5c4a6fe796878f767b30af3ed
[ "Apache-2.0" ]
1
2019-12-30T17:18:28.000Z
2019-12-30T17:18:28.000Z
2217.cpp
Wookhwang/BaekJun
1dfc9783a70318b5c4a6fe796878f767b30af3ed
[ "Apache-2.0" ]
null
null
null
2217.cpp
Wookhwang/BaekJun
1dfc9783a70318b5c4a6fe796878f767b30af3ed
[ "Apache-2.0" ]
null
null
null
#pragma warning(disable:4996) #include <stdio.h> #include <iostream> #include <algorithm> using namespace std; int main() { int rope; int weight[100000]; int result[100000]; int n = 1; int max; scanf("%d", &rope); for (int i = 0; i < rope; i++) { scanf("%d", &weight[i]); } sort(weight, weight + rope); for (int j = rope - 1; j >= 0; j--) { result[j] = weight[j] * n; n++; } sort(result, result + rope); max = result[rope - 1]; printf("%d", max); return 0; }
14.611111
39
0.530418
Wookhwang
6d2744f9812ace62e509437428882c04822e5d02
13,666
cpp
C++
control/json/zone.cpp
mikecgithub/phosphor-fan-presence
a66d154ed073fda465616a40670c98979c47ee91
[ "Apache-2.0" ]
null
null
null
control/json/zone.cpp
mikecgithub/phosphor-fan-presence
a66d154ed073fda465616a40670c98979c47ee91
[ "Apache-2.0" ]
null
null
null
control/json/zone.cpp
mikecgithub/phosphor-fan-presence
a66d154ed073fda465616a40670c98979c47ee91
[ "Apache-2.0" ]
null
null
null
/** * Copyright © 2020 IBM Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "zone.hpp" #include "dbus_zone.hpp" #include "fan.hpp" #include "sdbusplus.hpp" #include <nlohmann/json.hpp> #include <phosphor-logging/log.hpp> #include <sdeventplus/event.hpp> #include <algorithm> #include <chrono> #include <iterator> #include <map> #include <memory> #include <numeric> #include <utility> #include <vector> namespace phosphor::fan::control::json { using json = nlohmann::json; using namespace phosphor::logging; const std::map< std::string, std::map<std::string, std::function<std::function<void(DBusZone&, Zone&)>( const json&, bool)>>> Zone::_intfPropHandlers = { {DBusZone::thermalModeIntf, {{DBusZone::supportedProp, zone::property::supported}, {DBusZone::currentProp, zone::property::current}}}}; Zone::Zone(const json& jsonObj, const sdeventplus::Event& event, Manager* mgr) : ConfigBase(jsonObj), _dbusZone{}, _manager(mgr), _defaultFloor(0), _incDelay(0), _decInterval(0), _floor(0), _target(0), _incDelta(0), _decDelta(0), _requestTargetBase(0), _isActive(true), _incTimer(event, std::bind(&Zone::incTimerExpired, this)), _decTimer(event, std::bind(&Zone::decTimerExpired, this)) { // Increase delay is optional, defaults to 0 if (jsonObj.contains("increase_delay")) { _incDelay = std::chrono::seconds(jsonObj["increase_delay"].get<uint64_t>()); } // Poweron target is required setPowerOnTarget(jsonObj); // Default ceiling is optional, defaults to poweron target _defaultCeiling = _poweronTarget; if (jsonObj.contains("default_ceiling")) { _defaultCeiling = jsonObj["default_ceiling"].get<uint64_t>(); } // Start with the current ceiling set as the default ceiling _ceiling = _defaultCeiling; // Default floor is optional, defaults to 0 if (jsonObj.contains("default_floor")) { _defaultFloor = jsonObj["default_floor"].get<uint64_t>(); // Start with the current floor set as the default _floor = _defaultFloor; } // Decrease interval is optional, defaults to 0 // A decrease interval of 0sec disables the decrease timer if (jsonObj.contains("decrease_interval")) { _decInterval = std::chrono::seconds(jsonObj["decrease_interval"].get<uint64_t>()); } // Setting properties on interfaces to be served are optional if (jsonObj.contains("interfaces")) { setInterfaces(jsonObj); } } void Zone::enable() { // Create thermal control dbus object _dbusZone = std::make_unique<DBusZone>(*this); // Init all configured dbus interfaces' property states for (const auto& func : _propInitFunctions) { // Only call non-null init property functions if (func) { func(*_dbusZone, *this); } } // TODO - Restore any persisted properties in init function // Restore thermal control current mode state, if exists _dbusZone->restoreCurrentMode(); // Emit object added for this zone's associated dbus object _dbusZone->emit_object_added(); // A decrease interval of 0sec disables the decrease timer if (_decInterval != std::chrono::seconds::zero()) { // Start timer for fan target decreases _decTimer.restart(_decInterval); } } void Zone::addFan(std::unique_ptr<Fan> fan) { _fans.emplace_back(std::move(fan)); } void Zone::setTarget(uint64_t target) { if (_isActive) { _target = target; for (auto& fan : _fans) { fan->setTarget(_target); } } } void Zone::setActiveAllow(const std::string& ident, bool isActiveAllow) { _active[ident] = isActiveAllow; if (!isActiveAllow) { _isActive = false; } else { // Check all entries are set to allow active fan control auto actPred = [](const auto& entry) { return entry.second; }; _isActive = std::all_of(_active.begin(), _active.end(), actPred); } } void Zone::setFloor(uint64_t target) { // Check all entries are set to allow floor to be set auto pred = [](const auto& entry) { return entry.second; }; if (std::all_of(_floorChange.begin(), _floorChange.end(), pred)) { _floor = target; // Floor above target, update target to floor if (_target < _floor) { requestIncrease(_floor - _target); } } } void Zone::requestIncrease(uint64_t targetDelta) { // Only increase when delta is higher than the current increase delta for // the zone and currently under ceiling if (targetDelta > _incDelta && _target < _ceiling) { auto requestTarget = getRequestTargetBase(); requestTarget = (targetDelta - _incDelta) + requestTarget; _incDelta = targetDelta; // Target can not go above a current ceiling if (requestTarget > _ceiling) { requestTarget = _ceiling; } setTarget(requestTarget); // Restart timer countdown for fan target increase _incTimer.restartOnce(_incDelay); } } void Zone::incTimerExpired() { // Clear increase delta when timer expires allowing additional target // increase requests or target decreases to occur _incDelta = 0; } void Zone::requestDecrease(uint64_t targetDelta) { // Only decrease the lowest target delta requested if (_decDelta == 0 || targetDelta < _decDelta) { _decDelta = targetDelta; } } void Zone::decTimerExpired() { // Check all entries are set to allow a decrease auto pred = [](auto const& entry) { return entry.second; }; auto decAllowed = std::all_of(_decAllowed.begin(), _decAllowed.end(), pred); // Only decrease targets when allowed, a requested decrease target delta // exists, where no requested increases exist and the increase timer is not // running (i.e. not in the middle of increasing) if (decAllowed && _decDelta != 0 && _incDelta == 0 && !_incTimer.isEnabled()) { auto requestTarget = getRequestTargetBase(); // Request target should not start above ceiling if (requestTarget > _ceiling) { requestTarget = _ceiling; } // Target can not go below the defined floor if ((requestTarget < _decDelta) || (requestTarget - _decDelta < _floor)) { requestTarget = _floor; } else { requestTarget = requestTarget - _decDelta; } setTarget(requestTarget); } // Clear decrease delta when timer expires _decDelta = 0; // Decrease timer is restarted since its repeating } void Zone::setPersisted(const std::string& intf, const std::string& prop) { if (std::find_if(_propsPersisted[intf].begin(), _propsPersisted[intf].end(), [&prop](const auto& p) { return prop == p; }) == _propsPersisted[intf].end()) { _propsPersisted[intf].emplace_back(prop); } } bool Zone::isPersisted(const std::string& intf, const std::string& prop) const { auto it = _propsPersisted.find(intf); if (it == _propsPersisted.end()) { return false; } return std::any_of(it->second.begin(), it->second.end(), [&prop](const auto& p) { return prop == p; }); } void Zone::setPowerOnTarget(const json& jsonObj) { if (!jsonObj.contains("poweron_target")) { auto msg = "Missing required zone's poweron target"; log<level::ERR>(msg, entry("JSON=%s", jsonObj.dump().c_str())); throw std::runtime_error(msg); } _poweronTarget = jsonObj["poweron_target"].get<uint64_t>(); } void Zone::setInterfaces(const json& jsonObj) { for (const auto& interface : jsonObj["interfaces"]) { if (!interface.contains("name") || !interface.contains("properties")) { log<level::ERR>("Missing required zone interface attributes", entry("JSON=%s", interface.dump().c_str())); throw std::runtime_error( "Missing required zone interface attributes"); } auto propFuncs = _intfPropHandlers.find(interface["name"].get<std::string>()); if (propFuncs == _intfPropHandlers.end()) { // Construct list of available configurable interfaces auto intfs = std::accumulate( std::next(_intfPropHandlers.begin()), _intfPropHandlers.end(), _intfPropHandlers.begin()->first, [](auto list, auto intf) { return std::move(list) + ", " + intf.first; }); log<level::ERR>("Configured interface not available", entry("JSON=%s", interface.dump().c_str()), entry("AVAILABLE_INTFS=%s", intfs.c_str())); throw std::runtime_error("Configured interface not available"); } for (const auto& property : interface["properties"]) { if (!property.contains("name")) { log<level::ERR>( "Missing required interface property attributes", entry("JSON=%s", property.dump().c_str())); throw std::runtime_error( "Missing required interface property attributes"); } // Attribute "persist" is optional, defaults to `false` auto persist = false; if (property.contains("persist")) { persist = property["persist"].get<bool>(); } // Property name from JSON must exactly match supported // index names to functions in property namespace auto propFunc = propFuncs->second.find(property["name"].get<std::string>()); if (propFunc == propFuncs->second.end()) { // Construct list of available configurable properties auto props = std::accumulate( std::next(propFuncs->second.begin()), propFuncs->second.end(), propFuncs->second.begin()->first, [](auto list, auto prop) { return std::move(list) + ", " + prop.first; }); log<level::ERR>("Configured property not available", entry("JSON=%s", property.dump().c_str()), entry("AVAILABLE_PROPS=%s", props.c_str())); throw std::runtime_error( "Configured property function not available"); } _propInitFunctions.emplace_back( propFunc->second(property, persist)); } } } /** * Properties of interfaces supported by the zone configuration that return * a handler function that sets the zone's property value(s) and persist * state. */ namespace zone::property { // Get a set property handler function for the configured values of the // "Supported" property std::function<void(DBusZone&, Zone&)> supported(const json& jsonObj, bool persist) { std::vector<std::string> values; if (!jsonObj.contains("values")) { log<level::ERR>("No 'values' found for \"Supported\" property, " "using an empty list", entry("JSON=%s", jsonObj.dump().c_str())); } else { for (const auto& value : jsonObj["values"]) { if (!value.contains("value")) { log<level::ERR>("No 'value' found for \"Supported\" property " "entry, skipping", entry("JSON=%s", value.dump().c_str())); } else { values.emplace_back(value["value"].get<std::string>()); } } } return Zone::setProperty<std::vector<std::string>>( DBusZone::thermalModeIntf, DBusZone::supportedProp, &DBusZone::supported, std::move(values), persist); } // Get a set property handler function for a configured value of the // "Current" property std::function<void(DBusZone&, Zone&)> current(const json& jsonObj, bool persist) { // Use default value for "Current" property if no "value" entry given if (!jsonObj.contains("value")) { log<level::INFO>("No 'value' found for \"Current\" property, " "using default", entry("JSON=%s", jsonObj.dump().c_str())); // Set persist state of property return Zone::setPropertyPersist(DBusZone::thermalModeIntf, DBusZone::currentProp, persist); } return Zone::setProperty<std::string>( DBusZone::thermalModeIntf, DBusZone::currentProp, &DBusZone::current, jsonObj["value"].get<std::string>(), persist); } } // namespace zone::property } // namespace phosphor::fan::control::json
33.169903
80
0.598858
mikecgithub
6d2cc79543385595cbebaf8031159372cf202ee5
467
hpp
C++
mpllibs/metamonad/typeclass.hpp
sabel83/mpllibs
8e245aedcf658fe77bb29537aeba1d4e1a619a19
[ "BSL-1.0" ]
70
2015-01-15T09:05:15.000Z
2021-12-08T15:49:31.000Z
mpllibs/metamonad/typeclass.hpp
sabel83/mpllibs
8e245aedcf658fe77bb29537aeba1d4e1a619a19
[ "BSL-1.0" ]
4
2015-06-18T19:25:34.000Z
2016-05-13T19:49:51.000Z
mpllibs/metamonad/typeclass.hpp
sabel83/mpllibs
8e245aedcf658fe77bb29537aeba1d4e1a619a19
[ "BSL-1.0" ]
5
2015-07-10T08:18:09.000Z
2021-12-01T07:17:57.000Z
#ifndef MPLLIBS_METAMONAD_TYPECLASS_HPP #define MPLLIBS_METAMONAD_TYPECLASS_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include <mpllibs/metamonad/v1/typeclass.hpp> #include <mpllibs/metamonad/typeclass_expect.hpp> #include <mpllibs/metamonad/typeclass_expectations.hpp> #endif
29.1875
61
0.781585
sabel83
6d2ef8e3a85bef153a19b4963c6ffd5b449bfcc2
20,317
cpp
C++
astronomy/time_scales_test.cpp
erplsf/Principia
1f2a1fc53f8a73c1bc67f12213169e6969c8488f
[ "MIT" ]
null
null
null
astronomy/time_scales_test.cpp
erplsf/Principia
1f2a1fc53f8a73c1bc67f12213169e6969c8488f
[ "MIT" ]
null
null
null
astronomy/time_scales_test.cpp
erplsf/Principia
1f2a1fc53f8a73c1bc67f12213169e6969c8488f
[ "MIT" ]
null
null
null
 #include "astronomy/time_scales.hpp" #include "gmock/gmock.h" #include "gtest/gtest.h" #include "quantities/astronomy.hpp" #include "testing_utilities/almost_equals.hpp" #include "testing_utilities/approximate_quantity.hpp" #include "testing_utilities/is_near.hpp" #include "testing_utilities/numerics.hpp" namespace principia { namespace astronomy { namespace internal_time_scales { using quantities::astronomy::JulianYear; using quantities::si::Day; using quantities::si::Degree; using quantities::si::Hour; using quantities::si::Micro; using quantities::si::Milli; using quantities::si::Minute; using quantities::si::Nano; using testing_utilities::AbsoluteError; using testing_utilities::AlmostEquals; using testing_utilities::IsNear; using testing_utilities::operator""_⑴; using ::testing::AllOf; using ::testing::Eq; using ::testing::Gt; using ::testing::Lt; constexpr Instant j2000_week = "1999-W52-6T12:00:00"_TT; constexpr Instant j2000_from_tt = "2000-01-01T12:00:00"_TT; constexpr Instant j2000_from_tai = "2000-01-01T11:59:27,816"_TAI; constexpr Instant j2000_from_utc = "2000-01-01T11:58:55,816"_UTC; constexpr Instant j2000_tai = "2000-01-01T12:00:00"_TAI; constexpr Instant j2000_tai_from_tt = "2000-01-01T12:00:32,184"_TT; class TimeScalesTest : public testing::Test { protected: static constexpr bool OneMicrosecondApart(Instant const& t1, Instant const& t2) { return t1 - t2 <= 1 * Micro(Second) && t1 - t2 >= - 1 * Micro(Second); } }; using TimeScalesDeathTest = TimeScalesTest; // The checks are giant boolean expressions which are entirely repeated in the // error message; we try to match the relevant part. TEST_F(TimeScalesDeathTest, LeaplessScales) { EXPECT_DEATH("2015-06-30T23:59:60"_TT, "!tt.time...is_leap_second.."); EXPECT_DEATH("2015-06-30T23:59:60"_TAI, "!tai.time...is_leap_second.."); EXPECT_DEATH("2015-06-30T23:59:60"_UT1, "!ut1.time...is_leap_second.."); } TEST_F(TimeScalesDeathTest, BeforeRange) { EXPECT_DEATH("1960-12-31T23:59:59,999"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1830-04-10T23:59:59,999"_UT1, "mjd.TimeSince20000101T120000Z.ut1.. >= " "experimental_eop_c02.front...ut1_mjd"); } TEST_F(TimeScalesDeathTest, WarWasBeginning) { EXPECT_DEATH("2101-01-01T00:00:00"_UTC, "leap_seconds.size"); EXPECT_DEATH("2101-01-01T00:00:00"_UT1, "TimeSince20000101T120000Z.ut1. < eop_c04.back...ut1.."); } TEST_F(TimeScalesDeathTest, FirstUnknownUTC) { EXPECT_DEATH("2021-12-31T23:59:60"_UTC, "leap_seconds.size"); EXPECT_DEATH("2021-12-31T24:00:00"_UTC, "leap_seconds.size"); EXPECT_DEATH("2022-01-01T00:00:00"_UTC, "leap_seconds.size"); } TEST_F(TimeScalesDeathTest, StretchyLeaps) { EXPECT_DEATH("1961-07-31T23:59:59,950"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1963-10-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-03-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-08-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1964-12-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-02-28T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-06-30T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1965-08-31T23:59:60,100"_UTC, "IsValidStretchyUTC"); EXPECT_DEATH("1968-01-31T23:59:59,900"_UTC, "IsValidStretchyUTC"); } TEST_F(TimeScalesDeathTest, ModernLeaps) { EXPECT_DEATH("2015-12-31T23:59:60"_UTC, "IsValidModernUTC"); } TEST_F(TimeScalesTest, ConstexprJ2000) { static_assert(j2000_week == J2000); static_assert(j2000_from_tt == J2000); static_assert(j2000_from_tai == J2000); static_assert(j2000_from_utc == J2000); static_assert(j2000_tai == j2000_tai_from_tt); static_assert(j2000_tai - J2000 == 32.184 * Second); } TEST_F(TimeScalesTest, ConstexprWeeks) { // Check that week dates that go to the previous year work. static_assert("1914-W01-1T00:00:00"_TT == "19131229T000000"_TT); } TEST_F(TimeScalesTest, ConstexprMJD2000) { constexpr Instant mjd51544_utc = "2000-01-01T00:00:00"_UTC; constexpr Instant mjd51544_utc_from_ut1 = "2000-01-01T00:00:00,355"_UT1 + 388.0 * Micro(Second); static_assert(mjd51544_utc - mjd51544_utc_from_ut1 < 1 * Nano(Second)); static_assert(mjd51544_utc - mjd51544_utc_from_ut1 > -1 * Nano(Second)); } TEST_F(TimeScalesTest, ReferenceDates) { EXPECT_THAT("1858-11-17T00:00:00"_TT, Eq("MJD0"_TT)); EXPECT_THAT(j2000_week, Eq(J2000)); EXPECT_THAT(j2000_from_tt, Eq(J2000)); EXPECT_THAT(j2000_from_tai, Eq(J2000)); EXPECT_THAT(j2000_from_utc, Eq(J2000)); EXPECT_THAT(j2000_tai, Eq(j2000_tai_from_tt)); EXPECT_THAT(j2000_tai - J2000, Eq(32.184 * Second)); // Besselian epochs. constexpr Instant B1900 = "1899-12-31T00:00:00"_TT + 0.8135 * Day; Instant const JD2415020_3135 = "JD2415020.3135"_TT; EXPECT_THAT(B1900, AlmostEquals(JD2415020_3135, 1)); EXPECT_THAT(testing_utilities::AbsoluteError(JD2415020_3135, B1900), IsNear(0.5_⑴ * Micro(Second))); constexpr Instant B1950 = "1949-12-31T00:00:00"_TT + 0.9235 * Day; Instant const JD2433282_4235 = "JD2433282.4235"_TT; EXPECT_THAT(B1950, AlmostEquals(JD2433282_4235, 0)); } TEST_F(TimeScalesTest, LeapSecond) { Instant const eleven_fifty_nine_and_fifty_eight_seconds = "2015-06-30T23:59:58"_UTC; EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 1 * Second, Eq("2015-06-30T23:59:59"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 1.5 * Second, Eq("2015-06-30T23:59:59,5"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 2 * Second, Eq("2015-06-30T23:59:60"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 2.5 * Second, Eq("2015-06-30T23:59:60,5"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 3 * Second, Eq("2015-06-30T24:00:00"_UTC)); EXPECT_THAT(eleven_fifty_nine_and_fifty_eight_seconds + 3 * Second, Eq("2015-07-01T00:00:00"_UTC)); constexpr Instant end_of_december_2016 = "2016-12-31T24:00:00"_UTC; EXPECT_THAT(end_of_december_2016 - 2 * Second, Eq("2016-12-31T23:59:59"_UTC)); EXPECT_THAT(end_of_december_2016 - 1 * Second, Eq("2016-12-31T23:59:60"_UTC)); EXPECT_THAT(end_of_december_2016 - 0 * Second, Eq("2017-01-01T00:00:00"_UTC)); EXPECT_THAT("2016-12-31T23:59:59"_UTC - "2016-12-31T23:59:59"_TAI, Eq(36 * Second)); EXPECT_THAT("2017-01-01T00:00:00"_UTC - "2017-01-01T00:00:00"_TAI, Eq(37 * Second)); } // See the list of steps at // https://hpiers.obspm.fr/iers/bul/bulc/TimeSteps.history. // Note that while the same file is used to check that the date string is valid // with respect to positive or negative leap seconds, the actual conversion is // based exclusively on https://hpiers.obspm.fr/iers/bul/bulc/UTC-TAI.history, // so this provides some sort of cross-checking. TEST_F(TimeScalesTest, StretchyLeaps) { EXPECT_THAT(AbsoluteError("1961-07-31T24:00:00,000"_UTC - 0.050 * Second, "1961-07-31T23:59:59,900"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1961-08-01T00:00:00"_UTC, "1961-08-01T00:00:01,648"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1963-10-31T24:00:00,000"_UTC - 0.100 * Second, "1963-10-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1963-11-01T00:00:00"_UTC, "1963-11-01T00:00:02,697"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T24:00:00,000"_UTC - 0.100 * Second, "1964-03-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1964-04-01T00:00:00"_UTC, "1964-04-01T00:00:02,984"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-08-31T24:00:00,000"_UTC - 0.100 * Second, "1964-08-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1964-09-01T00:00:00"_UTC, "1964-09-01T00:00:03,282"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-12-31T24:00:00,000"_UTC - 0.100 * Second, "1964-12-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-01-01T00:00:00"_UTC, "1965-01-01T00:00:03,540"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-02-28T24:00:00,000"_UTC - 0.100 * Second, "1965-02-28T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-03-01T00:00:00"_UTC, "1965-03-01T00:00:03,717"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-06-30T24:00:00,000"_UTC - 0.100 * Second, "1965-06-30T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-07-01T00:00:00"_UTC, "1965-07-01T00:00:03,975"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1965-08-31T24:00:00,000"_UTC - 0.100 * Second, "1965-08-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1965-09-01T00:00:00"_UTC, "1965-09-01T00:00:04,155"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1968-01-31T24:00:00,000"_UTC - 0.100 * Second, "1968-01-31T23:59:59,800"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1968-02-01T00:00:00"_UTC, "1968-02-01T00:00:06,186"_TAI), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1971-12-31T24:00:00,000"_UTC - 0.107'7580 * Second, "1971-12-31T23:59:60,000"_UTC), Lt(1 * Micro(Second))); EXPECT_THAT( AbsoluteError("1972-01-01T00:00:00"_UTC, "1972-01-01T00:00:10,000"_TAI), Lt(0.5 * Milli(Second))); } TEST_F(TimeScalesTest, StretchyRates) { // Check that cancellations aren't destroying the test. EXPECT_NE("1961-01-01T00:00:00"_UTC + 1 * Minute / (1 - 150e-10), "1961-01-01T00:00:00"_UTC + 1 * Minute / (1 - 130e-10)); quantities::Time utc_minute; utc_minute = 1 * Minute / (1 - 150e-10); EXPECT_THAT("1961-01-01T00:00:00"_UTC + utc_minute, Eq("1961-01-01T00:01:00"_UTC)); EXPECT_THAT("1961-12-31T23:59:00"_UTC + utc_minute, Eq("1961-12-31T24:00:00"_UTC)); utc_minute = 1 * Minute / (1 - 130e-10); EXPECT_THAT("1962-01-01T00:00:00"_UTC + utc_minute, Eq("1962-01-01T00:01:00"_UTC)); EXPECT_THAT("1963-12-31T23:59:00"_UTC + utc_minute, Eq("1963-12-31T24:00:00"_UTC)); utc_minute = 1 * Minute / (1 - 150e-10); EXPECT_THAT("1964-01-01T00:00:00"_UTC + utc_minute, Eq("1964-01-01T00:01:00"_UTC)); EXPECT_THAT("1965-12-31T23:59:00"_UTC + utc_minute, AlmostEquals("1965-12-31T24:00:00"_UTC, 1)); utc_minute = 1 * Minute / (1 - 300e-10); EXPECT_THAT("1966-01-01T00:00:00"_UTC + utc_minute, Eq("1966-01-01T00:01:00"_UTC)); EXPECT_THAT("1971-12-31T23:58:00"_UTC + utc_minute, Eq("1971-12-31T23:59:00"_UTC)); utc_minute = 1 * Minute; EXPECT_THAT("1972-01-01T00:00:00"_UTC + utc_minute, Eq("1972-01-01T00:01:00"_UTC)); EXPECT_THAT("2000-01-01T00:00:00"_UTC + utc_minute, Eq("2000-01-01T00:01:00"_UTC)); } TEST_F(TimeScalesTest, UT1Continuity) { // Continuity with TAI. We have a fairly low resolution for UT1 at that time, // as well as high errors (~20 ms), and TAI was synchronized with UT2 anyway, // so it's not going to get much better than 100 ms. EXPECT_THAT( AbsoluteError("1958-01-01T00:00:00"_UT1, "1958-01-01T00:00:00"_TAI), Lt(100 * Milli(Second))); // Continuity at the beginning of the EOP C02 series. EXPECT_THAT(AbsoluteError("1961-12-31T23:59:59,000"_UT1, "1961-12-31T23:59:58,967"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:00,000"_UT1, "1961-12-31T23:59:59,967"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:00,033"_UT1, "1962-01-01T00:00:00,000"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1962-01-01T00:00:01,033"_UT1, "1962-01-01T00:00:01,000"_UTC), Lt(0.5 * Milli(Second))); // Continuity across a stretchy UTC leap. EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,000"_UT1, "1964-03-31T23:59:59,160"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,900"_UT1, "1964-03-31T23:59:60,060"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-03-31T23:59:59,940"_UT1, "1964-04-01T00:00:00,000"_UTC), Lt(0.5 * Milli(Second))); EXPECT_THAT(AbsoluteError("1964-04-01T00:00:00,000"_UT1, "1964-04-01T00:00:00,060"_UTC), Lt(0.5 * Milli(Second))); } // Check the times of the lunar eclipses in LunarEclipseTest. TEST_F(TimeScalesTest, LunarEclipses) { EXPECT_THAT(AbsoluteError("1950-04-02T20:44:34.0"_TT, "1950-04-02T20:44:04.8"_UT1), Lt(14 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-04-02T20:49:16.7"_TT, "1950-04-02T20:48:47.5"_UT1), Lt(14 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-09-26T04:17:11.4"_TT, "1950-09-26T04:16:42.1"_UT1), Lt(86 * Milli(Second))); EXPECT_THAT(AbsoluteError("1950-09-26T04:21:55.5"_TT, "1950-09-26T04:21:26.1"_UT1), Lt(15 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-03-23T10:37:33.2"_TT, "1951-03-23T10:37:03.7"_UT1), Lt(92 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-03-23T10:50:16.8"_TT, "1951-03-23T10:49:47.3"_UT1), Lt(92 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-09-15T12:27:06.3"_TT, "1951-09-15T12:26:36.6"_UT1), Lt(99 * Milli(Second))); EXPECT_THAT(AbsoluteError("1951-09-15T12:38:51.5"_TT, "1951-09-15T12:38:21.8"_UT1), Lt(99 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-02-11T00:28:39.9"_TT, "1952-02-11T00:28:10.0"_UT1), Lt(69 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-02-11T00:39:47.6"_TT, "1952-02-11T00:39:17.7"_UT1), Lt(69 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-08-05T19:40:29.4"_TT, "1952-08-05T19:39:59.3"_UT1), Lt(57 * Milli(Second))); EXPECT_THAT(AbsoluteError("1952-08-05T19:47:54.8"_TT, "1952-08-05T19:47:24.7"_UT1), Lt(57 * Milli(Second))); EXPECT_THAT(AbsoluteError("2000-01-21T04:41:30.5"_TT, "2000-01-21T04:40:26.7"_UT1), Lt(45 * Milli(Second))); EXPECT_THAT(AbsoluteError("2000-01-21T04:44:34.5"_TT, "2000-01-21T04:43:30.6"_UT1), Lt(56 * Milli(Second))); EXPECT_THAT("2048-01-01T06:53:54.8"_TT - "2048-01-01T06:52:23.6"_TT, AlmostEquals(91.2 * Second, 3e6, 4e6)); EXPECT_THAT("2048-01-01T06:58:19.8"_TT - "2048-01-01T06:56:48.6"_TT, AlmostEquals(91.2 * Second, 3e6, 4e6)); } TEST_F(TimeScalesTest, JulianDate) { static_assert("2010-01-04T00:00:00.108"_TT == "JD2455200.50000125"_TT, "Dates differ"); static_assert("2010-01-04T00:00:00.000"_TT == "JD2455200.50000"_TT, "Dates differ"); static_assert("2010-01-04T12:00:00.000"_TT == "JD2455201.00000"_TT, "Dates differ"); static_assert("2010-01-04T18:00:00.000"_TT == "JD2455201.25000"_TT, "Dates differ"); static_assert(OneMicrosecondApart("2010-01-04T02:57:46.659"_TT, "JD2455200.623456701388"_TT), "Dates differ"); static_assert("2000-01-01T00:00:00"_TT == "JD2451544.5"_TT, "Dates differ"); static_assert("2000-01-01T12:00:00"_TT == "JD2451545"_TT, "Dates differ"); EXPECT_THAT("JD2451545"_TT, Eq(j2000_week)); EXPECT_THAT("JD2455201.00000"_TT, Eq("2010-01-04T12:00:00.000"_TT)); double const jd = 2457662.55467; Instant const date = Instant() + (jd - 2451545.0) * Day; EXPECT_THAT("JD2457662.55467"_TT, AllOf(Lt(date + 1.0 * Second), Gt(date - 1.0 * Second))) << date - "JD2457662.55467"_TT; } TEST_F(TimeScalesTest, ModifiedJulianDate) { static_assert("2010-01-04T00:00:00.123"_TT == "MJD55200.0000014236111"_TT, "Dates differ"); static_assert("2010-01-04T00:00:00.000"_TT == "MJD55200.00000"_TT, "Dates differ"); static_assert("2010-01-04T12:00:00.000"_TT == "MJD55200.50000"_TT, "Dates differ"); static_assert("2010-01-04T18:00:00.000"_TT == "MJD55200.75000"_TT, "Dates differ"); static_assert(OneMicrosecondApart("2010-01-04T02:57:46.659"_TT, "MJD55200.123456701388"_TT), "Dates differ"); EXPECT_THAT("MJD0.0"_TT, Eq("1858-11-17T00:00:00"_TT)); EXPECT_THAT("MJD55200.0000"_TT, Eq("2010-01-04T00:00:00.000"_TT)); EXPECT_THAT("MJD55200.0000014236111"_TT, Eq("2010-01-04T00:00:00.123"_TT)); } TEST_F(TimeScalesDeathTest, JulianDateUTC) { EXPECT_DEATH("JD2451545"_UTC, "size > 0"); EXPECT_DEATH("MJD55200.123"_UTC, "size > 0"); } TEST_F(TimeScalesTest, EarthRotationAngle) { constexpr double revolutions_at_j2000_ut1 = 0.7790572732640; constexpr double excess_revolutions_per_ut1_day = 0.00273781191135448; // Round-trip from UT1, comparing with the direct computation from UT1. static_assert(EarthRotationAngle("JD2451545.0"_UT1) == 2 * π * Radian * revolutions_at_j2000_ut1, "Angles differ"); EXPECT_THAT( EarthRotationAngle("JD2455200.0"_UT1), AlmostEquals(2 * π * Radian * (revolutions_at_j2000_ut1 + excess_revolutions_per_ut1_day * (2455200 - 2451545)), 142)); EXPECT_THAT( EarthRotationAngle("JD2455200.623456701388"_UT1), AlmostEquals( 2 * π * Radian * (0.623456701388 + revolutions_at_j2000_ut1 + excess_revolutions_per_ut1_day * (5200.623456701388 - 1545) - 1), 134)); // Compare with the WGCCRE 2009 elements. EXPECT_THAT( (EarthRotationAngle(J2000) - π / 2 * Radian) - 190.147 * Degree, IsNear(0.0469_⑴ * Degree)); EXPECT_THAT((EarthRotationAngle("2000-01-01T23:00:00"_TT) - EarthRotationAngle("2000-01-01T01:00:00"_TT)) / (22 * Hour) - 360.9856235 * (Degree / Day), IsNear(-0.0000149_⑴ * Degree / Day)); EXPECT_THAT((EarthRotationAngle("2010-01-01T23:00:00"_TT) - EarthRotationAngle("2010-01-01T01:00:00"_TT)) / (22 * Hour) - 360.9856235 * (Degree / Day), IsNear(-0.0000137_⑴ * Degree / Day)); } TEST_F(TimeScalesTest, GNSS) { // BeiDou Navigation Satellite System // Signal In Space Interface Control Document // Open Service Signals B1C and B2a (Test Version), // 3.3 Time System. // The start epoch of BDT is 00:00:00 on January 1, 2006 of Coordinated // Universal Time (UTC). EXPECT_THAT("2006-01-01T00:00:00"_北斗, Eq("2006-01-01T00:00:00"_UTC)); // Galileo OS SIS ICD, Issue 1.1. // 5.1.2. Galileo System Time (GST). // The GST start epoch shall be 00:00 UT on Sunday 22nd August 1999 (midnight // between 21st and 22nd August). At the start epoch, GST shall be ahead of // UTC by thirteen (13) leap seconds. EXPECT_THAT("1999-08-22T00:00:13"_GPS, Eq("1999-08-22T00:00:00"_UTC)); } } // namespace internal_time_scales } // namespace astronomy } // namespace principia
42.064182
80
0.636019
erplsf
6d3004e3019668b1a57067eaf2bef1d7d765c0ec
744
cpp
C++
SandboxGame/main.cpp
bnoazx005/TDEngine2
93ebfecf8af791ff5ecd4f57525a6935e34cd05c
[ "Apache-2.0" ]
1
2019-07-15T01:14:15.000Z
2019-07-15T01:14:15.000Z
SandboxGame/main.cpp
bnoazx005/TDEngine2
93ebfecf8af791ff5ecd4f57525a6935e34cd05c
[ "Apache-2.0" ]
76
2018-10-27T16:59:36.000Z
2022-03-30T17:40:39.000Z
SandboxGame/main.cpp
bnoazx005/TDEngine2
93ebfecf8af791ff5ecd4f57525a6935e34cd05c
[ "Apache-2.0" ]
1
2019-07-29T02:02:08.000Z
2019-07-29T02:02:08.000Z
#include <iostream> #include "include/CCustomEngineListener.h" #include <TDEngine2.h> #include <thread> #if defined (TDE2_USE_WIN32PLATFORM) #pragma comment(lib, "TDEngine2.lib") #endif using namespace TDEngine2; int main(int argc, char** argv) { E_RESULT_CODE result = RC_OK; IEngineCoreBuilder* pEngineCoreBuilder = CreateConfigFileEngineCoreBuilder(CreateEngineCore, "settings.cfg", result); if (result != RC_OK) { return -1; } IEngineCore* pEngineCore = pEngineCoreBuilder->GetEngineCore(); pEngineCoreBuilder->Free(); IEngineListener* pCustomListener = new CCustomEngineListener(); pEngineCore->RegisterListener(pCustomListener); pEngineCore->Run(); pEngineCore->Free(); delete pCustomListener; return 0; }
19.076923
118
0.758065
bnoazx005
6d33be71e3f91dbc22216545750eb71b466bfdda
4,304
hpp
C++
visa/iga/IGALibrary/IR/DUAnalysis.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
visa/iga/IGALibrary/IR/DUAnalysis.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
visa/iga/IGALibrary/IR/DUAnalysis.hpp
bader/intel-graphics-compiler
04f51dc2f3d5047f334da5cb5eebe568480622f5
[ "MIT" ]
null
null
null
/*========================== begin_copyright_notice ============================ Copyright (c) 2017-2021 Intel Corporation Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ============================= end_copyright_notice ===========================*/ #ifndef _IGA_IR_DUANALYSIS_HPP #define _IGA_IR_DUANALYSIS_HPP #include "../IR/RegSet.hpp" #include "../IR/Kernel.hpp" #include <ostream> #include <string> #include <vector> namespace iga { // A live range is a path from a definition of some register values to // a use. The use may be a read (typical case) or a write (since we need // to be able to track WAW dependencies). struct Dep { // If the use is a read, this will be READ. // WRITE indicates that bytes are being redefined. // E.g. // mov r0 ... // mul r1:q .. r0 // RAW dependency (on the add) // add r0 ... // WAR dependency // add r1:d ... // WAW enum Type {RAW, WAR, WAW} useType = RAW; // // The producer instruction; // this can be nullptr if the value is a program input Instruction *def = nullptr; // // The consumer instruction; // this can be nullptr if the value is a program output Instruction *use = nullptr; // or write (redef) // // The register values that are live in this path RegSet values; // // This is number of in-order instructions this path covers // We determine in-orderness via OpSpec::isFixedLatency int minInOrderDist = 0; // // indicates if the dependency crosses a branch (JEU) // N.b. this will false for fallthrough since that isn't a branch // mov r1 ... // (f0.0) jmpi TARGET // add ... r1 // crossesBranch = false here // TARGET: // mul ... r1 // crossesBranch = true here bool crossesBranch = false; Dep(const Model &m) : values(m) { } Dep(Type t, Instruction *_use) : useType(t) , def(nullptr) , use(_use) , values(*Model::LookupModel(_use->platform())) , minInOrderDist(0) , crossesBranch(false) { } Dep(const Dep &) = default; Dep &operator=(const Dep &) = default; bool operator==(const Dep &p) const; bool operator!=(const Dep &p) const { return !(*this == p); } // for debug void str(std::ostream &os) const; std::string str() const; }; struct BlockInfo { Block *block; std::vector<Dep> liveDefsIn; std::vector<Dep> liveDefsOut; BlockInfo(Block *blk) : block(blk) { } BlockInfo(const BlockInfo &) = default; // BlockInfo(BlockInfo &&) = default; }; struct DepAnalysis { // information on each block std::vector<BlockInfo> blockInfo; // // relation of definitions and uses std::vector<Dep> deps; }; // the primary entry point for the live analysis DepAnalysis ComputeDepAnalysis(Kernel *k); } // namespace IGA #endif // _IGA_IR_ANALYSIS_HPP
35.570248
80
0.590381
bader
6d355eec0f38238c13c1f4bf5c285528507dd034
404
cpp
C++
tests/cpp/lib/make_reverse_iterator.201402.cpp
eggs-cpp/sd-6
d7ba0c08acf7c1c817baa1ea53f488d02394858a
[ "BSL-1.0" ]
7
2015-03-03T18:33:02.000Z
2018-08-31T08:26:01.000Z
tests/cpp/lib/make_reverse_iterator.201402.cpp
eggs-cpp/sd-6
d7ba0c08acf7c1c817baa1ea53f488d02394858a
[ "BSL-1.0" ]
null
null
null
tests/cpp/lib/make_reverse_iterator.201402.cpp
eggs-cpp/sd-6
d7ba0c08acf7c1c817baa1ea53f488d02394858a
[ "BSL-1.0" ]
null
null
null
// Eggs.SD-6 // // Copyright Agustin K-ballo Berge, Fusion Fenix 2015 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include <iterator> void test_make_reverse_iterator() { std::reverse_iterator<int*> p{std::make_reverse_iterator((int*)0)}; } int main() { test_make_reverse_iterator(); }
23.764706
79
0.732673
eggs-cpp
6d35785590dea8d08c91bbfa6f4551042054e6c2
12,004
cpp
C++
lib/AudioGroup.cpp
gpeter12/amuse
d96be61e296031d5417e46dba1d3b9060b2ab6c0
[ "MIT" ]
null
null
null
lib/AudioGroup.cpp
gpeter12/amuse
d96be61e296031d5417e46dba1d3b9060b2ab6c0
[ "MIT" ]
null
null
null
lib/AudioGroup.cpp
gpeter12/amuse
d96be61e296031d5417e46dba1d3b9060b2ab6c0
[ "MIT" ]
null
null
null
#include "amuse/AudioGroup.hpp" #include <regex> #include <sstream> #include "amuse/AudioGroupData.hpp" #include <athena/FileReader.hpp> #include <fmt/ostream.h> using namespace std::literals; namespace amuse { void AudioGroup::assign(const AudioGroupData& data) { m_pool = AudioGroupPool::CreateAudioGroupPool(data); m_proj = AudioGroupProject::CreateAudioGroupProject(data); m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(data); m_samp = data.getSamp(); } void AudioGroup::assign(SystemStringView groupPath) { /* Reverse order when loading intermediates */ m_groupPath = groupPath; m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(groupPath); m_pool = AudioGroupPool::CreateAudioGroupPool(groupPath); m_proj = AudioGroupProject::CreateAudioGroupProject(groupPath); m_samp = nullptr; } void AudioGroup::assign(const AudioGroup& data, SystemStringView groupPath) { /* Reverse order when loading intermediates */ m_groupPath = groupPath; m_sdir = AudioGroupSampleDirectory::CreateAudioGroupSampleDirectory(groupPath); m_pool = AudioGroupPool::CreateAudioGroupPool(groupPath); m_proj = AudioGroupProject::CreateAudioGroupProject(data.getProj()); m_samp = nullptr; } const SampleEntry* AudioGroup::getSample(SampleId sfxId) const { auto search = m_sdir.m_entries.find(sfxId); if (search == m_sdir.m_entries.cend()) return nullptr; return search->second.get(); } SystemString AudioGroup::getSampleBasePath(SampleId sfxId) const { #if _WIN32 return m_groupPath + _SYS_STR('/') + athena::utility::utf8ToWide(SampleId::CurNameDB->resolveNameFromId(sfxId)); #else return m_groupPath + _SYS_STR('/') + SampleId::CurNameDB->resolveNameFromId(sfxId).data(); #endif } std::pair<ObjToken<SampleEntryData>, const unsigned char*> AudioGroup::getSampleData(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); const_cast<SampleEntry*>(sample)->loadLooseData(basePath); return {sample->m_data, sample->m_data->m_looseData.get()}; } return {sample->m_data, m_samp + sample->m_data->m_sampleOff}; } SampleFileState AudioGroup::getSampleFileState(SampleId sfxId, const SampleEntry* sample, SystemString* pathOut) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); return sample->getFileState(basePath, pathOut); } if (sample->m_data->isFormatDSP() || sample->m_data->getSampleFormat() == SampleFormat::N64) return SampleFileState::MemoryOnlyCompressed; return SampleFileState::MemoryOnlyWAV; } void AudioGroup::patchSampleMetadata(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { SystemString basePath = getSampleBasePath(sfxId); sample->patchSampleMetadata(basePath); } } void AudioGroup::makeWAVVersion(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { m_sdir._extractWAV(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get()); } } void AudioGroup::makeCompressedVersion(SampleId sfxId, const SampleEntry* sample) const { if (sample->m_data->m_looseData) { m_sdir._extractCompressed(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get(), true); } } void AudioGroupDatabase::renameSample(SampleId id, std::string_view str) { SystemString oldBasePath = getSampleBasePath(id); SampleId::CurNameDB->rename(id, str); SystemString newBasePath = getSampleBasePath(id); Rename((oldBasePath + _SYS_STR(".wav")).c_str(), (newBasePath + _SYS_STR(".wav")).c_str()); Rename((oldBasePath + _SYS_STR(".dsp")).c_str(), (newBasePath + _SYS_STR(".dsp")).c_str()); Rename((oldBasePath + _SYS_STR(".vadpcm")).c_str(), (newBasePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::deleteSample(SampleId id) { SystemString basePath = getSampleBasePath(id); Unlink((basePath + _SYS_STR(".wav")).c_str()); Unlink((basePath + _SYS_STR(".dsp")).c_str()); Unlink((basePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::copySampleInto(const SystemString& basePath, const SystemString& newBasePath) { Copy((basePath + _SYS_STR(".wav")).c_str(), (newBasePath + _SYS_STR(".wav")).c_str()); Copy((basePath + _SYS_STR(".dsp")).c_str(), (newBasePath + _SYS_STR(".dsp")).c_str()); Copy((basePath + _SYS_STR(".vadpcm")).c_str(), (newBasePath + _SYS_STR(".vadpcm")).c_str()); } void AudioGroupDatabase::_recursiveRenameMacro(SoundMacroId id, std::string_view str, int& macroIdx, std::unordered_set<SoundMacroId>& renamedIds) { if (renamedIds.find(id) != renamedIds.cend()) return; if (const SoundMacro* macro = getPool().soundMacro(id)) { if (!strncmp(SoundMacroId::CurNameDB->resolveNameFromId(id).data(), "macro", 5)) { std::string macroName("macro"sv); if (macroIdx) macroName += fmt::format(FMT_STRING("{}"), macroIdx); macroName += '_'; macroName += str; ++macroIdx; SoundMacroId::CurNameDB->rename(id, macroName); renamedIds.insert(id); int sampleIdx = 0; for (const auto& cmd : macro->m_cmds) { switch (cmd->Isa()) { case SoundMacro::CmdOp::StartSample: { SoundMacro::CmdStartSample* ss = static_cast<SoundMacro::CmdStartSample*>(cmd.get()); if (!strncmp(SampleId::CurNameDB->resolveNameFromId(ss->sample.id).data(), "sample", 6)) { std::string sampleName("sample"sv); if (sampleIdx) sampleName += fmt::format(FMT_STRING("{}"), sampleIdx); sampleName += '_'; sampleName += macroName; ++sampleIdx; renameSample(ss->sample.id, sampleName); } break; } case SoundMacro::CmdOp::SplitKey: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitKey*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitVel: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitVel*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::Goto: _recursiveRenameMacro(static_cast<SoundMacro::CmdGoto*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::PlayMacro: _recursiveRenameMacro(static_cast<SoundMacro::CmdPlayMacro*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitMod: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitMod*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SplitRnd: _recursiveRenameMacro(static_cast<SoundMacro::CmdSplitRnd*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::GoSub: _recursiveRenameMacro(static_cast<SoundMacro::CmdGoSub*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::TrapEvent: _recursiveRenameMacro(static_cast<SoundMacro::CmdTrapEvent*>(cmd.get())->macro, str, macroIdx, renamedIds); break; case SoundMacro::CmdOp::SendMessage: _recursiveRenameMacro(static_cast<SoundMacro::CmdSendMessage*>(cmd.get())->macro, str, macroIdx, renamedIds); break; default: break; } } } } } static const std::regex DefineGRPEntry(R"(#define\s+GRP(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); static const std::regex DefineSNGEntry(R"(#define\s+SNG(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); static const std::regex DefineSFXEntry(R"(#define\s+SFX(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); void AudioGroupDatabase::importCHeader(std::string_view header) { std::match_results<std::string_view::const_iterator> dirMatch; auto begin = header.cbegin(); auto end = header.cend(); while (std::regex_search(begin, end, dirMatch, DefineGRPEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; GroupId::CurNameDB->rename(id, key); begin = dirMatch.suffix().first; } begin = header.cbegin(); end = header.cend(); while (std::regex_search(begin, end, dirMatch, DefineSNGEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; SongId::CurNameDB->rename(id, key); begin = dirMatch.suffix().first; } begin = header.cbegin(); end = header.cend(); std::unordered_set<SoundMacroId> renamedMacroIDs; while (std::regex_search(begin, end, dirMatch, DefineSFXEntry)) { std::string key = dirMatch[1].str(); std::string value = dirMatch[2].str(); char* endPtr; amuse::ObjectId id; id.id = strtoul(value.c_str(), &endPtr, 0); if (endPtr == value.c_str()) continue; SFXId::CurNameDB->rename(id, key); int macroIdx = 0; for (auto& sfxGrp : getProj().sfxGroups()) { for (auto& sfx : sfxGrp.second->m_sfxEntries) { if (sfx.first == id) { ObjectId sfxObjId = sfx.second.objId; if (sfxObjId == ObjectId() || sfxObjId.id & 0xc000) continue; _recursiveRenameMacro(sfxObjId, key, macroIdx, renamedMacroIDs); } } } begin = dirMatch.suffix().first; } } static void WriteDefineLine(std::stringstream& ret, std::string_view typeStr, std::string_view name, ObjectId id) { fmt::print(ret, FMT_STRING("#define {}{} 0x{}\n"), typeStr, name, id); } std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std::string_view groupName) const { std::stringstream ret; ret << "/* Auto-generated Amuse Defines\n" " *\n" " * Project: "sv; ret << projectName; ret << "\n" " * Subproject: "sv; ret << groupName; ret << "\n" " * Date: "sv; time_t curTime = time(nullptr); #ifndef _WIN32 struct tm curTm; localtime_r(&curTime, &curTm); char curTmStr[26]; asctime_r(&curTm, curTmStr); #else struct tm curTm; localtime_s(&curTm, &curTime); char curTmStr[26]; asctime_s(curTmStr, &curTm); #endif if (char* ch = strchr(curTmStr, '\n')) *ch = '\0'; ret << curTmStr; ret << "\n" " */\n\n\n"sv; bool addLF = false; for (const auto& sg : SortUnorderedMap(getProj().songGroups())) { auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first); WriteDefineLine(ret, "GRP"sv, name, sg.first); addLF = true; } for (const auto& sg : SortUnorderedMap(getProj().sfxGroups())) { auto name = amuse::GroupId::CurNameDB->resolveNameFromId(sg.first); WriteDefineLine(ret, "GRP"sv, name, sg.first); addLF = true; } if (addLF) ret << "\n\n"sv; addLF = false; std::unordered_set<amuse::SongId> songIds; for (const auto& sg : getProj().songGroups()) for (const auto& song : sg.second->m_midiSetups) songIds.insert(song.first); for (amuse::SongId id : SortUnorderedSet(songIds)) { auto name = amuse::SongId::CurNameDB->resolveNameFromId(id); WriteDefineLine(ret, "SNG"sv, name, id); addLF = true; } if (addLF) ret << "\n\n"sv; addLF = false; for (const auto& sg : SortUnorderedMap(getProj().sfxGroups())) { for (const auto& sfx : SortUnorderedMap(sg.second.get()->m_sfxEntries)) { auto name = amuse::SFXId::CurNameDB->resolveNameFromId(sfx.first); WriteDefineLine(ret, "SFX"sv, name, sfx.first.id); addLF = true; } } if (addLF) ret << "\n\n"sv; return ret.str(); } } // namespace amuse
37.5125
120
0.664612
gpeter12
6d377276a329bd3412d37bc153c4c6198d2a2118
3,141
hpp
C++
driver/src/hp_reverb_hid.hpp
mmmspatz/wumbo_mr
7dfecd4cb824ad2268f6f9208e3fe6c9510fb097
[ "BSL-1.0" ]
1
2021-02-12T06:54:53.000Z
2021-02-12T06:54:53.000Z
driver/src/hp_reverb_hid.hpp
mmmspatz/wumbo_mr
7dfecd4cb824ad2268f6f9208e3fe6c9510fb097
[ "BSL-1.0" ]
null
null
null
driver/src/hp_reverb_hid.hpp
mmmspatz/wumbo_mr
7dfecd4cb824ad2268f6f9208e3fe6c9510fb097
[ "BSL-1.0" ]
null
null
null
// Copyright Mark H. Spatz 2021-present // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE or copy at // https://www.boost.org/LICENSE_1_0.txt) #pragma once #include <array> #include <cassert> #include <cstddef> #include <cstdint> #include <wmr/vendor_hid_interface.hpp> #include "hid_device.hpp" namespace wmr { class HpReverbHid : public VendorHidInterface { public: HpReverbHid(std::unique_ptr<HidDevice> hid_dev); void WakeDisplay() final; private: // set then get as feature 4x at startup struct __attribute__((packed)) MyteryReport80 { static constexpr uint8_t kReportId = 0x50; static constexpr std::size_t kReportSize = 64; uint8_t report_id; uint8_t mystery_byte_1; std::array<uint8_t, 62> data; }; static_assert(sizeof(MyteryReport80) == MyteryReport80::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport9 { static constexpr uint8_t kReportId = 0x09; static constexpr std::size_t kReportSize = 64; uint8_t report_id; std::array<uint8_t, 63> data; }; static_assert(sizeof(MyteryReport9) == MyteryReport9::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport8 { static constexpr uint8_t kReportId = 0x08; static constexpr std::size_t kReportSize = 64; uint8_t report_id; std::array<uint8_t, 63> data; }; static_assert(sizeof(MyteryReport8) == MyteryReport8::kReportSize); // get as feature once at startup struct __attribute__((packed)) MyteryReport6 { static constexpr uint8_t kReportId = 0x06; static constexpr std::size_t kReportSize = 2; uint8_t report_id; uint8_t value; }; static_assert(sizeof(MyteryReport6) == MyteryReport6::kReportSize); // Set as feature to 0x01 once at startup struct __attribute__((packed)) MyteryReport4 { static constexpr uint8_t kReportId = 0x04; static constexpr std::size_t kReportSize = 2; uint8_t report_id; uint8_t value; }; static_assert(sizeof(MyteryReport4) == MyteryReport4::kReportSize); // Read as interrupt during operation struct __attribute__((packed)) MyteryReport5 { static constexpr uint8_t kReportId = 0x05; static constexpr std::size_t kReportSize = 33; uint8_t report_id; std::array<uint8_t, 32> data; }; static_assert(sizeof(MyteryReport5) == MyteryReport5::kReportSize); struct MysteryReport5Reader : HidDevice::ReportReader { void Update(Report report) final; }; // Read as interrupt during operation struct __attribute__((packed)) MyteryReport1 { static constexpr uint8_t kReportId = 0x01; static constexpr std::size_t kReportSize = 4; uint8_t report_id; uint8_t unknown_8; uint16_t unknown_16; }; static_assert(sizeof(MyteryReport1) == MyteryReport1::kReportSize); struct MysteryReport1Reader : HidDevice::ReportReader { void Update(Report report) final; }; std::unique_ptr<HidDevice> hid_dev_; std::shared_ptr<HidDevice::ReportReader> reader_5_; std::shared_ptr<HidDevice::ReportReader> reader_1_; }; } // namespace wmr
28.044643
71
0.730022
mmmspatz
6d38cdd8c0d32cb3d0c741a0950aba2542fe03b1
104
hh
C++
SDK/ClientModeShared.hh
Joyzyy/HelvetaCS
9e24cb0bc9748413b1a478275e30fc7e25150f8f
[ "WTFPL" ]
1
2021-11-10T10:50:46.000Z
2021-11-10T10:50:46.000Z
SDK/ClientModeShared.hh
Joyzyy/HelvetaCS
9e24cb0bc9748413b1a478275e30fc7e25150f8f
[ "WTFPL" ]
null
null
null
SDK/ClientModeShared.hh
Joyzyy/HelvetaCS
9e24cb0bc9748413b1a478275e30fc7e25150f8f
[ "WTFPL" ]
null
null
null
#pragma once #include "Forward.hh" struct SDK::ClientModeShared { PAD(0x28); int m_nRootSize[2]; };
11.555556
30
0.701923
Joyzyy
6d3a06a769b49345049a421aadd866de87145bdf
4,886
cpp
C++
QuantumGateLib/Network/IPAddress.cpp
Colorfingers/QuantumGate
e183e02464859f4ca486999182c4c41221f3261a
[ "MIT" ]
null
null
null
QuantumGateLib/Network/IPAddress.cpp
Colorfingers/QuantumGate
e183e02464859f4ca486999182c4c41221f3261a
[ "MIT" ]
null
null
null
QuantumGateLib/Network/IPAddress.cpp
Colorfingers/QuantumGate
e183e02464859f4ca486999182c4c41221f3261a
[ "MIT" ]
null
null
null
// This file is part of the QuantumGate project. For copyright and // licensing information refer to the license file(s) in the project root. #include "pch.h" #include "IPAddress.h" #include "..\Common\Endian.h" #include <regex> namespace QuantumGate::Implementation::Network { bool IPAddress::TryParse(const WChar* ipaddr_str, IPAddress& ipaddr) noexcept { try { IPAddress temp_ip(ipaddr_str); ipaddr = std::move(temp_ip); return true; } catch (...) {} return false; } bool IPAddress::TryParse(const String& ipaddr_str, IPAddress& ipaddr) noexcept { return TryParse(ipaddr_str.c_str(), ipaddr); } bool IPAddress::TryParse(const BinaryIPAddress& bin_ipaddr, IPAddress& ipaddr) noexcept { try { IPAddress temp_ip(bin_ipaddr); ipaddr = std::move(temp_ip); return true; } catch (...) {} return false; } bool IPAddress::TryParseMask(const IPAddress::Family af, const WChar* mask_str, IPAddress& ipmask) noexcept { try { if (std::wcslen(mask_str) <= IPAddress::MaxIPAddressStringLength) { // Looks for mask bits specified in the format // "/999" in the mask string used in CIDR notations // such as "192.168.0.0/16" std::wregex r(LR"bits(^\s*\/(\d+)\s*$)bits"); std::wcmatch m; if (std::regex_search(mask_str, m, r)) { auto cidr_lbits = std::stoi(m[1].str()); return CreateMask(af, cidr_lbits, ipmask); } else { // Treats the mask string as an IP address mask // e.g. "255.255.255.255" IPAddress temp_ip; if (TryParse(mask_str, temp_ip) && temp_ip.GetFamily() == af && temp_ip.IsMask()) { ipmask = std::move(temp_ip); return true; } } } } catch (...) {} return false; } bool IPAddress::TryParseMask(const IPAddress::Family af, const String& mask_str, IPAddress& ipmask) noexcept { return TryParseMask(af, mask_str.c_str(), ipmask); } void IPAddress::SetAddress(const WChar* ipaddr_str) { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in6_addr), "IP Address length mismatch"); if (std::wcslen(ipaddr_str) <= IPAddress::MaxIPAddressStringLength) { BinaryIPAddress baddr; if (InetPton(AF_INET, ipaddr_str, &baddr.Bytes) == 1) { m_BinaryAddress = baddr; m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv4; return; } else { const WChar* ipaddr_ptr = ipaddr_str; std::array<WChar, IPAddress::MaxIPAddressStringLength + 1> ipaddr_str2{ 0 }; // Remove link-local address zone index for IPv6 addresses; // starts with % on Windows. InetPton does not accept it. const auto pos = std::wcsstr(ipaddr_str, L"%"); if (pos != nullptr) { std::memcpy(ipaddr_str2.data(), ipaddr_str, (pos - ipaddr_str) * sizeof(WChar)); ipaddr_ptr = ipaddr_str2.data(); } if (InetPton(AF_INET6, ipaddr_ptr, &baddr.Bytes) == 1) { m_BinaryAddress = baddr; m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv6; return; } } } throw std::invalid_argument("Invalid IP address"); return; } void IPAddress::SetAddress(const sockaddr_storage* saddr) { assert(saddr != nullptr); switch (saddr->ss_family) { case AF_INET: { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in_addr), "IP Address length mismatch"); m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv4; auto ip4 = reinterpret_cast<const sockaddr_in*>(saddr); std::memcpy(&m_BinaryAddress.Bytes, &ip4->sin_addr, sizeof(ip4->sin_addr)); break; } case AF_INET6: { static_assert(sizeof(m_BinaryAddress.Bytes) >= sizeof(in6_addr), "IP Address length mismatch"); m_BinaryAddress.AddressFamily = BinaryIPAddress::Family::IPv6; auto ip6 = reinterpret_cast<const sockaddr_in6*>(saddr); std::memcpy(&m_BinaryAddress.Bytes, &ip6->sin6_addr, sizeof(ip6->sin6_addr)); break; } default: { throw std::invalid_argument("Unsupported internetwork address family"); } } return; } String IPAddress::GetString() const noexcept { try { auto afws = AF_UNSPEC; switch (m_BinaryAddress.AddressFamily) { case BinaryIPAddress::Family::IPv4: afws = AF_INET; break; case BinaryIPAddress::Family::IPv6: afws = AF_INET6; break; default: return {}; } std::array<WChar, IPAddress::MaxIPAddressStringLength> ipstr{ 0 }; const auto ip = InetNtop(afws, &m_BinaryAddress.Bytes, reinterpret_cast<PWSTR>(ipstr.data()), ipstr.size()); if (ip != NULL) { return ipstr.data(); } } catch (...) {} return {}; } std::ostream& operator<<(std::ostream& stream, const IPAddress& ipaddr) { stream << Util::ToStringA(ipaddr.GetString()); return stream; } std::wostream& operator<<(std::wostream& stream, const IPAddress& ipaddr) { stream << ipaddr.GetString(); return stream; } }
24.068966
111
0.663528
Colorfingers
6d3c3efbc4024cefa4774e9aa7eb7f0c8ee782b7
274
cpp
C++
C++/sqrt/sqrt.cpp
zSucrilhos/programming
aa0076a4a7084a6064e1e5df258ba0c90cf8ceeb
[ "MIT" ]
null
null
null
C++/sqrt/sqrt.cpp
zSucrilhos/programming
aa0076a4a7084a6064e1e5df258ba0c90cf8ceeb
[ "MIT" ]
4
2020-07-18T03:27:03.000Z
2020-07-18T03:28:37.000Z
C++/sqrt/sqrt.cpp
zSucrilhos/programming
aa0076a4a7084a6064e1e5df258ba0c90cf8ceeb
[ "MIT" ]
null
null
null
#include <iostream> using namespace std; int main() { double num01, sqr; cout << "Calculador de sqrt" << endl; cout << "Digite um número: "; cin >> num01; sqr = num01 * num01; cout << "O resultado é: " << sqr << endl; } // This is a commentary
16.117647
45
0.565693
zSucrilhos
6d3dc58662f91d201f5e7adcee3c9edb51b4239d
3,129
cpp
C++
code/engine/xrGame/agent_manager.cpp
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
58
2016-11-20T19:14:35.000Z
2021-12-27T21:03:35.000Z
code/engine/xrGame/agent_manager.cpp
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
59
2016-09-10T10:44:20.000Z
2018-09-03T19:07:30.000Z
code/engine/xrGame/agent_manager.cpp
InNoHurryToCode/xray-162
fff9feb9ffb681b3c6ba1dc7c4534fe80006f87e
[ "Apache-2.0" ]
39
2017-02-05T13:35:37.000Z
2022-03-14T11:00:12.000Z
//////////////////////////////////////////////////////////////////////////// // Module : agent_manager.cpp // Created : 24.05.2004 // Modified : 24.05.2004 // Author : Dmitriy Iassenev // Description : Agent manager //////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "agent_manager.h" #include "agent_corpse_manager.h" #include "agent_enemy_manager.h" #include "agent_explosive_manager.h" #include "agent_location_manager.h" #include "agent_member_manager.h" #include "agent_memory_manager.h" #include "agent_manager_planner.h" //#include "profiler.h" CAgentManager::CAgentManager() { init_scheduler(); init_components(); } CAgentManager::~CAgentManager() { VERIFY(member().members().empty()); #ifdef USE_SCHEDULER_IN_AGENT_MANAGER remove_scheduler(); #endif // USE_SCHEDULER_IN_AGENT_MANAGER remove_components(); } void CAgentManager::init_scheduler() { #ifdef USE_SCHEDULER_IN_AGENT_MANAGER shedule.t_min = 1000; shedule.t_max = 1000; shedule_register(); #else // USE_SCHEDULER_IN_AGENT_MANAGER m_last_update_time = 0; m_update_rate = 1000; #endif // USE_SCHEDULER_IN_AGENT_MANAGER } void CAgentManager::init_components() { m_corpse = xr_new<CAgentCorpseManager>(this); m_enemy = xr_new<CAgentEnemyManager>(this); m_explosive = xr_new<CAgentExplosiveManager>(this); m_location = xr_new<CAgentLocationManager>(this); m_member = xr_new<CAgentMemberManager>(this); m_memory = xr_new<CAgentMemoryManager>(this); m_brain = xr_new<CAgentManagerPlanner>(); brain().setup(this); } #ifdef USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::remove_scheduler() { shedule_unregister(); } #endif // USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::remove_components() { xr_delete(m_corpse); xr_delete(m_enemy); xr_delete(m_explosive); xr_delete(m_location); xr_delete(m_member); xr_delete(m_memory); xr_delete(m_brain); } void CAgentManager::remove_links(CObject* object) { corpse().remove_links(object); enemy().remove_links(object); explosive().remove_links(object); location().remove_links(object); member().remove_links(object); memory().remove_links(object); brain().remove_links(object); } void CAgentManager::update_impl() { VERIFY(!member().members().empty()); memory().update(); corpse().update(); enemy().update(); explosive().update(); location().update(); member().update(); brain().update(); } #ifdef USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::shedule_Update(u32 time_delta) { START_PROFILE("Agent_Manager") ISheduled::shedule_Update(time_delta); update_impl(); STOP_PROFILE } float CAgentManager::shedule_Scale() { return (.5f); } #else // USE_SCHEDULER_IN_AGENT_MANAGER void CAgentManager::update() { if (Device.dwTimeGlobal <= m_last_update_time) return; if (Device.dwTimeGlobal - m_last_update_time < m_update_rate) return; m_last_update_time = Device.dwTimeGlobal; update_impl(); } #endif // USE_SCHEDULER_IN_AGENT_MANAGER
26.74359
76
0.688399
InNoHurryToCode
6d420e92bf72c524eec3380dd238df32a22afc81
1,511
cpp
C++
src/utils/ColorScheme.cpp
leet-feat/feather
ff6e6adf0c853fcf664bd8f0b2ee94a51550b4f8
[ "BSD-3-Clause" ]
2
2021-06-30T19:03:35.000Z
2022-01-21T00:07:49.000Z
src/utils/ColorScheme.cpp
leet-feat/feather
ff6e6adf0c853fcf664bd8f0b2ee94a51550b4f8
[ "BSD-3-Clause" ]
1
2022-01-21T00:12:28.000Z
2022-01-21T15:55:09.000Z
src/utils/ColorScheme.cpp
leet-feat/feather
ff6e6adf0c853fcf664bd8f0b2ee94a51550b4f8
[ "BSD-3-Clause" ]
null
null
null
// SPDX-License-Identifier: BSD-3-Clause // Copyright (c) 2020-2021, The Monero Project. // Copyright (c) 2012 thomasv@gitorious #include "ColorScheme.h" #include <QDebug> bool ColorScheme::darkScheme = false; ColorSchemeItem ColorScheme::GREEN = ColorSchemeItem("#117c11", "#8af296"); ColorSchemeItem ColorScheme::YELLOW = ColorSchemeItem("#897b2a", "#ffff00"); ColorSchemeItem ColorScheme::RED = ColorSchemeItem("#7c1111", "#f18c8c"); ColorSchemeItem ColorScheme::BLUE = ColorSchemeItem("#123b7c", "#8cb3f2"); ColorSchemeItem ColorScheme::DEFAULT = ColorSchemeItem("black", "white"); ColorSchemeItem ColorScheme::GRAY = ColorSchemeItem("gray", "gray"); bool ColorScheme::hasDarkBackground(QWidget *widget) { int r, g, b; widget->palette().color(QPalette::Background).getRgb(&r, &g, &b); auto brightness = r + g + b; return brightness < (255*3/2); } void ColorScheme::updateFromWidget(QWidget *widget, bool forceDark) { darkScheme = forceDark || ColorScheme::hasDarkBackground(widget); } QString ColorSchemeItem::asStylesheet(bool background) { auto cssPrefix = background ? "background-" : ""; auto color = this->getColor(background); return QString("QWidget { %1color : %2; }").arg(cssPrefix, color); } QColor ColorSchemeItem::asColor(bool background) { auto color = this->getColor(background); return QColor(color); } QString ColorSchemeItem::getColor(bool background) { return m_colors[(int(background) + int(ColorScheme::darkScheme)) % 2]; }
37.775
77
0.717406
leet-feat
6d428ff549ce93b2a8c60365683e20449524b7a5
1,534
cpp
C++
Source/VoxelEditor/Private/VoxelWorldEditor.cpp
Batname/VoxelPlugin
711812c3fadafd4d33e6be861dc96241c39d81a5
[ "MIT" ]
1
2019-04-09T02:39:04.000Z
2019-04-09T02:39:04.000Z
Source/VoxelEditor/Private/VoxelWorldEditor.cpp
Batname/VoxelPlugin
711812c3fadafd4d33e6be861dc96241c39d81a5
[ "MIT" ]
null
null
null
Source/VoxelEditor/Private/VoxelWorldEditor.cpp
Batname/VoxelPlugin
711812c3fadafd4d33e6be861dc96241c39d81a5
[ "MIT" ]
null
null
null
// Copyright 2018 Phyronnaz #include "VoxelWorldEditor.h" #include "VoxelInvokerComponent.h" #include "VoxelWorld.h" #include "Components/CapsuleComponent.h" #include "LevelEditorViewport.h" #include "Editor.h" #include "VoxelWorldDetails.h" AVoxelWorldEditor::AVoxelWorldEditor() { PrimaryActorTick.bCanEverTick = true; Invoker = CreateDefaultSubobject<UVoxelInvokerComponent>(FName("Editor Invoker")); Invoker->DistanceOffset = 5000; auto TouchCapsule = CreateDefaultSubobject<UCapsuleComponent>(FName("Capsule")); TouchCapsule->InitCapsuleSize(0.1f, 0.1f); TouchCapsule->SetCollisionEnabled(ECollisionEnabled::NoCollision); TouchCapsule->SetCollisionResponseToAllChannels(ECR_Ignore); RootComponent = TouchCapsule; } TWeakObjectPtr<UVoxelInvokerComponent> AVoxelWorldEditor::GetInvoker() { return TWeakObjectPtr<UVoxelInvokerComponent>(Invoker); } void AVoxelWorldEditor::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (!World.IsValid()) { Destroy(); return; } if (GetWorld()->WorldType == EWorldType::Editor) { auto Client = static_cast<FLevelEditorViewportClient*>(GEditor->GetActiveViewport()->GetClient()); if (Client) { FVector CameraPosition = Client->GetViewLocation(); SetActorLocation(CameraPosition); } else { UE_LOG(LogTemp, Error, TEXT("Cannot find editor camera")); } } } #if WITH_EDITOR bool AVoxelWorldEditor::ShouldTickIfViewportsOnly() const { return true; } void AVoxelWorldEditor::Init(TWeakObjectPtr<AVoxelWorld> NewWorld) { World = NewWorld; } #endif
23.242424
100
0.769883
Batname
6d44ea114cc69d2e7b7d4118a1d067d1b33a1701
9,656
cc
C++
db/dbformat.cc
rnowak-basho-forks/leveldb
f6b6c42dbf19a2a8bebb75106fe8ce02bdd8d2bb
[ "BSD-3-Clause" ]
130
2015-01-02T15:23:15.000Z
2021-11-18T12:40:20.000Z
db/dbformat.cc
rnowak-basho-forks/leveldb
f6b6c42dbf19a2a8bebb75106fe8ce02bdd8d2bb
[ "BSD-3-Clause" ]
87
2015-01-12T17:38:26.000Z
2022-02-22T17:15:06.000Z
db/dbformat.cc
rnowak-basho-forks/leveldb
f6b6c42dbf19a2a8bebb75106fe8ce02bdd8d2bb
[ "BSD-3-Clause" ]
89
2015-01-12T03:25:54.000Z
2022-03-16T00:29:22.000Z
// Copyright (c) 2011 The LevelDB Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. See the AUTHORS file for names of contributors. #include <stdio.h> //#include "leveldb/expiry.h" #include "db/dbformat.h" #include "db/version_set.h" #include "port/port.h" #include "util/coding.h" namespace leveldb { static uint64_t PackSequenceAndType(uint64_t seq, ValueType t) { assert(seq <= kMaxSequenceNumber); // assert(t <= kValueTypeForSeek); requires revisit once expiry live assert(t <= kTypeValueExplicitExpiry); // temp replacement for above return (seq << 8) | t; } void AppendInternalKey(std::string* result, const ParsedInternalKey& key) { result->append(key.user_key.data(), key.user_key.size()); if (IsExpiryKey(key.type)) PutFixed64(result, key.expiry); PutFixed64(result, PackSequenceAndType(key.sequence, key.type)); } std::string ParsedInternalKey::DebugString() const { char buf[50]; if (IsExpiryKey(type)) snprintf(buf, sizeof(buf), "' @ %llu %llu : %d", (unsigned long long) expiry, (unsigned long long) sequence, int(type)); else snprintf(buf, sizeof(buf), "' @ %llu : %d", (unsigned long long) sequence, int(type)); std::string result = "'"; result += HexString(user_key.ToString()); result += buf; return result; } std::string ParsedInternalKey::DebugStringHex() const { char buf[50]; if (IsExpiryKey(type)) snprintf(buf, sizeof(buf), "' @ %llu %llu : %d", (unsigned long long) expiry, (unsigned long long) sequence, int(type)); else snprintf(buf, sizeof(buf), "' @ %llu : %d", (unsigned long long) sequence, int(type)); std::string result = "'"; result += HexString(user_key); result += buf; return result; } const char * KeyTypeString(ValueType val_type) { const char * ret_ptr; switch(val_type) { case kTypeDeletion: ret_ptr="kTypeDelete"; break; case kTypeValue: ret_ptr="kTypeValue"; break; case kTypeValueWriteTime: ret_ptr="kTypeValueWriteTime"; break; case kTypeValueExplicitExpiry: ret_ptr="kTypeValueExplicitExpiry"; break; default: ret_ptr="(unknown ValueType)"; break; } // switch return(ret_ptr); } std::string InternalKey::DebugString() const { std::string result; ParsedInternalKey parsed; if (ParseInternalKey(rep_, &parsed)) { result = parsed.DebugString(); } else { result = "(bad)"; result.append(EscapeString(rep_)); } return result; } const char* InternalKeyComparator::Name() const { return "leveldb.InternalKeyComparator"; } int InternalKeyComparator::Compare(const Slice& akey, const Slice& bkey) const { // Order by: // increasing user key (according to user-supplied comparator) // decreasing sequence number // decreasing type (though sequence# should be enough to disambiguate) int r = user_comparator_->Compare(ExtractUserKey(akey), ExtractUserKey(bkey)); if (r == 0) { uint64_t anum = DecodeFixed64(akey.data() + akey.size() - 8); uint64_t bnum = DecodeFixed64(bkey.data() + bkey.size() - 8); if (IsExpiryKey((ValueType)*(unsigned char *)&anum)) *(unsigned char*)&anum=(unsigned char)kTypeValue; if (IsExpiryKey((ValueType)*(unsigned char *)&bnum)) *(unsigned char*)&bnum=(unsigned char)kTypeValue; if (anum > bnum) { r = -1; } else if (anum < bnum) { r = +1; } } return r; } void InternalKeyComparator::FindShortestSeparator( std::string* start, const Slice& limit) const { // Attempt to shorten the user portion of the key Slice user_start = ExtractUserKey(*start); Slice user_limit = ExtractUserKey(limit); std::string tmp(user_start.data(), user_start.size()); user_comparator_->FindShortestSeparator(&tmp, user_limit); if (tmp.size() < user_start.size() && user_comparator_->Compare(user_start, tmp) < 0) { // User key has become shorter physically, but larger logically. // Tack on the earliest possible number to the shortened user key. PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); assert(this->Compare(*start, tmp) < 0); assert(this->Compare(tmp, limit) < 0); start->swap(tmp); } } void InternalKeyComparator::FindShortSuccessor(std::string* key) const { Slice user_key = ExtractUserKey(*key); std::string tmp(user_key.data(), user_key.size()); user_comparator_->FindShortSuccessor(&tmp); if (tmp.size() < user_key.size() && user_comparator_->Compare(user_key, tmp) < 0) { // User key has become shorter physically, but larger logically. // Tack on the earliest possible number to the shortened user key. PutFixed64(&tmp, PackSequenceAndType(kMaxSequenceNumber,kValueTypeForSeek)); assert(this->Compare(*key, tmp) < 0); key->swap(tmp); } } const char* InternalFilterPolicy::Name() const { return user_policy_->Name(); } void InternalFilterPolicy::CreateFilter(const Slice* keys, int n, std::string* dst) const { // We rely on the fact that the code in table.cc does not mind us // adjusting keys[]. Slice* mkey = const_cast<Slice*>(keys); for (int i = 0; i < n; i++) { mkey[i] = ExtractUserKey(keys[i]); // TODO(sanjay): Suppress dups? } user_policy_->CreateFilter(keys, n, dst); } bool InternalFilterPolicy::KeyMayMatch(const Slice& key, const Slice& f) const { return user_policy_->KeyMayMatch(ExtractUserKey(key), f); } LookupKey::LookupKey(const Slice& user_key, SequenceNumber s, KeyMetaData * meta) { meta_=meta; size_t usize = user_key.size(); size_t needed = usize + 13; // A conservative estimate char* dst; if (needed <= sizeof(space_)) { dst = space_; } else { dst = new char[needed]; } start_ = dst; dst = EncodeVarint32(dst, usize + 8); kstart_ = dst; memcpy(dst, user_key.data(), usize); dst += usize; EncodeFixed64(dst, PackSequenceAndType(s, kValueTypeForSeek)); dst += 8; end_ = dst; } KeyRetirement::KeyRetirement( const Comparator * Comparator, SequenceNumber SmallestSnapshot, const Options * Opts, Compaction * const Compaction) : has_current_user_key(false), last_sequence_for_key(kMaxSequenceNumber), user_comparator(Comparator), smallest_snapshot(SmallestSnapshot), options(Opts), compaction(Compaction), valid(false), dropped(0), expired(0) { // NULL is ok for compaction valid=(NULL!=user_comparator); return; } // KeyRetirement::KeyRetirement KeyRetirement::~KeyRetirement() { if (0!=expired) gPerfCounters->Add(ePerfExpiredKeys, expired); } // KeyRetirement::~KeyRetirement bool KeyRetirement::operator()( Slice & key) { ParsedInternalKey ikey; bool drop = false, expire_flag; if (valid) { if (!ParseInternalKey(key, &ikey)) { // Do not hide error keys current_user_key.clear(); has_current_user_key = false; last_sequence_for_key = kMaxSequenceNumber; } // else else { if (!has_current_user_key || user_comparator->Compare(ikey.user_key, Slice(current_user_key)) != 0) { // First occurrence of this user key current_user_key.assign(ikey.user_key.data(), ikey.user_key.size()); has_current_user_key = true; last_sequence_for_key = kMaxSequenceNumber; } // if if (last_sequence_for_key <= smallest_snapshot) { // Hidden by an newer entry for same user key drop = true; // (A) } // if else { expire_flag=false; if (NULL!=options && options->ExpiryActivated()) expire_flag=options->expiry_module->KeyRetirementCallback(ikey); if ((ikey.type == kTypeDeletion || expire_flag) && ikey.sequence <= smallest_snapshot && NULL!=compaction // mem to level0 ignores this test && compaction->IsBaseLevelForKey(ikey.user_key)) { // For this user key: // (1) there is no data in higher levels // (2) data in lower levels will have larger sequence numbers // (3) data in layers that are being compacted here and have // smaller sequence numbers will be dropped in the next // few iterations of this loop (by rule (A) above). // Therefore this deletion marker is obsolete and can be dropped. drop = true; if (expire_flag) ++expired; else ++dropped; } // if } // else last_sequence_for_key = ikey.sequence; } // else } // if #if 0 // needs clean up to be used again Log(options_.info_log, " Compact: %s, seq %d, type: %d %d, drop: %d, is_base: %d, " "%d smallest_snapshot: %d", ikey.user_key.ToString().c_str(), (int)ikey.sequence, ikey.type, kTypeValue, drop, compact->compaction->IsBaseLevelForKey(ikey.user_key), (int)last_sequence_for_key, (int)compact->smallest_snapshot); #endif return(drop); } // KeyRetirement::operator(Slice & ) } // namespace leveldb
33.182131
106
0.622618
rnowak-basho-forks
6d45fdba3b3272242f5d7531c20ae624d17dccde
2,560
cpp
C++
song_nevi/goinghome_remote/src/remote_nevi.cpp
leesuengyeol/goingHome_project
0c32f9f4194f0294510720ff2302d5d4a1df8ed5
[ "Apache-2.0" ]
null
null
null
song_nevi/goinghome_remote/src/remote_nevi.cpp
leesuengyeol/goingHome_project
0c32f9f4194f0294510720ff2302d5d4a1df8ed5
[ "Apache-2.0" ]
null
null
null
song_nevi/goinghome_remote/src/remote_nevi.cpp
leesuengyeol/goingHome_project
0c32f9f4194f0294510720ff2302d5d4a1df8ed5
[ "Apache-2.0" ]
null
null
null
#include "goinghome_remote.h" //debug 확인용 #define DEBUG //move_base action_client //amcl x,y 좌표 //static double amcl_x,amcl_y; //orientation //static double amcl_w; //static double arg_x,arg_y; //sector 영역 구분 bool nevi_sev_callback(nevi_srv::Request &req,nevi_srv::Response &res){ //action_clinet 객체 생성 "move_base"에게 요청을 보냄 true spin_thread 허용여부 (boost를 이용한) MoveBase_Client ac ("move_base", true); //액션 서버(move_base가 작동할때까지 대기) while(!ac.waitForServer(ros::Duration(5.0))){ ROS_INFO("Waiting for the move_base action server to come up"); } move_base_msgs::MoveBaseGoal goal_msg; // 상대 좌표 메세지 객체 // move_base_msgs::MoveBaseGoal //메세지 객체 header goal_msg.target_pose.header.frame_id = "map"; goal_msg.target_pose.header.stamp = ros::Time::now(); /*sector 에 따른 좌표 이동 필요 */ //메세지 객체 pose goal_msg.target_pose.pose.position.x = req.px; goal_msg.target_pose.pose.position.y = req.py; goal_msg.target_pose.pose.orientation.w =req.ow; #ifdef DEBUG //변위값 ROS_INFO("send pose.position.x %f",goal_msg.target_pose.pose.position.x); ROS_INFO("send pose.position.y %f",goal_msg.target_pose.pose.position.y); ROS_INFO("send pose.orientation.w %f",goal_msg.target_pose.pose.orientation.w); #endif ROS_INFO("Sending goal"); //메세지 전송 ac.sendGoal(goal_msg); //응답 대기 ac.waitForResult(); //응답 여부 판단 if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED){ //ac.getState() 로 상태 리턴 move_base_msgs/MoveBaseActionResult.msg ROS_INFO("the base moved at x=%f y=%f!!",req.px,req.py); res.result=true; return true; } else{ ROS_INFO("The base failed to move forward"); res.result=false; return false; } } //msg 받기 위한 callback 함수 /* void callback(const geometry_msgs::PoseWithCovarianceStamped& msg){ ROS_INFO("%f:x %f:y\n",msg.pose.pose.position.x,msg.pose.pose.position.y); amcl_x=msg.pose.pose.position.x; amcl_y=msg.pose.pose.position.y; } */ int main(int argc, char* argv[]){ //ros 초기화 ros::init(argc, argv, "remote_nevi"); //노드 관리를 위한 객체 생성 ros::NodeHandle remote_nevi; ros::ServiceServer nevi_sev_server=remote_nevi.advertiseService("nevi_service",nevi_sev_callback); ROS_INFO("nevi service server start"); ros::spin(); return 0; /* 타이머를 이용하여 일정 시간마다 amcl 값을 받도록 할 예정 ros::Subscriber amcl_sub=nh.subscribe("amcl_pose",100,callback); ROS_INFO("subscriber start and waiting"); //topic 받는걸 한번만 하도록한다. amcl_x 와 amcl_y 값이 0 일경우에는 다시 토픽을 받도록함. while ((amcl_x==0)&&(amcl_y==0)) ros::spinOnce();\ */ }
26.122449
100
0.696484
leesuengyeol
6d490b38923f9fd6fca03084200e90b200b6e09b
2,294
cpp
C++
main.cpp
krzkaczor/CSP-Solver
a7b6b81db38e54ddc0a507b7983cd7aa25002fd1
[ "MIT" ]
4
2017-12-06T14:55:53.000Z
2020-03-22T01:57:17.000Z
main.cpp
krzkaczor/CSP-Solver
a7b6b81db38e54ddc0a507b7983cd7aa25002fd1
[ "MIT" ]
null
null
null
main.cpp
krzkaczor/CSP-Solver
a7b6b81db38e54ddc0a507b7983cd7aa25002fd1
[ "MIT" ]
2
2020-12-23T15:56:08.000Z
2021-10-07T00:24:38.000Z
#include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <iostream> #include <string> #include <fstream> #include "grammar/CspProblemGrammar.h" #include "utils/utils.h" #include "csp_problem/CspProblem.h" #include "solvers/BacktrackingSolver.h" #include "solvers/ForwardCheckingSolver.h" using namespace std; using namespace csp; void print_solutions(std::vector<Environment> solutions) { cout << "Solutions: " << solutions.size() << endl; for(auto solution : solutions) { cout << to_string(solution) << endl; } } int main(int argc, char** args) { if (argc != 2) { cout << "Input file must be specified" << endl; exit(1); } string inputFilePath(args[1]); ifstream file(inputFilePath); string cspProblemString((istreambuf_iterator<char>(file)), istreambuf_iterator<char>()); CspProblemGrammar cspProblemGrammar; CspProblemDefinition cspProblemDefinition; std::string::const_iterator iter = cspProblemString.cbegin(); std::string::const_iterator inputEnd = cspProblemString.cend(); bool success = phrase_parse(iter, inputEnd, cspProblemGrammar, boost::spirit::ascii::blank, cspProblemDefinition); if (!success) { std::string rest(iter, inputEnd); cout << "Parsing error: "<< endl; cout << "stopped at: \"" << rest << "\"\n"; exit(1); } cout << "Parsing successful." << endl; CspProblem cspProblem(cspProblemDefinition, ExpressionFactory()); cout << cspProblem.describe(); cout << "Forward checking: " << endl; ForwardCheckingSolver fcsolver(false); auto start = std::chrono::system_clock::now(); print_solutions(fcsolver.solve(cspProblem)); auto end = std::chrono::system_clock::now(); cout << "Time elapsed " << chrono::duration_cast<chrono::seconds>(end - start).count() << " seconds" << endl; cout << "Backtracking: " << endl; BacktrackingSolver btsolver(false); start = std::chrono::system_clock::now(); print_solutions(btsolver.solve(cspProblem)); end = std::chrono::system_clock::now(); cout << "Time elapsed " << chrono::duration_cast<chrono::seconds>(end - start).count() << " seconds" << endl; return 0; }
33.246377
118
0.67524
krzkaczor
6d4cd67fd6ca320f24071a1708cab0d815084182
192,492
hpp
C++
modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp
JosephGeoBenjamin/opencv_contrib-hip
2a948c02b9077b0fd3ae2baf903e9990a5f0a684
[ "BSD-3-Clause" ]
null
null
null
modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp
JosephGeoBenjamin/opencv_contrib-hip
2a948c02b9077b0fd3ae2baf903e9990a5f0a684
[ "BSD-3-Clause" ]
null
null
null
modules/cudev/include/opencv2/cudev/functional/detail/color_cvt.hpp
JosephGeoBenjamin/opencv_contrib-hip
2a948c02b9077b0fd3ae2baf903e9990a5f0a684
[ "BSD-3-Clause" ]
1
2020-11-16T14:32:58.000Z
2020-11-16T14:32:58.000Z
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * The name of the copyright holders may not be used to endorse or promote products // derived from this software without specific prior written permission. // // This software is provided by the copyright holders and contributors "as is" and // any express or implied warranties, including, but not limited to, the implied // warranties of merchantability and fitness for a particular purpose are disclaimed. // In no event shall the Intel Corporation or contributors be liable for any direct, // indirect, incidental, special, exemplary, or consequential damages // (including, but not limited to, procurement of substitute goods or services; // loss of use, data, or profits; or business interruption) however caused // and on any theory of liability, whether in contract, strict liability, // or tort (including negligence or otherwise) arising in any way out of // the use of this software, even if advised of the possibility of such damage. // //M*/ #pragma once #ifndef OPENCV_CUDEV_FUNCTIONAL_COLOR_CVT_DETAIL_HPP #define OPENCV_CUDEV_FUNCTIONAL_COLOR_CVT_DETAIL_HPP #include "../../common.hpp" #include "../../util/vec_traits.hpp" #include "../../util/saturate_cast.hpp" #include "../../util/limits.hpp" #include "../functional.hpp" namespace cv { namespace cudev { namespace color_cvt_detail { // utility #define CV_CUDEV_DESCALE(x, n) (((x) + (1 << ((n)-1))) >> (n)) template <typename T> struct ColorChannel { __device__ __forceinline__ static T max() { return numeric_limits<T>::max(); } __device__ __forceinline__ static T half() { return (T)(max()/2 + 1); } }; template <> struct ColorChannel<float> { __device__ __forceinline__ static float max() { return 1.f; } __device__ __forceinline__ static float half() { return 0.5f; } }; template <typename T> __device__ __forceinline__ void setAlpha(typename MakeVec<T, 3>::type& vec, T val) { } template <typename T> __device__ __forceinline__ void setAlpha(typename MakeVec<T, 4>::type& vec, T val) { vec.w = val; } template <typename T> __device__ __forceinline__ T getAlpha(const typename MakeVec<T, 3>::type& vec) { return ColorChannel<T>::max(); } template <typename T> __device__ __forceinline__ T getAlpha(const typename MakeVec<T, 4>::type& vec) { return vec.w; } enum { rgb_shift = 15, yuv_shift = 14, xyz_shift = 12, R2Y = 4899, G2Y = 9617, B2Y = 1868, RY15 = 9798, GY15 = 19235, BY15 = 3735, BLOCK_SIZE = 256 }; // Various 3/4-channel to 3/4-channel RGB transformations template <typename T, int scn, int dcn, int bidx> struct RGB2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { typename MakeVec<T, dcn>::type dst; dst.x = bidx == 0 ? src.x : src.z; dst.y = src.y; dst.z = bidx == 0 ? src.z : src.x; setAlpha(dst, getAlpha<T>(src)); return dst; } }; // 24/32-bit RGB to 16-bit (565 or 555) RGB template <int scn, int bidx, int green_bits> struct RGB2RGB5x5; template <int scn, int bidx> struct RGB2RGB5x5<scn, bidx, 6> : unary_function<typename MakeVec<uchar, scn>::type, ushort> { __device__ ushort operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (ushort) ((b >> 3) | ((g & ~3) << 3) | ((r & ~7) << 8)); } }; template <int bidx> struct RGB2RGB5x5<3, bidx, 5> : unary_function<uchar3, ushort> { __device__ ushort operator ()(const uchar3& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (ushort) ((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7)); } }; template <int bidx> struct RGB2RGB5x5<4, bidx, 5> : unary_function<uchar4, ushort> { __device__ ushort operator ()(const uchar4& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int a = src.w; return (ushort) ((b >> 3) | ((g & ~7) << 2) | ((r & ~7) << 7) | (a ? 0x8000 : 0)); } }; // 16-bit (565 or 555) RGB to 24/32-bit RGB template <int dcn, int bidx, int green_bits> struct RGB5x52RGB; template <int bidx> struct RGB5x52RGB<3, bidx, 5> : unary_function<ushort, uchar3> { __device__ uchar3 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 7) & ~7; uchar3 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 2) & ~7; dst.z = bidx == 0 ? r : b; return dst; } }; template <int bidx> struct RGB5x52RGB<4, bidx, 5> : unary_function<ushort, uchar4> { __device__ uchar4 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 7) & ~7; uchar4 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 2) & ~7; dst.z = bidx == 0 ? r : b; dst.w = (src & 0x8000) * 0xffu; return dst; } }; template <int bidx> struct RGB5x52RGB<3, bidx, 6> : unary_function<ushort, uchar3> { __device__ uchar3 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 8) & ~7; uchar3 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 3) & ~3; dst.z = bidx == 0 ? r : b; return dst; } }; template <int bidx> struct RGB5x52RGB<4, bidx, 6> : unary_function<ushort, uchar4> { __device__ uchar4 operator ()(ushort src) const { const int b = src << 3; const int r = (src >> 8) & ~7; uchar4 dst; dst.x = bidx == 0 ? b : r; dst.y = (src >> 3) & ~3; dst.z = bidx == 0 ? r : b; dst.w = 255; return dst; } }; // Grayscale to RGB template <typename T, int dcn> struct Gray2RGB : unary_function<T, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(T src) const { typename MakeVec<T, dcn>::type dst; dst.z = dst.y = dst.x = src; setAlpha(dst, ColorChannel<T>::max()); return dst; } }; // Grayscale to 16-bit (565 or 555) RGB template <int green_bits> struct Gray2RGB5x5; template <> struct Gray2RGB5x5<5> : unary_function<uchar, ushort> { __device__ ushort operator ()(uchar src) const { const int t = src >> 3; return (ushort)(t | (t << 5) | (t << 10)); } }; template <> struct Gray2RGB5x5<6> : unary_function<uchar, ushort> { __device__ ushort operator ()(uchar src) const { const int t = src; return (ushort)((t >> 3) | ((t & ~3) << 3) | ((t & ~7) << 8)); } }; // 16-bit (565 or 555) RGB to Grayscale template <int green_bits> struct RGB5x52Gray; template <> struct RGB5x52Gray<5> : unary_function<ushort, uchar> { __device__ uchar operator ()(ushort src) const { return (uchar) CV_CUDEV_DESCALE(((src << 3) & 0xf8) * B2Y + ((src >> 2) & 0xf8) * G2Y + ((src >> 7) & 0xf8) * R2Y, yuv_shift); } }; template <> struct RGB5x52Gray<6> : unary_function<ushort, uchar> { __device__ uchar operator ()(ushort src) const { return (uchar) CV_CUDEV_DESCALE(((src << 3) & 0xf8) * B2Y + ((src >> 3) & 0xfc) * G2Y + ((src >> 8) & 0xf8) * R2Y, yuv_shift); } }; // RGB to Grayscale template <typename T, int scn, int bidx> struct RGB2Gray : unary_function<typename MakeVec<T, scn>::type, T> { __device__ T operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (T) CV_CUDEV_DESCALE(b * B2Y + g * G2Y + r * R2Y, yuv_shift); } }; template <int scn, int bidx> struct RGB2Gray<uchar, scn, bidx> : unary_function<typename MakeVec<uchar, scn>::type, uchar> { __device__ uchar operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; return (uchar)CV_CUDEV_DESCALE(b * BY15 + g * GY15 + r * RY15, rgb_shift); } }; template <int scn, int bidx> struct RGB2Gray<float, scn, bidx> : unary_function<typename MakeVec<float, scn>::type, float> { __device__ float operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; return b * 0.114f + g * 0.587f + r * 0.299f; } }; // RGB to YUV static __constant__ float c_RGB2YUVCoeffs_f[5] = { 0.114f, 0.587f, 0.299f, 0.492f, 0.877f }; static __constant__ int c_RGB2YUVCoeffs_i[5] = { B2Y, G2Y, R2Y, 8061, 14369 }; template <typename T, int scn, int dcn, int bidx> struct RGB2YUV : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int delta = ColorChannel<T>::half() * (1 << yuv_shift); const int Y = CV_CUDEV_DESCALE(b * c_RGB2YUVCoeffs_i[0] + g * c_RGB2YUVCoeffs_i[1] + r * c_RGB2YUVCoeffs_i[2], yuv_shift); const int Cb = CV_CUDEV_DESCALE((b - Y) * c_RGB2YUVCoeffs_i[3] + delta, yuv_shift); const int Cr = CV_CUDEV_DESCALE((r - Y) * c_RGB2YUVCoeffs_i[4] + delta, yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(Y); dst.y = saturate_cast<T>(Cb); dst.z = saturate_cast<T>(Cr); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2YUV<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = b * c_RGB2YUVCoeffs_f[0] + g * c_RGB2YUVCoeffs_f[1] + r * c_RGB2YUVCoeffs_f[2]; dst.y = (b - dst.x) * c_RGB2YUVCoeffs_f[3] + ColorChannel<float>::half(); dst.z = (r - dst.x) * c_RGB2YUVCoeffs_f[4] + ColorChannel<float>::half(); return dst; } }; // YUV to RGB static __constant__ float c_YUV2RGBCoeffs_f[5] = { 2.032f, -0.395f, -0.581f, 1.140f }; static __constant__ int c_YUV2RGBCoeffs_i[5] = { 33292, -6472, -9519, 18678 }; template <typename T, int scn, int dcn, int bidx> struct YUV2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int r = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[3], yuv_shift); const int g = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[2] + (src.y - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[1], yuv_shift); const int b = src.x + CV_CUDEV_DESCALE((src.y - ColorChannel<T>::half()) * c_YUV2RGBCoeffs_i[0], yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct YUV2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float r = src.x + (src.z - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[3]; const float g = src.x + (src.z - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[2] + (src.y - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[1]; const float b = src.x + (src.y - ColorChannel<float>::half()) * c_YUV2RGBCoeffs_f[0]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to YCrCb static __constant__ float c_RGB2YCrCbCoeffs_f[5] = { 0.299f, 0.587f, 0.114f, 0.713f, 0.564f }; static __constant__ int c_RGB2YCrCbCoeffs_i[5] = { R2Y, G2Y, B2Y, 11682, 9241 }; template <typename T, int scn, int dcn, int bidx> struct RGB2YCrCb : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; const int delta = ColorChannel<T>::half() * (1 << yuv_shift); const int Y = CV_CUDEV_DESCALE(b * c_RGB2YCrCbCoeffs_i[2] + g * c_RGB2YCrCbCoeffs_i[1] + r * c_RGB2YCrCbCoeffs_i[0], yuv_shift); const int Cr = CV_CUDEV_DESCALE((r - Y) * c_RGB2YCrCbCoeffs_i[3] + delta, yuv_shift); const int Cb = CV_CUDEV_DESCALE((b - Y) * c_RGB2YCrCbCoeffs_i[4] + delta, yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(Y); dst.y = saturate_cast<T>(Cr); dst.z = saturate_cast<T>(Cb); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2YCrCb<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = b * c_RGB2YCrCbCoeffs_f[2] + g * c_RGB2YCrCbCoeffs_f[1] + r * c_RGB2YCrCbCoeffs_f[0]; dst.y = (r - dst.x) * c_RGB2YCrCbCoeffs_f[3] + ColorChannel<float>::half(); dst.z = (b - dst.x) * c_RGB2YCrCbCoeffs_f[4] + ColorChannel<float>::half(); return dst; } }; // YCrCb to RGB static __constant__ float c_YCrCb2RGBCoeffs_f[5] = {1.403f, -0.714f, -0.344f, 1.773f}; static __constant__ int c_YCrCb2RGBCoeffs_i[5] = {22987, -11698, -5636, 29049}; template <typename T, int scn, int dcn, int bidx> struct YCrCb2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[3], yuv_shift); const int g = src.x + CV_CUDEV_DESCALE((src.z - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[2] + (src.y - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[1], yuv_shift); const int r = src.x + CV_CUDEV_DESCALE((src.y - ColorChannel<T>::half()) * c_YCrCb2RGBCoeffs_i[0], yuv_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct YCrCb2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = src.x + (src.z - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[3]; const float g = src.x + (src.z - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[2] + (src.y - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[1]; const float r = src.x + (src.y - ColorChannel<float>::half()) * c_YCrCb2RGBCoeffs_f[0]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to XYZ static __constant__ float c_RGB2XYZ_D65f[9] = { 0.412453f, 0.357580f, 0.180423f, 0.212671f, 0.715160f, 0.072169f, 0.019334f, 0.119193f, 0.950227f }; static __constant__ int c_RGB2XYZ_D65i[9] = { 1689, 1465, 739, 871, 2929, 296, 79, 488, 3892 }; template <typename T, int scn, int dcn, int bidx> struct RGB2XYZ : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; typename MakeVec<T, dcn>::type dst; dst.z = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[6] + g * c_RGB2XYZ_D65i[7] + b * c_RGB2XYZ_D65i[8], xyz_shift)); dst.x = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[0] + g * c_RGB2XYZ_D65i[1] + b * c_RGB2XYZ_D65i[2], xyz_shift)); dst.y = saturate_cast<T>(CV_CUDEV_DESCALE(r * c_RGB2XYZ_D65i[3] + g * c_RGB2XYZ_D65i[4] + b * c_RGB2XYZ_D65i[5], xyz_shift)); return dst; } }; template <int scn, int dcn, int bidx> struct RGB2XYZ<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; typename MakeVec<float, dcn>::type dst; dst.x = r * c_RGB2XYZ_D65f[0] + g * c_RGB2XYZ_D65f[1] + b * c_RGB2XYZ_D65f[2]; dst.y = r * c_RGB2XYZ_D65f[3] + g * c_RGB2XYZ_D65f[4] + b * c_RGB2XYZ_D65f[5]; dst.z = r * c_RGB2XYZ_D65f[6] + g * c_RGB2XYZ_D65f[7] + b * c_RGB2XYZ_D65f[8]; return dst; } }; // XYZ to RGB static __constant__ float c_XYZ2sRGB_D65f[9] = { 3.240479f, -1.53715f, -0.498535f, -0.969256f, 1.875991f, 0.041556f, 0.055648f, -0.204043f, 1.057311f }; static __constant__ int c_XYZ2sRGB_D65i[9] = { 13273, -6296, -2042, -3970, 7684, 170, 228, -836, 4331 }; template <typename T, int scn, int dcn, int bidx> struct XYZ2RGB : unary_function<typename MakeVec<T, scn>::type, typename MakeVec<T, dcn>::type> { __device__ typename MakeVec<T, dcn>::type operator ()(const typename MakeVec<T, scn>::type& src) const { const int b = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[6] + src.y * c_XYZ2sRGB_D65i[7] + src.z * c_XYZ2sRGB_D65i[8], xyz_shift); const int g = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[3] + src.y * c_XYZ2sRGB_D65i[4] + src.z * c_XYZ2sRGB_D65i[5], xyz_shift); const int r = CV_CUDEV_DESCALE(src.x * c_XYZ2sRGB_D65i[0] + src.y * c_XYZ2sRGB_D65i[1] + src.z * c_XYZ2sRGB_D65i[2], xyz_shift); typename MakeVec<T, dcn>::type dst; dst.x = saturate_cast<T>(bidx == 0 ? b : r); dst.y = saturate_cast<T>(g); dst.z = saturate_cast<T>(bidx == 0 ? r : b); setAlpha(dst, ColorChannel<T>::max()); return dst; } }; template <int scn, int dcn, int bidx> struct XYZ2RGB<float, scn, dcn, bidx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float b = src.x * c_XYZ2sRGB_D65f[6] + src.y * c_XYZ2sRGB_D65f[7] + src.z * c_XYZ2sRGB_D65f[8]; const float g = src.x * c_XYZ2sRGB_D65f[3] + src.y * c_XYZ2sRGB_D65f[4] + src.z * c_XYZ2sRGB_D65f[5]; const float r = src.x * c_XYZ2sRGB_D65f[0] + src.y * c_XYZ2sRGB_D65f[1] + src.z * c_XYZ2sRGB_D65f[2]; typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; // RGB to HSV static __constant__ int c_HsvDivTable [256] = {0, 1044480, 522240, 348160, 261120, 208896, 174080, 149211, 130560, 116053, 104448, 94953, 87040, 80345, 74606, 69632, 65280, 61440, 58027, 54973, 52224, 49737, 47476, 45412, 43520, 41779, 40172, 38684, 37303, 36017, 34816, 33693, 32640, 31651, 30720, 29842, 29013, 28229, 27486, 26782, 26112, 25475, 24869, 24290, 23738, 23211, 22706, 22223, 21760, 21316, 20890, 20480, 20086, 19707, 19342, 18991, 18651, 18324, 18008, 17703, 17408, 17123, 16846, 16579, 16320, 16069, 15825, 15589, 15360, 15137, 14921, 14711, 14507, 14308, 14115, 13926, 13743, 13565, 13391, 13221, 13056, 12895, 12738, 12584, 12434, 12288, 12145, 12006, 11869, 11736, 11605, 11478, 11353, 11231, 11111, 10995, 10880, 10768, 10658, 10550, 10445, 10341, 10240, 10141, 10043, 9947, 9854, 9761, 9671, 9582, 9495, 9410, 9326, 9243, 9162, 9082, 9004, 8927, 8852, 8777, 8704, 8632, 8561, 8492, 8423, 8356, 8290, 8224, 8160, 8097, 8034, 7973, 7913, 7853, 7795, 7737, 7680, 7624, 7569, 7514, 7461, 7408, 7355, 7304, 7253, 7203, 7154, 7105, 7057, 7010, 6963, 6917, 6872, 6827, 6782, 6739, 6695, 6653, 6611, 6569, 6528, 6487, 6447, 6408, 6369, 6330, 6292, 6254, 6217, 6180, 6144, 6108, 6073, 6037, 6003, 5968, 5935, 5901, 5868, 5835, 5803, 5771, 5739, 5708, 5677, 5646, 5615, 5585, 5556, 5526, 5497, 5468, 5440, 5412, 5384, 5356, 5329, 5302, 5275, 5249, 5222, 5196, 5171, 5145, 5120, 5095, 5070, 5046, 5022, 4998, 4974, 4950, 4927, 4904, 4881, 4858, 4836, 4813, 4791, 4769, 4748, 4726, 4705, 4684, 4663, 4642, 4622, 4601, 4581, 4561, 4541, 4522, 4502, 4483, 4464, 4445, 4426, 4407, 4389, 4370, 4352, 4334, 4316, 4298, 4281, 4263, 4246, 4229, 4212, 4195, 4178, 4161, 4145, 4128, 4112, 4096}; static __constant__ int c_HsvDivTable180[256] = {0, 122880, 61440, 40960, 30720, 24576, 20480, 17554, 15360, 13653, 12288, 11171, 10240, 9452, 8777, 8192, 7680, 7228, 6827, 6467, 6144, 5851, 5585, 5343, 5120, 4915, 4726, 4551, 4389, 4237, 4096, 3964, 3840, 3724, 3614, 3511, 3413, 3321, 3234, 3151, 3072, 2997, 2926, 2858, 2793, 2731, 2671, 2614, 2560, 2508, 2458, 2409, 2363, 2318, 2276, 2234, 2194, 2156, 2119, 2083, 2048, 2014, 1982, 1950, 1920, 1890, 1862, 1834, 1807, 1781, 1755, 1731, 1707, 1683, 1661, 1638, 1617, 1596, 1575, 1555, 1536, 1517, 1499, 1480, 1463, 1446, 1429, 1412, 1396, 1381, 1365, 1350, 1336, 1321, 1307, 1293, 1280, 1267, 1254, 1241, 1229, 1217, 1205, 1193, 1182, 1170, 1159, 1148, 1138, 1127, 1117, 1107, 1097, 1087, 1078, 1069, 1059, 1050, 1041, 1033, 1024, 1016, 1007, 999, 991, 983, 975, 968, 960, 953, 945, 938, 931, 924, 917, 910, 904, 897, 890, 884, 878, 871, 865, 859, 853, 847, 842, 836, 830, 825, 819, 814, 808, 803, 798, 793, 788, 783, 778, 773, 768, 763, 759, 754, 749, 745, 740, 736, 731, 727, 723, 719, 714, 710, 706, 702, 698, 694, 690, 686, 683, 679, 675, 671, 668, 664, 661, 657, 654, 650, 647, 643, 640, 637, 633, 630, 627, 624, 621, 617, 614, 611, 608, 605, 602, 599, 597, 594, 591, 588, 585, 582, 580, 577, 574, 572, 569, 566, 564, 561, 559, 556, 554, 551, 549, 546, 544, 541, 539, 537, 534, 532, 530, 527, 525, 523, 521, 518, 516, 514, 512, 510, 508, 506, 504, 502, 500, 497, 495, 493, 492, 490, 488, 486, 484, 482}; static __constant__ int c_HsvDivTable256[256] = {0, 174763, 87381, 58254, 43691, 34953, 29127, 24966, 21845, 19418, 17476, 15888, 14564, 13443, 12483, 11651, 10923, 10280, 9709, 9198, 8738, 8322, 7944, 7598, 7282, 6991, 6722, 6473, 6242, 6026, 5825, 5638, 5461, 5296, 5140, 4993, 4855, 4723, 4599, 4481, 4369, 4263, 4161, 4064, 3972, 3884, 3799, 3718, 3641, 3567, 3495, 3427, 3361, 3297, 3236, 3178, 3121, 3066, 3013, 2962, 2913, 2865, 2819, 2774, 2731, 2689, 2648, 2608, 2570, 2533, 2497, 2461, 2427, 2394, 2362, 2330, 2300, 2270, 2241, 2212, 2185, 2158, 2131, 2106, 2081, 2056, 2032, 2009, 1986, 1964, 1942, 1920, 1900, 1879, 1859, 1840, 1820, 1802, 1783, 1765, 1748, 1730, 1713, 1697, 1680, 1664, 1649, 1633, 1618, 1603, 1589, 1574, 1560, 1547, 1533, 1520, 1507, 1494, 1481, 1469, 1456, 1444, 1432, 1421, 1409, 1398, 1387, 1376, 1365, 1355, 1344, 1334, 1324, 1314, 1304, 1295, 1285, 1276, 1266, 1257, 1248, 1239, 1231, 1222, 1214, 1205, 1197, 1189, 1181, 1173, 1165, 1157, 1150, 1142, 1135, 1128, 1120, 1113, 1106, 1099, 1092, 1085, 1079, 1072, 1066, 1059, 1053, 1046, 1040, 1034, 1028, 1022, 1016, 1010, 1004, 999, 993, 987, 982, 976, 971, 966, 960, 955, 950, 945, 940, 935, 930, 925, 920, 915, 910, 906, 901, 896, 892, 887, 883, 878, 874, 869, 865, 861, 857, 853, 848, 844, 840, 836, 832, 828, 824, 820, 817, 813, 809, 805, 802, 798, 794, 791, 787, 784, 780, 777, 773, 770, 767, 763, 760, 757, 753, 750, 747, 744, 741, 737, 734, 731, 728, 725, 722, 719, 716, 713, 710, 708, 705, 702, 699, 696, 694, 691, 688, 685}; template <typename T, int scn, int dcn, int bidx, int hr> struct RGB2HSV; template <int scn, int dcn, int bidx, int hr> struct RGB2HSV<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int hsv_shift = 12; const int* hdiv_table = hr == 180 ? c_HsvDivTable180 : c_HsvDivTable256; const int b = bidx == 0 ? src.x : src.z; const int g = src.y; const int r = bidx == 0 ? src.z : src.x; int h, s, v = b; int vmin = b, diff; int vr, vg; v = ::max(v, g); v = ::max(v, r); vmin = ::min(vmin, g); vmin = ::min(vmin, r); diff = v - vmin; vr = (v == r) * -1; vg = (v == g) * -1; s = (diff * c_HsvDivTable[v] + (1 << (hsv_shift-1))) >> hsv_shift; h = (vr & (g - b)) + (~vr & ((vg & (b - r + 2 * diff)) + ((~vg) & (r - g + 4 * diff)))); h = (h * hdiv_table[diff] + (1 << (hsv_shift-1))) >> hsv_shift; h += (h < 0) * hr; typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(h); dst.y = saturate_cast<uchar>(s); dst.z = saturate_cast<uchar>(v); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct RGB2HSV<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = hr * (1.f / 360.f); const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; float h, s, v; float vmin, diff; v = vmin = r; v = ::fmax(v, g); v = ::fmax(v, b); vmin = ::fmin(vmin, g); vmin = ::fmin(vmin, b); diff = v - vmin; s = diff / (float)(::fabs(v) + numeric_limits<float>::epsilon()); diff = (float)(60. / (diff + numeric_limits<float>::epsilon())); h = (v == r) * (g - b) * diff; h += (v != r && v == g) * ((b - r) * diff + 120.f); h += (v != r && v != g) * ((r - g) * diff + 240.f); h += (h < 0) * 360.f; typename MakeVec<float, dcn>::type dst; dst.x = h * hscale; dst.y = s; dst.z = v; return dst; } }; // HSV to RGB static __constant__ int c_HsvSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; template <typename T, int scn, int dcn, int bidx, int hr> struct HSV2RGB; template <int scn, int dcn, int bidx, int hr> struct HSV2RGB<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = 6.f / hr; float h = src.x, s = src.y, v = src.z; float b = v, g = v, r = v; if (s != 0) { h *= hscale; if( h < 0 ) do h += 6; while( h < 0 ); else if( h >= 6 ) do h -= 6; while( h >= 6 ); int sector = __float2int_rd(h); h -= sector; if ( (unsigned)sector >= 6u ) { sector = 0; h = 0.f; } float tab[4]; tab[0] = v; tab[1] = v * (1.f - s); tab[2] = v * (1.f - s * h); tab[3] = v * (1.f - s * (1.f - h)); b = tab[c_HsvSectorData[sector][0]]; g = tab[c_HsvSectorData[sector][1]]; r = tab[c_HsvSectorData[sector][2]]; } typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct HSV2RGB<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x; buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); HSV2RGB<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to HLS template <typename T, int scn, int dcn, int bidx, int hr> struct RGB2HLS; template <int scn, int dcn, int bidx, int hr> struct RGB2HLS<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = hr * (1.f / 360.f); const float b = bidx == 0 ? src.x : src.z; const float g = src.y; const float r = bidx == 0 ? src.z : src.x; float h = 0.f, s = 0.f, l; float vmin, vmax, diff; vmax = vmin = r; vmax = ::fmax(vmax, g); vmax = ::fmax(vmax, b); vmin = ::fmin(vmin, g); vmin = ::fmin(vmin, b); diff = vmax - vmin; l = (vmax + vmin) * 0.5f; if (diff > numeric_limits<float>::epsilon()) { s = l < 0.5f ? diff / (vmax + vmin) : diff / (2 - vmax - vmin); diff = 60.f / diff; h = (vmax == r) * (g - b) * diff; h += (vmax != r && vmax == g) * ((b - r) * diff + 120.f); h += (vmax != r && vmax != g) * ((r - g) * diff + 240.f); h += (h < 0.f) * 360.f; } typename MakeVec<float, dcn>::type dst; dst.x = h * hscale; dst.y = l; dst.z = s; return dst; } }; template <int scn, int dcn, int bidx, int hr> struct RGB2HLS<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (1.f / 255.f); buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); RGB2HLS<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); return dst; } }; // HLS to RGB static __constant__ int c_HlsSectorData[6][3] = { {1,3,0}, {1,0,2}, {3,0,1}, {0,2,1}, {0,1,3}, {2,1,0} }; template <typename T, int scn, int dcn, int bidx, int hr> struct HLS2RGB; template <int scn, int dcn, int bidx, int hr> struct HLS2RGB<float, scn, dcn, bidx, hr> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float hscale = 6.0f / hr; float h = src.x, l = src.y, s = src.z; float b = l, g = l, r = l; if (s != 0) { float p2 = (l <= 0.5f) * l * (1 + s); p2 += (l > 0.5f) * (l + s - l * s); float p1 = 2 * l - p2; h *= hscale; if( h < 0 ) do h += 6; while( h < 0 ); else if( h >= 6 ) do h -= 6; while( h >= 6 ); int sector; sector = __float2int_rd(h); h -= sector; float tab[4]; tab[0] = p2; tab[1] = p1; tab[2] = p1 + (p2 - p1) * (1 - h); tab[3] = p1 + (p2 - p1) * h; b = tab[c_HlsSectorData[sector][0]]; g = tab[c_HlsSectorData[sector][1]]; r = tab[c_HlsSectorData[sector][2]]; } typename MakeVec<float, dcn>::type dst; dst.x = bidx == 0 ? b : r; dst.y = g; dst.z = bidx == 0 ? r : b; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, int bidx, int hr> struct HLS2RGB<uchar, scn, dcn, bidx, hr> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x; buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); HLS2RGB<float, 3, 3, bidx, hr> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to Lab enum { LAB_CBRT_TAB_SIZE = 1024, GAMMA_TAB_SIZE = 1024, lab_shift = xyz_shift, gamma_shift = 3, lab_shift2 = (lab_shift + gamma_shift), LAB_CBRT_TAB_SIZE_B = (256 * 3 / 2 * (1 << gamma_shift)) }; static __constant__ ushort c_sRGBGammaTab_b[] = {0,1,1,2,2,3,4,4,5,6,6,7,8,8,9,10,11,11,12,13,14,15,16,17,19,20,21,22,24,25,26,28,29,31,33,34,36,38,40,41,43,45,47,49,51,54,56,58,60,63,65,68,70,73,75,78,81,83,86,89,92,95,98,101,105,108,111,115,118,121,125,129,132,136,140,144,147,151,155,160,164,168,172,176,181,185,190,194,199,204,209,213,218,223,228,233,239,244,249,255,260,265,271,277,282,288,294,300,306,312,318,324,331,337,343,350,356,363,370,376,383,390,397,404,411,418,426,433,440,448,455,463,471,478,486,494,502,510,518,527,535,543,552,560,569,578,586,595,604,613,622,631,641,650,659,669,678,688,698,707,717,727,737,747,757,768,778,788,799,809,820,831,842,852,863,875,886,897,908,920,931,943,954,966,978,990,1002,1014,1026,1038,1050,1063,1075,1088,1101,1113,1126,1139,1152,1165,1178,1192,1205,1218,1232,1245,1259,1273,1287,1301,1315,1329,1343,1357,1372,1386,1401,1415,1430,1445,1460,1475,1490,1505,1521,1536,1551,1567,1583,1598,1614,1630,1646,1662,1678,1695,1711,1728,1744,1761,1778,1794,1811,1828,1846,1863,1880,1897,1915,1933,1950,1968,1986,2004,2022,2040}; static __constant__ float c_sRGBGammaTab[] = {0,7.55853e-05,0.,-7.51331e-13,7.55853e-05,7.55853e-05,-2.25399e-12,3.75665e-12,0.000151171,7.55853e-05,9.01597e-12,-6.99932e-12,0.000226756,7.55853e-05,-1.1982e-11,2.41277e-12,0.000302341,7.55853e-05,-4.74369e-12,1.19001e-11,0.000377927,7.55853e-05,3.09568e-11,-2.09095e-11,0.000453512,7.55853e-05,-3.17718e-11,1.35303e-11,0.000529097,7.55853e-05,8.81905e-12,-4.10782e-12,0.000604683,7.55853e-05,-3.50439e-12,2.90097e-12,0.000680268,7.55853e-05,5.19852e-12,-7.49607e-12,0.000755853,7.55853e-05,-1.72897e-11,2.70833e-11,0.000831439,7.55854e-05,6.39602e-11,-4.26295e-11,0.000907024,7.55854e-05,-6.39282e-11,2.70193e-11,0.000982609,7.55853e-05,1.71298e-11,-7.24017e-12,0.00105819,7.55853e-05,-4.59077e-12,1.94137e-12,0.00113378,7.55853e-05,1.23333e-12,-5.25291e-13,0.00120937,7.55853e-05,-3.42545e-13,1.59799e-13,0.00128495,7.55853e-05,1.36852e-13,-1.13904e-13,0.00136054,7.55853e-05,-2.04861e-13,2.95818e-13,0.00143612,7.55853e-05,6.82594e-13,-1.06937e-12,0.00151171,7.55853e-05,-2.52551e-12,3.98166e-12,0.00158729,7.55853e-05,9.41946e-12,-1.48573e-11,0.00166288,7.55853e-05,-3.51523e-11,5.54474e-11,0.00173846,7.55854e-05,1.3119e-10,-9.0517e-11,0.00181405,7.55854e-05,-1.40361e-10,7.37899e-11,0.00188963,7.55853e-05,8.10085e-11,-8.82272e-11,0.00196522,7.55852e-05,-1.83673e-10,1.62704e-10,0.0020408,7.55853e-05,3.04438e-10,-2.13341e-10,0.00211639,7.55853e-05,-3.35586e-10,2.25e-10,0.00219197,7.55853e-05,3.39414e-10,-2.20997e-10,0.00226756,7.55853e-05,-3.23576e-10,1.93326e-10,0.00234315,7.55853e-05,2.564e-10,-8.66446e-11,0.00241873,7.55855e-05,-3.53328e-12,-7.9578e-11,0.00249432,7.55853e-05,-2.42267e-10,1.72126e-10,0.0025699,7.55853e-05,2.74111e-10,-1.43265e-10,0.00264549,7.55854e-05,-1.55683e-10,-6.47292e-11,0.00272107,7.55849e-05,-3.4987e-10,8.67842e-10,0.00279666,7.55868e-05,2.25366e-09,-3.8723e-09,0.00287224,7.55797e-05,-9.36325e-09,1.5087e-08,0.00294783,7.56063e-05,3.58978e-08,-5.69415e-08,0.00302341,7.55072e-05,-1.34927e-07,2.13144e-07,0.003099,7.58768e-05,5.04507e-07,1.38713e-07,0.00317552,7.7302e-05,9.20646e-07,-1.55186e-07,0.00325359,7.86777e-05,4.55087e-07,4.26813e-08,0.00333276,7.97159e-05,5.83131e-07,-1.06495e-08,0.00341305,8.08502e-05,5.51182e-07,3.87467e-09,0.00349446,8.19642e-05,5.62806e-07,-1.92586e-10,0.00357698,8.30892e-05,5.62228e-07,1.0866e-09,0.00366063,8.4217e-05,5.65488e-07,5.02818e-10,0.00374542,8.53494e-05,5.66997e-07,8.60211e-10,0.00383133,8.6486e-05,5.69577e-07,7.13044e-10,0.00391839,8.76273e-05,5.71716e-07,4.78527e-10,0.00400659,8.87722e-05,5.73152e-07,1.09818e-09,0.00409594,8.99218e-05,5.76447e-07,2.50964e-10,0.00418644,9.10754e-05,5.772e-07,1.15762e-09,0.00427809,9.22333e-05,5.80672e-07,2.40865e-10,0.0043709,9.33954e-05,5.81395e-07,1.13854e-09,0.00446488,9.45616e-05,5.84811e-07,3.27267e-10,0.00456003,9.57322e-05,5.85792e-07,8.1197e-10,0.00465635,9.69062e-05,5.88228e-07,6.15823e-10,0.00475384,9.80845e-05,5.90076e-07,9.15747e-10,0.00485252,9.92674e-05,5.92823e-07,3.778e-10,0.00495238,0.000100454,5.93956e-07,8.32623e-10,0.00505343,0.000101645,5.96454e-07,4.82695e-10,0.00515567,0.000102839,5.97902e-07,9.61904e-10,0.00525911,0.000104038,6.00788e-07,3.26281e-10,0.00536375,0.00010524,6.01767e-07,9.926e-10,0.00546959,0.000106447,6.04745e-07,3.59933e-10,0.00557664,0.000107657,6.05824e-07,8.2728e-10,0.0056849,0.000108871,6.08306e-07,5.21898e-10,0.00579438,0.00011009,6.09872e-07,8.10492e-10,0.00590508,0.000111312,6.12303e-07,4.27046e-10,0.00601701,0.000112538,6.13585e-07,7.40878e-10,0.00613016,0.000113767,6.15807e-07,8.00469e-10,0.00624454,0.000115001,6.18209e-07,2.48178e-10,0.00636016,0.000116238,6.18953e-07,1.00073e-09,0.00647702,0.000117479,6.21955e-07,4.05654e-10,0.00659512,0.000118724,6.23172e-07,6.36192e-10,0.00671447,0.000119973,6.25081e-07,7.74927e-10,0.00683507,0.000121225,6.27406e-07,4.54975e-10,0.00695692,0.000122481,6.28771e-07,6.64841e-10,0.00708003,0.000123741,6.30765e-07,6.10972e-10,0.00720441,0.000125004,6.32598e-07,6.16543e-10,0.00733004,0.000126271,6.34448e-07,6.48204e-10,0.00745695,0.000127542,6.36392e-07,5.15835e-10,0.00758513,0.000128816,6.3794e-07,5.48103e-10,0.00771458,0.000130094,6.39584e-07,1.01706e-09,0.00784532,0.000131376,6.42635e-07,4.0283e-11,0.00797734,0.000132661,6.42756e-07,6.84471e-10,0.00811064,0.000133949,6.4481e-07,9.47144e-10,0.00824524,0.000135241,6.47651e-07,1.83472e-10,0.00838112,0.000136537,6.48201e-07,1.11296e-09,0.00851831,0.000137837,6.5154e-07,2.13163e-11,0.0086568,0.00013914,6.51604e-07,6.64462e-10,0.00879659,0.000140445,6.53598e-07,1.04613e-09,0.00893769,0.000141756,6.56736e-07,-1.92377e-10,0.0090801,0.000143069,6.56159e-07,1.58601e-09,0.00922383,0.000144386,6.60917e-07,-5.63754e-10,0.00936888,0.000145706,6.59226e-07,1.60033e-09,0.00951524,0.000147029,6.64027e-07,-2.49543e-10,0.00966294,0.000148356,6.63278e-07,1.26043e-09,0.00981196,0.000149687,6.67059e-07,-1.35572e-10,0.00996231,0.00015102,6.66653e-07,1.14458e-09,0.010114,0.000152357,6.70086e-07,2.13864e-10,0.010267,0.000153698,6.70728e-07,7.93856e-10,0.0104214,0.000155042,6.73109e-07,3.36077e-10,0.0105771,0.000156389,6.74118e-07,6.55765e-10,0.0107342,0.000157739,6.76085e-07,7.66211e-10,0.0108926,0.000159094,6.78384e-07,4.66116e-12,0.0110524,0.000160451,6.78398e-07,1.07775e-09,0.0112135,0.000161811,6.81631e-07,3.41023e-10,0.011376,0.000163175,6.82654e-07,3.5205e-10,0.0115398,0.000164541,6.8371e-07,1.04473e-09,0.0117051,0.000165912,6.86844e-07,1.25757e-10,0.0118717,0.000167286,6.87222e-07,3.14818e-10,0.0120396,0.000168661,6.88166e-07,1.40886e-09,0.012209,0.000170042,6.92393e-07,-3.62244e-10,0.0123797,0.000171425,6.91306e-07,9.71397e-10,0.0125518,0.000172811,6.9422e-07,2.02003e-10,0.0127253,0.0001742,6.94826e-07,1.01448e-09,0.0129002,0.000175593,6.97869e-07,3.96653e-10,0.0130765,0.00017699,6.99059e-07,1.92927e-10,0.0132542,0.000178388,6.99638e-07,6.94305e-10,0.0134333,0.00017979,7.01721e-07,7.55108e-10,0.0136138,0.000181195,7.03986e-07,1.05918e-11,0.0137957,0.000182603,7.04018e-07,1.06513e-09,0.013979,0.000184015,7.07214e-07,3.85512e-10,0.0141637,0.00018543,7.0837e-07,1.86769e-10,0.0143499,0.000186848,7.0893e-07,7.30116e-10,0.0145374,0.000188268,7.11121e-07,6.17983e-10,0.0147264,0.000189692,7.12975e-07,5.23282e-10,0.0149168,0.000191119,7.14545e-07,8.28398e-11,0.0151087,0.000192549,7.14793e-07,1.0081e-09,0.0153019,0.000193981,7.17817e-07,5.41244e-10,0.0154966,0.000195418,7.19441e-07,-3.7907e-10,0.0156928,0.000196856,7.18304e-07,1.90641e-09,0.0158903,0.000198298,7.24023e-07,-7.27387e-10,0.0160893,0.000199744,7.21841e-07,1.00317e-09,0.0162898,0.000201191,7.24851e-07,4.39949e-10,0.0164917,0.000202642,7.2617e-07,9.6234e-10,0.0166951,0.000204097,7.29057e-07,-5.64019e-10,0.0168999,0.000205554,7.27365e-07,1.29374e-09,0.0171062,0.000207012,7.31247e-07,9.77025e-10,0.017314,0.000208478,7.34178e-07,-1.47651e-09,0.0175232,0.000209942,7.29748e-07,3.06636e-09,0.0177338,0.00021141,7.38947e-07,-1.47573e-09,0.017946,0.000212884,7.3452e-07,9.7386e-10,0.0181596,0.000214356,7.37442e-07,1.30562e-09,0.0183747,0.000215835,7.41358e-07,-6.08376e-10,0.0185913,0.000217315,7.39533e-07,1.12785e-09,0.0188093,0.000218798,7.42917e-07,-1.77711e-10,0.0190289,0.000220283,7.42384e-07,1.44562e-09,0.0192499,0.000221772,7.46721e-07,-1.68825e-11,0.0194724,0.000223266,7.4667e-07,4.84533e-10,0.0196964,0.000224761,7.48124e-07,-5.85298e-11,0.0199219,0.000226257,7.47948e-07,1.61217e-09,0.0201489,0.000227757,7.52785e-07,-8.02136e-10,0.0203775,0.00022926,7.50378e-07,1.59637e-09,0.0206075,0.000230766,7.55167e-07,4.47168e-12,0.020839,0.000232276,7.55181e-07,2.48387e-10,0.021072,0.000233787,7.55926e-07,8.6474e-10,0.0213066,0.000235302,7.5852e-07,1.78299e-11,0.0215426,0.000236819,7.58573e-07,9.26567e-10,0.0217802,0.000238339,7.61353e-07,1.34529e-12,0.0220193,0.000239862,7.61357e-07,9.30659e-10,0.0222599,0.000241387,7.64149e-07,1.34529e-12,0.0225021,0.000242915,7.64153e-07,9.26567e-10,0.0227458,0.000244447,7.66933e-07,1.76215e-11,0.022991,0.00024598,7.66986e-07,8.65536e-10,0.0232377,0.000247517,7.69582e-07,2.45677e-10,0.023486,0.000249057,7.70319e-07,1.44193e-11,0.0237358,0.000250598,7.70363e-07,1.55918e-09,0.0239872,0.000252143,7.7504e-07,-6.63173e-10,0.0242401,0.000253691,7.73051e-07,1.09357e-09,0.0244946,0.000255241,7.76331e-07,1.41919e-11,0.0247506,0.000256793,7.76374e-07,7.12248e-10,0.0250082,0.000258348,7.78511e-07,8.62049e-10,0.0252673,0.000259908,7.81097e-07,-4.35061e-10,0.025528,0.000261469,7.79792e-07,8.7825e-10,0.0257902,0.000263031,7.82426e-07,6.47181e-10,0.0260541,0.000264598,7.84368e-07,2.58448e-10,0.0263194,0.000266167,7.85143e-07,1.81558e-10,0.0265864,0.000267738,7.85688e-07,8.78041e-10,0.0268549,0.000269312,7.88322e-07,3.15102e-11,0.027125,0.000270889,7.88417e-07,8.58525e-10,0.0273967,0.000272468,7.90992e-07,2.59812e-10,0.02767,0.000274051,7.91772e-07,-3.5224e-11,0.0279448,0.000275634,7.91666e-07,1.74377e-09,0.0282212,0.000277223,7.96897e-07,-1.35196e-09,0.0284992,0.000278813,7.92841e-07,1.80141e-09,0.0287788,0.000280404,7.98246e-07,-2.65629e-10,0.0290601,0.000281999,7.97449e-07,1.12374e-09,0.0293428,0.000283598,8.0082e-07,-5.04106e-10,0.0296272,0.000285198,7.99308e-07,8.92764e-10,0.0299132,0.000286799,8.01986e-07,6.58379e-10,0.0302008,0.000288405,8.03961e-07,1.98971e-10,0.0304901,0.000290014,8.04558e-07,4.08382e-10,0.0307809,0.000291624,8.05783e-07,3.01839e-11,0.0310733,0.000293236,8.05874e-07,1.33343e-09,0.0313673,0.000294851,8.09874e-07,2.2419e-10,0.031663,0.000296472,8.10547e-07,-3.67606e-10,0.0319603,0.000298092,8.09444e-07,1.24624e-09,0.0322592,0.000299714,8.13182e-07,-8.92025e-10,0.0325597,0.000301338,8.10506e-07,2.32183e-09,0.0328619,0.000302966,8.17472e-07,-9.44719e-10,0.0331657,0.000304598,8.14638e-07,1.45703e-09,0.0334711,0.000306232,8.19009e-07,-1.15805e-09,0.0337781,0.000307866,8.15535e-07,3.17507e-09,0.0340868,0.000309507,8.2506e-07,-4.09161e-09,0.0343971,0.000311145,8.12785e-07,5.74079e-09,0.0347091,0.000312788,8.30007e-07,-3.97034e-09,0.0350227,0.000314436,8.18096e-07,2.68985e-09,0.035338,0.00031608,8.26166e-07,6.61676e-10,0.0356549,0.000317734,8.28151e-07,-1.61123e-09,0.0359734,0.000319386,8.23317e-07,2.05786e-09,0.0362936,0.000321038,8.29491e-07,8.30388e-10,0.0366155,0.0003227,8.31982e-07,-1.65424e-09,0.036939,0.000324359,8.27019e-07,2.06129e-09,0.0372642,0.000326019,8.33203e-07,8.59719e-10,0.0375911,0.000327688,8.35782e-07,-1.77488e-09,0.0379196,0.000329354,8.30458e-07,2.51464e-09,0.0382498,0.000331023,8.38002e-07,-8.33135e-10,0.0385817,0.000332696,8.35502e-07,8.17825e-10,0.0389152,0.00033437,8.37956e-07,1.28718e-09,0.0392504,0.00033605,8.41817e-07,-2.2413e-09,0.0395873,0.000337727,8.35093e-07,3.95265e-09,0.0399258,0.000339409,8.46951e-07,-2.39332e-09,0.0402661,0.000341095,8.39771e-07,1.89533e-09,0.040608,0.000342781,8.45457e-07,-1.46271e-09,0.0409517,0.000344467,8.41069e-07,3.95554e-09,0.041297,0.000346161,8.52936e-07,-3.18369e-09,0.041644,0.000347857,8.43385e-07,1.32873e-09,0.0419927,0.000349548,8.47371e-07,1.59402e-09,0.0423431,0.000351248,8.52153e-07,-2.54336e-10,0.0426952,0.000352951,8.5139e-07,-5.76676e-10,0.043049,0.000354652,8.4966e-07,2.56114e-09,0.0434045,0.000356359,8.57343e-07,-2.21744e-09,0.0437617,0.000358067,8.50691e-07,2.58344e-09,0.0441206,0.000359776,8.58441e-07,-6.65826e-10,0.0444813,0.000361491,8.56444e-07,7.99218e-11,0.0448436,0.000363204,8.56684e-07,3.46063e-10,0.0452077,0.000364919,8.57722e-07,2.26116e-09,0.0455734,0.000366641,8.64505e-07,-1.94005e-09,0.045941,0.000368364,8.58685e-07,1.77384e-09,0.0463102,0.000370087,8.64007e-07,-1.43005e-09,0.0466811,0.000371811,8.59717e-07,3.94634e-09,0.0470538,0.000373542,8.71556e-07,-3.17946e-09,0.0474282,0.000375276,8.62017e-07,1.32104e-09,0.0478043,0.000377003,8.6598e-07,1.62045e-09,0.0481822,0.00037874,8.70842e-07,-3.52297e-10,0.0485618,0.000380481,8.69785e-07,-2.11211e-10,0.0489432,0.00038222,8.69151e-07,1.19716e-09,0.0493263,0.000383962,8.72743e-07,-8.52026e-10,0.0497111,0.000385705,8.70187e-07,2.21092e-09,0.0500977,0.000387452,8.76819e-07,-5.41339e-10,0.050486,0.000389204,8.75195e-07,-4.5361e-11,0.0508761,0.000390954,8.75059e-07,7.22669e-10,0.0512679,0.000392706,8.77227e-07,8.79936e-10,0.0516615,0.000394463,8.79867e-07,-5.17048e-10,0.0520568,0.000396222,8.78316e-07,1.18833e-09,0.0524539,0.000397982,8.81881e-07,-5.11022e-10,0.0528528,0.000399744,8.80348e-07,8.55683e-10,0.0532534,0.000401507,8.82915e-07,8.13562e-10,0.0536558,0.000403276,8.85356e-07,-3.84603e-10,0.05406,0.000405045,8.84202e-07,7.24962e-10,0.0544659,0.000406816,8.86377e-07,1.20986e-09,0.0548736,0.000408592,8.90006e-07,-1.83896e-09,0.0552831,0.000410367,8.84489e-07,2.42071e-09,0.0556944,0.000412143,8.91751e-07,-3.93413e-10,0.0561074,0.000413925,8.90571e-07,-8.46967e-10,0.0565222,0.000415704,8.8803e-07,3.78122e-09,0.0569388,0.000417491,8.99374e-07,-3.1021e-09,0.0573572,0.000419281,8.90068e-07,1.17658e-09,0.0577774,0.000421064,8.93597e-07,2.12117e-09,0.0581993,0.000422858,8.99961e-07,-2.21068e-09,0.0586231,0.000424651,8.93329e-07,2.9961e-09,0.0590486,0.000426447,9.02317e-07,-2.32311e-09,0.059476,0.000428244,8.95348e-07,2.57122e-09,0.0599051,0.000430043,9.03062e-07,-5.11098e-10,0.0603361,0.000431847,9.01528e-07,-5.27166e-10,0.0607688,0.000433649,8.99947e-07,2.61984e-09,0.0612034,0.000435457,9.07806e-07,-2.50141e-09,0.0616397,0.000437265,9.00302e-07,3.66045e-09,0.0620779,0.000439076,9.11283e-07,-4.68977e-09,0.0625179,0.000440885,8.97214e-07,7.64783e-09,0.0629597,0.000442702,9.20158e-07,-7.27499e-09,0.0634033,0.000444521,8.98333e-07,6.55113e-09,0.0638487,0.000446337,9.17986e-07,-4.02844e-09,0.0642959,0.000448161,9.05901e-07,2.11196e-09,0.064745,0.000449979,9.12236e-07,3.03125e-09,0.0651959,0.000451813,9.2133e-07,-6.78648e-09,0.0656486,0.000453635,9.00971e-07,9.21375e-09,0.0661032,0.000455464,9.28612e-07,-7.71684e-09,0.0665596,0.000457299,9.05462e-07,6.7522e-09,0.0670178,0.00045913,9.25718e-07,-4.3907e-09,0.0674778,0.000460968,9.12546e-07,3.36e-09,0.0679397,0.000462803,9.22626e-07,-1.59876e-09,0.0684034,0.000464644,9.1783e-07,3.0351e-09,0.068869,0.000466488,9.26935e-07,-3.09101e-09,0.0693364,0.000468333,9.17662e-07,1.8785e-09,0.0698057,0.000470174,9.23298e-07,3.02733e-09,0.0702768,0.00047203,9.3238e-07,-6.53722e-09,0.0707497,0.000473875,9.12768e-07,8.22054e-09,0.0712245,0.000475725,9.37429e-07,-3.99325e-09,0.0717012,0.000477588,9.2545e-07,3.01839e-10,0.0721797,0.00047944,9.26355e-07,2.78597e-09,0.0726601,0.000481301,9.34713e-07,-3.99507e-09,0.0731423,0.000483158,9.22728e-07,5.7435e-09,0.0736264,0.000485021,9.39958e-07,-4.07776e-09,0.0741123,0.000486888,9.27725e-07,3.11695e-09,0.0746002,0.000488753,9.37076e-07,-9.39394e-10,0.0750898,0.000490625,9.34258e-07,6.4055e-10,0.0755814,0.000492495,9.3618e-07,-1.62265e-09,0.0760748,0.000494363,9.31312e-07,5.84995e-09,0.0765701,0.000496243,9.48861e-07,-6.87601e-09,0.0770673,0.00049812,9.28233e-07,6.75296e-09,0.0775664,0.000499997,9.48492e-07,-5.23467e-09,0.0780673,0.000501878,9.32788e-07,6.73523e-09,0.0785701,0.000503764,9.52994e-07,-6.80514e-09,0.0790748,0.000505649,9.32578e-07,5.5842e-09,0.0795814,0.000507531,9.49331e-07,-6.30583e-10,0.0800899,0.000509428,9.47439e-07,-3.0618e-09,0.0806003,0.000511314,9.38254e-07,5.4273e-09,0.0811125,0.000513206,9.54536e-07,-3.74627e-09,0.0816267,0.000515104,9.43297e-07,2.10713e-09,0.0821427,0.000516997,9.49618e-07,2.76839e-09,0.0826607,0.000518905,9.57924e-07,-5.73006e-09,0.0831805,0.000520803,9.40733e-07,5.25072e-09,0.0837023,0.0005227,9.56486e-07,-3.71718e-10,0.084226,0.000524612,9.5537e-07,-3.76404e-09,0.0847515,0.000526512,9.44078e-07,7.97735e-09,0.085279,0.000528424,9.6801e-07,-5.79367e-09,0.0858084,0.000530343,9.50629e-07,2.96268e-10,0.0863397,0.000532245,9.51518e-07,4.6086e-09,0.0868729,0.000534162,9.65344e-07,-3.82947e-09,0.087408,0.000536081,9.53856e-07,3.25861e-09,0.087945,0.000537998,9.63631e-07,-1.7543e-09,0.088484,0.00053992,9.58368e-07,3.75849e-09,0.0890249,0.000541848,9.69644e-07,-5.82891e-09,0.0895677,0.00054377,9.52157e-07,4.65593e-09,0.0901124,0.000545688,9.66125e-07,2.10643e-09,0.0906591,0.000547627,9.72444e-07,-5.63099e-09,0.0912077,0.000549555,9.55551e-07,5.51627e-09,0.0917582,0.000551483,9.721e-07,-1.53292e-09,0.0923106,0.000553422,9.67501e-07,6.15311e-10,0.092865,0.000555359,9.69347e-07,-9.28291e-10,0.0934213,0.000557295,9.66562e-07,3.09774e-09,0.0939796,0.000559237,9.75856e-07,-4.01186e-09,0.0945398,0.000561177,9.6382e-07,5.49892e-09,0.095102,0.000563121,9.80317e-07,-3.08258e-09,0.0956661,0.000565073,9.71069e-07,-6.19176e-10,0.0962321,0.000567013,9.69212e-07,5.55932e-09,0.0968001,0.000568968,9.8589e-07,-6.71704e-09,0.09737,0.00057092,9.65738e-07,6.40762e-09,0.0979419,0.00057287,9.84961e-07,-4.0122e-09,0.0985158,0.000574828,9.72925e-07,2.19059e-09,0.0990916,0.000576781,9.79496e-07,2.70048e-09,0.0996693,0.000578748,9.87598e-07,-5.54193e-09,0.100249,0.000580706,9.70972e-07,4.56597e-09,0.100831,0.000582662,9.8467e-07,2.17923e-09,0.101414,0.000584638,9.91208e-07,-5.83232e-09,0.102,0.000586603,9.73711e-07,6.24884e-09,0.102588,0.000588569,9.92457e-07,-4.26178e-09,0.103177,0.000590541,9.79672e-07,3.34781e-09,0.103769,0.00059251,9.89715e-07,-1.67904e-09,0.104362,0.000594485,9.84678e-07,3.36839e-09,0.104958,0.000596464,9.94783e-07,-4.34397e-09,0.105555,0.000598441,9.81751e-07,6.55696e-09,0.106155,0.000600424,1.00142e-06,-6.98272e-09,0.106756,0.000602406,9.80474e-07,6.4728e-09,0.107359,0.000604386,9.99893e-07,-4.00742e-09,0.107965,0.000606374,9.8787e-07,2.10654e-09,0.108572,0.000608356,9.9419e-07,3.0318e-09,0.109181,0.000610353,1.00329e-06,-6.7832e-09,0.109793,0.00061234,9.82936e-07,9.1998e-09,0.110406,0.000614333,1.01054e-06,-7.6642e-09,0.111021,0.000616331,9.87543e-07,6.55579e-09,0.111639,0.000618326,1.00721e-06,-3.65791e-09,0.112258,0.000620329,9.96236e-07,6.25467e-10,0.112879,0.000622324,9.98113e-07,1.15593e-09,0.113503,0.000624323,1.00158e-06,2.20158e-09,0.114128,0.000626333,1.00819e-06,-2.51191e-09,0.114755,0.000628342,1.00065e-06,3.95517e-10,0.115385,0.000630345,1.00184e-06,9.29807e-10,0.116016,0.000632351,1.00463e-06,3.33599e-09,0.116649,0.00063437,1.01463e-06,-6.82329e-09,0.117285,0.000636379,9.94163e-07,9.05595e-09,0.117922,0.000638395,1.02133e-06,-7.04862e-09,0.118562,0.000640416,1.00019e-06,4.23737e-09,0.119203,0.000642429,1.0129e-06,-2.45033e-09,0.119847,0.000644448,1.00555e-06,5.56395e-09,0.120492,0.000646475,1.02224e-06,-4.9043e-09,0.121139,0.000648505,1.00753e-06,-8.47952e-10,0.121789,0.000650518,1.00498e-06,8.29622e-09,0.122441,0.000652553,1.02987e-06,-9.98538e-09,0.123094,0.000654582,9.99914e-07,9.2936e-09,0.12375,0.00065661,1.02779e-06,-4.83707e-09,0.124407,0.000658651,1.01328e-06,2.60411e-09,0.125067,0.000660685,1.0211e-06,-5.57945e-09,0.125729,0.000662711,1.00436e-06,1.22631e-08,0.126392,0.000664756,1.04115e-06,-1.36704e-08,0.127058,0.000666798,1.00014e-06,1.26161e-08,0.127726,0.000668836,1.03798e-06,-6.99155e-09,0.128396,0.000670891,1.01701e-06,4.48836e-10,0.129068,0.000672926,1.01836e-06,5.19606e-09,0.129742,0.000674978,1.03394e-06,-6.3319e-09,0.130418,0.000677027,1.01495e-06,5.2305e-09,0.131096,0.000679073,1.03064e-06,3.11123e-10,0.131776,0.000681135,1.03157e-06,-6.47511e-09,0.132458,0.000683179,1.01215e-06,1.06882e-08,0.133142,0.000685235,1.04421e-06,-6.47519e-09,0.133829,0.000687304,1.02479e-06,3.11237e-10,0.134517,0.000689355,1.02572e-06,5.23035e-09,0.135207,0.000691422,1.04141e-06,-6.3316e-09,0.1359,0.000693486,1.02242e-06,5.19484e-09,0.136594,0.000695546,1.038e-06,4.53497e-10,0.137291,0.000697623,1.03936e-06,-7.00891e-09,0.137989,0.000699681,1.01834e-06,1.2681e-08,0.13869,0.000701756,1.05638e-06,-1.39128e-08,0.139393,0.000703827,1.01464e-06,1.31679e-08,0.140098,0.000705896,1.05414e-06,-8.95659e-09,0.140805,0.000707977,1.02727e-06,7.75742e-09,0.141514,0.000710055,1.05055e-06,-7.17182e-09,0.142225,0.000712135,1.02903e-06,6.02862e-09,0.142938,0.000714211,1.04712e-06,-2.04163e-09,0.143653,0.000716299,1.04099e-06,2.13792e-09,0.144371,0.000718387,1.04741e-06,-6.51009e-09,0.14509,0.000720462,1.02787e-06,9.00123e-09,0.145812,0.000722545,1.05488e-06,3.07523e-10,0.146535,0.000724656,1.0558e-06,-1.02312e-08,0.147261,0.000726737,1.02511e-06,1.0815e-08,0.147989,0.000728819,1.05755e-06,-3.22681e-09,0.148719,0.000730925,1.04787e-06,2.09244e-09,0.14945,0.000733027,1.05415e-06,-5.143e-09,0.150185,0.00073512,1.03872e-06,3.57844e-09,0.150921,0.000737208,1.04946e-06,5.73027e-09,0.151659,0.000739324,1.06665e-06,-1.15983e-08,0.152399,0.000741423,1.03185e-06,1.08605e-08,0.153142,0.000743519,1.06443e-06,-2.04106e-09,0.153886,0.000745642,1.05831e-06,-2.69642e-09,0.154633,0.00074775,1.05022e-06,-2.07425e-09,0.155382,0.000749844,1.044e-06,1.09934e-08,0.156133,0.000751965,1.07698e-06,-1.20972e-08,0.156886,0.000754083,1.04069e-06,7.59288e-09,0.157641,0.000756187,1.06347e-06,-3.37305e-09,0.158398,0.000758304,1.05335e-06,5.89921e-09,0.159158,0.000760428,1.07104e-06,-5.32248e-09,0.159919,0.000762554,1.05508e-06,4.8927e-10,0.160683,0.000764666,1.05654e-06,3.36547e-09,0.161448,0.000766789,1.06664e-06,9.50081e-10,0.162216,0.000768925,1.06949e-06,-7.16568e-09,0.162986,0.000771043,1.04799e-06,1.28114e-08,0.163758,0.000773177,1.08643e-06,-1.42774e-08,0.164533,0.000775307,1.0436e-06,1.44956e-08,0.165309,0.000777438,1.08708e-06,-1.39025e-08,0.166087,0.00077957,1.04538e-06,1.13118e-08,0.166868,0.000781695,1.07931e-06,-1.54224e-09,0.167651,0.000783849,1.07468e-06,-5.14312e-09,0.168436,0.000785983,1.05925e-06,7.21381e-09,0.169223,0.000788123,1.0809e-06,-8.81096e-09,0.170012,0.000790259,1.05446e-06,1.31289e-08,0.170803,0.000792407,1.09385e-06,-1.39022e-08,0.171597,0.000794553,1.05214e-06,1.26775e-08,0.172392,0.000796695,1.09018e-06,-7.00557e-09,0.17319,0.000798855,1.06916e-06,4.43796e-10,0.17399,0.000800994,1.07049e-06,5.23031e-09,0.174792,0.000803151,1.08618e-06,-6.46397e-09,0.175596,0.000805304,1.06679e-06,5.72444e-09,0.176403,0.000807455,1.08396e-06,-1.53254e-09,0.177211,0.000809618,1.07937e-06,4.05673e-10,0.178022,0.000811778,1.08058e-06,-9.01916e-11,0.178835,0.000813939,1.08031e-06,-4.49821e-11,0.17965,0.000816099,1.08018e-06,2.70234e-10,0.180467,0.00081826,1.08099e-06,-1.03603e-09,0.181286,0.000820419,1.07788e-06,3.87392e-09,0.182108,0.000822587,1.0895e-06,4.41522e-10,0.182932,0.000824767,1.09083e-06,-5.63997e-09,0.183758,0.000826932,1.07391e-06,7.21707e-09,0.184586,0.000829101,1.09556e-06,-8.32718e-09,0.185416,0.000831267,1.07058e-06,1.11907e-08,0.186248,0.000833442,1.10415e-06,-6.63336e-09,0.187083,0.00083563,1.08425e-06,4.41484e-10,0.187919,0.0008378,1.08557e-06,4.86754e-09,0.188758,0.000839986,1.10017e-06,-5.01041e-09,0.189599,0.000842171,1.08514e-06,2.72811e-10,0.190443,0.000844342,1.08596e-06,3.91916e-09,0.191288,0.000846526,1.09772e-06,-1.04819e-09,0.192136,0.000848718,1.09457e-06,2.73531e-10,0.192985,0.000850908,1.0954e-06,-4.58916e-11,0.193837,0.000853099,1.09526e-06,-9.01158e-11,0.194692,0.000855289,1.09499e-06,4.06506e-10,0.195548,0.00085748,1.09621e-06,-1.53595e-09,0.196407,0.000859668,1.0916e-06,5.73717e-09,0.197267,0.000861869,1.10881e-06,-6.51164e-09,0.19813,0.000864067,1.08928e-06,5.40831e-09,0.198995,0.000866261,1.1055e-06,-2.20401e-10,0.199863,0.000868472,1.10484e-06,-4.52652e-09,0.200732,0.000870668,1.09126e-06,3.42508e-09,0.201604,0.000872861,1.10153e-06,5.72762e-09,0.202478,0.000875081,1.11872e-06,-1.14344e-08,0.203354,0.000877284,1.08441e-06,1.02076e-08,0.204233,0.000879484,1.11504e-06,4.06355e-10,0.205113,0.000881715,1.11626e-06,-1.18329e-08,0.205996,0.000883912,1.08076e-06,1.71227e-08,0.206881,0.000886125,1.13213e-06,-1.19546e-08,0.207768,0.000888353,1.09626e-06,8.93465e-10,0.208658,0.000890548,1.09894e-06,8.38062e-09,0.209549,0.000892771,1.12408e-06,-4.61353e-09,0.210443,0.000895006,1.11024e-06,-4.82756e-09,0.211339,0.000897212,1.09576e-06,9.02245e-09,0.212238,0.00089943,1.12283e-06,-1.45997e-09,0.213138,0.000901672,1.11845e-06,-3.18255e-09,0.214041,0.000903899,1.1089e-06,-7.11073e-10,0.214946,0.000906115,1.10677e-06,6.02692e-09,0.215853,0.000908346,1.12485e-06,-8.49548e-09,0.216763,0.00091057,1.09936e-06,1.30537e-08,0.217675,0.000912808,1.13852e-06,-1.3917e-08,0.218588,0.000915044,1.09677e-06,1.28121e-08,0.219505,0.000917276,1.13521e-06,-7.5288e-09,0.220423,0.000919523,1.11262e-06,2.40205e-09,0.221344,0.000921756,1.11983e-06,-2.07941e-09,0.222267,0.000923989,1.11359e-06,5.91551e-09,0.223192,0.000926234,1.13134e-06,-6.68149e-09,0.224119,0.000928477,1.11129e-06,5.90929e-09,0.225049,0.000930717,1.12902e-06,-2.05436e-09,0.22598,0.000932969,1.12286e-06,2.30807e-09,0.226915,0.000935222,1.12978e-06,-7.17796e-09,0.227851,0.00093746,1.10825e-06,1.15028e-08,0.228789,0.000939711,1.14276e-06,-9.03083e-09,0.22973,0.000941969,1.11566e-06,9.71932e-09,0.230673,0.00094423,1.14482e-06,-1.49452e-08,0.231619,0.000946474,1.09998e-06,2.02591e-08,0.232566,0.000948735,1.16076e-06,-2.13879e-08,0.233516,0.000950993,1.0966e-06,2.05888e-08,0.234468,0.000953247,1.15837e-06,-1.62642e-08,0.235423,0.000955515,1.10957e-06,1.46658e-08,0.236379,0.000957779,1.15357e-06,-1.25966e-08,0.237338,0.000960048,1.11578e-06,5.91793e-09,0.238299,0.000962297,1.13353e-06,3.82602e-09,0.239263,0.000964576,1.14501e-06,-6.3208e-09,0.240229,0.000966847,1.12605e-06,6.55613e-09,0.241197,0.000969119,1.14572e-06,-5.00268e-09,0.242167,0.000971395,1.13071e-06,-1.44659e-09,0.243139,0.000973652,1.12637e-06,1.07891e-08,0.244114,0.000975937,1.15874e-06,-1.19073e-08,0.245091,0.000978219,1.12302e-06,7.03782e-09,0.246071,0.000980486,1.14413e-06,-1.34276e-09,0.247052,0.00098277,1.1401e-06,-1.66669e-09,0.248036,0.000985046,1.1351e-06,8.00935e-09,0.249022,0.00098734,1.15913e-06,-1.54694e-08,0.250011,0.000989612,1.11272e-06,2.4066e-08,0.251002,0.000991909,1.18492e-06,-2.11901e-08,0.251995,0.000994215,1.12135e-06,1.08973e-09,0.25299,0.000996461,1.12462e-06,1.68311e-08,0.253988,0.000998761,1.17511e-06,-8.8094e-09,0.254987,0.00100109,1.14868e-06,-1.13958e-08,0.25599,0.00100335,1.1145e-06,2.45902e-08,0.256994,0.00100565,1.18827e-06,-2.73603e-08,0.258001,0.00100795,1.10618e-06,2.52464e-08,0.25901,0.00101023,1.18192e-06,-1.40207e-08,0.260021,0.00101256,1.13986e-06,1.03387e-09,0.261035,0.00101484,1.14296e-06,9.8853e-09,0.262051,0.00101715,1.17262e-06,-1.07726e-08,0.263069,0.00101947,1.1403e-06,3.40272e-09,0.26409,0.00102176,1.15051e-06,-2.83827e-09,0.265113,0.00102405,1.142e-06,7.95039e-09,0.266138,0.00102636,1.16585e-06,8.39047e-10,0.267166,0.00102869,1.16836e-06,-1.13066e-08,0.268196,0.00103099,1.13444e-06,1.4585e-08,0.269228,0.00103331,1.1782e-06,-1.72314e-08,0.270262,0.00103561,1.1265e-06,2.45382e-08,0.271299,0.00103794,1.20012e-06,-2.13166e-08,0.272338,0.00104028,1.13617e-06,1.12364e-09,0.273379,0.00104255,1.13954e-06,1.68221e-08,0.274423,0.00104488,1.19001e-06,-8.80736e-09,0.275469,0.00104723,1.16358e-06,-1.13948e-08,0.276518,0.00104953,1.1294e-06,2.45839e-08,0.277568,0.00105186,1.20315e-06,-2.73361e-08,0.278621,0.00105418,1.12114e-06,2.51559e-08,0.279677,0.0010565,1.19661e-06,-1.36832e-08,0.280734,0.00105885,1.15556e-06,-2.25706e-10,0.281794,0.00106116,1.15488e-06,1.45862e-08,0.282857,0.00106352,1.19864e-06,-2.83167e-08,0.283921,0.00106583,1.11369e-06,3.90759e-08,0.284988,0.00106817,1.23092e-06,-3.85801e-08,0.286058,0.00107052,1.11518e-06,2.58375e-08,0.287129,0.00107283,1.19269e-06,-5.16498e-09,0.288203,0.0010752,1.1772e-06,-5.17768e-09,0.28928,0.00107754,1.16167e-06,-3.92671e-09,0.290358,0.00107985,1.14988e-06,2.08846e-08,0.29144,0.00108221,1.21254e-06,-2.00072e-08,0.292523,0.00108458,1.15252e-06,-4.60659e-10,0.293609,0.00108688,1.15114e-06,2.18499e-08,0.294697,0.00108925,1.21669e-06,-2.73343e-08,0.295787,0.0010916,1.13468e-06,2.78826e-08,0.29688,0.00109395,1.21833e-06,-2.45915e-08,0.297975,0.00109632,1.14456e-06,1.08787e-08,0.299073,0.00109864,1.17719e-06,1.08788e-08,0.300172,0.00110102,1.20983e-06,-2.45915e-08,0.301275,0.00110337,1.13605e-06,2.78828e-08,0.302379,0.00110573,1.2197e-06,-2.73348e-08,0.303486,0.00110808,1.1377e-06,2.18518e-08,0.304595,0.00111042,1.20325e-06,-4.67556e-10,0.305707,0.00111283,1.20185e-06,-1.99816e-08,0.306821,0.00111517,1.14191e-06,2.07891e-08,0.307937,0.00111752,1.20427e-06,-3.57026e-09,0.309056,0.00111992,1.19356e-06,-6.50797e-09,0.310177,0.00112228,1.17404e-06,-2.00165e-10,0.3113,0.00112463,1.17344e-06,7.30874e-09,0.312426,0.001127,1.19536e-06,7.67424e-10,0.313554,0.00112939,1.19767e-06,-1.03784e-08,0.314685,0.00113176,1.16653e-06,1.09437e-08,0.315818,0.00113412,1.19936e-06,-3.59406e-09,0.316953,0.00113651,1.18858e-06,3.43251e-09,0.318091,0.0011389,1.19888e-06,-1.0136e-08,0.319231,0.00114127,1.16847e-06,7.30915e-09,0.320374,0.00114363,1.1904e-06,1.07018e-08,0.321518,0.00114604,1.2225e-06,-2.03137e-08,0.322666,0.00114842,1.16156e-06,1.09484e-08,0.323815,0.00115078,1.19441e-06,6.32224e-09,0.324967,0.00115319,1.21337e-06,-6.43509e-09,0.326122,0.00115559,1.19407e-06,-1.03842e-08,0.327278,0.00115795,1.16291e-06,1.81697e-08,0.328438,0.00116033,1.21742e-06,-2.6901e-09,0.329599,0.00116276,1.20935e-06,-7.40939e-09,0.330763,0.00116515,1.18713e-06,2.52533e-09,0.331929,0.00116754,1.1947e-06,-2.69191e-09,0.333098,0.00116992,1.18663e-06,8.24218e-09,0.334269,0.00117232,1.21135e-06,-4.74377e-10,0.335443,0.00117474,1.20993e-06,-6.34471e-09,0.336619,0.00117714,1.1909e-06,-3.94922e-09,0.337797,0.00117951,1.17905e-06,2.21417e-08,0.338978,0.00118193,1.24547e-06,-2.50128e-08,0.340161,0.00118435,1.17043e-06,1.8305e-08,0.341346,0.00118674,1.22535e-06,-1.84048e-08,0.342534,0.00118914,1.17013e-06,2.55121e-08,0.343725,0.00119156,1.24667e-06,-2.40389e-08,0.344917,0.00119398,1.17455e-06,1.10389e-08,0.346113,0.00119636,1.20767e-06,9.68574e-09,0.34731,0.0011988,1.23673e-06,-1.99797e-08,0.34851,0.00120122,1.17679e-06,1.06284e-08,0.349713,0.0012036,1.20867e-06,7.26868e-09,0.350917,0.00120604,1.23048e-06,-9.90072e-09,0.352125,0.00120847,1.20078e-06,2.53177e-09,0.353334,0.00121088,1.20837e-06,-2.26199e-10,0.354546,0.0012133,1.20769e-06,-1.62705e-09,0.355761,0.00121571,1.20281e-06,6.73435e-09,0.356978,0.00121813,1.22302e-06,4.49207e-09,0.358197,0.00122059,1.23649e-06,-2.47027e-08,0.359419,0.00122299,1.16238e-06,3.47142e-08,0.360643,0.00122542,1.26653e-06,-2.47472e-08,0.36187,0.00122788,1.19229e-06,4.66965e-09,0.363099,0.00123028,1.20629e-06,6.06872e-09,0.36433,0.00123271,1.2245e-06,8.57729e-10,0.365564,0.00123516,1.22707e-06,-9.49952e-09,0.366801,0.00123759,1.19858e-06,7.33792e-09,0.36804,0.00124001,1.22059e-06,9.95025e-09,0.369281,0.00124248,1.25044e-06,-1.73366e-08,0.370525,0.00124493,1.19843e-06,-2.08464e-10,0.371771,0.00124732,1.1978e-06,1.81704e-08,0.373019,0.00124977,1.25232e-06,-1.28683e-08,0.37427,0.00125224,1.21371e-06,3.50042e-09,0.375524,0.00125468,1.22421e-06,-1.1335e-09,0.37678,0.00125712,1.22081e-06,1.03345e-09,0.378038,0.00125957,1.22391e-06,-3.00023e-09,0.379299,0.00126201,1.21491e-06,1.09676e-08,0.380562,0.00126447,1.24781e-06,-1.10676e-08,0.381828,0.00126693,1.21461e-06,3.50042e-09,0.383096,0.00126937,1.22511e-06,-2.93403e-09,0.384366,0.00127181,1.21631e-06,8.23574e-09,0.385639,0.00127427,1.24102e-06,-2.06607e-10,0.386915,0.00127675,1.2404e-06,-7.40935e-09,0.388193,0.00127921,1.21817e-06,4.1761e-11,0.389473,0.00128165,1.21829e-06,7.24223e-09,0.390756,0.0012841,1.24002e-06,7.91564e-10,0.392042,0.00128659,1.2424e-06,-1.04086e-08,0.393329,0.00128904,1.21117e-06,1.10405e-08,0.39462,0.0012915,1.24429e-06,-3.951e-09,0.395912,0.00129397,1.23244e-06,4.7634e-09,0.397208,0.00129645,1.24673e-06,-1.51025e-08,0.398505,0.0012989,1.20142e-06,2.58443e-08,0.399805,0.00130138,1.27895e-06,-2.86702e-08,0.401108,0.00130385,1.19294e-06,2.92318e-08,0.402413,0.00130632,1.28064e-06,-2.86524e-08,0.403721,0.0013088,1.19468e-06,2.57731e-08,0.405031,0.00131127,1.272e-06,-1.48355e-08,0.406343,0.00131377,1.2275e-06,3.76652e-09,0.407658,0.00131623,1.23879e-06,-2.30784e-10,0.408976,0.00131871,1.2381e-06,-2.84331e-09,0.410296,0.00132118,1.22957e-06,1.16041e-08,0.411618,0.00132367,1.26438e-06,-1.37708e-08,0.412943,0.00132616,1.22307e-06,1.36768e-08,0.41427,0.00132865,1.2641e-06,-1.1134e-08,0.4156,0.00133114,1.2307e-06,1.05714e-09,0.416933,0.00133361,1.23387e-06,6.90538e-09,0.418267,0.00133609,1.25459e-06,1.12372e-09,0.419605,0.00133861,1.25796e-06,-1.14002e-08,0.420945,0.00134109,1.22376e-06,1.46747e-08,0.422287,0.00134358,1.26778e-06,-1.7496e-08,0.423632,0.00134606,1.21529e-06,2.5507e-08,0.424979,0.00134857,1.29182e-06,-2.49272e-08,0.426329,0.00135108,1.21703e-06,1.45972e-08,0.427681,0.00135356,1.26083e-06,-3.65935e-09,0.429036,0.00135607,1.24985e-06,4.00178e-11,0.430393,0.00135857,1.24997e-06,3.49917e-09,0.431753,0.00136108,1.26047e-06,-1.40366e-08,0.433116,0.00136356,1.21836e-06,2.28448e-08,0.43448,0.00136606,1.28689e-06,-1.77378e-08,0.435848,0.00136858,1.23368e-06,1.83043e-08,0.437218,0.0013711,1.28859e-06,-2.56769e-08,0.43859,0.0013736,1.21156e-06,2.47987e-08,0.439965,0.0013761,1.28595e-06,-1.39133e-08,0.441342,0.00137863,1.24421e-06,1.05202e-09,0.442722,0.00138112,1.24737e-06,9.70507e-09,0.444104,0.00138365,1.27649e-06,-1.00698e-08,0.445489,0.00138617,1.24628e-06,7.72123e-10,0.446877,0.00138867,1.24859e-06,6.98132e-09,0.448267,0.00139118,1.26954e-06,1.10477e-09,0.449659,0.00139373,1.27285e-06,-1.14003e-08,0.451054,0.00139624,1.23865e-06,1.4694e-08,0.452452,0.00139876,1.28273e-06,-1.75734e-08,0.453852,0.00140127,1.23001e-06,2.5797e-08,0.455254,0.00140381,1.3074e-06,-2.60097e-08,0.456659,0.00140635,1.22937e-06,1.86371e-08,0.458067,0.00140886,1.28529e-06,-1.8736e-08,0.459477,0.00141137,1.22908e-06,2.65048e-08,0.46089,0.00141391,1.30859e-06,-2.76784e-08,0.462305,0.00141645,1.22556e-06,2.46043e-08,0.463722,0.00141897,1.29937e-06,-1.11341e-08,0.465143,0.00142154,1.26597e-06,-9.87033e-09,0.466565,0.00142404,1.23636e-06,2.08131e-08,0.467991,0.00142657,1.2988e-06,-1.37773e-08,0.469419,0.00142913,1.25746e-06,4.49378e-09,0.470849,0.00143166,1.27094e-06,-4.19781e-09,0.472282,0.00143419,1.25835e-06,1.22975e-08,0.473717,0.00143674,1.29524e-06,-1.51902e-08,0.475155,0.00143929,1.24967e-06,1.86608e-08,0.476596,0.00144184,1.30566e-06,-2.96506e-08,0.478039,0.00144436,1.2167e-06,4.03368e-08,0.479485,0.00144692,1.33771e-06,-4.22896e-08,0.480933,0.00144947,1.21085e-06,3.94148e-08,0.482384,0.00145201,1.32909e-06,-2.59626e-08,0.483837,0.00145459,1.2512e-06,4.83124e-09,0.485293,0.0014571,1.2657e-06,6.63757e-09,0.486751,0.00145966,1.28561e-06,-1.57911e-09,0.488212,0.00146222,1.28087e-06,-3.21468e-10,0.489676,0.00146478,1.27991e-06,2.86517e-09,0.491142,0.00146735,1.2885e-06,-1.11392e-08,0.49261,0.00146989,1.25508e-06,1.18893e-08,0.494081,0.00147244,1.29075e-06,-6.61574e-09,0.495555,0.001475,1.27091e-06,1.45736e-08,0.497031,0.00147759,1.31463e-06,-2.18759e-08,0.49851,0.00148015,1.249e-06,1.33252e-08,0.499992,0.00148269,1.28897e-06,-1.62277e-09,0.501476,0.00148526,1.28411e-06,-6.83421e-09,0.502962,0.00148781,1.2636e-06,2.89596e-08,0.504451,0.00149042,1.35048e-06,-4.93997e-08,0.505943,0.00149298,1.20228e-06,4.94299e-08,0.507437,0.00149553,1.35057e-06,-2.91107e-08,0.508934,0.00149814,1.26324e-06,7.40848e-09,0.510434,0.00150069,1.28547e-06,-5.23187e-10,0.511936,0.00150326,1.2839e-06,-5.31585e-09,0.51344,0.00150581,1.26795e-06,2.17866e-08,0.514947,0.00150841,1.33331e-06,-2.22257e-08,0.516457,0.00151101,1.26663e-06,7.51178e-09,0.517969,0.00151357,1.28917e-06,-7.82128e-09,0.519484,0.00151613,1.2657e-06,2.37733e-08,0.521002,0.00151873,1.33702e-06,-2.76674e-08,0.522522,0.00152132,1.25402e-06,2.72917e-08,0.524044,0.00152391,1.3359e-06,-2.18949e-08,0.525569,0.00152652,1.27021e-06,6.83372e-10,0.527097,0.00152906,1.27226e-06,1.91613e-08,0.528628,0.00153166,1.32974e-06,-1.77241e-08,0.53016,0.00153427,1.27657e-06,-7.86963e-09,0.531696,0.0015368,1.25296e-06,4.92027e-08,0.533234,0.00153945,1.40057e-06,-6.9732e-08,0.534775,0.00154204,1.19138e-06,5.09114e-08,0.536318,0.00154458,1.34411e-06,-1.4704e-08,0.537864,0.00154722,1.3e-06,7.9048e-09,0.539413,0.00154984,1.32371e-06,-1.69152e-08,0.540964,0.00155244,1.27297e-06,1.51355e-10,0.542517,0.00155499,1.27342e-06,1.63099e-08,0.544074,0.00155758,1.32235e-06,-5.78647e-09,0.545633,0.00156021,1.30499e-06,6.83599e-09,0.547194,0.00156284,1.3255e-06,-2.15575e-08,0.548758,0.00156543,1.26083e-06,1.97892e-08,0.550325,0.00156801,1.32019e-06,2.00525e-09,0.551894,0.00157065,1.32621e-06,-2.78103e-08,0.553466,0.00157322,1.24278e-06,4.96314e-08,0.555041,0.00157586,1.39167e-06,-5.1506e-08,0.556618,0.00157849,1.23716e-06,3.71835e-08,0.558198,0.00158107,1.34871e-06,-3.76233e-08,0.55978,0.00158366,1.23584e-06,5.37052e-08,0.561365,0.00158629,1.39695e-06,-5.79884e-08,0.562953,0.00158891,1.22299e-06,5.90392e-08,0.564543,0.00159153,1.4001e-06,-5.89592e-08,0.566136,0.00159416,1.22323e-06,5.7588e-08,0.567731,0.00159678,1.39599e-06,-5.21835e-08,0.569329,0.00159941,1.23944e-06,3.19369e-08,0.57093,0.00160199,1.33525e-06,-1.59594e-08,0.572533,0.00160461,1.28737e-06,3.19006e-08,0.574139,0.00160728,1.38307e-06,-5.20383e-08,0.575748,0.00160989,1.22696e-06,5.70431e-08,0.577359,0.00161251,1.39809e-06,-5.69247e-08,0.578973,0.00161514,1.22731e-06,5.14463e-08,0.580589,0.00161775,1.38165e-06,-2.9651e-08,0.582208,0.00162042,1.2927e-06,7.55339e-09,0.58383,0.00162303,1.31536e-06,-5.62636e-10,0.585455,0.00162566,1.31367e-06,-5.30281e-09,0.587081,0.00162827,1.29776e-06,2.17738e-08,0.588711,0.00163093,1.36309e-06,-2.21875e-08,0.590343,0.00163359,1.29652e-06,7.37164e-09,0.591978,0.00163621,1.31864e-06,-7.29907e-09,0.593616,0.00163882,1.29674e-06,2.18247e-08,0.595256,0.00164148,1.36221e-06,-2.03952e-08,0.596899,0.00164414,1.30103e-06,1.51241e-10,0.598544,0.00164675,1.30148e-06,1.97902e-08,0.600192,0.00164941,1.36085e-06,-1.97074e-08,0.601843,0.00165207,1.30173e-06,-5.65175e-10,0.603496,0.00165467,1.30004e-06,2.1968e-08,0.605152,0.00165734,1.36594e-06,-2.77024e-08,0.606811,0.00165999,1.28283e-06,2.92369e-08,0.608472,0.00166264,1.37054e-06,-2.96407e-08,0.610136,0.00166529,1.28162e-06,2.97215e-08,0.611803,0.00166795,1.37079e-06,-2.96408e-08,0.613472,0.0016706,1.28186e-06,2.92371e-08,0.615144,0.00167325,1.36957e-06,-2.77031e-08,0.616819,0.00167591,1.28647e-06,2.19708e-08,0.618496,0.00167855,1.35238e-06,-5.75407e-10,0.620176,0.00168125,1.35065e-06,-1.9669e-08,0.621858,0.00168389,1.29164e-06,1.96468e-08,0.623544,0.00168653,1.35058e-06,6.86403e-10,0.625232,0.00168924,1.35264e-06,-2.23924e-08,0.626922,0.00169187,1.28547e-06,2.92788e-08,0.628615,0.00169453,1.3733e-06,-3.51181e-08,0.630311,0.00169717,1.26795e-06,5.15889e-08,0.63201,0.00169987,1.42272e-06,-5.2028e-08,0.633711,0.00170255,1.26663e-06,3.73139e-08,0.635415,0.0017052,1.37857e-06,-3.76227e-08,0.637121,0.00170784,1.2657e-06,5.35722e-08,0.63883,0.00171054,1.42642e-06,-5.74567e-08,0.640542,0.00171322,1.25405e-06,5.70456e-08,0.642257,0.0017159,1.42519e-06,-5.15163e-08,0.643974,0.00171859,1.27064e-06,2.98103e-08,0.645694,0.00172122,1.36007e-06,-8.12016e-09,0.647417,0.00172392,1.33571e-06,2.67039e-09,0.649142,0.0017266,1.34372e-06,-2.56152e-09,0.65087,0.00172928,1.33604e-06,7.57571e-09,0.6526,0.00173197,1.35876e-06,-2.77413e-08,0.654334,0.00173461,1.27554e-06,4.3785e-08,0.65607,0.00173729,1.40689e-06,-2.81896e-08,0.657808,0.00174002,1.32233e-06,9.36893e-09,0.65955,0.00174269,1.35043e-06,-9.28617e-09,0.661294,0.00174536,1.32257e-06,2.77757e-08,0.66304,0.00174809,1.4059e-06,-4.2212e-08,0.66479,0.00175078,1.27926e-06,2.1863e-08,0.666542,0.0017534,1.34485e-06,1.43648e-08,0.668297,0.00175613,1.38795e-06,-1.97177e-08,0.670054,0.00175885,1.3288e-06,4.90115e-09,0.671814,0.00176152,1.3435e-06,1.13232e-10,0.673577,0.00176421,1.34384e-06,-5.3542e-09,0.675343,0.00176688,1.32778e-06,2.13035e-08,0.677111,0.0017696,1.39169e-06,-2.02553e-08,0.678882,0.00177232,1.33092e-06,1.13005e-10,0.680656,0.00177499,1.33126e-06,1.98031e-08,0.682432,0.00177771,1.39067e-06,-1.97211e-08,0.684211,0.00178043,1.33151e-06,-5.2349e-10,0.685993,0.00178309,1.32994e-06,2.18151e-08,0.687777,0.00178582,1.39538e-06,-2.71325e-08,0.689564,0.00178853,1.31398e-06,2.71101e-08,0.691354,0.00179124,1.39531e-06,-2.17035e-08,0.693147,0.00179396,1.3302e-06,9.92865e-11,0.694942,0.00179662,1.3305e-06,2.13063e-08,0.69674,0.00179935,1.39442e-06,-2.57198e-08,0.698541,0.00180206,1.31726e-06,2.19682e-08,0.700344,0.00180476,1.38317e-06,-2.54852e-09,0.70215,0.00180752,1.37552e-06,-1.17741e-08,0.703959,0.00181023,1.3402e-06,-9.95999e-09,0.705771,0.00181288,1.31032e-06,5.16141e-08,0.707585,0.00181566,1.46516e-06,-7.72869e-08,0.709402,0.00181836,1.2333e-06,7.87197e-08,0.711222,0.00182106,1.46946e-06,-5.87781e-08,0.713044,0.00182382,1.29312e-06,3.71834e-08,0.714869,0.00182652,1.40467e-06,-3.03511e-08,0.716697,0.00182924,1.31362e-06,2.46161e-08,0.718528,0.00183194,1.38747e-06,-8.5087e-09,0.720361,0.00183469,1.36194e-06,9.41892e-09,0.722197,0.00183744,1.3902e-06,-2.91671e-08,0.724036,0.00184014,1.3027e-06,4.76448e-08,0.725878,0.00184288,1.44563e-06,-4.22028e-08,0.727722,0.00184565,1.31902e-06,1.95682e-09,0.729569,0.00184829,1.3249e-06,3.43754e-08,0.731419,0.00185104,1.42802e-06,-2.0249e-08,0.733271,0.00185384,1.36727e-06,-1.29838e-08,0.735126,0.00185654,1.32832e-06,1.25794e-08,0.736984,0.00185923,1.36606e-06,2.22711e-08,0.738845,0.00186203,1.43287e-06,-4.20594e-08,0.740708,0.00186477,1.3067e-06,2.67571e-08,0.742574,0.00186746,1.38697e-06,-5.36424e-09,0.744443,0.00187022,1.37087e-06,-5.30023e-09,0.746315,0.00187295,1.35497e-06,2.65653e-08,0.748189,0.00187574,1.43467e-06,-4.13564e-08,0.750066,0.00187848,1.3106e-06,1.9651e-08,0.751946,0.00188116,1.36955e-06,2.23572e-08,0.753828,0.00188397,1.43663e-06,-4.9475e-08,0.755714,0.00188669,1.2882e-06,5.63335e-08,0.757602,0.00188944,1.4572e-06,-5.66499e-08,0.759493,0.00189218,1.28725e-06,5.10567e-08,0.761386,0.00189491,1.44042e-06,-2.83677e-08,0.763283,0.00189771,1.35532e-06,2.80962e-09,0.765182,0.00190042,1.36375e-06,1.71293e-08,0.767083,0.0019032,1.41513e-06,-1.17221e-08,0.768988,0.001906,1.37997e-06,-2.98453e-08,0.770895,0.00190867,1.29043e-06,7.14987e-08,0.772805,0.00191146,1.50493e-06,-7.73354e-08,0.774718,0.00191424,1.27292e-06,5.90292e-08,0.776634,0.00191697,1.45001e-06,-3.9572e-08,0.778552,0.00191975,1.33129e-06,3.9654e-08,0.780473,0.00192253,1.45026e-06,-5.94395e-08,0.782397,0.00192525,1.27194e-06,7.88945e-08,0.784324,0.00192803,1.50862e-06,-7.73249e-08,0.786253,0.00193082,1.27665e-06,5.15913e-08,0.788185,0.00193352,1.43142e-06,-9.83099e-09,0.79012,0.00193636,1.40193e-06,-1.22672e-08,0.792058,0.00193912,1.36513e-06,-7.05275e-10,0.793999,0.00194185,1.36301e-06,1.50883e-08,0.795942,0.00194462,1.40828e-06,-4.33147e-11,0.797888,0.00194744,1.40815e-06,-1.49151e-08,0.799837,0.00195021,1.3634e-06,9.93244e-11,0.801788,0.00195294,1.3637e-06,1.45179e-08,0.803743,0.00195571,1.40725e-06,1.43363e-09,0.8057,0.00195853,1.41155e-06,-2.02525e-08,0.80766,0.00196129,1.35079e-06,1.99718e-08,0.809622,0.00196405,1.41071e-06,-3.01649e-11,0.811588,0.00196687,1.41062e-06,-1.9851e-08,0.813556,0.00196964,1.35107e-06,1.98296e-08,0.815527,0.0019724,1.41056e-06,1.37485e-10,0.817501,0.00197522,1.41097e-06,-2.03796e-08,0.819477,0.00197798,1.34983e-06,2.17763e-08,0.821457,0.00198074,1.41516e-06,-7.12085e-09,0.823439,0.00198355,1.3938e-06,6.70707e-09,0.825424,0.00198636,1.41392e-06,-1.97074e-08,0.827412,0.00198913,1.35479e-06,1.25179e-08,0.829402,0.00199188,1.39235e-06,2.92405e-08,0.831396,0.00199475,1.48007e-06,-6.98755e-08,0.833392,0.0019975,1.27044e-06,7.14477e-08,0.835391,0.00200026,1.48479e-06,-3.71014e-08,0.837392,0.00200311,1.37348e-06,1.73533e-08,0.839397,0.00200591,1.42554e-06,-3.23118e-08,0.841404,0.00200867,1.32861e-06,5.2289e-08,0.843414,0.00201148,1.48547e-06,-5.76348e-08,0.845427,0.00201428,1.31257e-06,5.9041e-08,0.847443,0.00201708,1.48969e-06,-5.93197e-08,0.849461,0.00201988,1.31173e-06,5.90289e-08,0.851482,0.00202268,1.48882e-06,-5.75864e-08,0.853507,0.00202549,1.31606e-06,5.21075e-08,0.855533,0.00202828,1.47238e-06,-3.16344e-08,0.857563,0.00203113,1.37748e-06,1.48257e-08,0.859596,0.00203393,1.42196e-06,-2.76684e-08,0.861631,0.00203669,1.33895e-06,3.62433e-08,0.863669,0.00203947,1.44768e-06,1.90463e-09,0.86571,0.00204237,1.45339e-06,-4.38617e-08,0.867754,0.00204515,1.32181e-06,5.43328e-08,0.8698,0.00204796,1.48481e-06,-5.42603e-08,0.87185,0.00205076,1.32203e-06,4.34989e-08,0.873902,0.00205354,1.45252e-06,-5.26029e-10,0.875957,0.00205644,1.45095e-06,-4.13949e-08,0.878015,0.00205922,1.32676e-06,4.68962e-08,0.880075,0.00206201,1.46745e-06,-2.69807e-08,0.882139,0.00206487,1.38651e-06,1.42181e-09,0.884205,0.00206764,1.39077e-06,2.12935e-08,0.886274,0.00207049,1.45465e-06,-2.69912e-08,0.888346,0.00207332,1.37368e-06,2.70664e-08,0.890421,0.00207615,1.45488e-06,-2.16698e-08,0.892498,0.00207899,1.38987e-06,8.14756e-12,0.894579,0.00208177,1.38989e-06,2.16371e-08,0.896662,0.00208462,1.45481e-06,-2.6952e-08,0.898748,0.00208744,1.37395e-06,2.65663e-08,0.900837,0.00209027,1.45365e-06,-1.97084e-08,0.902928,0.00209312,1.39452e-06,-7.33731e-09,0.905023,0.00209589,1.37251e-06,4.90578e-08,0.90712,0.00209878,1.51968e-06,-6.96845e-08,0.90922,0.00210161,1.31063e-06,5.08664e-08,0.911323,0.00210438,1.46323e-06,-1.45717e-08,0.913429,0.00210727,1.41952e-06,7.42038e-09,0.915538,0.00211013,1.44178e-06,-1.51097e-08,0.917649,0.00211297,1.39645e-06,-6.58618e-09,0.919764,0.00211574,1.37669e-06,4.14545e-08,0.921881,0.00211862,1.50105e-06,-4.00222e-08,0.924001,0.0021215,1.38099e-06,-5.7518e-10,0.926124,0.00212426,1.37926e-06,4.23229e-08,0.92825,0.00212714,1.50623e-06,-4.9507e-08,0.930378,0.00213001,1.35771e-06,3.64958e-08,0.93251,0.00213283,1.4672e-06,-3.68713e-08,0.934644,0.00213566,1.35658e-06,5.13848e-08,0.936781,0.00213852,1.51074e-06,-4.94585e-08,0.938921,0.0021414,1.36236e-06,2.72399e-08,0.941064,0.0021442,1.44408e-06,1.0372e-10,0.943209,0.00214709,1.44439e-06,-2.76547e-08,0.945358,0.0021499,1.36143e-06,5.09106e-08,0.947509,0.00215277,1.51416e-06,-5.67784e-08,0.949663,0.00215563,1.34382e-06,5.69935e-08,0.95182,0.00215849,1.5148e-06,-5.19861e-08,0.95398,0.00216136,1.35885e-06,3.17417e-08,0.956143,0.00216418,1.45407e-06,-1.53758e-08,0.958309,0.00216704,1.40794e-06,2.97615e-08,0.960477,0.00216994,1.49723e-06,-4.40657e-08,0.962649,0.00217281,1.36503e-06,2.72919e-08,0.964823,0.00217562,1.44691e-06,-5.49729e-09,0.967,0.0021785,1.43041e-06,-5.30273e-09,0.96918,0.00218134,1.41451e-06,2.67084e-08,0.971363,0.00218425,1.49463e-06,-4.19265e-08,0.973548,0.00218711,1.36885e-06,2.17881e-08,0.975737,0.00218992,1.43422e-06,1.43789e-08,0.977928,0.00219283,1.47735e-06,-1.96989e-08,0.980122,0.00219572,1.41826e-06,4.81221e-09,0.98232,0.00219857,1.43269e-06,4.50048e-10,0.98452,0.00220144,1.43404e-06,-6.61237e-09,0.986722,0.00220429,1.41421e-06,2.59993e-08,0.988928,0.0022072,1.4922e-06,-3.77803e-08,0.991137,0.00221007,1.37886e-06,5.9127e-09,0.993348,0.00221284,1.3966e-06,1.33339e-07,0.995563,0.00221604,1.79662e-06,-5.98872e-07,0.99778,0.00222015,0.,0.}; __device__ static int LabCbrt_b(int i) { float x = i * (1.f / (255.f * (1 << gamma_shift))); return (1 << lab_shift2) * (x < 0.008856f ? x * 7.787f + 0.13793103448275862f : ::cbrtf(x)); } __device__ static float splineInterpolate(float x, const float* tab, int n) { int ix = ::min(::max(int(x), 0), n-1); x -= ix; tab += ix * 4; return ((tab[3] * x + tab[2]) * x + tab[1]) * x + tab[0]; } template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { const int Lscale = (116 * 255 + 50) / 100; const int Lshift = -((16 * 255 * (1 << lab_shift2) + 50) / 100); int B = blueIdx == 0 ? src.x : src.z; int G = src.y; int R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = c_sRGBGammaTab_b[B]; G = c_sRGBGammaTab_b[G]; R = c_sRGBGammaTab_b[R]; } else { B <<= 3; G <<= 3; R <<= 3; } int fX = LabCbrt_b(CV_CUDEV_DESCALE(B * 778 + G * 1541 + R * 1777, lab_shift)); int fY = LabCbrt_b(CV_CUDEV_DESCALE(B * 296 + G * 2929 + R * 871, lab_shift)); int fZ = LabCbrt_b(CV_CUDEV_DESCALE(B * 3575 + G * 448 + R * 73, lab_shift)); int L = CV_CUDEV_DESCALE(Lscale * fY + Lshift, lab_shift2); int a = CV_CUDEV_DESCALE(500 * (fX - fY) + 128 * (1 << lab_shift2), lab_shift2); int b = CV_CUDEV_DESCALE(200 * (fY - fZ) + 128 * (1 << lab_shift2), lab_shift2); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(L); dst.y = saturate_cast<uchar>(a); dst.z = saturate_cast<uchar>(b); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Lab<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _1_3 = 1.0f / 3.0f; const float _a = 16.0f / 116.0f; float B = blueIdx == 0 ? src.x : src.z; float G = src.y; float R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); } float X = B * 0.189828f + G * 0.376219f + R * 0.433953f; float Y = B * 0.072169f + G * 0.715160f + R * 0.212671f; float Z = B * 0.872766f + G * 0.109477f + R * 0.017758f; float FX = X > 0.008856f ? ::powf(X, _1_3) : (7.787f * X + _a); float FY = Y > 0.008856f ? ::powf(Y, _1_3) : (7.787f * Y + _a); float FZ = Z > 0.008856f ? ::powf(Z, _1_3) : (7.787f * Z + _a); float L = Y > 0.008856f ? (116.f * FY - 16.f) : (903.3f * Y); float a = 500.f * (FX - FY); float b = 200.f * (FY - FZ); typename MakeVec<float, dcn>::type dst; dst.x = L; dst.y = a; dst.z = b; return dst; } }; // Lab to RGB static __constant__ float c_sRGBInvGammaTab[] = {0,0.0126255,0.,-8.33961e-06,0.0126172,0.0126005,-2.50188e-05,4.1698e-05,0.0252344,0.0126756,0.000100075,-0.000158451,0.0378516,0.0124004,-0.000375277,-0.000207393,0.0496693,0.0110276,-0.000997456,0.00016837,0.0598678,0.00953783,-0.000492346,2.07235e-05,0.068934,0.00861531,-0.000430176,3.62876e-05,0.0771554,0.00786382,-0.000321313,1.87625e-05,0.0847167,0.00727748,-0.000265025,1.53594e-05,0.0917445,0.00679351,-0.000218947,1.10545e-05,0.0983301,0.00638877,-0.000185784,8.66984e-06,0.104542,0.00604322,-0.000159774,6.82996e-06,0.110432,0.00574416,-0.000139284,5.51008e-06,0.116042,0.00548212,-0.000122754,4.52322e-06,0.121406,0.00525018,-0.000109184,3.75557e-06,0.126551,0.00504308,-9.79177e-05,3.17134e-06,0.131499,0.00485676,-8.84037e-05,2.68469e-06,0.13627,0.004688,-8.03496e-05,2.31725e-06,0.14088,0.00453426,-7.33978e-05,2.00868e-06,0.145343,0.00439349,-6.73718e-05,1.74775e-06,0.149671,0.00426399,-6.21286e-05,1.53547e-06,0.153875,0.00414434,-5.75222e-05,1.364e-06,0.157963,0.00403338,-5.34301e-05,1.20416e-06,0.161944,0.00393014,-4.98177e-05,1.09114e-06,0.165825,0.00383377,-4.65443e-05,9.57987e-07,0.169613,0.00374356,-4.36703e-05,8.88359e-07,0.173314,0.00365888,-4.10052e-05,7.7849e-07,0.176933,0.00357921,-3.86697e-05,7.36254e-07,0.180474,0.00350408,-3.6461e-05,6.42534e-07,0.183942,0.00343308,-3.45334e-05,6.12614e-07,0.187342,0.00336586,-3.26955e-05,5.42894e-07,0.190675,0.00330209,-3.10669e-05,5.08967e-07,0.193947,0.00324149,-2.954e-05,4.75977e-07,0.197159,0.00318383,-2.8112e-05,4.18343e-07,0.200315,0.00312887,-2.6857e-05,4.13651e-07,0.203418,0.00307639,-2.5616e-05,3.70847e-07,0.206469,0.00302627,-2.45035e-05,3.3813e-07,0.209471,0.00297828,-2.34891e-05,3.32999e-07,0.212426,0.0029323,-2.24901e-05,2.96826e-07,0.215336,0.00288821,-2.15996e-05,2.82736e-07,0.218203,0.00284586,-2.07514e-05,2.70961e-07,0.221029,0.00280517,-1.99385e-05,2.42744e-07,0.223814,0.00276602,-1.92103e-05,2.33277e-07,0.226561,0.0027283,-1.85105e-05,2.2486e-07,0.229271,0.00269195,-1.78359e-05,2.08383e-07,0.231945,0.00265691,-1.72108e-05,1.93305e-07,0.234585,0.00262307,-1.66308e-05,1.80687e-07,0.237192,0.00259035,-1.60888e-05,1.86632e-07,0.239766,0.00255873,-1.55289e-05,1.60569e-07,0.24231,0.00252815,-1.50472e-05,1.54566e-07,0.244823,0.00249852,-1.45835e-05,1.59939e-07,0.247307,0.00246983,-1.41037e-05,1.29549e-07,0.249763,0.00244202,-1.3715e-05,1.41429e-07,0.252191,0.00241501,-1.32907e-05,1.39198e-07,0.254593,0.00238885,-1.28731e-05,1.06444e-07,0.256969,0.00236342,-1.25538e-05,1.2048e-07,0.25932,0.00233867,-1.21924e-05,1.26892e-07,0.261647,0.00231467,-1.18117e-05,8.72084e-08,0.26395,0.00229131,-1.15501e-05,1.20323e-07,0.26623,0.00226857,-1.11891e-05,8.71514e-08,0.268487,0.00224645,-1.09276e-05,9.73165e-08,0.270723,0.00222489,-1.06357e-05,8.98259e-08,0.272937,0.00220389,-1.03662e-05,7.98218e-08,0.275131,0.00218339,-1.01267e-05,9.75254e-08,0.277304,0.00216343,-9.83416e-06,6.65195e-08,0.279458,0.00214396,-9.63461e-06,8.34313e-08,0.281592,0.00212494,-9.38431e-06,7.65919e-08,0.283708,0.00210641,-9.15454e-06,5.7236e-08,0.285805,0.00208827,-8.98283e-06,8.18939e-08,0.287885,0.00207055,-8.73715e-06,6.2224e-08,0.289946,0.00205326,-8.55047e-06,5.66388e-08,0.291991,0.00203633,-8.38056e-06,6.88491e-08,0.294019,0.00201978,-8.17401e-06,5.53955e-08,0.296031,0.00200359,-8.00782e-06,6.71971e-08,0.298027,0.00198778,-7.80623e-06,3.34439e-08,0.300007,0.00197227,-7.7059e-06,6.7248e-08,0.301971,0.00195706,-7.50416e-06,5.51915e-08,0.303921,0.00194221,-7.33858e-06,3.98124e-08,0.305856,0.00192766,-7.21915e-06,5.37795e-08,0.307776,0.00191338,-7.05781e-06,4.30919e-08,0.309683,0.00189939,-6.92853e-06,4.20744e-08,0.311575,0.00188566,-6.80231e-06,5.68321e-08,0.313454,0.00187223,-6.63181e-06,2.86195e-08,0.31532,0.00185905,-6.54595e-06,3.73075e-08,0.317172,0.00184607,-6.43403e-06,6.05684e-08,0.319012,0.00183338,-6.25233e-06,1.84426e-08,0.320839,0.00182094,-6.197e-06,4.44757e-08,0.322654,0.00180867,-6.06357e-06,4.20729e-08,0.324456,0.00179667,-5.93735e-06,2.56511e-08,0.326247,0.00178488,-5.8604e-06,3.41368e-08,0.328026,0.00177326,-5.75799e-06,4.64177e-08,0.329794,0.00176188,-5.61874e-06,1.86107e-08,0.33155,0.0017507,-5.5629e-06,2.81511e-08,0.333295,0.00173966,-5.47845e-06,4.75987e-08,0.335029,0.00172884,-5.33565e-06,1.98726e-08,0.336753,0.00171823,-5.27604e-06,2.19226e-08,0.338466,0.00170775,-5.21027e-06,4.14483e-08,0.340169,0.00169745,-5.08592e-06,2.09017e-08,0.341861,0.00168734,-5.02322e-06,2.39561e-08,0.343543,0.00167737,-4.95135e-06,3.22852e-08,0.345216,0.00166756,-4.85449e-06,2.57173e-08,0.346878,0.00165793,-4.77734e-06,1.38569e-08,0.348532,0.00164841,-4.73577e-06,3.80634e-08,0.350175,0.00163906,-4.62158e-06,1.27043e-08,0.35181,0.00162985,-4.58347e-06,3.03279e-08,0.353435,0.00162078,-4.49249e-06,1.49961e-08,0.355051,0.00161184,-4.4475e-06,2.88977e-08,0.356659,0.00160303,-4.3608e-06,1.84241e-08,0.358257,0.00159436,-4.30553e-06,1.6616e-08,0.359848,0.0015858,-4.25568e-06,3.43218e-08,0.361429,0.00157739,-4.15272e-06,-4.89172e-09,0.363002,0.00156907,-4.16739e-06,4.48498e-08,0.364567,0.00156087,-4.03284e-06,4.30676e-09,0.366124,0.00155282,-4.01992e-06,2.73303e-08,0.367673,0.00154486,-3.93793e-06,5.58036e-09,0.369214,0.001537,-3.92119e-06,3.97554e-08,0.370747,0.00152928,-3.80193e-06,-1.55904e-08,0.372272,0.00152163,-3.8487e-06,5.24081e-08,0.37379,0.00151409,-3.69147e-06,-1.52272e-08,0.375301,0.00150666,-3.73715e-06,3.83028e-08,0.376804,0.0014993,-3.62225e-06,1.10278e-08,0.378299,0.00149209,-3.58916e-06,6.99326e-09,0.379788,0.00148493,-3.56818e-06,2.06038e-08,0.381269,0.00147786,-3.50637e-06,2.98009e-08,0.382744,0.00147093,-3.41697e-06,-2.05978e-08,0.384211,0.00146404,-3.47876e-06,5.25899e-08,0.385672,0.00145724,-3.32099e-06,-1.09471e-08,0.387126,0.00145056,-3.35383e-06,2.10009e-08,0.388573,0.00144392,-3.29083e-06,1.63501e-08,0.390014,0.00143739,-3.24178e-06,3.00641e-09,0.391448,0.00143091,-3.23276e-06,3.12282e-08,0.392875,0.00142454,-3.13908e-06,-8.70932e-09,0.394297,0.00141824,-3.16521e-06,3.34114e-08,0.395712,0.00141201,-3.06497e-06,-5.72754e-09,0.397121,0.00140586,-3.08215e-06,1.9301e-08,0.398524,0.00139975,-3.02425e-06,1.7931e-08,0.39992,0.00139376,-2.97046e-06,-1.61822e-09,0.401311,0.00138781,-2.97531e-06,1.83442e-08,0.402696,0.00138192,-2.92028e-06,1.76485e-08,0.404075,0.00137613,-2.86733e-06,4.68617e-10,0.405448,0.00137039,-2.86593e-06,1.02794e-08,0.406816,0.00136469,-2.83509e-06,1.80179e-08,0.408178,0.00135908,-2.78104e-06,7.05594e-09,0.409534,0.00135354,-2.75987e-06,1.33633e-08,0.410885,0.00134806,-2.71978e-06,-9.04568e-10,0.41223,0.00134261,-2.72249e-06,2.0057e-08,0.41357,0.00133723,-2.66232e-06,1.00841e-08,0.414905,0.00133194,-2.63207e-06,-7.88835e-10,0.416234,0.00132667,-2.63444e-06,2.28734e-08,0.417558,0.00132147,-2.56582e-06,-1.29785e-09,0.418877,0.00131633,-2.56971e-06,1.21205e-08,0.420191,0.00131123,-2.53335e-06,1.24202e-08,0.421499,0.0013062,-2.49609e-06,-2.19681e-09,0.422803,0.0013012,-2.50268e-06,2.61696e-08,0.424102,0.00129628,-2.42417e-06,-1.30747e-08,0.425396,0.00129139,-2.46339e-06,2.6129e-08,0.426685,0.00128654,-2.38501e-06,-2.03454e-09,0.427969,0.00128176,-2.39111e-06,1.18115e-08,0.429248,0.00127702,-2.35567e-06,1.43932e-08,0.430523,0.00127235,-2.31249e-06,-9.77965e-09,0.431793,0.00126769,-2.34183e-06,2.47253e-08,0.433058,0.00126308,-2.26766e-06,2.85278e-10,0.434319,0.00125855,-2.2668e-06,3.93614e-09,0.435575,0.00125403,-2.25499e-06,1.37722e-08,0.436827,0.00124956,-2.21368e-06,5.79803e-10,0.438074,0.00124513,-2.21194e-06,1.37112e-08,0.439317,0.00124075,-2.1708e-06,4.17973e-09,0.440556,0.00123642,-2.15826e-06,-6.27703e-10,0.44179,0.0012321,-2.16015e-06,2.81332e-08,0.44302,0.00122787,-2.07575e-06,-2.24985e-08,0.444246,0.00122365,-2.14324e-06,3.20586e-08,0.445467,0.00121946,-2.04707e-06,-1.6329e-08,0.446685,0.00121532,-2.09605e-06,3.32573e-08,0.447898,0.00121122,-1.99628e-06,-2.72927e-08,0.449107,0.00120715,-2.07816e-06,4.6111e-08,0.450312,0.00120313,-1.93983e-06,-3.79416e-08,0.451514,0.00119914,-2.05365e-06,4.60507e-08,0.452711,0.00119517,-1.9155e-06,-2.7052e-08,0.453904,0.00119126,-1.99666e-06,3.23551e-08,0.455093,0.00118736,-1.89959e-06,-1.29613e-08,0.456279,0.00118352,-1.93848e-06,1.94905e-08,0.45746,0.0011797,-1.88e-06,-5.39588e-09,0.458638,0.00117593,-1.89619e-06,2.09282e-09,0.459812,0.00117214,-1.88991e-06,2.68267e-08,0.460982,0.00116844,-1.80943e-06,-1.99925e-08,0.462149,0.00116476,-1.86941e-06,2.3341e-08,0.463312,0.00116109,-1.79939e-06,-1.37674e-08,0.464471,0.00115745,-1.84069e-06,3.17287e-08,0.465627,0.00115387,-1.7455e-06,-2.37407e-08,0.466779,0.00115031,-1.81673e-06,3.34315e-08,0.467927,0.00114677,-1.71643e-06,-2.05786e-08,0.469073,0.00114328,-1.77817e-06,1.90802e-08,0.470214,0.00113978,-1.72093e-06,3.86247e-09,0.471352,0.00113635,-1.70934e-06,-4.72759e-09,0.472487,0.00113292,-1.72352e-06,1.50478e-08,0.473618,0.00112951,-1.67838e-06,4.14108e-09,0.474746,0.00112617,-1.66595e-06,-1.80986e-09,0.47587,0.00112283,-1.67138e-06,3.09816e-09,0.476991,0.0011195,-1.66209e-06,1.92198e-08,0.478109,0.00111623,-1.60443e-06,-2.03726e-08,0.479224,0.00111296,-1.66555e-06,3.2468e-08,0.480335,0.00110973,-1.56814e-06,-2.00922e-08,0.481443,0.00110653,-1.62842e-06,1.80983e-08,0.482548,0.00110333,-1.57413e-06,7.30362e-09,0.48365,0.0011002,-1.55221e-06,-1.75107e-08,0.484749,0.00109705,-1.60475e-06,3.29373e-08,0.485844,0.00109393,-1.50594e-06,-2.48315e-08,0.486937,0.00109085,-1.58043e-06,3.65865e-08,0.488026,0.0010878,-1.47067e-06,-3.21078e-08,0.489112,0.00108476,-1.56699e-06,3.22397e-08,0.490195,0.00108172,-1.47027e-06,-7.44391e-09,0.491276,0.00107876,-1.49261e-06,-2.46428e-09,0.492353,0.00107577,-1.5e-06,1.73011e-08,0.493427,0.00107282,-1.4481e-06,-7.13552e-09,0.494499,0.0010699,-1.4695e-06,1.1241e-08,0.495567,0.001067,-1.43578e-06,-8.02637e-09,0.496633,0.0010641,-1.45986e-06,2.08645e-08,0.497695,0.00106124,-1.39726e-06,-1.58271e-08,0.498755,0.0010584,-1.44475e-06,1.26415e-08,0.499812,0.00105555,-1.40682e-06,2.48655e-08,0.500866,0.00105281,-1.33222e-06,-5.24988e-08,0.501918,0.00104999,-1.48972e-06,6.59206e-08,0.502966,0.00104721,-1.29196e-06,-3.237e-08,0.504012,0.00104453,-1.38907e-06,3.95479e-09,0.505055,0.00104176,-1.3772e-06,1.65509e-08,0.506096,0.00103905,-1.32755e-06,-1.05539e-08,0.507133,0.00103637,-1.35921e-06,2.56648e-08,0.508168,0.00103373,-1.28222e-06,-3.25007e-08,0.509201,0.00103106,-1.37972e-06,4.47336e-08,0.51023,0.00102844,-1.24552e-06,-2.72245e-08,0.511258,0.00102587,-1.32719e-06,4.55952e-09,0.512282,0.00102323,-1.31352e-06,8.98645e-09,0.513304,0.00102063,-1.28656e-06,1.90992e-08,0.514323,0.00101811,-1.22926e-06,-2.57786e-08,0.51534,0.00101557,-1.30659e-06,2.44104e-08,0.516355,0.00101303,-1.23336e-06,-1.22581e-08,0.517366,0.00101053,-1.27014e-06,2.4622e-08,0.518376,0.00100806,-1.19627e-06,-2.66253e-08,0.519383,0.00100559,-1.27615e-06,2.22744e-08,0.520387,0.00100311,-1.20932e-06,-2.8679e-09,0.521389,0.00100068,-1.21793e-06,-1.08029e-08,0.522388,0.000998211,-1.25034e-06,4.60795e-08,0.523385,0.000995849,-1.1121e-06,-5.4306e-08,0.52438,0.000993462,-1.27502e-06,5.19354e-08,0.525372,0.000991067,-1.11921e-06,-3.42262e-08,0.526362,0.000988726,-1.22189e-06,2.53646e-08,0.52735,0.000986359,-1.14579e-06,-7.62782e-09,0.528335,0.000984044,-1.16868e-06,5.14668e-09,0.529318,0.000981722,-1.15324e-06,-1.29589e-08,0.530298,0.000979377,-1.19211e-06,4.66888e-08,0.531276,0.000977133,-1.05205e-06,-5.45868e-08,0.532252,0.000974865,-1.21581e-06,5.24495e-08,0.533226,0.000972591,-1.05846e-06,-3.60019e-08,0.534198,0.000970366,-1.16647e-06,3.19537e-08,0.535167,0.000968129,-1.07061e-06,-3.2208e-08,0.536134,0.000965891,-1.16723e-06,3.72738e-08,0.537099,0.000963668,-1.05541e-06,2.32205e-09,0.538061,0.000961564,-1.04844e-06,-4.65618e-08,0.539022,0.000959328,-1.18813e-06,6.47159e-08,0.53998,0.000957146,-9.93979e-07,-3.3488e-08,0.540936,0.000955057,-1.09444e-06,9.63166e-09,0.54189,0.000952897,-1.06555e-06,-5.03871e-09,0.542842,0.000950751,-1.08066e-06,1.05232e-08,0.543792,0.000948621,-1.04909e-06,2.25503e-08,0.544739,0.000946591,-9.81444e-07,-4.11195e-08,0.545685,0.000944504,-1.1048e-06,2.27182e-08,0.546628,0.000942363,-1.03665e-06,9.85146e-09,0.54757,0.000940319,-1.00709e-06,-2.51938e-09,0.548509,0.000938297,-1.01465e-06,2.25858e-10,0.549446,0.000936269,-1.01397e-06,1.61598e-09,0.550381,0.000934246,-1.00913e-06,-6.68983e-09,0.551315,0.000932207,-1.0292e-06,2.51434e-08,0.552246,0.000930224,-9.53765e-07,-3.42793e-08,0.553175,0.000928214,-1.0566e-06,5.23688e-08,0.554102,0.000926258,-8.99497e-07,-5.59865e-08,0.555028,0.000924291,-1.06746e-06,5.23679e-08,0.555951,0.000922313,-9.10352e-07,-3.42763e-08,0.556872,0.00092039,-1.01318e-06,2.51326e-08,0.557792,0.000918439,-9.37783e-07,-6.64954e-09,0.558709,0.000916543,-9.57732e-07,1.46554e-09,0.559625,0.000914632,-9.53335e-07,7.87281e-10,0.560538,0.000912728,-9.50973e-07,-4.61466e-09,0.56145,0.000910812,-9.64817e-07,1.76713e-08,0.56236,0.000908935,-9.11804e-07,-6.46564e-09,0.563268,0.000907092,-9.312e-07,8.19121e-09,0.564174,0.000905255,-9.06627e-07,-2.62992e-08,0.565078,0.000903362,-9.85524e-07,3.74007e-08,0.565981,0.000901504,-8.73322e-07,-4.0942e-09,0.566882,0.000899745,-8.85605e-07,-2.1024e-08,0.56778,0.00089791,-9.48677e-07,2.85854e-08,0.568677,0.000896099,-8.62921e-07,-3.3713e-08,0.569573,0.000894272,-9.64059e-07,4.6662e-08,0.570466,0.000892484,-8.24073e-07,-3.37258e-08,0.571358,0.000890734,-9.25251e-07,2.86365e-08,0.572247,0.00088897,-8.39341e-07,-2.12155e-08,0.573135,0.000887227,-9.02988e-07,-3.37913e-09,0.574022,0.000885411,-9.13125e-07,3.47319e-08,0.574906,0.000883689,-8.08929e-07,-1.63394e-08,0.575789,0.000882022,-8.57947e-07,-2.8979e-08,0.57667,0.00088022,-9.44885e-07,7.26509e-08,0.57755,0.000878548,-7.26932e-07,-8.28106e-08,0.578427,0.000876845,-9.75364e-07,7.97774e-08,0.579303,0.000875134,-7.36032e-07,-5.74849e-08,0.580178,0.00087349,-9.08486e-07,3.09529e-08,0.58105,0.000871765,-8.15628e-07,-6.72206e-09,0.581921,0.000870114,-8.35794e-07,-4.06451e-09,0.582791,0.00086843,-8.47987e-07,2.29799e-08,0.583658,0.000866803,-7.79048e-07,-2.82503e-08,0.584524,0.00086516,-8.63799e-07,3.04167e-08,0.585388,0.000863524,-7.72548e-07,-3.38119e-08,0.586251,0.000861877,-8.73984e-07,4.52264e-08,0.587112,0.000860265,-7.38305e-07,-2.78842e-08,0.587972,0.000858705,-8.21958e-07,6.70567e-09,0.58883,0.000857081,-8.01841e-07,1.06161e-09,0.589686,0.000855481,-7.98656e-07,-1.09521e-08,0.590541,0.00085385,-8.31512e-07,4.27468e-08,0.591394,0.000852316,-7.03272e-07,-4.08257e-08,0.592245,0.000850787,-8.25749e-07,1.34677e-09,0.593095,0.000849139,-8.21709e-07,3.54387e-08,0.593944,0.000847602,-7.15393e-07,-2.38924e-08,0.59479,0.0008461,-7.8707e-07,5.26143e-10,0.595636,0.000844527,-7.85491e-07,2.17879e-08,0.596479,0.000843021,-7.20127e-07,-2.80733e-08,0.597322,0.000841497,-8.04347e-07,3.09005e-08,0.598162,0.000839981,-7.11646e-07,-3.5924e-08,0.599002,0.00083845,-8.19418e-07,5.3191e-08,0.599839,0.000836971,-6.59845e-07,-5.76307e-08,0.600676,0.000835478,-8.32737e-07,5.81227e-08,0.60151,0.000833987,-6.58369e-07,-5.56507e-08,0.602344,0.000832503,-8.25321e-07,4.52706e-08,0.603175,0.000830988,-6.89509e-07,-6.22236e-09,0.604006,0.000829591,-7.08176e-07,-2.03811e-08,0.604834,0.000828113,-7.6932e-07,2.8142e-08,0.605662,0.000826659,-6.84894e-07,-3.25822e-08,0.606488,0.000825191,-7.8264e-07,4.25823e-08,0.607312,0.000823754,-6.54893e-07,-1.85376e-08,0.608135,0.000822389,-7.10506e-07,-2.80365e-08,0.608957,0.000820883,-7.94616e-07,7.1079e-08,0.609777,0.000819507,-5.81379e-07,-7.74655e-08,0.610596,0.000818112,-8.13775e-07,5.9969e-08,0.611413,0.000816665,-6.33868e-07,-4.32013e-08,0.612229,0.000815267,-7.63472e-07,5.32313e-08,0.613044,0.0008139,-6.03778e-07,-5.05148e-08,0.613857,0.000812541,-7.55323e-07,2.96187e-08,0.614669,0.000811119,-6.66466e-07,-8.35545e-09,0.615479,0.000809761,-6.91533e-07,3.80301e-09,0.616288,0.00080839,-6.80124e-07,-6.85666e-09,0.617096,0.000807009,-7.00694e-07,2.36237e-08,0.617903,0.000805678,-6.29822e-07,-2.80336e-08,0.618708,0.000804334,-7.13923e-07,2.8906e-08,0.619511,0.000802993,-6.27205e-07,-2.79859e-08,0.620314,0.000801655,-7.11163e-07,2.34329e-08,0.621114,0.000800303,-6.40864e-07,-6.14108e-09,0.621914,0.000799003,-6.59287e-07,1.13151e-09,0.622712,0.000797688,-6.55893e-07,1.61507e-09,0.62351,0.000796381,-6.51048e-07,-7.59186e-09,0.624305,0.000795056,-6.73823e-07,2.87524e-08,0.6251,0.000793794,-5.87566e-07,-4.7813e-08,0.625893,0.000792476,-7.31005e-07,4.32901e-08,0.626685,0.000791144,-6.01135e-07,-6.13814e-09,0.627475,0.000789923,-6.19549e-07,-1.87376e-08,0.628264,0.000788628,-6.75762e-07,2.14837e-08,0.629052,0.000787341,-6.11311e-07,-7.59265e-09,0.629839,0.000786095,-6.34089e-07,8.88692e-09,0.630625,0.000784854,-6.07428e-07,-2.7955e-08,0.631409,0.000783555,-6.91293e-07,4.33285e-08,0.632192,0.000782302,-5.61307e-07,-2.61497e-08,0.632973,0.000781101,-6.39757e-07,1.6658e-09,0.633754,0.000779827,-6.34759e-07,1.94866e-08,0.634533,0.000778616,-5.76299e-07,-2.00076e-08,0.635311,0.000777403,-6.36322e-07,9.39091e-10,0.636088,0.000776133,-6.33505e-07,1.62512e-08,0.636863,0.000774915,-5.84751e-07,-6.33937e-09,0.637638,0.000773726,-6.03769e-07,9.10609e-09,0.638411,0.000772546,-5.76451e-07,-3.00849e-08,0.639183,0.000771303,-6.66706e-07,5.1629e-08,0.639953,0.000770125,-5.11819e-07,-5.7222e-08,0.640723,0.000768929,-6.83485e-07,5.80497e-08,0.641491,0.000767736,-5.09336e-07,-5.57674e-08,0.642259,0.000766551,-6.76638e-07,4.58105e-08,0.643024,0.000765335,-5.39206e-07,-8.26541e-09,0.643789,0.000764231,-5.64002e-07,-1.27488e-08,0.644553,0.000763065,-6.02249e-07,-3.44168e-10,0.645315,0.00076186,-6.03281e-07,1.41254e-08,0.646077,0.000760695,-5.60905e-07,3.44727e-09,0.646837,0.000759584,-5.50563e-07,-2.79144e-08,0.647596,0.000758399,-6.34307e-07,4.86057e-08,0.648354,0.000757276,-4.88489e-07,-4.72989e-08,0.64911,0.000756158,-6.30386e-07,2.13807e-08,0.649866,0.000754961,-5.66244e-07,2.13808e-08,0.65062,0.000753893,-5.02102e-07,-4.7299e-08,0.651374,0.000752746,-6.43999e-07,4.86059e-08,0.652126,0.000751604,-4.98181e-07,-2.79154e-08,0.652877,0.000750524,-5.81927e-07,3.45089e-09,0.653627,0.000749371,-5.71575e-07,1.41119e-08,0.654376,0.00074827,-5.29239e-07,-2.93748e-10,0.655123,0.00074721,-5.3012e-07,-1.29368e-08,0.65587,0.000746111,-5.68931e-07,-7.56355e-09,0.656616,0.000744951,-5.91621e-07,4.3191e-08,0.65736,0.000743897,-4.62048e-07,-4.59911e-08,0.658103,0.000742835,-6.00022e-07,2.15642e-08,0.658846,0.0007417,-5.35329e-07,1.93389e-08,0.659587,0.000740687,-4.77312e-07,-3.93152e-08,0.660327,0.000739615,-5.95258e-07,1.87126e-08,0.661066,0.00073848,-5.3912e-07,2.40695e-08,0.661804,0.000737474,-4.66912e-07,-5.53859e-08,0.662541,0.000736374,-6.33069e-07,7.82648e-08,0.663277,0.000735343,-3.98275e-07,-7.88593e-08,0.664012,0.00073431,-6.34853e-07,5.83585e-08,0.664745,0.000733215,-4.59777e-07,-3.53656e-08,0.665478,0.000732189,-5.65874e-07,2.34994e-08,0.66621,0.000731128,-4.95376e-07,9.72743e-10,0.66694,0.00073014,-4.92458e-07,-2.73903e-08,0.66767,0.000729073,-5.74629e-07,4.89839e-08,0.668398,0.000728071,-4.27677e-07,-4.93359e-08,0.669126,0.000727068,-5.75685e-07,2.91504e-08,0.669853,0.000726004,-4.88234e-07,-7.66109e-09,0.670578,0.000725004,-5.11217e-07,1.49392e-09,0.671303,0.000723986,-5.06735e-07,1.68533e-09,0.672026,0.000722978,-5.01679e-07,-8.23525e-09,0.672749,0.00072195,-5.26385e-07,3.12556e-08,0.67347,0.000720991,-4.32618e-07,-5.71825e-08,0.674191,0.000719954,-6.04166e-07,7.8265e-08,0.67491,0.00071898,-3.69371e-07,-7.70634e-08,0.675628,0.00071801,-6.00561e-07,5.11747e-08,0.676346,0.000716963,-4.47037e-07,-8.42615e-09,0.677062,0.000716044,-4.72315e-07,-1.747e-08,0.677778,0.000715046,-5.24725e-07,1.87015e-08,0.678493,0.000714053,-4.68621e-07,2.26856e-09,0.679206,0.000713123,-4.61815e-07,-2.77758e-08,0.679919,0.000712116,-5.45142e-07,4.92298e-08,0.68063,0.000711173,-3.97453e-07,-4.99339e-08,0.681341,0.000710228,-5.47255e-07,3.12967e-08,0.682051,0.000709228,-4.53365e-07,-1.56481e-08,0.68276,0.000708274,-5.00309e-07,3.12958e-08,0.683467,0.000707367,-4.06422e-07,-4.99303e-08,0.684174,0.000706405,-5.56213e-07,4.9216e-08,0.68488,0.00070544,-4.08565e-07,-2.77245e-08,0.685585,0.00070454,-4.91738e-07,2.07748e-09,0.686289,0.000703562,-4.85506e-07,1.94146e-08,0.686992,0.00070265,-4.27262e-07,-2.01314e-08,0.687695,0.000701735,-4.87656e-07,1.50616e-09,0.688396,0.000700764,-4.83137e-07,1.41067e-08,0.689096,0.00069984,-4.40817e-07,1.67168e-09,0.689795,0.000698963,-4.35802e-07,-2.07934e-08,0.690494,0.000698029,-4.98182e-07,2.18972e-08,0.691192,0.000697099,-4.32491e-07,-7.19092e-09,0.691888,0.000696212,-4.54064e-07,6.86642e-09,0.692584,0.000695325,-4.33464e-07,-2.02747e-08,0.693279,0.000694397,-4.94288e-07,1.46279e-08,0.693973,0.000693452,-4.50405e-07,2.13678e-08,0.694666,0.000692616,-3.86301e-07,-4.04945e-08,0.695358,0.000691721,-5.07785e-07,2.14009e-08,0.696049,0.00069077,-4.43582e-07,1.44955e-08,0.69674,0.000689926,-4.00096e-07,-1.97783e-08,0.697429,0.000689067,-4.5943e-07,5.01296e-09,0.698118,0.000688163,-4.44392e-07,-2.73521e-10,0.698805,0.000687273,-4.45212e-07,-3.91893e-09,0.699492,0.000686371,-4.56969e-07,1.59493e-08,0.700178,0.000685505,-4.09121e-07,-2.73351e-10,0.700863,0.000684686,-4.09941e-07,-1.4856e-08,0.701548,0.000683822,-4.54509e-07,9.25979e-11,0.702231,0.000682913,-4.54231e-07,1.44855e-08,0.702913,0.000682048,-4.10775e-07,1.56992e-09,0.703595,0.000681231,-4.06065e-07,-2.07652e-08,0.704276,0.000680357,-4.68361e-07,2.18864e-08,0.704956,0.000679486,-4.02701e-07,-7.17595e-09,0.705635,0.000678659,-4.24229e-07,6.81748e-09,0.706313,0.000677831,-4.03777e-07,-2.0094e-08,0.70699,0.000676963,-4.64059e-07,1.39538e-08,0.707667,0.000676077,-4.22197e-07,2.38835e-08,0.708343,0.000675304,-3.50547e-07,-4.98831e-08,0.709018,0.000674453,-5.00196e-07,5.64395e-08,0.709692,0.000673622,-3.30878e-07,-5.66657e-08,0.710365,0.00067279,-5.00875e-07,5.1014e-08,0.711037,0.000671942,-3.47833e-07,-2.81809e-08,0.711709,0.000671161,-4.32376e-07,2.10513e-09,0.712379,0.000670303,-4.2606e-07,1.97604e-08,0.713049,0.00066951,-3.66779e-07,-2.15422e-08,0.713718,0.000668712,-4.31406e-07,6.8038e-09,0.714387,0.000667869,-4.10994e-07,-5.67295e-09,0.715054,0.00066703,-4.28013e-07,1.5888e-08,0.715721,0.000666222,-3.80349e-07,1.72576e-09,0.716387,0.000665467,-3.75172e-07,-2.27911e-08,0.717052,0.000664648,-4.43545e-07,2.9834e-08,0.717716,0.00066385,-3.54043e-07,-3.69401e-08,0.718379,0.000663031,-4.64864e-07,5.83219e-08,0.719042,0.000662277,-2.89898e-07,-7.71382e-08,0.719704,0.000661465,-5.21313e-07,7.14171e-08,0.720365,0.000660637,-3.07061e-07,-2.97161e-08,0.721025,0.000659934,-3.96209e-07,-1.21575e-08,0.721685,0.000659105,-4.32682e-07,1.87412e-08,0.722343,0.000658296,-3.76458e-07,-3.2029e-09,0.723001,0.000657533,-3.86067e-07,-5.9296e-09,0.723659,0.000656743,-4.03856e-07,2.69213e-08,0.724315,0.000656016,-3.23092e-07,-4.21511e-08,0.724971,0.000655244,-4.49545e-07,2.24737e-08,0.725625,0.000654412,-3.82124e-07,1.18611e-08,0.726279,0.000653683,-3.46541e-07,-1.03132e-08,0.726933,0.000652959,-3.7748e-07,-3.02128e-08,0.727585,0.000652114,-4.68119e-07,7.15597e-08,0.728237,0.000651392,-2.5344e-07,-7.72119e-08,0.728888,0.000650654,-4.85075e-07,5.8474e-08,0.729538,0.000649859,-3.09654e-07,-3.74746e-08,0.730188,0.000649127,-4.22077e-07,3.18197e-08,0.730837,0.000648379,-3.26618e-07,-3.01997e-08,0.731485,0.000647635,-4.17217e-07,2.93747e-08,0.732132,0.000646888,-3.29093e-07,-2.76943e-08,0.732778,0.000646147,-4.12176e-07,2.17979e-08,0.733424,0.000645388,-3.46783e-07,1.07292e-10,0.734069,0.000644695,-3.46461e-07,-2.22271e-08,0.734713,0.000643935,-4.13142e-07,2.91963e-08,0.735357,0.000643197,-3.25553e-07,-3.49536e-08,0.736,0.000642441,-4.30414e-07,5.10133e-08,0.736642,0.000641733,-2.77374e-07,-4.98904e-08,0.737283,0.000641028,-4.27045e-07,2.93392e-08,0.737924,0.000640262,-3.39028e-07,-7.86156e-09,0.738564,0.000639561,-3.62612e-07,2.10703e-09,0.739203,0.000638842,-3.56291e-07,-5.6653e-10,0.739842,0.000638128,-3.57991e-07,1.59086e-10,0.740479,0.000637412,-3.57513e-07,-6.98321e-11,0.741116,0.000636697,-3.57723e-07,1.20214e-10,0.741753,0.000635982,-3.57362e-07,-4.10987e-10,0.742388,0.000635266,-3.58595e-07,1.5237e-09,0.743023,0.000634553,-3.54024e-07,-5.68376e-09,0.743657,0.000633828,-3.71075e-07,2.12113e-08,0.744291,0.00063315,-3.07441e-07,-1.95569e-08,0.744924,0.000632476,-3.66112e-07,-2.58816e-09,0.745556,0.000631736,-3.73877e-07,2.99096e-08,0.746187,0.000631078,-2.84148e-07,-5.74454e-08,0.746818,0.000630337,-4.56484e-07,8.06629e-08,0.747448,0.000629666,-2.14496e-07,-8.63922e-08,0.748077,0.000628978,-4.73672e-07,8.60918e-08,0.748706,0.000628289,-2.15397e-07,-7.91613e-08,0.749334,0.000627621,-4.5288e-07,5.17393e-08,0.749961,0.00062687,-2.97663e-07,-8.58662e-09,0.750588,0.000626249,-3.23422e-07,-1.73928e-08,0.751214,0.00062555,-3.75601e-07,1.85532e-08,0.751839,0.000624855,-3.19941e-07,2.78479e-09,0.752463,0.000624223,-3.11587e-07,-2.96923e-08,0.753087,0.000623511,-4.00664e-07,5.63799e-08,0.75371,0.000622879,-2.31524e-07,-7.66179e-08,0.754333,0.000622186,-4.61378e-07,7.12778e-08,0.754955,0.000621477,-2.47545e-07,-2.96794e-08,0.755576,0.000620893,-3.36583e-07,-1.21648e-08,0.756196,0.000620183,-3.73077e-07,1.87339e-08,0.756816,0.000619493,-3.16875e-07,-3.16622e-09,0.757435,0.00061885,-3.26374e-07,-6.0691e-09,0.758054,0.000618179,-3.44581e-07,2.74426e-08,0.758672,0.000617572,-2.62254e-07,-4.40968e-08,0.759289,0.000616915,-3.94544e-07,2.97352e-08,0.759906,0.000616215,-3.05338e-07,-1.52393e-08,0.760522,0.000615559,-3.51056e-07,3.12221e-08,0.761137,0.000614951,-2.5739e-07,-5.00443e-08,0.761751,0.000614286,-4.07523e-07,4.9746e-08,0.762365,0.00061362,-2.58285e-07,-2.97303e-08,0.762979,0.000613014,-3.47476e-07,9.57079e-09,0.763591,0.000612348,-3.18764e-07,-8.55287e-09,0.764203,0.000611685,-3.44422e-07,2.46407e-08,0.764815,0.00061107,-2.705e-07,-3.04053e-08,0.765426,0.000610437,-3.61716e-07,3.73759e-08,0.766036,0.000609826,-2.49589e-07,-5.94935e-08,0.766645,0.000609149,-4.28069e-07,8.13889e-08,0.767254,0.000608537,-1.83902e-07,-8.72483e-08,0.767862,0.000607907,-4.45647e-07,8.87901e-08,0.76847,0.000607282,-1.79277e-07,-8.90983e-08,0.769077,0.000606656,-4.46572e-07,8.87892e-08,0.769683,0.000606029,-1.80204e-07,-8.72446e-08,0.770289,0.000605407,-4.41938e-07,8.13752e-08,0.770894,0.000604768,-1.97812e-07,-5.94423e-08,0.771498,0.000604194,-3.76139e-07,3.71848e-08,0.772102,0.000603553,-2.64585e-07,-2.96922e-08,0.772705,0.000602935,-3.53661e-07,2.19793e-08,0.773308,0.000602293,-2.87723e-07,1.37955e-09,0.77391,0.000601722,-2.83585e-07,-2.74976e-08,0.774512,0.000601072,-3.66077e-07,4.9006e-08,0.775112,0.000600487,-2.19059e-07,-4.93171e-08,0.775712,0.000599901,-3.67011e-07,2.90531e-08,0.776312,0.000599254,-2.79851e-07,-7.29081e-09,0.776911,0.000598673,-3.01724e-07,1.10077e-10,0.777509,0.00059807,-3.01393e-07,6.85053e-09,0.778107,0.000597487,-2.80842e-07,-2.75123e-08,0.778704,0.000596843,-3.63379e-07,4.35939e-08,0.779301,0.000596247,-2.32597e-07,-2.7654e-08,0.779897,0.000595699,-3.15559e-07,7.41741e-09,0.780492,0.00059509,-2.93307e-07,-2.01562e-09,0.781087,0.000594497,-2.99354e-07,6.45059e-10,0.781681,0.000593901,-2.97418e-07,-5.64635e-10,0.782275,0.000593304,-2.99112e-07,1.61347e-09,0.782868,0.000592711,-2.94272e-07,-5.88926e-09,0.78346,0.000592105,-3.1194e-07,2.19436e-08,0.784052,0.000591546,-2.46109e-07,-2.22805e-08,0.784643,0.000590987,-3.1295e-07,7.57368e-09,0.785234,0.000590384,-2.90229e-07,-8.01428e-09,0.785824,0.00058978,-3.14272e-07,2.44834e-08,0.786414,0.000589225,-2.40822e-07,-3.03148e-08,0.787003,0.000588652,-3.31766e-07,3.7171e-08,0.787591,0.0005881,-2.20253e-07,-5.87646e-08,0.788179,0.000587483,-3.96547e-07,7.86782e-08,0.788766,0.000586926,-1.60512e-07,-7.71342e-08,0.789353,0.000586374,-3.91915e-07,5.10444e-08,0.789939,0.000585743,-2.38782e-07,-7.83422e-09,0.790524,0.000585242,-2.62284e-07,-1.97076e-08,0.791109,0.000584658,-3.21407e-07,2.70598e-08,0.791693,0.000584097,-2.40228e-07,-2.89269e-08,0.792277,0.000583529,-3.27008e-07,2.90431e-08,0.792861,0.000582963,-2.39879e-07,-2.76409e-08,0.793443,0.0005824,-3.22802e-07,2.1916e-08,0.794025,0.00058182,-2.57054e-07,-4.18368e-10,0.794607,0.000581305,-2.58309e-07,-2.02425e-08,0.795188,0.000580727,-3.19036e-07,2.17838e-08,0.795768,0.000580155,-2.53685e-07,-7.28814e-09,0.796348,0.000579625,-2.75549e-07,7.36871e-09,0.796928,0.000579096,-2.53443e-07,-2.21867e-08,0.797506,0.000578523,-3.20003e-07,2.17736e-08,0.798085,0.000577948,-2.54683e-07,-5.30296e-09,0.798662,0.000577423,-2.70592e-07,-5.61698e-10,0.799239,0.00057688,-2.72277e-07,7.54977e-09,0.799816,0.000576358,-2.49627e-07,-2.96374e-08,0.800392,0.00057577,-3.38539e-07,5.1395e-08,0.800968,0.000575247,-1.84354e-07,-5.67335e-08,0.801543,0.000574708,-3.54555e-07,5.63297e-08,0.802117,0.000574168,-1.85566e-07,-4.93759e-08,0.802691,0.000573649,-3.33693e-07,2.19646e-08,0.803264,0.000573047,-2.678e-07,2.1122e-08,0.803837,0.000572575,-2.04433e-07,-4.68482e-08,0.804409,0.000572026,-3.44978e-07,4.70613e-08,0.804981,0.000571477,-2.03794e-07,-2.21877e-08,0.805552,0.000571003,-2.70357e-07,-1.79153e-08,0.806123,0.000570408,-3.24103e-07,3.42443e-08,0.806693,0.000569863,-2.2137e-07,1.47556e-10,0.807263,0.000569421,-2.20928e-07,-3.48345e-08,0.807832,0.000568874,-3.25431e-07,1.99812e-08,0.808401,0.000568283,-2.65487e-07,1.45143e-08,0.808969,0.000567796,-2.21945e-07,-1.84338e-08,0.809536,0.000567297,-2.77246e-07,-3.83608e-10,0.810103,0.000566741,-2.78397e-07,1.99683e-08,0.81067,0.000566244,-2.18492e-07,-1.98848e-08,0.811236,0.000565747,-2.78146e-07,-3.38976e-11,0.811801,0.000565191,-2.78248e-07,2.00204e-08,0.812366,0.000564695,-2.18187e-07,-2.04429e-08,0.812931,0.000564197,-2.79516e-07,2.1467e-09,0.813495,0.000563644,-2.73076e-07,1.18561e-08,0.814058,0.000563134,-2.37507e-07,1.00334e-08,0.814621,0.000562689,-2.07407e-07,-5.19898e-08,0.815183,0.000562118,-3.63376e-07,7.87163e-08,0.815745,0.000561627,-1.27227e-07,-8.40616e-08,0.816306,0.000561121,-3.79412e-07,7.87163e-08,0.816867,0.000560598,-1.43263e-07,-5.19898e-08,0.817428,0.000560156,-2.99233e-07,1.00335e-08,0.817988,0.000559587,-2.69132e-07,1.18559e-08,0.818547,0.000559085,-2.33564e-07,2.14764e-09,0.819106,0.000558624,-2.27122e-07,-2.04464e-08,0.819664,0.000558108,-2.88461e-07,2.00334e-08,0.820222,0.000557591,-2.28361e-07,-8.24277e-11,0.820779,0.000557135,-2.28608e-07,-1.97037e-08,0.821336,0.000556618,-2.87719e-07,1.92925e-08,0.821893,0.000556101,-2.29841e-07,2.13831e-09,0.822448,0.000555647,-2.23427e-07,-2.78458e-08,0.823004,0.000555117,-3.06964e-07,4.96402e-08,0.823559,0.000554652,-1.58043e-07,-5.15058e-08,0.824113,0.000554181,-3.12561e-07,3.71737e-08,0.824667,0.000553668,-2.0104e-07,-3.75844e-08,0.82522,0.000553153,-3.13793e-07,5.35592e-08,0.825773,0.000552686,-1.53115e-07,-5.74431e-08,0.826326,0.000552207,-3.25444e-07,5.7004e-08,0.826878,0.000551728,-1.54433e-07,-5.13635e-08,0.827429,0.000551265,-3.08523e-07,2.92406e-08,0.82798,0.000550735,-2.20801e-07,-5.99424e-09,0.828531,0.000550276,-2.38784e-07,-5.26363e-09,0.829081,0.000549782,-2.54575e-07,2.70488e-08,0.82963,0.000549354,-1.73429e-07,-4.33268e-08,0.83018,0.000548878,-3.03409e-07,2.7049e-08,0.830728,0.000548352,-2.22262e-07,-5.26461e-09,0.831276,0.000547892,-2.38056e-07,-5.99057e-09,0.831824,0.000547397,-2.56027e-07,2.92269e-08,0.832371,0.000546973,-1.68347e-07,-5.13125e-08,0.832918,0.000546482,-3.22284e-07,5.68139e-08,0.833464,0.000546008,-1.51843e-07,-5.67336e-08,0.83401,0.000545534,-3.22043e-07,5.09113e-08,0.834555,0.000545043,-1.6931e-07,-2.77022e-08,0.8351,0.000544621,-2.52416e-07,2.92924e-10,0.835644,0.000544117,-2.51537e-07,2.65305e-08,0.836188,0.000543694,-1.71946e-07,-4.68105e-08,0.836732,0.00054321,-3.12377e-07,4.15021e-08,0.837275,0.000542709,-1.87871e-07,1.13355e-11,0.837817,0.000542334,-1.87837e-07,-4.15474e-08,0.838359,0.000541833,-3.12479e-07,4.69691e-08,0.838901,0.000541349,-1.71572e-07,-2.71196e-08,0.839442,0.000540925,-2.52931e-07,1.90462e-09,0.839983,0.000540425,-2.47217e-07,1.95011e-08,0.840523,0.000539989,-1.88713e-07,-2.03045e-08,0.841063,0.00053955,-2.49627e-07,2.11216e-09,0.841602,0.000539057,-2.4329e-07,1.18558e-08,0.842141,0.000538606,-2.07723e-07,1.00691e-08,0.842679,0.000538221,-1.77516e-07,-5.21324e-08,0.843217,0.00053771,-3.33913e-07,7.92513e-08,0.843755,0.00053728,-9.6159e-08,-8.60587e-08,0.844292,0.000536829,-3.54335e-07,8.61696e-08,0.844828,0.000536379,-9.58263e-08,-7.98057e-08,0.845364,0.000535948,-3.35243e-07,5.42394e-08,0.8459,0.00053544,-1.72525e-07,-1.79426e-08,0.846435,0.000535041,-2.26353e-07,1.75308e-08,0.84697,0.000534641,-1.73761e-07,-5.21806e-08,0.847505,0.000534137,-3.30302e-07,7.19824e-08,0.848038,0.000533692,-1.14355e-07,-5.69349e-08,0.848572,0.000533293,-2.8516e-07,3.65479e-08,0.849105,0.000532832,-1.75516e-07,-2.96519e-08,0.849638,0.000532392,-2.64472e-07,2.2455e-08,0.85017,0.000531931,-1.97107e-07,-5.63451e-10,0.850702,0.000531535,-1.98797e-07,-2.02011e-08,0.851233,0.000531077,-2.59401e-07,2.17634e-08,0.851764,0.000530623,-1.94111e-07,-7.24794e-09,0.852294,0.000530213,-2.15854e-07,7.22832e-09,0.852824,0.000529803,-1.94169e-07,-2.16653e-08,0.853354,0.00052935,-2.59165e-07,1.98283e-08,0.853883,0.000528891,-1.9968e-07,1.95678e-09,0.854412,0.000528497,-1.9381e-07,-2.76554e-08,0.85494,0.000528027,-2.76776e-07,4.90603e-08,0.855468,0.00052762,-1.29596e-07,-4.93764e-08,0.855995,0.000527213,-2.77725e-07,2.92361e-08,0.856522,0.000526745,-1.90016e-07,-7.96341e-09,0.857049,0.000526341,-2.13907e-07,2.61752e-09,0.857575,0.000525922,-2.06054e-07,-2.50665e-09,0.8581,0.000525502,-2.13574e-07,7.40906e-09,0.858626,0.000525097,-1.91347e-07,-2.71296e-08,0.859151,0.000524633,-2.72736e-07,4.15048e-08,0.859675,0.000524212,-1.48221e-07,-1.96802e-08,0.860199,0.000523856,-2.07262e-07,-2.23886e-08,0.860723,0.000523375,-2.74428e-07,4.96299e-08,0.861246,0.000522975,-1.25538e-07,-5.69216e-08,0.861769,0.000522553,-2.96303e-07,5.88473e-08,0.862291,0.000522137,-1.19761e-07,-5.92584e-08,0.862813,0.00052172,-2.97536e-07,5.8977e-08,0.863334,0.000521301,-1.20605e-07,-5.74403e-08,0.863855,0.000520888,-2.92926e-07,5.15751e-08,0.864376,0.000520457,-1.38201e-07,-2.96506e-08,0.864896,0.000520091,-2.27153e-07,7.42277e-09,0.865416,0.000519659,-2.04885e-07,-4.05057e-11,0.865936,0.00051925,-2.05006e-07,-7.26074e-09,0.866455,0.000518818,-2.26788e-07,2.90835e-08,0.866973,0.000518451,-1.39538e-07,-4.94686e-08,0.867492,0.000518024,-2.87944e-07,4.95814e-08,0.868009,0.000517597,-1.39199e-07,-2.96479e-08,0.868527,0.000517229,-2.28143e-07,9.40539e-09,0.869044,0.000516801,-1.99927e-07,-7.9737e-09,0.86956,0.000516378,-2.23848e-07,2.24894e-08,0.870077,0.000515997,-1.5638e-07,-2.23793e-08,0.870592,0.000515617,-2.23517e-07,7.42302e-09,0.871108,0.000515193,-2.01248e-07,-7.31283e-09,0.871623,0.000514768,-2.23187e-07,2.18283e-08,0.872137,0.000514387,-1.57702e-07,-2.03959e-08,0.872652,0.000514011,-2.1889e-07,1.50711e-10,0.873165,0.000513573,-2.18437e-07,1.97931e-08,0.873679,0.000513196,-1.59058e-07,-1.97183e-08,0.874192,0.000512819,-2.18213e-07,-5.24324e-10,0.874704,0.000512381,-2.19786e-07,2.18156e-08,0.875217,0.000512007,-1.54339e-07,-2.71336e-08,0.875728,0.000511616,-2.3574e-07,2.71141e-08,0.87624,0.000511226,-1.54398e-07,-2.17182e-08,0.876751,0.000510852,-2.19552e-07,1.54131e-10,0.877262,0.000510414,-2.1909e-07,2.11017e-08,0.877772,0.000510039,-1.55785e-07,-2.49562e-08,0.878282,0.000509652,-2.30654e-07,1.91183e-08,0.878791,0.000509248,-1.73299e-07,8.08751e-09,0.8793,0.000508926,-1.49036e-07,-5.14684e-08,0.879809,0.000508474,-3.03441e-07,7.85766e-08,0.880317,0.000508103,-6.77112e-08,-8.40242e-08,0.880825,0.000507715,-3.19784e-07,7.87063e-08,0.881333,0.000507312,-8.36649e-08,-5.19871e-08,0.88184,0.000506988,-2.39626e-07,1.00327e-08,0.882346,0.000506539,-2.09528e-07,1.18562e-08,0.882853,0.000506156,-1.73959e-07,2.14703e-09,0.883359,0.000505814,-1.67518e-07,-2.04444e-08,0.883864,0.000505418,-2.28851e-07,2.00258e-08,0.88437,0.00050502,-1.68774e-07,-5.42855e-11,0.884874,0.000504682,-1.68937e-07,-1.98087e-08,0.885379,0.000504285,-2.28363e-07,1.96842e-08,0.885883,0.000503887,-1.6931e-07,6.76342e-10,0.886387,0.000503551,-1.67281e-07,-2.23896e-08,0.88689,0.000503149,-2.3445e-07,2.92774e-08,0.887393,0.000502768,-1.46618e-07,-3.51152e-08,0.887896,0.00050237,-2.51963e-07,5.15787e-08,0.888398,0.00050202,-9.72271e-08,-5.19903e-08,0.8889,0.00050167,-2.53198e-07,3.71732e-08,0.889401,0.000501275,-1.41678e-07,-3.70978e-08,0.889902,0.00050088,-2.52972e-07,5.16132e-08,0.890403,0.000500529,-9.81321e-08,-5.01459e-08,0.890903,0.000500183,-2.4857e-07,2.9761e-08,0.891403,0.000499775,-1.59287e-07,-9.29351e-09,0.891903,0.000499428,-1.87167e-07,7.41301e-09,0.892402,0.000499076,-1.64928e-07,-2.03585e-08,0.892901,0.000498685,-2.26004e-07,1.44165e-08,0.893399,0.000498276,-1.82754e-07,2.22974e-08,0.893898,0.000497978,-1.15862e-07,-4.40013e-08,0.894395,0.000497614,-2.47866e-07,3.44985e-08,0.894893,0.000497222,-1.44371e-07,-3.43882e-08,0.89539,0.00049683,-2.47535e-07,4.34497e-08,0.895886,0.000496465,-1.17186e-07,-2.02012e-08,0.896383,0.00049617,-1.7779e-07,-2.22497e-08,0.896879,0.000495748,-2.44539e-07,4.95952e-08,0.897374,0.000495408,-9.57532e-08,-5.69217e-08,0.89787,0.000495045,-2.66518e-07,5.88823e-08,0.898364,0.000494689,-8.98713e-08,-5.93983e-08,0.898859,0.000494331,-2.68066e-07,5.95017e-08,0.899353,0.000493973,-8.95613e-08,-5.9399e-08,0.899847,0.000493616,-2.67758e-07,5.8885e-08,0.90034,0.000493257,-9.11033e-08,-5.69317e-08,0.900833,0.000492904,-2.61898e-07,4.96326e-08,0.901326,0.000492529,-1.13001e-07,-2.23893e-08,0.901819,0.000492236,-1.80169e-07,-1.968e-08,0.902311,0.000491817,-2.39209e-07,4.15047e-08,0.902802,0.000491463,-1.14694e-07,-2.71296e-08,0.903293,0.000491152,-1.96083e-07,7.409e-09,0.903784,0.000490782,-1.73856e-07,-2.50645e-09,0.904275,0.000490427,-1.81376e-07,2.61679e-09,0.904765,0.000490072,-1.73525e-07,-7.96072e-09,0.905255,0.000489701,-1.97407e-07,2.92261e-08,0.905745,0.000489394,-1.09729e-07,-4.93389e-08,0.906234,0.000489027,-2.57746e-07,4.89204e-08,0.906723,0.000488658,-1.10985e-07,-2.71333e-08,0.907211,0.000488354,-1.92385e-07,8.30861e-12,0.907699,0.00048797,-1.9236e-07,2.71001e-08,0.908187,0.000487666,-1.1106e-07,-4.88041e-08,0.908675,0.000487298,-2.57472e-07,4.89069e-08,0.909162,0.000486929,-1.10751e-07,-2.76143e-08,0.909649,0.000486625,-1.93594e-07,1.9457e-09,0.910135,0.000486244,-1.87757e-07,1.98315e-08,0.910621,0.000485928,-1.28262e-07,-2.16671e-08,0.911107,0.000485606,-1.93264e-07,7.23216e-09,0.911592,0.000485241,-1.71567e-07,-7.26152e-09,0.912077,0.000484877,-1.93352e-07,2.18139e-08,0.912562,0.000484555,-1.2791e-07,-2.03895e-08,0.913047,0.000484238,-1.89078e-07,1.39494e-10,0.913531,0.000483861,-1.8866e-07,1.98315e-08,0.914014,0.000483543,-1.29165e-07,-1.98609e-08,0.914498,0.000483225,-1.88748e-07,7.39912e-12,0.914981,0.000482847,-1.88726e-07,1.98313e-08,0.915463,0.000482529,-1.29232e-07,-1.9728e-08,0.915946,0.000482212,-1.88416e-07,-5.24035e-10,0.916428,0.000481833,-1.89988e-07,2.18241e-08,0.916909,0.000481519,-1.24516e-07,-2.71679e-08,0.917391,0.000481188,-2.06019e-07,2.72427e-08,0.917872,0.000480858,-1.24291e-07,-2.21985e-08,0.918353,0.000480543,-1.90886e-07,1.94644e-09,0.918833,0.000480167,-1.85047e-07,1.44127e-08,0.919313,0.00047984,-1.41809e-07,7.39438e-12,0.919793,0.000479556,-1.41787e-07,-1.44423e-08,0.920272,0.000479229,-1.85114e-07,-1.84291e-09,0.920751,0.000478854,-1.90642e-07,2.18139e-08,0.92123,0.000478538,-1.25201e-07,-2.58081e-08,0.921708,0.00047821,-2.02625e-07,2.18139e-08,0.922186,0.00047787,-1.37183e-07,-1.84291e-09,0.922664,0.00047759,-1.42712e-07,-1.44423e-08,0.923141,0.000477262,-1.86039e-07,7.34701e-12,0.923618,0.00047689,-1.86017e-07,1.44129e-08,0.924095,0.000476561,-1.42778e-07,1.94572e-09,0.924572,0.000476281,-1.36941e-07,-2.21958e-08,0.925048,0.000475941,-2.03528e-07,2.72327e-08,0.925523,0.000475615,-1.2183e-07,-2.71304e-08,0.925999,0.00047529,-2.03221e-07,2.16843e-08,0.926474,0.000474949,-1.38168e-07,-2.16005e-12,0.926949,0.000474672,-1.38175e-07,-2.16756e-08,0.927423,0.000474331,-2.03202e-07,2.71001e-08,0.927897,0.000474006,-1.21902e-07,-2.71201e-08,0.928371,0.000473681,-2.03262e-07,2.17757e-08,0.928845,0.00047334,-1.37935e-07,-3.78028e-10,0.929318,0.000473063,-1.39069e-07,-2.02636e-08,0.929791,0.000472724,-1.9986e-07,2.18276e-08,0.930263,0.000472389,-1.34377e-07,-7.44231e-09,0.930736,0.000472098,-1.56704e-07,7.94165e-09,0.931208,0.000471809,-1.32879e-07,-2.43243e-08,0.931679,0.00047147,-2.05851e-07,2.97508e-08,0.932151,0.000471148,-1.16599e-07,-3.50742e-08,0.932622,0.000470809,-2.21822e-07,5.09414e-08,0.933092,0.000470518,-6.89976e-08,-4.94821e-08,0.933563,0.000470232,-2.17444e-07,2.77775e-08,0.934033,0.00046988,-1.34111e-07,-2.02351e-09,0.934502,0.000469606,-1.40182e-07,-1.96835e-08,0.934972,0.000469267,-1.99232e-07,2.11529e-08,0.935441,0.000468932,-1.35774e-07,-5.32332e-09,0.93591,0.000468644,-1.51743e-07,1.40413e-10,0.936378,0.000468341,-1.51322e-07,4.76166e-09,0.936846,0.000468053,-1.37037e-07,-1.9187e-08,0.937314,0.000467721,-1.94598e-07,1.23819e-08,0.937782,0.000467369,-1.57453e-07,2.92642e-08,0.938249,0.000467142,-6.96601e-08,-6.98342e-08,0.938716,0.000466793,-2.79163e-07,7.12586e-08,0.939183,0.000466449,-6.53869e-08,-3.63863e-08,0.939649,0.000466209,-1.74546e-07,1.46818e-08,0.940115,0.000465904,-1.305e-07,-2.2341e-08,0.940581,0.000465576,-1.97523e-07,1.50774e-08,0.941046,0.000465226,-1.52291e-07,2.16359e-08,0.941511,0.000464986,-8.73832e-08,-4.20162e-08,0.941976,0.000464685,-2.13432e-07,2.72198e-08,0.942441,0.00046434,-1.31773e-07,-7.2581e-09,0.942905,0.000464055,-1.53547e-07,1.81263e-09,0.943369,0.000463753,-1.48109e-07,7.58386e-12,0.943832,0.000463457,-1.48086e-07,-1.84298e-09,0.944296,0.000463155,-1.53615e-07,7.36433e-09,0.944759,0.00046287,-1.31522e-07,-2.76143e-08,0.945221,0.000462524,-2.14365e-07,4.34883e-08,0.945684,0.000462226,-8.39003e-08,-2.71297e-08,0.946146,0.000461977,-1.65289e-07,5.42595e-09,0.946608,0.000461662,-1.49012e-07,5.42593e-09,0.947069,0.000461381,-1.32734e-07,-2.71297e-08,0.94753,0.000461034,-2.14123e-07,4.34881e-08,0.947991,0.000460736,-8.36585e-08,-2.76134e-08,0.948452,0.000460486,-1.66499e-07,7.36083e-09,0.948912,0.000460175,-1.44416e-07,-1.82993e-09,0.949372,0.000459881,-1.49906e-07,-4.11073e-11,0.949832,0.000459581,-1.50029e-07,1.99434e-09,0.950291,0.000459287,-1.44046e-07,-7.93627e-09,0.950751,0.000458975,-1.67855e-07,2.97507e-08,0.951209,0.000458728,-7.86029e-08,-5.1462e-08,0.951668,0.000458417,-2.32989e-07,5.6888e-08,0.952126,0.000458121,-6.2325e-08,-5.68806e-08,0.952584,0.000457826,-2.32967e-07,5.14251e-08,0.953042,0.000457514,-7.86914e-08,-2.96107e-08,0.953499,0.000457268,-1.67523e-07,7.41296e-09,0.953956,0.000456955,-1.45285e-07,-4.11262e-11,0.954413,0.000456665,-1.45408e-07,-7.24847e-09,0.95487,0.000456352,-1.67153e-07,2.9035e-08,0.955326,0.000456105,-8.00484e-08,-4.92869e-08,0.955782,0.000455797,-2.27909e-07,4.89032e-08,0.956238,0.000455488,-8.11994e-08,-2.71166e-08,0.956693,0.000455244,-1.62549e-07,-4.13678e-11,0.957148,0.000454919,-1.62673e-07,2.72821e-08,0.957603,0.000454675,-8.0827e-08,-4.94824e-08,0.958057,0.000454365,-2.29274e-07,5.14382e-08,0.958512,0.000454061,-7.49597e-08,-3.7061e-08,0.958965,0.0004538,-1.86143e-07,3.72013e-08,0.959419,0.000453539,-7.45389e-08,-5.21396e-08,0.959873,0.000453234,-2.30958e-07,5.21476e-08,0.960326,0.000452928,-7.45146e-08,-3.72416e-08,0.960778,0.000452667,-1.8624e-07,3.72143e-08,0.961231,0.000452407,-7.45967e-08,-5.20109e-08,0.961683,0.000452101,-2.30629e-07,5.16199e-08,0.962135,0.000451795,-7.57696e-08,-3.52595e-08,0.962587,0.000451538,-1.81548e-07,2.98133e-08,0.963038,0.000451264,-9.2108e-08,-2.43892e-08,0.963489,0.000451007,-1.65276e-07,8.13892e-09,0.96394,0.000450701,-1.40859e-07,-8.16647e-09,0.964391,0.000450394,-1.65358e-07,2.45269e-08,0.964841,0.000450137,-9.17775e-08,-3.03367e-08,0.965291,0.000449863,-1.82787e-07,3.7215e-08,0.965741,0.000449609,-7.11424e-08,-5.89188e-08,0.96619,0.00044929,-2.47899e-07,7.92509e-08,0.966639,0.000449032,-1.01462e-08,-7.92707e-08,0.967088,0.000448773,-2.47958e-07,5.90181e-08,0.967537,0.000448455,-7.0904e-08,-3.75925e-08,0.967985,0.0004482,-1.83681e-07,3.17471e-08,0.968433,0.000447928,-8.84401e-08,-2.97913e-08,0.968881,0.000447662,-1.77814e-07,2.78133e-08,0.969329,0.000447389,-9.4374e-08,-2.18572e-08,0.969776,0.000447135,-1.59946e-07,1.10134e-11,0.970223,0.000446815,-1.59913e-07,2.18132e-08,0.97067,0.000446561,-9.44732e-08,-2.76591e-08,0.971116,0.000446289,-1.7745e-07,2.92185e-08,0.971562,0.000446022,-8.97948e-08,-2.96104e-08,0.972008,0.000445753,-1.78626e-07,2.96185e-08,0.972454,0.000445485,-8.97706e-08,-2.92588e-08,0.972899,0.000445218,-1.77547e-07,2.78123e-08,0.973344,0.000444946,-9.41103e-08,-2.23856e-08,0.973789,0.000444691,-1.61267e-07,2.12559e-09,0.974233,0.000444374,-1.5489e-07,1.38833e-08,0.974678,0.000444106,-1.13241e-07,1.94591e-09,0.975122,0.000443886,-1.07403e-07,-2.16669e-08,0.975565,0.000443606,-1.72404e-07,2.5117e-08,0.976009,0.000443336,-9.70526e-08,-1.91963e-08,0.976452,0.000443085,-1.54642e-07,-7.93627e-09,0.976895,0.000442752,-1.7845e-07,5.09414e-08,0.977338,0.000442548,-2.56262e-08,-7.66201e-08,0.97778,0.000442266,-2.55486e-07,7.67249e-08,0.978222,0.000441986,-2.53118e-08,-5.14655e-08,0.978664,0.000441781,-1.79708e-07,9.92773e-09,0.979106,0.000441451,-1.49925e-07,1.17546e-08,0.979547,0.000441186,-1.14661e-07,2.65868e-09,0.979988,0.000440965,-1.06685e-07,-2.23893e-08,0.980429,0.000440684,-1.73853e-07,2.72939e-08,0.980869,0.000440419,-9.19716e-08,-2.71816e-08,0.98131,0.000440153,-1.73516e-07,2.18278e-08,0.98175,0.000439872,-1.08033e-07,-5.24833e-10,0.982189,0.000439654,-1.09607e-07,-1.97284e-08,0.982629,0.000439376,-1.68793e-07,1.98339e-08,0.983068,0.000439097,-1.09291e-07,-2.62901e-12,0.983507,0.000438879,-1.09299e-07,-1.98234e-08,0.983946,0.000438601,-1.68769e-07,1.96916e-08,0.984384,0.000438322,-1.09694e-07,6.6157e-10,0.984823,0.000438105,-1.0771e-07,-2.23379e-08,0.985261,0.000437823,-1.74723e-07,2.90855e-08,0.985698,0.00043756,-8.74669e-08,-3.43992e-08,0.986136,0.000437282,-1.90665e-07,4.89068e-08,0.986573,0.000437048,-4.39442e-08,-4.20188e-08,0.98701,0.000436834,-1.7e-07,-4.11073e-11,0.987446,0.000436494,-1.70124e-07,4.21832e-08,0.987883,0.00043628,-4.35742e-08,-4.94824e-08,0.988319,0.000436044,-1.92021e-07,3.6537e-08,0.988755,0.00043577,-8.24102e-08,-3.70611e-08,0.989191,0.000435494,-1.93593e-07,5.21026e-08,0.989626,0.000435263,-3.72855e-08,-5.21402e-08,0.990061,0.000435032,-1.93706e-07,3.7249e-08,0.990496,0.000434756,-8.19592e-08,-3.72512e-08,0.990931,0.000434481,-1.93713e-07,5.21511e-08,0.991365,0.00043425,-3.72595e-08,-5.21439e-08,0.991799,0.000434019,-1.93691e-07,3.72152e-08,0.992233,0.000433743,-8.20456e-08,-3.71123e-08,0.992667,0.000433468,-1.93382e-07,5.16292e-08,0.9931,0.000433236,-3.84947e-08,-5.01953e-08,0.993533,0.000433008,-1.89081e-07,2.99427e-08,0.993966,0.00043272,-9.92525e-08,-9.9708e-09,0.994399,0.000432491,-1.29165e-07,9.94051e-09,0.994831,0.000432263,-9.93434e-08,-2.97912e-08,0.995263,0.000431975,-1.88717e-07,4.96198e-08,0.995695,0.000431746,-3.98578e-08,-4.94785e-08,0.996127,0.000431518,-1.88293e-07,2.9085e-08,0.996558,0.000431229,-1.01038e-07,-7.25675e-09,0.996989,0.000431005,-1.22809e-07,-5.79945e-11,0.99742,0.000430759,-1.22983e-07,7.48873e-09,0.997851,0.000430536,-1.00516e-07,-2.98969e-08,0.998281,0.000430245,-1.90207e-07,5.24942e-08,0.998711,0.000430022,-3.27246e-08,-6.08706e-08,0.999141,0.000429774,-2.15336e-07,7.17788e-08,0.999571,0.000429392,0.,0.}; template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB; template <int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float lThresh = 0.008856f * 903.3f; const float fThresh = 7.787f * 0.008856f + 16.0f / 116.0f; float Y, fy; if (src.x <= lThresh) { Y = src.x / 903.3f; fy = 7.787f * Y + 16.0f / 116.0f; } else { fy = (src.x + 16.0f) / 116.0f; Y = fy * fy * fy; } float X = src.y / 500.0f + fy; float Z = fy - src.z / 200.0f; if (X <= fThresh) X = (X - 16.0f / 116.0f) / 7.787f; else X = X * X * X; if (Z <= fThresh) Z = (Z - 16.0f / 116.0f) / 7.787f; else Z = Z * Z * Z; float B = 0.052891f * X - 0.204043f * Y + 1.151152f * Z; float G = -0.921235f * X + 1.875991f * Y + 0.045244f * Z; float R = 3.079933f * X - 1.537150f * Y - 0.542782f * Z; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); } typename MakeVec<float, dcn>::type dst; dst.x = blueIdx == 0 ? B : R; dst.y = G; dst.z = blueIdx == 0 ? R : B; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct Lab2RGB<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (100.f / 255.f); buf.y = src.y - 128; buf.z = src.z - 128; Lab2RGB<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; // RGB to Luv static __constant__ float c_LabCbrtTab[] = {0.137931,0.0114066,0.,1.18859e-07,0.149338,0.011407,3.56578e-07,-5.79396e-07,0.160745,0.0114059,-1.38161e-06,2.16892e-06,0.172151,0.0114097,5.12516e-06,-8.0814e-06,0.183558,0.0113957,-1.9119e-05,3.01567e-05,0.194965,0.0114479,7.13509e-05,-0.000112545,0.206371,0.011253,-0.000266285,-0.000106493,0.217252,0.0104009,-0.000585765,7.32149e-05,0.22714,0.00944906,-0.00036612,1.21917e-05,0.236235,0.0087534,-0.000329545,2.01753e-05,0.244679,0.00815483,-0.000269019,1.24435e-05,0.252577,0.00765412,-0.000231689,1.05618e-05,0.26001,0.00722243,-0.000200003,8.26662e-06,0.267041,0.00684723,-0.000175203,6.76746e-06,0.27372,0.00651712,-0.000154901,5.61192e-06,0.280088,0.00622416,-0.000138065,4.67009e-06,0.286179,0.00596204,-0.000124055,3.99012e-06,0.292021,0.0057259,-0.000112085,3.36032e-06,0.297638,0.00551181,-0.000102004,2.95338e-06,0.30305,0.00531666,-9.31435e-05,2.52875e-06,0.308277,0.00513796,-8.55572e-05,2.22022e-06,0.313331,0.00497351,-7.88966e-05,1.97163e-06,0.318228,0.00482163,-7.29817e-05,1.7248e-06,0.322978,0.00468084,-6.78073e-05,1.55998e-06,0.327593,0.0045499,-6.31274e-05,1.36343e-06,0.332081,0.00442774,-5.90371e-05,1.27136e-06,0.336451,0.00431348,-5.5223e-05,1.09111e-06,0.34071,0.00420631,-5.19496e-05,1.0399e-06,0.344866,0.00410553,-4.88299e-05,9.18347e-07,0.348923,0.00401062,-4.60749e-05,8.29942e-07,0.352889,0.00392096,-4.35851e-05,7.98478e-07,0.356767,0.00383619,-4.11896e-05,6.84917e-07,0.360562,0.00375586,-3.91349e-05,6.63976e-07,0.36428,0.00367959,-3.7143e-05,5.93086e-07,0.367923,0.00360708,-3.53637e-05,5.6976e-07,0.371495,0.00353806,-3.36544e-05,4.95533e-07,0.375,0.00347224,-3.21678e-05,4.87951e-07,0.378441,0.00340937,-3.0704e-05,4.4349e-07,0.38182,0.00334929,-2.93735e-05,4.20297e-07,0.38514,0.0032918,-2.81126e-05,3.7872e-07,0.388404,0.00323671,-2.69764e-05,3.596e-07,0.391614,0.00318384,-2.58976e-05,3.5845e-07,0.394772,0.00313312,-2.48223e-05,2.92765e-07,0.397881,0.00308435,-2.3944e-05,3.18232e-07,0.400942,0.00303742,-2.29893e-05,2.82046e-07,0.403957,0.00299229,-2.21432e-05,2.52315e-07,0.406927,0.00294876,-2.13862e-05,2.58416e-07,0.409855,0.00290676,-2.0611e-05,2.33939e-07,0.412741,0.00286624,-1.99092e-05,2.36342e-07,0.415587,0.00282713,-1.92001e-05,1.916e-07,0.418396,0.00278931,-1.86253e-05,2.1915e-07,0.421167,0.00275271,-1.79679e-05,1.83498e-07,0.423901,0.00271733,-1.74174e-05,1.79343e-07,0.426602,0.00268303,-1.68794e-05,1.72013e-07,0.429268,0.00264979,-1.63633e-05,1.75686e-07,0.431901,0.00261759,-1.58363e-05,1.3852e-07,0.434503,0.00258633,-1.54207e-05,1.64304e-07,0.437074,0.00255598,-1.49278e-05,1.28136e-07,0.439616,0.00252651,-1.45434e-05,1.57618e-07,0.442128,0.0024979,-1.40705e-05,1.0566e-07,0.444612,0.00247007,-1.37535e-05,1.34998e-07,0.447068,0.00244297,-1.33485e-05,1.29207e-07,0.449498,0.00241666,-1.29609e-05,9.32347e-08,0.451902,0.00239102,-1.26812e-05,1.23703e-07,0.45428,0.00236603,-1.23101e-05,9.74072e-08,0.456634,0.0023417,-1.20179e-05,1.12518e-07,0.458964,0.002318,-1.16803e-05,7.83681e-08,0.46127,0.00229488,-1.14452e-05,1.10452e-07,0.463554,0.00227232,-1.11139e-05,7.58719e-08,0.465815,0.00225032,-1.08863e-05,9.2699e-08,0.468055,0.00222882,-1.06082e-05,8.97738e-08,0.470273,0.00220788,-1.03388e-05,5.4845e-08,0.47247,0.00218736,-1.01743e-05,1.0808e-07,0.474648,0.00216734,-9.85007e-06,4.9277e-08,0.476805,0.00214779,-9.70224e-06,8.22408e-08,0.478943,0.00212863,-9.45551e-06,6.87942e-08,0.481063,0.00210993,-9.24913e-06,5.98144e-08,0.483163,0.00209161,-9.06969e-06,7.93789e-08,0.485246,0.00207371,-8.83155e-06,3.99032e-08,0.487311,0.00205616,-8.71184e-06,8.88325e-08,0.489358,0.002039,-8.44534e-06,2.20004e-08,0.491389,0.00202218,-8.37934e-06,9.13872e-08,0.493403,0.0020057,-8.10518e-06,2.96829e-08,0.495401,0.00198957,-8.01613e-06,5.81028e-08,0.497382,0.00197372,-7.84183e-06,6.5731e-08,0.499348,0.00195823,-7.64463e-06,3.66019e-08,0.501299,0.00194305,-7.53483e-06,2.62811e-08,0.503234,0.00192806,-7.45598e-06,9.66907e-08,0.505155,0.00191344,-7.16591e-06,4.18928e-09,0.507061,0.00189912,-7.15334e-06,6.53665e-08,0.508953,0.00188501,-6.95724e-06,3.23686e-08,0.510831,0.00187119,-6.86014e-06,4.35774e-08,0.512696,0.0018576,-6.72941e-06,3.17406e-08,0.514547,0.00184424,-6.63418e-06,6.78785e-08,0.516384,0.00183117,-6.43055e-06,-5.23126e-09,0.518209,0.0018183,-6.44624e-06,7.22562e-08,0.520021,0.00180562,-6.22947e-06,1.42292e-08,0.52182,0.0017932,-6.18679e-06,4.9641e-08,0.523607,0.00178098,-6.03786e-06,2.56259e-08,0.525382,0.00176898,-5.96099e-06,2.66696e-08,0.527145,0.00175714,-5.88098e-06,4.65094e-08,0.528897,0.00174552,-5.74145e-06,2.57114e-08,0.530637,0.00173411,-5.66431e-06,2.94588e-08,0.532365,0.00172287,-5.57594e-06,3.52667e-08,0.534082,0.00171182,-5.47014e-06,8.28868e-09,0.535789,0.00170091,-5.44527e-06,5.07871e-08,0.537484,0.00169017,-5.29291e-06,2.69817e-08,0.539169,0.00167967,-5.21197e-06,2.01009e-08,0.540844,0.0016693,-5.15166e-06,1.18237e-08,0.542508,0.00165903,-5.11619e-06,5.18135e-08,0.544162,0.00164896,-4.96075e-06,1.9341e-08,0.545806,0.00163909,-4.90273e-06,-9.96867e-09,0.54744,0.00162926,-4.93263e-06,8.01382e-08,0.549064,0.00161963,-4.69222e-06,-1.25601e-08,0.550679,0.00161021,-4.7299e-06,2.97067e-08,0.552285,0.00160084,-4.64078e-06,1.29426e-08,0.553881,0.0015916,-4.60195e-06,3.77327e-08,0.555468,0.00158251,-4.48875e-06,1.49412e-08,0.557046,0.00157357,-4.44393e-06,2.17118e-08,0.558615,0.00156475,-4.3788e-06,1.74206e-08,0.560176,0.00155605,-4.32653e-06,2.78152e-08,0.561727,0.00154748,-4.24309e-06,-9.47239e-09,0.563271,0.00153896,-4.27151e-06,6.9679e-08,0.564805,0.00153063,-4.06247e-06,-3.08246e-08,0.566332,0.00152241,-4.15494e-06,5.36188e-08,0.56785,0.00151426,-3.99409e-06,-4.83594e-09,0.56936,0.00150626,-4.00859e-06,2.53293e-08,0.570863,0.00149832,-3.93261e-06,2.27286e-08,0.572357,0.00149052,-3.86442e-06,2.96541e-09,0.573844,0.0014828,-3.85552e-06,2.50147e-08,0.575323,0.00147516,-3.78048e-06,1.61842e-08,0.576794,0.00146765,-3.73193e-06,2.94582e-08,0.578258,0.00146028,-3.64355e-06,-1.48076e-08,0.579715,0.00145295,-3.68798e-06,2.97724e-08,0.581164,0.00144566,-3.59866e-06,1.49272e-08,0.582606,0.00143851,-3.55388e-06,2.97285e-08,0.584041,0.00143149,-3.46469e-06,-1.46323e-08,0.585469,0.00142451,-3.50859e-06,2.88004e-08,0.58689,0.00141758,-3.42219e-06,1.864e-08,0.588304,0.00141079,-3.36627e-06,1.58482e-08,0.589712,0.00140411,-3.31872e-06,-2.24279e-08,0.591112,0.00139741,-3.38601e-06,7.38639e-08,0.592507,0.00139085,-3.16441e-06,-3.46088e-08,0.593894,0.00138442,-3.26824e-06,4.96675e-09,0.595275,0.0013779,-3.25334e-06,7.4346e-08,0.59665,0.00137162,-3.0303e-06,-6.39319e-08,0.598019,0.00136536,-3.2221e-06,6.21725e-08,0.599381,0.00135911,-3.03558e-06,-5.94423e-09,0.600737,0.00135302,-3.05341e-06,2.12091e-08,0.602087,0.00134697,-2.98979e-06,-1.92876e-08,0.603431,0.00134094,-3.04765e-06,5.5941e-08,0.604769,0.00133501,-2.87983e-06,-2.56622e-08,0.606101,0.00132917,-2.95681e-06,4.67078e-08,0.607427,0.0013234,-2.81669e-06,-4.19592e-08,0.608748,0.00131764,-2.94257e-06,6.15243e-08,0.610062,0.00131194,-2.75799e-06,-2.53244e-08,0.611372,0.00130635,-2.83397e-06,3.97739e-08,0.612675,0.0013008,-2.71465e-06,-1.45618e-08,0.613973,0.00129533,-2.75833e-06,1.84733e-08,0.615266,0.00128986,-2.70291e-06,2.73606e-10,0.616553,0.00128446,-2.70209e-06,4.00367e-08,0.617835,0.00127918,-2.58198e-06,-4.12113e-08,0.619111,0.00127389,-2.70561e-06,6.52039e-08,0.620383,0.00126867,-2.51e-06,-4.07901e-08,0.621649,0.00126353,-2.63237e-06,3.83516e-08,0.62291,0.00125838,-2.51732e-06,6.59315e-09,0.624166,0.00125337,-2.49754e-06,-5.11939e-09,0.625416,0.00124836,-2.5129e-06,1.38846e-08,0.626662,0.00124337,-2.47124e-06,9.18514e-09,0.627903,0.00123846,-2.44369e-06,8.97952e-09,0.629139,0.0012336,-2.41675e-06,1.45012e-08,0.63037,0.00122881,-2.37325e-06,-7.37949e-09,0.631597,0.00122404,-2.39538e-06,1.50169e-08,0.632818,0.00121929,-2.35033e-06,6.91648e-09,0.634035,0.00121461,-2.32958e-06,1.69219e-08,0.635248,0.00121,-2.27882e-06,-1.49997e-08,0.636455,0.0012054,-2.32382e-06,4.30769e-08,0.637659,0.00120088,-2.19459e-06,-3.80986e-08,0.638857,0.00119638,-2.30888e-06,4.97134e-08,0.640051,0.00119191,-2.15974e-06,-4.15463e-08,0.641241,0.00118747,-2.28438e-06,5.68667e-08,0.642426,0.00118307,-2.11378e-06,-7.10641e-09,0.643607,0.00117882,-2.1351e-06,-2.8441e-08,0.644784,0.00117446,-2.22042e-06,6.12658e-08,0.645956,0.00117021,-2.03663e-06,-3.78083e-08,0.647124,0.00116602,-2.15005e-06,3.03627e-08,0.648288,0.00116181,-2.05896e-06,-2.40379e-08,0.649448,0.00115762,-2.13108e-06,6.57887e-08,0.650603,0.00115356,-1.93371e-06,-6.03028e-08,0.651755,0.00114951,-2.11462e-06,5.62134e-08,0.652902,0.00114545,-1.94598e-06,-4.53417e-08,0.654046,0.00114142,-2.082e-06,6.55489e-08,0.655185,0.00113745,-1.88536e-06,-3.80396e-08,0.656321,0.00113357,-1.99948e-06,2.70049e-08,0.657452,0.00112965,-1.91846e-06,-1.03755e-08,0.65858,0.00112578,-1.94959e-06,1.44973e-08,0.659704,0.00112192,-1.9061e-06,1.1991e-08,0.660824,0.00111815,-1.87012e-06,-2.85634e-09,0.66194,0.0011144,-1.87869e-06,-5.65782e-10,0.663053,0.00111064,-1.88039e-06,5.11947e-09,0.664162,0.0011069,-1.86503e-06,3.96924e-08,0.665267,0.00110328,-1.74595e-06,-4.46795e-08,0.666368,0.00109966,-1.87999e-06,1.98161e-08,0.667466,0.00109596,-1.82054e-06,2.502e-08,0.66856,0.00109239,-1.74548e-06,-6.86593e-10,0.669651,0.0010889,-1.74754e-06,-2.22739e-08,0.670738,0.00108534,-1.81437e-06,3.01776e-08,0.671821,0.0010818,-1.72383e-06,2.07732e-08,0.672902,0.00107841,-1.66151e-06,-5.36658e-08,0.673978,0.00107493,-1.82251e-06,7.46802e-08,0.675051,0.00107151,-1.59847e-06,-6.62411e-08,0.676121,0.00106811,-1.79719e-06,7.10748e-08,0.677188,0.00106473,-1.58397e-06,-3.92441e-08,0.678251,0.00106145,-1.7017e-06,2.62973e-08,0.679311,0.00105812,-1.62281e-06,-6.34035e-09,0.680367,0.00105486,-1.64183e-06,-9.36249e-10,0.68142,0.00105157,-1.64464e-06,1.00854e-08,0.68247,0.00104831,-1.61438e-06,2.01995e-08,0.683517,0.00104514,-1.55378e-06,-3.1279e-08,0.68456,0.00104194,-1.64762e-06,4.53114e-08,0.685601,0.00103878,-1.51169e-06,-3.07573e-08,0.686638,0.00103567,-1.60396e-06,1.81133e-08,0.687672,0.00103251,-1.54962e-06,1.79085e-08,0.688703,0.00102947,-1.49589e-06,-3.01428e-08,0.689731,0.00102639,-1.58632e-06,4.30583e-08,0.690756,0.00102334,-1.45715e-06,-2.28814e-08,0.691778,0.00102036,-1.52579e-06,-1.11373e-08,0.692797,0.00101727,-1.5592e-06,6.74305e-08,0.693812,0.00101436,-1.35691e-06,-7.97709e-08,0.694825,0.0010114,-1.59622e-06,7.28391e-08,0.695835,0.00100843,-1.37771e-06,-3.27715e-08,0.696842,0.00100558,-1.47602e-06,-1.35807e-09,0.697846,0.00100262,-1.48009e-06,3.82037e-08,0.698847,0.000999775,-1.36548e-06,-3.22474e-08,0.699846,0.000996948,-1.46223e-06,3.11809e-08,0.700841,0.000994117,-1.36868e-06,-3.28714e-08,0.701834,0.000991281,-1.4673e-06,4.07001e-08,0.702824,0.000988468,-1.3452e-06,-1.07197e-08,0.703811,0.000985746,-1.37736e-06,2.17866e-09,0.704795,0.000982998,-1.37082e-06,2.00521e-09,0.705777,0.000980262,-1.3648e-06,-1.01996e-08,0.706756,0.000977502,-1.3954e-06,3.87931e-08,0.707732,0.000974827,-1.27902e-06,-2.57632e-08,0.708706,0.000972192,-1.35631e-06,4.65513e-09,0.709676,0.000969493,-1.34235e-06,7.14257e-09,0.710645,0.00096683,-1.32092e-06,2.63791e-08,0.71161,0.000964267,-1.24178e-06,-5.30543e-08,0.712573,0.000961625,-1.40095e-06,6.66289e-08,0.713533,0.000959023,-1.20106e-06,-3.46474e-08,0.714491,0.000956517,-1.305e-06,1.23559e-08,0.715446,0.000953944,-1.26793e-06,-1.47763e-08,0.716399,0.000951364,-1.31226e-06,4.67494e-08,0.717349,0.000948879,-1.17201e-06,-5.3012e-08,0.718297,0.000946376,-1.33105e-06,4.60894e-08,0.719242,0.000943852,-1.19278e-06,-1.21366e-08,0.720185,0.00094143,-1.22919e-06,2.45673e-09,0.721125,0.000938979,-1.22182e-06,2.30966e-09,0.722063,0.000936543,-1.21489e-06,-1.16954e-08,0.722998,0.000934078,-1.24998e-06,4.44718e-08,0.723931,0.000931711,-1.11656e-06,-4.69823e-08,0.724861,0.000929337,-1.25751e-06,2.4248e-08,0.725789,0.000926895,-1.18477e-06,9.5949e-09,0.726715,0.000924554,-1.15598e-06,-3.02286e-09,0.727638,0.000922233,-1.16505e-06,2.49649e-09,0.72856,0.00091991,-1.15756e-06,-6.96321e-09,0.729478,0.000917575,-1.17845e-06,2.53564e-08,0.730395,0.000915294,-1.10238e-06,-3.48578e-08,0.731309,0.000912984,-1.20695e-06,5.44704e-08,0.732221,0.000910734,-1.04354e-06,-6.38144e-08,0.73313,0.000908455,-1.23499e-06,8.15781e-08,0.734038,0.00090623,-9.90253e-07,-8.3684e-08,0.734943,0.000903999,-1.2413e-06,7.43441e-08,0.735846,0.000901739,-1.01827e-06,-3.48787e-08,0.736746,0.000899598,-1.12291e-06,5.56596e-09,0.737645,0.000897369,-1.10621e-06,1.26148e-08,0.738541,0.000895194,-1.06837e-06,3.57935e-09,0.739435,0.000893068,-1.05763e-06,-2.69322e-08,0.740327,0.000890872,-1.13842e-06,4.45448e-08,0.741217,0.000888729,-1.00479e-06,-3.20376e-08,0.742105,0.000886623,-1.1009e-06,2.40011e-08,0.74299,0.000884493,-1.0289e-06,-4.36209e-09,0.743874,0.000882422,-1.04199e-06,-6.55268e-09,0.744755,0.000880319,-1.06164e-06,3.05728e-08,0.745634,0.000878287,-9.69926e-07,-5.61338e-08,0.746512,0.000876179,-1.13833e-06,7.4753e-08,0.747387,0.000874127,-9.14068e-07,-6.40644e-08,0.74826,0.000872106,-1.10626e-06,6.22955e-08,0.749131,0.000870081,-9.19375e-07,-6.59083e-08,0.75,0.000868044,-1.1171e-06,8.21284e-08,0.750867,0.000866056,-8.70714e-07,-8.37915e-08,0.751732,0.000864064,-1.12209e-06,7.42237e-08,0.752595,0.000862042,-8.99418e-07,-3.42894e-08,0.753456,0.00086014,-1.00229e-06,3.32955e-09,0.754315,0.000858146,-9.92297e-07,2.09712e-08,0.755173,0.000856224,-9.29384e-07,-2.76096e-08,0.756028,0.000854282,-1.01221e-06,2.98627e-08,0.756881,0.000852348,-9.22625e-07,-3.22365e-08,0.757733,0.000850406,-1.01933e-06,3.94786e-08,0.758582,0.000848485,-9.00898e-07,-6.46833e-09,0.75943,0.000846664,-9.20303e-07,-1.36052e-08,0.760275,0.000844783,-9.61119e-07,1.28447e-09,0.761119,0.000842864,-9.57266e-07,8.4674e-09,0.761961,0.000840975,-9.31864e-07,2.44506e-08,0.762801,0.000839185,-8.58512e-07,-4.6665e-08,0.763639,0.000837328,-9.98507e-07,4.30001e-08,0.764476,0.00083546,-8.69507e-07,-6.12609e-09,0.76531,0.000833703,-8.87885e-07,-1.84959e-08,0.766143,0.000831871,-9.43372e-07,2.05052e-08,0.766974,0.000830046,-8.81857e-07,-3.92026e-09,0.767803,0.000828271,-8.93618e-07,-4.82426e-09,0.768631,0.000826469,-9.0809e-07,2.32172e-08,0.769456,0.000824722,-8.38439e-07,-2.84401e-08,0.77028,0.00082296,-9.23759e-07,3.09386e-08,0.771102,0.000821205,-8.30943e-07,-3.57099e-08,0.771922,0.000819436,-9.38073e-07,5.22963e-08,0.772741,0.000817717,-7.81184e-07,-5.42658e-08,0.773558,0.000815992,-9.43981e-07,4.55579e-08,0.774373,0.000814241,-8.07308e-07,-8.75656e-09,0.775186,0.0008126,-8.33578e-07,-1.05315e-08,0.775998,0.000810901,-8.65172e-07,-8.72188e-09,0.776808,0.000809145,-8.91338e-07,4.54191e-08,0.777616,0.000807498,-7.5508e-07,-5.37454e-08,0.778423,0.000805827,-9.16317e-07,5.03532e-08,0.779228,0.000804145,-7.65257e-07,-2.84584e-08,0.780031,0.000802529,-8.50632e-07,3.87579e-09,0.780833,0.00080084,-8.39005e-07,1.29552e-08,0.781633,0.0007992,-8.00139e-07,3.90804e-09,0.782432,0.000797612,-7.88415e-07,-2.85874e-08,0.783228,0.000795949,-8.74177e-07,5.0837e-08,0.784023,0.000794353,-7.21666e-07,-5.55513e-08,0.784817,0.000792743,-8.8832e-07,5.21587e-08,0.785609,0.000791123,-7.31844e-07,-3.38744e-08,0.786399,0.000789558,-8.33467e-07,2.37342e-08,0.787188,0.000787962,-7.62264e-07,-1.45775e-09,0.787975,0.000786433,-7.66638e-07,-1.79034e-08,0.788761,0.000784846,-8.20348e-07,1.34665e-08,0.789545,0.000783246,-7.79948e-07,2.3642e-08,0.790327,0.000781757,-7.09022e-07,-4.84297e-08,0.791108,0.000780194,-8.54311e-07,5.08674e-08,0.791888,0.000778638,-7.01709e-07,-3.58303e-08,0.792666,0.000777127,-8.092e-07,3.28493e-08,0.793442,0.000775607,-7.10652e-07,-3.59624e-08,0.794217,0.000774078,-8.1854e-07,5.13959e-08,0.79499,0.000772595,-6.64352e-07,-5.04121e-08,0.795762,0.000771115,-8.15588e-07,3.10431e-08,0.796532,0.000769577,-7.22459e-07,-1.41557e-08,0.797301,0.00076809,-7.64926e-07,2.55795e-08,0.798069,0.000766636,-6.88187e-07,-2.85578e-08,0.798835,0.000765174,-7.73861e-07,2.90472e-08,0.799599,0.000763714,-6.86719e-07,-2.80262e-08,0.800362,0.000762256,-7.70798e-07,2.34531e-08,0.801123,0.000760785,-7.00438e-07,-6.18144e-09,0.801884,0.000759366,-7.18983e-07,1.27263e-09,0.802642,0.000757931,-7.15165e-07,1.09101e-09,0.803399,0.000756504,-7.11892e-07,-5.63675e-09,0.804155,0.000755064,-7.28802e-07,2.14559e-08,0.80491,0.00075367,-6.64434e-07,-2.05821e-08,0.805663,0.00075228,-7.26181e-07,1.26812e-09,0.806414,0.000750831,-7.22377e-07,1.55097e-08,0.807164,0.000749433,-6.75848e-07,-3.70216e-09,0.807913,0.00074807,-6.86954e-07,-7.0105e-10,0.80866,0.000746694,-6.89057e-07,6.5063e-09,0.809406,0.000745336,-6.69538e-07,-2.53242e-08,0.810151,0.000743921,-7.45511e-07,3.51858e-08,0.810894,0.000742535,-6.39953e-07,3.79034e-09,0.811636,0.000741267,-6.28582e-07,-5.03471e-08,0.812377,0.000739858,-7.79624e-07,7.83886e-08,0.813116,0.000738534,-5.44458e-07,-8.43935e-08,0.813854,0.000737192,-7.97638e-07,8.03714e-08,0.81459,0.000735838,-5.56524e-07,-5.82784e-08,0.815325,0.00073455,-7.31359e-07,3.35329e-08,0.816059,0.000733188,-6.3076e-07,-1.62486e-08,0.816792,0.000731878,-6.79506e-07,3.14614e-08,0.817523,0.000730613,-5.85122e-07,-4.99925e-08,0.818253,0.000729293,-7.35099e-07,4.92994e-08,0.818982,0.000727971,-5.87201e-07,-2.79959e-08,0.819709,0.000726712,-6.71189e-07,3.07959e-09,0.820435,0.000725379,-6.6195e-07,1.56777e-08,0.82116,0.000724102,-6.14917e-07,-6.18564e-09,0.821883,0.000722854,-6.33474e-07,9.06488e-09,0.822606,0.000721614,-6.06279e-07,-3.00739e-08,0.823327,0.000720311,-6.96501e-07,5.16262e-08,0.824046,0.000719073,-5.41623e-07,-5.72214e-08,0.824765,0.000717818,-7.13287e-07,5.80503e-08,0.825482,0.000716566,-5.39136e-07,-5.57703e-08,0.826198,0.00071532,-7.06447e-07,4.58215e-08,0.826912,0.000714045,-5.68983e-07,-8.30636e-09,0.827626,0.000712882,-5.93902e-07,-1.25961e-08,0.828338,0.000711656,-6.3169e-07,-9.13985e-10,0.829049,0.00071039,-6.34432e-07,1.62519e-08,0.829759,0.00070917,-5.85676e-07,-4.48904e-09,0.830468,0.000707985,-5.99143e-07,1.70418e-09,0.831175,0.000706792,-5.9403e-07,-2.32768e-09,0.831881,0.000705597,-6.01014e-07,7.60648e-09,0.832586,0.000704418,-5.78194e-07,-2.80982e-08,0.83329,0.000703177,-6.62489e-07,4.51817e-08,0.833993,0.000701988,-5.26944e-07,-3.34192e-08,0.834694,0.000700834,-6.27201e-07,2.88904e-08,0.835394,0.000699666,-5.4053e-07,-2.25378e-08,0.836093,0.000698517,-6.08143e-07,1.65589e-09,0.836791,0.000697306,-6.03176e-07,1.59142e-08,0.837488,0.000696147,-5.55433e-07,-5.70801e-09,0.838184,0.000695019,-5.72557e-07,6.91792e-09,0.838878,0.000693895,-5.51803e-07,-2.19637e-08,0.839571,0.000692725,-6.17694e-07,2.13321e-08,0.840263,0.000691554,-5.53698e-07,-3.75996e-09,0.840954,0.000690435,-5.64978e-07,-6.29219e-09,0.841644,0.000689287,-5.83855e-07,2.89287e-08,0.842333,0.000688206,-4.97068e-07,-4.98181e-08,0.843021,0.000687062,-6.46523e-07,5.11344e-08,0.843707,0.000685922,-4.9312e-07,-3.55102e-08,0.844393,0.00068483,-5.9965e-07,3.13019e-08,0.845077,0.000683724,-5.05745e-07,-3.00925e-08,0.84576,0.000682622,-5.96022e-07,2.94636e-08,0.846442,0.000681519,-5.07631e-07,-2.81572e-08,0.847123,0.000680419,-5.92103e-07,2.35606e-08,0.847803,0.000679306,-5.21421e-07,-6.48045e-09,0.848482,0.000678243,-5.40863e-07,2.36124e-09,0.849159,0.000677169,-5.33779e-07,-2.96461e-09,0.849836,0.000676092,-5.42673e-07,9.49728e-09,0.850512,0.000675035,-5.14181e-07,-3.50245e-08,0.851186,0.000673902,-6.19254e-07,7.09959e-08,0.851859,0.000672876,-4.06267e-07,-7.01453e-08,0.852532,0.000671853,-6.16703e-07,3.07714e-08,0.853203,0.000670712,-5.24388e-07,6.66423e-09,0.853873,0.000669684,-5.04396e-07,2.17629e-09,0.854542,0.000668681,-4.97867e-07,-1.53693e-08,0.855211,0.000667639,-5.43975e-07,-3.03752e-10,0.855878,0.000666551,-5.44886e-07,1.65844e-08,0.856544,0.000665511,-4.95133e-07,-6.42907e-09,0.857209,0.000664501,-5.1442e-07,9.13195e-09,0.857873,0.0006635,-4.87024e-07,-3.00987e-08,0.858536,0.000662435,-5.7732e-07,5.16584e-08,0.859198,0.000661436,-4.22345e-07,-5.73255e-08,0.859859,0.000660419,-5.94322e-07,5.84343e-08,0.860518,0.000659406,-4.19019e-07,-5.72022e-08,0.861177,0.000658396,-5.90626e-07,5.11653e-08,0.861835,0.000657368,-4.3713e-07,-2.82495e-08,0.862492,0.000656409,-5.21878e-07,2.22788e-09,0.863148,0.000655372,-5.15195e-07,1.9338e-08,0.863803,0.0006544,-4.5718e-07,-1.99754e-08,0.864457,0.000653425,-5.17107e-07,9.59024e-10,0.86511,0.000652394,-5.1423e-07,1.61393e-08,0.865762,0.000651414,-4.65812e-07,-5.91149e-09,0.866413,0.000650465,-4.83546e-07,7.50665e-09,0.867063,0.00064952,-4.61026e-07,-2.4115e-08,0.867712,0.000648526,-5.33371e-07,2.93486e-08,0.86836,0.000647547,-4.45325e-07,-3.36748e-08,0.869007,0.000646555,-5.4635e-07,4.57461e-08,0.869653,0.0006456,-4.09112e-07,-3.01002e-08,0.870298,0.000644691,-4.99412e-07,1.50501e-08,0.870942,0.000643738,-4.54262e-07,-3.01002e-08,0.871585,0.000642739,-5.44563e-07,4.57461e-08,0.872228,0.000641787,-4.07324e-07,-3.36748e-08,0.872869,0.000640871,-5.08349e-07,2.93486e-08,0.873509,0.000639943,-4.20303e-07,-2.4115e-08,0.874149,0.00063903,-4.92648e-07,7.50655e-09,0.874787,0.000638067,-4.70128e-07,-5.91126e-09,0.875425,0.000637109,-4.87862e-07,1.61385e-08,0.876062,0.000636182,-4.39447e-07,9.61961e-10,0.876697,0.000635306,-4.36561e-07,-1.99863e-08,0.877332,0.000634373,-4.9652e-07,1.93785e-08,0.877966,0.000633438,-4.38384e-07,2.07697e-09,0.878599,0.000632567,-4.32153e-07,-2.76864e-08,0.879231,0.00063162,-5.15212e-07,4.90641e-08,0.879862,0.000630737,-3.6802e-07,-4.93606e-08,0.880493,0.000629852,-5.16102e-07,2.9169e-08,0.881122,0.000628908,-4.28595e-07,-7.71083e-09,0.881751,0.000628027,-4.51727e-07,1.6744e-09,0.882378,0.000627129,-4.46704e-07,1.01317e-09,0.883005,0.000626239,-4.43665e-07,-5.72703e-09,0.883631,0.000625334,-4.60846e-07,2.1895e-08,0.884255,0.000624478,-3.95161e-07,-2.22481e-08,0.88488,0.000623621,-4.61905e-07,7.4928e-09,0.885503,0.00062272,-4.39427e-07,-7.72306e-09,0.886125,0.000621818,-4.62596e-07,2.33995e-08,0.886746,0.000620963,-3.92398e-07,-2.62704e-08,0.887367,0.000620099,-4.71209e-07,2.20775e-08,0.887987,0.000619223,-4.04976e-07,-2.43496e-09,0.888605,0.000618406,-4.12281e-07,-1.23377e-08,0.889223,0.000617544,-4.49294e-07,-7.81876e-09,0.88984,0.000616622,-4.72751e-07,4.36128e-08,0.890457,0.000615807,-3.41912e-07,-4.7423e-08,0.891072,0.000614981,-4.84181e-07,2.68698e-08,0.891687,0.000614093,-4.03572e-07,-4.51384e-10,0.8923,0.000613285,-4.04926e-07,-2.50643e-08,0.892913,0.0006124,-4.80119e-07,4.11038e-08,0.893525,0.000611563,-3.56808e-07,-2.01414e-08,0.894136,0.000610789,-4.17232e-07,-2.01426e-08,0.894747,0.000609894,-4.7766e-07,4.11073e-08,0.895356,0.000609062,-3.54338e-07,-2.50773e-08,0.895965,0.000608278,-4.2957e-07,-4.02954e-10,0.896573,0.000607418,-4.30779e-07,2.66891e-08,0.89718,0.000606636,-3.50711e-07,-4.67489e-08,0.897786,0.000605795,-4.90958e-07,4.10972e-08,0.898391,0.000604936,-3.67666e-07,1.56948e-09,0.898996,0.000604205,-3.62958e-07,-4.73751e-08,0.8996,0.000603337,-5.05083e-07,6.87214e-08,0.900202,0.000602533,-2.98919e-07,-4.86966e-08,0.900805,0.000601789,-4.45009e-07,6.85589e-09,0.901406,0.00060092,-4.24441e-07,2.1273e-08,0.902007,0.000600135,-3.60622e-07,-3.23434e-08,0.902606,0.000599317,-4.57652e-07,4.84959e-08,0.903205,0.000598547,-3.12164e-07,-4.24309e-08,0.903803,0.000597795,-4.39457e-07,2.01844e-09,0.904401,0.000596922,-4.33402e-07,3.43571e-08,0.904997,0.000596159,-3.30331e-07,-2.02374e-08,0.905593,0.000595437,-3.91043e-07,-1.30123e-08,0.906188,0.000594616,-4.3008e-07,1.26819e-08,0.906782,0.000593794,-3.92034e-07,2.18894e-08,0.907376,0.000593076,-3.26366e-07,-4.06349e-08,0.907968,0.000592301,-4.4827e-07,2.1441e-08,0.90856,0.000591469,-3.83947e-07,1.44754e-08,0.909151,0.000590744,-3.40521e-07,-1.97379e-08,0.909742,0.000590004,-3.99735e-07,4.87161e-09,0.910331,0.000589219,-3.8512e-07,2.51532e-10,0.91092,0.00058845,-3.84366e-07,-5.87776e-09,0.911508,0.000587663,-4.01999e-07,2.32595e-08,0.912096,0.000586929,-3.3222e-07,-2.75554e-08,0.912682,0.000586182,-4.14887e-07,2.73573e-08,0.913268,0.000585434,-3.32815e-07,-2.22692e-08,0.913853,0.000584702,-3.99622e-07,2.11486e-09,0.914437,0.000583909,-3.93278e-07,1.38098e-08,0.915021,0.000583164,-3.51848e-07,2.25042e-09,0.915604,0.000582467,-3.45097e-07,-2.28115e-08,0.916186,0.000581708,-4.13531e-07,2.93911e-08,0.916767,0.000580969,-3.25358e-07,-3.51481e-08,0.917348,0.000580213,-4.30803e-07,5.15967e-08,0.917928,0.000579506,-2.76012e-07,-5.20296e-08,0.918507,0.000578798,-4.32101e-07,3.73124e-08,0.919085,0.000578046,-3.20164e-07,-3.76154e-08,0.919663,0.000577293,-4.3301e-07,5.35447e-08,0.92024,0.000576587,-2.72376e-07,-5.7354e-08,0.920816,0.000575871,-4.44438e-07,5.66621e-08,0.921391,0.000575152,-2.74452e-07,-5.00851e-08,0.921966,0.000574453,-4.24707e-07,2.4469e-08,0.92254,0.000573677,-3.513e-07,1.18138e-08,0.923114,0.000573009,-3.15859e-07,-1.21195e-08,0.923686,0.000572341,-3.52217e-07,-2.29403e-08,0.924258,0.000571568,-4.21038e-07,4.4276e-08,0.924829,0.000570859,-2.8821e-07,-3.49546e-08,0.9254,0.000570178,-3.93074e-07,3.59377e-08,0.92597,0.000569499,-2.85261e-07,-4.91915e-08,0.926539,0.000568781,-4.32835e-07,4.16189e-08,0.927107,0.00056804,-3.07979e-07,1.92523e-09,0.927675,0.00056743,-3.02203e-07,-4.93198e-08,0.928242,0.000566678,-4.50162e-07,7.61447e-08,0.928809,0.000566006,-2.21728e-07,-7.6445e-08,0.929374,0.000565333,-4.51063e-07,5.08216e-08,0.929939,0.000564583,-2.98599e-07,-7.63212e-09,0.930503,0.000563963,-3.21495e-07,-2.02931e-08,0.931067,0.000563259,-3.82374e-07,2.92001e-08,0.93163,0.000562582,-2.94774e-07,-3.69025e-08,0.932192,0.000561882,-4.05482e-07,5.88053e-08,0.932754,0.000561247,-2.29066e-07,-7.91094e-08,0.933315,0.000560552,-4.66394e-07,7.88184e-08,0.933875,0.000559856,-2.29939e-07,-5.73501e-08,0.934434,0.000559224,-4.01989e-07,3.13727e-08,0.934993,0.000558514,-3.07871e-07,-8.53611e-09,0.935551,0.000557873,-3.33479e-07,2.77175e-09,0.936109,0.000557214,-3.25164e-07,-2.55091e-09,0.936666,0.000556556,-3.32817e-07,7.43188e-09,0.937222,0.000555913,-3.10521e-07,-2.71766e-08,0.937778,0.00055521,-3.92051e-07,4.167e-08,0.938333,0.000554551,-2.67041e-07,-2.02941e-08,0.938887,0.000553956,-3.27923e-07,-2.00984e-08,0.93944,0.00055324,-3.88218e-07,4.10828e-08,0.939993,0.000552587,-2.6497e-07,-2.50237e-08,0.940546,0.000551982,-3.40041e-07,-5.92583e-10,0.941097,0.0005513,-3.41819e-07,2.7394e-08,0.941648,0.000550698,-2.59637e-07,-4.93788e-08,0.942199,0.000550031,-4.07773e-07,5.09119e-08,0.942748,0.000549368,-2.55038e-07,-3.50595e-08,0.943297,0.000548753,-3.60216e-07,2.97214e-08,0.943846,0.000548122,-2.71052e-07,-2.42215e-08,0.944394,0.000547507,-3.43716e-07,7.55985e-09,0.944941,0.000546842,-3.21037e-07,-6.01796e-09,0.945487,0.000546182,-3.3909e-07,1.65119e-08,0.946033,0.000545553,-2.89555e-07,-4.2498e-10,0.946578,0.000544973,-2.9083e-07,-1.4812e-08,0.947123,0.000544347,-3.35266e-07,6.83068e-11,0.947667,0.000543676,-3.35061e-07,1.45388e-08,0.94821,0.00054305,-2.91444e-07,1.38123e-09,0.948753,0.000542471,-2.87301e-07,-2.00637e-08,0.949295,0.000541836,-3.47492e-07,1.92688e-08,0.949837,0.000541199,-2.89685e-07,2.59298e-09,0.950378,0.000540628,-2.81906e-07,-2.96407e-08,0.950918,0.000539975,-3.70829e-07,5.63652e-08,0.951458,0.000539402,-2.01733e-07,-7.66107e-08,0.951997,0.000538769,-4.31565e-07,7.12638e-08,0.952535,0.00053812,-2.17774e-07,-2.96305e-08,0.953073,0.000537595,-3.06665e-07,-1.23464e-08,0.95361,0.000536945,-3.43704e-07,1.94114e-08,0.954147,0.000536316,-2.8547e-07,-5.69451e-09,0.954683,0.000535728,-3.02554e-07,3.36666e-09,0.955219,0.000535133,-2.92454e-07,-7.77208e-09,0.955753,0.000534525,-3.1577e-07,2.77216e-08,0.956288,0.000533976,-2.32605e-07,-4.35097e-08,0.956821,0.00053338,-3.63134e-07,2.7108e-08,0.957354,0.000532735,-2.8181e-07,-5.31772e-09,0.957887,0.000532156,-2.97764e-07,-5.83718e-09,0.958419,0.000531543,-3.15275e-07,2.86664e-08,0.95895,0.000530998,-2.29276e-07,-4.9224e-08,0.959481,0.000530392,-3.76948e-07,4.90201e-08,0.960011,0.000529785,-2.29887e-07,-2.76471e-08,0.96054,0.000529243,-3.12829e-07,1.96385e-09,0.961069,0.000528623,-3.06937e-07,1.97917e-08,0.961598,0.000528068,-2.47562e-07,-2.15261e-08,0.962125,0.000527508,-3.1214e-07,6.70795e-09,0.962653,0.000526904,-2.92016e-07,-5.30573e-09,0.963179,0.000526304,-3.07934e-07,1.4515e-08,0.963705,0.000525732,-2.64389e-07,6.85048e-09,0.964231,0.000525224,-2.43837e-07,-4.19169e-08,0.964756,0.00052461,-3.69588e-07,4.1608e-08,0.96528,0.000523996,-2.44764e-07,-5.30598e-09,0.965804,0.000523491,-2.60682e-07,-2.03841e-08,0.966327,0.000522908,-3.21834e-07,2.72378e-08,0.966849,0.000522346,-2.40121e-07,-2.89625e-08,0.967371,0.000521779,-3.27008e-07,2.90075e-08,0.967893,0.000521212,-2.39986e-07,-2.74629e-08,0.968414,0.00052065,-3.22374e-07,2.12396e-08,0.968934,0.000520069,-2.58656e-07,2.10922e-09,0.969454,0.000519558,-2.52328e-07,-2.96765e-08,0.969973,0.000518964,-3.41357e-07,5.6992e-08,0.970492,0.000518452,-1.70382e-07,-7.90821e-08,0.97101,0.000517874,-4.07628e-07,8.05224e-08,0.971528,0.000517301,-1.66061e-07,-6.41937e-08,0.972045,0.000516776,-3.58642e-07,5.70429e-08,0.972561,0.00051623,-1.87513e-07,-4.47686e-08,0.973077,0.00051572,-3.21819e-07,2.82237e-09,0.973593,0.000515085,-3.13352e-07,3.34792e-08,0.974108,0.000514559,-2.12914e-07,-1.75298e-08,0.974622,0.000514081,-2.65503e-07,-2.29648e-08,0.975136,0.000513481,-3.34398e-07,4.97843e-08,0.975649,0.000512961,-1.85045e-07,-5.6963e-08,0.976162,0.00051242,-3.55934e-07,5.88585e-08,0.976674,0.000511885,-1.79359e-07,-5.92616e-08,0.977185,0.000511348,-3.57143e-07,5.89785e-08,0.977696,0.000510811,-1.80208e-07,-5.74433e-08,0.978207,0.000510278,-3.52538e-07,5.15854e-08,0.978717,0.000509728,-1.97781e-07,-2.9689e-08,0.979226,0.000509243,-2.86848e-07,7.56591e-09,0.979735,0.000508692,-2.64151e-07,-5.74649e-10,0.980244,0.000508162,-2.65875e-07,-5.26732e-09,0.980752,0.000507615,-2.81677e-07,2.16439e-08,0.981259,0.000507116,-2.16745e-07,-2.17037e-08,0.981766,0.000506618,-2.81856e-07,5.56636e-09,0.982272,0.000506071,-2.65157e-07,-5.61689e-10,0.982778,0.000505539,-2.66842e-07,-3.31963e-09,0.983283,0.000504995,-2.76801e-07,1.38402e-08,0.983788,0.000504483,-2.3528e-07,7.56339e-09,0.984292,0.000504035,-2.1259e-07,-4.40938e-08,0.984796,0.000503478,-3.44871e-07,4.96026e-08,0.985299,0.000502937,-1.96064e-07,-3.51071e-08,0.985802,0.000502439,-3.01385e-07,3.12212e-08,0.986304,0.00050193,-2.07721e-07,-3.0173e-08,0.986806,0.000501424,-2.9824e-07,2.9866e-08,0.987307,0.000500917,-2.08642e-07,-2.96865e-08,0.987808,0.000500411,-2.97702e-07,2.92753e-08,0.988308,0.000499903,-2.09876e-07,-2.78101e-08,0.988807,0.0004994,-2.93306e-07,2.23604e-08,0.989307,0.000498881,-2.26225e-07,-2.02681e-09,0.989805,0.000498422,-2.32305e-07,-1.42531e-08,0.990303,0.000497915,-2.75065e-07,-5.65232e-10,0.990801,0.000497363,-2.76761e-07,1.65141e-08,0.991298,0.000496859,-2.27218e-07,-5.88639e-09,0.991795,0.000496387,-2.44878e-07,7.0315e-09,0.992291,0.000495918,-2.23783e-07,-2.22396e-08,0.992787,0.000495404,-2.90502e-07,2.23224e-08,0.993282,0.00049489,-2.23535e-07,-7.44543e-09,0.993776,0.000494421,-2.45871e-07,7.45924e-09,0.994271,0.000493951,-2.23493e-07,-2.23915e-08,0.994764,0.000493437,-2.90668e-07,2.25021e-08,0.995257,0.000492923,-2.23161e-07,-8.01218e-09,0.99575,0.000492453,-2.47198e-07,9.54669e-09,0.996242,0.000491987,-2.18558e-07,-3.01746e-08,0.996734,0.000491459,-3.09082e-07,5.1547e-08,0.997225,0.000490996,-1.54441e-07,-5.68039e-08,0.997716,0.000490517,-3.24853e-07,5.64594e-08,0.998206,0.000490036,-1.55474e-07,-4.98245e-08,0.998696,0.000489576,-3.04948e-07,2.36292e-08,0.999186,0.000489037,-2.3406e-07,1.49121e-08,0.999674,0.000488613,-1.89324e-07,-2.3673e-08,1.00016,0.000488164,-2.60343e-07,2.01754e-08,1.00065,0.000487704,-1.99816e-07,-5.70288e-08,1.00114,0.000487133,-3.70903e-07,8.87303e-08,1.00162,0.000486657,-1.04712e-07,-5.94737e-08,1.00211,0.000486269,-2.83133e-07,2.99553e-08,1.0026,0.000485793,-1.93267e-07,-6.03474e-08,1.00308,0.000485225,-3.74309e-07,9.2225e-08,1.00357,0.000484754,-9.76345e-08,-7.0134e-08,1.00405,0.000484348,-3.08036e-07,6.91016e-08,1.00454,0.000483939,-1.00731e-07,-8.70633e-08,1.00502,0.000483476,-3.61921e-07,4.07328e-08,1.0055,0.000482875,-2.39723e-07,4.33413e-08,1.00599,0.000482525,-1.09699e-07,-9.48886e-08,1.00647,0.000482021,-3.94365e-07,9.77947e-08,1.00695,0.000481526,-1.00981e-07,-5.78713e-08,1.00743,0.00048115,-2.74595e-07,1.44814e-08,1.00791,0.000480645,-2.31151e-07,-5.42665e-11,1.00839,0.000480182,-2.31314e-07,-1.42643e-08,1.00887,0.000479677,-2.74106e-07,5.71115e-08,1.00935,0.0004793,-1.02772e-07,-9.49724e-08,1.00983,0.000478809,-3.87689e-07,8.43596e-08,1.01031,0.000478287,-1.3461e-07,-4.04755e-09,1.01079,0.000478006,-1.46753e-07,-6.81694e-08,1.01127,0.000477508,-3.51261e-07,3.83067e-08,1.01174,0.00047692,-2.36341e-07,3.41521e-08,1.01222,0.00047655,-1.33885e-07,-5.57058e-08,1.0127,0.000476115,-3.01002e-07,6.94616e-08,1.01317,0.000475721,-9.26174e-08,-1.02931e-07,1.01365,0.000475227,-4.01412e-07,1.03846e-07,1.01412,0.000474736,-8.98751e-08,-7.40321e-08,1.0146,0.000474334,-3.11971e-07,7.30735e-08,1.01507,0.00047393,-9.27508e-08,-9.90527e-08,1.01554,0.000473447,-3.89909e-07,8.47188e-08,1.01602,0.000472921,-1.35753e-07,-1.40381e-09,1.01649,0.000472645,-1.39964e-07,-7.91035e-08,1.01696,0.000472128,-3.77275e-07,7.93993e-08,1.01744,0.000471612,-1.39077e-07,-7.52607e-11,1.01791,0.000471334,-1.39302e-07,-7.90983e-08,1.01838,0.000470818,-3.76597e-07,7.80499e-08,1.01885,0.000470299,-1.42448e-07,5.31733e-09,1.01932,0.00047003,-1.26496e-07,-9.93193e-08,1.01979,0.000469479,-4.24453e-07,1.53541e-07,1.02026,0.00046909,3.617e-08,-1.57217e-07,1.02073,0.000468691,-4.35482e-07,1.177e-07,1.02119,0.000468173,-8.23808e-08,-7.51659e-08,1.02166,0.000467783,-3.07878e-07,6.37538e-08,1.02213,0.000467358,-1.16617e-07,-6.064e-08,1.0226,0.000466943,-2.98537e-07,5.9597e-08,1.02306,0.000466525,-1.19746e-07,-5.85386e-08,1.02353,0.00046611,-2.95362e-07,5.53482e-08,1.024,0.000465685,-1.29317e-07,-4.36449e-08,1.02446,0.000465296,-2.60252e-07,2.20268e-11,1.02493,0.000464775,-2.60186e-07,4.35568e-08,1.02539,0.000464386,-1.29516e-07,-5.50398e-08,1.02586,0.000463961,-2.94635e-07,5.73932e-08,1.02632,0.000463544,-1.22456e-07,-5.53236e-08,1.02678,0.000463133,-2.88426e-07,4.46921e-08,1.02725,0.000462691,-1.5435e-07,-4.23534e-09,1.02771,0.000462369,-1.67056e-07,-2.77507e-08,1.02817,0.000461952,-2.50308e-07,-3.97101e-09,1.02863,0.000461439,-2.62221e-07,4.36348e-08,1.02909,0.000461046,-1.31317e-07,-5.13589e-08,1.02955,0.000460629,-2.85394e-07,4.25913e-08,1.03001,0.000460186,-1.5762e-07,2.0285e-10,1.03047,0.000459871,-1.57011e-07,-4.34027e-08,1.03093,0.000459427,-2.87219e-07,5.41987e-08,1.03139,0.000459015,-1.24623e-07,-5.4183e-08,1.03185,0.000458604,-2.87172e-07,4.33239e-08,1.03231,0.000458159,-1.572e-07,9.65817e-11,1.03277,0.000457845,-1.56911e-07,-4.37103e-08,1.03323,0.0004574,-2.88041e-07,5.55351e-08,1.03368,0.000456991,-1.21436e-07,-5.9221e-08,1.03414,0.00045657,-2.99099e-07,6.21394e-08,1.0346,0.000456158,-1.1268e-07,-7.01275e-08,1.03505,0.000455723,-3.23063e-07,9.91614e-08,1.03551,0.000455374,-2.55788e-08,-8.80996e-08,1.03596,0.000455058,-2.89878e-07,1.48184e-08,1.03642,0.000454523,-2.45422e-07,2.88258e-08,1.03687,0.000454119,-1.58945e-07,-1.09125e-08,1.03733,0.000453768,-1.91682e-07,1.48241e-08,1.03778,0.000453429,-1.4721e-07,-4.83838e-08,1.03823,0.00045299,-2.92361e-07,5.95019e-08,1.03869,0.000452584,-1.13856e-07,-7.04146e-08,1.03914,0.000452145,-3.25099e-07,1.02947e-07,1.03959,0.000451803,-1.62583e-08,-1.02955e-07,1.04004,0.000451462,-3.25123e-07,7.04544e-08,1.04049,0.000451023,-1.1376e-07,-5.96534e-08,1.04094,0.000450616,-2.9272e-07,4.89499e-08,1.04139,0.000450178,-1.45871e-07,-1.69369e-08,1.04184,0.000449835,-1.96681e-07,1.87977e-08,1.04229,0.000449498,-1.40288e-07,-5.82539e-08,1.04274,0.000449043,-3.1505e-07,9.50087e-08,1.04319,0.000448698,-3.00238e-08,-8.33623e-08,1.04364,0.000448388,-2.80111e-07,2.20363e-11,1.04409,0.000447828,-2.80045e-07,8.32742e-08,1.04454,0.000447517,-3.02221e-08,-9.47002e-08,1.04498,0.000447173,-3.14323e-07,5.7108e-08,1.04543,0.000446716,-1.42999e-07,-1.45225e-08,1.04588,0.000446386,-1.86566e-07,9.82022e-10,1.04632,0.000446016,-1.8362e-07,1.05944e-08,1.04677,0.00044568,-1.51837e-07,-4.33597e-08,1.04721,0.000445247,-2.81916e-07,4.36352e-08,1.04766,0.000444814,-1.51011e-07,-1.19717e-08,1.0481,0.000444476,-1.86926e-07,4.25158e-09,1.04855,0.000444115,-1.74171e-07,-5.03461e-09,1.04899,0.000443751,-1.89275e-07,1.58868e-08,1.04944,0.00044342,-1.41614e-07,-5.85127e-08,1.04988,0.000442961,-3.17152e-07,9.89548e-08,1.05032,0.000442624,-2.0288e-08,-9.88878e-08,1.05076,0.000442287,-3.16951e-07,5.81779e-08,1.05121,0.000441827,-1.42418e-07,-1.46144e-08,1.05165,0.000441499,-1.86261e-07,2.79892e-10,1.05209,0.000441127,-1.85421e-07,1.34949e-08,1.05253,0.000440797,-1.44937e-07,-5.42594e-08,1.05297,0.000440344,-3.07715e-07,8.43335e-08,1.05341,0.000439982,-5.47146e-08,-4.46558e-08,1.05385,0.000439738,-1.88682e-07,-2.49193e-08,1.05429,0.000439286,-2.6344e-07,2.5124e-08,1.05473,0.000438835,-1.88068e-07,4.36328e-08,1.05517,0.000438589,-5.71699e-08,-8.04459e-08,1.05561,0.000438234,-2.98508e-07,3.97324e-08,1.05605,0.000437756,-1.79311e-07,4.07258e-08,1.05648,0.000437519,-5.71332e-08,-8.34263e-08,1.05692,0.000437155,-3.07412e-07,5.45608e-08,1.05736,0.000436704,-1.4373e-07,-1.56078e-08,1.05779,0.000436369,-1.90553e-07,7.87043e-09,1.05823,0.000436012,-1.66942e-07,-1.58739e-08,1.05867,0.00043563,-2.14563e-07,5.56251e-08,1.0591,0.000435368,-4.76881e-08,-8.74172e-08,1.05954,0.000435011,-3.0994e-07,5.56251e-08,1.05997,0.000434558,-1.43064e-07,-1.58739e-08,1.06041,0.000434224,-1.90686e-07,7.87042e-09,1.06084,0.000433866,-1.67075e-07,-1.56078e-08,1.06127,0.000433485,-2.13898e-07,5.45609e-08,1.06171,0.000433221,-5.02157e-08,-8.34263e-08,1.06214,0.00043287,-3.00495e-07,4.07258e-08,1.06257,0.000432391,-1.78317e-07,3.97325e-08,1.063,0.000432154,-5.91198e-08,-8.04464e-08,1.06344,0.000431794,-3.00459e-07,4.36347e-08,1.06387,0.000431324,-1.69555e-07,2.5117e-08,1.0643,0.000431061,-9.42041e-08,-2.48934e-08,1.06473,0.000430798,-1.68884e-07,-4.47527e-08,1.06516,0.000430326,-3.03142e-07,8.46951e-08,1.06559,0.000429973,-4.90573e-08,-5.56089e-08,1.06602,0.000429708,-2.15884e-07,1.85314e-08,1.06645,0.000429332,-1.6029e-07,-1.85166e-08,1.06688,0.000428956,-2.1584e-07,5.5535e-08,1.06731,0.000428691,-4.92347e-08,-8.44142e-08,1.06774,0.000428339,-3.02477e-07,4.37032e-08,1.06816,0.000427865,-1.71368e-07,2.88107e-08,1.06859,0.000427609,-8.49356e-08,-3.97367e-08,1.06902,0.00042732,-2.04146e-07,1.09267e-08,1.06945,0.000426945,-1.71365e-07,-3.97023e-09,1.06987,0.00042659,-1.83276e-07,4.9542e-09,1.0703,0.000426238,-1.68414e-07,-1.58466e-08,1.07073,0.000425854,-2.15953e-07,5.84321e-08,1.07115,0.000425597,-4.0657e-08,-9.86725e-08,1.07158,0.00042522,-3.36674e-07,9.78392e-08,1.072,0.00042484,-4.31568e-08,-5.42658e-08,1.07243,0.000424591,-2.05954e-07,1.45377e-11,1.07285,0.000424179,-2.0591e-07,5.42076e-08,1.07328,0.00042393,-4.32877e-08,-9.76357e-08,1.0737,0.00042355,-3.36195e-07,9.79165e-08,1.07412,0.000423172,-4.24451e-08,-5.56118e-08,1.07455,0.00042292,-2.09281e-07,5.32143e-09,1.07497,0.000422518,-1.93316e-07,3.43261e-08,1.07539,0.000422234,-9.0338e-08,-2.34165e-08,1.07581,0.000421983,-1.60588e-07,-5.98692e-08,1.07623,0.000421482,-3.40195e-07,1.43684e-07,1.07666,0.000421233,9.08574e-08,-1.5724e-07,1.07708,0.000420943,-3.80862e-07,1.27647e-07,1.0775,0.000420564,2.0791e-09,-1.1493e-07,1.07792,0.000420223,-3.4271e-07,9.36534e-08,1.07834,0.000419819,-6.17499e-08,-2.12653e-08,1.07876,0.000419632,-1.25546e-07,-8.59219e-09,1.07918,0.000419355,-1.51322e-07,-6.35752e-08,1.0796,0.000418861,-3.42048e-07,1.43684e-07,1.08002,0.000418608,8.90034e-08,-1.53532e-07,1.08043,0.000418326,-3.71593e-07,1.12817e-07,1.08085,0.000417921,-3.31414e-08,-5.93184e-08,1.08127,0.000417677,-2.11097e-07,5.24697e-09,1.08169,0.00041727,-1.95356e-07,3.83305e-08,1.0821,0.000416995,-8.03642e-08,-3.93597e-08,1.08252,0.000416716,-1.98443e-07,-1.0094e-10,1.08294,0.000416319,-1.98746e-07,3.97635e-08,1.08335,0.00041604,-7.94557e-08,-3.97437e-08,1.08377,0.000415762,-1.98687e-07,1.94215e-12,1.08419,0.000415365,-1.98681e-07,3.97359e-08,1.0846,0.000415087,-7.94732e-08,-3.97362e-08,1.08502,0.000414809,-1.98682e-07,-4.31063e-13,1.08543,0.000414411,-1.98683e-07,3.97379e-08,1.08584,0.000414133,-7.94694e-08,-3.97418e-08,1.08626,0.000413855,-1.98695e-07,2.00563e-11,1.08667,0.000413458,-1.98635e-07,3.96616e-08,1.08709,0.000413179,-7.965e-08,-3.9457e-08,1.0875,0.000412902,-1.98021e-07,-1.04281e-09,1.08791,0.000412502,-2.01149e-07,4.36282e-08,1.08832,0.000412231,-7.02648e-08,-5.42608e-08,1.08874,0.000411928,-2.33047e-07,5.42057e-08,1.08915,0.000411624,-7.04301e-08,-4.33527e-08,1.08956,0.000411353,-2.00488e-07,-4.07378e-12,1.08997,0.000410952,-2.005e-07,4.3369e-08,1.09038,0.000410681,-7.03934e-08,-5.42627e-08,1.09079,0.000410378,-2.33182e-07,5.44726e-08,1.0912,0.000410075,-6.97637e-08,-4.44186e-08,1.09161,0.000409802,-2.03019e-07,3.99235e-09,1.09202,0.000409408,-1.91042e-07,2.84491e-08,1.09243,0.000409111,-1.05695e-07,1.42043e-09,1.09284,0.000408904,-1.01434e-07,-3.41308e-08,1.09325,0.000408599,-2.03826e-07,1.58937e-08,1.09366,0.000408239,-1.56145e-07,-2.94438e-08,1.09406,0.000407838,-2.44476e-07,1.01881e-07,1.09447,0.000407655,6.11676e-08,-1.39663e-07,1.09488,0.000407358,-3.57822e-07,9.91432e-08,1.09529,0.00040694,-6.03921e-08,-1.84912e-08,1.09569,0.000406764,-1.15866e-07,-2.51785e-08,1.0961,0.000406457,-1.91401e-07,-4.03115e-12,1.09651,0.000406074,-1.91413e-07,2.51947e-08,1.09691,0.000405767,-1.15829e-07,1.84346e-08,1.09732,0.00040559,-6.05254e-08,-9.89332e-08,1.09772,0.000405172,-3.57325e-07,1.3888e-07,1.09813,0.000404874,5.93136e-08,-9.8957e-08,1.09853,0.000404696,-2.37557e-07,1.853e-08,1.09894,0.000404277,-1.81968e-07,2.48372e-08,1.09934,0.000403987,-1.07456e-07,1.33047e-09,1.09975,0.000403776,-1.03465e-07,-3.01591e-08,1.10015,0.000403479,-1.93942e-07,9.66054e-11,1.10055,0.000403091,-1.93652e-07,2.97727e-08,1.10096,0.000402793,-1.04334e-07,2.19273e-11,1.10136,0.000402585,-1.04268e-07,-2.98604e-08,1.10176,0.000402287,-1.93849e-07,2.10325e-10,1.10216,0.0004019,-1.93218e-07,2.90191e-08,1.10256,0.0004016,-1.06161e-07,2.92264e-09,1.10297,0.000401397,-9.73931e-08,-4.07096e-08,1.10337,0.00040108,-2.19522e-07,4.07067e-08,1.10377,0.000400763,-9.7402e-08,-2.90783e-09,1.10417,0.000400559,-1.06126e-07,-2.90754e-08,1.10457,0.00040026,-1.93352e-07,9.00021e-14,1.10497,0.000399873,-1.93351e-07,2.9075e-08,1.10537,0.000399574,-1.06126e-07,2.90902e-09,1.10577,0.00039937,-9.73992e-08,-4.07111e-08,1.10617,0.000399053,-2.19533e-07,4.07262e-08,1.10657,0.000398736,-9.73541e-08,-2.98424e-09,1.10697,0.000398533,-1.06307e-07,-2.87892e-08,1.10736,0.000398234,-1.92674e-07,-1.06824e-09,1.10776,0.000397845,-1.95879e-07,3.30622e-08,1.10816,0.000397552,-9.66926e-08,-1.19712e-08,1.10856,0.000397323,-1.32606e-07,1.48225e-08,1.10895,0.000397102,-8.81387e-08,-4.73187e-08,1.10935,0.000396784,-2.30095e-07,5.52429e-08,1.10975,0.00039649,-6.4366e-08,-5.44437e-08,1.11014,0.000396198,-2.27697e-07,4.33226e-08,1.11054,0.000395872,-9.77293e-08,3.62656e-10,1.11094,0.000395678,-9.66414e-08,-4.47732e-08,1.11133,0.00039535,-2.30961e-07,5.95208e-08,1.11173,0.000395067,-5.23985e-08,-7.41008e-08,1.11212,0.00039474,-2.74701e-07,1.17673e-07,1.11252,0.000394543,7.83181e-08,-1.58172e-07,1.11291,0.000394225,-3.96199e-07,1.57389e-07,1.1133,0.000393905,7.59679e-08,-1.13756e-07,1.1137,0.000393716,-2.653e-07,5.92165e-08,1.11409,0.000393363,-8.76507e-08,-3.90074e-09,1.11449,0.000393176,-9.93529e-08,-4.36136e-08,1.11488,0.000392846,-2.30194e-07,5.91457e-08,1.11527,0.000392563,-5.27564e-08,-7.376e-08,1.11566,0.000392237,-2.74037e-07,1.16685e-07,1.11606,0.000392039,7.60189e-08,-1.54562e-07,1.11645,0.000391727,-3.87667e-07,1.43935e-07,1.11684,0.000391384,4.4137e-08,-6.35487e-08,1.11723,0.000391281,-1.46509e-07,-8.94896e-09,1.11762,0.000390961,-1.73356e-07,-1.98647e-08,1.11801,0.000390555,-2.3295e-07,8.8408e-08,1.1184,0.000390354,3.22736e-08,-9.53486e-08,1.11879,0.000390133,-2.53772e-07,5.45677e-08,1.11918,0.000389789,-9.0069e-08,-3.71296e-09,1.11957,0.000389598,-1.01208e-07,-3.97159e-08,1.11996,0.000389276,-2.20355e-07,4.33671e-08,1.12035,0.000388966,-9.02542e-08,-1.45431e-08,1.12074,0.000388741,-1.33883e-07,1.48052e-08,1.12113,0.000388518,-8.94678e-08,-4.46778e-08,1.12152,0.000388205,-2.23501e-07,4.46966e-08,1.12191,0.000387892,-8.94114e-08,-1.48992e-08,1.12229,0.000387669,-1.34109e-07,1.49003e-08,1.12268,0.000387445,-8.94082e-08,-4.47019e-08,1.12307,0.000387132,-2.23514e-07,4.4698e-08,1.12345,0.000386819,-8.942e-08,-1.48806e-08,1.12384,0.000386596,-1.34062e-07,1.48245e-08,1.12423,0.000386372,-8.95885e-08,-4.44172e-08,1.12461,0.00038606,-2.2284e-07,4.36351e-08,1.125,0.000385745,-9.19348e-08,-1.09139e-08,1.12539,0.000385528,-1.24677e-07,2.05584e-11,1.12577,0.000385279,-1.24615e-07,1.08317e-08,1.12616,0.000385062,-9.21198e-08,-4.33473e-08,1.12654,0.000384748,-2.22162e-07,4.33481e-08,1.12693,0.000384434,-9.21174e-08,-1.08356e-08,1.12731,0.000384217,-1.24624e-07,-5.50907e-12,1.12769,0.000383968,-1.24641e-07,1.08577e-08,1.12808,0.000383751,-9.20679e-08,-4.34252e-08,1.12846,0.000383437,-2.22343e-07,4.36337e-08,1.12884,0.000383123,-9.14422e-08,-1.19005e-08,1.12923,0.000382904,-1.27144e-07,3.96813e-09,1.12961,0.000382662,-1.15239e-07,-3.97207e-09,1.12999,0.000382419,-1.27155e-07,1.19201e-08,1.13038,0.000382201,-9.1395e-08,-4.37085e-08,1.13076,0.000381887,-2.2252e-07,4.37046e-08,1.13114,0.000381573,-9.14068e-08,-1.19005e-08,1.13152,0.000381355,-1.27108e-07,3.89734e-09,1.1319,0.000381112,-1.15416e-07,-3.68887e-09,1.13228,0.00038087,-1.26483e-07,1.08582e-08,1.13266,0.00038065,-9.39083e-08,-3.97438e-08,1.13304,0.000380343,-2.1314e-07,2.89076e-08,1.13342,0.000380003,-1.26417e-07,4.33225e-08,1.1338,0.00037988,3.55072e-09,-8.29883e-08,1.13418,0.000379638,-2.45414e-07,5.0212e-08,1.13456,0.000379298,-9.47781e-08,1.34964e-09,1.13494,0.000379113,-9.07292e-08,-5.56105e-08,1.13532,0.000378764,-2.57561e-07,1.01883e-07,1.1357,0.000378555,4.80889e-08,-1.13504e-07,1.13608,0.000378311,-2.92423e-07,1.13713e-07,1.13646,0.000378067,4.87176e-08,-1.02931e-07,1.13683,0.000377856,-2.60076e-07,5.95923e-08,1.13721,0.000377514,-8.12988e-08,-1.62288e-08,1.13759,0.000377303,-1.29985e-07,5.32278e-09,1.13797,0.000377059,-1.14017e-07,-5.06237e-09,1.13834,0.000376816,-1.29204e-07,1.49267e-08,1.13872,0.000376602,-8.44237e-08,-5.46444e-08,1.1391,0.000376269,-2.48357e-07,8.44417e-08,1.13947,0.000376026,4.96815e-09,-4.47039e-08,1.13985,0.000375902,-1.29143e-07,-2.48355e-08,1.14023,0.000375569,-2.0365e-07,2.48368e-08,1.1406,0.000375236,-1.2914e-07,4.46977e-08,1.14098,0.000375112,4.95341e-09,-8.44184e-08,1.14135,0.000374869,-2.48302e-07,5.45572e-08,1.14173,0.000374536,-8.463e-08,-1.46013e-08,1.1421,0.000374323,-1.28434e-07,3.8478e-09,1.14247,0.000374077,-1.1689e-07,-7.89941e-10,1.14285,0.000373841,-1.1926e-07,-6.88042e-10,1.14322,0.0003736,-1.21324e-07,3.54213e-09,1.1436,0.000373368,-1.10698e-07,-1.34805e-08,1.14397,0.000373107,-1.51139e-07,5.03798e-08,1.14434,0.000372767,0.,0.}; template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); const float _un = 13 * (4 * 0.950456f * _d); const float _vn = 13 * (9 * _d); float B = blueIdx == 0 ? src.x : src.z; float G = src.y; float R = blueIdx == 0 ? src.z : src.x; if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBGammaTab, GAMMA_TAB_SIZE); } float X = R * 0.412453f + G * 0.357580f + B * 0.180423f; float Y = R * 0.212671f + G * 0.715160f + B * 0.072169f; float Z = R * 0.019334f + G * 0.119193f + B * 0.950227f; float L = splineInterpolate(Y * (LAB_CBRT_TAB_SIZE / 1.5f), c_LabCbrtTab, LAB_CBRT_TAB_SIZE); L = 116.f * L - 16.f; const float d = (4 * 13) / ::fmaxf(X + 15 * Y + 3 * Z, numeric_limits<float>::epsilon()); float u = L * (X * d - _un); float v = L * ((9 * 0.25f) * Y * d - _vn); typename MakeVec<float, dcn>::type dst; dst.x = L; dst.y = u; dst.z = v; return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct RGB2Luv<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (1.f / 255.f); buf.y = src.y * (1.f / 255.f); buf.z = src.z * (1.f / 255.f); RGB2Luv<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 2.55f); dst.y = saturate_cast<uchar>(buf.y * 0.72033898305084743f + 96.525423728813564f); dst.z = saturate_cast<uchar>(buf.z * 0.9732824427480916f + 136.259541984732824f); return dst; } }; // Luv to RGB template <typename T, int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB; template <int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB<float, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<float, scn>::type, typename MakeVec<float, dcn>::type> { __device__ typename MakeVec<float, dcn>::type operator ()(const typename MakeVec<float, scn>::type& src) const { const float _d = 1.f / (0.950456f + 15 + 1.088754f * 3); const float _un = 13 * 4 * 0.950456f * _d; const float _vn = 13 * 9 * _d; float L = src.x; float u = src.y; float v = src.z; float Y1 = (L + 16.f) * (1.f / 116.f); Y1 = Y1 * Y1 * Y1; float Y0 = L * (1.f / 903.3f); float Y = L <= 8.f ? Y0 : Y1; u = (u + _un * L) * 3.f; v = (v + _vn * L) * 4.f; float iv = 1.f / v; iv = ::fmaxf(-0.25f, ::fminf(0.25f, iv)); float X = 3.f * u * iv; float Z = (12.f * 13.f * L - u) * iv - 5.f; float B = (0.055648f * X - 0.204043f + 1.057311f * Z) * Y; float G = (-0.969256f * X + 1.875991f + 0.041556f * Z) * Y; float R = (3.240479f * X - 1.537150f - 0.498535f * Z) * Y; R = ::fminf(::fmaxf(R, 0.f), 1.f); G = ::fminf(::fmaxf(G, 0.f), 1.f); B = ::fminf(::fmaxf(B, 0.f), 1.f); if (srgb) { B = splineInterpolate(B * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); G = splineInterpolate(G * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); R = splineInterpolate(R * GAMMA_TAB_SIZE, c_sRGBInvGammaTab, GAMMA_TAB_SIZE); } typename MakeVec<float, dcn>::type dst; dst.x = blueIdx == 0 ? B : R; dst.y = G; dst.z = blueIdx == 0 ? R : B; setAlpha(dst, ColorChannel<float>::max()); return dst; } }; template <int scn, int dcn, bool srgb, int blueIdx> struct Luv2RGB<uchar, scn, dcn, srgb, blueIdx> : unary_function<typename MakeVec<uchar, scn>::type, typename MakeVec<uchar, dcn>::type> { __device__ typename MakeVec<uchar, dcn>::type operator ()(const typename MakeVec<uchar, scn>::type& src) const { float3 buf; buf.x = src.x * (100.f / 255.f); buf.y = src.y * 1.388235294117647f - 134.f; buf.z = src.z * 1.027450980392157f - 140.f; Luv2RGB<float, 3, 3, srgb, blueIdx> cvtf; buf = cvtf(buf); typename MakeVec<uchar, dcn>::type dst; dst.x = saturate_cast<uchar>(buf.x * 255.f); dst.y = saturate_cast<uchar>(buf.y * 255.f); dst.z = saturate_cast<uchar>(buf.z * 255.f); setAlpha(dst, ColorChannel<uchar>::max()); return dst; } }; #undef CV_CUDEV_DESCALE } }} #endif
145.386707
46,899
0.695925
JosephGeoBenjamin
6d4ed7876e5f9dce771663f2de10ce140f057e9c
1,694
cpp
C++
lib/src/Delphi/Syntax/DelphiCaseElseClauseSyntax.cpp
henrikfroehling/polyglot
955fb37c2f54ebbaf933c16bf9e0e4bcca8a4142
[ "MIT" ]
null
null
null
lib/src/Delphi/Syntax/DelphiCaseElseClauseSyntax.cpp
henrikfroehling/polyglot
955fb37c2f54ebbaf933c16bf9e0e4bcca8a4142
[ "MIT" ]
50
2021-06-30T20:01:50.000Z
2021-11-28T16:21:26.000Z
lib/src/Delphi/Syntax/DelphiCaseElseClauseSyntax.cpp
henrikfroehling/polyglot
955fb37c2f54ebbaf933c16bf9e0e4bcca8a4142
[ "MIT" ]
null
null
null
#include "Delphi/Syntax/DelphiCaseElseClauseSyntax.hpp" #include <cassert> #include "interlinck/Core/Syntax/ISyntaxToken.hpp" #include "interlinck/Core/Syntax/SyntaxKinds.hpp" #include "Core/Support/SyntaxFactory.hpp" namespace interlinck::Delphi::Syntax { using Core::Support::SyntaxFactory; using namespace Core::Syntax; DelphiCaseElseClauseSyntax::DelphiCaseElseClauseSyntax(const ISyntaxToken* elseKeyword, const DelphiStatementListSyntax* statements) noexcept : DelphiSyntaxNode{SyntaxKind::CaseElseClause}, _elseKeyword{elseKeyword}, _statements{statements} { setPosition(_elseKeyword->position()); adjustWidthAndFlags(_elseKeyword); adjustWidthAndFlags(_statements); } SyntaxVariant DelphiCaseElseClauseSyntax::child(il_size index) const noexcept { assert(index < childCount()); switch (index) { case 0: return SyntaxVariant::asToken(_elseKeyword); case 1: return SyntaxVariant::asNode(_statements); default: return SyntaxVariant::empty(); } } const DelphiCaseElseClauseSyntax* DelphiCaseElseClauseSyntax::create(SyntaxFactory& syntaxFactory, const ISyntaxToken* elseKeyword, const DelphiStatementListSyntax* statements) noexcept { assert(elseKeyword != nullptr); assert(elseKeyword->syntaxKind() == SyntaxKind::ElseKeyword); assert(statements != nullptr); return syntaxFactory.syntaxNode<DelphiCaseElseClauseSyntax>(elseKeyword, statements); } } // end namespace interlinck::Delphi::Syntax
35.291667
122
0.680638
henrikfroehling
6d4f549961cb2b5a88482d5c1e90c9c4cb7bbd06
748
hpp
C++
include/shiva/windows/AssetBrowser.hpp
kochol/ariyana_old
efdd20eea0f1fafa803fb254d4775aa1915ba3a1
[ "MIT" ]
1
2022-01-11T01:15:43.000Z
2022-01-11T01:15:43.000Z
include/shiva/windows/AssetBrowser.hpp
kochol/ariyana_old
efdd20eea0f1fafa803fb254d4775aa1915ba3a1
[ "MIT" ]
null
null
null
include/shiva/windows/AssetBrowser.hpp
kochol/ariyana_old
efdd20eea0f1fafa803fb254d4775aa1915ba3a1
[ "MIT" ]
2
2020-09-02T17:24:58.000Z
2020-09-02T17:40:44.000Z
#pragma once #include "shiva/shivadef.hpp" #include "shiva/DirectoryTree.hpp" #include "../../../src/editor/windows/AssetGui.hpp" #include "ari/en/gui/DockableWindow.hpp" #include "DockWindow.hpp" namespace ari { class Button; class Dock; class DockSpace; } namespace shiva { class AssetGui; class SHIVA_API AssetBrowser : public DockWindow { public: ~AssetBrowser(); void Init(ari::World* p_world); private: void UpdateAssets(const DirectoryTree& _tree); static DirectoryTree* FindPathTree(DirectoryTree* _tree, const std::string& _path); void OnDblClick(AssetGui* _sender); void OnRightClick(AssetGui* _sender); std::vector<AssetGui*> m_vAssets; }; // AssetBrowser } // shiva
19.684211
86
0.695187
kochol
6d4f62858f5ff01f3684fde4010495b163d57f87
96,411
cpp
C++
src/game/items/CItemMulti.cpp
criminalx/Source-X
7e656bb9edcbe78dd735feeb12a9ccff3b0f2fe3
[ "Apache-2.0" ]
21
2020-01-29T14:53:31.000Z
2022-03-20T10:53:27.000Z
src/game/items/CItemMulti.cpp
criminalx/Source-X
7e656bb9edcbe78dd735feeb12a9ccff3b0f2fe3
[ "Apache-2.0" ]
435
2020-01-20T12:50:15.000Z
2022-03-29T03:31:27.000Z
src/game/items/CItemMulti.cpp
criminalx/Source-X
7e656bb9edcbe78dd735feeb12a9ccff3b0f2fe3
[ "Apache-2.0" ]
47
2020-01-21T23:25:38.000Z
2022-03-24T21:54:32.000Z
#include "../../common/resource/CResourceLock.h" #include "../../common/CException.h" #include "../../common/sphereproto.h" #include "../chars/CChar.h" #include "../clients/CClient.h" #include "../CServer.h" #include "../CWorldMap.h" #include "../triggers.h" #include "CItemMulti.h" #include "CItemShip.h" #include "CItemContainer.h" #include <algorithm> ///////////////////////////////////////////////////////////////////////////// CItemMulti::CItemMulti(ITEMID_TYPE id, CItemBase * pItemDef, bool fTurnable) : // CItemBaseMulti CTimedObject(PROFILE_MULTIS), CItem(id, pItemDef), CCMultiMovable(fTurnable) { CItemBaseMulti * pItemBase = static_cast<CItemBaseMulti*>(Base_GetDef()); _shipSpeed.period = pItemBase->_shipSpeed.period; _shipSpeed.tiles = pItemBase->_shipSpeed.tiles; _eSpeedMode = pItemBase->m_SpeedMode; m_pRegion = nullptr; _iHouseType = HOUSE_PRIVATE; _iMultiCount = pItemBase->_iMultiCount; _uiBaseStorage = pItemBase->_iBaseStorage; _uiBaseVendors = pItemBase->_iBaseVendors; _uiLockdownsPercent = pItemBase->_iLockdownsPercent; _uiIncreasedStorage = 0; _fIsAddon = false; } CItemMulti::~CItemMulti() { EXC_TRY("Cleanup in destructor"); ADDTOCALLSTACK("CItemMulti::~CItemMulti"); if (!m_pRegion) { return; } if (_uidGuild.IsValidUID()) { SetGuild(CUID()); } if (_uidOwner.IsValidUID()) { SetOwner(CUID()); } RemoveAllKeys(); if (!_lCoowners.empty()) { for (const CUID& charUID : _lCoowners) { DeleteCoowner(charUID, false); } } if (!_lFriends.empty()) { for (const CUID& charUID : _lFriends) { DeleteFriend(charUID, false); } } if (!_lVendors.empty()) { for (const CUID& charUID : _lVendors) { DeleteVendor(charUID, false); } } if (!_lLockDowns.empty()) { UnlockAllItems(); } if (!_lComps.empty()) { for (const CUID& itemUID : _lComps) { DeleteComponent(itemUID, false); } _lComps.clear(); } if (!_lSecureContainers.empty()) { for (const CUID& itemUID : _lSecureContainers) { Release(itemUID, false); } _lSecureContainers.clear(); } if (!_lAddons.empty()) { /* for (const CUID& itemUID : _lAddons) { CItemMulti *pItem = static_cast<CItemMulti*>(itemUID.ItemFind()); if (pItem) { DeleteAddon(itemUID); } } */ _lAddons.clear(); } CItemContainer *pMovingCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); if (pMovingCrate) { SetMovingCrate(CUID()); } MultiUnRealizeRegion(); // unrealize before removed from ground. // Must remove early because virtuals will fail in child destructor. // Attempt to remove all the accessory junk. // NOTE: assume we have already been removed from Top Level DeletePrepare(); delete m_pRegion; EXC_CATCH; } bool CItemMulti::Delete(bool fForce) { RemoveAllComponents(); return CObjBase::Delete(fForce); } const CItemBaseMulti * CItemMulti::Multi_GetDef() const noexcept { return static_cast <const CItemBaseMulti *>(Base_GetDef()); } CRegion * CItemMulti::GetRegion() const noexcept { return m_pRegion; } int CItemMulti::GetSideDistanceFromCenter(DIR_TYPE dir) const { ADDTOCALLSTACK("CItemMulti::GetSideDistanceFromCenter"); const CItemBaseMulti* pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); return pMultiDef->GetDistanceDir(dir); } int CItemMulti::Multi_GetDistanceMax() const { ADDTOCALLSTACK("CItemMulti::Multi_GetDistanceMax"); const CItemBaseMulti * pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); return pMultiDef->GetDistanceMax(); } const CItemBaseMulti * CItemMulti::Multi_GetDefByID(ITEMID_TYPE id) // static { ADDTOCALLSTACK("CItemMulti::Multi_GetDefByID"); const CItemBase * pItemBase = CItemBase::FindItemBase(id); return dynamic_cast <const CItemBaseMulti *>(pItemBase); } bool CItemMulti::MultiRealizeRegion() { ADDTOCALLSTACK("CItemMulti::MultiRealizeRegion"); // Add/move a region for the multi so we know when we are in it. // RETURN: ignored. if (!IsTopLevel() || IsType(IT_MULTI_ADDON)) { return false; } const CItemBaseMulti * pMultiDef = Multi_GetDef(); if (pMultiDef == nullptr) { g_Log.EventError("Bad Multi type 0%x, uid=0%x.\n", GetID(), (dword)GetUID()); return false; } if (m_pRegion == nullptr) { const CResourceID rid(GetUID().GetPrivateUID(), 0); m_pRegion = new CRegionWorld(rid); } // Get Background region. const CPointMap& pt = GetTopPoint(); const CRegionWorld * pRegionBack = dynamic_cast <CRegionWorld*> (pt.GetRegion(REGION_TYPE_AREA)); if (!pRegionBack) { g_Log.EventError("Can't realize multi region at invalid P=%hd,%hd,%hhd,%hhu. Multi uid=0%x.\n", pt.m_x, pt.m_y, pt.m_z, pt.m_map, (dword)GetUID()); return false; } ASSERT(pRegionBack != m_pRegion); // Create the new region rectangle. CRectMap rect = pMultiDef->m_rect; rect.m_map = pt.m_map; rect.OffsetRect(pt.m_x, pt.m_y); m_pRegion->SetRegionRect(rect); m_pRegion->m_pt = pt; dword dwFlags = pMultiDef->m_dwRegionFlags; if (IsType(IT_SHIP)) { dwFlags |= REGION_FLAG_SHIP; } else { dwFlags |= pRegionBack->GetRegionFlags(); // Houses get some of the attribs of the land around it. } m_pRegion->SetRegionFlags(dwFlags); tchar *pszTemp = Str_GetTemp(); snprintf(pszTemp, SCRIPT_MAX_LINE_LEN, "%s (%s)", pRegionBack->GetName(), GetName()); m_pRegion->SetName(pszTemp); m_pRegion->_pMultiLink = this; return m_pRegion->RealizeRegion(); } void CItemMulti::MultiUnRealizeRegion() { ADDTOCALLSTACK("CItemMulti::MultiUnRealizeRegion"); if (m_pRegion == nullptr) { return; } m_pRegion->_pMultiLink = nullptr; m_pRegion->UnRealizeRegion(); // find all creatures in the region and remove this from them. CWorldSearch Area(m_pRegion->m_pt, Multi_GetDistanceMax()); Area.SetSearchSquare(true); for (;;) { CChar * pChar = Area.GetChar(); if (pChar == nullptr) { break; } if (pChar->m_pArea != m_pRegion) { continue; } pChar->MoveToRegionReTest(REGION_TYPE_AREA); } } bool CItemMulti::Multi_CreateComponent(ITEMID_TYPE id, short dx, short dy, char dz, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::Multi_CreateComponent"); CItem * pItem = CreateTemplate(id); ASSERT(pItem); CPointMap pt(GetTopPoint()); pt.m_x += dx; pt.m_y += dy; pt.m_z += dz; bool fNeedKey = false; switch (pItem->GetType()) { case IT_SIGN_GUMP: case IT_SHIP_TILLER: pItem->m_uidLink = GetUID(); FALLTHROUGH; case IT_KEY: // it will get locked down with the house ? pItem->m_itKey.m_UIDLock.SetPrivateUID(dwKeyCode); // Set the key id for the key/sign. m_uidLink.SetPrivateUID(pItem->GetUID()); // Do not break, those need fNeedKey set to true. FALLTHROUGH; case IT_DOOR: case IT_CONTAINER: fNeedKey = true; break; default: break; } pItem->SetAttr(ATTR_MOVE_NEVER | (m_Attr&(ATTR_MAGIC | ATTR_INVIS))); pItem->m_uidLink = GetUID(); // lock it down with the structure. if (pItem->IsTypeLockable() || pItem->IsTypeLocked()) { pItem->m_itContainer.m_UIDLock.SetPrivateUID(dwKeyCode); // Set the key id for the door/key/sign. pItem->m_itContainer.m_dwLockComplexity = 10000; // never pickable. } pItem->r_ExecSingle("EVENTS +ei_house_component"); pItem->MoveToUpdate(pt); OnComponentCreate(pItem, false); // TODO: how do i know if that's an addon? AddComponent(pItem->GetUID()); if (IsType(IT_MULTI_ADDON)) { fNeedKey = false; } return fNeedKey; } void CItemMulti::Multi_Setup(CChar *pChar, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::Multi_Setup"); // Create house or Ship extra stuff. // ARGS: // dwKeyCode = set the key code for the doors/sides to this in case it's a drydocked ship. // NOTE: // This can only be done after the house is given location. const CItemBaseMulti * pMultiDef = Multi_GetDef(); // We are top level. if (pMultiDef == nullptr || !IsTopLevel()) { return; } if (dwKeyCode == UID_CLEAR) { dwKeyCode = GetUID(); } // ??? SetTimeout( GetDecayTime()); house decay ? bool fNeedKey = false; GenerateBaseComponents(&fNeedKey, dwKeyCode); if (IsType(IT_MULTI_ADDON)) // Addons doesn't require keys and are not added to any list. { return; } Multi_GetSign(); // set the m_uidLink if (pChar) { SetOwner(pChar->GetUID()); if (fNeedKey) { m_itShip.m_UIDCreator = pChar->GetUID(); if (IsType(IT_SHIP)) { if (g_Cfg._fAutoShipKeys) { GenerateKey(pChar->GetUID(), true); } } else { if (g_Cfg._fAutoHouseKeys) { GenerateKey(pChar->GetUID(), true); } } } } pChar->r_Call("f_multi_setup", pChar, nullptr, nullptr, nullptr); } bool CItemMulti::Multi_IsPartOf(const CItem * pItem) const { ADDTOCALLSTACK("CItemMulti::Multi_IsPartOf"); // Assume it is in my area test already. // IT_MULTI // IT_SHIP if (!pItem) { return false; } if (pItem == this) { return true; } if (pItem->m_uidLink == GetUID()) { return true; } const CUID uidItem = pItem->GetUID(); if (GetLockedItemIndex(uidItem) != -1) { return true; } if (GetSecuredContainerIndex(uidItem) != -1) { return true; } if (GetAddonIndex(uidItem) != -1) { return true; } if (GetComponentIndex(uidItem) != -1) { return true; } return false; } CItem * CItemMulti::Multi_FindItemComponent(int iComp) const { ADDTOCALLSTACK("CItemMulti::Multi_FindItemComponent"); if ((int)_lComps.size() > iComp) { return _lComps[(size_t)iComp].ItemFind(); } return nullptr; } CItem * CItemMulti::Multi_FindItemType(IT_TYPE type) const { ADDTOCALLSTACK("CItemMulti::Multi_FindItemType"); // Find a part of this multi nearby. if (!IsTopLevel()) { return nullptr; } CWorldSearch Area(GetTopPoint(), Multi_GetDistanceMax()); Area.SetSearchSquare(true); for (;;) { CItem * pItem = Area.GetItem(); if (pItem == nullptr) { return nullptr; } if (!Multi_IsPartOf(pItem)) { continue; } if (pItem->IsType(type)) { return(pItem); } } } bool CItemMulti::_OnTick() { if (!CCMultiMovable::_OnTick()) { return CItem::_OnTick(); } return true; } void CItemMulti::OnMoveFrom() { ADDTOCALLSTACK("CItemMulti::OnMoveFrom"); // Being removed from the top level. // Might just be moving. if (IsType(IT_MULTI_ADDON)) // Addons doesn't have region, don't try to unrealize it. { CItemMulti *pMulti = m_pRegion->_pMultiLink; if (pMulti) { pMulti->DeleteAddon(GetUID()); } m_pRegion = nullptr; } else { ASSERT(m_pRegion); m_pRegion->UnRealizeRegion(); } } bool CItemMulti::MoveTo(const CPointMap& pt, bool fForceFix) // Put item on the ground here. { ADDTOCALLSTACK("CItemMulti::MoveTo"); // Move this item to it's point in the world. (ground/top level) if (!CItem::MoveTo(pt, fForceFix)) { return false; } // Multis need special region info to track when u are inside them. // Add new region info. if (IsType(IT_MULTI_ADDON)) // Addons doesn't have region, don't try to realize it. { const CPointMap& ptTop = GetTopPoint(); CRegionWorld *pRegion = dynamic_cast<CRegionWorld*>(ptTop.GetRegion(REGION_TYPE_HOUSE)); if (!pRegion) { pRegion = dynamic_cast<CRegionWorld*>(ptTop.GetRegion(REGION_TYPE_AREA)); } ASSERT(pRegion); m_pRegion = pRegion; CItemMulti *pMulti = m_pRegion->_pMultiLink; if (pMulti) { pMulti->AddAddon(GetUID()); } } else { if (m_pRegion) { m_pRegion->UnRealizeRegion(); } MultiRealizeRegion(); } return true; } CItem * CItemMulti::Multi_GetSign() { ADDTOCALLSTACK("CItemMulti::Multi_GetSign"); // Get my sign or tiller link. CItem * pTiller = m_uidLink.ItemFind(); if (pTiller == nullptr) { pTiller = Multi_FindItemType(IsType(IT_SHIP) ? IT_SHIP_TILLER : IT_SIGN_GUMP); if (pTiller == nullptr) { return(this); } m_uidLink = pTiller->GetUID(); // Link the multi to it's sign/tiller } return pTiller; } void CItemMulti::OnHearRegion(lpctstr pszCmd, CChar * pSrc) { ADDTOCALLSTACK("CItemMulti::OnHearRegion"); // IT_SHIP or IT_MULTI const CItemBaseMulti * pMultiDef = Multi_GetDef(); if (pMultiDef == nullptr) return; TALKMODE_TYPE mode = TALKMODE_SAY; for (size_t i = 0; i < pMultiDef->m_Speech.size(); ++i) { CResourceLink * pLink = pMultiDef->m_Speech[i].GetRef(); ASSERT(pLink); CResourceLock s; if (!pLink->ResourceLock(s)) continue; TRIGRET_TYPE iRet = OnHearTrigger(s, pszCmd, pSrc, mode); if (iRet == TRIGRET_ENDIF || iRet == TRIGRET_RET_FALSE) continue; break; } } void CItemMulti::RevokePrivs(const CUID& uidSrc) { ADDTOCALLSTACK("CItemMulti::RevokePrivs"); if (!uidSrc.IsValidUID()) { return; } if (IsOwner(uidSrc)) { SetOwner(CUID()); } else if (GetCoownerIndex(uidSrc) >= 0) { DeleteCoowner(uidSrc, true); } else if (GetFriendIndex(uidSrc) >= 0) { DeleteFriend(uidSrc, true); } else if (GetBanIndex(uidSrc) >= 0) { DeleteBan(uidSrc, true); } else if (GetAccessIndex(uidSrc) >= 0) { DeleteAccess(uidSrc, true); } else if (GetVendorIndex(uidSrc) >= 0) { DeleteVendor(uidSrc, true); } } void CItemMulti::SetOwner(const CUID& uidOwner) { ADDTOCALLSTACK("CItemMulti::SetOwner"); CChar *pOldOwner = _uidOwner.CharFind(); _uidOwner.InitUID(); if (pOldOwner) // Old Owner may not exist, was removed? { if (!pOldOwner->m_pPlayer) { g_Log.EventWarn("Multi (UID 0%x) owned by a NPC (UID 0%x)?\n", (dword)GetUID(), (dword)pOldOwner->GetUID()); } else { CMultiStorage* pMultiStorage = pOldOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } RemoveKeys(pOldOwner->GetUID()); } if (!uidOwner.IsValidUID()) { return; } RevokePrivs(uidOwner); CChar *pOwner = uidOwner.CharFind(); if (pOwner) { if (!pOwner->m_pPlayer) { g_Log.EventWarn("Multi (UID 0%x): trying to set owner to a non-playing character (UID 0%x)?\n", (dword)GetUID(), (dword)uidOwner); } else { CMultiStorage* pMultiStorage = pOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->AddMulti(GetUID(), HP_OWNER); } } } _uidOwner = uidOwner; } bool CItemMulti::IsOwner(const CUID& uidTarget) const { return (_uidOwner == uidTarget); } CUID CItemMulti::GetOwner() const { if (_uidOwner.IsValidUID()) { return _uidOwner; } return {}; } void CItemMulti::SetGuild(const CUID& uidGuild) { ADDTOCALLSTACK("CItemMulti::SetGuild"); CItemStone *pGuildStone = static_cast<CItemStone*>(GetGuildStone().ItemFind()); _uidGuild.InitUID(); if (pGuildStone) // Old Guild may not exist, was it removed...? { CMultiStorage* pMultiStorage = pGuildStone->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); // ... if not, unlink it from this multi. } } if (!uidGuild.IsValidUID()) // Just clearing it { return; } _uidGuild = uidGuild; // Set the Guild* to a new guildstone. pGuildStone = static_cast<CItemStone*>(uidGuild.ItemFind()); CMultiStorage* pMultiStorage = pGuildStone->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_GUILD); } bool CItemMulti::IsGuild(const CUID& uidTarget) const { return (_uidGuild == uidTarget); } CUID CItemMulti::GetGuildStone() const { if (_uidGuild.IsValidUID()) { return _uidGuild; } return {}; } void CItemMulti::AddCoowner(const CUID& uidCoowner) { ADDTOCALLSTACK("CItemMulti::AddCoowner"); if (!uidCoowner.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetCoownerIndex(uidCoowner) >= 0) { return; } } CChar *pCoowner = uidCoowner.CharFind(); if (!pCoowner || !pCoowner->m_pPlayer) { return; } RevokePrivs(uidCoowner); CMultiStorage* pMultiStorage = pCoowner->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_COOWNER); _lCoowners.emplace_back(uidCoowner); } void CItemMulti::DeleteCoowner(const CUID& uidCoowner, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteCoowner"); for (size_t i = 0; i < _lCoowners.size(); ++i) { const CUID& uid = _lCoowners[i]; if (uid == uidCoowner) { if (fRemoveFromList) { _lCoowners.erase(_lCoowners.begin() + i); } CChar *pCoowner = uidCoowner.CharFind(); if (!pCoowner || !pCoowner->m_pPlayer) { continue; } CMultiStorage* pMultiStorage = pCoowner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } RemoveKeys(uid); return; } } } size_t CItemMulti::GetCoownerCount() const { return _lCoowners.size(); } int CItemMulti::GetCoownerIndex(const CUID& uidTarget) const { ADDTOCALLSTACK("CItemMulti::GetCoownerIndex"); if (_lCoowners.empty()) { return -1; } for (size_t i = 0; i < _lCoowners.size(); ++i) { if (_lCoowners[i] == uidTarget) { return (int)i; } } return -1; } void CItemMulti::AddFriend(const CUID& uidFriend) { ADDTOCALLSTACK("CItemMulti::AddFriend"); if (!uidFriend.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetFriendIndex(uidFriend) >= 0) { return; } } CChar *pFriend = uidFriend.CharFind(); if (!pFriend || !pFriend->m_pPlayer) { return; } RevokePrivs(uidFriend); CMultiStorage* pMultiStorage = pFriend->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_FRIEND); _lFriends.emplace_back(uidFriend); } void CItemMulti::DeleteFriend(const CUID& uidFriend, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteFriend"); for (size_t i = 0; i < _lFriends.size(); ++i) { if (_lFriends[i] == uidFriend) { if (fRemoveFromList) { _lFriends.erase(_lFriends.begin() + i); } CChar *pFriend = uidFriend.CharFind(); if (!pFriend || !pFriend->m_pPlayer) { continue; } CMultiStorage* pMultiStorage = pFriend->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } RemoveKeys(uidFriend); return; } } } size_t CItemMulti::GetFriendCount() const { return _lFriends.size(); } int CItemMulti::GetFriendIndex(const CUID& uidFriend) const { ADDTOCALLSTACK("CItemMulti::GetFriendIndex"); if (_lFriends.empty()) { return -1; } for (size_t i = 0; i < _lFriends.size(); ++i) { if (_lFriends[i] == uidFriend) { return (int)i; } } return -1; } void CItemMulti::AddBan(const CUID& uidBan) { ADDTOCALLSTACK("CItemMulti::AddBan"); if (!uidBan.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetBanIndex(uidBan) >= 0) { return; } } CChar *pBan = uidBan.CharFind(); if (!pBan || !pBan->m_pPlayer) { return; } RevokePrivs(uidBan); CMultiStorage* pMultiStorage = pBan->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_BAN); _lBans.emplace_back(uidBan); } void CItemMulti::DeleteBan(const CUID& uidBan, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteBan"); for (size_t i = 0; i < _lBans.size(); ++i) { if (_lBans[i] == uidBan) { if (fRemoveFromList) { _lBans.erase(_lBans.begin() + i); } CChar *pBan = uidBan.CharFind(); if (pBan && pBan->m_pPlayer) { CMultiStorage* pMultiStorage = pBan->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } return; } } } size_t CItemMulti::GetBanCount() const { return _lBans.size(); } int CItemMulti::GetBanIndex(const CUID& uidBan) const { ADDTOCALLSTACK("CItemMulti::GetBanIndex"); if (_lBans.empty()) { return -1; } for (size_t i = 0; i < _lBans.size(); ++i) { if (_lBans[i] == uidBan) { return (int)i; } } return -1; } void CItemMulti::AddAccess(const CUID& uidAccess) { ADDTOCALLSTACK("CItemMulti::AddAccess"); if (!uidAccess.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetAccessIndex(uidAccess) >= 0) { return; } } CChar *pAccess = uidAccess.CharFind(); if (!pAccess || !pAccess->m_pPlayer) { return; } RevokePrivs(uidAccess); CMultiStorage* pMultiStorage = pAccess->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_ACCESSONLY); _lAccesses.emplace_back(uidAccess); } void CItemMulti::DeleteAccess(const CUID& uidAccess, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteAccess"); for (size_t i = 0; i < _lAccesses.size(); ++i) { if (_lAccesses[i] == uidAccess) { if (fRemoveFromList) { _lAccesses.erase(_lAccesses.begin() + i); } CChar *pAccess = uidAccess.CharFind(); if (pAccess && pAccess->m_pPlayer) { CMultiStorage* pMultiStorage = pAccess->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } return; } } } size_t CItemMulti::GetAccessCount() const { return _lAccesses.size(); } int CItemMulti::GetAccessIndex(const CUID& uidAccess) const { if (_lAccesses.empty()) { return -1; } for (size_t i = 0; i < _lAccesses.size(); ++i) { if (_lAccesses[i] == uidAccess) { return (int)i; } } return -1; } void CItemMulti::Eject(const CUID& uidChar) { if (!uidChar.IsValidUID()) { return; } CChar *pChar = uidChar.CharFind(); ASSERT(pChar); pChar->Spell_Teleport(m_uidLink.ItemFind()->GetTopPoint(), true, false); } void CItemMulti::EjectAll(CUID uidCharNoTp) { CWorldSearch Area(m_pRegion->m_pt, Multi_GetDistanceMax()); Area.SetSearchSquare(true); CChar *pCharNoTp = uidCharNoTp.CharFind(); for (;;) { CChar * pChar = Area.GetChar(); if (pChar == nullptr) { break; } if (pChar->m_pArea != m_pRegion) { continue; } if (pChar == pCharNoTp) // Eject all but owner? ie enter customize { continue; } Eject(pChar->GetUID()); } } CItem *CItemMulti::GenerateKey(const CUID& uidTarget, bool fDupeOnBank) { ADDTOCALLSTACK("CItemMulti::GenerateKey"); if (!uidTarget.IsValidUID()) { return nullptr; } CChar *pTarget = uidTarget.CharFind(); if (!pTarget) { return nullptr; } // Create the key to the door. ITEMID_TYPE id = IsAttr(ATTR_MAGIC) ? ITEMID_KEY_MAGIC : ITEMID_KEY_COPPER; CItem *pKey = CreateScript(id, pTarget); ASSERT(pKey); pKey->SetType(IT_KEY); if (g_Cfg.m_fAutoNewbieKeys) { pKey->SetAttr(ATTR_NEWBIE); } pKey->SetAttr(m_Attr&ATTR_MAGIC); pKey->m_itKey.m_UIDLock.SetPrivateUID(GetUID()); pKey->m_uidLink = GetUID(); if (fDupeOnBank) { // Put in your bankbox CItem* pKeyDupe = CItem::CreateDupeItem(pKey); CItemContainer* pContBank = pTarget->GetBank(); pContBank->ContentAdd(pKeyDupe); pTarget->SysMessageDefault(DEFMSG_MSG_KEY_DUPEBANK); } // Put in your pack CItemContainer* pContPack = pTarget->GetPackSafe(); pContPack->ContentAdd(pKey); return pKey; } void CItemMulti::RemoveKeys(const CUID& uidTarget) { ADDTOCALLSTACK("CItemMulti::RemoveKeys"); if (!uidTarget.IsValidUID()) { return; } CChar* pTarget = uidTarget.CharFind(); if (!pTarget) { return; } const CUID uidHouse(GetUID()); CItemContainer* pTargPack = pTarget->GetPack(); if (pTargPack) { for (CSObjContRec* pObjRec : pTargPack->GetIterationSafeCont()) { CItem* pItemKey = static_cast<CItem*>(pObjRec); if (pItemKey->m_uidLink == uidHouse) { pItemKey->Delete(); } } } } void CItemMulti::RemoveAllKeys() { ADDTOCALLSTACK("CItemMulti::RemoveAllKeys"); if (g_Cfg._fAutoHouseKeys == 0) // Only when AutoHouseKeys != 0 { return; } RemoveKeys(GetOwner()); if (!_lCoowners.empty()) { for (const CUID& itCoowner : _lCoowners) { RemoveKeys(itCoowner); } } if (!_lFriends.empty()) { for (const CUID& itFriend : _lFriends) { RemoveKeys(itFriend); } } if (!_lAccesses.empty()) { for (const CUID& itAccess : _lAccesses) { RemoveKeys(itAccess); } } } int16 CItemMulti::GetMultiCount() const { return _iMultiCount; } void CItemMulti::Redeed(bool fDisplayMsg, bool fMoveToBank, CUID uidChar) { ADDTOCALLSTACK("CItemMulti::Redeed"); if (GetKeyNum("REMOVED") > 0) // Just don't pass from here again, to avoid duplicated deeds. { return; } TRIGRET_TYPE tRet = TRIGRET_RET_FALSE; bool fTransferAll = false; ITEMID_TYPE itDeed = IsType(IT_SHIP) ? ITEMID_SHIP_PLANS1 : ITEMID_DEED1; CItem *pDeed = CItem::CreateBase(itDeed); ASSERT(pDeed); tchar *pszName = Str_GetTemp(); const CItemBaseMulti * pItemBase = static_cast<const CItemBaseMulti*>(Base_GetDef()); snprintf(pszName, STR_TEMPLENGTH, g_Cfg.GetDefaultMsg(DEFMSG_DEED_NAME), pItemBase->GetName()); pDeed->SetName(pszName); bool fIsAddon = IsType(IT_MULTI_ADDON); if (fIsAddon) { CItemMulti *pMulti = static_cast<CItemMulti*>(m_uidLink.ItemFind()); if (pMulti) { pMulti->DeleteAddon(GetUID()); } } CScriptTriggerArgs args(pDeed); args.m_iN1 = itDeed; args.m_iN2 = 1; // Transfer / Redeed all items to the moving crate. args.m_iN3 = fMoveToBank; // Transfer the Moving Crate to the owner's bank. if (IsTrigUsed(TRIGGER_REDEED)) { tRet = OnTrigger(ITRIG_Redeed, uidChar.CharFind(), &args); if (args.m_iN2 == 0) { fMoveToBank = false; } else { fTransferAll = true; fMoveToBank = args.m_iN3 ? true : false; } } RemoveAllComponents(); if (!fIsAddon) // Addons doesn't have to transfer anything but themselves. { if (fTransferAll) { TransferAllItemsToMovingCrate(TRANSFER_ALL); // Whatever is left unlisted. } } CChar* pOwner = GetOwner().CharFind(); if (!pOwner || !pOwner->m_pPlayer) { return; } if (!fIsAddon) { if (fMoveToBank) { TransferMovingCrateToBank(); } CMultiStorage* pMultiStorage = pOwner->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } if (tRet == TRIGRET_RET_TRUE) { pDeed->Delete(); return; } pDeed->SetHue(GetHue()); pDeed->m_itDeed.m_Type = GetID(); if (m_Attr & ATTR_MAGIC) { pDeed->SetAttr(ATTR_MAGIC); } if (fMoveToBank) { pOwner->GetBank(LAYER_BANKBOX)->ContentAdd(pDeed); } else { pOwner->ItemBounce(pDeed, fDisplayMsg); } SetKeyNum("REMOVED", 1); Delete(); } void CItemMulti::SetMovingCrate(const CUID& uidCrate) { ADDTOCALLSTACK("CItemMulti::SetMovingCrate"); CItemContainer *pCurrentCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); CItemContainer *pNewCrate = static_cast<CItemContainer*>(uidCrate.ItemFind()); if (!uidCrate.IsValidUID() || !pNewCrate) { _uidMovingCrate.InitUID(); return; } if (pCurrentCrate && !pCurrentCrate->IsContainerEmpty()) { pCurrentCrate->SetCrateOfMulti(CUID()); pNewCrate->ContentsTransfer(pCurrentCrate, false); pCurrentCrate->Delete(); } _uidMovingCrate = uidCrate; pNewCrate->m_uidLink = GetUID(); pNewCrate->r_ExecSingle("EVENTS +ei_moving_crate"); pNewCrate->SetCrateOfMulti(GetUID()); } CUID CItemMulti::GetMovingCrate(bool fCreate) { ADDTOCALLSTACK("CItemMulti::GetMovingCrate"); if (_uidMovingCrate.IsValidUID()) { return _uidMovingCrate; } if (!fCreate) { return CUID(); } CItemContainer *pCrate = static_cast<CItemContainer*>(CItem::CreateBase(ITEMID_CRATE1)); ASSERT(pCrate); const CUID& uidCrate = pCrate->GetUID(); CPointMap pt = GetTopPoint(); pt.m_z -= 20; pCrate->MoveTo(pt); // Move the crate to z -20 pCrate->Update(); SetMovingCrate(uidCrate); return uidCrate; } void CItemMulti::TransferAllItemsToMovingCrate(TRANSFER_TYPE iType) { ADDTOCALLSTACK("CItemMulti::TransferAllItemsToMovingCrate"); CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); ASSERT(pCrate); //Transfer Types const bool fTransferAddons = ((iType & TRANSFER_ADDONS) || (iType & TRANSFER_ALL)); const bool fTransferAll = (iType & TRANSFER_ALL); const bool fTransferLockDowns = ((iType & TRANSFER_LOCKDOWNS) || (iType & TRANSFER_ALL)); const bool fTransferSecuredContainers = ((iType &TRANSFER_SECURED) || (iType & TRANSFER_ALL)); if (fTransferLockDowns) // Try to move locked down items, also to reduce the CWorldSearch impact. { TransferLockdownsToMovingCrate(); } if (fTransferSecuredContainers) { TransferSecuredToMovingCrate(); } if (fTransferAddons) { RedeedAddons(); } CPointMap ptArea; if (IsType(IT_MULTI_ADDON)) { ptArea = GetTopPoint().GetRegion(REGION_TYPE_HOUSE)->m_pt; // Addons doesnt have Area, search in the above region. } else { ptArea = m_pRegion->m_pt; } CWorldSearch Area(ptArea, Multi_GetDistanceMax()); // largest area. Area.SetSearchSquare(true); for (;;) { CItem * pItem = Area.GetItem(); if (pItem == nullptr) { break; } if (pItem->GetTopPoint().GetRegion(REGION_TYPE_HOUSE) != GetTopPoint().GetRegion(REGION_TYPE_HOUSE)) { continue; } if (pItem->IsType(IT_STONE_GUILD)) { continue; } if (pItem->GetUID() == GetUID() || pItem->GetUID() == pCrate->GetUID()) // Multi itself or the Moving Crate, neither is not handled here. { continue; } if (GetComponentIndex(pItem->GetUID()) != -1) // Components should never be transfered. { continue; } if (!fTransferAll) { if (!fTransferLockDowns && pItem->IsAttr(ATTR_LOCKEDDOWN)) // Skip this item if its locked down and we don't want to TRANSFER_LOCKDOWNS. { continue; } else if (!fTransferSecuredContainers && pItem->IsAttr(ATTR_SECURE)) // Skip this item if it's secured (container) and we don't want to TRANSFER_SECURED. { continue; } else if (pItem->IsType(IT_MULTI_ADDON) || pItem->IsType(IT_MULTI)) // If the item is a house Addon, redeed it. { if (fTransferAddons) // Shall be transfered, but addons needs an special transfer code by redeeding. { static_cast<CItemMulti*>(pItem)->Redeed(false, false); Area.RestartSearch(); // we removed an item and this will mess the search loop, so restart to fix it. continue; } else { continue; } } else if (!Multi_IsPartOf(pItem)) // Items not linked to, or listed on, this multi. { continue; } } pItem->RemoveFromView(); pCrate->ContentAdd(pItem); } if (pCrate->IsContainerEmpty()) { pCrate->Delete(); } } void CItemMulti::TransferLockdownsToMovingCrate() { ADDTOCALLSTACK("CItemMulti::TransferLockdownsToMovingCrate"); if (_lLockDowns.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } for (size_t i = 0; i < _lLockDowns.size(); ++i) { CItem *pItem = _lLockDowns[i].ItemFind(); if (pItem) // Move all valid items. { pItem->r_ExecSingle("EVENTS -ei_house_lockdown"); pCrate->ContentAdd(pItem); pItem->ClrAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink.InitUID(); } } _lLockDowns.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::TransferSecuredToMovingCrate() { ADDTOCALLSTACK("CItemMulti::TransferSecuredToMovingCrate"); if (_lSecureContainers.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } for (size_t i = 0; i < _lSecureContainers.size(); ++i) { CItemContainer *pItem = static_cast<CItemContainer*>(_lSecureContainers[i].ItemFind()); if (pItem) // Move all valid items. { pItem->r_ExecSingle("EVENTS -ei_house_secure"); pCrate->ContentAdd(pItem); pItem->ClrAttr(ATTR_SECURE); pItem->m_uidLink.InitUID(); } } _lLockDowns.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::RedeedAddons() { ADDTOCALLSTACK("CItemMulti::RedeedAddons"); if (_lAddons.empty()) { return; } CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(true).ItemFind()); if (!pCrate) { return; } std::vector<CUID> vAddons = _lAddons; for (size_t i = 0; i < vAddons.size(); ++i) { CItemMulti *pAddon = static_cast<CItemMulti*>(vAddons[i].ItemFind()); if (pAddon) // Move all valid items. { pAddon->Redeed(false, false); } } vAddons.clear(); _lAddons.clear(); // Clear the list, asume invalid items should be cleared too. } void CItemMulti::TransferMovingCrateToBank() { ADDTOCALLSTACK("CItemMulti::TransferMovingCrateToBank"); CItemContainer *pCrate = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); CChar *pOwner = GetOwner().CharFind(); if (pCrate && pOwner) { if (!pCrate->IsContainerEmpty()) { if (pOwner) { pCrate->RemoveFromView(); CItemContainer *pBank = pOwner->GetBank(); ASSERT(pBank); pBank->ContentAdd(pCrate); } } else { pCrate->Delete(); } } } void CItemMulti::AddAddon(const CUID& uidAddon) { ADDTOCALLSTACK("CItemMulti::AddAddon"); if (!uidAddon.IsValidUID()) { return; } CItemMulti *pAddon = static_cast<CItemMulti*>(uidAddon.ItemFind()); if (!pAddon) { return; } if (!g_Serv.IsLoading()) { if (!pAddon->IsType(IT_MULTI_ADDON)) { return; } if (GetAddonIndex(uidAddon) >= 0) { return; } } _lAddons.emplace_back(uidAddon); } void CItemMulti::DeleteAddon(const CUID& uidAddon) { ADDTOCALLSTACK("CItemMulti::DeleteAddon"); for (size_t i = 0; i < _lAddons.size(); ++i) { if (_lAddons[i] == uidAddon) { _lAddons.erase(_lAddons.begin() + i); return; } } } int CItemMulti::GetAddonIndex(const CUID& uidAddon) const { if (_lAddons.empty()) { return -1; } for (size_t i = 0; i < _lAddons.size(); ++i) { if (_lAddons[i] == uidAddon) { return (int)i; } } return -1; } size_t CItemMulti::GetAddonCount() const { return _lAddons.size(); } void CItemMulti::AddComponent(const CUID& uidComponent) { ADDTOCALLSTACK("CItemMulti::AddComponent"); if (!uidComponent.IsValidUID()) { return; } if (!g_Serv.IsLoading()) { if (GetComponentIndex(uidComponent) >= 0) { return; } } CItem *pComp = uidComponent.ItemFind(); if (pComp) { pComp->SetComponentOfMulti(GetUID()); } _lComps.emplace_back(uidComponent); } void CItemMulti::DeleteComponent(const CUID& uidComponent, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteComponent"); if (fRemoveFromList) { _lComps.erase(std::find(_lComps.begin(), _lComps.end(), uidComponent)); } if (!uidComponent.IsValidUID()) // Doing this after the erase to force check the vector, just in case... { return; } CItem *pComp = uidComponent.ItemFind(); if (pComp) { pComp->SetComponentOfMulti(CUID()); } } int CItemMulti::GetComponentIndex(const CUID& uidComponent) const { if (_lComps.empty()) { return -1; } for (size_t i = 0; i < _lComps.size(); ++i) { if (_lComps[i] == uidComponent) { return (int)i; } } return -1; } size_t CItemMulti::GetComponentCount() const { return _lComps.size(); } void CItemMulti::RemoveAllComponents() { ADDTOCALLSTACK("CItemMulti::RemoveAllComponents"); if (_lComps.empty()) { return; } const std::vector<CUID> lCopy(_lComps); for (size_t i = 0; i < lCopy.size(); ++i) { CItem *pComp = lCopy[i].ItemFind(); if (pComp) { pComp->Delete(); } } _lComps.clear(); } void CItemMulti::GenerateBaseComponents(bool *pfNeedKey, dword dwKeyCode) { ADDTOCALLSTACK("CItemMulti::GenerateBaseComponents"); const CItemBaseMulti * pMultiDef = Multi_GetDef(); ASSERT(pMultiDef); for (size_t i = 0; i < pMultiDef->m_Components.size(); ++i) { const CItemBaseMulti::CMultiComponentItem &component = pMultiDef->m_Components[i]; *pfNeedKey |= Multi_CreateComponent(component.m_id, component.m_dx, component.m_dy, component.m_dz, dwKeyCode); } } void CItemMulti::SetBaseStorage(uint16 iLimit) { _uiBaseStorage = iLimit; } uint16 CItemMulti::GetBaseStorage() const { return _uiBaseStorage; } void CItemMulti::SetIncreasedStorage(uint16 uiIncrease) { _uiIncreasedStorage = uiIncrease; } uint16 CItemMulti::GetIncreasedStorage() const { return _uiIncreasedStorage; } uint16 CItemMulti::GetMaxStorage() const { return _uiBaseStorage + ((_uiBaseStorage * _uiIncreasedStorage) / 100); } uint16 CItemMulti::GetCurrentStorage() const { return (int16)(_lLockDowns.size() + _lSecureContainers.size()); } void CItemMulti::SetBaseVendors(uint8 iLimit) { _uiBaseVendors = iLimit; } uint8 CItemMulti::GetBaseVendors() const { return _uiBaseVendors; } uint8 CItemMulti::GetMaxVendors() const { return (uint8)(_uiBaseVendors + (_uiBaseVendors * GetIncreasedStorage()) / 100); } uint16 CItemMulti::GetMaxLockdowns() const { uint16 uiMaxStorage = GetMaxStorage(); return (uiMaxStorage - (uiMaxStorage - (uiMaxStorage * (uint16)GetLockdownsPercent()) / 100)); } uint8 CItemMulti::GetLockdownsPercent() const { return _uiLockdownsPercent; } void CItemMulti::SetLockdownsPercent(uint8 iPercent) { _uiLockdownsPercent = iPercent; } void CItemMulti::LockItem(const CUID& uidItem) { ADDTOCALLSTACK("CItemMulti::LockItem"); if (!uidItem.IsValidUID()) { return; } CItem *pItem = uidItem.ItemFind(); ASSERT(pItem); if (!g_Serv.IsLoading()) { if (GetLockedItemIndex(uidItem) >= 0) { return; } pItem->SetAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink = GetUID(); pItem->r_ExecSingle("EVENTS +ei_house_lockdown"); } pItem->SetLockDownOfMulti(uidItem); _lLockDowns.emplace_back(uidItem); } void CItemMulti::UnlockItem(const CUID& uidItem, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::UnlockItem"); if (fRemoveFromList) { _lLockDowns.erase(std::find(_lLockDowns.begin(), _lLockDowns.end(), uidItem)); } CItem *pItem = uidItem.ItemFind(); if (!pItem) { return; } pItem->ClrAttr(ATTR_LOCKEDDOWN); pItem->m_uidLink.InitUID(); pItem->r_ExecSingle("EVENTS -ei_house_lockdown"); pItem->SetLockDownOfMulti(CUID()); } void CItemMulti::UnlockAllItems() { ADDTOCALLSTACK("CItemMulti::UnlockAllItems"); for (const CUID& uidLockeddown : _lLockDowns) { CItem *pItem = uidLockeddown.ItemFind(true); if (!pItem) continue; UnlockItem(uidLockeddown, false); } _lLockDowns.clear(); } int CItemMulti::GetLockedItemIndex(const CUID& uidItem) const { if (_lLockDowns.empty()) { return -1; } for (size_t i = 0; i < _lLockDowns.size(); ++i) { if (_lLockDowns[i] == uidItem) { return (int)i; } } return -1; } size_t CItemMulti::GetLockdownCount() const { return _lLockDowns.size() + _lSecureContainers.size(); } void CItemMulti::Secure(const CUID& uidContainer) { ADDTOCALLSTACK("CItemMulti::Secure"); if (!uidContainer.IsValidUID()) { return; } CItemContainer *pContainer = static_cast<CItemContainer*>(uidContainer.ItemFind()); ASSERT(pContainer); if (!g_Serv.IsLoading()) { if (GetSecuredContainerIndex(uidContainer) >= 0) { return; } pContainer->SetAttr(ATTR_SECURE); pContainer->m_uidLink = GetUID(); pContainer->r_ExecSingle("EVENTS +ei_house_secure"); } pContainer->SetSecuredOfMulti(GetUID()); _lSecureContainers.emplace_back(uidContainer); } void CItemMulti::Release(const CUID& uidContainer, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::Release"); if (fRemoveFromList) { _lLockDowns.erase(std::remove(_lLockDowns.begin(), _lLockDowns.end(), uidContainer)); } CItemContainer *pContainer = static_cast<CItemContainer*>(uidContainer.ItemFind()); if (!pContainer) { return; } pContainer->ClrAttr(ATTR_SECURE); pContainer->m_uidLink.InitUID(); pContainer->r_ExecSingle("EVENTS -ei_house_secure"); pContainer->SetSecuredOfMulti(CUID()); } int CItemMulti::GetSecuredContainerIndex(const CUID& uidContainer) const { ADDTOCALLSTACK("CItemMulti::GetSecuredContainerIndex"); if (_lSecureContainers.empty()) { return -1; } for (size_t i = 0; i < _lSecureContainers.size(); ++i) { if (_lSecureContainers[i] == uidContainer) { return (int)i; } } return -1; } int16 CItemMulti::GetSecuredItemsCount() const { ADDTOCALLSTACK("CItemMulti::GetSecuredItemsCount"); size_t iCount = 0; for (size_t i = 0; i < _lSecureContainers.size(); ++i) { CItemContainer *pContainer = static_cast<CItemContainer*>(_lSecureContainers[i].ItemFind()); if (pContainer) { iCount += pContainer->GetContentCount(); } } return (int16)iCount; } size_t CItemMulti::GetSecuredContainersCount() const { return _lSecureContainers.size(); } void CItemMulti::AddVendor(const CUID& uidVendor) { ADDTOCALLSTACK("CItemMulti::AddVendor"); if (!uidVendor.IsValidUID()) { return; } if ((g_Serv.IsLoading() == false) && (GetVendorIndex(uidVendor) >= 0)) { return; } CChar *pVendor = uidVendor.CharFind(); if (!pVendor || !pVendor->m_pPlayer) { return; } RevokePrivs(uidVendor); CMultiStorage* pMultiStorage = pVendor->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); pMultiStorage->AddMulti(GetUID(), HP_VENDOR); _lVendors.emplace_back(uidVendor); } void CItemMulti::DeleteVendor(const CUID& uidVendor, bool fRemoveFromList) { ADDTOCALLSTACK("CItemMulti::DeleteVendor"); for (size_t i = 0; i < _lVendors.size(); ++i) { if (_lVendors[i] == uidVendor) { if (fRemoveFromList) { _lVendors.erase(_lVendors.begin() + i); } CChar *pVendor = uidVendor.CharFind(); if (pVendor && pVendor->m_pPlayer) { CMultiStorage* pMultiStorage = pVendor->m_pPlayer->GetMultiStorage(); if (pMultiStorage) { pMultiStorage->DelMulti(GetUID()); } } break; } } } int CItemMulti::GetVendorIndex(const CUID& uidVendor) const { ADDTOCALLSTACK("CItemMulti::GetVendorIndex"); if (_lVendors.empty()) { return -1; } for (size_t i = 0; i < _lVendors.size(); ++i) { if (_lVendors[i] == uidVendor) { return (int)i; } } return -1; } size_t CItemMulti::GetVendorCount() { return _lVendors.size(); } enum MULTIREF_REF { SHR_ACCESS, SHR_ADDON, SHR_BAN, SHR_COMP, SHR_COOWNER, SHR_FRIEND, SHR_GUILD, SHR_LOCKDOWN, SHR_MOVINGCRATE, SHR_OWNER, SHR_REGION, SHR_SECURED, SHR_VENDOR, SHR_QTY }; lpctstr const CItemMulti::sm_szRefKeys[SHR_QTY + 1] = { "ACCESS", "ADDON", "BAN", "COMP", "COOWNER", "FRIEND", "GUILD", "LOCKDOWN", "MOVINGCRATE", "OWNER", "REGION", "SECURED", "VENDOR", nullptr }; bool CItemMulti::r_GetRef(lpctstr & ptcKey, CScriptObj * & pRef) { ADDTOCALLSTACK("CItemMulti::r_GetRef"); int iCmd = FindTableHeadSorted(ptcKey, sm_szRefKeys, CountOf(sm_szRefKeys) - 1); if (iCmd >= 0) { ptcKey += strlen(sm_szRefKeys[iCmd]); } switch (iCmd) { case SHR_ACCESS: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lAccesses.size() > idx) { CChar *pAccess = _lAccesses[idx].CharFind(); if (pAccess) { pRef = pAccess; return true; } } return false; } case SHR_ADDON: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lAddons.size() > idx) { CItemMulti *pAddon = static_cast<CItemMulti*>(_lAddons[idx].ItemFind()); if (pAddon) { pRef = pAddon; return true; } } return false; } case SHR_BAN: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lBans.size() > idx) { CChar *pBan = _lBans[idx].CharFind(); if (pBan) { pRef = pBan; return true; } } return false; } case SHR_COMP: { const int idx = Exp_GetVal(ptcKey); SKIP_SEPARATORS(ptcKey); CItem *pComp = Multi_FindItemComponent(idx); if (pComp) { pRef = pComp; return true; } return false; } case SHR_COOWNER: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lCoowners.size() > idx) { CChar *pCoowner = _lCoowners[idx].CharFind(); if (pCoowner) { pRef = pCoowner; return true; } } return false; } case SHR_FRIEND: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lFriends.size() > idx) { CChar *pFriend = _lFriends[idx].CharFind(); if (pFriend) { pRef = pFriend; return true; } } return false; } case SHR_LOCKDOWN: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lLockDowns.size() > idx) { CItem *plockdown = _lLockDowns[idx].ItemFind(); if (plockdown) { pRef = plockdown; return true; } } return false; } case SHR_MOVINGCRATE: { SKIP_SEPARATORS(ptcKey); pRef = static_cast<CItemContainer*>(GetMovingCrate(false).ItemFind()); return true; } case SHR_OWNER: { SKIP_SEPARATORS(ptcKey); pRef = _uidOwner.CharFind(); return true; } case SHR_GUILD: { SKIP_SEPARATORS(ptcKey); pRef = static_cast<CItemStone*>(_uidGuild.ItemFind()); return true; } case SHR_REGION: { SKIP_SEPARATORS(ptcKey); if (m_pRegion != nullptr) { pRef = m_pRegion; // Addons do not have region so return it only when not nullptr. return true; } return false; } case SHR_SECURED: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lSecureContainers.size() > idx) { CItem *pItem = _lSecureContainers[idx].ItemFind(); if (pItem) { CItemContainer *pCont = static_cast<CItemContainer*>(pItem); pRef = pCont; return true; } } return false; } case SHR_VENDOR: { const size_t idx = Exp_GetSTVal(ptcKey); SKIP_SEPARATORS(ptcKey); if (_lVendors.size() > idx) { CChar *pVendor = _lVendors[idx].CharFind(); if (pVendor) { pRef = pVendor; return true; } } return false; } default: break; } return(CItem::r_GetRef(ptcKey, pRef)); } enum { SHV_DELACCESS, SHV_DELADDON, SHV_DELBAN, SHV_DELCOMPONENT, SHV_DELCOOWNER, SHV_DELFRIEND, SHV_DELVENDOR, SHV_GENERATEBASECOMPONENTS, SHV_MOVEALLTOCRATE, SHV_MOVELOCKSTOCRATE, SHV_MULTICREATE, SHV_REDEED, SHV_RELEASE, SHV_REMOVEALLCOMPS, SHV_REMOVEKEYS, SHV_UNLOCKITEM, SHV_QTY }; lpctstr const CItemMulti::sm_szVerbKeys[SHV_QTY + 1] = { "DELACCESS", "DELADDON", "DELBAN", "DELCOMPONENT", "DELCOOWNER", "DELFRIEND", "DELVENDOR", "GENERATEBASECOMPONENTS", "MOVEALLTOCRATE", "MOVELOCKSTOCRATE", "MULTICREATE", "REDEED", "RELEASE", "REMOVEALLCOMPS", "REMOVEKEYS", "UNLOCKITEM", nullptr }; bool CItemMulti::r_Verb(CScript & s, CTextConsole * pSrc) // Execute command from script { ADDTOCALLSTACK("CItemMulti::r_Verb"); EXC_TRY("Verb"); // Speaking in this multis region. // return: true = command for the multi. if (CCMultiMovable::r_Verb(s, pSrc)) { return true; } const int iCmd = FindTableSorted(s.GetKey(), sm_szVerbKeys, CountOf(sm_szVerbKeys) - 1); switch (iCmd) { case SHV_DELACCESS: { const CUID uidAccess(s.GetArgDWVal()); if (!uidAccess.IsValidUID()) { _lAccesses.clear(); } else { DeleteAccess(uidAccess, true); } break; } case SHV_DELADDON: { const CUID uidAddon(s.GetArgDWVal()); if (!uidAddon.IsValidUID()) { _lAddons.clear(); } else { DeleteAddon(uidAddon); } break; } case SHV_DELBAN: { const CUID uidBan(s.GetArgDWVal()); if (!uidBan.IsValidUID()) { _lBans.clear(); } else { DeleteBan(uidBan, true); } break; } case SHV_DELCOMPONENT: { const CUID uidComp(s.GetArgDWVal()); if (!uidComp.IsValidUID()) { _lComps.clear(); } else { DeleteComponent(uidComp, true); } break; } case SHV_DELCOOWNER: { const CUID uidCoowner(s.GetArgDWVal()); if (!uidCoowner.IsValidUID()) { _lCoowners.clear(); } else { DeleteCoowner(uidCoowner, true); } break; } case SHV_DELFRIEND: { const CUID uidFriend(s.GetArgDWVal()); if (!uidFriend.IsValidUID()) { _lFriends.clear(); } else { DeleteFriend(uidFriend, true); } break; } case SHV_DELVENDOR: { const CUID uidVendor(s.GetArgDWVal()); if (!uidVendor.IsValidUID()) { _lVendors.clear(); } else { DeleteVendor(uidVendor, true); } break; } case SHV_UNLOCKITEM: { const CUID uidItem(s.GetArgDWVal()); if (!uidItem.IsValidUID()) { UnlockAllItems(); } else { UnlockItem(uidItem, true); } break; } case SHV_MOVEALLTOCRATE: { TransferAllItemsToMovingCrate((TRANSFER_TYPE)s.GetArgDWVal()); break; } case SHV_MOVELOCKSTOCRATE: { TransferLockdownsToMovingCrate(); break; } case SHV_MULTICREATE: { CUID uidChar(s.GetArgDWVal()); CChar *pCharSrc = uidChar.CharFind(); Multi_Setup(pCharSrc, 0); break; } case SHV_REDEED: { int64 piCmd[2]; Str_ParseCmds(s.GetArgStr(), piCmd, CountOf(piCmd)); const bool fShowMsg = piCmd[0] ? true : false; const bool fMoveToBank = piCmd[1] ? true : false; CUID charUID; if (pSrc && pSrc->GetChar()) { charUID.SetPrivateUID(pSrc->GetChar()->GetUID()); } else if (GetOwner().CharFind()) { charUID.SetPrivateUID(GetOwner()); } else { g_Log.EventError("Trying to redeed %s (0x%" PRIx32 ") with no redeed target, removing it instead.\n", GetName(), (dword)GetUID()); Delete(); return true; } Redeed(fShowMsg, fMoveToBank, charUID); break; } case SHV_RELEASE: { const CUID uidRelease(s.GetArgDWVal()); if (!uidRelease.IsValidUID()) { _lAccesses.clear(); } else { Release(uidRelease, true); } break; } case SHV_REMOVEKEYS: { const CUID uidChar(s.GetArgDWVal()); RemoveKeys(uidChar); break; } case SHV_REMOVEALLCOMPS: { RemoveAllComponents(); break; } case SHV_GENERATEBASECOMPONENTS: { bool fNeedKey = false; GenerateBaseComponents(&fNeedKey, UID_CLEAR); break; } default: { return CItem::r_Verb(s, pSrc); } } EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPTSRC; EXC_DEBUG_END; return true; } enum SHL_TYPE { SHL_ACCESSES, SHL_ADDACCESS, SHL_ADDADDON, SHL_ADDBAN, SHL_ADDCOMP, SHL_ADDCOOWNER, SHL_ADDFRIEND, SHL_ADDKEY, SHL_ADDONS, SHL_ADDVENDOR, SHL_BANS, SHL_BASESTORAGE, SHL_BASEVENDORS, SHL_COMPS, SHL_COOWNERS, SHL_CURRENTSTORAGE, SHL_FRIENDS, SHL_GETACCESSPOS, SHL_GETADDONPOS, SHL_GETBANPOS, SHL_GETCOMPPOS, SHL_GETCOOWNERPOS, SHL_GETFRIENDPOS, SHL_GETHOUSEVENDORPOS, SHL_GETLOCKEDITEMPOS, SHL_GETSECUREDCONTAINERPOS, SHL_GETSECUREDCONTAINERS, SHL_GETSECUREDITEMS, SHL_GUILD, SHL_HOUSETYPE, SHL_INCREASEDSTORAGE, SHL_ISOWNER, SHL_LOCKDOWNS, SHL_LOCKDOWNSPERCENT, SHL_LOCKITEM, SHL_MAXLOCKDOWNS, SHL_MAXSTORAGE, SHL_MAXVENDORS, SHL_MOVINGCRATE, SHL_OWNER, SHL_PRIV, SHL_REGION, SHL_REMOVEKEYS, SHL_SECURE, SHL_VENDORS, SHL_QTY }; const lpctstr CItemMulti::sm_szLoadKeys[SHL_QTY + 1] = { "ACCESSES", "ADDACCESS", "ADDADDON", "ADDBAN", "ADDCOMP", "ADDCOOWNER", "ADDFRIEND", "ADDKEY", "ADDONS", "ADDVENDOR", "BANS", "BASESTORAGE", "BASEVENDORS", "COMPS", "COOWNERS", "CURRENTSTORAGE", "FRIENDS", "GETACCESSPOS", "GETADDONPOS", "GETBANPOS", "GETCOMPPOS", "GETCOOWNERPOS", "GETFRIENDPOS", "GETHOUSEVENDORPOS", "GETLOCKEDITEMPOS", "GETSECUREDCONTAINERPOS", "GETSECUREDCONTAINERS", "GETSECUREDITEMS", "GUILD", "HOUSETYPE", "INCREASEDSTORAGE", "ISOWNER", "LOCKDOWNS", "LOCKDOWNSPERCENT", "LOCKITEM", "MAXLOCKDOWNS", "MAXSTORAGE", "MAXVENDORS", "MOVINGCRATE", "OWNER", "PRIV", "REGION", "REMOVEKEYS", "SECURE", "VENDORS", nullptr }; void CItemMulti::r_Write(CScript & s) { ADDTOCALLSTACK_INTENSIVE("CItemMulti::r_Write"); CItem::r_Write(s); if (m_pRegion) { m_pRegion->r_WriteBody(s, "REGION."); } if (_uidGuild.IsValidUID()) { s.WriteKeyHex("GUILD", (dword)_uidGuild); } if (_uidOwner.IsValidUID()) { s.WriteKeyHex("OWNER", (dword)_uidOwner); } // House general if (_iHouseType) { s.WriteKeyHex("HOUSETYPE", (dword)_iHouseType); } if (!_lCoowners.empty()) { for (const CUID& uid : _lCoowners) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDCOOWNER", (dword)uid); } } } if (!_lFriends.empty()) { for (const CUID& uid : _lFriends) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDFRIEND", (dword)uid); } } } if (!_lComps.empty()) { for (const CUID& uid : _lComps) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDCOMP", (dword)uid); } } } if (!_lAddons.empty()) { for (const CUID& uid : _lAddons) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDADDON", (dword)uid); } } } if (!_lSecureContainers.empty()) { for (const CUID& uid : _lSecureContainers) { if (uid.IsValidUID()) { s.WriteKeyHex("SECURE", (dword)uid); } } } if (!_lLockDowns.empty()) { for (const CUID& uid : _lLockDowns) { if (uid.IsValidUID()) { s.WriteKeyHex("LOCKITEM", (dword)uid); } } } if (auto val = GetLockdownsPercent()) { s.WriteKeyVal("LOCKDOWNSPERCENT", val); } const CUID uidCrate = GetMovingCrate(false); if (uidCrate.IsValidUID()) { s.WriteKeyHex("MOVINGCRATE", uidCrate.GetObjUID()); } // House vendors if (!_lVendors.empty()) { for (const CUID& uid : _lVendors) { if (uid.IsValidUID()) { s.WriteKeyHex("ADDVENDOR", (dword)uid); } } } if (auto val = GetBaseVendors()) { s.WriteKeyVal("BASEVENDORS", val); } // House Storage if (auto val = GetBaseStorage()) { s.WriteKeyVal("BASESTORAGE", val); } if (auto val = GetIncreasedStorage()) { s.WriteKeyVal("INCREASEDSTORAGE", val); } } bool CItemMulti::r_WriteVal(lpctstr ptcKey, CSString & sVal, CTextConsole * pSrc, bool fNoCallParent, bool fNoCallChildren) { UNREFERENCED_PARAMETER(fNoCallChildren); ADDTOCALLSTACK("CItemMulti::r_WriteVal"); if (CCMultiMovable::r_WriteVal(ptcKey, sVal, pSrc)) { return true; } int iCmd = FindTableHeadSorted(ptcKey, sm_szLoadKeys, CountOf(sm_szLoadKeys) - 1); if (iCmd >= 0) { ptcKey += strlen(sm_szLoadKeys[iCmd]); } SKIP_SEPARATORS(ptcKey); switch (iCmd) { // House Permissions case SHL_PRIV: { ASSERT(pSrc); if (CChar* pSrcChar = pSrc->GetChar()) { if (pSrcChar->m_pPlayer) { CMultiStorage* pMultiStorage = pSrcChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); sVal.FormatU8Val((uint8)pMultiStorage->GetPriv(GetUID())); break; } } sVal.FormatVal(0); break; } case SHL_OWNER: { CChar *pOwner = GetOwner().CharFind(); if (!IsStrEmpty(ptcKey)) { if (pOwner) { return pOwner->r_WriteVal(ptcKey, sVal, pSrc); } } if (pOwner) { sVal.FormatDWVal(pOwner->GetUID()); } else { sVal.FormatDWVal(0); } break; } case SHL_GUILD: { CItemStone *pGuild = static_cast<CItemStone*>(GetGuildStone().ItemFind()); if (!IsStrEmpty(ptcKey)) { if (pGuild) { return pGuild->r_WriteVal(ptcKey, sVal, pSrc); } } if (pGuild) { sVal.FormatDWVal(pGuild->GetUID()); } else { sVal.FormatDWVal(0); } break; } case SHL_ISOWNER: { CUID uidOwner(Exp_GetVal(ptcKey)); sVal.FormatBVal(IsOwner(uidOwner)); break; } case SHL_GETCOOWNERPOS: { CUID uidCoowner(Exp_GetVal(ptcKey)); sVal.FormatVal(GetCoownerIndex(uidCoowner)); break; } case SHL_COOWNERS: { sVal.FormatSTVal(GetCoownerCount()); break; } case SHL_GETFRIENDPOS: { CUID uidFriend(Exp_GetVal(ptcKey)); sVal.FormatVal(GetFriendIndex(uidFriend)); break; } case SHL_FRIENDS: { sVal.FormatSTVal(GetFriendCount()); break; } case SHL_ACCESSES: { sVal.FormatSTVal(GetAccessCount()); break; } case SHL_GETACCESSPOS: { CUID uidAccess(Exp_GetVal(ptcKey)); sVal.FormatVal(GetAccessIndex(uidAccess)); break; } case SHL_ADDONS: { sVal.FormatSTVal(GetAddonCount()); break; } case SHL_GETADDONPOS: { CUID uidAddon(Exp_GetVal(ptcKey)); sVal.FormatVal(GetAddonIndex(uidAddon)); break; } case SHL_BANS: { sVal.FormatSTVal(GetBanCount()); break; } case SHL_GETBANPOS: { CUID uidBan(Exp_GetVal(ptcKey)); sVal.FormatVal(GetBanIndex(uidBan)); break; } // House General case SHL_HOUSETYPE: { sVal.FormatU8Val((uint8)_iHouseType); break; } case SHL_GETCOMPPOS: { CUID uidComp(Exp_GetVal(ptcKey)); sVal.FormatVal(GetComponentIndex(uidComp)); break; } case SHL_MOVINGCRATE: { bool fCreate = false; if (strlen(ptcKey) <= 2) // check for <MovingCrate 0/1> (whitespace + number = 2 len) { fCreate = Exp_GetVal(ptcKey); } else if (!IsStrEmpty(ptcKey) && _uidMovingCrate.IsValidUID()) // If there's an already existing Moving Crate and args len is greater than 1, it should have a keyword to send to the crate. { CItemContainer *pCrate = static_cast<CItemContainer*>(_uidMovingCrate.ItemFind()); ASSERT(pCrate); // Removed crates should init _uidMovingCrate's uid? return pCrate->r_WriteVal(ptcKey, sVal, pSrc); } if (fCreate) { GetMovingCrate(true); } if (_uidMovingCrate.IsValidUID()) { sVal.FormatDWVal(_uidMovingCrate); } else { sVal.FormatDWVal(0); } break; } case SHL_ADDKEY: { ptcKey += 6; CUID uidOwner(Exp_GetVal(ptcKey)); bool fDupeOnBank = Exp_GetVal(ptcKey) ? 1 : 0; CChar *pCharOwner = uidOwner.CharFind(); CItem *pKey = nullptr; if (pCharOwner) { pKey = GenerateKey(uidOwner, fDupeOnBank); if (pKey) { sVal.FormatDWVal(pKey->GetUID()); break; } } sVal.FormatDWVal(0); break; } // House Storage case SHL_COMPS: { sVal.FormatSTVal(GetComponentCount()); break; } case SHL_LOCKDOWNS: { sVal.FormatSTVal(GetLockdownCount()); break; } case SHL_GETSECUREDCONTAINERPOS: { CUID uidCont(Exp_GetDWVal(ptcKey)); if (uidCont.IsValidUID()) { sVal.FormatVal(GetSecuredContainerIndex(uidCont)); break; } return false; } case SHL_GETSECUREDCONTAINERS: { sVal.FormatSTVal(GetSecuredContainersCount()); break; } case SHL_GETSECUREDITEMS: { sVal.Format16Val(GetSecuredItemsCount()); break; } case SHL_VENDORS: { sVal.FormatSTVal(GetVendorCount()); break; } case SHL_BASESTORAGE: { sVal.FormatU16Val(GetBaseStorage()); break; } case SHL_BASEVENDORS: { sVal.FormatU8Val(GetBaseVendors()); break; } case SHL_CURRENTSTORAGE: { sVal.FormatU16Val(GetCurrentStorage()); break; } case SHL_INCREASEDSTORAGE: { sVal.FormatU16Val(GetIncreasedStorage()); break; } case SHL_GETHOUSEVENDORPOS: { sVal.FormatVal(GetVendorIndex(CUID(Exp_GetVal(ptcKey)))); break; } case SHL_GETLOCKEDITEMPOS: { sVal.FormatVal(GetLockedItemIndex(CUID(Exp_GetVal(ptcKey)))); break; } case SHL_LOCKDOWNSPERCENT: { sVal.FormatU8Val(GetLockdownsPercent()); break; } case SHL_MAXLOCKDOWNS: { sVal.FormatU16Val(GetMaxLockdowns()); break; } case SHL_MAXSTORAGE: { sVal.FormatU16Val(GetMaxStorage()); break; } case SHL_MAXVENDORS: { sVal.FormatU16Val(GetMaxVendors()); break; } default: return (fNoCallParent ? false : CItem::r_WriteVal(ptcKey, sVal, pSrc)); } return true; } bool CItemMulti::r_LoadVal(CScript & s) { ADDTOCALLSTACK("CItemMulti::r_LoadVal"); EXC_TRY("LoadVal"); if (CCMultiMovable::r_LoadVal(s)) { return true; } int iCmd = FindTableHeadSorted(s.GetKey(), sm_szLoadKeys, CountOf(sm_szLoadKeys) - 1); switch (iCmd) { case SHL_REGION: { if (!IsTopLevel()) { MoveTo(GetTopPoint()); // Put item on the ground here. Update(); } ASSERT(m_pRegion); CScript script(s.GetKey() + 7, s.GetArgStr()); script.CopyParseState(s); return m_pRegion->r_LoadVal(script); } // misc case SHL_HOUSETYPE: { _iHouseType = (HOUSE_TYPE)s.GetArgU8Val(); break; } case SHL_MOVINGCRATE: { CUID uidCrate(s.GetArgDWVal()); if (uidCrate.IsValidUID()) { if (uidCrate.GetPrivateUID() == 1) // fix for 'movingcrate 1' { GetMovingCrate(true); } else { SetMovingCrate(uidCrate); } } else { SetMovingCrate(CUID()); } break; } case SHL_ADDKEY: { int64 piCmd[2]; int iLen = Str_ParseCmds(s.GetArgStr(), piCmd, CountOf(piCmd)); CUID uidOwner((dword)piCmd[0]); bool fDupeOnBank = false; if (iLen > 1) { fDupeOnBank = piCmd[1]; } CChar *pCharOwner = uidOwner.CharFind(); if (pCharOwner) { GenerateKey(uidOwner, fDupeOnBank); } break; } // House Permissions. case SHL_OWNER: { lpctstr ptcKey = s.GetKey(); ptcKey += 5; if (*ptcKey == '.') { CChar *pOwner = GetOwner().CharFind(); if (pOwner) { return pOwner->r_LoadVal(s); } return false; } CUID uid(s.GetArgDWVal()); if (!uid.IsValidUID()) { SetOwner(CUID()); } else { SetOwner(uid); } break; } case SHL_GUILD: { lpctstr ptcKey = s.GetKey(); ptcKey += 5; if (*ptcKey == '.') { CItemStone *pGuild = static_cast<CItemStone*>(GetGuildStone().ItemFind()); if (pGuild) { return pGuild->r_LoadVal(s); } return false; } CUID uid(s.GetArgDWVal()); if (!uid.IsValidUID()) { SetGuild(CUID()); break; } const CItem *pItem = uid.ItemFind(); if (pItem) { if (pItem->IsType(IT_STONE_GUILD)) { SetGuild(uid); return true; } else { return false; } } break; } case SHL_ADDCOOWNER: { AddCoowner(CUID(s.GetArgDWVal())); break; } case SHL_ADDFRIEND: { AddFriend(CUID(s.GetArgDWVal())); break; } case SHL_ADDBAN: { AddBan(CUID(s.GetArgDWVal())); break; } case SHL_ADDACCESS: { AddAccess(CUID(s.GetArgDWVal())); break; } case SHL_ADDADDON: { AddAddon(CUID(s.GetArgDWVal())); break; } // House Storage case SHL_ADDCOMP: { AddComponent(CUID(s.GetArgDWVal())); break; } case SHL_ADDVENDOR: { AddVendor(CUID(s.GetArgDWVal())); break; } case SHL_BASESTORAGE: { SetBaseStorage(s.GetArgU16Val()); break; } case SHL_BASEVENDORS: { SetBaseVendors(s.GetArgU8Val()); break; } case SHL_INCREASEDSTORAGE: { SetIncreasedStorage(s.GetArgU16Val()); break; } case SHL_LOCKDOWNSPERCENT: { SetLockdownsPercent(s.GetArgU8Val()); break; } case SHL_LOCKITEM: { CUID uidLock(s.GetArgDWVal()); if (uidLock.IsValidUID()) { LockItem(uidLock); } break; } case SHL_SECURE: { CUID uidSecured(s.GetArgDWVal()); CItem *pItem = uidSecured.ItemFind(); if (pItem && (pItem->IsType(IT_CONTAINER) || pItem->IsType(IT_CONTAINER_LOCKED))) { CItemContainer *pSecured = dynamic_cast<CItemContainer*>(pItem); //ensure it's a container. if (pSecured) { Secure(uidSecured); break; } } return false; } default: return CItem::r_LoadVal(s); } EXC_CATCH; EXC_DEBUG_START; EXC_ADD_SCRIPT; EXC_DEBUG_END; return true; } void CItemMulti::DupeCopy(const CItem * pItem) { ADDTOCALLSTACK("CItemMulti::DupeCopy"); CItem::DupeCopy(pItem); } CItem *CItemMulti::Multi_Create(CChar *pChar, const CItemBase * pItemDef, CPointMap & pt, CItem *pDeed) { if (!pChar || !pChar->m_pPlayer) { return nullptr; } ASSERT(pItemDef); const bool fShip = pItemDef->IsType(IT_SHIP); // must be in water. // pMultiDef can be nullptr, because we can also add simple items with a deed, not only multis. const CItemBaseMulti* pMultiDef = dynamic_cast <const CItemBaseMulti*> (pItemDef); /* * First thing to do is to check if the character creating the multi is allowed to have it */ if (fShip) { ASSERT(pMultiDef); CMultiStorage* pMultiStorage = pChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); if (!pMultiStorage->CanAddShip(pChar->GetUID(), pMultiDef->_iMultiCount)) { return nullptr; } } else if (pItemDef->IsType(IT_MULTI) || pItemDef->IsType(IT_MULTI_CUSTOM)) { ASSERT(pMultiDef); CMultiStorage* pMultiStorage = pChar->m_pPlayer->GetMultiStorage(); ASSERT(pMultiStorage); if (!pMultiStorage->CanAddHouse(pChar->GetUID(), pMultiDef->_iMultiCount)) { return nullptr; } } CScriptTriggerArgs args; args.m_VarsLocal.SetStrNew("check_blockradius", "-1, -1, 1, 1"); // Values are West, Norht, East, South args.m_VarsLocal.SetStrNew("check_multiradius", "0, -5, 0, 5"); args.m_VarsLocal.SetStrNew("id", g_Cfg.ResourceGetName(CResourceID(RES_ITEMDEF, pItemDef->GetID()))); args.m_VarsLocal.SetStrNew("p", pt.WriteUsed()); TRIGRET_TYPE tRet; pChar->r_Call("f_multi_onplacement_check", pChar, &args, nullptr, &tRet); if (tRet == TRIGRET_RET_TRUE) { return nullptr; } /* * There is a small difference in the coordinates where the mouse is in the screen and the ones received, * let's remove that difference. * Note: this fix is added here, before GM check, because otherwise they will place houses on wrong position. */ if (pMultiDef && (CItemBase::IsID_Multi(pItemDef->GetID()) || pItemDef->IsType(IT_MULTI_ADDON))) // or is this happening only for houses? if (CItemBase::IsID_House(pItemDef->GetID())) { pt.m_y -= (short)(pMultiDef->m_rect.m_bottom - 1); } if (!pChar->IsPriv(PRIV_GM) && tRet != TRIGRET_RET_HALFBAKED) { CRect rectBlockRadius; rectBlockRadius.Read(args.m_VarsLocal.GetKeyStr("check_blockradius")); CRect rectMultiRadius; rectMultiRadius.Read(args.m_VarsLocal.GetKeyStr("check_multiradius")); if (!pDeed->IsAttr(ATTR_MAGIC)) { CRect rect; CRect baseRect; if (pMultiDef) { baseRect = pMultiDef->m_rect; // Create a rect equal to the multi's one. } else { baseRect.OffsetRect(1, 1); // Guildstones pass through here, also other non multi items placed from deeds. } baseRect.m_map = pt.m_map; // set it's map to the current map. baseRect.OffsetRect(pt.m_x, pt.m_y);// fill the rect. rect = baseRect; CPointMap ptn = pt; // A copy to work on. // Check for chars in the way, just search for any char in the house area, no extra tiles, it's enough for them to do not be inside the house. CWorldSearch Area(pt, std::max(rect.GetWidth(), rect.GetHeight())); Area.SetSearchSquare(true); for (;;) { CChar * pCharSearch = Area.GetChar(); if (pCharSearch == nullptr) { break; } if (!rect.IsInside2d(pCharSearch->GetTopPoint())) // if the char is not inside the rec, ignore him. { continue; } if (pCharSearch->IsPriv(PRIV_GM) && !pChar->CanSee(pCharSearch)) // There is a GM in my way? get through him! { continue; } pChar->SysMessagef(g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_MULTI_INTWAY), pCharSearch->GetName()); // Did not met any of the above exceptions so i'm blocking the placement, return. return nullptr; } /* Char's check passed. * Intensive checks are done now: * - The area of search gets increased by 1* tile: There must be no blocking items from a 1x1* gap outside the house. * - All coord points inside that rect must be valid and have, as much, a Z difference of +-4. * * *1 tile by default, values can be overriden with local.check_BlockRadius in the f_house_onplacement_check function. */ rect += rectBlockRadius; int x = rect.m_left; /* * Loop through all the positions of the rect. */ for (; x < rect.m_right; ++x) // X loop { // Setting the Top-Left point of the CRect* ptn.m_x = (short)x; // *point Left int y = rect.m_top; // Reset North for each loop. for (; y < rect.m_bottom; ++y) // Y loop { ptn.m_y = (short)y; // *point North if (!ptn.IsValidPoint()) // Invalid point (out of map bounds). { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_FAIL); return nullptr; } dword dwBlockFlags = (fShip) ? CAN_C_SWIM : CAN_C_WALK; // Flags to check: Ships should check for swimable tiles. /* * Intensive check returning the top Z point of the given X, Y coords * It uses the dwBlockBlacks passed to check the new Z level. * Also update those dwBlockFlags with all the flags found at the given location. * 3rd param is set to also update Z with any house component found in the proccess. */ ptn.m_z = CWorldMap::GetHeightPoint2(ptn, dwBlockFlags, true); if (abs(ptn.m_z - pt.m_z) > 4) // Difference of Z > 4? so much, stop. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_BUMP); return nullptr; } if (fShip) { if (!(dwBlockFlags & CAN_I_WATER)) // Ships must be placed on water. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_SHIPW); return nullptr; } } else if (dwBlockFlags & (CAN_I_WATER | CAN_I_BLOCK | CAN_I_CLIMB)) // Did the intensive check find some undesired flags? Stop. { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_BLOCKED); return nullptr; } } } /* * The above loop did not find any blocking item/char, now another loop is done to check for another multis with extended limitations: * You can't place your house within a range of 5* tiles bottom of the stairs of any house. * Additionally your house can't have it's bottom blocked by another multi in a 5* tiles margin. * Simplifying it: the Rect must have an additional +5* tiles of radius on both TOP and BOTTOM points. * * *5 North & South tiles by default, values can be overriden with local.check_MultiRadius in the f_house_onplacement_check function. */ rect = baseRect; rect += rectMultiRadius; x = rect.m_left; for (; x < rect.m_right; ++x) { ptn.m_x = (short)x; int y = rect.m_top; for (; y < rect.m_bottom; ++y) { ptn.m_y = (short)y; /* * Search for any multi region on that point. */ CRegion * pRegion = ptn.GetRegion(REGION_TYPE_MULTI | REGION_TYPE_AREA | REGION_TYPE_ROOM); /* * If there is no region on that point (invalid point?) or the region has the NOBUILDING flag, stop * Ships are allowed to bypass this check?? */ if ((pRegion == nullptr) || (pRegion->IsFlag(REGION_FLAG_NOBUILDING) && !fShip)) { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_FAIL); return nullptr; } } } } } CItem * pItemNew = CItem::CreateTemplate(pItemDef->GetID(), nullptr, pChar); if (pItemNew == nullptr) { pChar->SysMessageDefault(DEFMSG_ITEMUSE_MULTI_COLLAPSE); return nullptr; } pItemNew->SetAttr(ATTR_MOVE_NEVER | (pDeed->m_Attr & (ATTR_MAGIC | ATTR_INVIS))); pItemNew->SetHue(pDeed->GetHue()); pItemNew->MoveToUpdate(pt); CItemMulti * pMultiItem = dynamic_cast <CItemMulti*>(pItemNew); if (pMultiItem) { pMultiItem->Multi_Setup(pChar, UID_CLEAR); } if (pItemDef->IsType(IT_STONE_GUILD)) { // Now name the guild CItemStone * pStone = dynamic_cast <CItemStone*>(pItemNew); ASSERT(pStone); pStone->AddRecruit(pChar, STONEPRIV_MASTER); if (CClient* pClient = pChar->GetClientActive()) { pClient->addPromptConsole(CLIMODE_PROMPT_STONE_NAME, g_Cfg.GetDefaultMsg(DEFMSG_ITEMUSE_GUILDSTONE_NEW), pItemNew->GetUID()); } } else if (pItemDef->IsType(IT_SHIP)) { pItemNew->Sound(Calc_GetRandVal(2) ? 0x12 : 0x13); } return pItemNew; } void CItemMulti::OnComponentCreate(CItem * pComponent, bool fIsAddon) { UNREFERENCED_PARAMETER(fIsAddon); CScript eComponent("+t_house_component"); pComponent->m_OEvents.r_LoadVal(eComponent, RES_EVENTS); switch (pComponent->GetType()) { case IT_DOOR: { pComponent->r_ExecSingle("EVENTS +ei_house_door"); pComponent->SetType(IT_DOOR_LOCKED); break; } case IT_CONTAINER: { pComponent->r_ExecSingle("EVENTS +ei_house_container"); pComponent->SetType(IT_CONTAINER_LOCKED); break; } case IT_SHIP_SIDE: { pComponent->SetType(IT_SHIP_SIDE_LOCKED); break; } case IT_SHIP_HOLD: { pComponent->SetType(IT_SHIP_HOLD_LOCK); break; } case IT_TELEPAD: { pComponent->r_ExecSingle("EVENTS +ei_house_telepad"); break; } default: break; } if (pComponent->GetHue() == HUE_DEFAULT) { pComponent->SetHue(GetHue()); } } CMultiStorage::CMultiStorage(const CUID& uidSrc) { _uidSrc = uidSrc; _iShipsTotal = 0; _iHousesTotal = 0; } CMultiStorage::~CMultiStorage() { for (auto& pair : _lHouses) { const CUID& uid = pair.first; CItemMulti *pMulti = static_cast<CItemMulti*>(uid.ItemFind()); if (!pMulti) continue; if (_uidSrc.IsChar()) { pMulti->RevokePrivs(_uidSrc); } else if (_uidSrc.IsItem()) //Only guild/town stones { pMulti->SetGuild(CUID()); } } for (auto& pair : _lShips) { const CUID& uid = pair.first; CItemShip *pShip = static_cast<CItemShip*>(uid.ItemFind()); if (!pShip) continue; if (_uidSrc.IsChar()) { pShip->RevokePrivs(_uidSrc); } else if (_uidSrc.IsItem()) //Only guild/town stones { pShip->SetGuild(CUID()); } } _uidSrc.InitUID(); } void CMultiStorage::AddMulti(const CUID& uidMulti, HOUSE_PRIV ePriv) { if (!uidMulti.IsValidUID()) { return; } const CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); if (!pMulti) { return; } CObjBase *pSrc = _uidSrc.ObjFind(); const bool isChar = pSrc && pSrc->IsChar(); if (pMulti->IsType(IT_SHIP)) { if (_lShips.empty() && isChar) { pSrc->r_ExecSingle("EVENTS +e_ship_priv"); } AddShip(uidMulti, ePriv); } else { if (_lHouses.empty() && isChar) { pSrc->r_ExecSingle("EVENTS +e_house_priv"); } AddHouse(uidMulti, ePriv); } } void CMultiStorage::DelMulti(const CUID& uidMulti) { CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); CObjBase *pSrc = _uidSrc.ObjFind(); if (pMulti->IsType(IT_SHIP)) { DelShip(uidMulti); if (_lShips.empty() && pSrc) { pSrc->r_ExecSingle("EVENTS -e_ship_priv"); } } else { DelHouse(uidMulti); if (_lHouses.empty() && pSrc) { pSrc->r_ExecSingle("EVENTS -e_house_priv"); } } pMulti->RevokePrivs(_uidSrc); } void CMultiStorage::AddHouse(const CUID& uidHouse, HOUSE_PRIV ePriv) { ADDTOCALLSTACK("CMultiStorage::AddHouse"); if (!uidHouse.IsValidUID()) { return; } if (GetHousePos(uidHouse) >= 0) { return; } const CItemMulti *pMulti = static_cast<CItemMulti*>(uidHouse.ItemFind()); _iHousesTotal += pMulti->GetMultiCount(); _lHouses[uidHouse] = ePriv; } void CMultiStorage::DelHouse(const CUID& uidHouse) { ADDTOCALLSTACK("CMultiStorage::DelHouse"); if (_lHouses.empty()) { return; } if (_lHouses.find(uidHouse) != _lHouses.end()) { const CItemMulti *pMulti = static_cast<CItemMulti*>(uidHouse.ItemFind()); _iHousesTotal -= pMulti->GetMultiCount(); _lHouses.erase(uidHouse); return; } } HOUSE_PRIV CMultiStorage::GetPriv(const CUID& uidMulti) { ADDTOCALLSTACK("CMultiStorage::GetPrivMulti"); const CItemMulti *pMulti = static_cast<CItemMulti*>(uidMulti.ItemFind()); if (pMulti->IsType(IT_MULTI)) { return _lHouses[uidMulti]; } else if (pMulti->IsType(IT_SHIP)) { return _lShips[uidMulti]; } return HP_NONE; } bool CMultiStorage::CanAddHouse(const CUID& uidChar, int16 iHouseCount) const { ADDTOCALLSTACK("CMultiStorage::CanAddHouse"); if (uidChar.IsItem()) { return true; // Guilds can have unlimited houses atm. } const CChar *pChar = uidChar.CharFind(); if (!pChar || !pChar->m_pPlayer) { return false; } if (iHouseCount == 0 || pChar->IsPriv(PRIV_GM)) { return true; } uint8 iMaxHouses = pChar->m_pPlayer->_iMaxHouses; if (iMaxHouses == 0) { if (pChar->GetClientActive()) { iMaxHouses = pChar->GetClientActive()->GetAccount()->_iMaxHouses; } } if (iMaxHouses == 0) { return true; } if (GetHouseCountTotal() + iHouseCount <= iMaxHouses) { return true; } pChar->SysMessageDefault(DEFMSG_HOUSE_ADD_LIMIT); return false; } int16 CMultiStorage::GetHousePos(const CUID& uidHouse) const { ADDTOCALLSTACK("CMultiStorage::GetHousePos"); if (_lHouses.empty()) { return -1; } int16 i = 0; for (MultiOwnedCont::const_iterator it = _lHouses.begin(); it != _lHouses.end(); ++it) { if (it->first == uidHouse) { return i; } ++i; } return -1; } int16 CMultiStorage::GetHouseCountTotal() const { return _iHousesTotal; } int16 CMultiStorage::GetHouseCountReal() const { return (int16)_lHouses.size(); } CUID CMultiStorage::GetHouseAt(int16 iPos) const { MultiOwnedCont::const_iterator it = _lHouses.begin(); std::advance(it, iPos); return it->first; } void CMultiStorage::ClearHouses() { _lHouses.clear(); } void CMultiStorage::r_Write(CScript & s) const { ADDTOCALLSTACK("CMultiStorage::r_Write"); UNREFERENCED_PARAMETER(s); } void CMultiStorage::AddShip(const CUID& uidShip, HOUSE_PRIV ePriv) { ADDTOCALLSTACK("CMultiStorage::AddShip"); if (!uidShip.IsValidUID()) { return; } if (GetShipPos(uidShip) >= 0) { return; } const CItemShip *pShip = static_cast<CItemShip*>(uidShip.ItemFind()); if (!pShip) { return; } _iShipsTotal += pShip->GetMultiCount(); _lShips[uidShip] = ePriv; } void CMultiStorage::DelShip(const CUID& uidShip) { ADDTOCALLSTACK("CMultiStorage::DelShip"); if (_lShips.empty()) { return; } if (_lShips.find(uidShip) != _lShips.end()) { const CItemShip *pShip = static_cast<CItemShip*>(uidShip.ItemFind()); if (pShip) { _iShipsTotal -= pShip->GetMultiCount(); } _lShips.erase(uidShip); return; } } bool CMultiStorage::CanAddShip(const CUID& uidChar, int16 iShipCount) { ADDTOCALLSTACK("CMultiStorage::CanAddShip"); if (uidChar.IsItem()) { return true; // Guilds can have unlimited ships atm. } const CChar *pChar = uidChar.CharFind(); if (!pChar || !pChar->m_pPlayer) { return false; } if (iShipCount == 0 || pChar->IsPriv(PRIV_GM)) { return true; } uint8 iMaxShips = pChar->m_pPlayer->_iMaxShips; if (iMaxShips == 0) { if (pChar->GetClientActive()) { iMaxShips = pChar->GetClientActive()->GetAccount()->_iMaxShips; } } if (iMaxShips == 0) { return true; } if (GetShipCountTotal() + iShipCount <= iMaxShips) { return true; } pChar->SysMessageDefault(DEFMSG_HOUSE_ADD_LIMIT); return false; } int16 CMultiStorage::GetShipPos(const CUID& uidShip) { if (_lShips.empty()) { return -1; } int16 i = 0; for (MultiOwnedCont::iterator it = _lShips.begin(); it != _lShips.end(); ++it) { if (it->first == uidShip) { return i; } ++i; } return -1; } int16 CMultiStorage::GetShipCountTotal() { return _iShipsTotal; } int16 CMultiStorage::GetShipCountReal() { return (int16)_lShips.size(); } CUID CMultiStorage::GetShipAt(int16 iPos) { MultiOwnedCont::const_iterator it = _lShips.begin(); std::advance(it, iPos); return it->first; } void CMultiStorage::ClearShips() { _lShips.clear(); }
25.743925
202
0.544191
criminalx
6d534ee13b4cda0a1d26b42ca5c7be9790648b4a
1,002
cpp
C++
RLSimion/CNTKWrapper/Chain.cpp
xcillero001/SimionZoo
b343b08f3356e1aa230d4132b0abb58aac4c5e98
[ "MIT" ]
1
2019-02-21T10:40:28.000Z
2019-02-21T10:40:28.000Z
RLSimion/CNTKWrapper/Chain.cpp
JosuGom3z/SimionZoo
b343b08f3356e1aa230d4132b0abb58aac4c5e98
[ "MIT" ]
null
null
null
RLSimion/CNTKWrapper/Chain.cpp
JosuGom3z/SimionZoo
b343b08f3356e1aa230d4132b0abb58aac4c5e98
[ "MIT" ]
null
null
null
#include "xmltags.h" #include "NetworkArchitecture.h" #include "Parameter.h" #include "Chain.h" #include "Link.h" #include "Network.h" #include "Parameter.h" #include "ParameterValues.h" #include "Exceptions.h" #include "CNTKWrapperInternals.h" Chain::Chain() { m_chainLinks = std::vector<Link*>(); } Chain::~Chain() { } Chain::Chain(tinyxml2::XMLElement* pParentNode) : Chain() { //read name m_name = CNTKWrapper::Internal::string2wstring((pParentNode->Attribute(XML_ATTRIBUTE_Name))); if (m_name.empty()) m_name = L"Chain"; //read links tinyxml2::XMLElement *pNode = pParentNode->FirstChildElement(XML_TAG_ChainLinks); if (pNode == nullptr) throw ProblemParserElementNotFound(XML_TAG_ChainLinks); loadChildren<Link>(pNode, XML_TAG_LinkBase, m_chainLinks); for (auto var : m_chainLinks) { var->setParentChain(this); } } const Link* Chain::getLinkById(const wstring id) const { for (auto item : m_chainLinks) { if (item->getId()==id) return item; } return nullptr; }
19.269231
94
0.720559
xcillero001
6d59307f1f90efe64f6283b3e08559b938583808
2,161
cpp
C++
jp.atcoder/abc007/abc007_3/19373550.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
1
2022-02-09T03:06:25.000Z
2022-02-09T03:06:25.000Z
jp.atcoder/abc007/abc007_3/19373550.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
1
2022-02-05T22:53:18.000Z
2022-02-09T01:29:30.000Z
jp.atcoder/abc007/abc007_3/19373550.cpp
kagemeka/atcoder-submissions
91d8ad37411ea2ec582b10ba41b1e3cae01d4d6e
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; template<typename T> struct Edge { public: T weight, capacity; Edge( T weight=1, T capacity=1 ) : weight(weight), capacity(capacity) {} }; template<typename T> struct Node {}; template<typename T> struct Graph { public: Graph(int n=0) : edges(n), nodes(n) {} void add_edge( int u, int v, T weight=1, T capacity=1 ) { edges[u].emplace( v, Edge<T>(weight, capacity) ); } vector<map<int, Edge<T>>> edges; vector<Node<T>> nodes; vector<int> level; void bfs(int source=0) { int n = (int)nodes.size(); level = vector<int>(n, -1); level[source] = 0; queue<int> que; que.push(source); while (!que.empty()) { int u = que.front(); que.pop(); for ( const auto& p: edges[u]) { int v = p.first; Edge<T> e = p.second; if (level[v] != -1) { continue; } level[v] = level[u] + 1; que.push(v); } } } }; class Solver { int r, c, sy, sx, gy, gx, n; vector<char> maze; void prepare() { cin >> r >> c >> sy >> sx >> gy >> gx; sy--; sx--; gy--; gx--; n = r * c; maze = vector<char>(n); for (int i = 0; i < n; i++) { cin >> maze[i]; } } void solve() { int src = sy * c + sx; int dst = gy * c + gx; Graph<int> g(n); for (int i = 0; i < n; i++) { if (maze[i] == '#') { continue; } vector<int> nx; if (i >= c) { nx.push_back(i - c); } if (i <= n-c) { nx.push_back(i + c); } if (i%c != 0) { nx.push_back(i - 1); } if (i%c != c-1) { nx.push_back(i + 1); } for (const int& j: nx) { if (maze[j] == '#') { continue; } g.add_edge(i, j); } } g.bfs(src); cout << g.level[dst] << '\n'; } public: void run() { prepare(); solve(); } }; int main() { ios::sync_with_stdio(false); cin.tie(0); int t = 1; while (t--) { Solver solver; solver.run(); } return 0; }
13.257669
32
0.441
kagemeka
6d5d2f2c995e2621b89dbd87e9a096443cb7bbf9
2,862
hpp
C++
include/TMPro/TMP_TextUtilities_LineSegment.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
include/TMPro/TMP_TextUtilities_LineSegment.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
include/TMPro/TMP_TextUtilities_LineSegment.hpp
RedBrumbler/virtuoso-codegen
e83f6f0f9b47bec4b6dd976b21edc1d46bf3cfe3
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: TMPro.TMP_TextUtilities #include "TMPro/TMP_TextUtilities.hpp" // Including type: System.ValueType #include "System/ValueType.hpp" // Including type: UnityEngine.Vector3 #include "UnityEngine/Vector3.hpp" // Completed includes #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(::TMPro::TMP_TextUtilities::LineSegment, "TMPro", "TMP_TextUtilities/LineSegment"); // Type namespace: TMPro namespace TMPro { // Size: 0x18 #pragma pack(push, 1) // WARNING Layout: Sequential may not be correctly taken into account! // Autogenerated type: TMPro.TMP_TextUtilities/TMPro.LineSegment // [TokenAttribute] Offset: FFFFFFFF struct TMP_TextUtilities::LineSegment/*, public ::System::ValueType*/ { public: public: // public UnityEngine.Vector3 Point1 // Size: 0xC // Offset: 0x0 ::UnityEngine::Vector3 Point1; // Field size check static_assert(sizeof(::UnityEngine::Vector3) == 0xC); // public UnityEngine.Vector3 Point2 // Size: 0xC // Offset: 0xC ::UnityEngine::Vector3 Point2; // Field size check static_assert(sizeof(::UnityEngine::Vector3) == 0xC); public: // Creating value type constructor for type: LineSegment constexpr LineSegment(::UnityEngine::Vector3 Point1_ = {}, ::UnityEngine::Vector3 Point2_ = {}) noexcept : Point1{Point1_}, Point2{Point2_} {} // Creating interface conversion operator: operator ::System::ValueType operator ::System::ValueType() noexcept { return *reinterpret_cast<::System::ValueType*>(this); } // Get instance field reference: public UnityEngine.Vector3 Point1 ::UnityEngine::Vector3& dyn_Point1(); // Get instance field reference: public UnityEngine.Vector3 Point2 ::UnityEngine::Vector3& dyn_Point2(); // public System.Void .ctor(UnityEngine.Vector3 p1, UnityEngine.Vector3 p2) // Offset: 0x1247E70 // ABORTED: conflicts with another method. LineSegment(::UnityEngine::Vector3 p1, ::UnityEngine::Vector3 p2); }; // TMPro.TMP_TextUtilities/TMPro.LineSegment #pragma pack(pop) static check_size<sizeof(TMP_TextUtilities::LineSegment), 12 + sizeof(::UnityEngine::Vector3)> __TMPro_TMP_TextUtilities_LineSegmentSizeCheck; static_assert(sizeof(TMP_TextUtilities::LineSegment) == 0x18); } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: TMPro::TMP_TextUtilities::LineSegment::LineSegment // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead!
45.428571
146
0.721523
RedBrumbler
6d629cf97390861e88c145c95724d8930b5e52a9
740
hpp
C++
src/text.hpp
ebassi/node-clutter
760b8f5704a216dcd633658051c0778151b21391
[ "MIT" ]
1
2017-08-31T00:58:33.000Z
2017-08-31T00:58:33.000Z
src/text.hpp
ebassi/node-clutter
760b8f5704a216dcd633658051c0778151b21391
[ "MIT" ]
null
null
null
src/text.hpp
ebassi/node-clutter
760b8f5704a216dcd633658051c0778151b21391
[ "MIT" ]
null
null
null
#ifndef NODE_CLUTTER_TEXT_H_ #define NODE_CLUTTER_TEXT_H_ #include <clutter/clutter.h> #include <v8.h> #include <node.h> namespace clutter { class Text : public Actor { public: static void Initialize(v8::Handle<v8::Object> target); protected: Text(); static v8::Handle<v8::Value> New(const v8::Arguments& args); static v8::Handle<v8::Value> SetColor(const v8::Arguments& args); static v8::Handle<v8::Value> GetColor(const v8::Arguments& args); static v8::Handle<v8::Value> SetText(const v8::Arguments& args); static v8::Handle<v8::Value> GetText(const v8::Arguments& args); static v8::Handle<v8::Value> SetFontName(const v8::Arguments& args); static v8::Handle<v8::Value> GetFontName(const v8::Arguments& args); }; } #endif
25.517241
69
0.72973
ebassi
6d68c799d92e80137b313e2b08aca1fe9404b034
1,255
cpp
C++
FamilyTree2.0/FamilyTreeQtGui/AddPersonDialog.cpp
wampirat/FamilyTree
ee6edb8f9bd6afaed6014af21a39d3eb09bd638c
[ "MIT" ]
null
null
null
FamilyTree2.0/FamilyTreeQtGui/AddPersonDialog.cpp
wampirat/FamilyTree
ee6edb8f9bd6afaed6014af21a39d3eb09bd638c
[ "MIT" ]
null
null
null
FamilyTree2.0/FamilyTreeQtGui/AddPersonDialog.cpp
wampirat/FamilyTree
ee6edb8f9bd6afaed6014af21a39d3eb09bd638c
[ "MIT" ]
null
null
null
#include "AddPersonDialog.hpp" #include "ui_AddPersonDialog.h" AddPersonDialog::AddPersonDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AddPersonDialog) { ui->setupUi(this); } AddPersonDialog::~AddPersonDialog() { delete ui; } bool AddPersonDialog::isPersonCreated() const { return personCreated; } Person AddPersonDialog::getPerson() const { return person; } void AddPersonDialog::on_diedCheckBox_toggled(bool checked) { if (checked) ui->actualPlaceLabel->setText("Miejsce pochówku"); else ui->actualPlaceLabel->setText("Miejsce zamieszkania"); ui->diedDateEdit->setEnabled(checked); } void AddPersonDialog::on_buttonBox_accepted() { auto name = ui->nameLineEdit->text().toStdString(); auto surname = ui->surnameLineEdit->text().toStdString(); auto place = ui->actualPlaceLineEdit->text().toStdString(); auto born = ui->bornDateEdit->value(); auto died = ui->diedCheckBox->isChecked(); auto death = ui->diedDateEdit->value(); person.setName(name); person.setSurname(surname); person.setPlace(place); person.setBirthdate(born); person.setIsAlive(!died); person.setDeathdate(death); personCreated = true; }
25.612245
68
0.683665
wampirat
6d6c62587e78f530d60f8189278966a03aa8dd2c
1,494
cpp
C++
shared_model/backend/protobuf/query_responses/impl/proto_error_query_response.cpp
132/iroha
66e1a490dc8917530020c53d162c573571deafd3
[ "Apache-2.0" ]
null
null
null
shared_model/backend/protobuf/query_responses/impl/proto_error_query_response.cpp
132/iroha
66e1a490dc8917530020c53d162c573571deafd3
[ "Apache-2.0" ]
8
2017-12-25T05:25:58.000Z
2018-01-20T10:12:45.000Z
shared_model/backend/protobuf/query_responses/impl/proto_error_query_response.cpp
132/iroha
66e1a490dc8917530020c53d162c573571deafd3
[ "Apache-2.0" ]
1
2018-01-18T18:23:09.000Z
2018-01-18T18:23:09.000Z
/** * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ #include "backend/protobuf/query_responses/proto_error_query_response.hpp" #include "utils/variant_deserializer.hpp" namespace shared_model { namespace proto { ErrorQueryResponse::ErrorQueryResponse( iroha::protocol::QueryResponse &query_response) : error_response_(*query_response.mutable_error_response()), variant_{[this] { auto &ar = error_response_; unsigned which = ar.GetDescriptor() ->FindFieldByName("reason") ->enum_type() ->FindValueByNumber(ar.reason()) ->index(); return shared_model::detail:: variant_impl<ProtoQueryErrorResponseListType>::template load< ProtoQueryErrorResponseVariantType>(ar, which); }()}, ivariant_{QueryErrorResponseVariantType{variant_}} {} const ErrorQueryResponse::QueryErrorResponseVariantType & ErrorQueryResponse::get() const { return ivariant_; } const ErrorQueryResponse::ErrorMessageType & ErrorQueryResponse::errorMessage() const { return error_response_.message(); } ErrorQueryResponse::ErrorCodeType ErrorQueryResponse::errorCode() const { return error_response_.error_code(); } } // namespace proto } // namespace shared_model
33.2
77
0.631191
132
6d6f06c272a40faeb2270dd82548b2eaea77aecb
133
cpp
C++
Empaerior/src/state/state.cpp
Darkyun991/Empaerior
b02fcf86fb49134dd2cf919667beb7eb789377e5
[ "MIT" ]
4
2019-12-01T20:01:58.000Z
2020-10-19T20:37:30.000Z
Empaerior/src/state/state.cpp
Dantsz/Empaerior
b02fcf86fb49134dd2cf919667beb7eb789377e5
[ "MIT" ]
null
null
null
Empaerior/src/state/state.cpp
Dantsz/Empaerior
b02fcf86fb49134dd2cf919667beb7eb789377e5
[ "MIT" ]
1
2020-01-31T09:19:36.000Z
2020-01-31T09:19:36.000Z
#include "pch.h" #include "../include/state/state.h" #include "../include/application.h" Empaerior::State::State() = default;
11.083333
36
0.661654
Darkyun991
6d70c49284054233aacbd9ee7867db587c0c5ac7
12,226
cpp
C++
src/FTPServer/FTPServer/SecurityPage.cpp
xingyun86/ppshuaiFTPServer
7cc8435ca541be75a0b48ff2a13b9f083e52af37
[ "MIT" ]
1
2017-12-10T06:08:10.000Z
2017-12-10T06:08:10.000Z
src/FTPServer/FTPServer/SecurityPage.cpp
xingyun86/ppshuaiFTPServer
7cc8435ca541be75a0b48ff2a13b9f083e52af37
[ "MIT" ]
null
null
null
src/FTPServer/FTPServer/SecurityPage.cpp
xingyun86/ppshuaiFTPServer
7cc8435ca541be75a0b48ff2a13b9f083e52af37
[ "MIT" ]
1
2018-10-26T07:19:23.000Z
2018-10-26T07:19:23.000Z
/****************************************************************/ /* */ /* SecurityPage.cpp */ /* */ /* Implementation of the CSecurityPage class. */ /* This class is a part of the FTP Server. */ /* */ /* Programmed by xingyun86 */ /* Copyright @2017 */ /* http://www.ppsbbs.tech */ /* */ /* Last updated: 10 july 2002 */ /* */ /****************************************************************/ #include "stdafx.h" #include "FTPServerApp.h" #include "ftpserver.h" #include "SecurityPage.h" #include "AddIPDlg.h" extern CFTPServer theServer; #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CSecurityPage::CSecurityPage(CWnd* pParent /*=NULL*/) : CDialogResize(CSecurityPage::IDD, pParent) { //{{AFX_DATA_INIT(CSecurityPage) m_bBlockAll = FALSE; //}}AFX_DATA_INIT } void CSecurityPage::DoDataExchange(CDataExchange* pDX) { CDialogResize::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSecurityPage) DDX_Control(pDX, IDC_BLOCKEDLIST, m_BlockedList); DDX_Control(pDX, IDC_NONBLOCKEDLIST, m_NonBlockedList); DDX_Check(pDX, IDC_BLOCK_ALL, m_bBlockAll); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSecurityPage, CDialogResize) //{{AFX_MSG_MAP(CSecurityPage) ON_BN_CLICKED(IDC_BLOCK_ALL, OnBlockAll) ON_WM_DESTROY() ON_BN_CLICKED(IDC_ADD_BLOCK, OnAddBlock) ON_BN_CLICKED(IDC_EDIT_BLOCK, OnEditBlock) ON_BN_CLICKED(IDC_ADD_NONBLOCK, OnAddNonblock) ON_BN_CLICKED(IDC_EDIT_NONBLOCK, OnEditNonblock) ON_BN_CLICKED(IDC_REMOVE_BLOCK, OnRemoveBlock) ON_BN_CLICKED(IDC_REMOVE_NONBLOCK, OnRemoveNonblock) ON_LBN_DBLCLK(IDC_BLOCKEDLIST, OnDblclkBlockedlist) ON_LBN_DBLCLK(IDC_NONBLOCKEDLIST, OnDblclkNonblockedlist) //}}AFX_MSG_MAP END_MESSAGE_MAP() BEGIN_DLGRESIZE_MAP(CSecurityPage) DLGRESIZE_CONTROL(IDC_BLOCKEDLIST, DLSZ_SIZE_X) DLGRESIZE_CONTROL(IDC_NONBLOCKEDLIST, DLSZ_SIZE_X) END_DLGRESIZE_MAP() /********************************************************************/ /* */ /* Function name : OnInitDialog */ /* Description : Initialize dialog */ /* */ /********************************************************************/ BOOL CSecurityPage::OnInitDialog() { CDialogResize::OnInitDialog(); InitResizing(FALSE, FALSE, WS_CLIPCHILDREN); m_bBlockAll = AfxGetApp()->GetProfileInt("Settings", "BlockAll", 0); GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll); UpdateData(FALSE); CStringArray strArray; theServer.m_SecurityManager.GetBlockedList(strArray); for (int i=0; i < strArray.GetSize(); i++) { m_BlockedList.AddString(strArray[i]); } theServer.m_SecurityManager.GetNonBlockedList(strArray); for (int j=0; j < strArray.GetSize(); j++) { m_NonBlockedList.AddString(strArray[j]); } // get list of all ip addresses in use by this system (only show first two...) char szHostName[128]; HOSTENT *lpHost=NULL; struct sockaddr_in sock; gethostname(szHostName, sizeof(szHostName)); lpHost = gethostbyname(szHostName); if (lpHost != NULL) { for(int i=0; lpHost->h_addr_list[i] != NULL ;i++) { memcpy(&(sock.sin_addr), lpHost->h_addr_list[i], lpHost->h_length); if (i == 0) { SetDlgItemText(IDC_IPADDRESS1, inet_ntoa(sock.sin_addr)); } else if (i == 1) { SetDlgItemText(IDC_IPADDRESS2, inet_ntoa(sock.sin_addr)); } } } return TRUE; } /********************************************************************/ /* */ /* Function name : OnDestroy */ /* Description : Dialog is about to be destroyed. */ /* */ /********************************************************************/ void CSecurityPage::OnDestroy() { UpdateData(); AfxGetApp()->WriteProfileInt("Settings", "BlockAll", m_bBlockAll); CDialogResize::OnDestroy(); } /********************************************************************/ /* */ /* Function name : OnBlockAll */ /* Description : Block all except... has been clicked. */ /* */ /********************************************************************/ void CSecurityPage::OnBlockAll() { UpdateData(); GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll); GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll); GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll); theServer.SetSecurityMode(!m_bBlockAll); } /********************************************************************/ /* */ /* Function name : OnAddBlock */ /* Description : Add IP address to blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnAddBlock() { CAddIPDlg dlg; if (dlg.DoModal() == IDOK) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } int nIndex = m_BlockedList.AddString(dlg.m_strIPaddress); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } } /********************************************************************/ /* */ /* Function name : OnEditBlock */ /* Description : Edit IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnEditBlock() { int nIndex = m_BlockedList.GetCurSel(); if (nIndex == -1) return; CAddIPDlg dlg; dlg.m_strTitle = "Edit IP address"; m_BlockedList.GetText(nIndex, dlg.m_strIPaddress); if (dlg.DoModal() == IDOK) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } m_BlockedList.DeleteString(nIndex); nIndex = m_BlockedList.AddString(dlg.m_strIPaddress); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } } /********************************************************************/ /* */ /* Function name : OnRemoveBlock */ /* Description : Remove IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnRemoveBlock() { int nIndex = m_BlockedList.GetCurSel(); if (nIndex == -1) return; m_BlockedList.DeleteString(nIndex); m_BlockedList.SetCurSel(0); UpdateSecurityData(0); } /********************************************************************/ /* */ /* Function name : OnAddNonblock */ /* Description : Add IP address to non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnAddNonblock() { CAddIPDlg dlg; if (dlg.DoModal() == IDOK) { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } int nIndex = m_NonBlockedList.AddString(dlg.m_strIPaddress); m_NonBlockedList.SetCurSel(nIndex); UpdateSecurityData(1); } } /********************************************************************/ /* */ /* Function name : OnEditNonblock */ /* Description : Edit IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnEditNonblock() { int nIndex = m_NonBlockedList.GetCurSel(); if (nIndex == -1) return; CAddIPDlg dlg; dlg.m_strTitle = "Edit IP address"; m_NonBlockedList.GetText(nIndex, dlg.m_strIPaddress); if (dlg.DoModal() == IDOK) { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); if (strText.CompareNoCase(dlg.m_strIPaddress) == 0) { // already exists ! return; } } m_NonBlockedList.DeleteString(nIndex); nIndex = m_NonBlockedList.AddString(dlg.m_strIPaddress); m_NonBlockedList.SetCurSel(nIndex); UpdateSecurityData(1); } } /********************************************************************/ /* */ /* Function name : OnRemoveNonblock */ /* Description : Remove IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnRemoveNonblock() { int nIndex = m_NonBlockedList.GetCurSel(); if (nIndex == -1) return; m_NonBlockedList.DeleteString(nIndex); m_NonBlockedList.SetCurSel(0); UpdateSecurityData(1); } /********************************************************************/ /* */ /* Function name : UpdateSecurityData */ /* Description : Update security data. */ /* */ /********************************************************************/ void CSecurityPage::UpdateSecurityData(int nType) { CStringArray strArray; if (nType == 0) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); strArray.Add(strText); } theServer.m_SecurityManager.UpdateBlockedList(strArray); } else { for (int i=0; i < m_NonBlockedList.GetCount(); i++) { CString strText; m_NonBlockedList.GetText(i, strText); strArray.Add(strText); } theServer.m_SecurityManager.UpdateNonBlockedList(strArray); } } /********************************************************************/ /* */ /* Function name : AddIPToBlockList */ /* Description : Add IP address to blocked list. */ /* */ /********************************************************************/ void CSecurityPage::AddIPToBlockList(LPCTSTR lpszIP) { for (int i=0; i < m_BlockedList.GetCount(); i++) { CString strText; m_BlockedList.GetText(i, strText); if (strText.CompareNoCase(lpszIP) == 0) { // already exists ! return; } } int nIndex = m_BlockedList.AddString(lpszIP); m_BlockedList.SetCurSel(nIndex); UpdateSecurityData(0); } /********************************************************************/ /* */ /* Function name : OnDblclkBlockedlist */ /* Description : Edit IP address from blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnDblclkBlockedlist() { OnEditBlock(); } /********************************************************************/ /* */ /* Function name : OnDblclkNonblockedlist */ /* Description : Edit IP address from non-blocked list. */ /* */ /********************************************************************/ void CSecurityPage::OnDblclkNonblockedlist() { OnEditNonblock(); }
28.498834
80
0.530754
xingyun86
6d7222fbb47d3b5de31c87aac906213c74ab219c
2,642
cpp
C++
Samples/GetIMUData/getIMUData.cpp
CelePixel/CeleX5_Zynq
de1058cb4905984f2a1279ec612105d70a7c117b
[ "Apache-2.0" ]
1
2019-07-10T06:29:35.000Z
2019-07-10T06:29:35.000Z
Samples/GetIMUData/getIMUData.cpp
CelePixel/CeleX5-Zynq
de1058cb4905984f2a1279ec612105d70a7c117b
[ "Apache-2.0" ]
null
null
null
Samples/GetIMUData/getIMUData.cpp
CelePixel/CeleX5-Zynq
de1058cb4905984f2a1279ec612105d70a7c117b
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2018 CelePixel Technology Co. Ltd. All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <opencv2/opencv.hpp> #include <celex5/celex5.h> #include <celex5/celex5datamanager.h> #define MAT_ROWS 800 #define MAT_COLS 1280 #define FPN_PATH "../Samples/config/FPN_3.txt" #ifdef _WIN32 #include <windows.h> #else #include<unistd.h> #endif using namespace std; using namespace cv; CeleX5 *pCeleX5 = new CeleX5; class SensorDataObserver : public CeleX5DataManager { public: SensorDataObserver(CX5SensorDataServer* pServer) { m_pServer = pServer; m_pServer->registerData(this, CeleX5DataManager::CeleX_Frame_Data); } ~SensorDataObserver() { m_pServer->registerData(this, CeleX5DataManager::CeleX_Frame_Data); } virtual void onFrameDataUpdated(CeleX5ProcessedData* pSensorData);//overrides Observer operation CX5SensorDataServer* m_pServer; }; void SensorDataObserver::onFrameDataUpdated(CeleX5ProcessedData* pSensorData) { if (NULL == pSensorData) return; if (CeleX5::Event_Address_Only_Mode == pSensorData->getSensorMode() || CeleX5::Event_Intensity_Mode == pSensorData->getSensorMode()) { std::vector<EventData> vecEvent; uint64_t frameNo = 0; pCeleX5->getEventDataVector(vecEvent, frameNo); cout << "vec no: " << frameNo << endl; if (vecEvent.size() > 0) { vector<IMUData> imu; if (pCeleX5->getIMUData(imu) > 0) { for (int i = 0; i < imu.size(); i++) { cout << "imu no: " << imu[i].frameNo << endl; cout << "x_ACC = " << imu[i].x_ACC << ", y_ACC = " << imu[i].y_ACC << ", z_ACC = " << imu[i].z_ACC << endl; } } } } } int main() { std::string ipAddress = "192.168.1.11"; int ipPort = 1234; if (NULL == pCeleX5) return 0; pCeleX5->openSensor(CeleX5::CeleX5_ZYNQ); pCeleX5->connectToZYNQServer(ipAddress, ipPort); //socket connect pCeleX5->setFpnFile(FPN_PATH); pCeleX5->setSensorFixedMode(CeleX5::Event_Address_Only_Mode); SensorDataObserver* pSensorData = new SensorDataObserver(pCeleX5->getSensorDataServer()); while (true) { #ifdef _WIN32 Sleep(1); #else usleep(1000 * 10); #endif } return 1; }
25.403846
112
0.715746
CelePixel
6d74865cd4979cfe7bc8ba248b473a1406c0afd3
1,065
hpp
C++
rmvmath/matrix/matrix4x3/operator/TMatrix4x3_operator.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
rmvmath/matrix/matrix4x3/operator/TMatrix4x3_operator.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
rmvmath/matrix/matrix4x3/operator/TMatrix4x3_operator.hpp
vitali-kurlovich/RMMath
a982b89e5db08e9cd16cb08e92839a315b6198dc
[ "MIT" ]
null
null
null
// // Created by Vitali Kurlovich on 12/16/15. // #ifndef RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP #define RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP #include "../TMatrix4x3_def.hpp" namespace rmmath { namespace matrix { template<typename T> inline bool operator==(const TMatrix4x3 <T> &a, const TMatrix4x3 <T> &b) { return &a == &b || (a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m10 == b.m10 && a.m11 == b.m11 && a.m12 == b.m12 && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22 && a.m30 == b.m30 && a.m31 == b.m31 && a.m32 == b.m32 ); } template<typename T> inline bool operator!=(const TMatrix4x3 <T> &a, const TMatrix4x3 <T> &b) { return !(a == b); } } } #endif //RMVECTORMATH_TMATRIX4X3_OPERATOR_HPP
22.1875
82
0.432864
vitali-kurlovich
6d74f87975bba2c9e295d172f5d7f68181f95b9e
6,420
hpp
C++
src/treeml/parser.hpp
igagis/puu
0a56fae45cd7727febffbc8eaf48e6e969d9571d
[ "MIT" ]
null
null
null
src/treeml/parser.hpp
igagis/puu
0a56fae45cd7727febffbc8eaf48e6e969d9571d
[ "MIT" ]
null
null
null
src/treeml/parser.hpp
igagis/puu
0a56fae45cd7727febffbc8eaf48e6e969d9571d
[ "MIT" ]
null
null
null
/* The MIT License (MIT) Copyright (c) 2012-2021 Ivan Gagis <igagis@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* ================ LICENSE END ================ */ #pragma once #include <string_view> #include <utki/span.hpp> #include <papki/file.hpp> #include "extra_info.hpp" /** * treeml is a very simple markup language. It is used to describe object * hierarchies. The only kind of objects present in treeml are strings. * Objects (which are strings) can have arbitrary number of child objects. */ namespace tml{ /** * @brief Listener interface for treeml parser. * During the treeml document parsing the Parser notifies this listener object * about parsed tokens. */ class listener{ public: /** * @brief A string token has been parsed. * This method is called by Parser when String token has been parsed. * @param str - parsed string. * @param info - extra information, like line:offset position in original text file. */ virtual void on_string_parsed(std::string_view str, const extra_info& info) = 0; /** * @brief Children list parsing started. * This method is called by Parser when '{' token has been parsed. */ virtual void on_children_parse_started(location loc) = 0; /** * @brief Children list parsing finished. * This method is called by Parser when '}' token has been parsed. */ virtual void on_children_parse_finished(location loc) = 0; virtual ~listener()noexcept{} }; /** * @brief treeml parser. * This is a class of treeml parser. It is used for event-based parsing of treeml * documents. */ class parser{ std::vector<char> buf; // buffer for current string being parsed // used for raw string open/close sequences, unicode sequences etc. std::string sequence; size_t sequence_index; // This variable is used for tracking current nesting level to make checks for detecting malformed treeml document unsigned nesting_level; enum class state{ initial, // state before parsing the first node idle, string_parsed, quoted_string, escape_sequence, unicode_sequence, unquoted_string, comment_seqence, single_line_comment, multiline_comment, raw_cpp_string_opening_sequence, raw_cpp_string_closing_sequence, raw_cpp_string, raw_python_string_opening_sequence, raw_python_string_closing_sequence, raw_python_string, } cur_state; state previous_state; void handle_string_parsed(tml::listener& listener); void process_char(char c, tml::listener& listener); void process_char_in_initial(char c, tml::listener& listener); void process_char_in_idle(char c, tml::listener& listener); void process_char_in_string_parsed(char c, tml::listener& listener); void process_char_in_unquoted_string(char c, tml::listener& listener); void process_char_in_quoted_string(char c, tml::listener& listener); void process_char_in_escape_sequence(char c, tml::listener& listener); void process_char_in_unicode_sequence(char c, tml::listener& listener); void process_char_in_comment_sequence(char c, tml::listener& listener); void process_char_in_single_line_comment(char c, tml::listener& listener); void process_char_in_multiline_comment(char c, tml::listener& listener); void process_char_in_raw_cpp_string_opening_sequence(char c, tml::listener& listener); void process_char_in_raw_cpp_string(char c, tml::listener& listener); void process_char_in_raw_cpp_string_closing_sequence(char c, tml::listener& listener); void process_char_in_raw_python_string_opening_sequence(char c, tml::listener& listener); void process_char_in_raw_python_string(char c, tml::listener& listener); void process_char_in_raw_python_string_closing_sequence(char c, tml::listener& listener); location cur_loc = {1, 1}; // offset starts with 1 void next_line(); extra_info info = { {}, tml::flag::first_on_line }; void set_string_start_pos(); public: /** * @brief Constructor. * Creates an initially reset Parser object. */ parser(){ this->reset(); } /** * @brief Reset parser. * Resets the parser to initial state, discarding all the temporary parsed data and state. */ void reset(); /** * @brief Parse chunk of treeml data. * Use this method to feed the treeml data to the parser. * @param chunk - data chunk to parse. * @param listener - listener object which will receive notifications about parsed tokens. */ void parse_data_chunk(utki::span<const char> chunk, listener& listener); void parse_data_chunk(utki::span<const uint8_t> chunk, listener& listener){ this->parse_data_chunk( utki::make_span( reinterpret_cast<const char*>(chunk.data()), chunk.size() ), listener ); } /** * @brief Finalize parsing. * Call this method to finalize parsing after all the available treeml data has been fed to the parser. * This will tell parser that there will be no more data and the temporary stored data should be interpreted as it is. * @param listener - listener object which will receive notifications about parsed tokens. */ void end_of_data(listener& listener); }; /** * @brief Parse treeml document provided by given file interface. * Use this function to parse the treeml document from file. * @param fi - file interface to use for getting the data to parse. * @param listener - listener object which will receive notifications about parsed tokens. */ void parse(const papki::file& fi, listener& listener); }
33.4375
119
0.75109
igagis
6d7546f4fb95f8fe845c29d2a0a74a0e5ae2fe80
551
cpp
C++
tests/sparse_set.cpp
ColinH/apecs
5a263bbb256213087ddad293d55fbfb1df2b234d
[ "MIT" ]
null
null
null
tests/sparse_set.cpp
ColinH/apecs
5a263bbb256213087ddad293d55fbfb1df2b234d
[ "MIT" ]
null
null
null
tests/sparse_set.cpp
ColinH/apecs
5a263bbb256213087ddad293d55fbfb1df2b234d
[ "MIT" ]
null
null
null
#include "apecs.hpp" #include <gtest/gtest.h> TEST(sparse_set, set_and_get) { apx::sparse_set<int> set; set.insert(2, 5); ASSERT_TRUE(set.has(2)); ASSERT_EQ(set[2], 5); } TEST(sparse_set, erase) { apx::sparse_set<int> set; set.insert(2, 5); ASSERT_TRUE(set.has(2)); set.erase(2); ASSERT_FALSE(set.has(2)); } TEST(sparse_set, fast_with_one_element) { apx::sparse_set<int> set; set.insert(2, 5); for (auto [key, value] : set.fast()) { ASSERT_EQ(key, 2); ASSERT_EQ(value, 5); } }
16.69697
42
0.598911
ColinH
6d791aea2c24e7f7199c94d53547a4e950efa33e
557
hpp
C++
src/server/Player.hpp
Fenex330/surv-royale
4b5264a346e44e7460221cc23c8aaf9a10c4a4d7
[ "MIT" ]
2
2022-03-01T18:57:26.000Z
2022-03-20T18:20:13.000Z
src/server/Player.hpp
Fenex330/surv-royale
4b5264a346e44e7460221cc23c8aaf9a10c4a4d7
[ "MIT" ]
null
null
null
src/server/Player.hpp
Fenex330/surv-royale
4b5264a346e44e7460221cc23c8aaf9a10c4a4d7
[ "MIT" ]
1
2021-11-11T19:01:18.000Z
2021-11-11T19:01:18.000Z
#pragma once #include "headers.hpp" class Player : public Obstacle { public: bool active; std::string nickname; std::string ID; sf::IpAddress address; unsigned short port; unsigned short slot; float crosshair_distance; int speed; std::array<Item*, 6> items; Player(int map_size, int speed, std::string ID, sf::IpAddress address, unsigned short port, std::string nickname); void interact(); void fire(); void move(sf::Int16 x_, sf::Int16 y_); };
23.208333
122
0.594255
Fenex330
6d79e59ad60e30a7f9ec4872831e0a2d537c96b7
3,919
hpp
C++
src/vendor/Karabiner-VirtualHIDDevice/src/include/karabiner_virtual_hid_device_methods.hpp
mul14/wwwjfy-Karabiner-Elements
36c51373d2cce23f913685dbf2b6b6e5479619dd
[ "Unlicense" ]
271
2016-10-03T22:35:55.000Z
2022-02-14T05:40:39.000Z
src/vendor/Karabiner-VirtualHIDDevice/src/include/karabiner_virtual_hid_device_methods.hpp
mul14/wwwjfy-Karabiner-Elements
36c51373d2cce23f913685dbf2b6b6e5479619dd
[ "Unlicense" ]
2
2017-02-03T03:16:21.000Z
2017-06-10T09:52:46.000Z
src/vendor/Karabiner-VirtualHIDDevice/src/include/karabiner_virtual_hid_device_methods.hpp
mul14/wwwjfy-Karabiner-Elements
36c51373d2cce23f913685dbf2b6b6e5479619dd
[ "Unlicense" ]
25
2016-10-06T19:20:13.000Z
2021-06-17T03:02:09.000Z
// -*- Mode: c++ -*- #pragma once #include "karabiner_virtual_hid_device.hpp" #include <IOKit/IOKitLib.h> namespace pqrs { class karabiner_virtual_hid_device_methods final { public: // VirtualHIDKeyboard static IOReturn initialize_virtual_hid_keyboard(mach_port_t connection, const karabiner_virtual_hid_device::properties::keyboard_initialization& properties) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::initialize_virtual_hid_keyboard), &properties, sizeof(properties), nullptr, 0); } static IOReturn terminate_virtual_hid_keyboard(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::terminate_virtual_hid_keyboard), nullptr, 0, nullptr, 0); } static IOReturn dispatch_keyboard_event(mach_port_t connection, const karabiner_virtual_hid_device::hid_event_service::keyboard_event& keyboard_event) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::dispatch_keyboard_event), &keyboard_event, sizeof(keyboard_event), nullptr, 0); } static IOReturn post_keyboard_input_report(mach_port_t connection, const karabiner_virtual_hid_device::hid_report::keyboard_input& report) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::post_keyboard_input_report), &report, sizeof(report), nullptr, 0); } static IOReturn reset_virtual_hid_keyboard(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::reset_virtual_hid_keyboard), nullptr, 0, nullptr, 0); } // VirtualHIDPointing static IOReturn initialize_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::initialize_virtual_hid_pointing), nullptr, 0, nullptr, 0); } static IOReturn terminate_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::terminate_virtual_hid_pointing), nullptr, 0, nullptr, 0); } static IOReturn post_pointing_input_report(mach_port_t connection, const karabiner_virtual_hid_device::hid_report::pointing_input& report) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::post_pointing_input_report), &report, sizeof(report), nullptr, 0); } static IOReturn reset_virtual_hid_pointing(mach_port_t connection) { return IOConnectCallStructMethod(connection, static_cast<uint32_t>(karabiner_virtual_hid_device::user_client_method::reset_virtual_hid_pointing), nullptr, 0, nullptr, 0); } }; }
49.607595
160
0.620056
mul14
6d7a0bed6aa3ca0b6a2bd84ad7b7e349382fc681
5,892
hh
C++
src/c++/include/common/Program.hh
sequencing/EAGLE
6da0438c1f7620ea74dec1f34baf20bb0b14b110
[ "BSD-3-Clause" ]
28
2015-05-22T16:03:29.000Z
2022-01-15T12:12:46.000Z
src/c++/include/common/Program.hh
sequencing/EAGLE
6da0438c1f7620ea74dec1f34baf20bb0b14b110
[ "BSD-3-Clause" ]
15
2015-10-21T11:19:09.000Z
2020-07-15T05:01:12.000Z
src/c++/include/common/Program.hh
sequencing/EAGLE
6da0438c1f7620ea74dec1f34baf20bb0b14b110
[ "BSD-3-Clause" ]
8
2017-01-21T00:31:17.000Z
2018-08-12T13:28:57.000Z
/** ** Copyright (c) 2014 Illumina, Inc. ** ** This file is part of Illumina's Enhanced Artificial Genome Engine (EAGLE), ** covered by the "BSD 2-Clause License" (see accompanying LICENSE file) ** ** \description Declaration of the skeleton of all c++ programs. ** ** \author Mauricio Varea **/ #ifndef EAGLE_COMMON_PROGRAM_HH #define EAGLE_COMMON_PROGRAM_HH #include <string> #include <iostream> #include <fstream> #include <cstdlib> #include <limits> #include <typeinfo> #include <boost/program_options.hpp> #include <boost/noncopyable.hpp> #include <boost/algorithm/string.hpp> #include <boost/filesystem.hpp> #include <boost/format.hpp> #include "common/Exceptions.hh" #include "common/Logger.hh" namespace eagle { namespace common { namespace bpo = boost::program_options; namespace bfs = boost::filesystem; typedef std::pair<bfs::path *, std::string> PathOption; struct ProgramInfo { ProgramInfo(std::string arg, unsigned int width) : tool(arg), toolName(tool.leaf().string()), project(EAGLE_NAME), version(EAGLE_VERSION), copyright(EAGLE_COPYRIGHT), optionsWidth(width) {} bfs::path tool; std::string toolName; std::string project; std::string version; std::string copyright; unsigned int optionsWidth; friend std::ostream& operator<< (std::ostream& os, ProgramInfo pi); }; std::string naiveDemangling(const char *type); /** ** Encapsulation of the processing of the command line options. ** ** TODO: add config file and environment options **/ class Options: boost::noncopyable { public: enum Action { RUN, HELP, VERSION, ABORT }; Options( bool anyOutput = true ); virtual ~Options() { } Action parse(int argc, char *argv[]); std::string usage(bool full = false) const; unsigned int width() const {return bpo::options_description::m_default_line_length;} protected: bpo::options_description parameters_; bpo::options_description namedOptions_; bpo::options_description unnamedOptions_; bpo::positional_options_description positionalOptions_; bpo::options_description general_; private: virtual std::string usagePrefix() const = 0; virtual std::string usageSuffix() const { return ""; } virtual void postProcess(bpo::variables_map &) { } }; class OptionsHelper : bpo::variables_map { public: OptionsHelper(bpo::variables_map vm) : bpo::variables_map(vm) {} void requiredOptions(std::vector<std::string> requiredOptionList); std::string mutuallyExclusiveOptions(std::vector<std::string> mutuallyExclusiveList); void inputPathsExist(); void outputFilesWriteable(); void outputDirsWriteable(); void addPathOptions(std::vector<bfs::path>& pathOptions, std::string label); void addPathOptions(bfs::path& pathOption, std::string label); void clearPathOptions() {pathOptions_.clear();} template<typename T> void inRange(std::pair<T,std::string> option, T minValue = std::numeric_limits<T>::min(), T maxValue = std::numeric_limits<T>::max()) { if( minValue > option.first || option.first >= maxValue ) { std::string t = naiveDemangling(typeid(T).name()); const boost::format message = boost::format("\n *** The '%s' option is out of range. Please specify a%s '%s' within [%s,%s)") % option.second % ((t[0] == 'a' || t[0] == 'e' || t[0] == 'i' || t[0] == 'o' || t[0] == 'u') ? "n" : "") % t % boost::lexical_cast<std::string>(minValue) % boost::lexical_cast<std::string>(maxValue); BOOST_THROW_EXCEPTION(InvalidOptionException(message.str())); } } private: std::vector<PathOption> pathOptions_; }; /** ** Unified behavior of all programs. **/ template<class O> void run(void(*callback)(const O &), int argc, char *argv[]) { #ifdef EAGLE_DEBUG_MODE std::cout << "Command-line invocation:\n "; for (int i = 0; i < argc; i++) { std::cout << std::string(argv[i]) << " "; } std::cout << std::endl; #endif try { O options; ProgramInfo info( std::string(argv[0]), options.width() ); const typename O::Action action = options.parse(argc, argv); if (O::RUN == action) { callback(options); } else { if (O::HELP == action || O::VERSION == action) { std::clog << info << std::endl; if (O::VERSION == action) exit(0); } std::clog << options.usage(O::HELP == action); exit(O::HELP != action); } } catch (const eagle::common::ExceptionData &exception) { std::clog << "Error: " << exception.getContext() << ": " << exception.getMessage() << std::endl; exit(1); } catch (const boost::exception &e) { std::clog << "Error: boost::exception: " << boost::diagnostic_information(e) << std::endl; exit(2); } catch (const std::bad_alloc &e) { std::clog << "memory allocation error: " << e.what() << std::endl; std::ifstream proc("/proc/self/status"); std::string s; while(std::getline(proc, s), !proc.fail()) { std::clog << "\t" << s << std::endl; } std::clog << "*** abandoned execution! ***" << std::endl; exit(3); } catch (const std::runtime_error &e) { std::clog << "runtime error: " << e.what() << std::endl; exit(4); } catch (const std::logic_error &e) { std::clog << "logic error: " << e.what() << std::endl; exit(5); } } } // namespace common } // namespace eagle #endif // EAGLE_COMMON_PROGRAM_HH
29.60804
144
0.594365
sequencing
6d7a501de0bc546d06424e3c8eb1630db7dd4c1d
192
hpp
C++
support/modules/rmm_cnstrct/functions.hpp
beocom/dhqlax_mso.fallujah
81217510ee2b66afbbef72c5ee3f9e4b3b7eff7f
[ "Apache-2.0" ]
null
null
null
support/modules/rmm_cnstrct/functions.hpp
beocom/dhqlax_mso.fallujah
81217510ee2b66afbbef72c5ee3f9e4b3b7eff7f
[ "Apache-2.0" ]
null
null
null
support/modules/rmm_cnstrct/functions.hpp
beocom/dhqlax_mso.fallujah
81217510ee2b66afbbef72c5ee3f9e4b3b7eff7f
[ "Apache-2.0" ]
null
null
null
class cnstrct { file = "support\modules\rmm_cnstrct"; class functions { class create {}; class handler {}; class open {}; class refresh {}; class sell {}; class update {}; }; };
17.454545
38
0.619792
beocom
6d8128eba1b5fe8fe4c86b07b60d6892ed6aa6bb
13,223
cpp
C++
ace/Timeprobe_T.cpp
azerothcore/lib-ace
c1fedd5f2033951eee9ecf898f6f2b75584aaefc
[ "DOC" ]
null
null
null
ace/Timeprobe_T.cpp
azerothcore/lib-ace
c1fedd5f2033951eee9ecf898f6f2b75584aaefc
[ "DOC" ]
null
null
null
ace/Timeprobe_T.cpp
azerothcore/lib-ace
c1fedd5f2033951eee9ecf898f6f2b75584aaefc
[ "DOC" ]
1
2020-04-26T03:07:12.000Z
2020-04-26T03:07:12.000Z
#ifndef ACE_TIMEPROBE_T_CPP #define ACE_TIMEPROBE_T_CPP #include "ace/config-all.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #if defined (ACE_COMPILE_TIMEPROBES) #include "ace/Timeprobe.h" #include "ace/High_Res_Timer.h" #include "ace/OS_NS_string.h" ACE_BEGIN_VERSIONED_NAMESPACE_DECL template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (u_long size) : timeprobes_ (0), lock_ (), max_size_ (size), current_size_ (0), report_buffer_full_ (0), allocator_ (0) { ACE_timeprobe_t *temp; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_*sizeof(ACE_timeprobe_t)), ACE_timeprobe_t, this->max_size_); //FUZZ: enable check_for_lack_ACE_OS this->timeprobes_ = temp; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>:: ACE_Timeprobe_Ex (ALLOCATOR *allocator, u_long size) : timeprobes_ (0), lock_ (), max_size_ (size), current_size_ (0), report_buffer_full_ (0), allocator_ (allocator) { ACE_timeprobe_t *temp = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_*sizeof(ACE_timeprobe_t)), ACE_timeprobe_t, this->max_size_); //FUZZ: enable check_for_lack_ACE_OS this->timeprobes_ = temp; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe_Ex (const ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> &) { // // Stupid MSVC is forcing me to define this; please don't use it. // ACELIB_ERROR ((LM_ERROR, ACE_TEXT ("ACE_NOTSUP: %N, line %l\n"))); errno = ENOTSUP; } template <class ACE_LOCK, class ALLOCATOR> ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::~ACE_Timeprobe_Ex (void) { ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *) (this->timeprobes_), this->max_size_, this->allocator ()->free, ACE_timeprobe_t); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (u_long event) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->timeprobes_[this->current_size_].event_.event_number_ = event; this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::NUMBER; this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); ++this->current_size_; #if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) // wrap around to the beginning on overflow if (this->current_size_ >= this->max_size_) { this->current_size_ = 0; this->report_buffer_full_ = 1; } #endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ ACE_ASSERT (this->current_size_ < this->max_size_); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobe (const char *event) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->timeprobes_[this->current_size_].event_.event_description_ = event; this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::STRING; this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime (); this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self (); ++this->current_size_; #if !defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE) // wrap around to the beginning on overflow if (this->current_size_ >= this->max_size_) { this->current_size_ = 0; this->report_buffer_full_ = 1; } #endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */ ACE_ASSERT (this->current_size_ < this->max_size_); } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::reset (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); this->current_size_ = 0; this->report_buffer_full_ = 0; } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::increase_size (u_long size) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); if (size > this->max_size_) { ACE_timeprobe_t *temp = 0; //FUZZ: disable check_for_lack_ACE_OS ACE_NEW_MALLOC_ARRAY (temp, (ACE_timeprobe_t *) this->allocator ()-> malloc (this->max_size_ * sizeof (ACE_timeprobe_t)), ACE_timeprobe_t, size); //FUZZ: enable check_for_lack_ACE_OS if (this->max_size_ > 0) { ACE_OS::memcpy (temp, this->timeprobes_, this->max_size_ * sizeof (ACE_timeprobe_t)); // Iterates over the array explicitly calling the destructor for // each probe instance, then deallocates the memory ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *)(this->timeprobes_), this->max_size_, this->allocator ()->free, ACE_timeprobe_t); } this->timeprobes_ = temp; this->max_size_ = size; } } template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (void) { return this->event_descriptions_; } template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sorted_event_descriptions (void) { return this->sorted_event_descriptions_; } template <class ACE_LOCK, class ALLOCATOR> ACE_timeprobe_t * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::timeprobes (void) { return this->timeprobes_; } template <class ACE_LOCK, class ALLOCATOR> ACE_LOCK & ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::lock (void) { return this->lock_; } template <class ACE_LOCK, class ALLOCATOR> u_long ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::max_size (void) { return this->max_size_; } template <class ACE_LOCK, class ALLOCATOR> u_long ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::current_size (void) { return this->current_size_; } template <class ACE_LOCK, class ALLOCATOR> int ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::event_descriptions (const char **descriptions, u_long minimum_id) { ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); ACE_Event_Descriptions events; events.descriptions_ = descriptions; events.minimum_id_ = minimum_id; this->event_descriptions_.insert (events); return 0; } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_times (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); // Sort the event descriptions this->sort_event_descriptions_i (); u_long size = this->report_buffer_full_ ? this->max_size_ : this->current_size_; ACELIB_DEBUG ((LM_DEBUG, "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", size)); if (size == 0) return; ACELIB_DEBUG ((LM_DEBUG, "\n%-50.50s %8.8s %13.13s\n\n", "Event", "thread", "usec")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); u_long i, j; // First element i = this->report_buffer_full_ ? this->current_size_ : 0; ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %13.13s\n", this->find_description_i (i), this->timeprobes_[i].thread_, "START")); if (size == 1) return; bool has_timestamp_inversion = false; j = i; i = (i + 1) % this->max_size_; do { // When reusing the same ACE_Timeprobe from multiple threads // with Linux on Intel SMP, it sometimes happens that the // recorded times go backward in time if they are recorded from // different threads (see bugzilla #2342). To obtain the // correct signed difference between consecutive recorded times, // one has to cast the time difference to an intermediate signed // integral type of the same size as ACE_hrtime_t. double time_difference = (ACE_INT64) (this->timeprobes_[i].time_ - this->timeprobes_[j].time_); if (time_difference < 0) has_timestamp_inversion = true; // Convert to microseconds. time_difference /= gsf; ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %14.3f\n", this->find_description_i (i), this->timeprobes_[i].thread_, time_difference)); j = i; i = (i + 1) % this->max_size_; } while (i != this->current_size_); static bool inversion_warning_printed = false; if (!inversion_warning_printed && has_timestamp_inversion) { inversion_warning_printed = true; ACELIB_DEBUG ((LM_DEBUG, "\nWARNING: The timestamps recorded by gethrtime() on" " this platform are\n" "not monotonic across different threads.\n")); } } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::print_absolute_times (void) { ACE_GUARD (ACE_LOCK, ace_mon, this->lock_); // Sort the event descriptions this->sort_event_descriptions_i (); u_long size = this->report_buffer_full_ ? this->max_size_ : this->current_size_; ACELIB_DEBUG ((LM_DEBUG, "\nACE_Timeprobe_Ex; %u timestamps were recorded:\n", size)); if (size == 0) return; ACELIB_DEBUG ((LM_DEBUG, "\n%-50.50s %8.8s %13.13s\n\n", "Event", "thread", "stamp")); u_long i = this->report_buffer_full_ ? this->current_size_ : 0; ACE_Time_Value tv; // to convert ACE_hrtime_t do { ACE_High_Res_Timer::hrtime_to_tv (tv, this->timeprobes_ [i].time_); ACELIB_DEBUG ((LM_DEBUG, "%-50.50s %8.8x %12.12u\n", this->find_description_i (i), this->timeprobes_ [i].thread_, tv.sec () * 1000000 + tv.usec ())); // Modulus increment: loops around at the end. i = (i + 1) % this->max_size_; } while (i != this->current_size_); } template <class ACE_LOCK, class ALLOCATOR> const char * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::find_description_i (u_long i) { if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING) return this->timeprobes_[i].event_.event_description_; else { EVENT_DESCRIPTIONS::iterator iterator = this->sorted_event_descriptions_.begin (); for (u_long j = 0; j < this->sorted_event_descriptions_.size () - 1; iterator++, j++) { EVENT_DESCRIPTIONS::iterator next_event_descriptions = iterator; ++next_event_descriptions; if (this->timeprobes_[i].event_.event_number_ < (*next_event_descriptions).minimum_id_) break; } return (*iterator).descriptions_[this->timeprobes_[i].event_.event_number_ - (*iterator).minimum_id_]; } } template <class ACE_LOCK, class ALLOCATOR> void ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::sort_event_descriptions_i (void) { size_t total_elements = this->event_descriptions_.size (); for (size_t i = 0; i < total_elements; i++) { EVENT_DESCRIPTIONS::iterator iterator = this->event_descriptions_.begin (); ACE_Event_Descriptions min_entry = *iterator; for (; iterator != this->event_descriptions_.end (); iterator++) if ((*iterator).minimum_id_ < min_entry.minimum_id_) min_entry = *iterator; this->sorted_event_descriptions_.insert (min_entry); this->event_descriptions_.remove (min_entry); } } template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR * ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>::allocator (void) { return allocator_ ? allocator_ : ACE_Singleton<ALLOCATOR, ACE_LOCK>::instance (); } template <class Timeprobe> ACE_Function_Timeprobe<Timeprobe>::ACE_Function_Timeprobe (Timeprobe &timeprobe, u_long event) : timeprobe_ (timeprobe), event_ (event) { this->timeprobe_.timeprobe (this->event_); } template <class Timeprobe> ACE_Function_Timeprobe<Timeprobe>::~ACE_Function_Timeprobe (void) { this->timeprobe_.timeprobe (this->event_ + 1); } ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_COMPILE_TIMEPROBES */ #endif /* ACE_TIMEPROBE_T_CPP */
30.967213
109
0.626257
azerothcore
6d821ed8f72731e808081df89cab1230029335e9
1,124
hpp
C++
src/serial/split_fluxes.hpp
Scientific-Computing-BPHC/Meshfree_Adjoint_cpp
8afe99007b08e6a21563c44f09e972a260fb5b94
[ "MIT" ]
null
null
null
src/serial/split_fluxes.hpp
Scientific-Computing-BPHC/Meshfree_Adjoint_cpp
8afe99007b08e6a21563c44f09e972a260fb5b94
[ "MIT" ]
null
null
null
src/serial/split_fluxes.hpp
Scientific-Computing-BPHC/Meshfree_Adjoint_cpp
8afe99007b08e6a21563c44f09e972a260fb5b94
[ "MIT" ]
null
null
null
#ifndef SPLIT_FLUXES_HPP #define SPLIT_FLUXES_HPP #include "point.hpp" void flux_Gyn(codi::RealReverse Gyn[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gyp(codi::RealReverse Gyp[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gxp(codi::RealReverse Gxp[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gxn(codi::RealReverse Gxn[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gx(codi::RealReverse Gx[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); void flux_Gy(codi::RealReverse Gy[4], codi::RealReverse nx, codi::RealReverse ny, codi::RealReverse u1, codi::RealReverse u2, codi::RealReverse rho, codi::RealReverse pr); #endif
66.117647
173
0.768683
Scientific-Computing-BPHC
6d829f817ca0208c44916a5be74993a777a74ff8
435
cpp
C++
FoxelEngine/Axes.cpp
FoxelFox/FoxelEngine
604aa08c9f50cde278ec6e4f84cadc45723596e0
[ "MIT" ]
6
2020-06-10T10:44:57.000Z
2022-03-08T16:45:18.000Z
FoxelEngine/Axes.cpp
FoxelFox/FoxelEngine
604aa08c9f50cde278ec6e4f84cadc45723596e0
[ "MIT" ]
null
null
null
FoxelEngine/Axes.cpp
FoxelFox/FoxelEngine
604aa08c9f50cde278ec6e4f84cadc45723596e0
[ "MIT" ]
null
null
null
#include "Axes.h" Axes::Axes(void){ anzVertex = 4; anzIndex = 6; indices = AxeIndices; vertices = AxeVertices; colors = AxeColor; } void Axes::render(){ glBindVertexArray(vao); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glDrawElements(GL_LINES,6,GL_UNSIGNED_INT,indices); glDisableVertexAttribArray(0); glDisableVertexAttribArray(1); glBindVertexArray(0); } Axes::~Axes(void){ }
18.125
53
0.708046
FoxelFox
6d84aed026dc08c4da387ebe0695ae5a0bda1df2
13,540
cpp
C++
lib/src/models/filename.cpp
BramboraSK/imgbrd-grabber
ef718d4f7df7843f03f058959fbcc72e2ba54457
[ "Apache-2.0" ]
1
2019-08-03T13:11:11.000Z
2019-08-03T13:11:11.000Z
lib/src/models/filename.cpp
AtlasJan/imgbrd-grabber
89c1425a7d1340d99b98e3121ef981ed27c4ee9c
[ "Apache-2.0" ]
null
null
null
lib/src/models/filename.cpp
AtlasJan/imgbrd-grabber
89c1425a7d1340d99b98e3121ef981ed27c4ee9c
[ "Apache-2.0" ]
null
null
null
#include "models/filename.h" #include <QCollator> #include <QJSEngine> #include <QRegularExpression> #include <QSettings> #include <algorithm> #include "filename/ast/filename-node-variable.h" #include "filename/ast-filename.h" #include "filename/filename-cache.h" #include "filename/filename-execution-visitor.h" #include "functions.h" #include "loader/token.h" #include "models/api/api.h" #include "models/filtering/post-filter.h" #include "models/image.h" #include "models/profile.h" #include "models/site.h" Filename::Filename() : Filename("") {} Filename::Filename(QString format) : m_format(std::move(format)) { m_ast = FilenameCache::Get(m_format); } QList<Token> Filename::getReplace(const QString &key, const Token &token, QSettings *settings) const { QList<Token> ret; QStringList value = token.value().toStringList(); if (token.whatToDoDefault().isEmpty()) { ret.append(Token(value)); return ret; } settings->beginGroup("Save"); const QString sort = settings->value(key + "_sort", "original").toString(); if (sort == QLatin1String("name")) { value.sort(); } if (value.isEmpty()) { ret.append(Token(settings->value(key + "_empty", token.emptyDefault()).toString())); } else if (value.size() > settings->value(key + "_multiple_limit", 1).toInt()) { const QString &whatToDo = settings->value(key + "_multiple", token.whatToDoDefault()).toString(); if (whatToDo == QLatin1String("keepAll")) { ret.append(Token(value)); } else if (whatToDo == QLatin1String("multiple")) { ret.reserve(ret.count() + value.count()); for (const QString &val : value) { ret.append(Token(val)); } } else if (whatToDo == QLatin1String("keepN")) { const int keepN = settings->value(key + "_multiple_keepN", 1).toInt(); ret.append(Token(QStringList(value.mid(0, qMax(1, keepN))))); } else if (whatToDo == QLatin1String("keepNThenAdd")) { const int keepN = settings->value(key + "_multiple_keepNThenAdd_keep", 1).toInt(); QString thenAdd = settings->value(key + "_multiple_keepNThenAdd_add", " (+ %count%)").toString(); thenAdd.replace("%total%", QString::number(value.size())); thenAdd.replace("%count%", QString::number(value.size() - keepN)); QStringList keptValues = value.mid(0, qMax(1, keepN)); if (value.size() > keepN) { ret.append(Token(keptValues.join(' ') + thenAdd)); } else { ret.append(Token(keptValues)); } } else { ret.append(Token(settings->value(key + "_value", token.multipleDefault()).toString())); } } else { ret.append(Token(value)); } settings->endGroup(); return ret; } QList<QMap<QString, Token>> Filename::expandTokens(QMap<QString, Token> tokens, QSettings *settings) const { QList<QMap<QString, Token>> ret; ret.append(tokens); const bool isJavascript = m_format.startsWith(QLatin1String("javascript:")); for (const QString &key : tokens.keys()) { const Token &token = tokens[key]; if (token.value().type() != QVariant::StringList) { continue; } const bool hasToken = !isJavascript && m_ast->tokens().contains(key); const bool hasVar = isJavascript && m_format.contains(key); if (!hasToken && !hasVar) { continue; } QList<Token> reps = getReplace(key, token, settings); const int cnt = ret.count(); for (int i = 0; i < cnt; ++i) { ret[i].insert(key, reps[0]); for (int j = 1; j < reps.count(); ++j) { tokens = ret[i]; tokens.insert(key, reps[j]); ret.append(tokens); } } } return ret; } QStringList Filename::path(const Image &img, Profile *profile, const QString &pth, int counter, PathFlags flags) const { return path(img.tokens(profile), profile, pth, counter, flags); } QStringList Filename::path(QMap<QString, Token> tokens, Profile *profile, QString folder, int counter, PathFlags flags) const { QSettings *settings = profile->getSettings(); // Computed tokens tokens.insert("count", Token(counter)); tokens.insert("current_date", Token(QDateTime::currentDateTime())); // Conditional filenames if (flags.testFlag(PathFlag::ConditionalFilenames)) { QList<ConditionalFilename> filenames = getFilenames(settings); for (const auto &fn : filenames) { if (fn.matches(tokens, settings)) { if (!fn.path.isEmpty()) { folder = fn.path; } if (!fn.filename.format().isEmpty()) { return fn.filename.path(tokens, profile, folder, counter, flags & (~PathFlag::ConditionalFilenames)); } } } } QStringList fns; if (m_format.isEmpty()) { return fns; } // Expand tokens into multiple filenames QList<QMap<QString, Token>> replacesList = expandTokens(tokens, settings); for (const auto &replaces : replacesList) { FilenameExecutionVisitor executionVisitor(replaces, settings); executionVisitor.setEscapeMethod(m_escapeMethod); executionVisitor.setKeepInvalidTokens(flags.testFlag(PathFlag::KeepInvalidTokens)); // TODO(Bionus): PathFlag::ExpandConditionals QString cFilename = executionVisitor.run(*m_ast->ast()); // Something wrong happened (JavaScript error...) if (cFilename.isEmpty()) { continue; } // "num" special token QRegularExpression rxNum("%num(?::.+)?%"); auto numMatch = rxNum.match(cFilename); if (numMatch.hasMatch()) { FilenameParser parser(numMatch.captured()); FilenameNodeVariable *var = parser.parseVariable(); int num = 1; const QString hasNum = numMatch.captured(); const bool noExt = var->opts.contains("noext"); const int mid = QDir::toNativeSeparators(cFilename).lastIndexOf(QDir::separator()); QDir dir(folder + (mid >= 0 ? QDir::separator() + cFilename.left(mid) : QString())); const QString cRight = mid >= 0 ? cFilename.right(cFilename.length() - mid - 1) : cFilename; QString filter = QString(cRight).replace(hasNum, "*"); if (noExt) { const QString ext = replaces["ext"].toString(); if (filter.endsWith("." + ext)) { filter = filter.left(filter.length() - ext.length()) + "*"; } } QFileInfoList files = dir.entryInfoList(QStringList() << filter, QDir::Files, QDir::NoSort); if (!files.isEmpty()) { // Get last file QCollator collator; collator.setNumericMode(true); const QFileInfo highest = noExt ? *std::max_element( files.begin(), files.end(), [&collator](const QFileInfo &a, const QFileInfo &b) { return collator.compare(a.completeBaseName(), b.completeBaseName()) < 0; } ) : *std::max_element( files.begin(), files.end(), [&collator](const QFileInfo &a, const QFileInfo &b) { return collator.compare(a.fileName(), b.fileName()) < 0; } ); const QString last = highest.fileName(); const int pos = cRight.indexOf(hasNum); const int len = last.length() - cRight.length() + hasNum.length(); num = last.midRef(pos, len).toInt() + 1; } QString val = executionVisitor.variableToString(var->name, num, var->opts); cFilename.replace(numMatch.capturedStart(), numMatch.capturedLength(), val); } fns.append(cFilename); } const int cnt = fns.count(); for (int i = 0; i < cnt; ++i) { if (flags.testFlag(PathFlag::Fix)) { // Trim directory names fns[i] = fns[i].trimmed(); fns[i].replace(QRegularExpression(" */ *"), "/"); // Max filename size option const int limit = !flags.testFlag(PathFlag::CapLength) ? 0 : settings->value("Save/limit").toInt(); fns[i] = fixFilename(fns[i], folder, limit); } // Include directory in result if (flags.testFlag(PathFlag::IncludeFolder)) { fns[i] = folder + "/" + fns[i]; } if (flags.testFlag(PathFlag::Fix)) { // Native separators fns[i] = QDir::toNativeSeparators(fns[i]); // We remove empty directory names const QChar sep = QDir::separator(); fns[i].replace(QRegularExpression("(.)" + QRegularExpression::escape(sep) + "{2,}"), QString("\\1") + sep); } } return fns; } QString Filename::format() const { return m_format; } void Filename::setFormat(const QString &format) { m_format = format; m_ast = FilenameCache::Get(format); } void Filename::setEscapeMethod(QString (*escapeMethod)(const QVariant &)) { m_escapeMethod = escapeMethod; } bool Filename::returnError(const QString &msg, QString *error) const { if (error != nullptr) { *error = msg; } return false; } bool Filename::isValid(Profile *profile, QString *error) const { static const QString red = QStringLiteral("<span style=\"color:red\">%1</span>"); static const QString orange = QStringLiteral("<span style=\"color:orange\">%1</span>"); static const QString green = QStringLiteral("<span style=\"color:green\">%1</span>"); // Field must be filled if (m_format.isEmpty()) { return returnError(red.arg(QObject::tr("Filename must not be empty!")), error); } // Can't validate javascript expressions if (m_format.startsWith("javascript:")) { returnError(orange.arg(QObject::tr("Can't validate Javascript expressions.")), error); return true; } // Can't validate invalid grammar if (!m_ast->error().isEmpty()) { returnError(red.arg(QObject::tr("Can't compile your filename: %1").arg(m_ast->error())), error); } const auto &toks = m_ast->tokens(); // Field must end by an extension if (!m_format.endsWith(".%ext%")) { return returnError(orange.arg(QObject::tr("Your filename doesn't ends by an extension, symbolized by %ext%! You may not be able to open saved files.")), error); } // Field must contain an unique token if (!toks.contains("md5") && !toks.contains("id") && !toks.contains("num")) { return returnError(orange.arg(QObject::tr("Your filename is not unique to each image and an image may overwrite a previous one at saving! You should use%md5%, which is unique to each image, to avoid this inconvenience.")), error); } // Looking for unknown tokens QStringList tokens = QStringList() << "tags" << "artist" << "general" << "copyright" << "character" << "model" << "photo_set" << "species" << "meta" << "filename" << "rating" << "md5" << "website" << "websitename" << "ext" << "all" << "id" << "search" << "search_(\\d+)" << "allo" << "date" << "score" << "count" << "width" << "height" << "pool" << "url_file" << "url_page" << "num" << "name" << "position" << "current_date"; if (profile != nullptr) { tokens.append(profile->getAdditionalTokens()); tokens.append(getCustoms(profile->getSettings()).keys()); } static const QRegularExpression rx("%(.+?)%"); auto matches = rx.globalMatch(m_format); while (matches.hasNext()) { auto match = matches.next(); bool found = false; for (const QString &token : tokens) { if (QRegularExpression("%(?:gallery\\.)?" + token + "(?::[^%]+)?%").match(match.captured(0)).hasMatch()) { found = true; } } if (!found) { return returnError(orange.arg(QObject::tr("The %%1% token does not exist and will not be replaced.").arg(match.captured(1))), error); } } // Check for invalid windows characters #ifdef Q_OS_WIN QString txt = QString(m_format).remove(rx); if (txt.contains(':') || txt.contains('*') || txt.contains('?') || (txt.contains('"') && txt.count('<') == 0) || txt.count('<') != txt.count('>') || txt.contains('|')) { return returnError(red.arg(QObject::tr("Your format contains characters forbidden on Windows! Forbidden characters: * ? \" : < > |")), error); } #endif // Check if code is unique if (!toks.contains("md5") && !toks.contains("website") && !toks.contains("websitename") && !toks.contains("count") && toks.contains("id")) { return returnError(green.arg(QObject::tr("You have chosen to use the %id% token. Know that it is only unique for a selected site. The same ID can identify different images depending on the site.")), error); } // All tests passed returnError(green.arg(QObject::tr("Valid filename!")), error); return true; } bool Filename::needTemporaryFile(const QMap<QString, Token> &tokens) const { if (m_format.startsWith("javascript:")) { return false; } const auto &toks = m_ast->tokens(); return ( (toks.contains("md5") && (!tokens.contains("md5") || tokens["md5"].value().toString().isEmpty())) || (toks.contains("filesize") && (!tokens.contains("filesize") || tokens["filesize"].value().toInt() <= 0)) || (toks.contains("width") && (!tokens.contains("width") || tokens["width"].value().toInt() <= 0)) || (toks.contains("height") && (!tokens.contains("height") || tokens["height"].value().toInt() <= 0)) ); } int Filename::needExactTags(Site *site, const QString &api) const { Q_UNUSED(api); QStringList forcedTokens = site != nullptr ? site->getApis().first()->forcedTokens() : QStringList(); if (forcedTokens.contains("*")) { return 2; } return needExactTags(forcedTokens); } int Filename::needExactTags(const QStringList &forcedTokens) const { // Javascript filenames always need tags as we don't know what they might do if (m_format.startsWith("javascript:")) { return 2; } const auto &toks = m_ast->tokens(); // If we need the filename and it is returned from the details page if (toks.contains("filename") && forcedTokens.contains("filename")) { return 2; } // If we need the date and it is returned from the details page if (toks.contains("date") && forcedTokens.contains("date")) { return 2; } // The filename contains one of the special tags QStringList forbidden = QStringList() << "artist" << "copyright" << "character" << "model" << "photo_set" << "species" << "meta" << "general"; for (const QString &token : forbidden) { if (toks.contains(token)) { return 1; } } // Namespaces come from detailed tags if (m_format.contains("includenamespace")) { return 1; } return 0; }
33.432099
426
0.666027
BramboraSK
6d8603c0e924c70003faab836b8b49ff88e64410
4,428
cpp
C++
tuw_multi_robot_ctrl/src/controller_node.cpp
JakubHazik/tuw_multi_robot
9c5c8a2ed87e0bf6f9a573e38b4d5790dfc25aba
[ "BSD-3-Clause" ]
null
null
null
tuw_multi_robot_ctrl/src/controller_node.cpp
JakubHazik/tuw_multi_robot
9c5c8a2ed87e0bf6f9a573e38b4d5790dfc25aba
[ "BSD-3-Clause" ]
null
null
null
tuw_multi_robot_ctrl/src/controller_node.cpp
JakubHazik/tuw_multi_robot
9c5c8a2ed87e0bf6f9a573e38b4d5790dfc25aba
[ "BSD-3-Clause" ]
null
null
null
#include <ros/ros.h> #include <simple_velocity_controller/controller_node.h> #include <tuw_nav_msgs/ControllerState.h> #include <tf/transform_datatypes.h> #define NSEC_2_SECS(A) ((float)A / 1000000000.0) int main(int argc, char** argv) { std::string name("pid_controller"); if (argc >= 2) { name = argv[1]; } ros::init(argc, argv, argv[1]); /// initializes the ros node with default name ros::NodeHandle n; velocity_controller::ControllerNode ctrl(n); return 0; } namespace velocity_controller { ControllerNode::ControllerNode(ros::NodeHandle& n) : Controller(), n_(n), n_param_("~") { max_vel_v_ = 0.8; n_param_.getParam("max_v", max_vel_v_); max_vel_w_ = 1.0; n_param_.getParam("max_w", max_vel_w_); setSpeedParams(max_vel_v_, max_vel_w_); goal_r_ = 0.2; n_param_.getParam("goal_radius", goal_r_); setGoalRadius(goal_r_); Kp_val_ = 5.0; n_param_.getParam("Kp", Kp_val_); Ki_val_ = 0.0; n_param_.getParam("Ki", Ki_val_); Kd_val_ = 1.0; n_param_.getParam("Kd", Kd_val_); setPID(Kp_val_, Ki_val_, Kd_val_); double loop_rate; n_param_.param<double>("loop_rate", loop_rate, 5); pubCmdVel_ = n.advertise<geometry_msgs::Twist>("cmd_vel", 1000); pubState_ = n.advertise<tuw_nav_msgs::ControllerState>("state_trajectory_ctrl", 10); subPose_ = n.subscribe("pose", 1000, &ControllerNode::subPoseCb, this); subPath_ = n.subscribe("path", 1000, &ControllerNode::subPathCb, this); subCtrl_ = n.subscribe("ctrl", 1000, &ControllerNode::subCtrlCb, this); ros::Rate r(loop_rate); while (ros::ok()) { ros::spinOnce(); publishState(); r.sleep(); } } void ControllerNode::subPoseCb(const geometry_msgs::PoseWithCovarianceStampedConstPtr &_pose) { PathPoint pt; pt.x = _pose->pose.pose.position.x; pt.y = _pose->pose.pose.position.y; tf::Quaternion q(_pose->pose.pose.orientation.x, _pose->pose.pose.orientation.y, _pose->pose.pose.orientation.z, _pose->pose.pose.orientation.w); tf::Matrix3x3 m(q); double roll, pitch, yaw; m.getRPY(roll, pitch, yaw); pt.theta = yaw; ros::Time time = ros::Time::now(); ros::Duration d = time - last_update_; float delta_t = d.sec + NSEC_2_SECS(d.nsec); update(pt, delta_t); float v, w; getSpeed(&v, &w); cmd_.linear.x = v; cmd_.angular.z = w; pubCmdVel_.publish(cmd_); } void ControllerNode::publishState() { ctrl_state_.header.stamp = ros::Time::now(); ctrl_state_.progress = getProgress(); if(isActive()) { ctrl_state_.state = ctrl_state_.STATE_DRIVING; } else { ctrl_state_.state = ctrl_state_.STATE_IDLE; } pubState_.publish(ctrl_state_); } void ControllerNode::subPathCb(const nav_msgs::Path_<std::allocator<void>>::ConstPtr& _path) { ctrl_state_.progress_in_relation_to = _path->header.seq; ctrl_state_.header.frame_id = _path->header.frame_id; if (_path->poses.size() == 0) return; // start at nearest point on path to pose // behavior controller resends full paths, therefore // it is important to start from the robots location float nearest_dist = std::numeric_limits<float>::max(); float dist = 0; auto it = _path->poses.begin(); bool changed = true; while (it != _path->poses.end() && changed) { dist = pow(current_pose_.x - it->pose.position.x, 2) + pow(current_pose_.y - it->pose.position.y, 2); if (dist < nearest_dist) { nearest_dist = dist; changed = true; it++; } else { changed = false; } } std::vector<PathPoint> path; for (; it != _path->poses.end(); ++it) { PathPoint pt; tf::Quaternion q(it->pose.orientation.x, it->pose.orientation.y, it->pose.orientation.z, it->pose.orientation.w); tf::Matrix3x3 m(q); double roll, pitch, yaw; m.getRPY(roll, pitch, yaw); pt.x = it->pose.position.x; pt.y = it->pose.position.y; pt.theta = yaw; path.push_back(pt); } setPath(std::make_shared<std::vector<PathPoint>>(path)); } void ControllerNode::subCtrlCb(const std_msgs::String _cmd) { std::string s = _cmd.data; ROS_INFO("Multi Robot Controller: received %s", s.c_str()); if (s.compare("run") == 0) { setState(run); } else if (s.compare("stop") == 0) { setState(stop); } else if (s.compare("step") == 0) { setState(step); } else { setState(run); } } }
23.806452
117
0.649051
JakubHazik
6d8a955cb721b29f4e1ebffe45a677d8a6f0b209
2,493
cpp
C++
Src-zd/thread_show.cpp
SuWeipeng/xm_rc
7f5d9bcfc42dff7e9e72a3e096b195ea1a3076aa
[ "Apache-2.0" ]
2
2020-03-10T03:00:38.000Z
2020-05-04T02:40:10.000Z
Src-zd/thread_show.cpp
SuWeipeng/xm_rc
7f5d9bcfc42dff7e9e72a3e096b195ea1a3076aa
[ "Apache-2.0" ]
null
null
null
Src-zd/thread_show.cpp
SuWeipeng/xm_rc
7f5d9bcfc42dff7e9e72a3e096b195ea1a3076aa
[ "Apache-2.0" ]
3
2020-03-10T03:00:48.000Z
2021-01-26T06:03:49.000Z
#include "rtt_interface.h" #include <string.h> #include <entry.h> #include "AP_Show.h" #include "AP_Buffer.h" extern vel_target vel; extern AP_Show* show; extern AP_Buffer* buffer; extern uint8_t key_value; extern ap_t mav_data; extern uint8_t mode_changed; extern int8_t car_mode; extern "C"{ char global_buf[4][16]; } rt_thread_t show_thread = RT_NULL; extern "C" void show_thread_entry(void* parameter) { char line[3][15]; char head[16]; char mode_page[16]; int8_t page_num = 0; uint8_t page_max = 2; while(1) { // Switch page if(key_value == 2 && page_num != 1){ page_num--; if(page_num < 0) page_num = 0; show->show_now(page_num); key_value = 0; } else if(key_value == 12){ page_num--; if(page_num < 0) page_num = 0; show->show_now(page_num); key_value = 0; } if(key_value == 1){ page_num++; if(page_num > page_max) page_num = page_max; show->show_now(page_num); key_value = 0; } // Show page show->show_page(page_num); // Page 0 sprintf (line[0], "vel_x:%.3f", vel.vel_x); sprintf (line[1], "vel_y:%.3f", vel.vel_y); sprintf (line[2], "rad_z:%.3f", vel.rad_z); for(uint8_t i=0; i<3; i++){ show->page_write(0, i, line[i], "rc output"); } // Page 1 sprintf(head, "%s \r\n", "key monitor"); show->page_write(1, 0, global_buf[0], head); show->page_write(1, 2, global_buf[2], head); if(key_value == 15){ memset(global_buf[2], 0, 16); } // Page 2 static int8_t prev_mode; char mode_name[6]; switch(mav_data.mode){ case 0:{ sprintf (mode_name, "%s", "Manual"); break; } case 1:{ sprintf (mode_name, "%s", "Auto"); break; } case 2:{ sprintf (mode_name, "%s", "ROS"); break; } } sprintf (mode_page, "Mode:%s", mode_name); show->page_write(2, 0, mode_page, "car mode"); if(page_num == 2){ switch(key_value){ case 3:{ car_mode++; if(car_mode > 2) car_mode = 2; break; } case 4:{ car_mode--; if(car_mode < 0) car_mode = 0; break; } default:{ break; } } if(prev_mode != car_mode){ mode_changed = 1; prev_mode = car_mode; } } // update screen rt_enter_critical(); show->update(); rt_exit_critical(); rt_thread_delay(500); } }
21.127119
51
0.549539
SuWeipeng
6d8ba1ab920195d39dd0f7ba8400dfb30608253b
463
cpp
C++
cpp/new_features/cpp17/as_const.cpp
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
2
2019-12-21T00:53:47.000Z
2020-01-01T10:36:30.000Z
cpp/new_features/cpp17/as_const.cpp
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
null
null
null
cpp/new_features/cpp17/as_const.cpp
KaiserLancelot/Cpp-Primer
a4791a6765f0b6c864e8881e6a5328e2a3d68974
[ "MIT" ]
null
null
null
// // Created by kaiser on 2020/4/18. // #include <iostream> #include <string> #include <utility> int main() { // 当基于范围的 for 循环被用于一个具有写时复制语义的(非 // const)对象时, 它可能会通过(隐式)调用非 const 的 begin() // 成员函数触发深层复制 // 如果想要避免这种行为(比如循环实际上不会修改这个对象), 可以使用 // std::as_const // 假设是写时复制的字符串 std::string cow_string{"str"}; // for(auto x : str) { /* ... */ } // 可能会导致深层复制 for (auto c : std::as_const(cow_string)) { std::cout << c; } std::cout << '\n'; }
17.807692
49
0.598272
KaiserLancelot
6d8f3afe3b32c425324b717c059a17c0033960e6
20,363
cpp
C++
lib/slikenet/DependentExtensions/RPC3/RPC3.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
2
2018-04-09T12:54:20.000Z
2018-12-07T20:34:53.000Z
lib/slikenet/DependentExtensions/RPC3/RPC3.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
4
2018-04-10T23:28:47.000Z
2021-05-16T20:35:21.000Z
lib/slikenet/DependentExtensions/RPC3/RPC3.cpp
TRUEPADDii/GothicMultiplayerLauncher
1ae083a62c083fc99bb9b1358a223ae02174af3f
[ "WTFPL" ]
3
2019-02-13T15:10:03.000Z
2021-07-12T19:24:07.000Z
/* * Original work: Copyright (c) 2014, Oculus VR, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * RakNet License.txt file in the licenses directory of this source tree. An additional grant * of patent rights can be found in the RakNet Patents.txt file in the same directory. * * * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt) * * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style * license found in the license.txt file in the root directory of this source tree. */ #include "RPC3.h" #include "slikenet/memoryoverride.h" #include "slikenet/assert.h" #include "slikenet/StringCompressor.h" #include "slikenet/BitStream.h" #include "slikenet/peerinterface.h" #include "slikenet/MessageIdentifiers.h" #include "slikenet/NetworkIDManager.h" #include <stdlib.h> using namespace SLNet; // int RPC3::RemoteRPCFunctionComp( const RPC3::RPCIdentifier &key, const RemoteRPCFunction &data ) // { // return strcmp(key.C_String(), data.identifier.C_String()); // } int SLNet::RPC3::LocalSlotObjectComp( const LocalSlotObject &key, const LocalSlotObject &data ) { if (key.callPriority>data.callPriority) return -1; if (key.callPriority==data.callPriority) { if (key.registrationCount<data.registrationCount) return -1; if (key.registrationCount==data.registrationCount) return 0; return 1; } return 1; } RPC3::RPC3() { currentExecution[0]=0; networkIdManager=0; outgoingTimestamp=0; outgoingPriority=HIGH_PRIORITY; outgoingReliability=RELIABLE_ORDERED; outgoingOrderingChannel=0; outgoingBroadcast=true; incomingTimeStamp=0; nextSlotRegistrationCount=0; } RPC3::~RPC3() { Clear(); } void RPC3::SetNetworkIDManager(NetworkIDManager *idMan) { networkIdManager=idMan; } bool RPC3::UnregisterFunction(const char *uniqueIdentifier) { return false; } bool RPC3::IsFunctionRegistered(const char *uniqueIdentifier) { DataStructures::HashIndex i = GetLocalFunctionIndex(uniqueIdentifier); return i.IsInvalid()==false; } void RPC3::SetTimestamp(SLNet::Time timeStamp) { outgoingTimestamp=timeStamp; } void RPC3::SetSendParams(PacketPriority priority, PacketReliability reliability, char orderingChannel) { outgoingPriority=priority; outgoingReliability=reliability; outgoingOrderingChannel=orderingChannel; } void RPC3::SetRecipientAddress(const SystemAddress &systemAddress, bool broadcast) { outgoingSystemAddress=systemAddress; outgoingBroadcast=broadcast; } void RPC3::SetRecipientObject(NetworkID networkID) { outgoingNetworkID=networkID; } SLNet::Time RPC3::GetLastSenderTimestamp(void) const { return incomingTimeStamp; } SystemAddress RPC3::GetLastSenderAddress(void) const { return incomingSystemAddress; } RakPeerInterface *RPC3::GetRakPeer(void) const { return rakPeerInterface; } const char *RPC3::GetCurrentExecution(void) const { return (const char *) currentExecution; } bool RPC3::SendCallOrSignal(RakString uniqueIdentifier, char parameterCount, SLNet::BitStream *serializedParameters, bool isCall) { SystemAddress systemAddr; // unsigned int outerIndex; // unsigned int innerIndex; if (uniqueIdentifier.IsEmpty()) return false; SLNet::BitStream bs; if (outgoingTimestamp!=0) { bs.Write((MessageID)ID_TIMESTAMP); bs.Write(outgoingTimestamp); } bs.Write((MessageID)ID_RPC_PLUGIN); bs.Write(parameterCount); if (outgoingNetworkID!=UNASSIGNED_NETWORK_ID && isCall) { bs.Write(true); bs.Write(outgoingNetworkID); } else { bs.Write(false); } bs.Write(isCall); // This is so the call SetWriteOffset works bs.AlignWriteToByteBoundary(); BitSize_t writeOffset = bs.GetWriteOffset(); if (outgoingBroadcast) { unsigned systemIndex; for (systemIndex=0; systemIndex < rakPeerInterface->GetMaximumNumberOfPeers(); systemIndex++) { systemAddr=rakPeerInterface->GetSystemAddressFromIndex(systemIndex); if (systemAddr!= SLNet::UNASSIGNED_SYSTEM_ADDRESS && systemAddr!=outgoingSystemAddress) { // if (GetRemoteFunctionIndex(systemAddr, uniqueIdentifier, &outerIndex, &innerIndex, isCall)) // { // // Write a number to identify the function if possible, for faster lookup and less bandwidth // bs.Write(true); // if (isCall) // bs.WriteCompressed(remoteFunctions[outerIndex]->operator [](innerIndex).functionIndex); // else // bs.WriteCompressed(remoteSlots[outerIndex]->operator [](innerIndex).functionIndex); // } // else // { // bs.Write(false); StringCompressor::Instance()->EncodeString(uniqueIdentifier, 512, &bs, 0); // } bs.WriteCompressed(serializedParameters->GetNumberOfBitsUsed()); // serializedParameters->PrintBits(); bs.WriteAlignedBytes((const unsigned char*) serializedParameters->GetData(), serializedParameters->GetNumberOfBytesUsed()); SendUnified(&bs, outgoingPriority, outgoingReliability, outgoingOrderingChannel, systemAddr, false); // Start writing again after ID_AUTO_RPC_CALL bs.SetWriteOffset(writeOffset); } } } else { systemAddr = outgoingSystemAddress; if (systemAddr!= SLNet::UNASSIGNED_SYSTEM_ADDRESS) { // if (GetRemoteFunctionIndex(systemAddr, uniqueIdentifier, &outerIndex, &innerIndex, isCall)) // { // // Write a number to identify the function if possible, for faster lookup and less bandwidth // bs.Write(true); // if (isCall) // bs.WriteCompressed(remoteFunctions[outerIndex]->operator [](innerIndex).functionIndex); // else // bs.WriteCompressed(remoteSlots[outerIndex]->operator [](innerIndex).functionIndex); // } // else // { // bs.Write(false); StringCompressor::Instance()->EncodeString(uniqueIdentifier, 512, &bs, 0); // } bs.WriteCompressed(serializedParameters->GetNumberOfBitsUsed()); bs.WriteAlignedBytes((const unsigned char*) serializedParameters->GetData(), serializedParameters->GetNumberOfBytesUsed()); SendUnified(&bs, outgoingPriority, outgoingReliability, outgoingOrderingChannel, systemAddr, false); } else return false; } return true; } void RPC3::OnAttach(void) { outgoingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; outgoingNetworkID=UNASSIGNED_NETWORK_ID; incomingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; } PluginReceiveResult RPC3::OnReceive(Packet *packet) { SLNet::Time timestamp=0; unsigned char packetIdentifier, packetDataOffset; if ( ( unsigned char ) packet->data[ 0 ] == ID_TIMESTAMP ) { if ( packet->length > sizeof( unsigned char ) + sizeof(SLNet::Time ) ) { packetIdentifier = ( unsigned char ) packet->data[ sizeof( unsigned char ) + sizeof(SLNet::Time ) ]; // Required for proper endian swapping SLNet::BitStream tsBs(packet->data+sizeof(MessageID),packet->length-1,false); tsBs.Read(timestamp); packetDataOffset=sizeof( unsigned char )*2 + sizeof(SLNet::Time ); } else return RR_STOP_PROCESSING_AND_DEALLOCATE; } else { packetIdentifier = ( unsigned char ) packet->data[ 0 ]; packetDataOffset=sizeof( unsigned char ); } switch (packetIdentifier) { case ID_RPC_PLUGIN: incomingTimeStamp=timestamp; incomingSystemAddress=packet->systemAddress; OnRPC3Call(packet->systemAddress, packet->data+packetDataOffset, packet->length-packetDataOffset); return RR_STOP_PROCESSING_AND_DEALLOCATE; // case ID_AUTO_RPC_REMOTE_INDEX: // OnRPCRemoteIndex(packet->systemAddress, packet->data+packetDataOffset, packet->length-packetDataOffset); // return RR_STOP_PROCESSING_AND_DEALLOCATE; } return RR_CONTINUE_PROCESSING; } void RPC3::OnRPC3Call(const SystemAddress &systemAddress, unsigned char *data, unsigned int lengthInBytes) { SLNet::BitStream bs(data,lengthInBytes,false); DataStructures::HashIndex functionIndex; LocalRPCFunction *lrpcf; bool hasParameterCount=false; char parameterCount; NetworkIDObject *networkIdObject; NetworkID networkId; bool hasNetworkId=false; // bool hasFunctionIndex=false; // unsigned int functionIndex; BitSize_t bitsOnStack; char strIdentifier[512]; incomingExtraData.Reset(); bs.Read(parameterCount); bs.Read(hasNetworkId); if (hasNetworkId) { bool readSuccess = bs.Read(networkId); RakAssert(readSuccess); RakAssert(networkId!=UNASSIGNED_NETWORK_ID); if (networkIdManager==0) { // Failed - Tried to call object member, however, networkIDManager system was never registered SendError(systemAddress, RPC_ERROR_NETWORK_ID_MANAGER_UNAVAILABLE, ""); return; } networkIdObject = networkIdManager->GET_OBJECT_FROM_ID<NetworkIDObject*>(networkId); if (networkIdObject==0) { // Failed - Tried to call object member, object does not exist (deleted?) SendError(systemAddress, RPC_ERROR_OBJECT_DOES_NOT_EXIST, ""); return; } } else { networkIdObject=0; } bool isCall; bs.Read(isCall); bs.AlignReadToByteBoundary(); // bs.Read(hasFunctionIndex); // if (hasFunctionIndex) // bs.ReadCompressed(functionIndex); // else StringCompressor::Instance()->DecodeString(strIdentifier,512,&bs,0); bs.ReadCompressed(bitsOnStack); SLNet::BitStream serializedParameters; if (bitsOnStack>0) { serializedParameters.AddBitsAndReallocate(bitsOnStack); // BITS_TO_BYTES is correct, why did I change this? bs.ReadAlignedBytes(serializedParameters.GetData(), BITS_TO_BYTES(bitsOnStack)); serializedParameters.SetWriteOffset(bitsOnStack); } // if (hasFunctionIndex) // { // if ( // (isCall==true && functionIndex>localFunctions.Size()) || // (isCall==false && functionIndex>localSlots.Size()) // ) // { // // Failed - other system specified a totally invalid index // // Possible causes: Bugs, attempts to crash the system, requested function not registered // SendError(systemAddress, RPC_ERROR_FUNCTION_INDEX_OUT_OF_RANGE, ""); // return; // } // } // else { // Find the registered function with this str if (isCall) { // for (functionIndex=0; functionIndex < localFunctions.Size(); functionIndex++) // { // bool isObjectMember = boost::fusion::get<0>(localFunctions[functionIndex].functionPointer); // // boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<0>(localFunctions[functionIndex].functionPointer); // // if (isObjectMember == (networkIdObject!=0) && // strcmp(localFunctions[functionIndex].identifier.C_String(), strIdentifier)==0) // { // // SEND RPC MAPPING // SLNet::BitStream outgoingBitstream; // outgoingBitstream.Write((MessageID)ID_AUTO_RPC_REMOTE_INDEX); // outgoingBitstream.Write(hasNetworkId); // outgoingBitstream.WriteCompressed(functionIndex); // StringCompressor::Instance()->EncodeString(strIdentifier,512,&outgoingBitstream,0); // outgoingBitstream.Write(isCall); // SendUnified(&outgoingBitstream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, systemAddress, false); // break; // } // } functionIndex = localFunctions.GetIndexOf(strIdentifier); if (functionIndex.IsInvalid()) { SendError(systemAddress, RPC_ERROR_FUNCTION_NOT_REGISTERED, strIdentifier); return; } lrpcf = localFunctions.ItemAtIndex(functionIndex); bool isObjectMember = boost::fusion::get<0>(lrpcf->functionPointer); if (isObjectMember==true && networkIdObject==0) { // Failed - Calling C++ function as C function SendError(systemAddress, RPC_ERROR_CALLING_CPP_AS_C, strIdentifier); return; } if (isObjectMember==false && networkIdObject!=0) { // Failed - Calling C function as C++ function SendError(systemAddress, RPC_ERROR_CALLING_C_AS_CPP, strIdentifier); return; } } else { functionIndex = localSlots.GetIndexOf(strIdentifier); if (functionIndex.IsInvalid()) { SendError(systemAddress, RPC_ERROR_FUNCTION_NOT_REGISTERED, strIdentifier); return; } } } if (isCall) { bool isObjectMember = boost::fusion::get<0>(lrpcf->functionPointer); boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<1>(lrpcf->functionPointer); // int arity = boost::fusion::get<2>(localFunctions[functionIndex].functionPointer); // if (isObjectMember) // arity--; // this pointer if (functionPtr==0) { // Failed - Function was previously registered, but isn't registered any longer SendError(systemAddress, RPC_ERROR_FUNCTION_NO_LONGER_REGISTERED, strIdentifier); return; } // Boost doesn't support this for class members // if (arity!=parameterCount) // { // // Failed - The number of parameters that this function has was explicitly specified, and does not match up. // SendError(systemAddress, RPC_ERROR_INCORRECT_NUMBER_OF_PARAMETERS, localFunctions[functionIndex].identifier); // return; // } _RPC3::InvokeArgs functionArgs; functionArgs.bitStream=&serializedParameters; functionArgs.networkIDManager=networkIdManager; functionArgs.caller=this; functionArgs.thisPtr=networkIdObject; // serializedParameters.PrintBits(); _RPC3::InvokeResultCodes res2 = functionPtr(functionArgs); } else { InvokeSignal(functionIndex, &serializedParameters, false); } } void RPC3::InterruptSignal(void) { interruptSignal=true; } void RPC3::InvokeSignal(DataStructures::HashIndex functionIndex, SLNet::BitStream *serializedParameters, bool temporarilySetUSA) { if (functionIndex.IsInvalid()) return; SystemAddress lastIncomingAddress=incomingSystemAddress; if (temporarilySetUSA) incomingSystemAddress= SLNet::UNASSIGNED_SYSTEM_ADDRESS; interruptSignal=false; LocalSlot *localSlot = localSlots.ItemAtIndex(functionIndex); unsigned int i; _RPC3::InvokeArgs functionArgs; functionArgs.bitStream=serializedParameters; functionArgs.networkIDManager=networkIdManager; functionArgs.caller=this; i=0; while (i < localSlot->slotObjects.Size()) { if (localSlot->slotObjects[i].associatedObject!=UNASSIGNED_NETWORK_ID) { functionArgs.thisPtr = networkIdManager->GET_OBJECT_FROM_ID<NetworkIDObject*>(localSlot->slotObjects[i].associatedObject); if (functionArgs.thisPtr==0) { localSlot->slotObjects.RemoveAtIndex(i); continue; } } else functionArgs.thisPtr=0; functionArgs.bitStream->ResetReadPointer(); bool isObjectMember = boost::fusion::get<0>(localSlot->slotObjects[i].functionPointer); boost::function<_RPC3::InvokeResultCodes (_RPC3::InvokeArgs)> functionPtr = boost::fusion::get<1>(localSlot->slotObjects[i].functionPointer); if (functionPtr==0) { if (temporarilySetUSA==false) { // Failed - Function was previously registered, but isn't registered any longer SendError(lastIncomingAddress, RPC_ERROR_FUNCTION_NO_LONGER_REGISTERED, localSlots.KeyAtIndex(functionIndex).C_String()); } return; } _RPC3::InvokeResultCodes res2 = functionPtr(functionArgs); // Not threadsafe if (interruptSignal==true) break; i++; } if (temporarilySetUSA) incomingSystemAddress=lastIncomingAddress; } // void RPC3::OnRPCRemoteIndex(const SystemAddress &systemAddress, unsigned char *data, unsigned int lengthInBytes) // { // // A remote system has given us their internal index for a particular function. // // Store it and use it from now on, to save bandwidth and search time // bool objectExists; // RakString strIdentifier; // unsigned int insertionIndex; // unsigned int remoteIndex; // RemoteRPCFunction newRemoteFunction; // SLNet::BitStream bs(data,lengthInBytes,false); // RPCIdentifier identifier; // bool isObjectMember; // bool isCall; // bs.Read(isObjectMember); // bs.ReadCompressed(remoteIndex); // bs.Read(strIdentifier); // bs.Read(isCall); // // if (strIdentifier.IsEmpty()) // return; // // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList; // if ( // (isCall==true && remoteFunctions.Has(systemAddress)) || // (isCall==false && remoteSlots.Has(systemAddress)) // ) // { // if (isCall==true) // theList = remoteFunctions.Get(systemAddress); // else // theList = remoteSlots.Get(systemAddress); // insertionIndex=theList->GetIndexFromKey(identifier, &objectExists); // if (objectExists==false) // { // newRemoteFunction.functionIndex=remoteIndex; // newRemoteFunction.identifier = strIdentifier; // theList->InsertAtIndex(newRemoteFunction, insertionIndex, _FILE_AND_LINE_ ); // } // } // else // { // theList = SLNet::OP_NEW<DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> >(_FILE_AND_LINE_); // // newRemoteFunction.functionIndex=remoteIndex; // newRemoteFunction.identifier = strIdentifier; // theList->InsertAtEnd(newRemoteFunction, _FILE_AND_LINE_ ); // // if (isCall==true) // remoteFunctions.SetNew(systemAddress,theList); // else // remoteSlots.SetNew(systemAddress,theList); // } // } void RPC3::OnClosedConnection(const SystemAddress &systemAddress, RakNetGUID rakNetGUID, PI2_LostConnectionReason lostConnectionReason ) { // if (remoteFunctions.Has(systemAddress)) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions.Get(systemAddress); // delete theList; // remoteFunctions.Delete(systemAddress); // } // // if (remoteSlots.Has(systemAddress)) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots.Get(systemAddress); // delete theList; // remoteSlots.Delete(systemAddress); // } } void RPC3::OnShutdown(void) { // Not needed, and if the user calls Shutdown inadvertantly, it unregisters his functions // Clear(); } void RPC3::Clear(void) { unsigned j; // for (j=0; j < remoteFunctions.Size(); j++) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions[j]; // SLNet::OP_DELETE(theList,_FILE_AND_LINE_); // } // for (j=0; j < remoteSlots.Size(); j++) // { // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots[j]; // SLNet::OP_DELETE(theList,_FILE_AND_LINE_); // } DataStructures::List<SLNet::RakString> keyList; DataStructures::List<LocalSlot*> outputList; localSlots.GetAsList(outputList,keyList,_FILE_AND_LINE_); for (j=0; j < outputList.Size(); j++) { SLNet::OP_DELETE(outputList[j],_FILE_AND_LINE_); } localSlots.Clear(_FILE_AND_LINE_); DataStructures::List<LocalRPCFunction*> outputList2; localFunctions.GetAsList(outputList2,keyList,_FILE_AND_LINE_); for (j=0; j < outputList2.Size(); j++) { SLNet::OP_DELETE(outputList2[j],_FILE_AND_LINE_); } localFunctions.Clear(_FILE_AND_LINE_); // remoteFunctions.Clear(); // remoteSlots.Clear(); outgoingExtraData.Reset(); incomingExtraData.Reset(); } void RPC3::SendError(SystemAddress target, unsigned char errorCode, const char *functionName) { SLNet::BitStream bs; bs.Write((MessageID)ID_RPC_REMOTE_ERROR); bs.Write(errorCode); bs.WriteAlignedBytes((const unsigned char*) functionName,(const unsigned int) strlen(functionName)+1); SendUnified(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, target, false); } // bool RPC3::GetRemoteFunctionIndex(const SystemAddress &systemAddress, RPC3::RPCIdentifier identifier, unsigned int *outerIndex, unsigned int *innerIndex, bool isCall) // { // bool objectExists=false; // if (isCall) // { // if (remoteFunctions.Has(systemAddress)) // { // *outerIndex = remoteFunctions.GetIndexAtKey(systemAddress); // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteFunctions[*outerIndex]; // *innerIndex = theList->GetIndexFromKey(identifier, &objectExists); // } // } // else // { // if (remoteSlots.Has(systemAddress)) // { // *outerIndex = remoteFunctions.GetIndexAtKey(systemAddress); // DataStructures::OrderedList<RPCIdentifier, RemoteRPCFunction, RPC3::RemoteRPCFunctionComp> *theList = remoteSlots[*outerIndex]; // *innerIndex = theList->GetIndexFromKey(identifier, &objectExists); // } // } // return objectExists; // } DataStructures::HashIndex RPC3::GetLocalSlotIndex(const char *sharedIdentifier) { return localSlots.GetIndexOf(sharedIdentifier); } DataStructures::HashIndex RPC3::GetLocalFunctionIndex(RPC3::RPCIdentifier identifier) { return localFunctions.GetIndexOf(identifier.C_String()); }
31.570543
169
0.742572
TRUEPADDii
6d92b8e7d365c3328b07dd9ad8c945eeb073357b
5,334
hpp
C++
QuantExt/qle/termstructures/yoyoptionletvolatilitysurface.hpp
PiotrSiejda/Engine
8360b5de32408f2a37da5ac3ca7b4e913bf67e9f
[ "BSD-3-Clause" ]
null
null
null
QuantExt/qle/termstructures/yoyoptionletvolatilitysurface.hpp
PiotrSiejda/Engine
8360b5de32408f2a37da5ac3ca7b4e913bf67e9f
[ "BSD-3-Clause" ]
null
null
null
QuantExt/qle/termstructures/yoyoptionletvolatilitysurface.hpp
PiotrSiejda/Engine
8360b5de32408f2a37da5ac3ca7b4e913bf67e9f
[ "BSD-3-Clause" ]
1
2022-02-07T02:04:10.000Z
2022-02-07T02:04:10.000Z
/* Copyright (C) 2018 Quaternion Risk Management Ltd All rights reserved. This file is part of ORE, a free-software/open-source library for transparent pricing and risk analysis - http://opensourcerisk.org ORE is free software: you can redistribute it and/or modify it under the terms of the Modified BSD License. You should have received a copy of the license along with this program. The license is also available online at <http://opensourcerisk.org> This program is distributed on the basis that it will form a useful contribution to risk analytics and model standardisation, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file qle/termstructures/yoyoptionletvolatilitysurface.hpp \brief YoY Inflation volatility surface - extends QuantLib YoYOptionletVolatilitySurface to include a volatility type and displacement \ingroup termstructures */ #ifndef quantext_yoy_optionlet_volatility_surface_hpp #define quantext_yoy_optionlet_volatility_surface_hpp #include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp> #include <ql/termstructures/volatility/volatilitytype.hpp> namespace QuantExt { using namespace QuantLib; //! YoY Inflation volatility surface /*! \ingroup termstructures */ class YoYOptionletVolatilitySurface : public QuantLib::TermStructure { public: //! \name Constructor //! calculate the reference date based on the global evaluation date YoYOptionletVolatilitySurface(boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> referenceVolSurface, VolatilityType volType = ShiftedLognormal, Real displacement = 0.0) : TermStructure(), referenceVolSurface_(referenceVolSurface), volType_(volType), displacement_(displacement) { referenceVolSurface->enableExtrapolation(); } Volatility volatility(const Date& maturityDate, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; Volatility volatility(const Period& optionTenor, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Volatility totalVariance(const Date& exerciseDate, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Volatility totalVariance(const Period& optionTenor, Rate strike, const Period& obsLag = Period(-1, Days), bool extrapolate = false) const; virtual Period observationLag() const { return referenceVolSurface_->observationLag(); } virtual Frequency frequency() const { return referenceVolSurface_->frequency(); } virtual bool indexIsInterpolated() const { return referenceVolSurface_->indexIsInterpolated(); } virtual Date baseDate() const { return referenceVolSurface_->baseDate(); } virtual Time timeFromBase(const Date& date, const Period& obsLag = Period(-1, Days)) const { return referenceVolSurface_->timeFromBase(date, obsLag); } virtual Date maxDate() const { return referenceVolSurface_->maxDate(); } virtual Real minStrike() const { return referenceVolSurface_->minStrike(); } virtual Real maxStrike() const { return referenceVolSurface_->maxStrike(); } virtual VolatilityType volatilityType() const; virtual Real displacement() const; virtual Volatility baseLevel() const { return referenceVolSurface_->baseLevel(); } boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> yoyVolSurface() const { return referenceVolSurface_; } protected: boost::shared_ptr<QuantLib::YoYOptionletVolatilitySurface> referenceVolSurface_; VolatilityType volType_; Real displacement_; Rate minStrike_, maxStrike_; }; inline Volatility YoYOptionletVolatilitySurface::volatility(const Date& maturityDate, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->volatility(maturityDate, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::volatility(const Period& optionTenor, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->volatility(optionTenor, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::totalVariance(const Date& exerciseDate, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->totalVariance(exerciseDate, strike, obsLag, extrapolate); } inline Volatility YoYOptionletVolatilitySurface::totalVariance(const Period& optionTenor, Rate strike, const Period& obsLag, bool extrapolate) const { return referenceVolSurface_->totalVariance(optionTenor, strike, obsLag, extrapolate); } inline VolatilityType YoYOptionletVolatilitySurface::volatilityType() const { return volType_; } inline Real YoYOptionletVolatilitySurface::displacement() const { return displacement_; } } // namespace QuantExt #endif
49.850467
120
0.726847
PiotrSiejda
6d964653d50aa71e89be517e4e3dc907397f332e
98
hpp
C++
include/easy2d/lib/string.hpp
snatvb/easy2d
0d82f4fd267e91605389e48df9c2d5b60887314f
[ "MIT" ]
null
null
null
include/easy2d/lib/string.hpp
snatvb/easy2d
0d82f4fd267e91605389e48df9c2d5b60887314f
[ "MIT" ]
null
null
null
include/easy2d/lib/string.hpp
snatvb/easy2d
0d82f4fd267e91605389e48df9c2d5b60887314f
[ "MIT" ]
null
null
null
#pragma once #include <string> namespace easy2d { using string = std::string; } // -- easy2d
12.25
31
0.653061
snatvb
6d9b2b89a80790389f99519241b8db026314361f
1,517
cpp
C++
tests/regressions/execution_tree/empty_hstack_509.cpp
diehlpk/phylanx
7eba54f0f22dc66d18addac0b24f006380d0f798
[ "BSL-1.0" ]
null
null
null
tests/regressions/execution_tree/empty_hstack_509.cpp
diehlpk/phylanx
7eba54f0f22dc66d18addac0b24f006380d0f798
[ "BSL-1.0" ]
null
null
null
tests/regressions/execution_tree/empty_hstack_509.cpp
diehlpk/phylanx
7eba54f0f22dc66d18addac0b24f006380d0f798
[ "BSL-1.0" ]
null
null
null
// Copyright (c) 2018 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // Fixing #509: Empty list defined inside Phylanx function has an issue #include <phylanx/phylanx.hpp> #include <hpx/hpx_main.hpp> #include <hpx/include/iostreams.hpp> #include <hpx/util/lightweight_test.hpp> #include <string> #include <sstream> std::string const hstack = "block(hstack())"; std::string const vstack = "block(vstack())"; int main(int argc, char* argv[]) { auto arg = phylanx::ir::node_data<double>{41.0}; phylanx::execution_tree::compiler::function_list snippets; auto const& hstack_f_code = phylanx::execution_tree::compile(hstack, snippets); auto hstack_f = hstack_f_code.run(); auto hstack_data = phylanx::execution_tree::extract_numeric_value(hstack_f(arg, arg)); HPX_TEST(hstack_data.num_dimensions() == 1); HPX_TEST(hstack_data.dimension(0) == 0); HPX_TEST(hstack_data.size() == 0); auto const& vstack_f_code = phylanx::execution_tree::compile(vstack, snippets); auto vstack_f = vstack_f_code.run(); auto vstack_data = phylanx::execution_tree::extract_numeric_value(vstack_f(arg, arg)); HPX_TEST(vstack_data.num_dimensions() == 2); HPX_TEST(vstack_data.dimension(0) == 0); HPX_TEST(vstack_data.dimension(1) == 1); HPX_TEST(vstack_data.size() == 0); return hpx::util::report_errors(); }
30.34
81
0.699407
diehlpk
6d9fa2b3f7d0798e61cb5b7d0b2cb7b61be8c731
4,803
cpp
C++
src/3rdparty/torrent-rasterbar/src/resolve_links.cpp
adem4ik/LIII
6aed4f91641c63b0e3d8d121769b9ecbb832602f
[ "MIT" ]
664
2017-08-14T22:25:24.000Z
2022-03-29T13:54:39.000Z
src/3rdparty/torrent-rasterbar/src/resolve_links.cpp
adem4ik/LIII
6aed4f91641c63b0e3d8d121769b9ecbb832602f
[ "MIT" ]
21
2018-11-05T22:03:20.000Z
2022-03-25T15:04:59.000Z
src/3rdparty/torrent-rasterbar/src/resolve_links.cpp
adem4ik/LIII
6aed4f91641c63b0e3d8d121769b9ecbb832602f
[ "MIT" ]
65
2019-07-23T11:56:01.000Z
2022-03-16T06:17:37.000Z
/* Copyright (c) 2014-2016, Arvid Norberg All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/resolve_links.hpp" #include "libtorrent/torrent_info.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp" #include <boost/shared_ptr.hpp> #include "libtorrent/aux_/disable_warnings_pop.hpp" namespace libtorrent { #ifndef TORRENT_DISABLE_MUTABLE_TORRENTS resolve_links::resolve_links(const boost::shared_ptr<torrent_info>& ti) : m_torrent_file(ti) { TORRENT_ASSERT(ti); int piece_size = ti->piece_length(); file_storage const& fs = ti->files(); m_file_sizes.reserve(fs.num_files()); for (int i = 0; i < fs.num_files(); ++i) { // don't match pad-files, and don't match files that aren't aligned to // ieces. Files are matched by comparing piece hashes, so pieces must // be aligned and the same size if (fs.pad_file_at(i)) continue; if ((fs.file_offset(i) % piece_size) != 0) continue; m_file_sizes.insert(std::make_pair(fs.file_size(i), i)); } m_links.resize(m_torrent_file->num_files()); } void resolve_links::match(boost::shared_ptr<const torrent_info> const& ti , std::string const& save_path) { if (!ti) return; if (!ti->is_valid()) return; // only torrents with the same if (ti->piece_length() != m_torrent_file->piece_length()) return; int piece_size = ti->piece_length(); file_storage const& fs = ti->files(); m_file_sizes.reserve(fs.num_files()); for (int i = 0; i < fs.num_files(); ++i) { // for every file in the other torrent, see if we have one that match // it in m_torrent_file // if the file base is not aligned to pieces, we're not going to match // it anyway (we only compare piece hashes) if ((fs.file_offset(i) % piece_size) != 0) continue; if (fs.pad_file_at(i)) continue; boost::int64_t file_size = fs.file_size(i); typedef boost::unordered_multimap<boost::int64_t, int>::iterator iterator; typedef std::pair<iterator, iterator> range_iterator; range_iterator range = m_file_sizes.equal_range(file_size); for (iterator iter = range.first; iter != range.second; ++iter) { TORRENT_ASSERT(iter->second < m_torrent_file->files().num_files()); TORRENT_ASSERT(iter->second >= 0); // if we already have found a duplicate for this file, no need // to keep looking if (m_links[iter->second].ti) continue; // files are aligned and have the same size, now start comparing // piece hashes, to see if the files are identical // the pieces of the incoming file int their_piece = fs.map_file(i, 0, 0).piece; // the pieces of "this" file (from m_torrent_file) int our_piece = m_torrent_file->files().map_file( iter->second, 0, 0).piece; int num_pieces = (file_size + piece_size - 1) / piece_size; bool match = true; for (int p = 0; p < num_pieces; ++p, ++their_piece, ++our_piece) { if (m_torrent_file->hash_for_piece(our_piece) != ti->hash_for_piece(their_piece)) { match = false; break; } } if (!match) continue; m_links[iter->second].ti = ti; m_links[iter->second].save_path = save_path; m_links[iter->second].file_idx = i; // since we have a duplicate for this file, we may as well remove // it from the file-size map, so we won't find it again. m_file_sizes.erase(iter); break; } } } #endif // TORRENT_DISABLE_MUTABLE_TORRENTS } // namespace libtorrent
33.124138
78
0.725588
adem4ik
6da207c00724d0fa0ea127d3db46c30b9e66c8ba
16,133
hpp
C++
sph_yamauchi/run/vector_x86.hpp
yamauchi1132/Research_Codes
c9e104f8592277cb4aa5c479b014c78c702a0939
[ "FSFAP" ]
null
null
null
sph_yamauchi/run/vector_x86.hpp
yamauchi1132/Research_Codes
c9e104f8592277cb4aa5c479b014c78c702a0939
[ "FSFAP" ]
null
null
null
sph_yamauchi/run/vector_x86.hpp
yamauchi1132/Research_Codes
c9e104f8592277cb4aa5c479b014c78c702a0939
[ "FSFAP" ]
null
null
null
#pragma once #include <immintrin.h> struct v4sf; struct v8sf; struct v2df; struct v4df; struct v4sf { typedef float _v4sf __attribute__((vector_size(16))) __attribute__((aligned(16))); _v4sf val; static int getVectorLength() { return 4; } v4sf(const v4sf & rhs) : val(rhs.val) {} v4sf operator = (const v4sf rhs) { val = rhs.val; return (*this); } v4sf() : val(_mm_setzero_ps()) {} v4sf(const float x) : val(_mm_set_ps(x, x, x, x)) {} v4sf(const float x, const float y, const float z, const float w) : val(_mm_set_ps(w, z, y, x)) {} v4sf(const _v4sf _val) : val(_val) {} operator _v4sf() {return val;} v4sf operator + (const v4sf rhs) const { return v4sf(val + rhs.val); } v4sf operator - (const v4sf rhs) const { return v4sf(val - rhs.val); } v4sf operator * (const v4sf rhs) const { return v4sf(val * rhs.val); } v4sf operator / (const v4sf rhs) const { return v4sf(_mm_div_ps(val, rhs.val)); } static v4sf madd(const v4sf c, const v4sf a, const v4sf b) { return v4sf(_mm_fmadd_ps(a.val, b.val, c.val)); } static v4sf nmadd(const v4sf c, const v4sf a, const v4sf b) { return v4sf(_mm_fnmadd_ps(a.val, b.val, c.val)); } v4sf operator += (const v4sf rhs) { val = val + rhs.val; return (*this); } v4sf operator -= (const v4sf rhs) { val = val - rhs.val; return (*this); } v4sf operator *= (const v4sf rhs) { val = val * rhs.val; return (*this); } v4sf operator /= (const v4sf rhs) { val = _mm_div_ps(val, rhs.val); return (*this); } v4df cvtps2pd(); static v4sf rcp_0th(const v4sf rhs) { return _mm_rcp_ps(rhs.val); } static v4sf rcp_1st(const v4sf rhs) { v4sf x0 = _mm_rcp_ps(rhs.val); v4sf h = v4sf(1.) - rhs * x0; return x0 + h * x0; } static v4sf sqrt(const v4sf rhs) { return v4sf(_mm_sqrt_ps(rhs.val)); } static v4sf rsqrt_0th(const v4sf rhs) { return v4sf(_mm_rsqrt_ps(rhs.val)); } static v4sf rsqrt_1st(const v4sf rhs) { v4sf x0 = v4sf(_mm_rsqrt_ps(rhs.val)); v4sf h = v4sf(1.) - rhs * x0 * x0; return x0 + v4sf(0.5) * h * x0; } static v4sf rsqrt_1st_phantom(const v4sf rhs) { v4sf x0 = v4sf(_mm_rsqrt_ps(rhs.val)); return v4sf(x0 * (rhs * x0 * x0 - v4sf(3.))); } void store(float *p) const { _mm_store_ps(p, val); } void load(float const *p) { val = _mm_load_ps(p); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n") const { int vl = getVectorLength(); float a[vl]; store(a); fprintf(fp, fmt, a[0], a[1], a[2], a[3]); } }; struct v8sf { typedef float _v8sf __attribute__((vector_size(32))) __attribute__((aligned(32))); _v8sf val; static int getVectorLength() { return 8; } v8sf(const v8sf & rhs) : val(rhs.val) {} v8sf operator = (const v8sf rhs) { val = rhs.val; return (*this); } v8sf() : val(_mm256_setzero_ps()) {} v8sf(const float x) : val(_mm256_set_ps(x, x, x, x, x, x, x, x)) {} v8sf(const float x0, const float y0, const float z0, const float w0, const float x1, const float y1, const float z1, const float w1) : val(_mm256_set_ps(w1, z1, y1, x1, w0, z0, y0, x0)) {} v8sf(const _v8sf _val) : val(_val) {} operator _v8sf() {return val;} v8sf(const v4sf rhs) { float buf[8]; rhs.store(&buf[0]); rhs.store(&buf[4]); load(buf); } v8sf(const v4sf x0, const v4sf x1) { float buf[8]; x0.store(&buf[0]); x1.store(&buf[4]); load(buf); } v8sf operator + (const v8sf rhs) const { //return v8sf(_mm256_add_ps(val, rhs.val)); return val + rhs.val; } v8sf operator - (const v8sf rhs) const { //return v8sf(_mm256_sub_ps(val, rhs.val)); return val - rhs.val; } v8sf operator * (const v8sf rhs) const { //return v8sf(_mm256_mul_ps(val, rhs.val)); return val * rhs.val; } v8sf operator / (const v8sf rhs) const { return v8sf(_mm256_div_ps(val, rhs.val)); } static v8sf madd(const v8sf c, const v8sf a, const v8sf b) { return v8sf(_mm256_fmadd_ps(a.val, b.val, c.val)); } static v8sf nmadd(const v8sf c, const v8sf a, const v8sf b) { return v8sf(_mm256_fnmadd_ps(a.val, b.val, c.val)); } static v8sf max(const v8sf a, const v8sf b) { return v8sf(_mm256_max_ps(a.val, b.val)); } static v8sf min(const v8sf a, const v8sf b) { return v8sf(_mm256_min_ps(a.val, b.val)); } v8sf operator += (const v8sf rhs) { //val = _mm256_add_ps(val, rhs.val); val = val + rhs.val; return (*this); } v8sf operator -= (const v8sf rhs) { //val = _mm256_sub_ps(val, rhs.val); val = val - rhs.val; return (*this); } v8sf operator *= (const v8sf rhs) { //val = _mm256_mul_ps(val, rhs.val); val = val * rhs.val; return (*this); } v8sf operator /= (const v8sf rhs) { val = _mm256_div_ps(val, rhs.val); return (*this); } v8sf operator & (const v8sf rhs) { return v8sf(_mm256_and_ps(val, rhs.val)); } v8sf operator != (const v8sf rhs) { return v8sf(_mm256_cmp_ps(val, rhs.val, _CMP_NEQ_UQ)); } v8sf operator < (const v8sf rhs) { return v8sf(_mm256_cmp_ps(val, rhs.val, _CMP_LT_OS)); } static v8sf rcp_0th(const v8sf rhs) { return _mm256_rcp_ps(rhs.val); } static v8sf rcp_1st(const v8sf rhs) { v8sf x0 = _mm256_rcp_ps(rhs.val); v8sf h = v8sf(1.) - rhs * x0; return x0 + h * x0; } static v8sf sqrt(const v8sf rhs) { return v8sf(_mm256_sqrt_ps(rhs.val)); } static v8sf rsqrt_0th(const v8sf rhs) { return v8sf(_mm256_rsqrt_ps(rhs.val)); } static v8sf rsqrt_1st(const v8sf rhs) { v8sf x0 = v8sf(_mm256_rsqrt_ps(rhs.val)); v8sf h = v8sf(1.) - rhs * x0 * x0; return x0 + v8sf(0.5) * h * x0; } static v8sf rsqrt_1st_phantom(const v8sf rhs) { v8sf x0 = v8sf(_mm256_rsqrt_ps(rhs.val)); return v8sf(x0 * (rhs * x0 * x0 - v8sf(3.))); } static v8sf hadd(v8sf x0, v8sf x1) { return _mm256_hadd_ps(x0, x1); } void store(float *p) const { _mm256_store_ps(p, val); } void load(float const *p) { val = _mm256_load_ps(p); } void cvtpd2ps(v4df & x0, v4df & x1); void extractf128(v4sf & x0, v4sf & x1) { x0 = _mm256_extractf128_ps(val, 0); x1 = _mm256_extractf128_ps(val, 1); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n%+e %+e %+e %+e\n\n") const { int vl = getVectorLength(); float a[vl]; store(a); fprintf(fp, fmt, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]); } static v8sf shuffle0(v8sf rhs) { return _mm256_permute_ps(rhs, 0x00); } static v8sf shuffle1(v8sf rhs) { return _mm256_permute_ps(rhs, 0x55); } static v8sf shuffle2(v8sf rhs) { return _mm256_permute_ps(rhs, 0xaa); } static v8sf shuffle3(v8sf rhs) { return _mm256_permute_ps(rhs, 0xff); } static v4sf reduce(const v8sf rhs) { int nv = getVectorLength(); float buf[nv]; rhs.store(buf); v4sf x0(buf[0], buf[1], buf[2], buf[3]); v4sf x1(buf[4], buf[5], buf[6], buf[7]); return v4sf(x0 + x1); } }; struct v2df { typedef double _v2df __attribute__((vector_size(16))) __attribute__((aligned(16))); _v2df val; static int getVectorLength() { return 2; } v2df(const v2df & rhs) : val(rhs.val) {} v2df operator = (const v2df rhs) { val = rhs.val; return (*this); } v2df() : val(_mm_setzero_pd()) {} v2df(const double x) : val(_mm_set_pd(x, x)) {} v2df(const double x, const double y) : val(_mm_set_pd(y, x)) {} v2df(const _v2df _val) : val(_val) {} operator _v2df() {return val;} v2df operator + (const v2df rhs) const { //return v2df(_mm_add_pd(val, rhs.val)); return val + rhs.val; } v2df operator - (const v2df rhs) const { //return v2df(_mm_sub_pd(val, rhs.val)); return val - rhs.val; } v2df operator * (const v2df rhs) const { //return v2df(_mm_mul_pd(val, rhs.val)); return val * rhs.val; } v2df operator / (const v2df rhs) const { return v2df(_mm_div_pd(val, rhs.val)); } static v2df madd(const v2df c, const v2df a, const v2df b) { return v2df(_mm_fmadd_pd(a.val, b.val, c.val)); } static v2df nmadd(const v2df c, const v2df a, const v2df b) { return v2df(_mm_fnmadd_pd(a.val, b.val, c.val)); } static v2df max(const v2df a, const v2df b) { return v2df(_mm_max_pd(a.val, b.val)); } static v2df min(const v2df a, const v2df b) { return v2df(_mm_min_pd(a.val, b.val)); } v2df operator += (const v2df rhs) { //val = _mm_add_pd(val, rhs.val); val = val + rhs.val; return (*this); } v2df operator -= (const v2df rhs) { //val = _mm_sub_pd(val, rhs.val); val = val - rhs.val; return (*this); } v2df operator *= (const v2df rhs) { //val = _mm_mul_pd(val, rhs.val); val = val * rhs.val; return (*this); } v2df operator /= (const v2df rhs) { val = _mm_div_pd(val, rhs.val); return (*this); } v2df operator & (const v2df rhs) { return v2df(_mm_and_pd(val, rhs.val)); } v2df operator != (const v2df rhs) { return v2df(_mm_cmp_pd(val, rhs.val, _CMP_NEQ_UQ)); } v2df operator < (const v2df rhs) { return v2df(_mm_cmp_pd(val, rhs.val, _CMP_LT_OS)); } static v2df sqrt(const v2df rhs) { return v2df(_mm_sqrt_pd(rhs.val)); } static v2df hadd(v2df x0, v2df x1) { return _mm_hadd_pd(x0, x1); } void store(double *p) const { _mm_store_pd(p, val); } void storel(double *p) const { _mm_storel_pd(p, val); } void storeh(double *p) const { _mm_storeh_pd(p, val); } void load(double const *p) { val = _mm_load_pd(p); } v4sf cvtpd2ps() { return _mm_cvtpd_ps(val); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e\n") const { int vl = getVectorLength(); double a[vl]; _mm_store_pd(a, val); fprintf(fp, fmt, a[0], a[1]); } }; struct v4df { typedef double _v4df __attribute__((vector_size(32))) __attribute__((aligned(32))); _v4df val; static int getVectorLength() { return 4; } v4df(const v4df & rhs) : val(rhs.val) {} v4df operator = (const v4df rhs) { val = rhs.val; return (*this); } v4df() : val(_mm256_setzero_pd()) {} v4df(const double x) : val(_mm256_set_pd(x, x, x, x)) {} v4df(const double x, const double y, const double z, const double w) : val(_mm256_set_pd(w, z, y, x)) {} v4df(const _v4df _val) : val(_val) {} operator _v4df() {return val;} //~v4df() {} v4df operator + (const v4df rhs) const { //return v4df(_mm256_add_pd(val, rhs.val)); return val + rhs.val; } v4df operator - (const v4df rhs) const { //return v4df(_mm256_sub_pd(val, rhs.val)); return val - rhs.val; } v4df operator * (const v4df rhs) const { //return v4df(_mm256_mul_pd(val, rhs.val)); return val * rhs.val; } v4df operator / (const v4df rhs) const { return v4df(_mm256_div_pd(val, rhs.val)); } static v4df madd(const v4df c, const v4df a, const v4df b) { return v4df(_mm256_fmadd_pd(a.val, b.val, c.val)); } static v4df nmadd(const v4df c, const v4df a, const v4df b) { return v4df(_mm256_fnmadd_pd(a.val, b.val, c.val)); } static v4df max(const v4df a, const v4df b) { return v4df(_mm256_max_pd(a.val, b.val)); } static v4df min(const v4df a, const v4df b) { return v4df(_mm256_min_pd(a.val, b.val)); } v4df operator += (const v4df rhs) { //val = _mm256_add_pd(val, rhs.val); val = val + rhs.val; return (*this); } v4df operator -= (const v4df rhs) { //val = _mm256_sub_pd(val, rhs.val); val = val - rhs.val; return (*this); } v4df operator *= (const v4df rhs) { //val = _mm256_mul_pd(val, rhs.val); val = val * rhs.val; return (*this); } v4df operator /= (const v4df rhs) { val = _mm256_div_pd(val, rhs.val); return (*this); } v4df operator & (const v4df rhs) { return v4df(_mm256_and_pd(val, rhs.val)); } v4df operator != (const v4df rhs) { return v4df(_mm256_cmp_pd(val, rhs.val, _CMP_NEQ_UQ)); } v4df operator < (const v4df rhs) { return v4df(_mm256_cmp_pd(val, rhs.val, _CMP_LT_OS)); } void store(double *p) const { _mm256_store_pd(p, val); } void load(double const *p) { val = _mm256_load_pd(p); } v4sf cvtpd2ps() { return _mm256_cvtpd_ps(val); } void extractf128(v2df & x0, v2df & x1) { x0 = _mm256_extractf128_pd(val, 0); x1 = _mm256_extractf128_pd(val, 1); } static v4df rcp_0th(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); return x0; } static v4df rcp_1st(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0; return x0 + h * x0; } static v4df rcp_4th(v4df rhs) { v4df x0 = (v4sf::rcp_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0; return (v4df(1.) + h) * (v4df(1.) + h * h) * x0; } static v4df sqrt(const v4df rhs) { return v4df(_mm256_sqrt_pd(rhs.val)); } static v4df rsqrt_0th(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); return x0; } static v4df rsqrt_1st(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + v4df(0.5) * h * x0; } static v4df rsqrt_2nd(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + v4df(0.375) * h) * h * x0; } static v4df rsqrt_3rd(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + (v4df(0.375) + v4df(0.3125) * h) * h) * h * x0; } static v4df rsqrt_4th(v4df rhs) { v4df x0 = (v4sf::rsqrt_0th(rhs.cvtpd2ps())).cvtps2pd(); v4df h = v4df(1.) - rhs * x0 * x0; return x0 + (v4df(0.5) + (v4df(0.375) + (v4df(0.3125) + v4df(0.2734375) * h) * h) * h) * h * x0; } static v4df rsqrt_1st_phantom(v4df rhs) { v4sf x1 = v4sf::rsqrt_1st_phantom(rhs.cvtpd2ps()); return x1.cvtps2pd(); } static v4df fabs(v4df rhs) { v4df signmask(-0.0); return _mm256_andnot_pd(signmask, rhs); } static v4df hadd(v4df x0, v4df x1) { return _mm256_hadd_pd(x0, x1); } void print(FILE * fp = stdout, const char * fmt = "%+e %+e %+e %+e\n") const { int vl = getVectorLength(); double a[vl]; _mm256_store_pd(a, val); fprintf(fp, fmt, a[0], a[1], a[2], a[3]); } }; void v8sf::cvtpd2ps(v4df & x0, v4df & x1) { x0 = _mm256_cvtps_pd(_mm256_extractf128_ps(val, 0)); x1 = _mm256_cvtps_pd(_mm256_extractf128_ps(val, 1)); } v4df v4sf::cvtps2pd() { return _mm256_cvtps_pd(val); }
28.453263
98
0.551478
yamauchi1132
6da229867c3a2cade69524ae6e8f88b642c7c02e
9,611
hpp
C++
tmrcheck.hpp
timoteogb/finn-hlslib
6efd5dee886ba7cc542ab69ae3c8b09d4a1ed1af
[ "BSD-3-Clause" ]
112
2019-09-23T12:23:26.000Z
2022-03-09T16:36:07.000Z
tmrcheck.hpp
timoteogb/finn-hlslib
6efd5dee886ba7cc542ab69ae3c8b09d4a1ed1af
[ "BSD-3-Clause" ]
26
2019-11-27T17:51:06.000Z
2022-02-04T21:06:59.000Z
tmrcheck.hpp
timoteogb/finn-hlslib
6efd5dee886ba7cc542ab69ae3c8b09d4a1ed1af
[ "BSD-3-Clause" ]
50
2019-10-08T20:35:41.000Z
2022-03-22T17:20:00.000Z
/****************************************************************************** * Copyright (c) 2021, Xilinx, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the copyright holder nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION). HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *******************************************************************************/ /****************************************************************************** * * Authors: Timoteo Garcia Bertoa <timoteog@xilinx.com> * * \file tmrcheck.hpp * * Library of templated HLS functions for BNN deployment. * This file performs error checks to triplicated channels of an OFM * *****************************************************************************/ #ifndef TMR_HPP #define TMR_HPP #include "hls_stream.h" /** * \brief Smart TMR block * * The function receives an OFM from the MVTU, with triplicated channels. It outputs a single channel for each triplication, * being this channel one which contains valid data. A flag is also available to watch the character of the error detected, * either all channels in a triplication are different, or just one. * * \tparam InW Input data width, activation precision * \tparam OFMChannels Number of Output Feature Map channels, including triplications * \tparam NUM_RED Number of redundancies (or triplicated channels) * \tparam REDF Redundancy factor (3 to triplicate) * \tparam OFMDim Width and Height of the Output Feature Map (assumed square) * \tparam MAX_CH_WIDTH Value to determine the precision of channel indexes * * \param in Input stream * \param out Output stream * \param errortype Flag to inform redundancy check results. 0 if no faults, LSB set if one PE is faulty, MSB set if all differ * \param channel_mask Value with binary channel masks (1 if channel is triplicated, 0 otherwise) * \param red_ch_index Array of redundant triplets' indexes. Each position stores the first triplicated channel index of a triplet */ template<unsigned int InW, unsigned int OFMChannels, unsigned int NUM_RED, unsigned int REDF, unsigned int OFMDim, unsigned int MAX_CH_WIDTH> void TMRCheck(hls::stream<ap_uint<InW*OFMChannels>> &in, hls::stream<ap_uint<InW*(OFMChannels-NUM_RED*(REDF-1))>> &out, ap_uint<2> &errortype, ap_uint<OFMChannels> channel_mask, ap_uint<MAX_CH_WIDTH> red_ch_index[NUM_RED]) { #pragma HLS ARRAY_PARTITION variable=red_ch_index complete dim=0 ap_uint<InW*OFMChannels> input; // Number of channels without triplications constexpr unsigned int OFMChannelsTMR = (OFMChannels-NUM_RED*(REDF-1)); errortype = 0; // CheckLoop: iterates over all OFM positions for(unsigned int pos = 0; pos < (OFMDim * OFMDim); pos++){ #pragma HLS pipeline II=1 // Read input stream input = in.read(); ap_uint<InW*NUM_RED> tmr_out = {0}; ap_uint<InW*OFMChannelsTMR> out_aux = {0}; ap_uint<2> numerrors[NUM_RED]; #pragma HLS ARRAY_PARTITION variable=numerrors complete dim=0 // Check triplicated channel indexes and store the corresponding data to perform TMR check for(unsigned int i = 0; i < NUM_RED; i++){ #pragma HLS UNROLL numerrors[i] = 0; // TMR CHECK: start // Store index of triplicated channel unsigned int idx = red_ch_index[i]; // CompareLoop: performs comparisons between PE0, PE1, PE2 for(unsigned int y = 0; y < REDF; y++){ for(unsigned int x = y+1; x < REDF; x++){ if( (input((idx+y+1)*InW-1, (idx+y)*InW)) == (input((idx+x+1)*InW-1, (idx+x)*InW)) ){ tmr_out((i+1)*InW-1, i*InW) = input((idx+x+1)*InW-1, (idx+x)*InW); } else { numerrors[i]++; if(numerrors[i] == REDF){ errortype |= (ap_uint<2>)0b10; } else { errortype |= (ap_uint<2>)0b1; } tmr_out((i+1)*InW-1, i*InW) = input((idx+1)*InW-1, idx*InW); } } } // end CompareLoop } // end Check triplicated channel indexes ap_uint<OFMChannels> unitL = 1; ap_uint<1> compute[OFMChannels]; #pragma HLS ARRAY_PARTITION variable=compute complete dim=0 // ChannelLoop: iterates over all OFM channels (including triplications), and outputs either: TMR check output/input/nothing for(unsigned int k = 0; k < OFMChannels; k++){ #pragma HLS UNROLL compute[k] = 0; // Check if current channel is any of the FIRST triplicated for(unsigned int i = 0; i < NUM_RED; i++){ // Store index of triplicated channel unsigned int idx = red_ch_index[i]; if(k == idx){ compute[k] = 1; } } // If it is one of the first triplicated, forward the TMR check output, which contains valid data if(compute[k]){ out_aux = out_aux >> InW; out_aux(OFMChannelsTMR*InW-1, (OFMChannelsTMR-1)*InW) = tmr_out(InW-1, 0); tmr_out = tmr_out >> InW; // If it is not a first triplicated channel, check if it is a triplicated or not using mask } else if((channel_mask & (unitL << k)) != 0){ ; // Nothing to do, skip triplicated channel // If it is a not triplicated channel, forward the input data } else { out_aux = out_aux >> InW; out_aux(OFMChannelsTMR*InW-1, (OFMChannelsTMR-1)*InW) = input((k+1)*InW-1, k*InW); } } // end ChannelLoop out.write(out_aux); } // end CheckLoop } // end TMRCheck /** * \brief Smart TMR block (batch) * * The function receives an OFM from the MVTU, with triplicated channels. It outputs a single channel for each triplication, * being this channel one which contains valid data. A flag is also available to watch the character of the error detected, * either all channels in a triplication are different, or just one. * * \tparam InW Input data width, activation precision * \tparam OFMChannels Number of Output Feature Map channels, including triplications * \tparam NUM_RED Number of redundancies (or triplicated channels) * \tparam REDF Redundancy factor (3 to triplicate) * \tparam OFMDim Width and Height of the Output Feature Map (assumed square) * \tparam MAX_CH_WIDTH Value to determine the precision of channel indexes * * \param in Input stream * \param out Output stream * \param errortype Flag to inform redundancy check results. 0 if no faults, LSB set if one PE is faulty, MSB set if all differ * \param channel_mask Value with binary channel masks (1 if channel is triplicated, 0 otherwise) * \param red_ch_index Array of redundant triplets' indexes. Each position stores the first triplicated channel index of a triplet * \param numReps Number of time the function has to be repeatedly executed (e.g. number of images) */ template<unsigned int InW, unsigned int OFMChannels, unsigned int NUM_RED, unsigned int REDF, unsigned int OFMDim, unsigned int MAX_CH_WIDTH> void TMRCheck_Batch(hls::stream<ap_uint<InW*OFMChannels>> &in, hls::stream<ap_uint<InW*(OFMChannels-NUM_RED*(REDF-1))>> &out, ap_uint<2> &errortype, ap_uint<OFMChannels> channel_mask, ap_uint<MAX_CH_WIDTH> red_ch_index[NUM_RED], unsigned int numReps) { for (unsigned int rep = 0; rep < numReps; rep++) { TMRCheck<InW, OFMChannels, NUM_RED, REDF, OFMDim, MAX_CH_WIDTH>(in, out, errortype, channel_mask, red_ch_index); } } #endif
46.882927
135
0.613984
timoteogb
6da3450b336f1b6746301a35745de95e4705f1ca
282
cpp
C++
verify/fast-pow.aizu-power.test.cpp
dutinmeow/library
3501f36656795f432ac816941ec7e9548dc3d6ef
[ "MIT" ]
7
2022-01-23T07:58:19.000Z
2022-02-25T04:11:12.000Z
verify/fast-pow.aizu-power.test.cpp
dutinmeow/library
3501f36656795f432ac816941ec7e9548dc3d6ef
[ "MIT" ]
null
null
null
verify/fast-pow.aizu-power.test.cpp
dutinmeow/library
3501f36656795f432ac816941ec7e9548dc3d6ef
[ "MIT" ]
null
null
null
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_B" #include <bits/stdc++.h> using namespace std; #include "utility/fast-pow.hpp" const long long MOD = 1e9 + 7; int main() { long long M, N; cin >> M >> N; cout << fast_pow(M, N, MOD) << '\n'; }
20.142857
83
0.648936
dutinmeow
6da8a33b93785639e63ae532d522e33071916487
6,708
hpp
C++
Core/AString.hpp
koz4k/soccer
7bceea654b50c5c0e18effd38e79249bd295e0a4
[ "MIT" ]
1
2018-09-28T17:04:11.000Z
2018-09-28T17:04:11.000Z
Core/AString.hpp
koz4k/soccer
7bceea654b50c5c0e18effd38e79249bd295e0a4
[ "MIT" ]
1
2021-04-06T21:57:39.000Z
2021-04-06T21:57:39.000Z
Core/AString.hpp
koz4k/soccer
7bceea654b50c5c0e18effd38e79249bd295e0a4
[ "MIT" ]
3
2017-08-26T12:06:05.000Z
2019-11-22T16:57:47.000Z
template <class B> force_inline void AString<B>::Insert(int pos, const char *s) { Insert(pos, s, strlen__(s)); } template <class B> void AString<B>::Cat(int c, int count) { tchar *s = B::Insert(GetLength(), count, NULL); while(count--) *s++ = c; } template <class B> force_inline void AString<B>::Cat(const tchar *s) { Cat(s, strlen__(s)); } template <class B> int AString<B>::Compare(const tchar *b) const { const tchar *a = B::Begin(); const tchar *ae = End(); for(;;) { if(a >= ae) return *b == 0 ? 0 : -1; if(*b == 0) return 1; int q = cmpval__(*a++) - cmpval__(*b++); if(q) return q; } } template <class B> typename AString<B>::String AString<B>::Mid(int from, int count) const { int l = GetLength(); if(from > l) from = l; if(from < 0) from = 0; if(count < 0) count = 0; if(from + count > l) count = l - from; return String(B::Begin() + from, count); } template <class B> int AString<B>::Find(int chr, int from) const { ASSERT(from >= 0 && from <= GetLength()); const tchar *e = End(); const tchar *ptr = B::Begin(); for(const tchar *s = ptr + from; s < e; s++) if(*s == chr) return (int)(s - ptr); return -1; } template <class B> int AString<B>::ReverseFind(int chr, int from) const { ASSERT(from >= 0 && from <= GetLength()); if(from < GetLength()) { const tchar *ptr = B::Begin(); for(const tchar *s = ptr + from; s >= ptr; s--) if(*s == chr) return (int)(s - ptr); } return -1; } template <class B> int AString<B>::ReverseFind(int len, const tchar *s, int from) const { ASSERT(from >= 0 && from <= GetLength()); if(from < GetLength()) { const tchar *ptr = B::Begin(); const tchar *p = ptr + from - len + 1; len *= sizeof(tchar); while(p >= ptr) { if(*s == *p && memcmp(s, p, len) == 0) return (int)(p - ptr); p--; } } return -1; } template <class B> int AString<B>::ReverseFindAfter(int len, const tchar *s, int from) const { int q = ReverseFind(len, s, from); return q >= 0 ? q + len : -1; } template <class B> void AString<B>::Replace(const tchar *find, int findlen, const tchar *replace, int replacelen) { if(findlen == 0) return; String r; int i = 0; const tchar *p = B::Begin(); for(;;) { int j = Find(findlen, find, i); if(j < 0) break; r.Cat(p + i, j - i); r.Cat(replace, replacelen); i = j + findlen; } r.Cat(p + i, B::GetCount() - i); B::Free(); B::Set0(r); } template <class B> int AString<B>::ReverseFind(const tchar *s, int from) const { return ReverseFind(strlen__(s), s, from); } template <class B> int AString<B>::ReverseFindAfter(const tchar *s, int from) const { return ReverseFindAfter(strlen__(s), s, from); } template <class B> int AString<B>::ReverseFind(int chr) const { return B::GetCount() ? ReverseFind(chr, B::GetCount() - 1) : -1; } template <class B> void AString<B>::Replace(const String& find, const String& replace) { Replace(~find, find.GetCount(), ~replace, replace.GetCount()); } template <class B> force_inline void AString<B>::Replace(const tchar *find, const tchar *replace) { Replace(find, (int)strlen__(find), replace, (int)strlen__(replace)); } template <class B> force_inline void AString<B>::Replace(const String& find, const tchar *replace) { Replace(~find, find.GetCount(), replace, (int)strlen__(replace)); } template <class B> force_inline void AString<B>::Replace(const tchar *find, const String& replace) { Replace(find, (int)strlen__(find), ~replace, replace.GetCount()); } template <class B> bool AString<B>::StartsWith(const tchar *s, int len) const { if(len > GetLength()) return false; return memcmp(s, B::Begin(), len * sizeof(tchar)) == 0; } template <class B> force_inline bool AString<B>::StartsWith(const tchar *s) const { return StartsWith(s, strlen__(s)); } template <class B> bool AString<B>::EndsWith(const tchar *s, int len) const { int l = GetLength(); if(len > l) return false; return memcmp(s, B::Begin() + l - len, len * sizeof(tchar)) == 0; } template <class B> force_inline bool AString<B>::EndsWith(const tchar *s) const { return EndsWith(s, strlen__(s)); } template <class B> int AString<B>::FindFirstOf(int len, const tchar *s, int from) const { ASSERT(from >= 0 && from <= GetLength()); const tchar *ptr = B::Begin(); const tchar *e = B::End(); const tchar *se = s + len; if(len == 1) { tchar c1 = s[0]; for(const tchar *bs = ptr + from; bs < e; bs++) { if(*bs == c1) return (int)(bs - ptr); } return -1; } if(len == 2) { tchar c1 = s[0]; tchar c2 = s[1]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2) return (int)(bs - ptr); } return -1; } if(len == 3) { tchar c1 = s[0]; tchar c2 = s[1]; tchar c3 = s[2]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2 || ch == c3) return (int)(bs - ptr); } return -1; } if(len == 4) { tchar c1 = s[0]; tchar c2 = s[1]; tchar c3 = s[2]; tchar c4 = s[3]; for(const tchar *bs = ptr + from; bs < e; bs++) { tchar ch = *bs; if(ch == c1 || ch == c2 || ch == c3 || ch == c4) return (int)(bs - ptr); } return -1; } for(const tchar *bs = ptr + from; bs < e; bs++) for(const tchar *ss = s; ss < se; ss++) if(*bs == *ss) return (int)(bs - ptr); return -1; } inline int String0::Compare(const String0& s) const { #ifdef FAST_STRING_COMPARE if((chr[KIND] | s.chr[KIND]) == 0) { #ifdef CPU_64 uint64 a64 = q[0]; uint64 b64 = s.q[0]; if(a64 != b64) return SwapEndian64(a64) < SwapEndian64(b64) ? -1 : 1; uint32 a32 = w[2]; uint32 b32 = s.w[2]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; #else uint32 a32 = w[0]; uint32 b32 = s.w[0]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; a32 = w[1]; b32 = s.w[1]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; a32 = w[2]; b32 = s.w[2]; if(a32 != b32) return SwapEndian32(a32) < SwapEndian32(b32) ? -1 : 1; #endif uint16 a16 = v[6]; uint16 b16 = s.v[6]; if(a16 != b16) return SwapEndian16(a16) < SwapEndian16(b16) ? -1 : 1; return 0; } #endif return LCompare(s); } force_inline void String0::Set(const char *s, int len) { Clear(); if(len < 14) { SVO_MEMCPY(chr, s, len); SLen() = len; Dsyn(); return; } SetL(s, len); Dsyn(); } force_inline String& String::operator=(const char *s) { AssignLen(s, strlen__(s)); return *this; } force_inline String::String(const char *s) { String0::Set0(s, strlen__(s)); } force_inline void StringBuffer::Strlen() { SetLength((int)strlen__(pbegin)); } force_inline void StringBuffer::Cat(const char *s) { Cat(s, (int)strlen__(s)); }
20.576687
94
0.601521
koz4k
6da9ad8e2d5ddcfecf30764dc2ec399ccc368e82
1,167
cpp
C++
DX9ShareContainer.cpp
Yamamoto0773/libClass
630f00b01780904463ad9a0c9b74f2e078d01bc8
[ "BSD-2-Clause" ]
1
2019-12-07T13:53:31.000Z
2019-12-07T13:53:31.000Z
DX9ShareContainer.cpp
Yamamoto0773/Dx9Wrapper
630f00b01780904463ad9a0c9b74f2e078d01bc8
[ "BSD-2-Clause" ]
null
null
null
DX9ShareContainer.cpp
Yamamoto0773/Dx9Wrapper
630f00b01780904463ad9a0c9b74f2e078d01bc8
[ "BSD-2-Clause" ]
null
null
null
#include "DX9ShareContainer.hpp" #include <d3dx9.h> namespace dx9 { namespace resource { bool DX9ShareContainer::isResCreated = false; size_t DX9ShareContainer::topLayerPos = 0; LogManager* DX9ShareContainer::log; CComPtr<IDirect3D9> DX9ShareContainer::d3d9; CComPtr<IDirect3DDevice9> DX9ShareContainer::d3ddev9; D3DCAPS9 DX9ShareContainer::d3dcaps9; D3DPRESENT_PARAMETERS DX9ShareContainer::d3dpresent; CComPtr<IDirect3DVertexBuffer9> DX9ShareContainer::vertex_rect; CComPtr<IDirect3DVertexBuffer9> DX9ShareContainer::vertex_circle; CComPtr<ID3DXEffect> DX9ShareContainer::effect; // シェーダ CComPtr<IDirect3DVertexDeclaration9> DX9ShareContainer::verDecl; // 頂点宣言 D3DXMATRIX DX9ShareContainer::projMat; BLENDMODE DX9ShareContainer::blendMode = BLENDMODE::NORMAL; bool DX9ShareContainer::isDrawStarted = false; bool DX9ShareContainer::isLost = false; bool DX9ShareContainer::isRightHand = false; unsigned long DX9ShareContainer::clearColor = 0xffffff; TextureFilter DX9ShareContainer::texFilter = TextureFilter::LINEAR; } }
38.9
77
0.735219
Yamamoto0773
6daa7e39d96e4d5a8f7193264f99e25e9d5af9e1
6,803
cpp
C++
src/Menge/MengeCore/PluginEngine/CorePluginEngine.cpp
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
null
null
null
src/Menge/MengeCore/PluginEngine/CorePluginEngine.cpp
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
null
null
null
src/Menge/MengeCore/PluginEngine/CorePluginEngine.cpp
mfprado/Menge
75b1ebe91989c2a58073444fb2d5908644856372
[ "Apache-2.0" ]
1
2021-07-01T09:40:01.000Z
2021-07-01T09:40:01.000Z
#include "MengeCore/PluginEngine/CorePluginEngine.h" #include "MengeCore/Agents/AgentGenerators/AgentGeneratorDatabase.h" #include "MengeCore/Agents/Elevations/ElevationDatabase.h" #include "MengeCore/Agents/Events/EventEffectDB.h" #include "MengeCore/Agents/Events/EventTargetDB.h" #include "MengeCore/Agents/Events/EventTriggerDB.h" #include "MengeCore/Agents/ObstacleSets/ObstacleSetDatabase.h" #include "MengeCore/Agents/ProfileSelectors/ProfileSelectorDatabase.h" #include "MengeCore/Agents/SpatialQueries/SpatialQueryDatabase.h" #include "MengeCore/Agents/StateSelectors/StateSelectorDatabase.h" #include "MengeCore/BFSM/Actions/ActionDatabase.h" #include "MengeCore/BFSM/Goals/GoalDatabase.h" #include "MengeCore/BFSM/GoalSelectors/GoalSelectorDatabase.h" #include "MengeCore/BFSM/Tasks/TaskDatabase.h" #include "MengeCore/BFSM/Transitions/ConditionDatabase.h" #include "MengeCore/BFSM/Transitions/TargetDatabase.h" #include "MengeCore/BFSM/VelocityComponents/VelComponentDatabase.h" #include "MengeCore/BFSM/VelocityModifiers/VelModifierDatabase.h" #include "MengeCore/Orca/ORCADBEntry.h" #include "MengeCore/PedVO/PedVODBEntry.h" #include "MengeCore/Runtime/SimulatorDB.h" namespace Menge { namespace PluginEngine { ///////////////////////////////////////////////////////////////////// // Implementation of CorePluginEngine ///////////////////////////////////////////////////////////////////// CorePluginEngine::CorePluginEngine( SimulatorDB * simDB ) : BasePluginEngine< CorePluginEngine, Plugin<CorePluginEngine> >(), _simDB( simDB ) { registerModelDBEntry( new ORCA::DBEntry() ); registerModelDBEntry( new PedVO::DBEntry() ); BFSM::ActionDB::initialize(); BFSM::ConditionDB::initialize(); BFSM::TargetDB::initialize(); BFSM::VelCompDB::initialize(); BFSM::VelModDB::initialize(); BFSM::TaskDB::initialize(); BFSM::GoalDB::initialize(); BFSM::GoalSelectorDB::initialize(); Agents::ElevationDB::initialize(); Agents::SpatialQueryDB::initialize(); Agents::AgentGeneratorDB::initialize(); Agents::ObstacleSetDB::initialize(); Agents::ProfileSelectorDB::initialize(); Agents::StateSelectorDB::initialize(); EventEffectDB::initialize(); EventTriggerDB::initialize(); EventTargetDB::initialize(); } ///////////////////////////////////////////////////////////////////// CorePluginEngine::~CorePluginEngine() { } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerModelDBEntry( SimulatorDBEntry * dbEntry ) { _simDB->registerEntry( dbEntry ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerActionFactory( BFSM::ActionFactory * factory ) { BFSM::ActionDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerConditionFactory( BFSM::ConditionFactory * factory ) { BFSM::ConditionDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerTargetFactory( BFSM::TargetFactory * factory ) { BFSM::TargetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerVelCompFactory( BFSM::VelCompFactory * factory ) { BFSM::VelCompDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerVelModFactory( BFSM::VelModFactory * factory ) { BFSM::VelModDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerTaskFactory( BFSM::TaskFactory * factory ) { BFSM::TaskDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerGoalFactory( BFSM::GoalFactory * factory ) { BFSM::GoalDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerGoalSelectorFactory( BFSM::GoalSelectorFactory * factory ) { BFSM::GoalSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerElevationFactory( Agents::ElevationFactory * factory ) { Agents::ElevationDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerSpatialQueryFactory( Agents::SpatialQueryFactory * factory ) { Agents::SpatialQueryDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerAgentGeneratorFactory( Agents::AgentGeneratorFactory * factory ) { Agents::AgentGeneratorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerObstacleSetFactory( Agents::ObstacleSetFactory * factory ) { Agents::ObstacleSetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerProfileSelectorFactory( Agents::ProfileSelectorFactory * factory ) { Agents::ProfileSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerStateSelectorFactory( Agents::StateSelectorFactory * factory ) { Agents::StateSelectorDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventEffectFactory( EventEffectFactory * factory ) { EventEffectDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventTriggerFactory( EventTriggerFactory * factory ) { EventTriggerDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// void CorePluginEngine::registerEventTargetFactory( EventTargetFactory * factory ) { EventTargetDB::addFactory( factory ); } ///////////////////////////////////////////////////////////////////// std::string CorePluginEngine::getIntroMessage() { return "Loading Menge core-simulation plugins..."; } ///////////////////////////////////////////////////////////////////// // Implementation of CorePluginEngine ///////////////////////////////////////////////////////////////////// #ifndef DOXYGEN_SHOULD_SKIP_THIS template<> const char * Plugin< CorePluginEngine >::getRegisterName() const { return "registerCorePlugin"; } } #endif // DOXYGEN_SHOULD_SKIP_THIS } // namespace Menge
35.617801
89
0.565339
mfprado
6dad3c9774ede8dabd840e73714882e4b27b5a3e
7,274
cpp
C++
Simulation.cpp
thomasbinay/SimuWorld
09929f4c71d5fa9da87976772bb210b2d19fd1b2
[ "MIT" ]
null
null
null
Simulation.cpp
thomasbinay/SimuWorld
09929f4c71d5fa9da87976772bb210b2d19fd1b2
[ "MIT" ]
null
null
null
Simulation.cpp
thomasbinay/SimuWorld
09929f4c71d5fa9da87976772bb210b2d19fd1b2
[ "MIT" ]
null
null
null
#include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> #include <SDL2/SDL_image.h> #include <cstdlib> #include <ctime> #include <map> #include <fstream> #include <iostream> #include "Simulation.hpp" #include "speed.hpp" Simulation::Simulation(Settings const& settings): m_settings(settings) { srand(time(0)); SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER); if(m_settings.hide) m_window = SDL_CreateWindow("SimuWorld", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_HIDDEN); else m_window = SDL_CreateWindow("SimuWorld", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_RESIZABLE); SDL_GetWindowSize(m_window, &m_winsize.x, &m_winsize.y); m_renderer = SDL_CreateRenderer(m_window, -1, SDL_RENDERER_ACCELERATED); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"); IMG_Init(IMG_INIT_JPG|IMG_INIT_PNG); SDL_SetWindowIcon(m_window, IMG_Load("icone.png")); TTF_Init(); m_map = new Map(m_renderer); m_population = new Population(m_renderer); m_camera = new Camera(); m_stats = new Stats(); m_leftclick = false; m_render = true; m_paused = false; m_map->generate(); m_population->generate(); set_simulation_speed(m_settings.speed); } Simulation::~Simulation() { SDL_DestroyRenderer(m_renderer); SDL_DestroyWindow(m_window); delete m_map; delete m_camera; delete m_population; delete m_stats; TTF_Quit(); IMG_Quit(); SDL_Quit(); } bool Simulation::get_error() const { if(m_map->get_error() || m_population->get_error() || m_stats->get_error()) return true; return false; } void Simulation::execute() { while(process_events() && check_status()) { update(); if(!m_settings.hide) render(); } } void Simulation::update() { if(!m_paused) { m_map->update(); m_population->update(*m_map); m_stats->update(*m_population, *m_map); } } void Simulation::render() { SDL_SetRenderDrawColor(m_renderer, 128, 128, 128, 255); SDL_RenderClear(m_renderer); if(m_render) { m_camera->update(*m_population, m_winsize); m_map->render(m_renderer, m_winsize, *m_camera); m_population->render(m_renderer, m_winsize, *m_camera); } m_stats->render(m_renderer, m_winsize); SDL_RenderPresent(m_renderer); } bool Simulation::process_events() { SDL_Event event; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_WINDOWEVENT: if(event.window.event == SDL_WINDOWEVENT_CLOSE) { if(confirm_exit()) return false; } else if(event.window.event == SDL_WINDOWEVENT_RESIZED) m_winsize = {event.window.data1, event.window.data2}; break; case SDL_MOUSEBUTTONDOWN: if(event.button.button == SDL_BUTTON_LEFT) { m_camera->focus_on_animal(*m_population, *m_stats, m_mousepos); m_leftclick = true; } else if(event.button.button == SDL_BUTTON_RIGHT) { if(event.button.x < 100) m_stats->select_graph(m_mousepos); } break; case SDL_MOUSEBUTTONUP: if(event.button.button == SDL_BUTTON_LEFT) m_leftclick = false; break; case SDL_MOUSEWHEEL: if(event.wheel.y < 0) m_camera->zoom(m_mousepos, false); else if(event.wheel.y > 0) m_camera->zoom(m_mousepos, true); break; case SDL_MOUSEMOTION: if(m_leftclick) m_camera->move(event.motion.x - m_mousepos.x, event.motion.y - m_mousepos.y); m_mousepos = {event.motion.x, event.motion.y}; break; case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_i) m_stats->show_hide_data(); else if(event.key.keysym.sym == SDLK_g) m_stats->show_hide_graph(); else if(event.key.keysym.sym == SDLK_r) m_render = !m_render; else if(event.key.keysym.sym == SDLK_p) m_paused = !m_paused; else if(event.key.keysym.sym == SDLK_b) m_population->show_hide_bubble(); else if(event.key.keysym.sym == SDLK_KP_PLUS || event.key.keysym.sym == SDLK_UP) change_simulation_speed(true); else if(event.key.keysym.sym == SDLK_KP_MINUS || event.key.keysym.sym == SDLK_DOWN) change_simulation_speed(false); else if(event.key.keysym.sym == SDLK_DELETE) m_stats->hide_all_graph(); else if(event.key.keysym.sym == SDLK_s) m_population->show_hide_blood(); break; } } return true; } bool Simulation::confirm_exit() { const SDL_MessageBoxButtonData buttons[] = { { SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0, "annuler" }, { 0, 1, "non" }, { SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 2, "oui" }, }; const SDL_MessageBoxData messageboxdata = { SDL_MESSAGEBOX_INFORMATION, NULL, "Fermeture de la simulation", "Voulez-vous sauvegarder les resultats ?", SDL_arraysize(buttons), buttons, NULL }; int selection; SDL_ShowMessageBox(&messageboxdata, &selection); switch(selection) { case -1: case 0: return false; case 2: if(!m_stats->save(m_settings.directory, m_settings.id)) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fermeture impossible", "Une erreur est survenue durant la sauvegarde", NULL); return false; } } return true; } bool Simulation::check_status() { if(m_settings.id == 0) //the programm has been launched from simuworld and not the launcher return true; bool has_finished = m_stats->has_finished(m_settings.duration); bool has_failed = m_stats->has_failed(); int percent = m_stats->get_percent(m_settings.duration); save_status(percent, has_failed); if((m_settings.stopOnFailure && has_failed) || has_finished) //simulation failure or completed { if((m_settings.saveOnFailure && has_failed && (percent > m_settings.minFailureSave)) || has_finished) //failure and save still or completed { while(!m_stats->save(m_settings.directory, m_settings.id)) SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fermeture impossible", "Une erreur est survenue durant la sauvegarde", NULL); } return false; } return true; } void Simulation::save_status(int percent, bool has_failed) { std::ofstream file("status_" + std::to_string(m_settings.id) + ".txt"); if(file) { file << percent << ";" << has_failed << std::endl; } file.close(); }
30.953191
148
0.590184
thomasbinay
6daf6b90b10252a6ee737c88f9009497d751cd80
1,714
hpp
C++
src/rendering/IndexBuffer.hpp
am-lola/ARVisualizer
b262a0ee5ffb9de1a4ccac16eb5c6b8deacba16d
[ "MIT" ]
1
2018-05-29T07:55:52.000Z
2018-05-29T07:55:52.000Z
src/rendering/IndexBuffer.hpp
am-lola/ARVisualizer
b262a0ee5ffb9de1a4ccac16eb5c6b8deacba16d
[ "MIT" ]
null
null
null
src/rendering/IndexBuffer.hpp
am-lola/ARVisualizer
b262a0ee5ffb9de1a4ccac16eb5c6b8deacba16d
[ "MIT" ]
null
null
null
#ifndef _ARINDEXBUFFER_HPP #define _ARINDEXBUFFER_HPP #include "common.hpp" #include "RenderResource.hpp" #include "RenderDefinitions.hpp" #ifndef GL_GLEXT_PROTOTYPES #define GL_GLEXT_PROTOTYPES #endif #include <GLFW/glfw3.h> namespace ar { class IndexBuffer : public RenderResource { public: virtual ~IndexBuffer() = default; virtual void BufferData() = 0; }; /* Index buffer. */ class GenericIndexBuffer : public IndexBuffer { public: GenericIndexBuffer() = default; GenericIndexBuffer(BufferUsage usage) : _usage(usage) { } virtual void InitResource() override { glGenBuffers(1, &_vio); } virtual void ReleaseResource() override { glDeleteBuffers(1, &_vio); } int AddIndices(const Vector<GLuint>& indices) { size_t offset = _indices.size(); // append new indices to the end of our existing list _indices.insert(std::end(_indices), std::begin(indices), std::end(indices)); _dirty = true; return (int)offset; } void SetIndices(const Vector<GLuint>& indices) { _indices = indices; _dirty = true; } virtual void BufferData() override { if (!_initialized) throw std::runtime_error("The index buffer was not initialized."); if (!_dirty) return; glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vio); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint) * _indices.size(), &_indices[0], GetGLUsage(_usage)); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); _dirty = false; } void ClearAll() { _indices.clear(); _dirty = true; } bool _dirty = false; BufferUsage _usage = BufferUsage::Static; GLuint _vio; Vector<GLuint> _indices; }; } // namespace ar #endif // _ARINDEXBUFFER_HPP
18.630435
110
0.693699
am-lola
6db09bf09ef557be55e9d512b3ddefbe2e4eb4a2
3,204
cpp
C++
src/chronotest.cpp
sda1969/cpptest
068b8401664e3c13f969abcfc93ea4f60028a73a
[ "Unlicense" ]
null
null
null
src/chronotest.cpp
sda1969/cpptest
068b8401664e3c13f969abcfc93ea4f60028a73a
[ "Unlicense" ]
null
null
null
src/chronotest.cpp
sda1969/cpptest
068b8401664e3c13f969abcfc93ea4f60028a73a
[ "Unlicense" ]
null
null
null
/* * chronotest.cpp * * Created on: 24 марта 2017 г. * Author: dmitry */ #include <iostream> #include <chrono> #include <thread> #include <ratio> #include <ctime> #include "chronotest.h" namespace chronotest { //duration test void test01(){ std::chrono::duration<int, std::ratio<60,1>> dminutes {1}; std::chrono::duration<int, std::ratio<1,1>> dseconds {1}; std::chrono::duration<int, std::ratio<1,1000>> dmiliseconds {500}; typedef std::chrono::duration<uint64_t, std::ratio<1,1000000>> microsec_t; while(1){ //std::this_thread::sleep_for(std::chrono::seconds(1)); //std::this_thread::sleep_for(std::chrono::hours(1)); //std::this_thread::sleep_for(dseconds); //std::this_thread::sleep_for(dmiliseconds); //auto dur = std::chrono::microseconds {500000}; //dmiliseconds = 100; нельзя //dseconds = std::chrono::duration<int, std::ratio<1,1>> {2}; //auto dur = dseconds; //auto dur = std::chrono::duration<double, std::ratio<1,1000>> {507.8}; //std::chrono::duration<double, std::ratio<1,1000>> dur {509.8}; //std::chrono::milliseconds dur {607}; microsec_t dur {807}; std::this_thread::sleep_for(dur); std::cout << dur.count() << " period passed\n"; } } //time_point and clock test void test02(){ std::chrono::system_clock::time_point tp_epoch; // epoch value std::chrono::time_point <std::chrono::system_clock, std::chrono::duration<int>> tp_seconds (std::chrono::duration<int>(1)); std::chrono::system_clock::time_point tp {tp_seconds}; std::cout << "1 second since system_clock epoch = "; std::cout << tp.time_since_epoch().count(); std::cout << " system_clock periods." << std::endl; // display time_point: std::time_t tt = std::chrono::system_clock::to_time_t(tp); std::cout << "time_point tp is: " << ctime(&tt); std::chrono::steady_clock::time_point t1 = std::chrono::steady_clock::now(); // с компилятором 4.7 строки ниже работали с 4.9 нет // std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<int, std::ratio<1,1000000 >>> t11 = std::chrono::steady_clock::now(); // std::time_t tt1 = std::chrono::steady_clock::to_time_t(t11); // std::cout << "time_point tp is: " << ctime(&tt1); std::chrono::steady_clock::time_point t2 = std::chrono::steady_clock::now(); //auto dur = std::chrono::duration<int, std::ratio<1,1000000>>(t2-t1); std::chrono::duration<int, std::ratio<1,1000000 > > dur = std::chrono::duration_cast < std::chrono::duration < int, std::ratio<1,1000000 > > >(t2 - t1); //std::chrono::microseconds dur = std::chrono::duration_cast< std::chrono::microseconds> (t2 - t1); std::cout << dur.count() << " us time interval\n"; typedef std::chrono::duration<int,std::ratio<60*60*24*7>> weeks_type; std::chrono::time_point<std::chrono::system_clock,weeks_type> today =std::chrono::time_point_cast<weeks_type>(std::chrono::system_clock::now()); std::cout << today.time_since_epoch().count() << " weeks since epoch" << std::endl; } void chronotest_run(){ // test01(); test02(); } }
37.694118
158
0.634207
sda1969
6db0f07b83b1b86ff87b68a9bda0147685e3e9ae
6,226
hpp
C++
lib/oatpp/src/oatpp/network/server/SimpleTCPConnectionProvider.hpp
nicraMarcin/custom-oatpp-starter
91e6c023fa78aab23cc559ab6830970134f749b9
[ "Apache-2.0" ]
null
null
null
lib/oatpp/src/oatpp/network/server/SimpleTCPConnectionProvider.hpp
nicraMarcin/custom-oatpp-starter
91e6c023fa78aab23cc559ab6830970134f749b9
[ "Apache-2.0" ]
null
null
null
lib/oatpp/src/oatpp/network/server/SimpleTCPConnectionProvider.hpp
nicraMarcin/custom-oatpp-starter
91e6c023fa78aab23cc559ab6830970134f749b9
[ "Apache-2.0" ]
1
2021-04-22T06:15:46.000Z
2021-04-22T06:15:46.000Z
/*************************************************************************** * * Project _____ __ ____ _ _ * ( _ ) /__\ (_ _)_| |_ _| |_ * )(_)( /(__)\ )( (_ _)(_ _) * (_____)(__)(__)(__) |_| |_| * * * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ***************************************************************************/ #ifndef oatpp_netword_server_SimpleTCPConnectionProvider_hpp #define oatpp_netword_server_SimpleTCPConnectionProvider_hpp #include "oatpp/network/ConnectionProvider.hpp" #include "oatpp/network/Connection.hpp" #include "oatpp/core/Types.hpp" namespace oatpp { namespace network { namespace server { /** * Simple provider of TCP connections. */ class SimpleTCPConnectionProvider : public base::Countable, public ServerConnectionProvider { public: /** * Connection with extra data - ex.: peer address. */ class ExtendedConnection : public oatpp::network::Connection { public: static const char* const PROPERTY_PEER_ADDRESS; static const char* const PROPERTY_PEER_ADDRESS_FORMAT; static const char* const PROPERTY_PEER_PORT; protected: data::stream::DefaultInitializedContext m_context; public: /** * Constructor. * @param handle - &id:oatpp::v_io_handle;. * @param properties - &id:oatpp::data::stream::Context::Properties;. */ ExtendedConnection(v_io_handle handle, data::stream::Context::Properties&& properties); /** * Get output stream context. * @return - &id:oatpp::data::stream::Context;. */ oatpp::data::stream::Context& getOutputStreamContext() override; /** * Get input stream context. <br> * @return - &id:oatpp::data::stream::Context;. */ oatpp::data::stream::Context& getInputStreamContext() override; }; private: v_uint16 m_port; std::atomic<bool> m_closed; oatpp::v_io_handle m_serverHandle; bool m_useExtendedConnections; private: oatpp::v_io_handle instantiateServer(); private: bool prepareConnectionHandle(oatpp::v_io_handle handle); std::shared_ptr<IOStream> getDefaultConnection(); std::shared_ptr<IOStream> getExtendedConnection(); public: /** * Constructor. * @param port - port to listen for incoming connections. * @param useExtendedConnections - set `true` to use &l:SimpleTCPConnectionProvider::ExtendedConnection;. * `false` to use &id:oatpp::network::Connection;. */ SimpleTCPConnectionProvider(v_uint16 port, bool useExtendedConnections = false); /** * Constructor. * @param host - host name without schema and port. Ex.: "oatpp.io", "127.0.0.1", "localhost". * @param port - port to listen for incoming connections. * @param useExtendedConnections - set `true` to use &l:SimpleTCPConnectionProvider::ExtendedConnection;. * `false` to use &id:oatpp::network::Connection;. */ SimpleTCPConnectionProvider(const oatpp::String& host, v_uint16 port, bool useExtendedConnections = false); public: /** * Create shared SimpleTCPConnectionProvider. * @param port - port to listen for incoming connections. * @param port * @return - `std::shared_ptr` to SimpleTCPConnectionProvider. */ static std::shared_ptr<SimpleTCPConnectionProvider> createShared(v_uint16 port, bool useExtendedConnections = false){ return std::make_shared<SimpleTCPConnectionProvider>(port, useExtendedConnections); } /** * Create shared SimpleTCPConnectionProvider. * @param host - host name without schema and port. Ex.: "oatpp.io", "127.0.0.1", "localhost". * @param port - port to listen for incoming connections. * @param port * @return - `std::shared_ptr` to SimpleTCPConnectionProvider. */ static std::shared_ptr<SimpleTCPConnectionProvider> createShared(const oatpp::String& host, v_uint16 port, bool useExtendedConnections = false){ return std::make_shared<SimpleTCPConnectionProvider>(host, port, useExtendedConnections); } /** * Virtual destructor. */ ~SimpleTCPConnectionProvider(); /** * Close accept-socket. */ void close() override; /** * Get incoming connection. * @return &id:oatpp::data::stream::IOStream;. */ std::shared_ptr<IOStream> getConnection() override; /** * No need to implement this.<br> * For Asynchronous IO in oatpp it is considered to be a good practice * to accept connections in a seperate thread with the blocking accept() * and then process connections in Asynchronous manner with non-blocking read/write. * <br> * *It may be implemented later* */ oatpp::async::CoroutineStarterForResult<const std::shared_ptr<oatpp::data::stream::IOStream>&> getConnectionAsync() override { /* * No need to implement this. * For Asynchronous IO in oatpp it is considered to be a good practice * to accept connections in a seperate thread with the blocking accept() * and then process connections in Asynchronous manner with non-blocking read/write * * It may be implemented later */ throw std::runtime_error("[oatpp::network::server::SimpleTCPConnectionProvider::getConnectionAsync()]: Error. Not implemented."); } /** * Call shutdown read and write on an underlying file descriptor. * `connection` **MUST** be an object previously obtained from **THIS** connection provider. * @param connection */ void invalidateConnection(const std::shared_ptr<IOStream>& connection) override; /** * Get port. * @return */ v_uint16 getPort(){ return m_port; } }; }}} #endif /* oatpp_netword_server_SimpleTCPConnectionProvider_hpp */
33.836957
148
0.681176
nicraMarcin
6db1a80d4a6ffaf31b9b0d6ba1fa2037f8b3f100
11,752
cpp
C++
moai/src/moaicore/MOAIBox2DPrismaticJoint.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
moai/src/moaicore/MOAIBox2DPrismaticJoint.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
moai/src/moaicore/MOAIBox2DPrismaticJoint.cpp
jjimenezg93/ai-pathfinding
e32ae8be30d3df21c7e64be987134049b585f1e6
[ "MIT" ]
null
null
null
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved. // http://getmoai.com #include "pch.h" #include <Box2D/Box2D.h> #include <moaicore/MOAISim.h> #include <moaicore/MOAIBox2DArbiter.h> #include <moaicore/MOAIBox2DBody.h> #include <moaicore/MOAIBox2DPrismaticJoint.h> #include <moaicore/MOAIBox2DWorld.h> #include <moaicore/MOAILogMessages.h> SUPPRESS_EMPTY_FILE_WARNING #if USE_BOX2D //================================================================// // local //================================================================// //----------------------------------------------------------------// /** @name getJointSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number jointSpeed in units/s, converted from m/s */ int MOAIBox2DPrismaticJoint::_getJointSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetJointSpeed () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getJointTranslation @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number jointTranslation in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getJointTranslation ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetJointTranslation () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getLowerLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number lowerLimit in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getLowerLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetLowerLimit () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getMotorForce @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number motorForce in kg * units / s^2, converted from N [kg * m / s^2] */ int MOAIBox2DPrismaticJoint::_getMotorForce ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; float step = ( float )( 1.0 / MOAISim::Get ().GetStep ()); state.Push ( joint->GetMotorForce (step) / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getMotorSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number motorSpeed in units/s, converted from m/s */ int MOAIBox2DPrismaticJoint::_getMotorSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetMotorSpeed () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name getUpperLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out number upperLimit in units, converted from meters. */ int MOAIBox2DPrismaticJoint::_getUpperLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->GetUpperLimit () / unitsToMeters ); return 1; } //----------------------------------------------------------------// /** @name isLimitEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out boolean limitEnabled */ int MOAIBox2DPrismaticJoint::_isLimitEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->IsLimitEnabled ()); return 1; } //----------------------------------------------------------------// /** @name isMotorEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @out boolean motorEnabled */ int MOAIBox2DPrismaticJoint::_isMotorEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; state.Push ( joint->IsMotorEnabled ()); return 1; } //----------------------------------------------------------------// /** @name setLimit @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number lower in units, converted to meters. Default value is 0. @opt number upper in units, converted to meters. Default value is 0. @out nil */ int MOAIBox2DPrismaticJoint::_setLimit ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float lower = state.GetValue < float >( 2, 0.0f ); float upper = state.GetValue < float >( 3, 0.0f ); float unitsToMeters = self->GetUnitsToMeters (); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetLimits ( lower * unitsToMeters, upper * unitsToMeters ); joint->EnableLimit ( true ); return 0; } //----------------------------------------------------------------// /** @name setLimitEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt boolean enabled Default value is 'true' @out nil */ int MOAIBox2DPrismaticJoint::_setLimitEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } bool enabled = state.GetValue < bool >( 2, true ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->EnableLimit ( enabled ); return 0; } //----------------------------------------------------------------// /** @name setMaxMotorForce @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number maxMotorForce in kg * units / s^2, converted to N [kg * m / s^2]. Default value is 0. @out nil */ int MOAIBox2DPrismaticJoint::_setMaxMotorForce ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) float unitsToMeters = self->GetUnitsToMeters (); if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float maxMotorForce = state.GetValue < float >( 2, 0.0f ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMaxMotorForce ( maxMotorForce * unitsToMeters ); return 0; } //----------------------------------------------------------------// /** @name setMotor @text See Box2D documentation. If speed is determined to be zero, the motor is disabled, unless forceEnable is set. @in MOAIBox2DPrismaticJoint self @opt number speed in units/s converted to m/s. Default value is 0. @opt number maxForce in kg * units / s^2, converted to N [kg * m / s^2]. Default value is 0. @opt boolean forceEnable Default value is false. @out nil */ int MOAIBox2DPrismaticJoint::_setMotor ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float speed = state.GetValue < float >( 2, 0.0f ); float max = state.GetValue < float >( 3, 0.0f ); bool forceEnable = state.GetValue < bool >( 4, false ); float unitsToMeters = self->GetUnitsToMeters (); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMotorSpeed ( speed * unitsToMeters ); joint->SetMaxMotorForce ( max * unitsToMeters ); joint->EnableMotor ( forceEnable ? true : ( speed != 0.0f ) ); return 0; } //----------------------------------------------------------------// /** @name setMotorEnabled @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt boolean enabled Default value is 'true' @out nil */ int MOAIBox2DPrismaticJoint::_setMotorEnabled ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } bool enabled = state.GetValue < bool >( 2, true ); b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->EnableMotor ( enabled ); return 0; } //----------------------------------------------------------------// /** @name setMotorSpeed @text See Box2D documentation. @in MOAIBox2DPrismaticJoint self @opt number motorSpeed in units/s, converted to m/s. Default value is 0. */ int MOAIBox2DPrismaticJoint::_setMotorSpeed ( lua_State* L ) { MOAI_LUA_SETUP ( MOAIBox2DPrismaticJoint, "U" ) if ( !self->mJoint ) { MOAILog ( state, MOAILogMessages::MOAIBox2DJoint_MissingInstance ); return 0; } float unitsToMeters = self->GetUnitsToMeters (); float speed = state.GetValue < float >( 2, 0.0f ) * unitsToMeters; b2PrismaticJoint* joint = ( b2PrismaticJoint* )self->mJoint; joint->SetMotorSpeed ( speed ); return 0; } //================================================================// // MOAIBox2DPrismaticJoint //================================================================// //----------------------------------------------------------------// MOAIBox2DPrismaticJoint::MOAIBox2DPrismaticJoint () { RTTI_BEGIN RTTI_EXTEND ( MOAIBox2DJoint ) RTTI_END } //----------------------------------------------------------------// MOAIBox2DPrismaticJoint::~MOAIBox2DPrismaticJoint () { } //----------------------------------------------------------------// void MOAIBox2DPrismaticJoint::RegisterLuaClass ( MOAILuaState& state ) { MOAIBox2DJoint::RegisterLuaClass ( state ); } //----------------------------------------------------------------// void MOAIBox2DPrismaticJoint::RegisterLuaFuncs ( MOAILuaState& state ) { MOAIBox2DJoint::RegisterLuaFuncs ( state ); luaL_Reg regTable [] = { { "getJointSpeed", _getJointSpeed }, { "getJointTranslation", _getJointTranslation }, { "getLowerLimit", _getLowerLimit }, { "getMotorForce", _getMotorForce }, { "getMotorSpeed", _getMotorSpeed }, { "getUpperLimit", _getUpperLimit }, { "isLimitEnabled", _isLimitEnabled }, { "isMotorEnabled", _isMotorEnabled }, { "setLimit", _setLimit }, { "setLimitEnabled", _setLimitEnabled }, { "setMaxMotorForce", _setMaxMotorForce }, { "setMotor", _setMotor }, { "setMotorSpeed", _setMotorSpeed }, { "setMotorEnabled", _setMotorEnabled }, { NULL, NULL } }; luaL_register ( state, 0, regTable ); } #endif
29.089109
99
0.626361
jjimenezg93
6db1b55cca7a17a60941db9856bd717e5606757f
3,546
cpp
C++
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
ontio/libcxx-mirror
4b4f32ea383deb28911f5618126c6ea6c110b5e4
[ "Apache-2.0" ]
null
null
null
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
ontio/libcxx-mirror
4b4f32ea383deb28911f5618126c6ea6c110b5e4
[ "Apache-2.0" ]
1
2019-04-21T16:53:33.000Z
2019-04-21T17:15:25.000Z
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minmax_showbase.pass.cpp
ontio/libcxx-mirror
4b4f32ea383deb28911f5618126c6ea6c110b5e4
[ "Apache-2.0" ]
1
2020-09-09T07:40:32.000Z
2020-09-09T07:40:32.000Z
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // <ostream> // template <class charT, class traits = char_traits<charT> > // class basic_ostream; // operator<<(short n); // operator<<(unsigned short n); // operator<<(int n); // operator<<(unsigned int n); // operator<<(long n); // operator<<(unsigned long n); // operator<<(long long n); // operator<<(unsigned long long n); // Testing to make sure that the max length values are correctly inserted when // using std::showbase // This test exposes a regression that was not fixed yet in the libc++ // shipped with macOS 10.12, 10.13 and 10.14. See D32670 for details. // XFAIL: with_system_cxx_lib=macosx10.14 // XFAIL: with_system_cxx_lib=macosx10.13 // XFAIL: with_system_cxx_lib=macosx10.12 #include <cassert> #include <cstdint> #include <ios> #include <limits> #include <sstream> #include <type_traits> template <typename T> static void test(std::ios_base::fmtflags fmt, const char *expected) { std::stringstream ss; ss.setf(fmt, std::ios_base::basefield); ss << std::showbase << (std::is_signed<T>::value ? std::numeric_limits<T>::min() : std::numeric_limits<T>::max()); assert(ss.str() == expected); } int main(int, char**) { const std::ios_base::fmtflags o = std::ios_base::oct; const std::ios_base::fmtflags d = std::ios_base::dec; const std::ios_base::fmtflags x = std::ios_base::hex; test<short>(o, "0100000"); test<short>(d, "-32768"); test<short>(x, "0x8000"); test<unsigned short>(o, "0177777"); test<unsigned short>(d, "65535"); test<unsigned short>(x, "0xffff"); test<int>(o, "020000000000"); test<int>(d, "-2147483648"); test<int>(x, "0x80000000"); test<unsigned int>(o, "037777777777"); test<unsigned int>(d, "4294967295"); test<unsigned int>(x, "0xffffffff"); const bool long_is_32 = std::integral_constant<bool, sizeof(long) == sizeof(int32_t)>::value; // avoid compiler warnings const bool long_is_64 = std::integral_constant<bool, sizeof(long) == sizeof(int64_t)>::value; // avoid compiler warnings const bool long_long_is_64 = std::integral_constant<bool, sizeof(long long) == sizeof(int64_t)>::value; // avoid compiler warnings if (long_is_32) { test<long>(o, "020000000000"); test<long>(d, "-2147483648"); test<long>(x, "0x80000000"); test<unsigned long>(o, "037777777777"); test<unsigned long>(d, "4294967295"); test<unsigned long>(x, "0xffffffff"); } else if (long_is_64) { test<long>(o, "01000000000000000000000"); test<long>(d, "-9223372036854775808"); test<long>(x, "0x8000000000000000"); test<unsigned long>(o, "01777777777777777777777"); test<unsigned long>(d, "18446744073709551615"); test<unsigned long>(x, "0xffffffffffffffff"); } if (long_long_is_64) { test<long long>(o, "01000000000000000000000"); test<long long>(d, "-9223372036854775808"); test<long long>(x, "0x8000000000000000"); test<unsigned long long>(o, "01777777777777777777777"); test<unsigned long long>(d, "18446744073709551615"); test<unsigned long long>(x, "0xffffffffffffffff"); } return 0; }
34.427184
134
0.62916
ontio
6db41753eb040fc4124bc7ce51c3938f61a526eb
668
cpp
C++
SourceCode/Chapter 03/Pr3-6.cpp
aceiro/poo2019
0f93d22296f43a8b024a346f510c00314817d2cf
[ "MIT" ]
1
2019-04-09T18:29:38.000Z
2019-04-09T18:29:38.000Z
SourceCode/Chapter 03/Pr3-6.cpp
aceiro/poo2019
0f93d22296f43a8b024a346f510c00314817d2cf
[ "MIT" ]
null
null
null
SourceCode/Chapter 03/Pr3-6.cpp
aceiro/poo2019
0f93d22296f43a8b024a346f510c00314817d2cf
[ "MIT" ]
null
null
null
// This program calculates the average // of three test scores. #include <iostream> #include <cmath> using namespace std; int main() { double test1, test2, test3; // To hold the scores double average; // To hold the average // Get the three test scores. cout << "Enter the first test score: "; cin >> test1; cout << "Enter the second test score: "; cin >> test2; cout << "Enter the third test score: "; cin >> test3; // Calculate the average of the scores. average = (test1 + test2 + test3) / 3.0; // Display the average. cout << "The average score is: " << average << endl; return 0; }
25.692308
56
0.595808
aceiro
6db4a79a56f75f2b423c15d8cd619db4b73e74fe
5,712
hpp
C++
include/tudocomp/meta/RegistryOf.hpp
421408/tudocomp
9634742393995acdde148b0412f083bfdd0fbe9f
[ "ECL-2.0", "Apache-2.0" ]
1
2020-09-22T11:29:02.000Z
2020-09-22T11:29:02.000Z
include/tudocomp/meta/RegistryOf.hpp
421408/tudocomp
9634742393995acdde148b0412f083bfdd0fbe9f
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
include/tudocomp/meta/RegistryOf.hpp
421408/tudocomp
9634742393995acdde148b0412f083bfdd0fbe9f
[ "ECL-2.0", "Apache-2.0" ]
1
2020-09-29T08:57:13.000Z
2020-09-29T08:57:13.000Z
#pragma once #include <functional> #include <memory> #include <sstream> #include <string> #include <unordered_map> #include <vector> #include <tudocomp/meta/Config.hpp> #include <tudocomp/meta/Meta.hpp> namespace tdc { namespace meta { /// \brief Error type for registry related errors. class RegistryError : public std::runtime_error { public: using std::runtime_error::runtime_error; }; /// \cond INTERNAL class RegistryOfAny { }; /// \endcond INTERNAL template<typename T> class RegistryOf : public RegistryOfAny { public: using register_callback_t = std::function<void(const Meta&)>; private: using ctor_t = std::function<std::unique_ptr<T>(Config&&)>; TypeDesc m_root_type; DeclLib m_lib; std::unordered_map<std::string, ctor_t> m_reg; std::vector<register_callback_t> m_callback; public: inline RegistryOf() : m_root_type(T::type_desc()) { } inline RegistryOf(const TypeDesc& root_type) : m_root_type(root_type) { } template<typename Algo> inline void register_algorithm() { auto meta = Algo::meta(); auto type = meta.decl()->type(); if(!type.subtype_of(m_root_type)) { throw RegistryError(std::string( "trying to register algorithm of type ") + type.name() + std::string(", expected ") + m_root_type.name()); } auto sig = meta.signature()->str(); auto it = m_reg.find(sig); if(it == m_reg.end()) { add_to_lib(m_lib, meta); m_reg.emplace(sig, [](Config&& cfg) { return std::make_unique<Algo>(std::move(cfg)); }); } else { throw RegistryError(std::string("already registered: ") + sig); } for(auto& f : m_callback) { f(meta); } } inline void add_register_callback(register_callback_t f) { m_callback.push_back(f); } class Selection { private: friend class RegistryOf; std::shared_ptr<const Decl> m_decl; std::unique_ptr<T> m_instance; inline Selection( std::shared_ptr<const Decl> decl, std::unique_ptr<T>&& instance) : m_decl(decl), m_instance(std::move(instance)) { } public: inline Selection() { } inline Selection(Selection&& other) : m_decl(std::move(other.m_decl)), m_instance(std::move(other.m_instance)) { } inline Selection& operator=(Selection&& other) { m_decl = std::move(other.m_decl); m_instance = std::move(other.m_instance); return *this; } inline operator bool() const { return bool(m_instance); } inline std::shared_ptr<const Decl> decl() const { return m_decl; } inline T& instance() { return *m_instance; } inline T& operator*() { return instance(); } inline T* operator->() { return m_instance.get(); } inline std::unique_ptr<T>&& move_instance() { return std::move(m_instance); } }; class Entry { private: friend class RegistryOf; std::shared_ptr<const Decl> m_decl; const ctor_t* m_ctor; Config m_cfg; inline Entry( std::shared_ptr<const Decl> decl, const ctor_t& ctor, Config&& cfg) : m_decl(decl), m_ctor(&ctor), m_cfg(cfg) { } public: inline std::shared_ptr<const Decl> decl() const { return m_decl; } inline Selection select() const { return Selection(m_decl, (*m_ctor)(Config(m_cfg))); } }; inline Entry find(ast::NodePtr<ast::Object> obj) const { auto decl = m_lib.find(obj->name(), m_root_type); if(!decl) { throw RegistryError( std::string("unknown algorithm: ") + obj->name()); } auto cfg = Config(decl, obj, m_lib); auto sig = cfg.signature(); auto reg_entry = m_reg.find(sig->str()); if(reg_entry == m_reg.end()) { throw RegistryError( std::string("unregistered instance: ") + sig->str()); } return Entry(decl, reg_entry->second, std::move(cfg)); } inline Selection select(ast::NodePtr<ast::Object> obj) const { return find(obj).select(); } inline Selection select(const std::string& str) const { auto obj = ast::convert<ast::Object>(ast::Parser::parse(str)); return select(obj); } template<typename C> inline Selection select(const std::string& options = "") const { auto meta = C::meta(); auto decl = meta.decl(); auto parsed = ast::convert<ast::Object>( ast::Parser::parse(decl->name() + paranthesize(options))); auto obj = parsed->inherit(meta.signature()); auto cfg = Config( decl, obj, m_lib + meta.known()); return Selection(decl, std::make_unique<C>(std::move(cfg))); } inline const TypeDesc& root_type() const { return m_root_type; } inline const DeclLib& library() const { return m_lib; } inline std::vector<std::shared_ptr<const Decl>> declarations() const { return m_lib.entries(); } inline std::vector<std::string> signatures() const { std::vector<std::string> sigs; for(auto e : m_reg) sigs.emplace_back(e.first); return sigs; } }; } //namespace meta template<typename T> using RegistryOf = meta::RegistryOf<T>; } //namespace tdc
25.61435
75
0.565651
421408
6db756864cf0c88876f7f1a33599c1d68533f2e0
1,630
cpp
C++
src/board.cpp
cruzantada/pares
4e47bb991e1000e65416021d9fec708e6999e8c7
[ "MIT" ]
1
2019-02-10T01:29:52.000Z
2019-02-10T01:29:52.000Z
src/board.cpp
cruzantada/pares
4e47bb991e1000e65416021d9fec708e6999e8c7
[ "MIT" ]
null
null
null
src/board.cpp
cruzantada/pares
4e47bb991e1000e65416021d9fec708e6999e8c7
[ "MIT" ]
null
null
null
#include <algorithm> #include <random> #include <chrono> #include "../include/board.h" Board::Board() { boardArr = { }; } void Board::addCard(Card card, int index) { boardArr[index] = card; } std::string Board::getCardWord(int index) { return boardArr[index].getWord(); } std::string Board::getCardMatch(int index) { return boardArr[index].getMatch(); } void Board::flipCardUp(int index) { boardArr[index].setFaceUp(true); } void Board::flipCardDown(int index) { boardArr[index].setFaceUp(false); } void Board::setCardNumbers() { for (int i = 0; i < boardArr.size(); ++i) { boardArr[i].setNum(i); } } void Board::setCardFillColors(float r, float g, float b) { for (int i = 0; i < boardArr.size(); ++i) { boardArr[i].setFillColor(r, g, b); } } void Board::setCardPositions() { boardArr[0].setPosition(50, 450, 200, 600); boardArr[1].setPosition(250, 450, 400, 600); boardArr[2].setPosition(450, 450, 600, 600); boardArr[3].setPosition(50, 250, 200, 400); boardArr[4].setPosition(250, 250, 400, 400); boardArr[5].setPosition(450, 250, 600, 400); boardArr[6].setPosition(50, 50, 200, 200); boardArr[7].setPosition(250, 50, 400, 200); boardArr[8].setPosition(450, 50, 600, 200); } void Board::displayCards() { for (int i = 0; i < boardArr.size(); ++i) { boardArr[i].display(); } } int Board::getNumCards() { return boardArr.size(); } void Board::shuffleCards() { // Obtain time-based seed unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::shuffle(boardArr.begin(), boardArr.end(), std::default_random_engine(seed)); }
18.522727
83
0.657055
cruzantada
6dbd63f2020c5d3f1ca6df93d304ce083b4ee496
56,288
cpp
C++
test_common/harness/kernelHelpers.cpp
grey-eminence/OpenCL-CTS
a69f3ca8cf2d50d6cf81eebedfa177d03c02b00b
[ "Apache-2.0" ]
null
null
null
test_common/harness/kernelHelpers.cpp
grey-eminence/OpenCL-CTS
a69f3ca8cf2d50d6cf81eebedfa177d03c02b00b
[ "Apache-2.0" ]
null
null
null
test_common/harness/kernelHelpers.cpp
grey-eminence/OpenCL-CTS
a69f3ca8cf2d50d6cf81eebedfa177d03c02b00b
[ "Apache-2.0" ]
null
null
null
// // Copyright (c) 2017 The Khronos Group Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include "crc32.h" #include "kernelHelpers.h" #include "deviceInfo.h" #include "errorHelpers.h" #include "imageHelpers.h" #include "typeWrappers.h" #include "testHarness.h" #include "parseParameters.h" #include <cassert> #include <vector> #include <string> #include <fstream> #include <sstream> #include <iomanip> #if defined(_WIN32) std::string slash = "\\"; #else std::string slash = "/"; #endif static cl_int get_first_device_id(const cl_context context, cl_device_id &device); long get_file_size(const std::string &fileName) { std::ifstream ifs(fileName.c_str(), std::ios::binary); if (!ifs.good()) return 0; // get length of file: ifs.seekg(0, std::ios::end); std::ios::pos_type length = ifs.tellg(); return static_cast<long>(length); } static std::string get_kernel_content(unsigned int numKernelLines, const char *const *kernelProgram) { std::string kernel; for (size_t i = 0; i < numKernelLines; ++i) { std::string chunk(kernelProgram[i], 0, std::string::npos); kernel += chunk; } return kernel; } std::string get_kernel_name(const std::string &source) { // Create list of kernel names std::string kernelsList; size_t kPos = source.find("kernel"); while (kPos != std::string::npos) { // check for '__kernel' size_t pos = kPos; if (pos >= 2 && source[pos - 1] == '_' && source[pos - 2] == '_') pos -= 2; //check character before 'kernel' (white space expected) size_t wsPos = source.find_last_of(" \t\r\n", pos); if (wsPos == std::string::npos || wsPos + 1 == pos) { //check character after 'kernel' (white space expected) size_t akPos = kPos + sizeof("kernel") - 1; wsPos = source.find_first_of(" \t\r\n", akPos); if (!(wsPos == akPos)) { kPos = source.find("kernel", kPos + 1); continue; } bool attributeFound; do { attributeFound = false; // find '(' after kernel name name size_t pPos = source.find("(", akPos); if (!(pPos != std::string::npos)) continue; // check for not empty kernel name before '(' pos = source.find_last_not_of(" \t\r\n", pPos - 1); if (!(pos != std::string::npos && pos > akPos)) continue; //find character before kernel name wsPos = source.find_last_of(" \t\r\n", pos); if (!(wsPos != std::string::npos && wsPos >= akPos)) continue; std::string name = source.substr(wsPos + 1, pos + 1 - (wsPos + 1)); //check for kernel attribute if (name == "__attribute__") { attributeFound = true; int pCount = 1; akPos = pPos + 1; while (pCount > 0 && akPos != std::string::npos) { akPos = source.find_first_of("()", akPos + 1); if (akPos != std::string::npos) { if (source[akPos] == '(') pCount++; else pCount--; } } } else { kernelsList += name + "."; } } while (attributeFound); } kPos = source.find("kernel", kPos + 1); } std::ostringstream oss; if (MAX_LEN_FOR_KERNEL_LIST > 0) { if (kernelsList.size() > MAX_LEN_FOR_KERNEL_LIST + 1) { kernelsList = kernelsList.substr(0, MAX_LEN_FOR_KERNEL_LIST + 1); kernelsList[kernelsList.size() - 1] = '.'; kernelsList[kernelsList.size() - 1] = '.'; } oss << kernelsList; } return oss.str(); } static std::string get_offline_compilation_file_type_str(const CompilationMode compilationMode) { switch (compilationMode) { default: assert(0 && "Invalid compilation mode"); abort(); case kOnline: assert(0 && "Invalid compilation mode for offline compilation"); abort(); case kBinary: return "binary"; case kSpir_v: return "SPIR-V"; } } static std::string get_unique_filename_prefix(unsigned int numKernelLines, const char *const *kernelProgram, const char *buildOptions) { std::string kernel = get_kernel_content(numKernelLines, kernelProgram); std::string kernelName = get_kernel_name(kernel); cl_uint kernelCrc = crc32(kernel.data(), kernel.size()); std::ostringstream oss; oss << kernelName << std::hex << std::setfill('0') << std::setw(8) << kernelCrc; if(buildOptions) { cl_uint bOptionsCrc = crc32(buildOptions, strlen(buildOptions)); oss << '.' << std::hex << std::setfill('0') << std::setw(8) << bOptionsCrc; } return oss.str(); } static std::string get_cl_build_options_filename_with_path(const std::string& filePath, const std::string& fileNamePrefix) { return filePath + slash + fileNamePrefix + ".options"; } static std::string get_cl_source_filename_with_path(const std::string& filePath, const std::string& fileNamePrefix) { return filePath + slash + fileNamePrefix + ".cl"; } static std::string get_binary_filename_with_path(CompilationMode mode, cl_uint deviceAddrSpaceSize, const std::string& filePath, const std::string& fileNamePrefix) { std::string binaryFilename = filePath + slash + fileNamePrefix; if(kSpir_v == mode) { std::ostringstream extension; extension << ".spv" << deviceAddrSpaceSize; binaryFilename += extension.str(); } return binaryFilename; } static bool file_exist_on_disk(const std::string& filePath, const std::string& fileName) { std::string fileNameWithPath = filePath + slash + fileName; bool exist = false; std::ifstream ifs; ifs.open(fileNameWithPath.c_str(), std::ios::binary); if(ifs.good()) exist = true; ifs.close(); return exist; } static bool should_save_kernel_source_to_disk(CompilationMode mode, CompilationCacheMode cacheMode, const std::string& binaryPath, const std::string& binaryName) { bool saveToDisk = false; if(cacheMode == kCacheModeDumpCl || (cacheMode == kCacheModeOverwrite && mode != kOnline)) { saveToDisk = true; } if(cacheMode == kCacheModeCompileIfAbsent && mode != kOnline) { saveToDisk = !file_exist_on_disk(binaryPath, binaryName); } return saveToDisk; } static int save_kernel_build_options_to_disk(const std::string& path, const std::string& prefix, const char *buildOptions) { std::string filename = get_cl_build_options_filename_with_path(path, prefix); std::ofstream ofs(filename.c_str(), std::ios::binary); if (!ofs.good()) { log_info("Can't save kernel build options: %s\n", filename.c_str()); return -1; } ofs.write(buildOptions, strlen(buildOptions)); ofs.close(); log_info("Saved kernel build options to file: %s\n", filename.c_str()); return CL_SUCCESS; } static int save_kernel_source_to_disk(const std::string& path, const std::string& prefix, const std::string& source) { std::string filename = get_cl_source_filename_with_path(path, prefix); std::ofstream ofs(filename.c_str(), std::ios::binary); if (!ofs.good()) { log_info("Can't save kernel source: %s\n", filename.c_str()); return -1; } ofs.write(source.c_str(), source.size()); ofs.close(); log_info("Saved kernel source to file: %s\n", filename.c_str()); return CL_SUCCESS; } static int save_kernel_source_and_options_to_disk(unsigned int numKernelLines, const char *const *kernelProgram, const char *buildOptions) { int error; std::string kernel = get_kernel_content(numKernelLines, kernelProgram); std::string kernelNamePrefix = get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions); // save kernel source to disk error = save_kernel_source_to_disk(gCompilationCachePath, kernelNamePrefix, kernel); // save kernel build options to disk if exists if (buildOptions != NULL) error |= save_kernel_build_options_to_disk(gCompilationCachePath, kernelNamePrefix, buildOptions); return error; } static std::string get_compilation_mode_str(const CompilationMode compilationMode) { switch (compilationMode) { default: assert(0 && "Invalid compilation mode"); abort(); case kOnline: return "online"; case kBinary: return "binary"; case kSpir_v: return "spir-v"; } } #ifdef KHRONOS_OFFLINE_COMPILER static std::string get_khronos_compiler_command(const cl_uint device_address_space_size, const bool openclCXX, const std::string &bOptions, const std::string &sourceFilename, const std::string &outputFilename) { // Set compiler options // Emit SPIR-V std::string compilerOptions = " -cc1 -emit-spirv"; // <triple>: for 32 bit SPIR-V use spir-unknown-unknown, for 64 bit SPIR-V use spir64-unknown-unknown. if(device_address_space_size == 32) { compilerOptions += " -triple=spir-unknown-unknown"; } else { compilerOptions += " -triple=spir64-unknown-unknown"; } // Set OpenCL C++ flag required by SPIR-V-ready clang (compiler provided by Khronos) if(openclCXX) { compilerOptions = compilerOptions + " -cl-std=c++"; } // Set correct includes if(openclCXX) { compilerOptions += " -I "; compilerOptions += STRINGIFY_VALUE(CL_LIBCLCXX_DIR); } else { compilerOptions += " -include opencl.h"; } #ifdef KHRONOS_OFFLINE_COMPILER_OPTIONS compilerOptions += STRINGIFY_VALUE(KHRONOS_OFFLINE_COMPILER_OPTIONS); #endif // Add build options passed to this function compilerOptions += " " + bOptions; compilerOptions += " " + sourceFilename + " -o " + outputFilename; std::string runString = STRINGIFY_VALUE(KHRONOS_OFFLINE_COMPILER) + compilerOptions; return runString; } #endif // KHRONOS_OFFLINE_COMPILER static cl_int get_cl_device_info_str(const cl_device_id device, const cl_uint device_address_space_size, const CompilationMode compilationMode, std::string &clDeviceInfo) { std::string extensionsString = get_device_extensions_string(device); std::string versionString = get_device_version_string(device); std::ostringstream clDeviceInfoStream; std::string file_type = get_offline_compilation_file_type_str(compilationMode); clDeviceInfoStream << "# OpenCL device info affecting " << file_type << " offline compilation:" << std::endl << "CL_DEVICE_ADDRESS_BITS=" << device_address_space_size << std::endl << "CL_DEVICE_EXTENSIONS=\"" << extensionsString << "\"" << std::endl; /* We only need the device's supported IL version(s) when compiling IL * that will be loaded with clCreateProgramWithIL() */ if (compilationMode == kSpir_v) { std::string ilVersionString = get_device_il_version_string(device); clDeviceInfoStream << "CL_DEVICE_IL_VERSION=\"" << ilVersionString << "\"" << std::endl; } clDeviceInfoStream << "CL_DEVICE_VERSION=\"" << versionString << "\"" << std::endl; clDeviceInfoStream << "CL_DEVICE_IMAGE_SUPPORT=" << (0 == checkForImageSupport(device)) << std::endl; clDeviceInfoStream << "CL_DEVICE_NAME=\"" << get_device_name(device).c_str() << "\"" << std::endl; clDeviceInfo = clDeviceInfoStream.str(); return CL_SUCCESS; } static int write_cl_device_info(const cl_device_id device, const cl_uint device_address_space_size, const CompilationMode compilationMode, std::string &clDeviceInfoFilename) { std::string clDeviceInfo; int error = get_cl_device_info_str(device, device_address_space_size, compilationMode, clDeviceInfo); if (error != CL_SUCCESS) { return error; } cl_uint crc = crc32(clDeviceInfo.data(), clDeviceInfo.size()); /* Get the filename for the clDeviceInfo file. * Note: the file includes the hash on its content, so it is usually unnecessary to delete it. */ std::ostringstream clDeviceInfoFilenameStream; clDeviceInfoFilenameStream << gCompilationCachePath << slash << "clDeviceInfo-"; clDeviceInfoFilenameStream << std::hex << std::setfill('0') << std::setw(8) << crc << ".txt"; clDeviceInfoFilename = clDeviceInfoFilenameStream.str(); if ((size_t) get_file_size(clDeviceInfoFilename) == clDeviceInfo.size()) { /* The CL device info file has already been created. * Nothing to do. */ return 0; } /* The file does not exist or its length is not as expected. Create/overwrite it. */ std::ofstream ofs(clDeviceInfoFilename); if (!ofs.good()) { log_info("OfflineCompiler: can't create CL device info file: %s\n", clDeviceInfoFilename.c_str()); return -1; } ofs << clDeviceInfo; ofs.close(); return CL_SUCCESS; } static std::string get_offline_compilation_command(const cl_uint device_address_space_size, const CompilationMode compilationMode, const std::string &bOptions, const std::string &sourceFilename, const std::string &outputFilename, const std::string &clDeviceInfoFilename) { std::ostringstream wrapperOptions; wrapperOptions << gCompilationProgram << " --mode=" << get_compilation_mode_str(compilationMode) << " --source=" << sourceFilename << " --output=" << outputFilename << " --cl-device-info=" << clDeviceInfoFilename; if (bOptions != "") { // Add build options passed to this function wrapperOptions << " -- " << bOptions; } return wrapperOptions.str(); } static int invoke_offline_compiler(const cl_device_id device, const cl_uint device_address_space_size, const CompilationMode compilationMode, const std::string &bOptions, const std::string &sourceFilename, const std::string &outputFilename, const bool openclCXX) { std::string runString; if (openclCXX) { #ifndef KHRONOS_OFFLINE_COMPILER log_error("CL C++ compilation is not possible: KHRONOS_OFFLINE_COMPILER was not defined.\n"); return CL_INVALID_OPERATION; #else if (compilationMode != kSpir_v) { log_error("Compilation mode must be SPIR-V for Khronos compiler"); return -1; } runString = get_khronos_compiler_command(device_address_space_size, openclCXX, bOptions, sourceFilename, outputFilename); #endif } else { std::string clDeviceInfoFilename; // See cl_offline_compiler-interface.txt for a description of the // format of the CL device information file generated below, and // the internal command line interface for invoking the offline // compiler. cl_int err = write_cl_device_info(device, device_address_space_size, compilationMode, clDeviceInfoFilename); if (err != CL_SUCCESS) { log_error("Failed writing CL device info file\n"); return err; } runString = get_offline_compilation_command(device_address_space_size, compilationMode, bOptions, sourceFilename, outputFilename, clDeviceInfoFilename); } // execute script log_info("Executing command: %s\n", runString.c_str()); fflush(stdout); int returnCode = system(runString.c_str()); if (returnCode != 0) { log_error("ERROR: Command finished with error: 0x%x\n", returnCode); return CL_COMPILE_PROGRAM_FAILURE; } return CL_SUCCESS; } static cl_int get_first_device_id(const cl_context context, cl_device_id &device) { cl_uint numDevices = 0; cl_int error = clGetContextInfo(context, CL_CONTEXT_NUM_DEVICES, sizeof(cl_uint), &numDevices, NULL); test_error(error, "clGetContextInfo failed getting CL_CONTEXT_NUM_DEVICES"); if (numDevices == 0) { log_error("ERROR: No CL devices found\n"); return -1; } std::vector<cl_device_id> devices(numDevices, 0); error = clGetContextInfo(context, CL_CONTEXT_DEVICES, numDevices*sizeof(cl_device_id), &devices[0], NULL); test_error(error, "clGetContextInfo failed getting CL_CONTEXT_DEVICES"); device = devices[0]; return CL_SUCCESS; } static cl_int get_device_address_bits(const cl_device_id device, cl_uint &device_address_space_size) { cl_int error = clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(cl_uint), &device_address_space_size, NULL); test_error(error, "Unable to obtain device address bits"); if (device_address_space_size != 32 && device_address_space_size != 64) { log_error("ERROR: Unexpected number of device address bits: %u\n", device_address_space_size); return -1; } return CL_SUCCESS; } static int get_offline_compiler_output(std::ifstream &ifs, const cl_device_id device, cl_uint deviceAddrSpaceSize, const bool openclCXX, const CompilationMode compilationMode, const std::string &bOptions, const std::string &kernelPath, const std::string &kernelNamePrefix) { std::string sourceFilename = get_cl_source_filename_with_path(kernelPath, kernelNamePrefix); std::string outputFilename = get_binary_filename_with_path(compilationMode, deviceAddrSpaceSize, kernelPath, kernelNamePrefix); ifs.open(outputFilename.c_str(), std::ios::binary); if(!ifs.good()) { std::string file_type = get_offline_compilation_file_type_str(compilationMode); if (gCompilationCacheMode == kCacheModeForceRead) { log_info("OfflineCompiler: can't open cached %s file: %s\n", file_type.c_str(), outputFilename.c_str()); return -1; } else { int error = invoke_offline_compiler(device, deviceAddrSpaceSize, compilationMode, bOptions, sourceFilename, outputFilename, openclCXX); if (error != CL_SUCCESS) return error; // read output file ifs.open(outputFilename.c_str(), std::ios::binary); if (!ifs.good()) { log_info("OfflineCompiler: can't read generated %s file: %s\n", file_type.c_str(), outputFilename.c_str()); return -1; } } } return CL_SUCCESS; } static int create_single_kernel_helper_create_program_offline(cl_context context, cl_device_id device, cl_program *outProgram, unsigned int numKernelLines, const char *const *kernelProgram, const char *buildOptions, const bool openclCXX, CompilationMode compilationMode) { if(kCacheModeDumpCl == gCompilationCacheMode) { return -1; } // Get device CL_DEVICE_ADDRESS_BITS int error; cl_uint device_address_space_size = 0; if (device == NULL) { error = get_first_device_id(context, device); test_error(error, "Failed to get device ID for first device"); } error = get_device_address_bits(device, device_address_space_size); if (error != CL_SUCCESS) return error; // set build options std::string bOptions; bOptions += buildOptions ? std::string(buildOptions) : ""; std::string kernelName = get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions); std::ifstream ifs; error = get_offline_compiler_output(ifs, device, device_address_space_size, openclCXX, compilationMode, bOptions, gCompilationCachePath, kernelName); if (error != CL_SUCCESS) return error; // ----------------------------------------------------------------------------------- // ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT ------------------ // ----------------------------------------------------------------------------------- // Only OpenCL C++ to SPIR-V compilation #if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION) if(openclCXX) { return CL_SUCCESS; } #endif ifs.seekg(0, ifs.end); int length = ifs.tellg(); ifs.seekg(0, ifs.beg); //treat modifiedProgram as input for clCreateProgramWithBinary if (compilationMode == kBinary) { // read binary from file: std::vector<unsigned char> modifiedKernelBuf(length); ifs.read((char *)&modifiedKernelBuf[0], length); ifs.close(); size_t lengths = modifiedKernelBuf.size(); const unsigned char *binaries = { &modifiedKernelBuf[0] }; log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithBinary\n"); *outProgram = clCreateProgramWithBinary(context, 1, &device, &lengths, &binaries, NULL, &error); if (*outProgram == NULL || error != CL_SUCCESS) { print_error(error, "clCreateProgramWithBinary failed"); return error; } } //treat modifiedProgram as input for clCreateProgramWithIL else if (compilationMode == kSpir_v) { // read spir-v from file: std::vector<unsigned char> modifiedKernelBuf(length); ifs.read((char *)&modifiedKernelBuf[0], length); ifs.close(); size_t length = modifiedKernelBuf.size(); log_info("offlineCompiler: clCreateProgramWithSource replaced with clCreateProgramWithIL\n"); *outProgram = clCreateProgramWithIL(context, &modifiedKernelBuf[0], length, &error); if (*outProgram == NULL || error != CL_SUCCESS) { print_error(error, "clCreateProgramWithIL failed"); return error; } } return CL_SUCCESS; } static int create_single_kernel_helper_create_program(cl_context context, cl_device_id device, cl_program *outProgram, unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions, const bool openclCXX, CompilationMode compilationMode) { std::string filePrefix = get_unique_filename_prefix(numKernelLines, kernelProgram, buildOptions); bool shouldSaveToDisk = should_save_kernel_source_to_disk(compilationMode, gCompilationCacheMode, gCompilationCachePath, filePrefix); if(shouldSaveToDisk) { if(CL_SUCCESS != save_kernel_source_and_options_to_disk(numKernelLines, kernelProgram, buildOptions)) { log_error("Unable to dump kernel source to disk"); return -1; } } if (compilationMode == kOnline) { int error = CL_SUCCESS; /* Create the program object from source */ *outProgram = clCreateProgramWithSource(context, numKernelLines, kernelProgram, NULL, &error); if (*outProgram == NULL || error != CL_SUCCESS) { print_error(error, "clCreateProgramWithSource failed"); return error; } return CL_SUCCESS; } else { return create_single_kernel_helper_create_program_offline(context, device, outProgram, numKernelLines, kernelProgram, buildOptions, openclCXX, compilationMode); } } int create_single_kernel_helper_create_program(cl_context context, cl_program *outProgram, unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions, const bool openclCXX) { return create_single_kernel_helper_create_program(context, NULL, outProgram, numKernelLines, kernelProgram, buildOptions, openclCXX, gCompilationMode); } int create_single_kernel_helper_create_program_for_device(cl_context context, cl_device_id device, cl_program *outProgram, unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions, const bool openclCXX) { return create_single_kernel_helper_create_program(context, device, outProgram, numKernelLines, kernelProgram, buildOptions, openclCXX, gCompilationMode); } int create_single_kernel_helper_with_build_options(cl_context context, cl_program *outProgram, cl_kernel *outKernel, unsigned int numKernelLines, const char **kernelProgram, const char *kernelName, const char *buildOptions, const bool openclCXX) { return create_single_kernel_helper(context, outProgram, outKernel, numKernelLines, kernelProgram, kernelName, buildOptions, openclCXX); } // Creates and builds OpenCL C/C++ program, and creates a kernel int create_single_kernel_helper(cl_context context, cl_program *outProgram, cl_kernel *outKernel, unsigned int numKernelLines, const char **kernelProgram, const char *kernelName, const char *buildOptions, const bool openclCXX) { int error; // Create OpenCL C++ program if(openclCXX) { // ----------------------------------------------------------------------------------- // ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT ------------------ // ----------------------------------------------------------------------------------- // Only OpenCL C++ to SPIR-V compilation #if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION) // Save global variable bool tempgCompilationCacheMode = gCompilationCacheMode; // Force OpenCL C++ -> SPIR-V compilation on every run gCompilationCacheMode = kCacheModeOverwrite; #endif error = create_openclcpp_program( context, outProgram, numKernelLines, kernelProgram, buildOptions ); if (error != CL_SUCCESS) { log_error("Create program failed: %d, line: %d\n", error, __LINE__); return error; } // ----------------------------------------------------------------------------------- // ------------- ONLY FOR OPENCL 22 CONFORMANCE TEST 22 DEVELOPMENT ------------------ // ----------------------------------------------------------------------------------- #if defined(DEVELOPMENT) && defined(ONLY_SPIRV_COMPILATION) // Restore global variables gCompilationCacheMode = tempgCompilationCacheMode; log_info("WARNING: KERNEL %s WAS ONLY COMPILED TO SPIR-V\n", kernelName); return error; #endif } // Create OpenCL C program else { error = create_single_kernel_helper_create_program( context, outProgram, numKernelLines, kernelProgram, buildOptions ); if (error != CL_SUCCESS) { log_error("Create program failed: %d, line: %d\n", error, __LINE__); return error; } } // Remove offline-compiler-only build options std::string newBuildOptions; if (buildOptions != NULL) { newBuildOptions = buildOptions; std::string offlineCompierOptions[] = { "-cl-fp16-enable", "-cl-fp64-enable", "-cl-zero-init-local-mem-vars" }; for(auto& s : offlineCompierOptions) { std::string::size_type i = newBuildOptions.find(s); if (i != std::string::npos) newBuildOptions.erase(i, s.length()); } } // Build program and create kernel return build_program_create_kernel_helper( context, outProgram, outKernel, numKernelLines, kernelProgram, kernelName, newBuildOptions.c_str() ); } // Creates OpenCL C++ program int create_openclcpp_program(cl_context context, cl_program *outProgram, unsigned int numKernelLines, const char **kernelProgram, const char *buildOptions) { // Create program return create_single_kernel_helper_create_program( context, NULL, outProgram, numKernelLines, kernelProgram, buildOptions, true, kSpir_v ); } // Builds OpenCL C/C++ program and creates int build_program_create_kernel_helper(cl_context context, cl_program *outProgram, cl_kernel *outKernel, unsigned int numKernelLines, const char **kernelProgram, const char *kernelName, const char *buildOptions) { int error; /* Compile the program */ int buildProgramFailed = 0; int printedSource = 0; error = clBuildProgram(*outProgram, 0, NULL, buildOptions, NULL, NULL); if (error != CL_SUCCESS) { unsigned int i; print_error(error, "clBuildProgram failed"); buildProgramFailed = 1; printedSource = 1; log_error("Build options: %s\n", buildOptions); log_error("Original source is: ------------\n"); for (i = 0; i < numKernelLines; i++) log_error("%s", kernelProgram[i]); } // Verify the build status on all devices cl_uint deviceCount = 0; error = clGetProgramInfo(*outProgram, CL_PROGRAM_NUM_DEVICES, sizeof(deviceCount), &deviceCount, NULL); if (error != CL_SUCCESS) { print_error(error, "clGetProgramInfo CL_PROGRAM_NUM_DEVICES failed"); return error; } if (deviceCount == 0) { log_error("No devices found for program.\n"); return -1; } cl_device_id *devices = (cl_device_id *)malloc(deviceCount * sizeof(cl_device_id)); if (NULL == devices) return -1; BufferOwningPtr<cl_device_id> devicesBuf(devices); memset(devices, 0, deviceCount * sizeof(cl_device_id)); error = clGetProgramInfo(*outProgram, CL_PROGRAM_DEVICES, sizeof(cl_device_id) * deviceCount, devices, NULL); if (error != CL_SUCCESS) { print_error(error, "clGetProgramInfo CL_PROGRAM_DEVICES failed"); return error; } cl_uint z; bool buildFailed = false; for (z = 0; z < deviceCount; z++) { char deviceName[4096] = ""; error = clGetDeviceInfo(devices[z], CL_DEVICE_NAME, sizeof(deviceName), deviceName, NULL); if (error != CL_SUCCESS || deviceName[0] == '\0') { log_error("Device \"%d\" failed to return a name\n", z); print_error(error, "clGetDeviceInfo CL_DEVICE_NAME failed"); } cl_build_status buildStatus; error = clGetProgramBuildInfo(*outProgram, devices[z], CL_PROGRAM_BUILD_STATUS, sizeof(buildStatus), &buildStatus, NULL); if (error != CL_SUCCESS) { print_error(error, "clGetProgramBuildInfo CL_PROGRAM_BUILD_STATUS failed"); return error; } if (buildStatus == CL_BUILD_SUCCESS && buildProgramFailed && deviceCount == 1) { buildFailed = true; log_error("clBuildProgram returned an error, but buildStatus is marked as CL_BUILD_SUCCESS.\n"); } if (buildStatus != CL_BUILD_SUCCESS) { char statusString[64] = ""; if (buildStatus == (cl_build_status)CL_BUILD_SUCCESS) sprintf(statusString, "CL_BUILD_SUCCESS"); else if (buildStatus == (cl_build_status)CL_BUILD_NONE) sprintf(statusString, "CL_BUILD_NONE"); else if (buildStatus == (cl_build_status)CL_BUILD_ERROR) sprintf(statusString, "CL_BUILD_ERROR"); else if (buildStatus == (cl_build_status)CL_BUILD_IN_PROGRESS) sprintf(statusString, "CL_BUILD_IN_PROGRESS"); else sprintf(statusString, "UNKNOWN (%d)", buildStatus); if (buildStatus != CL_BUILD_SUCCESS) log_error("Build not successful for device \"%s\", status: %s\n", deviceName, statusString); size_t paramSize = 0; error = clGetProgramBuildInfo(*outProgram, devices[z], CL_PROGRAM_BUILD_LOG, 0, NULL, &paramSize); if (error != CL_SUCCESS) { print_error(error, "clGetProgramBuildInfo CL_PROGRAM_BUILD_LOG failed"); return error; } std::string log; log.resize(paramSize / sizeof(char)); error = clGetProgramBuildInfo(*outProgram, devices[z], CL_PROGRAM_BUILD_LOG, paramSize, &log[0], NULL); if (error != CL_SUCCESS || log[0] == '\0') { log_error("Device %d (%s) failed to return a build log\n", z, deviceName); if (error) { print_error(error, "clGetProgramBuildInfo CL_PROGRAM_BUILD_LOG failed"); return error; } else { log_error("clGetProgramBuildInfo returned an empty log.\n"); return -1; } } // In this case we've already printed out the code above. if (!printedSource) { unsigned int i; log_error("Original source is: ------------\n"); for (i = 0; i < numKernelLines; i++) log_error("%s", kernelProgram[i]); printedSource = 1; } log_error("Build log for device \"%s\" is: ------------\n", deviceName); log_error("%s\n", log.c_str()); log_error("\n----------\n"); return -1; } } if (buildFailed) { return -1; } /* And create a kernel from it */ if (kernelName != NULL) { *outKernel = clCreateKernel(*outProgram, kernelName, &error); if (*outKernel == NULL || error != CL_SUCCESS) { print_error(error, "Unable to create kernel"); return error; } } return 0; } int get_max_allowed_work_group_size( cl_context context, cl_kernel kernel, size_t *outMaxSize, size_t *outLimits ) { cl_device_id *devices; size_t size, maxCommonSize = 0; int numDevices, i, j, error; cl_uint numDims; size_t outSize; size_t sizeLimit[]={1,1,1}; /* Assume fewer than 16 devices will be returned */ error = clGetContextInfo( context, CL_CONTEXT_DEVICES, 0, NULL, &outSize ); test_error( error, "Unable to obtain list of devices size for context" ); devices = (cl_device_id *)malloc(outSize); BufferOwningPtr<cl_device_id> devicesBuf(devices); error = clGetContextInfo( context, CL_CONTEXT_DEVICES, outSize, devices, NULL ); test_error( error, "Unable to obtain list of devices for context" ); numDevices = (int)( outSize / sizeof( cl_device_id ) ); for( i = 0; i < numDevices; i++ ) { error = clGetDeviceInfo( devices[i], CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof( size ), &size, NULL ); test_error( error, "Unable to obtain max work group size for device" ); if( size < maxCommonSize || maxCommonSize == 0) maxCommonSize = size; error = clGetKernelWorkGroupInfo( kernel, devices[i], CL_KERNEL_WORK_GROUP_SIZE, sizeof( size ), &size, NULL ); test_error( error, "Unable to obtain max work group size for device and kernel combo" ); if( size < maxCommonSize || maxCommonSize == 0) maxCommonSize = size; error= clGetDeviceInfo( devices[i], CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof( numDims ), &numDims, NULL); test_error( error, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS"); sizeLimit[0] = 1; error= clGetDeviceInfo( devices[i], CL_DEVICE_MAX_WORK_ITEM_SIZES, numDims*sizeof(size_t), sizeLimit, NULL); test_error( error, "clGetDeviceInfo failed for CL_DEVICE_MAX_WORK_ITEM_SIZES"); if (outLimits != NULL) { if (i == 0) { for (j=0; j<3; j++) outLimits[j] = sizeLimit[j]; } else { for (j=0; j<(int)numDims; j++) { if (sizeLimit[j] < outLimits[j]) outLimits[j] = sizeLimit[j]; } } } } *outMaxSize = (unsigned int)maxCommonSize; return 0; } extern int get_max_allowed_1d_work_group_size_on_device( cl_device_id device, cl_kernel kernel, size_t *outSize ) { cl_uint maxDim; size_t maxWgSize; size_t *maxWgSizePerDim; int error; error = clGetKernelWorkGroupInfo( kernel, device, CL_KERNEL_WORK_GROUP_SIZE, sizeof( size_t ), &maxWgSize, NULL ); test_error( error, "clGetKernelWorkGroupInfo CL_KERNEL_WORK_GROUP_SIZE failed" ); error = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof( cl_uint ), &maxDim, NULL ); test_error( error, "clGetDeviceInfo CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS failed" ); maxWgSizePerDim = (size_t*)malloc( maxDim * sizeof( size_t ) ); if( !maxWgSizePerDim ) { log_error( "Unable to allocate maxWgSizePerDim\n" ); return -1; } error = clGetDeviceInfo( device, CL_DEVICE_MAX_WORK_ITEM_SIZES, maxDim * sizeof( size_t ), maxWgSizePerDim, NULL ); if( error != CL_SUCCESS) { log_error( "clGetDeviceInfo CL_DEVICE_MAX_WORK_ITEM_SIZES failed\n" ); free( maxWgSizePerDim ); return error; } // "maxWgSize" is limited to that of the first dimension. if( maxWgSize > maxWgSizePerDim[0] ) { maxWgSize = maxWgSizePerDim[0]; } free( maxWgSizePerDim ); *outSize = maxWgSize; return 0; } int get_max_common_work_group_size( cl_context context, cl_kernel kernel, size_t globalThreadSize, size_t *outMaxSize ) { size_t sizeLimit[3]; int error = get_max_allowed_work_group_size( context, kernel, outMaxSize, sizeLimit ); if( error != 0 ) return error; /* Now find the largest factor of globalThreadSize that is <= maxCommonSize */ /* Note for speed, we don't need to check the range of maxCommonSize, b/c once it gets to 1, the modulo test will succeed and break the loop anyway */ for( ; ( globalThreadSize % *outMaxSize ) != 0 || (*outMaxSize > sizeLimit[0]); (*outMaxSize)-- ) ; return 0; } int get_max_common_2D_work_group_size( cl_context context, cl_kernel kernel, size_t *globalThreadSizes, size_t *outMaxSizes ) { size_t sizeLimit[3]; size_t maxSize; int error = get_max_allowed_work_group_size( context, kernel, &maxSize, sizeLimit ); if( error != 0 ) return error; /* Now find a set of factors, multiplied together less than maxSize, but each a factor of the global sizes */ /* Simple case */ if( globalThreadSizes[ 0 ] * globalThreadSizes[ 1 ] <= maxSize ) { if (globalThreadSizes[ 0 ] <= sizeLimit[0] && globalThreadSizes[ 1 ] <= sizeLimit[1]) { outMaxSizes[ 0 ] = globalThreadSizes[ 0 ]; outMaxSizes[ 1 ] = globalThreadSizes[ 1 ]; return 0; } } size_t remainingSize, sizeForThisOne; remainingSize = maxSize; int i, j; for (i=0 ; i<2; i++) { if (globalThreadSizes[i] > remainingSize) sizeForThisOne = remainingSize; else sizeForThisOne = globalThreadSizes[i]; for (; (globalThreadSizes[i] % sizeForThisOne) != 0 || (sizeForThisOne > sizeLimit[i]); sizeForThisOne--) ; outMaxSizes[i] = sizeForThisOne; remainingSize = maxSize; for (j=0; j<=i; j++) remainingSize /=outMaxSizes[j]; } return 0; } int get_max_common_3D_work_group_size( cl_context context, cl_kernel kernel, size_t *globalThreadSizes, size_t *outMaxSizes ) { size_t sizeLimit[3]; size_t maxSize; int error = get_max_allowed_work_group_size( context, kernel, &maxSize, sizeLimit ); if( error != 0 ) return error; /* Now find a set of factors, multiplied together less than maxSize, but each a factor of the global sizes */ /* Simple case */ if( globalThreadSizes[ 0 ] * globalThreadSizes[ 1 ] * globalThreadSizes[ 2 ] <= maxSize ) { if (globalThreadSizes[ 0 ] <= sizeLimit[0] && globalThreadSizes[ 1 ] <= sizeLimit[1] && globalThreadSizes[ 2 ] <= sizeLimit[2]) { outMaxSizes[ 0 ] = globalThreadSizes[ 0 ]; outMaxSizes[ 1 ] = globalThreadSizes[ 1 ]; outMaxSizes[ 2 ] = globalThreadSizes[ 2 ]; return 0; } } size_t remainingSize, sizeForThisOne; remainingSize = maxSize; int i, j; for (i=0 ; i<3; i++) { if (globalThreadSizes[i] > remainingSize) sizeForThisOne = remainingSize; else sizeForThisOne = globalThreadSizes[i]; for (; (globalThreadSizes[i] % sizeForThisOne) != 0 || (sizeForThisOne > sizeLimit[i]); sizeForThisOne--) ; outMaxSizes[i] = sizeForThisOne; remainingSize = maxSize; for (j=0; j<=i; j++) remainingSize /=outMaxSizes[j]; } return 0; } /* Helper to determine if a device supports an image format */ int is_image_format_supported( cl_context context, cl_mem_flags flags, cl_mem_object_type image_type, const cl_image_format *fmt ) { cl_image_format *list; cl_uint count = 0; cl_int err = clGetSupportedImageFormats( context, flags, image_type, 128, NULL, &count ); if( count == 0 ) return 0; list = (cl_image_format*) malloc( count * sizeof( cl_image_format ) ); if( NULL == list ) { log_error( "Error: unable to allocate %ld byte buffer for image format list at %s:%d (err = %d)\n", count * sizeof( cl_image_format ), __FILE__, __LINE__, err ); return 0; } BufferOwningPtr<cl_image_format> listBuf(list); cl_int error = clGetSupportedImageFormats( context, flags, image_type, count, list, NULL ); if( error ) { log_error( "Error: failed to obtain supported image type list at %s:%d (err = %d)\n", __FILE__, __LINE__, err ); return 0; } // iterate looking for a match. cl_uint i; for( i = 0; i < count; i++ ) { if( fmt->image_channel_data_type == list[ i ].image_channel_data_type && fmt->image_channel_order == list[ i ].image_channel_order ) break; } return ( i < count ) ? 1 : 0; } size_t get_pixel_bytes( const cl_image_format *fmt ); size_t get_pixel_bytes( const cl_image_format *fmt ) { size_t chanCount; switch( fmt->image_channel_order ) { case CL_R: case CL_A: case CL_Rx: case CL_INTENSITY: case CL_LUMINANCE: case CL_DEPTH: chanCount = 1; break; case CL_RG: case CL_RA: case CL_RGx: chanCount = 2; break; case CL_RGB: case CL_RGBx: case CL_sRGB: case CL_sRGBx: chanCount = 3; break; case CL_RGBA: case CL_ARGB: case CL_BGRA: case CL_sBGRA: case CL_sRGBA: #ifdef CL_1RGB_APPLE case CL_1RGB_APPLE: #endif #ifdef CL_BGR1_APPLE case CL_BGR1_APPLE: #endif chanCount = 4; break; default: log_error("Unknown channel order at %s:%d!\n", __FILE__, __LINE__ ); abort(); break; } switch( fmt->image_channel_data_type ) { case CL_UNORM_SHORT_565: case CL_UNORM_SHORT_555: return 2; case CL_UNORM_INT_101010: return 4; case CL_SNORM_INT8: case CL_UNORM_INT8: case CL_SIGNED_INT8: case CL_UNSIGNED_INT8: return chanCount; case CL_SNORM_INT16: case CL_UNORM_INT16: case CL_HALF_FLOAT: case CL_SIGNED_INT16: case CL_UNSIGNED_INT16: #ifdef CL_SFIXED14_APPLE case CL_SFIXED14_APPLE: #endif return chanCount * 2; case CL_SIGNED_INT32: case CL_UNSIGNED_INT32: case CL_FLOAT: return chanCount * 4; default: log_error("Unknown channel data type at %s:%d!\n", __FILE__, __LINE__ ); abort(); } return 0; } test_status verifyImageSupport( cl_device_id device ) { int result = checkForImageSupport( device ); if( result == 0 ) { return TEST_PASS; } if( result == CL_IMAGE_FORMAT_NOT_SUPPORTED ) { log_error( "SKIPPED: Device does not supported images as required by this test!\n" ); return TEST_SKIP; } return TEST_FAIL; } int checkForImageSupport( cl_device_id device ) { cl_uint i; int error; /* Check the device props to see if images are supported at all first */ error = clGetDeviceInfo( device, CL_DEVICE_IMAGE_SUPPORT, sizeof( i ), &i, NULL ); test_error( error, "Unable to query device for image support" ); if( i == 0 ) { return CL_IMAGE_FORMAT_NOT_SUPPORTED; } /* So our support is good */ return 0; } int checkFor3DImageSupport( cl_device_id device ) { cl_uint i; int error; /* Check the device props to see if images are supported at all first */ error = clGetDeviceInfo( device, CL_DEVICE_IMAGE_SUPPORT, sizeof( i ), &i, NULL ); test_error( error, "Unable to query device for image support" ); if( i == 0 ) { return CL_IMAGE_FORMAT_NOT_SUPPORTED; } char profile[128]; error = clGetDeviceInfo( device, CL_DEVICE_PROFILE, sizeof(profile ), profile, NULL ); test_error( error, "Unable to query device for CL_DEVICE_PROFILE" ); if( 0 == strcmp( profile, "EMBEDDED_PROFILE" ) ) { size_t width = -1L; size_t height = -1L; size_t depth = -1L; error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(width), &width, NULL ); test_error( error, "Unable to get CL_DEVICE_IMAGE3D_MAX_WIDTH" ); error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(height), &height, NULL ); test_error( error, "Unable to get CL_DEVICE_IMAGE3D_MAX_HEIGHT" ); error = clGetDeviceInfo( device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(depth), &depth, NULL ); test_error( error, "Unable to get CL_DEVICE_IMAGE3D_MAX_DEPTH" ); if( 0 == (height | width | depth )) return CL_IMAGE_FORMAT_NOT_SUPPORTED; } /* So our support is good */ return 0; } size_t get_min_alignment(cl_context context) { static cl_uint align_size = 0; if( 0 == align_size ) { cl_device_id * devices; size_t devices_size = 0; cl_uint result = 0; cl_int error; int i; error = clGetContextInfo (context, CL_CONTEXT_DEVICES, 0, NULL, &devices_size); test_error_ret(error, "clGetContextInfo failed", 0); devices = (cl_device_id*)malloc(devices_size); if (devices == NULL) { print_error( error, "malloc failed" ); return 0; } error = clGetContextInfo (context, CL_CONTEXT_DEVICES, devices_size, (void*)devices, NULL); test_error_ret(error, "clGetContextInfo failed", 0); for (i = 0; i < (int)(devices_size/sizeof(cl_device_id)); i++) { cl_uint alignment = 0; error = clGetDeviceInfo (devices[i], CL_DEVICE_MEM_BASE_ADDR_ALIGN, sizeof(cl_uint), (void*)&alignment, NULL); if (error == CL_SUCCESS) { alignment >>= 3; // convert bits to bytes result = (alignment > result) ? alignment : result; } else print_error( error, "clGetDeviceInfo failed" ); } align_size = result; free(devices); } return align_size; } cl_device_fp_config get_default_rounding_mode( cl_device_id device ) { char profileStr[128] = ""; cl_device_fp_config single = 0; int error = clGetDeviceInfo( device, CL_DEVICE_SINGLE_FP_CONFIG, sizeof( single ), &single, NULL ); if( error ) test_error_ret( error, "Unable to get device CL_DEVICE_SINGLE_FP_CONFIG", 0 ); if( single & CL_FP_ROUND_TO_NEAREST ) return CL_FP_ROUND_TO_NEAREST; if( 0 == (single & CL_FP_ROUND_TO_ZERO) ) test_error_ret( -1, "FAILURE: device must support either CL_DEVICE_SINGLE_FP_CONFIG or CL_FP_ROUND_TO_NEAREST", 0 ); // Make sure we are an embedded device before allowing a pass if( (error = clGetDeviceInfo( device, CL_DEVICE_PROFILE, sizeof( profileStr ), &profileStr, NULL ) )) test_error_ret( error, "FAILURE: Unable to get CL_DEVICE_PROFILE", 0 ); if( strcmp( profileStr, "EMBEDDED_PROFILE" ) ) test_error_ret( error, "FAILURE: non-EMBEDDED_PROFILE devices must support CL_FP_ROUND_TO_NEAREST", 0 ); return CL_FP_ROUND_TO_ZERO; } int checkDeviceForQueueSupport( cl_device_id device, cl_command_queue_properties prop ) { cl_command_queue_properties realProps; cl_int error = clGetDeviceInfo( device, CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, sizeof( realProps ), &realProps, NULL ); test_error_ret( error, "FAILURE: Unable to get device queue properties", 0 ); return ( realProps & prop ) ? 1 : 0; } int printDeviceHeader( cl_device_id device ) { char deviceName[ 512 ], deviceVendor[ 512 ], deviceVersion[ 512 ], cLangVersion[ 512 ]; int error; error = clGetDeviceInfo( device, CL_DEVICE_NAME, sizeof( deviceName ), deviceName, NULL ); test_error( error, "Unable to get CL_DEVICE_NAME for device" ); error = clGetDeviceInfo( device, CL_DEVICE_VENDOR, sizeof( deviceVendor ), deviceVendor, NULL ); test_error( error, "Unable to get CL_DEVICE_VENDOR for device" ); error = clGetDeviceInfo( device, CL_DEVICE_VERSION, sizeof( deviceVersion ), deviceVersion, NULL ); test_error( error, "Unable to get CL_DEVICE_VERSION for device" ); error = clGetDeviceInfo( device, CL_DEVICE_OPENCL_C_VERSION, sizeof( cLangVersion ), cLangVersion, NULL ); test_error( error, "Unable to get CL_DEVICE_OPENCL_C_VERSION for device" ); log_info("Compute Device Name = %s, Compute Device Vendor = %s, Compute Device Version = %s%s%s\n", deviceName, deviceVendor, deviceVersion, ( error == CL_SUCCESS ) ? ", CL C Version = " : "", ( error == CL_SUCCESS ) ? cLangVersion : "" ); return CL_SUCCESS; }
37.276821
170
0.568274
grey-eminence
6dbf6c5ee937acbe14cf2df5cab10e8cdf80ce58
16,728
cpp
C++
PhysX-3.2.4_PC_SDK_Core/Source/PhysXVehicle/src/VehicleUtilTelemetry.cpp
emlowry/AIEFramework
8f1dd02105237e72cfe303ec4c541eea7debd1f7
[ "MIT" ]
null
null
null
PhysX-3.2.4_PC_SDK_Core/Source/PhysXVehicle/src/VehicleUtilTelemetry.cpp
emlowry/AIEFramework
8f1dd02105237e72cfe303ec4c541eea7debd1f7
[ "MIT" ]
null
null
null
PhysX-3.2.4_PC_SDK_Core/Source/PhysXVehicle/src/VehicleUtilTelemetry.cpp
emlowry/AIEFramework
8f1dd02105237e72cfe303ec4c541eea7debd1f7
[ "MIT" ]
3
2017-01-04T19:48:57.000Z
2020-03-24T03:05:27.000Z
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2008-2013 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxVehicleUtilTelemetry.h" #include "PxVehicleSDK.h" #include "PsFoundation.h" #include "PsUtilities.h" #include "stdio.h" #include "CmPhysXCommon.h" namespace physx { #if PX_DEBUG_VEHICLE_ON PxVehicleGraphDesc::PxVehicleGraphDesc() : mPosX(PX_MAX_F32), mPosY(PX_MAX_F32), mSizeX(PX_MAX_F32), mSizeY(PX_MAX_F32), mBackgroundColor(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)), mAlpha(PX_MAX_F32) { } bool PxVehicleGraphDesc::isValid() const { PX_CHECK_AND_RETURN_VAL(mPosX != PX_MAX_F32, "PxVehicleGraphDesc.mPosX must be initialised", false); PX_CHECK_AND_RETURN_VAL(mPosY != PX_MAX_F32, "PxVehicleGraphDesc.mPosY must be initialised", false); PX_CHECK_AND_RETURN_VAL(mSizeX != PX_MAX_F32, "PxVehicleGraphDesc.mSizeX must be initialised", false); PX_CHECK_AND_RETURN_VAL(mSizeY != PX_MAX_F32, "PxVehicleGraphDesc.mSizeY must be initialised", false); PX_CHECK_AND_RETURN_VAL(mBackgroundColor.x != PX_MAX_F32 && mBackgroundColor.y != PX_MAX_F32 && mBackgroundColor.z != PX_MAX_F32, "PxVehicleGraphDesc.mBackgroundColor must be initialised", false); PX_CHECK_AND_RETURN_VAL(mAlpha != PX_MAX_F32, "PxVehicleGraphDesc.mAlpha must be initialised", false); return true; } PxVehicleGraphChannelDesc::PxVehicleGraphChannelDesc() : mMinY(PX_MAX_F32), mMaxY(PX_MAX_F32), mMidY(PX_MAX_F32), mColorLow(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)), mColorHigh(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)), mTitle(NULL) { } bool PxVehicleGraphChannelDesc::isValid() const { PX_CHECK_AND_RETURN_VAL(mMinY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMinY must be initialised", false); PX_CHECK_AND_RETURN_VAL(mMaxY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMaxY must be initialised", false); PX_CHECK_AND_RETURN_VAL(mMidY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMidY must be initialised", false); PX_CHECK_AND_RETURN_VAL(mColorLow.x != PX_MAX_F32 && mColorLow.y != PX_MAX_F32 && mColorLow.z != PX_MAX_F32, "PxVehicleGraphChannelDesc.mColorLow must be initialised", false); PX_CHECK_AND_RETURN_VAL(mColorHigh.x != PX_MAX_F32 && mColorHigh.y != PX_MAX_F32 && mColorHigh.z != PX_MAX_F32, "PxVehicleGraphChannelDesc.mColorHigh must be initialised", false); PX_CHECK_AND_RETURN_VAL(mTitle, "PxVehicleGraphChannelDesc.mTitle must be initialised", false); return true; } PxVehicleGraph::PxVehicleGraph() { mBackgroundMinX=0; mBackgroundMaxX=0; mBackgroundMinY=0; mBackgroundMaxY=0; mSampleTide=0; mBackgroundColor=PxVec3(255,255,255), mBackgroundAlpha=1.0f; for(PxU32 i=0;i<eMAX_NUM_CHANNELS;i++) { mChannelMinY[i]=0; mChannelMaxY[i]=0; mChannelMidY[i]=0; mChannelColorLow[i]=PxVec3(0,0,255); mChannelColorHigh[i]=PxVec3(255,0,0); memset(mChannelSamples[i], 0, sizeof(PxReal)*eMAX_NUM_SAMPLES); } mNumChannels = 0; PX_COMPILE_TIME_ASSERT((size_t)eMAX_NUM_CHANNELS >= (size_t)eMAX_NUM_ENGINE_CHANNELS && (size_t)eMAX_NUM_CHANNELS >= (size_t)eMAX_NUM_WHEEL_CHANNELS); } PxVehicleGraph::~PxVehicleGraph() { } void PxVehicleGraph::setup(const PxVehicleGraphDesc& desc, const eGraphType graphType) { mBackgroundMinX = (desc.mPosX - 0.5f*desc.mSizeX); mBackgroundMaxX = (desc.mPosX + 0.5f*desc.mSizeX); mBackgroundMinY = (desc.mPosY - 0.5f*desc.mSizeY); mBackgroundMaxY = (desc.mPosY + 0.5f*desc.mSizeY); mBackgroundColor=desc.mBackgroundColor; mBackgroundAlpha=desc.mAlpha; mNumChannels = (eGRAPH_TYPE_WHEEL==graphType) ? (PxU32)eMAX_NUM_WHEEL_CHANNELS : (PxU32)eMAX_NUM_ENGINE_CHANNELS; } void PxVehicleGraph::setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel) { PX_ASSERT(channel<eMAX_NUM_CHANNELS); mChannelMinY[channel]=desc.mMinY; mChannelMaxY[channel]=desc.mMaxY; mChannelMidY[channel]=desc.mMidY; PX_CHECK_MSG(mChannelMinY[channel]<=mChannelMidY[channel], "mChannelMinY must be less than or equal to mChannelMidY"); PX_CHECK_MSG(mChannelMidY[channel]<=mChannelMaxY[channel], "mChannelMidY must be less than or equal to mChannelMaxY"); mChannelColorLow[channel]=desc.mColorLow; mChannelColorHigh[channel]=desc.mColorHigh; strcpy(mChannelTitle[channel], desc.mTitle); } void PxVehicleGraph::clearRecordedChannelData() { mSampleTide=0; for(PxU32 i=0;i<eMAX_NUM_CHANNELS;i++) { memset(mChannelSamples[i], 0, sizeof(PxReal)*eMAX_NUM_SAMPLES); } } void PxVehicleGraph::updateTimeSlice(const PxReal* const samples) { mSampleTide++; mSampleTide=mSampleTide%eMAX_NUM_SAMPLES; for(PxU32 i=0;i<mNumChannels;i++) { mChannelSamples[i][mSampleTide]=PxClamp(samples[i],mChannelMinY[i],mChannelMaxY[i]); } } void PxVehicleGraph::computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const { PX_ASSERT(channel<mNumChannels); const PxReal sizeX=mBackgroundMaxX-mBackgroundMinX; const PxReal sizeY=mBackgroundMaxY-mBackgroundMinY; for(PxU32 i=0;i<PxVehicleGraph::eMAX_NUM_SAMPLES;i++) { const PxU32 index=(mSampleTide+1+i)%PxVehicleGraph::eMAX_NUM_SAMPLES; xy[2*i+0]=mBackgroundMinX+sizeX*i/((PxReal)(PxVehicleGraph::eMAX_NUM_SAMPLES)); const PxReal y=(mChannelSamples[channel][index]-mChannelMinY[channel])/(mChannelMaxY[channel]-mChannelMinY[channel]); xy[2*i+1]=mBackgroundMinY+sizeY*y; colors[i]=mChannelSamples[channel][index]<mChannelMidY[channel] ? mChannelColorLow[channel] : mChannelColorHigh[channel]; } strcpy(title,mChannelTitle[channel]); } void PxVehicleGraph::setupEngineGraph (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY, const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow) { PxVehicleGraphDesc desc; desc.mSizeX=sizeX; desc.mSizeY=sizeY; desc.mPosX=posX; desc.mPosY=posY; desc.mBackgroundColor=backgoundColor; desc.mAlpha=0.5f; setup(desc,PxVehicleGraph::eGRAPH_TYPE_ENGINE); //Engine revs { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=800.0f; desc2.mMidY=400.0f; char title[64]; sprintf(title, "engineRevs"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_ENGINE_REVS); } //Engine torque { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=1000.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "engineDriveTorque"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_ENGINE_DRIVE_TORQUE); } //Clutch slip { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-200.0f; desc2.mMaxY=200.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "clutchSlip"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_CLUTCH_SLIP); } //Accel control { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=1.1f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "accel"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_ACCEL_CONTROL); } //Brake control { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=1.1f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "brake/tank brake left"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_BRAKE_CONTROL); } //HandBrake control { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=1.1f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "handbrake/tank brake right"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_HANDBRAKE_CONTROL); } //Steer control { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-1.1f; desc2.mMaxY=1.1f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "steerLeft/tank thrust left"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_STEER_LEFT_CONTROL); } //Steer control { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-1.1f; desc2.mMaxY=1.1f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "steerRight/tank thrust right"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_STEER_RIGHT_CONTROL); } //Gear { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-4.f; desc2.mMaxY=20.f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "gearRatio"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_GEAR_RATIO); } } void PxVehicleGraph::setupWheelGraph (const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY, const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow) { PxVehicleGraphDesc desc; desc.mSizeX=sizeX; desc.mSizeY=sizeY; desc.mPosX=posX; desc.mPosY=posY; desc.mBackgroundColor=backgoundColor; desc.mAlpha=0.5f; setup(desc,PxVehicleGraph::eGRAPH_TYPE_WHEEL); //Jounce data channel { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-0.2f; desc2.mMaxY=0.4f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "suspJounce"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_JOUNCE); } //Jounce susp force channel { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=20000.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "suspForce"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_SUSPFORCE); } //Tire load channel. { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=20000.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "tireLoad"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_TIRELOAD); } //Normalised tire load channel. { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=3.0f; desc2.mMidY=1.0f; char title[64]; sprintf(title, "normTireLoad"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_NORMALIZED_TIRELOAD); } //Wheel omega channel { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-50.0f; desc2.mMaxY=250.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "wheelOmega"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_WHEEL_OMEGA); } //Tire friction { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=1.1f; desc2.mMidY=1.0f; char title[64]; sprintf(title, "friction"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_TIRE_FRICTION); } //Tire long slip { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-0.2f; desc2.mMaxY=0.2f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "tireLongSlip"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_TIRE_LONG_SLIP); } //Normalised tire long force { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=2.0f; desc2.mMidY=1.0f; char title[64]; sprintf(title, "normTireLongForce"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_NORM_TIRE_LONG_FORCE); } //Tire lat slip { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=-1.0f; desc2.mMaxY=1.0f; desc2.mMidY=0.0f; char title[64]; sprintf(title, "tireLatSlip"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_TIRE_LAT_SLIP); } //Normalised tire lat force { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=2.0f; desc2.mMidY=1.0f; char title[64]; sprintf(title, "normTireLatForce"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_NORM_TIRE_LAT_FORCE); } //Normalized aligning moment { PxVehicleGraphChannelDesc desc2; desc2.mColorHigh=lineColorHigh; desc2.mColorLow=lineColorLow; desc2.mMinY=0.0f; desc2.mMaxY=2.0f; desc2.mMidY=1.0f; char title[64]; sprintf(title, "normTireAlignMoment"); desc2.mTitle=title; setChannel(desc2,PxVehicleGraph::eCHANNEL_NORM_TIRE_ALIGNING_MOMENT); } } PxVehicleTelemetryData* physx::PxVehicleTelemetryData::allocate(const PxU32 numWheels) { //Work out the byte size required. PxU32 size = sizeof(PxVehicleTelemetryData); size += sizeof(PxVehicleGraph); //engine graph size += sizeof(PxVehicleGraph)*numWheels; //wheel graphs size += sizeof(PxVec3)*numWheels; //tire force app points size += sizeof(PxVec3)*numWheels; //susp force app points //Allocate the memory. PxVehicleTelemetryData* vehTelData=(PxVehicleTelemetryData*)PX_ALLOC(size, PX_DEBUG_EXP("PxVehicleNWTelemetryData")); //Patch up the pointers. PxU8* ptr = (PxU8*)vehTelData + sizeof(PxVehicleTelemetryData); vehTelData->mEngineGraph = (PxVehicleGraph*)ptr; ptr += sizeof(PxVehicleGraph); vehTelData->mWheelGraphs = (PxVehicleGraph*)ptr; ptr += sizeof(PxVehicleGraph)*numWheels; vehTelData->mSuspforceAppPoints = (PxVec3*)ptr; ptr += sizeof(PxVec3)*numWheels; vehTelData->mTireforceAppPoints = (PxVec3*)ptr; ptr += sizeof(PxVec3)*numWheels; //Set the number of wheels in each structure that needs it. vehTelData->mNumActiveWheels=numWheels; //Finished. return vehTelData; } void PxVehicleTelemetryData::free() { PX_FREE(this); } void physx::PxVehicleTelemetryData::setup (const PxF32 graphSizeX, const PxF32 graphSizeY, const PxF32 engineGraphPosX, const PxF32 engineGraphPosY, const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY, const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow) { mEngineGraph->setupEngineGraph (graphSizeX, graphSizeY, engineGraphPosX, engineGraphPosY, backgroundColor, lineColorHigh, lineColorLow); const PxU32 numActiveWheels=mNumActiveWheels; for(PxU32 k=0;k<numActiveWheels;k++) { mWheelGraphs[k].setupWheelGraph (graphSizeX, graphSizeY, wheelGraphPosX[k], wheelGraphPosY[k], backgroundColor, lineColorHigh, lineColorLow); mTireforceAppPoints[k]=PxVec3(0,0,0); mSuspforceAppPoints[k]=PxVec3(0,0,0); } } void physx::PxVehicleTelemetryData::clear() { mEngineGraph->clearRecordedChannelData(); const PxU32 numActiveWheels=mNumActiveWheels; for(PxU32 k=0;k<numActiveWheels;k++) { mWheelGraphs[k].clearRecordedChannelData(); mTireforceAppPoints[k]=PxVec3(0,0,0); mSuspforceAppPoints[k]=PxVec3(0,0,0); } } #endif //PX_DEBUG_VEHICLE_ON } //physx
29.712256
197
0.768472
emlowry
6dc1a8199499ee8c92a8148cb62899af2b4c3cbc
12,963
cpp
C++
src/alns/PALNS-CVRP/Route.cpp
alberto-santini/cvrp-decomposition
854d2b5b7cdd51fe4ab46acac7d88dbc7e5bfb88
[ "MIT" ]
null
null
null
src/alns/PALNS-CVRP/Route.cpp
alberto-santini/cvrp-decomposition
854d2b5b7cdd51fe4ab46acac7d88dbc7e5bfb88
[ "MIT" ]
null
null
null
src/alns/PALNS-CVRP/Route.cpp
alberto-santini/cvrp-decomposition
854d2b5b7cdd51fe4ab46acac7d88dbc7e5bfb88
[ "MIT" ]
null
null
null
// @@@ Notice! the savings algorithm assumes symmetric costs! #include "Route.h" // From SRP-Utils #include "Utils.h" #include "VectorUtils.h" Route::Route(const CVRPInstance& instance) : m_pInstance(&instance), m_pMatDists(&(instance.getDists())) { int iN = instance.getN(); m_vecRoute.push_back(0); m_vecRoute.push_back(iN + 1); m_iLoad = 0; m_dCost = m_pMatDists->getElement(0, iN + 1); m_dDuration = m_pMatDists->getElement(0, iN + 1); m_dToleranceEps = 1E-7; } /*********************************************************************** * bool Route::removeCustomer(int iPos) * * remove the customer at position <iPos> * * --- input parameters --- * iPos : The position of the customer to remove * iPos = 0 is invalid (position 0 is occupied by the depot). * --- output parameters --- * --- return value --- ***********************************************************************/ void Route::removeCustomer(int iPos) { #ifdef _DEBUG if(iPos <= 0 || iPos >= (int)m_vecRoute.size() - 1) error("Route::removeCustomer(...)", "remove position out of range "); #endif int iCustId = m_vecRoute[iPos]; double inc = m_pMatDists->getElement(m_vecRoute[iPos - 1], m_vecRoute[iPos + 1]) - m_pMatDists->getElement(m_vecRoute[iPos - 1], iCustId) - m_pMatDists->getElement(iCustId, m_vecRoute[iPos + 1]); m_dCost += inc; m_iLoad -= m_pInstance->getDemand(iCustId); m_dDuration += inc; m_dDuration -= m_pInstance->getServiceTime(iCustId); m_vecRoute.erase(m_vecRoute.begin() + iPos); } // Go through the route and removes customers if vecIsCustRemoved[id] == true // where <id> is the id of the customer. The method returns the number of customers removed. void Route::removeCustomers(const vector<bool>& vecIsCustRemoved, vector<int>& vecRemovedCusts) { vecRemovedCusts.clear(); assert((int)vecIsCustRemoved.size() >= (m_pInstance->getN() + 1)); vector<int> vecNewRoute(m_vecRoute.size()); vecNewRoute[0] = 0; int iOrigIdx, iNewIdx = 1; // Don't look at the last element in the route (it's the end depot). int iOrigLastIdx = (int)m_vecRoute.size() - 1; // dDelta : change in distance. double dDelta = 0; int iServTimeDelta = 0; for(iOrigIdx = 1; iOrigIdx < iOrigLastIdx; ++iOrigIdx) { // If the customer at position <iOrigIdx> hasn't been removed, then // copy it to the new route. if(!vecIsCustRemoved[m_vecRoute[iOrigIdx]]) { vecNewRoute[iNewIdx] = m_vecRoute[iOrigIdx]; ++iNewIdx; } else { // Customer is removed. Update delta and load. int iCustId = m_vecRoute[iOrigIdx]; dDelta += m_pMatDists->getElement(vecNewRoute[iNewIdx - 1], m_vecRoute[iOrigIdx + 1]) - m_pMatDists->getElement(vecNewRoute[iNewIdx - 1], iCustId) - m_pMatDists->getElement(iCustId, m_vecRoute[iOrigIdx + 1]); m_iLoad -= m_pInstance->getDemand(iCustId); iServTimeDelta -= m_pInstance->getServiceTime(iCustId); vecRemovedCusts.push_back(iCustId); } } m_dCost += dDelta; m_dDuration += dDelta + iServTimeDelta; vecNewRoute[iNewIdx] = m_pInstance->getN() + 1; ++iNewIdx; // Shrink the new vector. vecNewRoute.resize(iNewIdx); m_vecRoute.swap(vecNewRoute); } void Route::removeSequence(int iStartPos, int iNToRemove) { double dDeltaDist = 0; int iServTimeDelta = 0; int iDeltaLoad = 0; int i; for(i = 0; i < iNToRemove; ++i) { int iPos = iStartPos + i; dDeltaDist -= m_pMatDists->getElement(m_vecRoute[iPos - 1], m_vecRoute[iPos]); iServTimeDelta -= m_pInstance->getServiceTime(m_vecRoute[iPos]); iDeltaLoad -= m_pInstance->getDemand(m_vecRoute[iPos]); } dDeltaDist -= m_pMatDists->getElement(m_vecRoute[iStartPos + iNToRemove - 1], m_vecRoute[iStartPos + iNToRemove]); dDeltaDist += m_pMatDists->getElement(m_vecRoute[iStartPos - 1], m_vecRoute[iStartPos + iNToRemove]); m_dCost += dDeltaDist; m_iLoad += iDeltaLoad; m_dDuration += dDeltaDist + iServTimeDelta; m_vecRoute.erase(m_vecRoute.begin() + iStartPos, m_vecRoute.begin() + (iStartPos + iNToRemove)); } void Route::concatRoute(const Route& otherRoute) { // cout << "concatRoute" << endl; int iN = m_pInstance->getN(); double saving = m_pMatDists->getElement(getLastCustomer(), otherRoute.getFirstCustomer()) - m_pMatDists->getElement(getLastCustomer(), iN + 1) - m_pMatDists->getElement(0, otherRoute.getFirstCustomer()); m_dCost += otherRoute.getCost() + saving; m_iLoad += otherRoute.getLoad(); m_dDuration += otherRoute.getDuration() + saving; m_vecRoute.insert(m_vecRoute.begin() + size() - 1, otherRoute.m_vecRoute.begin() + 1, otherRoute.m_vecRoute.begin() + otherRoute.size() - 1); } // concatenate <otherRoute> to this route, inversing the order of <otherRoute> void Route::concatRouteInv(const Route& otherRoute) { // cout << "concatRouteInv" << endl; int iN = m_pInstance->getN(); double saving = m_pMatDists->getElement(getLastCustomer(), otherRoute.getLastCustomer()) - m_pMatDists->getElement(getLastCustomer(), iN + 1) - m_pMatDists->getElement(otherRoute.getLastCustomer(), iN + 1); m_dCost += otherRoute.getCost() + saving; m_iLoad += otherRoute.getLoad(); m_dDuration += otherRoute.getDuration() + saving; int i; m_vecRoute.pop_back(); for(i = otherRoute.size() - 2; i > 0; i--) m_vecRoute.push_back(otherRoute.getNodeId(i)); m_vecRoute.push_back(iN + 1); } // concatenate <otherRoute> to this route, inversing the order of <this> route void Route::concatRouteInvThis(const Route& otherRoute) { // cout << "concatRouteInvThis" << endl; int iN = m_pInstance->getN(); double saving = m_pMatDists->getElement(getFirstCustomer(), otherRoute.getFirstCustomer()) - m_pMatDists->getElement(0, getFirstCustomer()) - m_pMatDists->getElement(0, otherRoute.getFirstCustomer()); m_dCost += otherRoute.getCost() + saving; m_iLoad += otherRoute.getLoad(); m_dDuration += otherRoute.getDuration() + saving; reverse(m_vecRoute.begin(), m_vecRoute.end()); // Now the first node on m_vecRoute is n+1 and the last node is 0. Correct this: m_vecRoute.front() = 0; m_vecRoute.back() = iN + 1; m_vecRoute.insert(m_vecRoute.begin() + size() - 1, otherRoute.m_vecRoute.begin() + 1, otherRoute.m_vecRoute.begin() + otherRoute.size() - 1); } void Route::consCalc() { int iPos, iNodeId; int iMaxPos = (int)m_vecRoute.size(); assert(iMaxPos >= 2); double dDist = 0; int iServTime = 0; int iLoad = 0; for(iPos = 1; iPos < iMaxPos; iPos++) { iNodeId = m_vecRoute[iPos]; dDist += m_pMatDists->getElement(m_vecRoute[iPos - 1], iNodeId); iServTime += m_pInstance->getServiceTime(iNodeId); iLoad += m_pInstance->getDemand(iNodeId); } if(iLoad > m_pInstance->getMaxLoad()) { assert(false); error("Route::consCalc()", "Load is violated"); } if(dDist + iServTime > m_pInstance->getMaxDuration()) error("Route::consCalc()", "Duration is violated"); if(iLoad != m_iLoad) error("Route::consCalc()", "Calculated (" + int2String(iLoad) + ") and stored load (" + int2String(m_iLoad) + ") mismatch!"); if(fabs(dDist - m_dCost) > m_dToleranceEps) { assert(false); error("Route::consCalc()", "Calculated and stored cost mismatch!"); } if(fabs(dDist + iServTime - m_dDuration) > m_dToleranceEps) error("Route::consCalc()", "Calculated and stored duration mismatch!"); // Use the calculated distance. It is most precise (it's the result of the fewest number // of calculations). m_dCost = dDist; m_dDuration = dDist + iServTime; } // Perform two opt local search on the route. Return true iff the route was improved. // The method only works for symmetric distances. bool Route::twoOpt(double dImproveEps) { #ifndef BATCH_MODE consCalc(); #endif int i, j, iBestI, iBestJ; int iRouteLength = (int)m_vecRoute.size(); bool bImproved = false; bool bImprovedThisIter; do { bImprovedThisIter = false; double dBestDelta = DBL_MAX; // i indexes the first edge to remove. We are removing the edge (m_vecRoute[i-1], m_vecRoute[i]), that is // the edge between the (i-1)'th and i'th node in the tour. As the last node in the tour is node // iRouteLength-1 and there has to be one edge between the two edges removed the last edge in the tour that // can be the "first edge" is the joining the (iRouteLength-4)'th and (iRouteLength-3)'th nodes as the // second edge will joing ((iRouteLength-2)'th and (iRouteLength-1)'th for(i = 1; i <= iRouteLength - 3; i++) { // i indexes the second edge to remove. We are removing the edge between the (j-1)'th and j'th node in the tour. for(j = i + 2; j <= iRouteLength - 1; j++) { double dDelta = -m_pMatDists->getElement(m_vecRoute[i - 1], m_vecRoute[i]) - m_pMatDists->getElement(m_vecRoute[j - 1], m_vecRoute[j]) + m_pMatDists->getElement(m_vecRoute[i - 1], m_vecRoute[j - 1]) + m_pMatDists->getElement(m_vecRoute[i], m_vecRoute[j]); // DISTANCE MATRIX NOT SYMMETRIC => NEED THIS: for(auto k = i; k < j - 1; ++k) { dDelta -= m_pMatDists->getElement(m_vecRoute[k], m_vecRoute[k + 1]); dDelta += m_pMatDists->getElement(m_vecRoute[k + 1], m_vecRoute[k]); } if(dDelta < dBestDelta) { dBestDelta = dDelta; iBestI = i; iBestJ = j; } } } if(dBestDelta < -dImproveEps) { #ifndef BATCH_MODE consCalc(); #endif bImproved = true; bImprovedThisIter = true; do2optMove(iBestI, iBestJ); #ifndef BATCH_MODE consCalc(); #endif } } while(bImprovedThisIter); return bImproved; } void Route::do2optMove(int i, int j) { assert(i < j); double dDelta = -m_pMatDists->getElement(m_vecRoute[i - 1], m_vecRoute[i]) - m_pMatDists->getElement(m_vecRoute[j - 1], m_vecRoute[j]) + m_pMatDists->getElement(m_vecRoute[i - 1], m_vecRoute[j - 1]) + m_pMatDists->getElement(m_vecRoute[i], m_vecRoute[j]); // DISTANCE MATRIX NOT SYMMETRIC => NEED THIS: for(auto k = i; k < j - 1; ++k) { dDelta -= m_pMatDists->getElement(m_vecRoute[k], m_vecRoute[k + 1]); dDelta += m_pMatDists->getElement(m_vecRoute[k + 1], m_vecRoute[k]); } m_dCost += dDelta; m_dDuration += dDelta; // Update the route. All that the 2 opt move does is reversing the segment // (r[i], r[i+1], ... r[j-1]) where r[i] is the node at position i in the route. reverse(m_vecRoute.begin() + i, m_vecRoute.begin() + j); } // Set the nodes of this route to be the nodes of <vecNodes> void Route::setNodes(const vector<int>& vecNodes) { assert(vecNodes.size() >= 2); assert(vecNodes.front() == 0); assert(vecNodes.back() == m_pInstance->getN() + 1); m_vecRoute.assign(vecNodes.begin(), vecNodes.end()); int iPos, iNodeId; int iMaxPos = (int)m_vecRoute.size(); double dDist = 0; int iServTime = 0; m_iLoad = 0; for(iPos = 1; iPos < iMaxPos; iPos++) { iNodeId = m_vecRoute[iPos]; dDist += m_pMatDists->getElement(m_vecRoute[iPos - 1], iNodeId); iServTime += m_pInstance->getServiceTime(iNodeId); m_iLoad += m_pInstance->getDemand(iNodeId); } m_dCost = dDist; m_dDuration = dDist + iServTime; } // Set the customers of this route to be those of <vecCustomers> // (the method is similar to <setNodes(...)>, but in the method below <vecCustomers> should not contain the start and end depot). void Route::setCustomers(const vector<int>& vecCustomers) { assert(vecCustomers.front() != 0); assert(vecCustomers.back() != m_pInstance->getN() + 1); m_vecRoute.clear(); m_vecRoute.push_back(0); m_vecRoute.insert(m_vecRoute.end(), vecCustomers.begin(), vecCustomers.end()); m_vecRoute.push_back(m_pInstance->getN() + 1); consCalc(); } ostream& operator<<(ostream& os, const Route& route) { os << "{ "; outputVector(os, route.m_vecRoute); os << " }, cost: " << route.getCost() << ", load: " << route.getLoad() << ", duration: " << route.getDuration(); return os; }
41.816129
161
0.615598
alberto-santini