hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
abdb21f77748c08b2564dccc8027c0ec9f9143ca
1,693
cc
C++
bend_mnbrak.cc
lehoangha/tomo2d_HeriotWatt
48477115ed2455a8255521570e4e81ffe754be08
[ "MIT" ]
3
2018-05-03T14:42:29.000Z
2021-11-03T06:59:54.000Z
bend_mnbrak.cc
lehoangha/tomo2d_HeriotWatt
48477115ed2455a8255521570e4e81ffe754be08
[ "MIT" ]
1
2015-10-07T03:23:17.000Z
2015-10-07T03:23:17.000Z
bend_mnbrak.cc
lehoangha/tomo2d_HeriotWatt
48477115ed2455a8255521570e4e81ffe754be08
[ "MIT" ]
2
2018-09-19T13:17:25.000Z
2021-07-28T07:37:34.000Z
/* * bend_mnbrak.cc - initial bracket search for bending solver * (taken from Numerical Recipe's mnbrak.cc) * * Jun Korenaga, MIT/WHOI * January 1999 */ #include "bend.h" #include <math.h> #define GOLD 1.618034 #define GLIMIT 100.0 #define TINY 1.0e-20 #define SHFT(a,b,c,d) (a)=(b);(b)=(c);(c)=(d); #define SIGN(a,b) ((b) >= 0.0 ? fabs(a) : -fabs(a)) static double maxarg1,maxarg2; #define FMAX(a,b) (maxarg1=(a),maxarg2=(b),(maxarg1) > (maxarg2) ?\ (maxarg1) : (maxarg2)) void BendingSolver2d::mnbrak(double *ax, double *bx, double *cx, double *fa, double *fb, double *fc, PF1DIM pfunc) { double ulim,u,r,q,fu,dum; *fa=(this->*pfunc)(*ax); *fb=(this->*pfunc)(*bx); if (*fb > *fa) { SHFT(dum,*ax,*bx,dum) SHFT(dum,*fb,*fa,dum) } *cx=(*bx)+GOLD*(*bx-*ax); *fc=(this->*pfunc)(*cx); while (*fb > *fc) { r=(*bx-*ax)*(*fb-*fc); q=(*bx-*cx)*(*fb-*fa); u=(*bx)-((*bx-*cx)*q-(*bx-*ax)*r)/ (2.0*SIGN(FMAX(fabs(q-r),TINY),q-r)); ulim=(*bx)+GLIMIT*(*cx-*bx); if ((*bx-u)*(u-*cx) > 0.0) { fu=(this->*pfunc)(u); if (fu < *fc) { *ax=(*bx); *bx=u; *fa=(*fb); *fb=fu; return; } else if (fu > *fb) { *cx=u; *fc=fu; return; } u=(*cx)+GOLD*(*cx-*bx); fu=(this->*pfunc)(u); } else if ((*cx-u)*(u-ulim) > 0.0) { fu=(this->*pfunc)(u); if (fu < *fc) { SHFT(*bx,*cx,u,*cx+GOLD*(*cx-*bx)) SHFT(*fb,*fc,fu,(this->*pfunc)(u)) } } else if ((u-ulim)*(ulim-*cx) >= 0.0) { u=ulim; fu=(this->*pfunc)(u); } else { u=(*cx)+GOLD*(*cx-*bx); fu=(this->*pfunc)(u); } SHFT(*ax,*bx,*cx,u) SHFT(*fa,*fb,*fc,fu) } } #undef GOLD #undef GLIMIT #undef TINY #undef SHFT
22.276316
67
0.512109
lehoangha
abdd36d00280f356be581d89281511a8973376b7
1,275
cpp
C++
chapter16/Mammal2.cpp
UncleCShark/CppIn24HoursWithCmake
7d1f30906fed2c7d144e5495ad42a3a9a59d2dce
[ "MIT" ]
null
null
null
chapter16/Mammal2.cpp
UncleCShark/CppIn24HoursWithCmake
7d1f30906fed2c7d144e5495ad42a3a9a59d2dce
[ "MIT" ]
null
null
null
chapter16/Mammal2.cpp
UncleCShark/CppIn24HoursWithCmake
7d1f30906fed2c7d144e5495ad42a3a9a59d2dce
[ "MIT" ]
null
null
null
#include <iostream> enum BREED { YORKIE, CAIRN, DANDIE, SHETLAND, DOBERMAN, LAB }; class Mammal { public: // constructors Mammal() : age(2), weight(5) { } ~Mammal() { } // accessors int getAge() const { return age; } void setAge(int newAge) { age = newAge; } int getWeight() const { return weight; } void setWeight(int newWeight) { weight = newWeight; } // other methods void speak() const { std::cout << "Mammal sound!\n"; } void sleep() const { std::cout << "Shhh. I'm sleeping.\n"; } protected: int age; int weight; }; class Dog : public Mammal { public: // constructors Dog() : breed(YORKIE) { } ~Dog() { } // accessors BREED getBreed() const { return breed; } void setBreed(BREED newBreed) { breed = newBreed; } // other methods void wagTail() { std::cout << "Tail wagging ...\n"; } void begForFood() { std::cout << "Begging for food ...\n"; } private: BREED breed; }; int main() { Dog fido; fido.speak(); fido.wagTail(); std::cout << "Fido is " << fido.getAge() << " years old\n"; return 0; }
14.010989
63
0.505882
UncleCShark
abdd99bdb841232280a77408c20ced5bc6bf9c8f
840
cpp
C++
problems/leet/92-reverse-linked-list-ii/code.cpp
brunodccarvalho/competitive
4177c439174fbe749293b9da3445ce7303bd23c2
[ "MIT" ]
7
2020-10-15T22:37:10.000Z
2022-02-26T17:23:49.000Z
problems/leet/92-reverse-linked-list-ii/code.cpp
brunodccarvalho/competitive
4177c439174fbe749293b9da3445ce7303bd23c2
[ "MIT" ]
null
null
null
problems/leet/92-reverse-linked-list-ii/code.cpp
brunodccarvalho/competitive
4177c439174fbe749293b9da3445ce7303bd23c2
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> using namespace std; // ***** struct ListNode { int val; ListNode *next; ListNode() : val(0), next(nullptr) {} ListNode(int x) : val(x), next(nullptr) {} ListNode(int x, ListNode *next) : val(x), next(next) {} }; class Solution { public: ListNode *reverseBetween(ListNode *head, int m, int n) { if (m == n) return head; ListNode pre_head(0, head); head = &pre_head; while (m > 1) { --m, --n; head = head->next; } ListNode *tail = head->next; ListNode *ntail = head->next->next; while (n > 1) { --n; ListNode *next_ntail = ntail->next; ntail->next = tail; tail = ntail; ntail = next_ntail; } head->next->next = ntail; head->next = tail; return pre_head.next; } }; // ***** int main() { return 0; }
18.26087
58
0.545238
brunodccarvalho
abdf41741f09be06393ad86892a1bba03b4076b7
5,440
cc
C++
tls/src/internal.cc
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
tls/src/internal.cc
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
tls/src/internal.cc
sdelafond/centreon-broker
21178d98ed8a061ca71317d23c2026dbc4edaca2
[ "Apache-2.0" ]
null
null
null
/* ** Copyright 2009-2013,2017 Centreon ** ** 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. ** ** For more information : contact@centreon.com */ #include <cstring> #include <gnutls/gnutls.h> #if GNUTLS_VERSION_NUMBER < 0x030000 # include <cerrno> # include <pthread.h> # include <gcrypt.h> #endif // GNU TLS < 3.0.0 #include "com/centreon/broker/exceptions/msg.hh" #include "com/centreon/broker/io/raw.hh" #include "com/centreon/broker/io/stream.hh" #include "com/centreon/broker/logging/logging.hh" #include "com/centreon/broker/tls/internal.hh" #include "com/centreon/broker/tls/stream.hh" using namespace com::centreon::broker; /************************************** * * * Global Objects * * * **************************************/ /** * Those 2048-bits wide Diffie-Hellman parameters were generated the * 30/07/2009 on Ubuntu 9.04 x86 using OpenSSL 0.9.8g with generator 2. */ unsigned char const tls::dh_params_2048[] = "-----BEGIN DH PARAMETERS-----\n" \ "MIIBCAKCAQEA93F3CN41kJooLbqcOdWHJPb+/zPV+mMs5Svb6PVH/XS3BK/tuuVu\n" \ "r9okkOzGr07KLPiKf+3MJSgHs9N91wPG6JcMcRys3fH1Tszh1i1317tE54o+oLPv\n" \ "jcs9P13lFlZm4gB7sjkR5If/ZtudoVwv7JS5WHIXrzew7iW+kT/QXCp+jkO1Vusc\n" \ "mQHlq4Fqt/p7zxOHVc8GBttE6/vEYipm2pdym1kBy62Z6rZLowkukngI5uzdQvB4\n" \ "Pmq5BmeRzGRClSkmRW4pUXiBac8SMAgMBl7cgAEaURR2D8Y4XltyXW51xzO1x1QM\n" \ "bOl9nneRY2Y8X3FOR1+Mzt+x44F+cWtqIwIBAg==\n" \ "-----END DH PARAMETERS-----\n"; gnutls_dh_params_t tls::dh_params; #if GNUTLS_VERSION_NUMBER < 0x030000 GCRY_THREAD_OPTION_PTHREAD_IMPL; #endif // GNU TLS < 3.0.0 /************************************** * * * Static Functions * * * **************************************/ // Might be used below, when library logging is enabled. // static void log_gnutls_message(int level, char const* message) { // (void)level; // logging::debug(logging::low) // << "TLS: GNU TLS debug: " << message; // return ; // } /************************************** * * * Global Functions * * * **************************************/ /** * Deinit the TLS library. */ void tls::destroy() { // Unload Diffie-Hellman parameters. gnutls_dh_params_deinit(dh_params); // Unload GNU TLS library gnutls_global_deinit(); return ; } /** * @brief TLS initialization function. * * Prepare all necessary ressources for TLS use. */ void tls::initialize() { gnutls_datum_t const dhp = { const_cast<unsigned char*>(dh_params_2048), sizeof(dh_params_2048) }; int ret; // Eventually initialize libgcrypt. #if GNUTLS_VERSION_NUMBER < 0x030000 logging::info(logging::high) << "TLS: initializing libgcrypt (GNU TLS <= 2.11.0)"; gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif // GNU TLS < 3.0.0 // Initialize GNU TLS library. if (gnutls_global_init() != GNUTLS_E_SUCCESS) throw (exceptions::msg() << "TLS: GNU TLS library initialization failed"); // Log GNU TLS version. { logging::info(logging::medium) << "TLS: compiled with GNU TLS version " << GNUTLS_VERSION; char const* v(gnutls_check_version(GNUTLS_VERSION)); if (!v) throw (exceptions::msg() << "TLS: GNU TLS run-time version is " << "incompatible with the compile-time version (" << GNUTLS_VERSION << "): please update your GNU TLS library"); logging::info(logging::high) << "TLS: loading GNU TLS version " << v; // gnutls_global_set_log_function(log_gnutls_message); // gnutls_global_set_log_level(11); } // Load Diffie-Hellman parameters. ret = gnutls_dh_params_init(&dh_params); if (ret != GNUTLS_E_SUCCESS) throw (exceptions::msg() << "TLS: could not load TLS Diffie-Hellman parameters: " << gnutls_strerror(ret)); ret = gnutls_dh_params_import_pkcs3( dh_params, &dhp, GNUTLS_X509_FMT_PEM); if (ret != GNUTLS_E_SUCCESS) throw (exceptions::msg() << "TLS: could not import PKCS #3 parameters: " << gnutls_strerror(ret)); return ; } /** * The following static function is used to receive data from the lower * layer and give it to TLS for decoding. */ ssize_t tls::pull_helper( gnutls_transport_ptr_t ptr, void* data, size_t size) { return (static_cast<tls::stream*>(ptr)->read_encrypted(data, size)); } /** * The following static function is used to send data from TLS to the lower * layer. */ ssize_t tls::push_helper( gnutls_transport_ptr_t ptr, void const* data, size_t size) { return (static_cast<tls::stream*>(ptr)->write_encrypted(data, size)); }
31.627907
76
0.617279
sdelafond
abe1d57fa229bbcefbda3b3fb5e52d4b6be8f7e9
2,578
hpp
C++
third_party/boost/simd/arch/common/scalar/function/reversebits.hpp
SylvainCorlay/pythran
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
[ "BSD-3-Clause" ]
6
2018-02-25T22:23:33.000Z
2021-01-15T15:13:12.000Z
third_party/boost/simd/arch/common/scalar/function/reversebits.hpp
SylvainCorlay/pythran
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
[ "BSD-3-Clause" ]
null
null
null
third_party/boost/simd/arch/common/scalar/function/reversebits.hpp
SylvainCorlay/pythran
908ec070d837baf77d828d01c3e35e2f4bfa2bfa
[ "BSD-3-Clause" ]
7
2017-12-12T12:36:31.000Z
2020-02-10T14:27:07.000Z
//================================================================================================== /*! @file @copyright 2016 NumScale SAS Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ //================================================================================================== #ifndef BOOST_SIMD_ARCH_COMMON_SCALAR_FUNCTION_REVERSEBITS_HPP_INCLUDED #define BOOST_SIMD_ARCH_COMMON_SCALAR_FUNCTION_REVERSEBITS_HPP_INCLUDED #include <boost/simd/detail/dispatch/function/overload.hpp> #include <boost/config.hpp> namespace boost { namespace simd { namespace ext { namespace bd = boost::dispatch; BOOST_DISPATCH_OVERLOAD ( reversebits_ , (typename A0) , bd::cpu_ , bd::scalar_< bd::ints8_<A0> > ) { BOOST_FORCEINLINE A0 operator() ( A0 a0) const BOOST_NOEXCEPT { return std::uint8_t( ((uint8_t(a0) * 0x0802LU & 0x22110LU) | (uint8_t(a0) * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16 ); } }; BOOST_DISPATCH_OVERLOAD ( reversebits_ , (typename A0) , bd::cpu_ , bd::scalar_< bd::ints64_<A0> > ) { BOOST_FORCEINLINE A0 operator() ( A0 a0) const BOOST_NOEXCEPT { union { A0 a; std::uint32_t b[2]; } z = {a0}; z.b[0] = reversebits(z.b[0]); z.b[1] = reversebits(z.b[1]); std::swap(z.b[0], z.b[1]); return z.a; } }; BOOST_DISPATCH_OVERLOAD ( reversebits_ , (typename A0) , bd::cpu_ , bd::scalar_< bd::ints16_<A0> > ) { BOOST_FORCEINLINE A0 operator() ( A0 a0) const BOOST_NOEXCEPT { union { A0 a; std::uint8_t b[2]; } z = {a0}; z.b[0] = reversebits(z.b[0]); z.b[1] = reversebits(z.b[1]); std::swap(z.b[0], z.b[1]); return z.a; } }; BOOST_DISPATCH_OVERLOAD ( reversebits_ , (typename A0) , bd::cpu_ , bd::scalar_< bd::ints32_<A0> > ) { BOOST_FORCEINLINE A0 operator() ( A0 a0) const BOOST_NOEXCEPT { union { A0 a; std::uint16_t b[2]; } z = {a0}; z.b[0] = reversebits(z.b[0]); z.b[1] = reversebits(z.b[1]); std::swap(z.b[0], z.b[1]); return z.a; } }; } } } #endif
29.976744
100
0.470132
SylvainCorlay
abec65cc0db0fb3cf4e8e03fb6ee8b6ffd42af41
12,227
cpp
C++
code/2D/lib/mex/precompute_mex.cpp
ErisZhang/BCQN
6c103e0e173bb825e4207b282a0cba2ce5d10e24
[ "MIT" ]
15
2021-07-16T11:03:01.000Z
2022-01-15T00:58:26.000Z
code/2D/lib/mex/precompute_mex.cpp
ErisZhang/BCQN
6c103e0e173bb825e4207b282a0cba2ce5d10e24
[ "MIT" ]
1
2019-07-10T12:12:18.000Z
2019-07-10T12:12:18.000Z
code/2D/lib/mex/precompute_mex.cpp
ErisZhang/BCQN
6c103e0e173bb825e4207b282a0cba2ce5d10e24
[ "MIT" ]
4
2019-02-21T06:12:40.000Z
2020-09-27T09:58:32.000Z
#include <mex.h> #include <math.h> #include <Eigen/Dense> #include <iostream> #include <vector> using namespace Eigen; using namespace std; double get_tri_area(Vector2d p0, Vector2d p1, Vector2d p2) { Vector2d u = p1 - p0; Vector2d v = p2 - p0; return 0.5 * sqrt(u.dot(u) * v.dot(v) - u.dot(v) * u.dot(v)); } double get_tri_area(Vector3d p0, Vector3d p1, Vector3d p2) { Vector3d u = p1 - p0; Vector3d v = p2 - p0; return 0.5 * sqrt(u.dot(u) * v.dot(v) - u.dot(v) * u.dot(v)); } void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mxArray *X_g_inv_mex, *tri_areas_mex, *F_dot_mex, *row_mex, *col_mex, *val_mex, *x2u_mex, *J_mex, *J_info_mex, *JT_mex, *JT_info_mex, *perimeter_mex; double *tri_num, *tri_list, *ver_num, *ver_list, *uv_mesh, *dirichlet; double *X_g_inv, *tri_areas, *F_dot, *row, *col, *val, *x2u, *J, *J_info, *JT, *JT_info, *perimeter; tri_num = mxGetPr(prhs[0]); tri_list = mxGetPr(prhs[1]); ver_num = mxGetPr(prhs[2]); ver_list = mxGetPr(prhs[3]); uv_mesh = mxGetPr(prhs[4]); dirichlet = mxGetPr(prhs[5]); int tri_n = tri_num[0]; int ver_n = ver_num[0]; int is_uv_mesh = uv_mesh[0]; X_g_inv_mex = plhs[0] = mxCreateDoubleMatrix(4 * tri_n, 1, mxREAL); tri_areas_mex = plhs[1] = mxCreateDoubleMatrix(tri_n, 1, mxREAL); F_dot_mex = plhs[2] = mxCreateDoubleMatrix(24 * tri_n, 1, mxREAL); row_mex = plhs[3] = mxCreateDoubleMatrix(18 * tri_n, 1, mxREAL); col_mex = plhs[4] = mxCreateDoubleMatrix(18 * tri_n, 1, mxREAL); val_mex = plhs[5] = mxCreateDoubleMatrix(18 * tri_n, 1, mxREAL); x2u_mex = plhs[6] = mxCreateDoubleMatrix(2 * ver_n, 1, mxREAL); X_g_inv = mxGetPr(X_g_inv_mex); tri_areas = mxGetPr(tri_areas_mex); F_dot = mxGetPr(F_dot_mex); row = mxGetPr(row_mex); col = mxGetPr(col_mex); val = mxGetPr(val_mex); x2u = mxGetPr(x2u_mex); int count = 1; int fixed_num = 0; int tri[3]; for(int i = 0; i < 2 * ver_n; i++) { if(dirichlet[i] == 0) { x2u[i] = count; count++; }else { fixed_num++; x2u[i] = 0; } } //mexPrintf("check 1\n"); vector<vector<int>*> ver_tri_map; for(int i = 0; i < ver_n; i++) { vector<int>* tris = new vector<int>(); ver_tri_map.push_back(tris); } for(int i = 0; i < tri_n; i++) { tri[0] = tri_list[i] - 1; tri[1] = tri_list[i + tri_n] - 1; tri[2] = tri_list[i + 2 * tri_n] - 1; ver_tri_map[tri[0]]->push_back(i); ver_tri_map[tri[1]]->push_back(i); ver_tri_map[tri[2]]->push_back(i); } int max_valence = 0; for(int i = 0; i < ver_n; i++) { if(max_valence < ver_tri_map[i]->size()) { max_valence = ver_tri_map[i]->size(); } } J_mex = plhs[7] = mxCreateDoubleMatrix((2 * ver_n - fixed_num) * max_valence, 1, mxREAL); J_info_mex = plhs[8] = mxCreateDoubleMatrix(2, 1, mxREAL); JT_mex = plhs[9] = mxCreateDoubleMatrix(tri_n * 3 * 2, 1, mxREAL); JT_info_mex = plhs[10] = mxCreateDoubleMatrix(2, 1, mxREAL); perimeter_mex = plhs[11] = mxCreateDoubleMatrix(ver_n, 1, mxREAL); J = mxGetPr(J_mex); J_info = mxGetPr(J_info_mex); JT = mxGetPr(JT_mex); JT_info = mxGetPr(JT_info_mex); perimeter = mxGetPr(perimeter_mex); count = 0; J_info[0] = 2 * ver_n - fixed_num; J_info[1] = max_valence; for(int i = 0; i < ver_n; i++) { perimeter[i] = 0; if(dirichlet[2 * i] == 0) { for(int j = 0; j < max_valence; j++) { if(j < ver_tri_map[i]->size()) { J[count * max_valence + j] = ver_tri_map[i]->at(j); }else{ J[count * max_valence + j] = -1; } } count++; for(int j = 0; j < max_valence; j++) { if(j < ver_tri_map[i]->size()) { J[count * max_valence + j] = ver_tri_map[i]->at(j); }else{ J[count * max_valence + j] = -1; } } count++; } } JT_info[0] = tri_n; JT_info[1] = 3 * 2; for(int i = 0; i < tri_n; i++) { tri[0] = tri_list[i] - 1; tri[1] = tri_list[i + tri_n] - 1; tri[2] = tri_list[i + 2 * tri_n] - 1; for(int j = 0; j < 3; j++) { if(x2u[2 * tri[j]] > 0) { JT[i * 2 * 3 + 2 * j + 0] = x2u[2 * tri[j] + 0] - 1; JT[i * 2 * 3 + 2 * j + 1] = x2u[2 * tri[j] + 1] - 1; }else{ JT[i * 2 * 3 + 2 * j + 0] = -1; JT[i * 2 * 3 + 2 * j + 1] = -1; } } } for(int i = 0; i < ver_n; i++) { ver_tri_map[i]->clear(); delete ver_tri_map[i]; } ver_tri_map.clear(); /////////////////////////////////////////////////////////////////////// Matrix2d X_g, B; double C_sub[4][6]; double tri_area; for (int i = 0; i < 4; i++) { for (int j = 0; j < 6; j++) { C_sub[i][j] = 0; } } for(int i = 0; i < tri_n; i++) { tri[0] = tri_list[i] - 1; tri[1] = tri_list[i + tri_n] - 1; tri[2] = tri_list[i + 2 * tri_n] - 1; ///////////////////////////////////////////////////////////// if(is_uv_mesh) { Vector3d p0(ver_list[3 * tri[0]], ver_list[3 * tri[0] + 1], ver_list[3 * tri[0] + 2]); Vector3d p1(ver_list[3 * tri[1]], ver_list[3 * tri[1] + 1], ver_list[3 * tri[1] + 2]); Vector3d p2(ver_list[3 * tri[2]], ver_list[3 * tri[2] + 1], ver_list[3 * tri[2] + 2]); perimeter[tri[0]] += (p1 - p2).norm(); perimeter[tri[1]] += (p2 - p0).norm(); perimeter[tri[2]] += (p0 - p1).norm(); tri_area = tri_areas[i] = get_tri_area(p0, p1, p2); Vector3d bx = p1 - p0; Vector3d cx = p2 - p0; Vector3d Ux = bx; Ux.normalize(); Vector3d w = Ux.cross(cx); Vector3d Wx = w; Wx.normalize(); Vector3d Vx = Ux.cross(Wx); Matrix3d R; R.col(0) = Ux; R.col(1) = Vx; R.col(2) = Wx; Vector3d vb = R.transpose() * bx; Vector3d vc = R.transpose() * cx; X_g << vb[0], vc[0], vb[1], vc[1]; if(X_g.determinant() < 0) { X_g.row(1) = -1.0 * X_g.row(1); } }else{ Vector2d p0(ver_list[2 * tri[0]], ver_list[2 * tri[0] + 1]); Vector2d p1(ver_list[2 * tri[1]], ver_list[2 * tri[1] + 1]); Vector2d p2(ver_list[2 * tri[2]], ver_list[2 * tri[2] + 1]); perimeter[tri[0]] += (p1 - p2).norm(); perimeter[tri[1]] += (p2 - p0).norm(); perimeter[tri[2]] += (p0 - p1).norm(); tri_area = tri_areas[i] = get_tri_area(p0, p1, p2); Vector2d e0 = p1 - p0; Vector2d e1 = p2 - p0; X_g << e0[0], e1[0], e0[1], e1[1]; } /////////////////////////////////////////////////////////////// B = X_g.inverse(); X_g_inv[i] = B(0, 0); X_g_inv[tri_n + i] = B(1, 0); X_g_inv[2 * tri_n + i] = B(0, 1); X_g_inv[3 * tri_n + i] = B(1, 1); C_sub[0][0] = -(B(0, 0) + B(1, 0)); C_sub[1][1] = -(B(0, 0) + B(1, 0)); C_sub[0][2] = B(0, 0); C_sub[1][3] = B(0, 0); C_sub[0][4] = B(1, 0); C_sub[1][5] = B(1, 0); C_sub[2][0] = -(B(0, 1) + B(1, 1)); C_sub[3][1] = -(B(0, 1) + B(1, 1)); C_sub[2][2] = B(0, 1); C_sub[3][3] = B(0, 1); C_sub[2][4] = B(1, 1); C_sub[3][5] = B(1, 1); for(int j = 0; j < 6; j++) { F_dot[0 * tri_n * 6 + j * tri_n + i] = C_sub[0][j]; F_dot[1 * tri_n * 6 + j * tri_n + i] = C_sub[1][j]; F_dot[2 * tri_n * 6 + j * tri_n + i] = C_sub[2][j]; F_dot[3 * tri_n * 6 + j * tri_n + i] = C_sub[3][j]; } ////////////////////////////////////////////////////////////////////// Matrix2d A0; A0 << -1.0 * (B(0, 0) + B(1, 0)), 0, 0, -1.0 * (B(0, 0) + B(1, 0)); Matrix2d A1; A1 << -1.0 * (B(0, 1) + B(1, 1)), 0, 0, -1.0 * (B(0, 1) + B(1, 1)); Matrix2d B0; B0 << B(0, 0), 0, 0, B(0, 0); Matrix2d B1; B1 << B(0, 1), 0, 0, B(0, 1); Matrix2d C0; C0 << B(1, 0), 0, 0, B(1, 0); Matrix2d C1; C1 << B(1, 1), 0, 0, B(1, 1); Matrix2d AA = A0 * A0 + A1 * A1; Matrix2d AB = A0 * B0 + A1 * B1; Matrix2d AC = A0 * C0 + A1 * C1; Matrix2d BA = B0 * A0 + B1 * A1; Matrix2d BB = B0 * B0 + B1 * B1; Matrix2d BC = B0 * C0 + B1 * C1; Matrix2d CA = C0 * A0 + C1 * A1; Matrix2d CB = C0 * B0 + C1 * B1; Matrix2d CC = C0 * C0 + C1 * C1; row[18 * i + 0] = 2 * tri[0]; col[18 * i + 0] = 2 * tri[0]; val[18 * i + 0] = AA(0, 0) * tri_area; row[18 * i + 1] = 2 * tri[0] + 1; col[18 * i + 1] = 2 * tri[0] + 1; val[18 * i + 1] = AA(1, 1) * tri_area; row[18 * i + 2] = 2 * tri[0]; col[18 * i + 2] = 2 * tri[1]; val[18 * i + 2] = AB(0, 0) * tri_area; row[18 * i + 3] = 2 * tri[0] + 1; col[18 * i + 3] = 2 * tri[1] + 1; val[18 * i + 3] = AB(1, 1) * tri_area; row[18 * i + 4] = 2 * tri[0]; col[18 * i + 4] = 2 * tri[2]; val[18 * i + 4] = AC(0, 0) * tri_area; row[18 * i + 5] = 2 * tri[0] + 1; col[18 * i + 5] = 2 * tri[2] + 1; val[18 * i + 5] = AC(1, 1) * tri_area; row[18 * i + 6] = 2 * tri[1]; col[18 * i + 6] = 2 * tri[0]; val[18 * i + 6] = BA(0, 0) * tri_area; row[18 * i + 7] = 2 * tri[1] + 1; col[18 * i + 7] = 2 * tri[0] + 1; val[18 * i + 7] = BA(1, 1) * tri_area; row[18 * i + 8] = 2 * tri[1]; col[18 * i + 8] = 2 * tri[1]; val[18 * i + 8] = BB(0, 0) * tri_area; row[18 * i + 9] = 2 * tri[1] + 1; col[18 * i + 9] = 2 * tri[1] + 1; val[18 * i + 9] = BB(1, 1) * tri_area; row[18 * i + 10] = 2 * tri[1]; col[18 * i + 10] = 2 * tri[2]; val[18 * i + 10] = BC(0, 0) * tri_area; row[18 * i + 11] = 2 * tri[1] + 1; col[18 * i + 11] = 2 * tri[2] + 1; val[18 * i + 11] = BC(1, 1) * tri_area; row[18 * i + 12] = 2 * tri[2]; col[18 * i + 12] = 2 * tri[0]; val[18 * i + 12] = CA(0, 0) * tri_area; row[18 * i + 13] = 2 * tri[2] + 1; col[18 * i + 13] = 2 * tri[0] + 1; val[18 * i + 13] = CA(1, 1) * tri_area; row[18 * i + 14] = 2 * tri[2]; col[18 * i + 14] = 2 * tri[1]; val[18 * i + 14] = CB(0, 0) * tri_area; row[18 * i + 15] = 2 * tri[2] + 1; col[18 * i + 15] = 2 * tri[1] + 1; val[18 * i + 15] = CB(1, 1) * tri_area; row[18 * i + 16] = 2 * tri[2]; col[18 * i + 16] = 2 * tri[2]; val[18 * i + 16] = CC(0, 0) * tri_area; row[18 * i + 17] = 2 * tri[2] + 1; col[18 * i + 17] = 2 * tri[2] + 1; val[18 * i + 17] = CC(1, 1) * tri_area; } return; }
29.605327
153
0.399117
ErisZhang
74387bd503d654fadb158d57e5a9322d848274f3
4,522
cpp
C++
src/input/linux/linux_gpio.cpp
lii-enac/djnn-cpp
f27c5ba3186186ee22c93ae91c16063556e929b6
[ "BSD-2-Clause" ]
4
2018-09-11T14:27:57.000Z
2019-12-16T21:06:26.000Z
src/input/linux/linux_gpio.cpp
lii-enac/djnn-cpp
f27c5ba3186186ee22c93ae91c16063556e929b6
[ "BSD-2-Clause" ]
null
null
null
src/input/linux/linux_gpio.cpp
lii-enac/djnn-cpp
f27c5ba3186186ee22c93ae91c16063556e929b6
[ "BSD-2-Clause" ]
2
2018-06-11T14:15:30.000Z
2019-01-09T12:23:35.000Z
/* * djnn v2 * * The copyright holders for the contents of this file are: * Ecole Nationale de l'Aviation Civile, France (2019) * See file "license.terms" for the rights and conditions * defined by copyright holders. * * * Contributors: * Stéphane Chatty <chatty@djnn.net> * Mathieu Magnaudet <mathieu.magnaudet@enac.fr> * */ #include <stdexcept> #include "core/utils/error.h" #include "core/core-dev.h" // graph add/remove edge #include "core/utils/to_string.h" #include "core/utils/utils-dev.h" #include "linux_input.h" #include <fcntl.h> #include <unistd.h> #include <cstring> namespace djnn { static int num_gpios = 0; static map<int,GPIOLine*> gpio_lines; void p_init_gpios () { int num = 0; /* iterate on all controllers to determine the total number of GPIOs */ while (1) { char filename[64]; int fd; char buf[10]; const char* p; int numgpio = 0; /* attempt to read the information file for the next controller */ snprintf (filename, 64, "/sys/class/gpio/gpiochip%d/ngpio", num); fd = open (filename, O_RDONLY); if (fd < 0) break; /* read the number of GPIOs in this controller */ read (fd, buf, 10); for (p = buf; *p != '\n'; ++p) numgpio = 10*numgpio + *p - '0'; close (fd); /* update the total number of GPIOs */ num += numgpio; } num_gpios = num-1; if (num_gpios < 0) fprintf (stderr, "djnn warning: no GPIO\n"); } CoreProcess* p_find_gpio (const string& path, direction_e dir) { try { string::size_type sz; size_t index = std::stoi (path, &sz); map<int, GPIOLine*>::iterator it = gpio_lines.find (index); GPIOLine* line = nullptr; if (it != gpio_lines.end ()) { line = it->second; } else { line = new GPIOLine (nullptr, "line" + djnn::to_string (index), index, dir); line->activate (); } if (path.length() > (sz + 1)) return line->find_child_impl (path.substr ((sz + 1))); else return line; } catch (std::invalid_argument& arg) { warning (nullptr, "invalid gpio path specification: " + path); } return nullptr; } GPIOLine::GPIOLine (ParentProcess* parent, const string& name, int pin, direction_e dir) : FatProcess (name), _pin (pin), _dir (dir), _iofd (nullptr), _action (nullptr), _c_action (nullptr) { if (pin < 0 || pin > num_gpios) error (this, "no gpio " + __to_string (pin)); _value = new BoolProperty (this, "value", true); /* activate the GPIO interface */ _fd = open ("/sys/class/gpio/export", O_WRONLY); char buf[64]; const char* direction = _dir == IN ? "in" : "out"; const int dirlen = _dir == IN ? 2 : 3; if (_fd < 0) error (this, "unable to open gpio"); write (_fd, buf, snprintf (buf, 64, "%d", _pin)); close (_fd); /* set it to the desired direction */ snprintf (buf, 64, "/sys/class/gpio/gpio%d/direction", pin); _fd = open (buf, O_WRONLY); if (_fd < 0) { error (this, "cannot set direction of GPIO " + __to_string (pin)); } write (_fd, direction, dirlen); close (_fd); /* open the value file */ snprintf (buf, 64, "/sys/class/gpio/gpio%d/value", pin); _fd = open (buf, _dir == IN ? O_RDONLY : O_WRONLY); if (_fd < 0) { error (this, "cannot open GPIO " + __to_string (pin)); } if (dir == IN) { _iofd = new IOFD (nullptr, "gpiofd", _fd); _iofd->activate (); _action = new GPIOLineReadAction (this, "read"); _c_action = new Coupling (_iofd->find_child_impl ("readable"), ACTIVATION, _action, ACTIVATION); } else { _action = new GPIOLineWriteAction (this, "write"); _c_action = new Coupling (_value, ACTIVATION, _action, ACTIVATION); } finalize_construction (parent, name); } GPIOLine::~GPIOLine() { if (_dir == IN) { _iofd->deactivate (); delete _c_action; delete _action; delete _iofd; } else { delete _c_action; delete _action; } close (_fd); delete _value; } void GPIOLine::read_value () { char buf[10]; lseek (_fd, 0, SEEK_SET); if (read (_fd, buf, 10) > 0) _value->set_value (buf[0] - '0', true); } void GPIOLine::write_value () { char buf[4]; int value = _value->get_value (); snprintf (buf, 4, "%d", value); write (_fd, buf, strlen (buf) + 1); } }
25.693182
102
0.582043
lii-enac
743a96d9c7794f785b2e6b1eb97176ea1b188707
4,469
cpp
C++
Plugins/GeometryCache/Source/GeometryCache/Private/GeometryCacheTrack.cpp
greenrainstudios/AlembicUtilities
3970988065aef6861898a5185495e784a0c43ecb
[ "MIT" ]
null
null
null
Plugins/GeometryCache/Source/GeometryCache/Private/GeometryCacheTrack.cpp
greenrainstudios/AlembicUtilities
3970988065aef6861898a5185495e784a0c43ecb
[ "MIT" ]
null
null
null
Plugins/GeometryCache/Source/GeometryCache/Private/GeometryCacheTrack.cpp
greenrainstudios/AlembicUtilities
3970988065aef6861898a5185495e784a0c43ecb
[ "MIT" ]
1
2021-01-22T09:11:51.000Z
2021-01-22T09:11:51.000Z
// Copyright Epic Games, Inc. All Rights Reserved. #include "GeometryCacheTrack.h" #include "GeometryCacheHelpers.h" #include "UObject/AnimPhysObjectVersion.h" const FGeometryCacheTrackSampleInfo FGeometryCacheTrackSampleInfo::EmptySampleInfo; const FVisibilitySample FVisibilitySample::VisibleSample(true); const FVisibilitySample FVisibilitySample::InvisibleSample(false); UGeometryCacheTrack::UGeometryCacheTrack(const FObjectInitializer& ObjectInitializer /*= FObjectInitializer::Get()*/) : UObject(ObjectInitializer) { NumMaterials = 0; Duration = 0; } const bool UGeometryCacheTrack::UpdateMeshData(const float Time, const bool bLooping, int32& InOutMeshSampleIndex, FGeometryCacheMeshData*& OutMeshData) { return false; } const bool UGeometryCacheTrack::UpdateMatrixData(const float Time, const bool bLooping, int32& InOutMatrixSampleIndex, FMatrix& OutWorldMatrix) { // Retrieve sample index from Time const uint32 MatrixSampleIndex = FindSampleIndexFromTime(MatrixSampleTimes, Time, bLooping); // Update the Matrix and Index if MatrixSampleIndex is different from the stored InOutMatrixSampleIndex if (MatrixSampleIndex != InOutMatrixSampleIndex) { InOutMatrixSampleIndex = MatrixSampleIndex; OutWorldMatrix = MatrixSamples[MatrixSampleIndex]; return true; } return false; } const bool UGeometryCacheTrack::UpdateBoundsData(const float Time, const bool bLooping, const bool bIsPlayingBackward, int32& InOutBoundsSampleIndex, FBox& OutBounds) { // Fixme implement bounds in derived classes, should we make this abstract? check(false); return false; } UGeometryCacheTrack::~UGeometryCacheTrack() { MatrixSamples.Empty(); MatrixSampleTimes.Empty(); } void UGeometryCacheTrack::Serialize(FArchive& Ar) { Ar.UsingCustomVersion(FAnimPhysObjectVersion::GUID); if (Ar.CustomVer(FAnimPhysObjectVersion::GUID) >= FAnimPhysObjectVersion::GeometryCacheAssetDeprecation) { Super::Serialize(Ar); } Ar << MatrixSamples; Ar << MatrixSampleTimes; Ar << NumMaterials; } void UGeometryCacheTrack::SetMatrixSamples(const TArray<FMatrix>& Matrices, const TArray<float>& SampleTimes) { // Copy Matrix samples and sample-times MatrixSamples.Append(Matrices); MatrixSampleTimes.Append(SampleTimes); } void UGeometryCacheTrack::AddMatrixSample(const FMatrix& Matrix, const float SampleTime) { MatrixSamples.Add(Matrix); MatrixSampleTimes.Add(SampleTime); Duration = FMath::Max(Duration, SampleTime); } void UGeometryCacheTrack::SetDuration(float NewDuration) { Duration = NewDuration; } float UGeometryCacheTrack::GetDuration() { return Duration; } const float UGeometryCacheTrack::GetMaxSampleTime() const { // If there are sample-times available return the (maximal) time from the last sample if ( MatrixSampleTimes.Num() > 0 ) { return MatrixSampleTimes.Last(); } // Otherwise no data/times available return 0.0f; } const uint32 UGeometryCacheTrack::FindSampleIndexFromTime(const TArray<float>& SampleTimes, const float Time, const bool bLooping) { // No index possible if (SampleTimes.Num() == 0 || SampleTimes.Num() == 1) { return 0; } // Modulo the incoming Time if the animation is played on a loop float SampleTime = Time; if (bLooping) { SampleTime = GeometyCacheHelpers::WrapAnimationTime(Time, Duration); } // Binary searching for closest (floored) SampleIndex uint32 MinIndex = 0; uint32 MaxIndex = SampleTimes.Num() - 1; if (SampleTime >= SampleTimes[MaxIndex]) { return MaxIndex; } else if (SampleTime <= SampleTimes[MinIndex]) { return MinIndex; } while (MaxIndex > 0 && MaxIndex >= MinIndex) { uint32 Mid = (MinIndex + MaxIndex) / 2; if (SampleTime > SampleTimes[Mid]) { MinIndex = Mid + 1; } else { MaxIndex = Mid - 1; } } return MinIndex; } void UGeometryCacheTrack::GetResourceSizeEx(FResourceSizeEx& CumulativeResourceSize) { Super::GetResourceSizeEx(CumulativeResourceSize); // Determine resource size from data that is serialized CumulativeResourceSize.AddDedicatedSystemMemoryBytes(MatrixSamples.Num() * sizeof(FMatrix)); CumulativeResourceSize.AddDedicatedSystemMemoryBytes(MatrixSampleTimes.Num() * sizeof(float)); } const FGeometryCacheTrackSampleInfo& UGeometryCacheTrack::GetSampleInfo(float Time, bool bLooping) { return FGeometryCacheTrackSampleInfo::EmptySampleInfo; }
28.464968
167
0.750727
greenrainstudios
743c89ecec5979c250c222952bd2bcb9c8b506d9
46
cpp
C++
src/scanContext.cpp
softdream/Slam-Project-Of-MyOwn
6d6db8a5761e8530971b203983ea2215620aa5c2
[ "Apache-2.0" ]
21
2021-07-19T08:15:53.000Z
2022-03-31T07:07:55.000Z
src/scanContext.cpp
Forrest-Z/Slam-Project-Of-MyOwn
6d6db8a5761e8530971b203983ea2215620aa5c2
[ "Apache-2.0" ]
3
2022-03-02T12:55:37.000Z
2022-03-07T12:12:57.000Z
src/scanContext.cpp
softdream/Slam-Project-Of-MyOwn
6d6db8a5761e8530971b203983ea2215620aa5c2
[ "Apache-2.0" ]
4
2021-08-12T15:11:09.000Z
2022-01-08T14:20:36.000Z
#include "scanContext.h" namespace slam{ }
6.571429
24
0.695652
softdream
744127979977c33452dbd4f3f80463078c2ba9df
1,059
cpp
C++
pt07z.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
264
2015-01-08T10:07:01.000Z
2022-03-26T04:11:51.000Z
pt07z.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
17
2016-04-15T03:38:07.000Z
2020-10-30T00:33:57.000Z
pt07z.cpp
ohmyjons/SPOJ-1
870ae3b072a3fbc89149b35fe5649a74512a8f60
[ "Unlicense" ]
127
2015-01-08T04:56:44.000Z
2022-02-25T18:40:37.000Z
// 2008-07-29 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <list> using namespace std; int main() { int N,i,u,v; scanf("%d",&N); list<int> L[10000]; for (i=0; i<N-1; i++) { scanf("%d %d",&u,&v); u--,v--; L[u].push_back(v); L[v].push_back(u); } int size=1; int p[20000]; int n[20000]; int d[20000]; int maxdist=0; int node; p[0]=-1; n[0]=0; d[0]=0; while (size) { size--; int _n=n[size]; int _d=d[size]; int _p=p[size]; if (maxdist<_d) { maxdist=_d; node=_n; } list<int>::iterator I; for (I=L[_n].begin();I!=L[_n].end();I++) if (*I!=_p) { p[size]=_n; n[size]=*I; d[size]=_d+1; size++; } } size=1; maxdist=0; p[0]=-1; n[0]=node; d[0]=0; while (size) { size--; int _n=n[size]; int _d=d[size]; int _p=p[size]; if (maxdist<_d) { maxdist=_d; node=_n; } list<int>::iterator I; for (I=L[_n].begin();I!=L[_n].end();I++) if (*I!=_p) { p[size]=_n; n[size]=*I; d[size]=_d+1; size++; } } printf("%d\n",maxdist); return 0; }
13.934211
42
0.507082
ohmyjons
74440b1c5c4417fae1efdb360ec982198c4b4949
3,775
cpp
C++
7952603892_basic.cpp
sehgal-aamulya/SequenceAlignmentAlgorithms
35ce3c9a35c1a681f03c5b605b6152a1a30c014f
[ "MIT" ]
null
null
null
7952603892_basic.cpp
sehgal-aamulya/SequenceAlignmentAlgorithms
35ce3c9a35c1a681f03c5b605b6152a1a30c014f
[ "MIT" ]
null
null
null
7952603892_basic.cpp
sehgal-aamulya/SequenceAlignmentAlgorithms
35ce3c9a35c1a681f03c5b605b6152a1a30c014f
[ "MIT" ]
null
null
null
// // Created by Aamulya Sehgal on 12/4/21. // #include <string> #include <iostream> #include <fstream> #include <sys/resource.h> #include "SequenceAlignment.hpp" #include "StringGenerator.hpp" #include "StringTrim.hpp" int main(int argc, char *argv[]) { if (argc < 2) { std::cout << "Please include an input file name (./7952603892_basic input.txt)" << std::endl; std::cout << "You can also include an output file name (defaults to output.txt) " "(./7952603892_basic input.txt output.txt)" << std::endl; return EXIT_FAILURE; } constexpr std::array<std::array<int, 4>, 4> mismatchPenalty = { 0, 110, 48, 94, 110, 0, 118, 48, 48, 118, 0, 110, 94, 48, 110, 0 }; constexpr int gapPenalty = 30; constexpr char gapSymbol = '_'; const std::string_view inputFileName{argv[1]}; const std::string_view outputFileName{(argc >= 3) ? argv[2] : "output.txt"}; std::ifstream fin{inputFileName.data()}; std::string strOne, strTwo; std::vector<size_t> j; std::vector<size_t> k; std::getline(fin, strOne); trim(strOne); size_t value; while (fin >> value) { j.push_back(value); } fin.clear(); std::getline(fin, strTwo); trim(strTwo); while (fin >> value) { k.push_back(value); } const auto[stringOne, stringTwo] = inputStringGenerator(strOne, strTwo, j, k); std::ofstream fout{outputFileName.data()}; rusage start, end; const int startReturn = getrusage(RUSAGE_SELF, &start); if (startReturn) return startReturn; const SequenceAlignment sequenceAlignment(stringOne, stringTwo, gapSymbol, gapPenalty, mismatchPenalty); const size_t alignmentCost = sequenceAlignment.align(); const auto[sequenceOne, sequenceTwo] = sequenceAlignment.sequence(); const int endReturn = getrusage(RUSAGE_SELF, &end); if (endReturn) return endReturn; const double diffTime = (end.ru_utime.tv_sec * 1000000.0 + end.ru_utime.tv_usec + end.ru_stime.tv_sec * 1000000.0 + end.ru_stime.tv_usec - start.ru_utime.tv_sec * 1000000.0 - start.ru_utime.tv_usec - start.ru_stime.tv_sec * 1000000.0 - start.ru_stime.tv_usec) / 1000000.0; double diffMemory = end.ru_maxrss - start.ru_maxrss; if (diffMemory == 0.0) diffMemory = end.ru_maxrss; #ifdef __APPLE__ diffMemory /= 1024.0; #endif #ifndef NDEBUG std::cout << "Basic Version:" << std::endl; std::cout << "StringOne: " << stringOne << std::endl; std::cout << "StringTwo: " << stringTwo << std::endl; std::cout << std::endl; std::cout << "Problem Size (sum of string sizes): " << stringOne.size() + stringTwo.size() << std::endl; std::cout << std::endl; #endif if (sequenceOne.size() <= 50) { #ifndef NDEBUG std::cout << sequenceOne << std::endl; std::cout << sequenceTwo << std::endl; #endif fout << sequenceOne << std::endl; fout << sequenceTwo << std::endl; } else { #ifndef NDEBUG std::cout << sequenceOne.substr(0, 50) << " " << sequenceOne.substr(sequenceOne.size() - 50) << std::endl; std::cout << sequenceTwo.substr(0, 50) << " " << sequenceTwo.substr(sequenceTwo.size() - 50) << std::endl; #endif fout << sequenceOne.substr(0, 50) << " " << sequenceOne.substr(sequenceOne.size() - 50) << std::endl; fout << sequenceTwo.substr(0, 50) << " " << sequenceTwo.substr(sequenceTwo.size() - 50) << std::endl; } #ifndef NDEBUG std::cout << alignmentCost << std::endl; std::cout << std::fixed << diffTime << std::endl; std::cout << std::fixed << diffMemory << std::endl; #endif fout << alignmentCost << std::endl; fout << std::fixed << diffTime << std::endl; fout << std::fixed << diffMemory << std::endl; return 0; }
27.355072
106
0.629934
sehgal-aamulya
74475242e369b0e9625b44109b4a69ee8a647456
1,992
cpp
C++
RiocArduino/RORudderServo.cpp
robinz-labs/rioc-arduino
37e752cfc5cf13a61dd03b4556cf33aa18d24814
[ "Apache-2.0" ]
null
null
null
RiocArduino/RORudderServo.cpp
robinz-labs/rioc-arduino
37e752cfc5cf13a61dd03b4556cf33aa18d24814
[ "Apache-2.0" ]
null
null
null
RiocArduino/RORudderServo.cpp
robinz-labs/rioc-arduino
37e752cfc5cf13a61dd03b4556cf33aa18d24814
[ "Apache-2.0" ]
null
null
null
#include "RORudderServo.h" #include "RiocMessager.h" #include <Servo.h> RORudderServo::RORudderServo() { _pin = -1; _mode = -1; _enabled = false; _servo = NULL; } RORudderServo::~RORudderServo() { } bool RORudderServo::setup(byte msg[8], byte address_from) { if (_pin != -1) return false; int pin = msg[2]; int mode = msg[3]; if (pin<=DO_PIN_MAX_NUMBER) { _pin = pin; _mode = mode; _enabled = false; _servo = new Servo(); return true; } return false; } void RORudderServo::execute(byte msg[8], byte address_from) { if (_pin == -1) return; int cmd = msg[1]; if (cmd==0x01) { // SET ANGLE int angle = msg[3]; if (angle > 180) angle = 180; _servo->write(angle); // enable the servo as soon as write the first angle if (!_enabled) setEnabled(true); if (!isSilent()) { byte rsp[] = {0x13, 0x81, _pin, angle, 0, 0, 0, 0}; if (_messager!=NULL) _messager->sendMessage(rsp, address_from); } } else if (cmd==0x02) { // GET ANGLE int angle = _servo->read(); byte rsp[] = {0x13, 0x82, _pin, angle, 0, 0, 0, 0}; if (_messager!=NULL) _messager->sendMessage(rsp, address_from); } else if (cmd==0x03) { // SET ENABLE bool enabled = msg[3]; setEnabled(enabled); if (!isSilent()) { byte rsp[] = {0x13, 0x83, _pin, enabled, 0, 0, 0, 0}; if (_messager!=NULL) _messager->sendMessage(rsp, address_from); } } else if (cmd==0x04) { // GET ENABLE bool enabled = _enabled; //_servo->attached(); byte rsp[] = {0x13, 0x84, _pin, enabled, 0, 0, 0, 0}; if (_messager!=NULL) _messager->sendMessage(rsp, address_from); } } void RORudderServo::process() { } void RORudderServo::setAngle(int angle) { _servo->write(angle); } void RORudderServo::setEnabled(bool enabled) { if (enabled == _enabled) return; if (enabled) { _servo->attach(_pin); } else { _servo->detach(); } _enabled = enabled; }
17.628319
69
0.593876
robinz-labs
7449afbe93d4d2665437c7985ae6933b724e1722
75
cc
C++
project2/kernels/grad_case9.cc
beizai/CompilerProject2
07c99fd0ff0a0f66ac470ded5d11470b1c473b97
[ "MIT" ]
26
2020-05-11T09:00:41.000Z
2021-08-25T16:58:42.000Z
project2/kernels/grad_case9.cc
beizai/CompilerProject2
07c99fd0ff0a0f66ac470ded5d11470b1c473b97
[ "MIT" ]
2
2020-05-10T12:23:30.000Z
2020-06-12T03:20:41.000Z
project2/kernels/grad_case9.cc
beizai/CompilerProject2
07c99fd0ff0a0f66ac470ded5d11470b1c473b97
[ "MIT" ]
30
2020-05-10T05:45:23.000Z
2022-03-10T16:18:33.000Z
#include "../run2.h" void grad_case9(float (&dB)[4][6], float (&dA)[4]) {}
25
53
0.573333
beizai
744d0e53844aa1c5688e86825db28154e7cbf751
2,909
cpp
C++
fucapi2Bimestre/teste2.cpp
taynarodrigues/OpenGL
c1309835313f2a00b07668cfddbea21a26c5b21f
[ "MIT" ]
2
2020-04-05T02:38:14.000Z
2020-04-05T02:48:18.000Z
fucapi2Bimestre/teste2.cpp
taynarodrigues/OpenGL--Computacao-Grafica
c1309835313f2a00b07668cfddbea21a26c5b21f
[ "MIT" ]
null
null
null
fucapi2Bimestre/teste2.cpp
taynarodrigues/OpenGL--Computacao-Grafica
c1309835313f2a00b07668cfddbea21a26c5b21f
[ "MIT" ]
null
null
null
// Fazer código OpenGL para gerar pelo menos duas das seguintes curvas de Bezier (ver imagem). #include <GL/gl.h> #include <GL/glu.h> #include <stdlib.h> #include <GL/glut.h> GLfloat ctrlpoints2[4][3]={ { 0.0, 0.0, 0.0}, {-2.0, 0.3, 0.0}, {-3.0,-1.0, 0.0}, {-4.0, 4.0, 0.0} }; GLfloat ctrlpoints6[4][3]={ { 0.0, 0.0, 0.0}, {-2.0,-0.3, 0.0}, {-3.0, 1.0, 0.0}, {-4.0,-4.0, 0.0} }; void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); /*A forma de trabalhar com curvas por partes de forma geral é a seguinte 1. Você define os pontos de controle 2. Define as funções paramétricas da curva usando glMap1f() 3. Desenha a curva usando glEvalCoord1f() para avaliar os parâmetros nas funções paramétricas previamente criadas com glMap1f() Este processo se deve repetir para cada curva, primeiro glMap1f() depois glEvalCoord1f() para a primeira curva, depois glMap1f() e glEvalCoord1f() para a segunda e assim */ glEnable(GL_MAP1_VERTEX_3); } void display(void) { int i; glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glMap1f(GL_MAP1_VERTEX_3, 0.0,1.0,3,4, &ctrlpoints2[0][0]); glEnable(GL_MAP1_VERTEX_3);// glBegin(GL_LINE_STRIP); for (i = 0; i <= 30; i++) glEvalCoord1f((GLfloat) i/30.0); glEnd(); glPointSize(6.0f); //tamanho do ponto verde O código a seguir exibe os pontos de controle como pontos / // glColor3f(0.0, 1.0, 0.0); glBegin(GL_POINTS); for (i = 0; i < 4; i++) glVertex3fv(&ctrlpoints2[i][0]); glEnd(); //CURVA 2 //O grau da curva têm que ser 3, pelo que a quantidade de pontos de controle é 4. glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, &ctrlpoints6[0][0]); glColor3f(0.0, 1.0, 0.0); //COR VERDE glBegin(GL_LINE_STRIP); for (int j = 0; j <= 30; j++) { glEvalCoord1f((GLfloat)j / 30.0); } glEnd(); glBegin(GL_POINTS); for (int i = 0; i < 6; i++) { glVertex3fv(&ctrlpoints6[i][0]); } glEnd(); glFlush(); } void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (w <= h) glOrtho(-5.0, 5.0, -5.0*(GLfloat)h/(GLfloat)w, 5.0*(GLfloat)h/(GLfloat)w, -5.0, 5.0); else glOrtho(-5.0*(GLfloat)w/(GLfloat)h, 5.0*(GLfloat)w/(GLfloat)h, -5.0, 5.0, -5.0, 5.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (500, 500); glutInitWindowPosition (100, 100); glutCreateWindow("Curva de Bezier "); //cria a janela init (); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMainLoop(); return 0; } // g++ teste2.cpp -o firstOpenGlApp -lglut -lGLU -lGL // ./firstOpenGlApp
26.688073
131
0.609144
taynarodrigues
744d653f35c31e92367a03887fa714945000de7b
9,781
cpp
C++
11_learning_materials/stanford_self_driving_car/perception/descriptors_3d/src/shared/spectral_analysis.cpp
EatAllBugs/autonomous_learning
02ff7b0fa7b131a2f2203505ef5cc7e43b40bc47
[ "MIT" ]
14
2021-09-01T14:25:45.000Z
2022-02-21T08:49:57.000Z
11_learning_materials/stanford_self_driving_car/perception/descriptors_3d/src/shared/spectral_analysis.cpp
yinflight/autonomous_learning
02ff7b0fa7b131a2f2203505ef5cc7e43b40bc47
[ "MIT" ]
null
null
null
11_learning_materials/stanford_self_driving_car/perception/descriptors_3d/src/shared/spectral_analysis.cpp
yinflight/autonomous_learning
02ff7b0fa7b131a2f2203505ef5cc7e43b40bc47
[ "MIT" ]
3
2021-10-10T00:58:29.000Z
2022-01-23T13:16:09.000Z
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2009, Willow Garage * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ #include <descriptors_3d/shared/spectral_analysis.h> using namespace std; // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- SpectralAnalysis::SpectralAnalysis(double support_radius) { support_radius_ = support_radius; spectral_computed_ = false; } // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- SpectralAnalysis::~SpectralAnalysis() { clearSpectral(); } // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- void SpectralAnalysis::clearSpectral() { unsigned int nbr_data = normals_.size(); for (unsigned int i = 0 ; i < nbr_data ; i++) { if (normals_[i] != NULL) { delete normals_[i]; delete middle_eig_vecs_[i]; delete tangents_[i]; delete eigenvalues_[i]; } } normals_.clear(); middle_eig_vecs_.clear(); tangents_.clear(); eigenvalues_.clear(); spectral_computed_ = false; } // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- int SpectralAnalysis::analyzeInterestPoints(const sensor_msgs::PointCloud& data, cloud_kdtree::KdTree& data_kdtree, const vector<const geometry_msgs::Point32*>& interest_pts) { if (spectral_computed_) { ROS_ERROR("SpectralAnalysis::analyzeInterestPoints() spectral info already exists"); return -1; } // ---------------------------------------- // Ensure some regions are provided unsigned int nbr_interest_pts = interest_pts.size(); // ---------------------------------------- // Ensure radius is valid if (support_radius_ < 1e-6) { ROS_ERROR("SpectralAnalysis::analyzeInterestPoints() support radius must be set to a positive value"); return -1; } // ---------------------------------------- // Allocate accordingly normals_.assign(nbr_interest_pts, NULL); middle_eig_vecs_.assign(nbr_interest_pts, NULL); tangents_.assign(nbr_interest_pts, NULL); eigenvalues_.assign(nbr_interest_pts, NULL); // ---------------------------------------- // Find neighboring points within radius for each interest point int int_nbr_interest_pts = static_cast<int> (nbr_interest_pts); #pragma omp parallel for schedule(dynamic) for (int i = 0 ; i < int_nbr_interest_pts ; i++) { // --------------------- // Retrieve next interest point const geometry_msgs::Point32* curr_interest_pt = interest_pts[static_cast<size_t> (i)]; if (curr_interest_pt == NULL) { ROS_WARN("SpectralAnalysis::analyzeInterestPoints() passed NULL interest point"); } else { // --------------------- // Retrieve neighboring points around the interest point vector<int> neighbor_indices; vector<float> neighbor_distances; // unused // radiusSearch returning false (0 neighbors) is okay data_kdtree.radiusSearch(*curr_interest_pt, support_radius_, neighbor_indices, neighbor_distances); // --------------------- // Compute spectral information for interest point computeSpectralInfo(data, neighbor_indices, static_cast<size_t> (i)); } } spectral_computed_ = true; return 0; } // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- int SpectralAnalysis::analyzeInterestRegions(const sensor_msgs::PointCloud& data, cloud_kdtree::KdTree& data_kdtree, const vector<const vector<int>*>& interest_region_indices) { if (spectral_computed_) { ROS_ERROR("SpectralAnalysis::analyzeInterestRegions() spectral info already exists"); return -1; } // ---------------------------------------- // Ensure some regions are provided unsigned int nbr_regions = interest_region_indices.size(); // ---------------------------------------- // Allocate accordingly normals_.assign(nbr_regions, NULL); middle_eig_vecs_.assign(nbr_regions, NULL); tangents_.assign(nbr_regions, NULL); eigenvalues_.assign(nbr_regions, NULL); // ---------------------------------------- // For each interest region, either: // Use the region itself as the support volume // Find a support volume within a radius from the region's centroid int int_nbr_regions = static_cast<int> (nbr_regions); #pragma omp parallel for schedule(dynamic) for (int i = 0 ; i < int_nbr_regions ; i++) { // --------------------- // Retrieve next interest region // (By default, use the interest region as the support volume) const vector<int>* curr_interest_region = interest_region_indices[static_cast<size_t> (i)]; if (curr_interest_region == NULL) { ROS_WARN("SpectralAnalysis::analyzeInterestRegions() passed NULL interest region"); } else { // Do a range search around the interest region's CENTROID if indicated vector<int> neighbor_indices; if (support_radius_ > 1e-6) { // Compute centroid of interest region geometry_msgs::Point32 region_centroid; cloud_geometry::nearest::computeCentroid(data, *curr_interest_region, region_centroid); vector<float> neighbor_distances; // unused // radiusSearch returning false (0 neighbors) is okay data_kdtree.radiusSearch(region_centroid, support_radius_, neighbor_indices, neighbor_distances); // Now point to the neighboring points from radiusSearch curr_interest_region = &neighbor_indices; } // --------------------- // Compute spectral information for interest region computeSpectralInfo(data, *curr_interest_region, static_cast<size_t> (i)); } } // ---------------------------------------- spectral_computed_ = true; return 0; } // -------------------------------------------------------------- /* See function definition */ // -------------------------------------------------------------- void SpectralAnalysis::computeSpectralInfo(const sensor_msgs::PointCloud& data, const vector<int>& support_volume_indices, const size_t idx) { // ---------------------------------------- // Need 3-by-3 matrix to have full rank if (support_volume_indices.size() < 3) { ROS_DEBUG("SpectralAnalysis::computeSpectralInfo() not enough neighbors for interest sample %u", idx); return; } // ---------------------------------------- // Allocate for new data Eigen::Vector3d* new_normal = new Eigen::Vector3d(); Eigen::Vector3d* new_middle_eigvec = new Eigen::Vector3d(); Eigen::Vector3d* new_tangent = new Eigen::Vector3d(); Eigen::Vector3d* new_eig_vals = new Eigen::Vector3d(); // ---------------------------------------- // Eigen-analysis of support volume // smallest eigenvalue = index 0 geometry_msgs::Point32 centroid; Eigen::Matrix3d eigen_vectors; cloud_geometry::nearest::computePatchEigenNormalized(data, support_volume_indices, eigen_vectors, *(new_eig_vals), centroid); // ---------------------------------------- // Populate containers for (unsigned int j = 0 ; j < 3 ; j++) { (*(new_normal))[j] = eigen_vectors(j, 0); (*(new_middle_eigvec))[j] = eigen_vectors(j, 1); (*(new_tangent))[j] = eigen_vectors(j, 2); } // Make unit length new_normal->normalize(); new_middle_eigvec->normalize(); new_tangent->normalize(); normals_[idx] = new_normal; middle_eig_vecs_[idx] = new_middle_eigvec; tangents_[idx] = new_tangent; eigenvalues_[idx] = new_eig_vals; }
37.190114
106
0.584296
EatAllBugs
744f55bb19e02078fff95f271bb9ebe265ffa084
22,099
cpp
C++
src/core/models/error/error_model_factory.cpp
gunjanbaid/octopus
b19e825d10c16bc14565338aadf4aee63c8fe816
[ "MIT" ]
null
null
null
src/core/models/error/error_model_factory.cpp
gunjanbaid/octopus
b19e825d10c16bc14565338aadf4aee63c8fe816
[ "MIT" ]
null
null
null
src/core/models/error/error_model_factory.cpp
gunjanbaid/octopus
b19e825d10c16bc14565338aadf4aee63c8fe816
[ "MIT" ]
null
null
null
// Copyright (c) 2015-2019 Daniel Cooke // Use of this source code is governed by the MIT license that can be found in the LICENSE file. #include "error_model_factory.hpp" #include <array> #include <unordered_map> #include <fstream> #include <sstream> #include <iostream> #include <boost/optional.hpp> #include <boost/functional/hash.hpp> #include "utils/string_utils.hpp" #include "exceptions/user_error.hpp" #include "exceptions/malformed_file_error.hpp" #include "basic_repeat_based_indel_error_model.hpp" #include "repeat_based_snv_error_model.hpp" #include "custom_repeat_based_indel_error_model.hpp" namespace octopus { static constexpr std::array<LibraryPreparation, 3> libraries { LibraryPreparation::pcr, LibraryPreparation::pcr_free, LibraryPreparation::tenx }; static constexpr std::array<Sequencer, 8> sequencers { Sequencer::hiseq_2000, Sequencer::hiseq_2500, Sequencer::hiseq_4000, Sequencer::xten, Sequencer::novaseq, Sequencer::bgiseq_500, Sequencer::pacbio, Sequencer::pacbio_css }; std::ostream& operator<<(std::ostream& out, const LibraryPreparation& library) { switch (library) { case LibraryPreparation::pcr: out << "PCR"; break; case LibraryPreparation::pcr_free: out << "PCR-free"; break; case LibraryPreparation::tenx: out << "10X"; break; } return out; } template <typename Range> std::ostream& join(const Range& range, std::ostream& os, const std::string& delim = " ") { if (std::cbegin(range) != std::cend(range)) { using T = typename std::iterator_traits<decltype(std::cbegin(range))>::value_type; std::copy(std::cbegin(range), std::prev(std::cend(range)), std::ostream_iterator<T> {os, delim.c_str()}); os << *std::prev(std::cend(range)); } return os; } class UnknownLibraryPreparation : public UserError { std::string name_; std::string do_where() const override { return "operator>>(std::istream&, LibraryPreparation&)"; } std::string do_why() const override { return "The library preparation name " + name_ + " is unknown"; } std::string do_help() const override { std::ostringstream ss {}; ss << "Choose a valid library preparation name ["; join(libraries, ss, ", "); ss << "]"; return ss.str(); } public: UnknownLibraryPreparation(std::string name) : name_ {std::move(name)} {} }; std::istream& operator>>(std::istream& in, LibraryPreparation& result) { std::string token; in >> token; utils::capitalise(token); if (token == "PCR") result = LibraryPreparation::pcr; else if (token == "PCR-FREE" || token == "PCRF") result = LibraryPreparation::pcr_free; else if (token == "10X") result = LibraryPreparation::tenx; else throw UnknownLibraryPreparation {token}; return in; } std::ostream& operator<<(std::ostream& out, const Sequencer& sequencer) { switch (sequencer) { case Sequencer::hiseq_2000: out << "HiSeq-2000"; break; case Sequencer::hiseq_2500: out << "HiSeq-2500"; break; case Sequencer::hiseq_4000: out << "HiSeq-4000"; break; case Sequencer::xten: out << "X10"; break; case Sequencer::novaseq: out << "NovaSeq"; break; case Sequencer::bgiseq_500: out << "BGISEQ-500"; break; case Sequencer::pacbio: out << "PacBio"; break; case Sequencer::pacbio_css: out << "PacBioCSS"; break; } return out; } class UnknownSequencer : public UserError { std::string name_; std::string do_where() const override { return "operator>>(std::istream&, Sequencer&)"; } std::string do_why() const override { return "The sequencer name " + name_ + " is unknown"; } std::string do_help() const override { std::ostringstream ss {}; ss << "Choose a valid sequencer name ["; join(sequencers, ss, ", "); ss << "]"; return ss.str(); } public: UnknownSequencer(std::string name) : name_ {std::move(name)} {} }; std::istream& operator>>(std::istream& in, Sequencer& result) { std::string token; in >> token; utils::capitalise(token); if (token == "HISEQ-2000") result = Sequencer::hiseq_2000; else if (token == "HISEQ-2500") result = Sequencer::hiseq_2500; else if (token == "HISEQ-4000") result = Sequencer::hiseq_4000; else if (token == "X10") result = Sequencer::xten; else if (token == "NOVASEQ") result = Sequencer::novaseq; else if (token == "BGISEQ-500") result = Sequencer::bgiseq_500; else if (token == "PACBIO") result = Sequencer::pacbio; else if (token == "PACBIOCSS") result = Sequencer::pacbio_css; else throw UnknownSequencer {token}; return in; } LibraryPreparation to_library(const std::string& name) { LibraryPreparation result; std::istringstream ss {name}; ss >> result; return result; } Sequencer to_sequencer(const std::string& name) { Sequencer result; std::istringstream ss {name}; ss >> result; return result; } struct ModelConfigHash { std::size_t operator()(const ModelConfig& config) const { using boost::hash_combine; std::size_t seed {}; hash_combine(seed, config.library); hash_combine(seed, config.sequencer); return seed; } }; bool operator==(const ModelConfig& lhs, const ModelConfig& rhs) noexcept { return lhs.library == rhs.library && lhs.sequencer == rhs.sequencer; } using RepeatBasedIndelModelParameterMap = std::unordered_map<ModelConfig, BasicRepeatBasedIndelErrorModel::Parameters, ModelConfigHash>; static const RepeatBasedIndelModelParameterMap builtin_indel_models {{ { {LibraryPreparation::pcr_free, Sequencer::hiseq_2000}, { {45,45,43,43,41,38,35,32,29,25,21,20,19,18,17,17,16,16,15,14,14,13,12,12,11,10,9,9,8,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5}, {45,45,45,41,39,34,30,24,21,18,15,13,12,10,8,7,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3}, {45,45,42,40,35,29,26,24,22,21,20,19,18,18,17,17,16,16,15,15,15,14,13,13,12,12,11,11,10,10,9,9,9,7,7,7,6,6,5,4,4,4,4,4,4,4,4,4,3}, {45,45,40,36,30,28,26,25,23,22,22,22,21,21,20,20,20,18,17,16,14,14,14,14,12,11,11,11,10,10,10,7,7,7,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr_free, Sequencer::hiseq_2500}, { {45,45,43,43,41,38,35,32,29,25,21,20,19,18,17,17,16,16,15,14,14,13,12,12,11,10,9,9,8,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5}, {45,45,45,41,39,34,30,24,21,18,15,13,12,10,8,7,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3}, {45,45,42,40,35,29,26,24,22,21,20,19,18,18,17,17,16,16,15,15,15,14,13,13,12,12,11,11,10,10,9,9,9,7,7,7,6,6,5,4,4,4,4,4,4,4,4,4,3}, {45,45,40,36,30,28,26,25,23,22,22,22,21,21,20,20,20,18,17,16,14,14,14,14,12,11,11,11,10,10,10,7,7,7,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr_free, Sequencer::hiseq_4000}, { {45,45,43,43,41,38,35,32,29,25,21,20,19,18,17,17,16,16,15,14,14,13,12,12,11,10,9,9,8,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5}, {45,45,45,41,39,34,30,24,21,18,15,13,12,10,8,7,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3}, {45,45,42,40,35,29,26,24,22,21,20,19,18,18,17,17,16,16,15,15,15,14,13,13,12,12,11,11,10,10,9,9,9,7,7,7,6,6,5,4,4,4,4,4,4,4,4,4,3}, {45,45,40,36,30,28,26,25,23,22,22,22,21,21,20,20,20,18,17,16,14,14,14,14,12,11,11,11,10,10,10,7,7,7,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr_free, Sequencer::xten}, { {45,45,47,44,43,39,37,33,29,26,24,22,21,21,20,19,18,18,17,16,15,14,14,13,13,13,12,12,11,11,10,10,10,9,9,9,9,9,9,9,9,9,9,9,8}, {45,45,47,45,42,38,33,28,24,21,19,18,16,15,13,12,11,11,11,10,10,9,9,9,9,9,9,9,8,8,8,8,8,8,8,6}, {45,45,43,40,35,31,28,26,24,23,22,21,20,20,19,19,18,17,17,17,16,15,15,14,13,13,12,11,11,11,10,10,10,8,8,8,6,6,5}, {45,45,42,36,32,29,27,26,24,23,23,22,21,21,20,19,18,17,15,14,13,13,13,11,11,11,11,10,7,7,7,5,5,5,5,5,4} } }, { {LibraryPreparation::pcr_free, Sequencer::novaseq}, { {45,45,43,42,41,38,35,32,29,26,24,22,21,21,20,19,18,17,16,16,15,14,13,12,11,11,10,9,8,7,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3}, {45,45,43,40,37,33,28,21,19,17,15,13,12,11,8,7,7,6,6,6,5,5,5,5,3}, {45,45,39,38,33,29,26,25,23,22,21,20,20,19,18,18,17,17,16,15,15,14,14,13,12,11,10,9,9,9,8,8,8,8,8,6,5,5,5,4,4,4,4,4,4,3}, {45,45,39,34,30,27,25,25,22,22,21,21,21,21,19,19,19,16,13,13,13,11,11,11,11,11,10,9,8,7,6,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr_free, Sequencer::bgiseq_500}, { {45,45,47,44,43,39,37,33,29,26,24,22,21,21,20,19,18,18,17,16,15,14,14,13,13,13,12,12,11,11,10,10,10,9,9,9,9,9,9,9,9,9,9,9,8}, {45,45,47,45,42,38,33,28,24,21,19,18,16,15,13,12,11,11,11,10,10,9,9,9,9,9,9,9,8,8,8,8,8,8,8,6}, {45,45,43,40,35,31,28,26,24,23,22,21,20,20,19,19,18,17,17,17,16,15,15,14,13,13,12,11,11,11,10,10,10,8,8,8,6,6,5}, {45,45,42,36,32,29,27,26,24,23,23,22,21,21,20,19,18,17,15,14,13,13,13,11,11,11,11,10,7,7,7,5,5,5,5,5,4} } }, { {LibraryPreparation::pcr_free, Sequencer::pacbio}, { {13,13,11,10,9,8,7,7,7,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4}, {13,13,10,8,7,7,7,7,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4}, {13,13,8,7,6,6,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, {13,13,7,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4} } }, { {LibraryPreparation::pcr_free, Sequencer::pacbio_css}, { {31,31,27,24,21,18,16,14,13,12,11,10,10,9,9,8,8,8,8,7,7,7,7,7,7,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5}, {31,31,25,21,18,16,14,12,10,9,8,8,6,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4}, {31,31,24,22,20,17,15,14,12,11,10,10,9,9,9,8,8,8,8,7,7,7,7,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3}, {31,31,22,19,17,15,14,13,11,11,10,10,9,9,8,8,7,7,6,6,6,6,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr, Sequencer::hiseq_2000}, { {45,45,43,41,40,36,34,30,24,20,16,13,12,11,10,10,9,9,8,8,7,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,42,40,37,33,27,21,17,15,12,10,9,7,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,38,37,32,26,21,18,16,14,14,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,7,7,7,7,6,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,37,32,26,22,20,19,18,17,17,16,15,15,14,13,13,12,12,12,12,10,10,10,9,9,7,7,7,7,6,6,6,6,4,3} } }, { {LibraryPreparation::pcr, Sequencer::hiseq_2500}, { {45,45,43,41,40,36,34,30,24,20,16,13,12,11,10,10,9,9,8,8,7,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,42,40,37,33,27,21,17,15,12,10,9,7,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,38,37,32,26,21,18,16,14,14,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,7,7,7,7,6,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,37,32,26,22,20,19,18,17,17,16,15,15,14,13,13,12,12,12,12,10,10,10,9,9,7,7,7,7,6,6,6,6,4,3} } }, { {LibraryPreparation::pcr, Sequencer::hiseq_4000}, { {45,45,43,41,40,36,34,30,24,20,16,13,12,11,10,10,9,9,8,8,7,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,42,40,37,33,27,21,17,15,12,10,9,7,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,38,37,32,26,21,18,16,14,14,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,7,7,7,7,6,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,37,32,26,22,20,19,18,17,17,16,15,15,14,13,13,12,12,12,12,10,10,10,9,9,7,7,7,7,6,6,6,6,4,3} } }, { {LibraryPreparation::pcr, Sequencer::xten}, { {60,60,44,42,40,36,34,30,24,20,16,13,12,11,10,9,9,8,8,8,7,7,7,6,6,6,5,5,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3}, {60,60,42,40,37,35,28,22,18,15,12,10,9,7,6,4,4,5,5,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, {60,60,38,37,33,27,21,18,16,15,14,13,13,12,12,12,11,11,10,10,9,9,9,9,8,7,7,6,6,6,5,5,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3}, {60,60,38,33,26,22,20,19,18,18,17,16,17,15,14,14,14,14,13,12,12,11,10,10,8,7,7,6,6,5,5,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3} } }, { {LibraryPreparation::pcr, Sequencer::novaseq}, { {45,45,43,41,40,36,34,30,24,20,16,13,12,11,10,10,9,9,8,8,7,7,7,6,6,6,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,42,40,37,33,27,21,17,15,12,10,9,7,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,38,37,32,26,21,18,16,14,14,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,7,7,7,7,6,6,6,5,5,4,4,4,4,4,4,4,3}, {45,45,37,32,26,22,20,19,18,17,17,16,15,15,14,13,13,12,12,12,12,10,10,10,9,9,7,7,7,7,6,6,6,6,4,3} } }, { {LibraryPreparation::pcr, Sequencer::bgiseq_500}, { {60,60,49,47,43,39,35,31,25,21,17,14,13,12,11,11,10,10,9,9,9,8,8,8,8,8,7,7,7,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,4}, {60,60,48,45,42,38,32,26,22,17,14,12,10,9,8,7,6,6,6,5,5,5,5,5,4,4,4,4,4,4,4,4,3}, {60,60,44,42,36,29,22,19,17,15,15,14,14,13,13,13,12,12,12,11, 11,10,10,10,9,9,9,8,8,8,8,8,8,7,7,6,6,6,5,4,4,4,4,3}, {60,60,41,36,28,23,21,20,19,18,18,17,17,16,15,15,14,13,12,12,12,12,10,9,9,9,9,8,8,7,7,7,7,6,6,6,6,5,5,5,5,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::pcr, Sequencer::pacbio}, { {13,13,11,10,9,8,7,7,7,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4}, {13,13,10,8,7,7,7,7,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4}, {13,13,8,7,6,6,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, {13,13,7,6,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4} } }, { {LibraryPreparation::pcr, Sequencer::pacbio_css}, { {40,40,31,29,28,24,21,19,17,15,13,12,11,10,10,9,9,8,8,8,7,7,6,6,6,6,5,5,5,5,4}, {40,40,33,31,28,22,17,13,12,10,9,8,7,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {40,40,30,27,22,18,16,15,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,8,7,7,6,6,6,6,5,5,5,4}, {40,40,28,25,19,16,15,14,12,12,12,12,11,11,10,10,10,9,9,9,8,7,7,7,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::tenx, Sequencer::hiseq_2000}, { {45,45,36,34,30,27,26,24,20,16,13,12,11,10,9,8,8,7,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,4}, {45,45,34,31,28,24,21,18,16,14,12,10,9,8,8,8,7,7,7,7,7,7,7,7,7,7,6,3}, {45,45,34,33,29,23,18,15,14,13,12,12,11,11,10,10,10,9,9,9,9,8,8,8,8,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5}, {45,45,32,29,23,19,17,16,15,14,14,13,12,12,11,11,11,11,11,9,9,9,7,7,7,7,6} } }, { {LibraryPreparation::tenx, Sequencer::hiseq_2500}, { {45,45,37,35,30,28,26,25,21,17,14,12,11,11,10,10,9,9,8,8,8,7,7,7,7,7,7,7,6}, {45,45,36,33,29,26,22,20,17,15,13,11,10,9,9,9,9,8}, {45,45,33,32,28,23,18,15,13,12,12,11,11,10,10,9,9,9,8,8,8,8,7,7,7,6,6,6,6,6,5}, {45,45,31,28,23,19,16,15,14,13,12,12,11,10,10,10,10,10,10,9,9,7,7,6,6,6,5} } }, { {LibraryPreparation::tenx, Sequencer::hiseq_4000}, { {45,45,37,35,30,28,26,25,21,17,14,12,11,11,10,10,9,9,8,8,8,7,7,7,7,7,7,7,6}, {45,45,36,33,29,26,22,20,17,15,13,11,10,9,9,9,9,8}, {45,45,33,32,28,23,18,15,13,12,12,11,11,10,10,9,9,9,8,8,8,8,7,7,7,6,6,6,6,6,5}, {45,45,31,28,23,19,16,15,14,13,12,12,11,10,10,10,10,10,10,9,9,7,7,6,6,6,5} } }, { {LibraryPreparation::tenx, Sequencer::xten}, { {45,45,31,29,28,24,21,19,17,15,13,12,11,10,10,9,9,8,8,8,7,7,6,6,6,6,5,5,5,5,4}, {45,45,33,31,28,22,17,13,12,10,9,8,7,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,30,27,22,18,16,15,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,8,7,7,6,6,6,6,5,5,5,4}, {45,45,28,25,19,16,15,14,12,12,12,12,11,11,10,10,10,9,9,9,8,7,7,7,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::tenx, Sequencer::novaseq}, { {45,45,31,29,28,24,21,19,17,15,13,12,11,10,10,9,9,8,8,8,7,7,6,6,6,6,5,5,5,5,4}, {45,45,33,31,28,22,17,13,12,10,9,8,7,6,5,5,5,4,4,4,4,4,4,4,4,4,4,3}, {45,45,30,27,22,18,16,15,13,13,12,12,11,11,11,10,10,10,9,9,9,8,8,8,7,7,6,6,6,6,5,5,5,4}, {45,45,28,25,19,16,15,14,12,12,12,12,11,11,10,10,10,9,9,9,8,7,7,7,5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,3} } }, { {LibraryPreparation::tenx, Sequencer::bgiseq_500}, { {45,45,37,35,30,28,26,25,21,17,14,12,11,11,10,10,9,9,8,8,8,7,7,7,7,7,7,7,6}, {45,45,36,33,29,26,22,20,17,15,13,11,10,9,9,9,9,8}, {45,45,34,33,29,23,18,15,14,13,12,12,11,11,10,10,10,9,9,9,9,8,8,8,8,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5}, {45,45,32,29,23,19,17,16,15,14,14,13,12,12,11,11,11,11,11,9,9,9,7,7,7,7,6} } } }}; BasicRepeatBasedIndelErrorModel::Parameters lookup_builtin_indel_model(const ModelConfig config) { return builtin_indel_models.at(config); } bool use_snv_error_model(const ModelConfig config) { return config.sequencer != Sequencer::pacbio && config.sequencer != Sequencer::pacbio_css; } using RepeatBasedSnvModelParameterMap = std::unordered_map<LibraryPreparation, BasicRepeatBasedSNVErrorModel::Parameters>; static const RepeatBasedSnvModelParameterMap builtin_snv_models {{ { LibraryPreparation::pcr_free, { {125,125,60,55,50,30,20,15,12,12,10,10,10,10,8,7,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,60,60,52,52,38,38,22,22,17,17,15,15,13,13,10,10,10,10,8,8,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,125,55,55,55,40,40,40,25,25,25,19,19,19,11,11,11,9,9,9,7,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1} } }, { LibraryPreparation::pcr, { {125,125,60,55,38,23,16,14,11,10,9,8,7,7,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,60,60,52,52,38,38,22,22,17,17,15,15,13,13,10,10,10,10,8,8,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,125,55,55,55,40,40,40,25,25,25,19,19,19,11,11,11,9,9,9,7,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1} }}, { LibraryPreparation::tenx, { {125,125,60,55,38,23,16,14,11,10,9,8,7,7,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,60,60,52,52,38,38,22,22,17,17,15,15,13,13,10,10,10,10,8,8,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1}, {125,125,125,55,55,55,40,40,40,25,25,25,19,19,19,11,11,11,9,9,9,7,7,6,6,6,6,6,6,5,5,5,5,4,4,4,3,3,3,3,2,2,2,2,2,1,1,1,1,1,1} }} }}; boost::optional<BasicRepeatBasedSNVErrorModel::Parameters> lookup_builtin_snv_model(const ModelConfig config) { if (use_snv_error_model(config)) { return builtin_snv_models.at(config.library); } else { return boost::none; } } class MalformedErrorModelFile : public MalformedFileError { std::string do_where() const override { return "make_indel_error_model"; } std::string do_help() const override { return "refer to documentation on custom error models or use provided Python script"; } public: MalformedErrorModelFile(boost::filesystem::path file) : MalformedFileError {std::move(file), "model"} {} }; std::unique_ptr<SnvErrorModel> make_snv_error_model(const ModelConfig config) { auto model = lookup_builtin_snv_model(config); if (model) { return std::make_unique<BasicRepeatBasedSNVErrorModel>(std::move(*model)); } else { return nullptr; } } std::unique_ptr<IndelErrorModel> make_indel_error_model(const ModelConfig config) { return std::make_unique<BasicRepeatBasedIndelErrorModel>(lookup_builtin_indel_model(config)); } ModelConfig parse_model_config(const std::string& label) { auto result = default_model_config; const auto library_end_pos = label.find('.'); const auto library_name = label.substr(0, library_end_pos); if (!library_name.empty()) { result.library = to_library(library_name); } if (library_end_pos != std::string::npos) { const auto sequencer_name = label.substr(library_end_pos + 1); if (!sequencer_name.empty()) { result.sequencer = to_sequencer(sequencer_name); } } return result; } ErrorModel make_error_model(const std::string& label) { const auto config = parse_model_config(label); return {make_indel_error_model(config), make_snv_error_model(config)}; } ErrorModel make_error_model(const boost::filesystem::path& model_filename) { std::ifstream model_file {model_filename.string()}; std::string model_str {static_cast<std::stringstream const&>(std::stringstream() << model_file.rdbuf()).str()}; auto params = make_penalty_map(std::move(model_str)); if (!params.open) { throw MalformedErrorModelFile {model_filename}; } ErrorModel result {}; if (params.extend) { result.indel = std::make_unique<CustomRepeatBasedIndelErrorModel>(std::move(*params.open), std::move(*params.extend)); } else { result.indel = std::make_unique<CustomRepeatBasedIndelErrorModel>(std::move(*params.open)); } result.snv = make_snv_error_model(default_model_config); return result; } } // namespace octopus
41.933586
142
0.569257
gunjanbaid
74523286fde903feac0517ed6f46f645a50ac715
9,472
cpp
C++
animer/main.cpp
Benjins/GBADev
0a968a1aa1ee38b57644a1bb8d27f2c5332e3c90
[ "MIT" ]
null
null
null
animer/main.cpp
Benjins/GBADev
0a968a1aa1ee38b57644a1bb8d27f2c5332e3c90
[ "MIT" ]
null
null
null
animer/main.cpp
Benjins/GBADev
0a968a1aa1ee38b57644a1bb8d27f2c5332e3c90
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "../toolsCode/Renderer.h" #include "../toolsCode/Timer.h" #include "../toolsCode/openfile.h" #define TILE_INDEX_MULTIPLIER 24 void* bitmapData = NULL; #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) #define ARRAY_COUNT(x) (sizeof(x) / sizeof((x)[0])) #define SAFE_FREE(x) {if(x){free(x); (x) = nullptr;}} typedef struct { char* start; int length; }Token; inline float clamp(float val, float min, float max) { return MIN(max, MAX(min, val)); } inline int clamp(int val, int min, int max) { return MIN(max, MAX(min, val)); } inline bool RangeCheck(int a, int b, int c) { return (a < b) && (b < c); } enum KeyState { OFF = 0, RELEASE = 1, PRESS = 2, HOLD = 3 }; KeyState keyStates[256] = {}; inline KeyState StateFromBools(bool wasDown, bool isDown) { return (KeyState)((wasDown ? 1 : 0) | (isDown ? 2 : 0)); } struct WindowObj; const char* arg1Str; int arg1Length; WindowObj* windowObj; int frameWidth = 0; int frameHeight = 0; float zoomLevel = 1.0f; int xOffset = 0; int yOffset = 0; int currentPaintIndex = 0; int currMouseX = 0; int currMouseY = 0; int mouseState = 0; #include "AnimAsset.h" AnimAsset animAsset = {}; int animClipIndex = 0; float animTime = 0.0f; bool isPlaying = true; int white = 0xFFFFFFFF; BitmapData whiteCol = {&white, 1, 1}; int circleData[256] = {}; BitmapData cyanCircle = {circleData, 16, 16}; int plusData[256] = {}; BitmapData plusSign = {plusData, 16, 16}; int crossData[256] = {}; BitmapData crossSign = {crossData, 16, 16}; Timer timer; void Init(){ ReadAnimAssetFile(&animAsset, "anim.txt", arg1Str, arg1Length); for(int i = 0; i < 16; i++){ crossData[17*i] = 0xEE2222; crossData[16*i+16-i] = 0xEE2222; } for(int i = 0; i < 16; i++){ plusData[128+i] = 0xFFFFFF; plusData[i*16+8] = 0xFFFFFF; } for(int j = 0; j < 16; j++){ float rSqr = 64; float heightSqr = (8 - j)*(8 - j); float width = sqrt(rSqr - heightSqr); for(int i = 0; i < 16; i++){ int idx = j*16+i; if(abs(8 - i) < (int)width){ circleData[idx] = 0xFFFFFF; } else if(abs(8 - i) < width){ float widthFrac = width - (int)width; unsigned char amt = (unsigned char)(width * 255); circleData[idx] = amt | (amt << 8) | (amt << 16); } } } } char textBuffer[256] = {}; char textBuffer2[256] = {}; void RunFrame(){ float deltaTime = (float)timer.GetTimeSince(); timer.Reset(); if(isPlaying){ animTime += deltaTime; } if (keyStates['W'] > 1) { char fullAssetFileName[256] = {}; sprintf(fullAssetFileName, "%.*s/%s", arg1Length, arg1Str, "anim.txt"); SaveAnimAssetFile(&animAsset, fullAssetFileName); } BitmapData frameBuffer = { (int*)bitmapData, frameWidth, frameHeight }; memset(bitmapData, 0, frameBuffer.width*frameBuffer.height * 4); for(int i = 0; i < animAsset.animClipCount; i++){ DrawText(frameBuffer, animAsset.animClips[i].name, frameBuffer.width - 180, 100*i+40, 150, 40); if(Button(frameBuffer, frameBuffer.width - 180, 100*i+50, 50, 30, 0x777777, 0xEEEEEE, 0xDDDDDD, "")){ animClipIndex = i; animTime = 0; } } //Useful for seeing performance //DrawText(frameBuffer, timeStr, 400, 400, 500, 100); DrawBox(frameBuffer, 20, frameBuffer.height - 40, frameBuffer.width - 220, 30, white); int textBox = 0; if(TextBox(frameBuffer, textBuffer, sizeof(textBuffer), 500, 200, 100, 30)){ textBox = 1; } if(TextBox(frameBuffer, textBuffer2, sizeof(textBuffer2), 500, 260, 100, 30)){ textBox = 1; } int frameLength = 0; for(int i = 0; i < animAsset.animClips[animClipIndex].keyFrameCount; i++){ frameLength += animAsset.animClips[animClipIndex].keyFrames[i].duration; } float animLengthInSeconds = ((float)frameLength)/60.0f; while(animTime > animLengthInSeconds){ animTime -= animLengthInSeconds; } int secondLength = (frameLength+59)/60; int timelinePixelWidth = frameBuffer.width - 240; for(int i = 0; i <= secondLength; i++){ int x = 20 + (timelinePixelWidth/secondLength)*i; DrawBox(frameBuffer, x, frameBuffer.height - 80, 20, 70, white); } int animTickX = (animTime/animLengthInSeconds)*timelinePixelWidth; DrawBox(frameBuffer, animTickX, frameBuffer.height - 90, 20, 80, 0xFF7777FF); DrawText(frameBuffer, (isPlaying ? "Pause" : "Play"), frameBuffer.width - 180, frameBuffer.height - 90, 150, 40); if(Button(frameBuffer, frameBuffer.width - 180, frameBuffer.height - 80, 100, 50, 0x777777, 0xEEEEEE, 0xDDDDDD, "")){ isPlaying = !isPlaying; } if(mouseState == HOLD && currMouseX > 20 && currMouseX < frameBuffer.width - 220 && currMouseY > frameBuffer.height - 100 && currMouseY < frameBuffer.height){ float projectedAnimTime = ((float)currMouseX - 10)/timelinePixelWidth * animLengthInSeconds; animTime = clamp(projectedAnimTime, 0.0f, animLengthInSeconds); } else if(mouseState == HOLD && currMouseY < frameBuffer.height - 150 && currMouseY > frameBuffer.height - 200){ int frameLength = 0; for(int i = 0; i < animAsset.animClips[animClipIndex].keyFrameCount; i++){ float pixelX = (float(frameLength))/60 / animLengthInSeconds * timelinePixelWidth; if(currMouseX > pixelX && currMouseX < pixelX + 50){ float pixelOffset = pixelX + 25 - currMouseX; float frameOffset = pixelOffset / timelinePixelWidth * animLengthInSeconds * 60; int offsetInt = (frameOffset < 0 ? -1 : 1) * (int)((frameOffset < 0 ? -frameOffset : frameOffset)); if(i != 0){ animAsset.animClips[animClipIndex].keyFrames[i-1].duration -= offsetInt; if (i != animAsset.animClips[animClipIndex].keyFrameCount - 1) { animAsset.animClips[animClipIndex].keyFrames[i].duration += offsetInt; } } break; } frameLength += animAsset.animClips[animClipIndex].keyFrames[i].duration; } } else if(mouseState == RELEASE && currMouseY < frameBuffer.height - 100 && currMouseY > frameBuffer.height - 150){ int startTime = 0; for(int i = 0; i < animAsset.animClips[animClipIndex].keyFrameCount; i++){ float pixelX = ((float)startTime)/60/animLengthInSeconds * timelinePixelWidth; if(currMouseX > pixelX && currMouseX < pixelX + 50){ char fileName[256] = {}; if(OpenFile(fileName, windowObj, "bmp", "BMP files(*.bmp)", arg1Str, arg1Length)){ free(animAsset.animClips[animClipIndex].keyFrames[i].spriteData.data); free(animAsset.animClips[animClipIndex].keyFrames[i].fileName); int newFileNameLength = strlen(fileName); char* newFileName = (char*)malloc(newFileNameLength+1); memcpy(newFileName, fileName, newFileNameLength); newFileName[newFileNameLength] = '\0'; animAsset.animClips[animClipIndex].keyFrames[i].fileName = newFileName; char fullNewFileName[256] = {}; sprintf(fullNewFileName, "%.*s/%s", arg1Length, arg1Str, newFileName); animAsset.animClips[animClipIndex].keyFrames[i].spriteData = LoadBMPFile(fullNewFileName); } } startTime += animAsset.animClips[animClipIndex].keyFrames[i].duration; } } int currentFrames = (int)(animTime*60); if(Button(frameBuffer, frameBuffer.width - 150, frameBuffer.height - 250, 100, 50, 0x777777, 0xEEEEEE, 0xDDDDDD, "")){ char fileName[256] = {}; if(OpenFile(fileName, windowObj, "bmp", "BMP files(*.bmp)", arg1Str, arg1Length)){ int newFileNameLength = strlen(fileName); char* newFileName = (char*)malloc(newFileNameLength+1); memcpy(newFileName, fileName, newFileNameLength); newFileName[newFileNameLength] = '\0'; char fullNewFileName[256] = {}; sprintf(fullNewFileName, "%.*s/%s", arg1Length, arg1Str, newFileName); AnimKeyFrame newKeyFrame = {newFileName, LoadBMPFile(fullNewFileName), 20}; AddKeyFrame(&animAsset.animClips[animClipIndex], newKeyFrame); } } DrawBitmap(frameBuffer, frameBuffer.width - 149, frameBuffer.height - 299, 48, 48, plusSign); int frames = 0; int currKeyFrame = 0; for(int i = 0; i < animAsset.animClips[animClipIndex].keyFrameCount; i++){ frames += animAsset.animClips[animClipIndex].keyFrames[i].duration; if(frames > currentFrames){ currKeyFrame = i; break; } } int startTime = 0; for(int i = 0; i < animAsset.animClips[animClipIndex].keyFrameCount; i++){ float startPixels = ((float)startTime)/60/animLengthInSeconds * timelinePixelWidth; DrawBitmap(frameBuffer, (int)startPixels, frameBuffer.height - 200, 50, 50, cyanCircle); DrawBitmap(frameBuffer, (int)startPixels, frameBuffer.height - 150, 50, 50, animAsset.animClips[animClipIndex].keyFrames[i].spriteData); int duration = animAsset.animClips[animClipIndex].keyFrames[i].duration; if(Button(frameBuffer, (int)startPixels, frameBuffer.height - 250, 30, 30, 0x777777, 0xEEEEEE, 0xDDDDDD, "")){ RemoveAnimKeyFrame(&animAsset.animClips[animClipIndex], i); } DrawBitmap(frameBuffer, startPixels, frameBuffer.height - 250, 30, 30, crossSign); startTime += duration; } NoramlizeAnimClip(&animAsset.animClips[animClipIndex]); DrawBitmap(frameBuffer, 50, 50, 250, 250, animAsset.animClips[animClipIndex].keyFrames[currKeyFrame].spriteData); if(mouseState == PRESS){ mouseState = HOLD; } if(mouseState == RELEASE){ mouseState = OFF; } for(int i = 0; i < 256; i++){ if(keyStates[i] == PRESS){ keyStates[i] = HOLD; } if(keyStates[i] == RELEASE){ keyStates[i] = OFF; } } zoomLevel = clamp(zoomLevel, 0.25f, 2.0f); }
29.325077
138
0.676626
Benjins
74539fd3a437ada34e33972f54afa3905e6283f1
1,970
cpp
C++
training/1-3-7-wormhole/cpp11/main.cpp
hsun324/usaco-solutions
27f77911971513a4d2b1b820eaa09802acadfefa
[ "MIT" ]
2
2015-12-26T21:20:12.000Z
2017-12-19T00:11:45.000Z
training/1-3-7-wormhole/cpp11/main.cpp
hsun324/usaco-solutions
27f77911971513a4d2b1b820eaa09802acadfefa
[ "MIT" ]
null
null
null
training/1-3-7-wormhole/cpp11/main.cpp
hsun324/usaco-solutions
27f77911971513a4d2b1b820eaa09802acadfefa
[ "MIT" ]
null
null
null
/* ID: <ID HERE> LANG: C++11 TASK: wormhole */ #include <algorithm> #include <fstream> #include <map> #include <set> #include <utility> #include <vector> using namespace std; bool check_cycle(vector<int> &pairs, map<int, int> &transitions) { vector<bool> visited(pairs.size()); for (int i = 0; i < pairs.size(); i++) { if (visited[i]) continue; int current = i; do { visited[current] = true; int exit = pairs[current], next = -1; auto transition = transitions.find(exit); if (transition != transitions.end()) next = transition->second; if (next == i) break; current = next; } while (current >= 0); if (current >= 0) return true; } return false; } int construct_permutations_and_check(vector<int> &permutation, map<int, int> &transitions) { auto first_unassigned = find(permutation.begin(), permutation.end(), -1); if (first_unassigned == permutation.end()) return check_cycle(permutation, transitions) ? 1 : 0; int count = 0; int unassigned_index = first_unassigned - permutation.begin(); for (int i = unassigned_index + 1; i < permutation.size(); i++) { if (permutation[i] == -1) { vector<int> current(permutation); current[i] = unassigned_index; current[unassigned_index] = i; count += construct_permutations_and_check(current, transitions); } } return count; } int main() { ifstream cin("wormhole.in"); ofstream cout("wormhole.out"); int count; cin >> count; map<int, set<pair<int, int>>> wormholes; for (int i = 0, x, y; i < count; i++) { cin >> x >> y; wormholes[y].emplace(x, i); } map<int, int> transitions; for (auto &wormhole_set : wormholes) { int last_index = -1; for (auto &index : wormhole_set.second) { if (last_index >= 0) transitions[last_index] = index.second; last_index = index.second; } } vector<int> permutation(count, -1); int cycles = construct_permutations_and_check(permutation, transitions); cout << cycles << endl; return 0; }
21.413043
92
0.658883
hsun324
745999a25b480d74ca6a1b28c68a70a257dccc3b
8,465
cc
C++
tools/embedding_plugin/cc/kernels/v1/embedding_wrapper_fprop_v4.cc
quinnrong94/HugeCTR
1068dc48b05a1219b393144dd3b61a1749f232df
[ "Apache-2.0" ]
1
2021-06-04T04:03:54.000Z
2021-06-04T04:03:54.000Z
tools/embedding_plugin/cc/kernels/v1/embedding_wrapper_fprop_v4.cc
quinnrong94/HugeCTR
1068dc48b05a1219b393144dd3b61a1749f232df
[ "Apache-2.0" ]
null
null
null
tools/embedding_plugin/cc/kernels/v1/embedding_wrapper_fprop_v4.cc
quinnrong94/HugeCTR
1068dc48b05a1219b393144dd3b61a1749f232df
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2020, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "embedding_wrapper.h" #include "HugeCTR/include/embeddings/distributed_slot_sparse_embedding_hash.hpp" #include "HugeCTR/include/embeddings/localized_slot_sparse_embedding_hash.hpp" #include "HugeCTR/include/embeddings/localized_slot_sparse_embedding_one_hot.hpp" #include "embedding_utils.hpp" namespace HugeCTR { namespace Version1 { /** This function get input as a single tensor, rather that a list of tensors. * Its inputs: row_offsets, value_tensors both are single tensors (stack from list of tensor.) * TODO: Use NCCL to do memory transfer. */ template <typename TypeKey, typename TypeFP> tensorflow::Status EmbeddingWrapper<TypeKey, TypeFP>::fprop_v4( const tensorflow::Tensor* row_indices, const tensorflow::Tensor* values, const std::string& embedding_name, const bool is_training, const cudaStream_t& tf_stream, tensorflow::Tensor* const forward_result) { /*get input space*/ std::string input_space_name = embedding_name; input_space_name += (is_training ? "_train" : "_eval"); std::shared_ptr<InputSpace> space = get_input_space(input_space_name); if (!space) return tensorflow::errors::NotFound(__FILE__, ": ", __LINE__, ", Did not find ", input_space_name, " in input_spaces."); /*do distribute keys*/ const auto distribute_keys_func = get_item_from_map(distribute_keys_on_gpu_func_, embedding_name); WRAPPER_REQUIRE_OK((this->*distribute_keys_func)(row_indices, values, embedding_name, is_training, space)); #ifndef NDEBUG /*need synchronize streams? wait stream to finish distribute keys on GPU?*/ HugeCTR::CudaDeviceContext context; for (size_t dev_id = 0; dev_id < resource_manager_->get_local_gpu_count(); ++dev_id) { const auto& local_gpu = resource_manager_->get_local_gpu(dev_id); context.set_device(local_gpu->get_device_id()); WRAPPER_CUDA_CHECK(cudaStreamSynchronize(local_gpu->get_stream())); // check CSR results std::unique_ptr<TypeKey []> host_row_offsets(new TypeKey[space->row_offsets_tensors_[dev_id].get_num_elements()]()); WRAPPER_CUDA_CHECK(cudaMemcpyAsync(host_row_offsets.get(), space->row_offsets_tensors_[dev_id].get_ptr(), space->row_offsets_tensors_[dev_id].get_size_in_bytes(), cudaMemcpyDeviceToHost, local_gpu->get_stream())); std::unique_ptr<TypeKey []> host_values(new TypeKey[space->value_tensors_[dev_id].get_num_elements()]()); WRAPPER_CUDA_CHECK(cudaMemcpyAsync(host_values.get(), space->value_tensors_[dev_id].get_ptr(), space->value_tensors_[dev_id].get_size_in_bytes(), cudaMemcpyDeviceToHost, local_gpu->get_stream())); WRAPPER_CUDA_CHECK(cudaStreamSynchronize(local_gpu->get_stream())); std::cout << "dev_id = " << dev_id << ", row_offsets = "; for (size_t i = 0; i < space->row_offsets_tensors_[dev_id].get_num_elements(); ++i) { std::cout << host_row_offsets[i] << ", "; } std::cout << std::endl; std::cout << "dev_id = " << dev_id << ", values = "; for (size_t i = 0; i < space->value_tensors_[dev_id].get_num_elements(); ++i){ std::cout << host_values[i] << ", "; } std::cout << std::endl; } // for dev_id #endif try { /*do forward propagation*/ std::shared_ptr<IEmbedding> embedding = get_embedding(embedding_name); if (!embedding) return tensorflow::errors::NotFound(__FILE__, ":", __LINE__, " ", "Not found ", embedding_name); embedding->forward(is_training); /*get forward results*/ if (std::is_same<TypeFP, float>::value) { embedding->get_forward_results_tf(is_training, true, reinterpret_cast<void*>(forward_result->flat<float>().data())); } else if (std::is_same<TypeFP, __half>::value) { embedding->get_forward_results_tf(is_training, true, reinterpret_cast<void*>(forward_result->flat<Eigen::half>().data())); } else { return tensorflow::errors::Unimplemented(__FILE__, ":", __LINE__, " TypeFP should be {float, __half}."); } } catch (const HugeCTR::internal_runtime_error& rt_error) { return tensorflow::errors::Aborted(__FILE__, ":", __LINE__, " ", rt_error.what()); } /*record cudaEvent on each stream*/ std::vector<cudaEvent_t> fprop_events = get_item_from_map(fprop_events_, embedding_name); if (fprop_events.empty()) return tensorflow::errors::Aborted(__FILE__, ":", __LINE__, " ", "Cannot find fprop cudaEvent_t for embedding: ", embedding_name); for (size_t dev_id = 0; dev_id < resource_manager_->get_local_gpu_count(); ++dev_id){ CudaDeviceContext context; const auto& local_gpu = resource_manager_->get_local_gpu(dev_id); context.set_device(local_gpu->get_device_id()); WRAPPER_CUDA_CHECK(cudaEventRecord(fprop_events[dev_id], local_gpu->get_stream())); } /*synchronize tf stream with cuda stream*/ for (size_t dev_id = 0; dev_id < resource_manager_->get_local_gpu_count(); ++dev_id){ CudaDeviceContext context; const auto& local_gpu = resource_manager_->get_local_gpu(dev_id); context.set_device(local_gpu->get_device_id()); WRAPPER_CUDA_CHECK(cudaStreamWaitEvent(tf_stream, fprop_events[dev_id], 0)); } return tensorflow::Status::OK(); } template tensorflow::Status EmbeddingWrapper<long long, float>::fprop_v4( const tensorflow::Tensor* row_indices, const tensorflow::Tensor* values, const std::string& embedding_name, const bool is_training, const cudaStream_t& tf_stream, tensorflow::Tensor* const forward_result); template tensorflow::Status EmbeddingWrapper<long long, __half>::fprop_v4( const tensorflow::Tensor* row_indices, const tensorflow::Tensor* values, const std::string& embedding_name, const bool is_training, const cudaStream_t& tf_stream, tensorflow::Tensor* const forward_result); template tensorflow::Status EmbeddingWrapper<unsigned int, float>::fprop_v4( const tensorflow::Tensor* row_indices, const tensorflow::Tensor* values, const std::string& embedding_name, const bool is_training, const cudaStream_t& tf_stream, tensorflow::Tensor* const forward_result); template tensorflow::Status EmbeddingWrapper<unsigned int, __half>::fprop_v4( const tensorflow::Tensor* row_indices, const tensorflow::Tensor* values, const std::string& embedding_name, const bool is_training, const cudaStream_t& tf_stream, tensorflow::Tensor* const forward_result); } // namespace Version1 } // namespace HugeCTR
50.993976
134
0.606025
quinnrong94
7465ff9f1b9725685726c0c4c6e2c2c59d760f05
823
cpp
C++
ui/widget/toolbar/AdjustPanelToolBar.cpp
shinehanx/openphoto
e4466e5e80829385d2aa84813f2d5a8960053845
[ "Apache-2.0" ]
5
2021-03-11T00:30:25.000Z
2021-07-28T00:31:20.000Z
ui/widget/toolbar/AdjustPanelToolBar.cpp
shinehanx/openphoto
e4466e5e80829385d2aa84813f2d5a8960053845
[ "Apache-2.0" ]
null
null
null
ui/widget/toolbar/AdjustPanelToolBar.cpp
shinehanx/openphoto
e4466e5e80829385d2aa84813f2d5a8960053845
[ "Apache-2.0" ]
1
2021-09-14T16:28:26.000Z
2021-09-14T16:28:26.000Z
#include "AdjustPanelToolBar.h" #include <QIcon> AdjustPanelToolBar::AdjustPanelToolBar(QWidget *parent) : QToolBar(parent) { } AdjustPanelToolBar::AdjustPanelToolBar(ToolButtonData *datas, int size, QWidget *parent) : QToolBar(parent) { toolButtonDatas = datas; toolButtonSize = size; } void AdjustPanelToolBar::setup() { this->setStyleSheet(qssToolBar); this->setOrientation(Qt::Horizontal); this->setMovable(false); if (toolButtonDatas == nullptr) { return ; } int i = 0; for(ToolButtonData * data=toolButtonDatas; i<toolButtonSize; data++){ QAction * action = new QAction(this); action->setIcon(QIcon(data->icon)); action->setToolTip(data->tip); action->setData(QVariant(data->name)); this->addAction(action); i++; } }
24.939394
107
0.663426
shinehanx
7466b0e0ac71ab7eb83d9e4f513a021ac1d5a4f5
4,388
cpp
C++
plugins/mdaRoundPan.cpp
elk-audio/mda-vst2
8ea6ef97946a617d73e48d245777e57fb984357f
[ "MIT" ]
2
2020-05-01T20:57:56.000Z
2021-05-20T13:59:20.000Z
plugins/mdaRoundPan.cpp
elk-audio/mda-vst2
8ea6ef97946a617d73e48d245777e57fb984357f
[ "MIT" ]
null
null
null
plugins/mdaRoundPan.cpp
elk-audio/mda-vst2
8ea6ef97946a617d73e48d245777e57fb984357f
[ "MIT" ]
null
null
null
#include "mdaRoundPan.h" #include <math.h> #include <float.h> AudioEffect *createEffectInstance(audioMasterCallback audioMaster) { return new mdaRoundPan(audioMaster); } mdaRoundPan::mdaRoundPan(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, 1, 2) // programs, parameters { //inits here! fParam1 = (float)0.5; //pan fParam2 = (float)0.8; //auto //size = 1500; //bufpos = 0; //buffer = new float[size]; //buffer2 = new float[size]; setNumInputs(2); setNumOutputs(2); setUniqueID('mdaP'); // identify here DECLARE_VST_DEPRECATED(canMono) (); canProcessReplacing(); strcpy(programName, "Round Panner"); suspend(); // flush buffer //calcs here! phi = 0.0; dphi = (float)(5.0 / getSampleRate()); } bool mdaRoundPan::getProductString(char* text) { strcpy(text, "mda RoundPan"); return true; } bool mdaRoundPan::getVendorString(char* text) { strcpy(text, "mda"); return true; } bool mdaRoundPan::getEffectName(char* name) { strcpy(name, "RoundPan"); return true; } void mdaRoundPan::setParameter(VstInt32 index, float value) { switch(index) { case 0: fParam1 = value; phi = (float)(6.2831853 * (fParam1 - 0.5)); break; case 1: fParam2 = value; break; } //calcs here if (fParam2>0.55) { dphi = (float)(20.0 * (fParam2 - 0.55) / getSampleRate()); } else { if (fParam2<0.45) { dphi = (float)(-20.0 * (0.45 - fParam2) / getSampleRate()); } else { dphi = 0.0; } } } mdaRoundPan::~mdaRoundPan() { //if(buffer) delete buffer; //if(buffer2) delete buffer2; } void mdaRoundPan::suspend() { //memset(buffer, 0, size * sizeof(float)); //memset(buffer2, 0, size * sizeof(float)); } void mdaRoundPan::setProgramName(char *name) { strcpy(programName, name); } void mdaRoundPan::getProgramName(char *name) { strcpy(name, programName); } bool mdaRoundPan::getProgramNameIndexed (VstInt32 category, VstInt32 index, char* name) { if (index == 0) { strcpy(name, programName); return true; } return false; } float mdaRoundPan::getParameter(VstInt32 index) { float v=0; switch(index) { case 0: v = fParam1; break; case 1: v = fParam2; break; } return v; } void mdaRoundPan::getParameterName(VstInt32 index, char *label) { switch(index) { case 0: strcpy(label, "Pan"); break; case 1: strcpy(label, "Auto"); break; } } #include <stdio.h> void int2strng(VstInt32 value, char *string) { sprintf(string, "%d", value); } void mdaRoundPan::getParameterDisplay(VstInt32 index, char *text) { switch(index) { case 0: int2strng((VstInt32)(360.0 * (fParam1 - 0.5)), text); break; case 1: int2strng((VstInt32)(57.296 * dphi * getSampleRate()), text); break; } } void mdaRoundPan::getParameterLabel(VstInt32 index, char *label) { switch(index) { case 0: strcpy(label, "deg"); break; case 1: strcpy(label, "deg/sec"); break; } } //-------------------------------------------------------------------------------- // process void mdaRoundPan::process(float **inputs, float **outputs, VstInt32 sampleFrames) { float *in1 = inputs[0]; float *in2 = inputs[1]; float *out1 = outputs[0]; float *out2 = outputs[1]; float a, c, d, x=0.5, y=(float)0.7854; float ph, dph, fourpi=(float)12.566371; ph = phi; dph = dphi; --in1; --in2; --out1; --out2; while(--sampleFrames >= 0) { a = x * (*++in1 + *++in2); c = out1[1]; d = out2[1]; //process from here... c += (float)(a * -sin((x * ph) - y)); // output d += (float)(a * sin((x * ph) + y)); ph = ph + dph; *++out1 = c; *++out2 = d; } if(ph<0.0) ph = ph + fourpi; else if(ph>fourpi) ph = ph - fourpi; phi = ph; } void mdaRoundPan::processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames) { float *in1 = inputs[0]; float *in2 = inputs[1]; float *out1 = outputs[0]; float *out2 = outputs[1]; float a, c, d, x=0.5, y=(float)0.7854; float ph, dph, fourpi=(float)12.566371; ph = phi; dph = dphi; --in1; --in2; --out1; --out2; while(--sampleFrames >= 0) { a = x * (*++in1 + *++in2); //process from here... c = (float)(a * -sin((x * ph) - y)); // output d = (float)(a * sin((x * ph) + y)); ph = ph + dph; *++out1 = c; *++out2 = d; } if(ph<0.0) ph = ph + fourpi; else if(ph>fourpi) ph = ph - fourpi; phi = ph; }
21.198068
115
0.595488
elk-audio
746be647093c5e6f87c9e17d5414193ce5ed227e
794
cpp
C++
2018/day01/main.cpp
batduck27/Advent_of_code
6b2dadf28bebd2301464c864f5112dccede9762b
[ "MIT" ]
null
null
null
2018/day01/main.cpp
batduck27/Advent_of_code
6b2dadf28bebd2301464c864f5112dccede9762b
[ "MIT" ]
null
null
null
2018/day01/main.cpp
batduck27/Advent_of_code
6b2dadf28bebd2301464c864f5112dccede9762b
[ "MIT" ]
null
null
null
#include <iostream> #include <fstream> #include <vector> #include <set> std::vector<int> V; int solvePart1() { int res = 0; for (const auto& x : V) { res += x; } return res; } int solvePart2() { int currFreq = 0; std::set<int> S; for (size_t i = 0; i < V.size(); i = ((i == V.size() - 1) ? 0 : i + 1)) { if (S.find(currFreq) != S.end()) { break; } S.insert(currFreq); currFreq += V[i]; } return currFreq; } int main() { std::ifstream fin("data.in"); int nr; while (fin >> nr) { V.push_back(nr); } std::cout << "The result for part1 is: " << solvePart1() << "\n"; std::cout << "The result for part2 is: " << solvePart2() << "\n"; fin.close(); return 0; }
16.541667
77
0.479849
batduck27
747645889dcdbedd897f1bad4d954375badbc624
1,394
cpp
C++
Platformer/World.cpp
renato-grottesi/pokitto
e38bbb07889e88087149709310687d957f00c4c6
[ "MIT" ]
null
null
null
Platformer/World.cpp
renato-grottesi/pokitto
e38bbb07889e88087149709310687d957f00c4c6
[ "MIT" ]
null
null
null
Platformer/World.cpp
renato-grottesi/pokitto
e38bbb07889e88087149709310687d957f00c4c6
[ "MIT" ]
1
2021-01-15T23:35:34.000Z
2021-01-15T23:35:34.000Z
#include "World.hpp" #include "assets.h" // TODO: pass in the constructor uint8_t World::render(uint8_t cnt) { const uint16_t XCentralTile = xWorldToTile(cameraX); const uint16_t YCentralTile = yWorldToTile(cameraY); // TODO: clear this parallax code and make it configurable const int16_t xOff = (maxX - cameraX) * LCDWIDTH / maxX; const int16_t yOff = (maxY - cameraY) * LCDHEIGHT / maxY / 5; display.setup(cnt++, bg_001_pal, bg_001_data, 0xf, PaletteSize::PAL2, xOff - bg_001_data[0], LCDHEIGHT / 2 - bg_001_data[1] / 2 + yOff); display.setup(cnt++, bg_001_pal, bg_001_data, 0xf, PaletteSize::PAL2, xOff, LCDHEIGHT / 2 - bg_001_data[1] / 2 + yOff); for (int16_t yt = YCentralTile - 6; yt < YCentralTile + 7; yt++) { for (int16_t xt = XCentralTile - 7; xt < XCentralTile + 8; xt++) { if (xt < 0) continue; if (yt < 0) continue; if (xt >= width) continue; if (yt >= height) continue; uint8_t tile = data[yt * width + xt]; if (tile) { tile--; uint16_t screenX = minX + xTileToWorld(xt) - cameraX; uint16_t screenY = minY + yTileToWorld(yt) - cameraY; display.setup(cnt++, tile_pals[tile], tile_datas[tile], tile_pals[tile][0] == 0 ? 0x00 : 0xff, palSizes[tile], screenX, screenY); } } } return cnt; }
35.74359
95
0.599713
renato-grottesi
7476c428dddb4869a227bb9ff06d7a2ba1821386
8,751
cpp
C++
Dark Basic Public Shared/Official Plugins/3D Cloth & Particles/Code/DBProPhysicsMaster/Ragdoll_Basic_Setup.cpp
domydev/Dark-Basic-Pro
237fd8d859782cb27b9d5994f3c34bc5372b6c04
[ "MIT" ]
231
2018-01-28T00:06:56.000Z
2022-03-31T21:39:56.000Z
Dark Basic Public Shared/Official Plugins/3D Cloth & Particles/Code/DBProPhysicsMaster/Ragdoll_Basic_Setup.cpp
domydev/Dark-Basic-Pro
237fd8d859782cb27b9d5994f3c34bc5372b6c04
[ "MIT" ]
9
2016-02-10T10:46:16.000Z
2017-12-06T17:27:51.000Z
Dark Basic Public Shared/Official Plugins/3D Cloth & Particles/Code/DBProPhysicsMaster/Ragdoll_Basic_Setup.cpp
domydev/Dark-Basic-Pro
237fd8d859782cb27b9d5994f3c34bc5372b6c04
[ "MIT" ]
66
2018-01-28T21:54:52.000Z
2022-02-16T22:50:57.000Z
#include "stdafx.h" void Ragdoll_Basic::constructBasicDoll() { numParticles=30; numLinks=68; particle = new RagdollParticle[numParticles]; //Head, neck, and chest particle[RAGBASIC_HEADLEFT].Set(-0.055110f,2.0f,0.000000f,0.1f,RAGBASIC_HEADLEFT); particle[RAGBASIC_HEADRIGHT].Set(0.055110f,2.0f,0.000000f,0.1f,RAGBASIC_HEADRIGHT); particle[RAGBASIC_NECK].Set(0.000000f,1.745363f,0.000000f,0.1f,RAGBASIC_NECK); particle[RAGBASIC_CHEST].Set(0.000000f,1.436749f,0.000000f,0.1f,RAGBASIC_CHEST); //Waist particle[RAGBASIC_WAISTLEFT].Set(-0.188279f,1.19813f,0.000000f,0.1f,RAGBASIC_WAISTLEFT); particle[RAGBASIC_WAISTRIGHT].Set(0.188279f,1.19813f,0.000000f,0.1f,RAGBASIC_WAISTRIGHT); //Left arm particle[RAGBASIC_HANDLEFT].Set(-1.111011f,1.600000f,0.000000f,0.1f,RAGBASIC_HANDLEFT); particle[RAGBASIC_BICEPLEFT].Set(-0.591588f,1.65782f,0.070813f,0.1f,RAGBASIC_BICEPLEFT); particle[RAGBASIC_TRICEPLEFT].Set(-0.591588f,1.65782f,-0.070813f,0.1f,RAGBASIC_TRICEPLEFT); particle[RAGBASIC_UPELBOWLEFT].Set(-0.678951f,1.721530f,0.000000f,0.1f,RAGBASIC_UPELBOWLEFT); particle[RAGBASIC_LOWELBOWLEFT].Set(-0.678951f,1.600000f,0.000000f,0.1f,RAGBASIC_LOWELBOWLEFT); particle[RAGBASIC_SHOULDERLEFT].Set(-0.246891f,1.666339f,0.000000f,0.1f,RAGBASIC_SHOULDERLEFT); //Right arm particle[RAGBASIC_HANDRIGHT].Set(1.111011f,1.600000f,0.000000f,0.1f,RAGBASIC_HANDRIGHT); particle[RAGBASIC_BICEPRIGHT].Set(0.591588f,1.65782f,0.070813f,0.1f,RAGBASIC_BICEPRIGHT); particle[RAGBASIC_TRICEPRIGHT].Set(0.591588f,1.65782f,-0.070813f,0.1f,RAGBASIC_TRICEPRIGHT); particle[RAGBASIC_UPELBOWRIGHT].Set(0.678951f,1.721530f,0.000000f,0.1f,RAGBASIC_UPELBOWRIGHT); particle[RAGBASIC_LOWELBOWRIGHT].Set(0.678951f,1.600000f,0.000000f,0.1f,RAGBASIC_LOWELBOWRIGHT); particle[RAGBASIC_SHOULDERRIGHT].Set(0.246891f,1.666339f,0.000000f,0.1f,RAGBASIC_SHOULDERRIGHT); //Left leg particle[RAGBASIC_LEGTOPLEFT].Set(-0.13131f,0.951243f,0.000000f,0.1f,RAGBASIC_LEGTOPLEFT); particle[RAGBASIC_QUADLEFT].Set(-0.211058f,0.550156f,0.075043f,0.1f,RAGBASIC_QUADLEFT); particle[RAGBASIC_HAMLEFT].Set(-0.211058f,0.550156f,-0.075043f,0.1f,RAGBASIC_HAMLEFT); particle[RAGBASIC_OUTKNEELEFT].Set(-0.271140f,0.488410f,0.000000f,0.1f,RAGBASIC_OUTKNEELEFT); particle[RAGBASIC_INKNEELEFT].Set(-0.180760f,0.488410f,0.000000f,0.1f,RAGBASIC_INKNEELEFT); particle[RAGBASIC_FOOTLEFT].Set(-0.271140f,0.0f,0.000000f,0.05f,RAGBASIC_FOOTLEFT); //Right leg particle[RAGBASIC_LEGTOPRIGHT].Set(0.13131f,0.951243f,0.000000f,0.1f,RAGBASIC_LEGTOPRIGHT); particle[RAGBASIC_QUADRIGHT].Set(0.211058f,0.550156f,0.075043f,0.1f,RAGBASIC_QUADRIGHT); particle[RAGBASIC_HAMRIGHT].Set(0.211058f,0.550156f,-0.075043f,0.1f,RAGBASIC_HAMRIGHT); particle[RAGBASIC_OUTKNEERIGHT].Set(0.271140f,0.488410f,0.000000f,0.1f,RAGBASIC_OUTKNEERIGHT); particle[RAGBASIC_INKNEERIGHT].Set(0.180760f,0.488410f,0.000000f,0.1f,RAGBASIC_INKNEERIGHT); particle[RAGBASIC_FOOTRIGHT].Set(0.271140f,0.0f,0.000000f,0.05f,RAGBASIC_FOOTRIGHT); //Make normal links link = new RagdollLink[numLinks]; //Head link[0].Set(&particle[RAGBASIC_HEADLEFT],&particle[RAGBASIC_HEADRIGHT]); link[1].Set(&particle[RAGBASIC_HEADLEFT],&particle[RAGBASIC_NECK]); link[2].Set(&particle[RAGBASIC_HEADRIGHT],&particle[RAGBASIC_NECK]); //Upper torso link[3].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_NECK]); link[4].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_NECK]); link[5].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_CHEST]); link[6].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_CHEST]); link[7].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_WAISTLEFT]); link[8].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_WAISTRIGHT]); link[9].Set(&particle[RAGBASIC_NECK],&particle[RAGBASIC_CHEST]); link[10].Set(&particle[RAGBASIC_WAISTLEFT],&particle[RAGBASIC_CHEST]); link[11].Set(&particle[RAGBASIC_WAISTRIGHT],&particle[RAGBASIC_CHEST]); link[12].Set(&particle[RAGBASIC_WAISTLEFT],&particle[RAGBASIC_WAISTRIGHT]); //Lower torso link[13].Set(&particle[RAGBASIC_WAISTLEFT],&particle[RAGBASIC_LEGTOPLEFT]); link[14].Set(&particle[RAGBASIC_WAISTLEFT],&particle[RAGBASIC_LEGTOPRIGHT]); link[15].Set(&particle[RAGBASIC_WAISTRIGHT],&particle[RAGBASIC_LEGTOPLEFT]); link[16].Set(&particle[RAGBASIC_WAISTRIGHT],&particle[RAGBASIC_LEGTOPRIGHT]); link[17].Set(&particle[RAGBASIC_LEGTOPLEFT],&particle[RAGBASIC_LEGTOPRIGHT]); //Left arm link[18].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_UPELBOWLEFT]); link[19].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_LOWELBOWLEFT]); link[20].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_BICEPLEFT]); link[21].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_TRICEPLEFT]); link[22].Set(&particle[RAGBASIC_BICEPLEFT],&particle[RAGBASIC_UPELBOWLEFT]); link[23].Set(&particle[RAGBASIC_BICEPLEFT],&particle[RAGBASIC_LOWELBOWLEFT]); link[24].Set(&particle[RAGBASIC_TRICEPLEFT],&particle[RAGBASIC_UPELBOWLEFT]); link[25].Set(&particle[RAGBASIC_TRICEPLEFT],&particle[RAGBASIC_LOWELBOWLEFT]); link[26].Set(&particle[RAGBASIC_UPELBOWLEFT],&particle[RAGBASIC_LOWELBOWLEFT]); link[27].Set(&particle[RAGBASIC_UPELBOWLEFT],&particle[RAGBASIC_HANDLEFT]); link[28].Set(&particle[RAGBASIC_LOWELBOWLEFT],&particle[RAGBASIC_HANDLEFT]); //Right arm link[29].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_UPELBOWRIGHT]); link[30].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_LOWELBOWRIGHT]); link[31].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_BICEPRIGHT]); link[32].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_TRICEPRIGHT]); link[33].Set(&particle[RAGBASIC_BICEPRIGHT],&particle[RAGBASIC_UPELBOWRIGHT]); link[34].Set(&particle[RAGBASIC_BICEPRIGHT],&particle[RAGBASIC_LOWELBOWRIGHT]); link[35].Set(&particle[RAGBASIC_TRICEPRIGHT],&particle[RAGBASIC_UPELBOWRIGHT]); link[36].Set(&particle[RAGBASIC_TRICEPRIGHT],&particle[RAGBASIC_LOWELBOWRIGHT]); link[37].Set(&particle[RAGBASIC_UPELBOWRIGHT],&particle[RAGBASIC_LOWELBOWRIGHT]); link[38].Set(&particle[RAGBASIC_UPELBOWRIGHT],&particle[RAGBASIC_HANDRIGHT]); link[39].Set(&particle[RAGBASIC_LOWELBOWRIGHT],&particle[RAGBASIC_HANDRIGHT]); //Left leg link[40].Set(&particle[RAGBASIC_LEGTOPLEFT],&particle[RAGBASIC_INKNEELEFT]); link[41].Set(&particle[RAGBASIC_LEGTOPLEFT],&particle[RAGBASIC_OUTKNEELEFT]); link[42].Set(&particle[RAGBASIC_LEGTOPLEFT],&particle[RAGBASIC_QUADLEFT]); link[43].Set(&particle[RAGBASIC_LEGTOPLEFT],&particle[RAGBASIC_HAMLEFT]); link[44].Set(&particle[RAGBASIC_QUADLEFT],&particle[RAGBASIC_INKNEELEFT]); link[45].Set(&particle[RAGBASIC_QUADLEFT],&particle[RAGBASIC_OUTKNEELEFT]); link[46].Set(&particle[RAGBASIC_HAMLEFT],&particle[RAGBASIC_INKNEELEFT]); link[47].Set(&particle[RAGBASIC_HAMLEFT],&particle[RAGBASIC_OUTKNEELEFT]); link[48].Set(&particle[RAGBASIC_INKNEELEFT],&particle[RAGBASIC_OUTKNEELEFT]); link[49].Set(&particle[RAGBASIC_INKNEELEFT],&particle[RAGBASIC_FOOTLEFT]); link[50].Set(&particle[RAGBASIC_OUTKNEELEFT],&particle[RAGBASIC_FOOTLEFT]); //Right leg link[51].Set(&particle[RAGBASIC_LEGTOPRIGHT],&particle[RAGBASIC_INKNEERIGHT]); link[52].Set(&particle[RAGBASIC_LEGTOPRIGHT],&particle[RAGBASIC_OUTKNEERIGHT]); link[53].Set(&particle[RAGBASIC_LEGTOPRIGHT],&particle[RAGBASIC_QUADRIGHT]); link[54].Set(&particle[RAGBASIC_LEGTOPRIGHT],&particle[RAGBASIC_HAMRIGHT]); link[55].Set(&particle[RAGBASIC_QUADRIGHT],&particle[RAGBASIC_INKNEERIGHT]); link[56].Set(&particle[RAGBASIC_QUADRIGHT],&particle[RAGBASIC_OUTKNEERIGHT]); link[57].Set(&particle[RAGBASIC_HAMRIGHT],&particle[RAGBASIC_INKNEERIGHT]); link[58].Set(&particle[RAGBASIC_HAMRIGHT],&particle[RAGBASIC_OUTKNEERIGHT]); link[59].Set(&particle[RAGBASIC_INKNEERIGHT],&particle[RAGBASIC_OUTKNEERIGHT]); link[60].Set(&particle[RAGBASIC_INKNEERIGHT],&particle[RAGBASIC_FOOTRIGHT]); link[61].Set(&particle[RAGBASIC_OUTKNEERIGHT],&particle[RAGBASIC_FOOTRIGHT]); //Don't let head get too close to chest link[62].Set(&particle[RAGBASIC_HEADLEFT],&particle[RAGBASIC_CHEST],RAGLINK_MINIMUM,0.48f*0.48f); link[63].Set(&particle[RAGBASIC_HEADRIGHT],&particle[RAGBASIC_CHEST],RAGLINK_MINIMUM,0.48f*0.48f); //Don't let head get too close or far away from shoulders link[64].Set(&particle[RAGBASIC_HEADLEFT],&particle[RAGBASIC_SHOULDERLEFT],RAGLINK_MINMAX,0.13f*0.13f,0.51f*0.51f); link[65].Set(&particle[RAGBASIC_HEADRIGHT],&particle[RAGBASIC_SHOULDERRIGHT],RAGLINK_MINMAX,0.13f*0.13f,0.51f*0.51f); //Rotational head restraint link[66].Set(&particle[RAGBASIC_SHOULDERRIGHT],&particle[RAGBASIC_HEADLEFT],&particle[RAGBASIC_HEADRIGHT],0.05f); link[67].Set(&particle[RAGBASIC_SHOULDERLEFT],&particle[RAGBASIC_HEADRIGHT],&particle[RAGBASIC_HEADLEFT],0.05f); }
59.128378
118
0.801623
domydev
7476fde2adbe24d7a6020e259ca1b111a4021917
30,297
hpp
C++
data_compression/L1/include/hw/inflate.hpp
dycz0fx/Vitis_Libraries
d3fc414b552493657101ddb5245f24528720823d
[ "Apache-2.0" ]
null
null
null
data_compression/L1/include/hw/inflate.hpp
dycz0fx/Vitis_Libraries
d3fc414b552493657101ddb5245f24528720823d
[ "Apache-2.0" ]
null
null
null
data_compression/L1/include/hw/inflate.hpp
dycz0fx/Vitis_Libraries
d3fc414b552493657101ddb5245f24528720823d
[ "Apache-2.0" ]
null
null
null
/* * (c) Copyright 2019-2021 Xilinx, Inc. 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 _XFCOMPRESSION_INFLATE_HPP_ #define _XFCOMPRESSION_INFLATE_HPP_ #include "ap_axi_sdata.h" #include "hls_stream.h" #include "huffman_decoder.hpp" #include "lz_decompress.hpp" #include "stream_upsizer.hpp" #include "stream_downsizer.hpp" #include "mm2s.hpp" #include "s2mm.hpp" #include "checksum_wrapper.hpp" #include <ap_int.h> #include <assert.h> #include <stdint.h> namespace xf { namespace compression { namespace details { template <int PARALLEL_BYTES> void lzLiteralUpsizer(hls::stream<ap_uint<10> >& inStream, hls::stream<ap_uint<PARALLEL_BYTES * 8> >& litStream) { const uint8_t c_parallelBit = PARALLEL_BYTES * 8; const uint8_t c_maxLitLen = 128; ap_uint<c_parallelBit> outBuffer; ap_uint<4> idx = 0; ap_uint<2> status = 0; ap_uint<10> val; bool done = false; lzliteralUpsizer: while (status != 2) { #pragma HLS PIPELINE II = 1 status = 0; val = inStream.read(); status = val.range(1, 0); outBuffer.range((idx + 1) * 8 - 1, idx * 8) = val.range(9, 2); idx++; if ((status & 1) || (idx == 8)) { if (status != 3) { litStream << outBuffer; } idx = 0; } } if (idx > 1) { litStream << outBuffer; idx = 0; } } template <int PARALLEL_BYTES> void lzLiteralUpsizerLL(hls::stream<ap_uint<10> >& inStream, hls::stream<ap_uint<PARALLEL_BYTES * 8> >& litStream) { const uint8_t c_parallelBit = PARALLEL_BYTES * 8; const uint8_t c_maxLitLen = 128; ap_uint<c_parallelBit> outBuffer; ap_uint<4> idx = 0; ap_uint<2> status = 0; ap_uint<10> val; bool done = false; lzliteralUpsizer: while (status != 2) { #pragma HLS PIPELINE II = 1 status = 0; val = inStream.read(); status = val.range(1, 0); outBuffer.range((idx + 1) * 8 - 1, idx * 8) = val.range(9, 2); idx++; if ((status & 1) || (idx == PARALLEL_BYTES)) { if (idx > 1) { litStream << outBuffer; } idx = 0; } } if (idx > 1) { litStream << outBuffer; idx = 0; } } template <class SIZE_DT = uint8_t> void lzProcessingUnit(hls::stream<ap_uint<17> >& inStream, hls::stream<SIZE_DT>& litLenStream, hls::stream<SIZE_DT>& matchLenStream, hls::stream<ap_uint<16> >& offsetStream, hls::stream<ap_uint<10> >& outStream) { ap_uint<17> inValue, nextValue; const int c_maxLitLen = 128; uint16_t offset = 0; uint16_t matchLen = 0; uint8_t litLen = 0; uint8_t outLitLen = 0; ap_uint<10> lit = 0; nextValue = inStream.read(); bool eosFlag = nextValue.range(0, 0); bool lastLiteral = false; bool isLiteral = true; lzProcessing: for (; eosFlag == false;) { #pragma HLS PIPELINE II = 1 inValue = nextValue; nextValue = inStream.read(); eosFlag = nextValue.range(0, 0); bool outFlag, outStreamFlag; if (inValue.range(16, 9) == 0xFF && isLiteral) { outStreamFlag = true; outLitLen = litLen + 1; if (litLen == c_maxLitLen - 1) { outFlag = true; matchLen = 0; offset = 1; // dummy value litLen = 0; } else { outFlag = false; litLen++; } } else { if (isLiteral) { matchLen = inValue.range(16, 1); isLiteral = false; outFlag = false; outStreamFlag = false; } else { offset = inValue.range(16, 1); isLiteral = true; outFlag = true; outLitLen = litLen; litLen = 0; outStreamFlag = false; } } if (outStreamFlag) { lit.range(9, 2) = inValue.range(8, 1); if (nextValue.range(16, 9) == 0xFF) { lit.range(1, 0) = 0; } else { lit.range(1, 0) = 1; } lastLiteral = true; outStream << lit; } else if (lastLiteral) { outStream << 3; lastLiteral = false; } if (outFlag) { litLenStream << outLitLen; offsetStream << offset; matchLenStream << matchLen; } } if (litLen) { litLenStream << litLen; offsetStream << 0; matchLenStream << 0; } // Terminate condition outStream << 2; offsetStream << 0; matchLenStream << 0; litLenStream << 0; } template <class SIZE_DT = uint8_t, int PARALLEL_BYTES = 8, int OWIDTH = 16> void lzPreProcessingUnitLL(hls::stream<SIZE_DT>& inLitLen, hls::stream<SIZE_DT>& inMatchLen, hls::stream<ap_uint<OWIDTH> >& inOffset, hls::stream<ap_uint<11 + OWIDTH> >& outInfo) { SIZE_DT litlen = inLitLen.read(); SIZE_DT matchlen = inMatchLen.read(); ap_uint<OWIDTH> offset = inOffset.read(); ap_uint<OWIDTH> litCount = litlen; ap_uint<4> l_litlen = 0; ap_uint<4> l_matchlen = 0; ap_uint<3> l_stateinfo = 0; ap_uint<OWIDTH> l_matchloc = litCount - offset; ap_uint<11 + OWIDTH> outVal = 0; // 0-15 Match Loc, 16-19 Match Len, 20-23 Lit length, 24-26 State Info bool done = false; bool read = false; bool fdone = false; if (litlen == 0) { outVal.range(OWIDTH - 1, 0) = 0; outVal.range(OWIDTH + 3, OWIDTH) = matchlen; outVal.range(OWIDTH + 7, OWIDTH + 4) = litlen; outVal.range(OWIDTH + 10, OWIDTH + 8) = 6; outInfo << outVal; done = true; fdone = false; } while (!done) { #pragma HLS PIPELINE II = 1 if (litlen) { SIZE_DT val = (litlen > PARALLEL_BYTES) ? (SIZE_DT)PARALLEL_BYTES : litlen; litlen -= val; l_litlen = val; l_matchlen = 0; l_stateinfo = 0; l_matchloc = 0; read = (matchlen || litlen) ? false : true; } else { l_matchlen = (offset > PARALLEL_BYTES) ? ((matchlen > PARALLEL_BYTES) ? (SIZE_DT)PARALLEL_BYTES : (SIZE_DT)matchlen) : (matchlen > offset) ? (SIZE_DT)offset : (SIZE_DT)matchlen; if (offset < 6 * PARALLEL_BYTES) { l_stateinfo.range(0, 0) = 1; l_stateinfo.range(2, 1) = 1; } else { l_stateinfo.range(0, 0) = 0; l_stateinfo.range(2, 1) = 1; } l_matchloc = litCount - offset; if (offset < PARALLEL_BYTES) { offset = offset << 1; } l_litlen = 0; litCount += l_matchlen; matchlen -= l_matchlen; litlen = 0; read = matchlen ? false : true; } outVal.range(OWIDTH - 1, 0) = l_matchloc; outVal.range(OWIDTH + 3, OWIDTH) = l_matchlen; outVal.range(OWIDTH + 7, OWIDTH + 4) = l_litlen; outVal.range(OWIDTH + 10, OWIDTH + 8) = l_stateinfo; outInfo << outVal; if (read) { litlen = inLitLen.read(); matchlen = inMatchLen.read(); offset = inOffset.read(); litCount += litlen; if (litlen == 0 && matchlen == 0) { done = true; fdone = true; } } } if (fdone) { outVal.range(OWIDTH - 1, 0) = l_matchloc; outVal.range(OWIDTH + 3, OWIDTH) = matchlen; outVal.range(OWIDTH + 7, OWIDTH + 4) = litlen; outVal.range(OWIDTH + 10, OWIDTH + 8) = 6; outInfo << outVal; } } template <class SIZE_DT = uint8_t> void lzProcessingUnitLL(hls::stream<ap_uint<16> >& inStream, hls::stream<SIZE_DT>& litLenStream, hls::stream<SIZE_DT>& matchLenStream, hls::stream<ap_uint<16> >& offsetStream, hls::stream<ap_uint<10> >& outStream) { ap_uint<16> inValue, nextValue; const int c_maxLitLen = 128; uint16_t offset = 0; uint16_t matchLen = 0; uint8_t litLen = 0; uint8_t outLitLen = 0; ap_uint<10> lit = 0; const uint16_t lbase[32] = {0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; const uint16_t dbase[32] = {1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; nextValue = inStream.read(); bool eosFlag = (nextValue == 0xFFFF) ? true : false; bool lastLiteral = false; bool isLitLength = true; bool isExtra = false; bool dummyValue = false; lzProcessing: for (; eosFlag == false;) { #pragma HLS PIPELINE II = 1 inValue = nextValue; nextValue = inStream.read(); eosFlag = (nextValue == 0xFFFF); bool outFlag, outStreamFlag; if ((inValue.range(15, 8) == 0xFE) || (inValue.range(15, 8) == 0xFD)) { // ignore invalid byte outFlag = false; outStreamFlag = false; } else if (inValue.range(15, 8) == 0xF0) { outStreamFlag = true; outLitLen = litLen + 1; if (litLen == c_maxLitLen - 1) { outFlag = true; matchLen = 0; offset = 1; // dummy value litLen = 0; } else { outFlag = false; matchLen = 0; offset = 1; // dummy value litLen++; } } else if (isExtra && isLitLength) { // matchLen Extra matchLen += inValue.range(15, 0); isExtra = false; isLitLength = false; outStreamFlag = true; } else if (isExtra && !isLitLength) { // offset Extra offset += inValue.range(15, 0); isExtra = false; isLitLength = true; outFlag = true; outStreamFlag = true; } else if (isLitLength) { auto val = inValue.range(4, 0); matchLen = lbase[val]; if (val < 9) { isExtra = false; isLitLength = false; } else { isExtra = true; isLitLength = true; } outFlag = false; outStreamFlag = true; dummyValue = true; } else { auto val = inValue.range(4, 0); offset = dbase[val]; if (val < 4) { isExtra = false; isLitLength = true; outFlag = true; } else { isExtra = true; isLitLength = false; outFlag = false; } outLitLen = litLen; litLen = 0; outStreamFlag = true; } if (outStreamFlag) { lit.range(9, 2) = inValue.range(7, 0); if ((inValue.range(15, 8) == 0xF0)) { lit.range(1, 0) = 0; } else { lit.range(1, 0) = 1; } outStream << lit; } if (outFlag) { litLenStream << outLitLen; offsetStream << offset; matchLenStream << matchLen; } } if (litLen) { litLenStream << litLen; offsetStream << 0; matchLenStream << 0; outStream << 3; } // Terminate condition outStream << 2; offsetStream << 0; matchLenStream << 0; litLenStream << 0; } template <int STREAM_WIDTH> void kStreamReadZlibDecomp(hls::stream<ap_axiu<STREAM_WIDTH, 0, 0, 0> >& in, hls::stream<ap_uint<STREAM_WIDTH> >& out, hls::stream<bool>& outEos) { /** * @brief kStreamReadZlibDecomp Read 16-bit wide data from internal streams output by compression modules * and write to output axi stream. * * @param inKStream input kernel stream * @param readStream internal stream to be read for processing * @param input_size input data size * */ bool last = false; while (last == false) { #pragma HLS PIPELINE II = 1 ap_axiu<STREAM_WIDTH, 0, 0, 0> tmp = in.read(); out << tmp.data; last = tmp.last; outEos << 0; } out << 0; outEos << 1; // Terminate condition } template <int STREAM_WIDTH> void kStreamWriteZlibDecomp(hls::stream<ap_axiu<STREAM_WIDTH, 0, 0, 0> >& outKStream, hls::stream<ap_uint<STREAM_WIDTH + (STREAM_WIDTH / 8)> >& outDataStream) { /** * @brief kStreamWriteZlibDecomp Read 16-bit wide data from internal streams output by compression modules * and write to output axi stream. * * @param outKStream output kernel stream * @param outDataStream output data stream from internal modules * */ ap_uint<STREAM_WIDTH / 8> strb = 0; ap_uint<STREAM_WIDTH> data; ap_uint<STREAM_WIDTH + (STREAM_WIDTH / 8)> tmp; ap_axiu<STREAM_WIDTH, 0, 0, 0> t1; tmp = outDataStream.read(); strb = tmp.range((STREAM_WIDTH / 8) - 1, 0); t1.data = tmp.range(STREAM_WIDTH + (STREAM_WIDTH / 8) - 1, STREAM_WIDTH / 8); t1.strb = strb; t1.keep = strb; t1.last = 0; if (strb == 0) { t1.last = 1; outKStream << t1; } while (strb != 0) { #pragma HLS PIPELINE II = 1 tmp = outDataStream.read(); strb = tmp.range((STREAM_WIDTH / 8) - 1, 0); if (strb == 0) { t1.last = 1; } outKStream << t1; t1.data = tmp.range(STREAM_WIDTH + (STREAM_WIDTH / 8) - 1, STREAM_WIDTH / 8); t1.strb = strb; t1.keep = strb; t1.last = 0; } } template <int STREAM_WIDTH, int TUSER_WIDTH> void hls2AXIWithTUSER(hls::stream<ap_axiu<STREAM_WIDTH, TUSER_WIDTH, 0, 0> >& outAxi, hls::stream<ap_uint<STREAM_WIDTH + (STREAM_WIDTH / 8)> >& inData, hls::stream<bool>& inError) { ap_uint<STREAM_WIDTH / 8> strb = 0; ap_uint<STREAM_WIDTH> data; ap_uint<STREAM_WIDTH + (STREAM_WIDTH / 8)> tmp; ap_axiu<STREAM_WIDTH, TUSER_WIDTH, 0, 0> t1; ap_uint<TUSER_WIDTH - 1> fileSize = 0; tmp = inData.read(); strb = tmp.range((STREAM_WIDTH / 8) - 1, 0); t1.data = tmp.range(STREAM_WIDTH + (STREAM_WIDTH / 8) - 1, STREAM_WIDTH / 8); t1.strb = strb; t1.keep = strb; t1.last = 0; t1.user = 0; if (strb == 0) { t1.last = 1; outAxi << t1; } AXI2HLS: while (strb != 0) { #pragma HLS PIPELINE II = 1 FILESIZE: for (ap_uint<4> i = 0; i < (STREAM_WIDTH / 8); i++) { #pragma HLS UNROLL fileSize += (strb & 0x1); strb >>= 1; } tmp = inData.read(); strb = tmp.range((STREAM_WIDTH / 8) - 1, 0); if (strb == 0) { t1.last = 1; t1.user.range(TUSER_WIDTH - 1, 1) = fileSize; t1.user.range(0, 0) = inError.read(); } outAxi << t1; t1.data = tmp.range(STREAM_WIDTH + (STREAM_WIDTH / 8) - 1, STREAM_WIDTH / 8); t1.strb = strb; t1.keep = strb; t1.last = 0; } } /** * @brief Splits input into data and strb * * @tparam DATA_WIDTH data width of data stream * @param input combined input of data and strb * @param outData output data * @param outStrb output strb */ template <int DATA_WIDTH> void dataStrbSplitter(hls::stream<ap_uint<(DATA_WIDTH * 8) + DATA_WIDTH> >& input, hls::stream<ap_uint<DATA_WIDTH * 8> >& outData, hls::stream<ap_uint<5> >& outStrb) { ap_uint<DATA_WIDTH> strb = 0; splitter: while (1) { #pragma HLS PIPELINE II = 1 auto inVal = input.read(); auto data = inVal.range((DATA_WIDTH * 8) + DATA_WIDTH - 1, DATA_WIDTH); strb = inVal.range(DATA_WIDTH - 1, 0); auto strbVal = strb; if (strb == 0) break; outData << data; ap_uint<5> size = 0; for (ap_uint<4> i = 0; i < DATA_WIDTH; i++) { #pragma HLS UNROLL size += (strbVal & 0x1); strbVal >>= 1; } outStrb << size; } if (strb == 0) outStrb << 0; } /** * @brief Splits Data Stream into multiple * * @tparam DATA_WIDTH * @param input input stream * @param output1 output streams * @param output2 output streams */ template <int DATA_WIDTH> void streamDistributor(hls::stream<ap_uint<(DATA_WIDTH * 8) + DATA_WIDTH> >& input, hls::stream<ap_uint<(DATA_WIDTH * 8) + DATA_WIDTH> >& output1, hls::stream<ap_uint<(DATA_WIDTH * 8) + DATA_WIDTH> >& output2) { ap_uint<DATA_WIDTH> strb = 0; do { #pragma HLS PIPELINE II = 1 auto inVal = input.read(); strb = inVal.range(DATA_WIDTH - 1, 0); output1 << inVal; output2 << inVal; } while (strb != 0); } /** * @brief compare two checksums and generate 0 if match and 1 otherwise * * @param checkSum1 1st checksum input * @param checkSum2 2nd checksum input * @param output error output */ void chckSumComparator(hls::stream<ap_uint<32> >& checkSum1, hls::stream<ap_uint<32> >& checkSum2, hls::stream<bool>& output) { auto chk1 = checkSum1.read(); auto chk2 = checkSum2.read(); output << (chk1 != chk2); } template <int DECODER, int PARALLEL_BYTES, int FILE_FORMAT, bool LOW_LATENCY = false, int HISTORY_SIZE = (32 * 1024)> void inflateMultiByteCore(hls::stream<ap_uint<16> >& inStream, hls::stream<bool>& inEos, hls::stream<ap_uint<(PARALLEL_BYTES * 8) + PARALLEL_BYTES> >& outStream) { const int c_parallelBit = PARALLEL_BYTES * 8; const eHuffmanType c_decoderType = (eHuffmanType)DECODER; const FileFormat c_fileformat = (FileFormat)FILE_FORMAT; hls::stream<ap_uint<17> > bitunpackstream("bitUnPackStream"); hls::stream<ap_uint<16> > bitunpackstreamLL("bitUnPackStreamLL"); hls::stream<ap_uint<c_parallelBit> > litStream("litStream"); hls::stream<ap_uint<9> > matchLenStream("matchLenStream"); hls::stream<ap_uint<9> > litLenStream("litLenStream"); hls::stream<ap_uint<16> > offsetStream("offsetStream"); hls::stream<ap_uint<10> > lzProcOutStream("lzProcOutStream"); hls::stream<ap_uint<27> > infoStream("infoStream"); #pragma HLS STREAM variable = litStream depth = 32 #pragma HLS STREAM variable = lzProcOutStream depth = 16 #pragma HLS STREAM variable = bitunpackstream depth = 1024 #pragma HLS STREAM variable = bitunpackstreamLL depth = 256 #pragma HLS STREAM variable = litLenStream depth = 16 #pragma HLS STREAM variable = matchLenStream depth = 16 #pragma HLS STREAM variable = offsetStream depth = 16 #pragma HLS STREAM variable = infoStream depth = 4 #pragma HLS BIND_STORAGE variable = litStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = bitunpackstream type = FIFO impl = BRAM #pragma HLS BIND_STORAGE variable = bitunpackstreamLL type = fifo impl = lutram #pragma HLS BIND_STORAGE variable = lzProcOutStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = litLenStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = matchLenStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = offsetStream type = FIFO impl = SRL #pragma HLS dataflow if (LOW_LATENCY) { xf::compression::huffmanDecoderLL<c_decoderType, c_fileformat>(inStream, inEos, bitunpackstreamLL); xf::compression::details::lzProcessingUnitLL<ap_uint<9> >(bitunpackstreamLL, litLenStream, matchLenStream, offsetStream, lzProcOutStream); xf::compression::details::lzPreProcessingUnitLL<ap_uint<9>, PARALLEL_BYTES, 16>(litLenStream, matchLenStream, offsetStream, infoStream); xf::compression::details::lzLiteralUpsizerLL<PARALLEL_BYTES>(lzProcOutStream, litStream); xf::compression::lzMultiByteDecompressLL<PARALLEL_BYTES, HISTORY_SIZE, 16, ap_uint<9>, ap_uint<16> >( litStream, infoStream, outStream); } else { xf::compression::huffmanDecoder<c_decoderType>(inStream, inEos, bitunpackstream); xf::compression::details::lzProcessingUnit<ap_uint<9> >(bitunpackstream, litLenStream, matchLenStream, offsetStream, lzProcOutStream); xf::compression::details::lzLiteralUpsizer<PARALLEL_BYTES>(lzProcOutStream, litStream); xf::compression::lzMultiByteDecompress<PARALLEL_BYTES, HISTORY_SIZE, ap_uint<9> >( litLenStream, litStream, offsetStream, matchLenStream, outStream); } } template <int DECODER, int PARALLEL_BYTES, int FILE_FORMAT, int HISTORY_SIZE = (8 * 1024)> void inflateWithChkSum(hls::stream<ap_uint<16> >& inStream, hls::stream<bool>& inEos, hls::stream<ap_uint<(PARALLEL_BYTES * 8) + PARALLEL_BYTES> >& outStream, hls::stream<bool>& errorStrm) { const int c_parallelBit = PARALLEL_BYTES * 8; const eHuffmanType c_decoderType = (eHuffmanType)DECODER; const FileFormat c_fileformat = (FileFormat)FILE_FORMAT; hls::stream<ap_uint<16> > bitunpackstreamLL("bitUnPackStreamLL"); hls::stream<ap_uint<c_parallelBit> > litStream("litStream"); hls::stream<ap_uint<9> > matchLenStream("matchLenStream"); hls::stream<ap_uint<9> > litLenStream("litLenStream"); hls::stream<ap_uint<16> > offsetStream("offsetStream"); hls::stream<ap_uint<10> > lzProcOutStream("lzProcOutStream"); hls::stream<ap_uint<27> > infoStream("infoStream"); hls::stream<ap_uint<32> > chckSum[2]; hls::stream<ap_uint<(PARALLEL_BYTES * 8) + PARALLEL_BYTES> > lzOut("lzOut"); hls::stream<ap_uint<(PARALLEL_BYTES * 8) + PARALLEL_BYTES> > lzDistOut("lzDistOut"); hls::stream<ap_uint<(PARALLEL_BYTES * 8)> > lzData("lzData"); hls::stream<ap_uint<5> > lzStrb("lzStrb"); #pragma HLS STREAM variable = litStream depth = 32 #pragma HLS STREAM variable = lzProcOutStream depth = 16 #pragma HLS STREAM variable = bitunpackstreamLL depth = 256 #pragma HLS STREAM variable = litLenStream depth = 64 #pragma HLS STREAM variable = matchLenStream depth = 64 #pragma HLS STREAM variable = offsetStream depth = 64 #pragma HLS STREAM variable = infoStream depth = 4 #pragma HLS STREAM variable = chckSum depth = 4 #pragma HLS STREAM variable = lzOut depth = 4 #pragma HLS STREAM variable = lzDistOut depth = 4 #pragma HLS STREAM variable = lzData depth = 4 #pragma HLS STREAM variable = lzStrb depth = 4 #pragma HLS STREAM variable = chckSum depth = 4 #pragma HLS BIND_STORAGE variable = litStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = bitunpackstreamLL type = fifo impl = lutram #pragma HLS BIND_STORAGE variable = lzProcOutStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = litLenStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = matchLenStream type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = offsetStream type = FIFO impl = SRL #pragma HLS dataflow xf::compression::huffmanDecoderLL<c_decoderType, c_fileformat>(inStream, inEos, bitunpackstreamLL, chckSum[0]); xf::compression::details::lzProcessingUnitLL<ap_uint<9> >(bitunpackstreamLL, litLenStream, matchLenStream, offsetStream, lzProcOutStream); xf::compression::details::lzPreProcessingUnitLL<ap_uint<9>, PARALLEL_BYTES, 16>(litLenStream, matchLenStream, offsetStream, infoStream); xf::compression::details::lzLiteralUpsizerLL<PARALLEL_BYTES>(lzProcOutStream, litStream); xf::compression::lzMultiByteDecompressLL<PARALLEL_BYTES, HISTORY_SIZE, 16, ap_uint<9>, ap_uint<16> >( litStream, infoStream, lzOut); xf::compression::details::streamDistributor<PARALLEL_BYTES>(lzOut, lzDistOut, outStream); xf::compression::details::dataStrbSplitter<PARALLEL_BYTES>(lzDistOut, lzData, lzStrb); xf::compression::details::adler32<PARALLEL_BYTES>(lzData, lzStrb, chckSum[1]); xf::compression::details::chckSumComparator(chckSum[0], chckSum[1], errorStrm); } } // namespace details template <int DECODER, int PARALLEL_BYTES, int FILE_FORMAT, bool LOW_LATENCY = false, int HISTORY_SIZE = (32 * 1024)> void inflateMultiByte(hls::stream<ap_axiu<16, 0, 0, 0> >& inaxistream, hls::stream<ap_axiu<PARALLEL_BYTES * 8, 0, 0, 0> >& outaxistream) { const int c_parallelBit = PARALLEL_BYTES * 8; hls::stream<ap_uint<16> > axi2HlsStrm("axi2HlsStrm"); hls::stream<bool> axi2HlsEos("axi2HlsEos"); hls::stream<ap_uint<c_parallelBit + PARALLEL_BYTES> > inflateOut("inflateOut"); hls::stream<uint64_t> outSizeStream("outSizeStream"); #pragma HLS STREAM variable = axi2HlsStrm depth = 32 #pragma HLS STREAM variable = axi2HlsEos depth = 32 #pragma HLS STREAM variable = inflateOut depth = 32 //#pragma HLS STREAM variable = inflateOut depth = 4096 #pragma HLS BIND_STORAGE variable = axi2HlsStrm type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = axi2HlsEos type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = inflateOut type = fifo impl = SRL #pragma HLS dataflow details::kStreamReadZlibDecomp<16>(inaxistream, axi2HlsStrm, axi2HlsEos); details::inflateMultiByteCore<DECODER, PARALLEL_BYTES, FILE_FORMAT, LOW_LATENCY, HISTORY_SIZE>( axi2HlsStrm, axi2HlsEos, inflateOut); details::kStreamWriteZlibDecomp<c_parallelBit>(outaxistream, inflateOut); } template <int DECODER, int PARALLEL_BYTES, int FILE_FORMAT, int HISTORY_SIZE = (32 * 1024), int TUSER_WIDTH = 32> void inflate(hls::stream<ap_axiu<16, 0, 0, 0> >& inaxistream, hls::stream<ap_axiu<PARALLEL_BYTES * 8, TUSER_WIDTH, 0, 0> >& outaxistream) { const int c_parallelBit = PARALLEL_BYTES * 8; hls::stream<ap_uint<16> > axi2HlsStrm("axi2HlsStrm"); hls::stream<bool> axi2HlsEos("axi2HlsEos"); hls::stream<ap_uint<c_parallelBit + PARALLEL_BYTES> > inflateOut("inflateOut"); hls::stream<uint64_t> outSizeStream("outSizeStream"); hls::stream<bool> error("error"); #pragma HLS STREAM variable = axi2HlsStrm depth = 32 #pragma HLS STREAM variable = axi2HlsEos depth = 32 #pragma HLS STREAM variable = inflateOut depth = 32 #pragma HLS STREAM variable = error depth = 4 #pragma HLS BIND_STORAGE variable = axi2HlsStrm type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = axi2HlsEos type = FIFO impl = SRL #pragma HLS BIND_STORAGE variable = inflateOut type = fifo impl = SRL #pragma HLS dataflow details::kStreamReadZlibDecomp<16>(inaxistream, axi2HlsStrm, axi2HlsEos); details::inflateWithChkSum<DECODER, PARALLEL_BYTES, FILE_FORMAT, HISTORY_SIZE>(axi2HlsStrm, axi2HlsEos, inflateOut, error); details::hls2AXIWithTUSER<c_parallelBit, TUSER_WIDTH>(outaxistream, inflateOut, error); } template <int GMEM_DATAWIDTH, int GMEM_BRST_SIZE, int DECODER, int PARALLEL_BYTES, int FILE_FORMAT, bool LOW_LATENCY = false, int HISTORY_SIZE = (32 * 1024)> void inflateMultiByteMM(const ap_uint<GMEM_DATAWIDTH>* in, ap_uint<GMEM_DATAWIDTH>* out, uint32_t* encodedSize, uint32_t inputSize) { #pragma HLS dataflow constexpr int c_inBitWidth = 16; constexpr int c_burstDepth = 2 * GMEM_BRST_SIZE; // Internal Streams hls::stream<ap_uint<GMEM_DATAWIDTH> > mm2sStream; hls::stream<ap_uint<c_inBitWidth> > inInfateStream; hls::stream<bool> inInfateStreamEos; hls::stream<uint32_t> sizeStream; hls::stream<uint32_t> sizeStreamV; hls::stream<ap_uint<GMEM_DATAWIDTH + PARALLEL_BYTES> > outStream; // Initialize Size Stream uint32_t tmp = inputSize; sizeStreamV.write(tmp); #pragma HLS STREAM variable = mm2sStream depth = c_burstDepth #pragma HLS STREAM variable = inInfateStream depth = c_burstDepth #pragma HLS STREAM variable = inInfateStreamEos depth = c_burstDepth #pragma HLS STREAM variable = sizeStream depth = 4 #pragma HLS STREAM variable = sizeStreamV depth = 4 #pragma HLS STREAM variable = outStream depth = c_burstDepth // MM2S xf::compression::details::mm2sSimple<GMEM_DATAWIDTH, GMEM_BRST_SIZE>(in, mm2sStream, sizeStream, sizeStreamV); // Downsizer xf::compression::details::streamDownsizerEos<GMEM_DATAWIDTH, c_inBitWidth>(mm2sStream, sizeStream, inInfateStream, inInfateStreamEos); // Decompression xf::compression::details::inflateMultiByteCore<DECODER, PARALLEL_BYTES, FILE_FORMAT, LOW_LATENCY, HISTORY_SIZE>( inInfateStream, inInfateStreamEos, outStream); // S2MM xf::compression::details::s2mmAxi<GMEM_DATAWIDTH, GMEM_BRST_SIZE, PARALLEL_BYTES>(out, outStream, encodedSize); } } // namespace compression } // namespace xf #endif
37.265683
119
0.593689
dycz0fx
747707ad544d2548394b55cb711984acf2336f4b
350
hpp
C++
src/pile.hpp
naidjeldias/EDPA-2018
aeb3e83172419ca2e41735d84449b0ff12c8ec47
[ "MIT" ]
null
null
null
src/pile.hpp
naidjeldias/EDPA-2018
aeb3e83172419ca2e41735d84449b0ff12c8ec47
[ "MIT" ]
null
null
null
src/pile.hpp
naidjeldias/EDPA-2018
aeb3e83172419ca2e41735d84449b0ff12c8ec47
[ "MIT" ]
null
null
null
#include <iostream> #include <stdio.h> #include <stdlib.h> struct node{ int key; struct node *next; explicit node(int); }; class Pile{ private: node *top; int size; protected: node* insertValeu(node *&, int); void removeValeu(node *&); public: Pile(); int getSize(); void push(int); int pop(); };
11.290323
36
0.582857
naidjeldias
747871383e2ec8185377ec80ce5e859aee85a33c
223
cpp
C++
runtime/src/runtime/network/side.cpp
dumheter/wind_simulation
adf731847cb6145a85792a0ebceacc725a3acf9e
[ "MIT" ]
1
2021-04-26T11:24:02.000Z
2021-04-26T11:24:02.000Z
runtime/src/runtime/network/side.cpp
dumheter/wind_simulation
adf731847cb6145a85792a0ebceacc725a3acf9e
[ "MIT" ]
1
2020-06-09T08:53:07.000Z
2020-06-16T13:37:15.000Z
runtime/src/runtime/network/side.cpp
dumheter/wind_simulation
adf731847cb6145a85792a0ebceacc725a3acf9e
[ "MIT" ]
null
null
null
#include "side.hpp" namespace wind { std::string SideToString(const Side side) { switch (side) { case Side::kServer: return "server"; case Side::kClient: default: return "client"; } } } // namespace wind
15.928571
43
0.650224
dumheter
747b67e5a7aa13f3621ebf5ddd6d16453dcf554e
18,706
cpp
C++
Hooks.cpp
maikel233/X-HOOK-For-CS-GO
811bd67171ad48c44b9c5c05cc0fbb5fff4b3687
[ "MIT" ]
48
2018-11-10T06:39:17.000Z
2022-03-10T18:44:52.000Z
Hooks.cpp
maikel233/X-HOOK-For-CS-GO
811bd67171ad48c44b9c5c05cc0fbb5fff4b3687
[ "MIT" ]
7
2018-01-04T15:10:41.000Z
2020-11-14T03:54:30.000Z
Hooks.cpp
maikel233/X-HOOK-For-CS-GO
811bd67171ad48c44b9c5c05cc0fbb5fff4b3687
[ "MIT" ]
21
2018-11-23T23:13:09.000Z
2022-03-14T21:11:38.000Z
#include "Hooks.h" #include "Utils/Skins.h" #include "GUI/Tabs/AimTabs/AimBotTab.h" #include "SDK/SteamAPI.h" #include "SDK/materialconfig.h" #pragma comment(lib, "winmm.lib") //#pragma comment(lib, "d3d9.lib") bool Settings::Background::enable = true; bool SetKeyCodeState::shouldListen = false; ButtonCode_t* SetKeyCodeState::keyOutput = nullptr; bool Settings::Misc::AntiAfk = false; namespace Hooks { HRESULT WINAPI hPresent(IDirect3DDevice9* pDevice, RECT* pSourceRect, RECT* pDestRect, HWND hDestWindowOverride, RGNDATA* pDirtyRegion) { if (GetAsyncKeyState(VK_SNAPSHOT)) { return Present(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); } DWORD dwOld_D3DRS_COLORWRITEENABLE; return Present(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion); } HRESULT WINAPI hReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters) { static Reset_t oReset = D3D9Hook->GetOriginalFunction<Reset_t>(16); if (!renderer.IsReady() || !pDevice) return oReset(pDevice, pPresentationParameters); ImGui_ImplDX9_InvalidateDeviceObjects(); HRESULT result = oReset(pDevice, pPresentationParameters); ImGui_ImplDX9_CreateDeviceObjects(); return result; } void __stdcall hPaintTraverse(unsigned int VGUIPanel, bool forcerepaint, bool allowforce) { ESP::PrePaintTraverse(VGUIPanel, forcerepaint, allowforce); PanelHook->GetOriginalFunction<PaintTraverseFn>(41)(pPanel, VGUIPanel, forcerepaint, allowforce); static unsigned int drawPanel; if (!drawPanel) if (strstr(pPanel->GetName(VGUIPanel), "MatSystemTopPanel")) drawPanel = VGUIPanel; if (VGUIPanel != drawPanel) return; ////Anti ss if (Settings::ScreenshotCleaner::enabled && pEngine->IsTakingScreenshot()) return; Dlights::Paint(); ESP::Paint(); GrenadeHelper::Paint(); GrenadePrediction::Paint(); SniperCrosshair::Paint(); Recoilcrosshair::Paint(); Hitmarkers::Paint(); Walkbot::update(); //lbyindicator::Paint(); //AngleIndicator::Paint(); //SpeedIndicator::Paint(); } bool HookRecvProp(const char* className, const char* propertyName, std::unique_ptr<RecvPropHook>& recvPropHook) { // FIXME: Does not search recursively.. yet. // Recursion is a meme, stick to reddit mcswaggens. for (ClientClass* pClass = pClient->GetAllClasses(); pClass; pClass = pClass->m_pNext) { if (strcmp(pClass->m_pNetworkName, className) == 0) { RecvTable* pClassTable = pClass->m_pRecvTable; for (int nIndex = 0; nIndex < pClassTable->m_nProps; nIndex++) { RecvProp* pProp = &pClassTable->m_pProps[nIndex]; if (!pProp || strcmp(pProp->m_pVarName, propertyName) != 0) continue; recvPropHook = std::make_unique<RecvPropHook>(pProp); return true; } break; } } return false; } bool ShouldDrawFogs(void* thisptr) { if (!Settings::NoFog::enabled) return ClientModeHook->GetOriginalFunction<ShouldDrawFogFn>(17)(thisptr); /* Skybox Fog is separate */ IMatRenderContext* renderCtx = pMaterial->GetRenderContext(); renderCtx->FogMode(MaterialFogMode_t::MATERIAL_FOG_NONE); renderCtx->Release(); /* Return false for normal fog */ return false; // uhhh, no Sweetie, don't draw that fog. } bool ShouldDrawFog(void* thisptr) { return ShouldDrawFogs(thisptr); } static int __fastcall SendDatagram(NetworkChannel* network, void* edx, void* datagram) { if (!Settings::Aimbot::fakeLat || datagram || !pEngine->IsInGame() || !Settings::Aimbot::backtron) { return NetDataGram->GetOriginalFunction<SendDatagramFn>(46)(network, datagram); } int instate = network->InReliableState; int insequencenr = network->InSequenceNr; int faketimeLimit = Settings::Aimbot::timeLimit; if (faketimeLimit <= 200) { faketimeLimit = 0; } else { faketimeLimit -= 200; } float delta = max(0.f, std::clamp(faketimeLimit / 1000.f, 0.f, 0.2f) - network->getLatency(0)); Backtrack::AddLatencyToNetwork(network, delta + (delta / 20.0f)); NetworkChannel* OrigNet = network; void* OrigData = datagram; network->InReliableState = instate; network->InSequenceNr = insequencenr; return NetDataGram->GetOriginalFunction<SendDatagramFn>(46)(OrigNet, OrigData); } bool __stdcall hCreateMove(float frametime, CUserCmd* cmd) { auto result = ClientModeHook->GetOriginalFunction<CreateMoveFn>(24)(pClientMode, frametime, cmd); if (!cmd->command_number) return result; uintptr_t* framePointer; __asm mov framePointer, ebp; bool& sendPacket = *reinterpret_cast<bool*>(*framePointer - 0x1C); pGlobalVars->serverTime(cmd); BHop::CreateMove(cmd); AutoStrafe::CreateMove(cmd); BHop::CreateMoveCircle(cmd); //Resolver::CreateMove(cmd); if (Settings::Misc::AntiAfk && cmd->command_number % 2) { cmd->buttons |= 1 << 26; } static void* oldPointer = nullptr; C_BasePlayer* localplayer = (C_BasePlayer*)pEntityList->GetClientEntity(pEngine->GetLocalPlayer()); auto network = pEngine->GetNetChannelInfo(); if (oldPointer != network && network && localplayer) { oldPointer = network; Backtrack::UpdateIncomingSequences(true); NetDataGram = std::make_unique<VMTHook>(network); NetDataGram->HookFunction(SendDatagram, 46); } Backtrack::UpdateIncomingSequences(); GrenadeHelper::CreateMove(cmd); GrenadePrediction::CreateMove(cmd); Backtrack::run(cmd); Aimbot::CreateMove(cmd); Triggerbot::CreateMove(cmd); lbyindicator::CreateMove(cmd); ReportBot::run(); ShowRanks::CreateMove(cmd); AutoDefuse::CreateMove(cmd); JumpThrow::CreateMove(cmd); EdgeJump::PrePredictionCreateMove(cmd); NoDuckCooldown::CreateMove(cmd); PredictionSystem::StartPrediction(cmd); Autoblock::CreateMove(cmd); NameChanger::fakeBan(); AutoKnife::CreateMove(cmd); AntiAim::CreateMove(cmd); Airstuck::CreateMove(cmd); Fakewalk::CreateMove(cmd); MoonWalk::CreateMove(cmd); Walkbot::CreateMove(cmd); FakeLag::CreateMove(cmd); ESP::CreateMove(cmd); PredictionSystem::EndPrediction(); AngleIndicator::PostPredictionCreateMove(cmd); EdgeJump::PostPredictionCreateMove(cmd); return false; } bool __stdcall Hooked_SendLobbyChatMessage(CSteamID steamIdLobby, const void* pvMsgBody, int cubMsgBody) { typedef bool(__thiscall* SendLobbyChatMessage_t)(ISteamMatchmaking*, CSteamID, const void*, int); static SendLobbyChatMessage_t Original_SendLobbyChatMessage = SteamHook->GetOriginalFunction<SendLobbyChatMessage_t>(26); if (!LobbyMod::Get()->InterpretLobbyMessage(steamIdLobby, pvMsgBody, cubMsgBody)) return Original_SendLobbyChatMessage(pSteamMatchmaking, steamIdLobby, pvMsgBody, cubMsgBody);//Original_SendLobbyChatMessage(I.SteamMatchmaking(), steamIdLobby, pvMsgBody, cubMsgBody); return true; } using GCRetrieveMessage = EGCResult(__thiscall*)(void*, uint32_t* punMsgType, void* pubDest, uint32_t cubDest, uint32_t* pcubMsgSize); using GCSendMessage = EGCResult(__thiscall*)(void*, uint32_t unMsgType, const void* pubData, uint32_t cubData); EGCResult __fastcall hkGCRetrieveMessage(void* ecx, void*, uint32_t* punMsgType, void* pubDest, uint32_t cubDest, uint32_t* pcubMsgSize) { static auto oGCRetrieveMessage = SteamGameCoordinator->GetOriginalFunction<GCRetrieveMessage>(2); auto status = oGCRetrieveMessage(ecx, punMsgType, pubDest, cubDest, pcubMsgSize); if (status == k_EGCResultOK) { void* thisPtr = nullptr; __asm mov thisPtr, ebx; auto oldEBP = *reinterpret_cast<void**>((uint32_t)_AddressOfReturnAddress() - 4); uint32_t messageType = *punMsgType & 0x7FFFFFFF; write.ReceiveMessage(thisPtr, oldEBP, messageType, pubDest, cubDest, pcubMsgSize); } return status; } EGCResult __fastcall hkGCSendMessage(void* ecx, void*, uint32_t unMsgType, const void* pubData, uint32_t cubData) { static auto oGCSendMessage = SteamGameCoordinator->GetOriginalFunction<GCSendMessage>(0); bool sendMessage = write.PreSendMessage(unMsgType, const_cast<void*>(pubData), cubData); if (!sendMessage) return EGCResult::k_EGCResultOK; return oGCSendMessage(ecx, unMsgType, const_cast<void*>(pubData), cubData); } void __stdcall hDrawModelExecute(IMatRenderContext* matctx, const DrawModelState_t& state, const ModelRenderInfo_t& pInfo, matrix3x4_t* pCustomBoneToWorld) { if (!Settings::ScreenshotCleaner::enabled || !pEngine->IsTakingScreenshot()) { Chams::DrawModelExecute(matctx, state, pInfo, pCustomBoneToWorld); ThirdPerson::DrawModelExecute(matctx, state, pInfo, pCustomBoneToWorld); } ModelRenderHook->GetOriginalFunction<DrawModelExecuteFn>(21)(pModelRender, matctx, state, pInfo, pCustomBoneToWorld); pModelRender->ForcedMaterialOverride(nullptr); if (!Settings::ScreenshotCleaner::enabled || !pEngine->IsTakingScreenshot()) { ESP::DrawModelExecute(matctx, state, pInfo, pCustomBoneToWorld); } } # bool __fastcall hkOverrideConfig(IMaterialSystem* this0, int edx, MaterialSystem_Config_t* config, bool forceUpdate) { MaterialConfig::OverrideConfig(config, forceUpdate); return MaterialHook->GetOriginalFunction<OverrideConfigFn>(21)(this0, config, forceUpdate); //21 is correct. } void __fastcall hFrameStageNotify(void* ecx, void* edx, ClientFrameStage_t stage) { [[maybe_unused]] static auto backtrackInit = (Backtrack::init(), true); if (pEngine->isConnnected() && !pEngine->IsInGame()) NameChanger::changeName(true, nullptr, 0.0f); // PVS fix if (stage == ClientFrameStage_t::FRAME_RENDER_START) { C_BasePlayer* localplayer = (C_BasePlayer*)pEntityList->GetClientEntity(pEngine->GetLocalPlayer()); for (int i = 1; i < pEngine->GetMaxClients(); ++i) { C_BasePlayer* player = (C_BasePlayer*)pEntityList->GetClientEntity(i); if (!player || player == localplayer || player->GetDormant() || !player->GetAlive() || player->GetImmune()) continue; IEngineClient::player_info_t playerInfo; pEngine->GetPlayerInfo(player->GetIndex(), &playerInfo); // These were hard as shit to find: https://i.imgur.com/gTqgDLO.png *(int*)((uintptr_t)player + 0xA30) = pGlobalVars->framecount; // Last Occlusion check frame# *(int*)((uintptr_t)player + 0xA28) = 0; // Occlusion flags } } static bool SpoofCvars = false; if (!SpoofCvars) { ConVar* sv_cheats = pCvar->FindVar("sv_cheats"); SpoofedConvar* sv_cheats_spoofed = new SpoofedConvar(sv_cheats); sv_cheats_spoofed->SetInt(1); ConVar* ST = pCvar->FindVar("r_DrawSpecificStaticProp"); ST->SetValue(0); SpoofCvars = true; } if (stage == ClientFrameStage_t::FRAME_START) { FPSWindow::update(); } Backtrack::update(stage); CustomGlow::FrameStageNotify(stage); SkinChanger::FrameStageNotifyModels(stage); SkinChanger::FrameStageNotifySkins(stage); Noflash::FrameStageNotify(stage); View::FrameStageNotify(stage); // Resolver::FrameStageNotify(stage); SkyBox::FrameStageNotify(stage); ASUSWalls::FrameStageNotify(stage); NoSmoke::FrameStageNotify(stage); ThirdPerson::FrameStageNotify(stage); if (SkinChanger::forceFullUpdate) { pClientState->m_nDeltaTick = -1; SkinChanger::forceFullUpdate = false; } ClientHook->GetOriginalFunction<FrameStageNotifyFn>(37)(ecx, stage); // Resolver::PostFrameStageNotify(stage); View::PostFrameStageNotify(stage); } IDirect3DStateBlock9* pixel_state = NULL; IDirect3DVertexDeclaration9* vertDec; IDirect3DVertexShader9* vertShader; DWORD dwOld_D3DRS_COLORWRITEENABLE; void SaveState(IDirect3DDevice9* pDevice) { pDevice->GetRenderState(D3DRS_COLORWRITEENABLE, &dwOld_D3DRS_COLORWRITEENABLE); // pDevice->CreateStateBlock(D3DSBT_PIXELSTATE, &pixel_state); // This seam not to be needed anymore because valve fixed their shit pDevice->GetVertexDeclaration(&vertDec); pDevice->GetVertexShader(&vertShader); pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, 0xffffffff); pDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, false); pDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP); pDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP); pDevice->SetSamplerState(NULL, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP); pDevice->SetSamplerState(NULL, D3DSAMP_SRGBTEXTURE, NULL); } void RestoreState(IDirect3DDevice9* pDevice) // not restoring everything. Because its not needed. { pDevice->SetRenderState(D3DRS_COLORWRITEENABLE, dwOld_D3DRS_COLORWRITEENABLE); pDevice->SetRenderState(D3DRS_SRGBWRITEENABLE, true); //pixel_state->Apply(); //pixel_state->Release(); pDevice->SetVertexDeclaration(vertDec); pDevice->SetVertexShader(vertShader); } HRESULT WINAPI hkEndScene(IDirect3DDevice9* device) { static EndScene_t oEndScene = D3D9Hook->GetOriginalFunction<EndScene_t>(42); SaveState(device); Menu(); RestoreState(device); device->SetRenderState(D3DRS_COLORWRITEENABLE, dwOld_D3DRS_COLORWRITEENABLE); return oEndScene(device); } bool __fastcall hFireEventClientSide(void* ecx, void* edx, IGameEvent* pEvent) { Aimbot::FireGameEvent(pEvent); Hitmarkers::FireGameEvent(pEvent); NameStealer::FireGameEvent(pEvent); // Resolver::FireGameEvent(pEvent); Spammer::FireGameEvent(pEvent); EventLogger::FireGameEvent(pEvent); ValveDSCheck::FireGameEvent(pEvent); if (pEvent) { SkinChanger::FireEventClientSide(pEvent); SkinChanger::FireGameEvent(pEvent); } return FireEventHook->GetOriginalFunction<FireEventClientSideFn>(9)(ecx, pEvent); } void __stdcall hBeginFrame(float frameTime) { ClanTagChanger::BeginFrame(frameTime); NameChanger::BeginFrame(frameTime); NameStealer::BeginFrame(frameTime); Spammer::BeginFrame(frameTime); Radar::BeginFrame(); Skins::Localize(); DisablePostProcessing::BeginFrame(); return MaterialHook->GetOriginalFunction<BeginFrameFn>(42)(pMaterial, frameTime); } void __fastcall Hooks::EmitSound1(void* thisptr, void* edx, IRecipientFilter& filter, int iEntIndex, int iChannel, const char* pSoundEntry, unsigned int nSoundEntryHash, const char* pSample, float flVolume, int nSeed, float flAttenuation, int iFlags, int iPitch, const Vector* pOrigin, const Vector* pDirection, void* pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity, int Unknownn) { ESP::EmitSound(iEntIndex, pSample); SoundHook->GetOriginalFunction<EmitSound1Fn>(5)(thisptr, filter, iEntIndex, iChannel, pSoundEntry, nSoundEntryHash, pSample, flVolume, nSeed, flAttenuation, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity, Unknownn); } void __fastcall Hooks::EmitSound2(void* thisptr, void* edx, void* Filter, int iEntIndex, int iChannel, const char* pSoundEntry, unsigned int nSoundEntryHash, const char* pSample, float flVolume, int nSeed, int iSoundLevel, int iFlags, int iPitch, const Vector* pOrigin, const Vector* pDirection, void* pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity, void* SoundParam ) { ESP::EmitSound(iEntIndex, pSample); SoundHook->GetOriginalFunction<EmitSound2Fn>(5)(thisptr, Filter, iEntIndex, iChannel, pSoundEntry, nSoundEntryHash, pSample, flVolume, nSeed, iSoundLevel, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity, SoundParam); } void __fastcall Hooks::hkEmitSound(IEngineSound* thisptr, int edx, IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSoundEntry, unsigned int nSoundEntryHash, const char *pSample, float flVolume, float flAttenuation, int nSeed, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, CUtlVector< Vector >* pUtlVecOrigins, bool bUpdatePositions, float soundtime, int speakerentity, int Unknownn) { ESP::EmitSound(iEntIndex, pSample); auto oEmitSound = SoundHook->GetOriginalFunction<EmitSound1Fn>(5); oEmitSound(thisptr, filter, iEntIndex, iChannel, pSoundEntry, nSoundEntryHash, pSample, flVolume, flAttenuation, nSeed, iFlags, iPitch, pOrigin, pDirection, pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity, Unknownn); } void OnScreenSizeChanged(void* thisptr, int oldwidth, int oldheight) { SurfaceHook->GetOriginalFunction<OnScreenSizeChangedFn>(116)(thisptr, oldwidth, oldheight); //Fonts::SetupFonts(); } void __stdcall hPlaySounds(const char* fileName) { SurfaceHook->GetOriginalFunction<PlaySoundFn>(82)(pSurface, fileName); AutoAccept::PlaySound(fileName); } void __stdcall hLockCursor() { bool Lock = G::is_renderer_active; if (Lock) { pSurface->unlockcursor(); return; } SurfaceHook->GetOriginalFunction<LockCursor>(67)(pSurface); } void __fastcall Hooks::RenderSmokePostViewmodel(void* ecx, void* edx) { if (!NoSmoke::RenderSmokePostViewmodel()) RenderViewHook->GetOriginalFunction<NoSmokeFn>(41)(ecx); } void __fastcall hRenderView(void* ecx, void* edx, CViewSetup &setup, CViewSetup &hudViewSetup, int nClearFlags, int whatToDraw) { RenderViewHook->GetOriginalFunction<RenderViewFn>(6)(ecx, setup, hudViewSetup, nClearFlags, whatToDraw); SpeedIndicator::RenderView(ecx, setup, hudViewSetup, nClearFlags, whatToDraw); } void __fastcall hOverrideView(void* _this, void* _edx, ViewSetup* setup) { if (!Settings::ScreenshotCleaner::enabled || !pEngine->IsTakingScreenshot()) { GrenadePrediction::OverrideView(setup); FOVChanger::OverrideView(setup); ThirdPerson::OverrideView(setup); } OverrideView::currentFOV = setup->fov; ClientModeHook->GetOriginalFunction<OverreideViewFn>(18)(_this, setup); } float __stdcall hGetViewModelFOV() { float fov = ClientModeHook->GetOriginalFunction<GetViewModelFOVFn>(35)(); FOVChanger::GetViewModelFOV(fov); return fov; } void __fastcall Hooks::SetKeyCodeState(void* thisptr, void* edx, ButtonCode_t code, bool bPressed) { if (SetKeyCodeState::shouldListen && bPressed) { SetKeyCodeState::shouldListen = false; *SetKeyCodeState::keyOutput = code; UI::UpdateWeaponSettings(); G::input_shouldListen = true; } if (!SetKeyCodeState::shouldListen) Shortcuts::SetKeyCodeState(code, bPressed); InputInternalHook->GetOriginalFunction<SetKeyCodeStateFn>(91)(thisptr, code, bPressed); } void __fastcall Hooks::SetMouseCodeState(void* thisptr, void* edx, ButtonCode_t code, MouseCodeState_t state) { if (SetKeyCodeState::shouldListen && state == MouseCodeState_t::BUTTON_PRESSED) { SetKeyCodeState::shouldListen = false; *SetKeyCodeState::keyOutput = code; UI::UpdateWeaponSettings(); } InputInternalHook->GetOriginalFunction<SetMouseCodeStateFn>(92)(thisptr, code, state); } }
33.523297
229
0.74559
maikel233
747d2c9b57ad67d083031df7ec455524c50e9315
282
cpp
C++
Node.cpp
goodandevilsoftware/kasai
e2d6b9e84aa2e292ddcc1bc8688c284b9622ba32
[ "Unlicense" ]
null
null
null
Node.cpp
goodandevilsoftware/kasai
e2d6b9e84aa2e292ddcc1bc8688c284b9622ba32
[ "Unlicense" ]
null
null
null
Node.cpp
goodandevilsoftware/kasai
e2d6b9e84aa2e292ddcc1bc8688c284b9622ba32
[ "Unlicense" ]
null
null
null
// // Created by Nathaniel Blair on 24/10/20. // #include "Node.h" void Node::Connect(Node *otherNode) { friends.push_back(otherNode); } void Node::Receive(string message) { // TODO: implement Receive } void Node::Relay(string message) { // TODO: implement relay }
14.842105
42
0.666667
goodandevilsoftware
747dc2176fe92551812f62ac58a72c8dce42caf2
869
hpp
C++
uplift/src/objects/shared_memory.hpp
Inori/uplift
d718b83c66fda6fe018dac85c1fe7cdf79b559d5
[ "MIT" ]
1
2021-07-07T10:34:50.000Z
2021-07-07T10:34:50.000Z
uplift/src/objects/shared_memory.hpp
Inori/uplift
d718b83c66fda6fe018dac85c1fe7cdf79b559d5
[ "MIT" ]
null
null
null
uplift/src/objects/shared_memory.hpp
Inori/uplift
d718b83c66fda6fe018dac85c1fe7cdf79b559d5
[ "MIT" ]
null
null
null
#pragma once #include "object.hpp" namespace uplift::objects { class SharedMemory : public Object { public: static const Object::Type ObjectType = Type::SharedMemory; public: SharedMemory(Runtime* runtime); virtual ~SharedMemory(); SyscallError Initialize(const std::string& path, uint32_t flags, uint16_t mode); SyscallError Close(); SyscallError Read(void* data_buffer, size_t data_size, size_t* read_size); SyscallError Write(const void* data_buffer, size_t data_size, size_t* written_size); SyscallError Truncate(int64_t length); SyscallError IOControl(uint32_t request, void* argp); SyscallError MMap(void* addr, size_t len, int prot, int flags, size_t offset, void*& allocation); private: void* native_handle_; int64_t length_; std::string path_; uint32_t flags_; uint16_t mode_; }; }
26.333333
101
0.719217
Inori
748bf0f516f8e7819c352625c000de0bfa3e3dd8
59
cpp
C++
Engine/source/IO/Serializers.cpp
mbatc/Fractal
0df1f6a64d03676e3dd8af0686413f6ffdbf6627
[ "MIT" ]
null
null
null
Engine/source/IO/Serializers.cpp
mbatc/Fractal
0df1f6a64d03676e3dd8af0686413f6ffdbf6627
[ "MIT" ]
34
2021-05-09T10:31:24.000Z
2022-01-24T11:26:48.000Z
Engine/source/IO/Serializers.cpp
mbatc/Fractal
0df1f6a64d03676e3dd8af0686413f6ffdbf6627
[ "MIT" ]
null
null
null
#include "Fractal/IO/Serializers.h" namespace Fractal { }
9.833333
35
0.745763
mbatc
748d1def6c804820e55ee5343f303284e6bdbbbf
2,159
cpp
C++
Graphics3dSolution/Graphics3dLib/Rendering/RenderPaths/GraphicsBufferPath.cpp
TheFloHub/Graphics3dLib
4e4b310b49b0bae35d45136ccc43a006b39ba2b5
[ "MIT" ]
null
null
null
Graphics3dSolution/Graphics3dLib/Rendering/RenderPaths/GraphicsBufferPath.cpp
TheFloHub/Graphics3dLib
4e4b310b49b0bae35d45136ccc43a006b39ba2b5
[ "MIT" ]
null
null
null
Graphics3dSolution/Graphics3dLib/Rendering/RenderPaths/GraphicsBufferPath.cpp
TheFloHub/Graphics3dLib
4e4b310b49b0bae35d45136ccc43a006b39ba2b5
[ "MIT" ]
null
null
null
#include "GraphicsBufferPath.h" #include <Graphics3dLib/Assets/Shader.h> #include <Graphics3dLib/Rendering/FrameBufferObject.h> #include <Graphics3dLib/Components/Camera.h> #include <Graphics3dLib/Components/Transform.h> #include <Graphics3dLib/Scene/SceneObject.h> #include <glm/glm.hpp> #include <glm/gtc/matrix_inverse.hpp> #include <glm/gtc/type_ptr.hpp> G3d::GraphicsBufferPath::GraphicsBufferPath(unsigned int width, unsigned int height) : RenderPath( nullptr, new FrameBufferObject( width, height, GL_DEPTH_COMPONENT24, // depth buffer GL_RGBA16, // normals, A = roughness GL_RGBA8)) // albedo, A = metallic { } G3d::GraphicsBufferPath::~GraphicsBufferPath() { } void G3d::GraphicsBufferPath::render(Camera const* pCamera, std::vector<SceneObject const*> sceneObjects) { mpFrameBuffer->use(); glViewport(0, 0, mpFrameBuffer->getWidth(), mpFrameBuffer->getHeight()); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glm::mat4 modelViewMatrix; glm::mat4 modelViewProjectionMatrix; glm::mat3 normalMatrix; for (std::vector<SceneObject const*>::const_iterator objectIter = sceneObjects.cbegin(); objectIter != sceneObjects.cend(); ++objectIter) { // TODO: add Camera::current or Camera::main and do this in the materials!? modelViewMatrix = m180Rotation * pCamera->getSceneObject()->getTransform()->getWorldToLocalMatrix() * (*objectIter)->getTransform()->getLocalToWorldMatrix(); modelViewProjectionMatrix = pCamera->getProjectionMatrix() * modelViewMatrix; normalMatrix = glm::inverseTranspose(glm::mat3(modelViewMatrix)); Shader::setGlobalMat4("modelViewMatrix", modelViewMatrix); Shader::setGlobalMat4("modelViewProjectionMatrix", modelViewProjectionMatrix); Shader::setGlobalMat3("normalMatrix", normalMatrix); (*objectIter)->render(); } } G3d::TexturePtr G3d::GraphicsBufferPath::getDepthBuffer() { return mpFrameBuffer->getDepthComponent(); } G3d::TexturePtr G3d::GraphicsBufferPath::getNormalBuffer() { return mpFrameBuffer->getTexture(0); } G3d::TexturePtr G3d::GraphicsBufferPath::getAlbedoBuffer() { return mpFrameBuffer->getTexture(1); }
31.75
160
0.764706
TheFloHub
748e34b7e0eceb0b1a932b35182c3c6c4ba33e93
7,608
cpp
C++
Server Lib/Game Server/GAME/bot_gm_event.cpp
eantoniobr/SuperSS-Dev
f57c094f164cc90c2694df33ba394304cd0e7846
[ "MIT" ]
null
null
null
Server Lib/Game Server/GAME/bot_gm_event.cpp
eantoniobr/SuperSS-Dev
f57c094f164cc90c2694df33ba394304cd0e7846
[ "MIT" ]
null
null
null
Server Lib/Game Server/GAME/bot_gm_event.cpp
eantoniobr/SuperSS-Dev
f57c094f164cc90c2694df33ba394304cd0e7846
[ "MIT" ]
1
2021-11-03T00:21:07.000Z
2021-11-03T00:21:07.000Z
// Arquivo bot_gm_event.cpp // Criado em 03/11/2020 as 20:06 por Acrisio // Implementa��o da classe BotGMEvent #if defined(_WIN32) #pragma pack(1) #endif #if defined(_WIN32) #include <WinSock2.h> #endif #include "bot_gm_event.hpp" #include "../../Projeto IOCP/DATABASE/normal_manager_db.hpp" #include "../PANGYA_DB/cmd_bot_gm_event_info.hpp" #include "../../Projeto IOCP/UTIL/util_time.h" #include "../UTIL/lottery.hpp" #include "../../Projeto IOCP/UTIL/random_gen.hpp" #include <algorithm> #if defined(_WIN32) #define TRY_CHECK try { \ EnterCriticalSection(&m_cs); #elif defined(__linux__) #define TRY_CHECK try { \ pthread_mutex_lock(&m_cs); #endif #if defined(_WIN32) #define LEAVE_CHECK LeaveCriticalSection(&m_cs); #elif defined(__linux__) #define LEAVE_CHECK pthread_mutex_unlock(&m_cs); #endif #if defined(_WIN32) #define CATCH_CHECK(_method) }catch (exception& e) { \ LeaveCriticalSection(&m_cs); \ \ _smp::message_pool::getInstance().push(new message("[BotGMEvent::" + std::string(_method) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE)); #elif defined(__linux__) #define CATCH_CHECK(_method) }catch (exception& e) { \ pthread_mutex_unlock(&m_cs); \ \ _smp::message_pool::getInstance().push(new message("[BotGMEvent::" + std::string(_method) + "][ErrorSystem] " + e.getFullMessageError(), CL_FILE_LOG_AND_CONSOLE)); #endif #define END_CHECK } \ constexpr uint32_t MAX_REWARD_PER_ROUND = 3u; using namespace stdA; BotGMEvent::BotGMEvent() : m_rt(), m_rewards(), m_load(false), m_st{ 0u } { #if defined(_WIN32) InitializeCriticalSection(&m_cs); #elif defined(__linux__) INIT_PTHREAD_MUTEXATTR_RECURSIVE; INIT_PTHREAD_MUTEX_RECURSIVE(&m_cs); DESTROY_PTHREAD_MUTEXATTR_RECURSIVE; #endif // Inicializa initialize(); } BotGMEvent::~BotGMEvent() { clear(); #if defined(_WIN32) DeleteCriticalSection(&m_cs); #elif defined(__linux__) pthread_mutex_destroy(&m_cs); #endif } void BotGMEvent::clear() { TRY_CHECK; if (!m_rt.empty()) { m_rt.clear(); m_rt.shrink_to_fit(); } if (!m_rewards.empty()) { m_rewards.clear(); m_rewards.shrink_to_fit(); } m_load = false; LEAVE_CHECK; CATCH_CHECK("clear"); m_load = false; END_CHECK; } void BotGMEvent::load() { if (isLoad()) clear(); initialize(); } bool BotGMEvent::isLoad() { bool isload = false; TRY_CHECK; isload = (m_load); LEAVE_CHECK; CATCH_CHECK("isLoad"); isload = false; END_CHECK; return isload; } void BotGMEvent::initialize() { TRY_CHECK; CmdBotGMEventInfo cmd_bgei(true); // Waiter NormalManagerDB::add(0, &cmd_bgei, nullptr, nullptr); cmd_bgei.waitEvent(); if (cmd_bgei.getException().getCodeError() != 0) throw cmd_bgei.getException(); m_rt = cmd_bgei.getTimeInfo(); m_rewards = cmd_bgei.getRewardInfo(); // Log //#ifdef _DEBUG _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Carregou " + std::to_string(m_rt.size()) + " times.", CL_FILE_LOG_AND_CONSOLE)); for (auto& el : m_rt) _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Time[Start=" + _formatTime(el.m_start) + ", End=" + _formatTime(el.m_end) + ", Channel_id=" + std::to_string((unsigned short)el.m_channel_id) +"].", CL_FILE_LOG_AND_CONSOLE)); _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Bot GM Event System carregado com sucesso!", CL_FILE_LOG_AND_CONSOLE)); /*#else _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Carregou " + std::to_string(m_rt.size()) + " times.", CL_ONLY_FILE_LOG)); for (auto& el : m_rt) _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Time[Start=" + _formatTime(el.m_start) + ", End=" + _formatTime(el.m_end) + ", Channel_id=" + std::to_string((unsigned short)el.m_channel_id) + "].", CL_ONLY_FILE_LOG)); _smp::message_pool::getInstance().push(new message("[BotGMEvent::initialize][Log] Bot GM Event System carregado com sucesso!", CL_ONLY_FILE_LOG)); #endif // _DEBUG*/ // Carregou com sucesso m_load = true; LEAVE_CHECK; CATCH_CHECK("initialize"); // Relan�a para o server tomar as provid�ncias throw; END_CHECK; } bool BotGMEvent::checkTimeToMakeRoom() { if (!isLoad()) { _smp::message_pool::getInstance().push(new message("[BotGMEvent::checkTimeToMakeRoom][Error] Bot GM Event not have initialized, please call init function first.", CL_FILE_LOG_AND_CONSOLE)); return false; } bool is_time = false; TRY_CHECK; GetLocalTime(&m_st); auto it = std::find_if(m_rt.begin(), m_rt.end(), [&](auto& _el) { return _el.isBetweenTime(m_st); }); is_time = (it != m_rt.end()); LEAVE_CHECK; CATCH_CHECK("checkTimeToMakeRoom"); END_CHECK; return is_time; } bool BotGMEvent::messageSended() { if (!isLoad()) { _smp::message_pool::getInstance().push(new message("[BotGMEvent::messageSended][Error] Bot GM Event not have initialized, please call init function first.", CL_FILE_LOG_AND_CONSOLE)); return false; } bool is_sended = false; TRY_CHECK GetLocalTime(&m_st); auto it = std::find_if(m_rt.begin(), m_rt.end(), [&](auto& _el) { return _el.isBetweenTime(m_st); }); is_sended = (it != m_rt.end() && it->m_sended_message); LEAVE_CHECK CATCH_CHECK("messageSended") END_CHECK return is_sended; } void BotGMEvent::setSendedMessage() { if (!isLoad()) { _smp::message_pool::getInstance().push(new message("[BotGMEvent::setSendedMessage][Error] Bot GM Event not have initialized, please call init function first.", CL_FILE_LOG_AND_CONSOLE)); return; } TRY_CHECK GetLocalTime(&m_st); // Zera todas os intervalos que n�o est� na hora, e o intervalo que est� na hora seta ele std::for_each(m_rt.begin(), m_rt.end(), [&](auto& _el) { if (_el.isBetweenTime(m_st)) _el.m_sended_message = true; else _el.m_sended_message = false; }); LEAVE_CHECK CATCH_CHECK("setSendedMessage") END_CHECK } stRangeTime* BotGMEvent::getInterval() { if (!isLoad()) { _smp::message_pool::getInstance().push(new message("[BotGMEvent::getInterval][Error] Bot GM Event not have initialized, please call init function first.", CL_FILE_LOG_AND_CONSOLE)); return nullptr; } stRangeTime *rt = nullptr; TRY_CHECK GetLocalTime(&m_st); auto it = std::find_if(m_rt.begin(), m_rt.end(), [&](auto& _el) { return _el.isBetweenTime(m_st); }); if (it != m_rt.end()) rt = &(*it); LEAVE_CHECK CATCH_CHECK("getInterval") rt = nullptr; END_CHECK return rt; } std::vector< stReward > BotGMEvent::calculeReward() { std::vector< stReward > v_reward; TRY_CHECK; // No m�ximo 3 pr�mios uint32_t num_r = (uint32_t)sRandomGen::getInstance().rIbeMt19937_64_rdeviceRange(1, MAX_REWARD_PER_ROUND); Lottery lottery(std::clock()); Lottery::LotteryCtx* ctx = nullptr; for (auto& el : m_rewards) lottery.push(el.rate, (size_t)&el); bool remove_to_roleta = num_r < lottery.getCountItem(); // Not loop infinite num_r = num_r > lottery.getCountItem() ? lottery.getCountItem() : num_r; while (num_r > 0) { if ((ctx = lottery.spinRoleta(remove_to_roleta)) == nullptr) { // Log _smp::message_pool::getInstance().push(new message("[BotGMEvent::calculeReward][Error][WARNING] nao conseguiu sortear um reward na lottery.", CL_FILE_LOG_AND_CONSOLE)); // Continua continue; } v_reward.push_back(*(stReward*)ctx->value); // decrease num_r(reward) num_r--; } LEAVE_CHECK; CATCH_CHECK("calculeReward"); END_CHECK; return v_reward; }
22.508876
260
0.699527
eantoniobr
749dc6719febf881b52d956537cd7a548f6a2e28
6,612
hpp
C++
tpls/pressio/include/pressio/WIP/rom/lspg/impl/steady/rom_compose_steady_lspg_impl.hpp
fnrizzi/pressio-demoapps
6ff10bbcf4d526610580940753c9620725bff1ba
[ "BSD-3-Clause" ]
29
2019-11-11T13:17:57.000Z
2022-03-16T01:31:31.000Z
tpls/pressio/include/pressio/WIP/rom/lspg/impl/steady/rom_compose_steady_lspg_impl.hpp
fnrizzi/pressio-demoapps
6ff10bbcf4d526610580940753c9620725bff1ba
[ "BSD-3-Clause" ]
303
2019-09-30T10:15:41.000Z
2022-03-30T08:24:04.000Z
tpls/pressio/include/pressio/WIP/rom/lspg/impl/steady/rom_compose_steady_lspg_impl.hpp
fnrizzi/pressio-demoapps
6ff10bbcf4d526610580940753c9620725bff1ba
[ "BSD-3-Clause" ]
4
2020-07-07T03:32:36.000Z
2022-03-10T05:21:42.000Z
/* //@HEADER // ************************************************************************ // // rom_compose_steady_lspg_impl.hpp // Pressio // Copyright 2019 // National Technology & Engineering Solutions of Sandia, LLC (NTESS) // // Under the terms of Contract DE-NA0003525 with NTESS, the // U.S. Government retains certain rights in this software. // // Pressio is licensed under BSD-3-Clause terms of use: // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE // COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING // IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // Questions? Contact Francesco Rizzi (fnrizzi@sandia.gov) // // ************************************************************************ //@HEADER */ #ifndef ROM_LSPG_IMPL_STEADY_ROM_COMPOSE_STEADY_LSPG_IMPL_HPP_ #define ROM_LSPG_IMPL_STEADY_ROM_COMPOSE_STEADY_LSPG_IMPL_HPP_ #include "../rom_problem_tags.hpp" #include "./policies/rom_lspg_steady_residual_policy.hpp" #include "./policies/rom_lspg_steady_jacobian_policy.hpp" #include "rom_lspg_steady_system.hpp" #include "./traits/rom_lspg_steady_common_traits.hpp" #include "./traits/rom_lspg_steady_default_problem_traits.hpp" #include "./traits/rom_lspg_steady_preconditioned_problem_traits.hpp" #include "./traits/rom_lspg_steady_masked_problem_traits.hpp" #include "./traits/rom_lspg_steady_hyper_reduced_problem_traits.hpp" #include "./traits/rom_lspg_steady_preconditioned_hyper_reduced_problem_traits.hpp" #include "./rom_lspg_steady_default_problem.hpp" #include "./rom_lspg_steady_preconditioned_problem.hpp" #include "./rom_lspg_steady_masked_problem.hpp" #include "./rom_lspg_steady_hyper_reduced_problem.hpp" #include "./rom_lspg_steady_preconditioned_hyper_reduced_problem.hpp" namespace pressio{ namespace rom{ namespace lspg{ namespace impl{ template< class problem_tag, class enable, class fom_system_type, class decoder_type, class ...Args > struct composeSteady { //if we are here, something is wrong, find out what static_assert (::pressio::rom::why_not_steady_system_with_user_provided_apply_jacobian <fom_system_type, typename decoder_type::jacobian_type >::value, ""); using type = void; }; //------------------------ // specialize compose //------------------------ // default template< typename fom_system_type, typename decoder_type, typename lspg_state_type > struct composeSteady< ::pressio::rom::lspg::impl::Default, mpl::enable_if_t< ::pressio::rom::constraints::steady_system_with_user_provided_apply_jacobian< fom_system_type, typename decoder_type::jacobian_type>::value >, fom_system_type, decoder_type, lspg_state_type> { using type = ::pressio::rom::lspg::impl::steady::DefaultProblemSteady< fom_system_type, lspg_state_type, decoder_type>; }; // preconditioned default template< typename fom_system_type, typename decoder_type, typename lspg_state_type, typename precond_type > struct composeSteady< ::pressio::rom::lspg::impl::Preconditioned, mpl::enable_if_t< ::pressio::rom::constraints::steady_system_with_user_provided_apply_jacobian< fom_system_type, typename decoder_type::jacobian_type>::value >, fom_system_type, decoder_type, lspg_state_type, precond_type> { using type = ::pressio::rom::lspg::impl::steady::PreconditionedProblemSteady< fom_system_type, lspg_state_type, decoder_type, precond_type>; }; // masked template< typename fom_system_type, typename decoder_type, typename lspg_state_type, typename masker_type > struct composeSteady< ::pressio::rom::lspg::impl::Masked, mpl::enable_if_t< ::pressio::rom::constraints::steady_system_with_user_provided_apply_jacobian< fom_system_type, typename decoder_type::jacobian_type>::value >, fom_system_type, decoder_type, lspg_state_type, masker_type> { using type = ::pressio::rom::lspg::impl::steady::MaskedProblemSteady< fom_system_type, lspg_state_type, decoder_type, masker_type>; }; // hyper-reduced template< typename fom_system_type, typename decoder_type, typename lspg_state_type > struct composeSteady< ::pressio::rom::lspg::impl::HyperReduced, mpl::enable_if_t< ::pressio::rom::constraints::steady_system_with_user_provided_apply_jacobian< fom_system_type, typename decoder_type::jacobian_type>::value >, fom_system_type, decoder_type, lspg_state_type > { using type = ::pressio::rom::lspg::impl::steady::HyperReducedProblemSteady< fom_system_type, lspg_state_type, decoder_type>; }; // preconditioned hyper-reduced template< typename fom_system_type, typename decoder_type, typename lspg_state_type, typename precond_type > struct composeSteady< ::pressio::rom::lspg::impl::PreconditionedHyperReduced, mpl::enable_if_t< ::pressio::rom::constraints::steady_system_with_user_provided_apply_jacobian< fom_system_type, typename decoder_type::jacobian_type>::value >, fom_system_type, decoder_type, lspg_state_type, precond_type> { using type = ::pressio::rom::lspg::impl::steady::PreconditionedHyperReducedProblemSteady< fom_system_type, lspg_state_type, decoder_type, precond_type>; }; }}}} #endif // ROM_LSPG_IMPL_STEADY_ROM_COMPOSE_STEADY_LSPG_IMPL_HPP_
34.4375
91
0.748941
fnrizzi
74a9c4d6778e05abad93ba69a0dcdda1da4d528d
3,654
cpp
C++
UnitTests/TestGameEventHandler/testgameeventhandler.cpp
Moppa5/pirkanmaan-valloitus
725dd1a9ef29dcd314faa179124541618dc8e5bf
[ "MIT" ]
3
2020-10-30T13:26:34.000Z
2020-12-08T13:21:34.000Z
UnitTests/TestGameEventHandler/testgameeventhandler.cpp
Moppa5/pirkanmaan-valloitus
725dd1a9ef29dcd314faa179124541618dc8e5bf
[ "MIT" ]
15
2020-12-10T18:13:20.000Z
2021-06-08T10:37:51.000Z
UnitTests/TestGameEventHandler/testgameeventhandler.cpp
Moppa5/pirkanmaan-valloitus
725dd1a9ef29dcd314faa179124541618dc8e5bf
[ "MIT" ]
null
null
null
#include <QString> #include <QtTest> #include <interfaces/gameeventhandler.hh> #include "core/player.hh" using namespace Game; /** * @brief The TestGameEventHandler class is for unit testing * GameEventHandler class. It tests that the methods work properly * under valid conditions. */ class TestGameEventHandler : public QObject { Q_OBJECT public: /** * @brief Creates the GameEventHandler to be tested */ TestGameEventHandler(); private: GameEventHandler* geHandler; const Course::ResourceMap RM1{ {WOOD, 10}, {FOOD, 20}, {STONE, 30}, {ORE, 40}, {MONEY, 50} }; const Course::ResourceMap RMEmpty{ }; private Q_SLOTS: /** * @brief Tests modifyResources if it's successful * RM1 resourcemap with parameter false so no changes * RM1 with parameter true so resources change * Empty resourcemap does nothing */ void testModifyResources(); /** * @brief Tests modifyResource if it's succesful * False case should not make any changes * True case with negative result => no changes * True case with valid result => changes made */ void testModifyResource(); /** * @brief Tests if the resourcemap to be applied for a player is * valid. No negative resources allowed to be changed */ void testValidResourceMap(); }; TestGameEventHandler::TestGameEventHandler() { geHandler = new GameEventHandler(); } void TestGameEventHandler::testModifyResources() { std::vector<std::shared_ptr<Player>> players; std::shared_ptr<Player> player = std::make_shared<Player>("name"); players.push_back(player); geHandler->setPlayers(players); // Should not apply change ResourceMap oldResources = *(player->getResourceMap()); geHandler->modifyResources(player, RM1, false); QVERIFY(*(player->getResourceMap()) == oldResources); // Should apply change geHandler->modifyResources(player, RM1, true); QVERIFY(*(player->getResourceMap()) == RM1); // Applying empty should not change resources geHandler->modifyResources(player, RMEmpty, true); QVERIFY(*(player->getResourceMap()) == RM1); } void TestGameEventHandler::testModifyResource() { std::vector<std::shared_ptr<Player>> players; std::shared_ptr<Player> player = std::make_shared<Player>("name"); players.push_back(player); geHandler->setPlayers(players); // Should not apply change ResourceMap oldResources = *(player->getResourceMap()); geHandler->modifyResource(player, WOOD, 0, false); QVERIFY(*(player->getResourceMap()) == oldResources); geHandler->modifyResource(player, WOOD, 20, false); QVERIFY(*(player->getResourceMap()) == oldResources); // Should apply change if valid geHandler->modifyResource(player, WOOD, -100, true); QVERIFY(*(player->getResourceMap()) == oldResources); geHandler->modifyResource(player, WOOD, 1.5, true); QVERIFY((*(player->getResourceMap()))[WOOD] == 1); } void TestGameEventHandler::testValidResourceMap() { std::vector<std::shared_ptr<Player>> players; std::shared_ptr<Player> player = std::make_shared<Player>("name"); players.push_back(player); geHandler->setPlayers(players); QVERIFY(geHandler->modifyResource(player, WOOD, 0, false) == true); QVERIFY(geHandler->modifyResource(player, WOOD, 20, false) == true); QVERIFY(geHandler->modifyResource(player, WOOD, -100, true) == false); QVERIFY(geHandler->modifyResource(player, WOOD, 1.5, true) == true); } QTEST_APPLESS_MAIN(TestGameEventHandler) #include "testgameeventhandler.moc"
28.546875
74
0.684729
Moppa5
74ad20acebdfb2edc5e92b64d849d2a69949196f
2,947
cpp
C++
tests/tagwriter.cpp
dda119141/mp3tags
c75818e4fd6341f2c0c0b482f5c6eb1809b382aa
[ "MIT" ]
1
2020-08-01T21:51:05.000Z
2020-08-01T21:51:05.000Z
tests/tagwriter.cpp
dda119141/mp3tags
c75818e4fd6341f2c0c0b482f5c6eb1809b382aa
[ "MIT" ]
1
2020-05-01T11:52:59.000Z
2020-05-01T11:52:59.000Z
tests/tagwriter.cpp
dda119141/mp3tags
c75818e4fd6341f2c0c0b482f5c6eb1809b382aa
[ "MIT" ]
null
null
null
// Copyright(c) 2020-present, Moge & contributors. // Email: dda119141@gmail.com // Distributed under the MIT License (http://opensource.org/licenses/MIT) #include <iostream> #include <memory> #define CATCH_CONFIG_MAIN #include <catch.hpp> #include "tagreader.hpp" #include "tagwriter.hpp" TEST_CASE("Read/Write from/to id3v2 tag") { namespace fs = id3::filesystem; using std::cout; using std::endl; std::string filename; #ifdef HAS_FS_EXPERIMENTAL const std::string currentFilePath = fs::system_complete(__FILE__); #else const std::string currentFilePath = fs::absolute(__FILE__).string(); #endif cout << "current file path:" << currentFilePath << endl; const std::string mp3Path = (fs::path(currentFilePath).parent_path() /= "../files").string(); const auto findFileName = [&](const std::string& filName){ const auto pos = filName.find_last_of('/'); return filName.substr(pos+1); }; try { for (auto& filen : fs::directory_iterator(mp3Path)) { std::string _filename = filen.path().string(); if (findFileName(_filename) == std::string("test1.mp3")) { filename = _filename; } /* else if (_filename.find("test1.mp3") != std::string::npos) { filename = _filename; } */ } } catch (fs::filesystem_error& e) { cout << "wrong path:" << e.what() << endl; } SECTION("test path") { REQUIRE(filename == (fs::path(mp3Path) /= "test1.mp3").string()); } // cout << "File type: " << GetFileType(filename) << endl; // cout << "Group Description: " << GetContentGroupDescription(filename) // << endl; // cout << "GetTrackPosition: " << GetTrackPosition(filename) << endl; /* SECTION("Test writing album name: test2"){ REQUIRE(SetAlbum(filename, "test1") == 1); } */ SECTION("Test writing album") { REQUIRE(SetAlbum(filename, "AlbYingAlbum") == 1); } SECTION("Test writing title") { REQUIRE(SetTitle(filename, "testYingYangTitle") == 1); } SECTION("Test writing artist") { REQUIRE(SetLeadArtist(filename, "TitTestYingArtist") == 1); } SECTION("Test reading back album") { REQUIRE(GetAlbum(filename) == "AlbYingAlbum"); } SECTION("Test reading back title") { REQUIRE(GetTitle(filename) == "testYingYangTitle"); } SECTION("Test reading back artist") { REQUIRE(GetLeadArtist(filename) == "TitTestYingArtist"); } SECTION("Test reading Year") { REQUIRE(GetYear(filename) == "2009"); } SECTION("Test reading Content type") { REQUIRE(GetContentType(filename) == "Rap"); } SECTION("Test reading track position") { REQUIRE(GetTrackPosition(filename) == "05/18"); } SECTION("Test reading band orchestra") { REQUIRE(GetBandOrchestra(filename) == "Ying Yang Twins"); } }
30.697917
79
0.608755
dda119141
74ae7a99bdc0e9f5314ab89af36d7eee13582383
12,869
cpp
C++
framework/unitest/core/test_process_profiler.cpp
HFauto/CNStream
1d4847327fff83eedbc8de6911855c5f7bb2bf22
[ "Apache-2.0" ]
172
2019-08-24T10:05:14.000Z
2022-03-29T07:45:18.000Z
framework/unitest/core/test_process_profiler.cpp
HFauto/CNStream
1d4847327fff83eedbc8de6911855c5f7bb2bf22
[ "Apache-2.0" ]
27
2019-09-01T11:04:45.000Z
2022-01-17T09:27:07.000Z
framework/unitest/core/test_process_profiler.cpp
HFauto/CNStream
1d4847327fff83eedbc8de6911855c5f7bb2bf22
[ "Apache-2.0" ]
72
2019-08-24T10:13:06.000Z
2022-03-28T08:26:05.000Z
/************************************************************************* * Copyright (C) [2019] by Cambricon, Inc. 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 * * 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 <gtest/gtest.h> #include <string> #include <utility> #include "profiler/process_profiler.hpp" namespace cnstream { TEST(CoreProcessProfiler, GetName) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); EXPECT_EQ(profiler_name, profiler.GetName()); } TEST(CoreProcessProfiler, SetModuleName) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); const std::string module_name = "module"; profiler.SetModuleName(module_name).SetTraceLevel(TraceEvent::Level::MODULE); profiler.RecordStart(std::make_pair("stream0", 100)); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); EXPECT_NE(trace.module_traces.find(module_name), trace.module_traces.end()); EXPECT_EQ(trace.module_traces[module_name].size(), 1); EXPECT_NE(trace.module_traces[module_name].find(profiler_name), trace.module_traces[module_name].end()); EXPECT_EQ(trace.module_traces[module_name][profiler_name].size(), 1); } TEST(CoreProcessProfiler, SetTraceLevel) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); const std::string module_name = "module"; profiler.SetModuleName(module_name).SetTraceLevel(TraceEvent::Level::PIPELINE); profiler.RecordStart(std::make_pair("stream0", 100)); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); EXPECT_EQ(trace.module_traces.find(module_name), trace.module_traces.end()); EXPECT_NE(trace.process_traces.find(profiler_name), trace.process_traces.end()); EXPECT_EQ(trace.process_traces[profiler_name].size(), 1); } TEST(CoreProcessProfiler, RecordStartModule) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); const std::string module_name = "module"; profiler.SetModuleName(module_name).SetTraceLevel(TraceEvent::Level::MODULE); RecordKey key = std::make_pair("stream0", 100); profiler.RecordStart(key); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); EXPECT_NE(trace.module_traces.find(module_name), trace.module_traces.end()); EXPECT_EQ(trace.module_traces[module_name].size(), 1); EXPECT_NE(trace.module_traces[module_name].find(profiler_name), trace.module_traces[module_name].end()); EXPECT_EQ(trace.module_traces[module_name][profiler_name].size(), 1); TraceElem elem = trace.module_traces[module_name][profiler_name][0]; EXPECT_EQ(elem.type, TraceEvent::Type::START); EXPECT_EQ(elem.key, key); } TEST(CoreProcessProfiler, RecordEndModule) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); const std::string module_name = "module"; profiler.SetModuleName(module_name).SetTraceLevel(TraceEvent::Level::MODULE); RecordKey key = std::make_pair("stream0", 100); profiler.RecordEnd(key); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); ASSERT_NE(trace.module_traces.find(module_name), trace.module_traces.end()); ASSERT_EQ(trace.module_traces[module_name].size(), 1); ASSERT_NE(trace.module_traces[module_name].find(profiler_name), trace.module_traces[module_name].end()); ASSERT_EQ(trace.module_traces[module_name][profiler_name].size(), 1); TraceElem elem = trace.module_traces[module_name][profiler_name][0]; EXPECT_EQ(elem.type, TraceEvent::Type::END); EXPECT_EQ(elem.key, key); } TEST(CoreProcessProfiler, RecordStartPipeline) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); RecordKey key = std::make_pair("stream0", 100); profiler.RecordStart(key); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); ASSERT_NE(trace.process_traces.find(profiler_name), trace.process_traces.end()); ASSERT_EQ(trace.process_traces[profiler_name].size(), 1); TraceElem elem = trace.process_traces[profiler_name][0]; EXPECT_EQ(elem.type, TraceEvent::Type::START); EXPECT_EQ(elem.key, key); } TEST(CoreProcessProfiler, RecordEndPipeline) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); RecordKey key = std::make_pair("stream0", 100); profiler.RecordEnd(key); PipelineTrace trace = tracer.GetTrace(Time::min(), Time::max()); ASSERT_NE(trace.process_traces.find(profiler_name), trace.process_traces.end()); ASSERT_EQ(trace.process_traces[profiler_name].size(), 1); TraceElem elem = trace.process_traces[profiler_name][0]; EXPECT_EQ(elem.type, TraceEvent::Type::END); EXPECT_EQ(elem.key, key); } TEST(CoreProcessProfiler, RecordEndRecordEnd) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; RecordKey key = std::make_pair("stream0", 100); profiler.RecordEnd(key); profiler.RecordEnd(key); ProcessProfile profile = profiler.GetProfile(); EXPECT_EQ(profile.completed, 2); } TEST(CoreProcessProfiler, DropData) { static constexpr uint64_t kDEFAULT_MAX_DPB_SIZE = 16; PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; uint64_t dropped = 2; uint64_t ts = 0; for (; ts < dropped; ++ts) { RecordKey key = std::make_pair(stream_name, ts); profiler.RecordStart(key); } for (; ts < kDEFAULT_MAX_DPB_SIZE + dropped + 1; ++ts) { RecordKey key = std::make_pair(stream_name, ts); profiler.RecordStart(key); profiler.RecordEnd(key); } ProcessProfile profile = profiler.GetProfile(); EXPECT_EQ(profile.dropped, dropped); EXPECT_EQ(profile.completed, kDEFAULT_MAX_DPB_SIZE + 1); EXPECT_EQ(profile.ongoing, 0); EXPECT_EQ(profile.stream_profiles.size(), 1); EXPECT_EQ(profile.stream_profiles[0].stream_name, stream_name); EXPECT_EQ(profile.stream_profiles[0].dropped, dropped); EXPECT_EQ(profile.stream_profiles[0].completed, kDEFAULT_MAX_DPB_SIZE + 1); } TEST(CoreProcessProfiler, GetProfile0) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; RecordKey key = std::make_pair("stream0", 100); profiler.RecordEnd(key); ProcessProfile profile = profiler.GetProfile(); EXPECT_EQ(profile.dropped, 0); EXPECT_EQ(profile.completed, 1); EXPECT_EQ(profile.ongoing, 0); EXPECT_EQ(profile.stream_profiles.size(), 1); EXPECT_EQ(profile.stream_profiles[0].completed, 1); EXPECT_EQ(profile.stream_profiles[0].dropped, 0); } TEST(CoreProcessProfiler, GetProfile1) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; RecordKey key1 = std::make_pair(stream_name, 100); RecordKey key2 = std::make_pair(stream_name, 200); ProcessTrace trace; TraceElem elem_start1; elem_start1.key = key1; elem_start1.time = Time(std::chrono::duration_cast<Time::duration>(std::chrono::duration<double, std::milli>(50))); elem_start1.type = TraceEvent::Type::START; TraceElem elem_start2; elem_start2.key = key2; elem_start2.time = Time(std::chrono::duration_cast<Time::duration>(std::chrono::duration<double, std::milli>(100))); elem_start2.type = TraceEvent::Type::START; TraceElem elem_end1; elem_end1.key = key1; elem_end1.time = Time(std::chrono::duration_cast<Time::duration>(std::chrono::duration<double, std::milli>(200))); elem_end1.type = TraceEvent::Type::END; TraceElem elem_end2; elem_end2.key = key2; elem_end2.time = Time(std::chrono::duration_cast<Time::duration>(std::chrono::duration<double, std::milli>(300))); elem_end2.type = TraceEvent::Type::END; trace.push_back(elem_start1); trace.push_back(elem_start2); trace.push_back(elem_end1); trace.push_back(elem_end2); ProcessProfile profile = profiler.GetProfile(trace); EXPECT_EQ(profile.completed, 2); EXPECT_EQ(profile.fps, 1e3 / 250 * 2); EXPECT_EQ(profile.dropped, 0); EXPECT_EQ(profile.latency, 175); EXPECT_EQ(profile.minimum_latency, 150); EXPECT_EQ(profile.maximum_latency, 200); EXPECT_EQ(profile.ongoing, 0); EXPECT_EQ(profile.process_name, profiler_name); EXPECT_EQ(profile.stream_profiles.size(), 1); EXPECT_EQ(profile.stream_profiles[0].stream_name, stream_name); EXPECT_EQ(profile.stream_profiles[0].completed, 2); EXPECT_EQ(profile.stream_profiles[0].dropped, 0); EXPECT_EQ(profile.stream_profiles[0].fps, 1e3 / 250 * 2); EXPECT_EQ(profile.stream_profiles[0].minimum_latency, 150); EXPECT_EQ(profile.stream_profiles[0].maximum_latency, 200); } TEST(CoreProcessProfiler, OnStreamEos) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; RecordKey key = std::make_pair(stream_name, 100); profiler.RecordStart(key); profiler.RecordEnd(key); EXPECT_EQ(profiler.GetProfile().stream_profiles.size(), 1); profiler.OnStreamEos(stream_name); EXPECT_EQ(profiler.GetProfile().stream_profiles.size(), 0); } TEST(CoreProcessProfiler, OnStreamEosBorderCase) { PipelineTracer tracer; ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, &tracer); profiler.SetTraceLevel(TraceEvent::Level::PIPELINE); const std::string stream_name = "stream0"; EXPECT_EQ(profiler.GetProfile().stream_profiles.size(), 0); profiler.OnStreamEos(stream_name); EXPECT_EQ(profiler.GetProfile().stream_profiles.size(), 0); } TEST(CoreProcessProfiler, NullTracer) { ProfilerConfig config; config.enable_profiling = true; config.enable_tracing = true; const std::string profiler_name = "profiler"; ProcessProfiler profiler(config, profiler_name, nullptr); RecordKey key = std::make_pair("stream0", 100); profiler.RecordStart(key); } } // namespace cnstream
40.090343
118
0.749165
HFauto
74b5804be34a50f3fd7032bf5d3f30c5d7c250be
7,178
cpp
C++
ares/component/processor/tlcs900h/registers.cpp
moon-chilled/Ares
909fb098c292f8336d0502dc677050312d8b5c81
[ "0BSD" ]
7
2020-07-25T11:44:39.000Z
2021-01-29T13:21:31.000Z
ares/component/processor/tlcs900h/registers.cpp
jchw-forks/ares
d78298a1e95fd0ce65feabfd4f13b60e31210a7a
[ "0BSD" ]
null
null
null
ares/component/processor/tlcs900h/registers.cpp
jchw-forks/ares
d78298a1e95fd0ce65feabfd4f13b60e31210a7a
[ "0BSD" ]
1
2021-03-22T16:15:30.000Z
2021-03-22T16:15:30.000Z
#define a RFP #define p RFP - 1 & 3 template<> auto TLCS900H::map(Register<uint8> register) const -> maybe<uint8&> { switch(register.id) { #define r(id, name) case id: return r.name; r(0x00, xwa[0].b.b0) r(0x01, xwa[0].b.b1) r(0x02, xwa[0].b.b2) r(0x03, xwa[0].b.b3) r(0x04, xbc[0].b.b0) r(0x05, xbc[0].b.b1) r(0x06, xbc[0].b.b2) r(0x07, xbc[0].b.b3) r(0x08, xde[0].b.b0) r(0x09, xde[0].b.b1) r(0x0a, xde[0].b.b2) r(0x0b, xde[0].b.b3) r(0x0c, xhl[0].b.b0) r(0x0d, xhl[0].b.b1) r(0x0e, xhl[0].b.b2) r(0x0f, xhl[0].b.b3) r(0x10, xwa[1].b.b0) r(0x11, xwa[1].b.b1) r(0x12, xwa[1].b.b2) r(0x13, xwa[1].b.b3) r(0x14, xbc[1].b.b0) r(0x15, xbc[1].b.b1) r(0x16, xbc[1].b.b2) r(0x17, xbc[1].b.b3) r(0x18, xde[1].b.b0) r(0x19, xde[1].b.b1) r(0x1a, xde[1].b.b2) r(0x1b, xde[1].b.b3) r(0x1c, xhl[1].b.b0) r(0x1d, xhl[1].b.b1) r(0x1e, xhl[1].b.b2) r(0x1f, xhl[1].b.b3) r(0x20, xwa[2].b.b0) r(0x21, xwa[2].b.b1) r(0x22, xwa[2].b.b2) r(0x23, xwa[2].b.b3) r(0x24, xbc[2].b.b0) r(0x25, xbc[2].b.b1) r(0x26, xbc[2].b.b2) r(0x27, xbc[2].b.b3) r(0x28, xde[2].b.b0) r(0x29, xde[2].b.b1) r(0x2a, xde[2].b.b2) r(0x2b, xde[2].b.b3) r(0x2c, xhl[2].b.b0) r(0x2d, xhl[2].b.b1) r(0x2e, xhl[2].b.b2) r(0x2f, xhl[2].b.b3) r(0x30, xwa[3].b.b0) r(0x31, xwa[3].b.b1) r(0x32, xwa[3].b.b2) r(0x33, xwa[3].b.b3) r(0x34, xbc[3].b.b0) r(0x35, xbc[3].b.b1) r(0x36, xbc[3].b.b2) r(0x37, xbc[3].b.b3) r(0x38, xde[3].b.b0) r(0x39, xde[3].b.b1) r(0x3a, xde[3].b.b2) r(0x3b, xde[3].b.b3) r(0x3c, xhl[3].b.b0) r(0x3d, xhl[3].b.b1) r(0x3e, xhl[3].b.b2) r(0x3f, xhl[3].b.b3) r(0xd0, xwa[p].b.b0) r(0xd1, xwa[p].b.b1) r(0xd2, xwa[p].b.b2) r(0xd3, xwa[p].b.b3) r(0xd4, xbc[p].b.b0) r(0xd5, xbc[p].b.b1) r(0xd6, xbc[p].b.b2) r(0xd7, xbc[p].b.b3) r(0xd8, xde[p].b.b0) r(0xd9, xde[p].b.b1) r(0xda, xde[p].b.b2) r(0xdb, xde[p].b.b3) r(0xdc, xhl[p].b.b0) r(0xdd, xhl[p].b.b1) r(0xde, xhl[p].b.b2) r(0xdf, xhl[p].b.b3) r(0xe0, xwa[a].b.b0) r(0xe1, xwa[a].b.b1) r(0xe2, xwa[a].b.b2) r(0xe3, xwa[a].b.b3) r(0xe4, xbc[a].b.b0) r(0xe5, xbc[a].b.b1) r(0xe6, xbc[a].b.b2) r(0xe7, xbc[a].b.b3) r(0xe8, xde[a].b.b0) r(0xe9, xde[a].b.b1) r(0xea, xde[a].b.b2) r(0xeb, xde[a].b.b3) r(0xec, xhl[a].b.b0) r(0xed, xhl[a].b.b1) r(0xee, xhl[a].b.b2) r(0xef, xhl[a].b.b3) r(0xf0, xix .b.b0) r(0xf1, xix .b.b1) r(0xf2, xix .b.b2) r(0xf3, xix .b.b3) r(0xf4, xiy .b.b0) r(0xf5, xiy .b.b1) r(0xf6, xiy .b.b2) r(0xf7, xiy .b.b3) r(0xf8, xiz .b.b0) r(0xf9, xiz .b.b1) r(0xfa, xiz .b.b2) r(0xfb, xiz .b.b3) r(0xfc, xsp .b.b0) r(0xfd, xsp .b.b1) r(0xfe, xsp .b.b2) r(0xff, xsp .b.b3) #undef r } return nothing; } template<> auto TLCS900H::map(Register<uint16> register) const -> maybe<uint16&> { switch(register.id & ~1) { #define r(id, name) case id: return r.name; r(0x00, xwa[0].w.w0) r(0x02, xwa[0].w.w1) r(0x04, xbc[0].w.w0) r(0x06, xbc[0].w.w1) r(0x08, xde[0].w.w0) r(0x0a, xde[0].w.w1) r(0x0c, xhl[0].w.w0) r(0x0e, xhl[0].w.w1) r(0x10, xwa[1].w.w0) r(0x12, xwa[1].w.w1) r(0x14, xbc[1].w.w0) r(0x16, xbc[1].w.w1) r(0x18, xde[1].w.w0) r(0x1a, xde[1].w.w1) r(0x1c, xhl[1].w.w0) r(0x1e, xhl[1].w.w1) r(0x20, xwa[2].w.w0) r(0x22, xwa[2].w.w1) r(0x24, xbc[2].w.w0) r(0x26, xbc[2].w.w1) r(0x28, xde[2].w.w0) r(0x2a, xde[2].w.w1) r(0x2c, xhl[2].w.w0) r(0x2e, xhl[2].w.w1) r(0x30, xwa[3].w.w0) r(0x32, xwa[3].w.w1) r(0x34, xbc[3].w.w0) r(0x36, xbc[3].w.w1) r(0x38, xde[3].w.w0) r(0x3a, xde[3].w.w1) r(0x3c, xhl[3].w.w0) r(0x3e, xhl[3].w.w1) r(0xd0, xwa[p].w.w0) r(0xd2, xwa[p].w.w1) r(0xd4, xbc[p].w.w0) r(0xd6, xbc[p].w.w1) r(0xd8, xde[p].w.w0) r(0xda, xde[p].w.w1) r(0xdc, xhl[p].w.w0) r(0xde, xhl[p].w.w1) r(0xe0, xwa[a].w.w0) r(0xe2, xwa[a].w.w1) r(0xe4, xbc[a].w.w0) r(0xe6, xbc[a].w.w1) r(0xe8, xde[a].w.w0) r(0xea, xde[a].w.w1) r(0xec, xhl[a].w.w0) r(0xee, xhl[a].w.w1) r(0xf0, xix .w.w0) r(0xf2, xix .w.w1) r(0xf4, xiy .w.w0) r(0xf6, xiy .w.w1) r(0xf8, xiz .w.w0) r(0xfa, xiz .w.w1) r(0xfc, xsp .w.w0) r(0xfe, xsp .w.w1) #undef r } return nothing; } template<> auto TLCS900H::map(Register<uint32> register) const -> maybe<uint32&> { switch(register.id & ~3) { #define r(id, name) case id: return r.name; r(0x00, xwa[0].l.l0) r(0x04, xbc[0].l.l0) r(0x08, xde[0].l.l0) r(0x0c, xhl[0].l.l0) r(0x10, xwa[1].l.l0) r(0x14, xbc[1].l.l0) r(0x18, xde[1].l.l0) r(0x1c, xhl[1].l.l0) r(0x20, xwa[2].l.l0) r(0x24, xbc[2].l.l0) r(0x28, xde[2].l.l0) r(0x2c, xhl[2].l.l0) r(0x30, xwa[3].l.l0) r(0x34, xbc[3].l.l0) r(0x38, xde[3].l.l0) r(0x3c, xhl[3].l.l0) r(0xd0, xwa[p].l.l0) r(0xd4, xbc[p].l.l0) r(0xd8, xde[p].l.l0) r(0xdc, xhl[p].l.l0) r(0xe0, xwa[a].l.l0) r(0xe4, xbc[a].l.l0) r(0xe8, xde[a].l.l0) r(0xec, xhl[a].l.l0) r(0xf0, xix .l.l0) r(0xf4, xiy .l.l0) r(0xf8, xiz .l.l0) r(0xfc, xsp .l.l0) #undef r } return nothing; } #undef a #undef p template<> auto TLCS900H::load< uint8>(Register< uint8> register) const -> uint8 { return map(register)(Undefined); } template<> auto TLCS900H::load<uint16>(Register<uint16> register) const -> uint16 { return map(register)(Undefined); } template<> auto TLCS900H::load<uint32>(Register<uint32> register) const -> uint32 { return map(register)(Undefined); } template<> auto TLCS900H::store< uint8>(Register< uint8> register, uint32 data) -> void { if(auto r = map(register)) r() = data; } template<> auto TLCS900H::store<uint16>(Register<uint16> register, uint32 data) -> void { if(auto r = map(register)) r() = data; } template<> auto TLCS900H::store<uint32>(Register<uint32> register, uint32 data) -> void { if(auto r = map(register)) r() = data; } auto TLCS900H::expand(Register< uint8> register) const -> Register<uint16> { return {register.id & ~1}; } auto TLCS900H::expand(Register<uint16> register) const -> Register<uint32> { return {register.id & ~3}; } auto TLCS900H::shrink(Register<uint32> register) const -> Register<uint16> { return {register.id}; } auto TLCS900H::shrink(Register<uint16> register) const -> Register< uint8> { return {register.id}; } auto TLCS900H::load(FlagRegister f) const -> uint8 { switch(f.id) { case 0: return r.c << 0 | r.n << 1 | r.v << 2 | r.h << 4 | r.z << 6 | r.s << 7; case 1: return r.cp << 0 | r.np << 1 | r.vp << 2 | r.hp << 4 | r.zp << 6 | r.sp << 7; } unreachable; } auto TLCS900H::store(FlagRegister f, uint8 data) -> void { switch(f.id) { case 0: r.c = data.bit(0); r.n = data.bit(1); r.v = data.bit(2); r.h = data.bit(4); r.z = data.bit(6); r.s = data.bit(7); return; case 1: r.cp = data.bit(0); r.np = data.bit(1); r.vp = data.bit(2); r.hp = data.bit(4); r.zp = data.bit(6); r.sp = data.bit(7); return; } unreachable; } auto TLCS900H::load(StatusRegister) const -> uint16 { //900/H: d10 = RFP2 (always 0); d11 = MAX (always 1); d15 = SYSM (always 1) return load(F) | r.rfp << 8 | 0 << 10 | 1 << 11 | r.iff << 12 | 1 << 15; } auto TLCS900H::store(StatusRegister, uint16 data) -> void { store(F, data.bit(0,7)); r.rfp = data.bit(8,9); r.iff = data.bit(12,14); } auto TLCS900H::load(ProgramCounter) const -> uint32 { return r.pc.l.l0; } auto TLCS900H::store(ProgramCounter, uint32 data) -> void { r.pc.l.l0 = data; invalidate(); }
56.519685
137
0.588604
moon-chilled
74c369ddc7b5d7bf8c7f8930f9f06e47dd89ba17
3,446
cpp
C++
CoreTests/STL/Test_Types_FileAddress.cpp
azhirnov/GraphicsGenFramework-modular
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
12
2017-12-23T14:24:57.000Z
2020-10-02T19:52:12.000Z
CoreTests/STL/Test_Types_FileAddress.cpp
azhirnov/ModularGraphicsFramework
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
null
null
null
CoreTests/STL/Test_Types_FileAddress.cpp
azhirnov/ModularGraphicsFramework
348be601f1991f102defa0c99250529f5e44c4d3
[ "BSD-2-Clause" ]
null
null
null
// Copyright (c) Zhirnov Andrey. For more information see 'LICENSE.txt' #include "CoreTests/STL/Common.h" using namespace GX_STL; using namespace GX_STL::GXTypes; using namespace GX_STL::GXMath; extern void Test_Types_FileAddress () { const String filename = "../11/../22/33\\44\\55.ab"; const String ext = FileAddress::GetExtension( filename ); TEST( ext == "ab" ); const String name = FileAddress::GetName( filename ); TEST( name == "55" ); const String path = FileAddress::GetPath( filename ); TEST( path == "../11/../22/33\\44" ); const String name_ext = FileAddress::GetNameAndExt( filename ); TEST( name_ext == "55.ab" ); const String ext1 = FileAddress::GetExtensions( "aa/bb.c.d" ); TEST( ext1 == "c.d" ); const String ext2 = FileAddress::GetExtensions( "bb.cx.d" ); TEST( ext2 == "cx.d" ); const String ext3 = FileAddress::GetExtension( "aabb" ); TEST( ext3 == "" ); const String ext4 = FileAddress::GetExtensions( "aabb" ); TEST( ext4 == "" ); const String ext5 = FileAddress::GetExtension( "." ); TEST( ext5 == "" ); const String ext6 = FileAddress::GetExtensions( "." ); TEST( ext6 == "" ); Array<StringCRef> path_arr; FileAddress::DividePath( filename, path_arr ); TEST( path_arr.Count() == 7 ); TEST( path_arr[0] == ".." ); TEST( path_arr[1] == "11" ); TEST( path_arr[2] == ".." ); TEST( path_arr[3] == "22" ); TEST( path_arr[4] == "33" ); TEST( path_arr[5] == "44" ); TEST( path_arr[6] == "55.ab" ); String without_name = filename; FileAddress::RemoveName( INOUT without_name ); TEST( without_name == "../11/../22/33\\44" ); String without_ext = filename; FileAddress::RemoveExtension( INOUT without_ext ); TEST( without_ext == "../11/../22/33\\44\\55" ); String formated = filename; FileAddress::FormatPath( INOUT formated ); TEST( formated == "../22/33/44/55.ab" ); formated = "aa/bb/../../../aa/bb/cc/dd"; FileAddress::FormatPath( INOUT formated ); TEST( formated == "../aa/bb/cc/dd" ); String left = filename; FileAddress::RemoveDirectoriesFromLeft( INOUT left, 2 ); TEST( left == "../11" ); String right = filename; FileAddress::RemoveDirectoriesFromRight( INOUT right, 2 ); TEST( right == "../11/../22/33" ); String dir_path = "path"; FileAddress::AddDirectoryToPath( INOUT dir_path, "dir" ); TEST( dir_path == "path/dir" ); dir_path = "/path/"; FileAddress::AddDirectoryToPath( INOUT dir_path, "/dir1/" ); FileAddress::AddDirectoryToPath( INOUT dir_path, "/dir2/" ); TEST( dir_path == "/path/dir1/dir2/" ); dir_path = "path"; FileAddress::AddBaseDirectoryToPath( INOUT dir_path, "dir" ); TEST( dir_path == "dir/path" ); dir_path = "/path/"; FileAddress::AddBaseDirectoryToPath( INOUT dir_path, "/dir1/" ); FileAddress::AddBaseDirectoryToPath( INOUT dir_path, "/dir2/" ); TEST( dir_path == "/dir2/dir1/path/" ); String name1 = name; FileAddress::AddExtensionToName( INOUT name1, ".ext" ); TEST( name1 == name + ".ext" ); name1 = name + "."; FileAddress::AddExtensionToName( INOUT name1, ".ext" ); TEST( name1 == name + ".ext" ); name1 = name; FileAddress::AddExtensionToName( INOUT name1, "ext" ); TEST( name1 == name + ".ext" ); name1 = name + "."; FileAddress::AddExtensionToName( INOUT name1, "ext" ); TEST( name1 == name + ".ext" ); String name2 = FileAddress::GetName( "../out/common" ); TEST( name2 == "common" ); String name3 = FileAddress::GetName( "../out/common" ); TEST( name3 == "common" ); }
36.659574
95
0.645386
azhirnov
74cb9c22d6bf4f20f239a8c94b290af86685859f
1,078
cpp
C++
chapter02/2.5_Dealing_with_Types/2.5.2_The_auto_Type_Specifier.cpp
NorthFacing/step-by-c
bc0e4f0c0fe45042ae367a28a87d03b5c3c787e3
[ "MIT" ]
9
2019-05-10T05:39:21.000Z
2022-02-22T08:04:52.000Z
chapter02/2.5_Dealing_with_Types/2.5.2_The_auto_Type_Specifier.cpp
NorthFacing/step-by-c
bc0e4f0c0fe45042ae367a28a87d03b5c3c787e3
[ "MIT" ]
null
null
null
chapter02/2.5_Dealing_with_Types/2.5.2_The_auto_Type_Specifier.cpp
NorthFacing/step-by-c
bc0e4f0c0fe45042ae367a28a87d03b5c3c787e3
[ "MIT" ]
6
2019-05-13T13:39:19.000Z
2022-02-22T08:05:01.000Z
/** * 2.5.2 auto 类型说明符 * @Author Bob * @Eamil 0haizhu0@gmail.com * @Date 2017/7/14 */ int main() { /** * C++11 新标准引入了 auto 类型说明符,用它就能让编译器替我们去分析表达式所属的类型, * 也就是让编译器通过初始值来推算变量的类型。显然,auto 定义的变量必须有初始值。 */ auto item = 1 + 2; // item 初始化未 1与2 的和,因为 1和2 都是int型,所以item也是int类型 auto i = 0, *p = &i; // i 是整数,p是整形指针 // 复合类型、常量 和 auto /** * 首先,使用引用其实是使用引用的对象,特别是引用被当做初始值时,真正参与初始化的其实是引用对象的值。 * 此时编译器以引用对象的类型作为auto的类型: */ int k=0, &r = k; auto a = r; // a 是一个整数(r是j的别名,而j是一个整数) /** * 其次,auto 会忽略顶层const,保留底层const。比如初始值是一个指向常量的指针: */ const int ci = i, &cr = ci; auto b = ci; // b 是一个整数(ci的顶层const特性被忽略了) auto c = cr; // c 是一个整数(cr是ci的别名,ci本身是一个顶层const) auto d = &i; // d 是一个整形指针(整数的地址就是指向整数的指针) auto e = &ci; // e 是一个指向整数常量的指针(对常量对象取地址是一种底层const) /** * 如果希望推断出的类型是一个顶层const,则需要明确指出: */ const auto f = ci; // ci的推演类型是int,f是 const int /** * 还可以将引用的类型设为auto,此时原来的初始化规则仍然使用 */ auto &g = ci; // g 是一个整形常量引用,绑定到ci // auto &h = 42; // 错误:不能为非常量引用绑定字面值 const auto &j = 42; // 可以为常量引用绑定字面值 return 0; }
23.434783
68
0.613173
NorthFacing
74cde53b5ebac6ea9f29daf67aae078b07bdf8bb
2,869
cpp
C++
src/main.cpp
arihantdaga/wifi-dimmer
ba557fef52d3cccda9732538eb6fa38f0766fe50
[ "MIT" ]
null
null
null
src/main.cpp
arihantdaga/wifi-dimmer
ba557fef52d3cccda9732538eb6fa38f0766fe50
[ "MIT" ]
null
null
null
src/main.cpp
arihantdaga/wifi-dimmer
ba557fef52d3cccda9732538eb6fa38f0766fe50
[ "MIT" ]
null
null
null
#include "button.hpp" #include "config.hpp" #include "dimmer.hpp" // #include "encoder.hpp" #include <Arduino.h> #include <Embedis.h> void onRotate(int8_t); void onClick(); Button button; unsigned long secondElapsed = millis(); unsigned long fakeFreq = millis(); Embedis embedis(Serial); void setup() { delay(2000); Serial.begin(115200); Serial.println("\nBooting"); Serial.println(US_TO_RTC_TIMER_TICKS(65)); dimmer::setup(); // encoder::setup(ENCODER_PINA, ENCODER_PINB, onRotate); button.setup(ButtonType::pulldown, BUTTON_PIN, onClick); Serial.println("Ready"); // Add pinMode command to mirror Arduino's Embedis::command( F("dim"), [](Embedis* e) { if (e->argc != 3) return e->response(Embedis::ARGS_ERROR); int pin = String(e->argv[1]).toInt(); int val = String(e->argv[2]).toInt(); onRotate(val); // String argv3(e->argv[2]); // argv3.toUpperCase(); // int mode; // if (argv3 == "INPUT") mode = INPUT; // else if (argv3 == "OUTPUT") mode = OUTPUT; // else if (argv3 == "INPUT_PULLUP") mode = INPUT_PULLUP; // else return e->response(Embedis::ARGS_ERROR); // pinMode(pin, mode); // e->response(Embedis::OK); }); Embedis::command( F("toggle"), [](Embedis* e) { // if (e->argc != 3) return e->response(Embedis::ARGS_ERROR); // int pin = String(e->argv[1]).toInt(); // int val = String(e->argv[2]).toInt(); onClick(); // String argv3(e->argv[2]); // argv3.toUpperCase(); // int mode; // if (argv3 == "INPUT") mode = INPUT; // else if (argv3 == "OUTPUT") mode = OUTPUT; // else if (argv3 == "INPUT_PULLUP") mode = INPUT_PULLUP; // else return e->response(Embedis::ARGS_ERROR); // pinMode(pin, mode); // e->response(Embedis::OK); }); } void loop() { // encoder::handle(); button.handle(); // if (millis() - fakeFreq >= 10) { // fakeFreq = millis(); // reset timer // dimmer::zeroCrossed(); // } if (millis() - secondElapsed >= 1000) { secondElapsed = millis(); // reset timer Serial.printf("power: %s; brightness: %d; cross count: %d; low count: %d; timer interrupt count: %d; max " "interrupt count: %d\n", dimmer::powerOn ? "on" : "off", dimmer::brightness, dimmer::debugCrossCount, dimmer::debugLowCount, dimmer::debugTimerInterrupt, dimmer::maxInterruptCount); dimmer::debugCrossCount = 0; dimmer::debugLowCount = 0; dimmer::debugTimerInterrupt = 0; dimmer::maxInterruptCount = 0; } embedis.process(); } void onRotate(int8_t position) { dimmer::setBrightness(position * 1); // Serial.println(position); } void onClick() { dimmer::togglePower(); }
31.877778
114
0.577553
arihantdaga
74d12ac16006cf6e7da5d9fc77911a07d658cbe6
724
cpp
C++
convert_24h_to_12h/convert_24h_to_12h.cpp
BjornChrisnach/Introduction_to_Programming_in_C_plusplus
57b96b0f99cb486276181474e333c3b09d21a749
[ "MIT" ]
null
null
null
convert_24h_to_12h/convert_24h_to_12h.cpp
BjornChrisnach/Introduction_to_Programming_in_C_plusplus
57b96b0f99cb486276181474e333c3b09d21a749
[ "MIT" ]
null
null
null
convert_24h_to_12h/convert_24h_to_12h.cpp
BjornChrisnach/Introduction_to_Programming_in_C_plusplus
57b96b0f99cb486276181474e333c3b09d21a749
[ "MIT" ]
null
null
null
#include <iostream> #include <string> using namespace std; int main() { int hour24, minutes24; int hour12, minutes12; string period; char temp; cout<<"Please enter a time in 24 hour format:"<<endl; cin>>hour24>>temp>>minutes24; minutes12 = minutes24; if(hour24 >= 0 && hour24 <= 11){ period = "am"; if(hour24 == 0){ hour12 = 12; } else { hour12 = hour24; } } else { period = "pm"; if(hour24 == 12){ hour12 = 12; } else { hour12 = hour24 -12; } } cout<<hour24<<":"<<minutes24<<" is "<<hour12<<":"<<minutes12<<" "<<period<<endl; return 0; }
19.052632
84
0.476519
BjornChrisnach
74db8bc40a132f317512b5305d8ad5d8edeba284
2,616
cpp
C++
Melone/Src/Melone/Renderer/BufferObj.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
Melone/Src/Melone/Renderer/BufferObj.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
Melone/Src/Melone/Renderer/BufferObj.cpp
Nightskies/Melone
eb735a97fa1416c1feffecaefb479d30ce6e21e2
[ "MIT" ]
null
null
null
#include "mlpch.h" #include "BufferObj.h" #include "Renderer.h" #include "Platform/OpenGL/OpenGLBufferObj.h" namespace Melone { VBOElement::VBOElement(ShaderDataType elType, std::string elName, bool elNormalized) : type(elType), name(std::move(elName)), size(ShaderDataTypeSize(elType)), normalized(elNormalized) {} unsigned int VBOElement::getComponentCount(void) const { switch (type) { case Melone::ShaderDataType::Float: return 1; case Melone::ShaderDataType::Float2: return 2; case Melone::ShaderDataType::Float3: return 3; case Melone::ShaderDataType::Float4: return 4; case Melone::ShaderDataType::Mat3: return 9; case Melone::ShaderDataType::Mat4: return 16; case Melone::ShaderDataType::Int: return 1; case Melone::ShaderDataType::Int2: return 2; case Melone::ShaderDataType::Int3: return 3; case Melone::ShaderDataType::Int4: return 4; case Melone::ShaderDataType::Bool: return 1; default: MELONE_CORE_ASSERT(false, "Unknown shader data type"); return 0; } } VBOLayout::VBOLayout(std::initializer_list<VBOElement> el) : mElements(std::move(el)) { calculateOffsetAndStride(); } void VBOLayout::calculateOffsetAndStride(void) { unsigned int offset = 0; mStride = 0; for (auto& el : mElements) { el.offset = offset; offset += el.size; mStride += el.size; } } std::shared_ptr<VBO> VBO::create(unsigned int size) { switch (Renderer::getAPI()) { case RendererAPI::API::Undefined: MELONE_CORE_ASSERT(false, "RendererAPI is undefined"); return nullptr; case RendererAPI::API::OpenGL: return std::make_shared<OpenGLVBO>(size); default: MELONE_CORE_ASSERT(false, "Unknown renderer api"); return nullptr; } } std::shared_ptr<VBO> VBO::create(float* vertices, unsigned int size) { switch (Renderer::getAPI()) { case RendererAPI::API::Undefined: MELONE_CORE_ASSERT(false, "RendererAPI is undefined"); return nullptr; case RendererAPI::API::OpenGL: return std::make_shared<OpenGLVBO>(vertices, size); default: MELONE_CORE_ASSERT(false, "Unknown renderer api"); return nullptr; } } std::shared_ptr<IBO> IBO::create(unsigned int* indices, unsigned int count) { switch (Renderer::getAPI()) { case RendererAPI::API::Undefined: MELONE_CORE_ASSERT(false, "RendererAPI is undefined"); return nullptr; case RendererAPI::API::OpenGL: return std::make_shared<OpenGLIBO>(indices, count); default: MELONE_CORE_ASSERT(false, "Unknown renderer api"); return nullptr; } } }
21.8
85
0.689985
Nightskies
74e3b25f2b47de23ec1355fc2c6b5dafdd6baaa1
1,070
cpp
C++
docs/assets/examples/try.cpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
docs/assets/examples/try.cpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
docs/assets/examples/try.cpp
IohannRabeson/lexy
881beb56f030e8f4761514e70cb50d809ac4ad17
[ "BSL-1.0" ]
null
null
null
#include <optional> #include <lexy/callback.hpp> #include <lexy/dsl.hpp> #include <lexy/input/string_input.hpp> #include <lexy/parse.hpp> #include <lexy_ext/cfile.hpp> #include <lexy_ext/report_error.hpp> namespace dsl = lexy::dsl; //{ struct version { std::optional<int> major, minor, patch; }; struct production { static constexpr auto rule = [] { // If we don't have an integer, recover by producing nullopt. auto number = dsl::try_(dsl::integer<int>(dsl::digits<>), dsl::nullopt); auto dot = dsl::try_(dsl::period); return number + dot + number + dot + number; }(); static constexpr auto value = lexy::construct<version>; }; //} int main() { auto input = lexy_ext::read_file<>(stdin); auto result = lexy::parse<production>(input, lexy_ext::report_error); if (!result.has_value()) return 1; auto [major, minor, patch] = result.value(); std::printf("The value is: %d.%d.%d\n", major.value_or(0), minor.value_or(0), patch.value_or(0)); return result ? 0 : 1; }
24.318182
81
0.629907
IohannRabeson
74e47a7337eb25b058a9e4d072d7e4445832140e
3,868
cpp
C++
libs/GameUI/controllers/NineSlicer.cpp
max-delta/retrofit-public
5447fd6399fd74ffbb75494c103940751000db12
[ "X11" ]
3
2019-10-27T22:32:44.000Z
2020-05-21T04:00:46.000Z
libs/GameUI/controllers/NineSlicer.cpp
max-delta/retrofit-public
5447fd6399fd74ffbb75494c103940751000db12
[ "X11" ]
null
null
null
libs/GameUI/controllers/NineSlicer.cpp
max-delta/retrofit-public
5447fd6399fd74ffbb75494c103940751000db12
[ "X11" ]
null
null
null
#include "stdafx.h" #include "NineSlicer.h" #include "GameUI/ContainerManager.h" #include "GameUI/Container.h" #include "GameUI/UIContext.h" #include "RFType/CreateClassInfoDefinition.h" #include "core_math/Lerp.h" RFTYPE_CREATE_META( RF::ui::controller::NineSlicer ) { RFTYPE_META().BaseClass<RF::ui::controller::InstancedController>(); RFTYPE_REGISTER_BY_QUALIFIED_NAME( RF::ui::controller::NineSlicer ); } namespace RF::ui::controller { /////////////////////////////////////////////////////////////////////////////// NineSlicer::NineSlicer() { for( bool& b : mSliceEnabled ) { b = true; } } NineSlicer::NineSlicer( bool const ( &sliceEnabled )[9] ) { for( size_t i = 0; i < 9; i++ ) { mSliceEnabled[i] = sliceEnabled[i]; } } ContainerID NineSlicer::GetChildContainerID( size_t sliceIndex ) const { return mContainers.at( sliceIndex ); } void NineSlicer::CreateChildContainer( ContainerManager& manager, size_t sliceIndex ) { CreateChildContainerInternal( manager, GetMutableContainer( manager, mParentContainerID ), sliceIndex ); } void NineSlicer::DestroyChildContainer( ContainerManager& manager, size_t sliceIndex ) { ContainerID& id = mContainers.at( sliceIndex ); if( id != kInvalidContainerID ) { DestroyContainer( manager, id ); id = kInvalidContainerID; mSliceEnabled[sliceIndex] = false; } else { RF_ASSERT( mSliceEnabled[sliceIndex] == false ); } } void NineSlicer::OnInstanceAssign( UIContext& context, Container& container ) { mParentContainerID = container.mContainerID; m0 = CreateAnchor( context.GetMutableContainerManager(), container ); m33 = CreateAnchor( context.GetMutableContainerManager(), container ); m66 = CreateAnchor( context.GetMutableContainerManager(), container ); m100 = CreateAnchor( context.GetMutableContainerManager(), container ); for( size_t i = 0; i < 9; i++ ) { if( mSliceEnabled[i] == false ) { mContainers[i] = kInvalidContainerID; continue; } CreateChildContainerInternal( context.GetMutableContainerManager(), container, i ); } } void NineSlicer::OnAABBRecalc( UIContext& context, Container& container ) { gfx::ppu::AABB const& aabb = container.mAABB; gfx::ppu::CoordElem const x0 = aabb.Left(); gfx::ppu::CoordElem const x100 = aabb.Right(); gfx::ppu::CoordElem const x33 = math::Lerp( x0, x100, 1.f / 3.f ); gfx::ppu::CoordElem const x66 = math::Lerp( x0, x100, 2.f / 3.f ); gfx::ppu::CoordElem const y0 = aabb.Top(); gfx::ppu::CoordElem const y100 = aabb.Bottom(); gfx::ppu::CoordElem const y33 = math::Lerp( y0, y100, 1.f / 3.f ); gfx::ppu::CoordElem const y66 = math::Lerp( y0, y100, 2.f / 3.f ); MoveAnchor( context.GetMutableContainerManager(), m0, { x0, y0 } ); MoveAnchor( context.GetMutableContainerManager(), m33, { x33, y33 } ); MoveAnchor( context.GetMutableContainerManager(), m66, { x66, y66 } ); MoveAnchor( context.GetMutableContainerManager(), m100, { x100, y100 } ); } /////////////////////////////////////////////////////////////////////////////// void NineSlicer::CreateChildContainerInternal( ContainerManager& manager, Container& container, size_t sliceIndex ) { ContainerID& id = mContainers.at( sliceIndex ); if( id != kInvalidContainerID ) { RF_DBGFAIL_MSG( "Container already exists" ); return; } AnchorID top; AnchorID bottom; if( sliceIndex < 3 ) { top = m0; bottom = m33; } else if( sliceIndex < 6 ) { top = m33; bottom = m66; } else { top = m66; bottom = m100; } AnchorID left; AnchorID right; size_t const column = sliceIndex % 3; if( column == 0 ) { left = m0; right = m33; } else if( column == 1 ) { left = m33; right = m66; } else { left = m66; right = m100; } id = Controller::CreateChildContainer( manager, container, left, right, top, bottom ); } /////////////////////////////////////////////////////////////////////////////// }
23.301205
115
0.65486
max-delta
74e4b1a8bf02b4a4a9d3056df3816ee1be31bef0
4,952
cpp
C++
source/rfid/source/rfid.cpp
hyphaproject/hyphaplugins
b41b396392c5546e3c2802bfc34213c5da04fdf4
[ "MIT" ]
null
null
null
source/rfid/source/rfid.cpp
hyphaproject/hyphaplugins
b41b396392c5546e3c2802bfc34213c5da04fdf4
[ "MIT" ]
1
2017-02-18T10:51:07.000Z
2017-02-18T10:51:07.000Z
source/rfid/source/rfid.cpp
hyphaproject/hyphaplugins
b41b396392c5546e3c2802bfc34213c5da04fdf4
[ "MIT" ]
null
null
null
// Copyright (c) 2015-2016 Hypha #include "hyphaplugins/rfid/rfid.h" #include <errno.h> #include <fcntl.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/ioctl.h> #include <termios.h> #include <unistd.h> #include <Poco/ClassLibrary.h> #include <QtCore/QJsonArray> #include <QtCore/QJsonDocument> #include <QtCore/QJsonObject> #include <QtCore/QProcess> #include <QtSerialPort/QSerialPortInfo> using namespace hypha::plugin; using namespace hypha::plugin::rfid; void RFID::doWork() { std::this_thread::sleep_for(std::chrono::milliseconds(100)); // read card reader data char buf[1024]; if (read_until(fd, buf, '\n') == 0) { } QString uid(buf); uid = uid.remove(QRegExp("[ \\n\\t\\r]")); if (uid.isEmpty() || uid.length() < 5) return; // create json string with card id; QJsonDocument document_out; QJsonObject object_out; QJsonArray devices = QJsonArray::fromStringList(uid.split('\n', QString::SkipEmptyParts)); object_out.insert("source", QJsonValue(QString::fromStdString(getId()))); object_out.insert("devices", devices); object_out.insert("devicetype", QJsonValue("rfid")); document_out.setObject(object_out); qDebug(uid.toStdString().c_str()); sendMessage(document_out.toJson().data()); std::this_thread::sleep_for(std::chrono::seconds(2)); } void RFID::setup() { struct termios toptions; port.setPort(QSerialPortInfo::availablePorts().at(0)); QProcess process; if (process.execute("stty -F /dev/ttyACM0 9600 -parenb -parodd cs8 -hupcl " "-cstopb cread clocal -crtscts " "-ignbrk -brkint -ignpar -parmrk inpck -istrip -inlcr " "-igncr -icrnl -ixon -ixoff " "-iuclc -ixany -imaxbel -iutf8 " "-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill " "-ofdel nl0 cr0 tab0 bs0 vt0 ff0 " "-isig -icanon -iexten -echo -echoe -echok -echonl " "-noflsh -xcase -tostop -echoprt " "-echoctl -echoke ")) { qDebug("tty options set"); } port.setBaudRate(QSerialPort::Baud9600); port.setParity(QSerialPort::NoParity); port.setFlowControl(QSerialPort::NoFlowControl); port.setDataBits(QSerialPort::Data8); if (port.open(QIODevice::ReadWrite)) { port.write("BEEP"); } port.close(); // TODO: QSerialPort not working atm fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY); std::this_thread::sleep_for(std::chrono::seconds(2)); tcgetattr(fd, &toptions); cfsetispeed(&toptions, B9600); cfsetospeed(&toptions, B9600); toptions.c_cflag &= ~PARENB; toptions.c_cflag &= ~CSTOPB; toptions.c_cflag &= ~CSIZE; toptions.c_cflag |= CS8; toptions.c_lflag |= ICANON; tcsetattr(fd, TCSANOW, &toptions); beep(); beep(); beep(); } int RFID::read_until(int fd, char *buf, char until) { char b[1]; int i = 0; do { int n = read(fd, b, 1); // read a char at a time if (n == -1) return -1; // couldn't read if (n == 0) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); continue; } buf[i] = b[0]; i++; } while (b[0] != until); buf[i] = 0; // null terminate the string return 0; } std::string RFID::communicate(std::string UNUSED(message)) { return getStatusMessage(); } void RFID::loadConfig(std::string UNUSED(json)) {} std::string RFID::getConfig() { return "{}"; } hypha::plugin::HyphaPlugin *RFID::getInstance(std::string id) { RFID *instance = new RFID(); instance->setId(id); return instance; } void RFID::receiveMessage(std::string message) { if (message.length() > 0) { bool red = false; bool green = false; bool yellow = false; bool door = false; QJsonDocument document = QJsonDocument::fromJson(message.c_str()); QJsonObject object = document.object(); if (object.contains("beep")) { beep(); } if (object.contains("door")) { door = object.value("door").toBool(); setDoor(door); } if (object.contains("red") || object.contains("green") || object.contains("yellow")) { if (object.contains("red")) { red = object.value("red").toBool(); } if (object.contains("green")) { green = object.value("green").toBool(); } if (object.contains("yellow")) { yellow = object.value("yellow").toBool(); } setRGY(red, green, yellow); } } } void RFID::beep() { write(fd, "BEEP\n", 5); } void RFID::setDoor(bool open) { write(fd, open ? "DOOR_OPEN\n" : "DOOR_CLOSE\n", open ? 10 : 11); } void RFID::setRGY(bool red, bool green, bool yellow) { write(fd, red ? "RED_ON\n" : "RED_OFF\n", red ? 7 : 8); write(fd, green ? "GREEN_ON\n" : "GREEN_OFF\n", green ? 9 : 10); write(fd, yellow ? "YELLOW_ON\n" : "YELLOW_OFF\n", yellow ? 10 : 11); } POCO_BEGIN_MANIFEST(HyphaPlugin) POCO_EXPORT_CLASS(RFID) POCO_END_MANIFEST
27.977401
77
0.624394
hyphaproject
74e6f87843e903caabf0b62cb8af5d5cd1fea570
1,829
hpp
C++
libs/fnd/compare/include/bksge/fnd/compare/compare_three_way.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
4
2018-06-10T13:35:32.000Z
2021-06-03T14:27:41.000Z
libs/fnd/compare/include/bksge/fnd/compare/compare_three_way.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
566
2017-01-31T05:36:09.000Z
2022-02-09T05:04:37.000Z
libs/fnd/compare/include/bksge/fnd/compare/compare_three_way.hpp
myoukaku/bksge
0f8b60e475a3f1709723906e4796b5e60decf06e
[ "MIT" ]
1
2018-07-05T04:40:53.000Z
2018-07-05T04:40:53.000Z
/** * @file compare_three_way.hpp * * @brief compare_three_way の定義 * * @author myoukaku */ #ifndef BKSGE_FND_COMPARE_COMPARE_THREE_WAY_HPP #define BKSGE_FND_COMPARE_COMPARE_THREE_WAY_HPP #include <bksge/fnd/compare/config.hpp> #if defined(BKSGE_HAS_STD_COMPARE) && defined(BKSGE_HAS_CXX20_THREE_WAY_COMPARISON) #if defined(BKSGE_USE_STD_COMPARE) #include <compare> namespace bksge { using std::compare_three_way; } // namespace bksge #else // defined(BKSGE_USE_STD_COMPARE) #include <bksge/fnd/compare/detail/builtin_ptr_three_way.hpp> #include <bksge/fnd/compare/concepts/three_way_comparable_with.hpp> #include <bksge/fnd/config.hpp> #include <type_traits> // is_constant_evaluated #include <cstdint> #include <utility> namespace bksge { struct compare_three_way { template <typename T, typename U> requires bksge::three_way_comparable_with<T, U> || detail::builtin_ptr_three_way<T, U> constexpr auto operator()(T&& t, U&& u) const noexcept(noexcept(std::declval<T>() <=> std::declval<U>())) { if constexpr (detail::builtin_ptr_three_way<T, U>) { auto pt = static_cast<void const volatile*>(t); auto pu = static_cast<void const volatile*>(u); #if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811 if (std::is_constant_evaluated()) { return pt <=> pu; } #endif auto it = reinterpret_cast<std::uintptr_t>(pt); auto iu = reinterpret_cast<std::uintptr_t>(pu); return it <=> iu; } else { return static_cast<T&&>(t) <=> static_cast<U&&>(u); } } using is_transparent = void; }; } // namespace bksge #endif // defined(BKSGE_USE_STD_COMPARE) #endif // defined(BKSGE_HAS_CXX20_THREE_WAY_COMPARISON) #endif // BKSGE_FND_COMPARE_COMPARE_THREE_WAY_HPP
23.753247
90
0.708037
myoukaku
d55df69f1911e31ef3e8cd409cb73c42ebd35b99
1,288
hpp
C++
lib/arbimath/bigint/VectorUtil.hpp
waegemans/arbimath
d3408b6b75762bdb276b8d9cec6de54ebae913d0
[ "MIT" ]
null
null
null
lib/arbimath/bigint/VectorUtil.hpp
waegemans/arbimath
d3408b6b75762bdb276b8d9cec6de54ebae913d0
[ "MIT" ]
null
null
null
lib/arbimath/bigint/VectorUtil.hpp
waegemans/arbimath
d3408b6b75762bdb276b8d9cec6de54ebae913d0
[ "MIT" ]
null
null
null
#pragma once #include <cstdint> #include <string_view> #include <vector> namespace arbimath::vector_util { /// add two vectors with given signs together and return resulting sign and magnitude std::pair<bool, std::vector<uint64_t>> add(bool lhs_sign, const std::vector<uint64_t>& lhs, bool rhs_sign, const std::vector<uint64_t>& rhs); /// subtract two vectors with given signs together and return resulting sign and magnitude std::pair<bool, std::vector<uint64_t>> sub(bool lhs_sign, const std::vector<uint64_t>& lhs, bool rhs_sign, const std::vector<uint64_t>& rhs); /// add two vectors together and returns the result std::vector<uint64_t> addMagnitude(const std::vector<uint64_t>& lhs, const std::vector<uint64_t>& rhs); /// subs two vectors together and returns the result. lhs must be larger then rhs std::vector<uint64_t> subMagnitude(const std::vector<uint64_t>& lhs, const std::vector<uint64_t>& rhs); /// converts an hex string without prefix to std::vector<uint64_t> fromHexStringView(std::string_view stringView); /// check if lhs is smaller then rhs bool less(const std::vector<uint64_t>& lhs, const std::vector<uint64_t>& rhs); bool hasLeadingZeros(const std::vector<uint64_t>& x); void removeLeadingZeros(std::vector<uint64_t>& x); } // namespace arbimath::vector_util
49.538462
141
0.763199
waegemans
d56022d6b0104b3fc55d7884289eb77b00de5581
10,572
cpp
C++
src/my_renderer.cpp
ldm0/my_soft_renderer
25935e3e2ae1d8f0e7411ecc4b1abe6a60bd4497
[ "WTFPL" ]
null
null
null
src/my_renderer.cpp
ldm0/my_soft_renderer
25935e3e2ae1d8f0e7411ecc4b1abe6a60bd4497
[ "WTFPL" ]
null
null
null
src/my_renderer.cpp
ldm0/my_soft_renderer
25935e3e2ae1d8f0e7411ecc4b1abe6a60bd4497
[ "WTFPL" ]
null
null
null
#include"my_renderer.h" #include"my_graphic.h" #include"my_obj_loader/my_obj_loader.h" #include"SCG/scg.h" #include<Windows.h> #include<tchar.h> #include<math.h> Renderer::Renderer() :draw_mode(DRAW_MESH), yaw_pitch_roll({0}), camera_position({0}), back_buffer(0), z_buffer(0), v_buffer(0), c_buffer(0), mesh(0), /* texture_width(0), texture_height(0), texture(0), */ //window_exit(false), alloc(0), drop(0) { } Renderer::~Renderer() { if (mesh) { drop(v_buffer); drop(c_buffer); } mesh = NULL; } void Renderer::v_shading(void) { if (draw_mode == DRAW_MESH) return; unsigned numf = mesh->num_f; for (unsigned i = 0; i < numf; ++i) { //float brightness = 0.1; c_buffer[i].x = 0xff0000ff; c_buffer[i].y = 0x00ff00ff; c_buffer[i].z = 0x0000ffff; } } void Renderer::projection(void) { unsigned numv = mesh->num_v; for (unsigned i = 0; i < numv; ++i) { f4 tmp_v = { mesh->v_buffer[i].x, mesh->v_buffer[i].y, mesh->v_buffer[i].z, 1.f }; tmp_v = view_space(&tmp_v, &camera_position, &yaw_pitch_roll); v_buffer[i].x = tmp_v.x; v_buffer[i].y = tmp_v.y; v_buffer[i].z = tmp_v.z; } } void Renderer::clipping(void) { // do nothing } void Renderer::screen_mapping(void) { int width = scg_window_width; int height = scg_window_height; unsigned numv = mesh->num_v; for (unsigned i = 0; i < numv; ++i) { float scale = fminf((float)width, (float)height); v_buffer[i].x = v_buffer[i].x * scale + .5f * width; // Negative sign for origin at top-left corner v_buffer[i].y = -v_buffer[i].y * scale + .5f * height; } } void Renderer::draw_line(f3 a, f3 b) { int width = scg_window_width; int height = scg_window_height; // z buffer is not needed when drawing line float a_b_x = a.x - b.x; float a_b_y = a.y - b.y; float a_b_z = a.z - b.z; unsigned line_color = 0x00ffffff; if (fabsf(a_b_x) < fabsf(a_b_y)) { int top = (int)clampf(fminf(a.y, b.y), 0, (float)height); int bottom = (int)clampf(fmaxf(a.y, b.y), 0, (float)height); for (int y = top; y < bottom; ++y) { float depth = 1 / (a.z - a_b_z * (a.y - y) / a_b_y); int x = (int)((b.x * (a.y - (float)y) + a.x * ((float)y - b.y)) / a_b_y); if (x >= 0 && x < width) { if (depth >= z_buffer[x + y * width]) { z_buffer[x + y * width] = depth; back_buffer[x + y * width] = line_color; } } } } else { int left = (int)clampf(fminf(a.x, b.x), 0, (float)width); int right = (int)clampf(fmaxf(a.x, b.x), 0, (float)width); for (int x = left; x < right; ++x) { float depth = 1 / (a.z - a_b_z * (a.x - x) / a_b_x); int y = (int)((b.y * (a.x - (float)x) + a.y * ((float)x - b.x)) / a_b_x); if (y >= 0 && y < height) { if (depth >= z_buffer[x + y * width]) { z_buffer[x + y * width] = depth; back_buffer[x + y * width] = line_color; } } } } } void Renderer::rasterization(void) { int width = scg_window_width; int height = scg_window_height; unsigned numf = mesh->num_f; for (unsigned i = 0; i < numf; ++i) { u3 triangle = { mesh->f_buffer[i].v1, mesh->f_buffer[i].v2, mesh->f_buffer[i].v3, }; f3 a = v_buffer[triangle.x - 1]; f3 b = v_buffer[triangle.y - 1]; f3 c = v_buffer[triangle.z - 1]; if (draw_mode != DRAW_MESH) { // Draw color float window_height_f = (float)height; float window_width_f = (float)width; // get scan area float left_f = clampf(fminf(fminf(a.x, b.x), c.x), 0.f, window_width_f); float right_f = clampf(fmaxf(fmaxf(a.x, b.x), c.x), 0.f, window_width_f); float top_f = clampf(fminf(fminf(a.y, b.y), c.y), 0.f, window_height_f); float bottom_f = clampf(fmaxf(fmaxf(a.y, b.y), c.y), 0.f, window_height_f); int left = (int)(left_f + .5f); int right = (int)(right_f + .5f); int top = (int)(top_f + .5f); int bottom = (int)(bottom_f + .5f); float b_c_y = (b.y - c.y); float c_a_y = (c.y - a.y); float a_b_y = (a.y - b.y); int a_color_r = c_buffer[i].x >> 24; int a_color_g = 0xff & (c_buffer[i].x >> 16); int a_color_b = 0xff & (c_buffer[i].x >> 8); int b_color_r = c_buffer[i].y >> 24; int b_color_g = 0xff & (c_buffer[i].y >> 16); int b_color_b = 0xff & (c_buffer[i].y >> 8); int c_color_r = c_buffer[i].z >> 24; int c_color_g = 0xff & (c_buffer[i].z >> 16); int c_color_b = 0xff & (c_buffer[i].z >> 8); float b_a_z = b.z - a.z; float c_a_z = c.z - a.z; // Coordinate transform // Build two vector f2 b_a_position; b_a_position.x = b.x - a.x; b_a_position.y = -a_b_y; float length1 = sqrtf(b_a_position.x * b_a_position.x + b_a_position.y * b_a_position.y); b_a_position.x /= length1; b_a_position.y /= length1; f2 c_a_position; c_a_position.x = c.x - a.x; c_a_position.y = c_a_y; float length2 = sqrtf(c_a_position.x * c_a_position.x + c_a_position.y * c_a_position.y); c_a_position.x /= length2; c_a_position.y /= length2; // Build transform float determinant = b_a_position.x * c_a_position.y - b_a_position.y * c_a_position.x; mat2x2 inv_coord_transform; inv_coord_transform.m[0][0] = c_a_position.y / determinant; inv_coord_transform.m[0][1] = -b_a_position.y / determinant; inv_coord_transform.m[1][0] = -c_a_position.x / determinant; inv_coord_transform.m[1][1] = b_a_position.x / determinant; float tmp = b_c_y * a.x + c_a_y * b.x + a_b_y * c.x; for (unsigned y = top; y < bottom; ++y) { for (unsigned x = left; x < right; ++x) { float x_f = (float)x; float y_f = (float)y; float side0 = b_c_y * x_f + (c.y - y_f) * b.x + (y_f - b.y) * c.x; float side1 = (y_f - c.y) * a.x + c_a_y * x_f + (a.y - y_f) * c.x; float side2 = (b.y - y_f) * a.x + (y_f - a.y) * b.x + a_b_y * x_f; // the point is same side with another triangle point in each in 3 side bool draw = (tmp * side0 >= -0.f) && (tmp * side1 >= -0.f) && (tmp * side2 >= -0.f); if (!draw) continue; float u = ((x_f - a.x) * inv_coord_transform.m[0][0] + (y_f - a.y) * inv_coord_transform.m[1][0]) / length1; float v = ((x_f - a.x) * inv_coord_transform.m[0][1] + (y_f - a.y) * inv_coord_transform.m[1][1]) / length2; // Depth float pixel_depth = 1 / (a.z + u * b_a_z + v * c_a_z); if (pixel_depth > z_buffer[x + y * width]) { z_buffer[x + y * width] = pixel_depth; float tmp = 1 - u - v; unsigned pixel_color_r = (unsigned)(tmp * a_color_r + u * b_color_r + v * c_color_r); unsigned pixel_color_g = (unsigned)(tmp * a_color_g + u * b_color_g + v * c_color_g); unsigned pixel_color_b = (unsigned)(tmp * a_color_b + u * b_color_b + v * c_color_b); unsigned pixel_color = (unsigned)((pixel_color_r << 24) | (pixel_color_g << 16) | (pixel_color_b << 8)); back_buffer[x + y * width] = pixel_color >> 8; } } } } if (draw_mode != DRAW_COLOR) { // Draw mesh draw_line(a, b); draw_line(b, c); draw_line(c, a); } } } Renderer& Renderer::get(void) { static Renderer instance; return instance; } void Renderer::set_allocator(void *(*_malloc)(size_t), void (*_free)(void *)) { this->alloc = _malloc; this->drop = _free; } int Renderer::create_window(int width, int height, const TCHAR* title, WNDPROC event_process) { width = width; height = height; if (scg_create_window(width, height, title, event_process)) return -1; back_buffer = scg_back_buffer; // create depth buffer with the same width and height z_buffer = (float *)alloc(width * height * sizeof(float)); if (!z_buffer) return -1; return 0; } void Renderer::close_window(void) { if (z_buffer) drop(z_buffer); z_buffer = NULL; scg_close_window(); } void Renderer::refresh(void) { scg_refresh(); } void Renderer::clear(void) { int width = scg_window_width; int height = scg_window_height; #define block_size 32 #define block_color 0x7f for (unsigned y = 0; y < height; ++y) { for (unsigned x = 0; x < width; ++x) { unsigned b_color = (((x / block_size) % 2) ^ ((y / block_size) % 2)) * block_color; back_buffer[x + y * width] = b_color << 16 | b_color << 8 | b_color; z_buffer[x + y * width] = 0.f; } } #undef block_color #undef block_size } int Renderer::load_mesh(const my_obj_elements *_mesh) { mesh = _mesh; if (v_buffer) drop(v_buffer); v_buffer = (f3 *)alloc(_mesh->num_v * sizeof(f3)); if (!v_buffer) return -1; if (c_buffer) drop(c_buffer); c_buffer = (u3 *)alloc(_mesh->num_f * sizeof(u3)); if (!c_buffer) return -1; return 0; } /* void Renderer::load_texture(unsigned width, unsigned height, const unsigned *tex) { texture_width = width; texture_height = height; texture = tex; } */ void Renderer::draw(void) { v_shading(); projection(); clipping(); screen_mapping(); rasterization(); }
31.094118
128
0.507283
ldm0
d56700b5b805739edea709fd4eda59ecbd9decce
259
cpp
C++
src/08_evaluation_step1.cpp
pbouamriou/tuto_mpl
6c159662d50277f5bb4eda3038b394fb99501e3c
[ "MIT" ]
null
null
null
src/08_evaluation_step1.cpp
pbouamriou/tuto_mpl
6c159662d50277f5bb4eda3038b394fb99501e3c
[ "MIT" ]
null
null
null
src/08_evaluation_step1.cpp
pbouamriou/tuto_mpl
6c159662d50277f5bb4eda3038b394fb99501e3c
[ "MIT" ]
null
null
null
#include <iostream> class X; #if (__cplusplus < 201103L) template<typename T> struct Ptr { typedef T* type; }; #else template<typename T> struct Ptr { using type = T*; }; #endif int main() { std::cout << sizeof(Ptr<X>::type) << std::endl; }
11.26087
51
0.6139
pbouamriou
d567478d935bd4ceca756a92aa3b9b6980ab0f96
3,425
cpp
C++
functorch/csrc/BatchRulesPooling.cpp
laurencer/functorch
1bc4093b09f7a69606ff3fd2e6c76ffd55d4ac13
[ "BSD-3-Clause" ]
null
null
null
functorch/csrc/BatchRulesPooling.cpp
laurencer/functorch
1bc4093b09f7a69606ff3fd2e6c76ffd55d4ac13
[ "BSD-3-Clause" ]
null
null
null
functorch/csrc/BatchRulesPooling.cpp
laurencer/functorch
1bc4093b09f7a69606ff3fd2e6c76ffd55d4ac13
[ "BSD-3-Clause" ]
null
null
null
// Copyright (c) Facebook, Inc. and its affiliates. // All rights reserved. // // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. #include <functorch/csrc/BatchRulesHelper.h> #include <functorch/csrc/PlumbingHelper.h> #include <functorch/csrc/BatchedFallback.h> #include <ATen/core/dispatch/Dispatcher.h> namespace at { namespace functorch { std::tuple<Tensor,optional<int64_t>> adaptive_avg_pool2d_batch_rule( const Tensor& tensor, optional<int64_t> batch_dim, IntArrayRef output_size) { auto batch_size = tensor.size(*batch_dim); auto tensor_ = reshape_dim_into(*batch_dim, 0, tensor); auto result = at::adaptive_avg_pool2d(tensor_, output_size); return std::make_tuple( reshape_dim_outof(0, batch_size, result), 0 ); } std::tuple<Tensor,int64_t> max_pool2d_with_indices_backward_batch_rule( const Tensor & grad_output, optional<int64_t> grad_output_bdim, const Tensor & self, optional<int64_t> self_bdim, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices, optional<int64_t> indices_bdim) { TORCH_INTERNAL_ASSERT(grad_output_bdim && self_bdim && indices_bdim); auto bdim_size = self.size(*self_bdim); auto grad_output_ = reshape_dim_into(*grad_output_bdim, 0, grad_output); auto self_ = reshape_dim_into(*self_bdim, 0, self); auto indices_ = reshape_dim_into(*indices_bdim, 0, indices); auto result = at::max_pool2d_with_indices_backward( grad_output_, self_, kernel_size, stride, padding, dilation, ceil_mode, indices_); result = reshape_dim_outof(0, bdim_size, result); return std::make_tuple(result, 0); } Tensor max_pool2d_with_indices_backward_plumbing(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices) { auto maybe_layer = maybeCurrentDynamicLayer(); TORCH_INTERNAL_ASSERT(maybe_layer.has_value()); int64_t cur_level = maybe_layer->layerId(); Tensor grad_output_value; optional<int64_t> grad_output_bdim; std::tie(grad_output_value, grad_output_bdim) = unwrapTensorAtLevel(grad_output, cur_level); Tensor self_value; optional<int64_t> self_bdim; std::tie(self_value, self_bdim) = unwrapTensorAtLevel(self, cur_level); Tensor indices_value; optional<int64_t> indices_bdim; std::tie(indices_value, indices_bdim) = unwrapTensorAtLevel(indices, cur_level); if (self_bdim && grad_output_bdim && indices_bdim) { c10::impl::ExcludeDispatchKeyGuard guard(kBatchedKey); auto result = max_pool2d_with_indices_backward_batch_rule( grad_output_value, grad_output_bdim, self_value, self_bdim, kernel_size, stride, padding, dilation, ceil_mode, indices_value, indices_bdim); return makeBatched(std::get<0>(result), std::get<1>(result), cur_level); } static auto op = c10::Dispatcher::singleton() .findSchemaOrThrow("aten::max_pool2d_with_indices_backward", ""); return slow_fallback<Tensor>(op, { grad_output, self, kernel_size, stride, padding, dilation, ceil_mode, indices }); } TORCH_LIBRARY_IMPL(aten, FT_BATCHED_KEY, m) { VMAP_SUPPORT("adaptive_avg_pool2d", adaptive_avg_pool2d_batch_rule); m.impl("max_pool2d_with_indices_backward", max_pool2d_with_indices_backward_plumbing); } }}
42.8125
227
0.769343
laurencer
d56a9fada4449e73cfde2571a9dc7d1d58539527
658
cpp
C++
sw4261.cpp
sjnov11/SW-expert-academy
b7040017f2f8ff037aee40a5024284aaad1e50f9
[ "MIT" ]
1
2022-02-21T09:11:15.000Z
2022-02-21T09:11:15.000Z
sw4261.cpp
sjnov11/SW-expert-academy
b7040017f2f8ff037aee40a5024284aaad1e50f9
[ "MIT" ]
null
null
null
sw4261.cpp
sjnov11/SW-expert-academy
b7040017f2f8ff037aee40a5024284aaad1e50f9
[ "MIT" ]
1
2019-07-03T10:12:55.000Z
2019-07-03T10:12:55.000Z
#include <iostream> #include <string> #include <vector> using namespace std; char keypad[26] = { '2','2','2', '3','3','3', '4','4','4', '5','5','5', '6','6','6', '7','7','7','7', '8','8','8', '9','9','9','9' }; int main() { int T; cin >> T; for (int tc = 1; tc <= T; tc++) { string S; int N; cin >> S >> N; int answer = 0; for (int i = 0; i < N; i++) { string word; cin >> word; bool flag = true; for (int j = 0; j < word.size(); j++) { if (S[j] != keypad[word[j] - 'a']) { flag = false; break; } } if (flag) answer++; } cout << "#" << tc << " " << answer << "\n"; } }
18.277778
45
0.401216
sjnov11
d56d0d9dcc415e166f57e43916555271bef08c1d
10,535
cxx
C++
Src/Projects/box_Spring/boxSpring_box.cxx
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
53
2018-04-21T14:16:46.000Z
2022-03-19T11:27:37.000Z
Src/Projects/box_Spring/boxSpring_box.cxx
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
6
2019-06-05T16:37:29.000Z
2021-09-20T07:17:03.000Z
Src/Projects/box_Spring/boxSpring_box.cxx
Mikkelbf/OpenMoBu
c57c41a0908ad7734d48642549758271d11263b8
[ "BSD-3-Clause" ]
10
2019-02-22T18:43:59.000Z
2021-09-02T18:53:37.000Z
///////////////////////////////////////////////////////////////////////////////////////// // // boxSpring_box.cxx // // Sergei <Neill3d> Solokhin 2014-2018 // // GitHub page - https://github.com/Neill3d/OpenMoBu // Licensed under The "New" BSD License - https ://github.com/Neill3d/OpenMoBu/blob/master/LICENSE // ///////////////////////////////////////////////////////////////////////////////////////// /** \file boxSpring_box.cxx */ //--- Class declaration #include <math.h> #include "boxSpring_box.h" //--- Registration defines #define BOXSPRING__CLASS BOXSPRING__CLASSNAME #define BOXSPRING__NAME BOXSPRING__CLASSSTR #define BOXSPRING__LOCATION "Neill3d" #define BOXSPRING__LABEL "Spring" #define BOXSPRING__DESC "spring controller" //--- implementation and registration FBBoxImplementation ( BOXSPRING__CLASS ); // Box class name FBRegisterBox ( BOXSPRING__NAME, // Unique name to register box. BOXSPRING__CLASS, // Box class name BOXSPRING__LOCATION, // Box location ('plugins') BOXSPRING__LABEL, // Box label (name of box to display) BOXSPRING__DESC, // Box long description. FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon) /************************************************ * Creation ************************************************/ bool CBoxSpring::FBCreate() { lastLocalTimeDouble = lastSystemTimeDouble = 0.0; mOldPos[0] = mOldPos[1] = mOldPos[2] = 0.0; mCurrentPos[0] = mCurrentPos[1] = mCurrentPos[2] = 0.0; mVel[0] = mVel[1] = mVel[2] = 0.0; mDeltaTimeDouble = 0.0; mReset = false; //printf( "spring box here!\n" ); if( FBBox::FBCreate() ) { // Input Nodes mStiffnessNode = AnimationNodeInCreate ( 0, "Stiff", ANIMATIONNODE_TYPE_NUMBER ); mDampingNode = AnimationNodeInCreate ( 1, "Damp", ANIMATIONNODE_TYPE_NUMBER ); mFrictionNode = AnimationNodeInCreate ( 2, "Friction", ANIMATIONNODE_TYPE_NUMBER ); mLengthNode = AnimationNodeInCreate ( 3, "Length", ANIMATIONNODE_TYPE_NUMBER ); mMassNode = AnimationNodeInCreate ( 4, "Mass", ANIMATIONNODE_TYPE_NUMBER ); mPosNode = AnimationNodeInCreate ( 5, "Pos", ANIMATIONNODE_TYPE_VECTOR ); mTimedt = AnimationNodeInCreate ( 6, "EvalSteps", ANIMATIONNODE_TYPE_INTEGER ); mZeroFrame = AnimationNodeInCreate ( 7, "ZeroFrame", ANIMATIONNODE_TYPE_INTEGER ); mRealTime = AnimationNodeInCreate ( 8, "RealTime", ANIMATIONNODE_TYPE_BOOL ); // Output Node mResultNode = AnimationNodeOutCreate( 9, "Result", ANIMATIONNODE_TYPE_VECTOR ); return true; } return false; } /************************************************ * Destruction. ************************************************/ void CBoxSpring::FBDestroy() { FBBox::FBDestroy(); } /************************************************ * Real-time engine evaluation ************************************************/ void VectorSet( float a, float b, float c, FBVector3d &v ) { v[0] = a; v[1] = b; v[2] = c; } void VectorAdd( const FBVector3d &a, const FBVector3d &b, FBVector3d &c ) { c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; c[2] = a[2] + b[2]; } void VectorSub( const FBVector3d &a, const FBVector3d &b, FBVector3d &c ) { c[0] = a[0] - b[0]; c[1] = a[1] - b[1]; c[2] = a[2] - b[2]; } void VectorMul( const FBVector3d &a, const FBVector3d &b, FBVector3d &c ) { c[0] = a[0] * b[0]; c[1] = a[1] * b[1]; c[2] = a[2] * b[2]; } void VectorMul( const FBVector3d &a, float scale, FBVector3d &c ) { c[0] = a[0] * scale; c[1] = a[1] * scale; c[2] = a[2] * scale; } void VectorDiv( const FBVector3d &a, float scale, FBVector3d &c ) { c[0] = a[0] / scale; c[1] = a[1] / scale; c[2] = a[2] / scale; } float VectorLength( const FBVector3d &a ) { return sqrt( a[0]*a[0] + a[1]*a[1] + a[2]*a[2] ); } void VectorNorm( FBVector3d &v ) { float len = VectorLength( v ); if (len > 0) { v[0] /= len; v[1] /= len; v[2] /= len; } } float VectorDot( const FBVector3d &a, FBVector3d &b ) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; } struct SpringSettings { double length; double friction; double mass; double stiffness; double damping; SpringSettings(const double _length, const double _friction, const double _mass, const double _stiffness, const double _damping) : length(_length) , friction(_friction) , mass(_mass) , stiffness(_stiffness) , damping(_damping) {} }; bool CalculateSpring( const double dt, const FBVector3d &lV, const FBVector3d &mPos, const FBVector3d &mOldPos, const SpringSettings &settings, FBVector3d &mVel, FBVector3d &outPos ) { FBVector3d lForce, lR; FBVector3d px1, px2, pv1, pv2, dx, dv; // position & velocity double m, r, value; // vector length // position px1 = lV; px2 = mOldPos; VectorSub( px1, px2, dx ); // velocity VectorSub( lV, mOldPos, pv1 ); pv2 = mVel; VectorSub( pv1, pv2, dv ); // force r = settings.length; m = VectorLength( dx ); if (m == 0.0) m = 0.0001; lForce = dx; VectorNorm( lForce ); value = (settings.stiffness*(m-r)+settings.damping*(VectorDot(dv, dx)/m)); //value = lS*(m-r); VectorMul( lForce, value, lForce ); VectorDiv( lForce, settings.mass, lForce ); // add friction lR = mVel; if (m > 1.0f) VectorMul( lR, -settings.friction, lR ); else VectorMul( lR, -settings.friction, lR ); VectorAdd( lForce, lR, lForce ); VectorAdd( mVel, lForce, mVel ); // Change in velocity is added to the velocity. // The change is proportinal with the acceleration (force / m) and change in time VectorMul( mVel, dt, lR ); // Change in position is added to the position. VectorAdd( mOldPos, mVel, outPos ); // Change in position is velocity times the change in time /* // // damping // VectorSub( lV, mPos, lR ); VectorMul( lR, 0.5, lR ); double dt = (lTime - lastTimeDouble) * 10; VectorMul( lR, dt, lR ); VectorAdd( mPos, lR, mPos ); lR = mPos; */ return true; } bool CBoxSpring::AnimationNodeNotify( FBAnimationNode *pAnimationNode, FBEvaluateInfo *pEvaluateInfo ) { double lS, lD, lM, lFriction, lLength, lTimeDt, lZeroFrame, lRealTime; FBVector3d lInputPos, lR, lVel, lHold, lForce; bool lStatus[9]; FBTime lEvaluationTime, lLocalTime; // Read connector in values lStatus[0] = mStiffnessNode ->ReadData( &lS, pEvaluateInfo ); lStatus[1] = mMassNode ->ReadData( &lM, pEvaluateInfo ); lStatus[2] = mPosNode ->ReadData( &lInputPos[0], pEvaluateInfo ); lStatus[3] = mFrictionNode ->ReadData( &lFriction, pEvaluateInfo ); lStatus[4] = mLengthNode ->ReadData( &lLength, pEvaluateInfo ); lStatus[5] = mDampingNode ->ReadData( &lD, pEvaluateInfo ); lStatus[6] = mTimedt ->ReadData( &lTimeDt, pEvaluateInfo ); lStatus[7] = mZeroFrame ->ReadData( &lZeroFrame, pEvaluateInfo ); lStatus[8] = mRealTime ->ReadData( &lRealTime, pEvaluateInfo ); // Set default values if no input connection. if( !lStatus[0] ) { lS = 1.25; } if( !lStatus[1] ) { lM = 2.0; } if( !lStatus[2] ) { VectorSet( 0.0, 0.0, 0.0, lInputPos ); } if( !lStatus[3] ) { lFriction = 0.15; } if( !lStatus[4] ) { lLength = 0.0; } if( !lStatus[5] ) { lD = 0.1; } if (!lStatus[6]) lTimeDt = 30.0; if (!lStatus[7]) lZeroFrame = 0.0; if (!lStatus[8]) lRealTime = 1.0; const double resetLimit = 20.0; // Get the current evaluation time, indicating if recording. #ifdef OLD_FBEVALUATE_LOCALTIME // Get the current evaluation time, indicating if recording. if( lRealTime > 0.0 ) { lEvaluationTime = FBSystem().SystemTime; mDeltaTimeDouble += lEvaluationTime.GetSecondDouble() - lastSystemTimeDouble; if (mDeltaTimeDouble > resetLimit) { lastSystemTimeDouble = lEvaluationTime.GetSecondDouble(); mDeltaTimeDouble = 0.0; mReset = true; } } else { lEvaluationTime = pEvaluateInfo->GetLocalStart(); mDeltaTimeDouble += lEvaluationTime.GetSecondDouble() - lastLocalTimeDouble; if (mDeltaTimeDouble > resetLimit || lEvaluationTime.GetFrame() == (int)lZeroFrame) { lastLocalTimeDouble = lEvaluationTime.GetSecondDouble(); mDeltaTimeDouble = 0.0; mReset = true; } } lLocalTime = pEvaluateInfo->GetLocalStart(); #else // Get the current evaluation time, indicating if recording. if( lRealTime > 0.0 ) { lEvaluationTime = pEvaluateInfo->GetSystemTime(); mDeltaTimeDouble += lEvaluationTime.GetSecondDouble() - lastSystemTimeDouble; if (mDeltaTimeDouble > resetLimit) { lastSystemTimeDouble = lEvaluationTime.GetSecondDouble(); mDeltaTimeDouble = 0.0; mReset = true; } } else { lEvaluationTime = pEvaluateInfo->GetLocalTime(); mDeltaTimeDouble += lEvaluationTime.GetSecondDouble() - lastLocalTimeDouble; if (mDeltaTimeDouble > resetLimit || lEvaluationTime.GetFrame() == (int)lZeroFrame) { lastLocalTimeDouble = lEvaluationTime.GetSecondDouble(); mDeltaTimeDouble = 0.0; mReset = true; } } lLocalTime = pEvaluateInfo->GetLocalTime(); #endif if ( mReset ) { VectorSet( 0.0, 0.0, 0.0, mVel ); mCurrentPos = lInputPos; // at start mass pos and input pos is equal lR = lInputPos; mOldPos = lInputPos; mReset = false; } else { if (lTimeDt == 0.0) lTimeDt = 30.0; else if (lTimeDt < 0.0) lTimeDt = fabsl(lTimeDt); if (lTimeDt > 200.0) lTimeDt = 200.0; const double dt = 1.0 / lTimeDt; SpringSettings settings(lLength, lFriction, lM, lS, lD); lHold = lInputPos; //printf( "delta time double - %.2f\n", (float) mDeltaTimeDouble ); while( mDeltaTimeDouble > dt ) { //printf( "vel length - %.2f\n", (float)FBLength( FBTVector(mVel[0], mVel[1], mVel[2], 0.0) ) ); CalculateSpring( dt, lInputPos, mCurrentPos, mOldPos, settings, mVel, mCurrentPos ); mDeltaTimeDouble -= dt; } lR = mCurrentPos; mOldPos = mCurrentPos; } if( lRealTime > 0.0 ) { lastSystemTimeDouble = lEvaluationTime.GetSecondDouble(); } else { lastLocalTimeDouble = lEvaluationTime.GetSecondDouble(); } // Write result out to connector. mResultNode->WriteData( &lR[0], pEvaluateInfo ); return true; } /************************************************ * FBX Storage. ************************************************/ bool CBoxSpring::FbxStore( FBFbxObject *pFbxObject, kFbxObjectStore pStoreWhat ) { /* * Store box parameters. */ return true; } /************************************************ * FBX Retrieval. ************************************************/ bool CBoxSpring::FbxRetrieve(FBFbxObject *pFbxObject, kFbxObjectStore pStoreWhat ) { /* * Retrieve box parameters. */ return true; }
25.203349
182
0.625914
Mikkelbf
d56da687f54879debee3aa016e468bdf7c357561
7,864
cpp
C++
sparta/test/Argos/DatabaseDump/Database_dumper.cpp
knute-sifive/map
fb25626830a56ad68ab896bcd01929023ff31c48
[ "MIT" ]
null
null
null
sparta/test/Argos/DatabaseDump/Database_dumper.cpp
knute-sifive/map
fb25626830a56ad68ab896bcd01929023ff31c48
[ "MIT" ]
null
null
null
sparta/test/Argos/DatabaseDump/Database_dumper.cpp
knute-sifive/map
fb25626830a56ad68ab896bcd01929023ff31c48
[ "MIT" ]
null
null
null
#include "sparta/argos/Reader.hpp" #include "sparta/argos/PipelineDataCallback.hpp" #include "sparta/utils/SpartaAssert.hpp" #include "sparta/utils/SpartaTester.hpp" #include <iomanip> #include <unordered_map> #include <functional> #include <unistd.h> /** * \file Database_dumper.cpp * \brief dump an argos database to a human readable format. * Instructions, run ./ArgosDumper <path+database prefix> * the database prefix should be the same prefix passed to the simulator when creating the database * example * ./ArgosDumper ../../fiat/data_ > out.csv * * I recommend dumping the output to an *.csv file. Then in open office you can set the file to * recognize spaces as new columns. If you do this, then you will have a nice output formatted table * that should be a little easier to read/manipulate using sort functionality and what not in office. */ namespace sparta { namespace argos { class DumpCallback : public PipelineDataCallback { bool merge_transactions = false; bool sort_by_end_time = false; std::unordered_map<uint16_t, std::shared_ptr<transaction_t> > continued_transactions; std::vector<std::string> output_buffer; // Returns whether the given transaction is split across a heartbeat bool isContinued(transaction_t *t) { return (t->flags & CONTINUE_FLAG) != 0; } // Prints a transaction to output_buffer // This is used for the default sort mode (by transaction ID) when merging transactions template<typename T> void printToBuf(T* t, void(*print_func)(T*, std::ostream &)) { std::stringstream sstr; uint64_t trans_id = t->transaction_ID; print_func(t, sstr); if(output_buffer.size() <= trans_id) { output_buffer.resize(trans_id + 1); } output_buffer[trans_id] = sstr.str(); } template<typename T> void genericTransactionHandler(T* t, void(*print_func)(T*, std::ostream &)) { // If there's no merging, then we can just print the transaction and be done if(!merge_transactions) { print_func(t, std::cout); return; } uint16_t loc_id = t->location_ID; std::stringstream sstr; // This transaction has already been encountered and is split across a heartbeat boundary if(continued_transactions.count(loc_id)) { // Update the saved transaction with the latest end time std::shared_ptr<T> cont_trans = std::static_pointer_cast<T>(continued_transactions.at(loc_id)); cont_trans->time_End = t->time_End; // If this transaction isn't continued, then it's the last one in the chain. So, we can print it and delete the entry. if(!isContinued(t)) { if(!sort_by_end_time) { // This will be out of order with respect to transaction ID, so print it to the buffer instead of stdout printToBuf<T>(cont_trans.get(), print_func); } else { // We're sorting by end time, so we can just print directly to stdout print_func(cont_trans.get(), std::cout); } continued_transactions.erase(loc_id); } } else { // This is the first part of a transaction that has been split across a heartbeat boundary if(isContinued(t)) { continued_transactions[loc_id] = std::make_shared<T>(*t); } // This transaction isn't split at all else { if(!sort_by_end_time) { // This will be out of order with respect to transaction ID, so print it to the buffer instead of stdout printToBuf<T>(t, print_func); } else { // We're sorting by end time, so we can just print directly to stdout print_func(t, std::cout); } } } } static void printInst(instruction_t *t, std::ostream & sout) { sout << std::setbase(10); sout << "*instruction* " << t->transaction_ID << " @ " << t->location_ID << " start: " << t->time_Start << " end: "<<t->time_End; sout << " opcode: " << std::setbase(16) << std::showbase << t->operation_Code << " vaddr: " << t->virtual_ADR; sout << " real_addr: " << t->real_ADR << std::endl; } virtual void foundInstRecord(instruction_t*t) { genericTransactionHandler<instruction_t>(t, &printInst); } static void printMemOp(memoryoperation_t *t, std::ostream & sout) { sout << std::setbase(10); sout << "*memop* " << t->transaction_ID << " @ " << t->location_ID << " start: " << t->time_Start << " end: "<<t->time_End; sout << std::setbase(16) << std::showbase << " vaddr: " << t->virtual_ADR; sout << " real_addr: " << t->real_ADR << std::endl; } virtual void foundMemRecord(memoryoperation_t*t) { genericTransactionHandler<memoryoperation_t>(t, printMemOp); } static void printPairOp(pair_t * , std::ostream & ){ } virtual void foundPairRecord(pair_t * t){ genericTransactionHandler<pair_t>(t, printPairOp); } static void printAnnotation(annotation_t* , std::ostream & ) { } virtual void foundAnnotationRecord(annotation_t*t) { genericTransactionHandler<annotation_t>(t, printAnnotation); } public: // Sets merge/sort flags void setFlags(bool merge, bool sort) { merge_transactions = merge; sort_by_end_time = sort; } // Print the sorted buffer to stdout void flushBuffer() { for(auto & s : output_buffer) { std::cout << s; } } }; }//namespace sparta }//namespace argos void usage() { std::cerr << "Usage: ArgosDumper [-h] [-m] [-s] argos_db_prefix" << std::endl << "Options:" << std::endl << "\t-h\t\tPrint usage info" << std::endl << "\t-m\t\tMerge transactions that were split by a heartbeat interval" << std::endl << "\t-s\t\tSort output by transaction end time" << std:: endl; } int main(int argc, char ** argv) { sparta::argos::DumpCallback cb; std::string db_path = "db_pipeout/pipeout"; if (argc > 1) { db_path = argv[1]; } bool merge_transactions = false; bool sort_by_end_time = true; cb.setFlags(merge_transactions, sort_by_end_time); sparta::argos::Reader reader(db_path, &cb); // Get data reader.getWindow(reader.getCycleFirst(), reader.getCycleLast()); // If we're sorting by transaction ID, then we need to flush the buffer // In non-merging mode, sorting by transaction ID and end time should be identical if(merge_transactions && !sort_by_end_time) { cb.flushBuffer(); } std::cout << "range: [" << reader.getCycleFirst() << ", " << reader.getCycleLast() << "]" << std::endl; // Check indices std::cout << "Checking indices:" << std::endl; reader.dumpIndexTransactions(); }
34.491228
141
0.552009
knute-sifive
d570dc97b50454ae5075e488d7719a090bfd1215
5,791
cpp
C++
src/engine/entity/src/scripting/nodes/script_logic_gates.cpp
amrezzd/halley
5f6a5dd7d44b9c12d2c124436969ff2dfa69e3f4
[ "Apache-2.0" ]
null
null
null
src/engine/entity/src/scripting/nodes/script_logic_gates.cpp
amrezzd/halley
5f6a5dd7d44b9c12d2c124436969ff2dfa69e3f4
[ "Apache-2.0" ]
null
null
null
src/engine/entity/src/scripting/nodes/script_logic_gates.cpp
amrezzd/halley
5f6a5dd7d44b9c12d2c124436969ff2dfa69e3f4
[ "Apache-2.0" ]
null
null
null
#include "script_logic_gates.h" using namespace Halley; String ScriptLogicGateAnd::getShortDescription(const World& world, const ScriptGraphNode& node, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); return addParentheses(std::move(a)) + " AND " + addParentheses(std::move(b)); } gsl::span<const IScriptNodeType::PinType> ScriptLogicGateAnd::getPinConfiguration(const ScriptGraphNode& node) const { using ET = ScriptNodeElementType; using PD = ScriptNodePinDirection; const static auto data = std::array<PinType, 3>{ PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Output } }; return data; } std::pair<String, Vector<ColourOverride>> ScriptLogicGateAnd::getNodeDescription(const ScriptGraphNode& node, const World& world, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); ColourStringBuilder result; result.append("True if "); result.append(addParentheses(std::move(a)), Colour4f(0.97f, 0.35f, 0.35f)); result.append(" AND "); result.append(addParentheses(std::move(b)), Colour4f(0.97f, 0.35f, 0.35f)); return result.moveResults(); } ConfigNode ScriptLogicGateAnd::doGetData(ScriptEnvironment& environment, const ScriptGraphNode& node, size_t pinN) const { const bool value = readDataPin(environment, node, 0).asBool(false) && readDataPin(environment, node, 1).asBool(false); return ConfigNode(value); } String ScriptLogicGateOr::getShortDescription(const World& world, const ScriptGraphNode& node, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); return addParentheses(std::move(a)) + " OR " + addParentheses(std::move(b)); } gsl::span<const IScriptNodeType::PinType> ScriptLogicGateOr::getPinConfiguration(const ScriptGraphNode& node) const { using ET = ScriptNodeElementType; using PD = ScriptNodePinDirection; const static auto data = std::array<PinType, 3>{ PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Output } }; return data; } std::pair<String, Vector<ColourOverride>> ScriptLogicGateOr::getNodeDescription(const ScriptGraphNode& node, const World& world, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); ColourStringBuilder result; result.append("True if "); result.append(addParentheses(std::move(a)), Colour4f(0.97f, 0.35f, 0.35f)); result.append(" OR "); result.append(addParentheses(std::move(b)), Colour4f(0.97f, 0.35f, 0.35f)); return result.moveResults(); } ConfigNode ScriptLogicGateOr::doGetData(ScriptEnvironment& environment, const ScriptGraphNode& node, size_t pinN) const { const bool value = readDataPin(environment, node, 0).asBool(false) || readDataPin(environment, node, 1).asBool(false); return ConfigNode(value); } String ScriptLogicGateXor::getShortDescription(const World& world, const ScriptGraphNode& node, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); return addParentheses(std::move(a)) + " XOR " + addParentheses(std::move(b)); } gsl::span<const IScriptNodeType::PinType> ScriptLogicGateXor::getPinConfiguration(const ScriptGraphNode& node) const { using ET = ScriptNodeElementType; using PD = ScriptNodePinDirection; const static auto data = std::array<PinType, 3>{ PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Output } }; return data; } std::pair<String, Vector<ColourOverride>> ScriptLogicGateXor::getNodeDescription(const ScriptGraphNode& node, const World& world, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); auto b = getConnectedNodeName(world, node, graph, 1); ColourStringBuilder result; result.append("True if "); result.append(addParentheses(std::move(a)), Colour4f(0.97f, 0.35f, 0.35f)); result.append(" XOR "); result.append(addParentheses(std::move(b)), Colour4f(0.97f, 0.35f, 0.35f)); return result.moveResults(); } ConfigNode ScriptLogicGateXor::doGetData(ScriptEnvironment& environment, const ScriptGraphNode& node, size_t pinN) const { const bool value = (readDataPin(environment, node, 0).asBool(false) ^ readDataPin(environment, node, 1).asBool(false)) != 0; return ConfigNode(value); } String ScriptLogicGateNot::getShortDescription(const World& world, const ScriptGraphNode& node, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); return "NOT " + addParentheses(std::move(a)); } gsl::span<const IScriptNodeType::PinType> ScriptLogicGateNot::getPinConfiguration(const ScriptGraphNode& node) const { using ET = ScriptNodeElementType; using PD = ScriptNodePinDirection; const static auto data = std::array<PinType, 2>{ PinType{ ET::ReadDataPin, PD::Input }, PinType{ ET::ReadDataPin, PD::Output } }; return data; } std::pair<String, Vector<ColourOverride>> ScriptLogicGateNot::getNodeDescription(const ScriptGraphNode& node, const World& world, const ScriptGraph& graph) const { auto a = getConnectedNodeName(world, node, graph, 0); ColourStringBuilder result; result.append("True if NOT "); result.append(addParentheses(std::move(a)), Colour4f(0.97f, 0.35f, 0.35f)); return result.moveResults(); } ConfigNode ScriptLogicGateNot::doGetData(ScriptEnvironment& environment, const ScriptGraphNode& node, size_t pinN) const { const bool value = !readDataPin(environment, node, 0).asBool(false); return ConfigNode(value); }
42.896296
169
0.756346
amrezzd
d573bc75a0042247c0b732f147440ff8edfefe5b
8,243
cpp
C++
src/main.cpp
ysono/CarND-T3P1-Path-Planning
1df4812381f51c22c35d46c9ae06a7a3f1eb68cb
[ "MIT" ]
null
null
null
src/main.cpp
ysono/CarND-T3P1-Path-Planning
1df4812381f51c22c35d46c9ae06a7a3f1eb68cb
[ "MIT" ]
null
null
null
src/main.cpp
ysono/CarND-T3P1-Path-Planning
1df4812381f51c22c35d46c9ae06a7a3f1eb68cb
[ "MIT" ]
null
null
null
#include <fstream> #include <math.h> #include <uWS/uWS.h> #include <chrono> #include <iostream> #include <thread> #include <tuple> #include <vector> #include <functional> #include "Eigen-3.3/Eigen/Core" #include "Eigen-3.3/Eigen/QR" #include "json.hpp" #include "support.h" using std::cout; using std::endl; using std::string; using std::vector; using nlohmann::json; // For converting back and forth between radians and degrees. constexpr double pi() { return M_PI; } double deg2rad(double x) { return x * pi() / 180; } double rad2deg(double x) { return x * 180 / pi(); } // Checks if the SocketIO event has JSON data. // If there is data the JSON object in string format will be returned, // else the empty string "" will be returned. string hasData(string s) { auto found_null = s.find("null"); auto b1 = s.find_first_of("["); auto b2 = s.find_first_of("}"); if (found_null != string::npos) { return ""; } else if (b1 != string::npos && b2 != string::npos) { return s.substr(b1, b2 - b1 + 2); } return ""; } // Transform from Frenet s,d coordinates to Cartesian x,y vector<double> getXY(double s, double d, const vector<double> &maps_s, const vector<double> &maps_x, const vector<double> &maps_y) { int prev_wp = -1; while(s > maps_s[prev_wp+1] && (prev_wp < (int)(maps_s.size()-1) )) { prev_wp++; } int wp2 = (prev_wp+1)%maps_x.size(); double heading = atan2((maps_y[wp2]-maps_y[prev_wp]),(maps_x[wp2]-maps_x[prev_wp])); // the x,y,s along the segment double seg_s = (s-maps_s[prev_wp]); double seg_x = maps_x[prev_wp]+seg_s*cos(heading); double seg_y = maps_y[prev_wp]+seg_s*sin(heading); double perp_heading = heading-pi()/2; double x = seg_x + d*cos(perp_heading); double y = seg_y + d*sin(perp_heading); return {x,y}; } int main(int argc, char* argv[]) { PP_DEBUG = argc >= 2 && strcmp(argv[1], "--debug") == 0; uWS::Hub h; // Load up map values for waypoint's x,y,s and d normalized normal vectors vector<double> map_waypoints_x; vector<double> map_waypoints_y; vector<double> map_waypoints_s; vector<double> map_waypoints_dx; vector<double> map_waypoints_dy; // Waypoint map to read from string map_file_ = "../data/highway_map.csv"; // The max s value before wrapping around the track back to 0 double max_s = 6945.554; std::ifstream in_map_(map_file_.c_str(), std::ifstream::in); string line; while (getline(in_map_, line)) { std::istringstream iss(line); double x; double y; float s; float d_x; float d_y; iss >> x; iss >> y; iss >> s; iss >> d_x; iss >> d_y; map_waypoints_x.push_back(x); map_waypoints_y.push_back(y); map_waypoints_s.push_back(s); map_waypoints_dx.push_back(d_x); map_waypoints_dy.push_back(d_y); } std::function<vector<double>(double, double)> sd_to_xy = [&map_waypoints_s, &map_waypoints_x, &map_waypoints_y] (double s, double d) { return getXY(s, d, map_waypoints_s, map_waypoints_x, map_waypoints_y); }; FSM fsm {KEEP_LANE, 1, SPEED_LIMIT}; // A requried property of the previously planned path that's not retained and // provided by the simulator. double end_path_speed = 0; h.onMessage( [&fsm, &end_path_speed, &sd_to_xy] (uWS::WebSocket<uWS::SERVER> ws, char *data, size_t length, uWS::OpCode opCode) { //auto sdata = string(data).substr(0, length); //cout << sdata << endl; // "42" at the start of the message means there's a websocket message event. // The 4 signifies a websocket message // The 2 signifies a websocket event if (length && length > 2 && data[0] == '4' && data[1] == '2') { auto s = hasData(data); if (s != "") { auto j = json::parse(s); string event = j[0].get<string>(); if (event == "telemetry") { // j[1] is the data JSON object Telemetry telemetry; // Main car's localization Data telemetry.now_x = j[1]["x"]; telemetry.now_y = j[1]["y"]; telemetry.now_s = j[1]["s"]; telemetry.now_d = j[1]["d"]; double now_yaw = j[1]["yaw"]; // deg telemetry.now_yaw = deg2rad(now_yaw); // rad telemetry.now_speed = j[1]["speed"]; // keep all speed vars as mph // Previous path data given to the Planner vector<double> future_path_x = j[1]["previous_path_x"]; vector<double> future_path_y = j[1]["previous_path_y"]; telemetry.future_path_x = future_path_x; telemetry.future_path_y = future_path_y; telemetry.future_path_size = future_path_x.size(); telemetry.future_path_duration = PATH_INTERVAL * telemetry.future_path_size; // Previous path's end s and d values telemetry.future_s = j[1]["end_path_s"]; telemetry.future_d = j[1]["end_path_d"]; telemetry.future_speed = end_path_speed; // Sensor Fusion Data, a list of all other cars on the same side of the road. vector<vector<double> > now_obstacles = j[1]["sensor_fusion"]; telemetry.now_obstacles = now_obstacles; ////// End of unravelling telemtry data ////// if (PP_DEBUG) { cout << "======" << endl << fsm; } vector<double> next_path_x, next_path_y; if (telemetry.future_path_size >= NUM_OUTPUT_PATH_POINTS) { if (PP_DEBUG) { cout << "no need to generate path points" << endl; } } else { if (telemetry.future_path_size == 0) { telemetry.future_s = telemetry.now_s; telemetry.future_d = telemetry.now_d; } fsm = iterate_fsm(fsm, telemetry); // For all modes, adjust acceleration only. // We're using the same speed for all path points to be added. // Although it would be more effective to use different speeds for // points to be added, in practice it should make little difference // becuase we rarely have to generate more than 1 to 3 points. if (end_path_speed < fsm.target_speed) { end_path_speed += DEFAULT_ACCEL; } else { end_path_speed -= DEFAULT_ACCEL; } std::tie(next_path_x, next_path_y) = generate_path( fsm.target_lane, end_path_speed, telemetry, sd_to_xy); } ////// Finished generating path ////// json msgJson; msgJson["next_x"] = next_path_x; msgJson["next_y"] = next_path_y; auto msg = "42[\"control\","+ msgJson.dump()+"]"; ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); //this_thread::sleep_for(chrono::milliseconds(1000)); } } else { // Manual driving std::string msg = "42[\"manual\",{}]"; ws.send(msg.data(), msg.length(), uWS::OpCode::TEXT); } } }); // We don't need this since we're not using HTTP but if it's removed the // program // doesn't compile :-( h.onHttpRequest([](uWS::HttpResponse *res, uWS::HttpRequest req, char *data, size_t, size_t) { const std::string s = "<h1>Hello world!</h1>"; if (req.getUrl().valueLength == 1) { res->end(s.data(), s.length()); } else { // i guess this should be done more gracefully? res->end(nullptr, 0); } }); h.onConnection([&h](uWS::WebSocket<uWS::SERVER> ws, uWS::HttpRequest req) { std::cout << "Connected!!!" << std::endl; }); h.onDisconnection([&h](uWS::WebSocket<uWS::SERVER> ws, int code, char *message, size_t length) { ws.close(); std::cout << "Disconnected" << std::endl; }); int port = 4567; if (h.listen(port)) { std::cout << "Listening to port " << port << std::endl; } else { std::cerr << "Failed to listen to port" << std::endl; return -1; } h.run(); }
32.07393
131
0.582798
ysono
d575ed33c151f988d5b6bfdbec60ddfe488f3891
213
cpp
C++
src/var/ConstString.cpp
bander9289/StratifyAPI
9b45091aa71a4e5718047438ea4044c1fdc814a3
[ "MIT" ]
2
2016-05-21T03:09:19.000Z
2016-08-27T03:40:51.000Z
src/var/ConstString.cpp
bander9289/StratifyAPI
9b45091aa71a4e5718047438ea4044c1fdc814a3
[ "MIT" ]
75
2017-10-08T22:21:19.000Z
2020-03-30T21:13:20.000Z
src/var/ConstString.cpp
StratifyLabs/StratifyLib
975a5c25a84296fd0dec64fe4dc579cf7027abe6
[ "MIT" ]
5
2018-03-27T16:44:09.000Z
2020-07-08T16:45:55.000Z
/*! \file */ // Copyright 2011-2020 Tyler Gilbert and Stratify Labs, Inc; see LICENSE.md for rights. #include "var/ConstString.hpp" #include "var/Data.hpp" using namespace var; u32 sapi_const_string_unused;
17.75
100
0.737089
bander9289
d57789c51db7859511e6e61ceb723422b33327ee
10,500
cpp
C++
PS_Fgen_FW/Screens/ScreenPS.cpp
M1S2/PS_Fgen_FW
3fca0e33487b95cd1a5b4c2e9ea0d4f9f7a4dd97
[ "MIT" ]
null
null
null
PS_Fgen_FW/Screens/ScreenPS.cpp
M1S2/PS_Fgen_FW
3fca0e33487b95cd1a5b4c2e9ea0d4f9f7a4dd97
[ "MIT" ]
11
2021-06-08T13:08:46.000Z
2021-12-11T13:50:54.000Z
PS_Fgen_FW/Screens/ScreenPS.cpp
M1S2/PS_Fgen_FW
3fca0e33487b95cd1a5b4c2e9ea0d4f9f7a4dd97
[ "MIT" ]
1
2021-06-25T12:26:36.000Z
2021-06-25T12:26:36.000Z
/* * ScreenPS.cpp * Created: 07.11.2020 13:09:35 * Author: Markus Scheich */ #include "../Device.h" #ifdef PS_SUBSYSTEM_ENABLED ContainerList list_PS(SCREEN_TAB_WIDTH, 0, 240 - SCREEN_TAB_WIDTH, 64); #define PS_COLUMN1_POSX SCREEN_TAB_WIDTH + 5 #define PS_COLUMN2_POSX PS_COLUMN1_POSX + 83 #define PS_COLUMN3_POSX PS_COLUMN2_POSX + 57 #define PS_ROW1_POSY 25 #define PS_ROW2_POSY PS_ROW1_POSY + 20 void PSProtectionsClear(void* controlContext); void PSProtectionsClearedOK(void* controlContext); // ***** Power Supply Overview page ***** ContainerPage page_PSOverview; Icon ico_PSOverview(SCREEN_TAB_WIDTH + 5, 3, icon_supplyDC_width, icon_supplyDC_height, icon_supplyDC_bits); Label<15> lbl_PSOverview_caption(SCREEN_TAB_WIDTH + 25, 5, "PowerSupply"); Icon ico_PSOverviewVoltage(PS_COLUMN1_POSX, PS_ROW1_POSY - 2, icon_voltage_width, icon_voltage_height, icon_voltage_bits); NumericControl<float> numCtrl_PSOverviewVoltage(PS_COLUMN1_POSX + icon_voltage_width + 3, PS_ROW1_POSY, &Device.PsChannel.Voltage.Val, "V", PS_MIN_VOLTAGE, PS_MAX_VOLTAGE, 3, &Device.PsChannel, &PS_Channel::PSVoltageChanged); Icon ico_PSOverviewEnabled(PS_COLUMN2_POSX, PS_ROW1_POSY - 2, icon_OnOff_width, icon_OnOff_height, icon_OnOff_bits); BoolControl boolCtrl_PSOverviewEnabled(PS_COLUMN2_POSX + icon_OnOff_width + 3, PS_ROW1_POSY, &Device.PsChannel.Enabled.Val, &Device.PsChannel, &PS_Channel::PSEnabledChanged); Icon ico_PSOverviewCurrent(PS_COLUMN1_POSX, PS_ROW2_POSY - 2, icon_current_width, icon_current_height, icon_current_bits); NumericControl<float> numCtrl_PSOverviewCurrent(PS_COLUMN1_POSX + icon_current_width + 3, PS_ROW2_POSY, &Device.PsChannel.Current.Val, "A", PS_MIN_CURRENT, PS_MAX_CURRENT, 3, &Device.PsChannel, &PS_Channel::PSCurrentChanged); Icon ico_PSOverviewRegMode(PS_COLUMN2_POSX, PS_ROW2_POSY - 2, icon_pin_width, icon_pin_height, icon_pin_bits); EnumControl<volatile PsRegulationModes_t> enumCtrl_PSOverviewRegMode(PS_COLUMN2_POSX + icon_pin_width + 3, PS_ROW2_POSY, &Device.PsChannel.RegulationMode, PsRegulationModesNames, NUM_PS_REG_MODE_ELEMENTS, &Device.PsChannel, &PS_Channel::PSRegulationModeChanged); NumericIndicator<volatile float, 10> numInd_PsOverviewVoltage(PS_COLUMN3_POSX, 18, &Device.PsChannel.MeasuredVoltage, "V", PS_MAX_VOLTAGE, 3); NumericIndicator<volatile float, 10> numInd_PsOverviewCurrent(PS_COLUMN3_POSX, 28, &Device.PsChannel.MeasuredCurrent, "A", PS_MAX_CURRENT, 3); NumericIndicator<volatile float, 10> numInd_PsOverviewPower(PS_COLUMN3_POSX, 38, &Device.PsChannel.MeasuredPower, "W", PS_MAX_VOLTAGE * PS_MAX_CURRENT, 3); EnumIndicator<volatile PsStates_t> enumInd_PsOverviewState(PS_COLUMN3_POSX + 4, 48, &Device.PsChannel.PsState, PsStatesNames, NUM_PS_STATE_ELEMENTS); // ***** Power Supply Protection OVP page ***** ContainerPage page_PSProtectionOVP; Icon ico_PSProtection(40, 3, icon_protection_width, icon_protection_height, icon_protection_bits); Label<5> lbl_PSProtectionOVP_caption(60, 5, "OVP"); Icon ico_PSProtectionOVPLevel(PS_COLUMN1_POSX, PS_ROW1_POSY - 2, icon_level_width, icon_level_height, icon_level_bits); NumericControl<uint8_t> numCtrl_PSProtectionOVPLevel(PS_COLUMN1_POSX + icon_level_width + 3, PS_ROW1_POSY, &Device.PsChannel.OvpLevel.Val, "%%", PS_MIN_OVP_LEVEL_PERCENTAGE, PS_MAX_OVP_LEVEL_PERCENTAGE, 0, &Device.PsChannel, &PS_Channel::PSOvpLevelChanged); Icon ico_PSProtectionOVPState(PS_COLUMN2_POSX, PS_ROW1_POSY - 2, icon_OnOff_width, icon_OnOff_height, icon_OnOff_bits); BoolControl boolCtrl_PSProtectionOVPState(PS_COLUMN2_POSX + icon_OnOff_width + 3, PS_ROW1_POSY, &Device.PsChannel.OvpState.Val, &Device.PsChannel, &PS_Channel::PSOvpStateChanged); Icon ico_PSProtectionOVPDelay(PS_COLUMN1_POSX, PS_ROW2_POSY - 2, icon_delay_width, icon_delay_height, icon_delay_bits); NumericControl<float> numCtrl_PSProtectionOVPDelay(PS_COLUMN1_POSX + icon_delay_width + 3, PS_ROW2_POSY, &Device.PsChannel.OvpDelay.Val, "s", PS_MIN_OVP_DELAY, PS_MAX_OVP_DELAY, 3, &Device.PsChannel, &PS_Channel::PSOvpDelayChanged); ButtonControl<6> button_PSProtectionOVPClear(PS_COLUMN2_POSX, PS_ROW2_POSY, DEFAULT_UI_ELEMENT_WIDTH, DEFAULT_UI_ELEMENT_HEIGHT, "Clear", &Device.PsChannel, &PSProtectionsClear); // ***** Power Supply Protection OCP page ***** ContainerPage page_PSProtectionOCP; Label<5> lbl_PSProtectionOCP_caption(60, 5, "OCP"); Icon ico_PSProtectionOCPLevel(PS_COLUMN1_POSX, PS_ROW1_POSY - 2, icon_level_width, icon_level_height, icon_level_bits); NumericControl<uint8_t> numCtrl_PSProtectionOCPLevel(PS_COLUMN1_POSX + icon_level_width + 3, PS_ROW1_POSY, &Device.PsChannel.OcpLevel.Val, "%%", PS_MIN_OCP_LEVEL_PERCENTAGE, PS_MAX_OCP_LEVEL_PERCENTAGE, 0, &Device.PsChannel, &PS_Channel::PSOcpLevelChanged); Icon ico_PSProtectionOCPState(PS_COLUMN2_POSX, PS_ROW1_POSY - 2, icon_OnOff_width, icon_OnOff_height, icon_OnOff_bits); BoolControl boolCtrl_PSProtectionOCPState(PS_COLUMN2_POSX + icon_OnOff_width + 3, PS_ROW1_POSY, &Device.PsChannel.OcpState.Val, &Device.PsChannel, &PS_Channel::PSOcpStateChanged); Icon ico_PSProtectionOCPDelay(PS_COLUMN1_POSX, PS_ROW2_POSY - 2, icon_delay_width, icon_delay_height, icon_delay_bits); NumericControl<float> numCtrl_PSProtectionOCPDelay(PS_COLUMN1_POSX + icon_delay_width + 3, PS_ROW2_POSY, &Device.PsChannel.OcpDelay.Val, "s", PS_MIN_OCP_DELAY, PS_MAX_OCP_DELAY, 3, &Device.PsChannel, &PS_Channel::PSOcpDelayChanged); ButtonControl<6> button_PSProtectionOCPClear(PS_COLUMN2_POSX, PS_ROW2_POSY, DEFAULT_UI_ELEMENT_WIDTH, DEFAULT_UI_ELEMENT_HEIGHT, "Clear", &Device.PsChannel, &PSProtectionsClear); // ***** Power Supply Protection OPP page ***** ContainerPage page_PSProtectionOPP; Label<5> lbl_PSProtectionOPP_caption(60, 5, "OPP"); Icon ico_PSProtectionOPPLevel(PS_COLUMN1_POSX, PS_ROW1_POSY - 2, icon_level_width, icon_level_height, icon_level_bits); NumericControl<float> numCtrl_PSProtectionOPPLevel(PS_COLUMN1_POSX + icon_level_width + 3, PS_ROW1_POSY, &Device.PsChannel.OppLevel.Val, "W", PS_MIN_OPP_LEVEL, PS_MAX_OPP_LEVEL, 3, &Device.PsChannel, &PS_Channel::PSOppLevelChanged); Icon ico_PSProtectionOPPState(PS_COLUMN2_POSX, PS_ROW1_POSY - 2, icon_OnOff_width, icon_OnOff_height, icon_OnOff_bits); BoolControl boolCtrl_PSProtectionOPPState(PS_COLUMN2_POSX + icon_OnOff_width + 3, PS_ROW1_POSY, &Device.PsChannel.OppState.Val, &Device.PsChannel, &PS_Channel::PSOppStateChanged); Icon ico_PSProtectionOPPDelay(PS_COLUMN1_POSX, PS_ROW2_POSY - 2, icon_delay_width, icon_delay_height, icon_delay_bits); NumericControl<float> numCtrl_PSProtectionOPPDelay(PS_COLUMN1_POSX + icon_delay_width + 3, PS_ROW2_POSY, &Device.PsChannel.OppDelay.Val, "s", PS_MIN_OPP_DELAY, PS_MAX_OPP_DELAY, 3, &Device.PsChannel, &PS_Channel::PSOppDelayChanged); ButtonControl<6> button_PSProtectionOPPClear(PS_COLUMN2_POSX, PS_ROW2_POSY, DEFAULT_UI_ELEMENT_WIDTH, DEFAULT_UI_ELEMENT_HEIGHT, "Clear", &Device.PsChannel, &PSProtectionsClear); MessageDialog<25> msg_protectionsCleared(0, 0, 240, 64, "Protections Cleared.", MSG_INFO, MSG_BTN_OK, NULL, &PSProtectionsClearedOK); void PSProtectionsClear(void* controlContext) { Device.PsChannel.ClearProtections(); Device.ScreenManager.UiManager.ChangeVisualTreeRoot(&msg_protectionsCleared); } void PSProtectionsClearedOK(void* controlContext) { Device.ScreenManager.ShowUiMainPage(); } UIElement* uiBuildScreenPS() { enumCtrl_PSOverviewRegMode.Width = 39; numCtrl_PSOverviewVoltage.CurrentDigitPosition = -1; // select the 0.1 V digit. numCtrl_PSOverviewCurrent.CurrentDigitPosition = -1; // select the 0.1 A digit. page_PSOverview.AddItem(&ico_PSOverview); page_PSOverview.AddItem(&lbl_PSOverview_caption); page_PSOverview.AddItem(&ico_PSOverviewVoltage); page_PSOverview.AddItem(&numCtrl_PSOverviewVoltage); page_PSOverview.AddItem(&ico_PSOverviewEnabled); page_PSOverview.AddItem(&boolCtrl_PSOverviewEnabled); page_PSOverview.AddItem(&ico_PSOverviewCurrent); page_PSOverview.AddItem(&numCtrl_PSOverviewCurrent); page_PSOverview.AddItem(&ico_PSOverviewRegMode); page_PSOverview.AddItem(&enumCtrl_PSOverviewRegMode); page_PSOverview.AddItem(&numInd_PsOverviewVoltage); page_PSOverview.AddItem(&numInd_PsOverviewCurrent); page_PSOverview.AddItem(&numInd_PsOverviewPower); page_PSOverview.AddItem(&enumInd_PsOverviewState); page_PSOverview.InitItems(); numCtrl_PSProtectionOVPDelay.CurrentDigitPosition = -1; // select the 0.1 s digit. page_PSProtectionOVP.AddItem(&ico_PSProtection); page_PSProtectionOVP.AddItem(&lbl_PSProtectionOVP_caption); page_PSProtectionOVP.AddItem(&ico_PSProtectionOVPLevel); page_PSProtectionOVP.AddItem(&numCtrl_PSProtectionOVPLevel); page_PSProtectionOVP.AddItem(&ico_PSProtectionOVPState); page_PSProtectionOVP.AddItem(&boolCtrl_PSProtectionOVPState); page_PSProtectionOVP.AddItem(&ico_PSProtectionOVPDelay); page_PSProtectionOVP.AddItem(&numCtrl_PSProtectionOVPDelay); page_PSProtectionOVP.AddItem(&button_PSProtectionOVPClear); page_PSProtectionOVP.InitItems(); numCtrl_PSProtectionOCPDelay.CurrentDigitPosition = -1; // select the 0.1 s digit. page_PSProtectionOCP.AddItem(&ico_PSProtection); page_PSProtectionOCP.AddItem(&lbl_PSProtectionOCP_caption); page_PSProtectionOCP.AddItem(&ico_PSProtectionOCPLevel); page_PSProtectionOCP.AddItem(&numCtrl_PSProtectionOCPLevel); page_PSProtectionOCP.AddItem(&ico_PSProtectionOCPState); page_PSProtectionOCP.AddItem(&boolCtrl_PSProtectionOCPState); page_PSProtectionOCP.AddItem(&ico_PSProtectionOCPDelay); page_PSProtectionOCP.AddItem(&numCtrl_PSProtectionOCPDelay); page_PSProtectionOCP.AddItem(&button_PSProtectionOCPClear); page_PSProtectionOCP.InitItems(); numCtrl_PSProtectionOPPLevel.CurrentDigitPosition = -1; // select the 0.1 s digit. numCtrl_PSProtectionOPPDelay.CurrentDigitPosition = -1; // select the 0.1 s digit. page_PSProtectionOPP.AddItem(&ico_PSProtection); page_PSProtectionOPP.AddItem(&lbl_PSProtectionOPP_caption); page_PSProtectionOPP.AddItem(&ico_PSProtectionOPPLevel); page_PSProtectionOPP.AddItem(&numCtrl_PSProtectionOPPLevel); page_PSProtectionOPP.AddItem(&ico_PSProtectionOPPState); page_PSProtectionOPP.AddItem(&boolCtrl_PSProtectionOPPState); page_PSProtectionOPP.AddItem(&ico_PSProtectionOPPDelay); page_PSProtectionOPP.AddItem(&numCtrl_PSProtectionOPPDelay); page_PSProtectionOPP.AddItem(&button_PSProtectionOPPClear); page_PSProtectionOPP.InitItems(); list_PS.AddItem(&page_PSOverview); list_PS.AddItem(&page_PSProtectionOVP); list_PS.AddItem(&page_PSProtectionOCP); list_PS.AddItem(&page_PSProtectionOPP); return &list_PS; } #endif /* PS_SUBSYSTEM_ENABLED */
66.037736
262
0.836381
M1S2
d5798e8ed05db34d8c8fb29f13fb7b0c66f3eb67
3,748
cpp
C++
AIEngine/src/path/navmesh/polytope/PolytopePlaneSurface.cpp
petitg1987/urchinEngine
a14a57ac49a19237d748d2eafc7c2a38a45b95d6
[ "BSL-1.0" ]
18
2020-06-12T00:04:46.000Z
2022-01-11T14:56:19.000Z
AIEngine/src/path/navmesh/polytope/PolytopePlaneSurface.cpp
petitg1987/urchinEngine
a14a57ac49a19237d748d2eafc7c2a38a45b95d6
[ "BSL-1.0" ]
null
null
null
AIEngine/src/path/navmesh/polytope/PolytopePlaneSurface.cpp
petitg1987/urchinEngine
a14a57ac49a19237d748d2eafc7c2a38a45b95d6
[ "BSL-1.0" ]
6
2020-08-16T15:58:41.000Z
2022-03-05T13:17:50.000Z
#include <algorithm> #include <path/navmesh/polytope/PolytopePlaneSurface.h> namespace urchin { /** * @param ccwPoints Points of the plane which must be coplanar and counter clockwise oriented */ PolytopePlaneSurface::PolytopePlaneSurface(std::vector<Point3<float>> ccwPoints, bool isSlopeWalkable) : ccwPoints(std::move(ccwPoints)), isSlopeWalkable(isSlopeWalkable) { Vector3<float> v1 = this->ccwPoints[0].vector(this->ccwPoints[2]); Vector3<float> v2 = this->ccwPoints[1].vector(this->ccwPoints[0]); normal = v1.crossProduct(v2).normalize(); buildOutlineCwPoints(); buildAABBox(); } /** * @param ccwPoints Points of the plane which must be coplanar and counter clockwise oriented */ PolytopePlaneSurface::PolytopePlaneSurface(std::vector<Point3<float>> ccwPoints, const Vector3<float>& normal, bool isSlopeWalkable) : ccwPoints(std::move(ccwPoints)), normal(normal), isSlopeWalkable(isSlopeWalkable) { buildOutlineCwPoints(); buildAABBox(); } void PolytopePlaneSurface::buildOutlineCwPoints() { outlineCwPoints.reserve(ccwPoints.size()); for (auto it = ccwPoints.rbegin(); it != ccwPoints.rend(); ++it) { outlineCwPoints.emplace_back(Point2<float>(it->X, -it->Z)); } } void PolytopePlaneSurface::buildAABBox() { aabbox = AABBox<float>(ccwPoints); } bool PolytopePlaneSurface::isWalkable() const { return isWalkableCandidate() && isSlopeWalkable; } Rectangle<float> PolytopePlaneSurface::computeXZRectangle() const { Point2<float> minPoint(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()); Point2<float> maxPoint(-std::numeric_limits<float>::max(), -std::numeric_limits<float>::max()); for (const auto& point : ccwPoints) { minPoint.X = minPoint.X > point.X ? point.X : minPoint.X; minPoint.Y = minPoint.Y > -point.Z ? -point.Z : minPoint.Y; maxPoint.X = maxPoint.X < point.X ? point.X : minPoint.X; maxPoint.Y = maxPoint.Y < -point.Z ? -point.Z : minPoint.Y; } return Rectangle<float>(minPoint, maxPoint); } const AABBox<float>& PolytopePlaneSurface::getAABBox() const { return aabbox; } const std::vector<Point2<float>>& PolytopePlaneSurface::getOutlineCwPoints() const { return outlineCwPoints; } Plane<float> PolytopePlaneSurface::getPlane(const Rectangle<float>&) const { return Plane<float>(ccwPoints[0], ccwPoints[1], ccwPoints[2]); } const std::vector<CSGPolygon<float>>& PolytopePlaneSurface::getSelfObstacles() const { return selfObstacles; } /** * Return point on un-expanded surface */ Point3<float> PolytopePlaneSurface::computeRealPoint(const Point2<float>& point, const NavMeshAgent& agent) const { Point3<float> pointOnExpandedSurface(point.X, 0.0, -point.Y); float shortestFaceDistance = normal.dotProduct(pointOnExpandedSurface.vector(ccwPoints[0])); pointOnExpandedSurface.Y += shortestFaceDistance / normal.Y; float reduceDistance = - agent.computeExpandDistance(normal); return pointOnExpandedSurface.translate(normal * reduceDistance); } const std::shared_ptr<const NavTopography>& PolytopePlaneSurface::getNavTopography() const { return nullNavTopography; //no topography for flat surface } const std::vector<Point3<float>>& PolytopePlaneSurface::getCcwPoints() const { return ccwPoints; } const Vector3<float>& PolytopePlaneSurface::getNormal() const { return normal; } }
36.745098
138
0.661686
petitg1987
d581ed3bd62df2d3380dd0e9caa4e20aad775550
7,728
cpp
C++
tests/xtd.core.unit_tests/src/xtd/diagnostics/trace_listener.cpp
BaderEddineOuaich/xtd
6f28634c7949a541d183879d2de18d824ec3c8b1
[ "MIT" ]
1
2022-02-25T16:53:06.000Z
2022-02-25T16:53:06.000Z
tests/xtd.core.unit_tests/src/xtd/diagnostics/trace_listener.cpp
leanid/xtd
2e1ea6537218788ca08901faf8915d4100990b53
[ "MIT" ]
null
null
null
tests/xtd.core.unit_tests/src/xtd/diagnostics/trace_listener.cpp
leanid/xtd
2e1ea6537218788ca08901faf8915d4100990b53
[ "MIT" ]
null
null
null
#define TRACE #include <xtd/diagnostics/trace_listener.h> #include <xtd/xtd.tunit> #include <sstream> using namespace xtd::diagnostics; using namespace xtd::tunit; namespace unit_tests { class test_class_(test_trace_listener) { class unit_test_trace_listener : public trace_listener { public: unit_test_trace_listener() = default; xtd::ustring result() const {return string_stream.str();} void close() override {} void flush() override {} using trace_listener::write; void write(const xtd::ustring& message) override { if (need_indent()) write_indent(); string_stream << message; } using trace_listener::write_line; void write_line(const xtd::ustring& message) override { write(message); string_stream << std::endl; need_indent(true); } using trace_listener::need_indent; private: std::stringstream string_stream; }; public: void test_method_(new_trace_listener) { unit_test_trace_listener trace_listener; assert::are_equal(0U, trace_listener.indent_level(), csf_); assert::are_equal(4U, trace_listener.indent_size(), csf_); assert::is_false(trace_listener.is_thread_safe(), csf_); assert::is_empty(trace_listener.name(), csf_); assert::is_true(trace_listener.need_indent(), csf_); assert::are_equal(trace_options::none, trace_listener.trace_output_options(), csf_); assert::is_empty(trace_listener.result(), csf_); } void test_method_(indent_level) { unit_test_trace_listener trace_listener; trace_listener.indent_level(5); assert::are_equal(5U, trace_listener.indent_level(), csf_); } void test_method_(indent_size) { unit_test_trace_listener trace_listener; trace_listener.indent_size(8); assert::are_equal(8U, trace_listener.indent_size(), csf_); } void test_method_(name) { unit_test_trace_listener trace_listener; trace_listener.name("test_omplementation"); assert::are_equal("test_omplementation", trace_listener.name(), csf_); } void test_method_(need_indent) { unit_test_trace_listener trace_listener; trace_listener.need_indent(false); assert::is_false(trace_listener.need_indent(), csf_); } void test_method_(trace_output_options) { unit_test_trace_listener trace_listener; trace_listener.trace_output_options(trace_options::process_id | trace_options::callstack); assert::are_equal(trace_options::process_id | trace_options::callstack, trace_listener.trace_output_options(), csf_); } void test_method_(fail_message) { unit_test_trace_listener trace_listener; trace_listener.fail("invalid_argument"); assert::are_equal("Fail: invalid_argument\n", trace_listener.result(), csf_); } void test_method_(fail_detail_message) { unit_test_trace_listener trace_listener; trace_listener.fail("invalid_argument", "Pointer is null"); assert::are_equal("Fail: invalid_argument Pointer is null\n", trace_listener.result(), csf_); } void test_method_(trace_data_with_string) { unit_test_trace_listener trace_listener; trace_listener.trace_data(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, "information"); assert::are_equal("source error: 1 : information\n", trace_listener.result(), csf_); } void test_method_(trace_data_with_int) { unit_test_trace_listener trace_listener; trace_listener.trace_data(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, 42); assert::are_equal("source error: 1 : 42\n", trace_listener.result(), csf_); } void test_method_(trace_data_with_string_aarray) { unit_test_trace_listener trace_listener; trace_listener.trace_data(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, std::vector<xtd::ustring> {"one", "two"}); assert::are_equal("source error: 1 : one, two\n", trace_listener.result(), csf_); } void test_method_(trace_data_with_string_args) { unit_test_trace_listener trace_listener; trace_listener.trace_data(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, "one", "two"); assert::are_equal("source error: 1 : one, two\n", trace_listener.result(), csf_); } void test_method_(trace_event) { unit_test_trace_listener trace_listener; trace_listener.trace_event(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1); assert::are_equal("source error: 1\n", trace_listener.result(), csf_); } void test_method_(trace_event_with_string) { unit_test_trace_listener trace_listener; trace_listener.trace_event(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, "information"); assert::are_equal("source error: 1 : information\n", trace_listener.result(), csf_); } void test_method_(trace_event_with_format) { unit_test_trace_listener trace_listener; trace_listener.trace_event(xtd::diagnostics::trace_event_cache(), "source", xtd::diagnostics::trace_event_type::error, 1, "informations {}, {}", 42, "84"); assert::are_equal("source error: 1 : informations 42, 84\n", trace_listener.result(), csf_); } void test_method_(trace_transfer) { unit_test_trace_listener trace_listener; trace_listener.trace_transfer(xtd::diagnostics::trace_event_cache(), "source", 1, "message", "10203040-5060-7080-90a0-b0c0d0e0f001"); assert::are_equal("source transfer: 1 : message, related_activity_id=10203040-5060-7080-90a0-b0c0d0e0f001\n", trace_listener.result(), csf_); } void test_method_(write_string) { unit_test_trace_listener trace_listener; trace_listener.write("string"); assert::are_equal("string", trace_listener.result(), csf_); } void test_method_(write_int) { unit_test_trace_listener trace_listener; trace_listener.write(42); assert::are_equal("42", trace_listener.result(), csf_); } void test_method_(write_line_string) { unit_test_trace_listener trace_listener; trace_listener.write_line("string"); assert::are_equal("string\n", trace_listener.result(), csf_); } void test_method_(write_line_int) { unit_test_trace_listener trace_listener; trace_listener.write_line(42); assert::are_equal("42\n", trace_listener.result(), csf_); } void test_method_(write_stream_string) { unit_test_trace_listener trace_listener; trace_listener << "string"; assert::are_equal("string\n", trace_listener.result(), csf_); } void test_method_(write_stream_int) { unit_test_trace_listener trace_listener; trace_listener << 42; assert::are_equal("42\n", trace_listener.result(), csf_); } void test_method_(write_string_with_one_indent_level) { unit_test_trace_listener trace_listener; trace_listener.indent_level(1); trace_listener << "string"; assert::are_equal(" string\n", trace_listener.result(), csf_); } void test_method_(write_string_with_two_indent_level) { unit_test_trace_listener trace_listener; trace_listener.indent_size(8); trace_listener.indent_level(2); trace_listener << "string"; assert::are_equal(" string\n", trace_listener.result(), csf_); } }; }
40.041451
169
0.698499
BaderEddineOuaich
d584eb9d7aa75522aec97277674321061b90fbed
5,296
cpp
C++
src/resource_provider/daemon.cpp
j143/mesos
a85a22baa32f66ecaa13c4602a195d57f6abf9be
[ "Apache-2.0" ]
null
null
null
src/resource_provider/daemon.cpp
j143/mesos
a85a22baa32f66ecaa13c4602a195d57f6abf9be
[ "Apache-2.0" ]
null
null
null
src/resource_provider/daemon.cpp
j143/mesos
a85a22baa32f66ecaa13c4602a195d57f6abf9be
[ "Apache-2.0" ]
null
null
null
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you 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 "resource_provider/daemon.hpp" #include <utility> #include <vector> #include <glog/logging.h> #include <process/id.hpp> #include <process/process.hpp> #include <stout/foreach.hpp> #include <stout/json.hpp> #include <stout/nothing.hpp> #include <stout/option.hpp> #include <stout/os.hpp> #include <stout/path.hpp> #include <stout/protobuf.hpp> #include <stout/try.hpp> #include "resource_provider/local.hpp" using std::list; using std::string; using std::vector; using process::Owned; using process::Process; using process::ProcessBase; using process::spawn; using process::terminate; using process::wait; namespace mesos { namespace internal { class LocalResourceProviderDaemonProcess : public Process<LocalResourceProviderDaemonProcess> { public: LocalResourceProviderDaemonProcess( const process::http::URL& _url, const string& _workDir, const Option<string>& _configDir) : ProcessBase(process::ID::generate("local-resource-provider-daemon")), url(_url), workDir(_workDir), configDir(_configDir) {} protected: void initialize() override; private: struct Provider { Provider(const ResourceProviderInfo& _info, Owned<LocalResourceProvider> _provider) : info(_info), provider(std::move(_provider)) {} const ResourceProviderInfo info; const Owned<LocalResourceProvider> provider; }; Try<Nothing> load(const string& path); const process::http::URL url; const string workDir; const Option<string> configDir; vector<Provider> providers; }; void LocalResourceProviderDaemonProcess::initialize() { if (configDir.isNone()) { return; } Try<list<string>> entries = os::ls(configDir.get()); if (entries.isError()) { LOG(ERROR) << "Unable to list the resource provider directory '" << configDir.get() << "': " << entries.error(); } foreach (const string& entry, entries.get()) { const string path = path::join(configDir.get(), entry); if (os::stat::isdir(path)) { continue; } Try<Nothing> loading = load(path); if (loading.isError()) { LOG(ERROR) << "Failed to load resource provider config '" << path << "': " << loading.error(); continue; } } } Try<Nothing> LocalResourceProviderDaemonProcess::load(const string& path) { Try<string> read = os::read(path); if (read.isError()) { return Error("Failed to read the config file: " + read.error()); } Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get()); if (json.isError()) { return Error("Failed to parse the JSON config: " + json.error()); } Try<ResourceProviderInfo> info = ::protobuf::parse<ResourceProviderInfo>(json.get()); if (info.isError()) { return Error("Not a valid resource provider config: " + info.error()); } // Ensure that ('type', 'name') pair is unique. foreach (const Provider& provider, providers) { if (info->type() == provider.info.type() && info->name() == provider.info.name()) { return Error( "Multiple resource providers with type '" + info->type() + "' and name '" + info->name() + "'"); } } Try<Owned<LocalResourceProvider>> provider = LocalResourceProvider::create(url, info.get()); if (provider.isError()) { return Error( "Failed to create resource provider with type '" + info->type() + "' and name '" + info->name() + "'"); } providers.emplace_back(info.get(), provider.get()); return Nothing(); } Try<Owned<LocalResourceProviderDaemon>> LocalResourceProviderDaemon::create( const process::http::URL& url, const slave::Flags& flags) { // We require that the config directory exists to create a daemon. Option<string> configDir = flags.resource_provider_config_dir; if (configDir.isSome() && !os::exists(configDir.get())) { return Error("Config directory '" + configDir.get() + "' does not exist"); } return new LocalResourceProviderDaemon( url, flags.work_dir, configDir); } LocalResourceProviderDaemon::LocalResourceProviderDaemon( const process::http::URL& url, const string& workDir, const Option<string>& configDir) : process(new LocalResourceProviderDaemonProcess(url, workDir, configDir)) { spawn(CHECK_NOTNULL(process.get())); } LocalResourceProviderDaemon::~LocalResourceProviderDaemon() { terminate(process.get()); wait(process.get()); } } // namespace internal { } // namespace mesos {
26.613065
78
0.681647
j143
d586f35a84d344c5c59774ecc4363eecd344167c
5,634
cc
C++
m.heap/swe9416.cc
kimminki10/algorithms2
5d3b2d970dbc88169108632ce0d234bf74446316
[ "MIT" ]
null
null
null
m.heap/swe9416.cc
kimminki10/algorithms2
5d3b2d970dbc88169108632ce0d234bf74446316
[ "MIT" ]
null
null
null
m.heap/swe9416.cc
kimminki10/algorithms2
5d3b2d970dbc88169108632ce0d234bf74446316
[ "MIT" ]
null
null
null
#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #include <stdio.h> #include <ctime> ///// struct post { int like=0; int uid=-1; int timestamp; } posts[100'005]; int postCnt = 0; int following[1'003][1'003]; int fidx[1'003]; int userNum; void init(int N) { userNum = N; postCnt = 0; for (int i = 0; i <= N; i++) { following[i][0] = i; fidx[i] = 1; } } void follow(int uID1, int uID2, int timestamp) { int fi = fidx[uID1]++; following[uID1][fi] = uID2; } void makePost(int uID, int pID, int timestamp) { postCnt++; post &p = posts[pID]; p.like = 0; p.uid = uID; p.timestamp = timestamp; } void like(int pID, int timestamp) { posts[pID].like++; } bool isFollow(int uID, int puid) { int fl = fidx[uID]; for (int i = 0; i < fl; i++) { if (following[uID][i] == puid) { return true; } } return false; } void getFeed(int uID, int timestamp, int pIDList[]) { int topten[11]; int tidx = 0; for (int pid = postCnt; pid >= 1; pid--) { post p = posts[pid]; if (!isFollow(uID, p.uid)) { continue; } if (timestamp - p.timestamp > 1000) { if (tidx >= 10) { break; } topten[tidx++] = pid; if (tidx >= 10) { break; } continue; } int cur = 0; for (; cur < tidx; cur++) { int tid = topten[cur]; if (posts[tid].like < posts[pid].like) { for (int i = tidx; i >= cur+1; i--) { topten[i] = topten[i-1]; } break; } } topten[cur] = pid; tidx++; if (tidx > 10) { tidx = 10; } } for (int i = 0; i < 10; i++) { pIDList[i] = topten[i]; } } ///// static int mSeed; static int pseudo_rand(void) { mSeed = mSeed * 431345 + 2531999; return mSeed & 0x7FFFFFFF; } static int follow_status[1005][1005]; static int answer_score; static int n; // n >= 2 && n <= 1000 static int end_timestamp; static int follow_ratio; // follow_ratio >= 1 && follow_ratio <= 10000 static int make_ratio; // make_ratio >= 1 && make_ratio <= 10000 static int like_ratio; // like_ratio >= 1 && like_ratio <= 10000 static int get_feed_ratio; // get_feed_ratio >= 1 && get_feed_ratio <= 10000 static int post_arr[200000]; static int total_post_cnt; static int min_post_cnt; static bool run() { int uId1, uId2, pId, pIdList[10], ans_pIdList[10], rand_val; bool ret = true; scanf("%d%d%d%d%d%d%d", &mSeed, &n, &end_timestamp, &follow_ratio, &make_ratio, &like_ratio, &get_feed_ratio); init(n); for (int uId1 = 1; uId1 <= n; uId1++) { follow_status[uId1][uId1] = 1; int m = n / 10 + 1; if (m > 10) m = 10; for (int i = 0; i < m; i++) { uId2 = uId1; while (follow_status[uId1][uId2] == 1) { uId2 = pseudo_rand() % n + 1; } follow(uId1, uId2, 1); follow_status[uId1][uId2] = 1; } } min_post_cnt = total_post_cnt = 1; for (int timestamp = 1; timestamp <= end_timestamp; timestamp++) { rand_val = pseudo_rand() % 10000; if (rand_val < follow_ratio) { uId1 = pseudo_rand() % n + 1; uId2 = pseudo_rand() % n + 1; int lim = 0; while (follow_status[uId1][uId2] == 1 || uId1 == uId2) { uId2 = pseudo_rand() % n + 1; lim++; if (lim >= 5) break; } if (follow_status[uId1][uId2] == 0) { follow(uId1, uId2, timestamp); follow_status[uId1][uId2] = 1; } } rand_val = pseudo_rand() % 10000; if (rand_val < make_ratio) { uId1 = pseudo_rand() % n + 1; post_arr[total_post_cnt] = timestamp; makePost(uId1, total_post_cnt, timestamp); total_post_cnt += 1; } rand_val = pseudo_rand() % 10000; if (rand_val < like_ratio && total_post_cnt - min_post_cnt > 0) { while (post_arr[min_post_cnt] < timestamp - 1000 && min_post_cnt < total_post_cnt) min_post_cnt++; if (total_post_cnt != min_post_cnt) { pId = pseudo_rand() % (total_post_cnt - min_post_cnt) + min_post_cnt; like(pId, timestamp); } } rand_val = pseudo_rand() % 10000; if (rand_val < get_feed_ratio && total_post_cnt > 0) { uId1 = pseudo_rand() % n + 1; getFeed(uId1, timestamp, pIdList); for (int i = 0; i < 10; i++) { scanf("%d", ans_pIdList + i); } for (int i = 0; i < 10; i++) { if (ans_pIdList[i] == 0) break; if (ans_pIdList[i] != pIdList[i]) { ret = false; } } } } return ret; } int main() { clock_t start, end; freopen("../input.txt", "r", stdin); setbuf(stdout, NULL); int tc; start = clock(); scanf("%d%d", &tc, &answer_score); for (int t = 1; t <= tc; t++) { int score; for (int i = 0; i < 1005; i++) for (int j = 0; j < 1005; j++) follow_status[i][j] = 0; if (run()) score = answer_score; else score = 0; printf("#%d %d\n", t, score); } end = clock(); printf("time: %lf sec\n", (double)(end-start) / CLOCKS_PER_SEC); return 0; }
26.450704
77
0.49219
kimminki10
d587565617377a489d461c0dabadcd937e65b083
1,706
cpp
C++
part7/Task7.3/Task7.3/sort.cpp
Matvey1703/Homework
4599a5a5a1bdaeb819eee13a6233c72ce544c179
[ "Apache-2.0" ]
1
2020-09-30T17:17:41.000Z
2020-09-30T17:17:41.000Z
part7/Task7.3/Task7.3/sort.cpp
Matvey1703/Homework
4599a5a5a1bdaeb819eee13a6233c72ce544c179
[ "Apache-2.0" ]
null
null
null
part7/Task7.3/Task7.3/sort.cpp
Matvey1703/Homework
4599a5a5a1bdaeb819eee13a6233c72ce544c179
[ "Apache-2.0" ]
null
null
null
#include <string.h> #include "sort.h" bool less(ListElement* element1, ListElement* element2, bool byPhone) { if (byPhone) { return strcmp(fieldPhone(element1), fieldPhone(element2)) < 0; } else { return strcmp(fieldName(element1), fieldName(element2)) < 0; } } void mergeSort(List* list, ListElement* head, ListElement* tail, bool byPhone) { if (head == tail || isEmpty(list)) { return; } ListElement* leftDelimetr = head; ListElement* rightDelimetr = tail; while (shiftNext(leftDelimetr) != rightDelimetr && shiftNext(leftDelimetr) != shiftPrev(rightDelimetr)) { leftDelimetr = shiftNext(leftDelimetr); rightDelimetr = shiftPrev(rightDelimetr); } if (shiftNext(leftDelimetr) == shiftPrev(rightDelimetr)) { leftDelimetr = shiftNext(leftDelimetr); } mergeSort(list, head, leftDelimetr, byPhone); mergeSort(list, rightDelimetr, tail, byPhone); List* bufferList = create(); ListElement* leftHelper = head; ListElement* rightHelper = rightDelimetr; while (leftHelper != rightDelimetr || rightHelper != shiftNext(tail)) { if ((rightHelper == shiftNext(tail) || less(leftHelper, rightHelper, byPhone)) && leftHelper != rightDelimetr) { addElement(fieldName(leftHelper), fieldPhone(leftHelper), bufferList); leftHelper = shiftNext(leftHelper); } else { addElement(fieldName(rightHelper), fieldPhone(rightHelper), bufferList); rightHelper = shiftNext(rightHelper); } } ListElement* bufferHelper = headPointer(bufferList); ListElement* listHelper = head; while (bufferHelper != nullptr) { copyFields(&listHelper, &bufferHelper); listHelper = shiftNext(listHelper); bufferHelper = shiftNext(bufferHelper); } deleteList(bufferList); }
25.848485
112
0.727433
Matvey1703
d5886db1acc5531017a2656266bcc819a55ee107
16,472
cc
C++
thirdparty/google/type/timeofday.pb.cc
kobeya/GVA-demo
41a57bfff01ab0de2f56ddcd7611514e550472ff
[ "Apache-2.0" ]
2
2019-03-29T07:20:43.000Z
2019-08-13T04:47:27.000Z
thirdparty/google/type/timeofday.pb.cc
kobeya/GVA-demo
41a57bfff01ab0de2f56ddcd7611514e550472ff
[ "Apache-2.0" ]
null
null
null
thirdparty/google/type/timeofday.pb.cc
kobeya/GVA-demo
41a57bfff01ab0de2f56ddcd7611514e550472ff
[ "Apache-2.0" ]
1
2019-08-09T05:26:50.000Z
2019-08-09T05:26:50.000Z
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/type/timeofday.proto #include "google/type/timeofday.pb.h" #include <algorithm> #include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/port.h> #include <google/protobuf/io/coded_stream.h> #include <google/protobuf/wire_format_lite_inl.h> #include <google/protobuf/descriptor.h> #include <google/protobuf/generated_message_reflection.h> #include <google/protobuf/reflection_ops.h> #include <google/protobuf/wire_format.h> // This is a temporary google only hack #ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS #include "third_party/protobuf/version.h" #endif // @@protoc_insertion_point(includes) namespace google { namespace type { class TimeOfDayDefaultTypeInternal { public: ::google::protobuf::internal::ExplicitlyConstructed<TimeOfDay> _instance; } _TimeOfDay_default_instance_; } // namespace type } // namespace google namespace protobuf_google_2ftype_2ftimeofday_2eproto { static void InitDefaultsTimeOfDay() { GOOGLE_PROTOBUF_VERIFY_VERSION; { void* ptr = &::google::type::_TimeOfDay_default_instance_; new (ptr) ::google::type::TimeOfDay(); ::google::protobuf::internal::OnShutdownDestroyMessage(ptr); } ::google::type::TimeOfDay::InitAsDefaultInstance(); } ::google::protobuf::internal::SCCInfo<0> scc_info_TimeOfDay = {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsTimeOfDay}, {}}; void InitDefaults() { ::google::protobuf::internal::InitSCC(&scc_info_TimeOfDay.base); } ::google::protobuf::Metadata file_level_metadata[1]; const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::type::TimeOfDay, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::type::TimeOfDay, hours_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::type::TimeOfDay, minutes_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::type::TimeOfDay, seconds_), GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::google::type::TimeOfDay, nanos_), }; static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, sizeof(::google::type::TimeOfDay)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { reinterpret_cast<const ::google::protobuf::Message*>(&::google::type::_TimeOfDay_default_instance_), }; void protobuf_AssignDescriptors() { AddDescriptors(); AssignDescriptors( "google/type/timeofday.proto", schemas, file_default_instances, TableStruct::offsets, file_level_metadata, NULL, NULL); } void protobuf_AssignDescriptorsOnce() { static ::google::protobuf::internal::once_flag once; ::google::protobuf::internal::call_once(once, protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } void AddDescriptorsImpl() { InitDefaults(); static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\033google/type/timeofday.proto\022\013google.ty" "pe\"K\n\tTimeOfDay\022\r\n\005hours\030\001 \001(\005\022\017\n\007minute" "s\030\002 \001(\005\022\017\n\007seconds\030\003 \001(\005\022\r\n\005nanos\030\004 \001(\005B" "i\n\017com.google.typeB\016TimeOfDayProtoP\001Z>go" "ogle.golang.org/genproto/googleapis/type" "/timeofday;timeofday\242\002\003GTPb\006proto3" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( descriptor, 234); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "google/type/timeofday.proto", &protobuf_RegisterTypes); } void AddDescriptors() { static ::google::protobuf::internal::once_flag once; ::google::protobuf::internal::call_once(once, AddDescriptorsImpl); } // Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; } // namespace protobuf_google_2ftype_2ftimeofday_2eproto namespace google { namespace type { // =================================================================== void TimeOfDay::InitAsDefaultInstance() { } #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int TimeOfDay::kHoursFieldNumber; const int TimeOfDay::kMinutesFieldNumber; const int TimeOfDay::kSecondsFieldNumber; const int TimeOfDay::kNanosFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 TimeOfDay::TimeOfDay() : ::google::protobuf::Message(), _internal_metadata_(NULL) { ::google::protobuf::internal::InitSCC( &protobuf_google_2ftype_2ftimeofday_2eproto::scc_info_TimeOfDay.base); SharedCtor(); // @@protoc_insertion_point(constructor:google.type.TimeOfDay) } TimeOfDay::TimeOfDay(const TimeOfDay& from) : ::google::protobuf::Message(), _internal_metadata_(NULL) { _internal_metadata_.MergeFrom(from._internal_metadata_); ::memcpy(&hours_, &from.hours_, static_cast<size_t>(reinterpret_cast<char*>(&nanos_) - reinterpret_cast<char*>(&hours_)) + sizeof(nanos_)); // @@protoc_insertion_point(copy_constructor:google.type.TimeOfDay) } void TimeOfDay::SharedCtor() { ::memset(&hours_, 0, static_cast<size_t>( reinterpret_cast<char*>(&nanos_) - reinterpret_cast<char*>(&hours_)) + sizeof(nanos_)); } TimeOfDay::~TimeOfDay() { // @@protoc_insertion_point(destructor:google.type.TimeOfDay) SharedDtor(); } void TimeOfDay::SharedDtor() { } void TimeOfDay::SetCachedSize(int size) const { _cached_size_.Set(size); } const ::google::protobuf::Descriptor* TimeOfDay::descriptor() { ::protobuf_google_2ftype_2ftimeofday_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_google_2ftype_2ftimeofday_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const TimeOfDay& TimeOfDay::default_instance() { ::google::protobuf::internal::InitSCC(&protobuf_google_2ftype_2ftimeofday_2eproto::scc_info_TimeOfDay.base); return *internal_default_instance(); } void TimeOfDay::Clear() { // @@protoc_insertion_point(message_clear_start:google.type.TimeOfDay) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; ::memset(&hours_, 0, static_cast<size_t>( reinterpret_cast<char*>(&nanos_) - reinterpret_cast<char*>(&hours_)) + sizeof(nanos_)); _internal_metadata_.Clear(); } bool TimeOfDay::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:google.type.TimeOfDay) for (;;) { ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // int32 hours = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &hours_))); } else { goto handle_unusual; } break; } // int32 minutes = 2; case 2: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(16u /* 16 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &minutes_))); } else { goto handle_unusual; } break; } // int32 seconds = 3; case 3: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(24u /* 24 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &seconds_))); } else { goto handle_unusual; } break; } // int32 nanos = 4; case 4: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(32u /* 32 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>( input, &nanos_))); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:google.type.TimeOfDay) return true; failure: // @@protoc_insertion_point(parse_failure:google.type.TimeOfDay) return false; #undef DO_ } void TimeOfDay::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:google.type.TimeOfDay) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // int32 hours = 1; if (this->hours() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->hours(), output); } // int32 minutes = 2; if (this->minutes() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->minutes(), output); } // int32 seconds = 3; if (this->seconds() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->seconds(), output); } // int32 nanos = 4; if (this->nanos() != 0) { ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->nanos(), output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:google.type.TimeOfDay) } ::google::protobuf::uint8* TimeOfDay::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:google.type.TimeOfDay) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // int32 hours = 1; if (this->hours() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->hours(), target); } // int32 minutes = 2; if (this->minutes() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->minutes(), target); } // int32 seconds = 3; if (this->seconds() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->seconds(), target); } // int32 nanos = 4; if (this->nanos() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->nanos(), target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:google.type.TimeOfDay) return target; } size_t TimeOfDay::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:google.type.TimeOfDay) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // int32 hours = 1; if (this->hours() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->hours()); } // int32 minutes = 2; if (this->minutes() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->minutes()); } // int32 seconds = 3; if (this->seconds() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->seconds()); } // int32 nanos = 4; if (this->nanos() != 0) { total_size += 1 + ::google::protobuf::internal::WireFormatLite::Int32Size( this->nanos()); } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); SetCachedSize(cached_size); return total_size; } void TimeOfDay::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:google.type.TimeOfDay) GOOGLE_DCHECK_NE(&from, this); const TimeOfDay* source = ::google::protobuf::internal::DynamicCastToGenerated<const TimeOfDay>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.type.TimeOfDay) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:google.type.TimeOfDay) MergeFrom(*source); } } void TimeOfDay::MergeFrom(const TimeOfDay& from) { // @@protoc_insertion_point(class_specific_merge_from_start:google.type.TimeOfDay) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.hours() != 0) { set_hours(from.hours()); } if (from.minutes() != 0) { set_minutes(from.minutes()); } if (from.seconds() != 0) { set_seconds(from.seconds()); } if (from.nanos() != 0) { set_nanos(from.nanos()); } } void TimeOfDay::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:google.type.TimeOfDay) if (&from == this) return; Clear(); MergeFrom(from); } void TimeOfDay::CopyFrom(const TimeOfDay& from) { // @@protoc_insertion_point(class_specific_copy_from_start:google.type.TimeOfDay) if (&from == this) return; Clear(); MergeFrom(from); } bool TimeOfDay::IsInitialized() const { return true; } void TimeOfDay::Swap(TimeOfDay* other) { if (other == this) return; InternalSwap(other); } void TimeOfDay::InternalSwap(TimeOfDay* other) { using std::swap; swap(hours_, other->hours_); swap(minutes_, other->minutes_); swap(seconds_, other->seconds_); swap(nanos_, other->nanos_); _internal_metadata_.Swap(&other->_internal_metadata_); } ::google::protobuf::Metadata TimeOfDay::GetMetadata() const { protobuf_google_2ftype_2ftimeofday_2eproto::protobuf_AssignDescriptorsOnce(); return ::protobuf_google_2ftype_2ftimeofday_2eproto::file_level_metadata[kIndexInFileMessages]; } // @@protoc_insertion_point(namespace_scope) } // namespace type } // namespace google namespace google { namespace protobuf { template<> GOOGLE_PROTOBUF_ATTRIBUTE_NOINLINE ::google::type::TimeOfDay* Arena::CreateMaybeMessage< ::google::type::TimeOfDay >(Arena* arena) { return Arena::CreateInternal< ::google::type::TimeOfDay >(arena); } } // namespace protobuf } // namespace google // @@protoc_insertion_point(global_scope)
35.196581
168
0.700461
kobeya
d58a2f10f14324ec23e0876804b175d73a858784
60
cpp
C++
csapex_core_plugins/src/core/collection_node.cpp
AdrianZw/csapex_core_plugins
1b23c90af7e552c3fc37c7dda589d751d2aae97f
[ "BSD-3-Clause" ]
2
2016-09-02T15:33:22.000Z
2019-05-06T22:09:33.000Z
csapex_core_plugins/src/core/collection_node.cpp
AdrianZw/csapex_core_plugins
1b23c90af7e552c3fc37c7dda589d751d2aae97f
[ "BSD-3-Clause" ]
1
2021-02-14T19:53:30.000Z
2021-02-14T19:53:30.000Z
csapex_core_plugins/src/core/collection_node.cpp
AdrianZw/csapex_core_plugins
1b23c90af7e552c3fc37c7dda589d751d2aae97f
[ "BSD-3-Clause" ]
6
2016-10-12T00:55:23.000Z
2021-02-10T17:49:25.000Z
/// HEADER #include <csapex_core_plugins/collection_node.h>
20
48
0.8
AdrianZw
d58a5f894af4fb13f69479b9d8f5ee9cebf12ea2
331
cpp
C++
Ch 14/14.49_Book_test.cpp
Felon03/CppPrimer
7dc2daf59f0ae7ec5670def15cb5fab174fe9780
[ "Apache-2.0" ]
null
null
null
Ch 14/14.49_Book_test.cpp
Felon03/CppPrimer
7dc2daf59f0ae7ec5670def15cb5fab174fe9780
[ "Apache-2.0" ]
null
null
null
Ch 14/14.49_Book_test.cpp
Felon03/CppPrimer
7dc2daf59f0ae7ec5670def15cb5fab174fe9780
[ "Apache-2.0" ]
null
null
null
#include"14.49_Book.h" int main() { Book book1(1, "cpp primer 5th", "Lippman", "2013", 76); Book book2 = book1; Book book3(book1); Book book4 = Book(std::cin); if (book2) book2 = book4; std::cout << book2 << std::endl; auto flag = static_cast<bool>(book2); std::cout << std::boolalpha << flag << std::endl; return 0; }
20.6875
56
0.625378
Felon03
d58c5bb8038d50c0f658b79b6fcce571f4f5af83
4,353
cpp
C++
libs/img/src/CImage_SSE2.cpp
mrliujie/mrpt-learning-code
7b41a9501fc35c36580c93bc1499f5a36d26c216
[ "BSD-3-Clause" ]
2
2020-04-21T08:51:21.000Z
2022-03-21T10:47:52.000Z
libs/img/src/CImage_SSE2.cpp
qifengl/mrpt
979a458792273a86ec5ab105e0cd6c963c65ea73
[ "BSD-3-Clause" ]
null
null
null
libs/img/src/CImage_SSE2.cpp
qifengl/mrpt
979a458792273a86ec5ab105e0cd6c963c65ea73
[ "BSD-3-Clause" ]
null
null
null
/* +------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +------------------------------------------------------------------------+ */ #include "img-precomp.h" // Precompiled headers #if MRPT_HAS_SSE2 // --------------------------------------------------------------------------- // This file contains the SSE2 optimized functions for mrpt::img::CImage // See the sources and the doxygen documentation page "sse_optimizations" for // more details. // // Some functions here are derived from sources in libcvd, released // under BSD. https://www.edwardrosten.com/cvd/ // // --------------------------------------------------------------------------- #include <mrpt/img/CImage.h> #include <mrpt/core/SSE_types.h> #include <mrpt/core/SSE_macros.h> #include "CImage_SSEx.h" /** \addtogroup sse_optimizations * SSE optimized functions * @{ */ /** Subsample each 2x2 pixel block into 1x1 pixel, taking the first pixel & * ignoring the other 3 * - <b>Input format:</b> uint8_t, 1 channel * - <b>Output format:</b> uint8_t, 1 channel * - <b>Preconditions:</b> in & out aligned to 16bytes, w = k*16 (w=width in * pixels), widthStep=w*1 * - <b>Notes:</b> * - <b>Requires:</b> SSE2 * - <b>Invoked from:</b> mrpt::img::CImage::scaleHalf() */ void image_SSE2_scale_half_1c8u(const uint8_t* in, uint8_t* out, int w, int h) { alignas(32) const unsigned long long mask[2] = {0x00FF00FF00FF00FFull, 0x00FF00FF00FF00FFull}; const __m128i m = _mm_load_si128((const __m128i*)mask); int sw = w >> 4; int sh = h >> 1; for (int i = 0; i < sh; i++) { for (int j = 0; j < sw; j++) { const __m128i here_sampled = _mm_and_si128(_mm_load_si128((const __m128i*)in), m); _mm_storel_epi64( (__m128i*)out, _mm_packus_epi16(here_sampled, here_sampled)); in += 16; out += 8; } in += w; } } /** Average each 2x2 pixels into 1x1 pixel (arithmetic average) * - <b>Input format:</b> uint8_t, 1 channel * - <b>Output format:</b> uint8_t, 1 channel * - <b>Preconditions:</b> in & out aligned to 16bytes, w = k*16 (w=width in * pixels), widthStep=w*1 * - <b>Notes:</b> * - <b>Requires:</b> SSE2 * - <b>Invoked from:</b> mrpt::img::CImage::scaleHalfSmooth() */ void image_SSE2_scale_half_smooth_1c8u( const uint8_t* in, uint8_t* out, int w, int h) { alignas(MRPT_MAX_ALIGN_BYTES) const unsigned long long mask[2] = { 0x00FF00FF00FF00FFull, 0x00FF00FF00FF00FFull}; const uint8_t* nextRow = in + w; __m128i m = _mm_load_si128((const __m128i*)mask); int sw = w >> 4; int sh = h >> 1; for (int i = 0; i < sh; i++) { for (int j = 0; j < sw; j++) { __m128i here = _mm_load_si128((const __m128i*)in); __m128i next = _mm_load_si128((const __m128i*)nextRow); here = _mm_avg_epu8(here, next); next = _mm_and_si128(_mm_srli_si128(here, 1), m); here = _mm_and_si128(here, m); here = _mm_avg_epu16(here, next); _mm_storel_epi64((__m128i*)out, _mm_packus_epi16(here, here)); in += 16; nextRow += 16; out += 8; } in += w; nextRow += w; } } /** KLT score at a given point of a grayscale image. * - <b>Requires:</b> SSE2 * - <b>Invoked from:</b> mrpt::img::CImage::KLT_response() * * This function is not manually optimized for SSE2 but templatized for * different * window sizes such as the compiler can optimize automatically for that * size. * * Only for the most common window sizes this templates are instantiated * (W=[2-16] and W=32 ), * falling back to * a generic implementation otherwise. The next figure shows the performance * (time for * KLT_response() to compute the score for one single pixel) for different * window sizes. * * <img src="KLT_response_performance_SSE2.png" > * */ float KLT_response_optimized(); // TODO: // Sum of absolute differences: Use _mm_sad_epu8 /** @} */ #endif // end if MRPT_HAS_SSE2
32.244444
80
0.587641
mrliujie
d58db4da106d35a0d66213533072b97444540af1
1,055
cpp
C++
edc127.cpp
EDI9029/FC22
79dab09646b1f2e08ae0da1f385d48e5c8a9b09f
[ "MIT" ]
null
null
null
edc127.cpp
EDI9029/FC22
79dab09646b1f2e08ae0da1f385d48e5c8a9b09f
[ "MIT" ]
null
null
null
edc127.cpp
EDI9029/FC22
79dab09646b1f2e08ae0da1f385d48e5c8a9b09f
[ "MIT" ]
null
null
null
//Cooperation of EDB1 P.129// //Edward 1,17,2022 // /***************************************************************/ #include <stdio.h> #include <stdlib.h> int main(void){ int i,j,n,m,a,b,cur,book[101]={0},e[101][101]; int que[10001],head,tail; scanf("%d %d",&n,&m); for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ if(i==j){ e[i][j]=0; } else{ e[i][j]=99999999; } } } for(i=1;i<=m;i++){ scanf("%d %d",&a,&b); e[a][b]=1; e[b][a]=1; } head=1; tail=1; que[tail]=1; tail++; book[1]=1; while(head<tail){ cur=que[head]; for(i=1;i<=n;i++){ if(e[cur][i]==1 && book[i]==0){ que[tail]=i; tail++; book[i]=1; } if(tail>n){ break; } } head++; } for(i=1;i<tail;i++){ printf("%d",que[i]); } system("pause"); return 0; }
17.881356
65
0.320379
EDI9029
d5907501442b4aa0ba40b22f93327a99866432c2
32,515
hpp
C++
core/injector/application_injector.hpp
FlorianFranzen/kagome
27ee11c78767e72f0ecd2c515c77bebc2ff5758d
[ "Apache-2.0" ]
null
null
null
core/injector/application_injector.hpp
FlorianFranzen/kagome
27ee11c78767e72f0ecd2c515c77bebc2ff5758d
[ "Apache-2.0" ]
null
null
null
core/injector/application_injector.hpp
FlorianFranzen/kagome
27ee11c78767e72f0ecd2c515c77bebc2ff5758d
[ "Apache-2.0" ]
null
null
null
/** * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ #ifndef KAGOME_CORE_INJECTOR_APPLICATION_INJECTOR_HPP #define KAGOME_CORE_INJECTOR_APPLICATION_INJECTOR_HPP #include <boost/di.hpp> #include <boost/di/extension/scopes/shared.hpp> #include <libp2p/injector/host_injector.hpp> #include <libp2p/peer/peer_info.hpp> #include "api/service/api_service.hpp" #include "api/service/author/author_jrpc_processor.hpp" #include "api/service/author/impl/author_api_impl.hpp" #include "api/service/chain/chain_jrpc_processor.hpp" #include "api/service/chain/impl/chain_api_impl.hpp" #include "api/service/state/impl/state_api_impl.hpp" #include "api/service/state/state_jrpc_processor.hpp" #include "api/service/system/impl/system_api_impl.hpp" #include "api/service/system/system_jrpc_processor.hpp" #include "api/transport/impl/http/http_listener_impl.hpp" #include "api/transport/impl/http/http_session.hpp" #include "api/transport/impl/ws/ws_listener_impl.hpp" #include "api/transport/impl/ws/ws_session.hpp" #include "api/transport/rpc_thread_pool.hpp" #include "application/impl/app_state_manager_impl.hpp" #include "application/impl/configuration_storage_impl.hpp" #include "authorship/impl/block_builder_factory_impl.hpp" #include "authorship/impl/block_builder_impl.hpp" #include "authorship/impl/proposer_impl.hpp" #include "blockchain/impl/block_tree_impl.hpp" #include "blockchain/impl/key_value_block_header_repository.hpp" #include "blockchain/impl/key_value_block_storage.hpp" #include "blockchain/impl/storage_util.hpp" #include "boost/di/extension/injections/extensible_injector.hpp" #include "clock/impl/basic_waitable_timer.hpp" #include "clock/impl/clock_impl.hpp" #include "common/outcome_throw.hpp" #include "consensus/authority/authority_manager.hpp" #include "consensus/authority/authority_update_observer.hpp" #include "consensus/authority/impl/authority_manager_impl.hpp" #include "consensus/babe/babe_lottery.hpp" #include "consensus/babe/common.hpp" #include "consensus/babe/impl/babe_lottery_impl.hpp" #include "consensus/babe/impl/babe_synchronizer_impl.hpp" #include "consensus/babe/impl/epoch_storage_impl.hpp" #include "consensus/grandpa/finalization_observer.hpp" #include "consensus/grandpa/impl/environment_impl.hpp" #include "consensus/grandpa/impl/finalization_composite.hpp" #include "consensus/grandpa/impl/vote_crypto_provider_impl.hpp" #include "consensus/grandpa/structs.hpp" #include "consensus/grandpa/vote_graph.hpp" #include "consensus/grandpa/vote_tracker.hpp" #include "consensus/validation/babe_block_validator.hpp" #include "crypto/bip39/impl/bip39_provider_impl.hpp" #include "crypto/crypto_store/crypto_store_impl.hpp" #include "crypto/ed25519/ed25519_provider_impl.hpp" #include "crypto/hasher/hasher_impl.hpp" #include "crypto/pbkdf2/impl/pbkdf2_provider_impl.hpp" #include "crypto/random_generator/boost_generator.hpp" #include "crypto/secp256k1/secp256k1_provider_impl.hpp" #include "crypto/sr25519/sr25519_provider_impl.hpp" #include "crypto/vrf/vrf_provider_impl.hpp" #include "extensions/impl/extension_factory_impl.hpp" #include "network/impl/dummy_sync_protocol_client.hpp" #include "network/impl/extrinsic_observer_impl.hpp" #include "network/impl/gossiper_broadcast.hpp" #include "network/impl/remote_sync_protocol_client.hpp" #include "network/impl/router_libp2p.hpp" #include "network/impl/sync_protocol_observer_impl.hpp" #include "network/sync_protocol_client.hpp" #include "network/sync_protocol_observer.hpp" #include "network/types/sync_clients_set.hpp" #include "outcome/outcome.hpp" #include "runtime/binaryen/module/wasm_module_factory_impl.hpp" #include "runtime/binaryen/module/wasm_module_impl.hpp" #include "runtime/binaryen/runtime_api/babe_api_impl.hpp" #include "runtime/binaryen/runtime_api/block_builder_impl.hpp" #include "runtime/binaryen/runtime_api/core_factory_impl.hpp" #include "runtime/binaryen/runtime_api/core_impl.hpp" #include "runtime/binaryen/runtime_api/grandpa_api_impl.hpp" #include "runtime/binaryen/runtime_api/metadata_impl.hpp" #include "runtime/binaryen/runtime_api/offchain_worker_impl.hpp" #include "runtime/binaryen/runtime_api/parachain_host_impl.hpp" #include "runtime/binaryen/runtime_api/tagged_transaction_queue_impl.hpp" #include "runtime/common/storage_wasm_provider.hpp" #include "runtime/common/trie_storage_provider_impl.hpp" #include "storage/changes_trie/impl/storage_changes_tracker_impl.hpp" #include "storage/leveldb/leveldb.hpp" #include "storage/predefined_keys.hpp" #include "storage/trie/impl/trie_storage_backend_impl.hpp" #include "storage/trie/impl/trie_storage_impl.hpp" #include "storage/trie/polkadot_trie/polkadot_node.hpp" #include "storage/trie/polkadot_trie/polkadot_trie_factory_impl.hpp" #include "storage/trie/serialization/polkadot_codec.hpp" #include "storage/trie/serialization/trie_serializer_impl.hpp" #include "transaction_pool/impl/pool_moderator_impl.hpp" #include "transaction_pool/impl/transaction_pool_impl.hpp" namespace kagome::injector { namespace di = boost::di; template <typename C> auto useConfig(C c) { return boost::di::bind<std::decay_t<C>>().template to( std::move(c))[boost::di::override]; } template <class T> using sptr = std::shared_ptr<T>; template <class T> using uptr = std::unique_ptr<T>; template <typename Injector> sptr<network::PeerList> get_boot_nodes(const Injector &injector) { static auto initialized = boost::optional<sptr<network::PeerList>>(boost::none); if (initialized) { return initialized.value(); } auto &cfg = injector.template create<application::ConfigurationStorage &>(); initialized = std::make_shared<network::PeerList>(cfg.getBootNodes()); return initialized.value(); } template <typename Injector> sptr<api::ApiService> get_jrpc_api_service(const Injector &injector) { static auto initialized = boost::optional<sptr<api::ApiService>>(boost::none); if (initialized) { return initialized.value(); } using SubscriptionEnginePtr = std::shared_ptr< subscription::SubscriptionEngine<common::Buffer, std::shared_ptr<api::Session>, common::Buffer, primitives::BlockHash>>; auto subscription_engine = injector.template create<SubscriptionEnginePtr>(); auto app_state_manager = injector .template create<std::shared_ptr<application::AppStateManager>>(); auto rpc_thread_pool = injector.template create<std::shared_ptr<api::RpcThreadPool>>(); std::vector<std::shared_ptr<api::Listener>> listeners{ injector.template create<std::shared_ptr<api::HttpListenerImpl>>(), injector.template create<std::shared_ptr<api::WsListenerImpl>>(), }; auto server = injector.template create<std::shared_ptr<api::JRpcServer>>(); std::vector<std::shared_ptr<api::JRpcProcessor>> processors{ injector .template create<std::shared_ptr<api::state::StateJrpcProcessor>>(), injector.template create< std::shared_ptr<api::author::AuthorJRpcProcessor>>(), injector .template create<std::shared_ptr<api::chain::ChainJrpcProcessor>>(), injector.template create< std::shared_ptr<api::system::SystemJrpcProcessor>>()}; initialized = std::make_shared<api::ApiService>(std::move(app_state_manager), std::move(rpc_thread_pool), std::move(listeners), std::move(server), processors, std::move(subscription_engine)); auto state_api = injector.template create<std::shared_ptr<api::StateApi>>(); state_api->setApiService(initialized.value()); return initialized.value(); } // jrpc api listener (over HTTP) getter template <typename Injector> sptr<api::HttpListenerImpl> get_jrpc_api_http_listener( const Injector &injector, const boost::asio::ip::tcp::endpoint &endpoint) { static auto initialized = boost::optional<sptr<api::HttpListenerImpl>>(boost::none); if (initialized) { return initialized.value(); } auto app_state_manager = injector.template create<sptr<application::AppStateManager>>(); auto context = injector.template create<sptr<api::RpcContext>>(); api::HttpListenerImpl::Configuration listener_config; listener_config.endpoint = endpoint; auto &&http_session_config = injector.template create<api::HttpSession::Configuration>(); initialized = std::make_shared<api::HttpListenerImpl>( app_state_manager, context, listener_config, http_session_config); return initialized.value(); } // jrpc api listener (over Websockets) getter template <typename Injector> sptr<api::WsListenerImpl> get_jrpc_api_ws_listener( const Injector &injector, const boost::asio::ip::tcp::endpoint &endpoint) { static auto initialized = boost::optional<sptr<api::WsListenerImpl>>(boost::none); if (initialized) { return initialized.value(); } auto app_state_manager = injector.template create<sptr<application::AppStateManager>>(); auto context = injector.template create<sptr<api::RpcContext>>(); api::WsListenerImpl::Configuration listener_config; listener_config.endpoint = endpoint; auto &&ws_session_config = injector.template create<api::WsSession::Configuration>(); initialized = std::make_shared<api::WsListenerImpl>( app_state_manager, context, listener_config, ws_session_config); return initialized.value(); } // block storage getter template <typename Injector> sptr<blockchain::BlockStorage> get_block_storage(const Injector &injector) { static auto initialized = boost::optional<sptr<blockchain::BlockStorage>>(boost::none); if (initialized) { return initialized.value(); } auto &&hasher = injector.template create<sptr<crypto::Hasher>>(); const auto &db = injector.template create<sptr<storage::BufferStorage>>(); const auto &trie_storage = injector.template create<sptr<storage::trie::TrieStorage>>(); auto storage = blockchain::KeyValueBlockStorage::create( trie_storage->getRootHash(), db, hasher, [&db, &injector](const primitives::Block &genesis_block) { // handle genesis initialization, which happens when there is not // authorities and last completed round in the storage if (not db->get(storage::kAuthoritySetKey)) { // insert authorities auto grandpa_api = injector.template create<sptr<runtime::GrandpaApi>>(); const auto &weighted_authorities_res = grandpa_api->authorities( primitives::BlockId(primitives::BlockNumber{0})); BOOST_ASSERT_MSG(weighted_authorities_res, "grandpa_api_->authorities failed"); const auto &weighted_authorities = weighted_authorities_res.value(); for (const auto authority : weighted_authorities) { spdlog::info("Grandpa authority: {}", authority.id.id.toHex()); } consensus::grandpa::VoterSet voters{0}; for (const auto &weighted_authority : weighted_authorities) { voters.insert(weighted_authority.id.id, weighted_authority.weight); spdlog::debug("Added to grandpa authorities: {}, weight: {}", weighted_authority.id.id.toHex(), weighted_authority.weight); } BOOST_ASSERT_MSG(voters.size() != 0, "Grandpa voters are empty"); auto authorities_put_res = db->put(storage::kAuthoritySetKey, common::Buffer(scale::encode(voters).value())); if (not authorities_put_res) { BOOST_ASSERT_MSG(false, "Could not insert authorities"); std::exit(1); } } }); if (storage.has_error()) { common::raise(storage.error()); } initialized = storage.value(); return initialized.value(); } // block tree getter template <typename Injector> sptr<blockchain::BlockTree> get_block_tree(const Injector &injector) { static auto initialized = boost::optional<sptr<blockchain::BlockTree>>(boost::none); if (initialized) { return initialized.value(); } auto header_repo = injector.template create<sptr<blockchain::BlockHeaderRepository>>(); auto &&storage = injector.template create<sptr<blockchain::BlockStorage>>(); auto last_finalized_block_res = storage->getLastFinalizedBlockHash(); const auto block_id = last_finalized_block_res.has_value() ? primitives::BlockId{last_finalized_block_res.value()} : primitives::BlockId{0}; auto &&extrinsic_observer = injector.template create<sptr<network::ExtrinsicObserver>>(); auto &&hasher = injector.template create<sptr<crypto::Hasher>>(); auto &&tree = blockchain::BlockTreeImpl::create(std::move(header_repo), storage, block_id, std::move(extrinsic_observer), std::move(hasher)); if (!tree) { common::raise(tree.error()); } initialized = tree.value(); return initialized.value(); } template <typename Injector> sptr<extensions::ExtensionFactoryImpl> get_extension_factory( const Injector &injector) { static auto initialized = boost::optional<sptr<extensions::ExtensionFactoryImpl>>(boost::none); if (initialized) { return initialized.value(); } auto tracker = injector.template create<sptr<storage::changes_trie::ChangesTracker>>(); auto sr25519_provider = injector.template create<sptr<crypto::SR25519Provider>>(); auto ed25519_provider = injector.template create<sptr<crypto::ED25519Provider>>(); auto secp256k1_provider = injector.template create<sptr<crypto::Secp256k1Provider>>(); auto hasher = injector.template create<sptr<crypto::Hasher>>(); auto crypto_store = injector.template create<sptr<crypto::CryptoStore>>(); auto bip39_provider = injector.template create<sptr<crypto::Bip39Provider>>(); auto core_factory_method = [&injector](sptr<runtime::WasmProvider> wasm_provider) { auto core_factory = injector.template create<sptr<runtime::CoreFactory>>(); return core_factory->createWithCode(wasm_provider); }; initialized = std::make_shared<extensions::ExtensionFactoryImpl>(tracker, sr25519_provider, ed25519_provider, secp256k1_provider, hasher, crypto_store, bip39_provider, core_factory_method); return initialized.value(); } template <typename Injector> sptr<storage::trie::TrieStorageBackendImpl> get_trie_storage_backend( const Injector &injector) { static auto initialized = boost::optional<sptr<storage::trie::TrieStorageBackendImpl>>( boost::none); if (initialized) { return initialized.value(); } auto storage = injector.template create<sptr<storage::BufferStorage>>(); using blockchain::prefix::TRIE_NODE; auto backend = std::make_shared<storage::trie::TrieStorageBackendImpl>( storage, common::Buffer{TRIE_NODE}); initialized = backend; return backend; } template <typename Injector> sptr<storage::trie::TrieStorageImpl> get_trie_storage_impl( const Injector &injector) { static auto initialized = boost::optional<sptr<storage::trie::TrieStorageImpl>>(boost::none); if (initialized) { return initialized.value(); } auto factory = injector.template create<sptr<storage::trie::PolkadotTrieFactory>>(); auto codec = injector.template create<sptr<storage::trie::Codec>>(); auto serializer = injector.template create<sptr<storage::trie::TrieSerializer>>(); auto tracker = injector.template create<sptr<storage::changes_trie::ChangesTracker>>(); auto trie_storage_res = storage::trie::TrieStorageImpl::createEmpty( factory, codec, serializer, tracker); if (!trie_storage_res) { common::raise(trie_storage_res.error()); } sptr<storage::trie::TrieStorageImpl> trie_storage = std::move(trie_storage_res.value()); initialized = trie_storage; return trie_storage; } template <typename Injector> sptr<storage::trie::TrieStorage> get_trie_storage(const Injector &injector) { static auto initialized = boost::optional<sptr<storage::trie::TrieStorage>>(boost::none); if (initialized) { return initialized.value(); } auto configuration_storage = injector.template create<sptr<application::ConfigurationStorage>>(); const auto &genesis_raw_configs = configuration_storage->getGenesis(); auto trie_storage = injector.template create<sptr<storage::trie::TrieStorageImpl>>(); auto batch = trie_storage->getPersistentBatch(); if (not batch) { common::raise(batch.error()); } for (const auto &[key, val] : genesis_raw_configs) { spdlog::debug( "Key: {}, Val: {}", key.toHex(), val.toHex().substr(0, 200)); if (auto res = batch.value()->put(key, val); not res) { common::raise(res.error()); } } if (auto res = batch.value()->commit(); not res) { common::raise(res.error()); } initialized = trie_storage; return trie_storage; } // level db getter template <typename Injector> sptr<storage::BufferStorage> get_level_db(std::string_view leveldb_path, const Injector &injector) { static auto initialized = boost::optional<sptr<storage::BufferStorage>>(boost::none); if (initialized) { return initialized.value(); } auto options = leveldb::Options{}; options.create_if_missing = true; auto db = storage::LevelDB::create(leveldb_path, options); if (!db) { common::raise(db.error()); } initialized = db.value(); return initialized.value(); }; // configuration storage getter template <typename Injector> std::shared_ptr<application::ConfigurationStorage> get_configuration_storage( std::string_view genesis_path, const Injector &injector) { static auto initialized = boost::optional<sptr<application::ConfigurationStorage>>(boost::none); if (initialized) { return initialized.value(); } auto config_storage_res = application::ConfigurationStorageImpl::create( std::string(genesis_path)); if (config_storage_res.has_error()) { common::raise(config_storage_res.error()); } initialized = config_storage_res.value(); return config_storage_res.value(); }; template <typename Injector> sptr<network::SyncClientsSet> get_sync_clients_set(const Injector &injector) { static auto initialized = boost::optional<sptr<network::SyncClientsSet>>(boost::none); if (initialized) { return initialized.value(); } auto configuration_storage = injector.template create<sptr<application::ConfigurationStorage>>(); auto peer_infos = configuration_storage->getBootNodes().peers; auto host = injector.template create<sptr<libp2p::Host>>(); auto block_tree = injector.template create<sptr<blockchain::BlockTree>>(); auto block_header_repository = injector.template create<sptr<blockchain::BlockHeaderRepository>>(); auto res = std::make_shared<network::SyncClientsSet>(); auto &current_peer_info = injector.template create<network::OwnPeerInfo &>(); for (auto &peer_info : peer_infos) { spdlog::debug("Added peer with id: {}", peer_info.id.toBase58()); if (peer_info.id != current_peer_info.id) { res->clients.emplace_back( std::make_shared<network::RemoteSyncProtocolClient>( *host, std::move(peer_info))); } else { res->clients.emplace_back( std::make_shared<network::DummySyncProtocolClient>()); } } std::reverse(res->clients.begin(), res->clients.end()); initialized = res; return res; } template <typename Injector> sptr<primitives::BabeConfiguration> get_babe_configuration( const Injector &injector) { static auto initialized = boost::optional<sptr<primitives::BabeConfiguration>>(boost::none); if (initialized) { return *initialized; } auto babe_api = injector.template create<sptr<runtime::BabeApi>>(); auto configuration_res = babe_api->configuration(); if (not configuration_res) { common::raise(configuration_res.error()); } auto config = configuration_res.value(); for (const auto &authority : config.genesis_authorities) { spdlog::debug("Babe authority: {}", authority.id.id.toHex()); } config.leadership_rate.first *= 3; initialized = std::make_shared<primitives::BabeConfiguration>(config); return *initialized; }; template <class Injector> sptr<crypto::CryptoStore> get_crypto_store(std::string_view keystore_path, const Injector &injector) { static auto initialized = boost::optional<sptr<crypto::CryptoStore>>(boost::none); if (initialized) { return *initialized; } auto ed25519_provider = injector.template create<sptr<crypto::ED25519Provider>>(); auto sr25519_provider = injector.template create<sptr<crypto::SR25519Provider>>(); auto secp256k1_provider = injector.template create<sptr<crypto::Secp256k1Provider>>(); auto bip39_provider = injector.template create<sptr<crypto::Bip39Provider>>(); auto random_generator = injector.template create<sptr<crypto::CSPRNG>>(); auto crypto_store = std::make_shared<crypto::CryptoStoreImpl>(std::move(ed25519_provider), std::move(sr25519_provider), std::move(secp256k1_provider), std::move(bip39_provider), std::move(random_generator)); boost::filesystem::path path = std::string(keystore_path); if (auto &&res = crypto_store->initialize(path); res) { common::raise(res.error()); } initialized = crypto_store; return *initialized; } template <class Injector> sptr<consensus::grandpa::FinalizationObserver> get_finalization_observer( const Injector &injector) { static auto instance = boost::optional< std::shared_ptr<consensus::grandpa::FinalizationObserver>>(boost::none); if (instance) { return *instance; } instance = std::make_shared<consensus::grandpa::FinalizationComposite>( injector.template create< std::shared_ptr<authority::AuthorityManagerImpl>>()); return *instance; } template <typename... Ts> auto makeApplicationInjector( const std::string &genesis_path, const std::string &leveldb_path, const boost::asio::ip::tcp::endpoint &rpc_http_endpoint, const boost::asio::ip::tcp::endpoint &rpc_ws_endpoint, Ts &&... args) { using namespace boost; // NOLINT; // default values for configurations api::RpcThreadPool::Configuration rpc_thread_pool_config{}; api::HttpSession::Configuration http_config{}; api::WsSession::Configuration ws_config{}; transaction_pool::PoolModeratorImpl::Params pool_moderator_config{}; transaction_pool::TransactionPool::Limits tp_pool_limits{}; return di::make_injector( // bind configs injector::useConfig(rpc_thread_pool_config), injector::useConfig(http_config), injector::useConfig(ws_config), injector::useConfig(pool_moderator_config), injector::useConfig(tp_pool_limits), // inherit host injector libp2p::injector::makeHostInjector( // FIXME(xDimon): https://github.com/soramitsu/kagome/issues/495 // Uncomment after issue will be resolved // libp2p::injector::useSecurityAdaptors< // libp2p::security::Secio>()[di::override] ), // bind boot nodes di::bind<network::PeerList>.to( [](auto const &inj) { return get_boot_nodes(inj); }), di::bind<application::AppStateManager>.template to<application::AppStateManagerImpl>(), // bind io_context: 1 per injector di::bind<::boost::asio::io_context>.in( di::extension::shared)[boost::di::override], // bind interfaces di::bind<api::HttpListenerImpl>.to( [rpc_http_endpoint](const auto &injector) { return get_jrpc_api_http_listener(injector, rpc_http_endpoint); }), di::bind<api::WsListenerImpl>.to( [rpc_ws_endpoint](const auto &injector) { return get_jrpc_api_ws_listener(injector, rpc_ws_endpoint); }), di::bind<api::AuthorApi>.template to<api::AuthorApiImpl>(), di::bind<api::ChainApi>.template to<api::ChainApiImpl>(), di::bind<api::StateApi>.template to<api::StateApiImpl>(), di::bind<api::SystemApi>.template to<api::SystemApiImpl>(), di::bind<api::ApiService>.to([](const auto &injector) { return get_jrpc_api_service(injector); }), di::bind<api::JRpcServer>.template to<api::JRpcServerImpl>(), di::bind<authorship::Proposer>.template to<authorship::ProposerImpl>(), di::bind<authorship::BlockBuilder>.template to<authorship::BlockBuilderImpl>(), di::bind<authorship::BlockBuilderFactory>.template to<authorship::BlockBuilderFactoryImpl>(), di::bind<storage::BufferStorage>.to( [leveldb_path](const auto &injector) { return get_level_db(leveldb_path, injector); }), di::bind<blockchain::BlockStorage>.to( [](const auto &injector) { return get_block_storage(injector); }), di::bind<blockchain::BlockTree>.to( [](auto const &inj) { return get_block_tree(inj); }), di::bind<blockchain::BlockHeaderRepository>.template to<blockchain::KeyValueBlockHeaderRepository>(), di::bind<clock::SystemClock>.template to<clock::SystemClockImpl>(), di::bind<clock::SteadyClock>.template to<clock::SteadyClockImpl>(), di::bind<clock::Timer>.template to<clock::BasicWaitableTimer>(), di::bind<primitives::BabeConfiguration>.to([](auto const &injector) { return get_babe_configuration(injector); }), di::bind<consensus::BabeSynchronizer>.template to<consensus::BabeSynchronizerImpl>(), di::bind<consensus::grandpa::Environment>.template to<consensus::grandpa::EnvironmentImpl>(), di::bind<consensus::grandpa::VoteCryptoProvider>.template to<consensus::grandpa::VoteCryptoProviderImpl>(), di::bind<consensus::EpochStorage>.template to<consensus::EpochStorageImpl>(), di::bind<consensus::BlockValidator>.template to<consensus::BabeBlockValidator>(), di::bind<crypto::ED25519Provider>.template to<crypto::ED25519ProviderImpl>(), di::bind<crypto::Hasher>.template to<crypto::HasherImpl>(), di::bind<crypto::SR25519Provider>.template to<crypto::SR25519ProviderImpl>(), di::bind<crypto::VRFProvider>.template to<crypto::VRFProviderImpl>(), di::bind<crypto::Bip39Provider>.template to<crypto::Bip39ProviderImpl>(), di::bind<crypto::Pbkdf2Provider>.template to<crypto::Pbkdf2ProviderImpl>(), di::bind<crypto::Secp256k1Provider>.template to<crypto::Secp256k1ProviderImpl>(), di::bind<crypto::CryptoStore>.template to<crypto::CryptoStoreImpl>(), di::bind<extensions::ExtensionFactory>.template to( [](auto const &injector) { return get_extension_factory(injector); }), di::bind<network::Router>.template to<network::RouterLibp2p>(), di::bind<consensus::BabeGossiper>.template to<network::GossiperBroadcast>(), di::bind<consensus::grandpa::Gossiper>.template to<network::GossiperBroadcast>(), di::bind<network::Gossiper>.template to<network::GossiperBroadcast>(), di::bind<network::SyncClientsSet>.to([](auto const &injector) { return get_sync_clients_set(injector); }), di::bind<network::SyncProtocolObserver>.template to<network::SyncProtocolObserverImpl>(), di::bind<runtime::binaryen::WasmModule>.template to<runtime::binaryen::WasmModuleImpl>(), di::bind<runtime::binaryen::WasmModuleFactory>.template to<runtime::binaryen::WasmModuleFactoryImpl>(), di::bind<runtime::CoreFactory>.template to<runtime::binaryen::CoreFactoryImpl>(), di::bind<runtime::TaggedTransactionQueue>.template to<runtime::binaryen::TaggedTransactionQueueImpl>(), di::bind<runtime::ParachainHost>.template to<runtime::binaryen::ParachainHostImpl>(), di::bind<runtime::OffchainWorker>.template to<runtime::binaryen::OffchainWorkerImpl>(), di::bind<runtime::Metadata>.template to<runtime::binaryen::MetadataImpl>(), di::bind<runtime::GrandpaApi>.template to<runtime::binaryen::GrandpaApiImpl>(), di::bind<runtime::Core>.template to<runtime::binaryen::CoreImpl>(), di::bind<runtime::BabeApi>.template to<runtime::binaryen::BabeApiImpl>(), di::bind<runtime::BlockBuilder>.template to<runtime::binaryen::BlockBuilderImpl>(), di::bind<runtime::TrieStorageProvider>.template to<runtime::TrieStorageProviderImpl>(), di::bind<transaction_pool::TransactionPool>.template to<transaction_pool::TransactionPoolImpl>(), di::bind<transaction_pool::PoolModerator>.template to<transaction_pool::PoolModeratorImpl>(), di::bind<storage::changes_trie::ChangesTracker>.template to<storage::changes_trie::StorageChangesTrackerImpl>(), di::bind<storage::trie::TrieStorageBackend>.to( [](auto const &inj) { return get_trie_storage_backend(inj); }), di::bind<storage::trie::TrieStorageImpl>.to( [](auto const &inj) { return get_trie_storage_impl(inj); }), di::bind<storage::trie::TrieStorage>.to( [](auto const &inj) { return get_trie_storage(inj); }), di::bind<storage::trie::PolkadotTrieFactory>.template to<storage::trie::PolkadotTrieFactoryImpl>(), di::bind<storage::trie::Codec>.template to<storage::trie::PolkadotCodec>(), di::bind<storage::trie::TrieSerializer>.template to<storage::trie::TrieSerializerImpl>(), di::bind<runtime::WasmProvider>.template to<runtime::StorageWasmProvider>(), di::bind<application::ConfigurationStorage>.to( [genesis_path](const auto &injector) { return get_configuration_storage(genesis_path, injector); }), di::bind<network::ExtrinsicObserver>.template to<network::ExtrinsicObserverImpl>(), di::bind<network::ExtrinsicGossiper>.template to<network::GossiperBroadcast>(), di::bind<authority::AuthorityUpdateObserver>.template to<authority::AuthorityManagerImpl>(), di::bind<authority::AuthorityManager>.template to<authority::AuthorityManagerImpl>(), di::bind<consensus::grandpa::FinalizationObserver>.to( [](auto const &inj) { return get_finalization_observer(inj); }), // user-defined overrides... std::forward<decltype(args)>(args)...); } } // namespace kagome::injector #endif // KAGOME_CORE_INJECTOR_APPLICATION_INJECTOR_HPP
43.998647
120
0.673658
FlorianFranzen
d594616cadf9861adc32438c5dc7e2cd09c48072
713
cc
C++
table/raw_table_test.cc
SZ-NPE/SLM-DB
aa3abdac29a7806344e7b219fda7396085cc5dd2
[ "BSD-3-Clause" ]
17
2019-11-18T07:02:23.000Z
2021-12-30T10:15:08.000Z
table/raw_table_test.cc
SZ-NPE/SLM-DB
aa3abdac29a7806344e7b219fda7396085cc5dd2
[ "BSD-3-Clause" ]
null
null
null
table/raw_table_test.cc
SZ-NPE/SLM-DB
aa3abdac29a7806344e7b219fda7396085cc5dd2
[ "BSD-3-Clause" ]
18
2019-11-21T14:08:50.000Z
2022-03-17T07:46:16.000Z
#include "leveldb/env.h" #include "util/testharness.h" #include "raw_block_builder.h" uint64_t clflush_cnt = 0; uint64_t WRITE_LATENCY_IN_NS = 1000; namespace leveldb { class RAW_TABLE { }; TEST(RAW_TABLE, Blocks) { Options options; RawBlockBuilder builder(&options); for (int i = 0; i < 20; i++) { std::string key = "key"; key.append(std::to_string(i)); std::string value = "value"; value.append(std::to_string(i)); builder.Add(Slice(key), Slice(value)); } Slice result = builder.Finish(); char size[32]; memcpy(size, result.data(), 32); ASSERT_EQ(std::stoi(size), result.size()-32); //printf("%s", result.data()); }; } int main() { leveldb::test::RunAllTests(); }
19.805556
47
0.649369
SZ-NPE
d5953bec284bc2944f0f5da6301931a1ede0683a
297
cpp
C++
dependencies/faucmix-src/src/stream.cpp
wareya/kotareci
14c87d1364d442456f93cebe73a288f85b79ba74
[ "Libpng" ]
null
null
null
dependencies/faucmix-src/src/stream.cpp
wareya/kotareci
14c87d1364d442456f93cebe73a288f85b79ba74
[ "Libpng" ]
null
null
null
dependencies/faucmix-src/src/stream.cpp
wareya/kotareci
14c87d1364d442456f93cebe73a288f85b79ba74
[ "Libpng" ]
null
null
null
#include "stream.hpp" void * pcmstream::generateframe(SDL_AudioSpec * spec, unsigned int len, emitterinfo * info) {} bool pcmstream::isplaying() {} bool pcmstream::ready() {} Uint16 pcmstream::channels() {} void pcmstream::fire(emitterinfo * info) {} void pcmstream::cease(emitterinfo * info) {}
19.8
91
0.727273
wareya
d5978aa2e91b2fedd8890a321292114f39635b26
1,211
cpp
C++
SumofLeftLeaves/SumofLeftLeaves.cpp
sbchong/LeetCode
933c7d85519b473f48050b24465aaaba94eede8c
[ "Apache-2.0" ]
null
null
null
SumofLeftLeaves/SumofLeftLeaves.cpp
sbchong/LeetCode
933c7d85519b473f48050b24465aaaba94eede8c
[ "Apache-2.0" ]
null
null
null
SumofLeftLeaves/SumofLeftLeaves.cpp
sbchong/LeetCode
933c7d85519b473f48050b24465aaaba94eede8c
[ "Apache-2.0" ]
1
2020-07-29T14:36:51.000Z
2020-07-29T14:36:51.000Z
// SumofLeftLeaves.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode() : val(0), left(nullptr), right(nullptr) {} TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {} }; int sumOfLeftLeavesL(TreeNode* root) { if (!root)return 0; int result = 0; if (root->left && !root->left->left && !root->left->right) result += root->left->val; result += sumOfLeftLeavesL(root->left); result += sumOfLeftLeavesL(root->right); return result; } int main() { std::cout << "_______________start_______________\n\n"; TreeNode tree = { 1, &TreeNode(2,&TreeNode(4),&TreeNode(5)), &TreeNode(3) }; std::cout << "\t" << sumOfLeftLeavesL(&tree) << std::endl; } // 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单 // 调试程序: F5 或调试 >“开始调试”菜单 // 入门使用技巧: // 1. 使用解决方案资源管理器窗口添加/管理文件 // 2. 使用团队资源管理器窗口连接到源代码管理 // 3. 使用输出窗口查看生成输出和其他消息 // 4. 使用错误列表窗口查看错误 // 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目 // 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
27.522727
90
0.605285
sbchong
d5990f4be26649b13bfe75497021fd1e9240b32b
703
hpp
C++
include/alibabacloud/event_bridge_util.hpp
alibabacloud-sdk-cpp/eventbridge-util
3d679f81a6ce1f55bd1f22c757e9999c31ac5c1a
[ "Apache-2.0" ]
6
2020-09-10T06:40:24.000Z
2022-02-09T06:06:11.000Z
include/alibabacloud/event_bridge_util.hpp
alibabacloud-sdk-cpp/eventbridge-util
3d679f81a6ce1f55bd1f22c757e9999c31ac5c1a
[ "Apache-2.0" ]
69
2020-09-14T08:07:44.000Z
2022-01-27T09:05:09.000Z
include/alibabacloud/event_bridge_util.hpp
alibabacloud-sdk-cpp/eventbridge-util
3d679f81a6ce1f55bd1f22c757e9999c31ac5c1a
[ "Apache-2.0" ]
10
2020-09-11T07:54:03.000Z
2022-03-11T06:08:35.000Z
// This file is auto-generated, don't edit it. Thanks. #ifndef ALIBABACLOUD_EVENTBRIDGEUTIL_H_ #define ALIBABACLOUD_EVENTBRIDGEUTIL_H_ #include <boost/any.hpp> #include <darabonba/core.hpp> #include <iostream> using namespace std; namespace Alibabacloud_EventBridgeUtil { class Client { public: static string getStringToSign(shared_ptr<Darabonba::Request> request); static string getSignature(shared_ptr<string> stringToSign, shared_ptr<string> secret); static boost::any serialize(const shared_ptr<void> &events); static bool startWith(shared_ptr<string> origin, shared_ptr<string> prefix); Client(){}; }; } // namespace Alibabacloud_EventBridgeUtil #endif
27.038462
78
0.758179
alibabacloud-sdk-cpp
d59ab9d935963753331d357c5a80320501f64718
26
cpp
C++
src/orderparameters/SimpleVector.cpp
seanmarks/indus
a25012d79d5cb94986a3210a0c7f21b6d427ce5b
[ "MIT" ]
6
2019-01-14T16:03:19.000Z
2021-06-28T06:10:33.000Z
src/orderparameters/SimpleVector.cpp
seanmarks/indus
a25012d79d5cb94986a3210a0c7f21b6d427ce5b
[ "MIT" ]
3
2020-01-25T21:46:15.000Z
2021-08-17T15:31:53.000Z
src/orderparameters/SimpleVector.cpp
seanmarks/indus
a25012d79d5cb94986a3210a0c7f21b6d427ce5b
[ "MIT" ]
2
2021-01-29T16:53:19.000Z
2021-10-29T19:05:08.000Z
#include "SimpleVector.h"
13
25
0.769231
seanmarks
d59f1497dd708f9dec3713a85ee5fbafa18c14c8
870
cpp
C++
src/config.cpp
s-viour/wing
5635cabaaf614672e5d6ee2d4dd617d74198c30a
[ "MIT" ]
null
null
null
src/config.cpp
s-viour/wing
5635cabaaf614672e5d6ee2d4dd617d74198c30a
[ "MIT" ]
8
2021-11-24T04:16:07.000Z
2021-12-21T05:18:43.000Z
src/config.cpp
s-viour/wing
5635cabaaf614672e5d6ee2d4dd617d74198c30a
[ "MIT" ]
null
null
null
#include <fstream> #include <toml++/toml.h> #include <wing/config.h> using namespace wing; wing::project_config wing::load_config(const fs::path& path) { auto table = toml::parse_file(path.string()); auto name = table["name"].value<std::string>(); //auto project_type = table["type"].value<std::string>(); //auto vcpkg_dir = table["vcpkg_dir"].value<std::string>(); auto table_dependencies = table["dependencies"].as_array(); if (!name || !table_dependencies) { throw wing::config_error("missing required values or has malformed values"); } std::vector<dependency> dependencies; for (auto& table_dep : *table_dependencies) { auto dep = dependency { .name = table_dep.value<std::string>().value(), }; dependencies.push_back(dep); } return project_config { .name = name.value(), .dependencies = dependencies }; }
28.064516
80
0.673563
s-viour
d5a91f47fb10019fe2401979688879374980da79
3,862
cpp
C++
oomact/src/error-terms/ErrorTermWheelsZ.cpp
OnyxBlack7/oomact
5ae5fbbaddaf58e2fc24adaabedf711619934ac9
[ "BSD-3-Clause" ]
21
2017-06-19T13:57:59.000Z
2022-02-20T02:40:58.000Z
oomact/src/error-terms/ErrorTermWheelsZ.cpp
OnyxBlack7/oomact
5ae5fbbaddaf58e2fc24adaabedf711619934ac9
[ "BSD-3-Clause" ]
19
2017-05-10T09:11:25.000Z
2019-03-11T16:41:36.000Z
oomact/src/error-terms/ErrorTermWheelsZ.cpp
OnyxBlack7/oomact
5ae5fbbaddaf58e2fc24adaabedf711619934ac9
[ "BSD-3-Clause" ]
11
2017-06-19T13:39:12.000Z
2022-03-16T19:53:27.000Z
/****************************************************************************** * Copyright (C) 2013 by Jerome Maye * * jerome.maye@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the Lesser GNU General Public License as published by* * the Free Software Foundation; either version 3 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 * * Lesser GNU General Public License for more details. * * * * You should have received a copy of the Lesser GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************/ #include "aslam/calibration/error-terms/ErrorTermWheelsZ.h" #include <Eigen/Dense> using namespace aslam::backend; namespace aslam { namespace calibration { /******************************************************************************/ /* Constructors and Destructor */ /******************************************************************************/ ErrorTermWheelsZ::ErrorTermWheelsZ(const aslam::backend::EuclideanExpression& v_w_mwl, const aslam::backend::EuclideanExpression& v_w_mwr, const Covariance& sigma2_vert_vel) : _v_w_mwl(v_w_mwl), _v_w_mwr(v_w_mwr), _sigma2_vert_vel(sigma2_vert_vel) { setInvR(_sigma2_vert_vel.inverse()); DesignVariable::set_t dv; _v_w_mwl.getDesignVariables(dv); _v_w_mwr.getDesignVariables(dv); setDesignVariablesIterator(dv.begin(), dv.end()); } ErrorTermWheelsZ::ErrorTermWheelsZ(const ErrorTermWheelsZ& other) : ErrorTermFs<1>(other), _v_w_mwl(other. _v_w_mwl), _v_w_mwr(other. _v_w_mwr), _sigma2_vert_vel(other._sigma2_vert_vel){ } ErrorTermWheelsZ& ErrorTermWheelsZ::operator = (const ErrorTermWheelsZ& other) { if (this != &other) { ErrorTermFs<1>::operator=(other); _v_w_mwl = other._v_w_mwl; _v_w_mwr = other._v_w_mwr; _sigma2_vert_vel = other._sigma2_vert_vel; } return *this; } ErrorTermWheelsZ::~ErrorTermWheelsZ() { } /******************************************************************************/ /* Methods */ /******************************************************************************/ double ErrorTermWheelsZ::evaluateErrorImplementation() { error_t error; const double vzl = _v_w_mwl.toEuclidean()(2); const double vzr = _v_w_mwr.toEuclidean()(2); error(0) = vzl + vzr; setError(error); return evaluateChiSquaredError(); } void ErrorTermWheelsZ::evaluateJacobiansImplementation(JacobianContainer& jacobians) { Eigen::Matrix<double, 1, 3> Jl = Eigen::Matrix<double, 1, 3>::Zero(); Eigen::Matrix<double, 1, 3> Jr = Eigen::Matrix<double, 1, 3>::Zero(); Jl(2) = 1.0; Jr(2) = 1.0; _v_w_mwl.evaluateJacobians(jacobians, Jl); _v_w_mwr.evaluateJacobians(jacobians,Jr); } } }
40.229167
88
0.483687
OnyxBlack7
d5abff91677d3a21ba2d351f9751df7cdbc0e86f
400
cpp
C++
src/entity.cpp
kindanoob/pong
92f649e5d9f2286509ea5f8738097f0fc26e3a8f
[ "MIT" ]
null
null
null
src/entity.cpp
kindanoob/pong
92f649e5d9f2286509ea5f8738097f0fc26e3a8f
[ "MIT" ]
null
null
null
src/entity.cpp
kindanoob/pong
92f649e5d9f2286509ea5f8738097f0fc26e3a8f
[ "MIT" ]
null
null
null
#include "entity.h" Entity::Entity(const sf::Texture &texture, const std::string &name, int x, int y, double dx, double dy, int w, int h, int row, int col): name_(name), h_(h), w_(w), x_(x), y_(y), dx_(dx), dy_(dy), texture_(texture) { sprite_.setTexture(texture); sprite_.setTextureRect(sf::IntRect(col * w, row * h, w, h)); rect_ = sf::FloatRect(x, y, w, h); }
36.363636
87
0.5975
kindanoob
d5b10a97dd242b49178e0c5fe220607ba20daef3
7,119
cpp
C++
src/libtsduck/dtv/descriptors/tsISDBTerrestrialDeliverySystemDescriptor.cpp
cedinu/tsduck
dc693912b1fda85bcac3fcb830d7753bd8112552
[ "BSD-2-Clause" ]
1
2019-04-23T21:16:00.000Z
2019-04-23T21:16:00.000Z
src/libtsduck/dtv/descriptors/tsISDBTerrestrialDeliverySystemDescriptor.cpp
cedinu/tsduck
dc693912b1fda85bcac3fcb830d7753bd8112552
[ "BSD-2-Clause" ]
null
null
null
src/libtsduck/dtv/descriptors/tsISDBTerrestrialDeliverySystemDescriptor.cpp
cedinu/tsduck
dc693912b1fda85bcac3fcb830d7753bd8112552
[ "BSD-2-Clause" ]
null
null
null
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2021, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsISDBTerrestrialDeliverySystemDescriptor.h" #include "tsDescriptor.h" #include "tsNames.h" #include "tsTablesDisplay.h" #include "tsPSIRepository.h" #include "tsPSIBuffer.h" #include "tsDuckContext.h" #include "tsxmlElement.h" TSDUCK_SOURCE; #define MY_XML_NAME u"ISDB_terrestrial_delivery_system_descriptor" #define MY_CLASS ts::ISDBTerrestrialDeliverySystemDescriptor #define MY_DID ts::DID_ISDB_TERRES_DELIV #define MY_PDS ts::PDS_ISDB #define MY_STD ts::Standards::ISDB TS_REGISTER_DESCRIPTOR(MY_CLASS, ts::EDID::Private(MY_DID, MY_PDS), MY_XML_NAME, MY_CLASS::DisplayDescriptor); //---------------------------------------------------------------------------- // Constructors //---------------------------------------------------------------------------- ts::ISDBTerrestrialDeliverySystemDescriptor::ISDBTerrestrialDeliverySystemDescriptor() : AbstractDescriptor(MY_DID, MY_XML_NAME, MY_STD, 0), area_code(0), guard_interval(0), transmission_mode(0), frequencies() { } void ts::ISDBTerrestrialDeliverySystemDescriptor::clearContent() { area_code = 0; guard_interval = 0; transmission_mode = 0; frequencies.clear(); } ts::ISDBTerrestrialDeliverySystemDescriptor::ISDBTerrestrialDeliverySystemDescriptor(DuckContext& duck, const Descriptor& desc) : ISDBTerrestrialDeliverySystemDescriptor() { deserialize(duck, desc); } //---------------------------------------------------------------------------- // Serialization //---------------------------------------------------------------------------- void ts::ISDBTerrestrialDeliverySystemDescriptor::serializePayload(PSIBuffer& buf) const { buf.putBits(area_code, 12); buf.putBits(guard_interval, 2); buf.putBits(transmission_mode, 2); for (auto it = frequencies.begin(); it != frequencies.end(); ++it) { buf.putUInt16(HzToBin(*it)); } } //---------------------------------------------------------------------------- // Deserialization //---------------------------------------------------------------------------- void ts::ISDBTerrestrialDeliverySystemDescriptor::deserializePayload(PSIBuffer& buf) { buf.getBits(area_code, 12); buf.getBits(guard_interval, 2); buf.getBits(transmission_mode, 2); while (buf.canRead()) { frequencies.push_back(BinToHz(buf.getUInt16())); } } //---------------------------------------------------------------------------- // Enumerations in XML data. //---------------------------------------------------------------------------- namespace { const ts::Enumeration GuardIntervalNames({ {u"1/32", 0}, {u"1/16", 1}, {u"1/8", 2}, {u"1/4", 3}, }); const ts::Enumeration TransmissionModeNames({ {u"2k", 0}, {u"mode1", 0}, {u"4k", 1}, {u"mode2", 1}, {u"8k", 2}, {u"mode3", 2}, {u"undefined", 3}, }); } //---------------------------------------------------------------------------- // Static method to display a descriptor. //---------------------------------------------------------------------------- void ts::ISDBTerrestrialDeliverySystemDescriptor::DisplayDescriptor(TablesDisplay& disp, PSIBuffer& buf, const UString& margin, DID did, TID tid, PDS pds) { if (buf.canReadBytes(2)) { disp << margin << UString::Format(u"Area code: 0x%3X (%<d)", {buf.getBits<uint16_t>(12)}) << std::endl; const uint8_t guard = buf.getBits<uint8_t>(2); const uint8_t mode = buf.getBits<uint8_t>(2); disp << margin << UString::Format(u"Guard interval: %d (%s)", {guard, GuardIntervalNames.name(guard)}) << std::endl; disp << margin << UString::Format(u"Transmission mode: %d (%s)", {mode, TransmissionModeNames.name(mode)}) << std::endl; } while (buf.canReadBytes(2)) { disp << margin << UString::Format(u"Frequency: %'d Hz", {BinToHz(buf.getUInt16())}) << std::endl; } } //---------------------------------------------------------------------------- // XML serialization //---------------------------------------------------------------------------- void ts::ISDBTerrestrialDeliverySystemDescriptor::buildXML(DuckContext& duck, xml::Element* root) const { root->setIntAttribute(u"area_code", area_code, true); root->setEnumAttribute(GuardIntervalNames, u"guard_interval", guard_interval); root->setEnumAttribute(TransmissionModeNames, u"transmission_mode", transmission_mode); for (auto it = frequencies.begin(); it != frequencies.end(); ++it) { root->addElement(u"frequency")->setIntAttribute(u"value", *it, false); } } //---------------------------------------------------------------------------- // XML deserialization //---------------------------------------------------------------------------- bool ts::ISDBTerrestrialDeliverySystemDescriptor::analyzeXML(DuckContext& duck, const xml::Element* element) { xml::ElementVector xfreq; bool ok = element->getIntAttribute(area_code, u"area_code", true, 0, 0, 0x0FFF) && element->getIntEnumAttribute(guard_interval, GuardIntervalNames, u"guard_interval", true) && element->getIntEnumAttribute(transmission_mode, TransmissionModeNames, u"transmission_mode", true) && element->getChildren(xfreq, u"frequency", 0, 126); for (auto it = xfreq.begin(); ok && it != xfreq.end(); ++it) { uint64_t f = 0; ok = (*it)->getIntAttribute(f, u"value", true); frequencies.push_back(f); } return ok; }
38.690217
154
0.577047
cedinu
d5b39ffa193a8f72073a18803bfc48b7c3f511fe
592
cpp
C++
android-31/java/io/NotActiveException.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
12
2020-03-26T02:38:56.000Z
2022-03-14T08:17:26.000Z
android-31/java/io/NotActiveException.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
1
2021-01-27T06:07:45.000Z
2021-11-13T19:19:43.000Z
android-29/java/io/NotActiveException.cpp
YJBeetle/QtAndroidAPI
1468b5dc6eafaf7709f0b00ba1a6ec2b70684266
[ "Apache-2.0" ]
3
2021-02-02T12:34:55.000Z
2022-03-08T07:45:57.000Z
#include "../../JString.hpp" #include "./NotActiveException.hpp" namespace java::io { // Fields // QJniObject forward NotActiveException::NotActiveException(QJniObject obj) : java::io::ObjectStreamException(obj) {} // Constructors NotActiveException::NotActiveException() : java::io::ObjectStreamException( "java.io.NotActiveException", "()V" ) {} NotActiveException::NotActiveException(JString arg0) : java::io::ObjectStreamException( "java.io.NotActiveException", "(Ljava/lang/String;)V", arg0.object<jstring>() ) {} // Methods } // namespace java::io
21.925926
97
0.701014
YJBeetle
d5b49141afeee1125b245acc75c3de2651c2f55e
5,158
tcc
C++
flens/lapack/la/lanst.tcc
stip/FLENS
80495fa97dda42a0acafc8f83fc9639ae36d2e10
[ "BSD-3-Clause" ]
98
2015-01-26T20:31:37.000Z
2021-09-09T15:51:37.000Z
flens/lapack/la/lanst.tcc
stip/FLENS
80495fa97dda42a0acafc8f83fc9639ae36d2e10
[ "BSD-3-Clause" ]
16
2015-01-21T07:43:45.000Z
2021-12-06T12:08:36.000Z
flens/lapack/la/lanst.tcc
stip/FLENS
80495fa97dda42a0acafc8f83fc9639ae36d2e10
[ "BSD-3-Clause" ]
31
2015-01-05T08:06:45.000Z
2022-01-26T20:12:00.000Z
/* * Copyright (c) 2014, Michael Lehn * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1) Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3) Neither the name of the FLENS development group nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* Based on * DOUBLE PRECISION FUNCTION DLANST( NORM, N, D, E ) * * -- LAPACK auxiliary routine (version 3.2) -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * November 2006 */ #ifndef FLENS_LAPACK_LA_LANST_TCC #define FLENS_LAPACK_LA_LANST_TCC 1 #include <flens/blas/blas.h> #include <flens/lapack/lapack.h> namespace flens { namespace lapack { //== generic lapack implementation ============================================= namespace generic { template <typename VD, typename VE> typename VD::ElementType lanst_impl(Norm norm, const DenseVector<VD> &d, const DenseVector<VE> &e) { using std::abs; using std::max; using std::sqrt; typedef typename VD::ElementType T; typedef typename VD::IndexType IndexType; const T Zero(0), One(1); const Underscore<IndexType> _; const IndexType n = d.length(); T normA = 0; if (n==0) { normA = Zero; } else if (norm==MaximumNorm) { // // Find max(abs(A(i,j))). // normA = abs(d(n)); for (IndexType i=1; i<=n-1; ++i) { normA = max(normA, abs(d(i))); normA = max(normA, abs(e(i))); } } else if (norm==OneNorm || norm==InfinityNorm) { // // Find norm1(A). // if (n==1) { normA = abs(d(1)); } else { normA = max(abs(d(1)) +abs(e(1)), abs(e(n-1))+abs(d(n))); for (IndexType i=2; i<=n-1; ++i) { normA = max(normA, abs(d(i))+abs(e(i))+abs(e(i-1))); } } } else if (norm==FrobeniusNorm) { // // Find normF(A). // T scale = Zero; T sum = One; if (n>1) { lassq(e(_(1,n-1)), scale, sum); sum *= 2; } lassq(d, scale, sum); normA = scale*sqrt(sum); } return normA; } } // namespace generic //== interface for native lapack =============================================== #ifdef USE_CXXLAPACK namespace external { template <typename VD, typename VE> typename VD::ElementType lanst_impl(Norm norm, const DenseVector<VD> &d, const DenseVector<VE> &e) { typedef typename VD::IndexType IndexType; return cxxlapack::lanst<IndexType>(getF77Char(norm), d.length(), d.data(), e.data()); } } // namespace external #endif //== public interface ========================================================== template <typename VD, typename VE> typename RestrictTo<IsRealDenseVector<VD>::value && IsRealDenseVector<VE>::value, typename VD::ElementType>::Type lanst(Norm norm, const VD &d, const VE &e) { typedef typename VD::ElementType T; // // Test the input parameters // ASSERT(d.firstIndex()==1); ASSERT(e.firstIndex()==1); ASSERT(d.length()==e.length()+1 || d.length()==0); // // Call implementation // T result = LAPACK_SELECT::lanst_impl(norm, d, e); # ifdef CHECK_CXXLAPACK // // Compare results // T result_ = external::lanst_impl(norm, d, e); if (! isIdentical(result, result_, " result", "result_")) { ASSERT(0); } # endif return result; } } } // namespace lapack, flens #endif // FLENS_LAPACK_LA_LANST_TCC
28.185792
80
0.588019
stip
d5b6f7e628ff6bbd7230a7ed03e838c1f5eafcde
1,029
hpp
C++
Libraries/Engine/Level.hpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
3
2022-02-11T10:34:33.000Z
2022-02-24T17:44:17.000Z
Libraries/Engine/Level.hpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
null
null
null
Libraries/Engine/Level.hpp
RyanTylerRae/WelderEngineRevamp
3efdad59dd1821ddb1c09b59520e8e2d7023bb10
[ "MIT" ]
null
null
null
// MIT Licensed (see LICENSE.md). #pragma once namespace Zero { /// A level is resource that stores a set of objects that can be loaded into /// a space. Level is different from most resource types in that it does /// not really store the level data on the object but always loads the /// data from the file system. class Level : public Resource { public: ZilchDeclareType(Level, TypeCopyMode::ReferenceType); Level(); ~Level(); // Resource interface void UpdateContentItem(ContentItem* contentItem) override; // Save the current contents of the space into the level. void SaveSpace(Space* space); // Load the level contents into the space. void LoadSpace(Space* space); String GetLoadPath(); /// Path to level file. String LoadPath; DataNode* mCacheTree; }; /// Resource Manager for Levels. class LevelManager : public ResourceManager { public: DeclareResourceManager(LevelManager, Level); LevelManager(BoundType* resourceType); static void ClearCachedLevels(); }; } // namespace Zero
22.369565
76
0.73275
RyanTylerRae
d5bac26d7bd25b563ec2ef3d1131aa52666770c8
1,871
cpp
C++
modules/spatialos/player_controls_sync.cpp
CharlesMicou/spatialgodot
f2d3819af3c8ef12026efc17e5e45f0cc5a4b9b8
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
23
2019-03-15T11:25:16.000Z
2022-02-07T06:26:19.000Z
modules/spatialos/player_controls_sync.cpp
CharlesMicou/spatialgodot
f2d3819af3c8ef12026efc17e5e45f0cc5a4b9b8
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
null
null
null
modules/spatialos/player_controls_sync.cpp
CharlesMicou/spatialgodot
f2d3819af3c8ef12026efc17e5e45f0cc5a4b9b8
[ "CC-BY-3.0", "Apache-2.0", "MIT" ]
1
2019-03-23T11:45:38.000Z
2019-03-23T11:45:38.000Z
#include "player_controls_sync.h" #include "editor_node.h" #include "spatial_util.h" #include <improbable/worker.h> #include "component_view.h" #include <spellcrest/player_controls.h> WorkerLogger PlayerControlsSync::logger = WorkerLogger("player_controls_sync"); void PlayerControlsSync::sync(const Vector2 destination) { if (controls_component == NULL) { logger.warn("PlayerControlsSync node has no controls component, unable to sync."); return; } if (controls_component->hasAuthority()) { float x = destination.x; float y = destination.y; godotcore::GodotCoordinates2D asGodotData = godotcore::GodotCoordinates2D(godotcore::GodotCoordinates2D(godotcore::GodotChunk2D(), godotcore::GodotVector2D(x, y))); controls_component->tryUpdate(spellcrest::PlayerControls::Update{}.set_move_destination(asGodotData)); } } Vector2 PlayerControlsSync::get_controls_value() { if (controls_component == NULL) { return Vector2(); } std::pair<float, float> localpos = toLocalGodotPosition(controls_component->getData().move_destination(), 0, 0); return Vector2(localpos.first, localpos.second); } void PlayerControlsSync::set_player_controls_component(Node* component) { controls_component = dynamic_cast<ComponentView<spellcrest::PlayerControls>*>(component); if (controls_component == NULL) { logger.warn("A PlayerControlsSync node received incorrectly configured component refs."); } } PlayerControlsSync::PlayerControlsSync() { } void PlayerControlsSync::_bind_methods() { ClassDB::bind_method(D_METHOD("sync"), &PlayerControlsSync::sync); ClassDB::bind_method(D_METHOD("set_player_controls_components"), &PlayerControlsSync::set_player_controls_component); ClassDB::bind_method(D_METHOD("get_controls_value"), &PlayerControlsSync::get_controls_value); }
40.673913
172
0.750935
CharlesMicou
d5c3c11b4e8a0abc93ed89fde09bd8536ae0681a
8,038
cc
C++
Fleece/Core/SharedKeys.cc
tophatch/fleece
8853b610575c1a7d68681a792188bab9c0c1ec7d
[ "Apache-2.0" ]
134
2016-05-09T19:42:55.000Z
2022-01-16T13:05:18.000Z
Fleece/Core/SharedKeys.cc
tophatch/fleece
8853b610575c1a7d68681a792188bab9c0c1ec7d
[ "Apache-2.0" ]
70
2016-05-09T05:16:46.000Z
2022-03-08T19:43:30.000Z
Fleece/Core/SharedKeys.cc
tophatch/fleece
8853b610575c1a7d68681a792188bab9c0c1ec7d
[ "Apache-2.0" ]
32
2016-05-19T10:38:06.000Z
2022-01-30T22:45:25.000Z
// // SharedKeys.cc // // Copyright 2016-Present Couchbase, Inc. // // Use of this software is governed by the Business Source License included // in the file licenses/BSL-Couchbase.txt. As of the Change Date specified // in that file, in accordance with the Business Source License, use of this // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. // #include "SharedKeys.hh" #include "FleeceImpl.hh" #include "FleeceException.hh" #define LOCK(MUTEX) lock_guard<mutex> _lock(MUTEX) namespace fleece { namespace impl { using namespace std; SharedKeys::SharedKeys() :_table(2047) { } SharedKeys::~SharedKeys() { #ifdef __APPLE__ for (auto &str : _platformStringsByKey) { if (str) CFRelease(str); } #endif } key_t::key_t(const Value *v) noexcept { if (v->isInteger()) _int = (int16_t)v->asInt(); else _string = v->asString(); } bool key_t::operator== (const key_t &k) const noexcept { return shared() ? (_int == k._int) : (_string == k._string); } bool key_t::operator< (const key_t &k) const noexcept { if (shared()) return k.shared() ? (_int < k._int) : true; else return k.shared() ? false : (_string < k._string); } size_t SharedKeys::count() const { LOCK(_mutex); return _count; } bool SharedKeys::loadFrom(slice stateData) { return loadFrom(Value::fromData(stateData)); } bool SharedKeys::loadFrom(const Value *state) { if (!state) return false; Array::iterator i(state->asArray()); LOCK(_mutex); if (i.count() <= _count) return false; i += _count; // Start at the first _new_ string for (; i; ++i) { slice str = i.value()->asString(); if (!str) return false; int key; if (!SharedKeys::_add(str, key)) return false; } return true; } void SharedKeys::writeState(Encoder &enc) const { auto count = _count; enc.beginArray(count); for (size_t key = 0; key < count; ++key) enc.writeString(_byKey[key]); enc.endArray(); } alloc_slice SharedKeys::stateData() const { Encoder enc; writeState(enc); return enc.finish(); } bool SharedKeys::encode(slice str, int &key) const { // Is this string already encoded? auto entry = _table.find(str); if (_usuallyTrue(entry.key != nullslice)) { key = entry.value; return true; } return false; } bool SharedKeys::encodeAndAdd(slice str, int &key) { if (encode(str, key)) return true; // Should this string be encoded? if (str.size > _maxKeyLength || !isEligibleToEncode(str)) return false; LOCK(_mutex); if (_count >= kMaxCount) return false; throwIf(!_inTransaction, SharedKeysStateError, "not in transaction"); // OK, add to table: return _add(str, key); } bool SharedKeys::_add(slice str, int &key) { auto value = uint16_t(_count); auto entry = _table.insert(str, value); if (!entry.key) return false; // failed if (entry.value == value) { // new key: _byKey[value] = entry.key; ++_count; } key = entry.value; return true; } __hot bool SharedKeys::isEligibleToEncode(slice str) const { for (size_t i = 0; i < str.size; ++i) if (_usuallyFalse(!isalnum(str[i]) && str[i] != '_' && str[i] != '-')) return false; return true; } bool SharedKeys::isUnknownKey(int key) const { LOCK(_mutex); return _isUnknownKey(key); } /** Decodes an integer back to a string. */ slice SharedKeys::decode(int key) const { throwIf(key < 0, InvalidData, "key must be non-negative"); if (_usuallyFalse(key >= kMaxCount)) return nullslice; slice str = _byKey[key]; if (_usuallyFalse(!str)) return decodeUnknown(key); return str; } slice SharedKeys::decodeUnknown(int key) const { // Unrecognized key -- if not in a transaction, try reloading const_cast<SharedKeys*>(this)->refresh(); // Retry after refreshing: LOCK(_mutex); return _byKey[key]; } vector<slice> SharedKeys::byKey() const { LOCK(_mutex); return vector<slice>(&_byKey[0], &_byKey[_count]); } SharedKeys::PlatformString SharedKeys::platformStringForKey(int key) const { throwIf(key < 0, InvalidData, "key must be non-negative"); LOCK(_mutex); if ((unsigned)key >= _platformStringsByKey.size()) return nullptr; return _platformStringsByKey[key]; } void SharedKeys::setPlatformStringForKey(int key, SharedKeys::PlatformString platformKey) const { LOCK(_mutex); throwIf(key < 0, InvalidData, "key must be non-negative"); throwIf((unsigned)key >= _count, InvalidData, "key is not yet known"); if ((unsigned)key >= _platformStringsByKey.size()) _platformStringsByKey.resize(key + 1); #ifdef __APPLE__ _platformStringsByKey[key] = CFStringCreateCopy(kCFAllocatorDefault, platformKey); #else _platformStringsByKey[key] = platformKey; #endif } void SharedKeys::revertToCount(size_t toCount) { LOCK(_mutex); if (toCount >= _count) { throwIf(toCount > _count, SharedKeysStateError, "can't revert to a bigger count"); return; } // (Iterating backwards helps the ConcurrentArena free up key space.) for (int key = _count - 1; key >= int(toCount); --key) { _table.remove(_byKey[key]); _byKey[key] = nullslice; } _count = unsigned(toCount); } #pragma mark - PERSISTENCE: PersistentSharedKeys::PersistentSharedKeys() { _inTransaction = false; } bool PersistentSharedKeys::refresh() { // CBL-87: Race with transactionBegan, possible to enter a transaction and // get to here before the transaction reads the new shared keys. They won't // be read here due to _inTransaction being true LOCK(_refreshMutex); return !_inTransaction && read(); } void PersistentSharedKeys::transactionBegan() { // CBL-87: Race with refresh, several lines between here and when new // shared keys are actually read leaving a void in between where the shared // keys are trying to read but cannot properly be refreshed (via Pusher's // sendRevision for example) LOCK(_refreshMutex); throwIf(_inTransaction, SharedKeysStateError, "already in transaction"); _inTransaction = true; read(); // Catch up with any external changes } void PersistentSharedKeys::transactionEnded() { if (_inTransaction) { _committedPersistedCount = _persistedCount; _inTransaction = false; } } // Subclass's read() method calls this bool PersistentSharedKeys::loadFrom(const Value *state) { throwIf(changed(), SharedKeysStateError, "can't load when already changed"); if (!SharedKeys::loadFrom(state)) return false; _committedPersistedCount = _persistedCount = count(); return true; } void PersistentSharedKeys::save() { if (changed()) { write(stateData()); // subclass hook _persistedCount = count(); } } void PersistentSharedKeys::revert() { revertToCount(_committedPersistedCount); _persistedCount = _committedPersistedCount; } } }
27.621993
101
0.585096
tophatch
d5d292335c54348c250a7153199e33b654cd9459
77,031
inl
C++
src/fonts/stb_font_arial_bold_49_usascii.inl
stetre/moonfonts
5c8010c02ea62edcf42902e09478b0cd14af56ea
[ "MIT" ]
3
2018-03-13T12:51:57.000Z
2021-10-11T11:32:17.000Z
src/fonts/stb_font_arial_bold_49_usascii.inl
stetre/moonfonts
5c8010c02ea62edcf42902e09478b0cd14af56ea
[ "MIT" ]
null
null
null
src/fonts/stb_font_arial_bold_49_usascii.inl
stetre/moonfonts
5c8010c02ea62edcf42902e09478b0cd14af56ea
[ "MIT" ]
null
null
null
// Font generated by stb_font_inl_generator.c (4/1 bpp) // // Following instructions show how to use the only included font, whatever it is, in // a generic way so you can replace it with any other font by changing the include. // To use multiple fonts, replace STB_SOMEFONT_* below with STB_FONT_arial_bold_49_usascii_*, // and separately install each font. Note that the CREATE function call has a // totally different name; it's just 'stb_font_arial_bold_49_usascii'. // /* // Example usage: static stb_fontchar fontdata[STB_SOMEFONT_NUM_CHARS]; static void init(void) { // optionally replace both STB_SOMEFONT_BITMAP_HEIGHT with STB_SOMEFONT_BITMAP_HEIGHT_POW2 static unsigned char fontpixels[STB_SOMEFONT_BITMAP_HEIGHT][STB_SOMEFONT_BITMAP_WIDTH]; STB_SOMEFONT_CREATE(fontdata, fontpixels, STB_SOMEFONT_BITMAP_HEIGHT); ... create texture ... // for best results rendering 1:1 pixels texels, use nearest-neighbor sampling // if allowed to scale up, use bilerp } // This function positions characters on integer coordinates, and assumes 1:1 texels to pixels // Appropriate if nearest-neighbor sampling is used static void draw_string_integer(int x, int y, char *str) // draw with top-left point x,y { ... use texture ... ... turn on alpha blending and gamma-correct alpha blending ... glBegin(GL_QUADS); while (*str) { int char_codepoint = *str++; stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR]; glTexCoord2f(cd->s0, cd->t0); glVertex2i(x + cd->x0, y + cd->y0); glTexCoord2f(cd->s1, cd->t0); glVertex2i(x + cd->x1, y + cd->y0); glTexCoord2f(cd->s1, cd->t1); glVertex2i(x + cd->x1, y + cd->y1); glTexCoord2f(cd->s0, cd->t1); glVertex2i(x + cd->x0, y + cd->y1); // if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct x += cd->advance_int; } glEnd(); } // This function positions characters on float coordinates, and doesn't require 1:1 texels to pixels // Appropriate if bilinear filtering is used static void draw_string_float(float x, float y, char *str) // draw with top-left point x,y { ... use texture ... ... turn on alpha blending and gamma-correct alpha blending ... glBegin(GL_QUADS); while (*str) { int char_codepoint = *str++; stb_fontchar *cd = &fontdata[char_codepoint - STB_SOMEFONT_FIRST_CHAR]; glTexCoord2f(cd->s0f, cd->t0f); glVertex2f(x + cd->x0f, y + cd->y0f); glTexCoord2f(cd->s1f, cd->t0f); glVertex2f(x + cd->x1f, y + cd->y0f); glTexCoord2f(cd->s1f, cd->t1f); glVertex2f(x + cd->x1f, y + cd->y1f); glTexCoord2f(cd->s0f, cd->t1f); glVertex2f(x + cd->x0f, y + cd->y1f); // if bilerping, in D3D9 you'll need a half-pixel offset here for 1:1 to behave correct x += cd->advance; } glEnd(); } */ #ifndef STB_FONTCHAR__TYPEDEF #define STB_FONTCHAR__TYPEDEF typedef struct { // coordinates if using integer positioning float s0,t0,s1,t1; signed short x0,y0,x1,y1; int advance_int; // coordinates if using floating positioning float s0f,t0f,s1f,t1f; float x0f,y0f,x1f,y1f; float advance; } stb_fontchar; #endif #define STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH 256 #define STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT 280 #define STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT_POW2 512 #define STB_FONT_arial_bold_49_usascii_FIRST_CHAR 32 #define STB_FONT_arial_bold_49_usascii_NUM_CHARS 95 #define STB_FONT_arial_bold_49_usascii_LINE_SPACING 32 static unsigned int stb__arial_bold_49_usascii_pixels[]={ 0x200bfff5,0x003ceeff,0x00ffffe6,0x07feedb8,0xd9955000,0x0579bdfd, 0x3fe20000,0xaaaa807f,0x2aaaaa2a,0x512aaaaa,0x55555555,0x7fdc0035, 0x51000004,0x357bdd97,0x0c400000,0xeeeeb800,0x3bae004e,0x3ffe3eee, 0xffff802f,0xf9802eff,0xea803fff,0x007fffff,0x3ffff260,0xffffffff, 0x00002dff,0x2013fff2,0x3a7fffff,0xffffffff,0xfffff15f,0x007fffff, 0x00027fdc,0x3fffff20,0xdfffffff,0xeda80000,0x2e0bdfff,0xff35eeee, 0x2001ffff,0x21ffffff,0x400ffffc,0xffffffff,0x7fffcc02,0x7fffdc03, 0x44007fff,0xffffffeb,0xffffffff,0x002fffff,0x0ffffcc0,0x3fffffc0, 0xfffffffd,0x3ffe2bff,0x3fffffff,0xeffeb980,0x74c0001c,0xffffffff, 0x3fffffff,0x3fff6000,0x91ffffff,0x7f4fffff,0x9803ffff,0x446fffff, 0x7c04ffff,0x6fffffff,0x1ffffcc0,0xffffff10,0x7cc00fff,0xffffffff, 0xffffffff,0x0dffffff,0xbfffb000,0x3ffffe00,0x3fffffa7,0xff15ffff, 0xffffffff,0x7fffdc07,0x03ffffff,0xfffffc80,0xffffffff,0x00efffff, 0x3ffffa60,0xafffffff,0x2e7ffffc,0x805fffff,0x83fffffc,0x201ffffd, 0xffffffff,0x3ffe602f,0x3ffee03f,0x007fffff,0xfffffff7,0x54c3357b, 0xfffffdcb,0x7cc001ff,0xff002fff,0x7ff4ffff,0x5fffffff,0xfffffff1, 0xfb107fff,0xffffffff,0x1001bfff,0xfffffffd,0xffffffff,0x03ffffff, 0x3fffffa0,0xffffffff,0x227ffffe,0x00ffffff,0x07fffffc,0x02ffffd4, 0xffffd533,0x7ffcc09f,0x3fff603f,0x4019adff,0xefffffd8,0xfc88000b, 0x001fffff,0x801ffff6,0x3a7fffff,0xaaaeffff,0x2a66662a,0xd83fffff, 0xffffffff,0x05ffffff,0xffffffc8,0xfdccefff,0xffffffff,0xffffa806, 0xfdbbcfff,0x7fffffff,0x1fffffec,0xbfffff30,0x07ffffc0,0x5fffff80, 0x0ffffe60,0x06ffffe8,0x77ffff40,0xfb300002,0x3001dfff,0x4009ffff, 0x3a199999,0x4006ffff,0x43fffff9,0xfffffffa,0xffffffff,0x3ffe603f, 0x201effff,0xffffffd8,0x7fff403f,0xfe980eff,0x547fffff,0x205fffff, 0x02fffffc,0x00fffff2,0x037ffff4,0x407ffff3,0x005fffff,0x03bffff2, 0x3fea0000,0xffe805ff,0x200001ff,0x006ffffe,0x1fffffcc,0x33fffffe, 0xfffccffb,0x3ffa06ff,0x000dffff,0xfffffff7,0x3fffee01,0x3fe200ff, 0xff87ffff,0xfd00ffff,0xfa80ffff,0xf9007fff,0x7cc0dfff,0x3fe03fff, 0xf5004fff,0x22009fff,0xfffb8000,0x3ffea02f,0x7400007f,0x4006ffff, 0x23fffff9,0x73fffff9,0x3fff29ff,0xfffb81ff,0xb8005fff,0x05ffffff, 0x09fffff9,0xffffff90,0x7fffff90,0x9fffff30,0x5fffff00,0xdffff900, 0x1ffffcc0,0x07fffff0,0x09ffff10,0x77ff6544,0x3333321c,0x81bfff62, 0x004ffffd,0xd377776c,0x800dffff,0x23fffff9,0x70fffffa,0x3ffe69ff, 0xffff81ef,0xd0000fff,0x03ffffff,0x03fffffb,0xffffff30,0xbfffff30, 0x3fffff90,0xbffffb00,0xfffff900,0x1ffffcc0,0x07fffff0,0x40dfffd0, 0xfffffffa,0xffff8aff,0x3fffe23f,0x5fffff01,0xfffff800,0x1bffffa7, 0xfffff300,0x2ffffe47,0x00cc9ff7,0x3fffffe6,0x3fea0004,0xfe83ffff, 0x8800ffff,0xd07fffff,0xe81fffff,0x7006ffff,0x900fffff,0x4c0fffff, 0x3e03ffff,0x4c03ffff,0xf501ffff,0xffffffff,0xfffffbff,0x84fffa85, 0x00fffff9,0x3fffffc0,0x00dffffd,0x3fffff98,0xb9ffffee,0x7d4004ff, 0x000fffff,0x7fffff40,0x7fffff84,0x3ffffe00,0xfffff707,0x7ffffcc7, 0xffff5004,0xfffb803f,0x3ffe607f,0x3fffe03f,0x7ffe402f,0xfffff504, 0xffffdbdf,0x881fffff,0xffc87fff,0xff8007ff,0x3ffa7fff,0x7cc006ff, 0x3ea3ffff,0xff72ffff,0xfffb8009,0xd80007ff,0x445fffff,0x007fffff, 0x41fffffe,0x25fffff8,0x01fffffb,0x7fffff30,0xfffffb80,0x7ffff300, 0x3ffffe20,0x3fffe202,0xfffffb80,0x7fffd40d,0xfff06fff,0xffffe81f, 0xffff8006,0x3ffffa7f,0x7ffcc006,0x3ffe63ff,0x4ffbbfff,0x7fffe400, 0xfb80006f,0x7c46ffff,0x800fffff,0x07fffff8,0x43fffff6,0x006ffffe, 0x17ffffe2,0x3fffff50,0x0ffffe60,0x07ffffd4,0x10bfff70,0x40bfffff, 0x5ffffffa,0x443fffb0,0x005fffff,0x27fffff8,0x006ffffe,0x1fffffcc, 0x3ffffffa,0x74004fff,0x005fffff,0xfffffa80,0xffffff87,0xffff9801, 0x3ffea07f,0xffff9aff,0x7ffc003f,0x7fc407ff,0xff304fff,0x3ff607ff, 0x7ff407ff,0xffffc82f,0xffffe806,0x5fff703f,0x27ffffcc,0x7ffffc00, 0x1bffffa7,0xfffff300,0xfffffa87,0x002effff,0x0ffffffe,0x3ffe6000, 0x7ff41fff,0xfb802fff,0x7c07ffff,0xffbdffff,0x7c000fff,0xd807ffff, 0x981fffff,0xf983ffff,0x7c06ffff,0xfff887ff,0xffd802ff,0xff501fff, 0x7fffd47f,0xfff8003f,0x3fffa7ff,0x7fcc006f,0xffe83fff,0xffffffff, 0x7ffc01cf,0x80003fff,0x1ffffff9,0x37ffffec,0x7fffff40,0x7fffe407, 0x05ffffef,0xfffffe80,0x7fffd400,0x3fe61bef,0x3fea23ff,0x2202ffff, 0xffc85fff,0xff9007ff,0x3f201fff,0x3ffee2ff,0xff8002ff,0x3ffa7fff, 0x7cc006ff,0xd883ffff,0xffffffff,0x3a04ffff,0x004fffff,0xfffffa80, 0x7fffcc1f,0x3ff203ff,0x4c07ffff,0xffffffff,0xfd8002ff,0xe800ffff, 0x4fffffff,0x367ffff3,0x6fffffff,0x427ffcc0,0x004fffff,0x40dffffb, 0x3ee0fffe,0x8002ffff,0x3a7fffff,0x4006ffff,0x03fffff9,0x3ffffff2, 0x0effffff,0x5fffffd8,0xfffb8000,0xffe80fff,0x260cffff,0xfffffffd, 0xffffe807,0x0007ffff,0x03fffff9,0xfffffd10,0x3fffe69f,0xffffffb3, 0xfffa801d,0x7ffffc43,0xffffd003,0x1fffe209,0x03fffff9,0xffffff00, 0x037ffff4,0x3ffffe60,0x7ffe4403,0xffffffff,0xfffffc86,0xffc80006, 0xfa80ffff,0xffffffff,0xffffffff,0xffb807ff,0x04ffffff,0xfffff700, 0x3ffa2003,0xfff34fff,0x3ffff67f,0xfff7006f,0xfffff985,0xffff8801, 0xdfff503f,0x0fffffd8,0xfffff800,0x1bffffa7,0xfffff300,0x7ffe4007, 0x3fffffff,0x3fffffdc,0x7ffec000,0x3ff207ff,0xffffffff,0xfffffdff, 0xffff8807,0x0001ffff,0x03fffff7,0x3fffff20,0x7ffff34f,0x3ffffff6, 0x1fffc803,0x07ffffd4,0x7ffffcc0,0x89fff901,0x00fffffc,0x7fffff80, 0x01bffffa,0x7fffff30,0x76ffdc00,0x47ffffff,0x1ffffffa,0xff8805c0, 0x6405ffff,0xffffffff,0xfffff4ff,0x3fff600f,0x20006fff,0x00fffffb, 0xffffffd8,0x7ffff34f,0x3ffffff6,0x7ffe404f,0x3ffffe41,0x7ffffb80, 0x83ffff10,0x01fffffb,0x7fffff80,0x01bffffa,0x7fffff30,0xaa7fdc00, 0x20ffffff,0x5ffffff8,0x9033fe60,0x07ffffff,0xffffff70,0x7fffc7ff, 0xfff5007f,0x40007fff,0x00fffffc,0x7fffffcc,0xffff30bc,0x3fffb267, 0x3ee01fff,0x7ffe42ff,0xfff8807f,0xfffd06ff,0xfffff70b,0xffff0003, 0x7ffff4ff,0x7ffcc006,0x3ee003ff,0x3fffee4f,0x7ffff41f,0xfffb01ff, 0xffff119f,0x22001fff,0x40bdeeca,0x006fffff,0x1ffffff3,0x7ffe4000, 0xfffe807f,0xfff982ff,0xffffc83f,0x3ffea05f,0x7ffffd43,0x7fffdc00, 0xffffd84f,0xfffffa80,0xffff8002,0x3ffffa7f,0x7ffcc006,0x0a9883ff, 0xff893fee,0x7fcc2fff,0x440effff,0xefffffff,0x04ffffff,0xfff88000, 0xffb006ff,0x8000dfff,0x806ffffd,0x305fffff,0x3a07ffff,0x2607ffff, 0x7fcc4fff,0x3e202fff,0x5c2fffff,0xf304ffff,0x0007ffff,0x74ffffff, 0x4006ffff,0x53fffff9,0x5c7fffff,0x7fff44ff,0xffffc81f,0x7f4c1eff, 0xffffffff,0x26a206ff,0x7ffcc000,0xff9805ff,0x0003ffff,0x027ffff4, 0x0bffffe6,0x81ffffcc,0x00fffffa,0xf88dfff1,0x3606ffff,0x11ffffff, 0x01dffff7,0x13ffffe2,0x3ffffe00,0x1bffffa7,0xfffff300,0x3ffffe27, 0xf993fee6,0xf880ffff,0xbfffffff,0x7ffffcc1,0x202fffff,0x2eeffffa, 0x7ffffd40,0x7fff4404,0x20000fff,0x03fffff8,0x07ffffd4,0x03ffff98, 0x03fffff3,0x320ffff4,0x8bffffff,0xfffffea8,0xffffcdff,0x7ff401ff, 0xff8004ff,0x3ffa7fff,0x7cc006ff,0x3fa3ffff,0xff72ffff,0x3ffffe49, 0xffffff70,0xffddffff,0xffffffff,0xffff880b,0xff300fff,0x7445ffff, 0xfffffdcc,0x4c0003ff,0x401fffff,0x207ffffb,0x103ffff9,0x405fffff, 0xfe85fffb,0xffffffff,0xffffffff,0x1fffffff,0x6ffffc80,0xfffff800, 0x1bffffa7,0xfffff300,0x7ffffe47,0xf54ffbbf,0xc809ffff,0xffffffff, 0xffffffff,0x03ffffff,0x7ffffffc,0xffedbbdf,0x7c46ffff,0xffffffff, 0x5c0000ff,0xb807ffff,0x2607ffff,0xf103ffff,0x4405ffff,0x7cc0ffff, 0xffffffff,0xfffffeff,0x00dfffff,0x1fffff50,0xfffff800,0x1bffffa7, 0xfffff300,0x7ffffc47,0xfedfffff,0x800fffff,0xffffffe9,0xffffffff, 0xefffffff,0xfffff502,0xffffffff,0xf03fffff,0xffffffff,0xf900005f, 0xf900bfff,0x7cc0ffff,0x3fe03fff,0x7ec03fff,0xffd885ff,0xd1efffff, 0xdfffffff,0xfff88007,0x7fc002ff,0x3ffa7fff,0x7cc006ff,0x7d43ffff, 0xffffffff,0x3fffffff,0x7fffe400,0xffffffff,0xffffffff,0xffc81eff, 0xffffffff,0x04ffffff,0xfffffffd,0x3a00005f,0xc802ffff,0x2606ffff, 0x3e03ffff,0x4c03ffff,0x9504ffff,0xc9859dfd,0x201ceefe,0x7ec1aaaa, 0x7c004fff,0x3fa7ffff,0x4c006fff,0xc83fffff,0xffffffff,0x04ffffff, 0xffdb9300,0x5bffffff,0xfffffff5,0x3ffee01f,0xffffffff,0x3f602eff, 0x00beffff,0xffff1000,0x3fff200f,0x3ffe606f,0x3fffe03f,0xfffc803f, 0x0000003f,0x03bfffa2,0x00dffff5,0x27fffff8,0x006ffffe,0x1fffffcc, 0xffffffb8,0x02ffffff,0x55d4c000,0xfffd881a,0xeda804ff,0xdeffffff, 0x00262003,0x7ffdc000,0xfffb004f,0x7ffcc0df,0x3fffe03f,0xfffd004f, 0x0000007f,0x03ffffd1,0x003ffffe,0x3fffffc4,0x00dffffd,0x3fffff98, 0x3ffff620,0x000befff,0xfa800000,0x30000fff,0x00000003,0xffffd800, 0xffffd001,0x7fffcc0d,0x3ffffe03,0xffff1006,0x000003df,0x13ffffaa, 0x02ffffc8,0xffffff50,0x037ffff4,0x3ffffe60,0xbffb3003,0x00000001, 0x000fae00,0x00000000,0xffff8800,0xfffc8806,0x3fe605ff,0x3ffa03ff, 0xa800bfff,0x1cffffff,0xffd50000,0xf880bfff,0x2ae05fff,0x6ffffffc, 0x01bffffa,0x7fffff30,0x027fdc00,0x00000000,0x00000000,0x2e000000, 0x3e01ffff,0xffffffff,0x3fffe603,0x3ffff203,0x4c07ffff,0xfffffffe, 0xb71000ac,0x7fffffff,0x3ffff600,0xfffff880,0x3fa4ffff,0xeeeeffff, 0xfddddd14,0x4007ffff,0x00004ffb,0x00000000,0x00000000,0x7fff4000, 0x7ffffc05,0x2600ffff,0x2203ffff,0xffffffff,0xffff9007,0xdfffffff, 0xffffdddd,0x3fffffff,0x7fffc400,0xfffffa83,0x3fa2ffff,0xffffffff, 0xffffff15,0x4007ffff,0x00004ffb,0x00000000,0x00000000,0x3ffe6000, 0x7fffc00f,0x4c04ffff,0x6403ffff,0x7fffffff,0x3fffa600,0xffffffff, 0xffffffff,0x000cffff,0xc86fffc8,0xffffffff,0x7fffff44,0xff15ffff, 0xffffffff,0x0d54c007,0x00000000,0x00000000,0xb0000000,0xff009fff, 0x019fffff,0x03ffff98,0x7ffffec4,0xeb88007f,0xffffffff,0xffffffff, 0x440002df,0x7ec2ffff,0x86ffffff,0xfffffffe,0xffff15ff,0x07ffffff, 0x00000000,0x00000000,0x00000000,0x0ffff880,0xcfffff80,0xffff3000, 0x3ff66007,0x440007ff,0xffffeecb,0x0bcdefff,0x3fea0000,0x7fffe45f, 0xeed80ace,0x4eeeeeee,0xddddddd1,0x00005ddd,0x00000000,0x00000000, 0x88000000,0x33000999,0x26600013,0x98800099,0x20000019,0x00000098, 0x44066660,0x00000009,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0xb7100000,0x200059dd,0x0005fffc,0x00000060,0x00000130, 0x37bbb72a,0x000000ab,0x3bfb72e2,0x0000abcd,0x03577530,0x26ea2000, 0x3fa00000,0xfffa86ff,0xa980003f,0x5552aaaa,0x7d401555,0x1effffff, 0x3fffe200,0x3b260001,0x2a1bdfff,0x7746eeee,0x36e23eee,0x002cefff, 0x7fffec40,0xffffffff,0xd700000d,0xffffffff,0x0019ffff,0xfffff910, 0x80019fff,0xffffffd8,0x220000ce,0xfc85ffff,0x80002fff,0xd6fffffb, 0x201fffff,0xfffffffb,0xf9000fff,0x5c000bff,0xffffffff,0xfffff72f, 0x34fffff8,0xffffffff,0x3ea0009f,0xffffffff,0x2fffffff,0x3ffa6000, 0xffffffff,0x04ffffff,0x3ffffee0,0x3fffffff,0xfffff700,0x03ffffff, 0x3fffe600,0x0ffffe83,0xfffb8000,0xffffd6ff,0x3fffe01f,0x4ffffecf, 0x1ffff880,0xfffd8800,0xffffffff,0x47ffffba,0xf9cfffff,0xffffffff, 0xb1000eff,0xffffffff,0xffffffff,0xb8001bff,0xffffffff,0xffffffff, 0xfb805fff,0xffffffff,0x403fffff,0xfffffffd,0x03ffffff,0x1ffffb80, 0x007ffff8,0xfffff700,0x3fffffad,0x1ffffb80,0x003ffff2,0x000bfff9, 0x3ffffff2,0xefffffff,0x7fc7ffff,0xffffefff,0xffffffff,0xffe8805f, 0xffffffff,0xffffffff,0xf9001fff,0xffffffff,0xffffffff,0x4c09ffff, 0xffffffff,0xffffffff,0xfffff701,0xffffffff,0xfd8007ff,0x7fcc0fff, 0x700005ff,0x3adfffff,0xd80fffff,0x7fcc6fff,0x3fe202ff,0xf98001ff, 0xceffffff,0xffffffdb,0x7fffc7ff,0xccefffff,0xfffffffe,0x7fffe402, 0xccefffff,0xfffffffd,0xffa806ff,0xefffffff,0xffffdccd,0xd03fffff, 0x7dffffff,0xffffffd5,0xfffff10b,0xfffd79df,0x4001ffff,0xfa86fffe, 0x00003fff,0x2dfffff7,0x80fffffe,0x7c45fffe,0x3f203fff,0xfb0005ff, 0x107fffff,0xfffffffd,0xfffffff8,0xffffa82f,0x3fea06ff,0x01efffff, 0x3fffff62,0x3fe203ff,0x03ffffff,0x7fffffdc,0xfffff06f,0xffff303f, 0xffffb0ff,0xffff50bf,0x3e200bff,0xffc85fff,0x700002ff,0x22dfffff, 0xff019999,0xfff889ff,0xffff104f,0xfff30003,0x7c405fff,0x7c7fffff, 0x01ffffff,0x3fffffe6,0xfffff882,0xf7000dff,0x01ffffff,0x3ffffffa, 0xfff1000e,0xf985ffff,0x3a06ffff,0x7c1fffff,0x700fffff,0x01ffffff, 0x07ffff30,0x001ffffb,0x3fffee00,0xfff8006f,0x5ffff84f,0x00bfff90, 0x3ffffee0,0xffffc806,0x7ffffc7f,0xfffd805f,0xfffc84ff,0xa8005fff, 0x85ffffff,0x6ffffff9,0xffff9800,0x7ffd45ff,0x3fea03ff,0x3fe22fff, 0x7fc04fff,0x32a2ffff,0xfffdcccc,0xffccccdf,0x003ccfff,0x7ffffdc0, 0xffff8006,0x27fffc44,0x00ffffc4,0xfffffc80,0xffff8803,0x7ffffc7f, 0xfffa801f,0xffff85ff,0xd0000fff,0x83ffffff,0x1ffffffc,0xbfffb000, 0xffff8859,0x3ffea03f,0x3ffea0ff,0x7fe403ff,0x3ff24fff,0xffffffff, 0xffffffff,0x0006ffff,0xb7ffffdc,0x80eeeeed,0x7c45fffe,0xffc83fff, 0x3f60005f,0xf002ffff,0xff8fffff,0x9800ffff,0x4c6fffff,0x04ffffff, 0x3fffea00,0x7fffc3ff,0x220005ff,0xfffe800a,0x3fff606f,0x7fffdc6f, 0x7ffdc02f,0x3fff26ff,0xffffffff,0xffffffff,0x40006fff,0xd6fffffb, 0xb01fffff,0xffa8ffff,0x7ffc42ff,0x3fe0001f,0xd001ffff,0xff8fffff, 0xf1007fff,0xfc8fffff,0x000fffff,0x7fffff40,0x3ffffea4,0x0000001f, 0x03fffff9,0x89fffff3,0x02fffffb,0x3fffffd4,0xfffffff9,0xffffffff, 0xdfffffff,0xfffb8000,0xffffd6ff,0xffff501f,0x3ffffa27,0x02fffe40, 0x3ffffe00,0xfffd000f,0xfffff8ff,0x3fffe007,0x3fff60ff,0xc80006ff, 0x2e5fffff,0x00ffffff,0xff300000,0xb55bffff,0x83ffffff,0x03fffffa, 0x7fffffdc,0xffffff90,0xffffffff,0xffffffff,0xffb8000d,0xfffd6fff, 0x3ffa01ff,0xffffffff,0x0ffffc43,0x3fffa000,0xfff000ff,0xffff8fff, 0x3ffe007f,0x7fff47ff,0xb80005ff,0x326fffff,0x007fffff,0x7fd40000, 0xffffffff,0xf980efff,0x6404ffff,0x11ffffff,0xfff93333,0xff33335f, 0x01333dff,0xffffb800,0xfffffd6f,0x3fffe601,0xc86fffff,0x80005fff, 0x01fffffd,0x8ffffff0,0x00ffffff,0x6fffff88,0x27fffffc,0x7ffd4000, 0x3fff67ff,0x000006ff,0xffffd880,0x05ffffff,0x1fffffe2,0xfffffff0, 0x7fffec03,0x2ffffc40,0x3fee0000,0xfffd6fff,0x7f4401ff,0x884fffff, 0x0001ffff,0x2fffffc8,0xfffff980,0x7fffffc7,0xffff9802,0x7ffffc5f, 0xf980003f,0xfd1fffff,0x100bffff,0xdddddddd,0x205ddddd,0xffffffc8, 0x200dffff,0x03fffffd,0xfffffff9,0x37fffc03,0x01ffffd4,0x3ffee000, 0xffffd6ff,0x7953001f,0x3fff2015,0x00266205,0x0bfffff7,0xffffff90, 0x5ffffff8,0xfffffc80,0x7fffffc4,0xff980003,0xffd2ffff,0xf300bfff, 0xffffffff,0xf507ffff,0xffffffff,0x207fffff,0xcffffff9,0xfffffb31, 0x3e205fff,0xffc85fff,0x400001ff,0xd6fffffb,0x001fffff,0x7fffc400, 0xffffea81,0xffff302e,0x7fc403ff,0x7fc7ffff,0x201fffff,0x3ffffff8, 0x27fffffc,0x7ffd4000,0xfffb0fff,0xff300dff,0xffffffff,0xff987fff, 0xeddfffff,0x03ffffff,0xfffffff9,0xffffffff,0x3ea03fff,0xffd83fff, 0x400000ff,0xd6fffffb,0x001fffff,0x2fffe400,0x7fffffec,0xfffd05ff, 0xfd301dff,0xf8ffffff,0x1fffffff,0xfffffd88,0xfffffd86,0xffb80005, 0x3ff27fff,0xf9807fff,0xffffffff,0x7fc3ffff,0xfb83ffff,0xd01fffff, 0xffffffff,0xffffffff,0x3ffee03f,0x6ffff81f,0xffb80000,0xfffd6fff, 0x200001ff,0x5c1ffff8,0xffffffff,0xfff983ff,0xcaacffff,0xffffffff, 0x7fffffc7,0xecaacfff,0x82ffffff,0x06fffffc,0xffffc800,0x3ffff26f, 0xfff9807f,0xffffffff,0x3ffe63ff,0x3fee04ff,0x3f205fff,0xffffffff, 0x1ffffff9,0xfffd9995,0xff99999f,0x79999dff,0xfffb8000,0xffffd6ff, 0x3200001f,0x7fc45fff,0xffea9eff,0xfffd80ff,0xffffffff,0x7fffffff, 0x7ffffffc,0xffffffff,0xf706ffff,0x000fffff,0xbfffffb0,0x7fffffd4, 0x55554401,0xfffffaaa,0x3fffee3f,0x7fff402f,0x3f6a00ff,0xf88dffff, 0xf90fffff,0xffffffff,0xffffffff,0x00dfffff,0xfffffb80,0x1fffffd6, 0xfff10000,0xffffb83f,0x0ffffea1,0x3fffffe2,0xfcffffff,0x7fc7ffff, 0xfffcffff,0xffffffff,0xffff501f,0x440005ff,0x24ffffff,0x4ffffff8, 0x7fffc000,0x3fffa3ff,0xfffd807f,0x153001ff,0x7fffff98,0x3ffffff2, 0xffffffff,0xffffffff,0xb8033106,0xfd5fffff,0x0001ffff,0x90bfff90, 0xfff0ffff,0x3ffa209f,0x3fffffff,0xf8ffffff,0xff57ffff,0xbfffffff, 0x7fffc401,0x320006ff,0x42ffffff,0x0ffffffd,0x3fffe000,0xffff13ff, 0xfff900bf,0xa80005ff,0x325fffff,0xffffffff,0xffffffff,0x16ffffff, 0x80dfffdd,0xd5fffffc,0x001fffff,0x1ffff880,0xf86fffd8,0x7e405fff, 0x21dfffff,0x7c7fffff,0x3a67ffff,0x04efffff,0xffffffd0,0xfff10005, 0xfa81ffff,0x004fffff,0x3fffffe0,0xdfffff13,0xfffff900,0xffc80003, 0x3ff24fff,0xffffffff,0xffffffff,0xff16ffff,0xfc80ffff,0xffd5ffff, 0x80001fff,0xfd05fffc,0xfffd0dff,0x06aa200d,0x23fffffc,0x307fffff, 0xf9800155,0x01ffffff,0x3ffff620,0xfff883ff,0x8002ffff,0x3ffffff9, 0x01fffffe,0x83fffffa,0x405eccaa,0x21ffffff,0xffffe998,0xfffa9999, 0x099999df,0x03fffffe,0x4fffffe8,0x01fffffd,0x7fffc400,0x0dfffd01, 0x000dfffd,0x3fffffc0,0x01fffffe,0x7ffe4000,0x9803ffff,0x6ffffffe, 0x3ffffea0,0xfb1004ff,0x47ffffff,0x03fffffd,0x1fffffe6,0x05fffffb, 0x1fffffea,0xa86ffff8,0xd803ffff,0x304fffff,0x25ffffff,0x00fffffe, 0x17fff200,0xf86fffd8,0x00005fff,0xf1fffffe,0x000fffff,0x3fffe200, 0x21adffff,0xfffffca8,0x7ec01fff,0xbeffffff,0x3ff2e609,0x3fffffff, 0x3fffffee,0xffffe881,0x7fffdc5f,0x7ffcc0ef,0xff103fff,0xfff909ff, 0xfff9003f,0x74c19fff,0xd0ffffff,0x001fffff,0x07fffe20,0xf87fffc8, 0x00004fff,0xf1fffffe,0x000fffff,0x7fffdc00,0xffffffff,0xffffffff, 0xff8805ff,0xffffffff,0xffffffff,0x2fffffff,0x3fffffe2,0xfffbaadf, 0x7c41ffff,0xbdffffff,0x6ffffffd,0x0ffffea0,0x401ffff6,0xfffffff8, 0xffffffff,0x3fffa4ff,0xf90000ff,0xffb80bff,0x3ffea1ff,0x3e00003f, 0x7fc7ffff,0x00007fff,0x7ffffe40,0xffffffff,0xdfffffff,0xfffd3000, 0xffffffff,0xffffffff,0xff305fff,0xffffffff,0x07ffffff,0x3ffffff6, 0xffffffff,0x3fff202f,0x6ffff81f,0x3ffff200,0xffffffff,0x3fa0ffff, 0x8000ffff,0x801ffff8,0xfbafffff,0x0000ffff,0x1fffffe0,0x00ffffff, 0xffd30000,0xffffffff,0x5fffffff,0xfffb1000,0xffffffff,0xffffffff, 0x7ffdc01b,0xffffffff,0x3a206fff,0xffffffff,0x401fffff,0x440ffffd, 0x2004ffff,0xfffffff8,0xffffffff,0x7fffff41,0xfffc8000,0xffff7006, 0x07ffffff,0xffff8000,0x7ffffc7f,0x20000007,0xfffffffc,0xdfffffff, 0x7f5c0000,0xffffffff,0x1dffffff,0xfffff700,0x9fffffff,0xffffd300, 0x1bffffff,0x0dffff00,0x007ffff5,0xfffffd88,0x1fffffff,0x0fffffe8, 0x7fffc400,0x3fff2001,0x004fffff,0xfffff800,0x3fffffc7,0x26000000, 0xffffffdc,0x0002ceff,0x7fffe4c0,0xadffffff,0xffc88000,0x1dffffff, 0x7fffdc00,0x1003efff,0xf709ffff,0x20003fff,0xffffffea,0xffd00bef, 0xc8001fff,0xa8006fff,0x02effffd,0x99990000,0xccccc899,0x00000004, 0x0055d4c4,0x53100000,0x00033577,0x1aba9880,0xaba98000,0xccc98001, 0x4ccca82c,0xba988000,0x0000019a,0x00266660,0x00003100,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x5cc00000,0xabceeeed,0x2e600000,0x01bceeec,0x2aaaaa00, 0x20000002,0x000ffffa,0x2aaaaa00,0x0dd4c002,0x0ffffe00,0x1ab98000, 0xba880000,0x00abceed,0x55d44000,0x654c0001,0x400abdee,0xfffffffb, 0x00dfffff,0x3fff2200,0x0dffffff,0x7fffc400,0x0000006f,0x001bfff2, 0xffffff00,0xffffd500,0xfb005dff,0x44000bff,0xffffffec,0x7e40002e, 0xffffffff,0x20000dff,0xffffffda,0xffd8003f,0x05ffffff,0xffffffd3, 0xffffffff,0xf980019f,0xffffffff,0x2001ffff,0x06fffff8,0x3fa00000, 0x400004ff,0x407fffff,0xfffffffb,0x7dc04fff,0xf30007ff,0xffffffff, 0xd30009ff,0xffffffff,0x07ffffff,0xfffff900,0x03dfffff,0x3fffff60, 0xf984ffff,0xffffffff,0xffffffff,0x3fa2005f,0xffffffff,0x000fffff, 0x0dfffff1,0x3e200000,0x00002fff,0x03fffffc,0xfffffffb,0x01bfffff, 0x003fffe6,0xffffff50,0xdfffffff,0x3ffee001,0xffffffff,0x0effffff, 0xffffe880,0xffffffff,0x7ffe400f,0x2fffffff,0xffffffe8,0xffffffff, 0x003fffff,0xbffffff9,0xfffffd77,0x3ffe2009,0x000006ff,0x01ffff50, 0xffff8000,0xffff907f,0xffffffff,0x7ffc09ff,0x3fe6002f,0xffffffff, 0x805fffff,0xfffffffe,0xffffffff,0x4406ffff,0xffffffff,0x6fffffff, 0x7fffff40,0x4c0fedff,0xdfffffff,0xfffcbaab,0x801fffff,0x82fffffe, 0x007ffffd,0x0dfffff1,0x3f200000,0x800007ff,0x887fffff,0xcfffffff, 0xfffffffc,0x09fffb01,0x7ffffec0,0xffffdbef,0x3ee02fff,0xefffffff, 0xffffeccd,0x3604ffff,0xbeffffff,0xfffffffc,0x3ffffe02,0xfffc803f, 0x36200dff,0x03ffffff,0x06fffff8,0x01fffff3,0xdfffff10,0x3a000000, 0x00005fff,0x87fffff8,0x86fffffc,0x05fffffd,0x200dfff7,0x1ffffff8, 0x7fffff44,0xfffff105,0x36601bff,0x1fffffff,0xffffff98,0xfffffc83, 0xfffff104,0xfffd001f,0xfd1003ff,0xf00bffff,0x220fffff,0x801fffff, 0x06fffff8,0xff880000,0x800003ff,0xf87fffff,0x882fffff,0x307fffff, 0x7001ffff,0x207fffff,0x06fffffb,0x7ffffff9,0x3ffff600,0xfffd84ff, 0xfff104ff,0x3fe20fff,0xf8807fff,0x2006ffff,0x07fffffb,0x3fffffd8, 0x06ffffb8,0xdfffff10,0x980000c0,0x8001ffff,0x3fffe018,0x7fffcc7f, 0x3fff606f,0xffff02ff,0xffff9005,0x3ffe201f,0xfff987ff,0x74003fff, 0x447fffff,0x01ffffff,0x02af37b6,0x1bffffe2,0x3ffffe20,0xddd3002f, 0xfb80199b,0x2e1fffff,0x004fffff,0x4dfffff1,0xcefffec8,0xfff70002, 0x7f6d400f,0x3fe0cdff,0x7fdc7fff,0x3ee04fff,0xfd04ffff,0x4c4009ff, 0x7fffc03a,0xffffe85f,0x7dc000ff,0x2a0bdfff,0x005fffff,0x7ff77540, 0xeeeeffff,0xffffff81,0x4000001e,0xfffffff8,0xffffffc8,0xffff1001, 0x3fffeadf,0x004fffff,0x805fffd8,0xffffffd8,0xffff1fff,0xffffc8ff, 0x3ffea03f,0xfff905ff,0xf300000d,0xff07ffff,0x0007ffff,0x7dc01591, 0x0004ffff,0x7fffffdc,0x2fffffff,0xffffffd8,0x00000bef,0xffffff50, 0x7fffffff,0x7fffc400,0xfffffbff,0x0effffff,0x0ffffe00,0xfffffd30, 0xf7ffffff,0xfe8fffff,0x2602ffff,0x506fffff,0x0001ffff,0x7ffff440, 0x7fffc40f,0x000000ff,0x0ffffff6,0x3ee00351,0xffffffff,0xfa82ffff, 0xffffffff,0x0000acef,0x3fffff60,0x04ffffff,0x7ffffc40,0xffffffff, 0x05ffffff,0x03ffff30,0xffffffe8,0xffffffff,0x7fc7ffff,0x2201ffff, 0x107fffff,0x0005ffff,0xffffb988,0xfffa84ff,0x000007ff,0x97fffff4, 0x2efffffc,0x3ffffee0,0xffffffff,0xfffff902,0xffffffff,0x8800017b, 0xffffffff,0xf88002ff,0xffffffff,0xffffdbbc,0xfb802fff,0x7fdc07ff, 0xbbcfffff,0xfffffffd,0x7ffffc7f,0x3ffe201f,0xffd00fff,0xff80009f, 0x03ffffff,0x0dfffff7,0xfff80000,0xfffeafff,0x80dfffff,0xfffffffb, 0x02ffffff,0x3ffffffa,0xffffffff,0xe98001df,0xffffffff,0xff10000e, 0x01dfffff,0xdffffff3,0x0bfffb00,0xeffffff8,0xffffe981,0x7fffc7ff, 0x3fe201ff,0xf900ffff,0x44000dff,0x2fffffff,0x3fffff20,0x7c000006, 0xffffffff,0xffffffff,0x3ffe200e,0x6c4006ff,0xffffffff,0xffffffff, 0x3fff2001,0xffffffff,0xfff10001,0x4c01ffff,0x02ffffff,0x701ffffc, 0x01ffffff,0x7fffffcc,0x3ffffe27,0x3ffe200f,0xff500fff,0x7cc000ff, 0x0bffffff,0xbfffffb0,0x7c400000,0xffffffff,0xffffffff,0x3ffe205f, 0xd30006ff,0xffffffff,0x5fffffff,0xfffffb00,0xdfffffff,0x3ffe2000, 0xfe804fff,0x2604ffff,0x3201ffff,0x804fffff,0x27fffffd,0x0ffffff8, 0x3ffffe20,0xffff101f,0x3fea0003,0x3fffffff,0x4fffffe8,0x3e200000, 0xefffffff,0xffffb98a,0xfff102ff,0x98000dff,0xffffffeb,0x3fffffff, 0x3fffff60,0xfffffeff,0x05677c5f,0x7fffffc4,0xffffa800,0x3ffee05f, 0x7fffec07,0xfffa801f,0x3ffe27ff,0x3e200fff,0x200fffff,0x0003fffe, 0xfffb7797,0xffd89fff,0x00005fff,0x3ffffe20,0xfff505ff,0x3fe20fff, 0x00006fff,0x3ffff6e2,0x0fffffff,0xffffffb8,0xfffff89f,0xffff53ff, 0xffff889f,0xfff3007f,0x7fec0dff,0x7fffc06f,0xff9800ff,0x3fe27fff, 0x2201ffff,0x00ffffff,0x0017fff2,0xfffff980,0x3ffff21f,0x4000006f, 0x1fffffff,0x3fffff60,0xfffff881,0x26000006,0xfffffffb,0x7fffc43f, 0x3fe60eff,0xfd9fffff,0x7c41ffff,0x3007ffff,0x40ffffff,0x7c04ffff, 0x1007ffff,0xf8ffffff,0x201fffff,0x0ffffff8,0x01fffea0,0xffff5000, 0x7fffdcdf,0x4000007f,0x06ffffff,0x17ffffd4,0x37ffffc4,0x64400000, 0x46ffffff,0x07fffffc,0xdffffff7,0x10ffffff,0x00dfffff,0x1fffffe2, 0x017fffc4,0x0ffffff1,0x3fffffc0,0x07fffffe,0x7fffff88,0x0ffffc40, 0x3ffe0000,0xfff50fff,0x54000fff,0x7ffffc00,0x7ffcc05f,0xfff884ff, 0x554406ff,0xd8005dcb,0x6c7fffff,0x204fffff,0xfffffffc,0xf884ffff, 0x1007ffff,0x20ffffff,0x400ffffa,0x007fffff,0x8ffffff1,0x02fffffe, 0x1bffffe6,0x00ffffe0,0xffffb000,0x3fffe25f,0xf88001ff,0xffe81bef, 0x7c404fff,0xf885ffff,0x4c06ffff,0x00ffffff,0x7ffffd40,0x7fffffc7, 0x7ffff402,0x81ffffff,0x07fffff8,0xdfffff30,0x01bfff20,0x03fffffe, 0x3ffffe60,0x7ffffec7,0x3fffea03,0xfffd805f,0x7ec00005,0x3fe3ffff, 0x8005ffff,0x1efffffa,0x17fffff2,0xbfffff10,0xdfffff10,0xffffff00, 0xfffa8007,0x7fffc7ff,0x7fc400ff,0x4fffffff,0xffffff10,0xffff5003, 0x3fffa0bf,0xffffd804,0xfffa801f,0x7ffe47ff,0x3fee04ff,0xfb804fff, 0xcca887ff,0xffe804fe,0x3ff62fff,0x4001ffff,0x47fffffe,0x06fffffb, 0x27ffffcc,0x37ffffc4,0x7ffffec0,0x3ff6000f,0x7ff46fff,0xf9802fff, 0x1fffffff,0xffffff10,0xffffb009,0xffff109f,0xffff9005,0xfffb009f, 0xfffa8fff,0x3ff606ff,0xf9802fff,0x7fc41fff,0x7c406fff,0x220fffff, 0x05ffffff,0x3fffff20,0x7fffc43f,0x3fea01ff,0xff882fff,0xfa806fff, 0x005fffff,0xbffffff7,0x5fffffd8,0xffffe980,0xf881efff,0x01ffffff, 0x3fffffe6,0x0ffffa82,0xfffffb80,0x3ffe600f,0xfff87fff,0xff982fff, 0x3e007fff,0xffe83fff,0x3f202fff,0xfb87ffff,0x00efffff,0x7fffffd4, 0xffffe80f,0x3fffa05f,0xfff881ff,0xff8806ff,0x0affffff,0xfffffd98, 0x7ffdc1ff,0x3f204fff,0xffffffff,0x7ffc42ff,0x881fffff,0x06fffffe, 0x200dfff9,0xeffffff8,0xffffe880,0xfffd87ff,0xfffe86ff,0x3f6005ff, 0xfffb85ff,0xffb82fff,0xfd04ffff,0x37ffffff,0x7fffecc4,0xff705fff, 0xf709ffff,0x220dffff,0x006fffff,0xfffffff5,0xfffddfff,0x0dffffff, 0x3ffffffa,0xfffdcbce,0xffffffff,0xff10dfff,0x9fffffff,0xfffff755, 0x3ffa05ff,0x3fee004f,0xaacfffff,0xfffffffc,0xffff987f,0xfffccfff, 0x2001ffff,0xf887fffb,0xcfffffff,0xffffffec,0xffff500e,0xffffffff, 0xffffffff,0x7fff401d,0xfeccefff,0x102fffff,0x00dfffff,0x7fffffe4, 0xffffffff,0x00ffffff,0xfffffff3,0xffffffff,0xffffffff,0x3fe29fff, 0xffffffff,0xffffffff,0xffff105f,0xfffe8005,0xffffffff,0x7fffffff, 0xffffff90,0xffffffff,0xfff98009,0xffffa80f,0xffffffff,0x5c01ffff, 0xffffffff,0xffffffff,0x7cc00fff,0xffffffff,0x05ffffff,0x1bffffe2, 0xfffffb00,0xffffffff,0x803fffff,0xfffffffa,0xffffffff,0xfffffbcf, 0xffff10ef,0xfffff97f,0x3dffffff,0x03fffea0,0xfffff300,0x7fffffff, 0x40fffff9,0xfffffffd,0x00efffff,0x02ffff80,0xfffffff9,0x7fffffff, 0x3fffa600,0xffffffff,0x001fffff,0xfffffff3,0x1dffffff,0x7ffffc40, 0xffea8006,0xffffffff,0x000dffff,0xffffffb1,0x3dffffff,0x07ffff44, 0x27fffff1,0xfffffffb,0x3f200dff,0xd10007ff,0xffffffff,0x3ffff25f, 0x7fffdc07,0x04ffffff,0x13fff600,0xffffffb8,0x01efffff,0xfffffc80, 0xffffffff,0x7f44000c,0xffffffff,0xfff8804f,0x2e0006ff,0xfffffffe, 0x0002dfff,0xffffffd7,0x7dc07dff,0x7fffc42f,0x3fff6a3f,0xfe803eff, 0x640005ff,0x1dfffffe,0x01fffff2,0x3fffff6a,0x5c0002ef,0x64406fff, 0xffffffff,0x76540003,0xffffffff,0x7640000c,0x2effffff,0xfffff100, 0x2660000d,0x001aabca,0x55dd4400,0x000e6000,0x8002aa60,0x0001cccc, 0x00035510,0x00dd4c00,0x99993000,0x4ddd4400,0x53000000,0x00001357, 0x0006ae60,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x2aaaa000,0xaa8001aa,0x5550aaaa, 0x00000555,0x55300330,0x55555555,0x55555555,0x55415555,0x001aaaaa, 0x2aaaaaa0,0x2aaaaa0a,0x544001aa,0x542aaaaa,0x001aaaaa,0x2aaaaaaa, 0x2aaaa001,0x2aaaa0aa,0x4c0002aa,0x542aaaaa,0x0002aaaa,0x7fffffd0, 0xffff8800,0xffffd0ff,0x2000001f,0xfc803fc8,0xffffffff,0xffffffff, 0x2e1fffff,0x06ffffff,0xfffff700,0xffffa8bf,0x7e4006ff,0x644fffff, 0x006fffff,0xfffffff1,0x3ffe600d,0x3ff60fff,0x0000ffff,0x1bfffffa, 0x00ffffff,0x3ffffa00,0x7fc4003f,0xffd0ffff,0x00001fff,0x007fff70, 0xfffffff9,0xffffffff,0x3fffffff,0xffffffe8,0x7ffc4003,0xfd80ffff, 0x004fffff,0xfffffff3,0xfffffa81,0xffff5007,0x7001ffff,0xa8dfffff, 0x03ffffff,0xfffff100,0xfffff87f,0xffd00007,0x88007fff,0xd0ffffff, 0x001fffff,0x7fff4c00,0xfffc803f,0xffffffff,0xffffffff,0x7fcc1fff, 0x000fffff,0x3ffffff6,0xfffff103,0xffd003ff,0xf105ffff,0x003fffff, 0xfffffff9,0xfff9005f,0xffff09ff,0x2e000dff,0x40ffffff,0x007fffff, 0xfffffd00,0xfff88007,0xfffd0fff,0x400001ff,0x03fffffc,0xffffffc8, 0xffffffff,0xffffffff,0xfffffc81,0xfff3004f,0xfb80dfff,0x406fffff, 0x5ffffffb,0x3fffffe0,0xffffe803,0xe804ffff,0xc82fffff,0x00ffffff, 0xfffffd80,0x7fffff86,0xfffd0000,0xf88007ff,0xfd0fffff,0x0001ffff, 0x7ffffe40,0xffffc803,0xffffffff,0xffffffff,0xffe881ff,0xe801ffff, 0x01ffffff,0xffffffe8,0xfffff103,0x7fec01ff,0x7c405fff,0xffffffff, 0x7fffc406,0xfff980ff,0x44003fff,0x83ffffff,0x007fffff,0xfffffd00, 0xfff88007,0xfffd0fff,0x400001ff,0x03fffffc,0x3fee0000,0x203fffff, 0x6ffffffa,0x7ffffd40,0xfff3004f,0xfb01ffff,0x807fffff,0x06fffffb, 0x7fffffdc,0x2600ffff,0x207fffff,0x06fffffe,0x7ffffdc0,0xfffff80f, 0xffd00007,0x88007fff,0xd0ffffff,0x001fffff,0x7fffe400,0x5000003f, 0xbfffffff,0xfffffb00,0x3ffe207f,0x5c006fff,0x45ffffff,0x6ffffffa, 0xfffff980,0x3fff600f,0x2fffffff,0x3ffffee0,0x3ffff205,0x3f6001ff, 0xff05ffff,0x0000ffff,0x0ffffffa,0xfffff100,0x3ffffa1f,0x3001100f, 0xffffffdd,0x0007dddd,0xffffff10,0x3fe200df,0xc80fffff,0x02ffffff, 0xfffffe80,0x3ffffa1f,0xfff000ff,0x7fc05fff,0xffffffff,0x3fff604f, 0x3fe603ff,0x1003ffff,0x05ffffff,0x01fffffe,0x7ffff400,0x7fc4003f, 0xffd0ffff,0x76d41fff,0xa80cdfff,0xffffffff,0x0004ffff,0x7fffff44, 0x3ee000ff,0x444fffff,0x05ffffff,0xfffff300,0x3fffeedf,0x3f6003ff, 0xf303ffff,0xfff7ffff,0x7ffc0dff,0x7f401fff,0x5006ffff,0x01ffffff, 0x81fffffe,0xdeeeeee9,0x3fffffa0,0x7ffc4003,0xfffd0fff,0xfffb11ff, 0x83dfffff,0xfffffffa,0x004fffff,0x7ffffec0,0xfe8001ff,0x361fffff, 0x00ffffff,0x3ffff200,0xfffffdff,0x7fdc006f,0xff705fff,0xfffb3fff, 0xfff101ff,0xff700fff,0xb003ffff,0x40bfffff,0x107fffff,0x3fffffff, 0x3fffffe8,0x7fffc400,0xffffd0ff,0xfffffd5f,0x43ffffff,0xfffffffa, 0x004fffff,0x3ffffee0,0xf30003ff,0x2adfffff,0x02ffffff,0x7fff4400, 0xffffffff,0x7fcc001f,0xffb07fff,0x3ffeefff,0xfffa82ff,0xff8805ff, 0x4404ffff,0x02ffffff,0x21fffffe,0xffffffe8,0xfffffe82,0x7ffc4003, 0xfffd0fff,0xffffffff,0xbfffffff,0x7fffffd4,0x04ffffff,0xfffff500, 0xc80009ff,0xeaffffff,0x005fffff,0xfffff500,0x09ffffff,0x3ffffe00, 0xfffff81f,0x9fffff35,0x7fffff90,0x3ffff600,0x7ffd406f,0x7ffc07ff, 0xfffe87ff,0xffd02fff,0x88007fff,0xd0ffffff,0xffffffff,0xffffb77b, 0xff903fff,0x00007fff,0xfffffff1,0x3fa0000d,0xffffffff,0x00000fff, 0x3ffffff6,0x0000efff,0x85fffffd,0x23fffff9,0xd86fffff,0x001fffff, 0x3ffffff5,0x7ffffec0,0x7ffffc04,0x7ffffec7,0x3fffa03f,0x7c4003ff, 0xfd0fffff,0x01ffffff,0x9ffffff3,0x7fffff90,0xffe88000,0x000fffff, 0xfffff300,0x07ffffff,0xfff88000,0x02ffffff,0x3ffff200,0x7fffdc4f, 0x3ffff20f,0x7ffffc0f,0x3ffe2007,0xff104fff,0xf803ffff,0x3f27ffff, 0x403fffff,0x03fffffe,0x7ffffc40,0xfffffd0f,0x7ffe403f,0xfffc85ff, 0x6c0003ff,0x1fffffff,0x7fec0000,0x6fffffff,0xff700000,0x00bfffff, 0xfffffa80,0x37ffff46,0x8bffffea,0x05fffff9,0x7ffffec0,0xfffff507, 0xfffff00d,0x3ffffeef,0xfffe804f,0x7c4003ff,0xfd0fffff,0xa809ffff, 0xc85fffff,0x003fffff,0x3fffff20,0x800002ff,0xfffffff8,0x000001ff, 0xfffffffd,0xff88000d,0x3fe27fff,0x7fc44fff,0x3fee4fff,0x54003fff, 0x81ffffff,0x03fffffd,0xaffffff8,0x04ffffff,0x7fffffd0,0xffff8800, 0xffffd0ff,0xfff9805f,0xfffc86ff,0xf50003ff,0x09ffffff,0x7fd40000, 0x004fffff,0xffff7000,0x007fffff,0xfffffe80,0x5fffff51,0x4dffffd0, 0x01fffffc,0xffffff80,0xffffff84,0xfffff800,0x6fffffff,0x3ffffa00, 0x7fc4003f,0xffd0ffff,0xf9803fff,0xfc86ffff,0x8003ffff,0xfffffff9, 0xd8000005,0x00ffffff,0xfff88000,0xffffffff,0x3ff20001,0xfff93fff, 0xfff901ff,0x3fffa1ff,0xfc8000ff,0x7d47ffff,0xf006ffff,0xffffffff, 0x2001ffff,0x03fffffd,0x7ffffc40,0xfffffd0f,0xffff9803,0xffffc86f, 0x7f44003f,0x00efffff,0xffc80000,0x00005fff,0xffffffd0,0x00dfffff, 0x7ffffd40,0x0dffffd5,0x2bffffea,0x06fffff8,0xfffff300,0x7fffec3f, 0xffff003f,0xffffffff,0x3ff600bf,0x4c003fff,0xd0ffffff,0x801fffff, 0x86fffff8,0x03fffffc,0x7ffffec0,0x000001ff,0xbfffff90,0xff700000, 0xffffffff,0x20007fff,0x8efffff8,0x104fffff,0xf39fffff,0x0009ffff, 0x27fffff4,0x01ffffff,0x3fffffe0,0xffffffff,0xffffd802,0x7fcc004f, 0xffd0ffff,0xf8801fff,0xfc86ffff,0x2003ffff,0xfffffffc,0x20000002, 0x05fffffc,0x7ffc4000,0xfffbffff,0x0001ffff,0xf7ffffff,0x7405ffff, 0xffbeffff,0x20002fff,0x57fffffc,0x00bfffff,0x7ffffffc,0x6fffffff, 0xfffffc80,0x7ffd4005,0x3fffa7ff,0x7fc400ff,0xffc86fff,0xf5003fff, 0x07ffffff,0xfc800000,0x0005ffff,0x7ffffec0,0xfffff75f,0x3f6000df, 0xffffffff,0x3ff200ff,0xffffefff,0x3e60000f,0xfcafffff,0x2002ffff, 0xffffffff,0x3fffffe8,0x7ffffdc0,0x3ff2000f,0x3ffa6fff,0x7c400fff, 0xfc86ffff,0x9803ffff,0x5fffffff,0xc8000000,0x005fffff,0x3fffea00, 0x3ffa0fff,0x8003ffff,0xfffffffb,0x7cc06fff,0xffffffff,0xfe80006f, 0xfffdffff,0x3e000fff,0x30ffffff,0x01ffffff,0x7fffffd4,0xffff1005, 0x7fff4bff,0x7fc400ff,0xffb86fff,0x74403fff,0x0effffff,0xc8000000, 0x005fffff,0xfffff100,0xfff987ff,0x4001ffff,0xfffffff9,0xff803fff, 0xffffffff,0xffb80004,0xffffffff,0x7ffc005f,0x7fec1fff,0x3e204fff, 0x02ffffff,0xffffffd8,0x3fffffa3,0x7fffc400,0xffffb86f,0x7ffec04f, 0x0000ffff,0xfff90000,0x20000bff,0x5ffffffd,0xffffff90,0xffff000d, 0x03ffffff,0xffffffb0,0x00005fff,0xfffffff1,0x8005ffff,0x887fffff, 0x01ffffff,0x3ffffff2,0xffda81cf,0x7f47ffff,0x4400ffff,0xb86fffff, 0xcdffffff,0x3fffee4e,0x9999bfff,0x99999999,0x00019999,0x0bfffff9, 0xffff5000,0x3a201fff,0x03ffffff,0x7ffffec0,0xf7007fff,0xffffffff, 0x3f600001,0xffffffff,0xffff8007,0xffff907f,0x7ffc40bf,0xffffffff, 0xffffffff,0x7fff43ff,0x7fc400ff,0xff986fff,0x5fffffff,0x3fffffee, 0xffffffff,0xffffffff,0xf90007ff,0x000bffff,0xffffff88,0x7ffd403f, 0x2001ffff,0xfffffffb,0xfff3005f,0x00dfffff,0x7fffd400,0x004fffff, 0x07fffff8,0x5ffffff1,0x7ffffe40,0xffffffff,0x87ffffff,0x00fffffe, 0x37ffffc4,0xffffffe8,0x3ffee6ff,0xffffffff,0xffffffff,0x007fffff, 0xbfffff90,0xfffd8000,0xfb006fff,0x00dfffff,0x7fffffcc,0x3fe003ff, 0x05ffffff,0x3ffe2000,0x01ffffff,0x7fffff80,0x3ffffee0,0x7fffdc06, 0xffffffff,0x81efffff,0x00fffffe,0x37ffffc4,0xffffffb8,0x3ffee7ff, 0xffffffff,0xffffffff,0x007fffff,0xbfffff90,0x7ffd4000,0x1001ffff, 0x7fffffff,0x3fffe200,0x2001ffff,0xfffffffd,0x7ec00003,0x06ffffff, 0xffffff00,0xfffffe80,0x7fff4c03,0xffffffff,0x3fa04fff,0x4400ffff, 0x206fffff,0xeffffffa,0x3ffffee5,0xffffffff,0xffffffff,0x90007fff, 0x00bfffff,0x3ffffe20,0x7d4004ff,0x01ffffff,0xffffffd0,0xfffb800f, 0x0001ffff,0x7ffffd40,0xff0003ff,0xfa80ffff,0x400fffff,0xfffffec8, 0x01dfffff,0x07fffff4,0x3ffffe20,0x09ba9806,0xffffffb8,0xffffffff, 0xffffffff,0xf90007ff,0x000bffff,0x3ffffff2,0xfffb0006,0x3200dfff, 0x05ffffff,0x7ffffcc0,0xf000007f,0x03ffffff,0x3ffffe00,0xffffe807, 0x2aa2004f,0x001aabba,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x80000000,0xaaaaaaaa,0x9aaaaaaa, 0xaaa80019,0x55550aaa,0x55555555,0x20013355,0xaaaaaaaa,0xaaaaaaaa, 0x531aaaaa,0x00035555,0x21555553,0xaaaaaaaa,0x5554001a,0x10aaaaaa, 0x00133333,0x2aaaa600,0xaa98001a,0x541aaaaa,0x2a0aaaaa,0x360aaaaa, 0x2a0eeeee,0xaaaaaaaa,0xaaaaaaaa,0x2aaaaaaa,0xfffffffb,0xffffffff, 0x0019dfff,0x21fffffd,0xfffffffe,0xffffffff,0x3f601cff,0xffffffff, 0xffffffff,0xfffb5fff,0xfb000dff,0x3fa1ffff,0x6fffffff,0x3fffe600, 0xf92fffff,0x000bffff,0x3fffff60,0x7ffd4004,0x7c0fffff,0x3e3fffff, 0x3a2fffff,0x3e0fffff,0xffffffff,0xffffffff,0x6fffffff,0xfffffffb, 0xffffffff,0x09ffffff,0x0fffffe8,0xfffffffd,0xffffffff,0x3609ffff, 0xffffffff,0xffffffff,0xffb5ffff,0x8009ffff,0xd0fffffd,0xffffffff, 0x3ff2001f,0x2fffffff,0x0bfffff9,0x3fff6000,0x3ea004ff,0x0fffffff, 0x3ffffff8,0x8bfffffe,0x20fffffe,0xffffffff,0xffffffff,0xffffffff, 0xffffffb6,0xffffffff,0xffffffff,0x7ffff409,0xfffffd0f,0xffffffff, 0xbfffffff,0xffffffb0,0xffffffff,0x2bffffff,0xfffffffd,0x3fff6001, 0xffffd0ff,0x005fffff,0x3ffffffa,0xfff92fff,0x20000bff,0x04fffffd, 0xffffff30,0x3ffe03ff,0x3ffe3fff,0x3ffa2fff,0x3ffe0fff,0xffffffff, 0xffffffff,0xfb6fffff,0xffffffff,0xffffffff,0x07ffffff,0x43fffffa, 0xfffffffe,0xffffffff,0x44ffffff,0xfffffffd,0xffffffff,0xfb5fffff, 0x0bffffff,0x7ffffec0,0xffffffd0,0xf1009fff,0xffffffff,0x3ffff25f, 0xfb00005f,0x3009ffff,0xffffffff,0x7ffffc03,0x3ffffe3f,0x3ffffa2f, 0x3ffffe0f,0xffffffff,0xffffffff,0xfffb6fff,0xffffffff,0xffffffff, 0x3a0fffff,0xfd0fffff,0xffffffff,0xffffffff,0x6c1fffff,0xffffffff, 0xffffffff,0xffb5ffff,0x05ffffff,0x3fffff60,0xffffffd0,0xf500dfff, 0xffffffff,0x3ffff25f,0xfb00005f,0x8809ffff,0xffffffff,0x7ffffc01, 0x3ffffe3f,0x3ffffa2f,0x3ffffe0f,0xffffffff,0xffffffff,0xfffb6fff, 0x366009ff,0x2fffffff,0x0fffffe8,0x07fffffd,0xfffffea8,0x3fff64ff, 0xd80004ff,0xffffffff,0xfffd800f,0xffffd0ff,0x01ffffff,0xffffffc8, 0xff92ffff,0x0000bfff,0x13fffff6,0xfffffe88,0xfff801ff,0x3ffe3fff, 0x26622fff,0xfd800199,0x2004ffff,0x04fffffd,0x7ffffdc0,0xffffe84f, 0xfffffd0f,0x3ffee007,0x3ff66fff,0x80004fff,0xfffffffd,0xffd804ff, 0xfffd0fff,0x5fffffff,0xfffffe80,0xf92fffff,0x000bffff,0x3fffff60, 0xffffd104,0x3e005fff,0x3e3fffff,0x002fffff,0xffffd800,0x3ff6004f, 0x44004fff,0x85ffffff,0xd0fffffe,0x007fffff,0x3ffffffc,0x09fffffb, 0xffffb000,0x03ffffff,0x0fffffd8,0xfbfffffd,0x7c409fff,0xfffdffff, 0xffff92ff,0x360000bf,0xb04fffff,0x5fffffff,0x7ffffc00,0x3ffffe2f, 0xd800002f,0x004fffff,0x13fffff6,0x3ffff600,0xffffe86f,0xfffffd0f, 0x7ffe4007,0xfffb0fff,0xb00009ff,0xffffffff,0xffd80dff,0xfffd0fff, 0xfffff7ff,0x7ffffd40,0x92fffffb,0x00bfffff,0x3ffff600,0xffffd84f, 0x74002fff,0x3e1fffff,0x002fffff,0xffffd800,0x3ff6004f,0xe8004fff, 0xe85fffff,0xfd0fffff,0x4007ffff,0x0ffffffa,0x09fffffb,0xffffb000, 0x7fffffff,0x7ffffec0,0x3fffffd0,0x203fffff,0xfbdffffc,0xff92ffff, 0x0000bfff,0x13fffff6,0xfffffff9,0xfffd0005,0x7fffc3ff,0x800002ff, 0x04fffffd,0x3fffff60,0x7ffc4004,0xffe84fff,0xfffd0fff,0x7e4007ff, 0x3f67ffff,0x0004ffff,0xffffffd8,0x00ffffff,0x21fffffb,0xff7ffffe, 0x3fa07fff,0xfffbbfff,0xffff92ff,0x360000bf,0x324fffff,0x3fffffff, 0xffffb000,0x7ffffc1f,0xd800002f,0x004fffff,0x13fffff6,0xfffffb00, 0xffffd05f,0x3ffffa1f,0x3ffe003f,0x3ff65fff,0x80004fff,0xfafffffd, 0xb05fffff,0x3a1fffff,0xffb7ffff,0xfff10bff,0xffff73ff,0x3ffff25f, 0xfb00005f,0x3ee9ffff,0x03ffffff,0x3ffff200,0x7fffffc7,0xfd800002, 0x2004ffff,0x9cfffffd,0x99999999,0xffffffea,0xfffffd06,0x3fffffa1, 0xfffe8803,0x3ff63fff,0xccccefff,0xcccccccc,0x7ffffec2,0xffffffc8, 0xfffffd81,0x2fffffd0,0xa87ffffb,0xff77ffff,0x3ff25fff,0x00005fff, 0x59fffffb,0xffffffff,0x7fdc0009,0x7fffc7ff,0x800002ff,0x04fffffd, 0x3fffff60,0xffffffff,0xffffffff,0xfffd01ff,0x3fffa1ff,0x99999cff, 0xfffffca9,0x3ff62fff,0xffffffff,0xffffffff,0x7ffffec4,0xffffff88, 0xfffffd86,0x2fffffd0,0x41fffff9,0xf75ffffc,0x3f25ffff,0x0005ffff, 0xdfffffb0,0xffffffff,0x2a0003ff,0x7fc6ffff,0x0002ffff,0xfffffd80, 0x3fff6004,0xffffffff,0xffffffff,0x3fa03fff,0xffd0ffff,0xffffffff, 0xffffffff,0xffd8dfff,0xffffffff,0xffffffff,0x7ffffec4,0xffffff50, 0xfffffd87,0x4fffffd0,0x7c3fffff,0xff73ffff,0x3ff25fff,0x00005fff, 0xfffffffb,0xffffffff,0x3ea000df,0x7ffc5fff,0x00002fff,0x4fffffd8, 0x3ffff600,0xffffffff,0xffffffff,0x7fff401e,0xffffd0ff,0xffffffff, 0xffffffff,0xffffd81d,0xffffffff,0x44ffffff,0x20fffffd,0x0ffffffd, 0x43fffff6,0x367ffffe,0x3e65ffff,0xff71ffff,0x3ff25fff,0x00005fff, 0xfffffffb,0xffffffff,0xf30007ff,0xfff89fff,0x00002fff,0x4fffffd8, 0x3ffff600,0xffffffff,0x2cefffff,0xfffffd00,0x3fffffa1,0xffffffff, 0x1fffffff,0xffffffd8,0xffffffff,0x7ec4ffff,0x3e60ffff,0x365fffff, 0xfd0fffff,0x7fdcffff,0x3ffee7ff,0x3fffee7f,0xfffff92f,0x3f60000b, 0xffffffff,0xffffffcf,0x7fc4000f,0x7fffc4ff,0x3fffa2ff,0x7ec000ff, 0x2004ffff,0xeefffffd,0xffffffff,0x7f4001ef,0xffd0ffff,0xffffffff, 0xffffffff,0x3fff603b,0xccccceff,0x2ccccccc,0x07ffffec,0x3ffffff2, 0x1fffffb2,0x99fffffa,0xfb1fffff,0x7fdcbfff,0xfff92fff,0x20000bff, 0xfffffffd,0xffff73ff,0xff000bff,0xffff87ff,0x3fffa2ff,0x7ec000ff, 0x2004ffff,0x24fffffd,0xfffffc98,0x3fa002ff,0xffd0ffff,0xffffffff, 0x19dfffff,0xfffffd80,0xffd80004,0xffe80fff,0xfffb6fff,0x3fffa1ff, 0x7ffffc7f,0x47fffff4,0x92fffffb,0x00bfffff,0x3ffff600,0x7f44ffff, 0x003fffff,0x3e17fffc,0x3a2fffff,0x000fffff,0x27ffffec,0xfffffb00, 0x3fffe609,0xfd004fff,0x3fa1ffff,0x999cffff,0xfb000099,0x0009ffff, 0x1fffffb0,0xffffff50,0x1fffffb9,0xb1fffffa,0xff3dffff,0x7fdc3fff, 0xfff92fff,0x20000bff,0xfffffffd,0xfffffa84,0x3fa000ff,0x7fffc1ff, 0x3fffa2ff,0x7ec000ff,0x2004ffff,0x04fffffd,0x3fffffea,0xfffe804f, 0xffffd0ff,0xd800007f,0x004fffff,0xfffffd80,0xfffffb00,0x1fffffdf, 0x71fffffa,0xff9fffff,0xfffb8fff,0xffff92ff,0x360000bf,0x04ffffff, 0x3ffffff6,0x3fff6005,0x7fffffc1,0x3fffffa2,0x7ffec000,0x3f6004ff, 0x6404ffff,0x2fffffff,0x7fffff40,0x7fffffd0,0xffd80000,0x80004fff, 0x00fffffd,0xfffffff1,0x3a1fffff,0x7cc7ffff,0xffffffff,0x7fffdc5f, 0xfffff92f,0x3f60000b,0x4c05ffff,0x2fffffff,0x81fff900,0x22ffffff, 0x007ffffe,0x4fffffd8,0x3ffff600,0xfffe804f,0x3a00ffff,0xfd0fffff, 0x0007ffff,0xfffffd80,0xffd80004,0x3ee00fff,0xffffffff,0xffffd0ff, 0xffffff0f,0xfb87ffff,0xff92ffff,0x0000bfff,0x13fffff6,0x3fffff20, 0xffb800ff,0xffffff87,0x006ff882,0x4fffffd8,0x3ffff600,0xfff9804f, 0x3a05ffff,0xfd0fffff,0x0007ffff,0xfffffd80,0xffd80004,0x7f400fff, 0xffffffff,0xfffffd0f,0xffffffb0,0xffb83fff,0xfff92fff,0x20000bff, 0x04fffffd,0xffffff88,0xff80005f,0xfa82ffff,0xffd8006f,0x36004fff, 0x004fffff,0xfffffff7,0x3ffffa05,0xfffffd0f,0xfd800007,0x0004ffff, 0x0fffffd8,0x7ffffcc0,0xfd0fffff,0xff70ffff,0x0fffffff,0x25fffff7, 0x05fffffc,0xffffb000,0x3fee009f,0x002fffff,0x7fffffc0,0x004ffc82, 0x4fffffd8,0x3ffff600,0x3ffa004f,0xe80fffff,0xfd0fffff,0x0007ffff, 0xfffffd80,0xffd80004,0xfc800fff,0xffffffff,0x0fffffd0,0xfffffff3, 0xffff70bf,0x3ffff25f,0x999999df,0x99999999,0xfffffb09,0x7fff4009, 0xfb00ffff,0x7fc3ffff,0x3622ffff,0xd8000fff,0x004fffff,0x13fffff6, 0xfffff880,0xfffe84ff,0xffffd0ff,0xd800007f,0x004fffff,0xfffffd80, 0xffff8800,0xfd0fffff,0x3fe0ffff,0x83ffffff,0x92fffffb,0xffffffff, 0xffffffff,0x367fffff,0x004fffff,0x3fffffe6,0xffffb04f,0x7ffffc3f, 0x5ffff12f,0x3fff6000,0x3f6004ff,0x4004ffff,0xfffffffb,0x7fffff41, 0x7fffffd0,0xffd80000,0x80004fff,0x00fffffd,0xffffff50,0x3fffa1ff, 0xffffb07f,0xff703fff,0x3ff25fff,0xffffffff,0xffffffff,0xfffb3fff, 0xfd8009ff,0x81ffffff,0x21fffffd,0x22ffffff,0x20002ffe,0x04fffffd, 0x3fffff60,0xfffe8004,0x7ff46fff,0xfffd0fff,0x800007ff,0x04fffffd, 0xffffd800,0x3ff6000f,0xfd0fffff,0x3ee0ffff,0x707fffff,0x325fffff, 0xffffffff,0xffffffff,0xfb3fffff,0x8009ffff,0xfffffff8,0xfffffd86, 0x3fffffe1,0x000032a2,0x09fffffb,0x7ffffec0,0xfff88004,0x3fa3ffff, 0xffd0ffff,0x00007fff,0x4fffffd8,0xfffd8000,0x3e6000ff,0xd0ffffff, 0x260fffff,0x05ffffff,0x25fffff7,0xfffffffc,0xffffffff,0xb3ffffff, 0x009fffff,0xffffff90,0xffffd89f,0x3ffffe1f,0xd800002f,0x004fffff, 0x13fffff6,0x7fffdc00,0xfffd0fff,0x3fffa1ff,0x400003ff,0x04fffffd, 0xffffd800,0x7fe4000f,0xffd0ffff,0x7ffc0fff,0xff703fff,0x3ff25fff, 0xffffffff,0xffffffff,0xfffb3fff,0x3a0009ff,0x1fffffff,0x87fffff6, 0x02ffffff,0xfffd8000,0x000004ff,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x44000000,0x09accca9, 0xba988000,0x5555001a,0x55555555,0x55555555,0x55541555,0xaaaaaaaa, 0x00019aaa,0x3332a000,0x5555501c,0x55555555,0x00033555,0x55555400, 0x2a00002a,0xffffffff,0x4fffffff,0xccccb800,0x35555550,0x55555000, 0x7fec4015,0xefffffff,0x7fe44001,0x1effffff,0x3fffffa0,0xffffffff, 0xffffffff,0x3ffffa3f,0xffffffff,0x003effff,0x3ffe6000,0xfffb03ff, 0xffffffff,0x9fffffff,0x7c400003,0x01ffffff,0xffff7000,0xffffffff, 0x88009fff,0xfb1fffff,0x0009ffff,0x03ffffff,0xffffff91,0xbfffffff, 0xffff7001,0xffffffff,0xffffd019,0xffffffff,0xffffffff,0x7fff47ff, 0xffffffff,0xffffffff,0xfe800003,0xfb03ffff,0xffffffff,0xffffffff, 0x0000bfff,0x3fffffee,0xfb00005f,0xffffffff,0x09ffffff,0xfffffd80, 0x9fffffb1,0xfffff000,0xffffd03f,0xffffffff,0x5c01ffff,0xffffffff, 0x86ffffff,0xfffffffe,0xffffffff,0x3fffffff,0x3ffffffa,0xffffffff, 0x05ffffff,0x3fff2000,0xffb03fff,0xffffffff,0xffffffff,0x0000bfff, 0xfffffffd,0xfd00001f,0xffffffff,0x09ffffff,0x7ffffd40,0xfffffb1f, 0xffff0009,0xfffc83ff,0xffefffff,0x06ffffff,0xfffffff3,0xffffffff, 0xffffe89f,0xffffffff,0xffffffff,0x3fffa3ff,0xffffffff,0xffffffff, 0x980005ff,0x3fffffff,0xffffffb0,0xffffffff,0xffffffff,0x7fcc000b, 0x3fffffff,0x7ffc4000,0xffffffff,0x004fffff,0xfffffff5,0x3fffff63, 0xffff8004,0x3ffee1ff,0x5c42efff,0x45ffffff,0xfffffff8,0xfffffcdf, 0x3ffa1fff,0xffffffff,0xffffffff,0x3fa3ffff,0xffffffff,0xffffffff, 0x001fffff,0x3ffffa20,0xffb03fff,0xdddddfff,0xffffdddd,0x001fffff, 0x3fffff20,0x0006ffff,0x6fffffcc,0xcccccccc,0xffb802cc,0xb1ffffff, 0x009fffff,0x3ffffff0,0x27fffffc,0x3ffffe60,0x3fffea0f,0x7fd40bff, 0x3fa4ffff,0x0003ffff,0x7fffff40,0x3ff66203,0x006fffff,0x3fffff20, 0xffb03fff,0x2a009fff,0x2ffffffe,0xffff8800,0x1fffffff,0x3ffee000, 0x100000ff,0xfffffffb,0x3fff63ff,0xff8004ff,0xff31ffff,0x2e00dfff, 0x322fffff,0x204fffff,0x26fffffa,0x03fffffe,0x7fff4000,0xfb3003ff, 0x007fffff,0xffffff50,0x3f607fff,0x4004ffff,0x05fffffe,0xfffffa80, 0x05ffffff,0x3ffff200,0xfb880007,0xffffffff,0xffffb1ff,0xfff0009f, 0x3fee3fff,0xf3002fff,0x7f49ffff,0x7c00ffff,0x3fa7ffff,0x0003ffff, 0x7fffff40,0x3ffe2003,0x2000ffff,0xfffffff8,0xffb03fff,0xb8009fff, 0x006fffff,0xcfffffe8,0x00ffffff,0xdffffd00,0xfffa8000,0xffffffff, 0xffffb1ff,0xfff0009f,0x372a3fff,0x3e6007fe,0xfd15ffff,0xfd00ffff, 0x3fa1ffff,0x0003ffff,0x7fffff40,0x7ffdc003,0x36003fff,0xffffffff, 0xfffb03ff,0xf98009ff,0x4004ffff,0xd7fffff9,0x007fffff,0x13ffffe0, 0xffff7000,0xffffddff,0x3ffff63f,0xfff8004f,0x00201fff,0x3fffffb8, 0xf8805310,0x3fa7ffff,0x0003ffff,0x7fffff40,0xfffe8003,0xff5005ff, 0xffff7fff,0x3fff607f,0x7e4004ff,0x4002ffff,0x74fffffc,0x00dfffff, 0x7fffff10,0x159dfb73,0xfffffb80,0x3fffffb4,0x13fffff6,0x3ffffe00, 0xe880001f,0x000fffff,0x7ffffdc0,0x3fffffa5,0x7f400003,0x8003ffff, 0x07fffffc,0xafffff88,0x03fffffa,0x09fffffb,0xffffff80,0x7fffc000, 0xffff11ff,0xfa8003ff,0xffffffff,0x202fffff,0x362ffffb,0xfb1fffff, 0x0009ffff,0x03ffffff,0xfffe8800,0xe80006ff,0x3a4fffff,0x99cfffff, 0x99999999,0xfe819999,0x8003ffff,0x1ffffffa,0xaffffec0,0x03fffffa, 0x09fffffb,0xfffff710,0xffa800bf,0x7fec6fff,0x5c005fff,0xffffffff, 0x4fffffff,0xd817ff70,0xfb1fffff,0x0009ffff,0x03ffffff,0x7fff4c00, 0x40001fff,0x1ffffff9,0x3ffffffa,0xffffffff,0x1fffffff,0x1ffffff4, 0x7fffcc00,0x3fea01ff,0xfff50fff,0x3ff607ff,0xffffffff,0xffffffff, 0xd8004fff,0x543fffff,0x00ffffff,0x3fffff60,0xffffffff,0x02a84fff, 0x47fffff6,0xfffffffd,0xffffffff,0xffffffff,0xff50001f,0x007fffff, 0xfffff880,0x7ffff44f,0xffffffff,0xffffffff,0x7ffff41f,0xff88003f, 0xf102ffff,0x7d45ffff,0xfb03ffff,0xffffffff,0xffffffff,0x10007fff, 0x81ffffff,0x3ffffff8,0x3ffffe00,0xfffeffff,0x001fffff,0x8fffffec, 0xfffffffd,0xffffffff,0xffffffff,0xffa8001f,0x003fffff,0x7ffff440, 0x7fff40ff,0xffffffff,0xffffffff,0x7fff41ff,0xf88003ff,0xb02fffff, 0xfa8bffff,0xfb03ffff,0xffffffff,0xffffffff,0x70003dff,0x20bfffff, 0x06fffffd,0xffffff10,0xffffb819,0x7ec006ff,0xffb1ffff,0xffffffff, 0xffffffff,0x03ffffff,0xfffffa80,0x440002ff,0x3ffffffe,0xffffffe8, 0xffffffff,0x1fffffff,0x1ffffff4,0x7fffc400,0xfffb83ff,0x7ffd40ff, 0xfffb03ff,0xffffffff,0xffffffff,0x74003dff,0x502fffff,0x03ffffff, 0x5ffd9710,0x7ffffcc0,0x3ff6002f,0xfffb1fff,0xffffffff,0xffffffff, 0x003fffff,0x7fffffc4,0x7440002f,0x05ffffff,0xfffffffd,0xffffffff, 0x83ffffff,0x03fffffe,0xfffff880,0x7fffc42f,0xffffa82f,0xffffb03f, 0xffffffff,0xffffffff,0xf3003fff,0x401fffff,0x05ffffff,0x3ff60000, 0x36004fff,0xfb1fffff,0xffffffff,0xffffffff,0x3fffffff,0x7fffe400, 0x4c0001ff,0xefffffff,0xfffffd00,0x33333339,0x33333333,0x7fffffd0, 0xffff1000,0xfffd85ff,0xffff505f,0x3fff607f,0xaaaaadff,0xffecbaaa, 0x400fffff,0x05fffffc,0x7fffffe4,0xf5000000,0x400bffff,0xb1fffffd, 0x339fffff,0x33333333,0xffffff33,0x7ffec003,0x4c0001ff,0xefffffff, 0x3ffffa00,0x7400003f,0x003fffff,0xffffff98,0x3ffffee1,0xfffff500, 0x3ffff607,0x7fe4004f,0x2204ffff,0xacffffff,0xfcaaaaaa,0x003fffff, 0xffff3000,0x7fec00df,0xfffb1fff,0xff0009ff,0x4003ffff,0x003fffff, 0x7ffffc40,0x7f400eff,0x0003ffff,0x7fffff40,0xfffa8003,0xfff10fff, 0x99999dff,0xbfffffb9,0x3ff63999,0xc8004fff,0x00ffffff,0xfffffff7, 0xffffffff,0x0dffffff,0x3fe20000,0x36007fff,0xfb1fffff,0x0009ffff, 0x03ffffff,0x3ffffe60,0x3fe20001,0x005fffff,0x07fffffd,0xfffe8000, 0xfc8003ff,0x3e27ffff,0xffffffff,0xffffffff,0xfb2fffff,0x0009ffff, 0x3ffffff5,0x3fffffa0,0xffffffff,0xffffffff,0x9800001f,0x006fffff, 0x47fffff6,0x04fffffd,0xffffff80,0xffff5001,0x3e20001f,0x05ffffff, 0x3fffffa0,0x7f400003,0x8003ffff,0x25fffffe,0xfffffff8,0xffffffff, 0x2fffffff,0x09fffffb,0xfffff100,0xffff307f,0xffffffff,0xffffffff, 0x4c40bfff,0x5400ccaa,0x005fffff,0x47fffff6,0x04fffffd,0xffffff80, 0xffff5001,0x3fa0001f,0x005fffff,0x1ffffff4,0x3ffa0000,0x5c003fff, 0x22ffffff,0xfffffff8,0xffffffff,0x2fffffff,0x09fffffb,0xfffff500, 0xffff905f,0xffffffff,0xffffffff,0x3a01ffff,0x403fffff,0x04fffffc, 0x3fffff60,0x9fffffb1,0xfffff000,0x0000003f,0xffffffb0,0xfffd000b, 0x800007ff,0x03fffffe,0x3ffffe20,0x7fffc47f,0xffffffff,0xffffffff, 0xffffb2ff,0xff90009f,0xff01ffff,0xddddffff,0xdddddddd,0x7ffffffd, 0x3fffff20,0x3fffe207,0x3f6001ff,0xffb1ffff,0xf0009fff,0x003fffff, 0xffb80000,0x0006ffff,0x07fffffd,0xfffe8000,0xfd5003ff,0x887fffff, 0xcccccccc,0xfffdcccc,0xb1cccdff,0x009fffff,0xffffffa8,0xfffffa86, 0xffe8000f,0xff306fff,0x8819ffff,0x05fffffd,0x7ffffec0,0x9fffffb1, 0xfffff000,0x3fea003f,0x22004fff,0xdfffffff,0xcccccccc,0xfffd0ccc, 0x333339ff,0x33333333,0x7ff43333,0x9999cfff,0xfffebaa9,0x000effff, 0xfffffa80,0xfffffb03,0x53333339,0xffffd755,0xffb09fff,0x2000bfff, 0x1ffffffb,0xffffffd0,0xfffd759f,0xd8003fff,0xfb1fffff,0x0009ffff, 0x03ffffff,0x3ffffea0,0x3ffee004,0xffffffff,0xffffffff,0xffffffd0, 0xffffffff,0xffffffff,0x7fffff4f,0xffffffff,0xffffffff,0xf500001f, 0x3607ffff,0xffffffff,0xffffffff,0xffffffff,0x7ffffc41,0xff10002f, 0x220bffff,0xffffffff,0xffffffff,0xfffd8004,0xffffb1ff,0xfff0009f, 0x2a003fff,0x004fffff,0xfffffff1,0xffffffff,0x3a1fffff,0xffffffff, 0xffffffff,0x27ffffff,0xfffffffe,0xffffffff,0x02ffffff,0x3ffea000, 0xfffb03ff,0xffffffff,0xffffffff,0xf705ffff,0x000fffff,0xffffffd8, 0xfffff500,0xffffffff,0x3f60007f,0xffb1ffff,0xf0009fff,0x003fffff, 0x13ffffea,0x7ffffd40,0xffffffff,0x0fffffff,0xfffffffd,0xffffffff, 0xffffffff,0x7ffffff4,0xffffffff,0x01dfffff,0x7ffd4000,0xfffb03ff, 0xffffffff,0xffffffff,0x3fa07fff,0x0004ffff,0x7fffffd4,0x3fffaa03, 0xffffffff,0x3ff60002,0xfffb1fff,0xff0009ff,0x2003ffff,0x04fffffa, 0xffffff90,0xffffffff,0x21ffffff,0xfffffffe,0xffffffff,0x7fffffff, 0x3ffffffa,0xffffffff,0x0002efff,0xfffff500,0x3ffff607,0xffffffff, 0xffffffff,0xffff302d,0xf00003ff,0x00dfffff,0xfffffff7,0xd800039d, 0xfb1fffff,0x0009ffff,0x03ffffff,0x3ffffea0,0xffffb004,0xffffffff, 0xffffffff,0x3fffffa1,0xffffffff,0xffffffff,0x3ffffa7f,0xffffffff, 0x0002cdef,0x7fffd400,0xffffb03f,0xffffffff,0x17bddfff,0xfffffd80, 0xff900006,0x2003ffff,0x0009ba98,0x3ffff600,0xfffffb1f,0xffff0009, 0x000003ff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x7ffc4000,0xffffffff,0xffffffff, 0x2000003f,0x0004c000,0x00000002,0x00004c40,0x00999880,0x00662000, 0x00198000,0x000c4000,0x4000c400,0xeeec8009,0xffff11ee,0xffffffff, 0xffffffff,0xb8800007,0x7f64c04f,0x401cdfff,0x000002df,0x7fffe4c0, 0x0001bdef,0xfffffd91,0xa8007bff,0xfffffffd,0xb70000be,0x5bfffffd, 0x4eeeed80,0x77fff654,0xeeee980c,0x3ffb261e,0xdb880bdf,0xb02cefff, 0x225fffff,0xffffffff,0xffffffff,0x0003ffff,0x09fff930,0x7fffffe4, 0x3e04ffff,0x0000beff,0x3fff6200,0xffffffff,0x7ffec003,0xffffffff, 0x7f5400ef,0xffffffff,0x26004fff,0xfffffffe,0xfd02efff,0x3f62bfff, 0xffffffff,0x7ffffcc1,0xffffff71,0x7f441dff,0x4fffffff,0x2fffffd8, 0xfffffff1,0xffffffff,0x007fffff,0xffffea80,0xfffe884f,0xffffffff, 0xffff80ef,0x00000cff,0x7fffffd4,0xffffffff,0xfffd801e,0xffffffff, 0xf500efff,0xffffffff,0x09ffffff,0xffffff90,0xffffffff,0xbffffd05, 0xffffffd1,0x4c5fffff,0xfd9fffff,0xffffffff,0xffff98ef,0x3fffffff, 0x97ffffec,0xfffffff8,0xffffffff,0x001fffff,0xfffffb88,0xffe84fff, 0xffffffff,0x7c0fffff,0xdfffffff,0xffa80001,0xffffffff,0x1fffffff, 0x3fffff20,0xffffffff,0xff886fff,0xffffffff,0x3fffffff,0x3fffff20, 0xffffffff,0x7ff41fff,0xfffffeff,0xffffffff,0x3ffffe66,0xffffffff, 0xffefffff,0xffffffff,0x3ff61fff,0x99912fff,0x99999999,0xfffffd99, 0xffc98007,0xffffffff,0x7ffffdc4,0xfffcabdf,0x7ffc3fff,0xefffffff, 0xfff10002,0xdbdfffff,0xdfffffff,0x3ffffe20,0xffcaacef,0x641fffff, 0x99cfffff,0xffffeb98,0xffff106f,0xffb9bfff,0xe8dfffff,0xffffffff, 0xffffdbbe,0xfff32fff,0x59dfffff,0xfffffff9,0xfb77dfff,0x6cbfffff, 0x002fffff,0x3ffffe20,0x3ff6a005,0xffffffff,0x3ffe22ff,0xfe882fff, 0x3f60ffff,0xffffffff,0x2000cfff,0xdffffffd,0x7fffec40,0xfffb83ff, 0x3ffe05ff,0x7ff42fff,0x3fe205ff,0xfd81ffff,0xa81effff,0x22ffffff, 0xfffffffe,0xfffffa80,0xfffff33f,0xfff507ff,0x903fffff,0x44ffffff, 0x00099999,0x1bffff60,0x3fffae20,0xffffffff,0x7ffec0be,0x3fe603ff, 0x7e4c3fff,0xffffffff,0x4401dfff,0x04ffffff,0x7fffffe4,0x7ff65cc0, 0x3ffff200,0x7ffffc3f,0x055ed405,0xffffffa8,0x3ffff600,0x3ffffa5f, 0x3ff601ff,0xfff34fff,0x7f40bfff,0x304fffff,0x00ffffff,0x7ffd4000, 0x3f2201ff,0xffffffff,0x3e01cfff,0xd807ffff,0x2a07ffff,0xfffffffd, 0x702effff,0x00dfffff,0x0ffffffe,0xfff50020,0xffff87ff,0x0000adff, 0x13fffff2,0x1359df30,0x27fffff4,0x3ffffea0,0xffffff35,0x7fffec01, 0x7fffc07f,0x800000ff,0x04fffff8,0xffffffb5,0x05bfffff,0xdfffff10, 0xfffff700,0xffeb8801,0xffffffff,0x3fffa0bf,0xff7002ff,0x4000bfff, 0xfffffeb8,0x7ffffec4,0x001befff,0x0fffffec,0x7fff4000,0x7fcc02ff, 0xfff35fff,0xffc80fff,0x7fc05fff,0x0000ffff,0x6ffffd80,0x3fffffe0, 0x00beffff,0x3ffffe60,0xaaaaaaae,0x1fffffca,0x3fff6a00,0x4fffffff, 0x07fffffe,0x7ffffcc0,0x3f6e6006,0xffffffff,0x7ffffdc4,0xdfffffff, 0x7fff400a,0xe80001ff,0x401fffff,0x36fffff9,0x80dfffff,0x04fffffc, 0x07fffff4,0x3fea0000,0x3fe02fff,0x1cffffff,0xffff5000,0xffffffff, 0xffffffff,0xfd710005,0x29ffffff,0x0ffffff8,0xfffff100,0x7ff5c40f, 0xffffffff,0xffc84fff,0xffffffff,0xf00cffff,0x001fffff,0xfffffd00, 0xffff9803,0xfffff36f,0xffffc80b,0x7fff403f,0x400000ff,0x406ffffe, 0x1fffffff,0x7ffe4000,0xffffffff,0xffffffff,0x7e40002f,0xf34fffff, 0x800fffff,0x80ffffff,0xfffffffb,0xffffffff,0xffffb04f,0xffffffff, 0xff885fff,0x00007fff,0x01fffffd,0x6fffff88,0x0bfffff3,0x3fffffc8, 0x7fffff40,0x3e600000,0x7c03ffff,0xefffffff,0xfff70002,0xffffffff, 0xffffffff,0xd710007f,0x9fffffff,0x1fffffe2,0xfffff880,0xfffffb87, 0xfaacefff,0x2604ffff,0xfffffffc,0x1fffffff,0x07fffffc,0x7fff4000, 0x7fc400ff,0xfff36fff,0xffc80bff,0x7f403fff,0x0000ffff,0x3fffff60, 0x7ffffc00,0x1cffffff,0x3fffea00,0xaaaaaadf,0xaaaaaaaa,0x3ff6a001, 0xffffffff,0x3fffffe4,0xffff3000,0xffffb8df,0x7cc0adff,0x8804ffff, 0xffffffda,0x746fffff,0x001fffff,0xfffffe80,0x7fffc400,0xfffff36f, 0xffffc80b,0x7fff403f,0x300000ff,0x00bfffff,0xffffffb3,0x17dfffff, 0xfffff980,0x22000005,0xfffffffb,0x20bfffff,0x02ffffff,0xbfffff50, 0x3fffffe8,0x3ffffea0,0xfdb88004,0x47ffffff,0x02fffffd,0xfe81abb8, 0x4400ffff,0xf36fffff,0xc80bffff,0x403fffff,0x00fffffe,0xffff9000, 0x7e44003f,0xffffffff,0xf101cfff,0x100dffff,0xfffda800,0xffffffff, 0xffff902e,0x3ffa00df,0x3fe23fff,0x7d406fff,0x2604ffff,0x3fee200a, 0x3f20ffff,0xf805ffff,0xfd0effff,0x8801ffff,0xf36fffff,0xc80bffff, 0x403fffff,0x00fffffe,0xffff8800,0x3ae0006f,0xffffffff,0x740befff, 0x202fffff,0x42bdeff8,0xffffffc8,0x1dffffff,0x7ffffcc0,0x7ffd402f, 0x3fea1fff,0x7ec05fff,0x36e4ffff,0xe804fffe,0x2a0fffff,0x00ffffff, 0x9bffffea,0x00fffffe,0xb7ffffc4,0x05fffff9,0x1fffffe4,0x3fffffa0, 0x5fffffb0,0xfffff700,0xfb500007,0xffffffff,0x7fd45fff,0xfb00ffff, 0x7ecdffff,0xffffffff,0x2000cfff,0x3fffffff,0xffffff70,0xfffff989, 0xffff700f,0x7ffdc9ff,0x3e200fff,0xfe86ffff,0x981effff,0x23ffffff, 0x00fffffe,0xb7ffffc4,0x05fffff9,0x1fffffe4,0x3fffffa0,0x5fffffb0, 0xfffffb00,0x64c00001,0xffffffff,0x7fff44ff,0xf950bfff,0x7c5fffff, 0xffffffff,0xa8000bef,0xefffffff,0xffffecac,0xfff886ff,0x3261dfff, 0x4fffffff,0x3fffffe2,0x7ff4c1be,0xffa84fff,0xbbdfffff,0xfffffffe, 0x3fffffa0,0x7fffc400,0xfffff36f,0xffffc80b,0x7fff403f,0xffffb0ff, 0xffff005f,0x200000bf,0xffffffb8,0x7ffd44ff,0xffffffff,0x7c6fffff, 0xdfffffff,0xffc80002,0xffffffff,0x1fffffff,0xffffffd0,0xffffffdf, 0xfb8bffff,0xffffffff,0xfffffffe,0xffffb00f,0xffffffff,0xfe85ffff, 0x4400ffff,0xf36fffff,0xc80bffff,0x403fffff,0xb0fffffe,0x805fffff, 0x01fffffa,0xfea80000,0xfa84ffff,0xffffffff,0x40efffff,0x1cffffff, 0x7fec0000,0xffffffff,0x202fffff,0xfffffff9,0xfeefffff,0xffc87fff, 0xffffffff,0x01ffffff,0x3fffffa2,0xffffffff,0xffffe83f,0x7ffc400f, 0xffff36ff,0xfffc80bf,0x7ff403ff,0xfffb0fff,0xffc805ff,0x000007ff, 0x27ffe4c0,0xfffffe88,0x0effffff,0x00bffff8,0x3fea0000,0xffffffff, 0xfb800dff,0xffffffff,0xfffff74f,0xfffff705,0xffffffff,0x3fee005d, 0xffffffff,0xfffd03ff,0xff8801ff,0xfff36fff,0xffc80bff,0x7f403fff, 0xffb0ffff,0xfe805fff,0x00006fff,0x09f71000,0x7fffee44,0x3e02dfff, 0x0000002e,0x3ffffae2,0x4002dfff,0xffffffd8,0x3fffe62e,0xffd7105f, 0x5dffffff,0xfffb3000,0x019fffff,0x07fffff4,0x3ffffe20,0xbfffff36, 0xfffffc80,0x7ffff403,0x3e20000f,0x0004ffff,0x00080000,0x0026aea2, 0x00000006,0x01575310,0x37531000,0x53100000,0x00003557,0x004d5cc4, 0x00000000,0x00000000,0x7fffcc00,0x0000003f,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x40000000,0x01fffffa, 0x4ccccc40,0x99999999,0x99999999,0x00000999,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x03ffffee,0xfffff500, 0xffffffff,0xffffffff,0x00009fff,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x07ffffe4,0x3fffea00,0xffffffff, 0xffffffff,0x0004ffff,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x1fffff60,0x3fffea00,0xffffffff,0xffffffff, 0x0004ffff,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x1fffffa0,0x33332600,0xcccccccc,0xcccccccc,0x0002cccc, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x776c0200,0xee9806ee,0xddd74eee,0x754007dd, 0xdd94eeee,0xed801ddd,0x6c00eeee,0x7545eeee,0xeeeeeeee,0xeeeeeeee, 0x5554001e,0xdb1001aa,0x801ddddd,0x0deeeeed,0x7ffffb00,0x00000000, 0x00fffc80,0x55555000,0xddddd135,0x37fff225,0xffffff0b,0xfffff300, 0x3ffffe6b,0x3fff6007,0xffff52ff,0x7ffc405f,0x3e602fff,0x7dc5ffff, 0xffffffff,0xffffffff,0x7ffc002f,0x3ee003ff,0x205fffff,0x2ffffffc, 0xfffff100,0x3ffe200d,0xffffffff,0xffffffff,0x7fdc05ff,0xffff800f, 0x7ffffc7f,0xfffff8bf,0xfffffe8b,0xffffff2f,0xfffff300,0x7fffff4b, 0xffff8802,0x3fffe27f,0x3ffea04f,0x3ee04fff,0x7dc2ffff,0xffffffff, 0xffffffff,0x7ffc002f,0x7ec003ff,0x982fffff,0x05ffffff,0x3fffff20, 0xfff8802f,0xffffffff,0xffffffff,0x7fd405ff,0xfffff007,0xffffff8f, 0xbfffff8b,0xfffffffd,0x0ffffff0,0xbfffff30,0x2fffffdc,0x7ffffdc0, 0x3ffffec4,0xffffff90,0x7fffec0d,0x7fffdc0f,0xffffffff,0x02ffffff, 0x1fffffc0,0x3fffe200,0x3fa20fff,0x000effff,0xfffffff1,0xffff100d, 0xffffffff,0xffffffff,0x3ea144bf,0xfff8286f,0x7fffc7ff,0xffff8bff, 0xffffffef,0x3ffffe5f,0xffff9807,0x3fffe25f,0x7ff400ff,0x7fdc0fff, 0xffd01fff,0x101fffff,0x70bfffff,0xffffffff,0xffffffff,0xff8003ff, 0xa8003fff,0x24ffffff,0x1ffffffc,0x3ffff200,0x4401ffff,0xffffffff, 0xffffffff,0x2e5fffff,0x2bff32ef,0x7fc1feb8,0x7ffc7fff,0xfff8bfff, 0xffffffff,0x3fffe2ff,0xfff9807f,0x7ffe45ff,0x3fe603ff,0xff885fff, 0xff883fff,0x82ffffff,0x82fffffa,0x99999998,0xfffffa99,0xff8003ff, 0xb0003fff,0x53ffffff,0x07ffffff,0x7ffffc40,0x4405ffff,0xffffffff, 0xffffffff,0x3a5fffff,0xdffbefff,0x7c4ffffc,0x7fc7ffff,0xff8bffff, 0x9cffffff,0x7fffc7da,0xfff9807f,0x7ffcc5ff,0x3ff206ff,0xffd02fff, 0xfff50dff,0x909fffff,0x001fffff,0x3ffffa20,0xff0004ff,0x20007fff, 0xefffffe8,0x06fffffe,0x7ffffdc0,0x201fffff,0xccccccc8,0xcccccccc, 0x33cccccc,0xffffffff,0x8dffffff,0x746fffff,0xf8afffff,0x02ffffff, 0x07fffff8,0x5fffff98,0x1fffffe8,0x0ffffff0,0x07ffffdc,0x3ffffff2, 0xffff86ff,0x3f60005f,0x005fffff,0x0fffffe0,0xffff9800,0xffffffff, 0x7fffc000,0x4ffffebf,0x40000000,0xfffffeb9,0x03ceffff,0xffd8bff3, 0xfff89fff,0xff006fff,0xf300ffff,0xf70bffff,0xf509ffff,0x4c09ffff, 0x742fffff,0xfffeffff,0x3fffe60f,0xffb0003f,0x201dffff,0xaaaaaaa8, 0xadfffffa,0x02aaaaaa,0x7fffffe4,0x4002ffff,0xb8fffffb,0x000fffff, 0x2a000000,0x001fffff,0xffb89ff7,0xfff88fff,0xff002fff,0xf300ffff, 0xf10bffff,0xfb0fffff,0xe803ffff,0x3e24ffff,0xfffcdfff,0x3fffee2f, 0xffc8000f,0x200fffff,0xfffffff8,0xffffffff,0x05ffffff,0xffffffe8, 0xfe8005ff,0xfff15fff,0x000009ff,0x3ffa2000,0xfd004fff,0xffffa87f, 0xffffff17,0x3fffe003,0xfffa807f,0xfff905ff,0x7ffc43ff,0xffc806ff, 0x3ffea7ff,0x4ffffabf,0x01bffff6,0x3ffffee0,0x7fc401ff,0xffffffff, 0xffffffff,0xf8805fff,0x0effffff,0x7fffd400,0x3ffff21f,0xcccc880f, 0xcccccccc,0xcccccccc,0xfffe883c,0x2203fffc,0xff886ffd,0xffff15ff, 0x3fe001ff,0xfa807fff,0xf305ffff,0x7dc9ffff,0x9802ffff,0xfb1fffff, 0xfff13fff,0x3fffe2df,0x7fd4003f,0x802fffff,0xfffffff8,0xffffffff, 0x05ffffff,0xffffffb0,0xfffd000d,0xffff98df,0xffff883f,0xffffffff, 0xffffffff,0x7fff445f,0x305fffd2,0x3603ffff,0xfff13eee,0x7fc00fff, 0x5400ffff,0x205fffff,0x3a7ffffe,0x2007ffff,0xff3fffff,0x7fff4fff, 0xfffffa8f,0x3ffe6001,0x1003ffff,0xffffffff,0xffffffff,0x00bfffff, 0xfffffff5,0x7fcc009f,0xffe83fff,0xfff886ff,0xffffffff,0xffffffff, 0x7ffec5ff,0x03fffea5,0x0005dff1,0x0ffffff1,0x7fffffc0,0x7fffd400, 0x3ffee05f,0xffff9aff,0x3ff2004f,0xffff9dff,0x2bffff25,0x006ffffc, 0x3fffffe2,0x3fe2004f,0xffffffff,0xffffffff,0x7c405fff,0xffffffff, 0xfffb001f,0xfff701ff,0xfff885ff,0xffffffff,0xffffffff,0x1ffd85ff, 0x3b8177ec,0x3ffe2000,0x3fe007ff,0x5c00ffff,0x205fffff,0xbcfffff8, 0x001fffff,0x2fffffea,0x3e63ffff,0xffffcfff,0xffd1004f,0x800bffff, 0xaaaaaaa8,0xadfffffa,0x02aaaaaa,0x7fffffec,0x400effff,0x05fffff9, 0x8dfffff1,0xfffffff8,0xffffffff,0x05ffffff,0x00191097,0x7ffc4000, 0x3fe007ff,0x6401ffff,0x405fffff,0xfefffffc,0xf8006fff,0xffffffff, 0x7ffffc1f,0x001fffff,0xbffffffb,0x3fe00000,0x20003fff,0xfffffffb, 0x405fffff,0x01fffffd,0x87fffff2,0xfffffff8,0xffffffff,0x05ffffff, 0x80000000,0x07fffff8,0x3fffffa0,0x3fffe602,0x7fcc05ff,0xffffffff, 0xfffd8003,0xd87fffff,0xffffffff,0xffff9007,0x00000dff,0x01fffffc, 0xfffff980,0xfffffccf,0xffff102f,0xfff980df,0x000005ff,0x00000000, 0xfffff100,0x7ffec00d,0xfe880eff,0x805fffff,0xfffffffe,0xff50007f, 0x0bffffff,0xfffffff7,0xfff7009f,0x3333ffff,0x33333333,0xfffff800, 0xfffd0003,0x3ffe2dff,0x9880ffff,0x98009999,0x00019999,0x00000000, 0xfff10000,0x7dc00dff,0x8befffff,0xfffffec9,0xffb805ff,0x04ffffff, 0xfffff100,0xff307fff,0x03ffffff,0xffffff98,0xffffffff,0x007fffff, 0x01fffffc,0x7ffffe40,0x3fffea1f,0x000005ff,0x00000000,0x00000000, 0x1bffffe2,0xfffff980,0xffffffff,0x05ffffff,0xffffff88,0x360001ff, 0x1fffffff,0xfffffff0,0xffff300f,0xffffffff,0xffffffff,0xfffff800, 0x7ffcc003,0xffd84fff,0x54c3ffff,0x5542aaaa,0x5101aaaa,0x30003599, 0x7ffffe41,0xaaa98005,0xaaaaaaaa,0x3fffe200,0x7fd4006f,0xffffffff, 0xffffe9ef,0xffff9005,0xb8000dff,0x07ffffff,0x3ffffff6,0xffff9804, 0xffffffff,0x7fffffff,0x7ffffc00,0x3ffa2003,0xf880efff,0x21ffffff, 0x47fffffc,0x44ffffff,0xffffffe9,0x0fb801cf,0x0fffffec,0x43fffffa, 0xfffffffc,0x2200ffff,0x006fffff,0xffffffb8,0xffd0efff,0x3e600bff, 0x003fffff,0x7ffffc40,0x3ffee05f,0xf9802fff,0xffffffff,0xffffffff, 0x7fc007ff,0x32003fff,0x02ffffff,0x3fffffea,0x3fffff26,0x7fffffc7, 0x3ffffee4,0xbeffffff,0x407fecc0,0x745ffffd,0xf90fffff,0xffffffff, 0x7fc401ff,0x70006fff,0x7bfffffb,0x05ffffe8,0x3fffffa0,0xffe80000, 0x3e202fff,0x3007ffff,0xffffffff,0xffffffff,0xa800ffff,0x5001aaaa, 0x09ffffff,0xffffffb0,0x3fffff29,0x7fffffc7,0xffffff74,0xffffffff, 0xfffffddf,0xffffd101,0x7fffff41,0xffffff90,0x401fffff,0x06fffff8, 0x001a9800,0x00000000,0x00000000,0x00000000,0x00000000,0x3ffff200, 0x7ffffc7f,0xfffff94f,0xffffffff,0xffffffff,0x3ffa201f,0x3ffffa4f, 0xfffff90f,0x01ffffff,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x7ffe4000,0x7fffc7ff,0xffff94ff,0xffffffff,0xffffffff, 0x7fc401ff,0xffffd0ff,0x3ffff21f,0x0fffffff,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x3fee0000,0x7ff46fff,0x9ff93fff, 0x3ff26215,0xffffffff,0xbb8803ff,0xfffffd1b,0x333332a1,0x00cccccc, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x3ffe6000, 0x7ffe45ff,0x003f92ff,0xffffffb5,0x000001df,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x1fffffc4,0x43ffffee, 0x65c4000a,0x00000ace,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x5ffffd00,0x07ffff98,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x7fffec00, 0x37fffc40,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x3bbae000,0x09dddb06,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, }; static signed short stb__arial_bold_49_usascii_x[95]={ 0,3,2,0,1,1,1,1,2,1,0,1,2,1, 3,-1,1,3,1,1,0,1,1,1,1,1,4,3,2,1,2,2,1,0,3,2,3,3,3,2,3,2,0,3, 3,3,3,1,3,1,3,1,0,3,-1,0,0,-1,0,3,-1,0,2,-1,0,1,2,1,1,1,0,1,3,3, -3,2,3,2,3,1,2,1,2,1,0,3,0,0,0,0,0,1,3,0,1, }; static signed short stb__arial_bold_49_usascii_y[95]={ 39,7,7,7,5,7,7,7,7,7,7,12,32,24, 32,7,7,7,7,7,7,8,7,8,7,7,16,16,11,15,11,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,43,7,15,7,15,7,15,7,15,7,7, 7,7,7,15,15,15,15,15,15,15,8,16,16,16,16,16,16,7,7,7,19, }; static unsigned short stb__arial_bold_49_usascii_w[95]={ 0,8,17,24,22,36,30,8,12,12,17,23,8,13, 7,14,22,15,22,22,24,23,22,22,22,22,7,8,22,23,22,23,42,32,27,28,27,25,22,30,26,8,21,29, 23,31,26,32,25,33,29,27,26,26,31,42,30,31,26,11,14,12,22,26,11,22,24,23,24,22,16,23,21,7, 13,22,7,35,21,25,24,24,16,22,15,21,24,35,24,24,22,15,6,16,24, }; static unsigned short stb__arial_bold_49_usascii_h[95]={ 0,32,12,33,39,34,33,12,42,42,16,23,15,7, 7,33,33,32,32,33,32,32,33,31,33,33,23,31,25,17,25,32,42,32,32,33,32,32,32,33,32,32,33,32, 32,32,32,33,32,36,32,33,32,33,32,32,32,32,32,41,33,41,18,5,7,25,33,25,33,25,32,34,32,32, 42,32,32,24,24,25,33,33,24,25,32,24,23,23,23,33,23,42,42,42,9, }; static unsigned short stb__arial_bold_49_usascii_s[95]={ 255,228,173,198,149,1,29,247,97,1,220, 124,238,236,228,85,125,239,52,163,129,215,215,1,152,175,247,246,24,196,70, 28,54,182,154,186,101,75,92,121,1,237,223,198,174,142,115,88,66,172,28, 1,1,1,199,156,125,93,66,124,148,136,173,24,216,119,60,165,100,47,238, 206,28,245,110,231,58,211,189,93,63,38,1,142,50,18,40,65,148,230,101, 38,31,14,191, }; static unsigned short stb__arial_bold_49_usascii_t[95]={ 1,146,264,44,1,44,79,245,1,1,245, 245,245,264,264,79,79,179,179,79,179,179,79,213,44,44,213,146,213,245,213, 179,1,179,179,79,179,179,146,44,180,146,44,146,146,146,146,44,146,1,146, 79,147,113,113,113,113,113,113,1,79,1,245,239,264,213,79,213,79,213,79, 1,113,44,1,113,146,213,213,213,44,44,245,213,113,245,245,245,245,1,245, 1,1,1,264, }; static unsigned short stb__arial_bold_49_usascii_a[95]={ 195,234,333,390,390,624,507,167, 234,234,273,410,195,234,195,195,390,390,390,390,390,390,390,390, 390,390,234,234,410,410,410,429,684,507,507,507,507,468,429,546, 507,195,390,507,429,585,507,546,468,546,507,468,429,507,468,662, 468,468,429,234,195,234,410,390,234,390,429,390,429,390,234,429, 429,195,195,390,195,624,429,429,429,429,273,390,234,429,390,546, 390,390,351,273,196,273,410, }; // Call this function with // font: NULL or array length // data: NULL or specified size // height: STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT or STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT_POW2 // return value: spacing between lines static void stb_font_arial_bold_49_usascii(stb_fontchar font[STB_FONT_arial_bold_49_usascii_NUM_CHARS], unsigned char data[STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT][STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH], int height) { int i,j; if (data != 0) { unsigned int *bits = stb__arial_bold_49_usascii_pixels; unsigned int bitpack = *bits++, numbits = 32; for (i=0; i < STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH*height; ++i) data[0][i] = 0; // zero entire bitmap for (j=1; j < STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT-1; ++j) { for (i=1; i < STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH-1; ++i) { unsigned int value; if (numbits==0) bitpack = *bits++, numbits=32; value = bitpack & 1; bitpack >>= 1, --numbits; if (value) { if (numbits < 3) bitpack = *bits++, numbits = 32; data[j][i] = (bitpack & 7) * 0x20 + 0x1f; bitpack >>= 3, numbits -= 3; } else { data[j][i] = 0; } } } } // build font description if (font != 0) { float recip_width = 1.0f / STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH; float recip_height = 1.0f / height; for (i=0; i < STB_FONT_arial_bold_49_usascii_NUM_CHARS; ++i) { // pad characters so they bilerp from empty space around each character font[i].s0 = (stb__arial_bold_49_usascii_s[i]) * recip_width; font[i].t0 = (stb__arial_bold_49_usascii_t[i]) * recip_height; font[i].s1 = (stb__arial_bold_49_usascii_s[i] + stb__arial_bold_49_usascii_w[i]) * recip_width; font[i].t1 = (stb__arial_bold_49_usascii_t[i] + stb__arial_bold_49_usascii_h[i]) * recip_height; font[i].x0 = stb__arial_bold_49_usascii_x[i]; font[i].y0 = stb__arial_bold_49_usascii_y[i]; font[i].x1 = stb__arial_bold_49_usascii_x[i] + stb__arial_bold_49_usascii_w[i]; font[i].y1 = stb__arial_bold_49_usascii_y[i] + stb__arial_bold_49_usascii_h[i]; font[i].advance_int = (stb__arial_bold_49_usascii_a[i]+8)>>4; font[i].s0f = (stb__arial_bold_49_usascii_s[i] - 0.5f) * recip_width; font[i].t0f = (stb__arial_bold_49_usascii_t[i] - 0.5f) * recip_height; font[i].s1f = (stb__arial_bold_49_usascii_s[i] + stb__arial_bold_49_usascii_w[i] + 0.5f) * recip_width; font[i].t1f = (stb__arial_bold_49_usascii_t[i] + stb__arial_bold_49_usascii_h[i] + 0.5f) * recip_height; font[i].x0f = stb__arial_bold_49_usascii_x[i] - 0.5f; font[i].y0f = stb__arial_bold_49_usascii_y[i] - 0.5f; font[i].x1f = stb__arial_bold_49_usascii_x[i] + stb__arial_bold_49_usascii_w[i] + 0.5f; font[i].y1f = stb__arial_bold_49_usascii_y[i] + stb__arial_bold_49_usascii_h[i] + 0.5f; font[i].advance = stb__arial_bold_49_usascii_a[i]/16.0f; } } } #ifndef STB_SOMEFONT_CREATE #define STB_SOMEFONT_CREATE stb_font_arial_bold_49_usascii #define STB_SOMEFONT_BITMAP_WIDTH STB_FONT_arial_bold_49_usascii_BITMAP_WIDTH #define STB_SOMEFONT_BITMAP_HEIGHT STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT #define STB_SOMEFONT_BITMAP_HEIGHT_POW2 STB_FONT_arial_bold_49_usascii_BITMAP_HEIGHT_POW2 #define STB_SOMEFONT_FIRST_CHAR STB_FONT_arial_bold_49_usascii_FIRST_CHAR #define STB_SOMEFONT_NUM_CHARS STB_FONT_arial_bold_49_usascii_NUM_CHARS #define STB_SOMEFONT_LINE_SPACING STB_FONT_arial_bold_49_usascii_LINE_SPACING #endif
68.532918
127
0.811206
stetre
d5d39d65bcd29a5f3ef342fdb428128bf7363589
7,790
cpp
C++
dlc/src/v20210125/model/ViewResponseInfo.cpp
sinjoywong/tencentcloud-sdk-cpp
1b931d20956a90b15a6720f924e5c69f8786f9f4
[ "Apache-2.0" ]
null
null
null
dlc/src/v20210125/model/ViewResponseInfo.cpp
sinjoywong/tencentcloud-sdk-cpp
1b931d20956a90b15a6720f924e5c69f8786f9f4
[ "Apache-2.0" ]
null
null
null
dlc/src/v20210125/model/ViewResponseInfo.cpp
sinjoywong/tencentcloud-sdk-cpp
1b931d20956a90b15a6720f924e5c69f8786f9f4
[ "Apache-2.0" ]
null
null
null
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/dlc/v20210125/model/ViewResponseInfo.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Dlc::V20210125::Model; using namespace std; ViewResponseInfo::ViewResponseInfo() : m_viewBaseInfoHasBeenSet(false), m_columnsHasBeenSet(false), m_propertiesHasBeenSet(false), m_createTimeHasBeenSet(false), m_modifiedTimeHasBeenSet(false) { } CoreInternalOutcome ViewResponseInfo::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("ViewBaseInfo") && !value["ViewBaseInfo"].IsNull()) { if (!value["ViewBaseInfo"].IsObject()) { return CoreInternalOutcome(Error("response `ViewResponseInfo.ViewBaseInfo` is not object type").SetRequestId(requestId)); } CoreInternalOutcome outcome = m_viewBaseInfo.Deserialize(value["ViewBaseInfo"]); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_viewBaseInfoHasBeenSet = true; } if (value.HasMember("Columns") && !value["Columns"].IsNull()) { if (!value["Columns"].IsArray()) return CoreInternalOutcome(Error("response `ViewResponseInfo.Columns` is not array type")); const rapidjson::Value &tmpValue = value["Columns"]; for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr) { Column item; CoreInternalOutcome outcome = item.Deserialize(*itr); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_columns.push_back(item); } m_columnsHasBeenSet = true; } if (value.HasMember("Properties") && !value["Properties"].IsNull()) { if (!value["Properties"].IsArray()) return CoreInternalOutcome(Error("response `ViewResponseInfo.Properties` is not array type")); const rapidjson::Value &tmpValue = value["Properties"]; for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr) { Property item; CoreInternalOutcome outcome = item.Deserialize(*itr); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_properties.push_back(item); } m_propertiesHasBeenSet = true; } if (value.HasMember("CreateTime") && !value["CreateTime"].IsNull()) { if (!value["CreateTime"].IsString()) { return CoreInternalOutcome(Error("response `ViewResponseInfo.CreateTime` IsString=false incorrectly").SetRequestId(requestId)); } m_createTime = string(value["CreateTime"].GetString()); m_createTimeHasBeenSet = true; } if (value.HasMember("ModifiedTime") && !value["ModifiedTime"].IsNull()) { if (!value["ModifiedTime"].IsString()) { return CoreInternalOutcome(Error("response `ViewResponseInfo.ModifiedTime` IsString=false incorrectly").SetRequestId(requestId)); } m_modifiedTime = string(value["ModifiedTime"].GetString()); m_modifiedTimeHasBeenSet = true; } return CoreInternalOutcome(true); } void ViewResponseInfo::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_viewBaseInfoHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ViewBaseInfo"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kObjectType).Move(), allocator); m_viewBaseInfo.ToJsonObject(value[key.c_str()], allocator); } if (m_columnsHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Columns"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator); int i=0; for (auto itr = m_columns.begin(); itr != m_columns.end(); ++itr, ++i) { value[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator); (*itr).ToJsonObject(value[key.c_str()][i], allocator); } } if (m_propertiesHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Properties"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator); int i=0; for (auto itr = m_properties.begin(); itr != m_properties.end(); ++itr, ++i) { value[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator); (*itr).ToJsonObject(value[key.c_str()][i], allocator); } } if (m_createTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "CreateTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_createTime.c_str(), allocator).Move(), allocator); } if (m_modifiedTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ModifiedTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_modifiedTime.c_str(), allocator).Move(), allocator); } } ViewBaseInfo ViewResponseInfo::GetViewBaseInfo() const { return m_viewBaseInfo; } void ViewResponseInfo::SetViewBaseInfo(const ViewBaseInfo& _viewBaseInfo) { m_viewBaseInfo = _viewBaseInfo; m_viewBaseInfoHasBeenSet = true; } bool ViewResponseInfo::ViewBaseInfoHasBeenSet() const { return m_viewBaseInfoHasBeenSet; } vector<Column> ViewResponseInfo::GetColumns() const { return m_columns; } void ViewResponseInfo::SetColumns(const vector<Column>& _columns) { m_columns = _columns; m_columnsHasBeenSet = true; } bool ViewResponseInfo::ColumnsHasBeenSet() const { return m_columnsHasBeenSet; } vector<Property> ViewResponseInfo::GetProperties() const { return m_properties; } void ViewResponseInfo::SetProperties(const vector<Property>& _properties) { m_properties = _properties; m_propertiesHasBeenSet = true; } bool ViewResponseInfo::PropertiesHasBeenSet() const { return m_propertiesHasBeenSet; } string ViewResponseInfo::GetCreateTime() const { return m_createTime; } void ViewResponseInfo::SetCreateTime(const string& _createTime) { m_createTime = _createTime; m_createTimeHasBeenSet = true; } bool ViewResponseInfo::CreateTimeHasBeenSet() const { return m_createTimeHasBeenSet; } string ViewResponseInfo::GetModifiedTime() const { return m_modifiedTime; } void ViewResponseInfo::SetModifiedTime(const string& _modifiedTime) { m_modifiedTime = _modifiedTime; m_modifiedTimeHasBeenSet = true; } bool ViewResponseInfo::ModifiedTimeHasBeenSet() const { return m_modifiedTimeHasBeenSet; }
30.07722
141
0.66534
sinjoywong
d5d8d2ba88bfbe7ad100f17e91e8d167006b3f63
1,986
cpp
C++
lib/error.cpp
gabrielcuvillier/stdext
3a5346deab9f3fd86aa66384222792313daa7524
[ "MIT" ]
1
2019-10-02T12:51:19.000Z
2019-10-02T12:51:19.000Z
lib/error.cpp
gabrielcuvillier/stdext
3a5346deab9f3fd86aa66384222792313daa7524
[ "MIT" ]
null
null
null
lib/error.cpp
gabrielcuvillier/stdext
3a5346deab9f3fd86aa66384222792313daa7524
[ "MIT" ]
null
null
null
// Copyright (c) 2019 - Gabriel Cuvillier, Continuation Labs (www.continuation-labs.com) // Licensed under the MIT License. // Main header #include <stdext/error> // std #include <cstdio> // std::fprintf, stderr #include <cstdlib> // std::abort #include <exception> // std::set_terminate #include <string> // std::string // stdext #include <stdext/fs> void stdext::install_unhandled_exception_handler() noexcept { std::set_terminate( []() { std::fprintf( stderr, "Terminate handler called: aborting the program.\n" ); std::abort(); } ); } template<> const char* stdext::enum_to_string( stdext::InternalError err ) noexcept { switch ( err ) { case stdext::InternalError::AssertionFailed: return "InternalError::AssertionFailed"; } return "InternalError::<unknown>"; } void stdext::PRINTERROR( const char* file, int line, int col, const char* func, const char* message ) noexcept { std::fprintf( stderr, "Failure in %s, line %d:%d: function '%s': '%s'\n", stdext::get_file_name( std::string( file ) ).c_str(), line, col, func, message ); } namespace { const char* const abort_msg = " Aborting function\n"; const char* const abort_prog = " Aborting program\n"; const char* const skipping_iteration_msg = " Skipping iteration\n"; const char* const abort_loop_msg = " Aborting loop\n"; const char* const continue_msg = " Continuing\n"; } // namespace void stdext::EPICFAIL_RET() noexcept { std::fprintf( stderr, abort_msg ); } void stdext::EPICFAIL_CRASH() noexcept { std::fprintf( stderr, abort_prog ); } void stdext::EPICFAIL_RET_VOID() noexcept { std::fprintf( stderr, abort_msg ); } void stdext::EPICFAIL_RET_INT() noexcept { std::fprintf( stderr, abort_msg ); } void stdext::EPICFAIL_LOOP() noexcept { std::fprintf( stderr, skipping_iteration_msg ); } void stdext::EPICFAIL_LOOP_BREAK() noexcept { std::fprintf( stderr, abort_loop_msg ); } void stdext::EPICFAIL_NOP() noexcept { std::fprintf( stderr, continue_msg ); }
32.557377
110
0.70292
gabrielcuvillier
d5df0056a57d0ab2789b04d18b7eb3b1c837dc62
17,119
cpp
C++
ASCIILib/DialogFrame.cpp
Natman64/ASCIILib
04f661416261467df0d6f816fa31e870c0fcd8a9
[ "MIT" ]
1
2019-09-27T11:20:10.000Z
2019-09-27T11:20:10.000Z
ASCIILib/DialogFrame.cpp
NQNStudios/ASCIILib
04f661416261467df0d6f816fa31e870c0fcd8a9
[ "MIT" ]
13
2015-09-27T23:58:19.000Z
2015-09-28T16:24:11.000Z
ASCIILib/DialogFrame.cpp
Natman64/ASCIILib
04f661416261467df0d6f816fa31e870c0fcd8a9
[ "MIT" ]
null
null
null
#include "DialogFrame.h" #include <string> #include <algorithm> #include <stdlib.h> #include <time.h> #include <sstream> #include "Log.h" #include "StringTokenizer.h" #include "Game.h" using namespace ascii; namespace { const unsigned int LINE_BREAK_AMOUNT = 2; } ascii::DialogFrame::DialogFrame(Rectangle frame, DialogStyle* style, ascii::Game* game) : mFrame(frame), mTextColor(style->TextColor), mpGame(game), mLastCharX(mFrame.x), mLastCharY(mFrame.y), mMarkedCharX(0), mMarkedCharY(0), // FIXME this code does not account for right-to-left dialog! frameStartX(frame.left()), frameStartY(frame.top()), frameFinishX(frame.right() - 1), frameFinishY(frame.bottom() - 1), mpStyle(style), mDummyCellsPassed(0) { } int ascii::DialogFrame::Width() { return frameFinishX - frameStartX + 1; } int ascii::DialogFrame::Height() { return frameFinishY - frameStartY + 1; } void ascii::DialogFrame::AddWord(UnicodeString word) { // Count the length of the word, including trailing whitespace int lengthWithSpace = word.length(); // Copy and trim the word of whitespace UnicodeString trimmed = word; trimmed.trim(); // Count the length without trailing whitespace int length = trimmed.length(); if (lengthWithSpace == 0 || length == 0) { // TODO something goes wrong here and I don't know why, but this return // statement avoids the bug Log::Error("Tried to add an empty word"); return; } // Calculate where the word needs to be placed unsigned int drawX = mLastCharX; unsigned int drawY = mLastCharY; // Calculate where the word will terminate if inserted on the current line const unsigned int finishX = drawX + length - 1; if (finishX > frameFinishX) { //Log("Wrapping to the next line because of word"); //ULog(word); // Wrap to the next line if necessary drawX = frameStartX; ++drawY; } // Add the word (including trailing white-space) as a token mapped with // its screen position. mWords.push_back(ScrollingWord(word, Point(drawX, drawY), mpStyle)); // Store the coordinates where the word terminated, so we can place the // next word mLastCharX = drawX + lengthWithSpace; mLastCharY = drawY; } void ascii::DialogFrame::AddHeading(UnicodeString heading) { // Make sure the heading will fit on a line if (heading.length() > Width()) { Log::Error("Tried to add a heading which was too long to fit on a line: " + heading); return; } // Calculate where the heading needs to be placed unsigned int drawX = (frameStartX + frameFinishX) / 2 - heading.length() / 2; unsigned int drawY = mLastCharY; // Add the word as a token mapped with its screen position. mWords.push_back(ScrollingWord(heading, Point(drawX, drawY), mpStyle)); mLastCharX = drawX + heading.length() - 1; } UnicodeString ascii::DialogFrame::AddParagraphFlush(UnicodeString paragraph) { if (mLastCharY > frameFinishY) return paragraph; vector<int> wordCounts; vector<vector<UnicodeString> > lines; vector<int> lineLengths; int words = 0; int lineLength = 0; StringTokenizer tokenizer(paragraph); UnicodeString remainder; vector<UnicodeString> line; while (tokenizer.HasNextToken()) { // Retrieve the next token untrimmed UnicodeString word = tokenizer.NextToken(false); // Count the token's length trimmed UnicodeString trimmed(word); trimmed.trim(); lineLength += trimmed.length(); if (lineLength <= Width()) { //Log("Adding justified word"); //ULog(word); // Add the token untrimmed line.push_back(word); // Increase line length to account for untrimmed version before // counting the next token lineLength += word.length() - trimmed.length(); //Log("Line length after adding word: "); //Log(lineLength); } else { lineLength -= trimmed.length(); if (mLastCharY + lines.size() >= frameFinishY) { remainder = word + tokenizer.BufferRemainder(); break; } else { wordCounts.push_back(line.size()); lines.push_back(line); if (IsWhiteSpace(line.back()[line.back().length() - 1])) { lineLength -= 1; } lineLengths.push_back(lineLength); //Log("-------------------------------"); //Log("Adding justified word"); //ULog(word); line.clear(); line.push_back(word); lineLength = word.length(); //Log("Line length after adding word: "); //Log(lineLength); } } } if (!line.empty()) { lines.push_back(line); wordCounts.push_back(line.size()); lineLengths.push_back(lineLength); lineLength = 0; } for (int i = 0; i < lines.size(); ++i) { vector<UnicodeString> line = lines[i]; int wordCount = wordCounts[i]; int lineLength = lineLengths[i]; int extraSpaces = Width() - lineLength; //Log("Extra spaces: "); //Log(extraSpaces); vector<int> spaces; if (wordCount > 1) { for (int j = 0; j < wordCount - 1; ++j) { spaces.push_back(0); } for (int j = extraSpaces - 1; j >= 0; --j) { int whichGap = j % spaces.size(); spaces[whichGap] += 1; } } else { spaces.push_back(0); } // The last word has no trailing spaces spaces.push_back(0); int k = 0; for (int i = 0; i < line.size(); ++i) { UnicodeString uword = line[i]; if (CanFitWord(uword)) { AddWord(uword); RevealLetters(uword.length()); if (lineLength > 3 * Width() / 4) { mLastCharX += spaces[k++]; } } } } //Log::Print("Returning a remainder"); //Log::Print(remainder); return remainder; } void ascii::DialogFrame::AddSurface(Surface* surface) { // Make sure the surface will fit on a line if (surface->width() > Width()) { Log::Error("Tried to add a surface which was too wide to fit in this DialogFrame."); return; } // Make sure the surface will fit vertically in the remaining space if (surface->height() > (frameFinishY + 1 - mLastCharY)) { Log::Error("Tried to add a surface which was too tall to fit in this DialogFrame."); return; } // Place the surface in the frame Point position(mLastCharX, mLastCharY); mSurfaces[position] = surface; // Continue filling the DialogFrame one line below the bottom of the surface mLastCharY += surface->height(); HalfLineBreak(); } UnicodeString ascii::DialogFrame::MockWord(UnicodeString word, UChar mockLetter) { UnicodeString mockWord; for (int i = 0; i < word.length(); ++i) { mockWord += mockLetter; } return mockWord; } bool ascii::DialogFrame::AddMockParagraph(UnicodeString paragraph, UChar mockLetter) { StringTokenizer tokenizer(paragraph); while (tokenizer.HasNextToken()) { UnicodeString word = tokenizer.NextToken(); UnicodeString mockWord = MockWord(word, mockLetter) + " "; if (CanFitWord(mockWord)) { AddWord(mockWord); RevealLetters(mockWord.length()); } else { return false; } } if (CanLineBreak()) { LineBreak(); return true; } return false; } void ascii::DialogFrame::FillMockParagraphs(UChar mockLetter) { bool fitLastParagraph = true; while (fitLastParagraph) { // Add a random currently loaded paragraph, converted into the mock // character UnicodeString paragraph = mpGame->textManager()->GetRandomText(Width()*2); fitLastParagraph = AddMockParagraph(paragraph, mockLetter); } } void ascii::DialogFrame::FillMockParagraphsFlush(UChar mockLetter) { int maxLettersLeft = (frameFinishY - mLastCharY + 1) * Width(); int letters = 0; while (letters < maxLettersLeft) { UnicodeString paragraph = mpGame->textManager()->GetRandomText(Width()*2); StringTokenizer tokenizer(paragraph); UnicodeString mockParagraph; while (tokenizer.HasNextToken()) { UnicodeString word = tokenizer.NextToken(); UnicodeString mockWord = MockWord(word, mockLetter); mockParagraph += mockWord + " "; letters += mockWord.length() + 1; } AddParagraphFlush(mockParagraph); if (CanLineBreak()) { LineBreak(); } else { ++mLastCharY; } } } void ascii::DialogFrame::LineBreak() { // Don't line break ever if the style doesn't allow it if (!mpStyle->LineBreaks) return; // Only break for a single line if this frame is empty. We'll just assume a // parent object wrapped into this frame after filling an old one if (mLastCharX == frameStartX && mLastCharY == frameStartY) { HalfLineBreak(); return; } mLastCharX = frameStartX; mLastCharY += LINE_BREAK_AMOUNT; } void ascii::DialogFrame::HalfLineBreak() { if (mpStyle->LineBreaks) { mLastCharX = frameStartX; mLastCharY += LINE_BREAK_AMOUNT / 2; } } bool ascii::DialogFrame::CanFitWord(UnicodeString word) { // If we're already past the end of the frame because of a line break, // no go. if (mLastCharY > frameFinishY) return false; // If the word is wider than the frame, no go if (word.length() > mFrame.width) { Log::Error("Tried to add word '" + word + "' to a dialog frame for which it was too wide"); return false; } // Calculate the end of the word if placed immediately after the previous // one word.trim(); if (word.length() == 0) { Log::Print("Warning! Trying to add a word composed only of white-space"); } int finishX = mLastCharX + word.length() - 1; // If it can't fit on this line, can it fit on the next? if (finishX > frameFinishX) { //Log("Token doesn't fit in this frame:"); //ULog(word); //Log(frameFinishX - finishX); //Log(word.length()); // Fits as long as we can wrap to another line return mLastCharY < frameFinishY; } return true; // It fits on the current line } bool ascii::DialogFrame::CanFitHeading() { // 3 lines must remain in order for any text to be fit after the line // breaking following the heading int linesRequired = LINE_BREAK_AMOUNT + 1; return (frameFinishY - mLastCharY + 1 >= linesRequired); } bool ascii::DialogFrame::CanLineBreak() { // This doesn't make sense but trust me on it if (!mpStyle->LineBreaks) return true; // This frame can fit a line break as long as it's above its last line. return mLastCharY < frameFinishY; } int ascii::DialogFrame::RevealedLetters() { int sum = 0; for (int i = 0; i < mWords.size(); ++i) { sum += mWords[i].RevealedLetters(); } return sum; } int ascii::DialogFrame::LettersToReveal() { // Return the greatest number of letters that any child ScrollingWord is // missing. The sum is not returned because every ScrollingWord currently // in the frame reveals itself simultaneously int max = 0; for (int i = 0; i < mWords.size(); ++i) { ScrollingWord word = mWords[i]; if (word.LettersToReveal() > max) { max = word.LettersToReveal(); } } return max; } void ascii::DialogFrame::RevealLetters(int amount) { // Reveal letters on every word that's currently scrolling // (This can be used to reveal multiple words at the same time in // different places!) for (auto it = mWords.begin(); it != mWords.end(); ++it) { if (!it->Revealed()) { it->RevealLetters(amount); } } } void ascii::DialogFrame::RevealAllLetters() { // Reveal all letters on every word in the message for (auto it = mWords.begin(); it != mWords.end(); ++it) { if (!it->Revealed()) { it->RevealAllLetters(); } } } void ascii::DialogFrame::HideLetters(int amount, int dummyCells) { if (mDummyCellsPassed < dummyCells) { ++mDummyCellsPassed; return; } // Hide letters on every word that is currently being hidden // (This can be used to hide multiple words at the same time in different // places!) for (auto it = mWords.begin(); it != mWords.end(); ++it) { if (!it->Hidden()) { it->HideLetters(amount); // TODO handle hiding all words at once for special dialog break; } } } bool ascii::DialogFrame::AllWordsRevealed() { // If no words have been added, then all words are revealed if (mWords.empty()) { return true; } // Otherwise check all of them, until finding one that isn't fully revealed for (auto it = mWords.begin(); it != mWords.end(); ++it) { if (!it->Revealed()) { return false; } } // If none is unfinished, then all words are revealed return true; } bool ascii::DialogFrame::AllWordsHidden() { // If no words have been added, then all words are hidden if (mWords.empty()) { return true; } // Otherwise check all of them, until finding one that isn't fully hidden for (auto it = mWords.begin(); it != mWords.end(); ++it) { if (!it->Hidden()) { return false; } } // If none aren't fully hidden, all are fully hidden return true; } void ascii::DialogFrame::Clear() { // clear all scrolling words mWords.clear(); // clear all surface mSurfaces.clear(); // move the "cursor" back to the beginning mLastCharX = frameStartX; mLastCharY = frameStartY; } void ascii::DialogFrame::Draw(Graphics& graphics, Preferences* config) { // Draw every scrolling word for (auto it = mWords.begin(); it != mWords.end(); ++it) { it->Draw(graphics); } // Draw every surface for (auto it = mSurfaces.begin(); it != mSurfaces.end(); ++it) { graphics.blitSurface(it->second, it->first.x, it->first.y); } // If debug view is enabled, display the text frame's bounding // rectangle visually: if (config->GetBool("debug-view")) { for (int x = frameStartX; x <= frameFinishX; ++x) { for (int y = frameStartY; y <= frameFinishY; ++y) { graphics.setBackgroundColor(x, y, Color::Red); } } } } void ascii::DialogFrame::DrawCursor(Graphics& graphics) { // If this frame's DialogStyle requires a cursor, draw it following all // text that has been revealed if (mpStyle->HasCursor) { Point cursorPosition(mLastCharX, mLastCharY); if (!mWords.empty()) { cursorPosition = mWords.back().NextCell(); // Draw on the next line if it would appear past the end of this // one if (cursorPosition.x > frameFinishX) { cursorPosition.x = frameStartX; cursorPosition.y += 1; } } graphics.setBackgroundColor(cursorPosition.x, cursorPosition.y, mpStyle->CursorColor); } } bool ascii::DialogFrame::HasWords() { // This might be some hackish trickery return !mWords.empty() || !mSurfaces.empty(); } void ascii::DialogFrame::MarkPosition() { mMarkedCharX = mLastCharX; mMarkedCharY = mLastCharY; } void ascii::DialogFrame::RewindPosition() { mLastCharX = mMarkedCharX; mLastCharY = mMarkedCharY; }
27.30303
100
0.563234
Natman64
d5e10077a710ca79d5a9c42054fb12ad6e5f7d1c
898
cpp
C++
test/vpunsignedshorttest.cpp
prodigeinfo/libvapor
eb23abd8c211f4a5b04dcee757ea323451011924
[ "BSD-3-Clause" ]
null
null
null
test/vpunsignedshorttest.cpp
prodigeinfo/libvapor
eb23abd8c211f4a5b04dcee757ea323451011924
[ "BSD-3-Clause" ]
null
null
null
test/vpunsignedshorttest.cpp
prodigeinfo/libvapor
eb23abd8c211f4a5b04dcee757ea323451011924
[ "BSD-3-Clause" ]
null
null
null
#define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> #include <vapor/vpunsignedshort.hpp> using namespace std; using namespace vapor; BOOST_AUTO_TEST_SUITE(test_suite1) BOOST_AUTO_TEST_CASE(vpunsignedshort_serialize) { vparchive_t expect, result; vpunsignedshort vpn; expect = "unsignedShort;5;12345"; vpn = 12345; result = vpn.serialize(); BOOST_REQUIRE_EQUAL(expect, result); } BOOST_AUTO_TEST_CASE(vpunsignedshort_deserialize) { unsigned short expect; vpunsignedshort result; vparchive_t s; try { result.deserialize("void;5;12345"); BOOST_FAIL("bad type shoud fail [" + boost::lexical_cast<std::string>(result) + "]"); } catch (invalid_argument ex) {} s = "unsignedShort;5;12345"; expect = 12345; result.deserialize(s.c_str()); BOOST_REQUIRE_EQUAL(expect, result); } BOOST_AUTO_TEST_SUITE_END()
21.902439
93
0.711581
prodigeinfo
d5e4dd898852222cc34bd3fc24f21155f128d33b
6,855
cpp
C++
src/jnc_api/jnc_DerivableType.cpp
vovkos/jancy
df693ef8072aeb4280d771a7d146041978ffce1f
[ "MIT" ]
48
2017-04-21T15:55:22.000Z
2021-11-19T16:40:25.000Z
src/jnc_api/jnc_DerivableType.cpp
vovkos/jancy
df693ef8072aeb4280d771a7d146041978ffce1f
[ "MIT" ]
5
2018-09-18T07:43:46.000Z
2021-07-31T15:41:09.000Z
src/jnc_api/jnc_DerivableType.cpp
vovkos/jancy
df693ef8072aeb4280d771a7d146041978ffce1f
[ "MIT" ]
11
2018-10-06T11:33:43.000Z
2022-03-04T10:16:23.000Z
//.............................................................................. // // This file is part of the Jancy toolkit. // // Jancy is distributed under the MIT license. // For details see accompanying license.txt file, // the public copy of which is also available at: // http://tibbo.com/downloads/archive/jancy/license.txt // //.............................................................................. #include "pch.h" #include "jnc_DerivableType.h" #ifdef _JNC_DYNAMIC_EXTENSION_LIB # include "jnc_ExtensionLib.h" #elif defined(_JNC_CORE) # include "jnc_ct_DerivableType.h" #endif //.............................................................................. #ifdef _JNC_DYNAMIC_EXTENSION_LIB JNC_EXTERN_C size_t jnc_BaseTypeSlot_getOffset(jnc_BaseTypeSlot* baseType) { return jnc_g_dynamicExtensionLibHost->m_baseTypeSlotFuncTable->m_getOffsetFunc(baseType); } JNC_EXTERN_C size_t jnc_BaseTypeSlot_getVtableIndex(jnc_BaseTypeSlot* baseType) { return jnc_g_dynamicExtensionLibHost->m_baseTypeSlotFuncTable->m_getVtableIndexFunc(baseType); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JNC_EXTERN_C uint_t jnc_Field_getPtrTypeFlags(jnc_Field* field) { return jnc_g_dynamicExtensionLibHost->m_fieldFuncTable->m_getPtrTypeFlagsFunc(field); } JNC_EXTERN_C size_t jnc_Field_getOffset(jnc_Field* field) { return jnc_g_dynamicExtensionLibHost->m_fieldFuncTable->m_getOffsetFunc(field); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JNC_EXTERN_C jnc_Function* jnc_DerivableType_getStaticConstructor(jnc_DerivableType* type) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getStaticConstructorFunc(type); } JNC_EXTERN_C jnc_OverloadableFunction jnc_DerivableType_getConstructor(jnc_DerivableType* type) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getConstructorFunc(type); } JNC_EXTERN_C jnc_Function* jnc_DerivableType_getDestructor(jnc_DerivableType* type) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getDestructorFunc(type); } JNC_EXTERN_C jnc_OverloadableFunction jnc_DerivableType_getUnaryOperator( jnc_DerivableType* type, jnc_UnOpKind opKind ) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getUnaryOperatorFunc(type, opKind); } JNC_EXTERN_C jnc_OverloadableFunction jnc_DerivableType_getBinaryOperator( jnc_DerivableType* type, jnc_BinOpKind opKind ) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getBinaryOperatorFunc(type, opKind); } JNC_EXTERN_C jnc_OverloadableFunction jnc_DerivableType_getCallOperator(jnc_DerivableType* type) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getCallOperatorFunc(type); } JNC_EXTERN_C size_t jnc_DerivableType_getCastOperatorCount(jnc_DerivableType* type) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getCastOperatorCountFunc(type); } JNC_EXTERN_C jnc_Function* jnc_DerivableType_getCastOperator( jnc_DerivableType* type, size_t index ) { return jnc_g_dynamicExtensionLibHost->m_derivableTypeFuncTable->m_getCastOperatorFunc(type, index); } #else // _JNC_DYNAMIC_EXTENSION_LIB JNC_EXTERN_C JNC_EXPORT_O size_t jnc_BaseTypeSlot_getOffset(jnc_BaseTypeSlot* baseType) { return baseType->getOffset(); } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_BaseTypeSlot_getVtableIndex(jnc_BaseTypeSlot* baseType) { return baseType->getVtableIndex(); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JNC_EXTERN_C JNC_EXPORT_O uint_t jnc_Field_getPtrTypeFlags(jnc_Field* field) { return field->getPtrTypeFlags(); } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_Field_getOffset(jnc_Field* field) { return field->getOffset(); } // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . JNC_EXTERN_C JNC_EXPORT_O jnc_Function* jnc_DerivableType_getStaticConstructor(jnc_DerivableType* type) { return type->getStaticConstructor(); } JNC_EXTERN_C JNC_EXPORT_O jnc_OverloadableFunction jnc_DerivableType_getConstructor(jnc_DerivableType* type) { return type->getConstructor(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Function* jnc_DerivableType_getDestructor(jnc_DerivableType* type) { return type->getDestructor(); } JNC_EXTERN_C JNC_EXPORT_O jnc_OverloadableFunction jnc_DerivableType_getUnaryOperator( jnc_DerivableType* type, jnc_UnOpKind opKind ) { return type->getUnaryOperator((jnc::UnOpKind)opKind); } JNC_EXTERN_C JNC_EXPORT_O jnc_OverloadableFunction jnc_DerivableType_getBinaryOperator( jnc_DerivableType* type, jnc_BinOpKind opKind ) { return type->getBinaryOperator((jnc::BinOpKind)opKind); } JNC_EXTERN_C JNC_EXPORT_O jnc_OverloadableFunction jnc_DerivableType_getCallOperator(jnc_DerivableType* type) { return type->getCallOperator(); } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getCastOperatorCount(jnc_DerivableType* type) { return type->getCastOperatorArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Function* jnc_DerivableType_getCastOperator( jnc_DerivableType* type, size_t index ) { return type->getCastOperatorArray()[index]; } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getBaseTypeCount(jnc_DerivableType* type) { return type->getBaseTypeArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_BaseTypeSlot* jnc_DerivableType_getBaseType( jnc_DerivableType* type, size_t index ) { return type->getBaseTypeArray() [index]; } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_findBaseTypeOffset( jnc_DerivableType* type, jnc_Type* baseType ) { return type->findBaseTypeOffset(baseType); } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getStaticVariableCount(jnc_DerivableType* type) { return type->getStaticVariableArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Variable* jnc_DerivableType_getStaticVariable( jnc_DerivableType* type, size_t index ) { return type->getStaticVariableArray()[index]; } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getFieldCount(jnc_DerivableType* type) { return type->getFieldArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Field* jnc_DerivableType_getField( jnc_DerivableType* type, size_t index ) { return type->getFieldArray()[index]; } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getMethodCount(jnc_DerivableType* type) { return type->getMethodArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Function* jnc_DerivableType_getMethod( jnc_DerivableType* type, size_t index ) { return type->getMethodArray()[index]; } JNC_EXTERN_C JNC_EXPORT_O size_t jnc_DerivableType_getPropertyCount(jnc_DerivableType* type) { return type->getPropertyArray().getCount(); } JNC_EXTERN_C JNC_EXPORT_O jnc_Property* jnc_DerivableType_getProperty( jnc_DerivableType* type, size_t index ) { return type->getPropertyArray()[index]; } #endif // _JNC_DYNAMIC_EXTENSION_LIB
22.47541
103
0.768053
vovkos
d5e572fcf3fe72934cef6d27a971b7646c24ca35
1,874
cpp
C++
Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
TheCrott/serenity
925f21353efaa5304c5d486e6802c4e75e0c4d15
[ "BSD-2-Clause" ]
1
2021-11-26T08:29:28.000Z
2021-11-26T08:29:28.000Z
Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
TheCrott/serenity
925f21353efaa5304c5d486e6802c4e75e0c4d15
[ "BSD-2-Clause" ]
null
null
null
Userland/Libraries/LibWeb/Bindings/CSSStyleDeclarationWrapperCustom.cpp
TheCrott/serenity
925f21353efaa5304c5d486e6802c4e75e0c4d15
[ "BSD-2-Clause" ]
1
2022-02-09T08:28:12.000Z
2022-02-09T08:28:12.000Z
/* * Copyright (c) 2021, Andreas Kling <kling@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ #include <LibWeb/Bindings/CSSStyleDeclarationWrapper.h> #include <LibWeb/DOM/Element.h> namespace Web::Bindings { bool CSSStyleDeclarationWrapper::internal_has_property(JS::PropertyName const& name) const { if (!name.is_string()) return Base::internal_has_property(name); // FIXME: These should actually use camelCase versions of the property names! auto property_id = CSS::property_id_from_string(name.to_string()); return property_id != CSS::PropertyID::Invalid; } JS::Value CSSStyleDeclarationWrapper::internal_get(JS::PropertyName const& name, JS::Value receiver) const { if (!name.is_string()) return Base::internal_get(name, receiver); // FIXME: These should actually use camelCase versions of the property names! auto property_id = CSS::property_id_from_string(name.to_string()); if (property_id == CSS::PropertyID::Invalid) return Base::internal_get(name, receiver); if (auto maybe_property = impl().property(property_id); maybe_property.has_value()) return js_string(vm(), maybe_property->value->to_string()); return js_string(vm(), String::empty()); } bool CSSStyleDeclarationWrapper::internal_set(JS::PropertyName const& name, JS::Value value, JS::Value receiver) { if (!name.is_string()) return Base::internal_set(name, value, receiver); // FIXME: These should actually use camelCase versions of the property names! auto property_id = CSS::property_id_from_string(name.to_string()); if (property_id == CSS::PropertyID::Invalid) return Base::internal_set(name, value, receiver); auto css_text = value.to_string(global_object()); if (vm().exception()) return false; return impl().set_property(property_id, css_text); } }
36.745098
112
0.71825
TheCrott
d5e91b4055d47089a1923a34fe12cb477a0ea8c4
2,698
cpp
C++
bytezero/storages/bytezerosdk.cpp
alackfeng/bytezeroqt
27978eb28a0637234be07a6a9daa6dcc9c684d40
[ "MIT" ]
null
null
null
bytezero/storages/bytezerosdk.cpp
alackfeng/bytezeroqt
27978eb28a0637234be07a6a9daa6dcc9c684d40
[ "MIT" ]
null
null
null
bytezero/storages/bytezerosdk.cpp
alackfeng/bytezeroqt
27978eb28a0637234be07a6a9daa6dcc9c684d40
[ "MIT" ]
null
null
null
#include "bytezerosdk.h" static const char* BYTEZERO_SDK_VERSION = "v1.0.0"; static QString BYTEZERO_APP_NAME = QObject::tr("bytezero"); static QString BYTEZERO_APP_TEST_NAME = QObject::tr("bytezero_test"); BytezeroSdk::BytezeroSdk(QObject *parent) : QObject(parent), m_config(new Config()) { QThreadPool::globalInstance()->setMaxThreadCount(3); m_appMode = m_config->appMode(); qDebug() << "BytezeroSdk::BytezeroSdk - sdk." << this << ", app " << m_appMode << ", " << Utils::getAppDataPath(); } BytezeroSdk::~BytezeroSdk() { } BytezeroSdk *BytezeroSdk::reset() { return this; } BytezeroSdk *BytezeroSdk::init(QQmlApplicationEngine *qmlEngine) { engine = qmlEngine; rootContext = engine->rootContext(); registerContexts(); registerModels(); return this; } BytezeroSdk *BytezeroSdk::loadLanguage(QTranslator *translator) { m_translator = translator; QLocale locale; QString languageName = m_config->appLanguage(); if(languageName == "") { languageName = locale.name(); } setLanguage(languageName); return this; } bool BytezeroSdk::is_online() { return false; } bool BytezeroSdk::device_online(const device_access_func &) { return false; } bool BytezeroSdk::db_online(const db_access_func &) { return false; } QString BytezeroSdk::version() const { return BYTEZERO_SDK_VERSION; } QString BytezeroSdk::title() const { return (m_appMode == 2) ? QObject::tr("bytezero") : QObject::tr("bytezero_test"); } QString BytezeroSdk::language() const { return m_language; } void BytezeroSdk::setLanguage(QString lang) { if(m_language == lang) return; if(m_translator) { QString langBaseName = ":/i18n/bytezero_"; if(lang == "zh_CN") { langBaseName += lang; } else { langBaseName += "en"; } if (m_translator->load(langBaseName)) { QGuiApplication::instance()->installTranslator(m_translator); engine->retranslate(); m_language = lang; } else { qWarning() << "BytezeroSdk::setLanguage - language file load failed." << langBaseName << ", " << QGuiApplication::applicationDirPath(); } } m_config->setAppLanguage(m_language); emit languageChanged(); } void BytezeroSdk::registerContexts() { // qDebug() << "BytezeroSdk::registerContexts - call."; if(0 == engine) { return; } rootContext->setContextProperty("bzSdk", this); } void BytezeroSdk::registerModels() { // qDebug() << "BytezeroSdk::registerModels - call."; }
24.089286
148
0.627131
alackfeng
d5eb0563dc8f258ba50d1435f0ea354f2d4a679c
1,441
cpp
C++
test/treehash.test.cpp
habara-k/ac-library
c48e576430c335d7037fa88e9fa5f6a61858e68a
[ "Unlicense" ]
null
null
null
test/treehash.test.cpp
habara-k/ac-library
c48e576430c335d7037fa88e9fa5f6a61858e68a
[ "Unlicense" ]
null
null
null
test/treehash.test.cpp
habara-k/ac-library
c48e576430c335d7037fa88e9fa5f6a61858e68a
[ "Unlicense" ]
null
null
null
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2821" #include <atcoder/treehash> #include <atcoder/dsu> #include <iostream> #include <map> using namespace atcoder; using namespace std; int main() { int n1, m1; cin >> n1 >> m1; vector<vector<int>> g1(n1); dsu uf(n1); for (int i = 0; i < m1; i++) { int u, v; cin >> u >> v; --u, --v; g1[u].emplace_back(v); g1[v].emplace_back(u); uf.merge(u, v); } int n2; cin >> n2; vector<vector<int>> g2(n2); for (int i = 0; i < n2-1; i++) { int u, v; cin >> u >> v; --u, --v; g2[u].emplace_back(v); g2[v].emplace_back(u); } vector<int> roots; for (int i = 0; i < n1; ++i) if (uf.leader(i) == i) roots.emplace_back(i); map<int,map<int,int>> ord; for (int i = 0; i < n1; ++i) { ord[uf.leader(i)][i] = -1; } map<int,vector<vector<int>>> g; for (auto& tp : ord) { int cnt = 0; for (auto& p : tp.second) { p.second = cnt++; } g[tp.first].resize(cnt); } for (int u = 0; u < n1; ++u) { int r = uf.leader(u); for (int v : g1[u]) { g[r][ord[r][u]].emplace_back(ord[r][v]); } } int ans = 0; auto hash = TreeHash{g2}.get(); for (auto &tp : g) { auto h = TreeHash{tp.second}.get(); ans += h == hash; } cout << ans << endl; }
23.241935
79
0.476058
habara-k
d5eccc5795916c0fa10943584aa1ab5dacc91fc7
1,568
inl
C++
SoftRP/TextureRenderTargetImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
SoftRP/TextureRenderTargetImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
SoftRP/TextureRenderTargetImpl.inl
loreStefani/SoftRP
2676145f74c734b272268820b1e1c503aa8ff765
[ "MIT" ]
null
null
null
#ifndef SOFTRP_TEXTURE_RENDER_TARGET_IMPL_INL_ #define SOFTRP_TEXTURE_RENDER_TARGET_IMPL_INL_ #include "TextureRenderTarget.h" namespace SoftRP { inline TextureRenderTarget::TextureRenderTarget(unsigned int width, unsigned int height) : m_texture{ width, height } {} inline TextureRenderTarget::TextureRenderTarget(const TextureRenderTarget& rt) : m_texture{ rt.m_texture } {} inline TextureRenderTarget& TextureRenderTarget::operator=(const TextureRenderTarget& rt) { m_texture = rt.m_texture; } inline TextureRenderTarget::TextureRenderTarget(TextureRenderTarget&& rt) : m_texture{ std::move(rt.m_texture) } {} inline TextureRenderTarget& TextureRenderTarget::operator=(TextureRenderTarget&& rt) { m_texture = std::move(rt.m_texture); } inline unsigned int TextureRenderTarget::width() const{ return m_texture.width(); } inline unsigned int TextureRenderTarget::height() const{ return m_texture.height(); } inline void TextureRenderTarget::resize(unsigned int width, unsigned int height) { m_texture.resize(width, height); } inline void TextureRenderTarget::set(unsigned int i, unsigned int j, Math::Vector4 value) { m_texture.set(i, j, value); } inline Math::Vector4 TextureRenderTarget::get(unsigned int i, unsigned int j) { return m_texture.get(i, j); } inline void TextureRenderTarget::clear(Math::Vector4 value) { m_texture.clear(value); } #ifdef SOFTRP_MULTI_THREAD inline void TextureRenderTarget::clear(Math::Vector4 value, ThreadPool& threadPool) { m_texture.clear(value, threadPool); } #endif } #endif
29.584906
116
0.772321
loreStefani
d5f481cf93f4874a412755e232e2e5838a5162ba
325
hpp
C++
libs/actor/src/impl/protocol.hpp
nousxiong/gce
722edb8c91efaf16375664d66134ecabb16e1447
[ "BSL-1.0" ]
118
2015-01-24T01:16:46.000Z
2022-03-09T07:31:21.000Z
libs/actor/src/impl/protocol.hpp
txwdyzcb/gce
722edb8c91efaf16375664d66134ecabb16e1447
[ "BSL-1.0" ]
1
2015-09-24T13:03:11.000Z
2016-12-24T04:00:59.000Z
libs/actor/src/impl/protocol.hpp
txwdyzcb/gce
722edb8c91efaf16375664d66134ecabb16e1447
[ "BSL-1.0" ]
30
2015-03-12T09:21:45.000Z
2021-12-15T01:55:08.000Z
#ifndef GCE_IMPL_PROTOCOL_HPP #define GCE_IMPL_PROTOCOL_HPP #include <config.hpp> namespace gce { namespace msg { struct header { header() : size_(0) , type_(match_nil) { } boost::uint32_t size_; match_t type_; }; } } GCE_PACK(gce::msg::header, (size_&sfix)(type_)); #endif /// GCE_IMPL_PROTOCOL_HPP
12.037037
48
0.683077
nousxiong
d5f839e43706d7103b864cb0da6a9a052939c505
2,071
cpp
C++
00-Starter/src/Player.cpp
BenjaminGonvers/SAE921-GRP4100-Box2D
0ea3ff05bdd21ebc96ec1661a8766b370b8fab1c
[ "MIT" ]
null
null
null
00-Starter/src/Player.cpp
BenjaminGonvers/SAE921-GRP4100-Box2D
0ea3ff05bdd21ebc96ec1661a8766b370b8fab1c
[ "MIT" ]
null
null
null
00-Starter/src/Player.cpp
BenjaminGonvers/SAE921-GRP4100-Box2D
0ea3ff05bdd21ebc96ec1661a8766b370b8fab1c
[ "MIT" ]
null
null
null
#include "Player.h" #include <SFML/Graphics.hpp> #include <Box2D/Box2D.h> #include <BodyFixtureType.h> Player::Player(b2World& world, sf::Texture* texture, sf::SoundBuffer* sound_buffer, sf::Vector2f& pos, b2Vec2 vertices[], const int& number_vertices, b2BodyType body_type) : PhysicalObject(world, texture, pos,vertices,number_vertices,body_type ) { b2FixtureDef new_fixture_def; b2Vec2 new_fixture_vertices[4]; b2PolygonShape dynamicBox_; new_fixture_vertices[0].x = vertices[3].x - 0.2f; new_fixture_vertices[0].y = vertices[3].y - 0.1f; new_fixture_vertices[1].x = vertices[2].x + 0.2f; new_fixture_vertices[1].y = vertices[2].y - 0.1f; new_fixture_vertices[2].x = vertices[2].x + 0.2f; new_fixture_vertices[2].y = vertices[2].y - 0.2f; new_fixture_vertices[3].x = vertices[3].x - 0.1f; new_fixture_vertices[3].y = vertices[3].y - 0.2f; dynamicBox_.Set(new_fixture_vertices, 4); new_fixture_def.shape= &dynamicBox_; new_fixture_def.isSensor = true; new_fixture_def.userData.pointer = static_cast<std::uintptr_t>(BodyFixtureType::PlayerFootSensor); footSensorFixture_ = body_->CreateFixture(&new_fixture_def); body_->SetFixedRotation(true); jump_sound_.setBuffer(*sound_buffer); } void Player::Check_Player_Action() { if (sf::Keyboard::isKeyPressed(sf::Keyboard::W)) { if (!w_keyboard_pressed_&&isGrounded()) { body_->ApplyLinearImpulse(b2Vec2(0, 15), body_->GetWorldCenter(), true); jump_sound_.play(); w_keyboard_pressed_ = true; } }else { w_keyboard_pressed_ = false; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { body_->ApplyForceToCenter(b2Vec2(30, 0), true); } if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { body_->ApplyForceToCenter(b2Vec2(-30, 0), true); } } bool Player::isGrounded() const { return footContactsCounter_ > 0; } void Player::startFootContact() { footContactsCounter_ += 1; } void Player::endFootContact() { footContactsCounter_ -= 1; } void Player::StartContact() { footContactsCounter_ += 1; } void Player::EndContact() { footContactsCounter_ -= 1; }
22.51087
173
0.725254
BenjaminGonvers
d5fe2d76ea09661d1b4d7fee826b86f5a9f6236c
4,858
cc
C++
public/c/tests/system/buffer_unittest.cc
niftich/mojo
cb29e37b254b43f432d70d1bf7661e1f9ef31577
[ "BSD-3-Clause" ]
1
2021-03-29T04:24:25.000Z
2021-03-29T04:24:25.000Z
public/c/tests/system/buffer_unittest.cc
niftich/mojo
cb29e37b254b43f432d70d1bf7661e1f9ef31577
[ "BSD-3-Clause" ]
null
null
null
public/c/tests/system/buffer_unittest.cc
niftich/mojo
cb29e37b254b43f432d70d1bf7661e1f9ef31577
[ "BSD-3-Clause" ]
null
null
null
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file tests the C buffer API (the functions declared in // mojo/public/c/include/mojo/system/buffer.h). #include <mojo/system/buffer.h> #include <mojo/result.h> #include <mojo/system/handle.h> #include "third_party/gtest/include/gtest/gtest.h" namespace { const MojoHandleRights kDefaultSharedBufferHandleRights = MOJO_HANDLE_RIGHT_DUPLICATE | MOJO_HANDLE_RIGHT_TRANSFER | MOJO_HANDLE_RIGHT_GET_OPTIONS | MOJO_HANDLE_RIGHT_SET_OPTIONS | MOJO_HANDLE_RIGHT_MAP_READABLE | MOJO_HANDLE_RIGHT_MAP_WRITABLE | MOJO_HANDLE_RIGHT_MAP_EXECUTABLE; // The only handle that's guaranteed to be invalid is |MOJO_HANDLE_INVALID|. // Tests that everything that takes a handle properly recognizes it. TEST(BufferTest, InvalidHandle) { MojoHandle out_handle = MOJO_HANDLE_INVALID; EXPECT_EQ( MOJO_RESULT_INVALID_ARGUMENT, MojoDuplicateBufferHandle(MOJO_HANDLE_INVALID, nullptr, &out_handle)); MojoBufferInformation buffer_info = {}; EXPECT_EQ( MOJO_RESULT_INVALID_ARGUMENT, MojoGetBufferInformation(MOJO_HANDLE_INVALID, &buffer_info, static_cast<uint32_t>(sizeof(buffer_info)))); void* write_pointer = nullptr; EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoMapBuffer(MOJO_HANDLE_INVALID, 0u, 1u, &write_pointer, MOJO_MAP_BUFFER_FLAG_NONE)); // This isn't an "invalid handle" test, but we'll throw it in here anyway // (since it involves a look-up). EXPECT_EQ(MOJO_RESULT_INVALID_ARGUMENT, MojoUnmapBuffer(nullptr)); } TEST(BufferTest, Basic) { // Create a shared buffer (|h0|). MojoHandle h0 = MOJO_HANDLE_INVALID; EXPECT_EQ(MOJO_RESULT_OK, MojoCreateSharedBuffer(nullptr, 100, &h0)); EXPECT_NE(h0, MOJO_HANDLE_INVALID); // The handle should have the correct rights. MojoHandleRights rights = MOJO_HANDLE_RIGHT_NONE; EXPECT_EQ(MOJO_RESULT_OK, MojoGetRights(h0, &rights)); EXPECT_EQ(kDefaultSharedBufferHandleRights, rights); // Check information about the buffer from |h0|. MojoBufferInformation info = {}; static const uint32_t kInfoSize = static_cast<uint32_t>(sizeof(info)); EXPECT_EQ(MOJO_RESULT_OK, MojoGetBufferInformation(h0, &info, kInfoSize)); EXPECT_EQ(kInfoSize, info.struct_size); EXPECT_EQ(MOJO_BUFFER_INFORMATION_FLAG_NONE, info.flags); EXPECT_EQ(100u, info.num_bytes); // Map everything. void* pointer = nullptr; EXPECT_EQ(MOJO_RESULT_OK, MojoMapBuffer(h0, 0, 100, &pointer, MOJO_MAP_BUFFER_FLAG_NONE)); ASSERT_TRUE(pointer); static_cast<char*>(pointer)[50] = 'x'; // Duplicate |h0| to |h1|. MojoHandle h1 = MOJO_HANDLE_INVALID; EXPECT_EQ(MOJO_RESULT_OK, MojoDuplicateHandle(h0, &h1)); EXPECT_NE(h1, MOJO_HANDLE_INVALID); EXPECT_NE(h1, h0); // The new handle should have the correct rights. rights = MOJO_HANDLE_RIGHT_NONE; EXPECT_EQ(MOJO_RESULT_OK, MojoGetRights(h1, &rights)); EXPECT_EQ(kDefaultSharedBufferHandleRights, rights); // Check information about the buffer from |h1|. info = MojoBufferInformation(); EXPECT_EQ(MOJO_RESULT_OK, MojoGetBufferInformation(h1, &info, kInfoSize)); EXPECT_EQ(kInfoSize, info.struct_size); EXPECT_EQ(MOJO_BUFFER_INFORMATION_FLAG_NONE, info.flags); EXPECT_EQ(100u, info.num_bytes); // Close |h0|. EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h0)); // The mapping should still be good. static_cast<char*>(pointer)[51] = 'y'; // Unmap it. EXPECT_EQ(MOJO_RESULT_OK, MojoUnmapBuffer(pointer)); // Map half of |h1|. pointer = nullptr; EXPECT_EQ(MOJO_RESULT_OK, MojoMapBuffer(h1, 50, 50, &pointer, MOJO_MAP_BUFFER_FLAG_NONE)); ASSERT_TRUE(pointer); // It should have what we wrote. EXPECT_EQ('x', static_cast<char*>(pointer)[0]); EXPECT_EQ('y', static_cast<char*>(pointer)[1]); // Unmap it. EXPECT_EQ(MOJO_RESULT_OK, MojoUnmapBuffer(pointer)); // Test duplication with reduced rights. MojoHandle h2 = MOJO_HANDLE_INVALID; EXPECT_EQ(MOJO_RESULT_OK, MojoDuplicateHandleWithReducedRights( h1, MOJO_HANDLE_RIGHT_DUPLICATE, &h2)); EXPECT_NE(h2, MOJO_HANDLE_INVALID); EXPECT_NE(h2, h1); // |h2| should have the correct rights. rights = MOJO_HANDLE_RIGHT_NONE; EXPECT_EQ(MOJO_RESULT_OK, MojoGetRights(h2, &rights)); EXPECT_EQ(kDefaultSharedBufferHandleRights & ~MOJO_HANDLE_RIGHT_DUPLICATE, rights); // Trying to duplicate |h2| should fail. MojoHandle h3 = MOJO_HANDLE_INVALID; EXPECT_EQ(MOJO_RESULT_PERMISSION_DENIED, MojoDuplicateHandle(h2, &h3)); EXPECT_EQ(MOJO_HANDLE_INVALID, h3); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h1)); EXPECT_EQ(MOJO_RESULT_OK, MojoClose(h2)); } // TODO(vtl): Add multi-threaded tests. } // namespace
36.526316
76
0.742487
niftich
d5ff3c6462aa3185696e70f9629ae1d1810870c7
4,468
hpp
C++
openscenario/openscenario_interpreter/include/openscenario_interpreter/syntax/condition_edge.hpp
WJaworskiRobotec/scenario_simulator_v2
c23497ac8716dcefef20d4b5a4ff1185e01f48e6
[ "Apache-2.0" ]
45
2021-04-12T22:43:25.000Z
2022-02-27T23:57:53.000Z
openscenario/openscenario_interpreter/include/openscenario_interpreter/syntax/condition_edge.hpp
WJaworskiRobotec/scenario_simulator_v2
c23497ac8716dcefef20d4b5a4ff1185e01f48e6
[ "Apache-2.0" ]
140
2021-04-13T04:28:19.000Z
2022-03-30T12:44:32.000Z
openscenario/openscenario_interpreter/include/openscenario_interpreter/syntax/condition_edge.hpp
WJaworskiRobotec/scenario_simulator_v2
c23497ac8716dcefef20d4b5a4ff1185e01f48e6
[ "Apache-2.0" ]
13
2021-05-22T02:24:49.000Z
2022-03-25T05:16:31.000Z
// Copyright 2015-2020 Tier IV, Inc. 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 OPENSCENARIO_INTERPRETER__SYNTAX__CONDITION_EDGE_HPP_ #define OPENSCENARIO_INTERPRETER__SYNTAX__CONDITION_EDGE_HPP_ #include <iostream> namespace openscenario_interpreter { inline namespace syntax { /* ---- ConditionEdge ---------------------------------------------------------- * * <xsd:simpleType name="ConditionEdge"> * <xsd:union> * <xsd:simpleType> * <xsd:restriction base="xsd:string"> * <xsd:enumeration value="rising"/> * <xsd:enumeration value="falling"/> * <xsd:enumeration value="risingOrFalling"/> * <xsd:enumeration value="none"/> * </xsd:restriction> * </xsd:simpleType> * <xsd:simpleType> * <xsd:restriction base="parameter"/> * </xsd:simpleType> * </xsd:union> * </xsd:simpleType> * * Tier IV Extension: * - Add enumeration <xsd.enumeration value="sticky"/> * * -------------------------------------------------------------------------- */ struct ConditionEdge { enum value_type { /* ---- NOTE --------------------------------------------------------------- * * A condition defined with a 'none' edge shall return true at discrete * time t if its logical expression is true at discrete time t. * * Default constructor select this. * * ---------------------------------------------------------------------- */ none, /* ---- NOTE --------------------------------------------------------------- * * A condition defined with a rising edge shall return true at discrete * time t if its logical expression is true at discrete time t and its * logical expression was false at discrete time t-ts, where ts is the * simulation sampling time. * * ---------------------------------------------------------------------- */ rising, /* ---- NOTE --------------------------------------------------------------- * * A condition defined with a falling edge shall return true at discrete * time t if its logical expression is false at discrete time t and its * logical expression was true at discrete time t-ts, where ts is the * simulation sampling time. * * ---------------------------------------------------------------------- */ falling, /* ---- NOTE --------------------------------------------------------------- * * A condition defined with a 'risingOrFalling' edge shall return true at * discrete time t if its logical expression is true at discrete time t * and its logical expression was false at discrete time t-ts OR if its * logical expression is false at discrete time t and its logical * expression was true at discrete time t-ts. ts is the simulation * sampling time. * * ---------------------------------------------------------------------- */ risingOrFalling, /* ---- NOTE --------------------------------------------------------------- * * A condition defined by a 'sticky' edge returns true at discrete time * t + k (0 < k) if its logical expression evaluates to true at discrete * time t. This edge is provided for simply defining assertions such as * "Did the Ego car pass over checkpoint X? * * This is NOT an OpenSCENARIO 1.0.0 standard feature (Tier IV extension). * * ---------------------------------------------------------------------- */ sticky, } value; explicit ConditionEdge() = default; operator value_type() const noexcept { return value; } }; auto operator>>(std::istream & is, ConditionEdge &) -> std::istream &; auto operator<<(std::ostream & os, const ConditionEdge &) -> std::ostream &; } // namespace syntax } // namespace openscenario_interpreter #endif // OPENSCENARIO_INTERPRETER__SYNTAX__CONDITION_EDGE_HPP_
38.517241
80
0.539391
WJaworskiRobotec
9102488853d9d5e6e2efa2095887ee0bfdb10f5a
9,764
cpp
C++
VoxViz/VoxVizCore/DataSetReader.cpp
apecoraro/VoxVizThesis
43aeb666cc9f5005d9ec5b81acd4cc38aae0e0fd
[ "MIT" ]
3
2017-11-13T09:52:06.000Z
2019-06-27T16:57:58.000Z
VoxViz/VoxVizCore/DataSetReader.cpp
apecoraro/VoxVizThesis
43aeb666cc9f5005d9ec5b81acd4cc38aae0e0fd
[ "MIT" ]
null
null
null
VoxViz/VoxVizCore/DataSetReader.cpp
apecoraro/VoxVizThesis
43aeb666cc9f5005d9ec5b81acd4cc38aae0e0fd
[ "MIT" ]
4
2018-03-27T17:08:02.000Z
2021-01-28T06:36:44.000Z
#include "VoxVizCore/DataSetReader.h" #include "VoxVizCore/PVMReader.h" #include "VoxVizCore/SmartPtr.h" #include <QtCore/QFileInfo> #include <QtCore/QDir> #include <fstream> #include <sstream> #include <iostream> using namespace vox; static const char * const PATH_SEPARATORS = "/\\"; static unsigned int PATH_SEPARATORS_LEN = 2; std::string DataSetReader::GetFilePath(const std::string& fileName) { std::string::size_type slash = fileName.find_last_of(PATH_SEPARATORS); if (slash==std::string::npos) return std::string(); else return std::string(fileName, 0, slash); } std::string DataSetReader::GetFileExtension(const std::string& fileName) { static const char * const PATH_SEPARATORS = "/\\"; std::string::size_type dot = fileName.find_last_of('.'); std::string::size_type slash = fileName.find_last_of(PATH_SEPARATORS); if (dot==std::string::npos || (slash!=std::string::npos && dot<slash)) return std::string(""); return std::string(fileName.begin()+dot+1, fileName.end()); } VolumeDataSet* DataSetReader::readVolumeDataFile(const std::string& inputFile) { std::string ext = GetFileExtension(inputFile); if(ext == "pvm") { return PVMReader::instance().readVolumeData(inputFile); } else if(ext == "gvx" || ext == "gvp") { return new VolumeDataSet(inputFile); } else { std::ifstream inputStream; inputStream.open(inputFile.c_str()); if(inputStream.is_open() != true) return NULL; std::string text; inputStream >> text; if(text != "VOXEL_HEADER") return NULL; QVector3D pos; QQuaternion orient; double scale = 1.0; size_t dimX=0, dimY=0, dimZ=0; bool typeIsScalars = false; bool formatIsUByte = false; while(inputStream.eof() != true) { inputStream >> text; if(text == "POSITION") { double x, y, z; inputStream >> x >> y >> z; if(inputStream.fail()) break; pos.setX(x); pos.setY(y); pos.setZ(z); } else if(text == "ORIENTATION") { double x, y, z, angle; inputStream >> x >> y >> z >> angle; if(inputStream.fail()) break; orient = QQuaternion::fromAxisAndAngle(x, y, z, angle); } else if(text == "SCALE") { inputStream >> scale; if(inputStream.fail()) break; } else if(text == "DIMENSIONS") { inputStream >> dimX >> dimY >> dimZ; if(inputStream.fail()) break; } else if(text == "TYPE") { inputStream >> text; if(inputStream.fail()) break; typeIsScalars = (text == "SCALARS"); } else if(text == "FORMAT") { inputStream >> text; if(inputStream.fail()) break; formatIsUByte = (text == "GL_RGBA8" || text == "GL_R8"); } else if(text == "VOXEL_HEADER_END") { break; } } if(dimX == 0 || dimY == 0 || dimZ == 0) return NULL; SmartPtr<VolumeDataSet> spData = new VolumeDataSet(inputFile, pos, orient, scale, scale, scale, dimX, dimY, dimZ); inputStream >> text; if(text == "VOXEL_SCALARS") { spData->initVoxels(); for(size_t z = 0; z < dimZ; ++z) { std::string voxSlice; inputStream >> voxSlice; if(voxSlice != "VOXEL_SLICE") return NULL; for(size_t y = 0; y < dimY; ++y) { for(size_t x = 0; x < dimX; ++x) { float value; inputStream >> value; if(inputStream.fail()) return NULL; spData->value(x, y, z) = static_cast<unsigned char>(value * 255.0f); } } } } else { size_t voxelCount = dimX * dimY * dimZ; if(text == "VOXEL_IMAGE_FILE") { std::string extBinaryFile = inputFile + ".voxb"; //inputStream >> extBinaryFile; std::ifstream binaryInputStream; binaryInputStream.open(extBinaryFile, std::ios_base::in | std::ios_base::binary); if(binaryInputStream.is_open() == false) return NULL; Vec4f* pVoxelColors = new Vec4f[voxelCount]; binaryInputStream.read((char*)pVoxelColors, sizeof(Vec4f) * voxelCount); spData->setColors(pVoxelColors); } else if(text == "VOXEL_SUB_IMAGE_FILES") { QFileInfo fileInfo(QString(inputFile.c_str())); QDir baseDir = fileInfo.dir(); while(inputStream.eof() != true) { std::string subImageText; inputStream >> subImageText; if(subImageText != "VOXEL_SUB_IMAGE_FILE") break; unsigned int rangeStartX, rangeStartY, rangeStartZ; inputStream >> rangeStartX; inputStream >> rangeStartY; inputStream >> rangeStartZ; if(inputStream.fail()) return NULL; unsigned int rangeEndX, rangeEndY, rangeEndZ; inputStream >> rangeEndX; inputStream >> rangeEndY; inputStream >> rangeEndZ; if(inputStream.fail()) return NULL; //skip the space character inputStream.seekg(1, std::ios_base::cur); std::stringbuf extBinaryFile; inputStream.get(extBinaryFile); if(inputStream.fail()) return NULL; std::stringstream extBinaryFilePath; extBinaryFilePath << baseDir.absolutePath().toAscii().data() << "/" << extBinaryFile.str(); std::cout << "Loading sub-image: " << extBinaryFilePath.str() << std::endl; std::ifstream binaryInputStream; binaryInputStream.open(extBinaryFilePath.str(), std::ios_base::in | std::ios_base::binary); if(binaryInputStream.is_open() == false) return NULL; VolumeDataSet::SubVolume::Format format = VolumeDataSet::SubVolume::FORMAT_UBYTE_RGBA; if(formatIsUByte == true) { if(typeIsScalars == true) format = VolumeDataSet::SubVolume::FORMAT_UBYTE_SCALARS; } else format = VolumeDataSet::SubVolume::FORMAT_FLOAT_RGBA; VolumeDataSet::SubVolume subVolume(rangeStartX, rangeStartY, rangeStartZ, rangeEndX, rangeEndY, rangeEndZ, format); int ubyteFormat; binaryInputStream.read((char*)&ubyteFormat, sizeof(int)); if((ubyteFormat == 0 && formatIsUByte) || (ubyteFormat != 0 && formatIsUByte == false)) return NULL; unsigned int dataSize; binaryInputStream.read((char*)&dataSize, sizeof(unsigned int)); if(dataSize != subVolume.dataSize()) return NULL; binaryInputStream.read((char*)subVolume.data(), subVolume.dataSize()); spData->addSubVolume(subVolume); } } else { Vec4ub* pVoxelColors = new Vec4ub[voxelCount]; spData->setColors(pVoxelColors); for(size_t z = 0; z < dimZ; ++z) { std::string voxSlice; inputStream >> voxSlice; if(voxSlice != "VOXEL_SLICE") return NULL; for(size_t y = 0; y < dimY; ++y) { for(size_t x = 0; x < dimX; ++x) { float r, g, b, a; inputStream >> r >> g >> b >> a; if(inputStream.fail()) return NULL; spData->setColor(x, y, z, r, g, b, a); } } } } } return spData.release(); } }
35.376812
107
0.436194
apecoraro
9104150482f82dc3178dbffb9ebbccef66fe0881
153
hpp
C++
scenes/sphere_animation.hpp
AdrienVannson/3D-Renderer
78148e88b9ab91ccaea0f883a746ee93cac5d767
[ "MIT" ]
null
null
null
scenes/sphere_animation.hpp
AdrienVannson/3D-Renderer
78148e88b9ab91ccaea0f883a746ee93cac5d767
[ "MIT" ]
null
null
null
scenes/sphere_animation.hpp
AdrienVannson/3D-Renderer
78148e88b9ab91ccaea0f883a746ee93cac5d767
[ "MIT" ]
1
2021-03-18T08:05:35.000Z
2021-03-18T08:05:35.000Z
#ifndef SPHERE_ANIMATION_HPP #define SPHERE_ANIMATION_HPP #include "renderer/Scene.hpp" void renderSphereAnimation (); #endif // SPHERE_ANIMATION_HPP
17
30
0.816993
AdrienVannson
9106d61feff462942f2afc9fdfb8f8e20c1cbd37
6,055
cc
C++
dali/operators/reader/numpy_reader_gpu_op.cc
awolant/DALI
ace3e0bee44b7b10cdf7255ec02e143646c68ce1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
dali/operators/reader/numpy_reader_gpu_op.cc
awolant/DALI
ace3e0bee44b7b10cdf7255ec02e143646c68ce1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
dali/operators/reader/numpy_reader_gpu_op.cc
awolant/DALI
ace3e0bee44b7b10cdf7255ec02e143646c68ce1
[ "ECL-2.0", "Apache-2.0" ]
null
null
null
// Copyright (c) 2020-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // 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 <memory> #include <string> #include "dali/core/mm/memory.h" #include "dali/core/mm/malloc_resource.h" #include "dali/operators/reader/numpy_reader_gpu_op.h" #include "dali/pipeline/data/views.h" namespace dali { namespace { /** * @brief Allocates memory that's suitable for use with GDS / CUfile * * Currently (CUDA 11.4) GPUDirect Storage can work only with memory allocated with cudaMalloc and * cuMemAlloc. Since DALI is transitioning to CUDA Virtual Memory Management for memory * allocation, we need a special allocator that's compatible with GDS. */ std::shared_ptr<uint8_t> gds_alloc(size_t bytes) { uint8_t *ptr = nullptr; CUDA_CALL(cudaMalloc(&ptr, bytes)); return std::shared_ptr<uint8_t>(ptr, [](void *mem) { CUDA_DTOR_CALL(cudaFree(mem)); }); } } // namespace NumpyReaderGPU::NumpyReaderGPU(const OpSpec& spec) : NumpyReader<GPUBackend, NumpyFileWrapperGPU>(spec), thread_pool_(num_threads_, spec.GetArgument<int>("device_id"), false), sg_(1 << 18, spec.GetArgument<int>("max_batch_size")) { prefetched_batch_tensors_.resize(prefetch_queue_depth_); for (auto &t : prefetched_batch_tensors_) t.set_alloc_func(gds_alloc); // set a device guard DeviceGuard g(device_id_); // init loader bool shuffle_after_epoch = spec.GetArgument<bool>("shuffle_after_epoch"); loader_ = InitLoader<NumpyLoaderGPU>(spec, std::vector<string>(), shuffle_after_epoch); kmgr_transpose_.Resize<TransposeKernel>(1, 1); } void NumpyReaderGPU::Prefetch() { // We actually prepare the next batch DomainTimeRange tr("[DALI][NumpyReaderGPU] Prefetch #" + to_string(curr_batch_producer_), DomainTimeRange::kRed); DataReader<GPUBackend, NumpyFileWrapperGPU>::Prefetch(); auto &curr_batch = prefetched_batch_queue_[curr_batch_producer_]; auto &curr_tensor_list = prefetched_batch_tensors_[curr_batch_producer_]; // get shapes for (size_t data_idx = 0; data_idx < curr_batch.size(); ++data_idx) { thread_pool_.AddWork([&curr_batch, data_idx](int tid) { curr_batch[data_idx]->read_meta_f(); }); } thread_pool_.RunAll(); // resize the current batch auto ref_type = curr_batch[0]->get_type(); auto ref_shape = curr_batch[0]->get_shape(); TensorListShape<> tmp_shapes(curr_batch.size(), ref_shape.sample_dim()); for (size_t data_idx = 0; data_idx < curr_batch.size(); ++data_idx) { auto &sample = curr_batch[data_idx]; DALI_ENFORCE(ref_type == sample->get_type(), make_string("Inconsistent data! " "The data produced by the reader has inconsistent type:\n" "type of [", data_idx, "] is ", sample->get_type(), " whereas\n" "type of [0] is ", ref_type)); DALI_ENFORCE( ref_shape.sample_dim() == sample->get_shape().sample_dim(), make_string( "Inconsistent data! The data produced by the reader has inconsistent dimensionality:\n" "[", data_idx, "] has ", sample->get_shape().sample_dim(), " dimensions whereas\n" "[0] has ", ref_shape.sample_dim(), " dimensions.")); tmp_shapes.set_tensor_shape(data_idx, sample->get_shape()); } // Check if the curr_tensor_list has the proper allocator. // Some buffers allocated with a different method can slip in because output buffers // are swapped with ones in prefetched_batch_tensors_ when all samples can be returned // without any changes. // See the line `std::swap(output, prefetched_batch_tensors_[curr_batch_consumer_]);` // in numpy_reader_gpu_op_impl.cu if (!dynamic_cast<mm::cuda_malloc_memory_resource*>(mm::GetDefaultDeviceResource())) { auto *tgt = curr_tensor_list.alloc_func().target<shared_ptr<uint8_t>(*)(size_t)>(); if (!tgt || *tgt != &gds_alloc) { curr_tensor_list.Reset(); curr_tensor_list.set_alloc_func(gds_alloc); } } curr_tensor_list.Resize(tmp_shapes, ref_type); size_t chunk_size = static_cast<size_t>( \ div_ceil(static_cast<uint64_t>(curr_tensor_list.nbytes()), static_cast<uint64_t>(thread_pool_.NumThreads()))); // read the data for (size_t data_idx = 0; data_idx < curr_tensor_list.ntensor(); ++data_idx) { curr_tensor_list.SetMeta(data_idx, curr_batch[data_idx]->get_meta()); size_t image_bytes = static_cast<size_t>(volume(curr_tensor_list.tensor_shape(data_idx)) * curr_tensor_list.type_info().size()); uint8_t* dst_ptr = static_cast<uint8_t*>(curr_tensor_list.raw_mutable_tensor(data_idx)); size_t file_offset = 0; while (image_bytes > 0) { size_t read_bytes = std::min(image_bytes, chunk_size); void* buffer = static_cast<void*>(dst_ptr); thread_pool_.AddWork([&curr_batch, data_idx, buffer, file_offset, read_bytes](int tid) { curr_batch[data_idx]->read_sample_f(buffer, file_offset, read_bytes); }); // update addresses dst_ptr += read_bytes; file_offset += read_bytes; image_bytes -= read_bytes; } } thread_pool_.RunAll(); for (size_t data_idx = 0; data_idx < curr_tensor_list.ntensor(); ++data_idx) { curr_batch[data_idx]->file_stream->Close(); } } DALI_REGISTER_OPERATOR(readers__Numpy, NumpyReaderGPU, GPU); // Deprecated alias DALI_REGISTER_OPERATOR(NumpyReader, NumpyReaderGPU, GPU); } // namespace dali
39.575163
99
0.69711
awolant