blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
620070710c2102ba0dadeead818a94a16ba19f5a
a4a2e3d07360c472dc8ada66d50953373af65026
/DOA/LinkedLists/Node.h
d9cdbf1a8b00ae0c8794d5b8082ef8fcaa4e2221
[]
no_license
Todtaure/IKT6
7b433c447f351ca181b59f396757b8ee97ad84a2
1c4ba6a17a469b19c7d92f4420360fd827f385fc
refs/heads/master
2016-09-06T16:15:07.383941
2015-04-16T13:40:00
2015-04-16T13:40:00
29,924,420
0
0
null
null
null
null
UTF-8
C++
false
false
153
h
Node.h
#pragma once template <typename T> class Node { public: Node(T i = T(), Node* n = nullptr) :info(i), next(n){} ~Node(){} T info; Node* next; };
5019874b06f6c511e92972da4840ec528d043849
1ae0e562962e638b9087beb2e747e17f53d43e5d
/test/TestIssue.cpp
658f5cfbd822169bc5fede12385e53d0aff667c3
[]
no_license
strinsberg/tracker-express
f62278447d8bf5b765997c0a6ddd10857718dca9
f79304a9da9f4b2b37a88ad11eea89272256b06d
refs/heads/master
2022-12-19T06:10:00.450083
2020-09-26T05:16:32
2020-09-26T05:16:32
226,718,639
0
0
null
null
null
null
UTF-8
C++
false
false
2,472
cpp
TestIssue.cpp
#include "gtest/gtest.h" #include "Issue.h" #include "Status.h" TEST(TestIssue, testTitle) { Issue i(1); i.setTitle("Test"); EXPECT_EQ("Test", i.getTitle()); } TEST(TestIssue, testDescription) { Issue i(1); i.setDescription("Test"); EXPECT_EQ("Test", i.getDescription()); } TEST(TestIssue, testAssignee) { Issue i(1); i.setAssignee(0); EXPECT_EQ(0, i.getAssignee()); } TEST(TestIssue, testTag) { Issue i(1); i.addTag("Test"); EXPECT_EQ("Test", i.getTagAtPos(0)); } TEST(TestIssue, testTag2) { Issue i(1); i.addTag("Test"); EXPECT_EQ("Test", i.getTags().at(0)); } TEST(TestIssue, testPriority) { Issue i(1); i.setPriority(1); EXPECT_EQ(1, i.getPriority()); } TEST(TestIssue, testIdGetter) { Issue i(1); EXPECT_EQ(1, i.getId()); } TEST(TestIssue, testCreator) { Issue i(1); i.setCreator(42); EXPECT_EQ(42, i.getCreator()); } TEST(TestIssue, testStatus) { Issue i(1); i.setStatus(Status::NEW); EXPECT_EQ(Status::NEW, i.getStatus()); } TEST(TestIssue, test_update_title_desc_priority) { Issue iss(1); nlohmann::json data = { {"title", "some new title"}, {"description", "trying to figure it out"}, {"priority", 30}, }; iss.update(data.dump()); EXPECT_EQ("some new title", iss.getTitle()); EXPECT_EQ("trying to figure it out", iss.getDescription()); EXPECT_EQ(30, iss.getPriority()); } TEST(TestIssue, test_update_assignee_creator_status) { Issue iss(1); nlohmann::json data = { {"assignee", 3}, {"creator", 2}, {"status", 1}, }; iss.update(data.dump()); EXPECT_EQ(3, iss.getAssignee()); EXPECT_EQ(2, iss.getCreator()); EXPECT_EQ(Status::ASSIGNED, iss.getStatus()); } TEST(TestIssue, test_update_assignee_creator_status_minus) { Issue iss(1); nlohmann::json data = { {"assignee", -1}, {"creator", 2}, {"status", 1}, }; iss.update(data.dump()); EXPECT_EQ(-1, iss.getAssignee()); EXPECT_EQ(2, iss.getCreator()); EXPECT_EQ(0, iss.getStatus()); } TEST(TestIssue, test_to_json_string) { Issue iss(1); auto data = iss.toJson(); EXPECT_EQ(1, data["id"]); EXPECT_EQ("empty", data["title"]); EXPECT_EQ("empty", data["description"]); EXPECT_EQ(-1, data["assignee"]); EXPECT_EQ(-1, data["creator"]); EXPECT_EQ(-1, data["priority"]); // add tags when they are ready }
4fa2d0801bc17f15704ed1a8231447f49f0fd16c
d8944e9d8edaea7a73c49ce87aecfdf6a53faa9c
/Src/ApkFactory/Adapter/TableContralAdapterRes.h
828c64d6e8c0b0d41a44bb14c31c1e8cc58666d8
[]
no_license
xubingyue/AutopackingAndroid
d67f9c0875e0321f80c85479ff1d6ceedef517eb
8e82926933cab0568617f9d5400e223c4bae5b6b
refs/heads/master
2021-06-02T19:58:56.048240
2016-08-01T08:54:47
2016-08-01T08:54:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
326
h
TableContralAdapterRes.h
#ifndef TABLE_CONTRAL_ADAPTER_RES_H #define TABLE_CONTRAL_ADAPTER_RES_H #include <QModelIndex> #include "Interface/ITableContral.h" class TableContralAdapterRes :public ITableContral { public: void AddRow(); void DelRow(QModelIndexList &selecteds); void DoubleClick(const QModelIndex &index); protected: private: }; #endif
6c905759f6f174a86131ace301f4f06d143a6892
05078aaa6f2863671525c2cb4771f61726285f5d
/debug/MSVC_Hubert/HLS/internal/_hls_float_X86-64.h
f86de2f8e42604d3191e419b00dcf6e53a703324
[]
no_license
DeanKamen/I-BERT_in_C
59a01694c832af811e28f13fe05d3a66660597b7
dbec32eeba175936aa4ba30acd123fac54cd6572
refs/heads/main
2023-08-07T18:34:23.735367
2021-09-20T15:19:59
2021-09-20T15:19:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
29,339
h
_hls_float_X86-64.h
/* Copyright 1992-2021 Intel Corporation. */ /* */ /* This software and the related documents are Intel copyrighted */ /* materials, and your use of them is governed by the express license */ /* under which they were provided to you ("License"). Unless the License */ /* provides otherwise, you may not use, modify, copy, publish, */ /* distribute, disclose or transmit this software or the related */ /* documents without Intel's prior written permission. */ /* */ /* This software and the related documents are provided as is, with no */ /* express or implied warranties, other than those that are expressly */ /* stated in the License. */ #ifndef _INTEL_IHC_HLS_INTERNAL_HLS_FLOAT_X86_64 #define _INTEL_IHC_HLS_INTERNAL_HLS_FLOAT_X86_64 #include "HLS/internal/_hls_float_interface.h" #include "_hls_float_common_inc.h" #include <cassert> #include <iostream> #include <limits> namespace ihc { namespace internal { using RD_t = fp_config::FP_Round; namespace { // Copy an ac_int to an unsigned char array template <int N> void copy_ac_int_to_array(const ac_int<N, false> &ac_val, hls_vpfp_intermediate_ty::inter_storage_ty *arr_val, int num_chars) { assert(num_chars == (N / 8 + (N % 8 > 0))); for (int idx = 0; (idx * 8) < N; idx++) { arr_val[idx] = ac_val.template slc<8>(8 * idx); } } // Copy an unsigned char array into an ac_int template <int N> void copy_array_to_ac_int( const hls_vpfp_intermediate_ty::inter_storage_ty *arr_val, ac_int<N, false> &ac_val, int num_chars) { assert(num_chars == (N / 8 + (N % 8 > 0))); static_assert(sizeof(hls_vpfp_intermediate_ty::inter_storage_ty) == 1, "Currently, only char arrays are supported."); for (int idx = 0; (idx * 8) < N; idx++) { if (N - idx * 8 >= 8) { // Set 8 bits at a time to set the underlying ac_int ac_val.set_slc(8 * idx, ac_int<8, false>(arr_val[idx])); } else { // In case we have fewer than 8 bits left, set the remaining bits. // Note that the last_size is set to 1 in case N % 8 == 0 since we would // get a compile time error otherwise. In this case, this code is never // exercised. constexpr int last_size = N % 8 ? N % 8 : 1; constexpr unsigned bit_mask = (1 << last_size) - 1; ac_val.set_slc(8 * idx, ac_int<last_size, false>(arr_val[idx] & bit_mask)); } } } // Convert hls_float --> vpfp_intermediate_ty template <int E, int M, RD_t Rnd> void convert_hls_float_to_vpfp_inter(const hls_float<E, M, Rnd> &input, hls_vpfp_intermediate_ty &output) { constexpr int m_chars = M / (8 * sizeof(hls_vpfp_intermediate_ty::inter_storage_ty)) + ((M % (8 * sizeof(hls_vpfp_intermediate_ty::inter_storage_ty))) > 0); constexpr int e_chars = E / (8 * sizeof(hls_vpfp_intermediate_ty::inter_storage_ty)) + ((E % (8 * sizeof(hls_vpfp_intermediate_ty::inter_storage_ty))) > 0); copy_ac_int_to_array(input.get_exponent(), output.get_exponent(), e_chars); copy_ac_int_to_array(input.get_mantissa(), output.get_mantissa(), m_chars); output.set_sign_bit(input.get_sign_bit()); } // Convert vpfp_intermediate_ty -> hls_float template <int E, int M, RD_t Rnd> void convert_vpfp_inter_to_hls_float(const hls_vpfp_intermediate_ty &input, hls_float<E, M, Rnd> &output) { ac_int<M, false> mantissa; ac_int<E, false> exponent; copy_array_to_ac_int(input.get_mantissa(), mantissa, input.get_mantissa_words()); copy_array_to_ac_int(input.get_exponent(), exponent, input.get_exponent_words()); output.set_exponent(exponent); output.set_mantissa(mantissa); output.set_sign_bit(input.get_sign_bit()); } } // namespace // between hls_float type conversions template <int Ein, int Min, int Eout, int Mout, RD_t Rin, RD_t Rout> inline void hls_vpfp_cast(const hls_float<Ein, Min, Rin> &from, hls_float<Eout, Mout, Rout> &to) { if (Ein == Eout && Min == Mout) { to.set_bits(from.get_bits()); } // 4 == RoundtoZero in hls_float.h else if (Rout == 4) { // We decide to implement RoundToZero in source because // the logic is fairly simple and can be easily const-propagated hls_vpfp_trunc_convert(from, to); } else { hls_vpfp_intermediate_ty input_m(Ein, Min), output_m(Eout, Mout); convert_hls_float_to_vpfp_inter(from, input_m); // Flush subnormals when the output size is smaller than the input type, // but not the other way around if (Eout > Ein) { hls_inter_convert(output_m, input_m, Rout, true); } else { hls_inter_convert(output_m, input_m, Rout, false); } convert_vpfp_inter_to_hls_float(output_m, to); } } // from integer type to hls_float conversions template <typename T, int Eout, int Mout, RD_t Rout> inline void hls_vpfp_cast_integral(const T &from, hls_float<Eout, Mout, Rout> &to) { static_assert(std::is_integral<T>::value, "this function only supports casting from integer types"); static_assert( sizeof(from) <= sizeof(long long int), "Conversions to hls_float from integer types only works up to 64 bits."); hls_vpfp_intermediate_ty output_m(Eout, Mout); if (std::is_signed<T>::value) { long long int from_converted = from; hls_convert_int_to_hls_inter(output_m, from_converted); convert_vpfp_inter_to_hls_float(output_m, to); } else { unsigned long long int from_converted = from; hls_convert_int_to_hls_inter(output_m, from_converted); convert_vpfp_inter_to_hls_float(output_m, to); } } // from hls_float to integral type conversions template <typename T, int Eout, int Mout, RD_t Rout> inline void hls_vpfp_cast_integral(const hls_float<Eout, Mout, Rout> &from, T &to) { static_assert(std::is_integral<T>::value, "this function only supports casting to integer types"); static_assert( sizeof(to) <= sizeof(long long int), "Conversions to hls_float from integer types only works up to 64 bits."); hls_vpfp_intermediate_ty input_m(Eout, Mout); #if defined(DEBUG_HLS_FLOAT_WARN) && defined(HLS_X86) bool emit_warnings = true; #else bool emit_warnings = false; #endif if (std::is_signed<T>::value) { long long int to_converted; convert_hls_float_to_vpfp_inter(from, input_m); hls_convert_hls_inter_to_int(to_converted, input_m, emit_warnings); // Saturate to the possibly smaller data type if (sizeof(to) < sizeof(long long int)) { const T min_val = std::numeric_limits<T>::min(); const T max_val = std::numeric_limits<T>::max(); if (to_converted < min_val) { to_converted = min_val; } else if (to_converted > max_val) { to_converted = max_val; } } to = to_converted; } else { unsigned long long int to_converted; convert_hls_float_to_vpfp_inter(from, input_m); hls_convert_hls_inter_to_int(to_converted, input_m, emit_warnings); // Saturate to the possibly smaller data type if (sizeof(to) < sizeof(long long int)) { const T min_val = std::numeric_limits<T>::min(); const T max_val = std::numeric_limits<T>::max(); if (to_converted < min_val) { to_converted = min_val; } else if (to_converted > max_val) { to_converted = max_val; } } to = to_converted; } } ///////////////////////////// Binary Operators /////////////////////////////// template <int AccuracyLevel, int SubnormalSupport, int Eout, int Mout, RD_t Rndout, int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> inline void hls_vpfp_add(hls_float<Eout, Mout, Rndout> &ret, const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2), result_m(Eout, Mout); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); hls_inter_add(result_m, arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); convert_vpfp_inter_to_hls_float(result_m, ret); } template <int AccuracyLevel, int SubnormalSupport, int Eout, int Mout, RD_t Rndout, int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> inline void hls_vpfp_sub(hls_float<Eout, Mout, Rndout> &ret, const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2), result_m(Eout, Mout); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); hls_inter_sub(result_m, arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); convert_vpfp_inter_to_hls_float(result_m, ret); } template <int AccuracyLevel, int SubnormalSupport, int Eout, int Mout, RD_t Rndout, int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> inline void hls_vpfp_mul(hls_float<Eout, Mout, Rndout> &ret, const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2), result_m(Eout, Mout); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); hls_inter_mul(result_m, arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); convert_vpfp_inter_to_hls_float(result_m, ret); } template <int AccuracyLevel, int SubnormalSupport, int Eout, int Mout, RD_t Rndout, int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> inline void hls_vpfp_div(hls_float<Eout, Mout, Rndout> &ret, const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { if (arg1.is_nan() || arg2.is_nan()) { // anything that involves nan ret = hls_float<Eout, Mout, Rndout>::nan(); } else if (arg2.is_zero() && !arg1.is_zero()) { // none zero over non zero ret = arg1.get_sign_bit() ^ arg2.get_sign_bit() ? hls_float<Eout, Mout, Rndout>::neg_inf() : hls_float<Eout, Mout, Rndout>::pos_inf(); } else { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2), result_m(Eout, Mout); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); hls_inter_div(result_m, arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); convert_vpfp_inter_to_hls_float(result_m, ret); } } /////////////////////////// Relational Operator ////////////////////////////// template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2, int AccuracyLevel = 0, int SubnormalSupport = 0> inline bool hls_vpfp_gt(const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); return hls_inter_gt(arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2, int AccuracyLevel = 0, int SubnormalSupport = 0> inline bool hls_vpfp_lt(const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); return hls_inter_lt(arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2, int AccuracyLevel = 0, int SubnormalSupport = 0> inline bool hls_vpfp_eq(const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); return hls_inter_eq(arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2, int AccuracyLevel = 0, int SubnormalSupport = 0> inline bool hls_vpfp_ge(const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); return hls_inter_ge(arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2, int AccuracyLevel = 0, int SubnormalSupport = 0> inline bool hls_vpfp_le(const hls_float<E1, M1, Rnd1> &arg1, const hls_float<E2, M2, Rnd2> &arg2) { hls_vpfp_intermediate_ty arg1_m(E1, M1), arg2_m(E2, M2); convert_hls_float_to_vpfp_inter(arg1, arg1_m); convert_hls_float_to_vpfp_inter(arg2, arg2_m); return hls_inter_le(arg1_m, arg2_m, fp_config::isSubnormalOn(SubnormalSupport)); } /////////////////////////////// To STRING //////////////////////////////////// template <int E, int M, RD_t Rnd> std::string get_str_x86(hls_float<E, M, Rnd> x, int base, int rounding) { // When the base is not recognized, return an empty string. if (base < 2 || base > 16) { return ""; } hls_vpfp_intermediate_ty argx(E, M); convert_hls_float_to_vpfp_inter(x, argx); // at least 7 for -@inf@[null] // the internal get_str returns us the mantissa and where the decimal point // should be normally we need mantissa + 1 at least, but has to be greater // than 7 size_t buffer_size = M + 2 > 7 ? M + 2 : 7; char *c_str_raw = new char[buffer_size]; int dec_pos = hls_inter_get_str(c_str_raw, buffer_size, argx, base, rounding); // just to make sure we null terminate, forever c_str_raw[buffer_size - 1] = '\0'; std::string ret = c_str_raw; delete[] c_str_raw; size_t special_char = ret.find("@"); bool needs_trimming = false; if (special_char != std::string::npos) { // special encodings std::string new_s; for (char &c : ret) { if (c != '@') { new_s += c; } } ret = new_s; } else if (x.is_zero()) { ret = x.get_sign_bit() ? "-0.0" : "0.0"; } else { bool neg = ret[0] == '-'; if (neg) ret = ret.substr(1); // normal numbers if (dec_pos <= 0) { std::string pre = "0."; for (int i = 0; i > dec_pos; --i) { pre += '0'; } ret = pre + ret; needs_trimming = true; } else if (dec_pos > ret.length()) { for (int i = ret.length(); i < dec_pos; ++i) { ret += '0'; } } else { ret.insert(dec_pos, "."); needs_trimming = true; } std::string lead = neg ? "-" : ""; ret = lead + ret; } if (needs_trimming) { size_t cut_off = ret.length() - 1; // trim trailing zeros while (cut_off > 0 && ret[cut_off] == '0' && ret[cut_off - 1] == '0') { cut_off--; } ret = ret.substr(0, cut_off + 1); } return ret; } /////////////////////// Commonly Used Math Operations //////////////////////// template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> sqrt_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_sqrt(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> cbrt_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_cbrt(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> recip_vpfp_impl(hls_float<E, M, Rnd> const &x) { if (x.is_zero()) { return x.get_sign_bit() ? hls_float<E, M, Rnd>::neg_inf() : hls_float<E, M, Rnd>::pos_inf(); } hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_recip(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> rsqrt_vpfp_impl(hls_float<E, M, Rnd> const &x) { if (x.is_zero()) { return x.get_sign_bit() ? hls_float<E, M, Rnd>::neg_inf() : hls_float<E, M, Rnd>::pos_inf(); } hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_rsqrt(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> hypot_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> const &y) { hls_float<E1, M1> result; hls_vpfp_intermediate_ty x_m(E1, M1), y_m(E2, M2), result_m(E1, M1); convert_hls_float_to_vpfp_inter(x, x_m); convert_hls_float_to_vpfp_inter(y, y_m); hls_inter_hypot(result_m, x_m, y_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } ////////////////// Exponential and Logarithmic Functions ///////////////////// template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> exp_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_exp(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> exp2_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_exp2(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> exp10_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_exp10(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> expm1_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_expm1(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> log_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_log(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> log2_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_log2(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> log10_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_log10(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> log1p_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_log1p(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } ///////////////////////// Power Functions //////////////////////////////// template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> pow_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> const &y) { hls_float<E1, M1> result; // a few cases here will return nan: // inf to the power of zero // x and y is nan if (x.is_nan() && y.is_nan()) { return hls_float<E1, M1, Rnd1>::nan(); } // anything to the power of 0 is 1 else if (y.is_zero()) { return 1.0; } else { hls_vpfp_intermediate_ty x_m(E1, M1), y_m(E2, M2), result_m(E1, M1); convert_hls_float_to_vpfp_inter(x, x_m); convert_hls_float_to_vpfp_inter(y, y_m); hls_inter_pow(result_m, x_m, y_m); convert_vpfp_inter_to_hls_float(result_m, result); } // for infinity, handle the corner case which we get infinity but should be // -inf this happens when the exponent (y) is odd negative integer, x is less // than 0, and -0 if (result.is_inf() && !result.get_sign_bit() && x.get_sign_bit() && y.get_sign_bit()) { bool is_float_int_odd = false; ac_int<E2, false> exp = y.get_exponent(); ac_int<M2, false> man = y.get_mantissa(); ac_int<E2 + 1, true> exp_real = ac_int<E2 + 1, true>(exp) - ac_int<E2 + 1, true>((ac_int<E2, false>(1) << E2 - 1) - 1); if (exp_real >= 0 && exp_real <= M2) { // so the assumption here is that, as long as the mantissa is even ac_int<M2, false> mask = ((ac_int<M2, false>(1) << (M2 - exp_real)) - 1); bool is_int = (man & mask) == 0; bool is_odd = false; if (man == 0 && exp_real == 0) { // this is the number 1 is_odd = true; } else { is_odd = man.template slc<1>((unsigned)(M2 - exp_real)); } is_float_int_odd = is_int && is_odd; } if (is_float_int_odd) { return hls_float<E1, M1>::neg_inf(); } } return result; } template <int E, int M, RD_t Rnd, int W, bool S> hls_float<E, M, Rnd> pown_vpfp_impl(hls_float<E, M, Rnd> const &x, ac_int<W, S> const &n) { hls_float<E, M> result; static_assert(W <= 64, "pown only supports integers of sizes up to 64 bits "); if (n == 0) { // any number to the power of 0 is 1 - including nan return 1.0; } else { // normal cases hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_pown(result_m, x_m, (long int)n); convert_vpfp_inter_to_hls_float(result_m, result); } // for infinity, handle the corner case which it is power to a negative number if (x.get_sign_bit()) { if (n % 2 == 0) { result.set_sign_bit(0); } else { result.set_sign_bit(1); } } return result; } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> powr_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> const &y) { hls_float<E1, M1> ret; // inf to the inf gives inf // inf to the -inf gives 0 if (x.is_inf() && !x.get_sign_bit() && y.is_inf()) { ret = y.get_sign_bit() ? hls_float<E1, M1>(0.0) : hls_float<E1, M1>::pos_inf(); } // a few cases here will return nan: // negative x (not including -0) // inf to the power of zero // x or y is nan // 0 to the power of 0 // 1 to the power of inf else if ((x.get_sign_bit() && !x.is_zero()) || (x.is_inf() && y.is_zero()) || x.is_nan() || y.is_nan() || (x.is_zero() && y.is_zero()) || (y.is_inf() && x.get_mantissa() == 0 && x.get_exponent().template slc<E1 - 1>(0).bit_complement() == 0)) { ret = hls_float<E1, M1, Rnd1>::nan(); } else { hls_vpfp_intermediate_ty x_m(E1, M1), y_m(E2, M2), result_m(E1, M1); convert_hls_float_to_vpfp_inter(x, x_m); convert_hls_float_to_vpfp_inter(y, y_m); hls_inter_pow(result_m, x_m, y_m, false); // no subnormal support convert_vpfp_inter_to_hls_float(result_m, ret); } return ret; } /////////////////////// Trigonometric Functions ///////////////////////////// template <int E, int M, RD_t Rnd> inline hls_float<E, M, Rnd> sin_vpfp_impl(const hls_float<E, M, Rnd> &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_sin(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> sinpi_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_sinpi(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> cos_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_cos(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> cospi_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_cospi(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> sincos_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> &cos_value) { cos_value = cos_vpfp_impl(x); return sin_vpfp_impl(x); } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> sincospi_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> &cos_value) { cos_value = cospi_vpfp_impl(x); return sinpi_vpfp_impl(x); } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> asin_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_asin(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> asinpi_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_asinpi(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> acos_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_acos(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> acospi_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_acospi(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> atan_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M, Rnd> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_atan(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E, int M, RD_t Rnd> hls_float<E, M, Rnd> atanpi_vpfp_impl(hls_float<E, M, Rnd> const &x) { hls_float<E, M> result; hls_vpfp_intermediate_ty x_m(E, M), result_m(E, M); convert_hls_float_to_vpfp_inter(x, x_m); hls_inter_atanpi(result_m, x_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } template <int E1, int M1, int E2, int M2, RD_t Rnd1, RD_t Rnd2> hls_float<E1, M1> atan2_vpfp_impl(hls_float<E1, M1, Rnd1> const &x, hls_float<E2, M2, Rnd2> const &y) { hls_float<E1, M1> result; hls_vpfp_intermediate_ty x_m(E1, M1), y_m(E2, M2), result_m(E1, M1); convert_hls_float_to_vpfp_inter(x, x_m); convert_hls_float_to_vpfp_inter(y, y_m); hls_inter_atan2(result_m, x_m, y_m); convert_vpfp_inter_to_hls_float(result_m, result); return result; } } // namespace internal } // namespace ihc #endif // _INTEL_IHC_HLS_INTERNAL_HLS_FLOAT_X86_64
7d8cab85c99d97909997d30dcbc2fe73b0229f35
867eb068fb3253107bd575162ae9299c4e29c7bd
/ex2/vectorAdd.cpp
5000ebcde7c309d3889a736c98b832697e6e9d35
[]
no_license
etnoy/apcsa
e0adbba15bf06d2116e268f355660b5a7ce2d75e
fdb9ac3d5a51c01c3317ec16b64758bbad40d9be
refs/heads/master
2016-09-05T11:01:59.639413
2009-12-15T13:24:26
2009-12-15T13:24:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,353
cpp
vectorAdd.cpp
#include <omp.h> #include <iostream> #include "walltime.h" #define NMAX 1000000 using namespace std; int main() { int myId, numTdreads; double time, time_start=0.0; double dotProduct; double *a,*b,*c,d; int chunk_size, n_start,n_end; // Allocate memory for the vectors as 1-D arrays a = new double[NMAX]; b = new double[NMAX]; c = new double[NMAX]; // Initialize the vectors with some values for(int i=0; i<NMAX; i++) { a[i] = i; b[i] = i/10.0; } // serial execution time = walltime(&time_start); for(int i=0; i< NMAX; i ++) { c[i] = 2*a[i] + b[i]; } time = walltime(&time); cout << "Serial execution time =" << time << "sec" << endl; time = walltime(&time_start); // parallel execution // TODO: Modify the following code to obtain sppedup (minor change required) #pragma omp parallel for private(time) for(int i=0 ; i< NMAX; i ++) { c[i] = 2*a[i] + b[i]; } time = walltime(&time); cout << "Parallel execution time =" << time << "sec" << endl; // TODO: Implement scalar procduct (dot product) #pragma omp parallel for private(time) reduction(+:d) for(int i=0 ; i< NMAX; i ++) { d += a[i]*b[i]; } time = walltime(&time); cout << "Parallel execution time =" << time << "sec" << endl; // De-allocate memory delete [] a; delete [] b; delete [] c; return 0; }
580f515b95cf2d3985348c4b2afb7b995bc200eb
c9019a466fbb31c9404199d0f2bc92a67d55c32b
/src/hbase_full_sender.cc
4af4b7aac54a82d35611addfd45821001f39c41a
[]
no_license
YuanDdQiao/mybus
8d307b131e92218c8856aa7bf43dfdc0875e0a7b
9e2ad1413992c952eb5ffbae143ed8f4b73f8605
refs/heads/master
2020-03-10T19:14:02.786213
2015-07-29T14:26:29
2015-07-29T14:26:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,976
cc
hbase_full_sender.cc
/*************************************************************************** * * Copyright (c) 2014 Sina.com, Inc. All Rights Reserved * **************************************************************************/ /** * @file redis_full_sender.cc * @author zhangbo6(zhangbo6@staff.sina.com.cn) * @date 2014/12/26 10:25:08 * @version 1.0 * @brief * **/ #include <unistd.h> #include <math.h> //for abs() #include "hbase_full_sender.h" #include "bus_hbase_util.h" namespace bus { hbase_full_pool_t::~hbase_full_pool_t() { while(!_queue.isEmpty()) { void *data = _queue.simple_pop(); row_t *row = static_cast<row_t*>(data); if (row != NULL) delete row; } pthread_mutex_destroy(&_cmutex); } int hbase_full_pool_t::init_connection(bus_hbase_t* conn, uint32_t statid, data_source_t **curdst, uint32_t &dst_partnum, bool need_connect) { bus_stat_t& stat = g_bus.get_stat(); bus_config_t& config = g_bus.get_config(); pthread_t pid = pthread_self(); std::vector<data_source_t*> &source = config.get_source(); std::vector<data_source_t*> &dst = config.get_dst(); uint32_t dstsize = dst.size(); data_source_t* cursource = source[_src_partnum]; const int src_port = cursource->get_port(); char buffer[128]; uint32_t dstnum = dst_partnum; if (stat.get_thrift_flag(statid) && dstnum != (statid % dstsize)) { g_logger.notice("%lx try connect default thriftserver [%d]", pid, dstnum); stat.reset_thrift_flag(statid); dstnum = statid % dstsize; need_connect = true; } if (!need_connect) return 0; while (!_stop_flag) { //info thriftserver *curdst = dst[dstnum]; char *curip = const_cast<char*>((*curdst)->get_ip()); int curport = (*curdst)->get_port(); //设置ip+port g_logger.notice("try to connect with next thriftserver [%d] [%s:%d]", dstnum, curip, curport); snprintf(buffer, sizeof(buffer), "%d.%d.%lx", src_port, curport, pid); stat.set_sender_thread_name(statid, buffer); conn->set_thrift_ip_port(curip, curport); if (conn->connect()) { stat.set_consumer_thread_state(statid, THREAD_FAIL); g_logger.warn("init connection [%s:%d] fail", curip, curport); dstnum = (dstnum + 1) % dstsize; sleep(2); continue; } else { g_logger.notice("connect with thriftserver [%s:%d] success", curip, curport); stat.set_consumer_thread_state(statid, THREAD_RUNNING); dst_partnum = dstnum; break; } } if (_stop_flag) return -1; return 0; } uint32_t hbase_full_pool_t::_get_data(std::vector<void*> &batch_vector, MAP2VECTOR &cmd2table) { int32_t rtn = _queue.pop_batch(batch_vector); uint32_t batchsize = batch_vector.size(); if (-1 == rtn) { g_logger.notice("[%s:%d][sender=%lx], recv data NULL", _ip, _port, pthread_self()); //通知同一个sender中其它thread。 _queue.push(NULL); if (0 == batchsize) return 0; } //将batch_vector中的hbase_cmd_t按table分组 std::string table_name; for (std::vector<void*>::iterator it = batch_vector.begin(); it != batch_vector.end(); ++it) { row_t* hrow = static_cast<row_t*>(*it); if (NULL == hrow) { g_logger.debug("%lx hcmd NULL", pthread_self()); break;} table_name = hrow->get_cmd()->get_hbase_table(); //g_logger.debug("row:%s %d", hcmd->get_hbase_row(), hcmd->get_hbase_cmd()); int count = cmd2table.count(table_name); if (count == 0) { std::vector<row_t*> tmpvec; tmpvec.reserve(HBASE_BATCH_COUNT); cmd2table[table_name] = tmpvec; } cmd2table[table_name].push_back(hrow); } return batchsize; } int hbase_full_pool_t::_send_data(bus_hbase_t* conn, MAP2VECTOR &cmd2table, int statid, data_source_t *curdst, uint32_t &processnum) { bus_stat_t& stat = g_bus.get_stat(); //循环将分组的数据发送出去 for (MAP2VECTOR::iterator itmap = cmd2table.begin(); itmap != cmd2table.end(); ++itmap) { //g_logger.debug("%d send %s, count %d", pthread_self(), (itmap->first).c_str(), (itmap->second).size()); uint32_t sz = itmap->second.size(); if (0 == sz) continue; int batch_ret = conn->send_to_hbase(itmap->first, itmap->second, processnum); if (batch_ret) return batch_ret; //发送成功后,更新计数 if ((itmap->second)[0]->get_src_schema()->get_record_flag()) stat.incr_consumer_succ_count(statid, sz); (itmap->second).clear(); } return 0; } void hbase_full_pool_t::process() { bus_stat_t& stat = g_bus.get_stat(); pthread_t pid = pthread_self(); bus_config_t& config = g_bus.get_config(); std::vector<data_source_t*> &source = config.get_source(); std::vector<data_source_t*> &dst = config.get_dst(); uint32_t dstsize = dst.size(); std::vector<void*> batch_vector; batch_vector.reserve(HBASE_BATCH_COUNT); MAP2VECTOR cmd2table; bool need_connect = true; uint32_t processnum = 0; //用于记录send的位置 char buffer[128]; snprintf(buffer, sizeof(buffer), "%d.%d.%lx", (source[_src_partnum])->get_port(), _port, pid); uint32_t statid = stat.get_sender_thread_id(buffer); g_logger.debug("down worker %lx start %d", pid, statid); //hbase full sender的多线程,再断线重连后,可能会使用不同的下游 //因此这里使用curdst来指向当前使用的下游,这样每个线程可以不一样 uint32_t dstnum = statid % dstsize; data_source_t *curdst = dst[dstnum]; bus_hbase_t* conn = new (std::nothrow)bus_hbase_t(&_stop_flag); if (NULL == conn) oom_error(); add_conn(conn); while (!_stop_flag) { if (init_connection(conn, statid, &curdst, dstnum, need_connect)) { //_stop_flag goto hbase_full_sender_stop; } //从队列中获取row, 并按照table存入到cmd2table //g_logger.debug("%ld batch_vecotr.size() %d", pthread_self(), batch_vector.size()); if (batch_vector.empty() && !_get_data(batch_vector, cmd2table)) goto hbase_full_sender_stop; //g_logger.debug("batch_vector:%d", batch_vector.size()); int32_t rtn = _send_data(conn, cmd2table, statid, curdst, processnum); if (0 == rtn) { need_connect = false; } else if (rtn == -1) { g_logger.warn("full send data to [%s:%d] fatal error, stop", curdst->get_ip(), curdst->get_port()); stat.set_consumer_thread_state(statid, THREAD_FAIL); goto hbase_full_sender_stop; } else { g_logger.warn("full send data to [%s:%d] failed, need reconnet", curdst->get_ip(), curdst->get_port()); need_connect = true; continue; } //释放row clear_batch_vector(batch_vector); } //while hbase_full_sender_stop: clear_batch_vector(batch_vector); add_exit_thread(pid); if (NULL != conn) { conn->disconnect(); //close on NON_OPEN xxx delete conn; conn = NULL; } if (stat.get_consumer_thread_state(statid) == THREAD_FAIL) { stat.set_consumer_thread_state(statid, THREAD_EXIT_WITH_FAIL); } else { stat.set_consumer_thread_state(statid, THREAD_EXIT); } g_logger.notice("[%s:%d][sender=%lx] exit succ", curdst->get_ip(), curdst->get_port(), pid); } /* void clear_batch_map(MAP2VECTOR &map) { for (MAP2VECTOR::iterator it = map.begin(); it != map.end(); ++it) { clear_batch_row(it->second); } } */ } //namespace bus
a74a2b7e754b607099a3404a4144f52490c19634
af8e4d71f99bc5833ba6caa46f4f69911c63225d
/hard/124.二叉树中的最大路径和.cpp
2f911446a4aeee7ed855ae8c708de4fcebd3df3a
[]
no_license
zyhustgithub/leetcode
8c77cb000472cda14b4b52572268e640497243d8
1b263344b047ab793e1f836d842b251ecee6b3bd
refs/heads/master
2021-08-12T04:17:21.201733
2021-08-05T15:34:16
2021-08-05T15:34:16
250,941,833
3
0
null
null
null
null
UTF-8
C++
false
false
1,058
cpp
124.二叉树中的最大路径和.cpp
/* * @lc app=leetcode.cn id=124 lang=cpp * * [124] 二叉树中的最大路径和 */ // @lc code=start /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: int maxPathSum(TreeNode* root) { int val = -0x3f3f3f; MaxNumTree(root, val); return val; } int MaxNumTree(TreeNode *curNode, int &val) { if (curNode == nullptr) { return 0; } int left = MaxNumTree(curNode->left, val); int right = MaxNumTree(curNode->right, val); int ltr = curNode->val + max(0, left) + max(0, right); val = (val < ltr) ? ltr : val; return curNode->val + max(0, max(left, right)); } }; // @lc code=end
3a61c02a002d3abd86aab86cc5458aadda12f0e1
fff4bcec5f66252f885a3386e98d6e597b1fdf70
/src/ClientDlg.h
f70db5a3cb9ef2995863a8c25c250d950d8c768a
[]
no_license
ZhangZhiHao233/Remotecomm
e767802bd5727067c7d4f9f73fae199906564066
e8cf2136151b71450f3553255eeecc1fed1e1468
refs/heads/master
2022-11-17T23:25:40.439435
2020-07-12T11:31:16
2020-07-12T11:31:16
279,048,821
0
0
null
null
null
null
GB18030
C++
false
false
2,197
h
ClientDlg.h
#pragma once #include "afxcmn.h" #include "afxwin.h" // CClientDlg 对话框 class CClientDlg : public CDialog { DECLARE_DYNAMIC(CClientDlg) public: CClientDlg(CWnd* pParent = NULL); // 标准构造函数 virtual ~CClientDlg(); // 对话框数据 enum { IDD = IDD_DIALOG_CLIENT }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 DECLARE_MESSAGE_MAP() public: // 服务器IP控件 CIPAddressCtrl m_ipadress; virtual BOOL OnInitDialog(); // 客户端提示信息编辑框 CEdit m_edit_tip; public: CString InitEditText(); afx_msg void OnBnClickedButtonCntSer(); // 连接服务器按钮 CButton m_button_cntser; // 客户端网络信息编辑框 CRichEditCtrl m_richedit_net_cli; afx_msg void OnButtonSendNet(); void SetListInfo(CString cstrInfo,int iMode); void SetBthList(int iMode); void OnInitComDate(); void UpdateComInfo(CString cstrInfo); void OnSaveDate(int iMode); CStringArray* DivString(CString test); CEdit m_edit_net_cli; CString m_str_net_cli; // 网络信息发送按钮 CButton m_button_send_net; afx_msg void OnDownloadhex(); CButton m_radio_recvmode_cli; CButton m_radio_sendmode_cli; CButton m_radio_recvmode_cli_hex; CButton m_radio_sendmode_cli_hex; CComboBox m_combo_com_cli; CComboBox m_combo_barud_cli; CComboBox m_combo_date_cli; CComboBox m_combo_stop_cli; CComboBox m_combo_check_cli; afx_msg void OnSendcom(); afx_msg void OnBnClickedButtonClearRecv(); afx_msg void OnBnClickedButtonSaveRecv(); afx_msg void OnBnClickedButtonClearSend(); CRichEditCtrl m_richedit_recv; CRichEditCtrl m_richedit_send; CString m_richedit_recv_string; CString m_richedit_send_string; CButton m_button_send_com; CButton m_button_auto_sendcom; afx_msg void OnAutosend(); CEdit m_edit_send; CEdit m_edit_recv; BOOL send_mode_cli; BOOL recv_mode_cli; afx_msg void OnZeroCount(); afx_msg void OnBthDisCnt(); afx_msg void OnPaint(); afx_msg void OnBnClickedRadioTextRecvCli(); afx_msg void OnBnClickedRadioHexRecvCli(); afx_msg void OnBnClickedRadioTextSendCli(); afx_msg void OnBnClickedRadioHexSendCli(); afx_msg void OnBnClickedButtonSaceSend(); afx_msg void OnTimer(UINT_PTR nIDEvent); };
0b800e4b7206e93bcbecc1325fd5f16c32a03352
deaa518c6ba667f4fe2ab28b55de11d515ecc176
/Subarray with Distinct Elements Hashing and Tries Challeges.cpp
2597a142e6122cd93c2c0e7468924b636be20bec
[]
no_license
keshavjaiswal39/Coding-Block-Algo-plusplus
1c154451c2aa44c73d45ebc05c4c2bbe1d4c9293
908351f12717942955afddc9dbe143fab7446784
refs/heads/master
2023-03-21T10:22:33.104054
2021-03-12T04:41:11
2021-03-12T04:41:11
346,939,743
0
0
null
null
null
null
UTF-8
C++
false
false
443
cpp
Subarray with Distinct Elements Hashing and Tries Challeges.cpp
#include <bits/stdc++.h> using namespace std; int main() { set<int> s; int N; cin>>N; int a[N]; for(int i=0;i<N;i++) { cin>>a[i]; } int i=0,j=0,sum=0; for(int i=0;i<N;i++) { while(j<N && s.find(a[j])==s.end()) { s.insert(a[j]); j++; } sum += ((j-i+1)*(j-i))/2; s.erase(a[i]); } cout<<sum; return 0; }
73da984c07f39fc0aa4b3898575f924092b27022
b690baf6e48d1dd76c18a4a28254a0daaff5f64c
/LeetCode/Majority Element/O(N).cpp
0ae8611cb2c72b7deb51e299c48444ef2f0e81dc
[]
no_license
sorablaze11/Solved-Programming-Problems-
3262c06f773d2a37d72b7df302a49efb7d355842
b91ecbd59f6db85cc6a289f76563ed58baa1393d
refs/heads/master
2020-08-22T06:49:07.754044
2020-01-25T10:35:21
2020-01-25T10:35:21
216,341,201
0
0
null
null
null
null
UTF-8
C++
false
false
421
cpp
O(N).cpp
class Solution { public: int majorityElement(vector<int>& nums) { // Boyer-Moore Voting Algorithm int cnt = 0, ans; for(int i = 0; i < nums.size(); i++){ if(cnt == 0) { ans = nums[i]; cnt++; }else { if(nums[i] == ans) cnt++; else cnt--; } } return ans; } };
4b0dfd24568145b82ad91935196b2d288144c81a
b6aaef99338cd4492ec792877522db1821a25fc4
/Object_oriented_programming/D/main.cpp
2d94f2968beccbf484487ccefe8475f83da9fcb7
[]
no_license
MikalaiNavitski/uj-first-year
303894a89aa424719457d118d35bb34eada69c66
5af102e012cd9f2db9240a0e6db898ebbf81b191
refs/heads/master
2023-06-22T19:32:15.939468
2021-07-20T09:10:49
2021-07-20T09:10:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,415
cpp
main.cpp
//package pl.edu.uj.tcs.oop.satori.map_list_converter; import java.util.*; public class Switch { public static <T> Map<Integer, T> toMap(List<T> initList) { return new AbstractMap<>() { final List<T> list = initList; private transient Set<Map.Entry<Integer, T>> set; @Override public T remove(Object key){ throw new UnsupportedOperationException();} @Override public Set<Entry<Integer, T>> entrySet() { if (set == null) { set = new AbstractSet<>() { public Iterator<Map.Entry<Integer, T>> iterator() { return new Iterator<>() { int idx = 0; @Override public boolean hasNext() { return idx < list.size(); } @Override public Entry<Integer, T> next() { if (idx >= list.size()) return null; ++idx; return new AbstractMap.SimpleEntry<>(idx - 1, list.get(idx - 1)) { }; } }; } public int size() { return list.size(); } @Override public boolean remove(Object o) { throw new UnsupportedOperationException(); } }; } return set; } }; } public static <T> List<T> toList(Map<Integer, T> initMap) { return new AbstractList<>() { final Map<Integer, T> map = initMap; private void check() { for (int i = 0; i < map.size(); ++i) if (!map.containsKey(i)) throw new MapIsNotListException(); } @Override public T get(int index) { check(); return map.get(index); } @Override public int size() { return map.size(); } }; } }
d2d5b001df1ec87c76d0be5863aaec9d523a3b2a
82dc3cc4c97c05e384812cc9aa07938e2dbfe24b
/contrib/translate/src-mirror/MergeResults.cpp
0e85655ec637c9bbcd095eb53530c0d3b6f596c6
[ "BSD-3-Clause" ]
permissive
samanseifi/Tahoe
ab40da0f8d952491943924034fa73ee5ecb2fecd
542de50ba43645f19ce4b106ac8118c4333a3f25
refs/heads/master
2020-04-05T20:24:36.487197
2017-12-02T17:09:11
2017-12-02T17:24:23
38,074,546
3
0
null
null
null
null
UTF-8
C++
false
false
56
cpp
MergeResults.cpp
/home/saman/Tahoe/contrib/translate/src/MergeResults.cpp
322b137a6b6f9b127bbace31b93df8e703673cc2
09f547eb0973ef1bba646aed67a434fb00c58c44
/king.cpp
440575dd8fdbb066a2cd9dfa46be11369f430335
[]
no_license
HarrisonWelch/ChurchChess
6e1db8f9704c8e2275c071ac1ea0cb5b1e2df41b
64723669d946cebf145229efff5eff2dbc747a06
refs/heads/master
2021-06-04T11:07:38.176688
2016-05-18T20:39:40
2016-05-18T20:39:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,655
cpp
king.cpp
#include "king.h" char isKing(char piece) { return piece == BLACK_KING || piece == WHITE_KING; } std::vector<Move> getKingMoves(const Chessboard& chessboard, char row, char col) { if (isKing(chessboard.get(row, col)) == 0) { throw std::invalid_argument("This is not a king."); } std::vector<Move> moves; char color = chessboard.getColor(row, col); char directions[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, -1}, {-1, 1}}; // Regular moves for (int i = 0; i < 8; i++) { char rowPrime = row + directions[i][0]; char colPrime = col + directions[i][1]; if (rowPrime >= 0 && rowPrime <= 7 && colPrime >= 0 && colPrime <= 7) { if (chessboard.getColor(rowPrime, colPrime) != color && chessboard.getCheck(rowPrime, colPrime) == 0) { Move m(row, col, rowPrime, colPrime); m.setCheck(); moves.push_back(m); } } } // Castling if (color == WHITE_PIECE && chessboard.isWhiteKingCastlingAllowed()) { if (chessboard.get(row, 5) == OPEN_SQUARE && chessboard.get(row, 6) == OPEN_SQUARE && chessboard.getCheck(row, 5) == 0 && chessboard.getCheck(row, 6) == 0) { Move m(row, col, row, 6); m.setCastling(); moves.push_back(m); } } if (color == WHITE_PIECE && chessboard.isWhiteQueenCastlingAllowed()) { if (chessboard.get(row, 2) == OPEN_SQUARE && chessboard.get(row, 3) == OPEN_SQUARE && chessboard.getCheck(row, 2) == 0 && chessboard.getCheck(row, 3) == 0) { Move m(row, col, row, 2); m.setCastling(); moves.push_back(m); } } if (color == BLACK_PIECE && chessboard.isBlackKingCastlingAllowed()) { if (chessboard.get(row, 5) == OPEN_SQUARE && chessboard.get(row, 6) == OPEN_SQUARE && chessboard.getCheck(row, 5) == 0 && chessboard.getCheck(row, 6) == 0) { Move m(row, col, row, 6); m.setCastling(); moves.push_back(m); } } if (color == BLACK_PIECE && chessboard.isBlackQueenCastlingAllowed()) { if (chessboard.get(row, 2) == OPEN_SQUARE && chessboard.get(row, 3) == OPEN_SQUARE && chessboard.getCheck(row, 2) == 0 && chessboard.getCheck(row, 3) == 0) { Move m(row, col, row, 2); m.setCastling(); moves.push_back(m); } } return moves; }
1b88b5cf42ad654049375f8a5ff11c96c2fbdab2
d61f2cac3bd9ed39f95184b89dd40952c6482786
/testCase/results/25/TS
5284f2edc9c933fd6b25638f46b5593825659752
[]
no_license
karimimp/PUFoam
4b3a5b427717aa0865889fa2342112cc3d24ce66
9d16e06d63e141607491219924018bea99cbb9e5
refs/heads/master
2022-06-24T08:51:18.370701
2022-04-28T18:33:03
2022-04-28T18:33:03
120,094,729
6
3
null
2022-04-27T09:46:38
2018-02-03T13:43:52
C++
UTF-8
C++
false
false
9,063
TS
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "25"; object TS; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField nonuniform List<scalar> 800 ( 340.86479 340.87062 340.87164 340.87177 340.87179 340.87182 340.87185 340.87187 340.87189 340.8719 340.8719 340.87189 340.87187 340.87185 340.87182 340.87179 340.87177 340.87164 340.87062 340.86479 339.2343 339.29947 339.31387 339.31605 339.31567 339.31506 339.31468 339.31452 339.31447 339.31446 339.31446 339.31447 339.31452 339.31468 339.31506 339.31566 339.31605 339.31387 339.29946 339.2343 337.85368 337.95374 337.98158 337.98655 337.98645 337.98564 337.9851 337.98485 337.98477 337.98476 337.98476 337.98477 337.98485 337.9851 337.98564 337.98645 337.98655 337.98158 337.95374 337.85368 336.79671 336.92193 336.96069 336.96783 336.96788 336.96688 336.96618 336.96585 336.96575 336.96573 336.96573 336.96575 336.96585 336.96618 336.96688 336.96788 336.96782 336.96069 336.92193 336.79671 336.09763 336.23662 336.28543 336.29446 336.29448 336.29315 336.29223 336.29176 336.2916 336.29156 336.29156 336.2916 336.29176 336.29223 336.29315 336.29448 336.29446 336.28543 336.23662 336.09763 335.75637 335.89934 335.95927 335.97045 335.97038 335.96858 335.96732 335.96663 335.96635 335.96625 335.96625 335.96635 335.96663 335.96732 335.96858 335.97038 335.97045 335.95927 335.89935 335.75638 335.73585 335.88003 335.94935 335.96346 335.96346 335.96111 335.95942 335.95841 335.95795 335.95776 335.95777 335.95795 335.95841 335.95942 335.96111 335.96346 335.96346 335.94936 335.88003 335.73586 335.95531 336.10952 336.1829 336.20154 336.20207 336.19922 336.19707 336.19568 336.19502 336.19472 336.19472 336.19502 336.19568 336.19707 336.19922 336.20207 336.20154 336.18291 336.10953 335.95531 336.27887 336.46666 336.53946 336.56554 336.56759 336.56452 336.56208 336.56041 336.55959 336.5592 336.5592 336.55959 336.56042 336.56209 336.56452 336.56759 336.56555 336.53946 336.46667 336.27888 336.50232 336.76368 336.83693 336.87549 336.88163 336.87946 336.87744 336.87594 336.8752 336.87484 336.87484 336.8752 336.87594 336.87744 336.87946 336.88163 336.87549 336.83693 336.76369 336.50233 336.30966 336.7038 336.78866 336.84882 336.86626 336.86854 336.869 336.86893 336.86892 336.86892 336.86892 336.86892 336.86893 336.86901 336.86854 336.86626 336.84883 336.78867 336.70381 336.30967 335.2192 335.78568 335.94656 336.0467 336.04969 336.0619 336.06881 336.07296 336.07653 336.07782 336.07782 336.07653 336.07296 336.06881 336.0619 336.0497 336.04671 335.94657 335.78569 335.21921 332.49433 333.27088 333.6039 333.70347 333.71704 333.74836 333.76886 333.7854 333.81374 333.82118 333.82118 333.81374 333.7854 333.76887 333.74837 333.71704 333.70348 333.60391 333.27089 332.49433 327.11262 328.21904 328.70182 328.86397 328.94256 329.00412 329.05031 329.08001 329.04958 329.06022 329.06022 329.04958 329.08001 329.05031 329.00413 328.94256 328.86398 328.70183 328.21904 327.11263 320.07516 320.94046 321.39913 321.56095 321.65814 321.73753 321.94512 321.99518 322.00849 322.02006 322.02006 322.00849 321.99518 321.94512 321.73753 321.65814 321.56096 321.39913 320.94046 320.07516 316.84992 317.06242 317.24103 317.34532 317.41402 317.47459 317.52735 317.57229 317.60107 317.61307 317.61307 317.60107 317.57229 317.52734 317.47459 317.41401 317.34532 317.24103 317.06242 316.84992 314.50984 314.54535 314.60946 314.66997 314.72205 314.77007 314.8135 314.84831 314.87115 314.882 314.882 314.87115 314.84831 314.8135 314.77007 314.72204 314.66997 314.60945 314.54535 314.50983 312.89081 312.92509 312.97607 313.02906 313.0781 313.12241 313.16097 313.19111 313.21122 313.22107 313.22107 313.21122 313.19111 313.16097 313.12241 313.0781 313.02905 312.97607 312.92508 312.89081 311.39287 311.44153 311.49759 311.55182 311.60074 311.64322 311.67856 311.70555 311.72355 311.73247 311.73247 311.72355 311.70555 311.67855 311.64322 311.60074 311.55181 311.49759 311.44153 311.39286 310.01556 310.0804 310.15046 310.2133 310.26658 310.31035 310.34501 310.3707 310.3876 310.39596 310.39596 310.3876 310.3707 310.34501 310.31034 310.26658 310.21329 310.15045 310.0804 310.01556 308.76287 308.83847 308.92219 308.996 309.05647 309.10416 309.14047 309.16658 309.18345 309.19172 309.19172 309.18345 309.16658 309.14047 309.10416 309.05647 308.996 308.92219 308.83847 308.76287 307.63299 307.71311 307.8061 307.88942 307.95742 308.01022 308.04959 308.07737 308.09505 308.10364 308.10364 308.09505 308.07737 308.04959 308.01022 307.95741 307.88942 307.8061 307.71311 307.63298 306.6191 306.69908 306.79633 306.88591 306.96 307.0177 307.06055 307.09056 307.10954 307.11871 307.11871 307.10954 307.09056 307.06054 307.0177 306.96 306.88591 306.79633 306.69908 306.6191 305.71184 305.78884 305.88618 305.97852 306.05644 306.11787 306.16377 306.19601 306.2164 306.22625 306.22625 306.2164 306.19601 306.16377 306.11787 306.05644 305.97852 305.88618 305.78884 305.71184 304.90113 304.97363 305.06815 305.16023 305.23957 305.30314 305.35119 305.3852 305.4068 305.41727 305.41727 305.4068 305.3852 305.35119 305.30314 305.23957 305.16023 305.06815 304.97363 304.90113 304.17722 304.24455 304.33442 304.42392 304.50259 304.56666 304.61573 304.65081 304.67324 304.68416 304.68416 304.67324 304.65081 304.61573 304.56666 304.50259 304.42392 304.33442 304.24455 304.17722 303.53115 303.59312 303.67729 303.76264 303.83896 303.90207 303.95104 303.98641 304.00921 304.02035 304.02035 304.00921 303.98641 303.95104 303.90207 303.83896 303.76264 303.67729 303.59312 303.53115 302.95495 303.01161 303.08957 303.16978 303.24253 303.30351 303.35139 303.38632 303.40899 303.42012 303.42012 303.40899 303.38632 303.35139 303.30351 303.24253 303.16978 303.08957 303.01161 302.95495 302.44161 302.49313 302.56473 302.63922 302.70759 302.76557 302.81157 302.84542 302.86755 302.87845 302.87845 302.86755 302.84543 302.81157 302.76557 302.70759 302.63922 302.56473 302.49313 302.44161 301.98505 302.03167 302.09694 302.16547 302.22898 302.28335 302.32689 302.35917 302.38039 302.39089 302.39089 302.38039 302.35917 302.32689 302.28336 302.22898 302.16547 302.09694 302.03167 301.98505 301.58006 301.62202 301.68115 301.74367 301.80207 301.85247 301.89313 301.92348 301.94354 301.95349 301.95349 301.94354 301.92348 301.89313 301.85247 301.80207 301.74367 301.68115 301.62203 301.58006 301.22225 301.25982 301.31302 301.36962 301.42284 301.46909 301.50663 301.53482 301.55352 301.56283 301.56283 301.55352 301.53482 301.50663 301.46909 301.42284 301.36962 301.31303 301.25982 301.22225 300.90802 300.94144 300.98898 301.03982 301.08791 301.12994 301.16426 301.19015 301.2074 301.21601 301.21601 301.2074 301.19015 301.16426 301.12994 301.08791 301.03982 300.98898 300.94144 300.90802 300.63453 300.66402 300.70615 300.75145 300.79454 300.83241 300.8635 300.88706 300.90281 300.91069 300.91069 300.90281 300.88706 300.8635 300.83241 300.79454 300.75146 300.70615 300.66402 300.63453 300.39971 300.42545 300.46245 300.50246 300.54074 300.57459 300.60252 300.62378 300.63804 300.64519 300.64519 300.63804 300.62378 300.60252 300.57459 300.54074 300.50246 300.46245 300.42546 300.39971 300.20225 300.22445 300.25657 300.29158 300.32532 300.35535 300.38027 300.39934 300.41218 300.41863 300.41863 300.41218 300.39934 300.38027 300.35535 300.32532 300.29158 300.25657 300.22445 300.20225 300.04171 300.06053 300.0881 300.11846 300.148 300.17452 300.19669 300.21375 300.22528 300.23108 300.23108 300.22528 300.21375 300.19669 300.17452 300.14801 300.11846 300.0881 300.06054 300.04171 299.9185 299.93419 299.9576 299.98381 300.00966 300.03311 300.05288 300.06819 300.07859 300.08385 300.08385 300.07859 300.06819 300.05288 300.03311 300.00966 299.98381 299.95761 299.93419 299.9185 299.83394 299.8469 299.86683 299.88965 299.91253 299.93356 299.95147 299.96543 299.97497 299.97979 299.97979 299.97497 299.96543 299.95147 299.93356 299.91253 299.88965 299.86683 299.8469 299.83394 299.79024 299.80129 299.81894 299.83962 299.8607 299.88029 299.89709 299.91027 299.9193 299.92389 299.92389 299.9193 299.91027 299.89709 299.88029 299.8607 299.83963 299.81894 299.8013 299.79024 ) ; boundaryField { Wall { type zeroGradient; } frontAndBack { type empty; } atmosphere { type zeroGradient; } } // ************************************************************************* //
05b22ae8fc83f2fafc484fadf0deab440004b7e2
e263b3c0fd10874ffa11e1097487a65b4074fe9f
/src/City.cpp
d685b66cc3c11f8032f7759490c73f8bf0f93fa3
[]
no_license
Agent77/ex6
e410af917763af903c75098b996a7378defad82f
be5e807ec59fcd0b634d41fb52c580e2e6fd10cc
refs/heads/master
2021-05-01T01:46:53.302585
2017-01-30T19:36:07
2017-01-30T19:36:07
79,842,368
0
0
null
null
null
null
UTF-8
C++
false
false
10,085
cpp
City.cpp
#include <sstream> #include "City.h" City::City() { gridSizeX=0; gridSizeY=0; } void City::CallTaxiCenter(Passenger p) { } Passenger City::checkForPassengerCalls() { } /* * The function parses a given string and creates new driver. if input is incorrect, returns fake * driver with id -1. */ Driver City::createDriver(string s) { char status; char cId[3]; char cAge[3]; char cExp[3]; char cVId[3]; int index=0; int counter = 0; Driver d; bool valid=true; for (int j=0; j<s.size();j++){ if (s[j]!=',') { if (counter != 2) { if (isdigit(s[j])) { switch (counter) { case 0: cId[index] = s[j]; break; case 1: cAge[index] = s[j]; break; case 3: cExp[index] = s[j]; break; case 4: cVId[index] = s[j]; break; } index++; }else { valid=false; break; } }else{ status=s[j]; valid = isValidStatus(status); } }else{ counter++; index=0; } } if (counter==4 && valid){ string sId=string (cId); string sAge=string (cAge); string sExp=string (cExp); string sVId=string (cVId); int id = stoi(sId); int age = stoi(sAge); int exp = stoi(sExp); int vId = stoi(sVId); if (id>=0 && age>=0 && exp>=0 && vId>=0){ d = Driver(id, age, status, exp, vId); return d; } } d = Driver (-1,-1,'M',-1,-1); return d; } /* * The function parses a given string and creates new trip. if input is incorrect returns NULL. */ Trip* City::createTrip(string s) { //8 ints int i = 0; int value[13]; int f; string g; if (validTrip(s)) { std::istringstream sep(s); std::getline(sep, g, ','); std::istringstream(g) >> f; for (int j = 0; j < s.size() / 2; j++) { value[i] = f; i++; std::getline(sep, g, ','); std::istringstream(g) >> f; } Trip* trip = new Trip(value[0], value[1], value[2], value[3], value[4], value[5], value[6], value[7]); return trip; } else { return NULL; } } /* * The function parses a given string and creates new coordinate. if input is incorrect returns NULL. */ Coordinate* City::createCoordinate(string s) { int size=s.size()/2 +1; int counter=0; char c1[4]={0}; char c2[4]={0}; int index=0; if(size!=2){ return NULL; } for (int i=0; i < s.size(); i++) { if (s[i] != ',') { switch (counter) { case 0: c1[index] = s[i]; index++; break; case 1: c2[index] = s[i]; index++; break; } } else { counter++; index=0; } } string s1 = string(c1); string s2 = string(c2); if(!isNumber(s1) || !isNumber((s2))){ return NULL; } int x = stoi(s1); int y = stoi(s2); if (x<0 || x>gridSizeX || y<0 || y>gridSizeY || x<0 || x>gridSizeX || y<0 || y>gridSizeY){ return NULL; } Coordinate *point = new Point(x, y); return point; } /* * The function parses a given string and creates new graph. if input is incorrect returns NULL. */ Graph* City::createGraph(string s) { char c1[4]={0}; char c2[4]={0}; int counter =0; int index=0; for (int i=0; i<s.size(); i++){ if(isdigit(s[i])){ switch (counter) { case 0: c1[index] = s[i]; index++; break; case 1: c2[index] = s[i]; index++; break; } } else if (s[i]==' ' && counter==0){ index=0; counter++; } else{ return NULL; } } if (c1[0]==0 || c2[0]==0){ return NULL; } string s1= string (c1); string s2= string (c2); gridSizeX = stoi(s1); gridSizeY = stoi(s2); if (gridSizeX <= 0 || gridSizeY <= 0) { return NULL; } Graph *graphPointer = new Grid(gridSizeX, gridSizeY); return graphPointer; } /* * checks whether a given char is a correct driver status */ bool City::isValidStatus(char c){ switch(c) { case 'S': return true; case 'M': return true; case 'W': return true; case 'D': return true; default: return false; } } /* * checks if a given string has only numbers and ',' */ bool City::isNumber(string s) { for (int i=0; i<s.size(); i++){ if (!isdigit(s[i]) && !s[i]==','){ return false; } } return true; } /* * The function parses a given string and creates new taxi. if input incorrect returns fake taxi * with id -1. */ Taxi City::createTaxi(string s) { int counter=0; int size= s.size(); int index=0; char s1[3]; char s2[3]; bool valid=true; int i=0; int id; int type; for(; i<size; i++){ if (s[i]!=',') { if (!isdigit(s[i])){ valid = false; break; } if (counter==0) { s1[index] = s[i]; } else { s2[index] = s[i]; } index++; } else { counter++; index=0; } if (counter==2){ i++; break; } } string s3= string(s1); string s4= string(s2); char c3= (char)s[i]; char c4= (char)s[i+2]; int counter2=0; if (counter==2) { if (isNumber(s3) && isNumber((s4))) { id = stoi(s3); type = stoi(s4); if (id >= 0 && (type == 1 || type == 2)) { switch (c3) { case 'H': counter2++; break; case 'S': counter2++; break; case 'T': counter2++; break; case 'F': counter2++; break; default: valid=false; break; } switch (c4) { case 'R': counter2++; break; case 'B': counter2++; break; case 'G': counter2++; break; case 'P': counter2++; break; case 'W': counter2++; break; default: valid=false; break; } } } } else { valid = false; } if (counter2==2 || valid){ if (type == 1) { StandardCab t = StandardCab(id, type, c3, c4); return t; } else if (type == 2) { LuxuryCab t = LuxuryCab(id, type, c3, c4); return t; } } StandardCab t = StandardCab(-1, 1, 'L', 'N'); return t; } /* * checks whether a given string is correct input for a trip or not */ bool City::validTrip(string s) { int size=s.size(); int i=0; int index=0; int id; char sId[3]; int startX; char sStartX[3]; int startY; char sStartY[3]; int endX; char sEndX[3]; int endY; char sEndY[3]; int pass; char sPass[3]; double tariff; char sTariff[3]; int time; char sTime[3]; int counter=0; char c[3]; while (i<size) { if (s[i] != ','){ if (!isdigit(s[i])) { return false; } switch (counter) { case 0: sId[index] = s[i]; break; case 1: sStartX[index] = s[i]; break; case 2: sStartY[index] = s[i]; break; case 3: sEndX[index] = s[i]; break; case 4: sEndY[index] = s[i]; break; case 5: sPass[index] = s[i]; break; case 6: sTariff[index]=s[i]; break; case 7: sTime[index]=s[i]; break; default: break; } i++; index++; }else { i++; counter++; index=0; } } id= stoi(sId); startX= stoi(sStartX); startY= stoi(sStartY); endX= stoi(sEndX); endY= stoi(sEndY); pass=stoi(sPass); tariff= stoi(sTariff); time= stoi(sTime); if (counter!=7 || id<0 || pass<0 || tariff<0 || time<=0){ return false; } if (startX<0 || startX>=gridSizeX || startY<0 || startY>=gridSizeY || endX<0 || endX>=gridSizeX || endY<0 || endY>=gridSizeY){ return false; } if(startX == endX && startY == endY) { return false; } return true; }
82a76bc23b1bef0058e9003b428bdc85536f9c9a
da358ee83fc3362c0e0a0a2e041fc5a9548847b7
/Algorithm/union_find.cpp
4b287934dafc1ddb56354bcc043aa32592714211
[]
no_license
seoyeon0413/Algorithm
a548dc2d28ebc7086830d24c17ba95b5e90b498c
8af859d6cd14c73d23a4ba35fa034ad6496d29a9
refs/heads/master
2023-02-16T22:32:45.944868
2021-01-17T15:36:02
2021-01-17T15:36:02
255,344,789
0
0
null
null
null
null
UHC
C++
false
false
984
cpp
union_find.cpp
#include <stdio.h> int getParent(int parent[], int x) { if (parent[x] == x) return x; return getParent(parent, parent[x]); } //각 부모 노드를 합칩니다. void unionParent(int parent[], int a, int b) { a = getParent(parent, a); b = getParent(parent, b); if (a < b) parent[b] = a; else parent[a] = b; } //같은 부모 노드를 가지는지 확인 int findParent(int parent[], int a, int b) { a = getParent(parent, a); b = getParent(parent, b); if (a == b) return 1; else return 0; } int main() { int parent[11]; for (int i = 1; i <= 10; i++) { parent[i] = i; } unionParent(parent, 1, 2); unionParent(parent, 2, 3); unionParent(parent, 3, 4); unionParent(parent, 5, 6); unionParent(parent, 6, 7); unionParent(parent, 7, 8); // (1,2,3) (4,5,6) printf("1과 5는 연결되어있나요? %d\n", findParent(parent, 1, 5)); unionParent(parent, 1, 5); printf("1과 5는 연결되어있나요? %d\n", findParent(parent, 1, 5)); return 0; }
69636fbccfd673d24cf361e92dc32faba9f2761a
c9e669d526ec8b303809c71dd15aa04bfb8045c1
/Internal/BasicTimer/BasicTimerWithInterruptBasicImpl.h
39b3080d20984dbb2c1b78b5c114e30bc1c12ac7
[ "MIT" ]
permissive
crispycookies/LENTIA-Timer
b8dbef4612bb64453eab4da792aee1015d4d2b97
c7a931e5464af0cf9caf12056e92e35dfb02c1e1
refs/heads/master
2022-11-28T12:48:38.361572
2020-08-05T21:28:30
2020-08-05T21:28:30
280,517,363
0
0
null
null
null
null
UTF-8
C++
false
false
1,215
h
BasicTimerWithInterruptBasicImpl.h
// // Created by TobiEgger on 23.02.2020. // #ifndef DRONE_BASICTIMERWITHINTERRUPTBASICIMPL_H #define DRONE_BASICTIMERWITHINTERRUPTBASICIMPL_H #include "BasicTimerBasicImpl.h" #include "../../../../Common/IRQs/IRQCallee.h" #include "../../../../Common/IRQs/IRQ.h" #include "../../../../Common/IRQs/IRQCallee.h" #include "../Interrupts/IRQTimerBasicImpl.h" class BasicTimerWithInterruptBasicImpl : public BasicTimerBasicImpl, public IRQCallee { protected: IRQn_Type irq_n; IRQTimerBasicImpl * irq; BasicTimerWithInterruptBasicImpl(Timer * _timer, SynchronizationObject * _sync, IRQn_Type irq_n_, IRQTimerBasicImpl * irq_) : BasicTimerBasicImpl(_timer, _sync, true), irq_n(irq_n_), irq(irq_){ if(irq_ == nullptr){ return; } irq_->setTimer(_timer); }; public: ~BasicTimerWithInterruptBasicImpl() override{ if(irq == nullptr){ return; } irq->unsetTimer(); } virtual bool setIRQCallback(IRQ::callee_ptr_t callback); virtual bool enableIRQ(); virtual bool disableIRQ(); bool init() override; bool de_init() override; virtual bool init_without_irq(); virtual bool de_init_without_irq(); irqn_type_opt_t getIRQ() const override; }; #endif //DRONE_BASICTIMERWITHINTERRUPTBASICIMPL_H
9bda7a946a44610012e906e8229c12080ce42b8a
a2452f6e456a2248f2de708a2d39e8e574d5240a
/Coursework1Release/main.cpp
d866d4eaf8daf5938835cda0c4c1bd0ad52b82c5
[ "Apache-2.0" ]
permissive
razvanilin/parallelGeneticAlgorithm
0986bfe636621916c4d70ec0fca9e0b9ef241364
e268a13ab3760e6a049cf83f87ddc649c9ae9079
refs/heads/master
2021-01-11T04:50:48.516366
2016-11-03T20:59:20
2016-11-03T20:59:20
71,454,915
0
0
null
null
null
null
UTF-8
C++
false
false
6,783
cpp
main.cpp
// // main.cpp // Coursework1 // // Created by Razvan Ilin on 13/10/2016. // Copyright © 2016 Razvan Ilin. All rights reserved. // #include <iostream> #include <string> #include <vector> #include <memory> #include <algorithm> #include <random> #include <chrono> #include <array> #include <cstring> using namespace std; using namespace std::chrono; constexpr char *secret = "A long time ago in a galaxy far, far away...."; constexpr unsigned int GENE_LENGTH = 8; constexpr unsigned int NUM_COPIES_ELITE = 4; constexpr unsigned int NUM_ELITE = 8; constexpr double CROSSOVER_RATE = 0.9; constexpr unsigned int POP_SIZE = 100; const unsigned int NUM_CHARS = strlen(secret); const unsigned int CHROMO_LENGTH = NUM_CHARS * GENE_LENGTH; constexpr double MUTATION_RATE = 0.001; struct genome { vector<unsigned int> bits; unsigned int fitness = 0.0; unsigned int gene_length = GENE_LENGTH; }; genome best; unsigned int calculate_total_fitness(const vector<genome> &genomes) { unsigned int total_fitness = 0; for (auto &genome : genomes) total_fitness += genome.gene_length; return total_fitness; } inline bool comp_by_fitness(const genome &a, const genome &b) { return a.fitness < b.fitness; } void grab_N_best(const unsigned int N, const unsigned int copies, vector<genome> &old_pop, vector<genome> &new_pop) { sort(old_pop.begin(), old_pop.end(), comp_by_fitness); best = old_pop[0]; for (unsigned int n = 0; n < N; ++n) for (unsigned int i = 0; i < copies; ++i) new_pop[n * copies + i] = old_pop[n]; } const genome& roulette_wheel_selection(unsigned int pop_size, const unsigned int fitness, const vector<genome> &genomes) { static default_random_engine e(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()); static uniform_real_distribution<double> dist; double slice = dist(e) * fitness; unsigned int total = 0; for (unsigned int i = 0; i < pop_size; ++i) { total += genomes[i].fitness; if (total > slice) return genomes[i]; } return genomes[0]; } void cross_over(double crossover_rate, unsigned int chromo_length, const genome &mum, const genome &dad, genome &baby1, genome &baby2) { static default_random_engine e(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()); static uniform_real_distribution<double> float_dist; static uniform_int_distribution<unsigned int> int_dist(0, chromo_length); if (float_dist(e) > crossover_rate || mum.bits == dad.bits) { baby1.bits = mum.bits; baby2.bits = mum.bits; } else { const unsigned int cp = int_dist(e); baby1.bits.insert(baby1.bits.end(), mum.bits.begin(), mum.bits.begin() + cp); baby1.bits.insert(baby1.bits.end(), dad.bits.begin() + cp, dad.bits.end()); baby2.bits.insert(baby2.bits.end(), dad.bits.begin(), dad.bits.begin() + cp); baby2.bits.insert(baby2.bits.end(), mum.bits.begin() + cp, mum.bits.end()); } } void mutate(double mutation_rate, genome &gen) { static default_random_engine e(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()); static uniform_real_distribution<double> dist; double rnd; for (auto &bit : gen.bits) { rnd = dist(e); if (rnd < mutation_rate) bit = !bit; } } vector<genome> epoch(unsigned int pop_size, vector<genome> &genomes) { auto fitness = calculate_total_fitness(genomes); vector<genome> babies(pop_size); if (((NUM_COPIES_ELITE * NUM_ELITE) % 2) == 0) grab_N_best(NUM_ELITE, NUM_COPIES_ELITE, genomes, babies); for (unsigned int i = NUM_ELITE * NUM_COPIES_ELITE; i < pop_size; i += 2) { auto mum = roulette_wheel_selection(pop_size, fitness, genomes); auto dad = roulette_wheel_selection(pop_size, fitness, genomes); genome baby1; genome baby2; cross_over(CROSSOVER_RATE, CHROMO_LENGTH, mum, dad, baby1, baby2); mutate(MUTATION_RATE, baby1); mutate(MUTATION_RATE, baby2); babies[i] = baby1; babies[i + 1] = baby2; } return babies; } vector<unsigned int> decode(genome &gen) { static vector<unsigned int> this_gene(gen.gene_length); vector<unsigned int> decoded(NUM_CHARS); for (unsigned int gene = 0, count = 0; gene < gen.bits.size(); gene += gen.gene_length, ++count) { for (unsigned int bit = 0; bit < gen.gene_length; ++bit) this_gene[bit] = gen.bits[gene + bit]; unsigned int val = 0; unsigned int multiplier = 1; for (unsigned int c_bit = this_gene.size(); c_bit > 0; --c_bit) { val += this_gene[c_bit - 1] * multiplier; multiplier *= 2; } decoded[count] = val; } return decoded; } vector<vector<unsigned int>> update_epoch(unsigned int pop_size, vector<genome> &genomes) { vector<vector<unsigned int>> guesses; genomes = epoch(pop_size, genomes); for (unsigned int i = 0; i < genomes.size(); ++i) guesses.push_back(decode(genomes[i])); return guesses; } unsigned int check_guess(const vector<unsigned int> &guess) { vector<unsigned char> v(guess.size()); for (unsigned int i = 0; i < guess.size(); ++i) v[i] = static_cast<unsigned char>(guess[i]); string s(v.begin(), v.end()); unsigned int diff = 0; for (unsigned int i = 0; i < s.length(); ++i) diff += abs(s[i] - secret[i]); return diff; } string get_guess(const vector<unsigned int> &guess) { vector<unsigned char> v(guess.size()); for (unsigned int i = 0; i < guess.size(); ++i) v[i] = static_cast<unsigned char>(guess[i]); string s(v.begin(), v.end()); return s; } int main() { default_random_engine e(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()); uniform_int_distribution<unsigned int> int_dist(0, 1); vector<genome> genomes(POP_SIZE); for (unsigned int i = 0; i < POP_SIZE; ++i) { for (unsigned int j = 0; j < CHROMO_LENGTH; ++j) genomes[i].bits.push_back(int_dist(e)); } auto population = update_epoch(POP_SIZE, genomes); for (unsigned int generation = 0; generation < 2048; ++generation) { for (unsigned int i = 0; i < POP_SIZE; ++i) genomes[i].fitness = check_guess(population[i]); population = update_epoch(POP_SIZE, genomes); if (generation % 10 == 0) { cout << "Generation " << generation << ": " << get_guess(decode(best)) << endl; cout << "Diff: " << check_guess(decode(best)) << endl; } } return 0; }
c6b0a7528aad7fb3b73bb676d548491981896201
312e69112d0efa23ebcb7dff403dedeb40a25398
/configure.cpp
c175bfaecb0881bb7c433e8747bf60420f83ab02
[]
no_license
wlrwxer/tcp-port-forward
0aeffcf6d5124dfcd46f02e8e697cc5e4dd0043e
05b5191ab2637dcea0a1099442425350c457bb66
refs/heads/master
2020-03-29T05:00:34.549476
2018-09-21T03:21:21
2018-09-21T03:21:21
149,560,919
2
0
null
null
null
null
UTF-8
C++
false
false
1,023
cpp
configure.cpp
// // configure.cpp // mars_online_server // // Created by baba on 9/3/13. // Copyright (c) 2013 baba. All rights reserved. // #include <luabind/luabind.hpp> #include "configure.h" void logging_lua(const char *) { } int global::update_configure_from_lua(const char *luafile) { assert(luafile); lua_file_ = luafile; try { boost::shared_ptr<lua_State> L(luaL_newstate(), boost::bind(lua_close, _1)); luaL_openlibs(&*L); luabind::open(&*L); luabind::module(&*L) [ luabind::def("logging", logging_lua), #include "tcp_port_forward/configure.cc" ]; if (luaL_dofile(&*L, luafile)) { print_error("global::update_configure_from_lua lua_dofile failed."); return 1; } luabind::call_function<void>(&*L, "update_configure", backup_); std::swap(current_, backup_); } catch (luabind::error& e) { print_error("global::update_configure_from_lua %s", e.what()); } return 0; }
67ea632944a22e38e75926996e45e5bca639e646
42e146f13a65324b0f07a6eea1fd8c9ac98bd0f7
/FileUtils.cpp
7f5ade6ddd5518b95e1e48ad0d2b55f0fe264a96
[]
no_license
mfurkin/fileutils
413a55f05c9defdcb404273c9d3a9c998f4fbd88
43a21c5d4b5d1893567c6d04f1e073910d0df383
refs/heads/master
2021-09-02T05:07:49.331092
2017-12-30T16:51:05
2017-12-30T16:51:05
115,810,149
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
1,826
cpp
FileUtils.cpp
/* * FileUtils.cpp * * Created on: 30 äåê. 2017 ã. * Author: Àë¸íà */ #include "FileUtils.h" std::string FILEUTILS_TAG="FileUtils"; int makeSureFileExists(const char* fname, int isFile, LoggerEngine* logger_ptr) { HANDLE findPath; WIN32_FIND_DATA findData; findPath = FindFirstFile(fname,&findData); int result = (findPath != INVALID_HANDLE_VALUE); if (result) { std::string fname_st(fname); logString(FILEUTILS_TAG,"Search successful fname:",fname_st,logger_ptr); } else { unsigned long errCode = GetLastError(); logPtr(FILEUTILS_TAG,"Error during log opening error code=",errCode,logger_ptr); if (!(isFile)) CreateDirectory(fname,NULL); else { HANDLE file; file = CreateFile(fname,GENERIC_WRITE | GENERIC_READ,0,NULL,CREATE_NEW,0,NULL); if (file != INVALID_HANDLE_VALUE) CloseHandle(file); else { errCode = GetLastError(); logPtr(FILEUTILS_TAG,"Log file creating error, error code=",GetLastError(),logger_ptr); } } } FindClose(findPath); return result; } void getLogPath(char* dest, char* dirName, void* logger_ptr ) { SHGetFolderPath(NULL,CSIDL_APPDATA,NULL,SHGFP_TYPE_CURRENT,dest); makeSureFileExists(dest,FALSE,(LoggerEngine*)logger_ptr); strcat(dest,dirName); makeSureFileExists(dest,FALSE,(LoggerEngine*)logger_ptr); } void getLogFname(char* dest, char* dirName, char* fname, void* logger_ptr) { getLogPath(dest, dirName, (LoggerEngine*)logger_ptr); strcat(dest,fname); } void logString(std::string& tag, std::string msg, std::string msg2, LoggerEngine* logger_ptr) { if (logger_ptr) (*logger_ptr).logString(tag,msg,msg2); } void logPtr(std::string& tag, std::string msg, unsigned ptr, LoggerEngine* logger_ptr) { if (logger_ptr) (*logger_ptr).logPtr(tag,msg,ptr); }
f4b71242f1cc76912e26d58fc56ca61ad8df92c9
0e2b9243fd5d36e8724893aada5eb9205edb8893
/DSA-wangdao/6.cpp
63c04c4fb5436521c85354a175a221dfbf627603
[]
no_license
songcs/ky-code
80edb4abf13bf154d1f6e4c6815e26cdbab4a3f9
62322532fdfd94c5f252b28aef31b11076c7ed70
refs/heads/master
2021-01-01T18:40:40.680472
2017-08-18T03:38:49
2017-08-18T03:38:49
98,404,161
0
0
null
null
null
null
UTF-8
C++
false
false
1,488
cpp
6.cpp
/*一般线性表的顺序查找*/ typedef struct { ElemType *elem;//元素存储空间基址,建表时按实际长度分配,0号单元留空 int TableLen;//表的长度 } SSTable; int Search_Seq(SSTable ST, ElemType key) { ST.elem[0] = key;//哨兵 for (i = ST.TableLen; ST.elem[i] != key; i--); return i;//若表中不存在关键字为key的元素,查找到i=0时,退出for循环 } /*折半查找*/ int Binary_Search(SSTable L, ElemType key) { int low = 0, high = L.TableLen - 1, mid; while (low <= high) { mid = (low + high) / 2; if (L.elem[mid] == key) return mid; else if (L.elem[mid] > key) high = mid - 1; else low = mid + 1; } return -1; } /*折半查找的递归算法*/ int Bin_Search_Rec(SSTable st, ElemType key, int low, int high) { if (low > high) return 0; mid = (low + high) / 2; if (key > st.elem[mid]) Bin_Search_Rec(st, key, mid + 1, high); else if (key < st.elem[mid]) Bin_Search_Rec(st, key, low, mid - 1); else return mid; } /*若找到指定的结点,将该结点和其前驱结点(若存在)交换*/ int SeqSrch(SSTable st, ElemType k) { int i = 0, n = st.TableLen; while ((st.elem[i] != key) && (i < n)) i++; if (i < n && i > 0) { ElemType temp = st.elem[i]; st.elem[i] = st.elem[i - 1]; st.elem[i - 1] = temp; return i - 1; } else return -1; }
f4dc99b928f5e02a406d7a771877342bb86eee60
263454e4d7f144d15a7676811b4ad4eeb5390a0a
/558 UVA.cpp
414e77b63d90ae66bf17b2fec1263635134b3e32
[]
no_license
notorious94/UVa-solution
4d6b90518f499b24d55af75f448445aac5252795
367d62dedbad0c2a2718a1807917dc6965fd39e3
refs/heads/master
2021-06-07T20:24:46.233613
2020-01-27T17:14:19
2020-01-27T17:14:19
94,576,972
3
3
null
null
null
null
UTF-8
C++
false
false
1,818
cpp
558 UVA.cpp
#include<bits/stdc++.h> using namespace std; /// M A C R O Starts Here #define pf printf #define sf scanf #define MAX 500000 #define MOD 100000007 #define INF INT_MAX #define pi acos(-1.0) #define get_stl(s) getline(cin,s) #define sif(a) scanf("%d",&a) #define pif(a) printf("%d\n",a) #define puf(a) printf("%llu\n",a) #define pii pair<int, int> #define mem(name, value) memset(name, value, sizeof(name)) #define all(name) name.begin(),name.end() typedef long long ll; typedef unsigned long long ull; class edge{ public: int u,v,w; edge(int a, int b, int c) { u = a; v = b; w = c; } }; int dist[1000]; vector<edge>e; void init(int n) { e.clear(); for(int i=0;i<n;i++) dist[i] = INF; } void input(int m) { int a,b,c; while(m--) { scanf("%d%d%d",&a,&b,&c); e.push_back(edge(a,b,c)); } } bool BellmanFord(int n) { dist[0] = 0; for(int s=1;s<=n;s++) { bool update = false; for(int i=0;i<e.size();i++) { int u = e[i].u; int v = e[i].v; int w = e[i].w; if(dist[u]!=INF) { if(dist[u]+w<dist[v]) { dist[v] = dist[u]+w; update = true; } } } if(update == true && s==n) return true; if(update == false) return false; } } int main() { //freopen("in.txt","r", stdin); //freopen("out.txt","w", stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int t,n,m; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&m); init(n); input(m); (BellmanFord(n)) ? printf("possible\n") : printf("not possible\n"); } return 0; }
998a646aa78865465a13d25a0c85109b35b9abf1
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/Trigger/TrigValidation/TrigValTools/src/TRoot2Html.cxx
c5785b4fce307f8e3aef24117491167e7c9d0711
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
5,071
cxx
TRoot2Html.cxx
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ /** * @file TRoot2Html.cxx * @brief TRoot2Html implementation * @author Frank Winklmeier * * $Id: TRoot2Html.cxx,v 1.1 2008-07-28 11:02:00 fwinkl Exp $ */ #include "TrigValTools/TRoot2Html.h" #include <iostream> #include <sstream> #include "TError.h" #include "TClass.h" #include "TH1.h" #include "TFile.h" #include "TCanvas.h" #include "TSystem.h" #include "TKey.h" #include "TPRegexp.h" using namespace std; TRoot2Html::TRoot2Html() : _nodeId(1), _showFullFileName(kFALSE) { setOutputDir("./"); setImageSize(400,400); } TRoot2Html::TRoot2Html(const TRoot2Html& other): TMultiFileLooper(other), _imgHeight(other._imgHeight), _imgWidth(other._imgWidth), _nodeId(other._nodeId), _showFullFileName(other._showFullFileName) { } void TRoot2Html::beginJob() { _xml.open(_outDir+"/tree.xml"); if (!_xml) { cout << "Cannot write to directory " << _outDir << endl; return; } _xml << "<?_xml version='1.0' encoding='iso-8859-1'?>" << endl; _xml << "<!-- This file was auto generated by root2html -->" << endl; _xml << "<!-- Use it with the dhtmlxTree component (http://www.scbr.com/docs/products/dhtmlxTree) -->" << endl; _xml << "<tree id=\"0\">" << endl; _nodeId = 1; } void TRoot2Html::endJob() { _xml << "</tree>" << endl; _xml.close(); } void TRoot2Html::beforeFile() { TString treeNodeName; if (_showFullFileName) treeNodeName = file()->GetName(); else treeNodeName = gSystem->BaseName(file()->GetName()); _xml << "<!-- Start of " << treeNodeName << " -->" << endl; _xml << xmlTreeItem(treeNodeName) << endl; // Create output directory gSystem->mkdir(_outDir+"/img", true); } void TRoot2Html::afterFile() { _xml << xmlTreeItemClose() << endl; } void TRoot2Html::beforeDir() { TString s(getPathFromDir(*gDirectory)); TString imgDir = TString(_outDir) + "/img/" + s; gSystem->mkdir(imgDir, true); _xml << xmlTreeItem(gDirectory->GetName()) << endl; } void TRoot2Html::afterDir() { _xml << xmlTreeItemClose() << endl; } void TRoot2Html::processKey(TDirectory& dir, TKey& key) { dir.cd(); TObject* obj = key.ReadObj(); if (obj->IsA()->InheritsFrom("TH1")) { _xml << xmlTreeItem(key.GetName()) << endl; TString imgPath = hist2Png(*gDirectory, key.GetName()); if (imgPath!="") { _xml << xmlUserData("img",imgPath) << endl; } _xml << xmlTreeItemClose() << endl; } } // Save histogram 'name' from 'dir' in '_outDir/img' // Return "" on error otherwise image path relative to _outDir TString TRoot2Html::hist2Png(TDirectory& dir, const TString& name) { TH1* h = (TH1*)dir.Get(name); if (h==0) { cout << "hist2Png: Cannot load histogram " << name << endl; return ""; } TCanvas c("c","c",_imgWidth,_imgHeight); TString options(getDrawOptions(*h)); if (_verbose) cout << "Drawing histogram " << h->GetName() << " (" << h->ClassName() << ") with options '" << options << "'" << endl; h->Draw(options); TString s(getPathFromDir(dir)); TString pngName = "img/" + s + "/" + name + ".png"; // Suppress the info message when saving file Int_t oldIgnoreLevel = gErrorIgnoreLevel; if (!_verbose) gErrorIgnoreLevel = kWarning; c.SaveAs(_outDir+"/"+pngName); gErrorIgnoreLevel = oldIgnoreLevel; return pngName; } // Set draw options for all histograms matching re void TRoot2Html::addDrawOptions(const char* regexp, const char* options) { if (regexp && options) { TPRegexp* re = new TPRegexp(regexp); if (re) _drawOptions.push_back(std::pair<TPRegexp*,TString>(re,options)); } } void TRoot2Html::addClassDrawOptions(const char* regexp, const char* options) { if (regexp && options) { TPRegexp* re = new TPRegexp(regexp); if (re) _classDrawOptions.push_back(std::pair<TPRegexp*,TString>(re,options)); } } // return draw options for specified histogram TString TRoot2Html::getDrawOptions(const TH1& h) { TString options(""); // First check if we have class wide draw options for this histogram vector< pair<TPRegexp*,TString> >::iterator iter; for (iter=_classDrawOptions.begin(); iter!=_classDrawOptions.end(); iter++) { if (iter->first->Match(h.ClassName())>0) { options = iter->second; break; } } // Check if any regexp matches the histogram name for (iter=_drawOptions.begin(); iter!=_drawOptions.end(); iter++) { if (iter->first->Match(h.GetName())>0) { options = iter->second; break; } } return options; } // Tree node with text and id const char* TRoot2Html::xmlTreeItem(const char* text) { TString s; s.Form("<item text=\"%s\" id=\"%d\">",text,_nodeId); _nodeId++; return s.Data(); } // Tree node close const char* TRoot2Html::xmlTreeItemClose() { return "</item>"; } // User data for tree node const char* TRoot2Html::xmlUserData(const char* name, const char* data) { TString s; s.Form("<userdata name=\"%s\">%s</userdata>",name,data); return s.Data(); }
e1ce5bd3e4df08c4a5476dd13f6f0354c34dc5ed
d14ff1fb06234cc93cf1abb76effaa4321912e18
/src/elements/trailGroupManager.h
aade94d53db576717303773e3df49f7b4edf879d
[]
no_license
YeongJoo-Kim/RideAndFall-037
b1f7adb681ddd2c0f846afadf92e3afa6ce8914e
8554d54c0582f5531e0c5c8554d1f30edada734a
refs/heads/master
2021-12-03T04:15:33.504583
2013-06-05T13:44:14
2013-06-05T13:44:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,618
h
trailGroupManager.h
/* * trailGroupManager.h * ofxFernCameraDemo * * Created by theo on 28/01/2010. * * Copyright Theodore Watson 2010 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * */ #include "ofMain.h" #include "baseTrailParticle.h" #include "srcDstTrailParticle.h" class trailGroupManager{ public: void setup(int numParticles, ofPoint spawnPoint, ofPoint targetPoint ){ particles.assign(numParticles, srcDstTrailParticle()); for(int i = 0; i < particles.size(); i++){ particles[i].init( spawnPoint, targetPoint, 10, ofVec3f(ofRandom(10, -10), ofRandom(10, -10), ofRandom(10, -10)), ofVec3f(0,0,0) ); } } void update(float forceMag){ for(int i = 0; i < particles.size(); i++){ particles[i].update(forceMag, 0.1, 0.75); } } vector <baseElement *> getElements(){ vector <baseElement *> elements; for(int i = 0; i < particles.size(); i++){ elements.push_back(&particles[i]); } return elements; } vector <srcDstTrailParticle> particles; };
e7bb5b918c35e4222c409feac1efeab619f07d89
3ea61f80e1e4b2113523624f0de88457b2669852
/src/host/vrm3dvision_backup/srv_gen/cpp/include/vrm3dvision/setExposure.h
7faab3cb858df8f6e205a478d95cec538af17f9a
[]
no_license
rneerg/RoboVision3D
c4f8e05e91702a0df04eeb902771dad52588eb45
f0293ea5f1aaaf64d4530ac9f0f92a3583b55ef6
refs/heads/master
2020-04-18T16:03:55.217179
2014-09-04T11:55:03
2014-09-04T11:55:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,743
h
setExposure.h
/* Auto-generated by genmsg_cpp for file /home/jeppe/workspace-d3/robovision3d/host/vrm3dvision/srv/setExposure.srv */ #ifndef VRM3DVISION_SERVICE_SETEXPOSURE_H #define VRM3DVISION_SERVICE_SETEXPOSURE_H #include <string> #include <vector> #include <map> #include <ostream> #include "ros/serialization.h" #include "ros/builtin_message_traits.h" #include "ros/message_operations.h" #include "ros/time.h" #include "ros/macros.h" #include "ros/assert.h" #include "ros/service_traits.h" namespace vrm3dvision { template <class ContainerAllocator> struct setExposureRequest_ { typedef setExposureRequest_<ContainerAllocator> Type; setExposureRequest_() : camera(0) , exposure() { } setExposureRequest_(const ContainerAllocator& _alloc) : camera(0) , exposure(_alloc) { } typedef int32_t _camera_type; int32_t camera; typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _exposure_type; std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > exposure; enum { LEFT_CAMERA = 1 }; enum { RIGHT_CAMERA = 2 }; enum { LEFT_AND_RIGHT_CAMERA = 3 }; enum { COLOR_CAMERA = 4 }; enum { ALL_CAMERAS = 7 }; typedef boost::shared_ptr< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::vrm3dvision::setExposureRequest_<ContainerAllocator> const> ConstPtr; boost::shared_ptr<std::map<std::string, std::string> > __connection_header; }; // struct setExposureRequest typedef ::vrm3dvision::setExposureRequest_<std::allocator<void> > setExposureRequest; typedef boost::shared_ptr< ::vrm3dvision::setExposureRequest> setExposureRequestPtr; typedef boost::shared_ptr< ::vrm3dvision::setExposureRequest const> setExposureRequestConstPtr; template <class ContainerAllocator> struct setExposureResponse_ { typedef setExposureResponse_<ContainerAllocator> Type; setExposureResponse_() : success(false) { } setExposureResponse_(const ContainerAllocator& _alloc) : success(false) { } typedef uint8_t _success_type; uint8_t success; typedef boost::shared_ptr< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::vrm3dvision::setExposureResponse_<ContainerAllocator> const> ConstPtr; boost::shared_ptr<std::map<std::string, std::string> > __connection_header; }; // struct setExposureResponse typedef ::vrm3dvision::setExposureResponse_<std::allocator<void> > setExposureResponse; typedef boost::shared_ptr< ::vrm3dvision::setExposureResponse> setExposureResponsePtr; typedef boost::shared_ptr< ::vrm3dvision::setExposureResponse const> setExposureResponseConstPtr; struct setExposure { typedef setExposureRequest Request; typedef setExposureResponse Response; Request request; Response response; typedef Request RequestType; typedef Response ResponseType; }; // struct setExposure } // namespace vrm3dvision namespace ros { namespace message_traits { template<class ContainerAllocator> struct IsMessage< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > : public TrueType {}; template<class ContainerAllocator> struct IsMessage< ::vrm3dvision::setExposureRequest_<ContainerAllocator> const> : public TrueType {}; template<class ContainerAllocator> struct MD5Sum< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > { static const char* value() { return "74690dad3b322aa8761f4ad7fe2c58c2"; } static const char* value(const ::vrm3dvision::setExposureRequest_<ContainerAllocator> &) { return value(); } static const uint64_t static_value1 = 0x74690dad3b322aa8ULL; static const uint64_t static_value2 = 0x761f4ad7fe2c58c2ULL; }; template<class ContainerAllocator> struct DataType< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > { static const char* value() { return "vrm3dvision/setExposureRequest"; } static const char* value(const ::vrm3dvision::setExposureRequest_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct Definition< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > { static const char* value() { return "int32 LEFT_CAMERA = 1\n\ int32 RIGHT_CAMERA = 2\n\ int32 LEFT_AND_RIGHT_CAMERA = 3\n\ int32 COLOR_CAMERA = 4\n\ int32 ALL_CAMERAS = 7\n\ \n\ int32 camera\n\ string exposure\n\ \n\ "; } static const char* value(const ::vrm3dvision::setExposureRequest_<ContainerAllocator> &) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace message_traits { template<class ContainerAllocator> struct IsMessage< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > : public TrueType {}; template<class ContainerAllocator> struct IsMessage< ::vrm3dvision::setExposureResponse_<ContainerAllocator> const> : public TrueType {}; template<class ContainerAllocator> struct MD5Sum< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > { static const char* value() { return "358e233cde0c8a8bcfea4ce193f8fc15"; } static const char* value(const ::vrm3dvision::setExposureResponse_<ContainerAllocator> &) { return value(); } static const uint64_t static_value1 = 0x358e233cde0c8a8bULL; static const uint64_t static_value2 = 0xcfea4ce193f8fc15ULL; }; template<class ContainerAllocator> struct DataType< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > { static const char* value() { return "vrm3dvision/setExposureResponse"; } static const char* value(const ::vrm3dvision::setExposureResponse_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct Definition< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > { static const char* value() { return "bool success\n\ \n\ \n\ "; } static const char* value(const ::vrm3dvision::setExposureResponse_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct IsFixedSize< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > : public TrueType {}; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::vrm3dvision::setExposureRequest_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.camera); stream.next(m.exposure); } ROS_DECLARE_ALLINONE_SERIALIZER; }; // struct setExposureRequest_ } // namespace serialization } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::vrm3dvision::setExposureResponse_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.success); } ROS_DECLARE_ALLINONE_SERIALIZER; }; // struct setExposureResponse_ } // namespace serialization } // namespace ros namespace ros { namespace service_traits { template<> struct MD5Sum<vrm3dvision::setExposure> { static const char* value() { return "5ba508c10b2f392acb59bcd971e154d8"; } static const char* value(const vrm3dvision::setExposure&) { return value(); } }; template<> struct DataType<vrm3dvision::setExposure> { static const char* value() { return "vrm3dvision/setExposure"; } static const char* value(const vrm3dvision::setExposure&) { return value(); } }; template<class ContainerAllocator> struct MD5Sum<vrm3dvision::setExposureRequest_<ContainerAllocator> > { static const char* value() { return "5ba508c10b2f392acb59bcd971e154d8"; } static const char* value(const vrm3dvision::setExposureRequest_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct DataType<vrm3dvision::setExposureRequest_<ContainerAllocator> > { static const char* value() { return "vrm3dvision/setExposure"; } static const char* value(const vrm3dvision::setExposureRequest_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct MD5Sum<vrm3dvision::setExposureResponse_<ContainerAllocator> > { static const char* value() { return "5ba508c10b2f392acb59bcd971e154d8"; } static const char* value(const vrm3dvision::setExposureResponse_<ContainerAllocator> &) { return value(); } }; template<class ContainerAllocator> struct DataType<vrm3dvision::setExposureResponse_<ContainerAllocator> > { static const char* value() { return "vrm3dvision/setExposure"; } static const char* value(const vrm3dvision::setExposureResponse_<ContainerAllocator> &) { return value(); } }; } // namespace service_traits } // namespace ros #endif // VRM3DVISION_SERVICE_SETEXPOSURE_H
8f93210fcb4091185bb99c36e9c49c2074e052cf
020f3a042b20fa2f1ae0b0871b63ddeb3d26b2e4
/src/lib/GammaPP.cpp
a2dca97dc104c8795f8962740df37c622d333801
[ "MIT" ]
permissive
bbw7561135/mcray
f19553795a794fd878ced73f611f6e1239d8b402
80c2867e70733fb0ea6d30bcc592225c35e01d80
refs/heads/main
2023-01-28T04:54:01.226664
2020-12-04T23:06:09
2020-12-04T23:06:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,293
cpp
GammaPP.cpp
/* * GammaPP.cpp * * Author: * Oleg Kalashev * * Copyright (c) 2020 Institute for Nuclear Research, RAS * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "GammaPP.h" #include <math.h> #include "MathUtils.h" #include "Output.h" #include "ParticleStack.h" #include "TableBackgrounds.h" #include "PropagationEngine.h" namespace Interactions { using namespace mcray; const double EMInteraction::AlphaEM = 7.2973525698e-3;//~1/137 const double EMInteraction::SigmaCoef = AlphaEM*AlphaEM*2*M_PI; GammaPP::GammaPP(BackgroundIntegral* aBackground): fBackground(aBackground) { } RandomInteraction* GammaPP::Clone() const { return new GammaPP(fBackground->Clone()); } GammaPP::~GammaPP() { } double GammaPP::SampleSecondaryFracE(double aS, double aRand) const { double mass = Particle::Mass(Electron); double s = aS/(mass*mass); SecondaryEnergySamplingEquationPars pars = {s, aRand*DifSigmaIntegral(0.5, s) }; double x_lo = 0.5*(1. - sqrt(1. - 4./s)); double x_hi = 0.5; const double relError = 1e-3; const int max_iter = 100; double r = 0; try{ //TODO: use MathUtils::SampleLogDistribution sampling method r = MathUtils::SolveEquation(&SecondaryEnergySamplingEquation, x_lo, x_hi, &pars, relError, max_iter, gsl_root_fsolver_bisection); }catch(Exception* ex) { #ifdef _DEBUG fDebugOutput = true; double dx = 0.01*(x_hi-x_lo); for(double x=x_lo; x<=x_hi; x+=dx) { SecondaryEnergySamplingEquation(x, &pars); } ASSERT(0); #endif throw ex; } return r; } bool GammaPP::SampleS(const Particle& aParticle, double& aS, Randomizer& aRandomizer) const { ASSERT(aParticle.Type == Photon); aS = 0.; return (fBackground->GetRateAndSampleS(fSigma, aParticle, aRandomizer, aS)!=0); } void GammaPP::SampleSecondaries(Particle& aParticle, std::vector<Particle>& aSecondaries, double aS, Randomizer& aRandomizer) const { ASSERT(aParticle.Type == Photon); Particle sec = aParticle; Particle sec2 = aParticle; double rand = aRandomizer.Rand(); sec.Type = rand>0.5 ? Electron : Positron; sec2.Type = rand>0.5 ? Positron : Electron; double r = SampleSecondaryFracE(aS, aRandomizer.Rand()); sec.Energy = aParticle.Energy*r; sec2.Energy = aParticle.Energy - sec.Energy; aSecondaries.push_back(sec); aSecondaries.push_back(sec2); } GammaPP::Sigma::Sigma() { double m = Particle::Mass(Electron); fThresholdS=4.*m*m; } double GammaPP::Sigma::f(double s) const { double beta2 = 1. - fThresholdS/s; if(beta2<=0) return 0; double beta = sqrt(beta2); double result = SigmaCoef*((3.-beta2*beta2)*log((1.+beta)/(1.-beta))-2.*beta*(2.-beta2))/s; ASSERT_VALID_NO(result); return result; } double GammaPP::Rate(const Particle& aParticle) const { if(aParticle.Type != Photon) return 0.; return fBackground->GetRateS(fSigma, aParticle); } bool GammaPP::fDebugOutput = false; double GammaPP::SecondaryEnergySamplingEquation(double r, void* aParams) { SecondaryEnergySamplingEquationPars* p=(SecondaryEnergySamplingEquationPars*)aParams; double result = DifSigmaIntegral(r, p->s) - p->Integral; #ifdef _DEBUG if(GammaPP::fDebugOutput) { std::cerr << "f( " << r << " ) = " << result << std::endl; } #endif return result; } double GammaPP::DifSigmaIntegral(double r, double s) { double beta = sqrt(1.-4./s); double rMin = 0.5*(1.0 - beta); if(r<=rMin) return 0.; return DifSigmaIntegralUnnorm(r, s) - DifSigmaIntegralUnnorm(rMin, s); } double GammaPP::DifSigmaIntegralUnnorm(double r, double s) { /* Formula for unnormalized diff cross section was taken from http://lanl.arxiv.org/abs/1106.5508v1 eq. (10) DifSigmaIntegral is integral of diff cross section from r_min = 1/2*(1 - (1 - 4/s)^(1/2)) to r Mathematica program used to produce the output: G[r_, s_] = 1/r*(r^2/(1 - r) + 1 - r + 4/s/(1 - r) - 4/s/s/r/(1 - r)/(1 - r))/(1 + (2 - 8/s)*4/s) F[r_, s_] = Integrate[G[t, s], {t, 1/2*(1 - (1 - 4/s)^(1/2)), r}, Assumptions -> r > 1/2*(1 - (1 - 4/s)^(1/2)) && r < 0.5 && s > 4] //the exact expression below has small (~1e-16 in mathematica) nonzero value for r=rMin (mathematica bug?) //therefore we subtract F[rMin, s] from F[r, s] */ double s2 = s*s; double r2 = r*r; double r3 = r2*r; double beta = sqrt(1.-4./s); double log_r_minus = log(1 - r); double log_r = log(r); double result = 0.; /* ///test (moved to DifSigmaIntegralTest) double rMin = 0.5*(1.0 - beta); if(r<=rMin) return 0.; double a=r-rMin; if(a<1e-3) { double b_1=beta-1.; double b_P1 = beta+1.; result = (16*a*(-2 + s))/ (b_1*b_1*b_P1*b_P1* (-32 + 8*s + s2)) + (32*a*a*(-4*beta + beta*s))/ (b_1*b_1*b_1*b_P1*b_P1*b_P1* (-32 + 8*s + s2)) + (256*a*a*a*(28 - 11*s + s2))/ (3.*b_1*b_1*b_1*b_1*b_P1*b_P1*b_P1*b_P1*s* (-32 + 8*s + s2)); } else {*/ result = -((4 - 8*r + r*s2 - 3*r2*s2 + 2*r3*s2 - 4*r*beta + 4*r2*beta - r*s2*beta + r2*s2*beta + 8*r*log_r_minus - 8*r2*log_r_minus - 4*r*s*log_r_minus + 4*r2*s*log_r_minus - r*s2*log_r_minus + r2*s2*log_r_minus - 8*r*log_r + 8*r2*log_r + 4*r*s*log_r - 4*r2*s*log_r + r*s2*log_r - r2*s2*log_r + (-1 + r)*r*(-8 + 4*s + s2)*log(1 - beta) - (-1 + r)*r*(-8 + 4*s + s2)*log(1 + beta))/ ((-1 + r)*r*(-32 + 8*s + s2))); //} ASSERT_VALID_NO(result); return result; } double GammaPP::DifSigmaIntegralTest(double r, double s, bool aSeries, double& a) { /* Formula for unnormalized diff cross section was taken from http://lanl.arxiv.org/abs/1106.5508v1 eq. (10) DifSigmaIntegral is integral of diff cross section from r_min = 1/2*(1 - (1 - 4/s)^(1/2)) to r Mathematica program used to produce the output: G[r_, s_] = 1/r*(r^2/(1 - r) + 1 - r + 4/s/(1 - r) - 4/s/s/r/(1 - r)/(1 - r))/(1 + (2 - 8/s)*4/s) F[r_, s_] = Integrate[G[t, s], {t, 1/2*(1 - (1 - 4/s)^(1/2)), r}, Assumptions -> r > 1/2*(1 - (1 - 4/s)^(1/2)) && r < 0.5 && s > 4] //the exact expression below has small (~1e-16 in mathematica) nonzero value for r=rMin (mathematica bug?) */ double s2 = s*s; double r2 = r*r; double r3 = r2*r; double beta = sqrt(1.-4./s); double log_r_minus = log(1 - r); double log_r = log(r); double rMin = 0.5*(1.0 - beta); if(r<=rMin) return 0.; a=r-rMin; double result = 0.; if(aSeries)///Series[F[1/2*(1 - (1 - 4/s)^(1/2)) + a, s], {a, 0, 3}] excluding part depending on s only { double b_1=beta-1.; double b_P1 = beta+1.; result = (16*a*(-2 + s))/ (b_1*b_1*b_P1*b_P1* (-32 + 8*s + s2)) + (32*a*a*(-4*beta + beta*s))/ (b_1*b_1*b_1*b_P1*b_P1*b_P1* (-32 + 8*s + s2)) + (256*a*a*a*(28 - 11*s + s2))/ (3.*b_1*b_1*b_1*b_1*b_P1*b_P1*b_P1*b_P1*s* (-32 + 8*s + s2)); } else {//F[r_, s_] result = -((4 - 8*r + r*s2 - 3*r2*s2 + 2*r3*s2 - 4*r*beta + 4*r2*beta - r*s2*beta + r2*s2*beta + 8*r*log_r_minus - 8*r2*log_r_minus - 4*r*s*log_r_minus + 4*r2*s*log_r_minus - r*s2*log_r_minus + r2*s2*log_r_minus - 8*r*log_r + 8*r2*log_r + 4*r*s*log_r - 4*r2*s*log_r + r*s2*log_r - r2*s2*log_r + (-1 + r)*r*(-8 + 4*s + s2)*log(1 - beta) - (-1 + r)*r*(-8 + 4*s + s2)*log(1 + beta))/ ((-1 + r)*r*(-32 + 8*s + s2))); } ASSERT_VALID_NO(result); return result; } void GammaPP::UnitTest() { double Zmax = 2e-6; double Emin = 10/units.Eunit; //double alphaThinning = 0;//alpha = 1 conserves number of particles on the average; alpha = 0 disables thinning ParticleStack particles; Result result(Emin); result.AddOutput(new SpectrumOutput("out", Emin, pow(10, 0.05))); cosmology.Init(); CompoundBackground backgr; double cmbTemp = 2.73/Units::phTemperature_mult/units.Eunit; backgr.AddComponent(new PlankBackground(cmbTemp, 1e-4*cmbTemp, 1e4*cmbTemp)); //backgr.AddComponent(new PlankBackground(cmbTemp, 6.2e-10/units.Eunit, 6.4e-10/units.Eunit));//only central value //backgr.AddComponent(new Backgrounds::Kneiske1001EBL()); //backgr.AddComponent(new Backgrounds::GaussianBackground(6.3e-10/units.Eunit, 1e-11/units.Eunit, 1., 413*units.Vunit)); //double n = BackgroundUtils::CalcIntegralDensity(backgr)/units.Vunit; double stepZ = 0.05; double logStepK = pow(10,0.05); double epsRel = 1e-3; PBackgroundIntegral backgrI = new ContinuousBackgroundIntegral(backgr, stepZ, logStepK, Zmax, epsRel); GammaPP* pp = new GammaPP(backgrI); RedShift* rs = new RedShift(); double E = Emin; std::cerr << "#E\tRedshiftRate\tPPRate\t\t[E]=1eV [Rate]=1/Mpc\n"; for(double E=1; E<1e14; E*=logStepK) { Particle photon(Photon, 0.); photon.Energy = E/units.Eunit;//MeV double rate = pp->Rate(photon); double redshiftRate = rs->Rate(photon); double mult = 1./units.Lunit*Units::Mpc_in_cm; std::cerr << E*1e6 << "\t" << redshiftRate*mult << "\t" << rate*mult << std::endl; } double s = 8.; double x_lo = 0.5*(1. - sqrt(1. - 4./s)); double dx = 0.01*(0.5-x_lo); std::cerr << "\n\n\n\n\n"; for(double x=x_lo; x<=0.5; x+=dx) { double a; double seriesRes = DifSigmaIntegralTest(x,s,true,a); double origRes = DifSigmaIntegralTest(x,s,false,a); std::cerr << a << "\t" << origRes << "\t" << seriesRes << std::endl; } PropagationEngine pe(particles, result, 2011); //EnergyBasedThinning thinning(alphaThinning); //pe.SetThinning(&thinning); pe.AddInteraction(rs); pe.AddInteraction(pp); int nParticlesPerBin = 10000; double Emax = 1e9/units.Eunit; /// build initial state //for(double E=Emin; E<Emax; E*=logStepK) //{ E=Emax; Particle photon(Photon, Zmax); photon.Energy = E;//MeV //electron.Weight = exp(-Emax/E); //if(electron.Weight>0) for(int i=0; i<nParticlesPerBin; i++) particles.AddPrimary(photon); //} std::cerr << std::setprecision(15); pe.Run(); } void GammaPP::UnitTestSampling(double aE, double aZ) { std::string out = "sample_ph_E"; out += ToString(aE*1e6);//eV out += "_Z"; out += ToString(aZ); std::ofstream secPPout; secPPout.open("sample_sec_pp",std::ios::out); std::ofstream secPPoutVarS; secPPoutVarS.open("sample_sec_pp_varS",std::ios::out); debug.SetOutputFile(out); if(!cosmology.IsInitialized()) cosmology.Init(); CompoundBackground backgr; double cmbTemp = 2.73/Units::phTemperature_mult/units.Eunit; backgr.AddComponent(new PlankBackground(cmbTemp, 1e-3*cmbTemp, 1e3*cmbTemp)); //backgr.AddComponent(new PlankBackground(cmbTemp, 6.2e-10/units.Eunit, 6.4e-10/units.Eunit));//only central value double stepZ = 0.05; double logStepK = pow(10,0.05); double epsRel = 1e-3; Backgrounds::Kneiske0309EBL* kn0309 = new Backgrounds::Kneiske0309EBL(); backgr.AddComponent(kn0309); PBackgroundIntegral backgrI = new ContinuousBackgroundIntegral(backgr, stepZ, logStepK, aZ+1, epsRel); Interactions::GammaPP pp(backgrI); Particle photon(Photon, aZ); photon.Energy = aE;//MeV photon.Time.setZ(aZ); photon.Type = Photon; Randomizer rnd; double S=2.; for(int i=0; i<10000; i++) { std::vector<Particle> secondaries; if(pp.GetSecondaries(photon, secondaries, rnd))//this outputs sampled s to debug file { ASSERT(secondaries.size()==2); secPPoutVarS << secondaries[0].Energy/aE << "\n" << secondaries[1].Energy/aE << "\n"; } double r = pp.SampleSecondaryFracE(S, rnd.Rand()); secPPout << r << '\n'; secPPout << 1.-r << std::endl; } secPPout.close(); } void GammaPP::UnitTest(bool aPrintRates, bool aPropagate, bool aSplit, bool aBestFitEBL) { double Zmax = 2e-4; double Emax = 3e8/units.Eunit; double Emin = 1/units.Eunit; //double alphaThinning = 0;//alpha = 1 conserves number of particles on the average; alpha = 0 disables thinning ParticleStack particles; Result result(Emin); if(aPropagate) { std::string out = "out_pp_"; out += aSplit?"split" : "no_split"; result.AddOutput(new SpectrumOutput(out, Emin, pow(10, 0.05))); } if(!cosmology.IsInitialized()) cosmology.Init(); CompoundBackground backgr; double cmbTemp = 2.73/Units::phTemperature_mult/units.Eunit; backgr.AddComponent(new PlankBackground(cmbTemp, 1e-5*cmbTemp, 1e3*cmbTemp)); //backgr.AddComponent(new PlankBackground(cmbTemp, 6.2e-10/units.Eunit, 6.4e-10/units.Eunit));//only central value double stepZ = 0.05; double logStepK = pow(10,0.05); double epsRel = 1e-3; TableBackground* ebl = aBestFitEBL ? ((TableBackground*)new Backgrounds::Kneiske0309EBL()) : ((TableBackground*)new Backgrounds::Kneiske1001EBL()); PBackgroundIntegral backgrIebl; PRandomInteraction ppEbl; if(!aSplit) { backgr.AddComponent(ebl); } else { backgrIebl = new ContinuousBackgroundIntegral(*ebl, stepZ, logStepK, Zmax, epsRel); ppEbl = new GammaPP(backgrIebl); } PBackgroundIntegral backgrI = new ContinuousBackgroundIntegral(backgr, stepZ, logStepK, Zmax, epsRel); PRandomInteraction pp = new GammaPP(backgrI); PCELInteraction rs = new RedShift(); double E = Emin; if(aPrintRates) { std::ofstream ratesOut; std::string ratesFile = "pp_rates_"; ratesFile += aBestFitEBL ? "BestFitEBL_" : "MinimalEBL_"; ratesFile += aSplit ? "split" : "no_split"; ratesOut.open(ratesFile.c_str(),std::ios::out); ratesOut << "#E\tRedshiftRate\tPPRate\t\t[E]=1eV [Rate]=1/Mpc\n"; for(double E=Emin; E<Emax; E*=logStepK) { Particle photon(Photon, 0.); photon.Energy = E/units.Eunit;//MeV double ppRate = pp->Rate(photon); double redshiftRate = rs->Rate(photon); if(aSplit) { ppRate += ppEbl->Rate(photon); } double mult = 1./units.Lunit*Units::Mpc_in_cm; ratesOut << E*1e6 << "\t" << redshiftRate*mult << "\t" << ppRate*mult << std::endl; } } if(!aPropagate) return; PropagationEngine pe(particles, result, 2011); //EnergyBasedThinning thinning(alphaThinning); //pe.SetThinning(&thinning); //pe.AddInteraction(rs); pe.AddInteraction(pp); //ics->fDeleteElectron = true;//check in single interaction mode if(aSplit) { pe.AddInteraction(ppEbl); } int nParticlesPerBin = 10000; /// build initial state //for(double E=Emin; E<Emax; E*=logStepK) //{ E=Emax; Particle photon(Photon, Zmax); photon.Energy = E;//MeV //electron.Weight = exp(-Emax/E); //if(electron.Weight>0) for(int i=0; i<nParticlesPerBin; i++) particles.AddPrimary(photon); //} pe.RunMultithread(); if(aSplit) delete ebl; } } /* namespace Interactions */
0ed699129c72412b082396d3427d0bf9fd640ebb
01b1f86aa05da3543a2399ffc34a8ba91183e896
/modules/core/trigonometric/include/nt2/trigonometric/functions/scalar/impl/trigo/trig_base.hpp
3fb9a0818dde29a854408bbe24c47f2a2bb37f8d
[ "BSL-1.0" ]
permissive
jtlap/nt2
8070b7b3c4b2f47c73fdc7006b0b0eb8bfc8306a
1b97350249a4e50804c2f33e4422d401d930eccc
refs/heads/master
2020-12-25T00:49:56.954908
2015-05-04T12:09:18
2015-05-04T12:09:18
1,045,122
35
7
null
null
null
null
UTF-8
C++
false
false
10,460
hpp
trig_base.hpp
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #ifndef NT2_TRIGONOMETRIC_FUNCTIONS_SCALAR_IMPL_TRIGO_TRIG_BASE_HPP_INCLUDED #define NT2_TRIGONOMETRIC_FUNCTIONS_SCALAR_IMPL_TRIGO_TRIG_BASE_HPP_INCLUDED #include <nt2/trigonometric/functions/scalar/impl/selection_tags.hpp> #include <nt2/trigonometric/functions/scalar/impl/trigo/trig_reduction.hpp> #include <nt2/include/functions/scalar/is_invalid.hpp> #include <nt2/include/functions/scalar/is_nan.hpp> #include <nt2/include/functions/scalar/is_eqz.hpp> #include <nt2/include/functions/scalar/is_nez.hpp> #include <nt2/include/functions/scalar/shift_left.hpp> #include <nt2/include/functions/scalar/sqr.hpp> #include <nt2/include/functions/scalar/rec.hpp> #include <nt2/include/functions/scalar/oneminus.hpp> #include <nt2/include/functions/scalar/bitofsign.hpp> #include <nt2/include/functions/scalar/bitwise_xor.hpp> #include <nt2/include/functions/scalar/bitwise_or.hpp> #include <nt2/include/functions/scalar/shift_left.hpp> #include <nt2/include/functions/scalar/abs.hpp> #include <nt2/include/functions/scalar/is_invalid.hpp> #include <nt2/include/constants/pio_4.hpp> #include <nt2/include/constants/one.hpp> #include <nt2/include/constants/quarter.hpp> #include <nt2/include/constants/pi.hpp> #include <nt2/include/constants/_45.hpp> #include <nt2/include/constants/pio_180.hpp> #include <nt2/include/constants/inf.hpp> #include <nt2/sdk/simd/tags.hpp> // trigonometric functions are implemented using the classical cephes/fdlibm/libc principles // however the formal reduce/eval/return is properly divided to allow choices versus // speed, accuracy and SIMD vectorisation // // On small_ ranges performance can be obtained with almost full accuracy (1 ulp) at 1 to 2 // cycles per element for a cosine computation using SIMD. But if one require full accuracy // on the full float or double range, the prize can grow up to few hundreds of cycle for // some big_ values of input. // See the NT2 technical documentation for more insights namespace nt2 { namespace details { // in the class defined below: // A0 is the argument type of the trigonometric functions // // Up to now, only floating real based on IEEE 754 float or double are supported // (sorry no long double yet for lack of portability) // The possible conversion of integer types to floating ones // is already addressed in the primary functors invocations namely cos_, sin_ etc. // WARNING: take attention to the fact that to fit SIMD needs sin(One<int32_t>()) // is a float and sin(One<int64_t>()) is a double template < class A0, class unit_tag> struct trig_ranges; template < class A0> struct trig_ranges<A0, radian_tag> { static inline A0 max_range() {return nt2::Pio_4<A0>(); } static inline A0 scale() {return nt2::One<A0>(); } }; template < class A0> struct trig_ranges<A0, pi_tag> { static inline A0 max_range() {return nt2::Quarter<A0>(); } static inline A0 scale() {return nt2::Pi<A0>(); } }; template < class A0> struct trig_ranges<A0, degree_tag> { static inline A0 max_range() {return nt2::_45<A0>(); } static inline A0 scale() {return nt2::Pio_180<A0>(); } }; // This class expose the public static members: // cosa x -> cos(a*x) // sina x -> sin(a*x) // tana x -> tan(a*x) // cota x -> cot(a*x) // sincosa x -> cos(a*x) and sin(a*x) // "a" is not a run time parameter ! // It stands as a remainder that according the Tag it can be considered // as a scale factor for the input of values: // 1 radian_tag, // pi pi_tag // pi/180 degree_tag, // but the scaling is internal to the algorithm to provide better accuracy // and better performance. // It heritates of a reduction and an evaluation class to perform // the appropriate range reductions and function evaluations. // In this file stands the scalar version ! // Some definitions are useless but provide facilities of comparaison with // the SIMD implementation // template < class A0, class unit_tag, class style, class mode = big_> struct trig_base{}; template < class A0, class unit_tag, class mode> struct trig_base<A0,unit_tag,tag::not_simd_type,mode> { typedef trig_reduction<A0,unit_tag,tag::not_simd_type, mode> redu_t; typedef trig_evaluation<A0,tag::not_simd_type> eval_t; typedef typename meta:: scalar_of<A0>::type sA0; // scalar version of A0 typedef typename meta::as_integer<A0, signed>::type int_type; // signed integer type associated to A0 typedef typename meta::scalar_of<int_type>::type sint_type; // scalar version of the associated type typedef typename mode::type style; // for all functions the scalar algorithm is: // * quick return (or exception raising TODO) for inf and nan or specific invalid cases inputs // * range reduction // * computation of sign and evaluation selections flags // * evaluations // * return with flag based corrections static inline A0 cosa(const A0& a0){ return cosa(a0, style()); } static inline A0 sina(const A0& a0){ return sina(a0, style()); } static inline A0 tana(const A0& a0){ return tana(a0, style()); } static inline A0 cota(const A0& a0){ return cota(a0, style()); } static inline A0 sincosa(const A0& a0, A0& c){ return sincosa(a0,c,style()); } static inline A0 cosa(const A0& a0, const regular&) { static const sint_type de = static_cast<sint_type>(sizeof(sint_type)*8-1); // size in bits of the scalar types minus one if (nt2::is_invalid(a0)) return nt2::Nan<A0>(); //Nan or Inf input const A0 x = nt2::abs(a0); A0 xr = nt2::Nan<A0>(); const int_type n = redu_t::reduce(x, xr); const int_type swap_bit = n&nt2::One<int_type>(); const int_type sign_bit = shli(nt2::bitwise_xor(swap_bit, (n&2)>>1), de); A0 z = nt2::sqr(xr); if (swap_bit) z = eval_t::sin_eval(z, xr); else z = eval_t::cos_eval(z); return b_xor(z,sign_bit); } static inline A0 sina(const A0& a0, const regular&) { static const sint_type de = static_cast<sint_type>(sizeof(sint_type)*8-1); if (is_invalid(a0)) return Nan<A0>(); const A0 x = nt2::abs(a0); A0 xr = nt2::Nan<A0>(); const int_type n = redu_t::reduce(x, xr); const int_type swap_bit = n&nt2::One<int_type>(); const A0 sign_bit = nt2::bitwise_xor(nt2::bitofsign(a0), nt2::shli(n&nt2::Two<int_type>(), de-1)); A0 z = nt2::sqr(xr); if (swap_bit) z = eval_t::cos_eval(z); else z = eval_t::sin_eval(z, xr); return b_xor(z,sign_bit); } static inline A0 tana(const A0& a0, const regular&) { if (nt2::is_invalid(a0)||redu_t::tan_invalid(a0)) return nt2::Nan<A0>(); if (nt2::is_eqz(a0)) return a0; const A0 x = nt2::abs(a0); A0 xr = nt2::Nan<A0>(), y; const int_type n = redu_t::reduce(x, xr); y = eval_t::tan_eval(xr, 1-((n&1)<<1)); // 1 -- n even //-1 -- n odd return nt2::bitwise_xor(y, nt2::bitofsign(a0)); } static inline A0 cota(const A0& a0, const regular&) { if (nt2::is_invalid(a0)||redu_t::cot_invalid(a0)) return nt2::Nan<A0>(); const A0 x = nt2::abs(a0); const A0 bos = nt2::bitofsign(a0); if (!a0) return b_or(nt2::Inf<A0>(), bos); A0 xr = nt2::Nan<A0>(); const int_type n = redu_t::reduce(x, xr); const A0 y = eval_t::cot_eval(xr, 1-((n&1)<<1)); return nt2::bitwise_xor(y, bos); } static inline A0 sincosa(const A0& a0, A0& c, const regular&) { A0 s; if (nt2::is_invalid(a0)) { c = nt2::Nan<A0>(); return c; } const A0 x = nt2::abs(a0); static const sint_type de = static_cast<sint_type>(sizeof(sint_type)*8-1); A0 xr; const int_type n = redu_t::reduce(x, xr); const int_type swap_bit = n&One<int_type>(); const A0 z = nt2::sqr(xr); const int_type cos_sign_bit = shli(nt2::bitwise_xor(swap_bit, (n&nt2::Two<int_type>())>>1), de); const A0 sin_sign_bit = nt2::bitwise_xor(bitofsign(a0), nt2::shli(n&Two<int_type>(), de-1)); if (nt2::is_nez(swap_bit)) { c = eval_t::sin_eval(z, xr); s = eval_t::cos_eval(z); } else { c = eval_t::cos_eval(z); s = eval_t::sin_eval(z, xr); } c = nt2::bitwise_xor(c,cos_sign_bit); return nt2::bitwise_xor(s,sin_sign_bit); } static inline A0 cosa(const A0& a0, const fast &) { A0 x = scale(a0); if(not_in_range(a0)) return nt2::Nan<A0>(); else return eval_t::cos_eval(nt2::sqr(x)); } static inline A0 sina(const A0& a0, const fast&) { A0 x = scale(a0); if(not_in_range(a0)) return nt2::Nan<A0>(); else return eval_t::sin_eval(sqr(x), x); } static inline A0 tana(const A0& a0, const fast&) { A0 x = scale(a0); if(not_in_range(a0)) return nt2::Nan<A0>(); else return eval_t::base_tan_eval(x); } static inline A0 cota(const A0& a0, const fast&) { A0 x = scale(a0); if(not_in_range(a0)) return nt2::Nan<A0>(); else return nt2::rec(eval_t::base_tan_eval(x)); } static inline A0 sincosa(const A0& a0, A0& c, const fast&) { if(not_in_range(a0)){c = nt2::Nan<A0>(); return c; } A0 x = scale(a0); A0 z = nt2::sqr(x); c = eval_t::cos_eval(z); return eval_t::sin_eval(z, x); } static inline bool not_in_range(const A0& a0) { return nt2::abs(a0) > trig_ranges<A0,unit_tag>::max_range(); } static inline A0 scale (const A0& a0) { return a0*trig_ranges<A0,unit_tag>::scale(); } }; } } #endif
ae90759c68ac5d1e896720a27266627f3e8fa59a
a5a99f646e371b45974a6fb6ccc06b0a674818f2
/CondTools/DT/plugins/DTKeyedConfigDBInit.cc
77a68376b724b69b2b52f565f22b83b9cd490ca1
[ "Apache-2.0" ]
permissive
cms-sw/cmssw
4ecd2c1105d59c66d385551230542c6615b9ab58
19c178740257eb48367778593da55dcad08b7a4f
refs/heads/master
2023-08-23T21:57:42.491143
2023-08-22T20:22:40
2023-08-22T20:22:40
10,969,551
1,006
3,696
Apache-2.0
2023-09-14T19:14:28
2013-06-26T14:09:07
C++
UTF-8
C++
false
false
1,756
cc
DTKeyedConfigDBInit.cc
/* * See header file for a description of this class. * * $Date: 2010/06/01 10:34:12 $ * $Revision: 1.3 $ * \author Paolo Ronchese INFN Padova * */ //----------------------- // This Class' Header -- //----------------------- #include "CondTools/DT/plugins/DTKeyedConfigDBInit.h" //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "CondFormats/DTObjects/interface/DTKeyedConfig.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ServiceRegistry/interface/Service.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" #include "CondCore/DBOutputService/interface/KeyedElement.h" //--------------- // C++ Headers -- //--------------- #include <iostream> //------------------- // Initializations -- //------------------- //---------------- // Constructors -- //---------------- DTKeyedConfigDBInit::DTKeyedConfigDBInit(const edm::ParameterSet& ps) : container(ps.getParameter<std::string>("container")), iov(ps.getParameter<std::string>("iov")) {} //-------------- // Destructor -- //-------------- DTKeyedConfigDBInit::~DTKeyedConfigDBInit() {} //-------------- // Operations -- //-------------- void DTKeyedConfigDBInit::beginJob() { return; } void DTKeyedConfigDBInit::analyze(const edm::Event& e, const edm::EventSetup& c) { return; } void DTKeyedConfigDBInit::endJob() { edm::Service<cond::service::PoolDBOutputService> outdb; DTKeyedConfig bk; bk.setId(999999999); bk.add("dummy"); cond::KeyedElement k(&bk, 999999999); outdb->writeOneIOV(*(k.m_obj), k.m_key, container); std::vector<cond::Time_t> kl; kl.push_back(999999999); outdb->writeOneIOV(kl, 1, iov); return; } DEFINE_FWK_MODULE(DTKeyedConfigDBInit);
e99564699b16c2f8a1e657aae1da234defea5156
b7d366d78820cc9fae661d883d7be7bc83ce8ab1
/tests/socket_address_unittest.cpp
89e30d7502c58fa6ba7847e20c362593455dc5be
[ "MIT" ]
permissive
OrigamiKing/ezio
cb7ca87123cac7603c1609b2d2599831204c4ee3
f448d1d0d42ffb01ab94228e991d70a7230bfbb1
refs/heads/master
2020-06-12T00:47:31.825361
2019-05-04T09:41:24
2019-05-04T09:41:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,226
cpp
socket_address_unittest.cpp
/* @ 0xCCCCCCCC */ #include "catch2/catch.hpp" #include <cstring> #include "ezio/socket_address.h" namespace { bool operator==(const sockaddr_in& lhs, const sockaddr_in& rhs) { return lhs.sin_family == rhs.sin_family && lhs.sin_port == rhs.sin_port && lhs.sin_addr.s_addr == rhs.sin_addr.s_addr; } } // namespace namespace ezio { TEST_CASE("SocketAddress represents the abstraction of sockaddr_in", "[SocketAddress]") { SECTION("create from port only") { SocketAddress addr(1234); REQUIRE(1234 == addr.port()); REQUIRE("0.0.0.0:1234" == addr.ToHostPort()); } SECTION("create from ip address and port") { SocketAddress addr("127.0.0.1", 8888); REQUIRE(8888 == addr.port()); REQUIRE("127.0.0.1:8888" == addr.ToHostPort()); } SECTION("create from raw sockaddr") { sockaddr_in saddr; memset(&saddr, 0, sizeof(saddr)); saddr.sin_family = AF_INET; saddr.sin_port = HostToNetwork(static_cast<unsigned short>(9876)); saddr.sin_addr.s_addr = HostToNetwork(INADDR_LOOPBACK); SocketAddress addr(saddr); REQUIRE(9876 == addr.port()); REQUIRE("127.0.0.1:9876" == addr.ToHostPort()); } } TEST_CASE("Copy and move SocketAddress instances", "[SocketAddress]") { SECTION("Copy from a SocketAddress") { SocketAddress addr_x(1234); SocketAddress addr_y(addr_x); REQUIRE(addr_x.ToHostPort() == addr_y.ToHostPort()); REQUIRE((addr_x.raw() == addr_y.raw())); SocketAddress addr_z("127.0.0.1", 9876); REQUIRE_FALSE((addr_z.raw() == addr_x.raw())); addr_z = addr_y; REQUIRE(addr_z.ToHostPort() == addr_x.ToHostPort()); REQUIRE((addr_z.raw() == addr_x.raw())); } SECTION("Move from a SocketAddress") { SocketAddress addr_x(SocketAddress("127.0.0.1", 9876)); REQUIRE(addr_x.port() == 9876); REQUIRE(addr_x.ToHostPort() == "127.0.0.1:9876"); SocketAddress addr_y(1234); addr_y = std::move(addr_x); REQUIRE(addr_y.port() == 9876); REQUIRE(addr_y.ToHostPort() == "127.0.0.1:9876"); } } } // namespace ezio
c762755a7c6b80f28ac802b164432340bb10ec57
2f5ce9c25bec38659a81f9dd588b604bce974f2f
/glwidget.cpp
bd762ed7042542d8e85099982bb3d9e56d52e983
[]
no_license
caozhengquan/FaceReconstruction
e90a54fad0394948b99777c44f43bb74ec6ba86f
3dd849914add9cf3ac1247a79382dd6aee6b286a
refs/heads/master
2021-01-19T22:44:00.432034
2017-03-29T15:08:13
2017-03-29T15:08:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,793
cpp
glwidget.cpp
#include "glwidget.h" #include <QFileDialog> //#include <QImage> GLWidget::GLWidget(QWidget *parent): QOpenGLWidget(parent) { this->setMouseTracking(true); } void GLWidget::initializeGL() { initializeOpenGLFunctions(); glClearColor(0.9f,0.9f,1.0f,10.f); shader.compile("../Renderer/shader.vert","../Renderer/shader.frag"); light = QVector3D(0,0,1); connect(this,SIGNAL(frameSwapped()),this,SLOT(update())); printContext(); } void GLWidget::resizeGL(int w, int h) { //glViewport( 0, 0, w, h ); float aspect = w/(float)h; camera.setAspect(aspect); } void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderScene(); } void GLWidget::renderScene() { //drawLambert(); shader.program.bind(); shader.program.setUniformValue("projectionMatrix",camera.projection()); shader.program.setUniformValue("viewMatrix",camera.view()); shader.program.setUniformValue("lightDirection",light); shader.program.setUniformValue("disptex",m_drawTexture); shader.program.setUniformValue("disptexnorm",m_drawTextureLambert); shader.program.setUniformValue("dispnorm",m_drawNormals); shader.program.setUniformValue("dispalb",m_drawLambert); shader.program.setUniformValue("dispalbonly",m_drawColors); shader.program.setUniformValue("disperror",m_drawError); shader.program.setUniformValue("dispshadow",m_drawShadows); shader.program.setUniformValue("dispcust",m_drawCustom); glEnable(GL_DEPTH_TEST); //glDepthMask(true); //glDepthFunc(GL_LEQUAL); // glEnable(GL_CULL_FACE); //if(m_drawWireframe) // glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); //else // glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); QMap<QString,Mesh>::iterator it=meshes.begin(); while(it!=meshes.end()) { QMatrix4x4 modelViewMatrix = camera.view() * it.value().modelMatrix; QMatrix3x3 normalMatrix = modelViewMatrix.normalMatrix(); QMatrix4x4 MVP = camera.projection() * modelViewMatrix; shader.program.setUniformValue("N",normalMatrix); shader.program.setUniformValue("MVP",MVP); it.value().draw(shader); it++; } // Draw black outline if(m_drawWireframe) { glPolygonOffset(-1.0f, -1.0f); // Shift depth values glEnable(GL_POLYGON_OFFSET_LINE); // Draw lines antialiased glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Draw black wireframe version of geometry glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glLineWidth(12.5f); // draw wireframe on top of mesh //drawShadows(); shader.program.setUniformValue("disptex",false); shader.program.setUniformValue("disptexnorm",false); shader.program.setUniformValue("dispnorm",false); shader.program.setUniformValue("dispalb",false); shader.program.setUniformValue("dispalbonly",false); shader.program.setUniformValue("disperror",false); shader.program.setUniformValue("dispshadow",true); shader.program.setUniformValue("dispcust",false); //glEnable(GL_DEPTH_TEST); //glDepthMask(false); //glPolygonMode(GL_BACK,GL_LINE); //glLineWidth(5); //glEnable( GL_POLYGON_OFFSET_LINE ); //glPolygonOffset( -1, -1 ); QMap<QString,Mesh>::iterator it2=meshes.begin(); while(it2!=meshes.end()) { QMatrix4x4 modelViewMatrix = camera.view() * it2.value().modelMatrix; QMatrix3x3 normalMatrix = modelViewMatrix.normalMatrix(); QMatrix4x4 MVP = camera.projection() * modelViewMatrix; shader.program.setUniformValue("N",normalMatrix); shader.program.setUniformValue("MVP",MVP); it2.value().draw(shader); it2++; } //glDisable( GL_POLYGON_OFFSET_LINE ); //drawLambert(); //glDepthMask(true); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_POLYGON_OFFSET_LINE); glLineWidth(1.0f); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); } } void GLWidget::keyPressEvent(QKeyEvent *e) { if(e->key() == Qt::Key_L) m_controlLight = !m_controlLight; // rotation if(e->key() == Qt::Key_Right ) camera.view().rotate(5, QVector3D(0,1,0)); if(e->key() == Qt::Key_Left ) camera.view().rotate(-5, QVector3D(0,1,0)); if(e->key() == Qt::Key_Up ) camera.view().rotate(5, QVector3D(1,0,0)); if(e->key() == Qt::Key_Down ) camera.view().rotate(-5, QVector3D(1,0,0)); } void GLWidget::mouseMoveEvent(QMouseEvent *m) { float width = this->width(); float height = this->height(); if(m->buttons() && m_controlLight) { QPointF pos = QPointF( m->pos().x() /width*2 -1, 1- m->pos().y()/height*2 ); light = QVector3D (pos.x(),pos.y(),sqrt( qMax(1-pos.x()*pos.x()-pos.y()*pos.y(),0.0) ) ); } float dx = (m->x() )/width*2-1; float dy = 1-(m->y() )/height*2; if (m->buttons() & Qt::LeftButton && !m_controlLight) { camera = Camera(); camera.setZoom(lastFov); camera.view().translate(dx,dy,0); } else if (m->buttons() & Qt::RightButton && !m_controlLight) { if(!m_mouseLook) { lastPos = m->pos(); m_mouseLook = true; } dx = (m->x() -lastPos.x()); dy = (m->y() -lastPos.y()); camera.view().rotate(dx/10.0,QVector3D(0,1,0)); camera.view().rotate(dy/10.0,QVector3D(1,0,0)); //camera.setZoom(lastFov); lastPos = m->pos(); } else { m_mouseLook = false; } } void GLWidget::wheelEvent(QWheelEvent *w) { float step = 2; float fov; if(w->delta() < 0) fov = qMin( lastFov + step, (float)120.0); else fov = qMax( lastFov - step, (float)10.0); camera.setZoom(fov); lastFov = fov; } void GLWidget::addMesh(QString meshName, Mesh mesh) { makeCurrent(); //Mesh newMesh=mesh; QMap<QString,Mesh>::iterator it=meshes.begin(); while(it!=meshes.end()) { it.value().clean(); it++; } meshes.insert(meshName,mesh); meshes[meshName].setup(); } // Private void GLWidget::printContext() { QString glType; QString glVersion; QString glProfile; // Get Version Information glType = (context()->isOpenGLES()) ? "OpenGL ES" : "OpenGL"; glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION)); // Get Profile Information #define CASE(c) case QSurfaceFormat::c: glProfile = #c; break switch (format().profile()) { CASE(NoProfile); CASE(CoreProfile); CASE(CompatibilityProfile); } #undef CASE // qPrintable() will print our QString w/o quotes around it. qDebug() << glType +" "+ glVersion + "(" + glProfile + ")"; } void GLWidget::controlLight() { m_controlLight = !m_controlLight; } void GLWidget::drawTexture() { m_drawTexture = true; m_drawCustom = false; m_drawTextureLambert = false; m_drawNormals = false; m_drawColors = false; m_drawLambert = false; m_drawShadows = false; m_drawError = false; } void GLWidget::drawTextureLambert() { m_drawTextureLambert = true; m_drawCustom = false; m_drawTexture = false; m_drawNormals = false; m_drawColors = false; m_drawLambert = false; m_drawShadows = false; m_drawError = false; } void GLWidget::drawNormals() { m_drawNormals = true; m_drawCustom = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawColors = false; m_drawLambert = false; m_drawShadows = false; m_drawError = false; } void GLWidget::drawColors() { m_drawColors = true; m_drawCustom = false; m_drawNormals = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawLambert = false; m_drawShadows = false; m_drawError = false; } void GLWidget::drawLambert() { m_drawLambert = true; m_drawCustom = false; m_drawColors = false; m_drawNormals = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawShadows = false; m_drawError = false; } void GLWidget::drawShadows() { m_drawShadows = true; m_drawCustom = false; m_drawLambert = false; m_drawColors = false; m_drawNormals = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawError = false; } void GLWidget::drawError() { m_drawError = true; m_drawCustom = false; m_drawLambert = false; m_drawColors = false; m_drawNormals = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawShadows = false; } void GLWidget::drawWireframe() { m_drawWireframe = !m_drawWireframe; } void GLWidget::drawCustom() { m_drawError = false; m_drawCustom = true; m_drawLambert = false; m_drawColors = false; m_drawNormals = false; m_drawTexture = false; m_drawTextureLambert = false; m_drawShadows = false; } void GLWidget::savePic() { QString file = QFileDialog::getSaveFileName(this, "Save as...", "name", "PNG (*.png);; BMP (*.bmp);;TIFF (*.tiff *.tif);; JPEG (*.jpg *.jpeg)"); //this->grabFramebuffer().save(file); QImage img = this->grabFramebuffer(); qDebug() << "image grabbed! size "<<img.size(); bool success = img.save(file); if(success) qDebug() << "image saved!"; else qDebug() << "image NOT saved :("; //QPainter painter(&img); //this->render(&painter); //img.save("/home/mat/file.jpg"); } QGroupBox* GLWidget::displayMenu() { QGroupBox *m_menu = new QGroupBox("Display Options"); QPushButton *wireBtm = new QPushButton("wireframe"); connect(wireBtm,SIGNAL(pressed()),this,SLOT(drawWireframe())); QPushButton *texBtm = new QPushButton("texture"); connect(texBtm,SIGNAL(pressed()),this,SLOT(drawTexture())); QPushButton *texnBtm = new QPushButton("texture+normals"); connect(texnBtm,SIGNAL(pressed()),this,SLOT(drawTextureLambert())); QPushButton *colBtm = new QPushButton("albedo"); connect(colBtm,SIGNAL(pressed()),this,SLOT(drawColors())); QPushButton *colnBtm = new QPushButton("albedo+normals"); connect(colnBtm,SIGNAL(pressed()),this,SLOT(drawLambert())); QPushButton *normBtm = new QPushButton("normals"); connect(normBtm,SIGNAL(pressed()),this,SLOT(drawNormals())); QPushButton *shadowBtm = new QPushButton("shadows"); connect(shadowBtm,SIGNAL(pressed()),this,SLOT(drawShadows())); QPushButton *errorBtm = new QPushButton("p-errors"); connect(errorBtm,SIGNAL(pressed()),this,SLOT(drawError())); QPushButton *customBtm = new QPushButton("red"); connect(customBtm,SIGNAL(pressed()),this,SLOT(drawCustom())); QPushButton *lightBtm = new QPushButton("moveLight"); connect(lightBtm,SIGNAL(pressed()),this,SLOT(controlLight())); QPushButton *savePicBtm = new QPushButton("savePic"); connect(savePicBtm,SIGNAL(pressed()),this,SLOT(savePic())); QGridLayout *menuLayout = new QGridLayout; menuLayout->addWidget(wireBtm,0,0); menuLayout->addWidget(lightBtm,0,1); menuLayout->addWidget(texBtm,1,0); menuLayout->addWidget(texnBtm,1,1); menuLayout->addWidget(colBtm,2,0); menuLayout->addWidget(colnBtm,2,1); menuLayout->addWidget(normBtm,3,0); menuLayout->addWidget(shadowBtm,3,1); menuLayout->addWidget(errorBtm,4,0); menuLayout->addWidget(savePicBtm,4,1); menuLayout->addWidget(customBtm,5,0); m_menu->setLayout(menuLayout); m_menu->setSizePolicy(QSizePolicy( QSizePolicy::Fixed,QSizePolicy::Fixed)); return m_menu; }
c4645a9584419a5cb802db42ae67c7372e7c52a0
1b1cc0a0d1dba081ee3ed6c6dac774cc58b231bd
/main.cpp
9272d3795c0fed50536e53b57fb7d8a868b4c5d0
[]
no_license
DManchevv/KDA
b9beeed3f70a25da62c0ab5360919c473ec10484
59d8c3430e49aeb1ec3851df8678222af1def29b
refs/heads/master
2022-12-24T15:09:53.279835
2020-09-26T13:36:01
2020-09-26T13:36:01
192,762,041
0
0
null
null
null
null
UTF-8
C++
false
false
294
cpp
main.cpp
#include <iostream> #include <cstring> #include <map> #include <iomanip> #include <fstream> #include "State.h" #include "Automat.h" #include "Menu.h" #include <sstream> #include "AutomatContainer.h" int main() { Menu menu; menu.Introduction(); menu.StartMenu(); return 0; }
420eef3bc8a67f797e9a0834e729351b7c30c04b
7ca7a401c8d313f668b29d4bf9f711ccebc654b9
/include/openfv/optimization.h
6c22b52d73dacedff2624189ce20209c4a5564c9
[]
no_license
leahmendelson/openfv
84f678eb720da0cfc6290e5cf83fe719accd3752
96a42b50431772e3e585eb3185325ef69c441c00
refs/heads/master
2021-08-28T03:41:16.725631
2017-05-30T03:11:12
2017-05-30T03:11:12
73,751,035
2
1
null
2016-11-14T22:04:25
2016-11-14T22:04:24
null
UTF-8
C++
false
false
29,979
h
optimization.h
// 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 Flow Visualization Library // // Copyright 2013-2015 Abhishek Bajpayee // // This file is part of openFV. // // openFV is free software: you can redistribute it and/or modify it under the terms of the // GNU General Public License as published by the Free Software Foundation, either version // 3 of the License, or (at your option) any later version. // // openFV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // See the GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along with openFV. // If not, see http://www.gnu.org/licenses/. #ifndef OPTIMIZATION_H #define OPTIMIZATION_H #include "std_include.h" #include "tracking.h" using namespace cv; using namespace std; // CLASS AND STRUCT DEFINITIONS // Read a Bundle Adjustment dataset // Container class for a pinhole bundle adjustment dataset class baProblem { public: ~baProblem() { delete[] point_index_; delete[] camera_index_; delete[] plane_index_; delete[] observations_; delete[] parameters_; } baProblem() { point_index_ = NULL; camera_index_ = NULL; plane_index_ = NULL; observations_ = NULL; parameters_ = NULL; } int num_observations() const { return num_observations_; } const double* observations() const { return observations_; } double* mutable_cameras() { return parameters_; } double* mutable_points() { return parameters_ + 9 * num_cameras_; } double* mutable_planes() { return parameters_ + 9 * num_cameras_ + 3 * num_points_; } int num_cameras() { return num_cameras_; } int num_points() { return num_points_; } int num_planes() { return num_planes_; } int* camera_index() { return camera_index_; } int* point_index() { return point_index_; } double* mutable_camera_for_observation(int i) { return mutable_cameras() + camera_index_[i] * 9; } double* mutable_point_for_observation(int i) { return mutable_points() + point_index_[i] * 3; } double* mutable_plane_for_observation(int i) { return mutable_planes() + plane_index_[i] * 4; } bool LoadFile(const char* filename) { FILE* fptr = fopen(filename, "r"); if (fptr == NULL) { return false; }; FscanfOrDie(fptr, "%d", &num_cameras_); FscanfOrDie(fptr, "%d", &num_planes_); FscanfOrDie(fptr, "%d", &num_points_); FscanfOrDie(fptr, "%d", &num_observations_); point_index_ = new int[num_observations_]; camera_index_ = new int[num_observations_]; plane_index_ = new int[num_observations_]; observations_ = new double[2 * num_observations_]; num_parameters_ = (9 * num_cameras_) + (3 * num_points_) + (4 * num_planes_); parameters_ = new double[num_parameters_]; for (int i = 0; i < num_observations_; ++i) { FscanfOrDie(fptr, "%d", camera_index_ + i); FscanfOrDie(fptr, "%d", plane_index_ + i); FscanfOrDie(fptr, "%d", point_index_ + i); for (int j = 0; j < 2; ++j) { FscanfOrDie(fptr, "%lf", observations_ + 2*i + j); } } for (int i = 0; i < num_parameters_; ++i) { FscanfOrDie(fptr, "%lf", parameters_ + i); } return true; } double cx; double cy; double scale; private: template<typename T> void FscanfOrDie(FILE *fptr, const char *format, T *value) { int num_scanned = fscanf(fptr, format, value); if (num_scanned != 1) { LOG(FATAL) << "Invalid UW data file."; } } int num_cameras_; int num_planes_; int num_points_; int* point_index_; int* camera_index_; int* plane_index_; int num_observations_; int num_parameters_; double* observations_; double* parameters_; }; // Container class for a refractive bundle adjustment dataset class baProblem_ref { public: ~baProblem_ref() { delete[] point_index_; delete[] camera_index_; delete[] plane_index_; delete[] observations_; delete[] parameters_; } baProblem_ref() { point_index_ = NULL; camera_index_ = NULL; plane_index_ = NULL; observations_ = NULL; parameters_ = NULL; } int num_observations() const { return num_observations_; } const double* observations() const { return observations_; } double* mutable_cameras() { return parameters_; } double* mutable_points() { return parameters_ + 9 * num_cameras_; } double* mutable_planes() { return parameters_ + 9 * num_cameras_ + 3 * num_points_; } int num_cameras() { return num_cameras_; } int num_points() { return num_points_; } int num_planes() { return num_planes_; } int* camera_index() { return camera_index_; } int* point_index() { return point_index_; } double t() { return t_; } double n1() { return n1_; } double n2() { return n2_; } double n3() { return n3_; } double z0() { return z0_; } double* mutable_camera_for_observation(int i) { return mutable_cameras() + camera_index_[i] * 9; } double* mutable_point_for_observation(int i) { return mutable_points() + point_index_[i] * 3; } double* mutable_plane_for_observation(int i) { return mutable_planes() + plane_index_[i] * 4; } bool LoadFile(const char* filename) { FILE* fptr = fopen(filename, "r"); if (fptr == NULL) { return false; }; FscanfOrDie(fptr, "%d", &num_cameras_); FscanfOrDie(fptr, "%d", &num_planes_); FscanfOrDie(fptr, "%d", &num_points_); FscanfOrDie(fptr, "%d", &num_observations_); point_index_ = new int[num_observations_]; camera_index_ = new int[num_observations_]; plane_index_ = new int[num_observations_]; observations_ = new double[2 * num_observations_]; num_parameters_ = (9 * num_cameras_) + (3 * num_points_) + (4 * num_planes_); parameters_ = new double[num_parameters_]; for (int i = 0; i < num_observations_; ++i) { FscanfOrDie(fptr, "%d", camera_index_ + i); FscanfOrDie(fptr, "%d", plane_index_ + i); FscanfOrDie(fptr, "%d", point_index_ + i); for (int j = 0; j < 2; ++j) { FscanfOrDie(fptr, "%lf", observations_ + 2*i + j); } } for (int i = 0; i < num_parameters_; ++i) { FscanfOrDie(fptr, "%lf", parameters_ + i); } FscanfOrDie(fptr, "%lf", &t_); FscanfOrDie(fptr, "%lf", &n1_); FscanfOrDie(fptr, "%lf", &n2_); FscanfOrDie(fptr, "%lf", &n3_); FscanfOrDie(fptr, "%lf", &z0_); return true; } double cx; double cy; double scale; private: template<typename T> void FscanfOrDie(FILE *fptr, const char *format, T *value) { int num_scanned = fscanf(fptr, format, value); if (num_scanned != 1) { LOG(FATAL) << "Invalid UW data file."; } } int num_cameras_; int num_planes_; int num_points_; int* point_index_; int* camera_index_; int* plane_index_; int num_observations_; int num_parameters_; double* observations_; double* parameters_; double t_, n1_, n2_, n3_, z0_; }; class baProblem_plane { public: ~baProblem_plane() { delete[] point_index_; delete[] camera_index_; delete[] plane_index_; delete[] observations_; delete[] parameters_; } baProblem_plane() { point_index_ = NULL; camera_index_ = NULL; plane_index_ = NULL; observations_ = NULL; parameters_ = NULL; } int num_observations() const { return num_observations_; } const double* observations() const { return observations_; } double* mutable_cameras() { return parameters_; } double* mutable_planes() { return parameters_ + 9 * num_cameras_; } int num_cameras() { return num_cameras_; } int num_planes() { return num_planes_; } int num_points() { return num_points_; } int* camera_index() { return camera_index_; } int* point_index() { return point_index_; } int* plane_index() { return plane_index_; } double t() { return t_; } double n1() { return n1_; } double n2() { return n2_; } double n3() { return n3_; } double z0() { return z0_; } double* mutable_camera_for_observation(int i) { return mutable_cameras() + camera_index_[i] * 9; } double* mutable_plane_for_observation(int i) { return mutable_planes() + plane_index_[i] * 6; } bool LoadFile(const char* filename) { FILE* fptr = fopen(filename, "r"); if (fptr == NULL) { return false; }; FscanfOrDie(fptr, "%d", &num_cameras_); FscanfOrDie(fptr, "%d", &num_planes_); FscanfOrDie(fptr, "%d", &num_points_); FscanfOrDie(fptr, "%d", &num_observations_); camera_index_ = new int[num_observations_]; plane_index_ = new int[num_observations_]; point_index_ = new int[num_observations_]; observations_ = new double[2 * num_observations_]; num_parameters_ = (9 * num_cameras_) + (6 * num_planes_); parameters_ = new double[num_parameters_]; for (int i = 0; i < num_observations_; ++i) { FscanfOrDie(fptr, "%d", camera_index_ + i); FscanfOrDie(fptr, "%d", plane_index_ + i); FscanfOrDie(fptr, "%d", point_index_ + i); for (int j = 0; j < 2; ++j) { FscanfOrDie(fptr, "%lf", observations_ + 2*i + j); } } for (int i = 0; i < num_parameters_; ++i) { FscanfOrDie(fptr, "%lf", parameters_ + i); } FscanfOrDie(fptr, "%lf", &t_); FscanfOrDie(fptr, "%lf", &n1_); FscanfOrDie(fptr, "%lf", &n2_); FscanfOrDie(fptr, "%lf", &n3_); FscanfOrDie(fptr, "%lf", &z0_); return true; } double cx; double cy; double scale; private: template<typename T> void FscanfOrDie(FILE *fptr, const char *format, T *value) { int num_scanned = fscanf(fptr, format, value); if (num_scanned != 1) { LOG(FATAL) << "Invalid UW data file."; } } int num_cameras_; int num_planes_; int num_points_; int* point_index_; int* camera_index_; int* plane_index_; int num_observations_; int num_parameters_; double* observations_; double* parameters_; double t_, n1_, n2_, n3_, z0_; }; // Pinhole Reprojection Error function class pinholeReprojectionError { public: pinholeReprojectionError(double observed_x, double observed_y, double cx, double cy, int num_cams): observed_x(observed_x), observed_y(observed_y), cx(cx), cy(cy), num_cams(num_cams) {} template <typename T> bool operator()(const T* const camera, const T* const point, T* residuals) const { // camera[0,1,2] are the angle-axis rotation. T p[3]; ceres::AngleAxisRotatePoint(camera, point, p); // camera[3,4,5] are the translation. p[0] += camera[3]; p[1] += camera[4]; p[2] += camera[5]; // Compute the center of distortion. T xp = p[0] / p[2]; T yp = p[1] / p[2]; // Image principal points T px = T(cx); T py = T(cy); // Apply second and fourth order radial distortion. const T& l1 = camera[7]; const T& l2 = camera[8]; // T r2 = xp*xp + yp*yp; // T distortion = T(1.0) + r2 * (l1 + l2 * r2); // Compute final projected point position. const T& focal = camera[6]; //T predicted_x = (focal * distortion * xp) + px; //T predicted_y = (focal * distortion * yp) + py; T predicted_x = (focal * xp) + px; T predicted_y = (focal * yp) + py; // The error is the squared euclidian distance between the predicted and observed position. residuals[0] = predicted_x - T(observed_x); residuals[1] = predicted_y - T(observed_y); return true; } double observed_x; double observed_y; double cx; double cy; int num_cams; }; // Pinhole Reprojection Error function with radial distortion class pinholeReprojectionError_dist { public: pinholeReprojectionError_dist(double observed_x, double observed_y, double cx, double cy, int num_cams): observed_x(observed_x), observed_y(observed_y), cx(cx), cy(cy), num_cams(num_cams) {} template <typename T> bool operator()(const T* const camera, const T* const point, T* residuals) const { // camera[0,1,2] are the angle-axis rotation. T p[3]; ceres::AngleAxisRotatePoint(camera, point, p); // camera[3,4,5] are the translation. p[0] += camera[3]; p[1] += camera[4]; p[2] += camera[5]; // Compute the center of distortion. T xp = p[0] / p[2]; T yp = p[1] / p[2]; // Image principal points T px = T(cx); T py = T(cy); // Apply second and fourth order radial distortion. const T& l1 = camera[7]; const T& l2 = camera[8]; T r2 = xp*xp + yp*yp; T distortion = T(1.0) + r2 * (l1 + l2 * r2); // Compute final projected point position. const T& focal = camera[6]; //T predicted_x = (focal * distortion * xp) + px; //T predicted_y = (focal * distortion * yp) + py; T predicted_x = (focal * xp * distortion) + px; T predicted_y = (focal * yp * distortion) + py; // The error is the squared euclidian distance between the predicted and observed position. residuals[0] = predicted_x - T(observed_x); residuals[1] = predicted_y - T(observed_y); return true; } double observed_x; double observed_y; double cx; double cy; int num_cams; }; // Error of points from a plane in space class planeError { public: planeError(int num_cams): num_cams(num_cams) {} template <typename T> bool operator()(const T* const point, const T* const plane, T* residuals) const { residuals[0] = plane[0]*point[0] + plane[1]*point[1] + plane[2]*point[2] + plane[3]; residuals[0] /= sqrt( pow(plane[0],2) + pow(plane[1],2) + pow(plane[2],2) ); residuals[0] /= T(num_cams); return true; } private: int num_cams; }; // Grid physical size constraint class gridPhysSizeError { public: gridPhysSizeError(double grid_phys_size, int gridx, int gridy): grid_phys_size(grid_phys_size), gridx(gridx), gridy(gridy) {} template <typename T> bool operator()(const T* const p1, const T* const p2, const T* const p3, T* residuals) const { residuals[0] = sqrt(pow(p1[0]-p2[0],2) + pow(p1[1]-p2[1],2) + pow(p1[2]-p2[2],2)) - T((gridx-1)*grid_phys_size); residuals[0] += sqrt(pow(p1[0]-p3[0],2) + pow(p1[1]-p3[1],2) + pow(p1[2]-p3[2],2)) - T((gridy-1)*grid_phys_size); return true; } private: double grid_phys_size; int gridx; int gridy; }; class zError { public: zError() {} template <typename T> bool operator()(const T* const p1, const T* const p2, const T* const p3, const T* const p4, T* residuals) const { residuals[0] = pow(p1[2]-T(0),2)+pow(p2[2]-T(0),2)+pow(p3[2]-T(0),2)+pow(p4[2]-T(0),2); return true; } }; class zError2 { public: zError2() {} template <typename T> bool operator()(const T* const p, T* residuals) const { residuals[0] = pow(p[0]-T(0),2)+pow(p[1]-T(0),2)+pow(p[2]-T(1),2)+pow(p[4]-T(0),2); return true; } }; // xy plane constraint class xyPlaneError { public: xyPlaneError() {} template <typename T> bool operator()(const T* const plane, T* residuals) const { residuals[0] = pow(plane[0]-T(0),2)+pow(plane[1]-T(0),2)+pow(plane[2]-T(1),2)+pow(plane[3]-T(0),2); return true; } }; // Refractive Reprojection Error function class refractiveReprojectionError { public: refractiveReprojectionError(double observed_x, double observed_y, double cx, double cy, int num_cams, double t, double n1, double n2, double n3, double z0) : observed_x(observed_x), observed_y(observed_y), cx(cx), cy(cy), num_cams(num_cams), t_(t), n1_(n1), n2_(n2), n3_(n3), z0_(z0) { } template <typename T> bool operator()(const T* const camera, const T* const point, T* residuals) const { // Inital guess for points on glass T* R = new T[9]; ceres::AngleAxisToRotationMatrix(camera, R); T c[3]; for (int i=0; i<3; i++) { c[i] = T(0); for (int j=0; j<3; j++) { c[i] += -R[i*1 + j*3]*camera[j+3]; } } // All the refraction stuff T* a = new T[3]; T* b = new T[3]; a[0] = c[0] + (point[0]-c[0])*(T(-t_)+T(z0_)-c[2])/(point[2]-c[2]); a[1] = c[1] + (point[1]-c[1])*(T(-t_)+T(z0_)-c[2])/(point[2]-c[2]); a[2] = T(-t_)+T(z0_); b[0] = c[0] + (point[0]-c[0])*(T(z0_)-c[2])/(point[2]-c[2]); b[1] = c[1] + (point[1]-c[1])*(T(z0_)-c[2])/(point[2]-c[2]); b[2] = T(z0_); T rp = sqrt( pow(point[0]-c[0],2) + pow(point[1]-c[1],2) ); T dp = point[2]-b[2]; T phi = atan2(point[1]-c[1],point[0]-c[0]); T ra = sqrt( pow(a[0]-c[0],2) + pow(a[1]-c[1],2) ); T rb = sqrt( pow(b[0]-c[0],2) + pow(b[1]-c[1],2) ); T da = a[2]-c[2]; T db = b[2]-a[2]; T f, g, dfdra, dfdrb, dgdra, dgdrb; // Newton Raphson loop to solve for Snell's law for (int i=0; i<20; i++) { f = ( ra/sqrt(pow(ra,2)+pow(da,2)) ) - ( T(n2_/n1_)*(rb-ra)/sqrt(pow(rb-ra,2)+pow(db,2)) ); g = ( (rb-ra)/sqrt(pow(rb-ra,2)+pow(db,2)) ) - ( T(n3_/n2_)*(rp-rb)/sqrt(pow(rp-rb,2)+pow(dp,2)) ); dfdra = ( T(1.0)/sqrt(pow(ra,2)+pow(da,2)) ) - ( pow(ra,2)/pow(pow(ra,2)+pow(da,2),1.5) ) + ( T(n2_/n1_)/sqrt(pow(ra-rb,2)+pow(db,2)) ) - ( T(n2_/n1_)*(ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ); dfdrb = ( T(n2_/n1_)*(ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(n2_/n1_)/sqrt(pow(ra-rb,2)+pow(db,2)) ); dgdra = ( (ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(1.0)/sqrt(pow(ra-rb,2)+pow(db,2)) ); dgdrb = ( T(1.0)/sqrt(pow(ra-rb,2)+pow(db,2)) ) + ( T(n3_/n2_)/sqrt(pow(rb-rp,2)+pow(dp,2)) ) - ( (ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(n3_/n2_)*(rb-rp)*(T(2)*rb-T(2)*rp)/(T(2)*pow(pow(rb-rp,2)+pow(dp,2),1.5)) ); ra = ra - ( (f*dgdrb - g*dfdrb)/(dfdra*dgdrb - dfdrb*dgdra) ); rb = rb - ( (g*dfdra - f*dgdra)/(dfdra*dgdrb - dfdrb*dgdra) ); } a[0] = ra*cos(phi) + c[0]; a[1] = ra*sin(phi) + c[1]; // Continuing projecting point a to camera T p[3]; ceres::AngleAxisRotatePoint(camera, a, p); // camera[3,4,5] are the translation. p[0] += camera[3]; p[1] += camera[4]; p[2] += camera[5]; // Compute the center of distortion. T xp = p[0] / p[2]; T yp = p[1] / p[2]; // Image principal points T px = T(cx); T py = T(cy); // Apply second and fourth order radial distortion. const T& l1 = camera[7]; const T& l2 = camera[8]; T r2 = xp*xp + yp*yp; T distortion = T(1.0) + r2 * (l1 + l2 * r2); // Compute final projected point position. const T& focal = camera[6]; //T predicted_x = (focal * distortion * xp) + px; //T predicted_y = (focal * distortion * yp) + py; T predicted_x = (focal * xp) + px; T predicted_y = (focal * yp) + py; // The error is the squared euclidian distance between the predicted and observed position. residuals[0] = predicted_x - T(observed_x); residuals[1] = predicted_y - T(observed_y); return true; } double observed_x, observed_y, cx, cy, t_, n1_, n2_, n3_, z0_; int num_cams; }; // Refractive Reprojection Error function for planes class refractiveReprojError { public: refractiveReprojError(double observed_x, double observed_y, double cx, double cy, int num_cams, double t, double n1, double n2, double n3, double z0, int gridx, int gridy, double grid_phys, int index, int plane_id) : observed_x(observed_x), observed_y(observed_y), cx(cx), cy(cy), num_cams(num_cams), t_(t), n1_(n1), n2_(n2), n3_(n3), z0_(z0), gridx_(gridx), gridy_(gridy), grid_phys_(grid_phys), index_(index), plane_id_(plane_id) { } template <typename T> bool operator()(const T* const camera, const T* const plane, T* residuals) const { // Inital guess for points on glass T* R = new T[9]; ceres::AngleAxisToRotationMatrix(camera, R); T c[3]; for (int i=0; i<3; i++) { c[i] = T(0); for (int j=0; j<3; j++) { c[i] += -R[i*1 + j*3]*camera[j+3]; } } // Generate point on grid int number = index_ - plane_id_*(gridx_*gridy_); int j = floor(number/gridx_); int i = number - j*gridx_; T* grid_point = new T[3]; grid_point[0] = T(i*grid_phys_); grid_point[1] = T(j*grid_phys_); grid_point[2] = T(0); // Move point to be on given grid plane T point[3]; ceres::AngleAxisRotatePoint(plane, grid_point, point); point[0] += plane[3]; point[1] += plane[4]; point[2] += plane[5]; // Solve for refraction to reproject point into camera T* a = new T[3]; T* b = new T[3]; a[0] = c[0] + (point[0]-c[0])*(T(-t_)+T(z0_)-c[2])/(point[2]-c[2]); a[1] = c[1] + (point[1]-c[1])*(T(-t_)+T(z0_)-c[2])/(point[2]-c[2]); a[2] = T(-t_)+T(z0_); b[0] = c[0] + (point[0]-c[0])*(T(z0_)-c[2])/(point[2]-c[2]); b[1] = c[1] + (point[1]-c[1])*(T(z0_)-c[2])/(point[2]-c[2]); b[2] = T(z0_); T rp = sqrt( pow(point[0]-c[0],2) + pow(point[1]-c[1],2) ); T dp = point[2]-b[2]; T phi = atan2(point[1]-c[1],point[0]-c[0]); T ra = sqrt( pow(a[0]-c[0],2) + pow(a[1]-c[1],2) ); T rb = sqrt( pow(b[0]-c[0],2) + pow(b[1]-c[1],2) ); T da = a[2]-c[2]; T db = b[2]-a[2]; T f, g, dfdra, dfdrb, dgdra, dgdrb; // Newton Raphson loop to solve for Snell's law for (int iter=0; iter<20; iter++) { f = ( ra/sqrt(pow(ra,2)+pow(da,2)) ) - ( T(n2_/n1_)*(rb-ra)/sqrt(pow(rb-ra,2)+pow(db,2)) ); g = ( (rb-ra)/sqrt(pow(rb-ra,2)+pow(db,2)) ) - ( T(n3_/n2_)*(rp-rb)/sqrt(pow(rp-rb,2)+pow(dp,2)) ); dfdra = ( T(1.0)/sqrt(pow(ra,2)+pow(da,2)) ) - ( pow(ra,2)/pow(pow(ra,2)+pow(da,2),1.5) ) + ( T(n2_/n1_)/sqrt(pow(ra-rb,2)+pow(db,2)) ) - ( T(n2_/n1_)*(ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ); dfdrb = ( T(n2_/n1_)*(ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(n2_/n1_)/sqrt(pow(ra-rb,2)+pow(db,2)) ); dgdra = ( (ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(1.0)/sqrt(pow(ra-rb,2)+pow(db,2)) ); dgdrb = ( T(1.0)/sqrt(pow(ra-rb,2)+pow(db,2)) ) + ( T(n3_/n2_)/sqrt(pow(rb-rp,2)+pow(dp,2)) ) - ( (ra-rb)*(T(2)*ra-T(2)*rb)/(T(2)*pow(pow(ra-rb,2)+pow(db,2),1.5)) ) - ( T(n3_/n2_)*(rb-rp)*(T(2)*rb-T(2)*rp)/(T(2)*pow(pow(rb-rp,2)+pow(dp,2),1.5)) ); ra = ra - ( (f*dgdrb - g*dfdrb)/(dfdra*dgdrb - dfdrb*dgdra) ); rb = rb - ( (g*dfdra - f*dgdra)/(dfdra*dgdrb - dfdrb*dgdra) ); } a[0] = ra*cos(phi) + c[0]; a[1] = ra*sin(phi) + c[1]; // Continuing projecting point a to camera T p[3]; ceres::AngleAxisRotatePoint(camera, a, p); // camera[3,4,5] are the translation. p[0] += camera[3]; p[1] += camera[4]; p[2] += camera[5]; // Compute the center of distortion. T xp = p[0] / p[2]; T yp = p[1] / p[2]; // Image principal points T px = T(cx); T py = T(cy); // Apply second and fourth order radial distortion. const T& l1 = camera[7]; const T& l2 = camera[8]; T r2 = xp*xp + yp*yp; //T distortion = T(1.0) + r2 * (l1 + l2 * r2); // Compute final projected point position. const T& focal = camera[6]; T predicted_x = (focal * xp) + px; T predicted_y = (focal * yp) + py; // The error is the squared euclidian distance between the predicted and observed position. residuals[0] = predicted_x - T(observed_x); residuals[1] = predicted_y - T(observed_y); return true; } double observed_x, observed_y, cx, cy, t_, n1_, n2_, n3_, z0_, grid_phys_; int num_cams, gridx_, gridy_, index_, plane_id_; }; // Poly2 Fit Error function class poly2FitError { public: poly2FitError(double xin, double yin): x(xin), y(yin) {} template <typename T> bool operator()(const T* const params, T* residuals) const { residuals[0] = y - T(params[0]*x*x + params[1]*x + params[2]); return true; } double x; double y; }; // Gaussian Fit Error function class gaussFitError { public: gaussFitError(double xin, double yin): x(xin), y(yin) {} template <typename T> bool operator()(const T* const params, T* residuals) const { residuals[0] = y - T(params[0]*exp(-pow(((x-params[1])/params[2]),2))); return true; } double x; double y; }; // Relaxation Tracking Error function // class rlxTrackingError { // public: // rlxTrackingError(string path): // path_(path) {} // template <typename T> // bool operator()(const T* const params, // T* residuals) const { // pTracking track(path_, params[0], params[1]); // track.set_vars(double(params[0]), // double(params[1]), // double(params[2]), // double(params[3])); // track.track_frames(15, 16); // residuals[0] = T(1.0) - T(track.sim_performance()); // return true; // } // string path_; // }; // FUNCTION DEFINITIONS //double BA_pinhole(baProblem &ba_problem, string ba_file, Size img_size, vector<int> const_points); //double BA_refractive(baProblem_ref &ba_problem, string ba_file, Size img_size, vector<int> const_points); #endif
2d007dbf132e592955d6c083af4719ec4d53b060
0f4680f1b035096230b70a85f5000c9c54ef2ba2
/GfxFramework/src/Graffics/DirectXContext/d3d_SwapChain.h
4e62f943aad8adc4503c5fd3f6165f97153b0bd2
[ "MIT" ]
permissive
Ohjurot/DirectX-12-Sandbox
9347deefd3ddbd605aa5452b9295904deb48aa5a
99f9b033ae00907144b5cf8efb1c3ae46a22dc7a
refs/heads/master
2023-02-21T14:25:45.482943
2021-01-27T17:20:46
2021-01-27T17:20:46
279,083,537
1
0
null
null
null
null
UTF-8
C++
false
false
862
h
d3d_SwapChain.h
#pragma once #include <Windows.h> #include <d3d12.h> #include <dxgi.h> #include <cassert> #include <Graffics/gfxCommon.h> #include <Graffics/DirectXContext/d3d_Device.h> namespace D3D { class SwapChain { public: // Construct / Destrucy SwapChain(UINT width, UINT height, HWND windowHandle); ~SwapChain(); // Init and shutdown HRESULT Init(D3D::Device* ptrD3DDevice); VOID Shutdown(); // Function VOID beginFrame(D3D::Device* ptrD3DDevice, FLOAT clearColor[4]); VOID endFrame(D3D::Device* ptrD3DDevice); HRESULT present(); private: UINT m_uiWidth, m_uiHeight; HWND m_targetWindowHandle; IDXGIFactory* m_TptrFactory = NULL; IDXGISwapChain* m_ptrSwapChain = NULL; ID3D12DescriptorHeap* m_ptrRtvDescHeap = NULL; ID3D12Resource* m_ptrsBackBuffers[2] = {NULL, NULL}; UINT m_uiBackBufferIndex = 0; }; }
58f63026d1534c7dace6c6e43d806ac972bae14f
38715d20f133315f0a9e3b81c54bfa10ab2b088f
/algorithms/erosion/openmp/algorithm_erosion_openmp.h
6364beb3e1d11f3b8edb21a225197422a60d5139
[]
no_license
prutskov/PIP
20bffb0c5fccdf3632f509e189df42393a2d211f
eb54a9ff7951f77a90011c681312957c7633e820
refs/heads/master
2022-04-24T20:36:44.555161
2020-04-28T18:41:10
2020-04-28T18:41:10
237,084,779
0
0
null
null
null
null
UTF-8
C++
false
false
427
h
algorithm_erosion_openmp.h
#pragma once #include "../../algorithm.h" #include "../parameter_erosion.h" #include <vector> namespace algorithms { namespace erosion { namespace openmp { class Algorithm : public algorithms::Algorithm { protected: virtual void computeImpl() override; void pixelCompute(int x, int y, const Frame& frame, Frame& result, MorphType morphType, int rowsSE, int colsSE, int indexRes); }; } } }
d08b1a63221799f1b2892e665a2b8dfc275ef653
59ed206b49e454d980cb0b483b515ee7119a6237
/source/test_black_line/test_black_line.cpp
a7c9845c9724e5c68e3d628a398822bf0b39b696
[]
no_license
Ryosuke1221/Opencv_Apps
7de5c91c425ead7bb43457909ce37dca0b832d27
d35e1f7d9568c1fc9e867d801e51da6c864a6f85
refs/heads/master
2021-01-02T10:48:15.326207
2020-11-22T09:36:45
2020-11-22T09:36:45
239,586,206
0
0
null
null
null
null
UTF-8
C++
false
false
3,255
cpp
test_black_line.cpp
// Standard includes #include<stdio.h> #include<math.h> #include<string> #include<vector> #include<iostream> #include<fstream> //OpenCV include #include<opencv2/opencv.hpp> #include"TimeString.h" int main() { int width_line = 3; CTimeString time_; vector<string> filenames_; string dir_ = "../../data/test_black_line"; CTimeString::getFileNames_extension(dir_, filenames_, ".png"); { //.jpg vector<string> filenames_jpg; CTimeString::getFileNames_extension(dir_, filenames_jpg, ".jpg"); for (int i = 0; i < filenames_jpg.size(); i++) filenames_.push_back(filenames_jpg[i]); } if(filenames_.size() == 0) { cout << "ERROR: no file found" << endl; return 0; } cout << endl; //cv::Mat image_test = cv::imread(dir_ + "/" + filenames_[0]); { //cv::Mat *p_image_raw; cv::Mat image_raw; //Sleep(0.5 * 1000); cout << "Start!!" << endl; for (int i = 0; i < filenames_.size(); i++) { //int rows_size = image_test.rows; //int cols_size = image_test.cols; //p_image_raw = new cv::Mat(rows_size, cols_size, CV_8UC3, cvScalar(0, 0, 0)); //*p_image_raw = cv::imread(dir_ + "/" + filenames_[i]); cv::Mat image_raw = cv::imread(dir_ + "/" + filenames_[i]); int rows_size = image_raw.rows; int cols_size = image_raw.cols; //up for (int rows_ = 0; rows_ < 3; rows_++) { //cv::Vec3b *src_raw = p_image_raw->ptr<cv::Vec3b>(rows_); cv::Vec3b *src_raw = image_raw.ptr<cv::Vec3b>(rows_); for (int cols_ = 0; cols_ < cols_size; cols_++) { src_raw[cols_][0] = 0; src_raw[cols_][1] = 0; src_raw[cols_][2] = 0; } } //down for (int rows_ = rows_size - 3; rows_ < rows_size; rows_++) { //cv::Vec3b *src_raw = p_image_raw->ptr<cv::Vec3b>(rows_); cv::Vec3b *src_raw = image_raw.ptr<cv::Vec3b>(rows_); for (int cols_ = 0; cols_ < cols_size; cols_++) { src_raw[cols_][0] = 0; src_raw[cols_][1] = 0; src_raw[cols_][2] = 0; } } //left for (int rows_ = 3; rows_ < rows_size - 3; rows_++) { //cv::Vec3b *src_raw = p_image_raw->ptr<cv::Vec3b>(rows_); cv::Vec3b *src_raw = image_raw.ptr<cv::Vec3b>(rows_); for (int cols_ = 0; cols_ < 3; cols_++) { src_raw[cols_][0] = 0; src_raw[cols_][1] = 0; src_raw[cols_][2] = 0; } } //right for (int rows_ = 3; rows_ < rows_size - 3; rows_++) { //cv::Vec3b *src_raw = p_image_raw->ptr<cv::Vec3b>(rows_); cv::Vec3b *src_raw = image_raw.ptr<cv::Vec3b>(rows_); for (int cols_ = 0; cols_ < cols_size; cols_++) for (int cols_ = cols_size - 3; cols_ < cols_size; cols_++) { src_raw[cols_][0] = 0; src_raw[cols_][1] = 0; src_raw[cols_][2] = 0; } } //save image //https://www.sejuku.net/blog/58892 string filename_new = filenames_[i].substr(0, filenames_[i].size() - 4) + "_line" + filenames_[i].substr(filenames_[i].size() - 4, 4); //cv::imwrite(dir_ + "/line/" + filename_new, *p_image_raw); cv::imwrite(dir_ + "/line/" + filename_new, image_raw); cout << "saved:" << filename_new << endl; } //delete p_image_raw; } return 0; }
de90ae3b0a3b1118954842c62db309a6778a50fe
04c4cc99ddcbc20679715351a0ecbcc7207f183c
/Unit 22/PlayCards/PlayCards/rank.cpp
d639b6cf9de29325e80a858177e803ddfa285cb7
[]
no_license
henrymound/CPlusPlus
95b9e35f434e328d4a14f609e1c1a43819f06db3
4fa093308c9f2d4746a921855c7c85cc39ad3e05
refs/heads/master
2021-05-29T05:57:39.063086
2015-05-30T21:07:17
2015-05-30T21:07:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
222
cpp
rank.cpp
#include "rank.h" using namespace std; const int NUMBER_OF_RANKS = 13; const string RANK_NAMES[] = { "Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
bd7f80fbb6162e9204c8e8d9ba00996a28f10e7e
67fd88914a5aaf8daf6c620bc9182d4490ff5ff1
/Source/MBLab_fBlah_study/fBlahBlueprintFunctionLibrary.cpp
76ee565e4ce941d8c6ab4f0bf6e1f6f3bf0e752e
[ "CC-BY-4.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
TritonSailor/UE4MBLabCharacterStudy
6f966aca464fc8e6da0b8ca8001204e6acbf3d97
4e0dd75f603f1897fe674b06def4ba7f57115355
refs/heads/master
2020-05-01T04:31:18.646813
2019-03-15T19:47:37
2019-03-15T19:47:37
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
4,415
cpp
fBlahBlueprintFunctionLibrary.cpp
// © Ajit D'Monte 2019 #include "fBlahBlueprintFunctionLibrary.h" #include "Runtime/Engine/Classes/Engine/SkeletalMesh.h" #include "Runtime/Engine/Classes/Animation/SkeletalMeshActor.h" #include "Runtime/Engine/Classes/Components/SkeletalMeshComponent.h" TArray<FString> UfBlahBlueprintFunctionLibrary::GetCharacterMorphs(USkeletalMeshComponent* mesh) { TArray<FString> outputArray; USkeletalMesh * skelMesh = mesh->SkeletalMesh; TMap<FName, int32> myMap = skelMesh->MorphTargetIndexMap; for (TPair<FName, int32> Entry : myMap) { outputArray.Add(Entry.Key.ToString()); } return outputArray; } void UfBlahBlueprintFunctionLibrary::SetCharacterMorphTarget(USkeletalMeshComponent* SkeletalMeshComponent, FName TargetName, float Weight) { if (SkeletalMeshComponent != nullptr) { TMap <FName, float> MorphTargetCurves; MorphTargetCurves.Add(TargetName, Weight); USkeletalMesh *InSkeletalMesh = SkeletalMeshComponent->SkeletalMesh; SkeletalMeshComponent->MorphTargetWeights.SetNumZeroed(InSkeletalMesh->MorphTargets.Num()); if (FMath::Abs(Weight) > SMALL_NUMBER) { int32 MorphId = INDEX_NONE; UMorphTarget* Target = InSkeletalMesh ? InSkeletalMesh->FindMorphTargetAndIndex(TargetName, MorphId) : nullptr; if (Target != nullptr) { int32 MorphIndex = INDEX_NONE; for (int32 i = 0; i < SkeletalMeshComponent->ActiveMorphTargets.Num(); i++) { if (SkeletalMeshComponent->ActiveMorphTargets[i].MorphTarget == Target) { MorphIndex = i; } } if (MorphIndex == INDEX_NONE) { SkeletalMeshComponent->ActiveMorphTargets.Add(FActiveMorphTarget(Target, MorphId)); SkeletalMeshComponent->MorphTargetWeights[MorphId] = Weight; } else { check(MorphId == SkeletalMeshComponent->ActiveMorphTargets[MorphIndex].WeightIndex); float& CurrentWeight = SkeletalMeshComponent->MorphTargetWeights[MorphId]; CurrentWeight = FMath::Max<float>(CurrentWeight, Weight); } } } } } void UfBlahBlueprintFunctionLibrary::UpdateMorphTarget(USkeletalMeshComponent* SkeletalMeshComponent) { if (SkeletalMeshComponent != nullptr && !SkeletalMeshComponent->GetWorld()->IsGameWorld()) { SkeletalMeshComponent->TickAnimation(0.f, false); SkeletalMeshComponent->RefreshBoneTransforms(); SkeletalMeshComponent->RefreshSlaveComponents(); SkeletalMeshComponent->UpdateComponentToWorld(); SkeletalMeshComponent->FinalizeBoneTransform(); SkeletalMeshComponent->MarkRenderTransformDirty(); SkeletalMeshComponent->MarkRenderDynamicDataDirty(); } } void UfBlahBlueprintFunctionLibrary::String__ExplodeString(TArray<FString>& OutputStrings, FString InputString, FString Separator, int32 limit, bool bTrimElements) { OutputStrings.Empty(); //~~~~~~~~~~~ if (InputString.Len() > 0 && Separator.Len() > 0) { int32 StringIndex = 0; int32 SeparatorIndex = 0; FString Section = ""; FString Extra = ""; int32 PartialMatchStart = -1; while (StringIndex < InputString.Len()) { if (InputString[StringIndex] == Separator[SeparatorIndex]) { if (SeparatorIndex == 0) { //A new partial match has started. PartialMatchStart = StringIndex; } Extra.AppendChar(InputString[StringIndex]); if (SeparatorIndex == (Separator.Len() - 1)) { //We have matched the entire separator. SeparatorIndex = 0; PartialMatchStart = -1; if (bTrimElements == true) { OutputStrings.Add(FString(Section).TrimStart().TrimEnd()); } else { OutputStrings.Add(FString(Section)); } //if we have reached the limit, stop. if (limit > 0 && OutputStrings.Num() >= limit) { return; //~~~~ } Extra.Empty(); Section.Empty(); } else { ++SeparatorIndex; } } else { //Not matched. //We should revert back to PartialMatchStart+1 (if there was a partial match) and clear away extra. if (PartialMatchStart >= 0) { StringIndex = PartialMatchStart; PartialMatchStart = -1; Extra.Empty(); SeparatorIndex = 0; } Section.AppendChar(InputString[StringIndex]); } ++StringIndex; } //If there is anything left in Section or Extra. They should be added as a new entry. if (bTrimElements == true) { OutputStrings.Add(FString(Section + Extra).TrimStart().TrimEnd()); } else { OutputStrings.Add(FString(Section + Extra)); } Section.Empty(); Extra.Empty(); } }
0519b73aee5fe394beb996224cf481f483b9526d
09c5c4baed3d26701e866be100e4e52d9a34b856
/StudyAlone/StudyAlone/BOJ1002.h
68eb2eb4acf8e55dcf008c568e22f737dce3c38a
[]
no_license
sangdo913/Algorithms
556ac5fc789e35df2f65601e4439caca967edd7b
ee11265895d8ce3314f009df38166defc4b946c7
refs/heads/master
2022-09-11T12:00:58.615980
2022-07-31T11:11:04
2022-07-31T11:11:04
116,484,870
3
0
null
null
null
null
UTF-8
C++
false
false
1,095
h
BOJ1002.h
#include<iostream> #include<cmath> using namespace std; #define DIST(x,y) (((x)-(y))*((x)-(y))) int Do(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); int tc; cin >> tc; while(tc--){ int x1, y1, r1, x2, y2, r2; cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2; if(x1 == x2 && y1 == y2){ if(r1 == r2) cout << -1 << '\n'; else cout << 0 << '\n'; } else{ int d = DIST(x1,x2) + DIST(y1, y2); int d2 = (r1+r2)*(r1+r2); if(d == d2){ cout << 1 << '\n'; } else if(d > d2){ cout << 0 << '\n'; } else{ double dd1 = sqrt((double)d) + (double)r1; double dd2 = sqrt((double)d) + (double)r2; if(dd1 < (double)r2 || dd2 < double(r1)){ cout << 0 << '\n'; } else if(dd1 == (double)r2 || dd2 == (double)r1) cout << 1 << '\n'; else cout << 2 << '\n'; } } } return 0; }
b108fc13619bd253569baa44a235275b3ff63e44
947f7337f02133ff894005fa2d1d667a79040b0f
/C++/Complete-Modern-C++/Section04-Classes-and-Objects/src/car.cpp
88162e0d21883ef62350df2b52b4dd0bc4281c24
[]
no_license
qelias/Udemy
34464626f1bcce560f6274188cb479bf090db5dc
2ddbcd001b371262c6b234e772856bbd1208d7df
refs/heads/main
2023-03-25T01:42:11.970181
2021-03-23T12:15:16
2021-03-23T12:15:16
318,497,631
0
0
null
2021-03-20T15:36:45
2020-12-04T11:36:33
Jupyter Notebook
UTF-8
C++
false
false
1,123
cpp
car.cpp
#include "car.h" #include <iostream> int Car::totalCount = 0; Car::Car(){ totalCount++; fuel = 0; speed = 0; passengers =0; std::cout<<"default constructor"<<std::endl; } Car::Car(float amount, float initial_speed, int initial_passengers){ totalCount++; fuel = amount; speed = initial_speed; passengers =initial_passengers; std::cout<<"full car construcor"<<std::endl; } Car::Car(float amount){ totalCount++; fuel = amount; std::cout<<"initial fuel constructor"<<std::endl; } Car::~Car(){ totalCount--; std::cout <<"Car() object destroyed"<<std::endl; } void Car::FillFuel(float amount){ fuel = amount; } void Car::Accelerate(){ speed++; fuel -= 0.5f; } void Car::Brake(){ speed=0; } void Car::AddPassengers(int count){ passengers=count; } void Car::Dashboard(){ std::cout<<"Total cars:"<<totalCount<<std::endl; std::cout<<"Fuel "<<fuel<<std::endl; std::cout<<"Passengers "<<passengers<<std::endl; std::cout<<"Speed "<<speed<<std::endl; } void Car::ShowCount(){ std::cout<<"Total cars:"<<totalCount<<std::endl; }
6488b3907abb92261574aa085f7a64f7d4877ac6
d884ddefa3fa70bb6a58b7d12f681bcda28c2ea4
/roar/render/roRenderDriver.dx11.windows.cpp
51708120274f46d039df54d65ccf81b950222ca3
[]
no_license
mtlung/rhinoca
442e47b552b27088d0ca29b259a4a0ddacd5e8c8
bc1dfd740c616b548c457dc747733c92240d2b60
refs/heads/master
2020-08-21T17:41:46.075103
2020-03-14T03:45:59
2020-03-14T03:45:59
216,207,638
0
0
null
null
null
null
UTF-8
C++
false
false
12,582
cpp
roRenderDriver.dx11.windows.cpp
#include "pch.h" #include "roRenderDriver.h" #include "../base/roArray.h" #include "../base/roCpuProfiler.h" #include "../base/roLog.h" #include "../base/roMemory.h" #include "../base/roStopWatch.h" #include "../base/roStringHash.h" #include <dxgi.h> #include <d3d11.h> #pragma comment(lib, "d3d11.lib") #pragma comment(lib, "d3dcompiler.lib") #pragma comment(lib, "dxgi.lib") #pragma comment(lib, "dxguid.lib" ) using namespace ro; static DefaultAllocator _allocator; //namespace { #include "roRenderDriver.dx11.inl" struct ContextImpl : public roRDriverContextImpl { HWND hWnd; StopWatch stopWatch; }; //} // namespace roRDriverContext* _newDriverContext_DX11(roRDriver* driver) { ContextImpl* ret = _allocator.newObj<ContextImpl>().unref(); if(!ret) return NULL; ret->driver = driver; ret->width = ret->height = 0; ret->majorVersion = 0; ret->minorVersion = 0; ret->frameCount = 0; ret->lastFrameDuration = 0; ret->lastSwapTime = 0; ret->currentBlendStateHash = 0; ret->currentRasterizerStateHash = 0; ret->currentDepthStencilStateHash = 0; ret->currentShaders.assign(NULL); ret->currentRenderTargetViewHash = 0; SamplerState texState = { 0, ComPtr<ID3D11SamplerState>(NULL) }; ret->samplerStateCache.assign(texState); ret->hWnd = NULL; ret->triangleFanIndexBufferSize = 0; ret->triangleFanIndexBuffer = driver->newBuffer(); ret->constBufferInUse.assign(NULL); return ret; } static ContextImpl* _currentContext = NULL; void _deleteDriverContext_DX11(roRDriverContext* self) { ContextImpl* impl = static_cast<ContextImpl*>(self); if(!impl) return; for(roSize i=0; i<impl->currentShaders.size(); ++i) roAssert(!impl->currentShaders[i] && "Please destroy all shaders before detroy the context"); impl->driver->deleteBuffer(impl->triangleFanIndexBuffer); for(roRDriverBufferImpl*& i : impl->constBufferInUse) { // The same buffer may be used in multiple shader, only do the deletion for the last one if(roOccurrence(impl->constBufferInUse.begin(), impl->constBufferInUse.end(), i) == 1) impl->driver->deleteBuffer(i); i = NULL; } for(roSize i=0; i<impl->stagingBufferCache.size(); ++i) { roAssert(!impl->stagingBufferCache[i].mapped); } for(roSize i=0; i<impl->stagingTextureCache.size(); ++i) { roAssert(!impl->stagingTextureCache[i].mapped); } if(impl == _currentContext) { _currentContext = NULL; roRDriverCurrentContext = NULL; } // Change back to windowed mode before releasing swap chain if(impl->dxSwapChain) impl->dxSwapChain->SetFullscreenState(false, NULL); _allocator.deleteObj(impl); } void _useDriverContext_DX11(roRDriverContext* self) { ContextImpl* impl = static_cast<ContextImpl*>(self); _currentContext = impl; roRDriverCurrentContext = impl; } roRDriverContext* _getCurrentContext_DX11() { return _currentContext; } static bool _initRenderTarget(ContextImpl* impl, const DXGI_SWAP_CHAIN_DESC& swapChainDesc) { ID3D11Device* device = impl->dxDevice; ID3D11DeviceContext* immediateContext = impl->dxDeviceContext; IDXGISwapChain* swapChain = impl->dxSwapChain; // Create render target ComPtr<ID3D11Resource> backBuffer; swapChain->GetBuffer(0, __uuidof(backBuffer), reinterpret_cast<void**>(&backBuffer.ptr)); ID3D11RenderTargetView* renderTargetView = NULL; HRESULT hr = device->CreateRenderTargetView(backBuffer, NULL, &renderTargetView); if(FAILED(hr)) { roLog("error", "CreateRenderTargetView failed\n"); return false; } // Create depth - stencil buffer // reference: http://www.dx11.org.uk/3dcube.htm D3D11_TEXTURE2D_DESC depthDesc; roMemZeroStruct(depthDesc); depthDesc.Width = swapChainDesc.BufferDesc.Width; depthDesc.Height = swapChainDesc.BufferDesc.Height; depthDesc.MipLevels = 1; depthDesc.ArraySize = 1; depthDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; // may be DXGI_FORMAT_D32_FLOAT depthDesc.SampleDesc.Count = swapChainDesc.SampleDesc.Count; depthDesc.SampleDesc.Quality = swapChainDesc.SampleDesc.Quality; depthDesc.Usage = D3D11_USAGE_DEFAULT; depthDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthDesc.CPUAccessFlags = 0; depthDesc.MiscFlags = 0; ID3D11Texture2D* depthStencilTexture = NULL; hr = device->CreateTexture2D(&depthDesc, NULL, &depthStencilTexture); if(FAILED(hr)) { roLog("error", "CreateTexture2D for depth-stencil texture failed\n"); return false; } D3D11_DEPTH_STENCIL_VIEW_DESC depthViewDesc; roMemZeroStruct(depthViewDesc); depthViewDesc.Format = depthDesc.Format; depthViewDesc.ViewDimension = swapChainDesc.SampleDesc.Count == 1 ? D3D11_DSV_DIMENSION_TEXTURE2D : D3D11_DSV_DIMENSION_TEXTURE2DMS; depthViewDesc.Texture2D.MipSlice = 0; ID3D11DepthStencilView* depthStencilView = NULL; hr = device->CreateDepthStencilView(depthStencilTexture, &depthViewDesc, &depthStencilView); if(FAILED(hr)) { roLog("error", "CreateDepthStencilView failed\n"); return false; } immediateContext->OMSetRenderTargets(1, &renderTargetView, depthStencilView); impl->dxRenderTargetView = renderTargetView; impl->dxDepthStencilTexture = depthStencilTexture; impl->dxDepthStencilView = depthStencilView; return true; } bool _initDriverContext_DX11(roRDriverContext* self, void* platformSpecificWindow) { ContextImpl* impl = static_cast<ContextImpl*>(self); if(!impl) return false; HWND hWnd = impl->hWnd = reinterpret_cast<HWND>(platformSpecificWindow); WINDOWINFO info; roMemZeroStruct(info); ::GetWindowInfo(hWnd, &info); impl->width = info.rcClient.right - info.rcClient.left; impl->height = info.rcClient.bottom - info.rcClient.top; HRESULT hr; // Reference on device, context and swap chain: // http://msdn.microsoft.com/en-us/library/bb205075(VS.85).aspx // Create device and swap chain DXGI_SWAP_CHAIN_DESC swapChainDesc; roMemZeroStruct(swapChainDesc); swapChainDesc.BufferCount = 1; swapChainDesc.BufferDesc.Width = impl->width; swapChainDesc.BufferDesc.Height = impl->height; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferDesc.RefreshRate.Numerator = 60; swapChainDesc.BufferDesc.RefreshRate.Denominator = 1; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.OutputWindow = hWnd; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.Windowed = TRUE; swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swapChainDesc.Flags = 0; ID3D11Device* device = NULL; IDXGISwapChain* swapChain = NULL; D3D_FEATURE_LEVEL featureLevel; ID3D11DeviceContext* immediateContext = NULL; hr = D3D11CreateDeviceAndSwapChain( NULL, // Which graphics adaptor to use, default is the first one returned by IDXGIFactory1::EnumAdapters D3D_DRIVER_TYPE_HARDWARE, NULL, // Software rasterizer #if roDEBUG // D3D11_CREATE_DEVICE_DEBUG | D3D11_CREATE_DEVICE_PREVENT_INTERNAL_THREADING_OPTIMIZATIONS | #endif D3D11_CREATE_DEVICE_SINGLETHREADED, NULL, 0, // Feature level D3D11_SDK_VERSION, &swapChainDesc, &swapChain, &device, &featureLevel, &immediateContext ); if(FAILED(hr)) { roLog("error", "D3D11CreateDeviceAndSwapChain failed\n"); return false; } swapChain->SetFullscreenState((BOOL)false, NULL); impl->dxSwapChain = swapChain; impl->dxDevice = device; impl->dxDeviceContext = immediateContext; impl->stagingBufferCacheSearchIndex = 0; impl->stagingTextureCacheSearchIndex = 0; // Create render target if(!_initRenderTarget(impl, swapChainDesc)) return false; impl->driver->applyDefaultState(impl); return true; } void _driverSwapBuffers_DX11() { if(!_currentContext) { roAssert(false && "Please call roRDriver->useContext"); return; } roScopeProfile("roRenderDriver::swapBuffer"); static const float removalTimeOut = 5; // Clean up not frequently used input layout cache for(roSize i=0; i<_currentContext->inputLayoutCache.size();) { float lastUsedTime = _currentContext->inputLayoutCache[i].lastUsedTime; if(lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->inputLayoutCache.removeBySwapAt(i); else ++i; } // Update and clean up on staging buffer cache // NOTE: We just set dxBuffer to null rather than remove the entry in // stagingBufferCache, to avoid array container re-allocation invaliding pointer for(roSize i=0; i<_currentContext->stagingBufferCache.size();) { StagingBuffer& staging = _currentContext->stagingBufferCache[i]; if(staging.dxBuffer && !staging.mapped && staging.lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) { staging.size = 0; staging.dxBuffer = (ID3D11Resource*)NULL; } else ++i; } // Clean up on staging texture cache for(roSize i=0; i<_currentContext->stagingTextureCache.size();) { StagingTexture& staging = _currentContext->stagingTextureCache[i]; if(staging.dxTexture && !staging.mapped && staging.lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) { staging.hash = 0; staging.dxTexture = (ID3D11Resource*)NULL; } else ++i; } // Clean up on render target cache for(roSize i=0; i<_currentContext->renderTargetCache.size();) { RenderTarget& rt = _currentContext->renderTargetCache[i]; if(rt.lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->renderTargetCache.removeBySwapAt(i); else ++i; } // Clean up not frequently used blend cache for(roSize i=0; i<_currentContext->blendStateCache.size();) { float lastUsedTime = _currentContext->blendStateCache[i].lastUsedTime; if(lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->blendStateCache.removeBySwapAt(i); else ++i; } // Clean up not frequently used rasterizer cache for(roSize i=0; i<_currentContext->rasterizerState.size();) { float lastUsedTime = _currentContext->rasterizerState[i].lastUsedTime; if(lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->rasterizerState.removeBySwapAt(i); else ++i; } // Clean up not frequently used depth stencil cache for(roSize i=0; i<_currentContext->depthStencilStateCache.size();) { float lastUsedTime = _currentContext->depthStencilStateCache[i].lastUsedTime; if(lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->depthStencilStateCache.removeBySwapAt(i); else ++i; } // Clean up not frequently used buffer cache for(roSize i=0; i<_currentContext->bufferCache.size();) { float lastUsedTime = _currentContext->bufferCache[i].lastUsedTime; if(lastUsedTime < _currentContext->lastSwapTime - removalTimeOut) _currentContext->bufferCache.removeBySwapAt(i); else ++i; } int sync = 0; // use 0 for no vertical sync roVerify(SUCCEEDED(_currentContext->dxSwapChain->Present(sync, 0))); // Update statistics ++_currentContext->frameCount; float lastSwapTime = _currentContext->lastSwapTime; _currentContext->lastSwapTime = _currentContext->stopWatch.getFloat(); _currentContext->lastFrameDuration = _currentContext->lastSwapTime - lastSwapTime; } bool _driverChangeResolution_DX11(unsigned width, unsigned height) { if(!_currentContext) return false; if(width * height == 0) return true; // Do nothing if the dimension is zero HWND hWnd = (HWND)_currentContext->hWnd; RECT rcClient, rcWindow; POINT ptDiff; ::GetClientRect(hWnd, &rcClient); ::GetWindowRect(hWnd, &rcWindow); ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right; ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom; ::SetWindowPos(hWnd, 0, rcWindow.left, rcWindow.top, width + ptDiff.x, height + ptDiff.y, SWP_NOMOVE|SWP_NOZORDER); _currentContext->width = width; _currentContext->height = height; // Dealing with window resizing: // http://www.breaktrycatch.com/getting-started-with-directx-11/ // http://msdn.microsoft.com/en-us/library/windows/desktop/ee417025%28v=vs.85%29.aspx // Release all render target and view first _currentContext->dxDeviceContext->OMSetRenderTargets(0, NULL, NULL); _currentContext->dxRenderTargetView = (ID3D11RenderTargetView*)NULL; DXGI_SWAP_CHAIN_DESC swapChainDesc; _currentContext->dxSwapChain->GetDesc(&swapChainDesc); swapChainDesc.BufferDesc.Width = width; swapChainDesc.BufferDesc.Height = height; HRESULT hr = _currentContext->dxSwapChain->ResizeBuffers( swapChainDesc.BufferCount, width, height, swapChainDesc.BufferDesc.Format, swapChainDesc.Flags); if(!_initRenderTarget(_currentContext, swapChainDesc)) return false; return SUCCEEDED(hr); }
66176677648150ce7ed805a18fd89679fc977bef
6d6f770686212d6bcbcf873f0395fa5308f20ed8
/OCEAN_SIMULATOR/SIMULATOR/OCEAN2020FOM_simple/Tests/Test_1.cpp
ef295dc043341eedbfda462e3f9c7b46e969ab2a
[]
no_license
SavvasR1991/Marine_vessel_sim
f5ac18ebf64f26aae2ac0cb2163010bdf8c5f0d4
49843482c48df092e36d8a488837cdb045ec952c
refs/heads/main
2023-06-18T14:51:37.975824
2021-07-16T07:06:50
2021-07-16T07:06:50
307,322,910
0
0
null
null
null
null
UTF-8
C++
false
false
71
cpp
Test_1.cpp
/*namespace F1 { void main(int argc, char * argv[]) { } }*/
ac041e5abeb3d36ae4069132a649b82891d6ac27
b9d873f27991b5da6e98fcd7be858871e7a286b6
/CppModule/13-virtual-function/Sample.cpp
8d1a70b746ea50a1d8dd6f671b4c0e186fa00508
[]
no_license
yishengma/C-Cpp-Sample
9eabbca68bcb47fb256f0271dcff09efb9d12d0e
37c24a308f9fd6bcab26cd92117102fe4df606c8
refs/heads/master
2022-11-08T08:08:37.130989
2020-06-28T12:00:06
2020-06-28T12:00:06
268,240,603
1
1
null
null
null
null
UTF-8
C++
false
false
1,294
cpp
Sample.cpp
// // Created by 海盗的帽子 on 2020/6/1. // #include <iostream> //跟java 的抽象类一个概念 class BaseActivity { public: //普通函数 void startActivity(){ initView(); initData(); } //子类需要继承的 //类似Java中的抽象方法 //纯虚函数 virtual void initData() = 0; virtual void initView() = 0; }; class MainActivity : public BaseActivity { public: void initData() { std::cout<<"MainActivity initData"<<std::endl; } void initView() { std::cout<<"MainActivity initView"<<std::endl; } }; //所有的函数都是虚函数,那么就可以认为是接口 class ClickListener { public: virtual void onClick() = 0; }; class ImageClickListener : public ClickListener { void onClick() override { std::cout << "ImageClickListener" << std::endl; } }; //类回调 void click(ClickListener* clickListener){ clickListener->onClick(); }; //函数指针 void click(void print()){ print(); }; int main() { //回调可以用, //函数指针作为回调 //纯虚函数累进行回调 ClickListener* listener = new ImageClickListener(); listener->onClick(); //构造函数顺序:父类-》子类 //析构函数顺序:子类-》父类 }
24261dec27daca8f1845176c1ed68d2b97575b96
8bfa651acc369f1d954510a0c37a0bc6b0c3dba0
/Prueba2/prog9.cpp
f1610f84e0e85ff2212a53269cb097fb654348eb
[]
no_license
migueruokumura/PAGrupo2SII2019
adcbce2011f4cf77a5b35f7be07e9b92fd6d9c6d
877634e3d13f5df6d66b640f217672fb0a1d8e84
refs/heads/master
2020-09-03T17:48:59.244607
2019-10-31T00:52:26
2019-10-31T00:52:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
246
cpp
prog9.cpp
#include <iostream> using namespace std; void f1() { static int i = 100; i += 1; cout<<i<<endl; } void f2() { static int i = 100; i += 1; cout<<i<<endl; } int main() { f1(); //101 f1(); //101 return 0; }
d85dd504a44214646e767d8f7bb97ecc4fa792be
f9a823c1edded12b7dab9a9490b58969f8fb1e76
/Flipper/src/Flipper/Log.cpp
b34974f2a7f25c69ac0a27366d7c3f73b18f84d8
[ "Apache-2.0" ]
permissive
MurraySmith27/FlipperEngine
2ca856c42dff6366fd5e4d21477eff82ec16325d
1b52ff7a6bc147cc1e62f3d8c415b9fa9cf43aac
refs/heads/master
2022-11-15T04:35:54.365464
2020-07-05T21:47:33
2020-07-05T21:47:33
261,017,455
0
0
null
null
null
null
UTF-8
C++
false
false
582
cpp
Log.cpp
#include "flpch.h" #include "Log.h" namespace Flipper { std::shared_ptr<spdlog::logger> Log::s_ClientLogger; std::shared_ptr<spdlog::logger> Log::s_CoreLogger; void Log::Init() { spdlog::set_pattern("[%T] %^%n: %v %$ "); try { s_ClientLogger = spdlog::stdout_color_mt("FLIPPER_APP"); s_ClientLogger->set_level(spdlog::level::trace); s_CoreLogger = spdlog::stdout_color_mt("FLIPPER"); s_CoreLogger->set_level(spdlog::level::trace); } catch (const spdlog::spdlog_ex & ex) { std::cout << "Couldn't intialize log: " << ex.what() << std::endl; } } }
9b3785c29360f02f46be98096913887925aa8049
1e395205d1c315c269a44c2e465831f862b2a491
/src/nimbro/behaviour/walk_and_kick/src/wak_vis.cpp
61efde2e4adc071a3a1f113720bb7a16bb1323f7
[]
permissive
anh0001/EROS
01c46f88cc91ef0677b482124b2974790143e723
a5fae8bf9612cd13fbbcfc0838685430a6fe8fa4
refs/heads/master
2021-08-28T00:07:13.261399
2021-08-20T08:56:12
2021-08-20T08:56:12
195,176,022
0
2
MIT
2021-08-20T08:52:12
2019-07-04T05:44:14
null
UTF-8
C++
false
false
14,460
cpp
wak_vis.cpp
// Walk and kick: Visualisation // Author: Philipp Allgeuer <pallgeuer@ais.uni-bonn.de> // Includes #include <walk_and_kick/wak_vis.h> // Defines #define GOAL_HEIGHT 0.80 #define GOAL_DIAMETER 0.12 #define TEXT_FONT_HEIGHT 0.10 #define TEXT_POSZ_MODE (0.39 + 0*0.10) #define TEXT_POSZ_GAME (0.39 + 1*0.10) #define TEXT_POSZ_BEH (0.39 + 2*0.10) #define TEXT_POSZ_SUB (0.39 + 3*0.10) #define TEXT_OFFZ_BT 0.08 #define BTW_BOX_SIZE 0.03 #define BS_BOX_SIZEX 0.10 #define BS_BOX_SIZEZ 0.03 #define ARROW_SHAFT_DIAM 0.025 #define ARROW_HEAD_DIAM 0.050 #define ARROW_HEAD_LENGTH 0.0 #define FAT_SHAFT_DIAM 0.15 #define FAT_HEAD_DIAM 0.25 #define FAT_HEAD_LENGTH 0.17 #define LINE_THICKNESS 0.015 #define SPHERE_SIZE 0.050 #define BALLOFFSET_SIZE 0.03 #define SUGGFOOT_BOXLEN 0.30 #define FOOT_THICK 0.02 #define TOE_DIAM 0.03 #define WALK_TARGET_SIZE 0.1 #define OBSTACLE_HEIGHT 0.7 #define OBSTACLE_DIAMETER 0.2 // Namespaces using namespace walk_and_kick; // // WAKMarkerMan class // // Constructor WAKMarkerMan::WAKMarkerMan(WAKConfig& config) : MarkerManager("~behaviour_markers", 1, true) , config(config) , field() , egoTrunk("/ego_rot") , egoFloor("/ego_floor") , alloFrame("/beh_field") , BallTarget(this, egoFloor, 1.0, "BallTarget") , Ball(this, egoFloor, 1.0, "Ball") , BallTargetType(this, egoFloor, TEXT_FONT_HEIGHT, "BallTarget") , BallTargetWidthBox(this, egoFloor, BTW_BOX_SIZE, 1.0, BTW_BOX_SIZE, "BallTarget") , BallToTargetLine(this, egoFloor, "BallTarget") , BallToTargetWedge(this, egoFloor, "BallTarget") , WalkingTarget(this, egoFloor, "TargetPose") , WalkingTargetTol(this, egoFloor, "TargetPose") , ObstacleA(this, egoFloor, OBSTACLE_HEIGHT, OBSTACLE_DIAMETER, "Obstacle") , ObstacleB(this, egoFloor, OBSTACLE_HEIGHT, OBSTACLE_DIAMETER, "Obstacle") , TargetPoseArrow(this, alloFrame, FAT_SHAFT_DIAM, FAT_HEAD_DIAM, FAT_HEAD_LENGTH, "TargetPose") , ModeStateText(this, egoTrunk, TEXT_FONT_HEIGHT, "BehaviourState") , GameStateText(this, egoTrunk, TEXT_FONT_HEIGHT, "BehaviourState") , BehStateText(this, egoTrunk, TEXT_FONT_HEIGHT, "BehaviourState") , SubStateText(this, egoTrunk, TEXT_FONT_HEIGHT, "BehaviourState") , GoalSign(this, alloFrame, BS_BOX_SIZEX, field.fieldWidth(), BS_BOX_SIZEZ, "GameState") , GcvXY(this, egoTrunk, ARROW_SHAFT_DIAM, ARROW_HEAD_DIAM, ARROW_HEAD_LENGTH, "GCV") , GcvZ(this, egoTrunk, ARROW_SHAFT_DIAM, ARROW_HEAD_DIAM, ARROW_HEAD_LENGTH, "GCV") , CompassHeading(this, egoFloor, ARROW_SHAFT_DIAM, ARROW_HEAD_DIAM, ARROW_HEAD_LENGTH, "Compass") , CompassHeadingText(this, egoFloor, TEXT_FONT_HEIGHT, "Compass") , SuggestedFoot(this, egoFloor, SUGGFOOT_BOXLEN, FOOT_THICK, FOOT_THICK, "BehShared") , ReqBallOffset(this, egoFloor, "BehShared") , GBBPath(this, egoFloor, "GoBehindBall") , GBBPsiDes(this, egoFloor, "GoBehindBallDetail") , GBBBallView(this, egoFloor, "GoBehindBall") , GBBFarCircle(this, egoFloor, "GoBehindBallDetail") , GBBNearCircle(this, egoFloor, "GoBehindBallDetail") , GBBHaloCircle(this, egoFloor, "GoBehindBallDetail") , GBBBehindBall(this, egoFloor, "GoBehindBall") , GBBBetaAngle(this, egoFloor, "GoBehindBallDetail") , GBBRobotHalo(this, egoFloor, "GoBehindBallDetail") , DBBallRegion(this, egoFloor, "DribbleBall") , KBBallRegionL(this, egoFloor, "KickBall") , KBBallRegionR(this, egoFloor, "KickBall") , KBKickVector(this, egoFloor, ARROW_SHAFT_DIAM, ARROW_HEAD_DIAM, 6.0*ARROW_SHAFT_DIAM, "KickBall") , m_hiddenGBB(false) { // Configure the markers as required Ball.setColor(0.88235, 0.19608, 0.0); BallTarget.setColor(0.5, 0.11, 0.0); BallTargetType.setColor(0.5, 0.11, 0.0); BallTargetWidthBox.setColor(0.5, 0.11, 0.0); BallToTargetLine.setType(visualization_msgs::Marker::LINE_LIST); BallToTargetLine.setScale(LINE_THICKNESS); BallToTargetLine.setNumPoints(4); BallToTargetLine.setNumPtColors(4); BallToTargetLine.setPtColor(0, 0.5, 0.3, 0.2); BallToTargetLine.setPtColor(1, 0.5, 0.3, 0.2); BallToTargetLine.setPtColor(2, 0.7, 0.5, 0.4); BallToTargetLine.setPtColor(3, 0.7, 0.5, 0.4); BallToTargetWedge.setType(visualization_msgs::Marker::LINE_STRIP); BallToTargetWedge.setColor(0.5, 0.3, 0.2); BallToTargetWedge.setScale(LINE_THICKNESS); BallToTargetWedge.setNumPoints(3); WalkingTarget.setType(visualization_msgs::Marker::LINE_LIST); WalkingTarget.setScale(LINE_THICKNESS * 2.0); WalkingTarget.setNumPoints(4); WalkingTarget.setPoint(0, WALK_TARGET_SIZE, WALK_TARGET_SIZE); WalkingTarget.setPoint(1, -WALK_TARGET_SIZE, -WALK_TARGET_SIZE); WalkingTarget.setPoint(2, WALK_TARGET_SIZE, -WALK_TARGET_SIZE); WalkingTarget.setPoint(3, -WALK_TARGET_SIZE, WALK_TARGET_SIZE); WalkingTargetTol.setType(visualization_msgs::Marker::LINE_STRIP); WalkingTargetTol.setScale(LINE_THICKNESS); WalkingTargetTol.setColor(0.8, 0.0, 0.8); WalkingTargetTol.setNumPoints(NumCirclePoints); ObstacleA.setColor(0.0, 0.0, 0.4); ObstacleA.setPosition(0.0, 0.0, 0.5*OBSTACLE_HEIGHT); ObstacleB.setColor(0.13, 0.13, 0.13); ObstacleB.setPosition(0.0, 0.0, 0.5*OBSTACLE_HEIGHT); TargetPoseArrow.setColor(0.8, 0.0, 0.8); ModeStateText.setPosition(0.0, 0.0, TEXT_POSZ_MODE); GameStateText.setPosition(0.0, 0.0, TEXT_POSZ_GAME); BehStateText.setPosition(0.0, 0.0, TEXT_POSZ_BEH); SubStateText.setPosition(0.0, 0.0, TEXT_POSZ_SUB); ModeStateText.setColor(0.8, 0.0, 0.0); GameStateText.setColor(0.0, 0.25, 0.0); BehStateText.setColor(0.6, 0.0, 1.0); SubStateText.setColor(0.0, 0.0, 1.0); GoalSign.setPosition(field.fieldLengthH() + field.boundary() - 0.5*BS_BOX_SIZEX, 0.0, 0.5*BS_BOX_SIZEZ); GcvXY.setColor(0.0, 0.6, 0.6); GcvZ.setColor(0.6, 0.2, 1.0); CompassHeading.setColor(0.3, 0.3, 0.3); CompassHeadingText.setColor(0.3, 0.3, 0.3); CompassHeadingText.setText("N"); SuggestedFoot.setColor(0.8, 0.6, 0.0); SuggestedFoot.setPosition(0.0, 0.0, 0.5*FOOT_THICK); ReqBallOffset.setType(visualization_msgs::Marker::SPHERE_LIST); ReqBallOffset.setColor(0.8, 0.6, 0.0); ReqBallOffset.setScale(BALLOFFSET_SIZE); ReqBallOffset.setNumPoints(2); GBBPath.setType(visualization_msgs::Marker::LINE_STRIP); GBBPath.setScale(LINE_THICKNESS); GBBPath.setColor(1.0, 0.0, 0.0); GBBPsiDes.setType(visualization_msgs::Marker::LINE_STRIP); GBBPsiDes.setScale(LINE_THICKNESS); GBBPsiDes.setColor(0.9, 0.8, 0); GBBPsiDes.setNumPoints(2); GBBBallView.setType(visualization_msgs::Marker::LINE_STRIP); GBBBallView.setScale(LINE_THICKNESS); GBBBallView.setColor(0.7, 0.7, 0.7); GBBBallView.setNumPoints(3); GBBFarCircle.setType(visualization_msgs::Marker::LINE_STRIP); GBBFarCircle.setScale(LINE_THICKNESS); GBBFarCircle.setColor(0.4, 0.6, 1.0); GBBFarCircle.setNumPoints(NumCirclePoints); GBBNearCircle.setType(visualization_msgs::Marker::LINE_STRIP); GBBNearCircle.setScale(LINE_THICKNESS); GBBNearCircle.setColor(0.4, 0.6, 1.0); GBBNearCircle.setNumPoints(NumCirclePoints); GBBHaloCircle.setType(visualization_msgs::Marker::LINE_STRIP); GBBHaloCircle.setScale(LINE_THICKNESS); GBBHaloCircle.setColor(0.4940, 0.1840, 0.5560); GBBHaloCircle.setNumPoints(NumCirclePoints); GBBBehindBall.setType(visualization_msgs::Marker::LINE_STRIP); GBBBehindBall.setScale(LINE_THICKNESS); GBBBehindBall.setColor(0.0, 0.0, 1.0); GBBBehindBall.setNumPoints(3); GBBBetaAngle.setType(visualization_msgs::Marker::LINE_STRIP); GBBBetaAngle.setScale(LINE_THICKNESS); GBBBetaAngle.setColor(1.0, 0.0, 1.0); GBBBetaAngle.setNumPoints(3); GBBRobotHalo.setType(visualization_msgs::Marker::LINE_STRIP); GBBRobotHalo.setScale(LINE_THICKNESS); GBBRobotHalo.setColor(0.2, 0.2, 0.2); GBBRobotHalo.setNumPoints(NumCirclePoints); DBBallRegion.setType(visualization_msgs::Marker::LINE_STRIP); DBBallRegion.setScale(LINE_THICKNESS); DBBallRegion.setNumPoints(2*(30 + 1) + 3); // Note: This should match with the uses of this marker in the BehDribbleBall class KBBallRegionL.setType(visualization_msgs::Marker::LINE_STRIP); KBBallRegionL.setScale(LINE_THICKNESS); KBBallRegionL.setNumPoints(5); KBBallRegionR.setType(visualization_msgs::Marker::LINE_STRIP); KBBallRegionR.setScale(LINE_THICKNESS); KBBallRegionR.setNumPoints(5); KBKickVector.setColor(1.0, 0.5, 0.0); // Set properties of the markers that depend on the ball diameter double ballDiameter = field.ballDiameter(); double ballRadius = 0.5*ballDiameter; Ball.setScale(ballDiameter); Ball.setPosition(0.0, 0.0, ballRadius); BallTarget.setScale(ballDiameter); BallTarget.setPosition(0.0, 0.0, ballRadius); BallTargetType.setPosition(0.0, 0.0, ballDiameter + TEXT_OFFZ_BT); BallTargetWidthBox.setPosition(0.0, 0.0, ballRadius); BallToTargetLine.marker.points[0].z = ballRadius; BallToTargetLine.marker.points[1].z = ballRadius; BallToTargetLine.marker.points[2].z = ballRadius + LINE_THICKNESS; BallToTargetLine.marker.points[3].z = ballRadius + LINE_THICKNESS; for(size_t i = 0; i < BallToTargetWedge.marker.points.size(); i++) BallToTargetWedge.marker.points[i].z = ballRadius; for(size_t i = 0; i < WalkingTarget.marker.points.size(); i++) WalkingTarget.marker.points[i].z = LINE_THICKNESS; WalkingTargetTol.setPosition(0.0, 0.0, 0.5f*LINE_THICKNESS); for(size_t i = 0; i < ReqBallOffset.marker.points.size(); i++) ReqBallOffset.marker.points[i].z = ballRadius; GBBPath.setPosition(0.0, 0.0, ballRadius + LINE_THICKNESS); for(size_t i = 0; i < GBBPsiDes.marker.points.size(); i++) GBBPsiDes.marker.points[i].z = ballRadius; for(size_t i = 0; i < GBBBallView.marker.points.size(); i++) GBBBallView.marker.points[i].z = ballRadius; GBBFarCircle.setPosition(0.0, 0.0, ballRadius); GBBNearCircle.setPosition(0.0, 0.0, ballRadius); GBBHaloCircle.setPosition(0.0, 0.0, ballRadius); for(size_t i = 0; i < GBBBehindBall.marker.points.size(); i++) GBBBehindBall.marker.points[i].z = ballRadius + 0.5*LINE_THICKNESS; for(size_t i = 0; i < GBBBetaAngle.marker.points.size(); i++) GBBBetaAngle.marker.points[i].z = ballRadius + 0.5*LINE_THICKNESS; GBBRobotHalo.setPosition(0.0, 0.0, ballRadius); for(size_t i = 0; i < DBBallRegion.marker.points.size(); i++) DBBallRegion.marker.points[i].z = ballRadius + LINE_THICKNESS; for(size_t i = 0; i < KBBallRegionL.marker.points.size(); i++) KBBallRegionL.marker.points[i].z = ballRadius + LINE_THICKNESS; for(size_t i = 0; i < KBBallRegionR.marker.points.size(); i++) KBBallRegionR.marker.points[i].z = ballRadius + LINE_THICKNESS; KBKickVector.setPoint(0, 0.0, 0.0, ballRadius + LINE_THICKNESS); KBKickVector.setPoint(1, 0.0, 0.0, ballRadius + LINE_THICKNESS); } // Intercepted clear function void WAKMarkerMan::clear(ros::Time stamp) { // Pass on the work to the base implementation vis_utils::MarkerManager::clear(stamp); // Hide a selected group of markers by default BallToTargetWedge.hide(); GBBPath.hide(); GBBPsiDes.hide(); GBBBallView.hide(); GBBFarCircle.hide(); GBBNearCircle.hide(); GBBHaloCircle.hide(); GBBBehindBall.hide(); GBBBetaAngle.hide(); GBBRobotHalo.hide(); DBBallRegion.hide(); KBBallRegionL.hide(); KBBallRegionR.hide(); KBKickVector.hide(); } // Intercepted publish function void WAKMarkerMan::publish() { // Add a selected group of markers by default BallToTargetWedge.updateAdd(); if(!(GBBPath.hidden() && m_hiddenGBB)) { m_hiddenGBB = GBBPath.hidden(); // If GBBPath is hidden then it is assumed/known that all others will be too... GBBPath.updateAdd(); GBBPsiDes.updateAdd(); GBBBallView.updateAdd(); GBBFarCircle.updateAdd(); GBBNearCircle.updateAdd(); GBBHaloCircle.updateAdd(); GBBBehindBall.updateAdd(); GBBBetaAngle.updateAdd(); GBBRobotHalo.updateAdd(); } DBBallRegion.updateAdd(); KBBallRegionL.updateAdd(); KBBallRegionR.updateAdd(); KBKickVector.updateAdd(); // Pass on the work to the base implementation vis_utils::MarkerManager::publish(); } // Update the visibility, 2D position and alpha value of a marker void WAKMarkerMan::updateMarkerXY(vis_utils::GenMarker& marker, bool show, float x, float y, float a) { // Update the marker as required if(show) { marker.marker.pose.position.x = x; marker.marker.pose.position.y = y; marker.marker.color.a = a; marker.show(); } else marker.hide(); marker.updateAdd(); } // // WAKMarkerMan class // // Constructor WAKBagMarkerMan::WAKBagMarkerMan(WAKConfig& config) : MarkerManager("~behaviour_bag_markers", 1, true) , config(config) , egoTrunk("/ego_rot") , egoFloor("/ego_floor") , RobotTrunk(this, egoTrunk, SPHERE_SIZE, "Robot") , RobotLeftFoot(this, egoFloor, "Robot") , RobotRightFoot(this, egoFloor, "Robot") , RobotLeftToe(this, egoFloor, "Robot") , RobotRightToe(this, egoFloor, "Robot") { // Configure the markers as required RobotTrunk.setColor(0.1, 0.1, 0.1); RobotLeftFoot.setColor(0.1, 0.1, 0.1); RobotRightFoot.setColor(0.1, 0.1, 0.1); RobotLeftToe.setColor(0.7, 0.1, 0.1); RobotRightToe.setColor(0.7, 0.1, 0.1); // Config parameter callbacks boost::function<void()> updateCb = boost::bind(&WAKBagMarkerMan::updateVis, this); config.visFootLength.setCallback(boost::bind(updateCb)); config.visFootWidth.setCallback(boost::bind(updateCb)); config.visFootOffsetX.setCallback(boost::bind(updateCb)); config.visFootOffsetY.setCallback(boost::bind(updateCb)); updateVis(); } // Update function for visualisation void WAKBagMarkerMan::updateVis() { // Local variables float length = config.visFootLength(); float width = config.visFootWidth(); float offX = config.visFootOffsetX(); float offY = config.visFootOffsetY(); // Update the markers based on the config parameters RobotLeftFoot.setScale(length, width, FOOT_THICK); RobotLeftFoot.setPosition(offX, offY, 0.5*FOOT_THICK); RobotRightFoot.setScale(length, width, FOOT_THICK); RobotRightFoot.setPosition(offX, -offY, 0.5*FOOT_THICK); RobotLeftToe.setScale(TOE_DIAM, TOE_DIAM, width*0.99); RobotLeftToe.setPosition(offX + 0.5*(length - TOE_DIAM), offY, FOOT_THICK); RobotLeftToe.setOrientation(M_SQRT1_2, M_SQRT1_2, 0.0, 0.0); RobotRightToe.setScale(TOE_DIAM, TOE_DIAM, width*0.99); RobotRightToe.setPosition(offX + 0.5*(length - TOE_DIAM), -offY, FOOT_THICK); RobotRightToe.setOrientation(M_SQRT1_2, M_SQRT1_2, 0.0, 0.0); } // Update function for markers void WAKBagMarkerMan::updateMarkers() { // Add all the required markers to publish if(willPublish()) { RobotTrunk.updateAdd(); RobotLeftFoot.updateAdd(); RobotRightFoot.updateAdd(); RobotLeftToe.updateAdd(); RobotRightToe.updateAdd(); } } // EOF
fe7e92eb7afafb4a4d181adc9f2f886c82a0e03b
f399edede120df020d3e8224dd868846f5d3495b
/1104.cpp
67658c7800802da5bd92f140b20bf148e7303e1d
[]
no_license
liaojianqi/PAT
c6bb9452cb6d0b3787f33de547ad4c2f70217504
47601c1e1acc981aa7c1df7a6ee48c2942cfcfaa
refs/heads/master
2021-01-21T05:29:47.226954
2017-03-01T14:32:35
2017-03-01T14:32:35
83,200,319
0
0
null
null
null
null
UTF-8
C++
false
false
329
cpp
1104.cpp
#include <cstdio> typedef long long ll; const int MAXN=100003; int n; double num[MAXN]; double sum; int main(int argc, char const *argv[]){ freopen("data.txt","r",stdin); scanf("%d",&n) ; for(int i=0;i<n;++i){ scanf("%lf",&num[i]); ll l = i, r = n-1-i; sum += num[i]*(l*r+l+r+1); } printf("%.2f\n",sum); return 0; }
8638055d59216d2a244c4ace5258c740771df449
108f55773d9ed51097d67a1ac04dde8814c0328f
/src/GeoRestRequestHandler/c_RestResult.cpp
baf98e3138f844464e2c8ad3a64286848ba6358e
[]
no_license
jumpinjackie/georest
744e0f43963b86dd7ffa9d0820abcd6a576f3755
0579e822933b02e087950f652105e9647e5cc48d
refs/heads/master
2021-01-10T20:50:33.149005
2012-02-09T09:45:36
2012-02-09T09:45:36
32,226,921
0
0
null
null
null
null
UTF-8
C++
false
false
7,366
cpp
c_RestResult.cpp
// // Copyright (C) 2010 by Haris Kurtagic // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // #include "stdafx.h" #include "c_RestResult.h" #include "Poco\UnicodeConverter.h" #ifdef _WIN32 #undef GetMessage #endif ////////////////////////////////////////////////////////////////// /// <summary> /// Constructor. Create a new c_RestResult object. /// </summary> c_RestResult::c_RestResult() { m_StatusCode = Poco::Net::HTTPResponse::HTTP_OK; // HTTP_STATUS_OK; m_pResultObject = NULL; m_FeatureReader_StartIndex = -1; m_FeatureReader_Count = 64; m_IsSitemapXML=false; } c_RestResult::c_RestResult(MgDisposable* resultObject) { m_StatusCode = Poco::Net::HTTPResponse::HTTP_OK; m_pResultObject = resultObject; m_FeatureReader_StartIndex = -1; m_FeatureReader_Count = 64; m_IsSitemapXML=false; } ////////////////////////////////////////////////////////////////// /// <summary> /// Destructor. This will clean up the result. /// </summary> c_RestResult::~c_RestResult() { } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the status code of the result. /// <returns> /// Success/Error code. /// </returns> /// </summary> Poco::Net::HTTPResponse::HTTPStatus c_RestResult::GetStatusCode() { return m_StatusCode; } ////////////////////////////////////////////////////////////////// /// <summary> /// Sets the status code of the result. /// <returns> /// Nothing. /// </returns> /// </summary> void c_RestResult::SetStatusCode(Poco::Net::HTTPResponse::HTTPStatus status) { m_StatusCode = status; } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the error message in the result. /// <returns> /// Error message or empty string if error message not set. /// </returns> /// </summary> STRING c_RestResult::GetErrorMessage() { return m_ErrorMessage; } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the detailed error message in the result. /// </summary> STRING c_RestResult::GetDetailedErrorMessage() { return m_DetailedMessage; } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the HTTP error message in the result. /// <returns> /// Error message or empty string if error message not set. /// </returns> /// </summary> STRING c_RestResult::GetHttpStatusMessage() { return m_HttpStatusMessage; } ////////////////////////////////////////////////////////////////// /// <summary> /// Sets the error message in the result. /// <returns> /// Nothing. /// </returns> /// </summary> void c_RestResult::SetErrorMessage(CREFSTRING errorMsg) { m_ErrorMessage = errorMsg; } ////////////////////////////////////////////////////////////////// /// <summary> /// Sets the detailed error message in the result. /// </summary> void c_RestResult::SetDetailedErrorMessage(CREFSTRING errorMsg) { m_DetailedMessage = errorMsg; } ////////////////////////////////////////////////////////////////// /// <summary> /// Sets the HTTP error message in the result. /// <returns> /// Nothing. /// </returns> /// </summary> void c_RestResult::SetHttpStatusMessage(CREFSTRING errorMsg) { m_HttpStatusMessage = errorMsg; } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the result object. /// <returns> /// Pointer to an object /// </returns> /// </summary> MgDisposable* c_RestResult::GetResultObject() { return SAFE_ADDREF((MgDisposable*)m_pResultObject); } ////////////////////////////////////////////////////////////////// /// <summary> /// Sets the result object. /// </summary> /// <param name="resultObject"> /// object returned by the API /// </param> /// <returns> /// Nothing. /// </returns> void c_RestResult::SetResultObject(MgDisposable* resultObject, CREFSTRING contentType) { m_pResultObject = SAFE_ADDREF(resultObject); m_contentType = contentType; } ////////////////////////////////////////////////////////////////// /// <summary> /// Gets the result content type. /// <returns> /// Content type (e.g. "text/xml") /// </returns> /// </summary> STRING c_RestResult::GetResultContentType() { return m_contentType; } void c_RestResult::Dispose() { delete this; } INT32 c_RestResult::GetClassId() { return 0; } ///---------------------------------------------------------------------------- /// <summary> /// Sets the error information based on a Mg exception. /// </summary> ///---------------------------------------------------------------------------- void c_RestResult::SetErrorInfo(c_RestRequest* , MgException* mgException) { #ifdef _DEBUG assert(0 != mgException); #endif Poco::Net::HTTPResponse::HTTPStatus httpStatusCode = Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR; // HTTP_STATUS_INTERNAL_SERVER_ERROR; STRING httpStatusMessage; STRING errorMessage; STRING detailedMessage; try { // Map Mg exception to HTTP result. httpStatusMessage = mgException->GetClassName(); #ifdef _MG_ENT_2011 errorMessage = mgException->GetExceptionMessage(); #else errorMessage = mgException->GetMessage(); #endif detailedMessage = mgException->GetDetails(); #ifdef _DEBUG detailedMessage += L"\n"; detailedMessage += mgException->GetStackTrace(); #endif //httpStatusCode = HTTP_STATUS_MG_ERROR; } catch (MgException* e) { SAFE_RELEASE(e); } catch (...) { } // Set the error information. try { SetStatusCode(httpStatusCode); //SetHttpStatusMessage(httpStatusMessage); SetErrorMessage(errorMessage); SetDetailedErrorMessage(detailedMessage); } catch (MgException* e) { SAFE_RELEASE(e); } catch (...) { } } void c_RestResult::SetErrorInfo( c_RestRequest* awRequest, c_ExceptionHTTPStatus& Exception ) { SetStatusCode(Exception.httpStatus()); std::wstring tmpstr; Poco::UnicodeConverter::toUTF16(Exception.displayText(),tmpstr); SetErrorMessage(tmpstr); } void c_RestResult::SetErrorInfo( c_RestRequest* awRequest, Poco::Exception& Exception ) { SetStatusCode(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); std::wstring tmpstr; Poco::UnicodeConverter::toUTF16(Exception.displayText(),tmpstr); SetErrorMessage(tmpstr); } void c_RestResult::SetErrorInfo( c_RestRequest* awRequest, FdoException* Exception ) { SetStatusCode(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR); std::wstring tmpstr; if( Exception->GetExceptionMessage() ) tmpstr = Exception->GetExceptionMessage(); SetErrorMessage(tmpstr); }
fe1a2e6dd37d6e8536b19863aaa14eb1faf17422
7e5be101928eb7ea43bc1a335d3475536f8a5bb2
/OJ - Codeforces/#298/C.cpp
ca8b43099302a74d40f37bdc803074fbc2b8043e
[]
no_license
TaoSama/ICPC-Code-Library
f94d4df0786a8a1c175da02de0a3033f9bd103ec
ec80ec66a94a5ea1d560c54fe08be0ecfcfc025e
refs/heads/master
2020-04-04T06:19:21.023777
2018-11-05T18:22:32
2018-11-05T18:22:32
54,618,194
0
2
null
null
null
null
UTF-8
C++
false
false
914
cpp
C.cpp
// // // // Created by TaoSama on 2015-04-12 // Copyright (c) 2015 TaoSama. All rights reserved. // #include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <set> #include <vector> using namespace std; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int N = 2e5 + 10; int n, a[N]; long long A; int main() { #ifdef LOCAL freopen("in.txt", "r", stdin); // freopen("out.txt","w",stdout); #endif ios_base::sync_with_stdio(0); while(cin >> n >> A) { long long sum = 0; for(int i = 1; i <= n; ++i) cin >> a[i], sum += a[i]; for(int i = 1; i <= n; ++i){ int l = max(1LL, A - (sum - a[i])); int r = min(0LL + a[i], A - (n - 1)); cout<<a[i] - (r - l + 1); cout<<(i == n ? '\n' :' '); } } return 0; }
539ba85562da35a5071e80fb075d1da315217933
d6fae196e039fef21c7d4d9da6124e4bd2cc8e28
/src/ProteinCollection.cpp
1288529575de32426fc34c39874f0e4bb8a3e994
[]
no_license
igorfratel/genome_groups
82aa016d46b5f4b075e5b1a267f03ea4b5440502
04608bc2b631285ec3e2e7a5b41be7fdb5a83e6f
refs/heads/master
2021-09-19T03:55:15.754109
2018-07-23T03:29:33
2018-07-23T03:29:33
111,434,878
1
1
null
null
null
null
UTF-8
C++
false
false
3,769
cpp
ProteinCollection.cpp
/*Undirected edge-weighted graph with adjacency lists implementation*/ #include "ProteinCollection.h" #include <iostream> /** *Creates object with known number of nodes to be added. */ ProteinCollection::ProteinCollection(size_t n_nodes) : nodes(n_nodes), adj(n_nodes) { } /** *Adds node with string identifier. */ void ProteinCollection::add_protein(const std::string& node) { auto new_id = nodes.size(); nodes.emplace(node, node_info_t { new_id, false }); } /** *Adds edge connecting two existing nodes with given weight. */ void ProteinCollection::connect_proteins(const std::string& node1, const std::string& node2, double weight) { auto x = nodes.at(node1).index; auto y = nodes.at(node2).index; if (x >= y) adj[x].emplace(y, weight); else adj[y].emplace(x, weight); } /** *Returns true if given nodes are directly connected and false otherwise. */ bool ProteinCollection::are_connected(const std::string& node1, const std::string& node2) const{ try{ auto x = nodes.at(node1).index; auto y = nodes.at(node2).index; return x >= y ? adj[x].count(y) : adj[y].count(x); } catch(...) { return false; } } /** *Returns weight of the edge connecting two existing and directly *connected nodes or 0.0 otherwise. */ double ProteinCollection::get_similarity(const std::string& node1, const std::string& node2) const{ try{ auto x = nodes.at(node1).index; auto y = nodes.at(node2).index; try{ return x >= y ? adj[x].at(y) : adj[y].at(x); } catch(...) { return 0.0; } } catch(...) { return 0.0; } } /** *Normalizes all the similarity scores, that is, divides them by the highest score in the object. */ void ProteinCollection::normalize() { double max_score = 0; for(size_t i = 0; i < adj.size(); i++) for (typename std::unordered_map<int, double>::iterator it = adj[i].begin(); it != adj[i].end(); ++it) if (it->second > max_score) max_score = it->second; for(size_t i = 0; i < adj.size(); i++) for (typename std::unordered_map<int, double>::iterator it = adj[i].begin(); it != adj[i].end(); ++it) it->second = it->second/max_score; } /** *Returns Vector of connected components where each position is a vector *of nodes in the same component. */ std::vector<std::vector<std::string>> ProteinCollection::connected_components(double weight) { std::vector<std::vector<std::string> > components; for(typename std::unordered_map<std::string, node_info_t>::iterator it = nodes.begin(); it != nodes.end(); ++it) (it->second).visited = false; for(typename std::unordered_map<std::string, node_info_t>::iterator it = nodes.begin(); it != nodes.end(); ++it) if (!(it->second).visited) //For every unvisited node, runs DFS to get all connected nodes DFS_vector_fill(it, components, weight); return components; } /** *Runs DFS from a starting node "n" and adds a vector to components with all the nodes in the same *connected component as n. */ void ProteinCollection::DFS_vector_fill(typename std::unordered_map<std::string, node_info_t>::iterator n, std::vector<std::vector<std::string> > &components, double weight) { std::stack<typename std::unordered_map<std::string, node_info_t>::iterator> my_stack; std::vector<std::string> aux; my_stack.push(n); while (!my_stack.empty()) { n = my_stack.top(); my_stack.pop(); if (!(n->second).visited) { aux.push_back(n->first); (n->second).visited = true; } for(typename std::unordered_map<std::string, node_info_t>::iterator it = nodes.begin(); it != nodes.end(); ++it){ if (!(it->second).visited) { try { if (adj[(n->second).index].at((it->second).index) >= weight) my_stack.push(it); } catch(...){} } } } components.push_back(aux); }
c2e98810f473f962d50e6b3b6c4390c5aff96ecf
107d77cadc57cc8ac16e028b37eda389f15cef06
/term2/projects/p2-unscented-kalman-filter/include/tools.h
6c89f7d2da7bcfaed450571cd955af9168e2c419
[]
no_license
phunghx/Udacity-Self-Driving-Car-Nanodegree
de1b818414f589130eaa51dcbed827208403a43a
805b63a2e9ea49c31382d3092221c7b3ee2042f5
refs/heads/master
2021-05-12T07:46:35.782314
2017-11-10T15:45:38
2017-11-10T15:45:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,218
h
tools.h
#ifndef TOOLS_H_ #define TOOLS_H_ #include <vector> #include "Eigen/Dense" /// \brief Set of common tools required for the project class Tools { public: /// \brief Computes the Root Mean Squared Error (RMSE) between estimate and /// ground truth /// \param estimations estimates /// \param ground_truth ground truth /// \return the computed RMSE static Eigen::VectorXd calculateRMSE(const std::vector<Eigen::VectorXd>& estimations, const std::vector<Eigen::VectorXd>& ground_truth); /// \brief Returns true if x is not zero, up to some predefined threshold /// \param x input /// \return true if x is greater than a small threshold static bool isNotZero(const double x); /// \brief Normalizes an angle to the range [-pi, pi) /// \param x angle to normalize /// \return the normalized angle static double normalizeAngle(const double x); /// \brief Computes the square root of a matrix /// \param x the input matrix /// \return the square root of x, A, such that x = A' * A static Eigen::MatrixXd sqrt(const Eigen::MatrixXd& x); }; #endif /* TOOLS_H_ */
f1dac557c2cb44a25df018dc352f71b0646bb75f
1d63aa8be17ed966f9e68dddcd9e2cf8a531f25f
/img/patricia.h
0b6642b06647249f1af2ab78ec5d33dd1292d2ab
[]
no_license
righthandabacus/righthandabacus.github.io
a660593ec46861d8ef5ca1a0bd81486029ba24dc
9ebec0e3a2274b402fa0ac0d853928229e576bcd
refs/heads/master
2023-08-10T14:42:45.316247
2023-07-22T15:59:52
2023-07-22T15:59:52
44,995,823
2
0
null
null
null
null
UTF-8
C++
false
false
1,722
h
patricia.h
/* vim:set ts=8 sw=8 filetype=cpp noai nosi cin nu noet nolbr sm sbr=">" ff=unix syntax=cpp noic nowrap: */ /** * @author * Copyright 2007 (c) Adrian Sai-wah Tam. * Released under GNU Lesser General Public Licence * @date * Tue Apr 17 14:13:24 HKT 2007 * * @file * @brief * Header file to patricia_cpp.cc */ #ifndef __PATRICIA_H__ #define __PATRICIA_H__ #include <stdlib.h> /** @class patricia patricia.h * @brief * A Patricia tree node */ class patricia { protected: char* str; ///< Key of this node int len; ///< Length of key in bits void* data; ///< Data associated with this key patricia* left; ///< Left branch (1 bit) pointer patricia* right; ///< Right branch (0 bit) pointer /* Internal functions */ protected: patricia* _search(char* key, const patricia*last=NULL) const; void _freekey(patricia* node); void _clone(const patricia* target); static int _bitncmp(const char*s1,const char*s2,int n); static int _extractbit(const char*s,int n); static int _getmatchlen(const char*s1,const char*s2); static int _bitlen(const char* const s); static int _charcmp(const char* s, const char* t); public: patricia(); patricia(char* key, void* data); patricia(const patricia* node); patricia* maxmatch(char* key, const patricia*last=NULL) const; void add(char* key, void* data); void del(char* key, patricia*papa=NULL); inline char* getkey() const { return str; }; inline void* getdata() const { return data; }; #ifdef UNITTEST int validate() const; void printcompact() const; void print(int n=0) const; friend int main(); #endif }; #ifdef UNITTEST #include <stdio.h> #include <string.h> #include <assert.h> #endif #endif
dd3040ceae059ad7637aa1feb6987cde4086133b
3fe692c3ebf0b16c0a6ae9d8633799abc93bd3bb
/Contests/NOIP2018#3Day1/kal0rona/pow/pow.cpp
384792be7d382ceacf9c17786962cdb0ab29c2e8
[]
no_license
kaloronahuang/KaloronaCodebase
f9d297461446e752bdab09ede36584aacd0b3aeb
4fa071d720e06100f9b577e87a435765ea89f838
refs/heads/master
2023-06-01T04:24:11.403154
2023-05-23T00:38:07
2023-05-23T00:38:07
155,797,801
14
1
null
null
null
null
UTF-8
C++
false
false
948
cpp
pow.cpp
#include <iostream> #include <cstdio> #define ll long long using namespace std; const int maxq = 1000200; ll bi[maxq], reses[maxq]; ll a, p, q, k, l, m, c, cur; ll quick_pow(ll base, ll tim, ll mod) { if (base == 1) return 1; if (tim == 1) return base % mod; ll res = quick_pow(base, tim / 2, mod); if (base & 1) return (base * res % mod) * res % mod; return res * res % mod; } void solve() { for (int i = 1; i <= q; i++) { ll res = quick_pow(a, bi[i], p); if (res % k == 0) reses[++cur] = res ^ reses[cur - 1]; } } int main() { freopen("pow.in", "r", stdin); freopen("pow.out", "w", stdout); scanf("%lld%lld%lld%lld%lld%lld%lld%lld", &a, &p, &q, &k, &bi[0], &l, &m, &c); for (int i = 1; i <= q; i++) bi[i] = (m * bi[i - 1] + c) % l; solve(); for (int i = 1; i <= (int)(q / k); i++) printf("%lld", reses[i]); return 0; }
c9c02ae39446e7f7479d275b0ef235f5e48e0cab
96e607f322c33b0d0cbf4548f185301197597312
/include/Methods.h
84bc9d4cd2e624e4ee55c704dedc3e27203b69e0
[]
no_license
Botelho31/SB-Leitor-JVM
72014368dcc1cfb258b57ce8f114550edb585494
2dbeac647744ac4f0c253c2e904b066754f4e2ec
refs/heads/main
2023-04-24T00:49:45.273039
2021-04-25T21:13:30
2021-04-25T21:13:30
346,366,666
0
0
null
null
null
null
UTF-8
C++
false
false
497
h
Methods.h
#ifndef JAVA_H #include "JavaClass.h" #endif #ifndef METHODS_H #define METHODS_H #include "Attributes.h" #include "Method.h" class Methods{ public: Methods(FILE* fp, ConstantPool *cp); ~Methods(); std::string get_Method_Flags (uint16_t flags); void printMethods(ConstantPool *cp); std::vector<Method*> methods; u2 methods_count; private: }; #endif
a1ce241b0369864f22fd322c7865e8aa6701ca8d
87a07564aa1b1836443aaa7dafd5e3255f10c711
/DBWorkTesting/countrymodel.cpp
a1430954a4d7938a2886df7491c17a272874a847
[]
no_license
lesikv1/qt_with_mysql
93887cad76868c2d4abe0602ae3e9f76d61bee56
1b527389a3c3e2baa6e5acae3ee0e38e49532fbf
refs/heads/master
2020-09-05T03:46:12.941734
2019-11-13T13:26:40
2019-11-13T13:26:40
219,973,268
1
0
null
null
null
null
UTF-8
C++
false
false
367
cpp
countrymodel.cpp
#include "countrymodel.h" CountryModel::CountryModel() { } CountryModel::CountryModel(QObject *parent, QSqlDatabase db) { setTable("country"); setEditStrategy(QSqlTableModel::OnFieldChange); select(); setHeaderData( 0, Qt::Horizontal,"Id"); setHeaderData( 1, Qt::Horizontal,"Country"); setHeaderData( 2, Qt::Horizontal,"Citizenship"); }
a91b8d45f272f2c69ec60986af23390f8491217c
b6f2d5b89a648da2c6f716da5243a009845b22fe
/CPP/hello_STDLIB/pairMain.cpp
a41bf03a40a729ff86b65d125a1c7f481c061021
[]
no_license
Lenir/TIL
71c2b3ee5a1a1447334f3b712dc44e5e9c0bd419
cf10757bca640b267b2b130a2b5c94896023c9c2
refs/heads/master
2023-08-11T21:41:01.092993
2023-07-18T01:05:18
2023-07-18T01:05:18
112,985,712
0
0
null
2023-07-18T01:05:19
2017-12-04T02:38:04
Java
UTF-8
C++
false
false
704
cpp
pairMain.cpp
#include "pairMain.h" using namespace std; void pair_main(){ vector<pair<int, string> > intStrPairVector; pair<int, string> intStrPair; intStrPair.first = 1; intStrPair.second = "alpha"; intStrPairVector.push_back(intStrPair); intStrPairVector.push_back(make_pair(2, "beta")); intStrPairVector.push_back(make_pair(3, "charile")); printPairVectorElements(&intStrPairVector); } void printPairVectorElements(vector<pair<int, string> > *pairVector){ vector<pair<int, string> >::iterator pairVectorItr; for(pairVectorItr = (*pairVector).begin(); pairVectorItr != (*pairVector).end(); pairVectorItr++){ cout<< "(" <<(*pairVectorItr).first<<", "<<(*pairVectorItr).second << ")" << endl; } }
d51186157204fa338492e1bcb51f7f1f5f49092d
7ca4136090969e6f998886db32d76f1c2b56d125
/main.cpp
94171987bc13a369e0a872d3b8706cf9bc1d620f
[]
no_license
AugustInMay/ega
744d89c40f052bcb2746f6658f6933cbaeb2a6bb
07e73bdde2d16cac198d5b841250041617701a95
refs/heads/master
2020-09-16T15:15:06.964406
2019-11-29T17:59:14
2019-11-29T17:59:14
223,811,233
0
0
null
2019-11-29T21:44:41
2019-11-24T21:15:44
C++
UTF-8
C++
false
false
15,705
cpp
main.cpp
#include "crossover.h" #include "procreator_choice.h" #include "mutation.h" #include "selection.h" #include "stop_condition.h" #include <fstream> int factorial(int i){ if (i==0) return 1; else return i*factorial(i-1); } int main() { srand(time(NULL)); double **R=new double*[15], G_coef, prev_stop_cond_val=0; int init_pop_meth, num_of_pop, mut_procent=10, mut_rand=rand()%101, mut_ind, cross_meth, procreator_pairs_num, B, selec_method, max_stop_cond_val, cur_stop_cond_val=0, stop_cond_meth, num_of_iterations=1, procr_choice, best_ind, global_ind; char proc_of_gen_ans; bool init_pop_check=true, proc_of_gen=false, crossover_ind, elitist=false, emergency_stop=false; for(int i=0; i<15; i++){ R[i]=new double[15]; } ifstream out("input"); for(int i=0; i<15; i++) { for (int j = 0; j < 15; j++) { if (i == j) { R[i][j] = 0; } else { out >> R[i][j]; } } } cout<<"First things first. By which method will the INITIAL POPULATION be built?\n1)Randomly 2)Greedy algorithm " "(closest neighbour) 3) Greedy algorithm (closest city)\n!WARNING! The chosen method will effect the ammount " "of population."<<endl; while(init_pop_check){ cin>>init_pop_meth; switch(init_pop_meth){ case 1:{ cout<<"\n-----Random method was chosen-----\nNow choose the number of population. You can choose from 2 to " ""<<factorial(15)<<". However it is recommended not to take a big population."<<endl; cin>>num_of_pop; while(num_of_pop<2||num_of_pop>factorial(15)){ cout<<"Wrong input! Try again..."<<endl; cin>>num_of_pop; } init_pop_check=false; break; } case 2:{ cout<<"\n-----Greedy algorithm (closest neighbour) was chosen-----\nNow choose the number of population. " "You can choose from 2 to 15"<<endl; cin>>num_of_pop; while(num_of_pop<2||num_of_pop>15){ cout<<"Wrong input! Try again..."<<endl; cin>>num_of_pop; } cout<<"\nWould you like to see the process of generating? \n1) yes 2) no"<<endl; cin>>proc_of_gen_ans; while(proc_of_gen_ans!='y'&&proc_of_gen_ans!='Y'&&proc_of_gen_ans!='n'&&proc_of_gen_ans!='N'){ cout<<"Wrong input! Try again..."<<endl; cin>>proc_of_gen_ans; } if(proc_of_gen_ans=='y'||proc_of_gen_ans=='Y'){ proc_of_gen=true; } else{ proc_of_gen=false; } init_pop_check=false; break; } case 3:{ cout<<"\n-----Greedy algorithm (closest city) was chosen-----\nNow choose the number of population. " "You can choose from 2 to 15"<<endl; cin>>num_of_pop; while(num_of_pop<2||num_of_pop>15){ cout<<"Wrong input! Try again..."<<endl; cin>>num_of_pop; } cout<<"\nWould you like to see the process of generating? \n1) yes 2) no"<<endl; cin>>proc_of_gen_ans; while(proc_of_gen_ans!='y'&&proc_of_gen_ans!='Y'&&proc_of_gen_ans!='n'&&proc_of_gen_ans!='N'){ cout<<"Wrong input! Try again..."<<endl; cin>>proc_of_gen_ans; } if(proc_of_gen_ans=='y'||proc_of_gen_ans=='Y'){ proc_of_gen=true; } else{ proc_of_gen=false; } init_pop_check=false; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } init_pop_check=true; cout<<"Now choose the crossover:\n1) OX-crossover 2) PMX-crossover"<<endl; while(init_pop_check){ cin>>cross_meth; switch(cross_meth){ case 1:{ crossover_ind=true; init_pop_check=false; cout<<"\n-----OX-crossover was chosen-----"<<endl; break; } case 2:{ crossover_ind=false; init_pop_check=false; cout<<"\n-----PMX-crossover was chosen-----"<<endl; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } cout<<"Now choose the number of procreator pairs (twice of that is the number of children). You can choose from 1 to "<<num_of_pop*(num_of_pop-1)/2<<endl; while(true){ cin>>procreator_pairs_num; if(procreator_pairs_num<1||procreator_pairs_num>(num_of_pop*(num_of_pop-1)/2)){ cout<<"Wrong input! Try again..."<<endl; } else{ break; } } init_pop_check=true; cout<<"There are now "<<procreator_pairs_num<<" pairs of procreators, and "<<procreator_pairs_num*2<<" possible children"<<endl; cout<<"Choose by which method will the procreators be chosen:\n1) Randomly 2) Positive associative mating 3) Negative associative mating"<<endl; while(init_pop_check){ cin>>procr_choice; switch(procr_choice){ case 1:{ init_pop_check=false; cout<<"\n-----Random method was chosen-----"<<endl; break; } case 2:{ init_pop_check=false; cout<<"\n-----Positive associative mating was chosen-----"<<endl; break; } case 3:{ init_pop_check=false; cout<<"\n-----Negative associative mating was chosen-----"<<endl; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } progeny *ch=new progeny[procreator_pairs_num*2]; cout<<"Now enter the g coefficient (0;1] to choose the number of procreators which will be replaced by the progenies:"<<endl; while(true){ cin>>G_coef; if(G_coef<=0||G_coef>1){ cout<<"Wrong input! Try again..."<<endl; } else{ cout<<"The overlap number is "<<overlap_num(G_coef, num_of_pop)<<". Is this acceptable? y/n"; cin>>proc_of_gen_ans; while(proc_of_gen_ans!='y'&&proc_of_gen_ans!='Y'&&proc_of_gen_ans!='n'&&proc_of_gen_ans!='N'){ cout<<"Wrong input! Try again..."<<endl; cin>>proc_of_gen_ans; } if(proc_of_gen_ans=='y'||proc_of_gen_ans=='Y'){ break; } else{ cout<<"Please, enter another coefficient..."<<endl; } } } progeny *pot=new progeny[overlap_num(G_coef, num_of_pop)]; init_pop_check=true; cout<<"Now choose the mutation:\n1) Dot mutation 2) Saltation 3) Inversion 4) Translocation"<<endl; while(init_pop_check){ cin>>mut_ind; switch(mut_ind){ case 1:{ init_pop_check=false; cout<<"\n-----Dot mutation was chosen-----"<<endl; break; } case 2:{ init_pop_check=false; cout<<"\n-----Saltation was chosen-----"<<endl; break; } case 3:{ init_pop_check=false; cout<<"\n-----Inversion was chosen-----"<<endl; break; } case 4:{ init_pop_check=false; cout<<"\n-----Translocation was chosen-----"<<endl; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } cout<<"Current possibility of mutation is 10%. However you can change it. Would you like to do it? y/n"<<endl; cin>>proc_of_gen_ans; while(proc_of_gen_ans!='y'&&proc_of_gen_ans!='Y'&&proc_of_gen_ans!='n'&&proc_of_gen_ans!='N'){ cout<<"Wrong input! Try again..."<<endl; cin>>proc_of_gen_ans; } if(proc_of_gen_ans=='y'||proc_of_gen_ans=='Y'){ cout<<"Please, enter the possibility of mutation (from 0 to 100)"; cin>>mut_procent; while(mut_procent<=-1||mut_procent>=101){ cout<<"Wrong input! Try again..."<<endl; cin>>mut_procent; } } init_pop_check=true; cout<<"Please choose the selection method:\n1) Proportional method 2) B-tournament"<<endl; while(init_pop_check){ cin>>selec_method; switch(selec_method){ case 1:{ cout<<"\n-----Proportional method was chosen-----"<<endl; init_pop_check=false; break; } case 2:{ cout<<"\n-----B-tournament was chosen-----\nNow enter B (from 2 to "<<procreator_pairs_num*2<<"):"<<endl; cin>>B; while(B<2||B>procreator_pairs_num*2){ cout<<"Wrong input! Try again..."<<endl; cin>>B; } init_pop_check=false; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } /*cout<<"Would you like it to be an elitist one? y/n"<<endl; cin>>proc_of_gen_ans; while(proc_of_gen_ans!='y'&&proc_of_gen_ans!='Y'&&proc_of_gen_ans!='n'&&proc_of_gen_ans!='N'){ cout<<"Wrong input! Try again..."<<endl; cin>>proc_of_gen_ans; } if(proc_of_gen_ans=='y'||proc_of_gen_ans=='Y'){ elitist=true; } else{ elitist=false; }*/ init_pop_check=true; cout<<"Finally choose the stop condition\n1) Iteration condition 2) Number of generations without " "max improvement 3) Number of generations without average improvement 4) Low difference in population " "immediately 5) Low difference in population for a period of time"<<endl; while(init_pop_check){ cin>>stop_cond_meth; switch(stop_cond_meth){ case 1:{ cout<<"\n-----Iteration condition was chosen-----\nEnter the maximum iteration"<<endl; cin>>max_stop_cond_val; init_pop_check=false; break; } case 2:{ cout<<"\n-----Number of generations without max improvement was chosen-----\nEnter the number:"<<endl; cin>>max_stop_cond_val; init_pop_check=false; break; } case 3:{ cout<<"\n-----Number of generations without average improvement was chosen-----\nEnter the number:"<<endl; cin>>max_stop_cond_val; init_pop_check=false; break; } case 4:{ cout<<"\n-----Low difference in population immediately was chosen-----\nEnter the min difference:"<<endl; cin>>max_stop_cond_val; init_pop_check=false; break; } case 5:{ cout<<"\n-----Low difference in population for a period of time was chosen-----\nEnter the min difference:"<<endl; cin>>max_stop_cond_val; cout<<"\nEnter the number of iterations:"<<endl; cin>>prev_stop_cond_val; init_pop_check=false; break; } default:{ cout<<"Wrong input! Try again..."<<endl; break; } } } progeny *population=new progeny[num_of_pop]; for(int i=0; i<num_of_pop; i++){ if(proc_of_gen){ cout<<"\n\n-----"<<i+1<<"-species-----"<<endl; } population[i]=*new progeny(0, 15, NULL, true, false, true, init_pop_meth, R, proc_of_gen); for(int j=0; j<i; j++){ if(population[j]==population[i]){ if(proc_of_gen){ cout<<"\n!!!However, there is this gen already. Retrying..."<<endl; } i--; continue; } } } switch(stop_cond_meth){ case 2:{ prev_stop_cond_val=min_dist(population, num_of_pop); break; } case 3:{ prev_stop_cond_val=av_dist(population, num_of_pop); break; } } cout<<"\n\n-----The 0 generation-----"<<endl; double ret=100000; for(int i=0; i<num_of_pop; i++){ population[i].show_gen(); if(population[i].get_dist()<=ret){ ret=population[i].get_dist(); global_ind=i; } } progeny par_per_it[2], ch_per_it[2], solution=*new progeny(population[global_ind]); cout<<"The global solution is:"<<endl; solution.show_gen(); while(true){ cout<<"\n\n-----The "<<num_of_iterations<<" generation-----"<<endl; num_of_iterations++; int j=0; for(int i=0; i<procreator_pairs_num; i++){ procreator_choice_process(procr_choice, population, num_of_pop, 15, par_per_it, R, &emergency_stop); if(emergency_stop){ goto Finished; } crossover(par_per_it, ch_per_it, 15, R, crossover_ind); ch[j]=*new progeny(ch_per_it[0]); ch[j+1]=*new progeny(ch_per_it[1]); j+=2; } cout<<"\n\nCreated children:"<<endl; for(int i=0; i<procreator_pairs_num*2; i++){ ch[i].show_gen(); } for(int i=0; i<procreator_pairs_num*2; i++){ mut_rand=rand()%101; if(mut_rand<=mut_procent){ cout<<"Mutation occured!!!"<<endl; ch[i].show_gen(); cout<<"Changed to..."<<endl; chosen_mut(mut_ind, ch[i], 15, R); ch[i].show_gen(); } } if(selec_method==1){ roulete(overlap_num(G_coef, num_of_pop), ch, procreator_pairs_num*2, pot); } else{ B_tournament(overlap_num(G_coef, num_of_pop), ch, procreator_pairs_num*2, B, pot); } if(stop_cond_meth==1){ cur_stop_cond_val++; } overlap(overlap_num(G_coef, num_of_pop), population, num_of_pop, pot, elitist); double ret=100000; cout<<"\n!!!The new generation is:"<<endl; for(int i=0; i<num_of_pop; i++){ population[i].show_gen(); if(population[i].get_dist()<=ret){ ret=population[i].get_dist(); best_ind=i; } } if(solution.get_dist()>population[best_ind].get_dist()){ solution=*new progeny(population[best_ind]); } cout<<"\n!!!The best in generation is:"<<endl; population[best_ind].show_gen(); if(stop_cond(stop_cond_meth, max_stop_cond_val, &cur_stop_cond_val, &prev_stop_cond_val, population, num_of_pop)){ break; } } Finished: cout<<"\n\n-----The best solution is:"<<endl; solution.show_gen(); delete[] pot; delete[] ch; delete[] population; delete[] R; return 0; }
ceea67c88bdb7212d5430a621e0ed48567ea2c2c
421c68830683c56b793a90c528c11040df4644ab
/stack_using_linked_list.cpp
91f65b631a6d53ed924704ba9bc27c990d0581cc
[]
no_license
nitesh038/data_structure_and_algorithm
a27fce1c455ecec91f2b2082dd7797eb7f5a65e3
3588c38c60d8caf31e400b7566047e09fdb95aec
refs/heads/master
2023-05-28T05:42:28.958480
2021-06-16T19:25:36
2021-06-16T19:25:36
320,923,224
1
0
null
2020-12-20T18:07:02
2020-12-12T21:01:09
C++
UTF-8
C++
false
false
2,349
cpp
stack_using_linked_list.cpp
//Important Link - https://www.geeksforgeeks.org/passing-reference-to-a-pointer-in-c/ #include<iostream> struct Node { int data; struct Node* next; }; bool isEmpty(struct Node* top) { if(top==NULL) return true; return false; } bool isFull(struct Node* t) { if(t==NULL) return true; return false; } void push(struct Node** top, int data) { struct Node *t = new Node; if(isFull(t)) { std::cout<<"Stack Overflow\n"; delete t; t=nullptr; return ; } t->data = data; t->next = *top; *top=t; } int pop(struct Node** top) { struct Node *t = new Node; if(isEmpty(*top)) { std::cout<<"Stack Underflow\n"; return -1; } t = *top; *top = (*top)->next; int popped_element = t->data; delete t; t = nullptr; return popped_element; } void display(struct Node* top) { struct Node* p = top; std::cout<< "Elements in the stack are: \n"; while(p!=NULL) { std::cout<<p->data<<std::endl; p=p->next; } } int peek(Node* top, int pos) { Node* t = top; for(int counter=0; counter < pos-1 && t != NULL; counter++ ) t = t->next; if(t!=NULL) return t->data; else return -1; } int main() { struct Node* top = NULL; char ch{}; int data{}; int position{}; while(ch!='5') { std::cout << "Press 1 to Push an element .. 2 to Pop an element .... 3 to Peek and 4 to display and 5 to exit\n"; std::cin >> ch; switch (ch) { case '1': std::cout<< "\nEnter the element to push to stack: \n"; std::cin >> data; push(&top, data); break; case '2': std::cout<< "Popped element is: " << pop(&top) << std::endl; break; case '3': std::cout<< "\nEnter the Position to Peek: \n"; std::cin >> position; std::cout<< "Peeked Element is: " << peek(top, position) << std::endl; break; case '4': display(top); break; case '5': break; default: std::cout<< "Wrong Input provided\n"; break; } } return 0; }
f75fb9a72ca637ac6f8863ab1ccb0f4e5725828d
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/python/pythran/pythran/xsimd/types/xsimd_generic_arch.hpp
6aaee93393e05907a0b4e2de64f4c8b1f0648060
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C++
false
false
2,113
hpp
xsimd_generic_arch.hpp
/*************************************************************************** * Copyright (c) Johan Mabille, Sylvain Corlay, Wolf Vollprecht and * * Martin Renou * * Copyright (c) QuantStack * * Copyright (c) Serge Guelton * * * * Distributed under the terms of the BSD 3-Clause License. * * * * The full license is in the file LICENSE, distributed with this software. * ****************************************************************************/ #ifndef XSIMD_GENERIC_ARCH_HPP #define XSIMD_GENERIC_ARCH_HPP #include "../config/xsimd_config.hpp" /** * @defgroup architectures Architecture description * */ namespace xsimd { /** * @ingroup architectures * * Base class for all architectures. */ struct generic { /// Whether this architecture is supported at compile-time. static constexpr bool supported() noexcept { return true; } /// Whether this architecture is available at run-time. static constexpr bool available() noexcept { return true; } /// If this architectures supports aligned memory accesses, the required /// alignment. static constexpr std::size_t alignment() noexcept { return 0; } /// Whether this architecture requires aligned memory access. static constexpr bool requires_alignment() noexcept { return false; } /// Unique identifier for this architecture. static constexpr unsigned version() noexcept { return generic::version(0, 0, 0); } /// Name of the architecture. static constexpr char const* name() noexcept { return "generic"; } protected: static constexpr unsigned version(unsigned major, unsigned minor, unsigned patch) noexcept { return major * 10000u + minor * 100u + patch; } }; } #endif
443f0b2e3678808c7ae223c78d639aecf7b4aedc
e811bbeed7e1c8b66967f5ba3d41bb96ebd85c46
/src/salamander.hpp
64ea5c41916acbc5a18167b05ff83f3c9a2d06fc
[]
no_license
r-barnes/BarnesClark2017-Salamanders
0f8ea5136b837841fadd3408f3d6a5c9a00b64f9
b3d5636f644688a04604108dad4a0fde024c07c0
refs/heads/master
2021-01-20T02:37:41.842391
2017-10-19T19:12:52
2017-10-19T19:12:52
80,172,174
0
0
null
null
null
null
UTF-8
C++
false
false
3,438
hpp
salamander.hpp
#ifndef _salamander #define _salamander #include "params.hpp" #include <cstdint> #include <bitset> class Salamander { public: ///Gene Type - used for storing genetic information that is used to ///determine whether individuals are of the same species, based on a bitwise ///comparison of the binary expression of this number. typedef std::bitset<64> genetype; ///Initialize a new salamander. Is initialized as "alive", but with no ///parent (=-1), genome = 0, optimum temperature = 0, and ///probability of mutation = 1e-4. Salamander(); ///Breed this salamander with another to make a baby! Returns a child ///salamander. Child's optimum temperature is the average of its parents, ///plus a mutation, drawn from a standard normal distribution. Child genome ///is based on a merge of the bit fields of the parents' genomes. Salamander breed(const Salamander &b) const; ///Determine whether two salamander genomes are similar. If the genomes are ///considered similarly, then the individuals are members of the same ///species. species_sim_thresh is a number in [0,1] describing how similar ///two genomes must be before salamanders are deemed to be of the same ///species. Returns TRUE if salamanders are of the same species. bool pSimilar(const Salamander &b, int species_sim_thresh) const; ///Comparison of the similarity between two genomes. Used to compare genetic ///similarity and determine whether genes come from members of the same ///species. species_sim_thresh is a number in [0,1] describing how similar ///two genomes must be before salamanders are deemed to be of the same ///species. Returns TRUE if genes are of the same species. bool pSimilarGenome(const Salamander::genetype &b, int species_sim_thresh) const; ///Mutate this salamander's genome. Flips each element of the bit field with ///probability mutation_probability. void mutate(); ///Determines whether a salamander dies given an input temperature and its ///optimum temperature. Based on a logit curve, parameterized such that a ///salamander dies with ~50% probability if it is more than 8 degrees C from ///its optimum temperature, and with ~90% probability if it is more than 12 ///degrees from its optimum temperature. Returns TRUE if the salamander ///dies. bool pDie( const double tempdegC, const double conspecific_abundance, const double heterospecific_abundance ) const; ///Neutral genes. Determined by the parents of the salamander and used to ///determine if the salamander is of the same species as another salamander. genetype genes; ///Optimal temperature in degC for this salamander. For the first ///salamander, this is initialized as 33.5618604122814, which is the ///temperature (in degrees C) that we have projected for sea level in the ///Appalachians 65MYA. This value is determined for children by the average ///of their parents' otemp, and changes between generations based on a ///mutation rate described in mutate(). double otempdegC; ///The phylogenetic node this salamander is part of (i.e., from what lineage ///did this salamander arise?) Is set to -1 for uninitialized salamanders, but ///should always be set to a positive number indicating the salamander's ///parent species. The only exception to this is the first salamander ///("Eve"), which is its own parent, set at 0. int species; }; #endif
c8ee955909e09534c09e206f306b226c03d3935c
8ac089df03caa28f051872e63a4bfeca8c7d9e3b
/ZViewer/ZViewer/src/SelectToFolderDlg.h
4ca3b156c1a3cc05ad7dba987b9cbaa1c5e38238
[]
no_license
zelon/ZViewer
ecdd8cff618a10620e4fa14698c6f479e3028ba9
baad184793737e8c8f291e90426d6d509585d6c3
refs/heads/master
2022-01-18T11:55:56.858852
2022-01-02T02:56:33
2022-01-02T02:56:33
3,062,306
7
5
null
null
null
null
UTF-8
C++
false
false
537
h
SelectToFolderDlg.h
#pragma once /// class for selecting a directory class CSelectToFolderDlg final { public: CSelectToFolderDlg(const tstring & initaliDir = L""); ~CSelectToFolderDlg(); /// 다이얼로그를 화면에 띄운다. bool DoModal(); const tstring & GetSelectedFolder() const { return m_strSelectedFolder; } static INT_PTR CALLBACK MoveToDlgPrc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam); private: HWND m_hWnd; void SetFolder(const tstring & strFolder); void OnBrowserButton() const; tstring m_strSelectedFolder; };
96e8c1b3ad2d79c66c289d5d83b2e2e1e194d6c6
6c0e8a23af93c38dc9d62b43fb3b96d952a85c21
/hello/valera2.cpp
34d951bb02d4d60990361f11d5164a748625ceff
[]
no_license
Bernini0/Codes
9072be1f3a1213d1dc582c233ebcedf991b62f2b
377ec182232d8cfe23baffa4ea4c43ebef5f10bf
refs/heads/main
2023-07-06T13:10:49.072244
2021-08-11T17:30:03
2021-08-11T17:30:03
393,320,827
0
0
null
null
null
null
UTF-8
C++
false
false
947
cpp
valera2.cpp
#include <bits/stdc++.h> using namespace std; int main() { int y, k, n; scanf("%d %d %d", &y, &k, &n); int e = k; int b = y % k; int c = n / k; int d = 0; int f = (n - y) / k; if (k > n) { printf("-1\n"); return 0; } else if (y >= n) { printf("-1\n"); return 0; } else if (e == 1) { for (int i = 1; i <= n - y; i++) { if (i == (n - y)) { printf("%d\n", i); } else { printf("%d ", i); } } return 0; } else if (c == 1) { printf("%d", k - b); return 0; } else if (c > 1 && f > 0) { for (int i = k - b; i <= (n - y); i = i + k) { printf("%d ", i); d = i; } printf("%d\n", d + k); } return 0; } printf("-1\n"); }
9bfc03928e7eb849b2c2344fdcce42640216c663
06c50c8d6d1cf3d2a19410ab3a7e56083e83aef4
/include/xne/domains/inet/utility.h
236bad589ad79f5f6d4f72ef06a6763762283b0f
[ "MIT" ]
permissive
codacy-badger/xne
8fbff5d2d64d572c766d088d97ebd82bf14a92e1
f857f237b523becc3ab9c9db145c63c2c60bfc3c
refs/heads/master
2020-04-22T21:50:20.390271
2019-02-12T11:55:22
2019-02-12T11:55:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
704
h
utility.h
/** * @file utility.h * @author isnullxbh * @date 2019-02-12 15:26 * @version 0.0.1 */ #ifndef XNE_DOMAINS_INET_UTILITY_H #define XNE_DOMAINS_INET_UTILITY_H #include <string> #include "xne/core/basic_protocol.h" #include "xne/domains/inet/address_base.h" namespace xne { namespace net { namespace inet { class utility { public: static void presentation_to_network_address(const basic_protocol& protocol, const std::string& str, address_base& address); static void network_address_to_presentation(const basic_protocol& protocol, std::string& buf, const address_base& address); }; } // namespace inet } // namespace net } // namespace xne #endif // XNE_DOMAINS_INET_UTILITY_H
b8e86f8b9b9f817c995049fc6b91ddced6936bf4
726df6fc883aa216b81f8e0682ec427febdbf89d
/PTKeyEventInterfaces/PtKeyEventInterface.h
51ca69d61124393b06133015acdd4b7bcf65d8bd
[]
no_license
Qmax/QUTE
48ac34384885558ea4f6310f122b2e4f6450853d
09d65671d4280d6cd9b9f97243846708d7968cff
refs/heads/master
2021-01-01T05:33:53.379760
2014-12-04T11:38:05
2014-12-04T11:38:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,390
h
PtKeyEventInterface.h
#ifndef GPIOEVENTINTERFACE_H #define GPIOEVENTINTERFACE_H #include<QtCore> #include<PTEventInterfaces.h> #include <QtGui> #include <QWSKeyboardHandler> #include <string.h> #include "/usr/local/DigiEL-5.6/kernel/linux-2.6.31/include/linux/input.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <dirent.h> #include <linux/input.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/select.h> #include <sys/time.h> #include <termios.h> #include <signal.h> #include <QSocketNotifier> #include <QFile> #include <QString> #include <QDebug> #include <QCoreApplication> #include <QApplication> #include <QEvent> #include <QKeyEvent> #include <QCustomEvent> #include "qevent.h" #include "KeyObject.h" #include <PtKeys.h> #include <qdebug.h> #if 1 #define qLog(x) qDebug() #else #define qLog(x) while (0) qDebug() #endif struct TranslatedKeyEvent { explicit TranslatedKeyEvent(input_event const & event); int unicode_; int keyCode_; bool isPress_; bool autoRepeat_; private: static const int unknownCode = 0xffff; }; const QEvent::Type PTKeyEventCode = (QEvent::Type) 5678; class PTKeyEvent:public QWidget,public QWSKeyboardHandler { Q_OBJECT public: PTKeyEvent(QWidget *parent=0,int *pKey=0); ~PTKeyEvent(); int callclosefd(); void create(QString driver, QString pDevice); unsigned int l_nRegisterValue; QWidget *m_TW; private: QSocketNotifier *m_notify; int kbdFD; bool shift; int *m_nKey; private Q_SLOTS: void readKbdData(); }; class PTKeyEventInterface:public QObject,public PTEventInterface { Q_OBJECT Q_INTERFACES(PTEventInterface) public: ~PTKeyEventInterface(){} void InvokeGPIOEvent(QWidget *parent,QString driver, QString device,int *pKeyCode); void closefd(void); bool BlockSig(bool get); protected: PTKeyEvent *g_objKeyevent; }; class PTKeyPressEvent:public QEvent { public: //static const QEvent::Type myType = static_cast<QEvent::Type>(2000); PTKeyPressEvent(int pKbdData):QEvent((QEvent::Type)1236) { //PTKeyPressEvent = (QEvent::Type)1234; m_nKeycode = pKbdData; qLog() << "PTKEYCODE" << hex << pKbdData; } int m_nKeycode; public slots: protected: }; #endif // GPIOEVENTINTERFACE_H
4803e54cec24021d6078d2e3456a03530427be2c
48dfc3cd5f400a7d3426281d3f2664d46ec71dbe
/Traffic_Simulation_Graphical/Light.cpp
bda67c708b6ac29b596a1e3b9966abdb839f2d33
[]
no_license
Harsha-G/Traffic_Simulation_Cpp_MFC
21292f11f11d91a573cef310fe6778bab82c084d
ef5ccbf53966f7296e58db1fffe257dd69081f34
refs/heads/master
2020-03-31T06:56:52.186537
2018-10-08T02:49:06
2018-10-08T02:49:06
152,000,995
2
1
null
null
null
null
UTF-8
C++
false
false
168
cpp
Light.cpp
#include "stdafx.h" //#include "Header.h" // //Light::Light() { // state = false; //} // //void Light::toggle() { // state = (state == true)? false : true; //}
d50501c128d8df9471e0a7d6f6775051ae0921d3
703e2a29617917491f33bd9047dbef5c14eb7a04
/src/game/map/tiletemplate.h
ba4501761dbed7c7ae11a0f2919d8d512f94ecfb
[]
no_license
mcdooda/crispy-guacamole
83a020894431c20e80b32ef1044f50c774ad840a
d6265fa79b95647ed1736f7116356a39dd6a1c7f
refs/heads/master
2023-01-13T15:10:38.684785
2023-01-02T19:37:21
2023-01-02T19:37:21
62,343,659
7
0
null
null
null
null
UTF-8
C++
false
false
1,491
h
tiletemplate.h
#ifndef GAME_MAP_TILETEMPLATE_H #define GAME_MAP_TILETEMPLATE_H #include <string> #include "texturepack.h" #include "navigability.h" namespace game { class Game; namespace map { class TileTemplate { public: TileTemplate(const std::filesystem::path& path, Game& game); ~TileTemplate(); inline std::filesystem::path getName() const { return m_path.stem(); } inline const std::shared_ptr<const flat::video::Texture>& getTexture() const { return m_texture; } int getRandomTileVariantIndex(Game& game) const; int getRandomTileVariantIndex(Game& game, const std::vector<int>& tileVariantIndices) const; inline float getFrameDuration() const { return m_frameDuration; } inline int getNumFrames() const { return m_numFrames; } inline int getNumVariants() const { return static_cast<int>(m_tileVariantProbabilities.size()); } inline const flat::lua::SharedLuaReference<LUA_TFUNCTION>& getSelectTile() const { return m_selectTile; } inline Navigability getNavigability() const { return m_navigability; } private: void loadTileConfig(Game& game, const std::filesystem::path& path); private: std::filesystem::path m_path; std::shared_ptr<const flat::video::Texture> m_texture; std::vector<float> m_tileVariantProbabilities; flat::lua::SharedLuaReference<LUA_TFUNCTION> m_selectTile; float m_tileVariantProbabilitiesSum; float m_frameDuration; int m_numFrames; Navigability m_navigability; }; } // map } // game #endif // GAME_MAP_TILETEMPLATE_H
9189aa86d0dea97c136cf0afa818dfc3e44fc731
7cb0393186494b56be1471475ed26fa72e9e1092
/third-party/JCQP/CholeskyDenseSolver.cpp
2872164d72603c461ac7454e3ede9ce77fda3888
[ "MIT" ]
permissive
Sorokonog/Cheetah-Software
15b5ee6b9a92b051d0b2f710234cfef829532c81
e2a7f0521412be129ca114a9545636bc3e20f186
refs/heads/master
2022-02-11T14:46:45.286293
2021-12-25T07:36:33
2021-12-25T07:36:33
235,743,673
1
2
MIT
2021-12-24T20:10:52
2020-01-23T07:19:52
C++
UTF-8
C++
false
false
10,988
cpp
CholeskyDenseSolver.cpp
/*! * @file: CholeskyDenseSolver.cpp * * Dense Cholesky Solver. */ #include "CholeskyDenseSolver.h" #include "Timer.h" #include <cassert> #include <iostream> #include <immintrin.h> static constexpr s64 UNROLL_MATVEC = 8; //! Loop unroll for all inner loops, AVX2 only /*! * Perform initial factorization */ template<typename T> void CholeskyDenseSolver<T>::setup(const DenseMatrix<T> &kktMat) { Timer tim; assert(kktMat.cols() == kktMat.rows()); // must be a square matrix n = kktMat.rows(); // setup L.resize(n,n); // Lower triangular D.resize(n); // Diagonal L = kktMat; // solved in place for better cache usage D.setZero(); pivots = new s64[n]; // permutations for pivoting Vector<T> temp(n); // O(n) temporary storage, used in a few places if(_print) printf("CHOLDENSE SETUP %.3f ms\n", tim.getMs()); tim.start(); // in place dense LDLT algorithm for(s64 row = 0; row < n; row++) { // step 1: find the largest row to pivot with T largestDiagValue = -std::numeric_limits<T>::infinity(); s64 pivot = -1; for(s64 rowSel = row; rowSel < n; rowSel++) { T v = std::abs(L(rowSel, rowSel)); if(v > largestDiagValue) { largestDiagValue = v; pivot = rowSel; } } assert(pivot != -1); // step 2: PIVOT pivots[row] = pivot; if(pivot != row) // but only if we need to (pivot > row)! { assert(pivot > row); // swap row for(s64 i = 0; i < row; i++) { std::swap(L(row, i), L(pivot, i)); } // swap col for(s64 i = pivot + 1; i < n; i++) { std::swap(L(i, row), L(i, pivot)); } // swap elt std::swap(L(row, row), L(pivot, pivot)); for(s64 i = row + 1; i < pivot; i++) { std::swap(L(i, row), L(pivot, i)); } } // step 3, FACTOR: // wikipedia equation: A_ij - L_ij * D_j = sum_{k=1}^{j-1} L_ik * L_jk * D_k // wikipedia eqn 2 : D_j = A_jj - sum_{k = 1}^{j-1} L_jk^2 D_k // wikipedia "i" is my "row" if(row > 0) { for(s64 i = 0; i < row; i++) { temp[i] = L(i, i) * L(row, i); // temp[k] = D_k * L_ik } for(s64 i = 0; i < row; i++) { L(row, row) -= temp[i] * L(row, i); // D_i = A_ii - sum_k D_k * L_ik } //T factor = L(row, row); // compute ith (row-th) column of L // all L's are assumed to be in the row-th column // reuse the L_ik * D_k from earlier. // instead of solving 1-by-1, compute contributions from columns because matrix is col-major order. if(n - row - 1 > 0) { T* mat = L.data() + row + 1; T* result = L.data() + row + 1 + n * row; T* vec = temp.data(); setupAVX(mat, result, vec, row); // O(n^2) inner loop } } // step 4, divide. T diag = L(row, row); if(std::abs(diag) < 1e-6) { printf("ERROR: LDLT fail (poorly conditioned pivot %g)\n", diag); assert(false); } if(n - row - 1 > 0) { T mult = T(1) / diag; for(s64 i = row + 1; i < n; i++) { L(i, row) *= mult; } } } if(_print) printf("CHOLDENSE FACT %.3f ms\n", tim.getMs()); tim.start(); // set up memory: solve1 = new T[n * (n - 1)]; // elements of L ordered for first triangular solve solve2 = new T[n * (n - 1)]; // elements of L ordered for second triangular solve s64 c = 0; for(s64 j = 0; j < n; j++) { for(s64 i = j + 1; i < n; i++) { solve1[c++] = L(i,j); // i > j } } c = 0; for(s64 j = n; j --> 0;) { for(s64 i = 0; i < j; i++) { solve2[c++] = L(j, i); } } if(_print) printf("CHOLDENSE FIN %.3f ms\n", tim.getMs()); } /*! * Inner O(n^2) loop used in factorization, written with AVX intrinsics */ template<> void CholeskyDenseSolver<double>::setupAVX(double *mat, double *result, double *vec, u64 row) { s64 R = n - row - 1; s64 C = row; double* matPtr; double* resultPtr; for(s64 c = 0; c < C; c++) { #ifdef JCQP_USE_AVX2 __m256d vecData = _mm256_set1_pd(vec[c]); // broadcast to all #endif resultPtr = result; matPtr = mat + c * n; s64 r = 0; r = 0; #ifdef JCQP_USE_AVX2 s64 end = R - 4 * UNROLL_MATVEC; // gcc fails to make this optimization. for(; r < end; r += 4 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256d matData = _mm256_loadu_pd(matPtr); __m256d resultData = _mm256_loadu_pd(resultPtr); resultData = _mm256_fnmadd_pd(vecData, matData, resultData); _mm256_storeu_pd(resultPtr, resultData); matPtr += 4; resultPtr += 4; } } #endif // leftovers that don't fit in a vector. for(; r < R; r++) { *resultPtr = *resultPtr - *matPtr * vec[c]; resultPtr++; matPtr++; } } } /*! * Specialization for float, can pack 8 numbers/register */ template<> void CholeskyDenseSolver<float>::setupAVX(float *mat, float *result, float *vec, u64 row) { s64 R = n - row - 1; s64 C = row; float* matPtr; float* resultPtr; for(s64 c = 0; c < C; c++) { #ifdef JCQP_USE_AVX2 __m256 vecData = _mm256_set1_ps(vec[c]); // broadcast to all #endif resultPtr = result; matPtr = mat + c * n; s64 r = 0; #ifdef JCQP_USE_AVX2 s64 end = R - 8 * UNROLL_MATVEC; // gcc fails to make this optimization. for(; r < end; r += 8 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256 matData = _mm256_loadu_ps(matPtr); __m256 resultData = _mm256_loadu_ps(resultPtr); resultData = _mm256_fnmadd_ps(vecData, matData, resultData); _mm256_storeu_ps(resultPtr, resultData); matPtr += 8; resultPtr += 8; } } #endif // leftovers. for(; r < R; r++) { *resultPtr = *resultPtr - *matPtr * vec[c]; resultPtr++; matPtr++; } } } /*! * Reconstruct the original matrix (permuted). Only used for debugging, this is slow */ template<typename T> DenseMatrix<T> CholeskyDenseSolver<T>::getReconstructedPermuted() { DenseMatrix<T> LDebug(n,n); for(s64 j = 0; j < n; j++) { for(s64 i = 0; i < n; i++) { if(i == j) { LDebug(i,j) = 1; } else if (i > j) { LDebug(i,j) = L(i,j); } } } DenseMatrix<T> Reconstructed = LDebug * L.diagonal().asDiagonal() * LDebug.transpose(); return Reconstructed; } /*! * public solve function */ template<typename T> void CholeskyDenseSolver<T>::solve(Vector<T> &out) { // only use the AVX solver if we have it available. #ifdef JCQP_USE_AVX2 solveAVX(out); return; #endif s64 c = 0; // first permute: for(s64 i = 0; i < n; i++) { std::swap(out[pivots[i]], out[i]); } // now temp = b // next solve L * y = b in place with temp. L is column major // the inner loop is down the result of the solve. for(s64 j = 0; j < n; j++) { for(s64 i = j + 1; i < n; i++) { out[i] -= solve1[c++] * out[j]; // i > j } } // next do scaling for inv(D) * y // now temp contains y; for(s64 i = 0; i < n; i++) { out[i] /= L(i,i); } c = 0; for(s64 j = n; j --> 0;) { for(s64 i = 0; i < j; i++) { out[i] -= solve2[c++] * out[j]; } } // finally, untranspose for(s64 i = n; i-->0;) { std::swap(out[pivots[i]], out[i]); } } #ifdef JCQP_USE_AVX2 template<> void CholeskyDenseSolver<double>::solveAVX(Vector<double> &out) { // first permute: for(s64 i = 0; i < n; i++) { std::swap(out[pivots[i]], out[i]); } // O(n^2) loop 1 double* matPtr = solve1; double* lhsPtr; for(s64 j = 0; j < n; j++) { lhsPtr = out.data() + j + 1; __m256d rhs = _mm256_set1_pd(out[j]); s64 i = j + 1; s64 vEnd = n - 4 * UNROLL_MATVEC; for(; i < vEnd; i += 4 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256d mat = _mm256_loadu_pd(matPtr); __m256d lhs = _mm256_loadu_pd(lhsPtr); lhs = _mm256_fnmadd_pd(rhs, mat, lhs); _mm256_storeu_pd(lhsPtr, lhs); matPtr += 4; lhsPtr += 4; } } for(; i < n; i++) { *lhsPtr = *lhsPtr - *matPtr * out[j]; lhsPtr++; matPtr++; } } // next do scaling for inv(D) * y // now temp contains y; for(s64 i = 0; i < n; i++) { out[i] /= L(i,i); } matPtr = solve2; for(s64 j = n; j --> 0;) { lhsPtr = out.data(); __m256d rhs = _mm256_set1_pd(out[j]); s64 i = 0; s64 vEnd = j - 4 * UNROLL_MATVEC; for(; i < vEnd; i += 4 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256d mat = _mm256_loadu_pd(matPtr); __m256d lhs = _mm256_loadu_pd(lhsPtr); lhs = _mm256_fnmadd_pd(rhs, mat, lhs); _mm256_storeu_pd(lhsPtr, lhs); matPtr += 4; lhsPtr += 4; } } for(; i < j; i++) { *lhsPtr = *lhsPtr - *matPtr * out[j]; lhsPtr++; matPtr++; } } // O(n^2) loop 2 // finally, untranspose for(s64 i = n; i-->0;) { std::swap(out[pivots[i]], out[i]); } } template<> void CholeskyDenseSolver<float>::solveAVX(Vector<float> &out) { // first permute: for(s64 i = 0; i < n; i++) { std::swap(out[pivots[i]], out[i]); } // O(n^2) loop 1 float* matPtr = solve1; float* lhsPtr; for(s64 j = 0; j < n; j++) { lhsPtr = out.data() + j + 1; __m256 rhs = _mm256_set1_ps(out[j]); s64 i = j + 1; s64 vEnd = n - 8 * UNROLL_MATVEC; for(; i < vEnd; i += 8 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256 mat = _mm256_loadu_ps(matPtr); __m256 lhs = _mm256_loadu_ps(lhsPtr); lhs = _mm256_fnmadd_ps(rhs, mat, lhs); _mm256_storeu_ps(lhsPtr, lhs); matPtr += 8; lhsPtr += 8; } } for(; i < n; i++) { *lhsPtr = *lhsPtr - *matPtr * out[j]; lhsPtr++; matPtr++; } } // next do scaling for inv(D) * y // now temp contains y; for(s64 i = 0; i < n; i++) { out[i] /= L(i,i); } matPtr = solve2; for(s64 j = n; j --> 0;) { lhsPtr = out.data(); __m256 rhs = _mm256_set1_ps(out[j]); s64 i = 0; s64 vEnd = j - 8 * UNROLL_MATVEC; for(; i < vEnd; i += 8 * UNROLL_MATVEC) { for(s64 u = 0; u < UNROLL_MATVEC; u++) { __m256 mat = _mm256_loadu_ps(matPtr); __m256 lhs = _mm256_loadu_ps(lhsPtr); lhs = _mm256_fnmadd_ps(rhs, mat, lhs); _mm256_storeu_ps(lhsPtr, lhs); matPtr += 8; lhsPtr += 8; } } for(; i < j; i++) { *lhsPtr = *lhsPtr - *matPtr * out[j]; lhsPtr++; matPtr++; } } // O(n^2) loop 2 // finally, untranspose for(s64 i = n; i-->0;) { std::swap(out[pivots[i]], out[i]); } } #endif template class CholeskyDenseSolver<double>; template class CholeskyDenseSolver<float>;
918c2ce112e70beb52d5cd30b78bd2bdf328cb40
7dbad8f9f2269476c8883ae9c4e23d53d4e5bbda
/games/game_over/game_stats_2.cpp
1c8f93a6697a7ea225041138c89db902c81009c4
[]
no_license
Geschoss/beginning-c-plus-plus
422cf6c707eece4d3f33617d61a7d7c83b5351fb
a28806c29f308fe43df83cc290790a62ac6fb649
refs/heads/master
2022-03-09T18:28:11.657722
2022-01-22T09:25:31
2022-01-22T09:25:31
232,835,657
0
0
null
null
null
null
UTF-8
C++
false
false
701
cpp
game_stats_2.cpp
// Программа Game Stats 2.0 // Демонстрирует арифметические операции с переменными #include <iostream> using namespace std; int main() { unsigned int score = 5000; cout << "score: " << score << endl; // изменение значения переменной score = score + 100; cout << "score: " << score << endl; // комбинированный оператор присваивания score += 100; cout << "score: " << score << endl; // оператор инкремента int lives = 3; cout << "lives: " << lives++ << endl; cout << "lives: " << ++lives << endl; return 0; }
7ff53fad160e457d60ce22f52f47f5946cfe8e56
a6c929e04d6248dc46358e33e6de95dc77169e06
/Minigin/ColliderComponent.cpp
f69d3d3b3a00d1828c3088f7c591dc41e4ff8cdf
[]
no_license
StijnMaris/GameEngine-DigDug
ef3f010c598a78023ffa180fe7239cbceb808334
f025a1b77e2de53804b45611335d2054804f6928
refs/heads/master
2020-04-29T19:03:29.898193
2019-05-26T21:46:57
2019-05-26T21:46:57
176,342,545
0
0
null
null
null
null
UTF-8
C++
false
false
1,078
cpp
ColliderComponent.cpp
#include "MiniginPCH.h" #include "ColliderComponent.h" #include "GameObject.h" dae::ColliderComponent::ColliderComponent(std::shared_ptr<Transform> transform, SDL_Rect rect) :BaseComponent("ColliderComponent"), m_pTransformComponent(transform) { SetColliderRect(rect); } dae::ColliderComponent::~ColliderComponent() { } void dae::ColliderComponent::Update() { m_PrevPosition = m_pTransformComponent->GetPosition(); m_Collider.x = static_cast<int> (m_pTransformComponent->GetPosition().x); m_Collider.y = static_cast<int> (m_pTransformComponent->GetPosition().y); } void dae::ColliderComponent::SetColliderRect(SDL_Rect rect) { m_Collider = rect; m_Collider.w = int(static_cast<float>(m_Collider.w) * m_pTransformComponent->GetScale().x); m_Collider.h = int(static_cast<float>(m_Collider.h) * m_pTransformComponent->GetScale().y); m_Collider.x = static_cast<int> (m_pTransformComponent->GetPosition().x); m_Collider.y = static_cast<int> (m_pTransformComponent->GetPosition().y); m_Collider.x -= int(m_Collider.w * 0.5f); m_Collider.y -= int(m_Collider.h * 0.5f); }
771724e956ed5b00b603e5a90eeaa96e2eb25f7d
f4e854b53e2da2f6e4d5ed5e76911281577efb29
/zad3-zalazek/src/main.cpp
d7c6cb6d60d55a810ac6931c177f8f80fac29b75
[]
no_license
Marcel129/Uklad_rownan_liniowych
4078bde6299d6525c53a29db1b4a99305ede4346
b5d0a086d2bd032651f251c05dc0e97e737abf39
refs/heads/master
2021-04-16T16:58:30.760416
2020-04-19T20:52:34
2020-04-19T20:52:34
249,371,664
0
0
null
null
null
null
UTF-8
C++
false
false
752
cpp
main.cpp
#include <iostream> #include "Wektor.hh" #include "Macierz.hh" #include "UkladRownanLiniowych.hh" #include "rozmiar.h" using namespace std; int main(int argc, char **argv) { if (argc < 2) { cout << endl; cout << "Nie wskazano pliku z bazą danych." << endl; exit(1); } fstream baza_pytan; baza_pytan.open(argv[1], ios::in); if (baza_pytan.good() == false) { cout << "Błąd otwarcia pliku. Koniec działania programu" << endl; exit(1); } cout << endl << " Start programu " << endl << endl; UkladRownanLiniowych UklRown; baza_pytan >> UklRown; UklRown.Oblicz(); cout << UklRown << endl << endl; cout << "Błąd obliczeń wynosi: " << UklRown.Blad() << endl << endl; }
95fe05cffaf659c64741dadecf56315d50149a06
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_1674486_1/C++/isti757/DiamondInheritance.cpp
c5275b0d3d508a596976405c01754dc006c291a6
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
1,216
cpp
DiamondInheritance.cpp
#include <vector> #include <stdio.h> #include <string> #include <iostream> #include <algorithm> #include <numeric> using namespace std; bool bfs(vector<vector<int> > &edges, vector<bool> &vis, int n) { if(vis[n]) { return true; } else { vis[n] = true; for(int i = 0; i < edges[n].size(); i++) { if(bfs(edges, vis, edges[n][i])) return true; } return false; } } int main() { int T; cin >> T; for(int TT = 1; TT <= T; TT++) { int N; cin >> N; vector<vector<int> > edges(N, vector<int>()); for(int i = 0; i < N; i++) { int M; cin >> M; for(int j = 0; j < M; j++) { int V; cin >> V; edges[V-1].push_back(i); } } bool exists = false; for(int i = 0; i < N; i++) { vector<bool> vis(N, 0); if(bfs(edges, vis, i)) { exists = true; break; } } if(exists) { printf("Case #%d: Yes\n", TT); } else { printf("Case #%d: No\n", TT); } } return 0; }
b91d81201886154b1908377afe7fa7eb636f1983
fdfeb3da025ece547aed387ad9c83b34a28b4662
/Simple/CCore/inc/Timer.h
f70550d2839119f2db240114ce9c87e33992a300
[ "FTL", "BSL-1.0" ]
permissive
SergeyStrukov/CCore-3-xx
815213a9536e9c0094548ad6db469e62ab2ad3f7
820507e78f8aa35ca05761e00e060c8f64c59af5
refs/heads/master
2021-06-04T05:29:50.384520
2020-07-04T20:20:29
2020-07-04T20:20:29
93,891,835
8
1
null
null
null
null
UTF-8
C++
false
false
1,821
h
Timer.h
/* Timer.h */ //---------------------------------------------------------------------------------------- // // Project: CCore 3.00 // // Tag: Simple Mini // // License: Boost Software License - Version 1.0 - August 17th, 2003 // // see http://www.boost.org/LICENSE_1_0.txt or the local copy // // Copyright (c) 2015 Sergey Strukov. All rights reserved. // //---------------------------------------------------------------------------------------- #ifndef CCore_inc_Timer_h #define CCore_inc_Timer_h #include <CCore/inc/Gadget.h> #include <CCore/inc/sys/SysTime.h> namespace CCore { /* classes */ template <UIntType T,T Time()> class Timer; template <UIntType T,T Time()> class DiffTimer; /* class Timer<T,T Time()> */ template <UIntType T,T Time()> class Timer { T start; public: Timer() { reset(); } void reset() { start=Time(); } using ValueType = T ; T get() const { return Time()-start; } bool less(T lim) const { return get()<lim; } bool exceed(T lim) const { return get()>=lim; } void shift(T delta) { start+=delta; } static T Get() { return Time(); } }; /* class DiffTimer<T,T Time()> */ template <UIntType T,T Time()> class DiffTimer { T prev; public: DiffTimer() { reset(); } void reset() { prev=Time(); } using ValueType = T ; T get() { return Diff(prev,Time()); } }; /* timer types */ using MSecTimer = Timer<Sys::MSecTimeType,Sys::GetMSecTime> ; using SecTimer = Timer<Sys::SecTimeType,Sys::GetSecTime> ; using ClockTimer = Timer<Sys::ClockTimeType,Sys::GetClockTime> ; using MSecDiffTimer = DiffTimer<Sys::MSecTimeType,Sys::GetMSecTime> ; using SecDiffTimer = DiffTimer<Sys::SecTimeType,Sys::GetSecTime> ; using ClockDiffTimer = DiffTimer<Sys::ClockTimeType,Sys::GetClockTime> ; } // namespace CCore #endif
0d2278f7752714b73f1d00b201ef5065257d4bb5
8741a8e1fa4c910f47c1246fd11411fa36029578
/MySolution/Project/Tool/Pdbt_Common.h
290bc4c9f41ed8233278171d30621a0f14e11e9a
[]
no_license
liwenlang/MyMFC
36b38198908c712fa366b24baeefa0f70825d874
2fb1ccddbdd57de8585f55adc486859e240532a5
refs/heads/master
2023-02-26T01:08:09.172756
2021-01-27T09:19:22
2021-01-27T09:19:22
268,955,339
0
0
null
null
null
null
GB18030
C++
false
false
1,309
h
Pdbt_Common.h
#pragma once #include "Source/Pdbt_Db_Connect.h" /** * @brief 该模块的公用 常量和函数定义 * * * @author liwenlang * @version v1.0 * @date [2012-7-30] * @note */ namespace pmdbtool { const CString g_strComParamSet_Total = _T("施工安全参数(全国)") ; const CString g_strComParamSet_Global = _T("绘制顺序") ; enum TableIndex { eComParamSet_Total = 1 , eDrawIndex = 2 , eDefaultSheet = 1 , /// 默认操作第一页 }; enum { eMaxColIndex = 20 , /// 最大列 }; /// enum { /// } ; inline int GetTableIndex( const CString & strTable ) { if ( strTable.Compare(g_strComParamSet_Total) == 0 ) { return eComParamSet_Total ; } else if ( strTable.Compare(g_strComParamSet_Global) == 0 ) { return eDrawIndex; } } class CTestClock { public: CTestClock( const CString & strHintInfo = _T("") ) : m_strHintInfo( strHintInfo ) { m_dwBegin = GetTickCount() ; } ~CTestClock() { DWORD dwEnd = GetTickCount() ; DWORD dwSpan = dwEnd - m_dwBegin ; CString strMsg; strMsg.Format(_T("%d"), (int)dwSpan); CDataSetErrorInfo::Instance()->PrintInfo( m_strHintInfo + strMsg , 0 ); } private: DWORD m_dwBegin ; CString m_strHintInfo ; }; } ; #define Db_Opr CDbConnect::Instance()
25fd70eeb5d63845b14b2d121eb4defe45ad39bd
3b526f8b3b699818434a45a64f2ab149b0088156
/main.cpp
a60f2f46b68754a781403f3cc06332139c5bc272
[]
no_license
Ariionex/Database
f2cc535539e7a59e10b559a9b282161abe0d9e74
c3cfc5ea169614ab03e1d31f3b57b962546c43f2
refs/heads/master
2020-04-23T11:31:56.145541
2019-03-10T09:59:40
2019-03-10T09:59:40
171,139,587
0
0
null
null
null
null
UTF-8
C++
false
false
981
cpp
main.cpp
#include <iostream> #include "Student.hpp" #include "Database.hpp" using namespace std; int main() { Database db; Person* jan = new Student("Jan","Kowalski","Fiolkowa 5","1234567890",Gender::male,166666); db.addStudent(jan); Person* adam = new Student("Adam","Adamski","Dziwna 10","0987654321",Gender::male,222222); db.addStudent(adam); Person* krzysztof = new Student("Krzysztof","Jarzyna","Szczecinska 11","1987654320",Gender::male,333222); db.addStudent(krzysztof); Person* lucyfer = new Student("Lucyfer","Podolski","Szczesliwej 666","8887654320",Gender::male,333444); db.addStudent(lucyfer); Person* baltazar = new Student("Baltazar","Smith","Kowalowa 77","2987654320",Gender::male,336722); db.addStudent(baltazar); db.sortByIndex(); db.show(); cout<<endl; db.removeByPesel("8887654320"); db.sortByLastname(); db.save("Baza_danych.txt"); db.load("Baza_danych.txt"); db.show(); return 0; }
61a3d4b4298f3522490c870a14c30b5cc4523c78
e9786f00a5f9e59f1604f405bba535104926439f
/Framework/Sources/o2/Scene/ISceneDrawable.h
38eee5b802a42c7828e41aa6677ce9a17ce121ae
[ "MIT" ]
permissive
brucelevis/o2
0953532f270736c5b3fbb31fabc0ab72f1ddf8d0
29085e7c3ba86a54aacfada666adea755ea7b1ee
refs/heads/master
2023-09-02T04:48:48.716244
2021-11-07T17:07:30
2021-11-07T17:07:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,207
h
ISceneDrawable.h
#pragma once #include "o2/Render/IDrawable.h" #include "o2/Utils/Property.h" #include "o2/Utils/Serialization/Serializable.h" #if IS_EDITOR #include "o2/Utils/Editor/SceneEditableObject.h" #endif namespace o2 { class SceneLayer; // ------------------------------------------------------------------ // Scene drawable object. Has virtual draw function and sorting depth // Depth shows how later object will be drawn // ------------------------------------------------------------------ class ISceneDrawable: virtual public ISerializable, public IDrawable { public: PROPERTIES(ISceneDrawable); PROPERTY(float, drawDepth, SetDrawingDepth, GetSceneDrawableDepth); // Drawing depth property. Objects with higher depth will be drawn later public: // Default constructor ISceneDrawable(); // Copy-constructor ISceneDrawable(const ISceneDrawable& other); // Destructor ~ISceneDrawable(); // Copy operator ISceneDrawable& operator=(const ISceneDrawable& other); // Draws content void Draw() override; // Sets drawing depth. Objects with higher depth will be drawn later virtual void SetDrawingDepth(float depth); // Returns drawing depth float GetSceneDrawableDepth() const; // Sets this drawable as last drawing object in layer with same depth void SetLastOnCurrentDepth(); SERIALIZABLE(ISceneDrawable); protected: float mDrawingDepth = 0.0f; // Drawing depth. Objects with higher depth will be drawn later @SERIALIZABLE protected: // Returns current scene layer virtual SceneLayer* GetSceneDrawableSceneLayer() const { return nullptr; } // Returns is drawable enabled virtual bool IsSceneDrawableEnabled() const { return false; } // Is is called when drawable has enabled void OnEnabled(); // Is is called when drawable has enabled void OnDisabled(); // It is called when actor was included to scene void OnAddToScene(); // It is called when actor was excluded from scene void OnRemoveFromScene(); friend class Scene; friend class SceneLayer; #if IS_EDITOR public: // Returns pointer to owner editable object virtual SceneEditableObject* GetEditableOwner(); // It is called when drawable was drawn. Storing render scissor rect, calling onDraw callback, adding in drawnEditableObjects void OnDrawn() override; #endif }; } CLASS_BASES_META(o2::ISceneDrawable) { BASE_CLASS(o2::ISerializable); BASE_CLASS(o2::IDrawable); } END_META; CLASS_FIELDS_META(o2::ISceneDrawable) { FIELD().NAME(drawDepth).PUBLIC(); FIELD().SERIALIZABLE_ATTRIBUTE().DEFAULT_VALUE(0.0f).NAME(mDrawingDepth).PROTECTED(); } END_META; CLASS_METHODS_META(o2::ISceneDrawable) { PUBLIC_FUNCTION(void, Draw); PUBLIC_FUNCTION(void, SetDrawingDepth, float); PUBLIC_FUNCTION(float, GetSceneDrawableDepth); PUBLIC_FUNCTION(void, SetLastOnCurrentDepth); PROTECTED_FUNCTION(SceneLayer*, GetSceneDrawableSceneLayer); PROTECTED_FUNCTION(bool, IsSceneDrawableEnabled); PROTECTED_FUNCTION(void, OnEnabled); PROTECTED_FUNCTION(void, OnDisabled); PROTECTED_FUNCTION(void, OnAddToScene); PROTECTED_FUNCTION(void, OnRemoveFromScene); PUBLIC_FUNCTION(SceneEditableObject*, GetEditableOwner); PUBLIC_FUNCTION(void, OnDrawn); } END_META;
b203d67f92c470abb8c9e9f9f7ccd462f10ceb67
e837d14a409a8e64aa73013588edceb24a054131
/types/includes/schema_common.h
2b2575c132231a8c748fbbd5405134913565e4db
[ "Apache-2.0" ]
permissive
subhagho/ReactFS
9c6f467fb82706965a24a37c8eae741360d2b2d2
d8b7cab144ca104abda2a7abb5bbf510e4185738
refs/heads/master
2021-01-12T15:25:34.052691
2017-03-16T06:06:26
2017-03-16T06:06:26
71,780,597
3
1
null
2017-01-16T05:36:58
2016-10-24T11:05:59
C++
UTF-8
C++
false
false
25,866
h
schema_common.h
/* * Copyright [2016] [Subhabrata Ghosh] * * 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. * */ // // Created by Subhabrata Ghosh on 15/12/16. // #ifndef REACTFS_SCHEMA_COMMON_H #define REACTFS_SCHEMA_COMMON_H #include "common/includes/common.h" #include "common/includes/log_utils.h" #include "core/includes/core.h" using namespace REACTFS_NS_COMMON_PREFIX; REACTFS_NS_CORE namespace types { /*! * Singleton utility class for managing data type IO handlers. * * Native type handlers are automatically added. Other type handlers * should be added externally. * * Note:: Needs to be disposed prior to application existing. */ class __type_defs_utils { private: /// Thread lock mutex for creating handlers. static mutex thread_mutex; /// Static map of the registered data type IO handlers. static unordered_map<string, __base_datatype_io *> type_handlers; /*! * Create a new instance of the IO handler. * * @param type - Datatype enum * @return - Datatype IO handler */ static __base_datatype_io *create_type_handler(__type_def_enum type) { lock_guard<std::mutex> lock(thread_mutex); string type_n = __type_enum_helper::get_type_string(type); unordered_map<string, __base_datatype_io *>::iterator iter = type_handlers.find(type_n); if (iter != type_handlers.end()) { return nullptr; } __base_datatype_io *t = nullptr; switch (type) { case __type_def_enum::TYPE_BYTE: t = new __dt_byte(); CHECK_ALLOC(t, TYPE_NAME(__dt_byte)); break; case __type_def_enum::TYPE_CHAR: t = new __dt_char(); CHECK_ALLOC(t, TYPE_NAME(__dt_char)); break; case __type_def_enum::TYPE_DOUBLE: t = new __dt_double(); CHECK_ALLOC(t, TYPE_NAME(__dt_double)); break; case __type_def_enum::TYPE_FLOAT: t = new __dt_float(); CHECK_ALLOC(t, TYPE_NAME(__dt_float)); break; case __type_def_enum::TYPE_INTEGER: t = new __dt_int(); CHECK_ALLOC(t, TYPE_NAME(__dt_int)); break; case __type_def_enum::TYPE_LONG: t = new __dt_long(); CHECK_ALLOC(t, TYPE_NAME(__dt_long)); break; case __type_def_enum::TYPE_SHORT: t = new __dt_short(); CHECK_ALLOC(t, TYPE_NAME(__dt_short)); break; case __type_def_enum::TYPE_STRING: t = new __dt_string(); CHECK_ALLOC(t, TYPE_NAME(__dt_string)); break; case __type_def_enum::TYPE_STRUCT: t = new __dt_byte(); CHECK_ALLOC(t, TYPE_NAME(__dt_byte)); break; case __type_def_enum::TYPE_TEXT: t = new __dt_text(); CHECK_ALLOC(t, TYPE_NAME(__dt_text)); break; case __type_def_enum::TYPE_TIMESTAMP: t = new __dt_timestamp(); CHECK_ALLOC(t, TYPE_NAME(__dt_timestamp)); break; case __type_def_enum::TYPE_BOOL: t = new __dt_bool(); CHECK_ALLOC(t, TYPE_NAME(__dt_bool)); break; case __type_def_enum::TYPE_DATETIME: t = new __dt_datetime(); CHECK_ALLOC(t, TYPE_NAME(__dt_datetime)); break; default: throw BASE_ERROR("Type not supported as basic type handler. [type=%s]", __type_enum_helper::get_type_string(type).c_str()); } return t; } public: static string create_list_key(__type_def_enum type, __type_def_enum inner_type) { return common_utils::format("%s::%s", __type_enum_helper::get_type_string(type).c_str(), __type_enum_helper::get_type_string(inner_type).c_str()); } static string create_map_key(__type_def_enum type, __type_def_enum key_type, __type_def_enum value_type) { return common_utils::format("%s::%s::%s", __type_enum_helper::get_type_string(type).c_str(), __type_enum_helper::get_type_string(key_type).c_str(), __type_enum_helper::get_type_string(value_type).c_str()); } /*! * Get the datatype IO handler for the specified datatype enum. * * Note: Only valid inner type datatype handlers are auto-created, others should be * added explicitly. * * @param type - Datatype enum * @return - Datatype IO handler */ static __base_datatype_io *get_type_handler(__type_def_enum type) { string type_n = __type_enum_helper::get_type_string(type); unordered_map<string, __base_datatype_io *>::iterator iter = type_handlers.find(type_n); if (iter != type_handlers.end()) { return iter->second; } else { if (__type_enum_helper::is_native(type) || type == __type_def_enum::TYPE_TEXT) { // If not available and native type, create a new instance. __base_datatype_io *ptr = create_type_handler(type); if (IS_NULL(ptr)) { // Another thread should have added this type handler. iter = type_handlers.find(type_n); if (iter != type_handlers.end()) { return iter->second; } } else { type_handlers.insert({type_n, ptr}); return ptr; } } } return nullptr; } /*! * Get the datatype IO handler for the specified datatype key. * * Note: Only valid inner type datatype handlers are auto-created, others should be * added explicitly. * * @param type - Datatype enum * @return - Datatype IO handler */ static __base_datatype_io *get_type_handler(string &key) { CHECK_NOT_EMPTY(key); unordered_map<string, __base_datatype_io *>::iterator iter = type_handlers.find(key); if (iter != type_handlers.end()) { return iter->second; } return nullptr; } /*! * Add a non-native IO handler that was instantiated externally. * * * @param key - String key for array/list/map types * @param handler - Handler instance. * @return - Has been added? Will return false if handler already registered. */ static bool add_external_handler(string &key, __base_datatype_io *handler) { CHECK_NOT_NULL(handler); CHECK_NOT_EMPTY(key); lock_guard<std::mutex> lock(thread_mutex); unordered_map<string, __base_datatype_io *>::iterator iter = type_handlers.find(key); if (iter != type_handlers.end()) { return false; } type_handlers.insert({key, handler}); return true; } /*! * Add a non-native IO handler that was instantiated externally. * * * @param type - Datatype enum * @param handler - Handler instance. * @return - Has been added? Will return false if handler already registered. */ static bool add_external_handler(__type_def_enum type, __base_datatype_io *handler) { CHECK_NOT_NULL(handler); lock_guard<std::mutex> lock(thread_mutex); string type_n = __type_enum_helper::get_type_string(type); unordered_map<string, __base_datatype_io *>::iterator iter = type_handlers.find(type_n); if (iter != type_handlers.end()) { return false; } type_handlers.insert({type_n, handler}); return true; } /*! * Dispose all the registered instances of the IO handlers. */ static void dispose() { lock_guard<std::mutex> lock(thread_mutex); unordered_map<string, __base_datatype_io *>::iterator iter; for (iter = type_handlers.begin(); iter != type_handlers.end(); iter++) { CHECK_AND_FREE(iter->second); } type_handlers.clear(); } }; /*! * Absract base class for defining type constraints. */ class __constraint { protected: bool is_not = false; public: /*! * Virtual base desctructor. */ virtual ~__constraint() {} /*! * Validate the data by applying this constraint instance. * * @param value - Data value to validate * @return - Constraint passed? */ virtual bool validate(const void *value) const = 0; /*! * Write (serialize) this constraint instance. * * @param buffer - Output buffer to write the constraint to. * @param offset - Offset in the buffer to start writing. * @return - Number of byte written. */ virtual uint32_t write(void *buffer, uint64_t offset) = 0; /*! * Read (de-serialize) the constraint instance. * * @param buffer - Input buffer to read data from. * @param offset - Offset in the input buffer to read from. * @return - Number of bytes consumed. */ virtual uint32_t read(void *buffer, uint64_t offset) = 0; /*! * Get the datatype enum that this constraint instance supports. * * @return - Supported datatype enum. */ virtual __type_def_enum get_datatype() = 0; /*! * Set if this constraint should return the negative of the constraint definition. * * @param is_not - Should be reversed? */ void set_not(bool is_not) { this->is_not = is_not; } /*! * Utility function to print the definition of this constraint. */ virtual void print() const = 0; }; /*! * Abstract base class for defining default values. */ class __default { protected: /// Datatype IO handler. __base_datatype_io *handler = nullptr; public: /*!<destructor * Base virtual destructor. */ virtual ~__default() { } /*! * Write (serialize) this default value instance. * * @param buffer - Output buffer to write the constraint to. * @param offset - Offset in the buffer to start writing. * @return - Number of byte written. */ virtual uint32_t write(void *buffer, uint64_t offset) = 0; /*! * Read (de-serialize) the default value instance. * * @param buffer - Input buffer to read data from. * @param offset - Offset in the input buffer to read from. * @return - Number of bytes consumed. */ virtual uint32_t read(void *buffer, uint64_t offset) = 0; /*! * Get the datatype enum that this default value instance supports. * * @return - Supported datatype enum. */ virtual __type_def_enum get_datatype() = 0; /*! * Get the default value. * * @return - Value pointer. */ virtual const void *get_default() const = 0; /*! * Utility function to print the definition of this constraint. */ virtual void print() const = 0; }; /*! * Template base class for defining typed default value instances. * * @tparam __T - Datatype of the value. * @tparam __type - Datatype enum of the value. */ template<typename __T, __type_def_enum __type> class __typed_default : public __default { protected: /// Datatype enum of the value. __type_def_enum datatype = __type; /// Typed default value __T value; public: /*!<constructor * Default empty constructor. */ __typed_default() { PRECONDITION(__type_enum_helper::is_native(datatype)); handler = __type_defs_utils::get_type_handler(this->datatype); CHECK_NOT_NULL(handler); } /*! * Get the default value. * * @return - Typed default value. */ const __T get_value() const { CHECK_NOT_NULL(value); return value; } /*! * Set the default value. * * @param value - Typed default value. */ void set_value(__T value) { this->value = value; } virtual const void *get_default() const override { return &this->value; } /*! * Get the datatype enum of the supported value type. * * @return - Supported datatype enum. */ __type_def_enum get_datatype() override { return this->datatype; } /*! * Write (serialize) this default value instance. * * @param buffer - Output buffer to write the constraint to. * @param offset - Offset in the buffer to start writing. * @return - Number of byte written. */ uint32_t write(void *buffer, uint64_t offset) override { CHECK_NOT_NULL(buffer); CHECK_NOT_NULL(handler); return handler->write(buffer, &value, offset, ULONG_MAX); } /*! * Read (de-serialize) the default value instance. * * @param buffer - Input buffer to read data from. * @param offset - Offset in the input buffer to read from. * @return - Number of bytes consumed. */ uint32_t read(void *buffer, uint64_t offset) override { CHECK_NOT_NULL(buffer); CHECK_NOT_NULL(handler); __T *t = nullptr; uint64_t r_size = handler->read(buffer, &t, offset, ULONG_MAX); CHECK_NOT_NULL(t); this->value = *t; return r_size; } virtual void print() const override { string t = __type_enum_helper::get_type_string(this->datatype); string v = __type_enum_helper::get_string_value(&value, this->datatype); LOG_DEBUG("\t[type=%s] value='%s'", t.c_str(), v.c_str()); } }; typedef __typed_default<char, __type_def_enum::TYPE_CHAR> __default_char; typedef __typed_default<bool, __type_def_enum::TYPE_BOOL> __default_bool; typedef __typed_default<short, __type_def_enum::TYPE_SHORT> __default_short; typedef __typed_default<int, __type_def_enum::TYPE_INTEGER> __default_int; typedef __typed_default<long, __type_def_enum::TYPE_LONG> __default_long; typedef __typed_default<uint64_t, __type_def_enum::TYPE_TIMESTAMP> __default_timestamp; typedef __typed_default<float, __type_def_enum::TYPE_FLOAT> __default_float; typedef __typed_default<double, __type_def_enum::TYPE_DOUBLE> __default_double; class __default_string : public __typed_default<char *, __type_def_enum::TYPE_STRING> { public: __default_string() { this->value = nullptr; } void set_value(string &value) { FREE_PTR(this->value); if (!IS_EMPTY(value)) { uint32_t size = value.length() + 1; this->value = (char *) malloc(sizeof(char) * size); CHECK_ALLOC(this->value, TYPE_NAME(char)); memset(this->value, 0, size); memcpy(this->value, value.c_str(), value.length()); } } /*! * Write (serialize) this default value instance. * * @param buffer - Output buffer to write the constraint to. * @param offset - Offset in the buffer to start writing. * @return - Number of byte written. */ uint32_t write(void *buffer, uint64_t offset) override { CHECK_NOT_NULL(buffer); CHECK_NOT_NULL(handler); return handler->write(buffer, value, offset, ULONG_MAX); } /*! * Read (de-serialize) the default value instance. * * @param buffer - Input buffer to read data from. * @param offset - Offset in the input buffer to read from. * @return - Number of bytes consumed. */ uint32_t read(void *buffer, uint64_t offset) override { CHECK_NOT_NULL(buffer); CHECK_NOT_NULL(handler); char *t = nullptr; uint64_t r_size = handler->read(buffer, &t, offset, ULONG_MAX); CHECK_NOT_NULL(t); this->value = t; return r_size; } virtual const void *get_default() const override { CHECK_NOT_NULL(this->value); return this->value; } virtual void print() const override { string t = __type_enum_helper::get_type_string(this->datatype); if (NOT_NULL(this->value) && strlen(this->value) > 0) { LOG_DEBUG("\t[type=%s] value='%s'", t.c_str(), this->value); } else { LOG_ERROR("\t[type=%s] value=NULL", t.c_str()); } } }; } REACTFS_NS_CORE_END #endif //REACTFS_SCHEMA_COMMON_H
ce0e595e854d472ad7758ea0b981dfb7a4c6aa3a
3f22b88662bd1ae5962b3d6734d5ecfa75d5c2c9
/Classes/SettingsScene.cpp
bc54508a949969f3812fea349d2c20e586762580
[]
no_license
INTO250/Block_X_Breaker
d10657450baec4c4c5b4b5a9a87000c4672bd3d7
5629c8eedf2700536013d3f7874575cfe3ba7c80
refs/heads/main
2023-05-30T21:20:41.241946
2021-06-20T09:27:13
2021-06-20T09:27:13
363,011,371
1
2
null
2021-06-18T02:09:01
2021-04-30T03:05:28
C++
GB18030
C++
false
false
4,589
cpp
SettingsScene.cpp
#include "MenuScene.h" #include "SettingsScene.h" #include "AudioEngine.h" USING_NS_CC; extern int BGM; extern float volumeSound; std::string IPAddr = "192.168.224.76"; #define BG_HEIGHT 1404 cocos2d::Scene* SettingsScene::createScene() { return SettingsScene::create(); } bool SettingsScene::init() { if (!Scene::init()) { return false; } auto visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); background_1 = Sprite::create("background.jpg"); background_2 = Sprite::create("background.jpg"); //用两张背景图来实现背景滚动的效果 background_1->setAnchorPoint(Vec2(0, 0)); background_2->setAnchorPoint(Vec2(0, 0)); background_1->setPosition(Vec2(0, 0)); background_2->setPosition(Vec2(0, BG_HEIGHT)); this->addChild(background_1, -5); this->addChild(background_2, -5); auto closeButton = MenuItemImage::create("close_button.png", "close_button_selected.png", CC_CALLBACK_1(SettingsScene::backToMenu, this)); auto closeButtonMenu = Menu::create(closeButton, NULL); closeButtonMenu->setAnchorPoint(Vec2(0, 1)); closeButtonMenu->setPosition(Vec2(50, visibleSize.height - 50)); this->addChild(closeButtonMenu); musicSlider = ui::Slider::create(); musicSlider->loadBarTexture("slider_back.png"); musicSlider->loadSlidBallTextures("slider_node.png", "slider_node.png", "slider_node.png"); musicSlider->loadProgressBarTexture("slider_front.png"); musicSlider->setPercent(AudioEngine::getVolume(BGM) * 100); musicSlider->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 + 50)); musicSlider->addEventListener(CC_CALLBACK_2(SettingsScene::onMusicSliderMoved, this)); this->addChild(musicSlider); auto musicLabel = Label::createWithTTF("Music","fonts/Marker Felt.ttf", 48); musicLabel->setTextColor(Color4B::WHITE); musicLabel->setPosition(Vec2(visibleSize.width / 2 , visibleSize.height / 2 + 150)); this->addChild(musicLabel); soundSlider = ui::Slider::create(); soundSlider->loadBarTexture("slider_back.png"); soundSlider->loadSlidBallTextures("slider_node.png", "slider_node.png", "slider_node.png"); soundSlider->loadProgressBarTexture("slider_front.png"); soundSlider->setPercent(volumeSound * 100); soundSlider->setPosition(Vec2(visibleSize.width / 2 , visibleSize.height / 2 - 150)); soundSlider->addEventListener(CC_CALLBACK_2(SettingsScene::onSoundSliderMoved, this)); this->addChild(soundSlider); auto soundLabel = Label::createWithTTF("Sound", "fonts/Marker Felt.ttf", 48); soundLabel->setTextColor(Color4B::WHITE); soundLabel->setPosition(Vec2(visibleSize.width / 2 , visibleSize.height / 2 - 50)); this->addChild(soundLabel); IP = ui::TextField::create(); IP->setMaxLength(30); IP->setColor(Color3B::WHITE); IP->setFontSize(48); IP->setFontName("fonts/Marker Felt.ttf"); IP->setString(IPAddr); IP->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 - 450)); this->addChild(IP); auto IPLabel = Label::createWithTTF("IP Address", "fonts/Marker Felt.ttf", 48); IPLabel->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 - 375)); IPLabel->setColor(Color3B::WHITE); this->addChild(IPLabel); this->scheduleUpdate(); return true; } void SettingsScene::backToMenu(cocos2d::Ref* pSender) { IPAddr = IP->getString(); auto sound = AudioEngine::play2d("sound_click.mp3", false, volumeSound); Director::getInstance()->replaceScene(TransitionFade::create(2.0f, MenuScene::createScene())); } void SettingsScene::update(float dt) { background_1->setPositionY(background_1->getPositionY() - 1); background_2->setPositionY(background_2->getPositionY() - 1); if (background_1->getPositionY() < -BG_HEIGHT) { background_1->setPositionY(BG_HEIGHT); } if (background_2->getPositionY() < -BG_HEIGHT) { background_2->setPositionY(BG_HEIGHT); } } void SettingsScene::onMusicSliderMoved(Ref* pSender, ui::Slider::EventType type) { switch (type) { case ui::Slider::EventType::ON_PERCENTAGE_CHANGED: AudioEngine::setVolume(BGM, musicSlider->getPercent() / 100.0f); break; } } void SettingsScene::onSoundSliderMoved(Ref* pSender, ui::Slider::EventType type) { switch (type) { case ui::Slider::EventType::ON_PERCENTAGE_CHANGED: volumeSound = soundSlider->getPercent() / 100.0f; break; } }
4ddbb3419e2eed57d687f7ede74ef7549c8fac7d
b01299f1d8972949863b3862ac6b83da580d443f
/lib/curl/test/webkit-inspector.cpp
d62f1ead8729a23ce92b6ebad80d87c27e688771
[]
no_license
neophytos-sk/phigita-star
daf170f29212f601270c8182ffb1835163485efe
dd48dc5f5768acb199c3ee2866d01efb4ef98f8a
refs/heads/master
2021-01-25T10:21:12.039782
2016-02-24T09:50:28
2016-02-24T09:50:28
35,161,947
3
2
null
2023-03-20T11:47:34
2015-05-06T14:01:52
HTML
UTF-8
C++
false
false
1,094
cpp
webkit-inspector.cpp
/* * ===================================================================================== * * Filename: webkit-inspector.cpp * * Description: * * Version: 1.0 * Created: 02/12/2014 09:28:23 AM * Revision: none * Compiler: gcc * * Author: Neophytos Demetriou (), * Organization: * * ===================================================================================== */ #include <QtGui/QApplication> #include <QtWebKit/QWebInspector> #include <QtWebKit/QGraphicsWebView> #include "html5applicationviewer.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); Html5ApplicationViewer viewer; viewer.setOrientation(Html5ApplicationViewer::ScreenOrientationAuto); viewer.showExpanded(); viewer.webView()->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true); QWebInspector inspector; inspector.setPage(viewer.webView()->page()); inspector.setVisible(true); viewer.loadFile(QLatin1String("html/index.html")); return app.exec(); }
6518f3038e96a782b5228ed565360d035b88ff20
6f224b734744e38062a100c42d737b433292fb47
/libc/src/unistd/unlink.h
1119bfad7dbc533510e9e9993c7744472475f98c
[ "NCSA", "LLVM-exception", "Apache-2.0" ]
permissive
smeenai/llvm-project
1af036024dcc175c29c9bd2901358ad9b0e6610e
764287f1ad69469cc264bb094e8fcdcfdd0fcdfb
refs/heads/main
2023-09-01T04:26:38.516584
2023-08-29T21:11:41
2023-08-31T22:16:12
216,062,316
0
0
Apache-2.0
2019-10-18T16:12:03
2019-10-18T16:12:03
null
UTF-8
C++
false
false
571
h
unlink.h
//===-- Implementation header for unlink ------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_LIBC_SRC_UNISTD_UNLINK_H #define LLVM_LIBC_SRC_UNISTD_UNLINK_H namespace __llvm_libc { int unlink(const char *path); } // namespace __llvm_libc #endif // LLVM_LIBC_SRC_UNISTD_UNLINK_H
31c637fa8025c2eff21924567ce699213c1587b2
37ffd116535acab191da2b4c62dfd58868f8287b
/palindrome_number/solution.cpp
65471a66699ceca91e18a3f9b0c37c34de24e7bf
[]
no_license
huwenboshi/leetcode_exercises
c1a494dd4452d2644d21d7bb337f8b268508df17
73bb1741070b50b7729afe7e2edb79d224b2a6d4
refs/heads/master
2019-06-24T14:20:27.149089
2016-08-30T06:43:08
2016-08-30T06:43:08
66,914,041
1
0
null
null
null
null
UTF-8
C++
false
false
901
cpp
solution.cpp
#include <iostream> using namespace std; class Solution { public: bool isPalindrome(int xin) { long long int x = xin; if(x < 0) { return false; } long long int x_tmp = x; long long int num_digit = 0; while(x_tmp > 0) { x_tmp /= 10; num_digit++; } long long int pow = 1; for(int i=0; i<num_digit-1; i++) { pow *= 10; } for(int i=0; i<num_digit/2; i++) { int digit_low = x % 10; int digit_high = x/pow; if(digit_low != digit_high) { return false; } x = (x-digit_high*pow-digit_low)/10; pow /= 100; } return true; } }; int main() { Solution sol; //cout << sol.isPalindrome(5521255) << endl; cout << sol.isPalindrome(-2147483648) << endl; }
594738b9ba3f7cb1f1a26c240dfb475c3db74ad4
b65db772bb0d59bb9f21f77f048ad3e09cfb75ec
/DX12Lib/src/UnorderedAccessView.cpp
e5883aa5913e823b7f9cb2c88b31960be04dbe1e
[ "MIT" ]
permissive
jpvanoosten/LearningDirectX12
8a0cadd4e72f5da8d79fe25dc1febaedbe09bf41
49eb021f6a6f538e3b6001fd8f9b7108d2900751
refs/heads/main
2023-08-07T16:53:45.507006
2023-04-26T11:47:45
2023-04-26T11:47:45
101,299,944
531
89
MIT
2021-01-22T15:06:50
2017-08-24T13:49:45
CMake
UTF-8
C++
false
false
1,379
cpp
UnorderedAccessView.cpp
#include "DX12LibPCH.h" #include <dx12lib/UnorderedAccessView.h> #include <dx12lib/Device.h> #include <dx12lib/Resource.h> using namespace dx12lib; UnorderedAccessView::UnorderedAccessView( Device& device, const std::shared_ptr<Resource>& resource, const std::shared_ptr<Resource>& counterResource, const D3D12_UNORDERED_ACCESS_VIEW_DESC* uav ) : m_Device( device ) , m_Resource( resource ) , m_CounterResource( counterResource ) { assert( m_Resource || uav ); auto d3d12Device = m_Device.GetD3D12Device(); auto d3d12Resource = m_Resource ? m_Resource->GetD3D12Resource() : nullptr; auto d3d12CounterResource = m_CounterResource ? m_CounterResource->GetD3D12Resource() : nullptr; if ( m_Resource ) { auto d3d12ResourceDesc = m_Resource->GetD3D12ResourceDesc(); // Resource must be created with the D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS flag. assert( ( d3d12ResourceDesc.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ) != 0 ); } m_Descriptor = m_Device.AllocateDescriptors( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ); d3d12Device->CreateUnorderedAccessView( d3d12Resource.Get(), d3d12CounterResource.Get(), uav, m_Descriptor.GetDescriptorHandle() ); }
2ba6f816be30608ce59dd541660cc69a8783c1ff
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_20682.cpp
474be1c3ebceeafb0cc7849d4f1824b0c092cdce
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
669
cpp
Kitware_CMake_repos_basic_block_block_20682.cpp
{ DWORD arg_len; /* Convert argument to wide char. */ arg_len = MultiByteToWideChar(CP_UTF8, 0, *arg, -1, temp_buffer, (int) (dst + dst_len - pos)); if (arg_len == 0) { err = GetLastError(); goto error; } if (verbatim_arguments) { /* Copy verbatim. */ wcscpy(pos, temp_buffer); pos += arg_len - 1; } else { /* Quote/escape, if needed. */ pos = quote_cmd_arg(temp_buffer, pos); } *pos++ = *(arg + 1) ? L' ' : L'\0'; }
5af2b2b41281f47a3b054054bcf94f286ab259a9
31f5cddb9885fc03b5c05fba5f9727b2f775cf47
/engine/modules/box2d/box2d_joint_motor.cpp
1ac922fda1bf4134316b57e02db56e1805bf8827
[ "MIT" ]
permissive
timi-liuliang/echo
2935a34b80b598eeb2c2039d686a15d42907d6f7
d6e40d83c86431a819c6ef4ebb0f930c1b4d0f24
refs/heads/master
2023-08-17T05:35:08.104918
2023-08-11T18:10:35
2023-08-11T18:10:35
124,620,874
822
102
MIT
2021-06-11T14:29:03
2018-03-10T04:07:35
C++
UTF-8
C++
false
false
216
cpp
box2d_joint_motor.cpp
#include "box2d_joint_motor.h" namespace Echo { Box2DJointMotor::Box2DJointMotor() { } Box2DJointMotor::~Box2DJointMotor() { } void Box2DJointMotor::bindMethods() { } }
02fafd629a8fd293a9cf55e60bb4bcaf1d3ce57b
dcc8aaadc3a0a9dc62c4d2b87f34b64fab9cb313
/userInterface.h
5e5b50ea6fee7657c8ec2ff0b871d74553b0b596
[]
no_license
Crinnion0/PrisonerDilemma
510d470d1e2a6cb51b8bd6482eec98f18efe9fd3
57deef95cd6dde12a63550673259cd2bbb5ccba3
refs/heads/master
2020-03-10T01:49:08.552066
2018-04-11T16:08:27
2018-04-11T16:08:27
129,120,235
0
0
null
null
null
null
UTF-8
C++
false
false
742
h
userInterface.h
#pragma once #include <iostream> #include <string> #include "strategy.h" using namespace std; class userInterface { public: userInterface(); ~userInterface(); void get_welcome() const; string get_fileLocation(); string gameOrTournament() { return "Game (1) or Tournament?\n"; } void setIteration(); int getIteration() { return iterationSelection; } void setUserSelection(); int getUserSelection(); void setStrategyNumber(); int getStrategyNumber() { return strategyNumber; } void setGangNumber(int a) { gangNumber = a; } int getGangNumber() { return gangNumber; } protected: int interfaceSelection; int iterationSelection; int strategyNumber; int gangNumber; string interfaceWelcome; string fileLocation; };
c5a3e28a2f2fc040b54c7af3b938d67d4f9240d6
88ae8695987ada722184307301e221e1ba3cc2fa
/third_party/vulkan-deps/vulkan-validation-layers/src/layers/stateless/sl_instance_device.cpp
28f2b23eb32c63c83ac6d895a24281095ade6735
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LGPL-2.0-or-later", "MIT", "GPL-1.0-or-later", "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
51,793
cpp
sl_instance_device.cpp
/* Copyright (c) 2015-2023 The Khronos Group Inc. * Copyright (c) 2015-2023 Valve Corporation * Copyright (c) 2015-2023 LunarG, Inc. * Copyright (C) 2015-2023 Google 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 "stateless/stateless_validation.h" static const int kMaxParamCheckerStringLength = 256; bool StatelessValidation::ValidateString(const char *apiName, const ParameterName &stringName, const std::string &vuid, const char *validateString) const { bool skip = false; VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString); if (result == VK_STRING_ERROR_NONE) { return skip; } else if (result & VK_STRING_ERROR_LENGTH) { skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), kMaxParamCheckerStringLength); } else if (result & VK_STRING_ERROR_BAD_DATA) { skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName, stringName.get_name().c_str()); } return skip; } bool StatelessValidation::ValidateApiVersion(uint32_t api_version, APIVersion effective_api_version) const { bool skip = false; uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0); if (effective_api_version != api_version_nopatch) { if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) { skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010", "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", api_version, effective_api_version.major(), effective_api_version.minor()); } else { skip |= LogWarning(instance, kVUIDUndefined, "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", api_version, effective_api_version.major(), effective_api_version.minor()); } } return skip; } bool StatelessValidation::ValidateInstanceExtensions(const VkInstanceCreateInfo *pCreateInfo) const { bool skip = false; // Create and use a local instance extension object, as an actual instance has not been created yet uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0); InstanceExtensions local_instance_extensions; local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo); for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { skip |= ValidateExtensionReqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388", "instance", pCreateInfo->ppEnabledExtensionNames[i]); } if (pCreateInfo->flags & VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR && !local_instance_extensions.vk_khr_portability_enumeration) { skip |= LogError(instance, "VUID-VkInstanceCreateInfo-flags-06559", "vkCreateInstance(): pCreateInfo->flags has VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR set, but " "pCreateInfo->ppEnabledExtensionNames does not include VK_KHR_portability_enumeration"); } return skip; } bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string &ext_name) const { if (instance_extensions.vk_khr_get_physical_device_properties2) { // Struct is legal IF it's supported const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device); if (dev_exts_enumerated == device_extensions_enumerated.end()) return true; auto enum_iter = dev_exts_enumerated->second.find(ext_name); if (enum_iter != dev_exts_enumerated->second.cend()) { return true; } } return false; } bool StatelessValidation::ValidateValidationFeatures(const VkInstanceCreateInfo *pCreateInfo, const VkValidationFeaturesEXT *validation_features) const { bool skip = false; bool debug_printf = false; bool gpu_assisted = false; bool reserve_slot = false; for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { switch (validation_features->pEnabledValidationFeatures[i]) { case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: gpu_assisted = true; break; case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: debug_printf = true; break; case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: reserve_slot = true; break; default: break; } } if (reserve_slot && !gpu_assisted) { skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); } if (gpu_assisted && debug_printf) { skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); } return skip; } template <typename ExtensionState> ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { if (!extension_name) return kNotEnabled; // null strings specify nothing auto info = ExtensionState::get_info(extension_name); ExtEnabled state = info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct return state; } bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance) const { bool skip = false; // Note: From the spec-- // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0; skip |= ValidateApiVersion(local_api_version, api_version); skip |= ValidateInstanceExtensions(pCreateInfo); const auto *validation_features = LvlFindInChain<VkValidationFeaturesEXT>(pCreateInfo->pNext); if (validation_features) skip |= ValidateValidationFeatures(pCreateInfo, validation_features); #ifdef VK_USE_PLATFORM_METAL_EXT auto export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(pCreateInfo->pNext); while (export_metal_object_info) { if ((export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT) && (export_metal_object_info->exportObjectType != VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT)) { skip |= LogError(instance, "VUID-VkInstanceCreateInfo-pNext-06779", "vkCreateInstance(): The pNext chain contains a VkExportMetalObjectCreateInfoEXT whose " "exportObjectType = %s, but only VkExportMetalObjectCreateInfoEXT structs with exportObjectType of " "VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT or " "VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT are allowed", string_VkExportMetalObjectTypeFlagBitsEXT(export_metal_object_info->exportObjectType)); } export_metal_object_info = LvlFindInChain<VkExportMetalObjectCreateInfoEXT>(export_metal_object_info->pNext); } #endif // VK_USE_PLATFORM_METAL_EXT return skip; } void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, VkResult result) { auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); // Copy extension data into local object if (result != VK_SUCCESS) return; this->instance_extensions = instance_data->instance_extensions; this->device_extensions = instance_data->device_extensions; } void StatelessValidation::CommonPostCallRecordEnumeratePhysicalDevice(const VkPhysicalDevice *phys_devices, const int count) { // Assume phys_devices is valid assert(phys_devices); for (int i = 0; i < count; ++i) { const auto &phys_device = phys_devices[i]; if (0 == physical_device_properties_map.count(phys_device)) { auto phys_dev_props = new VkPhysicalDeviceProperties; DispatchGetPhysicalDeviceProperties(phys_device, phys_dev_props); physical_device_properties_map[phys_device] = phys_dev_props; // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state uint32_t ext_count = 0; vvl::unordered_set<std::string> dev_exts_enumerated{}; std::vector<VkExtensionProperties> ext_props{}; instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, nullptr); ext_props.resize(ext_count); instance_dispatch_table.EnumerateDeviceExtensionProperties(phys_device, nullptr, &ext_count, ext_props.data()); for (uint32_t j = 0; j < ext_count; j++) { dev_exts_enumerated.insert(ext_props[j].extensionName); std::string_view extension_name = ext_props[j].extensionName; if (extension_name == "VK_EXT_discard_rectangles") { discard_rectangles_extension_version = ext_props[j].specVersion; } else if (extension_name == "VK_NV_scissor_exclusive") { scissor_exclusive_extension_version = ext_props[j].specVersion; } } device_extensions_enumerated[phys_device] = std::move(dev_exts_enumerated); } } } void StatelessValidation::PostCallRecordEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices, VkResult result) { if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { return; } if (pPhysicalDeviceCount && pPhysicalDevices) { CommonPostCallRecordEnumeratePhysicalDevice(pPhysicalDevices, *pPhysicalDeviceCount); } } void StatelessValidation::PostCallRecordEnumeratePhysicalDeviceGroups( VkInstance instance, uint32_t *pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties *pPhysicalDeviceGroupProperties, VkResult result) { if ((VK_SUCCESS != result) && (VK_INCOMPLETE != result)) { return; } if (pPhysicalDeviceGroupCount && pPhysicalDeviceGroupProperties) { for (uint32_t i = 0; i < *pPhysicalDeviceGroupCount; i++) { const auto &group = pPhysicalDeviceGroupProperties[i]; CommonPostCallRecordEnumeratePhysicalDevice(group.physicalDevices, group.physicalDeviceCount); } } } void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { delete (it->second); it = physical_device_properties_map.erase(it); } } void StatelessValidation::GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 &pProperties) const { if (api_version >= VK_API_VERSION_1_1) { DispatchGetPhysicalDeviceProperties2(physicalDevice, &pProperties); } else if (IsExtEnabled(device_extensions.vk_khr_get_physical_device_properties2)) { DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &pProperties); } } void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); if (result != VK_SUCCESS) return; ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); // Parmeter validation also uses extension data stateless_validation->device_extensions = this->device_extensions; VkPhysicalDeviceProperties device_properties = {}; // Need to get instance and do a getlayerdata call... DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); if (IsExtEnabled(device_extensions.vk_nv_shading_rate_image)) { // Get the needed shading rate image limits auto shading_rate_image_props = LvlInitStruct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&shading_rate_image_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; } if (IsExtEnabled(device_extensions.vk_nv_mesh_shader)) { // Get the needed mesh shader limits auto mesh_shader_props = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesNV>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.mesh_shader_props_nv = mesh_shader_props; } if (IsExtEnabled(device_extensions.vk_ext_mesh_shader)) { // Get the needed mesh shader EXT limits auto mesh_shader_props_ext = LvlInitStruct<VkPhysicalDeviceMeshShaderPropertiesEXT>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&mesh_shader_props_ext); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.mesh_shader_props_ext = mesh_shader_props_ext; } if (IsExtEnabled(device_extensions.vk_nv_ray_tracing)) { // Get the needed ray tracing limits auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPropertiesNV>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.ray_tracing_props_nv = ray_tracing_props; } if (IsExtEnabled(device_extensions.vk_khr_ray_tracing_pipeline)) { // Get the needed ray tracing limits auto ray_tracing_props = LvlInitStruct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&ray_tracing_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.ray_tracing_props_khr = ray_tracing_props; } if (IsExtEnabled(device_extensions.vk_khr_acceleration_structure)) { // Get the needed ray tracing acc structure limits auto acc_structure_props = LvlInitStruct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&acc_structure_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.acc_structure_props = acc_structure_props; } if (IsExtEnabled(device_extensions.vk_ext_transform_feedback)) { // Get the needed transform feedback limits auto transform_feedback_props = LvlInitStruct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&transform_feedback_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.transform_feedback_props = transform_feedback_props; } if (IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor)) { // Get the needed vertex attribute divisor limits auto vertex_attribute_divisor_props = LvlInitStruct<VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&vertex_attribute_divisor_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.vertex_attribute_divisor_props = vertex_attribute_divisor_props; } if (IsExtEnabled(device_extensions.vk_ext_blend_operation_advanced)) { // Get the needed blend operation advanced properties auto blend_operation_advanced_props = LvlInitStruct<VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&blend_operation_advanced_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.blend_operation_advanced_props = blend_operation_advanced_props; } if (IsExtEnabled(device_extensions.vk_khr_maintenance4)) { // Get the needed maintenance4 properties auto maintance4_props = LvlInitStruct<VkPhysicalDeviceMaintenance4PropertiesKHR>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&maintance4_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.maintenance4_props = maintance4_props; } if (IsExtEnabled(device_extensions.vk_khr_fragment_shading_rate)) { auto fragment_shading_rate_props = LvlInitStruct<VkPhysicalDeviceFragmentShadingRatePropertiesKHR>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&fragment_shading_rate_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.fragment_shading_rate_props = fragment_shading_rate_props; } if (IsExtEnabled(device_extensions.vk_khr_depth_stencil_resolve)) { auto depth_stencil_resolve_props = LvlInitStruct<VkPhysicalDeviceDepthStencilResolveProperties>(); auto prop2 = LvlInitStruct<VkPhysicalDeviceProperties2>(&depth_stencil_resolve_props); GetPhysicalDeviceProperties2(physicalDevice, prop2); phys_dev_ext_props.depth_stencil_resolve_props = depth_stencil_resolve_props; } stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; // Save app-enabled features in this device's validation object // The enabled features can come from either pEnabledFeatures, or from the pNext chain const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); safe_VkPhysicalDeviceFeatures2 tmp_features2_state; tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; if (features2) { tmp_features2_state.features = features2->features; } else if (pCreateInfo->pEnabledFeatures) { tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; } else { tmp_features2_state.features = {}; } // Use pCreateInfo->pNext to get full chain stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); stateless_validation->physical_device_features2 = tmp_features2_state; } bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { bool skip = false; for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { skip |= ValidateString("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); } // If this device supports VK_KHR_portability_subset, it must be enabled const std::string portability_extension_name("VK_KHR_portability_subset"); const std::string fragmentmask_extension_name("VK_AMD_shader_fragment_mask"); const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; bool portability_requested = false; bool fragmentmask_requested = false; for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { skip |= ValidateString("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); skip |= ValidateExtensionReqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", pCreateInfo->ppEnabledExtensionNames[i]); if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { portability_requested = true; } if (fragmentmask_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { fragmentmask_requested = true; } } if (portability_supported && !portability_requested) { skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", report_data->FormatHandle(physicalDevice).c_str()); } { const bool maint1 = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE_1_EXTENSION_NAME)); bool negative_viewport = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME)); if (negative_viewport) { // Only need to check for VK_KHR_MAINTENANCE_1_EXTENSION_NAME if api version is 1.0, otherwise it's deprecated due to // integration into api version 1.1 if (api_version >= VK_API_VERSION_1_1) { skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-01840", "vkCreateDevice(): ppEnabledExtensionNames must not include " "VK_AMD_negative_viewport_height if api version is greater than or equal to 1.1."); } else if (maint1) { skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", "vkCreateDevice(): ppEnabledExtensionNames must not simultaneously include " "VK_KHR_maintenance1 and VK_AMD_negative_viewport_height."); } } } { const auto *descriptor_buffer_features = LvlFindInChain<VkPhysicalDeviceDescriptorBufferFeaturesEXT>(pCreateInfo->pNext); if (descriptor_buffer_features && descriptor_buffer_features->descriptorBuffer && fragmentmask_requested) { skip |= LogError(device, "VUID-VkDeviceCreateInfo-None-08095", "vkCreateDevice(): If the descriptorBuffer feature is enabled, ppEnabledExtensionNames must not " "contain VK_AMD_shader_fragment_mask."); } } { bool khr_bda = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); bool ext_bda = IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); if (khr_bda && ext_bda) { skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", "vkCreateDevice(): ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " "VK_EXT_buffer_device_address."); } } if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { // Check for get_physical_device_properties2 struct const auto *features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); if (features2) { // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", "vkCreateDevice(): pNext includes a VkPhysicalDeviceFeatures2 struct when " "pCreateInfo->pEnabledFeatures is non-NULL."); } } auto features2 = LvlFindInChain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; const auto *robustness2_features = LvlFindInChain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", "vkCreateDevice(): If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); } const auto *raytracing_features = LvlFindInChain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { skip |= LogError( device, "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", "vkCreateDevice(): If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, " "rayTracingPipelineShaderGroupHandleCaptureReplay " "must also be VK_TRUE."); } auto vertex_attribute_divisor_features = LvlFindInChain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); if (vertex_attribute_divisor_features && (!IsExtEnabled(device_extensions.vk_ext_vertex_attribute_divisor))) { skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, "vkCreateDevice(): pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device."); } const auto *vulkan_11_features = LvlFindInChain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); if (vulkan_11_features) { const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); while (current) { if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-02829", "vkCreateDevice(): If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then " "it must not include a %s structure", string_VkStructureType(current->sType)); break; } current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); } // Check features are enabled if matching extension is passed in as well for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; if ((0 == strncmp(extension, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && (vulkan_11_features->shaderDrawParameters == VK_FALSE)) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-04476", "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan11Features::shaderDrawParameters is not VK_TRUE.", VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME); } } } const auto *vulkan_12_features = LvlFindInChain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); if (vulkan_12_features) { const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); while (current) { if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-pNext-02830", "vkCreateDevice(): If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not " "include a %s structure", string_VkStructureType(current->sType)); break; } current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); } // Check features are enabled if matching extension is passed in as well for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && (vulkan_12_features->drawIndirectCount == VK_FALSE)) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02831", "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); } if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02832", "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " "is not VK_TRUE.", VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); } if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && (vulkan_12_features->descriptorIndexing == VK_FALSE)) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02833", "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); } if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02834", "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); } if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-02835", "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); } } if (vulkan_12_features->bufferDeviceAddress == VK_TRUE) { if (IsExtEnabledByCreateinfo(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME))) { skip |= LogError(instance, "VUID-VkDeviceCreateInfo-pNext-04748", "vkCreateDevice(): pNext chain includes VkPhysicalDeviceVulkan12Features with bufferDeviceAddress " "set to VK_TRUE and ppEnabledExtensionNames contains VK_EXT_buffer_device_address"); } } } const auto *vulkan_13_features = LvlFindInChain<VkPhysicalDeviceVulkan13Features>(pCreateInfo->pNext); if (vulkan_13_features) { const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); while (current) { if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES || current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES) { skip |= LogError( instance, "VUID-VkDeviceCreateInfo-pNext-06532", "vkCreateDevice(): If the pNext chain includes a VkPhysicalDeviceVulkan13Features structure, then it must not " "include a %s structure", string_VkStructureType(current->sType)); break; } current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); } } // Validate pCreateInfo->pQueueCreateInfos if (pCreateInfo->pQueueCreateInfos) { for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " "index value.", i); } if (queue_create_info.pQueuePriorities != nullptr) { for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { const float queue_priority = queue_create_info.pQueuePriorities[j]; if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 "] (=%f) is not between 0 and 1 (inclusive).", i, j, queue_priority); } } } // Need to know if protectedMemory feature is passed in preCall to creating the device VkBool32 protected_memory = VK_FALSE; const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = LvlFindInChain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); if (protected_features) { protected_memory = protected_features->protectedMemory; } else if (vulkan_11_features) { protected_memory = vulkan_11_features->protectedMemory; } if (((queue_create_info.flags & VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) != 0) && (protected_memory == VK_FALSE)) { skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", "vkCreateDevice: pCreateInfo->flags contains VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " "protectedMemory feature being enabled as well."); } } } // feature dependencies for VK_KHR_variable_pointers const auto *variable_pointers_features = LvlFindInChain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); VkBool32 variable_pointers = VK_FALSE; VkBool32 variable_pointers_storage_buffer = VK_FALSE; if (vulkan_11_features) { variable_pointers = vulkan_11_features->variablePointers; variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; } else if (variable_pointers_features) { variable_pointers = variable_pointers_features->variablePointers; variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; } if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { skip |= LogError( instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", "vkCreateDevice(): If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); } // feature dependencies for VK_KHR_multiview const auto *multiview_features = LvlFindInChain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); VkBool32 multiview = VK_FALSE; VkBool32 multiview_geometry_shader = VK_FALSE; VkBool32 multiview_tessellation_shader = VK_FALSE; if (vulkan_11_features) { multiview = vulkan_11_features->multiview; multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; } else if (multiview_features) { multiview = multiview_features->multiview; multiview_geometry_shader = multiview_features->multiviewGeometryShader; multiview_tessellation_shader = multiview_features->multiviewTessellationShader; } if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", "vkCreateDevice(): If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); } if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", "vkCreateDevice(): If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); } return skip; } bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties, const char *apiName) const { bool skip = false; if (pImageFormatInfo != nullptr) { const auto image_stencil_struct = LvlFindInChain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); if (image_stencil_struct != nullptr) { if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); // No flags other than the legal attachment bits may be set legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", apiName); } } } const auto image_drm_format = LvlFindInChain<VkPhysicalDeviceImageDrmFormatModifierInfoEXT>(pImageFormatInfo->pNext); if (image_drm_format) { if (pImageFormatInfo->tiling != VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { skip |= LogError( physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " "but tiling (%s) is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", apiName, string_VkImageTiling(pImageFormatInfo->tiling)); } if (image_drm_format->sharingMode == VK_SHARING_MODE_CONCURRENT && image_drm_format->queueFamilyIndexCount <= 1) { skip |= LogError( physicalDevice, "VUID-VkPhysicalDeviceImageDrmFormatModifierInfoEXT-sharingMode-02315", "%s: pNext chain of VkPhysicalDeviceImageFormatInfo2 includes VkPhysicalDeviceImageDrmFormatModifierInfoEXT, " "with sharing mode VK_SHARING_MODE_CONCURRENT, but queueFamilyIndexCount is %" PRIu32 ".", apiName, image_drm_format->queueFamilyIndexCount); } } else { if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { skip |= LogError( physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02249", "%s(): pNext chain of VkPhysicalDeviceImageFormatInfo2 does not include " "VkPhysicalDeviceImageDrmFormatModifierInfoEXT, but tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.", apiName); } } if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && (pImageFormatInfo->flags & VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT)) { const auto format_list = LvlFindInChain<VkImageFormatListCreateInfo>(pImageFormatInfo->pNext); if (!format_list || format_list->viewFormatCount == 0) { skip |= LogError( physicalDevice, "VUID-VkPhysicalDeviceImageFormatInfo2-tiling-02313", "%s(): tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT and flags contain VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT " "bit, but the pNext chain does not include VkImageFormatListCreateInfo with non-zero viewFormatCount.", apiName); } } } return skip; } bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties) const { return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, "vkGetPhysicalDeviceImageFormatProperties2"); } bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, VkImageFormatProperties2 *pImageFormatProperties) const { return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, "vkGetPhysicalDeviceImageFormatProperties2KHR"); } bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { bool skip = false; if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); } return skip; } bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const { return ValidateArray("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); } bool StatelessValidation::ValidateDebugUtilsObjectNameInfoEXT(const std::string &api_name, VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { bool skip = false; if ((pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) && (pNameInfo->objectHandle == HandleToUint64(VK_NULL_HANDLE))) { skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", "%s() objectType is VK_OBJECT_TYPE_UNKNOWN but objectHandle is VK_NULL_HANDLE", api_name.c_str()); } return skip; } bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { bool skip = false; if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { skip |= LogError(device, "VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02587", "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); } if (pNameInfo->objectHandle == HandleToUint64(VK_NULL_HANDLE)) { skip |= LogError(device, "VUID-vkSetDebugUtilsObjectNameEXT-pNameInfo-02588", "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectHandle cannot be VK_NULL_HANDLE."); } skip |= ValidateDebugUtilsObjectNameInfoEXT("vkSetDebugUtilsObjectNameEXT", device, pNameInfo); return skip; } bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { bool skip = false; if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); } return skip; }
717cdae19b954106e78395ccffbea0002fce9475
c2dce5941201390ee01abc300f62fd4e4d3281e0
/include/cetty/util/StringUtil.h
404bb77158a0049392480e5da5c5c3c49267c4df
[ "Apache-2.0" ]
permissive
justding/cetty2
1cf2b7b5808fe0ca9dd5221679ba44fcbba2b8dc
62ac0cd1438275097e47a9ba471e72efd2746ded
refs/heads/master
2020-12-14T09:01:47.987777
2015-11-08T10:38:59
2015-11-08T10:38:59
66,538,583
1
0
null
2016-08-25T08:11:20
2016-08-25T08:11:20
null
UTF-8
C++
false
false
17,167
h
StringUtil.h
#if !defined(CETTY_UTIL_STRINGUTIL_H) #define CETTY_UTIL_STRINGUTIL_H /* * Copyright (c) 2010-2011 frankee zhou (frankee.zhou at gmail dot com) * * Distributed under 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 <string> #include <vector> #include <stdarg.h> #include <boost/assert.hpp> #include <boost/static_assert.hpp> #include <cstring> #include <cetty/Types.h> namespace cetty { namespace util { class StringPiece; class StringUtil { public: static const std::string NEWLINE; static inline bool isISOControl(int ch) { return iscntrl(ch) != 0; } static inline bool isWhitespace(int ch) { return isspace(ch) != 0; } static inline bool isDigit(int ch) { return ('0' <= ch && ch <= '9'); } static inline bool isDigits(const std::string& str) { for (std::size_t i = 0, j = str.size(); i < j; ++i) { if (str[i] < '0' || str[i] > '9') { return false; } } return true; } static inline bool isNumber(const std::string& str) { if (str.empty()) { return false; } for (std::size_t i = 0, j = str.size(); i < j; ++i) { if (str[0] == '+' || str[0] == '-') { continue; } if ((str[i] >= '0' && str[i] <= '9') || str[i] == '.') { continue; } else { return false; } } return true; } static inline bool isHex(int ch) { return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'); } static inline bool isAlnum(char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9'); } static int hashCode(const std::string& str); /** * Append a formatted string at the end of a string. * @param dest the destination string. * @param format the printf-like format string. The conversion character `%' can be used with * such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `%'. * @param ... used according to the format string. */ static void printf(std::string* dest, const char* format, ...); /** * Generate a formatted string. * @param format the printf-like format string. The conversion character `%' can be used with * such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `%'. * @param ... used according to the format string. * @return the result string. */ static std::string printf(const char* format, ...); /** * Append a formatted string at the end of a string. * @param dest the destination string. * @param format the printf-like format string. The conversion character `%' can be used with * such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `%'. * @param ap used according to the format string. */ static void vstrprintf(std::string* dest, const char* format, va_list ap); /** * Split a string with a delimiter. * @param str the string. * @param delim the delimiter. * @param elems a vector object into which the result elements are pushed. * @return the number of result elements. */ static size_t split(const std::string& str, char delim, std::vector<std::string>* elems); /** * Split a string with delimiters. * @param str the string. * @param delims the delimiters. * @param elems a vector object into which the result elements are pushed. * @return the number of result elements. */ static size_t split(const std::string& str, const std::string& delims, std::vector<std::string>* elems); /** * Convert the letters of a string into upper case. * @param str the string to convert. * @return the string itself. */ static std::string* toUpper(std::string* str); /** * Convert the letters of a string into lower case. * @param str the string to convert. * @return the string itself. */ static std::string* toLower(std::string* str); static inline bool iequals(const std::string& astr, const std::string& bstr) { return iequals(astr.c_str(), bstr.c_str()); } static inline bool iequals(const char* astr, const char* bstr) { BOOST_ASSERT(astr && bstr); while (*astr != '\0') { if (*astr != *bstr && *astr + 0x20 != *bstr && *astr != *bstr + 0x20) { return false; } ++astr; ++bstr; } return *bstr == '\0'; } static inline int icompare(const std::string& astr, const std::string& bstr) { return icompare(astr.c_str(), bstr.c_str()); } /** * Compare two strings by case insensitive evaluation. */ static inline int icompare(const char* astr, const char* bstr) { BOOST_ASSERT(astr && bstr); while (*astr != '\0') { if (*bstr == '\0') { return 1; } int ac = *reinterpret_cast<const unsigned char*>(astr); if (ac >= 'A' && ac <= 'Z') { ac += 'a' - 'A'; } int bc = *reinterpret_cast<const unsigned char*>(bstr); if (bc >= 'A' && bc <= 'Z') { bc += 'a' - 'A'; } if (ac != bc) { return ac - bc; } astr++; bstr++; } return (*bstr == '\0') ? 0 : -1; } // HasPrefixString() // Check if a string begins with a given prefix. static inline bool hasPrefixString(const std::string& str, const std::string& prefix) { return str.size() >= prefix.size() && str.compare(0, prefix.size(), prefix) == 0; } // StripPrefixString() // Given a string and a putative prefix, returns the string minus the // prefix string if the prefix matches, otherwise the original // string. static inline std::string stripPrefixString(const std::string& str, const std::string& prefix) { if (hasPrefixString(str, prefix)) { return str.substr(prefix.size()); } else { return str; } } // HasSuffixString() // Return true if str ends in suffix. static inline bool hasSuffixString(const std::string& str, const std::string& suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } // StripSuffixString() // Given a string and a putative suffix, returns the string minus the // suffix string if the suffix matches, otherwise the original // string. static inline std::string stripSuffixString(const std::string& str, const std::string& suffix) { if (hasSuffixString(str, suffix)) { return str.substr(0, str.size() - suffix.size()); } else { return str; } } // ---------------------------------------------------------------------- // StripString // Replaces any occurrence of the character 'remove' (or the characters // in 'remove') with the character 'replacewith'. // Good for keeping html characters or protocol characters (\t) out // of places where they might cause a problem. // ---------------------------------------------------------------------- static inline std::string* stripString(std::string* s, const char* remove, char replacewith) { const char* strStart = s->c_str(); const char* str = strStart; for (str = strpbrk(str, remove); str != NULL; str = strpbrk(str + 1, remove)) { (*s)[str - strStart] = replacewith; } return s; } /** * Strip a String of it's ISO control characters. * * @param value * The String that should be stripped. * @return {@code String} * A new String instance with its hexadecimal control characters replaced * by a space. Or the unmodified String if it does not contain any ISO * control characters. */ static std::string stripControlCharacters(const std::string& value); static std::string* stripControlCharacters(std::string* str); /** * Cut space characters at head or tail of a string. * @param str the string to convert. * @return the string itself. */ static std::string* trim(std::string* str); // ---------------------------------------------------------------------- // StringReplace() // Give me a string and two patterns "old" and "new", and I replace // the first instance of "old" in the string with "new", if it // exists. RETURN a new string, regardless of whether the replacement // happened or not. // TODO if s is same with res // ---------------------------------------------------------------------- static void replace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replaceAll, std::string* res); static inline std::string replace(const std::string& s, const std::string& oldsub, const std::string& newsub, bool replaceAll) { std::string ret; replace(s, oldsub, newsub, replaceAll, &ret); return ret; } static void replace(const std::string& s, char oldChar, char newChar, bool replaceAll, std::string* res); // ---------------------------------------------------------------------- // JoinStrings() // These methods concatenate a vector of strings into a C++ std::string, using // the C-string "delim" as a separator between components. There are two // flavors of the function, one flavor returns the concatenated string, // another takes a pointer to the target string. In the latter case the // target string is cleared and overwritten. // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- // JoinStrings() // This merges a vector of string components with delim inserted // as separaters between components. // // ---------------------------------------------------------------------- static std::string* join(const std::vector<std::string>& components, const char* delim, std::string* result); static std::string join(const std::vector<std::string>& components, const char* delim); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int32_t strto32(const char* str); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int32_t strto32(const std::string& str); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int32_t strto32(const StringPiece& str); static int32_t strto32(const char* str, int base); static int32_t strto32(const std::string& str, int base); static int32_t strto32(const StringPiece& str, int base); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int64_t strto64(const char* str); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int64_t strto64(const std::string& str); /** * Convert a decimal string to an integer. * @param str the decimal string. * @return the integer. If the string does not contain numeric expression, 0 is returned. */ static int64_t strto64(const StringPiece& str); static int64_t strto64(const char* str, int base); static int64_t strto64(const std::string& str, int base); static int64_t strto64(const StringPiece& str, int base); /** * * */ static inline double strtof(const std::string& str) { return strtof(str.c_str()); } /** * Convert a decimal string to a real number. * @param str the decimal string. * @return the real number. If the string does not contain numeric expression, 0.0 is returned. */ static double strtof(const char* str); static std::string numtostr(int number); static std::string* numtostr(int number, std::string* str); static std::string numtostr(unsigned int number); static std::string* numtostr(unsigned int number, std::string* str); static std::string numtostr(long number); static std::string* numtostr(long number, std::string* str); static std::string numtostr(unsigned long number); static std::string* numtostr(unsigned long number, std::string* str); static std::string numtostr(long long number); static std::string* numtostr(long long number, std::string* str); static std::string numtostr(unsigned long long number); static std::string* numtostr(unsigned long long number, std::string* str); // Description: converts a double or float to a string which, if // passed to NoLocaleStrtod(), will produce the exact same original double // (except in case of NaN; all NaNs are considered the same value). // We try to keep the string short but it's not guaranteed to be as // short as possible. // // DoubleToBuffer() and FloatToBuffer() write the text to the given // buffer and return it. The buffer must be at least // kDoubleToBufferSize bytes for doubles and kFloatToBufferSize // bytes for floats. kFastToBufferSize is also guaranteed to be large // enough to hold either. // // Return value: string // ---------------------------------------------------------------------- static std::string numtostr(float number); static std::string* numtostr(float number, std::string* str); static std::string numtostr(double number); static std::string* numtostr(double number, std::string* str); static inline std::string hextostr(int hex) { if (hex >= 0) { return hextostr(static_cast<uint32_t>(hex)); } } static std::string* hextostr(int hex, std::string* str) { if (hex >= 0) { return hextostr(static_cast<uint32_t>(hex), str); } } static std::string hextostr(uint32_t hex); static std::string* hextostr(uint32_t hex, std::string* str); static std::string hextostr(uint64_t hex); static std::string* hextostr(uint64_t hex, std::string* str); /** * Convert a UTF-8 string into a UCS wstring. * @param src the source object. * @param dest the destination object. */ static void utftoucs(const std::string& src, std::wstring* dest); /** * Convert a UTF-8 string into a UCS-4 array. * @param src the source object. * @param dest the destination object. */ static void utftoucs(const std::string& src, std::vector<uint32_t>* dest); /** * Convert a UCS-4 array into a UTF-8 string. * @param src the source object. * @param dest the destination object. */ static void ucstoutf(const std::vector<uint32_t>& src, std::string* dest); /** * Convert a UCS wstring into a UTF-8 string. * @param src the source object. * @param dest the destination object. */ static void ucstoutf(const std::wstring& src, std::string* dest); private: StringUtil() {} ~StringUtil() {} }; } } #endif //#if !defined(CETTY_UTIL_STRINGUTIL_H) // Local Variables: // mode: c++ // End:
dd94c8c4b01c8fb905c41c022708bb48d06f218f
4fcde4ed2ae1901e580fc40e7b84a546e33be0f9
/src/type_info/LF_ARGLIST.cc
1470f2acf2b2ba694130a34717efe87cdb4922e5
[ "Apache-2.0" ]
permissive
sradigan/libmspdb
18e99934c0098edf60089b8716e35ca209040e5a
31283565f18fd32e27717e7e0180b9c27f44d824
refs/heads/main
2023-03-23T10:41:10.849046
2021-03-17T17:24:49
2021-03-17T17:26:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,552
cc
LF_ARGLIST.cc
/* * 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. */ #include "type_info/LF_ARGLIST.hh" #include "TypeInfoStream.hh" #include "pdb_exception.hh" #include "../builtin_expect.hh" #include "../portable_endian.hh" #include <mutex> #include <vector> namespace mspdb { struct lfArgList { le_uint32_t count; }; class LF_ARGLIST::IMPL { public: IMPL(const TypeInfoStream& tpi) : tpi(tpi) {} public: const TypeInfoStream& tpi; std::vector<uint32_t> arg_types; std::vector<std::reference_wrapper<const LF_TYPE>> resolved_arg_types; std::mutex mtx; }; const std::vector<std::reference_wrapper<const LF_TYPE>>& LF_ARGLIST::arg_types() const { std::lock_guard<std::mutex> lock(pImpl->mtx); if (pImpl->resolved_arg_types.empty()) { pImpl->resolved_arg_types.reserve(pImpl->arg_types.size()); for (auto arg_type : pImpl->arg_types) { pImpl->resolved_arg_types.emplace_back(pImpl->tpi.type(arg_type)); } } return pImpl->resolved_arg_types; } LF_ARGLIST::LF_ARGLIST(const char* buffer, int32_t buffer_size, const TypeInfoStream& tpi) : LF_TYPE(buffer, buffer_size), pImpl(std::make_unique<IMPL>(tpi)) { // LF_TYPE advances our buffer/buffer_size past the "type" field (constructor takes references) if (unlikely(buffer_size < sizeof(lfArgList))) { throw pdb_exception("Buffer size too small for LF_ARGLIST"); } const auto* arglist = reinterpret_cast<const lfArgList*>(buffer); buffer += sizeof(lfArgList); buffer_size -= sizeof(lfArgList); if (unlikely(buffer_size < sizeof(uint32_t) * arglist->count)) { throw pdb_exception("Buffer size too small for LF_ARGLIST contents"); } const auto* args = reinterpret_cast<const le_uint32_t*>(buffer); pImpl->arg_types.reserve(arglist->count); for (int i = 0; i < arglist->count; ++i) { pImpl->arg_types.push_back(args[i]); } } LF_ARGLIST::~LF_ARGLIST() = default; } /* namespace mspdb */
5c764f01412e556b0ee15098cada2d10c9129c2b
ce434fc49f92c3b0bfefbf59e18adc7ed5ac59cf
/OpenMQ135/OpenMQ135.cpp
7e5264d03bc94f23d302d55055646623e52bf209
[]
no_license
tantt2810/OpenSensor
19959d8f0892105962d7257f0386d91370f8fc3e
9648ec98c03e7e341f62f30434b11fa6b3df5942
refs/heads/master
2021-01-21T13:14:14.935657
2016-05-26T07:40:03
2016-05-26T07:40:03
52,935,719
5
2
null
null
null
null
UTF-8
C++
false
false
6,448
cpp
OpenMQ135.cpp
#include <OpenMQ135.h> /****************** OpenMQ135 **************************************** Contruction function: you must declare your analog pin that you use in the parameter ************************************************************************************/ OpenMQ135::OpenMQ135(int analogpin): OpenSensor(analogpin){} /****************** OpenMQ135 **************************************** Contruction function: you must declare your analog pin and digital pin that you use in the parameter ************************************************************************************/ OpenMQ135::OpenMQ135(int analogpin, int digitalpin): OpenSensor(analogpin, digitalpin){} /****************** MQResistanceCalculation **************************************** Input: raw_adc - raw value read from adc, which represents the voltage Output: the calculated sensor resistance Remarks: The sensor and the load resistor forms a voltage divider. Given the voltage across the load resistor and its resistance, the resistance of the sensor could be derived. The RL_VALUE value you can configure in header file. ************************************************************************************/ float OpenMQ135::MQResistanceCalculation(int raw_adc){ return (RL_VALUE * (getVcc() - VoltageCalculation(raw_adc))/VoltageCalculation(raw_adc)); //return (RL_VALUE * (1023 - raw_adc)/raw_adc); } /************************************ GetRo ***************************************** Input: None Output: Ro value of the sensor Remarks: This function assumes that the sensor is in clean air. It use MQResistanceCalculation to calculates the sensor resistance in clean air and then divides it with RO_CLEAN_AIR_FACTOR. RSRO_CLEAN_AIR_FACTOR is about 10, which differs slightly between different sensors. ************************************************************************************/ float OpenMQ135::GetRo(){ float val = 0; for(int i=1; i<=GET_RO_SAMPLE_TIMES; i++){ val += MQResistanceCalculation(readAnalog()); } val /= GET_RO_SAMPLE_TIMES; //calculate the average value val /= RSRO_CLEAN_AIR_FACTOR; //divide for RSRO_CLEAN_AIR_FACTOR to calculate Ro return val; } /***************************** GetRs ********************************************* Input: None Output: Rs of the sensor Remarks: This function use MQResistanceCalculation to caculate the sensor resistance (Rs). The Rs changes as the sensor is in the different consentration of the target gas. The sample times could be configured by changing the definition in header file. ************************************************************************************/ float OpenMQ135::GetRs(){ float val = 0; for(int i=1; i<=GET_RS_SAMPLE_TIMES; i++){ val += MQResistanceCalculation(readAnalog()); } val /= GET_RS_SAMPLE_TIMES; return val; } /***************************** readCO2 ********************************************* Input: None Output: ppm of CO2 of the sensor Remarks: This function return ppm of CO2 of the sensor. It use CO2Curve[2], GetRs(), Ro to calculate ppm of CO2. ************************************************************************************/ float OpenMQ135::readCO2(){ return co2 = CO2Curve[0] * pow( (GetRs()/Ro), CO2Curve[1]); } /***************************** readCO ********************************************* Input: None Output: ppm of CO of the sensor Remarks: This function return ppm of CO of the sensor. It use COCurve[2], GetRs(), Ro to calculate ppm of CO. ************************************************************************************/ float OpenMQ135::readCO(){ return co = COCurve[0] * pow( (GetRs()/Ro), COCurve[1]); } /***************************** readNH4 ********************************************* Input: None Output: ppm of NH4 of the sensor Remarks: This function return ppm of NH4 of the sensor. It use NH4Curve[2], GetRs(), Ro to calculate ppm of NH4. ************************************************************************************/ float OpenMQ135::readNH4(){ return nh4 = NH4Curve[0] * pow( (GetRs()/Ro), NH4Curve[1]); } /***************************** readSulfide ********************************************* Input: None Output: ppm of Sulfide of the sensor Remarks: This function return ppm of Sulfide of the sensor. It use SulfideCurve[2], GetRs(), Ro to calculate ppm of Sulfide. ************************************************************************************/ float OpenMQ135::readSulfide(){ return sulfide = SulfideCurve[0] * pow( (GetRs()/Ro), SulfideCurve[1]); } /***************************** readMethane ********************************************* Input: None Output: ppm of Methane of the sensor Remarks: This function return ppm of Methane of the sensor. It use MethaneCurve[2], GetRs(), Ro to calculate ppm of Methane. ************************************************************************************/ float OpenMQ135::readMethane(){ return methane = MethaneCurve[0] * pow( (GetRs()/Ro), MethaneCurve[1]); } /***************************** readBenzene ********************************************* Input: None Output: ppm of Benzene of the sensor Remarks: This function return ppm of Benzene of the sensor. It use BenzeneCurve[2], GetRs(), Ro to calculate ppm of Benzene. ************************************************************************************/ float OpenMQ135::readBenzene(){ return benzene = BenzeneCurve[0] * pow( (GetRs()/Ro), BenzeneCurve[1]); } /************************************ getSensor ******************************* Input: None Output: basic information about sensor such as name, version, type, min/max value, etc. ************************************************************************************/ SensorInfo OpenMQ135::getSensor(){ SensorInfo sensor; strncpy(sensor.name, "MQ135", sizeof(sensor.name) - 1); sensor.version = OPENMQ135_VERSION; sensor.type = getTypeName(SENSOR_TYPE_GAS); sensor.min_value = 0; sensor.max_value = 10000; sensor.analogpin = getAnalogpin(); sensor.digitalpin = getDigitalpin(); sensor.Vcc = getVcc(); sensor.resolution = getResolution(); return sensor; }
9b23927f4ab35ff3d73720bb815f606183c72000
283d132555b4bd323797c23cd17b6f6008ec1853
/tensorflow/core/user_ops/gpu_cholesky.cu.cc
4399d19604d7733f09120c58792eb03b87936246
[ "Apache-2.0" ]
permissive
c0g/tomserflow
a0905e8087b1b793e7b9000e3ba16fba16a30875
f7b42f6ba58c3ff20ecd002535d2cca5d93bcf8e
refs/heads/master
2022-12-23T00:42:41.532096
2016-10-18T07:12:32
2016-10-18T07:12:32
71,149,479
0
1
Apache-2.0
2022-12-08T01:50:36
2016-10-17T14:51:45
C++
UTF-8
C++
false
false
453
cc
gpu_cholesky.cu.cc
// /* Copyright 2016 Tom Nickson. All rights reserved. */ #if GOOGLE_CUDA #define EIGEN_USE_GPU #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "tensorflow/core/user_ops/cuda_matrix_helper_impl.h" typedef Eigen::GpuDevice GPUDevice; // Instantiate the GPU implementation for GPU number types. template struct tensorflow::CUDAMatrixHelper<GPUDevice, float>; template struct tensorflow::CUDAMatrixHelper<GPUDevice, double>; #endif
788078228b4b7df897c28223c24576c4f5744031
0d86675d6f69836db9a7cd5244ebc7307d7f997a
/open_spiel/games/universal_poker/logic/card_set.h
aa6c792362f570769d02d23d11fc4ed63e65536e
[ "LicenseRef-scancode-generic-cla", "Apache-2.0" ]
permissive
sarahperrin/open_spiel
a7a4ecde1156b458d144989d3d7ef1814577741b
6f3551fd990053cf2287b380fb9ad0b2a2607c18
refs/heads/master
2021-12-25T04:12:19.270095
2021-12-09T16:17:43
2021-12-09T16:17:43
235,547,820
3
0
Apache-2.0
2020-01-22T10:17:41
2020-01-22T10:17:40
null
UTF-8
C++
false
false
2,444
h
card_set.h
// Copyright 2019 DeepMind Technologies 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. #ifndef OPEN_SPIEL_CARD_SET_H #define OPEN_SPIEL_CARD_SET_H #include <cstdint> #include <string> #include <vector> namespace open_spiel { namespace universal_poker { namespace logic { constexpr int kMaxSuits = 4; // Also defined in ACPC game.h // This is an equivalent wrapper to acpc evalHandTables.Cardset. // It stores the cards for each color over 16 * 4 bits. The use of a Union // allows to access only a specific color (16 bits) using bySuit[color]. // A uint8_t card is defined by the integer <rank> * MAX_SUITS + <suit> class CardSet { public: union CardSetUnion { CardSetUnion() : cards(0) {} uint16_t bySuit[kMaxSuits]; uint64_t cards; } cs; public: CardSet() : cs() {} CardSet(std::string cardString); CardSet(std::vector<int> cards); // Returns a set containing num_ranks cards per suit for num_suits. CardSet(uint16_t num_suits, uint16_t num_ranks); std::string ToString() const; // Returns the cards present in this set in ascending order. std::vector<uint8_t> ToCardArray() const; // Add a card, as MAX_RANKS * <suite> + <rank> to the CardSet. void AddCard(uint8_t card); // Toogle (does not remove) the bit associated to `card`. void RemoveCard(uint8_t card); bool ContainsCards(uint8_t card) const; int NumCards() const; // Returns the ranking value of this set of cards as evaluated by ACPC. int RankCards() const; // Returns all the possible nbCards-subsets of this CardSet. std::vector<CardSet> SampleCards(int nbCards); }; // Returns the lexicographically next permutation of the supplied bits. // See https://graphics.stanford.edu/~seander/bithacks.html#NextBitPermutation uint64_t bit_twiddle_permute(uint64_t v); } // namespace logic } // namespace universal_poker } // namespace open_spiel #endif // OPEN_SPIEL_CARD_SET_H
3a4e836a476f0f0b3721b66a338bc6c35ca52acd
e5091c3a8477fa12e1adfdb1f3d826eb6e9bb2be
/Other/ivan_and_mega_queries.cpp
09d5a9ca1b6e52bef34dcf48eba9b6357b904560
[]
no_license
leonardoAnjos16/Competitive-Programming
1db3793bfaa7b16fc9a2854c502b788a47f1bbe1
4c9390da44b2fa3c9ec4298783bfb3258b34574d
refs/heads/master
2023-08-14T02:25:31.178582
2023-08-06T06:54:52
2023-08-06T06:54:52
230,381,501
7
0
null
null
null
null
UTF-8
C++
false
false
1,955
cpp
ivan_and_mega_queries.cpp
#include <bits/stdc++.h> using namespace std; #define llong long long int const int LOG = 25; struct SparseTable { private: int n; vector<vector<int>> mx; public: SparseTable(int n, vector<int> &a) { this->n = n; mx.assign(LOG, vector<int>(n + 1)); for (int i = 1; i <= n; i++) mx[0][i] = a[i]; for (int i = 1; i < LOG; i++) for (int j = 1; j <= n; j++) mx[i][j] = max(mx[i - 1][j], mx[i - 1][min(j + (1 << (i - 1)), n)]); } int query(int l, int r) { int idx = 0; while ((1 << (idx + 1)) <= r - l + 1) idx++; return max(mx[idx][l], mx[idx][r - (1 << idx) + 1]); } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; SparseTable table(n, a); int q; cin >> q; while (q--) { int m; cin >> m; vector<int> ind(m); for (int i = 0; i < m; i++) cin >> ind[i]; int last_mx = -1; llong ans = a[ind[0]]; for (int i = 1; i < m; i++) { ans += a[ind[i]]; int mx = table.query(ind[i - 1], ind[i]); int l = 0, r = i - 1, first = -1; while (l <= r) { int mid = (l + r) / 2; if (table.query(ind[mid], ind[i]) > mx) l = mid + 1; else r = mid - 1, first = mid; } l = i; r = m - 1; int last = -1; while (l <= r) { int mid = (l + r) / 2; if (table.query(ind[i - 1], ind[mid]) > mx) r = mid - 1; else l = mid + 1, last = mid; } assert(first != -1 && last != -1); if (mx == last_mx) first = i - 1; ans += (i - first) * (last - i + 1LL) * mx; last_mx = mx; } cout << ans << "\n"; } }
23785f57a0f11f851712e7a48a5f221e621bd7d8
3ea34c23f90326359c3c64281680a7ee237ff0f2
/Data/912/E
221aa87f181e5e26c39b86b5490e89a8c657c873
[]
no_license
lcnbr/EM
c6b90c02ba08422809e94882917c87ae81b501a2
aec19cb6e07e6659786e92db0ccbe4f3d0b6c317
refs/heads/master
2023-04-28T20:25:40.955518
2020-02-16T23:14:07
2020-02-16T23:14:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
80,905
E
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | foam-extend: Open Source CFD | | \\ / O peration | Version: 4.0 | | \\ / A nd | Web: http://www.foam-extend.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volVectorField; location "Data/912"; object E; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 1 -1 0 0 0 0]; internalField nonuniform List<vector> 4096 ( (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-30260.2980700196,16061.0809802578,14199.2170897617) (-32023.9845969587,15402.6848838711,30820.5168028493) (-36079.6160138024,14022.6956173992,52877.4371992527) (-43766.8874754744,11795.6441793473,84848.6804953822) (-57632.3608088966,8822.51763489516,133658.523669389) (-82543.6257813939,5457.09930422613,210745.050146544) (-127670.678344343,2399.21561059098,336016.512880328) (-209224.505069577,567.345913217812,544673.672036682) (-345339.129986912,-29.3586346105854,890042.160658258) (-481474.929587241,-51.6472062892896,1371568.7374518) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-32054.1277893807,34581.0026607673,13534.2061088707) (-33831.4680427299,33324.7925020447,29443.5665334301) (-37951.2728653907,30703.7491921238,50713.7858240929) (-45817.6208017142,26424.3463439408,81902.7044612173) (-60071.5714858616,20549.0880069544,130247.705575018) (-85586.0207324835,13634.1245838542,207656.70102788) (-131188.89084771,7116.03717811195,334128.770308037) (-212405.671058951,3065.53534992126,544036.251930256) (-347449.719246,1506.15715771502,889950.455383992) (-482442.292219127,775.180819957177,1371565.91957678) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-36102.5155543408,58389.3793530067,12294.1388621009) (-37897.1600565487,56700.4893961016,26815.6020245931) (-42151.829824212,53132.5525094639,46538.6285314695) (-50420.5280944766,47253.803689013,76129.6992808758) (-65570.113508812,38911.2395199711,123337.661276671) (-92657.5419159577,28532.6433360206,201096.684440462) (-139829.782428804,18078.0281060093,329964.475941372) (-220356.876859461,10985.1244499652,542401.763700762) (-352566.158060323,7270.19026525011,889203.88865362) (-484743.822156815,3927.39912034293,1370795.49251003) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-43612.0210555477,91386.873438221,10614.5269703338) (-45418.1790208192,89490.3032614684,23242.8921257879) (-49822.8124756027,85466.1663915818,40732.0907192663) (-58656.2236726811,78794.1728807584,67847.9452001976) (-75319.9259595895,69076.6523163712,113002.45836339) (-105432.2974748,56361.6764977869,190605.722676418) (-156319.353379167,42272.7823770952,322730.32178451) (-235674.776160004,30817.7158622638,538572.506532183) (-361899.050123893,21905.8837762001,885835.863145086) (-488799.200468273,11759.9611508235,1366802.50158298) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-57064.3619420824,139715.724079287,8735.51130101522) (-58864.4208541931,137847.294359009,19242.9410576667) (-63341.0508880877,133908.955399485,34141.2029378497) (-72635.1915299798,127389.094107743,58181.4732408495) (-90857.2028372109,117822.257850635,100293.070543802) (-124707.433009211,104882.454054849,176479.725995937) (-181447.460517186,89035.1008116701,311164.868078551) (-259029.880434125,71501.9410135975,529510.523361368) (-375492.151927843,51359.9871950563,875548.571870401) (-494698.369435012,27194.6940706891,1354812.20838557) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-81324.8860024741,214105.02199241,6935.58808935143) (-83039.7269866374,212428.19055652,15394.4188784769) (-87363.8276550542,208906.539998457,27760.6619345594) (-96561.6137841924,203023.685076609,48687.684749883) (-114975.979755876,194117.85882659,87368.0635298043) (-149448.080031888,181097.169020856,160601.428595693) (-206341.709044875,162418.828301783,293559.410150481) (-280406.120778258,136207.561890538,509259.910051778) (-390232.692159302,99684.3086038373,851168.280802334) (-502136.609386902,53181.8082558692,1327317.77600397) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-125952.988564648,334688.866970476,5369.14358658544) (-127468.868335729,333259.420657213,12006.7818216189) (-131340.222892641,330191.898709731,22061.6460029891) (-139740.554803798,324943.600387099,39882.2854963003) (-156830.597911613,316495.757146571,74334.9850879341) (-189184.886344206,302732.497729219,141884.542723769) (-242543.539441448,279523.071702679,267323.838764325) (-309920.851642104,240787.658582863,472664.593714099) (-412282.742787466,180149.101012563,804482.544092776) (-514312.751533295,98131.008018005,1273846.09586398) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-207605.887516126,538308.826756677,3985.92772991463) (-208802.630247514,537023.773329489,9024.20530515615) (-211898.351837694,534177.691175194,16936.7646773963) (-218727.96787486,529088.934306509,31519.3986328321) (-232758.586263676,520249.607831371,60524.1342117012) (-259629.852584454,504267.151271541,118619.333253831) (-304299.402693689,473841.813951455,228599.993698728) (-358896.179337284,416342.118723536,411941.712895355) (-452396.624374807,322174.273817017,722313.164465708) (-537623.884814715,182634.434746641,1175433.62255172) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-344295.349580471,879904.588235472,2699.58810166676) (-345129.216358976,878642.700118785,6209.87767135771) (-347211.391246915,875686.904993945,11912.0550994875) (-351797.393159975,870068.570285612,22729.8122803672) (-361078.756517568,859534.956616245,44523.220013074) (-378469.098697326,839078.699705765,88180.7702761649) (-407714.666279742,798660.856432806,171076.394074554) (-451320.069907424,721110.7580353,317627.82467021) (-526380.864642599,583550.59230918,582632.37082062) (-578266.468835613,350929.876490725,992603.39791215) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-480984.618975128,1359514.39194881,1374.81526177305) (-481414.680790639,1358204.48841462,3227.70775657316) (-482444.954865359,1355067.32216244,6292.24545346087) (-484677.420529318,1348878.16825494,12160.0680134664) (-489180.054750974,1336830.49785538,24044.5815253224) (-497573.899486028,1312916.39414095,47780.7865761658) (-512222.125448833,1265159.60676308,93504.1616947156) (-536969.799307339,1171617.95669897,179966.762338346) (-578147.517389728,991674.023985546,349990.8480517) (-582331.648071104,641613.765961295,641638.606652242) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4518232.03023369,14310.8356331971,12437.343230034) (4515298.81230796,13632.1407514669,26722.9127405513) (4508543.0196299,12185.0990266304,45155.6852370954) (4495884.06215704,9796.79954233951,70948.4432291179) (4473366.71131063,6448.6936522695,108741.184624242) (4433310.66026403,2489.3430315272,165638.062714106) (4359764.39266294,-1051.58506664611,254495.083940359) (4214422.64543187,-2582.15647394821,408670.597079701) (3886443.86762248,-2132.36829812489,754260.474935311) (2995584.39784312,-1042.60454227441,1853484.25921413) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4515167.61113842,30567.7583989774,11761.8454733724) (4512225.2393472,29287.4485918316,25290.3374100312) (4505423.35330104,26528.9422167563,42812.3752203837) (4492532.37895801,21871.5297702524,67628.1523996193) (4469402.32012065,15101.7395761729,104741.722036133) (4428213.3423669,6626.66614537946,162045.542989778) (4353567.36141812,-1437.40563635137,252915.618460663) (4208865.19634024,-4804.19097795592,409107.292732405) (3883012.17413959,-3561.05028490361,755314.588500441) (2994098.8261701,-1532.58605779949,1854503.95879357) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4508321.55781541,50903.3798993079,10480.8122968198) (4505388.09956798,49182.9533157724,22540.5551152939) (4498468.86893553,45437.6584312008,38251.6473080579) (4485007.13514881,39002.7571170538,60933.2638849229) (4460300.10148149,29172.8354451789,96232.4601924571) (4415742.65285829,15782.3324542592,153917.106276242) (4336833.99590879,1610.44179728249,249445.987671943) (4193531.91557722,-4300.68221918181,410294.193643514) (3874103.11078373,-2038.37684860911,757342.758530032) (2990406.21726385,-133.973521012256,1856034.61373956) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4495788.5438019,77975.320138299,8768.00207045978) (4492884.49485193,76068.65419615,18820.1344843085) (4485829.38468401,71943.5855364931,31902.5173863295) (4471497.18103773,64819.2428307375,51173.1341292034) (4443818.59007166,53574.3912127327,82873.5694972807) (4391651.074578,37114.5946337416,139698.442431927) (4299688.21554969,17165.4193992888,243376.403068013) (4158676.63225053,7523.58112999651,412441.238475223) (3856143.64500426,8384.50542212007,759216.168243197) (2983532.95926525,5909.25682305017,1856081.2853326) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4473763.25875833,115491.276092003,6896.93051279337) (4470926.78436424,113687.678474185,14727.2081832187) (4463850.54245462,109880.821554466,24838.8859895057) (4448795.59421469,103490.92032517,39976.9299173104) (4417739.62605228,93758.353146729,66436.6462607534) (4354187.68496277,80169.3742389517,119727.255850518) (4232921.77448796,64152.6133958431,233611.334015741) (4094018.67192671,50162.1586297665,413164.711322088) (3827974.10753165,36683.1042526741,756640.360198842) (2973279.21579718,19815.9954005775,1849996.5435561) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4434593.72613584,169612.775468539,5200.39565203358) (4431950.43476131,168109.058902688,11029.3606424749) (4425213.86614555,165021.862599031,18551.1329642437) (4410446.04774187,159972.454074337,30302.4448560131) (4379050.42442945,152382.503696937,52892.397287378) (4313727.65747047,141416.186516923,103710.354673985) (4191004.15028537,126219.192154989,219538.423751525) (4058249.35611781,106715.597625646,399570.015026454) (3803946.51618717,77701.407576372,739613.010523199) (2961468.6220337,41075.5633962087,1829988.71827397) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4361811.88622146,253258.89352827,3829.51432109726) (4359516.31210214,252111.720351618,8082.17960120224) (4353569.78416185,249792.902789297,13641.6395234041) (4340166.26719309,246137.477334503,22810.3014332669) (4310923.68686288,240719.261206291,41959.7663163356) (4248528.02197333,232390.191986642,88513.359695995) (4129593.52138238,217842.910968783,199993.087225265) (4009692.78536963,191898.428056567,370437.126949578) (3768170.60076375,140143.211225133,702782.486916515) (2941235.71809354,74905.1274856511,1788644.96036723) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (4216282.06678246,401870.866894415,2740.57950224293) (4214482.29526512,400958.725107247,5849.1564009049) (4209771.32862422,399123.228952243,10089.6569429236) (4198948.69759851,396283.159339683,17507.8166313747) (4174894.25221099,392170.415148684,33644.3313811732) (4122037.19930607,385657.47428135,73950.5043629034) (4018025.02941726,370649.452707876,174060.037679707) (3939570.94641759,324133.092220489,318598.754927776) (3695819.91204207,248373.531638988,637392.405263877) (2894346.50367991,142088.411427801,1713479.23999401) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (3887432.54673942,743537.651158785,1845.82658263735) (3886194.53209852,742684.292666688,4037.01773265758) (3883071.94727718,740814.946531491,7302.46879623184) (3876002.11421672,737542.926563812,13483.701362266) (3860944.41090629,731748.764359034,27122.6918949503) (3830349.98747788,720286.400488478,58915.1866795358) (3775099.61286758,694477.385129249,127513.482277789) (3697075.77941463,635781.049592117,242710.182751063) (3476916.46815671,532034.668278526,530992.220479145) (2751850.99155309,346999.316421085,1571204.36226401) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (2995919.19907178,1840919.4824222,954.857856538915) (2995292.27488929,1840031.82395091,2140.87805929832) (2993770.5013561,1837968.88787466,4011.98766153982) (2990403.11942801,1834039.39206667,7675.4893683383) (2983393.29627084,1826442.60434533,15648.8055271932) (2969624.19886398,1810854.00680421,33123.6080284553) (2944094.02558979,1777733.43992206,68791.9093639232) (2895026.57186863,1708944.03229836,138873.062648619) (2751947.33273588,1570114.61446443,345938.773504022) (2237547.62982986,1224140.33061388,1224158.98857714) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-77790.372210745,11285.6435929992,9496.2516844963) (-81041.120427334,10631.941873794,19963.735379091) (-88372.0330439129,9131.3186586518,32506.962227373) (-101777.246357594,6533.61256766109,48394.151007473) (-124712.427716988,2578.48187052652,68654.3009976475) (-162923.162923639,-2513.55077977407,92161.1677982608) (-225434.633323758,-7175.17011970047,109294.856737759) (-324363.379544106,-8104.03462951612,80944.4091764053) (-466267.311296603,-5576.77435252521,-136008.144718919) (-571997.243517547,-2571.53225376212,-1141095.47827136) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-81311.5986821309,23733.5406322486,8790.80561434826) (-84499.0512066702,22482.0692275528,18424.4616475069) (-91737.5462100311,19597.439337743,29878.7333125767) (-105135.140854835,14403.0748951737,44436.2836310352) (-128393.562711303,6046.88512090033,63523.2560456935) (-167656.356693914,-5794.79686131762,87433.694021163) (-231609.045041803,-18119.0614660019,108313.484660393) (-329558.738181176,-20102.1239380253,83495.0013233907) (-468843.34731711,-12462.537505599,-133004.221233665) (-572902.402963292,-5239.44628723677,-1138575.58523374) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-89018.0047945223,38351.567216878,7481.02885840084) (-92085.0081859507,36669.6380143683,15526.0606585715) (-99167.8193163176,32771.6428704569,24748.0382107507) (-112699.885634189,25482.9856248622,36134.6410971075) (-137137.271930495,12743.6795024856,51634.7129606577) (-180446.651882803,-8244.96070777667,75033.6743812925) (-252202.369231231,-35505.3536563128,106215.824544701) (-347529.983755031,-39158.1178411301,91093.2106130384) (-476701.136120682,-20026.6356366524,-125778.951518346) (-575423.12509785,-7043.34322626299,-1133386.21938457) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-102775.418123449,55906.0886624257,5768.93331290279) (-105655.241001101,54093.6247466877,11644.1752666406) (-112497.350009379,49964.1946301486,17537.8510334128) (-126291.720874156,42122.5056365943,23446.7257665969) (-153460.771909912,27551.72694655,30677.5331372213) (-208608.591488562,-300.95043462989,47752.6817637193) (-316145.419822509,-49583.3715382856,102423.827850957) (-406305.455537272,-57130.2874372422,110137.578067953) (-496350.231046997,-19799.1341521764,-112836.554532138) (-580782.847323952,-4355.04674435486,-1126449.55159181) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-125826.982090831,76276.347071732,3979.47527294142) (-128460.641454295,74696.0580890816,7523.96058218352) (-134908.169512234,71272.9089049476,9733.4511072697) (-148670.233090264,65191.548108237,8889.72877367367) (-179045.837258865,55139.8040488067,2846.60781563246) (-256751.718233263,39770.2407088731,-1525.68729878753) (-510484.810578383,22273.6592664174,94783.359795917) (-605370.752258822,14430.0907291051,147371.898648157) (-534905.975138969,12686.6348494335,-97474.2948496685) (-589588.206858092,8043.81698031254,-1122246.2430859) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-163792.143810929,96942.4208856747,2479.28896594472) (-166094.445063928,95813.5957178619,4166.12399551349) (-171868.568354818,93545.6852630644,3735.27497082781) (-184654.665251824,89892.1002649987,-1105.07135923725) (-214159.840293692,84455.1094409099,-12450.6191950955) (-291594.698661211,76386.9370168858,-18985.4665383561) (-532751.59641112,64940.1756815106,86863.2565760839) (-619528.765859379,58279.6046724686,145551.357443031) (-552857.915414686,42025.5662648782,-102223.649537515) (-598456.571198137,20914.3060516144,-1130409.45254386) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-225952.36212773,108024.520625592,1441.64144232619) (-227848.620644907,107382.642009182,1997.02073115005) (-232669.627164607,106326.312349923,215.297803785481) (-243809.965798562,105277.378357561,-6434.2544640434) (-270857.6402005,105020.199984344,-20458.5251110065) (-346572.521800704,106181.94984044,-30393.5013274298) (-597856.641050491,106517.703572827,80238.6260472429) (-678264.132021546,122002.677751607,129231.963192324) (-580285.503188245,67979.6268020385,-123506.500559748) (-613201.829434788,28133.1776646709,-1151528.33181145) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-325214.839478749,73422.9487099872,857.971009846291) (-326639.493806763,73123.6745007043,998.220423285255) (-330302.655724897,72909.6723432999,-751.662387849882) (-339036.319459274,73833.9075787468,-6563.68171825799) (-361359.88108716,78710.0756298065,-19239.9312324386) (-430666.793428533,94442.5567479788,-30037.0525723063) (-704635.11894094,128163.128295724,95737.1638961525) (-575107.722325737,82038.3990961768,75139.6041280182) (-602578.09756965,29790.1423021759,-163513.40892723) (-636151.921352593,-227.325844397133,-1179894.98755249) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-467583.91060427,-147380.86081333,579.759700109018) (-468535.494692544,-147595.104550819,788.058375729845) (-470868.339785769,-147809.972494471,207.483109522296) (-476226.83341933,-147395.01489256,-1575.15394999086) (-488508.048701118,-145161.90573183,-3491.22014784203) (-517822.421190273,-139786.660787783,3669.89888912614) (-581984.403820703,-135901.810539426,49578.3472456087) (-603621.33314863,-165698.180885967,22771.5326240612) (-659630.667940654,-192484.77653099,-193646.919612357) (-670404.348029979,-167033.808277401,-1179825.60476313) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-572998.55290172,-1154041.71105371,338.095047000213) (-573470.256105751,-1154285.09285077,550.107175030955) (-574575.949281409,-1154747.12052134,593.19867256306) (-577029.901690115,-1155271.7873408,662.485071967674) (-582319.424876435,-1155895.41151242,1868.20483291868) (-593370.052463919,-1157749.63264168,7584.9208477759) (-613842.721593292,-1165387.21350693,19766.5638315049) (-636886.111486209,-1185163.12374161,-4096.31712494687) (-670626.777307397,-1181030.46378533,-168217.026994234) (-647313.132535713,-1012815.72315262,-1012814.8569203) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-91890.7189248468,7848.13839761367,6252.20831648906) (-94654.9304399189,7249.96468195685,12616.0536471171) (-100716.259632141,5815.31844155064,19144.961793797) (-111385.892987548,3226.84309072245,25526.7653330262) (-128620.816631629,-1060.25248176664,30495.4067294368) (-154986.783054098,-7192.14577131212,29751.1726312111) (-192882.24056706,-13325.0859773224,10523.8658518371) (-239866.455279102,-13286.5326903397,-60686.5257228271) (-277523.610132575,-8174.42909713378,-241255.797789713) (-241353.863457108,-3489.19995305484,-568409.977897112) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-95106.8586165505,16058.7244470621,5584.67388497163) (-97695.0856490351,14910.0896819207,11120.5833273687) (-103428.93977622,12151.6305123114,16475.6648227973) (-113504.848912485,6862.16446685763,21210.0515043104) (-129903.080797493,-2672.23922508775,24331.5563338212) (-155522.414869443,-18549.1316101376,23554.6003481824) (-193179.259155744,-38676.8883568208,10476.6168416287) (-238736.978133847,-38054.8536478581,-55576.822248175) (-275679.505565321,-20321.8344468765,-236593.258650224) (-240223.944433224,-7752.4642234211,-565008.452909954) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-101993.5457057,24657.4560406193,4376.80931762302) (-104264.201900561,23125.4727161857,8340.61999796452) (-109317.427038691,19434.9574229987,11206.9008096483) (-118233.993544735,11902.047064036,11701.1261230178) (-132981.951636451,-3527.40036157896,8400.96696546285) (-157596.494609083,-36348.2273309774,3349.90541257295) (-199109.497693046,-99402.0761118627,10982.2216294358) (-238803.242729903,-97939.540907698,-37859.8321358571) (-271183.451723054,-39697.9219570049,-224001.429023363) (-237447.939084786,-12426.0019612747,-557303.077298595) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-113854.919296247,32908.1993323666,2828.75788105511) (-115679.727544836,31321.7802841625,4656.93685681666) (-119709.338951011,27595.2702841917,3708.61293725846) (-126726.930362444,19772.9585316502,-3727.08904206935) (-138316.36919189,2017.32752103726,-24416.2196427024) (-161241.704725242,-48394.3613967127,-59736.9723402947) (-243736.11220574,-243870.431607292,12322.0755383596) (-256073.282661468,-256175.81414979,20326.175904653) (-260595.608743255,-58366.9216091539,-196759.44674694) (-231804.69840495,-13183.7780278234,-544979.819599382) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-132526.391314824,38318.8455908014,1288.76296555965) (-133860.959508224,37084.639032413,926.222271238112) (-136654.663780971,34374.7930529633,-4106.80622879523) (-140781.877253943,29280.7358806316,-21502.9394140955) (-143790.631884059,20097.1630949244,-74837.98036279) (-129747.733131054,4988.04352985225,-255224.370391565) (6.27441439105279e-05,1.69307785035832e-05,-4.18597939572815e-05) (-28.2898817522234,343.83070738196,218100.994165416) (-218332.410817714,-5226.49165303644,-151613.000111965) (-221632.503109442,-812.44401351331,-531940.037874943) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-160476.773386445,34893.6057920829,109.869374235336) (-161344.288930441,34208.0536654052,-1763.70139224397) (-162998.260087293,32888.5280650617,-9147.74467186708) (-164773.789513484,30899.6067696966,-30647.4912992716) (-162726.122002245,27915.4367139037,-89899.4832096969) (-137888.485217765,21553.6570485921,-260171.31017188) (5.7102071436457e-05,2.13247941945335e-05,-3.15706071417107e-05) (-405.314779317485,-269.661945218157,212452.673599524) (-213100.304554072,14734.8216523938,-147266.250566525) (-221530.892797133,6230.23451026094,-531234.607491261) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-199541.223939328,9016.55426538702,-534.086661704956) (-200039.226173032,8877.11729655626,-3012.5447647382) (-200765.245751377,8990.69041349504,-11019.0885263956) (-200748.241546783,10362.5965254341,-33543.802533908) (-195077.301777989,14811.0814325962,-96219.785675113) (-161881.744625861,22345.2292280686,-281702.135029426) (0.000156766158319643,-5.87379329628368e-05,-4.32323974363309e-05) (-335.142738031689,225467.801949518,227480.551215094) (-228117.593937269,45943.2840438889,-155895.820427386) (-230561.346225046,5318.68526839376,-537624.754395235) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-246980.190489799,-68600.2431740297,-617.851549532084) (-247212.049704166,-68356.8503061666,-2811.32804940559) (-247372.49243644,-67209.8695015611,-9540.93142280806) (-246347.0162828,-62908.978609069,-28958.6594647821) (-238913.506320954,-47977.6503204061,-88616.3024779888) (-200670.280457265,7740.2236209308,-304007.809842123) (-461.67391194379,251261.931043969,225415.104749653) (-226139.712237767,53993.6252765937,47921.2713346079) (-285180.583170728,-26882.076403122,-196650.882617305) (-250076.095486657,-34274.7928559129,-543133.230358911) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-283561.903201747,-252248.645420117,-373.605156425037) (-283671.214527675,-251948.398253558,-1646.3373738968) (-283640.499891323,-250889.010889486,-5195.03588040578) (-282851.575962228,-247579.733790983,-13899.5381555918) (-279176.229435339,-238354.788594857,-32854.2191469105) (-267769.013487196,-214696.627701604,-60470.7755274532) (-252112.881896771,-167146.4072206,28066.0408131798) (-290113.998369998,-198414.560957432,-33033.1077314207) (-312349.402021005,-203084.835354287,-204111.614699897) (-256135.521111388,-143714.021149804,-508941.213324593) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-244773.716255114,-580345.454069446,-128.027997282142) (-244820.167765063,-580106.550366736,-619.964224793402) (-244778.270177596,-579395.972868765,-1910.68134932227) (-244453.357400632,-577429.579463601,-4637.37996618051) (-243313.518485412,-572794.630997232,-9203.44395482958) (-240796.174001803,-563593.50340648,-12880.4467120767) (-239857.354697442,-550802.687201966,-3209.53362653782) (-253122.880693164,-547650.988551495,-37736.3368255075) (-256779.165711641,-509921.300341684,-144747.48343386) (-205390.570894684,-365174.050804297,-365210.01542038) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-100078.210962059,4714.56585610786,3472.92618110279) (-101938.472606168,4251.7426075447,6504.72573980908) (-105874.161239518,3134.4055991151,8528.22174807029) (-112384.824040115,1101.95151029723,8425.2012903414) (-121994.232265839,-2390.3381910053,4188.95511554972) (-134960.665902226,-7759.31552180278,-8077.84651452128) (-150947.571840891,-13647.6531191623,-36364.8621215266) (-165930.806732888,-12161.163111484,-98139.347556258) (-164640.655642567,-6318.97775763049,-204703.32428863) (-117170.167324077,-2337.84242343226,-326549.177998202) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-102531.655686507,9171.23059656574,2968.13232949524) (-104146.988455322,8295.79816625095,5375.97957707796) (-107550.672413397,6180.73820325335,6451.37961011824) (-112902.30707117,2050.90301987729,4899.88625922538) (-120362.724690186,-5820.69375208039,-1210.11428700815) (-129826.709704399,-20651.5530399637,-14013.5819338904) (-141278.821148402,-44614.8442986344,-34946.8287617661) (-155425.846872941,-38121.795293915,-92297.3278402453) (-157739.045462407,-15821.4032379148,-200735.362462881) (-114060.793199086,-4963.68649477706,-324272.669625655) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-107677.426419724,12794.7180343902,2060.39327619935) (-108845.502080431,11666.1908086104,3271.30081371371) (-111129.881671389,8941.26961593911,2323.22403372439) (-114136.232409899,3290.66901186856,-3014.30309310299) (-116747.913497459,-8949.08347678368,-16119.9515073909) (-116295.186143436,-40034.4343639493,-38038.3786490423) (-109184.067765255,-144030.694862572,-28547.9580128995) (-120212.89512431,-115237.44308727,-70022.6578251403) (-138036.093557558,-29122.2998905609,-189869.119337994) (-106152.56242597,-6774.66953675965,-319353.512954834) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-116168.553258478,14189.5957203603,918.756276258876) (-116729.560558844,13093.2396713858,541.540427490975) (-117470.591130041,10584.1630374206,-3340.10081495941) (-117106.125567429,5653.76482181228,-15324.001419916) (-111826.875145027,-3506.46731011727,-47256.1116334497) (-89483.5695100505,-16910.4233147807,-142138.257897811) (3.06118398472753e-05,4.44264675233898e-06,-1.50094085253585e-05) (-453.180662417406,-127.249127372367,15974.1290260211) (-90057.3870193444,-16096.9215493804,-167589.471039062) (-90507.9116550745,-2981.24910197646,-312679.678223734) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-128603.300357481,10399.5075561404,-133.002793122498) (-128551.709681734,9635.08006130113,-1984.09300952848) (-127790.48305913,8038.64487234541,-8302.75556629593) (-124215.302230487,5319.70800328328,-24535.273771223) (-112314.513017589,1201.25136790377,-60719.1113157114) (-78883.8453629529,-3118.55672537919,-125374.865673209) (-3.2527083008382e-06,2.92995979309964e-06,7.22135843297058e-05) (6.73723466374069e-05,6.13552226908117e-06,-1.99307743776961e-06) (-2.79139785199039,67.9108450814053,-154487.390071) (-68644.8915704688,-660.415433654384,-309795.835278265) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-145225.274775306,-4007.12095654788,-844.870098449771) (-144686.655761167,-4307.40163347273,-3560.02157295012) (-142772.872797273,-4729.66586144156,-11017.0981291836) (-136931.503433999,-4893.18006924847,-28646.4961361349) (-120893.906520602,-4243.12986821165,-65034.3303816577) (-81440.0584623654,-2295.61646526933,-122305.697397166) (1.40619771474076e-06,6.85742100947511e-06,5.63989622940234e-05) (5.03385062986128e-05,1.50315265782002e-05,-3.10509383415871e-06) (-200.288299564821,-117.404882521128,-155253.256871974) (-65517.7991974087,-2724.36245424709,-309202.403451113) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-164285.535726422,-38159.8608848376,-1102.94828461359) (-163509.256519207,-38024.9137830402,-3915.40578886399) (-160970.335535737,-37317.5530035943,-11122.4288623604) (-153912.070271738,-34892.6753467118,-27959.1048599457) (-135518.669645617,-28673.4747554681,-63087.3921050653) (-91123.5423936538,-16132.5636976835,-120008.647104861) (8.97496567297797e-06,9.20298157050427e-05,6.71832631699422e-05) (8.74663356751686e-05,-3.26100093551633e-06,-2.25397106629847e-06) (-543.788317693493,-10859.5501762342,-157916.496197224) (-70548.2093681206,-14056.9776524441,-306597.017855947) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-179416.582485104,-104806.870442635,-916.598446894939) (-178631.092085679,-104412.748328202,-3109.72152022583) (-176125.105608115,-103060.360435297,-8614.30091684995) (-169225.745501807,-98981.9098659241,-21646.3371786284) (-150975.950371083,-87755.0420216853,-50502.3258622768) (-104540.264207308,-58885.3876500308,-103879.51815989) (0.000106956218880235,-6.25075090102762e-06,-5.19232317612217e-06) (-305.954301250848,-9501.80517878063,-10791.4611238471) (-91989.9231755218,-53674.1967195332,-161167.474575755) (-92484.507238617,-40144.1562791029,-292671.884197133) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-174934.872289825,-212918.807377748,-515.093976807812) (-174330.652089441,-212561.529096832,-1706.87564640864) (-172441.84349703,-211490.958931295,-4474.93354470371) (-167354.108359719,-208651.319301351,-10302.9917117875) (-153784.238115907,-201909.522197968,-21540.5028549324) (-116279.459115221,-187099.709456954,-44815.7354199844) (-785.010104862808,-154287.884718416,-9764.526421075) (-93484.3352041402,-160877.159633139,-55018.8351325741) (-126236.053203175,-147155.292932501,-147651.087737435) (-98590.4714095422,-92791.4601565273,-252548.833561859) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-122601.697218095,-334899.741440596,-191.084974175291) (-122280.599689505,-334654.715269093,-637.466877485753) (-121317.493031074,-333969.19171423,-1620.01124108998) (-118916.057777022,-332320.574882751,-3488.0552833007) (-113182.694368159,-328840.011248233,-6688.39035028105) (-100538.725225502,-322137.308266035,-11908.2403174999) (-79378.9052181115,-310301.565249079,-16373.0092661766) (-95117.3630929541,-293984.285515626,-41271.4009839023) (-99190.9188254032,-252766.292459972,-93248.6483426844) (-72186.3735886012,-159572.838923277,-159671.466882025) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-103933.464329241,2307.50679256158,1547.74657462448) (-104962.930936686,2051.95407434254,2520.25083079972) (-106941.605354056,1493.89817648596,2093.79676885026) (-109852.478745488,566.480952629468,-1005.02947840663) (-113413.818176144,-870.818934330754,-8714.62463377166) (-116980.370163495,-2735.10684268858,-23959.8135298115) (-119691.671833536,-4050.60946578148,-51165.1040713859) (-118780.005396824,-1716.85553285616,-96599.0498745923) (-104889.086820543,535.963490502511,-156886.582187108) (-65867.6519114336,748.514464570802,-208937.612064341) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105554.665871907,4036.97485604743,1293.54212191842) (-106338.289537973,3567.19313389758,1969.60414501277) (-107751.46378442,2538.13399619613,1126.1596963264) (-109441.393050733,721.609978376372,-2489.88334985998) (-110720.928948798,-2350.3372451069,-10652.1607804703) (-110629.204328178,-7227.20430944383,-25357.568689939) (-109188.034939814,-12588.2230604366,-48910.7413038672) (-108764.311096197,-2941.11435945477,-94348.018254011) (-98722.3518054846,3852.32219435738,-156681.070614781) (-63180.3582553386,2929.29099027369,-209742.282084237) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-108815.96816089,4337.81769271449,837.698904500171) (-109162.547465351,3763.0651843056,958.87223901213) (-109429.981684178,2513.96939322338,-716.863145221403) (-108676.130891958,209.133048487667,-5664.48773327643) (-104932.498480806,-4153.05656151889,-15677.1834335151) (-95068.0793496179,-13313.2433533344,-30818.2511834486) (-78249.066567038,-34981.4765779709,-39359.9988641295) (-79364.9300290208,4461.9462311558,-87611.0245500295) (-82997.2241285736,18812.4366824546,-157610.008467116) (-56997.4799161587,8867.91264329734,-212703.712629942) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-113857.425656805,1753.75680707849,272.933283961686) (-113626.360005583,1242.05870794746,-309.260792939891) (-112397.952516465,215.384870755189,-3083.31488404844) (-108359.03235053,-1487.61203096767,-10133.6630214945) (-97167.1811513295,-4030.32249316315,-24916.0910835464) (-68785.1670913937,-6323.35586518891,-52604.3809903503) (2.60207494694876e-05,4.4581899995413e-06,3.53372218963409e-06) (66.2764980235871,282.536758374104,-73405.7699626032) (-50923.1813928825,73926.656071329,-167654.194977943) (-46504.2337359506,18894.7014455367,-221684.661699313) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-120515.80749223,-6129.59371122731,-204.142346943674) (-119717.39074886,-6423.99673857788,-1372.4058332911) (-117187.089935269,-6891.23484660374,-4869.17923979233) (-110498.428641581,-7321.47026160057,-12752.1945980643) (-94525.4902897584,-7301.54509242188,-27269.9947266365) (-60402.1064317749,-5618.1523945878,-46456.9371284157) (-3.07187099826713e-06,1.81186576352149e-06,4.18002270970758e-06) (5.91374364680583e-05,8.73602301398221e-07,1.16848743932265e-05) (-480.983117609714,-71.5828593625059,-222782.041106531) (-34326.4070412158,2523.04015706278,-240728.864347314) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-127991.802418441,-22898.2476019059,-464.818466188575) (-126801.134301544,-22932.848705452,-1841.48795893923) (-123433.139185988,-22719.396970692,-5353.05944614008) (-115199.285031619,-21652.6405566033,-12754.1075535173) (-96746.1480938883,-18626.6003127579,-25576.8107598944) (-59933.73919129,-11804.0390703923,-40897.2433551661) (8.45875150320728e-07,3.90284742159201e-06,-3.68830305847488e-12) (4.21012696123764e-05,5.68508734770645e-07,8.54232656456074e-06) (-403.607684898656,-328.70226491054,-220201.612188106) (-32208.3329512603,-7682.57325961719,-243305.465017574) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-133736.142009233,-53034.3589177686,-413.282401332385) (-132442.545879722,-52866.686140913,-1546.15560536102) (-128844.920436019,-52135.6212778603,-4255.34639790958) (-120279.423643935,-49833.315473471,-9707.31810884636) (-101364.815269154,-43751.3142499076,-18736.4585481575) (-63356.8016831317,-29277.1585695454,-29030.0797595258) (6.79025133233937e-06,7.11464671905745e-06,-4.35143800124068e-12) (7.36510611004339e-05,2.27559175732287e-06,1.21081872007446e-05) (-291.76677662765,-102049.606623742,-227503.31494361) (-34212.659974659,-35842.7824937741,-235678.655102929) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-132342.047666368,-99947.9772736516,-160.916462854871) (-131223.170431143,-99736.3352284981,-699.189029800877) (-128092.572363416,-98998.8676953946,-1868.47585696712) (-120654.319874985,-96711.9945619471,-3561.2223953108) (-103956.810987896,-90109.2796695609,-4222.39635884475) (-68266.3963213278,-70128.6845910319,355.261776659674) (9.4661237174428e-05,1.43117386795249e-05,5.06270962448743e-06) (-289.511932306997,-102167.685982857,-102086.775551178) (-47283.7794770673,-87562.4307931202,-161280.095080254) (-43640.5064288071,-46075.5780904536,-199891.300293385) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-114871.341744262,-160084.012197147,72.5043779305161) (-114078.705640419,-160034.202866616,118.425567018838) (-111923.292743691,-159917.631106682,518.638224966748) (-106931.715189374,-159763.310801403,3147.56129407812) (-95806.0536903106,-160784.869738752,15844.9669376699) (-70399.721533426,-170795.829346869,70632.3741117077) (-656.009918065291,-232259.919348474,-102296.787462167) (-48493.5871192635,-161972.211372704,-87483.0101571958) (-61778.1399875019,-119779.438725733,-119723.915440263) (-44385.6062361725,-66251.9846993286,-153752.374004756) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-71036.6725483757,-211755.973443007,106.936576147972) (-70624.2568642413,-211856.287141718,272.678025985782) (-69565.2001723018,-212139.644461612,742.39852214438) (-67255.5384355067,-212903.306656023,2221.87503524993) (-62527.4802006854,-215138.813339391,5920.60446842854) (-53619.2431734922,-221064.90953404,9270.20260358556) (-39977.6947707214,-230374.084406691,-32016.8427855909) (-45510.0937053429,-198380.727916986,-45215.5956289227) (-44821.6129705699,-153254.237935008,-66110.1022744716) (-29944.3495214069,-87237.5680543377,-87366.5429866645) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105280.120526527,803.62604834947,543.030148932091) (-105751.574794829,764.521087513033,567.152919560442) (-106481.657045446,795.495796199377,-688.291185249294) (-107224.79672009,1048.8689724909,-4364.84218313513) (-107407.924832714,1801.92641797188,-12172.6619445361) (-106193.208443873,3563.54793887926,-26523.3716030363) (-102599.494687472,6419.80383872034,-50035.3525878182) (-94617.5435354369,8267.68610667515,-82465.5005558833) (-76511.6345740757,6686.0527508639,-117529.005553215) (-44192.4866035995,3434.77217387747,-142638.943034936) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-106216.762533174,924.497861694404,541.224847919562) (-106504.598332502,881.150644072892,590.904085889921) (-106843.810199867,984.364711036758,-505.618413501109) (-106776.977882654,1562.59988714052,-3683.76449622835) (-105522.123343893,3432.43409404027,-10513.0777772051) (-102160.6170015,8330.20573487144,-23748.3228998749) (-96615.070784339,18367.8116244829,-48269.2948411154) (-91195.6181235055,26487.7530370476,-84058.0547441888) (-74937.6896725922,19618.8980585523,-120775.562184776) (-43571.8766571004,9146.85559598411,-146096.127205122) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-107893.093956439,-518.643753158379,520.267410400064) (-107883.793417654,-550.613120890225,673.277127664171) (-107454.973995476,-341.947750093775,24.5819000903459) (-105772.082158788,597.549286305286,-1914.41623224151) (-101273.351310758,3641.02465389667,-5782.15396214645) (-91731.5096684061,13041.5546607708,-13830.0725692561) (-76752.226361942,43322.9832408672,-40282.084390738) (-86025.8493313652,83871.2122281956,-91004.6242795435) (-74020.5406844307,50882.7803505856,-131245.190015714) (-43225.648027757,19381.4007718555,-155251.567079998) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-110148.452774242,-4733.45519318212,505.838557460857) (-109756.145188853,-4741.73402793804,826.744647775823) (-108314.67622909,-4473.14335893063,874.663969236472) (-104399.77978441,-3528.46215844472,1041.42284786803) (-94686.8037395349,-1321.70125369573,3523.77134367206) (-70662.567945123,2142.069502152,16300.6573560223) (1.74811009736021e-05,-6.03103644491999e-06,1.27287514329796e-05) (-100031.960235306,30.9372818186163,-124141.653516944) (-85650.2328556973,124302.517332172,-162834.339035723) (-46281.6171974029,31069.1280334144,-174744.682835809) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-112427.585130897,-13362.5133258737,540.835771356867) (-111662.250068707,-13319.0982723156,1063.05933558244) (-109362.602481019,-12964.9618156265,1730.39033802759) (-103618.58296597,-11859.958010452,3182.04051442029) (-90178.0082554687,-9405.92883088409,6918.78605731894) (-60296.8152480137,-5067.80177327194,14023.366148983) (-7.10348090445298e-06,3.14828424204527e-07,-2.76686583816618e-06) (3.9494840564143e-05,-3.19601121875058e-06,2.04244444299554e-05) (-156817.423051359,48.0968725047683,-256154.204415367) (-58141.5472694129,4696.08932385937,-205966.025477622) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-113594.367435942,-28372.8084938556,612.860185482001) (-112616.38978971,-28308.5090875417,1417.52648887656) (-109882.785670057,-27879.0930894853,2781.30424680757) (-103386.158600561,-26499.7507161871,5607.97052148468) (-88744.5440880077,-23023.7665184636,11224.2042031851) (-57721.8619582433,-15061.3591113081,19005.884308173) (-5.07903794688408e-07,8.81371414062671e-07,2.55295446626509e-13) (2.84814413279602e-05,-6.80514966903594e-06,1.72289669899969e-05) (-148703.374529647,-131.708193209627,-251557.628535221) (-58691.3088986,-9632.78388507694,-210745.779378954) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-111507.522954949,-51399.1925825115,797.765034375762) (-110537.503372715,-51372.104309489,1956.31774931538) (-107894.069202285,-51060.7932127626,4187.16663885731) (-101840.580337941,-49853.6384937674,9102.21111044539) (-88472.2358870784,-46006.2326765771,19192.0978864821) (-59430.5350961158,-33941.5928490604,34146.0650372152) (3.68761518809888e-06,2.52651791501948e-06,-3.39713689566483e-13) (3.97563712278663e-05,6.10430507919494e-06,2.09852347846227e-05) (-162977.505521856,-148834.432808115,-261025.472849716) (-58550.427807995,-45156.8469787045,-201163.641922755) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-102497.633412156,-82172.4873194192,928.880482698646) (-101743.787490501,-82296.5749437308,2373.96817629695) (-99741.3984860675,-82496.6879286706,5458.68901485688) (-95456.3286858001,-82597.4071979627,13004.4665298663) (-86731.2683780255,-81537.8993715635,31310.5906149811) (-67399.9203917453,-71795.9922859821,68298.5141223198) (5.46333450823898e-05,2.92602411279856e-05,1.05221872536746e-05) (-119686.571409004,-149948.301872565,-148719.795959626) (-85792.3557931811,-101768.323395625,-157277.329056012) (-43402.7097684469,-46670.1390736278,-156001.833621444) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-82055.9582909678,-115823.425396987,835.554624269352) (-81593.2911201921,-116178.114142458,2231.67930277012) (-80466.8265093233,-117166.577057967,5445.10219769512) (-78566.532587309,-119683.888279805,14166.4006774676) (-77251.7851276614,-127069.546140757,41143.778884013) (-87838.1726344095,-153540.741438644,140326.979137658) (-182128.072671594,-271069.238108993,-149970.943374629) (-89382.0909868911,-158568.084022825,-100462.657356736) (-59405.2789580808,-102559.975883164,-102043.865898628) (-32199.2309512091,-51699.8013492228,-109200.578907991) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-47030.8338209058,-140308.167098961,478.902974504513) (-46808.1298981403,-140802.00165408,1286.66352002821) (-46311.8335308851,-142149.609892531,3016.329713175) (-45580.7147509221,-145243.708575588,6901.32632437734) (-45265.9085331932,-152207.112208576,14777.320724699) (-48317.7797705135,-166992.937647842,22928.053530918) (-60714.2161484125,-189948.276294482,-37456.3869059075) (-44642.2796075919,-152509.074182266,-44383.210844219) (-32464.5880541343,-108202.898094725,-51097.3135490896) (-18175.0779688426,-57202.1224640653,-57364.2639868118) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105414.042640163,12.1211415475046,121.800972091945) (-105628.906856081,129.983320253431,-130.850286908546) (-105852.753816885,579.477043050135,-1339.23055852446) (-105770.803324163,1640.24785655376,-4433.47181100692) (-104772.881319887,3767.86340926629,-10836.3787330986) (-101954.424380634,7610.37715972585,-22685.5399560665) (-95937.5189573137,12412.7372803522,-41760.2529665761) (-84064.0056820432,11708.2268948055,-64022.0177147765) (-64000.512762225,8272.52929324279,-84805.6688198716) (-35074.4910105974,4076.9409355588,-98000.6053484294) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105887.180921176,-592.600242631622,275.139772181455) (-106018.90996382,-353.4935280503,272.928251806037) (-106141.002905857,532.484417930875,-382.886417084526) (-105908.375292787,2743.42951725545,-2354.67066765363) (-104872.158913097,7808.47451124652,-7045.24620042702) (-102516.885023883,18859.2206576297,-17937.8216759479) (-97916.5661260384,38315.0950587602,-42538.6841126573) (-86273.4623209261,31734.45248675,-67487.0655071788) (-65705.3036075049,20564.7267528928,-89011.6490319142) (-35945.8909302516,9505.50775272976,-102066.201575934) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-106467.062093198,-2571.15880102353,552.526695151399) (-106530.766648284,-2244.47410603951,1090.48050377105) (-106488.762560229,-1050.64311507647,1707.39660153453) (-106036.188394741,2101.34008584354,2613.59226889695) (-105068.290647182,10333.675401361,3883.33071520604) (-104628.280794611,34244.0738487285,1395.24865031071) (-107931.565345998,120112.17662802,-49222.4939348894) (-94682.4992174261,69867.2013282005,-78698.5928902746) (-71338.8211309109,39240.9441842462,-100056.529875145) (-38498.3754720546,16320.6235908082,-111598.918268922) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-106824.6765123,-6820.83682418297,925.901761218715) (-106806.369218076,-6492.5669238728,2224.21860827789) (-106526.026766914,-5369.40172665674,4754.32775768453) (-105704.892991191,-2608.874220204,10769.6552705079) (-104596.032749772,3317.16728784086,27695.3923942616) (-108496.603161452,12650.8257627463,87122.6756965723) (-159957.77866929,119.854459659109,-99591.0348876848) (-120272.363740472,99901.4944427614,-109384.924497086) (-85886.2870668028,53120.0316970185,-123027.957798745) (-44191.4772721163,19245.6127172898,-128043.086850518) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-106233.435686626,-14307.2993449767,1292.31307652398) (-106108.167372902,-14074.8785421861,3320.54199903116) (-105566.933167881,-13295.4431435601,7450.91410279381) (-103982.256600156,-11432.8794966202,16638.5930133954) (-99370.5862933087,-7791.82994506655,36940.1682841428) (-82808.5067925835,-2366.98875577956,74469.6743472367) (2.61721076918388e-05,-1.11179641984503e-05,-2.42376325845198e-05) (-159499.425631446,-58.5186480512929,-156247.809120346) (-111193.311362709,8210.27777241557,-156962.166884387) (-52656.0080437984,4208.97004636933,-147411.063439079) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-103529.934024904,-25919.2591567946,1547.5264007815) (-103377.966696539,-25864.5724066228,4098.79717204704) (-102786.025633068,-25561.9383527752,9268.53234427308) (-101134.011355681,-24652.5996064692,20236.1052092395) (-96106.5496918531,-22461.6080982321,42267.8889662506) (-77964.1582242485,-16559.6520446148,76702.8485210871) (2.34069903357334e-05,-2.10166756178799e-05,-1.69426811790038e-05) (-150034.20345433,-18.5313746107074,-148006.988805758) (-113164.0911478,-14322.31307486,-161013.681340337) (-54341.0875352239,-9454.22762625401,-151700.70503109) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-97125.0114007017,-42021.4059204925,1719.63520945071) (-97010.1747165133,-42183.4665225349,4511.20066916093) (-96615.0307978135,-42510.5918170296,10180.8157289461) (-95665.0392852321,-43079.4682377138,22432.1433074778) (-92740.1839064889,-43920.0680917862,48158.5513204417) (-79571.2521473384,-41637.461299191,93377.0776262469) (3.1094810676938e-05,-2.99900331831844e-05,-2.22316953181503e-05) (-165410.46683462,-119222.638547756,-162266.460070871) (-112035.625580467,-71413.399752831,-156117.25333429) (-51910.9954886065,-29934.9953421887,-142275.917937743) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-84763.5634494842,-61417.0316274781,1661.55574430914) (-84735.6315257893,-61832.4199991827,4302.35325624671) (-84731.6420827582,-62887.0449960238,9669.05003192851) (-85165.2592498854,-65347.3648250943,21645.8771833947) (-87838.7318793692,-71682.1741387196,50515.4467316756) (-102127.159095674,-91758.7625522436,135363.986688663) (-184771.729522788,-181269.346383444,-119154.479494312) (-124516.439958425,-119168.289055618,-114378.960437019) (-81943.2362100168,-75087.4935336403,-114553.986239369) (-40260.7766738503,-35332.1977810002,-112298.716895164) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-64312.2746874031,-80461.3623101762,1300.64707913429) (-64358.2986509392,-81095.985895599,3329.22050629989) (-64600.41163609,-82730.7925667254,7306.55320377169) (-65603.9910656011,-86411.358516455,15408.0053734269) (-69297.49442485,-94740.5017437204,30512.0422756152) (-81500.8510254296,-113604.944064807,46020.9021791977) (-111229.735725128,-149156.003925718,-56990.7772249946) (-81948.2871819377,-113420.210548856,-70172.6595367174) (-54710.3797751726,-75351.9897707151,-74603.0624825493) (-27764.2477542382,-37561.8982821594,-76808.345178358) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-35198.0678992622,-92992.7859362563,698.657704439349) (-35244.913757385,-93729.5636374191,1769.0193055021) (-35424.0411481017,-95581.1437848312,3731.57814082308) (-36047.7289099682,-99387.9526643038,7175.18644772145) (-37920.4245382812,-106607.406486511,11696.6071956019) (-42523.8780899133,-118263.306709195,10561.0681593884) (-49227.8729275083,-128820.305096045,-21260.9738911973) (-39739.7452362075,-107539.447364996,-32044.2714464424) (-27658.5976683182,-75516.9315081036,-36685.3200948687) (-14380.0835228909,-38928.9363836892,-39113.2764392923) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105130.610910556,-260.447798422724,-22.9839311889055) (-105289.76940014,-100.34669405316,-261.774693076214) (-105436.284989303,431.550869328602,-1109.79438998081) (-105194.318464089,1588.39498855625,-3274.67423861373) (-103925.501235802,3708.49973052812,-7830.55405322908) (-100550.308549927,7070.46459785513,-16305.1344817893) (-93268.0557346606,10452.0389037783,-29426.6366082199) (-79547.8550303469,9510.01946993083,-43452.8067298434) (-58624.9225919983,6560.73103138658,-55389.1279314605) (-31252.050004998,3223.91215000193,-62435.4810870596) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105339.425911849,-970.40324707762,162.200439328629) (-105537.174862317,-653.250206735972,233.368850504836) (-105836.204430299,392.725518857518,-32.6042745829412) (-105987.651487188,2805.71275152585,-1170.64584314946) (-105600.404507787,7749.80712487552,-4483.70764280723) (-103844.669463098,16875.3849534974,-12960.8435592357) (-98402.4153033732,28403.6714118467,-30426.6268899666) (-84151.2870681101,23391.8290561972,-46430.6117290496) (-61757.4365170541,14936.9923854664,-58754.740173584) (-32792.7929788037,6957.81832388445,-65641.7442989175) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105289.458530155,-2680.08884074928,532.082030626223) (-105634.213390375,-2236.36779107349,1218.64635705334) (-106298.155605897,-819.343765494986,2240.10868707298) (-107372.719219294,2684.97488767717,3697.37737547435) (-109191.953944201,11003.0536173513,4567.79418001635) (-112154.440605235,30524.9427839914,-1555.60383985323) (-113713.359048111,68167.1506784975,-35537.2894043899) (-96241.9843131511,44313.2888947943,-54899.2641472702) (-69294.1192726375,24692.1774906111,-66699.1511106824) (-36262.6698477073,10623.6853728678,-72600.7237840128) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-104563.841811535,-5958.95341167298,1018.02987016066) (-105101.842303203,-5505.18702277147,2582.32218698599) (-106270.093965082,-4130.65064822443,5637.69626788232) (-108727.895669364,-621.042274674016,11966.7161084115) (-114441.777679086,8776.8478093352,24038.6668457421) (-128403.373498525,38484.3973151778,35985.9826516271) (-156473.342294086,160107.784769765,-59439.0878148362) (-121504.099910747,60641.2229764478,-74535.2857262091) (-82761.7404963115,27842.9726022372,-80810.6274083269) (-41891.5974315654,10840.0648444028,-83326.8867204153) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-102348.272200134,-11328.7696497925,1484.65275162727) (-103026.83029371,-11044.9766303045,3943.10527996884) (-104669.395904742,-10221.3472719134,9136.26464052143) (-108523.57743461,-8297.47639295026,21354.0195932516) (-118677.446243665,-4267.19490524287,53704.9222581879) (-150757.338509517,2586.41092516294,157551.740365142) (-278349.15256043,-249.544127071693,-158943.761933104) (-159774.060479946,9360.96522269415,-107388.869330847) (-99150.6597903643,6291.92048062128,-97880.4687815764) (-48028.3892935988,2591.08176468248,-94259.1044520596) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-97544.1564925336,-19091.1798398113,1776.63265765169) (-98321.0387365559,-19091.5604452674,4766.28851263308) (-100268.969549573,-19025.0176109317,11052.9027681553) (-104907.012075366,-18843.4857443633,25371.9128392516) (-116757.394411971,-18759.1808300132,60514.7434841375) (-151632.353029631,-17916.6684481407,154686.01766283) (-272497.003140199,171.012767819176,-149315.529703824) (-164200.566743959,-15277.7542300765,-110510.446961419) (-102701.105334937,-13065.2647747448,-101616.247518912) (-49559.0864807154,-6951.22652298779,-96855.9402857443) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-88900.7370609285,-29184.5147795894,1869.06060000478) (-89687.7332768337,-29476.9231130879,4931.98182814763) (-91715.9198227121,-30225.7671095959,11233.6203517118) (-96549.111236244,-32186.4252875011,25460.6318458642) (-108769.785713962,-38639.5333971145,61370.5862204369) (-145183.712066584,-63792.6629548582,172859.040646405) (-283795.466076703,-184021.760968499,-164700.638245989) (-159136.581678102,-77944.6789683475,-108307.598664246) (-96820.5525182827,-41107.8005125555,-95480.1359886159) (-46242.7322274048,-18211.4157229679,-89888.2100498385) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-75080.4126318009,-40558.5063513224,1690.84075405025) (-75762.2628574744,-41073.9109770153,4314.45994966218) (-77566.9247537384,-42373.0777738181,9297.05328486607) (-81688.5604166895,-45384.8637087404,19018.7928729085) (-90974.8386300154,-52732.0117744567,36247.3780008947) (-111731.809836727,-70712.2325111488,52771.5982982403) (-150303.269975953,-107205.695661278,-58512.9265558156) (-113348.003071944,-76224.5966253491,-71401.4457852999) (-74367.9903687282,-47592.8184172587,-72491.6737218884) (-36647.3405217063,-22696.4129496409,-71620.1126473508) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-55136.432663239,-50998.9876604698,1264.63928498549) (-55633.8343435057,-51639.1159949524,3105.37999548921) (-56970.4636586181,-53221.3302872071,6323.68453140518) (-59850.8742782789,-56515.6400360355,11701.3440713769) (-65661.9923481751,-62967.8000469679,18301.6302672119) (-76051.1577443687,-74227.8163952621,16367.5208702629) (-87847.5709741733,-86748.5245036944,-27471.8150382779) (-72109.9665557693,-70889.7938623182,-42644.9384274745) (-49442.0338550985,-48087.203918274,-47418.8988465286) (-24992.7302076035,-24072.1564887309,-48814.6728540743) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-29388.8761850178,-57467.0755009867,658.896126272834) (-29663.2649524598,-58153.2594884864,1591.39081488046) (-30351.0376477265,-59803.783691636,3100.84071893541) (-31775.5179517925,-62963.2533150767,5276.24303979905) (-34396.0483590349,-68261.2603774734,7045.32719105616) (-38308.1287052146,-75289.5104540329,3891.27186512708) (-41213.9937645218,-79214.7217757612,-11656.4100257925) (-34929.7587843787,-67538.5025199691,-19817.6878199693) (-24581.9589259175,-47695.6693100302,-23285.8611706145) (-12627.2646183772,-24475.376870356,-24635.4596935025) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-104944.178670742,-189.085016920047,2.65277710578227) (-105090.634903564,-85.0685771371795,-111.413142331396) (-105249.153164208,249.449401563674,-547.994368988913) (-105011.896625062,951.969309845533,-1682.38551786235) (-103676.25391753,2155.72231415638,-4087.35515028785) (-100023.507521338,3907.10163578923,-8521.25781466535) (-92082.1038297762,5412.55231804291,-15119.7620375956) (-77683.203738822,4928.3393007548,-21912.7526298741) (-56535.3617485623,3398.74389436073,-27401.0573676704) (-29827.2647192396,1679.27931198926,-30505.1219654202) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-105008.980578616,-629.73067918504,110.200329030939) (-105283.686077932,-420.013479004286,191.656446511713) (-105728.137595314,235.189291517999,97.8497215741013) (-106134.298317422,1680.90828237134,-484.442420719935) (-105980.944575526,4394.33406071173,-2342.51409953505) (-104077.648102932,8812.58738959491,-7015.02121350611) (-97634.9039735343,13240.9453280274,-15610.9255533303) (-82713.6131157373,11332.4325380163,-23452.692742962) (-60013.7347912272,7376.79630233762,-29174.4468767614) (-31558.9786616087,3484.50603420581,-32213.4879161694) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-104661.535329991,-1622.4101506075,364.756271259748) (-105187.09335082,-1319.83330274396,817.456055446098) (-106262.281106498,-431.151397865918,1447.92224543183) (-108077.291071971,1643.45834909654,2189.94403138556) (-110679.490371104,6043.97449745961,2027.84002154379) (-113200.807846718,14528.3203543565,-2641.52570173423) (-111108.42239417,25554.2780205557,-17559.7950482034) (-94187.3604160239,19127.4088775086,-27409.3952848213) (-67511.4892412714,11264.4477989159,-33079.6768127704) (-35122.3196390246,5009.26219143528,-35744.7831786807) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-103472.261632093,-3400.13444386185,686.14411381205) (-104315.241674255,-3088.35690957354,1668.06709169083) (-106250.432233001,-2225.34458586289,3442.5985476087) (-110070.509280288,-143.006383891416,6571.6768915191) (-117102.266971178,4796.06208320401,10480.0785978695) (-128064.643530159,16322.8473112766,8346.82167258208) (-136918.145150141,38332.5838553696,-23986.6813061797) (-113512.616636875,22417.9276595814,-35268.6833621246) (-78906.2795643731,11517.6348005121,-39377.3312956616) (-40173.6739427307,4754.15613265911,-40840.1487257183) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-100552.853460291,-6175.49415645932,979.940972753917) (-101670.163538845,-5984.39565968511,2519.3129679998) (-104428.27080494,-5487.40382171023,5540.24710404444) (-110291.360172984,-4367.12084060663,11532.1442991328) (-122256.646307396,-2082.52385366057,21989.930299727) (-144662.194899207,1874.50682467887,30343.1271760117) (-175435.609355907,5659.72722444733,-39897.5593975944) (-136059.353237153,5011.45651388886,-46205.7954946892) (-90481.527213535,2825.71880874801,-46183.0120797594) (-44931.7572531023,1113.93846047408,-45639.4264480685) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-94829.8202656724,-10035.1616151985,1145.33123187486) (-96109.1504988351,-10050.0275070948,2999.07484156275) (-99335.0936343764,-10078.651864496,6656.44696915149) (-106306.845055225,-10122.9488807723,13812.1079891759) (-120498.03083001,-10449.5838786824,25919.8044322384) (-146742.180673868,-11221.477161026,34125.6160621762) (-181243.168101263,-10935.1957724354,-40533.2959798637) (-141219.417388362,-10049.6191909549,-48453.3696306139) (-93365.0512514592,-7050.12574641925,-47913.579158929) (-46057.959256085,-3562.38979747183,-46738.3781256165) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-85208.5446464079,-14894.9404454163,1167.58641569724) (-86496.2124728316,-15103.1270629989,3029.1651675997) (-89712.175247901,-15646.5942325869,6593.36296087703) (-96598.786465754,-16937.658769662,13457.7480792784) (-110379.158926213,-20503.0432535591,25120.5806664061) (-135720.517817942,-30024.7547976384,34460.6640543731) (-170490.145838025,-50188.0719843985,-39591.7799723224) (-131386.183811565,-31902.1449545809,-45489.6520752384) (-86446.3039307327,-18497.0904003209,-44416.9360088838) (-42555.8364895382,-8520.01396080401,-43146.2075834186) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-70843.345141365,-20149.2636031154,1017.25566726343) (-71935.1118364456,-20480.9517484687,2567.9293317044) (-74616.2515446031,-21307.7530753212,5278.41496530376) (-80095.0786999397,-23102.4176744373,9849.69215333048) (-90175.9030556409,-27024.4212748169,15572.1346002153) (-105878.009540517,-34680.17491174,14373.7544181052) (-120507.184107559,-44404.3804127178,-21206.0230219664) (-99702.3530737916,-34712.5156431264,-32041.3023315663) (-68077.0493916106,-22442.157139217,-34387.1765697916) (-34111.8143850185,-10872.9926773145,-34569.7239899684) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-51236.0940639758,-24793.252240373,743.650037993058) (-51999.7056292588,-25170.7240234399,1799.2935987174) (-53852.9307719812,-26104.0099110303,3478.01754778926) (-57440.6903286582,-27948.9833661586,5914.39928988962) (-63474.3556515022,-31222.6087014407,7924.95001984015) (-71468.7546294861,-36044.6035420202,4706.97553523626) (-76369.4152390247,-39706.4171915492,-11469.1434210824) (-65169.582121184,-33433.4545942287,-19688.5889045677) (-45769.9861288354,-23080.9214653368,-22721.8723047134) (-23334.0790417922,-11636.2247884553,-23617.2913593845) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (-26978.8564172573,-27581.0721840771,377.800175942908) (-27396.6649805527,-27972.0414606556,912.517641251968) (-28319.5652872941,-28914.1493243589,1691.18469414793) (-30042.6790459915,-30650.8851102666,2660.24753245531) (-32738.1755195617,-33330.1041290706,3109.87012061213) (-35876.9088545677,-36441.8508886926,1075.89761663926) (-37083.4905460226,-37543.1379624121,-5217.88483099715) (-31980.7929249094,-32296.5779166031,-9303.7273680929) (-22801.8681871146,-22971.1095312619,-11193.63004097) (-11742.7734128587,-11811.9883020338,-11902.3577329102) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) (0,0,0) ) ; boundaryField { fuel { type fixedValue; value uniform (0.1 0 0); } air { type fixedValue; value uniform (-0.1 0 0); } outlet { type zeroGradient; } frontAndBack { type empty; } } // ************************************************************************* //
4d26892cec91c94025016176317a18fc3669be6b
b92e8dad9915de1d875abf1da1350ee8e21b6ca6
/homwok/Assignment_4/Gaddis_8thED_Chap5_Prob05/main.cpp
edabeaa46496c144d918ca85f18a82d467c3b578
[]
no_license
bassamelsaleh/ElsalehBassam_csc5_42892
33cc5e4ba4d7c3b471fd7d840aaf4fe34d52cfdb
961898581ba79a590ab20f5601c5552647be2b67
refs/heads/master
2021-01-17T11:34:47.881220
2016-06-06T20:00:21
2016-06-06T20:00:21
52,302,675
0
0
null
2016-04-25T22:11:18
2016-02-22T20:18:28
Makefile
UTF-8
C++
false
false
679
cpp
main.cpp
/* * Author: Bassam Elsaleh * March 21, 2016 * purpose- Club Pricing */ //System Libraries #include <iostream> #include <iomanip> using namespace std; //User Libraries //Global Constants //Function Prototypes //Execution Begins Here int main(int argc, char** argv) { //Declare variables float cha=2500; float per=0.04; int year=0; cout<<"Here are our Club Charges within the next 6 years."<<endl; cout<<"Year Price"<<endl; //loop to get calculations while(year<6){ cha=cha*per+cha; year++; cout<<setprecision(2)<<fixed; cout<<setw(2)<<year<<setw(8)<<"$"<<cha<<endl; } return 0; }
0780c62dc94d1a7a4a56ccb2b1bc68b7fd01846a
6ab9a3229719f457e4883f8b9c5f1d4c7b349362
/euler/e035.cpp
5b48f54d9ef03f850f206ec10ce0ce5e9f5f0657
[]
no_license
ajmarin/coding
77c91ee760b3af34db7c45c64f90b23f6f5def16
8af901372ade9d3d913f69b1532df36fc9461603
refs/heads/master
2022-01-26T09:54:38.068385
2022-01-09T11:26:30
2022-01-09T11:26:30
2,166,262
33
15
null
null
null
null
UTF-8
C++
false
false
743
cpp
e035.cpp
#include <cmath> #include <cstdio> #include <ctime> #define MAX 1000000 #define SQMAX 1000 bool p[MAX]; int p10[6] = { 1, 10, 100, 1000, 10000, 100000 }; bool circular_prime(int x){ int k = x, d = 0; while(x) x /= 10, d++; for(int i = 0; i < d; ++i){ if(!p[k]) return 0; k = (k % 10) * p10[d - 1] + k / 10; } return p[k]; } int main(void){ clock_t ini = clock(); int ans = 1; for(int i = 0; i < MAX; ++i) p[i] = 1; for(int i = 4; i < MAX; i += 2) p[i] = 0; for(int i = 3; i < SQMAX; i += 2) if(p[i]) for(int j = i * i; j < MAX; j += i) p[j] = 0; for(int i = 3; i < MAX; i += 2) ans += circular_prime(i); printf("Time spent: %.3lfs\n", ((double)(clock() - ini))/CLOCKS_PER_SEC); printf("Answer: %d\n", ans); return 0; }
751ee4e1edd1eb96e223bf7ad9fcff0273abc5c2
2277375bd4a554d23da334dddd091a36138f5cae
/ThirdParty/Havok/Source/Physics2012/Dynamics/Motion/hkpMotion.cpp
c246fcbc65334f16b2aebd8aff4eab46417d9c0a
[]
no_license
kevinmore/Project-Nebula
9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc
f6d284d4879ae1ea1bd30c5775ef8733cfafa71d
refs/heads/master
2022-10-22T03:55:42.596618
2020-06-19T09:07:07
2020-06-19T09:07:07
25,372,691
6
5
null
null
null
null
UTF-8
C++
false
false
6,353
cpp
hkpMotion.cpp
/* * * Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's * prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok. * Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement. * */ #include <Physics2012/Dynamics/hkpDynamics.h> #include <Physics2012/Dynamics/Motion/hkpMotion.h> #include <Physics/ConstraintSolver/Solve/hkpSolverInfo.h> #include <Common/Base/Math/SweptTransform/hkSweptTransformUtil.h> #include <Common/Base/DebugUtil/DeterminismUtil/hkCheckDeterminismUtil.h> #include <Common/Base/Math/Vector/hkVector4Util.h> hkpMotion::hkpMotion() : hkReferencedObject() { hkVector4 position; position.setZero(); hkQuaternion rotation; rotation.setIdentity(); init(position, rotation, false); } hkpMotion::hkpMotion(const hkVector4& position, const hkQuaternion& rotation, bool wantDeactivation) { init(position, rotation, wantDeactivation); } HK_FORCE_INLINE void hkpMotion::init(const hkVector4& position, const hkQuaternion& rotation, bool wantDeactivation) { m_linearVelocity.setZero(); m_angularVelocity.setZero(); hkCheckDeterminismUtil::checkMt(0xf0000050, position); hkCheckDeterminismUtil::checkMt(0xf0000051, rotation); m_motionState.initMotionState( position, rotation ); m_motionState.m_linearDamping.setZero(); m_motionState.m_angularDamping.setZero(); m_type = MOTION_INVALID; // deactivation data { if ( wantDeactivation) { m_deactivationIntegrateCounter = hkInt8(0xf & int(position(0))); } else { m_deactivationIntegrateCounter = 0xff; } m_deactivationNumInactiveFrames[0] = 0; m_deactivationNumInactiveFrames[1] = 0; m_deactivationRefPosition[0].setZero(); m_deactivationRefPosition[1].setZero(); m_deactivationRefOrientation[0] = 0; m_deactivationRefOrientation[1] = 0; } // Gravity factor - leave gravity as it is by default m_gravityFactor.setOne(); } // Set the mass of the rigid body. void hkpMotion::setMass(hkReal mass) { hkReal massInv; if (mass == 0.0f) { massInv = 0.0f; } else { massInv = 1.0f / mass; } setMassInv( massInv ); } void hkpMotion::setMass(hkSimdRealParameter mass) { hkSimdReal massInv; massInv.setReciprocal<HK_ACC_23_BIT,HK_DIV_SET_ZERO>(mass); setMassInv( massInv ); } // Get the mass of the rigid body. hkReal hkpMotion::getMass() const { const hkSimdReal massInv = getMassInv(); hkSimdReal invM; invM.setReciprocal<HK_ACC_23_BIT,HK_DIV_SET_ZERO>(massInv); return invM.getReal(); } // Set the mass of the rigid body. void hkpMotion::setMassInv(hkReal massInv) { m_inertiaAndMassInv(3) = massInv; } void hkpMotion::setMassInv(hkSimdRealParameter massInv) { m_inertiaAndMassInv.setW(massInv); } // Explicit center of mass in local space. void hkpMotion::setCenterOfMassInLocal(const hkVector4& centerOfMass) { hkSweptTransformUtil::setCentreOfRotationLocal( centerOfMass, m_motionState ); } void hkpMotion::setPosition(const hkVector4& position) { hkSweptTransformUtil::warpToPosition( position, m_motionState ); } void hkpMotion::setRotation(const hkQuaternion& rotation) { hkSweptTransformUtil::warpToRotation( rotation, m_motionState); } void hkpMotion::setPositionAndRotation(const hkVector4& position, const hkQuaternion& rotation) { hkSweptTransformUtil::warpTo( position, rotation, m_motionState ); } void hkpMotion::setTransform(const hkTransform& transform) { hkSweptTransformUtil::warpTo( transform, m_motionState ); } void hkpMotion::approxTransformAt( hkTime time, hkTransform& transformOut ) { getMotionState()->getSweptTransform().approxTransformAt( time, transformOut ); } void hkpMotion::setLinearVelocity(const hkVector4& newVel) { HK_ASSERT2(0xf093fe57, newVel.isOk<3>(), "Invalid Linear Velocity"); m_linearVelocity = newVel; } void hkpMotion::setAngularVelocity(const hkVector4& newVel) { HK_ASSERT2(0xf093fe56, newVel.isOk<3>(), "Invalid Angular Velocity"); m_angularVelocity = newVel; } void hkpMotion::applyLinearImpulse(const hkVector4& imp) { // PSEUDOCODE IS m_linearVelocity += m_massInv * imp; m_linearVelocity.addMul( getMassInv(), imp); } void hkpMotion::getMotionStateAndVelocitiesAndDeactivationType(hkpMotion* motionOut) { motionOut->m_motionState = m_motionState; motionOut->m_linearVelocity = m_linearVelocity; // Copy over linear velocity motionOut->m_angularVelocity = m_angularVelocity; // Copy over angular velocity motionOut->m_deactivationIntegrateCounter = m_deactivationIntegrateCounter; } void hkpMotion::setDeactivationClass(int deactivationClass) { HK_ASSERT2( 0xf0230234, deactivationClass > 0 && deactivationClass < hkpSolverInfo::DEACTIVATION_CLASSES_END, "Your deactivation class is out of range"); m_motionState.m_deactivationClass = hkUint8(deactivationClass); } void hkpMotion::requestDeactivation() { // See hkRigidMotionUtilCheckDeactivation(), hkRigidMotionUtilCanDeactivateFinal() for details m_deactivationRefPosition[0] = getPosition(); m_deactivationRefPosition[0].setW(hkSimdReal_Max); // speed m_deactivationRefPosition[1] = m_deactivationRefPosition[0]; m_deactivationRefOrientation[0] = hkVector4Util::packQuaternionIntoInt32( getRotation().m_vec ); m_deactivationRefOrientation[1] = m_deactivationRefOrientation[0]; (m_deactivationNumInactiveFrames[0] &= ~0x7f) |= NUM_INACTIVE_FRAMES_TO_DEACTIVATE+1; (m_deactivationNumInactiveFrames[1] &= ~0x7f) |= NUM_INACTIVE_FRAMES_TO_DEACTIVATE+1; } //HK_COMPILE_TIME_ASSERT( sizeof(hkpMotion) == 0xd0 ); /* * Havok SDK - Product file, BUILD(#20130912) * * Confidential Information of Havok. (C) Copyright 1999-2013 * Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok * Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership * rights, and intellectual property rights in the Havok software remain in * Havok and/or its suppliers. * * Use of this software for evaluation purposes is subject to and indicates * acceptance of the End User licence Agreement for this product. A copy of * the license is included with this software and is also available from salesteam@havok.com. * */
52dd741c891551a46b413e063b29bdda6bc22e80
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/agc031/A/4608459.cpp
7faf533bc76f64bd69c324d89a0471a97c68d0de
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
531
cpp
4608459.cpp
#include <iostream> #include <map> # define rep(i, n) for (int i = 0; i < (int)(n); i++) using namespace std; const int INF = 1000000000 + 7; int main() { int n; string s; cin >> n >> s; map<char, int> counter; rep (i, n) { if (counter.find(s[i]) == counter.end()) counter[s[i]] = 1; else counter[s[i]]++; } long long ans = 1; for (auto elem : counter) { ans *= elem.second+1; ans %= INF; } cout << ans-1 << endl; return 0; }
e7be179b86bf5071d4b10b1911b5e23fc42882b1
a1889ba2d2eea14ceaf004beefd13d47c1ac210d
/LibParticle/PartioBgeo/core/ParticleHeaders.cpp
72e01c49a12d8eb6b06fa2cc4f17e42e8dd7d683
[]
no_license
NTCodeBase/LibParticle
93b4ee08ca82dab4f5dcf830abb223be92f21cf0
8a2561ca5009c43e5bf6f3c25bb0ad77b9777996
refs/heads/master
2020-03-26T07:10:17.943815
2019-06-29T19:59:46
2019-06-29T19:59:46
144,639,459
0
0
null
null
null
null
UTF-8
C++
false
false
7,185
cpp
ParticleHeaders.cpp
/* PARTIO SOFTWARE Copyright 2010 Disney Enterprises, 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. * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation Studios" or the names of its contributors may NOT be used to endorse or promote products derived from this software without specific prior written permission from Walt Disney Pictures. Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED. IN NO EVENT SHALL WALT DISNEY PICTURES, 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 BASED 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 DAMAGES. */ #include "ParticleHeaders.h" #include <map> #include <algorithm> #include <cassert> #include <iostream> using namespace Partio; ParticleHeaders:: ParticleHeaders() : particleCount(0) {} ParticleHeaders:: ~ParticleHeaders() {} void ParticleHeaders:: release() const { delete this; } int ParticleHeaders:: numParticles() const { return particleCount; } int ParticleHeaders:: numAttributes() const { return (int)attributes.size(); } int ParticleHeaders:: numFixedAttributes() const { return (int)fixedAttributes.size(); } bool ParticleHeaders:: attributeInfo(const int attributeIndex, ParticleAttribute& attribute) const { if(attributeIndex < 0 || attributeIndex >= (int)attributes.size()) { return false; } attribute = attributes[attributeIndex]; return true; } bool ParticleHeaders:: fixedAttributeInfo(const int attributeIndex, FixedAttribute& attribute) const { if(attributeIndex < 0 || attributeIndex >= (int)fixedAttributes.size()) { return false; } attribute = fixedAttributes[attributeIndex]; return true; } bool ParticleHeaders:: attributeInfo(const char* attributeName, ParticleAttribute& attribute) const { std::map<std::string, int>::const_iterator it = nameToAttribute.find(attributeName); if(it != nameToAttribute.end()) { attribute = attributes[it->second]; return true; } return false; } bool ParticleHeaders:: fixedAttributeInfo(const char* attributeName, FixedAttribute& attribute) const { std::map<std::string, int>::const_iterator it = nameToFixedAttribute.find(attributeName); if(it != nameToFixedAttribute.end()) { attribute = fixedAttributes[it->second]; return true; } return false; } void ParticleHeaders:: sort() { assert(false); } int ParticleHeaders:: registerIndexedStr(const ParticleAttribute&, const char*) { assert(false); return -1; } int ParticleHeaders:: registerFixedIndexedStr(const FixedAttribute&, const char*) { assert(false); return -1; } int ParticleHeaders:: lookupIndexedStr(const ParticleAttribute&, const char*) const { assert(false); return -1; } int ParticleHeaders:: lookupFixedIndexedStr(const FixedAttribute&, const char*) const { assert(false); return -1; } const std::vector<std::string>& ParticleHeaders:: indexedStrs(const ParticleAttribute&) const { static std::vector<std::string> dummy; assert(false); return dummy; } const std::vector<std::string>& ParticleHeaders:: fixedIndexedStrs(const FixedAttribute&) const { static std::vector<std::string> dummy; assert(false); return dummy; } void ParticleHeaders:: findPoints(const float bboxMin[3], const float bboxMax[3], std::vector<ParticleIndex>&) const { (void)bboxMin; (void)bboxMax; assert(false); } float ParticleHeaders:: findNPoints(const float center[3], const int, const float, std::vector<ParticleIndex>&, std::vector<float>&) const { (void)center; assert(false); return 0; } int ParticleHeaders:: findNPoints(const float center[3], int, const float, ParticleIndex*, float*, float*) const { (void)center; assert(false); return 0; } ParticleAttribute ParticleHeaders:: addAttribute(const char* attribute, ParticleAttributeType type, const int count) { // TODO: check if attribute already exists and if so what data type ParticleAttribute attr; attr.name = attribute; attr.type = type; attr.attributeIndex = (int)attributes.size(); // all arrays separate so we don't use this here! attr.count = count; attributes.push_back(attr); nameToAttribute[attribute] = (int)attributes.size() - 1; return attr; } FixedAttribute ParticleHeaders:: addFixedAttribute(const char* attribute, ParticleAttributeType type, const int count) { // TODO: check if attribute already exists and if so what data type FixedAttribute attr; attr.name = attribute; attr.type = type; attr.attributeIndex = (int)fixedAttributes.size(); // all arrays separate so we don't use this here! attr.count = count; fixedAttributes.push_back(attr); nameToFixedAttribute[attribute] = (int)fixedAttributes.size() - 1; return attr; } ParticleIndex ParticleHeaders:: addParticle() { ParticleIndex index = particleCount; particleCount++; return index; } ParticlesDataMutable::iterator ParticleHeaders:: addParticles(const int countToAdd) { particleCount += countToAdd; return iterator(); } void* ParticleHeaders:: dataInternal(const ParticleAttribute&, const ParticleIndex) const { assert(false); return 0; } void* ParticleHeaders:: fixedDataInternal(const FixedAttribute&) const { assert(false); return 0; } void ParticleHeaders:: dataInternalMultiple(const ParticleAttribute&, const int, const ParticleIndex*, const bool, char*) const { assert(false); } void ParticleHeaders:: dataAsFloat(const ParticleAttribute&, const int, const ParticleIndex*, const bool, float*) const { assert(false); } void ParticleHeaders:: setIndexedStr(const ParticleAttribute&, int, const char*) { assert(false); } void ParticleHeaders:: setFixedIndexedStr(const FixedAttribute&, int, const char*) { assert(false); }
6d3fb37943b0790bf55bea808a57bd2620b5c181
ef66e297a49d04098d98a711ca3fda7b8a9a657c
/LeetCodeR2/334-Increasing Triplet Subsequence/solution.cpp
ee2e16b822917dc84113820fb06b456006384748
[]
no_license
breezy1812/MyCodes
34940357954dad35ddcf39aa6c9bc9e5cd1748eb
9e3d117d17025b3b587c5a80638cb8b3de754195
refs/heads/master
2020-07-19T13:36:05.270908
2018-12-15T08:54:30
2018-12-15T08:54:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
457
cpp
solution.cpp
class Solution { public: bool increasingTriplet(vector<int>& nums) { vector<int> increasing; for(auto num : nums) { auto it = lower_bound(increasing.begin(), increasing.end(), num); if(it == increasing.end()) increasing.push_back(num); else *it = num; if(increasing.size() == 3) return true; } return false; } };
1abc72e1e2989d1d9f46c8a43fbb934922451252
c94de0b609fcfd691232a9006886f40412d3520b
/String-Searching-algorithms/suffix_array.cpp
a981c566882a0cc908533f28d7d4b06ef2b83d5a
[]
no_license
Vignesh2508/Algorithms-And-DataStructures
65e5680be056085680610e91f98fca5d27727b53
1bdbba2fa97a7d0c20952234db434d910b80dbb5
refs/heads/master
2020-12-02T14:49:34.010044
2018-01-28T16:28:33
2018-01-28T16:28:33
231,041,318
1
0
null
2019-12-31T06:46:36
2019-12-31T06:46:35
null
UTF-8
C++
false
false
1,660
cpp
suffix_array.cpp
//Implementation of Suffix array O(n*logn*logn) //Kasai's algorithm for computing Longest common prefix array in O(n) //Solution of DISUBSTR - Distinct Substrings problem in Spoj #include<bits/stdc++.h> using namespace std; long cmp(long i,long j); string str; long gap=1,sa[1000007],pos[1000007],tmp[1000007],n,lcp[1000007]; int main() { int t; cout<<"Enter the no of Test cases\n"; cin>>t; while(t--){ cin>>str; n=str.length(); int i; for(i=0;i<n;i++) { sa[i]=i; pos[i]=str[i]; tmp[i]=0; lcp[i]=0; } for(gap=1;;gap=gap*2) { //printf("%ld ",gap); sort(sa,sa+n,cmp); for(i=0;i<n-1;i++) tmp[i+1]=tmp[i]+cmp(sa[i],sa[i+1]); for(i=0;i<n;i++) pos[sa[i]]=tmp[i]; if(tmp[n-1]==n-1)//means all suffix are sorted break; } cout<<"Suffix Array :\n"; for(i=0;i<n;i++) cout<<sa[i]<<" "; cout<<endl; long k=0,j; for(i=0;i<n;i++) { pos[sa[i]]=i; } for(i=0;i<n;i++) { if(pos[i]==n-1) { k=0; continue; } j=sa[pos[i]+1]; while(i+k<n&&j+k<n&&str[i+k]==str[j+k]) k++; lcp[pos[i]]=k; if(k>0) k--; } cout<<"Longest Common Prefix :\n"; for(i=0;i<n;i++) cout<<lcp[i]<<" "; cout<<endl; //Counting no of distinct substrings k=0; for(i=0;i<n;i++){ k=k+n-sa[i]-lcp[i]; } printf("No of Distinct Substrings : %ld\n",k); cout<<endl; } return 0; } long cmp(long i,long j) { if(pos[i]!=pos[j]) return pos[i]<pos[j]; i=i+gap; j=j+gap; if(i<n&&j<n) return pos[i]<pos[j]; else return i>j; } /* Explanation for the testcase with string ABABA: len=1 : A,B len=2 : AB,BA len=3 : ABA,BAB len=4 : ABAB,BABA len=5 : ABABA Thus, total number of distinct substrings is 9. */
cf3d499bd2211147baeebfb82723bbee9a5ba6cb
93fbf65a76bbeb5d8e915c14e5601ae363b3057f
/3rd sem DS Lab/Practice.cpp
cb437176f1da029370c1b06a014b803e8f971ab4
[]
no_license
sauravjaiswa/Coding-Problems
fd864a7678a961a422902eef42a29218cdd2367f
cb978f90d7dcaec75af84cba05d141fdf4f243a0
refs/heads/master
2023-04-14T11:34:03.138424
2021-03-25T17:46:47
2021-03-25T17:46:47
309,085,423
0
0
null
null
null
null
UTF-8
C++
false
false
1,055
cpp
Practice.cpp
//Merge Sort #include<iostream> using namespace std; int n,*temp; void mergesort(int a[],int l,int u); void merge(int a[],int l,int m,int u) { int i,j,index; temp=new int[n]; i=l; j=m+1; index=l; while(i<=m&&j<=u) { if(a[i]<a[j]) { temp[index]=a[i]; i++; } else { temp[index]=a[j]; j++; } index++; } if(i>m) { while(j<=u) { temp[index]=a[j]; j++; index++; } } else { while(i<=m) { temp[index]=a[i]; i++; index++; } } for(int k=l;k<index;k++) a[k] = temp[k]; } void mergesort(int a[],int l,int u) { if(l<u) { int m=(l+u)/2; mergesort(a,l,m); mergesort(a,m+1,u); merge(a,l,m,u); } } int main() { int i,j,t; cout<<"Enter array size:\n"; cin>>n; int a[n]; cout<<"Enter values in array:\n"; for(i=0;i<n;i++) cin>>a[i]; /*Insertion sort int temp; for(i=1;i<n;i++) { temp=a[i]; j=i-1; while(j>=0&&temp<a[j]) { a[j+1]=a[j]; j--; } a[j+1]=temp; }*/ //Merge Sort mergesort(a,0,n-1); cout<<"Sorted array:\n"; for(i=0;i<n;i++) cout<<a[i]<<" "; }
9788d371741a3c3da8b7571ec30c069190920e98
2ffd002d702d5e281a94ce85cec050fe822664d0
/Header files/Game.h
b290de46264ecd56fe7937ff66ff3e88a41867db
[]
no_license
Salman0115/C-Game-
1a14d0d525698b079305926ea8b892653be167b7
c206b1f7da3f68b4e2036ade8131a4b8280eeba3
refs/heads/main
2023-02-17T06:33:35.142265
2021-01-16T17:01:11
2021-01-16T17:01:11
330,210,446
0
0
null
null
null
null
UTF-8
C++
false
false
1,598
h
Game.h
/*! \file Game.h */ #pragma once #include "Block.h" #include <Box2D/Box2D.h> #include <SFML/Graphics.hpp> #include "MovingBlock.h" #include "Character.h" #include <vector> #include "iostream" #include "Platform.h" #include "Col_Def.h" #include "openingDoor.h" #include "SFMLDebugDraw.h" #include "doorOpenSensor.h" #include "contactListener.h" #include "movingPLatforms.h" #include "collectibles.h" class Game : public sf::Drawable { private: sf::Texture mytexture; //!< Texture to be used by picture sf::Texture coin; //!< Texture to be used for coin sf::RectangleShape BackPic; //!< Picture drawn to the scene sf::RectangleShape pic; sf::View view; int Score; b2World* m_pWorld = nullptr; std::vector<Block> m_Blocks; //!< for static blocks std::vector<collectibles> coins; //!< vector for coins //MovingBlock D_Block; std::vector<MovingBlock> D_Block; //!< for dynamic blocks. Character character; //!< Character openingDoor Door; doorOpenSensor m_Open; sf::Texture Player; contactListener listener; Platform platform; sf::Texture p_Texture; sf::Texture charact; int32 velocityIterations = 8; //how strongly to correct velocity int32 positionIterations = 3; bool m_debug = true;// false; //!< Toggle for debug drawing SFMLDebugDraw m_debugDraw; //!< Box2D debug drawing void toggleDebug() { m_debug = !m_debug; } //!< Toggle for debug drawing public: void draw(sf::RenderTarget& target, sf::RenderStates states) const; //!< draw functions. Game(); void onKeyPress(sf::Keyboard::Key code); //!< on key press function void update(float timestep); ~Game(); };