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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fb91c42c90d61e7af4a56ce451b90b3152306037 | 7ebca2667b9bceadf978fd86cfd9f6222a94d7a6 | /Linter.cpp | e5c7d4a41eee05c3d23529aec2bab71d6e11c4b5 | [] | no_license | SanteriSuomi/Misc-DSA | a1c376c77fc2f1bec1f283a6ac9f5b6c39cffe7d | 95fc4101bf3dc6dc7c1b3b631efe1a764e824bc4 | refs/heads/main | 2023-04-21T07:37:32.868136 | 2021-05-12T20:32:03 | 2021-05-12T20:32:03 | 350,853,636 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,690 | cpp | Linter.cpp | #include <fstream>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// Implements a very basic (and very badly programmed) variable linter
std::vector<std::string> datatypes{"int"};
std::unordered_map<std::string, std::string>
global; // variable name | variable type global
std::unordered_map<std::string, std::string>
local; // variable name | variable type local
int gettype(std::string &line, std::string *type, size_t pos) {
for (const auto &d : datatypes) {
pos = line.find(d, pos);
if (pos != std::string::npos) {
pos += d.length();
*type = d;
break;
}
}
return pos;
}
// Return true if is a function
size_t getname(std::string &line, std::string *name, size_t pos) {
for (pos++; pos < line.length() && line[pos] != ' ' && line[pos] != ';'; pos++) {
if (line[pos] == '(') {
return pos;
}
(*name) += line[pos];
}
return 0;
}
void checkname(std::string *name) {
if (global.count(*name) > 0) {
std::cerr << "Variable " << *name << " is already declared globally!"
<< "\n";
} else if (local.count(*name) > 0) {
std::cerr << "Variable " << *name << " is already declared locally!"
<< "\n";
}
}
void getparameters(std::string &line, size_t pos, std::string *type,
std::string *name) {
*type = "";
*name = "";
bool b = true;
bool end = false;
for (pos++; pos < line.length(); pos++) {
end = line[pos] == ')';
if (line[pos] == ',' || end) {
checkname(name);
local[*name] = *type;
std::cout << "Param. Type: " << *type << "\n";
std::cout << "Param. Name: " << *name << "\n";
*type = "";
*name = "";
if (end) break;
pos++;
b = !b;
} else if (line[pos] == ' ') {
b = !b;
} else if (b) {
*type += line[pos];
} else {
*name += line[pos];
}
}
}
std::ifstream getfile() {
std::string filePath;
std::ifstream file(filePath);
while (!file.good()) {
std::cout << "Give file path: ";
std::getline(std::cin, filePath);
file = std::ifstream(filePath);
}
return file;
}
void getvalue(std::string &line, std::string *value) {
size_t pos = line.find('=');
if (pos == std::string::npos) {
*value = "";
} else {
for (pos++; pos < line.length(); pos++) {
if (line[pos] == ';') {
return;
} else if (line[pos] != ' ') {
*value += line[pos];
}
}
}
}
void checkvalue(std::string &line, std::string *value, std::string *name) {
getvalue(line, value);
if (value->empty()) {
std::cerr << "Variable " << *name << " may not have been initialized!"
<< "\n";
} else {
std::cout << "Value: " << *value << "\n";
}
}
void processline(std::ifstream &file, std::string &line, std::string *type,
std::string *name, std::string *value, bool &infunction) {
if (line.empty() || line[0] == '/')
return;
else if (line.find('}') && infunction) {
infunction = false;
local.clear();
return;
}
std::cout << "Line: " << line << "\n";
size_t pos = gettype(line, type, 0);
if (!type->empty()) {
size_t length = getname(line, name, pos);
if (length > 0) {
infunction = true;
std::cout << "Function '" << *name << "' start"
<< "\n";
getparameters(line, length, type, name);
} else {
std::cout << "Type: " << *type << "\n";
std::cout << "Name: " << *name << "\n";
checkname(name);
checkvalue(line, value, name);
if (infunction) {
local[*name] = *type;
} else {
global[*name] = *type;
}
}
*type = "";
*name = "";
*value = "";
}
}
void lint(std::ifstream &file) {
std::string line;
bool infunction = false;
if (file.is_open()) {
std::string *type = new std::string;
std::string *name = new std::string;
std::string *value = new std::string;
while (std::getline(file, line)) {
processline(file, line, type, name, value, infunction);
}
delete type;
delete name;
delete value;
}
}
int main() {
std::ifstream file = getfile();
lint(file);
} |
7c4a2867d067ab4620f43a4d77c2ad5269b221cf | fcb0b531dd7a4cfa33138c95c832abfd0e8e59b9 | /course02/homework01/dovile/main.cc | f1bf041cc6884794c7288f7ac52b029413a38dd5 | [] | no_license | wisepotato/cppcourse | 6b29335656dfa8cf9a675c5078a5ffec13be4a77 | 9ad58adc8fbb081f45e337dfa15ace8a69b5cab8 | refs/heads/master | 2022-11-26T09:48:10.734023 | 2020-07-30T15:07:01 | 2020-07-30T15:07:01 | 273,211,760 | 0 | 0 | null | 2020-06-18T10:43:39 | 2020-06-18T10:43:39 | null | UTF-8 | C++ | false | false | 1,892 | cc | main.cc | #include "linked_list.tpp"
#include <cassert>
void test_push_back()
{
LinkedList<int> linkedList;
linkedList.PushBack(0);
assert(!linkedList.Empty());
assert(linkedList.Size() == 1);
}
void test_erase_at()
{
LinkedList<int> linkedList;
linkedList.PushBack(0);
linkedList.PushBack(1);
linkedList.PushBack(2);
linkedList.EraseAt(1);
assert(linkedList.Size() == 2);
}
void test_erase_at_bad()
{
LinkedList<int> linkedList;
bool catchedError = false;
try
{
linkedList.EraseAt(0);
}
catch(std::exception&)
{
catchedError = true;
}
assert(catchedError);
}
void test_get_at()
{
LinkedList<int> linkedList;
linkedList.PushBack(0);
linkedList.PushBack(1);
auto& value = linkedList.At(0);
assert(value == 0);
}
void test_get_at_bad()
{
LinkedList<int> linkedList;
bool catchedError = false;
try
{
linkedList.At(0);
}
catch (std::exception&)
{
catchedError = true;
}
assert(catchedError);
}
void test_print_linked_list()
{
LinkedList<int> linkedList;
linkedList.PushBack(5);
linkedList.PushBack(2);
linkedList.PushBack(7);
std::cout << linkedList << std::endl;
}
void test_iterator()
{
LinkedList<int> linkedList;
linkedList.PushBack(1);
linkedList.PushBack(2);
linkedList.PushBack(3);
int expectedValue = 1;
for (auto value : linkedList)
{
assert(value == expectedValue);
++expectedValue;
}
// test derefernece operator
expectedValue = 1;
for (auto it = linkedList.begin(); it != linkedList.end(); ++it)
{
assert(*it == expectedValue);
++expectedValue;
}
}
int main()
{
#ifdef NDEBUG
#error Compile the code in debug mode!
#endif
test_push_back();
test_erase_at();
test_erase_at_bad();
test_get_at();
test_get_at_bad();
test_print_linked_list();
test_iterator();
return 0;
}
|
1f67dae16f4a16a4dd1f2548378ae7333552f34e | 38e693f73b6c75e37da7e5acadb871f13892fecf | /44/Soal44/Soal44/Source.cpp | fc65f73277005992a983c40e70fc0f283c8c7e83 | [] | no_license | mahdisml/AdvancedProgramming | 649ea8eaec6091ef04b0f3e4a28dc11be3f11a72 | 1096b9348d00133e6c0407d00295e69f7934ad39 | refs/heads/master | 2021-12-24T20:35:51.976823 | 2021-09-30T22:32:11 | 2021-09-30T22:32:11 | 87,694,478 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 356 | cpp | Source.cpp | #include <iostream>
using namespace std;
int End = 0; //for ending
int Temp;
int a; // voroodi
int b;
int Zarb(int a, int b) {
if (b == 1) return a;
return a + Zarb(a, b - 1);
}
void main() {
cout << "Adad aval : ";
cin >> a;
system("cls");
cout << "Adad dovom : ";
cin >> b;
system("cls");
cout << Zarb(a, b);
} |
d865ba0e2a5e8e34e96dafe79eaee1bbd7ed1d9d | c330ff20fae575aaa3cc2cef4997f544477a1f48 | /fancyUI/fcyUIBase/fuiEvent.cpp | 82c898ebe8e02b31bd9ce8bf5841ad3da5bf0766 | [] | no_license | sunnycase/fancy2d | cffd575ead82df42ee645c20c34b6354fa3b510c | d2403cfd3a52508e434beee3e3c0776d07e22050 | refs/heads/master | 2021-01-13T03:33:39.265125 | 2016-12-05T16:32:05 | 2016-12-05T16:32:05 | 77,521,117 | 2 | 1 | null | 2016-12-28T09:36:09 | 2016-12-28T09:36:09 | null | UTF-8 | C++ | false | false | 1,765 | cpp | fuiEvent.cpp | #include "fuiEvent.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////
fuiEventArgs fuiDelegate::EmptyEventArgs;
fuiDelegate::fuiDelegate()
{}
fuiDelegate::fuiDelegate(const fuiDelegate& Right)
: m_FunctorList(Right.m_FunctorList)
{}
fuiDelegate::~fuiDelegate()
{}
fuiDelegate& fuiDelegate::operator=(const fuiDelegate& Right)
{
m_FunctorList = Right.m_FunctorList;
return *this;
}
void fuiDelegate::operator()(fuiControl* pControl, fuiEventArgs* pArgs)
{
Exec(pControl, pArgs);
}
fuiDelegate& fuiDelegate::operator+=(const EventCallBack& CallBack)
{
Append(CallBack);
return *this;
}
void fuiDelegate::Append(const EventCallBack& CallBack)
{
m_FunctorList.push_back(CallBack);
}
void fuiDelegate::Clear()
{
m_FunctorList.clear();
}
void fuiDelegate::Exec(fuiControl* pControl, fuiEventArgs* pArgs)
{
for(vector<EventCallBack>::iterator i = m_FunctorList.begin();
i != m_FunctorList.end();
++i)
{
(*i)(pControl, pArgs);
}
}
////////////////////////////////////////////////////////////////////////////////
void fuiEventSet::RegisterEvent(const std::wstring& Str)
{
m_EventList[Str] = fuiDelegate();
}
void fuiEventSet::ExecEvent(const std::wstring& Str, fuiControl* pControl, fuiEventArgs* pArgs)
{
if(!m_EventFlag[Str])
{
m_EventFlag[Str] = true;
try
{
m_EventList[Str](pControl, pArgs);
}
catch(...)
{
m_EventFlag[Str] = false;
throw;
}
m_EventFlag[Str] = false;
}
}
fuiDelegate& fuiEventSet::GetEvent(const std::wstring& EventName)
{
unordered_map<std::wstring, fuiDelegate>::iterator i = m_EventList.find(EventName);
if(i == m_EventList.end())
throw fcyException("fuiEventSet::GetEvent", "Event is not exist.");
else
return i->second;
}
|
5c7ef9d884816194800f3297b77ddcaaa61c55a6 | 898c761766be7b0db4ea51e50f11953a04da0f50 | /preface/2021-6-12Hard/guess/grader.cpp | 87ab230eb530e713043079bb5d46cbdc05128a16 | [] | no_license | zhoufangyuanTV/zzzz | 342f87de6fdbdc7f8c6dce12649fe96c2c1bcf9c | 1d686ff1bc6adb883fa18d0e110df7f82ebe568d | refs/heads/master | 2023-08-25T03:22:41.184640 | 2021-09-30T12:42:01 | 2021-09-30T12:42:01 | 286,425,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,318 | cpp | grader.cpp | #include "guess.h"
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <vector>
#include <random>
#include <ctime>
#include <unordered_map>
#include <cstdint>
#include <bitset>
using namespace std;
#define LOG(f...) fprintf(stderr, f)
namespace sample_grader {
const char token[] = "Correct!";
mt19937 rng;
const int N = 3005;
const int LOG_LIM = 500;
vector<int> G[N];
int st[16][N * 2];
int lg[N * 2];
int fst[N], dep[N], euler_dfc = 0, dfc = 0;
int dfn[N];
void DFS(int x, int fa = 0) {
st[0][++euler_dfc] = x; fst[x] = euler_dfc;
dfn[++dfc] = x;
if (fa)
G[x].erase(find(begin(G[x]), end(G[x]), fa));
for (int v : G[x]) {
dep[v] = dep[x] + 1;
DFS(v, x);
st[0][++euler_dfc] = x;
}
}
int min_dep(int x, int y) { return dep[x] < dep[y] ? x : y; }
void pre_log2() {
for (int i = 2; i < (N * 2); i <<= 1)
lg[i] = 1;
for (int i = 3; i < (N * 2); ++i)
lg[i] += lg[i - 1];
}
void build_st() {
for (int i = 1; i <= lg[euler_dfc]; ++i)
for (int j = 1, li = euler_dfc - (1 << i) + 1; j <= li; ++j)
st[i][j] = min_dep(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
}
int LCA(int x, int y) {
x = fst[x]; y = fst[y];
if (x > y)
swap(x, y);
int k = lg[y - x + 1];
return min_dep(st[k][x], st[k][y - (1 << k) + 1]);
}
unordered_map<uint32_t, bool> edges;
int cnt_query = 0;
int n, L, data_type;
int reported = 0;
}
int query(const vector<int> &S) {
using namespace sample_grader;
++cnt_query;
if (cnt_query > L)
printf("FAIL : Query limit exceeded\n"), exit(0);
if ((int)S.size() < 2)
printf("FAIL : Query with |S| < 2"), exit(0);
for (int x : S)
if (x < 1 || x > n)
printf("FAIL : Vertex id not in [1, n]\n"), exit(0);
int cnt = S.size();
if (cnt <= LOG_LIM) {
static int A[LOG_LIM];
copy(begin(S), end(S), A);
sort(A, A + cnt, [](int x, int y) { return fst[x] < fst[y]; });
int maxd = -1, pos = 0;
for (int i = 1; i < cnt; ++i) {
if (A[i - 1] == A[i])
printf("FAIL : Duplicate vertices in single query\n"), exit(0);
int D = dep[LCA(A[i - 1], A[i])];
if (D > maxd) {
maxd = D;
pos = LCA(A[i - 1], A[i]);
}
}
return pos;
}
else {
static bitset<N> vis;
vis.reset();
for (int x : S) {
if (vis._Unchecked_test(x))
printf("FAIL : Duplicate vertices in single query\n"), exit(0);
vis._Unchecked_set(x);
}
for (int i = n; i >= 1; --i) {
int cnt = 0;
for (int v : G[dfn[i]])
cnt += vis._Unchecked_test(v);
cnt += vis._Unchecked_test(dfn[i]);
if (cnt >= 2)
return dfn[i];
if (cnt)
vis.set(dfn[i]);
}
printf("GRADER ERROR : Answer not found!\n");
throw;
}
}
void report(int u, int v) {
using namespace sample_grader;
if (u < 1 || u > n)
printf("FAIL : Report u not in [1, n]\n"), exit(0);
if (v < 1 || v > n)
printf("FAIL : Report v not in [1, n]\n"), exit(0);
if (u > v)
swap(u, v);
uint32_t id = uint32_t(u) << 15 | uint32_t(v);
auto it = edges.find(id);
if (it == edges.end())
printf("FAIL : Reported edge (%d, %d) does not exist\n", u, v), exit(0);
if (it->second)
printf("FAIL : Duplicate edge (%d, %d) reported\n", u, v), exit(0);
it->second = true;
++reported;
}
void mian() {
using namespace sample_grader;
pre_log2();
int T;
assert(scanf("%d", &T) == 1);
for (int caseid = 1; caseid <= T; ++caseid) {
euler_dfc = 0; dfc = 0;
assert(scanf("%d%d%d", &n, &L, &data_type) == 3);
edges.clear();
reported = 0;
cnt_query = 0;
for (int i = 1; i <= n; ++i)
G[i].clear();
for (int i = 1; i < n; ++i) {
int u, v;
assert(scanf("%d%d", &u, &v) == 2);
if (u > v)
swap(u, v);
edges.emplace(uint32_t(u) << 15 | uint32_t(v), false);
G[u].emplace_back(v); G[v].emplace_back(u);
}
assert((int)edges.size() == n - 1);
DFS(1);
build_st();
solve(n, L, data_type);
if (reported != n - 1)
printf("FAIL : Some edges not reported\n"), exit(0);
printf("Case %d : %d / %d query\n", caseid, cnt_query, L);
}
printf("%s\n", token);
printf("Real time : %lldms\n", clock() * 1000LL / CLOCKS_PER_SEC);
}
|
eb536748e1114e1c71462f5379b7617acb7d5c75 | 20b0a4d8ae9b3bbf52e06f64155653f4bbdb74a6 | /TestSortHelper.h | 1d8015f8f0f858a3d6cfdea9ca9367e668acb175 | [] | no_license | yuyu232594/C-Program | 7606ca2a1b37332dea6152896f48cfa12c3019f8 | e5708443508a5ac011fdff2d33324e4e4a1ea08d | refs/heads/master | 2022-12-29T00:25:29.930039 | 2020-10-15T02:46:07 | 2020-10-15T02:46:07 | 262,900,266 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 992 | h | TestSortHelper.h | #include <iostream>
#include <ctime>
#include <algorithm>
#include <cassert>
#include <string>
using namespace std;
namespace TestSortHelper{
//生成有n个元素的随机数组,范围是[rangeL,rangeR]
int* generateRandomArray(int n,int rangeL,int rangeR){
assert(rangeL<=rangeR);
int *arr=new int[n];
srand(time(NULL));
for (int i=0;i<n;i++)
arr[i]=rand()%(rangeR-rangeL+1)+rangeL;
return arr;
}
template<typename T>
void printArray(T arr[],int n){
for (int i=0;i<n;i++)
cout<<arr[i]<<" "<<endl;
}
template<typename T>
bool isSorted(T arr[],int n){
for (int i=0;i<n-1;i++)
if (arr[i]>arr[i+1])
return false;
return true;
}
template<typename T>
void testSort(string sortName, void(*sort)(T arr[],int n),T arr[],int n){
//clock_t是一种时钟周期的类型
clock_t startTime=clock();
sort(arr,n);
clock_t endTime=clock();
assert(isSorted(arr,n));
cout<<sortName<<":"<<double(endTime-startTime)/CLOCKS_PER_SEC<<"S"<<endl;
}
} |
ea21ab481e180faf30c4ca231e30dfbd7e0da535 | ee1691aec48eff9a568b2535258f9d3f73f6170f | /src/dataset.cc | 69a56690e430af5ac94adfe0fdc43ad52cd8ae42 | [] | no_license | hemajun815/tensorflow_cc_image_classify | 3590658e5a2baa10d6a459de3aa3307827b5e1d7 | afb29067fb61b3759ab88fa3125dbb6a278a7c62 | refs/heads/master | 2021-05-02T14:49:37.503671 | 2018-02-28T02:40:01 | 2018-02-28T02:40:01 | 120,726,922 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,045 | cc | dataset.cc | #include "dataset.h"
#include <dirent.h> // opendir
#include <cstring> // strcmp
#include <algorithm> // random_shuffle
#include <sstream> // std::stringstream
Dataset::Dataset(const std::string &parent_dir)
{
this->m_p_index = new int(0);
this->m_p_vct_filename = new std::vector<std::string>();
if (!this->load_filenames(parent_dir))
throw "Failed to load filenames.";
}
Dataset::~Dataset()
{
delete this->m_p_vct_filename;
delete this->m_p_index;
}
int Dataset::size()
{
return this->m_p_vct_filename->size();
}
void Dataset::shuffle()
{
random_shuffle(this->m_p_vct_filename->begin(), this->m_p_vct_filename->end());
}
void Dataset::reset()
{
this->m_p_index = new int(0);
}
bool Dataset::get_batch(const int &batch_size, std::vector<std::string> &vct_filename, std::vector<int> &vct_label)
{
if (*this->m_p_index + batch_size > this->size())
return false;
vct_filename.clear();
vct_label.clear();
for (auto i = 0; i < batch_size; i++)
{
auto filename = this->m_p_vct_filename->at(*this->m_p_index + i);
vct_filename.push_back(filename);
auto found = filename.find_last_of("/\\");
auto str_label = filename.substr(found - 1, 1);\
auto label = 0;
std::stringstream(str_label) >> label;
vct_label.push_back(label);
}
*this->m_p_index += batch_size;
return true;
}
bool Dataset::load_filenames(const std::string &parent_dir)
{
auto p_dir = opendir(parent_dir.data());
if (p_dir)
{
struct dirent *p_file = nullptr;
while (p_file = readdir(p_dir))
{
if (0 == strcmp(p_file->d_name, ".") || 0 == strcmp(p_file->d_name, ".."))
continue;
if (p_file->d_type == DT_DIR)
this->load_filenames(parent_dir + '/' + p_file->d_name);
else
this->m_p_vct_filename->push_back(parent_dir + '/' + p_file->d_name);
}
closedir(p_dir);
return true;
}
return false;
} |
95165e478361a0f539bba23857cf49c14f466a21 | 162bb2cceaa60eb8c251e5cda8432b77ae98e0a2 | /UnigramTagger/emissionParameters.h | 0936d9efa9f5fb80d128ffadb32f18a05689c2a8 | [] | no_license | CanisMinor/RosettaGram | 289d242e379a681b42a96d746fbd1cf80ea96b2e | 01655f4ced2783e746d08c09ce65c093057fe096 | refs/heads/master | 2020-04-10T15:51:03.802854 | 2014-07-06T18:55:23 | 2014-07-06T18:55:31 | 21,235,881 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 257 | h | emissionParameters.h | #ifndef EMISSIONPARAMETER_H
#define EMISSIONPARAMETER_H
std::map<std::vector<std::string>, double> emissionParameters(const std::string);
std::map<std::string,std::string> findMaxEmission(std::map<std::vector<std::string>, double>);
#endif
|
af3dad526ec9ad34011614af77f8bcde27cff72e | 74c6be2131adae09b4238af4cf658b7ce8227d25 | /src/52.cpp | d96f88b17f55fd92b15292bfed338db3950d25f2 | [] | no_license | Ricardo-L-C/leetcode_problems | 62f0aa236bd21141ffe085798aaa27dd85079df4 | acbcb9e77eb2647b0c458c29eddf67b080637493 | refs/heads/master | 2021-02-08T05:14:14.721937 | 2020-03-12T09:37:34 | 2020-03-12T09:37:34 | 244,112,963 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 932 | cpp | 52.cpp | #include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<algorithm>
using namespace std;
class Solution
{
public:
int ans = 0;
vector<int> cur;
int n;
int totalNQueens(int n)
{
this->n = n;
dfs(0);
return this->ans;
}
void dfs(int depth)
{
if (depth == n)
{
++this->ans;
return;
}
for (int i = 0; i < n; ++i)
{
if (check(depth, i))
{
cur.push_back(i);
dfs(depth + 1);
cur.pop_back();
}
}
}
bool check(int x, int y)
{
if (x == 0)
return true;
for (auto i = 0; i < cur.size(); ++i)
if (y == cur[i] || abs(y - cur[i]) == x - i)
return false;
return true;
}
};
int main()
{
Solution a;
} |
5804a57accac9488053d2e55a4e2f197e0c62159 | 433a2faf5a215307165a67a5b7e8a3632c7e87a2 | /基礎題庫/a032.cpp | ea0487f88381886948ca3fda3469e6ad03c06057 | [] | no_license | evo960225/GreenJudge | 79cccb7280b9fcb99f811738d54f5c5d3d67bd70 | 37aa7e96294121f1c1a558e4a91ccbc67cea1caf | refs/heads/master | 2021-10-24T03:59:29.169539 | 2021-10-13T06:45:29 | 2021-10-13T06:45:29 | 13,683,843 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 223 | cpp | a032.cpp | #include<iostream>
using namespace std;
int main(){
char ch;
int a,b;
while(cin>>a>>ch>>b){
if(ch=='+'){
cout<<a+b<<endl;
}else if(ch=='-'){
cout<<a-b<<endl;
}else{
cout<<a*b<<endl;
}
}
return 0;
}
|
27c4d6720216512e4a4a871a96fd62f6802713a0 | 3d6882fb5bd9b80296157d26ab3c1f5dbfee2767 | /Classes/OpeningScene.h | 996c4f21322be0ed7906d39af4427213c03e225f | [] | no_license | Thumbby/2018-Tongji-SE-C-program-MOBA | 9412d243f70da1bb8907a63092d94e263f186231 | b234709e9b50737989bf84673d741e8ce93d5fbf | refs/heads/master | 2020-05-14T02:28:00.523744 | 2019-06-16T15:01:50 | 2019-06-16T15:01:50 | 181,690,006 | 8 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 418 | h | OpeningScene.h | #ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
class OpeningScene : public cocos2d::Scene
{
public:
static cocos2d::Scene* createScene();
virtual bool init();
// a selector callback
void menuCloseCallback(cocos2d::Ref* pSender);
// implement the "static create()" method manually
CREATE_FUNC(OpeningScene);//ºê²Ù×÷
};
#endif // __HELLOWORLD_SCENE_H__ |
b7c89560248de4c9ffd1de23327a6276f1bc967a | c0120490cd9d0fd98a835eb1e495020356778dfd | /48hrs/main.cpp | 3bb2b9f781e37dab443d8768b819e53676351d4c | [
"MIT"
] | permissive | wgoddard/fab-48hr-game-jam-2009 | 5a8f1e80fe3f7585547b8e5d4a77047fbe93b264 | 5f7d41b38a117d1abc159651fc23a0e736d49d4a | refs/heads/master | 2021-01-19T17:14:01.770361 | 2014-03-16T09:59:46 | 2014-03-16T09:59:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 23,525 | cpp | main.cpp | #include "global.h"
#include "XInput.h"
#include "StaticGraphic.h"
#include <ctime>
#include "Girly.h"
#include "Bouncer.h"
#include "Fan.h"
#include "Bullet.h"
#include "Box.h"
#include "Prince.h"
#include "HealthUp.h"
#include "SuperUp.h"
#include "TempGraphic.h"
std::vector <Player*> players;
std::vector <Enemy*> enemies;
std::vector <Entity *> entities;
std::vector <hgeRectExt> tempBoundingBoxes;
std::vector <Bullet *> bullets;
std::vector <PowerUp *> powerups;
std::vector <TempGraphic *> tempGraphics;
StaticGraphic * titleScreen;
StaticGraphic * background;
StaticGraphic * loseScreen;
StaticGraphic * winScreen;
StaticGraphic * riotScreen;
StaticGraphic * obscenityScreen;
StaticGraphic * gust;
StaticGraphic * options;
Prince * prince;
int currentRound = 0;
int currentStorm = 0;
float timeToFinish = 0;
bool Intro();
bool FrameFunc();
bool RenderFunc();
bool TitleFrame();
bool TitleRender();
bool MenuFrame();
bool MenuRender();
bool CreditsFrame();
bool CreditsRender();
bool PauseFrame();
bool PauseRender();
float levelTime = 50;
int currentLevel = 0;
int spawned = 0;
void Reset()
{
hge->System_SetState(HGE_FRAMEFUNC, TitleFrame);
hge->System_SetState(HGE_RENDERFUNC, TitleRender);
currentLevel = 1;
levelTime = 0;
spawned = 0;
for (unsigned int i = 0; i < entities.size(); ++i)
delete entities[i];
entities.clear();
entities.push_back(new Box("poops.png", 0, 350, 150, S_HEIGHT, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 0, 0, S_WIDTH, 200, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 0, S_HEIGHT-70, S_WIDTH, 70, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 150, 360, 178, 156, 0x00FFFFFF));
//entities.push_back(new Box("poops.png", S_WIDTH, 0, 20, S_HEIGHT, 0x00FFFFFF));
//entities.push_back(new StaticGraphic("plant.png", 200, 40, 107, 163, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*2, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*4, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*6, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*8, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*2, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*4, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*6, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*8, S_HEIGHT-163, 130, 184, 0));
delete gust;
gust = new StaticGraphic("gust.png", S_WIDTH + 500, S_HEIGHT/2, 826, 688, 0, true);
prince = new Prince("prince.png", 70, 160, 96, 96);
entities.push_back(prince);
enemies.clear();
players.clear();
tempGraphics.clear();
bullets.clear();
powerups.clear();
}
bool GetXKey(DWORD key)
{
PLUGGED_IN = 0;
for (unsigned int i = 0; i < NUMBER_PLAYERS; ++i )
{
DWORD dwResult;
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
dwResult = XInputGetState( i, &state );
if (dwResult == ERROR_SUCCESS)
PLUGGED_IN++;
else
break;
//if (state.Gamepad.sThumbLX > 10276 || state.Gamepad.sThumbLX < -10276 || state.Gamepad.sThumbLY > 10000 || state.Gamepad.sThumbLY < -10000)
//players[i]->Move(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY, dt);
//if (state.Gamepad.bRightTrigger > 100)
// players[i]->AttackC();
//if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
//{
// sheep[i]->HoldKeyA();
//}
XINPUT_KEYSTROKE keystroke;
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
for (dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke); dwResult == ERROR_SUCCESS; dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke))
{
if (keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN)
{
if (keystroke.VirtualKey == key)
return true;
//if (keystroke.VirtualKey == VK_PAD_B)
// players[i]->AttackB();
//if (keystroke.VirtualKey == VK_PAD_X)
// sheep[i]->PressKeyC();
}
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
}
}
return false;
}
bool obscenityFrame()
{
float dt = hge->Timer_GetDelta();
GENERIC_COUNTDOWN -= dt;
if (GENERIC_COUNTDOWN < 0)
{
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
}
return false;
}
bool obscenityRender()
{
hge->Gfx_BeginScene();
obscenityScreen->Render();
hge->Gfx_EndScene();
return false;
}
bool riotFrame()
{
float dt = hge->Timer_GetDelta();
GENERIC_COUNTDOWN -= dt;
if (GENERIC_COUNTDOWN < 0)
{
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
}
return false;
}
bool riotRender()
{
hge->Gfx_BeginScene();
riotScreen->Render();
hge->Gfx_EndScene();
return false;
}
bool lastFrame()
{
if (hge->Input_GetKeyState(HGEK_ENTER) || GetXKey(VK_PAD_START))
{
hge->Channel_StopAll();
Reset();
//hge->System_SetState(HGE_FRAMEFUNC, CreditsFrame);
//hge->System_SetState(HGE_RENDERFUNC, CreditsRender);
//fnt->SetColor(0xFFFFFFFF);
}
return false;
}
bool winRender()
{
//player sound
//show text
static StaticGraphic fade("nofilehere.png", 0, 0, S_WIDTH, S_HEIGHT, 0);
static DWORD color = 0x00000000;
static short alpha = 0;
if (alpha < 255 * 2)
{
alpha++;
color = 0 | (alpha/2 << 24);
fade.GetSprite().SetColor(color);
}
hge->Gfx_BeginScene();
fade.Render();
winScreen->Render();
hge->Gfx_EndScene();
return false;
}
bool loseRender()
{
//player sound
//show text
static StaticGraphic fade("nofilehere.png", 0, 0, S_WIDTH, S_HEIGHT, 0);
static DWORD color = 0x00000000;
static short alpha = 0;
if (alpha < 255 * 2)
{
alpha++;
color = 0 | (alpha/2 << 24);
fade.GetSprite().SetColor(color);
}
hge->Gfx_BeginScene();
fade.Render();
loseScreen->Render();
hge->Gfx_EndScene();
return false;
}
float creditsPosition = S_HEIGHT;
bool CreditsFrame()
{
creditsPosition -= 0.5f;
if (creditsPosition < -800)
creditsPosition = S_HEIGHT;
if (hge->Input_GetKey())
return true;
return false;
}
bool CreditsRender()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
fnt->printf(S_WIDTH/2, creditsPosition, HGETEXT_CENTER, "%s%s%s%s%s",
"Credits (Alphabetical)\n\n\n",
"*Design*\n----\nKrystal Condren\nNathan Perry\nPaul Fox\nWilliam Goddard\nYing Luo", "\n\n\n*Programming*\n----\nWilliam Goddard",
"\n\n\n*Art Work*\n----\nKrystal Condren\nNathan Perry\nYing Luo", "\n\n\n*Tools*\n----\nPaul Fox");
hge->Gfx_EndScene();
return false;
}
int pauseOption = 0;
bool PauseFrame()
{
if (hge->Input_KeyDown(HGEK_ESCAPE))
{
hge->Channel_ResumeAll();
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
return false;
}
bool start = false;
bool up = false;
bool down = false;
PLUGGED_IN = 0;
for (unsigned int i = 0; i < NUMBER_PLAYERS; ++i )
{
DWORD dwResult;
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
dwResult = XInputGetState( i, &state );
if (dwResult == ERROR_SUCCESS)
PLUGGED_IN++;
else
break;
//if (state.Gamepad.sThumbLX > 10276 || state.Gamepad.sThumbLX < -10276 || state.Gamepad.sThumbLY > 10000 || state.Gamepad.sThumbLY < -10000)
//players[i]->Move(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY, dt);
//if (state.Gamepad.bRightTrigger > 100)
// players[i]->AttackC();
//if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
//{
// sheep[i]->HoldKeyA();
//}
XINPUT_KEYSTROKE keystroke;
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
for (dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke); dwResult == ERROR_SUCCESS; dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke))
{
if (keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN)
{
if (keystroke.VirtualKey == VK_PAD_START)
start = true;
if (keystroke.VirtualKey == VK_PAD_LTHUMB_UP)
up = true;
if (keystroke.VirtualKey == VK_PAD_LTHUMB_DOWN)
down = true;
//if (keystroke.VirtualKey == VK_PAD_B)
// players[i]->AttackB();
//if (keystroke.VirtualKey == VK_PAD_X)
// sheep[i]->PressKeyC();
}
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
}
}
if (hge->Input_KeyDown(HGEK_DOWN) || down)
pauseOption++;
if (hge->Input_KeyDown(HGEK_UP) || up)
pauseOption--;
if (pauseOption < 0) pauseOption = 2;
if (pauseOption > 2) pauseOption = 0;
if (hge->Input_KeyDown(HGEK_ENTER) || start)
{
switch(pauseOption)
{
case 0:
hge->Channel_ResumeAll();
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
return false;
break;
case 1:
hge->Channel_StopAll();
Reset();
return false;
break;
case 2:
/////////////////
hge->System_SetState(HGE_FRAMEFUNC, CreditsFrame);
hge->System_SetState(HGE_RENDERFUNC, CreditsRender);
return false;
break;
}
}
return false;
}
bool PauseRender()
{
hge->Gfx_BeginScene();
//hge->Gfx_Clear(0);
static StaticGraphic temp("sss", S_WIDTH/2 - 100, 100, 300, 450, 0);
temp.GetSprite().SetColor(0x88000000);
temp.Render();
fnt->printf(S_WIDTH/2, 200, HGETEXT_LEFT, "Resume");
fnt->printf(S_WIDTH/2, 300, HGETEXT_LEFT, "Restart");
fnt->printf(S_WIDTH/2, 400, HGETEXT_LEFT, "Exit");
int selection = 0;
switch(pauseOption)
{
case 0:
selection = 200;
break;
case 1:
selection = 300;
break;
case 2:
selection = 400;
break;
default:
break;
}
fnt->printf(S_WIDTH/2 - 50, selection, HGETEXT_LEFT, "*");
hge->Gfx_EndScene();
return false;
}
bool TitleFrame()
{
if (hge->Input_GetKeyState(HGEK_ENTER) || GetXKey(VK_PAD_START))
{
hge->System_SetState(HGE_FRAMEFUNC, MenuFrame);
hge->System_SetState(HGE_RENDERFUNC, MenuRender);
fnt->SetColor(0xFFFFFFFF);
}
return false;
}
bool TitleRender()
{
static BYTE alpha = 0;
static bool up = true;
if (up)
alpha++;
else
alpha--;
if (alpha >= 255) up = false;
else if (alpha <= 0) up = true;
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
titleScreen->Render();
fnt->SetColor((alpha << 24) + 0xFFFFFF);
fnt->printf(S_WIDTH/2, 680, HGETEXT_CENTER, "Press START to continue.");
hge->Gfx_EndScene();
return false;
}
bool MenuFrame()
{
PLUGGED_IN = 0;
for (unsigned int i = 0; i < MAX_CONTROLLERS; ++i )
{
DWORD dwResult;
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
dwResult = XInputGetState( i, &state );
if (dwResult == ERROR_SUCCESS)
PLUGGED_IN++;
if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
std::cout << "Controller " << i << " x " << state.Gamepad.sThumbLX << " y " << state.Gamepad.sThumbLY << '\n';
}
if (hge->Input_KeyDown(HGEK_ENTER) || GetXKey(VK_PAD_START))
{
hge->System_SetState(HGE_FRAMEFUNC, Intro);
hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
hge->Stream_Play(music, true);
timeToFinish = 60.0f;
currentRound = 1;
currentStorm = 1;
players.push_back(new Girly("girl real.png", 500, 500, 96, 96));
//players.push_back(new Girly("girl2.png", 700, 500, 96, 96));
players.push_back(new Bouncer("bouncer.png", 700, 500, 96, 96));
//enemies.push_back(new Fan("Boss.png", S_WIDTH - 400, hge->Random_Int(300, S_HEIGHT-100), 288, 288, 1, 1, 50 + 10 * currentLevel, 5, true));
for (int i = 0; i < players.size(); ++i)
{
entities.push_back(players[i]);
}
}
return false;
}
bool MenuRender()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
options->Render();
//fnt->printf(S_WIDTH/2, 300, HGETEXT_CENTER, "%d players selected.", NUMBER_PLAYERS);
fnt->printf(S_WIDTH/2, 500, HGETEXT_CENTER, "%d controllers plugged in.", PLUGGED_IN);
hge->Gfx_EndScene();
return false;
}
bool Intro()
{
/////////////////////
///Skip this shit
hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
return false;
////////////////
}
bool FrameFunc()
{
float dt=hge->Timer_GetDelta();
int size = entities.size();
for (unsigned int i = 0; i < size; ++i)
entities[i]->Update(dt);
size = bullets.size();
for (unsigned int i = 0; i < size; ++i)
bullets[i]->Update(dt);
for (unsigned int i = 0; i < tempGraphics.size(); ++i)
{
tempGraphics[i]->Update(dt);
if (tempGraphics[i]->IsAlive() == false)
{
delete tempGraphics[i];
tempGraphics.erase(tempGraphics.begin() + i);
}
}
for (unsigned int i = 0; i < enemies.size(); ++i)
{
if (enemies[i]->IsAlive() == false)
{
Entity * temp = enemies[i];
delete enemies[i];
enemies.erase(enemies.begin() + i );
for (unsigned int j = 0; j < entities.size(); ++j)
{
if (entities[j] == temp)
{
entities.erase(entities.begin() + j);
break;
}
}
//enemies[i] = NULL;
--i;
}
}
for (unsigned int i = 0; i < bullets.size(); ++i)
{
if (bullets[i]->IsAlive() == false)
{
delete bullets[i];
bullets.erase(bullets.begin() + i);
}
}
gust->MoveLeft(dt);
int fps = hge->Timer_GetFPS();
if (fps < 5)
fps = 5;
//int lucky = hge->Random_Int(0, fps*50);
int lucky = rand() % (fps*50);
//std::cout << lucky << '\n';
if (lucky == fps*50 - 1)
powerups.push_back(new HealthUp("Health.png", hge->Random_Int(200, 500), hge->Random_Int(200, S_HEIGHT-100), 96, 96));
lucky = hge->Random_Int(0, fps*50);
if (lucky == fps*50)
powerups.push_back(new SuperUp("Power.png", hge->Random_Int(200, 500), hge->Random_Int(200, S_HEIGHT-100), 96, 96));
static float time = 0;
time += dt;
levelTime += dt;
if (currentLevel % 3 == 0 && spawned == 0 && currentLevel > 0)
{
Enemy * temp = new Fan("girl.png", S_WIDTH - 400, hge->Random_Int(300, S_HEIGHT-100), 48, 48, 8, 8, 50 + 10 * currentLevel, 5, true);
while ( temp->Collide() )
{
temp->SetPosition(hge->Random_Int(S_WIDTH - 200, S_WIDTH + 600), hge->Random_Int(300, S_HEIGHT-100));
}
enemies.push_back(temp);
entities.push_back(temp);
spawned++;
}
else if (time > 0.1 && enemies.size() < 100 && spawned < 100)
{
for (unsigned int i = 0; i < 3; ++i)
{
Enemy * temp = new Fan("girl.png", hge->Random_Int(S_WIDTH-50, S_WIDTH+500), hge->Random_Int(250, S_HEIGHT-100), 48, 48, 1, 1, 1, currentLevel/2 + 1);
while (temp->Collide())
{
float tempx = temp->GetX();
temp->SetPosition(tempx + 50, hge->Random_Int(200, S_HEIGHT-100));
}
enemies.push_back(temp);
entities.push_back(temp);
}
time = 0;
spawned++;
}
if (levelTime >= 30 && currentLevel < 7)
{
levelTime = 0;
time = 0;
spawned = 0;
currentLevel++;
for (unsigned int i = 0; i < 30; ++i)
{
Enemy * temp = new Fan("girl.png", hge->Random_Int(S_WIDTH-50, S_WIDTH+500), hge->Random_Int(250, S_HEIGHT-100), 48, 48, 1, 1, 1, currentLevel/2 + 1);
while (temp->Collide())
{
float tempx = temp->GetX();
temp->SetPosition(tempx + 50, rand() % (S_HEIGHT-100) + 200);
}
enemies.push_back(temp);
entities.push_back(temp);
}
gust->SetPosition(S_WIDTH+500, S_HEIGHT/2);
}
if (currentLevel == 7)
{
hge->System_SetState(HGE_FRAMEFUNC, lastFrame);
hge->System_SetState(HGE_RENDERFUNC, winRender);
}
PLUGGED_IN = 0;
for (unsigned int i = 0; i < NUMBER_PLAYERS; ++i )
{
DWORD dwResult;
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
dwResult = XInputGetState( i, &state );
if (dwResult == ERROR_SUCCESS)
PLUGGED_IN++;
else
break;
//if (state.Gamepad.sThumbLX > 10276 || state.Gamepad.sThumbLX < -10276 || state.Gamepad.sThumbLY > 10000 || state.Gamepad.sThumbLY < -10000)
players[i]->Move(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY, dt);
if (state.Gamepad.bRightTrigger > 100)
players[i]->AttackC();
//if (state.Gamepad.wButtons & XINPUT_GAMEPAD_A)
//{
// sheep[i]->HoldKeyA();
//}
XINPUT_KEYSTROKE keystroke;
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
for (dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke); dwResult == ERROR_SUCCESS; dwResult = XInputGetKeystroke(i, XINPUT_FLAG_GAMEPAD, &keystroke))
{
if (keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN)
{
if (keystroke.VirtualKey == VK_PAD_A)
players[i]->AttackA();
if (keystroke.VirtualKey == VK_PAD_B)
players[i]->AttackB();
if (keystroke.VirtualKey == VK_PAD_START)
{
hge->System_SetState(HGE_FRAMEFUNC, PauseFrame);
hge->System_SetState(HGE_RENDERFUNC, PauseRender);
hge->Channel_PauseAll();
}
//if (keystroke.VirtualKey == VK_PAD_X)
// sheep[i]->PressKeyC();
}
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
}
}
if (PLUGGED_IN == 0)
{
int xm = 0, ym = 0;
if (hge->Input_GetKeyState(HGEK_LEFT))
xm = -32767;
else if (hge->Input_GetKeyState(HGEK_RIGHT))
xm = 32767;
if (hge->Input_GetKeyState(HGEK_UP))
ym = 32767;
else if (hge->Input_GetKeyState(HGEK_DOWN))
ym = -32767;
players[0]->Move(xm, ym, dt);
if (hge->Input_GetKeyState(HGEK_Z))
{
players[0]->AttackA();
}
if (hge->Input_GetKeyState(HGEK_X))
{
players[0]->AttackB();
}
if (hge->Input_GetKeyState(HGEK_C))
{
players[0]->AttackC();
}
}
if (hge->Input_KeyDown(HGEK_D))
{
DEBUG = !DEBUG;
hge->System_SetState(HGE_HIDEMOUSE, !DEBUG);
}
if (DEBUG)
{
//std::cout << "Boxes size: " << tempBoundingBoxes.size() << '\n';
for (unsigned int i = 0; i < tempBoundingBoxes.size(); ++i)
{
if (tempBoundingBoxes[i].Update(dt))
{
tempBoundingBoxes.erase(tempBoundingBoxes.begin() + i);
--i;
}
}
}
if (hge->Input_KeyDown(HGEK_ESCAPE))
{
hge->Channel_PauseAll();
hge->System_SetState(HGE_FRAMEFUNC, PauseFrame);
hge->System_SetState(HGE_RENDERFUNC, PauseRender);
return false;
}
return false;
}
bool RenderFunc()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);
//for (unsigned int i = 0; i < graphics.size(); ++i)
// graphics[i]->Render();
background->Render();
int size = tempGraphics.size();
for (unsigned int i = 0; i < size; ++i)
tempGraphics[i]->Render();
size = entities.size();
for (unsigned int i = size - 1; i > 0; --i)
entities[i]->Render();
for (unsigned int i = 0; i < bullets.size(); ++i)
bullets[i]->Render();
for (unsigned int i = 0; i < powerups.size(); ++i)
powerups[i]->Render();
//fnt->printf(20, 20, HGETEXT_LEFT, "%d FPS", hge->Timer_GetFPS());
if (PLUGGED_IN < NUMBER_PLAYERS)
fnt->printf(S_WIDTH/2, 100, HGETEXT_CENTER, "Please enable %d controllers.", NUMBER_PLAYERS-PLUGGED_IN);
for (unsigned int i = 0; i < NUMBER_PLAYERS; ++i)
{
fnt->printf(10, S_HEIGHT/2 + i * 35, HGETEXT_LEFT, "Score %d", players[i]->GetScore());
}
if (currentLevel < 6)
{
fnt->printf(S_WIDTH/2, 20, HGETEXT_CENTER, "%.2f seconds until storm worsens.", (30-levelTime));
fnt->printf(S_WIDTH/2, 50, HGETEXT_CENTER, "Storm Category %d", currentLevel);
}
else
fnt->printf(S_WIDTH/2, 50, HGETEXT_CENTER, "Eye of the storm!");
if (DEBUG)
{
fnt->printf(5, 5, HGETEXT_LEFT, "dt:%.3f\nFPS:%d", hge->Timer_GetDelta(), hge->Timer_GetFPS());
for (unsigned int i = 0; i < tempBoundingBoxes.size(); ++i)
tempBoundingBoxes[i].Render();
}
//hge->Gfx_RenderLine(0,500,500,501);
gust->Render();
static StaticGraphic redfade ("nopoops.png", 0, 0, S_WIDTH, S_HEIGHT, 0);
RED_FADE_ALPHA-=2;
if (RED_FADE_ALPHA < 0)
RED_FADE_ALPHA = 0;
redfade.GetSprite().SetColor(0x00FF0000 | (RED_FADE_ALPHA << 24));
redfade.Render();
hge->Gfx_EndScene();
return false;
}
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
//int main (int argc, char * argv[])
{
hge = hgeCreate(HGE_VERSION);
hge->System_SetState(HGE_LOGFILE, LOGFILE.c_str());
hge->System_SetState(HGE_FRAMEFUNC, TitleFrame);
hge->System_SetState(HGE_RENDERFUNC, TitleRender);
// hge->System_SetState(HGE_EXITFUNC, ExitFunc);
hge->System_SetState(HGE_TITLE, NAME.c_str());
hge->System_SetState(HGE_FPS, 100);
hge->System_SetState(HGE_WINDOWED, S_WINDOWED);
hge->System_SetState(HGE_SCREENWIDTH, S_WIDTH);
hge->System_SetState(HGE_SCREENHEIGHT, S_HEIGHT);
hge->System_SetState(HGE_SCREENBPP, S_BPP);
hge->System_SetState(HGE_ZBUFFER, true);
hge->System_SetState(HGE_SHOWSPLASH, false);
if (DEBUG)
hge->System_SetState(HGE_HIDEMOUSE, !DEBUG);
if(hge->System_Initiate())
{
hge->Resource_AttachPack("resource.pak");
DWORD dwResult;
for (DWORD i=0; i< MAX_CONTROLLERS; i++ )
{
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );
// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &state );
if( dwResult == ERROR_SUCCESS )
{
std::cout << "Controller " << i << " connected\n";
}
else
{
std::cout << "Controller " << i << " not conntected\n"; // Controller is not connected
}
}
// Load a font
fnt=new hgeFont("font1.fnt");
fnt->SetZ(0.0f);
particles = new hgeSprite(resource.GetTexture("particles.png"), 32, 0, 32, 32);
titleScreen = new StaticGraphic(TITLE_GRAPHIC, 0, 0, S_WIDTH, S_HEIGHT, 1.0f, false);
background = new StaticGraphic("Map copy.png", 0, 0, S_WIDTH, S_HEIGHT, 1.0f, false);
loseScreen = new StaticGraphic("lose.png", 0, 0, S_WIDTH, S_HEIGHT, 0.0f, false);
winScreen = new StaticGraphic("win.png", 0, 0, S_WIDTH, S_HEIGHT, 0.0f, false);
riotScreen = new StaticGraphic("RIOT.png", 0, 0, S_WIDTH, S_HEIGHT, 0, false);
options = new StaticGraphic("options.png", 0, 0, S_WIDTH, S_HEIGHT, 0, false);
obscenityScreen = new StaticGraphic("OBSCENITY.png", 0, 0, S_WIDTH, S_HEIGHT, 0.0f, false);
gust = new StaticGraphic("gust.png", S_WIDTH + 500, S_HEIGHT/2, 826, 688, 0, true);
bar = hge->Texture_Load("bar.png");
punch = hge->Effect_Load("punch.wav");
music = hge->Stream_Load("Knife Fight.mp3");
entities.push_back(new Box("poops.png", 0, 350, 150, S_HEIGHT, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 0, 0, S_WIDTH, 200, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 0, S_HEIGHT-70, S_WIDTH, 70, 0x00FFFFFF));
entities.push_back(new Box("poops.png", 150, 360, 178, 156, 0x00FFFFFF));
//entities.push_back(new Box("poops.png", S_WIDTH, 0, 20, S_HEIGHT, 0x00FFFFFF));
//entities.push_back(new StaticGraphic("plant.png", 200, 40, 107, 163, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*2, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*4, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*6, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*8, 40, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*2, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*4, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*6, S_HEIGHT-163, 130, 184, 0));
entities.push_back(new StaticGraphic("plant.png", 200+107*8, S_HEIGHT-163, 130, 184, 0));
prince = new Prince("prince.png", 70, 160, 96, 96);
entities.push_back(prince);
hge->Random_Seed();
srand(time(NULL));
hge->System_Start();
for (unsigned int i = 0; i < entities.size(); ++i)
delete (entities[i]);
delete fnt;
delete titleScreen;
delete background;
delete loseScreen;
delete riotScreen;
delete obscenityScreen;
delete particles;
delete options;
resource.Purge();
hge->Texture_Free(bar);
hge->Effect_Free(punch);
hge->Stream_Free(music);
}
// Clean up and shutdown
hge->System_Shutdown();
hge->Release();
//exit(0);
return 0;
}
|
60122ada9d74cb0f6f0bb25fbc0b43042fd1260c | cdc524f626c5c982ebe744234ec8b00dae5eeca1 | /main.cpp | 60585f89fd8ac15066c9c2898ac0180cf0784f02 | [] | no_license | Neroli1108/PerformanceProfiler | 68b1e13576516667fb8176c11630ec452ae355c0 | c4d0d3a9441679613e6766d94fe698379afd031b | refs/heads/master | 2020-03-27T04:02:14.969282 | 2018-08-27T22:52:20 | 2018-08-27T22:52:20 | 145,907,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 515 | cpp | main.cpp | #include "PerformanceProfiler.h"
int main(int argc, char *argv[])
{
std::string mark = argv[1];
if (mark == "performance")
{
Converter *converter = new Converter(argv[2], argv[3]);
converter->writeSummary();
}
else if (mark == "show")
{
Converter *converter = new Converter(argv[2], atoi(argv[3]));
converter->showSpecificdata(std::atoi(argv[3]));
}
else
{
std::cout << "the number of the arguments is not correct." << std::endl;
}
}
|
0d69090179f6335e0c01e66f22545fb2261b4b62 | cfa955080fae0b3b8674ae339fbec99a9cd0fc6d | /week-2/day-3/PurpleSteps.cpp | 4287723c26856ce3770536df37e7ab5b519abc5d | [] | no_license | green-fox-academy/Csano97 | bfd77f3adb85a584537a54ad0242bee658c7b381 | 09abc43750c4029b1492a9727f186fb51863f815 | refs/heads/master | 2020-06-09T23:31:01.583756 | 2019-09-19T12:29:56 | 2019-09-19T12:29:56 | 193,527,586 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 651 | cpp | PurpleSteps.cpp | #include "draw.h"
// Reproduce this:
// [https://github.com/green-fox-academy/teaching-materials/blob/master/workshop/drawing/assets/r3.png]
// Pay attention for the outlines as well
void draw(SDL_Renderer *gRenderer)
{
int x = 0;
int y = 0;
for (int i = 0; i < 20; ++i) {
SDL_SetRenderDrawColor(gRenderer, 118, 29, 150, 0xFF);
SDL_Rect SDL_RectEmpty = {x, y, 25, 25};
SDL_RenderDrawRect(gRenderer, &SDL_RectEmpty);
SDL_SetRenderDrawColor(gRenderer, 153, 63, 186, 0xFF);
SDL_Rect fillRect = {x, y, 23, 23};
SDL_RenderFillRect(gRenderer, &fillRect);
x += 25;
y += 25;
}
} |
a9695743e1f94a006450b38e5b01ee5e9a8c4ee3 | a03f0716497436d4cfb6038b1f6c7684e20d3a54 | /RandomCityGame/City Of AMaze_BackUpThisFolder_ButDontShipItWithYourGame/il2cppOutput/Bulk_UnityEngine.InputModule_0.cpp | a6b655393e3983dee4b147d678579b6b0d60033f | [
"MIT"
] | permissive | ComarPers922/AI-based-3D-Game-Simulator | 963384eb9bae4f1d5f25bd5f2cf2e17ae620ccf4 | 3346702e000f1497c4fde392196e31f0c6412762 | refs/heads/master | 2020-05-19T17:28:29.979864 | 2019-05-08T06:28:04 | 2019-05-08T06:28:04 | 185,133,975 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 36,903 | cpp | Bulk_UnityEngine.InputModule_0.cpp | #include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <cstring>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <limits>
#include <assert.h>
#include <stdint.h>
#include "il2cpp-class-internals.h"
#include "codegen/il2cpp-codegen.h"
#include "il2cpp-object-internals.h"
// System.Action`1<System.Int32Enum>
struct Action_1_tABA1E3BFA092E3309A0ECC53722E4F9826DCE983;
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>
struct Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1;
// System.Action`2<System.Int32,System.Object>
struct Action_2_tCC05A68F0FC31E84E54091438749644062A6C27F;
// System.Action`2<System.Int32,System.String>
struct Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36;
// System.Action`3<System.Int32Enum,System.Int32,System.IntPtr>
struct Action_3_tA1F157C5B221E0F24BDD45BD4F6A9C25B81357F9;
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>
struct Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4;
// System.AsyncCallback
struct AsyncCallback_t3F3DA3BEDAEE81DD1D24125DF8EB30E85EE14DA4;
// System.Char[]
struct CharU5BU5D_t4CC6ABF0AD71BEC97E3C2F1E9C5677E46D3A75C2;
// System.DelegateData
struct DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE;
// System.Delegate[]
struct DelegateU5BU5D_tDFCDEE2A6322F96C0FE49AF47E9ADB8C4B294E86;
// System.IAsyncResult
struct IAsyncResult_t8E194308510B375B42432981AE5E7488C458D598;
// System.Reflection.MethodInfo
struct MethodInfo_t;
// System.String
struct String_t;
// System.Void
struct Void_t22962CB4C05B1D89B55A6E1139F0E87A90987017;
extern RuntimeClass* NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var;
extern const RuntimeMethod* Action_1_Invoke_m60C027AA0F030AC2B693BEFB8E213066CD9000D0_RuntimeMethod_var;
extern const RuntimeMethod* Action_2_Invoke_mC215CA1421B7DF8C0023F107CA72045332A79489_RuntimeMethod_var;
extern const RuntimeMethod* Action_3_Invoke_m14ADB6DD0234BFB201A7050855A62A4DA2612D0A_RuntimeMethod_var;
extern const uint32_t NativeInputSystem_NotifyBeforeUpdate_m317D534DBDD42915CE638051B87E48B76ED28574_MetadataUsageId;
extern const uint32_t NativeInputSystem_NotifyDeviceDiscovered_m48C3818DDCFB1A2C0530B6CE1C78743ABA4614B0_MetadataUsageId;
extern const uint32_t NativeInputSystem_NotifyUpdate_m77B02AB50FCFA5649D7203E76163C757EE1DA3CA_MetadataUsageId;
struct Delegate_t_marshaled_com;
struct Delegate_t_marshaled_pinvoke;
#ifndef U3CMODULEU3E_TF8A948C14EE892A95D0E0992A0BE6B176FF2DA1D_H
#define U3CMODULEU3E_TF8A948C14EE892A95D0E0992A0BE6B176FF2DA1D_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// <Module>
struct U3CModuleU3E_tF8A948C14EE892A95D0E0992A0BE6B176FF2DA1D
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // U3CMODULEU3E_TF8A948C14EE892A95D0E0992A0BE6B176FF2DA1D_H
#ifndef RUNTIMEOBJECT_H
#define RUNTIMEOBJECT_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Object
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEOBJECT_H
struct Il2CppArrayBounds;
#ifndef RUNTIMEARRAY_H
#define RUNTIMEARRAY_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Array
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // RUNTIMEARRAY_H
#ifndef STRING_T_H
#define STRING_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.String
struct String_t : public RuntimeObject
{
public:
// System.Int32 System.String::m_stringLength
int32_t ___m_stringLength_0;
// System.Char System.String::m_firstChar
Il2CppChar ___m_firstChar_1;
public:
inline static int32_t get_offset_of_m_stringLength_0() { return static_cast<int32_t>(offsetof(String_t, ___m_stringLength_0)); }
inline int32_t get_m_stringLength_0() const { return ___m_stringLength_0; }
inline int32_t* get_address_of_m_stringLength_0() { return &___m_stringLength_0; }
inline void set_m_stringLength_0(int32_t value)
{
___m_stringLength_0 = value;
}
inline static int32_t get_offset_of_m_firstChar_1() { return static_cast<int32_t>(offsetof(String_t, ___m_firstChar_1)); }
inline Il2CppChar get_m_firstChar_1() const { return ___m_firstChar_1; }
inline Il2CppChar* get_address_of_m_firstChar_1() { return &___m_firstChar_1; }
inline void set_m_firstChar_1(Il2CppChar value)
{
___m_firstChar_1 = value;
}
};
struct String_t_StaticFields
{
public:
// System.String System.String::Empty
String_t* ___Empty_5;
public:
inline static int32_t get_offset_of_Empty_5() { return static_cast<int32_t>(offsetof(String_t_StaticFields, ___Empty_5)); }
inline String_t* get_Empty_5() const { return ___Empty_5; }
inline String_t** get_address_of_Empty_5() { return &___Empty_5; }
inline void set_Empty_5(String_t* value)
{
___Empty_5 = value;
Il2CppCodeGenWriteBarrier((&___Empty_5), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // STRING_T_H
#ifndef VALUETYPE_T4D0C27076F7C36E76190FB3328E232BCB1CD1FFF_H
#define VALUETYPE_T4D0C27076F7C36E76190FB3328E232BCB1CD1FFF_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.ValueType
struct ValueType_t4D0C27076F7C36E76190FB3328E232BCB1CD1FFF : public RuntimeObject
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.ValueType
struct ValueType_t4D0C27076F7C36E76190FB3328E232BCB1CD1FFF_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.ValueType
struct ValueType_t4D0C27076F7C36E76190FB3328E232BCB1CD1FFF_marshaled_com
{
};
#endif // VALUETYPE_T4D0C27076F7C36E76190FB3328E232BCB1CD1FFF_H
#ifndef NATIVEINPUTSYSTEM_T522F6391494159917EE6963E9E61C9EFA9C5795C_H
#define NATIVEINPUTSYSTEM_T522F6391494159917EE6963E9E61C9EFA9C5795C_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngineInternal.Input.NativeInputSystem
struct NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C : public RuntimeObject
{
public:
public:
};
struct NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields
{
public:
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr> UnityEngineInternal.Input.NativeInputSystem::onUpdate
Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * ___onUpdate_0;
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType> UnityEngineInternal.Input.NativeInputSystem::onBeforeUpdate
Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * ___onBeforeUpdate_1;
// System.Action`2<System.Int32,System.String> UnityEngineInternal.Input.NativeInputSystem::s_OnDeviceDiscoveredCallback
Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * ___s_OnDeviceDiscoveredCallback_2;
public:
inline static int32_t get_offset_of_onUpdate_0() { return static_cast<int32_t>(offsetof(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields, ___onUpdate_0)); }
inline Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * get_onUpdate_0() const { return ___onUpdate_0; }
inline Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 ** get_address_of_onUpdate_0() { return &___onUpdate_0; }
inline void set_onUpdate_0(Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * value)
{
___onUpdate_0 = value;
Il2CppCodeGenWriteBarrier((&___onUpdate_0), value);
}
inline static int32_t get_offset_of_onBeforeUpdate_1() { return static_cast<int32_t>(offsetof(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields, ___onBeforeUpdate_1)); }
inline Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * get_onBeforeUpdate_1() const { return ___onBeforeUpdate_1; }
inline Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 ** get_address_of_onBeforeUpdate_1() { return &___onBeforeUpdate_1; }
inline void set_onBeforeUpdate_1(Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * value)
{
___onBeforeUpdate_1 = value;
Il2CppCodeGenWriteBarrier((&___onBeforeUpdate_1), value);
}
inline static int32_t get_offset_of_s_OnDeviceDiscoveredCallback_2() { return static_cast<int32_t>(offsetof(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields, ___s_OnDeviceDiscoveredCallback_2)); }
inline Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * get_s_OnDeviceDiscoveredCallback_2() const { return ___s_OnDeviceDiscoveredCallback_2; }
inline Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 ** get_address_of_s_OnDeviceDiscoveredCallback_2() { return &___s_OnDeviceDiscoveredCallback_2; }
inline void set_s_OnDeviceDiscoveredCallback_2(Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * value)
{
___s_OnDeviceDiscoveredCallback_2 = value;
Il2CppCodeGenWriteBarrier((&___s_OnDeviceDiscoveredCallback_2), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // NATIVEINPUTSYSTEM_T522F6391494159917EE6963E9E61C9EFA9C5795C_H
#ifndef BOOLEAN_TB53F6830F670160873277339AA58F15CAED4399C_H
#define BOOLEAN_TB53F6830F670160873277339AA58F15CAED4399C_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Boolean
struct Boolean_tB53F6830F670160873277339AA58F15CAED4399C
{
public:
// System.Boolean System.Boolean::m_value
bool ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Boolean_tB53F6830F670160873277339AA58F15CAED4399C, ___m_value_0)); }
inline bool get_m_value_0() const { return ___m_value_0; }
inline bool* get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(bool value)
{
___m_value_0 = value;
}
};
struct Boolean_tB53F6830F670160873277339AA58F15CAED4399C_StaticFields
{
public:
// System.String System.Boolean::TrueString
String_t* ___TrueString_5;
// System.String System.Boolean::FalseString
String_t* ___FalseString_6;
public:
inline static int32_t get_offset_of_TrueString_5() { return static_cast<int32_t>(offsetof(Boolean_tB53F6830F670160873277339AA58F15CAED4399C_StaticFields, ___TrueString_5)); }
inline String_t* get_TrueString_5() const { return ___TrueString_5; }
inline String_t** get_address_of_TrueString_5() { return &___TrueString_5; }
inline void set_TrueString_5(String_t* value)
{
___TrueString_5 = value;
Il2CppCodeGenWriteBarrier((&___TrueString_5), value);
}
inline static int32_t get_offset_of_FalseString_6() { return static_cast<int32_t>(offsetof(Boolean_tB53F6830F670160873277339AA58F15CAED4399C_StaticFields, ___FalseString_6)); }
inline String_t* get_FalseString_6() const { return ___FalseString_6; }
inline String_t** get_address_of_FalseString_6() { return &___FalseString_6; }
inline void set_FalseString_6(String_t* value)
{
___FalseString_6 = value;
Il2CppCodeGenWriteBarrier((&___FalseString_6), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // BOOLEAN_TB53F6830F670160873277339AA58F15CAED4399C_H
#ifndef ENUM_T2AF27C02B8653AE29442467390005ABC74D8F521_H
#define ENUM_T2AF27C02B8653AE29442467390005ABC74D8F521_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Enum
struct Enum_t2AF27C02B8653AE29442467390005ABC74D8F521 : public ValueType_t4D0C27076F7C36E76190FB3328E232BCB1CD1FFF
{
public:
public:
};
struct Enum_t2AF27C02B8653AE29442467390005ABC74D8F521_StaticFields
{
public:
// System.Char[] System.Enum::enumSeperatorCharArray
CharU5BU5D_t4CC6ABF0AD71BEC97E3C2F1E9C5677E46D3A75C2* ___enumSeperatorCharArray_0;
public:
inline static int32_t get_offset_of_enumSeperatorCharArray_0() { return static_cast<int32_t>(offsetof(Enum_t2AF27C02B8653AE29442467390005ABC74D8F521_StaticFields, ___enumSeperatorCharArray_0)); }
inline CharU5BU5D_t4CC6ABF0AD71BEC97E3C2F1E9C5677E46D3A75C2* get_enumSeperatorCharArray_0() const { return ___enumSeperatorCharArray_0; }
inline CharU5BU5D_t4CC6ABF0AD71BEC97E3C2F1E9C5677E46D3A75C2** get_address_of_enumSeperatorCharArray_0() { return &___enumSeperatorCharArray_0; }
inline void set_enumSeperatorCharArray_0(CharU5BU5D_t4CC6ABF0AD71BEC97E3C2F1E9C5677E46D3A75C2* value)
{
___enumSeperatorCharArray_0 = value;
Il2CppCodeGenWriteBarrier((&___enumSeperatorCharArray_0), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Enum
struct Enum_t2AF27C02B8653AE29442467390005ABC74D8F521_marshaled_pinvoke
{
};
// Native definition for COM marshalling of System.Enum
struct Enum_t2AF27C02B8653AE29442467390005ABC74D8F521_marshaled_com
{
};
#endif // ENUM_T2AF27C02B8653AE29442467390005ABC74D8F521_H
#ifndef INT32_T585191389E07734F19F3156FF88FB3EF4800D102_H
#define INT32_T585191389E07734F19F3156FF88FB3EF4800D102_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32
struct Int32_t585191389E07734F19F3156FF88FB3EF4800D102
{
public:
// System.Int32 System.Int32::m_value
int32_t ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(Int32_t585191389E07734F19F3156FF88FB3EF4800D102, ___m_value_0)); }
inline int32_t get_m_value_0() const { return ___m_value_0; }
inline int32_t* get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(int32_t value)
{
___m_value_0 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32_T585191389E07734F19F3156FF88FB3EF4800D102_H
#ifndef INTPTR_T_H
#define INTPTR_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.IntPtr
struct IntPtr_t
{
public:
// System.Void* System.IntPtr::m_value
void* ___m_value_0;
public:
inline static int32_t get_offset_of_m_value_0() { return static_cast<int32_t>(offsetof(IntPtr_t, ___m_value_0)); }
inline void* get_m_value_0() const { return ___m_value_0; }
inline void** get_address_of_m_value_0() { return &___m_value_0; }
inline void set_m_value_0(void* value)
{
___m_value_0 = value;
}
};
struct IntPtr_t_StaticFields
{
public:
// System.IntPtr System.IntPtr::Zero
intptr_t ___Zero_1;
public:
inline static int32_t get_offset_of_Zero_1() { return static_cast<int32_t>(offsetof(IntPtr_t_StaticFields, ___Zero_1)); }
inline intptr_t get_Zero_1() const { return ___Zero_1; }
inline intptr_t* get_address_of_Zero_1() { return &___Zero_1; }
inline void set_Zero_1(intptr_t value)
{
___Zero_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INTPTR_T_H
#ifndef VOID_T22962CB4C05B1D89B55A6E1139F0E87A90987017_H
#define VOID_T22962CB4C05B1D89B55A6E1139F0E87A90987017_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void
struct Void_t22962CB4C05B1D89B55A6E1139F0E87A90987017
{
public:
union
{
struct
{
};
uint8_t Void_t22962CB4C05B1D89B55A6E1139F0E87A90987017__padding[1];
};
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // VOID_T22962CB4C05B1D89B55A6E1139F0E87A90987017_H
#ifndef DELEGATE_T_H
#define DELEGATE_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Delegate
struct Delegate_t : public RuntimeObject
{
public:
// System.IntPtr System.Delegate::method_ptr
Il2CppMethodPointer ___method_ptr_0;
// System.IntPtr System.Delegate::invoke_impl
intptr_t ___invoke_impl_1;
// System.Object System.Delegate::m_target
RuntimeObject * ___m_target_2;
// System.IntPtr System.Delegate::method
intptr_t ___method_3;
// System.IntPtr System.Delegate::delegate_trampoline
intptr_t ___delegate_trampoline_4;
// System.IntPtr System.Delegate::extra_arg
intptr_t ___extra_arg_5;
// System.IntPtr System.Delegate::method_code
intptr_t ___method_code_6;
// System.Reflection.MethodInfo System.Delegate::method_info
MethodInfo_t * ___method_info_7;
// System.Reflection.MethodInfo System.Delegate::original_method_info
MethodInfo_t * ___original_method_info_8;
// System.DelegateData System.Delegate::data
DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE * ___data_9;
// System.Boolean System.Delegate::method_is_virtual
bool ___method_is_virtual_10;
public:
inline static int32_t get_offset_of_method_ptr_0() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_ptr_0)); }
inline Il2CppMethodPointer get_method_ptr_0() const { return ___method_ptr_0; }
inline Il2CppMethodPointer* get_address_of_method_ptr_0() { return &___method_ptr_0; }
inline void set_method_ptr_0(Il2CppMethodPointer value)
{
___method_ptr_0 = value;
}
inline static int32_t get_offset_of_invoke_impl_1() { return static_cast<int32_t>(offsetof(Delegate_t, ___invoke_impl_1)); }
inline intptr_t get_invoke_impl_1() const { return ___invoke_impl_1; }
inline intptr_t* get_address_of_invoke_impl_1() { return &___invoke_impl_1; }
inline void set_invoke_impl_1(intptr_t value)
{
___invoke_impl_1 = value;
}
inline static int32_t get_offset_of_m_target_2() { return static_cast<int32_t>(offsetof(Delegate_t, ___m_target_2)); }
inline RuntimeObject * get_m_target_2() const { return ___m_target_2; }
inline RuntimeObject ** get_address_of_m_target_2() { return &___m_target_2; }
inline void set_m_target_2(RuntimeObject * value)
{
___m_target_2 = value;
Il2CppCodeGenWriteBarrier((&___m_target_2), value);
}
inline static int32_t get_offset_of_method_3() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_3)); }
inline intptr_t get_method_3() const { return ___method_3; }
inline intptr_t* get_address_of_method_3() { return &___method_3; }
inline void set_method_3(intptr_t value)
{
___method_3 = value;
}
inline static int32_t get_offset_of_delegate_trampoline_4() { return static_cast<int32_t>(offsetof(Delegate_t, ___delegate_trampoline_4)); }
inline intptr_t get_delegate_trampoline_4() const { return ___delegate_trampoline_4; }
inline intptr_t* get_address_of_delegate_trampoline_4() { return &___delegate_trampoline_4; }
inline void set_delegate_trampoline_4(intptr_t value)
{
___delegate_trampoline_4 = value;
}
inline static int32_t get_offset_of_extra_arg_5() { return static_cast<int32_t>(offsetof(Delegate_t, ___extra_arg_5)); }
inline intptr_t get_extra_arg_5() const { return ___extra_arg_5; }
inline intptr_t* get_address_of_extra_arg_5() { return &___extra_arg_5; }
inline void set_extra_arg_5(intptr_t value)
{
___extra_arg_5 = value;
}
inline static int32_t get_offset_of_method_code_6() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_code_6)); }
inline intptr_t get_method_code_6() const { return ___method_code_6; }
inline intptr_t* get_address_of_method_code_6() { return &___method_code_6; }
inline void set_method_code_6(intptr_t value)
{
___method_code_6 = value;
}
inline static int32_t get_offset_of_method_info_7() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_info_7)); }
inline MethodInfo_t * get_method_info_7() const { return ___method_info_7; }
inline MethodInfo_t ** get_address_of_method_info_7() { return &___method_info_7; }
inline void set_method_info_7(MethodInfo_t * value)
{
___method_info_7 = value;
Il2CppCodeGenWriteBarrier((&___method_info_7), value);
}
inline static int32_t get_offset_of_original_method_info_8() { return static_cast<int32_t>(offsetof(Delegate_t, ___original_method_info_8)); }
inline MethodInfo_t * get_original_method_info_8() const { return ___original_method_info_8; }
inline MethodInfo_t ** get_address_of_original_method_info_8() { return &___original_method_info_8; }
inline void set_original_method_info_8(MethodInfo_t * value)
{
___original_method_info_8 = value;
Il2CppCodeGenWriteBarrier((&___original_method_info_8), value);
}
inline static int32_t get_offset_of_data_9() { return static_cast<int32_t>(offsetof(Delegate_t, ___data_9)); }
inline DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE * get_data_9() const { return ___data_9; }
inline DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE ** get_address_of_data_9() { return &___data_9; }
inline void set_data_9(DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE * value)
{
___data_9 = value;
Il2CppCodeGenWriteBarrier((&___data_9), value);
}
inline static int32_t get_offset_of_method_is_virtual_10() { return static_cast<int32_t>(offsetof(Delegate_t, ___method_is_virtual_10)); }
inline bool get_method_is_virtual_10() const { return ___method_is_virtual_10; }
inline bool* get_address_of_method_is_virtual_10() { return &___method_is_virtual_10; }
inline void set_method_is_virtual_10(bool value)
{
___method_is_virtual_10 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.Delegate
struct Delegate_t_marshaled_pinvoke
{
intptr_t ___method_ptr_0;
intptr_t ___invoke_impl_1;
Il2CppIUnknown* ___m_target_2;
intptr_t ___method_3;
intptr_t ___delegate_trampoline_4;
intptr_t ___extra_arg_5;
intptr_t ___method_code_6;
MethodInfo_t * ___method_info_7;
MethodInfo_t * ___original_method_info_8;
DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE * ___data_9;
int32_t ___method_is_virtual_10;
};
// Native definition for COM marshalling of System.Delegate
struct Delegate_t_marshaled_com
{
intptr_t ___method_ptr_0;
intptr_t ___invoke_impl_1;
Il2CppIUnknown* ___m_target_2;
intptr_t ___method_3;
intptr_t ___delegate_trampoline_4;
intptr_t ___extra_arg_5;
intptr_t ___method_code_6;
MethodInfo_t * ___method_info_7;
MethodInfo_t * ___original_method_info_8;
DelegateData_t1BF9F691B56DAE5F8C28C5E084FDE94F15F27BBE * ___data_9;
int32_t ___method_is_virtual_10;
};
#endif // DELEGATE_T_H
#ifndef INT32ENUM_T6312CE4586C17FE2E2E513D2E7655B574F10FDCD_H
#define INT32ENUM_T6312CE4586C17FE2E2E513D2E7655B574F10FDCD_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Int32Enum
struct Int32Enum_t6312CE4586C17FE2E2E513D2E7655B574F10FDCD
{
public:
// System.Int32 System.Int32Enum::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(Int32Enum_t6312CE4586C17FE2E2E513D2E7655B574F10FDCD, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // INT32ENUM_T6312CE4586C17FE2E2E513D2E7655B574F10FDCD_H
#ifndef NATIVEINPUTUPDATETYPE_T744D5594ED044E47F3BAF84F45326948B8930C71_H
#define NATIVEINPUTUPDATETYPE_T744D5594ED044E47F3BAF84F45326948B8930C71_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngineInternal.Input.NativeInputUpdateType
struct NativeInputUpdateType_t744D5594ED044E47F3BAF84F45326948B8930C71
{
public:
// System.Int32 UnityEngineInternal.Input.NativeInputUpdateType::value__
int32_t ___value___2;
public:
inline static int32_t get_offset_of_value___2() { return static_cast<int32_t>(offsetof(NativeInputUpdateType_t744D5594ED044E47F3BAF84F45326948B8930C71, ___value___2)); }
inline int32_t get_value___2() const { return ___value___2; }
inline int32_t* get_address_of_value___2() { return &___value___2; }
inline void set_value___2(int32_t value)
{
___value___2 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // NATIVEINPUTUPDATETYPE_T744D5594ED044E47F3BAF84F45326948B8930C71_H
#ifndef MULTICASTDELEGATE_T_H
#define MULTICASTDELEGATE_T_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.MulticastDelegate
struct MulticastDelegate_t : public Delegate_t
{
public:
// System.Delegate[] System.MulticastDelegate::delegates
DelegateU5BU5D_tDFCDEE2A6322F96C0FE49AF47E9ADB8C4B294E86* ___delegates_11;
public:
inline static int32_t get_offset_of_delegates_11() { return static_cast<int32_t>(offsetof(MulticastDelegate_t, ___delegates_11)); }
inline DelegateU5BU5D_tDFCDEE2A6322F96C0FE49AF47E9ADB8C4B294E86* get_delegates_11() const { return ___delegates_11; }
inline DelegateU5BU5D_tDFCDEE2A6322F96C0FE49AF47E9ADB8C4B294E86** get_address_of_delegates_11() { return &___delegates_11; }
inline void set_delegates_11(DelegateU5BU5D_tDFCDEE2A6322F96C0FE49AF47E9ADB8C4B294E86* value)
{
___delegates_11 = value;
Il2CppCodeGenWriteBarrier((&___delegates_11), value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
// Native definition for P/Invoke marshalling of System.MulticastDelegate
struct MulticastDelegate_t_marshaled_pinvoke : public Delegate_t_marshaled_pinvoke
{
Delegate_t_marshaled_pinvoke** ___delegates_11;
};
// Native definition for COM marshalling of System.MulticastDelegate
struct MulticastDelegate_t_marshaled_com : public Delegate_t_marshaled_com
{
Delegate_t_marshaled_com** ___delegates_11;
};
#endif // MULTICASTDELEGATE_T_H
#ifndef ACTION_1_TA0A72999A108CE29CD4CB14537B8FE41501859C1_H
#define ACTION_1_TA0A72999A108CE29CD4CB14537B8FE41501859C1_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>
struct Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_1_TA0A72999A108CE29CD4CB14537B8FE41501859C1_H
#ifndef ACTION_2_T3DE7FA14577DE01568F76D409273F315827CAA36_H
#define ACTION_2_T3DE7FA14577DE01568F76D409273F315827CAA36_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`2<System.Int32,System.String>
struct Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_2_T3DE7FA14577DE01568F76D409273F315827CAA36_H
#ifndef ACTION_3_T218EFA183BDE39E1AC9A0240E98B4BFC33A703D4_H
#define ACTION_3_T218EFA183BDE39E1AC9A0240E98B4BFC33A703D4_H
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>
struct Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 : public MulticastDelegate_t
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // ACTION_3_T218EFA183BDE39E1AC9A0240E98B4BFC33A703D4_H
// System.Void System.Action`1<System.Int32Enum>::Invoke(!0)
extern "C" IL2CPP_METHOD_ATTR void Action_1_Invoke_m8672DDC58300CA227FC37981067B766C9879344B_gshared (Action_1_tABA1E3BFA092E3309A0ECC53722E4F9826DCE983 * __this, int32_t p0, const RuntimeMethod* method);
// System.Void System.Action`3<System.Int32Enum,System.Int32,System.IntPtr>::Invoke(!0,!1,!2)
extern "C" IL2CPP_METHOD_ATTR void Action_3_Invoke_mA42EA0FED3B60DF0F9FC0E7EA4DECB94B577ED27_gshared (Action_3_tA1F157C5B221E0F24BDD45BD4F6A9C25B81357F9 * __this, int32_t p0, int32_t p1, intptr_t p2, const RuntimeMethod* method);
// System.Void System.Action`2<System.Int32,System.Object>::Invoke(!0,!1)
extern "C" IL2CPP_METHOD_ATTR void Action_2_Invoke_m8C87606D1DEC8A89FB53D1ADF8768A7403DD6202_gshared (Action_2_tCC05A68F0FC31E84E54091438749644062A6C27F * __this, int32_t p0, RuntimeObject * p1, const RuntimeMethod* method);
// System.Void UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362 (bool ___value0, const RuntimeMethod* method);
// System.Void System.Action`1<UnityEngineInternal.Input.NativeInputUpdateType>::Invoke(!0)
inline void Action_1_Invoke_m60C027AA0F030AC2B693BEFB8E213066CD9000D0 (Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * __this, int32_t p0, const RuntimeMethod* method)
{
(( void (*) (Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 *, int32_t, const RuntimeMethod*))Action_1_Invoke_m8672DDC58300CA227FC37981067B766C9879344B_gshared)(__this, p0, method);
}
// System.Void System.Action`3<UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr>::Invoke(!0,!1,!2)
inline void Action_3_Invoke_m14ADB6DD0234BFB201A7050855A62A4DA2612D0A (Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * __this, int32_t p0, int32_t p1, intptr_t p2, const RuntimeMethod* method)
{
(( void (*) (Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 *, int32_t, int32_t, intptr_t, const RuntimeMethod*))Action_3_Invoke_mA42EA0FED3B60DF0F9FC0E7EA4DECB94B577ED27_gshared)(__this, p0, p1, p2, method);
}
// System.Void System.Action`2<System.Int32,System.String>::Invoke(!0,!1)
inline void Action_2_Invoke_mC215CA1421B7DF8C0023F107CA72045332A79489 (Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * __this, int32_t p0, String_t* p1, const RuntimeMethod* method)
{
(( void (*) (Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 *, int32_t, String_t*, const RuntimeMethod*))Action_2_Invoke_m8C87606D1DEC8A89FB53D1ADF8768A7403DD6202_gshared)(__this, p0, p1, method);
}
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Void UnityEngineInternal.Input.NativeInputSystem::.cctor()
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem__cctor_m062AB23A2EB8CDEC8BEB378C4588038BD1614A11 (const RuntimeMethod* method)
{
{
NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362((bool)0, /*hidden argument*/NULL);
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyBeforeUpdate(UnityEngineInternal.Input.NativeInputUpdateType)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyBeforeUpdate_m317D534DBDD42915CE638051B87E48B76ED28574 (int32_t ___updateType0, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyBeforeUpdate_m317D534DBDD42915CE638051B87E48B76ED28574_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var);
Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * L_0 = ((NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var))->get_onBeforeUpdate_1();
V_0 = L_0;
Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * L_1 = V_0;
if (!L_1)
{
goto IL_0014;
}
}
{
Action_1_tA0A72999A108CE29CD4CB14537B8FE41501859C1 * L_2 = V_0;
int32_t L_3 = ___updateType0;
NullCheck(L_2);
Action_1_Invoke_m60C027AA0F030AC2B693BEFB8E213066CD9000D0(L_2, L_3, /*hidden argument*/Action_1_Invoke_m60C027AA0F030AC2B693BEFB8E213066CD9000D0_RuntimeMethod_var);
}
IL_0014:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyUpdate(UnityEngineInternal.Input.NativeInputUpdateType,System.Int32,System.IntPtr)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyUpdate_m77B02AB50FCFA5649D7203E76163C757EE1DA3CA (int32_t ___updateType0, int32_t ___eventCount1, intptr_t ___eventData2, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyUpdate_m77B02AB50FCFA5649D7203E76163C757EE1DA3CA_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var);
Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * L_0 = ((NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var))->get_onUpdate_0();
V_0 = L_0;
Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * L_1 = V_0;
if (!L_1)
{
goto IL_0016;
}
}
{
Action_3_t218EFA183BDE39E1AC9A0240E98B4BFC33A703D4 * L_2 = V_0;
int32_t L_3 = ___updateType0;
int32_t L_4 = ___eventCount1;
intptr_t L_5 = ___eventData2;
NullCheck(L_2);
Action_3_Invoke_m14ADB6DD0234BFB201A7050855A62A4DA2612D0A(L_2, L_3, L_4, (intptr_t)L_5, /*hidden argument*/Action_3_Invoke_m14ADB6DD0234BFB201A7050855A62A4DA2612D0A_RuntimeMethod_var);
}
IL_0016:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::NotifyDeviceDiscovered(System.Int32,System.String)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_NotifyDeviceDiscovered_m48C3818DDCFB1A2C0530B6CE1C78743ABA4614B0 (int32_t ___deviceId0, String_t* ___deviceDescriptor1, const RuntimeMethod* method)
{
static bool s_Il2CppMethodInitialized;
if (!s_Il2CppMethodInitialized)
{
il2cpp_codegen_initialize_method (NativeInputSystem_NotifyDeviceDiscovered_m48C3818DDCFB1A2C0530B6CE1C78743ABA4614B0_MetadataUsageId);
s_Il2CppMethodInitialized = true;
}
Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * V_0 = NULL;
{
IL2CPP_RUNTIME_CLASS_INIT(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var);
Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * L_0 = ((NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_StaticFields*)il2cpp_codegen_static_fields_for(NativeInputSystem_t522F6391494159917EE6963E9E61C9EFA9C5795C_il2cpp_TypeInfo_var))->get_s_OnDeviceDiscoveredCallback_2();
V_0 = L_0;
Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * L_1 = V_0;
if (!L_1)
{
goto IL_0015;
}
}
{
Action_2_t3DE7FA14577DE01568F76D409273F315827CAA36 * L_2 = V_0;
int32_t L_3 = ___deviceId0;
String_t* L_4 = ___deviceDescriptor1;
NullCheck(L_2);
Action_2_Invoke_mC215CA1421B7DF8C0023F107CA72045332A79489(L_2, L_3, L_4, /*hidden argument*/Action_2_Invoke_mC215CA1421B7DF8C0023F107CA72045332A79489_RuntimeMethod_var);
}
IL_0015:
{
return;
}
}
// System.Void UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)
extern "C" IL2CPP_METHOD_ATTR void NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362 (bool ___value0, const RuntimeMethod* method)
{
typedef void (*NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362_ftn) (bool);
static NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362_ftn _il2cpp_icall_func;
if (!_il2cpp_icall_func)
_il2cpp_icall_func = (NativeInputSystem_set_hasDeviceDiscoveredCallback_mB5319D5A7C245D6F12C294928D4AF3B635FFE362_ftn)il2cpp_codegen_resolve_icall ("UnityEngineInternal.Input.NativeInputSystem::set_hasDeviceDiscoveredCallback(System.Boolean)");
_il2cpp_icall_func(___value0);
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
cdcb89003200da5a0d3e0eb11df1e0af68571fd4 | 1824b659c0fc57a92a27f451d875c2c50e05df98 | /Spoj/fibosum.cpp | 1e43033a9905ec22a2f942ff78c825145c741c33 | [] | no_license | convexhull/codechef-ds-and-algo-solutions | 78b46c51926ac38984d877b9c97cb0213b4003ea | dde7f8d768c3eb7d2184aba74c4722a54e73f3f8 | refs/heads/master | 2022-08-10T18:02:46.802337 | 2020-05-23T12:16:36 | 2020-05-23T12:16:36 | 266,325,011 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,511 | cpp | fibosum.cpp | #include<bits/stdc++.h>
#define M 1000000007
using namespace std;
vector< vector<long long> > matrixmult(vector< vector<long long> > &first, vector< vector<long long> > &second)
{
vector< vector<long long> > ans(2,vector<long long>(2));
for(long long i=0;i<=1;i++)
{
for(long long j=0;j<=1;j++)
{
long long sum=0;
for(long long k=0;k<=1;k++)
{
sum = ( sum + (first[i][k]%M * second[k][j]%M)%M )%M;
}
ans[i][j]=sum;
}
}
return ans;
}
long long fibo(long long n)
{
if(n==0)
return 1;
vector< vector<long long> > result{{1,0},{0,1}};
vector< vector<long long> > factor{{0,1},{1,1}};
while(n>0)
{
if(n%2)
result=matrixmult(result,factor);
factor=matrixmult(factor,factor);
n/=2;
}
return result[1][1];
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
long long T;
cin>>T;
while(T--)
{
long long n,m;
cin>>n>>m;
long long first=fibo(n)-1;
long long second=fibo(m+1)-1;
//long long sum1=fibo(n+1)-1;
//long long sum2=fibo(m+1)-1;
long long sum=(second%M - first%M)%M;
if(sum<0)
sum+=M;
//cout<<first<<" "<<second<<endl;
cout<<sum<<endl;
}
return 0;
}
|
79c673efbd54e6fe08742e60bd0587de736ba2a8 | e852d6e28590800f2ee69eeb2bd0c9c9af4e7d67 | /ArrayList.h | 6db34ac5b02edb84b27542d87e7a15bddf3dc55d | [] | no_license | jesse-target/TestRepo | cb540d86020e324c6bee0f0ccbb56e1005a6e616 | d9fe0d340063f27f395e29239de052f0097d55a1 | refs/heads/master | 2021-01-13T02:12:05.365079 | 2012-05-23T18:00:30 | 2012-05-23T18:00:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,457 | h | ArrayList.h | #ifndef _ARRAYLIST_
#define _ARRAYLIST_
#include <cstdlib>
#define MAX_SIZE 5000
template < class T >
class ArrayList {
private:
int itsIndex;
T * s [MAX_SIZE];
public:
ArrayList () {
itsIndex=0;
}
void push ( T p ) {
s[itsIndex] = new T;
*s[itsIndex] = p;
itsIndex++;
}
T top () {
return s[itsIndex];
}
T get ( int i ) {
if ( i>=0 && i<=itsIndex ) {
return *s[i];
}
return 0;
}
T operator[] ( int i ) {
if ( i>=0 && i<=itsIndex ) {
return *s[i];
}
return 0;
}
int size () {
return itsIndex + 1;
}
void empty () {
itsIndex=-1;
}
bool isEmpty () {
return (itsIndex==-1);
}
int count ( T what ) {
int C=0;
for ( int i=0; i<=itsIndex; i++ ) {
if ( *s[i]==what )
C++;
}
return C;
}
bool has ( T what ) {
for ( int i=0; i<=itsIndex; i++ ) {
if ( what==*s[i] )
return true;
}
return false;
}
int get ( T what ) {
for ( int i=0; i<=itsIndex; i++ ) {
if ( what==*s[i] )
return i;
}
return -1;
}
void remove ( int index ) {
itsIndex--;
for ( int i=index; i<=itsIndex; i++ )
s[i]=s[i+1];
}
void removeAll ( T what ) {
for ( int i=0; i<=itsIndex; ) {
if ( what==*s[i] )
remove( i );
else
i++;
}
}
void replace ( T what, T with ) {
for (int i=0; i<itsIndex; i++)
if (what==*s[i])
*s[i]=with;
}
void swap ( int one, int two ) {
T temp=*s[one];
*s[one]=*s[two];
*s[two]=temp;
}
};
#endif
|
6cfdc21ca96db13833f7d8094d4f552ee7368b80 | c8a04cea9afde109e8f7ffce09bde1c616c1bb2e | /542/542.cpp | 280c575647342628f001a3dde922dc211e4bfa6b | [
"MIT"
] | permissive | JanaSabuj/Leetcode-solutions | 956fea8538b3d87b999d0c65ef158ad8500b61c7 | 68464fc54c18ec6d7d72e862c1c75e8309314198 | refs/heads/master | 2022-09-12T13:32:13.884649 | 2022-08-15T06:21:34 | 2022-08-15T06:21:34 | 165,518,391 | 17 | 5 | null | 2020-04-17T13:26:01 | 2019-01-13T14:59:56 | C++ | UTF-8 | C++ | false | false | 1,587 | cpp | 542.cpp | class Solution {
public:
#define inf (1 << 30)
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool valid(int r, int c, int n, int m) {return (r >= 0 and r < n and c >= 0 and c < m);}
vector<vector<int>> bfs(vector<vector<int>>& matrix, vector<pair<int,int>>& src, int n, int m){
vector<vector<int>> dist(n, vector<int>(m, 0));
// find dist of all items from 0
queue<pair<int,int>> q;
for(auto& [x, y]: src){
q.push({x,y});
dist[x][y] = 0;
}
while(!q.empty()){
auto [x,y] = q.front();
q.pop();
for(int i = 0; i < 4; i++){
int r = x + dx[i];
int c = y + dy[i];
if(valid(r,c,n,m) and matrix[r][c] == 1){
q.push({r,c});
matrix[r][c] = 0;// mark as visited
dist[r][c] = dist[x][y] + 1;
}
}
}
return dist;
}
vector<vector<int>> updateMatrix(vector<vector<int>>& matrix) {
int n = matrix.size();
int m = matrix[0].size();
vector<pair<int,int>> src;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if(matrix[i][j] == 0){
src.push_back({i,j});
}
}
}
// bfs
vector<vector<int>> dist = bfs(matrix, src, n, m);
return dist;
}
};
|
99ac31627e8a27ccdc4f193fe3d578dee175bb74 | f6434fb8764722d22a3635625e4f861d6ec630c7 | /source/Vizor/Platform/SurfaceDevice.hpp | 97ca409639d4764de1b64089e8d64d66c1975e96 | [
"MIT"
] | permissive | kurocha/vizor-platform | a5252ec6af43caae25217b31ebd21d8c8b2dc955 | 100ad5ba5be12abef15686047143ca506557f1da | refs/heads/master | 2022-12-24T10:11:38.454321 | 2022-12-11T07:38:22 | 2022-12-11T07:38:22 | 171,962,944 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,503 | hpp | SurfaceDevice.hpp | //
// SurfaceDevice.hpp
// This file is part of the "Vizor" project and released under the MIT License.
// This file is part of the "Vizor Platform" project and released under the .
//
// Created by Samuel Williams on 16/2/2019.
// Copyright, 2019, by Samuel Williams. All rights reserved.
//
#pragma once
#include "SurfaceContext.hpp"
#include <Vizor/GraphicsDevice.hpp>
namespace Vizor
{
namespace Platform
{
class SurfaceDevice : public GraphicsDevice
{
public:
SurfaceDevice(const PhysicalContext & physical_context, Window & window, bool enable_swapchain = true) : GraphicsDevice(physical_context), _window(window), _enable_swapchain(enable_swapchain) {}
virtual ~SurfaceDevice();
SurfaceDevice(const SurfaceDevice &) = delete;
vk::SurfaceKHR surface();
std::uint32_t present_queue_family_index() const noexcept {return _present_queue_family_index;}
vk::Queue present_queue() const noexcept {return _present_queue;}
SurfaceContext context() {return SurfaceContext(GraphicsDevice::context(), present_queue(), surface());}
protected:
virtual void prepare(Layers & layers, Extensions & extensions) const noexcept override;
virtual void setup_queues() override;
virtual void setup_device(Layers & layers, Extensions & extensions) override;
Window & _window;
bool _enable_swapchain;
std::uint32_t _present_queue_family_index = -1;
vk::Queue _present_queue = nullptr;
vk::SurfaceKHR _surface;
};
}
} |
1f67afbcb192d5aaf2d40070673fa0897bf1efbf | 20b67a33ab7547fa56c7c9b78b4320e261b83120 | /Graph Algos/Articulation Point - Birdge - BCC/1308 - Ant Network .cpp | 838bf427796a67d1c0590742d0749241e266c7ca | [
"MIT"
] | permissive | forkkr/Lightoj | ceb6bdebeecec7c41144e43d22203f06e45e038e | b9592e39b5805c683764f8bdadeef6e8428d80d2 | refs/heads/master | 2023-04-16T17:05:18.927078 | 2023-04-12T05:12:51 | 2023-04-12T05:12:51 | 86,373,510 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,224 | cpp | 1308 - Ant Network .cpp | #include<bits/stdc++.h>
using namespace std;
const int mxn = 10005;
vector< int > adj[mxn] , bcc[mxn];
int low[mxn] , dv[mxn], parent[mxn] , bccnt= 0 ,root, rootchild;
bool vis[mxn] , ap[mxn];
set< int > apcnt[mxn];
typedef unsigned long long ull;
int cnt ;
void dfs(int u)
{
vis[u] = true;
low[u] = dv[u] = cnt;
cnt++;
for(int i = 0; i < adj[u].size(); i++)
{
int v = adj[u][i];
if(!vis[v])
{
if(root==u)
rootchild++;
parent[v] = u;
dfs(v);
if(low[v] >= dv[u] && root != u)
{
ap[u] = true;
}
low[u] = min(low[u] , low[v]);
}
else if(parent[u]!=v)
{
low[u] = min(low[u] , dv[v]);
}
}
}
void dfs1(int u)
{
vis[u] = true;
bcc[bccnt].push_back(u);
for(int i = 0; i < adj[u].size(); i++)
{
int v = adj[u][i];
if(ap[v])
{
apcnt[bccnt].insert(v);
continue;
}
if(!vis[v])
{
dfs1(v);
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tc;
cin>>tc;
int cs = 0;
while(tc--)
{
cs++;
int n , m , u ,v;
cin>>n>>m;
for(int i = 0; i < m; i++)
{
cin>>u>>v;
adj[u].push_back(v);
adj[v].push_back(u);
}
memset(vis , false , sizeof(vis));
memset(ap , false , sizeof(ap));
for(int i = 0; i < n; i++)
{
if(!vis[i])
{
cnt = 0;
root = i;
rootchild = 0;
dfs(i);
if(rootchild > 1)
ap[root] = true;
}
}
memset( vis , false , sizeof(vis));
bccnt = 0;
for(int i = 0; i < n ; i++)
{
if(ap[i])
continue;
if(!vis[i])
{
bccnt++;
dfs1(i);
}
}
if(bccnt==1)
{
if(bcc[1].size()==0)
{
cout<<"Case "<<cs<<": "<<0<<" "<<1<<endl;
}
else if(bcc[1].size()==1)
{
cout<<"Case "<<cs<<": "<<1<<" "<<1<<endl;
}
else
{
ull res = ( (unsigned long long) bcc[1].size()*((unsigned long long )bcc[1].size()-1))/2;
cout<<"Case "<<cs<<": "<<2<<" "<<res<<endl;
}
}
else
{
ull res = 1 , r=0;
for(int i =1; i <= bccnt; i++)
{
if(apcnt[i].size() <= 1)
res *= (unsigned long long )bcc[i].size();
else
r++;
}
cout<<"Case "<<cs<<": "<<bccnt-r<<" "<<res<<endl;
}
for(int i = 0; i < mxn; i++)
{
adj[i].clear();
bcc[i].clear();
apcnt[i].clear();
}
}
return 0;
}
|
02552454684e78c61941632cf07274d3d03da18f | 68cda4a9a53b61d865c42600c23aae613e44f426 | /src/librobot/intake.cpp | 488287d85c42b0e9579b157fd68118a9d0afb890 | [
"MIT"
] | permissive | kettering-vex-u/TowerTakeover_WCD | 1acf8b5dd300e96b4ffbafc514c95386f075acad | c74485d71d77f43f83c7715f5034032d17f44519 | refs/heads/master | 2021-07-12T06:32:19.537576 | 2021-02-27T19:32:16 | 2021-02-27T19:32:16 | 235,164,110 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 467 | cpp | intake.cpp | #include "main.h"
using namespace okapi;
namespace intake {
Motor intakeL(INTAKE_L);
Motor intakeR(INTAKE_R);
void init() {}
void intakeIn(double power) {
intakeL.moveVoltage(power);
intakeR.moveVoltage(-power);
}
void intakeOut(double power) {
intakeL.moveVoltage(-power);
intakeR.moveVoltage(power);
}
void stopIntake() {
intakeL.moveVoltage(0);
intakeR.moveVoltage(0);
}
}
|
459bc932fe74824124806fb4e09928ae20d5d259 | 48427a31b711f074ae833f4cefda0546c6cb88a8 | /ConsoleApplication17/Source_OLD.cpp | b00380096b476d04fe034dfa325929b2cb01fd02 | [] | no_license | virrius/arucoCube | 3d41905fe081ec811912d5503cee45e0a11df3d6 | 17ce576d20ba4e3ac82a298a067ec9b15535bcc1 | refs/heads/master | 2021-04-06T11:37:32.835199 | 2018-04-22T13:22:44 | 2018-04-22T13:22:44 | 125,265,961 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 2,850 | cpp | Source_OLD.cpp | #include<opencv2\core.hpp>
#include<opencv2\highgui.hpp>
#include<iostream>
#include<opencv2\imgproc.hpp>
#include<opencv2\calib3d.hpp>
#include<fstream>
class calibratemecompletely {
protected:
//необходимое число кадров для калибровки
const int CalibNum = 15;
//число удачных кадров
int goodCalib = 0;
const cv::Size boardSize = cv::Size(4, 4);
std::vector<cv::Point3f> points3D;// вершины
std::vector<cv::Point2f>corners;
std::vector<std::vector<cv::Point3f>> objPoints3D;//физическое расположение
std::vector<std::vector<cv::Point2f>> imgPoints2D;//расположение на изображении
cv::Mat cameraMatrix = cv::Mat(3, 3, CV_32FC1);
cv::Mat distCoeffs;
std::vector<cv::Mat> rvecs;
std::vector<cv::Mat> tvecs;
public:
calibratemecompletely()
{
for (int i = 0; i < boardSize.height*boardSize.width; i++)
{
points3D.push_back(cv::Point3f(i/boardSize.width, i%boardSize.height, 0));
}
}
void ChessCalibration()
{
std::cout << "start calibration \n";
cv::VideoCapture cam(0);
cv::Mat image, grayImg;
//создаем систему уравнений
while (goodCalib<CalibNum)
{
cam >> image;
cv::cvtColor(image, grayImg, CV_BGR2GRAY);
bool success = cv::findChessboardCorners(image, boardSize, corners, cv::CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);
if (success)
{
imgPoints2D.push_back(corners);
objPoints3D.push_back(points3D);
std::cout << "captured! ";
goodCalib++;
std::cout << goodCalib << "/" << CalibNum << std::endl;
cv::cornerSubPix(grayImg, corners, cv::Size(11, 11), cv::Size(-1, -1), cv::TermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 30, 0.001));
cv::drawChessboardCorners(grayImg, boardSize, corners, success);
}
cv::imshow("1", image);
cv::imshow("2",grayImg);
char key = cv::waitKey(100);
if (key == 27)
{
std::cout << "terminated \n" ;
return;
}
}
//калибровка
cameraMatrix.ptr<float>(0)[0] = 1;
cameraMatrix.ptr<float>(1)[1] = 1;
cv::calibrateCamera(objPoints3D, imgPoints2D, boardSize, cameraMatrix, distCoeffs, rvecs, tvecs);
std::cout << "Calibrated succesfully \n";
cv::destroyAllWindows();
cam.release();
}
void ShowUndistorted()
{
cv::VideoCapture cam(0);
cv::Mat frame, UndistFrame;
while (true)
{
cam >> frame;
cv::undistort(frame, UndistFrame, cameraMatrix, distCoeffs);
cv::imshow("win1", frame);
cv::imshow("win2", UndistFrame);
cv::waitKey(1);
}
cv::destroyAllWindows();
cam.release();
}
};
int main()
{
calibratemecompletely calib1;
calib1.ChessCalibration();
calib1.ShowUndistorted();
return 0;
} |
674d811a107cc3e2491518317b0b2e03f41f596f | 53b6f37764cc75a124c853454ce28dbff33266fb | /include/TNTexture.h | 2385f6a21f29a273928e25400e673f86313a27f4 | [] | no_license | qbasicer/TerraNova | 62e9dc203dda7d1c86eda416062a7c363b6a7165 | 61d792a4923530014813271a5e2e966bf4ab750b | refs/heads/master | 2020-04-04T03:33:16.306456 | 2014-12-01T19:54:19 | 2014-12-01T19:54:19 | 1,015,763 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 522 | h | TNTexture.h | #ifndef TNTEXTURE_H
#define TNTEXTURE_H
#ifdef __APPLE__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#include <GL/gl.h>
#include <GL/glu.h>
#include <string>
class TNTexture
{
public:
TNTexture(std::string name, const char* file, GLuint id);
virtual ~TNTexture();
GLuint getTextureId(){return textureId;}
std::string getName(){return textureName;}
protected:
private:
std::string textureName;
GLuint textureId;
};
#endif // TNTEXTURE_H
|
0dfb91705605d6b8a031caedb5ffde54d8008e9f | 176372ffe75727e6b29f91c9c3df67ee0c851d4a | /omdbapi.cpp | 9b7d6e6eca8a996d949f045106a33e31b4295354 | [] | no_license | MarcoPossato/omdbapi | 9a9f36a9a4485010d10324f787dfb24ffb333988 | 0e78d7a8c8c0b62a4f4fc35479f3849b21fa5f26 | refs/heads/master | 2020-05-02T10:51:29.743472 | 2019-03-27T03:15:39 | 2019-03-27T03:15:39 | 177,909,552 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 7,857 | cpp | omdbapi.cpp | ///////////////////////////////////////////
// //
// Desenvolvimento em C++ //
// //
// Título: Busca Filmes //
// //
// Autor: Marco Possato //
// //
// Data: 25/03/2019 //
// //
///////////////////////////////////////////
#include <iostream>
#include <string>
#include <stdlib.h>
#include <Windows.h>
#include <curl/curl.h>
#include <json/json.h>
int comunica_site(std::string request) {
// Inicia comunicação com a url
CURL* curl = curl_easy_init();
// Monta a URL a ser chamada
curl_easy_setopt(curl, CURLOPT_URL, request.c_str());
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
// Timeout de 10 segundos.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10);
// Status da resposta
int httpCode(0);
std::unique_ptr<std::string> httpData(new std::string());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, httpData.get());
curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpCode);
curl_easy_cleanup(curl);
return httpCode;
}
namespace {
std::size_t callback(const char* in, std::size_t size,
std::size_t num, std::string* out)
{
const std::size_t totalBytes(size * num);
out->append(in, totalBytes);
return totalBytes;
}
}
int main() {
bool sair = 0;
char opcao_usuario;
std::string nome_filme;
std::string url_request;
int i = 0;
const std::string titulo_search(jsonData["Title"].asString());
const int year_search(jsonData["Year"].asInt());
const std::string rated_search(jsonData["Rated"].asString());
const std::string released_search(jsonData["Released"].asString());
const std::string runtime_search(jsonData["Runtime"].asString());
const std::string genre_search(jsonData["Genre"].asString());
const std::string director_search(jsonData["Director"].asString());
const std::string writer_search(jsonData["Writer"].asString());
const std::string actors_search(jsonData["Actors"].asString());
const std::string plot_search(jsonData["Plot"].asString());
const std::string language_search(jsonData["Language"].asString());
const std::string country_search(jsonData["Country"].asString());
const std::string awards_search(jsonData["Awards"].asString());
const std::string poster_search(jsonData["Poster"].asString());
const std::string ratings_search(jsonData["Ratings"].asString());
const std::string imd_search(jsonData["Internet Movie Database"].asString());
const int rotten_tomatoes_search(jsonData["Rotten Tomatoes"].asInt());
const std::string metacritic_search(jsonData["Metacritic"].asString());
const std::string type_search(jsonData["Type"].asString());
const std::string dvd_search(jsonData["DVD"].asString());
const int boxoffive_search(jsonData["BoxOffice"].asInt());
const std::string production_search(jsonData["Production"].asString());
const std::string website_search(jsonData["Website"].asString());
const std::string movie_type(jsonData["Movie"].asString());
const std::string series_type(jsonData["Series"].asString());
const std::string episode_type(jsonData["Episode"].asString());
std::cout << "*----------------------------*" << std::endl;
std::cout << "* Bem vindo ao Busca Filmes! *" << std::endl;
std::cout << "*----------------------------*" << std::endl << std::endl;
// estrutura do programa
do {
std::cout << "Pressione a opcao desejada." << std::endl << std::endl << "Pressione h para HELP;" << std::endl <<
"Pressione s para BUSCAR;" << std::endl << "Pressione t para TIPO;" << std::endl << "Pressione q para SAIR." <<
std::endl;
std::cin >> opcao_usuario;
system("cls");
switch (opcao_usuario)
{
// help
case 104:
std::cout << "Bem vindo a AJUDA!" << std::endl << std::endl;
std::cout << "Voce pode escolher as seguintes opcoes:" << std::endl << std::endl;
std::cout << "Pressione s para BUSCAR;" << std::endl << "Pressione t para TIPO;" << std::endl << "Pressione q para SAIR." <<
std::endl;
system("pause");
system("cls");
break;
// Search
case 115:
std::cout << "Busca!" << std::endl;
std::cout << "Qual filme deseja pesquisar?" << std::endl;
// tornou-se necessário colocar duas vezes o getline para poder esperar a inserção do nome
std::getline(std::cin, nome_filme);
std::getline(std::cin, nome_filme);
// transforma todos os espaços em +
do {
if (nome_filme[i] == 32) {
nome_filme[i] = 43;
}
i++;
} while (nome_filme[i] != '\0');
// monta a url a ser enviada
url_request = "http://www.omdbapi.com/?t" + nome_filme + "&apikey=6d211a10";
int resultado_search = comunica_site(url_request);
if (resultado_search == 200)
{
// Prepara para ler o arquivo em Json
Json::Value jsonData;
Json::Reader jsonReader;
if (jsonReader.parse(*httpData.get(), jsonData))
{
std::cout << "Title: " << titulo_search << std::endl;
std::cout << "Year: " << year_search << std::endl;
std::cout << "Rated: " << rated_search << std::endl;
std::cout << "Released: " << released_search << std::endl;
std::cout << "Runtime: " << runtime_search << std::endl;
std::cout << "Genre: " << genre_search << std::endl;
std::cout << "Director: " << director_search << std::endl;
std::cout << "Writer: " << writer_search << std::endl;
std::cout << "Actors: " << actors_search << std::endl;
std::cout << "Plot: " << plot_search << std::endl;
std::cout << "Language: " << language_search << std::endl;
std::cout << "Country: " << country_search << std::endl;
std::cout << "Awards: " << awards_search << std::endl;
std::cout << "Poster: " << poster_search << std::endl;
std::cout << "Ratings: " << ratings_search << std::endl;
std::cout << "Internet Movie Database: " << imd_search << std::endl;
std::cout << "Rotten Tomatoes: " << rotten_tomatoes_search << std::endl;
std::cout << "Metacritic: " << metacritic_search << std::endl;
std::cout << "Type: " << type_search << std::endl;
std::cout << "DVD: " << dvd_search << std::endl;
std::cout << "BoxOffice: " << boxoffive_search << std::endl;
std::cout << "Production: " << production_search << std::endl;
std::cout << "Website: " << website_search << std::endl;
}
else
{
std::cout << "Nao foi possivel carregar as informacoes" << std::endl;
return 0;
}
}
else
{
std::cout << "Sem resposta do site" << std::endl;
return 0;
}
// aguarda confirmação do usuário para prosseguir
system("pause");
system("cls");
break;
// type
case 116:
std::cout << "O tipo pesquisado e:" << std::endl;
// monta url do request
url_request = "http://www.omdbapi.com/?type&apikey=6d211a10";
int resultado_type = comunica_site(url_request);
if (resultado_type == 200)
{
// Prepara para ler o arquivo em Json
Json::Value jsonData;
Json::Reader jsonReader;
if (jsonReader.parse(*httpData.get(), jsonData))
{
std::cout << "Type: " << movie_type << std::endl;
std::cout << "Type: " << series_type << std::endl;
std::cout << "Type: " << episode_type << std::endl;
}
else
{
std::cout << "Nao foi possivel carregar as informacoes" << std::endl;
return 0;
}
}
else
{
std::cout << "Sem resposta do site" << std::endl;
return 0;
}
// aguarda confirmação do usuário para prosseguir
system("pause");
system("cls");
break;
// quit
case 113:
std::cout << "Obrigado!!!" << std::endl << "Volte sempre.";
sair = 1;
Sleep(2000);
break;
// null
default:
std::cout << "Opcao invalida." << std::endl << "Por favor, tente novamente." << std::endl;
Sleep(2000);
system("cls");
break;
}
} while (!sair);
return 0;
} |
396c66dbdcb71b9943ea17e1d59236c31f70c268 | 74a4b35e9846ebae3163668049e7f445015f685c | /AssaultRifle.cpp | e5a2c76997f3516dd632cb9fe322c08aeda8b056 | [] | no_license | PapaDabrowski/PROE1PROJEKT | c140cf6af2052117705de7c873598eb7784724fe | dfa378cb8cac8b83e9a080053c71a2e609c89dc7 | refs/heads/master | 2020-03-31T15:06:12.365111 | 2018-10-09T21:47:09 | 2018-10-09T21:47:09 | 152,324,052 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 885 | cpp | AssaultRifle.cpp | #include <iostream>
#include "AssaultRifle.h"
using namespace std;
AssaultRifle::AssaultRifle(unsigned int Id_,float Caliber_,unsigned int MagSize_,unsigned int MuzzleVelocity_,
unsigned int Range_,unsigned int Weight_,unsigned int Rate_)
{
Id=Id_;
Type="AssaultRifle";
MagSize=MagSize_;
MuzzleVelocity=MuzzleVelocity_;
Caliber=Caliber_;
Range=Range_;
Weight=Weight_;
RateOfFire=Rate_;
}
unsigned int AssaultRifle::GetId()
{
return Id;
}
std::string AssaultRifle::GetType()
{
return Type;
}
float AssaultRifle::GetCaliber()
{
return Caliber;
}
unsigned int AssaultRifle::GetInfo()
{
return RateOfFire;
}
unsigned int AssaultRifle::GetMuzzleVelocity()
{
return MuzzleVelocity;
}
unsigned int AssaultRifle::GetMagSize()
{
return MagSize;
}
unsigned int AssaultRifle::GetRange()
{
return Range;
}
unsigned int AssaultRifle::GetWeight()
{
return Weight;
}
|
d780fa5f5d5532185abc5415eb2a545e62004261 | e4d6419ccacb7e8629390e00aafc7182c5437f69 | /проект/Kappa/tests/interaction/k_VTTest.cpp | b22d79242e602b7a7fb3b5c2547f60f2a6686888 | [] | no_license | chikitkin/kappa-nn | e2dfb3f5639fd60afc47f0c7dc4bb2ffed29f29f | 8fa529f2ddf8d93f8005d6d98c0a304960af2418 | refs/heads/master | 2021-01-04T10:47:07.242538 | 2020-03-13T13:28:40 | 2020-03-13T13:28:40 | 240,512,746 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,543 | cpp | k_VTTest.cpp | /*
* File: omegaTest.cpp
*/
#include <iostream>
#include "kappa.hpp"
#include <fstream>
using namespace std;
using namespace kappa;
void calculate(Molecule m, Particle a, Approximation appr) {
std::cout << "Loading interaction parameters for " << m.name << "+" << a.name << endl;
Interaction inter(m, a, "c:/Users/st024385/Documents/DB/Interaction/interaction.yaml");
ofstream outf;
std::cout << "Calculating k_VT" << endl;
std::vector<double> T_vals = { 500., 1000., 2000., 5000., 10000., 15000., 20000., 25000., 30000., 40000. };
std::vector<int> i_vals;
i_vals = { 1, 5, 10, 20, 30 };
std::vector<std::string> model_names = {"Billing", "FHO+RS", "FHO+VSS"};
std::vector<std::string> cs_model_names = {"FHO+RS"};
std::vector<kappa::models_k_vt> VT_models = {models_k_vt::model_k_vt_billing, models_k_vt::model_k_vt_rs_fho, models_k_vt::model_k_vt_vss_fho};
std::vector<kappa::models_cs_vt> VT_cs_models = {models_cs_vt::model_cs_vt_rs_fho};
// std::vector<std::string> TM_model_names = {"Treanor-Marrone, U=inf, Scanlon", "Treanor-Marrone, U=D/6K, Scanlon", "Treanor-Marrone, U=3T, Scanlon"};
// std::vector<kappa::models_k_diss> TM_model_vals = {model_k_diss_tm_infty_arrh_scanlon, model_k_diss_tm_D6k_arrh_scanlon, model_k_diss_tm_3T_arrh_scanlon};
double res, tmp;
outf.open("c:/Users/st024385/Documents/Code/kappa-tests/VT-FHO/" + m.name + "_" + a.name + ".txt");
outf << "T;";
int counter;
for (auto i : i_vals) {
counter = 0;
for (auto VT_model: VT_models) {
outf << model_names[counter] << ",i=" << i << "(" << m.vibr_energy[0][i] / K_CONST_EV << " eV);";
counter++;
}
outf << ";";
}
outf << endl;
for (auto T : T_vals) {
outf << T << ";";
for (auto i : i_vals) {
for (auto VT_model: VT_models) {
outf << appr.k_VT(T, m, inter, i, -1, VT_model) << ";";
counter++;
}
outf << ";";
}
outf << endl;
}
outf.close();
double g;
outf.open("c:/Users/st024385/Documents/Code/kappa-tests/VT-FHO/" + m.name + "_" + a.name + "_CS.txt");
outf << "t;";
for (auto i : i_vals) {
counter = 0;
for (auto VT_cs_model: VT_cs_models) {
outf << cs_model_names[counter] << ",i=" << i << "(" << m.vibr_energy[0][i] / K_CONST_EV << " eV);";
counter++;
}
}
outf << endl;
for (int k=0; k<40; k++) {
g = k * 5000; // energy of relative motion in Kelvins
outf << g << ";";
g = sqrt(2 * g * K_CONST_K / inter.collision_mass);
for (auto i : i_vals) {
for (auto VT_cs_model: VT_cs_models) {
outf << appr.crosssection_VT(g, m, inter, i, -1, VT_cs_model) << ";";
counter++;
}
}
outf << endl;
}
outf.close();
}
int main(int argc, char** argv) {
std::cout << "Start Test for k_VT coefficients, loading particle data" << endl;
Molecule N2("N2", false, true, "c:/Users/st024385/Documents/DB/Particles/particles.yaml");
// Molecule O2("O2", false);
Atom N("N", "c:/Users/st024385/Documents/DB/Particles/particles.yaml");
// Atom O("O");
Approximation ApproximationTest{};
calculate(N2, N, ApproximationTest);
calculate(N2, N2, ApproximationTest);
// calculate(O2, O, ApproximationTest);
string a;
cout << "Enter anything to quit: ";
cin >> a;
return 0;
}
|
143d39d9b9d25d638051363034ba7a9a8c6b8f5e | c569d3158379e966c30cad257be58a874f2afbf7 | /src/Largest Rectangle in Histogram/Largest Rectangle in Histogram.cpp | 53f192ce547b49ed715c964e8214d97685922dbe | [] | no_license | luas13/Leetcode_New | 5f59412bdb7d020ca07d38997e5d08dc8ce73074 | 01fc9cca279c223352df3a28f0708c7b7e495f05 | refs/heads/master | 2021-01-09T06:39:51.419046 | 2019-05-28T04:04:01 | 2019-05-28T04:04:01 | 68,578,643 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,063 | cpp | Largest Rectangle in Histogram.cpp | //Its better to store index of element in the stack because
//at any point of time, u can get both the element and its value
class Solution {
public:
int largestRectangleArea(vector<int>& heights) {
int l = heights.size();
if (l < 2)
return (l == 0 ? 0: heights[0]);
stack<int> s;
int i=0;
int max_area = INT_MIN;
while (i<l)
{
if (s.empty() || heights[s.top()] <= heights[i])
s.push(i++);
else
{
int topi = s.top();
// Imp: we pop the top element first
s.pop();
max_area = max(max_area, heights[topi] * (s.empty() ? i : i-1 - s.top()) );
}
}
while (!s.empty())
{
int topi = s.top();
s.pop();
max_area = max(max_area, heights[topi] * (s.empty() ? l : l-1 - s.top()) );
}
return max_area;
}
};
|
0899a141f69c0d604709bddedeeccd84bc7164f4 | 004b3695ff689d613bda1c1b7f71562eed24938c | /wbc_opspace/opspace/src/testTask.cpp | 1ca104898caf58973514c62bf1ebcbb7ed1fa769 | [] | no_license | hsu/whole_body_control | 0f36d8520e17255a3f358c099269b257a9e759af | 9b766d29152681b0fe97743f0c4000fd1e69428d | refs/heads/master | 2020-12-30T18:57:32.951936 | 2011-03-02T00:17:00 | 2011-03-02T00:17:00 | 1,442,582 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,520 | cpp | testTask.cpp | /*
* Whole-Body Control for Human-Centered Robotics http://www.me.utexas.edu/~hcrl/
*
* Copyright (c) 2011 University of Texas at Austin. All rights reserved.
*
* Authors: Roland Philippsen and Luis Sentis
*
* BSD license:
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of
* contributors to this software may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR THE CONTRIBUTORS TO THIS SOFTWARE 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 <gtest/gtest.h>
#include <opspace/task_library.hpp>
#include <opspace/Controller.hpp>
#include <jspace/test/model_library.hpp>
#include <err.h>
using jspace::Model;
using jspace::State;
using jspace::pretty_print;
using namespace opspace;
using namespace std;
static Model * get_puma()
{
static Model * puma(0);
if ( ! puma) {
puma = jspace::test::create_puma_model();
}
size_t const ndof(puma->getNDOF());
State state(ndof, ndof, 0);
for (size_t ii(0); ii < ndof; ++ii) {
state.position_[ii] = 0.01 * ii + 0.08;
state.velocity_[ii] = 0.02 - 0.005 * ii;
}
puma->update(state);
return puma;
}
TEST (task, basics)
{
Model * puma(get_puma());
SelectedJointPostureTask odd("odd");
Status st;
st = odd.update(*puma);
EXPECT_FALSE (st.ok) << "update before init should have failed";
st = odd.init(*puma);
EXPECT_FALSE (st.ok) << "init before selection setting should have failed";
Parameter * selection(odd.lookupParameter("selection", TASK_PARAM_TYPE_VECTOR));
ASSERT_NE ((void*)0, selection) << "failed to retrieve selection parameter";
Vector sel(Vector::Zero(puma->getNDOF()));
for (size_t ii(0); ii < puma->getNDOF(); ii += 2) {
sel[ii] = 1.0;
}
st = selection->set(sel);
EXPECT_TRUE (st.ok) << "failed to set selection: " << st.errstr;
st = odd.init(*puma);
EXPECT_TRUE (st.ok) << "init failed: " << st.errstr;
st = odd.update(*puma);
EXPECT_TRUE (st.ok) << "update failed: " << st.errstr;
}
static SelectedJointPostureTask * create_sel_jp_task(string const & name, Vector const & selection)
throw(runtime_error)
{
SelectedJointPostureTask * task(new SelectedJointPostureTask(name));
Parameter * sel_p(task->lookupParameter("selection", TASK_PARAM_TYPE_VECTOR));
if ( ! sel_p) {
delete task;
throw runtime_error("failed to retrieve selection parameter");
}
Status const st(sel_p->set(selection));
if ( ! st) {
delete task;
throw runtime_error("failed to set selection: " + st.errstr);
}
return task;
}
static void append_odd_even_tasks(Controller & ctrl, size_t ndof)
throw(runtime_error)
{
vector<Task*> task;
try {
Vector sel_odd(Vector::Zero(ndof));
Vector sel_even(Vector::Zero(ndof));
for (size_t ii(0); ii < ndof; ++ii) {
if (0 == (ii % 2)) {
sel_even[ii] = 1.0;
}
else {
sel_odd[ii] = 1.0;
}
}
task.push_back(create_sel_jp_task("odd", sel_odd));
task.push_back(create_sel_jp_task("even", sel_even));
for (size_t ii(0); ii < task.size(); ++ii) {
if ( ! ctrl.appendTask(task[ii], true)) {
throw runtime_error("failed to add task `" + task[ii]->getName() + "'");
}
task[ii] = 0; // avoid double-free in case we throw later
}
}
catch (runtime_error const & ee) {
for (size_t ii(0); ii < task.size(); ++ii) {
delete task[ii];
}
throw ee;
}
}
static void append_odd_full_tasks(Controller & ctrl, size_t ndof)
throw(runtime_error)
{
vector<Task*> task;
try {
Vector sel_odd(Vector::Zero(ndof));
Vector sel_full(Vector::Ones(ndof));
for (size_t ii(1); ii < ndof; ii += 2) {
sel_odd[ii] = 1.0;
}
task.push_back(create_sel_jp_task("odd", sel_odd));
task.push_back(create_sel_jp_task("full", sel_full));
for (size_t ii(0); ii < task.size(); ++ii) {
if ( ! ctrl.appendTask(task[ii], true)) {
throw runtime_error("failed to add task `" + task[ii]->getName() + "'");
}
task[ii] = 0; // avoid double-free in case we throw later
}
}
catch (runtime_error const & ee) {
for (size_t ii(0); ii < task.size(); ++ii) {
delete task[ii];
}
throw ee;
}
}
TEST (controller, odd_even)
{
Task * jpos(0);
Vector gamma_jpos;
vector<Controller*> ctrl;
vector<ostringstream*> msg;
vector<Vector> gamma;
try {
Model * puma(get_puma());
Matrix aa;
Vector gg;
ASSERT_TRUE (puma->getMassInertia(aa)) << "failed to get mass inertia";
ASSERT_TRUE (puma->getGravity(gg)) << "failed to get gravity";
jpos = create_sel_jp_task("all", Vector::Ones(puma->getNDOF()));
Status st;
st = jpos->init(*puma);
EXPECT_TRUE (st.ok) << "failed to init jpos task: " << st.errstr;
st = jpos->update(*puma);
EXPECT_TRUE (st.ok) << "failed to update jpos task: " << st.errstr;
gamma_jpos = aa * jpos->getCommand() + gg;
msg.push_back(new ostringstream());
ctrl.push_back(new SController("Samir", msg.back()));
gamma.push_back(Vector::Zero(puma->getNDOF()));
msg.push_back(new ostringstream());
ctrl.push_back(new LController("Luis", msg.back()));
gamma.push_back(Vector::Zero(puma->getNDOF()));
for (size_t ii(0); ii < ctrl.size(); ++ii) {
append_odd_even_tasks(*ctrl[ii], puma->getNDOF());
st = ctrl[ii]->init(*puma);
EXPECT_TRUE (st.ok) << "failed to init controller #"
<< ii << " `" << ctrl[ii]->getName() << "': " << st.errstr;
st = ctrl[ii]->computeCommand(*puma, gamma[ii]);
EXPECT_TRUE (st.ok) << "failed to compute torques #"
<< ii << " `" << ctrl[ii]->getName() << "': " << st.errstr;
cout << "==================================================\n"
<< "messages from controller #" << ii << " `" << ctrl[ii]->getName() << "'\n"
<< "--------------------------------------------------\n"
<< msg[ii]->str();
}
cout << "==================================================\n"
<< "whole-body torque comparison:\n";
pretty_print(gamma_jpos, cout, " reference jpos task", " ");
for (size_t ii(0); ii < ctrl.size(); ++ii) {
pretty_print(gamma[ii], cout, " controller `" + ctrl[ii]->getName() + "'", " ");
Vector const delta(gamma_jpos - gamma[ii]);
pretty_print(delta, cout, " delta", " ");
}
}
catch (exception const & ee) {
ADD_FAILURE () << "exception " << ee.what();
for (size_t ii(0); ii < ctrl.size(); ++ii) {
delete ctrl[ii];
}
for (size_t ii(0); ii < msg.size(); ++ii) {
delete msg[ii];
}
}
}
TEST (controller, odd_full)
{
Task * jpos(0);
Vector gamma_jpos;
vector<Controller*> ctrl;
vector<ostringstream*> msg;
vector<Vector> gamma;
try {
Model * puma(get_puma());
Matrix aa;
Vector gg;
ASSERT_TRUE (puma->getMassInertia(aa)) << "failed to get mass inertia";
ASSERT_TRUE (puma->getGravity(gg)) << "failed to get gravity";
jpos = create_sel_jp_task("all", Vector::Ones(puma->getNDOF()));
Status st;
st = jpos->init(*puma);
EXPECT_TRUE (st.ok) << "failed to init jpos task: " << st.errstr;
st = jpos->update(*puma);
EXPECT_TRUE (st.ok) << "failed to update jpos task: " << st.errstr;
gamma_jpos = aa * jpos->getCommand() + gg;
msg.push_back(new ostringstream());
ctrl.push_back(new SController("Samir", msg.back()));
gamma.push_back(Vector::Zero(puma->getNDOF()));
msg.push_back(new ostringstream());
ctrl.push_back(new LController("Luis", msg.back()));
gamma.push_back(Vector::Zero(puma->getNDOF()));
msg.push_back(new ostringstream());
ctrl.push_back(new TPController("TaskPosture", msg.back()));
gamma.push_back(Vector::Zero(puma->getNDOF()));
for (size_t ii(0); ii < ctrl.size(); ++ii) {
append_odd_full_tasks(*ctrl[ii], puma->getNDOF());
st = ctrl[ii]->init(*puma);
EXPECT_TRUE (st.ok) << "failed to init controller #"
<< ii << " `" << ctrl[ii]->getName() << "': " << st.errstr;
st = ctrl[ii]->computeCommand(*puma, gamma[ii]);
EXPECT_TRUE (st.ok) << "failed to compute torques #"
<< ii << " `" << ctrl[ii]->getName() << "': " << st.errstr;
cout << "==================================================\n"
<< "messages from controller #" << ii << " `" << ctrl[ii]->getName() << "'\n"
<< "--------------------------------------------------\n"
<< msg[ii]->str();
}
cout << "==================================================\n"
<< "whole-body torque comparison:\n";
pretty_print(gamma_jpos, cout, " reference jpos task", " ");
for (size_t ii(0); ii < ctrl.size(); ++ii) {
pretty_print(gamma[ii], cout, " controller `" + ctrl[ii]->getName() + "'", " ");
Vector const delta(gamma_jpos - gamma[ii]);
pretty_print(delta, cout, " delta", " ");
}
}
catch (exception const & ee) {
ADD_FAILURE () << "exception " << ee.what();
for (size_t ii(0); ii < ctrl.size(); ++ii) {
delete ctrl[ii];
}
for (size_t ii(0); ii < msg.size(); ++ii) {
delete msg[ii];
}
}
}
int main(int argc, char ** argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS ();
}
|
3b3779a2c6fb085c45dbcf3069593b5a603c5d1b | aab998e72720bb425e35fd7154ad5f1af14f6d73 | /week6/stringEg12.cpp | bf7a5b59e089fbe75629f38665156698a692583c | [] | no_license | zhenglab/OOP | 5e2407f36d61e4adc897db0670d4d8fd1f112a26 | 67a16498a6033eb8f9eacc6fc755cae9cafd0720 | refs/heads/master | 2021-01-23T03:54:21.244635 | 2018-05-02T09:15:36 | 2018-05-02T09:15:36 | 86,136,120 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 273 | cpp | stringEg12.cpp | #include <iostream>
#include <string>
using namespace std;
//string的删除 成员函数erase()
int main()
{
string s1("hello world");
cout<<s1<<","<<s1.length()<<","<<s1.size()<<endl;
s1.erase(5);
cout<<s1<<","<<s1.length()<<","<<s1.size()<<endl;
return 0;
}
|
6cd63fe8bc8745c13707896912509fa739bfea19 | 70e88d49f779f03cdab00a6b18a0f902bd7136cc | /IMACMan/src/Ghost.cpp | 78d692b8c260981227c2408bbb7f23bd3d2618ff | [] | no_license | NeirdaP/IMAC-Man | fd986338fd389c2d6e073a89caf0dd43add2e9ce | f72c2de43169b39669a3361791356c997807dbdd | refs/heads/master | 2021-09-03T23:20:34.503873 | 2018-01-12T18:50:18 | 2018-01-12T18:50:18 | 114,548,616 | 0 | 0 | null | 2018-01-12T12:02:37 | 2017-12-17T15:46:24 | C | UTF-8 | C++ | false | false | 3,482 | cpp | Ghost.cpp | //
// Created by Thibault on 02/01/2018.
//
#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include "../include/Ghost.h"
Ghost::Ghost(){
Personnage();
setPosXY(7, 7);
active = true;
regenerationTimer = 10;
}
Ghost::~Ghost(){
std::cout << "fantome detruit" << std::endl;
}
//getters
float Ghost::getRegenTimer(){
return regenerationTimer;
}
//setters
void Ghost::setRegenTimer(float t){
regenerationTimer = t;
}
void Ghost::moveRandom(Labyrinth* laby){
//std::srand(std::time(nullptr));
int randomDir = std::rand() % 4;
//std::cout << "random dir : " << randomDir << std::endl;
move(randomDir, laby);
}
void Ghost::move(int action, Labyrinth* laby){
//std::cout << "move ghost" << std::endl;
int positionX = (int)getPosX();
int positionY = (int)getPosY();
laby->setOneCaseLaby(positionX, positionY, 0);
bool movementDone = false;
while(!movementDone) {
switch (action) {
case 0:
//veut aller en haut
//véririfie s'il y a un mur, si oui rappelle move(action++)
if (laby->getLaby()[positionX * laby->getWidth() + (positionY - 1)] == 1) {
action++;
} else {
positionY--;
movementDone = true;
}
break;
case 1:
//veut aller à droite
if (laby->getLaby()[(positionX + 1) * laby->getWidth() + positionY] == 1) {
action++;
} else {
positionX++;
movementDone = true;
}
break;
case 2:
//veut aller en bas
if (laby->getLaby()[positionX * laby->getWidth() + (positionY + 1)] == 1) {
action++;
} else {
positionY++;
movementDone = true;
}
break;
case 3:
//veut aller à gauche
if (laby->getLaby()[(positionX - 1) * laby->getWidth() + positionY] == 1) {
action = 0;
} else {
positionX--;
movementDone = true;
}
break;
default:
action = 0;
break;
}
}
setPosX((float)positionX);
setPosY((float)positionY);
if(!active){
setPosXY(7,7);
}
else{
laby->setOneCaseLaby(positionX, positionY, 5);
}
setDirection(action);
}
void Ghost::eat(Pacman* p,glimac::SDLWindowManager& windowManager){
if(p->getPosX() == getPosX() && p->getPosY() == getPosY()){
if(!p->getIsPrey()) {
p->die();
}
else if(p->getIsPrey()){
std::cout <<"--------------------" << std::endl << "Vous avez mange un fantome" << std::endl << "--------------------" << std::endl;
p->setPoints(p->getPoints()+100);
active = false;
deactivatedTime = windowManager.getTime();
}
}
}
bool Ghost::isActive() const {
return active;
}
void Ghost::setActive(bool active) {
Ghost::active = active;
}
float Ghost::getDeactivatedTime() const {
return deactivatedTime;
}
void Ghost::setDeactivatedTime(float deactivatedTime) {
Ghost::deactivatedTime = deactivatedTime;
}
|
c6b97e1adfd17b1943cf1ec023fba1215e73b487 | 0238be70211e249b0702f153d9449dbc5a969ac6 | /线性表 - 单链表/List.h | 99f3453fca207bb96aa98f8d6a6bb33cb6addeac | [] | no_license | xianyun2014/data-struct_and_algorithm | c5ca1b5cdac2ef448bceaba9bbe7a92ceb4f6daf | 186128785bb4b41ea426bb5d1b1f07ddb3e670aa | refs/heads/master | 2021-01-23T17:20:13.252297 | 2014-09-29T16:54:04 | 2014-09-29T16:54:04 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 5,080 | h | List.h | /********************************************************************
purpose: 带头结点的循环单链表
author: xianyun1230
QQ: 836663997
e-mail: xianyun1230@163.com
created: 2014/02/13
*********************************************************************/
#include <iostream>
template<typename T>
class List
{
public:
List();
~List();
bool push_back(const T &val); //末尾插入数据
bool push_front(const T &val); //开头插入数据
bool pop_front(T &val); //开头删除数据
void reverse(); //链表倒置
bool del(const T & val); //删除所有值为val 的元素
bool erase(int s, int e); //删除[s,e] 区间内容
bool sort(); //从小到大排列,插入排序实现
int count(const T & val); //统计val 值出现的次数
bool empty(){return _size == 0;}
unsigned int size() const {return _size;} //返回元素个数
void show() const; //遍历链表
T operator[](const int n) const;
private:
typedef struct _Node
{
T data;
_Node * next;
}Node;
Node * head, * end; //分别指向头结点、尾指针
unsigned int _size; //元素数
};
template<typename T>
List<T>::List() //默认构造函数,创建头尾结点,元素数为0
{
_size = 0;
head = new Node;
head->next = head;
end = head;
}
template<typename T>
List<T>::~List()
{
Node * ph = head, *pt = head->next;
while(pt != head)
{
ph = pt->next;
delete pt;
pt = ph;
}
}
template<typename T>
bool List<T>::push_back(const T & val)
{
Node *temp = new Node; //temp用作新尾,next属性设为head以循环(循环链表)
temp->data = val;
temp->next = head;
end->next = temp;
end = temp; //指向新尾
++_size;
return true;
}
template<typename T>
bool List<T>::push_front(const T &val)
{
Node *temp = new Node;
temp->data = val;
temp->next = head->next;
head->next = temp;
++_size;
return true;
}
template<typename T>
bool List<T>::pop_front(T &val)
{
if (_size == 0)
return 0;
Node *temp = head->next;
val = temp->data; //用于返回值
head->next = temp->next;
delete temp;
--_size;
if (_size == 0)
end = head;
return val;
}
template<typename T>
void List<T>::reverse() //链表前端就地倒置
{
if (_size < 2)
return;
Node * ps = head->next; //新尾
Node * pn = ps->next; //从第二个结点开始未待倒置部分
Node * pnn = pn->next; //pnn标记待倒置部分
while(pn != head) //到结尾会循环到head
{
pn->next = head->next; //pn融入已倒置部分
head->next = pn; //head带领已倒置部分
pn = pnn;
pnn = pnn->next; //未倒置部分后移
}
ps->next = head; //ps指向的为已倒置部分最后一个结点,指向head保证循环
end = ps;
}
template<typename T>
bool List<T>::del(const T &val)
{
bool deled = false;
if (_size > 0)
{
Node * pt = new Node;
Node * pl = pt;
Node * temp = pl; //用于释放内存
pl->next = head->next;
while(pl != head)
{
if (pl->next->data == val)
{
temp = pl->next; //存储待删位置
pl->next = pl->next->next; //隔离待删结点
delete temp; //释放内存
--_size;
deled = true;
}
pl = pl->next;
}
if (_size == 0)
end = head;
delete pt;
}
return deled;
}
template<typename T>
bool List<T>::erase(int s, int e) //删除[s,e]区间
{
if (e<s || s<0 || e >= _size)
return false;
int num = s;
Node * ps = head;
while(num--)
ps = ps->next; //找到下标为s 的元素的前一个元素
num = e - s + 1; //释放e - s + 1 个元素
Node * pe = ps->next;
Node * pt = pe;
while(num--)
{
pe = pe->next;
delete pt;
pt = pe;
}
ps->next = pe; //拼接
return true;
}
template<typename T>
bool List<T>::sort() //插入排序算法
{
if (_size >= 2)
{
Node * ps = head->next->next; //指向未排序区域
Node *pi, *pt;
head->next->next = NULL; //已排序区域(第一个结点)末尾设置NULL,以作标记
while(ps != head)
{
for (pi = head; (pi->next != NULL) && (pi->next->data <= ps->data); pi = pi->next) //查找插入位置
continue;
pt = ps; //存取需插入节点
ps = ps->next; //未排序区后移
if (pi->next != NULL) //判断是否为已排序区最大值
{
pt->next = pi->next;
pi->next = pt;
}
else
{
pi->next = pt;
pt->next = NULL; //为最大值需设置尾部NULL标记
}
}
pt = head->next; //寻找NULL前第一个节点
while(pt->next)
pt = pt->next;
pt->next = head; //循环
}
return true;
}
template<typename T>
int List<T>::count(const T &val)
{
int n = 0;
Node * ps = head->next;
while(ps != head)
{
if (ps->data == val)
++n;
ps = ps->next;
}
return n;
}
template<typename T>
void List<T>::show()const
{
Node * temp = head->next;
std::cout <<"链表数据共" <<size() <<"个,内容如下:\n";
while(temp != head){
std::cout <<temp->data <<std::endl;
temp = temp->next;
}
}
template<typename T>
T List<T>::operator[](const int n) const
{
if (n < 0 || n >= _size)
return 0;
int num = n;
Node * pt = head->next;
while(num--)
pt = pt->next;
return pt->data;
}
|
6977cd6cdc0e3f667e08e5cc2630c7288a85a0d5 | a422561a72722b53213c738e8de9b5749c0818d5 | /CodeC3/TuanLinh_C3_Bai1.cpp | 91cf0f712e41dd228a3dffab974f0b5c283f2427 | [] | no_license | hieu-ln/IT81-11 | 60b572c4c9b63e9fa6770798e4a9758cd0fa9e1b | e4788f70b9083cd342f5664fe32fe98de4d57b4d | refs/heads/master | 2020-06-11T06:41:27.616057 | 2019-08-13T15:18:13 | 2019-08-13T15:18:13 | 193,879,451 | 0 | 3 | null | 2019-07-19T17:02:26 | 2019-06-26T10:05:03 | null | UTF-8 | C++ | false | false | 7,800 | cpp | TuanLinh_C3_Bai1.cpp | #include <iostream>
#include <stdio.h>
#include <ctime>
using namespace std;
#define MAX 5000
//cau 1.1
int a[MAX];
int n;
// Nhap danh sach
void init(int a[], int &n)
{
cout << "Nhap so luong phan tu cua danh sach: ";
cin >> n;
for (int i = 0; i < n; i++)
a[i] = rand() % 1000 + 1;
cout << "Danh sach da duoc sap xep ngau nhien nhu sau: " << endl;
for (int i = 0; i < n; i++)
cout << a[i] << " ";
cout << endl;
}
void input(int a[], int n)
{
cout << "Nhap so luong phan tu cua danh sach: ";
cin >> n;
cout << "Nhap vao cac phan tu cua danh sach: " << endl;
for (int i = 0; i < n; i++)
{
cout << "a[" << i << "]=";
cin >> a[i];
}
}
//xuat danh sach
void output(int a[], int n)
{
for ( int i = 0; i < n; i++)
cout << a[i] << "\t";
cout << endl;
}
void copyArray(int a[], int b[], int n)
{
for ( int i = 0; i < n; i++)
b[i] = a[i];
}
//Insertion sort
void insertion(int a[], int n)
{
int i, j, x;
for (i = 1; i < n; i++)
{
x = a[i]; //luu gia tri a[i]
j = i - 1;
while (j >= 0 && x < a[i])
{
a[j + 1] = a[j];
j--;
}
a[j + 1] = x;
}
}
//Doi cho 2 so nguyen
void swap(int &a, int &b)
{
int t = a;
a = b;
b = t;
}
//Selection sort
void selection(int a[], int n)
{
int i, j, z;
for (i = 0; i < n; i++)
{
z = i;
for ( j = i + 1; j < n; j++)
if (a[j] < a[z])
z = j;
swap(a[z], a[i]);
}
}
//Interchange sort
void interchange(int a[], int n)
{
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (a[i] > a[j])
swap(a[i], a[j]);
}
//Bubble sort
void bubble(int a[], int n)
{
int i, j;
bool haveSwap = false;
for (i = 0; i < n - 1; i++)
{
haveSwap = false;
for ( j = 0; j < n - 1; j++)
{
if (a[j] > a[j + 1])
{
swap(a[j], a[j + 1]);
haveSwap = true;
}
}
if (haveSwap == false)
break;
}
}
//cau 1.8
int partition(int a[], int low, int high)
{
int pivot = a[high];
int left = low;
int right = high - 1;
while (true)
{
while (left <= right && a[left] < pivot)
left++;
while (right >= left && a[right] > pivot)
right--;
if (left >= right)
break;
swap(a[left], a[right]);
left++;
right--;
}
swap(a[left], a[right]);
return left;
}
//Quick sort
void quick(int a[], int low, int high)
{
if (low < high)
{
int pi = partition(a, low, high);
//pi la chi so noi phan tu nay dung dung vi tri va la phan tu chia mang lam 2 phan trai va phai
quick(a, low, pi - 1);
quick(a, pi + 1, high);
}
}
//cau 1.9
void heapify(int a[], int n, int i)
{
int largest = i;
int l = 2 * i + 1;
int r = 2 * i + 2;
if (l < n && a[l] > a[largest])
largest = l; //neu con cuoi ben trai lonws hon goc
if (r < n && a[r] > a[largest])
largest = r; //neu con phai la con lon hon con lon nhat sau cung
if (largest != i)
{
swap(a[i], a[largest]);
heapify(a, n, largest);
}
}
//Heap sort
void heap(int a[], int n)
{
for (int i = (n / 2) - 1; i >= 0; i--)
heapify(a, n, i);
for (int i = n - 1; i >= 0; i--)
{
swap(a[0], a[i]);
heapify(a, i, 0);
}
}
//Search sequence
void sequence(int a[], int n, int x)
{
int i = 0;
while (i < n && a[i] != x)
i++;
if (i == n)
cout << "Khong tim thay gia tri " << x << endl;
else
cout << "Tim thay gia tri " << x << " tai vi tri " << i << endl;
}
//Search binary
int binary(int a[], int l, int r, int x)
{
if (r >= 1)
{
int mid = l + (r - 1) / 2;
if (a[mid] == x)
return mid;
if (a[mid] > x)
return binary(a, l, mid - 1, x);
return binary(a, mid + 1, r, x);
}
return -1;
}
int main()
{
int b[MAX];
clock_t start;
double duration;
int choice, x, i;
system("cls");
cout << "------------MENU------------" << endl;
cout << "1. Khoi tao danh sach ngau nhien " << endl;
cout << "2. Nhap danh sach " << endl;
cout << "3. Xuat danh sach " << endl;
cout << "4. Sap xep tang dan theo selection " << endl;
cout << "5. Sap xep tang dan theo insertion " << endl;
cout << "6. Sap xep tang dan theo bubble " << endl;
cout << "7. Sap xep tang dan theo interchange " << endl;
cout << "8. Sap xep tang dan theo quick " << endl;
cout << "9. Sap xep tang dan theo heap " << endl;
cout << "10. Tim kiem phan tu 1 cach tuan tu " << endl;
cout << "11. Tim kiem phan tu theo nhi phan " << endl;
cout << "12. Thoat " << endl;
do {
cout << "Vui long chon so de thuc hien " << endl;
cin >> choice;
switch(choice)
{
case 1:
init(a, n);
break;
case 2:
input(a, n);
break;
case 3:
cout << "Danh sach la: ";
break;
case 4:
copyArray(a, b, n);
start = clock();
selection(b, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep selection la: " << duration * 1000000 << " Microseconds";
break;
case 5:
copyArray(a, b, n);
start = clock();
insertion(b, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep insertion la: " << duration * 1000000 << " Microseconds";
break;
case 6:
copyArray(a, b, n);
start = clock();
bubble(b, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep bubble la: " << duration * 1000000 << " Microseconds";
break;
case 7:
copyArray(a, b, n);
start = clock();
interchange(b, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep interchange la: " << duration * 1000000 << " Microseconds";
break;
case 8:
copyArray(a, b, n);
start = clock();
quick(a, 0, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep quick la: " << duration * 1000000 << " Microseconds";
break;
case 9:
copyArray(a, b, n);
start = clock();
heap(b, n);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (n < 100)
{
cout << "Danh sach sau khi sap xep la: ";
output(b, n);
}
if (duration > 0)
cout << "Thoi gian thuc hien sap xep heap la: " << duration * 1000000 << " Microseconds";
break;
case 10:
cout << "Nhap gia tri can tim : ";
cin >> x;
start = clock();
sequence(a, n, x);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (duration > 0)
cout << "Thoi gian tim kiem tuan tu la: " << duration * 1000000 << " Microseconds";
break;
case 11:
cout << "Nhap gia tri can tim : ";
cin >> x;
start = clock();
i = binary(b, 0, n, x);
duration = (clock() - start) / (double) CLOCKS_PER_SEC;
if (i == -1)
cout << "Khong tim thay " << x << endl;
else
cout << "Tim thay x " << x << " tai vi tri " << i << endl;
if (duration > 0)
cout << "Thoi gian tim kiem nhi phan la: " << duration * 1000000 << " Microseconds";
break;
case 12:
cout << "Goodbye.....!";
break;
default:
break;
}
} while (choice >= 11);
return 0;
} |
0a52904316b24cc1fdd8167b0fe6943625b50e1c | e7c7806044478cadf6d3858d216b4a1e897a2ad7 | /source/Renderer/Mesh.h | 82f2e30e93daa59fcce8334e931d70ef3c7b24d6 | [
"MIT"
] | permissive | Sherin192/NoctisEngine | 21b1e09b50ce4f6a4ad4f009c6958c985b13ae07 | ac0eccf1822f9e05203f53028e4c77b71da9bf9b | refs/heads/master | 2020-07-06T14:25:48.302354 | 2020-06-12T03:20:24 | 2020-06-12T03:20:24 | 203,048,185 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,933 | h | Mesh.h | #ifndef _MESH_H
#define _MESH_H
#include "NoctisRenderDevice.h"
#include "NoctisBuffers.h"
#include "NoctisTexture.h"
#include "Vertex.h"
#include "Material.h"
//------------------------------------------------------------------------------------
// Forward Declarations:
//------------------------------------------------------------------------------------
namespace noctis
{
class AssetImporterImpl;
namespace rdr
{
class Shader;
class Material;
}
}
//====================================================================================
namespace noctis::rdr
{
//------------------------------------------------------------------------------------
// Mesh:
//------------------------------------------------------------------------------------
class Mesh
{
public:
Mesh(std::shared_ptr<RenderDevice>&, std::string&, std::vector<Vertex>&, std::vector<unsigned>&);
Mesh(const Mesh& other) = delete;
//TODO: rule of 5
Mesh(Mesh&& other) noexcept;
void Render(std::shared_ptr<RenderDevice>& renderDevice);
VertexBuffer<Vertex>& GetVertexBuffer() noexcept { return m_vertexBuffer; }
IndexBuffer<>& GetIndexBuffer() noexcept { return m_indexBuffer; }
const std::string& GetName() const noexcept { return m_name; }
std::shared_ptr<Material> GetMaterial() noexcept { return MaterialPool::Instance().GetMaterial(m_materialName); }
void SetMaterial(const std::string& name) { m_materialName = name; }
private:
void Setup(std::shared_ptr<RenderDevice>& renderDevice, std::vector<Vertex>& vertices, std::vector<unsigned>& indices);
std::string m_name;
std::string m_materialName;
VertexBuffer<Vertex> m_vertexBuffer;
IndexBuffer<> m_indexBuffer;
friend class AssetImporterImpl;
};
//====================================================================================
} //noctis::rdr
#endif //_MESH_H
|
36fd54b7f50a56e14e490ef79ac8063cc78f70f5 | 5b3b2d225b88dd3e991ef4ad147805834f7dd8a2 | /graph/FractionalProgramming分数规划.cpp | 912e90573edd3df53e8d4359fffcda0607577d9f | [] | no_license | dnvtmf/ACM | 129fce98ee3ede1538a26848b14397026f8b98bc | ce6bcc625e106851566b03c95fb20ad111fbede2 | refs/heads/master | 2021-01-10T13:01:29.203524 | 2017-08-07T11:50:38 | 2017-08-07T11:50:38 | 36,800,547 | 9 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,080 | cpp | FractionalProgramming分数规划.cpp | ///分数规划 Fractional Programming
//source: <<最小割模型在信息学竞赛中的应用>>
/*
一般形式: $\min{\{\lambda = f( \overrightarrow{x}) = \frac{a(\overrightarrow{x})}{b(\overrightarrow{x})}\}}(\overrightarrow{x} \in S, \forall \overrightarrow{x} \in S, b(\overrightarrow{x}) > 0)$
其中解向量$\overrightarrow{x}$在解空间S内, $a(\overrightarrow{x})$与$b(\overrightarrow{x})$都是连续的实值函数.
解决分数规划问题的一般方法是分析其对偶问题, 还可进行参数搜索(parametric search), 即对答案进行猜测, 在验证该猜测值的最优性, 将优化问题转化为判定性问题或者其他优化问题.
构造新函数: $\displaystyle g(\lambda)=\min{\{a(\overrightarrow{x}) - \lambda \cdot b(\overrightarrow{x})\}}(\overrightarrow{x} \in S)$
函数性质: (单调性) $g(\lambda)$是一个严格递减函数, 即对于$\lambda_1 < \lambda_2$, 一定有$g(\lambda_1) > g(\lambda_2)$.
(Dinkelbach定理) 设$\lambda^*$为原规划的最优解, 则$g(\lambda)=0$当且仅当$\lambda = \lambda^*$.
设$\lambda^*$为该优化的最优解, 则:@$$\left\{ \begin{array}{c}
g(\lambda)=0 \Leftrightarrow \lambda = \lambda^*\\
g(\lambda)<0 \Leftrightarrow \lambda > \lambda^*\\
g(\lambda)>0 \Leftrightarrow \lambda < \lambda^*
\end{array}\right.$$@
由该性质, 就可以对最优解$\lambda^*$进行二分查找.
上述是针对最小化目标函数的分数规划, 实际上对于最大化目标函数也一样适用.
*/
///0-1分数规划 0-1 fractional programming
/*是分数规划的解向量$\overrightarrow{x}$满足$\forall x_i \in \{0,1\}$, 即一下形式:@$$\min{\{ \lambda = f(x) = \frac{\sum_{e \in E}{w_e x_e}}{\sum_{e \in E}{1 \cdot x_e}} = \frac{\overrightarrow{w} \cdot \overrightarrow{x}}{\overrightarrow{c} \cdot \overrightarrow{x}} \}}$$@
其中, $\overrightarrow{x}$表示一个解向量, $x_e \in\{0, 1\}$, 即对与每条边都选与不选两种决策, 并且选出的边集组成一个s-t边割集. 形式化的, 若$x_e = 1$, 则$e \in C$, $x_e = 0$, 则$e \not \in C$.
*/
|
b0373b06aa484f15a09e1f0397bd277b2221d7b9 | eac370a90fabd0a311524e9fe0a19ae16cc51d04 | /source/MemoryLocation.cpp | 53ef913672306a77234f08cc0e43739422e9ea7c | [
"MIT"
] | permissive | santhoshinty/mariana-trench | c6f23efc7d415e1de834041475dbc86bfb07b467 | bfeb71424f6f57f0947a9b798508da5fb1087eca | refs/heads/main | 2023-08-28T04:15:06.395083 | 2021-11-05T12:03:50 | 2021-11-05T12:05:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,427 | cpp | MemoryLocation.cpp | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <fmt/format.h>
#include <Show.h>
#include <mariana-trench/Assert.h>
#include <mariana-trench/MemoryLocation.h>
namespace marianatrench {
FieldMemoryLocation* MemoryLocation::make_field(const DexString* field) {
mt_assert(field != nullptr);
auto found = fields_.find(field);
if (found != fields_.end()) {
return found->second.get();
}
// To avoid non-convergence, we need to break infinite chains.
// If any parent of `this` is already a `FieldMemoryLocation` for the given
// field, return it in order to collapse the memory locations into a single
// location.
MemoryLocation* memory_location = this;
while (auto* field_memory_location =
memory_location->dyn_cast<FieldMemoryLocation>()) {
if (field_memory_location->field() == field) {
return field_memory_location;
} else {
memory_location = field_memory_location->parent();
}
}
auto result = fields_.emplace(
field, std::make_unique<FieldMemoryLocation>(this, field));
mt_assert(result.second);
return result.first->second.get();
}
MemoryLocation* MemoryLocation::root() {
// By defaut, this is a root memory location.
return this;
}
const Path& MemoryLocation::path() {
// By default, this is a root memory location.
static const Path empty_path;
return empty_path;
}
std::optional<AccessPath> MemoryLocation::access_path() {
auto* parameter = root()->dyn_cast<ParameterMemoryLocation>();
if (!parameter) {
return std::nullopt;
}
return AccessPath(Root(Root::Kind::Argument, parameter->position()), path());
}
std::ostream& operator<<(
std::ostream& out,
const MemoryLocation& memory_location) {
return out << memory_location.str();
}
ParameterMemoryLocation::ParameterMemoryLocation(ParameterPosition position)
: position_(position) {}
std::string ParameterMemoryLocation::str() const {
return fmt::format("ParameterMemoryLocation({})", position_);
}
ThisParameterMemoryLocation::ThisParameterMemoryLocation()
: ParameterMemoryLocation(0) {}
std::string ThisParameterMemoryLocation::str() const {
return "ThisParameterMemoryLocation";
}
FieldMemoryLocation::FieldMemoryLocation(
MemoryLocation* parent,
const DexString* field)
: parent_(parent),
field_(field),
root_(parent->root()),
path_(parent->path()) {
mt_assert(parent != nullptr);
mt_assert(field != nullptr);
path_.append(field);
}
std::string FieldMemoryLocation::str() const {
return fmt::format(
"FieldMemoryLocation({}, `{}`)", parent_->str(), show(field_));
}
MemoryLocation* FieldMemoryLocation::root() {
return root_;
}
const Path& FieldMemoryLocation::path() {
return path_;
}
InstructionMemoryLocation::InstructionMemoryLocation(
const IRInstruction* instruction)
: instruction_(instruction) {
mt_assert(instruction != nullptr);
}
std::string InstructionMemoryLocation::str() const {
return fmt::format("InstructionMemoryLocation(`{}`)", show(instruction_));
}
MemoryFactory::MemoryFactory(const Method* method) {
mt_assert(method != nullptr);
// Create parameter locations
for (ParameterPosition i = 0; i < method->number_of_parameters(); i++) {
if (i == 0 && !method->is_static()) {
parameters_.push_back(std::make_unique<ThisParameterMemoryLocation>());
} else {
parameters_.push_back(std::make_unique<ParameterMemoryLocation>(i));
}
}
}
ParameterMemoryLocation* MemoryFactory::make_parameter(
ParameterPosition parameter_position) {
static_assert(std::is_unsigned_v<ParameterPosition>);
if (parameter_position >= parameters_.size()) {
throw std::out_of_range(
"Accessing out of bounds parameter in memory factory.");
}
return parameters_[parameter_position].get();
}
InstructionMemoryLocation* MemoryFactory::make_location(
const IRInstruction* instruction) {
mt_assert(instruction != nullptr);
auto found = instructions_.find(instruction);
if (found != instructions_.end()) {
return found->second.get();
}
auto result = instructions_.emplace(
instruction, std::make_unique<InstructionMemoryLocation>(instruction));
mt_assert(result.second);
return result.first->second.get();
}
} // namespace marianatrench
|
1c09c8977a3ce7f1e35559f6f86ef7cb3270c1d0 | b625a45a0c7f1294c3d48b4e90c7d7757703f0bc | /demo.cpp | d193e97395344d8890b79f66af9690774084c58a | [] | no_license | desuanuroop/Shared_ptr | da1aa740eca81535a2bcab7cbe161158f2a0df76 | f19cb38b146152b708cc8d90b7bc68165db9e042 | refs/heads/master | 2020-12-24T06:06:48.355574 | 2016-11-28T23:09:33 | 2016-11-28T23:09:33 | 73,228,118 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 785 | cpp | demo.cpp | #include "SharedPtr.hpp"
#include <new>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <random>
#include <errno.h>
#include <assert.h>
#include <memory>
using namespace std;
class Base{
public:
int x;
Base(){ x= 99;
}
~Base(){cout<<"In Base destructor"<<endl;;
}
};
class Derived:public Base{
public:
int *y, x;
Derived(){
x = 100;
y = new int();
}
~Derived(){cout<<"In Derived destructor"<<endl;delete y;}
};
int main(){
/* decltype(b) c;
decltype(*b) cc = *b;
cout<<"type b: "<<typeid(c).name()<<endl;
cout<<"type b*: "<<typeid(cc).name()<<endl;
delete b;*/
// std::shared_ptr<Base> p(new Derived());
Derived d;
cout<<d.x<<endl;
}
|
a11096700ef5cab61a6b238aa800d5293610a4b4 | 3ddf15ec7f6eb7e3c42ae177bfd372c8f8d1ed18 | /IBMdec/src/decoder/common/param/Numeric.h | 39db71edfc214aecbce83f16c05467e2297a56c4 | [] | no_license | dumpinfo/IBMDec | 7fc534396e4e2a00acbea28a1a889219d7dadaf5 | fd88102c66ca9b652d5a683812b2a69663f16329 | refs/heads/master | 2020-07-26T01:44:40.287642 | 2019-09-14T19:18:43 | 2019-09-14T19:18:43 | 208,491,042 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,182 | h | Numeric.h | /*---------------------------------------------------------------------------------------------*
* Copyright (C) 2012 Daniel Bolaños - www.bltek.com - Boulder Language Technologies *
* *
* www.bavieca.org is the website of the Bavieca Speech Recognition Toolkit *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
* See the License for the specific language governing permissions and *
* limitations under the License. *
*---------------------------------------------------------------------------------------------*/
#ifndef NUMERIC_H
#define NUMERIC_H
using namespace std;
#include <algorithm>
#include <math.h>
namespace Bavieca {
const double PI_NUMBER = 2.0*acos(0.0);
/**
@author daniel <dani.bolanos@gmail.com>
*/
class Numeric {
private:
// fast fourier transform (auxiliar function)
static void fft_aux(double dData[], unsigned long nn);
public:
// addition of two log-values (natural logarithm)
static inline float logAddition(float fLnA, float fLnB) {
if (fabs(fLnA-fLnB) >= log(8388607.0)) { // 2^23-1 = 8388607
return max(fLnA,fLnB); // necessary to prevent dShiftedLnA = fLnA - fLnB from having a too big value
}
else {
double dShiftedLnA = fLnA-fLnB;
double dShiftedSum = exp(dShiftedLnA)+1.0;
float fShiftedSumLn = (float)log(dShiftedSum);
float fUnshiftedSumLn = fShiftedSumLn + fLnB;
return fUnshiftedSumLn;
}
}
// addition of two log-values (natural logarithm)
static inline double logAddition(double dLnA, double dLnB) {
if (fabs(dLnA-dLnB) >= log(8388607.0)) { // 2^23-1 = 8388607
return max(dLnA,dLnB); // necessary to prevent dShiftedLnA = dLnA - dLnB from having a too big value
}
else {
double dShiftedLnA = dLnA-dLnB;
double dShiftedSum = exp(dShiftedLnA)+1.0;
double dShiftedSumLn = log(dShiftedSum);
double dUnshiftedSumLn = dShiftedSumLn + dLnB;
return dUnshiftedSumLn;
}
}
// fast fourier transform
static void fft(double dData[], unsigned long n);
};
}; // end-of-namespace
#endif
|
be82af147d3eae434b39bd23ebd49fdf44c3e1b8 | 490385b0147e9e4e3f3ad98556fcf7ce9550ac8d | /OACreater_userStudy_/OACreater/Edge.cpp | 56a12ff93c6c1bad9dcb69a7c5abb625f67032b7 | [] | no_license | xiaokn/OACreater_ | a6d797cfa6dc7091eecf017c45a2ca86576e5c48 | 102b0d6cdf75aa84b7401b2bbecc817b2362e3ac | refs/heads/master | 2020-04-14T21:00:47.458268 | 2019-01-04T14:01:00 | 2019-01-04T14:01:00 | 164,114,206 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 10,523 | cpp | Edge.cpp | #include "Edge.h"
Edge::Edge()
{
m_isVisible = true;
m_edgeToLineDis = 0;
m_spacingId = -1;
m_point_edge_dis = -1;
}
Edge::~Edge()
{
}
void Edge::SetEdge(qglviewer::Camera* c, qglviewer::ManipulatedFrame* frame, cv::Vec3d point1, cv::Vec3d point2, int r_no, int shapeEdgeNo, cv::Vec3d bbox_min, cv::Vec3d bbox_max)
{
m_bboxMin = bbox_min;
m_bboxMax = bbox_max;
m_shapeEdgeNo = shapeEdgeNo;
m_rotateNo = r_no;//旋转优化的辅助变量
//得到3D局部坐标和世界坐标以及3D坐标的投影
m_localPt3D[0] = point1;
m_localPt3D[1] = point2;
m_globalPt3D[0] = Compute3DLocalToWorld(c, frame, point1);
m_globalPt3D[1] = Compute3DLocalToWorld(c, frame, point2);
m_projectPt2D[0] = ComputeProjectedVertex(c, frame, point1);
m_projectPt2D[1] = ComputeProjectedVertex(c, frame, point2);
ComputeEdgePoints();
//计算2D和3D的方向
m_dir2D[0] = m_projectPt2D[1][0] - m_projectPt2D[0][0];
m_dir2D[1] = m_projectPt2D[1][1] - m_projectPt2D[0][1];
m_dir3D[0] = m_globalPt3D[1][0] - m_globalPt3D[0][0];
m_dir3D[1] = m_globalPt3D[1][1] - m_globalPt3D[0][1];
m_dir3D[2] = m_globalPt3D[1][2] - m_globalPt3D[0][2];
//单位化
m_dir2D = Utils::Nomalize(m_dir2D);
m_dir3D = Utils::Nomalize(m_dir3D);
Compute3DTo2DMatrix(c);
ComputeCenterToVertex(frame);
ComputeCenterToVertex1(frame);
//计算gdv_unitThreshold
double threshold = Utils::Calculate2DTwoPointDistance(m_projectPt2D[0],m_projectPt2D[1])/5;
gdv_unitThreshold = (gdv_unitThreshold + threshold) / 2;
}
cv::Vec2d Edge::ComputeProjectedVertex(qglviewer::Camera* c, qglviewer::ManipulatedFrame* frame, cv::Vec3d Pt3D)
{
qglviewer::Vec globalPos, localPos, projectedPos;
localPos.x = Pt3D[0];
localPos.y = Pt3D[1];
localPos.z = Pt3D[2];
globalPos = frame->inverseCoordinatesOf(localPos);
projectedPos = c->projectedCoordinatesOf(globalPos);
cv::Vec2d thisPt;
thisPt[0] = projectedPos.x;
thisPt[1] = projectedPos.y;
//returnM(c, m);
return thisPt;
}
cv::Vec3d Edge::Compute3DLocalToWorld(qglviewer::Camera* c, qglviewer::ManipulatedFrame* frame, cv::Vec3d Pt3D)
{
qglviewer::Vec globalPos, localPos;
localPos.x = Pt3D[0];
localPos.y = Pt3D[1];
localPos.z = Pt3D[2];
globalPos = frame->inverseCoordinatesOf(localPos);
cv::Vec3d thisPt;
thisPt[0] = globalPos.x;
thisPt[1] = globalPos.y;
thisPt[2] = globalPos.z;
return thisPt;
}
void Edge::ComputeEdgePoints()
{
m_points.clear();
float part_lenth = 10;
float dis = Utils::Calculate2DTwoPointDistance(m_projectPt2D);
float dx = (m_projectPt2D[1][0] - m_projectPt2D[0][0]) / (dis / part_lenth);
float dy = (m_projectPt2D[1][1] - m_projectPt2D[0][1]) / (dis / part_lenth);
m_points.push_back(m_projectPt2D[0]);
cv::Vec2d start = m_projectPt2D[0];
for (int i = 0; i < dis / part_lenth - 1; i++)
{
start[0] += dx;
start[1] += dy;
m_points.push_back(start);
}
m_points.push_back(m_projectPt2D[1]);
}
void Edge::ComputeEndPt2DProjectedVertex()
{
if (m_line[0] == NULL)
{
return;
}
cv::Vec2d pline;
pline[0] = m_line[2];
pline[1] = m_line[3];
m_endPt2DPV[0] = GetProjectivePoint(pline, m_projectPt2D[0]);
m_endPt2DPV[1] = GetProjectivePoint(pline, m_projectPt2D[1]);
if (m_line[0] == 0)
{
m_point_dis[0] = m_endPt2DPV[0][1];
m_point_dis[1] = m_endPt2DPV[1][1];
return;
}
double k;
k = m_line[1] / m_line[0];
if (k == 0)
{
m_point_dis[0] = m_endPt2DPV[0][0];
m_point_dis[1] = m_endPt2DPV[1][0];
return;
}
else
{
m_point_dis[0] = sqrt(m_endPt2DPV[0][0] * m_endPt2DPV[0][0] + (m_endPt2DPV[0][1] - m_point_line[1])*(m_endPt2DPV[0][1] - m_point_line[1]));
m_point_dis[1] = sqrt(m_endPt2DPV[1][0] * m_endPt2DPV[1][0] + (m_endPt2DPV[1][1] - m_point_line[1])*(m_endPt2DPV[1][1] - m_point_line[1]));
return;
}
}
cv::Vec2d Edge::GetProjectivePoint(cv::Vec2d pLine, cv::Vec2d pOut)
{
double k;
cv::Vec2d pProject;
if (m_line[0] == 0)
{
pProject[0] = pLine[0];
pProject[1] = pOut[1];
//
m_point_line[0] = pLine[0];
m_point_line[1] = 0;
return pProject;
}
k = m_line[1] / m_line[0];
if (k == 0)
{
pProject[0] = pOut[0];
pProject[1] = pLine[1];
//
m_point_line[0] = 0;
m_point_line[1] = pLine[1];
return pProject;
}
else
{
pProject[0] = (float)((k * pLine[0] + pOut[0] / k + pOut[1] - pLine[1]) / (1 / k + k));
pProject[1] = (float)(-1 / k * (pProject[0] - pOut[0]) + pOut[1]);
//
m_point_line[0] = 0;
m_point_line[1] = m_line[3] - k*m_line[2];
return pProject;
}
}
void Edge::ComputeCenterToVertex(qglviewer::ManipulatedFrame* frame)
{
double a, b, c;
if (m_localPt3D[0][0] > 0)
{
a = 0.5;
//a = m_bboxMax[0] / sizeX;
}
else
{
a = -0.5;
//a = m_bboxMin[0] / sizeX;
}
if (m_localPt3D[0][1] > 0)
{
b = 0.5;
//b = m_bboxMax[1] / sizeY;
}
else
{
b = -0.5;
//b = m_bboxMin[1] / sizeY;
}
if (m_localPt3D[0][2] > 0)
{
c = 0.5;
//c = m_bboxMax[2] / sizeZ;
}
else
{
c = -0.5;
//c = m_bboxMin[2] / sizeZ;
}
//m是坐标转换矩阵
GLdouble get_m[16], m[16], rotateM[9];
frame->getWorldMatrix(get_m);
#define M(row,col) get_m[col*4+row]
m[0] = M(0, 0); m[1] = M(0, 1); m[2] = M(0, 2); m[3] = M(0, 3);
m[4] = M(1, 0); m[5] = M(1, 1); m[6] = M(1, 2); m[7] = M(1, 3);
m[8] = M(2, 0); m[9] = M(2, 1); m[10] = M(2, 2); m[11] = M(2, 3);
m[12] = M(3, 0); m[13] = M(3, 1); m[14] = M(3, 2); m[15] = M(3, 3);
#undef M
rotateM[0] = m[0]; rotateM[1] = m[1]; rotateM[2] = m[2];
rotateM[3] = m[4]; rotateM[4] = m[5]; rotateM[5] = m[6];
rotateM[6] = m[8]; rotateM[7] = m[9]; rotateM[8] = m[10];
m_centerToVertex[0] = m[0] * a; m_centerToVertex[1] = m[1] * b; m_centerToVertex[2] = m[2] * c;
m_centerToVertex[3] = m[4] * a; m_centerToVertex[4] = m[5] * b; m_centerToVertex[5] = m[6] * c;
m_centerToVertex[6] = m[8] * a; m_centerToVertex[7] = m[9] * b; m_centerToVertex[8] = m[10] * c;
////test
//GLdouble out[3];
//GLdouble in[3];
//in[0] = m_bboxMax[0]-m_bboxMin[0];
//in[1] = m_bboxMax[1]-m_bboxMin[1];
//in[2] = m_bboxMax[2]-m_bboxMin[2];
//out[0] = m_centerToVertex[0] * in[0] + m_centerToVertex[1] * in[1] + m_centerToVertex[2] * in[2];
//out[1] = m_centerToVertex[3] * in[0] + m_centerToVertex[4] * in[1] + m_centerToVertex[5] * in[2];
//out[2] = m_centerToVertex[6] * in[0] + m_centerToVertex[7] * in[1] + m_centerToVertex[8] * in[2];
//cv::Vec3d center = Compute3DLocalToWorld(NULL, frame, cv::Vec3d(0, 0, 0));
//std::cout << " 源点 " << m_globalPt3D[0][0] << " " << m_globalPt3D[0][1] << " " << m_globalPt3D[0][2] << " \n";
//std::cout << " 求的点 " << center[0] + out[0] << " " << center[1] + out[1] << " " << center[2] + out[2] << " \n";
}
void Edge::Compute3DTo2DMatrix(qglviewer::Camera* c)
{
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];
c->getViewport(viewport);
c->computeModelViewMatrix();
c->computeProjectionMatrix();
c->getModelViewMatrix(modelMatrix);
c->getProjectionMatrix(projMatrix);
GLdouble out2[16], out3[16], out4[8];
GLdouble view[16], *output;
for (int k = 0; k < 16; k++)
{
view[k] = 0;
}
double x, y, w, h;
x = viewport[0];
y = viewport[1];
w = viewport[2];
h = viewport[3];
view[0] = w / 2;
view[3] = x + w / 2;
view[5] = h / 2;
view[7] = y + h / 2;
//view[10] = (zFar-zNear)/2;
//view[11] = (zFar+zNear)/2;
view[15] = 1;
for (int k = 0; k < 4; k++){
for (int s = 0; s < 4; s++){
out2[k * 4 + s] = 0;//变量使用前记得初始化,否则结果具有不确定性
for (int n = 0; n < 4; n++){
out2[k * 4 + s] += modelMatrix[k * 4 + n] * projMatrix[n * 4 + s];
}
}
}
for (int k = 0; k < 4; k++){
for (int s = 0; s < 4; s++){
out3[k * 4 + s] = 0;//变量使用前记得初始化,否则结果具有不确定性
for (int n = 0; n < 4; n++){
out3[k * 4 + s] += out2[k * 4 + n] * view[n * 4 + s];
}
}
}
out4[0] = out3[0]; out4[1] = out3[4]; out4[2] = out3[8]; out4[3] = out3[12] + w / 2;
out4[4] = out3[1]; out4[5] = out3[5]; out4[6] = out3[9]; out4[7] = out3[13] - h / 2;
for (int i = 0; i < 8; i++)
{
m_3DTo2DMatrix[i] = out4[i];
}
}
void Edge::DrawEdge(QPainter& painter)
{
QPointF point1, point2;
point1.setX(m_projectPt2D[0][0]); point1.setY(m_projectPt2D[0][1]);
point2.setX(m_projectPt2D[1][0]); point2.setY(m_projectPt2D[1][1]);
painter.drawLine(point1, point2);
}
void Edge::ComputeCenterToVertex1(qglviewer::ManipulatedFrame* frame)
{
double a, b, c;
if (m_localPt3D[1][0] > 0)
{
a = 0.5;
}
else
{
a = -0.5;
}
if (m_localPt3D[1][1] > 0)
{
b = 0.5;
}
else
{
b = -0.5;
}
if (m_localPt3D[1][2] > 0)
{
c = 0.5;
}
else
{
c = -0.5;
}
//m是坐标转换矩阵
GLdouble get_m[16], m[16], rotateM[9];
frame->getWorldMatrix(get_m);
#define M(row,col) get_m[col*4+row]
m[0] = M(0, 0); m[1] = M(0, 1); m[2] = M(0, 2); m[3] = M(0, 3);
m[4] = M(1, 0); m[5] = M(1, 1); m[6] = M(1, 2); m[7] = M(1, 3);
m[8] = M(2, 0); m[9] = M(2, 1); m[10] = M(2, 2); m[11] = M(2, 3);
m[12] = M(3, 0); m[13] = M(3, 1); m[14] = M(3, 2); m[15] = M(3, 3);
#undef M
rotateM[0] = m[0]; rotateM[1] = m[1]; rotateM[2] = m[2];
rotateM[3] = m[4]; rotateM[4] = m[5]; rotateM[5] = m[6];
rotateM[6] = m[8]; rotateM[7] = m[9]; rotateM[8] = m[10];
m_centerToVertex1[0] = m[0] * a; m_centerToVertex1[1] = m[1] * b; m_centerToVertex1[2] = m[2] * c;
m_centerToVertex1[3] = m[4] * a; m_centerToVertex1[4] = m[5] * b; m_centerToVertex1[5] = m[6] * c;
m_centerToVertex1[6] = m[8] * a; m_centerToVertex1[7] = m[9] * b; m_centerToVertex1[8] = m[10] * c;
////test
//GLdouble out[3];
//GLdouble in[3];
//in[0] = m_bboxMax[0] - m_bboxMin[0];
//in[1] = m_bboxMax[1] - m_bboxMin[1];
//in[2] = m_bboxMax[2] - m_bboxMin[2];
//out[0] = m_centerToVertex1[0] * in[0] + m_centerToVertex1[1] * in[1] + m_centerToVertex1[2] * in[2];
//out[1] = m_centerToVertex1[3] * in[0] + m_centerToVertex1[4] * in[1] + m_centerToVertex1[5] * in[2];
//out[2] = m_centerToVertex1[6] * in[0] + m_centerToVertex1[7] * in[1] + m_centerToVertex1[8] * in[2];
//cv::Vec3d center = Compute3DLocalToWorld(NULL, frame, cv::Vec3d(0, 0, 0));
//std::cout << " 源点 " << m_globalPt3D[1][0] << " " << m_globalPt3D[1][1] << " " << m_globalPt3D[1][2] << " \n";
//std::cout << " 求的点 " << center[0] + out[0] << " " << center[1] + out[1] << " " << center[2] + out[2] << " \n";
}
|
bf7c631d854ec5a7fe0eb5bbfd02de83beeaced9 | c70c3cff6f1af19e85854e1a83795ad3237c6556 | /src/bsg.h | 18617c6ba9e04bcceba84dbfc68495ac623ba9fa | [] | no_license | linkhp/demo-graphic | 96a69a4d3be9b8e52ee1f8251301ab3b91fc3d66 | 63f0d23f68411a6c394d91e929ee9ee1d1c86c6f | refs/heads/master | 2021-06-12T03:59:53.335536 | 2017-03-08T14:38:51 | 2017-03-08T14:38:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,398 | h | bsg.h | #ifndef BSGHEADER
#define BSGHEADER
#include <stdio.h>
#include <stdlib.h>
#include <stdexcept>
#include <memory.h>
#include <math.h>
#include <GL/glew.h>
#include <GL/freeglut.h>
#include <string>
#include <vector>
#include <list>
#include <iostream>
#include <fstream>
// Include GLM
#include <glm/glm.hpp>
#include <glm/geometric.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
// Some miscellaneous dependencies.
#include <png.h>
namespace bsg {
typedef enum {
GLDATA_VERTICES = 0,
GLDATA_COLORS = 1,
GLDATA_NORMALS = 2,
GLDATA_TEXCOORDS = 3
} GLDATATYPE;
typedef enum {
GLSHADER_VERTEX = 0,
GLSHADER_FRAGMENT = 1,
GLSHADER_GEOMETRY = 2
} GLSHADERTYPE;
typedef enum {
GLMATRIX_MODEL = 0,
GLMATRIX_VIEW = 1,
GLMATRIX_PROJECTION = 2
} GLMATRIXTYPE;
/// \mainpage Shader Manager
///
/// A set of classes to manage a collection of shaders and objects to
/// make it easy to define an OpenGL 3D object drawn by them. This is
/// very specifically meant to support OpenGL version 2.1 and GLSL
/// 1.2. I know there are newer and better things out there, but this
/// is designed to support the lowest common denominator among the set
/// of machines that our group works on: student-owned laptops, CCV
/// linux workstations, and the Brown University YURT virtual reality
/// environment, to name a few.
///
/// In structure, this is very much like a Baby Scene Graph package,
/// with a scene consisting of a graph of objects. This package is a
/// teaching tool, as much as it is a package with which to get useful
/// things done. If you run out of capacity here, consider using Open
/// Scene Graph before extending this one.
///
/// The important member classes are these:
///
/// lightList -- A list of light positions and colors.
///
/// shaderMgr -- Holds the code for the pieces of a shader
/// collection. Use this to add a vertex or fragment
/// shader. Has switches to compile them, and returns
/// the program index when it's needed. Controls the
/// text of the shader to adjust to match the number of
/// lights and so on.
///
/// bsgPtr -- A smart pointer. We use it for shaderMgr, so that
/// multiple objects can use the same shader object.
/// We use it from drawableCompound so that you can
/// sub-class those and still have an object you can
/// include in a scene.
///
/// textureMgr -- A class to hold a texture and take care of loading
/// it into the OpenGL slots where it belongs.
///
/// drawableObj -- Contains a set of vertices, colors, normals,
/// texture coordinates, whatever. Points to a
/// particular shaderMgr for drawing the object.
///
/// drawableCompound -- A collection of drawableObj objects to be
/// considered a single object. This is where the
/// model matrix is applied, so it's ok if it's a
/// compound of just one drawableObj.
///
/// scene -- A collection of drawableCompound objects that make
/// up a scene.
///
/// \brief A reference counter for a smart pointer to bsg objects.
class bsgPtrRC {
private:
int count; // Reference count
public:
bsgPtrRC(int start) : count(start) {};
/// Increment the reference count.
void addRef() { count++; }
// Decrement and return count.
int release() { return --count; }
};
/// \brief A smart pointer to a bsg object.
///
/// A smart pointer to the bsgPtr so that multiple objects can use
/// the same shader object.
///
template <class T>
class bsgPtr {
private:
T* _pData; // The pointer.
bsgPtrRC* _reference; // The reference count.
public:
bsgPtr() : _pData(0) {
_reference = new bsgPtrRC(1); };
bsgPtr(T* pValue) : _pData(pValue) { _reference = new bsgPtrRC(1); };
/// Copy constructor
bsgPtr(const bsgPtr &sp) : _pData(sp._pData), _reference(sp._reference) {
_reference->addRef();
}
/// Destructor. Decrement the reference count. If the count
/// becomes zero, delete the data.
~bsgPtr() {
if (_reference->release() == 0) {
delete _pData;
delete _reference;
}
}
T& operator*() { return *_pData; };
T* operator->() { return _pData; };
/// Assignment operator.
bsgPtr<T>& operator=(const bsgPtr<T> &sp) {
if (this != &sp) {
// Decrement the old reference count. If references become
// zero, delete the data.
if (_reference->release() == 0) {
delete _pData;
delete _reference;
}
// Copy the data and reference pointer and increment the
// reference count.
_pData = sp._pData;
_reference = sp._reference;
_reference->addRef();
}
return *this;
}
};
/// \brief Just a place to park some random utilities.
class bsgUtils {
public:
static void printMat(const std::string &name, const glm::mat4 &mat);
};
/// \brief Some data for an object.
///
/// We package the data needed for a piece of data belonging to an
/// object. The name is the same as the variable name in the shader
/// that will use it, and the ID is the index number by which we can
/// refer to that buffer in the C++ code.
template <class T>
class drawableObjData {
private:
std::vector<T> _data;
public:
drawableObjData(): name("") {
_data.reserve(50);
ID = 0; bufferID = 0;
};
drawableObjData(const std::string inName, const std::vector<T> inData) :
name(inName), _data(inData) {}
// Copy constructor
drawableObjData(const drawableObjData &objData) :
_data(objData.getData()), name(objData.name), ID(objData.ID),
bufferID(objData.bufferID) {};
/// The name of that data inside a shader.
std::string name;
std::vector<T> getData() const { return _data; };
void addData(T d) { _data.push_back(d); };
// The ID that goes with that name.
GLuint ID;
/// The ID of the buffer containing that data.
GLuint bufferID;
/// A size calculator.
size_t size() { return _data.size() * sizeof(T); };
/// Another size calculator.
int intSize() { return sizeof(T) / sizeof(float); };
};
/// \class lightList
/// \brief A class to manage a list of lights in a scene.
///
/// lightList is a class for managing a list of lights to go with some
/// shader. The lights are communicated with the shader in two blocks
/// of data, one for the light positions and the other for the light
/// colors. Since the shaders depend on the specific number of lights
/// in the list, we think of this list as an integral part of the
/// shader's data, even if a few different shaders might refer to the
/// same list.
///
/// The load() and draw() methods of this class will be invoked in the
/// load() and draw() methods of the shaders that depend on them.
/// There may be several shaders that use the same lights, so this may
/// result in multiple loads of the same data. Optimizing that
/// redundancy out of the system is an exercise left for the reader.
///
class lightList {
private:
/// The positions of the lights in the list.
drawableObjData<glm::vec3> _lightPositions;
/// The colors of the lights in the list.
drawableObjData<glm::vec3> _lightColors;
/// The default names of things in the shaders, put here for easy
/// comparison or editing. If you're mucking around with the
/// shaders, don't forget that these are names of arrays inside the
/// shader, and that the size of the arrays is set with 'XX', see
/// the shader constructors below.
void setupDefaultNames() {
setNames("lightPosition", "lightColor");
}
public:
lightList() {
setupDefaultNames();
};
/// Set the names of the light positions and colors to be used inside
/// the shaders.
void setNames(const std::string &positionName, const std::string &colorName) {
_lightPositions.name = positionName;
_lightColors.name = colorName;
};
/// \brief Add lights to the list.
///
/// Since the shaders are compiled and linked after the number of
/// lights is set, this is pretty much a one-way street. Add
/// lights, but don't subtract them. If you want to extinguish one,
/// just move it far away, or dial its intensity way down.
int addLight(const glm::vec3 &position, const glm::vec3 &color) {
_lightPositions.addData(position);
_lightColors.addData(color);
return _lightPositions.size();
};
int addLight(const glm::vec3 &position) {
glm::vec3 white = glm::vec3(1.0f, 1.0f, 1.0f);
return addLight(position, white);
};
int getNumLights() { return _lightPositions.getData().size(); };
// We have mutators and accessors for all the pieces...
std::vector<glm::vec3> getPositions() { return _lightPositions.getData(); };
void setPositions(const std::vector<glm::vec3> positions) {
_lightPositions.getData() = positions;
};
GLuint getPositionID() { return _lightPositions.ID; };
std::vector<glm::vec3> getColors() { return _lightColors.getData(); };
void setColors(const std::vector<glm::vec3> &colors) { _lightColors.getData() = colors; };
GLuint getColorID() { return _lightColors.ID; };
/// ... and also for individual lights.
void setPosition(const int &i, const glm::vec3 &position) {
_lightPositions.getData()[i] = position;
};
glm::vec3 getPosition(const int &i) { return _lightPositions.getData()[i]; };
/// \brief Change a light's color.
void setColor(const int &i, const glm::vec3 &color) {
_lightColors.getData()[i] = color; };
glm::vec3 getColor(const int &i) { return _lightColors.getData()[i]; };
/// Load these lights for use with this program. This should be
/// called inside the load() method of the manager object of the
/// shader that uses them.
void load(const GLuint programID);
/// \brief "Draw" these lights.
///
/// Obviously, we don't draw the lights, but we use this method to
/// update the positino and color of the lights, in case they have
/// changed since the last scene render.
void draw(const GLuint programID);
};
typedef enum {
texturePNG = 0,
textureDDS = 1,
textureBMP = 2
} textureType;
/// \brief A manager of textures and texture files.
///
/// A class to hold a texture and take care of loading it into the
/// OpenGL slots where it belongs.
///
class textureMgr {
private:
GLfloat _width, _height;
GLuint _textureAttribID;
std::string _textureAttribName;
void setupDefaultNames() {
_textureAttribName = std::string("textureSampler");
};
GLuint _textureBufferID;
GLuint loadPNG(const std::string imagePath);
public:
textureMgr(const textureType &type, const std::string &fileName);
textureMgr() {};
void load(const GLuint programID);
void draw(const GLuint programID);
GLuint getTextureID() { return _textureBufferID; };
GLfloat getWidth() { return _width; };
GLfloat getHeight() { return _height; };
};
/// /brief A collection of shaders that work together as a shader program.
///
/// Holds the code for the pieces of a shader collection. Use this
/// to add a vertex or fragment shader. Has switches to compile
/// them, and returns the program index when it's needed. Controls
/// the text of the shader to adjust to match the number of lights
/// and so on.
class shaderMgr {
private:
/// The shader text and compilation log together are stored here,
/// using the GLSHADERTYPE as an index to keep them straight.
std::vector<std::string> _shaderText;
std::vector<std::string> _shaderLog;
std::vector<GLuint> _shaderIDs;
std::string _linkLog;
GLuint _programID;
/// Tells us whether the shaders have been loaded and compiled yet.
bool _compiled;
bsgPtr<lightList> _lightList;
std::string _getShaderInfoLog(GLuint obj);
std::string _getProgramInfoLog(GLuint obj);
public:
shaderMgr() {
// Easiest way to initialize a non-static three-element
// std::vector. Dumb, but simple and it works.
_shaderIDs.push_back(999);
_shaderIDs.push_back(999);
_shaderIDs.push_back(999);
_shaderText.push_back("");
_shaderText.push_back("");
_shaderText.push_back("");
_shaderLog.push_back("");
_shaderLog.push_back("");
_shaderLog.push_back("");
_compiled = false;
};
~shaderMgr() {
if (_compiled) glDeleteProgram(_programID);
}
/// \brief Add lights to the shader.
///
/// This should be done before adding the shader code itself, unless
/// the shader does not depend on the number of lights. The shader
/// manager class will edit any 'XX' string in the shader and
/// replace it with the number of lights in this list. If your
/// shader ignores lighting, as many do, this will not do anything
/// besides issue a polite warning that the shader doesn't care.
void addLights(const bsgPtr<lightList> lightList);
/// \brief Add a shader to the program.
///
/// You must specify at least a vertex and fragment shader. The
/// geometry shader is optional.
void addShader(const GLSHADERTYPE type, const std::string &shaderFile);
/// \brief Compile and link the loaded shaders.
///
/// You need to have specified at least a vertex and fragment
/// shader. The geometry shader is optional.
void compileShaders();
/// Get the ID number for an attribute name that appears in a shader.
GLuint getAttribID(const std::string &attribName);
/// Get the ID number for a uniform name that appears in a shader.
GLuint getUniformID(const std::string &unifName);
/// \brief Returns the program ID of the compiled shader.
GLuint getProgram() { return _programID; };
/// \brief Use this to enable the shader program.
///
/// This call should appear before any of the OpenGL calls that rely
/// on this shader program, like enabling a buffer or loading an
/// attribute's data. OpenGL uses "state", and this call puts the
/// GPU in a state of being ready to use this shader.
void useProgram() { glUseProgram(_programID); };
};
/// \brief The information necessary to draw an object.
///
/// This object contains a set of vertices, colors, normals, texture
/// coordinates. This is meant to work with modern OpenGL, that uses
/// shaders, specifically OpenGL 2.1 and GLSL 1.2. Yes, we know
/// that's old, but it's the latest version that works identically on
/// *all* the platforms we want to support. (Thanks, Apple.)
///
/// All the drawableObj shapes in a compound object (see below) use the
/// same shader, and the same model matrix.
class drawableObj {
private:
// Specifies whether this is a triangle, a triangle strip, fan,
// whatever.
GLenum _drawType;
GLsizei _count;
// These are the components. Apart from the vertices, they don't
// all have to be filled in, though they have to work with the
// shader.
drawableObjData<glm::vec4> _vertices;
drawableObjData<glm::vec4> _colors;
drawableObjData<glm::vec4> _normals;
drawableObjData<glm::vec2> _uvs;
std::string print() const { return std::string("drawableObj"); };
friend std::ostream &operator<<(std::ostream &os, const drawableObj &obj);
public:
drawableObj() {};
/// \brief Specify the draw type of the shape.
///
/// This refers to the OpenGL primitive draw types. You can read
/// about them here: https://www.khronos.org/opengl/wiki/Primitive
///
/// This is a nice intro:
/// http://www.falloutsoftware.com/tutorials/gl/gl3.htm
void setDrawType(const GLenum drawType) {
_drawType = drawType;
_count = _vertices.size();
};
/// \brief Specify the draw type and the vertex count.
void setDrawType(const GLenum drawType, const GLsizei count) {
_drawType = drawType;
_count = count;
};
/// \brief Add some vec4 data.
///
/// You can add vec4 data, including vertices, colors, and normal
/// vectors, with this method. The name parameter is the name
/// you'll use in the shader for the corresponding attribute.
void addData(const GLDATATYPE type,
const std::string &name,
const std::vector<glm::vec4> &data);
/// \brief Add some vec2 texture coordinates.
///
/// You can add vec2 texture coordinates, with this method. The
/// name parameter is the name you'll use in the shader for the
/// corresponding attribute.
void addData(const GLDATATYPE type,
const std::string &name,
const std::vector<glm::vec2> &data);
/// \brief One-time-only draw preparation.
///
/// This generates the proper number of buffers for the shape data
/// and arranges the correspondence between the attribute names used
/// in your shaders and the ID numbers used in the OpenGL calls that
/// load data to be used for those attributes. For example, you'll
/// want to know that the buffer with some specific buffer ID is the
/// same as the attribute called "position" in the shader. You
/// don't have to worry about this, except to the extent you have to
/// make sure that the names set in the addData method are the same
/// names you're using in the shader attributes.
///
/// Call this function after all the data is in place and we know
/// whether we have colors or textures or normals to worry about.
void prepare(GLuint programID);
/// \brief Loads the shape about to be drawn.
///
/// This binds the OpenGL buffers for the shape data and loads that
/// data into those buffers. The load step is separate from the
/// draw step because you might want to draw several times, for
/// example for a stereo display where you have to draw twice.
void load();
/// \brief This is the actual step of drawing the object.
///
/// The method binds each OpenGL buffer, then enables the arrays.
/// We assume the data we want to draw is already in the buffer, via
/// the load() method.
void draw();
};
/// \brief A collection of drawableObj objects.
///
/// A compound drawable object is made of a bunch of drawableObj
/// objects but can be considered to be a considered a single object.
/// It might consist of just one object, but that's ok, since this is
/// also where the objects are placed in model space.
///
/// This is to say that this class is where the model matrix is
/// handled. The component objects must specify their vertex
/// coordinates in the same coordinate system as each other. If you
/// want to move objects independently of each other, use different
/// drawableCompound objects. (Or consider using a real scene graph
/// API, or rewriting this one.) The view matrix and the projection
/// matrix are used here, though they are generated and managed at the
/// scene level.
///
/// The shaders are included in this object as a pointer because many
/// objects will use the same shader. So the program that calls this
/// should keep three separate lists: the objects in the scene, the
/// shaders used to render them, and the lights used by those shaders.
///
/// This class imposes a small number of restrictions on the shader
/// code itself, mostly that the matrix names in the shader must match
/// the matrix names here. There is a setMatrixNames() method for
/// that. Setting things up for the number of lights is also
/// something that needs to be configured carefully. See the
/// lightList documentation.
///
class drawableCompound {
protected:
/// The list of objects that make up this compound object.
std::list<drawableObj> _objects;
/// The shader that will be used to render all the pieces of this
/// compound object. Or at least the one they will start with. You
/// can always go back and change the shader for an individual
/// object.
bsgPtr<shaderMgr> _pShader;
/// The position in model space.
glm::vec3 _position;
/// A three-dimensional scale parameter.
glm::vec3 _scale;
/// The orientation of the object in model space.
glm::quat _orientation;
/// The model matrix, along with a flag to say whether it must be
/// recalculated. The flag is set when the position, scale, or
/// orientation are changed.
glm::mat4 _modelMatrix;
bool _modelMatrixNeedsReset;
/// These are pairs of ways to reference the matrices that include
/// the matrix name (used in the shader) and the ID (used in the
/// OpenGL code).
std::string _modelMatrixName;
GLuint _modelMatrixID;
std::string _viewMatrixName;
GLuint _viewMatrixID;
std::string _projMatrixName;
GLuint _projMatrixID;
public:
drawableCompound(bsgPtr<shaderMgr> pShader) :
_pShader(pShader),
// Set the default names for our matrices.
_modelMatrixName("modelMatrix"),
_viewMatrixName("viewMatrix"),
_projMatrixName("projMatrix") {
_position = glm::vec3(0.0f, 0.0f, 0.0f);
_scale = glm::vec3(1.0f, 1.0f, 1.0f);
// The glm::quat constructor initializes orientation to be zero
// rotation by default, so need not be mentioned here.
};
/// \brief Set the name of one of the matrices.
///
/// This is the name by which this matrix will be known inside your
/// shaders. In other words, these strings must match the "uniform"
/// declarations in your shaders.
void setMatrixName(GLMATRIXTYPE type, const std::string name) {
switch(type) {
case(GLMATRIX_MODEL):
_modelMatrixName = name;
break;
case(GLMATRIX_VIEW):
_viewMatrixName = name;
break;
case(GLMATRIX_PROJECTION):
_projMatrixName = name;
break;
}
};
/// \brief Adds an object to the compound object.
///
/// We set the shader to each object to be the same shader for the
/// whole compound object. If you find that objectionable, you are
/// probably ready for a more elaborate set of classes to do your
/// rendering with.
void addObject(drawableObj obj) {
_objects.push_back(obj);
};
/// \brief Calculate the model matrix.
///
/// Uses the current position, rotation, and scale to calculate a
/// new model matrix. There is an internal flag used to set whether
/// the model matrix needs to be recalculated or not.
glm::mat4 getModelMatrix();
int getNumObjects() { return _objects.size(); };
/// \brief Set the model position using a vector.
void setPosition(glm::vec3 position) {
_position = position;
_modelMatrixNeedsReset = true;
};
/// \brief Set the model position using three floats.
void setPosition(GLfloat x, GLfloat y, GLfloat z) {
setPosition(glm::vec3(x, y, z));
};
/// \brief Set the scale using a vector.
void setScale(glm::vec3 scale) {
_scale = scale;
_modelMatrixNeedsReset = true;
};
/// \brief Set the scale using a single float, applied in three dimensions.
void setScale(float scale) {
_scale = glm::vec3(scale, scale, scale);
_modelMatrixNeedsReset = true;
};
/// \brief Set the rotation with a quaternion.
void setOrientation(glm::quat orientation) {
_orientation = orientation;
_modelMatrixNeedsReset = true;
};
/// \brief Set the rotation with Euler angles.
///
/// Uses a 3-vector of (pitch, yaw, roll) in radians.
void setRotation(glm::vec3 pitchYawRoll) {
_orientation = glm::quat(pitchYawRoll);
_modelMatrixNeedsReset = true;
};
/// \brief Returns the vector position.
glm::vec3 getPosition() { return _position; };
/// \brief Returns the vector scale.
glm::vec3 getScale() { return _scale; };
/// \brief Returns the orientation as a quaternion.
glm::quat getOrientation() { return _orientation; };
/// \brief Returns the orienation as Euler angles.
glm::vec3 getPitchYawRoll() { return glm::eulerAngles(_orientation); };
/// \brief Gets ready for the drawing sequence.
///
void prepare();
/// \brief Load a compound object.
///
/// Prepares a compound object to be drawn, including bringing up a
/// refreshed model matrix, in case we've moved its position or
/// orientation.
void load();
/// \brief Draws a compound object.
///
/// Just executes draw() for all the component objects.
void draw(const glm::mat4 &viewMatrix,
const glm::mat4 &projMatrix);
};
/// \brief A collection of drawableCompound objects that make up a
/// scene.
///
/// A scene is a collection of objects to render, and is also where
/// the view and projection matrices are handled to turn the scene
/// into an image.
///
class scene {
private:
/// We use a pointer to the drawableCompound objects so you can
/// create an object that inherits from drawableCompound and still
/// use it here.
typedef std::list<bsgPtr<drawableCompound> > compoundList;
compoundList _compoundObjects;
glm::mat4 _viewMatrix;
glm::mat4 _projMatrix;
// View matrix inputs.
glm::vec3 _cameraPosition;
glm::vec3 _lookAtPosition;
// Projection matrix inputs;
float _fov, _aspect;
float _nearClip, _farClip;
glm::mat4 _calculateViewMatrix();
glm::mat4 _calculateProjMatrix();
public:
scene() {
_cameraPosition = glm::vec3(10.0f, 10.0f, 10.0f);
_lookAtPosition = glm::vec3( 0.0f, 0.0f, 0.0f);
_fov = M_PI / 2.0f;
_aspect = 1.0f;
_nearClip = 0.1f;
_farClip = 100.0f;
}
void setCameraPosition(const glm::vec3 cameraPosition) {
_cameraPosition = cameraPosition;
};
void addToCameraPosition(const glm::vec3 stepVec) {
_cameraPosition += stepVec;
}
glm::vec3 getCameraPosition() { return _cameraPosition; };
void setLookAtPosition(const glm::vec3 lookAtPosition) {
_lookAtPosition = lookAtPosition;
};
void addToLookAtPosition(const glm::vec3 stepVec) {
_lookAtPosition += stepVec;
}
glm::vec3 getLookAtPosition() { return _lookAtPosition; };
/// \brief Rotates the camera location around the lookat point.
void addToCameraViewAngle(const float horizAngle, const float vertAngle);
/// \brief Return the view matrix.
///
/// This function recalculates the view matrix, based on the camera
/// position and lookat point.
glm::mat4 getViewMatrix() {
_viewMatrix = _calculateViewMatrix();
return _viewMatrix;
}
/// \brief Return a projection matrix.
///
/// This function recalculates a projection matrix based on the
/// window size (aspect ratio) and clip parameters.
glm::mat4 getProjMatrix() {
_projMatrix = _calculateProjMatrix();
return _projMatrix;
}
/// \brief Set the field of view. In radians.
void setFOV(float fov) { _fov = fov; };
/// \brief Sets the aspect ratio of the view window.
void setAspect(float aspect) { _aspect = aspect; };
/// \brief Add a compound object to our scene.
void addCompound(const bsgPtr<drawableCompound> pCompoundObject) {
_compoundObjects.push_back( pCompoundObject);
}
/// \brief Prepare the scene to be drawn.
///
/// This does a bunch of one-time-only initializations for the
/// member compound elements.
void prepare();
/// \brief Generates a projection matrix and loads all the compound elements.
void load();
/// \brief Loads all the compound elements.
///
/// But you supply the projection matrix.
void load(glm::mat4 &projMatrix);
/// \brief Generates a view matrix and draws all the compound elements.
void draw();
/// \brief Draws all the compound elements.
///
/// But you supply the view matrix.
void draw(glm::mat4 &viewMatrix);
};
}
#endif //BSGHEADER
|
9dd5d2196853f3291be576a038a6eba2cf54f614 | 2a9246c620b588068e2a82a166f7836bf56938e3 | /PhotonAnalysis/interface/HiPhotonMCTruth.h | 7c0f484d1d1ec418f37bcd92a1974c465a5e657c | [] | no_license | CmsHI/CVS_CmsHi | 6dc20b07a34a8927f1af3d11b59b59058b5ddeeb | 9b9dcd34a1b718e4649ca2ddc34583706dfd5d1c | refs/heads/master | 2021-01-20T15:36:12.324219 | 2013-06-20T13:06:49 | 2013-06-20T13:06:49 | 11,457,757 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,210 | h | HiPhotonMCTruth.h | #ifndef HiPhotonMCTruth_h
#define HiPhotonMCTruth_h
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/Candidate/interface/CandidateFwd.h"
#include "Geometry/CaloGeometry/interface/CaloGeometry.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "CmsHi/PhotonAnalysis/interface/HiMCGammaJetSignalDef.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/Common/interface/Handle.h"
#include <vector>
class HiPhotonMCTruth
{
public:
HiPhotonMCTruth(edm::Handle<reco::GenParticleCollection> inputHandle);
bool IsPrompt(const reco::GenParticle &pp);
bool IsIsolated(const reco::GenParticle &pp);
bool IsIsolatedPP(const reco::GenParticle &pp,double cone = 0.4, double etCut = 2.0);
bool IsIsolatedJP(const reco::GenParticle &pp);
private:
HiMCGammaJetSignalDef mcisocut;
};
#endif
|
8aff4f0354b1f3bb547ac7d577359d399bec45cd | f7ad5fad663d642576ebdfd6279d3d9c33c81e83 | /MyString.hpp | 5e3b237d0bd9d631825f0d029a87dd7ad1dedc5f | [] | no_license | onionwarrior/MyString | d0ef18f0fd18b047d1591c2a13c1b104fd426cc1 | 1877056ec2537b9f80e66713375e67be2b2b1ba6 | refs/heads/master | 2023-08-25T00:05:22.985666 | 2021-09-14T21:46:48 | 2021-09-14T21:46:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,120 | hpp | MyString.hpp | #pragma once
#include <string>
#include <iostream>
#include <type_traits>
#include <functional>
#include <cstring>
constexpr size_t default_append = -1;
//funny patteern matching using template magic
// это для default
class MyString final
{
size_t size_ = 0;
size_t capacity_ = 1;
char *str_ = nullptr;
void resize(size_t); // nothrow
template <typename ArgType>
ArgType to_impl(std::true_type const &)
{
if constexpr (std::is_signed_v<ArgType>)
{
int64_t ret_val = 0;
sscanf(str_, "%lld", &ret_val);
return static_cast<ArgType>(ret_val);
}
else
{
uint64_t ret_val = 0;
sscanf(str_, "%llu", &ret_val);
return static_cast<ArgType>(ret_val);
}
}
template <typename ArgType>
ArgType to_impl(std::false_type const &)
{
auto ret_val = 0.0;
sscanf(str_, "%lf", &ret_val);
return static_cast<ArgType>(ret_val);
}
public:
template <bool IsConst,bool IsReverse>
struct Iterator
{
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
using value_type = char;
using pointer = std::conditional_t<IsConst, value_type const *, value_type *>;
using reference = std::conditional_t<IsConst, value_type const &, value_type &>;
Iterator(pointer ptr) : ptr_(ptr)
{
}
template< bool _Const = IsConst >
std::enable_if_t< _Const, reference >
operator*()
{
return *ptr_;
}
template< bool _Const = IsConst >
std::enable_if_t< !_Const, reference >
operator*()
{
return *ptr_;
}
pointer operator->()
{
return ptr_;
}
Iterator &operator++()
{
if constexpr(!IsReverse)
ptr_++;
else
ptr_--;
return *this;
}
Iterator operator++(int)
{
Iterator<IsConst,IsReverse> tmp = *this;
if constexpr(!IsReverse)
++(*this);
else
--(*this);
return tmp;
}
friend bool operator==(const Iterator &a, const Iterator &b)
{
return a.ptr_ == b.ptr_;
}
friend bool operator!=(const Iterator &a, const Iterator &b)
{
return a.ptr_ != b.ptr_;
}
private:
template< bool _IsReverse = IsReverse >
std::enable_if_t< _IsReverse, reference >
operator--()
{
ptr_--;
return *ptr_;
}
pointer ptr_=nullptr;
};
MyString();
MyString(const char *);
MyString(const std::string &);
MyString(std::initializer_list<char>);
MyString(MyString &&) noexcept;
MyString(const char *, size_t);
MyString(char, size_t);
MyString(const MyString &);
template<typename T,std::enable_if_t<std::is_integral<T>::value, bool> = true>
MyString(T arg):size_{128},capacity_{size_+1},str_{new char[capacity_]()}
{
if constexpr(std::is_signed<T>::value)
std::snprintf(str_,size_,"%lld",static_cast<int64_t>(arg));
else
std::snprintf(str_,size_,"%llu",static_cast<uint64_t>(arg));
shrink_to_fit();
}
template<typename T,std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
MyString(T arg):size_{128},capacity_{size_+1},str_{new char[capacity_]()}
{
if constexpr(std::is_same<float,T>::value)
std::snprintf(str_,size_,"%f",arg);
else
std::snprintf(str_,size_,"%lf",arg);
shrink_to_fit();
}
friend void swap(MyString &first, MyString &second);
char *c_str() const;
char *data() const;
size_t size() const;
size_t length() const;
bool empty() const;
size_t capacity() const;
void clear();
void append(size_t, char);
void append(const char *c_str, size_t = 0, size_t = default_append);
void append(const std::string &str, size_t = 0, size_t = default_append);
void replace(size_t, size_t, const char *);
void replace(size_t, size_t, const std::string &);
void insert(size_t, size_t, char);
void insert(size_t, const char *, size_t = default_append);
void insert(size_t, const std::string &, size_t = default_append);
MyString substr(size_t, size_t = default_append);
int find(const char *, size_t = 0);
int find(const std::string &, size_t = 0);
void erase(size_t, size_t);
void shrink_to_fit();
MyString operator+(const MyString &);
MyString operator+(const char *);
MyString operator+(const std::string &);
MyString &operator+=(const MyString &);
MyString &operator+=(const std::string &);
MyString &operator+=(const char *);
MyString &operator=(const char);
MyString &operator=(const char *);
MyString &operator=(const MyString &);
MyString &operator=(const std::string &);
MyString &operator=(MyString &&);
char operator[](size_t) const;
char &operator[](size_t);
friend bool operator==(MyString const &, MyString const &);
friend bool operator<(MyString const &, MyString const &);
friend bool operator>(MyString const &, MyString const &);
friend bool operator<=(MyString const &, MyString const &);
friend bool operator>=(MyString const &, MyString const &);
friend bool operator!=(MyString const &, MyString const &);
char & at(int);
template <typename T>
friend std::basic_ostream<T> &operator<<(std::basic_ostream<T> &, const MyString &);
template <typename T>
friend std::basic_istream<T> &operator>>(std::basic_istream<T> &, MyString &);
template <typename ArgType>
ArgType to()
{
return to_impl<ArgType>(std::is_integral<ArgType>{});
}
using const_iterator=Iterator<true,false>;
using iterator=Iterator<false,false>;
using const_reverse_iterator=Iterator<true,true>;
using reverse_iterator=Iterator<false,true>;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
const_iterator cbegin() const;
const_iterator cend() const;
reverse_iterator rbegin();
reverse_iterator rend();
const_reverse_iterator rcbegin() const;
const_reverse_iterator rcend() const;
const_reverse_iterator rbegin() const;
const_reverse_iterator rend() const;
~MyString();
};
template <typename T>
std::basic_ostream<T> &operator<<(std::basic_ostream<T> &out, const MyString &str)
{
out << (str.str_);
return out;
}
template <typename T>
std::basic_istream<T> &operator>>(std::basic_istream<T> &in, MyString &str)
{
char ch;
while (in.get(ch) && ch != '\n')
{
str.append(1, ch);
}
return in;
}
|
f38a2b02259a1a8f7a61ddc33ff83397e22e2b0e | cc785e941c3d9e3a9479d408967dc0c6b3cd6567 | /wgSeries/Game/libSimpleSkin/SkinFileReader.h | a53110e2eabc67a2736af54d35ad7f364a8cc8e8 | [] | no_license | zj19880815/InfoSecuSource | a5524ae8cde6fc2fd3b78d325b15fc52285db782 | 4e14e5212152e3a63dccbd94ff81b762bb24a065 | refs/heads/master | 2021-07-14T16:37:43.115351 | 2021-01-16T13:05:15 | 2021-01-16T13:05:15 | 237,572,438 | 1 | 0 | null | 2020-02-01T06:21:21 | 2020-02-01T06:21:21 | null | UTF-8 | C++ | false | false | 881 | h | SkinFileReader.h | #pragma once
#include "SkinWindow.h"
#include "SkinControl.h"
#include "SkinDraggableControl.h"
#include "SkinRectangleControl.h"
#include "SkinImageControl.h"
#include "SkinStaticControl.h"
class CSkinFileReader
{
public:
CSkinFileReader(void);
virtual ~CSkinFileReader(void);
CSkinWindow * LoadSkin(LPCTSTR pszFileName, LPCTSTR pszSkinMode, HWND hTargetWindow);
void ReleaseSkin();
CSkinWindow * GetSkinWindow();
CSkinWindow * SetCurrentMode(LPCTSTR pszMode);
LPCTSTR GetCurrentMode();
LPCTSTR GetBasePath();
void GetFullFilePath(LPCTSTR pszFileName, STRING * pszResult);
protected:
CSkinWindow * ApplySkinMode(XMLNS::IXMLDOMNodePtr spModeNode, HWND hTargetWindow);
CSkinControl * CreateSkinControl(CSkinControl * pParent, XMLNS::IXMLDOMNodePtr spNode);
CSkinWindow * m_pSkinWindow;
STRING m_szBasePath;
STRING m_szCurrentMode;
STRING m_szCurrentSkinFile;
};
|
2e570b214aa00285457212d309fbb2e456f273a3 | 41f91f0337bb72962cfa19f1b6cfe11ff1fe972f | /Round #629 (Div. 3)-B K-th Beautiful String.cpp | 71bbee549be832fc22c47591efcf99b34da6297a | [] | no_license | m-maheshwari-04/Codeforces | a74d2930df8fdb6d1e94196ac7e2d349deb6c399 | 87b7ec5b0416bb14198f135b80af3df5720faeed | refs/heads/master | 2023-01-22T03:45:57.245519 | 2020-12-01T17:50:40 | 2020-12-01T17:50:40 | 296,025,948 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 523 | cpp | Round #629 (Div. 3)-B K-th Beautiful String.cpp |
#include <iostream>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
unsigned long int k;
cin>>n>>k;
int n1,n2,i,sum=1;
for(n1=1;;n1++){
if(k<=sum){
break;
}
sum=sum+(n1+1);
}
n2=n1-sum+k;
n1=n1+1;
for(i=n;i>0;i--){
if(i!=n1&&i!=n2)
cout<<"a";
else
cout<<"b";
}
cout<<endl;
}
return 0;
} |
823bd0af8cc89d639b4c34702929009d3d01b79d | 9c0b20b9c9670b2e918194e2e492d25768a1029d | /ConnectedComponents.cpp | 0081d0785ac922b333b9bb952e403cf39f7a47c2 | [] | no_license | emuemuJP/AOJ | 3162571915d95a0d1baee198fa11f7b11ae1b32c | e02b229afe47adef7c398961f49c3f22bf1d1731 | refs/heads/master | 2023-05-03T04:25:40.951980 | 2021-05-22T11:13:49 | 2021-05-22T11:13:49 | 328,708,599 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,960 | cpp | ConnectedComponents.cpp | #include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
void bfs(const vector<vector<int>>& mat, vector<bool>& search, const int index, vector<int>& group, const int id)
{
bool reach = false;
search[index] = true;
if(group[index] == -1) group[index] = id;
for(size_t i=0;i<mat[index].size(); i++)
{
if(!search[mat[index][i]])
{
search[mat[index][i]] = true;
if(group[index] == -1) group[index] = id;
bfs(mat, search, mat[index][i], group, id);
}
}
}
void assignGroup(const vector<vector<int>>& mat, vector<int>& group)
{
int id = 0;
for(size_t i=0;i<group.size(); i++)
{
if(group[i] == -1)
{
vector<bool> search(group.size());
bfs(mat, search, i, group, id++);
}
}
}
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef TEST
chrono::system_clock::time_point start, end;
start = chrono::system_clock::now();
#endif
long N, M;
cin >> N >> M;
vector<vector<int>> f(N, vector<int>());
for(size_t i=0;i<M; i++)
{
long s, t;
cin >> s >> t;
f[s].push_back(t);
f[t].push_back(s);
}
vector<int> group(N, -1);
assignGroup(f, group);
long q;
cin >> q;
for(size_t i=0;i<q; i++)
{
long s, t;
cin >> s >> t;
if(group[s] == group[t]) cout << "yes" << endl;
else cout << "no" << endl;
}
#ifdef TEST
end = chrono::system_clock::now();
cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
return 0;
} |
9cb40d0d3b37af8a0d066b45a1ce04e0b1b5567b | d69ccdb35375cd3342b56a92abb8315867a1fa17 | /EP446/EP446.cpp | 1b68814e4359f7e5d810458e1f3439e5f0a9ac8b | [] | no_license | amol447/ProjectEuler | 5bfdc968410cc101ba2d58286c39552096f98066 | b31ce21e26b2b878a081d50b48308ff8db54bca7 | refs/heads/master | 2021-01-10T20:28:15.395037 | 2015-02-14T18:34:15 | 2015-02-14T18:34:15 | 20,061,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,084 | cpp | EP446.cpp | #include<iostream>
#include<primesieve.hpp>
#include<vector>
#include<utility>
#include<cmath>
#include<algorithm>
#include<unordered_map>
#include<set>
#include<list>
using namespace std;
// implements sieve given here http://www.ams.org/journals/mcom/1959-13-066/S0025-5718-1959-0105784-2/S0025-5718-1959-0105784-2.pdf
inline long multiplyModuloN(long x,long y,long moduloN)
{
return ( ( x%moduloN ) * ( y%moduloN ) )%moduloN;
}
inline long addModuloN(long x,long y,long moduloN)
{
return ( x + y) % moduloN;
}
unordered_map<long,long> operator+(unordered_map<long,long> x,unordered_map<long,long>y)
{
unordered_map<long,long> result;
for(auto i=x.begin();i!=x.end();++i)
result[i->first]=x[i->first];
for(auto i=y.begin();i!=y.end();++i)
result[i->first]+=y[i->first];
return result;
}
long intExp(long a,long b,long acc)
{
if(b==0)
return acc;
if(b%2==0)
return intExp(a*a,b/2,acc);
else
return intExp(a,b-1,acc*a);
}
long intExpModuloN(long a,long b,long acc,long moduloN)
{
if(b==0)
return acc;
if(b%2==0)
return intExp(multiplyModuloN(a,a,moduloN),b/2,acc);
else
return intExp(a,b-1,multiplyModuloN(acc,a,moduloN) );
}
pair<long,long> calcNextABk(long A,long B,long k,long h,long p)
{
long C=( ( h * ( 1 + A*A ) )/intExp(p,k,1)) %p;
A=A+C*intExp(p,k,1);
B=intExp(p,k+1,1)-A;
return make_pair(A,B);
}
void updateFactorizationMap(unordered_map<long,long>& factors,long prime)
{
if(factors.find(prime)!=factors.end())
factors[prime]++;
else
factors[prime]=1;
}
vector<unordered_map<long,long> > nSquaredPlusOneSieve(long maxNumber)
{
vector<long> sieve(maxNumber+1);
for(unsigned long i=1;i<maxNumber+1;++i)
sieve[i]=i*i+1;
vector<unordered_map<long,long> > result(maxNumber+1);
//divide by 2 where possible
for(unsigned long i=1;i<maxNumber+1;i+=2)
{
if(i<maxNumber+1)
{
sieve[i]=sieve[i]/2;
updateFactorizationMap(result[i],2);
}
}
long leftToDo=2;
long A,B,h,k;
long currPrime;
while(leftToDo<maxNumber+1)
{
if(sieve[leftToDo]==1)
{
leftToDo++;
continue;
}
currPrime=sieve[leftToDo];
A=leftToDo;
B=currPrime-leftToDo;
h=( ((currPrime+1)/2)*A )%currPrime;
k=1;
while( (A<maxNumber+1) || (B<maxNumber+1) )
{
for(unsigned long i=A;i<maxNumber+1;i+=intExp(currPrime,k,1))
{
if(i<maxNumber+1)
{
updateFactorizationMap(result[i],currPrime);
if(sieve[i]%currPrime!=0)
cout<<"error prone sieve-fix it A, i="<<i<<", prime="<<currPrime<< ", k="<<k <<endl;
sieve[i]/=currPrime;
}
}
for(unsigned long i=B;i<maxNumber+1;i+=intExp(currPrime,k,1))
{
if(i<maxNumber+1)
{
updateFactorizationMap(result[i],currPrime);
if(sieve[i]%currPrime!=0)
cout<<"error prone sieve-fix it B "<<i<<endl;
sieve[i]/=currPrime;
}
}
if(currPrime > maxNumber+1)
break;
auto temp=calcNextABk(A,B,k,h,currPrime);
A=temp.first;
B=temp.second;
k=k+1;
}
leftToDo++;
}
return result;
}
long numRetractionsFunction(long n,const vector<unordered_map<long,long> > & primeFactors,long moduloN)
{
long result=1;
long num=1;
for(auto i=primeFactors.at(n).cbegin();i!=primeFactors.at(n).cend();++i)
{
result=multiplyModuloN(result,(1+intExpModuloN(i->first,i->second,1,moduloN)),moduloN);
num=multiplyModuloN(num,intExpModuloN(i->first,i->second,1,moduloN),moduloN);
}
return result-num;
}
long calcRetractions(long maxNumber,long moduloN)
{
vector<unordered_map<long,long> > nSquaredPlusOneFactors=nSquaredPlusOneSieve(maxNumber+1);
vector<unordered_map<long,long> > n4PlusOneFactors(maxNumber+1);
long result=0;
n4PlusOneFactors[1]=nSquaredPlusOneFactors[2];
for(unsigned long i=1;i<maxNumber;++i)
{
n4PlusOneFactors[i+1]=nSquaredPlusOneFactors[i]+nSquaredPlusOneFactors[i+2];
}
for(long i=1;i<maxNumber+1;++i)
{
result=addModuloN(numRetractionsFunction(i,n4PlusOneFactors,moduloN),result,moduloN);
}
return result;
}
int main()
{
long maxNumber=1e7;
long moduloN=1000000007;
// long moduloN=1e4;
long result= calcRetractions(maxNumber,moduloN);
cout<<result<<endl;
}
|
73ef0935c7d430006e7b5a970146fdb7e15ba72f | dac5254630fefae851da7c843dcab7f6a6af9703 | /Linux/Sources/Application/Letter/CFileTableAction.cp | 33c39a4001ed305016c183abf83e15cd8583865e | [
"Apache-2.0"
] | permissive | gpreviato/Mulberry-Mail | dd4e3618468fff36361bd2aeb0a725593faa0f8d | ce5c56ca7044e5ea290af8d3d2124c1d06f36f3a | refs/heads/master | 2021-01-20T03:31:39.515653 | 2017-09-21T13:09:55 | 2017-09-21T13:09:55 | 18,178,314 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,023 | cp | CFileTableAction.cp | /*
Copyright (c) 2007 Cyrus Daboo. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Source for CFileTableAction class
#include "CFileTableAction.h"
#include "CAttachment.h"
#include "CAttachmentList.h"
#include "CFileTable.h"
// __________________________________________________________________________________________________
// C L A S S __ CFileTableAction
// __________________________________________________________________________________________________
// C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S
// Default constructor
CFileTableAction::CFileTableAction(CFileTable *owner, int inStringIndex)
: LAction(inStringIndex, false),
mOwner(owner)
{
}
// Default destructor
CFileTableAction::~CFileTableAction()
{
}
#pragma mark -
// __________________________________________________________________________________________________
// C L A S S __ CFileTableDeleteAction
// __________________________________________________________________________________________________
// C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S
// Default constructor
CFileTableDeleteAction::CFileTableDeleteAction(CFileTable *owner) :
CFileTableAction(owner, IDS_FileTableDelete_REDO)
{
int row = 0;
while(mOwner->GetNextSelectedCell(row))
{
// Get file spec
CAttachment* attach = mOwner->GetBody()->GetPart(row);
// Copy it
CAttachment* copy = CAttachment::CopyAttachment(*attach);
// Add to lists
mItems.push_back(copy);
mItemPos.push_back(row);
}
}
// Default destructor
CFileTableDeleteAction::~CFileTableDeleteAction()
{
}
// O T H E R M E T H O D S ____________________________________________________________________________
void CFileTableDeleteAction::RedoSelf()
{
// Remove all items in list (in reverse)
for(ulvector::reverse_iterator riter = mItemPos.rbegin(); riter != mItemPos.rend(); riter++)
{
int row = *riter;
//mOwner->GetAttachList()->RemoveAttachmentAt(row - 1);
}
mOwner->ResetTable();
}
void CFileTableDeleteAction::UndoSelf()
{
// Add all items in list
CAttachmentList::iterator iter = mItems.begin();
for(ulvector::iterator piter = mItemPos.begin(); piter != mItemPos.end(); piter++, iter++)
{
int row = *piter;
// Get copy of info
CAttachment* copy = CAttachment::CopyAttachment(**iter);
//mOwner->GetAttachList()->InsertAttachmentAt(row, copy);
}
mOwner->ResetTable();
}
#pragma mark -
// __________________________________________________________________________________________________
// C L A S S __ CFileTableAddAction
// __________________________________________________________________________________________________
// C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S
// Default constructor
CFileTableAddAction::CFileTableAddAction(CFileTable *owner, CAttachment* add) :
CFileTableAction(owner, IDS_FileTableAdd_REDO)
{
// Add to lists
mItems.push_back(add);
int pos = mOwner->GetBody()->CountParts()+1;
mItemPos.push_back(pos);
}
// Default destructor
CFileTableAddAction::~CFileTableAddAction()
{
// Make sure owner disposes of cached action
mOwner->ActionDeleted();
}
// O T H E R M E T H O D S ____________________________________________________________________________
// Default constructor
void CFileTableAddAction::Add(CAttachment* add)
{
// Delete existing if undone and new copy takes place
if (!mIsDone)
{
// Delete all items in lists
mItems.clear();
mItemPos.clear();
// Reset state
mIsDone = true;
}
// Add to lists
mItems.push_back(add);
int pos = mOwner->GetBody()->CountParts()+1;
mItemPos.push_back(pos);
// Add to list
CAttachment* copy;
copy = CAttachment::CopyAttachment(*add);
//mOwner->GetAttachList()->InsertAttachmentAt(pos, copy);
mOwner->ResetTable();
}
void CFileTableAddAction::RedoSelf()
{
// Add all items in list
CAttachmentList::iterator iter = mItems.begin();
for(ulvector::iterator piter = mItemPos.begin(); piter != mItemPos.end(); piter++, iter++)
{
int row = *piter;
// Get copy of info
CAttachment* copy = CAttachment::CopyAttachment(**iter);
//mOwner->GetAttachList()->InsertAttachmentAt(row, copy);
}
mOwner->ResetTable();
}
void CFileTableAddAction::UndoSelf()
{
// Remove all items in list (in reverse)
for(ulvector::reverse_iterator riter = mItemPos.rbegin(); riter != mItemPos.rend(); riter++)
{
int row = *riter;
//mOwner->GetAttachList()->RemoveAttachmentAt(row);
}
mOwner->ResetTable();
}
|
cc5d4f389edc5a8b0bc65f77bdab1e08e9f0f7c8 | 3f852d453be93736bac6dd952af3b8172d524047 | /mcm.cpp | 50b3d1bc64db55ba39cf670504f925727efeabae | [] | no_license | burin-n/grader-algo | 1d7294e6ecf7959bb9b828275f5fa1080f921b74 | 7098a74154325c1f99dfc084236219a113acd76e | refs/heads/master | 2021-08-07T05:42:56.365914 | 2017-11-07T16:24:56 | 2017-11-07T16:24:56 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 787 | cpp | mcm.cpp | #include <bits/stdc++.h>
using namespace std;
int dp[101][101];
int m[101];
const int INF = 1e9;
void init(){
for(int i=0;i<101;i++){
for(int j=0;j<101;j++)
dp[i][j] = INF;
dp[i][i] = 0;
}
}
int solve(int i,int j){
if(i == j) return dp[i][j]=0;
if(dp[i][j] != INF) return dp[i][j];
for(int k=i;k<j;k++)
dp[i][j] = min(dp[i][j],solve(i,k) + solve(k+1,j) + m[i-1]*m[k]*m[j]);
return dp[i][j];
}
int btmup(int n){
for(int i=n;i>0;i--){
for(int j=i;j<=n;j++){
for(int k=i;k<j;k++)
dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+m[i-1]*m[k]*m[j]);
}
}
return dp[1][n];
}
int main(){
ios_base::sync_with_stdio(0);
int n;
cin >> n;
for(int i=0;i<=n;i++)
cin >> m[i];
init();
//cout << solve(1,n) << endl;
cout << btmup(n) << endl;
return 0;
}
|
b71755a07eb60bcee9d09b032acee6992e02f297 | 07a80c0b0419245bfc2b69a08f4f619d905fab30 | /backend/Taxi.h | 223c74a0b09798086146dbded4ee6806c7d65f20 | [] | no_license | roastduck/carpool | f6acbf8fd4aa5f6d74423d6ac5a2155bd8526a05 | 1bd55ed66b9d1c8142a62cbcff704c4c64ff1a57 | refs/heads/master | 2020-03-16T22:50:10.743095 | 2018-05-26T12:42:27 | 2018-05-26T12:42:27 | 133,054,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 490 | h | Taxi.h | #ifndef TAXI_H_
#define TAXI_H_
#include <cstdio>
#include <vector>
#include <memory>
#include "Result.h"
class Graph;
class Taxi
{
private:
int at;
std::vector<int> targets;
Path findShortest(const std::vector<Path> &begin, const std::vector<std::vector<Path>> &paths) const;
public:
static void input(Graph &graph, FILE *f);
std::unique_ptr<Candidate> verify(const Graph &graph, int pickSt, int pickEn, int pickDist, int aloneDist) const;
};
#endif // TAXI_H_
|
de18c9d241de1acfee949d416e39af0f7e3f1cd0 | c508360b05fce43ef590589d3f31fd0ccfcf0bed | /TICT-PPC/ppc-week3-Milooooo1/Week3Opdracht5.cpp | 6f651b484987374e03e5a98e1c67785eb4825366 | [] | no_license | Milooooo1/schoolExercises | 53c86d6ad2e32dbbd2698acf3235d509fd1d8dd2 | 04bac4b38833f352c120ea843c631fd747de7d52 | refs/heads/master | 2023-03-29T00:22:46.598419 | 2021-04-01T18:37:13 | 2021-04-01T18:37:13 | 294,451,803 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 377 | cpp | Week3Opdracht5.cpp | #include <iostream>
#include <vector>
using namespace std;
float gemiddelde(vector<int> vect){
float totaal = 0;
for(int i = 0; i < vect.size(); i++){
totaal += vect[i];
}
cout << totaal << endl << vect.size() << endl;
return totaal / vect.size();
}
int main(){
vector<int> vect = {5, 7, 1, 12, 8, 2, 3, 9, 4};
cout << gemiddelde(vect) << endl;
} |
c99ea7d07db9bdb25cab5bb7d04448b316ea3354 | b34d9f43d3c3327bdd5e702b66812cc643c468cb | /Accept/3943 헤일스톤 수열.cpp | f379f54564de86a7272f30c4b1766896f3485f9f | [] | no_license | lis123kr/Baekjoon-Online-Judge | 817302354d78f5db6a5a906f93ced27a116080cd | 356034981312730b9365b23d1917b0fabc015d08 | refs/heads/master | 2022-07-21T21:16:07.971195 | 2022-07-15T08:11:14 | 2022-07-15T08:11:14 | 75,055,346 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 446 | cpp | 3943 헤일스톤 수열.cpp | #include<stdio.h>
int D[300003];
int max(int a, int b) { return a > b ? a : b; }
int solve(int n) {
if (n == 1)
return 1;
if (n<= 300000 && D[n] != 0)
return D[n];
if(n<=300000)
return D[n] = n%2 ? max(n, solve(3*n+1)) : max(n, solve(n / 2));
else
return n % 2 ? max(n, solve(3 * n + 1)) : max(n, solve(n / 2));
}
int main() {
int n, t;
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
printf("%d\n", solve(n));
}
return 0;
} |
34cdb041721cc8038e631fc5b5c7e33c87635b09 | a675e76f367fe8822b6bf4ede935cf320303d8bb | /Lunch_Q1.cpp | 9ad4f693d6d78a418689b042db54b313fc2535eb | [] | no_license | kunalchhabra2001/CodeChef-Challenges | 8333c4cd456b0f2ffc7c8a4ee107db30eae454a2 | 6943470bf6afa0039c1915fbd71b748692f08773 | refs/heads/master | 2022-09-26T06:47:14.819811 | 2020-06-02T10:29:46 | 2020-06-02T10:29:46 | 268,770,865 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 741 | cpp | Lunch_Q1.cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int t;
cin >> t;
while(t--)
{
int n,sum=0,diff2=0,diff1=0,max_diff=0,add=0;
cin >> n;
int arr[n];
std::vector<int> v;
for(int i=0;i<n;i++){
cin >> arr[i];
}
int dis[n];
for(int i=0;i<n;i++)
{
if(arr[i]==1){
v.push_back(i);
}
}
int len = v.size();
if(len==0)cout<<"0"<<endl;
else{
for(int i=1;i<len-1;i++)
{
diff1 = v[i]-v[i-1];
diff2 = v[i+1]-v[i];
add = min(diff2,diff1);
max_diff = min(max_diff,add);
sum += add;
}
diff1 = v[len-1]-v[len-2];
diff2 = n + v[0] - v[len-1];
if(diff1<diff2)
sum += min(diff1,diff2);
sum -= max_diff;
cout << sum << endl;
}
}
} |
78183cbe824f7aaef767bc3366d7ad5f7ef1f99c | abb3b337d6dfe090d46860e72107356cb16fa128 | /HRobotPressureSensorSRI.h | cbc28c1184c94ca655f2c892e8dee64199e2b554 | [] | no_license | a2824256/URtest | 6bb5a976ef4e4ad10f731e3bb3c685fae79465ce | 126991886e415e0a4702a36e85207f37c408ffd1 | refs/heads/master | 2023-03-21T00:34:58.543229 | 2021-03-02T07:44:11 | 2021-03-02T07:44:11 | 343,687,406 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,517 | h | HRobotPressureSensorSRI.h | #ifndef HROBOTPRESSURESENSOROPTO_H
#define HROBOTPRESSURESENSOROPTO_H
#include <QObject>
#include <QMutex>
#include "HConnector.h"
#include <QUdpSocket>
#include "HRobotPressureSensorPrivateBase.h"
typedef struct ResponseStruct {
unsigned int sequenceNumber;
unsigned int sampleCounter;
unsigned int status;
double fx;
double fy;
double fz;
double tx;
double ty;
double tz;
} Response;
class HRobotPressureSensorSRI:public HRobotPressureSensorPrivateBase
{
Q_OBJECT
public:
HRobotPressureSensorSRI();
~HRobotPressureSensorSRI();
bool GetPressureSensorInfo(double &x, double& y, double& z);
// void Check();
void SetNeedToCalibration(bool bCalibration);
private:
void SendCommand();
bool ParseData(QByteArray byteArray);
double LowPassFilter_RC_1order(double Vi, double Vo_p, double sampleFrq, double CutFrq);
private:
QUdpSocket *m_UdpSocket;
QByteArray m_SensorData ;
bool m_bNeedCalibration;
Response m_Response;
Response m_ResponseCalibration;
QAbstractSocket::SocketState m_SocketState ;
HPressureInfo m_PressureInfo;
int m_nNoDataCount ;
int m_nDataError ;
int m_iSriAngle;
QMutex m_Mutex;
signals:
void SigWrite(QByteArray);
void SigSendCommand(qint16 command, qint32 data) ;
void SigReconnect();
void SigInit();
public slots:
void SlotStateChanged(QAbstractSocket::SocketState);
void SlotReadData();
void SlotConnected();
};
#endif // HROBOTPRESSURESENSOROPTO_H
|
12105311d659f7dae867fdc50ea3430221ef2a5d | 46f2e7a10fca9f7e7b80b342240302c311c31914 | /lid_driven_flow/cavity/0.0586/U | 9c39d5fd81bc39ebb85135ae442a00d8a319a978 | [] | no_license | patricksinclair/openfoam_warmups | 696cb1950d40b967b8b455164134bde03e9179a1 | 03c982f7d46b4858e3b6bfdde7b8e8c3c4275df9 | refs/heads/master | 2020-12-26T12:50:00.615357 | 2020-02-04T20:22:35 | 2020-02-04T20:22:35 | 237,510,814 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 62,995 | U | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0.0586";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
2500
(
(2.97207e-05 -2.98447e-05 0)
(9.02454e-05 -3.64845e-05 0)
(0.000124332 -1.86647e-05 0)
(9.27237e-05 7.51408e-06 0)
(-1.64973e-05 3.43076e-05 0)
(-0.00020176 5.89383e-05 0)
(-0.000456035 8.02749e-05 0)
(-0.000770177 9.79868e-05 0)
(-0.00113402 0.000112093 0)
(-0.00153712 0.000122742 0)
(-0.00196916 0.000130134 0)
(-0.00242019 0.000134485 0)
(-0.00288073 0.000136015 0)
(-0.00334186 0.000134946 0)
(-0.00379529 0.000131491 0)
(-0.00423331 0.000125862 0)
(-0.00464891 0.000118263 0)
(-0.00503567 0.000108894 0)
(-0.00538787 9.79484e-05 0)
(-0.0057004 8.56191e-05 0)
(-0.00596882 7.20947e-05 0)
(-0.00618935 5.75644e-05 0)
(-0.00635885 4.22184e-05 0)
(-0.00647488 2.625e-05 0)
(-0.00653567 9.85692e-06 0)
(-0.00654014 -6.75715e-06 0)
(-0.00648797 -2.33812e-05 0)
(-0.00637955 -3.9796e-05 0)
(-0.00621607 -5.57743e-05 0)
(-0.00599949 -7.10803e-05 0)
(-0.0057326 -8.54713e-05 0)
(-0.00541901 -9.86977e-05 0)
(-0.00506318 -0.000110506 0)
(-0.00467039 -0.00012064 0)
(-0.00424678 -0.000128844 0)
(-0.00379928 -0.000134868 0)
(-0.00333562 -0.000138466 0)
(-0.00286425 -0.000139406 0)
(-0.00239428 -0.000137468 0)
(-0.0019354 -0.000132452 0)
(-0.00149777 -0.000124179 0)
(-0.00109185 -0.000112499 0)
(-0.000728267 -9.7304e-05 0)
(-0.000417445 -7.85597e-05 0)
(-0.000169192 -5.63894e-05 0)
(8.0527e-06 -3.13021e-05 0)
(0.000108488 -4.59762e-06 0)
(0.000131675 2.07262e-05 0)
(9.15321e-05 3.74321e-05 0)
(2.93547e-05 2.92955e-05 0)
(3.67276e-05 -9.05873e-05 0)
(8.26969e-05 -8.19557e-05 0)
(3.36282e-05 1.80188e-05 0)
(-0.000170273 0.000154071 0)
(-0.00055272 0.000297859 0)
(-0.00111407 0.000434939 0)
(-0.00184258 0.000557772 0)
(-0.00271934 0.000662732 0)
(-0.0037214 0.000748317 0)
(-0.00482387 0.000814172 0)
(-0.00600116 0.000860602 0)
(-0.00722791 0.000888298 0)
(-0.00847946 0.000898189 0)
(-0.00973229 0.000891348 0)
(-0.0109642 0.000868937 0)
(-0.0121544 0.000832167 0)
(-0.0132839 0.000782277 0)
(-0.0143352 0.000720524 0)
(-0.0152925 0.000648171 0)
(-0.016142 0.000566488 0)
(-0.0168714 0.000476753 0)
(-0.0174703 0.000380256 0)
(-0.0179302 0.000278307 0)
(-0.0182444 0.000172238 0)
(-0.0184081 6.34134e-05 0)
(-0.0184185 -4.6766e-05 0)
(-0.0182748 -0.000156858 0)
(-0.0179783 -0.000265376 0)
(-0.0175323 -0.000370792 0)
(-0.0169424 -0.000471537 0)
(-0.0162163 -0.000566008 0)
(-0.015364 -0.000652582 0)
(-0.0143978 -0.000729625 0)
(-0.0133322 -0.000795514 0)
(-0.0121836 -0.000848656 0)
(-0.010971 -0.000887517 0)
(-0.00971491 -0.000910649 0)
(-0.00843796 -0.000916726 0)
(-0.00716419 -0.000904583 0)
(-0.00591894 -0.000873263 0)
(-0.00472842 -0.000822085 0)
(-0.00361917 -0.000750728 0)
(-0.00261737 -0.000659383 0)
(-0.0017479 -0.000549001 0)
(-0.00103289 -0.000421766 0)
(-0.000489639 -0.000282036 0)
(-0.000127444 -0.000138004 0)
(5.71105e-05 -4.7292e-06 0)
(9.09577e-05 8.99206e-05 0)
(3.77729e-05 9.15348e-05 0)
(1.98771e-05 -0.000126241 0)
(-1.38928e-05 -3.38886e-05 0)
(-0.000227241 0.000232801 0)
(-0.000670668 0.000575502 0)
(-0.0013672 0.000939119 0)
(-0.0023175 0.00129031 0)
(-0.00350644 0.00160941 0)
(-0.00490866 0.00188546 0)
(-0.00649245 0.00211281 0)
(-0.00822249 0.00228907 0)
(-0.0100618 0.00241394 0)
(-0.0119731 0.00248844 0)
(-0.0139195 0.0025145 0)
(-0.0158658 0.0024946 0)
(-0.0177781 0.00243162 0)
(-0.019625 0.00232869 0)
(-0.021377 0.00218911 0)
(-0.0230072 0.00201628 0)
(-0.0244915 0.00181368 0)
(-0.0258082 0.00158485 0)
(-0.0269383 0.00133339 0)
(-0.0278659 0.00106293 0)
(-0.0285777 0.000777196 0)
(-0.0290634 0.000479964 0)
(-0.0293157 0.000175111 0)
(-0.0293302 -0.000133389 0)
(-0.029106 -0.000441455 0)
(-0.028645 -0.000744897 0)
(-0.0279526 -0.00103942 0)
(-0.0270376 -0.00132064 0)
(-0.025912 -0.00158409 0)
(-0.0245913 -0.00182528 0)
(-0.0230946 -0.00203972 0)
(-0.021444 -0.00222298 0)
(-0.0196651 -0.00237074 0)
(-0.0177867 -0.0024789 0)
(-0.0158402 -0.00254365 0)
(-0.0138598 -0.00256158 0)
(-0.0118819 -0.00252982 0)
(-0.00994435 -0.00244618 0)
(-0.00808604 -0.00230939 0)
(-0.00634592 -0.00211936 0)
(-0.0047619 -0.00187763 0)
(-0.00336923 -0.00158806 0)
(-0.00219858 -0.0012579 0)
(-0.00127319 -0.000899771 0)
(-0.000605023 -0.000534755 0)
(-0.000189597 -0.000197282 0)
(5.49779e-07 5.74128e-05 0)
(2.21973e-05 0.000133238 0)
(-4.72651e-06 -9.87334e-05 0)
(-0.000146212 0.000166103 0)
(-0.000566027 0.000675018 0)
(-0.0012884 0.00129565 0)
(-0.00232661 0.00194739 0)
(-0.00367765 0.00257764 0)
(-0.00532179 0.00315299 0)
(-0.00722778 0.00365327 0)
(-0.00935691 0.00406704 0)
(-0.0116657 0.00438866 0)
(-0.0141083 0.00461644 0)
(-0.0166379 0.00475135 0)
(-0.0192081 0.00479624 0)
(-0.0217738 0.00475518 0)
(-0.0242918 0.00463316 0)
(-0.0267214 0.00443576 0)
(-0.0290247 0.004169 0)
(-0.0311668 0.00383918 0)
(-0.0331163 0.0034528 0)
(-0.034845 0.00301655 0)
(-0.0363283 0.00253725 0)
(-0.0375453 0.00202184 0)
(-0.0384786 0.00147741 0)
(-0.039115 0.000911213 0)
(-0.0394449 0.000330662 0)
(-0.0394629 -0.000256643 0)
(-0.0391676 -0.000842911 0)
(-0.0385618 -0.00142016 0)
(-0.0376526 -0.00198022 0)
(-0.0364514 -0.00251478 0)
(-0.0349741 -0.00301541 0)
(-0.0332409 -0.00347366 0)
(-0.0312765 -0.00388111 0)
(-0.0291098 -0.00422949 0)
(-0.0267739 -0.00451082 0)
(-0.0243058 -0.00471755 0)
(-0.0217461 -0.00484277 0)
(-0.0191385 -0.00488042 0)
(-0.0165294 -0.0048255 0)
(-0.0139669 -0.00467449 0)
(-0.0115001 -0.00442568 0)
(-0.00917789 -0.00407974 0)
(-0.00704724 -0.00364054 0)
(-0.00515169 -0.00311625 0)
(-0.00352885 -0.00252109 0)
(-0.00220756 -0.00187802 0)
(-0.00120395 -0.0012229 0)
(-0.000516612 -0.000610157 0)
(-0.000126546 -0.00012086 0)
(-1.25886e-06 0.000114909 0)
(-3.03438e-05 4.50225e-06 0)
(-0.000289332 0.00054449 0)
(-0.000935415 0.00137347 0)
(-0.00195754 0.00233623 0)
(-0.00335352 0.00333178 0)
(-0.00511302 0.00429052 0)
(-0.00720975 0.00516584 0)
(-0.00960599 0.00592798 0)
(-0.0122564 0.00655903 0)
(-0.0151105 0.00704941 0)
(-0.0181149 0.00739548 0)
(-0.021215 0.00759779 0)
(-0.0243564 0.00765996 0)
(-0.0274861 0.00758772 0)
(-0.0305529 0.00738838 0)
(-0.0335087 0.00707034 0)
(-0.0363084 0.0066428 0)
(-0.0389103 0.00611552 0)
(-0.0412769 0.00549868 0)
(-0.0433744 0.00480279 0)
(-0.0451735 0.00403864 0)
(-0.0466491 0.00321725 0)
(-0.0477804 0.0023499 0)
(-0.0485515 0.00144813 0)
(-0.0489511 0.000523752 0)
(-0.0489727 -0.000411148 0)
(-0.0486145 -0.00134417 0)
(-0.0478802 -0.00226265 0)
(-0.0467783 -0.00315364 0)
(-0.0453224 -0.004004 0)
(-0.0435317 -0.00480045 0)
(-0.0414303 -0.00552967 0)
(-0.0390477 -0.00617847 0)
(-0.0364184 -0.00673396 0)
(-0.0335818 -0.00718373 0)
(-0.0305818 -0.00751615 0)
(-0.0274667 -0.00772066 0)
(-0.0242882 -0.0077881 0)
(-0.0211008 -0.00771116 0)
(-0.0179614 -0.00748492 0)
(-0.0149273 -0.00710742 0)
(-0.0120556 -0.00658055 0)
(-0.00940114 -0.00591116 0)
(-0.00701476 -0.00511259 0)
(-0.0049407 -0.00420684 0)
(-0.00321416 -0.00322781 0)
(-0.00185756 -0.00222579 0)
(-0.000876203 -0.00127323 0)
(-0.000265383 -0.000472335 0)
(-2.59828e-05 2.32182e-05 0)
(-5.46715e-05 0.000183993 0)
(-0.000431849 0.00110878 0)
(-0.00131015 0.00234061 0)
(-0.00264027 0.00371066 0)
(-0.00440127 0.00510303 0)
(-0.0065728 0.0064343 0)
(-0.00912002 0.00764628 0)
(-0.0119977 0.00870025 0)
(-0.0151534 0.00957187 0)
(-0.0185301 0.0102475 0)
(-0.0220675 0.0107212 0)
(-0.0257043 0.0109931 0)
(-0.0293792 0.0110675 0)
(-0.0330323 0.0109518 0)
(-0.0366061 0.0106559 0)
(-0.0400457 0.0101913 0)
(-0.0433002 0.00957064 0)
(-0.0463223 0.00880774 0)
(-0.0490692 0.00791696 0)
(-0.0515026 0.00691322 0)
(-0.0535889 0.00581189 0)
(-0.0552996 0.00462874 0)
(-0.0566111 0.00337993 0)
(-0.0575052 0.00208198 0)
(-0.0579689 0.00075184 0)
(-0.0579949 -0.000593164 0)
(-0.0575813 -0.00193528 0)
(-0.0567321 -0.00325638 0)
(-0.055457 -0.00453798 0)
(-0.0537716 -0.00576134 0)
(-0.0516977 -0.00690753 0)
(-0.0492627 -0.00795767 0)
(-0.0465 -0.00889305 0)
(-0.043449 -0.00969545 0)
(-0.0401541 -0.0103474 0)
(-0.0366654 -0.0108327 0)
(-0.0330372 -0.0111366 0)
(-0.0293282 -0.0112465 0)
(-0.0255999 -0.0111526 0)
(-0.0219163 -0.0108484 0)
(-0.0183423 -0.0103318 0)
(-0.0149423 -0.00960622 0)
(-0.0117782 -0.00868167 0)
(-0.00890792 -0.00757697 0)
(-0.00638289 -0.00632203 0)
(-0.00424585 -0.00496122 0)
(-0.0025275 -0.00355796 0)
(-0.00124264 -0.00219986 0)
(-0.000404215 -0.00100524 0)
(-4.95407e-05 -0.000142577 0)
(-7.707e-05 0.000436671 0)
(-0.000569088 0.00185804 0)
(-0.00167805 0.0035786 0)
(-0.00331673 0.00542268 0)
(-0.00544412 0.00726427 0)
(-0.00802802 0.00900947 0)
(-0.0110235 0.0105906 0)
(-0.0143765 0.0119613 0)
(-0.0180272 0.0130914 0)
(-0.0219114 0.0139635 0)
(-0.0259625 0.0145696 0)
(-0.0301127 0.0149093 0)
(-0.0342946 0.0149878 0)
(-0.0384423 0.0148143 0)
(-0.0424926 0.0144015 0)
(-0.0463852 0.0137642 0)
(-0.0500639 0.0129191 0)
(-0.0534769 0.0118843 0)
(-0.0565768 0.0106788 0)
(-0.0593214 0.00932233 0)
(-0.0616737 0.0078355 0)
(-0.0636022 0.00623934 0)
(-0.0650809 0.00455544 0)
(-0.0660897 0.00280594 0)
(-0.0666142 0.0010135 0)
(-0.0666463 -0.000798684 0)
(-0.0661838 -0.00260688 0)
(-0.0652311 -0.00438685 0)
(-0.0637987 -0.00611392 0)
(-0.061904 -0.0077631 0)
(-0.0595705 -0.00930919 0)
(-0.0568286 -0.0107271 0)
(-0.0537151 -0.0119919 0)
(-0.0502729 -0.0130796 0)
(-0.0465512 -0.0139671 0)
(-0.0426048 -0.0146328 0)
(-0.0384936 -0.0150577 0)
(-0.034282 -0.0152253 0)
(-0.0300379 -0.0151229 0)
(-0.0258318 -0.0147424 0)
(-0.0217352 -0.0140814 0)
(-0.0178194 -0.0131447 0)
(-0.0141536 -0.0119454 0)
(-0.0108031 -0.0105078 0)
(-0.00782702 -0.00886906 0)
(-0.00527708 -0.00708308 0)
(-0.00319389 -0.00522455 0)
(-0.00160362 -0.0033933 0)
(-0.000538247 -0.00171942 0)
(-7.12479e-05 -0.000379733 0)
(-9.76147e-05 0.000758667 0)
(-0.000699855 0.00278762 0)
(-0.00203457 0.00508437 0)
(-0.00397846 0.00747074 0)
(-0.00647027 0.00981445 0)
(-0.00946494 0.0120141 0)
(-0.0129063 0.013995 0)
(-0.0167305 0.0157043 0)
(-0.0208695 0.0171072 0)
(-0.0252517 0.0181833 0)
(-0.0298039 0.0189229 0)
(-0.034452 0.0193256 0)
(-0.039123 0.0193976 0)
(-0.0437455 0.0191502 0)
(-0.048251 0.0185992 0)
(-0.0525746 0.017763 0)
(-0.0566558 0.0166626 0)
(-0.0604383 0.0153208 0)
(-0.0638714 0.0137617 0)
(-0.0669094 0.0120104 0)
(-0.0695125 0.0100929 0)
(-0.0716466 0.00803616 0)
(-0.0732836 0.00586758 0)
(-0.0744017 0.0036154 0)
(-0.0749855 0.0013085 0)
(-0.075026 -0.00102355 0)
(-0.0745207 -0.0033505 0)
(-0.0734741 -0.00564151 0)
(-0.0718977 -0.00786517 0)
(-0.0698095 -0.00998968 0)
(-0.0672352 -0.011983 0)
(-0.064207 -0.0138133 0)
(-0.0607644 -0.0154491 0)
(-0.0569537 -0.0168596 0)
(-0.0528278 -0.0180159 0)
(-0.0484457 -0.0188907 0)
(-0.0438721 -0.0194598 0)
(-0.0391765 -0.0197026 0)
(-0.0344326 -0.0196033 0)
(-0.0297168 -0.0191516 0)
(-0.0251073 -0.0183447 0)
(-0.0206823 -0.0171882 0)
(-0.0165182 -0.0156983 0)
(-0.0126883 -0.0139038 0)
(-0.00926073 -0.0118485 0)
(-0.00629689 -0.00959442 0)
(-0.0038487 -0.00722568 0)
(-0.00195475 -0.0048517 0)
(-0.000666268 -0.0026109 0)
(-9.11421e-05 -0.000684557 0)
(-0.00011664 0.00114625 0)
(-0.00082461 0.00389177 0)
(-0.00237934 0.00685277 0)
(-0.00462366 0.00985108 0)
(-0.00747657 0.0127509 0)
(-0.0108797 0.015446 0)
(-0.0147647 0.0178563 0)
(-0.0190575 0.0199248 0)
(-0.0236809 0.021613 0)
(-0.0285556 0.0228983 0)
(-0.0336012 0.0237703 0)
(-0.0387377 0.0242288 0)
(-0.0438861 0.0242816 0)
(-0.0489702 0.0239427 0)
(-0.0539167 0.0232311 0)
(-0.0586564 0.0221694 0)
(-0.0631247 0.0207831 0)
(-0.0672622 0.0191002 0)
(-0.0710146 0.0171501 0)
(-0.0743336 0.0149637 0)
(-0.0771768 0.0125728 0)
(-0.0795082 0.0100106 0)
(-0.0812978 0.00731076 0)
(-0.0825224 0.00450799 0)
(-0.0831655 0.0016378 0)
(-0.0832172 -0.00126347 0)
(-0.082675 -0.00415868 0)
(-0.0815432 -0.00700992 0)
(-0.0798335 -0.00977861 0)
(-0.0775651 -0.0124257 0)
(-0.0747645 -0.0149119 0)
(-0.0714659 -0.017198 0)
(-0.0677109 -0.0192454 0)
(-0.0635483 -0.0210165 0)
(-0.0590342 -0.0224754 0)
(-0.0542314 -0.023589 0)
(-0.0492087 -0.0243274 0)
(-0.0440405 -0.0246652 0)
(-0.0388057 -0.024583 0)
(-0.0335869 -0.024068 0)
(-0.0284685 -0.0231164 0)
(-0.0235359 -0.0217341 0)
(-0.0188735 -0.0199396 0)
(-0.014563 -0.0177655 0)
(-0.0106822 -0.015261 0)
(-0.00730356 -0.0124952 0)
(-0.00449098 -0.00955969 0)
(-0.00229604 -0.00657138 0)
(-0.000788852 -0.00367478 0)
(-0.000109564 -0.00105356 0)
(-0.000134528 0.00159631 0)
(-0.000944505 0.0051651 0)
(-0.00271406 0.00887845 0)
(-0.00525424 0.0125595 0)
(-0.00846499 0.0160707 0)
(-0.0122745 0.0193029 0)
(-0.0166019 0.0221729 0)
(-0.021362 0.0246206 0)
(-0.026468 0.0266055 0)
(-0.0318324 0.0281038 0)
(-0.0373675 0.0291053 0)
(-0.0429869 0.0296108 0)
(-0.048606 0.0296304 0)
(-0.0541434 0.029181 0)
(-0.0595217 0.0282856 0)
(-0.0646676 0.0269713 0)
(-0.069513 0.0252686 0)
(-0.0739953 0.0232109 0)
(-0.0780577 0.0208333 0)
(-0.0816494 0.0181729 0)
(-0.0847259 0.0152677 0)
(-0.0872494 0.0121573 0)
(-0.0891884 0.00888194 0)
(-0.0905185 0.00548318 0)
(-0.0912221 0.00200341 0)
(-0.0912888 -0.00151395 0)
(-0.0907154 -0.00502451 0)
(-0.0895061 -0.008483 0)
(-0.0876728 -0.0118433 0)
(-0.0852351 -0.0150587 0)
(-0.0822203 -0.0180823 0)
(-0.0786638 -0.0208671 0)
(-0.0746089 -0.0233669 0)
(-0.0701066 -0.0255365 0)
(-0.0652156 -0.0273331 0)
(-0.0600019 -0.0287166 0)
(-0.0545383 -0.029651 0)
(-0.0489036 -0.0301059 0)
(-0.0431819 -0.0300572 0)
(-0.0374617 -0.0294892 0)
(-0.0318341 -0.028396 0)
(-0.026392 -0.0267835 0)
(-0.0212281 -0.0246714 0)
(-0.0164335 -0.0220951 0)
(-0.0120964 -0.0191085 0)
(-0.00830096 -0.0157858 0)
(-0.00512382 -0.012225 0)
(-0.00262983 -0.00854895 0)
(-0.000907372 -0.00490677 0)
(-0.00012693 -0.00148394 0)
(-0.000151641 0.00210652 0)
(-0.00106094 0.00660331 0)
(-0.00304144 0.011157 0)
(-0.00587408 0.0155924 0)
(-0.00944037 0.0197714 0)
(-0.0136551 0.0235836 0)
(-0.0184246 0.026944 0)
(-0.0236522 0.029791 0)
(-0.0292409 0.0320836 0)
(-0.0350945 0.033798 0)
(-0.0411177 0.0349249 0)
(-0.0472175 0.0354675 0)
(-0.0533037 0.0354384 0)
(-0.0592899 0.0348587 0)
(-0.0650943 0.0337554 0)
(-0.0706402 0.0321609 0)
(-0.0758561 0.0301111 0)
(-0.0806767 0.0276451 0)
(-0.0850429 0.0248044 0)
(-0.0889019 0.0216321 0)
(-0.0922075 0.018173 0)
(-0.0949201 0.0144732 0)
(-0.0970073 0.01058 0)
(-0.0984434 0.00654184 0)
(-0.0992099 0.00240821 0)
(-0.0992957 -0.00177013 0)
(-0.098697 -0.00594135 0)
(-0.0974177 -0.0100525 0)
(-0.0954695 -0.0140497 0)
(-0.0928721 -0.0178783 0)
(-0.0896534 -0.0214833 0)
(-0.0858494 -0.0248096 0)
(-0.0815046 -0.0278028 0)
(-0.0766718 -0.03041 0)
(-0.071412 -0.0325804 0)
(-0.0657939 -0.0342666 0)
(-0.0598939 -0.035426 0)
(-0.0537951 -0.0360218 0)
(-0.0475869 -0.0360251 0)
(-0.0413635 -0.0354162 0)
(-0.0352232 -0.0341864 0)
(-0.0292665 -0.0323404 0)
(-0.0235954 -0.0298983 0)
(-0.0183108 -0.0268972 0)
(-0.0135123 -0.0233942 0)
(-0.00929622 -0.0194681 0)
(-0.00575258 -0.0152215 0)
(-0.00295962 -0.0107825 0)
(-0.00102352 -0.00630407 0)
(-0.000143648 -0.00197385 0)
(-0.000168301 0.00267538 0)
(-0.00117532 0.00820358 0)
(-0.00336456 0.0136856 0)
(-0.0064879 0.0189476 0)
(-0.010409 0.023852 0)
(-0.0150291 0.0282879 0)
(-0.0202419 0.0321701 0)
(-0.0259384 0.035437 0)
(-0.0320114 0.038048 0)
(-0.0383553 0.0399808 0)
(-0.0448672 0.0412285 0)
(-0.0514469 0.041797 0)
(-0.0579987 0.041703 0)
(-0.0644312 0.0409719 0)
(-0.0706585 0.0396361 0)
(-0.0766003 0.0377332 0)
(-0.0821824 0.0353054 0)
(-0.087337 0.0323979 0)
(-0.092003 0.0290587 0)
(-0.0961258 0.0253376 0)
(-0.0996578 0.0212861 0)
(-0.102558 0.0169573 0)
(-0.104794 0.0124054 0)
(-0.106337 0.00768593 0)
(-0.10717 0.00285583 0)
(-0.107279 -0.0020268 0)
(-0.106662 -0.00690248 0)
(-0.10532 -0.0117105 0)
(-0.103265 -0.0163889 0)
(-0.100517 -0.0208749 0)
(-0.097104 -0.0251051 0)
(-0.0930618 -0.029016 0)
(-0.0884359 -0.0325446 0)
(-0.0832803 -0.0356293 0)
(-0.0776578 -0.0382113 0)
(-0.0716398 -0.0402349 0)
(-0.0653057 -0.0416501 0)
(-0.0587431 -0.0424131 0)
(-0.0520461 -0.0424891 0)
(-0.0453154 -0.0418532 0)
(-0.0386562 -0.0404932 0)
(-0.0321778 -0.0384115 0)
(-0.0259912 -0.0356272 0)
(-0.0202086 -0.0321783 0)
(-0.014941 -0.0281239 0)
(-0.0102982 -0.0235459 0)
(-0.0063837 -0.0185512 0)
(-0.00328941 -0.0132721 0)
(-0.00113906 -0.00786572 0)
(-0.000160098 -0.00252238 0)
(-0.000184783 0.00330214 0)
(-0.00128902 0.00996457 0)
(-0.0036865 0.0164631 0)
(-0.00710067 0.0226249 0)
(-0.0113775 0.0283131 0)
(-0.016405 0.0334174 0)
(-0.0220634 0.0378533 0)
(-0.0282317 0.0415606 0)
(-0.0347917 0.0445007 0)
(-0.0416284 0.046654 0)
(-0.0486304 0.0480167 0)
(-0.0556908 0.0485992 0)
(-0.0627079 0.0484229 0)
(-0.0695854 0.0475187 0)
(-0.0762334 0.0459247 0)
(-0.0825683 0.043685 0)
(-0.0885134 0.040848 0)
(-0.0939986 0.0374659 0)
(-0.0989611 0.0335932 0)
(-0.103345 0.029287 0)
(-0.107102 0.0246057 0)
(-0.11019 0.0196092 0)
(-0.112574 0.0143592 0)
(-0.114227 0.0089182 0)
(-0.11513 0.00335051 0)
(-0.115268 -0.00227825 0)
(-0.114638 -0.00790094 0)
(-0.113242 -0.0134489 0)
(-0.111089 -0.0188522 0)
(-0.1082 -0.0240395 0)
(-0.104602 -0.0289388 0)
(-0.100331 -0.0334778 0)
(-0.0954322 -0.0375844 0)
(-0.089961 -0.0411882 0)
(-0.0839815 -0.0442211 0)
(-0.0775671 -0.0466189 0)
(-0.0708005 -0.0483229 0)
(-0.0637729 -0.0492817 0)
(-0.0565838 -0.0494531 0)
(-0.04934 -0.0488063 0)
(-0.0421543 -0.0473243 0)
(-0.0351448 -0.0450057 0)
(-0.0284327 -0.0418676 0)
(-0.0221414 -0.0379476 0)
(-0.0163949 -0.0333055 0)
(-0.0113165 -0.0280259 0)
(-0.00702403 -0.0222189 0)
(-0.00362333 -0.0160207 0)
(-0.00125573 -0.0095928 0)
(-0.00017662 -0.00312963 0)
(-0.000201328 0.00398676 0)
(-0.00140325 0.0118865 0)
(-0.00401019 0.0194903 0)
(-0.00771724 0.0266258 0)
(-0.0123527 0.0331569 0)
(-0.017791 0.0389748 0)
(-0.023899 0.0439968 0)
(-0.030543 0.0481653 0)
(-0.0375936 0.0514448 0)
(-0.044926 0.0538197 0)
(-0.0524203 0.0552911 0)
(-0.0599625 0.0558747 0)
(-0.0674448 0.0555978 0)
(-0.0747662 0.0544976 0)
(-0.0818328 0.0526191 0)
(-0.088558 0.0500133 0)
(-0.0948627 0.0467358 0)
(-0.100675 0.0428459 0)
(-0.105931 0.0384054 0)
(-0.110574 0.0334785 0)
(-0.114554 0.0281308 0)
(-0.117828 0.0224295 0)
(-0.120362 0.0164432 0)
(-0.122128 0.0102419 0)
(-0.123104 0.00389701 0)
(-0.123278 -0.00251829 0)
(-0.122642 -0.00892925 0)
(-0.1212 -0.0152593 0)
(-0.118959 -0.0214303 0)
(-0.115939 -0.0273624 0)
(-0.112166 -0.0329747 0)
(-0.107676 -0.0381858 0)
(-0.102514 -0.0429144 0)
(-0.0967349 -0.0470801 0)
(-0.0904046 -0.0506053 0)
(-0.083598 -0.0534161 0)
(-0.0764004 -0.0554445 0)
(-0.0689068 -0.05663 0)
(-0.0612219 -0.0569222 0)
(-0.0534586 -0.0562829 0)
(-0.0457377 -0.0546887 0)
(-0.0381864 -0.0521335 0)
(-0.0309368 -0.0486307 0)
(-0.0241244 -0.0442163 0)
(-0.0178865 -0.0389499 0)
(-0.0123609 -0.0329174 0)
(-0.00768048 -0.0262319 0)
(-0.00396546 -0.0190335 0)
(-0.00137519 -0.0114884 0)
(-0.000193521 -0.00379656 0)
(-0.000218137 0.00472981 0)
(-0.00151911 0.0139708 0)
(-0.00433834 0.0227696 0)
(-0.00834213 0.0309535 0)
(-0.0133408 0.0383876 0)
(-0.019195 0.0449648 0)
(-0.0257577 0.0506053 0)
(-0.0328823 0.0552553 0)
(-0.0404277 0.0588839 0)
(-0.048259 0.0614808 0)
(-0.0562477 0.0630534 0)
(-0.0642723 0.0636238 0)
(-0.0722191 0.0632267 0)
(-0.0799824 0.0619068 0)
(-0.0874645 0.0597166 0)
(-0.0945761 0.056715 0)
(-0.101236 0.0529653 0)
(-0.107371 0.0485345 0)
(-0.112917 0.0434921 0)
(-0.117815 0.0379097 0)
(-0.122015 0.0318602 0)
(-0.125476 0.0254181 0)
(-0.12816 0.0186591 0)
(-0.13004 0.0116603 0)
(-0.131095 0.00450038 0)
(-0.131309 -0.00274024 0)
(-0.130676 -0.00997923 0)
(-0.129196 -0.0171322 0)
(-0.126878 -0.0241128 0)
(-0.123739 -0.0308328 0)
(-0.119803 -0.0372021 0)
(-0.115105 -0.04313 0)
(-0.109691 -0.0485252 0)
(-0.103614 -0.0532973 0)
(-0.0969411 -0.0573581 0)
(-0.089748 -0.0606233 0)
(-0.0821223 -0.0630143 0)
(-0.0741629 -0.0644604 0)
(-0.0659789 -0.0649016 0)
(-0.05769 -0.0642908 0)
(-0.0494248 -0.0625968 0)
(-0.0413204 -0.0598068 0)
(-0.03352 -0.0559298 0)
(-0.026172 -0.0509981 0)
(-0.0194279 -0.0450703 0)
(-0.0134409 -0.0382327 0)
(-0.00835972 -0.0306006 0)
(-0.00431968 -0.0223184 0)
(-0.001499 -0.0135576 0)
(-0.000211082 -0.004525 0)
(-0.000235387 0.00553242 0)
(-0.0016376 0.0162205 0)
(-0.00467338 0.0263052 0)
(-0.00897945 0.0356132 0)
(-0.0143476 0.0440106 0)
(-0.0206242 0.0513929 0)
(-0.0276478 0.0576842 0)
(-0.0352584 0.0628354 0)
(-0.043303 0.0668217 0)
(-0.0516361 0.0696398 0)
(-0.0601203 0.0713045 0)
(-0.0686268 0.0718462 0)
(-0.0770359 0.0713079 0)
(-0.0852373 0.0697431 0)
(-0.09313 0.067213 0)
(-0.100622 0.0637851 0)
(-0.107631 0.0595312 0)
(-0.114083 0.0545266 0)
(-0.119911 0.0488489 0)
(-0.125059 0.0425771 0)
(-0.129476 0.0357918 0)
(-0.13312 0.0285745 0)
(-0.135955 0.0210081 0)
(-0.137951 0.0131767 0)
(-0.139088 0.00516583 0)
(-0.139349 -0.00293689 0)
(-0.138727 -0.0110419 0)
(-0.137221 -0.0190571 0)
(-0.134838 -0.0268881 0)
(-0.131592 -0.0344381 0)
(-0.127507 -0.0416082 0)
(-0.122616 -0.0482977 0)
(-0.116963 -0.0544053 0)
(-0.110602 -0.0598297 0)
(-0.103597 -0.0644716 0)
(-0.0960253 -0.0682351 0)
(-0.0879771 -0.0710298 0)
(-0.0795539 -0.0727737 0)
(-0.0708695 -0.0733954 0)
(-0.06205 -0.0728373 0)
(-0.0532321 -0.0710586 0)
(-0.0445629 -0.0680386 0)
(-0.0361975 -0.0637794 0)
(-0.028298 -0.0583086 0)
(-0.0210309 -0.0516824 0)
(-0.0145657 -0.0439865 0)
(-0.00906816 -0.0353383 0)
(-0.00468971 -0.025886 0)
(-0.00162861 -0.0158074 0)
(-0.000229556 -0.00531758 0)
(-0.00025323 0.00639618 0)
(-0.00175957 0.0186395 0)
(-0.0050175 0.0301027 0)
(-0.00963292 0.0406115 0)
(-0.0153783 0.0500332 0)
(-0.0220848 0.0582663 0)
(-0.0295763 0.0652396 0)
(-0.0376786 0.0709105 0)
(-0.0462263 0.0752617 0)
(-0.0550632 0.0782983 0)
(-0.0640427 0.0800442 0)
(-0.0730286 0.0805396 0)
(-0.0818954 0.0798374 0)
(-0.0905285 0.078001 0)
(-0.0988238 0.0751015 0)
(-0.106687 0.0712161 0)
(-0.114036 0.0664258 0)
(-0.120794 0.0608148 0)
(-0.126897 0.0544688 0)
(-0.132287 0.047475 0)
(-0.136914 0.0399213 0)
(-0.140737 0.0318966 0)
(-0.14372 0.0234904 0)
(-0.145833 0.0147936 0)
(-0.147056 0.00589853 0)
(-0.147371 -0.00310059 0)
(-0.146769 -0.0121071 0)
(-0.145249 -0.0210218 0)
(-0.142814 -0.0297424 0)
(-0.139477 -0.0381636 0)
(-0.13526 -0.0461775 0)
(-0.130194 -0.0536736 0)
(-0.12432 -0.0605399 0)
(-0.11769 -0.0666641 0)
(-0.110367 -0.0719346 0)
(-0.10243 -0.0762429 0)
(-0.0939686 -0.0794859 0)
(-0.085087 -0.0815683 0)
(-0.0759036 -0.0824058 0)
(-0.0665505 -0.0819285 0)
(-0.0571728 -0.0800842 0)
(-0.0479278 -0.0768418 0)
(-0.0389831 -0.072195 0)
(-0.030515 -0.0661651 0)
(-0.0227062 -0.0588041 0)
(-0.0157439 -0.0501964 0)
(-0.00981184 -0.0404606 0)
(-0.00507906 -0.0297492 0)
(-0.00176541 -0.0182465 0)
(-0.000249183 -0.00617766 0)
(-0.000271802 0.00732313 0)
(-0.00188583 0.0212328 0)
(-0.00537269 0.0341692 0)
(-0.0103059 0.0459566 0)
(-0.0164374 0.0564635 0)
(-0.0235825 0.0655924 0)
(-0.0315492 0.0732781 0)
(-0.0401487 0.0794855 0)
(-0.0492026 0.0842065 0)
(-0.0585437 0.0874563 0)
(-0.068016 0.08927 0)
(-0.077476 0.0896991 0)
(-0.0867927 0.088808 0)
(-0.0958472 0.0866715 0)
(-0.104533 0.0833719 0)
(-0.112755 0.0789969 0)
(-0.120428 0.0736377 0)
(-0.12748 0.0673878 0)
(-0.133844 0.0603417 0)
(-0.139464 0.0525947 0)
(-0.144292 0.0442423 0)
(-0.148287 0.0353802 0)
(-0.151414 0.0261046 0)
(-0.153644 0.0165128 0)
(-0.154955 0.00670333 0)
(-0.15533 -0.00322333 0)
(-0.154758 -0.0131641 0)
(-0.153236 -0.0230126 0)
(-0.150766 -0.0326595 0)
(-0.147358 -0.0419912 0)
(-0.14303 -0.0508908 0)
(-0.13781 -0.0592381 0)
(-0.131737 -0.0669101 0)
(-0.124859 -0.0737826 0)
(-0.117239 -0.0797312 0)
(-0.108953 -0.084634 0)
(-0.100092 -0.0883732 0)
(-0.0907624 -0.0908389 0)
(-0.0810853 -0.0919321 0)
(-0.071199 -0.0915684 0)
(-0.0612568 -0.0896818 0)
(-0.0514264 -0.0862288 0)
(-0.0418883 -0.0811925 0)
(-0.0328342 -0.0745859 0)
(-0.0244639 -0.0664551 0)
(-0.0169835 -0.056882 0)
(-0.0105965 -0.0459858 0)
(-0.00549105 -0.033923 0)
(-0.0019107 -0.0208854 0)
(-0.000270187 -0.00710929 0)
(-0.00029123 0.00831569 0)
(-0.00201709 0.0240063 0)
(-0.00574078 0.0385129 0)
(-0.0110014 0.0516576 0)
(-0.017529 0.0633109 0)
(-0.0251219 0.0733797 0)
(-0.0335712 0.081806 0)
(-0.0426728 0.0885641 0)
(-0.0522346 0.0936569 0)
(-0.0620779 0.0971117 0)
(-0.0720375 0.0989766 0)
(-0.0819626 0.0993163 0)
(-0.0917167 0.0982087 0)
(-0.101178 0.0957413 0)
(-0.110237 0.0920092 0)
(-0.118798 0.0871116 0)
(-0.126778 0.0811507 0)
(-0.134103 0.07423 0)
(-0.14071 0.0664532 0)
(-0.146544 0.0579237 0)
(-0.15156 0.0487445 0)
(-0.155716 0.0390182 0)
(-0.15898 0.0288472 0)
(-0.161323 0.0183346 0)
(-0.162724 0.00758448 0)
(-0.163165 -0.00329686 0)
(-0.162634 -0.0142005 0)
(-0.161126 -0.0250139 0)
(-0.158639 -0.0356206 0)
(-0.155181 -0.0458995 0)
(-0.150767 -0.055725 0)
(-0.14542 -0.0649669 0)
(-0.139175 -0.0734914 0)
(-0.132077 -0.0811618 0)
(-0.124186 -0.0878402 0)
(-0.115575 -0.0933897 0)
(-0.106335 -0.097677 0)
(-0.0965728 -0.100576 0)
(-0.0864126 -0.101969 0)
(-0.075998 -0.101757 0)
(-0.06549 -0.0998573 0)
(-0.055067 -0.0962107 0)
(-0.044923 -0.0907875 0)
(-0.0352655 -0.08359 0)
(-0.026313 -0.0746566 0)
(-0.018292 -0.0640651 0)
(-0.0114275 -0.0519344 0)
(-0.00592888 -0.0384248 0)
(-0.00206576 -0.023736 0)
(-0.00029279 -0.00811721 0)
(-0.000311633 0.00937665 0)
(-0.00215406 0.0269668 0)
(-0.00612351 0.043143 0)
(-0.0117223 0.0577249 0)
(-0.0186569 0.0705852 0)
(-0.0267072 0.0816364 0)
(-0.0356463 0.0908292 0)
(-0.0452535 0.098149 0)
(-0.0553228 0.103612 0)
(-0.0656634 0.107259 0)
(-0.0761007 0.109155 0)
(-0.0864768 0.109378 0)
(-0.0966506 0.108023 0)
(-0.106497 0.105192 0)
(-0.115905 0.100992 0)
(-0.124781 0.0955381 0)
(-0.133041 0.0889426 0)
(-0.140614 0.0813199 0)
(-0.14744 0.0727832 0)
(-0.153467 0.0634444 0)
(-0.15865 0.0534138 0)
(-0.162953 0.0428002 0)
(-0.166343 0.0317119 0)
(-0.168794 0.0202573 0)
(-0.170285 0.0085453 0)
(-0.170798 -0.00331287 0)
(-0.170319 -0.0152032 0)
(-0.16884 -0.0270077 0)
(-0.166358 -0.0386038 0)
(-0.162877 -0.0498631 0)
(-0.158406 -0.0606518 0)
(-0.152964 -0.0708302 0)
(-0.146581 -0.0802533 0)
(-0.139298 -0.0887716 0)
(-0.131169 -0.096233 0)
(-0.122265 -0.102485 0)
(-0.112674 -0.107376 0)
(-0.102502 -0.110762 0)
(-0.0918762 -0.112507 0)
(-0.0809439 -0.112491 0)
(-0.0698738 -0.110613 0)
(-0.0588546 -0.106796 0)
(-0.0480943 -0.100994 0)
(-0.0378172 -0.0931964 0)
(-0.0282616 -0.0834307 0)
(-0.0196763 -0.071769 0)
(-0.01231 -0.0583287 0)
(-0.00639564 -0.0432738 0)
(-0.00223182 -0.026812 0)
(-0.000317209 -0.00920678 0)
(-0.000333138 0.0105092 0)
(-0.00229746 0.0301221 0)
(-0.00652267 0.04807 0)
(-0.0124715 0.0641699 0)
(-0.0198248 0.078297 0)
(-0.0283421 0.0903709 0)
(-0.0377774 0.100353 0)
(-0.0478922 0.108241 0)
(-0.0584655 0.114067 0)
(-0.0692944 0.11789 0)
(-0.0801949 0.11979 0)
(-0.0910022 0.119866 0)
(-0.101571 0.118229 0)
(-0.111774 0.114996 0)
(-0.1215 0.110294 0)
(-0.130657 0.104247 0)
(-0.139163 0.0969839 0)
(-0.146951 0.088629 0)
(-0.153964 0.0793055 0)
(-0.160154 0.0691335 0)
(-0.16548 0.0582303 0)
(-0.169909 0.0467111 0)
(-0.173411 0.034689 0)
(-0.175961 0.0222769 0)
(-0.17754 0.00958777 0)
(-0.178128 -0.00326324 0)
(-0.177712 -0.016158 0)
(-0.176281 -0.0289742 0)
(-0.173829 -0.0415836 0)
(-0.170354 -0.0538519 0)
(-0.165861 -0.0656375 0)
(-0.160363 -0.0767914 0)
(-0.153884 -0.0871576 0)
(-0.146459 -0.0965739 0)
(-0.138135 -0.104873 0)
(-0.128978 -0.111885 0)
(-0.119073 -0.11744 0)
(-0.108524 -0.121374 0)
(-0.0974585 -0.123528 0)
(-0.0860269 -0.12376 0)
(-0.0744045 -0.121947 0)
(-0.0627907 -0.117991 0)
(-0.0514071 -0.111825 0)
(-0.040496 -0.103423 0)
(-0.0303169 -0.0927998 0)
(-0.0211429 -0.0800183 0)
(-0.013249 -0.0651933 0)
(-0.0068944 -0.0484912 0)
(-0.00241014 -0.0301286 0)
(-0.00034367 -0.010384 0)
(-0.000355882 0.0117168 0)
(-0.00244808 0.0334808 0)
(-0.00694014 0.0533052 0)
(-0.013252 0.0710045 0)
(-0.0210362 0.0864572 0)
(-0.0300303 0.099591 0)
(-0.0399669 0.11038 0)
(-0.0505889 0.118837 0)
(-0.0616593 0.125014 0)
(-0.0729625 0.128989 0)
(-0.0843051 0.130863 0)
(-0.0955163 0.130754 0)
(-0.106447 0.128794 0)
(-0.116969 0.125121 0)
(-0.126973 0.119876 0)
(-0.136368 0.113201 0)
(-0.145077 0.105237 0)
(-0.153037 0.0961208 0)
(-0.160197 0.0859858 0)
(-0.166513 0.0749603 0)
(-0.17195 0.0631684 0)
(-0.176478 0.0507306 0)
(-0.180071 0.0377645 0)
(-0.182708 0.0243862 0)
(-0.184369 0.0107121 0)
(-0.185036 -0.00314033 0)
(-0.184695 -0.0170499 0)
(-0.183331 -0.0308909 0)
(-0.180935 -0.0445312 0)
(-0.177501 -0.057831 0)
(-0.173027 -0.0706419 0)
(-0.16752 -0.0828065 0)
(-0.160995 -0.0941581 0)
(-0.153479 -0.104521 0)
(-0.145013 -0.113713 0)
(-0.135656 -0.121546 0)
(-0.125485 -0.12783 0)
(-0.114602 -0.132377 0)
(-0.103133 -0.135005 0)
(-0.0912294 -0.135546 0)
(-0.079073 -0.13385 0)
(-0.0668722 -0.129794 0)
(-0.0548633 -0.12329 0)
(-0.0433068 -0.114287 0)
(-0.0324851 -0.102786 0)
(-0.0226981 -0.0888386 0)
(-0.0142495 -0.0725538 0)
(-0.00742828 -0.0541 0)
(-0.00260202 -0.0337023 0)
(-0.000372413 -0.0116557 0)
(-0.000380025 0.0130035 0)
(-0.00260681 0.0370523 0)
(-0.00737811 0.0588613 0)
(-0.0140672 0.0782419 0)
(-0.0222953 0.0950769 0)
(-0.0317755 0.109304 0)
(-0.0422172 0.120911 0)
(-0.0533427 0.129933 0)
(-0.0648984 0.136441 0)
(-0.0766557 0.140536 0)
(-0.0884122 0.142344 0)
(-0.0999911 0.142008 0)
(-0.111241 0.139681 0)
(-0.122034 0.135522 0)
(-0.132264 0.129692 0)
(-0.141843 0.122351 0)
(-0.1507 0.113653 0)
(-0.15878 0.103749 0)
(-0.166036 0.0927809 0)
(-0.172432 0.0808862 0)
(-0.177939 0.0681949 0)
(-0.182532 0.0548323 0)
(-0.186191 0.0409194 0)
(-0.188897 0.0265747 0)
(-0.190632 0.011916 0)
(-0.191379 -0.00293735 0)
(-0.191123 -0.0178631 0)
(-0.189848 -0.0327335 0)
(-0.187539 -0.0474136 0)
(-0.184185 -0.0617599 0)
(-0.179777 -0.0756182 0)
(-0.174314 -0.0888234 0)
(-0.167803 -0.101199 0)
(-0.16026 -0.112556 0)
(-0.151717 -0.122696 0)
(-0.142223 -0.131413 0)
(-0.131848 -0.138494 0)
(-0.120687 -0.143726 0)
(-0.108862 -0.146901 0)
(-0.0965258 -0.147821 0)
(-0.0838632 -0.146305 0)
(-0.0710919 -0.142201 0)
(-0.0584618 -0.135392 0)
(-0.0462529 -0.125802 0)
(-0.0347718 -0.113411 0)
(-0.0243476 -0.098256 0)
(-0.0153164 -0.0804378 0)
(-0.00800052 -0.060125 0)
(-0.00280885 -0.0375512 0)
(-0.000403698 -0.013029 0)
(-0.000405764 0.0143737 0)
(-0.00277474 0.0408475 0)
(-0.00783919 0.0647523 0)
(-0.014921 0.0858962 0)
(-0.0236068 0.104167 0)
(-0.0335819 0.119515 0)
(-0.0445302 0.131947 0)
(-0.0561519 0.141519 0)
(-0.0681755 0.148327 0)
(-0.0803592 0.152503 0)
(-0.0924918 0.154198 0)
(-0.104392 0.153583 0)
(-0.115907 0.150837 0)
(-0.12691 0.146144 0)
(-0.137301 0.139684 0)
(-0.146998 0.131637 0)
(-0.155937 0.122174 0)
(-0.16407 0.111456 0)
(-0.171361 0.0996375 0)
(-0.17778 0.086863 0)
(-0.183307 0.0732684 0)
(-0.187923 0.0589827 0)
(-0.191615 0.044129 0)
(-0.194366 0.028827 0)
(-0.196163 0.0131947 0)
(-0.19699 -0.00264878 0)
(-0.196829 -0.0185814 0)
(-0.195664 -0.0344752 0)
(-0.193475 -0.0501943 0)
(-0.190245 -0.0655926 0)
(-0.185958 -0.0805119 0)
(-0.180602 -0.0947806 0)
(-0.174174 -0.108213 0)
(-0.166679 -0.120607 0)
(-0.158136 -0.13175 0)
(-0.148584 -0.141415 0)
(-0.138081 -0.149366 0)
(-0.126713 -0.155363 0)
(-0.114596 -0.159166 0)
(-0.10188 -0.160545 0)
(-0.0887523 -0.159284 0)
(-0.0754372 -0.155197 0)
(-0.0621984 -0.14813 0)
(-0.0493356 -0.137978 0)
(-0.0371817 -0.124695 0)
(-0.0260974 -0.108296 0)
(-0.0164549 -0.0888737 0)
(-0.00861461 -0.066593 0)
(-0.00303215 -0.0416953 0)
(-0.00043782 -0.0145123 0)
(-0.00043335 0.0158326 0)
(-0.00295327 0.0448784 0)
(-0.00832664 0.0709936 0)
(-0.0158186 0.0939825 0)
(-0.0249764 0.11374 0)
(-0.0354547 0.13023 0)
(-0.0469086 0.143482 0)
(-0.0590142 0.153579 0)
(-0.0714813 0.160648 0)
(-0.0840546 0.164852 0)
(-0.0965146 0.166377 0)
(-0.108676 0.165423 0)
(-0.120388 0.162199 0)
(-0.131528 0.156916 0)
(-0.142001 0.149779 0)
(-0.151733 0.140986 0)
(-0.160673 0.130725 0)
(-0.168781 0.119172 0)
(-0.176031 0.10649 0)
(-0.182406 0.0928321 0)
(-0.187892 0.0783381 0)
(-0.19248 0.0631399 0)
(-0.196163 0.0473618 0)
(-0.198931 0.0311229 0)
(-0.200773 0.0145397 0)
(-0.201675 -0.00227085 0)
(-0.201619 -0.0191886 0)
(-0.200587 -0.0360875 0)
(-0.198554 -0.0528325 0)
(-0.195497 -0.0692772 0)
(-0.191391 -0.0852608 0)
(-0.186214 -0.100607 0)
(-0.179949 -0.115122 0)
(-0.17259 -0.128593 0)
(-0.164141 -0.140791 0)
(-0.154625 -0.151468 0)
(-0.144087 -0.160365 0)
(-0.132601 -0.167211 0)
(-0.120272 -0.171734 0)
(-0.107246 -0.173665 0)
(-0.0937084 -0.172749 0)
(-0.0798893 -0.168756 0)
(-0.0660646 -0.161494 0)
(-0.0525543 -0.15082 0)
(-0.0397186 -0.136653 0)
(-0.0279532 -0.118985 0)
(-0.0176706 -0.0978913 0)
(-0.00927446 -0.0735322 0)
(-0.00327366 -0.0461562 0)
(-0.000475119 -0.0161146 0)
(-0.000463105 0.0173861 0)
(-0.00314417 0.0491591 0)
(-0.00884467 0.0776028 0)
(-0.0167663 0.102517 0)
(-0.0264117 0.123805 0)
(-0.0374004 0.14145 0)
(-0.0493556 0.155507 0)
(-0.0619271 0.166091 0)
(-0.0748046 0.173368 0)
(-0.0877196 0.177536 0)
(-0.100445 0.17882 0)
(-0.112795 0.177456 0)
(-0.12462 0.173689 0)
(-0.135805 0.167756 0)
(-0.146263 0.159889 0)
(-0.155934 0.150309 0)
(-0.164777 0.139221 0)
(-0.172765 0.126814 0)
(-0.179887 0.113262 0)
(-0.186135 0.0987231 0)
(-0.191508 0.0833428 0)
(-0.196007 0.0672536 0)
(-0.199632 0.0505792 0)
(-0.20238 0.0334363 0)
(-0.204244 0.0159383 0)
(-0.205214 -0.00180206 0)
(-0.205271 -0.0196689 0)
(-0.204395 -0.0375402 0)
(-0.202557 -0.0552842 0)
(-0.199726 -0.072756 0)
(-0.195868 -0.0897949 0)
(-0.190951 -0.106222 0)
(-0.184943 -0.121836 0)
(-0.177821 -0.136415 0)
(-0.169574 -0.149715 0)
(-0.160206 -0.161469 0)
(-0.149746 -0.17139 0)
(-0.13825 -0.179177 0)
(-0.125811 -0.184521 0)
(-0.112564 -0.187109 0)
(-0.0986901 -0.186642 0)
(-0.0844226 -0.182841 0)
(-0.070048 -0.175465 0)
(-0.055906 -0.164326 0)
(-0.0423858 -0.1493 0)
(-0.0299211 -0.130347 0)
(-0.0189698 -0.107521 0)
(-0.00998451 -0.0809733 0)
(-0.0035354 -0.0509575 0)
(-0.000516002 -0.0178457 0)
(-0.000495457 0.0190411 0)
(-0.00334974 0.0537059 0)
(-0.00939873 0.0846001 0)
(-0.0177723 0.111519 0)
(-0.0279222 0.134376 0)
(-0.0394275 0.153177 0)
(-0.0518757 0.168009 0)
(-0.0648876 0.179028 0)
(-0.078132 0.186441 0)
(-0.0913275 0.190493 0)
(-0.104241 0.191452 0)
(-0.116688 0.189597 0)
(-0.128523 0.185208 0)
(-0.139642 0.178559 0)
(-0.149971 0.169908 0)
(-0.159464 0.159499 0)
(-0.168095 0.147556 0)
(-0.175854 0.134282 0)
(-0.182742 0.119859 0)
(-0.188769 0.104453 0)
(-0.193945 0.0882101 0)
(-0.198282 0.0712635 0)
(-0.201791 0.0537342 0)
(-0.204475 0.0357349 0)
(-0.206334 0.0173734 0)
(-0.207359 -0.0012438 0)
(-0.207535 -0.0200075 0)
(-0.206837 -0.0388021 0)
(-0.205234 -0.0575016 0)
(-0.202687 -0.0759656 0)
(-0.199152 -0.0940357 0)
(-0.194584 -0.111532 0)
(-0.188937 -0.128251 0)
(-0.182169 -0.143962 0)
(-0.17425 -0.158405 0)
(-0.165162 -0.171296 0)
(-0.154914 -0.182321 0)
(-0.14354 -0.191146 0)
(-0.131115 -0.19742 0)
(-0.117758 -0.200786 0)
(-0.103644 -0.200891 0)
(-0.0890031 -0.197399 0)
(-0.0741308 -0.190012 0)
(-0.0593852 -0.178484 0)
(-0.0451858 -0.162642 0)
(-0.0320079 -0.142405 0)
(-0.0203596 -0.117794 0)
(-0.01075 -0.0889489 0)
(-0.00381982 -0.0561251 0)
(-0.000560962 -0.0197169 0)
(-0.000530968 0.020806 0)
(-0.00357305 0.058538 0)
(-0.0099959 0.092009 0)
(-0.0188474 0.121009 0)
(-0.0295203 0.145463 0)
(-0.0415469 0.165407 0)
(-0.0544745 0.180968 0)
(-0.0678922 0.192348 0)
(-0.0814471 0.199808 0)
(-0.0948456 0.203645 0)
(-0.107852 0.204179 0)
(-0.120283 0.201738 0)
(-0.132005 0.196642 0)
(-0.142926 0.189203 0)
(-0.15299 0.17971 0)
(-0.162167 0.168432 0)
(-0.170452 0.15561 0)
(-0.177852 0.14146 0)
(-0.184388 0.126176 0)
(-0.190083 0.109925 0)
(-0.194964 0.0928557 0)
(-0.199056 0.0750989 0)
(-0.20238 0.0567713 0)
(-0.204949 0.0379791 0)
(-0.206768 0.0188225 0)
(-0.207833 -0.000600882 0)
(-0.20813 -0.020191 0)
(-0.207632 -0.0398414 0)
(-0.206305 -0.0594345 0)
(-0.204103 -0.0788375 0)
(-0.200972 -0.0978972 0)
(-0.196852 -0.116437 0)
(-0.191682 -0.13425 0)
(-0.185399 -0.151102 0)
(-0.177951 -0.166722 0)
(-0.169297 -0.180805 0)
(-0.159417 -0.193013 0)
(-0.148322 -0.202976 0)
(-0.136062 -0.210302 0)
(-0.122736 -0.21458 0)
(-0.108502 -0.215398 0)
(-0.0935868 -0.212355 0)
(-0.0782889 -0.205085 0)
(-0.0629834 -0.193272 0)
(-0.0481208 -0.176682 0)
(-0.0342208 -0.155177 0)
(-0.0218484 -0.128742 0)
(-0.0115775 -0.0974943 0)
(-0.0041299 -0.061688 0)
(-0.000610613 -0.0217407 0)
(-0.000570392 0.0226909 0)
(-0.00381808 0.063679 0)
(-0.0106455 0.0998574 0)
(-0.0200055 0.131009 0)
(-0.0312218 0.157079 0)
(-0.0437725 0.178135 0)
(-0.0571591 0.194355 0)
(-0.0709364 0.206001 0)
(-0.0847294 0.213394 0)
(-0.0982339 0.216897 0)
(-0.111213 0.216888 0)
(-0.123493 0.213749 0)
(-0.134953 0.207851 0)
(-0.14552 0.199543 0)
(-0.155158 0.189149 0)
(-0.163861 0.176961 0)
(-0.171645 0.16324 0)
(-0.178539 0.148217 0)
(-0.184584 0.132089 0)
(-0.189823 0.115029 0)
(-0.194299 0.097183 0)
(-0.198052 0.0786788 0)
(-0.201113 0.059626 0)
(-0.203506 0.0401223 0)
(-0.205244 0.0202574 0)
(-0.206328 0.000117874 0)
(-0.206745 -0.0202082 0)
(-0.206468 -0.0406263 0)
(-0.205459 -0.0610307 0)
(-0.203666 -0.0812987 0)
(-0.201023 -0.101286 0)
(-0.197459 -0.120822 0)
(-0.192892 -0.139704 0)
(-0.187241 -0.157691 0)
(-0.180427 -0.174507 0)
(-0.17238 -0.189829 0)
(-0.163052 -0.203295 0)
(-0.152421 -0.214501 0)
(-0.140506 -0.223007 0)
(-0.127381 -0.228346 0)
(-0.11318 -0.23004 0)
(-0.098117 -0.227613 0)
(-0.0824902 -0.220616 0)
(-0.0666883 -0.208654 0)
(-0.0511917 -0.19141 0)
(-0.0365683 -0.168681 0)
(-0.0234465 -0.140398 0)
(-0.0124747 -0.106647 0)
(-0.0044694 -0.0676784 0)
(-0.000665736 -0.0239316 0)
(-0.000614732 0.0247085 0)
(-0.00409015 0.0691573 0)
(-0.0113596 0.108179 0)
(-0.0212647 0.141549 0)
(-0.033047 0.169234 0)
(-0.0461215 0.191349 0)
(-0.0599379 0.208132 0)
(-0.0740138 0.219918 0)
(-0.0879524 0.227105 0)
(-0.101442 0.230129 0)
(-0.114249 0.229438 0)
(-0.126214 0.225476 0)
(-0.137235 0.218668 0)
(-0.147263 0.209407 0)
(-0.15629 0.19805 0)
(-0.164335 0.184917 0)
(-0.17144 0.170287 0)
(-0.177662 0.154399 0)
(-0.183063 0.137459 0)
(-0.187706 0.119639 0)
(-0.191654 0.101083 0)
(-0.194961 0.0819116 0)
(-0.197672 0.0622251 0)
(-0.199822 0.0421102 0)
(-0.201432 0.021644 0)
(-0.202507 0.000899176 0)
(-0.203039 -0.0200509 0)
(-0.203001 -0.0411266 0)
(-0.202351 -0.0622369 0)
(-0.201031 -0.0832732 0)
(-0.198967 -0.104104 0)
(-0.196071 -0.124567 0)
(-0.192245 -0.144468 0)
(-0.187385 -0.163567 0)
(-0.181384 -0.181582 0)
(-0.174142 -0.198179 0)
(-0.165575 -0.212971 0)
(-0.155623 -0.225521 0)
(-0.14427 -0.235342 0)
(-0.13155 -0.241907 0)
(-0.117571 -0.244662 0)
(-0.102521 -0.243046 0)
(-0.086693 -0.236515 0)
(-0.0704823 -0.224573 0)
(-0.0543988 -0.206808 0)
(-0.0390605 -0.182928 0)
(-0.0251666 -0.152794 0)
(-0.0134517 -0.11645 0)
(-0.00484313 -0.0741329 0)
(-0.000727334 -0.026306 0)
(-0.000665338 0.0268744 0)
(-0.00439626 0.0750082 0)
(-0.0121542 0.117014 0)
(-0.022648 0.152658 0)
(-0.0350214 0.18194 0)
(-0.0486149 0.205031 0)
(-0.0628198 0.222248 0)
(-0.077114 0.234015 0)
(-0.0910805 0.240822 0)
(-0.104404 0.243193 0)
(-0.116862 0.241659 0)
(-0.128314 0.236733 0)
(-0.138687 0.228899 0)
(-0.147962 0.218596 0)
(-0.156162 0.206218 0)
(-0.163341 0.19211 0)
(-0.16957 0.176567 0)
(-0.174933 0.159838 0)
(-0.179519 0.142132 0)
(-0.183414 0.123619 0)
(-0.186698 0.104436 0)
(-0.189443 0.084696 0)
(-0.191709 0.0644868 0)
(-0.193541 0.0438816 0)
(-0.194969 0.0229423 0)
(-0.196004 0.00172491 0)
(-0.196642 -0.0197144 0)
(-0.196857 -0.0413139 0)
(-0.196605 -0.0630005 0)
(-0.195822 -0.0846831 0)
(-0.194427 -0.106246 0)
(-0.192317 -0.127543 0)
(-0.189377 -0.148389 0)
(-0.185479 -0.168552 0)
(-0.180488 -0.187749 0)
(-0.17427 -0.205637 0)
(-0.1667 -0.221813 0)
(-0.157678 -0.235805 0)
(-0.147137 -0.247079 0)
(-0.13507 -0.255046 0)
(-0.121541 -0.259069 0)
(-0.106708 -0.258492 0)
(-0.0908419 -0.252657 0)
(-0.0743414 -0.24095 0)
(-0.0577404 -0.222839 0)
(-0.0417089 -0.197919 0)
(-0.0270245 -0.165962 0)
(-0.0145213 -0.126949 0)
(-0.00525729 -0.0810935 0)
(-0.000796726 -0.0288836 0)
(-0.000724032 0.0292086 0)
(-0.00474569 0.081276 0)
(-0.01305 0.126412 0)
(-0.024185 0.164375 0)
(-0.0371766 0.195206 0)
(-0.0512774 0.219153 0)
(-0.0658128 0.236632 0)
(-0.0802196 0.248179 0)
(-0.0940642 0.254395 0)
(-0.107035 0.255909 0)
(-0.118928 0.253347 0)
(-0.129632 0.247299 0)
(-0.13911 0.238314 0)
(-0.147384 0.22688 0)
(-0.154514 0.213427 0)
(-0.160591 0.198323 0)
(-0.165723 0.181878 0)
(-0.170025 0.164347 0)
(-0.173611 0.145938 0)
(-0.176592 0.126817 0)
(-0.179068 0.107112 0)
(-0.181129 0.0869221 0)
(-0.182848 0.0663223 0)
(-0.184281 0.0453691 0)
(-0.185467 0.0241066 0)
(-0.186425 0.00257198 0)
(-0.187154 -0.0191984 0)
(-0.187632 -0.0411635 0)
(-0.187813 -0.0632711 0)
(-0.18763 -0.0854513 0)
(-0.186992 -0.107609 0)
(-0.185788 -0.129616 0)
(-0.183883 -0.151304 0)
(-0.181128 -0.172455 0)
(-0.177358 -0.19279 0)
(-0.172403 -0.211965 0)
(-0.166094 -0.229562 0)
(-0.158282 -0.245083 0)
(-0.148847 -0.257948 0)
(-0.137723 -0.267503 0)
(-0.124923 -0.273024 0)
(-0.110556 -0.273745 0)
(-0.0948637 -0.268882 0)
(-0.0782317 -0.257677 0)
(-0.0612124 -0.239448 0)
(-0.0445274 -0.21365 0)
(-0.0290402 -0.179934 0)
(-0.0157 -0.138194 0)
(-0.00572008 -0.0886094 0)
(-0.000875665 -0.0316875 0)
(-0.000793299 0.0317367 0)
(-0.00515085 0.0880165 0)
(-0.0140739 0.136434 0)
(-0.0259135 0.176742 0)
(-0.0395513 0.209038 0)
(-0.0541363 0.233673 0)
(-0.0689207 0.251191 0)
(-0.0833009 0.262266 0)
(-0.0968327 0.267636 0)
(-0.109218 0.268055 0)
(-0.120284 0.264254 0)
(-0.12996 0.256914 0)
(-0.138258 0.246648 0)
(-0.145245 0.233997 0)
(-0.151031 0.219424 0)
(-0.155749 0.203318 0)
(-0.159544 0.185998 0)
(-0.162564 0.167724 0)
(-0.164954 0.148697 0)
(-0.166848 0.129075 0)
(-0.168366 0.108973 0)
(-0.169614 0.0884743 0)
(-0.170679 0.0676375 0)
(-0.171629 0.0465002 0)
(-0.17251 0.0250864 0)
(-0.173351 0.00341249 0)
(-0.174153 -0.0185074 0)
(-0.174898 -0.0406553 0)
(-0.175541 -0.0630025 0)
(-0.176013 -0.0855036 0)
(-0.176219 -0.108088 0)
(-0.176036 -0.130651 0)
(-0.175317 -0.153047 0)
(-0.17389 -0.175075 0)
(-0.171561 -0.196473 0)
(-0.168124 -0.216899 0)
(-0.163365 -0.235932 0)
(-0.157077 -0.25305 0)
(-0.149081 -0.267636 0)
(-0.139243 -0.278968 0)
(-0.127504 -0.286236 0)
(-0.113914 -0.288551 0)
(-0.0986606 -0.284982 0)
(-0.0821053 -0.274604 0)
(-0.0648058 -0.256552 0)
(-0.0475316 -0.2301 0)
(-0.0312387 -0.194738 0)
(-0.0170093 -0.150245 0)
(-0.00624237 -0.0967387 0)
(-0.000966525 -0.0347461 0)
(-0.00087656 0.0344918 0)
(-0.00562837 0.0953006 0)
(-0.0152615 0.147155 0)
(-0.0278811 0.189807 0)
(-0.0421914 0.223435 0)
(-0.0572198 0.248528 0)
(-0.0721386 0.265798 0)
(-0.0863075 0.27609 0)
(-0.0992826 0.28031 0)
(-0.110794 0.279358 0)
(-0.120716 0.274086 0)
(-0.129035 0.265271 0)
(-0.135821 0.253596 0)
(-0.141202 0.239651 0)
(-0.145339 0.223928 0)
(-0.148415 0.206833 0)
(-0.150617 0.188691 0)
(-0.152127 0.169756 0)
(-0.153118 0.15022 0)
(-0.153748 0.130228 0)
(-0.154156 0.109877 0)
(-0.154463 0.0892341 0)
(-0.154768 0.068336 0)
(-0.155149 0.0471999 0)
(-0.155662 0.0258281 0)
(-0.15634 0.00421427 0)
(-0.157192 -0.0176513 0)
(-0.158202 -0.0397752 0)
(-0.15933 -0.0621552 0)
(-0.160505 -0.0847726 0)
(-0.161631 -0.107585 0)
(-0.162579 -0.130517 0)
(-0.16319 -0.15345 0)
(-0.163273 -0.176209 0)
(-0.16261 -0.198554 0)
(-0.160957 -0.220159 0)
(-0.158055 -0.240606 0)
(-0.153638 -0.259364 0)
(-0.147457 -0.275781 0)
(-0.139297 -0.289078 0)
(-0.129016 -0.298352 0)
(-0.116578 -0.302588 0)
(-0.1021 -0.300691 0)
(-0.0858934 -0.291534 0)
(-0.0685034 -0.274031 0)
(-0.0507386 -0.247227 0)
(-0.0336517 -0.210401 0)
(-0.0184778 -0.163166 0)
(-0.00683886 -0.105552 0)
(-0.00107258 -0.0380944 0)
(-0.000978604 0.0375174 0)
(-0.00620077 0.103219 0)
(-0.0166591 0.158668 0)
(-0.0301473 0.203623 0)
(-0.0451502 0.238384 0)
(-0.0605526 0.263627 0)
(-0.0754437 0.280279 0)
(-0.0891556 0.289408 0)
(-0.101262 0.29212 0)
(-0.111544 0.289485 0)
(-0.119941 0.282491 0)
(-0.126516 0.272015 0)
(-0.131413 0.258811 0)
(-0.134829 0.243512 0)
(-0.136988 0.226635 0)
(-0.138124 0.208593 0)
(-0.138466 0.189708 0)
(-0.138233 0.170223 0)
(-0.137623 0.150317 0)
(-0.136816 0.130112 0)
(-0.135967 0.109687 0)
(-0.13521 0.0890854 0)
(-0.134654 0.0683229 0)
(-0.134385 0.0473936 0)
(-0.134466 0.0262767 0)
(-0.134936 0.00494187 0)
(-0.13581 -0.0166451 0)
(-0.137077 -0.0385169 0)
(-0.138702 -0.0606987 0)
(-0.140617 -0.0832012 0)
(-0.142727 -0.106013 0)
(-0.1449 -0.129092 0)
(-0.146971 -0.152352 0)
(-0.148738 -0.175653 0)
(-0.149959 -0.198786 0)
(-0.15036 -0.221451 0)
(-0.149635 -0.243247 0)
(-0.147459 -0.263645 0)
(-0.143507 -0.281974 0)
(-0.137473 -0.297406 0)
(-0.129113 -0.308952 0)
(-0.118285 -0.315464 0)
(-0.105002 -0.315667 0)
(-0.0894958 -0.308203 0)
(-0.0722738 -0.291717 0)
(-0.0541655 -0.264962 0)
(-0.0363191 -0.226939 0)
(-0.0201431 -0.177034 0)
(-0.0075297 -0.115135 0)
(-0.00119843 -0.0417767 0)
(-0.00110627 0.0408708 0)
(-0.00689897 0.111889 0)
(-0.0183278 0.171084 0)
(-0.0327862 0.218246 0)
(-0.0484857 0.25385 0)
(-0.0641479 0.278829 0)
(-0.078781 0.2944 0)
(-0.0917077 0.301905 0)
(-0.102548 0.302694 0)
(-0.111159 0.298031 0)
(-0.117577 0.289053 0)
(-0.12196 0.276737 0)
(-0.124544 0.261905 0)
(-0.125605 0.245222 0)
(-0.125436 0.22722 0)
(-0.124324 0.208309 0)
(-0.122541 0.188798 0)
(-0.120337 0.16891 0)
(-0.117934 0.148802 0)
(-0.11553 0.128571 0)
(-0.113292 0.108271 0)
(-0.111361 0.0879202 0)
(-0.109854 0.0675103 0)
(-0.108862 0.0470113 0)
(-0.108453 0.0263787 0)
(-0.108671 0.00555819 0)
(-0.109537 -0.0155093 0)
(-0.111047 -0.0368825 0)
(-0.113169 -0.0586147 0)
(-0.115845 -0.080747 0)
(-0.118983 -0.103301 0)
(-0.122455 -0.126271 0)
(-0.126097 -0.14961 0)
(-0.129698 -0.173219 0)
(-0.133006 -0.196929 0)
(-0.135719 -0.22048 0)
(-0.137491 -0.243503 0)
(-0.137942 -0.265487 0)
(-0.136665 -0.285762 0)
(-0.133258 -0.303466 0)
(-0.127355 -0.317536 0)
(-0.11868 -0.326697 0)
(-0.107113 -0.329478 0)
(-0.0927639 -0.324263 0)
(-0.0760611 -0.309372 0)
(-0.0578251 -0.283194 0)
(-0.0392896 -0.244359 0)
(-0.0220554 -0.191933 0)
(-0.00834286 -0.125595 0)
(-0.00135071 -0.0458498 0)
(-0.0012696 0.0446291 0)
(-0.00776608 0.12146 0)
(-0.0203485 0.184539 0)
(-0.0358877 0.233724 0)
(-0.0522556 0.269757 0)
(-0.0679927 0.293929 0)
(-0.0820394 0.307836 0)
(-0.0937424 0.313169 0)
(-0.102807 0.311564 0)
(-0.109208 0.304507 0)
(-0.11311 0.293285 0)
(-0.114791 0.278976 0)
(-0.114596 0.262451 0)
(-0.11289 0.2444 0)
(-0.110034 0.22535 0)
(-0.106371 0.205695 0)
(-0.102209 0.185718 0)
(-0.0978269 0.165615 0)
(-0.0934639 0.145509 0)
(-0.0893268 0.125468 0)
(-0.08559 0.105517 0)
(-0.0823984 0.0856471 0)
(-0.0798698 0.0658237 0)
(-0.0780976 0.0459927 0)
(-0.0771516 0.0260862 0)
(-0.0770795 0.0060266 0)
(-0.0779066 -0.0142689 0)
(-0.0796355 -0.0348843 0)
(-0.0822435 -0.0558998 0)
(-0.0856807 -0.0773871 0)
(-0.0898659 -0.0994018 0)
(-0.0946818 -0.121976 0)
(-0.0999702 -0.145106 0)
(-0.105525 -0.168741 0)
(-0.111089 -0.192762 0)
(-0.116346 -0.216962 0)
(-0.120921 -0.241019 0)
(-0.124381 -0.264466 0)
(-0.126246 -0.286651 0)
(-0.126008 -0.306709 0)
(-0.123169 -0.323523 0)
(-0.117293 -0.3357 0)
(-0.108082 -0.341579 0)
(-0.0954757 -0.339254 0)
(-0.0797673 -0.326666 0)
(-0.0617186 -0.301747 0)
(-0.0426217 -0.26264 0)
(-0.024282 -0.20796 0)
(-0.00931801 -0.137068 0)
(-0.00153924 -0.0503891 0)
(-0.00148382 0.0488971 0)
(-0.00886338 0.132129 0)
(-0.022828 0.199194 0)
(-0.0395577 0.25009 0)
(-0.056505 0.285966 0)
(-0.0720215 0.308619 0)
(-0.085014 0.320144 0)
(-0.0949074 0.322664 0)
(-0.101551 0.31815 0)
(-0.105089 0.308325 0)
(-0.10585 0.294627 0)
(-0.104263 0.278216 0)
(-0.100792 0.259996 0)
(-0.0958955 0.240655 0)
(-0.0900055 0.220696 0)
(-0.0835102 0.200481 0)
(-0.0767507 0.180252 0)
(-0.0700204 0.160163 0)
(-0.0635683 0.140301 0)
(-0.0576027 0.120696 0)
(-0.052296 0.101342 0)
(-0.0477896 0.0822 0)
(-0.0441975 0.0632096 0)
(-0.0416098 0.0442933 0)
(-0.0400953 0.025361 0)
(-0.0397025 0.00631377 0)
(-0.0404609 -0.0129526 0)
(-0.0423795 -0.0325449 0)
(-0.0454459 -0.0525684 0)
(-0.0496229 -0.0731233 0)
(-0.0548443 -0.0942985 0)
(-0.0610095 -0.116165 0)
(-0.0679768 -0.138764 0)
(-0.0755551 -0.162096 0)
(-0.0834952 -0.186104 0)
(-0.0914811 -0.210644 0)
(-0.0991224 -0.235462 0)
(-0.10595 -0.260155 0)
(-0.11142 -0.284126 0)
(-0.114923 -0.306533 0)
(-0.115818 -0.326242 0)
(-0.113486 -0.341775 0)
(-0.107409 -0.351287 0)
(-0.097295 -0.352573 0)
(-0.0832228 -0.343138 0)
(-0.0658196 -0.320354 0)
(-0.0463813 -0.28172 0)
(-0.0269131 -0.225219 0)
(-0.0105124 -0.149726 0)
(-0.00177913 -0.0554956 0)
(-0.00177299 0.0538207 0)
(-0.01028 0.144151 0)
(-0.0259079 0.215228 0)
(-0.0439135 0.26733 0)
(-0.0612413 0.302231 0)
(-0.0760709 0.322441 0)
(-0.0873443 0.330711 0)
(-0.0946504 0.329692 0)
(-0.0980628 0.321731 0)
(-0.0979583 0.308793 0)
(-0.0948741 0.292448 0)
(-0.0894083 0.273908 0)
(-0.0821548 0.254076 0)
(-0.0736651 0.233608 0)
(-0.0644302 0.21296 0)
(-0.0548734 0.192437 0)
(-0.0453527 0.172226 0)
(-0.0361653 0.152431 0)
(-0.0275555 0.13309 0)
(-0.019722 0.114195 0)
(-0.0128259 0.095704 0)
(-0.00699643 0.0775489 0)
(-0.00233698 0.0596444 0)
(0.00107068 0.0418911 0)
(0.00316321 0.0241796 0)
(0.00389359 0.00639301 0)
(0.00323021 -0.011591 0)
(0.00115716 -0.0298982 0)
(-0.00232423 -0.0486553 0)
(-0.00719246 -0.0679873 0)
(-0.0134014 -0.0880135 0)
(-0.020874 -0.108841 0)
(-0.0294949 -0.130558 0)
(-0.0390996 -0.153219 0)
(-0.049464 -0.176832 0)
(-0.0602901 -0.201329 0)
(-0.0711936 -0.226543 0)
(-0.0816911 -0.252159 0)
(-0.0911928 -0.277668 0)
(-0.0990045 -0.302299 0)
(-0.104347 -0.324946 0)
(-0.1064 -0.344095 0)
(-0.104388 -0.357756 0)
(-0.0977106 -0.363431 0)
(-0.0861373 -0.358147 0)
(-0.0700448 -0.338603 0)
(-0.0506335 -0.301462 0)
(-0.0300688 -0.243818 0)
(-0.0120107 -0.163791 0)
(-0.00209453 -0.0613096 0)
(-0.00217687 0.0596075 0)
(-0.0121489 0.157858 0)
(-0.0297733 0.23283 0)
(-0.0490675 0.285339 0)
(-0.0663843 0.318129 0)
(-0.0798002 0.334718 0)
(-0.0884168 0.338704 0)
(-0.0921161 0.33336 0)
(-0.0913011 0.321438 0)
(-0.0866519 0.305118 0)
(-0.0789535 0.286063 0)
(-0.0689884 0.265486 0)
(-0.0574766 0.244245 0)
(-0.0450475 0.222924 0)
(-0.0322328 0.201901 0)
(-0.0194704 0.181401 0)
(-0.00711458 0.161542 0)
(0.00455184 0.142365 0)
(0.0153052 0.123857 0)
(0.0249698 0.105967 0)
(0.0334075 0.0886169 0)
(0.0405099 0.0717118 0)
(0.0461918 0.0551434 0)
(0.0503854 0.0387941 0)
(0.053037 0.0225391 0)
(0.0541043 0.00624788 0)
(0.0535554 -0.010215 0)
(0.0513682 -0.0269892 0)
(0.047532 -0.0442175 0)
(0.0420506 -0.0620447 0)
(0.0349457 -0.0806152 0)
(0.0262641 -0.100069 0)
(0.0160857 -0.120535 0)
(0.0045346 -0.142124 0)
(-0.00820663 -0.164909 0)
(-0.0218805 -0.188908 0)
(-0.036135 -0.214053 0)
(-0.0505027 -0.240146 0)
(-0.0643816 -0.266799 0)
(-0.0770216 -0.293363 0)
(-0.0875251 -0.318828 0)
(-0.0948753 -0.341713 0)
(-0.0980068 -0.359954 0)
(-0.0959424 -0.370804 0)
(-0.0880172 -0.370803 0)
(-0.0741974 -0.355867 0)
(-0.0554208 -0.321596 0)
(-0.0339057 -0.26384 0)
(-0.0139409 -0.179553 0)
(-0.00252581 -0.0680315 0)
(-0.00276414 0.0665623 0)
(-0.0146726 0.173682 0)
(-0.0346582 0.252159 0)
(-0.0550832 0.303833 0)
(-0.0716694 0.332958 0)
(-0.0825558 0.344456 0)
(-0.087213 0.342994 0)
(-0.085997 0.332544 0)
(-0.0797664 0.316239 0)
(-0.0695745 0.296423 0)
(-0.0564785 0.274768 0)
(-0.0414401 0.252418 0)
(-0.0252825 0.230126 0)
(-0.00868254 0.208358 0)
(0.00781945 0.18738 0)
(0.0238016 0.167317 0)
(0.0389398 0.148203 0)
(0.0529886 0.130012 0)
(0.0657635 0.112673 0)
(0.0771265 0.0960941 0)
(0.0869743 0.0801651 0)
(0.0952288 0.0647659 0)
(0.10183 0.0497704 0)
(0.106729 0.0350473 0)
(0.109887 0.020462 0)
(0.111269 0.00587597 0)
(0.110844 -0.00885347 0)
(0.108586 -0.0238735 0)
(0.104473 -0.0393363 0)
(0.0984874 -0.0553994 0)
(0.0906253 -0.0722253 0)
(0.0808975 -0.0899792 0)
(0.0693399 -0.108826 0)
(0.0560243 -0.128924 0)
(0.0410738 -0.150412 0)
(0.0246822 -0.173394 0)
(0.00713811 -0.197912 0)
(-0.0111458 -0.223901 0)
(-0.0296006 -0.251134 0)
(-0.0474691 -0.279135 0)
(-0.0637819 -0.307067 0)
(-0.0773551 -0.333583 0)
(-0.0868322 -0.356654 0)
(-0.0908007 -0.373387 0)
(-0.0880301 -0.379878 0)
(-0.0778633 -0.371197 0)
(-0.0607113 -0.341629 0)
(-0.0386177 -0.285306 0)
(-0.0164999 -0.197379 0)
(-0.00314335 -0.075957 0)
(-0.00365783 0.0751486 0)
(-0.0181632 0.192164 0)
(-0.0408327 0.273261 0)
(-0.0618724 0.322197 0)
(-0.0764632 0.345573 0)
(-0.0831422 0.350222 0)
(-0.082075 0.342092 0)
(-0.0743245 0.325867 0)
(-0.0613347 0.304978 0)
(-0.0445782 0.281803 0)
(-0.0253757 0.257909 0)
(-0.00482912 0.234276 0)
(0.0161857 0.211479 0)
(0.0369964 0.189818 0)
(0.0571012 0.169414 0)
(0.076134 0.15028 0)
(0.0938335 0.132356 0)
(0.110017 0.115543 0)
(0.124558 0.0997213 0)
(0.137372 0.0847581 0)
(0.1484 0.0705166 0)
(0.157604 0.0568584 0)
(0.164955 0.0436451 0)
(0.170428 0.0307389 0)
(0.174 0.0180012 0)
(0.175649 0.00529212 0)
(0.175347 -0.00753116 0)
(0.173064 -0.0206163 0)
(0.168767 -0.0341172 0)
(0.162419 -0.048196 0)
(0.153989 -0.0630238 0)
(0.143447 -0.0787818 0)
(0.130781 -0.09566 0)
(0.115999 -0.113855 0)
(0.0991508 -0.133562 0)
(0.080343 -0.154967 0)
(0.0597685 -0.178217 0)
(0.0377413 -0.203395 0)
(0.0147398 -0.230459 0)
(-0.00854126 -0.259158 0)
(-0.0311374 -0.28891 0)
(-0.0517706 -0.318622 0)
(-0.0688389 -0.346458 0)
(-0.0804811 -0.369551 0)
(-0.0847852 -0.383702 0)
(-0.0802191 -0.383159 0)
(-0.066281 -0.360671 0)
(-0.0444136 -0.308068 0)
(-0.0199923 -0.217727 0)
(-0.00407388 -0.0855399 0)
(-0.00508292 0.0860972 0)
(-0.0230976 0.21395 0)
(-0.0485295 0.295879 0)
(-0.068958 0.339226 0)
(-0.079416 0.354153 0)
(-0.0794427 0.349992 0)
(-0.0703584 0.334095 0)
(-0.0541899 0.311738 0)
(-0.0330574 0.286446 0)
(-0.00883729 0.260432 0)
(0.0169558 0.234998 0)
(0.0431681 0.210844 0)
(0.0689573 0.188294 0)
(0.093731 0.16744 0)
(0.117086 0.148242 0)
(0.13876 0.130586 0)
(0.158588 0.114323 0)
(0.176475 0.0992899 0)
(0.192372 0.085321 0)
(0.206258 0.0722545 0)
(0.218131 0.0599349 0)
(0.227994 0.048214 0)
(0.235853 0.0369495 0)
(0.241713 0.0260039 0)
(0.245569 0.0152424 0)
(0.247411 0.00453073 0)
(0.247217 -0.00626709 0)
(0.244955 -0.0172916 0)
(0.240582 -0.0286902 0)
(0.234046 -0.0406204 0)
(0.225285 -0.0532521 0)
(0.214234 -0.0667701 0)
(0.200827 -0.0813767 0)
(0.185005 -0.0972921 0)
(0.166733 -0.114753 0)
(0.146013 -0.134008 0)
(0.122913 -0.155303 0)
(0.0976032 -0.178861 0)
(0.0704084 -0.204834 0)
(0.0418736 -0.233232 0)
(0.0128481 -0.2638 0)
(-0.0154217 -0.295829 0)
(-0.0412089 -0.327872 0)
(-0.0622757 -0.357353 0)
(-0.0759852 -0.380061 0)
(-0.0796868 -0.389624 0)
(-0.0714592 -0.377175 0)
(-0.0514255 -0.3316 0)
(-0.0248812 -0.241112 0)
(-0.00554906 -0.0975015 0)
(-0.00744697 0.100588 0)
(-0.0301616 0.239675 0)
(-0.0577004 0.319064 0)
(-0.0749577 0.352681 0)
(-0.0778262 0.355892 0)
(-0.0678128 0.341027 0)
(-0.0479439 0.316717 0)
(-0.0214024 0.288478 0)
(0.00904368 0.259568 0)
(0.0412472 0.231754 0)
(0.0736613 0.205883 0)
(0.10523 0.182265 0)
(0.135269 0.160913 0)
(0.16336 0.141689 0)
(0.189266 0.124388 0)
(0.212874 0.108782 0)
(0.234149 0.0946444 0)
(0.253103 0.0817629 0)
(0.269776 0.0699417 0)
(0.284219 0.0590027 0)
(0.296487 0.0487844 0)
(0.306629 0.0391387 0)
(0.314688 0.0299286 0)
(0.320694 0.0210253 0)
(0.324664 0.012305 0)
(0.326599 0.0036461 0)
(0.326486 -0.00507374 0)
(0.324291 -0.0139806 0)
(0.319966 -0.0232078 0)
(0.313444 -0.0328988 0)
(0.30464 -0.0432118 0)
(0.293453 -0.0543228 0)
(0.279769 -0.0664307 0)
(0.263464 -0.0797609 0)
(0.244414 -0.0945694 0)
(0.22251 -0.111144 0)
(0.197674 -0.129802 0)
(0.169897 -0.150882 0)
(0.13929 -0.174714 0)
(0.106154 -0.201572 0)
(0.0710866 -0.231573 0)
(0.0351217 -0.2645 0)
(-0.000105858 -0.299507 0)
(-0.0321932 -0.334642 0)
(-0.0578972 -0.366145 0)
(-0.0733271 -0.387512 0)
(-0.0745953 -0.388501 0)
(-0.059431 -0.354578 0)
(-0.0318159 -0.267971 0)
(-0.00798492 -0.11301 0)
(-0.0114292 0.120498 0)
(-0.0401435 0.269582 0)
(-0.0673136 0.340429 0)
(-0.0764906 0.358669 0)
(-0.0665188 0.346702 0)
(-0.0421663 0.319892 0)
(-0.00861179 0.287518 0)
(0.0298641 0.254645 0)
(0.0701188 0.223737 0)
(0.110048 0.195784 0)
(0.148345 0.171002 0)
(0.184263 0.149234 0)
(0.217423 0.130168 0)
(0.247676 0.113449 0)
(0.275017 0.0987343 0)
(0.299516 0.0857094 0)
(0.321286 0.0740999 0)
(0.340455 0.0636684 0)
(0.357154 0.05421 0)
(0.371504 0.0455482 0)
(0.383613 0.0375289 0)
(0.393575 0.030016 0)
(0.401462 0.0228873 0)
(0.407328 0.0160302 0)
(0.41121 0.00933882 0)
(0.413119 0.00271031 0)
(0.413049 -0.00395801 0)
(0.410969 -0.0107719 0)
(0.406828 -0.0178434 0)
(0.400549 -0.0252946 0)
(0.39203 -0.0332618 0)
(0.381143 -0.0419002 0)
(0.367735 -0.0513894 0)
(0.351627 -0.0619402 0)
(0.332617 -0.0738017 0)
(0.310485 -0.087269 0)
(0.285009 -0.102691 0)
(0.255985 -0.120475 0)
(0.223267 -0.141082 0)
(0.186833 -0.165009 0)
(0.146891 -0.19273 0)
(0.104042 -0.224568 0)
(0.0595159 -0.260442 0)
(0.0154843 -0.299383 0)
(-0.0246028 -0.338696 0)
(-0.055821 -0.372607 0)
(-0.0719805 -0.390355 0)
(-0.0670977 -0.374115 0)
(-0.0414763 -0.298219 0)
(-0.0120566 -0.133906 0)
(-0.0178754 0.148744 0)
(-0.0531267 0.302393 0)
(-0.0734589 0.354734 0)
(-0.0659671 0.350844 0)
(-0.0360054 0.321137 0)
(0.00724901 0.282864 0)
(0.0566021 0.244524 0)
(0.107285 0.20967 0)
(0.156432 0.17936 0)
(0.202506 0.153532 0)
(0.244807 0.131685 0)
(0.283127 0.113209 0)
(0.317528 0.097522 0)
(0.348204 0.084116 0)
(0.375409 0.0725672 0)
(0.399408 0.0625288 0)
(0.420457 0.0537184 0)
(0.43879 0.0459059 0)
(0.454614 0.0389023 0)
(0.468109 0.032551 0)
(0.479423 0.0267199 0)
(0.488682 0.0212956 0)
(0.495981 0.0161789 0)
(0.501392 0.0112801 0)
(0.504962 0.00651626 0)
(0.506714 0.00180774 0)
(0.506647 -0.00292441 0)
(0.504735 -0.00776135 0)
(0.500926 -0.0127894 0)
(0.49514 -0.0181033 0)
(0.487268 -0.0238103 0)
(0.477168 -0.0300344 0)
(0.464663 -0.0369227 0)
(0.449537 -0.044652 0)
(0.43153 -0.0534388 0)
(0.41034 -0.0635501 0)
(0.385619 -0.0753179 0)
(0.356985 -0.0891557 0)
(0.324034 -0.105576 0)
(0.286387 -0.125205 0)
(0.243763 -0.148776 0)
(0.196128 -0.17709 0)
(0.143946 -0.210859 0)
(0.0885859 -0.250347 0)
(0.0329277 -0.294565 0)
(-0.0178888 -0.33968 0)
(-0.0557661 -0.376142 0)
(-0.0700479 -0.384374 0)
(-0.0536486 -0.330028 0)
(-0.0185397 -0.163011 0)
(-0.0268195 0.190245 0)
(-0.0655625 0.332456 0)
(-0.0646802 0.351157 0)
(-0.0274097 0.319371 0)
(0.0302132 0.272744 0)
(0.09515 0.226916 0)
(0.159732 0.187298 0)
(0.220153 0.154754 0)
(0.274877 0.128518 0)
(0.323579 0.107438 0)
(0.366513 0.0904164 0)
(0.404174 0.0765479 0)
(0.437118 0.0651218 0)
(0.465885 0.0555942 0)
(0.490958 0.0475517 0)
(0.512763 0.0406784 0)
(0.531661 0.0347316 0)
(0.547955 0.029522 0)
(0.5619 0.0249002 0)
(0.573705 0.020746 0)
(0.583541 0.0169611 0)
(0.591545 0.0134628 0)
(0.597823 0.0101804 0)
(0.602453 0.00705113 0)
(0.605488 0.0040175 0)
(0.606955 0.00102513 0)
(0.606857 -0.00197966 0)
(0.605174 -0.00505194 0)
(0.601857 -0.00825041 0)
(0.596833 -0.01164 0)
(0.589995 -0.0152948 0)
(0.581202 -0.0193019 0)
(0.570275 -0.0237665 0)
(0.556988 -0.028818 0)
(0.541059 -0.0346186 0)
(0.522143 -0.0413756 0)
(0.499822 -0.0493572 0)
(0.473589 -0.0589146 0)
(0.442844 -0.0705119 0)
(0.406895 -0.0847651 0)
(0.36498 -0.102489 0)
(0.316339 -0.124739 0)
(0.260393 -0.152819 0)
(0.197105 -0.188156 0)
(0.127695 -0.231812 0)
(0.0558858 -0.283106 0)
(-0.01022 -0.336285 0)
(-0.0563453 -0.374068 0)
(-0.0641678 -0.356945 0)
(-0.0272121 -0.20504 0)
(-0.0329789 0.250126 0)
(-0.0618046 0.343619 0)
(-0.0118434 0.310257 0)
(0.0704822 0.25145 0)
(0.158832 0.196276 0)
(0.241861 0.152108 0)
(0.315233 0.118819 0)
(0.378253 0.0941119 0)
(0.431801 0.075674 0)
(0.477201 0.0617135 0)
(0.515753 0.0509494 0)
(0.548593 0.0424893 0)
(0.576658 0.0357143 0)
(0.600708 0.0301919 0)
(0.621353 0.0256154 0)
(0.63908 0.0217632 0)
(0.654282 0.0184721 0)
(0.667272 0.0156198 0)
(0.678302 0.0131122 0)
(0.687577 0.0108759 0)
(0.695257 0.00885189 0)
(0.701469 0.00699161 0)
(0.706313 0.00525413 0)
(0.709859 0.00360368 0)
(0.712156 0.00200795 0)
(0.71323 0.000436515 0)
(0.713088 -0.00114044 0)
(0.711713 -0.00275344 0)
(0.709067 -0.0044351 0)
(0.705087 -0.0062217 0)
(0.699683 -0.00815498 0)
(0.692734 -0.0102846 0)
(0.684081 -0.0126714 0)
(0.673521 -0.0153915 0)
(0.660796 -0.0185425 0)
(0.645578 -0.0222524 0)
(0.627452 -0.0266921 0)
(0.605892 -0.0320945 0)
(0.580229 -0.0387831 0)
(0.549616 -0.0472165 0)
(0.512982 -0.0580549 0)
(0.468997 -0.0722595 0)
(0.41608 -0.0912298 0)
(0.352516 -0.116959 0)
(0.276914 -0.152089 0)
(0.189446 -0.199378 0)
(0.0941883 -0.259356 0)
(0.0027953 -0.324178 0)
(-0.0566332 -0.361956 0)
(-0.0321393 -0.26402 0)
(0.00102985 0.294768 0)
(0.0166333 0.298387 0)
(0.1519 0.21281 0)
(0.28233 0.145218 0)
(0.387555 0.0996788 0)
(0.471025 0.0700199 0)
(0.53691 0.0508384 0)
(0.589059 0.0381994 0)
(0.630798 0.0295834 0)
(0.664664 0.0234839 0)
(0.692493 0.019008 0)
(0.715611 0.0156164 0)
(0.734986 0.0129737 0)
(0.751333 0.0108644 0)
(0.765189 0.00914508 0)
(0.776962 0.00771712 0)
(0.786968 0.00651065 0)
(0.795452 0.00547474 0)
(0.802607 0.00457127 0)
(0.808584 0.00377098 0)
(0.813504 0.00305082 0)
(0.817457 0.00239212 0)
(0.820516 0.00177931 0)
(0.822732 0.00119894 0)
(0.82414 0.00063898 0)
(0.82476 8.81839e-05 0)
(0.824596 -0.000464414 0)
(0.823639 -0.00103007 0)
(0.821862 -0.00162081 0)
(0.819223 -0.00225004 0)
(0.81566 -0.00293334 0)
(0.811088 -0.00368942 0)
(0.805396 -0.00454142 0)
(0.798439 -0.00551877 0)
(0.790029 -0.00665986 0)
(0.779923 -0.00801603 0)
(0.767807 -0.00965762 0)
(0.753265 -0.0116837 0)
(0.735749 -0.014238 0)
(0.714522 -0.0175361 0)
(0.688576 -0.021913 0)
(0.656515 -0.0279095 0)
(0.616385 -0.0364293 0)
(0.565439 -0.0490223 0)
(0.499973 -0.0683452 0)
(0.415553 -0.0986988 0)
(0.307308 -0.146191 0)
(0.170941 -0.21755 0)
(0.0269825 -0.307267 0)
(0.0051713 -0.302952 0)
(0.290224 0.152387 0)
(0.389411 0.128175 0)
(0.565162 0.0746721 0)
(0.682888 0.0421904 0)
(0.752452 0.0245178 0)
(0.797527 0.0149093 0)
(0.828849 0.00963378 0)
(0.851567 0.00663953 0)
(0.868702 0.00484052 0)
(0.882064 0.00368623 0)
(0.892748 0.00289818 0)
(0.901452 0.00233099 0)
(0.908638 0.00190496 0)
(0.91463 0.00157392 0)
(0.919659 0.00130956 0)
(0.923896 0.00109357 0)
(0.92747 0.000913553 0)
(0.930479 0.000760756 0)
(0.933 0.00062881 0)
(0.935092 0.000512924 0)
(0.9368 0.000409394 0)
(0.938161 0.000315263 0)
(0.939201 0.0002281 0)
(0.93994 0.000145829 0)
(0.940392 6.66077e-05 0)
(0.940564 -1.12704e-05 0)
(0.940458 -8.94402e-05 0)
(0.94007 -0.000169637 0)
(0.939391 -0.00025368 0)
(0.938403 -0.000343615 0)
(0.937085 -0.000441843 0)
(0.935405 -0.000551281 0)
(0.933319 -0.000675589 0)
(0.930772 -0.000819496 0)
(0.927692 -0.000989288 0)
(0.923983 -0.00119356 0)
(0.91952 -0.00144442 0)
(0.914136 -0.00175959 0)
(0.907601 -0.00216606 0)
(0.899597 -0.00270722 0)
(0.889665 -0.003457 0)
(0.877118 -0.00454957 0)
(0.860876 -0.00624335 0)
(0.839148 -0.00905866 0)
(0.808889 -0.0140549 0)
(0.764841 -0.0233231 0)
(0.696086 -0.0408243 0)
(0.577953 -0.0737692 0)
(0.397986 -0.128731 0)
(0.293832 -0.153751 0)
)
;
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0);
}
fixedWalls
{
type noSlip;
}
frontAndBack
{
type empty;
}
}
// ************************************************************************* //
| |
cb5d263b4757f949b84c278258dc4183f88e9b30 | 3832467874eab6130075b4c7ac891713b2453aec | /src/oci20/function_codes.h | b3e70a419c268b555a16980d0c482e5308a2727b | [] | no_license | welldias/stonedb | 1e6b44b656148f9f7d7769b466e764743f86061d | ad64718449baf79287de2432dfc5ca12f468655f | refs/heads/master | 2023-01-23T20:11:42.904873 | 2020-12-06T03:25:53 | 2020-12-06T03:25:53 | 242,632,221 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,541 | h | function_codes.h | #ifndef __PROJECT_STONE_OCI20_FUNCTION_CODES_H__
#define __PROJECT_STONE_OCI20_FUNCTION_CODES_H__
#include <oci.h>
#include <string>
namespace Oci20 {
class FunctionNames {
public:
enum class Code : ub2 {
CreateTable = 1,
SetRole = 2,
Insert = 3,
Select = 4,
Update = 5,
DropRole = 6,
DropView = 7,
DropTable = 8,
Delete = 9,
CreateView = 10,
DropUser = 11,
CreateRole = 12,
CreateSequence = 13,
AlterSequence = 14,
DropSequence = 16,
CreateSchema = 17,
CreateCluster = 18,
CreateUser = 19,
CreateIndex = 20,
DropIndex = 21,
DropCluster = 22,
ValidateIndex = 23,
CreateProcedure = 24,
AlterProcedure = 25,
AlterTable = 26,
Explain = 27,
Grant = 28,
Revoke = 29,
CreateSynonym = 30,
DropSynonym = 31,
AlterSystem = 32,
SetTransaction = 33,
PlSqlExecute = 34,
LockTable = 35,
Rename = 37,
Comment = 38,
Audit = 39,
Noaudit = 40,
AlterIndex = 41,
CreateExternalDatabase = 42,
DropExternalDatabase = 43,
CreateDatabase = 44,
AlterDatabase = 45,
CreateRollbackSegment = 46,
AlterRollbackSegment = 47,
DropRollbackSegment = 48,
CreateTablespace = 49,
AlterTablespace = 50,
DropTablespace = 51,
AlterSession = 52,
AlterUser = 53,
Commit = 54,
Rollback = 55,
Savepoint = 56,
CreateControlFile = 57,
AlterTracing = 58,
CreateTrigger = 59,
AlterTrigger = 60,
DropTrigger = 61,
AnalyzeTable = 62,
AnalyzeIndex = 63,
AnalyzeCluster = 64,
CreateProfile = 65,
DropProfile = 66,
AlterProfile = 67,
DropProcedure = 68,
AlterResourceCost = 70,
CreateSnapshotLog = 71,
AlterSnapshotLog = 72,
DropSnapshotLog = 73,
CreateSnapshot = 74,
AlterSnapshot = 75,
DropSnapshot = 76,
CreateType = 77,
DropType = 78,
AlterRole = 79,
AlterType = 80,
CreateTypeBody = 81,
AlterTypeBody = 82,
DropTypeBody = 83,
TruncateTable = 85,
TruncateCluster = 86,
AlterView = 88,
CreateFunction = 91,
AlterFunction = 92,
DropFunction = 93,
CreatePackage = 94,
AlterPackage = 95,
DropPackage = 96,
CreatePackageBody = 97,
AlterPackageBody = 98,
DropPackageBody = 99,
Noop = 36,
DropLibrary = 84,
CreateBitmapfile = 87,
DropBitmapfile = 89,
SetConstraints = 90,
CreateDirectory = 157,
DropDirectory = 158,
CreateLibrary = 159,
CreateJava = 160,
AlterJava = 161,
DropJava = 162,
CreateOperator = 163,
CreateIndextype = 164,
DropIndextype = 165,
AlterIndextype = 166,
DropOperator = 167,
AssociateStatistics = 168,
DisassociateStatistics = 169,
CallMethod = 170,
CreateSummary = 171,
AlterSummary = 172,
DropSummary = 173,
CreateDimension = 174,
AlterDimension = 175,
DropDimension = 176,
CreateContext = 177,
DropContext = 178,
AlterOutline = 179,
CreateOutline = 180,
DropOutline = 181,
UpdateIndexes = 182,
AlterOperator = 183,
Merge = 189,
};
static std::string Get(Code code);
static std::string Get(ub2 code);
static bool PossibleCompilationErrors(Code code);
static bool PossibleCompilationErrors(ub2 code);
private:
struct FucntionName { Code code; const char* name; };
static const FucntionName m_fucntionName[];
};
}
#endif // __PROJECT_STONE_OCI20_FUNCTION_CODES_H__
|
1ddbb9370a5130dff4e9b2b10cc565f92d868bbe | 732e5ad601cc0bff20528147845f7025e9fc0cfe | /Stack and queue/reversestringusingstack.cpp | 67aa82104a756ec2cdde5f34d81659c2f85bc329 | [] | no_license | SETURAJ/Data-Structures | 004bc3d2eb63f283ad4dfadd848abeb132a58d39 | b8a216ace503ce9168f8361aa661c95664c899dc | refs/heads/main | 2023-08-01T05:56:01.288299 | 2021-09-28T04:40:35 | 2021-09-28T04:40:35 | 411,138,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 440 | cpp | reversestringusingstack.cpp | #include<bits/stdc++.h>
using namespace std;
string reverse(string str)
{
string res="";
if(str.length()==0 || str.length()==1)
return str;
stack<char>s;
for(int i=0;i<str.length();i++)
{
s.push(str[i]);
}
for(int i=0;i<str.length();i++)
{
char ch=s.top();
s.pop();
res+=ch;
}
return res;
}
int main()
{
string str;
cin>>str;
cout<<reverse(str);
} |
e3d57ff589b0c4f690573b01f0049aea3fac0b45 | e29df8015865b1cbb5cafb5d6be89dc4480802e6 | /Genius/Genius/control/eventdispatch/eventdispatch.cpp | dcbe18776bcfa274b01594c3c91bd2b96f321e2c | [] | no_license | xugongming38/Genius | 1b894fd0694af9d7d383f57c28a0aa9c7ea2f629 | ba4cb06fa15714ebfbb4ef0813e44f992165d8fc | refs/heads/master | 2020-03-19T07:37:10.870441 | 2018-06-05T09:14:12 | 2018-06-05T09:14:12 | 136,132,084 | 4 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,995 | cpp | eventdispatch.cpp | #include"eventdispatch.h"
//假装实现构造与析构函数
EventDispatch::EventDispatch()
{
}
EventDispatch::~EventDispatch()
{
}
//单例模式
EventDispatch* EventDispatchInstance=nullptr;
EventDispatch* EventDispatch::getInstance()
{
if(EventDispatchInstance==nullptr)
{
EventDispatchInstance=new EventDispatch();
}
return EventDispatchInstance;
}
//每帧调用的时间分发操作
void EventDispatch::dispatchEvent()
{
//处理自定义事件
HandleCustom();
//处理鼠标事件
HandleMouse();
//处理键盘事件
handleKeyboard();
}
//由事件产生者调用,创建事件,其中event必须有event的类型
bool EventDispatch::sendEvent(Event* event)
{
switch (event->getType())
{
case EventType::EventCustomType:
queueCustom.push(event);
break;
case EventType::EventKeyboardType:
queueKeyboard.push(event);
break;
case EventType::EventMouseType:
queueMouse.push(event);
break;
default:
return false;
break;
}
return true;
}
bool EventDispatch::addListener(Listener* ls)
{
switch (ls->getType())
{
case ListenerType::CustomListenerType:
CustomListeners.push_back((CustomListener*)ls);
break;
case ListenerType::KeyboardListenerType:
KeyboardListeners.push_back((KeyboardListener*)ls);
break;
case ListenerType::MouseListenerType:
MouseListeners.push_back((MouseListener*)ls);
break;
default:
return false;
break;
}
return true;
}
//以下为三种事件相应处理
//处理自定义事件
void EventDispatch::HandleCustom()
{
while(!queueCustom.empty())
{
EventCustom *event=(EventCustom *)queueCustom.front();
//关于注册后调用次数问题,可以在用户代码中计数处理,这里不在实现
for (auto iter = 0; iter != CustomListeners.size(); ++iter)
if(CustomListeners.at(iter)->isHandle(event->getEventName()))
CustomListeners.at(iter)->handleCustomCallBack();
queueCustom.pop();
}
}
//处理鼠标事件
void EventDispatch::HandleMouse()
{
while(!queueMouse.empty())
{
EventMouse *event=(EventMouse *)queueMouse.front();
//cout<<MouseListeners.size()<<"$$"<<endl;
//关于注册后调用次数问题,可以在用户代码中计数处理,这里不在实现
//此处在处理鼠标事件中又又一次调用添加监听者,导致迭代器损坏,注意问题;
//重写数据结构 不再使用vector
for (int iter = 0; iter < MouseListeners.size();++ iter)
{
MouseListeners.at(iter)->handleMouseCallBack(event->getMouse());
}
queueMouse.pop();
}
}
//处理键盘事件
void EventDispatch::handleKeyboard()
{
while(!queueKeyboard.empty())
{
EventKeyboard *event=(EventKeyboard *)queueKeyboard.front();
//关于注册后调用次数问题,可以在用户代码中计数处理,这里不在实现
for (auto iter = 0; iter< KeyboardListeners.size(); iter++)
KeyboardListeners.at(iter)->handleKeyboardCallBack(event->getKey());
queueKeyboard.pop();
}
}
void EventDispatch::MouseListeners_Clear()
{
MouseListeners.clear();
} |
70e7d57699f709a385ecf24f817f565ba94e92e0 | dcb70454adbb1dcc2c1b1588a17abd6175b0bfaf | /src/periphery/VPM.cpp | 914f5c2f8f8e883bca4c6ce8c3069ae0ba868cc0 | [
"MIT"
] | permissive | sibnick/VC4C | 1ecb5cbe88539fbff296af1e2223a84c931908b4 | dc99d28b1cb28ff4e92d66ce4e261276a2f948d4 | refs/heads/master | 2021-07-13T15:01:55.024407 | 2017-10-16T09:44:57 | 2017-10-16T09:47:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,947 | cpp | VPM.cpp | /*
* Author: doe300
*
* See the file "LICENSE" for the full license governing this code.
*/
#include "VPM.h"
#include "log.h"
using namespace vc4c;
using namespace vc4c::periphery;
using namespace vc4c::intermediate;
static long getVPMSize(const DataType& paramType)
{
//documentation, table 32 (page 57)
switch(paramType.getScalarBitCount())
{
case 8:
return 0;
case 16:
return 1;
case 32:
return 2;
default:
throw CompilationError(CompilationStep::CODE_GENERATION, "Invalid parameter type-size", std::to_string(paramType.getScalarBitCount()));
}
}
static long getVPMDMAMode(const DataType& paramType)
{
//documentation, table 34 (page 58) / table 36 (page 59)
//The offset is added initially onto the address, so don't set it (it will skip to write the first byte(s)/half word)
switch(paramType.getScalarBitCount())
{
case 8:
return 4; //use byte-wise addressing with offset 1 byte
case 16:
return 2; //use half-word wise addressing with offset of a half word
case 32:
return 0;
default:
throw CompilationError(CompilationStep::CODE_GENERATION, "Invalid parameter type-size", std::to_string(paramType.getScalarBitCount()));
}
}
/*
static InstructionWalker insertConfigureVPRDMA(InstructionWalker it, const DataType& destType, const uint8_t numVectors = 1)
{
//for some additional information, see
//http://maazl.de/project/vc4asm/doc/VideoCoreIV-addendum.html
//initialize VPM DMA for reading from host
const long dmaMode = getVPMDMAMode(destType);
const VPRSetup dmaSetup(VPRDMASetup(dmaMode, destType.getVectorWidth(true) % 16 / * 0 => 16 * /, numVectors % 16 / * 0 => 16 * /));
it.emplace(new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(dmaSetup))));
it.nextInBlock();
const VPRSetup strideSetup(VPRStrideSetup(destType.getPhysicalWidth()));
it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(strideSetup))));
return it.nextInBlock();
}
*/
InstructionWalker periphery::insertReadDMA(Method& method, InstructionWalker it, const Value& dest, const Value& addr, const bool useMutex)
{
/*
if(addr.hasType(ValueType::LOCAL))
{
//set the type of the parameter, if we can determine it
if(dynamic_cast<const Parameter*>(addr.local) != nullptr)
dynamic_cast<Parameter*>(addr.local)->decorations = add_flag(dynamic_cast<const Parameter*>(addr.local)->decorations, ParameterDecorations::INPUT);
if(addr.local->reference.first != nullptr && dynamic_cast<const Parameter*>(addr.local->reference.first) != nullptr)
dynamic_cast<Parameter*>(addr.local->reference.first)->decorations = add_flag(dynamic_cast<const Parameter*>(addr.local->reference.first)->decorations, ParameterDecorations::INPUT);
}
if(useMutex)
{
//acquire mutex
it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
it.nextInBlock();
}
/ *
* Reading memory has two step: (see https://www.raspberrypi.org/forums/viewtopic.php?p=1143940&sid=dc1d1cceda5f0b407b2bfca9ae3422ec#p1143940)
* 1. reading from memory into VPM via DMA
* 2. reading from VPM into QPU
*
* So we need these steps:
* 1. configure VPM DMA
* 2. set memory address
* 3. wait for DMA to finish
* 4. configure VPR
* 5. read value
* /
//1) configure VPR DMA to read from memory into VPM
it = insertConfigureVPRDMA(it, dest.type);
//2) write input-argument base address + offset/index into VPM_ADDR
//"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
it.emplace(new MoveOperation(VPM_IN_ADDR_REGISTER, addr));
it.nextInBlock();
//3) wait for DMA to finish loading into VPM
//"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
it.emplace( new MoveOperation(NOP_REGISTER, VPM_IN_WAIT_REGISTER));
it.nextInBlock();
//4) configure reading from VPM into QPU
const auto size = getVPMSize(dest.type);
const VPRSetup genericSetup(VPRGenericSetup(size, TYPE_INT32.getScalarBitCount() / dest.type.getScalarBitCount()));
it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(genericSetup))));
it.nextInBlock();
//5) read value from VPM
it.emplace( new MoveOperation(dest, VPM_IO_REGISTER));
it.nextInBlock();
if(useMutex)
{
//free mutex
it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
it.nextInBlock();
}
return it;
*/
if(useMutex)
{
//acquire mutex
it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
it.nextInBlock();
}
it = method.vpm->insertReadRAM(it, addr, dest.type, false);
it = method.vpm->insertReadVPM(it, dest, false);
if(useMutex)
{
//free mutex
it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
it.nextInBlock();
}
return it;
}
//static InstructionWalker insertConfigureDynamicVPRDMA(InstructionWalker it, Method& method, const Value& numComponents, const Value& componentWidth, const Value& numVectors = INT_ONE)
//{
// const uint32_t VPM_READ_DMA_SETUP = 0 | (1 << 31) | (0 << 24) /* | (destType.num % 16 << 20) */ /* | (numVectors % 16 << 16) */ | (1 << 12) | (0 << 11);
// const Value dmaTemp = method.addNewLocal(TYPE_INT32, "%vpm_dma");
// const Value dmaTemp1 = method.addNewLocal(TYPE_INT32, "%vpm_dma");
// it.emplace( new Operation("and", dmaTemp, numComponents, Value(Literal(0xFFL), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("shl", dmaTemp, dmaTemp, Value(Literal(20L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("or", dmaTemp1, Value(Literal(static_cast<long>(VPM_READ_DMA_SETUP)), TYPE_INT32), dmaTemp));
// it.nextInBlock();
// Value dmaTemp2(UNDEFINED_VALUE);
// if(numVectors.hasType(ValueType::LITERAL))
// {
// dmaTemp2 = Value(Literal((numVectors.literal.integer % 16) << 16), TYPE_INT32);
// }
// else
// {
// dmaTemp2 = method.addNewLocal(TYPE_INT32, "%vpm_dma");
// it.emplace( new Operation("and", dmaTemp2, numVectors, Value(Literal(0xFFL), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("shl", dmaTemp2, dmaTemp2, Value(Literal(16L), TYPE_INT8)));
// it.nextInBlock();
// }
// it.emplace( new Operation("or", dmaTemp1, dmaTemp1, dmaTemp2));
// it.nextInBlock();
// //this does the same as getVPMDMAMode
// // 1 Byte => 4, 2 Bytes => 2, 4 Bytes => 0 -> 8 >> # Bytes
// const Value dmaMode = method.addNewLocal(TYPE_INT8, "%vpm_dma_mode");
// it.emplace( new Operation("shr", dmaMode, Value(Literal(8L), TYPE_INT8), componentWidth));
// it.nextInBlock();
// it.emplace( new Operation("shl", dmaMode, dmaMode, Value(Literal(28L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("or", VPM_IN_SETUP_REGISTER, dmaTemp1, dmaMode));
// it.nextInBlock();
// it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>( 9 << 28))));
// it.nextInBlock();
// return it;
//}
//
//InstructionWalker periphery::insertReadDMADynamic(InstructionWalker it, Method& method, const Value& dest, const Value& addr, const Value& componentWidth, const Value& numComponents, const bool useMutex)
//{
// if(useMutex)
// {
// //acquire mutex
// it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
// it.nextInBlock();
// }
// //1) configure loading from memory into VPM via DMA
// it = insertConfigureDynamicVPRDMA(it, method, numComponents, componentWidth);
// //2) write input-argument base address + offset/index into VPM_ADDR
// //"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
// it.emplace( new MoveOperation(VPM_IN_ADDR_REGISTER, addr));
// it.nextInBlock();
// //3) wait for DMA to finish loading
// //"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
// it.emplace( new MoveOperation(NOP_REGISTER, VPM_IN_WAIT_REGISTER));
// it.nextInBlock();
// //4) configure reading from VPM into QPU
// //Configures the address and mode to read from
// const Value vpmSize = method.addNewLocal(TYPE_INT32, "%vpm_size");
// //this does the same as getVPMSize
// // 1 Byte => 0, 2 Bytes => 1, 4 Bytes => 2 -> # Bytes >> 1
// it.emplace( new Operation("shr", vpmSize, componentWidth, Value(Literal(1L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("shl", vpmSize, vpmSize, Value(Literal(8L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace(new Operation("or", VPM_IN_SETUP_REGISTER, Value(Literal(static_cast<long>(1 << 20 | 1 << 12 | 1 << 11 | 0 << 10 /* | vpmSize << 8 */)), TYPE_INT32), vpmSize));
// it.nextInBlock();
// //5) read value from VPM
// it.emplace(new MoveOperation(dest, VPM_IO_REGISTER));
// it.nextInBlock();
// if(useMutex)
// {
// //free mutex
// it.emplace(new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
// it.nextInBlock();
// }
// return it;
//}
/*
static InstructionWalker insertConfigureVPW(InstructionWalker it, const DataType& sourceType, const uint8_t numVectors = 1)
{
//initialize VPM DMA for writing to host
const long dmaMode = getVPMDMAMode(sourceType);
const VPWSetup dmaSetup(VPWDMASetup(dmaMode, sourceType.getVectorWidth(true), numVectors % 128 / * 0 => 128 * /));
it.emplace( new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(dmaSetup))));
it.nextInBlock();
//set stride to zero
const VPWSetup strideSetup(VPWStrideSetup(0));
it.emplace( new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(strideSetup))));
it.nextInBlock();
//general VPM configuration
const long vpmSize = getVPMSize(sourceType);
const VPWSetup genericSetup(VPWGenericSetup(vpmSize, TYPE_INT32.getScalarBitCount()/sourceType.getScalarBitCount() / * 0 => 64 * /));
it.emplace(new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(genericSetup))));
it.nextInBlock();
return it;
}
*/
InstructionWalker periphery::insertWriteDMA(Method& method, InstructionWalker it, const Value& src, const Value& addr, const bool useMutex)
{
/*
if(addr.hasType(ValueType::LOCAL))
{
//set the type of the parameter, if we can determine it
if(dynamic_cast<const Parameter*>(addr.local) != nullptr)
dynamic_cast<Parameter*>(addr.local)->decorations = add_flag(dynamic_cast<const Parameter*>(addr.local)->decorations, ParameterDecorations::OUTPUT);
if(addr.local->reference.first != nullptr && dynamic_cast<const Parameter*>(addr.local->reference.first) != nullptr)
dynamic_cast<Parameter*>(addr.local->reference.first)->decorations = add_flag(dynamic_cast<const Parameter*>(addr.local->reference.first)->decorations, ParameterDecorations::OUTPUT);
}
if(useMutex)
{
//acquire mutex
it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
it.nextInBlock();
}
//1) (re-)configure VPM
it = insertConfigureVPW(it, src.type);
//2) write value to VPM out-register
it.emplace(new MoveOperation(VPM_IO_REGISTER, src));
it.nextInBlock();
//"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
//3) -> write output-argument base address + offset/index into VPM_ADDR
it.emplace( new MoveOperation(VPM_OUT_ADDR_REGISTER, addr));
it.nextInBlock();
//"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
it.emplace( new MoveOperation(NOP_REGISTER, VPM_OUT_WAIT_REGISTER));
it.nextInBlock();
if(useMutex)
{
//free mutex
it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
it.nextInBlock();
}
return it;
*/
if(useMutex)
{
//acquire mutex
it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
it.nextInBlock();
}
it = method.vpm->insertWriteVPM(it, src, false);
it = method.vpm->insertWriteRAM(it, addr, src.type, false);
if(useMutex)
{
//free mutex
it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
it.nextInBlock();
}
return it;
}
//static InstructionWalker insertConfigureDynamicVPW(InstructionWalker it, Method& method, const Value& numComponents, const Value& componentWidth, const Value& numVectors = INT_ONE)
//{
// //general VPM configuration
// /*
// * - write horizontal
// * - write packed (for sizes < 32-bit, they are written into the same 32-bit word)
// * - set size according to output data-type
// */
// const Value vpmSize = method.addNewLocal(TYPE_INT32, "%vpm_size");
// //this does the same as getVPMSize
// // 1 Byte => 0, 2 Bytes => 1, 4 Bytes => 2 -> # Bytes >> 1
// it.emplace( new Operation("shr", vpmSize, componentWidth, Value(Literal(1L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("shl", vpmSize, vpmSize, Value(Literal(8L), TYPE_INT8)));
// it.nextInBlock();
// it.emplace( new Operation("or", VPM_OUT_SETUP_REGISTER, Value(Literal(static_cast<long>(1 << 11 | 0 << 10 /* | vpmSize << 8 */ | 1 << 20)), TYPE_INT32), vpmSize));
// it.nextInBlock();
// //initialize VPM DMA for writing to host
// /*
// * See Table 34: (page. 58)
// * - configure DMA mode
// * - 1 row (write for every output/QPU separate)
// * - set row depth according to the number of elements in the output-vector
// * - write horizontally
// * - set mode according to output data-type (0 for 32-bit, 2-3 for 16-bit (half word offset), 4-7 for 8-bit (byte offset)
// */
// const uint32_t VPM_WRITE_DMA_SETUP = 0 | (2 << 30) | (1 << 23) /* | (sourceType.num << 16) */ | (1 << 14);
// const Value dmaTemp = method.addNewLocal(TYPE_INT32, "%vpm_dma");
// it.emplace( new Operation("shl", dmaTemp, numComponents, Value(Literal(16L), TYPE_INT8)));
// it.nextInBlock();
// //this does the same as getVPMDMAMode
// // 1 Byte => 4, 2 Bytes => 2, 4 Bytes => 0 -> 8 >> # Bytes
// const Value dmaMode = method.addNewLocal(TYPE_INT8, "%vpm_dma_mode");
// it.emplace( new Operation("shr", dmaMode, Value(Literal(8L), TYPE_INT8), componentWidth));
// it.nextInBlock();
// it.emplace( new Operation("or", dmaTemp, dmaTemp, dmaMode));
// it.nextInBlock();
// it.emplace( new Operation("or", VPM_OUT_SETUP_REGISTER, Value(Literal(static_cast<long>(VPM_WRITE_DMA_SETUP)), TYPE_INT32), dmaTemp));
// it.nextInBlock();
// //set stride to zero
// /*
// * See Table 35 (page 59):
// * - configure DMA stride, set to zero
// */
// const uint32_t VPM_WRITE_STRIDE_SETUP = 0 | (3 << 30);
// it.emplace( new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(VPM_WRITE_STRIDE_SETUP))));
// it.nextInBlock();
// return it;
//}
//
//InstructionWalker periphery::insertWriteDMADynamic(InstructionWalker it, Method& method, const Value& src, const Value& addr, const Value& componentWidth, const Value& numComponents, const bool useMutex)
//{
// if(useMutex)
// {
// //acquire mutex
// it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
// it.nextInBlock();
// }
// //1) (re-)configure VPM
// it = insertConfigureDynamicVPW(it, method, numComponents, componentWidth);
// //2) write value to VPM out-register
// it.emplace( new MoveOperation(VPM_IO_REGISTER, src));
// it.nextInBlock();
// //"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
// //3) -> write output-argument base address + offset/index into VPM_ADDR
// it.emplace( new MoveOperation(VPM_OUT_ADDR_REGISTER, addr));
// it.nextInBlock();
// //"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
// it.emplace( new MoveOperation(NOP_REGISTER, VPM_OUT_WAIT_REGISTER));
// it.nextInBlock();
// if(useMutex)
// {
// //free mutex
// it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
// it.nextInBlock();
// }
// return it;
//}
//InstructionWalker periphery::insertCopyDMA(InstructionWalker it, Method& method, const Value& srcAddr, const Value& destAddr, const DataType& vectorType, const uint8_t numEntries, const bool useMutex)
//{
// //TODO Replace with calls to insertLoadVPM/insertStoreVPM, since they are correct/can be optimized
// //TODO could rewrite, so QPUs do not need to access data, simply load RAM -> VPM and then store VPM -> RAM
// if(numEntries > 16)
// //XXX split into two parts, need to adapt src/dest addresses for upper half
// throw CompilationError(CompilationStep::LLVM_2_IR, "Can only copy 16 elements at a time");
// if(useMutex)
// {
// //acquire mutex
// it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
// it.nextInBlock();
// }
//
// const Value tmp = method.addNewLocal(vectorType, "%copy_tmp");
// //1) configure VPR DMA to read from memory into VPM
// it = insertConfigureVPRDMA(it, tmp.type, numEntries);
// //2) write input-argument base address + offset/index into VPM_ADDR
// //"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
// it.emplace( new MoveOperation(VPM_IN_ADDR_REGISTER, srcAddr));
// it.nextInBlock();
// //3) configure VPW
// it = insertConfigureVPW(it, tmp.type, numEntries);
// //4) wait for DMA to finish loading into VPM
// //"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
// it.emplace( new MoveOperation(NOP_REGISTER, VPM_IN_WAIT_REGISTER));
// it.nextInBlock();
// //5) configure reading from VPM into QPU
// const auto size = getVPMSize(tmp.type);
// const VPRSetup genericVPRSetup(VPRGenericSetup(size, TYPE_INT32.getScalarBitCount() / tmp.type.getScalarBitCount(), numEntries % 16 /* 0 => 16 */));
// it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(genericVPRSetup.value))));
// it.nextInBlock();
// //6) read values from VPM and store into VPW
// for(std::size_t i = 0; i < numEntries; ++i)
// {
// it.emplace( new MoveOperation(tmp, VPM_IO_REGISTER));
// it.nextInBlock();
// it.emplace( new MoveOperation(VPM_IO_REGISTER, tmp));
// it.nextInBlock();
// }
// //7) write VPW to memory and wait for it to be finished
// //"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
// it.emplace( new MoveOperation(VPM_OUT_ADDR_REGISTER, destAddr));
// it.nextInBlock();
// //"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
// it.emplace( new MoveOperation(NOP_REGISTER, VPM_OUT_WAIT_REGISTER));
// it.nextInBlock();
//
// if(useMutex)
// {
// //free mutex
// it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
// it.nextInBlock();
// }
// return it;
//}
std::pair<DataType, uint8_t> getBestVectorSize(const long numBytes)
{
for(uint8_t numElements = 16; numElements > 0; --numElements)
{
//16, 15, 14, ... elements of type...
for(uint8_t typeSize = 4; typeSize > 0; typeSize /= 2)
{
//4 bytes (int), 2 bytes(short), 1 byte (char)
if(numBytes % (numElements * typeSize) == 0)
{
DataType result = typeSize == 4 ? TYPE_INT32 : typeSize == 2 ? TYPE_INT16 : TYPE_INT8;
result.num = numElements;
uint8_t numVectors = numBytes / (numElements * typeSize);
return std::make_pair(result, numVectors);
}
}
}
throw CompilationError(CompilationStep::LLVM_2_IR, "Failed to find element- and vector-sizes matching the given amount of bytes", std::to_string(numBytes));
}
static uint8_t calculateAddress(const DataType& type, unsigned byteOffset)
{
//see Broadcom spec, pages 57, 58 and figure 8 (page 54)
//Y coord is the multiple of 16 * 32-bit (= 64 Byte)
//B coord is the byte [0, 1, 2, 3] in the word
//H coord is the half-word [0, 1] in the word
//the stride is always 32-bit and the pack-mode is always laned
//XXX for now, we always address in size of 16-element vectors, since there is now way to address the upper-half of an 16-element vector (correct?)
//check alignment
if((byteOffset * 8) % (16 * type.getScalarBitCount()) != 0)
throw CompilationError(CompilationStep::GENERAL, "Invalid alignment in VPM for type", type.to_string());
//TODO correct?? needs testing!
uint8_t yCoord = byteOffset / 64;
uint8_t remainder = byteOffset % 64;
if(type.getScalarBitCount() == 32)
//"ADDR[5:0] = Y[5:0]"
return yCoord;
else if(type.getScalarBitCount() == 16)
// "ADDR[6:0] = Y[5:0] | H[0]"
return (yCoord << 1) | (remainder / 32);
else if(type.getScalarBitCount() == 8)
// "ADDR[7:0] = Y[5:0] | B[1:0]"
return (yCoord << 2) | (remainder / 16);
else
throw CompilationError(CompilationStep::GENERAL, "Invalid bit-width to store in VPM", type.to_string());
}
InstructionWalker VPM::insertReadVPM(InstructionWalker it, const Value& dest, bool useMutex)
{
updateScratchSize(dest.type.getPhysicalWidth());
it = insertLockMutex(it, useMutex);
//1) configure reading from VPM into QPU
const auto size = getVPMSize(dest.type);
const VPRSetup genericSetup(VPRGenericSetup(size, TYPE_INT32.getScalarBitCount() / dest.type.getScalarBitCount(), calculateAddress(dest.type, 0)));
it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(genericSetup))));
it.nextInBlock();
//2) read value from VPM
it.emplace( new MoveOperation(dest, VPM_IO_REGISTER));
it.nextInBlock();
it = insertUnlockMutex(it, useMutex);
return it;
}
InstructionWalker VPM::insertWriteVPM(InstructionWalker it, const Value& src, bool useMutex)
{
updateScratchSize(src.type.getPhysicalWidth());
it = insertLockMutex(it, useMutex);
//1. configure writing from QPU into VPM
const long vpmSize = getVPMSize(src.type);
const VPWSetup genericSetup(VPWGenericSetup(vpmSize, TYPE_INT32.getScalarBitCount() / src.type.getScalarBitCount(), calculateAddress(src.type, 0)));
it.emplace(new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(genericSetup))));
it.nextInBlock();
//2. write data to VPM
it.emplace(new MoveOperation(VPM_IO_REGISTER, src));
it.nextInBlock();
it = insertUnlockMutex(it, useMutex);
return it;
}
InstructionWalker VPM::insertReadRAM(InstructionWalker it, const Value& memoryAddress, const DataType& type, bool useMutex)
{
if(memoryAddress.hasType(ValueType::LOCAL) && memoryAddress.local != nullptr)
{
//set the type of the parameter, if we can determine it
if(memoryAddress.local->as<Parameter>() != nullptr)
memoryAddress.local->as<Parameter>()->decorations = add_flag(memoryAddress.local->as<Parameter>()->decorations, ParameterDecorations::INPUT);
if(memoryAddress.local->reference.first != nullptr && memoryAddress.local->reference.first->as<Parameter>() != nullptr)
memoryAddress.local->reference.first->as<Parameter>()->decorations = add_flag(memoryAddress.local->reference.first->as<Parameter>()->decorations, ParameterDecorations::INPUT);
}
it = insertLockMutex(it, useMutex);
//for some additional information, see
//http://maazl.de/project/vc4asm/doc/VideoCoreIV-addendum.html
//initialize VPM DMA for reading from host
const long dmaMode = getVPMDMAMode(type);
VPRSetup dmaSetup(VPRDMASetup(dmaMode, type.getVectorWidth(true) % 16 /* 0 => 16 */, 1 % 16 /* 0 => 16 */));
dmaSetup.dmaSetup.setAddress(0);
it.emplace(new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(dmaSetup))));
it.nextInBlock();
const VPRSetup strideSetup(VPRStrideSetup(type.getPhysicalWidth()));
it.emplace( new LoadImmediate(VPM_IN_SETUP_REGISTER, Literal(static_cast<long>(strideSetup))));
it.nextInBlock();
//"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
//-> write output-argument base address + offset/index into VPM_ADDR
it.emplace( new MoveOperation(VPM_IN_ADDR_REGISTER, memoryAddress));
it.nextInBlock();
//"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
it.emplace( new MoveOperation(NOP_REGISTER, VPM_IN_WAIT_REGISTER));
it.nextInBlock();
it = insertUnlockMutex(it, useMutex);
return it;
}
InstructionWalker VPM::insertWriteRAM(InstructionWalker it, const Value& memoryAddress, const DataType& type, bool useMutex)
{
if(memoryAddress.hasType(ValueType::LOCAL) && memoryAddress.local != nullptr)
{
//set the type of the parameter, if we can determine it
if(memoryAddress.local->as<Parameter>() != nullptr)
memoryAddress.local->as<Parameter>()->decorations = add_flag(memoryAddress.local->as<Parameter>()->decorations, ParameterDecorations::OUTPUT);
if(memoryAddress.local->reference.first != nullptr && memoryAddress.local->reference.first->as<Parameter>() != nullptr)
memoryAddress.local->reference.first->as<Parameter>()->decorations = add_flag(memoryAddress.local->reference.first->as<Parameter>()->decorations, ParameterDecorations::OUTPUT);
}
it = insertLockMutex(it, useMutex);
//initialize VPM DMA for writing to host
const long dmaMode = getVPMDMAMode(type);
VPWSetup dmaSetup(VPWDMASetup(dmaMode, type.getVectorWidth(true), 1 % 128 /* 0 => 128 */));
dmaSetup.dmaSetup.setVPMBase(0);
it.emplace( new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(dmaSetup))));
it.nextInBlock();
//set stride to zero
const VPWSetup strideSetup(VPWStrideSetup(0));
it.emplace( new LoadImmediate(VPM_OUT_SETUP_REGISTER, Literal(static_cast<long>(strideSetup))));
it.nextInBlock();
//"the actual DMA load or store operation is initiated by writing the memory address to the VCD_LD_ADDR or VCD_ST_ADDR register" (p. 56)
//-> write output-argument base address + offset/index into VPM_ADDR
it.emplace( new MoveOperation(VPM_OUT_ADDR_REGISTER, memoryAddress));
it.nextInBlock();
//"A new DMA load or store operation cannot be started until the previous one is complete" (p. 56)
it.emplace( new MoveOperation(NOP_REGISTER, VPM_OUT_WAIT_REGISTER));
it.nextInBlock();
it = insertUnlockMutex(it, useMutex);
return it;
}
InstructionWalker VPM::insertCopyRAM(Method& method, InstructionWalker it, const Value& destAddress, const Value& srcAddress, const unsigned numBytes, bool useMutex)
{
const auto size = getBestVectorSize(numBytes);
updateScratchSize(size.first.getPhysicalWidth());
it = insertLockMutex(it, useMutex);
it = insertReadRAM(it, srcAddress, size.first, false);
it = insertWriteRAM(it, destAddress, size.first, false);
for(uint8_t i = 1; i < size.second; ++i)
{
const Value tmpSource = method.addNewLocal(srcAddress.type, "%mem_copy_addr");
const Value tmpDest = method.addNewLocal(destAddress.type, "%mem_copy_addr");
//increment offset from base address
it.emplace(new Operation("add", tmpSource, srcAddress, Value(Literal(static_cast<long>(i * size.first.getPhysicalWidth())), TYPE_INT8)));
it.nextInBlock();
it.emplace(new Operation("add", tmpDest, destAddress, Value(Literal(static_cast<long>(i * size.first.getPhysicalWidth())), TYPE_INT8)));
it.nextInBlock();
it = insertReadRAM(it, tmpSource, size.first, false);
it = insertWriteRAM(it, tmpDest, size.first, false);
}
it = insertUnlockMutex(it, useMutex);
return it;
}
VPM::VPM(const unsigned totalVPMSize) : maximumVPMSize(totalVPMSize), areas(), isScratchLocked(false)
{
areas.push_back(VPMArea{VPMUsage::GENERAL_DMA, 0, 0, nullptr});
}
VPMArea& VPM::getScratchArea()
{
return areas.front();
}
VPMArea* VPM::findArea(const Local* local)
{
for(VPMArea& area : areas)
if(area.dmaAddress == local)
return &area;
return nullptr;
}
VPMArea* VPM::addArea(const Local* local, unsigned requestedSize, bool alignToBack)
{
VPMArea* area = findArea(local);
if(area != nullptr && area->size >= requestedSize)
return area;
//TODO find free consecutive space in VPM with the requested size and return it
//no more (big enough) free space on VPM
return nullptr;
}
unsigned VPM::getMaxCacheVectors(const DataType& type, bool writeAccess) const
{
if(writeAccess)
return std::min(63u, (maximumVPMSize / 16) / (type.getScalarBitCount() / 8));
return std::min(15u, (maximumVPMSize / 16) / (type.getScalarBitCount() / 8));
}
void VPM::updateScratchSize(unsigned requestedSize)
{
if(isScratchLocked)
throw CompilationError(CompilationStep::GENERAL, "Size of the scratch area is already locked");
if(requestedSize > maximumVPMSize)
throw CompilationError(CompilationStep::GENERAL, "The requested size of the scratch area exceeds the total VPM size", std::to_string(requestedSize));
if(getScratchArea().size < requestedSize)
logging::debug() << "Increased the scratch size to " << requestedSize << " bytes" << logging::endl;
//TODO is this correct?
//Since we do not store all data completely packed, do we?
getScratchArea().size = std::max(getScratchArea().size, requestedSize);
}
InstructionWalker VPM::insertLockMutex(InstructionWalker it, bool useMutex) const
{
if(useMutex)
{
//acquire mutex
it.emplace( new MoveOperation(NOP_REGISTER, MUTEX_REGISTER));
it.nextInBlock();
}
return it;
}
InstructionWalker VPM::insertUnlockMutex(InstructionWalker it, bool useMutex) const
{
if(useMutex)
{
//free mutex
it.emplace( new MoveOperation(MUTEX_REGISTER, BOOL_TRUE));
it.nextInBlock();
}
return it;
}
|
016aabc098c954617771290acccdfbe3356cceea | a21517ae4c20e7780fbb87612f5a478c399299c5 | /Contest/codeforces/r642/B.cpp | 528d0fc9b8660bc62ff2bfd8085fe7b22192034a | [] | no_license | abhishek-987/CompetitiveProgramming | f5afd2077530f7b50f7a3b04e5ca3e9dcb35aaf2 | c773cbe1c4f758d428ef9fe6f5b6c482e88f4ddc | refs/heads/master | 2022-03-07T14:44:46.456600 | 2022-02-27T12:17:13 | 2022-02-27T12:17:13 | 186,524,874 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,484 | cpp | B.cpp | #include <bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define um unordered_map
#define all(x) (x).begin(),(x).end()
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define forb(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forf(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
typedef long double ld; typedef long long ll;
typedef vector<int> vi; typedef vector<pair<int, int>> vpi; typedef vector<vi> vvi;
typedef vector<ll> vll; typedef vector<pair<ll, ll>> vpll; typedef vector<vll> vvll;
const ll MOD = 1e9+7, INF = 1e18;
/********************************************************************************/
int32_t main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cout.precision(10); cout << fixed;
int t;
cin>>t;
while(t--){
int n,k;
cin>>n>>k;
int a[n];
int b[n];
forn(i,n) cin>>a[i];
forn(i,n) cin>>b[i];
sort(a,a+n,greater<int>());
sort(b,b+n,greater<int>());
int r=n,f=0,g=0,ans=0;
while(r--){
if(a[f]>b[g]){
ans+=a[f];
f++;
}else{
if(k>0){
ans+=b[g];
g++;
k--;
}else{
ans+=a[f];
f++;
}
}
}
cout<<ans<<endl;
}
return 0;
} |
2695a142626bba42c9afdd210d0383d1d66ee16b | a41dcb5e59db36172644bf072879679df4adb65f | /LB10/LB10/Altmer.cpp | a55dcdb2856b18b4c9b65e3732d949b0551dc7e7 | [] | no_license | SalminaTatyana/OOP_LB10 | ab2b9cc11332bee2fa60735aa1892bc7efd1e150 | a193a70a59cbc47ece3e2b546e7419a6fcb1c229 | refs/heads/main | 2023-08-31T00:27:25.455867 | 2021-10-24T15:04:42 | 2021-10-24T15:04:42 | null | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 316 | cpp | Altmer.cpp | #include "Altmer.h"
Altmer::Altmer()
{
this->age = 200;
this->race = "Эльфы";
this->maxage = 575;
this->alch = 15;
this->magic = 25;
this->msg = "Высокие эльфы от рождения имеют 50 дополнительных единиц магии.";
}
Altmer::~Altmer()
{
}
|
df83ceab34d9c4524e16c25483cbf668301d7647 | f83ef53177180ebfeb5a3e230aa29794f52ce1fc | /opencv/opencv-2.4.13.6/modules/ocl/src/split_merge.cpp | 5d98ddbd1a65992749f7ad162b83215d7831ffa7 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | msrLi/portingSources | fe7528b3fd08eed4a1b41383c88ee5c09c2294ef | 57d561730ab27804a3172b33807f2bffbc9e52ae | refs/heads/master | 2021-07-08T01:22:29.604203 | 2019-07-10T13:07:06 | 2019-07-10T13:07:06 | 196,183,165 | 2 | 1 | Apache-2.0 | 2020-10-13T14:30:53 | 2019-07-10T10:16:46 | null | UTF-8 | C++ | false | false | 13,679 | cpp | split_merge.cpp | /*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Jia Haipeng, jiahaipeng95@gmail.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "opencl_kernels.hpp"
using namespace cv;
using namespace cv::ocl;
namespace cv
{
namespace ocl
{
namespace split_merge
{
static void merge_vector_run(const oclMat *mat_src, size_t n, oclMat &mat_dst)
{
if(!mat_dst.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && mat_dst.type() == CV_64F)
{
CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
Context *clCxt = mat_dst.clCxt;
int channels = mat_dst.oclchannels();
int depth = mat_dst.depth();
string kernelName = "merge_vector";
int vector_lengths[4][7] = {{0, 0, 0, 0, 0, 0, 0},
{2, 2, 1, 1, 1, 1, 1},
{4, 4, 2, 2 , 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1}
};
size_t vector_length = vector_lengths[channels - 1][depth];
int offset_cols = (mat_dst.offset / mat_dst.elemSize()) & (vector_length - 1);
int cols = divUp(mat_dst.cols + offset_cols, vector_length);
size_t localThreads[3] = { 64, 4, 1 };
size_t globalThreads[3] = { (size_t)cols, (size_t)mat_dst.rows, 1 };
int dst_step1 = mat_dst.cols * mat_dst.elemSize();
vector<pair<size_t , const void *> > args;
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_dst.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.offset));
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[0].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[0].offset));
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[1].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[1].offset));
if(channels == 4)
{
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].offset));
if(n == 3)
{
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[2].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[2].offset));
}
else if( n == 4)
{
args.push_back( make_pair( sizeof(cl_mem), (void *)&mat_src[3].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].step));
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_src[3].offset));
}
}
args.push_back( make_pair( sizeof(cl_int), (void *)&mat_dst.rows));
args.push_back( make_pair( sizeof(cl_int), (void *)&cols));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst_step1));
openCLExecuteKernel(clCxt, &merge_mat, kernelName, globalThreads, localThreads, args, channels, depth);
}
static void merge(const oclMat *mat_src, size_t n, oclMat &mat_dst)
{
CV_Assert(mat_src);
CV_Assert(n > 0);
int depth = mat_src[0].depth();
Size size = mat_src[0].size();
int total_channels = 0;
for(size_t i = 0; i < n; ++i)
{
CV_Assert(depth == mat_src[i].depth());
CV_Assert(size == mat_src[i].size());
total_channels += mat_src[i].oclchannels();
}
CV_Assert(total_channels <= 4);
if(total_channels == 1)
{
mat_src[0].copyTo(mat_dst);
return;
}
mat_dst.create(size, CV_MAKETYPE(depth, total_channels));
merge_vector_run(mat_src, n, mat_dst);
}
static void split_vector_run(const oclMat &src, oclMat *dst)
{
if(!src.clCxt->supportsFeature(FEATURE_CL_DOUBLE) && src.type() == CV_64F)
{
CV_Error(CV_OpenCLDoubleNotSupported, "Selected device doesn't support double");
return;
}
Context *clCtx = src.clCxt;
int channels = src.channels();
int depth = src.depth();
depth = (depth == CV_8S) ? CV_8U : depth;
depth = (depth == CV_16S) ? CV_16U : depth;
string kernelName = "split_vector";
size_t VEC_SIZE = 4;
vector<pair<size_t , const void *> > args;
args.push_back( make_pair( sizeof(cl_mem), (void *)&src.data));
args.push_back( make_pair( sizeof(cl_int), (void *)&src.step));
int srcOffsetXBytes = src.offset % src.step;
int srcOffsetY = src.offset / src.step;
cl_int2 srcOffset = {{srcOffsetXBytes, srcOffsetY}};
args.push_back( make_pair( sizeof(cl_int2), (void *)&srcOffset));
bool dst0Aligned = false, dst1Aligned = false, dst2Aligned = false, dst3Aligned = false;
int alignSize = dst[0].elemSize1() * VEC_SIZE;
int alignMask = alignSize - 1;
args.push_back( make_pair( sizeof(cl_mem), (void *)&dst[0].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst[0].step));
int dst0OffsetXBytes = dst[0].offset % dst[0].step;
int dst0OffsetY = dst[0].offset / dst[0].step;
cl_int2 dst0Offset = {{dst0OffsetXBytes, dst0OffsetY}};
args.push_back( make_pair( sizeof(cl_int2), (void *)&dst0Offset));
if ((dst0OffsetXBytes & alignMask) == 0)
dst0Aligned = true;
args.push_back( make_pair( sizeof(cl_mem), (void *)&dst[1].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst[1].step));
int dst1OffsetXBytes = dst[1].offset % dst[1].step;
int dst1OffsetY = dst[1].offset / dst[1].step;
cl_int2 dst1Offset = {{dst1OffsetXBytes, dst1OffsetY}};
args.push_back( make_pair( sizeof(cl_int2), (void *)&dst1Offset));
if ((dst1OffsetXBytes & alignMask) == 0)
dst1Aligned = true;
// DON'T MOVE VARIABLES INTO 'IF' BODY
int dst2OffsetXBytes, dst2OffsetY;
cl_int2 dst2Offset;
int dst3OffsetXBytes, dst3OffsetY;
cl_int2 dst3Offset;
if (channels >= 3)
{
args.push_back( make_pair( sizeof(cl_mem), (void *)&dst[2].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst[2].step));
dst2OffsetXBytes = dst[2].offset % dst[2].step;
dst2OffsetY = dst[2].offset / dst[2].step;
dst2Offset.s[0] = dst2OffsetXBytes; dst2Offset.s[1] = dst2OffsetY;
args.push_back( make_pair( sizeof(cl_int2), (void *)&dst2Offset));
if ((dst2OffsetXBytes & alignMask) == 0)
dst2Aligned = true;
}
if (channels >= 4)
{
args.push_back( make_pair( sizeof(cl_mem), (void *)&dst[3].data));
args.push_back( make_pair( sizeof(cl_int), (void *)&dst[3].step));
dst3OffsetXBytes = dst[3].offset % dst[3].step;
dst3OffsetY = dst[3].offset / dst[3].step;
dst3Offset.s[0] = dst3OffsetXBytes; dst3Offset.s[1] = dst3OffsetY;
args.push_back( make_pair( sizeof(cl_int2), (void *)&dst3Offset));
if ((dst3OffsetXBytes & alignMask) == 0)
dst3Aligned = true;
}
cl_int2 size = {{ src.cols, src.rows }};
args.push_back( make_pair( sizeof(cl_int2), (void *)&size));
string build_options =
cv::format("-D VEC_SIZE=%d -D DATA_DEPTH=%d -D DATA_CHAN=%d",
(int)VEC_SIZE, depth, channels);
if (dst0Aligned)
build_options += " -D DST0_ALIGNED";
if (dst1Aligned)
build_options += " -D DST1_ALIGNED";
if (dst2Aligned)
build_options += " -D DST2_ALIGNED";
if (dst3Aligned)
build_options += " -D DST3_ALIGNED";
const DeviceInfo& devInfo = clCtx->getDeviceInfo();
// TODO Workaround for issues. Need to investigate a problem.
if (channels == 2
&& devInfo.deviceType == CVCL_DEVICE_TYPE_CPU
&& devInfo.platform->platformVendor.find("Intel") != std::string::npos
&& (devInfo.deviceVersion.find("Build 56860") != std::string::npos
|| devInfo.deviceVersion.find("Build 76921") != std::string::npos
|| devInfo.deviceVersion.find("Build 78712") != std::string::npos))
build_options += " -D BYPASS_VSTORE=true";
size_t globalThreads[3] = { divUp(src.cols, VEC_SIZE), (size_t)src.rows, 1 };
openCLExecuteKernel(clCtx, &split_mat, kernelName, globalThreads, NULL, args, -1, -1, build_options.c_str());
}
static void split(const oclMat &mat_src, oclMat *mat_dst)
{
CV_Assert(mat_dst);
int depth = mat_src.depth();
int num_channels = mat_src.channels();
Size size = mat_src.size();
if (num_channels == 1)
{
mat_src.copyTo(mat_dst[0]);
return;
}
for (int i = 0; i < mat_src.oclchannels(); i++)
mat_dst[i].create(size, CV_MAKETYPE(depth, 1));
split_vector_run(mat_src, mat_dst);
}
}
}
}
void cv::ocl::merge(const oclMat *src, size_t n, oclMat &dst)
{
split_merge::merge(src, n, dst);
}
void cv::ocl::merge(const vector<oclMat> &src, oclMat &dst)
{
split_merge::merge(&src[0], src.size(), dst);
}
void cv::ocl::split(const oclMat &src, oclMat *dst)
{
split_merge::split(src, dst);
}
void cv::ocl::split(const oclMat &src, vector<oclMat> &dst)
{
dst.resize(src.oclchannels()); // TODO Why oclchannels?
if(src.oclchannels() > 0)
split_merge::split(src, &dst[0]);
}
|
1aca35c7ade5871b5ba6a584ca152e5254e5a1fd | d909fcfdc7bfa827646155eb0ff040ee232abd3d | /utils/Timer.cpp | a49d67133d55774b9df49d9887c600c9b8786e52 | [] | no_license | smsolivier/DGTRT | fe75fed9e6b2d6fb9223aa1551cd7c3535cd29ad | adb26be8cee67ce355367c8b77c42ca316a9c624 | refs/heads/master | 2020-04-09T06:38:03.661031 | 2018-12-03T02:40:38 | 2018-12-03T02:40:38 | 160,120,898 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 411 | cpp | Timer.cpp | #include "Timer.hpp"
using namespace std;
namespace trt
{
void Timer::Start() {
_start = chrono::system_clock::now();
}
void Timer::Stop() {
_el = chrono::system_clock::now() - _start;
}
ostream& operator<<(ostream& out, const Timer& t) {
double count = t.GetDuration();
out << count << " ";
if (count > 60) {
out << "min";
} else {
out << "s";
}
return out;
}
} // end namespace trt |
1264abfa50d74c3c5cfe7b1a5996f646ddcaeff0 | dc0c9ea3fa7498b0552b5f0cdd121489404cb07a | /timus/1081.cpp | 4022a6cbb98965c7422468c3aeb696a908594f55 | [] | no_license | alaneos777/club | 226e7e86983da7f87d87efbfd47d42326872dd25 | 47da01e884d6324aa1c9f701d6f70b8b978a0e18 | refs/heads/master | 2023-08-05T02:43:33.428365 | 2023-07-29T02:43:58 | 2023-07-29T02:43:58 | 143,675,419 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 591 | cpp | 1081.cpp | #include <bits/stdc++.h>
using namespace std;
vector<int> F(47);
int nearestF(int Fn){
if(Fn == 1) return 2;
int i = lower_bound(F.begin(), F.end(), Fn) - F.begin();
if(F[i] != Fn) i--;
return i;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
F[0] = 0, F[1] = 1;
for(int i = 2; i <= 46; i++){
F[i] = F[i - 1] + F[i - 2];
}
int n, k;
cin >> n >> k;
string ans = "";
ans.append(n, '0');
k--;
if(k >= F[n + 2]){
cout << "-1\n";
}else{
while(k > 0){
int i = nearestF(k);
ans[n - 1 - (i - 2)] = '1';
k -= F[i];
}
cout << ans << "\n";
}
return 0;
} |
ca4b0c4a16f4ae995b4bd06153ee89b8f969c28f | 6f885bc26e67694258a93d7f9ab55b2da5e629dc | /401C.cpp | 2367c0e9ba88553297b277a524eaabc9bb131616 | [] | no_license | Ashik1704026/codeforce | 644121030b3fdadb5405451f2e3b857acb7203d6 | 04b6d72b739cdf4bc3ce7e68e6dc72ebf983ab20 | refs/heads/master | 2021-11-22T14:23:47.848180 | 2021-08-30T18:18:11 | 2021-08-30T18:18:11 | 223,139,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 400 | cpp | 401C.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m;
if(n>m+1 || m>(2*n)+2){
cout<<"-1";
return 0;
}
int flag=0;
if(n>=m) flag=1;
while(n!=0 || m!=0){
if(flag){ cout<<"0",n--;flag=0;}
else if(m>n+1 && flag==0){ cout<<"11",m-=2;flag=1;}
else if(m>=n && flag==0){cout<<"1",m--;flag=1;}
}
return 0;
} |
a5ff050a6490317d27f161f2f85a5790ae4f6473 | edc1c2488380f463290bac1f6bdc9e6b20e1780e | /test-queue.cpp | 7200432eca99ce78b9d28a5bd9f347b7fc351c15 | [] | no_license | Coderrine/A1Part2 | d04ad95f3effa46e4f584ba617834bf68f774592 | 3eb5af5edf6da182d3b079dc0a1d48ca9fece11e | refs/heads/master | 2020-12-23T20:04:32.448723 | 2020-01-30T01:17:43 | 2020-01-30T01:17:43 | 237,259,104 | 0 | 0 | null | 2020-01-30T16:51:02 | 2020-01-30T16:51:02 | null | UTF-8 | C++ | false | false | 4,637 | cpp | test-queue.cpp | #include <stdlib.h>
#include <stdio.h>
#include "object.h"
#include "string.h"
#include "queue.h"
/**
* Program to test the functionality of the queue
* @author: Conor Paschenko <paschenko.c@husky.neu.edu>, James Herbstritt <herbstritt.j@husky.neu.edu>
*/
// prints a fail message to stderr then exits the process
void FAIL(const char* msg) {
fprintf(stderr, "failed: %s\n", msg);
exit(1);
}
// prints a success message to stdout
void OK(const char* msg) {
printf("success: %s\n", msg);
}
// fails the process if a given boolean expression p is false, continues otherwise
void t_true(bool p, const char* msg) {
if (!p) FAIL(msg);
}
// two Queue's are equal when they have the same elements in the same order
void equal_test() {
String* s1 = new String("String one");
Object* o2 = new Object();
Queue* q1 = new Queue();
Queue* q2 = new Queue();
t_true(q1->equals(q2), "empty queues are equal");
q1->queue_push(s1);
t_true(!q1->equals(q2), "q1 and q2 are not equal");
q2->queue_push(s1);
t_true(q1->equals(q2), "q1 is equal to q2");
q1->queue_push(o2);
q1->queue_push(s1);
q1->queue_push(s1);
q2->queue_push(o2);
q2->queue_push(s1);
t_true(!q1->equals(q2), "q1 should not equal q2");
OK("equal");
delete q1;
delete q2;
delete s1;
delete o2;
}
// checks if hashes are same which implies the two are equal
void queue_hashes() {
String* s1 = new String("hash");
String* s2 = new String("hash");
Queue* q1 = new Queue();
Queue* q2 = new Queue();
q1->queue_push(s1);
q2->queue_push(s2);
t_true(q1->equals(q2), "q1 equals q2");
t_true(q1->hash() == q2->hash(), "queues have the same hash and are therefore equal");
OK("queue hashes");
delete q1;
delete q2;
delete s1;
delete s2;
}
// size increases as elements are pushed
void queue_push_increase_size() {
Object* o1 = new Object();
Object* o2 = new Object();
Queue* q1 = new Queue();
t_true(q1->getSize() == 0, "initial size is 0");
q1->queue_push(o1);
t_true(q1->getSize() == 1, "size increases to 1");
q1->queue_push(o1);
q1->queue_push(o1);
q1->queue_push(o1);
t_true(q1->getSize() == 4, "size increases to 4");
OK("size increases correctly");
delete q1;
delete o1;
delete o2;
}
// size decreases as elements are popped
void queue_pop_decrease_size() {
Object* o1 = new Object();
Object* o2 = new Object();
Queue* q1 = new Queue();
q1->queue_push(o1);
q1->queue_push(o2);
q1->queue_push(o2);
q1->queue_push(o1);
q1->queue_push(o1);
t_true(q1->getSize() == 5, "size is 5");
q1->queue_pop();
t_true(q1->getSize() == 4, "size decreases to 4");
q1->queue_pop();
q1->queue_pop();
t_true(q1->getSize() == 2, "size decreases to 2");
q1->queue_pop();
q1->queue_pop();
q1->queue_pop();
q1->queue_pop();
t_true(q1->getSize() == 0, "size remains at 0");
OK("size decreases correctly");
delete q1;
delete o1;
delete o2;
}
// correct elements are popped
void queue_pop() {
String* s1 = new String("one");
String* s2 = new String("two");
String* s3 = new String("three");
Queue* q1 = new Queue();
q1->queue_push(s1);
q1->queue_push(s2);
q1->queue_push(s3);
t_true(s1->equals(q1->queue_pop()), "s1 should be popped");
t_true(s2->equals(q1->queue_pop()), "s2 should be popped");
t_true(s3->equals(q1->queue_pop()), "s3 should be popped");
OK("pop works correctly");
delete q1;
delete s1;
delete s2;
delete s3;
}
// peeking returns the Queue's top element but does not remove it
void queue_frontElement() {
String* s1 = new String("first");
String* s2 = new String("second");
Queue* q1 = new Queue();
q1->queue_push(s1);
q1->queue_push(s2);
t_true(q1->getSize() == 2, "size is 2 before the peek");
t_true(s1->equals(q1->frontElement()), "s1 is the top element");
t_true(q1->getSize() == 2, "size is 2 after the peek");
OK("queue peek");
delete q1;
delete s1;
delete s2;
}
// popping or peeking an empty Queue should return a nullptr
void queue_pop_peek_empty() {
String* s1 = new String("dummy");
Queue* q1 = new Queue();
q1->queue_push(s1);
t_true(s1->equals(q1->queue_pop()), "popping once returns s1");
t_true(q1->queue_empty(), "queue should now be empty");
t_true(q1->queue_pop() == nullptr, "popping twice returns nullptr");
t_true(q1->frontElement() == nullptr, "peeking return nullptr");
OK("queue pop peek empty");
delete q1;
delete s1;
}
// runs the tests
int main() {
equal_test();
queue_hashes();
queue_push_increase_size();
queue_pop_decrease_size();
queue_pop();
queue_frontElement();
queue_pop_peek_empty();
return 0;
}
|
0ba2e34ea86b5524c1db2c611fd0f9fa22162c9d | 8495e8201b12c5dca8f3bc1319cbf208f679cb50 | /unit_tests/accumulator_mode_ROL.cpp | 4590b4da7c0056ce272bda84db4b091271e25ff6 | [] | no_license | vcato/qt-quick-6502-emulator | 1eb8afbfab9ad776fed81a0810f5b3912e6756df | 6202e546efddc612f229da078238f829dd756e12 | refs/heads/master | 2021-06-21T13:52:51.234446 | 2021-06-15T01:24:18 | 2021-06-15T01:24:18 | 208,083,263 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,230 | cpp | accumulator_mode_ROL.cpp | #include "addressing_mode_helpers.hpp"
struct ROL_Accumulator_Expectations
{
constexpr ROL_Accumulator_Expectations &accumulator(const uint8_t v) { a = v; return *this; }
uint8_t a;
NZCFlags flags;
};
using ROLAccumulator = ROL<Accumulator, ROL_Accumulator_Expectations, 2>;
using ROLAccumulatorMode = ParameterizedInstructionExecutorTestFixture<ROLAccumulator>;
static void SetupAffectedOrUsedRegisters(InstructionExecutorTestFixture &fixture, const ROLAccumulator &instruction_param)
{
fixture.r.a = instruction_param.requirements.initial.a;
fixture.r.SetFlag(FLAGS6502::N, instruction_param.requirements.initial.flags.n_value.expected_value);
fixture.r.SetFlag(FLAGS6502::Z, instruction_param.requirements.initial.flags.z_value.expected_value);
fixture.r.SetFlag(FLAGS6502::C, instruction_param.requirements.initial.flags.c_value.expected_value);
}
template<>
void LoadInstructionIntoMemoryAndSetRegistersToInitialState( InstructionExecutorTestFixture &fixture,
const ROLAccumulator &instruction_param)
{
SetupRAMForInstructionsThatHaveNoEffectiveAddress(fixture, instruction_param);
SetupAffectedOrUsedRegisters(fixture, instruction_param);
}
template<>
void RegistersAreInExpectedState(const Registers ®isters,
const ROL_Accumulator_Expectations &expectations)
{
EXPECT_THAT(registers.a, Eq(expectations.a));
EXPECT_THAT(registers.GetFlag(FLAGS6502::N), Eq(expectations.flags.n_value.expected_value));
EXPECT_THAT(registers.GetFlag(FLAGS6502::Z), Eq(expectations.flags.z_value.expected_value));
EXPECT_THAT(registers.GetFlag(FLAGS6502::C), Eq(expectations.flags.c_value.expected_value));
}
template<>
void MemoryContainsInstruction(const InstructionExecutorTestFixture &fixture,
const Instruction<AbstractInstruction_e::ROL, Accumulator> &)
{
EXPECT_THAT(fixture.fakeMemory.at( fixture.executor.registers().program_counter ), Eq( OpcodeFor(AbstractInstruction_e::ROL, AddressMode_e::Accumulator) ));
}
template<>
void MemoryContainsExpectedComputation(const InstructionExecutorTestFixture &,
const ROLAccumulator &)
{
// No memory is affected
}
static const std::vector<ROLAccumulator> ROLAccumulatorModeTestValues {
ROLAccumulator{
// Beginning of a page
// Demonstrate the carry bit behavior
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0,
.flags = { } },
.final = {
.a = 0,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = true },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
// Middle of a page
// Demonstrate the carry bit behavior
Accumulator().address(0x8080),
ROLAccumulator::Requirements{
.initial = {
.a = 0,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = true },
.c_value = { .expected_value = true } } },
.final = {
.a = 0b00000001,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
// End of a page
// Demonstrate the carry bit behavior
Accumulator().address(0x80FF),
ROLAccumulator::Requirements{
.initial = {
.a = 0b10000000,
.flags = {
.n_value = { .expected_value = true },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = true },
.c_value = { .expected_value = true } },
}}
},
ROLAccumulator{
// End of a page
// Demonstrate the carry bit behavior
Accumulator().address(0x80FF),
ROLAccumulator::Requirements{
.initial = {
.a = 0b10000000,
.flags = {
.n_value = { .expected_value = true },
.z_value = { .expected_value = false },
.c_value = { .expected_value = true } } },
.final = {
.a = 0b00000001,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = true } },
}}
},
// Check the bit shift through each bit
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00000001,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b00000010,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00000010,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b00000100,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00000100,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b00001000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00001000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b00010000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00010000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b00100000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b00100000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b01000000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
},
ROLAccumulator{
Accumulator().address(0x8000),
ROLAccumulator::Requirements{
.initial = {
.a = 0b01000000,
.flags = {
.n_value = { .expected_value = false },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } } },
.final = {
.a = 0b10000000,
.flags = {
.n_value = { .expected_value = true },
.z_value = { .expected_value = false },
.c_value = { .expected_value = false } },
}}
}
};
TEST_P(ROLAccumulatorMode, TypicalInstructionExecution)
{
TypicalInstructionExecution(*this, GetParam());
}
INSTANTIATE_TEST_SUITE_P(RotateLeftAccumulatorAtVariousAddresses,
ROLAccumulatorMode,
testing::ValuesIn(ROLAccumulatorModeTestValues) );
|
360f369e4e9fd2bd930c12d7aa8f34b086d8d25f | f014956ba5a73313b078fa982386307aa8bd361c | /src/wheelloader/test_HYDR_actuator.cpp | 5b4633949f8658334a59733d18cc252dcf655703 | [
"BSD-3-Clause"
] | permissive | VictorBertolazzo/chrono | eb5f6f14fb44a67dc315a7fdaec2741d1a5fd11b | 9fffb22e4009bbf2958d9c016fb22668c843d505 | refs/heads/develop | 2021-07-09T19:30:37.824545 | 2017-12-10T17:48:13 | 2017-12-10T17:48:13 | 96,514,918 | 0 | 0 | null | 2017-07-07T08:03:53 | 2017-07-07T08:03:53 | null | UTF-8 | C++ | false | false | 4,307 | cpp | test_HYDR_actuator.cpp | // This example computes a double integration on the input pressure function for the displacement-driven pistons.
// It must be merged with hydraulic_force.cpp file
// Victor Bertolazzo
#include <cmath>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <valarray>
#include <vector>
#include "chrono/ChConfig.h"
#include "chrono/core/ChFileutils.h"
#include "chrono/core/ChTimer.h"
#include "chrono/utils/ChUtilsCreators.h"
#include "chrono/utils/ChUtilsGenerators.h"
#include "chrono/utils/ChUtilsInputOutput.h"
#include "chrono_parallel/physics/ChSystemParallel.h"
#include "chrono_parallel/solver/ChIterativeSolverParallel.h"
#include "chrono/motion_functions/ChFunction_Recorder.h"
#include "chrono/motion_functions/ChFunction_Integrate.h"
#include "chrono/motion_functions/ChFunction_Base.h"
#include "chrono/core/ChLog.h"
#include "chrono/core/ChVectorDynamic.h"
#include "chrono/motion_functions/ChFunction_Sine.h"
#include "chrono_postprocess/ChGnuPlot.h"
#define USE_DISPLACEMENT
#ifdef CHRONO_OPENGL
#include "chrono_opengl/ChOpenGLWindow.h"
#endif
using namespace chrono;
using namespace postprocess;
// --------------------------------------------------------------------------
using std::cout;
using std::endl;
// --------------------------------------------------------------------------
//-- CLASSES------------
int main(int argc, char** argv) {
int num_threads = 4;
// Get number of threads from arguments (if specified)
if (argc > 1) {
num_threads = std::stoi(argv[1]);
}
std::cout << "Requested number of threads: " << num_threads << std::endl;
int binsX = 20;
int binsY = 20;
int binsZ = 10;
std::cout << "Broad-phase bins: " << binsX << " x " << binsY << " x " << binsZ << std::endl;
// --------------------------
// Create the parallel system
// --------------------------
// Create system and set method-specific solver settings
chrono::ChSystemParallel* system;
//---Function Creation--//
// Pressure function means the differences (pHead*aHead-pRod*Arod) weighted by *1/m_pist
// Are all these data available? Yes
auto pressure = std::make_shared<ChFunction_Recorder>();
for (int i = 0; i < 10; i++){ pressure->AddPoint(i, 1.); }
// Assuming pres_funct is of type ChFunction_Recorder
double xmin = 0;
double xmax = 15;
pressure->Estimate_x_range(xmin, xmax);// double& x
ChFunction_Integrate fun;
fun.Set_order(2); fun.Set_x_start(xmin); fun.Set_x_end(xmax);
fun.Set_num_samples(10); fun.Set_C_start(0.);
fun.Set_fa(pressure);
fun.ComputeIntegral();
auto speed = std::make_shared<ChFunction_Recorder>();
for (int i = 0; i < 101; i++){
double h = i*(xmax - xmin) / 100;
speed->AddPoint(xmin + h, fun.Get_y(xmin + h));//I'd want to access to array_x(row last, column 0) member
}
speed->Estimate_x_range(xmin, xmax);// double& x
ChFunction_Integrate speed_fun;
speed_fun.Set_order(2); speed_fun.Set_x_start(xmin); speed_fun.Set_x_end(xmax);
speed_fun.Set_num_samples(10); speed_fun.Set_C_start(0.);
speed_fun.Set_fa(speed);
speed_fun.ComputeIntegral();
ChFunction_Recorder pos;
for (int i = 0; i < 101; i++){
double h = i*(xmax - xmin) / 100;
pos.AddPoint(xmin + h, speed_fun.Get_y(xmin + h));//I'd want to access to array_x(row last, column 0) member
}
// Gnuplot
ChGnuPlot mplot("__tmp_gnuplot_4.gpl");
mplot.SetGrid();
mplot.Plot(pos, "Actuator Displacement Function", " with lines lt -1 lc rgb'#00AAEE' ");
// Sanity check: print number of threads in a parallel region
#pragma omp parallel
#pragma omp master
{ std::cout << "Actual number of OpenMP threads: " << omp_get_num_threads() << std::endl; }
// ---------------
// Simulate system
// ---------------
double time_end = 1.00;
double time_step = 1e-4;
double cum_sim_time = 0;
double cum_broad_time = 0;
double cum_narrow_time = 0;
double cum_solver_time = 0;
double cum_update_time = 0;
std::cout << std::endl;
std::cout << "Simulation time: " << cum_sim_time << std::endl;
std::cout << " Broadphase: " << cum_broad_time << std::endl;
std::cout << " Narrowphase: " << cum_narrow_time << std::endl;
std::cout << " Solver: " << cum_solver_time << std::endl;
std::cout << " Update: " << cum_update_time << std::endl;
std::cout << std::endl;
return 0;
} |
9de4098019243c0dcea117824947ce962fe7e849 | 233676e340835a58e8041bdc82c313e599af415c | /Schweizer-Messer/numpy_eigen/src/autogen_test_module/test_3_2_long.cpp | 4728113e6fa6845a26bbd5a7d934f39eec7d44d1 | [
"BSD-3-Clause"
] | permissive | ethz-asl/kalibr | 9213daa87ed191ce1e05fba9f7424204c2d9734c | 94bb8437a72a0d97a491097a7085bf3db4f93bba | refs/heads/master | 2023-08-29T17:04:47.774244 | 2023-08-14T02:08:46 | 2023-08-14T02:08:46 | 20,293,077 | 3,744 | 1,341 | NOASSERTION | 2023-09-10T02:18:47 | 2014-05-29T12:31:48 | C++ | UTF-8 | C++ | false | false | 263 | cpp | test_3_2_long.cpp | #include <Eigen/Core>
#include <numpy_eigen/boost_python_headers.hpp>
Eigen::Matrix<boost::int64_t, 3, 2> test_long_3_2(const Eigen::Matrix<boost::int64_t, 3, 2> & M)
{
return M;
}
void export_long_3_2()
{
boost::python::def("test_long_3_2",test_long_3_2);
}
|
7bffc06462f8556dc520fe24659bc2d013337927 | 59461cfb3126538f3e64146e5f9c211d1d8cf02d | /Leetcode-Mooc/Chapter9-动态规划/Q198_House_Robber.h | 1609ab41c3ee6bb2f9c5333ce58bd8601e43c766 | [] | no_license | shexuan/cpp_practice | 4001ea11dfd2812bcb6b489041326fa8c2dfebe8 | a5b47ee00735ad3fd27d9cfd354ead4f255f26ce | refs/heads/main | 2023-03-17T16:43:43.190405 | 2021-03-06T17:10:03 | 2021-03-06T17:10:03 | 334,880,551 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 729 | h | Q198_House_Robber.h | //
// Created by shexuan on 2021/3/3.
//
#ifndef CHAPTER9__Q198_HOUSE_ROBBER_H
#define CHAPTER9__Q198_HOUSE_ROBBER_H
#include <vector>
using namespace std;
class Solution {
public:
int rob(vector<int>& nums) {
int size_ = nums.size();
if(size_==0) return 0;
if(size_==1) return nums[0];
vector<int> memo(size_+1, -1);
memo[0] = nums[0];
memo[1] = max(nums[0], nums[1]);
// memo[2] = max(memo[1], memo[0]+nums[2])
// 状态转移公式:f(k) = max(f(k-1), f(k-2)+nums[k])
for(int i=2; i<size_; i++){
memo[i] = max(memo[i-1], memo[i-2]+nums[i]);
}
return memo[size_-1];
}
};
#endif //CHAPTER9__Q198_HOUSE_ROBBER_H
|
81f0a768190edcf670aa896dc0817af86c32f777 | a290dc132b70c9739a7493313401eaf8223a6f44 | /objet_chambre/objet_chambre.ino | c84fe2d30a0feb2cb483690e319efca4f4aa143d | [
"MIT"
] | permissive | pbaron2/IoT-chambre | f4953b369984d8909afba0405d36b2260cf3ae44 | 4fac2e63d1c808ddea7fab88b31ed81c8d4da26d | refs/heads/master | 2021-07-19T23:59:44.233965 | 2020-04-13T09:50:08 | 2020-04-13T09:50:08 | 168,817,202 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,451 | ino | objet_chambre.ino | #include "main.h"
RTC_DS1307 rtc;
TM1637Display afficheur = TM1637Display(PIN_CLK_7SEG, PIN_DIO_7SEG);
Adafruit_SSD1306 ecran(D3);
DHT_Unified dht(PIN_DHT, DHT22);
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "europe.pool.ntp.org");
//Central European Time (Frankfurt, Paris)
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; //Central European Summer Time
TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; //Central European Standard Time
Timezone tz(CEST, CET);
//ESP8266WebServer server(80); //Server on port 80
WiFiClient espClient;
PubSubClient client(espClient);
bool wifiConnected = false;
bool mqttConnected = false;
volatile bool etatSwitch[3] = {false, false, false};
String jourL[7] = {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"};
String moisL[12] = {"Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"};
int temperature = 0;
int humidite = 0;
int luminosite = 0;
int lumiRaw = 0;
alarmTime alarme = {0, 0};
bool activateAlarme = false;
unsigned long previousMillis = 0;
bool etatBuzzer = false;
bool dataValid = false;
meteoStruct meteo = {0, 0, 0, 0};
Affichage etatAffich = NORMAL;
bool changeAffichStat = true;
unsigned long tempsEcoule = 0;
Timer t;
const uint8_t SEG_BOOT[] = {
SEG_C | SEG_D | SEG_E | SEG_F | SEG_G, // b
SEG_C | SEG_D | SEG_E | SEG_G, // o
SEG_C | SEG_D | SEG_E | SEG_G, // o
SEG_D | SEG_E | SEG_F | SEG_G // t
};
void setup()
{
Serial.begin(115200);
// RTC
Wire.begin(PIN_SDA, PIN_SCL);
rtc.begin();
if (!rtc.isrunning())
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// Afficheur
afficheur.setBrightness(0);
afficheur.setSegments(SEG_BOOT);
// Ecran
ecran.begin(SSD1306_SWITCHCAPVCC, 0x3C);
ecran.dim(false);
affichageInitTitre();
// EEPROM
EEPROM.begin(8);
// Definition des PINs
pinMode(PIN_BUZZ, OUTPUT);
noTone(PIN_BUZZ);
pinMode(PIN_SW1, INPUT);
pinMode(PIN_SW2, INPUT);
pinMode(PIN_SW3, INPUT);
attachInterrupt(digitalPinToInterrupt(PIN_SW1), switchPressed1, RISING);
attachInterrupt(digitalPinToInterrupt(PIN_SW2), switchPressed2, RISING);
attachInterrupt(digitalPinToInterrupt(PIN_SW3), switchPressed3, RISING);
// DHT
dht.begin();
t.every(DELAI_MESURE, updateDHT);
// WiFi
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
int nbTent = 0;
while (WiFi.status() != WL_CONNECTED && nbTent < DELAI_CONNEXION * 2)
{
affichageInitConnexion(nbTent/3);
delay(500);
Serial.print(".");
nbTent++;
}
Serial.println();
if(nbTent == DELAI_CONNEXION * 2) // Connexion echouee
{
Serial.print("Not connected");
EEPROM.write(ADDRESS_MODEREGL, MANUEL);
EEPROM.commit();
wifiConnected = false;
}
else
{
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
wifiConnected = true;
}
affichageInitConnected(wifiConnected);
// NTP
timeClient.begin();
timeClient.setUpdateInterval(3600000);
timeClient.setTimeOffset(0);
if(wifiConnected)
timeClient.update();
// Web
/*server.on("/", webpage); // Which routine to handle at root location
server.begin(); */
// MQTT
client.setServer(MQTT_SERVER, 1883);
reconnectMqtt();
t.every(DELAI_MQTT, mqttPost);
t.every(5 * DELAI_MQTT, reconnectMqtt);
// Meteo
updateMeteo();
t.every(3600000, updateMeteo);
// Alarme
alarme.hour = EEPROM.read(ADDRESS_H_ALARME);
alarme.minute = EEPROM.read(ADDRESS_M_ALARME);
// Mesures
for(int nbMes = 0; nbMes < NB_MESURES; nbMes++)
{
affichageInitMesures(nbMes);
updateLuminosite();
updateDHT();
delay(500);
}
}
void loop()
{
// Connexion WiFi
wifiConnected = (WiFi.status() == WL_CONNECTED);
// Timer
t.update();
/*// Gestion Web
if(wifiConnected)
server.handleClient();*/
// Gestion MQTT
mqttConnected = client.connected();
if(wifiConnected && mqttConnected)
client.loop();
Serial.println(mqttConnected);
// Luminosite afficheur
updateLuminosite();
afficheur.setBrightness(luminosite);
Serial.print("\nLUMINOSITE: ");
Serial.println(luminosite);
// Luminosite ecran
ecran.dim(luminosite == 0);
// Synchronisation auto de l'heure
if(EEPROM.read(ADDRESS_MODEREGL) == AUTO && wifiConnected)
{
rtc.adjust(DateTime(tz.toLocal(timeClient.getEpochTime())));
Serial.println("\nHeure synchronisee via NTP");
}
// Maj variable timeout retour affichage normal
if(etatSwitch[MENU] || etatSwitch[PLUS] || etatSwitch[MOINS])
{
tempsEcoule = millis();
}
// Navigation menu
if(etatSwitch[MENU])
{
if(EEPROM.read(ADDRESS_MODEREGL) == MANUEL)
etatAffich = (Affichage) ((etatAffich + 1) % 11);
else if(EEPROM.read(ADDRESS_MODEREGL) == AUTO)
etatAffich = (Affichage) ((etatAffich + 1) % 5);
else
{
EEPROM.write(ADDRESS_MODEREGL, AUTO);
EEPROM.commit();
etatAffich = (Affichage) ((etatAffich + 1) % 5);
}
if(!EEPROM.read(ADDRESS_ETATALAR) && etatAffich == ALARME_HOUR)
{
etatAffich = TIME_MODE;
}
if(etatAffich == NORMAL || etatAffich == ALARME_ETAT || etatAffich == TIME_MODE)
changeAffichStat = true;
etatSwitch[MENU] = false;
}
Serial.print("\netatAffich / changeAffichStat : ");
Serial.print(etatAffich);
Serial.print(" / ");
Serial.println(changeAffichStat);
// Retour affichage normal timeout
if(etatAffich != NORMAL && abs(millis() - tempsEcoule) > DELAI_RETOUR)
{
etatAffich = NORMAL;
changeAffichStat = true;
Serial.println("\nTimeout -> retour a l'affichage normal");
}
// Afficheur
DateTime now = rtc.now();
bool pair = now.second() % 2;
afficheur.showNumberDecEx(now.hour(), 0xFF * pair, false, 2, HOURS);
afficheur.showNumberDecEx(now.minute(), 0xFF * pair, true, 2, MINUTES);
Serial.print("\nTime actuel : ");
Serial.print(now.day());
Serial.print("/");
Serial.print(now.month());
Serial.print("/");
Serial.print(now.year());
Serial.print(" ");
Serial.print(now.hour());
Serial.print(":");
Serial.print(now.minute());
Serial.print(":");
Serial.println(now.second());
/*
ecran.fillRect(10, 8, 6*4, 8, BLACK);
ecran.setCursor(10,8);
ecran.print(analogRead(PIN_PHOTORES));
ecran.fillRect(10, 32, 6*5, 8, BLACK);
ecran.setCursor(10,32);
for(byte i = 0 ; i < 3 ; i++)
{
if(etatSwitch[i])
ecran.print("X ");
else
ecran.print("_ ");
etatSwitch[i] = false;
}
ecran.display();
*/
// Gestion de l'affichage et des interactions
if(etatAffich == NORMAL)
{
if(changeAffichStat)
{
affichageNormalStat();
if(EEPROM.read(ADDRESS_H_ALARME) != alarme.hour)
{
EEPROM.write(ADDRESS_H_ALARME, alarme.hour);
EEPROM.commit();
}
if(EEPROM.read(ADDRESS_M_ALARME) != alarme.minute)
{
EEPROM.write(ADDRESS_M_ALARME, alarme.minute);
EEPROM.commit();
}
}
affichageNormalDyna(now);
}
else if(etatAffich == ALARME_ETAT || etatAffich == ALARME_HOUR || etatAffich == ALARME_MINUTE)
{
if(changeAffichStat)
{
affichageAlarmeStat();
}
if(etatSwitch[PLUS])
{
if(etatAffich == ALARME_ETAT)
{
if(EEPROM.read(ADDRESS_ETATALAR) != 1)
{
EEPROM.write(ADDRESS_ETATALAR, 1);
EEPROM.commit();
}
}
else if(etatAffich == ALARME_HOUR)
alarme.hour = (alarme.hour + 1) % 24;
else if(etatAffich == ALARME_MINUTE)
alarme.minute = (alarme.minute + 1) % 60;
etatSwitch[PLUS] = false;
}
if(etatSwitch[MOINS])
{
if(etatAffich == ALARME_ETAT)
{
if(EEPROM.read(ADDRESS_ETATALAR) != 0)
{
EEPROM.write(ADDRESS_ETATALAR, 0);
EEPROM.commit();
}
}
else if(etatAffich == ALARME_HOUR)
alarme.hour = (alarme.hour +23) % 24;
else if(etatAffich == ALARME_MINUTE)
alarme.minute = (alarme.minute +59) % 60;
etatSwitch[MOINS] = false;
}
affichageAlarmeDyna();
}
else if(etatAffich == TIME_JOUR || etatAffich == TIME_MOIS || etatAffich == TIME_ANNEE || etatAffich == TIME_HEURE || etatAffich == TIME_MINUTE || etatAffich == TIME_SECONDE || etatAffich == TIME_MODE)
{
if(changeAffichStat)
{
affichageTimeStat();
}
if(etatSwitch[PLUS])
{
if(etatAffich == TIME_JOUR)
rtc.adjust(DateTime(now.year(), now.month(), now.day() % nbJourDansMois(now.month(), now.year()) + 1, now.hour(), now.minute(), now.second()));
else if(etatAffich == TIME_MOIS)
{
int nbJour = nbJourDansMois((now.month() % 12) + 1, now.year());
int jour = (now.day() > nbJour) ? nbJour : now.day();
rtc.adjust(DateTime(now.year(), (now.month() % 12) + 1, jour, now.hour(), now.minute(), now.second()));
}
else if(etatAffich == TIME_ANNEE)
rtc.adjust(DateTime(((now.year() - 1999) % 100) + 2000, now.month(), now.day(), now.hour(), now.minute(), now.second()));
else if(etatAffich == TIME_HEURE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), (now.hour() + 1) % 24, now.minute(), now.second()));
else if(etatAffich == TIME_MINUTE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), (now.minute() + 1) % 60, now.second()));
else if(etatAffich == TIME_SECONDE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), now.minute(), 30));
else if(etatAffich == TIME_MODE)
{
if(EEPROM.read(ADDRESS_MODEREGL) != AUTO)
{
EEPROM.write(ADDRESS_MODEREGL, AUTO);
EEPROM.commit();
}
if(wifiConnected)
timeClient.update();
}
etatSwitch[PLUS] = false;
}
if(etatSwitch[MOINS])
{
if(etatAffich == TIME_JOUR)
rtc.adjust(DateTime(now.year(), now.month(), ((now.day() + nbJourDansMois(now.month(), now.year()) - 2) % nbJourDansMois(now.month(), now.year())) + 1, now.hour(), now.minute(), now.second()));
else if(etatAffich == TIME_MOIS)
{
int nbJour = nbJourDansMois(((now.month() + 10) % 12) + 1, now.year());
int jour = (now.day() > nbJour) ? nbJour : now.day();
rtc.adjust(DateTime(now.year(), ((now.month() + 10) % 12) + 1, jour, now.hour(), now.minute(), now.second()));
}
else if(etatAffich == TIME_ANNEE)
rtc.adjust(DateTime(((now.year() - 1901) % 100) + 2000, now.month(), now.day(), now.hour(), now.minute(), now.second()));
else if(etatAffich == TIME_HEURE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), (now.hour() + 23) % 24, now.minute(), now.second()));
else if(etatAffich == TIME_MINUTE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), (now.minute() + 59) % 60, now.second()));
else if(etatAffich == TIME_SECONDE)
rtc.adjust(DateTime(now.year(), now.month(), now.day(), now.hour(), now.minute(), 0));
else if(etatAffich == TIME_MODE)
{
if(EEPROM.read(ADDRESS_MODEREGL) != MANUEL)
{
EEPROM.write(ADDRESS_MODEREGL, MANUEL);
EEPROM.commit();
}
}
etatSwitch[MOINS] = false;
}
affichageTimeDyna(now);
}
changeAffichStat = false;
// Alarme
activateAlarme = false;
if(EEPROM.read(ADDRESS_ETATALAR))
{
int refAct = 60 * now.hour() + now.minute();
int refAlarme = 60 * alarme.hour + alarme.minute;
if(refAlarme < 1440 - ALARME_DUREE)
{
if(refAct >= refAlarme && refAct <= refAlarme + ALARME_DUREE)
{
activateAlarme = true;
}
}
else
{
if(refAct >= refAlarme || refAct <= refAlarme + ALARME_DUREE - 1440)
{
activateAlarme = true;
}
}
}
unsigned long currentMillis = millis();
if (activateAlarme && currentMillis - previousMillis >= 500)
{
previousMillis = currentMillis;
etatBuzzer = !etatBuzzer;
}
if(etatBuzzer && activateAlarme)
{
tone(PIN_BUZZ, 330);
}
else
{
noTone(PIN_BUZZ);
}
delay(10);
/*
digitalWrite(PIN_DHT, HIGH);
delay(200);
digitalWrite(PIN_DHT, LOW);
delay(100);*/
}
|
95c9cc8316added03ec40f4dfd2a5b534729311e | 582bb93445abfdf904021248624270c07dc817d6 | /source/mainwindow.h | eaf4776d2df8b96ef6d448a7f4fb33672aa60ce0 | [] | no_license | 18445867102/SignalProcessor | c6d64bbd4b8664f784a8ab04ce9e1340dea376a1 | b13039c388edcbc898ca3d5e781cf7ae101eb6d3 | refs/heads/master | 2021-02-07T02:50:33.081020 | 2020-03-01T00:58:16 | 2020-03-01T00:58:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,375 | h | mainwindow.h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QtWidgets>
#include <QtQuickWidgets/QtQuickWidgets>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <ActiveQt/QAxWidget>
#include <QDesktopServices>
#include <QUrl>
//#include <QtWebKit/QtWebKit>
//#include <QtWebKit/QWebView>
#include "mclass/mstatusbar.h"
#include "serialport/mserialwidget.h"
#include "dockwidget/mdockwidget.h"
#include "dockwidget/mdocktitlewidget.h"
#include "tabwidget/mtabwidget.h"
#include "modulesclass/dragwidget.h"
#include "modulesclass/mgraphicsview.h"
#include "modulesclass/mgroupbox.h"
#include "mboardeditor.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void create_toolbar();
void create_statusbar();
void create_dockwidget();
void create_mainWidget();
void layoutAddInOutModule();
public slots:
void slotClear(); //清除场景中所有的图元
void slot_setSerialPort(); //串口子窗口
void slot_configure();
void slot_editHardware(); //硬件编辑器子窗口
void slot_cursorPostion(QPoint); //更新状态栏
void slot_tabifiedDockWidgetActivated(QDockWidget *);
void slot_boardChange(int);
void slot_boardAdd(int);
void slot_boardRemove(int);
void slot_serialIsOpen(bool);
private slots:
void on_actionSaveFile_triggered();
void on_actionOpenFile_triggered();
void on_action_about_triggered();
void on_action_description_triggered();
private:
void closeEvent(QCloseEvent *event);
//工具栏控件
QAction *action_serialPort;
QAction *action_configure;
QAction *action_savefile;
//停靠窗口
MDockWidget *mdockWidget;
QDockWidget *moduleboxWidget;
QStackedWidget *stackWidget;
MGraphicsView *view;
QQuickWidget *quickWidget;
// MTabWidget * tabwidget;
//状态栏控件
MStatusBar *statusBar;
QLabel *stb_filePath;
QLabel *stb_viewPoint;
QLabel *stb_scenePoint;
//子窗口
Ui::MainWindow *ui;
MSerialWidget *serialPort;
MBoardEditor *editBoard;
//流布局
QFlowLayout *flow;
//其它
QListWidgetItem *previous = nullptr;
QJsonObject modulesData;
int pre;
};
#endif // MAINWINDOW_H
|
65c5d271acb3ccc597e5a3a0095e614cf0f008a9 | 9758a9ca4d42da7e728ff324f3d48aa097576d90 | /project 3/Training/optTree.h | 73286767912d429ee048ff1ae687ce5e8438db62 | [] | no_license | ernie0218e/Computer-Vision-Projects | 9c53ebf450b13dd3b95ba687bee22502fde94cd7 | 28665a9e5c2d75c2b5680f2644da4b9475dc3fcd | refs/heads/master | 2021-01-12T09:31:41.985292 | 2017-01-15T14:05:06 | 2017-01-15T14:05:06 | 76,182,474 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,346 | h | optTree.h | #ifndef USE_ARMA
#define USE_ARMA
#include <armadillo>
using namespace std;
using namespace arma;
// store the info of point
class Point{
public:
int x;
int y;
};
// store image data and their label
// TO-DO - store image data costs too much memory
// we only need to store the index
class Dataset{
public:
mat* data;
vec* label;
};
// Store info of decision rule and subset of data
class Node{
public:
Point pt_dm1;
Point pt_dm2;
Dataset subset;
};
// real node of tree
// store info in 'Node'
// connect to child nodes with 'TreeNode' pointers
class TreeNode {
public:
Node * node;
TreeNode ** childNodes;
};
// find the best way to divide date into three parts
// and the decision rule of given node
// parameters: mat& patches - given training image
// vec& label - training image label
// int classNum - number of classes
// int patchWidth - width of patch
// Node* resultNode - store the decision rule (pt_dm1, pt_dm2)
// Dataset* subsets - three subset of data (which are from 'patches')
// int currentDepth - the number of iterations for optimaization based on this value
void optTree(mat& patches, vec& label, int classNum, int patchWidth, Node* resultNode, Dataset* subsets, int currentDepth=0);
// Node* resultNode and Dataset* subsets may be redundant
#endif |
cb26a05ad69129d616887e7461808d3719fb3d99 | 23d75bf1b7229682298f1dc7d58daef9b90374da | /distributori.cpp | df9608eb9355ee22c85a3c4b19acb5e581136429 | [] | no_license | nicomazz/oii | 97dccf7c309c59ad4f12d274656a5ac280449fff | 9a4887962a91f1f129014055662cd5105e68ac59 | refs/heads/master | 2016-09-06T05:48:15.660053 | 2016-02-14T14:23:35 | 2016-02-14T14:23:35 | 39,682,536 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 771 | cpp | distributori.cpp | #include <stdio.h>
#include <assert.h>
#include <iostream>
#define MAXN 100000
using namespace std;
int rifornisci(int N, int M, int K, int D[]) {
int Att = 0;
int d = 0; // distributori usati
for (int i = 0; i < N; i++)
if (D[i] > Att+M)
{
if (D[i-1] > K) return d;
d++;
Att = D[i-1];
}
if (K - Att > M ) d++;
return d;
}
int D[MAXN];
int main() {
FILE *fr, *fw;
int N, M, K, i;
fr = fopen("input.txt", "r");
fw = fopen("output.txt", "w");
assert(3 == fscanf(fr, "%d %d %d", &N, &M, &K));
for(i=0; i<N; i++)
assert(1 == fscanf(fr, "%d", &D[i]));
fprintf(fw, "%d\n", rifornisci(N, M, K, D));
fclose(fr);
fclose(fw);
return 0;
}
|
9cbef92dae0e098e6d57d14baa8d879e9d608d1b | 06bed8ad5fd60e5bba6297e9870a264bfa91a71d | /libPr3/loconet/Pr4/pr4adapter.cpp | 2b35519e0657bd3afc23b55dc1b67cbd76284ba1 | [] | no_license | allenck/DecoderPro_app | 43aeb9561fe3fe9753684f7d6d76146097d78e88 | 226c7f245aeb6951528d970f773776d50ae2c1dc | refs/heads/master | 2023-05-12T07:36:18.153909 | 2023-05-10T21:17:40 | 2023-05-10T21:17:40 | 61,044,197 | 4 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 7,336 | cpp | pr4adapter.cpp | #include "pr4adapter.h"
#include "pr4systemconnectionmemo.h"
#include "../PR2/lnpr2packtizer.h"
#include "lncommandstationtype.h"
#include "loggerfactory.h"
/**
* Override {@link jmri.jmrix.loconet.locobuffer.LocoBufferAdapter} so that it refers to the
* (switch) settings on the Digitrax PR4.
* <p>
* Based on PR3Adapter.java
*
* @author Bob Jacobsen Copyright (C) 2004, 2005, 2006, 2008
* @author B. Milhaupt Copyright (C) 2019
*/
// /*public*/ class PR4Adapter extends LocoBufferAdapter {
/*public*/ PR4Adapter::PR4Adapter(QObject* /*parent*/)
: LocoBufferAdapter(new PR4SystemConnectionMemo){
//super(new PR4SystemConnectionMemo());
options.remove(option2Name);
options.insert(option2Name, new Option(tr("CommandStationTypeLabel"), commandStationOptions(), false));
}
/**
* Sets up the serial port characteristics. Always uses flow control, which is
* not considered a user-settable option. Sets the PR4 for the appropriate
* operating mode, based on the selected "command station type".
*
* @param activeSerialPort the port to be configured
*/
//@Override
/*protected*/ void PR4Adapter::setSerialPort(SerialPort* activeSerialPort) /*throw (UnsupportedCommOperationException)*/ {
// find the baud rate value, configure comm options
int baud = currentBaudNumber(mBaudRate);
activeSerialPort->setSerialPortParams(baud, SerialPort::DATABITS_8,
SerialPort::STOPBITS_1, SerialPort::PARITY_NONE);
// configure flow control to always on
int flow = SerialPort::FLOWCONTROL_RTSCTS_OUT;
if (getOptionState(option1Name) ==(validOption1[1])) {
flow = SerialPort::FLOWCONTROL_NONE;
}
configureLeadsAndFlowControl(activeSerialPort, flow);
log->info("PR4 adapter"
+ QString(activeSerialPort->getFlowControlMode() == SerialPort::FLOWCONTROL_RTSCTS_OUT ? " set hardware flow control, mode=" : " set no flow control, mode=")
+ QString::number(activeSerialPort->getFlowControlMode())
+ " RTSCTS_OUT=" + QString::number(SerialPort::FLOWCONTROL_RTSCTS_OUT)
+ " RTSCTS_IN=" + QString::number(SerialPort::FLOWCONTROL_RTSCTS_IN));
}
/**
* Set up all of the other objects to operate with a PR4 connected to this
* port. This overrides the version in loconet.locobuffer, but it has to
* duplicate much of the functionality there, so the code is basically
* copied.
*
* Note that the PR4 does not support "LocoNet Data Signal termination" when
* in LocoNet interface mode (i.e. MS100 mode).
*/
//@Override
/*public*/ void PR4Adapter::configure() {
setCommandStationType(getOptionState(option2Name));
setTurnoutHandling(getOptionState(option3Name));
if (commandStationType->getType() == LnCommandStationType::COMMAND_STATION_PR4_ALONE) {
// PR4 standalone case
// connect to a packetizing traffic controller
// that does echoing
//
// Note - already created a LocoNetSystemConnectionMemo, so re-use
// it when creating a PR2 Packetizer. (If create a new one, will
// end up with two "LocoNet" menus...)
LnPr2Packetizer* packets = new LnPr2Packetizer(this->getSystemConnectionMemo()->self());
packets->connectPort(this);
// set traffic controller and configure command station and mangers
((LocoNetSystemConnectionMemo*) this->getSystemConnectionMemo())->setLnTrafficController(packets);
// do the common manager config
((LocoNetSystemConnectionMemo*)this->getSystemConnectionMemo())->configureCommandStation(commandStationType,
mTurnoutNoRetry, mTurnoutExtraSpace, mTranspondingAvailable); // never transponding!
((PR4SystemConnectionMemo*)this->getSystemConnectionMemo())->configureManagersPR2();
// start operation
//packets->startThreads();
// set mode
LocoNetMessage* msg = new LocoNetMessage(6);
msg->setOpCode(0xD3);
msg->setElement(1, 0x10);
msg->setElement(2, 1); // set PR2
msg->setElement(3, 0);
msg->setElement(4, 0);
packets->sendLocoNetMessage(msg);
} else {
// MS100 modes - connecting to a separate command station
// get transponding option
setTranspondingAvailable(getOptionState("TranspondingPresent"));
// connect to a packetizing traffic controller
LnPacketizer* packets = getPacketizer(getOptionState(option4Name));
packets->connectPort(this);
// set traffic controller and configure command station and mangers
((LocoNetSystemConnectionMemo*)this->getSystemConnectionMemo())->setLnTrafficController(packets);
// do the common manager config
((LocoNetSystemConnectionMemo*)this->getSystemConnectionMemo())->configureCommandStation(commandStationType,
mTurnoutNoRetry, mTurnoutExtraSpace, mTranspondingAvailable);
((PR4SystemConnectionMemo*)this->getSystemConnectionMemo())->configureManagersMS100();
// start operation
//packets->startThreads();
// set mode
LocoNetMessage* msg = new LocoNetMessage(6);
msg->setOpCode(0xD3);
msg->setElement(1, 0x10);
msg->setElement(2, 0); // set MS100, no power
msg->setElement(3, 0);
msg->setElement(4, 0);
packets->sendLocoNetMessage(msg);
}
}
/**
* {@inheritDoc}
*
* @return String[] containing the single valid baud rate, "57,600".
*/
//@Override
/*public*/ QStringList PR4Adapter::validBaudRates() {
return QStringList() << "57,600 baud"; // NOI18N
}
/**
* {@inheritDoc}
*
* @return int[] containing the single valid baud rate, 57600.
*/
//@Override
/*public*/ QVector<int> PR4Adapter::validBaudNumbers() {
return QVector<int>() << 57600;
}
//@Override
/*public*/ int PR4Adapter::defaultBaudIndex() {
return 0;
}
// Option 1 does flow control, inherited from LocoBufferAdapter
/**
* The PR4 can be used as a "Standalone Programmer", or with various LocoNet
* command stations. The PR4 does not support "LocoNet Data signal termination",
* so that is not added as a valid option (as it would be for the PR3).
*
* @return an array of strings containing the various command station names and
* name(s) of modes without command stations
*/
/*public*/ QStringList PR4Adapter::commandStationOptions() {
QVector<QString> retval = QVector<QString>(commandStationNames.length() + 1);
//retval[0] = LnCommandStationType::COMMAND_STATION_PR4_ALONE.getName();
retval[0] = LnCommandStationType::getByType(LnCommandStationType::COMMAND_STATION_PR4_ALONE)->getName();
for (int i = 0; i < commandStationNames.length(); i++) {
retval[i + 1] = commandStationNames[i];
}
return retval.toList();
}
//@Override
/*public*/ SystemConnectionMemo *PR4Adapter::getSystemConnectionMemo() {
SystemConnectionMemo* m = LocoBufferAdapter::getSystemConnectionMemo();
if (qobject_cast<PR4SystemConnectionMemo*>(m->self())) {
return (PR4SystemConnectionMemo*) m;
}
log->error("Cannot cast the system connection memo to a PR4SystemConnection Memo.");
return nullptr;
}
/*public*/ QString PR4Adapter::className()
{
return "jrmi.jmrix.loconet.pr4.PR4Adapter";
}
/*private*/ /*final*/ /*static*/ Logger* PR4Adapter::log = LoggerFactory::getLogger("PR4Adapter");
|
34d6cb8d014cdd02105d37d019a8831ab77fa127 | 09210b68e42f1139dd66b9319f5593e04c764342 | /main.cpp | 4b057790915d34996a8cd8c72a111428a411cfdc | [] | no_license | eko18p2/CPP_10_Inheritance | c737a7febb515888322a6592d2f00e43a776ad26 | bf9c4a7ce70b1941aaeefdd955ec754595e34ae9 | refs/heads/master | 2020-04-05T04:04:25.789018 | 2018-11-07T11:35:28 | 2018-11-07T11:35:28 | 156,536,830 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,348 | cpp | main.cpp | #include <utility>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#define PROGRAMMER_POSITION "programmer"
#define ADMIN_POSITION "admin"
using namespace std;
class Worker {
public:
enum Position{ADMIN,PROGRAMMER};
private:
string name;
Position position;
public:
Worker(string name, Position position) :name(std::move(name)), position(position) {}
virtual ~Worker()=default;
const string &getName() const {
return name;
}
void setName(const string &name) {
Worker::name = name;
}
Position getPosition() const {
return position;
}
void setPosition(Position position) {
Worker::position = position;
}
};
class Proggrammer:public Worker {
string programmingLanguage;
public:
Proggrammer(const string &name, string programmingLanguage)
: Worker(name, Worker::PROGRAMMER), programmingLanguage(std::move(programmingLanguage)) {}
const string &getProgrammingLanguage() const {
return programmingLanguage;
}
void setProgrammingLanguage(const string &programmingLanguage) {
Proggrammer::programmingLanguage = programmingLanguage;
}
};
class Admin:public Worker{
string operationSystem;
public:
Admin(const string &name, string operationSystem)
: Worker(name, Worker::ADMIN),operationSystem(std::move(operationSystem)) {}
const string &getOperationSystem() const {
return operationSystem;
}
void setOperationSystem(const string &operationSystem) {
Admin::operationSystem = operationSystem;
}
};
int main() {
// vector<shared_ptr<Worker>> workers={
// shared_ptr<Worker>(new Admin("Vasia","Linux")),
// shared_ptr<Worker>(new Proggrammer("Petia","C++")),
// shared_ptr<Worker>(new Proggrammer("Ivan","Python")),
// shared_ptr<Worker>(new Proggrammer("Oleg","Ruby")),
// shared_ptr<Worker>(new Admin("Evgen","Windows"))
// };
//
// for(shared_ptr<Worker> w:workers){
// cout<<w->getName()<<endl;
// cout<<"\tPosition: "<<w->getPosition()<<endl;
// if(w->getPosition() == ADMIN_POSITION){
// cout<<"\tOS: "<<((Admin*)w.get())->getOperationSystem()<<endl;
// }
// if(w->getPosition() == PROGRAMMER_POSITION){
// cout<<"\tLanguage: "<<((Proggrammer*)w.get())->getProgrammingLanguage()<<endl;
// }
//
// }
vector<Worker*> workers={
new Admin("Vasia","Linux"),
new Proggrammer("Petia","C++"),
new Proggrammer("Ivan","Python"),
new Proggrammer("Oleg","Ruby"),
new Admin("Evgen","Windows")
};
map<Worker::Position,string> positionNames;
positionNames[Worker::ADMIN]="Admin";
positionNames[Worker::PROGRAMMER]="Programmer";
for(Worker* w:workers){
cout<<w->getName()<<endl;
cout<<"\tPosition: "<<positionNames[w->getPosition()]<<endl;
switch (w->getPosition()){
case Worker::ADMIN:
cout<<"\tOS: "<< dynamic_cast<Admin*>(w)->getOperationSystem()<<endl;
break;
case Worker::PROGRAMMER:
cout<<"\tLanguage: "<<dynamic_cast<Proggrammer*>(w)->getProgrammingLanguage()<<endl;
}
}
for(Worker* w:workers){
delete w;
}
system("pause");
return 0;
}
|
adb1d1ee8a9309ba63a41dfb30a5bb7af3a67ad0 | 4da66ea2be83b62a46d77bf53f690b5146ac996d | /modules/monkey/native/bbgc_mx.h | 90b71839564c6bcef51411b8e3ab4fdb46b8c02e | [
"Zlib"
] | permissive | blitz-research/monkey2 | 620855b08b6f41b40ff328da71d2e0d05d943855 | 3f6be81d73388b800a39ee53acaa7f4a0c6a9f42 | refs/heads/develop | 2021-04-09T17:13:34.240441 | 2020-06-28T04:26:30 | 2020-06-28T04:26:30 | 53,753,109 | 146 | 76 | Zlib | 2019-09-07T21:28:05 | 2016-03-12T20:59:51 | Monkey | UTF-8 | C++ | false | false | 3,044 | h | bbgc_mx.h |
#ifndef BB_GC_H
#define BB_GC_H
#ifndef BB_THREADS
#error "Wrong gc header"
#endif
#include "bbtypes.h"
#include "bbfunction.h"
struct bbGCNode;
struct bbGCThread;
struct bbGCFiber;
struct bbGCFrame;
struct bbGCRoot;
struct bbGCTmp;
namespace bbGC{
extern bbGCThread *threads;
extern thread_local bbGCThread *currentThread;
extern thread_local bbGCFiber *currentFiber;
extern std::atomic_char markedBit;
extern std::atomic_char unmarkedBit;
extern std::atomic<bbGCNode*> markQueue;
}
struct bbGCNode{
bbGCNode *succ;
bbGCNode *pred;
bbGCNode *qsucc;
std::atomic_char state;
char flags; //1=finalize
char pad[2];
bbGCNode(){}
virtual ~bbGCNode(){}
void gcNeedsFinalize();
virtual void gcFinalize();
virtual void gcMark();
virtual void dbEmit();
virtual const char *typeName()const;
};
struct bbGCThread{
bbGCThread *succ,*pred;
bbGCFiber *fibers;
void *handle;
bbFunction<void()> entry;
bbGCThread();
~bbGCThread();
void link();
void unlink();
};
struct bbGCFiber{
bbGCFiber *succ;
bbGCFiber *pred;
bbGCFrame *frames;
bbGCTmp *tmps;
bbGCTmp *freeTmps;
bbGCNode *ctoring;
bbFunction<void()> entry;
bbGCFiber();
void link();
void unlink();
};
struct bbGCFrame{
bbGCFrame *succ;
bbGCFrame():succ( bbGC::currentFiber->frames ){
bbGC::currentFiber->frames=this;
}
~bbGCFrame(){
bbGC::currentFiber->frames=succ;
}
virtual void gcMark();
};
struct bbGCRoot{
bbGCRoot *succ;
bbGCRoot();
virtual void gcMark();
};
struct bbGCTmp{
bbGCTmp *succ;
bbGCNode *node;
};
namespace bbGC{
void init();
void setTrigger( size_t trigger );
void suspend();
void resume();
void retain( bbGCNode *p );
void release( bbGCNode *p );
void setDebug( bool debug );
void *malloc( size_t size );
size_t mallocSize( void *p );
void free( void *p );
void collect();
inline void pushTmp( bbGCNode *p ){
bbGCTmp *tmp=currentFiber->freeTmps;
if( tmp ) currentFiber->freeTmps=tmp->succ; else tmp=new bbGCTmp;
tmp->succ=currentFiber->tmps;
tmp->node=p;
currentFiber->tmps=tmp;
}
inline void popTmps( int n ){
while( n-- ){
bbGCTmp *tmp=currentFiber->tmps;
currentFiber->tmps=tmp->succ;
tmp->succ=currentFiber->freeTmps;
currentFiber->freeTmps=tmp;
}
}
template<class T> T *tmp( T *p ){
pushTmp( p );
return p;
}
#ifdef NDEBUG
__forceinline void enqueue( bbGCNode *p ){
if( !p || p->state.load()!=unmarkedBit ) return;
if( p->state.exchange( 4 )==4 ) return;
p->qsucc=markQueue;
while( !markQueue.compare_exchange_weak( p->qsucc,p ) ){}
}
inline void beginCtor( bbGCNode *p ){
p->state=4;
p->flags=0;
p->qsucc=currentFiber->ctoring;
currentFiber->ctoring=p;
}
inline void endCtor( bbGCNode *p ){
currentFiber->ctoring=p->qsucc;
p->succ=p->pred=p;
p->qsucc=markQueue;
while( !markQueue.compare_exchange_weak( p->qsucc,p ) ){}
}
#else
void enqueue( bbGCNode *p );
void beginCtor( bbGCNode *p );
void endCtor( bbGCNode *p );
#endif
}
template<class T> void bbGCMark( T const& ){
}
#endif
|
fae6ee53e4de32a34bb79be20ac696b9d8fb17eb | e0c3ab98fd1c1afb4f1ffe1ea649c9a0df084c63 | /ZephyrSharp.GameSystem.Components/CameraComponent.h | 3e7ea9250691ad4d0583975d02cd9da8ed1863c3 | [] | no_license | s059ff/ZephyrEngine | 6b9e28fb3cb0f8d90e0cba73b758c33ce77a0137 | b484258119ecff0f51a785fa02e9c4d4594ddf2a | refs/heads/master | 2020-03-22T14:20:23.452845 | 2018-07-08T23:44:42 | 2018-07-08T23:44:42 | 110,549,395 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 951 | h | CameraComponent.h | #pragma once
using namespace ZephyrSharp::Linalg;
namespace ZephyrSharp
{
namespace GameSystem
{
namespace Components
{
/// <summary>
/// カメラを表します。
/// </summary>
public ref class CameraComponent : public EntityComponent
{
public:
/// <summary>
/// ある地点から別のある地点を注視するようにカメラの向きを設定します。
/// </summary>
/// <param name="eye">カメラの座標。</param>
/// <param name="at">注視先の座標。</param>
void LookAt(Vector3 eye, Vector3 at);
/// <summary>
/// ビューイング行列を取得します。
/// </summary>
property Matrix4x3 ViewingMatrix { Matrix4x3 get(); }
};
}
}
}
|
b41487caf79c594fd3b2776c704422bb587ea98b | 0a70fc8307e312ba0adb43b22000eb37440a3fb2 | /ArrangingCoins/Solution.cpp | d05eb7a8f9064f4e34558e91059241894958f25d | [] | no_license | keyforone/algorithm_data_structure | afbcc2aef2427b2d9eb2f9e2021cb5530427c177 | cffff7ada252a17702c69f55af08b5d473d52877 | refs/heads/master | 2021-01-12T13:15:33.783296 | 2016-11-07T09:41:10 | 2016-11-07T09:41:10 | 72,166,267 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 142 | cpp | Solution.cpp |
int arrangeCoins(int n)
{
if( n < 0) return 0;
unsigned long x = (unsigned long)sqrt(8*(unsigned long)n+1);
return (x-1)/2;
}
|
fb3e427375acab71bfaf80c1961927afb89f87b2 | a8275a51289d84f84d6e588be6745a5d431f9ab9 | /lab5_q4.cpp | e5828b8744e26d9e2c7547c7b5996967aa35570f | [] | no_license | SquircleCode/CS-141-SEM1 | c897a0177cc2ebb65f2e172634aa4cfa28f157fd | ddac168a89e6df02802c3c93b86d7e647acb0ee8 | refs/heads/master | 2020-03-27T20:34:19.356830 | 2018-11-18T17:28:35 | 2018-11-18T17:28:35 | 147,078,386 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 503 | cpp | lab5_q4.cpp | /*
* Auto-Generated File
* Author
Name : SAI KRISHNA I
Roll No : 1811131
*/
// Importing Libraries
#include <iostream>
using namespace std;
// Main Method
int main(){
// To-Do
// program name
cout << "\t\t\tDIVISIBILTY BY 5 AND 11\n";
// variables
int a;
string res;
// input
cout << "Enter a number : ";
cin >> a;
// divisiblity by 5 and 11
if(a%5==0 && a%11==0)
res = "";
else
res = "not";
// result
cout<< "The number is "<<res<<" divisible by 5 and 11"<<endl;
return 0;
}
|
f572c79b86dd4d491e618714e3fd97ace4a8d2cf | 5db1e511c9e7c2d9d56b220a177268dca3c999c7 | /Dev/StaticSheepNeoBuildSystem/game/SheepEngine/config/Config.cpp | dab6fbacb8b8d600421da9cfd8fb50c46d4cc7ee | [] | no_license | StaticSheep/StaticSheepGame | d8aa951dfc5da3f5be1a4b5259f6bb70fff6dcee | 5808781f57fb7a79cc937abdf6835f27790af35e | refs/heads/master | 2021-01-18T21:02:31.199570 | 2015-03-18T05:37:07 | 2015-03-18T05:37:07 | 19,442,525 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 2,494 | cpp | Config.cpp | /*****************************************************************
Filename: Config.cpp
Project:
Author(s): Zachary Nawar (Primary)
All content © 2014 DigiPen (USA) Corporation, all rights reserved.
*****************************************************************/
#include "pch/precompiled.h"
#include "Config.h"
//#include "wxeditor/App.h"
#include "engine/core/Engine.h"
#include "systems/input/Input.h"
#include "systems/debug/Debug.h"
#include "systems/graphics/SheepGraphics.h"
#include "systems/audio/SheepAudio.h"
#include "systems/gamelogic/GameLogic.h"
#include "systems/physics/SheepPhysics.h"
#include "systems/anttweak/AntTweakModule.h"
#include "systems/skynet/Skynet.h"
//#include "WxWindow.h"
#include "systems/editor/GizmoEditor.h"
#include "systems/metrics/MetricController.h"
//#include "gfx/wxw/d3d/WxD3DCanvas.h"
//#include "gfx/wxw/d3d/WxD3DContext.h"
static bool editor;
namespace Framework
{
Engine* AllocateEngine(int argc, char** argv)
{
Engine* Core = new Engine();
#ifdef _DEBUG
editor = true;
OpenConsole();
#else
if(argc > 1)
{
for(int i = 1; i < argc; ++i)
{
if(strcmp(argv[i], "-editor") == 0)
editor = true;
}
}
if (editor)
OpenConsole();
#endif
Core->AddSystem(new InputManager());
Core->AddSystem(new Skynet());
Core->AddSystem(new GameLogic());
Core->AddSystem(new SheepPhysics());
Core->AddSystem(new SheepAudio());
Core->AddSystem(new MetricController());
void* rc = nullptr;
#if USE_EDITOR
//rc = ((dit::App*)dit::EDITOR_WINDOW)->window->canvas->context->GetRenderContext();
#endif
Core->AddSystem(new SheepGraphics());
Core->AddSystem(new Debug());
if(editor)
{
Core->AddSystem(new AntTweakModule());
Core->AddSystem(new GizmoEditor());
}
#if USE_EDITOR
#else
Core->MakeWindow(GetModuleHandle(NULL), 1, !editor);
#endif
return Core;
}
void InitEngine(void)
{
ENGINE->Initialize();
#if USE_EDITOR
#else
if (editor)
{
//ENGINE->LoadLuaLevel("content/lua/engine/lua_levels/uisandbox.lua");
ENGINE->OpenEditor();
// ENGINE->ChangeLevel("Asteroid");
}
ENGINE->SystemMessage(Message(Message::EngineReady));
if (!editor)
{
ShowCursor(false);
//ENGINE->ChangeLevel("Intro");
ENGINE->ChangeLevel("Asteroid");
}
//ENGINE->LoadLevel("content/data/spaces/Level1.space");
#endif
}
} |
e6b673bfdde2b8cb04292efe78dceb7f072c9ea1 | 8da9d3c3e769ead17f5ad4a4cba6fb3e84a9e340 | /src/chila/lib/node/util.cpp | 8f273b81188ecdcbf63086064f9fc16825b51d76 | [] | no_license | blockspacer/chila | 6884a540fafa73db37f2bf0117410c33044adbcf | b95290725b54696f7cefc1c430582f90542b1dec | refs/heads/master | 2021-06-05T10:22:53.536352 | 2016-08-24T15:07:49 | 2016-08-24T15:07:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,427 | cpp | util.cpp | /* Copyright 2011-2015 Roberto Daniel Gimenez Gamarra (chilabot@gmail.com)
* (C.I.: 1.439.390 - Paraguay)
*/
#include "util.hpp"
#include "NodeWithChildren.hpp"
#include "Reference.hpp"
#include "nspDef.hpp"
MY_NSP_START
{
chila::lib::misc::Path getNodePath(const Node &node)
{
return node.path();
}
NodeWithChildren &mainParent(NodeWithChildren &node)
{
if (auto parent = node.parentPtr())
return mainParent(*parent);
else
return node;
}
PathVec getReferences(
NodeWithChildren &node,
const chila::lib::misc::Path &path)
{
std::vector<chila::lib::misc::Path> ret;
node.visit([&](const chila::lib::node::Node &node)
{
if (auto *typed = node.toTypePtr<IReference>()) try
{
if (typed->refPath() == path)
ret.push_back(node.path());
}
catch (const chila::lib::node::Exception &ex)
{
}
});
return ret;
}
void replaceReferences(NodeWithChildren &node, const PathVec &paths, const Node &newRefNode)
{
for (auto &path : paths)
{
auto &ref = node.find(path);
auto newNode = ref.toType<IReference>().createWithRef(newRefNode);
ref.parent<NodeWithChildren>().replace(newNode, ref.name());
}
}
}
MY_NSP_END
|
1a46e81a53b3ea02b05a2a5b8d1963da46078036 | b40ca00779ba9e0d9412b21849d44897f74f874c | /kubrican_AZA_2/Graph.cpp | 188b750a8b112cbe24ccda9d67ac8f2a0fcc89e1 | [] | no_license | JurajKubrican/fei_aza2 | 74fe889e9fa38f74c4475d89f2ac1821cee426df | 2b6b8a9197299cd1115f2daeed675385bdb24a4c | refs/heads/master | 2021-06-09T08:15:18.787260 | 2016-12-31T14:28:26 | 2016-12-31T14:28:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,285 | cpp | Graph.cpp | #include <set>
#include <map>
#include <vector>
#include <fstream>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <string>
#include <thread>
#include <future>
#include "MyThreadPool.cpp"
#define ACCURACY 0.2
//TO multithread or not t
#define THREAD_IT 1
using namespace std;
class Vertex {
public:
Vertex(string fname , vector<int> contents) {
this->fname = fname;
this->contents = contents;
}
//cahced get neighbors
set<Vertex*> get_neighbours( set<Vertex*> possible) {
set<Vertex*> result;
//remove those who are cached not neighbors
set<Vertex*> notNeighbors = this->get_not_neighbours();
for (set<Vertex*>::iterator it = notNeighbors.begin(); it != notNeighbors.end(); ) {
possible.erase(it);
}
//remove those who are cached neighbors + add them to result
set<Vertex*> neighbors = this->get_neighbours();
for (set<Vertex*>::iterator it = neighbors.begin(); it != neighbors.end(); it++) {
result.insert(*it);
possible.erase(*it);
}
if (THREAD_IT) {
//multithreaded prepairation
map<string, vector<int>> input;
map<string, Vertex*> ref;
for (set<Vertex*>::iterator it = possible.begin(); it != possible.end(); it++) {
if (*it == this)
continue;
ref.insert(make_pair((*it)->get_name(), *it));
input.insert(make_pair((*it)->get_name(), (*it)->get_contents()));
}
MyThreadPool threadPool(this->get_contents(), input);
map<string, int> output = threadPool.get_result();
//calculate + cache
for (map<string, int>::iterator it = output.begin(); it != output.end(); it++) {
if (it->second == 1) {
//cout << ref[it->first]->get_name() << endl;
result.insert(ref[it->first]);
this->add_neighbour(ref[it->first]);
}
else {
this->add_not_neighbour(ref[it->first]);
}
}
}else{
//single threaded
//calculate the rest + cache it
vector<int> V1C = this->get_contents();
for (set<Vertex*>::iterator it = possible.begin(); it != possible.end(); it++) {
if (*it == this)
continue;
vector<int>V2C = (*it)->get_contents();
if (is_neighbor_LCS(make_pair(V1C, V2C))) {
this->add_neighbour(*it);
result.insert(*it);
}
else {
this->add_not_neighbour(*it);
}
}
}
return result;
}
string get_name() {
return this->fname;
}
int get_size() {
return this->contents.size();
}
private:
string fname;
vector<int> contents;
set<Vertex*> neighbours;
set<Vertex*> not_neighbors;
set<Vertex*> get_neighbours() {
return neighbours;
}
void add_neighbour(Vertex* pnewVert) {
neighbours.insert(pnewVert);
pnewVert->add_neighbour2(this);
}
void add_neighbour2(Vertex* pnewVert) {
neighbours.insert(pnewVert);
}
void add_not_neighbour(Vertex* pnewVert) {
not_neighbors.insert(pnewVert);
pnewVert->add_not_neighbour2(this);
}
void add_not_neighbour2(Vertex* pnewVert) {
not_neighbors.insert(pnewVert);
}
set<Vertex*> get_not_neighbours() {
return not_neighbors;
}
vector<int> get_contents() {
return this->contents;
}
//takes less memory than the originla implemewnation
int is_neighbor_LCS( pair<vector<int>,vector<int>> in)
{
const vector<int> str1 = in.first;
const vector<int> str2 = in.second;
int str1size = str1.size();
int str2size = str2.size();
//optimalization:
int minSizeTreshold = ceil(min(str1size, str2size));
if (str1.empty() || str2.empty())
return 0;
int *curr = new int[str2size];
int *prev = new int[str2size];
int *swap = nullptr;
int maxSubstr = 0;
for (uint16_t i = 0; i < str1size; ++i){
for (uint16_t j = 0; j<str2size; ++j){
if (str1[i] != str2[j]){
curr[j] = 0;
}else{
if (i == 0 || j == 0){
curr[j] = 1;
}else{
curr[j] = 1 + prev[j - 1];
}
//return immediately after found > 20%
if (maxSubstr < curr[j]){
maxSubstr = curr[j];
if (maxSubstr >= minSizeTreshold) {
return true;
}
}
}
}
swap = curr;
curr = prev;
prev = swap;
}
delete[] curr;
delete[] prev;
return (maxSubstr >= (ACCURACY * min(str2.size(), str1.size())));
}
};
class Graph {
public:
Vertex* get_Vertex(string fname) {
if (vertices.find(fname) != vertices.end())
return vertices[fname];
else
return NULL;
}
Vertex* add_new_vertex(string fname, vector<int> contents) {
return (vertices[fname] = new Vertex(fname, contents));
}
set<Vertex*> cliqueFrom(string fname) {
Vertex * V1 = this->get_Vertex(fname);
set<Vertex*> all;
for (map<string, Vertex* >::iterator it = vertices.begin(); it != vertices.end(); it++) {
all.insert(it->second);
}
set<Vertex*> iniR;
iniR.insert(V1);
set<Vertex*> iniP = V1->get_neighbours(all);
set<Vertex*> iniX;
set<Vertex*> max_clique = this->BronKerbosh(iniR, iniP, iniX);
return max_clique;
}
private:
set<Vertex*> BronKerbosh(set<Vertex*>R, set<Vertex*>P, set<Vertex*>&X) {
set<Vertex*>max_clique;
if (P.size() == 0 && X.size() == 0) {
cout << "REPORTING AS MAX CLIQUE";
max_clique = R;
return max_clique;
}
cout << "clique: " << R.size() << "cadidates:" << P.size() << endl;
//Optimalization: vertex ordering
map<int, Vertex*> ordered;
for (set<Vertex*>::iterator it = P.begin(); it != P.end(); it++) {
ordered.insert(make_pair((*it)->get_size(),(*it)));
}
for (map<int,Vertex*>::iterator it = ordered.begin(); it != ordered.end(); it++) {
//cout << (*it)->get_name();
set<Vertex*>tmpN = it->second->get_neighbours(P);
set<Vertex*> tmpR(R); tmpR.insert(it->second );
set<Vertex*> tmpP(my_intersect(P, tmpN));
set<Vertex*> tmpX = my_intersect(X, tmpN);
if (tmpR.size() + tmpP.size() > max_clique.size()) {
set<Vertex*> tmp_clique = BronKerbosh(tmpR, tmpP, tmpX);
if (max_clique.size() < tmp_clique.size()) {
max_clique = tmp_clique;
}
}
if(P.find(it->second) != P.end())
P.erase(it->second);
X.insert(it->second);
}
return max_clique;
};
map<string, Vertex* > vertices;
set<Vertex*> my_intersect(set<Vertex*> a, set<Vertex*> b) {
set<Vertex*> intersect;
set_intersection(a.begin(), a.end(), b.begin(), b.end(),
std::inserter(intersect, intersect.begin()));
return intersect;
}
};;
|
fcd8d81099d4192591e02128f5c50203675208c2 | 79ba22542dcaa07bbe04e47488277b68c36273d5 | /menu_p.hpp | e19eaa40280be76a61b59de75b186776b82754e1 | [] | no_license | maxzerrrrrr/ECEMON | f59e4bf1e8e8890e13aa18fdac35fee79151122e | a3dc043e6d5e8580afb26bcaeaa863ed340ed65e | refs/heads/master | 2021-08-24T03:25:37.216329 | 2017-12-05T20:48:02 | 2017-12-05T20:48:02 | 113,502,036 | 0 | 0 | null | 2017-12-07T21:50:26 | 2017-12-07T21:50:26 | null | UTF-8 | C++ | false | false | 599 | hpp | menu_p.hpp | #ifndef MENU_P_HPP
#define MENU_P_HPP
#include <allegro.h>
#include <iostream>
#include "Carte.h"
#include "Joueur.h"
#include "shop.hpp"
int menu_p(Deck d,Joueur j,int* choix_joueur,BITMAP* save,BITMAP* joueur_c,std::vector <Joueur> Joueurs, std::vector <Carte> Collection,int *choix,BITMAP* terrain, BITMAP* buffermenu, BITMAP* cursor, BITMAP* screen, BITMAP* menup, BITMAP* cases_terrain, BITMAP* cadre, BITMAP* cadre_b, BITMAP* buffer, BITMAP* terrain_b, BITMAP* cases_terrain_b, BITMAP* shop, BITMAP* carte_m, BITMAP*carte_m_s, BITMAP* carte_shop,BITMAP* joueur_b);
#endif // MENU_P_HPP
|
d6479e97457ae9ce44c0da89fd4835ccd1845290 | 585966f1ebadc25701b83255a9e766d7a2245dd0 | /d05/ex01/Form.cpp | 69c79532fecd4103b4c591d5dfae69ac123df7ae | [] | no_license | nkone/C_Plus_Plus | 585b5a05f325f5b87dd65e8a37bf56ba4f1f4ef5 | a459419e31949412456e219b724d9718c7382801 | refs/heads/master | 2020-08-23T16:16:53.942029 | 2019-11-01T04:44:27 | 2019-11-01T04:44:27 | 216,660,512 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,306 | cpp | Form.cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Form.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phtruong <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/29 17:44:08 by phtruong #+# #+# */
/* Updated: 2019/10/29 20:43:09 by phtruong ### ########.fr */
/* */
/* ************************************************************************** */
#include "Form.hpp"
// Init useless form
Form::Form() : _name("Empty"), _signed(false), _gradeToSign(150), _gradeToExe(150) {}
Form::~Form() {}
Form::Form(const Form& other) : _name(other._name), _gradeToSign(other._gradeToSign), _gradeToExe(other._gradeToExe) {
_signed = other._signed;
}
Form& Form::operator=(const Form& other) {
if (this != &other)
*this = other;
return *this;
}
Form::Form(const std::string& name, int toSign, int toExe) :
_name(name), _gradeToSign(toSign), _gradeToExe(toExe) {
// throw exception constructor if grade is less than _max value of 1
if (toSign < _maxGrade || toExe < _maxGrade) {
throw(GradeTooHighException());
} else if (toSign > _minGrade || toExe > _minGrade) {
// throw exception constructor if grade is greater than _min value of 150
throw(GradeTooLowException());
}
this->_signed = false;
}
// Getters
std::string Form::getName() const { return this->_name; }
bool Form::getSigned() const { return this->_signed; }
int Form::getGradeToSign(void) const { return this->_gradeToSign; }
int Form::getGradeToExe(void) const { return this->_gradeToExe; }
// Functional
void Form::beSigned(Bureaucrat& subject) {
if (subject.getGrade() > this->_gradeToSign)
throw(GradeTooLowException());
this->_signed = true;
}
typedef Form::GradeTooHighException GradeTooHighException;
GradeTooHighException::GradeTooHighException() {}
GradeTooHighException::~GradeTooHighException() throw() {}
GradeTooHighException::GradeTooHighException(const GradeTooHighException& other) {
*this = other;
}
GradeTooHighException& GradeTooHighException::operator=(const GradeTooHighException&) {
return *this;
}
const char* GradeTooHighException::what() const throw() { return "Error grade is too high"; }
typedef Form::GradeTooLowException GradeTooLowException;
GradeTooLowException::GradeTooLowException() {}
GradeTooLowException::~GradeTooLowException() throw() {}
GradeTooLowException::GradeTooLowException(const GradeTooLowException& other) {
*this = other;
}
GradeTooLowException& GradeTooLowException::operator=(const GradeTooLowException&) {
return *this;
}
const char* GradeTooLowException::what() const throw() { return "Error grade is too low"; }
std::ostream& operator<<(std::ostream& o, const Form& ref) {
o << "Form: " << ref.getName() <<
" to Sign: " << ref.getGradeToSign() <<
" to Execute: " << ref.getGradeToExe();
return o;
}
|
aa70f2d0325048dfbd16c68b293c2351d0b629f5 | 705c9971e22b1347ae51c637cf68ff8bcc37f864 | /Lecture-3-Bitmasking/Subsequences.cpp | 4564d246c02cb6375673799190869a71b6500f06 | [] | no_license | gaurishanand13/InterviewPrep-July21 | eec6164034e4e354f33fc7510b49c50884160638 | 36fe575a563bcf220f4befa5153c0b51b9c3de2e | refs/heads/main | 2023-07-24T16:11:30.686136 | 2021-09-03T16:53:59 | 2021-09-03T16:53:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 327 | cpp | Subsequences.cpp | // Subsequences.cpp
#include <iostream>
using namespace std;
int main() {
int n;
char a[100];
cin >> a;
n = strlen(a);
for (int k = 0 ; k < (1 << n) ; k++) {
int pos = 0;
int i = k;
while (i) {
if (i & 1) {
cout << a[pos];
}
pos++;
i = i >> 1;
}
cout << endl;
}
return 0;
}
|
47fe17b58d6f43ce7c3be94808bbc97330dd1785 | e3ac6d1aafff3fdfb95159c54925aded869711ed | /Temp/StagingArea/Data/il2cppOutput/t2251026098.h | 577aa9fe0ed1932f8516a0ae2fb4f28ed0282170 | [] | no_license | charlantkj/refugeeGame- | 21a80d17cf5c82eed2112f04ac67d8f3b6761c1d | d5ea832a33e652ed7cdbabcf740e599497a99e4d | refs/heads/master | 2021-01-01T05:26:18.635755 | 2016-04-24T22:33:48 | 2016-04-24T22:33:48 | 56,997,457 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,242 | h | t2251026098.h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "t1553882356.h"
#include "t3525329788.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
struct t2251026098 : public t1553882356
{
public:
t3525329788 f12;
t3525329788 f13;
bool f14;
public:
inline static int32_t fog12() { return static_cast<int32_t>(offsetof(t2251026098, f12)); }
inline t3525329788 fg12() const { return f12; }
inline t3525329788 * fag12() { return &f12; }
inline void fs12(t3525329788 value)
{
f12 = value;
}
inline static int32_t fog13() { return static_cast<int32_t>(offsetof(t2251026098, f13)); }
inline t3525329788 fg13() const { return f13; }
inline t3525329788 * fag13() { return &f13; }
inline void fs13(t3525329788 value)
{
f13 = value;
}
inline static int32_t fog14() { return static_cast<int32_t>(offsetof(t2251026098, f14)); }
inline bool fg14() const { return f14; }
inline bool* fag14() { return &f14; }
inline void fs14(bool value)
{
f14 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
1c1048ef16c9335e5e3ad2eb5a2191801c62566e | c700ce79c42646a665e5fdd956a7f5e2cef20005 | /list.h | fb43f9260a8ab77c96599f8d81b3d2f2e8bbccd0 | [] | no_license | movingname/cruiser-psu | f5ad378bde2571a5cb36bd9679e4918da262a193 | e97895d561363430423ab3adb85466a6641da9b1 | refs/heads/master | 2021-01-10T06:13:25.239826 | 2014-01-24T19:59:13 | 2014-01-24T19:59:13 | 55,562,280 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,982 | h | list.h | /***************************************************************************
* Copyright 2013 Penn State University
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Cruiser: concurrent heap buffer overflow monitoring using lock-free data
* structures, PLDI 2011, Pages 367-377.
* Authors: Qiang Zeng, Dinghao Wu, Peng Liu.
***************************************************************************/
#ifndef LIST_H
#define LIST_H
#include "common.h"
namespace cruiser{
// 4M
#define LIST_RING_SIZE 0x400000U
// 4 * 64 / 4 or 8 = 64 (32bit system) or 32 (64bit system)
#define BATCH_SIZE (4 * L1_CACHE_BYTES / sizeof(int*))
// Note: this is the ring used for caching CruiserNodes; it is NOT the
// cruiserRing for transmitting buffer addresses.
template<typename T, unsigned int ringSize>
class RingT{
private:
// The cacheline protection is improved over the Hong Kong paper:
// pi and ci are in different cachelines (while in the hongkong paper,
// they are in the same cacheline). So the producer owns the cacheline
// exclusive most of the time, except for "pi" is read by the consumer
// occassionally.
char cache_pad0[L1_CACHE_BYTES];
T* array[ringSize];
unsigned int volatile pi; // The producer index; read by the consumer
char cache_pad1[L1_CACHE_BYTES-sizeof(int)];
unsigned int volatile ci; // The consumer index; read by the producer
char cache_pad2[L1_CACHE_BYTES-sizeof(int)];
// The consumer's local variables
unsigned int pi_snapshot;
unsigned int ci_current; // ci = ci_current, per batch
unsigned int ci_batch;
char cache_pad3[L1_CACHE_BYTES-3*sizeof(int)];
// The producer's local variables
unsigned int ci_snapshot;
unsigned int pi_current; // pi = pi_current, per batch
unsigned int pi_batch;
char cache_pad4[L1_CACHE_BYTES-3*sizeof(int)];
//bool isFull(){return (pi -ci >= ringSize);}
//bool isEmpty(){return ci == pi;}
unsigned toIndex(unsigned i){return i & (ringSize - 1);}
public:
RingT(unsigned preFilled){
assert(preFilled < ringSize);
for(unsigned int i = 0; i < preFilled; i++){
array[i] = (T*) original_malloc(sizeof(T));
}
pi = pi_current = pi_snapshot = preFilled;
ci = ci_current = ci_snapshot = ci_batch = pi_batch = 0;
}
bool produce(T *node){
if(pi_current - ci_snapshot >= ringSize){
if(pi_current - ci >= ringSize)
return false;
else
ci_snapshot = ci;
}
array[toIndex(pi_current)] = node; // Entry value assignment
pi_current++;
pi_batch++;
if(pi_batch >= BATCH_SIZE){
pi_batch = 0;
// Make sure the consumer sees the entry vaule assignment
// before it sees pi is updated.
// __sync_synchronize(); // not needed in x86?
pi = pi_current;
}
return true;
}
bool consume(T * &node){
if(ci_current == pi_snapshot){
if(ci_current == pi)
return false;
else
pi_snapshot = pi;
}
node = array[toIndex(ci_current)];
ci_current++;
ci_batch++;
if(ci_batch >= BATCH_SIZE){
ci_batch = 0;
//__sync_synchronize();
ci = ci_current;
}
return true;
}
};
#ifdef CRUISER_OLD_LIST
// Below is a less efficient list design, which uses Compare-And-Swap to
// insert nodes.
class List:public NodeContainer{
private:
class ListNode{
public:
CruiserNode cn;
ListNode *next;
};
RingT<ListNode, LIST_RING_SIZE> ring;
// Below is an incorrect design by using an array as the pre-allocated
// storage, because if a ListNode can not be inserted back into the
// ring, it has to be freed, which is not allowed for array elements.
// ListNode nodeArray[LIST_RING_SIZE];
ListNode dummy;
public:
#define PRE_ALLOCATED_FACTION 0.25
List():ring(PRE_ALLOCATED_FACTION * LIST_RING_SIZE){
dummy.cn.userAddr = NULL;
dummy.next = NULL;
}
//pushFront
bool insert(const CruiserNode & node){
ListNode* pn;
if(!ring.consume(pn))
pn = (ListNode*)original_malloc( sizeof(ListNode) );
assert(pn);
pn->cn = node;
do{
pn->next = dummy.next;
}while(!__sync_bool_compare_and_swap(&dummy.next, pn->next, pn));
return true;
}
int traverse( int (*pfn)(const CruiserNode &) );
};
int List::traverse( int (*pfn)(const CruiserNode &) ){
ListNode *cur, *prev, *next;
bool bFirst;
again:
prev = &dummy;
cur = dummy.next;
bFirst = true;
while(true){
//if(g_stop)
// return 0;
if(!cur)
return 1;
// pfn Return values:
// 0: to stop monitoring (obosolete)
// 1: have checked one node
// 2: have encountered a dummy node (should never happen)
// 3: a node to be removed
switch(pfn(cur->cn)){
//case 0:
// return 0;
case 1:
prev = cur;
cur = cur->next;
bFirst = false;
break;
// Should never happen because currently
// there is only one list segement.
//case 2:
// return 2;
case 3:
next = cur->next;
if( bFirst ){
if( __sync_bool_compare_and_swap(&dummy.next, cur, next) ){
if(!ring.produce(cur))
original_free(cur);
}
// No matter the deletion succeeded or not, traverse
// again. Otherwise, the "prev" variable may not point to
// the previous node of the node pointed to by the
// "next" variable.
goto again;
}else{
assert(prev->next == cur);
prev->next = next;
if(!ring.produce(cur))
original_free(cur);
cur = next;
}
break;
}
}
}
#else //ifndef CRUISER_OLD_LIST
// Below is the list as described in the paper.
// It uses a ring to cache the deleted list nodes in order to reuse them later.
class List:public NodeContainer{
private:
class ListNode{
public:
CruiserNode cn;
ListNode *next;
void markDelete(){cn.userAddr = (void*)-1L;}
bool isMarkedDelete(){return cn.userAddr == (void*)-1L;}
};
RingT<ListNode, LIST_RING_SIZE> ring;
ListNode dummy;
public:
#define PRE_ALLOCATED_FACTION 0
List():ring(PRE_ALLOCATED_FACTION * LIST_RING_SIZE){
dummy.next = NULL;
dummy.cn.userAddr = NULL;
}
//pushFront
bool insert(const CruiserNode & node){
ListNode* pn;
if(!ring.consume(pn))
pn = (ListNode*)original_malloc( sizeof(ListNode) );
assert(pn);
pn->cn = node;
pn->next = dummy.next;
dummy.next = pn;
return true;
}
int traverse( int (*pfn)(const CruiserNode &) );
};
int List::traverse( int (*pfn)(const CruiserNode &) ){
ListNode *prev, *cur, *next;
cur = dummy.next;
if(!cur)
return 1;
if(!cur->isMarkedDelete()){
// pfn Return values:
// 0: to stop monitoring (obsolete);
// 1: have checked one node
// 2: have encountered a dummy node (should never happen)
// 3: a node is to be removed
if(pfn(cur->cn) == 3)
cur->markDelete();
}
prev = cur;
cur = cur->next;
while(NULL != cur){
next = cur->next;
if(cur->isMarkedDelete()){
prev->next = next;
if(!ring.produce(cur))
original_free(cur);//delete cur;
}else{
switch(pfn(cur->cn)){
// As the "stop monitoring" feature may be exploited,
// we disallow it in this implementation.
//case 0: // Stop monitoring
// return 0;
case 1:
prev = cur;
break;
// Should never happen because for this implementation
// there is only one dummy node.
//case 2:
// return 2;
case 3:
prev->next = next;
if(!ring.produce(cur))
original_free(cur);
break;
default:
break;
}
}
cur = next;
}
return 1;
}
#endif //CRUISER_OLD_LIST
}//namespace cruiser
#endif //LIST_H
|
2e4ab254c46e494a60a1ba8c5c6ceb11ab0cae7f | 7fb9da0070acd4b197364540c498f5948adc8d53 | /ARMY/army.cpp | 7332315d13fa5f913492020d8695e37488f00ec7 | [] | no_license | omkaracharya/SPOJ | 5c2971ee1136ffacd85b2edddd351c9bcff696da | 92dafb93c63ec3497e4d1f08e65718ce0e19fb76 | refs/heads/master | 2021-05-28T14:43:29.848622 | 2015-04-12T12:47:35 | 2015-04-12T12:47:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,406 | cpp | army.cpp | #include <stdio.h>
#include <iostream>
using namespace std;
int main(){
int test,ng,nm;
scanf("%d",&test);
printf("\n");
int arr[test],flag,x,y,min1,min2,temp,count1,count2;
for(int i=0;i<test;i++){
scanf("%d%d",&ng,&nm);
int nga[ng],nma[nm];
count1 = ng;
count2 = nm;
for(int j=0;j<ng;j++){
scanf("%d",&nga[j]);
}
for(int j=0;j<nm;j++){
scanf("%d",&nma[j]);
}
for(int j=0;j<ng-1;j++){
for (int d=0;d<ng-j-1;d++){
if(nga[d] > nga[d+1]){
temp = nga[d];
nga[d] = nga[d+1];
nga[d+1] = temp;
}
}
}
for(int j=0;j<nm-1;j++){
for (int d=0;d<nm-j-1;d++){
if(nma[d] > nma[d+1]){
temp = nma[d];
nma[d] = nma[d+1];
nma[d+1] = temp;
}
}
}
printf("\n");
min1 = nga[0];
min2 = nma[0];
x=0;
y=0;
flag=0;
for(int j=0;j<(nm+ng);j++){
if(min1 < min2){
count1--;
if(count1 != 0){
min1 = nga[x+1];
x = x+1;
}else{
flag = 1;
break;
}
}else{
count2--;
if(count2 != 0){
min2 = nma[y+1];
y = y+1;
}else{
flag = 2;
break;
}
}
}
if(flag == 2){
arr[i] = 1;
}else if(flag == 1){
arr[i] = 2;
}
}
for(int i=0;i<test;i++){
if(arr[i] == 1){
printf("Godzilla\n");
}else if(arr[i] == 2){
printf("MechaGodzilla\n");
}
}
return 0;
} |
fa3e215264ec6039acf4974e32ba0a517379756b | 73b66af86d033d5367d52bf32ca23e8bd6f45086 | /classfication-GNN/agpAlg.cpp | 7ff48c3be2c82e91d2da59bf5ae935d50144fc3e | [] | no_license | wanghzccls/AGP-Approximate_Graph_Propagation | 968c1de38666bfe1472c34b69d714ccd59262544 | f5d2dff8011dbef8ee08adf336039e473b74f4ff | refs/heads/main | 2023-08-28T16:48:26.495469 | 2021-10-30T11:23:39 | 2021-10-30T11:23:39 | 374,632,189 | 7 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 15,342 | cpp | agpAlg.cpp | #include "agpAlg.h"
using namespace std;
using namespace Eigen;
namespace propagation
{
double Agp::agp_operation(string dataset,string agp_alg,uint mm,uint nn,int LL,double rmaxx,double alphaa,double tt,Eigen::Map<Eigen::MatrixXd> &feat)
{
int NUMTHREAD=40; //Number of threads
rmax=rmaxx;
m=mm;
n=nn;
L=LL;
alpha=alphaa;
t=tt;
dataset_name=dataset;
el=vector<uint>(m);
pl=vector<uint>(n+1);
string dataset_el="data/"+dataset+"_adj_el.txt";
const char *p1=dataset_el.c_str();
if (FILE *f1 = fopen(p1, "rb"))
{
size_t rtn = fread(el.data(), sizeof el[0], el.size(), f1);
if(rtn!=m)
cout<<"Error! "<<dataset_el<<" Incorrect read!"<<endl;
fclose(f1);
}
else
{
cout<<dataset_el<<" Not Exists."<<endl;
exit(1);
}
string dataset_pl="data/"+dataset+"_adj_pl.txt";
const char *p2=dataset_pl.c_str();
if (FILE *f2 = fopen(p2, "rb"))
{
size_t rtn = fread(pl.data(), sizeof pl[0], pl.size(), f2);
if(rtn!=n+1)
cout<<"Error! "<<dataset_pl<<" Incorrect read!"<<endl;
fclose(f2);
}
else
{
cout<<dataset_pl<<" Not Exists."<<endl;
exit(1);
}
int dimension=feat.rows();
vector<thread> threads;
Du_a=vector<double>(n,0);
Du_b=vector<double>(n,0);
random_w = vector<int>(dimension);
rowsum_pos = vector<double>(dimension,0);
rowsum_neg = vector<double>(dimension,0);
for(int i = 0 ; i < dimension ; i++ )
random_w[i] = i;
random_shuffle(random_w.begin(),random_w.end());
double rrr; //a=1-rrr; b=r;
if((dataset_name=="Amazon2M_train"||dataset_name=="Amazon2M_full")&& L==4)
rrr=0.2;
else
rrr=0.5;
for(uint i=0; i<n; i++)
{
uint du=pl[i+1]-pl[i];
Du_a[i]=pow(du,1-rrr);
Du_b[i]=pow(du,rrr);
}
for(int i=0; i<dimension; i++)
{
for(uint j=0; j<n; j++)
{
if(feat(i,j)>0)
rowsum_pos[i]+=feat(i,j);
else
rowsum_neg[i]+=feat(i,j);
}
}
struct timeval t_start,t_end;
double timeCost;
clock_t start_t, end_t;
gettimeofday(&t_start,NULL);
cout<<"Begin propagation..."<<endl;
int ti,start;
int ends=0;
start_t = clock();
for( ti=1 ; ti <= dimension%NUMTHREAD ; ti++ )
{
start = ends;
ends+=ceil((double)dimension/NUMTHREAD);
if(agp_alg=="sgc_agp")
threads.push_back(thread(&Agp::sgc_agp,this,feat,start,ends));
else if(agp_alg=="appnp_agp")
threads.push_back(thread(&Agp::appnp_agp,this,feat,start,ends));
else if(agp_alg=="gdc_agp")
threads.push_back(thread(&Agp::gdc_agp,this,feat,start,ends));
}
for( ; ti<=NUMTHREAD ; ti++ )
{
start = ends;
ends+=dimension/NUMTHREAD;
if(agp_alg=="sgc_agp")
threads.push_back(thread(&Agp::sgc_agp,this,feat,start,ends));
else if(agp_alg=="appnp_agp")
threads.push_back(thread(&Agp::appnp_agp,this,feat,start,ends));
else if(agp_alg=="gdc_agp")
threads.push_back(thread(&Agp::gdc_agp,this,feat,start,ends));
}
for (int t = 0; t < NUMTHREAD ; t++)
threads[t].join();
vector<thread>().swap(threads);
end_t = clock();
double total_t = (double)(end_t - start_t) / CLOCKS_PER_SEC;
gettimeofday(&t_end, NULL);
timeCost = t_end.tv_sec - t_start.tv_sec + (t_end.tv_usec - t_start.tv_usec)/1000000.0;
cout<<"The propagation time: "<<timeCost<<" s"<<endl;
cout<<"The clock time : "<<total_t<<" s"<<endl;
double dataset_size=(double)(((long long)m+n)*4+(long long)n*dimension*8)/1024.0/1024.0/1024.0;
return dataset_size;
}
//SGC_AGP
void Agp::sgc_agp(Eigen::Ref<Eigen::MatrixXd>feats,int st,int ed)
{
uint seed=time(NULL)^pthread_self();
double** residue=new double*[2];
for(int i=0; i<2; i++)
residue[i]=new double[n];
for(int it=st; it<ed; it++)
{
int w=random_w[it];
double rowsum_p=rowsum_pos[w];
double rowsum_n=rowsum_neg[w];
double rmax_p=rowsum_p*rmax;
double rmax_n=rowsum_n;
if(dataset_name=="papers100M")
rmax_n*=(rmax/50);
else
rmax_n*=rmax;
double MaxPR=0; //max positive residue
double MaxNR=0; //max negative residue(consider absolute value)
for(uint ik=0; ik<n; ik++)
{
double tmpf=feats(w,ik)/Du_b[ik];
residue[0][ik]=tmpf;
residue[1][ik]=0;
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
feats(w,ik)=0;
}
uint j=0,k=0;
for(int il=0; il<=L; il++)
{
if(dataset_name=="papers100M" && L==10)
{
if(il<3)
rmax_n=rowsum_n*(1.8e-9);
else if(il>=3&&il<=5)
rmax_n=rowsum_n*(1.3e-9);
else
rmax_n=rowsum_n*(0.3e-9);
}
j=il%2;
k=1-j;
if(((MaxPR<=rmax_p)&&(MaxNR>=rmax_n))||(il==L)){
for(uint ik=0; ik<n; ik++)
{
feats(w,ik)=residue[j][ik]*Du_b[ik];
}
break;
}
for(uint ik=0; ik<n; ik++)
{
double old=residue[j][ik];
residue[j][ik]=0;
if(old>rmax_p||old<rmax_n)
{
uint im,v,dv;
double ran;
for(im=pl[ik]; im<pl[ik+1]; im++)
{
v=el[im];
dv=pl[v+1]-pl[v];
if(old>rmax_p*Du_a[v]||old<rmax_n*Du_a[v])
{
residue[k][v]+=old/dv;
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
{
ran=rand_r(&seed)%RAND_MAX/(double)RAND_MAX;
break;
}
}
for(; im<pl[ik+1]; im++)
{
v=el[im];
if(ran*rmax_p*Du_a[v]<old)
{
residue[k][v]+=rmax_p/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else if (old<ran*rmax_n*Du_a[v])
{
residue[k][v]+=rmax_n/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
break;
}
}
}
}
}
for(int i=0; i<2; i++)
delete[]residue[i];
delete[]residue;
}
//APPNP_AGP
void Agp::appnp_agp(Eigen::Ref<Eigen::MatrixXd>feats,int st,int ed)
{
uint seed=time(NULL)^pthread_self();
double** residue=new double*[2];
for(int i=0; i<2; i++)
residue[i]=new double[n];
for(int it=st; it<ed; it++)
{
int w=random_w[it];
double rowsum_p=rowsum_pos[w];
double rowsum_n=rowsum_neg[w];
double rmax_p=rowsum_p*rmax;
double rmax_n=rowsum_n;
if(dataset_name=="papers100M")
rmax_n*=(rmax/50);
else
rmax_n*=rmax;
double MaxPR=0; //max positive residue
double MaxNR=0; //max negative residue(consider absolute value)
for(uint ik=0; ik<n; ik++)
{
double tmpf=feats(w,ik);
residue[0][ik]=tmpf;
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
residue[1][ik]=0;
feats(w,ik)=0;
}
int j=0,k=0;
for(int il=0; il<=L; il++)
{
j=il%2;
k=1-j;
if(((MaxPR<=rmax_p)&&(MaxNR>=rmax_n))||(il==L)){
for(uint ik=0; ik<n; ik++)
feats(w,ik)+=residue[j][ik];
break;
}
for(uint ik=0; ik<n; ik++)
{
double old=residue[j][ik];
residue[j][ik]=0;
if(old>rmax_p||old<rmax_n)
{
uint im,v;
double ran;
feats(w,ik)+=old*alpha;
for(im=pl[ik]; im<pl[ik+1]; im++)
{
v=el[im];
if(old>rmax_p*Du_a[v]/(1-alpha)||old<rmax_n*Du_a[v]/(1-alpha)){
residue[k][v]+=(1-alpha)*old/(Du_a[v]*Du_b[ik]);
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
{
ran=rand_r(&seed)%RAND_MAX/(double)RAND_MAX;
break;
}
}
for(; im<pl[ik+1]; im++)
{
v=el[im];
if(ran*rmax_p*Du_a[v]/(1-alpha)<old){
residue[k][v]+=rmax_p/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else if (old<ran*rmax_n*Du_a[v]/(1-alpha)){
residue[k][v]+=rmax_n/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
break;
}
}
else{
feats(w,ik)+=old;
}
}
}
}
for(int i=0; i<2; i++)
delete[] residue[i];
delete[] residue;
}
//GDC_AGP
void Agp::gdc_agp(Eigen::Ref<Eigen::MatrixXd>feats,int st,int ed)
{
uint seed=time(NULL)^pthread_self();
double** residue=new double*[2];
for(int i=0; i<2; i++)
residue[i]=new double[n];
double W[L+1]= {0};
double Y[L+1]= {0};
long long tempp[L+1];
tempp[0]=1;
tempp[1]=1;
for(int ik=0; ik<=L; ik++)
{
if(ik>1)
tempp[ik]=tempp[ik-1]*ik;
W[ik]=exp(-t)*pow(t,(ik))/tempp[ik];
}
for(int ik=0; ik<=L; ik++)
{
Y[ik]=1;
for(int ij=0; ij<=ik; ij++)
Y[ik]-= W[ij];
}
for(int it=st; it<ed; it++)
{
int w=random_w[it];
double rowsum_p=rowsum_pos[w];
double rowsum_n=rowsum_neg[w];
double rmax_p=rowsum_p*rmax;
double rmax_n=rowsum_n;
if(dataset_name=="papers100M")
rmax_n*=(rmax/50);
else
rmax_n*=rmax;
double MaxPR=0; //max positive residue
double MaxNR=0; //max negative residue(consider absolute value)
for(uint ik=0; ik<n; ik++)
{
double tmpf=feats(w,ik);
residue[0][ik]=tmpf;
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
residue[1][ik]=0;
feats(w,ik)=0;
}
int j=0,k=0;
for(int il=0; il<=L; il++)
{
j=il%2;
k=1-j;
if(((MaxPR<=rmax_p)&&(MaxNR>=rmax_n))||(il==L)){
for(uint ik=0; ik<n; ik++)
feats(w,ik)+=residue[j][ik];
break;
}
for(uint ik=0; ik<n; ik++)
{
double old=residue[j][ik];
residue[j][ik]=0;
if(old>rmax_p||old<rmax_n)
{
uint im,v;
double ran;
feats(w,ik)+=old*W[il]/Y[il];
for(im=pl[ik]; im<pl[ik+1]; im++)
{
v=el[im];
if(old>rmax_p*Du_a[v]/(Y[il+1]/Y[il])||old<rmax_n*Du_a[v]/(Y[il+1]/Y[il]))
{
residue[k][v]+=(Y[il+1]/Y[il])*old/(Du_b[ik]*Du_a[v]);
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
{
ran=rand_r(&seed)%RAND_MAX/(double)RAND_MAX;
break;
}
}
for(; im<pl[ik+1]; im++)
{
v=el[im];
if(ran*rmax_p*Du_a[v]/(Y[il+1]/Y[il])<old)
{
residue[k][v]+=rmax_p/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else if (old<ran*rmax_n*Du_a[v]/(Y[il+1]/Y[il]))
{
residue[k][v]+=rmax_n/Du_a[v];
double tmpf=residue[k][v];
if(tmpf>MaxPR)
MaxPR=tmpf;
else if(tmpf<MaxNR)
MaxNR=tmpf;
}
else
break;
}
}
}
}
}
for(int i=0; i<2; i++)
delete[] residue[i];
delete[] residue;
}
}
|
ee65225131eca6153260d0bfa324bfcecb0eac11 | eb3d7cbbb4ded421fa211384f5ee1df251646577 | /src/geos-base.cpp | a5ff8c6b9176b63a2eec83a039b918873c6e4f3a | [] | no_license | SymbolixAU/geom | f2ab70e698881079ec5c09ac7c6ee7d74420bf87 | 45a913ddb3942807635547ce471a08d0e5f3af62 | refs/heads/master | 2021-05-19T19:02:29.902255 | 2020-04-01T04:52:55 | 2020-04-01T04:52:55 | 252,074,507 | 0 | 0 | null | 2020-04-01T04:46:56 | 2020-04-01T04:46:55 | null | UTF-8 | C++ | false | false | 1,467 | cpp | geos-base.cpp |
#include "geos-base.h"
#include "geos-coords.h"
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
std::string cpp_version_impl() {
return GEOSversion();
}
static void __errorHandler(const char *fmt, ...) {
char buf[BUFSIZ], *p;
va_list ap;
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
p = buf + strlen(buf) - 1;
if(strlen(buf) > 0 && *p == '\n') *p = '\0';
Rcpp::Function error(".stop_geos", Rcpp::Environment::namespace_env("geom"));
error(buf);
return;
}
static void __warningHandler(const char *fmt, ...) {
char buf[BUFSIZ], *p;
va_list ap;
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
va_end(ap);
p = buf + strlen(buf) - 1;
if(strlen(buf) > 0 && *p == '\n') *p = '\0';
Rcpp::Function warning("warning");
warning(buf);
return;
}
static void __countErrorHandler(const char *fmt, void *userdata) {
int *i = (int *) userdata;
*i = *i + 1;
}
static void __emptyNoticeHandler(const char *fmt, void *userdata) { }
GEOSContextHandle_t geos_init(void) {
#ifdef HAVE350
GEOSContextHandle_t context = GEOS_init_r();
GEOSContext_setNoticeHandler_r(context, __warningHandler);
GEOSContext_setErrorHandler_r(context, __errorHandler);
return context;
#else
return initGEOS_r((GEOSMessageHandler) __warningHandler, (GEOSMessageHandler) __errorHandler);
#endif
}
void geos_finish(GEOSContextHandle_t context) {
#ifdef HAVE350
GEOS_finish_r(context);
#else
finishGEOS_r(context);
#endif
}
|
25e2b9df420e45409c6bf09622ffa1f7dac7e63b | b3fd6c4697a7990ca7ba387adfb9b43842ffc589 | /spFCTRL.cpp | 93606dd4e56626c8408186a55ab4653227d3c655 | [] | no_license | jainrishabh98/CP | 48ab325fbfced6174778ec74e286b0874df9d82b | 3d244de1096c484bb663ac328655a879d1f28b54 | refs/heads/master | 2021-06-07T09:10:42.900663 | 2020-02-05T08:58:39 | 2020-02-05T08:58:39 | 150,934,959 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | cpp | spFCTRL.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main ()
{
int t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
ll m =1;
ll ans = 0;ll i = 5;
while(m!=0)
{
m = n/i;
i = i*5;
ans += m;
}
cout<<ans<<"\n";
}
return 0;
} |
874067d1a94bb1396de96286c8fdac2dbd79f31f | fadedee801e9eea16e97ea980a255267caf64683 | /DIV1/SRM627/HappyLetterDiv1.cpp | 3c3df965e1b432b663d6fa1f38d93d0e2d89cc0e | [] | no_license | Vetteru/Topcoder | ef8fd271129a262c864cc298721aed24f4a81ef2 | cca7c662901a0b8e27a3d5a03e5fbe3d8e3ba339 | refs/heads/master | 2021-01-10T20:40:35.689482 | 2015-07-14T12:57:20 | 2015-07-14T12:57:20 | 21,316,426 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,099 | cpp | HappyLetterDiv1.cpp | // BEGIN CUT HERE
// END CUT HERE
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
bool isPrime(int a){for(int i=2; i*i<=a; i++) if(a%i==0) return false; return a>1;}
string toStr(int a){ostringstream oss; oss<<a; return oss.str();}
int toInt(string s){return atoi(s.substr(0,s.size()).c_str());}
class HappyLetterDiv1 {
public:
string getHappyLetters(string letters) {
map<char, int> M;
for(int i = 0; i < (int)letters.length(); i++) M[letters[i]]++;
string str = letters;
sort(ALL(str));
str.erase(unique(ALL(str)), str.end());
string res = "";
for(int i = 0; i < (int)str.length(); i++) if(possible(str[i], M)) res += str[i];
return res;
}
bool possible(char c, map<char,int> M){
while(1){
char a = '?', b = '?';
for(char i = 'a'; i <= 'z'; i++){
if(i == c) continue;
if(M[a] <= M[i] && M[i] > 0){
b = a;
a = i;
}else if(M[b] < M[i] && M[i] > 0){
b = i;
}
}
if(a == '?' || b == '?') break;
M[a]--; M[b]--;
}
int cnt = 0;
for(char i = 'a'; i <= 'z'; i++) if(i != c) cnt += M[i];
return cnt < M[c];
}
// BEGIN CUT HERE
public:
void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); }
private:
template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
void verify_case(int Case, const string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
void test_case_0() { string Arg0 = "aabbacccc"; string Arg1 = "abc"; verify_case(0, Arg1, getHappyLetters(Arg0)); }
void test_case_1() { string Arg0 = "aaaaaaaccdd"; string Arg1 = "a"; verify_case(1, Arg1, getHappyLetters(Arg0)); }
void test_case_2() { string Arg0 = "ddabccadb"; string Arg1 = "abcd"; verify_case(2, Arg1, getHappyLetters(Arg0)); }
void test_case_3() { string Arg0 = "aaabbb"; string Arg1 = ""; verify_case(3, Arg1, getHappyLetters(Arg0)); }
void test_case_4() { string Arg0 = "rdokcogscosn"; string Arg1 = "cos"; verify_case(4, Arg1, getHappyLetters(Arg0)); }
// END CUT HERE
};
// BEGIN CUT HERE
int main(){
HappyLetterDiv1 ___test;
___test.run_test(-1);
}
// END CUT HERE
|
2d7225712311f8a8f20dca47e7776d19c9a30ac5 | 9d7f4c58b78a11f9f7aa3ff7ad37ea6ec49c991d | /include/HTCalc.h | 788a818f6cbcced4c24d8fda6102564584904520 | [] | no_license | UHH2/VLQToTopAndLepton | db2439a4cfd3eb872d9c7052de5e06368387f304 | 9405eed66c8dcb53770e29f53f1620741d3d8ac1 | refs/heads/master | 2020-04-06T06:34:12.329184 | 2018-10-30T15:05:38 | 2018-10-30T15:05:38 | 28,093,098 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,190 | h | HTCalc.h | #pragma once
#include <iostream>
#include <memory>
#include "UHH2/core/include/AnalysisModule.h"
#include "UHH2/core/include/Event.h"
#include "UHH2/common/include/ObjectIdUtils.h"
class HTCalc: public uhh2::AnalysisModule {
public:
enum jetTyp {jet, topjet};
explicit HTCalc( uhh2::Context & ctx,
const boost::optional<JetId> & jetid = boost::none,
const jetTyp jetColl = jet,
const std::string & collection = "");
virtual bool process( uhh2::Event & event);
private:
std::string m_collection;
jetTyp m_jetTyp;
boost::optional<JetId> m_jetid;
uhh2::Event::Handle<double> ht_handle;
uhh2::Event::Handle<std::vector<Jet> > h_jets;
uhh2::Event::Handle<std::vector<TopJet> > h_topjets;
};
/*
class METSelection: public uhh2::Selection {
public:
explicit METSelection(double met_);
virtual bool passes(const uhh2::Event & event);
private:
double met;
};
*/
/*
class HTSelection: public uhh2::Selection{
public:
//enum htType{HT, HtLep};
explicit HTSelection(uhh2::Context & ctx, double HTmin);
virtual bool process(const uhh2::Event & event);
private:
//htType type;
double HTmin;
uhh2::Event::Handle<double> ht;
};
*/
|
ffbe57c98ded4f9637345c8d0e099b91c843cc72 | 73aa2b691105d33ced93e6c962c8e6d7285386df | /src/friendsmodel.cpp | 67dbc9108e63d63ed634b76fc0aea2ae5086bb3e | [] | no_license | sandsmark/bluefish | f905ae58ff498faa0847e058c8f0842aace8736b | e1a0602f36fd247232b3ecc4fcedb3ed51b98052 | refs/heads/master | 2021-01-10T21:11:57.083842 | 2014-12-13T05:56:33 | 2014-12-13T05:56:33 | 25,899,614 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,627 | cpp | friendsmodel.cpp | #include "friendsmodel.h"
#include <QJsonObject>
FriendsModel::FriendsModel(QObject *parent) :
QAbstractListModel(parent)
{
}
QHash<int, QByteArray> FriendsModel::roleNames() const
{
QHash<int, QByteArray> names;
names[UsernameRole] = "username";
names[DisplayNameRole] = "displayName";
return names;
}
void FriendsModel::parseJson(const QJsonArray &friends)
{
beginResetModel();
m_friends.clear();
endResetModel();
int added = 0;
foreach (const QJsonValue &item, friends) {
QJsonObject object = item.toObject();
QString username = object["name"].toString();
QString displayName = object["display"].toString();
if (displayName.isNull()) displayName = "";
if (username.isEmpty()) {
qWarning() << "invalid user in friend array" << object;
continue;
}
m_friends.append(Friend());
m_friends.last().username = username;
m_friends.last().displayName = displayName;
added++;
}
beginInsertRows(QModelIndex(), 0, added - 1);
endInsertRows();
//endResetModel();
}
QVariant FriendsModel::data(const QModelIndex &index, int role) const
{
if (index.row() > m_friends.size() || index.row() < 0) {
qWarning() << "asked for invalid row" << index.row();
return QVariant();
}
switch (role) {
case UsernameRole:
return m_friends[index.row()].username;
break;
case DisplayNameRole:
return m_friends[index.row()].displayName;
default:
qWarning() << "unknown role" << role;
return QVariant();
}
}
|
e74fabd7a74cc06c685a044f304cf3c5c9d6a34c | 8ee1af57190c0dd7936839247a155f5ffa6ef76e | /engine/src/ShaderDescriptor.h | ebf488ef4897e046e635837584f3affe8f70ed82 | [] | no_license | WinteryFox/VixenEngineVulkan | 75eff0834f11759265d1337492d2c8eb9e8f5d14 | 42d661dbfa9d5e122959c313ca91db112588a526 | refs/heads/master | 2022-09-23T00:07:17.345731 | 2022-02-15T20:30:24 | 2022-02-15T20:30:24 | 180,230,015 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 587 | h | ShaderDescriptor.h | #pragma once
#include <cstdio>
#include <vulkan/vulkan.h>
namespace Vixen {
class ShaderDescriptor {
const uint32_t binding;
const size_t size;
const VkDescriptorType type;
const VkShaderStageFlags stage;
public:
ShaderDescriptor(uint32_t binding, size_t size, VkDescriptorType type, VkShaderStageFlags stage);
[[nodiscard]] uint32_t getBinding() const;
[[nodiscard]] VkDescriptorType getType() const;
[[nodiscard]] VkShaderStageFlags getStage() const;
[[nodiscard]] size_t getSize() const;
};
}
|
bc45dcb73620ab39ece4a3974105d7782b3ff4bd | 3f427cb040a6d92e1e762f634bd3e70fd4e6ead1 | /timer_demo/main.cpp | 91b63eb1a37064dbdee863a4e09fd55fab50854d | [] | no_license | koinas/test_project | 181979c6171c41ad14c3e38fb467131e62b0886b | 30bda04ca308cd220b26fdad106ffef4e370831b | refs/heads/master | 2016-09-06T19:34:20.810565 | 2014-08-18T19:25:00 | 2014-08-18T19:25:00 | 23,051,121 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 600 | cpp | main.cpp |
#include <windows.h>
#include <iostream>
VOID CALLBACK TimerProc(
__in HWND hwnd,
__in UINT uMsg,
__in UINT_PTR idEvent,
__in DWORD dwTime
);
#include "math.h"
int main(void)
{
double a = 0.1;
double b = 0.1;
if(cos(a)!=cos(b))
Sleep(1);
SetTimer(0,0,500,TimerProc);
MSG msg;
while(1)
{
if(PeekMessage(&msg,0,0,0,TRUE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
//std::cout<<"hello";
}
VOID CALLBACK TimerProc(
__in HWND hwnd,
__in UINT uMsg,
__in UINT_PTR idEvent,
__in DWORD dwTime
)
{
std::cout<<"TIMER\n";
std::cout<<"UPDATED\n";
} |
ac2252ab75231a9f7cb822fa9d56019f83031633 | c1a1a48f204540af9bac96dd40bec23185c4f5a7 | /sorting.cpp | 6131331c28936c502a754ceb5e9e0dc908ee898d | [] | no_license | boldenth/Algorithms | 5b39b77fd71ff087a1f430fa6ff92ffb8d860300 | fda1058a7880bc2b775cea7ad92904f9e8eaf7f7 | refs/heads/master | 2021-06-14T01:58:58.236162 | 2017-04-12T00:45:53 | 2017-04-12T00:45:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,263 | cpp | sorting.cpp | /*
Author: Thomas Bolden
Project: Sorting Methods
Date: March 7, 2017
*/
#include <iostream>
using std::cout; using std::cin; using std::endl;
using std::ostream;
#include <iomanip> // not used
#include <cmath> // not used
#include <ctime> // used to seed random number and to time algos
using std::clock_t; using std::clock;
#include <vector>
using std::vector;
#include <string>
using std::string; using std::to_string;
using std::stod; using std::stol;
#include <algorithm>
using std::copy; using std::transform; using std::reverse;
using std::plus; using std::iter_swap;
// =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
//
// List Class with Sorting Methods
// - TODO: Add heap sort, binary tree sort
// - TODO: Fix output, doesn't make much sense with
// the recursive algorithms
//
// private:
// vector<T> list_ .
// size_t size_ .
// long comparisons_ .
// long swaps_ .
// long loops_ .
// long time_ .
//
// public:
// void bubble_sort .
// void selection_sort .
// void insertion_sort .
// void merge_sort .
// void quick_sort .
//
// =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
template <typename T>
class List{
public: // attributes
vector<T> list_;
string method_;
size_t size_;
long comparisons_;
long swaps_;
long loops_;
double time_;
public: // methods
List(vector<T>&);
void bubble_sort();
void selection_sort();
void insertion_sort();
void merge_sort(int, int);
void quick_sort(int, int);
//friend ostream& operator<<(ostream&, const List<T>& l);
};
//
template <typename T>
List<T>::List(vector<T>& v){
list_ = v;
size_ = v.size();
}
// print list
//template <typename T>
//ostream& operator << (ostream& os, const List<T>& l){
// string to_print;
// return os;
//}
// currently only supports longs !!!
int main(){
int case_num, list_length, print_list, max_list_size;
cout << "How large of a list do you want? ";
cin >> max_list_size;
cout << "Sorting Method? (1) Bubble, (2) Selection, ";
cout << endl << "(3) Insertion, (4) Merge, (5) Quick: ";
cin >> case_num;
cout << "Would you like to print the sorted list for verification? ";
cout << endl << "(1) YES, (0) NO: ";
cin >> print_list;
string name;
srand(time(NULL));
list_length = max_list_size;
// enable for variable list size
//list_length = rand() % max_list_size;
vector<long> list_init;
// following loop fills the list with random numbers
for(int i = 0; i < list_length; i++){
list_init.push_back(rand()%max_list_size);
}
List<long> list(list_init);
switch (case_num){
// bubble sort
case 1: {
clock_t begin = clock();
list.bubble_sort();
clock_t end = clock();
list.time_ = double(end - begin) / CLOCKS_PER_SEC;
break;
}
// selection sort
case 2: {
clock_t begin = clock();
list.selection_sort();
clock_t end = clock();
list.time_ = double(end - begin) / CLOCKS_PER_SEC;
break;
}
// insertion sort
case 3: {
clock_t begin = clock();
list.insertion_sort();
clock_t end = clock();
list.time_ = double(end - begin) / CLOCKS_PER_SEC;
break;
}
// merge sort
case 4: {
clock_t begin = clock();
list.merge_sort(0, list.size_);
clock_t end = clock();
list.time_ = double(end - begin) / CLOCKS_PER_SEC;
break;
}
// quick sort
case 5: {
clock_t begin = clock();
list.quick_sort(0, list.size_);
clock_t end = clock();
list.time_ = double(end - begin) / CLOCKS_PER_SEC;
break;
}
} // switch
cout << "To " << list.method_ << " sort the list of length " << list.size_;
cout << " required... " << endl;
cout << list.time_ << " seconds," << endl;
cout << list.loops_ << " passes," << endl;
cout << list.comparisons_ << " comparisons," << endl;
cout << "and " << list.swaps_ << " swaps." << endl;
//cout << "Passes: " << list.loops_ << endl;
// printing the list for verification purposes
if(print_list){
for(int j = 0; j < list.size_; j++){
cout << list.list_[j] << ' ';
}
cout << endl;
}
// if I made a friend function to print (haven't yet)
//cout << list;
return 0;
}
// Implimentation of the Bubble Sort Algorithm
// with O(n^2) complexity in the worst case
// and O(n) complexity in the best case
template <typename T>
void List<T>::bubble_sort(){
method_ = "bubble";
for(int loops = 0; loops < size_ - 1; loops++){
loops_++;
for(int index = 0; index < size_ - loops - 1; index++){
comparisons_++;
if(list_[index] > list_[index+1]){
swaps_++;
T temp = list_[index];
list_[index] = list_[index+1];
list_[index+1] = temp;
} // swaps
} // comparisons
} // passes
}
// Implimentation of the Selection Sort Algorithm
// with O(n^2) complexity in the worst case
// and O(n) complexity in the best case
template <typename T>
void List<T>::selection_sort(){
method_ = "selection";
int index_min;
for(int loops = 0; loops < size_ - 1; loops++){
loops_++;
index_min = loops;
for(int index = loops + 1; index < size_; index++){
comparisons_++;
if(list_[index] < list_[index_min]){
swaps_++;
T temp = list_[index];
list_[index] = list_[index_min];
list_[index_min] = temp;
} // swaps
} // comparisons
} // passes
}
// Implimentation of the Insertion Sort Algorithm
// with O(n^2) complexity in the worst case
// and O(n) complexity in the best case
template <typename T>
void List<T>::insertion_sort(){
method_ = "insertion";
loops_++;
for(int loops = 1; loops < size_; loops++){
comparisons_++;
int index = loops;
while(index > 0 && list_[index] < list_[index-1]){
swaps_++;
T temp = list_[index];
list_[index] = list_[index-1];
list_[index-1] = temp;
index--;
} // swaps / "insertions"
} // comparisons <-- NOT REALLY - FIX REQUIRED!!
// should it be same as swaps + 1 per element?
}
// Implimentation of the Merge Sort Algorithm
// with O(nlogn) complexity in the worst case
// and O(nlogn) complexity in the best case
template <typename T>
void List<T>::merge_sort(int left, int right){
method_ = "merge"; // http://quiz.geeksforgeeks.org/merge-sort/
T temp;
comparisons_++;
if(left < right){
int mid = left + (right - left) / 2; // prevents overflow
loops_++;
merge_sort(left, mid);
merge_sort(mid+1, right);
vector<T> tempLeft, tempRight;
int ls = mid - left + 1;
int rs = right - mid;
for(int l = 0; l < ls; l++){
swaps_++;
tempLeft.push_back(list_[left+l]);
}
for(int r = 0; r < rs; r++){
swaps_++;
tempRight.push_back(list_[mid+r+1]);
}
int i = 0;
int j = 0;
int k = left;
while(i < ls && j < rs){
comparisons_++;
if(tempLeft[i] <= tempRight[j]){
list_[k] = tempLeft[i];
i++;
}
else{
list_[k] = tempRight[j];
j++;
}
k++;
}
// add leftovers
while(i < ls){
list_[k] = tempLeft[i];
i++;
k++;
}
while(j < rs){
list_[k] = tempRight[j];
j++;
k++;
}
}
}
// Implimentation of the Quick Sort Algorithm
// with O(n^2) complexity in the worst case
// and O(nlogn) complexity in the best case
template <typename T>
void List<T>::quick_sort(int left, int right){
method_ = "quick";
int l = left;
int r = right;
int mid = list_[left + (right - left) / 2]; // prevents overflow
T temp;
while (l <= r) {
while (list_[l] < mid){
l++;
}
while (list_[r] > mid){
r--;
}
comparisons_++;
if (l <= r) {
swaps_++;
temp = list_[l];
list_[l] = list_[r];
list_[r] = temp;
l++;
r--;
}
}
// recursive callbacks
if (left < r){
loops_++;
quick_sort(left, r);
}
if (l < right){
loops_++;
quick_sort(l, right);
}
} |
5cd3c7b45a9535bf4e000c97ae9835f2a1292f00 | eb40a068cef3cabd7a0df37a0ec2bde3c1e4e5ae | /src/opr/include/megbrain/opr/muxing.h | 5129a4355bac9835794e7d07e57be593917a2371 | [
"Apache-2.0",
"LicenseRef-scancode-generic-cla"
] | permissive | tpoisonooo/MegEngine | ccb5c089a951e848344f136eaf10a5c66ae8eb6f | b8f7ad47419ef287a1ca17323fd6362c6c69445c | refs/heads/master | 2022-11-07T04:50:40.987573 | 2021-05-27T08:55:50 | 2021-05-27T08:55:50 | 249,964,363 | 1 | 0 | NOASSERTION | 2021-05-27T08:55:50 | 2020-03-25T11:48:35 | null | UTF-8 | C++ | false | false | 1,763 | h | muxing.h | /**
* \file src/opr/include/megbrain/opr/muxing.h
* MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
*
* Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/
#pragma once
#include "megbrain/graph.h"
namespace mgb {
namespace opr {
/*!
* \brief concat and then copy to all
*/
MGB_DEFINE_OPR_CLASS(AllGather, cg::OutshapePureByInshapeOpr<>) // {
class CopyStrategy;
std::unique_ptr<CopyStrategy> m_copy_strategy;
//! input layout corresponding to current copy strategy
std::vector<TensorLayout> m_input_layout;
int m_axis;
void get_output_var_shape(
const TensorShapeArray &inp_shape,
TensorShapeArray &out_shape) const override;
void init_output_comp_node() override;
void do_execute(ExecEnv &env) override;
NodeProp* do_make_node_prop() const override;
void on_mem_status_changed();
OprEventCallback get_opr_event_callback() override final;
void on_output_comp_node_stream_changed() override;
public:
AllGather(const VarNodeArray &input, int axis,
const OperatorNodeConfig &config);
~AllGather();
VarNodeArray grad(const VarNodeArray &out_grad);
static SymbolVarArray make(
const SymbolVarArray &input, int axis,
const OperatorNodeConfig &config = {});
};
}
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
|
80b90bbde0dd2f02bac31a564b9b33813f6f896c | ba5cc6c21bdacdbbe50a6131131af26aedf30c79 | /2017-10-10-std/list.cc | 9f5b2bdfe2c77d1604237794a5a7ca23d0aab97d | [] | no_license | wencakisa/elsys-oop | 4d2dd6a1c0f0f33901813635955a34d7ea3991f9 | dfe6ea435fb5cb317444053fd7bde9aa4d5d99ce | refs/heads/master | 2021-09-14T18:49:51.523085 | 2018-05-17T14:25:03 | 2018-05-17T14:25:03 | 104,384,486 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,217 | cc | list.cc | #include <iostream>
#include <list>
using namespace std;
void print_list(list<int>& l) {
for (list<int>::iterator it = l.begin(); it != l.end(); ++it) {
cout << *it << " ";
}
cout << endl;
}
int main() {
list<int> l;
cout << "Size: " << l.size() << endl;
cout << "Empty: " << l.empty() << endl;
l.push_back(0);
l.push_back(1);
l.push_back(2);
cout << "Size: " << l.size() << endl;
cout << "Empty: " << l.empty() << endl;
print_list(l);
l.push_front(-1);
cout << "Size: " << l.size() << endl;
print_list(l);
cout << "Front: " << l.front() << endl;
cout << "Back: " << l.back() << endl;
print_list(l);
l.insert(l.begin(), -2);
l.insert(l.end(), 3);
print_list(l);
auto it = l.begin();
it++;
l.insert(it, -1);
print_list(l);
// cout << l[0] << endl;
it = l.begin();
it++;
l.erase(it);
print_list(l);
l.erase(l.begin(), l.end());
cout << "Empty: " << l.empty() << endl;
list<int> l1(10);
print_list(l1);
list<int> l2(10, 42);
print_list(l2);
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
list<int> l3(a, a + 10);
print_list(l3);
return 0;
}
|
030b4905cf30ae5e909e0cd19ee5a72d6f61615f | 138b56b150301cf75c163b7b9dc1efa0d624d1fb | /source/include/icma/me/CMAPOSTagger.h | b963d46238ca53aa725decf914c19f7b82fc5d18 | [
"Apache-2.0"
] | permissive | royshan/icma | b5696a958192653230489cada223f44942afe348 | a1655ae6431912d10aa879b6b04d90ffa8b15b50 | refs/heads/master | 2020-12-26T01:12:16.841069 | 2014-09-23T10:37:13 | 2014-09-23T10:37:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,073 | h | CMAPOSTagger.h | /** \file CMAPOSTagger.h
* \brief for the POS tagger using MaxEnt Model.
*
* \author vernkin
*
* Created on March 20, 2009, 10:46 AM
*/
#ifndef _CMAPOSTAGGER_H
#define _CMAPOSTAGGER_H
#include "icma/me/CMABasicTrainer.h"
#include "VTrie.h"
#include "strutil.h"
#include "icma/util/CPPStringUtils.h"
#include "icma/type/cma_ctype.h"
#include "icma/type/cma_wtype.h"
#include "icma/util/StringArray.h"
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>
#include <string>
using namespace maxent::me;
namespace cma{
/**
* Get context of POS(Part of Speech) (zh/chinese)
*
* \param words the words vector
* \param tags the poc tags vector
* \param i the index in the wrods
* \param rareWord whether this word is rareWord
* \param context to hold the return context
* \param ctype indicates the encoding types
*/
void get_pos_zh_scontext(vector<string>& words, vector<string>& tags, size_t i,
bool rareWord, vector<string>& context, CMA_CType *ctype);
/**
* Training the POS Maxent model
*
* \param file the source file, with formate "word1/tag1 word2/tag2 ..."
* \param modelPath is the path of the directory that contains all the model, like
poc.model, sys.dic and so on.
* \param encType the encoding type, default is gb18030
* \param extractFile if set, save the training data to the extractFile and exit
* \param iters how many iterations are required for training[default=15]
* \param method the method of Maximum Model Parameters Estimation [default = gis]
* \param gaussian apply Gaussian penality when training [default=0.0]
* \param isPOS if true, output the tag dictioanry
*/
void pos_train(const char* file, const string& modelPath,
Knowledge::EncodeType encType = Knowledge::ENCODE_TYPE_GB18030,
string posDelimiter = "/", bool isLargeCorpus = false,
const char* extractFile = 0, string method = "gis", size_t iters = 15,
float gaussian = 0.0f);
/**
* \brief to hold the objects in the N-best algorithm
*
*/
struct POSTagUnit{
/**
* the current pos
*/
string pos;
/**
* the score for the current poc
*/
double score;
/**
* the candidate number
*/
int index;
/**
* Previous index in the candidate list. -1 if not exists
*/
int previous;
};
/**
* \brief Tagging the POS Information
* Tagging the POS using the maxent model.
*/
class POSTagger{
public:
typedef StringArray POSUnitType;
/**
* Construct the POSTagger with outer VTrie
* \param model POS model name
* \param loadModel whether loadModel, default is true
*/
POSTagger(const string& model, VTrie* pTrie, bool loadModel = true );
/**
* Construct the POSTagger with inner VTrie (read from dictFile)
*
*/
POSTagger(const string& model, const char* dictFile);
~POSTagger();
/**
* Tag the segmented file with pos (In UTF8 Encoding)
* \param inFile the input file
* \param outFile the output file
*/
void tag_file(const char* inFile, const char *outFile);
/**
* tagging given words list and return N best
* \param words the given words list
* \param N return N best
* \param retSize retSize <= N, the size of segment
* \param to store the result value
*/
void tag_sentence(vector<string>& words, size_t N, size_t retSize,
vector<pair<vector<string>, double> >& segment);
/**
* Only return the best result
* \param words words string vector, values in [ beginIdx, endIdx ) will
* be processed.
* \param segSeq segment sequence. Each unit takes two values, the first
* is beginning index and the second the length of the word
* \param type Character Types array, its range is [ 0, endIdx - beginIdx ).
* \param wordBeginIdx word begin index for the parameter words.
* \param wordEndIdx word end index ( exclusive ) for the parameter words.
* \param seqStartIdx the begin index (include) in the parameter segSeq.
* \param posRet to hold the result value
*/
void tag_sentence_best(
StringVectorType& words,
PGenericArray<size_t>& segSeq,
CharType* types,
size_t wordBeginIdx,
size_t wordEngIdx,
size_t seqStartIdx,
PGenericArray< const char* >& posRet
);
/**
* Quick Tag sentence best, no statistical model is used
* \param words words string vector, values in [ beginIdx, endIdx ) will
* be processed.
* \param segSeq segment sequence. Each unit takes two values, the first
* is beginning index and the second the length of the word
* \param type Character Types array, its range is [ 0, endIdx - beginIdx ).
* \param wordBeginIdx word begin index for the parameter words.
* \param wordEndIdx word end index ( exclusive ) for the parameter words.
* \param seqStartIdx the begin index (include) in the parameter segSeq.
* \param posRet to hold the result value
*/
void quick_tag_sentence_best(
StringVectorType& words,
PGenericArray<size_t>& segSeq,
CharType* types,
size_t wordBeginIdx,
size_t wordEngIdx,
size_t seqStartIdx,
PGenericArray< const char* >& posRet,
bool tagLetterNumber = false
);
/**
* Set the reference to the specific character encoding
*
* \param ctype new specific character encoding
*/
void setCType(CMA_CType *ctype){
ctype_ = ctype;
}
/**
* Append the POS Information into Trie and POS Vector
* \param line a line like: word1 pos1 pos2 ... posN
* \return whether add successfully
*/
bool appendWordPOS(string& line);
private:
/**
* tag word words[i] under given tag history hist
* \param lastIndex the last index of candidates
* \param canSize the used size in the candidates
* \return a list of (tag, score) pair sorted
*/
void tag_word(vector<string>& words, int index, size_t N, string* tags,
POSTagUnit* candidates, int& lastIndex, size_t& canSize,
double initScore, int candidateNum, CMA_WType& wtype);
public:
/** vector to hold the POS information */
vector< POSUnitType > posVec_;
/** default POS */
string defaultPOS;
/** Number POS */
string numberPOS;
/** Letter POS */
string letterPOS;
/** Mixed Letter and Numerber POS*/
string mixedNumberLetterPOS;
/** Punctuation POS */
string puncPOS;
/** Date POS */
string datePOS;
private:
/**
* The maxent model
*/
MaxentModel me;
/**
* If the trie_ passed by parameter the trie_ is not supposed destroyed by
* the POSTagger
*/
VTrie *trie_;
/** Whether the trie is created by the constructor */
bool isInnerTrie_;
/** the encoding type */
CMA_CType *ctype_;
};
}
#endif /* _CMAPOSTAGGER_H */
|
e8aee46bf1a0efa3b2f4b8f5419b82b63971f197 | 7477a778e1a81a35cfd2a435317a1ab6597b4a13 | /chess.cpp | 814bde9ed3ead48364c569bb59fcc8ce06d0cc81 | [] | no_license | GoToChess/OOP-C- | c3b8c3f9f94025fb128ef6a97c6382d4e7c952ff | 1dace45d3508a81153878128b7082be71f216168 | refs/heads/master | 2022-06-09T17:13:01.009347 | 2020-05-07T15:40:57 | 2020-05-07T15:40:57 | 250,331,775 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,300 | cpp | chess.cpp | #include "computer.h"
//code I've been using to test computer class
//********************************************
int main()
{
int difficulty;
int userturn = 1;
int n;
cout << "welcome " << endl;
cpu move1(&difficulty);
Rules king;
Board chess;
while (1)
{
if (userturn)
{
chess.print_board(board);
cout << " user's go... " << endl;
cin >> n;
cout << n << endl;
system("cls");
//run user's code
if(king.incheck('B', board)) // if the user's king is in check (moved into a check)
{
cout << "Game_over, Computer wins" << endl;
break; // breaks while loop and main ends
}
if (king.incheck('W', board))
{
cout << "White king in checkmate" << endl;
}
userturn = 0;
}
if (!userturn)
{
//board display function here
if (difficulty == 1)
{
move1.easy_diff(board);
}
if (difficulty == 2)
{
move1.med_diff(board);
}
if (difficulty == 3)
{
move1.hard_diff(board);
}
if (king.incheck('W', board))
{
cout << " Game over, User wins" << endl;
break;
}
if (king.incheck('B', board))
{
cout << "Black king in checkmate" << endl;
}
userturn = 1;
}
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.