blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
0a9915eaaa6f239ab24d83b62e3ac90d19f057a7
c279be60d136a6e54087c98e17cb9f5c30c2169c
/shootemup_1_new_test/include/vector2d.h
309a42e8617787cb37a60d3e8d24204bd9d1152c
[]
no_license
flickenmaste/shootemup_2
3f41c8629fae984cd58786a175ca8f3f66aa8c3e
9b4bcd701bc2a74ce7eaf63216543f73510e4713
refs/heads/master
2021-01-02T22:17:03.166217
2013-10-15T21:22:42
2013-10-15T21:22:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,099
h
//class vector 2d //Last Edit 10/8/2013 //Will Gilstrap ///////////////////// #ifndef _VECTOR2D_H_ #define _VECTOR2D_H_ class vector2d { public: vector2d() {x = 0; y = 0;} ~vector2d(){} float GetX() {return x;} float GetY() {return y;} void SetX(int nextX) {x = nextX;} void SetY(int nextY) {y = nextY;} vector2d operator+ (const vector2d &w) { vector2d temp; temp.x = this->x + w.x; temp.y = this->x + w.y; return temp; } vector2d operator+ (float s) //scalar add { vector2d temp; temp.x = this->x + s; temp.y = this->y + s; return temp; } vector2d operator- (const vector2d &w) { vector2d temp; temp.x = this->x - w.x; temp.y = this->x - w.y; return temp; } vector2d operator- (float s) //scalar sub { vector2d temp; temp.x = this->x - s; temp.y = this->y - s; return temp; } vector2d operator* (float s) //scalar multi { vector2d temp; temp.x = this->x * s; temp.y = this->y * s; return temp; } float dotProduct(vector2d &a, vector2d &b) { return (a.x * b.x + a.y * b.y); } private: float x; float y; }; #endif
[ "justinl@aie.edu.au" ]
justinl@aie.edu.au
c4500ddbc7afd08e1612279551db484cce5914ec
3643cefb07c523c1c3025405e199b3e07d23950f
/PROX/APPLICATIONS/PROX_GUI/include/prox_gui_widget.h
b9394b0da2cedb186891d189bdbf95e2ca6b7c2a
[ "MIT" ]
permissive
erleben/matchstick
cceaac24c19915579965d909e01d80bed3b3d470
1cfdc32b95437bbb0063ded391c34c9ee9b9583b
refs/heads/master
2021-07-08T04:57:29.669086
2020-07-30T06:07:37
2020-07-30T06:07:37
162,964,654
3
0
null
null
null
null
UTF-8
C++
false
false
915
h
#ifndef PROX_GUI_WIDGET_H #define PROX_GUI_WIDGET_H #include <QTimer> #include <QGLWidget> #include <QApplication> #include <QMouseEvent> namespace prox_gui { class Widget : public QGLWidget { Q_OBJECT private: //QOpenGLContext m__context; // QWindow way QTimer m_timer; public: Widget( QGLFormat const & format, QWidget *parent = 0); ~Widget(); QSize minimumSizeHint() const; QSize sizeHint() const; public slots: void animate(); //signals: protected: void initializeGL(); void paintGL(); void resizeGL(int width, int height); void mousePressEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void keyPressEvent(QKeyEvent *e); public: void save_screen(QString const & filename); }; }// namespace prox_gui // PROX_GUI_WIDGET_H #endif
[ "kenny@di.ku.dk" ]
kenny@di.ku.dk
dc8425f5cd3113122a665aa42842dfe1ab5f7c29
30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a
/contest/1542576598.cpp
28ff27d848cd201cebb7caa1e58a05de5fcc4c64
[]
no_license
thegamer1907/Code_Analysis
0a2bb97a9fb5faf01d983c223d9715eb419b7519
48079e399321b585efc8a2c6a84c25e2e7a22a61
refs/heads/master
2020-05-27T01:20:55.921937
2019-11-20T11:15:11
2019-11-20T11:15:11
188,403,594
2
1
null
null
null
null
UTF-8
C++
false
false
2,724
cpp
#include <iostream> #include <vector> #include <string.h> #include <stack> #include <queue> #include <algorithm> #include <climits> #include <cmath> #include <map> #include <set> #include <assert.h> #include <sstream> #include <bitset> #define REP(i,n) for(ll i=0;i<(n);i++) #define MOD 1000000007 #define int long long #ifdef int const long long INF = LLONG_MAX / 10; #else const int INF = 1010101010; #endif using namespace std; typedef long long ll; typedef vector<vector<ll>> mat; typedef pair<int, int> P; //typedef pair<double, double> P; int n, k; int bit; map<int, int> cnt; signed main() { cin >> n >> k; REP(i,n) { int mask = 0; REP(j,k) { cin >> bit; if (bit == 1) { mask += 1 << j; } } cnt[mask]++; } /* for (auto it=cnt.begin(); it!=cnt.end(); it++) { cout << it->first << " : " << it->second << endl; } */ if (cnt[0] > 0) { cout << "YES" << endl; return 0; } cnt.erase(0); REP(i,k) { if (cnt[1<<i] > 0) { //cout << (1<<i) << endl; //cout << "YYYYYYYYYY" << endl; for (auto it=cnt.begin(); it!=cnt.end(); it++) { if ((~(it->first >> i) & 1)/* && it->first != 0*/) { //cout << it->first << endl; //cout << "AAA" << endl; cout << "YES" << endl; return 0; } } } if (cnt[1<<i] == 0) cnt.erase(1<<i); } for(auto it=cnt.begin(); it!=cnt.end(); it++) { if (__builtin_popcount(it->first) == 2) { //cout << "OOOOOOOOOOO" << endl; //cout << "it->first = " << it->first << endl; vector<int> idx(2); idx.clear(); REP(i,k) { if ((it->first >> i) & 1) { idx.push_back(i); } } cnt[it->first]--; for (auto it2=cnt.begin(); it2!=cnt.end(); it2++) { bool ok = true; REP(i,2) { if ((it2->first >> idx[i]) & 1) { ok = false; } } if (ok && cnt[it2->first] > 0) { cout << "YES" << endl; //cout << "BBBBB" << endl; return 0; } } cnt[it->first]++; } } cout << "NO" << endl; }
[ "harshitagar1907@gmail.com" ]
harshitagar1907@gmail.com
4da9ba48cc3e857ad66bc8fb9fe79dd0ca50b1dc
c4322cfd7ddaa70db9a0ec193efd3e0b057ceddf
/src/Nodo.cpp
8e9df81b35f140bea7f26020bb525162977f41a4
[]
no_license
DannZero/Pila
17c68204a28d4aa0a7e3dfd505380451160974b7
f685434b44d268a2be153a73f9cf786c81783bb2
refs/heads/master
2020-04-14T19:02:48.565987
2016-09-14T15:48:15
2016-09-14T15:48:15
68,173,501
0
0
null
2016-09-14T04:33:45
2016-09-14T04:33:43
C++
UTF-8
C++
false
false
412
cpp
/** * Autor: Daniel Ponce de León Súchil */ #include "Nodo.h" Nodo::Nodo(int dato) { this->dato = dato; this->next = NULL; } Nodo::Nodo(int dato, Nodo *next) { this->dato = dato; this->next = next; } int Nodo::getDato() { return this->dato; } Nodo *Nodo::getNext() { return this->next; } void Nodo::setDato(int dato) { this->dato = dato; } void Nodo::setNext(Nodo *next) { this->next = next; }
[ "dannzero@gmail.com" ]
dannzero@gmail.com
8fc567eef994b071afdbdfc39acb8da667fc2146
63ea75c1cd144db8434e7b84ab5b3d1baa986ac7
/run/tutorials/incompressible/pisoFoam/les/pitzDaily/0.006/k
76a9b66dd2e384f54e91f24e74c44e0705d07680
[]
no_license
houkensjtu/interFOAM
86a3f88891db4d47eb6ac033515b51bf2a63e069
8040064d075718d4259a207a30c216974bf8a8af
refs/heads/master
2016-09-06T15:02:08.625024
2013-03-11T12:40:10
2013-03-11T12:40:10
8,702,790
1
1
null
null
null
null
UTF-8
C++
false
false
137,168
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 2.1.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.006"; object k; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 2 -2 0 0 0 0]; internalField nonuniform List<scalar> 12225 ( 9.29786 9.23063 6.91161 4.86487 3.81592 3.26295 2.91509 2.65747 2.42324 2.27443 2.13419 2.08929 1.96948 1.95393 1.86265 1.87445 1.81392 1.92092 2.4658 5.09181 5.39546 5.08938 4.50648 4.03838 3.64927 3.31776 3.02658 2.80565 2.59247 2.45804 2.30487 2.19917 2.10182 1.99101 1.93806 1.89019 0.198899 1.30826 1.9515 2.47286 2.58645 2.54719 2.44101 2.32425 2.25142 2.12737 2.01456 1.87297 1.80424 1.67978 1.62528 1.51179 1.43907 1.38138 0.0100485 0.162763 0.387664 0.608868 0.796439 0.875002 0.884443 0.898122 0.953487 0.97635 0.975483 0.963857 0.951664 0.91772 0.867224 0.824364 0.745085 0.712352 0.000423892 0.013499 0.0426665 0.0825283 0.148554 0.185862 0.194083 0.202898 0.227293 0.256566 0.27728 0.288332 0.294693 0.293841 0.291078 0.283798 0.251982 0.230739 3.99341e-05 0.00078316 0.00276417 0.00628968 0.0159538 0.0256123 0.0282663 0.0296575 0.0326614 0.0348101 0.038589 0.0467894 0.0597944 0.0695168 0.0727917 0.0718358 0.0640427 0.0576514 2.54511e-05 7.20937e-05 0.000191623 0.000416613 0.00114516 0.00263196 0.00317055 0.00323263 0.00316268 0.00288215 0.00288312 0.00350812 0.00690262 0.0111116 0.0123159 0.0121465 0.0107443 0.00878215 2.84888e-05 3.65511e-05 4.12051e-05 5.2926e-05 0.000108922 0.000320792 0.000436209 0.000443714 0.000412494 0.000332184 0.000318696 0.000362202 0.000692068 0.00136645 0.00162395 0.00162225 0.00142535 0.00115194 2.29772e-05 3.50384e-05 3.53032e-05 3.3819e-05 3.70638e-05 5.94245e-05 9.90635e-05 0.000123518 0.000130528 0.000131381 0.000133329 0.000140354 0.000168501 0.000261833 0.000322855 0.000331487 0.000312541 0.000295402 4.23821e-05 4.56168e-05 4.35044e-05 4.28199e-05 4.47107e-05 4.8042e-05 4.85628e-05 4.77828e-05 4.82772e-05 5.41141e-05 7.72915e-05 0.000129157 0.000167201 0.000187097 0.000196578 0.000197251 0.00018339 0.000146033 2.69855e-05 2.94446e-05 2.85374e-05 2.93497e-05 3.45863e-05 3.66842e-05 3.58901e-05 3.2929e-05 3.26148e-05 3.34124e-05 3.60025e-05 4.25044e-05 6.40736e-05 9.39304e-05 0.000111595 0.000114983 0.000112811 0.000114665 2.26255e-05 2.28642e-05 2.43876e-05 3.23086e-05 4.28029e-05 4.40169e-05 4.179e-05 3.92837e-05 3.92741e-05 3.8928e-05 3.80076e-05 3.90882e-05 4.9192e-05 6.65228e-05 7.44979e-05 7.6916e-05 7.73434e-05 7.45089e-05 2.33912e-05 2.59127e-05 2.57728e-05 2.59495e-05 2.71187e-05 3.05193e-05 3.27326e-05 3.29436e-05 3.21026e-05 3.10324e-05 3.1177e-05 3.35231e-05 3.79601e-05 4.03673e-05 4.1811e-05 4.37861e-05 4.41144e-05 4.50048e-05 2.24422e-05 2.23482e-05 2.36905e-05 2.52256e-05 2.57958e-05 2.63468e-05 2.90496e-05 3.91573e-05 4.51403e-05 4.57584e-05 4.45098e-05 3.87564e-05 3.26471e-05 2.94938e-05 2.81068e-05 2.78953e-05 2.89667e-05 3.25382e-05 2.19043e-05 2.90056e-05 3.25744e-05 3.27095e-05 3.08644e-05 2.83887e-05 2.7367e-05 2.70555e-05 2.71357e-05 2.79075e-05 3.05673e-05 3.22359e-05 3.275e-05 3.28083e-05 3.26607e-05 3.28389e-05 3.42985e-05 4.26043e-05 2.13584e-05 2.75201e-05 3.02829e-05 2.97221e-05 2.70634e-05 2.50915e-05 2.48279e-05 2.53016e-05 2.78891e-05 3.0674e-05 3.14137e-05 3.13164e-05 3.04875e-05 2.99791e-05 2.93999e-05 2.88993e-05 3.05341e-05 5.79184e-05 2.12869e-05 2.54645e-05 3.19117e-05 3.20737e-05 2.96912e-05 2.72275e-05 2.64594e-05 2.61194e-05 2.6083e-05 2.61775e-05 2.65386e-05 2.66752e-05 2.66641e-05 2.64108e-05 2.63645e-05 2.72736e-05 3.0453e-05 3.66639e-05 2.50426e-05 3.31362e-05 3.32443e-05 3.33382e-05 3.46069e-05 3.46514e-05 3.28087e-05 3.02937e-05 2.92608e-05 2.88318e-05 2.87224e-05 2.92283e-05 3.29302e-05 3.87223e-05 4.19533e-05 4.30087e-05 4.24047e-05 4.25747e-05 2.05886e-05 2.45434e-05 2.5946e-05 2.70755e-05 3.44793e-05 5.1547e-05 5.65435e-05 5.45247e-05 4.31768e-05 3.24829e-05 2.78846e-05 2.6397e-05 2.62805e-05 2.71978e-05 3.00342e-05 3.15572e-05 3.27479e-05 3.39061e-05 2.22008e-05 2.41145e-05 2.36393e-05 2.39367e-05 2.60693e-05 2.85757e-05 3.42971e-05 4.38781e-05 4.78783e-05 4.80103e-05 4.6205e-05 3.92082e-05 3.27769e-05 2.96714e-05 2.83085e-05 2.76823e-05 2.76401e-05 2.80323e-05 2.1719e-05 2.17414e-05 2.26466e-05 2.52974e-05 2.8689e-05 3.01969e-05 3.12168e-05 3.38586e-05 3.69812e-05 3.79571e-05 3.79506e-05 3.77322e-05 3.68592e-05 3.51622e-05 3.42677e-05 3.37625e-05 3.34862e-05 3.32336e-05 2.13544e-05 2.75652e-05 3.62298e-05 3.66502e-05 3.29374e-05 2.96098e-05 2.94465e-05 3.02431e-05 3.28052e-05 3.45355e-05 3.53926e-05 3.63958e-05 3.8493e-05 4.39979e-05 5.5407e-05 6.54162e-05 7.42689e-05 7.81329e-05 2.60782e-05 4.39686e-05 4.23666e-05 3.46092e-05 3.20005e-05 3.27798e-05 3.74704e-05 5.09915e-05 6.08873e-05 6.53497e-05 6.85138e-05 7.39145e-05 8.55986e-05 0.000117545 0.000170171 0.000200369 0.000227911 0.000230841 2.90719e-05 3.38747e-05 3.50651e-05 4.42483e-05 6.88234e-05 0.000125356 0.000265711 0.000392231 0.00045212 0.000485147 0.000535224 0.000635045 0.000865053 0.001417 0.00200989 0.00237865 0.00264651 0.00266947 2.35361e-05 5.97038e-05 0.000212858 0.000575757 0.00100273 0.00182309 0.0036684 0.00579291 0.00704831 0.00772301 0.00830442 0.00932513 0.0117263 0.0153924 0.0189989 0.0215785 0.0236145 0.0243442 3.09928e-05 0.000869787 0.0045403 0.0117617 0.0183385 0.0315476 0.0501679 0.0677141 0.0781513 0.0860404 0.0915527 0.0992346 0.108109 0.118551 0.1267 0.1339 0.137722 0.140943 0.000529287 0.0187862 0.0856949 0.158425 0.228609 0.312294 0.389341 0.442047 0.472461 0.490684 0.501436 0.51123 0.518694 0.525501 0.52823 0.528243 0.527098 0.523863 0.0234435 0.306937 0.897101 1.19017 1.40345 1.58105 1.68648 1.70013 1.6898 1.66255 1.61921 1.57326 1.52015 1.47149 1.41403 1.37254 1.31587 1.28344 0.667006 3.26097 4.36626 4.41018 4.27255 3.96891 3.63868 3.34163 3.08113 2.85222 2.64907 2.46534 2.29869 2.1486 2.00859 1.89243 1.76626 1.69119 7.00246 9.84414 8.61573 6.45318 5.02744 4.08672 3.43764 2.97912 2.63707 2.3746 2.15765 1.97682 1.81431 1.67206 1.53684 1.41893 1.29936 1.2063 0.000333104 0.000574908 0.000930838 0.00160539 0.00272654 0.00441498 0.00677423 0.00985919 0.0136657 0.0181446 0.0231903 0.0286668 0.0344035 0.0402124 0.0459069 0.0513024 0.0562389 0.0605686 0.0642092 0.0670706 0.0685843 0.069284 0.0694792 0.0686986 0.0670035 0.0648655 0.0624037 0.0597959 0.0571602 0.0546223 0.0522949 0.0502775 0.0486584 0.0475323 0.0469523 0.0469223 0.0476029 0.049028 0.0512715 0.0543958 0.0585076 0.0636972 0.0700419 0.0776397 0.0865775 0.0969227 0.108731 0.12204 0.13686 0.153174 0.170937 0.190079 0.210505 0.232089 0.254689 0.278146 0.302296 0.326965 0.351972 0.377141 0.402307 0.427318 0.452029 0.476307 0.500038 0.523135 0.545515 0.567119 0.587895 0.607808 0.626878 0.645023 0.662289 0.678827 0.694324 0.708608 0.721995 0.734626 0.746576 0.757893 0.768617 0.778778 0.788418 0.797564 0.806237 0.814476 0.822315 0.829761 0.836831 0.84355 0.849942 0.856033 0.861845 0.867394 0.872693 0.877758 0.882606 0.887251 0.891704 0.895977 0.900079 0.904023 0.90782 0.911477 0.915001 0.918399 0.921679 0.924851 0.92792 0.930889 0.933763 0.936546 0.939249 0.941883 0.944441 0.946924 0.949333 0.951673 0.953948 0.956162 0.958318 0.960418 0.962465 0.964459 0.966403 0.968298 0.970146 0.971951 0.973712 0.97543 0.977105 0.97873 0.980315 0.981862 0.983373 0.984848 0.986286 0.987686 0.989049 0.990375 0.991666 0.992923 0.994145 0.995331 0.99648 0.997592 0.998668 0.999709 1.00072 1.00169 1.00262 1.00351 1.00436 1.00516 1.00593 1.00665 1.00731 1.00792 1.00847 1.00896 1.00934 1.00968 1.0098 1.01009 1.00954 1.01029 1.00795 1.00991 1.00451 1.00847 0.998664 1.00483 0.990275 0.994868 0.978813 0.975555 0.961179 0.932111 0.922816 0.838495 0.00201139 0.000601764 0.000587375 0.00076939 0.00107627 0.00148677 0.00200037 0.00259717 0.00323949 0.00388297 0.00447658 0.0049694 0.00531638 0.00548414 0.0055299 0.00537737 0.00508804 0.00466379 0.00416462 0.00363326 0.00310996 0.00266544 0.00235107 0.002195 0.00219121 0.00230042 0.00241391 0.00253809 0.00267253 0.00281573 0.00296779 0.00312687 0.00329262 0.00346527 0.00364638 0.00383808 0.00404275 0.00426525 0.00451062 0.00478273 0.00509082 0.00544421 0.00584962 0.00631861 0.00686174 0.00749081 0.00821852 0.00905542 0.0100137 0.0111063 0.0123457 0.0137446 0.015315 0.017068 0.0190138 0.0211613 0.0235177 0.0260891 0.0288793 0.0318893 0.0351217 0.0385649 0.0422348 0.0460911 0.0501681 0.0544217 0.0588336 0.0634716 0.0681628 0.0730827 0.0780977 0.0831284 0.0884321 0.0936678 0.0988958 0.104506 0.110376 0.116419 0.122565 0.128752 0.134953 0.141119 0.147243 0.153302 0.159271 0.165174 0.170967 0.176635 0.182182 0.187611 0.192933 0.198151 0.203269 0.208301 0.213253 0.218124 0.222922 0.227655 0.232327 0.23694 0.241499 0.246008 0.250472 0.254894 0.259279 0.26363 0.267951 0.272245 0.276515 0.280765 0.284997 0.289215 0.293422 0.297619 0.30181 0.305996 0.310181 0.314366 0.318554 0.322745 0.326942 0.331148 0.335364 0.339592 0.343833 0.348089 0.352361 0.356651 0.360959 0.365287 0.369639 0.374013 0.37841 0.38283 0.387274 0.391745 0.396243 0.40077 0.405325 0.409907 0.414517 0.419155 0.423824 0.428524 0.433255 0.438016 0.442808 0.447628 0.452479 0.457362 0.462277 0.467224 0.472202 0.477211 0.48225 0.48732 0.492423 0.497554 0.502722 0.507912 0.513153 0.518394 0.523725 0.528988 0.534459 0.539686 0.545405 0.550435 0.556678 0.561148 0.568308 0.572127 0.58074 0.583657 0.59426 0.595776 0.610117 0.610242 0.622213 0.660195 0.00713543 0.000796073 0.000526802 0.000525957 0.00056849 0.000630936 0.000700323 0.000769735 0.000830374 0.000868411 0.000882988 0.000881085 0.000849928 0.000807962 0.000759815 0.000709412 0.000669979 0.000644778 0.000632839 0.000640966 0.000671144 0.00072138 0.000790371 0.000875493 0.00097601 0.0010821 0.00118982 0.0012951 0.00139483 0.00148612 0.00156681 0.00163452 0.00168721 0.00172067 0.0017365 0.00174121 0.00172718 0.00169954 0.00165885 0.00160677 0.00154603 0.00147887 0.00140726 0.00133267 0.00125585 0.001178 0.00110064 0.00102903 0.000965056 0.000909624 0.000863481 0.000827222 0.00080127 0.00078597 0.000781029 0.000787963 0.00080706 0.000837912 0.00088108 0.000937189 0.00100692 0.00109024 0.00118868 0.00130066 0.00142975 0.00157395 0.00173371 0.00191339 0.002107 0.0023194 0.00255396 0.00279682 0.00307104 0.00335129 0.00365962 0.0039756 0.00432306 0.00468823 0.00507494 0.00549457 0.00591776 0.0063851 0.00685536 0.00734541 0.00787526 0.00838435 0.0089408 0.00955521 0.0102164 0.0109195 0.0116589 0.0124257 0.0132193 0.0140358 0.014866 0.0157061 0.0165534 0.017407 0.0182659 0.0191283 0.0199931 0.0208596 0.0217272 0.0225956 0.0234649 0.0243348 0.0252056 0.0260774 0.0269504 0.027825 0.0287017 0.0295812 0.0304643 0.0313514 0.032243 0.0331397 0.0340422 0.0349514 0.0358681 0.0367931 0.037727 0.0386705 0.0396247 0.0405903 0.0415684 0.0425597 0.0435649 0.0445848 0.0456201 0.0466719 0.0477411 0.0488286 0.0499351 0.0510609 0.052207 0.0533744 0.0545641 0.0557772 0.0570142 0.0582757 0.0595622 0.0608744 0.0622136 0.0635811 0.0649778 0.0664042 0.0678606 0.0693479 0.0708669 0.072419 0.0740055 0.0756275 0.0772858 0.0789812 0.0807149 0.0824873 0.0843031 0.0861553 0.0880671 0.0899919 0.0920386 0.0939865 0.0962852 0.0980981 0.100907 0.102343 0.105831 0.107156 0.111111 0.11227 0.117128 0.118064 0.123844 0.124865 0.131669 0.13334 0.142451 0.145518 0.154386 0.191101 0.0193568 0.00131907 0.000556412 0.00052263 0.000528857 0.000540402 0.000548273 0.000555071 0.000559689 0.000562387 0.000564406 0.000568051 0.000575037 0.000588735 0.000610218 0.000642298 0.00068571 0.000748843 0.000835468 0.000947775 0.00108491 0.00124513 0.0014257 0.00162037 0.00182407 0.00202637 0.00221696 0.00238789 0.00253011 0.00264201 0.00271106 0.00274356 0.00275351 0.00272217 0.00265967 0.00256965 0.0024587 0.00233088 0.00219147 0.00204354 0.00189261 0.00174288 0.00159713 0.00145662 0.00132347 0.00119903 0.00108383 0.000976278 0.000876161 0.000783603 0.000698583 0.000620944 0.000550369 0.000486477 0.00042895 0.000377512 0.000331791 0.000291288 0.000255308 0.000223063 0.00019431 0.000169286 0.000147715 0.000129272 0.000113793 0.000100893 9.02377e-05 8.17277e-05 7.51737e-05 7.02345e-05 6.68944e-05 6.47492e-05 6.41557e-05 6.435e-05 6.59287e-05 6.80998e-05 7.14136e-05 7.53508e-05 8.02649e-05 8.58254e-05 9.22051e-05 9.94396e-05 0.000107122 0.00011607 0.000125077 0.000135329 0.000146431 0.000157117 0.000170692 0.000184644 0.000198333 0.000216417 0.000233806 0.000250889 0.000274341 0.000303578 0.000338049 0.00037722 0.000420267 0.000466513 0.000515426 0.000566558 0.000619547 0.000674104 0.000729988 0.000787 0.000844982 0.000903805 0.000963367 0.00102358 0.0010844 0.00114581 0.00120782 0.00127039 0.00133351 0.00139718 0.00146142 0.00152629 0.00159183 0.00165812 0.00172517 0.00179305 0.00186183 0.0019316 0.00200245 0.00207448 0.00214778 0.00222242 0.0022985 0.00237611 0.00245539 0.00253645 0.0026194 0.00270431 0.00279131 0.00288052 0.00297212 0.00306624 0.00316301 0.00326253 0.00336489 0.00347024 0.00357879 0.00369074 0.00380627 0.0039255 0.00404855 0.00417558 0.00430678 0.00444242 0.00458278 0.00472811 0.00487862 0.0050345 0.00519622 0.00536352 0.00553846 0.0057174 0.00591022 0.00609708 0.00632116 0.00649939 0.00678812 0.00692366 0.00731178 0.00742745 0.00787989 0.00799606 0.00859466 0.00866338 0.00948946 0.00949413 0.0105913 0.0106296 0.0119808 0.0122819 0.0142511 0.01506 0.0172853 0.026946 0.0450519 0.0024072 0.000621004 0.000554025 0.000553621 0.000562604 0.000574705 0.00058323 0.000592993 0.000607925 0.000630574 0.000663905 0.000713697 0.000784278 0.000882414 0.00101374 0.00118897 0.00140917 0.00167694 0.00199636 0.00237037 0.00279719 0.00326987 0.00377256 0.00428613 0.00476412 0.0051705 0.0054956 0.00569744 0.00579462 0.00582494 0.00573146 0.00556737 0.00534287 0.00505395 0.00471804 0.00435769 0.00398507 0.00361416 0.00325407 0.00291472 0.0026004 0.00231234 0.00205051 0.00181377 0.00160084 0.00141008 0.00123968 0.00108782 0.000952718 0.000832738 0.000726372 0.000632298 0.000549286 0.000476106 0.000411587 0.000354766 0.000304949 0.000261628 0.000224274 0.00019212 0.000164276 0.000140132 0.000119228 0.000101177 8.56276e-05 7.22698e-05 6.08328e-05 5.10744e-05 4.2768e-05 3.57239e-05 2.97741e-05 2.47785e-05 2.05758e-05 1.7051e-05 1.41114e-05 1.16773e-05 9.67357e-06 8.03621e-06 6.69992e-06 5.62892e-06 4.77084e-06 4.08624e-06 3.56975e-06 3.16063e-06 2.8578e-06 2.66019e-06 2.50861e-06 2.42338e-06 2.41304e-06 2.40967e-06 2.45889e-06 2.57775e-06 2.67955e-06 2.791e-06 3.03424e-06 3.28943e-06 3.51781e-06 3.96631e-06 4.65484e-06 5.55032e-06 6.62386e-06 7.85328e-06 9.22014e-06 1.07089e-05 1.23061e-05 1.40007e-05 1.57826e-05 1.76429e-05 1.95736e-05 2.15682e-05 2.36212e-05 2.5728e-05 2.78835e-05 3.00824e-05 3.23206e-05 3.45954e-05 3.69058e-05 3.92511e-05 4.16306e-05 4.40428e-05 4.6487e-05 4.8964e-05 5.1476e-05 5.40259e-05 5.66162e-05 5.92493e-05 6.19272e-05 6.46521e-05 6.74276e-05 7.02583e-05 7.31491e-05 7.61046e-05 7.9128e-05 8.22239e-05 8.53983e-05 8.86578e-05 9.20084e-05 9.54562e-05 9.90063e-05 0.000102664 0.000106435 0.00011033 0.000114358 0.000118528 0.000122846 0.000127319 0.000131955 0.000136765 0.000141764 0.000146966 0.000152384 0.000158033 0.000163921 0.000170089 0.000176493 0.000183332 0.000190225 0.000198134 0.000205108 0.000215282 0.000220865 0.000235852 0.00023868 0.000258638 0.000261816 0.000286608 0.000288423 0.000324703 0.000323331 0.000376893 0.000372355 0.000451198 0.00045164 0.000554471 0.000586238 0.000752279 0.000853353 0.00108987 0.00234566 0.0867748 0.00504774 0.000942258 0.000662881 0.000651042 0.000654922 0.000650278 0.000682218 0.000731095 0.000793211 0.000876763 0.000997251 0.00115674 0.00137562 0.00166509 0.00204908 0.00254118 0.00317154 0.00395443 0.00491203 0.00604615 0.00733831 0.00873786 0.0101588 0.0115177 0.0126672 0.0135227 0.014017 0.0142145 0.0141869 0.0138608 0.0132802 0.0126245 0.0118148 0.0108929 0.00986638 0.00881092 0.00774922 0.00673103 0.00578633 0.004938 0.00419705 0.00356258 0.00302605 0.00257451 0.00219535 0.00187618 0.00160637 0.0013772 0.00118175 0.0010145 0.000870981 0.00074753 0.000641175 0.000549524 0.000470584 0.000402599 0.000343996 0.000293421 0.00024978 0.000212186 0.000179879 0.000152176 0.000128469 0.000108215 9.09434e-05 7.62461e-05 6.37649e-05 5.31892e-05 4.42528e-05 3.67198e-05 3.03813e-05 2.50612e-05 2.06165e-05 1.69185e-05 1.38472e-05 1.13023e-05 9.19915e-06 7.46587e-06 6.04158e-06 4.87512e-06 3.92275e-06 3.1476e-06 2.51912e-06 2.01079e-06 1.60091e-06 1.2719e-06 1.00833e-06 7.98112e-07 6.31362e-07 4.98791e-07 3.94385e-07 3.12847e-07 2.48372e-07 1.98613e-07 1.60402e-07 1.30552e-07 1.08913e-07 9.25405e-08 8.04238e-08 7.56779e-08 7.56504e-08 8.30926e-08 9.68302e-08 1.15715e-07 1.39305e-07 1.67218e-07 1.99125e-07 2.34737e-07 2.73789e-07 3.1604e-07 3.61276e-07 4.09288e-07 4.59863e-07 5.12767e-07 5.6779e-07 6.24751e-07 6.83518e-07 7.43966e-07 8.05979e-07 8.69413e-07 9.34144e-07 1.00011e-06 1.06728e-06 1.13568e-06 1.20532e-06 1.27618e-06 1.34826e-06 1.42155e-06 1.49611e-06 1.57203e-06 1.64941e-06 1.72838e-06 1.80899e-06 1.89134e-06 1.97556e-06 2.06182e-06 2.15027e-06 2.24109e-06 2.33443e-06 2.43047e-06 2.52934e-06 2.63132e-06 2.73663e-06 2.84557e-06 2.95829e-06 3.07504e-06 3.19608e-06 3.32174e-06 3.45245e-06 3.58857e-06 3.73058e-06 3.879e-06 4.03387e-06 4.19721e-06 4.36628e-06 4.55074e-06 4.73106e-06 4.95459e-06 5.12527e-06 5.44079e-06 5.54079e-06 6.03221e-06 6.07374e-06 6.68111e-06 6.74401e-06 7.57817e-06 7.58695e-06 8.83364e-06 8.77553e-06 1.07295e-05 1.0648e-05 1.36071e-05 1.40249e-05 1.81993e-05 2.0461e-05 2.80892e-05 3.61051e-05 5.07497e-05 0.000154607 0.160438 0.00825903 0.000987782 0.000747019 0.000742399 0.000797742 0.000994478 0.00107712 0.00110543 0.00122202 0.00140955 0.00169534 0.00211857 0.00269318 0.00348652 0.00455147 0.00599499 0.00785933 0.0102348 0.0131183 0.0164823 0.0201754 0.0239384 0.0274694 0.0305081 0.0327749 0.0339089 0.0343425 0.0340785 0.0331751 0.0319318 0.030072 0.0284171 0.0263126 0.024125 0.0216756 0.0191742 0.0166047 0.0141019 0.0117431 0.0096212 0.00779469 0.00627847 0.0050517 0.00407688 0.00331013 0.00270747 0.0022309 0.00185026 0.00154272 0.00129147 0.00108429 0.0009122 0.000768466 0.000647887 0.000546397 0.000460793 0.000388507 0.000327426 0.000275781 0.000232093 0.000195127 0.000163851 0.000137395 0.000115027 9.61326e-05 8.01911e-05 6.6761e-05 5.54635e-05 4.5974e-05 3.80183e-05 3.13636e-05 2.581e-05 2.11854e-05 1.73433e-05 1.41595e-05 1.15286e-05 9.36079e-06 7.57943e-06 6.11985e-06 4.92747e-06 3.95639e-06 3.1678e-06 2.52919e-06 2.01361e-06 1.59875e-06 1.26595e-06 9.99708e-07 7.8732e-07 6.18386e-07 4.84387e-07 3.78423e-07 2.94885e-07 2.29185e-07 1.77664e-07 1.37381e-07 1.05975e-07 8.15678e-08 6.26437e-08 4.80178e-08 3.67443e-08 2.80754e-08 2.14836e-08 1.6527e-08 1.28528e-08 1.0189e-08 8.31805e-09 7.09488e-09 6.33863e-09 6.05486e-09 6.03674e-09 6.29514e-09 6.78035e-09 7.44468e-09 8.25603e-09 9.19153e-09 1.02333e-08 1.13673e-08 1.25824e-08 1.38696e-08 1.52203e-08 1.66274e-08 1.80858e-08 1.95916e-08 2.11423e-08 2.27353e-08 2.43685e-08 2.60393e-08 2.7746e-08 2.94878e-08 3.12656e-08 3.30806e-08 3.49345e-08 3.68277e-08 3.87612e-08 4.07373e-08 4.27588e-08 4.48287e-08 4.69516e-08 4.91311e-08 5.13712e-08 5.3675e-08 5.60476e-08 5.84942e-08 6.10219e-08 6.36344e-08 6.6339e-08 6.91424e-08 7.20528e-08 7.5081e-08 7.82339e-08 8.15245e-08 8.49687e-08 8.85625e-08 9.23751e-08 9.63016e-08 1.00678e-07 1.04805e-07 1.10342e-07 1.13936e-07 1.22309e-07 1.23663e-07 1.3666e-07 1.37526e-07 1.52746e-07 1.5424e-07 1.7635e-07 1.77127e-07 2.10536e-07 2.11174e-07 2.6455e-07 2.69513e-07 3.52392e-07 3.82229e-07 5.14281e-07 6.23671e-07 8.83729e-07 1.3314e-06 2.06654e-06 8.76295e-06 0.227025 0.0145561 0.00157583 0.00114677 0.00118223 0.00120662 0.0011267 0.00124908 0.00149821 0.00186996 0.00242669 0.00311174 0.00411193 0.00558092 0.00767965 0.0106009 0.014475 0.0195074 0.0257184 0.0331355 0.0415094 0.0502303 0.0581183 0.0651091 0.0699443 0.0721364 0.0728369 0.0717724 0.0692765 0.0659733 0.0631492 0.0588427 0.0556596 0.0513365 0.0472889 0.0428896 0.0384681 0.0338361 0.0291261 0.024371 0.0197793 0.0156262 0.0121248 0.00930643 0.0071125 0.00545504 0.00422144 0.00330606 0.0026224 0.00210513 0.00170719 0.00139569 0.00114791 0.000948162 0.000785469 0.000651991 0.000541939 0.000450881 0.000375327 0.000312498 0.000260168 0.00021654 0.000180145 0.000149766 0.000124398 0.000103214 8.55301e-05 7.07753e-05 5.84716e-05 4.82206e-05 3.96907e-05 3.26041e-05 2.67264e-05 2.18595e-05 1.78371e-05 1.452e-05 1.17909e-05 9.55082e-06 7.71655e-06 6.21833e-06 4.9979e-06 4.00644e-06 3.20312e-06 2.55402e-06 2.03095e-06 1.61071e-06 1.27405e-06 1.00507e-06 7.90789e-07 6.20535e-07 4.85651e-07 3.79112e-07 2.95181e-07 2.29231e-07 1.77563e-07 1.37201e-07 1.0575e-07 8.13094e-08 6.2368e-08 4.77229e-08 3.64305e-08 2.77482e-08 2.10879e-08 1.59902e-08 1.20982e-08 9.13545e-09 6.88622e-09 5.18378e-09 3.89901e-09 2.93344e-09 2.20999e-09 1.67089e-09 1.27181e-09 9.78836e-10 7.66202e-10 6.14216e-10 5.08202e-10 4.36672e-10 3.9145e-10 3.65787e-10 3.55512e-10 3.55802e-10 3.65117e-10 3.80928e-10 4.01744e-10 4.26499e-10 4.54383e-10 4.84783e-10 5.17255e-10 5.5148e-10 5.87249e-10 6.24409e-10 6.62859e-10 7.02514e-10 7.43319e-10 7.85264e-10 8.28357e-10 8.72625e-10 9.18137e-10 9.64955e-10 1.01315e-09 1.06278e-09 1.11392e-09 1.16665e-09 1.22114e-09 1.27746e-09 1.33579e-09 1.39631e-09 1.45916e-09 1.52462e-09 1.59277e-09 1.66393e-09 1.73854e-09 1.8164e-09 1.89946e-09 1.98457e-09 2.08136e-09 2.16948e-09 2.29659e-09 2.36713e-09 2.56762e-09 2.58812e-09 2.88264e-09 2.91036e-09 3.25848e-09 3.3019e-09 3.81536e-09 3.87352e-09 4.65234e-09 4.77589e-09 6.06433e-09 6.44852e-09 8.62716e-09 9.93273e-09 1.38618e-08 1.89471e-08 2.74279e-08 4.73841e-08 8.47221e-08 4.85478e-07 0.356496 0.0240169 0.00196061 0.00112178 0.00112862 0.00129743 0.00157604 0.00238279 0.00277134 0.00324315 0.00405691 0.00568287 0.00812211 0.0117042 0.0167802 0.0237737 0.0331347 0.0457289 0.0602794 0.0744408 0.0900912 0.105663 0.120027 0.127844 0.130839 0.131412 0.127542 0.121287 0.115501 0.107845 0.103495 0.0960498 0.0904756 0.0824972 0.0754227 0.0687346 0.0625564 0.0567556 0.0511393 0.0451528 0.0383602 0.030886 0.0237294 0.0179216 0.0132423 0.00970899 0.00712549 0.00527325 0.00395564 0.00301697 0.00234104 0.00184531 0.00147351 0.00118825 0.000965003 0.000787554 0.000644908 0.000529313 0.000435102 0.000358021 0.000294796 0.000242842 0.000200082 0.000164841 0.000135767 0.000111769 9.1955e-05 7.55895e-05 6.20694e-05 5.09024e-05 4.16854e-05 3.40846e-05 2.78219e-05 2.26669e-05 1.84299e-05 1.49537e-05 1.21071e-05 9.7805e-06 7.88251e-06 6.33759e-06 5.08318e-06 4.06709e-06 3.24598e-06 2.58407e-06 2.05187e-06 1.62516e-06 1.28394e-06 1.01176e-06 7.95222e-07 6.23419e-07 4.87488e-07 3.80252e-07 2.95857e-07 2.29609e-07 1.77751e-07 1.37262e-07 1.05739e-07 8.12655e-08 6.23096e-08 4.76589e-08 3.63656e-08 2.76859e-08 2.103e-08 1.59384e-08 1.20528e-08 9.09473e-09 6.84792e-09 5.14551e-09 3.85874e-09 2.88824e-09 2.15774e-09 1.60909e-09 1.19795e-09 8.90575e-10 6.61268e-10 4.90541e-10 3.63677e-10 2.69591e-10 1.99981e-10 1.48607e-10 1.10808e-10 8.30937e-11 6.2859e-11 4.81532e-11 3.753e-11 2.99194e-11 2.45318e-11 2.07844e-11 1.82445e-11 1.66031e-11 1.55985e-11 1.51095e-11 1.49439e-11 1.50543e-11 1.5374e-11 1.58449e-11 1.64324e-11 1.7113e-11 1.78702e-11 1.86923e-11 1.95717e-11 2.05022e-11 2.14801e-11 2.25034e-11 2.35726e-11 2.46873e-11 2.58504e-11 2.70643e-11 2.83302e-11 2.96535e-11 3.10357e-11 3.24822e-11 3.40045e-11 3.55953e-11 3.73028e-11 3.90451e-11 4.10655e-11 4.2847e-11 4.55851e-11 4.69161e-11 5.13375e-11 5.17224e-11 5.79142e-11 5.87532e-11 6.62733e-11 6.77559e-11 7.8777e-11 8.18821e-11 9.97507e-11 1.06911e-10 1.41524e-10 1.59718e-10 2.34944e-10 2.96032e-10 4.35565e-10 7.84559e-10 1.28301e-09 2.64222e-09 5.89239e-09 3.56955e-08 0.480294 0.0363336 0.00225062 0.00125298 0.00161666 0.00214948 0.00280676 0.00299764 0.00366868 0.00500526 0.00752582 0.011409 0.0165526 0.0240187 0.0353181 0.0525841 0.0734394 0.0913132 0.11564 0.14403 0.170781 0.18121 0.185219 0.186169 0.183592 0.176288 0.171377 0.166493 0.158883 0.150642 0.145493 0.13855 0.130248 0.115328 0.101266 0.0891269 0.0786652 0.0706039 0.063881 0.0582218 0.053264 0.0478612 0.0411163 0.0327154 0.0242935 0.0175575 0.0125628 0.00895398 0.00639672 0.00461465 0.00338424 0.00253311 0.00193632 0.00150821 0.00119253 0.000953414 0.00076813 0.000622073 0.000505522 0.000411734 0.000335831 0.00027416 0.000223919 0.000182921 0.000149434 0.000122065 9.96813e-05 8.13648e-05 6.63719e-05 5.41002e-05 4.40571e-05 3.58383e-05 2.91138e-05 2.36155e-05 1.91249e-05 1.5462e-05 1.24777e-05 1.00494e-05 8.07671e-06 6.47726e-06 5.1833e-06 4.13851e-06 3.29663e-06 2.61978e-06 2.07689e-06 1.64259e-06 1.29595e-06 1.01993e-06 8.00716e-07 6.27072e-07 4.89886e-07 3.81787e-07 2.96803e-07 2.30166e-07 1.78062e-07 1.37417e-07 1.05793e-07 8.12563e-08 6.22643e-08 4.75999e-08 3.63054e-08 2.76283e-08 2.09773e-08 1.58913e-08 1.20124e-08 9.06049e-09 6.81937e-09 5.12192e-09 3.83929e-09 2.87221e-09 2.14456e-09 1.59827e-09 1.18902e-09 8.83097e-10 6.54858e-10 4.8489e-10 3.58532e-10 2.64751e-10 1.95259e-10 1.43845e-10 1.05872e-10 7.78738e-11 5.72616e-11 4.21036e-11 3.09654e-11 2.2787e-11 1.67879e-11 1.23925e-11 9.17509e-12 6.82123e-12 5.09845e-12 3.83804e-12 2.91502e-12 2.24084e-12 1.74965e-12 1.39265e-12 1.13391e-12 9.47211e-13 8.13588e-13 7.19222e-13 6.53966e-13 6.10301e-13 5.8278e-13 5.66226e-13 5.61066e-13 5.6198e-13 5.68602e-13 5.79635e-13 5.94272e-13 6.12046e-13 6.32577e-13 6.55615e-13 6.812e-13 7.08776e-13 7.39459e-13 7.70815e-13 8.08955e-13 8.41338e-13 8.95756e-13 9.19598e-13 1.00949e-12 1.01924e-12 1.1426e-12 1.18531e-12 1.31091e-12 1.45981e-12 1.62609e-12 1.92313e-12 2.47e-12 2.98232e-12 4.90517e-12 6.46423e-12 1.33764e-11 2.24174e-11 4.81107e-11 1.22865e-10 2.78578e-10 7.73659e-10 1.94016e-09 6.61791e-09 0.609368 0.0569673 0.00362463 0.00231033 0.00273376 0.00308753 0.00309369 0.00368027 0.00540684 0.00818655 0.0125744 0.0192633 0.0297189 0.0461622 0.0724146 0.0973424 0.125904 0.161809 0.193253 0.205903 0.210124 0.210639 0.207924 0.201849 0.198138 0.196128 0.192561 0.189905 0.186609 0.182224 0.176143 0.171032 0.16467 0.155121 0.139085 0.117584 0.0964403 0.0806387 0.0702792 0.0630741 0.0575372 0.0528773 0.0483665 0.0434093 0.0371505 0.0291862 0.0212646 0.0152492 0.0107678 0.00752775 0.00526185 0.00371708 0.00267728 0.00197578 0.0014945 0.0011551 0.000907976 0.000722462 0.000579628 0.000467541 0.000378405 0.000306893 0.000249184 0.000202428 0.000164458 0.000133577 0.000108425 8.79593e-05 7.13235e-05 5.77995e-05 4.68051e-05 3.78681e-05 3.06065e-05 2.47103e-05 1.99263e-05 1.60469e-05 1.29028e-05 1.03571e-05 8.29866e-06 6.63705e-06 5.29789e-06 4.22028e-06 3.35467e-06 2.66075e-06 2.10569e-06 1.66267e-06 1.30983e-06 1.02945e-06 8.07199e-07 6.31431e-07 4.92774e-07 3.83657e-07 2.97977e-07 2.30876e-07 1.78473e-07 1.37647e-07 1.05909e-07 8.12935e-08 6.22474e-08 4.75534e-08 3.62492e-08 2.75717e-08 2.09246e-08 1.58442e-08 1.19713e-08 9.02573e-09 6.79043e-09 5.09803e-09 3.81959e-09 2.85597e-09 2.13127e-09 1.5875e-09 1.18039e-09 8.76224e-10 6.49393e-10 4.80534e-10 3.55061e-10 2.61996e-10 1.93084e-10 1.42134e-10 1.04521e-10 7.67974e-11 5.63928e-11 4.13933e-11 3.03767e-11 2.22918e-11 1.63639e-11 1.20218e-11 8.84315e-12 6.51557e-12 4.80926e-12 3.5565e-12 2.63604e-12 1.9599e-12 1.46313e-12 1.09756e-12 8.27568e-13 6.27496e-13 4.78968e-13 3.68557e-13 2.86295e-13 2.24713e-13 1.78347e-13 1.43247e-13 1.16515e-13 9.61117e-14 8.04671e-14 6.84259e-14 5.90939e-14 5.18302e-14 4.61626e-14 4.17398e-14 3.83185e-14 3.56444e-14 3.37117e-14 3.20008e-14 3.10244e-14 3.00839e-14 2.97016e-14 2.93774e-14 3.04504e-14 3.04429e-14 3.28057e-14 3.54662e-14 3.97293e-14 5.04066e-14 6.60849e-14 9.7346e-14 1.84207e-13 3.20751e-13 8.8978e-13 1.72871e-12 4.79116e-12 1.23968e-11 3.0744e-11 9.05023e-11 2.25064e-10 5.85955e-10 1.52083e-09 3.83095e-09 0.726969 0.0837186 0.00480897 0.00222425 0.00243305 0.00308151 0.00363217 0.00573243 0.0122619 0.018195 0.0256852 0.0376125 0.0579468 0.0948282 0.122489 0.155667 0.187789 0.206772 0.212415 0.21315 0.211498 0.209343 0.209002 0.210432 0.216673 0.222951 0.225674 0.226035 0.217169 0.201373 0.188105 0.177947 0.169152 0.165532 0.157488 0.143892 0.123309 0.0999537 0.0800148 0.0671078 0.0593967 0.053987 0.0497182 0.0457909 0.0415594 0.0367363 0.0308171 0.0237325 0.0175019 0.0124719 0.00864877 0.00590982 0.0040352 0.00279155 0.00197802 0.00144334 0.00108405 0.000834231 0.000653855 0.000519118 0.000415741 0.000334863 0.00027071 0.000219331 0.0001779 0.000144259 0.000116878 9.4604e-05 7.64886e-05 6.17694e-05 4.98218e-05 4.0136e-05 3.22952e-05 2.59563e-05 2.08376e-05 1.67088e-05 1.33822e-05 1.07043e-05 8.54958e-06 6.81768e-06 5.42725e-06 4.31235e-06 3.41994e-06 2.70678e-06 2.138e-06 1.68525e-06 1.3255e-06 1.04026e-06 8.14583e-07 6.36423e-07 4.96102e-07 3.85823e-07 2.9937e-07 2.31759e-07 1.78997e-07 1.37929e-07 1.06052e-07 8.13566e-08 6.22608e-08 4.7535e-08 3.62133e-08 2.75264e-08 2.08753e-08 1.57971e-08 1.1929e-08 8.98893e-09 6.75935e-09 5.07254e-09 3.79901e-09 2.83938e-09 2.11783e-09 1.57659e-09 1.17156e-09 8.69103e-10 6.43657e-10 4.75924e-10 3.51379e-10 2.59085e-10 1.90808e-10 1.40367e-10 1.03151e-10 7.57297e-11 5.55557e-11 4.07346e-11 2.98582e-11 2.18838e-11 1.60431e-11 1.17698e-11 8.64591e-12 6.36188e-12 4.68986e-12 3.46361e-12 2.56344e-12 1.90273e-12 1.41769e-12 1.061e-12 7.97758e-13 6.02744e-13 4.57993e-13 3.50402e-13 2.70239e-13 2.10237e-13 1.65043e-13 1.30764e-13 1.04573e-13 8.44583e-14 6.89322e-14 5.68875e-14 4.74572e-14 4.00095e-14 3.40793e-14 2.93026e-14 2.54725e-14 2.23659e-14 1.98694e-14 1.76818e-14 1.61597e-14 1.44323e-14 1.35492e-14 1.2407e-14 1.19476e-14 1.16752e-14 1.21914e-14 1.30531e-14 1.60943e-14 2.0598e-14 3.39291e-14 5.5572e-14 1.33047e-13 2.52419e-13 7.29772e-13 1.61188e-12 4.39168e-12 1.18785e-11 2.86657e-11 8.28248e-11 2.0309e-10 5.10912e-10 1.31031e-09 3.0862e-09 0.837969 0.138818 0.00803268 0.00219328 0.00249686 0.00349572 0.00492886 0.00826758 0.0153327 0.0225008 0.034054 0.056149 0.0998343 0.135464 0.165069 0.192781 0.204725 0.209698 0.210519 0.209905 0.209444 0.210267 0.216105 0.227314 0.239554 0.251638 0.264917 0.276147 0.282194 0.270644 0.227928 0.184687 0.164257 0.153545 0.149113 0.144313 0.129375 0.10841 0.0886339 0.0719587 0.0605041 0.0541809 0.0498293 0.0461245 0.0427914 0.0390905 0.0351248 0.0306428 0.0253574 0.0195617 0.0141326 0.00979768 0.00658332 0.00436176 0.00289895 0.00196485 0.00137374 0.000994887 0.000744413 0.000571841 0.00044779 0.000355258 0.00028425 0.000228683 0.000184629 0.000149345 0.000120875 9.78515e-05 7.91853e-05 6.40305e-05 5.17201e-05 4.17206e-05 3.36017e-05 2.70158e-05 2.16815e-05 1.73679e-05 1.38857e-05 1.10807e-05 8.82701e-06 7.01972e-06 5.57276e-06 4.41622e-06 3.49345e-06 2.75849e-06 2.17419e-06 1.71042e-06 1.34292e-06 1.05228e-06 8.22791e-07 6.41955e-07 4.99825e-07 3.88293e-07 3.00954e-07 2.32763e-07 1.79623e-07 1.38287e-07 1.06223e-07 8.14178e-08 6.2269e-08 4.7519e-08 3.61845e-08 2.74921e-08 2.08388e-08 1.57597e-08 1.18929e-08 8.95579e-09 6.72968e-09 5.04645e-09 3.77668e-09 2.82091e-09 2.10299e-09 1.56481e-09 1.1622e-09 8.61605e-10 6.37617e-10 4.71061e-10 3.47492e-10 2.56007e-10 1.88388e-10 1.38476e-10 1.01677e-10 7.45829e-11 5.46635e-11 4.004e-11 2.9317e-11 2.14616e-11 1.57124e-11 1.15095e-11 8.44026e-12 6.19961e-12 4.56251e-12 3.3647e-12 2.48745e-12 1.84462e-12 1.37311e-12 1.02643e-12 7.7075e-13 5.81603e-13 4.41466e-13 3.37451e-13 2.60002e-13 2.02073e-13 1.58489e-13 1.255e-13 1.00367e-13 8.11203e-14 6.6279e-14 5.47713e-14 4.57487e-14 3.8626e-14 3.29561e-14 2.8395e-14 2.47852e-14 2.18104e-14 1.94302e-14 1.74725e-14 1.59674e-14 1.44032e-14 1.37672e-14 1.25476e-14 1.24105e-14 1.23484e-14 1.31507e-14 1.41052e-14 1.83806e-14 2.29263e-14 3.99215e-14 6.12675e-14 1.43408e-13 2.71147e-13 7.16677e-13 1.68721e-12 4.29317e-12 1.17276e-11 2.79437e-11 7.58461e-11 1.88906e-10 4.56566e-10 1.13617e-09 2.6362e-09 0.866845 0.217401 0.0167988 0.0027334 0.00392565 0.00697283 0.01055 0.0159293 0.0223333 0.0313402 0.0464529 0.0814828 0.128749 0.160372 0.182079 0.194541 0.20104 0.205264 0.20568 0.206216 0.206488 0.20641 0.208072 0.211132 0.21204 0.2148 0.228491 0.254649 0.288493 0.306068 0.300588 0.247987 0.183026 0.151018 0.137503 0.131843 0.122915 0.106721 0.0898236 0.0734244 0.060972 0.0528533 0.0485503 0.0457293 0.0430822 0.0403806 0.037013 0.0335788 0.0299991 0.0262417 0.021463 0.0159502 0.0109689 0.00726735 0.00468427 0.00299859 0.00194382 0.00129808 0.000902128 0.000653177 0.000489854 0.00037728 0.00029601 0.000235092 0.000188131 0.000151334 0.000122247 9.88997e-05 8.00262e-05 6.47259e-05 5.23056e-05 4.22186e-05 3.40294e-05 2.73872e-05 2.20043e-05 1.76471e-05 1.41254e-05 1.12841e-05 8.99605e-06 7.15736e-06 5.68263e-06 4.50244e-06 3.55994e-06 2.80887e-06 2.21162e-06 1.73768e-06 1.36236e-06 1.06584e-06 8.32145e-07 6.48342e-07 5.04073e-07 3.91094e-07 3.02795e-07 2.33913e-07 1.80312e-07 1.38699e-07 1.06449e-07 8.15102e-08 6.22802e-08 4.74906e-08 3.61351e-08 2.74334e-08 2.0782e-08 1.57107e-08 1.18526e-08 8.92323e-09 6.70367e-09 5.02535e-09 3.75888e-09 2.80557e-09 2.08994e-09 1.55397e-09 1.15334e-09 8.54418e-10 6.31805e-10 4.66392e-10 3.43772e-10 2.53055e-10 1.86043e-10 1.36606e-10 1.0019e-10 7.34139e-11 5.37563e-11 3.93416e-11 2.87801e-11 2.10481e-11 1.53931e-11 1.12623e-11 8.248e-12 6.04875e-12 4.44328e-12 3.27057e-12 2.41387e-12 1.78778e-12 1.32943e-12 9.92746e-13 7.44612e-13 5.61316e-13 4.25796e-13 3.25388e-13 2.50666e-13 1.94751e-13 1.52668e-13 1.20845e-13 9.66884e-14 7.82886e-14 6.41384e-14 5.31733e-14 4.45703e-14 3.77636e-14 3.23461e-14 2.80097e-14 2.45797e-14 2.17228e-14 1.95307e-14 1.76558e-14 1.61898e-14 1.49581e-14 1.43138e-14 1.34081e-14 1.35041e-14 1.3616e-14 1.49386e-14 1.61542e-14 2.16912e-14 2.68314e-14 4.73747e-14 7.13773e-14 1.55701e-13 3.01276e-13 7.40103e-13 1.77906e-12 4.28416e-12 1.15925e-11 2.7258e-11 7.07508e-11 1.7634e-10 4.11662e-10 9.98613e-10 2.31097e-09 0.826966 0.324912 0.040478 0.00548307 0.00509831 0.00824427 0.0131938 0.0190639 0.0274322 0.0458123 0.0793202 0.131422 0.164087 0.177891 0.187187 0.193778 0.195304 0.202407 0.203596 0.202889 0.198589 0.187787 0.164684 0.144054 0.133584 0.131821 0.137714 0.149009 0.174366 0.242655 0.303693 0.279897 0.235085 0.177232 0.146915 0.133675 0.121352 0.100605 0.0820371 0.070413 0.0595529 0.0509349 0.0459758 0.0439052 0.0426231 0.0410926 0.0390923 0.0357903 0.0319266 0.0284412 0.0251728 0.0215552 0.0170196 0.0119805 0.00777251 0.00490092 0.00304176 0.00189651 0.00121344 0.000809392 0.000565963 0.000413184 0.000312101 0.000241594 0.0001902 0.000151557 0.000121945 9.85429e-05 7.97139e-05 6.44995e-05 5.21629e-05 4.21441e-05 3.40047e-05 2.73948e-05 2.20319e-05 1.76856e-05 1.41684e-05 1.13273e-05 9.03701e-06 7.19444e-06 5.71515e-06 4.53023e-06 3.58312e-06 2.82792e-06 2.22704e-06 1.7499e-06 1.37205e-06 1.07344e-06 8.37968e-07 6.52776e-07 5.07367e-07 3.93439e-07 3.04443e-07 2.35058e-07 1.81072e-07 1.3918e-07 1.06744e-07 8.16849e-08 6.23722e-08 4.75229e-08 3.61251e-08 2.73948e-08 2.07311e-08 1.56579e-08 1.1801e-08 8.87539e-09 6.66177e-09 4.99058e-09 3.73132e-09 2.78418e-09 2.07318e-09 1.54059e-09 1.14251e-09 8.45601e-10 6.24656e-10 4.60673e-10 3.39251e-10 2.49491e-10 1.83218e-10 1.34347e-10 9.83768e-11 7.19631e-11 5.26082e-11 3.84423e-11 2.80781e-11 2.04988e-11 1.49623e-11 1.09248e-11 7.98423e-12 5.84244e-12 4.28128e-12 3.14299e-12 2.31345e-12 1.7091e-12 1.26797e-12 9.44743e-13 7.06952e-13 5.3164e-13 4.02294e-13 3.06684e-13 2.35698e-13 1.82676e-13 1.42832e-13 1.12773e-13 9.00442e-14 7.2815e-14 5.96498e-14 4.9502e-14 4.15657e-14 3.52997e-14 3.03519e-14 2.64237e-14 2.33047e-14 2.07884e-14 1.88577e-14 1.7098e-14 1.5919e-14 1.48682e-14 1.4226e-14 1.37706e-14 1.40213e-14 1.42997e-14 1.60489e-14 1.75318e-14 2.39855e-14 2.98026e-14 5.24544e-14 7.94383e-14 1.63104e-13 3.24551e-13 7.59376e-13 1.83059e-12 4.29022e-12 1.12819e-11 2.66046e-11 6.63966e-11 1.63798e-10 3.76474e-10 8.8422e-10 2.06693e-09 0.696624 0.456162 0.0954778 0.0161292 0.00692011 0.00818437 0.0126514 0.0180019 0.0260388 0.0440023 0.0842649 0.147012 0.179373 0.189151 0.194652 0.195837 0.194195 0.194522 0.198173 0.197599 0.189122 0.165767 0.137391 0.119218 0.115543 0.118326 0.124025 0.132553 0.141987 0.164693 0.235519 0.273366 0.249848 0.203055 0.168214 0.149503 0.133426 0.106305 0.0739848 0.0575576 0.0521962 0.0475391 0.0430916 0.0406355 0.0401364 0.0401459 0.0395952 0.0375681 0.0334613 0.0289982 0.0257136 0.0227651 0.0196146 0.0159764 0.0117261 0.00772366 0.00482476 0.00293774 0.00178065 0.00110132 0.000709516 0.000480917 0.000342264 0.00025337 0.000192991 0.000149842 0.000117723 9.37192e-05 7.54635e-05 6.10399e-05 4.94142e-05 4.00169e-05 3.23979e-05 2.62071e-05 2.11699e-05 1.70705e-05 1.37372e-05 1.10307e-05 8.837e-06 7.06249e-06 5.62995e-06 4.47664e-06 3.55047e-06 2.80864e-06 2.21623e-06 1.74428e-06 1.36936e-06 1.07245e-06 8.37857e-07 6.53004e-07 5.07744e-07 3.9385e-07 3.04806e-07 2.35362e-07 1.81316e-07 1.39369e-07 1.06888e-07 8.17883e-08 6.24432e-08 4.75741e-08 3.61659e-08 2.74256e-08 2.07485e-08 1.56638e-08 1.18009e-08 8.87184e-09 6.65457e-09 4.97963e-09 3.71847e-09 2.77193e-09 2.06299e-09 1.53269e-09 1.13653e-09 8.4103e-10 6.21087e-10 4.57876e-10 3.37088e-10 2.47837e-10 1.8196e-10 1.33405e-10 9.76865e-11 7.14651e-11 5.22495e-11 3.81827e-11 2.789e-11 2.03629e-11 1.48651e-11 1.08562e-11 7.93643e-12 5.8095e-12 4.25901e-12 3.12892e-12 2.3059e-12 1.70673e-12 1.26946e-12 9.48916e-13 7.1292e-13 5.38705e-13 4.09867e-13 3.14299e-13 2.43057e-13 1.89639e-13 1.49375e-13 1.18909e-13 9.58004e-14 7.82134e-14 6.471e-14 5.42455e-14 4.59921e-14 3.94903e-14 3.43573e-14 3.02307e-14 2.70599e-14 2.45306e-14 2.24616e-14 2.08528e-14 1.97991e-14 1.86396e-14 1.83615e-14 1.83684e-14 1.89163e-14 1.96199e-14 2.24797e-14 2.484e-14 3.3831e-14 4.18494e-14 7.04479e-14 1.04923e-13 1.98658e-13 3.88425e-13 8.44523e-13 1.98294e-12 4.47551e-12 1.13404e-11 2.65325e-11 6.3917e-11 1.55712e-10 3.52441e-10 8.06917e-10 1.89447e-09 0.464323 0.528359 0.234459 0.0514362 0.0131939 0.00909867 0.0114218 0.0172736 0.0259433 0.0442252 0.0864129 0.147409 0.179642 0.188596 0.193276 0.198281 0.197266 0.19549 0.194617 0.192319 0.186856 0.172563 0.148137 0.129837 0.121359 0.120641 0.122552 0.131404 0.140651 0.156409 0.214524 0.249067 0.243988 0.211265 0.172872 0.151006 0.134042 0.107908 0.0720533 0.0464794 0.038075 0.0364362 0.035739 0.0344555 0.0341431 0.0350811 0.0365649 0.0365315 0.0340961 0.0287244 0.0247566 0.0221521 0.0196448 0.0167359 0.0135094 0.0100367 0.00680783 0.00430256 0.00261146 0.00156518 0.00095188 0.000601196 0.000399505 0.000279338 0.000203654 0.000153014 0.000117278 9.09418e-05 7.11836e-05 5.63496e-05 4.50785e-05 3.63027e-05 2.93186e-05 2.36954e-05 1.91527e-05 1.54725e-05 1.24868e-05 1.00642e-05 8.09819e-06 6.50372e-06 5.21222e-06 4.16739e-06 3.32394e-06 2.6444e-06 2.09803e-06 1.66004e-06 1.30982e-06 1.03059e-06 8.08646e-07 6.3269e-07 4.93643e-07 3.84109e-07 2.98046e-07 2.30666e-07 1.7806e-07 1.37078e-07 1.05262e-07 8.06373e-08 6.16203e-08 4.6966e-08 3.57082e-08 2.70925e-08 2.05142e-08 1.54973e-08 1.16775e-08 8.77927e-09 6.58708e-09 4.93151e-09 3.68302e-09 2.74375e-09 2.03913e-09 1.51202e-09 1.11874e-09 8.26088e-10 6.08843e-10 4.47948e-10 3.29016e-10 2.41226e-10 1.76517e-10 1.28931e-10 9.40514e-11 6.85561e-11 4.99433e-11 3.63551e-11 2.64362e-11 1.9204e-11 1.39417e-11 1.0121e-11 7.3501e-12 5.3401e-12 3.88173e-12 2.82507e-12 2.06115e-12 1.50948e-12 1.11032e-12 8.20386e-13 6.09087e-13 4.54743e-13 3.41754e-13 2.58726e-13 1.97395e-13 1.51839e-13 1.17866e-13 9.24934e-14 7.35172e-14 5.92652e-14 4.84213e-14 4.00796e-14 3.35439e-14 2.8412e-14 2.44048e-14 2.12816e-14 1.89529e-14 1.70931e-14 1.57179e-14 1.46966e-14 1.38785e-14 1.33269e-14 1.33535e-14 1.34886e-14 1.42377e-14 1.50559e-14 1.79573e-14 2.04334e-14 2.92508e-14 3.74721e-14 6.50347e-14 1.00604e-13 1.91052e-13 3.82238e-13 8.23697e-13 1.93799e-12 4.35844e-12 1.08012e-11 2.53105e-11 5.97635e-11 1.43232e-10 3.22893e-10 7.25288e-10 1.67026e-09 0.161796 0.615242 0.466226 0.142354 0.0366724 0.0139887 0.0131152 0.0173259 0.0279948 0.0457566 0.0831666 0.142239 0.182093 0.194068 0.195083 0.198069 0.202929 0.202702 0.201061 0.196821 0.191946 0.188047 0.179919 0.164738 0.150055 0.146682 0.147881 0.153959 0.162246 0.174639 0.216787 0.242609 0.233151 0.202576 0.166566 0.131961 0.100827 0.0739291 0.0488111 0.0323581 0.0257953 0.0262211 0.02814 0.0289922 0.02939 0.030021 0.0308444 0.0312815 0.0308969 0.0268504 0.0207859 0.0181614 0.0170908 0.0157895 0.0136941 0.0109258 0.00794663 0.00535544 0.00340165 0.00208048 0.00125567 0.000767062 0.000484762 0.000321037 0.000223052 0.000161335 0.000120164 9.12468e-05 7.01009e-05 5.42994e-05 4.23743e-05 3.33231e-05 2.6434e-05 2.11206e-05 1.69411e-05 1.36085e-05 1.09318e-05 8.77529e-06 7.03702e-06 5.63663e-06 4.51002e-06 3.60437e-06 2.87665e-06 2.2924e-06 1.82365e-06 1.44812e-06 1.14767e-06 9.07577e-07 7.16152e-07 5.63721e-07 4.42598e-07 3.46674e-07 2.70829e-07 2.10996e-07 1.63945e-07 1.27038e-07 9.81672e-08 7.56433e-08 5.81263e-08 4.4544e-08 3.40377e-08 2.59389e-08 1.97156e-08 1.49501e-08 1.13106e-08 8.52996e-09 6.41113e-09 4.80562e-09 3.59444e-09 2.68301e-09 1.99822e-09 1.48445e-09 1.09964e-09 8.12192e-10 5.98329e-10 4.39833e-10 3.22648e-10 2.36172e-10 1.725e-10 1.25726e-10 9.14568e-11 6.64272e-11 4.8194e-11 3.49317e-11 2.52908e-11 1.82842e-11 1.31986e-11 9.5176e-12 6.85866e-12 4.93945e-12 3.55567e-12 2.5607e-12 1.84767e-12 1.33738e-12 9.71387e-13 7.07968e-13 5.18065e-13 3.8112e-13 2.82252e-13 2.1062e-13 1.58408e-13 1.20109e-13 9.19465e-14 7.12678e-14 5.60482e-14 4.47705e-14 3.62863e-14 2.98275e-14 2.48365e-14 2.09806e-14 1.80565e-14 1.58498e-14 1.41922e-14 1.29301e-14 1.2076e-14 1.13453e-14 1.08561e-14 1.07196e-14 1.08112e-14 1.10345e-14 1.18819e-14 1.2736e-14 1.55303e-14 1.79971e-14 2.6228e-14 3.43565e-14 5.99623e-14 9.52394e-14 1.81716e-13 3.68271e-13 7.8852e-13 1.84959e-12 4.15865e-12 1.01033e-11 2.36932e-11 5.51721e-11 1.30341e-10 2.92571e-10 6.48141e-10 1.46398e-09 0.147091 0.578936 0.51555 0.276084 0.0842453 0.0276728 0.0176124 0.0195469 0.0277186 0.0422454 0.0697155 0.12615 0.173904 0.192239 0.199806 0.200863 0.203263 0.206188 0.207291 0.205959 0.202445 0.19791 0.199639 0.20019 0.190388 0.178432 0.177909 0.184533 0.191852 0.198903 0.226249 0.227896 0.215362 0.188335 0.150538 0.104786 0.0626687 0.0376316 0.0263806 0.0219123 0.0216809 0.0239117 0.0267241 0.0277902 0.0286956 0.0292076 0.0292856 0.0289998 0.0277568 0.0237727 0.0183171 0.0150936 0.0139355 0.0136131 0.0131498 0.0116654 0.00877351 0.00599725 0.00386442 0.00240436 0.00147186 0.000902552 0.000564034 0.000364246 0.000244863 0.000171325 0.000124073 9.2289e-05 6.9974e-05 5.37083e-05 4.15339e-05 3.22727e-05 2.51653e-05 1.97174e-05 1.55454e-05 1.2325e-05 9.80883e-06 7.82471e-06 6.24649e-06 4.98333e-06 3.96973e-06 3.15673e-06 2.50548e-06 1.98468e-06 1.56895e-06 1.23775e-06 9.7451e-07 7.6564e-07 6.00234e-07 4.69579e-07 3.66588e-07 2.85553e-07 2.21949e-07 1.72142e-07 1.33209e-07 1.02846e-07 7.92257e-08 6.0892e-08 4.66952e-08 3.57249e-08 2.72662e-08 2.07612e-08 1.57699e-08 1.19486e-08 9.03553e-09 6.82261e-09 5.14133e-09 3.8656e-09 2.90139e-09 2.17496e-09 1.62837e-09 1.21742e-09 9.08675e-10 6.7674e-10 5.02683e-10 3.7236e-10 2.75005e-10 2.02491e-10 1.48727e-10 1.09061e-10 7.98898e-11 5.84525e-11 4.26988e-11 3.11345e-11 2.267e-11 1.65006e-11 1.20192e-11 8.76417e-12 6.39584e-12 4.66927e-12 3.41032e-12 2.49468e-12 1.83097e-12 1.3499e-12 1.00006e-12 7.44729e-13 5.58035e-13 4.21394e-13 3.21131e-13 2.47176e-13 1.92256e-13 1.51158e-13 1.20267e-13 9.70325e-14 7.94705e-14 6.6127e-14 5.58287e-14 4.78574e-14 4.1621e-14 3.67053e-14 3.29579e-14 3.00689e-14 2.77782e-14 2.60736e-14 2.48672e-14 2.37366e-14 2.31659e-14 2.31348e-14 2.33635e-14 2.39091e-14 2.55661e-14 2.72489e-14 3.20297e-14 3.64317e-14 4.94512e-14 6.24937e-14 1.00112e-13 1.49626e-13 2.63447e-13 4.99695e-13 9.97807e-13 2.19719e-12 4.74018e-12 1.0986e-11 2.51218e-11 5.69569e-11 1.30921e-10 2.90099e-10 6.3022e-10 1.42323e-09 0.235146 0.39576 0.489019 0.367128 0.158046 0.0560342 0.029288 0.0258273 0.0278051 0.0338132 0.0529965 0.10157 0.152547 0.187913 0.204653 0.210514 0.212598 0.214192 0.218407 0.225952 0.225703 0.218002 0.218386 0.217916 0.205599 0.199551 0.199565 0.202181 0.20138 0.207549 0.229974 0.223448 0.206299 0.184534 0.147359 0.0989888 0.0562333 0.0317672 0.0234692 0.021037 0.0210424 0.0239784 0.0266848 0.0273891 0.0286608 0.0292851 0.029218 0.0286011 0.0267987 0.0228154 0.0178973 0.0146156 0.0133528 0.0131361 0.0130886 0.0128201 0.0113598 0.0078327 0.00490967 0.00294957 0.00174985 0.00104944 0.000647148 0.000414153 0.000275612 0.000190129 0.000135201 9.85211e-05 7.31957e-05 5.52119e-05 4.21354e-05 3.24362e-05 2.51231e-05 1.95346e-05 1.52399e-05 1.19509e-05 9.43267e-06 7.48466e-06 5.96025e-06 4.75331e-06 3.78735e-06 3.01125e-06 2.38947e-06 1.89218e-06 1.49535e-06 1.17924e-06 9.27943e-07 7.28582e-07 5.70765e-07 4.46168e-07 3.47966e-07 2.70769e-07 2.10256e-07 1.62874e-07 1.25874e-07 9.70722e-08 7.46852e-08 5.73335e-08 4.39148e-08 3.35518e-08 2.5578e-08 1.94597e-08 1.47715e-08 1.11846e-08 8.44686e-09 6.3665e-09 4.79078e-09 3.59721e-09 2.69369e-09 2.01221e-09 1.49979e-09 1.11549e-09 8.28153e-10 6.14008e-10 4.54778e-10 3.3645e-10 2.48501e-10 1.83134e-10 1.34601e-10 9.86848e-11 7.22323e-11 5.28235e-11 3.86067e-11 2.82002e-11 2.05893e-11 1.50315e-11 1.09809e-11 8.0316e-12 5.88263e-12 4.31476e-12 3.17024e-12 2.33445e-12 1.72321e-12 1.27548e-12 9.47551e-13 7.07437e-13 5.31679e-13 4.02951e-13 3.0833e-13 2.38333e-13 1.86224e-13 1.47166e-13 1.17751e-13 9.55418e-14 7.86275e-14 6.56986e-14 5.56692e-14 4.79096e-14 4.19079e-14 3.7158e-14 3.35129e-14 3.07176e-14 2.8442e-14 2.67364e-14 2.55458e-14 2.44121e-14 2.38991e-14 2.39e-14 2.41706e-14 2.47922e-14 2.65522e-14 2.84077e-14 3.34108e-14 3.82494e-14 5.16716e-14 6.611e-14 1.04916e-13 1.58806e-13 2.76814e-13 5.24308e-13 1.03598e-12 2.25799e-12 4.81661e-12 1.09918e-11 2.48271e-11 5.57394e-11 1.2624e-10 2.77972e-10 5.95895e-10 1.32809e-09 0.270777 0.225365 0.417693 0.360988 0.220248 0.116606 0.0614832 0.0354458 0.0299397 0.0334578 0.0443001 0.0670987 0.124168 0.177113 0.19603 0.221024 0.229324 0.228428 0.229956 0.237842 0.238919 0.234344 0.231463 0.223575 0.217126 0.216907 0.216566 0.208277 0.199636 0.210309 0.21915 0.20772 0.19595 0.177737 0.132457 0.0784256 0.0443597 0.0259814 0.0189074 0.0175181 0.0175645 0.020525 0.0247025 0.0255841 0.0265209 0.0283692 0.0285208 0.0277068 0.0245389 0.020795 0.0173089 0.0142871 0.0129886 0.0128561 0.0130242 0.0130765 0.0127963 0.0113552 0.00745212 0.00436198 0.00246281 0.00138082 0.000793519 0.000479 0.000306449 0.000206579 0.0001449 0.000104508 7.68661e-05 5.73658e-05 4.33099e-05 3.3007e-05 2.53464e-05 1.95785e-05 1.51866e-05 1.18095e-05 9.20023e-06 7.18608e-06 5.63334e-06 4.43551e-06 3.50851e-06 2.78382e-06 2.20897e-06 1.75095e-06 1.38576e-06 1.09451e-06 8.62605e-07 6.78328e-07 5.32124e-07 4.16454e-07 3.25194e-07 2.53304e-07 1.96837e-07 1.52596e-07 1.18016e-07 9.10677e-08 7.00944e-08 5.38169e-08 4.12314e-08 3.15161e-08 2.40324e-08 1.82807e-08 1.38714e-08 1.05026e-08 7.93215e-09 5.97518e-09 4.49105e-09 3.37016e-09 2.52485e-09 1.88683e-09 1.40607e-09 1.04528e-09 7.75539e-10 5.74491e-10 4.24909e-10 3.13638e-10 2.30958e-10 1.69742e-10 1.24587e-10 9.13488e-11 6.68864e-11 4.88703e-11 3.56121e-11 2.58897e-11 1.8794e-11 1.36361e-11 9.89525e-12 7.18306e-12 5.216e-12 3.79081e-12 2.76076e-12 2.01743e-12 1.4794e-12 1.08775e-12 8.01686e-13 5.92876e-13 4.40863e-13 3.30335e-13 2.49746e-13 1.90571e-13 1.46864e-13 1.14425e-13 9.02683e-14 7.21998e-14 5.85086e-14 4.81024e-14 4.00666e-14 3.39119e-14 2.92319e-14 2.55477e-14 2.27261e-14 2.05748e-14 1.88234e-14 1.7525e-14 1.66222e-14 1.57667e-14 1.54146e-14 1.54379e-14 1.56622e-14 1.61609e-14 1.75036e-14 1.90166e-14 2.29104e-14 2.69968e-14 3.77478e-14 5.04513e-14 8.2288e-14 1.31538e-13 2.36717e-13 4.63399e-13 9.34262e-13 2.07142e-12 4.47378e-12 1.02551e-11 2.3153e-11 5.20143e-11 1.17007e-10 2.569e-10 5.48718e-10 1.17057e-09 0.276702 0.184931 0.332049 0.328307 0.242809 0.142514 0.075554 0.0439603 0.0371548 0.0372421 0.04181 0.0618235 0.110459 0.136705 0.16573 0.21687 0.228229 0.228251 0.229035 0.234235 0.237764 0.238199 0.235238 0.223854 0.22194 0.222563 0.221035 0.204844 0.193304 0.198261 0.198395 0.197503 0.191423 0.170475 0.115864 0.0576589 0.0291194 0.020422 0.0159744 0.0150222 0.015581 0.0194851 0.0245582 0.0261219 0.0263564 0.0273221 0.0281182 0.0274771 0.0244149 0.0188673 0.0153337 0.0131548 0.0118951 0.0117051 0.0120051 0.0127008 0.0128263 0.0124332 0.0107823 0.0068897 0.00390271 0.00211792 0.0011383 0.000631514 0.000373079 0.000237011 0.000160174 0.000113015 8.19519e-05 6.04801e-05 4.51894e-05 3.40928e-05 2.593e-05 1.9858e-05 1.52951e-05 1.18331e-05 9.18295e-06 7.13916e-06 5.55693e-06 4.33267e-06 3.3866e-06 2.65594e-06 2.09072e-06 1.65018e-06 1.30373e-06 1.0294e-06 8.11154e-07 6.37768e-07 5.0038e-07 3.91703e-07 3.05895e-07 2.38302e-07 1.85223e-07 1.43639e-07 1.11116e-07 8.57433e-08 6.60149e-08 5.07079e-08 3.88548e-08 2.97044e-08 2.26518e-08 1.72279e-08 1.30739e-08 9.90172e-09 7.48188e-09 5.63866e-09 4.23797e-09 3.17839e-09 2.37974e-09 1.77797e-09 1.32518e-09 9.84989e-10 7.30255e-10 5.40588e-10 3.99871e-10 2.95499e-10 2.17959e-10 1.60331e-10 1.176e-10 8.60476e-11 6.28588e-11 4.5876e-11 3.34576e-11 2.43814e-11 1.77533e-11 1.2921e-11 9.40233e-12 6.83914e-12 4.97041e-12 3.60965e-12 2.62215e-12 1.90794e-12 1.39186e-12 1.01836e-12 7.47619e-13 5.51503e-13 4.09596e-13 3.06743e-13 2.31892e-13 1.77039e-13 1.36567e-13 1.06543e-13 8.41845e-14 6.74716e-14 5.48267e-14 4.52303e-14 3.78267e-14 3.21395e-14 2.78034e-14 2.44273e-14 2.18552e-14 1.98344e-14 1.82884e-14 1.72079e-14 1.6318e-14 1.56453e-14 1.55461e-14 1.56359e-14 1.60127e-14 1.67055e-14 1.84059e-14 2.02605e-14 2.47694e-14 2.96477e-14 4.15915e-14 5.63564e-14 9.06101e-14 1.45829e-13 2.58935e-13 5.02809e-13 9.99024e-13 2.1792e-12 4.64957e-12 1.04938e-11 2.33795e-11 5.20536e-11 1.15534e-10 2.51812e-10 5.32637e-10 1.12803e-09 0.254687 0.176941 0.244436 0.267314 0.231556 0.15521 0.0966784 0.0647645 0.0482413 0.0439864 0.0487426 0.0739177 0.084256 0.0938082 0.13429 0.184514 0.199318 0.213785 0.217592 0.217959 0.222184 0.228186 0.223894 0.216824 0.214858 0.213823 0.207279 0.185928 0.182053 0.186122 0.19656 0.20037 0.190949 0.145724 0.0847179 0.0456691 0.0237943 0.018521 0.0156368 0.0144399 0.0151065 0.0192299 0.025707 0.028874 0.0289407 0.0284575 0.0286076 0.0285901 0.0265669 0.0196982 0.0141943 0.0117151 0.0104673 0.00998233 0.0100567 0.0108029 0.0117073 0.0119141 0.0114654 0.00938311 0.00593104 0.00332566 0.00174481 0.000909031 0.000493473 0.000288361 0.000183063 0.00012434 8.83071e-05 6.43983e-05 4.77087e-05 3.57121e-05 2.69424e-05 2.04608e-05 1.56289e-05 1.19989e-05 9.25151e-06 7.15786e-06 5.55201e-06 4.31267e-06 3.35213e-06 2.60686e-06 2.02937e-06 1.5822e-06 1.23611e-06 9.67951e-07 7.59642e-07 5.96733e-07 4.68474e-07 3.67055e-07 2.86891e-07 2.23718e-07 1.74022e-07 1.3503e-07 1.04521e-07 8.06987e-08 6.21539e-08 4.77572e-08 3.66029e-08 2.79856e-08 2.13442e-08 1.62413e-08 1.23324e-08 9.34069e-09 7.05652e-09 5.31817e-09 3.99848e-09 2.99895e-09 2.24391e-09 1.67533e-09 1.2479e-09 9.27416e-10 6.87881e-10 5.09202e-10 3.7612e-10 2.77271e-10 2.04157e-10 1.50235e-10 1.10512e-10 8.1204e-11 5.95123e-11 4.34483e-11 3.16015e-11 2.29247e-11 1.66106e-11 1.20369e-11 8.73013e-12 6.3387e-12 4.60884e-12 3.35823e-12 2.45391e-12 1.79791e-12 1.31934e-12 9.68852e-13 7.12328e-13 5.25339e-13 3.89696e-13 2.9138e-13 2.19803e-13 1.67339e-13 1.28755e-13 1.00289e-13 7.91777e-14 6.34454e-14 5.15539e-14 4.25438e-14 3.56368e-14 3.03325e-14 2.62858e-14 2.31558e-14 2.07654e-14 1.88648e-14 1.74534e-14 1.64802e-14 1.56415e-14 1.51016e-14 1.50664e-14 1.51772e-14 1.5596e-14 1.63309e-14 1.806e-14 2.0001e-14 2.44735e-14 2.95819e-14 4.1188e-14 5.67407e-14 8.9644e-14 1.47454e-13 2.59773e-13 5.06324e-13 1.00268e-12 2.17549e-12 4.63154e-12 1.03837e-11 2.30107e-11 5.10368e-11 1.12362e-10 2.43905e-10 5.12648e-10 1.07153e-09 0.249217 0.175165 0.195444 0.219518 0.213279 0.16207 0.115758 0.0826626 0.0651408 0.0659232 0.0786869 0.0784366 0.0763723 0.0852671 0.120681 0.130464 0.149067 0.178752 0.181679 0.180066 0.187938 0.193897 0.192582 0.192816 0.192309 0.187661 0.174199 0.171219 0.175315 0.188949 0.215265 0.208041 0.178627 0.101099 0.0440663 0.0234568 0.0153464 0.0130411 0.0130779 0.0130942 0.0141123 0.0172085 0.0224232 0.0274606 0.0288639 0.028342 0.0282509 0.028718 0.0274619 0.0213215 0.0143556 0.0108179 0.00962354 0.00917995 0.00914368 0.00940528 0.00975846 0.0101236 0.0102785 0.00968454 0.00706271 0.00430759 0.00244324 0.00130086 0.000679392 0.000369664 0.000218647 0.000140712 9.66434e-05 6.91798e-05 5.07235e-05 3.77193e-05 2.83046e-05 2.13789e-05 1.62314e-05 1.23769e-05 9.47424e-06 7.2781e-06 5.6086e-06 4.33361e-06 3.35541e-06 2.60155e-06 2.0185e-06 1.56639e-06 1.21541e-06 9.433e-07 7.32536e-07 5.69364e-07 4.4307e-07 3.45206e-07 2.69151e-07 2.09768e-07 1.63289e-07 1.26873e-07 9.83116e-08 7.59604e-08 5.85523e-08 4.50246e-08 3.45348e-08 2.64225e-08 2.01636e-08 1.53481e-08 1.16545e-08 8.82958e-09 6.67257e-09 5.02884e-09 3.78078e-09 2.83632e-09 2.12282e-09 1.58453e-09 1.17963e-09 8.76308e-10 6.49723e-10 4.80705e-10 3.54928e-10 2.61459e-10 1.92131e-10 1.4091e-10 1.03243e-10 7.56325e-11 5.54046e-11 4.05694e-11 2.96748e-11 2.1668e-11 1.5783e-11 1.14654e-11 8.30642e-12 6.00184e-12 4.32778e-12 3.11899e-12 2.25108e-12 1.62976e-12 1.18458e-12 8.64452e-13 6.33548e-13 4.66766e-13 3.46057e-13 2.58501e-13 1.9479e-13 1.48055e-13 1.13621e-13 8.82538e-14 6.95003e-14 5.56066e-14 4.51701e-14 3.73046e-14 3.13492e-14 2.67805e-14 2.32965e-14 2.06399e-14 1.85772e-14 1.69618e-14 1.58545e-14 1.50234e-14 1.43278e-14 1.40773e-14 1.41169e-14 1.43066e-14 1.48426e-14 1.56755e-14 1.74588e-14 1.95245e-14 2.42219e-14 2.9645e-14 4.09664e-14 5.74386e-14 8.95375e-14 1.51048e-13 2.63938e-13 5.14376e-13 1.01645e-12 2.1968e-12 4.65225e-12 1.03712e-11 2.28479e-11 5.04157e-11 1.10238e-10 2.38492e-10 4.98697e-10 1.03198e-09 0.258503 0.198952 0.188187 0.203008 0.208265 0.177189 0.147499 0.118456 0.10791 0.106597 0.094324 0.0790244 0.0773933 0.0868815 0.097422 0.111117 0.133238 0.139108 0.141542 0.154889 0.161711 0.158299 0.15432 0.154387 0.159681 0.163859 0.16672 0.175105 0.191417 0.225821 0.222556 0.192726 0.116364 0.0543595 0.024953 0.0145808 0.0118535 0.0112928 0.0115206 0.0124639 0.0146977 0.0182326 0.0208203 0.0239046 0.0256931 0.0256708 0.0252568 0.024365 0.024114 0.0212376 0.0143593 0.0102056 0.00897241 0.00884899 0.00884425 0.00902504 0.00912429 0.00897332 0.00863205 0.00834604 0.00704224 0.00448488 0.00265651 0.0015087 0.000835203 0.000460554 0.000262655 0.00016159 0.000107192 7.50274e-05 5.42727e-05 4.00237e-05 2.98696e-05 2.24737e-05 1.70096e-05 1.29309e-05 9.86313e-06 7.54241e-06 5.77998e-06 4.43774e-06 3.41342e-06 2.63036e-06 2.03027e-06 1.56909e-06 1.21372e-06 9.39076e-07 7.26498e-07 5.61823e-07 4.34215e-07 3.35477e-07 2.59136e-07 2.00171e-07 1.54641e-07 1.19468e-07 9.22827e-08 7.12403e-08 5.49304e-08 4.22838e-08 3.24742e-08 2.4873e-08 1.89982e-08 1.44745e-08 1.10027e-08 8.34252e-09 6.30774e-09 4.75621e-09 3.57801e-09 2.68543e-09 2.01079e-09 1.5021e-09 1.11916e-09 8.31494e-10 6.16267e-10 4.55886e-10 3.36676e-10 2.48118e-10 1.82383e-10 1.33719e-10 9.78233e-11 7.14522e-11 5.21295e-11 3.79988e-11 2.76914e-11 2.01952e-11 1.47475e-11 1.07768e-11 7.8743e-12 5.74842e-12 4.19299e-12 3.05806e-12 2.23164e-12 1.62924e-12 1.1895e-12 8.68841e-13 6.35806e-13 4.67384e-13 3.45981e-13 2.58134e-13 1.94394e-13 1.48005e-13 1.14006e-13 8.8893e-14 7.01829e-14 5.62492e-14 4.57838e-14 3.78893e-14 3.19419e-14 2.73799e-14 2.38725e-14 2.12112e-14 1.91427e-14 1.74911e-14 1.63629e-14 1.55189e-14 1.48254e-14 1.46068e-14 1.46538e-14 1.48649e-14 1.53573e-14 1.65408e-14 1.79513e-14 2.09408e-14 2.44177e-14 3.18804e-14 4.12104e-14 6.21943e-14 9.19287e-14 1.57987e-13 2.70851e-13 5.26815e-13 1.02963e-12 2.21381e-12 4.67102e-12 1.03609e-11 2.27348e-11 4.99599e-11 1.08767e-10 2.34744e-10 4.88616e-10 1.00584e-09 0.271982 0.320273 0.329106 0.27681 0.251218 0.23256 0.205146 0.17997 0.164222 0.148997 0.11825 0.0929699 0.0882554 0.092735 0.104291 0.115059 0.119329 0.125056 0.138964 0.144399 0.142301 0.132673 0.128053 0.129332 0.143262 0.164886 0.185871 0.227482 0.247098 0.23979 0.203302 0.109646 0.0525743 0.0261428 0.0145358 0.0109294 0.0101552 0.0101888 0.0108233 0.0128813 0.0177176 0.022643 0.0247098 0.0251226 0.0256468 0.0256962 0.0253285 0.0238912 0.0210909 0.0180082 0.0134783 0.00972628 0.00817335 0.00812427 0.00855843 0.00886599 0.00893514 0.00878769 0.00787207 0.00698346 0.00578526 0.00412803 0.00261062 0.00153233 0.00087313 0.00050111 0.000295645 0.000181494 0.000118448 8.16634e-05 5.84253e-05 4.27378e-05 3.16836e-05 2.37034e-05 1.786e-05 1.35365e-05 1.03075e-05 7.87515e-06 6.0296e-06 4.62203e-06 3.54559e-06 2.72118e-06 2.08941e-06 1.60519e-06 1.23389e-06 9.4918e-07 7.30719e-07 5.62828e-07 4.33583e-07 3.33939e-07 2.57065e-07 1.97754e-07 1.51972e-07 1.16642e-07 8.94456e-08 6.85405e-08 5.24797e-08 4.01445e-08 3.06704e-08 2.34045e-08 1.7846e-08 1.35921e-08 1.03313e-08 7.83449e-09 5.92711e-09 4.47282e-09 3.36737e-09 2.52918e-09 1.89465e-09 1.41546e-09 1.05444e-09 7.83598e-10 5.81239e-10 4.30176e-10 3.17387e-10 2.33463e-10 1.71388e-10 1.2566e-10 9.19988e-11 6.72129e-11 4.89691e-11 3.55673e-11 2.57628e-11 1.86276e-11 1.3469e-11 9.7516e-12 7.06994e-12 5.13243e-12 3.73023e-12 2.71473e-12 1.97922e-12 1.44655e-12 1.06032e-12 7.80109e-13 5.76531e-13 4.28046e-13 3.19455e-13 2.39782e-13 1.81106e-13 1.37857e-13 1.06083e-13 8.27167e-14 6.54011e-14 5.24583e-14 4.26845e-14 3.53152e-14 2.97743e-14 2.55287e-14 2.22836e-14 1.98198e-14 1.78941e-14 1.64174e-14 1.54118e-14 1.46027e-14 1.40257e-14 1.39179e-14 1.3988e-14 1.42365e-14 1.47672e-14 1.6008e-14 1.74191e-14 2.0528e-14 2.39035e-14 3.16843e-14 4.08252e-14 6.22359e-14 9.13808e-14 1.58853e-13 2.70912e-13 5.25683e-13 1.02578e-12 2.20282e-12 4.64481e-12 1.02755e-11 2.25682e-11 4.94402e-11 1.07373e-10 2.32106e-10 4.80964e-10 9.86892e-10 0.394343 0.50921 0.747471 0.798784 0.768684 0.656814 0.553502 0.447055 0.365483 0.328842 0.269732 0.192422 0.150002 0.137154 0.140361 0.149714 0.150884 0.152248 0.159621 0.162139 0.158668 0.156252 0.150474 0.151953 0.182134 0.239531 0.253545 0.257995 0.244461 0.194365 0.0930416 0.0459925 0.0243856 0.0140591 0.0103577 0.00959343 0.00974947 0.00982895 0.010355 0.0129927 0.0187832 0.0234439 0.0260383 0.0262539 0.0261063 0.0262451 0.0259236 0.0242413 0.0202493 0.0169367 0.0129362 0.00929328 0.00745578 0.00722192 0.00782946 0.0087515 0.00889461 0.0087518 0.00773918 0.00582479 0.00448766 0.00336525 0.00229635 0.00143946 0.000856991 0.000504764 0.000305556 0.000193459 0.000127571 8.79786e-05 6.27932e-05 4.58128e-05 3.386e-05 2.52288e-05 1.89133e-05 1.42578e-05 1.08055e-05 8.22808e-06 6.28959e-06 4.82112e-06 3.70152e-06 2.84368e-06 2.18435e-06 1.67682e-06 1.28625e-06 9.86084e-07 7.55563e-07 5.78723e-07 4.43171e-07 3.39321e-07 2.59824e-07 1.98948e-07 1.5229e-07 1.16513e-07 8.90813e-08 6.80465e-08 5.19168e-08 3.95599e-08 3.00966e-08 2.28574e-08 1.73328e-08 1.31252e-08 9.92551e-09 7.49376e-09 5.64639e-09 4.24656e-09 3.18915e-09 2.39145e-09 1.78958e-09 1.33607e-09 9.95263e-10 7.39766e-10 5.48731e-10 4.06215e-10 3.00033e-10 2.21047e-10 1.62408e-10 1.19031e-10 8.70616e-11 6.35531e-11 4.63154e-11 3.3709e-11 2.45012e-11 1.77779e-11 1.28753e-11 9.30614e-12 6.70827e-12 4.82407e-12 3.46387e-12 2.4865e-12 1.78656e-12 1.28648e-12 9.29834e-13 6.75571e-13 4.94116e-13 3.63904e-13 2.69698e-13 2.01201e-13 1.51294e-13 1.1482e-13 8.81645e-14 6.8666e-14 5.43553e-14 4.38034e-14 3.59352e-14 3.00362e-14 2.56121e-14 2.22785e-14 1.97454e-14 1.77814e-14 1.6333e-14 1.53083e-14 1.45023e-14 1.39454e-14 1.38056e-14 1.38524e-14 1.40206e-14 1.44703e-14 1.51369e-14 1.66064e-14 1.81482e-14 2.16006e-14 2.52135e-14 3.35772e-14 4.29881e-14 6.57341e-14 9.55904e-14 1.67416e-13 2.81805e-13 5.44968e-13 1.05298e-12 2.24728e-12 4.70645e-12 1.04179e-11 2.27136e-11 4.97069e-11 1.07778e-10 2.32379e-10 4.79953e-10 9.83664e-10 1.40817 1.10442 1.09982 1.10773 1.11653 1.08705 1.03602 0.977475 0.859258 0.797256 0.761528 0.667813 0.485758 0.361223 0.341235 0.364701 0.365785 0.339603 0.347658 0.351794 0.349225 0.346695 0.327286 0.328436 0.322001 0.295506 0.273125 0.229276 0.124708 0.063527 0.0370879 0.0217302 0.0127051 0.00907796 0.00859296 0.00889038 0.00898238 0.00907337 0.00967153 0.0124712 0.0211084 0.0246473 0.0257911 0.0254574 0.0247968 0.02493 0.0247518 0.0232299 0.0185156 0.0149333 0.0114669 0.00849174 0.00690898 0.00658788 0.00702311 0.00854017 0.00898348 0.00883585 0.00781124 0.00557327 0.0038235 0.00264919 0.00183962 0.00122384 0.000775421 0.00048175 0.000302698 0.000196957 0.000133226 9.29858e-05 6.67083e-05 4.87649e-05 3.6072e-05 2.68787e-05 2.01282e-05 1.51351e-05 1.14259e-05 8.66098e-06 6.59183e-06 5.03574e-06 3.85885e-06 2.96347e-06 2.27846e-06 1.75236e-06 1.34732e-06 1.03503e-06 7.94217e-07 6.08574e-07 4.65629e-07 3.558e-07 2.71554e-07 2.0701e-07 1.5766e-07 1.19978e-07 9.12332e-08 6.933e-08 5.26484e-08 3.99441e-08 3.02675e-08 2.29079e-08 1.73215e-08 1.3083e-08 9.86594e-09 7.4246e-09 5.57743e-09 4.18405e-09 3.13377e-09 2.34285e-09 1.74791e-09 1.30124e-09 9.66943e-10 7.1724e-10 5.31043e-10 3.92445e-10 2.89372e-10 2.12869e-10 1.56305e-10 1.14641e-10 8.40014e-11 6.145e-11 4.485e-11 3.26644e-11 2.3754e-11 1.72617e-11 1.25377e-11 9.10454e-12 6.61285e-12 4.80546e-12 3.4957e-12 2.54683e-12 1.85836e-12 1.35709e-12 9.91814e-13 7.2628e-13 5.34101e-13 3.95533e-13 2.95517e-13 2.23028e-13 1.70368e-13 1.31929e-13 1.03573e-13 8.24262e-14 6.64528e-14 5.44499e-14 4.542e-14 3.8501e-14 3.32356e-14 2.9175e-14 2.60436e-14 2.36537e-14 2.17856e-14 2.03697e-14 1.93394e-14 1.84836e-14 1.79567e-14 1.78882e-14 1.79744e-14 1.83627e-14 1.90112e-14 2.05488e-14 2.21525e-14 2.56509e-14 2.94543e-14 3.85787e-14 4.81863e-14 7.26181e-14 1.02291e-13 1.81006e-13 2.91705e-13 5.63809e-13 1.06685e-12 2.246e-12 4.65556e-12 1.03775e-11 2.23698e-11 4.90572e-11 1.06886e-10 2.29377e-10 4.72389e-10 9.82222e-10 1.73201 1.53596 1.35511 1.19666 1.13828 1.10993 1.06328 1.01681 0.940063 0.887606 0.878578 0.867417 0.839982 0.766675 0.6874 0.677029 0.665098 0.647469 0.622919 0.5662 0.524689 0.458961 0.427664 0.407629 0.349267 0.268571 0.1831 0.0996396 0.0504271 0.0288352 0.0197044 0.0118594 0.00797595 0.00755991 0.00772507 0.00862029 0.00875566 0.0088926 0.00954004 0.0115665 0.0203193 0.0267712 0.0268392 0.0253801 0.0230032 0.0229121 0.0231849 0.0218809 0.016698 0.0124858 0.00995263 0.00788197 0.00667893 0.00632994 0.00648851 0.00803641 0.00911108 0.009102 0.00817174 0.00567006 0.0037027 0.00235538 0.00149915 0.000975422 0.000646486 0.000429652 0.000287107 0.000195156 0.000136263 9.73833e-05 7.07353e-05 5.2007e-05 3.85643e-05 2.87674e-05 2.15546e-05 1.62089e-05 1.22292e-05 9.25672e-06 7.02986e-06 5.35625e-06 4.09362e-06 3.13682e-06 2.40863e-06 1.85219e-06 1.42546e-06 1.0973e-06 8.44373e-07 6.49172e-07 4.98591e-07 3.82487e-07 2.93023e-07 2.24136e-07 1.71122e-07 1.304e-07 9.92078e-08 7.53784e-08 5.7189e-08 4.33098e-08 3.27478e-08 2.47301e-08 1.86513e-08 1.40454e-08 1.05576e-08 7.92172e-09 5.93424e-09 4.43812e-09 3.31382e-09 2.47045e-09 1.83816e-09 1.36456e-09 1.01104e-09 7.47783e-10 5.51993e-10 4.06709e-10 2.9907e-10 2.19473e-10 1.60761e-10 1.17516e-10 8.57213e-11 6.2406e-11 4.53563e-11 3.29245e-11 2.3879e-11 1.73023e-11 1.25221e-11 9.05047e-12 6.53321e-12 4.71116e-12 3.3962e-12 2.44953e-12 1.7689e-12 1.27988e-12 9.28882e-13 6.77234e-13 4.96357e-13 3.6563e-13 2.70747e-13 2.01753e-13 1.51568e-13 1.15031e-13 8.84052e-14 6.88502e-14 5.42917e-14 4.34587e-14 3.54297e-14 2.94755e-14 2.50151e-14 2.16098e-14 1.90551e-14 1.70896e-14 1.55831e-14 1.45612e-14 1.37977e-14 1.31497e-14 1.28601e-14 1.28703e-14 1.29906e-14 1.33214e-14 1.39215e-14 1.53023e-14 1.6749e-14 1.98265e-14 2.31424e-14 3.08203e-14 3.96435e-14 6.09217e-14 8.85973e-14 1.57104e-13 2.6406e-13 5.14107e-13 1.00044e-12 2.15636e-12 4.52203e-12 1.01682e-11 2.21167e-11 4.86955e-11 1.06271e-10 2.29156e-10 4.73531e-10 9.78098e-10 1.24914 1.16206 1.10915 0.991652 0.835889 0.757785 0.745603 0.747758 0.724408 0.636716 0.584708 0.571599 0.568427 0.568362 0.563367 0.541958 0.523727 0.498389 0.424019 0.385285 0.358383 0.293027 0.236361 0.204503 0.147353 0.0914109 0.056748 0.0368561 0.0210196 0.0141816 0.0107799 0.00719385 0.0059621 0.00684771 0.00730286 0.00719015 0.00753461 0.00882137 0.0101857 0.0122305 0.0191306 0.0272006 0.0281758 0.0268369 0.0233113 0.0210098 0.0205236 0.0199135 0.015803 0.0115494 0.00953842 0.00783148 0.00667888 0.00629918 0.00631829 0.00715345 0.00897874 0.00929013 0.00873418 0.00619968 0.00380304 0.00231494 0.00140395 0.000863253 0.000552653 0.000371822 0.000260729 0.000187581 0.000136693 0.000100289 7.40527e-05 5.49573e-05 4.09411e-05 3.05925e-05 2.29215e-05 1.72189e-05 1.29694e-05 9.79545e-06 7.41952e-06 5.63638e-06 4.29393e-06 3.27984e-06 2.51102e-06 1.92604e-06 1.47943e-06 1.13729e-06 8.74459e-07 6.72243e-07 5.16531e-07 3.96575e-07 3.0418e-07 2.32999e-07 1.78197e-07 1.36083e-07 1.03772e-07 7.90106e-08 6.00435e-08 4.55453e-08 3.44915e-08 2.60725e-08 1.96731e-08 1.48194e-08 1.11416e-08 8.35843e-09 6.25794e-09 4.67812e-09 3.49184e-09 2.60121e-09 1.93324e-09 1.43348e-09 1.0609e-09 7.83874e-10 5.78121e-10 4.25468e-10 3.12343e-10 2.28675e-10 1.67013e-10 1.21768e-10 8.86827e-11 6.45023e-11 4.68077e-11 3.38751e-11 2.44626e-11 1.76378e-11 1.26981e-11 9.12773e-12 6.55296e-12 4.70205e-12 3.37544e-12 2.42571e-12 1.7447e-12 1.25523e-12 9.03511e-13 6.5146e-13 4.7123e-13 3.4244e-13 2.5022e-13 1.84102e-13 1.36756e-13 1.02821e-13 7.83619e-14 6.05986e-14 4.76219e-14 3.80212e-14 3.09184e-14 2.56634e-14 2.17339e-14 1.88071e-14 1.66143e-14 1.49013e-14 1.36088e-14 1.27362e-14 1.20558e-14 1.1562e-14 1.14281e-14 1.14601e-14 1.15963e-14 1.19268e-14 1.25122e-14 1.38486e-14 1.51853e-14 1.81065e-14 2.13076e-14 2.86655e-14 3.71727e-14 5.70327e-14 8.44939e-14 1.47152e-13 2.55676e-13 4.97203e-13 9.87407e-13 2.13664e-12 4.51262e-12 1.01581e-11 2.22631e-11 4.91595e-11 1.07403e-10 2.32121e-10 4.81995e-10 9.91684e-10 0.649249 0.5922 0.56755 0.564689 0.531962 0.40249 0.354678 0.351993 0.352117 0.339523 0.307696 0.279068 0.238828 0.223596 0.218705 0.206875 0.204111 0.194727 0.155791 0.12525 0.111146 0.0931286 0.0691286 0.0549721 0.0440246 0.0295189 0.0203196 0.0147515 0.00994407 0.00742566 0.00591532 0.00526065 0.00543395 0.00627646 0.00691709 0.00674148 0.00696982 0.00883997 0.012953 0.0159561 0.0204118 0.025068 0.0274478 0.0269966 0.0240869 0.0211416 0.0187097 0.0159036 0.0124003 0.0103129 0.00927326 0.00811273 0.00697225 0.00644722 0.00637946 0.0066883 0.00842548 0.00932979 0.00917292 0.00734499 0.00431128 0.00246552 0.00142573 0.000851121 0.000533853 0.000355918 0.000251106 0.000183946 0.00013727 0.000103198 7.76045e-05 5.82908e-05 4.37503e-05 3.28365e-05 2.4662e-05 1.8545e-05 1.39671e-05 1.05386e-05 7.96813e-06 6.0379e-06 4.58584e-06 3.49117e-06 2.66389e-06 2.037e-06 1.56047e-06 1.19704e-06 9.19109e-07 7.06031e-07 5.42378e-07 4.16524e-07 3.1961e-07 2.44955e-07 1.87491e-07 1.43321e-07 1.09401e-07 8.3373e-08 6.3431e-08 4.81704e-08 3.65082e-08 2.76217e-08 2.08622e-08 1.57218e-08 1.18175e-08 8.86242e-09 6.63371e-09 4.95647e-09 3.69541e-09 2.74861e-09 2.04013e-09 1.51141e-09 1.1175e-09 8.24659e-10 6.07192e-10 4.45922e-10 3.26722e-10 2.38922e-10 1.7443e-10 1.27129e-10 9.2447e-11 6.70529e-11 4.85217e-11 3.50522e-11 2.52903e-11 1.82238e-11 1.31118e-11 9.42048e-12 6.76169e-12 4.84986e-12 3.4766e-12 2.49115e-12 1.78521e-12 1.28083e-12 9.21457e-13 6.65651e-13 4.83101e-13 3.5221e-13 2.58137e-13 1.90565e-13 1.42049e-13 1.0712e-13 8.18345e-14 6.33761e-14 4.9833e-14 3.98316e-14 3.24652e-14 2.70142e-14 2.29064e-14 1.98301e-14 1.75098e-14 1.57384e-14 1.4458e-14 1.35916e-14 1.28875e-14 1.23475e-14 1.21926e-14 1.22242e-14 1.23654e-14 1.26932e-14 1.33712e-14 1.45834e-14 1.58814e-14 1.87254e-14 2.1912e-14 2.84062e-14 3.71769e-14 5.49517e-14 8.33347e-14 1.3871e-13 2.46962e-13 4.81893e-13 9.60696e-13 2.10444e-12 4.45151e-12 1.00898e-11 2.23478e-11 4.94633e-11 1.08762e-10 2.36418e-10 4.93155e-10 1.02106e-09 0.216664 0.185781 0.167806 0.17336 0.175604 0.153606 0.115689 0.111103 0.116786 0.116913 0.108915 0.0992464 0.083711 0.0706054 0.0604344 0.0546113 0.0533981 0.0516571 0.0453221 0.0332135 0.0282888 0.0260634 0.0207631 0.0168029 0.0143577 0.0107542 0.00788173 0.00655226 0.00547497 0.00445208 0.00415882 0.0044492 0.00565032 0.00569745 0.00590214 0.00639739 0.00726439 0.00998236 0.0162794 0.0202457 0.0220621 0.0234319 0.0242299 0.0248637 0.0247055 0.0222393 0.0187037 0.0145762 0.0106315 0.00828024 0.00786036 0.00790336 0.00736921 0.00680407 0.0066864 0.00675946 0.0076699 0.00913098 0.0092652 0.00851304 0.00545342 0.00299554 0.00164258 0.000927564 0.000556498 0.000361295 0.00025208 0.000184965 0.000139562 0.000106307 8.09419e-05 6.13982e-05 4.64008e-05 3.49792e-05 2.63386e-05 1.98312e-05 1.49422e-05 1.12715e-05 8.51431e-06 6.44103e-06 4.87992e-06 3.70294e-06 2.81446e-06 2.14279e-06 1.63409e-06 1.24801e-06 9.54366e-07 7.30574e-07 5.59695e-07 4.28927e-07 3.28676e-07 2.5175e-07 1.92697e-07 1.4737e-07 1.12577e-07 8.58783e-08 6.54e-08 4.97073e-08 3.77187e-08 2.85795e-08 2.16159e-08 1.63176e-08 1.22936e-08 9.24178e-09 6.93174e-09 5.18772e-09 3.87406e-09 2.88654e-09 2.14592e-09 1.5915e-09 1.17753e-09 8.69466e-10 6.4058e-10 4.70737e-10 3.45078e-10 2.5237e-10 1.8414e-10 1.34063e-10 9.74025e-11 7.06239e-11 5.11006e-11 3.68955e-11 2.65928e-11 1.91446e-11 1.37672e-11 9.8851e-12 7.08564e-12 5.07266e-12 3.63034e-12 2.59946e-12 1.8628e-12 1.33666e-12 9.61659e-13 6.94632e-13 5.03943e-13 3.67308e-13 2.6931e-13 1.99069e-13 1.48772e-13 1.127e-13 8.66401e-14 6.76192e-14 5.36465e-14 4.33414e-14 3.57758e-14 3.0177e-14 2.59696e-14 2.28063e-14 2.03891e-14 1.85439e-14 1.72138e-14 1.63258e-14 1.56417e-14 1.51355e-14 1.50004e-14 1.50373e-14 1.52194e-14 1.57557e-14 1.64713e-14 1.78238e-14 2.02362e-14 2.25812e-14 2.77038e-14 3.38231e-14 4.59203e-14 6.34616e-14 9.77496e-14 1.58438e-13 2.758e-13 5.26135e-13 1.03339e-12 2.23217e-12 4.69557e-12 1.05118e-11 2.33968e-11 5.14053e-11 1.13166e-10 2.4665e-10 5.1452e-10 1.07783e-09 0.0522207 0.040693 0.0320145 0.0324053 0.0371357 0.0357075 0.0256997 0.023912 0.0277347 0.0301142 0.0284391 0.0251282 0.0234056 0.0194759 0.0157227 0.0133365 0.0125382 0.0124285 0.0116156 0.00850282 0.00699418 0.00663719 0.00608394 0.00524889 0.00492681 0.00427135 0.00349819 0.00341531 0.00368785 0.00376788 0.00386766 0.00414486 0.00506183 0.00559273 0.00600352 0.00702815 0.00877273 0.0118877 0.0179888 0.0226389 0.0237436 0.0236669 0.0237837 0.0240867 0.0238597 0.0222519 0.0188359 0.0142793 0.0102305 0.00779407 0.00684924 0.00686438 0.00719423 0.00718018 0.00715534 0.0071877 0.00746735 0.0085898 0.00908647 0.00882455 0.00706199 0.00402853 0.00219436 0.0011945 0.000675458 0.000410644 0.000272629 0.000195066 0.000146046 0.000111462 8.53824e-05 6.52172e-05 4.9596e-05 3.75742e-05 2.83946e-05 2.14299e-05 1.6169e-05 1.22047e-05 9.22008e-06 6.97214e-06 5.27745e-06 3.99847e-06 3.03225e-06 2.3016e-06 1.74856e-06 1.32953e-06 1.01176e-06 7.70568e-07 5.87268e-07 4.47784e-07 3.41512e-07 2.60474e-07 1.98645e-07 1.51444e-07 1.15387e-07 8.78216e-08 6.67471e-08 5.06597e-08 3.8401e-08 2.90654e-08 2.19616e-08 1.65647e-08 1.24705e-08 9.36997e-09 7.02812e-09 5.2624e-09 3.93238e-09 2.9317e-09 2.18025e-09 1.61782e-09 1.1982e-09 8.85621e-10 6.52947e-10 4.80058e-10 3.52019e-10 2.57548e-10 1.88068e-10 1.37066e-10 9.96564e-11 7.22643e-11 5.2278e-11 3.77512e-11 2.72219e-11 1.96013e-11 1.40894e-11 1.01078e-11 7.23927e-12 5.1798e-12 3.70501e-12 2.6492e-12 1.89275e-12 1.35247e-12 9.68767e-13 6.96653e-13 5.03077e-13 3.64682e-13 2.65645e-13 1.94914e-13 1.4443e-13 1.08265e-13 8.21633e-14 6.31979e-14 4.93971e-14 3.94133e-14 3.21207e-14 2.67555e-14 2.27394e-14 1.96918e-14 1.74296e-14 1.57557e-14 1.45149e-14 1.35957e-14 1.29566e-14 1.24576e-14 1.20809e-14 1.19875e-14 1.20456e-14 1.21924e-14 1.25497e-14 1.31008e-14 1.43113e-14 1.56276e-14 1.86172e-14 2.20471e-14 3.00748e-14 4.05716e-14 6.51124e-14 1.04918e-13 1.92387e-13 3.81064e-13 7.85945e-13 1.77996e-12 3.91928e-12 9.05987e-12 2.09519e-11 4.72421e-11 1.0617e-10 2.36076e-10 5.01484e-10 1.06842e-09 0.0073686 0.00527801 0.00368144 0.00372132 0.00519605 0.0056468 0.00436817 0.00410297 0.00530752 0.0063943 0.00601279 0.0053934 0.00519757 0.00464947 0.00372612 0.00302922 0.00277614 0.0027811 0.00272607 0.00231202 0.00201205 0.00203192 0.00210892 0.00208652 0.00215553 0.00240898 0.00243075 0.00255475 0.00328542 0.00362235 0.00380272 0.00425582 0.00468507 0.00541609 0.00712331 0.00962307 0.0130807 0.0161237 0.020302 0.0237176 0.0242283 0.0236975 0.0237446 0.024631 0.0242545 0.0212879 0.0162577 0.0132283 0.00999402 0.00757164 0.00656401 0.00637751 0.0066525 0.00732335 0.00760379 0.00776657 0.00784926 0.00811862 0.00850396 0.00850736 0.00780032 0.00540772 0.00313702 0.00173162 0.000954787 0.000545641 0.000335214 0.000224215 0.000160622 0.000119811 9.09416e-05 6.9335e-05 5.28062e-05 4.01161e-05 3.04046e-05 2.30067e-05 1.73939e-05 1.31475e-05 9.94013e-06 7.51907e-06 5.69129e-06 4.31061e-06 3.26681e-06 2.47694e-06 1.87867e-06 1.42519e-06 1.08133e-06 8.20532e-07 6.22683e-07 4.72555e-07 3.58615e-07 2.7215e-07 2.06529e-07 1.56703e-07 1.18842e-07 9.00539e-08 6.8178e-08 5.15695e-08 3.89662e-08 2.94096e-08 2.21669e-08 1.6679e-08 1.2526e-08 9.39068e-09 7.02833e-09 5.24997e-09 3.91271e-09 2.90916e-09 2.15852e-09 1.59878e-09 1.18183e-09 8.71489e-10 6.41035e-10 4.70328e-10 3.44268e-10 2.51502e-10 1.83362e-10 1.33347e-10 9.67056e-11 6.99577e-11 5.05077e-11 3.64042e-11 2.61991e-11 1.8829e-11 1.35131e-11 9.68277e-12 6.92952e-12 4.95762e-12 3.54807e-12 2.53915e-12 1.81837e-12 1.30586e-12 9.4178e-13 6.82839e-13 4.98069e-13 3.65975e-13 2.71519e-13 2.03948e-13 1.55474e-13 1.20492e-13 9.5205e-14 7.67582e-14 6.33485e-14 5.36336e-14 4.63925e-14 4.10671e-14 3.70879e-14 3.41086e-14 3.1972e-14 3.03478e-14 2.91115e-14 2.82209e-14 2.75727e-14 2.71158e-14 2.70556e-14 2.71201e-14 2.73136e-14 2.7674e-14 2.8527e-14 2.95016e-14 3.19694e-14 3.42078e-14 4.00393e-14 4.50654e-14 5.87438e-14 7.28765e-14 1.08032e-13 1.61139e-13 2.66109e-13 4.97811e-13 9.56117e-13 2.07216e-12 4.42623e-12 1.01032e-11 2.28004e-11 5.16105e-11 1.1636e-10 2.5671e-10 5.47281e-10 1.24496e-09 0.00110689 0.000951926 0.000620619 0.000644331 0.000952014 0.00130632 0.00109831 0.001071 0.00128231 0.00162358 0.00159224 0.00158038 0.00157784 0.00144399 0.00130896 0.00130986 0.00131133 0.00130677 0.0013523 0.00135232 0.00135471 0.00137415 0.00152743 0.0016269 0.00178513 0.00212802 0.00229019 0.00250765 0.00319118 0.00369238 0.00408512 0.0050628 0.00615841 0.0072925 0.0102498 0.0137538 0.0157337 0.0176058 0.0216674 0.0253851 0.025564 0.0237949 0.0213075 0.0233716 0.0244801 0.0218284 0.0149752 0.0109662 0.00887475 0.00718905 0.00642062 0.00625752 0.00634824 0.00722032 0.00811646 0.0083649 0.00840153 0.00819489 0.00782871 0.00770855 0.00741191 0.00598902 0.00395031 0.0024042 0.00137572 0.000773778 0.000448714 0.000278823 0.000187308 0.000133709 9.90478e-05 7.46778e-05 5.66555e-05 4.30268e-05 3.26516e-05 2.4752e-05 1.87481e-05 1.41939e-05 1.07444e-05 8.1343e-06 6.1603e-06 4.66745e-06 3.53802e-06 2.68287e-06 2.0348e-06 1.54328e-06 1.17026e-06 8.87079e-07 6.72072e-07 5.08864e-07 3.85047e-07 2.91191e-07 2.20087e-07 1.66232e-07 1.25449e-07 9.45805e-08 7.124e-08 5.36125e-08 4.03129e-08 3.02825e-08 2.27168e-08 1.70145e-08 1.27247e-08 9.50278e-09 7.08545e-09 5.27356e-09 3.91732e-09 2.90404e-09 2.14864e-09 1.58657e-09 1.16896e-09 8.59297e-10 6.3023e-10 4.61156e-10 3.36678e-10 2.45275e-10 1.78288e-10 1.29295e-10 9.35537e-11 6.75463e-11 4.86792e-11 3.50348e-11 2.51898e-11 1.80968e-11 1.29929e-11 9.32417e-12 6.68893e-12 4.79668e-12 3.43922e-12 2.47045e-12 1.78331e-12 1.29645e-12 9.512e-13 7.05676e-13 5.29958e-13 4.03525e-13 3.12021e-13 2.45601e-13 1.97231e-13 1.6177e-13 1.35849e-13 1.16694e-13 1.02611e-13 9.23559e-14 8.47651e-14 7.93597e-14 7.53242e-14 7.24261e-14 7.04069e-14 6.89753e-14 6.80749e-14 6.74523e-14 6.7332e-14 6.72846e-14 6.79238e-14 6.8384e-14 6.99454e-14 7.10295e-14 7.4215e-14 7.67656e-14 8.39624e-14 8.92812e-14 1.0361e-13 1.14818e-13 1.44246e-13 1.74629e-13 2.35706e-13 3.59938e-13 5.23469e-13 9.4039e-13 1.62922e-12 3.26282e-12 6.50901e-12 1.44625e-11 3.10074e-11 6.84633e-11 1.53883e-10 3.30877e-10 6.98766e-10 1.60127e-09 0.000307953 0.000363458 0.000274369 0.000276424 0.00030883 0.000689483 0.000690481 0.000693941 0.000690877 0.000867438 0.000974799 0.0011412 0.00109894 0.0010982 0.00111309 0.00124702 0.00127937 0.00128719 0.00133209 0.00137891 0.00138692 0.00140434 0.00155815 0.00178518 0.00199268 0.00266424 0.00321043 0.00339299 0.00372693 0.00483293 0.00562664 0.00708197 0.00962615 0.0116579 0.0127911 0.0151442 0.0193657 0.0216912 0.0226591 0.0263804 0.0273661 0.0252264 0.0193089 0.0167545 0.0188212 0.0189392 0.0145822 0.0102088 0.00840679 0.00707763 0.00638215 0.00629019 0.00632402 0.00700926 0.00846373 0.00884283 0.00882902 0.008509 0.00746765 0.00693296 0.00657431 0.00573528 0.00412538 0.00271447 0.00167404 0.000991959 0.000583878 0.000353818 0.000226578 0.000154233 0.000110377 8.17206e-05 6.15219e-05 4.66373e-05 3.54295e-05 2.69209e-05 2.04483e-05 1.55257e-05 1.17849e-05 8.94454e-06 6.78935e-06 5.1547e-06 3.91491e-06 2.97432e-06 2.26038e-06 1.71816e-06 1.30612e-06 9.92813e-07 7.54436e-07 5.72996e-07 4.34889e-07 3.29797e-07 2.49855e-07 1.89068e-07 1.42884e-07 1.07835e-07 8.12789e-08 6.119e-08 4.60072e-08 3.45388e-08 2.58848e-08 1.9365e-08 1.44622e-08 1.07825e-08 8.02535e-09 5.96234e-09 4.42099e-09 3.27125e-09 2.41515e-09 1.77915e-09 1.30782e-09 9.59252e-10 7.01993e-10 5.12502e-10 3.73232e-10 2.71154e-10 1.96539e-10 1.42115e-10 1.02496e-10 7.37302e-11 5.29175e-11 3.79022e-11 2.70876e-11 1.93106e-11 1.37306e-11 9.73874e-12 6.89291e-12 4.87208e-12 3.44246e-12 2.43356e-12 1.72231e-12 1.22086e-12 8.6651e-13 6.15762e-13 4.38803e-13 3.1431e-13 2.26814e-13 1.65304e-13 1.21986e-13 9.13404e-14 6.96555e-14 5.42393e-14 4.32508e-14 3.54312e-14 2.98256e-14 2.58536e-14 2.29925e-14 2.09424e-14 1.95127e-14 1.85691e-14 1.80427e-14 1.7838e-14 1.78406e-14 1.79232e-14 1.80793e-14 1.83765e-14 1.91121e-14 1.98288e-14 2.11665e-14 2.21932e-14 2.47292e-14 2.67509e-14 3.23957e-14 3.69759e-14 5.09134e-14 6.46656e-14 1.02683e-13 1.56567e-13 2.75177e-13 5.26037e-13 1.06356e-12 2.38491e-12 5.12586e-12 1.23479e-11 2.79406e-11 6.4112e-11 1.49995e-10 3.30499e-10 7.13741e-10 1.67253e-09 0.000152885 0.000187127 0.000204276 0.000200195 0.00023203 0.00045063 0.000627244 0.000642798 0.000672848 0.00068091 0.000884569 0.000946137 0.000953337 0.000987153 0.00119761 0.00129221 0.00133891 0.00139962 0.00154739 0.00187029 0.00194578 0.00205232 0.00250577 0.00288023 0.0032906 0.00440791 0.00486678 0.00506466 0.00550652 0.00668098 0.00848094 0.0105823 0.0125715 0.0150447 0.0174121 0.0183115 0.0206347 0.024117 0.0242925 0.0242498 0.0253057 0.0246328 0.0187885 0.0131162 0.0114419 0.0108562 0.0100245 0.00863744 0.00788462 0.00704568 0.00637944 0.00633654 0.00635347 0.00669823 0.00839593 0.00904672 0.00898242 0.00857677 0.00701842 0.00550363 0.00494019 0.00469056 0.00397512 0.002767 0.00175978 0.00106929 0.000642552 0.000394015 0.000253052 0.000171733 0.000121798 8.88504e-05 6.61809e-05 4.99668e-05 3.79369e-05 2.8853e-05 2.19478e-05 1.66895e-05 1.26855e-05 9.63847e-06 7.32115e-06 5.55969e-06 4.22128e-06 3.20463e-06 2.43259e-06 1.84642e-06 1.40142e-06 1.06357e-06 8.07067e-07 6.12295e-07 4.6438e-07 3.5203e-07 2.6668e-07 2.01849e-07 1.5263e-07 1.15292e-07 8.69987e-08 6.55749e-08 4.93584e-08 3.70913e-08 2.78228e-08 2.08316e-08 1.55701e-08 1.1619e-08 8.65593e-09 6.43634e-09 4.77587e-09 3.5358e-09 2.61173e-09 1.92489e-09 1.41556e-09 1.03865e-09 7.60342e-10 5.55289e-10 4.04525e-10 2.93958e-10 2.13069e-10 1.54016e-10 1.11007e-10 7.9774e-11 5.71602e-11 4.0835e-11 2.90847e-11 2.06561e-11 1.46329e-11 1.0343e-11 7.29596e-12 5.13644e-12 3.60928e-12 2.53186e-12 1.77363e-12 1.24131e-12 8.68242e-13 6.0725e-13 4.25305e-13 2.98947e-13 2.11208e-13 1.50219e-13 1.07758e-13 7.80743e-14 5.72671e-14 4.26415e-14 3.23061e-14 2.49908e-14 1.98001e-14 1.61339e-14 1.34921e-14 1.15987e-14 1.02361e-14 9.21107e-15 8.50494e-15 8.02236e-15 7.67663e-15 7.46653e-15 7.43862e-15 7.4702e-15 7.56455e-15 7.72673e-15 8.14753e-15 8.54822e-15 9.71968e-15 1.06251e-14 1.37131e-14 1.60812e-14 2.49384e-14 3.30593e-14 6.05313e-14 9.83378e-14 1.92911e-13 3.97565e-13 8.6998e-13 2.06906e-12 4.67903e-12 1.16981e-11 2.72304e-11 6.41777e-11 1.53046e-10 3.41805e-10 7.55972e-10 1.80543e-09 0.000117352 0.00016215 0.000185115 0.000228779 0.000320303 0.000441328 0.000659001 0.00066154 0.000872981 0.00105093 0.00137668 0.00145605 0.00159475 0.00199737 0.00212862 0.00219402 0.00228875 0.00242242 0.00289773 0.00332337 0.00336877 0.00341373 0.003694 0.00433381 0.00478196 0.00537998 0.00571125 0.00641421 0.00727832 0.0082461 0.0115932 0.015828 0.0169584 0.0179233 0.021072 0.0225301 0.0226882 0.0235689 0.0243025 0.0234066 0.0220027 0.0211115 0.0173893 0.0119228 0.00904939 0.0075052 0.00649729 0.00631341 0.00641871 0.0067345 0.00644719 0.00612044 0.00614231 0.00619219 0.00739356 0.00896794 0.00900022 0.0084722 0.0067784 0.00486664 0.00353893 0.00297264 0.00281467 0.00247286 0.00169508 0.00106568 0.000651265 0.000402881 0.000259911 0.000177304 0.000127349 9.45175e-05 7.11496e-05 5.40006e-05 4.11623e-05 3.14267e-05 2.39967e-05 1.83142e-05 1.39685e-05 1.06478e-05 8.11239e-06 6.17784e-06 4.70236e-06 3.57741e-06 2.72009e-06 2.06708e-06 1.56994e-06 1.19166e-06 9.03941e-07 6.85203e-07 5.18994e-07 3.92763e-07 2.96954e-07 2.24291e-07 1.69237e-07 1.27568e-07 9.60586e-08 7.22423e-08 5.42495e-08 4.06686e-08 3.04329e-08 2.27338e-08 1.69553e-08 1.26257e-08 9.38545e-09 6.96313e-09 5.15473e-09 3.80721e-09 2.80538e-09 2.06245e-09 1.51287e-09 1.10719e-09 8.08332e-10 5.88649e-10 4.27546e-10 3.0972e-10 2.23789e-10 1.61283e-10 1.15929e-10 8.30977e-11 5.93871e-11 4.23091e-11 3.00456e-11 2.12706e-11 1.50177e-11 1.05799e-11 7.4393e-12 5.22083e-12 3.65647e-12 2.55603e-12 1.78417e-12 1.24435e-12 8.67745e-13 6.0539e-13 4.22939e-13 2.9657e-13 2.09352e-13 1.49004e-13 1.07127e-13 7.79077e-14 5.74258e-14 4.30532e-14 3.29318e-14 2.57919e-14 2.07355e-14 1.71469e-14 1.45627e-14 1.27402e-14 1.14329e-14 1.04245e-14 9.72437e-15 9.23312e-15 8.88292e-15 8.70761e-15 8.69643e-15 8.72369e-15 8.87086e-15 9.04377e-15 9.57743e-15 1.0007e-14 1.14203e-14 1.23729e-14 1.59834e-14 1.83779e-14 2.85797e-14 3.65877e-14 6.83138e-14 1.05981e-13 2.06377e-13 4.20349e-13 9.12615e-13 2.16597e-12 4.87462e-12 1.2343e-11 2.8788e-11 6.91078e-11 1.67379e-10 3.7594e-10 8.49999e-10 2.05084e-09 7.20389e-05 9.36136e-05 0.000134159 0.000169568 0.000190116 0.000197325 0.000469971 0.000812599 0.000854069 0.000838532 0.000967134 0.00164528 0.00242473 0.00243391 0.00252951 0.00278276 0.00319195 0.00360142 0.00414428 0.00432246 0.00439101 0.00453873 0.0050164 0.00524185 0.00565448 0.00693037 0.00775829 0.008884 0.0126313 0.0146428 0.0161362 0.0191428 0.0201787 0.020327 0.0215892 0.0236952 0.023544 0.0226092 0.0199249 0.0172032 0.0158662 0.0157321 0.0149814 0.0114418 0.00785529 0.00605985 0.00543387 0.00530329 0.0054214 0.00611605 0.00629671 0.00559892 0.00522928 0.00518801 0.00547568 0.00732576 0.00810988 0.0077909 0.00632572 0.00461735 0.0031878 0.0022278 0.0017172 0.00140273 0.00111068 0.000808544 0.000552784 0.000369541 0.000250172 0.000175274 0.000127812 9.62373e-05 7.37142e-05 5.66146e-05 4.35028e-05 3.3417e-05 2.56367e-05 1.96366e-05 1.50188e-05 1.14733e-05 8.75697e-06 6.67913e-06 5.09144e-06 3.87921e-06 2.95421e-06 2.24869e-06 1.71077e-06 1.30074e-06 9.88288e-07 7.5028e-07 5.69063e-07 4.31165e-07 3.26316e-07 2.4668e-07 1.86264e-07 1.40479e-07 1.05811e-07 7.95785e-08 5.97468e-08 4.47749e-08 3.34939e-08 2.50128e-08 1.8649e-08 1.38811e-08 1.03129e-08 7.64558e-09 5.65521e-09 4.17322e-09 3.07239e-09 2.25675e-09 1.65386e-09 1.20915e-09 8.81782e-10 6.41365e-10 4.65235e-10 3.36563e-10 2.42852e-10 1.74798e-10 1.25487e-10 8.98223e-11 6.40761e-11 4.5541e-11 3.22498e-11 2.27653e-11 1.60301e-11 1.12646e-11 7.89966e-12 5.52723e-12 3.85783e-12 2.686e-12 1.86533e-12 1.29191e-12 8.92642e-13 6.16086e-13 4.2572e-13 2.9528e-13 2.05907e-13 1.44503e-13 1.02198e-13 7.29748e-14 5.27214e-14 3.86614e-14 2.88628e-14 2.20372e-14 1.72826e-14 1.39783e-14 1.16461e-14 9.99501e-15 8.83937e-15 7.97477e-15 7.36954e-15 6.96619e-15 6.69874e-15 6.57789e-15 6.57531e-15 6.59437e-15 6.6925e-15 6.80529e-15 7.16559e-15 7.43625e-15 8.4102e-15 9.04735e-15 1.17292e-14 1.33855e-14 2.14463e-14 2.7267e-14 5.51321e-14 8.39969e-14 1.81849e-13 3.64677e-13 8.37173e-13 2.02594e-12 4.69257e-12 1.24183e-11 2.91394e-11 7.25347e-11 1.79182e-10 4.06875e-10 9.48629e-10 2.27589e-09 5.41042e-05 7.80188e-05 0.000257272 0.000262656 0.000565618 0.000658331 0.00142899 0.00177839 0.00263889 0.00257296 0.00301218 0.00356925 0.00407578 0.00421152 0.00421713 0.00439666 0.00504904 0.00527276 0.00534311 0.0056235 0.00586575 0.00626194 0.00738158 0.00801534 0.0087092 0.0115107 0.0137875 0.0151387 0.0181438 0.0193478 0.0194003 0.0198495 0.0206765 0.0206454 0.0207031 0.0219738 0.0223 0.0214969 0.0171635 0.0108323 0.00785085 0.00740038 0.00786964 0.00776063 0.00621036 0.00486312 0.00468709 0.0045386 0.00435888 0.00433286 0.00460272 0.00487785 0.00483723 0.00468775 0.00441504 0.0044457 0.00524966 0.00579791 0.0056639 0.00456748 0.00313683 0.00207679 0.00137528 0.000932985 0.000652006 0.000465911 0.000340468 0.000255251 0.000195981 0.000152843 0.000120112 9.473e-05 7.47541e-05 5.8877e-05 4.61421e-05 3.59438e-05 2.78511e-05 2.1487e-05 1.65204e-05 1.26681e-05 9.69419e-06 7.40659e-06 5.6517e-06 4.30822e-06 3.28127e-06 2.49717e-06 1.89902e-06 1.44305e-06 1.09567e-06 8.31191e-07 6.29951e-07 4.76941e-07 3.60707e-07 2.72494e-07 2.05617e-07 1.54959e-07 1.16617e-07 8.76223e-08 6.57233e-08 4.92114e-08 3.67855e-08 2.74519e-08 2.04518e-08 1.52084e-08 1.12858e-08 8.35601e-09 6.17233e-09 4.54857e-09 3.34423e-09 2.45325e-09 1.79554e-09 1.31091e-09 9.54494e-10 6.9302e-10 5.01764e-10 3.62316e-10 2.60949e-10 1.8744e-10 1.3424e-10 9.58201e-11 6.81508e-11 4.82948e-11 3.41065e-11 2.40137e-11 1.68636e-11 1.18146e-11 8.25708e-12 5.75484e-12 3.99874e-12 2.76985e-12 1.91279e-12 1.3174e-12 9.05645e-13 6.22217e-13 4.27957e-13 2.95309e-13 2.04781e-13 1.42826e-13 1.00391e-13 7.12248e-14 5.11124e-14 3.72518e-14 2.76866e-14 2.10734e-14 1.64871e-14 1.33211e-14 1.11053e-14 9.53612e-15 8.45503e-15 7.66429e-15 7.10377e-15 6.73986e-15 6.49952e-15 6.37031e-15 6.3559e-15 6.36094e-15 6.41757e-15 6.48803e-15 6.7617e-15 6.97408e-15 7.79949e-15 8.33161e-15 1.06394e-14 1.20834e-14 1.92385e-14 2.44423e-14 5.04539e-14 7.61418e-14 1.76259e-13 3.40934e-13 8.20279e-13 1.97343e-12 4.74022e-12 1.28381e-11 3.02535e-11 7.87602e-11 1.95668e-10 4.52395e-10 1.0919e-09 2.58398e-09 4.03483e-05 6.41513e-05 0.000136861 0.000356314 0.00125471 0.00140536 0.00143417 0.00192766 0.00451654 0.0060698 0.00572418 0.00581176 0.00668438 0.00868526 0.00921154 0.00951344 0.0103625 0.010797 0.0111484 0.0121304 0.0125495 0.0132034 0.014628 0.0150864 0.0154003 0.0168292 0.0179586 0.0181609 0.0187172 0.0195142 0.0194136 0.0193363 0.0193635 0.0187496 0.0161519 0.0130066 0.0114843 0.0101924 0.00814985 0.00582458 0.00433464 0.00385375 0.00404364 0.00452791 0.00436035 0.00383814 0.00368865 0.00353314 0.00333456 0.00316979 0.00307711 0.00349272 0.00451781 0.00452446 0.00392276 0.00316233 0.00300591 0.00332699 0.00418477 0.00426959 0.00363047 0.00229672 0.00138184 0.000864646 0.000565287 0.00038618 0.000278286 0.000212142 0.000168962 0.000137928 0.000113252 9.24747e-05 7.483e-05 5.99632e-05 4.75997e-05 3.74949e-05 2.93523e-05 2.28531e-05 1.7711e-05 1.3674e-05 1.05244e-05 8.07963e-06 6.19001e-06 4.73458e-06 3.61667e-06 2.7594e-06 2.10267e-06 1.60022e-06 1.21632e-06 9.23383e-07 7.00124e-07 5.30182e-07 4.00981e-07 3.02871e-07 2.28455e-07 1.72074e-07 1.29406e-07 9.7158e-08 7.28243e-08 5.44939e-08 4.07088e-08 3.03584e-08 2.25978e-08 1.67865e-08 1.24419e-08 9.20039e-09 6.78763e-09 4.99634e-09 3.66971e-09 2.68923e-09 1.96587e-09 1.43325e-09 1.04201e-09 7.55441e-10 5.46153e-10 3.93732e-10 2.83033e-10 2.02857e-10 1.44949e-10 1.03238e-10 7.3274e-11 5.18187e-11 3.65183e-11 2.56565e-11 1.79757e-11 1.25595e-11 8.74797e-12 6.07166e-12 4.19883e-12 2.89406e-12 1.98909e-12 1.36366e-12 9.32941e-13 6.37612e-13 4.3592e-13 2.98618e-13 2.05367e-13 1.42023e-13 9.89192e-14 6.95098e-14 4.93993e-14 3.56509e-14 2.6256e-14 1.9816e-14 1.53813e-14 1.23326e-14 1.02288e-14 8.76696e-15 7.75662e-15 7.02112e-15 6.50712e-15 6.17775e-15 5.96925e-15 5.86472e-15 5.85625e-15 5.86076e-15 5.91477e-15 5.97575e-15 6.21089e-15 6.38636e-15 7.0525e-15 7.5068e-15 9.32875e-15 1.06671e-14 1.6354e-14 2.13346e-14 4.29366e-14 6.64461e-14 1.638e-13 3.0943e-13 8.04473e-13 1.90081e-12 4.82492e-12 1.31747e-11 3.14406e-11 8.6077e-11 2.1375e-10 5.11911e-10 1.27362e-09 2.96797e-09 5.6484e-05 0.000160627 0.000307662 0.00111666 0.00234294 0.00501371 0.00501262 0.00888763 0.0109027 0.0133142 0.0132676 0.0148399 0.0158165 0.0156701 0.0154384 0.0154868 0.0158967 0.0160788 0.0161776 0.0163613 0.0163371 0.016345 0.0168029 0.0168715 0.0168419 0.0171625 0.0176118 0.0171442 0.0160491 0.0157581 0.0144453 0.0118875 0.0113944 0.0109322 0.00846801 0.00588199 0.00443856 0.00339077 0.00291465 0.00285574 0.00268029 0.00255119 0.00260886 0.00321006 0.00339795 0.0033274 0.00332603 0.00333573 0.00320182 0.00292568 0.00270276 0.00263341 0.00303304 0.00346041 0.00322564 0.00241338 0.00207306 0.00206235 0.00247614 0.00341492 0.00355152 0.00299235 0.00190021 0.00119123 0.000758382 0.000498783 0.000340661 0.000244288 0.000184661 0.000145361 0.000117002 9.48826e-05 7.68073e-05 6.17823e-05 4.93101e-05 3.90567e-05 3.07304e-05 2.40546e-05 1.87539e-05 1.45729e-05 1.12913e-05 8.7258e-06 6.72678e-06 5.17363e-06 3.97014e-06 3.04033e-06 2.32399e-06 1.77333e-06 1.35088e-06 1.02739e-06 7.80122e-07 5.91428e-07 4.47657e-07 3.3828e-07 2.55198e-07 1.92189e-07 1.44485e-07 1.08432e-07 8.12349e-08 6.0754e-08 4.5356e-08 3.37967e-08 2.51314e-08 1.86464e-08 1.38035e-08 1.01954e-08 7.51365e-09 5.52514e-09 4.05369e-09 2.96699e-09 2.16607e-09 1.57715e-09 1.14515e-09 8.29109e-10 5.9853e-10 4.30779e-10 3.09104e-10 2.21114e-10 1.57676e-10 1.1207e-10 7.93824e-11 5.60381e-11 3.94305e-11 2.76587e-11 1.93387e-11 1.34736e-11 9.35127e-12 6.4649e-12 4.45308e-12 3.0575e-12 2.09393e-12 1.43111e-12 9.76431e-13 6.65497e-13 4.53602e-13 3.09605e-13 2.11897e-13 1.45595e-13 1.0062e-13 7.01427e-14 4.95228e-14 3.55619e-14 2.60872e-14 1.96437e-14 1.52271e-14 1.21932e-14 1.01208e-14 8.69158e-15 7.71791e-15 7.05727e-15 6.58913e-15 6.27684e-15 6.12841e-15 6.09261e-15 6.10177e-15 6.12433e-15 6.2187e-15 6.30064e-15 6.55588e-15 6.74327e-15 7.37324e-15 7.84763e-15 9.40716e-15 1.08446e-14 1.53545e-14 2.08624e-14 3.82169e-14 6.32853e-14 1.5808e-13 2.97929e-13 8.57933e-13 1.88148e-12 5.10479e-12 1.36431e-11 3.3318e-11 9.59699e-11 2.36911e-10 5.97125e-10 1.51938e-09 3.58433e-09 0.000206637 0.000219187 0.00134085 0.00169148 0.00776068 0.00708932 0.00873586 0.00943665 0.0146356 0.014895 0.0146212 0.0142274 0.0141882 0.0140018 0.0128252 0.0119536 0.0118134 0.0114038 0.0103199 0.0100039 0.00958883 0.0085407 0.0081734 0.0080899 0.00747582 0.00675709 0.0065854 0.00599605 0.0050165 0.0047068 0.00441873 0.00354086 0.00319148 0.00291637 0.00243807 0.00207863 0.00182469 0.00154922 0.00142571 0.00142759 0.00166172 0.00179392 0.00180964 0.00171232 0.00165635 0.00182099 0.00260397 0.0032003 0.00341944 0.00326878 0.00272727 0.00259867 0.00239244 0.00210688 0.00186733 0.0016665 0.00160379 0.00158493 0.0015278 0.00151263 0.00168894 0.00194236 0.00192811 0.00154978 0.00105835 0.000732879 0.00051154 0.000357302 0.000252974 0.000183973 0.000137842 0.000105817 8.24864e-05 6.47748e-05 5.0972e-05 4.00828e-05 3.14636e-05 2.46444e-05 1.92555e-05 1.50067e-05 1.16666e-05 9.04853e-06 7.00243e-06 5.40763e-06 4.16767e-06 3.20583e-06 2.46133e-06 1.88625e-06 1.44293e-06 1.10183e-06 8.39879e-07 6.39062e-07 4.85377e-07 3.67964e-07 2.7842e-07 2.10256e-07 1.58469e-07 1.19205e-07 8.94943e-08 6.7054e-08 5.01351e-08 3.74016e-08 2.78373e-08 2.06697e-08 1.53115e-08 1.13158e-08 8.34321e-09 6.13688e-09 4.50286e-09 3.29547e-09 2.4054e-09 1.75093e-09 1.27095e-09 9.19886e-10 6.63815e-10 4.77533e-10 3.42435e-10 2.44775e-10 1.7443e-10 1.23921e-10 8.77622e-11 6.19541e-11 4.35875e-11 3.05584e-11 2.13448e-11 1.48514e-11 1.02923e-11 7.10467e-12 4.88727e-12 3.35218e-12 2.29414e-12 1.56709e-12 1.06839e-12 7.2709e-13 4.94221e-13 3.35972e-13 2.2883e-13 1.56396e-13 1.07408e-13 7.43318e-14 5.20552e-14 3.70422e-14 2.68804e-14 1.99471e-14 1.51632e-14 1.18549e-14 9.5626e-15 7.97655e-15 6.86381e-15 6.07707e-15 5.52294e-15 5.13765e-15 4.87778e-15 4.70098e-15 4.62814e-15 4.58484e-15 4.58988e-15 4.6e-15 4.68631e-15 4.81164e-15 5.1331e-15 5.66503e-15 6.44234e-15 8.26282e-15 1.08781e-14 1.75209e-14 3.00754e-14 6.15682e-14 1.41855e-13 3.12397e-13 9.10771e-13 1.9523e-12 5.71665e-12 1.4319e-11 3.68204e-11 1.08576e-10 2.65587e-10 7.14867e-10 1.8412e-09 4.46341e-09 8.55222e-05 0.000158445 0.000476185 0.000695347 0.000878636 0.000872698 0.0009238 0.00126038 0.00135991 0.00133522 0.00139941 0.00127006 0.00135126 0.00139713 0.00160171 0.00150762 0.00141429 0.00144556 0.00140258 0.00131389 0.00133402 0.00133079 0.00126917 0.00123323 0.00126524 0.00120752 0.00111002 0.00114219 0.00112179 0.00101319 0.00100953 0.00111172 0.0010471 0.000897318 0.000873951 0.000884354 0.000844427 0.000886667 0.000954793 0.00110986 0.0011419 0.00123324 0.0012549 0.00113989 0.00113457 0.00125791 0.00126281 0.00118816 0.00119982 0.00143388 0.0023765 0.00246789 0.00224085 0.0016585 0.00136204 0.00142412 0.00154816 0.00145057 0.00121084 0.00100618 0.000746074 0.000532381 0.000430276 0.000411447 0.000427569 0.000453912 0.000443367 0.000357083 0.000251571 0.000182087 0.000135612 0.000103709 8.08709e-05 6.37595e-05 5.04589e-05 3.98771e-05 3.14091e-05 2.46711e-05 1.93276e-05 1.51016e-05 1.17693e-05 9.1494e-06 7.09587e-06 5.49086e-06 4.2398e-06 3.2671e-06 2.51259e-06 1.92862e-06 1.4776e-06 1.12996e-06 8.62535e-07 6.5719e-07 4.99795e-07 3.79367e-07 2.87393e-07 2.17286e-07 1.63957e-07 1.23472e-07 9.27966e-08 6.95957e-08 5.20801e-08 3.88824e-08 2.89603e-08 2.15189e-08 1.59518e-08 1.17968e-08 8.70276e-09 6.40404e-09 4.70002e-09 3.44006e-09 2.51083e-09 1.8275e-09 1.32634e-09 9.59793e-10 6.92414e-10 4.97905e-10 3.56877e-10 2.54965e-10 1.81594e-10 1.28932e-10 9.12455e-11 6.43565e-11 4.52262e-11 3.16623e-11 2.20797e-11 1.53354e-11 1.06066e-11 7.30174e-12 5.00909e-12 3.42628e-12 2.33806e-12 1.59175e-12 1.08097e-12 7.32454e-13 4.95621e-13 3.35339e-13 2.27218e-13 1.54549e-13 1.05831e-13 7.31721e-14 5.13328e-14 3.67172e-14 2.68921e-14 2.02311e-14 1.5677e-14 1.25797e-14 1.04835e-14 9.11929e-15 8.22094e-15 7.64775e-15 7.30722e-15 7.12136e-15 7.12466e-15 7.21115e-15 7.48391e-15 7.727e-15 8.07432e-15 8.48057e-15 8.93951e-15 9.7979e-15 1.04106e-14 1.22298e-14 1.32301e-14 1.83424e-14 2.04448e-14 3.81518e-14 4.73812e-14 1.21489e-13 1.94927e-13 4.53466e-13 1.11764e-12 2.45296e-12 7.48629e-12 1.62642e-11 4.39646e-11 1.26048e-10 3.1032e-10 8.9229e-10 2.29639e-09 5.97576e-09 5.33361e-05 5.68758e-05 7.54543e-05 9.37679e-05 9.28125e-05 9.04831e-05 8.80839e-05 9.38905e-05 8.77808e-05 8.43718e-05 8.61469e-05 9.92985e-05 0.000139644 0.000131237 0.000145131 0.00018632 0.000187066 0.000189841 0.000201048 0.000209596 0.00021228 0.000216534 0.000244686 0.000235974 0.000228863 0.000268695 0.000258355 0.000248554 0.000276203 0.000284816 0.000279138 0.000281633 0.000320025 0.000348915 0.000378636 0.000533423 0.000538996 0.000565889 0.000716994 0.000965048 0.000894343 0.000711814 0.000712543 0.000857222 0.000804314 0.000575045 0.000558286 0.000628987 0.000780981 0.00115424 0.00117443 0.00114483 0.00116999 0.0011374 0.00099618 0.00085949 0.000821633 0.000888713 0.000953288 0.000890368 0.000630624 0.000441449 0.000321012 0.000240834 0.000190246 0.000158286 0.000136346 0.000119289 0.000104689 9.1473e-05 7.91845e-05 6.77184e-05 5.72082e-05 4.77917e-05 3.95443e-05 3.24624e-05 2.64398e-05 2.13433e-05 1.70885e-05 1.35866e-05 1.07391e-05 8.44642e-06 6.61499e-06 5.16146e-06 4.01403e-06 3.11237e-06 2.4066e-06 1.85608e-06 1.42801e-06 1.0961e-06 8.39435e-07 6.41433e-07 4.89039e-07 3.72013e-07 2.82356e-07 2.1383e-07 1.61577e-07 1.21823e-07 9.16419e-08 6.87772e-08 5.14921e-08 3.84556e-08 2.86488e-08 2.12906e-08 1.57837e-08 1.16716e-08 8.60798e-09 6.33084e-09 4.64247e-09 3.39447e-09 2.47438e-09 1.79817e-09 1.30258e-09 9.40387e-10 6.76437e-10 4.84813e-10 3.46253e-10 2.46404e-10 1.74745e-10 1.23482e-10 8.69287e-11 6.09524e-11 4.25497e-11 2.95683e-11 2.04515e-11 1.40817e-11 9.65429e-12 6.59743e-12 4.49052e-12 3.04635e-12 2.06171e-12 1.39293e-12 9.40392e-13 6.36088e-13 4.32439e-13 2.97921e-13 2.09579e-13 1.52288e-13 1.15588e-13 9.27753e-14 7.91949e-14 7.17082e-14 6.78582e-14 6.76639e-14 6.8837e-14 7.18958e-14 7.58559e-14 8.12719e-14 8.75573e-14 9.45664e-14 1.02906e-13 1.11832e-13 1.2235e-13 1.33704e-13 1.46944e-13 1.6089e-13 1.77775e-13 1.94303e-13 2.18199e-13 2.34791e-13 2.74163e-13 2.87129e-13 3.43244e-13 3.8759e-13 4.15999e-13 5.68337e-13 6.10021e-13 9.77589e-13 1.125e-12 2.07913e-12 3.24252e-12 5.73647e-12 1.4762e-11 2.51871e-11 6.51915e-11 1.66238e-10 4.09961e-10 1.26387e-09 3.25004e-09 1.02052e-08 3.59034e-05 3.63355e-05 3.76449e-05 3.70227e-05 3.56462e-05 3.50723e-05 3.49047e-05 3.55956e-05 3.7409e-05 3.73451e-05 3.66359e-05 3.61936e-05 3.90662e-05 4.85995e-05 4.8921e-05 4.92342e-05 5.47424e-05 5.8026e-05 5.81196e-05 6.43506e-05 6.9753e-05 6.76504e-05 6.97716e-05 7.9539e-05 7.61039e-05 7.75411e-05 8.96639e-05 9.03035e-05 9.08625e-05 9.70842e-05 0.000116891 0.000117947 0.000127304 0.000200481 0.000230238 0.000264971 0.000382345 0.000414337 0.000378025 0.000358072 0.000327049 0.000270068 0.000247595 0.000242535 0.000240451 0.000250508 0.000310597 0.000601867 0.000876337 0.000921322 0.000853895 0.000786352 0.00078625 0.000755127 0.000616888 0.000453568 0.000391099 0.000388195 0.000405098 0.000469791 0.000508319 0.00050486 0.00044907 0.000328369 0.000247209 0.000196614 0.000162858 0.000137386 0.000116187 9.7734e-05 8.15189e-05 6.73678e-05 5.52086e-05 4.49182e-05 3.63127e-05 2.91905e-05 2.3349e-05 1.85937e-05 1.47469e-05 1.1652e-05 9.17414e-06 7.19934e-06 5.63209e-06 4.39319e-06 3.4174e-06 2.6514e-06 2.05191e-06 1.5841e-06 1.22005e-06 9.37489e-07 7.18718e-07 5.49742e-07 4.19531e-07 3.19427e-07 2.4265e-07 1.839e-07 1.39047e-07 1.04881e-07 7.89128e-08 5.92296e-08 4.43448e-08 3.31179e-08 2.4673e-08 1.83366e-08 1.35938e-08 1.0051e-08 7.41084e-09 5.44844e-09 3.99372e-09 2.91896e-09 2.12704e-09 1.54569e-09 1.12002e-09 8.093e-10 5.83204e-10 4.18841e-10 2.998e-10 2.13835e-10 1.52048e-10 1.07792e-10 7.62076e-11 5.37493e-11 3.7833e-11 2.66138e-11 1.87505e-11 1.32665e-11 9.46282e-12 6.85192e-12 5.07154e-12 3.87176e-12 3.07297e-12 2.55619e-12 2.22791e-12 2.04768e-12 1.93475e-12 1.92193e-12 1.94259e-12 2.00373e-12 2.08919e-12 2.2023e-12 2.34149e-12 2.49305e-12 2.67616e-12 2.87552e-12 3.09323e-12 3.35012e-12 3.61615e-12 3.92463e-12 4.26352e-12 4.6272e-12 5.04867e-12 5.49697e-12 6.01058e-12 6.56834e-12 7.20516e-12 7.88627e-12 8.70258e-12 9.49848e-12 1.0666e-11 1.13837e-11 1.34243e-11 1.35824e-11 1.69981e-11 1.71501e-11 2.11073e-11 2.23472e-11 2.70923e-11 3.11979e-11 3.70812e-11 4.6968e-11 6.23778e-11 7.80346e-11 1.37063e-10 1.7575e-10 3.31637e-10 5.29262e-10 1.00533e-09 2.42777e-09 5.76512e-09 3.42216e-08 2.94763e-05 3.40866e-05 3.59437e-05 3.7503e-05 3.97584e-05 4.01902e-05 4.16894e-05 4.25544e-05 4.19216e-05 3.96724e-05 3.67114e-05 3.62133e-05 3.60581e-05 3.4551e-05 3.50955e-05 3.75877e-05 3.75442e-05 3.87173e-05 4.26435e-05 4.26398e-05 4.44618e-05 5.1209e-05 5.18935e-05 5.43775e-05 6.68144e-05 6.75118e-05 6.81593e-05 7.76336e-05 7.80023e-05 7.65438e-05 8.52679e-05 9.35495e-05 9.55916e-05 0.000109367 0.000164173 0.000183835 0.000208292 0.000302118 0.000339429 0.000332301 0.000335605 0.000368537 0.000386696 0.000397601 0.000427376 0.00053284 0.000629267 0.000645779 0.000660157 0.000729056 0.000840352 0.000859094 0.000824558 0.00066405 0.00053428 0.000497354 0.000489104 0.00047102 0.000394586 0.000291593 0.000235615 0.000208264 0.000195659 0.000189919 0.000182543 0.000166715 0.000145977 0.000124635 0.000104892 8.75416e-05 7.26211e-05 5.99046e-05 4.91266e-05 4.00451e-05 3.24467e-05 2.61384e-05 2.09427e-05 1.66961e-05 1.32499e-05 1.04712e-05 8.24362e-06 6.46716e-06 5.0571e-06 3.94264e-06 3.06519e-06 2.37675e-06 1.83831e-06 1.41842e-06 1.09189e-06 8.38629e-07 6.42682e-07 4.91445e-07 3.74991e-07 2.85522e-07 2.16938e-07 1.64481e-07 1.24448e-07 9.3962e-08 7.07952e-08 5.32151e-08 3.99072e-08 2.9859e-08 2.22909e-08 1.66032e-08 1.23391e-08 9.14873e-09 6.76801e-09 4.99633e-09 3.68121e-09 2.70805e-09 1.98944e-09 1.46113e-09 1.07339e-09 7.89964e-10 5.83059e-10 4.32768e-10 3.23846e-10 2.44914e-10 1.88488e-10 1.48262e-10 1.19827e-10 9.96898e-11 8.57061e-11 7.61361e-11 7.00434e-11 6.5915e-11 6.37534e-11 6.33332e-11 6.35445e-11 6.46273e-11 6.63083e-11 6.86479e-11 7.15357e-11 7.48345e-11 7.87584e-11 8.3096e-11 8.79138e-11 9.34491e-11 9.93279e-11 1.05968e-10 1.13381e-10 1.21175e-10 1.3022e-10 1.39887e-10 1.50379e-10 1.625e-10 1.75039e-10 1.89439e-10 2.05156e-10 2.22023e-10 2.41409e-10 2.62015e-10 2.85408e-10 3.10849e-10 3.39536e-10 3.7038e-10 4.06694e-10 4.42916e-10 4.93174e-10 5.27784e-10 6.12156e-10 6.23853e-10 7.68054e-10 7.73198e-10 9.50077e-10 9.65279e-10 1.22693e-09 1.24038e-09 1.64499e-09 1.67211e-09 2.37074e-09 2.47255e-09 3.81526e-09 4.25177e-09 6.98122e-09 8.8198e-09 1.46229e-08 2.4377e-08 4.64765e-08 3.12619e-07 3.32824e-05 3.3521e-05 3.3723e-05 3.38772e-05 3.4447e-05 3.49158e-05 3.53247e-05 3.64412e-05 3.71815e-05 3.76583e-05 3.82114e-05 3.84155e-05 3.88996e-05 3.95243e-05 3.95728e-05 3.96827e-05 4.03536e-05 4.24185e-05 4.49174e-05 5.26234e-05 5.98575e-05 6.41601e-05 7.59025e-05 8.57464e-05 9.13494e-05 0.000107192 0.000117794 0.000120279 0.000125309 0.000139656 0.000147334 0.000162137 0.00020699 0.000238813 0.000252094 0.000275453 0.000326205 0.000356262 0.000397048 0.000510888 0.000666777 0.0007509 0.00083409 0.00105436 0.00136501 0.00153844 0.00171181 0.00185713 0.00188644 0.00185405 0.00171486 0.00149516 0.0012705 0.00101204 0.000755658 0.000559312 0.000448432 0.000406141 0.000399506 0.000399554 0.000395054 0.00037265 0.000308162 0.000246181 0.000200361 0.000167147 0.000141715 0.00012073 0.000102545 8.64549e-05 7.2211e-05 5.97319e-05 4.8958e-05 3.97961e-05 3.21131e-05 2.57485e-05 2.0531e-05 1.62914e-05 1.28724e-05 1.01327e-05 7.94941e-06 6.21776e-06 4.85006e-06 3.77375e-06 2.92949e-06 2.26918e-06 1.75416e-06 1.35346e-06 1.0424e-06 8.01439e-07 6.15183e-07 4.71509e-07 3.60895e-07 2.75876e-07 2.10637e-07 1.60674e-07 1.22494e-07 9.33678e-08 7.11724e-08 5.42826e-08 4.14592e-08 3.17546e-08 2.44144e-08 1.88586e-08 1.46545e-08 1.14794e-08 9.09553e-09 7.30815e-09 5.96264e-09 4.93858e-09 4.16615e-09 3.59713e-09 3.17237e-09 2.86127e-09 2.62333e-09 2.45901e-09 2.32565e-09 2.224e-09 2.18111e-09 2.16071e-09 2.15483e-09 2.15837e-09 2.17938e-09 2.21748e-09 2.26583e-09 2.32864e-09 2.40403e-09 2.48952e-09 2.58789e-09 2.70059e-09 2.82309e-09 2.9627e-09 3.11663e-09 3.2828e-09 3.47096e-09 3.67297e-09 3.89421e-09 4.14257e-09 4.40462e-09 4.69814e-09 5.02035e-09 5.36028e-09 5.74971e-09 6.16316e-09 6.613e-09 7.12476e-09 7.65514e-09 8.26007e-09 8.9152e-09 9.61874e-09 1.04196e-08 1.12693e-08 1.22259e-08 1.3265e-08 1.44231e-08 1.56737e-08 1.71152e-08 1.85916e-08 2.05051e-08 2.20224e-08 2.50289e-08 2.58769e-08 3.1035e-08 3.13358e-08 3.79858e-08 3.86154e-08 4.80415e-08 4.82883e-08 6.29097e-08 6.25269e-08 8.69462e-08 8.58808e-08 1.29467e-07 1.32017e-07 2.08419e-07 2.37388e-07 3.87097e-07 5.32424e-07 8.93861e-07 4.92714e-06 7.95669e-05 8.11613e-05 8.25648e-05 8.30374e-05 8.38735e-05 8.61763e-05 8.91389e-05 9.40993e-05 0.000101167 0.000108183 0.000114103 0.000121067 0.000127517 0.00013131 0.000138715 0.000146106 0.000158342 0.000188029 0.000228638 0.000274322 0.000333003 0.000394211 0.000447324 0.00049844 0.000544631 0.000570822 0.000588307 0.000600365 0.000607325 0.000620117 0.000655415 0.000768175 0.000876186 0.00101221 0.00116237 0.00125042 0.00130098 0.00141317 0.00161785 0.00173996 0.00187929 0.00209702 0.00225892 0.00230621 0.00233739 0.00241435 0.00262997 0.00297573 0.00337702 0.00369963 0.00382857 0.00381336 0.00355197 0.00270588 0.00199185 0.00150125 0.00115755 0.00090496 0.000716476 0.000581957 0.000492767 0.000435962 0.000395364 0.000357787 0.000317865 0.000275843 0.000234193 0.000195333 0.000160747 0.00013098 0.000105941 8.52004e-05 6.82039e-05 5.43864e-05 4.32245e-05 3.42557e-05 2.70823e-05 2.1369e-05 1.6835e-05 1.32479e-05 1.04175e-05 8.18925e-06 6.43818e-06 5.0636e-06 3.98544e-06 3.14072e-06 2.47989e-06 1.96332e-06 1.55913e-06 1.2424e-06 9.94123e-07 7.99689e-07 6.47422e-07 5.27754e-07 4.33192e-07 3.58402e-07 2.99533e-07 2.53178e-07 2.16271e-07 1.86527e-07 1.62657e-07 1.43852e-07 1.28905e-07 1.16702e-07 1.0657e-07 9.83026e-08 9.20424e-08 8.72191e-08 8.30288e-08 7.94172e-08 7.65273e-08 7.48488e-08 7.36747e-08 7.28401e-08 7.22913e-08 7.2138e-08 7.21037e-08 7.25922e-08 7.35207e-08 7.46086e-08 7.62475e-08 7.80321e-08 8.01923e-08 8.27372e-08 8.55176e-08 8.8721e-08 9.22886e-08 9.61734e-08 1.00497e-07 1.05291e-07 1.10432e-07 1.16183e-07 1.22414e-07 1.29109e-07 1.36582e-07 1.44543e-07 1.53238e-07 1.62865e-07 1.73011e-07 1.84307e-07 1.96551e-07 2.09527e-07 2.24201e-07 2.39705e-07 2.566e-07 2.75524e-07 2.95198e-07 3.17445e-07 3.41363e-07 3.67056e-07 3.95978e-07 4.26625e-07 4.60816e-07 4.97872e-07 5.3871e-07 5.82938e-07 6.32878e-07 6.8513e-07 7.48775e-07 8.05575e-07 8.98158e-07 9.4174e-07 1.09598e-06 1.11413e-06 1.32911e-06 1.35504e-06 1.63889e-06 1.65613e-06 2.09269e-06 2.08027e-06 2.78311e-06 2.72194e-06 3.93193e-06 3.87471e-06 5.9115e-06 6.2704e-06 9.85662e-06 1.20698e-05 1.8547e-05 7.28403e-05 0.000245544 0.000257931 0.000266773 0.000276158 0.00029836 0.000341462 0.000400743 0.000472632 0.000550628 0.000634312 0.000714828 0.000786578 0.000852568 0.000907752 0.000970712 0.00107819 0.00123554 0.00144588 0.00171996 0.00203607 0.00237049 0.00270649 0.00299631 0.00320644 0.00334219 0.00340384 0.00340968 0.00340086 0.00338768 0.00338859 0.00342561 0.00362955 0.00413168 0.00459692 0.00495039 0.00522209 0.00547287 0.00577317 0.00614471 0.00647047 0.00660548 0.00659993 0.00648739 0.00607952 0.00576341 0.00567836 0.00573328 0.00625385 0.00751708 0.00826317 0.00846644 0.00839603 0.0077276 0.00593456 0.00443192 0.00334482 0.00260677 0.00212446 0.0018063 0.00158081 0.00140178 0.00124394 0.00109615 0.000955433 0.000822789 0.000700384 0.000590054 0.000492722 0.000408408 0.000336478 0.000275884 0.00022537 0.000183618 0.00014936 0.000121418 9.87248e-05 8.03534e-05 6.55225e-05 5.3569e-05 4.39351e-05 3.61687e-05 2.99081e-05 2.48563e-05 2.0767e-05 1.7443e-05 1.47354e-05 1.25334e-05 1.07434e-05 9.27811e-06 8.06524e-06 7.0568e-06 6.2226e-06 5.53553e-06 4.9647e-06 4.48049e-06 4.06652e-06 3.71981e-06 3.43492e-06 3.19577e-06 2.9873e-06 2.80645e-06 2.65864e-06 2.54232e-06 2.442e-06 2.35276e-06 2.2783e-06 2.22828e-06 2.19722e-06 2.17154e-06 2.15174e-06 2.14091e-06 2.13575e-06 2.13551e-06 2.15203e-06 2.16913e-06 2.2046e-06 2.24082e-06 2.28876e-06 2.3459e-06 2.40663e-06 2.48198e-06 2.56061e-06 2.65059e-06 2.75088e-06 2.85855e-06 2.97891e-06 3.10983e-06 3.25086e-06 3.40547e-06 3.57405e-06 3.754e-06 3.9525e-06 4.16536e-06 4.39349e-06 4.64495e-06 4.91154e-06 5.20162e-06 5.51866e-06 5.85283e-06 6.22178e-06 6.61762e-06 7.03858e-06 7.50763e-06 8.00173e-06 8.53955e-06 9.13259e-06 9.75159e-06 1.04436e-05 1.11828e-05 1.19762e-05 1.2858e-05 1.37912e-05 1.48218e-05 1.59344e-05 1.71475e-05 1.84614e-05 1.99164e-05 2.14605e-05 2.32466e-05 2.49842e-05 2.73815e-05 2.90051e-05 3.27172e-05 3.36411e-05 3.92415e-05 4.01493e-05 4.70362e-05 4.8046e-05 5.82418e-05 5.85221e-05 7.42755e-05 7.33001e-05 9.88789e-05 9.71191e-05 0.000138081 0.000141018 0.000207071 0.000233707 0.000328995 0.000918522 0.00278093 0.00284824 0.00289575 0.00298332 0.00319098 0.00352796 0.0039511 0.00444297 0.00498653 0.00553866 0.00605696 0.00652165 0.00697325 0.00748916 0.00810775 0.00885654 0.00976334 0.0107939 0.0118753 0.0129498 0.0139501 0.0147736 0.0153212 0.0155733 0.0156158 0.0155853 0.0154579 0.0151552 0.0149867 0.0149535 0.0150539 0.0157603 0.016822 0.0176893 0.0184006 0.0189025 0.01917 0.019273 0.0192833 0.0192455 0.0190748 0.0184226 0.0170285 0.0160142 0.015561 0.0155014 0.0156871 0.0167609 0.0179333 0.0183997 0.0184033 0.0178801 0.0153827 0.0120903 0.00958734 0.00775208 0.00643209 0.00547869 0.00477382 0.00423369 0.00379888 0.00342632 0.00308709 0.0027658 0.00245787 0.00216529 0.0018924 0.00164303 0.00141927 0.00122156 0.001049 0.00089977 0.000771604 0.000662182 0.000569202 0.000490356 0.000423569 0.000367147 0.000319533 0.000279249 0.000245106 0.000216208 0.000191752 0.000170955 0.00015314 0.000137841 0.00012479 0.000113756 0.000104361 9.61755e-05 8.89914e-05 8.28155e-05 7.76146e-05 7.32145e-05 6.93576e-05 6.58808e-05 6.28513e-05 6.04211e-05 5.84778e-05 5.6755e-05 5.5201e-05 5.38918e-05 5.30514e-05 5.26182e-05 5.22731e-05 5.2055e-05 5.19603e-05 5.1911e-05 5.21771e-05 5.24888e-05 5.31341e-05 5.38704e-05 5.4771e-05 5.59473e-05 5.71144e-05 5.86511e-05 6.01948e-05 6.20088e-05 6.40141e-05 6.6127e-05 6.85685e-05 7.10973e-05 7.39117e-05 7.69604e-05 8.02091e-05 8.37662e-05 8.75774e-05 9.16551e-05 9.60667e-05 0.000100814 0.00010586 0.000111348 0.000117187 0.00012342 0.000130197 0.000137353 0.000145085 0.000153427 0.000162213 0.0001718 0.000181995 0.000192837 0.000204711 0.000217189 0.000230692 0.000245338 0.000260671 0.000277542 0.000295447 0.000314586 0.00033552 0.000357615 0.000381693 0.000407503 0.000435305 0.00046526 0.000497791 0.000532457 0.000570928 0.000610317 0.000658111 0.000699077 0.000765078 0.000799108 0.000895982 0.000923417 0.00104583 0.00107892 0.00124111 0.00126871 0.00150556 0.00151706 0.00187142 0.0018705 0.00238353 0.00243024 0.00320213 0.00344074 0.00437954 0.00888834 0.0250891 0.0256535 0.0262402 0.0269643 0.0279626 0.0292394 0.0306627 0.03214 0.0337042 0.0353965 0.0370262 0.0384501 0.0398738 0.0415742 0.0436397 0.0459728 0.0484368 0.0510046 0.0535956 0.0558134 0.0571593 0.0575934 0.057593 0.0574449 0.0569338 0.055523 0.0541451 0.0532446 0.0528996 0.0528869 0.0534193 0.0548008 0.0554766 0.0555696 0.0554755 0.0551386 0.0540456 0.0521111 0.0503658 0.0485879 0.0464738 0.0441167 0.041977 0.0405148 0.0398606 0.0397475 0.0399128 0.0402021 0.0402175 0.0400614 0.0393316 0.0364627 0.0309504 0.0260762 0.022161 0.0191723 0.0169195 0.0151778 0.0137666 0.0125686 0.0115142 0.0105604 0.00967985 0.00885683 0.00808423 0.0073607 0.00668798 0.0060675 0.00549931 0.00498279 0.00451624 0.00409668 0.00372056 0.00338479 0.00308643 0.00282131 0.0025854 0.00237669 0.00219282 0.00202986 0.00188495 0.00175713 0.00164504 0.00154614 0.00145794 0.00137919 0.00130996 0.00125066 0.00119992 0.00115442 0.00111283 0.00107715 0.00104828 0.00102485 0.00100479 0.000986475 0.000970478 0.000958795 0.000954986 0.000953135 0.000952426 0.000953246 0.000956248 0.000962253 0.000970399 0.000981543 0.000995289 0.00101083 0.00103034 0.00105035 0.00107484 0.00110057 0.00112907 0.00116141 0.00119429 0.00123259 0.00127152 0.00131487 0.00136126 0.00140999 0.00146377 0.00151947 0.00157995 0.00164422 0.00171215 0.00178507 0.0018622 0.00194394 0.00203104 0.00212348 0.00222099 0.00232522 0.00243504 0.00255122 0.00267536 0.00280557 0.00294433 0.00309167 0.00324604 0.00341146 0.00358539 0.00376894 0.00396562 0.00417102 0.00439003 0.00462296 0.00486595 0.00512719 0.00540136 0.00569096 0.00600077 0.00632488 0.00667086 0.00703639 0.00742313 0.00783343 0.00826896 0.00872833 0.00922021 0.00973121 0.0102984 0.0108461 0.0115391 0.012073 0.0129867 0.0134316 0.0146334 0.0150801 0.0165042 0.0169618 0.0188344 0.0192229 0.0217048 0.0220693 0.0252861 0.0259389 0.0303718 0.0318406 0.0366962 0.0569624 0.142011 0.14259 0.14301 0.143459 0.144186 0.145243 0.146419 0.147753 0.14925 0.150816 0.152463 0.154126 0.155741 0.157587 0.160071 0.163138 0.166297 0.169062 0.170905 0.171539 0.17151 0.171238 0.170457 0.168076 0.163973 0.160282 0.157277 0.155162 0.154048 0.153548 0.153167 0.152679 0.151987 0.150859 0.148378 0.144558 0.140374 0.13615 0.13192 0.127356 0.122422 0.117774 0.114211 0.112018 0.110864 0.11011 0.109114 0.10728 0.10303 0.095711 0.0872338 0.0785657 0.070594 0.0638732 0.0584876 0.0541464 0.0504405 0.0470587 0.0438643 0.0408519 0.0380642 0.0355295 0.0332458 0.031189 0.029326 0.0276268 0.02607 0.024639 0.0233198 0.0221047 0.0209871 0.0199593 0.0190144 0.0181479 0.0173585 0.0166382 0.0159771 0.0153777 0.0148417 0.0143562 0.0139122 0.0135166 0.0131717 0.0128669 0.0125927 0.0123493 0.0121421 0.0119759 0.0118459 0.0117359 0.0116402 0.0115706 0.0115546 0.0115512 0.0115693 0.0116085 0.011668 0.0117476 0.0118484 0.0119698 0.0121126 0.0122766 0.0124605 0.0126677 0.0128927 0.0131415 0.0134105 0.0136978 0.0140141 0.0143409 0.0147018 0.0150764 0.0154764 0.0159053 0.0163463 0.0168264 0.0173179 0.0178441 0.0183947 0.0189682 0.0195779 0.0202068 0.0208716 0.0215647 0.0222872 0.023045 0.0238336 0.0246558 0.0255146 0.0264091 0.0273387 0.0283102 0.0293178 0.0303658 0.0314599 0.0325914 0.0337717 0.0349984 0.0362661 0.0375905 0.0389587 0.0403777 0.0418575 0.0433808 0.0449677 0.0466136 0.0483072 0.0500755 0.0518966 0.0537811 0.0557409 0.0577553 0.0598482 0.0620092 0.0642412 0.0665519 0.0689396 0.0714029 0.0739552 0.0765756 0.0793178 0.0820711 0.0850816 0.0878819 0.0913279 0.0939775 0.0981692 0.100392 0.105556 0.107669 0.113712 0.115527 0.1229 0.124553 0.133419 0.135538 0.146558 0.150438 0.161778 0.206154 0.516238 0.505275 0.495354 0.48647 0.478893 0.472422 0.466896 0.46233 0.458567 0.455549 0.453292 0.451791 0.450926 0.450358 0.449935 0.449652 0.44943 0.449279 0.448942 0.44805 0.446609 0.444912 0.443068 0.441261 0.43948 0.437351 0.434482 0.430768 0.426297 0.420993 0.414556 0.406907 0.398463 0.389912 0.381802 0.374312 0.367395 0.360863 0.354259 0.347186 0.339864 0.332884 0.326411 0.319832 0.312071 0.30224 0.2901 0.276078 0.260956 0.245652 0.231093 0.218003 0.206646 0.196755 0.187759 0.179122 0.17058 0.162166 0.154086 0.14656 0.139725 0.133606 0.128151 0.123274 0.118884 0.114906 0.111286 0.107979 0.104951 0.102179 0.0996441 0.0973246 0.0952073 0.0932806 0.0915389 0.0899666 0.0885435 0.0872769 0.0861761 0.0852099 0.0843523 0.0836296 0.0830607 0.0826072 0.0822356 0.0819705 0.0818481 0.0818297 0.0819073 0.0820831 0.0823507 0.0827074 0.0831531 0.0836874 0.0843081 0.0850128 0.0858004 0.0866698 0.0876198 0.0886479 0.0897536 0.0909346 0.0921897 0.0935218 0.0949225 0.0964014 0.0979477 0.0995632 0.101258 0.103004 0.104841 0.106727 0.108691 0.110725 0.11281 0.114983 0.117199 0.119497 0.121853 0.12427 0.126762 0.129302 0.131918 0.13459 0.137324 0.140123 0.142979 0.145896 0.148875 0.151913 0.155007 0.158165 0.161375 0.164643 0.167973 0.171351 0.174793 0.178288 0.181831 0.185437 0.189086 0.19279 0.196551 0.20035 0.204211 0.208117 0.212061 0.216066 0.220104 0.224191 0.228328 0.232495 0.236715 0.240971 0.245266 0.249607 0.253983 0.258395 0.262848 0.267332 0.271854 0.276414 0.280999 0.285667 0.290247 0.295154 0.299562 0.304853 0.309237 0.314382 0.319896 0.323473 0.331449 0.333844 0.34404 0.345068 0.358067 0.359332 0.372046 0.412398 1.21286 1.1429 1.08271 1.03157 0.988333 0.951926 0.921468 0.896181 0.875251 0.858002 0.843979 0.832518 0.822888 0.814584 0.807214 0.800678 0.794948 0.789598 0.784254 0.7789 0.773647 0.768746 0.764304 0.760022 0.755493 0.7503 0.744202 0.737438 0.7302 0.722206 0.713391 0.704295 0.69544 0.686946 0.678706 0.670569 0.662371 0.653976 0.64523 0.636117 0.626609 0.616344 0.604742 0.591463 0.576708 0.561132 0.545542 0.530608 0.516673 0.503709 0.491429 0.479447 0.467389 0.455024 0.442379 0.429738 0.417503 0.406031 0.395531 0.386053 0.377534 0.369855 0.362886 0.356517 0.350657 0.345256 0.340275 0.33567 0.331403 0.327453 0.323799 0.320432 0.317345 0.314527 0.311963 0.309646 0.307575 0.305744 0.304141 0.302755 0.30158 0.300615 0.299857 0.2993 0.298944 0.29878 0.298755 0.298891 0.299251 0.29975 0.300391 0.301173 0.302098 0.303171 0.304386 0.305728 0.307188 0.308765 0.310453 0.312248 0.314144 0.316138 0.318225 0.320403 0.322666 0.325011 0.327432 0.329927 0.332491 0.33512 0.337815 0.340566 0.343376 0.346238 0.349147 0.352107 0.355106 0.358151 0.361233 0.364352 0.367504 0.370687 0.373899 0.377137 0.380401 0.383686 0.386992 0.390317 0.393658 0.397015 0.400385 0.403767 0.407158 0.410558 0.413968 0.417382 0.420804 0.424229 0.427654 0.431083 0.434508 0.437935 0.441362 0.444784 0.448207 0.451621 0.455028 0.458433 0.461829 0.465219 0.468602 0.471973 0.475338 0.478692 0.482036 0.485372 0.488693 0.492 0.495291 0.498569 0.501816 0.505085 0.50823 0.511584 0.514417 0.518196 0.520194 0.524926 0.525927 0.531406 0.531078 0.537148 0.535965 0.541183 0.541828 0.542138 0.548572 0.540231 0.551759 0.551092 1.51858 1.37683 1.27146 1.19183 1.13051 1.08264 1.04455 1.01347 0.98782 0.966451 0.948052 0.931559 0.916556 0.903044 0.890996 0.880182 0.870237 0.860748 0.851403 0.8422 0.833353 0.825004 0.817125 0.809597 0.802342 0.795522 0.789394 0.783918 0.778825 0.773973 0.769381 0.765033 0.760795 0.756469 0.751854 0.746864 0.741546 0.735887 0.729887 0.723496 0.716701 0.709566 0.702192 0.694775 0.687507 0.680455 0.673556 0.666706 0.65983 0.652857 0.645715 0.638397 0.630999 0.623707 0.616756 0.610361 0.604646 0.599627 0.595229 0.591331 0.587812 0.58457 0.581531 0.578647 0.575894 0.57325 0.570705 0.568266 0.565941 0.563729 0.561629 0.559644 0.557775 0.556022 0.554389 0.552876 0.551483 0.550213 0.549066 0.548043 0.547145 0.546371 0.545717 0.545182 0.544765 0.544461 0.544286 0.544257 0.544314 0.544457 0.544684 0.544974 0.54535 0.545849 0.546489 0.547241 0.54803 0.548887 0.549815 0.550811 0.551871 0.552993 0.554174 0.555409 0.556697 0.558031 0.559413 0.560832 0.562292 0.563791 0.565314 0.566883 0.568463 0.570083 0.571719 0.573372 0.57506 0.576744 0.578464 0.580183 0.581919 0.583668 0.585416 0.587182 0.588945 0.590716 0.592492 0.594265 0.596044 0.597822 0.599596 0.601369 0.603142 0.604908 0.606672 0.608433 0.610182 0.611927 0.613661 0.615386 0.617109 0.618816 0.620516 0.622207 0.623876 0.625541 0.627191 0.628823 0.630451 0.632054 0.633642 0.635218 0.636768 0.638305 0.639817 0.641303 0.642761 0.644189 0.645579 0.64694 0.648238 0.649534 0.650667 0.65193 0.652742 0.654151 0.654015 0.656192 0.653974 0.658117 0.652032 0.659169 0.648157 0.65654 0.643204 0.645423 0.637971 0.618134 0.61817 0.566453 0.991373 0.88293 0.816959 0.77187 0.737565 0.708862 0.682818 0.658087 0.634198 0.611078 0.588762 0.567363 0.547112 0.528244 0.51087 0.494934 0.480309 0.466983 0.455091 0.444758 0.435964 0.428518 0.422153 0.416641 0.411872 0.407797 0.404315 0.401221 0.398349 0.395734 0.393547 0.391887 0.390736 0.390047 0.389812 0.390016 0.390671 0.391831 0.393383 0.395285 0.397449 0.399787 0.402302 0.405013 0.407923 0.411029 0.414333 0.417833 0.421526 0.425386 0.429367 0.433409 0.437484 0.441595 0.445764 0.449999 0.454277 0.458555 0.462772 0.466869 0.470792 0.474503 0.477978 0.481207 0.48419 0.486932 0.489437 0.491715 0.49378 0.495643 0.49732 0.498821 0.500159 0.501337 0.502375 0.503289 0.504089 0.504794 0.50541 0.505947 0.506411 0.506813 0.507157 0.507452 0.507705 0.507924 0.508116 0.508285 0.50843 0.508557 0.508668 0.508766 0.508858 0.50895 0.509042 0.50913 0.509213 0.509293 0.509371 0.50945 0.509531 0.509613 0.509696 0.50978 0.509864 0.509946 0.510029 0.510108 0.510187 0.510266 0.510338 0.510416 0.51048 0.510549 0.510606 0.510661 0.510716 0.510753 0.510795 0.510817 0.510838 0.510849 0.510848 0.510846 0.510824 0.510799 0.51076 0.51071 0.510651 0.510578 0.510493 0.510397 0.51029 0.510169 0.510036 0.509887 0.50972 0.509541 0.509346 0.509138 0.50892 0.508681 0.508428 0.508159 0.507865 0.507563 0.507242 0.506901 0.506549 0.50617 0.505774 0.50536 0.504918 0.504457 0.503964 0.503439 0.502881 0.502288 0.501651 0.500976 0.500228 0.499455 0.4985 0.497669 0.496279 0.495606 0.493145 0.493306 0.488407 0.490403 0.481434 0.486438 0.471401 0.478449 0.458245 0.460636 0.440651 0.423001 0.408737 0.330871 0.853512 0.931136 1.07104 1.18647 1.26243 1.30513 1.32612 1.33409 1.34323 1.3552 1.3742 1.39419 1.42501 1.44874 1.49318 1.51482 1.58124 1.59239 1.68605 1.68772 1.80518 1.80481 1.95725 1.9221 2.18521 0.599671 0.551575 0.55532 0.577988 0.63221 0.707208 0.783607 0.852379 0.915836 0.975692 1.03812 1.09662 1.16666 1.22203 1.31 1.35783 1.46898 1.51213 1.64648 1.68869 1.84437 1.89857 2.09135 2.13785 2.38692 0.158241 0.139149 0.129975 0.130262 0.13626 0.153653 0.183134 0.219033 0.259209 0.302416 0.350449 0.399723 0.461557 0.514858 0.601075 0.651144 0.767506 0.821379 0.958707 1.01891 1.174 1.24785 1.42885 1.51404 1.7217 0.0210121 0.017359 0.0155256 0.0140334 0.0138531 0.0149181 0.018679 0.0245914 0.0324074 0.0419476 0.0543194 0.0670258 0.0878035 0.102882 0.140066 0.160735 0.21757 0.2487 0.333209 0.378705 0.492957 0.558723 0.709936 0.79824 0.990987 0.00173066 0.00131556 0.00109606 0.000889007 0.000762676 0.000760746 0.000930467 0.0012945 0.00191318 0.00266888 0.00406999 0.00504609 0.00802254 0.00959004 0.0151886 0.01848 0.0294434 0.0362989 0.05783 0.0719743 0.113188 0.140241 0.215081 0.266305 0.399219 0.000109616 8.03337e-05 6.28436e-05 4.94062e-05 3.79894e-05 3.47638e-05 3.77299e-05 4.72622e-05 7.63826e-05 0.000100193 0.000191403 0.000226676 0.000417024 0.000495075 0.00090225 0.00110322 0.00203703 0.002631 0.00483228 0.00658357 0.0126897 0.0170445 0.0333632 0.0467456 0.0918952 6.295e-06 4.77973e-06 3.92113e-06 3.27993e-06 2.83881e-06 2.77875e-06 2.93048e-06 3.12326e-06 4.35047e-06 5.13314e-06 9.21838e-06 1.06207e-05 1.92706e-05 2.22753e-05 4.27745e-05 5.06862e-05 9.87901e-05 0.00014228 0.000207051 0.00041787 0.000789179 0.00107524 0.0027501 0.00423801 0.0106591 3.79228e-07 3.54403e-07 3.66363e-07 4.41143e-07 5.30267e-07 6.13665e-07 7.7527e-07 1.17575e-06 1.59186e-06 1.89165e-06 2.08381e-06 2.23399e-06 2.44083e-06 2.64102e-06 3.48103e-06 3.93709e-06 5.8683e-06 9.6386e-06 1.10452e-05 2.63396e-05 4.07003e-05 5.44975e-05 0.000167627 0.000258837 0.000714448 3.97895e-08 5.27612e-08 8.20678e-08 1.55967e-07 2.36726e-07 3.52844e-07 5.15922e-07 7.95524e-07 1.05962e-06 1.45681e-06 1.63188e-06 1.93351e-06 2.01289e-06 2.30502e-06 2.38707e-06 2.83925e-06 3.04869e-06 3.74039e-06 4.31007e-06 5.35961e-06 7.61014e-06 8.84803e-06 1.67908e-05 2.25166e-05 5.07235e-05 1.24344e-08 2.342e-08 4.56422e-08 9.86072e-08 1.87132e-07 2.62681e-07 3.79709e-07 6.39031e-07 8.85809e-07 1.21379e-06 1.33445e-06 1.55683e-06 1.59788e-06 1.80041e-06 1.83146e-06 2.14018e-06 2.25777e-06 2.6279e-06 3.24634e-06 3.49863e-06 4.66253e-06 5.2703e-06 7.12316e-06 8.16794e-06 1.29043e-05 8.30683e-09 1.74482e-08 3.48748e-08 7.56765e-08 1.2858e-07 2.25103e-07 3.2487e-07 5.13301e-07 6.80073e-07 1.01521e-06 1.1636e-06 1.48373e-06 1.60407e-06 1.94528e-06 2.06497e-06 2.51248e-06 2.69711e-06 3.17895e-06 3.77865e-06 4.10637e-06 5.30809e-06 5.96494e-06 7.59509e-06 8.5651e-06 1.23764e-05 6.6378e-09 1.45618e-08 2.76795e-08 5.90782e-08 1.08795e-07 1.78102e-07 2.59816e-07 4.35716e-07 5.88981e-07 8.71389e-07 1.00086e-06 1.27457e-06 1.36786e-06 1.63128e-06 1.72068e-06 2.08142e-06 2.24053e-06 2.75869e-06 3.15367e-06 3.59447e-06 4.7952e-06 5.36591e-06 6.91364e-06 7.84859e-06 1.14461e-05 5.50598e-09 1.18742e-08 2.25601e-08 4.83997e-08 8.14354e-08 1.50472e-07 2.24964e-07 3.70996e-07 4.85841e-07 7.4771e-07 8.82526e-07 1.18873e-06 1.33228e-06 1.69312e-06 1.83811e-06 2.28704e-06 2.47284e-06 3.02852e-06 3.38284e-06 3.86168e-06 5.06249e-06 5.58041e-06 7.07081e-06 8.03814e-06 1.16206e-05 4.66898e-09 1.02212e-08 1.91367e-08 3.79611e-08 6.96228e-08 1.30278e-07 1.89154e-07 3.15084e-07 4.22591e-07 6.69554e-07 7.9751e-07 1.08046e-06 1.2097e-06 1.52321e-06 1.65731e-06 2.07049e-06 2.26168e-06 2.87247e-06 3.17043e-06 3.9254e-06 4.80254e-06 5.34853e-06 7.08785e-06 8.08423e-06 1.15271e-05 4.03809e-09 8.54134e-09 1.60575e-08 3.33942e-08 5.70202e-08 1.08627e-07 1.64249e-07 2.79166e-07 3.70059e-07 5.84658e-07 7.06875e-07 9.86524e-07 1.13364e-06 1.48663e-06 1.64274e-06 2.08806e-06 2.27918e-06 2.8967e-06 3.17575e-06 3.94762e-06 4.76982e-06 5.29711e-06 7.03512e-06 8.04039e-06 1.138e-05 3.60936e-09 7.51381e-09 1.40896e-08 2.88106e-08 4.9239e-08 9.52001e-08 1.46019e-07 2.46671e-07 3.29029e-07 5.29759e-07 6.53609e-07 9.32727e-07 1.07927e-06 1.42039e-06 1.5838e-06 2.03553e-06 2.2375e-06 2.88716e-06 3.15893e-06 4.01211e-06 4.76181e-06 5.32334e-06 7.16361e-06 8.17727e-06 1.15007e-05 3.19126e-09 6.54172e-09 1.22384e-08 2.56356e-08 4.3158e-08 8.13554e-08 1.28598e-07 2.20755e-07 2.95073e-07 4.75779e-07 5.92437e-07 8.59039e-07 1.00589e-06 1.34397e-06 1.51067e-06 1.96151e-06 2.16259e-06 2.83469e-06 3.08354e-06 3.99416e-06 4.63624e-06 5.21612e-06 7.10161e-06 8.0573e-06 1.12283e-05 2.805e-09 5.77723e-09 1.07465e-08 2.21097e-08 3.73444e-08 7.13203e-08 1.14759e-07 1.97399e-07 2.64411e-07 4.29228e-07 5.41192e-07 7.99598e-07 9.45651e-07 1.28087e-06 1.44825e-06 1.89956e-06 2.09597e-06 2.76941e-06 3.00033e-06 3.91095e-06 4.51338e-06 5.05401e-06 6.90377e-06 7.77944e-06 1.072e-05 2.67165e-09 5.48662e-09 1.01655e-08 2.02408e-08 3.4613e-08 6.80933e-08 1.06839e-07 1.88697e-07 2.55974e-07 4.22683e-07 5.38952e-07 8.07614e-07 9.65553e-07 1.33656e-06 1.52582e-06 2.04964e-06 2.27415e-06 3.0736e-06 3.34246e-06 4.43296e-06 5.13781e-06 5.81637e-06 8.05169e-06 9.15043e-06 1.28824e-05 2.48439e-09 5.08464e-09 9.33059e-09 1.85817e-08 3.18353e-08 6.19563e-08 9.64684e-08 1.74347e-07 2.38493e-07 3.95644e-07 5.08751e-07 7.72682e-07 9.3349e-07 1.31409e-06 1.51018e-06 2.05874e-06 2.28498e-06 3.14381e-06 3.40122e-06 4.6005e-06 5.27601e-06 6.03105e-06 8.447e-06 9.59775e-06 1.35373e-05 2.29633e-09 4.69256e-09 8.44745e-09 1.71783e-08 2.90735e-08 5.57556e-08 8.78984e-08 1.60413e-07 2.20513e-07 3.67665e-07 4.75828e-07 7.29138e-07 8.85197e-07 1.25332e-06 1.44691e-06 1.98845e-06 2.20894e-06 3.06286e-06 3.30134e-06 4.489e-06 5.12474e-06 5.84344e-06 8.18976e-06 9.25852e-06 1.29722e-05 2.18568e-09 4.50923e-09 8.05707e-09 1.61098e-08 2.74775e-08 5.2666e-08 8.26085e-08 1.51427e-07 2.10141e-07 3.52633e-07 4.57987e-07 7.04625e-07 8.60426e-07 1.2263e-06 1.42316e-06 1.96878e-06 2.19034e-06 3.06469e-06 3.29465e-06 4.52394e-06 5.13992e-06 5.87538e-06 8.27093e-06 9.33579e-06 1.3064e-05 2.10044e-09 4.30963e-09 7.62618e-09 1.52189e-08 2.61138e-08 4.96135e-08 7.77258e-08 1.43191e-07 2.00144e-07 3.37582e-07 4.40018e-07 6.80312e-07 8.35048e-07 1.19829e-06 1.39702e-06 1.94554e-06 2.16752e-06 3.05453e-06 3.27924e-06 4.53219e-06 5.1303e-06 5.878e-06 8.27614e-06 9.33392e-06 1.30357e-05 2.04448e-09 4.16996e-09 7.31972e-09 1.44546e-08 2.51813e-08 4.75188e-08 7.43775e-08 1.37193e-07 1.92772e-07 3.2673e-07 4.2796e-07 6.65762e-07 8.202e-07 1.18159e-06 1.38122e-06 1.93205e-06 2.15282e-06 3.05191e-06 3.2684e-06 4.5405e-06 5.12822e-06 5.8715e-06 8.28326e-06 9.33438e-06 1.30167e-05 2.03358e-09 4.04895e-09 7.07102e-09 1.38781e-08 2.47812e-08 4.60621e-08 7.16852e-08 1.32418e-07 1.87625e-07 3.19857e-07 4.18964e-07 6.51615e-07 8.04783e-07 1.1641e-06 1.36451e-06 1.91635e-06 2.13641e-06 3.04058e-06 3.25138e-06 4.53661e-06 5.10333e-06 5.85008e-06 8.26219e-06 9.28557e-06 1.29095e-05 1.98518e-09 3.99304e-09 6.94587e-09 1.3701e-08 2.42665e-08 4.49145e-08 7.01429e-08 1.29816e-07 1.84088e-07 3.14303e-07 4.12967e-07 6.44654e-07 7.97623e-07 1.15661e-06 1.35803e-06 1.91468e-06 2.13649e-06 3.05225e-06 3.265e-06 4.5633e-06 5.13536e-06 5.89229e-06 8.31581e-06 9.34711e-06 1.29966e-05 1.98788e-09 3.94999e-09 6.88181e-09 1.34127e-08 2.45868e-08 4.42764e-08 6.88475e-08 1.27834e-07 1.8252e-07 3.12815e-07 4.10744e-07 6.40492e-07 7.93461e-07 1.15203e-06 1.35454e-06 1.91182e-06 2.13452e-06 3.05426e-06 3.2665e-06 4.57631e-06 5.14815e-06 5.91094e-06 8.35029e-06 9.39368e-06 1.30645e-05 2.07913e-09 3.77043e-09 6.61679e-09 1.30455e-08 2.55502e-08 4.29399e-08 6.60952e-08 1.235e-07 1.78651e-07 3.07592e-07 4.0088e-07 6.18785e-07 7.65051e-07 1.10719e-06 1.30248e-06 1.83071e-06 2.04341e-06 2.90649e-06 3.10518e-06 4.32908e-06 4.85323e-06 5.55337e-06 7.80176e-06 8.73729e-06 1.20374e-05 2.04449e-09 3.85161e-09 6.70379e-09 1.30361e-08 2.53042e-08 4.33588e-08 6.69133e-08 1.24377e-07 1.78747e-07 3.06341e-07 4.00099e-07 6.195e-07 7.6643e-07 1.10864e-06 1.30477e-06 1.83291e-06 2.04749e-06 2.90985e-06 3.11111e-06 4.33246e-06 4.85851e-06 5.56321e-06 7.81106e-06 8.7556e-06 1.20776e-05 2.00501e-09 3.98445e-09 6.91559e-09 1.3171e-08 2.54783e-08 4.42071e-08 6.86422e-08 1.26794e-07 1.81394e-07 3.10757e-07 4.05853e-07 6.27934e-07 7.75354e-07 1.11816e-06 1.31345e-06 1.84095e-06 2.05544e-06 2.91554e-06 3.11857e-06 4.33841e-06 4.86972e-06 5.57568e-06 7.83102e-06 8.78752e-06 1.21314e-05 2.01554e-09 4.12171e-09 7.17243e-09 1.36077e-08 2.49533e-08 4.61487e-08 7.14124e-08 1.29891e-07 1.83186e-07 3.11668e-07 4.08927e-07 6.36363e-07 7.85055e-07 1.12971e-06 1.32415e-06 1.84927e-06 2.06389e-06 2.9163e-06 3.12384e-06 4.33099e-06 4.86927e-06 5.57522e-06 7.82168e-06 8.77574e-06 1.21364e-05 2.07985e-09 4.30922e-09 7.61619e-09 1.43698e-08 2.63744e-08 4.92997e-08 7.53258e-08 1.36529e-07 1.9172e-07 3.23341e-07 4.20704e-07 6.47927e-07 7.96627e-07 1.14252e-06 1.33606e-06 1.85714e-06 2.0711e-06 2.90914e-06 3.11946e-06 4.30385e-06 4.84564e-06 5.54132e-06 7.76315e-06 8.71078e-06 1.20579e-05 2.06348e-09 4.29677e-09 7.6888e-09 1.51825e-08 2.5609e-08 4.95962e-08 8.0141e-08 1.42214e-07 1.95631e-07 3.2773e-07 4.30123e-07 6.69556e-07 8.20727e-07 1.16913e-06 1.36193e-06 1.88523e-06 2.10299e-06 2.94677e-06 3.16529e-06 4.36308e-06 4.91817e-06 5.6348e-06 7.90587e-06 8.89435e-06 1.23511e-05 2.26697e-09 4.54459e-09 8.40932e-09 1.59135e-08 2.69029e-08 5.27353e-08 8.52331e-08 1.48193e-07 2.02876e-07 3.3893e-07 4.44194e-07 6.91704e-07 8.46104e-07 1.20035e-06 1.39568e-06 1.91918e-06 2.14111e-06 2.97885e-06 3.20839e-06 4.39914e-06 4.9763e-06 5.69242e-06 7.98109e-06 8.99221e-06 1.25202e-05 3.12357e-09 5.61994e-09 1.02246e-08 2.08516e-08 3.9076e-08 6.42843e-08 9.86928e-08 1.81829e-07 2.54334e-07 4.20621e-07 5.31153e-07 7.83854e-07 9.45897e-07 1.31732e-06 1.52659e-06 2.06507e-06 2.30291e-06 3.13314e-06 3.37806e-06 4.53651e-06 5.13019e-06 5.81587e-06 8.02918e-06 8.99379e-06 1.23254e-05 3.17907e-09 6.04511e-09 1.09724e-08 2.2215e-08 4.15225e-08 6.96658e-08 1.07551e-07 1.94217e-07 2.68096e-07 4.42026e-07 5.57548e-07 8.22359e-07 9.87689e-07 1.36448e-06 1.57128e-06 2.10328e-06 2.33837e-06 3.16098e-06 3.40848e-06 4.56585e-06 5.186e-06 5.88383e-06 8.13472e-06 9.1398e-06 1.26086e-05 3.33323e-09 6.57214e-09 1.20904e-08 2.47435e-08 4.42607e-08 7.69398e-08 1.18838e-07 2.10366e-07 2.87334e-07 4.72647e-07 5.94859e-07 8.72824e-07 1.03928e-06 1.42106e-06 1.63097e-06 2.17455e-06 2.42263e-06 3.23772e-06 3.50907e-06 4.63984e-06 5.28685e-06 5.9761e-06 8.24306e-06 9.28732e-06 1.28614e-05 3.78204e-09 7.59918e-09 1.40532e-08 2.8718e-08 5.1661e-08 8.83408e-08 1.35112e-07 2.38596e-07 3.22251e-07 5.19743e-07 6.44954e-07 9.30498e-07 1.09427e-06 1.46426e-06 1.65344e-06 2.14725e-06 2.37372e-06 3.14e-06 3.40992e-06 4.49466e-06 5.18586e-06 5.86533e-06 8.09031e-06 9.13448e-06 1.27154e-05 4.27436e-09 8.60494e-09 1.61652e-08 3.46179e-08 5.65904e-08 1.03798e-07 1.55914e-07 2.6712e-07 3.56202e-07 5.69128e-07 6.98395e-07 9.90356e-07 1.15718e-06 1.5465e-06 1.74754e-06 2.2777e-06 2.52555e-06 3.29869e-06 3.5989e-06 4.63918e-06 5.37852e-06 6.03258e-06 8.21805e-06 9.29192e-06 1.29933e-05 4.99507e-09 1.04399e-08 1.94413e-08 4.16162e-08 6.81174e-08 1.19603e-07 1.83266e-07 3.06669e-07 4.04278e-07 6.37935e-07 7.75309e-07 1.08161e-06 1.23688e-06 1.59427e-06 1.76325e-06 2.22165e-06 2.43521e-06 3.12569e-06 3.41679e-06 4.3741e-06 5.18131e-06 5.80057e-06 7.93052e-06 9.01292e-06 1.27958e-05 6.00985e-09 1.29109e-08 2.37528e-08 5.06339e-08 8.11397e-08 1.4551e-07 2.13091e-07 3.53101e-07 4.66695e-07 7.23995e-07 8.6037e-07 1.16844e-06 1.32956e-06 1.71534e-06 1.89771e-06 2.40009e-06 2.63858e-06 3.34733e-06 3.68611e-06 4.58721e-06 5.52705e-06 6.14048e-06 8.20427e-06 9.34246e-06 1.33073e-05 7.6734e-09 1.57586e-08 3.00586e-08 6.46428e-08 1.01531e-07 1.79176e-07 2.63198e-07 4.19058e-07 5.48766e-07 8.36701e-07 9.88516e-07 1.3146e-06 1.44712e-06 1.77181e-06 1.90477e-06 2.31654e-06 2.51287e-06 3.12876e-06 3.46092e-06 4.20952e-06 5.29145e-06 5.84193e-06 7.72895e-06 8.79536e-06 1.28306e-05 9.75661e-09 2.11844e-08 3.89327e-08 8.39676e-08 1.37966e-07 2.18073e-07 3.14582e-07 5.07278e-07 6.63503e-07 9.76379e-07 1.11911e-06 1.43376e-06 1.57379e-06 1.93726e-06 2.09083e-06 2.56068e-06 2.77905e-06 3.39069e-06 3.80809e-06 4.37111e-06 5.74703e-06 6.36081e-06 8.19971e-06 9.26925e-06 1.35379e-05 1.35699e-08 2.69163e-08 5.27273e-08 1.10613e-07 1.76788e-07 2.80152e-07 4.00415e-07 6.13166e-07 8.10162e-07 1.16315e-06 1.34436e-06 1.65119e-06 1.74026e-06 2.00428e-06 2.07983e-06 2.43602e-06 2.60743e-06 3.11756e-06 3.70561e-06 4.10744e-06 5.43366e-06 6.09291e-06 7.97746e-06 8.91521e-06 1.30633e-05 2.10773e-08 4.18794e-08 8.30329e-08 1.84904e-07 2.92637e-07 3.97329e-07 5.83069e-07 9.38175e-07 1.23775e-06 1.64372e-06 1.79242e-06 2.10907e-06 2.20793e-06 2.55738e-06 2.66492e-06 3.16649e-06 3.3779e-06 3.87348e-06 4.77895e-06 5.12575e-06 6.64885e-06 7.50781e-06 9.79986e-06 1.10083e-05 1.63012e-05 4.35301e-08 7.11273e-08 1.23651e-07 2.51992e-07 3.88521e-07 4.97639e-07 7.11322e-07 1.1198e-06 1.52734e-06 1.93716e-06 2.08248e-06 2.26332e-06 2.24026e-06 2.38873e-06 2.35001e-06 2.65392e-06 2.75604e-06 3.08077e-06 4.07357e-06 4.27166e-06 5.72158e-06 6.44851e-06 8.6839e-06 9.63198e-06 1.50319e-05 2.67986e-07 2.80925e-07 3.27125e-07 4.4089e-07 5.29085e-07 6.47107e-07 9.38357e-07 1.4817e-06 1.88384e-06 2.20185e-06 2.26897e-06 2.41407e-06 2.38461e-06 2.55374e-06 2.53166e-06 2.86636e-06 3.01828e-06 3.35414e-06 4.72516e-06 5.17269e-06 8.18364e-06 9.25014e-06 2.43884e-05 2.87095e-05 6.81262e-05 3.20486e-06 2.45286e-06 1.96227e-06 1.64812e-06 1.50323e-06 1.48187e-06 1.55693e-06 1.96705e-06 2.4884e-06 2.7832e-06 2.99472e-06 3.03376e-06 3.38404e-06 3.45165e-06 5.27355e-06 5.76887e-06 1.27886e-05 1.53134e-05 3.43574e-05 4.93714e-05 0.000129114 0.000166479 0.000565916 0.0008099 0.00219891 4.58181e-05 3.17095e-05 2.23989e-05 1.60903e-05 1.12926e-05 8.3582e-06 7.61297e-06 7.45272e-06 9.62238e-06 1.07281e-05 1.95429e-05 2.32541e-05 4.85321e-05 5.87632e-05 0.000133075 0.000163177 0.000381683 0.000497587 0.00110512 0.00157359 0.00355142 0.00491965 0.0113871 0.0163638 0.0354498 0.000592645 0.000417422 0.000303853 0.000229914 0.000163451 0.000133606 0.000135027 0.000152299 0.000238502 0.000304128 0.000574163 0.000739558 0.00140141 0.00180746 0.00341225 0.00439688 0.00832624 0.0107597 0.0197902 0.0258644 0.0451921 0.0583421 0.0985343 0.125536 0.201286 0.00607807 0.0045784 0.00368347 0.00303297 0.00250921 0.00248187 0.00276409 0.00359163 0.00521145 0.00702337 0.0110269 0.0140326 0.0221763 0.0274384 0.0424939 0.0513995 0.0785109 0.0928121 0.137283 0.160972 0.224501 0.261742 0.354057 0.406989 0.530848 0.0416244 0.0337433 0.0290966 0.0260056 0.0257492 0.0271348 0.0319899 0.0415507 0.0545096 0.0697074 0.0901527 0.109705 0.141336 0.162354 0.210934 0.235434 0.300319 0.329067 0.412857 0.449022 0.546448 0.595892 0.719002 0.781313 0.928532 0.163447 0.139331 0.124804 0.123578 0.127465 0.140267 0.169117 0.203426 0.239902 0.27677 0.317245 0.355111 0.403634 0.439444 0.504121 0.536754 0.61914 0.652225 0.753279 0.790418 0.906527 0.956599 1.10198 1.16038 1.33058 0.367894 0.324712 0.310168 0.317072 0.340142 0.388671 0.441495 0.488806 0.531743 0.571931 0.614764 0.654668 0.705151 0.743705 0.810489 0.845467 0.932729 0.966567 1.07606 1.11079 1.24082 1.28539 1.45096 1.49338 1.69599 0.509309 0.48773 0.505401 0.552984 0.618946 0.680345 0.728731 0.766397 0.801183 0.835512 0.874351 0.911527 0.95978 0.9975 1.06206 1.09686 1.18284 1.21508 1.32591 1.35562 1.49236 1.52638 1.70464 1.72101 1.96267 0.558425 0.599571 0.689016 0.773967 0.840259 0.883902 0.911284 0.932797 0.956472 0.982113 1.01345 1.04381 1.0851 1.11692 1.17308 1.20265 1.27823 1.30393 1.4041 1.42401 1.55208 1.56979 1.74106 1.72581 1.99075 0.387213 0.512337 0.597279 0.649944 0.678629 0.688996 0.690743 0.692794 0.699421 0.708544 0.721948 0.735212 0.755285 0.769889 0.79859 0.811491 0.85186 0.861113 0.916653 0.920282 0.994312 0.992443 1.09489 1.06383 1.24732 ) ; boundaryField { inlet { type fixedValue; value uniform 2e-05; } outlet { type inletOutlet; inletValue uniform 0; value nonuniform List<scalar> 57 ( 2.18521 2.38692 1.7217 0.990987 0.399219 0.0918952 0.0106591 0.000714448 5.07235e-05 1.29043e-05 1.23764e-05 1.14461e-05 1.16206e-05 1.15271e-05 1.138e-05 1.15007e-05 1.12283e-05 1.072e-05 1.28824e-05 1.35373e-05 1.29722e-05 1.3064e-05 1.30357e-05 1.30167e-05 1.29095e-05 1.29966e-05 1.30645e-05 1.20374e-05 1.20776e-05 1.21314e-05 1.21364e-05 1.20579e-05 1.23511e-05 1.25202e-05 1.23254e-05 1.26086e-05 1.28614e-05 1.27154e-05 1.29933e-05 1.27958e-05 1.33073e-05 1.28306e-05 1.35379e-05 1.30633e-05 1.63012e-05 1.50319e-05 6.81262e-05 0.00219891 0.0354498 0.201286 0.530848 0.928532 1.33058 1.69599 1.96267 1.99075 1.24732 ) ; } upperWall { type fixedValue; value uniform 0; } lowerWall { type fixedValue; value uniform 0; } frontAndBack { type empty; } } // ************************************************************************* //
[ "houkensjtu@gmail.com" ]
houkensjtu@gmail.com
54d9f56914a9eb350eaa8e6f7cb6daee3ae16d87
26c2fd0b65d6dc3a8778477502f9bf74db9c7747
/MathWars/SettingState.h
fd3b3b725e035d1dc8907eaa3c129acff981de1d
[]
no_license
Ashlin-Gov/MathGame
668d8852804b62f3de6005c6b3d785bf59d87ee8
8a70c106122be7ee01293c4eebcb0f13b2cb4914
refs/heads/master
2022-11-25T14:09:21.472288
2020-08-09T22:51:47
2020-08-09T22:51:47
286,310,888
0
0
null
null
null
null
UTF-8
C++
false
false
395
h
#pragma once #include <SFML/Graphics.hpp> #include "State.h" #include "Game.h" namespace MathWars { class SettingState : public State { public: SettingState(GameDataRef data, PlayerDataRef player); void Init(); void HandleInput(); void Update(float dt); void Draw(float dt); private: GameDataRef _data; PlayerDataRef _players; sf::Sprite _background, _homeBtn; }; } //
[ "Ashlin.G@hotmail.com" ]
Ashlin.G@hotmail.com
a4e702daa35cdcf3f1a1014e23e93f485869fc07
23378c451e396684f712fc9f9e2a65a53a61a8a8
/DFS/351.Android-Unlock-Patterns/351.Android-Unlock-Patterns.cpp
78a9af0d7d13c70aa699aa0366f0325d74560f78
[]
no_license
wisdompeak/LeetCode
25676a8bf606c0511dd9844d4e61388235de82f4
f3d38bbe9e40ceb0ab9780a4cb0dec938eae578e
refs/heads/master
2023-09-01T18:45:36.056015
2023-08-28T08:01:22
2023-08-28T08:01:22
83,542,585
5,153
1,209
null
2023-07-22T18:15:25
2017-03-01T10:30:52
C++
UTF-8
C++
false
false
1,468
cpp
class Solution { int count = 0; int m,n; int visited[3][3]; vector<pair<int,int>>dir = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{-1,1},{1,-1},{-1,-1},{-1,2},{1,2},{-2,1},{2,1},{-1,-2},{1,-2},{-2,-1},{2,-1}}; public: int numberOfPatterns(int m, int n) { this->m = m; this->n = n; for (int i=0; i<3; i++) for (int j=0; j<3; j++) { visited[i][j] = 1; dfs(i,j,1); visited[i][j] = 0; } return count; } void dfs(int x, int y, int r) { if (r>=m && r<=n) count++; if (r>n) return; for (int k=0; k< dir.size(); k++) { int i = x+dir[k].first; int j = y+dir[k].second; if (i<0||i>=3||j<0||j>=3) continue; if (visited[i][j] == 0) { visited[i][j] = 1; dfs(i,j,r+1); visited[i][j] = 0; } else { i = i+dir[k].first; j = j+dir[k].second; if (i<0||i>=3||j<0||j>=3) continue; if (visited[i][j]==1) continue; visited[i][j] = 1; dfs(i,j,r+1); visited[i][j] = 0; } } } };
[ "noreply@github.com" ]
noreply@github.com
f0b0faa68aff937fab106393a49addd1effc98ae
fa9877968535297eea3ce8157444f73dcfb6be16
/C++/Volume005/AOJ-0513-20131122-カードシャッフルシミュレーション.cpp
463d3327203ee022996093be1c4929ed4e3d4736
[]
no_license
kyos1704/aoj
3681fe9c83ea13bb16f69ef3365819406a4becbb
e5358370668646ee263ba8570b59777f772feb1f
refs/heads/master
2021-01-22T01:05:42.612286
2015-02-17T10:13:42
2015-02-17T10:13:42
9,950,885
0
0
null
null
null
null
UTF-8
C++
false
false
935
cpp
#include<vector> #include<iostream> using namespace std; int n,m; bool input(){ if(!(cin>>n>>m)){ return false; } return true; } vector<int> ans; void init(){ ans.clear(); ans.resize(2*n); for(int i=0;i<ans.size();i++){ ans[i]=i+1; } } void kk(int k){ vector<int> t[2]; for(int i=0;i<k;i++){ t[1].push_back(ans[i]); } for(int i=k;i<2*n;i++){ t[0].push_back(ans[i]); } for(int i=0;i<t[1].size();i++){ t[0].push_back(t[1][i]); } ans=t[0]; } void r(){ vector<int> t[2]; for(int i=0;i<n;i++){ t[0].push_back(ans[i]); } for(int i=n;i<2*n;i++){ t[1].push_back(ans[i]); } for(int i=0;i<ans.size();i++){ ans[i]=t[i%2][i/2]; } } void s(int n){ if(n==0){ r(); }else{ kk(n); } } int main(){ input(); init(); for(int i=0;i<m;i++){ int tmp; cin>>tmp; s(tmp); } for(int i=0;i<ans.size();i++){ cout<<ans[i]<<endl; } return 0; }
[ "kyos.kyos1704@gmail.com" ]
kyos.kyos1704@gmail.com
962e52a13186976d9a613141245b25ff3c5f99ab
1d005e55f2c097bd2513f2f437496ded42b90dc4
/cf/gym101821F.cpp
193b581f79006662ccd4cd071a27a5bdb2301e98
[]
no_license
Undefined-User/code_lib
fe2657a8f0d190a8e052c2f72d65365c19eb4b21
3ac7d28ba2f675f131c701621c749f2aa32c9bfc
refs/heads/master
2020-03-29T01:43:51.359206
2018-09-16T09:00:01
2018-09-16T09:00:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,284
cpp
#include <bits/stdc++.h> using namespace std; namespace fft { typedef double db; struct cp { db x, y; cp() { x = y = 0; } cp(db x, db y) : x(x), y(y) {} }; inline cp operator+(cp a, cp b) { return cp(a.x + b.x, a.y + b.y); } inline cp operator-(cp a, cp b) { return cp(a.x - b.x, a.y - b.y); } inline cp operator*(cp a, cp b) { return cp(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } inline cp conj(cp a) { return cp(a.x, -a.y); } int base = 1; vector<cp> roots = {{0, 0}, {1, 0}}; vector<int> rev = {0, 1}; const db PI = acosl(-1.0); void ensure_base(int nbase) { if (nbase <= base) { return; } rev.resize(static_cast<unsigned long>(1 << nbase)); for (int i = 0; i < (1 << nbase); i++) { rev[i] = (rev[i >> 1] >> 1) + ((i & 1) << (nbase - 1)); } roots.resize(static_cast<unsigned long>(1 << nbase)); while (base < nbase) { db angle = 2 * PI / (1 << (base + 1)); for (int i = 1 << (base - 1); i < (1 << base); i++) { roots[i << 1] = roots[i]; db angle_i = angle * (2 * i + 1 - (1 << base)); roots[(i << 1) + 1] = cp(cos(angle_i), sin(angle_i)); } base++; } } void fft(vector<cp> &a, int n = -1) { if (n == -1) { n = a.size(); } assert((n & (n - 1)) == 0); int zeros = __builtin_ctz(n); ensure_base(zeros); int shift = base - zeros; for (int i = 0; i < n; i++) { if (i < (rev[i] >> shift)) { swap(a[i], a[rev[i] >> shift]); } } for (int k = 1; k < n; k <<= 1) { for (int i = 0; i < n; i += 2 * k) { for (int j = 0; j < k; j++) { cp z = a[i + j + k] * roots[j + k]; a[i + j + k] = a[i + j] - z; a[i + j] = a[i + j] + z; } } } } vector<cp> fa, fb; vector<int> multiply(vector<int> &a, vector<int> &b) { int need = a.size() + b.size() - 1; int nbase = 0; while ((1 << nbase) < need) nbase++; ensure_base(nbase); int sz = 1 << nbase; if (sz > (int) fa.size()) fa.resize(static_cast<unsigned long>(sz)); for (int i = 0; i < sz; i++) { int x = (i < (int) a.size() ? a[i] : 0); int y = (i < (int) b.size() ? b[i] : 0); fa[i] = cp(x, y); } fft(fa, sz); cp r(0, -0.25 / sz); for (int i = 0; i <= (sz >> 1); i++) { int j = (sz - i) & (sz - 1); cp z = (fa[j] * fa[j] - conj(fa[i] * fa[i])) * r; if (i != j) { fa[j] = (fa[i] * fa[i] - conj(fa[j] * fa[j])) * r; } fa[i] = z; } fft(fa, sz); vector<int> res(static_cast<unsigned long>(need)); for (int i = 0; i < need; i++) { res[i] = fa[i].x + 0.5; } return res; } vector<int> multiply_mod(vector<int> &a, vector<int> &b, int m, int eq = 0) { int need = a.size() + b.size() - 1; int nbase = 0; while ((1 << nbase) < need) nbase++; ensure_base(nbase); int sz = 1 << nbase; if (sz > (int) fa.size()) { fa.resize(static_cast<unsigned long>(sz)); } for (int i = 0; i < (int) a.size(); i++) { int x = (a[i] % m + m) % m; fa[i] = cp(x & ((1 << 15) - 1), x >> 15); } fill(fa.begin() + a.size(), fa.begin() + sz, cp {0, 0}); fft(fa, sz); if (sz > (int) fb.size()) { fb.resize(static_cast<unsigned long>(sz)); } if (eq) { copy(fa.begin(), fa.begin() + sz, fb.begin()); } else { for (int i = 0; i < (int) b.size(); i++) { int x = (b[i] % m + m) % m; fb[i] = cp(x & ((1 << 15) - 1), x >> 15); } fill(fb.begin() + b.size(), fb.begin() + sz, cp {0, 0}); fft(fb, sz); } db ratio = 0.25 / sz; cp r2(0, -1); cp r3(ratio, 0); cp r4(0, -ratio); cp r5(0, 1); for (int i = 0; i <= (sz >> 1); i++) { int j = (sz - i) & (sz - 1); cp a1 = (fa[i] + conj(fa[j])); cp a2 = (fa[i] - conj(fa[j])) * r2; cp b1 = (fb[i] + conj(fb[j])) * r3; cp b2 = (fb[i] - conj(fb[j])) * r4; if (i != j) { cp c1 = (fa[j] + conj(fa[i])); cp c2 = (fa[j] - conj(fa[i])) * r2; cp d1 = (fb[j] + conj(fb[i])) * r3; cp d2 = (fb[j] - conj(fb[i])) * r4; fa[i] = c1 * d1 + c2 * d2 * r5; fb[i] = c1 * d2 + c2 * d1; } fa[j] = a1 * b1 + a2 * b2 * r5; fb[j] = a1 * b2 + a2 * b1; } fft(fa, sz); fft(fb, sz); vector<int> res(static_cast<unsigned long>(need)); for (int i = 0; i < need; i++) { long long aa = fa[i].x + 0.5; long long bb = fb[i].x + 0.5; long long cc = fa[i].y + 0.5; res[i] = (aa + ((bb % m) << 15) + ((cc % m) << 30)) % m; } return res; } vector<int> square_mod(vector<int> &a, int m) { return multiply_mod(a, a, m, 1); } }; template <typename T> inline void read(T &x) { char ch; for(ch=getchar();!isdigit(ch);ch=getchar()); for(x=0;isdigit(ch);ch=getchar()) x=x*10+ch-48; } int main() { #ifdef Wavator freopen("test.in", "r", stdin); #endif int n; read(n); vector<int> a(2000001),b(2000001); for(int i=0;i<n;++i){ int x; read(x); a[x]=1; } for(int i=1;i<2000001;++i){ if(a[i]) b[2000000-i]=1; } auto res = fft::multiply(a,b); vector<bool> ck(2000001); for(int i=1;i<=2000000;++i) ck[i]=res[i+2000000]==0; for(int i=1;i<=2000000;++i){ bool f=true; for(int j=i;j<=2000000;j+=i) f&=(ck[j]); if(f) return !printf("%d\n", i); } puts("-1"); return 0; }
[ "noreply@github.com" ]
noreply@github.com
685f26c46862daa0e7666306f9835f89c7cdea3d
5f6770731ebb1f7d70cd0f1fa278c51f4357710b
/src/wasm/wasm-interpreter.cc
dda4c1bb7dab0d7e0eeeb13dd19effbb0b0c056d
[ "BSD-3-Clause", "SunPro", "bzip2-1.0.6" ]
permissive
artynet/v8-314
49520b93521234b5ff578d7888be89a4a0ff8c40
203391bcc0e970d3cae27ba99afd337c1c5f6d42
refs/heads/master
2021-01-14T14:23:44.213470
2016-06-30T10:25:16
2016-06-30T10:27:09
63,405,030
0
0
null
null
null
null
UTF-8
C++
false
false
62,497
cc
// Copyright 2016 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/wasm/wasm-interpreter.h" #include "src/wasm/ast-decoder.h" #include "src/wasm/decoder.h" #include "src/wasm/wasm-external-refs.h" #include "src/wasm/wasm-module.h" #include "src/base/accounting-allocator.h" #include "src/zone-containers.h" namespace v8 { namespace internal { namespace wasm { #if DEBUG #define TRACE(...) \ do { \ if (FLAG_trace_wasm_interpreter) PrintF(__VA_ARGS__); \ } while (false) #else #define TRACE(...) #endif #define FOREACH_INTERNAL_OPCODE(V) V(Breakpoint, 0xFF) #define FOREACH_SIMPLE_BINOP(V) \ V(I32Add, uint32_t, +) \ V(I32Sub, uint32_t, -) \ V(I32Mul, uint32_t, *) \ V(I32And, uint32_t, &) \ V(I32Ior, uint32_t, |) \ V(I32Xor, uint32_t, ^) \ V(I32Eq, uint32_t, ==) \ V(I32Ne, uint32_t, !=) \ V(I32LtU, uint32_t, <) \ V(I32LeU, uint32_t, <=) \ V(I32GtU, uint32_t, >) \ V(I32GeU, uint32_t, >=) \ V(I32LtS, int32_t, <) \ V(I32LeS, int32_t, <=) \ V(I32GtS, int32_t, >) \ V(I32GeS, int32_t, >=) \ V(I64Add, uint64_t, +) \ V(I64Sub, uint64_t, -) \ V(I64Mul, uint64_t, *) \ V(I64And, uint64_t, &) \ V(I64Ior, uint64_t, |) \ V(I64Xor, uint64_t, ^) \ V(I64Eq, uint64_t, ==) \ V(I64Ne, uint64_t, !=) \ V(I64LtU, uint64_t, <) \ V(I64LeU, uint64_t, <=) \ V(I64GtU, uint64_t, >) \ V(I64GeU, uint64_t, >=) \ V(I64LtS, int64_t, <) \ V(I64LeS, int64_t, <=) \ V(I64GtS, int64_t, >) \ V(I64GeS, int64_t, >=) \ V(F32Add, float, +) \ V(F32Mul, float, *) \ V(F32Div, float, /) \ V(F32Eq, float, ==) \ V(F32Ne, float, !=) \ V(F32Lt, float, <) \ V(F32Le, float, <=) \ V(F32Gt, float, >) \ V(F32Ge, float, >=) \ V(F64Add, double, +) \ V(F64Mul, double, *) \ V(F64Div, double, /) \ V(F64Eq, double, ==) \ V(F64Ne, double, !=) \ V(F64Lt, double, <) \ V(F64Le, double, <=) \ V(F64Gt, double, >) \ V(F64Ge, double, >=) #define FOREACH_OTHER_BINOP(V) \ V(I32DivS, int32_t) \ V(I32DivU, uint32_t) \ V(I32RemS, int32_t) \ V(I32RemU, uint32_t) \ V(I32Shl, uint32_t) \ V(I32ShrU, uint32_t) \ V(I32ShrS, int32_t) \ V(I64DivS, int64_t) \ V(I64DivU, uint64_t) \ V(I64RemS, int64_t) \ V(I64RemU, uint64_t) \ V(I64Shl, uint64_t) \ V(I64ShrU, uint64_t) \ V(I64ShrS, int64_t) \ V(I32Ror, int32_t) \ V(I32Rol, int32_t) \ V(I64Ror, int64_t) \ V(I64Rol, int64_t) \ V(F32Sub, float) \ V(F32Min, float) \ V(F32Max, float) \ V(F32CopySign, float) \ V(F64Min, double) \ V(F64Max, double) \ V(F64Sub, double) \ V(F64CopySign, double) \ V(I32AsmjsDivS, int32_t) \ V(I32AsmjsDivU, uint32_t) \ V(I32AsmjsRemS, int32_t) \ V(I32AsmjsRemU, uint32_t) #define FOREACH_OTHER_UNOP(V) \ V(I32Clz, uint32_t) \ V(I32Ctz, uint32_t) \ V(I32Popcnt, uint32_t) \ V(I32Eqz, uint32_t) \ V(I64Clz, uint64_t) \ V(I64Ctz, uint64_t) \ V(I64Popcnt, uint64_t) \ V(I64Eqz, uint64_t) \ V(F32Abs, float) \ V(F32Neg, float) \ V(F32Ceil, float) \ V(F32Floor, float) \ V(F32Trunc, float) \ V(F32NearestInt, float) \ V(F32Sqrt, float) \ V(F64Abs, double) \ V(F64Neg, double) \ V(F64Ceil, double) \ V(F64Floor, double) \ V(F64Trunc, double) \ V(F64NearestInt, double) \ V(F64Sqrt, double) \ V(I32SConvertF32, float) \ V(I32SConvertF64, double) \ V(I32UConvertF32, float) \ V(I32UConvertF64, double) \ V(I32ConvertI64, int64_t) \ V(I64SConvertF32, float) \ V(I64SConvertF64, double) \ V(I64UConvertF32, float) \ V(I64UConvertF64, double) \ V(I64SConvertI32, int32_t) \ V(I64UConvertI32, uint32_t) \ V(F32SConvertI32, int32_t) \ V(F32UConvertI32, uint32_t) \ V(F32SConvertI64, int64_t) \ V(F32UConvertI64, uint64_t) \ V(F32ConvertF64, double) \ V(F32ReinterpretI32, int32_t) \ V(F64SConvertI32, int32_t) \ V(F64UConvertI32, uint32_t) \ V(F64SConvertI64, int64_t) \ V(F64UConvertI64, uint64_t) \ V(F64ConvertF32, float) \ V(F64ReinterpretI64, int64_t) \ V(I32ReinterpretF32, float) \ V(I64ReinterpretF64, double) \ V(I32AsmjsSConvertF32, float) \ V(I32AsmjsUConvertF32, float) \ V(I32AsmjsSConvertF64, double) \ V(I32AsmjsUConvertF64, double) static inline int32_t ExecuteI32DivS(int32_t a, int32_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapDivByZero; return 0; } if (b == -1 && a == std::numeric_limits<int32_t>::min()) { *trap = kTrapDivUnrepresentable; return 0; } return a / b; } static inline uint32_t ExecuteI32DivU(uint32_t a, uint32_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapDivByZero; return 0; } return a / b; } static inline int32_t ExecuteI32RemS(int32_t a, int32_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapRemByZero; return 0; } if (b == -1) return 0; return a % b; } static inline uint32_t ExecuteI32RemU(uint32_t a, uint32_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapRemByZero; return 0; } return a % b; } static inline uint32_t ExecuteI32Shl(uint32_t a, uint32_t b, TrapReason* trap) { return a << (b & 0x1f); } static inline uint32_t ExecuteI32ShrU(uint32_t a, uint32_t b, TrapReason* trap) { return a >> (b & 0x1f); } static inline int32_t ExecuteI32ShrS(int32_t a, int32_t b, TrapReason* trap) { return a >> (b & 0x1f); } static inline int64_t ExecuteI64DivS(int64_t a, int64_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapDivByZero; return 0; } if (b == -1 && a == std::numeric_limits<int64_t>::min()) { *trap = kTrapDivUnrepresentable; return 0; } return a / b; } static inline uint64_t ExecuteI64DivU(uint64_t a, uint64_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapDivByZero; return 0; } return a / b; } static inline int64_t ExecuteI64RemS(int64_t a, int64_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapRemByZero; return 0; } if (b == -1) return 0; return a % b; } static inline uint64_t ExecuteI64RemU(uint64_t a, uint64_t b, TrapReason* trap) { if (b == 0) { *trap = kTrapRemByZero; return 0; } return a % b; } static inline uint64_t ExecuteI64Shl(uint64_t a, uint64_t b, TrapReason* trap) { return a << (b & 0x3f); } static inline uint64_t ExecuteI64ShrU(uint64_t a, uint64_t b, TrapReason* trap) { return a >> (b & 0x3f); } static inline int64_t ExecuteI64ShrS(int64_t a, int64_t b, TrapReason* trap) { return a >> (b & 0x3f); } static inline uint32_t ExecuteI32Ror(uint32_t a, uint32_t b, TrapReason* trap) { uint32_t shift = (b & 0x1f); return (a >> shift) | (a << (32 - shift)); } static inline uint32_t ExecuteI32Rol(uint32_t a, uint32_t b, TrapReason* trap) { uint32_t shift = (b & 0x1f); return (a << shift) | (a >> (32 - shift)); } static inline uint64_t ExecuteI64Ror(uint64_t a, uint64_t b, TrapReason* trap) { uint32_t shift = (b & 0x3f); return (a >> shift) | (a << (64 - shift)); } static inline uint64_t ExecuteI64Rol(uint64_t a, uint64_t b, TrapReason* trap) { uint32_t shift = (b & 0x3f); return (a << shift) | (a >> (64 - shift)); } static float quiet(float a) { static const uint32_t kSignalingBit = 1 << 22; uint32_t q = bit_cast<uint32_t>(std::numeric_limits<float>::quiet_NaN()); if ((q & kSignalingBit) != 0) { // On some machines, the signaling bit set indicates it's a quiet NaN. return bit_cast<float>(bit_cast<uint32_t>(a) | kSignalingBit); } else { // On others, the signaling bit set indicates it's a signaling NaN. return bit_cast<float>(bit_cast<uint32_t>(a) & ~kSignalingBit); } } static double quiet(double a) { static const uint64_t kSignalingBit = 1ULL << 51; uint64_t q = bit_cast<uint64_t>(std::numeric_limits<double>::quiet_NaN()); if ((q & kSignalingBit) != 0) { // On some machines, the signaling bit set indicates it's a quiet NaN. return bit_cast<double>(bit_cast<uint64_t>(a) | kSignalingBit); } else { // On others, the signaling bit set indicates it's a signaling NaN. return bit_cast<double>(bit_cast<uint64_t>(a) & ~kSignalingBit); } } static inline float ExecuteF32Sub(float a, float b, TrapReason* trap) { float result = a - b; // Some architectures (e.g. MIPS) need extra checking to preserve the payload // of a NaN operand. if (result - result != 0) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); } return result; } static inline float ExecuteF32Min(float a, float b, TrapReason* trap) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); return std::min(a, b); } static inline float ExecuteF32Max(float a, float b, TrapReason* trap) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); return std::max(a, b); } static inline float ExecuteF32CopySign(float a, float b, TrapReason* trap) { return copysignf(a, b); } static inline double ExecuteF64Sub(double a, double b, TrapReason* trap) { double result = a - b; // Some architectures (e.g. MIPS) need extra checking to preserve the payload // of a NaN operand. if (result - result != 0) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); } return result; } static inline double ExecuteF64Min(double a, double b, TrapReason* trap) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); return std::min(a, b); } static inline double ExecuteF64Max(double a, double b, TrapReason* trap) { if (std::isnan(a)) return quiet(a); if (std::isnan(b)) return quiet(b); return std::max(a, b); } static inline double ExecuteF64CopySign(double a, double b, TrapReason* trap) { return copysign(a, b); } static inline int32_t ExecuteI32AsmjsDivS(int32_t a, int32_t b, TrapReason* trap) { if (b == 0) return 0; if (b == -1 && a == std::numeric_limits<int32_t>::min()) { return std::numeric_limits<int32_t>::min(); } return a / b; } static inline uint32_t ExecuteI32AsmjsDivU(uint32_t a, uint32_t b, TrapReason* trap) { if (b == 0) return 0; return a / b; } static inline int32_t ExecuteI32AsmjsRemS(int32_t a, int32_t b, TrapReason* trap) { if (b == 0) return 0; if (b == -1) return 0; return a % b; } static inline uint32_t ExecuteI32AsmjsRemU(uint32_t a, uint32_t b, TrapReason* trap) { if (b == 0) return 0; return a % b; } static inline int32_t ExecuteI32AsmjsSConvertF32(float a, TrapReason* trap) { return DoubleToInt32(a); } static inline uint32_t ExecuteI32AsmjsUConvertF32(float a, TrapReason* trap) { return DoubleToUint32(a); } static inline int32_t ExecuteI32AsmjsSConvertF64(double a, TrapReason* trap) { return DoubleToInt32(a); } static inline uint32_t ExecuteI32AsmjsUConvertF64(double a, TrapReason* trap) { return DoubleToUint32(a); } static int32_t ExecuteI32Clz(uint32_t val, TrapReason* trap) { return base::bits::CountLeadingZeros32(val); } static uint32_t ExecuteI32Ctz(uint32_t val, TrapReason* trap) { return base::bits::CountTrailingZeros32(val); } static uint32_t ExecuteI32Popcnt(uint32_t val, TrapReason* trap) { return word32_popcnt_wrapper(&val); } static inline uint32_t ExecuteI32Eqz(uint32_t val, TrapReason* trap) { return val == 0 ? 1 : 0; } static int64_t ExecuteI64Clz(uint64_t val, TrapReason* trap) { return base::bits::CountLeadingZeros64(val); } static inline uint64_t ExecuteI64Ctz(uint64_t val, TrapReason* trap) { return base::bits::CountTrailingZeros64(val); } static inline int64_t ExecuteI64Popcnt(uint64_t val, TrapReason* trap) { return word64_popcnt_wrapper(&val); } static inline int32_t ExecuteI64Eqz(uint64_t val, TrapReason* trap) { return val == 0 ? 1 : 0; } static inline float ExecuteF32Abs(float a, TrapReason* trap) { return bit_cast<float>(bit_cast<uint32_t>(a) & 0x7fffffff); } static inline float ExecuteF32Neg(float a, TrapReason* trap) { return bit_cast<float>(bit_cast<uint32_t>(a) ^ 0x80000000); } static inline float ExecuteF32Ceil(float a, TrapReason* trap) { return ceilf(a); } static inline float ExecuteF32Floor(float a, TrapReason* trap) { return floorf(a); } static inline float ExecuteF32Trunc(float a, TrapReason* trap) { return truncf(a); } static inline float ExecuteF32NearestInt(float a, TrapReason* trap) { return nearbyintf(a); } static inline float ExecuteF32Sqrt(float a, TrapReason* trap) { return sqrtf(a); } static inline double ExecuteF64Abs(double a, TrapReason* trap) { return bit_cast<double>(bit_cast<uint64_t>(a) & 0x7fffffffffffffff); } static inline double ExecuteF64Neg(double a, TrapReason* trap) { return bit_cast<double>(bit_cast<uint64_t>(a) ^ 0x8000000000000000); } static inline double ExecuteF64Ceil(double a, TrapReason* trap) { return ceil(a); } static inline double ExecuteF64Floor(double a, TrapReason* trap) { return floor(a); } static inline double ExecuteF64Trunc(double a, TrapReason* trap) { return trunc(a); } static inline double ExecuteF64NearestInt(double a, TrapReason* trap) { return nearbyint(a); } static inline double ExecuteF64Sqrt(double a, TrapReason* trap) { return sqrt(a); } static int32_t ExecuteI32SConvertF32(float a, TrapReason* trap) { if (a < static_cast<float>(INT32_MAX) && a >= static_cast<float>(INT32_MIN)) { return static_cast<int32_t>(a); } *trap = kTrapFloatUnrepresentable; return 0; } static int32_t ExecuteI32SConvertF64(double a, TrapReason* trap) { if (a < (static_cast<double>(INT32_MAX) + 1.0) && a > (static_cast<double>(INT32_MIN) - 1.0)) { return static_cast<int32_t>(a); } *trap = kTrapFloatUnrepresentable; return 0; } static uint32_t ExecuteI32UConvertF32(float a, TrapReason* trap) { if (a < (static_cast<float>(UINT32_MAX) + 1.0) && a > -1) { return static_cast<uint32_t>(a); } *trap = kTrapFloatUnrepresentable; return 0; } static uint32_t ExecuteI32UConvertF64(double a, TrapReason* trap) { if (a < (static_cast<float>(UINT32_MAX) + 1.0) && a > -1) { return static_cast<uint32_t>(a); } *trap = kTrapFloatUnrepresentable; return 0; } static inline uint32_t ExecuteI32ConvertI64(int64_t a, TrapReason* trap) { return static_cast<uint32_t>(a & 0xFFFFFFFF); } static int64_t ExecuteI64SConvertF32(float a, TrapReason* trap) { int64_t output; if (!float32_to_int64_wrapper(&a, &output)) { *trap = kTrapFloatUnrepresentable; } return output; } static int64_t ExecuteI64SConvertF64(double a, TrapReason* trap) { int64_t output; if (!float64_to_int64_wrapper(&a, &output)) { *trap = kTrapFloatUnrepresentable; } return output; } static uint64_t ExecuteI64UConvertF32(float a, TrapReason* trap) { uint64_t output; if (!float32_to_uint64_wrapper(&a, &output)) { *trap = kTrapFloatUnrepresentable; } return output; } static uint64_t ExecuteI64UConvertF64(double a, TrapReason* trap) { uint64_t output; if (!float64_to_uint64_wrapper(&a, &output)) { *trap = kTrapFloatUnrepresentable; } return output; } static inline int64_t ExecuteI64SConvertI32(int32_t a, TrapReason* trap) { return static_cast<int64_t>(a); } static inline int64_t ExecuteI64UConvertI32(uint32_t a, TrapReason* trap) { return static_cast<uint64_t>(a); } static inline float ExecuteF32SConvertI32(int32_t a, TrapReason* trap) { return static_cast<float>(a); } static inline float ExecuteF32UConvertI32(uint32_t a, TrapReason* trap) { return static_cast<float>(a); } static inline float ExecuteF32SConvertI64(int64_t a, TrapReason* trap) { float output; int64_to_float32_wrapper(&a, &output); return output; } static inline float ExecuteF32UConvertI64(uint64_t a, TrapReason* trap) { float output; uint64_to_float32_wrapper(&a, &output); return output; } static inline float ExecuteF32ConvertF64(double a, TrapReason* trap) { return static_cast<float>(a); } static inline float ExecuteF32ReinterpretI32(int32_t a, TrapReason* trap) { return bit_cast<float>(a); } static inline double ExecuteF64SConvertI32(int32_t a, TrapReason* trap) { return static_cast<double>(a); } static inline double ExecuteF64UConvertI32(uint32_t a, TrapReason* trap) { return static_cast<double>(a); } static inline double ExecuteF64SConvertI64(int64_t a, TrapReason* trap) { double output; int64_to_float64_wrapper(&a, &output); return output; } static inline double ExecuteF64UConvertI64(uint64_t a, TrapReason* trap) { double output; uint64_to_float64_wrapper(&a, &output); return output; } static inline double ExecuteF64ConvertF32(float a, TrapReason* trap) { return static_cast<double>(a); } static inline double ExecuteF64ReinterpretI64(int64_t a, TrapReason* trap) { return bit_cast<double>(a); } static inline int32_t ExecuteI32ReinterpretF32(float a, TrapReason* trap) { return bit_cast<int32_t>(a); } static inline int64_t ExecuteI64ReinterpretF64(double a, TrapReason* trap) { return bit_cast<int64_t>(a); } enum InternalOpcode { #define DECL_INTERNAL_ENUM(name, value) kInternal##name = value, FOREACH_INTERNAL_OPCODE(DECL_INTERNAL_ENUM) #undef DECL_INTERNAL_ENUM }; static const char* OpcodeName(uint32_t val) { switch (val) { #define DECL_INTERNAL_CASE(name, value) \ case kInternal##name: \ return "Internal" #name; FOREACH_INTERNAL_OPCODE(DECL_INTERNAL_CASE) #undef DECL_INTERNAL_CASE } return WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(val)); } static const int kRunSteps = 1000; // A helper class to compute the control transfers for each bytecode offset. // Control transfers allow Br, BrIf, BrTable, If, Else, and End bytecodes to // be directly executed without the need to dynamically track blocks. class ControlTransfers : public ZoneObject { public: ControlTransferMap map_; ControlTransfers(Zone* zone, size_t locals_encoded_size, const byte* start, const byte* end) : map_(zone) { // A control reference including from PC, from value depth, and whether // a value is explicitly passed (e.g. br/br_if/br_table with value). struct CRef { const byte* pc; sp_t value_depth; bool explicit_value; }; // Represents a control flow label. struct CLabel : public ZoneObject { const byte* target; size_t value_depth; ZoneVector<CRef> refs; CLabel(Zone* zone, size_t v) : target(nullptr), value_depth(v), refs(zone) {} // Bind this label to the given PC. void Bind(ControlTransferMap* map, const byte* start, const byte* pc, bool expect_value) { DCHECK_NULL(target); target = pc; for (auto from : refs) { auto pcdiff = static_cast<pcdiff_t>(target - from.pc); auto spdiff = static_cast<spdiff_t>(from.value_depth - value_depth); ControlTransfer::StackAction action = ControlTransfer::kNoAction; if (expect_value && !from.explicit_value) { action = spdiff == 0 ? ControlTransfer::kPushVoid : ControlTransfer::kPopAndRepush; } pc_t offset = static_cast<size_t>(from.pc - start); (*map)[offset] = {pcdiff, spdiff, action}; } } // Reference this label from the given location. void Ref(ControlTransferMap* map, const byte* start, CRef from) { DCHECK_GE(from.value_depth, value_depth); if (target) { auto pcdiff = static_cast<pcdiff_t>(target - from.pc); auto spdiff = static_cast<spdiff_t>(from.value_depth - value_depth); pc_t offset = static_cast<size_t>(from.pc - start); (*map)[offset] = {pcdiff, spdiff, ControlTransfer::kNoAction}; } else { refs.push_back(from); } } }; // An entry in the control stack. struct Control { const byte* pc; CLabel* end_label; CLabel* else_label; void Ref(ControlTransferMap* map, const byte* start, const byte* from_pc, size_t from_value_depth, bool explicit_value) { end_label->Ref(map, start, {from_pc, from_value_depth, explicit_value}); } }; // Compute the ControlTransfer map. // This works by maintaining a stack of control constructs similar to the // AST decoder. The {control_stack} allows matching {br,br_if,br_table} // bytecodes with their target, as well as determining whether the current // bytecodes are within the true or false block of an else. // The value stack depth is tracked as {value_depth} and is needed to // determine how many values to pop off the stack for explicit and // implicit control flow. std::vector<Control> control_stack; size_t value_depth = 0; Decoder decoder(start, end); // for reading operands. const byte* pc = start + locals_encoded_size; while (pc < end) { WasmOpcode opcode = static_cast<WasmOpcode>(*pc); TRACE("@%td: control %s (depth = %zu)\n", (pc - start), WasmOpcodes::OpcodeName(opcode), value_depth); switch (opcode) { case kExprBlock: { TRACE("control @%td $%zu: Block\n", (pc - start), value_depth); CLabel* label = new (zone) CLabel(zone, value_depth); control_stack.push_back({pc, label, nullptr}); break; } case kExprLoop: { TRACE("control @%td $%zu: Loop\n", (pc - start), value_depth); CLabel* label1 = new (zone) CLabel(zone, value_depth); CLabel* label2 = new (zone) CLabel(zone, value_depth); control_stack.push_back({pc, label1, nullptr}); control_stack.push_back({pc, label2, nullptr}); label2->Bind(&map_, start, pc, false); break; } case kExprIf: { TRACE("control @%td $%zu: If\n", (pc - start), value_depth); value_depth--; CLabel* end_label = new (zone) CLabel(zone, value_depth); CLabel* else_label = new (zone) CLabel(zone, value_depth); control_stack.push_back({pc, end_label, else_label}); else_label->Ref(&map_, start, {pc, value_depth, false}); break; } case kExprElse: { Control* c = &control_stack.back(); TRACE("control @%td $%zu: Else\n", (pc - start), value_depth); c->end_label->Ref(&map_, start, {pc, value_depth, false}); value_depth = c->end_label->value_depth; DCHECK_NOT_NULL(c->else_label); c->else_label->Bind(&map_, start, pc + 1, false); c->else_label = nullptr; break; } case kExprEnd: { Control* c = &control_stack.back(); TRACE("control @%td $%zu: End\n", (pc - start), value_depth); if (c->end_label->target) { // only loops have bound labels. DCHECK_EQ(kExprLoop, *c->pc); control_stack.pop_back(); c = &control_stack.back(); } if (c->else_label) c->else_label->Bind(&map_, start, pc + 1, true); c->end_label->Ref(&map_, start, {pc, value_depth, false}); c->end_label->Bind(&map_, start, pc + 1, true); value_depth = c->end_label->value_depth + 1; control_stack.pop_back(); break; } case kExprBr: { BreakDepthOperand operand(&decoder, pc); TRACE("control @%td $%zu: Br[arity=%u, depth=%u]\n", (pc - start), value_depth, operand.arity, operand.depth); value_depth -= operand.arity; control_stack[control_stack.size() - operand.depth - 1].Ref( &map_, start, pc, value_depth, operand.arity > 0); value_depth++; break; } case kExprBrIf: { BreakDepthOperand operand(&decoder, pc); TRACE("control @%td $%zu: BrIf[arity=%u, depth=%u]\n", (pc - start), value_depth, operand.arity, operand.depth); value_depth -= (operand.arity + 1); control_stack[control_stack.size() - operand.depth - 1].Ref( &map_, start, pc, value_depth, operand.arity > 0); value_depth++; break; } case kExprBrTable: { BranchTableOperand operand(&decoder, pc); TRACE("control @%td $%zu: BrTable[arity=%u count=%u]\n", (pc - start), value_depth, operand.arity, operand.table_count); value_depth -= (operand.arity + 1); for (uint32_t i = 0; i < operand.table_count + 1; ++i) { uint32_t target = operand.read_entry(&decoder, i); control_stack[control_stack.size() - target - 1].Ref( &map_, start, pc + i, value_depth, operand.arity > 0); } value_depth++; break; } default: { value_depth = value_depth - OpcodeArity(pc, end) + 1; break; } } pc += OpcodeLength(pc, end); } } ControlTransfer Lookup(pc_t from) { auto result = map_.find(from); if (result == map_.end()) { V8_Fatal(__FILE__, __LINE__, "no control target for pc %zu", from); } return result->second; } }; // Code and metadata needed to execute a function. struct InterpreterCode { const WasmFunction* function; // wasm function AstLocalDecls locals; // local declarations const byte* orig_start; // start of original code const byte* orig_end; // end of original code byte* start; // start of (maybe altered) code byte* end; // end of (maybe altered) code ControlTransfers* targets; // helper for control flow. const byte* at(pc_t pc) { return start + pc; } }; // The main storage for interpreter code. It maps {WasmFunction} to the // metadata needed to execute each function. class CodeMap { public: Zone* zone_; const WasmModule* module_; ZoneVector<InterpreterCode> interpreter_code_; CodeMap(const WasmModule* module, Zone* zone) : zone_(zone), module_(module), interpreter_code_(zone) { if (module == nullptr) return; for (size_t i = 0; i < module->functions.size(); ++i) { const WasmFunction* function = &module->functions[i]; const byte* code_start = module->module_start + function->code_start_offset; const byte* code_end = module->module_start + function->code_end_offset; AddFunction(function, code_start, code_end); } } InterpreterCode* FindCode(const WasmFunction* function) { if (function->func_index < interpreter_code_.size()) { InterpreterCode* code = &interpreter_code_[function->func_index]; DCHECK_EQ(function, code->function); return code; } return nullptr; } InterpreterCode* GetCode(uint32_t function_index) { CHECK_LT(function_index, interpreter_code_.size()); return Preprocess(&interpreter_code_[function_index]); } InterpreterCode* GetIndirectCode(uint32_t indirect_index) { if (indirect_index >= module_->function_table.size()) return nullptr; uint32_t index = module_->function_table[indirect_index]; if (index >= interpreter_code_.size()) return nullptr; return GetCode(index); } InterpreterCode* Preprocess(InterpreterCode* code) { if (code->targets == nullptr && code->start) { // Compute the control targets map and the local declarations. CHECK(DecodeLocalDecls(code->locals, code->start, code->end)); code->targets = new (zone_) ControlTransfers(zone_, code->locals.decls_encoded_size, code->orig_start, code->orig_end); } return code; } int AddFunction(const WasmFunction* function, const byte* code_start, const byte* code_end) { InterpreterCode code = { function, AstLocalDecls(zone_), code_start, code_end, const_cast<byte*>(code_start), const_cast<byte*>(code_end), nullptr}; DCHECK_EQ(interpreter_code_.size(), function->func_index); interpreter_code_.push_back(code); return static_cast<int>(interpreter_code_.size()) - 1; } bool SetFunctionCode(const WasmFunction* function, const byte* start, const byte* end) { InterpreterCode* code = FindCode(function); if (code == nullptr) return false; code->targets = nullptr; code->orig_start = start; code->orig_end = end; code->start = const_cast<byte*>(start); code->end = const_cast<byte*>(end); Preprocess(code); return true; } }; // Responsible for executing code directly. class ThreadImpl : public WasmInterpreter::Thread { public: ThreadImpl(Zone* zone, CodeMap* codemap, WasmModuleInstance* instance) : codemap_(codemap), instance_(instance), stack_(zone), frames_(zone), state_(WasmInterpreter::STOPPED), break_pc_(kInvalidPc), trap_reason_(kTrapCount) {} virtual ~ThreadImpl() {} //========================================================================== // Implementation of public interface for WasmInterpreter::Thread. //========================================================================== virtual WasmInterpreter::State state() { return state_; } virtual void PushFrame(const WasmFunction* function, WasmVal* args) { InterpreterCode* code = codemap()->FindCode(function); CHECK_NOT_NULL(code); frames_.push_back({code, 0, 0, stack_.size()}); for (size_t i = 0; i < function->sig->parameter_count(); ++i) { stack_.push_back(args[i]); } frames_.back().ret_pc = InitLocals(code); TRACE(" => PushFrame(#%u @%zu)\n", code->function->func_index, frames_.back().ret_pc); } virtual WasmInterpreter::State Run() { do { TRACE(" => Run()\n"); if (state_ == WasmInterpreter::STOPPED || state_ == WasmInterpreter::PAUSED) { state_ = WasmInterpreter::RUNNING; Execute(frames_.back().code, frames_.back().ret_pc, kRunSteps); } } while (state_ == WasmInterpreter::STOPPED); return state_; } virtual WasmInterpreter::State Step() { TRACE(" => Step()\n"); if (state_ == WasmInterpreter::STOPPED || state_ == WasmInterpreter::PAUSED) { state_ = WasmInterpreter::RUNNING; Execute(frames_.back().code, frames_.back().ret_pc, 1); } return state_; } virtual void Pause() { UNIMPLEMENTED(); } virtual void Reset() { TRACE("----- RESET -----\n"); stack_.clear(); frames_.clear(); state_ = WasmInterpreter::STOPPED; trap_reason_ = kTrapCount; } virtual int GetFrameCount() { return static_cast<int>(frames_.size()); } virtual const WasmFrame* GetFrame(int index) { UNIMPLEMENTED(); return nullptr; } virtual WasmFrame* GetMutableFrame(int index) { UNIMPLEMENTED(); return nullptr; } virtual WasmVal GetReturnValue() { if (state_ == WasmInterpreter::TRAPPED) return WasmVal(0xdeadbeef); CHECK_EQ(WasmInterpreter::FINISHED, state_); CHECK_EQ(1, stack_.size()); return stack_[0]; } virtual pc_t GetBreakpointPc() { return break_pc_; } bool Terminated() { return state_ == WasmInterpreter::TRAPPED || state_ == WasmInterpreter::FINISHED; } private: // Entries on the stack of functions being evaluated. struct Frame { InterpreterCode* code; pc_t call_pc; pc_t ret_pc; sp_t sp; // Limit of parameters. sp_t plimit() { return sp + code->function->sig->parameter_count(); } // Limit of locals. sp_t llimit() { return plimit() + code->locals.total_local_count; } }; CodeMap* codemap_; WasmModuleInstance* instance_; ZoneVector<WasmVal> stack_; ZoneVector<Frame> frames_; WasmInterpreter::State state_; pc_t break_pc_; TrapReason trap_reason_; CodeMap* codemap() { return codemap_; } WasmModuleInstance* instance() { return instance_; } const WasmModule* module() { return instance_->module; } void DoTrap(TrapReason trap, pc_t pc) { state_ = WasmInterpreter::TRAPPED; trap_reason_ = trap; CommitPc(pc); } // Push a frame with arguments already on the stack. void PushFrame(InterpreterCode* code, pc_t call_pc, pc_t ret_pc) { CHECK_NOT_NULL(code); DCHECK(!frames_.empty()); frames_.back().call_pc = call_pc; frames_.back().ret_pc = ret_pc; size_t arity = code->function->sig->parameter_count(); DCHECK_GE(stack_.size(), arity); // The parameters will overlap the arguments already on the stack. frames_.push_back({code, 0, 0, stack_.size() - arity}); frames_.back().ret_pc = InitLocals(code); TRACE(" => push func#%u @%zu\n", code->function->func_index, frames_.back().ret_pc); } pc_t InitLocals(InterpreterCode* code) { for (auto p : code->locals.local_types) { WasmVal val; switch (p.first) { case kAstI32: val = WasmVal(static_cast<int32_t>(0)); break; case kAstI64: val = WasmVal(static_cast<int64_t>(0)); break; case kAstF32: val = WasmVal(static_cast<float>(0)); break; case kAstF64: val = WasmVal(static_cast<double>(0)); break; default: UNREACHABLE(); break; } stack_.insert(stack_.end(), p.second, val); } return code->locals.decls_encoded_size; } void CommitPc(pc_t pc) { if (!frames_.empty()) { frames_.back().ret_pc = pc; } } bool SkipBreakpoint(InterpreterCode* code, pc_t pc) { if (pc == break_pc_) { break_pc_ = kInvalidPc; return true; } return false; } bool DoReturn(InterpreterCode** code, pc_t* pc, pc_t* limit, WasmVal val) { DCHECK_GT(frames_.size(), 0u); stack_.resize(frames_.back().sp); frames_.pop_back(); if (frames_.size() == 0) { // A return from the top frame terminates the execution. state_ = WasmInterpreter::FINISHED; stack_.clear(); stack_.push_back(val); TRACE(" => finish\n"); return false; } else { // Return to caller frame. Frame* top = &frames_.back(); *code = top->code; *pc = top->ret_pc; *limit = top->code->end - top->code->start; if (top->code->start[top->call_pc] == kExprCallIndirect || (top->code->orig_start && top->code->orig_start[top->call_pc] == kExprCallIndirect)) { // UGLY: An indirect call has the additional function index on the // stack. stack_.pop_back(); } TRACE(" => pop func#%u @%zu\n", (*code)->function->func_index, *pc); stack_.push_back(val); return true; } } void DoCall(InterpreterCode* target, pc_t* pc, pc_t ret_pc, pc_t* limit) { PushFrame(target, *pc, ret_pc); *pc = frames_.back().ret_pc; *limit = target->end - target->start; } // Adjust the program counter {pc} and the stack contents according to the // code's precomputed control transfer map. Returns the different between // the new pc and the old pc. int DoControlTransfer(InterpreterCode* code, pc_t pc) { auto target = code->targets->Lookup(pc); switch (target.action) { case ControlTransfer::kNoAction: TRACE(" action [sp-%u]\n", target.spdiff); PopN(target.spdiff); break; case ControlTransfer::kPopAndRepush: { WasmVal val = Pop(); TRACE(" action [pop x, sp-%u, push x]\n", target.spdiff - 1); DCHECK_GE(target.spdiff, 1u); PopN(target.spdiff - 1); Push(pc, val); break; } case ControlTransfer::kPushVoid: TRACE(" action [sp-%u, push void]\n", target.spdiff); PopN(target.spdiff); Push(pc, WasmVal()); break; } return target.pcdiff; } void Execute(InterpreterCode* code, pc_t pc, int max) { Decoder decoder(code->start, code->end); pc_t limit = code->end - code->start; while (true) { if (max-- <= 0) { // Maximum number of instructions reached. state_ = WasmInterpreter::PAUSED; return CommitPc(pc); } if (pc >= limit) { // Fell off end of code; do an implicit return. TRACE("@%-3zu: ImplicitReturn\n", pc); WasmVal val = PopArity(code->function->sig->return_count()); if (!DoReturn(&code, &pc, &limit, val)) return; decoder.Reset(code->start, code->end); continue; } const char* skip = " "; int len = 1; byte opcode = code->start[pc]; byte orig = opcode; if (opcode == kInternalBreakpoint) { orig = code->orig_start[pc]; if (SkipBreakpoint(code, pc)) { // skip breakpoint by switching on original code. skip = "[skip] "; } else { state_ = WasmInterpreter::PAUSED; TRACE("@%-3zu: [break] %-24s:", pc, WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(orig))); TraceValueStack(); TRACE("\n"); break_pc_ = pc; return CommitPc(pc); } } USE(skip); TRACE("@%-3zu: %s%-24s:", pc, skip, WasmOpcodes::OpcodeName(static_cast<WasmOpcode>(orig))); TraceValueStack(); TRACE("\n"); switch (orig) { case kExprNop: Push(pc, WasmVal()); break; case kExprBlock: case kExprLoop: { // Do nothing. break; } case kExprIf: { WasmVal cond = Pop(); bool is_true = cond.to<uint32_t>() != 0; if (is_true) { // fall through to the true block. TRACE(" true => fallthrough\n"); } else { len = DoControlTransfer(code, pc); TRACE(" false => @%zu\n", pc + len); } break; } case kExprElse: { len = DoControlTransfer(code, pc); TRACE(" end => @%zu\n", pc + len); break; } case kExprSelect: { WasmVal cond = Pop(); WasmVal fval = Pop(); WasmVal tval = Pop(); Push(pc, cond.to<int32_t>() != 0 ? tval : fval); break; } case kExprBr: { BreakDepthOperand operand(&decoder, code->at(pc)); WasmVal val = PopArity(operand.arity); len = DoControlTransfer(code, pc); TRACE(" br => @%zu\n", pc + len); if (operand.arity > 0) Push(pc, val); break; } case kExprBrIf: { BreakDepthOperand operand(&decoder, code->at(pc)); WasmVal cond = Pop(); WasmVal val = PopArity(operand.arity); bool is_true = cond.to<uint32_t>() != 0; if (is_true) { len = DoControlTransfer(code, pc); TRACE(" br_if => @%zu\n", pc + len); if (operand.arity > 0) Push(pc, val); } else { TRACE(" false => fallthrough\n"); len = 1 + operand.length; Push(pc, WasmVal()); } break; } case kExprBrTable: { BranchTableOperand operand(&decoder, code->at(pc)); uint32_t key = Pop().to<uint32_t>(); WasmVal val = PopArity(operand.arity); if (key >= operand.table_count) key = operand.table_count; len = DoControlTransfer(code, pc + key) + key; TRACE(" br[%u] => @%zu\n", key, pc + len); if (operand.arity > 0) Push(pc, val); break; } case kExprReturn: { ReturnArityOperand operand(&decoder, code->at(pc)); WasmVal val = PopArity(operand.arity); if (!DoReturn(&code, &pc, &limit, val)) return; decoder.Reset(code->start, code->end); continue; } case kExprUnreachable: { DoTrap(kTrapUnreachable, pc); return CommitPc(pc); } case kExprEnd: { len = DoControlTransfer(code, pc); DCHECK_EQ(1, len); break; } case kExprI8Const: { ImmI8Operand operand(&decoder, code->at(pc)); Push(pc, WasmVal(operand.value)); len = 1 + operand.length; break; } case kExprI32Const: { ImmI32Operand operand(&decoder, code->at(pc)); Push(pc, WasmVal(operand.value)); len = 1 + operand.length; break; } case kExprI64Const: { ImmI64Operand operand(&decoder, code->at(pc)); Push(pc, WasmVal(operand.value)); len = 1 + operand.length; break; } case kExprF32Const: { ImmF32Operand operand(&decoder, code->at(pc)); Push(pc, WasmVal(operand.value)); len = 1 + operand.length; break; } case kExprF64Const: { ImmF64Operand operand(&decoder, code->at(pc)); Push(pc, WasmVal(operand.value)); len = 1 + operand.length; break; } case kExprGetLocal: { LocalIndexOperand operand(&decoder, code->at(pc)); Push(pc, stack_[frames_.back().sp + operand.index]); len = 1 + operand.length; break; } case kExprSetLocal: { LocalIndexOperand operand(&decoder, code->at(pc)); WasmVal val = Pop(); stack_[frames_.back().sp + operand.index] = val; Push(pc, val); len = 1 + operand.length; break; } case kExprCallFunction: { CallFunctionOperand operand(&decoder, code->at(pc)); InterpreterCode* target = codemap()->GetCode(operand.index); DoCall(target, &pc, pc + 1 + operand.length, &limit); code = target; decoder.Reset(code->start, code->end); continue; } case kExprCallIndirect: { CallIndirectOperand operand(&decoder, code->at(pc)); size_t index = stack_.size() - operand.arity - 1; DCHECK_LT(index, stack_.size()); uint32_t table_index = stack_[index].to<uint32_t>(); if (table_index >= module()->function_table.size()) { return DoTrap(kTrapFuncInvalid, pc); } uint16_t function_index = module()->function_table[table_index]; InterpreterCode* target = codemap()->GetCode(function_index); DCHECK(target); if (target->function->sig_index != operand.index) { return DoTrap(kTrapFuncSigMismatch, pc); } DoCall(target, &pc, pc + 1 + operand.length, &limit); code = target; decoder.Reset(code->start, code->end); continue; } case kExprCallImport: { UNIMPLEMENTED(); break; } case kExprLoadGlobal: { GlobalIndexOperand operand(&decoder, code->at(pc)); const WasmGlobal* global = &module()->globals[operand.index]; byte* ptr = instance()->globals_start + global->offset; MachineType type = global->type; WasmVal val; if (type == MachineType::Int8()) { val = WasmVal(static_cast<int32_t>(*reinterpret_cast<int8_t*>(ptr))); } else if (type == MachineType::Uint8()) { val = WasmVal(static_cast<int32_t>(*reinterpret_cast<uint8_t*>(ptr))); } else if (type == MachineType::Int16()) { val = WasmVal(static_cast<int32_t>(*reinterpret_cast<int16_t*>(ptr))); } else if (type == MachineType::Uint16()) { val = WasmVal( static_cast<int32_t>(*reinterpret_cast<uint16_t*>(ptr))); } else if (type == MachineType::Int32()) { val = WasmVal(*reinterpret_cast<int32_t*>(ptr)); } else if (type == MachineType::Uint32()) { val = WasmVal(*reinterpret_cast<uint32_t*>(ptr)); } else if (type == MachineType::Int64()) { val = WasmVal(*reinterpret_cast<int64_t*>(ptr)); } else if (type == MachineType::Uint64()) { val = WasmVal(*reinterpret_cast<uint64_t*>(ptr)); } else if (type == MachineType::Float32()) { val = WasmVal(*reinterpret_cast<float*>(ptr)); } else if (type == MachineType::Float64()) { val = WasmVal(*reinterpret_cast<double*>(ptr)); } else { UNREACHABLE(); } Push(pc, val); len = 1 + operand.length; break; } case kExprStoreGlobal: { GlobalIndexOperand operand(&decoder, code->at(pc)); const WasmGlobal* global = &module()->globals[operand.index]; byte* ptr = instance()->globals_start + global->offset; MachineType type = global->type; WasmVal val = Pop(); if (type == MachineType::Int8()) { *reinterpret_cast<int8_t*>(ptr) = static_cast<int8_t>(val.to<int32_t>()); } else if (type == MachineType::Uint8()) { *reinterpret_cast<uint8_t*>(ptr) = static_cast<uint8_t>(val.to<uint32_t>()); } else if (type == MachineType::Int16()) { *reinterpret_cast<int16_t*>(ptr) = static_cast<int16_t>(val.to<int32_t>()); } else if (type == MachineType::Uint16()) { *reinterpret_cast<uint16_t*>(ptr) = static_cast<uint16_t>(val.to<uint32_t>()); } else if (type == MachineType::Int32()) { *reinterpret_cast<int32_t*>(ptr) = val.to<int32_t>(); } else if (type == MachineType::Uint32()) { *reinterpret_cast<uint32_t*>(ptr) = val.to<uint32_t>(); } else if (type == MachineType::Int64()) { *reinterpret_cast<int64_t*>(ptr) = val.to<int64_t>(); } else if (type == MachineType::Uint64()) { *reinterpret_cast<uint64_t*>(ptr) = val.to<uint64_t>(); } else if (type == MachineType::Float32()) { *reinterpret_cast<float*>(ptr) = val.to<float>(); } else if (type == MachineType::Float64()) { *reinterpret_cast<double*>(ptr) = val.to<double>(); } else { UNREACHABLE(); } Push(pc, val); len = 1 + operand.length; break; } #define LOAD_CASE(name, ctype, mtype) \ case kExpr##name: { \ MemoryAccessOperand operand(&decoder, code->at(pc)); \ uint32_t index = Pop().to<uint32_t>(); \ size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ if (operand.offset > effective_mem_size || \ index > (effective_mem_size - operand.offset)) { \ return DoTrap(kTrapMemOutOfBounds, pc); \ } \ byte* addr = instance()->mem_start + operand.offset + index; \ WasmVal result(static_cast<ctype>(ReadLittleEndianValue<mtype>(addr))); \ Push(pc, result); \ len = 1 + operand.length; \ break; \ } LOAD_CASE(I32LoadMem8S, int32_t, int8_t); LOAD_CASE(I32LoadMem8U, int32_t, uint8_t); LOAD_CASE(I32LoadMem16S, int32_t, int16_t); LOAD_CASE(I32LoadMem16U, int32_t, uint16_t); LOAD_CASE(I64LoadMem8S, int64_t, int8_t); LOAD_CASE(I64LoadMem8U, int64_t, uint8_t); LOAD_CASE(I64LoadMem16S, int64_t, int16_t); LOAD_CASE(I64LoadMem16U, int64_t, uint16_t); LOAD_CASE(I64LoadMem32S, int64_t, int32_t); LOAD_CASE(I64LoadMem32U, int64_t, uint32_t); LOAD_CASE(I32LoadMem, int32_t, int32_t); LOAD_CASE(I64LoadMem, int64_t, int64_t); LOAD_CASE(F32LoadMem, float, float); LOAD_CASE(F64LoadMem, double, double); #undef LOAD_CASE #define STORE_CASE(name, ctype, mtype) \ case kExpr##name: { \ MemoryAccessOperand operand(&decoder, code->at(pc)); \ WasmVal val = Pop(); \ uint32_t index = Pop().to<uint32_t>(); \ size_t effective_mem_size = instance()->mem_size - sizeof(mtype); \ if (operand.offset > effective_mem_size || \ index > (effective_mem_size - operand.offset)) { \ return DoTrap(kTrapMemOutOfBounds, pc); \ } \ byte* addr = instance()->mem_start + operand.offset + index; \ WriteLittleEndianValue<mtype>(addr, static_cast<mtype>(val.to<ctype>())); \ Push(pc, val); \ len = 1 + operand.length; \ break; \ } STORE_CASE(I32StoreMem8, int32_t, int8_t); STORE_CASE(I32StoreMem16, int32_t, int16_t); STORE_CASE(I64StoreMem8, int64_t, int8_t); STORE_CASE(I64StoreMem16, int64_t, int16_t); STORE_CASE(I64StoreMem32, int64_t, int32_t); STORE_CASE(I32StoreMem, int32_t, int32_t); STORE_CASE(I64StoreMem, int64_t, int64_t); STORE_CASE(F32StoreMem, float, float); STORE_CASE(F64StoreMem, double, double); #undef STORE_CASE #define ASMJS_LOAD_CASE(name, ctype, mtype, defval) \ case kExpr##name: { \ uint32_t index = Pop().to<uint32_t>(); \ ctype result; \ if (index >= (instance()->mem_size - sizeof(mtype))) { \ result = defval; \ } else { \ byte* addr = instance()->mem_start + index; \ /* TODO(titzer): alignment for asmjs load mem? */ \ result = static_cast<ctype>(*reinterpret_cast<mtype*>(addr)); \ } \ Push(pc, WasmVal(result)); \ break; \ } ASMJS_LOAD_CASE(I32AsmjsLoadMem8S, int32_t, int8_t, 0); ASMJS_LOAD_CASE(I32AsmjsLoadMem8U, int32_t, uint8_t, 0); ASMJS_LOAD_CASE(I32AsmjsLoadMem16S, int32_t, int16_t, 0); ASMJS_LOAD_CASE(I32AsmjsLoadMem16U, int32_t, uint16_t, 0); ASMJS_LOAD_CASE(I32AsmjsLoadMem, int32_t, int32_t, 0); ASMJS_LOAD_CASE(F32AsmjsLoadMem, float, float, std::numeric_limits<float>::quiet_NaN()); ASMJS_LOAD_CASE(F64AsmjsLoadMem, double, double, std::numeric_limits<double>::quiet_NaN()); #undef ASMJS_LOAD_CASE #define ASMJS_STORE_CASE(name, ctype, mtype) \ case kExpr##name: { \ WasmVal val = Pop(); \ uint32_t index = Pop().to<uint32_t>(); \ if (index < (instance()->mem_size - sizeof(mtype))) { \ byte* addr = instance()->mem_start + index; \ /* TODO(titzer): alignment for asmjs store mem? */ \ *(reinterpret_cast<mtype*>(addr)) = static_cast<mtype>(val.to<ctype>()); \ } \ Push(pc, val); \ break; \ } ASMJS_STORE_CASE(I32AsmjsStoreMem8, int32_t, int8_t); ASMJS_STORE_CASE(I32AsmjsStoreMem16, int32_t, int16_t); ASMJS_STORE_CASE(I32AsmjsStoreMem, int32_t, int32_t); ASMJS_STORE_CASE(F32AsmjsStoreMem, float, float); ASMJS_STORE_CASE(F64AsmjsStoreMem, double, double); #undef ASMJS_STORE_CASE case kExprMemorySize: { Push(pc, WasmVal(static_cast<uint32_t>(instance()->mem_size))); break; } #define EXECUTE_SIMPLE_BINOP(name, ctype, op) \ case kExpr##name: { \ WasmVal rval = Pop(); \ WasmVal lval = Pop(); \ WasmVal result(lval.to<ctype>() op rval.to<ctype>()); \ Push(pc, result); \ break; \ } FOREACH_SIMPLE_BINOP(EXECUTE_SIMPLE_BINOP) #undef EXECUTE_SIMPLE_BINOP #define EXECUTE_OTHER_BINOP(name, ctype) \ case kExpr##name: { \ TrapReason trap = kTrapCount; \ volatile ctype rval = Pop().to<ctype>(); \ volatile ctype lval = Pop().to<ctype>(); \ WasmVal result(Execute##name(lval, rval, &trap)); \ if (trap != kTrapCount) return DoTrap(trap, pc); \ Push(pc, result); \ break; \ } FOREACH_OTHER_BINOP(EXECUTE_OTHER_BINOP) #undef EXECUTE_OTHER_BINOP #define EXECUTE_OTHER_UNOP(name, ctype) \ case kExpr##name: { \ TrapReason trap = kTrapCount; \ volatile ctype val = Pop().to<ctype>(); \ WasmVal result(Execute##name(val, &trap)); \ if (trap != kTrapCount) return DoTrap(trap, pc); \ Push(pc, result); \ break; \ } FOREACH_OTHER_UNOP(EXECUTE_OTHER_UNOP) #undef EXECUTE_OTHER_UNOP default: V8_Fatal(__FILE__, __LINE__, "Unknown or unimplemented opcode #%d:%s", code->start[pc], OpcodeName(code->start[pc])); UNREACHABLE(); } pc += len; } UNREACHABLE(); // above decoding loop should run forever. } WasmVal Pop() { DCHECK_GT(stack_.size(), 0u); DCHECK_GT(frames_.size(), 0u); DCHECK_GT(stack_.size(), frames_.back().llimit()); // can't pop into locals WasmVal val = stack_.back(); stack_.pop_back(); return val; } void PopN(int n) { DCHECK_GE(stack_.size(), static_cast<size_t>(n)); DCHECK_GT(frames_.size(), 0u); size_t nsize = stack_.size() - n; DCHECK_GE(nsize, frames_.back().llimit()); // can't pop into locals stack_.resize(nsize); } WasmVal PopArity(size_t arity) { if (arity == 0) return WasmVal(); CHECK_EQ(1, arity); return Pop(); } void Push(pc_t pc, WasmVal val) { // TODO(titzer): store PC as well? stack_.push_back(val); } void TraceStack(const char* phase, pc_t pc) { if (FLAG_trace_wasm_interpreter) { PrintF("%s @%zu", phase, pc); UNIMPLEMENTED(); PrintF("\n"); } } void TraceValueStack() { Frame* top = frames_.size() > 0 ? &frames_.back() : nullptr; sp_t sp = top ? top->sp : 0; sp_t plimit = top ? top->plimit() : 0; sp_t llimit = top ? top->llimit() : 0; if (FLAG_trace_wasm_interpreter) { for (size_t i = sp; i < stack_.size(); ++i) { if (i < plimit) PrintF(" p%zu:", i); else if (i < llimit) PrintF(" l%zu:", i); else PrintF(" s%zu:", i); WasmVal val = stack_[i]; switch (val.type) { case kAstI32: PrintF("i32:%d", val.to<int32_t>()); break; case kAstI64: PrintF("i64:%" PRId64 "", val.to<int64_t>()); break; case kAstF32: PrintF("f32:%f", val.to<float>()); break; case kAstF64: PrintF("f64:%lf", val.to<double>()); break; case kAstStmt: PrintF("void"); break; default: UNREACHABLE(); break; } } } } }; //============================================================================ // The implementation details of the interpreter. //============================================================================ class WasmInterpreterInternals : public ZoneObject { public: WasmModuleInstance* instance_; CodeMap codemap_; ZoneVector<ThreadImpl*> threads_; WasmInterpreterInternals(Zone* zone, WasmModuleInstance* instance) : instance_(instance), codemap_(instance_ ? instance_->module : nullptr, zone), threads_(zone) { threads_.push_back(new ThreadImpl(zone, &codemap_, instance)); } void Delete() { // TODO(titzer): CFI doesn't like threads in the ZoneVector. for (auto t : threads_) delete t; threads_.resize(0); } }; //============================================================================ // Implementation of the public interface of the interpreter. //============================================================================ WasmInterpreter::WasmInterpreter(WasmModuleInstance* instance, base::AccountingAllocator* allocator) : zone_(allocator), internals_(new (&zone_) WasmInterpreterInternals(&zone_, instance)) {} WasmInterpreter::~WasmInterpreter() { internals_->Delete(); } void WasmInterpreter::Run() { internals_->threads_[0]->Run(); } void WasmInterpreter::Pause() { internals_->threads_[0]->Pause(); } bool WasmInterpreter::SetBreakpoint(const WasmFunction* function, pc_t pc, bool enabled) { InterpreterCode* code = internals_->codemap_.FindCode(function); if (!code) return false; size_t size = static_cast<size_t>(code->end - code->start); // Check bounds for {pc}. if (pc < code->locals.decls_encoded_size || pc >= size) return false; // Make a copy of the code before enabling a breakpoint. if (enabled && code->orig_start == code->start) { code->start = reinterpret_cast<byte*>(zone_.New(size)); memcpy(code->start, code->orig_start, size); code->end = code->start + size; } bool prev = code->start[pc] == kInternalBreakpoint; if (enabled) { code->start[pc] = kInternalBreakpoint; } else { code->start[pc] = code->orig_start[pc]; } return prev; } bool WasmInterpreter::GetBreakpoint(const WasmFunction* function, pc_t pc) { InterpreterCode* code = internals_->codemap_.FindCode(function); if (!code) return false; size_t size = static_cast<size_t>(code->end - code->start); // Check bounds for {pc}. if (pc < code->locals.decls_encoded_size || pc >= size) return false; // Check if a breakpoint is present at that place in the code. return code->start[pc] == kInternalBreakpoint; } bool WasmInterpreter::SetTracing(const WasmFunction* function, bool enabled) { UNIMPLEMENTED(); return false; } int WasmInterpreter::GetThreadCount() { return 1; // only one thread for now. } WasmInterpreter::Thread* WasmInterpreter::GetThread(int id) { CHECK_EQ(0, id); // only one thread for now. return internals_->threads_[id]; } WasmVal WasmInterpreter::GetLocalVal(const WasmFrame* frame, int index) { CHECK_GE(index, 0); UNIMPLEMENTED(); WasmVal none; none.type = kAstStmt; return none; } WasmVal WasmInterpreter::GetExprVal(const WasmFrame* frame, int pc) { UNIMPLEMENTED(); WasmVal none; none.type = kAstStmt; return none; } void WasmInterpreter::SetLocalVal(WasmFrame* frame, int index, WasmVal val) { UNIMPLEMENTED(); } void WasmInterpreter::SetExprVal(WasmFrame* frame, int pc, WasmVal val) { UNIMPLEMENTED(); } size_t WasmInterpreter::GetMemorySize() { return internals_->instance_->mem_size; } WasmVal WasmInterpreter::ReadMemory(size_t offset) { UNIMPLEMENTED(); return WasmVal(); } void WasmInterpreter::WriteMemory(size_t offset, WasmVal val) { UNIMPLEMENTED(); } int WasmInterpreter::AddFunctionForTesting(const WasmFunction* function) { return internals_->codemap_.AddFunction(function, nullptr, nullptr); } bool WasmInterpreter::SetFunctionCodeForTesting(const WasmFunction* function, const byte* start, const byte* end) { return internals_->codemap_.SetFunctionCode(function, start, end); } ControlTransferMap WasmInterpreter::ComputeControlTransfersForTesting( Zone* zone, const byte* start, const byte* end) { ControlTransfers targets(zone, 0, start, end); return targets.map_; } } // namespace wasm } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
7aa1c8d8ae8fd49b3ea3f91dc34736228c1d59a9
323788cf746237167c70f38117d3fbd26e92c041
/sandbox/korbinian/src/gmmbin/gmm-decode-nbest.cc
3a28e5f2f8d82ffdbbdd9ee34c600edeac2e7dc5
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
zweiein/kaldi
3cfc5d1fc66c1ca32c74f71171d4af2e2512f15c
708448c693272af0d68c8e178c7b4ff836125acf
refs/heads/master
2020-12-26T00:45:36.907011
2015-10-23T21:17:02
2015-10-23T21:17:02
46,313,562
0
1
null
2015-11-17T00:57:57
2015-11-17T00:57:57
null
UTF-8
C++
false
false
9,197
cc
// gmmbin/gmm-decode-nbest.cc // Copyright 2009-2011 Microsoft Corporation, Mirko Hannemann // 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 // // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, // MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache 2 License for the specific language governing permissions and // limitations under the License. #include "base/kaldi-common.h" #include "util/common-utils.h" #include "gmm/am-diag-gmm.h" #include "hmm/transition-model.h" #include "fst/fstlib.h" #include "fstext/fstext-lib.h" #include "decoder/nbest-decoder.h" #include "gmm/decodable-am-diag-gmm.h" #include "util/timer.h" #include "lat/kaldi-lattice.h" // for CompactLatticeArc #include "fstext/lattice-utils.h" // for ConvertLattice using namespace kaldi; fst::Fst<fst::StdArc> *ReadNetwork(std::string filename) { // read decoding network FST Input ki(filename); // use ki.Stream() instead of is. if (!ki.Stream().good()) KALDI_ERR << "Could not open decoding-graph FST " << filename; fst::FstHeader hdr; if (!hdr.Read(ki.Stream(), "<unknown>")) { KALDI_ERR << "Reading FST: error reading FST header."; } if (hdr.ArcType() != fst::StdArc::Type()) { KALDI_ERR << "FST with arc type " << hdr.ArcType() << " not supported.\n"; } fst::FstReadOptions ropts("<unspecified>", &hdr); fst::Fst<fst::StdArc> *decode_fst = NULL; if (hdr.FstType() == "vector") { decode_fst = fst::VectorFst<fst::StdArc>::Read(ki.Stream(), ropts); } else if (hdr.FstType() == "const") { decode_fst = fst::ConstFst<fst::StdArc>::Read(ki.Stream(), ropts); } else { KALDI_ERR << "Reading FST: unsupported FST type: " << hdr.FstType(); } if (decode_fst == NULL) { // fst code will warn. KALDI_ERR << "Error reading FST (after reading header)."; return NULL; } else { return decode_fst; } } int main(int argc, char *argv[]) { try { typedef kaldi::int32 int32; const char *usage = "Decode features using GMM-based model, producing N-best lattice output.\n" "Note: this program was mainly intended to validate the lattice generation\n" "algorithm and is not very useful; in general, processing the\n" "lattices into n-best lists will be more efficient.\n" "Usage:\n" " gmm-decode-nbest [options] model-in fst-in features-rspecifier nbestlattice-wspecifier words-wspecifier [alignments-wspecifier]\n"; ParseOptions po(usage); bool allow_partial = true; BaseFloat acoustic_scale = 0.1; std::string word_syms_filename; NBestDecoderOptions decoder_opts; decoder_opts.Register(&po, true); // true == include obscure settings. po.Register("acoustic-scale", &acoustic_scale, "Scaling factor for acoustic likelihoods"); po.Register("word-symbol-table", &word_syms_filename, "Symbol table for words [for debug output]"); po.Register("allow-partial", &allow_partial, "Produce output even when final state was not reached"); po.Read(argc, argv); if (po.NumArgs() < 4 || po.NumArgs() > 6) { po.PrintUsage(); exit(1); } std::string model_in_filename = po.GetArg(1), fst_in_filename = po.GetArg(2), feature_rspecifier = po.GetArg(3), lattice_wspecifier = po.GetArg(4), words_wspecifier = po.GetOptArg(5), alignment_wspecifier = po.GetOptArg(6); TransitionModel trans_model; AmDiagGmm am_gmm; { bool binary; Input ki(model_in_filename, &binary); trans_model.Read(ki.Stream(), binary); am_gmm.Read(ki.Stream(), binary); } CompactLatticeWriter compact_lattice_writer; if (!compact_lattice_writer.Open(lattice_wspecifier)) { KALDI_ERR << "Could not open table for writing lattices: " << lattice_wspecifier; } Int32VectorWriter words_writer(words_wspecifier); Int32VectorWriter alignment_writer(alignment_wspecifier); fst::SymbolTable *word_syms = NULL; if (word_syms_filename != "") if (!(word_syms = fst::SymbolTable::ReadText(word_syms_filename))) KALDI_ERR << "Could not read symbol table from file " << word_syms_filename; SequentialBaseFloatMatrixReader feature_reader(feature_rspecifier); // It's important that we initialize decode_fst after feature_reader, as it // can prevent crashes on systems installed without enough virtual memory. // It has to do with what happens on UNIX systems if you call fork() on a // large process: the page-table entries are duplicated, which requires a // lot of virtual memory. fst::Fst<fst::StdArc> *decode_fst = ReadNetwork(fst_in_filename); BaseFloat tot_like = 0.0; kaldi::int64 frame_count = 0; int num_success = 0, num_fail = 0; NBestDecoder decoder(*decode_fst, decoder_opts); Timer timer; for (; !feature_reader.Done(); feature_reader.Next()) { std::string key = feature_reader.Key(); Matrix<BaseFloat> features (feature_reader.Value()); feature_reader.FreeCurrent(); if (features.NumRows() == 0) { KALDI_WARN << "Zero-length utterance: " << key; num_fail++; continue; } DecodableAmDiagGmmScaled gmm_decodable(am_gmm, trans_model, features, acoustic_scale); decoder.Decode(&gmm_decodable); fst::VectorFst<CompactLatticeArc> decoded; // output FST. bool was_final; int32 nbest; BaseFloat nbest_beam; if (decoder.GetNBestLattice(&decoded, &was_final, &nbest, &nbest_beam)) { if (!was_final) { if (allow_partial) { KALDI_WARN << "Decoder did not reach end-state, " << "outputting partial traceback since --allow-partial=true"; } else { KALDI_WARN << "Decoder did not reach end-state, " << "output partial traceback with --allow-partial=true"; num_fail++; KALDI_WARN << "Did not successfully decode utterance " << key << ", len = " << features.NumRows(); continue; // next utterance } } num_success++; KALDI_LOG << "retrieved:" << nbest << " tokens, effective beam:" << nbest_beam; // std::cout << "n-best paths:\n"; // fst::FstPrinter<CompactLatticeArc> fstprinter(decoded, NULL, NULL, NULL, false, true); // fstprinter.Print(&std::cout, "standard output"); if (acoustic_scale != 0.0) // We'll write the lattice without acoustic scaling fst::ScaleLattice(fst::AcousticLatticeScale(1.0 / acoustic_scale), &decoded); compact_lattice_writer.Write(key, decoded); fst::VectorFst<CompactLatticeArc> decoded1; ShortestPath(decoded, &decoded1); fst::VectorFst<LatticeArc> utterance; ConvertLattice(decoded1, &utterance, true); std::vector<int32> alignment; std::vector<int32> words; LatticeWeight weight; frame_count += features.NumRows(); GetLinearSymbolSequence(utterance, &alignment, &words, &weight); words_writer.Write(key, words); if (alignment_writer.IsOpen()) alignment_writer.Write(key, alignment); if (word_syms != NULL) { std::cerr << key << ' '; for (size_t i = 0; i < words.size(); i++) { std::string s = word_syms->Find(words[i]); if (s == "") KALDI_ERR << "Word-id " << words[i] <<" not in symbol table."; std::cerr << s << ' '; } std::cerr << '\n'; } BaseFloat like = -(weight.Value1() - weight.Value2()); // KALDI_LOG << "final weight:" << weight.Value1() << "," << weight.Value2(); tot_like += like; KALDI_LOG << "Log-like per frame for utterance " << key << " is " << (like / features.NumRows()) << " over " << features.NumRows() << " frames."; } else { num_fail++; KALDI_WARN << "Did not successfully decode utterance " << key << ", len = " << features.NumRows(); } } double elapsed = timer.Elapsed(); KALDI_LOG << "Time taken [excluding initialization] "<< elapsed << "s: real-time factor assuming 100 frames/sec is " << (elapsed*100.0/frame_count); KALDI_LOG << "Done " << num_success << " utterances, failed for " << num_fail; KALDI_LOG << "Overall log-likelihood per frame is " << (tot_like/frame_count) << " over " << frame_count<<" frames."; if (word_syms) delete word_syms; delete decode_fst; if (num_success != 0) return 0; else return 1; } catch(const std::exception &e) { std::cerr << e.what(); return -1; } }
[ "sikoried@5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8" ]
sikoried@5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
be0a2995b661a8f98bf114bd3e6e5be918fd478f
043201e8d546e17d543b20f009799992fba6f9a1
/Perfect Keyboard.cpp
5cd33abcc4ef19dc180d4053739d85008ea3e6f1
[]
no_license
RavisriVK/Competitive-Programming-Sample
fe074472ad692a7ee236e8ece5652423166771c0
ba15f2663bfa9cc813aa8a50e52d5017f002dbf9
refs/heads/main
2023-06-25T20:00:51.699540
2021-07-14T07:00:01
2021-07-14T07:00:01
355,074,485
0
0
null
null
null
null
UTF-8
C++
false
false
1,488
cpp
#include<iostream> #include<string.h> #include<algorithm> #include<vector> #define MOD(a) ((a)<0?((-1)*(a)):(a)) using namespace std; int main() { int N; scanf("%d",&N); while(N--) { char s[201]; scanf("%s",s); vector<int> alp; int length=strlen(s); alp.insert(alp.begin(),s[0]); int flag=0; for(int i=1; i<length; i++) { vector<int>::iterator it1=find(alp.begin(),alp.end(),s[i-1]); vector<int>::iterator it2=find(alp.begin(),alp.end(),s[i]); if(it2==alp.end()) { if(alp.back()==s[i-1]) alp.insert(alp.end(),s[i]); else if(alp.front()==s[i-1]) alp.insert(alp.begin(),s[i]); else { flag=1; break; } } else if(MOD(distance(it1,it2))>1) { flag=1; break; } } if(flag==1) { printf("NO\n"); } else { int alpha[26]={0}; printf("YES\n"); for(int i=0; i<alp.size(); i++) { printf("%c",alp.at(i)); alpha[alp.at(i)-'a']=1; } for(int i=0; i<26; i++) if(alpha[i]==0) printf("%c",'a'+i); printf("\n"); } } }
[ "ravivalluri@MacBook-Pro.local" ]
ravivalluri@MacBook-Pro.local
14c6a5fbe13380a2bae0f23463b509b5a428751f
8a100a50efe9df71962b2552bd9b75300958b1fe
/Transmitters/Old Version/X_CTRL_STM32F4xx/X_CTRL_GUN/USER/Shell/XC_COM/XC_COM.cpp
d23aa365c0b9641f2e56c21be8ca41efe6bd716f
[ "MIT" ]
permissive
yu1741588584/X-CTRL
156d608a02a9953de3a92e1d0a0abc62ece74350
9d93a49688fd8526253c9c9119479d04fab8371b
refs/heads/master
2022-12-27T22:29:31.691813
2022-04-30T03:49:20
2022-04-30T03:49:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,803
cpp
#include "XC_COM.h" #ifdef ARDUINO # include "HardwareSerial.h" # include "Basic/TasksManage.h" # define XC_COM_DELAY(ms) vTaskDelay(ms) # define XC_COM_BUF_WRITE(buf,size) Serial.write(buf,size) # define XC_COM_BUF_AVALIABLE() Serial.available() # define XC_COM_BUF_READ(buf,size) Serial.readBytes((uint8_t*)buf,size) # define XC_DEBUG(format, ...) # define XC_COM_BUF_FLUSH() Serial.flush() #endif #ifdef _WIN32 # include <windows.h> # include <time.h> # include "../FileGroup.h" # define XC_COM_DELAY(ms) Sleep(ms) # define XC_COM_BUF_WRITE(buf,size) Serial.write(buf,size) # define XC_COM_BUF_AVALIABLE() Serial.available() # define XC_COM_BUF_READ(buf,size) Serial.read(buf,size) # define XC_COM_BUF_FLUSH() Serial.flush() # define XC_DEBUG(format, ...) printf(format, ##__VA_ARGS__) # define millis() clock() #endif #define XC_HEAD_SLAVE 0x55AA #define XC_HEAD_MASTER 0xAA55 #define XC_BUFFER_SIZE 64 #define XC_SEND_DELAY 50 #define XC_SEND_RETRY 100 #define XC_FILEPATH_MAX 64 #define XC_STRUCT_INIT(Struct) memset(&Struct,0,sizeof(Struct)) #define XC_STRUCT_CRC32(Struct) CRC32_Calculate(0, &Struct, sizeof(Struct) - sizeof(uint32_t)) typedef enum { XC_CMD_None, XC_CMD_Send, XC_CMD_Recv, } XC_CMD_Type; #pragma pack (1) typedef struct { uint16_t Head; uint8_t CMD; uint32_t FileSize; char FileName[64]; uint32_t PackSize; uint32_t PackCount; uint16_t PackTimeout; // uint8_t Reserved[64]; uint32_t CRC32; } XC_HandshakeHead_TypeDef; typedef struct{ uint32_t Size; uint32_t Cnt; uint32_t CRC32; }XC_PackCheck_TypeDef; typedef struct { uint32_t Size; uint32_t Cnt; uint8_t Buffer[XC_BUFFER_SIZE]; uint32_t CRC32; } XC_DataPack_TypeDef;; #pragma pack (0) static FILE* pfile = NULL; static uint16_t XC_SendRetry = XC_SEND_RETRY; static uint16_t XC_SendDelay = XC_SEND_DELAY; static uint32_t XC_COM_LoopTime = 0; XC_HandshakeHead_TypeDef XC_Handshake; XC_DataPack_TypeDef XC_DataPack; uint32_t XC_COM_GetLoopTime() { return XC_COM_LoopTime; } float XC_COM_GetSpeedBps() { if (XC_COM_LoopTime == 0) { return 0; } return ((float)XC_Handshake.FileSize / (XC_COM_LoopTime / 1000)); } void XC_COM_SetRetryDelay(uint16_t retry, uint16_t delay) { XC_SendRetry = retry; XC_SendDelay = delay; } static uint32_t XC_GetPackCount(uint32_t fileSize, uint32_t packSize) { return (fileSize / packSize + ((fileSize % packSize) == 0 ? 0 : 1)); } static bool XC_COM_SendPrepare(const char* filePath) { bool retval = false; pfile = fopen(filePath, "rb"); if (pfile) { fseek(pfile, 0, SEEK_END); String name = String(filePath); int index = name.lastIndexOf('/') + 1; name = name.substring(index); XC_STRUCT_INIT(XC_Handshake); XC_Handshake.Head = XC_HEAD_MASTER; XC_Handshake.CMD = XC_CMD_Send; XC_Handshake.FileSize = ftell(pfile); strcpy(XC_Handshake.FileName, name.c_str()); XC_Handshake.PackSize = XC_BUFFER_SIZE; XC_Handshake.PackCount = XC_GetPackCount(XC_Handshake.FileSize, XC_Handshake.PackSize); XC_Handshake.PackTimeout = XC_SendDelay; XC_Handshake.CRC32 = XC_STRUCT_CRC32(XC_Handshake); fseek(pfile, 0, SEEK_SET); retval = true; } return retval; } static bool XC_COM_SendHandshake() { if (!pfile) return false; uint16_t retryCnt = XC_SendRetry; XC_HandshakeHead_TypeDef slave; while (retryCnt--) { XC_COM_BUF_FLUSH(); XC_COM_BUF_WRITE(&XC_Handshake, sizeof(XC_Handshake)); XC_COM_DELAY(XC_SEND_DELAY); if (XC_COM_BUF_AVALIABLE() >= sizeof(slave)) { XC_STRUCT_INIT(slave); XC_COM_BUF_READ(&slave, sizeof(slave)); XC_COM_BUF_FLUSH(); if (slave.Head == XC_HEAD_SLAVE && slave.CMD == XC_CMD_Recv) { slave.Head = XC_Handshake.Head; slave.CMD = XC_Handshake.CMD; if (memcmp(&slave, &XC_Handshake, sizeof(slave)) == 0) { return true; } } else { XC_DEBUG("Handshake faild, retry...\r\n"); } } } fclose(pfile); pfile = NULL; return false; } bool XC_COM_SendFile(const char* filePath) { XC_DEBUG("Send Preparing...\r\n"); if (!XC_COM_SendPrepare(filePath)) return false; XC_DEBUG(".Head = 0x%x\r\n", XC_Handshake.Head); XC_DEBUG(".CMD = %d\r\n", XC_Handshake.CMD); XC_DEBUG(".FileSize = %d Bytes\r\n", XC_Handshake.FileSize); XC_DEBUG(".FileName = %s\r\n", XC_Handshake.FileName); XC_DEBUG(".PackSize = %d\r\n", XC_Handshake.PackSize); XC_DEBUG(".PackCount = %d\r\n", XC_Handshake.PackCount); XC_DEBUG(".PackTimeout = %d\r\n", XC_Handshake.PackTimeout); XC_DEBUG(".CRC32 = 0x%x\r\n", XC_Handshake.CRC32); XC_DEBUG("Send Handshake...\r\n"); if (!XC_COM_SendHandshake()) return false; fseek(pfile, 0, SEEK_SET); XC_DEBUG("Sending...\r\n"); XC_PackCheck_TypeDef packCheck; uint32_t count = XC_Handshake.PackCount; uint32_t startTime = millis(); for (uint32_t i = 0; i < count; i++) { bool isTimeout = true; uint32_t readSize = fread(XC_DataPack.Buffer, 1, sizeof(XC_DataPack.Buffer), pfile); XC_DataPack.Size = readSize; XC_DataPack.Cnt = i; XC_DataPack.CRC32 = XC_STRUCT_CRC32(XC_DataPack); uint16_t retryCnt = 0; Retry: XC_COM_BUF_WRITE(&XC_DataPack, sizeof(XC_DataPack)); uint32_t start = millis(); while (millis() - start < XC_SendDelay) { if (XC_COM_BUF_AVALIABLE() >= sizeof(packCheck)) { XC_STRUCT_INIT(packCheck); XC_COM_BUF_READ(&packCheck, sizeof(packCheck)); XC_COM_BUF_FLUSH(); if ( packCheck.Cnt == XC_DataPack.Cnt && packCheck.Size == XC_DataPack.Size && packCheck.CRC32 == XC_DataPack.CRC32 ) { //XC_DEBUG("%d/%d\r\n", XC_DataPack.Cnt + 1, XC_Handshake.PackCount); //XC_DEBUG("Size:%d, CRC:0x%x\r\n", XC_DataPack.Size, packCheck.CRC32); isTimeout = false; break; } } } if (isTimeout) { if (retryCnt < XC_SEND_RETRY) { XC_DEBUG("Send error retry(%d)\r\n", retryCnt); retryCnt++; goto Retry; } goto failed; } static uint32_t lastPrintTime; if (millis() - lastPrintTime > 1000) { lastPrintTime = millis(); uint32_t now = XC_DataPack.Cnt + 1; uint32_t sum = XC_Handshake.PackCount; XC_DEBUG("Pack: %d/%d (%0.2f%%)\r\n", now, sum, (float)now / sum * 100); } } XC_COM_LoopTime = millis() - startTime; fclose(pfile); pfile = NULL; return true; failed: return false; } static bool XC_COM_RecvPrepare(const char* filePath) { XC_COM_BUF_FLUSH(); uint16_t retryCnt = XC_SEND_RETRY; XC_DEBUG("Wait Handshake...\r\n"); while (XC_COM_BUF_AVALIABLE() < sizeof(XC_Handshake) && --retryCnt) { XC_COM_BUF_FLUSH(); XC_COM_DELAY(XC_SendDelay); } if (retryCnt == 0) { XC_DEBUG("time out\r\n"); return false; } XC_DEBUG("Handshake checking...\r\n"); XC_STRUCT_INIT(XC_Handshake); XC_COM_BUF_READ(&XC_Handshake, sizeof(XC_Handshake)); XC_COM_BUF_FLUSH(); XC_DEBUG(".Head = 0x%x\r\n", XC_Handshake.Head); XC_DEBUG(".CMD = %d\r\n", XC_Handshake.CMD); XC_DEBUG(".FileSize = %d Bytes\r\n", XC_Handshake.FileSize); XC_DEBUG(".FileName = %s\r\n", XC_Handshake.FileName); XC_DEBUG(".PackSize = %d\r\n", XC_Handshake.PackSize); XC_DEBUG(".PackCount = %d\r\n", XC_Handshake.PackCount); XC_DEBUG(".PackTimeout = %d\r\n", XC_Handshake.PackTimeout); XC_DEBUG(".CRC32 = 0x%x\r\n", XC_Handshake.CRC32); if (XC_Handshake.CRC32 != XC_STRUCT_CRC32(XC_Handshake)) { XC_DEBUG("CRC(0x%x) check error\r\n", XC_Handshake.CRC32); return false; } XC_Handshake.Head = XC_HEAD_SLAVE; XC_Handshake.CMD = XC_CMD_Recv; XC_COM_BUF_WRITE(&XC_Handshake, sizeof(XC_Handshake)); char FilePath[XC_FILEPATH_MAX]; if (filePath) { sprintf(FilePath, "%s/%s", filePath, XC_Handshake.FileName); } pfile = fopen(filePath ? FilePath : XC_Handshake.FileName, "wb+"); if (pfile) { XC_DEBUG("file %s open success\r\n", XC_Handshake.FileName); } else { XC_DEBUG("file open failed\r\n"); return false; } return true; } bool XC_COM_RecvFile(const char* filePath) { bool retval = false; if (!XC_COM_RecvPrepare(filePath)) return false; XC_COM_BUF_FLUSH(); fseek(pfile, 0, SEEK_SET); XC_PackCheck_TypeDef packCheck; uint32_t count = XC_Handshake.PackCount; uint32_t lastRxTime = millis(); uint32_t lastCnt = 0xFFFFFFFF; for(uint32_t i = 0; i < count; ) { if (XC_COM_BUF_AVALIABLE() >= sizeof(XC_DataPack)) { lastRxTime = millis(); XC_STRUCT_INIT(packCheck); XC_STRUCT_INIT(XC_DataPack); XC_COM_BUF_READ(&XC_DataPack, sizeof(XC_DataPack)); XC_COM_BUF_FLUSH(); packCheck.Cnt = i; packCheck.Size = XC_DataPack.Size; packCheck.CRC32 = XC_STRUCT_CRC32(XC_DataPack); XC_COM_BUF_WRITE(&packCheck, sizeof(packCheck)); if(packCheck.CRC32 == XC_DataPack.CRC32) { if (XC_DataPack.Cnt != lastCnt) { lastCnt = XC_DataPack.Cnt; XC_DEBUG("Pack %d/%d, Size:%d, CRC:0x%x\r\n", XC_DataPack.Cnt + 1, XC_Handshake.PackCount, XC_DataPack.Size, packCheck.CRC32); fwrite(XC_DataPack.Buffer, XC_DataPack.Size, 1, pfile); i++; } } else { XC_DEBUG("CRC:0x%x ERROR! Retrying...", XC_DataPack.CRC32); retval = false; } retval = true; } if (millis() - lastRxTime > (XC_Handshake.PackTimeout * 2)) { XC_DEBUG("Pack time out\r\n"); retval = false; break; } } fclose(pfile); pfile = NULL; return retval; }
[ "1290176185@qq.com" ]
1290176185@qq.com
a0a533b77f219cd388a0897f684ca1a2df1c4abf
4e1d6b7225d973619eb8d8fc32a3a802282aad67
/1475.cpp
f3b3f146b10fdd4e4266a582745e3728747e1008
[]
no_license
peter9378/acmicpc_stepbystep
482263c9d4ab71388d020350503aa569f3ae3239
d33363309df421a18daabb49d9abd42f4de0df46
refs/heads/master
2021-10-22T18:16:12.979205
2019-03-12T13:12:34
2019-03-12T13:12:34
120,999,181
0
0
null
null
null
null
UTF-8
C++
false
false
563
cpp
/** * baekjoon online judge * No. 1475 방 번호경사로 * @author peter9378 * @date 2019.03.12 */ #include <iostream> #include <algorithm> using namespace std; int arr[11]; // main function int main() { ios::sync_with_stdio(false); cin.tie(NULL); // input data int N; cin >> N; while (true) { arr[N % 10]++; if (N / 10 == 0) break; N /= 10; } int answer = 0; for (int i = 0; i < 10; i++) { if (i != 9 && i != 6) answer = max(answer, arr[i]); } // print answer cout << max(answer, (arr[6] + arr[9] + 1) / 2); return 0; }
[ "peter9378@naver.com" ]
peter9378@naver.com
bfd1c71d36e651d5971d80cbb497b8a33c8a60d4
7d228f077214f798c1fa6ee2a486a25c01d72cce
/wrspice/devlib/sw/swdefs.h
86806ca848f49f4414c30adb187a47a62b3876ee
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Plourde-Research-Lab/xictools
1f3de596f5de4d9c9c5fab2a021e530f1f258ce9
070b9089607f9a99aabe8d11849b0e4d1fe4fcb8
refs/heads/master
2021-07-08T13:21:29.734753
2017-10-04T16:08:10
2017-10-04T16:08:10
106,029,821
0
1
null
2017-10-06T17:04:21
2017-10-06T17:04:21
null
UTF-8
C++
false
false
8,028
h
/*========================================================================* * * * Distributed by Whiteley Research Inc., Sunnyvale, California, USA * * http://wrcad.com * * Copyright (C) 2017 Whiteley Research Inc., all rights reserved. * * Author: Stephen R. Whiteley, except as indicated. * * * * As fully as possible recognizing licensing terms and conditions * * imposed by earlier work from which this work was derived, if any, * * this work is released under the Apache License, Version 2.0 (the * * "License"). You may not use this file except in compliance with * * the License, and compliance with inherited licenses which are * * specified in a sub-header below this one if applicable. A copy * * of the License is provided with this distribution, or you may * * obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * See the License for the specific language governing permissions * * and limitations under the License. * * * * 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 NON- * * INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED * * OR STEPHEN R. WHITELEY 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. * * * *========================================================================* * XicTools Integrated Circuit Design System * * * * WRspice Circuit Simulation and Analysis Tool: Device Library * * * *========================================================================* $Id:$ *========================================================================*/ /*************************************************************************** JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992 Copyright 1990 Regents of the University of California. All rights reserved. Authors: 1985 Gordon M. Jacobs 1992 Stephen R. Whiteley ****************************************************************************/ #ifndef SWDEFS_H #define SWDEFS_H #include "device.h" // // structures used to describe switches // #define FABS fabs #define REFTEMP wrsREFTEMP #define CHARGE wrsCHARGE #define CONSTCtoK wrsCONSTCtoK #define CONSTboltz wrsCONSTboltz #define CONSTvt0 wrsCONSTvt0 #define CONSTKoverQ wrsCONSTKoverQ #define CONSTroot2 wrsCONSTroot2 #define CONSTe wrsCONSTe namespace SW { struct SWdev : public IFdevice { SWdev(); sGENmodel *newModl(); sGENinstance *newInst(); int destroy(sGENmodel**); int delInst(sGENmodel*, IFuid, sGENinstance*); int delModl(sGENmodel**, IFuid, sGENmodel*); void parse(int, sCKT*, sLine*); // int loadTest(sGENinstance*, sCKT*); int load(sGENinstance*, sCKT*); int setup(sGENmodel*, sCKT*, int*); // int unsetup(sGENmodel*, sCKT*); int resetup(sGENmodel*, sCKT*); // int temperature(sGENmodel*, sCKT*); // int getic(sGENmodel*, sCKT*); // int accept(sCKT*, sGENmodel*); // int trunc(sGENmodel*, sCKT*, double*); // int convTest(sGENmodel*, sCKT*); int setInst(int, IFdata*, sGENinstance*); int setModl(int, IFdata*, sGENmodel*); int askInst(const sCKT*, const sGENinstance*, int, IFdata*); int askModl(const sGENmodel*, int, IFdata*); // int findBranch(sCKT*, sGENmodel*, IFuid); int acLoad(sGENmodel*, sCKT*); int pzLoad(sGENmodel*, sCKT*, IFcomplex*); // int disto(int, sGENmodel*, sCKT*); int noise(int, int, sGENmodel*, sCKT*, sNdata*, double*); }; struct sSWinstance : public sGENinstance { sSWinstance() { memset(this, 0, sizeof(sSWinstance)); GENnumNodes = 2; } sSWinstance *next() { return (static_cast<sSWinstance*>(GENnextInstance)); } int SWposNode; // number of positive node of switch int SWnegNode; // number of negative node of switch int SWposCntrlNode; // positive controlling node of switch int SWnegCntrlNode; // negative controlling node of switch int SWcontBranch; // number of branch of controlling current IFuid SWcontName; // name of controlling source double *SWposPosptr; // pointer to sparse matrix diagonal at // (positive,positive) for switch conductance double *SWnegPosptr; // pointer to sparse matrix offdiagonal at // (neagtive,positive) for switch conductance double *SWposNegptr; // pointer to sparse matrix offdiagonal at // (positive,neagtive) for switch conductance double *SWnegNegptr; // pointer to sparse matrix diagonal at // (neagtive,neagtive) for switch conductance double SWcond; // conductance of the switch now unsigned SWzero_stateGiven : 1; // flag to indicate initial state #ifndef NONOISE double SWnVar[NSTATVARS]; #else double *SWnVar; #endif }; // default on conductance = 1 mho #define SW_ON_CONDUCTANCE 1.0 // default off conductance #define SW_OFF_CONDUCTANCE ckt->CKTcurTask->TSKgmin #define SW_NUM_STATES 1 struct sSWmodel : public sGENmodel { sSWmodel() { memset(this, 0, sizeof(sSWmodel)); } sSWmodel *next() { return (static_cast<sSWmodel*>(GENnextModel)); } sSWinstance *inst() { return (static_cast<sSWinstance*>(GENinstances)); } double SWonResistance; // switch "on" resistance double SWoffResistance; // switch "off" resistance double SWvThreshold; // switching threshold voltage double SWvHysteresis; // switching hysteresis voltage double SWiThreshold; // switching threshold current double SWiHysteresis; // switching hysteresis current double SWonConduct; // switch "on" conductance double SWoffConduct; // switch "off" conductance // flags to indicate... unsigned SWonGiven : 1; // on-resistance was given unsigned SWoffGiven : 1; // off-resistance was given unsigned SWvThreshGiven : 1; // threshold volt was given unsigned SWvHystGiven : 1; // hysteresis volt was given unsigned SWiThreshGiven : 1; // threshold current was given unsigned SWiHystGiven : 1; // hysteresis current was given }; } // namespace SW using namespace SW; // device parameters // DO NOT CHANGE THIS without updating aski/seti tables! enum { SW_IC_ON = 1, SW_IC_OFF, SW_IC, SW_CONTROL, SW_VOLTAGE, SW_CURRENT, SW_POWER, SW_POS_NODE, SW_NEG_NODE, SW_POS_CONT_NODE, SW_NEG_CONT_NODE }; // model parameters enum { SW_MOD_SW = 1000, SW_MOD_CSW, SW_MOD_RON, SW_MOD_ROFF, SW_MOD_VTH, SW_MOD_VHYS, SW_MOD_ITH, SW_MOD_IHYS, SW_MOD_GON, SW_MOD_GOFF }; #endif // SWDEFS_H
[ "stevew@wrcad.com" ]
stevew@wrcad.com
a8bec98963a19b752887b4a3d53d56b1414e456c
12c1f30d1a04698c0541b661f3e6d311655ef618
/C++ program/class templates.cpp
a257dd97512d9ce77e78e6b6ea68ad4994682927
[]
no_license
Minitechhacker/C-
9a742006a321236710ac98b651cd163e6ea4373b
06f318ab377eb24a2302e71bf482f5804233fadf
refs/heads/master
2020-09-29T21:59:54.970470
2020-01-18T06:03:00
2020-01-18T06:03:00
227,131,675
0
0
null
null
null
null
UTF-8
C++
false
false
346
cpp
#include <iostream> using namespace std; template<class T> class A { public: T num1 = 5; T num2 = 6; void add() { std::cout << "Addition of num1 and num2 : " << num1+num2<<std::endl; } }; int main() { A<int> d; d.add(); return 0; }
[ "noreply@github.com" ]
noreply@github.com
0940667cb120aab4e23c471053e5c6516c8dddd8
dedb48451f2d7dd70c6856cf18e0f99d7c8d8b16
/WinapiPainter/View/EllipseDrawer.cpp
ff413781193cf13c5abf3d785d295c7bbd8f6b0f
[]
no_license
andyklimenko/winapi-painter
aca25fd745a59125254938960c4675fe5b299680
29efee530ae63198df5fb373a78c2b604c46faf8
refs/heads/master
2021-01-09T05:24:43.823826
2017-02-03T22:55:37
2017-02-03T22:55:37
80,760,761
0
0
null
null
null
null
UTF-8
C++
false
false
237
cpp
#include "stdafx.h" #include "EllipseDrawer.h" EllipseDrawer::EllipseDrawer() { } EllipseDrawer::~EllipseDrawer() { } void EllipseDrawer::Draw(HDC hdc, const POINT from, const POINT to) { Ellipse(hdc, from.x, from.y, to.x, to.y); }
[ "andrey.klimenko@gmail.com" ]
andrey.klimenko@gmail.com
c52ff3068406885bffa009391e42a65a434b73f3
01af73b1d9817fbf708dcb19ffc21898bc41f0cc
/STL ASSIGNMENT/STL_ASS1_QUE8/src/main.cpp
6efb4f546d9e5eb41b448542b5e3058c7aa33b5d
[]
no_license
SanketChidrewar/Coding-Challenges
140bd1122a184979a1c6583ac67e80fbfa8fc056
01e1af3b248e582a174a0f1a2f120cafdcddc0e6
refs/heads/master
2021-01-05T22:49:45.351940
2020-05-01T05:55:45
2020-05-01T05:55:45
241,155,189
0
3
null
null
null
null
UTF-8
C++
false
false
2,988
cpp
/* * main.cpp * * Created on: 15-Apr-2020 * Author: sunbeam */ //8. Create a student class storing roll number, name (use char[] not string) and marks. Write a menu //driven File IO program using C++ library classes to add student, display all students, find student //by roll number and edit student. #include<iostream> #include "Student.h" #include<cstring> #include<vector> #include<fstream> using namespace std; typedef enum{EXIT,ADD_STUDENT,FIND_STUDENT,DISPLAY_ALL_STUDENT,EDIT_STUDENT}menuop; void load_student_data(vector<Student>&st) { ifstream is; Student obj; is.open("src/student.txt",ios::in); if(!is) { cout << "failed to open file" << endl; } else { while (!is.eof()) { is.read((char*)&obj,sizeof(obj)); st.push_back(obj); } } vector<Student>::iterator it = st.end(); st.erase(it); } int menuChoice() { int ch; cout<<"ENTER \n0. EXIT \n1. ADD_STUDENT \n2. FIND_STUDENT \n3. DISPLAY_ALL_STUDENT \n4. EDIT_STUDENT\nENTER OPTION :"; cin>>ch; return ch; } void add_student(vector<Student>&st) { int rn; char name[50]; int marks; cout<<" ENTER roll no :"; cin>>rn; cout<<" ENTER name :"; cin>>name; cout<<" ENTER marks :"; cin>>marks; //Student st_obj(rn,name,marks); st.push_back(Student(rn,name,marks)); //cout<<"SIZE :"<<st.size()<<endl; } void find_student(vector<Student>& st) { int rn,flag=0; cout<<"Enter roll no of student :"; cin>>rn; for(unsigned int i=0;i<st.size();i++) { if(st[i].getRollNumber() == rn) { st[i].display_student(); flag =1; } } if(flag==0) { cout<<"===DATA NOT FOUND==="<<endl; } } void display_all_student(vector<Student>& st) { cout<<endl<<"===ALL STUDENT DATA==="<<endl; for(unsigned int i=0;i<st.size();i++) { st[i].display_student(); } cout<<endl; } void edit_student(vector<Student>& st) { int rn,flag=0; char name[50]; int marks; cout<<"Enter roll no of student :"; cin>>rn; for(unsigned int i=0;i<st.size();i++) { if(st[i].getRollNumber() == rn) { cout<<"ENTER NAME TO BE UPDATED :"; cin>>name; cout<<"ENTER MARKS TO BE UPDATED :"; cin>>marks; st[i].setName(name); st[i].setMarks(marks); cout<<endl<<"===DATA SUCCESSFULLY UPDATED==="<<endl<<endl; flag =1; } } if(flag==0) { cout<<"===DATA NOT FOUND==="<<endl; } } void upload_student_data(vector<Student>&st) { ofstream os; os.open("src/student.txt",ios::trunc); if(!os) { cout << "failed to open file" << endl; } else { for(unsigned int i=0;i<st.size();i++) { os.write((const char*)&st[i],sizeof(st[i])); } } } int main() { int choice; vector<Student> st; load_student_data(st); while((choice = menuChoice())!=EXIT) { switch(choice) { case ADD_STUDENT: add_student(st); break; case FIND_STUDENT: find_student(st); break; case DISPLAY_ALL_STUDENT: display_all_student(st); break; case EDIT_STUDENT: edit_student(st); break; } } upload_student_data(st); return 0; }
[ "sanketchidrewar11@gmail.com" ]
sanketchidrewar11@gmail.com
d6e8537a8309fd0e34ac37d61f58d110839378c8
3019cc02f3738fafb71dc53e1764401501ea8475
/dev/sample/so_5/coop_notification/main.cpp
24d06cc4be2644600c088a92276a019ea0f2fe78
[ "BSD-3-Clause", "BSL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
eao197/so-5-5
a341ac895298e08479f01ac42be15b14ad11af6b
fa0c31c84d2637dce04e13a155040150d505fbbd
refs/heads/master
2021-06-11T03:38:26.141983
2020-07-04T08:39:56
2020-07-04T08:39:56
32,193,560
78
21
NOASSERTION
2018-10-15T05:38:09
2015-03-14T03:11:06
C++
UTF-8
C++
false
false
2,488
cpp
/* * A sample for the exception handler and cooperation notifications. */ #include <iostream> #include <stdexcept> // Main SObjectizer header file. #include <so_5/all.hpp> // A class of an agent which will throw an exception. class a_child_t : public so_5::agent_t { public : a_child_t( context_t ctx, bool should_throw ) : so_5::agent_t{ ctx } , m_should_throw{ should_throw } {} virtual void so_evt_start() override { if( m_should_throw ) throw std::runtime_error( "A child agent failure!" ); } private : const bool m_should_throw; }; // A class of parent agent. class a_parent_t : public so_5::agent_t { public : a_parent_t( context_t ctx ) : so_5::agent_t{ ctx } , m_counter{ 0 } , m_max_counter{ 3 } {} virtual void so_define_agent() override { so_default_state() .event( &a_parent_t::evt_child_created ) .event( &a_parent_t::evt_child_destroyed ); } void so_evt_start() override { register_child_coop(); } private : int m_counter; const int m_max_counter; void evt_child_created( const so_5::msg_coop_registered & evt ) { std::cout << "coop_reg: " << evt.m_coop_name << std::endl; if( m_counter >= m_max_counter ) so_deregister_agent_coop_normally(); // Otherwise should wait for cooperation shutdown. } void evt_child_destroyed( const so_5::msg_coop_deregistered & evt ) { std::cout << "coop_dereg: " << evt.m_coop_name << ", reason: " << evt.m_reason.reason() << std::endl; ++m_counter; register_child_coop(); } void register_child_coop() { using namespace so_5; introduce_child_coop( *this, "child", [this]( coop_t & coop ) { coop.add_reg_notificator( make_coop_reg_notificator( so_direct_mbox() ) ); coop.add_dereg_notificator( make_coop_dereg_notificator( so_direct_mbox() ) ); coop.set_exception_reaction( deregister_coop_on_exception ); coop.make_agent< a_child_t >( m_counter < m_max_counter ); std::cout << "registering coop: " << coop.query_coop_name() << std::endl; } ); } }; int main() { try { so_5::launch( // The SObjectizer Environment initialization. []( so_5::environment_t & env ) { // Creating and registering a cooperation. env.register_agent_as_coop( "parent", env.make_agent< a_parent_t >() ); } ); } catch( const std::exception & ex ) { std::cerr << "Error: " << ex.what() << std::endl; return 1; } return 0; }
[ "eao197@1d1731ae-3f85-447d-88f8-c72b288064d1" ]
eao197@1d1731ae-3f85-447d-88f8-c72b288064d1
0c8116e45e9e3091d4f6df6a95e5eaf5b3aea94e
6bf4b3eb3a4b94ec8a570bbbe030d4e63ff5bcaf
/visualstudioprojects/testdatabase/testdatabase/CoverageDatabase.h
06e64c4d2df3094ba22d57217ecd70d319277282
[]
no_license
ewang-git/dev
5f9e6c9e39a32f0fafb512e10114e5860a596631
e421a80def77316dbc6886fadc7d32e3dfb3614e
refs/heads/master
2021-01-13T14:56:14.506764
2016-12-22T00:23:52
2016-12-22T00:23:52
76,669,359
0
0
null
null
null
null
UTF-8
C++
false
false
894
h
#include <stdio.h> #include <iostream> #include <occi.h> #include "common.h" using namespace std; using namespace oracle::occi; /* Interface to coverage database * * * Modified : * * ewang 04/16/2008 creation * */ //#include <iostream> //#include <string> #include <occi.h> using namespace oracle::occi ; using namespace std ; class CoverageDatabase { string user; string pass; string conn_string; string picktest_rtn_table ; string picktest_hit_table ; string picktest_tst_table ; string picktestTablePrefix ; string labelName ; Environment *env; Connection *conn; int get4ByteInt(unsigned char *buffer, int order); public: CoverageDatabase(); int SetPicktestTables(string label) ; bool getHitMatrixByRtn(std::vector<std::string> changed_routines); bool getHitMatrixByTst(std::vector<std::string> test_names); bool getHitMatrix(void); };
[ "eric.wang@oracle.com" ]
eric.wang@oracle.com
e599deb09797c6338b1b9e208ecfdc2fa1a8c08d
f8f51545395f4abdb5f4ed709c9dccd5c764e5ec
/3D-Lecture-master/Game Project/Graphic/Renderer.h
d4ca7523ce0f838744d24f26d432d5f91e988537
[ "MIT" ]
permissive
kami36/Study
2110553e346c6f6f1922f7e4675ecc483789eb47
808e66976c1572f46d6d73d65c84313f9cbea28f
refs/heads/master
2016-09-06T05:36:22.316724
2014-06-26T07:53:06
2014-06-26T07:53:06
19,969,140
1
0
null
null
null
null
UHC
C++
false
false
507
h
#pragma once namespace graphic { class cRenderer : public common::cSingleton<cRenderer> { public: cRenderer(); virtual ~cRenderer(); bool CreateDirectX(HWND hWnd, const int width, const int height); LPDIRECT3DDEVICE9 GetDevice() { return m_DxDevice; } protected: private: LPDIRECT3DDEVICE9 m_DxDevice; }; // 렌더러 초기화. bool InitRenderer(HWND hWnd, const int width, const int height); void ReleaseRenderer(); cRenderer* GetRenderer(); LPDIRECT3DDEVICE9 GetDevice(); }
[ "kami36@naver.com" ]
kami36@naver.com
d21e76e02a201a99bf39918b75dcfa40dc33a85b
fd3c21cd620334a93a5c0768aad93db6595515e3
/shibari_console/shibari_console.cpp
29cd017ae0feea0f764cf62c76cc1b410fd07231
[ "BSD-3-Clause" ]
permissive
Waterman178/shibari
d4b1f4bf0970ee68242b3d2885a434cd923398b6
5b0bc7b7b886fe0c9b19f5e4d97c7e969edacb56
refs/heads/master
2020-09-23T13:03:36.713209
2019-06-07T21:04:20
2019-06-07T21:04:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,253
cpp
#include "stdafx.h" int main(int argc, const char **argv){ shibari shi; std::vector<shibari_module *> modules; std::string out_name = "shibari_result.exe"; if (argc < 2) { printf("need more parameters !\n"); system("PAUSE"); return 0; } for (int arg_idx = 1; arg_idx < argc; arg_idx++) { //module= if (strlen(argv[arg_idx]) > 7 && !strncmp(argv[arg_idx],"module=",7)) { pe_image image = pe_image(std::string(argv[arg_idx]+7)); if (image.get_image_status() == pe_image_status::pe_image_status_ok) { modules.push_back(new shibari_module(image)); continue; } printf("[%s] image error!\n", std::string(argv[arg_idx] + 7).c_str()); system("PAUSE"); return 0; } //extname= if (strlen(argv[arg_idx]) > 8 && !strncmp(argv[arg_idx], "extname=", 8)) { if (modules.size()) { modules[modules.size() - 1]->get_module_exports().add_name(std::string(argv[arg_idx] + 8)); continue; } printf("[%s] extname error!\n", std::string(argv[arg_idx] + 8).c_str()); system("PAUSE"); return 0; } //outname= if (strlen(argv[arg_idx]) > 8 && !strncmp(argv[arg_idx], "outname=", 8)) { out_name = std::string(argv[arg_idx] + 8); } } shi.set_main_module(modules[0]); for (unsigned int module_idx = 1; module_idx < modules.size(); module_idx++) { shi.add_extended_module(modules[module_idx]); } std::vector<uint8_t> out_exe; unsigned int exec_start_time = clock(); switch (shi.exec_shibari(PE_IMAGE_BUILD_ALL_EXTENDED_SECTIONS, out_exe)) { case shibari_linker_ok: { printf("finished in %f\n",(clock() - exec_start_time)/1000.f); printf("result code: shibari_linker_ok\n"); FILE* hTargetFile; fopen_s(&hTargetFile,out_name.c_str(), "wb"); if (hTargetFile) { fwrite(out_exe.data(), out_exe.size(), 1, hTargetFile); fclose(hTargetFile); } break; } case shibari_linker_error_bad_input: { printf("result code: shibari_linker_error_bad_input\n"); break; } case shibari_linker_error_export_linking: { printf("result code: shibari_linker_error_export_linking\n"); break; } case shibari_linker_error_import_linking: { printf("result code: shibari_linker_error_import_linking\n"); break; } case shibari_linker_error_loadconfig_linking: { printf("result code: shibari_linker_error_loadconfig_linking\n"); break; } case shibari_linker_error_relocation_linking: { printf("result code: shibari_linker_error_relocation_linking\n"); break; } case shibari_linker_error_exceptions_linking: { printf("result code: shibari_linker_error_exceptions_linking\n"); break; } case shibari_linker_error_tls_linking: { printf("result code: shibari_linker_error_tls_linking\n"); break; } default: break; } system("PAUSE"); return 0; }
[ "jnastarot@yandex.ru" ]
jnastarot@yandex.ru
12de69e1a199c2b1a43a31b37be98fa17f281f8e
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/3.LB+ctrl+ctrlisb+po.c.cbmc.cpp
843a3e9c46ec5fe003c008c797c061bbfd3549c3
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
43,085
cpp
// 0:vars:3 // 3:atom_0_X0_1:1 // 4:atom_1_X0_1:1 // 5:atom_2_X0_1:1 // 6:thr0:1 // 7:thr1:1 // 8:thr2:1 #define ADDRSIZE 9 #define NPROC 4 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; buff(0,7) = 0; pw(0,7) = 0; cr(0,7) = 0; iw(0,7) = 0; cw(0,7) = 0; cx(0,7) = 0; is(0,7) = 0; cs(0,7) = 0; crmax(0,7) = 0; buff(0,8) = 0; pw(0,8) = 0; cr(0,8) = 0; iw(0,8) = 0; cw(0,8) = 0; cx(0,8) = 0; is(0,8) = 0; cs(0,8) = 0; crmax(0,8) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; buff(1,7) = 0; pw(1,7) = 0; cr(1,7) = 0; iw(1,7) = 0; cw(1,7) = 0; cx(1,7) = 0; is(1,7) = 0; cs(1,7) = 0; crmax(1,7) = 0; buff(1,8) = 0; pw(1,8) = 0; cr(1,8) = 0; iw(1,8) = 0; cw(1,8) = 0; cx(1,8) = 0; is(1,8) = 0; cs(1,8) = 0; crmax(1,8) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; buff(2,7) = 0; pw(2,7) = 0; cr(2,7) = 0; iw(2,7) = 0; cw(2,7) = 0; cx(2,7) = 0; is(2,7) = 0; cs(2,7) = 0; crmax(2,7) = 0; buff(2,8) = 0; pw(2,8) = 0; cr(2,8) = 0; iw(2,8) = 0; cw(2,8) = 0; cx(2,8) = 0; is(2,8) = 0; cs(2,8) = 0; crmax(2,8) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); buff(3,0) = 0; pw(3,0) = 0; cr(3,0) = 0; iw(3,0) = 0; cw(3,0) = 0; cx(3,0) = 0; is(3,0) = 0; cs(3,0) = 0; crmax(3,0) = 0; buff(3,1) = 0; pw(3,1) = 0; cr(3,1) = 0; iw(3,1) = 0; cw(3,1) = 0; cx(3,1) = 0; is(3,1) = 0; cs(3,1) = 0; crmax(3,1) = 0; buff(3,2) = 0; pw(3,2) = 0; cr(3,2) = 0; iw(3,2) = 0; cw(3,2) = 0; cx(3,2) = 0; is(3,2) = 0; cs(3,2) = 0; crmax(3,2) = 0; buff(3,3) = 0; pw(3,3) = 0; cr(3,3) = 0; iw(3,3) = 0; cw(3,3) = 0; cx(3,3) = 0; is(3,3) = 0; cs(3,3) = 0; crmax(3,3) = 0; buff(3,4) = 0; pw(3,4) = 0; cr(3,4) = 0; iw(3,4) = 0; cw(3,4) = 0; cx(3,4) = 0; is(3,4) = 0; cs(3,4) = 0; crmax(3,4) = 0; buff(3,5) = 0; pw(3,5) = 0; cr(3,5) = 0; iw(3,5) = 0; cw(3,5) = 0; cx(3,5) = 0; is(3,5) = 0; cs(3,5) = 0; crmax(3,5) = 0; buff(3,6) = 0; pw(3,6) = 0; cr(3,6) = 0; iw(3,6) = 0; cw(3,6) = 0; cx(3,6) = 0; is(3,6) = 0; cs(3,6) = 0; crmax(3,6) = 0; buff(3,7) = 0; pw(3,7) = 0; cr(3,7) = 0; iw(3,7) = 0; cw(3,7) = 0; cx(3,7) = 0; is(3,7) = 0; cs(3,7) = 0; crmax(3,7) = 0; buff(3,8) = 0; pw(3,8) = 0; cr(3,8) = 0; iw(3,8) = 0; cw(3,8) = 0; cx(3,8) = 0; is(3,8) = 0; cs(3,8) = 0; crmax(3,8) = 0; cl[3] = 0; cdy[3] = 0; cds[3] = 0; cdl[3] = 0; cisb[3] = 0; caddr[3] = 0; cctrl[3] = 0; cstart[3] = get_rng(0,NCONTEXT-1); creturn[3] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; mem(7+0,0) = 0; mem(8+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; co(7,0) = 0; delta(7,0) = -1; co(8,0) = 0; delta(8,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !37, metadata !DIExpression()), !dbg !53 // br label %label_1, !dbg !54 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !51), !dbg !55 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !40, metadata !DIExpression()), !dbg !56 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !57 // LD: Guess old_cr = cr(1,0); cr(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN LDCOM // Check ASSUME(active[cr(1,0)] == 1); ASSUME(cr(1,0) >= iw(1,0)); ASSUME(cr(1,0) >= 0); ASSUME(cr(1,0) >= cdy[1]); ASSUME(cr(1,0) >= cisb[1]); ASSUME(cr(1,0) >= cdl[1]); ASSUME(cr(1,0) >= cl[1]); // Update creg_r0 = cr(1,0); crmax(1,0) = max(crmax(1,0),cr(1,0)); caddr[1] = max(caddr[1],0); if(cr(1,0) < cw(1,0)) { r0 = buff(1,0); } else { if(pw(1,0) != co(0,cr(1,0))) { ASSUME(cr(1,0) >= old_cr); } pw(1,0) = co(0,cr(1,0)); r0 = mem(0,cr(1,0)); } ASSUME(creturn[1] >= cr(1,0)); // call void @llvm.dbg.value(metadata i64 %0, metadata !43, metadata !DIExpression()), !dbg !56 // %conv = trunc i64 %0 to i32, !dbg !58 // call void @llvm.dbg.value(metadata i32 %conv, metadata !38, metadata !DIExpression()), !dbg !53 // %tobool = icmp ne i32 %conv, 0, !dbg !59 // br i1 %tobool, label %if.then, label %if.else, !dbg !61 old_cctrl = cctrl[1]; cctrl[1] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[1] >= old_cctrl); ASSUME(cctrl[1] >= creg_r0); ASSUME(cctrl[1] >= 0); if((r0!=0)) { goto T1BLOCK2; } else { goto T1BLOCK3; } T1BLOCK2: // br label %lbl_LC00, !dbg !62 goto T1BLOCK4; T1BLOCK3: // br label %lbl_LC00, !dbg !63 goto T1BLOCK4; T1BLOCK4: // call void @llvm.dbg.label(metadata !52), !dbg !64 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !44, metadata !DIExpression()), !dbg !65 // call void @llvm.dbg.value(metadata i64 1, metadata !46, metadata !DIExpression()), !dbg !65 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !66 // ST: Guess iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0+1*1); cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0+1*1)] == 1); ASSUME(active[cw(1,0+1*1)] == 1); ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(iw(1,0+1*1) >= 0); ASSUME(cw(1,0+1*1) >= iw(1,0+1*1)); ASSUME(cw(1,0+1*1) >= old_cw); ASSUME(cw(1,0+1*1) >= cr(1,0+1*1)); ASSUME(cw(1,0+1*1) >= cl[1]); ASSUME(cw(1,0+1*1) >= cisb[1]); ASSUME(cw(1,0+1*1) >= cdy[1]); ASSUME(cw(1,0+1*1) >= cdl[1]); ASSUME(cw(1,0+1*1) >= cds[1]); ASSUME(cw(1,0+1*1) >= cctrl[1]); ASSUME(cw(1,0+1*1) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0+1*1) = 1; mem(0+1*1,cw(1,0+1*1)) = 1; co(0+1*1,cw(1,0+1*1))+=1; delta(0+1*1,cw(1,0+1*1)) = -1; ASSUME(creturn[1] >= cw(1,0+1*1)); // %cmp = icmp eq i32 %conv, 1, !dbg !67 // %conv1 = zext i1 %cmp to i32, !dbg !67 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !47, metadata !DIExpression()), !dbg !53 // call void @llvm.dbg.value(metadata i64* @atom_0_X0_1, metadata !48, metadata !DIExpression()), !dbg !68 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !50, metadata !DIExpression()), !dbg !68 // store atomic i64 %1, i64* @atom_0_X0_1 seq_cst, align 8, !dbg !69 // ST: Guess iw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,3); cw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,3)] == 1); ASSUME(active[cw(1,3)] == 1); ASSUME(sforbid(3,cw(1,3))== 0); ASSUME(iw(1,3) >= max(creg_r0,0)); ASSUME(iw(1,3) >= 0); ASSUME(cw(1,3) >= iw(1,3)); ASSUME(cw(1,3) >= old_cw); ASSUME(cw(1,3) >= cr(1,3)); ASSUME(cw(1,3) >= cl[1]); ASSUME(cw(1,3) >= cisb[1]); ASSUME(cw(1,3) >= cdy[1]); ASSUME(cw(1,3) >= cdl[1]); ASSUME(cw(1,3) >= cds[1]); ASSUME(cw(1,3) >= cctrl[1]); ASSUME(cw(1,3) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,3) = (r0==1); mem(3,cw(1,3)) = (r0==1); co(3,cw(1,3))+=1; delta(3,cw(1,3)) = -1; ASSUME(creturn[1] >= cw(1,3)); // ret i8* null, !dbg !70 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !73, metadata !DIExpression()), !dbg !87 // br label %label_2, !dbg !54 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !85), !dbg !89 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !75, metadata !DIExpression()), !dbg !90 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !57 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r1 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r1 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r1 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !77, metadata !DIExpression()), !dbg !90 // %conv = trunc i64 %0 to i32, !dbg !58 // call void @llvm.dbg.value(metadata i32 %conv, metadata !74, metadata !DIExpression()), !dbg !87 // %tobool = icmp ne i32 %conv, 0, !dbg !59 // br i1 %tobool, label %if.then, label %if.else, !dbg !61 old_cctrl = cctrl[2]; cctrl[2] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[2] >= old_cctrl); ASSUME(cctrl[2] >= creg_r1); ASSUME(cctrl[2] >= 0); if((r1!=0)) { goto T2BLOCK2; } else { goto T2BLOCK3; } T2BLOCK2: // br label %lbl_LC01, !dbg !62 goto T2BLOCK4; T2BLOCK3: // br label %lbl_LC01, !dbg !63 goto T2BLOCK4; T2BLOCK4: // call void @llvm.dbg.label(metadata !86), !dbg !98 // call void (...) @isb(), !dbg !65 // isb: Guess cisb[2] = get_rng(0,NCONTEXT-1); // Check ASSUME(cisb[2] >= cdy[2]); ASSUME(cisb[2] >= cctrl[2]); ASSUME(cisb[2] >= caddr[2]); ASSUME(creturn[2] >= cisb[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !78, metadata !DIExpression()), !dbg !100 // call void @llvm.dbg.value(metadata i64 1, metadata !80, metadata !DIExpression()), !dbg !100 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !67 // ST: Guess iw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0+2*1); cw(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0+2*1)] == 2); ASSUME(active[cw(2,0+2*1)] == 2); ASSUME(sforbid(0+2*1,cw(2,0+2*1))== 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(iw(2,0+2*1) >= 0); ASSUME(cw(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cw(2,0+2*1) >= old_cw); ASSUME(cw(2,0+2*1) >= cr(2,0+2*1)); ASSUME(cw(2,0+2*1) >= cl[2]); ASSUME(cw(2,0+2*1) >= cisb[2]); ASSUME(cw(2,0+2*1) >= cdy[2]); ASSUME(cw(2,0+2*1) >= cdl[2]); ASSUME(cw(2,0+2*1) >= cds[2]); ASSUME(cw(2,0+2*1) >= cctrl[2]); ASSUME(cw(2,0+2*1) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,0+2*1) = 1; mem(0+2*1,cw(2,0+2*1)) = 1; co(0+2*1,cw(2,0+2*1))+=1; delta(0+2*1,cw(2,0+2*1)) = -1; ASSUME(creturn[2] >= cw(2,0+2*1)); // %cmp = icmp eq i32 %conv, 1, !dbg !68 // %conv1 = zext i1 %cmp to i32, !dbg !68 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !81, metadata !DIExpression()), !dbg !87 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !82, metadata !DIExpression()), !dbg !103 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !84, metadata !DIExpression()), !dbg !103 // store atomic i64 %1, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !70 // ST: Guess iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,4); cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,4)] == 2); ASSUME(active[cw(2,4)] == 2); ASSUME(sforbid(4,cw(2,4))== 0); ASSUME(iw(2,4) >= max(creg_r1,0)); ASSUME(iw(2,4) >= 0); ASSUME(cw(2,4) >= iw(2,4)); ASSUME(cw(2,4) >= old_cw); ASSUME(cw(2,4) >= cr(2,4)); ASSUME(cw(2,4) >= cl[2]); ASSUME(cw(2,4) >= cisb[2]); ASSUME(cw(2,4) >= cdy[2]); ASSUME(cw(2,4) >= cdl[2]); ASSUME(cw(2,4) >= cds[2]); ASSUME(cw(2,4) >= cctrl[2]); ASSUME(cw(2,4) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,4) = (r1==1); mem(4,cw(2,4)) = (r1==1); co(4,cw(2,4))+=1; delta(4,cw(2,4)) = -1; ASSUME(creturn[2] >= cw(2,4)); // ret i8* null, !dbg !71 ret_thread_2 = (- 1); // Dumping thread 3 int ret_thread_3 = 0; cdy[3] = get_rng(0,NCONTEXT-1); ASSUME(cdy[3] >= cstart[3]); T3BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !108, metadata !DIExpression()), !dbg !121 // br label %label_3, !dbg !53 goto T3BLOCK1; T3BLOCK1: // call void @llvm.dbg.label(metadata !120), !dbg !123 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !110, metadata !DIExpression()), !dbg !124 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !56 // LD: Guess old_cr = cr(3,0+2*1); cr(3,0+2*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM // Check ASSUME(active[cr(3,0+2*1)] == 3); ASSUME(cr(3,0+2*1) >= iw(3,0+2*1)); ASSUME(cr(3,0+2*1) >= 0); ASSUME(cr(3,0+2*1) >= cdy[3]); ASSUME(cr(3,0+2*1) >= cisb[3]); ASSUME(cr(3,0+2*1) >= cdl[3]); ASSUME(cr(3,0+2*1) >= cl[3]); // Update creg_r2 = cr(3,0+2*1); crmax(3,0+2*1) = max(crmax(3,0+2*1),cr(3,0+2*1)); caddr[3] = max(caddr[3],0); if(cr(3,0+2*1) < cw(3,0+2*1)) { r2 = buff(3,0+2*1); } else { if(pw(3,0+2*1) != co(0+2*1,cr(3,0+2*1))) { ASSUME(cr(3,0+2*1) >= old_cr); } pw(3,0+2*1) = co(0+2*1,cr(3,0+2*1)); r2 = mem(0+2*1,cr(3,0+2*1)); } ASSUME(creturn[3] >= cr(3,0+2*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !112, metadata !DIExpression()), !dbg !124 // %conv = trunc i64 %0 to i32, !dbg !57 // call void @llvm.dbg.value(metadata i32 %conv, metadata !109, metadata !DIExpression()), !dbg !121 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !113, metadata !DIExpression()), !dbg !127 // call void @llvm.dbg.value(metadata i64 1, metadata !115, metadata !DIExpression()), !dbg !127 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !59 // ST: Guess iw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,0); cw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,0)] == 3); ASSUME(active[cw(3,0)] == 3); ASSUME(sforbid(0,cw(3,0))== 0); ASSUME(iw(3,0) >= 0); ASSUME(iw(3,0) >= 0); ASSUME(cw(3,0) >= iw(3,0)); ASSUME(cw(3,0) >= old_cw); ASSUME(cw(3,0) >= cr(3,0)); ASSUME(cw(3,0) >= cl[3]); ASSUME(cw(3,0) >= cisb[3]); ASSUME(cw(3,0) >= cdy[3]); ASSUME(cw(3,0) >= cdl[3]); ASSUME(cw(3,0) >= cds[3]); ASSUME(cw(3,0) >= cctrl[3]); ASSUME(cw(3,0) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,0) = 1; mem(0,cw(3,0)) = 1; co(0,cw(3,0))+=1; delta(0,cw(3,0)) = -1; ASSUME(creturn[3] >= cw(3,0)); // %cmp = icmp eq i32 %conv, 1, !dbg !60 // %conv1 = zext i1 %cmp to i32, !dbg !60 // call void @llvm.dbg.value(metadata i32 %conv1, metadata !116, metadata !DIExpression()), !dbg !121 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !117, metadata !DIExpression()), !dbg !130 // %1 = zext i32 %conv1 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !119, metadata !DIExpression()), !dbg !130 // store atomic i64 %1, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !62 // ST: Guess iw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW old_cw = cw(3,5); cw(3,5) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM // Check ASSUME(active[iw(3,5)] == 3); ASSUME(active[cw(3,5)] == 3); ASSUME(sforbid(5,cw(3,5))== 0); ASSUME(iw(3,5) >= max(creg_r2,0)); ASSUME(iw(3,5) >= 0); ASSUME(cw(3,5) >= iw(3,5)); ASSUME(cw(3,5) >= old_cw); ASSUME(cw(3,5) >= cr(3,5)); ASSUME(cw(3,5) >= cl[3]); ASSUME(cw(3,5) >= cisb[3]); ASSUME(cw(3,5) >= cdy[3]); ASSUME(cw(3,5) >= cdl[3]); ASSUME(cw(3,5) >= cds[3]); ASSUME(cw(3,5) >= cctrl[3]); ASSUME(cw(3,5) >= caddr[3]); // Update caddr[3] = max(caddr[3],0); buff(3,5) = (r2==1); mem(5,cw(3,5)) = (r2==1); co(5,cw(3,5))+=1; delta(5,cw(3,5)) = -1; ASSUME(creturn[3] >= cw(3,5)); // ret i8* null, !dbg !63 ret_thread_3 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // %thr2 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !140, metadata !DIExpression()), !dbg !180 // call void @llvm.dbg.value(metadata i8** %argv, metadata !141, metadata !DIExpression()), !dbg !180 // %0 = bitcast i64* %thr0 to i8*, !dbg !83 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !83 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !142, metadata !DIExpression()), !dbg !182 // %1 = bitcast i64* %thr1 to i8*, !dbg !85 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !85 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !146, metadata !DIExpression()), !dbg !184 // %2 = bitcast i64* %thr2 to i8*, !dbg !87 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !87 // call void @llvm.dbg.declare(metadata i64* %thr2, metadata !147, metadata !DIExpression()), !dbg !186 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !148, metadata !DIExpression()), !dbg !187 // call void @llvm.dbg.value(metadata i64 0, metadata !150, metadata !DIExpression()), !dbg !187 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !90 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !151, metadata !DIExpression()), !dbg !189 // call void @llvm.dbg.value(metadata i64 0, metadata !153, metadata !DIExpression()), !dbg !189 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !92 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !154, metadata !DIExpression()), !dbg !191 // call void @llvm.dbg.value(metadata i64 0, metadata !156, metadata !DIExpression()), !dbg !191 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !94 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_0_X0_1, metadata !157, metadata !DIExpression()), !dbg !193 // call void @llvm.dbg.value(metadata i64 0, metadata !159, metadata !DIExpression()), !dbg !193 // store atomic i64 0, i64* @atom_0_X0_1 monotonic, align 8, !dbg !96 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !160, metadata !DIExpression()), !dbg !195 // call void @llvm.dbg.value(metadata i64 0, metadata !162, metadata !DIExpression()), !dbg !195 // store atomic i64 0, i64* @atom_1_X0_1 monotonic, align 8, !dbg !98 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !163, metadata !DIExpression()), !dbg !197 // call void @llvm.dbg.value(metadata i64 0, metadata !165, metadata !DIExpression()), !dbg !197 // store atomic i64 0, i64* @atom_2_X0_1 monotonic, align 8, !dbg !100 // ST: Guess iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,5); cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,5)] == 0); ASSUME(active[cw(0,5)] == 0); ASSUME(sforbid(5,cw(0,5))== 0); ASSUME(iw(0,5) >= 0); ASSUME(iw(0,5) >= 0); ASSUME(cw(0,5) >= iw(0,5)); ASSUME(cw(0,5) >= old_cw); ASSUME(cw(0,5) >= cr(0,5)); ASSUME(cw(0,5) >= cl[0]); ASSUME(cw(0,5) >= cisb[0]); ASSUME(cw(0,5) >= cdy[0]); ASSUME(cw(0,5) >= cdl[0]); ASSUME(cw(0,5) >= cds[0]); ASSUME(cw(0,5) >= cctrl[0]); ASSUME(cw(0,5) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,5) = 0; mem(5,cw(0,5)) = 0; co(5,cw(0,5))+=1; delta(5,cw(0,5)) = -1; ASSUME(creturn[0] >= cw(0,5)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !101 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call11 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !102 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %call12 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !103 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[3] >= cdy[0]); // %3 = load i64, i64* %thr0, align 8, !dbg !104, !tbaa !105 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r4 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r4 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r4 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call13 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !109 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %4 = load i64, i64* %thr1, align 8, !dbg !110, !tbaa !105 // LD: Guess old_cr = cr(0,7); cr(0,7) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,7)] == 0); ASSUME(cr(0,7) >= iw(0,7)); ASSUME(cr(0,7) >= 0); ASSUME(cr(0,7) >= cdy[0]); ASSUME(cr(0,7) >= cisb[0]); ASSUME(cr(0,7) >= cdl[0]); ASSUME(cr(0,7) >= cl[0]); // Update creg_r5 = cr(0,7); crmax(0,7) = max(crmax(0,7),cr(0,7)); caddr[0] = max(caddr[0],0); if(cr(0,7) < cw(0,7)) { r5 = buff(0,7); } else { if(pw(0,7) != co(7,cr(0,7))) { ASSUME(cr(0,7) >= old_cr); } pw(0,7) = co(7,cr(0,7)); r5 = mem(7,cr(0,7)); } ASSUME(creturn[0] >= cr(0,7)); // %call14 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !111 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // %5 = load i64, i64* %thr2, align 8, !dbg !112, !tbaa !105 // LD: Guess old_cr = cr(0,8); cr(0,8) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,8)] == 0); ASSUME(cr(0,8) >= iw(0,8)); ASSUME(cr(0,8) >= 0); ASSUME(cr(0,8) >= cdy[0]); ASSUME(cr(0,8) >= cisb[0]); ASSUME(cr(0,8) >= cdl[0]); ASSUME(cr(0,8) >= cl[0]); // Update creg_r6 = cr(0,8); crmax(0,8) = max(crmax(0,8),cr(0,8)); caddr[0] = max(caddr[0],0); if(cr(0,8) < cw(0,8)) { r6 = buff(0,8); } else { if(pw(0,8) != co(8,cr(0,8))) { ASSUME(cr(0,8) >= old_cr); } pw(0,8) = co(8,cr(0,8)); r6 = mem(8,cr(0,8)); } ASSUME(creturn[0] >= cr(0,8)); // %call15 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !113 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cw(0,7+0)); ASSUME(cdy[0] >= cw(0,8+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(cdy[0] >= cr(0,7+0)); ASSUME(cdy[0] >= cr(0,8+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[3]); // call void @llvm.dbg.value(metadata i64* @atom_0_X0_1, metadata !167, metadata !DIExpression()), !dbg !212 // %6 = load atomic i64, i64* @atom_0_X0_1 seq_cst, align 8, !dbg !115 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r7 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r7 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r7 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %6, metadata !169, metadata !DIExpression()), !dbg !212 // %conv = trunc i64 %6 to i32, !dbg !116 // call void @llvm.dbg.value(metadata i32 %conv, metadata !166, metadata !DIExpression()), !dbg !180 // call void @llvm.dbg.value(metadata i64* @atom_1_X0_1, metadata !171, metadata !DIExpression()), !dbg !215 // %7 = load atomic i64, i64* @atom_1_X0_1 seq_cst, align 8, !dbg !118 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r8 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r8 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r8 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i64 %7, metadata !173, metadata !DIExpression()), !dbg !215 // %conv19 = trunc i64 %7 to i32, !dbg !119 // call void @llvm.dbg.value(metadata i32 %conv19, metadata !170, metadata !DIExpression()), !dbg !180 // call void @llvm.dbg.value(metadata i64* @atom_2_X0_1, metadata !175, metadata !DIExpression()), !dbg !218 // %8 = load atomic i64, i64* @atom_2_X0_1 seq_cst, align 8, !dbg !121 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r9 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r9 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r9 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // call void @llvm.dbg.value(metadata i64 %8, metadata !177, metadata !DIExpression()), !dbg !218 // %conv23 = trunc i64 %8 to i32, !dbg !122 // call void @llvm.dbg.value(metadata i32 %conv23, metadata !174, metadata !DIExpression()), !dbg !180 // %and = and i32 %conv19, %conv23, !dbg !123 creg_r10 = max(creg_r8,creg_r9); ASSUME(active[creg_r10] == 0); r10 = r8 & r9; // call void @llvm.dbg.value(metadata i32 %and, metadata !178, metadata !DIExpression()), !dbg !180 // %and24 = and i32 %conv, %and, !dbg !124 creg_r11 = max(creg_r7,creg_r10); ASSUME(active[creg_r11] == 0); r11 = r7 & r10; // call void @llvm.dbg.value(metadata i32 %and24, metadata !179, metadata !DIExpression()), !dbg !180 // %cmp = icmp eq i32 %and24, 1, !dbg !125 // br i1 %cmp, label %if.then, label %if.end, !dbg !127 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r11); ASSUME(cctrl[0] >= 0); if((r11==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([105 x i8], [105 x i8]* @.str.1, i64 0, i64 0), i32 noundef 76, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !128 // unreachable, !dbg !128 r12 = 1; T0BLOCK2: // %9 = bitcast i64* %thr2 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !131 // %10 = bitcast i64* %thr1 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !131 // %11 = bitcast i64* %thr0 to i8*, !dbg !131 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !131 // ret i32 0, !dbg !132 ret_thread_0 = 0; ASSERT(r12== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
56ce5867a1379678a318a163dd0cd93956325ae7
b60b32163470f01c903dbde72b1142eb1a0e63fb
/hdu/1021/main.cpp
5cf11de272a57290e828d9b83eced1f2c9506c04
[]
no_license
mdyang/oj-solutions
b4830c87ae861186fd738a5da72b9283d06a87eb
e038b513e82b6dbe9cb350c687007a2324f953fc
refs/heads/master
2016-09-16T16:45:06.281518
2016-04-09T05:20:12
2016-04-09T05:20:12
15,038,618
0
0
null
null
null
null
UTF-8
C++
false
false
325
cpp
#include<stdio.h> int i=0; unsigned char num[1000000]; void init(){ num[i++]=1; num[i++]=2; for(;;){ num[i]=(num[i-1]+num[i-2])%3; if(++i >= 1000000)break; } } int main(){ init(); int t; while(scanf("%d",&t)!=EOF){ printf((num[t]==0)?"yes\n":"no\n"); } return 0; }
[ "conanholmes001@gmail.com" ]
conanholmes001@gmail.com
06d3039342b4d6bf33381a130e9c243f6ded1f2a
a270bab68aae815647904796fbd841e692266b56
/src/qt/guiutil.cpp
519b5c909218ad3ad8b21773bc1d89249747bdda
[ "MIT" ]
permissive
justinricher/greenbacks
3983571fd71e384d044310c54543fa92f24e1ad1
e7e62e417262425ca4f32631c3cc769e664be012
refs/heads/master
2021-01-18T10:04:12.342819
2014-08-29T23:09:10
2014-08-29T23:09:10
62,428,575
1
0
null
2016-07-02T01:37:26
2016-07-02T01:37:26
null
UTF-8
C++
false
false
13,375
cpp
#include "guiutil.h" #include "bitcoinaddressvalidator.h" #include "walletmodel.h" #include "bitcoinunits.h" #include "util.h" #include "init.h" #include <QString> #include <QDateTime> #include <QDoubleValidator> #include <QFont> #include <QLineEdit> #include <QUrl> #include <QTextDocument> // For Qt::escape #include <QAbstractItemView> #include <QApplication> #include <QClipboard> #include <QFileDialog> #include <QDesktopServices> #include <QThread> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #ifdef WIN32 #ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif #define _WIN32_WINNT 0x0501 #ifdef _WIN32_IE #undef _WIN32_IE #endif #define _WIN32_IE 0x0501 #define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX #endif #include "shlwapi.h" #include "shlobj.h" #include "shellapi.h" #endif namespace GUIUtil { QString dateTimeStr(const QDateTime &date) { return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); } QString dateTimeStr(qint64 nTime) { return dateTimeStr(QDateTime::fromTime_t((qint32)nTime)); } QFont bitcoinAddressFont() { QFont font("Monospace"); font.setStyleHint(QFont::TypeWriter); return font; } void setupAddressWidget(QLineEdit *widget, QWidget *parent) { widget->setMaxLength(BitcoinAddressValidator::MaxAddressLength); widget->setValidator(new BitcoinAddressValidator(parent)); widget->setFont(bitcoinAddressFont()); } void setupAmountWidget(QLineEdit *widget, QWidget *parent) { QDoubleValidator *amountValidator = new QDoubleValidator(parent); amountValidator->setDecimals(8); amountValidator->setBottom(0.0); widget->setValidator(amountValidator); widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter); } bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { // Greenbacks: check prefix if(uri.scheme() != QString("greenbacks")) return false; SendCoinsRecipient rv; rv.address = uri.path(); rv.amount = 0; QList<QPair<QString, QString> > items = uri.queryItems(); for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) { bool fShouldReturnFalse = false; if (i->first.startsWith("req-")) { i->first.remove(0, 4); fShouldReturnFalse = true; } if (i->first == "label") { rv.label = i->second; fShouldReturnFalse = false; } else if (i->first == "amount") { if(!i->second.isEmpty()) { if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount)) { return false; } } fShouldReturnFalse = false; } if (fShouldReturnFalse) return false; } if(out) { *out = rv; } return true; } bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) { // Convert greenbacks:// to greenbacks: // // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, // which will lower-case it (and thus invalidate the address). if(uri.startsWith("greenbacks://")) { uri.replace(0, 12, "greenbacks:"); } QUrl uriInstance(uri); return parseBitcoinURI(uriInstance, out); } QString HtmlEscape(const QString& str, bool fMultiLine) { QString escaped = Qt::escape(str); if(fMultiLine) { escaped = escaped.replace("\n", "<br>\n"); } return escaped; } QString HtmlEscape(const std::string& str, bool fMultiLine) { return HtmlEscape(QString::fromStdString(str), fMultiLine); } void copyEntryData(QAbstractItemView *view, int column, int role) { if(!view || !view->selectionModel()) return; QModelIndexList selection = view->selectionModel()->selectedRows(column); if(!selection.isEmpty()) { // Copy first item QApplication::clipboard()->setText(selection.at(0).data(role).toString()); } } QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedSuffixOut) { QString selectedFilter; QString myDir; if(dir.isEmpty()) // Default to user documents location { myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); } else { myDir = dir; } QString result = QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter); /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */ QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); QString selectedSuffix; if(filter_re.exactMatch(selectedFilter)) { selectedSuffix = filter_re.cap(1); } /* Add suffix if needed */ QFileInfo info(result); if(!result.isEmpty()) { if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) { /* No suffix specified, add selected suffix */ if(!result.endsWith(".")) result.append("."); result.append(selectedSuffix); } } /* Return selected suffix if asked to */ if(selectedSuffixOut) { *selectedSuffixOut = selectedSuffix; } return result; } Qt::ConnectionType blockingGUIThreadConnection() { if(QThread::currentThread() != QCoreApplication::instance()->thread()) { return Qt::BlockingQueuedConnection; } else { return Qt::DirectConnection; } } bool checkPoint(const QPoint &p, const QWidget *w) { QWidget *atW = qApp->widgetAt(w->mapToGlobal(p)); if (!atW) return false; return atW->topLevelWidget() == w; } bool isObscured(QWidget *w) { return !(checkPoint(QPoint(0, 0), w) && checkPoint(QPoint(w->width() - 1, 0), w) && checkPoint(QPoint(0, w->height() - 1), w) && checkPoint(QPoint(w->width() - 1, w->height() - 1), w) && checkPoint(QPoint(w->width() / 2, w->height() / 2), w)); } void openDebugLogfile() { boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; /* Open debug.log with the associated application */ if (boost::filesystem::exists(pathDebug)) QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(pathDebug.string()))); } ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *parent) : QObject(parent), size_threshold(size_threshold) { } bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) { if(evt->type() == QEvent::ToolTipChange) { QWidget *widget = static_cast<QWidget*>(obj); QString tooltip = widget->toolTip(); if(tooltip.size() > size_threshold && !tooltip.startsWith("<qt>") && !Qt::mightBeRichText(tooltip)) { // Prefix <qt/> to make sure Qt detects this as rich text // Escape the current message as HTML and replace \n by <br> tooltip = "<qt>" + HtmlEscape(tooltip, true) + "<qt/>"; widget->setToolTip(tooltip); return true; } } return QObject::eventFilter(obj, evt); } #ifdef WIN32 boost::filesystem::path static StartupShortcutPath() { return GetSpecialFolderPath(CSIDL_STARTUP) / "greenbacks.lnk"; } bool GetStartOnSystemStartup() { // check for Bitcoin.lnk return boost::filesystem::exists(StartupShortcutPath()); } bool SetStartOnSystemStartup(bool fAutoStart) { // If the shortcut exists already, remove it for updating boost::filesystem::remove(StartupShortcutPath()); if (fAutoStart) { CoInitialize(NULL); // Get a pointer to the IShellLink interface. IShellLink* psl = NULL; HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, reinterpret_cast<void**>(&psl)); if (SUCCEEDED(hres)) { // Get the current executable path TCHAR pszExePath[MAX_PATH]; GetModuleFileName(NULL, pszExePath, sizeof(pszExePath)); TCHAR pszArgs[5] = TEXT("-min"); // Set the path to the shortcut target psl->SetPath(pszExePath); PathRemoveFileSpec(pszExePath); psl->SetWorkingDirectory(pszExePath); psl->SetShowCmd(SW_SHOWMINNOACTIVE); psl->SetArguments(pszArgs); // Query IShellLink for the IPersistFile interface for // saving the shortcut in persistent storage. IPersistFile* ppf = NULL; hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast<void**>(&ppf)); if (SUCCEEDED(hres)) { WCHAR pwsz[MAX_PATH]; // Ensure that the string is ANSI. MultiByteToWideChar(CP_ACP, 0, StartupShortcutPath().string().c_str(), -1, pwsz, MAX_PATH); // Save the link by calling IPersistFile::Save. hres = ppf->Save(pwsz, TRUE); ppf->Release(); psl->Release(); CoUninitialize(); return true; } psl->Release(); } CoUninitialize(); return false; } return true; } #elif defined(LINUX) // Follow the Desktop Application Autostart Spec: // http://standards.freedesktop.org/autostart-spec/autostart-spec-latest.html boost::filesystem::path static GetAutostartDir() { namespace fs = boost::filesystem; char* pszConfigHome = getenv("XDG_CONFIG_HOME"); if (pszConfigHome) return fs::path(pszConfigHome) / "autostart"; char* pszHome = getenv("HOME"); if (pszHome) return fs::path(pszHome) / ".config" / "autostart"; return fs::path(); } boost::filesystem::path static GetAutostartFilePath() { return GetAutostartDir() / "greenbacks.desktop"; } bool GetStartOnSystemStartup() { boost::filesystem::ifstream optionFile(GetAutostartFilePath()); if (!optionFile.good()) return false; // Scan through file for "Hidden=true": std::string line; while (!optionFile.eof()) { getline(optionFile, line); if (line.find("Hidden") != std::string::npos && line.find("true") != std::string::npos) return false; } optionFile.close(); return true; } bool SetStartOnSystemStartup(bool fAutoStart) { if (!fAutoStart) boost::filesystem::remove(GetAutostartFilePath()); else { char pszExePath[MAX_PATH+1]; memset(pszExePath, 0, sizeof(pszExePath)); if (readlink("/proc/self/exe", pszExePath, sizeof(pszExePath)-1) == -1) return false; boost::filesystem::create_directories(GetAutostartDir()); boost::filesystem::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out|std::ios_base::trunc); if (!optionFile.good()) return false; // Write a bitcoin.desktop file to the autostart directory: optionFile << "[Desktop Entry]\n"; optionFile << "Type=Application\n"; optionFile << "Name=greenbacks\n"; optionFile << "Exec=" << pszExePath << " -min\n"; optionFile << "Terminal=false\n"; optionFile << "Hidden=false\n"; optionFile.close(); } return true; } #else // TODO: OSX startup stuff; see: // https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html bool GetStartOnSystemStartup() { return false; } bool SetStartOnSystemStartup(bool fAutoStart) { return false; } #endif HelpMessageBox::HelpMessageBox(QWidget *parent) : QMessageBox(parent) { header = tr("greenbacks-Qt") + " " + tr("version") + " " + QString::fromStdString(FormatFullVersion()) + "\n\n" + tr("Usage:") + "\n" + " greenbacks-qt [" + tr("command-line options") + "] " + "\n"; coreOptions = QString::fromStdString(HelpMessage()); uiOptions = tr("UI options") + ":\n" + " -lang=<lang> " + tr("Set language, for example \"de_DE\" (default: system locale)") + "\n" + " -min " + tr("Start minimized") + "\n" + " -splash " + tr("Show splash screen on startup (default: 1)") + "\n"; setWindowTitle(tr("greenbacks-Qt")); setTextFormat(Qt::PlainText); // setMinimumWidth is ignored for QMessageBox so put in non-breaking spaces to make it wider. setText(header + QString(QChar(0x2003)).repeated(50)); setDetailedText(coreOptions + "\n" + uiOptions); } void HelpMessageBox::printToConsole() { // On other operating systems, the expected action is to print the message to the console. QString strUsage = header + "\n" + coreOptions + "\n" + uiOptions; fprintf(stdout, "%s", strUsage.toStdString().c_str()); } void HelpMessageBox::showOrPrint() { #if defined(WIN32) // On Windows, show a message box, as there is no stderr/stdout in windowed applications exec(); #else // On other operating systems, print help text to console printToConsole(); #endif } } // namespace GUIUtil
[ "root@d1stkfactory" ]
root@d1stkfactory
cfb577472f9e79ef441bdd7f8a92ca126aafe117
3bec86a19444d5e21dade6fb3d4b9ab7d6ebc9f4
/src/3rdparty/glm/test/core/core_cpp_constexpr.cpp
3b056641187db7ada5624bff45ce45bdcacc11b7
[ "MIT", "BSD-2-Clause" ]
permissive
copperspice/cs_paint
01f2b470a24b23f2f8cf8e80b650e5e5bec905ed
dc01ccba49259842a61a7b0adae1aa1206d6436c
refs/heads/master
2023-07-30T22:03:12.532732
2023-01-25T17:27:57
2023-01-25T17:27:57
209,148,794
95
9
BSD-2-Clause
2020-11-21T21:13:27
2019-09-17T20:18:16
C++
UTF-8
C++
false
false
19,937
cpp
#include <glm/glm.hpp> #if GLM_CONFIG_CONSTEXP == GLM_ENABLE #include <glm/gtc/constants.hpp> #include <glm/gtc/quaternion.hpp> #include <glm/ext/vector_relational.hpp> #include <glm/ext/vector_int1.hpp> #include <glm/ext/vector_bool1.hpp> #include <glm/ext/vector_bool4.hpp> #include <glm/ext/vector_float1.hpp> #include <glm/vector_relational.hpp> static int test_vec1() { int Error = 0; { constexpr glm::bvec1 B(true); constexpr bool A = glm::all(B); static_assert(A, "GLM: Failed constexpr"); constexpr glm::bvec1 D(true); constexpr bool C = glm::any(D); static_assert(C, "GLM: Failed constexpr"); } { constexpr glm::bvec2 C(true); constexpr glm::bvec2 B(true); static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr"); } { constexpr glm::ivec1 O(glm::ivec1(1)); static_assert(glm::ivec1(1) == O, "GLM: Failed constexpr"); constexpr glm::ivec1 P(1); static_assert(glm::ivec1(1) == P, "GLM: Failed constexpr"); } { constexpr glm::ivec1 L(glm::ivec2(1, 2)); static_assert(glm::ivec1(1) == L, "GLM: Failed constexpr"); constexpr glm::ivec1 M(glm::ivec3(1, 2, 3)); static_assert(glm::ivec1(1) == M, "GLM: Failed constexpr"); constexpr glm::ivec1 N(glm::ivec4(1, 2, 3, 4)); static_assert(glm::ivec1(1) == N, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); static_assert(A[0] == 1, "GLM: Failed constexpr"); static_assert(glm::vec1(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec1::length() == 1, "GLM: Failed constexpr"); } { constexpr glm::bvec1 A1(true); constexpr glm::bvec1 A2(true); constexpr glm::bvec1 B1(false); constexpr glm::bvec1 B2(false); static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr"); static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); constexpr glm::ivec1 B = A + 1; constexpr glm::ivec1 C(3); static_assert(A + B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D = +A; static_assert(D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(3); constexpr glm::ivec1 B = A - 1; constexpr glm::ivec1 C(1); static_assert(A - B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D = -A; static_assert(-D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(3); constexpr glm::ivec1 B = A * 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B * C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(3); constexpr glm::ivec1 B = A / 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B / C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(3); constexpr glm::ivec1 B = A % 2; constexpr glm::ivec1 C(1); static_assert(B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D(2); static_assert(A % D == C, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); constexpr glm::ivec1 B = A & 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A & C), "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); constexpr glm::ivec1 B = A | 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A | C), "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); constexpr glm::ivec1 B = A ^ 0; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(0); static_assert(A == (A ^ C), "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(1); constexpr glm::ivec1 B = A << 1; static_assert(B == glm::ivec1(2), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == (A << C), "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(2); constexpr glm::ivec1 B = A >> 1; static_assert(B == glm::ivec1(1), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == A >> C, "GLM: Failed constexpr"); } { constexpr glm::ivec1 A(~0); constexpr glm::ivec1 B = ~A; static_assert(A == ~B, "GLM: Failed constexpr"); } return Error; } static int test_vec2() { int Error = 0; { constexpr glm::bvec2 B(true); constexpr bool A = glm::all(B); static_assert(A, "GLM: Failed constexpr"); constexpr glm::bvec2 D(true, false); constexpr bool C = glm::any(D); static_assert(C, "GLM: Failed constexpr"); } { constexpr glm::bvec2 C(true); constexpr glm::bvec2 B(true, false); static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr"); } { constexpr glm::ivec2 O(glm::ivec1(1)); static_assert(glm::ivec2(1) == O, "GLM: Failed constexpr"); constexpr glm::ivec2 A(1); static_assert(glm::ivec2(1) == A, "GLM: Failed constexpr"); } { constexpr glm::ivec2 F(glm::ivec1(1), glm::ivec1(2)); static_assert(glm::ivec2(1, 2) == F, "GLM: Failed constexpr"); constexpr glm::ivec2 G(1, glm::ivec1(2)); static_assert(glm::ivec2(1, 2) == G, "GLM: Failed constexpr"); constexpr glm::ivec2 H(glm::ivec1(1), 2); static_assert(glm::ivec2(1, 2) == H, "GLM: Failed constexpr"); constexpr glm::ivec2 I(1, 2); static_assert(glm::ivec2(1, 2) == I, "GLM: Failed constexpr"); } { constexpr glm::ivec2 L(glm::ivec2(1, 2)); static_assert(glm::ivec2(1, 2) == L, "GLM: Failed constexpr"); constexpr glm::ivec2 M(glm::ivec3(1, 2, 3)); static_assert(glm::ivec2(1, 2) == M, "GLM: Failed constexpr"); constexpr glm::ivec2 N(glm::ivec4(1, 2, 3, 4)); static_assert(glm::ivec2(1, 2) == N, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); static_assert(A[0] == 1, "GLM: Failed constexpr"); static_assert(glm::vec2(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec2(1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec2(1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec2::length() == 2, "GLM: Failed constexpr"); } { constexpr glm::bvec2 A1(true); constexpr glm::bvec2 A2(true); constexpr glm::bvec2 B1(false); constexpr glm::bvec2 B2(false); static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr"); static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); constexpr glm::ivec2 B = A + 1; constexpr glm::ivec2 C(3); static_assert(A + B == C, "GLM: Failed constexpr"); constexpr glm::ivec2 D = +A; static_assert(D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(3); constexpr glm::ivec2 B = A - 1; constexpr glm::ivec2 C(1); static_assert(A - B == C, "GLM: Failed constexpr"); constexpr glm::ivec2 D = -A; static_assert(-D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(3); constexpr glm::ivec2 B = A * 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec2 C(1); static_assert(B * C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(3); constexpr glm::ivec2 B = A / 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec2 C(1); static_assert(B / C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(3); constexpr glm::ivec2 B = A % 2; constexpr glm::ivec2 C(1); static_assert(B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D(2); static_assert(A % D == C, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); constexpr glm::ivec2 B = A & 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A & C), "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); constexpr glm::ivec2 B = A | 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A | C), "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); constexpr glm::ivec2 B = A ^ 0; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(0); static_assert(A == (A ^ C), "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(1); constexpr glm::ivec2 B = A << 1; static_assert(B == glm::ivec2(2), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == (A << C), "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(2); constexpr glm::ivec2 B = A >> 1; static_assert(B == glm::ivec2(1), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == A >> C, "GLM: Failed constexpr"); } { constexpr glm::ivec2 A(~0); constexpr glm::ivec2 B = ~A; static_assert(A == ~B, "GLM: Failed constexpr"); } return Error; } static int test_vec3() { int Error = 0; { constexpr glm::bvec3 B(true); constexpr bool A = glm::all(B); static_assert(A, "GLM: Failed constexpr"); constexpr glm::bvec3 D(true, false, true); constexpr bool C = glm::any(D); static_assert(C, "GLM: Failed constexpr"); } { constexpr glm::bvec3 C(true); constexpr glm::bvec3 B(true, false, true); static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr"); } { constexpr glm::ivec3 O(glm::ivec1(1)); static_assert(glm::ivec3(1) == O, "GLM: Failed constexpr"); constexpr glm::ivec3 A(1); static_assert(glm::ivec3(1) == A, "GLM: Failed constexpr"); } { constexpr glm::ivec3 B(glm::ivec2(1, 2), 3); static_assert(glm::ivec3(1, 2, 3) == B, "GLM: Failed constexpr"); constexpr glm::ivec3 C(1, glm::ivec2(2, 3)); static_assert(glm::ivec3(1, 2, 3) == C, "GLM: Failed constexpr"); constexpr glm::ivec3 D(glm::ivec1(1), glm::ivec2(2, 3)); static_assert(glm::ivec3(1, 2, 3) == D, "GLM: Failed constexpr"); constexpr glm::ivec3 E(glm::ivec2(1, 2), glm::ivec1(3)); static_assert(glm::ivec3(1, 2, 3) == E, "GLM: Failed constexpr"); } { constexpr glm::ivec3 F(glm::ivec1(1), glm::ivec1(2), glm::ivec1(3)); static_assert(glm::ivec3(1, 2, 3) == F, "GLM: Failed constexpr"); constexpr glm::ivec3 G(1, glm::ivec1(2), glm::ivec1(3)); static_assert(glm::ivec3(1, 2, 3) == G, "GLM: Failed constexpr"); constexpr glm::ivec3 H(glm::ivec1(1), 2, glm::ivec1(3)); static_assert(glm::ivec3(1, 2, 3) == H, "GLM: Failed constexpr"); constexpr glm::ivec3 I(1, 2, glm::ivec1(3)); static_assert(glm::ivec3(1, 2, 3) == I, "GLM: Failed constexpr"); constexpr glm::ivec3 J(glm::ivec1(1), glm::ivec1(2), 3); static_assert(glm::ivec3(1, 2, 3) == J, "GLM: Failed constexpr"); constexpr glm::ivec3 K(1, glm::ivec1(2), 3); static_assert(glm::ivec3(1, 2, 3) == K, "GLM: Failed constexpr"); constexpr glm::ivec3 L(glm::ivec1(1), 2, 3); static_assert(glm::ivec3(1, 2, 3) == L, "GLM: Failed constexpr"); constexpr glm::ivec3 M(1, 2, 3); static_assert(glm::ivec3(1, 2, 3) == M, "GLM: Failed constexpr"); } { constexpr glm::ivec3 N(glm::ivec4(1, 2, 3, 4)); static_assert(glm::ivec3(1, 2, 3) == N, "GLM: Failed constexpr"); } { constexpr glm::ivec3 const A(1); static_assert(A[0] == 1, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).x > 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3(1.0f, -1.0f, -1.0f).y < 0.0f, "GLM: Failed constexpr"); static_assert(glm::vec3::length() == 3, "GLM: Failed constexpr"); } { constexpr glm::bvec3 A1(true); constexpr glm::bvec3 A2(true); constexpr glm::bvec3 B1(false); constexpr glm::bvec3 B2(false); static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr"); static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(1); constexpr glm::ivec3 B = A + 1; constexpr glm::ivec3 C(3); static_assert(A + B == C, "GLM: Failed constexpr"); constexpr glm::ivec3 D = +A; static_assert(D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(3); constexpr glm::ivec3 B = A - 1; constexpr glm::ivec3 C(1); static_assert(A - B == C, "GLM: Failed constexpr"); constexpr glm::ivec3 D = -A; static_assert(-D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(3); constexpr glm::ivec3 B = A * 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec3 C(1); static_assert(B * C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(3); constexpr glm::ivec3 B = A / 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec3 C(1); static_assert(B / C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(3); constexpr glm::ivec3 B = A % 2; constexpr glm::ivec3 C(1); static_assert(B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D(2); static_assert(A % D == C, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(1); constexpr glm::ivec3 B = A & 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A & C), "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(1); constexpr glm::ivec3 B = A | 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A | C), "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(1); constexpr glm::ivec3 B = A ^ 0; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(0); static_assert(A == (A ^ C), "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(1); constexpr glm::ivec3 B = A << 1; static_assert(B == glm::ivec3(2), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == (A << C), "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(2); constexpr glm::ivec3 B = A >> 1; static_assert(B == glm::ivec3(1), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == A >> C, "GLM: Failed constexpr"); } { constexpr glm::ivec3 A(~0); constexpr glm::ivec3 B = ~A; static_assert(A == ~B, "GLM: Failed constexpr"); } return Error; } static int test_vec4() { int Error = 0; { constexpr glm::bvec4 B(true); constexpr bool A = glm::all(B); static_assert(A, "GLM: Failed constexpr"); constexpr glm::bvec4 D(true, false, true, false); constexpr bool C = glm::any(D); static_assert(C, "GLM: Failed constexpr"); } { constexpr glm::bvec4 C(true); constexpr glm::bvec4 B(true, false, true, false); static_assert(glm::any(glm::equal(C, B)), "GLM: Failed constexpr"); } { constexpr glm::ivec4 O(glm::ivec4(1)); static_assert(glm::ivec4(1) == O, "GLM: Failed constexpr"); constexpr glm::ivec4 A(1); static_assert(glm::ivec4(1) == A, "GLM: Failed constexpr"); constexpr glm::ivec4 N(glm::ivec4(1, 2, 3, 4)); static_assert(glm::ivec4(1, 2, 3, 4) == N, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(glm::ivec3(1, 2, 3), 4); static_assert(glm::ivec4(1, 2, 3, 4) == A, "GLM: Failed constexpr"); constexpr glm::ivec4 B(glm::ivec2(1, 2), glm::ivec2(3, 4)); static_assert(glm::ivec4(1, 2, 3, 4) == B, "GLM: Failed constexpr"); constexpr glm::ivec4 C(1, glm::ivec3(2, 3, 4)); static_assert(glm::ivec4(1, 2, 3, 4) == C, "GLM: Failed constexpr"); constexpr glm::ivec4 D(glm::ivec1(1), glm::ivec2(2, 3), glm::ivec1(4)); static_assert(glm::ivec4(1, 2, 3, 4) == D, "GLM: Failed constexpr"); constexpr glm::ivec4 E(glm::ivec2(1, 2), glm::ivec1(3), glm::ivec1(4)); static_assert(glm::ivec4(1, 2, 3, 4) == E, "GLM: Failed constexpr"); constexpr glm::ivec4 F(glm::ivec1(1), glm::ivec1(2), glm::ivec2(3, 4)); static_assert(glm::ivec4(1, 2, 3, 4) == F, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); static_assert(A[0] == 1, "GLM: Failed constexpr"); static_assert(glm::ivec4(1).x > 0, "GLM: Failed constexpr"); static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).x > 0, "GLM: Failed constexpr"); static_assert(glm::ivec4(1.0f, -1.0f, -1.0f, 1.0f).y < 0, "GLM: Failed constexpr"); static_assert(glm::ivec4::length() == 4, "GLM: Failed constexpr"); } { constexpr glm::bvec4 A1(true); constexpr glm::bvec4 A2(true); constexpr glm::bvec4 B1(false); constexpr glm::bvec4 B2(false); static_assert(A1 == A2 && B1 == B2, "GLM: Failed constexpr"); static_assert(A1 == A2 || B1 == B2, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); constexpr glm::ivec4 B = A + 1; constexpr glm::ivec4 C(3); static_assert(A + B == C, "GLM: Failed constexpr"); constexpr glm::ivec4 D = +A; static_assert(D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(3); constexpr glm::ivec4 B = A - 1; constexpr glm::ivec4 C(1); static_assert(A - B == C, "GLM: Failed constexpr"); constexpr glm::ivec4 D = -A; static_assert(-D == A, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(3); constexpr glm::ivec4 B = A * 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec4 C(1); static_assert(B * C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(3); constexpr glm::ivec4 B = A / 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec4 C(1); static_assert(B / C == A, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(3); constexpr glm::ivec4 B = A % 2; constexpr glm::ivec4 C(1); static_assert(B == C, "GLM: Failed constexpr"); constexpr glm::ivec1 D(2); static_assert(A % D == C, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); constexpr glm::ivec4 B = A & 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A & C), "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); constexpr glm::ivec4 B = A | 1; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(A == (A | C), "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); constexpr glm::ivec4 B = A ^ 0; static_assert(A == B, "GLM: Failed constexpr"); constexpr glm::ivec1 C(0); static_assert(A == (A ^ C), "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(1); constexpr glm::ivec4 B = A << 1; static_assert(B == glm::ivec4(2), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == (A << C), "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(2); constexpr glm::ivec4 B = A >> 1; static_assert(B == glm::ivec4(1), "GLM: Failed constexpr"); constexpr glm::ivec1 C(1); static_assert(B == A >> C, "GLM: Failed constexpr"); } { constexpr glm::ivec4 A(~0); constexpr glm::ivec4 B = ~A; static_assert(A == ~B, "GLM: Failed constexpr"); } return Error; } static int test_quat() { int Error = 0; { static_assert(glm::quat::length() == 4, "GLM: Failed constexpr"); static_assert(glm::quat(1.0f, glm::vec3(0.0f)).w > 0.0f, "GLM: Failed constexpr"); static_assert(glm::quat(1.0f, 0.0f, 0.0f, 0.0f).w > 0.0f, "GLM: Failed constexpr"); glm::quat constexpr Q = glm::identity<glm::quat>(); static_assert(Q.x - glm::quat(1.0f, glm::vec3(0.0f)).x <= glm::epsilon<float>(), "GLM: Failed constexpr"); } return Error; } static int test_mat2x2() { int Error = 0; static_assert(glm::mat2x2::length() == 2, "GLM: Failed constexpr"); return Error; } #endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE int main() { int Error = 0; # if GLM_CONFIG_CONSTEXP == GLM_ENABLE Error += test_vec1(); Error += test_vec2(); Error += test_vec3(); Error += test_vec4(); Error += test_quat(); Error += test_mat2x2(); # endif//GLM_CONFIG_CONSTEXP == GLM_ENABLE return Error; }
[ "ansel@copperspice.com" ]
ansel@copperspice.com
10d199fc6cfc3e712b245f89fbac33e3e3f6f643
28e7caca31f1d5cebd5bae43b2e2fd8b038e91e2
/src/wasm/wasm-objects.cc
0f81ea2ccac37681cc8c79c16e8b6000de4a1bad
[ "SunPro", "BSD-3-Clause", "bzip2-1.0.6" ]
permissive
haseebahmadqau/v8
a91779d7a675ed1ed263d0c2e0f5c49749118fd5
140c786bc0a4c73a58c208d82bd498b1b3cdd5f9
refs/heads/master
2020-03-28T07:51:14.085708
2018-09-08T03:05:43
2018-09-08T08:41:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
57,925
cc
// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "src/wasm/wasm-objects.h" #include "src/utils.h" #include "src/assembler-inl.h" #include "src/base/iterator.h" #include "src/code-factory.h" #include "src/compiler/wasm-compiler.h" #include "src/debug/debug-interface.h" #include "src/objects-inl.h" #include "src/objects/debug-objects-inl.h" #include "src/objects/shared-function-info.h" #include "src/trap-handler/trap-handler.h" #include "src/wasm/jump-table-assembler.h" #include "src/wasm/module-compiler.h" #include "src/wasm/module-decoder.h" #include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-limits.h" #include "src/wasm/wasm-memory.h" #include "src/wasm/wasm-module.h" #include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-text.h" #define TRACE(...) \ do { \ if (FLAG_trace_wasm_instances) PrintF(__VA_ARGS__); \ } while (false) #define TRACE_IFT(...) \ do { \ if (false) PrintF(__VA_ARGS__); \ } while (false) namespace v8 { namespace internal { // Import a few often used types from the wasm namespace. using WasmFunction = wasm::WasmFunction; using WasmModule = wasm::WasmModule; namespace { // Manages the natively-allocated memory for a WasmInstanceObject. Since // an instance finalizer is not guaranteed to run upon isolate shutdown, // we must use a Managed<WasmInstanceNativeAllocations> to guarantee // it is freed. // Native allocations are the signature ids and targets for indirect call // targets, as well as the call targets for imported functions. class WasmInstanceNativeAllocations { public: // Helper macro to set an internal field and the corresponding field // on an instance. #define SET(instance, field, value) \ { \ auto v = value; \ this->field##_ = v; \ instance->set_##field(v); \ } // Allocates initial native storage for a given instance. WasmInstanceNativeAllocations(Handle<WasmInstanceObject> instance, size_t num_imported_functions, size_t num_imported_mutable_globals) { SET(instance, imported_function_targets, reinterpret_cast<Address*>( calloc(num_imported_functions, sizeof(Address)))); SET(instance, imported_mutable_globals, reinterpret_cast<Address*>( calloc(num_imported_mutable_globals, sizeof(Address)))); } ~WasmInstanceNativeAllocations() { free(); } // Frees natively-allocated storage. void free() { ::free(indirect_function_table_sig_ids_); ::free(indirect_function_table_targets_); ::free(imported_function_targets_); ::free(imported_mutable_globals_); indirect_function_table_sig_ids_ = nullptr; indirect_function_table_targets_ = nullptr; imported_function_targets_ = nullptr; imported_mutable_globals_ = nullptr; } // Resizes the indirect function table. void resize_indirect_function_table(Isolate* isolate, Handle<WasmInstanceObject> instance, uint32_t new_size) { uint32_t old_size = instance->indirect_function_table_size(); void* new_sig_ids = nullptr; void* new_targets = nullptr; Handle<FixedArray> new_instances; if (indirect_function_table_sig_ids_) { // Reallocate the old storage. new_sig_ids = realloc(indirect_function_table_sig_ids_, new_size * sizeof(uint32_t)); new_targets = realloc(indirect_function_table_targets_, new_size * sizeof(Address)); Handle<FixedArray> old(instance->indirect_function_table_instances(), isolate); new_instances = isolate->factory()->CopyFixedArrayAndGrow( old, static_cast<int>(new_size - old_size)); } else { // Allocate new storage. new_sig_ids = malloc(new_size * sizeof(uint32_t)); new_targets = malloc(new_size * sizeof(Address)); new_instances = isolate->factory()->NewFixedArray(static_cast<int>(new_size)); } // Initialize new entries. instance->set_indirect_function_table_size(new_size); SET(instance, indirect_function_table_sig_ids, reinterpret_cast<uint32_t*>(new_sig_ids)); SET(instance, indirect_function_table_targets, reinterpret_cast<Address*>(new_targets)); instance->set_indirect_function_table_instances(*new_instances); for (uint32_t j = old_size; j < new_size; j++) { IndirectFunctionTableEntry(instance, static_cast<int>(j)).clear(); } } uint32_t* indirect_function_table_sig_ids_ = nullptr; Address* indirect_function_table_targets_ = nullptr; Address* imported_function_targets_ = nullptr; Address* imported_mutable_globals_ = nullptr; #undef SET }; size_t EstimateNativeAllocationsSize(const WasmModule* module) { size_t estimate = sizeof(WasmInstanceNativeAllocations) + (1 * kPointerSize * module->num_imported_mutable_globals) + (2 * kPointerSize * module->num_imported_functions); for (auto& table : module->tables) { estimate += 3 * kPointerSize * table.initial_size; } return estimate; } WasmInstanceNativeAllocations* GetNativeAllocations( WasmInstanceObject* instance) { return reinterpret_cast<Managed<WasmInstanceNativeAllocations>*>( instance->managed_native_allocations()) ->raw(); } #ifdef DEBUG bool IsBreakablePosition(wasm::NativeModule* native_module, int func_index, int offset_in_func) { AccountingAllocator alloc; Zone tmp(&alloc, ZONE_NAME); wasm::BodyLocalDecls locals(&tmp); const byte* module_start = native_module->wire_bytes().start(); const WasmFunction& func = native_module->module()->functions[func_index]; wasm::BytecodeIterator iterator(module_start + func.code.offset(), module_start + func.code.end_offset(), &locals); DCHECK_LT(0, locals.encoded_size); for (uint32_t offset : iterator.offsets()) { if (offset > static_cast<uint32_t>(offset_in_func)) break; if (offset == static_cast<uint32_t>(offset_in_func)) return true; } return false; } #endif // DEBUG enum DispatchTableElements : int { kDispatchTableInstanceOffset, kDispatchTableIndexOffset, kDispatchTableFunctionTableOffset, // Marker: kDispatchTableNumElements }; } // namespace // static Handle<WasmModuleObject> WasmModuleObject::New( Isolate* isolate, const wasm::WasmFeatures& enabled, std::shared_ptr<const wasm::WasmModule> shared_module, wasm::ModuleEnv& env, OwnedVector<const uint8_t> wire_bytes, Handle<Script> script, Handle<ByteArray> asm_js_offset_table) { DCHECK_EQ(shared_module.get(), env.module); // Create a new {NativeModule} first. size_t native_memory_estimate = isolate->wasm_engine()->code_manager()->EstimateNativeModuleSize( env.module); auto native_module = isolate->wasm_engine()->code_manager()->NewNativeModule( isolate, enabled, native_memory_estimate, wasm::NativeModule::kCanAllocateMoreMemory, std::move(shared_module), env); native_module->set_wire_bytes(std::move(wire_bytes)); native_module->SetRuntimeStubs(isolate); // Delegate to the shared {WasmModuleObject::New} allocator. Handle<WasmModuleObject> module_object = New(isolate, std::move(native_module), script); if (!asm_js_offset_table.is_null()) { module_object->set_asm_js_offset_table(*asm_js_offset_table); } return module_object; } // static Handle<WasmModuleObject> WasmModuleObject::New( Isolate* isolate, std::shared_ptr<wasm::NativeModule> native_module, Handle<Script> script) { int export_wrapper_size = static_cast<int>(native_module->module()->num_exported_functions); Handle<FixedArray> export_wrappers = isolate->factory()->NewFixedArray(export_wrapper_size, TENURED); // Use the given shared {NativeModule}, but increase its reference count by // allocating a new {Managed<T>} that the {WasmModuleObject} references. size_t native_memory_estimate = isolate->wasm_engine()->code_manager()->EstimateNativeModuleSize( native_module->module()); size_t memory_estimate = EstimateWasmModuleSize(native_module->module()) + native_memory_estimate; Handle<Managed<wasm::NativeModule>> managed_native_module = Managed<wasm::NativeModule>::FromSharedPtr(isolate, memory_estimate, std::move(native_module)); Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( isolate->factory()->NewJSObject(isolate->wasm_module_constructor())); module_object->set_export_wrappers(*export_wrappers); if (script->type() == Script::TYPE_WASM) { script->set_wasm_module_object(*module_object); } module_object->set_script(*script); module_object->set_weak_instance_list( ReadOnlyRoots(isolate).empty_weak_array_list()); module_object->set_managed_native_module(*managed_native_module); return module_object; } bool WasmModuleObject::SetBreakPoint(Handle<WasmModuleObject> module_object, int* position, Handle<BreakPoint> break_point) { Isolate* isolate = module_object->GetIsolate(); // Find the function for this breakpoint. int func_index = module_object->GetContainingFunction(*position); if (func_index < 0) return false; const WasmFunction& func = module_object->module()->functions[func_index]; int offset_in_func = *position - func.code.offset(); // According to the current design, we should only be called with valid // breakable positions. DCHECK(IsBreakablePosition(module_object->native_module(), func_index, offset_in_func)); // Insert new break point into break_positions of module object. WasmModuleObject::AddBreakpoint(module_object, *position, break_point); // Iterate over all instances of this module and tell them to set this new // breakpoint. We do this using the weak list of all instances. Handle<WeakArrayList> weak_instance_list(module_object->weak_instance_list(), isolate); for (int i = 0; i < weak_instance_list->length(); ++i) { MaybeObject* maybe_instance = weak_instance_list->Get(i); if (maybe_instance->IsWeakHeapObject()) { Handle<WasmInstanceObject> instance( WasmInstanceObject::cast(maybe_instance->ToWeakHeapObject()), isolate); Handle<WasmDebugInfo> debug_info = WasmInstanceObject::GetOrCreateDebugInfo(instance); WasmDebugInfo::SetBreakpoint(debug_info, func_index, offset_in_func); } } return true; } namespace { int GetBreakpointPos(Isolate* isolate, Object* break_point_info_or_undef) { if (break_point_info_or_undef->IsUndefined(isolate)) return kMaxInt; return BreakPointInfo::cast(break_point_info_or_undef)->source_position(); } int FindBreakpointInfoInsertPos(Isolate* isolate, Handle<FixedArray> breakpoint_infos, int position) { // Find insert location via binary search, taking care of undefined values on // the right. Position is always greater than zero. DCHECK_LT(0, position); int left = 0; // inclusive int right = breakpoint_infos->length(); // exclusive while (right - left > 1) { int mid = left + (right - left) / 2; Object* mid_obj = breakpoint_infos->get(mid); if (GetBreakpointPos(isolate, mid_obj) <= position) { left = mid; } else { right = mid; } } int left_pos = GetBreakpointPos(isolate, breakpoint_infos->get(left)); return left_pos < position ? left + 1 : left; } } // namespace void WasmModuleObject::AddBreakpoint(Handle<WasmModuleObject> module_object, int position, Handle<BreakPoint> break_point) { Isolate* isolate = module_object->GetIsolate(); Handle<FixedArray> breakpoint_infos; if (module_object->has_breakpoint_infos()) { breakpoint_infos = handle(module_object->breakpoint_infos(), isolate); } else { breakpoint_infos = isolate->factory()->NewFixedArray(4, TENURED); module_object->set_breakpoint_infos(*breakpoint_infos); } int insert_pos = FindBreakpointInfoInsertPos(isolate, breakpoint_infos, position); // If a BreakPointInfo object already exists for this position, add the new // breakpoint object and return. if (insert_pos < breakpoint_infos->length() && GetBreakpointPos(isolate, breakpoint_infos->get(insert_pos)) == position) { Handle<BreakPointInfo> old_info( BreakPointInfo::cast(breakpoint_infos->get(insert_pos)), isolate); BreakPointInfo::SetBreakPoint(isolate, old_info, break_point); return; } // Enlarge break positions array if necessary. bool need_realloc = !breakpoint_infos->get(breakpoint_infos->length() - 1) ->IsUndefined(isolate); Handle<FixedArray> new_breakpoint_infos = breakpoint_infos; if (need_realloc) { new_breakpoint_infos = isolate->factory()->NewFixedArray( 2 * breakpoint_infos->length(), TENURED); module_object->set_breakpoint_infos(*new_breakpoint_infos); // Copy over the entries [0, insert_pos). for (int i = 0; i < insert_pos; ++i) new_breakpoint_infos->set(i, breakpoint_infos->get(i)); } // Move elements [insert_pos, ...] up by one. for (int i = breakpoint_infos->length() - 1; i >= insert_pos; --i) { Object* entry = breakpoint_infos->get(i); if (entry->IsUndefined(isolate)) continue; new_breakpoint_infos->set(i + 1, entry); } // Generate new BreakpointInfo. Handle<BreakPointInfo> breakpoint_info = isolate->factory()->NewBreakPointInfo(position); BreakPointInfo::SetBreakPoint(isolate, breakpoint_info, break_point); // Now insert new position at insert_pos. new_breakpoint_infos->set(insert_pos, *breakpoint_info); } void WasmModuleObject::SetBreakpointsOnNewInstance( Handle<WasmModuleObject> module_object, Handle<WasmInstanceObject> instance) { if (!module_object->has_breakpoint_infos()) return; Isolate* isolate = module_object->GetIsolate(); Handle<WasmDebugInfo> debug_info = WasmInstanceObject::GetOrCreateDebugInfo(instance); Handle<FixedArray> breakpoint_infos(module_object->breakpoint_infos(), isolate); // If the array exists, it should not be empty. DCHECK_LT(0, breakpoint_infos->length()); for (int i = 0, e = breakpoint_infos->length(); i < e; ++i) { Handle<Object> obj(breakpoint_infos->get(i), isolate); if (obj->IsUndefined(isolate)) { for (; i < e; ++i) { DCHECK(breakpoint_infos->get(i)->IsUndefined(isolate)); } break; } Handle<BreakPointInfo> breakpoint_info = Handle<BreakPointInfo>::cast(obj); int position = breakpoint_info->source_position(); // Find the function for this breakpoint, and set the breakpoint. int func_index = module_object->GetContainingFunction(position); DCHECK_LE(0, func_index); const WasmFunction& func = module_object->module()->functions[func_index]; int offset_in_func = position - func.code.offset(); WasmDebugInfo::SetBreakpoint(debug_info, func_index, offset_in_func); } } namespace { enum AsmJsOffsetTableEntryLayout { kOTEByteOffset, kOTECallPosition, kOTENumberConvPosition, kOTESize }; Handle<ByteArray> GetDecodedAsmJsOffsetTable( Handle<WasmModuleObject> module_object, Isolate* isolate) { DCHECK(module_object->is_asm_js()); Handle<ByteArray> offset_table(module_object->asm_js_offset_table(), isolate); // The last byte in the asm_js_offset_tables ByteArray tells whether it is // still encoded (0) or decoded (1). enum AsmJsTableType : int { Encoded = 0, Decoded = 1 }; int table_type = offset_table->get(offset_table->length() - 1); DCHECK(table_type == Encoded || table_type == Decoded); if (table_type == Decoded) return offset_table; wasm::AsmJsOffsetsResult asm_offsets; { DisallowHeapAllocation no_gc; byte* bytes_start = offset_table->GetDataStartAddress(); byte* bytes_end = reinterpret_cast<byte*>( reinterpret_cast<Address>(bytes_start) + offset_table->length() - 1); asm_offsets = wasm::DecodeAsmJsOffsets(bytes_start, bytes_end); } // Wasm bytes must be valid and must contain asm.js offset table. DCHECK(asm_offsets.ok()); DCHECK_GE(kMaxInt, asm_offsets.val.size()); int num_functions = static_cast<int>(asm_offsets.val.size()); int num_imported_functions = static_cast<int>(module_object->module()->num_imported_functions); DCHECK_EQ(module_object->module()->functions.size(), static_cast<size_t>(num_functions) + num_imported_functions); int num_entries = 0; for (int func = 0; func < num_functions; ++func) { size_t new_size = asm_offsets.val[func].size(); DCHECK_LE(new_size, static_cast<size_t>(kMaxInt) - num_entries); num_entries += static_cast<int>(new_size); } // One byte to encode that this is a decoded table. DCHECK_GE(kMaxInt, 1 + static_cast<uint64_t>(num_entries) * kOTESize * kIntSize); int total_size = 1 + num_entries * kOTESize * kIntSize; Handle<ByteArray> decoded_table = isolate->factory()->NewByteArray(total_size, TENURED); decoded_table->set(total_size - 1, AsmJsTableType::Decoded); module_object->set_asm_js_offset_table(*decoded_table); int idx = 0; const std::vector<WasmFunction>& wasm_funs = module_object->module()->functions; for (int func = 0; func < num_functions; ++func) { std::vector<wasm::AsmJsOffsetEntry>& func_asm_offsets = asm_offsets.val[func]; if (func_asm_offsets.empty()) continue; int func_offset = wasm_funs[num_imported_functions + func].code.offset(); for (wasm::AsmJsOffsetEntry& e : func_asm_offsets) { // Byte offsets must be strictly monotonously increasing: DCHECK_IMPLIES(idx > 0, func_offset + e.byte_offset > decoded_table->get_int(idx - kOTESize)); decoded_table->set_int(idx + kOTEByteOffset, func_offset + e.byte_offset); decoded_table->set_int(idx + kOTECallPosition, e.source_position_call); decoded_table->set_int(idx + kOTENumberConvPosition, e.source_position_number_conversion); idx += kOTESize; } } DCHECK_EQ(total_size, idx * kIntSize + 1); return decoded_table; } } // namespace int WasmModuleObject::GetSourcePosition(Handle<WasmModuleObject> module_object, uint32_t func_index, uint32_t byte_offset, bool is_at_number_conversion) { Isolate* isolate = module_object->GetIsolate(); const WasmModule* module = module_object->module(); if (module->origin != wasm::kAsmJsOrigin) { // for non-asm.js modules, we just add the function's start offset // to make a module-relative position. return byte_offset + module_object->GetFunctionOffset(func_index); } // asm.js modules have an additional offset table that must be searched. Handle<ByteArray> offset_table = GetDecodedAsmJsOffsetTable(module_object, isolate); DCHECK_LT(func_index, module->functions.size()); uint32_t func_code_offset = module->functions[func_index].code.offset(); uint32_t total_offset = func_code_offset + byte_offset; // Binary search for the total byte offset. int left = 0; // inclusive int right = offset_table->length() / kIntSize / kOTESize; // exclusive DCHECK_LT(left, right); while (right - left > 1) { int mid = left + (right - left) / 2; int mid_entry = offset_table->get_int(kOTESize * mid); DCHECK_GE(kMaxInt, mid_entry); if (static_cast<uint32_t>(mid_entry) <= total_offset) { left = mid; } else { right = mid; } } // There should be an entry for each position that could show up on the stack // trace: DCHECK_EQ(total_offset, offset_table->get_int(kOTESize * left)); int idx = is_at_number_conversion ? kOTENumberConvPosition : kOTECallPosition; return offset_table->get_int(kOTESize * left + idx); } v8::debug::WasmDisassembly WasmModuleObject::DisassembleFunction( int func_index) { DisallowHeapAllocation no_gc; if (func_index < 0 || static_cast<uint32_t>(func_index) >= module()->functions.size()) return {}; Vector<const byte> wire_bytes = native_module()->wire_bytes(); std::ostringstream disassembly_os; v8::debug::WasmDisassembly::OffsetTable offset_table; PrintWasmText(module(), wire_bytes, static_cast<uint32_t>(func_index), disassembly_os, &offset_table); return {disassembly_os.str(), std::move(offset_table)}; } bool WasmModuleObject::GetPossibleBreakpoints( const v8::debug::Location& start, const v8::debug::Location& end, std::vector<v8::debug::BreakLocation>* locations) { DisallowHeapAllocation no_gc; const std::vector<WasmFunction>& functions = module()->functions; if (start.GetLineNumber() < 0 || start.GetColumnNumber() < 0 || (!end.IsEmpty() && (end.GetLineNumber() < 0 || end.GetColumnNumber() < 0))) return false; // start_func_index, start_offset and end_func_index is inclusive. // end_offset is exclusive. // start_offset and end_offset are module-relative byte offsets. uint32_t start_func_index = start.GetLineNumber(); if (start_func_index >= functions.size()) return false; int start_func_len = functions[start_func_index].code.length(); if (start.GetColumnNumber() > start_func_len) return false; uint32_t start_offset = functions[start_func_index].code.offset() + start.GetColumnNumber(); uint32_t end_func_index; uint32_t end_offset; if (end.IsEmpty()) { // Default: everything till the end of the Script. end_func_index = static_cast<uint32_t>(functions.size() - 1); end_offset = functions[end_func_index].code.end_offset(); } else { // If end is specified: Use it and check for valid input. end_func_index = static_cast<uint32_t>(end.GetLineNumber()); // Special case: Stop before the start of the next function. Change to: Stop // at the end of the function before, such that we don't disassemble the // next function also. if (end.GetColumnNumber() == 0 && end_func_index > 0) { --end_func_index; end_offset = functions[end_func_index].code.end_offset(); } else { if (end_func_index >= functions.size()) return false; end_offset = functions[end_func_index].code.offset() + end.GetColumnNumber(); if (end_offset > functions[end_func_index].code.end_offset()) return false; } } AccountingAllocator alloc; Zone tmp(&alloc, ZONE_NAME); const byte* module_start = native_module()->wire_bytes().start(); for (uint32_t func_idx = start_func_index; func_idx <= end_func_index; ++func_idx) { const WasmFunction& func = functions[func_idx]; if (func.code.length() == 0) continue; wasm::BodyLocalDecls locals(&tmp); wasm::BytecodeIterator iterator(module_start + func.code.offset(), module_start + func.code.end_offset(), &locals); DCHECK_LT(0u, locals.encoded_size); for (uint32_t offset : iterator.offsets()) { uint32_t total_offset = func.code.offset() + offset; if (total_offset >= end_offset) { DCHECK_EQ(end_func_index, func_idx); break; } if (total_offset < start_offset) continue; locations->emplace_back(func_idx, offset, debug::kCommonBreakLocation); } } return true; } MaybeHandle<FixedArray> WasmModuleObject::CheckBreakPoints( Isolate* isolate, Handle<WasmModuleObject> module_object, int position) { if (!module_object->has_breakpoint_infos()) return {}; Handle<FixedArray> breakpoint_infos(module_object->breakpoint_infos(), isolate); int insert_pos = FindBreakpointInfoInsertPos(isolate, breakpoint_infos, position); if (insert_pos >= breakpoint_infos->length()) return {}; Handle<Object> maybe_breakpoint_info(breakpoint_infos->get(insert_pos), isolate); if (maybe_breakpoint_info->IsUndefined(isolate)) return {}; Handle<BreakPointInfo> breakpoint_info = Handle<BreakPointInfo>::cast(maybe_breakpoint_info); if (breakpoint_info->source_position() != position) return {}; // There is no support for conditional break points. Just assume that every // break point always hits. Handle<Object> break_points(breakpoint_info->break_points(), isolate); if (break_points->IsFixedArray()) { return Handle<FixedArray>::cast(break_points); } Handle<FixedArray> break_points_hit = isolate->factory()->NewFixedArray(1); break_points_hit->set(0, *break_points); return break_points_hit; } MaybeHandle<String> WasmModuleObject::ExtractUtf8StringFromModuleBytes( Isolate* isolate, Handle<WasmModuleObject> module_object, wasm::WireBytesRef ref) { // TODO(wasm): cache strings from modules if it's a performance win. Vector<const uint8_t> wire_bytes = module_object->native_module()->wire_bytes(); return ExtractUtf8StringFromModuleBytes(isolate, wire_bytes, ref); } MaybeHandle<String> WasmModuleObject::ExtractUtf8StringFromModuleBytes( Isolate* isolate, Vector<const uint8_t> wire_bytes, wasm::WireBytesRef ref) { Vector<const uint8_t> name_vec = wire_bytes + ref.offset(); name_vec.Truncate(ref.length()); // UTF8 validation happens at decode time. DCHECK(unibrow::Utf8::ValidateEncoding(name_vec.start(), name_vec.length())); return isolate->factory()->NewStringFromUtf8( Vector<const char>::cast(name_vec)); } MaybeHandle<String> WasmModuleObject::GetModuleNameOrNull( Isolate* isolate, Handle<WasmModuleObject> module_object) { const WasmModule* module = module_object->module(); if (!module->name.is_set()) return {}; return ExtractUtf8StringFromModuleBytes(isolate, module_object, module->name); } MaybeHandle<String> WasmModuleObject::GetFunctionNameOrNull( Isolate* isolate, Handle<WasmModuleObject> module_object, uint32_t func_index) { DCHECK_LT(func_index, module_object->module()->functions.size()); wasm::WireBytesRef name = module_object->module()->LookupFunctionName( wasm::ModuleWireBytes(module_object->native_module()->wire_bytes()), func_index); if (!name.is_set()) return {}; return ExtractUtf8StringFromModuleBytes(isolate, module_object, name); } Handle<String> WasmModuleObject::GetFunctionName( Isolate* isolate, Handle<WasmModuleObject> module_object, uint32_t func_index) { MaybeHandle<String> name = GetFunctionNameOrNull(isolate, module_object, func_index); if (!name.is_null()) return name.ToHandleChecked(); EmbeddedVector<char, 32> buffer; int length = SNPrintF(buffer, "wasm-function[%u]", func_index); return isolate->factory() ->NewStringFromOneByte(Vector<uint8_t>::cast(buffer.SubVector(0, length))) .ToHandleChecked(); } Vector<const uint8_t> WasmModuleObject::GetRawFunctionName( uint32_t func_index) { DCHECK_GT(module()->functions.size(), func_index); wasm::ModuleWireBytes wire_bytes(native_module()->wire_bytes()); wasm::WireBytesRef name_ref = module()->LookupFunctionName(wire_bytes, func_index); wasm::WasmName name = wire_bytes.GetName(name_ref); return Vector<const uint8_t>::cast(name); } int WasmModuleObject::GetFunctionOffset(uint32_t func_index) { const std::vector<WasmFunction>& functions = module()->functions; if (static_cast<uint32_t>(func_index) >= functions.size()) return -1; DCHECK_GE(kMaxInt, functions[func_index].code.offset()); return static_cast<int>(functions[func_index].code.offset()); } int WasmModuleObject::GetContainingFunction(uint32_t byte_offset) { const std::vector<WasmFunction>& functions = module()->functions; // Binary search for a function containing the given position. int left = 0; // inclusive int right = static_cast<int>(functions.size()); // exclusive if (right == 0) return false; while (right - left > 1) { int mid = left + (right - left) / 2; if (functions[mid].code.offset() <= byte_offset) { left = mid; } else { right = mid; } } // If the found function does not contains the given position, return -1. const WasmFunction& func = functions[left]; if (byte_offset < func.code.offset() || byte_offset >= func.code.end_offset()) { return -1; } return left; } bool WasmModuleObject::GetPositionInfo(uint32_t position, Script::PositionInfo* info) { int func_index = GetContainingFunction(position); if (func_index < 0) return false; const WasmFunction& function = module()->functions[func_index]; info->line = func_index; info->column = position - function.code.offset(); info->line_start = function.code.offset(); info->line_end = function.code.end_offset(); return true; } Handle<WasmTableObject> WasmTableObject::New(Isolate* isolate, uint32_t initial, int64_t maximum, Handle<FixedArray>* js_functions) { Handle<JSFunction> table_ctor( isolate->native_context()->wasm_table_constructor(), isolate); auto table_obj = Handle<WasmTableObject>::cast( isolate->factory()->NewJSObject(table_ctor)); *js_functions = isolate->factory()->NewFixedArray(initial); Object* null = ReadOnlyRoots(isolate).null_value(); for (int i = 0; i < static_cast<int>(initial); ++i) { (*js_functions)->set(i, null); } table_obj->set_functions(**js_functions); DCHECK_EQ(maximum, static_cast<int>(maximum)); Handle<Object> max = isolate->factory()->NewNumber(maximum); table_obj->set_maximum_length(*max); table_obj->set_dispatch_tables(ReadOnlyRoots(isolate).empty_fixed_array()); return Handle<WasmTableObject>::cast(table_obj); } void WasmTableObject::AddDispatchTable(Isolate* isolate, Handle<WasmTableObject> table_obj, Handle<WasmInstanceObject> instance, int table_index) { Handle<FixedArray> dispatch_tables(table_obj->dispatch_tables(), isolate); int old_length = dispatch_tables->length(); DCHECK_EQ(0, old_length % kDispatchTableNumElements); if (instance.is_null()) return; // TODO(titzer): use weak cells here to avoid leaking instances. // Grow the dispatch table and add a new entry at the end. Handle<FixedArray> new_dispatch_tables = isolate->factory()->CopyFixedArrayAndGrow(dispatch_tables, kDispatchTableNumElements); new_dispatch_tables->set(old_length + kDispatchTableInstanceOffset, *instance); new_dispatch_tables->set(old_length + kDispatchTableIndexOffset, Smi::FromInt(table_index)); table_obj->set_dispatch_tables(*new_dispatch_tables); } void WasmTableObject::Grow(Isolate* isolate, uint32_t count) { if (count == 0) return; // Degenerate case: nothing to do. Handle<FixedArray> dispatch_tables(this->dispatch_tables(), isolate); DCHECK_EQ(0, dispatch_tables->length() % kDispatchTableNumElements); uint32_t old_size = functions()->length(); // Tables are stored in the instance object, no code patching is // necessary. We simply have to grow the raw tables in each instance // that has imported this table. // TODO(titzer): replace the dispatch table with a weak list of all // the instances that import a given table. for (int i = 0; i < dispatch_tables->length(); i += kDispatchTableNumElements) { Handle<WasmInstanceObject> instance( WasmInstanceObject::cast(dispatch_tables->get(i)), isolate); DCHECK_EQ(old_size, instance->indirect_function_table_size()); uint32_t new_size = old_size + count; WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(instance, new_size); } } void WasmTableObject::Set(Isolate* isolate, Handle<WasmTableObject> table, int32_t table_index, Handle<JSFunction> function) { Handle<FixedArray> array(table->functions(), isolate); if (function.is_null()) { ClearDispatchTables(isolate, table, table_index); // Degenerate case. array->set(table_index, ReadOnlyRoots(isolate).null_value()); return; } // TODO(titzer): Change this to MaybeHandle<WasmExportedFunction> DCHECK(WasmExportedFunction::IsWasmExportedFunction(*function)); auto exported_function = Handle<WasmExportedFunction>::cast(function); Handle<WasmInstanceObject> other_instance(exported_function->instance(), isolate); int func_index = exported_function->function_index(); auto* wasm_function = &other_instance->module()->functions[func_index]; DCHECK_NOT_NULL(wasm_function); DCHECK_NOT_NULL(wasm_function->sig); Address call_target = exported_function->GetWasmCallTarget(); UpdateDispatchTables(isolate, table, table_index, wasm_function->sig, handle(exported_function->instance(), isolate), call_target); array->set(table_index, *function); } void WasmTableObject::UpdateDispatchTables( Isolate* isolate, Handle<WasmTableObject> table, int table_index, wasm::FunctionSig* sig, Handle<WasmInstanceObject> from_instance, Address call_target) { // We simply need to update the IFTs for each instance that imports // this table. Handle<FixedArray> dispatch_tables(table->dispatch_tables(), isolate); DCHECK_EQ(0, dispatch_tables->length() % kDispatchTableNumElements); for (int i = 0; i < dispatch_tables->length(); i += kDispatchTableNumElements) { Handle<WasmInstanceObject> to_instance( WasmInstanceObject::cast( dispatch_tables->get(i + kDispatchTableInstanceOffset)), isolate); // Note that {SignatureMap::Find} may return {-1} if the signature is // not found; it will simply never match any check. auto sig_id = to_instance->module()->signature_map.Find(*sig); IndirectFunctionTableEntry(to_instance, table_index) .set(sig_id, *from_instance, call_target); } } void WasmTableObject::ClearDispatchTables(Isolate* isolate, Handle<WasmTableObject> table, int index) { Handle<FixedArray> dispatch_tables(table->dispatch_tables(), isolate); DCHECK_EQ(0, dispatch_tables->length() % kDispatchTableNumElements); for (int i = 0; i < dispatch_tables->length(); i += kDispatchTableNumElements) { Handle<WasmInstanceObject> target_instance( WasmInstanceObject::cast( dispatch_tables->get(i + kDispatchTableInstanceOffset)), isolate); DCHECK_LT(index, target_instance->indirect_function_table_size()); IndirectFunctionTableEntry(target_instance, index).clear(); } } namespace { MaybeHandle<JSArrayBuffer> GrowMemoryBuffer(Isolate* isolate, Handle<JSArrayBuffer> old_buffer, uint32_t pages, uint32_t maximum_pages) { if (!old_buffer->is_growable()) return {}; void* old_mem_start = old_buffer->backing_store(); size_t old_size = old_buffer->byte_length()->Number(); CHECK_GE(wasm::kV8MaxWasmMemoryBytes, old_size); CHECK_EQ(0, old_size % wasm::kWasmPageSize); size_t old_pages = old_size / wasm::kWasmPageSize; if (old_pages > maximum_pages || // already reached maximum (pages > maximum_pages - old_pages) || // exceeds remaining (pages > FLAG_wasm_max_mem_pages - old_pages)) { // exceeds limit return {}; } size_t new_size = static_cast<size_t>(old_pages + pages) * wasm::kWasmPageSize; CHECK_GE(wasm::kV8MaxWasmMemoryBytes, new_size); // Reusing the backing store from externalized buffers causes problems with // Blink's array buffers. The connection between the two is lost, which can // lead to Blink not knowing about the other reference to the buffer and // freeing it too early. if (!old_buffer->is_external() && ((new_size < old_buffer->allocation_length()) || old_size == new_size)) { if (old_size != new_size) { DCHECK_NOT_NULL(old_buffer->backing_store()); // If adjusting permissions fails, propagate error back to return // failure to grow. if (!i::SetPermissions(GetPlatformPageAllocator(), old_mem_start, new_size, PageAllocator::kReadWrite)) { return {}; } reinterpret_cast<v8::Isolate*>(isolate) ->AdjustAmountOfExternalAllocatedMemory(pages * wasm::kWasmPageSize); } // NOTE: We must allocate a new array buffer here because the spec // assumes that ArrayBuffers do not change size. void* backing_store = old_buffer->backing_store(); bool is_external = old_buffer->is_external(); // Disconnect buffer early so GC won't free it. i::wasm::DetachMemoryBuffer(isolate, old_buffer, false); Handle<JSArrayBuffer> new_buffer = wasm::SetupArrayBuffer(isolate, backing_store, new_size, is_external); return new_buffer; } else { // We couldn't reuse the old backing store, so create a new one and copy the // old contents in. Handle<JSArrayBuffer> new_buffer; if (!wasm::NewArrayBuffer(isolate, new_size).ToHandle(&new_buffer)) { return {}; } wasm::WasmMemoryTracker* const memory_tracker = isolate->wasm_engine()->memory_tracker(); // If the old buffer had full guard regions, we can only safely use the new // buffer if it also has full guard regions. Otherwise, we'd have to // recompile all the instances using this memory to insert bounds checks. if (memory_tracker->HasFullGuardRegions(old_mem_start) && !memory_tracker->HasFullGuardRegions(new_buffer->backing_store())) { return {}; } if (old_size == 0) return new_buffer; memcpy(new_buffer->backing_store(), old_mem_start, old_size); DCHECK(old_buffer.is_null() || !old_buffer->is_shared()); constexpr bool free_memory = true; i::wasm::DetachMemoryBuffer(isolate, old_buffer, free_memory); return new_buffer; } } // May GC, because SetSpecializationMemInfoFrom may GC void SetInstanceMemory(Handle<WasmInstanceObject> instance, Handle<JSArrayBuffer> buffer) { instance->SetRawMemory(reinterpret_cast<byte*>(buffer->backing_store()), buffer->byte_length()->Number()); #if DEBUG if (!FLAG_mock_arraybuffer_allocator) { // To flush out bugs earlier, in DEBUG mode, check that all pages of the // memory are accessible by reading and writing one byte on each page. // Don't do this if the mock ArrayBuffer allocator is enabled. byte* mem_start = instance->memory_start(); size_t mem_size = instance->memory_size(); for (size_t offset = 0; offset < mem_size; offset += wasm::kWasmPageSize) { byte val = mem_start[offset]; USE(val); mem_start[offset] = val; } } #endif } } // namespace Handle<WasmMemoryObject> WasmMemoryObject::New( Isolate* isolate, MaybeHandle<JSArrayBuffer> maybe_buffer, int32_t maximum) { // TODO(kschimpf): Do we need to add an argument that defines the // style of memory the user prefers (with/without trap handling), so // that the memory will match the style of the compiled wasm module. // See issue v8:7143 Handle<JSFunction> memory_ctor( isolate->native_context()->wasm_memory_constructor(), isolate); auto memory_obj = Handle<WasmMemoryObject>::cast( isolate->factory()->NewJSObject(memory_ctor, TENURED)); Handle<JSArrayBuffer> buffer; if (!maybe_buffer.ToHandle(&buffer)) { // If no buffer was provided, create a 0-length one. buffer = wasm::SetupArrayBuffer(isolate, nullptr, 0, false); } memory_obj->set_array_buffer(*buffer); memory_obj->set_maximum_pages(maximum); return memory_obj; } uint32_t WasmMemoryObject::current_pages() { uint32_t byte_length; CHECK(array_buffer()->byte_length()->ToUint32(&byte_length)); return byte_length / wasm::kWasmPageSize; } bool WasmMemoryObject::has_full_guard_region(Isolate* isolate) { const wasm::WasmMemoryTracker::AllocationData* allocation = isolate->wasm_engine()->memory_tracker()->FindAllocationData( array_buffer()->backing_store()); CHECK_NOT_NULL(allocation); Address allocation_base = reinterpret_cast<Address>(allocation->allocation_base); Address buffer_start = reinterpret_cast<Address>(allocation->buffer_start); // Return whether the allocation covers every possible Wasm heap index. // // We always have the following relationship: // allocation_base <= buffer_start <= buffer_start + memory_size <= // allocation_base + allocation_length // (in other words, the buffer fits within the allocation) // // The space between buffer_start + memory_size and allocation_base + // allocation_length is the guard region. Here we make sure the guard region // is large enough for any Wasm heap offset. return buffer_start + wasm::kWasmMaxHeapOffset <= allocation_base + allocation->allocation_length; } void WasmMemoryObject::AddInstance(Isolate* isolate, Handle<WasmMemoryObject> memory, Handle<WasmInstanceObject> instance) { Handle<WeakArrayList> old_instances = memory->has_instances() ? Handle<WeakArrayList>(memory->instances(), isolate) : handle(ReadOnlyRoots(isolate->heap()).empty_weak_array_list(), isolate); Handle<WeakArrayList> new_instances = WeakArrayList::AddToEnd( isolate, old_instances, MaybeObjectHandle::Weak(instance)); memory->set_instances(*new_instances); Handle<JSArrayBuffer> buffer(memory->array_buffer(), isolate); SetInstanceMemory(instance, buffer); } void WasmMemoryObject::RemoveInstance(Handle<WasmMemoryObject> memory, Handle<WasmInstanceObject> instance) { if (memory->has_instances()) { memory->instances()->RemoveOne(MaybeObjectHandle::Weak(instance)); } } // static int32_t WasmMemoryObject::Grow(Isolate* isolate, Handle<WasmMemoryObject> memory_object, uint32_t pages) { Handle<JSArrayBuffer> old_buffer(memory_object->array_buffer(), isolate); if (!old_buffer->is_growable()) return -1; uint32_t old_size = 0; CHECK(old_buffer->byte_length()->ToUint32(&old_size)); DCHECK_EQ(0, old_size % wasm::kWasmPageSize); Handle<JSArrayBuffer> new_buffer; uint32_t maximum_pages = FLAG_wasm_max_mem_pages; if (memory_object->has_maximum_pages()) { maximum_pages = Min(FLAG_wasm_max_mem_pages, static_cast<uint32_t>(memory_object->maximum_pages())); } if (!GrowMemoryBuffer(isolate, old_buffer, pages, maximum_pages) .ToHandle(&new_buffer)) { return -1; } if (memory_object->has_instances()) { Handle<WeakArrayList> instances(memory_object->instances(), isolate); for (int i = 0; i < instances->length(); i++) { MaybeObject* elem = instances->Get(i); HeapObject* heap_object; if (elem->ToWeakHeapObject(&heap_object)) { Handle<WasmInstanceObject> instance( WasmInstanceObject::cast(heap_object), isolate); SetInstanceMemory(instance, new_buffer); } else { DCHECK(elem->IsClearedWeakHeapObject()); } } } memory_object->set_array_buffer(*new_buffer); return old_size / wasm::kWasmPageSize; } // static MaybeHandle<WasmGlobalObject> WasmGlobalObject::New( Isolate* isolate, MaybeHandle<JSArrayBuffer> maybe_buffer, wasm::ValueType type, int32_t offset, bool is_mutable) { Handle<JSFunction> global_ctor( isolate->native_context()->wasm_global_constructor(), isolate); auto global_obj = Handle<WasmGlobalObject>::cast( isolate->factory()->NewJSObject(global_ctor)); uint32_t type_size = wasm::ValueTypes::ElementSizeInBytes(type); Handle<JSArrayBuffer> buffer; if (!maybe_buffer.ToHandle(&buffer)) { // If no buffer was provided, create one long enough for the given type. buffer = isolate->factory()->NewJSArrayBuffer(SharedFlag::kNotShared, TENURED); const bool initialize = true; if (!JSArrayBuffer::SetupAllocatingData(buffer, isolate, type_size, initialize)) { return {}; } } // Check that the offset is in bounds. uint32_t buffer_size = 0; CHECK(buffer->byte_length()->ToUint32(&buffer_size)); CHECK(offset + type_size <= buffer_size); global_obj->set_array_buffer(*buffer); global_obj->set_flags(0); global_obj->set_type(type); global_obj->set_offset(offset); global_obj->set_is_mutable(is_mutable); return global_obj; } void IndirectFunctionTableEntry::clear() { instance_->indirect_function_table_sig_ids()[index_] = -1; instance_->indirect_function_table_targets()[index_] = 0; instance_->indirect_function_table_instances()->set( index_, ReadOnlyRoots(instance_->GetIsolate()).undefined_value()); } void IndirectFunctionTableEntry::set(int sig_id, WasmInstanceObject* instance, Address call_target) { TRACE_IFT("IFT entry %p[%d] = {sig_id=%d, instance=%p, target=%" PRIuPTR "}\n", *instance_, index_, sig_id, instance, call_target); instance_->indirect_function_table_sig_ids()[index_] = sig_id; instance_->indirect_function_table_targets()[index_] = call_target; instance_->indirect_function_table_instances()->set(index_, instance); } WasmInstanceObject* IndirectFunctionTableEntry::instance() { return WasmInstanceObject::cast( instance_->indirect_function_table_instances()->get(index_)); } int IndirectFunctionTableEntry::sig_id() { return instance_->indirect_function_table_sig_ids()[index_]; } Address IndirectFunctionTableEntry::target() { return instance_->indirect_function_table_targets()[index_]; } void ImportedFunctionEntry::set_wasm_to_js( JSReceiver* callable, const wasm::WasmCode* wasm_to_js_wrapper) { TRACE_IFT("Import callable %p[%d] = {callable=%p, target=%p}\n", *instance_, index_, callable, wasm_to_js_wrapper->instructions().start()); DCHECK_EQ(wasm::WasmCode::kWasmToJsWrapper, wasm_to_js_wrapper->kind()); instance_->imported_function_instances()->set(index_, *instance_); instance_->imported_function_callables()->set(index_, callable); instance_->imported_function_targets()[index_] = wasm_to_js_wrapper->instruction_start(); } void ImportedFunctionEntry::set_wasm_to_wasm(WasmInstanceObject* instance, Address call_target) { TRACE_IFT("Import WASM %p[%d] = {instance=%p, target=%" PRIuPTR "}\n", *instance_, index_, instance, call_target); instance_->imported_function_instances()->set(index_, instance); instance_->imported_function_callables()->set( index_, instance_->GetReadOnlyRoots().undefined_value()); instance_->imported_function_targets()[index_] = call_target; } WasmInstanceObject* ImportedFunctionEntry::instance() { return WasmInstanceObject::cast( instance_->imported_function_instances()->get(index_)); } JSReceiver* ImportedFunctionEntry::callable() { return JSReceiver::cast( instance_->imported_function_callables()->get(index_)); } Address ImportedFunctionEntry::target() { return instance_->imported_function_targets()[index_]; } bool ImportedFunctionEntry::is_js_receiver_entry() { return instance_->imported_function_callables()->get(index_)->IsJSReceiver(); } bool WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize( Handle<WasmInstanceObject> instance, uint32_t minimum_size) { uint32_t old_size = instance->indirect_function_table_size(); if (old_size >= minimum_size) return false; // Nothing to do. Isolate* isolate = instance->GetIsolate(); HandleScope scope(isolate); auto native_allocations = GetNativeAllocations(*instance); native_allocations->resize_indirect_function_table(isolate, instance, minimum_size); return true; } void WasmInstanceObject::SetRawMemory(byte* mem_start, size_t mem_size) { CHECK_LE(mem_size, wasm::kV8MaxWasmMemoryBytes); #if V8_HOST_ARCH_64_BIT uint64_t mem_mask64 = base::bits::RoundUpToPowerOfTwo64(mem_size) - 1; set_memory_start(mem_start); set_memory_size(mem_size); set_memory_mask(mem_mask64); #else // Must handle memory > 2GiB specially. CHECK_LE(mem_size, size_t{kMaxUInt32}); uint32_t mem_mask32 = (mem_size > 2 * size_t{GB}) ? 0xFFFFFFFFu : base::bits::RoundUpToPowerOfTwo32(static_cast<uint32_t>(mem_size)) - 1; set_memory_start(mem_start); set_memory_size(mem_size); set_memory_mask(mem_mask32); #endif } const WasmModule* WasmInstanceObject::module() { return module_object()->module(); } Handle<WasmDebugInfo> WasmInstanceObject::GetOrCreateDebugInfo( Handle<WasmInstanceObject> instance) { if (instance->has_debug_info()) { return handle(instance->debug_info(), instance->GetIsolate()); } Handle<WasmDebugInfo> new_info = WasmDebugInfo::New(instance); DCHECK(instance->has_debug_info()); return new_info; } Handle<WasmInstanceObject> WasmInstanceObject::New( Isolate* isolate, Handle<WasmModuleObject> module_object) { Handle<JSFunction> instance_cons( isolate->native_context()->wasm_instance_constructor(), isolate); Handle<JSObject> instance_object = isolate->factory()->NewJSObject(instance_cons, TENURED); Handle<WasmInstanceObject> instance( reinterpret_cast<WasmInstanceObject*>(*instance_object), isolate); // Initialize the imported function arrays. auto module = module_object->module(); auto num_imported_functions = module->num_imported_functions; auto num_imported_mutable_globals = module->num_imported_mutable_globals; size_t native_allocations_size = EstimateNativeAllocationsSize(module); auto native_allocations = Managed<WasmInstanceNativeAllocations>::Allocate( isolate, native_allocations_size, instance, num_imported_functions, num_imported_mutable_globals); instance->set_managed_native_allocations(*native_allocations); Handle<FixedArray> imported_function_instances = isolate->factory()->NewFixedArray(num_imported_functions); instance->set_imported_function_instances(*imported_function_instances); Handle<FixedArray> imported_function_callables = isolate->factory()->NewFixedArray(num_imported_functions); instance->set_imported_function_callables(*imported_function_callables); Handle<Code> centry_stub = CodeFactory::CEntry(isolate); instance->set_centry_stub(*centry_stub); instance->SetRawMemory(nullptr, 0); instance->set_roots_array_address( reinterpret_cast<Address>(isolate->heap()->roots_array_start())); instance->set_stack_limit_address( isolate->stack_guard()->address_of_jslimit()); instance->set_real_stack_limit_address( isolate->stack_guard()->address_of_real_jslimit()); instance->set_globals_start(nullptr); instance->set_indirect_function_table_size(0); instance->set_indirect_function_table_sig_ids(nullptr); instance->set_indirect_function_table_targets(nullptr); instance->set_native_context(*isolate->native_context()); instance->set_module_object(*module_object); instance->set_undefined_value(ReadOnlyRoots(isolate).undefined_value()); instance->set_null_value(ReadOnlyRoots(isolate).null_value()); instance->set_jump_table_start( module_object->native_module()->jump_table_start()); // Insert the new instance into the modules weak list of instances. // TODO(mstarzinger): Allow to reuse holes in the {WeakArrayList} below. Handle<WeakArrayList> weak_instance_list(module_object->weak_instance_list(), isolate); weak_instance_list = WeakArrayList::AddToEnd( isolate, weak_instance_list, MaybeObjectHandle::Weak(instance)); module_object->set_weak_instance_list(*weak_instance_list); return instance; } namespace { void InstanceFinalizer(const v8::WeakCallbackInfo<void>& data) { DisallowHeapAllocation no_gc; JSObject** p = reinterpret_cast<JSObject**>(data.GetParameter()); WasmInstanceObject* instance = reinterpret_cast<WasmInstanceObject*>(*p); Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate()); // If a link to shared memory instances exists, update the list of memory // instances before the instance is destroyed. TRACE("Finalizing instance of %p {\n", instance->module_object()->native_module()); // Since the order of finalizers is not guaranteed, it can be the case // that {instance->compiled_module()->module()}, which is a // {Managed<WasmModule>} has been collected earlier in this GC cycle. // Weak references to this instance won't be cleared until // the next GC cycle, so we need to manually break some links (such as // the weak references from {WasmMemoryObject::instances}. if (instance->has_memory_object()) { WasmMemoryObject::RemoveInstance(handle(instance->memory_object(), isolate), handle(instance, isolate)); } // Free raw C++ memory associated with the instance. GetNativeAllocations(instance)->free(); GlobalHandles::Destroy(reinterpret_cast<Object**>(p)); TRACE("}\n"); } } // namespace void WasmInstanceObject::InstallFinalizer(Isolate* isolate, Handle<WasmInstanceObject> instance) { Handle<Object> global_handle = isolate->global_handles()->Create(*instance); GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(), InstanceFinalizer, v8::WeakCallbackType::kFinalizer); } Address WasmInstanceObject::GetCallTarget(uint32_t func_index) { wasm::NativeModule* native_module = module_object()->native_module(); if (func_index < native_module->num_imported_functions()) { return imported_function_targets()[func_index]; } return native_module->GetCallTargetForFunction(func_index); } bool WasmExportedFunction::IsWasmExportedFunction(Object* object) { if (!object->IsJSFunction()) return false; JSFunction* js_function = JSFunction::cast(object); if (Code::JS_TO_WASM_FUNCTION != js_function->code()->kind()) return false; DCHECK(js_function->shared()->HasWasmExportedFunctionData()); return true; } WasmExportedFunction* WasmExportedFunction::cast(Object* object) { DCHECK(IsWasmExportedFunction(object)); return reinterpret_cast<WasmExportedFunction*>(object); } WasmInstanceObject* WasmExportedFunction::instance() { return shared()->wasm_exported_function_data()->instance(); } int WasmExportedFunction::function_index() { return shared()->wasm_exported_function_data()->function_index(); } Handle<WasmExportedFunction> WasmExportedFunction::New( Isolate* isolate, Handle<WasmInstanceObject> instance, MaybeHandle<String> maybe_name, int func_index, int arity, Handle<Code> export_wrapper) { DCHECK_EQ(Code::JS_TO_WASM_FUNCTION, export_wrapper->kind()); int num_imported_functions = instance->module()->num_imported_functions; int jump_table_offset = -1; if (func_index >= num_imported_functions) { ptrdiff_t jump_table_diff = instance->module_object()->native_module()->jump_table_offset( func_index); DCHECK(jump_table_diff >= 0 && jump_table_diff <= INT_MAX); jump_table_offset = static_cast<int>(jump_table_diff); } Handle<WasmExportedFunctionData> function_data = Handle<WasmExportedFunctionData>::cast(isolate->factory()->NewStruct( WASM_EXPORTED_FUNCTION_DATA_TYPE, TENURED)); function_data->set_wrapper_code(*export_wrapper); function_data->set_instance(*instance); function_data->set_jump_table_offset(jump_table_offset); function_data->set_function_index(func_index); Handle<String> name; if (!maybe_name.ToHandle(&name)) { EmbeddedVector<char, 16> buffer; int length = SNPrintF(buffer, "%d", func_index); name = isolate->factory() ->NewStringFromOneByte( Vector<uint8_t>::cast(buffer.SubVector(0, length))) .ToHandleChecked(); } NewFunctionArgs args = NewFunctionArgs::ForWasm( name, function_data, isolate->sloppy_function_without_prototype_map()); Handle<JSFunction> js_function = isolate->factory()->NewFunction(args); // According to the spec, exported functions should not have a [[Construct]] // method. DCHECK(!js_function->IsConstructor()); js_function->shared()->set_length(arity); js_function->shared()->set_internal_formal_parameter_count(arity); return Handle<WasmExportedFunction>::cast(js_function); } Address WasmExportedFunction::GetWasmCallTarget() { return instance()->GetCallTarget(function_index()); } #undef TRACE #undef TRACE_IFT } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
94e458de013036e9a008272e73d6ac983c9b2cef
2efda80d33463f8486a85fbfe12341f5166e2ece
/src/lastfmpp/affiliation.cpp
8b9f46dba2392fd8ca48c8bce1334971a5010047
[ "MIT" ]
permissive
chrismanning/lastfmpp
5248081a1f7c5b8232f9824452c4335fb8a3d637
59439e62d2654359a48f8244a4b69b95d398beb3
refs/heads/master
2021-03-24T12:31:19.338239
2015-12-24T14:06:58
2015-12-24T14:06:58
38,926,005
0
0
null
null
null
null
UTF-8
C++
false
false
1,301
cpp
/************************************************************************** ** Copyright (C) 2015 Christian Manning ** ** This software may be modified and distributed under the terms ** of the MIT license. See the LICENSE file for details. **************************************************************************/ #include <lastfmpp/affiliation.hpp> namespace lastfmpp { std::experimental::string_view affiliation::supplier_name() const { return m_supplier_name; } void affiliation::supplier_name(std::experimental::string_view supplier_name) { m_supplier_name = supplier_name.to_string(); } const uri_t& affiliation::buy_link() const { return m_buy_link; } void affiliation::buy_link(uri_t buy_link) { m_buy_link = std::move(buy_link); } std::experimental::string_view affiliation::price() const { return m_price; } void affiliation::price(std::experimental::string_view price) { m_price = price.to_string(); } const uri_t& affiliation::supplier_icon() const { return m_supplier_icon; } void affiliation::supplier_icon(uri_t supplier_icon) { m_supplier_icon = std::move(supplier_icon); } bool affiliation::is_search() const { return m_is_search; } void affiliation::is_search(bool is_search) { m_is_search = is_search; } } // namespace lastfm
[ "cmanning999@gmail.com" ]
cmanning999@gmail.com
82618a4588e5b698ddc576eb3b1334463072619b
b3ee4b3c63efdc6bc87adae7ca02da89bc6141dd
/ppmp/PPMP/Mangling/AllCases.t.cpp
5ccde48516cb78d698d0e467dc498035faae7d5f
[]
no_license
el-bart/dictools
1cfefac79c6729d806968f4a47fcf3eef40483bb
620ef0a30de3b5b297db9c222c3d8714e97ad9d7
refs/heads/master
2021-01-20T10:35:48.739709
2012-08-08T12:04:46
2012-08-08T12:04:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,018
cpp
/* * AllCases.t.cpp * */ #include <tut/tut.hpp> #include <string> #include <sstream> #include <queue> #include "PPMP/Mangling/AllCases.hpp" using namespace std; using namespace PPMP; using namespace PPMP::Mangling; namespace { struct TestClass: public Processor { TestClass(void): ac_(*this) { } queue<string> q_; virtual void process(Common::FastString &str) { tut::ensure("too many elements produced", q_.size()>0 ); tut::ensure_equals("invalid string", str.c_str(), q_.front() ); q_.pop(); } AllCases ac_; }; typedef tut::test_group<TestClass> factory; typedef factory::object testObj; factory tf("PPMP/Mangling/AllCases"); } // unnamed namespace namespace tut { // test empty output set template<> template<> void testObj::test<1>(void) { q_.push("666"); // test Common::FastString fs("666"); ac_.process(fs); // nothing should be in queue ensure_equals("something's left", q_.size(), 0); } // test simple set (only letters) template<> template<> void testObj::test<2>(void) { q_.push("ab"); q_.push("Ab"); q_.push("aB"); q_.push("AB"); // test Common::FastString fs("ab"); ac_.process(fs); // check if nothing has left ensure_equals("not all elements generated", q_.size(), 0); } // test example set (mixed elements) template<> template<> void testObj::test<3>(void) { q_.push("42X-f"); q_.push("42x-f"); q_.push("42X-F"); q_.push("42x-F"); // test Common::FastString fs("42X-f"); ac_.process(fs); // check if nothing has left ensure_equals("not all elements generated", q_.size(), 0); } // test longer sequence template<> template<> void testObj::test<4>(void) { q_.push("$abc6"); q_.push("$Abc6"); q_.push("$aBc6"); q_.push("$ABc6"); q_.push("$abC6"); q_.push("$AbC6"); q_.push("$aBC6"); q_.push("$ABC6"); // test Common::FastString fs("$abc6"); ac_.process(fs); // check if nothing has left ensure_equals("not all elements generated", q_.size(), 0); } } // namespace tut
[ "bartosz.szurgot@pwr.wroc.pl" ]
bartosz.szurgot@pwr.wroc.pl
60877ec238d83857eb10107a5e8d531446e29b0c
5bef96cb50e3543ef70ce8a6330b1d67b893f12a
/include/mexopencv_features2d.hpp
0877e7a39e81ad85c30130ef93ca981826596806
[ "BSD-3-Clause" ]
permissive
ZhangPeike/mexopencv
5ec5c55a8cd0506f39799b8bdab9bce1a7062e70
0f58860a8b1cfcd9f5a129fc16476b3518ced7da
refs/heads/master
2020-06-11T03:46:51.828671
2016-11-29T13:22:02
2016-11-29T13:22:02
76,011,919
1
0
null
2016-12-09T07:22:21
2016-12-09T07:22:20
null
UTF-8
C++
false
false
14,660
hpp
/** * @file mexopencv_features2d.hpp * @brief Common definitions for the features2d and xfeatures2d modules * @ingroup features2d * @ingroup xfeatures2d * @author Amro * @date 2015 * * Header file for MEX-functions that use features2d or xfeatures2d modules * from OpenCV library. This file includes maps for option processing, as well * as functions for creating instances of Features2D-derived classes from * parsed arguments. */ #ifndef MEXOPENCV_FEATURES2D_HPP #define MEXOPENCV_FEATURES2D_HPP #include "mexopencv.hpp" #include "opencv2/opencv_modules.hpp" #ifdef HAVE_OPENCV_XFEATURES2D #include "opencv2/xfeatures2d.hpp" #endif // ==================== Feature Detection and Description ==================== /// ORB score types const ConstMap<std::string, int> ORBScoreType = ConstMap<std::string, int> ("Harris", cv::ORB::HARRIS_SCORE) ("FAST", cv::ORB::FAST_SCORE); /// inverse ORB score types const ConstMap<int, std::string> ORBScoreTypeInv = ConstMap<int, std::string> (cv::ORB::HARRIS_SCORE, "Harris") (cv::ORB::FAST_SCORE, "FAST"); /// FAST types const ConstMap<std::string, int> FASTTypeMap = ConstMap<std::string, int> ("TYPE_5_8", cv::FastFeatureDetector::TYPE_5_8) ("TYPE_7_12", cv::FastFeatureDetector::TYPE_7_12) ("TYPE_9_16", cv::FastFeatureDetector::TYPE_9_16); /// inverse FAST types const ConstMap<int, std::string> FASTTypeMapInv = ConstMap<int, std::string> (cv::FastFeatureDetector::TYPE_5_8, "TYPE_5_8") (cv::FastFeatureDetector::TYPE_7_12, "TYPE_7_12") (cv::FastFeatureDetector::TYPE_9_16, "TYPE_9_16"); /// KAZE Diffusivity type const ConstMap<std::string, int> KAZEDiffusivityType = ConstMap<std::string, int> ("PM_G1", cv::KAZE::DIFF_PM_G1) ("PM_G2", cv::KAZE::DIFF_PM_G2) ("WEICKERT", cv::KAZE::DIFF_WEICKERT) ("CHARBONNIER", cv::KAZE::DIFF_CHARBONNIER); /// inverse KAZE Diffusivity type const ConstMap<int, std::string> KAZEDiffusivityTypeInv = ConstMap<int, std::string> (cv::KAZE::DIFF_PM_G1, "PM_G1") (cv::KAZE::DIFF_PM_G2, "PM_G2") (cv::KAZE::DIFF_WEICKERT, "WEICKERT") (cv::KAZE::DIFF_CHARBONNIER, "CHARBONNIER"); /// AKAZE descriptor type const ConstMap<std::string, int> AKAZEDescriptorType = ConstMap<std::string, int> ("KAZEUpright", cv::AKAZE::DESCRIPTOR_KAZE_UPRIGHT) ("KAZE", cv::AKAZE::DESCRIPTOR_KAZE) ("MLDBUpright", cv::AKAZE::DESCRIPTOR_MLDB_UPRIGHT) ("MLDB", cv::AKAZE::DESCRIPTOR_MLDB); /// inverse AKAZE descriptor type const ConstMap<int, std::string> AKAZEDescriptorTypeInv = ConstMap<int, std::string> (cv::AKAZE::DESCRIPTOR_KAZE_UPRIGHT, "KAZEUpright") (cv::AKAZE::DESCRIPTOR_KAZE, "KAZE") (cv::AKAZE::DESCRIPTOR_MLDB_UPRIGHT, "MLDBUpright") (cv::AKAZE::DESCRIPTOR_MLDB, "MLDB"); /// AGAST neighborhood types const ConstMap<std::string, int> AgastTypeMap = ConstMap<std::string, int> ("AGAST_5_8", cv::AgastFeatureDetector::AGAST_5_8) ("AGAST_7_12d", cv::AgastFeatureDetector::AGAST_7_12d) ("AGAST_7_12s", cv::AgastFeatureDetector::AGAST_7_12s) ("OAST_9_16", cv::AgastFeatureDetector::OAST_9_16); /// inverse AGAST neighborhood types const ConstMap<int, std::string> AgastTypeInvMap = ConstMap<int, std::string> (cv::AgastFeatureDetector::AGAST_5_8, "AGAST_5_8") (cv::AgastFeatureDetector::AGAST_7_12d, "AGAST_7_12d") (cv::AgastFeatureDetector::AGAST_7_12s, "AGAST_7_12s") (cv::AgastFeatureDetector::OAST_9_16, "OAST_9_16"); #ifdef HAVE_OPENCV_XFEATURES2D /// DAISY normalization types const ConstMap<std::string, int> DAISYNormType = ConstMap<std::string, int> ("None", cv::xfeatures2d::DAISY::NRM_NONE) ("Partial", cv::xfeatures2d::DAISY::NRM_PARTIAL) ("Full", cv::xfeatures2d::DAISY::NRM_FULL) ("SIFT", cv::xfeatures2d::DAISY::NRM_SIFT); /// inverse DAISY normalization types const ConstMap<int, std::string> DAISYNormTypeInv = ConstMap<int, std::string> (cv::xfeatures2d::DAISY::NRM_NONE, "None") (cv::xfeatures2d::DAISY::NRM_PARTIAL, "Partial") (cv::xfeatures2d::DAISY::NRM_FULL, "Full") (cv::xfeatures2d::DAISY::NRM_SIFT, "SIFT"); #endif /** Create an instance of BRISK using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::BRISK */ cv::Ptr<cv::BRISK> createBRISK( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of ORB using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::ORB */ cv::Ptr<cv::ORB> createORB( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of MSER using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::MSER */ cv::Ptr<cv::MSER> createMSER( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of FastFeatureDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::FastFeatureDetector */ cv::Ptr<cv::FastFeatureDetector> createFastFeatureDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of GFTTDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::GFTTDetector */ cv::Ptr<cv::GFTTDetector> createGFTTDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of SimpleBlobDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::SimpleBlobDetector */ cv::Ptr<cv::SimpleBlobDetector> createSimpleBlobDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of KAZE using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::KAZE */ cv::Ptr<cv::KAZE> createKAZE( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of AKAZE using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::AKAZE */ cv::Ptr<cv::AKAZE> createAKAZE( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of AgastFeatureDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::AgastFeatureDetector */ cv::Ptr<cv::AgastFeatureDetector> createAgastFeatureDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); #ifdef HAVE_OPENCV_XFEATURES2D /** Create an instance of SIFT using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::SIFT */ cv::Ptr<cv::xfeatures2d::SIFT> createSIFT( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of SURF using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::SURF */ cv::Ptr<cv::xfeatures2d::SURF> createSURF( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of FREAK using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::FREAK */ cv::Ptr<cv::xfeatures2d::FREAK> createFREAK( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of StarDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::StarDetector */ cv::Ptr<cv::xfeatures2d::StarDetector> createStarDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of BriefDescriptorExtractor using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::BriefDescriptorExtractor */ cv::Ptr<cv::xfeatures2d::BriefDescriptorExtractor> createBriefDescriptorExtractor( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of LUCID using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::LUCID */ cv::Ptr<cv::xfeatures2d::LUCID> createLUCID( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of LATCH using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::LATCH */ cv::Ptr<cv::xfeatures2d::LATCH> createLATCH( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of DAISY using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::DAISY */ cv::Ptr<cv::xfeatures2d::DAISY> createDAISY( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of MSDDetector using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::xfeatures2d::MSDDetector */ cv::Ptr<cv::xfeatures2d::MSDDetector> createMSDDetector( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); #endif /** Factory function for FeatureDetector creation * @param type feature detector type, one of: * - "BRISK" * - "ORB" * - "MSER" * - "FastFeatureDetector" * - "GFTTDetector" * - "SimpleBlobDetector" * - "KAZE" * - "AKAZE" * - "AgastFeatureDetector" * - "SIFT" (requires `xfeatures2d` module) * - "SURF" (requires `xfeatures2d` module) * - "StarDetector" (requires `xfeatures2d` module) * - "MSDDetector" (requires `xfeatures2d` module) * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::FeatureDetector */ cv::Ptr<cv::FeatureDetector> createFeatureDetector( const std::string& type, std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Factory function for DescriptorExtractor creation * @param type descriptor extractor type, one of: * - "BRISK" * - "ORB" * - "KAZE" * - "AKAZE" * - "SIFT" (requires `xfeatures2d` module) * - "SURF" (requires `xfeatures2d` module) * - "FREAK" (requires `xfeatures2d` module) * - "BriefDescriptorExtractor" (requires `xfeatures2d` module) * - "LUCID" (requires `xfeatures2d` module) * - "LATCH" (requires `xfeatures2d` module) * - "DAISY" (requires `xfeatures2d` module) * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::DescriptorExtractor */ cv::Ptr<cv::DescriptorExtractor> createDescriptorExtractor( const std::string& type, std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); // ==================== Descriptor Matching ==================== /** Create an instance of FlannBasedMatcher using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::FlannBasedMatcher */ cv::Ptr<cv::FlannBasedMatcher> createFlannBasedMatcher( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Create an instance of BFMatcher using options in arguments * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::BFMatcher */ cv::Ptr<cv::BFMatcher> createBFMatcher( std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); /** Factory function for DescriptorMatcher creation * @param type descriptor matcher type, one of: * - "BruteForce" * - "BruteForce-L1" * - "BruteForce-SL2" * - "BruteForce-Hamming" or "BruteForce-HammingLUT" * - "BruteForce-Hamming(2)" * - "FlannBased" * . * Or: * - "FlannBasedMatcher" * - "BFMatcher" * . * The last two matcher types are the ones that accept extra arguments * passed to the corresponding create functions. * @param first iterator at the beginning of the vector range * @param last iterator at the end of the vector range * @return smart pointer to an instance cv::DescriptorMatcher */ cv::Ptr<cv::DescriptorMatcher> createDescriptorMatcher( const std::string& type, std::vector<MxArray>::const_iterator first, std::vector<MxArray>::const_iterator last); #endif
[ "amroamroamro@gmail.com" ]
amroamroamro@gmail.com
9671c38bffa5fadbb6346b6823fa9fa4a3133373
e7554d214590aa3e6975524f95eccf85ebdaa64b
/dbscan_demo/demo.cpp
5d6564d08392c998ec8458cc73fa15737fe63f36
[]
no_license
huyquangvevo/DBSCAN-Parallel
70834fe3035f15fa4bbf2bb4f1ca0931fd87210a
53c180e0061997db39a0e9d27dc63c06fa55a324
refs/heads/master
2021-06-24T18:49:06.993342
2021-04-17T16:48:02
2021-04-17T16:48:02
218,655,494
0
0
null
null
null
null
UTF-8
C++
false
false
213
cpp
#include<vector> using namespace std; int main(){ vector<vector<int>> c; vector<int> p; p.push_back(0); p.push_back(2); p.push_back(4); p.push_back(3); c.push_back(p); return 0; }
[ "quanghuy27101997@gmail.com" ]
quanghuy27101997@gmail.com
7f5bb8266bd52a35f012e6a2314d184634d606e9
bbdccf4473b6c0beff578ae69499f12dbf8a9c3f
/export/windows/cpp/obj/src/Personaje.cpp
ebbe143c017bc182098e987158446db4aa1d002b
[]
no_license
IanFrancolol/Space-Invoders-
706fefb7b09fc88b5827a9151803d362dd11a12b
e2878956b346477fafc485cbf059602b02ef4eef
refs/heads/master
2021-07-01T03:39:02.364296
2017-09-20T15:15:48
2017-09-20T15:15:48
103,409,940
0
0
null
null
null
null
UTF-8
C++
false
true
11,429
cpp
// Generated by Haxe 3.4.2 (git build master @ 890f8c7) #include <hxcpp.h> #ifndef INCLUDED_Bala #include <Bala.h> #endif #ifndef INCLUDED_Personaje #include <Personaje.h> #endif #ifndef INCLUDED_flixel_FlxBasic #include <flixel/FlxBasic.h> #endif #ifndef INCLUDED_flixel_FlxG #include <flixel/FlxG.h> #endif #ifndef INCLUDED_flixel_FlxGame #include <flixel/FlxGame.h> #endif #ifndef INCLUDED_flixel_FlxObject #include <flixel/FlxObject.h> #endif #ifndef INCLUDED_flixel_FlxSprite #include <flixel/FlxSprite.h> #endif #ifndef INCLUDED_flixel_FlxState #include <flixel/FlxState.h> #endif #ifndef INCLUDED_flixel_group_FlxTypedGroup #include <flixel/group/FlxTypedGroup.h> #endif #ifndef INCLUDED_flixel_input_FlxBaseKeyList #include <flixel/input/FlxBaseKeyList.h> #endif #ifndef INCLUDED_flixel_input_FlxKeyManager #include <flixel/input/FlxKeyManager.h> #endif #ifndef INCLUDED_flixel_input_IFlxInputManager #include <flixel/input/IFlxInputManager.h> #endif #ifndef INCLUDED_flixel_input_keyboard_FlxKeyList #include <flixel/input/keyboard/FlxKeyList.h> #endif #ifndef INCLUDED_flixel_input_keyboard_FlxKeyboard #include <flixel/input/keyboard/FlxKeyboard.h> #endif #ifndef INCLUDED_flixel_util_IFlxDestroyable #include <flixel/util/IFlxDestroyable.h> #endif #ifndef INCLUDED_openfl__legacy_display_DisplayObject #include <openfl/_legacy/display/DisplayObject.h> #endif #ifndef INCLUDED_openfl__legacy_display_DisplayObjectContainer #include <openfl/_legacy/display/DisplayObjectContainer.h> #endif #ifndef INCLUDED_openfl__legacy_display_IBitmapDrawable #include <openfl/_legacy/display/IBitmapDrawable.h> #endif #ifndef INCLUDED_openfl__legacy_display_InteractiveObject #include <openfl/_legacy/display/InteractiveObject.h> #endif #ifndef INCLUDED_openfl__legacy_display_Sprite #include <openfl/_legacy/display/Sprite.h> #endif #ifndef INCLUDED_openfl__legacy_events_EventDispatcher #include <openfl/_legacy/events/EventDispatcher.h> #endif #ifndef INCLUDED_openfl__legacy_events_IEventDispatcher #include <openfl/_legacy/events/IEventDispatcher.h> #endif HX_DEFINE_STACK_FRAME(_hx_pos_afe0a5609aa5ed3f_11_new,"Personaje","new",0xf5311b39,"Personaje.new","Personaje.hx",11,0x8643ee57) HX_LOCAL_STACK_FRAME(_hx_pos_afe0a5609aa5ed3f_21_update,"Personaje","update",0xb381c8d0,"Personaje.update","Personaje.hx",21,0x8643ee57) HX_LOCAL_STACK_FRAME(_hx_pos_afe0a5609aa5ed3f_29_movimiento,"Personaje","movimiento",0x30823a9c,"Personaje.movimiento","Personaje.hx",29,0x8643ee57) HX_LOCAL_STACK_FRAME(_hx_pos_afe0a5609aa5ed3f_42_checkLimite,"Personaje","checkLimite",0xfee5538b,"Personaje.checkLimite","Personaje.hx",42,0x8643ee57) HX_LOCAL_STACK_FRAME(_hx_pos_afe0a5609aa5ed3f_61_Disparar,"Personaje","Disparar",0x6e3bc72b,"Personaje.Disparar","Personaje.hx",61,0x8643ee57) void Personaje_obj::__construct( ::Dynamic __o_X, ::Dynamic __o_Y, ::Dynamic SimpleGraphic){ ::Dynamic X = __o_X.Default(0); ::Dynamic Y = __o_Y.Default(0); HX_STACKFRAME(&_hx_pos_afe0a5609aa5ed3f_11_new) HXLINE( 14) this->checkDisparo = false; HXLINE( 17) super::__construct(X,Y,SimpleGraphic); } Dynamic Personaje_obj::__CreateEmpty() { return new Personaje_obj; } void *Personaje_obj::_hx_vtable = 0; Dynamic Personaje_obj::__Create(hx::DynamicArray inArgs) { hx::ObjectPtr< Personaje_obj > _hx_result = new Personaje_obj(); _hx_result->__construct(inArgs[0],inArgs[1],inArgs[2]); return _hx_result; } bool Personaje_obj::_hx_isInstanceOf(int inClassId) { if (inClassId<=(int)0x25a685e0) { if (inClassId<=(int)0x0b6ffd77) { return inClassId==(int)0x00000001 || inClassId==(int)0x0b6ffd77; } else { return inClassId==(int)0x25a685e0; } } else { return inClassId==(int)0x2e105115 || inClassId==(int)0x2e6b0ac7; } } void Personaje_obj::update(Float elapsed){ HX_STACKFRAME(&_hx_pos_afe0a5609aa5ed3f_21_update) HXLINE( 22) this->super::update(elapsed); HXLINE( 23) this->movimiento(); HXLINE( 24) this->checkLimite(); HXLINE( 25) this->Disparar(); } void Personaje_obj::movimiento(){ HX_STACKFRAME(&_hx_pos_afe0a5609aa5ed3f_29_movimiento) HXLINE( 30) int velocidad = (int)4; HXLINE( 32) ::flixel::input::keyboard::FlxKeyList _this = ( ( ::flixel::input::keyboard::FlxKeyList)(::flixel::FlxG_obj::keys->pressed) ); HXDLIN( 32) if (_this->keyManager->checkStatus((int)39,_this->status)) { HXLINE( 34) Float _hx_tmp = this->x; HXDLIN( 34) this->set_x((_hx_tmp + ((velocidad * ::flixel::FlxG_obj::elapsed) * ::flixel::FlxG_obj::updateFramerate))); } HXLINE( 36) ::flixel::input::keyboard::FlxKeyList _this1 = ( ( ::flixel::input::keyboard::FlxKeyList)(::flixel::FlxG_obj::keys->pressed) ); HXDLIN( 36) if (_this1->keyManager->checkStatus((int)37,_this1->status)) { HXLINE( 38) Float _hx_tmp1 = this->x; HXDLIN( 38) this->set_x((_hx_tmp1 - ((velocidad * ::flixel::FlxG_obj::elapsed) * ::flixel::FlxG_obj::updateFramerate))); } } HX_DEFINE_DYNAMIC_FUNC0(Personaje_obj,movimiento,(void)) void Personaje_obj::checkLimite(){ HX_STACKFRAME(&_hx_pos_afe0a5609aa5ed3f_42_checkLimite) HXLINE( 43) if ((this->x < (int)0)) { HXLINE( 45) this->set_x((int)0); } else { HXLINE( 47) Float _hx_tmp = this->x; HXDLIN( 47) int _hx_tmp1 = ::flixel::FlxG_obj::width; HXDLIN( 47) if ((_hx_tmp > (_hx_tmp1 - this->get_width()))) { HXLINE( 49) int _hx_tmp2 = ::flixel::FlxG_obj::width; HXDLIN( 49) this->set_x((_hx_tmp2 - this->get_width())); } } HXLINE( 51) if ((this->y < (int)0)) { HXLINE( 53) this->set_y((int)0); } else { HXLINE( 55) Float _hx_tmp3 = this->y; HXDLIN( 55) int _hx_tmp4 = ::flixel::FlxG_obj::height; HXDLIN( 55) if ((_hx_tmp3 > (_hx_tmp4 - this->get_height()))) { HXLINE( 57) int _hx_tmp5 = ::flixel::FlxG_obj::height; HXDLIN( 57) this->set_y((_hx_tmp5 - this->get_height())); } } } HX_DEFINE_DYNAMIC_FUNC0(Personaje_obj,checkLimite,(void)) void Personaje_obj::Disparar(){ HX_GC_STACKFRAME(&_hx_pos_afe0a5609aa5ed3f_61_Disparar) HXLINE( 62) this->bala = ::Bala_obj::__alloc( HX_CTX ,((Float)this->x / (Float)(int)2),this->y,HX_("assets/images/bala.png",da,83,43,8c)); HXLINE( 63) ::flixel::FlxG_obj::game->_state->add(this->bala).StaticCast< ::flixel::FlxBasic >(); } HX_DEFINE_DYNAMIC_FUNC0(Personaje_obj,Disparar,(void)) hx::ObjectPtr< Personaje_obj > Personaje_obj::__new( ::Dynamic __o_X, ::Dynamic __o_Y, ::Dynamic SimpleGraphic) { hx::ObjectPtr< Personaje_obj > __this = new Personaje_obj(); __this->__construct(__o_X,__o_Y,SimpleGraphic); return __this; } hx::ObjectPtr< Personaje_obj > Personaje_obj::__alloc(hx::Ctx *_hx_ctx, ::Dynamic __o_X, ::Dynamic __o_Y, ::Dynamic SimpleGraphic) { Personaje_obj *__this = (Personaje_obj*)(hx::Ctx::alloc(_hx_ctx, sizeof(Personaje_obj), true, "Personaje")); *(void **)__this = Personaje_obj::_hx_vtable; __this->__construct(__o_X,__o_Y,SimpleGraphic); return __this; } Personaje_obj::Personaje_obj() { } void Personaje_obj::__Mark(HX_MARK_PARAMS) { HX_MARK_BEGIN_CLASS(Personaje); HX_MARK_MEMBER_NAME(bala,"bala"); HX_MARK_MEMBER_NAME(checkDisparo,"checkDisparo"); ::flixel::FlxSprite_obj::__Mark(HX_MARK_ARG); HX_MARK_END_CLASS(); } void Personaje_obj::__Visit(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(bala,"bala"); HX_VISIT_MEMBER_NAME(checkDisparo,"checkDisparo"); ::flixel::FlxSprite_obj::__Visit(HX_VISIT_ARG); } hx::Val Personaje_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp) { switch(inName.length) { case 4: if (HX_FIELD_EQ(inName,"bala") ) { return hx::Val( bala ); } break; case 6: if (HX_FIELD_EQ(inName,"update") ) { return hx::Val( update_dyn() ); } break; case 8: if (HX_FIELD_EQ(inName,"Disparar") ) { return hx::Val( Disparar_dyn() ); } break; case 10: if (HX_FIELD_EQ(inName,"movimiento") ) { return hx::Val( movimiento_dyn() ); } break; case 11: if (HX_FIELD_EQ(inName,"checkLimite") ) { return hx::Val( checkLimite_dyn() ); } break; case 12: if (HX_FIELD_EQ(inName,"checkDisparo") ) { return hx::Val( checkDisparo ); } } return super::__Field(inName,inCallProp); } hx::Val Personaje_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp) { switch(inName.length) { case 4: if (HX_FIELD_EQ(inName,"bala") ) { bala=inValue.Cast< ::Bala >(); return inValue; } break; case 12: if (HX_FIELD_EQ(inName,"checkDisparo") ) { checkDisparo=inValue.Cast< bool >(); return inValue; } } return super::__SetField(inName,inValue,inCallProp); } void Personaje_obj::__GetFields(Array< ::String> &outFields) { outFields->push(HX_HCSTRING("bala","\xf4","\xe1","\x10","\x41")); outFields->push(HX_HCSTRING("checkDisparo","\x54","\x98","\xc8","\xa8")); super::__GetFields(outFields); }; #if HXCPP_SCRIPTABLE static hx::StorageInfo Personaje_obj_sMemberStorageInfo[] = { {hx::fsObject /*::Bala*/ ,(int)offsetof(Personaje_obj,bala),HX_HCSTRING("bala","\xf4","\xe1","\x10","\x41")}, {hx::fsBool,(int)offsetof(Personaje_obj,checkDisparo),HX_HCSTRING("checkDisparo","\x54","\x98","\xc8","\xa8")}, { hx::fsUnknown, 0, null()} }; static hx::StaticInfo *Personaje_obj_sStaticStorageInfo = 0; #endif static ::String Personaje_obj_sMemberFields[] = { HX_HCSTRING("bala","\xf4","\xe1","\x10","\x41"), HX_HCSTRING("checkDisparo","\x54","\x98","\xc8","\xa8"), HX_HCSTRING("update","\x09","\x86","\x05","\x87"), HX_HCSTRING("movimiento","\x55","\x88","\xff","\x0e"), HX_HCSTRING("checkLimite","\xb2","\x07","\x0c","\xce"), HX_HCSTRING("Disparar","\xa4","\x04","\x14","\xf8"), ::String(null()) }; static void Personaje_obj_sMarkStatics(HX_MARK_PARAMS) { HX_MARK_MEMBER_NAME(Personaje_obj::__mClass,"__mClass"); }; #ifdef HXCPP_VISIT_ALLOCS static void Personaje_obj_sVisitStatics(HX_VISIT_PARAMS) { HX_VISIT_MEMBER_NAME(Personaje_obj::__mClass,"__mClass"); }; #endif hx::Class Personaje_obj::__mClass; void Personaje_obj::__register() { hx::Object *dummy = new Personaje_obj; Personaje_obj::_hx_vtable = *(void **)dummy; hx::Static(__mClass) = new hx::Class_obj(); __mClass->mName = HX_HCSTRING("Personaje","\xc7","\x0a","\x6b","\x2e"); __mClass->mSuper = &super::__SGetClass(); __mClass->mConstructEmpty = &__CreateEmpty; __mClass->mConstructArgs = &__Create; __mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField; __mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField; __mClass->mMarkFunc = Personaje_obj_sMarkStatics; __mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */); __mClass->mMembers = hx::Class_obj::dupFunctions(Personaje_obj_sMemberFields); __mClass->mCanCast = hx::TCanCast< Personaje_obj >; #ifdef HXCPP_VISIT_ALLOCS __mClass->mVisitFunc = Personaje_obj_sVisitStatics; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mMemberStorageInfo = Personaje_obj_sMemberStorageInfo; #endif #ifdef HXCPP_SCRIPTABLE __mClass->mStaticStorageInfo = Personaje_obj_sStaticStorageInfo; #endif hx::_hx_RegisterClass(__mClass->mName, __mClass); }
[ "theoleyenda1997@gmail.com" ]
theoleyenda1997@gmail.com
d19c19697ba1ba0cb325cce2ff8f9750a557fcc2
a8691bc4dcb296fadf1e77fe3847a7f2de8751f1
/variable_resistor.ino
9c9bbc9384c0fa31a9311a0c55bb4adf09f83fa8
[]
no_license
Justin900429/basic-circuit
96efd63da1f7cb2c9d96cc283427f882b8864de8
80f32d935a38942ce1650a152bf648c84e3a9b26
refs/heads/main
2023-06-20T00:10:53.827587
2021-07-04T07:06:30
2021-07-04T07:06:30
382,784,644
0
1
null
null
null
null
UTF-8
C++
false
false
243
ino
// ADD // 換行顯示 void setup() { Serial.begin(9600); // 序列通訊速度為9600位元 } void loop() { Serial.println(analogRead(A0)); // 換行(ln) // analogRead(A0) 讀取腳位A0的數值 delay(500); // 每0.5秒讀一次 }
[ "justin900429@gmail.com" ]
justin900429@gmail.com
2c597ad872582d988dad5f1203246254c007bfb9
d84967ba1e6adc72e120f84524c51ad57912df5a
/devel/electron10/files/patch-ui_views_controls_textfield_textfield.cc
ca8a5645839d2efad2ececa0d32804e7679e22f9
[]
no_license
tagattie/FreeBSD-Electron
f191d03c067d03ad3007e7748de905da06ba67f9
af26f766e772bb04db5eb95148ee071101301e4e
refs/heads/master
2023-09-04T10:56:17.446818
2023-09-04T09:03:11
2023-09-04T09:03:11
176,520,396
73
9
null
2023-08-31T03:29:16
2019-03-19T13:41:20
C++
UTF-8
C++
false
false
3,064
cc
--- ui/views/controls/textfield/textfield.cc.orig 2020-09-21 18:40:09 UTC +++ ui/views/controls/textfield/textfield.cc @@ -64,7 +64,7 @@ #include "base/win/win_util.h" #endif -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_BSD) #include "ui/base/ime/linux/text_edit_command_auralinux.h" // nogncheck #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" // nogncheck #endif @@ -185,14 +185,14 @@ ui::TextEditCommand GetCommandForKeyEvent(const ui::Ke #endif return ui::TextEditCommand::DELETE_BACKWARD; } -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_BSD) // Only erase by line break on Linux and ChromeOS. if (shift) return ui::TextEditCommand::DELETE_TO_BEGINNING_OF_LINE; #endif return ui::TextEditCommand::DELETE_WORD_BACKWARD; case ui::VKEY_DELETE: -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_BSD) // Only erase by line break on Linux and ChromeOS. if (shift && control) return ui::TextEditCommand::DELETE_TO_END_OF_LINE; @@ -260,7 +260,7 @@ bool IsControlKeyModifier(int flags) { // Control-modified key combination, but we cannot extend it to other platforms // as Control has different meanings and behaviors. // https://crrev.com/2580483002/#msg46 -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_BSD) return flags & ui::EF_CONTROL_DOWN; #else return false; @@ -717,7 +717,7 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& e #endif } -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if (defined(OS_LINUX) || defined(OS_BSD)) && !defined(OS_CHROMEOS) if (!handled && !had_focus && event.IsOnlyMiddleMouseButton()) RequestFocusWithPointer(ui::EventPointerType::kMouse); #endif @@ -763,7 +763,7 @@ bool Textfield::OnKeyPressed(const ui::KeyEvent& event if (!textfield) return handled; -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if (defined(OS_LINUX) || defined(OS_BSD)) && !defined(OS_CHROMEOS) ui::TextEditKeyBindingsDelegateAuraLinux* delegate = ui::GetTextEditKeyBindingsDelegate(); std::vector<ui::TextEditCommandAuraLinux> commands; @@ -915,7 +915,7 @@ void Textfield::AboutToRequestFocusFromTabTraversal(bo } bool Textfield::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if (defined(OS_LINUX) || defined(OS_BSD)) && !defined(OS_CHROMEOS) // Skip any accelerator handling that conflicts with custom keybindings. ui::TextEditKeyBindingsDelegateAuraLinux* delegate = ui::GetTextEditKeyBindingsDelegate(); @@ -2202,7 +2202,7 @@ bool Textfield::PasteSelectionClipboard() { } void Textfield::UpdateSelectionClipboard() { -#if defined(OS_LINUX) && !defined(OS_CHROMEOS) +#if (defined(OS_LINUX) || defined(OS_BSD)) && !defined(OS_CHROMEOS) if (text_input_type_ != ui::TEXT_INPUT_TYPE_PASSWORD) { ui::ScopedClipboardWriter(ui::ClipboardBuffer::kSelection) .WriteText(GetSelectedText());
[ "tagattie@gmail.com" ]
tagattie@gmail.com
382a9bf64da7a1f108913d130870b72dabbbfd89
ead41ea55240a4d36eb70a5beb33deeeb9bf6736
/mbed-os-test-program2/main2.cpp
902d1e676b8de6543709062945c2a3cf73754bcc
[]
no_license
EvanLu0815/mbed0
d33d1aba7aff6e251ce846fa0c324d4800ec382d
0f3beb2a39439bc46bc03e41a968354321f3e907
refs/heads/master
2021-02-15T02:05:33.009837
2020-03-11T02:52:08
2020-03-11T02:52:08
244,854,136
0
0
null
null
null
null
UTF-8
C++
false
false
246
cpp
#include "mbed.h" //#include "led.h" DigitalOut redLED(LED_RED); DigitalOut greenLED(LED_GREEN); int Led(DigitalOut& ledpin); int main() { redLED = 1; greenLED = 1; while (true) { Led(redLED); Led(greenLED); } }
[ "rabbit94212@gmail.com" ]
rabbit94212@gmail.com
a731a6845a20841fe7d0c5c6b441ae70ff7903f3
f3131ad1937b6dd660929e2a350a3381adc728c1
/src/sim.h
a5ed6540df01f2a53fbe1f53393897a564f16164
[]
no_license
APN-Pucky/sr5sim
d1dbb52bca8c643538da7896565c30aadd7220eb
c7d47a0a919c6c8b44d98eacdaac9153c5d8de96
refs/heads/master
2020-06-04T16:45:34.024510
2019-06-25T16:49:57
2019-06-25T16:49:57
192,109,175
0
0
null
null
null
null
UTF-8
C++
false
false
689
h
#include <vector> #include <iostream> #include <string> #include <initializer_list> #include "character.h" #include "debug.h" using namespace std; struct SimulationData { int wins=0; int stalls=0; int losses=0; vector<int> data; SimulationData& operator+=(const SimulationData& sim) { _DEBUG_ASSERT(sim.data.size()==data.size()); wins += sim.wins; stalls += sim.stalls; losses += sim.losses; for(int i = 0; i < sim.data.size();++i) data[i] += sim.data[i]; return *this; } void reset() { wins =0; losses =0; stalls=0; data.clear(); } }; using SimData = SimulationData; void simulate(SimData& sd,std::vector<Character> chars, bool data =false);
[ "APN-Pucky@users.noreply.github.com" ]
APN-Pucky@users.noreply.github.com
fa011f1a6e3038cf6ba0d4baf413645bccedb446
3fef56efe52dd97c4942d8b8021d69c28b8b4e1e
/Problemset/1355B - Young Explorers.cpp
2119dfeaf89b6c6a18622e81b879366c3f44df8b
[]
no_license
naiyer-abbas/Code-Forces
384850c939b4243499ffd446092ff69a3e3ea8b0
aca143949efe1583cdc9c8f71cb0e21b5d14fa1e
refs/heads/master
2023-05-07T00:53:17.811357
2021-05-26T17:48:37
2021-05-26T17:48:37
327,666,421
3
0
null
null
null
null
UTF-8
C++
false
false
796
cpp
#pragma GCC optimize("O2") #include <bits/stdc++.h> using namespace std; #define ll long long int #define ull unsigned long long int #define pb push_back #define mp make_pair #define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); #define MOD 1000000007 int main() { fast; int t; cin >> t; while(t--) { int n; cin >> n; vector <int> v(n); map <int, int> um; for(auto &e : v) { cin >> e; um[e] ++; } int groups = 0; int left = 0; for(auto &e : um) { e.second += left; groups += e.second / e.first; left = e.second - (e.first * (e.second / e.first)); } cout << groups << endl; } }
[ "nairabbas123@gmail.com" ]
nairabbas123@gmail.com
865bade3a141f37acaa0d5097b25b06c5e20c51f
1cc17e9f4c3b6fba21aef3af5e900c80cfa98051
/chrome/browser/process_singleton_win.cc
3a259fec3acdbaf247770c482829fa4eeae25e96
[ "BSD-3-Clause" ]
permissive
sharpglasses/BitPop
2643a39b76ab71d1a2ed5b9840217b0e9817be06
1fae4ecfb965e163f6ce154b3988b3181678742a
refs/heads/master
2021-01-21T16:04:02.854428
2013-03-22T02:12:27
2013-03-22T02:12:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
15,116
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/process_singleton.h" #include "base/base_paths.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/path_service.h" #include "base/process_util.h" #include "base/utf_string_conversions.h" #include "base/win/scoped_handle.h" #include "base/win/wrapped_window_proc.h" #include "chrome/browser/ui/simple_message_box.h" #include "chrome/common/chrome_constants.h" #include "chrome/installer/util/wmi.h" #include "content/public/common/result_codes.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/win/hwnd_util.h" namespace { const char kLockfile[] = "lockfile"; // Checks the visibility of the enumerated window and signals once a visible // window has been found. BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { bool* result = reinterpret_cast<bool*>(param); *result = IsWindowVisible(window) != 0; // Stops enumeration if a visible window has been found. return !*result; } // This function thunks to the object's version of the windowproc, taking in // consideration that there are several messages being dispatched before // WM_NCCREATE which we let windows handle. LRESULT CALLBACK ThunkWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { ProcessSingleton* singleton = reinterpret_cast<ProcessSingleton*>(ui::GetWindowUserData(hwnd)); if (message == WM_NCCREATE) { CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lparam); singleton = reinterpret_cast<ProcessSingleton*>(cs->lpCreateParams); CHECK(singleton); ui::SetWindowUserData(hwnd, singleton); } else if (!singleton) { return ::DefWindowProc(hwnd, message, wparam, lparam); } return singleton->WndProc(hwnd, message, wparam, lparam); } bool ParseCommandLine(const COPYDATASTRUCT* cds, CommandLine* parsed_command_line, FilePath* current_directory) { // We should have enough room for the shortest command (min_message_size) // and also be a multiple of wchar_t bytes. The shortest command // possible is L"START\0\0" (empty current directory and command line). static const int min_message_size = 7; if (cds->cbData < min_message_size * sizeof(wchar_t) || cds->cbData % sizeof(wchar_t) != 0) { LOG(WARNING) << "Invalid WM_COPYDATA, length = " << cds->cbData; return false; } // We split the string into 4 parts on NULLs. DCHECK(cds->lpData); const std::wstring msg(static_cast<wchar_t*>(cds->lpData), cds->cbData / sizeof(wchar_t)); const std::wstring::size_type first_null = msg.find_first_of(L'\0'); if (first_null == 0 || first_null == std::wstring::npos) { // no NULL byte, don't know what to do LOG(WARNING) << "Invalid WM_COPYDATA, length = " << msg.length() << ", first null = " << first_null; return false; } // Decode the command, which is everything until the first NULL. if (msg.substr(0, first_null) == L"START") { // Another instance is starting parse the command line & do what it would // have done. VLOG(1) << "Handling STARTUP request from another process"; const std::wstring::size_type second_null = msg.find_first_of(L'\0', first_null + 1); if (second_null == std::wstring::npos || first_null == msg.length() - 1 || second_null == msg.length()) { LOG(WARNING) << "Invalid format for start command, we need a string in 4 " "parts separated by NULLs"; return false; } // Get current directory. *current_directory = FilePath(msg.substr(first_null + 1, second_null - first_null)); const std::wstring::size_type third_null = msg.find_first_of(L'\0', second_null + 1); if (third_null == std::wstring::npos || third_null == msg.length()) { LOG(WARNING) << "Invalid format for start command, we need a string in 4 " "parts separated by NULLs"; } // Get command line. const std::wstring cmd_line = msg.substr(second_null + 1, third_null - second_null); *parsed_command_line = CommandLine::FromString(cmd_line); return true; } return false; } } // namespace // Microsoft's Softricity virtualization breaks the sandbox processes. // So, if we detect the Softricity DLL we use WMI Win32_Process.Create to // break out of the virtualization environment. // http://code.google.com/p/chromium/issues/detail?id=43650 bool ProcessSingleton::EscapeVirtualization(const FilePath& user_data_dir) { if (::GetModuleHandle(L"sftldr_wow64.dll") || ::GetModuleHandle(L"sftldr.dll")) { int process_id; if (!installer::WMIProcess::Launch(GetCommandLineW(), &process_id)) return false; is_virtualized_ = true; // The new window was spawned from WMI, and won't be in the foreground. // So, first we sleep while the new chrome.exe instance starts (because // WaitForInputIdle doesn't work here). Then we poll for up to two more // seconds and make the window foreground if we find it (or we give up). HWND hwnd = 0; ::Sleep(90); for (int tries = 200; tries; --tries) { hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, user_data_dir.value().c_str()); if (hwnd) { ::SetForegroundWindow(hwnd); break; } ::Sleep(10); } return true; } return false; } // Look for a Chrome instance that uses the same profile directory. // If there isn't one, create a message window with its title set to // the profile directory path. ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) : window_(NULL), locked_(false), foreground_window_(NULL), is_virtualized_(false), lock_file_(INVALID_HANDLE_VALUE) { remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, user_data_dir.value().c_str()); if (!remote_window_ && !EscapeVirtualization(user_data_dir)) { // Make sure we will be the one and only process creating the window. // We use a named Mutex since we are protecting against multi-process // access. As documented, it's clearer to NOT request ownership on creation // since it isn't guaranteed we will get it. It is better to create it // without ownership and explicitly get the ownership afterward. std::wstring mutex_name(L"Local\\ChromeProcessSingletonStartup!"); base::win::ScopedHandle only_me( CreateMutex(NULL, FALSE, mutex_name.c_str())); DCHECK(only_me.Get() != NULL) << "GetLastError = " << GetLastError(); // This is how we acquire the mutex (as opposed to the initial ownership). DWORD result = WaitForSingleObject(only_me, INFINITE); DCHECK(result == WAIT_OBJECT_0) << "Result = " << result << "GetLastError = " << GetLastError(); // We now own the mutex so we are the only process that can create the // window at this time, but we must still check if someone created it // between the time where we looked for it above and the time the mutex // was given to us. remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, user_data_dir.value().c_str()); if (!remote_window_) { // We have to make sure there is no Chrome instance running on another // machine that uses the same profile. FilePath lock_file_path = user_data_dir.AppendASCII(kLockfile); lock_file_ = CreateFile(lock_file_path.value().c_str(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL); DWORD error = GetLastError(); LOG_IF(WARNING, lock_file_ != INVALID_HANDLE_VALUE && error == ERROR_ALREADY_EXISTS) << "Lock file exists but is writable."; LOG_IF(ERROR, lock_file_ == INVALID_HANDLE_VALUE) << "Lock file can not be created! Error code: " << error; if (lock_file_ != INVALID_HANDLE_VALUE) { HINSTANCE hinst = base::GetModuleFromAddress(&ThunkWndProc); WNDCLASSEX wc = {0}; wc.cbSize = sizeof(wc); wc.lpfnWndProc = base::win::WrappedWindowProc<ThunkWndProc>; wc.hInstance = hinst; wc.lpszClassName = chrome::kMessageWindowClass; ATOM clazz = ::RegisterClassEx(&wc); DCHECK(clazz); // Set the window's title to the path of our user data directory so // other Chrome instances can decide if they should forward to us. window_ = ::CreateWindow(MAKEINTATOM(clazz), user_data_dir.value().c_str(), 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hinst, this); CHECK(window_); } } BOOL success = ReleaseMutex(only_me); DCHECK(success) << "GetLastError = " << GetLastError(); } } ProcessSingleton::~ProcessSingleton() { // We need to unregister the window as late as possible so that we can detect // another instance of chrome running. Otherwise we may end up writing out // data while a new chrome is starting up. if (window_) { ::DestroyWindow(window_); ::UnregisterClass(chrome::kMessageWindowClass, base::GetModuleFromAddress(&ThunkWndProc)); } if (lock_file_ != INVALID_HANDLE_VALUE) CloseHandle(lock_file_); } ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() { if (is_virtualized_) return PROCESS_NOTIFIED; // We already spawned the process in this case. if (lock_file_ == INVALID_HANDLE_VALUE && !remote_window_) return LOCK_ERROR; else if (!remote_window_) return PROCESS_NONE; // Found another window, send our command line to it // format is "START\0<<<current directory>>>\0<<<commandline>>>". std::wstring to_send(L"START\0", 6); // want the NULL in the string. FilePath cur_dir; if (!PathService::Get(base::DIR_CURRENT, &cur_dir)) return PROCESS_NONE; to_send.append(cur_dir.value()); to_send.append(L"\0", 1); // Null separator. to_send.append(GetCommandLineW()); to_send.append(L"\0", 1); // Null separator. // Allow the current running browser window making itself the foreground // window (otherwise it will just flash in the taskbar). DWORD process_id = 0; DWORD thread_id = GetWindowThreadProcessId(remote_window_, &process_id); // It is possible that the process owning this window may have died by now. if (!thread_id || !process_id) { remote_window_ = NULL; return PROCESS_NONE; } AllowSetForegroundWindow(process_id); COPYDATASTRUCT cds; cds.dwData = 0; cds.cbData = static_cast<DWORD>((to_send.length() + 1) * sizeof(wchar_t)); cds.lpData = const_cast<wchar_t*>(to_send.c_str()); DWORD_PTR result = 0; if (SendMessageTimeout(remote_window_, WM_COPYDATA, NULL, reinterpret_cast<LPARAM>(&cds), SMTO_ABORTIFHUNG, kTimeoutInSeconds * 1000, &result)) { // It is possible that the process owning this window may have died by now. if (!result) { remote_window_ = NULL; return PROCESS_NONE; } return PROCESS_NOTIFIED; } // It is possible that the process owning this window may have died by now. if (!IsWindow(remote_window_)) { remote_window_ = NULL; return PROCESS_NONE; } // The window is hung. Scan for every window to find a visible one. bool visible_window = false; EnumThreadWindows(thread_id, &BrowserWindowEnumeration, reinterpret_cast<LPARAM>(&visible_window)); // If there is a visible browser window, ask the user before killing it. if (visible_window && chrome::ShowMessageBox(NULL, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), l10n_util::GetStringUTF16(IDS_BROWSER_HUNGBROWSER_MESSAGE), chrome::MESSAGE_BOX_TYPE_QUESTION) == chrome::MESSAGE_BOX_RESULT_NO) { // The user denied. Quit silently. return PROCESS_NOTIFIED; } // Time to take action. Kill the browser process. base::KillProcessById(process_id, content::RESULT_CODE_HUNG, true); remote_window_ = NULL; return PROCESS_NONE; } ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessOrCreate( const NotificationCallback& notification_callback) { NotifyResult result = NotifyOtherProcess(); if (result != PROCESS_NONE) return result; return Create(notification_callback) ? PROCESS_NONE : PROFILE_IN_USE; } // On Windows, there is no need to call Create() since the message // window is created in the constructor but to avoid having more // platform specific code in browser_main.cc we tolerate calls to // Create(). bool ProcessSingleton::Create( const NotificationCallback& notification_callback) { DCHECK(!remote_window_); DCHECK(notification_callback_.is_null()); if (window_ != NULL) notification_callback_ = notification_callback; return window_ != NULL; } void ProcessSingleton::Cleanup() { } LRESULT ProcessSingleton::OnCopyData(HWND hwnd, const COPYDATASTRUCT* cds) { // If locked, it means we are not ready to process this message because // we are probably in a first run critical phase. if (locked_) { #if defined(USE_AURA) NOTIMPLEMENTED(); #else // Attempt to place ourselves in the foreground / flash the task bar. if (foreground_window_ != NULL && IsWindow(foreground_window_)) { SetForegroundWindow(foreground_window_); } else { // Read the command line and store it. It will be replayed when the // ProcessSingleton becomes unlocked. CommandLine parsed_command_line(CommandLine::NO_PROGRAM); FilePath current_directory; if (ParseCommandLine(cds, &parsed_command_line, &current_directory)) saved_startup_messages_.push_back( std::make_pair(parsed_command_line.argv(), current_directory)); } #endif return TRUE; } CommandLine parsed_command_line(CommandLine::NO_PROGRAM); FilePath current_directory; if (!ParseCommandLine(cds, &parsed_command_line, &current_directory)) return TRUE; return notification_callback_.Run(parsed_command_line, current_directory) ? TRUE : FALSE; } LRESULT ProcessSingleton::WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { switch (message) { case WM_COPYDATA: return OnCopyData(reinterpret_cast<HWND>(wparam), reinterpret_cast<COPYDATASTRUCT*>(lparam)); default: break; } return ::DefWindowProc(hwnd, message, wparam, lparam); }
[ "vgachkaylo@crystalnix.com" ]
vgachkaylo@crystalnix.com
3e19d6f50d7a81c03ce33b12d35e2bcfa233e285
5827eb058e60272a792b22ad62aba138eaea8e08
/processData.cpp
8f7aed6608cc362f78d515acf36190b375229ec0
[]
no_license
phamtgiang/Algorithm
70dcc79e11982e7680c7d8b714962afa6ab2f0c6
6ebdbb3c3ea79d4ad01428763e6e2ea9003dca97
refs/heads/main
2023-05-13T00:28:50.075109
2021-05-31T02:55:31
2021-05-31T02:55:31
372,365,239
0
0
null
null
null
null
UTF-8
C++
false
false
13,910
cpp
#include "processData.h" /* valgrind --leak-check=full --show-leak-kinds=all ./a.out */ /* TODO: You can implement methods, functions that support your data structures here. * */ using namespace std; void Initialization() { // If you use global variables, please initialize them explicitly in this function. } void Finalization() { // Release your data before exiting } void Request_CL(const char* pRequest, void* &pData, void* &pOutput, int &N) { N = 1; pOutput = new int[N]; *(int*)pOutput = (*(TDataset**)pData)->lines->getSize() - 1; } void Request_CL_cityName(const char* pRequest, void* &pData, void* &pOutput, int &N){ string city_name = pRequest; city_name = city_name.substr(3); bool found = false; int idx; for (int i = 0; i < (*(TDataset**)pData)->cities->getSize()-1; i++) if ((*(TDataset**)pData)->cities->at(i).name == city_name) { idx = i; found = true; break; // get first id of city } // determine id of city via city_name int numberOfLinesInCity = -1; if (found) // if city does not exist , return -1 { numberOfLinesInCity = 0; for (int i = 0; i < (*(TDataset**)pData)->lines->getSize()-1; i++) if ((*(TDataset**)pData)->lines->at(i).city_id == (*(TDataset**)pData)->cities->at(idx).id) numberOfLinesInCity++; // number line in given city } N = 1; pOutput = new int[N]; *(int*)pOutput = numberOfLinesInCity; } void Request_LSC_cityName(const char* pRequest,void* &pData , void* &pOutput, int &N) { string city_name = pRequest; city_name = city_name.substr(4); string id_city ; for (int i = 0; i < (*(TDataset**)pData)->cities->getSize()-1; i++) if ((*(TDataset**)pData)->cities->at(i).name == city_name) { id_city = (*(TDataset**)pData)->cities->at(i).id; // get first id break; } pOutput = new int[10000]; int index = 0; int numberOfStationsInCity = 0; TStation * _stations = new TStation[(*(TDataset**)pData)->stations->getSize()]; (*(TDataset**)pData)->stations->_traverse(_stations,0); for(int i = 0 ; i < (*(TDataset**)pData)->stations->getSize()-1;i++) if(id_city == _stations[i].city_id) { *((int*)pOutput + index) = stoi(_stations[i].id); numberOfStationsInCity++; index++; } delete[] _stations; N = numberOfStationsInCity; } void Request_LLC_cityName(const char* pRequest, void* &pData, void* &pOutput, int &N) { string city_name = pRequest; city_name = city_name.substr(4); string id_city; for (int i = 0; i < (*(TDataset**)pData)->cities->getSize()-1; i++) if ((*(TDataset**)pData)->cities->at(i).name == city_name) { id_city = (*(TDataset**)pData)->cities->at(i).id; // get first id break; } pOutput = new int[1000]; int index = 0; int numberOfLinesInCity = 0; for (int i = 1; i < (*(TDataset**)pData)->lines->getSize()-1; i++) if (id_city == (*(TDataset**)pData)->lines->at(i).city_id) { *((int*)pOutput + index) = stoi((*(TDataset**)pData)->lines->at(i).id); numberOfLinesInCity++; index++; } N = numberOfLinesInCity; } void Request_LSL_lineid(const char* pRequest, void* &pData, void* &pOutput, int &N) { string line_id = pRequest; line_id = line_id.substr(4); pOutput = new int[5000]; int numberOfStation_Line = 0; int index = 0; TStation_line* _station_lines = new TStation_line[(*(TDataset**)pData)->station_lines->getSize()]; (*(TDataset**)pData)->station_lines->_traverse(_station_lines,0); for(int i = 0 ;i < (*(TDataset**)pData)->station_lines->getSize()-1;i++) if(line_id == _station_lines[i].line_id) { *((int*)pOutput + index) = stoi(_station_lines[i].station_id); numberOfStation_Line++; index++; } delete []_station_lines; N = numberOfStation_Line; } void Request_FC_cityName(const char* pRequest, void* &pData , void* &pOutput, int &N) { string city_name = pRequest; city_name = city_name.substr(3); string id_city = "-1"; for (int i = 0; i < (*(TDataset**)pData)->cities->getSize()-1; i++) if ((*(TDataset**)pData)->cities->at(i).name == city_name) { id_city = (*(TDataset**)pData)->cities->at(i).id; break; // get first id } N = 1; pOutput = new int[N]; *(int*)pOutput = stoi(id_city); } void Request_FS_stationName(const char* pRequest, void *&pData, void* &pOutput, int &N)//V { string station_name = pRequest; station_name = station_name.substr(3); string id_station = "-1"; TStation* _stations = new TStation[(*(TDataset**)pData)->stations->getSize()]; (*(TDataset**)pData)->stations->_traverse(_stations,0); for(int i = 0;i < (*(TDataset**)pData)->stations->getSize()-1;i++) if(_stations[i].name == station_name) { id_station = _stations[i].id; break; // get first station_id } delete []_stations; N = 1; pOutput = new int[N]; *(int*)pOutput = stoi(id_station); } void Request_RSL_station_id_line_id(const char* pRequest, void *&pData, void* &pOutput, int &N)//Vi { string pRe = pRequest; string station_id, line_id; int pos[100]; int i = 0; for (int index = 0; index < pRe.size(); index++) if (pRe[index] == ' ') pos[i++] = index + 1; station_id = pRe.substr(pos[0], pos[1] - 1 - pos[0]); line_id = pRe.substr(pos[1]); TStation_line* _station_lines = new TStation_line[(*(TDataset**)pData)->station_lines->getSize()]; (*(TDataset**)pData)->station_lines->_traverse(_station_lines,0); bool remove = false; for(int i = 0 ; i < (*(TDataset**)pData)->station_lines->getSize() - 1 ; i++) if(line_id == _station_lines[i].line_id && station_id == _station_lines[i].station_id) { (*(TDataset**)pData)->station_lines->remove(i); remove = true; break; } delete []_station_lines; N = 1; pOutput = new int[N]; if(remove) *(int*)pOutput = 0; else *(int*)pOutput = -1; } void Request_SLP_station_id_track_id(const char* pRequest, void *&pData, void* &pOutput, int &N)//V { N = 1; pOutput = new int[N]; string pRe = pRequest; string station_id, track_id; int pos[100]; int i = 0; for (int index = 0; index < pRe.size(); index++) if (pRe[index] == ' ') pos[i++] = index + 1; station_id = pRe.substr(pos[0], pos[1] - 1 - pos[0]); track_id = pRe.substr(pos[1]); string _POINT_station; bool found = false; for(int i = 0 ;i < (*(TDataset**)pData)->tracks->getSize()-1;i++) { if(track_id == (*(TDataset**)pData)->tracks->at(i).id) { string LINE =(*(TDataset**)pData)->tracks->at(i).geometry.substr(11); LINE = LINE.substr(0,LINE.size()-1); stringstream LINESTRING(LINE); string point; while(!LINESTRING.eof()) { getline(LINESTRING,point,','); TLINESTRING _POINT(point); (*(TDataset**)pData)->LINESTRING->push_back(_POINT); // add all point into POINT List } for(int i = 0 ;i < (*(TDataset**)pData)->stations->getSize()-1;i++) if(station_id ==(*(TDataset**)pData)->stations->at(i).id) { _POINT_station =(*(TDataset**)pData)->stations->at(i).geometry.substr(6,(*(TDataset**)pData)->stations->at(i).geometry.size() - 1 - 6); break; } for(int i = 0 ;i < (*(TDataset**)pData)->LINESTRING->getSize();i++) if(_POINT_station == (*(TDataset**)pData)->LINESTRING->at(i).POINT) { found = true; *(int*)pOutput = i; break; } break; } } if(!found) *(int*)pOutput = -1; } void Request_ISL_station_id_line_id_p_i(const char* pRequest , void* &pData , void* &pOutput , int& N )//VI { string pRe = pRequest; string station_id, line_id , p_i; int pos[100]; int i = 0; for (int index = 0; index < pRe.size(); index++) if (pRe[index] == ' ') pos[i++] = index + 1; station_id = pRe.substr(pos[0], pos[1] - 1 - pos[0]); line_id = pRe.substr(pos[1] , pos[2] - 1 - pos[1]); p_i = pRe.substr(pos[2]); TStation_line station_lines(station_id,line_id); bool insert = false; TStation_line* _station_lines = new TStation_line[(*(TDataset**)pData)->station_lines->getSize()]; (*(TDataset**)pData)->station_lines->_traverse(_station_lines,0); for(int i = 0 ; i < (*(TDataset**)pData)->station_lines->getSize() - 1 ; i++) if(line_id == _station_lines[i].line_id){ if(station_id == _station_lines[i].station_id) { insert = false; break; } else insert = true; } if(insert){ int pos = stoi(p_i); for(int i = 0 ; i < (*(TDataset**)pData)->station_lines->getSize() - 1 ; i++){ if(line_id == _station_lines[i].line_id)pos--; if(pos == -1){ (*(TDataset**)pData)->station_lines->insert(i,station_lines); break; } } } delete []_station_lines; N = 1; pOutput = new int[N]; if(insert) *(int*)pOutput = 0; else *(int*)pOutput = -1; } void Request_US_station_id_csv_description(const char* pRequest , void* &pData , void* &pOutput ,int& N ) { N = 1; pOutput = new int[N]; string csv_description = pRequest; int pos[100]; int index = -1; int two = 0; bool ban = true; for(int i = 0 ;i < csv_description.size();i++) { if(csv_description[i] == ' ' && two < 2) { pos[++index] = i + 1; two++; } else if(csv_description[i] == 'P' && csv_description[i+1] == 'O') { pos[++index] = i; ban = false; } else if(!ban && csv_description[i] == ' ') { pos[++index] = i + 1; } } string id , name,geometry,buildstart,opening,closure; id = csv_description.substr(pos[0], pos[1] - pos[0] - 1); name = csv_description.substr(pos[1],pos[2] - pos[1] - 1); geometry = csv_description.substr(pos[2],pos[4] - pos[2] - 1); bool update = false; TStation* _stations = new TStation[(*(TDataset**)pData)->stations->getSize()]; (*(TDataset**)pData)->stations->_traverse(_stations,0); for(int i = 0 ; i < (*(TDataset**)pData)->stations->getSize()-1;i++) { if(id == _stations[i].id) { TStation stations(id,name,geometry,_stations[i].city_id); (*(TDataset**)pData)->stations->update(i,stations); update = true; break; } } if(update) *(int*)pOutput = 0; else *(int*)pOutput = -1; delete [] _stations; } void Request_RS_station_id(const char* pRequest , void* &pData , void* &pOutput ,int& N ) { string station_id = pRequest; station_id = station_id.substr(3); bool remove = false; TStation* _stations = new TStation[(*(TDataset**)pData)->stations->getSize()]; (*(TDataset**)pData)->stations->_traverse(_stations,0); for(int i = 0 ; i < (*(TDataset**)pData)->stations->getSize() - 1 ; i++) if(station_id == _stations[i].id) { (*(TDataset**)pData)->stations->remove(i); remove = true; break; } N = 1; pOutput = new int[N]; if(remove) *(int*)pOutput = 0; else *(int*)pOutput = -1; delete[]_stations; } void Request_IS_csv_description(const char* pRequest, void *&pData, void* &pOutput, int &N) { N = 1; pOutput = new int[N]; /* Ex: IS Keisei Tsudanuma POINT(140.024812197129 35.6837744784723) 1921 1921 999999*/ string csv_description = pRequest; int pos[100]; int index = -1; int one = 0; bool ban = true; for(int i = 0 ;i < csv_description.size();i++) { if(csv_description[i] == ' ' && one < 1) { pos[++index] = i + 1; one++; } else if(csv_description[i] == 'P' && csv_description[i+1] == 'O') { pos[++index] = i; ban = false; } else if(!ban && csv_description[i] == ' ') { pos[++index] = i + 1; } } string name,geometry,buildstart,opening,closure; geometry = csv_description.substr(pos[1],pos[3] - pos[1] - 1); name = csv_description.substr(pos[0],pos[1] - pos[0] - 1); TStation* _stations = new TStation[(*(TDataset**)pData)->stations->getSize()]; (*(TDataset**)pData)->stations->_traverse(_stations,0); int id_max = 0; for(int i = 0 ;i < (*(TDataset**)pData)->stations->getSize();i++) { int VALUE; stringstream in(_stations[i].id); in >> VALUE; if(id_max < VALUE) id_max = VALUE; } TStation stations(std::to_string(id_max+1),name,geometry,""); (*(TDataset**)pData)->stations->push_back(stations); *(int*)pOutput = id_max + 1; delete [] _stations; } void ProcessRequest(const char* pRequest, void* pData, void* &pOutput, int &N) { string pRe = pRequest; if (pRe == "CL") Request_CL(pRequest, pData, pOutput,N); else if (pRe[0] == 'C' && pRe.size() > 3) Request_CL_cityName(pRequest, pData, pOutput, N); else if (pRe.substr(0, 3) == "LSC" && pRe.size() > 4) Request_LSC_cityName(pRequest, pData, pOutput, N); else if (pRe.substr(0, 3) == "LLC" && pRe.size() > 4) Request_LLC_cityName(pRequest, pData, pOutput, N); else if (pRe.substr(0, 3) == "LSL" && pRe.size() > 4) Request_LSL_lineid(pRequest, pData, pOutput, N); else if (pRe.substr(0, 2) == "FC" && pRe.size() > 3) Request_FC_cityName(pRequest, pData, pOutput, N); else if (pRe.substr(0, 2) == "FS" && pRe.size() > 3) Request_FS_stationName(pRequest, pData, pOutput, N); else if(pRe.substr(0,3) == "SLP" && pRe.size() > 4) Request_SLP_station_id_track_id(pRequest,pData,pOutput,N); else if(pRe.substr(0,3) == "IS " && pRe.size() > 3) Request_IS_csv_description(pRequest, pData, pOutput, N); else if(pRe.substr(0,3) == "RS " && pRe.size() > 3) Request_RS_station_id(pRequest ,pData , pOutput ,N ); else if(pRe.substr(0,2) == "US" && pRe.size() > 3) Request_US_station_id_csv_description(pRequest , pData , pOutput ,N ); else if(pRe.substr(0,3) == "ISL" && pRe.size() > 4) Request_ISL_station_id_line_id_p_i(pRequest ,pData ,pOutput ,N ); else if (pRe.substr(0,3) == "RSL" && pRe.size() > 4) Request_RSL_station_id_line_id(pRequest, pData, pOutput, N); }
[ "truonggiangbkhcm@gmail.com" ]
truonggiangbkhcm@gmail.com
a2677386d0e35b88afed3033432d66b7c40a8722
6b738bd0081ad09b12965ea77be58253e783b442
/binpac/codegen/operators/function.cc
8cfd176b11bd11914990fb261f71cab28fdd540a
[ "BSD-2-Clause" ]
permissive
FrozenCaribou/hilti
1f9b4d94aea500dfa50b3f54a9a079cf9e067506
10d3653b13268d7c2d1a19e0f675f43c9598a7b5
refs/heads/master
2021-01-18T02:59:12.841005
2016-05-31T14:02:15
2016-05-31T14:02:15
40,124,420
1
0
null
2015-08-03T12:49:21
2015-08-03T12:49:20
null
UTF-8
C++
false
false
695
cc
#include "cg-operator-common.h" #include <binpac/autogen/operators/function.h> using namespace binpac; using namespace binpac::codegen; void CodeBuilder::visit(expression::operator_::function::Call* i) { auto func = ast::checkedCast<expression::Function>(i->op1()); auto args = callParameters(i->op2()); shared_ptr<hilti::Expression> cookie = nullptr; if ( in<declaration::Function>() || in<declaration::Hook>() || in<declaration::Type>() ) cookie = hilti::builder::id::create("__cookie", i->location()); else cookie = hilti::builder::reference::createNull(i->location()); auto result = cg()->hiltiCall(func, args, cookie); setResult(result); }
[ "robin@icir.org" ]
robin@icir.org
c5c64c1221896cc57e3668eaaebc5bdf02d13ba6
0d6ecee519b425717062239e77bba6bb625cb685
/MultiWii-r1253/MultiWii/Serial.ino
12b9096f001d4456d46d359ef690b3b57728074f
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
speedy199/MultiWii3D
b1e720a5dc618e24c567fa8eeb4f8f1a4cd1aaea
549712086afe9639dbc187042f208767798b9239
refs/heads/master
2021-01-17T22:10:20.694970
2013-03-31T15:47:17
2013-03-31T15:47:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
26,542
ino
#if defined(MEGA) #define UART_NUMBER 4 #elif defined(PROMICRO) #define UART_NUMBER 2 #else #define UART_NUMBER 1 #endif #if defined(GPS_SERIAL) #define RX_BUFFER_SIZE 256 // 256 RX buffer is needed for GPS communication (64 or 128 was too short) #else #define RX_BUFFER_SIZE 64 #endif #define TX_BUFFER_SIZE 128 #define INBUF_SIZE 64 static volatile uint8_t serialHeadRX[UART_NUMBER],serialTailRX[UART_NUMBER]; static uint8_t serialBufferRX[RX_BUFFER_SIZE][UART_NUMBER]; static volatile uint8_t serialHeadTX[UART_NUMBER],serialTailTX[UART_NUMBER]; static uint8_t serialBufferTX[TX_BUFFER_SIZE][UART_NUMBER]; static uint8_t inBuf[INBUF_SIZE][UART_NUMBER]; #define BIND_CAPABLE 0; //Used for Spektrum today; can be used in the future for any RX type that needs a bind and has a MultiWii module. #if defined(SPEK_BIND) #define BIND_CAPABLE 1; #endif // Capability is bit flags; next defines should be 2, 4, 8... const uint32_t PROGMEM capability = 0+BIND_CAPABLE; #ifdef DEBUGMSG #define DEBUG_MSG_BUFFER_SIZE 128 static char debug_buf[DEBUG_MSG_BUFFER_SIZE]; static uint8_t head_debug; static uint8_t tail_debug; #endif // Multiwii Serial Protocol 0 #define MSP_VERSION 0 #define MSP_IDENT 100 //out message multitype + multiwii version + protocol version + capability variable #define MSP_STATUS 101 //out message cycletime & errors_count & sensor present & box activation & current setting number #define MSP_RAW_IMU 102 //out message 9 DOF #define MSP_SERVO 103 //out message 8 servos #define MSP_MOTOR 104 //out message 8 motors #define MSP_RC 105 //out message 8 rc chan #define MSP_RAW_GPS 106 //out message fix, numsat, lat, lon, alt, speed, ground course #define MSP_COMP_GPS 107 //out message distance home, direction home #define MSP_ATTITUDE 108 //out message 2 angles 1 heading #define MSP_ALTITUDE 109 //out message altitude, variometer #define MSP_BAT 110 //out message vbat, powermetersum #define MSP_RC_TUNING 111 //out message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID #define MSP_PID 112 //out message up to 16 P I D (8 are used) #define MSP_BOX 113 //out message up to 16 checkbox (11 are used) #define MSP_MISC 114 //out message powermeter trig + 8 free for future use #define MSP_MOTOR_PINS 115 //out message which pins are in use for motors & servos, for GUI #define MSP_BOXNAMES 116 //out message the aux switch names #define MSP_PIDNAMES 117 //out message the PID names #define MSP_WP 118 //out message get a WP, WP# is in the payload, returns (WP#, lat, lon, alt, flags) WP#0-home, WP#16-poshold #define MSP_SET_RAW_RC 200 //in message 8 rc chan #define MSP_SET_RAW_GPS 201 //in message fix, numsat, lat, lon, alt, speed #define MSP_SET_PID 202 //in message up to 16 P I D (8 are used) #define MSP_SET_BOX 203 //in message up to 16 checkbox (11 are used) #define MSP_SET_RC_TUNING 204 //in message rc rate, rc expo, rollpitch rate, yaw rate, dyn throttle PID #define MSP_ACC_CALIBRATION 205 //in message no param #define MSP_MAG_CALIBRATION 206 //in message no param #define MSP_SET_MISC 207 //in message powermeter trig + 8 free for future use #define MSP_RESET_CONF 208 //in message no param #define MSP_SET_WP 209 //in message sets a given WP (WP#,lat, lon, alt, flags) #define MSP_SELECT_SETTING 210 //in message Select Setting Number (0-2) #define MSP_SPEK_BIND 240 //in message no param #define MSP_EEPROM_WRITE 250 //in message no param #define MSP_DEBUGMSG 253 //out message debug string buffer #define MSP_DEBUG 254 //out message debug1,debug2,debug3,debug4 static uint8_t checksum[UART_NUMBER]; static uint8_t indRX[UART_NUMBER]; static uint8_t cmdMSP[UART_NUMBER]; #if defined(PROMINI) #define CURRENTPORT 0 #else static uint8_t CURRENTPORT=0; #endif uint32_t read32() { uint32_t t = read16(); t+= (uint32_t)read16()<<16; return t; } uint16_t read16() { uint16_t t = read8(); t+= (uint16_t)read8()<<8; return t; } uint8_t read8() { return inBuf[indRX[CURRENTPORT]++][CURRENTPORT]&0xff; } void headSerialResponse(uint8_t err, uint8_t s) { serialize8('$'); serialize8('M'); serialize8(err ? '!' : '>'); checksum[CURRENTPORT] = 0; // start calculating a new checksum serialize8(s); serialize8(cmdMSP[CURRENTPORT]); } void headSerialReply(uint8_t s) { headSerialResponse(0, s); } void inline headSerialError(uint8_t s) { headSerialResponse(1, s); } void tailSerialReply() { serialize8(checksum[CURRENTPORT]);UartSendData(); } void serializeNames(PGM_P s) { for (PGM_P c = s; pgm_read_byte(c); c++) { serialize8(pgm_read_byte(c)); } } void serialCom() { uint8_t c,n; static uint8_t offset[UART_NUMBER]; static uint8_t dataSize[UART_NUMBER]; static enum _serial_state { IDLE, HEADER_START, HEADER_M, HEADER_ARROW, HEADER_SIZE, HEADER_CMD, } c_state[UART_NUMBER];// = IDLE; for(n=0;n<UART_NUMBER;n++) { #if !defined(PROMINI) CURRENTPORT=n; #endif #define GPS_COND #if defined(GPS_SERIAL) #if defined(GPS_PROMINI) #define GPS_COND #else #define GPS_COND && (GPS_SERIAL != CURRENTPORT) #endif #endif #define SPEK_COND #if defined(SPEKTRUM) && (UART_NUMBER > 1) #define SPEK_COND && (SPEK_SERIAL_PORT != CURRENTPORT) #endif while (SerialAvailable(CURRENTPORT) GPS_COND SPEK_COND) { uint8_t bytesTXBuff = ((uint8_t)(serialHeadTX[CURRENTPORT]-serialTailTX[CURRENTPORT]))%TX_BUFFER_SIZE; // indicates the number of occupied bytes in TX buffer if (bytesTXBuff > TX_BUFFER_SIZE - 50 ) return; // ensure there is enough free TX buffer to go further (50 bytes margin) c = SerialRead(CURRENTPORT); if (c_state[CURRENTPORT] == IDLE) { c_state[CURRENTPORT] = (c=='$') ? HEADER_START : IDLE; if (c_state[CURRENTPORT] == IDLE) evaluateOtherData(c); // evaluate all other incoming serial data } else if (c_state[CURRENTPORT] == HEADER_START) { c_state[CURRENTPORT] = (c=='M') ? HEADER_M : IDLE; } else if (c_state[CURRENTPORT] == HEADER_M) { c_state[CURRENTPORT] = (c=='<') ? HEADER_ARROW : IDLE; } else if (c_state[CURRENTPORT] == HEADER_ARROW) { if (c > INBUF_SIZE) { // now we are expecting the payload size c_state[CURRENTPORT] = IDLE; continue; } dataSize[CURRENTPORT] = c; offset[CURRENTPORT] = 0; checksum[CURRENTPORT] = 0; indRX[CURRENTPORT] = 0; checksum[CURRENTPORT] ^= c; c_state[CURRENTPORT] = HEADER_SIZE; // the command is to follow } else if (c_state[CURRENTPORT] == HEADER_SIZE) { cmdMSP[CURRENTPORT] = c; checksum[CURRENTPORT] ^= c; c_state[CURRENTPORT] = HEADER_CMD; } else if (c_state[CURRENTPORT] == HEADER_CMD && offset[CURRENTPORT] < dataSize[CURRENTPORT]) { checksum[CURRENTPORT] ^= c; inBuf[offset[CURRENTPORT]++][CURRENTPORT] = c; } else if (c_state[CURRENTPORT] == HEADER_CMD && offset[CURRENTPORT] >= dataSize[CURRENTPORT]) { if (checksum[CURRENTPORT] == c) { // compare calculated and transferred checksum evaluateCommand(); // we got a valid packet, evaluate it } c_state[CURRENTPORT] = IDLE; } } } } void evaluateCommand() { switch(cmdMSP[CURRENTPORT]) { case MSP_SET_RAW_RC: for(uint8_t i=0;i<8;i++) { rcData[i] = read16(); } headSerialReply(0); break; #if GPS case MSP_SET_RAW_GPS: f.GPS_FIX = read8(); GPS_numSat = read8(); GPS_coord[LAT] = read32(); GPS_coord[LON] = read32(); GPS_altitude = read16(); GPS_speed = read16(); GPS_update |= 2; // New data signalisation to GPS functions headSerialReply(0); break; #endif case MSP_SET_PID: for(uint8_t i=0;i<PIDITEMS;i++) { conf.P8[i]=read8(); conf.I8[i]=read8(); conf.D8[i]=read8(); } headSerialReply(0); break; case MSP_SET_BOX: for(uint8_t i=0;i<CHECKBOXITEMS;i++) { conf.activate[i]=read16(); } headSerialReply(0); break; case MSP_SET_RC_TUNING: conf.rcRate8 = read8(); conf.rcExpo8 = read8(); conf.rollPitchRate = read8(); conf.yawRate = read8(); conf.dynThrPID = read8(); conf.thrMid8 = read8(); conf.thrExpo8 = read8(); headSerialReply(0); break; case MSP_SET_MISC: #if defined(POWERMETER) conf.powerTrigger1 = read16() / PLEVELSCALE; #endif headSerialReply(0); break; #ifdef MULTIPLE_CONFIGURATION_PROFILES case MSP_SELECT_SETTING: if(!f.ARMED) { global_conf.currentSet = read8(); if(global_conf.currentSet>2) global_conf.currentSet = 0; writeGlobalSet(0); readEEPROM(); } headSerialReply(0); break; #endif case MSP_IDENT: headSerialReply(7); serialize8(VERSION); // multiwii version serialize8(MULTITYPE); // type of multicopter serialize8(MSP_VERSION); // MultiWii Serial Protocol Version serialize32(pgm_read_dword(&(capability))); // "capability" break; case MSP_STATUS: headSerialReply(11); serialize16(cycleTime); serialize16(i2c_errors_count); serialize16(ACC|BARO<<1|MAG<<2|GPS<<3|SONAR<<4); serialize32( #if ACC f.ANGLE_MODE<<BOXANGLE| f.HORIZON_MODE<<BOXHORIZON| #endif #if BARO && (!defined(SUPPRESS_BARO_ALTHOLD)) f.BARO_MODE<<BOXBARO| #endif #if MAG f.MAG_MODE<<BOXMAG|f.HEADFREE_MODE<<BOXHEADFREE|rcOptions[BOXHEADADJ]<<BOXHEADADJ| #endif #if defined(SERVO_TILT) || defined(GIMBAL)|| defined(SERVO_MIX_TILT) rcOptions[BOXCAMSTAB]<<BOXCAMSTAB| #endif #if defined(CAMTRIG) rcOptions[BOXCAMTRIG]<<BOXCAMTRIG| #endif #if GPS f.GPS_HOME_MODE<<BOXGPSHOME|f.GPS_HOLD_MODE<<BOXGPSHOLD| #endif #if defined(FIXEDWING) || defined(HELICOPTER) || defined(INFLIGHT_ACC_CALIBRATION) f.PASSTHRU_MODE<<BOXPASSTHRU| #endif #if defined(BUZZER) rcOptions[BOXBEEPERON]<<BOXBEEPERON| #endif #if defined(LED_FLASHER) rcOptions[BOXLEDMAX]<<BOXLEDMAX| #endif #if defined(LANDING_LIGHTS_DDR) rcOptions[BOXLLIGHTS]<<BOXLLIGHTS | #endif f.ARMED<<BOXARM); serialize8(global_conf.currentSet); // current setting break; case MSP_RAW_IMU: headSerialReply(18); for(uint8_t i=0;i<3;i++) serialize16(accSmooth[i]); for(uint8_t i=0;i<3;i++) serialize16(gyroData[i]); for(uint8_t i=0;i<3;i++) serialize16(magADC[i]); break; case MSP_SERVO: headSerialReply(16); for(uint8_t i=0;i<8;i++) #if defined(SERVO) serialize16(servo[i]); #else serialize16(0); #endif break; case MSP_MOTOR: headSerialReply(16); for(uint8_t i=0;i<8;i++) { serialize16( (i < NUMBER_MOTOR) ? motor[i] : 0 ); } break; case MSP_RC: headSerialReply(RC_CHANS * 2); for(uint8_t i=0;i<RC_CHANS;i++) serialize16(rcData[i]); break; #if GPS case MSP_RAW_GPS: headSerialReply(16); serialize8(f.GPS_FIX); serialize8(GPS_numSat); serialize32(GPS_coord[LAT]); serialize32(GPS_coord[LON]); serialize16(GPS_altitude); serialize16(GPS_speed); serialize16(GPS_ground_course); // added since r1172 break; case MSP_COMP_GPS: headSerialReply(5); serialize16(GPS_distanceToHome); serialize16(GPS_directionToHome); serialize8(GPS_update & 1); break; #endif case MSP_ATTITUDE: headSerialReply(8); for(uint8_t i=0;i<2;i++) serialize16(angle[i]); serialize16(heading); serialize16(headFreeModeHold); break; case MSP_ALTITUDE: headSerialReply(6); serialize32(EstAlt); serialize16(vario); // added since r1172 break; case MSP_BAT: headSerialReply(3); serialize8(vbat); serialize16(intPowerMeterSum); break; case MSP_RC_TUNING: headSerialReply(7); serialize8(conf.rcRate8); serialize8(conf.rcExpo8); serialize8(conf.rollPitchRate); serialize8(conf.yawRate); serialize8(conf.dynThrPID); serialize8(conf.thrMid8); serialize8(conf.thrExpo8); break; case MSP_PID: headSerialReply(3*PIDITEMS); for(uint8_t i=0;i<PIDITEMS;i++) { serialize8(conf.P8[i]); serialize8(conf.I8[i]); serialize8(conf.D8[i]); } break; case MSP_BOX: headSerialReply(2*CHECKBOXITEMS); for(uint8_t i=0;i<CHECKBOXITEMS;i++) { serialize16(conf.activate[i]); } break; case MSP_BOXNAMES: headSerialReply(strlen_P(boxnames)); serializeNames(boxnames); break; case MSP_PIDNAMES: headSerialReply(strlen_P(pidnames)); serializeNames(pidnames); break; case MSP_MISC: headSerialReply(2); serialize16(intPowerTrigger1); break; case MSP_MOTOR_PINS: headSerialReply(8); for(uint8_t i=0;i<8;i++) { serialize8(PWM_PIN[i]); } break; #if defined(USE_MSP_WP) case MSP_WP: { uint8_t wp_no = read8(); //get the wp number headSerialReply(12); if (wp_no == 0) { serialize8(0); //wp0 serialize32(GPS_home[LAT]); serialize32(GPS_home[LON]); serialize16(0); //altitude will come here serialize8(0); //nav flag will come here } else if (wp_no == 16) { serialize8(16); //wp16 serialize32(GPS_hold[LAT]); serialize32(GPS_hold[LON]); serialize16(0); //altitude will come here serialize8(0); //nav flag will come here } } break; case MSP_SET_WP: { uint8_t wp_no = read8(); //get the wp number if (wp_no == 0) { GPS_home[LAT] = read32(); GPS_home[LON] = read32(); read32(); // future: to set altitude read8(); // future: to set nav flag } } headSerialReply(0); break; #endif case MSP_RESET_CONF: if(!f.ARMED) LoadDefaults(); headSerialReply(0); break; case MSP_ACC_CALIBRATION: if(!f.ARMED) calibratingA=400; headSerialReply(0); break; case MSP_MAG_CALIBRATION: if(!f.ARMED) f.CALIBRATE_MAG = 1; headSerialReply(0); break; #if defined(SPEK_BIND) case MSP_SPEK_BIND: spekBind(); headSerialReply(0); break; #endif case MSP_EEPROM_WRITE: writeParams(0); headSerialReply(0); break; case MSP_DEBUG: headSerialReply(8); for(uint8_t i=0;i<4;i++) { serialize16(debug[i]); // 4 variables are here for general monitoring purpose } break; #ifdef DEBUGMSG case MSP_DEBUGMSG: { uint8_t size = debugmsg_available(); if (size > 16) size = 16; headSerialReply(size); debugmsg_serialize(size); } break; #endif default: // we do not know how to handle the (valid) message, indicate error MSP $M! headSerialError(0); break; } tailSerialReply(); } // evaluate all other incoming serial data void evaluateOtherData(uint8_t sr) { switch (sr) { // Note: we may receive weird characters here which could trigger unwanted features during flight. // this could lead to a crash easily. // Please use if (!f.ARMED) where neccessary #ifdef LCD_CONF case 's': case 'S': if (!f.ARMED) configurationLoop(); break; #endif #if defined(LCD_TELEMETRY) && defined(LCD_TEXTSTAR) case 'A': // button A press toggle_telemetry(1); break; case 'B': // button B press toggle_telemetry(2); break; case 'C': // button C press toggle_telemetry(3); break; case 'D': // button D press toggle_telemetry(4); break; case 'a': // button A release case 'b': // button B release case 'c': // button C release case 'd': // button D release break; #endif #ifdef LCD_TELEMETRY case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': #if defined(LOG_VALUES) && defined(DEBUG) case 'R': #endif #ifdef DEBUG case 'F': #endif toggle_telemetry(sr); break; #endif // LCD_TELEMETRY } } // ******************************************************* // For Teensy 2.0, these function emulate the API used for ProMicro // it cant have the same name as in the arduino API because it wont compile for the promini (eaven if it will be not compiled) // ******************************************************* #if defined(TEENSY20) unsigned char T_USB_Available(){ int n = Serial.available(); if (n > 255) n = 255; return n; } #endif // ******************************************************* // Interrupt driven UART transmitter - using a ring buffer // ******************************************************* void serialize32(uint32_t a) { serialize8((a ) & 0xFF); serialize8((a>> 8) & 0xFF); serialize8((a>>16) & 0xFF); serialize8((a>>24) & 0xFF); } void serialize16(int16_t a) { serialize8((a ) & 0xFF); serialize8((a>>8) & 0xFF); } void serialize8(uint8_t a) { uint8_t t = serialHeadTX[CURRENTPORT]; if (++t >= TX_BUFFER_SIZE) t = 0; serialBufferTX[t][CURRENTPORT] = a; checksum[CURRENTPORT] ^= a; serialHeadTX[CURRENTPORT] = t; } #if defined(PROMINI) || defined(MEGA) #if defined(PROMINI) ISR(USART_UDRE_vect) { // Serial 0 on a PROMINI #endif #if defined(MEGA) ISR(USART0_UDRE_vect) { // Serial 0 on a MEGA #endif uint8_t t = serialTailTX[0]; if (serialHeadTX[0] != t) { if (++t >= TX_BUFFER_SIZE) t = 0; UDR0 = serialBufferTX[t][0]; // Transmit next byte in the ring serialTailTX[0] = t; } if (t == serialHeadTX[0]) UCSR0B &= ~(1<<UDRIE0); // Check if all data is transmitted . if yes disable transmitter UDRE interrupt } #endif #if defined(MEGA) || defined(PROMICRO) ISR(USART1_UDRE_vect) { // Serial 1 on a MEGA or on a PROMICRO uint8_t t = serialTailTX[1]; if (serialHeadTX[1] != t) { if (++t >= TX_BUFFER_SIZE) t = 0; UDR1 = serialBufferTX[t][1]; // Transmit next byte in the ring serialTailTX[1] = t; } if (t == serialHeadTX[1]) UCSR1B &= ~(1<<UDRIE1); } #endif #if defined(MEGA) ISR(USART2_UDRE_vect) { // Serial 2 on a MEGA uint8_t t = serialTailTX[2]; if (serialHeadTX[2] != t) { if (++t >= TX_BUFFER_SIZE) t = 0; UDR2 = serialBufferTX[t][2]; serialTailTX[2] = t; } if (t == serialHeadTX[2]) UCSR2B &= ~(1<<UDRIE2); } ISR(USART3_UDRE_vect) { // Serial 3 on a MEGA uint8_t t = serialTailTX[3]; if (serialHeadTX[3] != t) { if (++t >= TX_BUFFER_SIZE) t = 0; UDR3 = serialBufferTX[t][3]; serialTailTX[3] = t; } if (t == serialHeadTX[3]) UCSR3B &= ~(1<<UDRIE3); } #endif void UartSendData() { #if defined(PROMINI) UCSR0B |= (1<<UDRIE0); #endif #if defined(PROMICRO) switch (CURRENTPORT) { case 0: while(serialHeadTX[0] != serialTailTX[0]) { if (++serialTailTX[0] >= TX_BUFFER_SIZE) serialTailTX[0] = 0; #if !defined(TEENSY20) USB_Send(USB_CDC_TX,serialBufferTX[serialTailTX[0]],1); #else Serial.write(serialBufferTX[serialTailTX[0]],1); #endif } break; case 1: UCSR1B |= (1<<UDRIE1); break; } #endif #if defined(MEGA) switch (CURRENTPORT) { case 0: UCSR0B |= (1<<UDRIE0); break; case 1: UCSR1B |= (1<<UDRIE1); break; case 2: UCSR2B |= (1<<UDRIE2); break; case 3: UCSR3B |= (1<<UDRIE3); break; } #endif } #if defined(GPS_SERIAL) bool SerialTXfree(uint8_t port) { return (serialHeadTX[port] == serialTailTX[port]); } #endif static void inline SerialOpen(uint8_t port, uint32_t baud) { uint8_t h = ((F_CPU / 4 / baud -1) / 2) >> 8; uint8_t l = ((F_CPU / 4 / baud -1) / 2); switch (port) { #if defined(PROMINI) case 0: UCSR0A = (1<<U2X0); UBRR0H = h; UBRR0L = l; UCSR0B |= (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0); break; #endif #if defined(PROMICRO) #if (ARDUINO >= 100) && !defined(TEENSY20) case 0: UDIEN &= ~(1<<SOFE); break;// disable the USB frame interrupt of arduino (it causes strong jitter and we dont need it) #endif case 1: UCSR1A = (1<<U2X1); UBRR1H = h; UBRR1L = l; UCSR1B |= (1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1); break; #endif #if defined(MEGA) case 0: UCSR0A = (1<<U2X0); UBRR0H = h; UBRR0L = l; UCSR0B |= (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0); break; case 1: UCSR1A = (1<<U2X1); UBRR1H = h; UBRR1L = l; UCSR1B |= (1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1); break; case 2: UCSR2A = (1<<U2X2); UBRR2H = h; UBRR2L = l; UCSR2B |= (1<<RXEN2)|(1<<TXEN2)|(1<<RXCIE2); break; case 3: UCSR3A = (1<<U2X3); UBRR3H = h; UBRR3L = l; UCSR3B |= (1<<RXEN3)|(1<<TXEN3)|(1<<RXCIE3); break; #endif } } static void inline SerialEnd(uint8_t port) { switch (port) { #if defined(PROMINI) case 0: UCSR0B &= ~((1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0)|(1<<UDRIE0)); break; #endif #if defined(PROMICRO) case 1: UCSR1B &= ~((1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1)|(1<<UDRIE1)); break; #endif #if defined(MEGA) case 0: UCSR0B &= ~((1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0)|(1<<UDRIE0)); break; case 1: UCSR1B &= ~((1<<RXEN1)|(1<<TXEN1)|(1<<RXCIE1)|(1<<UDRIE1)); break; case 2: UCSR2B &= ~((1<<RXEN2)|(1<<TXEN2)|(1<<RXCIE2)|(1<<UDRIE2)); break; case 3: UCSR3B &= ~((1<<RXEN3)|(1<<TXEN3)|(1<<RXCIE3)|(1<<UDRIE3)); break; #endif } } static void inline store_uart_in_buf(uint8_t data, uint8_t portnum) { #if defined(SPEKTRUM) if (portnum == SPEK_SERIAL_PORT) { if (!spekFrameFlags) { sei(); uint32_t spekTimeNow = (timer0_overflow_count << 8) * (64 / clockCyclesPerMicrosecond()); //Move timer0_overflow_count into registers so we don't touch a volatile twice uint32_t spekInterval = spekTimeNow - spekTimeLast; //timer0_overflow_count will be slightly off because of the way the Arduino core timer interrupt handler works; that is acceptable for this use. Using the core variable avoids an expensive call to millis() or micros() spekTimeLast = spekTimeNow; if (spekInterval > 5000) { //Potential start of a Spektrum frame, they arrive every 11 or every 22 ms. Mark it, and clear the buffer. serialTailRX[portnum] = 0; serialHeadRX[portnum] = 0; spekFrameFlags = 0x01; } cli(); } } #endif uint8_t h = serialHeadRX[portnum]; if (++h >= RX_BUFFER_SIZE) h = 0; if (h == serialTailRX[portnum]) return; // we did not bite our own tail? serialBufferRX[serialHeadRX[portnum]][portnum] = data; serialHeadRX[portnum] = h; } #if defined(PROMINI) ISR(USART_RX_vect) { store_uart_in_buf(UDR0, 0); } #endif #if defined(PROMICRO) ISR(USART1_RX_vect) { store_uart_in_buf(UDR1, 1); } #endif #if defined(MEGA) ISR(USART0_RX_vect) { store_uart_in_buf(UDR0, 0); } ISR(USART1_RX_vect) { store_uart_in_buf(UDR1, 1); } ISR(USART2_RX_vect) { store_uart_in_buf(UDR2, 2); } ISR(USART3_RX_vect) { store_uart_in_buf(UDR3, 3); } #endif uint8_t SerialRead(uint8_t port) { #if defined(PROMICRO) #if defined(TEENSY20) if(port == 0) return Serial.read(); #else #if (ARDUINO >= 100) if(port == 0) USB_Flush(USB_CDC_TX); #endif if(port == 0) return USB_Recv(USB_CDC_RX); #endif #endif uint8_t t = serialTailRX[port]; uint8_t c = serialBufferRX[t][port]; if (serialHeadRX[port] != t) { if (++t >= RX_BUFFER_SIZE) t = 0; serialTailRX[port] = t; } return c; } #if defined(SPEKTRUM) uint8_t SerialPeek(uint8_t port) { uint8_t c = serialBufferRX[serialTailRX[port]][port]; if ((serialHeadRX[port] != serialTailRX[port])) return c; else return 0; } #endif uint8_t SerialAvailable(uint8_t port) { #if defined(PROMICRO) #if !defined(TEENSY20) if(port == 0) return USB_Available(USB_CDC_RX); #else if(port == 0) return T_USB_Available(); #endif #endif return (serialHeadRX[port] - serialTailRX[port])%RX_BUFFER_SIZE; } void SerialWrite(uint8_t port,uint8_t c){ #if !defined(PROMINI) CURRENTPORT=port; #endif serialize8(c);UartSendData(); } #ifdef DEBUGMSG void debugmsg_append_str(const char *str) { while(*str) { debug_buf[head_debug++] = *str++; if (head_debug == DEBUG_MSG_BUFFER_SIZE) { head_debug = 0; } } } static uint8_t debugmsg_available() { if (head_debug >= tail_debug) { return head_debug-tail_debug; } else { return head_debug + (DEBUG_MSG_BUFFER_SIZE-tail_debug); } } static void debugmsg_serialize(uint8_t l) { for (uint8_t i=0; i<l; i++) { if (head_debug != tail_debug) { serialize8(debug_buf[tail_debug++]); if (tail_debug == DEBUG_MSG_BUFFER_SIZE) { tail_debug = 0; } } else { serialize8('\0'); } } } #else void debugmsg_append_str(const char *str) {}; #endif
[ "chris@luadev.com" ]
chris@luadev.com
384501e8ff344fe6609c40999f81b9c72e7830bc
eaf0d750ff63a1b51e3c9d62905b35a9d1a682fa
/SDL 2d game/SDL 2d game/ComponentFramework19.1.2/SDL_Project/Collision.h
f6182deb458a97eec5fd70cfac711d0e1735b1b5
[]
no_license
QuocAnhLe935/Sdl-midstone
452962c3dbdab3d7dbe88d25e8569a37a8c8e3ca
4b87b6cb7addbce58c326d2af41032a21ad89a25
refs/heads/main
2023-01-24T00:34:10.670019
2020-12-09T01:23:50
2020-12-09T01:23:50
313,486,012
0
0
null
null
null
null
UTF-8
C++
false
false
292
h
#ifndef COLLISION_H #define COLLISION_H #include "Vector.h" #include "Ball.h" #include "VMath.h" #include <SDL.h> class Collision: public Body, public GameObject { public: static bool Collisions(Ball *ball, Ball *ball2); static void ResponseCollision(Ball *ball, Ball *ball2); }; #endif
[ "54999435+QuocAnhLe935@users.noreply.github.com" ]
54999435+QuocAnhLe935@users.noreply.github.com
e285b3d8726734770d251a905b6b4a32c283e75f
f58d3ad03089b1474adcdd17b096488a97b80314
/collider/collider.h
676f417e9e702aa1678719e0275c5af45b7c1e13
[]
no_license
fbxiang/PhysicsVideoGen
7ecf1e416662b0cef63064ea0a2e6ea9ded327f2
f073eeb574145f868db0e7a3f885195c2f72a2be
refs/heads/master
2020-06-17T02:34:37.565332
2016-11-29T05:46:01
2016-11-29T05:46:01
75,047,773
0
0
null
null
null
null
UTF-8
C++
false
false
2,346
h
/* * collider.h * * Created on: Aug 23, 2016 * Author: fx */ #ifndef COLLIDER_COLLIDER_H_ #define COLLIDER_COLLIDER_H_ #include "../math/math_helper.h" #define COLLIDER 0 #define AABB_COLLIDER 1 #define CIRCLE_COLLIDER 2 #define LINE_COLLIDER 3 /* Manifold struct is used in collision detection */ struct Manifold { class Collider* A; class Collider* B; float penetration; vector2f normal; Manifold(Collider* a, Collider* b) { A = a; B = b; penetration = 0; } }; /* Collider attached object will be automatically checked for collision*/ class Collider { public: /* Constructor * @param Object2d* parent object * @param float restriction */ Collider(class Object2d* p, float res=1.0f); virtual ~Collider(); /* @return vector2f position of the collider in world coordinates */ vector2f getPosition() const; /* @return vector2f actual scale of the collider */ vector2f getScale() const; void setRistriction(float res); /* @return int the type of the current collider, only intended for subclasses */ virtual int getType() const; /* vector2f relative position with respect to parent object */ vector2f relPos; /* vector2f relative scale with respect to parent object */ vector2f relScale = vector2f(1.0f, 1.0f); /* Object2d* pointer to parent */ class Object2d* parent; /* float restriction used when calculating colliding */ float restriction = 1.0f; }; class AABBCollider: public Collider { public: AABBCollider(class Object2d* p, float res=1.0f); vector2f getLowerLeft() const; vector2f getUpperRight() const; virtual int getType() const; }; class CircleCollider: public Collider { public: CircleCollider(class Object2d* p, float res=1.0f); float getRadius() const; virtual int getType() const; }; class LineCollider: public Collider { public: LineCollider(class Object2d* p, float res=1.0f, vector2f s=vector2f(), vector2f e=vector2f()); virtual int getType() const; vector2f start, end; }; /* This function is only intended for collision detection managed by the world object*/ /* The logic of collision handling is from * http://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331 * credit to the author */ bool detectCollision(Manifold* m); #endif /* COLLIDER_COLLIDER_H_ */
[ "fxiang2@illinois.edu" ]
fxiang2@illinois.edu
bcba7874436eab1a0d7f34b9bb2ddc438e98aa65
40ec0ae528dd8799a88f0bcfc156343ed3ec295e
/src/behaviour/line_follower.hpp
afa7898ac18bfbe6694db985d6af69a75db67021
[]
no_license
ILIAVOLKOV222/HS-Robot-Controller
e25db7c682ca85cd2b5e54cdf6a6fd8f8608ef98
5b5d62179c343e4bbd002e052732a1d2a3246146
refs/heads/master
2023-08-22T10:52:05.820059
2021-10-22T11:07:11
2021-10-22T11:07:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
690
hpp
#ifndef HS_BEHAVIOUR_LINE_FOLLOWER_HPP #define HS_BEHAVIOUR_LINE_FOLLOWER_HPP #include "behaviour.hpp" namespace hs::behaviour { /// Line following robot behaviour. /// /// Uses the robot's camera to detect a black line and makes the robot follow it. class LineFollower : public Behaviour { public: /// Behaviour type name. Custom behaviour must define this constant too. static inline const char* NAME = "LineFollower"; // Use default constructor. using Behaviour::Behaviour; /// Updates the behaviour. virtual void update() override; }; } // namespace hs::behaviour #endif // HS_BEHAVIOUR_LINE_FOLLOWER_HPP
[ "noreply@github.com" ]
noreply@github.com
56bfb976d74b62bffbfd38a202224ca8a0d85a16
9c22a7f4e39ec744d68eac3d5ea9db5c7b2013d7
/src/appleseed.studio/mainwindow/project/entitybrowser.h
afebcab246287e96a6df5e32c8e55918bbe3c608
[ "MIT" ]
permissive
jotpandher/appleseed
4b6b7f30ce816280c3502d710920e39c740f5d51
c74bd03e314d3a9fd7dd0cbaeb2f1374ae4b546f
refs/heads/master
2021-01-15T12:54:13.278636
2014-11-23T14:14:01
2014-11-23T14:14:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,783
h
// // This source file is part of appleseed. // Visit http://appleseedhq.net/ for additional information and resources. // // This software is released under the MIT license. // // Copyright (c) 2010-2013 Francois Beaune, Jupiter Jazz Limited // Copyright (c) 2014 Francois Beaune, The appleseedhq Organization // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #ifndef APPLESEED_STUDIO_MAINWINDOW_PROJECT_ENTITYBROWSER_H #define APPLESEED_STUDIO_MAINWINDOW_PROJECT_ENTITYBROWSER_H // appleseed.studio headers. #include "mainwindow/project/entityeditor.h" // Standard headers. #include <string> // Forward declarations. namespace foundation { class StringDictionary; } namespace renderer { class Assembly; } namespace renderer { class BaseGroup; } namespace renderer { class Project; } namespace renderer { class Scene; } namespace appleseed { namespace studio { // // Browse the entities from a parent entity. // template <typename ParentEntity> class EntityBrowser; // // Browse the entities in a project. // template <> class EntityBrowser<renderer::Project> : public EntityEditor::IEntityBrowser { public: explicit EntityBrowser(const renderer::Project& scene); virtual foundation::StringDictionary get_entities(const std::string& type) const; private: const renderer::Project& m_project; }; // // Browse the entities in a base group (the common denominator between a scene and an assembly). // template <> class EntityBrowser<renderer::BaseGroup> : public EntityEditor::IEntityBrowser { public: explicit EntityBrowser(const renderer::BaseGroup& base_group); virtual foundation::StringDictionary get_entities(const std::string& type) const; private: const renderer::BaseGroup& m_base_group; }; // // Browse the entities in a scene. // template <> class EntityBrowser<renderer::Scene> : public EntityBrowser<renderer::BaseGroup> { public: explicit EntityBrowser(const renderer::Scene& scene); virtual foundation::StringDictionary get_entities(const std::string& type) const; private: const renderer::Scene& m_scene; }; // // Browse the entities in an assembly. // template <> class EntityBrowser<renderer::Assembly> : public EntityBrowser<renderer::BaseGroup> { public: explicit EntityBrowser(const renderer::Assembly& assembly); virtual foundation::StringDictionary get_entities(const std::string& type) const; private: const renderer::Assembly& m_assembly; foundation::StringDictionary get_entities( const renderer::Assembly& assembly, const std::string& type) const; }; } // namespace studio } // namespace appleseed #endif // !APPLESEED_STUDIO_MAINWINDOW_PROJECT_ENTITYBROWSER_H
[ "beaune@aist.enst.fr" ]
beaune@aist.enst.fr
1806f84b8379fda1d86c4dfc1ef1a11dfb27d001
367d2670c75d385d122bca60b9f550ca5b3888c1
/gem5/src/arch/arm/isa.hh
40fa561e23b5bc6d3004b0c16aa43a824683f277
[ "BSD-3-Clause", "LicenseRef-scancode-proprietary-license", "LGPL-2.0-or-later", "MIT" ]
permissive
Anish-Saxena/aqua_rowhammer_mitigation
4f060037d50fb17707338a6edcaa0ac33c39d559
3fef5b6aa80c006a4bd6ed4bedd726016142a81c
refs/heads/main
2023-04-13T05:35:20.872581
2023-01-05T21:10:39
2023-01-05T21:10:39
519,395,072
4
3
Unlicense
2023-01-05T21:10:40
2022-07-30T02:03:02
C++
UTF-8
C++
false
false
31,494
hh
/* * Copyright (c) 2010, 2012-2021 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Copyright (c) 2009 The Regents of The University of Michigan * 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 copyright holders 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. */ #ifndef __ARCH_ARM_ISA_HH__ #define __ARCH_ARM_ISA_HH__ #include "arch/arm/isa_device.hh" #include "arch/arm/miscregs.hh" #include "arch/arm/registers.hh" #include "arch/arm/self_debug.hh" #include "arch/arm/system.hh" #include "arch/arm/tlb.hh" #include "arch/arm/types.hh" #include "arch/generic/isa.hh" #include "arch/generic/traits.hh" #include "debug/Checkpoint.hh" #include "enums/DecoderFlavor.hh" #include "enums/VecRegRenameMode.hh" #include "sim/sim_object.hh" struct ArmISAParams; struct DummyArmISADeviceParams; class Checkpoint; class EventManager; namespace ArmISA { class ISA : public BaseISA { protected: // Parent system ArmSystem *system; // Micro Architecture const Enums::DecoderFlavor _decoderFlavor; const Enums::VecRegRenameMode _vecRegRenameMode; /** Dummy device for to handle non-existing ISA devices */ DummyISADevice dummyDevice; // PMU belonging to this ISA BaseISADevice *pmu; // Generic timer interface belonging to this ISA std::unique_ptr<BaseISADevice> timer; // GICv3 CPU interface belonging to this ISA std::unique_ptr<BaseISADevice> gicv3CpuInterface; // Cached copies of system-level properties bool highestELIs64; bool haveSecurity; bool haveLPAE; bool haveVirtualization; bool haveCrypto; bool haveLargeAsid64; uint8_t physAddrRange; bool haveSVE; bool haveLSE; bool haveVHE; bool havePAN; bool haveSecEL2; bool haveTME; /** SVE vector length in quadwords */ unsigned sveVL; /** * If true, accesses to IMPLEMENTATION DEFINED registers are treated * as NOP hence not causing UNDEFINED INSTRUCTION. */ bool impdefAsNop; bool afterStartup; SelfDebug * selfDebug; /** MiscReg metadata **/ struct MiscRegLUTEntry { uint32_t lower; // Lower half mapped to this register uint32_t upper; // Upper half mapped to this register uint64_t _reset; // value taken on reset (i.e. initialization) uint64_t _res0; // reserved uint64_t _res1; // reserved uint64_t _raz; // read as zero (fixed at 0) uint64_t _rao; // read as one (fixed at 1) public: MiscRegLUTEntry() : lower(0), upper(0), _reset(0), _res0(0), _res1(0), _raz(0), _rao(0) {} uint64_t reset() const { return _reset; } uint64_t res0() const { return _res0; } uint64_t res1() const { return _res1; } uint64_t raz() const { return _raz; } uint64_t rao() const { return _rao; } // raz/rao implies writes ignored uint64_t wi() const { return _raz | _rao; } }; /** Metadata table accessible via the value of the register */ static std::vector<struct MiscRegLUTEntry> lookUpMiscReg; class MiscRegLUTEntryInitializer { struct MiscRegLUTEntry &entry; std::bitset<NUM_MISCREG_INFOS> &info; typedef const MiscRegLUTEntryInitializer& chain; public: chain mapsTo(uint32_t l, uint32_t u = 0) const { entry.lower = l; entry.upper = u; return *this; } chain res0(uint64_t mask) const { entry._res0 = mask; return *this; } chain res1(uint64_t mask) const { entry._res1 = mask; return *this; } chain raz(uint64_t mask) const { entry._raz = mask; return *this; } chain rao(uint64_t mask) const { entry._rao = mask; return *this; } chain implemented(bool v = true) const { info[MISCREG_IMPLEMENTED] = v; return *this; } chain unimplemented() const { return implemented(false); } chain unverifiable(bool v = true) const { info[MISCREG_UNVERIFIABLE] = v; return *this; } chain warnNotFail(bool v = true) const { info[MISCREG_WARN_NOT_FAIL] = v; return *this; } chain mutex(bool v = true) const { info[MISCREG_MUTEX] = v; return *this; } chain banked(bool v = true) const { info[MISCREG_BANKED] = v; return *this; } chain banked64(bool v = true) const { info[MISCREG_BANKED64] = v; return *this; } chain bankedChild(bool v = true) const { info[MISCREG_BANKED_CHILD] = v; return *this; } chain userNonSecureRead(bool v = true) const { info[MISCREG_USR_NS_RD] = v; return *this; } chain userNonSecureWrite(bool v = true) const { info[MISCREG_USR_NS_WR] = v; return *this; } chain userSecureRead(bool v = true) const { info[MISCREG_USR_S_RD] = v; return *this; } chain userSecureWrite(bool v = true) const { info[MISCREG_USR_S_WR] = v; return *this; } chain user(bool v = true) const { userNonSecureRead(v); userNonSecureWrite(v); userSecureRead(v); userSecureWrite(v); return *this; } chain privNonSecureRead(bool v = true) const { info[MISCREG_PRI_NS_RD] = v; return *this; } chain privNonSecureWrite(bool v = true) const { info[MISCREG_PRI_NS_WR] = v; return *this; } chain privNonSecure(bool v = true) const { privNonSecureRead(v); privNonSecureWrite(v); return *this; } chain privSecureRead(bool v = true) const { info[MISCREG_PRI_S_RD] = v; return *this; } chain privSecureWrite(bool v = true) const { info[MISCREG_PRI_S_WR] = v; return *this; } chain privSecure(bool v = true) const { privSecureRead(v); privSecureWrite(v); return *this; } chain priv(bool v = true) const { privSecure(v); privNonSecure(v); return *this; } chain privRead(bool v = true) const { privSecureRead(v); privNonSecureRead(v); return *this; } chain hypE2HRead(bool v = true) const { info[MISCREG_HYP_E2H_RD] = v; return *this; } chain hypE2HWrite(bool v = true) const { info[MISCREG_HYP_E2H_WR] = v; return *this; } chain hypE2H(bool v = true) const { hypE2HRead(v); hypE2HWrite(v); return *this; } chain hypRead(bool v = true) const { hypE2HRead(v); info[MISCREG_HYP_RD] = v; return *this; } chain hypWrite(bool v = true) const { hypE2HWrite(v); info[MISCREG_HYP_WR] = v; return *this; } chain hyp(bool v = true) const { hypRead(v); hypWrite(v); return *this; } chain monE2HRead(bool v = true) const { info[MISCREG_MON_E2H_RD] = v; return *this; } chain monE2HWrite(bool v = true) const { info[MISCREG_MON_E2H_WR] = v; return *this; } chain monE2H(bool v = true) const { monE2HRead(v); monE2HWrite(v); return *this; } chain monSecureRead(bool v = true) const { monE2HRead(v); info[MISCREG_MON_NS0_RD] = v; return *this; } chain monSecureWrite(bool v = true) const { monE2HWrite(v); info[MISCREG_MON_NS0_WR] = v; return *this; } chain monNonSecureRead(bool v = true) const { monE2HRead(v); info[MISCREG_MON_NS1_RD] = v; return *this; } chain monNonSecureWrite(bool v = true) const { monE2HWrite(v); info[MISCREG_MON_NS1_WR] = v; return *this; } chain mon(bool v = true) const { monSecureRead(v); monSecureWrite(v); monNonSecureRead(v); monNonSecureWrite(v); return *this; } chain monSecure(bool v = true) const { monSecureRead(v); monSecureWrite(v); return *this; } chain monNonSecure(bool v = true) const { monNonSecureRead(v); monNonSecureWrite(v); return *this; } chain allPrivileges(bool v = true) const { userNonSecureRead(v); userNonSecureWrite(v); userSecureRead(v); userSecureWrite(v); privNonSecureRead(v); privNonSecureWrite(v); privSecureRead(v); privSecureWrite(v); hypRead(v); hypWrite(v); monSecureRead(v); monSecureWrite(v); monNonSecureRead(v); monNonSecureWrite(v); return *this; } chain nonSecure(bool v = true) const { userNonSecureRead(v); userNonSecureWrite(v); privNonSecureRead(v); privNonSecureWrite(v); hypRead(v); hypWrite(v); monNonSecureRead(v); monNonSecureWrite(v); return *this; } chain secure(bool v = true) const { userSecureRead(v); userSecureWrite(v); privSecureRead(v); privSecureWrite(v); monSecureRead(v); monSecureWrite(v); return *this; } chain reads(bool v) const { userNonSecureRead(v); userSecureRead(v); privNonSecureRead(v); privSecureRead(v); hypRead(v); monSecureRead(v); monNonSecureRead(v); return *this; } chain writes(bool v) const { userNonSecureWrite(v); userSecureWrite(v); privNonSecureWrite(v); privSecureWrite(v); hypWrite(v); monSecureWrite(v); monNonSecureWrite(v); return *this; } chain exceptUserMode() const { user(0); return *this; } chain highest(ArmSystem *const sys) const; MiscRegLUTEntryInitializer(struct MiscRegLUTEntry &e, std::bitset<NUM_MISCREG_INFOS> &i) : entry(e), info(i) { // force unimplemented registers to be thusly declared implemented(1); } }; const MiscRegLUTEntryInitializer InitReg(uint32_t reg) { return MiscRegLUTEntryInitializer(lookUpMiscReg[reg], miscRegInfo[reg]); } void initializeMiscRegMetadata(); RegVal miscRegs[NumMiscRegs]; const IntRegIndex *intRegMap; void updateRegMap(CPSR cpsr) { if (cpsr.width == 0) { intRegMap = IntReg64Map; } else { switch (cpsr.mode) { case MODE_USER: case MODE_SYSTEM: intRegMap = IntRegUsrMap; break; case MODE_FIQ: intRegMap = IntRegFiqMap; break; case MODE_IRQ: intRegMap = IntRegIrqMap; break; case MODE_SVC: intRegMap = IntRegSvcMap; break; case MODE_MON: intRegMap = IntRegMonMap; break; case MODE_ABORT: intRegMap = IntRegAbtMap; break; case MODE_HYP: intRegMap = IntRegHypMap; break; case MODE_UNDEFINED: intRegMap = IntRegUndMap; break; default: panic("Unrecognized mode setting in CPSR.\n"); } } } BaseISADevice &getGenericTimer(); BaseISADevice &getGICv3CPUInterface(); private: void assert32() { assert(((CPSR)readMiscReg(MISCREG_CPSR)).width); } void assert64() { assert(!((CPSR)readMiscReg(MISCREG_CPSR)).width); } public: void clear(); protected: void clear32(const ArmISAParams *p, const SCTLR &sctlr_rst); void clear64(const ArmISAParams *p); void initID32(const ArmISAParams *p); void initID64(const ArmISAParams *p); void addressTranslation(TLB::ArmTranslationType tran_type, BaseTLB::Mode mode, Request::Flags flags, RegVal val); void addressTranslation64(TLB::ArmTranslationType tran_type, BaseTLB::Mode mode, Request::Flags flags, RegVal val); public: SelfDebug* getSelfDebug() const { return selfDebug; } static SelfDebug* getSelfDebug(ThreadContext *tc) { auto *arm_isa = static_cast<ArmISA::ISA *>(tc->getIsaPtr()); return arm_isa->getSelfDebug(); } RegVal readMiscRegNoEffect(int misc_reg) const; RegVal readMiscReg(int misc_reg); void setMiscRegNoEffect(int misc_reg, RegVal val); void setMiscReg(int misc_reg, RegVal val); RegId flattenRegId(const RegId& regId) const { switch (regId.classValue()) { case IntRegClass: return RegId(IntRegClass, flattenIntIndex(regId.index())); case FloatRegClass: return RegId(FloatRegClass, flattenFloatIndex(regId.index())); case VecRegClass: return RegId(VecRegClass, flattenVecIndex(regId.index())); case VecElemClass: return RegId(VecElemClass, flattenVecElemIndex(regId.index()), regId.elemIndex()); case VecPredRegClass: return RegId(VecPredRegClass, flattenVecPredIndex(regId.index())); case CCRegClass: return RegId(CCRegClass, flattenCCIndex(regId.index())); case MiscRegClass: return RegId(MiscRegClass, flattenMiscIndex(regId.index())); } return RegId(); } int flattenIntIndex(int reg) const { assert(reg >= 0); if (reg < NUM_ARCH_INTREGS) { return intRegMap[reg]; } else if (reg < NUM_INTREGS) { return reg; } else if (reg == INTREG_SPX) { CPSR cpsr = miscRegs[MISCREG_CPSR]; ExceptionLevel el = opModeToEL( (OperatingMode) (uint8_t) cpsr.mode); if (!cpsr.sp && el != EL0) return INTREG_SP0; switch (el) { case EL3: return INTREG_SP3; case EL2: return INTREG_SP2; case EL1: return INTREG_SP1; case EL0: return INTREG_SP0; default: panic("Invalid exception level"); return 0; // Never happens. } } else { return flattenIntRegModeIndex(reg); } } int flattenFloatIndex(int reg) const { assert(reg >= 0); return reg; } int flattenVecIndex(int reg) const { assert(reg >= 0); return reg; } int flattenVecElemIndex(int reg) const { assert(reg >= 0); return reg; } int flattenVecPredIndex(int reg) const { assert(reg >= 0); return reg; } int flattenCCIndex(int reg) const { assert(reg >= 0); return reg; } int flattenMiscIndex(int reg) const { assert(reg >= 0); int flat_idx = reg; if (reg == MISCREG_SPSR) { CPSR cpsr = miscRegs[MISCREG_CPSR]; switch (cpsr.mode) { case MODE_EL0T: warn("User mode does not have SPSR\n"); flat_idx = MISCREG_SPSR; break; case MODE_EL1T: case MODE_EL1H: flat_idx = MISCREG_SPSR_EL1; break; case MODE_EL2T: case MODE_EL2H: flat_idx = MISCREG_SPSR_EL2; break; case MODE_EL3T: case MODE_EL3H: flat_idx = MISCREG_SPSR_EL3; break; case MODE_USER: warn("User mode does not have SPSR\n"); flat_idx = MISCREG_SPSR; break; case MODE_FIQ: flat_idx = MISCREG_SPSR_FIQ; break; case MODE_IRQ: flat_idx = MISCREG_SPSR_IRQ; break; case MODE_SVC: flat_idx = MISCREG_SPSR_SVC; break; case MODE_MON: flat_idx = MISCREG_SPSR_MON; break; case MODE_ABORT: flat_idx = MISCREG_SPSR_ABT; break; case MODE_HYP: flat_idx = MISCREG_SPSR_HYP; break; case MODE_UNDEFINED: flat_idx = MISCREG_SPSR_UND; break; default: warn("Trying to access SPSR in an invalid mode: %d\n", cpsr.mode); flat_idx = MISCREG_SPSR; break; } } else if (miscRegInfo[reg][MISCREG_MUTEX]) { // Mutually exclusive CP15 register switch (reg) { case MISCREG_PRRR_MAIR0: case MISCREG_PRRR_MAIR0_NS: case MISCREG_PRRR_MAIR0_S: { TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); // If the muxed reg has been flattened, work out the // offset and apply it to the unmuxed reg int idxOffset = reg - MISCREG_PRRR_MAIR0; if (ttbcr.eae) flat_idx = flattenMiscIndex(MISCREG_MAIR0 + idxOffset); else flat_idx = flattenMiscIndex(MISCREG_PRRR + idxOffset); } break; case MISCREG_NMRR_MAIR1: case MISCREG_NMRR_MAIR1_NS: case MISCREG_NMRR_MAIR1_S: { TTBCR ttbcr = readMiscRegNoEffect(MISCREG_TTBCR); // If the muxed reg has been flattened, work out the // offset and apply it to the unmuxed reg int idxOffset = reg - MISCREG_NMRR_MAIR1; if (ttbcr.eae) flat_idx = flattenMiscIndex(MISCREG_MAIR1 + idxOffset); else flat_idx = flattenMiscIndex(MISCREG_NMRR + idxOffset); } break; case MISCREG_PMXEVTYPER_PMCCFILTR: { PMSELR pmselr = miscRegs[MISCREG_PMSELR]; if (pmselr.sel == 31) flat_idx = flattenMiscIndex(MISCREG_PMCCFILTR); else flat_idx = flattenMiscIndex(MISCREG_PMXEVTYPER); } break; default: panic("Unrecognized misc. register.\n"); break; } } else { if (miscRegInfo[reg][MISCREG_BANKED]) { bool secureReg = haveSecurity && !highestELIs64 && inSecureState(miscRegs[MISCREG_SCR], miscRegs[MISCREG_CPSR]); flat_idx += secureReg ? 2 : 1; } else { flat_idx = snsBankedIndex64((MiscRegIndex)reg, !inSecureState(miscRegs[MISCREG_SCR], miscRegs[MISCREG_CPSR])); } } return flat_idx; } /** * Returns the enconcing equivalent when VHE is implemented and * HCR_EL2.E2H is enabled and executing at EL2 */ int redirectRegVHE(ThreadContext * tc, int misc_reg) { const HCR hcr = readMiscRegNoEffect(MISCREG_HCR_EL2); if (hcr.e2h == 0x0 || currEL(tc) != EL2) return misc_reg; SCR scr = readMiscRegNoEffect(MISCREG_SCR_EL3); bool sec_el2 = scr.eel2 && haveSecEL2; switch(misc_reg) { case MISCREG_SPSR_EL1: return MISCREG_SPSR_EL2; case MISCREG_ELR_EL1: return MISCREG_ELR_EL2; case MISCREG_SCTLR_EL1: return MISCREG_SCTLR_EL2; case MISCREG_CPACR_EL1: return MISCREG_CPTR_EL2; // case : // return MISCREG_TRFCR_EL2; case MISCREG_TTBR0_EL1: return MISCREG_TTBR0_EL2; case MISCREG_TTBR1_EL1: return MISCREG_TTBR1_EL2; case MISCREG_TCR_EL1: return MISCREG_TCR_EL2; case MISCREG_AFSR0_EL1: return MISCREG_AFSR0_EL2; case MISCREG_AFSR1_EL1: return MISCREG_AFSR1_EL2; case MISCREG_ESR_EL1: return MISCREG_ESR_EL2; case MISCREG_FAR_EL1: return MISCREG_FAR_EL2; case MISCREG_MAIR_EL1: return MISCREG_MAIR_EL2; case MISCREG_AMAIR_EL1: return MISCREG_AMAIR_EL2; case MISCREG_VBAR_EL1: return MISCREG_VBAR_EL2; case MISCREG_CONTEXTIDR_EL1: return MISCREG_CONTEXTIDR_EL2; case MISCREG_CNTKCTL_EL1: return MISCREG_CNTHCTL_EL2; case MISCREG_CNTP_TVAL_EL0: return sec_el2? MISCREG_CNTHPS_TVAL_EL2: MISCREG_CNTHP_TVAL_EL2; case MISCREG_CNTP_CTL_EL0: return sec_el2? MISCREG_CNTHPS_CTL_EL2: MISCREG_CNTHP_CTL_EL2; case MISCREG_CNTP_CVAL_EL0: return sec_el2? MISCREG_CNTHPS_CVAL_EL2: MISCREG_CNTHP_CVAL_EL2; case MISCREG_CNTV_TVAL_EL0: return sec_el2? MISCREG_CNTHVS_TVAL_EL2: MISCREG_CNTHV_TVAL_EL2; case MISCREG_CNTV_CTL_EL0: return sec_el2? MISCREG_CNTHVS_CTL_EL2: MISCREG_CNTHV_CTL_EL2; case MISCREG_CNTV_CVAL_EL0: return sec_el2? MISCREG_CNTHVS_CVAL_EL2: MISCREG_CNTHV_CVAL_EL2; default: return misc_reg; } /*should not be accessible */ return misc_reg; } int snsBankedIndex64(MiscRegIndex reg, bool ns) const { int reg_as_int = static_cast<int>(reg); if (miscRegInfo[reg][MISCREG_BANKED64]) { reg_as_int += (haveSecurity && !ns) ? 2 : 1; } return reg_as_int; } std::pair<int,int> getMiscIndices(int misc_reg) const { // Note: indexes of AArch64 registers are left unchanged int flat_idx = flattenMiscIndex(misc_reg); if (lookUpMiscReg[flat_idx].lower == 0) { return std::make_pair(flat_idx, 0); } // do additional S/NS flattenings if mapped to NS while in S bool S = haveSecurity && !highestELIs64 && inSecureState(miscRegs[MISCREG_SCR], miscRegs[MISCREG_CPSR]); int lower = lookUpMiscReg[flat_idx].lower; int upper = lookUpMiscReg[flat_idx].upper; // upper == 0, which is CPSR, is not MISCREG_BANKED_CHILD (no-op) lower += S && miscRegInfo[lower][MISCREG_BANKED_CHILD]; upper += S && miscRegInfo[upper][MISCREG_BANKED_CHILD]; return std::make_pair(lower, upper); } unsigned getCurSveVecLenInBits() const; unsigned getCurSveVecLenInBitsAtReset() const { return sveVL * 128; } static void zeroSveVecRegUpperPart(VecRegContainer &vc, unsigned eCount); void serialize(CheckpointOut &cp) const override { DPRINTF(Checkpoint, "Serializing Arm Misc Registers\n"); SERIALIZE_ARRAY(miscRegs, NUM_PHYS_MISCREGS); } void unserialize(CheckpointIn &cp) override { DPRINTF(Checkpoint, "Unserializing Arm Misc Registers\n"); UNSERIALIZE_ARRAY(miscRegs, NUM_PHYS_MISCREGS); CPSR tmp_cpsr = miscRegs[MISCREG_CPSR]; updateRegMap(tmp_cpsr); } void startup() override; void setupThreadContext(); void takeOverFrom(ThreadContext *new_tc, ThreadContext *old_tc) override; Enums::DecoderFlavor decoderFlavor() const { return _decoderFlavor; } /** Returns true if the ISA has a GICv3 cpu interface */ bool haveGICv3CpuIfc() const { // gicv3CpuInterface is initialized at startup time, hence // trying to read its value before the startup stage will lead // to an error assert(afterStartup); return gicv3CpuInterface != nullptr; } Enums::VecRegRenameMode vecRegRenameMode() const { return _vecRegRenameMode; } typedef ArmISAParams Params; const Params *params() const; ISA(Params *p); }; } template<> struct RenameMode<ArmISA::ISA> { static Enums::VecRegRenameMode init(const BaseISA* isa) { auto arm_isa = dynamic_cast<const ArmISA::ISA *>(isa); assert(arm_isa); return arm_isa->vecRegRenameMode(); } static Enums::VecRegRenameMode mode(const ArmISA::PCState& pc) { if (pc.aarch64()) { return Enums::Full; } else { return Enums::Elem; } } static bool equalsInit(const BaseISA* isa1, const BaseISA* isa2) { return init(isa1) == init(isa2); } }; #endif
[ "asaxena317@krishna-srv4.ece.gatech.edu" ]
asaxena317@krishna-srv4.ece.gatech.edu
ff66eac1b95cc9c078a7fe040adc6b14887055be
9f60ad21ecc6ace24ca69621382d884c446b08c3
/Giant.h
8685820f3dd203ac85015a2452cede9e1184398f
[]
no_license
SpiceSoy/NoBacking
5eb491e2efcefabe780ce339d8ae9dea5a95d5f4
edbb52a15eb7f6c68054e92f4a0f2ffb411c1959
refs/heads/master
2022-01-26T21:34:51.532534
2019-06-12T13:16:23
2019-06-12T13:16:23
188,994,521
0
0
null
null
null
null
UTF-8
C++
false
false
435
h
#pragma once #include "GameObject.h" #include "Animation.h" #include "State.h" #include <atlimage.h> class Giant : public GameStateObject { float maxHP = 100; public: Giant(GameFramework* framework, const std::string& tag); float delayCounter = 0.0f; virtual void Update(float deltaTime) override; virtual void Draw(PaintInfo info) override; virtual void Reset() {}; virtual void Damaged(int hp, bool off = false) override; };
[ "kimhj06160@gmail.com" ]
kimhj06160@gmail.com
94d7b609e7f23a08c2a8c331c13db77c99e53146
249551d6f2cb7a58b9605a0e83e0256273a24a37
/src/SC_InsertableIBLT.h
2baaf5eeb6bb54e73d51c6321ecb66ff0013a070
[]
no_license
cortalo/ColdFilter
1793e1c4c3a654e1a9df7cad0677aa01159c3ad4
7000cbdfbede18299866311f16e7bcb285735b5e
refs/heads/master
2020-03-13T12:36:01.993922
2018-10-24T03:09:54
2018-10-24T03:09:54
131,122,556
0
0
null
2018-04-26T08:13:16
2018-04-26T08:13:15
null
UTF-8
C++
false
false
1,218
h
#ifndef STREAMCLASSIFIER_SC_IBLT_H #define STREAMCLASSIFIER_SC_IBLT_H #include "InsertableIblt.h" #include "SC.h" #define T2 241 template<uint64_t iblt_size_in_bytes, uint64_t sc_memory_in_bytes, uint32_t bucket_num = 200> class SC_InsertableIBLT: public VirtualIBLT { StreamClassifier<sc_memory_in_bytes, bucket_num, 16, T2> sc; InsertableIBLT<iblt_size_in_bytes> iblt; public: SC_InsertableIBLT() { sc.init_spa(&iblt); // sc.print_basic_info(); } inline void build(uint32_t * items, int n) { for (int i = 0; i < n; ++i) { sc.insert(items[i]); } sc.refresh(); } void dump(unordered_map<uint32_t, int> &result) { iblt.dump(result); for (auto itr: result) { int remain = sc.query(itr.first); result[itr.first] += remain; } } int approximate_query(uint32_t key) { int val_sc = sc.query(key); int val_iblt = iblt.approximate_query(key); if (val_iblt == 0) { return val_sc; } else if (val_sc != 15 + T2) { return val_sc; } else { return -1; } } }; #endif //STREAMCLASSIFIER_SC_IBLT_H
[ "1939883477@qq.com" ]
1939883477@qq.com
e3e4ebab602556e1fd49bfdb0dfe8f9e69398768
c507645952553f2a7e93c14ec19ff3246feca49b
/src/Transform.h
2a934fa74b91f5604abdf3ceb3325af8e2d0f1ba
[]
no_license
LeifNode/KinectProject
33a6fc002b7a513245ce0202829c55b3365f0b86
68b9fe0279dbf672670ae2b6ed92a0656dc5732d
refs/heads/master
2021-03-12T23:19:26.096556
2015-01-13T23:57:41
2015-01-13T23:57:41
20,317,533
0
0
null
null
null
null
UTF-8
C++
false
false
978
h
#pragma once #include "d3dStd.h" class Transform { public: Transform(); ~Transform(); void rotate(const XMVECTOR& rotationQuaternion); XMVECTOR getRotation() const { return mRotationQuat; } void setRotation(const XMVECTOR& rotation) { mTransformDirty = true; mRotationQuat = rotation; } XMVECTOR getScale() const { return mScaling; } void scale(float scale); void scale(float x, float y, float z); void scale(const XMVECTOR& scalingAxis); void setScale(float scale); void setScale(float scaleX, float scaleY, float scaleZ); void setScale(const XMVECTOR& scaleVec); void translate(const XMVECTOR& offset); void setTranslation(const XMVECTOR& translation) { mTranslation = translation; } XMVECTOR getTranslation() const { return mTranslation; } XMMATRIX getTransform(); void reset(); private: mutable bool mTransformDirty; XMMATRIX mTransformation; XMVECTOR mRotationQuat; XMVECTOR mRotationOrigin; XMVECTOR mScaling; XMVECTOR mTranslation; };
[ "LErkenbrach@gmail.com" ]
LErkenbrach@gmail.com
a8332fb95c4d984aebcd59b5ab7ca1b1626f80ce
04b1803adb6653ecb7cb827c4f4aa616afacf629
/chrome/browser/ui/webui/version_handler_win_unittest.cc
9345bb0a2407dece491d665a201ba3527d8af201
[ "BSD-3-Clause" ]
permissive
Samsung/Castanets
240d9338e097b75b3f669604315b06f7cf129d64
4896f732fc747dfdcfcbac3d442f2d2d42df264a
refs/heads/castanets_76_dev
2023-08-31T09:01:04.744346
2021-07-30T04:56:25
2021-08-11T05:45:21
125,484,161
58
49
BSD-3-Clause
2022-10-16T19:31:26
2018-03-16T08:07:37
null
UTF-8
C++
false
false
3,190
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ui/webui/version_handler_win.h" #include "base/test/scoped_os_info_override_win.h" #include "base/test/test_reg_util_win.h" #include "base/win/registry.h" #include "chrome/browser/ui/webui/version_handler_win.h" #include "testing/gtest/include/gtest/gtest.h" class WebUIWindowsVersion : public testing::Test { protected: base::win::RegKey ubr_key; void SetUp() override { ASSERT_NO_FATAL_FAILURE(registry_override_manager_.OverrideRegistry(root)); ubr_key.Create(root, ubr_loc, KEY_ALL_ACCESS); EXPECT_TRUE(ubr_key.Valid()); } void TearDown() override { ubr_key.DeleteKey(ubr_loc); ubr_key.Close(); } private: const HKEY root = HKEY_LOCAL_MACHINE; // Win10 UBR, see base::win::OSInfo const wchar_t* ubr_loc = L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"; registry_util::RegistryOverrideManager registry_override_manager_; }; TEST_F(WebUIWindowsVersion, Win10Pro) { // set Windows Registry Key UBR ubr_key.WriteValue(L"UBR", 555); ubr_key.WriteValue(L"ReleaseId", L"1000"); // override base::win::OSInfo base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWin10Pro); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "10 OS Version 1000 (Build 15063.555)"); } TEST_F(WebUIWindowsVersion, WinServer2016) { ubr_key.WriteValue(L"UBR", 1555); ubr_key.WriteValue(L"ReleaseId", L"1001"); base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWinServer2016); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "Server OS Version 1001 (Build 17134.1555)"); } TEST_F(WebUIWindowsVersion, Win81Pro) { ubr_key.WriteValue(L"UBR", 0UL); ubr_key.WriteValue(L"ReleaseId", L"1001"); base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWin81Pro); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "8.1 Version 1001 (Build 9600)"); } TEST_F(WebUIWindowsVersion, WinServer2012R2) { ubr_key.WriteValue(L"UBR", 0UL); ubr_key.WriteValue(L"ReleaseId", L"1001"); base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWinServer2012R2); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "Server 2012 R2 Version 1001 (Build 9600)"); } TEST_F(WebUIWindowsVersion, Win7ProSP1) { ubr_key.WriteValue(L"UBR", 0UL); ubr_key.WriteValue(L"ReleaseId", L"1001"); base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWin7ProSP1); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "7 Service Pack 1 Version 1001 (Build 7601)"); } TEST_F(WebUIWindowsVersion, Win7ProSP1NoReleaseId) { ubr_key.WriteValue(L"UBR", 0UL); base::test::ScopedOSInfoOverride os( base::test::ScopedOSInfoOverride::Type::kWin7ProSP1); EXPECT_EQ(VersionHandlerWindows::GetFullWindowsVersionForTesting(), "7 Service Pack 1 (Build 7601)"); }
[ "sunny.nam@samsung.com" ]
sunny.nam@samsung.com
3d47303ac1c532d23d9912611360cc3c55bef059
ec68c973b7cd3821dd70ed6787497a0f808e18e1
/Cpp/SDK/ImpactEffect_Weapon_Blade_Metal_Medium_classes.h
d7fd7c054b23674fa46ec5a4e1241124a38d15f8
[]
no_license
Hengle/zRemnant-SDK
05be5801567a8cf67e8b03c50010f590d4e2599d
be2d99fb54f44a09ca52abc5f898e665964a24cb
refs/heads/main
2023-07-16T04:44:43.113226
2021-08-27T14:26:40
2021-08-27T14:26:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
803
h
#pragma once // Name: Remnant, Version: 1.0 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass ImpactEffect_Weapon_Blade_Metal_Medium.ImpactEffect_Weapon_Blade_Metal_Medium_C // 0x0000 class AImpactEffect_Weapon_Blade_Metal_Medium_C : public AImpactEffect_Weapon_Melee_C { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass ImpactEffect_Weapon_Blade_Metal_Medium.ImpactEffect_Weapon_Blade_Metal_Medium_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
7a039f6fd6519ee2022f385e9e35e376ed97c2a0
ea2b32a0af294fd00f0256bab48bc28925c54d24
/Server_LinuxSystemUtility/thirdpart/Simple-WebSocket-Server/server_ws.hpp
625323c065a6a5864a80188f42a082939d20345e
[]
no_license
vivatakethat/LinuxSystemUtility
531ec52d692a210f0c3f0262ce9a063dd9c0ee24
69fb3a6ee0e2f0c505d0a34c101cd409da93f978
refs/heads/main
2023-04-10T00:47:42.813731
2021-04-16T07:35:48
2021-04-16T07:35:48
305,148,617
0
0
null
null
null
null
UTF-8
C++
false
false
30,812
hpp
#ifndef SERVER_WS_HPP #define SERVER_WS_HPP #include "crypto.hpp" #include "utility.hpp" #include <array> #include <atomic> #include <iostream> #include <limits> #include <list> #include <memory> #include <mutex> #include <thread> #include <unordered_set> #ifdef USE_STANDALONE_ASIO #include <asio.hpp> #include <asio/steady_timer.hpp> namespace SimpleWeb { using error_code = std::error_code; using errc = std::errc; namespace make_error_code = std; } // namespace SimpleWeb #else #include <boost/asio.hpp> #include <boost/asio/steady_timer.hpp> namespace SimpleWeb { namespace asio = boost::asio; using error_code = boost::system::error_code; namespace errc = boost::system::errc; namespace make_error_code = boost::system::errc; } // namespace SimpleWeb #endif // Late 2017 TODO: remove the following checks and always use std::regex #ifdef USE_BOOST_REGEX #include <boost/regex.hpp> namespace SimpleWeb { namespace regex = boost; } #else #include <regex> namespace SimpleWeb { namespace regex = std; } #endif namespace SimpleWeb { template <class socket_type> class SocketServer; template <class socket_type> class SocketServerBase { public: class Message : public std::istream { friend class SocketServerBase<socket_type>; public: unsigned char fin_rsv_opcode; std::size_t size() noexcept { return length; } /// Convenience function to return std::string. The stream buffer is consumed. std::string string() noexcept { try { std::string str; auto size = streambuf.size(); str.resize(size); read(&str[0], static_cast<std::streamsize>(size)); return str; } catch(...) { return std::string(); } } private: Message() noexcept : std::istream(&streambuf), length(0) {} Message(unsigned char fin_rsv_opcode, std::size_t length) noexcept : std::istream(&streambuf), fin_rsv_opcode(fin_rsv_opcode), length(length) {} std::size_t length; asio::streambuf streambuf; }; /// The buffer is not consumed during send operations. /// Do not alter while sending. class SendStream : public std::ostream { friend class SocketServerBase<socket_type>; asio::streambuf streambuf; public: SendStream() noexcept : std::ostream(&streambuf) {} /// Returns the size of the buffer std::size_t size() const noexcept { return streambuf.size(); } }; class Connection : public std::enable_shared_from_this<Connection> { friend class SocketServerBase<socket_type>; friend class SocketServer<socket_type>; public: Connection(std::unique_ptr<socket_type> &&socket) noexcept : socket(std::move(socket)), timeout_idle(0), strand(this->socket->get_io_service()), closed(false) {} std::string method, path, query_string, http_version; CaseInsensitiveMultimap header; regex::smatch path_match; asio::ip::tcp::endpoint remote_endpoint; std::string remote_endpoint_address() noexcept { try { return remote_endpoint.address().to_string(); } catch(...) { return std::string(); } } unsigned short remote_endpoint_port() noexcept { return remote_endpoint.port(); } private: template <typename... Args> Connection(std::shared_ptr<ScopeRunner> handler_runner, long timeout_idle, Args &&... args) noexcept : handler_runner(std::move(handler_runner)), socket(new socket_type(std::forward<Args>(args)...)), timeout_idle(timeout_idle), strand(socket->get_io_service()), closed(false) {} std::shared_ptr<ScopeRunner> handler_runner; std::unique_ptr<socket_type> socket; // Socket must be unique_ptr since asio::ssl::stream<asio::ip::tcp::socket> is not movable std::mutex socket_close_mutex; asio::streambuf read_buffer; std::shared_ptr<Message> fragmented_message; long timeout_idle; std::unique_ptr<asio::steady_timer> timer; std::mutex timer_mutex; void close() noexcept { error_code ec; std::unique_lock<std::mutex> lock(socket_close_mutex); // The following operations seems to be needed to run sequentially socket->lowest_layer().shutdown(asio::ip::tcp::socket::shutdown_both, ec); socket->lowest_layer().close(ec); } void set_timeout(long seconds = -1) noexcept { bool use_timeout_idle = false; if(seconds == -1) { use_timeout_idle = true; seconds = timeout_idle; } std::unique_lock<std::mutex> lock(timer_mutex); if(seconds == 0) { timer = nullptr; return; } timer = std::unique_ptr<asio::steady_timer>(new asio::steady_timer(socket->get_io_service())); timer->expires_from_now(std::chrono::seconds(seconds)); std::weak_ptr<Connection> connection_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed timer->async_wait([connection_weak, use_timeout_idle](const error_code &ec) { if(!ec) { if(auto connection = connection_weak.lock()) { if(use_timeout_idle) connection->send_close(1000, "idle timeout"); // 1000=normal closure else connection->close(); } } }); } void cancel_timeout() noexcept { std::unique_lock<std::mutex> lock(timer_mutex); if(timer) { error_code ec; timer->cancel(ec); } } bool generate_handshake(const std::shared_ptr<asio::streambuf> &write_buffer) { std::ostream handshake(write_buffer.get()); auto header_it = header.find("Sec-WebSocket-Key"); if(header_it == header.end()) return false; static auto ws_magic_string = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; auto sha1 = Crypto::sha1(header_it->second + ws_magic_string); handshake << "HTTP/1.1 101 Web Socket Protocol Handshake\r\n"; handshake << "Upgrade: websocket\r\n"; handshake << "Connection: Upgrade\r\n"; handshake << "Sec-WebSocket-Accept: " << Crypto::Base64::encode(sha1) << "\r\n"; handshake << "\r\n"; return true; } asio::io_service::strand strand; class SendData { public: SendData(std::shared_ptr<SendStream> header_stream, std::shared_ptr<SendStream> message_stream, std::function<void(const error_code)> &&callback) noexcept : header_stream(std::move(header_stream)), message_stream(std::move(message_stream)), callback(std::move(callback)) {} std::shared_ptr<SendStream> header_stream; std::shared_ptr<SendStream> message_stream; std::function<void(const error_code)> callback; }; std::list<SendData> send_queue; void send_from_queue() { auto self = this->shared_from_this(); strand.post([self]() { asio::async_write(*self->socket, self->send_queue.begin()->header_stream->streambuf, self->strand.wrap([self](const error_code &ec, std::size_t /*bytes_transferred*/) { auto lock = self->handler_runner->continue_lock(); if(!lock) return; if(!ec) { asio::async_write(*self->socket, self->send_queue.begin()->message_stream->streambuf.data(), self->strand.wrap([self](const error_code &ec, std::size_t /*bytes_transferred*/) { auto lock = self->handler_runner->continue_lock(); if(!lock) return; auto send_queued = self->send_queue.begin(); if(send_queued->callback) send_queued->callback(ec); if(!ec) { self->send_queue.erase(send_queued); if(self->send_queue.size() > 0) self->send_from_queue(); } else self->send_queue.clear(); })); } else { auto send_queued = self->send_queue.begin(); if(send_queued->callback) send_queued->callback(ec); self->send_queue.clear(); } })); }); } std::atomic<bool> closed; void read_remote_endpoint() noexcept { try { remote_endpoint = socket->lowest_layer().remote_endpoint(); } catch(...) { } } public: /// fin_rsv_opcode: 129=one fragment, text, 130=one fragment, binary, 136=close connection. /// See http://tools.ietf.org/html/rfc6455#section-5.2 for more information void send(const std::shared_ptr<SendStream> &send_stream, const std::function<void(const error_code &)> &callback = nullptr, unsigned char fin_rsv_opcode = 129) { cancel_timeout(); set_timeout(); auto header_stream = std::make_shared<SendStream>(); std::size_t length = send_stream->size(); header_stream->put(static_cast<char>(fin_rsv_opcode)); // Unmasked (first length byte<128) if(length >= 126) { std::size_t num_bytes; if(length > 0xffff) { num_bytes = 8; header_stream->put(127); } else { num_bytes = 2; header_stream->put(126); } for(std::size_t c = num_bytes - 1; c != static_cast<std::size_t>(-1); c--) header_stream->put((static_cast<unsigned long long>(length) >> (8 * c)) % 256); } else header_stream->put(static_cast<char>(length)); auto self = this->shared_from_this(); strand.post([self, header_stream, send_stream, callback]() { self->send_queue.emplace_back(header_stream, send_stream, callback); if(self->send_queue.size() == 1) self->send_from_queue(); }); } void send_close(int status, const std::string &reason = "", const std::function<void(const error_code &)> &callback = nullptr) { // Send close only once (in case close is initiated by server) if(closed) return; closed = true; auto send_stream = std::make_shared<SendStream>(); send_stream->put(status >> 8); send_stream->put(status % 256); *send_stream << reason; // fin_rsv_opcode=136: message close send(send_stream, callback, 136); } }; class Endpoint { friend class SocketServerBase<socket_type>; private: std::unordered_set<std::shared_ptr<Connection>> connections; std::mutex connections_mutex; public: std::function<void(std::shared_ptr<Connection>)> on_open; std::function<void(std::shared_ptr<Connection>, std::shared_ptr<Message>)> on_message; std::function<void(std::shared_ptr<Connection>, int, const std::string &)> on_close; std::function<void(std::shared_ptr<Connection>, const error_code &)> on_error; std::function<void(std::shared_ptr<Connection>)> on_ping; std::function<void(std::shared_ptr<Connection>)> on_pong; std::unordered_set<std::shared_ptr<Connection>> get_connections() noexcept { std::unique_lock<std::mutex> lock(connections_mutex); auto copy = connections; return copy; } }; class Config { friend class SocketServerBase<socket_type>; private: Config(unsigned short port) noexcept : port(port) {} public: /// Port number to use. Defaults to 80 for HTTP and 443 for HTTPS. Set to 0 get an assigned port. unsigned short port; /// If io_service is not set, number of threads that the server will use when start() is called. /// Defaults to 1 thread. std::size_t thread_pool_size = 1; /// Timeout on request handling. Defaults to 5 seconds. long timeout_request = 5; /// Idle timeout. Defaults to no timeout. long timeout_idle = 0; /// Maximum size of incoming messages. Defaults to architecture maximum. /// Exceeding this limit will result in a message_size error code and the connection will be closed. std::size_t max_message_size = std::numeric_limits<std::size_t>::max(); /// IPv4 address in dotted decimal form or IPv6 address in hexadecimal notation. /// If empty, the address will be any address. std::string address; /// Set to false to avoid binding the socket to an address that is already in use. Defaults to true. bool reuse_address = true; }; /// Set before calling start(). Config config; private: class regex_orderable : public regex::regex { std::string str; public: regex_orderable(const char *regex_cstr) : regex::regex(regex_cstr), str(regex_cstr) {} regex_orderable(const std::string &regex_str) : regex::regex(regex_str), str(regex_str) {} bool operator<(const regex_orderable &rhs) const noexcept { return str < rhs.str; } }; public: /// Warning: do not add or remove endpoints after start() is called std::map<regex_orderable, Endpoint> endpoint; /// If you know the server port in advance, use start() instead. /// Returns assigned port. If io_service is not set, an internal io_service is created instead. /// Call before accept_and_run(). unsigned short bind() { asio::ip::tcp::endpoint endpoint; if(config.address.size() > 0) endpoint = asio::ip::tcp::endpoint(asio::ip::address::from_string(config.address), config.port); else endpoint = asio::ip::tcp::endpoint(asio::ip::tcp::v4(), config.port); if(!io_service) { io_service = std::make_shared<asio::io_service>(); internal_io_service = true; } if(!acceptor) acceptor = std::unique_ptr<asio::ip::tcp::acceptor>(new asio::ip::tcp::acceptor(*io_service)); acceptor->open(endpoint.protocol()); acceptor->set_option(asio::socket_base::reuse_address(config.reuse_address)); acceptor->bind(endpoint); after_bind(); return acceptor->local_endpoint().port(); } /// If you know the server port in advance, use start() instead. /// Accept requests, and if io_service was not set before calling bind(), run the internal io_service instead. /// Call after bind(). void accept_and_run() { acceptor->listen(); accept(); if(internal_io_service) { if(io_service->stopped()) io_service->reset(); // If thread_pool_size>1, start m_io_service.run() in (thread_pool_size-1) threads for thread-pooling threads.clear(); for(std::size_t c = 1; c < config.thread_pool_size; c++) { threads.emplace_back([this]() { this->io_service->run(); }); } // Main thread if(config.thread_pool_size > 0) io_service->run(); // Wait for the rest of the threads, if any, to finish as well for(auto &t : threads) t.join(); } } /// Start the server by calling bind() and accept_and_run() void start() { cout<<__LINE__<<endl;//debug bind(); accept_and_run(); } /// Stop accepting new connections, and close current connections void stop() noexcept { if(acceptor) { error_code ec; acceptor->close(ec); for(auto &pair : endpoint) { std::unique_lock<std::mutex> lock(pair.second.connections_mutex); for(auto &connection : pair.second.connections) connection->close(); pair.second.connections.clear(); } if(internal_io_service) io_service->stop(); } } /// Stop accepting new connections void stop_accept() noexcept { if(acceptor) { error_code ec; acceptor->close(ec); } } virtual ~SocketServerBase() noexcept {} std::unordered_set<std::shared_ptr<Connection>> get_connections() noexcept { std::unordered_set<std::shared_ptr<Connection>> all_connections; for(auto &e : endpoint) { std::unique_lock<std::mutex> lock(e.second.connections_mutex); all_connections.insert(e.second.connections.begin(), e.second.connections.end()); } return all_connections; } /** * Upgrades a request, from for instance Simple-Web-Server, to a WebSocket connection. * The parameters are moved to the Connection object. * See also Server::on_upgrade in the Simple-Web-Server project. * The socket's io_service is used, thus running start() is not needed. * * Example use: * server.on_upgrade=[&socket_server] (auto socket, auto request) { * auto connection=std::make_shared<SimpleWeb::SocketServer<SimpleWeb::WS>::Connection>(std::move(socket)); * connection->method=std::move(request->method); * connection->path=std::move(request->path); * connection->query_string=std::move(request->query_string); * connection->http_version=std::move(request->http_version); * connection->header=std::move(request->header); * connection->remote_endpoint=std::move(*request->remote_endpoint); * socket_server.upgrade(connection); * } */ void upgrade(const std::shared_ptr<Connection> &connection) { connection->handler_runner = handler_runner; connection->timeout_idle = config.timeout_idle; write_handshake(connection); } /// If you have your own asio::io_service, store its pointer here before running start(). std::shared_ptr<asio::io_service> io_service; protected: bool internal_io_service = false; std::unique_ptr<asio::ip::tcp::acceptor> acceptor; std::vector<std::thread> threads; std::shared_ptr<ScopeRunner> handler_runner; SocketServerBase(unsigned short port) noexcept : config(port), handler_runner(new ScopeRunner()) {} virtual void after_bind() {} virtual void accept() = 0; void read_handshake(const std::shared_ptr<Connection> &connection) { connection->read_remote_endpoint(); connection->set_timeout(config.timeout_request); asio::async_read_until(*connection->socket, connection->read_buffer, "\r\n\r\n", [this, connection](const error_code &ec, std::size_t /*bytes_transferred*/) { connection->cancel_timeout(); auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { std::istream stream(&connection->read_buffer); if(RequestMessage::parse(stream, connection->method, connection->path, connection->query_string, connection->http_version, connection->header)) write_handshake(connection); } }); } void write_handshake(const std::shared_ptr<Connection> &connection) { for(auto &regex_endpoint : endpoint) { regex::smatch path_match; if(regex::regex_match(connection->path, path_match, regex_endpoint.first)) //take_mark:这个c++11正则表达式要GCC4.9才能生效 { auto write_buffer = std::make_shared<asio::streambuf>(); if(connection->generate_handshake(write_buffer)) { connection->path_match = std::move(path_match); connection->set_timeout(config.timeout_request); asio::async_write(*connection->socket, *write_buffer, [this, connection, write_buffer, &regex_endpoint](const error_code &ec, std::size_t /*bytes_transferred*/) { connection->cancel_timeout(); auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { connection_open(connection, regex_endpoint.second); read_message(connection, regex_endpoint.second); } else connection_error(connection, regex_endpoint.second, ec); }); } return; } } } void read_message(const std::shared_ptr<Connection> &connection, Endpoint &endpoint) const { asio::async_read(*connection->socket, connection->read_buffer, asio::transfer_exactly(2), [this, connection, &endpoint](const error_code &ec, std::size_t bytes_transferred) { auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { if(bytes_transferred == 0) { // TODO: why does this happen sometimes? read_message(connection, endpoint); return; } std::istream stream(&connection->read_buffer); std::array<unsigned char, 2> first_bytes; stream.read((char *)&first_bytes[0], 2); unsigned char fin_rsv_opcode = first_bytes[0]; // Close connection if unmasked message from client (protocol error) if(first_bytes[1] < 128) { const std::string reason("message from client not masked"); connection->send_close(1002, reason); connection_close(connection, endpoint, 1002, reason); return; } std::size_t length = (first_bytes[1] & 127); if(length == 126) { // 2 next bytes is the size of content asio::async_read(*connection->socket, connection->read_buffer, asio::transfer_exactly(2), [this, connection, &endpoint, fin_rsv_opcode](const error_code &ec, std::size_t /*bytes_transferred*/) { auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { std::istream stream(&connection->read_buffer); std::array<unsigned char, 2> length_bytes; stream.read((char *)&length_bytes[0], 2); std::size_t length = 0; std::size_t num_bytes = 2; for(std::size_t c = 0; c < num_bytes; c++) length += static_cast<std::size_t>(length_bytes[c]) << (8 * (num_bytes - 1 - c)); read_message_content(connection, length, endpoint, fin_rsv_opcode); } else connection_error(connection, endpoint, ec); }); } else if(length == 127) { // 8 next bytes is the size of content asio::async_read(*connection->socket, connection->read_buffer, asio::transfer_exactly(8), [this, connection, &endpoint, fin_rsv_opcode](const error_code &ec, std::size_t /*bytes_transferred*/) { auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { std::istream stream(&connection->read_buffer); std::array<unsigned char, 8> length_bytes; stream.read((char *)&length_bytes[0], 8); std::size_t length = 0; std::size_t num_bytes = 8; for(std::size_t c = 0; c < num_bytes; c++) length += static_cast<std::size_t>(length_bytes[c]) << (8 * (num_bytes - 1 - c)); read_message_content(connection, length, endpoint, fin_rsv_opcode); } else connection_error(connection, endpoint, ec); }); } else read_message_content(connection, length, endpoint, fin_rsv_opcode); } else connection_error(connection, endpoint, ec); }); } void read_message_content(const std::shared_ptr<Connection> &connection, std::size_t length, Endpoint &endpoint, unsigned char fin_rsv_opcode) const { if(length + (connection->fragmented_message ? connection->fragmented_message->length : 0) > config.max_message_size) { connection_error(connection, endpoint, make_error_code::make_error_code(errc::message_size)); const int status = 1009; const std::string reason = "message too big"; connection->send_close(status, reason); connection_close(connection, endpoint, status, reason); return; } asio::async_read(*connection->socket, connection->read_buffer, asio::transfer_exactly(4 + length), [this, connection, length, &endpoint, fin_rsv_opcode](const error_code &ec, std::size_t /*bytes_transferred*/) { auto lock = connection->handler_runner->continue_lock(); if(!lock) return; if(!ec) { std::istream istream(&connection->read_buffer); // Read mask std::array<unsigned char, 4> mask; istream.read((char *)&mask[0], 4); std::shared_ptr<Message> message; // If fragmented message if((fin_rsv_opcode & 0x80) == 0 || (fin_rsv_opcode & 0x0f) == 0) { if(!connection->fragmented_message) { connection->fragmented_message = std::shared_ptr<Message>(new Message(fin_rsv_opcode, length)); connection->fragmented_message->fin_rsv_opcode |= 0x80; } else connection->fragmented_message->length += length; message = connection->fragmented_message; } else message = std::shared_ptr<Message>(new Message(fin_rsv_opcode, length)); std::ostream ostream(&message->streambuf); for(std::size_t c = 0; c < length; c++) ostream.put(istream.get() ^ mask[c % 4]); // If connection close if((fin_rsv_opcode & 0x0f) == 8) { connection->cancel_timeout(); connection->set_timeout(); int status = 0; if(length >= 2) { unsigned char byte1 = message->get(); unsigned char byte2 = message->get(); status = (static_cast<int>(byte1) << 8) + byte2; } auto reason = message->string(); connection->send_close(status, reason); this->connection_close(connection, endpoint, status, reason); } // If ping else if((fin_rsv_opcode & 0x0f) == 9) { connection->cancel_timeout(); connection->set_timeout(); // Send pong auto empty_send_stream = std::make_shared<SendStream>(); connection->send(empty_send_stream, nullptr, fin_rsv_opcode + 1); if(endpoint.on_ping) endpoint.on_ping(connection); // Next message this->read_message(connection, endpoint); } // If pong else if((fin_rsv_opcode & 0x0f) == 10) { connection->cancel_timeout(); connection->set_timeout(); if(endpoint.on_pong) endpoint.on_pong(connection); // Next message this->read_message(connection, endpoint); } // If fragmented message and not final fragment else if((fin_rsv_opcode & 0x80) == 0) { // Next message this->read_message(connection, endpoint); } else { connection->cancel_timeout(); connection->set_timeout(); if(endpoint.on_message) endpoint.on_message(connection, message); // Next message // Only reset fragmented_message for non-control frames (control frames can be in between a fragmented message) connection->fragmented_message = nullptr; this->read_message(connection, endpoint); } } else this->connection_error(connection, endpoint, ec); }); } void connection_open(const std::shared_ptr<Connection> &connection, Endpoint &endpoint) const { connection->cancel_timeout(); connection->set_timeout(); { std::unique_lock<std::mutex> lock(endpoint.connections_mutex); endpoint.connections.insert(connection); } if(endpoint.on_open) endpoint.on_open(connection); } void connection_close(const std::shared_ptr<Connection> &connection, Endpoint &endpoint, int status, const std::string &reason) const { connection->cancel_timeout(); connection->set_timeout(); { std::unique_lock<std::mutex> lock(endpoint.connections_mutex); endpoint.connections.erase(connection); } if(endpoint.on_close) endpoint.on_close(connection, status, reason); } void connection_error(const std::shared_ptr<Connection> &connection, Endpoint &endpoint, const error_code &ec) const { connection->cancel_timeout(); connection->set_timeout(); { std::unique_lock<std::mutex> lock(endpoint.connections_mutex); endpoint.connections.erase(connection); } if(endpoint.on_error) endpoint.on_error(connection, ec); } }; template <class socket_type> class SocketServer : public SocketServerBase<socket_type> {}; using WS = asio::ip::tcp::socket; template <> class SocketServer<WS> : public SocketServerBase<WS> { public: SocketServer() noexcept : SocketServerBase<WS>(80) {} protected: void accept() override { std::shared_ptr<Connection> connection(new Connection(handler_runner, config.timeout_idle, *io_service)); acceptor->async_accept(*connection->socket, [this, connection](const error_code &ec) { auto lock = connection->handler_runner->continue_lock(); if(!lock) return; // Immediately start accepting a new connection (if io_service hasn't been stopped) if(ec != asio::error::operation_aborted) accept(); if(!ec) { asio::ip::tcp::no_delay option(true); connection->socket->set_option(option); read_handshake(connection); } }); } }; } // namespace SimpleWeb #endif /* SERVER_WS_HPP */
[ "vivatakethat@foxmail.com" ]
vivatakethat@foxmail.com
6af1e7d25964af7472f52c690f2b7f24ce8cbf2b
1a8ec64d49b93b9e84494cd9848bb0ec3ca9ba64
/qdeltaedit.h
7c865877dc8dbcafc82559b518af5f407355a182
[]
no_license
pavelovcharov/QDeltaEdit
792b9faeec9dbb0489abe8386c35fb2ce471f291
82468dc8ba0ce1edbdf5ff0d15da73bc416bbc8b
refs/heads/master
2021-05-08T11:11:45.059782
2018-02-02T12:00:31
2018-02-02T12:00:31
119,886,087
0
0
null
null
null
null
UTF-8
C++
false
false
393
h
#ifndef QDELTAEDIT_H #define QDELTAEDIT_H #include <QWidget> namespace Ui { class QDeltaEdit; } class QDeltaEdit : public QWidget { Q_OBJECT public: explicit QDeltaEdit(QWidget *parent = 0); ~QDeltaEdit(); void setDelta(double value, double target); private: Ui::QDeltaEdit *ui; double _value; double _target; }; #endif // QDELTAEDIT_H
[ "pavel.ovcharov@devexpress.com" ]
pavel.ovcharov@devexpress.com
60009e41a105fa2aaf1d977797ef6d746d6456ac
0ec9df3bb8b86216e18fe4cb66b6612297245aea
/Sources/CXXBoost/include/boost/algorithm/string/compare.hpp
d19691f3ce4b9aba59d1b8f096c0c5953d5f3270
[]
no_license
jprescott/BoostTestWithLib
78ae59d1ee801201883cf07ab76b8267fadf7daa
8650523cab467c41be60f3a1c144f556e9a7f25c
refs/heads/master
2022-11-18T14:49:00.664753
2020-07-18T21:45:17
2020-07-18T21:45:17
280,749,418
0
1
null
null
null
null
UTF-8
C++
false
false
5,133
hpp
// Boost string_algo library compare.hpp header file -------------------------// // Copyright Pavol Droba 2002-2006. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // See http://www.boost.org/ for updates, documentation, and revision history. #ifndef BOOST_STRING_COMPARE_HPP #define BOOST_STRING_COMPARE_HPP #include <boost/algorithm/string/config.hpp> #include <locale> /*! \file Defines element comparison predicates. Many algorithms in this library can take an additional argument with a predicate used to compare elements. This makes it possible, for instance, to have case insensitive versions of the algorithms. */ namespace boost { namespace algorithm { // is_equal functor -----------------------------------------------// //! is_equal functor /*! Standard STL equal_to only handle comparison between arguments of the same type. This is a less restrictive version which wraps operator ==. */ struct is_equal { //! Function operator /*! Compare two operands for equality */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1==Arg2; } }; //! case insensitive version of is_equal /*! Case insensitive comparison predicate. Comparison is done using specified locales. */ struct is_iequal { //! Constructor /*! \param Loc locales used for comparison */ is_iequal( const std::locale& Loc=std::locale() ) : m_Loc( Loc ) {} //! Function operator /*! Compare two operands. Case is ignored. */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) return std::toupper(Arg1)==std::toupper(Arg2); #else return std::toupper<T1>(Arg1,m_Loc)==std::toupper<T2>(Arg2,m_Loc); #endif } private: std::locale m_Loc; }; // is_less functor -----------------------------------------------// //! is_less functor /*! Convenient version of standard std::less. Operation is templated, therefore it is not required to specify the exact types upon the construction */ struct is_less { //! Functor operation /*! Compare two operands using > operator */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1<Arg2; } }; //! case insensitive version of is_less /*! Case insensitive comparison predicate. Comparison is done using specified locales. */ struct is_iless { //! Constructor /*! \param Loc locales used for comparison */ is_iless( const std::locale& Loc=std::locale() ) : m_Loc( Loc ) {} //! Function operator /*! Compare two operands. Case is ignored. */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) return std::toupper(Arg1)<std::toupper(Arg2); #else return std::toupper<T1>(Arg1,m_Loc)<std::toupper<T2>(Arg2,m_Loc); #endif } private: std::locale m_Loc; }; // is_not_greater functor -----------------------------------------------// //! is_not_greater functor /*! Convenient version of standard std::not_greater_to. Operation is templated, therefore it is not required to specify the exact types upon the construction */ struct is_not_greater { //! Functor operation /*! Compare two operands using > operator */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { return Arg1<=Arg2; } }; //! case insensitive version of is_not_greater /*! Case insensitive comparison predicate. Comparison is done using specified locales. */ struct is_not_igreater { //! Constructor /*! \param Loc locales used for comparison */ is_not_igreater( const std::locale& Loc=std::locale() ) : m_Loc( Loc ) {} //! Function operator /*! Compare two operands. Case is ignored. */ template< typename T1, typename T2 > bool operator()( const T1& Arg1, const T2& Arg2 ) const { #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x564) && !defined(_USE_OLD_RW_STL) return std::toupper(Arg1)<=std::toupper(Arg2); #else return std::toupper<T1>(Arg1,m_Loc)<=std::toupper<T2>(Arg2,m_Loc); #endif } private: std::locale m_Loc; }; } // namespace algorithm // pull names to the boost namespace using algorithm::is_equal; using algorithm::is_iequal; using algorithm::is_less; using algorithm::is_iless; using algorithm::is_not_greater; using algorithm::is_not_igreater; } // namespace boost #endif // BOOST_STRING_COMPARE_HPP
[ "jprescott12@icloud.com" ]
jprescott12@icloud.com
7cf655e747ce12d46811ddfbb23a5d813c5c0bc9
565954d0f9dcc1a046ba9abeb6ccc978dd99cd84
/av_camera/include/28181/TIOBuffer.h
bc3a9f9e08bf45c3e88e9fcb276e015eb6c42833
[]
no_license
kinglee1982/project
1073b8f642a8d18a12ed5ee1cb9e34285fa8478e
b86303df6b72558cb01b0ca933e891b15c091387
refs/heads/master
2022-03-28T02:55:29.956489
2019-11-08T04:36:29
2019-11-08T04:36:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,856
h
#ifndef TIOBUFFER_H_ #define TIOBUFFER_H_ #include <string> #include <iostream> #include <sstream> #include <fstream> #include <string.h> //////////////////////////////////////////////////////////////////////////// class ImsIOBuffer { public: enum { MEMORY_INCREASE_STEP = 1024 }; typedef unsigned char uint8_t; protected: uint8_t* m_ptr; size_t m_length; size_t m_readPos; size_t m_writePos; size_t m_increaseStep; public: ImsIOBuffer(): m_ptr(NULL), m_length(0), m_readPos(0), m_writePos(0), m_increaseStep(MEMORY_INCREASE_STEP) { } ~ImsIOBuffer() { cleanup(); } explicit ImsIOBuffer(size_t size): m_ptr(NULL), m_length(0), m_readPos(0), m_writePos(0), m_increaseStep(MEMORY_INCREASE_STEP) { expect(size); } ImsIOBuffer(const ImsIOBuffer& ref): m_ptr(NULL), m_length(0), m_readPos(0), m_writePos(0), m_increaseStep(MEMORY_INCREASE_STEP) { assign(ref); } const ImsIOBuffer& operator = (const ImsIOBuffer& ref) { assign(ref); return (*this); } bool expect(size_t expected) { if (expected == 0) { return true; } if ((m_writePos + expected) <= m_length) { return true; } if (!m_ptr) { m_ptr = new uint8_t[expected]; memset(m_ptr, 0, expected); m_length = expected; m_writePos = 0; m_readPos = 0; return (m_ptr != NULL); } if ((m_writePos - m_readPos + expected) <= m_length) { moveData(); return true; } bool done = false; size_t newSize = m_writePos + expected + m_increaseStep; uint8_t* pTmp = new uint8_t[newSize]; if (pTmp) { memset(pTmp, 0, newSize); memcpy(pTmp, m_ptr + m_readPos, m_writePos - m_readPos); delete [] m_ptr; m_ptr = pTmp; m_length = newSize; m_writePos -= m_readPos; m_readPos = 0; done = true; } return done; } bool ensure(size_t size) { if (m_length >= size) { return true; } return expect(size - m_writePos); } void clear() { m_readPos = 0; m_writePos = 0; } size_t read(unsigned char* buffer, size_t length) { if (!buffer || length == 0) { return 0; } size_t left = readable(); if (left < length) { length = left; } memcpy(buffer, m_ptr + m_readPos, length); m_readPos += length; return length; } size_t write(const unsigned char* buffer, size_t length) { if (!buffer || length == 0) { return 0; } if (!expect(length)) { return 0; } memcpy(m_ptr + m_writePos, buffer, length); m_writePos += length; return length; } size_t readable() const { return (m_writePos - m_readPos); } size_t writable() const { return (m_length - m_writePos); } const uint8_t* getReadPtr() const { return m_ptr + m_readPos; } const uint8_t* getWritePtr() const { return m_ptr + m_writePos; } uint8_t* getReadPtr() { return m_ptr + m_readPos; } uint8_t* getWritePtr() { return m_ptr + m_writePos; } uint8_t* getPtr() { return m_ptr; } size_t getReadPos() const { return m_writePos; } size_t getWritePos() const { return m_readPos; } bool checkReadable(size_t length) const { return ((m_writePos - m_readPos) >= length); } bool checkWritable(size_t length) const { return (writable() >= length); } size_t capacity() const { return m_length; } size_t size() const { return readable(); } bool empty() const { return size() == 0; } std::string toString() const { std::stringstream ss; ss << "size: " << m_length; ss << ";"; ss << "out: " << m_readPos; ss << ";"; ss << "in: " << m_writePos; ss << std::endl; return ss.str(); } template < class T > size_t writeValue(T value) { return write((uint8_t*)&value, sizeof(value)); } template < class T > size_t readValue(T& value) { return read((uint8_t*)&value, sizeof(value)); } size_t writeString(const char* str, size_t length) { return write((const uint8_t*)str, length); } size_t writeString(const std::string& str) { return write((const uint8_t*)str.c_str(), str.size()); } size_t readString(char* str, size_t length) { return read((uint8_t*)str, length); } size_t readString(std::string& value, size_t length = (size_t)-1) { size_t left = readable(); if (left < length) { length = left; } else if (length == size_t(-1)) { length = left; } if (length > 0) { value.assign((char*)getReadPtr(), length); m_readPos += length; recycle(); } return length; } uint8_t& operator [] (size_t idx) { return (m_ptr + m_readPos)[idx]; } size_t writeFrom(const ImsIOBuffer& buf, size_t length) { size_t left = buf.readable(); if (left < length) { length = left; } return write(buf.getReadPtr(), length); } size_t writeFrom(const ImsIOBuffer& buf) { return write(buf.getReadPtr(), buf.readable()); } size_t moveFrom(ImsIOBuffer& buf, size_t length) { size_t ret = writeFrom(buf, length); buf.skip(ret); return ret; } bool skip(size_t size) { bool done = false; if (checkReadable(size)) { m_readPos += size; recycle(); done = true; } return done; } void skipAll() { m_readPos = 0; m_writePos = 0; } bool advance(size_t size) { bool done = false; if ((m_length - m_writePos) >= size) { m_writePos += size; done = true; } return done; } size_t fromStream(std::istream& input, size_t length) { expect(length); input.read((char*)getWritePtr(), length); size_t ret = input.gcount(); m_writePos += ret; return ret; } size_t toStream(std::ostream& os, size_t length) { size_t left = readable(); if (left < length) { length = left; } os.write((char*)getReadPtr(), length); m_readPos += length; recycle(); return length; } bool fromFile(const char* filename) { std::ifstream ifs; ifs.open(filename, std::ios::binary); if (!ifs.is_open()) { return false; } ifs.seekg(0, std::ios_base::end); size_t length = ifs.tellg(); ifs.seekg(0); expect(length); ifs.read((char*)getWritePtr(), length); m_writePos += length; ifs.close(); return true; } bool toFile(const char* filename) const { std::ofstream ofs; ofs.open(filename, std::ios::binary); if (!ofs.is_open()) { return false; } ofs.write((char*)getReadPtr(), readable()); ofs.close(); return true; } void setIncreaseStep(size_t length) { if (length > 0) { m_increaseStep = length; } } void moveData() { if (m_readPos == 0) { return; } if ((m_writePos - m_readPos) <= m_readPos) { memcpy(m_ptr, m_ptr + m_readPos, (m_writePos - m_readPos)); m_writePos -= m_readPos; m_readPos = 0; } else { uint8_t* pDest = m_ptr; uint8_t* pSrc = m_ptr + m_readPos; for (size_t i = 0; i < ((m_writePos - m_readPos)/m_readPos); ++ i) { pDest = m_ptr + (i * m_readPos); pSrc = pDest + m_readPos; memcpy(pDest, pSrc, m_readPos); } size_t left = (m_writePos - m_readPos) % m_readPos; if (left != 0) { pDest += m_readPos; pSrc += m_readPos; memcpy(pDest, pSrc, left); } m_writePos -= m_readPos; m_readPos = 0; } } protected: void cleanup() { if (m_ptr) { delete[] m_ptr; m_ptr = NULL; m_writePos = 0; m_readPos = 0; m_length = 0; } } void recycle() { if (m_readPos == m_writePos) { m_readPos = 0; m_writePos = 0; } } void assign(const ImsIOBuffer& ref) { expect(ref.m_length); if (m_length > 0) { memcpy(m_ptr, ref.m_ptr, m_length); m_readPos = ref.m_readPos; m_writePos = ref.m_writePos; } } }; //////////////////////////////////////////////////////////////////////////// #endif /* TIOBUFFER_H_ */
[ "xun" ]
xun
f84027b9ae5f364920d171e757bcb350bec698b4
4d4822b29e666cea6b2d99d5b9d9c41916b455a9
/Example/Pods/Headers/Private/GeoFeatures/boost/format/detail/workarounds_gcc-2_95.hpp
05570128dade78e359db09fae948a9ac114588f7
[ "BSL-1.0", "Apache-2.0" ]
permissive
eswiss/geofeatures
7346210128358cca5001a04b0e380afc9d19663b
1ffd5fdc49d859b829bdb8a9147ba6543d8d46c4
refs/heads/master
2020-04-05T19:45:33.653377
2016-01-28T20:11:44
2016-01-28T20:11:44
50,859,811
0
0
null
2016-02-01T18:12:28
2016-02-01T18:12:28
null
UTF-8
C++
false
false
80
hpp
../../../../../../../../GeoFeatures/boost/format/detail/workarounds_gcc-2_95.hpp
[ "hatter24@gmail.com" ]
hatter24@gmail.com
41a1836c22978035d96e5efeb62aa1eefd2de452
5a4deed727f876f8f931dcc5d9246f1c3be0d05d
/umonibench-jaguar-pinger/jaguar/mock/CallBack_test.cc
0665cd6478b99c6b99d007d91b707dd74cc62192
[]
no_license
ieasydevops/pingtester
2f222e64c9677f5d5a56afbe02a1580accb5d60a
dcc095d8aa48ba4c585fd605795b146499c66582
refs/heads/master
2021-06-09T15:29:57.649455
2016-12-18T16:18:05
2016-12-18T16:18:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,745
cc
// // Created by blackwood on 12/14/16. // #include <muduo/base/Logging.h> #include <boost/bind/bind.hpp> #include <boost/function.hpp> class Penguin { public: void run() { LOG_INFO << "Penguin Run"; }; void swim() { LOG_INFO << "Penguin swim"; }; }; class Sparrow { public: void fly() { LOG_INFO << "Sparrow fly"; }; void run() { LOG_INFO << "Sparrow run"; }; }; typedef boost::function<void()> SwimCallBack; typedef boost::function<void()> FlyCallBack; typedef boost::function<void()> RunCallBack; class Foo { public: Foo(FlyCallBack flyCallBack, RunCallBack runCallBack) : flyCallBack_(flyCallBack), runCallBack_(runCallBack) { } void doAction() { flyCallBack_(); runCallBack_(); }; private: FlyCallBack flyCallBack_; RunCallBack runCallBack_; }; class Bar { public: Bar(SwimCallBack swimCallBack, FlyCallBack flyCallBack, RunCallBack runCallBack) : swimCallBack_(swimCallBack), flyCallBack_(flyCallBack), runCallBack_(runCallBack) { } void doAction() { swimCallBack_(); flyCallBack_(); runCallBack_(); }; private: SwimCallBack swimCallBack_; FlyCallBack flyCallBack_; RunCallBack runCallBack_; }; int main() { Penguin p; Sparrow s; Foo foo(boost::bind(&Sparrow::fly, &s), boost::bind(&Penguin::run, &p)); foo.doAction(); Bar bar(boost::bind(&Penguin::swim, &p), boost::bind(&Sparrow::fly, &s), boost::bind(&Sparrow::run, &s)); bar.doAction(); }
[ "xinyun.mei@ucarinc.com" ]
xinyun.mei@ucarinc.com
e10555dfe2af502e65c066180904ae6d06ba55be
22c37cc9629d921d222ef3502b527f844a842fe5
/student.h
68885360494a1fe3c12f42ba15868806160a6fdd
[]
no_license
BradleyRule/Hashtable
18772fc108ef0a2d21e62c65ffabe92cfd170bf6
96313d3f6de9fe2c5381950e2bb9d76dcf85faf7
refs/heads/main
2023-01-24T23:22:17.450501
2020-12-07T03:23:00
2020-12-07T03:23:00
317,956,928
0
0
null
null
null
null
UTF-8
C++
false
false
365
h
#ifndef STUDENT #define STUDENT #include <iostream> #include <cstring> using namespace std; class Student{ public: Student(char*); char* getFirstName(); void setLastName(char*); char* getLastName(); void setID(int); int getID(); void setGPA(float); float getGPA(); private: char* firstname; char* lastname; int id; float gpa; }; #endif
[ "noreply@github.com" ]
noreply@github.com
07b5b3318a1efb22a13015db72f528630c7d0e48
a68707e03246986cec128271bb0fbf90f91b31fc
/node_modules/react-native/React/Fabric/Utils/RuntimeEventBeat.h
ed7055a374aa3c017e4af52c30c21fde25a0f8f9
[ "CC-BY-SA-4.0", "MIT", "CC-BY-4.0", "CC-BY-NC-SA-4.0" ]
permissive
albseb511/react-native-kite-zerodha-mockup
fe1163275ec5c5ac27d8852e0737445c0928a7d4
70237dacabf889cf22b99f65522010416ed0177e
refs/heads/master
2023-01-08T21:11:03.958157
2019-05-21T19:48:45
2019-05-21T19:48:45
187,160,542
9
7
MIT
2023-01-03T21:58:52
2019-05-17T06:37:00
Java
UTF-8
C++
false
false
892
h
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <CoreFoundation/CFRunLoop.h> #include <CoreFoundation/CoreFoundation.h> #include <react/events/EventBeat.h> #include <react/uimanager/primitives.h> namespace facebook { namespace react { /* * Event beat associated with JavaScript runtime. * The beat is called on `RuntimeExecutor`'s thread induced by the main thread * event loop. */ class RuntimeEventBeat : public EventBeat { public: RuntimeEventBeat(RuntimeExecutor runtimeExecutor); ~RuntimeEventBeat(); void induce() const override; private: const RuntimeExecutor runtimeExecutor_; CFRunLoopObserverRef mainRunLoopObserver_; mutable std::atomic<bool> isBusy_{false}; }; } // namespace react } // namespace facebook
[ "albert@wisense.in" ]
albert@wisense.in
777144ae50ee6706ae2a3814353cb383dc695407
8105c30b6a950f4e7d64986f8b8f7950999d6c51
/DComputeLib/src/typeReflection.cpp
a5a701a25ae4b5ac0ba9686e670e0d3a95128ed4
[]
no_license
dario-DI/DistributedCompute
fb690b7ab7a8c00ed7503a1025d5004da99a2fcc
db97c7463bc1b86f3aa1e81657edd0be7aa4cad5
refs/heads/master
2021-01-19T16:25:15.224669
2014-09-28T03:09:09
2014-09-28T03:09:09
7,122,729
15
11
null
null
null
null
GB18030
C++
false
false
3,439
cpp
// DComputeLib.cpp : Defines the entry point for the DLL application. // #include <assert.h> #include <string> #include <DCompute/typeReflection.h> #include <DCompute/typeWrappers.h> namespace DCompute { ////////////////class TypeReflectorRegistry Impelement////////////////////////// // class TypeReflectorRegistry { public: typedef std::string KeyType; static TypeReflectorRegistry* instance(void); ~TypeReflectorRegistry(); volatile void addFactory( const KeyType& key, ITypeCreator* factory ); ITypeCreator* getFactory( const KeyType& key ); public: typedef std::map<KeyType, ITypeCreator*> FactoryMap; FactoryMap _factoryMap; private: TypeReflectorRegistry(); }; TypeReflectorRegistry* TypeReflectorRegistry::instance() { static TypeReflectorRegistry s_regist; return &s_regist; } TypeReflectorRegistry::TypeReflectorRegistry() { } TypeReflectorRegistry::~TypeReflectorRegistry() { for (FactoryMap::iterator itr=_factoryMap.begin(); itr!=_factoryMap.end(); ++itr) { delete itr->second; itr->second = NULL; } _factoryMap.clear(); } volatile void TypeReflectorRegistry::addFactory( const KeyType& key, ITypeCreator* factory ) { if ( factory->GetVersion() != DCOMPUTE_LIB_VERSION ) { assert(false); // 版本已升级,必须重新编译 return; } #ifdef _DEBUG FactoryMap::iterator itr = _factoryMap.find( key ); if ( itr != _factoryMap.end() ) { assert( false ); // 相同名映射 } #endif _factoryMap[key] = factory; } ITypeCreator* TypeReflectorRegistry::getFactory( const KeyType& key ) { FactoryMap::iterator itr = _factoryMap.find( key ); if ( itr == _factoryMap.end() ) { assert(false); printf("type has no register:%s.\n", key.data()); return NULL; } return itr->second; } /////////////////////////////////////////////////////// // class TypeReflectorManager volatile void TypeReflectorManager::AddCreator( const String& key, ITypeCreator* factory ) { TypeReflectorRegistry::instance()->addFactory(key.data(), factory); } ITypeCreator* TypeReflectorManager::GetCreator( const String& key ) { return TypeReflectorRegistry::instance()->getFactory(key.data()); } IType* TypeReflectorManager::CreateObject( const String& key ) { ITypeCreator* creator = GetCreator( key ); if ( creator == NULL ) return NULL; return creator->Create(); } void TypeReflectorManager::DestoryObject( IType* ptr ) { if ( ptr==NULL ) return; ITypeCreator* creator = ptr->_creator; creator->Destory(ptr); } IType* TypeReflectorManager::ReflectString2Object(const String& str) { std::istringstream sin(str.data()); DSERIALIZER_TYPE ar_in(sin); String typeName; ar_in >> BOOST_SERIALIZATION_NVP(typeName); IType* ptr = TypeReflectorManager::CreateObject( typeName ); IType_Serializable* serializablePtr = Query<IType_Serializable*>(ptr); if ( serializablePtr==NULL ) return NULL; serializablePtr->String2Object(str); return ptr; } IType* TypeReflectorManager::ReflectFile2Object( const String& filename ) { using namespace std; ifstream fin(filename.data(), ios::in|ios::binary/*|ios::trunc|ios::_Nocreate*/); DSERIALIZER_TYPE ar_in(fin); String typeName; ar_in >> BOOST_SERIALIZATION_NVP(typeName); fin.close(); IType* ptr = TypeReflectorManager::CreateObject( typeName ); IType_Serializable* serializablePtr = Query<IType_Serializable*>(ptr); if ( serializablePtr==NULL ) return NULL; serializablePtr->File2Object(filename); return ptr; } }
[ "dx2120@163.com" ]
dx2120@163.com
3bda5783a09aba08b104903623f6c3addb989a01
ddf86c7a1bfd9a7be96efb60e6498b8c5be6bd5f
/ESP32LapTimer/Lora.cpp
929ca64fd6d20295c37062862e4f5b1b65836c37
[]
no_license
Smeat/Chorus32-ESP32LapTimer
d5046f96c2955bbd2251b34681fb63edde56af75
addc3f3f2d65b59b72055c10831d53a43532ad3a
refs/heads/master
2022-08-31T06:07:28.966235
2019-07-19T18:38:55
2019-07-20T22:18:30
187,360,668
14
5
null
2019-05-18T13:22:30
2019-05-18T13:22:29
null
UTF-8
C++
false
false
1,156
cpp
#include "Lora.h" #include "HardwareConfig.h" #ifdef USE_LORA #include "Output.h" #include <SPI.h> #include <LoRa.h> #include <Arduino.h> #if defined(LORA_MOSI) && defined(LORA_SCK) && defined(LORA_MISO) // lora spi pins defined #define CUSTOM_LORA_SPI static SPIClass lora_spi(HSPI); #endif void lora_send_packet(void* output, uint8_t* buf, uint32_t size) { if (buf != NULL && size != 0) { LoRa.beginPacket(); uint32_t bytes = LoRa.write(buf, size); LoRa.endPacket(true); } } void lora_init(void* output) { #ifdef CUSTOM_LORA_SPI Serial.println("Using custom lora pins!"); lora_spi.begin(LORA_SCK, LORA_MISO, LORA_MOSI); LoRa.setSPI(lora_spi); #endif LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ); if(!LoRa.begin(LORA_FREQ)) { Serial.println("Failed to init LoRa!!"); } } void lora_update(void* output) { int pos = 0; uint8_t packetBuffer[1500]; int packetSize = LoRa.parsePacket(); if(packetSize > 0) { while(LoRa.available() > 0 && pos < 1500 && pos < packetSize) { packetBuffer[pos] = LoRa.read(); ++pos; } output_t* out = (output_t*)output; out->handle_input_callback(packetBuffer, pos); } } #endif // USE_LORA
[ "smeatsan@gmail.com" ]
smeatsan@gmail.com
eb476d6f33e33c1f890692e1817343057e5a6912
7d4bba54afdcef21d4df0ff719e5d7b01acddb3e
/src/Commands/StrafeXFeet.h
3a7c1ede989730be97ea806dec5f39babb78d2ca
[]
no_license
The-Charge/2015_TrashBot
8120f0b2672c8400ece7fb93cc2b721410a43e41
df0436ed5599551be9d0d03039d5909af54f526e
refs/heads/master
2021-01-22T04:33:46.346156
2015-03-07T18:27:15
2015-03-07T18:27:15
29,376,017
1
0
null
2015-02-03T22:31:51
2015-01-17T01:42:53
C++
UTF-8
C++
false
false
844
h
// RobotBuilder Version: 1.5 // // This file was generated by RobotBuilder. It contains sections of // code that are automatically generated and assigned by robotbuilder. // These sections will be updated in the future when you export to // C++ from RobotBuilder. Do not put any code or make any change in // the blocks indicating autogenerated code or it will be lost on an // update. Deleting the comments indicating the section will prevent // it from being updated in the future. #ifndef STRAFEXFEET_H #define STRAFEXFEET_H #include "Commands/Subsystem.h" #include "../Robot.h" /** * * * @author ExampleAuthor */ class StrafeXFeet: public Command { public: StrafeXFeet(float); virtual void Initialize(); virtual void Execute(); virtual bool IsFinished(); virtual void End(); virtual void Interrupted(); float feet; }; #endif
[ "richardw@hesonline.com" ]
richardw@hesonline.com
5f56e5e80299e041425ba8a074fc3ebcf830b78e
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/rsync/gumtree/rsync_repos_function_41_rsync-2.6.0.cpp
9dfe0c1543c492a4bffa20e5fb83fcdafbbf13c3
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,069
cpp
void add_exclude_file(struct exclude_struct ***listp, const char *fname, int fatal, int include) { int fd; char line[MAXPATHLEN]; char *eob = line + MAXPATHLEN - 1; extern int eol_nulls; if (!fname || !*fname) return; if (*fname != '-' || fname[1]) fd = open(fname, O_RDONLY|O_BINARY); else fd = 0; if (fd < 0) { if (fatal) { rsyserr(FERROR, errno, "failed to open %s file %s", include ? "include" : "exclude", fname); exit_cleanup(RERR_FILEIO); } return; } while (1) { char ch, *s = line; int cnt; while (1) { if ((cnt = read(fd, &ch, 1)) <= 0) { if (cnt < 0 && errno == EINTR) continue; break; } if (eol_nulls? !ch : (ch == '\n' || ch == '\r')) break; if (s < eob) *s++ = ch; } *s = '\0'; if (*line && *line != ';' && *line != '#') { /* Skip lines starting with semicolon or pound. * It probably wouldn't cause any harm to not skip * them but there's no need to save them. */ add_exclude(listp, line, include); } if (cnt <= 0) break; } close(fd); }
[ "993273596@qq.com" ]
993273596@qq.com
6339b88f9fb7de550d33e3c0572722b3a2c6bea5
65a715ab7b9316dfca31c6535512b3351185fd40
/213-house-robber-ii/house-robber-ii.cpp
b1f24e2277c5c83301e50facdce002dd8ad3c4f1
[]
no_license
theFool32/LeetCode
8791fe773cb692cf0edbe4ea5f9bf18cfecb1eb3
2d41a1845b71d8ce324a06ab4e66a6d23a216d52
refs/heads/master
2020-04-07T04:29:52.756888
2018-09-13T01:50:35
2018-09-13T01:50:35
42,583,598
42
11
null
null
null
null
UTF-8
C++
false
false
1,479
cpp
// You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night. // // Given a list of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can rob tonight without alerting the police. // // Example 1: // // // Input: [2,3,2] // Output: 3 // Explanation: You cannot rob house 1 (money = 2) and then rob house 3 (money = 2), //   because they are adjacent houses. // // // Example 2: // // // Input: [1,2,3,1] // Output: 4 // Explanation: Rob house 1 (money = 1) and then rob house 3 (money = 3). //   Total amount you can rob = 1 + 3 = 4. // class Solution { public: int rob1(vector<int>& nums, int begin, int end) { int n = 0, y = 0; for (int i = begin;i < end;++i) { int num = nums[i]; int t = n; n = max(n, y); y = num + t; } return max(n,y); } int rob(vector<int>& nums) { int size = nums.size(); if (size == 0) return 0; if (size == 1) return nums[0]; return max(rob1(nums, 0, size-1), rob1(nums, 1, size)); } };
[ "saber.rl32@gmail.com" ]
saber.rl32@gmail.com
a5e2ed5562039a69b03e01f2ef27a96a5d1cafcc
1d203f96dd96c6af07f60f1a0d156f20a00161d8
/player.cpp
fa1be05f84d66fa3d3e9b8c809b47229d7f00a77
[]
no_license
matczak/sGame
1594404d0c1953fa5dfa6aff4789e5d11e709f20
fcd8aca716e040339e6bc5364ca56b03693220dc
refs/heads/master
2021-01-10T07:16:30.534956
2016-02-05T12:20:29
2016-02-05T12:20:29
47,467,327
0
0
null
null
null
null
UTF-8
C++
false
false
992
cpp
#include "Player.h" Player::Player(QGraphicsItem *parent): QGraphicsPixmapItem(parent){ setPixmap(QPixmap(":/imgs/res/ship.png")); timer.start(); // time to shoot paused = false; sound = true; bulletSound = new QMediaPlayer(); bulletSound->setMedia(QUrl("qrc:/sounds/res/fireEffect.mp3")); } void Player::move(direction dir) { if (paused) return; if ( dir == LEFT) { if (x()<10) return; setPos(x()-10, y()); } else if (dir == RIGHT) { if (x()>330)return; setPos(x()+10, y()); } } void Player::togglePause() { paused = !paused; } void Player::toggleSound() { sound = !sound; } void Player::shoot() { if (timer.elapsed() > 500 && !paused) { if (sound== true) { bulletSound->setPosition(0); bulletSound->play(); } Bullet * bullet = new Bullet(PLAYER); bullet->setPos(x()+30,y()-20); scene()->addItem(bullet); timer.restart(); } }
[ "michnik13@gmail.com" ]
michnik13@gmail.com
478574f5b828244669cf2ed7b41396b30a99e292
f81b774e5306ac01d2c6c1289d9e01b5264aae70
/chrome/updater/update_service_in_process.cc
8a6fe9ca71eb705ff810f717150c6012cbdbe8e7
[ "BSD-3-Clause" ]
permissive
waaberi/chromium
a4015160d8460233b33fe1304e8fd9960a3650a9
6549065bd785179608f7b8828da403f3ca5f7aab
refs/heads/master
2022-12-13T03:09:16.887475
2020-09-05T20:29:36
2020-09-05T20:29:36
293,153,821
1
1
BSD-3-Clause
2020-09-05T21:02:50
2020-09-05T21:02:49
null
UTF-8
C++
false
false
8,007
cc
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/updater/update_service_in_process.h" #include <string> #include <utility> #include <vector> #include "base/bind.h" #include "base/bind_helpers.h" #include "base/callback.h" #include "base/run_loop.h" #include "base/sequenced_task_runner.h" #include "base/task/post_task.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/updater/configurator.h" #include "chrome/updater/constants.h" #include "chrome/updater/installer.h" #include "chrome/updater/persisted_data.h" #include "chrome/updater/prefs.h" #include "chrome/updater/registration_data.h" #include "components/prefs/pref_service.h" #include "components/update_client/crx_update_item.h" #include "components/update_client/update_client.h" #include "components/update_client/update_client_errors.h" namespace updater { namespace { // The functions below are various adaptors between |update_client| and // |UpdateService| types. update_client::Callback MakeUpdateClientCallback( UpdateService::Callback callback) { return base::BindOnce( [](UpdateService::Callback callback, update_client::Error error) { std::move(callback).Run(static_cast<UpdateService::Result>(error)); }, std::move(callback)); } UpdateService::UpdateState::State ToUpdateState( update_client::ComponentState component_state) { switch (component_state) { case update_client::ComponentState::kNew: return UpdateService::UpdateState::State::kNotStarted; case update_client::ComponentState::kChecking: return UpdateService::UpdateState::State::kCheckingForUpdates; case update_client::ComponentState::kDownloading: case update_client::ComponentState::kDownloadingDiff: case update_client::ComponentState::kDownloaded: return UpdateService::UpdateState::State::kDownloading; case update_client::ComponentState::kCanUpdate: return UpdateService::UpdateState::State::kUpdateAvailable; case update_client::ComponentState::kUpdating: case update_client::ComponentState::kUpdatingDiff: return UpdateService::UpdateState::State::kInstalling; case update_client::ComponentState::kUpdated: return UpdateService::UpdateState::State::kUpdated; case update_client::ComponentState::kUpToDate: return UpdateService::UpdateState::State::kNoUpdate; case update_client::ComponentState::kUpdateError: return UpdateService::UpdateState::State::kUpdateError; case update_client::ComponentState::kUninstalled: case update_client::ComponentState::kRegistration: case update_client::ComponentState::kRun: case update_client::ComponentState::kLastStatus: NOTREACHED(); return UpdateService::UpdateState::State::kUnknown; } } UpdateService::ErrorCategory ToErrorCategory( update_client::ErrorCategory error_category) { switch (error_category) { case update_client::ErrorCategory::kNone: return UpdateService::ErrorCategory::kNone; case update_client::ErrorCategory::kDownload: return UpdateService::ErrorCategory::kDownload; case update_client::ErrorCategory::kUnpack: return UpdateService::ErrorCategory::kUnpack; case update_client::ErrorCategory::kInstall: return UpdateService::ErrorCategory::kInstall; case update_client::ErrorCategory::kService: return UpdateService::ErrorCategory::kService; case update_client::ErrorCategory::kUpdateCheck: return UpdateService::ErrorCategory::kUpdateCheck; } } update_client::UpdateClient::CrxStateChangeCallback MakeUpdateClientCrxStateChangeCallback( scoped_refptr<update_client::Configurator> config, UpdateService::StateChangeCallback callback) { return base::BindRepeating( [](scoped_refptr<update_client::Configurator> config, UpdateService::StateChangeCallback callback, update_client::CrxUpdateItem crx_update_item) { UpdateService::UpdateState update_state; update_state.app_id = crx_update_item.id; update_state.state = ToUpdateState(crx_update_item.state); update_state.next_version = crx_update_item.next_version; update_state.downloaded_bytes = crx_update_item.downloaded_bytes; update_state.total_bytes = crx_update_item.total_bytes; update_state.install_progress = crx_update_item.install_progress; update_state.error_category = ToErrorCategory(crx_update_item.error_category); update_state.error_code = crx_update_item.error_code; update_state.extra_code1 = crx_update_item.extra_code1; // Commit the prefs values written by |update_client| when the // update has completed, such as `pv` and `fingerprint`. if (update_state.state == UpdateService::UpdateState::State::kUpdated) { config->GetPrefService()->CommitPendingWrite(); } callback.Run(update_state); }, config, callback); } std::vector<base::Optional<update_client::CrxComponent>> GetComponents( scoped_refptr<PersistedData> persisted_data, const std::vector<std::string>& ids) { std::vector<base::Optional<update_client::CrxComponent>> components; for (const auto& id : ids) { components.push_back(base::MakeRefCounted<Installer>(id, persisted_data) ->MakeCrxComponent()); } return components; } } // namespace UpdateServiceInProcess::UpdateServiceInProcess( scoped_refptr<update_client::Configurator> config) : config_(config), persisted_data_( base::MakeRefCounted<PersistedData>(config_->GetPrefService())), main_task_runner_(base::SequencedTaskRunnerHandle::Get()), update_client_(update_client::UpdateClientFactory(config)) {} void UpdateServiceInProcess::RegisterApp( const RegistrationRequest& request, base::OnceCallback<void(const RegistrationResponse&)> callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); persisted_data_->RegisterApp(request); update_client_->SendRegistrationPing(request.app_id, request.version, base::DoNothing()); // Result of registration. Currently there's no error handling in // PersistedData, so we assume success every time, which is why we respond // with 0. main_task_runner_->PostTask( FROM_HERE, base::BindOnce(std::move(callback), RegistrationResponse(0))); } void UpdateServiceInProcess::UpdateAll(StateChangeCallback state_update, Callback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); const auto app_ids = persisted_data_->GetAppIds(); DCHECK(base::Contains(app_ids, kUpdaterAppId)); update_client_->Update( app_ids, base::BindOnce(&GetComponents, persisted_data_), MakeUpdateClientCrxStateChangeCallback(config_, state_update), false, MakeUpdateClientCallback(std::move(callback))); } void UpdateServiceInProcess::Update(const std::string& app_id, Priority priority, StateChangeCallback state_update, Callback callback) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); update_client_->Update( {app_id}, base::BindOnce(&GetComponents, persisted_data_), MakeUpdateClientCrxStateChangeCallback(config_, state_update), priority == Priority::kForeground, MakeUpdateClientCallback(std::move(callback))); } void UpdateServiceInProcess::Uninitialize() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); PrefsCommitPendingWrites(config_->GetPrefService()); } UpdateServiceInProcess::~UpdateServiceInProcess() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); config_->GetPrefService()->SchedulePendingLossyWrites(); } } // namespace updater
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
8ccd95dea4f0a707a18576b7ae037f2315ad5b4a
6f6e279f8ab001060223d288c51877b5ee22b0d9
/common/tools/ats/smoketest/Timew/ConsoleAlarmAlertServer/Include/ConsoleAlarmAlertServer.h
d4aeb6785e5b9de913c2f32441d012c4b59bbd9a
[]
no_license
fedor4ever/pkgbuild
25b387442911a0baf72e08069758c27b773904b3
7142cf79393d1a1011fcb0ce856f3f89f407ba8a
refs/heads/master
2016-09-05T09:22:33.948115
2015-04-12T11:20:10
2015-04-12T11:20:10
33,690,293
0
0
null
null
null
null
UTF-8
C++
false
false
3,468
h
// Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of the License "Symbian Foundation License v1.0" // which accompanies this distribution, and is available // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". // // Initial Contributors: // Nokia Corporation - initial contribution. // // Contributors: // // Description: // TALARMALERTSERVER.H // // #ifndef __CONSOLEALARMALERTSERVER_H__ #define __CONSOLEALARMALERTSERVER_H__ // System includes #include <e32base.h> // User includes // Type definitions // Constants // Enumerations // Classes referenced class CTestAlarmAlertConsole; class CConsoleAlarmAlertSession; /////////////////////////////////////////////////////////////////////////////////////// // ----> CConsoleAlarmAlertServer (header) /////////////////////////////////////////////////////////////////////////////////////// class CConsoleAlarmAlertServer : public CPolicyServer { /////////////////////////////////////////////////////////////////////////////////////// public: // STATIC CONSTRUCT / DESTRUCT /////////////////////////////////////////////////////////////////////////////////////// static CConsoleAlarmAlertServer* NewLC(); ~CConsoleAlarmAlertServer(); public: inline void AddResponseArray(TAny* aResponseArray); void SetAttachment(HBufC8* aData); inline HBufC8* Attachment() const; inline TAny* ResponseArray() const; inline CConsoleAlarmAlertSession* WaitingSession() const; inline void SetNotifying(TBool aIsNotifying); inline TBool IsNotifying() const; /////////////////////////////////////////////////////////////////////////////////////// private: // INTERNAL CONSTRUCT /////////////////////////////////////////////////////////////////////////////////////// CConsoleAlarmAlertServer(); void ConstructL(); /////////////////////////////////////////////////////////////////////////////////////// public: // FROM CServer2 /////////////////////////////////////////////////////////////////////////////////////// CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; /////////////////////////////////////////////////////////////////////////////////////// private: // FROM CActive /////////////////////////////////////////////////////////////////////////////////////// TInt RunError(TInt aError); /////////////////////////////////////////////////////////////////////////////////////// private: // MEMBER DATA /////////////////////////////////////////////////////////////////////////////////////// TAny* iInstructionSet; HBufC8* iAttachment; CConsoleAlarmAlertSession* iWaitingSession; TBool iIsNotifying; }; // inline functions void CConsoleAlarmAlertServer::AddResponseArray(TAny* aResponseArray) { iInstructionSet = aResponseArray; } HBufC8* CConsoleAlarmAlertServer::Attachment() const { return iAttachment; } TAny* CConsoleAlarmAlertServer::ResponseArray() const { return iInstructionSet; } CConsoleAlarmAlertSession* CConsoleAlarmAlertServer::WaitingSession() const { return iWaitingSession; } void CConsoleAlarmAlertServer::SetNotifying(TBool aIsNotifying) { iIsNotifying = aIsNotifying; } TBool CConsoleAlarmAlertServer::IsNotifying() const { return iIsNotifying; } #endif
[ "louisn@symbian.org" ]
louisn@symbian.org
623181d7801c3c15f9f5d94a54a7afbaf82b208d
040edc2bdbefe7c0d640a18d23f25a8761d62f40
/25mt/src/dfgammln.cpp
ee12c65adb5513b1b61bc676298c777316333c31
[ "BSD-2-Clause" ]
permissive
johnrsibert/tagest
9d3be8352f6bb5603fbd0eb6140589bb852ff40b
0194b1fbafe062396cc32a0f5a4bbe824341e725
refs/heads/master
2021-01-24T00:18:24.231639
2018-01-16T19:10:25
2018-01-16T19:10:25
30,438,830
3
3
null
2016-12-08T17:59:28
2015-02-07T00:05:30
C++
UTF-8
C++
false
false
1,281
cpp
//$Id: dfgammln.cpp 2754 2011-01-02 20:57:07Z jsibert $ #include <fvar.hpp> #include <math.h> double dfgammln(const double v1) { static double cof[6]={76.18009172947146,-86.50532032941677, 24.01409824083091,-1.231739572450155, 0.1208650973866179e-2,-0.5395239384953e-5}; dvector x(-1,5); dvector dfx(-1,5); dfx.initialize(); int j; double tmp=0.0; double tmp1=0.0; double xx=0.0; double dftmp=0.0; double dftmp1=0.0; double dfser=0.0; double dfxx=0.0; xx=v1; //value(v1); x(-1)=xx-1.0; tmp=x(-1)+5.5; tmp1 = tmp -(x(-1)+0.5)*log(tmp); double ser=1.000000000190015; for (j=0;j<=5;j++) { x(j) = x(j-1)+1.0; ser += cof[j]/x(j); } //double z = -tmp1+log(2.50662827465*ser); dftmp1 = -1.; dfser = 1.0/ser; for (j=5;j>=0;j--) { //ser += cof[j]/x(j); dfx(j)-=dfser*cof[j]/(x(j)*x(j)); //x(j) = x(j-1)+1.0; dfx(j-1)+=dfx(j); dfx(j)=0.; } //ser=1.0; dfser=0.0; //tmp1 = tmp - (x(-1)+0.5)*log(tmp); dfx(-1)-=dftmp1*log(tmp); dftmp += dftmp1*(1.0 -(x(-1)+0.5)/tmp); dftmp1=0.0; //tmp=x(-1)+5.5; dfx(-1)+=dftmp; dftmp=0.0; //x(-1)=xx-1.0; dfxx=dfx(-1); dfx(-1)=0.0; //x=xx-1.0; dfxx+=dfx(-1); dfx(-1)=0.0; return(dfxx); }
[ "sibert@hawaii.edu" ]
sibert@hawaii.edu
e30b887c78dc11c7a33fff3b663aa2f0a24c1c17
253545d772f46e2851fc611a8283ef94291c17b7
/CPP_Basic/ch04/ch04_4/ch04_4_ex/ObjPtrArr.cpp
27134578b59a1abfa875516e5fae70fe6f3d83a9
[]
no_license
redherring2141/CPP_Study
1ebb023faf04aba20c729bac576cd7e0fdd38385
42e208b2a1f4cb240a585084df4bb60502ed6654
refs/heads/master
2023-04-10T07:45:29.064154
2021-04-21T01:44:28
2021-04-21T01:44:28
299,589,914
0
0
null
null
null
null
UTF-8
C++
false
false
1,188
cpp
#include <iostream> #include <cstring> using namespace std; class Person {// Same with the class Person in ObjArr.cpp private: char *name; int age; public: Person(char *myname, int myage) { int len = strlen(myname)+1; name = new char[len]; strcpy(name, myname); age = myage; } Person() { name = NULL; age = 0; cout << "called Person()" << endl; } void SetPersonInfo(char *myname, int myage) { name = myname; age = myage; } void ShowPersonInfo() const { cout << "Name: " << name << ", "; cout << "Age: " << age << endl; } ~Person() { delete []name; cout << "called destructor!" << endl; } }; int main(void) { Person *parr[3]; char namestr[100]; int age; for (int i=0; i<3; i++) { cout << "Name: "; cin >> namestr; cout << "Age: "; cin >> age; parr[i] = new Person(namestr, age); } parr[0]->ShowPersonInfo(); parr[1]->ShowPersonInfo(); parr[2]->ShowPersonInfo(); delete parr[0]; delete parr[1]; delete parr[2]; return 0; }
[ "redherring2141@kaist.ac.kr" ]
redherring2141@kaist.ac.kr
42e8bab40854a9f7034354d9eb28cffb3dd4c438
fd96857bdf886bf27c40fc4774f7887c4f8cbddc
/headers/Daemon/GameEngine.hpp
d3c2575382dae8125efd446dcbacb0effa311ad8
[ "MIT" ]
permissive
InfiernoGamesStudio/KnightScript
c4ff33c2b1ef69d340497e5d7717784edf59453f
bb88f570b25850e6efbbde19d90d86a5e5d1e040
refs/heads/master
2020-03-10T03:23:34.582965
2018-04-26T19:27:50
2018-04-26T19:27:50
127,582,082
0
0
null
null
null
null
UTF-8
C++
false
false
1,902
hpp
/** * MIT License * * Copyright (c) 2018 InfiernoGamesStudio * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. **/ #ifndef _DAEMON_GAME_ENGINE_HPP_ #define _DAEMON_GAME_ENGINE_HPP_ namespace Daemon { struct GameEngine { std::string name; std::string author; std::string version; std::string content_path; std::string script_path; struct { int width; int height; float ratio; } screen; GLFWwindow* window; struct GameContentManager content_manager; }; struct GameEngine* CreateEngine( std::string config_file, struct GameEngine* engine = nullptr ); void InitEngine( struct GameEngine* engine ); void AwakeEngine( struct GameEngine* engine ); void ProcessEngine( struct GameEngine* engine ); void DestroyEngine( struct GameEngine* engine ); }; #endif
[ "noreply@github.com" ]
noreply@github.com
77ba90250987c7deaa5843add392348ed5d2d2c6
6c0a11f53eff7b31ee0c493524e69b003b5938d7
/src.gfx/OgreMesh2Serializer.cpp
f97760f95dab4fb9b0e762cf1019813788240433
[]
no_license
yangfengzzz/Sisy
d2a8a6c34cd24f2eb9ab11bf99c76c68032ccc25
1f9637bcdc31905a4fb28fe2b9446c1ed279a923
refs/heads/master
2023-02-02T20:16:19.307627
2020-03-26T02:03:15
2020-03-26T02:03:15
322,533,099
1
0
null
null
null
null
UTF-8
C++
false
false
7,448
cpp
/* ----------------------------------------------------------------------------- This source file is part of OGRE (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/ Copyright (c) 2000-2014 Torus Knot Software Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ----------------------------------------------------------------------------- */ #include "OgreStableHeaders.h" #include "OgreMesh2Serializer.h" #include "OgreMesh2.h" #include "OgreException.h" #include "OgreLogManager.h" namespace Ogre { const unsigned short HEADER_CHUNK_ID = 0x1000; //--------------------------------------------------------------------- MeshSerializer::MeshSerializer( VaoManager *vaoManager ) :mListener(0) { // Init implementations // String identifiers have not always been 100% unified with OGRE version // Note MUST be added in reverse order so latest is first in the list mVersionData.push_back(OGRE_NEW MeshVersionData( MESH_VERSION_2_1, "[MeshSerializer_v2.1 R2]", OGRE_NEW MeshSerializerImpl( vaoManager ))); //These formats will be removed on release mVersionData.push_back(OGRE_NEW MeshVersionData( MESH_VERSION_LEGACY, "[MeshSerializer_v2.1 R1]", OGRE_NEW MeshSerializerImpl_v2_1_R1( vaoManager ))); mVersionData.push_back(OGRE_NEW MeshVersionData( MESH_VERSION_LEGACY, "[MeshSerializer_v2.1]", OGRE_NEW MeshSerializerImpl_v2_1_R0( vaoManager ))); } //--------------------------------------------------------------------- MeshSerializer::~MeshSerializer() { // delete map for (MeshVersionDataList::iterator i = mVersionData.begin(); i != mVersionData.end(); ++i) { OGRE_DELETE *i; } mVersionData.clear(); } //--------------------------------------------------------------------- void MeshSerializer::exportMesh(const Mesh* pMesh, const String& filename, Endian endianMode) { std::fstream *f = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)(); f->open(filename.c_str(), std::ios::binary | std::ios::out); DataStreamPtr stream(OGRE_NEW FileStreamDataStream(f)); exportMesh(pMesh, stream, endianMode); stream->close(); } //--------------------------------------------------------------------- void MeshSerializer::exportMesh(const Mesh* pMesh, const String& filename, MeshVersion version, Endian endianMode) { if( version == MESH_VERSION_LEGACY ) { OGRE_EXCEPT( Exception::ERR_INVALIDPARAMS, "You may not supply a legacy version number for writing meshes.", "MeshSerializer::exportMesh" ); } std::fstream *f = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)(); f->open(filename.c_str(), std::ios::binary | std::ios::out); DataStreamPtr stream(OGRE_NEW FileStreamDataStream(f)); exportMesh(pMesh, stream, version, endianMode); stream->close(); } //--------------------------------------------------------------------- void MeshSerializer::exportMesh(const Mesh* pMesh, DataStreamPtr stream, Endian endianMode) { exportMesh(pMesh, stream, MESH_VERSION_LATEST, endianMode); } //--------------------------------------------------------------------- void MeshSerializer::exportMesh(const Mesh* pMesh, DataStreamPtr stream, MeshVersion version, Endian endianMode) { MeshSerializerImpl* impl = 0; if (version == MESH_VERSION_LATEST) impl = mVersionData[0]->impl; else { for (MeshVersionDataList::iterator i = mVersionData.begin(); i != mVersionData.end(); ++i) { if (version == (*i)->version) { impl = (*i)->impl; break; } } } if (!impl) { OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Cannot find serializer implementation for " "specified version", "MeshSerializer::exportMesh"); } impl->exportMesh(pMesh, stream, endianMode); } //--------------------------------------------------------------------- void MeshSerializer::importMesh(DataStreamPtr& stream, Mesh* pDest) { determineEndianness(stream); // Read header and determine the version unsigned short headerID; // Read header ID readShorts(stream, &headerID, 1); if (headerID != HEADER_CHUNK_ID) { OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "File header not found", "MeshSerializer::importMesh"); } // Read version String ver = readString(stream); // Jump back to start stream->seek(0); // Find the implementation to use MeshSerializerImpl* impl = 0; for (MeshVersionDataList::iterator i = mVersionData.begin(); i != mVersionData.end(); ++i) { if ((*i)->versionString == ver) { impl = (*i)->impl; break; } } if (!impl) OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, "Cannot find serializer implementation for " "mesh version " + ver, "MeshSerializer::importMesh"); // Call implementation impl->importMesh(stream, pDest, mListener); // Warn on old version of mesh if (ver != mVersionData[0]->versionString) { LogManager::getSingleton().logMessage("WARNING: " + pDest->getName() + " is an older format (" + ver + "); you should upgrade it as soon as possible" + " using the OgreMeshTool tool.", LML_CRITICAL); } if(mListener) mListener->processMeshCompleted(pDest); } //--------------------------------------------------------------------- void MeshSerializer::setListener( MeshSerializerListener *listener ) { mListener = listener; } //------------------------------------------------------------------------- MeshSerializerListener *MeshSerializer::getListener() { return mListener; } //------------------------------------------------------------------------- }
[ "yangfengzzz@hotmail.com" ]
yangfengzzz@hotmail.com
a964733747ebb370e75d20390424adb376e1f1e0
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/httpd/gumtree/httpd_repos_function_2277_httpd-2.4.25.cpp
56f38acc2a047e750ca2331c4536784e654188e2
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
134
cpp
int h2_res_ignore_trailer(const char *name, size_t len) { return ignore_header(H2_LIT_ARGS(IgnoredResponseTrailers), name, len); }
[ "993273596@qq.com" ]
993273596@qq.com
5337d29e25329b54304e168754dc1282d029ef58
eac812b8fde25475f85eb427cc3b9883bd3e59a8
/app/android/jni/third-party/include/glm/detail/type_mat2x2.inl
da536884897c5ca15faeec1b504a2616b828c2d9
[ "BSD-3-Clause" ]
permissive
Riotpiaole/rtabmap
f6dc452f07310ea4d682c3611f8e03267a94cde3
2b8b36db2ed7a08361dcffc9e2da3070b92a3883
refs/heads/master
2020-08-15T20:22:03.547609
2020-04-27T15:13:26
2020-04-27T15:13:26
215,402,703
0
0
BSD-3-Clause
2019-10-15T21:47:24
2019-10-15T21:47:24
null
UTF-8
C++
false
false
15,200
inl
/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @ref core /// @file glm/core/type_mat2x2.inl /// @date 2005-01-16 / 2011-06-15 /// @author Christophe Riccio /////////////////////////////////////////////////////////////////////////////////// namespace glm{ namespace detail { template <typename T, precision P> GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t tmat2x2<T, P>::length() const {return 2;} ////////////////////////////////////// // Accesses template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::col_type & tmat2x2<T, P>::operator[](length_t i) { assert(i < this->length()); return this->value[i]; } template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::col_type const & tmat2x2<T, P>::operator[](length_t i) const { assert(i < this->length()); return this->value[i]; } ////////////////////////////////////////////////////////////// // Constructors template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2() { this->value[0] = col_type(1, 0); this->value[1] = col_type(0, 1); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat2x2<T, P> const & m ) { this->value[0] = m.value[0]; this->value[1] = m.value[1]; } template <typename T, precision P> template <precision Q> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2( tmat2x2<T, Q> const & m) { this->value[0] = m.value[0]; this->value[1] = m.value[1]; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( ctor ) {} template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( T const & s ) { value_type const Zero(0); this->value[0] = col_type(s, Zero); this->value[1] = col_type(Zero, s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( T const & x0, T const & y0, T const & x1, T const & y1 ) { this->value[0] = col_type(x0, y0); this->value[1] = col_type(x1, y1); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( col_type const & v0, col_type const & v1 ) { this->value[0] = v0; this->value[1] = v1; } ////////////////////////////////////// // Conversion constructors template <typename T, precision P> template <typename X1, typename Y1, typename X2, typename Y2> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( X1 const & x1, Y1 const & y1, X2 const & x2, Y2 const & y2 ) { this->value[0] = col_type(static_cast<T>(x1), value_type(y1)); this->value[1] = col_type(static_cast<T>(x2), value_type(y2)); } template <typename T, precision P> template <typename V1, typename V2> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tvec2<V1, P> const & v1, tvec2<V2, P> const & v2 ) { this->value[0] = col_type(v1); this->value[1] = col_type(v2); } ////////////////////////////////////////////////////////////// // mat2x2 matrix conversions template <typename T, precision P> template <typename U, precision Q> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat2x2<U, Q> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat3x3<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat4x4<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat2x3<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat3x2<T, P> const & m ) { this->value[0] = m[0]; this->value[1] = m[1]; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat2x4<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat4x2<T, P> const & m ) { this->value[0] = m[0]; this->value[1] = m[1]; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat3x4<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>::tmat2x2 ( tmat4x3<T, P> const & m ) { this->value[0] = col_type(m[0]); this->value[1] = col_type(m[1]); } ////////////////////////////////////////////////////////////// // mat2x2 operators // This function shouldn't required but it seems that VC7.1 have an optimisation bug if this operator wasn't declared template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator= (tmat2x2<T, P> const & m) { this->value[0] = m[0]; this->value[1] = m[1]; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator= (tmat2x2<U, P> const & m) { this->value[0] = m[0]; this->value[1] = m[1]; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator+= (U s) { this->value[0] += s; this->value[1] += s; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator+= (tmat2x2<U, P> const & m) { this->value[0] += m[0]; this->value[1] += m[1]; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator-= (U s) { this->value[0] -= s; this->value[1] -= s; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator-= (tmat2x2<U, P> const & m) { this->value[0] -= m[0]; this->value[1] -= m[1]; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator*= (U s) { this->value[0] *= s; this->value[1] *= s; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator*= (tmat2x2<U, P> const & m) { return (*this = *this * m); } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator/= (U s) { this->value[0] /= s; this->value[1] /= s; return *this; } template <typename T, precision P> template <typename U> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator/= (tmat2x2<U, P> const & m) { return (*this = *this * detail::compute_inverse<detail::tmat2x2, T, P>::call(m)); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator++() { ++this->value[0]; ++this->value[1]; return *this; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P>& tmat2x2<T, P>::operator--() { --this->value[0]; --this->value[1]; return *this; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> tmat2x2<T, P>::operator++(int) { tmat2x2<T, P> Result(*this); ++*this; return Result; } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> tmat2x2<T, P>::operator--(int) { tmat2x2<T, P> Result(*this); --*this; return Result; } template <typename T, precision P> struct compute_inverse<detail::tmat2x2, T, P> { GLM_FUNC_QUALIFIER static detail::tmat2x2<T, P> call(detail::tmat2x2<T, P> const & m) { T OneOverDeterminant = static_cast<T>(1) / ( + m[0][0] * m[1][1] - m[1][0] * m[0][1]); detail::tmat2x2<T, P> Inverse( + m[1][1] * OneOverDeterminant, - m[0][1] * OneOverDeterminant, - m[1][0] * OneOverDeterminant, + m[0][0] * OneOverDeterminant); return Inverse; } }; ////////////////////////////////////////////////////////////// // Binary operators template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+ ( tmat2x2<T, P> const & m, T const & s ) { return tmat2x2<T, P>( m[0] + s, m[1] + s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+ ( T const & s, tmat2x2<T, P> const & m ) { return tmat2x2<T, P>( m[0] + s, m[1] + s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator+ ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { return tmat2x2<T, P>( m1[0] + m2[0], m1[1] + m2[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator- ( tmat2x2<T, P> const & m, T const & s ) { return tmat2x2<T, P>( m[0] - s, m[1] - s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator- ( T const & s, tmat2x2<T, P> const & m ) { return tmat2x2<T, P>( s - m[0], s - m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator- ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { return tmat2x2<T, P>( m1[0] - m2[0], m1[1] - m2[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator* ( tmat2x2<T, P> const & m, T const & s ) { return tmat2x2<T, P>( m[0] * s, m[1] * s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator* ( T const & s, tmat2x2<T, P> const & m ) { return tmat2x2<T, P>( m[0] * s, m[1] * s); } template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::col_type operator* ( tmat2x2<T, P> const & m, typename tmat2x2<T, P>::row_type const & v ) { return detail::tvec2<T, P>( m[0][0] * v.x + m[1][0] * v.y, m[0][1] * v.x + m[1][1] * v.y); } template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::row_type operator* ( typename tmat2x2<T, P>::col_type const & v, tmat2x2<T, P> const & m ) { return detail::tvec2<T, P>( v.x * m[0][0] + v.y * m[0][1], v.x * m[1][0] + v.y * m[1][1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator* ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { return tmat2x2<T, P>( m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1], m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat3x2<T, P> operator* ( tmat2x2<T, P> const & m1, tmat3x2<T, P> const & m2 ) { return tmat3x2<T, P>( m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1], m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1], m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1], m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat4x2<T, P> operator* ( tmat2x2<T, P> const & m1, tmat4x2<T, P> const & m2 ) { return tmat4x2<T, P>( m1[0][0] * m2[0][0] + m1[1][0] * m2[0][1], m1[0][1] * m2[0][0] + m1[1][1] * m2[0][1], m1[0][0] * m2[1][0] + m1[1][0] * m2[1][1], m1[0][1] * m2[1][0] + m1[1][1] * m2[1][1], m1[0][0] * m2[2][0] + m1[1][0] * m2[2][1], m1[0][1] * m2[2][0] + m1[1][1] * m2[2][1], m1[0][0] * m2[3][0] + m1[1][0] * m2[3][1], m1[0][1] * m2[3][0] + m1[1][1] * m2[3][1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator/ ( tmat2x2<T, P> const & m, T const & s ) { return tmat2x2<T, P>( m[0] / s, m[1] / s); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator/ ( T const & s, tmat2x2<T, P> const & m ) { return tmat2x2<T, P>( s / m[0], s / m[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::col_type operator/ ( tmat2x2<T, P> const & m, typename tmat2x2<T, P>::row_type & v ) { return detail::compute_inverse<detail::tmat2x2, T, P>::call(m) * v; } template <typename T, precision P> GLM_FUNC_QUALIFIER typename tmat2x2<T, P>::row_type operator/ ( typename tmat2x2<T, P>::col_type const & v, tmat2x2<T, P> const & m ) { return v * detail::compute_inverse<detail::tmat2x2, T, P>::call(m); } template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> operator/ ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { tmat2x2<T, P> m1_copy(m1); return m1_copy /= m2; } // Unary constant operators template <typename T, precision P> GLM_FUNC_QUALIFIER tmat2x2<T, P> const operator- ( tmat2x2<T, P> const & m ) { return tmat2x2<T, P>( -m[0], -m[1]); } ////////////////////////////////////// // Boolean operators template <typename T, precision P> GLM_FUNC_QUALIFIER bool operator== ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { return (m1[0] == m2[0]) && (m1[1] == m2[1]); } template <typename T, precision P> GLM_FUNC_QUALIFIER bool operator!= ( tmat2x2<T, P> const & m1, tmat2x2<T, P> const & m2 ) { return (m1[0] != m2[0]) || (m1[1] != m2[1]); } } //namespace detail } //namespace glm
[ "rlian072@uottawa.ca" ]
rlian072@uottawa.ca
8c4ce94f0f5ad9cb9f12d52d12c74d4cd238c2c3
682b2f75ad805434c417831711bfa6655e4e2432
/AI/BTTask_Groggy.h
084a903c1179c2afb15d3349924252330a90c5e2
[]
no_license
godyello123/JamJamGuradian
dae578617383ec9bba565c11dd64cc019eb8ef47
a878a3c52922c0447ce6d2be6ba3fd85421b7b4e
refs/heads/master
2023-03-17T22:42:44.541024
2021-03-16T08:48:47
2021-03-16T08:48:47
325,564,168
0
0
null
null
null
null
UTF-8
C++
false
false
525
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "BehaviorTree/BTTaskNode.h" #include "BTTask_Groggy.generated.h" /** * */ UCLASS() class MPSG_API UBTTask_Groggy : public UBTTaskNode { GENERATED_BODY() public: UBTTask_Groggy(); protected: virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory); virtual void TickTask(UBehaviorTreeComponent& OwnerComp, uint8* NodeMemory, float DeltaSeconds); };
[ "godyello123@gmail.com" ]
godyello123@gmail.com
4206836702d96f9785cb33679845ef7e72425358
8ee5b1d44a1568b239dce3421145c0dc19e4e6c9
/codegen_test2/cpp/pkg_db_service.h
f54dda559ffd5323064d0b60fb014191ae64b6ef
[ "MIT" ]
permissive
denghe/xxlib
c38a7be26f877565e02adda974319484f4aa6289
4fc059fe06bcefbcb283fac301b3703cb0d53131
refs/heads/main
2023-08-31T21:06:37.352038
2023-08-29T03:40:57
2023-08-29T03:40:57
343,328,442
18
9
null
null
null
null
UTF-8
C++
false
false
2,488
h
#pragma once #include <pkg_generic.h> #include <pkg_db_service.h.inc> struct CodeGen_pkg_db_service { inline static const ::std::string md5 = "#*MD5<18441371d29e2004db3ffe2e348b69a5>*#"; static void Register(); CodeGen_pkg_db_service() { Register(); } }; inline CodeGen_pkg_db_service __CodeGen_pkg_db_service; namespace Database_Service { struct GetAccountInfoByUsernamePasswordResult; } namespace Service_Database { struct GetAccountInfoByUsernamePassword; } namespace xx { template<> struct TypeId<::Database_Service::GetAccountInfoByUsernamePasswordResult> { static const uint16_t value = 110; }; template<> struct TypeId<::Service_Database::GetAccountInfoByUsernamePassword> { static const uint16_t value = 100; }; } namespace Database { // 账号信息 struct AccountInfo { XX_OBJ_STRUCT_H(AccountInfo) using IsSimpleType_v = AccountInfo; int32_t accountId = -1; ::std::string nickname; double coin = 0; }; } namespace Database_Service { // 回应:查询结果 struct GetAccountInfoByUsernamePasswordResult : ::xx::ObjBase { XX_OBJ_OBJECT_H(GetAccountInfoByUsernamePasswordResult, ::xx::ObjBase) using IsSimpleType_v = GetAccountInfoByUsernamePasswordResult; // 为空就是没找到 ::std::optional<::Database::AccountInfo> accountInfo; static void WriteTo(xx::Data& d, ::std::optional<::Database::AccountInfo> const& accountInfo); }; } namespace Service_Database { // 请求:根据用户名密码拿账号信息。出错返回 Generic.Error. 成功返回 Database_Service.GetAccountInfoByUsernamePasswordResult struct GetAccountInfoByUsernamePassword : ::xx::ObjBase { XX_OBJ_OBJECT_H(GetAccountInfoByUsernamePassword, ::xx::ObjBase) using IsSimpleType_v = GetAccountInfoByUsernamePassword; ::std::string username; ::std::string password; static void WriteTo(xx::Data& d, std::string_view const& username, std::string_view const& password); }; } namespace xx { XX_OBJ_STRUCT_TEMPLATE_H(::Database::AccountInfo) template<typename T> struct DataFuncs<T, std::enable_if_t<std::is_same_v<::Database::AccountInfo, std::decay_t<T>>>> { template<bool needReserve = true> static inline void Write(Data& d, T const& in) { (*(xx::ObjManager*)-1).Write(d, in); } static inline int Read(Data_r& d, T& out) { return (*(xx::ObjManager*)-1).Read(d, out); } }; } #include <pkg_db_service_.h.inc>
[ "denghe@hotmail.com" ]
denghe@hotmail.com
64143becbcbdfb4facc22507fb2c96ef745ff025
3d14bc04783f79d2cb5477437586a009bbdf091f
/Graph Implementation/main.cpp
86c228aa7cd217a5ce6d25523dfa29cff1206e29
[]
no_license
paulrishav93/Programs
64af4d4fddce5a948709eaab6bfa7e2ff44a1dc5
8a943356163cd67dee51d2d1f0c5388aef67c28a
refs/heads/master
2020-12-24T15:49:43.234070
2014-08-23T10:37:18
2014-08-23T10:37:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,217
cpp
#include <iostream> using namespace std; void buildheap(int A[], int length); void heapify(int A[], int heapsize, int root); void heapsort(int A[], int length)// (takes O(n lg n) time) { int heapsize = length; buildheap(A, length); //Take the unsorted list and make it a heap for (int i = length-1; i >=2; i--) { swap(A[1], A[i]); heapsize--; heapify(A, heapsize, 1); } } void buildheap(int A[], int length) // (takes O(n) time) { for (int i = ((length)/2); i >= 1 ; i--) heapify(A, length, i); } void heapify(int A[], int heapsize, int root) //(takes O(h) time, // h is the height of root { int left = 2*root, right = 2*root +1, largest; if ( (left < heapsize) && (A[left] > A[root])) largest = left; else largest = root; if ( (right < heapsize) && (A[right] > A[largest])) largest = right; if (largest != root) { swap(A[root], A[largest]); heapify(A, heapsize, largest); } } class graph { private: bool *color; int vertices; void addVertex(int u, int v) { node *temp=&ptr[u]; while(temp->next!=NULL) temp=temp->next; temp->next=new node(v); } public: int V() { return vertices; } class node { public: node(int name) { label=name; next=NULL; }; node(){next=NULL;}; int label; node *next; }; class edge { public: edge(int u, int v) { U=u; V=v; next=NULL; } int U,V; edge *next; }; node *ptr; bool *marked; edge *edgeList; edge *edgeTemp; graph(int v) { ptr=new node[v+1]; vertices=v; for(int i=1;i<=v;++i) ptr[i].label=i; marked=new bool[V()+1]; for(int i=1;i<=V();++i) marked[i]=false; edgeList=NULL; } void addEdge(int u, int v) { addVertex(u,v); //addVertex(v,u); For undirected graphs only if(!edgeList) { edgeList=new edge(u,v); edgeTemp=edgeList; } else { edgeTemp->next=new edge(u,v); edgeTemp=edgeTemp->next; } } void printEdges() { edge *temp=edgeList; while(temp) { cout<<temp->U<<"-"<<temp->V<<endl; temp=temp->next; } } int *id=new int[V()+1]; int *arrival=new int[V()+1]; int *departure=new int[V()+1]; int time=1; int count=1; void dfs(int vertex) { marked[vertex]=1; id[vertex]=count; arrival[vertex]=time++; node *temp=&ptr[vertex]; int v=vertex; while(temp->next) { temp=temp->next; vertex=temp->label; if(!marked[vertex]) dfs(vertex); } departure[v]=time++; //cannot use departure[vertex] as value of 'vertex' has changed } void connectedComponent() { for(int v=1;v<=V();v++) { if(!marked[v]) { dfs(v); count++; } } for(int v=1;v<=V();v++) cout<<id[v]<<" "; } void topologicalSort() { int *topSortArray=new int[V()]; for(int i=1;i<=V();++i) topSortArray[i]=departure[i]; for(int i=1;i<=V();++i) cout<<topSortArray[i]<<" "; heapsort(topSortArray,V()+1); cout<<endl<<V()<<endl; int j=V(); int i=1; while(i<j) swap(topSortArray[i++],topSortArray[j--]); for(int i=1;i<=V();++i) { for(int j=1;j<=V();++j) { if(departure[j]==topSortArray[i]) { topSortArray[i]=j; } } } cout<<endl; for(int i=1;i<=V();++i) cout<<topSortArray[i]<<" "; } }; int main() { graph Graph(2); for(int i=1;i<=Graph.V();++i) if(!Graph.marked[i]) Graph.dfs(i); //Graph.topologicalSort(); return 0x0; }
[ "rishavpaul.nitw@gmail.com" ]
rishavpaul.nitw@gmail.com
55463ddfdd1c7b34370f84398d5fdc64ad146762
1168f3ea26e5842431cf8b97fa3902af839b1b8a
/src/Statistics_dialog/grouping.h
f9c3619fac17529db70307b80fbf88a18c7cdbaf
[]
no_license
LianaTosunyan/ATRChipset
775cf51c06d87e8edb4762169fa6b98dd46291a4
fa0f63c87390bb49fefcaea0d8af82f178e4f4b7
refs/heads/master
2021-01-23T04:53:41.182958
2017-03-26T17:05:20
2017-03-26T17:06:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
193
h
#ifndef GROUPING_H #define GROUPING_H #include <QWidget> #include <QListWidget> class CGrouping: public QWidget { Q_OBJECT public: CGrouping(); }; #endif // GROUPING_H
[ "noreply@github.com" ]
noreply@github.com
2bee3b18d4537dc38ac45a7c4d77c7773bea941f
51e8b9cd3b69e58b7dcdd6978fd9f16eef432ad0
/glut114/3dsloader.cpp
b0df521b6e137db5cacb39cf7d539106e31ab52d
[ "Apache-2.0" ]
permissive
ceefour/glut101
6986c2798e0213c484c8c4561eaceae1f008fc87
50e57d220ebb3f7432f721f9ed7fe4e034f9d868
refs/heads/master
2016-09-06T12:38:02.835027
2015-03-19T13:12:49
2015-03-19T13:12:49
31,212,598
0
0
null
null
null
null
UTF-8
C++
false
false
5,426
cpp
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <io.h> #include "3dsloader.h" /********************************************************** * * FUNCTION Load3DS (obj_type_ptr, char *) * * This function loads a mesh from a 3ds file. * Please note that we are loading only the vertices, polygons and mapping lists. * If you need to load meshes with advanced features as for example: * multi objects, materials, lights and so on, you must insert other chunk parsers. * *********************************************************/ char Load3DS(obj_type_ptr p_object, char *p_filename) { int i; //Index variable FILE *l_file; //File pointer unsigned short l_chunk_id; //Chunk identifier unsigned int l_chunk_length; //Chunk lenght unsigned char l_char; //Char variable unsigned short l_qty; //Number of elements in each chunk unsigned short l_face_flags; //Flag that stores some face information if ((l_file = fopen(p_filename, "rb")) == NULL) return 0; //Open the file while (ftell(l_file) < _filelength(_fileno(l_file))) //Loop to scan the whole file { //getche(); //Insert this command for debug (to wait for keypress for each chuck reading) fread(&l_chunk_id, 2, 1, l_file); //Read the chunk header printf("ChunkID: %x\n", l_chunk_id); fread(&l_chunk_length, 4, 1, l_file); //Read the lenght of the chunk printf("ChunkLength: %x\n", l_chunk_length); switch (l_chunk_id) { //----------------- MAIN3DS ----------------- // Description: Main chunk, contains all the other chunks // Chunk ID: 4d4d // Chunk Lenght: 0 + sub chunks //------------------------------------------- case 0x4d4d: break; //----------------- EDIT3DS ----------------- // Description: 3D Editor chunk, objects layout info // Chunk ID: 3d3d (hex) // Chunk Lenght: 0 + sub chunks //------------------------------------------- case 0x3d3d: break; //--------------- EDIT_OBJECT --------------- // Description: Object block, info for each object // Chunk ID: 4000 (hex) // Chunk Lenght: len(object name) + sub chunks //------------------------------------------- case 0x4000: i = 0; do { fread(&l_char, 1, 1, l_file); p_object->name[i] = l_char; i++; } while (l_char != '\0' && i<20); break; //--------------- OBJ_TRIMESH --------------- // Description: Triangular mesh, contains chunks for 3d mesh info // Chunk ID: 4100 (hex) // Chunk Lenght: 0 + sub chunks //------------------------------------------- case 0x4100: break; //--------------- TRI_VERTEXL --------------- // Description: Vertices list // Chunk ID: 4110 (hex) // Chunk Lenght: 1 x unsigned short (number of vertices) // + 3 x float (vertex coordinates) x (number of vertices) // + sub chunks //------------------------------------------- case 0x4110: fread(&l_qty, sizeof(unsigned short), 1, l_file); p_object->vertices_qty = l_qty; printf("Number of vertices: %d\n", l_qty); for (i = 0; i<l_qty; i++) { fread(&p_object->vertex[i].x, sizeof(float), 1, l_file); fread(&p_object->vertex[i].y, sizeof(float), 1, l_file); fread(&p_object->vertex[i].z, sizeof(float), 1, l_file); printf("Vertices list x=%f, y=%f, z=%f\n", p_object->vertex[i].x, p_object->vertex[i].y, p_object->vertex[i].z); } break; //--------------- TRI_FACEL1 ---------------- // Description: Polygons (faces) list // Chunk ID: 4120 (hex) // Chunk Lenght: 1 x unsigned short (number of polygons) // + 3 x unsigned short (polygon points) x (number of polygons) // + sub chunks //------------------------------------------- case 0x4120: fread(&l_qty, sizeof(unsigned short), 1, l_file); p_object->polygons_qty = l_qty; printf("Number of polygons: %d\n", l_qty); for (i = 0; i<l_qty; i++) { fread(&p_object->polygon[i].a, sizeof (unsigned short), 1, l_file); fread(&p_object->polygon[i].b, sizeof (unsigned short), 1, l_file); fread(&p_object->polygon[i].c, sizeof (unsigned short), 1, l_file); fread(&l_face_flags, sizeof(unsigned short), 1, l_file); printf("Polygon point a=%d, b=%d, c=%d\n", p_object->polygon[i].a, p_object->polygon[i].b, p_object->polygon[i].c); printf("Face flags: %x\n", l_face_flags); } break; //------------- TRI_MAPPINGCOORS ------------ // Description: Vertices list // Chunk ID: 4140 (hex) // Chunk Lenght: 1 x unsigned short (number of mapping points) // + 2 x float (mapping coordinates) x (number of mapping points) // + sub chunks //------------------------------------------- case 0x4140: fread(&l_qty, sizeof(unsigned short), 1, l_file); for (i = 0; i<l_qty; i++) { fread(&p_object->mapcoord[i].u, sizeof (float), 1, l_file); fread(&p_object->mapcoord[i].v, sizeof(float), 1, l_file); printf("Mapping list u=%f v=%f\n", p_object->mapcoord[i].u, p_object->mapcoord[i].v); } break; //----------- Skip unknow chunks ------------ //We need to skip all the chunks that currently we don't use //We use the chunk length information to set the file pointer //to the same level next chunk //------------------------------------------- default: fseek(l_file, l_chunk_length - 6, SEEK_CUR); } } fclose(l_file); // Closes the file stream return (1); // Returns ok }
[ "ceefour666@gmail.com" ]
ceefour666@gmail.com
4973beed35b193cce9be8f8ddb7022b790f21d28
1af49694004c6fbc31deada5618dae37255ce978
/third_party/blink/renderer/core/frame/page_dismissal_scope.cc
8c9e63638606d0504bc27384755522e3e12b3b73
[ "BSD-3-Clause", "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
728
cc
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "third_party/blink/renderer/core/frame/page_dismissal_scope.h" #include "base/check.h" #include "third_party/blink/renderer/platform/wtf/wtf.h" namespace blink { static unsigned page_dismissal_scope_count = 0; PageDismissalScope::PageDismissalScope() { DCHECK(IsMainThread()); ++page_dismissal_scope_count; } PageDismissalScope::~PageDismissalScope() { DCHECK(IsMainThread()); --page_dismissal_scope_count; } bool PageDismissalScope::IsActive() { DCHECK(IsMainThread()); return page_dismissal_scope_count > 0; } } // namespace blink
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
2e36d855d0fcc510533935bfc9ad18e4fc2aaa62
42619fe653792a19849c827e1446bb40fbfddfcc
/cast/dynamic_cast2.cpp
dbb959e09ed58ae98de01b79e350880559ee9b19
[]
no_license
mitesh741/cpp
1673ff69189fa89346daad22c60680cdb04408f1
6959313b0760746c484bd1e96308769a7708656b
refs/heads/master
2022-01-06T12:46:52.591131
2019-05-06T11:24:07
2019-05-06T11:24:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
893
cpp
#include <iostream> #include <string> using namespace std; class Window { public: Window() { } Window(const string s):name(s) { }; virtual ~Window() { }; void getName() { cout << name << endl; }; private: string name; }; class ScrollWindow : public Window { public: ScrollWindow(string s) : Window(s) { }; ~ScrollWindow() { }; void scroll() { cout << "scroll()" << endl; }; }; void DoSomething(Window *w) { w->getName(); //w->scroll(); // class "Window" has no member scroll /* check if the pointer is pointing to a scroll window */ ScrollWindow *sw = dynamic_cast<ScrollWindow*>(w); // IMPORTANT /* if not null, it's a scroll window object */ if(sw) sw->scroll(); } int main() { Window *w = new Window("plain window"); ScrollWindow *sw = new ScrollWindow("scroll window"); DoSomething(w); DoSomething(sw); return 0; }
[ "mpmitesh741@gmail.com" ]
mpmitesh741@gmail.com
8c0560cfc8c1eac925d58b7e12d561fd5f6460e1
478ba34fca3329c6c2d5a4808d57cdea8e4e4ab9
/1semestre/aeda/aeda1920_ci1/Tests/Room.cpp
59d60d8e71a4463e43df895339769cc3f67419f8
[]
no_license
monkin77/2ano
83fc8120a99ab7921a27222ec3dae0773af975e2
c0e81627106787e28c73d35ceafeddb13aaad33e
refs/heads/master
2023-01-14T07:04:33.781302
2020-11-26T18:51:03
2020-11-26T18:51:03
303,187,948
0
0
null
null
null
null
UTF-8
C++
false
false
2,426
cpp
#include <iostream> #include "Room.h" using namespace std; Room::Room(): code(0), floor(0), reservation(false) {} Room::Room(string c, int f) : code(c), floor(f), reservation(false) { roomLength = 0; roomWidth = 0; } Room::Room(string c, int f, int w, int l) : code(c), floor(f), roomWidth(w), roomLength(l), reservation(false) { } string Room::getCode() const { return code; } int Room::getFloor() const { return floor; } int Room::getWidth() const { return roomWidth; } int Room::getLength() const { return roomLength; } float Room::getArea() const { return roomLength * roomWidth / 10000; // need to ensure conversion from cm2 to m2 } void Room::setLength(int roomLength){ this->roomLength = roomLength; } void Room::setWidth(int roomWidth){ this->roomWidth = roomWidth; } bool Room::getReservation() const{ return reservation; } void Room::setReservation(bool roomReserv){ this->reservation = roomReserv; } RegularRoom::RegularRoom(string c, int f) : Room (c, f) { } RegularRoom::RegularRoom(string c, int f, int w, int l) : Room (c, f, w, l) { } FamilyRoom::FamilyRoom(string c, int f) : Room (c, f) { numChildrenBed = 0; } FamilyRoom::FamilyRoom(std::string c, int f, int w, int l, float numCB) : Room (c, f, w, l) { this->numChildrenBed = numCB; } int FamilyRoom::getNumChildrenBed() const { return numChildrenBed; } void FamilyRoom::setNumChildrenBed(int numCB){ this->numChildrenBed = numCB; } LuxuryRoom::LuxuryRoom(string c, int f) : Room(c, f) { typeBed = ""; } LuxuryRoom::LuxuryRoom(std::string c, int f, int w, int l, std::string typeBed) : Room(c, f, w, l) { this->typeBed = typeBed; } string LuxuryRoom::getTypeBed() const { return typeBed; } void LuxuryRoom::setTypeBed(string tB){ this->typeBed = tB; } //------------------------------------------ //------------------------------------------ //TODO bool Room::operator == (const Room &room) const{ if( (this->code == room.code) && (this->floor == room.floor) ) return true; return false; } //TODO float RegularRoom::price() const { float singlePrice = 4.0; return singlePrice * this->getArea(); } //TODO float FamilyRoom::price() const { float singlePrice = 4.0; return singlePrice * this->getArea(); } //TODO float LuxuryRoom::price() const { float singlePrice = 4.0 * 1.15; return singlePrice * this->getArea(); }
[ "monkinsmurf@gmail.com" ]
monkinsmurf@gmail.com
5b210afc553b947c7cf90b399ca4efa6890d49a5
b0528c7487901e68684f4ca1cc9a5d9b7208d6f0
/source/game_view/rendering/AssignStep.cpp
7ff811f91ad550c322c0d877c39a42f7ba553f04
[]
no_license
seasky100/sailing-simulator
f76d38f0aae1aaa51e26283070ccea6ca1b9f92f
8369bc0e9700d671942e54e1f924d9884ca839fb
refs/heads/master
2021-06-05T01:34:41.097231
2016-10-30T13:49:10
2016-10-30T13:49:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,277
cpp
#include "AssignStep.h" #include "../video_system/OpenGLRenderer.h" #include "../scene_graph/SceneNode.h" #include "../scene_graph/LightNode.h" #include "../scene_graph/CameraNode.h" using namespace Game_View; void AssignStep::VExecute( SceneGraph* pSceneGraph, const unsigned int deltaMilliseconds) { RenderFunction renderFunction = fastdelegate::MakeDelegate( this, &AssignStep::AssignFromSceneNode ); ExecuteOnAllSceneNodes(pSceneGraph, deltaMilliseconds, renderFunction); } void AssignStep::AssignFromSceneNode( StrongSceneNodePtr pSceneNode, const unsigned int deltaMilliseconds) { if (!pSceneNode->VHasActor()) { LightNode* pLightNode = dynamic_cast<LightNode*>(pSceneNode.get()); if (pLightNode != nullptr) { m_pRenderer->AddLight(pLightNode); return; } CameraNode* pCameraNode = dynamic_cast<CameraNode*>(pSceneNode.get()); if (pCameraNode != nullptr) { m_pRenderer->SetCamera(pCameraNode); return; } return; } }
[ "markus.kohout@rwth-aachen.de" ]
markus.kohout@rwth-aachen.de
1c596ffc38dac322220c1eca5935a15542ed30bb
683b495906d3a2948f75847eabe9f8ab64802ccd
/Tram.cpp
5967c5ae917c2c8bacc0f5964e052e58d1310fa8
[]
no_license
IShahnawazShaikh/Data-Structures
71afbdd51b1455da9c873cda66c84d4fdcaffd0d
7ee62f6bc4ac78de4c019a36096867926ca2ae8f
refs/heads/master
2022-12-30T05:49:48.346718
2020-10-25T17:29:24
2020-10-25T17:29:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
519
cpp
#include<iostream> using namespace std; class Tram{ public: int n; Tram(int n){ this->n=n; } void minimum(){ int i,TramValue=0; int a,b,capacity=0; for(i=1;i<=this->n;i++){ if(capacity<TramValue) capacity=TramValue; cin>>a; cin>>b; if(a<=TramValue){ TramValue-=a; } if(i!=n) TramValue+=b; } TramValue=0; cout<<capacity; } }; int main(){ int n; cin>>n; if(n>=2 && n<=1000){ Tram obj(n); obj.minimum(); } return 0; }
[ "32239343+shahnawazshaikh123@users.noreply.github.com" ]
32239343+shahnawazshaikh123@users.noreply.github.com
3fe6085679d64fab2422754c56a31772175ed949
1742cd526f243de44a84769c07266c473648ecd6
/uri/1444.cpp
e49d726e336f5b545521af9449861bf4bac3756f
[]
no_license
filipeabelha/gym-solutions
0d555f124fdb32508f6406f269a67eed5044d9c6
4eb8ad60643d7923780124cba3d002c5383a66a4
refs/heads/master
2021-01-23T05:09:38.962238
2020-11-29T07:14:31
2020-11-29T07:14:31
86,275,942
2
0
null
null
null
null
UTF-8
C++
false
false
327
cpp
#include <bits/stdc++.h> using namespace std; int n, ans; int main () { while (1) { scanf("%d", &n); if (!n) break; for (ans = 0; n > 1; ) { if (n % 3 == 0) ans += n/3, n = n/3; else ans += n/3 + 1, n = n/3 + 1; } printf("%d\n", ans); } return 0; }
[ "me@filipeabelha.com" ]
me@filipeabelha.com
f56bd26a57e15310dd8ff582340c1e08f9e013c7
07258c094a909f06ad365a2cfd7627e811353239
/seance.cpp
cbb121a7f749534f87401deb67184846b46094cf
[]
no_license
talai2u/timetable
4475bcae90f9aeb84bf840ae0a529cf07737ac5c
34932f43eb16890b9b61dd0c2ac68cc3a58d0339
refs/heads/master
2021-01-11T23:52:50.364637
2017-01-11T13:04:39
2017-01-11T13:04:39
78,639,278
0
0
null
null
null
null
UTF-8
C++
false
false
6,097
cpp
#include "seance.h" seance::seance() { } seance::~seance() { } seance::seance( date_* d, time_* heure_debut, time_* heure_fin, cours* c, salle* s) :_date{d}, _heure_debut{heure_debut}, _heure_fin{heure_fin}, _cours{c}, _salle{s} {} //-------- Setters end getters --------------- int seance::id() const{ return _id; } void seance::set_id(const int id){ _id = id; } date_ seance::date() const{ return *_date; } void seance::set_date( date_* d){ _date = d; } time_ seance::heure_debut() const{ return *_heure_debut; } void seance::set_heure_debut( time_* h_debut){ _heure_debut = h_debut; } time_ seance::heure_fin() const{ return *_heure_fin; } void seance::set_heure_fin( time_* h_fin){ _heure_fin = h_fin; } cours seance::get_cours() const { return *_cours; } void seance::set_cours(cours* c){ _cours = c; } salle seance::get_salle() const { return *_salle; } void seance::set_salle(salle* s){ _salle = s; } //--------------------------------------- void seance::ajouter(){ database db; int query_state; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; return; } string query="INSERT INTO seances (`id`, `date_seance`, `heure_debut`, `heure_fin`, `id_cours`, `id_salle`) VALUES ( NULL, '"+_date->getDate()+"', '"+_heure_debut->getTime()+"', '"+_heure_fin->getTime()+"', '"+std::to_string(_cours->id())+"', '"+std::to_string(_salle->id())+"')"; query_state=mysql_query(db.conn, query.c_str()); if(query_state!=0){ cout<<mysql_error(db.conn)<<endl<<endl; return; } mysql_query(db.conn, "SELECT LAST_INSERT_ID()"); db.res = mysql_store_result(db.conn); db.row = mysql_fetch_row(db.res); _id = atoi(db.row[0]); cout<< "Les données sont bien ajoutées" <<endl<<endl; mysql_close(db.conn); } void seance::supprimer() const{ database db; int query_state; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; return; } string query="DELETE FROM seances WHERE id = '"+std::to_string(_id)+"'"; query_state=mysql_query(db.conn, query.c_str()); if(query_state!=0){ cout<<mysql_error(db.conn)<<endl<<endl; return; } cout<< "Les données sont bien supprimées" <<endl<<endl; mysql_close(db.conn); } void seance::modifier() const{ database db; int query_state; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; return; } string query="UPDATE seances set date_seance='"+_date->getDate()+"', heure_debut='"+_heure_debut->getTime()+"', heure_fin='"+_heure_fin->getTime()+"', id_cours='"+std::to_string(_cours->id())+"', id_salle='"+std::to_string(_salle->id())+"' WHERE id = '"+std::to_string(_id)+"'"; query_state=mysql_query(db.conn, query.c_str()); if(query_state!=0){ cout<<mysql_error(db.conn)<<endl<<endl; return; } cout<< "Les données sont bien modifiées" <<endl<<endl; mysql_close(db.conn); } void seance::charger(){ database db; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; return; } string query= "SELECT * FROM seances WHERE id = '"+std::to_string(_id)+"'"; mysql_query(db.conn, query.c_str()); db.res = mysql_store_result(db.conn); while ((db.row = mysql_fetch_row(db.res))) { if(db.row[1] != NULL){ int day = _date->stringToDate(db.row[1]).day(); int month = _date->stringToDate(db.row[1]).month(); int year = _date->stringToDate(db.row[1]).year(); date_* d = new date_(day, month, year); set_date(d); } if(db.row[2] != NULL){ int hour = _heure_debut->stringToTime(db.row[2]).hour(); int minute = _heure_debut->stringToTime(db.row[2]).minute(); time_* t = new time_(hour, minute); set_heure_debut(t); } if(db.row[3] != NULL){ int hour = _heure_fin->stringToTime(db.row[3]).hour(); int minute = _heure_fin->stringToTime(db.row[3]).minute(); time_* t = new time_(hour, minute); set_heure_fin(t); } if(db.row[4] != NULL){ cours* c = new cours; c->set_id(atoi(db.row[4])); c->charger(); set_cours(c); } if(db.row[5] != NULL){ salle* s = new salle; s->set_id(atoi(db.row[5])); s->charger(); set_salle(s); } } mysql_close(db.conn); } vector<seance> seance::seancesByFiliere(int id_filiere) const{ database db; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; } string query= "SELECT S.id FROM seances S INNER JOIN cours C ON S.id_cours = C.id INNER JOIN filieres F ON C.id_filiere = F.id WHERE F.id = '"+std::to_string(id_filiere)+"' ORDER BY date_seance, heure_debut;"; mysql_query(db.conn, query.c_str()); db.res = mysql_store_result(db.conn); vector<seance> seances; while ((db.row = mysql_fetch_row(db.res))) { seance s ; s.set_id(atoi(db.row[0])); s.charger(); seances.push_back(s); } mysql_close(db.conn); return seances; } vector<seance> seance::getAll() const{ database db; if(!db.connect()){ cout<<mysql_error(db.conn)<<endl<<endl; } string query= "SELECT * FROM seance"; mysql_query(db.conn, query.c_str()); db.res = mysql_store_result(db.conn); vector<seance> _seance; while ((db.row = mysql_fetch_row(db.res))) { seance s ; s.set_id(atoi(db.row[0])); s.charger(); _seance.push_back(s); } mysql_close(db.conn); return _seance; }
[ "talai.yns@gmail.com" ]
talai.yns@gmail.com
0823b5b9341641594f2b186e26802652593a3757
1ceed49a59cc104695732b404ce3f195ae3d4954
/sem 1/4.11/main.cpp
5fab9e9a94aae27e4822b8dcccc4e36917bfc589
[]
no_license
pawellazicki/C_Homework
60804b4627082c9ff4edb1d8b5b38af37825ecf2
725e59ce635fa8c908d2d4d74610ac7cda5ba73a
refs/heads/master
2020-05-29T16:57:05.415139
2019-05-29T16:01:21
2019-05-29T16:01:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
412
cpp
#include <stdio.h> #include <stdlib.h> #define PI 3.14159 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(void) { float r,o,p; do { printf("wpisz promien kola aby orzymac jego obwod i powierzchnie:\n"); scanf("%f", &r); if(r<=0) { printf("blad\n"); } } while(r<=0); o = 2*PI*r; p = PI*r*r; printf("%.2f\n%.2f", o,p); return 0; }
[ "pawelllaz@gmail.com" ]
pawelllaz@gmail.com
7ab50487fd8270b00fb77edcdaa76c8651f0d0df
32aac3f245804748bceba053f0da2838fe7c36de
/TestCase/client/RegManager_Test.h
98cd2e1f5fb98d596011e6bf1fa73d2e2757b51d
[]
no_license
bfss-storage/bfss_server
68408d547fcb4adc6574c3ace6ec5baa33589d79
fd3e55e24efe3e788c1d2be7bf35f1481d86db35
refs/heads/master
2023-01-07T13:05:12.698807
2019-05-28T08:03:58
2019-05-28T08:03:58
188,982,645
2
1
null
2023-01-03T22:50:51
2019-05-28T08:02:14
C++
UTF-8
C++
false
false
852
h
#pragma once #include <BFSS_REGMD.h> #include <thrift/protocol/TBinaryProtocol.h> #include <thrift/transport/TSocket.h> #include <thrift/transport/TTransportUtils.h> #include <thrift/stdcxx.h> #include "gtest/gtest.h" #include <set> using namespace std; using namespace apache::thrift; using namespace apache::thrift::protocol; using namespace apache::thrift::transport; using namespace BFSS_REGM; using ::testing::EmptyTestEventListener; using ::testing::InitGoogleTest; using ::testing::Test; using ::testing::TestEventListeners; using ::testing::TestInfo; using ::testing::TestPartResult; using ::testing::UnitTest; class REGM_TEST : public ::testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); protected: virtual void SetUp(); virtual void TearDown(); BFSS_REGMDClient * _client; };
[ "bfssstorage@gmail.com" ]
bfssstorage@gmail.com
3858fd9907ed0bcc8611fc78dd14e158fe6cec23
a70f1bcc082202dac4f5a9c1f949b78395380f0c
/sketchbook/Hang time game/SerialLCDClass/Serial_LCD/Serial_LCD.ino
b86f0fde37d8317128140b9814fafcc72ecda4f8
[]
no_license
arlinjv/Arduino
1e948792fb94a0fee58406dc0053a714d38e1534
2af8628fc2e3aaaae3ca4d1146ee090e574c3666
refs/heads/master
2021-01-15T15:27:38.706338
2017-06-08T19:26:01
2017-06-08T19:26:01
64,614,530
0
0
null
null
null
null
UTF-8
C++
false
false
1,069
ino
// sketch used to implement new LCD class to replace old approach #include <SoftwareSerial.h> #include "SerLCD_Class.h" // Serial output code borrowed from http://www.arduino.cc/en/Tutorial/Graph int lcdPin = 2; int currentReading; int lowestReading = 1023; String readingStr = ""; String minStr = ""; String lineOne = "Line 1 - String"; //SoftwareSerial LCD = SoftwareSerial(0, pin); SerLCD lcd(lcdPin); void setup() { // initialize the serial communication: Serial.begin(115200); lcd.setupLCD(); } void loop() { currentReading = analogRead(A0); if (currentReading < lowestReading) { lowestReading = currentReading; } readingStr="Current: "; if (currentReading < 1000) { readingStr+=" "; } readingStr+= currentReading; lcd.writeLineOne(readingStr); Serial.println(readingStr); minStr="min: "; if (lowestReading < 1000) { minStr+=" "; } minStr += lowestReading; lcd.writeLineTwo(minStr); // wait a bit for the analog-to-digital converter // to stabilize after the last reading: delay(100); }
[ "arlinjv@att.net" ]
arlinjv@att.net
badb710c06159df8ac5f4200efa10e3d2b8aca71
3b49c521e0336d56f0e43f98bfe1e4a217e443b1
/tokit_c++_src/tokit/language/c++/gen_cpp.cpp
f000cef91af7569458a6a2e408b62abdc6fa78dd
[]
no_license
ycllz/tokit
e1409aa17840091744ba8aa63a055ed7bc9de86e
c2d0646a00397f564c9cd40e2af841ef6bdb3ad6
refs/heads/master
2021-01-02T09:18:00.166678
2014-11-18T03:19:14
2014-11-18T03:19:14
null
0
0
null
null
null
null
GB18030
C++
false
false
19,684
cpp
///<------------------------------------------------------------------------------ //< @file: prop\parser\gen_cpp.cpp //< @author: 洪坤安 //< @date: 2014年9月25日 23:13:52 //< @brief: //< Copyright (c) 2014 Tokit. All rights reserved. ///<------------------------------------------------------------------------------ #include "c++_generator.h" #include "file_tool.h" #include "str_tool.h" #include "echo_tool.h" #include "cfg.h" #include "parser.h" #include <fstream> using namespace filetool; using namespace std; namespace cxx { // 生成结构体的构造函数 string gen_struct_ctor(const cfg_t &cfg) { string ctor_text = "%cfg%::%cfg%()" ; strtool::replace(ctor_text, "%cfg%", cpptool::get_cfg_type_name(cfg)); for(size_t n = 0; n < cfg.fields.size(); ++n){ const field_t &field = cfg.fields[n]; if (field.is_array() || field.is_set()){ continue; } ctor_text += n ? "\n , " : "\n : "; ctor_text += (field.fieldtype == fieldtype_string) ? field.en_name + "(\"\")" : field.en_name + "(0)"; } ctor_text += "\n{\n}"; return ctor_text; } // 生成结构体的构造函数 string gen_struct_print(const cfg_t &cfg) { string print_text = "std::string %cfg%::print() const" "\n{" "%print%" "\n}" ; strtool::replace(print_text, "%cfg%", cpptool::get_cfg_type_name(cfg)); string printf_fmt; string printf_argv; static const string static_printf_format[fieldtype_max] = { "", "%s", "%u", "%d", "%d", "%d", "\"I64d\"", "%u", "%u", "%u", "\"I64u\"", "%f", "%lf", }; size_t n_fields = cfg.fields.size(); for(size_t n = 0; n < n_fields; ++n){ const field_t &field = cfg.fields[n]; if (field.is_array() || field.is_set()){ continue; } printf_fmt += field.en_name + "=" + static_printf_format[field.fieldtype]; if (n + 1 < n_fields){ printf_fmt += " "; } if (0 == n % 10 && n > 1){ printf_fmt += "\"\n \""; } printf_argv += "\n , "; printf_argv += (field.fieldtype == fieldtype_string) ? field.en_name + ".c_str()" : field.en_name; } string print_stmt; if(n_fields > 0){ print_stmt = "\n char buf[2048];" "\n snprintf(buf, sizeof(buf), \"%printf_fmt%\"%printf_argv%);" "\n" "\n return buf;"; strtool::replace(print_stmt, "%printf_fmt%", printf_fmt); strtool::replace(print_stmt, "%printf_argv%", printf_argv); } strtool::replace(print_text, "%print%", print_stmt); return print_text; } // 生成读取属性的语句 string gen_load_attr_statement(const field_t &field) { static const string static_load_attr_stmt[fieldtype_max] = { "", "cfg.%field% = %cast%(%val%);", "cfg.%field% = (%val%[0] != '0');", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = %cast%(%val%);", "cfg.%field% = (float)%cast%(%val%);", "cfg.%field% = %cast%(%val%);", }; static const string static_cast_func_name[fieldtype_max] = { "", "strtool::un_escape_xml", "strtool::str_to_bool", "strtool::str_to_int32", "strtool::str_to_int32", "strtool::str_to_int32", "strtool::str_to_int64", "strtool::str_to_uint32", "strtool::str_to_uint32", "strtool::str_to_uint32", "strtool::str_to_uint64", "atof", "atof", }; static const string static_load_vec_stmt = "cfg.%field% = strtool::split_str_to_vec<%T%>(%val%, %cast%);"; static const string static_load_set_stmt = "cfg.%field% = strtool::split_str_to_set<%T%>(%val%, %cast%);"; static const string static_load_str_vec_stmt = "cfg.%field% = strtool::split(%val%);"; static const string static_load_str_set_stmt = "cfg.%field% = strtool::split_str_set(%val%);"; string stmt = static_load_attr_stmt[field.fieldtype]; if (field.is_array()){ if (field.fieldtype == fieldtype_string){ stmt = static_load_str_vec_stmt; }else{ stmt = static_load_vec_stmt; } }else if (field.is_set()){ if (field.fieldtype == fieldtype_string){ stmt = static_load_str_set_stmt; }else{ stmt = static_load_set_stmt; } } string val = "node->first_attribute(\"%field%\")->value()"; const string &cast_func = static_cast_func_name[field.fieldtype]; strtool::replace(stmt, "%val%", val); strtool::replace(stmt, "%field%", field.en_name); strtool::replace(stmt, "%T%", cpp_generator::raw_type_2_c_type(field.fieldtype)); strtool::replace(stmt, "%cast%", cast_func); return stmt; } // 拼接字符串键值 // eg: string key = tostr(prop.type) + tostr(prop.id) + prop.name; // eg: string key = tostr(prop.type) + prop.name; // eg: string &key = prop.name; string splice_str_key(fieldvec_t keys) { string ret = "string key = "; if(keys.size() == 1){ ret = "std::string &key = "; }else{ ret = "std::string key = "; } for (fieldvec_t::iterator itr = keys.begin(); itr != keys.end(); ++itr){ field_t &key = *itr; if(key.fieldtype == fieldtype_string){ ret += key.en_name; }else{ ret += "strtool::tostr(" + key.en_name + ")"; } ret += " + "; } ret.erase(ret.end() - 3, ret.end()); ret += ";"; return ret; } // splice the key string // eg: string key = tostr(prop.type) + tostr(prop.id) + prop.name; // eg: string key = tostr(prop.type) + prop.name; // eg: string &key = prop.name; string splice_int_key(fieldvec_t &keys) { size_t n_key = keys.size(); if(n_key <= 1){ return ""; } string ret = ""; switch(n_key) { // 2个主键 case 2: ret = "uint64 key = keytool::Get3232Key("; ret += keys[0].en_name; ret += ", "; ret += keys[1].en_name; ret += ");"; break; // 3个主键 case 3: ret = "uint64 key = keytool::Get161616Key("; ret += keys[0].en_name; ret += ", "; ret += keys[1].en_name; ret += ", "; ret += keys[2].en_name; ret += ");"; break; // 4个主键 case 4: ret = "uint64 key = keytool::Get16161616Key("; ret += keys[0].en_name; ret += ", "; ret += keys[1].en_name; ret += ", "; ret += keys[2].en_name; ret += ", "; ret += keys[3].en_name; ret += ");"; break; } return ret; } string splice_n_key(const cfg_t &cfg, const char* prefix = "") { size_t n_key = cfg.keys.size(); if(n_key <= 1){ return ""; } bool is_key_has_str = false; for (size_t n = 0; n < n_key; n++){ int keyidx = cfg.keys[n]; const field_t &key = cfg.fields[keyidx]; if(key.fieldtype == fieldtype_string){ is_key_has_str = true; break; } } fieldvec_t keys; for (size_t n = 0; n < n_key; n++){ int keyidx = cfg.keys[n]; field_t key = cfg.fields[keyidx]; // 注意,这里进行了赋值拷贝 key.en_name = prefix + key.en_name; keys.push_back(key); } string text = is_key_has_str ? splice_str_key(keys) : splice_int_key(keys); return text; } string gen_n_key_map_insert_stmt(const cfg_t &cfg) { size_t n_key = cfg.keys.size(); if(n_key <= 1){ return ""; } bool is_key_has_str = false; for (size_t n = 0; n < n_key; n++){ int keyidx = cfg.keys[n]; const field_t &key = cfg.fields[keyidx]; if(key.fieldtype == fieldtype_string){ is_key_has_str = true; break; } } fieldvec_t keys; for (size_t n = 0; n < n_key; n++){ int keyidx = cfg.keys[n]; field_t key = cfg.fields[keyidx]; // 注意,这里进行了赋值拷贝 key.en_name = "cfg." + key.en_name; keys.push_back(key); } string map_key = "\n " + splice_n_key(cfg, "cfg."); string map_insert = "\n m_%map%[key] = curcfg;\n"; strtool::replace(map_insert, "%map%", cpptool::get_n_key_map_name(cfg)); return map_key + map_insert; } string gen_1_key_map_insert_stmt(const cfg_t &cfg) { string text = ""; for(size_t n = 0; n < cfg.fields.size(); n++){ const field_t &field = cfg.fields[n]; if (!field.is_1_key() || field.is_n_key()){ continue; } string insert_stmt = "\n m_%map%[cfg.%key%] = curcfg;"; strtool::replace(insert_stmt, "%map%", cpptool::get_1_key_map_name(cfg, field)); strtool::replace(insert_stmt, "%key%", field.en_name); text += insert_stmt; } strtool::replace(text, "%cfg%", cfg.en_name); return text; } string gen_load_func(const cfg_t &cfg) { string text = "\n// %comment%" "\n%load_func_name%" "\n{" "\n tick_t load_tick;" "\n" "\n rapidxml::file<> fdoc(this->get_path(\"%cfg%.xml\").c_str());" "\n rapidxml::xml_document<> doc;" "\n if(!fdoc.data()){" "\n std::cout << \"err: load \" << this->get_path(\"%cfg%.xml\") << \" failed, please check the file path\" << std::endl;" "\n return false;" "\n }" "\n" "\n doc.parse<0>(fdoc.data());" "\n" "\n rapidxml::xml_node<>* root = doc.first_node();" "\n if(!root){" "\n std::cout << \"err: parse <%cfg%.xml> failed, please check xml file format\" << std::endl;" "\n return false;" "\n }" "\n" "\n clear_%cfg%();" "\n" "\n int n_row = 0;" "\n for(rapidxml::xml_node<> *node = root->first_node(); node; node = node->next_sibling()){" "\n ++n_row;" "\n }" "\n%vec_reserve_stmt%" "\n %cfgtype% cfg;" "\n for(rapidxml::xml_node<> *node = root->first_node(); node; node = node->next_sibling()){" // "\n rapidxml::xml_attribute<> *attr = node->first_attribute();" "\n" ; string vec_reserve_stmt; if (!cfg.only_has_1_row()){ vec_reserve_stmt = "\n m_%vec%.reserve(n_row);\n"; } strtool::replace(text, "%vec_reserve_stmt%", vec_reserve_stmt); strtool::replace(text, "%cfg%", cfg.en_name); strtool::replace(text, "%load_func_name%", cpptool::get_load_func_declare(cfg)); strtool::replace(text, "%comment%", cfg.cn_name); strtool::replace(text, "%vec%", cpptool::get_vec_name(cfg)); strtool::replace(text, "%cfgtype%", cpptool::get_cfg_type_name(cfg)); string load_attr_stmt; size_t n_field = cfg.fields.size(); for(size_t n = 0; n < n_field; n++){ const field_t &field = cfg.fields[n]; load_attr_stmt = " " + gen_load_attr_statement(field) + "\n"; if (n * 2 + 1 > n_field){ strtool::replace(load_attr_stmt, "node->first_attribute", "node->last_attribute"); } text += load_attr_stmt; } if (!cfg.only_has_1_row()){ string vec_push_stmt = "\n m_%vec%.push_back(cfg);" "\n %cfgtype%* curcfg = &m_%vec%.back();" ; strtool::replace(vec_push_stmt, "%vec%", cpptool::get_vec_name(cfg)); strtool::replace(vec_push_stmt, "%cfg%", cfg.en_name); strtool::replace(vec_push_stmt, "%cfgtype%", cpptool::get_cfg_type_name(cfg)); string map_insert_stmt = "\n "; map_insert_stmt += gen_n_key_map_insert_stmt(cfg); map_insert_stmt += gen_1_key_map_insert_stmt(cfg); text += vec_push_stmt; text += map_insert_stmt; }else{ string eval_stmt = "\n m_%cfg% = cfg;" "\n break;" ; strtool::replace(eval_stmt, "%cfg%", cfg.en_name); text += eval_stmt; } string end_stmt = "\n }" "\n" "\n printf(\"load <%-20s> success, cost time = <%-6f>s\\n\", \"%cfg%.xml\", load_tick.end_tick());" "\n return true;" "\n}" ; strtool::replace(end_stmt, "%cfg%", cfg.en_name); text += end_stmt; return text; } string gen_call_load_func_stmt(const cfg_t &cfg) { return " is_succ &= load_" + cfg.en_name + "();"; } string gen_call_clear_func_stmt(const cfg_t &cfg) { string text = " " + cpptool::get_clear_func_name(cfg) + "();"; return text; } string gen_clear_func(const cfg_t &cfg) { string text = "\n%clear_func%" "\n{" "%clear_stmt%" "\n}" ; string clear_stmt; if (!cfg.only_has_1_row()){ clear_stmt += "\n m_" + cpptool::get_vec_name(cfg) + ".clear();"; if (cfg.keys.size() > 1){ clear_stmt += "\n m_" + cpptool::get_n_key_map_name(cfg) + ".clear();"; } size_t n_field = cfg.fields.size(); for(size_t n = 0; n < n_field; n++){ const field_t &field = cfg.fields[n]; if (!field.is_1_key() || field.is_n_key()){ continue; } clear_stmt += "\n m_" + cpptool::get_1_key_map_name(cfg, field) + ".clear();"; } }else{ clear_stmt = "\n m_%cfg% = %cfgtype%();"; strtool::replace(clear_stmt, "%cfgtype%", cpptool::get_cfg_type_name(cfg)); strtool::replace(clear_stmt, "%cfg%", cfg.en_name); } strtool::replace(text, "%clear_func%", cpptool::get_clear_func_declare(cfg)); strtool::replace(text, "%clear_stmt%", clear_stmt); return text; } string gen_n_key_find_func(const cfg_t &cfg) { const size_t n_key = cfg.keys.size(); if(n_key <= 1){ return ""; } string text = "\n%find_func%" "\n{" "\n %key_stmt%" "\n %map%::iterator itr = m_%map%.find(key);" "\n if(itr == m_%map%.end()){" "\n return NULL;" "\n }" "\n" "\n %cfg% *cfg = itr->second;" "\n return cfg;" "\n}" "\n" ; strtool::replace(text, "%cfg%", cpptool::get_cfg_type_name(cfg)); strtool::replace(text, "%find_func%", cpptool::get_n_key_find_func_declare(cfg)); strtool::replace(text, "%key_stmt%", splice_n_key(cfg)); strtool::replace(text, "%map%", cpptool::get_n_key_map_name(cfg)); return text; } string gen_1_key_find_func(const cfg_t &cfg) { string templet = "\n%find_func%" "\n{" "\n %map%::iterator itr = m_%map%.find(%key%);" "\n if(itr == m_%map%.end()){" "\n return NULL;" "\n }" "\n" "\n %cfg% *cfg = itr->second;" "\n return cfg;" "\n}" ; string text; for(size_t n = 0; n < cfg.fields.size(); n++){ const field_t &field = cfg.fields[n]; if (!field.is_1_key() || field.is_n_key()){ continue; } string func_stmt = templet; strtool::replace(func_stmt, "%cfg%", cpptool::get_cfg_type_name(cfg)); strtool::replace(func_stmt, "%find_func%", cpptool::get_1_key_find_func_declare(cfg, field)); strtool::replace(func_stmt, "%map%", cpptool::get_1_key_map_name(cfg, field)); strtool::replace(func_stmt, "%key%", field.en_name); text += func_stmt + "\n"; } strtool::replace(text, "%cfg%", cfg.en_name); return text; } string gen_find_func(const cfg_t &cfg) { if (cfg.only_has_1_row()){ return ""; } string text; text += cpptool::get_comment(cfg); text += gen_n_key_find_func(cfg) + gen_1_key_find_func(cfg); return text; } } bool cpp_generator::gen_cpp_file(const string &cpp_file) { static string cpp_templet; if (cpp_templet.empty()){ filetool::get_whole_file_str(m_cpp_templet_path, cpp_templet); if(cpp_templet.empty()){ ECHO_ERR("生成c++文件失败:找不到模板文件<%s>", m_cpp_templet_path.c_str()); return false; } } string src = cpp_templet; strtool::replace(src, "%cfg%", m_cfgbase.filename); strtool::replace(src, "%structs_ctor%", cpptool::splice(m_cfgbase, cxx::gen_struct_ctor, "\n\n")); strtool::replace(src, "%structs_print%", cpptool::splice(m_cfgbase, cxx::gen_struct_print, "\n\n")); strtool::replace(src, "%load_funcs%", cpptool::splice(m_cfgbase, cxx::gen_load_func, "\n")); strtool::replace(src, "%clear_funcs%", cpptool::splice(m_cfgbase, cxx::gen_clear_func, "\n")); strtool::replace(src, "%find_funcs%", cpptool::splice(m_cfgbase, cxx::gen_find_func, "\n")); strtool::replace(src, "%mgr%", cpptool::get_mgr_name(m_cfgbase)); strtool::replace(src, "%load_stmt%", cpptool::splice(m_cfgbase, cxx::gen_call_load_func_stmt, "\n")); strtool::replace(src, "%clear_stmt%", cpptool::splice(m_cfgbase, cxx::gen_call_clear_func_stmt, "\n")); strtool::replace(src, "%cfg_member%", cpptool::get_member_comment_list(m_cfgbase)); bool is_overwrite_file_ok = filetool::overwrite_file(cpp_file, src); return is_overwrite_file_ok; }
[ "psydollar@gmail.com" ]
psydollar@gmail.com
1d47d62239405c24dbbed99b8e8adc18b4192e30
43a2fbc77f5cea2487c05c7679a30e15db9a3a50
/Cpp/Internal (Offsets Only)/SDK/BP_WeShallSailTogether_ShantyDesc_classes.h
65ee3deb36ab56954422b77a7ce4f4fc5ebcfc65
[]
no_license
zH4x/SoT-Insider-SDK
57e2e05ede34ca1fd90fc5904cf7a79f0259085c
6bff738a1b701c34656546e333b7e59c98c63ad7
refs/heads/main
2023-06-09T23:10:32.929216
2021-07-07T01:34:27
2021-07-07T01:34:27
383,638,719
0
0
null
null
null
null
UTF-8
C++
false
false
821
h
#pragma once // Name: SoT-Insider, Version: 1.102.2382.0 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_WeShallSailTogether_ShantyDesc.BP_WeShallSailTogether_ShantyDesc_C // 0x0000 (FullSize[0x0118] - InheritedSize[0x0118]) class UBP_WeShallSailTogether_ShantyDesc_C : public UShantyItemDesc { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_WeShallSailTogether_ShantyDesc.BP_WeShallSailTogether_ShantyDesc_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "Massimo.linker@gmail.com" ]
Massimo.linker@gmail.com
90d9b881b7fcfe3deb50ff7e49eb663bcf4b1f8e
c7f7fe16096d01f1b2be0c181109d137442ed3a7
/exp/http/httplib.h
a9a87603101b52fef013f5581c619b138a7a9026
[ "MIT" ]
permissive
dualword/quartz
f418413b3740df8ecc81d487cb7e91f3e1bf510b
29b0cf7fb981ec95db894259e32af233f64fa616
refs/heads/master
2023-03-20T11:01:02.717558
2019-11-10T04:24:02
2019-11-10T04:24:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
53,533
h
// // httplib.h // // Copyright (c) 2017 Yuji Hirose. All rights reserved. // MIT License // #ifndef _CPPHTTPLIB_HTTPLIB_H_ #define _CPPHTTPLIB_HTTPLIB_H_ #ifdef _WIN32 #ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #ifndef _CRT_NONSTDC_NO_DEPRECATE #define _CRT_NONSTDC_NO_DEPRECATE #endif #if defined(_MSC_VER) && _MSC_VER < 1900 #define snprintf _snprintf_s #endif #ifndef S_ISREG #define S_ISREG(m) (((m)&S_IFREG) == S_IFREG) #endif #ifndef S_ISDIR #define S_ISDIR(m) (((m)&S_IFDIR) == S_IFDIR) #endif #include <io.h> #include <winsock2.h> #include <ws2tcpip.h> #undef min #undef max typedef SOCKET socket_t; #else #include <pthread.h> #include <unistd.h> #include <netdb.h> #include <cstring> #include <netinet/in.h> #include <arpa/inet.h> #include <signal.h> #include <sys/socket.h> typedef int socket_t; #endif #include <fstream> #include <functional> #include <map> #include <memory> #include <regex> #include <string> #include <thread> #include <sys/stat.h> #include <fcntl.h> #include <assert.h> #ifdef CPPHTTPLIB_OPENSSL_SUPPORT #include <openssl/ssl.h> #endif #ifdef CPPHTTPLIB_ZLIB_SUPPORT #include <zlib.h> #endif /* * Configuration */ #define CPPHTTPLIB_KEEPALIVE_MAX_COUNT 5 #define CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND 5 #define CPPHTTPLIB_KEEPALIVE_TIMEOUT_USECOND 0 namespace httplib { namespace detail { struct ci { bool operator()(const std::string& s1, const std::string& s2) const { return std::lexicographical_compare( s1.begin(), s1.end(), s2.begin(), s2.end(), [](char c1, char c2) { return ::tolower(c1) < ::tolower(c2); }); } }; } // namespace detail enum class HttpVersion { v1_0 = 0, v1_1 }; typedef std::multimap<std::string, std::string, detail::ci> Headers; template <typename uint64_t, typename... Args> std::pair<std::string, std::string> make_range_header(uint64_t value, Args... args); typedef std::multimap<std::string, std::string> Params; typedef std::smatch Match; typedef std::function<void(uint64_t current, uint64_t total)> Progress; struct MultipartFile { std::string filename; std::string content_type; size_t offset = 0; size_t length = 0; }; typedef std::multimap<std::string, MultipartFile> MultipartFiles; struct Request { std::string version; std::string method; std::string path; Headers headers; std::string body; Params params; MultipartFiles files; Match matches; Progress progress; bool has_header(const char* key) const; std::string get_header_value(const char* key) const; void set_header(const char* key, const char* val); bool has_param(const char* key) const; std::string get_param_value(const char* key) const; bool has_file(const char* key) const; MultipartFile get_file_value(const char* key) const; }; struct Response { std::string version; int status; Headers headers; std::string body; bool has_header(const char* key) const; std::string get_header_value(const char* key) const; void set_header(const char* key, const char* val); void set_redirect(const char* url); void set_content(const char* s, size_t n, const char* content_type); void set_content(const std::string& s, const char* content_type); Response() : status(-1) { } }; class Stream { public: virtual ~Stream() { } virtual int read(char* ptr, size_t size) = 0; virtual int write(const char* ptr, size_t size1) = 0; virtual int write(const char* ptr) = 0; template <typename... Args> void write_format(const char* fmt, const Args&... args); }; class SocketStream : public Stream { public: SocketStream(socket_t sock); virtual ~SocketStream(); virtual int read(char* ptr, size_t size); virtual int write(const char* ptr, size_t size); virtual int write(const char* ptr); private: socket_t sock_; }; class Server { public: typedef std::function<void(const Request&, Response&)> Handler; typedef std::function<void(const Request&, const Response&)> Logger; Server(HttpVersion http_version = HttpVersion::v1_0); virtual ~Server(); virtual bool is_valid() const; Server& get(const char* pattern, Handler handler); Server& post(const char* pattern, Handler handler); bool set_base_dir(const char* path); void set_error_handler(Handler handler); void set_logger(Logger logger); bool listen(const char* host, int port, int socket_flags = 0); bool is_running() const; void stop(); protected: bool process_request(Stream& strm, bool last_connection); const HttpVersion http_version_; private: typedef std::vector<std::pair<std::regex, Handler>> Handlers; socket_t create_server_socket(const char* host, int port, int socket_flags) const; bool routing(Request& req, Response& res); bool handle_file_request(Request& req, Response& res); bool dispatch_request(Request& req, Response& res, Handlers& handlers); bool parse_request_line(const char* s, Request& req); void write_response(Stream& strm, bool last_connection, const Request& req, Response& res); virtual bool read_and_close_socket(socket_t sock); socket_t svr_sock_; std::string base_dir_; Handlers get_handlers_; Handlers post_handlers_; Handler error_handler_; Logger logger_; }; class Client { public: Client(const char* host, int port = 80, size_t timeout_sec = 300, HttpVersion http_version = HttpVersion::v1_0); virtual ~Client(); virtual bool is_valid() const; std::shared_ptr<Response> get(const char* path, Progress progress = nullptr); std::shared_ptr<Response> get(const char* path, const Headers& headers, Progress progress = nullptr); std::shared_ptr<Response> head(const char* path); std::shared_ptr<Response> head(const char* path, const Headers& headers); std::shared_ptr<Response> post(const char* path, const std::string& body, const char* content_type); std::shared_ptr<Response> post(const char* path, const Headers& headers, const std::string& body, const char* content_type); std::shared_ptr<Response> post(const char* path, const Params& params); std::shared_ptr<Response> post(const char* path, const Headers& headers, const Params& params); bool send(Request& req, Response& res); protected: bool process_request(Stream& strm, Request& req, Response& res); const std::string host_; const int port_; size_t timeout_sec_; const HttpVersion http_version_; const std::string host_and_port_; private: socket_t create_client_socket() const; bool read_response_line(Stream& strm, Response& res); void write_request(Stream& strm, Request& req); virtual bool read_and_close_socket(socket_t sock, Request& req, Response& res); }; #ifdef CPPHTTPLIB_OPENSSL_SUPPORT class SSLSocketStream : public Stream { public: SSLSocketStream(SSL* ssl); virtual ~SSLSocketStream(); virtual int read(char* ptr, size_t size); virtual int write(const char* ptr, size_t size); virtual int write(const char* ptr); private: SSL* ssl_; }; class SSLServer : public Server { public: SSLServer(const char* cert_path, const char* private_key_path, HttpVersion http_version = HttpVersion::v1_0); virtual ~SSLServer(); virtual bool is_valid() const; private: virtual bool read_and_close_socket(socket_t sock); SSL_CTX* ctx_; }; class SSLClient : public Client { public: SSLClient(const char* host, int port = 80, size_t timeout_sec = 300, HttpVersion http_version = HttpVersion::v1_0); virtual ~SSLClient(); virtual bool is_valid() const; private: virtual bool read_and_close_socket(socket_t sock, Request& req, Response& res); SSL_CTX* ctx_; }; #endif /* * Implementation */ namespace detail { static std::vector<const char*> http_version_strings = {"HTTP/1.0", "HTTP/1.1"}; template <class Fn> void split(const char* b, const char* e, char d, Fn fn) { int i = 0; int beg = 0; while (e ? (b + i != e) : (b[i] != '\0')) { if (b[i] == d) { fn(&b[beg], &b[i]); beg = i + 1; } i++; } if (i) { fn(&b[beg], &b[i]); } } // NOTE: until the read size reaches `fixed_buffer_size`, use `fixed_buffer` // to store data. The call can set memory on stack for performance. class stream_line_reader { public: stream_line_reader(Stream& strm, char* fixed_buffer, size_t fixed_buffer_size) : strm_(strm) , fixed_buffer_(fixed_buffer) , fixed_buffer_size_(fixed_buffer_size) { } const char* ptr() const { if (glowable_buffer_.empty()) { return fixed_buffer_; } else { return glowable_buffer_.data(); } } bool getline() { fixed_buffer_used_size_ = 0; glowable_buffer_.clear(); for (size_t i = 0;; i++) { char byte; auto n = strm_.read(&byte, 1); if (n < 0) { return false; } else if (n == 0) { if (i == 0) { return false; } else { break; } } append(byte); if (byte == '\n') { break; } } return true; } private: void append(char c) { if (fixed_buffer_used_size_ < fixed_buffer_size_ - 1) { fixed_buffer_[fixed_buffer_used_size_++] = c; fixed_buffer_[fixed_buffer_used_size_] = '\0'; } else { if (glowable_buffer_.empty()) { assert(fixed_buffer_[fixed_buffer_used_size_] == '\0'); glowable_buffer_.assign(fixed_buffer_, fixed_buffer_used_size_); } glowable_buffer_ += c; } } Stream& strm_; char* fixed_buffer_; const size_t fixed_buffer_size_; size_t fixed_buffer_used_size_; std::string glowable_buffer_; }; inline int close_socket(socket_t sock) { #ifdef _WIN32 return closesocket(sock); #else return close(sock); #endif } inline int select_read(socket_t sock, size_t sec, size_t usec) { fd_set fds; FD_ZERO(&fds); FD_SET(sock, &fds); timeval tv; tv.tv_sec = sec; tv.tv_usec = usec; return select(sock + 1, &fds, NULL, NULL, &tv); } inline bool is_socket_writable(socket_t sock, size_t sec, size_t usec) { fd_set fdsw; FD_ZERO(&fdsw); FD_SET(sock, &fdsw); fd_set fdse; FD_ZERO(&fdse); FD_SET(sock, &fdse); timeval tv; tv.tv_sec = sec; tv.tv_usec = usec; if (select(sock + 1, NULL, &fdsw, &fdse, &tv) <= 0) { return false; } return FD_ISSET(sock, &fdsw) != 0; } template <typename T> inline bool read_and_close_socket(socket_t sock, bool keep_alive, T callback) { bool ret = false; if (keep_alive) { auto count = CPPHTTPLIB_KEEPALIVE_MAX_COUNT; while (count > 0 && detail::select_read(sock, CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND, CPPHTTPLIB_KEEPALIVE_TIMEOUT_USECOND) > 0) { auto last_connection = count == 1; SocketStream strm(sock); ret = callback(strm, last_connection); if (!ret) { break; } count--; } } else { SocketStream strm(sock); ret = callback(strm, true); } close_socket(sock); return ret; } inline int shutdown_socket(socket_t sock) { #ifdef _WIN32 return shutdown(sock, SD_BOTH); #else return shutdown(sock, SHUT_RDWR); #endif } template <typename Fn> socket_t create_socket(const char* host, int port, Fn fn, int socket_flags = 0) { #ifdef _WIN32 #define SO_SYNCHRONOUS_NONALERT 0x20 #define SO_OPENTYPE 0x7008 int opt = SO_SYNCHRONOUS_NONALERT; setsockopt( INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char*)&opt, sizeof(opt)); #endif // Get address info struct addrinfo hints; struct addrinfo* result; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = socket_flags; hints.ai_protocol = 0; auto service = std::to_string(port); if (getaddrinfo(host, service.c_str(), &hints, &result)) { return -1; } for (auto rp = result; rp; rp = rp->ai_next) { // Create a socket auto sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sock == -1) { continue; } // Make 'reuse address' option available int yes = 1; setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof(yes)); // bind or connect if (fn(sock, *rp)) { freeaddrinfo(result); return sock; } close_socket(sock); } freeaddrinfo(result); return -1; } inline void set_nonblocking(socket_t sock, bool nonblocking) { #ifdef _WIN32 auto flags = nonblocking ? 1UL : 0UL; ioctlsocket(sock, FIONBIO, &flags); #else auto flags = fcntl(sock, F_GETFL, 0); fcntl(sock, F_SETFL, nonblocking ? (flags | O_NONBLOCK) : (flags & (~O_NONBLOCK))); #endif } inline bool is_connection_error() { #ifdef _WIN32 return WSAGetLastError() != WSAEWOULDBLOCK; #else return errno != EINPROGRESS; #endif } inline bool is_file(const std::string& path) { struct stat st; return stat(path.c_str(), &st) >= 0 && S_ISREG(st.st_mode); } inline bool is_dir(const std::string& path) { struct stat st; return stat(path.c_str(), &st) >= 0 && S_ISDIR(st.st_mode); } inline bool is_valid_path(const std::string& path) { size_t level = 0; size_t i = 0; // Skip slash while (i < path.size() && path[i] == '/') { i++; } while (i < path.size()) { // Read component auto beg = i; while (i < path.size() && path[i] != '/') { i++; } auto len = i - beg; assert(len > 0); if (!path.compare(beg, len, ".")) { ; } else if (!path.compare(beg, len, "..")) { if (level == 0) { return false; } level--; } else { level++; } // Skip slash while (i < path.size() && path[i] == '/') { i++; } } return true; } inline void read_file(const std::string& path, std::string& out) { std::ifstream fs(path, std::ios_base::binary); fs.seekg(0, std::ios_base::end); auto size = fs.tellg(); fs.seekg(0); out.resize(static_cast<size_t>(size)); fs.read(&out[0], size); } inline std::string file_extension(const std::string& path) { std::smatch m; auto pat = std::regex("\\.([a-zA-Z0-9]+)$"); if (std::regex_search(path, m, pat)) { return m[1].str(); } return std::string(); } inline const char* find_content_type(const std::string& path) { auto ext = file_extension(path); if (ext == "txt") { return "text/plain"; } else if (ext == "html") { return "text/html"; } else if (ext == "css") { return "text/css"; } else if (ext == "jpeg" || ext == "jpg") { return "image/jpg"; } else if (ext == "png") { return "image/png"; } else if (ext == "gif") { return "image/gif"; } else if (ext == "svg") { return "image/svg+xml"; } else if (ext == "ico") { return "image/x-icon"; } else if (ext == "json") { return "application/json"; } else if (ext == "pdf") { return "application/pdf"; } else if (ext == "js") { return "application/javascript"; } else if (ext == "xml") { return "application/xml"; } else if (ext == "xhtml") { return "application/xhtml+xml"; } return nullptr; } inline const char* status_message(int status) { switch (status) { case 200: return "OK"; case 400: return "Bad Request"; case 404: return "Not Found"; default: case 500: return "Internal Server Error"; } } inline const char* get_header_value(const Headers& headers, const char* key, const char* def) { auto it = headers.find(key); if (it != headers.end()) { return it->second.c_str(); } return def; } inline int get_header_value_int(const Headers& headers, const char* key, int def) { auto it = headers.find(key); if (it != headers.end()) { return std::stoi(it->second); } return def; } inline bool read_headers(Stream& strm, Headers& headers) { static std::regex re(R"((.+?):\s*(.+?)\s*\r\n)"); const auto bufsiz = 2048; char buf[bufsiz]; stream_line_reader reader(strm, buf, bufsiz); for (;;) { if (!reader.getline()) { return false; } if (!strcmp(reader.ptr(), "\r\n")) { break; } std::cmatch m; if (std::regex_match(reader.ptr(), m, re)) { auto key = std::string(m[1]); auto val = std::string(m[2]); headers.emplace(key, val); } } return true; } template <typename T> bool read_content_with_length(Stream& strm, T& x, size_t len, Progress progress) { x.body.assign(len, 0); size_t r = 0; while (r < len) { auto n = strm.read(&x.body[r], len - r); if (n <= 0) { return false; } r += n; if (progress) { progress(r, len); } } return true; } template <typename T> bool read_content_without_length(Stream& strm, T& x) { for (;;) { char byte; auto n = strm.read(&byte, 1); if (n < 0) { return false; } else if (n == 0) { return true; } x.body += byte; } return true; } template <typename T> bool read_content_chunked(Stream& strm, T& x) { const auto bufsiz = 16; char buf[bufsiz]; stream_line_reader reader(strm, buf, bufsiz); if (!reader.getline()) { return false; } auto chunk_len = std::stoi(reader.ptr(), 0, 16); while (chunk_len > 0) { std::string chunk(chunk_len, 0); auto n = strm.read(&chunk[0], chunk_len); if (n <= 0) { return false; } if (!reader.getline()) { return false; } if (strcmp(reader.ptr(), "\r\n")) { break; } x.body += chunk; if (!reader.getline()) { return false; } chunk_len = std::stoi(reader.ptr(), 0, 16); } return true; } template <typename T> bool read_content(Stream& strm, T& x, Progress progress = Progress()) { auto len = get_header_value_int(x.headers, "Content-Length", 0); if (len) { return read_content_with_length(strm, x, len, progress); } else { const auto& encoding = get_header_value( x.headers, "Transfer-Encoding", ""); if (!strcmp(encoding, "chunked")) { return read_content_chunked(strm, x); } else { return read_content_without_length(strm, x); } } return true; } template <typename T> inline void write_headers(Stream& strm, const T& info) { for (const auto& x : info.headers) { strm.write_format("%s: %s\r\n", x.first.c_str(), x.second.c_str()); } strm.write("\r\n"); } inline std::string encode_url(const std::string& s) { std::string result; for (auto i = 0; s[i]; i++) { switch (s[i]) { case ' ': result += "+"; break; case '\'': result += "%27"; break; case ',': result += "%2C"; break; case ':': result += "%3A"; break; case ';': result += "%3B"; break; default: if (s[i] < 0) { result += '%'; char hex[4]; size_t len = snprintf( hex, sizeof(hex) - 1, "%02X", (unsigned char)s[i]); assert(len == 2); result.append(hex, len); } else { result += s[i]; } break; } } return result; } inline bool is_hex(char c, int& v) { if (0x20 <= c && isdigit(c)) { v = c - '0'; return true; } else if ('A' <= c && c <= 'F') { v = c - 'A' + 10; return true; } else if ('a' <= c && c <= 'f') { v = c - 'a' + 10; return true; } return false; } inline bool from_hex_to_i(const std::string& s, int i, int cnt, int& val) { val = 0; for (; cnt; i++, cnt--) { if (!s[i]) { return false; } int v = 0; if (is_hex(s[i], v)) { val = val * 16 + v; } else { return false; } } return true; } inline size_t to_utf8(int code, char* buff) { if (code < 0x0080) { buff[0] = (code & 0x7F); return 1; } else if (code < 0x0800) { buff[0] = (0xC0 | ((code >> 6) & 0x1F)); buff[1] = (0x80 | (code & 0x3F)); return 2; } else if (code < 0xD800) { buff[0] = (0xE0 | ((code >> 12) & 0xF)); buff[1] = (0x80 | ((code >> 6) & 0x3F)); buff[2] = (0x80 | (code & 0x3F)); return 3; } else if (code < 0xE000) { // D800 - DFFF is invalid... return 0; } else if (code < 0x10000) { buff[0] = (0xE0 | ((code >> 12) & 0xF)); buff[1] = (0x80 | ((code >> 6) & 0x3F)); buff[2] = (0x80 | (code & 0x3F)); return 3; } else if (code < 0x110000) { buff[0] = (0xF0 | ((code >> 18) & 0x7)); buff[1] = (0x80 | ((code >> 12) & 0x3F)); buff[2] = (0x80 | ((code >> 6) & 0x3F)); buff[3] = (0x80 | (code & 0x3F)); return 4; } // NOTREACHED return 0; } inline std::string decode_url(const std::string& s) { std::string result; for (int i = 0; s[i]; i++) { if (s[i] == '%') { if (s[i + 1] && s[i + 1] == 'u') { int val = 0; if (from_hex_to_i(s, i + 2, 4, val)) { // 4 digits Unicode codes char buff[4]; size_t len = to_utf8(val, buff); if (len > 0) { result.append(buff, len); } i += 5; // 'u0000' } else { result += s[i]; } } else { int val = 0; if (from_hex_to_i(s, i + 1, 2, val)) { // 2 digits hex codes result += val; i += 2; // '00' } else { result += s[i]; } } } else if (s[i] == '+') { result += ' '; } else { result += s[i]; } } return result; } inline void parse_query_text(const std::string& s, Params& params) { split(&s[0], &s[s.size()], '&', [&](const char* b, const char* e) { std::string key; std::string val; split(b, e, '=', [&](const char* b, const char* e) { if (key.empty()) { key.assign(b, e); } else { val.assign(b, e); } }); params.emplace(key, decode_url(val)); }); } inline bool parse_multipart_boundary(const std::string& content_type, std::string& boundary) { auto pos = content_type.find("boundary="); if (pos == std::string::npos) { return false; } boundary = content_type.substr(pos + 9); return true; } inline bool parse_multipart_formdata(const std::string& boundary, const std::string& body, MultipartFiles& files) { static std::string dash = "--"; static std::string crlf = "\r\n"; static std::regex re_content_type("Content-Type: (.*?)"); static std::regex re_content_disposition("Content-Disposition: form-data; " "name=\"(.*?)\"(?:; " "filename=\"(.*?)\")?"); auto dash_boundary = dash + boundary; auto pos = body.find(dash_boundary); if (pos != 0) { return false; } pos += dash_boundary.size(); auto next_pos = body.find(crlf, pos); if (next_pos == std::string::npos) { return false; } pos = next_pos + crlf.size(); while (pos < body.size()) { next_pos = body.find(crlf, pos); if (next_pos == std::string::npos) { return false; } std::string name; MultipartFile file; auto header = body.substr(pos, (next_pos - pos)); while (pos != next_pos) { std::smatch m; if (std::regex_match(header, m, re_content_type)) { file.content_type = m[1]; } else if (std::regex_match(header, m, re_content_disposition)) { name = m[1]; file.filename = m[2]; } pos = next_pos + crlf.size(); next_pos = body.find(crlf, pos); if (next_pos == std::string::npos) { return false; } header = body.substr(pos, (next_pos - pos)); } pos = next_pos + crlf.size(); next_pos = body.find(crlf + dash_boundary, pos); if (next_pos == std::string::npos) { return false; } file.offset = pos; file.length = next_pos - pos; pos = next_pos + crlf.size() + dash_boundary.size(); next_pos = body.find(crlf, pos); if (next_pos == std::string::npos) { return false; } files.emplace(name, file); pos = next_pos + crlf.size(); } return true; } inline std::string to_lower(const char* beg, const char* end) { std::string out; auto it = beg; while (it != end) { out += ::tolower(*it); it++; } return out; } inline void make_range_header_core(std::string&) { } template <typename uint64_t> inline void make_range_header_core(std::string& field, uint64_t value) { if (!field.empty()) { field += ", "; } field += std::to_string(value) + "-"; } template <typename uint64_t, typename... Args> inline void make_range_header_core(std::string& field, uint64_t value1, uint64_t value2, Args... args) { if (!field.empty()) { field += ", "; } field += std::to_string(value1) + "-" + std::to_string(value2); make_range_header_core(field, args...); } #ifdef CPPHTTPLIB_ZLIB_SUPPORT inline bool can_compress(const std::string& content_type) { return !content_type.find("text/") || content_type == "image/svg+xml" || content_type == "application/javascript" || content_type == "application/json" || content_type == "application/xml" || content_type == "application/xhtml+xml"; } inline void compress(const Request& req, Response& res) { // TODO: Server version is HTTP/1.1 and 'Accpet-Encoding' has gzip, not // gzip;q=0 const auto& encodings = req.get_header_value("Accept-Encoding"); if (encodings.find("gzip") == std::string::npos) { return; } if (!can_compress(res.get_header_value("Content-Type"))) { return; } z_stream strm; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; auto ret = deflateInit2( &strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY); if (ret != Z_OK) { return; } strm.avail_in = res.body.size(); strm.next_in = (Bytef*)res.body.data(); std::string compressed; const auto bufsiz = 16384; char buff[bufsiz]; do { strm.avail_out = bufsiz; strm.next_out = (Bytef*)buff; deflate(&strm, Z_FINISH); compressed.append(buff, bufsiz - strm.avail_out); } while (strm.avail_out == 0); res.set_header("Content-Encoding", "gzip"); res.body.swap(compressed); deflateEnd(&strm); } #endif #ifdef _WIN32 class WSInit { public: WSInit() { WSADATA wsaData; WSAStartup(0x0002, &wsaData); } ~WSInit() { WSACleanup(); } }; static WSInit wsinit_; #endif } // namespace detail // Header utilities template <typename uint64_t, typename... Args> inline std::pair<std::string, std::string> make_range_header(uint64_t value, Args... args) { std::string field; detail::make_range_header_core(field, value, args...); field.insert(0, "bytes="); return std::make_pair("Range", field); } // Request implementation inline bool Request::has_header(const char* key) const { return headers.find(key) != headers.end(); } inline std::string Request::get_header_value(const char* key) const { return detail::get_header_value(headers, key, ""); } inline void Request::set_header(const char* key, const char* val) { headers.emplace(key, val); } inline bool Request::has_param(const char* key) const { return params.find(key) != params.end(); } inline std::string Request::get_param_value(const char* key) const { auto it = params.find(key); if (it != params.end()) { return it->second; } return std::string(); } inline bool Request::has_file(const char* key) const { return files.find(key) != files.end(); } inline MultipartFile Request::get_file_value(const char* key) const { auto it = files.find(key); if (it != files.end()) { return it->second; } return MultipartFile(); } // Response implementation inline bool Response::has_header(const char* key) const { return headers.find(key) != headers.end(); } inline std::string Response::get_header_value(const char* key) const { return detail::get_header_value(headers, key, ""); } inline void Response::set_header(const char* key, const char* val) { headers.emplace(key, val); } inline void Response::set_redirect(const char* url) { set_header("Location", url); status = 302; } inline void Response::set_content(const char* s, size_t n, const char* content_type) { body.assign(s, n); set_header("Content-Type", content_type); } inline void Response::set_content(const std::string& s, const char* content_type) { body = s; set_header("Content-Type", content_type); } // Rstream implementation template <typename... Args> inline void Stream::write_format(const char* fmt, const Args&... args) { const auto bufsiz = 2048; char buf[bufsiz]; #if defined(_MSC_VER) && _MSC_VER < 1900 auto n = _snprintf_s(buf, bufsiz, bufsiz - 1, fmt, args...); #else auto n = snprintf(buf, bufsiz - 1, fmt, args...); #endif if (n > 0) { if (n >= bufsiz - 1) { std::vector<char> glowable_buf(bufsiz); while (n >= static_cast<int>(glowable_buf.size() - 1)) { glowable_buf.resize(glowable_buf.size() * 2); #if defined(_MSC_VER) && _MSC_VER < 1900 n = _snprintf_s(&glowable_buf[0], glowable_buf.size(), glowable_buf.size() - 1, fmt, args...); #else n = snprintf( &glowable_buf[0], glowable_buf.size() - 1, fmt, args...); #endif } write(&glowable_buf[0], n); } else { write(buf, n); } } } // Socket stream implementation inline SocketStream::SocketStream(socket_t sock) : sock_(sock) { } inline SocketStream::~SocketStream() { } inline int SocketStream::read(char* ptr, size_t size) { return recv(sock_, ptr, size, 0); } inline int SocketStream::write(const char* ptr, size_t size) { return send(sock_, ptr, size, 0); } inline int SocketStream::write(const char* ptr) { return write(ptr, strlen(ptr)); } // HTTP server implementation inline Server::Server(HttpVersion http_version) : http_version_(http_version) , svr_sock_(-1) { #ifndef _WIN32 signal(SIGPIPE, SIG_IGN); #endif } inline Server::~Server() { } inline Server& Server::get(const char* pattern, Handler handler) { get_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); return *this; } inline Server& Server::post(const char* pattern, Handler handler) { post_handlers_.push_back(std::make_pair(std::regex(pattern), handler)); return *this; } inline bool Server::set_base_dir(const char* path) { if (detail::is_dir(path)) { base_dir_ = path; return true; } return false; } inline void Server::set_error_handler(Handler handler) { error_handler_ = handler; } inline void Server::set_logger(Logger logger) { logger_ = logger; } inline bool Server::listen(const char* host, int port, int socket_flags) { if (!is_valid()) { return false; } svr_sock_ = create_server_socket(host, port, socket_flags); if (svr_sock_ == -1) { return false; } auto ret = true; for (;;) { auto val = detail::select_read(svr_sock_, 0, 100000); if (val == 0) { // Timeout if (svr_sock_ == -1) { // The server socket was closed by 'stop' method. break; } continue; } socket_t sock = accept(svr_sock_, NULL, NULL); if (sock == -1) { if (svr_sock_ != -1) { detail::close_socket(svr_sock_); ret = false; } else { ; // The server socket was closed by user. } break; } // TODO: Use thread pool... std::thread([=]() { read_and_close_socket(sock); }).detach(); } return ret; } inline bool Server::is_running() const { return svr_sock_ != -1; } inline void Server::stop() { detail::shutdown_socket(svr_sock_); detail::close_socket(svr_sock_); svr_sock_ = -1; } inline bool Server::parse_request_line(const char* s, Request& req) { static std::regex re("(GET|HEAD|POST) ([^?]+)(?:\\?(.+?))? " "(HTTP/1\\.[01])\r\n"); std::cmatch m; if (std::regex_match(s, m, re)) { req.version = std::string(m[4]); req.method = std::string(m[1]); req.path = detail::decode_url(m[2]); // Parse query text auto len = std::distance(m[3].first, m[3].second); if (len > 0) { detail::parse_query_text(m[3], req.params); } return true; } return false; } inline void Server::write_response(Stream& strm, bool last_connection, const Request& req, Response& res) { assert(res.status != -1); if (400 <= res.status && error_handler_) { error_handler_(req, res); } // Response line strm.write_format( "%s %d %s\r\n", detail::http_version_strings[static_cast<size_t>(http_version_)], res.status, detail::status_message(res.status)); // Headers if (!res.has_header("Connection") && (last_connection || req.version == "HTTP/1.0")) { res.set_header("Connection", "close"); } if (!res.body.empty()) { #ifdef CPPHTTPLIB_ZLIB_SUPPORT detail::compress(req, res); #endif if (!res.has_header("Content-Type")) { res.set_header("Content-Type", "text/plain"); } auto length = std::to_string(res.body.size()); res.set_header("Content-Length", length.c_str()); } detail::write_headers(strm, res); // Body if (!res.body.empty() && req.method != "HEAD") { strm.write(res.body.c_str(), res.body.size()); } // Log if (logger_) { logger_(req, res); } } inline bool Server::handle_file_request(Request& req, Response& res) { if (!base_dir_.empty() && detail::is_valid_path(req.path)) { std::string path = base_dir_ + req.path; if (!path.empty() && path.back() == '/') { path += "index.html"; } if (detail::is_file(path)) { detail::read_file(path, res.body); auto type = detail::find_content_type(path); if (type) { res.set_header("Content-Type", type); } res.status = 200; return true; } } return false; } inline socket_t Server::create_server_socket(const char* host, int port, int socket_flags) const { return detail::create_socket( host, port, [](socket_t sock, struct addrinfo& ai) -> bool { if (::bind(sock, ai.ai_addr, ai.ai_addrlen)) { return false; } if (::listen(sock, 5)) { // Listen through 5 channels return false; } return true; }, socket_flags); } inline bool Server::routing(Request& req, Response& res) { if (req.method == "GET" && handle_file_request(req, res)) { return true; } if (req.method == "GET" || req.method == "HEAD") { return dispatch_request(req, res, get_handlers_); } else if (req.method == "POST") { return dispatch_request(req, res, post_handlers_); } return false; } inline bool Server::dispatch_request(Request& req, Response& res, Handlers& handlers) { for (const auto& x : handlers) { const auto& pattern = x.first; const auto& handler = x.second; if (std::regex_match(req.path, req.matches, pattern)) { handler(req, res); return true; } } return false; } inline bool Server::process_request(Stream& strm, bool last_connection) { const auto bufsiz = 2048; char buf[bufsiz]; detail::stream_line_reader reader(strm, buf, bufsiz); // Connection has been closed on client if (!reader.getline()) { return false; } Request req; Response res; res.version = detail::http_version_strings[static_cast<size_t>( http_version_)]; // Request line and headers if (!parse_request_line(reader.ptr(), req) || !detail::read_headers(strm, req.headers)) { res.status = 400; write_response(strm, last_connection, req, res); return true; } auto ret = true; if (req.get_header_value("Connection") == "close") { ret = false; } // Body if (req.method == "POST") { if (!detail::read_content(strm, req)) { res.status = 400; write_response(strm, last_connection, req, res); return ret; } const auto& content_type = req.get_header_value("Content-Type"); if (!content_type.find("application/x-www-form-urlencoded")) { detail::parse_query_text(req.body, req.params); } else if (!content_type.find("multipart/form-data")) { std::string boundary; if (!detail::parse_multipart_boundary(content_type, boundary) || !detail::parse_multipart_formdata( boundary, req.body, req.files)) { res.status = 400; write_response(strm, last_connection, req, res); return ret; } } } if (routing(req, res)) { if (res.status == -1) { res.status = 200; } } else { res.status = 404; } write_response(strm, last_connection, req, res); return ret; } inline bool Server::is_valid() const { return true; } inline bool Server::read_and_close_socket(socket_t sock) { auto keep_alive = http_version_ == HttpVersion::v1_1; return detail::read_and_close_socket( sock, keep_alive, [this](Stream& strm, bool last_connection) { return process_request(strm, last_connection); }); } // HTTP client implementation inline Client::Client(const char* host, int port, size_t timeout_sec, HttpVersion http_version) : host_(host) , port_(port) , timeout_sec_(timeout_sec) , http_version_(http_version) , host_and_port_(host_ + ":" + std::to_string(port_)) { } inline Client::~Client() { } inline bool Client::is_valid() const { return true; } inline socket_t Client::create_client_socket() const { return detail::create_socket( host_.c_str(), port_, [=](socket_t sock, struct addrinfo& ai) -> bool { detail::set_nonblocking(sock, true); auto ret = connect(sock, ai.ai_addr, ai.ai_addrlen); if (ret == -1 && detail::is_connection_error()) { return false; } detail::set_nonblocking(sock, false); return detail::is_socket_writable(sock, timeout_sec_, 0); }); } inline bool Client::read_response_line(Stream& strm, Response& res) { const auto bufsiz = 2048; char buf[bufsiz]; detail::stream_line_reader reader(strm, buf, bufsiz); if (!reader.getline()) { return false; } const static std::regex re("HTTP/1\\.[01] (\\d+?) .+\r\n"); std::cmatch m; if (std::regex_match(reader.ptr(), m, re)) { res.status = std::stoi(std::string(m[1])); } return true; } inline bool Client::send(Request& req, Response& res) { if (req.path.empty()) { return false; } auto sock = create_client_socket(); if (sock == -1) { return false; } return read_and_close_socket(sock, req, res); } inline void Client::write_request(Stream& strm, Request& req) { auto path = detail::encode_url(req.path); // Request line strm.write_format( "%s %s %s\r\n", req.method.c_str(), path.c_str(), detail::http_version_strings[static_cast<size_t>(http_version_)]); // Headers req.set_header("Host", host_and_port_.c_str()); if (!req.has_header("Accept")) { req.set_header("Accept", "*/*"); } if (!req.has_header("User-Agent")) { req.set_header("User-Agent", "cpp-httplib/0.2"); } // TODO: if (!req.has_header("Connection") && // (last_connection || http_version_ == // detail::HttpVersion::v1_0)) { if (!req.has_header("Connection")) { req.set_header("Connection", "close"); } if (!req.body.empty()) { if (!req.has_header("Content-Type")) { req.set_header("Content-Type", "text/plain"); } auto length = std::to_string(req.body.size()); req.set_header("Content-Length", length.c_str()); } detail::write_headers(strm, req); // Body if (!req.body.empty()) { if (req.get_header_value("Content-Type") == "application/x-www-form-urlencoded") { auto str = detail::encode_url(req.body); strm.write(str.c_str(), str.size()); } else { strm.write(req.body.c_str(), req.body.size()); } } } inline bool Client::process_request(Stream& strm, Request& req, Response& res) { // Send request write_request(strm, req); // Receive response and headers if (!read_response_line(strm, res) || !detail::read_headers(strm, res.headers)) { return false; } // TODO: Check if 'Connection' header is 'close' or HTTP version is 1.0, // then close socket... // Body if (req.method != "HEAD") { if (!detail::read_content(strm, res, req.progress)) { return false; } } return true; } inline bool Client::read_and_close_socket(socket_t sock, Request& req, Response& res) { return detail::read_and_close_socket( sock, false, [&](Stream& strm, bool /*last_connection*/) { return process_request(strm, req, res); }); } inline std::shared_ptr<Response> Client::get(const char* path, Progress progress) { return get(path, Headers(), progress); } inline std::shared_ptr<Response> Client::get(const char* path, const Headers& headers, Progress progress) { Request req; req.method = "GET"; req.path = path; req.headers = headers; req.progress = progress; auto res = std::make_shared<Response>(); return send(req, *res) ? res : nullptr; } inline std::shared_ptr<Response> Client::head(const char* path) { return head(path, Headers()); } inline std::shared_ptr<Response> Client::head(const char* path, const Headers& headers) { Request req; req.method = "HEAD"; req.headers = headers; req.path = path; auto res = std::make_shared<Response>(); return send(req, *res) ? res : nullptr; } inline std::shared_ptr<Response> Client::post(const char* path, const std::string& body, const char* content_type) { return post(path, Headers(), body, content_type); } inline std::shared_ptr<Response> Client::post(const char* path, const Headers& headers, const std::string& body, const char* content_type) { Request req; req.method = "POST"; req.headers = headers; req.path = path; req.headers.emplace("Content-Type", content_type); req.body = body; auto res = std::make_shared<Response>(); return send(req, *res) ? res : nullptr; } inline std::shared_ptr<Response> Client::post(const char* path, const Params& params) { return post(path, Headers(), params); } inline std::shared_ptr<Response> Client::post(const char* path, const Headers& headers, const Params& params) { std::string query; for (auto it = params.begin(); it != params.end(); ++it) { if (it != params.begin()) { query += "&"; } query += it->first; query += "="; query += it->second; } return post(path, headers, query, "application/x-www-form-urlencoded"); } /* * SSL Implementation */ #ifdef CPPHTTPLIB_OPENSSL_SUPPORT namespace detail { template <typename U, typename V, typename T> inline bool read_and_close_socket_ssl(socket_t sock, bool keep_alive, SSL_CTX* ctx, U SSL_connect_or_accept, V setup, T callback) { auto ssl = SSL_new(ctx); if (!ssl) { return false; } auto bio = BIO_new_socket(sock, BIO_NOCLOSE); SSL_set_bio(ssl, bio, bio); setup(ssl); SSL_connect_or_accept(ssl); bool ret = false; if (keep_alive) { auto count = CPPHTTPLIB_KEEPALIVE_MAX_COUNT; while (count > 0 && detail::select_read(sock, CPPHTTPLIB_KEEPALIVE_TIMEOUT_SECOND, CPPHTTPLIB_KEEPALIVE_TIMEOUT_USECOND) > 0) { auto last_connection = count == 1; SSLSocketStream strm(ssl); ret = callback(strm, last_connection); if (!ret) { break; } count--; } } else { SSLSocketStream strm(ssl); ret = callback(strm, true); } SSL_shutdown(ssl); SSL_free(ssl); close_socket(sock); return ret; } class SSLInit { public: SSLInit() { SSL_load_error_strings(); SSL_library_init(); } }; static SSLInit sslinit_; } // namespace detail // SSL socket stream implementation inline SSLSocketStream::SSLSocketStream(SSL* ssl) : ssl_(ssl) { } inline SSLSocketStream::~SSLSocketStream() { } inline int SSLSocketStream::read(char* ptr, size_t size) { return SSL_read(ssl_, ptr, size); } inline int SSLSocketStream::write(const char* ptr, size_t size) { return SSL_write(ssl_, ptr, size); } inline int SSLSocketStream::write(const char* ptr) { return write(ptr, strlen(ptr)); } // SSL HTTP server implementation inline SSLServer::SSLServer(const char* cert_path, const char* private_key_path, HttpVersion http_version) : Server(http_version) { ctx_ = SSL_CTX_new(SSLv23_server_method()); if (ctx_) { SSL_CTX_set_options( ctx_, SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION | SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION); // auto ecdh = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); // SSL_CTX_set_tmp_ecdh(ctx_, ecdh); // EC_KEY_free(ecdh); if (SSL_CTX_use_certificate_file(ctx_, cert_path, SSL_FILETYPE_PEM) != 1 || SSL_CTX_use_PrivateKey_file( ctx_, private_key_path, SSL_FILETYPE_PEM) != 1) { SSL_CTX_free(ctx_); ctx_ = nullptr; } } } inline SSLServer::~SSLServer() { if (ctx_) { SSL_CTX_free(ctx_); } } inline bool SSLServer::is_valid() const { return ctx_; } inline bool SSLServer::read_and_close_socket(socket_t sock) { auto keep_alive = http_version_ == HttpVersion::v1_1; return detail::read_and_close_socket_ssl( sock, keep_alive, ctx_, SSL_accept, [](SSL* /*ssl*/) { }, [this](Stream& strm, bool last_connection) { return process_request(strm, last_connection); }); } // SSL HTTP client implementation inline SSLClient::SSLClient(const char* host, int port, size_t timeout_sec, HttpVersion http_version) : Client(host, port, timeout_sec, http_version) { ctx_ = SSL_CTX_new(SSLv23_client_method()); } inline SSLClient::~SSLClient() { if (ctx_) { SSL_CTX_free(ctx_); } } inline bool SSLClient::is_valid() const { return ctx_; } inline bool SSLClient::read_and_close_socket(socket_t sock, Request& req, Response& res) { return is_valid() && detail::read_and_close_socket_ssl( sock, false, ctx_, SSL_connect, [&](SSL* ssl) { SSL_set_tlsext_host_name(ssl, host_.c_str()); }, [&](Stream& strm, bool /*last_connection*/) { return process_request(strm, req, res); }); } #endif } // namespace httplib #endif // vim: et ts=4 sw=4 cin cino={1s ff=unix
[ "varunamachi@gmail.com" ]
varunamachi@gmail.com
c139882a4b53118749629aa081bd564f5226d4f5
a909df0ba2abf695df4a7d15350312d4c6463c48
/AtCoder/dp_q.cpp
e2e2c2ca92ec1aa601bd79c4a9405fe81364bc3a
[]
no_license
SayaUrobuchi/uvachan
1dadd767a96bb02c7e9449c48e463847480e98ec
c213f5f3dcfc72376913a21f9abe72988a8127a1
refs/heads/master
2023-07-23T03:59:50.638063
2023-07-16T04:31:23
2023-07-16T04:31:23
94,064,326
0
0
null
null
null
null
UTF-8
C++
false
false
712
cpp
#include <iostream> #include <set> using namespace std; using pp = pair<int, long long>; using sss = set<pp>; int h[262144]; int main() { int n, i, t; long long ans; sss se; while (scanf("%d", &n) == 1) { for (i=0; i<n; i++) { scanf("%d", &h[i]); } se.clear(); for (i=0, ans=0; i<n; i++) { scanf("%d", &t); pp cur = {h[i], t}; sss::iterator it = se.lower_bound(cur); if (se.size() && it != se.begin()) { --it; cur.second += it->second; ++it; } while (it != se.end() && it->second <= cur.second) { sss::iterator tmp = it; ++it; se.erase(tmp); } se.insert(cur); ans = max(ans, cur.second); } printf("%lld\n", ans); } return 0; }
[ "sa0726866@gmail.com" ]
sa0726866@gmail.com
26fa2c3f700371b583f9a1ef58d3d82f4f1a8829
0db10f9d35a9cea4165ffbe62cf7f19cae252056
/src/matrix/kaldi-matrix.h
821bf8df817a2d7ce0d9a8bdb00c9db05de962a0
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
nichongjia/kaldi
4da4b985f8fe3b484d60d8929d4b9046f8174372
c7a2331e593da84ad43d13f902b8c6971a1f5bb1
refs/heads/master
2021-01-17T16:08:46.590348
2017-07-21T07:09:48
2017-07-21T07:09:48
72,055,985
1
0
null
2016-10-27T00:23:45
2016-10-27T00:23:45
null
UTF-8
C++
false
false
43,417
h
// matrix/kaldi-matrix.h // Copyright 2009-2011 Ondrej Glembek; Microsoft Corporation; Lukas Burget; // Saarland University; Petr Schwarz; Yanmin Qian; // Karel Vesely; Go Vivace Inc.; Haihua Xu // See ../../COPYING for clarification regarding multiple authors // // 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 // // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, // MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache 2 License for the specific language governing permissions and // limitations under the License. #ifndef KALDI_MATRIX_KALDI_MATRIX_H_ #define KALDI_MATRIX_KALDI_MATRIX_H_ 1 #include "matrix/matrix-common.h" namespace kaldi { /// @{ \addtogroup matrix_funcs_scalar /// We need to declare this here as it will be a friend function. /// tr(A B), or tr(A B^T). template<typename Real> Real TraceMatMat(const MatrixBase<Real> &A, const MatrixBase<Real> &B, MatrixTransposeType trans = kNoTrans); /// @} /// \addtogroup matrix_group /// @{ /// Base class which provides matrix operations not involving resizing /// or allocation. Classes Matrix and SubMatrix inherit from it and take care /// of allocation and resizing. template<typename Real> class MatrixBase { public: // so this child can access protected members of other instances. friend class Matrix<Real>; // friend declarations for CUDA matrices (see ../cudamatrix/) friend class CuMatrixBase<Real>; friend class CuMatrix<Real>; friend class CuSubMatrix<Real>; friend class CuPackedMatrix<Real>; friend class PackedMatrix<Real>; /// Returns number of rows (or zero for emtpy matrix). inline MatrixIndexT NumRows() const { return num_rows_; } /// Returns number of columns (or zero for emtpy matrix). inline MatrixIndexT NumCols() const { return num_cols_; } /// Stride (distance in memory between each row). Will be >= NumCols. inline MatrixIndexT Stride() const { return stride_; } /// Returns size in bytes of the data held by the matrix. size_t SizeInBytes() const { return static_cast<size_t>(num_rows_) * static_cast<size_t>(stride_) * sizeof(Real); } /// Gives pointer to raw data (const). inline const Real* Data() const { return data_; } /// Gives pointer to raw data (non-const). inline Real* Data() { return data_; } /// Returns pointer to data for one row (non-const) inline Real* RowData(MatrixIndexT i) { KALDI_ASSERT(static_cast<UnsignedMatrixIndexT>(i) < static_cast<UnsignedMatrixIndexT>(num_rows_)); return data_ + i * stride_; } /// Returns pointer to data for one row (const) inline const Real* RowData(MatrixIndexT i) const { KALDI_ASSERT(static_cast<UnsignedMatrixIndexT>(i) < static_cast<UnsignedMatrixIndexT>(num_rows_)); return data_ + i * stride_; } /// Indexing operator, non-const /// (only checks sizes if compiled with -DKALDI_PARANOID) inline Real& operator() (MatrixIndexT r, MatrixIndexT c) { KALDI_PARANOID_ASSERT(static_cast<UnsignedMatrixIndexT>(r) < static_cast<UnsignedMatrixIndexT>(num_rows_) && static_cast<UnsignedMatrixIndexT>(c) < static_cast<UnsignedMatrixIndexT>(num_cols_)); return *(data_ + r * stride_ + c); } /// Indexing operator, provided for ease of debugging (gdb doesn't work /// with parenthesis operator). Real &Index (MatrixIndexT r, MatrixIndexT c) { return (*this)(r, c); } /// Indexing operator, const /// (only checks sizes if compiled with -DKALDI_PARANOID) inline const Real operator() (MatrixIndexT r, MatrixIndexT c) const { KALDI_PARANOID_ASSERT(static_cast<UnsignedMatrixIndexT>(r) < static_cast<UnsignedMatrixIndexT>(num_rows_) && static_cast<UnsignedMatrixIndexT>(c) < static_cast<UnsignedMatrixIndexT>(num_cols_)); return *(data_ + r * stride_ + c); } /* Basic setting-to-special values functions. */ /// Sets matrix to zero. void SetZero(); /// Sets all elements to a specific value. void Set(Real); /// Sets to zero, except ones along diagonal [for non-square matrices too] void SetUnit(); /// Sets to random values of a normal distribution void SetRandn(); /// Sets to numbers uniformly distributed on (0, 1) void SetRandUniform(); /* Copying functions. These do not resize the matrix! */ /// Copy given matrix. (no resize is done). template<typename OtherReal> void CopyFromMat(const MatrixBase<OtherReal> & M, MatrixTransposeType trans = kNoTrans); /// Copy from compressed matrix. void CopyFromMat(const CompressedMatrix &M); /// Copy given spmatrix. (no resize is done). template<typename OtherReal> void CopyFromSp(const SpMatrix<OtherReal> &M); /// Copy given tpmatrix. (no resize is done). template<typename OtherReal> void CopyFromTp(const TpMatrix<OtherReal> &M, MatrixTransposeType trans = kNoTrans); /// Copy from CUDA matrix. Implemented in ../cudamatrix/cu-matrix.h template<typename OtherReal> void CopyFromMat(const CuMatrixBase<OtherReal> &M, MatrixTransposeType trans = kNoTrans); /// This function has two modes of operation. If v.Dim() == NumRows() * /// NumCols(), then treats the vector as a row-by-row concatenation of a /// matrix and copies to *this. /// if v.Dim() == NumCols(), it sets each row of *this to a copy of v. void CopyRowsFromVec(const VectorBase<Real> &v); /// This version of CopyRowsFromVec is implemented in ../cudamatrix/cu-vector.cc void CopyRowsFromVec(const CuVectorBase<Real> &v); template<typename OtherReal> void CopyRowsFromVec(const VectorBase<OtherReal> &v); /// Copies vector into matrix, column-by-column. /// Note that rv.Dim() must either equal NumRows()*NumCols() or NumRows(); /// this has two modes of operation. void CopyColsFromVec(const VectorBase<Real> &v); /// Copy vector into specific column of matrix. void CopyColFromVec(const VectorBase<Real> &v, const MatrixIndexT col); /// Copy vector into specific row of matrix. void CopyRowFromVec(const VectorBase<Real> &v, const MatrixIndexT row); /// Copy vector into diagonal of matrix. void CopyDiagFromVec(const VectorBase<Real> &v); /* Accessing of sub-parts of the matrix. */ /// Return specific row of matrix [const]. inline const SubVector<Real> Row(MatrixIndexT i) const { KALDI_ASSERT(static_cast<UnsignedMatrixIndexT>(i) < static_cast<UnsignedMatrixIndexT>(num_rows_)); return SubVector<Real>(data_ + (i * stride_), NumCols()); } /// Return specific row of matrix. inline SubVector<Real> Row(MatrixIndexT i) { KALDI_ASSERT(static_cast<UnsignedMatrixIndexT>(i) < static_cast<UnsignedMatrixIndexT>(num_rows_)); return SubVector<Real>(data_ + (i * stride_), NumCols()); } /// Return a sub-part of matrix. inline SubMatrix<Real> Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const { return SubMatrix<Real>(*this, row_offset, num_rows, col_offset, num_cols); } inline SubMatrix<Real> RowRange(const MatrixIndexT row_offset, const MatrixIndexT num_rows) const { return SubMatrix<Real>(*this, row_offset, num_rows, 0, num_cols_); } inline SubMatrix<Real> ColRange(const MatrixIndexT col_offset, const MatrixIndexT num_cols) const { return SubMatrix<Real>(*this, 0, num_rows_, col_offset, num_cols); } /* Various special functions. */ /// Returns sum of all elements in matrix. Real Sum() const; /// Returns trace of matrix. Real Trace(bool check_square = true) const; // If check_square = true, will crash if matrix is not square. /// Returns maximum element of matrix. Real Max() const; /// Returns minimum element of matrix. Real Min() const; /// Element by element multiplication with a given matrix. void MulElements(const MatrixBase<Real> &A); /// Divide each element by the corresponding element of a given matrix. void DivElements(const MatrixBase<Real> &A); /// Multiply each element with a scalar value. void Scale(Real alpha); /// Set, element-by-element, *this = max(*this, A) void Max(const MatrixBase<Real> &A); /// Equivalent to (*this) = (*this) * diag(scale). Scaling /// each column by a scalar taken from that dimension of the vector. void MulColsVec(const VectorBase<Real> &scale); /// Equivalent to (*this) = diag(scale) * (*this). Scaling /// each row by a scalar taken from that dimension of the vector. void MulRowsVec(const VectorBase<Real> &scale); /// Divide each row into src.NumCols() equal groups, and then scale i'th row's /// j'th group of elements by src(i, j). Requires src.NumRows() == /// this->NumRows() and this->NumCols() % src.NumCols() == 0. void MulRowsGroupMat(const MatrixBase<Real> &src); /// Returns logdet of matrix. Real LogDet(Real *det_sign = NULL) const; /// matrix inverse. /// if inverse_needed = false, will fill matrix with garbage. /// (only useful if logdet wanted). void Invert(Real *log_det = NULL, Real *det_sign = NULL, bool inverse_needed = true); /// matrix inverse [double]. /// if inverse_needed = false, will fill matrix with garbage /// (only useful if logdet wanted). /// Does inversion in double precision even if matrix was not double. void InvertDouble(Real *LogDet = NULL, Real *det_sign = NULL, bool inverse_needed = true); /// Inverts all the elements of the matrix void InvertElements(); /// Transpose the matrix. This one is only /// applicable to square matrices (the one in the /// Matrix child class works also for non-square. void Transpose(); /// Copies column r from column indices[r] of src. /// As a special case, if indexes[i] == -1, sets column i to zero. /// all elements of "indices" must be in [-1, src.NumCols()-1], /// and src.NumRows() must equal this.NumRows() void CopyCols(const MatrixBase<Real> &src, const MatrixIndexT *indices); /// Copies row r from row indices[r] of src (does nothing /// As a special case, if indexes[i] == -1, sets row i to zero. /// all elements of "indices" must be in [-1, src.NumRows()-1], /// and src.NumCols() must equal this.NumCols() void CopyRows(const MatrixBase<Real> &src, const MatrixIndexT *indices); /// Add column indices[r] of src to column r. /// As a special case, if indexes[i] == -1, skip column i /// indices.size() must equal this->NumCols(), /// all elements of "reorder" must be in [-1, src.NumCols()-1], /// and src.NumRows() must equal this.NumRows() void AddCols(const MatrixBase<Real> &src, const MatrixIndexT *indices); /// Copies row r of this matrix from an array of floats at the location given /// by src[r]. If any src[r] is NULL then this.Row(r) will be set to zero. /// Note: we are using "pointer to const pointer to const object" for "src", /// because we may create "src" by calling Data() of const CuArray void CopyRows(const Real *const *src); /// Copies row r of this matrix to the array of floats at the location given /// by dst[r]. If dst[r] is NULL, does not copy anywhere. Requires that none /// of the memory regions pointed to by the pointers in "dst" overlap (e.g. /// none of the pointers should be the same). void CopyToRows(Real *const *dst) const; /// Does for each row r, this.Row(r) += alpha * src.row(indexes[r]). /// If indexes[r] < 0, does not add anything. all elements of "indexes" must /// be in [-1, src.NumRows()-1], and src.NumCols() must equal this.NumCols(). void AddRows(Real alpha, const MatrixBase<Real> &src, const MatrixIndexT *indexes); /// Does for each row r, this.Row(r) += alpha * src[r], treating src[r] as the /// beginning of a region of memory representing a vector of floats, of the /// same length as this.NumCols(). If src[r] is NULL, does not add anything. void AddRows(Real alpha, const Real *const *src); /// For each row r of this matrix, adds it (times alpha) to the array of /// floats at the location given by dst[r]. If dst[r] is NULL, does not do /// anything for that row. Requires that none of the memory regions pointed /// to by the pointers in "dst" overlap (e.g. none of the pointers should be /// the same). void AddToRows(Real alpha, Real *const *dst) const; /// Applies floor to all matrix elements void ApplyFloor(Real floor_val); /// Applies floor to all matrix elements void ApplyCeiling(Real ceiling_val); /// Calculates log of all the matrix elemnts void ApplyLog(); /// Exponentiate each of the elements. void ApplyExp(); /// Applies power to all matrix elements void ApplyPow(Real power); /// Apply power to the absolute value of each element. /// Include the sign of the input element if include_sign == true. /// If the power is negative and the input to the power is zero, /// The output will be set zero. void ApplyPowAbs(Real power, bool include_sign=false); /// Applies the Heaviside step function (x > 0 ? 1 : 0) to all matrix elements /// Note: in general you can make different choices for x = 0, but for now /// please leave it as it (i.e. returning zero) because it affects the /// RectifiedLinearComponent in the neural net code. void ApplyHeaviside(); /// Eigenvalue Decomposition of a square NxN matrix into the form (*this) = P D /// P^{-1}. Be careful: the relationship of D to the eigenvalues we output is /// slightly complicated, due to the need for P to be real. In the symmetric /// case D is diagonal and real, but in /// the non-symmetric case there may be complex-conjugate pairs of eigenvalues. /// In this case, for the equation (*this) = P D P^{-1} to hold, D must actually /// be block diagonal, with 2x2 blocks corresponding to any such pairs. If a /// pair is lambda +- i*mu, D will have a corresponding 2x2 block /// [lambda, mu; -mu, lambda]. /// Note that if the input matrix (*this) is non-invertible, P may not be invertible /// so in this case instead of the equation (*this) = P D P^{-1} holding, we have /// instead (*this) P = P D. /// /// The non-member function CreateEigenvalueMatrix creates D from eigs_real and eigs_imag. void Eig(MatrixBase<Real> *P, VectorBase<Real> *eigs_real, VectorBase<Real> *eigs_imag) const; /// The Power method attempts to take the matrix to a power using a method that /// works in general for fractional and negative powers. The input matrix must /// be invertible and have reasonable condition (or we don't guarantee the /// results. The method is based on the eigenvalue decomposition. It will /// return false and leave the matrix unchanged, if at entry the matrix had /// real negative eigenvalues (or if it had zero eigenvalues and the power was /// negative). bool Power(Real pow); /** Singular value decomposition Major limitations: For nonsquare matrices, we assume m>=n (NumRows >= NumCols), and we return the "skinny" Svd, i.e. the matrix in the middle is diagonal, and the one on the left is rectangular. In Svd, *this = U*diag(S)*Vt. Null pointers for U and/or Vt at input mean we do not want that output. We expect that S.Dim() == m, U is either NULL or m by n, and v is either NULL or n by n. The singular values are not sorted (use SortSvd for that). */ void DestructiveSvd(VectorBase<Real> *s, MatrixBase<Real> *U, MatrixBase<Real> *Vt); // Destroys calling matrix. /// Compute SVD (*this) = U diag(s) Vt. Note that the V in the call is already /// transposed; the normal formulation is U diag(s) V^T. /// Null pointers for U or V mean we don't want that output (this saves /// compute). The singular values are not sorted (use SortSvd for that). void Svd(VectorBase<Real> *s, MatrixBase<Real> *U, MatrixBase<Real> *Vt) const; /// Compute SVD but only retain the singular values. void Svd(VectorBase<Real> *s) const { Svd(s, NULL, NULL); } /// Returns smallest singular value. Real MinSingularValue() const { Vector<Real> tmp(std::min(NumRows(), NumCols())); Svd(&tmp); return tmp.Min(); } void TestUninitialized() const; // This function is designed so that if any element // if the matrix is uninitialized memory, valgrind will complain. /// Returns condition number by computing Svd. Works even if cols > rows. /// Returns infinity if all singular values are zero. Real Cond() const; /// Returns true if matrix is Symmetric. bool IsSymmetric(Real cutoff = 1.0e-05) const; // replace magic number /// Returns true if matrix is Diagonal. bool IsDiagonal(Real cutoff = 1.0e-05) const; // replace magic number /// Returns true if the matrix is all zeros, except for ones on diagonal. (it /// does not have to be square). More specifically, this function returns /// false if for any i, j, (*this)(i, j) differs by more than cutoff from the /// expression (i == j ? 1 : 0). bool IsUnit(Real cutoff = 1.0e-05) const; // replace magic number /// Returns true if matrix is all zeros. bool IsZero(Real cutoff = 1.0e-05) const; // replace magic number /// Frobenius norm, which is the sqrt of sum of square elements. Same as Schatten 2-norm, /// or just "2-norm". Real FrobeniusNorm() const; /// Returns true if ((*this)-other).FrobeniusNorm() /// <= tol * (*this).FrobeniusNorm(). bool ApproxEqual(const MatrixBase<Real> &other, float tol = 0.01) const; /// Tests for exact equality. It's usually preferable to use ApproxEqual. bool Equal(const MatrixBase<Real> &other) const; /// largest absolute value. Real LargestAbsElem() const; // largest absolute value. /// Returns log(sum(exp())) without exp overflow /// If prune > 0.0, it uses a pruning beam, discarding /// terms less than (max - prune). Note: in future /// we may change this so that if prune = 0.0, it takes /// the max, so use -1 if you don't want to prune. Real LogSumExp(Real prune = -1.0) const; /// Apply soft-max to the collection of all elements of the /// matrix and return normalizer (log sum of exponentials). Real ApplySoftMax(); /// Set each element to the sigmoid of the corresponding element of "src". void Sigmoid(const MatrixBase<Real> &src); /// Sets each element to the Heaviside step function (x > 0 ? 1 : 0) of the /// corresponding element in "src". Note: in general you can make different /// choices for x = 0, but for now please leave it as it (i.e. returning zero) /// because it affects the RectifiedLinearComponent in the neural net code. void Heaviside(const MatrixBase<Real> &src); /// Set each element to y = log(1 + exp(x)) void SoftHinge(const MatrixBase<Real> &src); /// Apply the function y(i) = (sum_{j = i*G}^{(i+1)*G-1} x_j^(power))^(1 / p). /// Requires src.NumRows() == this->NumRows() and src.NumCols() % this->NumCols() == 0. void GroupPnorm(const MatrixBase<Real> &src, Real power); /// Calculate derivatives for the GroupPnorm function above... /// if "input" is the input to the GroupPnorm function above (i.e. the "src" variable), /// and "output" is the result of the computation (i.e. the "this" of that function /// call), and *this has the same dimension as "input", then it sets each element /// of *this to the derivative d(output-elem)/d(input-elem) for each element of "input", where /// "output-elem" is whichever element of output depends on that input element. void GroupPnormDeriv(const MatrixBase<Real> &input, const MatrixBase<Real> &output, Real power); /// Apply the function y(i) = (max_{j = i*G}^{(i+1)*G-1} x_j /// Requires src.NumRows() == this->NumRows() and src.NumCols() % this->NumCols() == 0. void GroupMax(const MatrixBase<Real> &src); /// Calculate derivatives for the GroupMax function above, where /// "input" is the input to the GroupMax function above (i.e. the "src" variable), /// and "output" is the result of the computation (i.e. the "this" of that function /// call), and *this must have the same dimension as "input". Each element /// of *this will be set to 1 if the corresponding input equals the output of /// the group, and 0 otherwise. The equals the function derivative where it is /// defined (it's not defined where multiple inputs in the group are equal to the output). void GroupMaxDeriv(const MatrixBase<Real> &input, const MatrixBase<Real> &output); /// Set each element to the tanh of the corresponding element of "src". void Tanh(const MatrixBase<Real> &src); // Function used in backpropagating derivatives of the sigmoid function: // element-by-element, set *this = diff * value * (1.0 - value). void DiffSigmoid(const MatrixBase<Real> &value, const MatrixBase<Real> &diff); // Function used in backpropagating derivatives of the tanh function: // element-by-element, set *this = diff * (1.0 - value^2). void DiffTanh(const MatrixBase<Real> &value, const MatrixBase<Real> &diff); /** Uses Svd to compute the eigenvalue decomposition of a symmetric positive * semi-definite matrix: (*this) = rP * diag(rS) * rP^T, with rP an * orthogonal matrix so rP^{-1} = rP^T. Throws exception if input was not * positive semi-definite (check_thresh controls how stringent the check is; * set it to 2 to ensure it won't ever complain, but it will zero out negative * dimensions in your matrix. */ void SymPosSemiDefEig(VectorBase<Real> *s, MatrixBase<Real> *P, Real check_thresh = 0.001); friend Real kaldi::TraceMatMat<Real>(const MatrixBase<Real> &A, const MatrixBase<Real> &B, MatrixTransposeType trans); // tr (A B) // so it can get around const restrictions on the pointer to data_. friend class SubMatrix<Real>; /// Add a scalar to each element void Add(const Real alpha); /// Add a scalar to each diagonal element. void AddToDiag(const Real alpha); /// *this += alpha * a * b^T template<typename OtherReal> void AddVecVec(const Real alpha, const VectorBase<OtherReal> &a, const VectorBase<OtherReal> &b); /// [each row of *this] += alpha * v template<typename OtherReal> void AddVecToRows(const Real alpha, const VectorBase<OtherReal> &v); /// [each col of *this] += alpha * v template<typename OtherReal> void AddVecToCols(const Real alpha, const VectorBase<OtherReal> &v); /// *this += alpha * M [or M^T] void AddMat(const Real alpha, const MatrixBase<Real> &M, MatrixTransposeType transA = kNoTrans); /// *this = beta * *this + alpha * M M^T, for symmetric matrices. It only /// updates the lower triangle of *this. It will leave the matrix asymmetric; /// if you need it symmetric as a regular matrix, do CopyLowerToUpper(). void SymAddMat2(const Real alpha, const MatrixBase<Real> &M, MatrixTransposeType transA, Real beta); /// *this = beta * *this + alpha * diag(v) * M [or M^T]. /// The same as adding M but scaling each row M_i by v(i). void AddDiagVecMat(const Real alpha, const VectorBase<Real> &v, const MatrixBase<Real> &M, MatrixTransposeType transM, Real beta = 1.0); /// *this = beta * *this + alpha * M [or M^T] * diag(v) /// The same as adding M but scaling each column M_j by v(j). void AddMatDiagVec(const Real alpha, const MatrixBase<Real> &M, MatrixTransposeType transM, VectorBase<Real> &v, Real beta = 1.0); /// *this = beta * *this + alpha * A .* B (.* element by element multiplication) void AddMatMatElements(const Real alpha, const MatrixBase<Real>& A, const MatrixBase<Real>& B, const Real beta); /// *this += alpha * S template<typename OtherReal> void AddSp(const Real alpha, const SpMatrix<OtherReal> &S); void AddMatMat(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const MatrixBase<Real>& B, MatrixTransposeType transB, const Real beta); /// *this = a * b / c (by element; when c = 0, *this = a) void AddMatMatDivMat(const MatrixBase<Real>& A, const MatrixBase<Real>& B, const MatrixBase<Real>& C); /// *this = a * b / c (by element; when c = 0, *this = a) void SetMatMatDivMat(const MatrixBase<Real>& A, const MatrixBase<Real>& B, const MatrixBase<Real>& C); /// A version of AddMatMat specialized for when the second argument /// contains a lot of zeroes. void AddMatSmat(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const MatrixBase<Real>& B, MatrixTransposeType transB, const Real beta); /// A version of AddMatMat specialized for when the first argument /// contains a lot of zeroes. void AddSmatMat(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const MatrixBase<Real>& B, MatrixTransposeType transB, const Real beta); /// this <-- beta*this + alpha*A*B*C. void AddMatMatMat(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const MatrixBase<Real>& B, MatrixTransposeType transB, const MatrixBase<Real>& C, MatrixTransposeType transC, const Real beta); /// this <-- beta*this + alpha*SpA*B. // This and the routines below are really // stubs that need to be made more efficient. void AddSpMat(const Real alpha, const SpMatrix<Real>& A, const MatrixBase<Real>& B, MatrixTransposeType transB, const Real beta) { Matrix<Real> M(A); return AddMatMat(alpha, M, kNoTrans, B, transB, beta); } /// this <-- beta*this + alpha*A*B. void AddTpMat(const Real alpha, const TpMatrix<Real>& A, MatrixTransposeType transA, const MatrixBase<Real>& B, MatrixTransposeType transB, const Real beta) { Matrix<Real> M(A); return AddMatMat(alpha, M, transA, B, transB, beta); } /// this <-- beta*this + alpha*A*B. void AddMatSp(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const SpMatrix<Real>& B, const Real beta) { Matrix<Real> M(B); return AddMatMat(alpha, A, transA, M, kNoTrans, beta); } /// this <-- beta*this + alpha*A*B*C. void AddSpMatSp(const Real alpha, const SpMatrix<Real> &A, const MatrixBase<Real>& B, MatrixTransposeType transB, const SpMatrix<Real>& C, const Real beta) { Matrix<Real> M(A), N(C); return AddMatMatMat(alpha, M, kNoTrans, B, transB, N, kNoTrans, beta); } /// this <-- beta*this + alpha*A*B. void AddMatTp(const Real alpha, const MatrixBase<Real>& A, MatrixTransposeType transA, const TpMatrix<Real>& B, MatrixTransposeType transB, const Real beta) { Matrix<Real> M(B); return AddMatMat(alpha, A, transA, M, transB, beta); } /// this <-- beta*this + alpha*A*B. void AddTpTp(const Real alpha, const TpMatrix<Real>& A, MatrixTransposeType transA, const TpMatrix<Real>& B, MatrixTransposeType transB, const Real beta) { Matrix<Real> M(A), N(B); return AddMatMat(alpha, M, transA, N, transB, beta); } /// this <-- beta*this + alpha*A*B. // This one is more efficient, not like the others above. void AddSpSp(const Real alpha, const SpMatrix<Real>& A, const SpMatrix<Real>& B, const Real beta); /// Copy lower triangle to upper triangle (symmetrize) void CopyLowerToUpper(); /// Copy upper triangle to lower triangle (symmetrize) void CopyUpperToLower(); /// This function orthogonalizes the rows of a matrix using the Gram-Schmidt /// process. It is only applicable if NumRows() <= NumCols(). It will use /// random number generation to fill in rows with something nonzero, in cases /// where the original matrix was of deficient row rank. void OrthogonalizeRows(); /// stream read. /// Use instead of stream<<*this, if you want to add to existing contents. // Will throw exception on failure. void Read(std::istream & in, bool binary, bool add = false); /// write to stream. void Write(std::ostream & out, bool binary) const; // Below is internal methods for Svd, user does not have to know about this. #if !defined(HAVE_ATLAS) && !defined(USE_KALDI_SVD) // protected: // Should be protected but used directly in testing routine. // destroys *this! void LapackGesvd(VectorBase<Real> *s, MatrixBase<Real> *U, MatrixBase<Real> *Vt); #else protected: // destroys *this! bool JamaSvd(VectorBase<Real> *s, MatrixBase<Real> *U, MatrixBase<Real> *V); #endif protected: /// Initializer, callable only from child. explicit MatrixBase(Real *data, MatrixIndexT cols, MatrixIndexT rows, MatrixIndexT stride) : data_(data), num_cols_(cols), num_rows_(rows), stride_(stride) { KALDI_ASSERT_IS_FLOATING_TYPE(Real); } /// Initializer, callable only from child. /// Empty initializer, for un-initialized matrix. explicit MatrixBase(): data_(NULL) { KALDI_ASSERT_IS_FLOATING_TYPE(Real); } // Make sure pointers to MatrixBase cannot be deleted. ~MatrixBase() { } /// A workaround that allows SubMatrix to get a pointer to non-const data /// for const Matrix. Unfortunately C++ does not allow us to declare a /// "public const" inheritance or anything like that, so it would require /// a lot of work to make the SubMatrix class totally const-correct-- /// we would have to override many of the Matrix functions. inline Real* Data_workaround() const { return data_; } /// data memory area Real* data_; /// these atributes store the real matrix size as it is stored in memory /// including memalignment MatrixIndexT num_cols_; /// < Number of columns MatrixIndexT num_rows_; /// < Number of rows /** True number of columns for the internal matrix. This number may differ * from num_cols_ as memory alignment might be used. */ MatrixIndexT stride_; private: KALDI_DISALLOW_COPY_AND_ASSIGN(MatrixBase); }; /// A class for storing matrices. template<typename Real> class Matrix : public MatrixBase<Real> { public: /// Empty constructor. Matrix(); /// Basic constructor. Matrix(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type = kSetZero, MatrixStrideType stride_type = kDefaultStride): MatrixBase<Real>() { Resize(r, c, resize_type, stride_type); } /// Copy constructor from CUDA matrix /// This is defined in ../cudamatrix/cu-matrix.h template<typename OtherReal> explicit Matrix(const CuMatrixBase<OtherReal> &cu, MatrixTransposeType trans = kNoTrans); /// Swaps the contents of *this and *other. Shallow swap. void Swap(Matrix<Real> *other); /// Defined in ../cudamatrix/cu-matrix.cc void Swap(CuMatrix<Real> *mat); /// Constructor from any MatrixBase. Can also copy with transpose. /// Allocates new memory. explicit Matrix(const MatrixBase<Real> & M, MatrixTransposeType trans = kNoTrans); /// Same as above, but need to avoid default copy constructor. Matrix(const Matrix<Real> & M); // (cannot make explicit) /// Copy constructor: as above, but from another type. template<typename OtherReal> explicit Matrix(const MatrixBase<OtherReal> & M, MatrixTransposeType trans = kNoTrans); /// Copy constructor taking SpMatrix... /// It is symmetric, so no option for transpose, and NumRows == Cols template<typename OtherReal> explicit Matrix(const SpMatrix<OtherReal> & M) : MatrixBase<Real>() { Resize(M.NumRows(), M.NumRows(), kUndefined); this->CopyFromSp(M); } /// Constructor from CompressedMatrix explicit Matrix(const CompressedMatrix &C); /// Copy constructor taking TpMatrix... template <typename OtherReal> explicit Matrix(const TpMatrix<OtherReal> & M, MatrixTransposeType trans = kNoTrans) : MatrixBase<Real>() { if (trans == kNoTrans) { Resize(M.NumRows(), M.NumCols(), kUndefined); this->CopyFromTp(M); } else { Resize(M.NumCols(), M.NumRows(), kUndefined); this->CopyFromTp(M, kTrans); } } /// read from stream. // Unlike one in base, allows resizing. void Read(std::istream & in, bool binary, bool add = false); /// Remove a specified row. void RemoveRow(MatrixIndexT i); /// Transpose the matrix. Works for non-square /// matrices as well as square ones. void Transpose(); /// Distructor to free matrices. ~Matrix() { Destroy(); } /// Sets matrix to a specified size (zero is OK as long as both r and c are /// zero). The value of the new data depends on resize_type: /// -if kSetZero, the new data will be zero /// -if kUndefined, the new data will be undefined /// -if kCopyData, the new data will be the same as the old data in any /// shared positions, and zero elsewhere. /// /// You can set stride_type to kStrideEqualNumCols to force the stride /// to equal the number of columns; by default it is set so that the stride /// in bytes is a multiple of 16. /// /// This function takes time proportional to the number of data elements. void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type = kSetZero, MatrixStrideType stride_type = kDefaultStride); /// Assignment operator that takes MatrixBase. Matrix<Real> &operator = (const MatrixBase<Real> &other) { if (MatrixBase<Real>::NumRows() != other.NumRows() || MatrixBase<Real>::NumCols() != other.NumCols()) Resize(other.NumRows(), other.NumCols(), kUndefined); MatrixBase<Real>::CopyFromMat(other); return *this; } /// Assignment operator. Needed for inclusion in std::vector. Matrix<Real> &operator = (const Matrix<Real> &other) { if (MatrixBase<Real>::NumRows() != other.NumRows() || MatrixBase<Real>::NumCols() != other.NumCols()) Resize(other.NumRows(), other.NumCols(), kUndefined); MatrixBase<Real>::CopyFromMat(other); return *this; } private: /// Deallocates memory and sets to empty matrix (dimension 0, 0). void Destroy(); /// Init assumes the current class contents are invalid (i.e. junk or have /// already been freed), and it sets the matrix to newly allocated memory with /// the specified number of rows and columns. r == c == 0 is acceptable. The data /// memory contents will be undefined. void Init(const MatrixIndexT r, const MatrixIndexT c, const MatrixStrideType stride_type); }; /// @} end "addtogroup matrix_group" /// \addtogroup matrix_funcs_io /// @{ /// A structure containing the HTK header. /// [TODO: change the style of the variables to Kaldi-compliant] struct HtkHeader { /// Number of samples. int32 mNSamples; /// Sample period. int32 mSamplePeriod; /// Sample size int16 mSampleSize; /// Sample kind. uint16 mSampleKind; }; // Read HTK formatted features from file into matrix. template<typename Real> bool ReadHtk(std::istream &is, Matrix<Real> *M, HtkHeader *header_ptr); // Write (HTK format) features to file from matrix. template<typename Real> bool WriteHtk(std::ostream &os, const MatrixBase<Real> &M, HtkHeader htk_hdr); // Write (CMUSphinx format) features to file from matrix. template<typename Real> bool WriteSphinx(std::ostream &os, const MatrixBase<Real> &M); /// @} end of "addtogroup matrix_funcs_io" /** Sub-matrix representation. Can work with sub-parts of a matrix using this class. Note that SubMatrix is not very const-correct-- it allows you to change the contents of a const Matrix. Be careful! */ template<typename Real> class SubMatrix : public MatrixBase<Real> { public: // Initialize a SubMatrix from part of a matrix; this is // a bit like A(b:c, d:e) in Matlab. // This initializer is against the proper semantics of "const", since // SubMatrix can change its contents. It would be hard to implement // a "const-safe" version of this class. SubMatrix(const MatrixBase<Real>& T, const MatrixIndexT ro, // row offset, 0 < ro < NumRows() const MatrixIndexT r, // number of rows, r > 0 const MatrixIndexT co, // column offset, 0 < co < NumCols() const MatrixIndexT c); // number of columns, c > 0 // This initializer is mostly intended for use in CuMatrix and related // classes. Be careful! SubMatrix(Real *data, MatrixIndexT num_rows, MatrixIndexT num_cols, MatrixIndexT stride); ~SubMatrix<Real>() {} /// This type of constructor is needed for Range() to work [in Matrix base /// class]. Cannot make it explicit. SubMatrix<Real> (const SubMatrix &other): MatrixBase<Real> (other.data_, other.num_cols_, other.num_rows_, other.stride_) {} private: /// Disallow assignment. SubMatrix<Real> &operator = (const SubMatrix<Real> &other); }; /// @} End of "addtogroup matrix_funcs_io". /// \addtogroup matrix_funcs_scalar /// @{ // Some declarations. These are traces of products. template<typename Real> bool ApproxEqual(const MatrixBase<Real> &A, const MatrixBase<Real> &B, Real tol = 0.01) { return A.ApproxEqual(B, tol); } template<typename Real> inline void AssertEqual(const MatrixBase<Real> &A, const MatrixBase<Real> &B, float tol = 0.01) { KALDI_ASSERT(A.ApproxEqual(B, tol)); } /// Returns trace of matrix. template <typename Real> double TraceMat(const MatrixBase<Real> &A) { return A.Trace(); } /// Returns tr(A B C) template <typename Real> Real TraceMatMatMat(const MatrixBase<Real> &A, MatrixTransposeType transA, const MatrixBase<Real> &B, MatrixTransposeType transB, const MatrixBase<Real> &C, MatrixTransposeType transC); /// Returns tr(A B C D) template <typename Real> Real TraceMatMatMatMat(const MatrixBase<Real> &A, MatrixTransposeType transA, const MatrixBase<Real> &B, MatrixTransposeType transB, const MatrixBase<Real> &C, MatrixTransposeType transC, const MatrixBase<Real> &D, MatrixTransposeType transD); /// @} end "addtogroup matrix_funcs_scalar" /// \addtogroup matrix_funcs_misc /// @{ /// Function to ensure that SVD is sorted. This function is made as generic as /// possible, to be applicable to other types of problems. s->Dim() should be /// the same as U->NumCols(), and we sort s from greatest to least absolute /// value (if sort_on_absolute_value == true) or greatest to least value /// otherwise, moving the columns of U, if it exists, and the rows of Vt, if it /// exists, around in the same way. Note: the "absolute value" part won't matter /// if this is an actual SVD, since singular values are non-negative. template<typename Real> void SortSvd(VectorBase<Real> *s, MatrixBase<Real> *U, MatrixBase<Real>* Vt = NULL, bool sort_on_absolute_value = true); /// Creates the eigenvalue matrix D that is part of the decomposition used Matrix::Eig. /// D will be block-diagonal with blocks of size 1 (for real eigenvalues) or 2x2 /// for complex pairs. If a complex pair is lambda +- i*mu, D will have a corresponding /// 2x2 block [lambda, mu; -mu, lambda]. /// This function will throw if any complex eigenvalues are not in complex conjugate /// pairs (or the members of such pairs are not consecutively numbered). template<typename Real> void CreateEigenvalueMatrix(const VectorBase<Real> &real, const VectorBase<Real> &imag, MatrixBase<Real> *D); /// The following function is used in Matrix::Power, and separately tested, so we /// declare it here mainly for the testing code to see. It takes a complex value to /// a power using a method that will work for noninteger powers (but will fail if the /// complex value is real and negative). template<typename Real> bool AttemptComplexPower(Real *x_re, Real *x_im, Real power); /// @} end of addtogroup matrix_funcs_misc /// \addtogroup matrix_funcs_io /// @{ template<typename Real> std::ostream & operator << (std::ostream & Out, const MatrixBase<Real> & M); template<typename Real> std::istream & operator >> (std::istream & In, MatrixBase<Real> & M); // The Matrix read allows resizing, so we override the MatrixBase one. template<typename Real> std::istream & operator >> (std::istream & In, Matrix<Real> & M); template<typename Real> bool SameDim(const MatrixBase<Real> &M, const MatrixBase<Real> &N) { return (M.NumRows() == N.NumRows() && M.NumCols() == N.NumCols()); } /// @} end of \addtogroup matrix_funcs_io } // namespace kaldi // we need to include the implementation and some // template specializations. #include "matrix/kaldi-matrix-inl.h" #endif // KALDI_MATRIX_KALDI_MATRIX_H_
[ "nicj@i2r.a-star.edu.sg" ]
nicj@i2r.a-star.edu.sg
467d5043efda1d8f1bc771e74eb029f15c7ffd6d
6e889590729afb39a4f393789fba33ce03e7c6fd
/cpuluscplus/cpuluscplus/opencv/opencv 之 hardexample剪切.cpp
6c730eabd3ce116506474957f83f2dfea7c85cf1
[]
no_license
sunrong1/cplusplus_cv
db56c4646455d2e1d8aaf92d3cc06cdf87450cb4
3d87f44c01499e01b5758de2370be7a1871bf822
refs/heads/master
2021-08-11T23:35:24.781641
2014-05-29T14:57:09
2014-05-29T14:57:09
null
0
0
null
null
null
null
GB18030
C++
false
false
3,415
cpp
#include <iostream> #include <fstream> #include <string> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <opencv2/ml/ml.hpp> using namespace std; using namespace cv; int hardExampleCount = 0; //hard example计数 int main() { Mat src; char saveName[256];//剪裁出来的hard example图片的文件名 string ImgName; ifstream fin_detector("detector64.txt");//打开自己训练的SVM检测器文件 ifstream fin_imgList("posbig.txt");//打开原始负样本图片文件列表 //ifstream fin_imgList("subset.txt"); // ifstream fin_imgList("neghard.txt"); // while(getline(fin_imgList,ImgName)) // { // string fullName = "F:/OpenCVproject/data/INRIA/INRIAPerson/Test/neghard/" + ImgName;//加上路径名 // src = imread(fullName);//读取图片 // imshow("hard",src); // waitKey(); // } //从文件中读入自己训练的SVM参数 float temp; vector<float> myDetector;//3781维的检测器参数,(必须为3781维?) while(!fin_detector.eof()) { fin_detector >> temp; myDetector.push_back(temp);//放入检测器数组 } cout<<"检测子维数:"<<myDetector.size()<<endl; //namedWindow("src",0); HOGDescriptor hog;//HOG特征检测器 hog.setSVMDetector(myDetector);//设置检测器参数为自己训练的SVM参数 //一行一行读取文件列表 while(getline(fin_imgList,ImgName)) { cout<<"处理:"<<ImgName<<endl; //string fullName = "F:/OpenCVproject/data/INRIA/INRIAPerson/Train/neg/" + ImgName;//加上路径名 string fullName = "F:/OpenCVproject/data/INRIA/INRIAPerson/Test/pos/" + ImgName;//加上路径名 src = imread(fullName);//读取图片 imshow("show",src); waitKey(); Mat img = src.clone();//复制原图 vector<Rect> found;//矩形框数组 //对负样本原图进行多尺度检测,检测出的都是误报 hog.detectMultiScale(src, found, 0, Size(8,8), Size(32,32), 1.05, 2); //遍历从图像中检测出来的矩形框,得到hard example for(int i=0; i < found.size(); i++) { //检测出来的很多矩形框都超出了图像边界,将这些矩形框都强制规范在图像边界内部 Rect r = found[i]; if(r.x < 0) r.x = 0; if(r.y < 0) r.y = 0; if(r.x + r.width > src.cols) r.width = src.cols - r.x; if(r.y + r.height > src.rows) r.height = src.rows - r.y; //将矩形框保存为图片,就是Hard Example Mat hardExampleImg = src(r);//从原图上截取矩形框大小的图片 rectangle(src,found[i].tl(),found[i].br(),Scalar(0,0,255),3); /* imshow("show",src); waitKey();*/ resize(hardExampleImg,hardExampleImg,Size(64,128));//将剪裁出来的图片缩放为64*128大小 sprintf(saveName,"hardexample%09d.jpg",hardExampleCount++);//生成hard example图片的文件名 imwrite(saveName, hardExampleImg);//保存文件 //画矩形框,因为hog检测出的矩形框比实际人体框要稍微大些,所以这里需要做一些调整 //r.x += cvRound(r.width*0.1); //r.width = cvRound(r.width*0.8); //r.y += cvRound(r.height*0.07); //r.height = cvRound(r.height*0.8); //rectangle(img, r.tl(), r.br(), Scalar(0,255,0), 3); } //imwrite(ImgName,img); //imshow("src",src); //waitKey(100);//注意:imshow之后一定要加waitKey,否则无法显示图像 } system("pause"); }
[ "sunrong1990@126.com" ]
sunrong1990@126.com
2d8d5cb07b1b58163e2fb0210a903a5f44c1e6d9
01ec525eca69738ae90f12a6e87279c52818c9ae
/omochain/libraries/utilities/include/eos/utilities/string_escape.hpp
e849e15d5e0fbc406f9bb233e1d3b65e6510e9c8
[ "MIT" ]
permissive
omochain01/omochain
8625c55dcb229da96a741425d9216bf19495bdd7
532df59aa916bc04d7c989e34229344332d21bfb
refs/heads/master
2020-03-25T10:09:44.722303
2018-09-27T06:54:08
2018-09-27T06:54:08
143,685,265
0
0
null
null
null
null
UTF-8
C++
false
false
1,329
hpp
/* * Copyright (c) 2017, Respective Authors. * * The MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #pragma once #include <string> namespace omo { namespace utilities { std::string escape_string_for_c_source_code(const std::string& input); } } // end namespace omo::utilities
[ "omochain2@163.com" ]
omochain2@163.com
c2d418e0dce3f1cecdb173bd91fdff95c1db82f7
27b78a089fa389244eefcdd08d8d7e273a3bb3e8
/bial/src/Signal.cpp
99c8d7aa577658a60784ef16ec77404aaa013d5a
[]
no_license
GIBIS-UNIFESP/BIAL
651f3a7f44238df977be245b07a1391d2518f974
eddd3d756b744b5caf8429acec7abe208b3a3bd1
refs/heads/master
2021-01-12T13:32:10.299904
2018-02-09T11:55:34
2018-02-09T11:55:34
69,836,560
11
6
null
2017-12-01T16:01:12
2016-10-03T02:55:05
C++
UTF-8
C++
false
false
15,473
cpp
/* Biomedical Image Analysis Library * See README file in the root instalation directory for more information. */ /** * @date 2012/Sep/11 * @brief Signal handeling. */ #ifndef BIALSIGNAL_C #define BIALSIGNAL_C #include "Signal.hpp" #if defined ( BIAL_EXPLICIT_LIB ) && ( BIAL_Signal ) #define BIAL_EXPLICIT_Signal #endif #if defined ( BIAL_EXPLICIT_Signal ) || ( BIAL_IMPLICIT_BIN ) #include "File.hpp" #include "RandomQueue.hpp" #include "SortingBinarySearch.hpp" namespace Bial { Signal::Signal( ) : frequency( ), _data( ), qk_data( ) { } Signal::Signal( size_t data_size, double data_minimum, double data_step ) try : frequency( data_size, 0.0 ), _data( data_size, data_minimum ), qk_data( ) { COMMENT( "Assigning quick pointers.", 2 ); qk_data = &_data[ 0 ]; COMMENT( "Assigning data.", 2 ); for( size_t dt = 1; dt < _data.size( ); ++dt ) { QK_DATA( dt ) = QK_DATA( dt - 1 ) + data_step; } } catch( std::bad_alloc &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Memory allocation error." ) ); throw( std::runtime_error( msg ) ); } catch( std::runtime_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Runtime error." ) ); throw( std::runtime_error( msg ) ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Empty kernel." ) ); throw( std::logic_error( msg ) ); } template< class D > Signal::Signal( Vector< D > &new_frequency, double data_minimum, double data_step ) try : frequency( new_frequency ), _data( new_frequency.size( ), data_minimum ), qk_data( ) { if( new_frequency.size( ) == 0 ) { std::string msg( BIAL_ERROR( "Empty data vector to build the histogram." ) ); throw( std::logic_error( msg ) ); } COMMENT( "Assigning quick pointers.", 2 ); qk_data = &_data[ 0 ]; COMMENT( "Assigning data.", 2 ); for( size_t dt = 1; dt < _data.size( ); ++dt ) { QK_DATA( dt ) = QK_DATA( dt - 1 ) + data_step; } } catch( std::bad_alloc &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Memory allocation error." ) ); throw( std::runtime_error( msg ) ); } catch( std::runtime_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Runtime error." ) ); throw( std::runtime_error( msg ) ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Empty kernel." ) ); throw( std::logic_error( msg ) ); } template< class D > Signal::Signal( Vector< D > &new_frequency, Vector< D > &new_data ) try : frequency( new_frequency ), _data( new_data ), qk_data( ) { if( new_frequency.size( ) == 0 ) { std::string msg( BIAL_ERROR( "Empty data vector to build the histogram." ) ); throw( std::logic_error( msg ) ); } if( new_frequency.size( ) != new_data.size( ) ) { std::string msg( BIAL_ERROR( "Frequency and data vector dimensions do not match." ) ); throw( std::logic_error( msg ) ); } COMMENT( "Assigning quick pointers.", 2 ); qk_data = &_data[ 0 ]; } catch( std::bad_alloc &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Memory allocation error." ) ); throw( std::runtime_error( msg ) ); } catch( std::runtime_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Runtime error." ) ); throw( std::runtime_error( msg ) ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Empty kernel." ) ); throw( std::logic_error( msg ) ); } Signal::Signal( const Signal &sgn ) try : frequency( sgn.frequency ), _data( sgn._data ), qk_data( ) { COMMENT( "Assigning quick access pointers.", 2 ); qk_data = &_data[ 0 ]; } catch( std::bad_alloc &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Memory allocation error." ) ); throw( std::runtime_error( msg ) ); } catch( std::runtime_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Runtime error." ) ); throw( std::runtime_error( msg ) ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } Signal &Signal::operator=( const Signal &other ) { COMMENT( "Assigning signal", 2 ); frequency = other.frequency; _data = other._data; qk_data = &_data[ 0 ]; return( *this ); } const double &Signal::operator[]( size_t p ) const { try { #ifdef BIAL_DEBUG return( frequency.at( p ) ); #else return( frequency( p ) ); #endif } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } } double &Signal::operator[]( size_t p ) { try { #ifdef BIAL_DEBUG return( frequency.at( p ) ); #else return( frequency( p ) ); #endif } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } } size_t Signal::Size( ) const { return( _data.size( ) ); } size_t Signal::size( ) const { return( _data.size( ) ); } size_t Signal::Bins( ) const { return( _data.size( ) ); } const double* Signal::Data( ) const { return( qk_data ); } double* Signal::Data( ) { return( qk_data ); } const double* Signal::data( ) const { return( qk_data ); } double* Signal::data( ) { return( qk_data ); } template< class D > void Signal::Data( Vector< D > val ) { try { if( val.size( ) != frequency.size( ) ) { std::string msg( BIAL_ERROR( "Frequency and input vector dimensions do not match." ) ); throw( std::logic_error( msg ) ); } _data = val; } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } ; } const double* Signal::Frequency( ) const { return( frequency.data( ) ); } double* Signal::Frequency( ) { return( frequency.data( ) ); } void Signal::Frequency( Vector< double > val ) { try { if( val.size( ) != _data.size( ) ) { std::string msg( BIAL_ERROR( "Data and input vector dimensions do not match." ) ); throw( std::logic_error( msg ) ); } frequency = val; } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } ; } double Signal::MinimumFrequency( size_t min_bin ) const { try { if( _data.size( ) > 0 ) { return( MinimumFrequency( min_bin, _data.size( ) - 1 ) ); } return( 0 ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } double Signal::MinimumFrequency( size_t min_bin, size_t max_bin ) const { try { double min = 0.0; for( size_t it = min_bin; it <= max_bin; ++it ) { if( min > frequency( it ) ) { min = frequency( it ); } } return( min ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } double Signal::MaximumFrequency( size_t min_bin ) const { try { if( _data.size( ) > 0 ) { return( MaximumFrequency( min_bin, _data.size( ) - 1 ) ); } return( 0 ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } double Signal::MaximumFrequency( size_t min_bin, size_t max_bin ) const { try { double max = 0.0; for( size_t it = min_bin; it <= max_bin; ++it ) { if( max < frequency( it ) ) { max = frequency( it ); } } return( max ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } size_t Signal::MinimumFrequencyBin( size_t min_bin ) const { try { if( _data.size( ) > 0 ) { return( MinimumFrequencyBin( min_bin, _data.size( ) - 1 ) ); } return( 0 ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } size_t Signal::MinimumFrequencyBin( size_t min_bin, size_t max_bin ) const { try { size_t bin = min_bin; double min = frequency( min_bin ); for( size_t it = min_bin + 1; it <= max_bin; ++it ) { if( min > frequency( it ) ) { min = frequency( it ); bin = it; } } return( bin ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } size_t Signal::MaximumFrequencyBin( size_t min_bin ) const { try { if( _data.size( ) > 0 ) { return( MaximumFrequencyBin( min_bin, _data.size( ) - 1 ) ); } return( 0 ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } size_t Signal::MaximumFrequencyBin( size_t min_bin, size_t max_bin ) const { try { size_t bin = min_bin; double max = frequency( min_bin ); for( size_t it = min_bin + 1; it <= max_bin; ++it ) { if( max < frequency( it ) ) { max = frequency( it ); bin = it; } } return( bin ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } size_t Signal::Bin( double val ) const { try { return( Sorting::BinarySearch( _data, val ) ); } catch( std::bad_alloc &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Memory allocation error." ) ); throw( std::runtime_error( msg ) ); } catch( std::runtime_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Runtime error." ) ); throw( std::runtime_error( msg ) ); } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } inline void Signal::Bin( size_t bin, double val ) { QK_DATA( bin ) = val; } const double &Signal::Data( size_t bin ) const { return( QK_DATA( bin ) ); } double &Signal::Data( size_t bin ) { return( QK_DATA( bin ) ); } template< class O > void Signal::Print( O &os ) const { try { for( size_t it = 0; it < _data.size( ); ++it ) { os << QK_DATA( it ) << " " << frequency( it ) << std::endl; } } catch( const std::out_of_range &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Out of range exception." ) ); throw( std::out_of_range( msg ) ); } catch( const std::logic_error &e ) { std::string msg( e.what( ) + std::string( "\n" ) + BIAL_ERROR( "Logic Error." ) ); throw( std::logic_error( msg ) ); } } #ifdef BIAL_EXPLICIT_Signal template Signal::Signal( Vector< int > &new_frequency, double data_minimum, double data_step ); template Signal::Signal( Vector< int > &new_frequency, Vector< int > &new_data ); template void Signal::Data( Vector< int > val ); template Signal::Signal( Vector< llint > &new_frequency, double data_minimum, double data_step ); template Signal::Signal( Vector< llint > &new_frequency, Vector< llint > &new_data ); template void Signal::Data( Vector< llint > val ); template Signal::Signal( Vector< float > &new_frequency, double data_minimum, double data_step ); template Signal::Signal( Vector< float > &new_frequency, Vector< float > &new_data ); template void Signal::Data( Vector< float > val ); template Signal::Signal( Vector< double > &new_frequency, double data_minimum, double data_step ); template Signal::Signal( Vector< double > &new_frequency, Vector< double > &new_data ); template void Signal::Data( Vector< double > val ); template void Signal::Print( std::ostream &os ) const; template void Signal::Print( OFile &os ) const; #endif } #endif #endif
[ "lucaslellis777@gmail.com" ]
lucaslellis777@gmail.com
b5b10aa2d72dc5b1fdc96084e2cfd7bbd025dd70
eacf1e8a6b0cfdc6e639b90d8de9e4d057fedd3e
/Ex157.cpp
aabbd74fe1abd361e4a53d49a429301221985fe6
[]
no_license
domiee13/200-CPP-Exercises
4686a45fb20d56253a84bf1fed931ea4225f2366
ae6eacf2194ef45bab34a66c0eddda58b2de4783
refs/heads/master
2020-07-22T16:19:52.256243
2020-02-05T04:30:21
2020-02-05T04:30:21
207,258,835
0
1
null
null
null
null
UTF-8
C++
false
false
998
cpp
/* Cho xâu ký tự S bao gồm các ký tự ‘a’,..,’z’ và các chữ số. Nhiệm vụ của bạn là hãy tìm số lớn nhất có mặt trong xâu. */ //Y tuong: Add cac so vao vector va goi ham max() #include <iostream> #include <fstream> #include <vector> #include <algorithm> using namespace std; ifstream inp("inp.txt",ios::in); ofstream out("out.txt",ios::out); int findMaxNum(string); int findMax(vector<int>); int main(){ int countTest; inp>>countTest; for(int i = 0;i<countTest;i++){ string s; inp>>s; out<<findMaxNum(s)<<endl; } cout<<"DONE!"<<endl; return 0; } int findMaxNum(string s){ string tmp=""; vector<int> num; for(char ch:s){ if(isdigit(ch)){ tmp+=ch; } else{ num.push_back(atoi(tmp.c_str()));//Neu khong co c_str() se khong thuc hien duoc cau lenh tmp=""; } } return *max_element(num.begin(),num.end()); }
[ "dungngocmd@gmail.com" ]
dungngocmd@gmail.com
2efe3860de0d8be35a3ac6226a8a38f3eaad3fe6
2c378ab9a3099d9286df6bbf7abe2ee3aa69ddcb
/old_bak/ClientEngine/UI/src/NDUIMenuLayer.cpp
321f5bbbc54b508fe4de6abcf7c3f4ced548be4e
[]
no_license
kerasking/HHHH
524bbbaabc26443cda7b29ca19aef7e9c1047a42
3c53a7e753ccf60c8c95121b3c4871df0aad315b
refs/heads/master
2021-05-26T18:18:43.087367
2012-12-28T02:50:52
2012-12-28T02:50:52
8,725,602
1
0
null
null
null
null
UTF-8
C++
false
false
8,471
cpp
// // NDUIMenuLayer.mm // DragonDrive // // Created by xiezhenghai on 10-12-29. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "NDUIMenuLayer.h" #import "NDTile.h" #import "CCTextureCache.h" #import "NDDirector.h" #import "CGPointExtension.h" #import "CCTextureCache.h" #import "cocos2dExt.h" #import "NDUtility.h" #include "GameScene.h" namespace NDEngine { IMPLEMENT_CLASS(NDUIMenuLayer, NDUILayer) #define title_height 28 #define bottom_height 42 #define context_height NDDirector::DefaultDirector()->GetWinSize().height - title_height - bottom_height #define left_top_image [NSString stringWithFormat:@"%s", GetImgPath("w3.png")] #define right_bottom_image [NSString stringWithFormat:@"%s", GetImgPath("w4.png")] //#define back_button_image [NSString stringWithFormat:@"%@/res/image/btnBack_up.png", [[NSBundle mainBundle] resourcePath]] //#define back_button_down_image [NSString stringWithFormat:@"%@/res/image/btnBack_down.png", [[NSBundle mainBundle] resourcePath]] #define back_button_Rect CGRectMake(15, NDDirector::DefaultDirector()->GetWinSize().height - bottom_height + 5, 40, 22) #define ok_button_Rect CGRectMake(NDDirector::DefaultDirector()->GetWinSize().width - 50, NDDirector::DefaultDirector()->GetWinSize().height - bottom_height + 5, 35, 37) //#define back_button_down_interval 10 //static int backButtonInterval = 0; NDUIMenuLayer::NDUIMenuLayer() { m_tiles = [[NSMutableArray alloc] init]; m_btnCancel = NULL; m_btnOk = NULL; m_picCancel = NULL; m_picOk = NULL; } NDUIMenuLayer::~NDUIMenuLayer() { [m_tiles release]; delete m_picCancel; delete m_picOk; } void NDUIMenuLayer::Initialization() { NDUILayer::Initialization(); NDUILayer::SetFrameRect(CGRectMake(0, 0, NDDirector::DefaultDirector()->GetWinSize().width, NDDirector::DefaultDirector()->GetWinSize().height)); this->SetDelegate(this); m_btnCancel = new NDUIButton(); m_btnCancel->Initialization(); m_picCancel = NDPicturePool::DefaultPool()->AddPicture(GetImgPath("titles.png")); if (m_picCancel) { m_picCancel->Cut(CGRectMake(120, 0, 40, 20)); m_btnCancel->SetImage(m_picCancel); } m_btnCancel->SetFrameRect(CGRectMake(NDDirector::DefaultDirector()->GetWinSize().width - 50, NDDirector::DefaultDirector()->GetWinSize().height - bottom_height + 8, m_picCancel->GetSize().width, m_picCancel->GetSize().height)); this->AddChild(m_btnCancel); this->MakeLeftTopTile(); this->MakeRightTopTile(); this->MakeLeftBottomTile(); this->MakeRightBottomTile(); } void NDUIMenuLayer::ShowOkBtn() { if (!m_btnOk) { m_btnOk = new NDUIButton(); m_btnOk->Initialization(); m_picOk = NDPicturePool::DefaultPool()->AddPicture(GetImgPath("titles.png")); if (m_picOk) { m_picOk->Cut(CGRectMake(80, 0, 40, 20)); m_btnOk->SetImage(m_picOk); } m_btnOk->SetFrameRect(CGRectMake(15, NDDirector::DefaultDirector()->GetWinSize().height - bottom_height + 8, m_picOk->GetSize().width, m_picOk->GetSize().height)); this->AddChild(m_btnOk); } } unsigned int NDUIMenuLayer::GetTitleHeight() { return title_height; } unsigned int NDUIMenuLayer::GetOperationHeight() { return bottom_height; } unsigned int NDUIMenuLayer::GetTextHeight() { return context_height; } void NDUIMenuLayer::draw() { NDUILayer::draw(); if (this->IsVisibled()) { this->drawBackground(); //glDisableClientState(GL_COLOR_ARRAY); for (int i = 0; i < (int)[m_tiles count]; i++) { NDTile *tile = [m_tiles objectAtIndex:i]; [tile draw]; } //glEnableClientState(GL_COLOR_ARRAY); } } void NDUIMenuLayer::OnBeforeNodeRemoveFromParent(NDNode* node, bool bCleanUp) { if (this->GetParent() && this->GetParent()->IsKindOfClass(RUNTIME_CLASS(GameScene))) { ((GameScene*)(this->GetParent()))->SetUIShow(false); } } void NDUIMenuLayer::drawBackground() { CGSize winSize = NDDirector::DefaultDirector()->GetWinSize(); //draw title recttangle DrawRecttangle(CGRectMake(0, 0, winSize.width, title_height), ccc4(49, 146, 189, 255)); //draw context recttangle DrawRecttangle(CGRectMake(0, title_height, winSize.width, context_height), ccc4(165, 178, 156, 255)); //draw bottom recttangle DrawRecttangle(CGRectMake(0, title_height + context_height, winSize.width, bottom_height), ccc4(16, 56, 66, 255)); //draw left frame DrawLine(ccp(0, 0), ccp(0, winSize.height), ccc4(8, 32, 16, 255), 1); DrawLine(ccp(1, 0), ccp(1, winSize.height), ccc4(107, 158, 156, 255), 1); DrawLine(ccp(2, 0), ccp(2, winSize.height), ccc4(24, 85, 82, 255), 1); //draw right frame DrawLine(ccp(winSize.width-1, 0), ccp(winSize.width-1, winSize.height), ccc4(8, 32, 16, 255), 1); DrawLine(ccp(winSize.width-2, 0), ccp(winSize.width-2, winSize.height), ccc4(107, 158, 156, 255), 1); DrawLine(ccp(winSize.width-3, 0), ccp(winSize.width-3, winSize.height), ccc4(24, 85, 82, 255), 1); //draw top frame DrawLine(ccp(0, 0), ccp(winSize.width, 0), ccc4(8, 32, 16, 255), 1); DrawLine(ccp(0, 1), ccp(winSize.width, 1), ccc4(107, 158, 156, 255), 1); DrawLine(ccp(0, 2), ccp(winSize.width, 2), ccc4(24, 85, 82, 255), 1); //draw right frame DrawLine(ccp(0, winSize.height-1), ccp(winSize.width, winSize.height-1), ccc4(8, 32, 16, 255), 1); DrawLine(ccp(0, winSize.height-2), ccp(winSize.width, winSize.height-2), ccc4(107, 158, 156, 255), 1); DrawLine(ccp(0, winSize.height-3), ccp(winSize.width, winSize.height-3), ccc4(24, 85, 82, 255), 1); //draw split line between title and context DrawLine(ccp(0, title_height), ccp(winSize.width, title_height), ccc4(24, 85, 82, 255), 1); //draw split line between context and bottom DrawLine(ccp(0, title_height+context_height), ccp(winSize.width, title_height+context_height), ccc4(107, 158, 156, 255), 2); } void NDUIMenuLayer::MakeLeftTopTile() { CGSize winSize = NDDirector::DefaultDirector()->GetWinSize(); NDTile* tile = [[NDTile alloc] init]; tile.texture = [[CCTextureCache sharedTextureCache] addImage:left_top_image]; tile.cutRect = CGRectMake(0, 0, tile.texture.maxS * tile.texture.pixelsWide, tile.texture.maxT * tile.texture.pixelsHigh); tile.drawRect = CGRectMake(0, 0, 16, 16); tile.reverse = NO; tile.rotation = NDRotationEnumRotation0; tile.mapSize = CGSizeMake(winSize.width, winSize.height); [tile make]; [m_tiles addObject:tile]; [tile release]; } void NDUIMenuLayer::MakeRightTopTile() { CGSize winSize = NDDirector::DefaultDirector()->GetWinSize(); NDTile* tile = [[NDTile alloc] init]; tile.texture = [[CCTextureCache sharedTextureCache] addImage:left_top_image]; tile.cutRect = CGRectMake(0, 0, tile.texture.maxS * tile.texture.pixelsWide, tile.texture.maxT * tile.texture.pixelsHigh); tile.drawRect = CGRectMake(winSize.width - tile.cutRect.size.width , 0, 16, 16); tile.reverse = YES; tile.rotation = NDRotationEnumRotation0; tile.mapSize = CGSizeMake(winSize.width, winSize.height); [tile make]; [m_tiles addObject:tile]; [tile release]; } void NDUIMenuLayer::MakeLeftBottomTile() { CGSize winSize = NDDirector::DefaultDirector()->GetWinSize(); NDTile* tile = [[NDTile alloc] init]; tile.texture = [[CCTextureCache sharedTextureCache] addImage:right_bottom_image]; tile.cutRect = CGRectMake(0, 0, tile.texture.maxS * tile.texture.pixelsWide, tile.texture.maxT * tile.texture.pixelsHigh); tile.drawRect = CGRectMake(0, winSize.height - tile.cutRect.size.height , 8, 8); tile.reverse = YES; tile.rotation = NDRotationEnumRotation0; tile.mapSize = CGSizeMake(winSize.width, winSize.height); [tile make]; [m_tiles addObject:tile]; [tile release]; } void NDUIMenuLayer::MakeRightBottomTile() { CGSize winSize = NDDirector::DefaultDirector()->GetWinSize(); NDTile* tile = [[NDTile alloc] init]; tile.texture = [[CCTextureCache sharedTextureCache] addImage:right_bottom_image]; tile.cutRect = CGRectMake(0, 0, tile.texture.maxS * tile.texture.pixelsWide, tile.texture.maxT * tile.texture.pixelsHigh); tile.drawRect = CGRectMake(winSize.width - tile.cutRect.size.width, winSize.height - tile.cutRect.size.height , 8, 8); tile.reverse = NO; tile.rotation = NDRotationEnumRotation0; tile.mapSize = CGSizeMake(winSize.width, winSize.height); [tile make]; [m_tiles addObject:tile]; [tile release]; } }
[ "hubris6965@hotmail.com" ]
hubris6965@hotmail.com
bfb9b3a9f3270e7fed05b4369deed19a7af80b11
d9a50abfe2b0a1adf655048ddba8ef302d750d53
/DERAS-Server/src/ieee_sep/AbstractDevice.cpp
efc079113a6cad98b5ad79c9815dbd704089e6db
[ "BSD-2-Clause" ]
permissive
psu-powerlab/DERAS-Server
f7ed520ee6885a77ac5d3b2f672d8a6502004c97
5b41f35148aa1ff45c1f6b3a96f94ce443a72d0f
refs/heads/master
2022-11-29T15:01:50.874535
2020-06-18T20:06:10
2020-06-18T20:06:10
261,805,865
0
0
BSD-2-Clause
2020-07-06T18:53:10
2020-05-06T15:44:56
C++
UTF-8
C++
false
false
367
cpp
/////////////////////////////////////////////////////////// // AbstractDevice.cpp // Implementation of the Class AbstractDevice // Created on: 13-Apr-2020 2:51:19 PM // Original author: shu /////////////////////////////////////////////////////////// #include "AbstractDevice.h" AbstractDevice::AbstractDevice(){ } AbstractDevice::~AbstractDevice(){ }
[ "psu.powerlab@gmail.com" ]
psu.powerlab@gmail.com
781a29c34c52dc500b5d9756c3304d89b0a9824f
47ddc4ed976de66ce3a6e33d7b0fa25f67a66db4
/Source/fantastic_pancakes/Player/PlayerAnimInstance.cpp
7a2004fa1d4818313b5d7606c50c4f553e6d1ab2
[]
no_license
AnagramMC/fantastic_pancakes
ddda2df98ff29c5c6b865fe16f199aba4b2de7a7
5bf8a459e9e9cda2ec2a84ef0f34c0941ea4642d
refs/heads/master
2016-09-01T13:26:05.929197
2016-02-02T04:28:54
2016-02-02T04:28:54
50,708,024
0
0
null
null
null
null
UTF-8
C++
false
false
148
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "fantastic_pancakes.h" #include "PlayerAnimInstance.h"
[ "hisham.ata@hotmail.com" ]
hisham.ata@hotmail.com