blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
715c73e179101f80ac45fc647d0e6ce783a8694e | d45562166228aa9e416aaf52276a6dd03fcd4b98 | /exercise5.cpp | f29bf87e5dc4ad5d38cd2214e89f0a19b9923418 | [] | no_license | nannanwuhui/C- | 20032fe89e9d7b4a306911183cd79a54a9e4752b | 5e342e581681ee107c5825c9f36e67c8ff2e71b4 | refs/heads/master | 2020-12-24T21:00:50.341393 | 2017-08-04T06:37:22 | 2017-08-04T06:37:22 | 55,964,414 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 485 | cpp | #include <iostream>
#include <cstdio>
using namespace std;
class A
{
public:
virtual void Foo() {}
int m_a;
};
class B : public A
{
public:
virtual ~B() {}
};
class C
{
public:
virtual ~C() {}
};
class D : public B, public C
{
public:
int m_d;
};
int main(){
cout << "sizeof(A):" << sizeof(A) << endl;//16
cout << "sizeof(B):" << sizeof(B) << endl;//16
cout << "sizeof(C):" << sizeof(C) << endl;//8
cout << "sizeof(D):" << sizeof(D) << endl;//32
return 0;
}
| [
"nannanwuhui@aliyun.com"
] | nannanwuhui@aliyun.com |
9445677d265b35b29d89d6ea62b4586d8cecedf3 | ce5f67f199c6397a80fde10d9392bfe291952291 | /rzhang/copyRandomList/Solution.cpp | 40148e2fd770c52709eecf87be76bc2a35396227 | [] | no_license | rpj911/LeetCode-2 | 2d2cdf1e81b973b90ce50972488fd2b738979a56 | 305d7db080162eafd86a8ae77ec604addd6faf92 | refs/heads/master | 2020-02-26T16:39:14.034967 | 2014-08-23T06:22:18 | 2014-08-23T06:22:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,012 | cpp | /**
* * Definition for singly-linked list with a random pointer.
* * struct RandomListNode {
* * int label;
* * RandomListNode *next, *random;
* * RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* * };
* */
class Solution {
RandomListNode* helper(unordered_map<RandomListNode*, RandomListNode*>& map, RandomListNode* node) {
if (node == NULL) {
return NULL;
}
if (map.find(node) != map.end()) {
return map[node];
} else {
RandomListNode* ret = new RandomListNode(node->label);
map[node] = ret;
ret->next = helper(map, node->next);
ret->random = helper(map, node->random);
return ret;
}
}
public:
RandomListNode *copyRandomList(RandomListNode *head) {
unordered_map<RandomListNode*, RandomListNode*> pmap;
RandomListNode* ret = helper(pmap, head);
return ret;
}
};
| [
"ruiz1@andrew.cmu.edu"
] | ruiz1@andrew.cmu.edu |
119be43e57710033071927d36ef7bc7187498a1f | a4b09665ae7e698652aff7f67a751c031271ee14 | /DEM/Low/src/System/System.h | 03d9f47956e11688f5394e5f3e8d288001b9cc29 | [
"MIT"
] | permissive | ugozapad/deusexmachina | 80ce769c83ed997fa6440402ac4f0123ce907310 | f5ca9f2eb850bc827bcf2c18a7303f3e569fea5c | refs/heads/master | 2020-05-20T04:38:43.234542 | 2019-01-17T11:27:24 | 2019-01-17T11:27:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,968 | h | #pragma once
#include <StdDEM.h>
// System functions and macros
class CString;
namespace Sys
{
enum EMsgType
{
MsgType_Log, // Silent log message
MsgType_Message, // Important message to the user, possibly in a form of message box
MsgType_DbgOut, // Message to debug output window
MsgType_Error // Error message
};
enum EMsgBoxButton
{
MBB_OK = 0x01,
MBB_Cancel = 0x02,
MBB_Abort = 0x04,
MBB_Retry = 0x08,
MBB_Ignore = 0x10,
MBB_Yes = 0x20,
MBB_No = 0x40
};
typedef void (*FLogHandler)(EMsgType Type, const char* pMessage);
// Assertions and program termination
void DebugBreak();
void Crash(const char* pFile, int Line, const char* pMessage);
bool TraceStack(char* pTrace, unsigned int MaxLength);
bool ReportAssertionFailure(const char* pExpression, const char* pMessage, const char* pFile, int Line, const char* pFunc = NULL);
void __cdecl Error(const char* pMsg, ...) __attribute__((format(printf, 1, 2)));
//!!!need non-terminating error!
// Logging
void __cdecl Log(const char* pMsg, ...) __attribute__((format(printf, 1, 2)));
void __cdecl DbgOut(const char* pMsg, ...) __attribute__((format(printf, 1, 2)));
void __cdecl Message(const char* pMsg, ...) __attribute__((format(printf, 1, 2)));
// System UI
EMsgBoxButton ShowMessageBox(EMsgType Type, const char* pHeaderText, const char* pMessage, unsigned int Buttons = MBB_OK);
// Threading
void Sleep(unsigned long MSec); //!!!???to Thread namespace/class?!
// Input
bool GetKeyName(U8 ScanCode, bool ExtendedKey, CString& OutName);
// Timing
double GetAppTime();
}
// See http://cnicholson.net/2009/02/stupid-c-tricks-adventures-in-assert/
#ifdef DEM_NO_ASSERT
#define n_verify(exp) do { (exp); } while(0)
#define n_assert(exp) do { (void)sizeof(exp); } while(0)
#define n_assert2(exp, msg) do { (void)sizeof(exp); } while(0)
#else
#define n_verify(exp) do { if (!(exp)) if (::Sys::ReportAssertionFailure(#exp, NULL, __FILE__, __LINE__, __FUNCTION__)) __debugbreak(); } while(0)
#define n_assert(exp) do { if (!(exp)) if (::Sys::ReportAssertionFailure(#exp, NULL, __FILE__, __LINE__, __FUNCTION__)) __debugbreak(); } while(0)
#define n_assert2(exp, msg) do { if (!(exp)) if (::Sys::ReportAssertionFailure(#exp, msg, __FILE__, __LINE__, __FUNCTION__)) __debugbreak(); } while(0)
#endif
#ifdef _DEBUG
#define n_verify_dbg(exp) n_verify(exp)
#define n_assert_dbg(exp) n_assert(exp)
#define n_assert2_dbg(exp, msg) n_assert2(exp, msg)
#define DBG_ONLY(call) call
#else
#define n_verify_dbg(exp) do { (exp); } while(0)
#define n_assert_dbg(exp) do { (void)sizeof(exp); } while(0)
#define n_assert2_dbg(exp, msg) do { (void)sizeof(exp); } while(0)
#define DBG_ONLY(call)
#endif
#define NOT_IMPLEMENTED do { ::Sys::Error(DEM_FUNCTION_NAME ## " > IMPLEMENT ME!!!\n"); } while(0)
#define NOT_IMPLEMENTED_MSG(msg) do { ::Sys::Error(DEM_FUNCTION_NAME ## " > IMPLEMENT ME!!!\n" ## msg ## "\n"); } while(0)
| [
"vladimir.orlov@playrix.com"
] | vladimir.orlov@playrix.com |
49d9d0beebc7d002d49da61b17263f03a59b15fd | 7fdf648cd1a0c0ae92cb6b66f129303a1f4c6171 | /src/game_object/plane.h | d567404a5c60c533d6e51e17e1cd2850a91058d4 | [] | no_license | buchuitoudegou/CarGame | 86f4882cde7b95e1e17e6d82a65a78c1947f6bac | 7060fb2a286b094308ec4f7ee36f437488cc3f01 | refs/heads/master | 2022-01-09T08:25:05.677442 | 2019-06-20T14:57:45 | 2019-06-20T14:57:45 | 186,408,720 | 1 | 1 | null | 2019-06-12T08:17:18 | 2019-05-13T11:44:20 | C++ | UTF-8 | C++ | false | false | 805 | h | #ifndef PLANE_H
#define PLANE_H
#include "./entity.h"
#include "../stb_image/stb_image.h"
#include "../renderers/RendererManager.h"
class Plane: public Entity {
public:
float planeVertices[48] = {
// positions // normals // texcoords
25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 0.0f,
-25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
-25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 25.0f,
25.0f, -0.5f, 25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 0.0f,
-25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 0.0f, 25.0f,
25.0f, -0.5f, -25.0f, 0.0f, 1.0f, 0.0f, 25.0f, 25.0f
};
unsigned int planeVAO, texture;
void initPlaneVAO();
Plane();
void draw(Shader* shader = nullptr) const;
glm::mat4 getModelMat() const;
void initTexture();
};
#endif | [
"756541536@qq.com"
] | 756541536@qq.com |
677825a6190eca4029befe656bb793e8085fae72 | e6841a65c30e2ff468cf1e779559cbc03567cdb1 | /Praktikum GGI 2/Lösungen/Strassenverkehr Florian Walbroel 2014/Strassenverkehr/Aufgabenblock_3/Fahrzeug.h | 56d92ca8d585ba9b45d1f2b805c0f9a91887d5f3 | [] | no_license | karimbouaziz95/Praktikum2_Versuch | 51ceff8b20e28f1cb5fe13d0397bf75a59a56e84 | 092993f74a9faabbf3918ad5b1393c8b7c06f90f | refs/heads/main | 2023-08-23T04:53:36.152724 | 2021-10-17T16:20:01 | 2021-10-17T16:20:01 | 418,179,393 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,223 | h | #pragma once
#include "AktivesVO.h"
#include <string>
#include <iostream>
using namespace std;
class Weg;
class FzgVerhalten;
class Fahrzeug : public AktivesVO
{
public:
Fahrzeug(void);
Fahrzeug(string sName);
Fahrzeug(string sName, double dMaxSpeed);
~Fahrzeug(void);
string GetName() const;
double GetAbschnittStrecke() const;
void vNeueStrecke(Weg* ptWay, FzgVerhalten* ptFzgVerhalten);
virtual void vAbfertigung();
virtual void vAusgabe() const;
virtual double GetTankinhalt() const {return 0.0;};
virtual double dGeschwindigkeit() const;
virtual double dTanken(double dMenge=0.0, bool status=false) { return 0.0;};
virtual void vZeichnen(Weg* pWay) const {};
virtual ostream& ostreamAusgabe(ostream& Stream);
virtual istream& istreamEingabe(istream& Stream);
virtual bool operator <(const Fahrzeug& fVergleich);
virtual bool operator >(const Fahrzeug& fVergleich);
virtual void operator =(const Fahrzeug& fVergleich);
protected:
void vInitialisierung();
double p_dMaxGeschwindigkeit;
double p_dGesamtStrecke;
double p_dGesamtZeit;
double p_dZeit;
double p_dAbschnittStrecke;
FzgVerhalten *p_ptVerhalten;
private:
Fahrzeug(const Fahrzeug&); //Copykonstruktor verbieten, da private.
}; | [
"kimou007@live.fr"
] | kimou007@live.fr |
eb46a0137a0663e268cf19a59bc9da86b320d956 | f4e152179242265bb57a0c5ee76044a5489327db | /Server/inc/AutoSummary.hpp | 1c3b4d050b2953956ca59b65a061f1a12096f85a | [] | no_license | zhouyinwpu/SearchEngine | c938778eb7b04b9146068ffa28f933b37a232e65 | cecdee42654434d8a0ff3920842e66c46c161c18 | refs/heads/master | 2020-04-04T22:18:16.373313 | 2015-10-16T09:46:02 | 2015-10-16T09:46:02 | 156,318,569 | 1 | 0 | null | 2018-11-06T03:10:32 | 2018-11-06T03:10:31 | null | UTF-8 | C++ | false | false | 2,903 | hpp | #ifndef _AUTOSUMMERY_HPP
#define _AUTOSUMMERY_HPP
#include"../src/Statistics/src/Application.hpp"
#include <string>
#include<set>
#include <utility>
#include<vector>
#include<iostream>
#include<functional>
using namespace std;
using namespace CppJieba;
class AutoSummary
{
public:
AutoSummary(Application &app,int maxSentenceNum=10)//初始化一个自动摘要对象
:maxSentenceNum_(maxSentenceNum),
app_(app)
{}
//自动提取摘要
string summarizer(string & originTxt,int KEYNUM=50)
{
vector<pair<string,double> > keywords;
app_.extract(originTxt,keywords,KEYNUM); //取文章的前50个关键词,按权重排序
vector<string> sentences; //装载句子的数组
getSentences(originTxt,sentences); //把文章拆分成句子
int sentencesNum = sentences.size(); //句子的数量
vector<string> summaryRet; //装包含关键字的句子
set<int> summarySet; //句子去重
set<int>::iterator it;
KEYNUM = keywords.size();
for(int i = 0;i<KEYNUM;i++)
{
for(int j = 0;j<sentencesNum;j++)
{
int pos = sentences[j].find(keywords[i].first,0);
if(pos!=string::npos)
{
it = summarySet.find(pos);
if(it==summarySet.end())
{
summaryRet.push_back(sentences[j]);//向数组添加句子
summarySet.insert(j);
break; //跳出循环,找下一个关键字
}
}
}
if(summaryRet.size()>maxSentenceNum_||summaryRet.size()>=sentencesNum)
break;
}
string summaryStr;
int i = 0;
int num = summaryRet.size();
while(i<num)
{
summaryStr = summaryStr + sentences[i]+"……";
i++;
}
return summaryStr;//后期改为使用std::move避免复制,提高效率
}
private:
//私有成员函数,在summarizer()中调用
void getSentences(const string &originTxt,vector<string> &sentenceVec)
{
int beg=0,end=0,pos=0,pos1=0;
int txtSize = originTxt.size();
while(beg<txtSize&&pos!=string::npos)
{
if((pos=originTxt.find("。",beg))!=string::npos)
{
if((pos1=originTxt.find("?",beg))!=string::npos)
{
pos=((pos<pos1)?pos:pos1);
if((pos1=originTxt.find("!",beg))!=string::npos)
{
pos=((pos<pos1)?pos:pos1);
}
}
else if((pos1=originTxt.find("!",beg))!=string::npos)
{
pos=((pos<pos1)?pos:pos1);
}
}
else if((pos=originTxt.find("?",beg))!=string::npos)
{
if((pos1=originTxt.find("!",beg))!=string::npos)
{
pos=((pos<pos1)?pos:pos1);
}
}
else if((pos1=originTxt.find("!",beg))!=string::npos)
{
pos = pos1;
}
else
{
break;
}
if(pos!=-1)
{
int len = pos-beg;
string sentence(originTxt.substr(beg,len));
sentenceVec.push_back(sentence);
beg = pos+3;
}
}
}
private:
Application & app_;
int maxSentenceNum_;
};
#endif
| [
"932738410@qq.com"
] | 932738410@qq.com |
856d084b3ae9c71e305c62d35dcb38241ad8040a | ad0e98d23975b3b1ae85efce55116738f6f9a009 | /include/union.hpp | 332de357d6f251142384e0de3930265f2007fd26 | [
"MIT"
] | permissive | jermp/s_indexes | eda3bf758eb38b3c9e0d43c50d00599db503a049 | c80ab970b8ea563feb884aeb6902a4e35f36477c | refs/heads/master | 2023-01-23T09:13:55.088302 | 2023-01-08T09:31:15 | 2023-01-08T09:31:15 | 182,795,912 | 16 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 8,804 | hpp | #pragma once
#include "constants.hpp"
#include "util.hpp"
#include "uncompress.hpp"
#include "decode.hpp"
namespace sliced {
#define DECODE(ptr) \
uint8_t id = *ptr; \
int c = *(ptr + 1) + 1; \
int type = type::dense; \
int bytes = 32; \
if (LIKELY(c < 31)) { \
bytes = c; \
type = type::sparse; \
} \
out += decode_block(data_##ptr, type, c, base + id * 256, out); \
data_##ptr += bytes; \
ptr += 2;
size_t ss_union_block(uint8_t const* l, uint8_t const* r, int card_l,
int card_r, uint32_t base, uint32_t* out) {
assert(card_l > 0 and
card_l <= int(constants::block_sparseness_threshold - 2));
assert(card_r > 0 and
card_r <= int(constants::block_sparseness_threshold - 2));
size_t size = 0;
uint8_t const* end_l = l + card_l;
uint8_t const* end_r = r + card_r;
while (true) {
if (*l < *r) {
out[size++] = *l + base;
++l;
if (l == end_l) break;
} else if (*r < *l) {
out[size++] = *r + base;
++r;
if (r == end_r) break;
} else {
out[size++] = *l + base;
++l;
++r;
if (l == end_l or r == end_r) break;
}
}
if (l != end_l) {
size += decode_sparse_block(l, end_l - l, base, out + size);
}
if (r != end_l) {
size += decode_sparse_block(r, end_r - r, base, out + size);
}
return size;
}
size_t ds_union_block(uint8_t const* l, uint8_t const* r, int cardinality,
uint32_t base, uint32_t* out) {
static uint64_t x[4];
memcpy(x, reinterpret_cast<uint64_t const*>(l), constants::block_size / 8);
uncompress_sparse_block(r, cardinality, x);
return or_bitmaps(l, reinterpret_cast<uint8_t const*>(x),
constants::block_size_in_64bit_words, base, out);
}
inline uint32_t decode_block(uint8_t const* data, int type, int cardinality,
uint32_t base, uint32_t* out) {
if (type == type::sparse) {
return decode_sparse_block(data, cardinality, base, out);
}
return decode_bitmap(reinterpret_cast<uint64_t const*>(data),
constants::block_size_in_64bit_words, base, out);
}
size_t ss_union_chunk(uint8_t const* l, uint8_t const* r, int blocks_l,
int blocks_r, uint32_t base, uint32_t* out) {
assert(blocks_l >= 1 and blocks_l <= 256);
assert(blocks_r >= 1 and blocks_r <= 256);
uint8_t const* data_l = l + blocks_l * 2;
uint8_t const* data_r = r + blocks_r * 2;
uint8_t const* end_l = data_l;
uint8_t const* end_r = data_r;
uint32_t* in = out;
while (true) {
if (*l < *r) {
DECODE(l)
if (l == end_l) break;
} else if (*l > *r) {
DECODE(r)
if (r == end_r) break;
} else {
uint8_t id = *l;
++l;
++r;
int cl = *l + 1;
int cr = *r + 1;
int type_l = type::dense;
int type_r = type::dense;
int bl = 32;
int br = 32;
if (LIKELY(cl < 31)) {
bl = cl;
type_l = type::sparse;
}
if (LIKELY(cr < 31)) {
br = cr;
type_r = type::sparse;
}
uint32_t b = base + id * 256;
uint32_t n = 0;
switch (block_pair(type_l, type_r)) {
case block_pair(type::sparse, type::sparse):
n = ss_union_block(data_l, data_r, cl, cr, b, out);
break;
case block_pair(type::sparse, type::dense):
n = ds_union_block(data_r, data_l, cl, b, out);
break;
case block_pair(type::dense, type::sparse):
n = ds_union_block(data_l, data_r, cr, b, out);
break;
case block_pair(type::dense, type::dense):
n = or_bitmaps(data_l, data_r,
constants::block_size_in_64bit_words, b,
out);
break;
default:
assert(false);
__builtin_unreachable();
}
out += n;
data_l += bl;
data_r += br;
++l;
++r;
if (l == end_l or r == end_r) { break; }
}
}
while (l != end_l) { DECODE(l) }
while (r != end_r) { DECODE(r) }
return size_t(out - in);
}
size_t ds_union_chunk(uint8_t const* l, uint8_t const* r, int blocks_r,
uint32_t base, uint32_t* out) {
static std::vector<uint64_t> x(1024);
std::fill(x.begin(), x.end(), 0);
uncompress_sparse_chunk(r, blocks_r, x.data());
return or_bitmaps(l, reinterpret_cast<uint8_t const*>(x.data()),
constants::chunk_size_in_64bit_words, base, out);
}
size_t pairwise_union(s_sequence const& l, s_sequence const& r, uint32_t* out) {
auto it_l = l.begin();
auto it_r = r.begin();
uint32_t* in = out;
while (true) {
uint16_t id_l = it_l.id();
uint16_t id_r = it_r.id();
if (id_l == id_r) {
uint32_t n = 0;
uint32_t base = id_l << 16;
int blocks_l = 0;
int blocks_r = 0;
uint16_t type_l = it_l.type();
uint16_t type_r = it_r.type();
switch (chunk_pair(type_l, type_r)) {
case chunk_pair(type::sparse, type::sparse):
blocks_l = it_l.blocks();
blocks_r = it_r.blocks();
if (blocks_l < blocks_r) {
n = ss_union_chunk(it_l.data, it_r.data, blocks_l,
blocks_r, base, out);
} else {
n = ss_union_chunk(it_r.data, it_l.data, blocks_r,
blocks_l, base, out);
}
break;
case chunk_pair(type::sparse, type::dense):
n = ds_union_chunk(it_r.data, it_l.data, it_l.blocks(),
base, out);
break;
case chunk_pair(type::sparse, type::full):
n = decode_full_chunk(base, out);
break;
case chunk_pair(type::dense, type::sparse):
n = ds_union_chunk(it_l.data, it_r.data, it_r.blocks(),
base, out);
break;
case chunk_pair(type::dense, type::dense):
n = or_bitmaps(it_l.data, it_r.data,
constants::chunk_size_in_64bit_words, base,
out);
break;
case chunk_pair(type::dense, type::full):
n = decode_full_chunk(base, out);
break;
case chunk_pair(type::full, type::sparse):
n = decode_full_chunk(base, out);
break;
case chunk_pair(type::full, type::dense):
n = decode_full_chunk(base, out);
break;
case chunk_pair(type::full, type::full):
n = decode_full_chunk(base, out);
break;
default:
assert(false);
__builtin_unreachable();
}
out += n;
it_l.next();
it_r.next();
if (!it_l.has_next() or !it_r.has_next()) break;
} else if (id_l < id_r) {
out += decode_chunk(it_l, out);
it_l.next();
if (!it_l.has_next()) break;
} else {
out += decode_chunk(it_r, out);
it_r.next();
if (!it_r.has_next()) break;
}
}
while (it_l.has_next()) {
out += decode_chunk(it_l, out);
it_l.next();
}
while (it_r.has_next()) {
out += decode_chunk(it_r, out);
it_r.next();
}
return size_t(out - in);
}
} // namespace sliced | [
"jeis90@gmail.com"
] | jeis90@gmail.com |
25bea95a965d8e75f8c8b183e39dec531c7923bf | dbe4c0f546c497c4b74772cd9cc5a94f3a81996b | /Code/AMP/reactphysics3d/collision/TriangleVertexArray.h | c6ce9e85f4fc4abd00f41510026cabd4434e9d91 | [] | no_license | lectorguard/AMP_Engine_Demo | 43c8a83c3c0b4f915240ea86cd6532f09683b6fe | 443ea45d1eb8768d87f5f806624b0d471de4840f | refs/heads/master | 2021-01-04T04:51:08.793701 | 2020-02-14T02:03:18 | 2020-02-14T02:03:18 | 240,393,852 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,139 | h | /********************************************************************************
* ReactPhysics3D physics library, http://www.reactphysics3d.com *
* Copyright (c) 2010-2019 Daniel Chappuis *
*********************************************************************************
* *
* This software is provided 'as-is', without any express or implied warranty. *
* In no event will the authors be held liable for any damages arising from the *
* use of this software. *
* *
* Permission is granted to anyone to use this software for any purpose, *
* including commercial applications, and to alter it and redistribute it *
* freely, subject to the following restrictions: *
* *
* 1. The origin of this software must not be misrepresented; you must not claim *
* that you wrote the original software. If you use this software in a *
* product, an acknowledgment in the product documentation would be *
* appreciated but is not required. *
* *
* 2. Altered source versions must be plainly marked as such, and must not be *
* misrepresented as being the original software. *
* *
* 3. This notice may not be removed or altered from any source distribution. *
* *
********************************************************************************/
#ifndef REACTPHYSICS3D_TRIANGLE_VERTEX_ARRAY_H
#define REACTPHYSICS3D_TRIANGLE_VERTEX_ARRAY_H
// Libraries
#include "../configuration.h"
namespace reactphysics3d {
// Declarations
struct Vector3;
// Class TriangleVertexArray
/**
* This class is used to describe the vertices and faces of a triangular mesh.
* A TriangleVertexArray represents a continuous array of vertices and indexes
* of a triangular mesh. When you create a TriangleVertexArray, no data is copied
* into the array. It only stores pointer to the data. The purpose is to allow
* the user to share vertices data between the physics engine and the rendering
* part. Therefore, make sure that the data pointed by a TriangleVertexArray
* remains valid during the TriangleVertexArray life.
*/
class TriangleVertexArray {
public:
/// Data type for the vertices in the array
enum class VertexDataType {VERTEX_FLOAT_TYPE, VERTEX_DOUBLE_TYPE};
/// Data type for the vertex normals in the array
enum class NormalDataType {NORMAL_FLOAT_TYPE, NORMAL_DOUBLE_TYPE};
/// Data type for the indices in the array
enum class IndexDataType {INDEX_INTEGER_TYPE, INDEX_SHORT_TYPE};
protected:
// -------------------- Attributes -------------------- //
/// Number of vertices in the array
uint mNbVertices;
/// Pointer to the first vertex value in the array
const uchar* mVerticesStart;
/// Stride (number of bytes) between the beginning of two vertices
/// values in the array
uint mVerticesStride;
/// Pointer to the first vertex normal value in the array
const uchar* mVerticesNormalsStart;
/// Stride (number of bytes) between the beginning of two vertex normals
/// values in the array
uint mVerticesNormalsStride;
/// Number of triangles in the array
uint mNbTriangles;
/// Pointer to the first vertex index of the array
const uchar* mIndicesStart;
/// Stride (number of bytes) between the beginning of the three indices of two triangles
uint mIndicesStride;
/// Data type of the vertices in the array
VertexDataType mVertexDataType;
/// Data type of the vertex normals in the array
NormalDataType mVertexNormaldDataType;
/// Data type of the indices in the array
IndexDataType mIndexDataType;
/// True if the vertices normals are provided by the user
bool mAreVerticesNormalsProvidedByUser;
// -------------------- Methods -------------------- //
/// Compute the vertices normals when they are not provided by the user
void computeVerticesNormals();
public:
// -------------------- Methods -------------------- //
/// Constructor without vertices normals
TriangleVertexArray(uint nbVertices, const void* verticesStart, uint verticesStride,
uint nbTriangles, const void* indexesStart, uint indexesStride,
VertexDataType vertexDataType, IndexDataType indexDataType);
/// Constructor with vertices normals
TriangleVertexArray(uint nbVertices, const void* verticesStart, uint verticesStride,
const void* verticesNormalsStart, uint uverticesNormalsStride,
uint nbTriangles, const void* indexesStart, uint indexesStride,
VertexDataType vertexDataType, NormalDataType normalDataType,
IndexDataType indexDataType);
/// Destructor
~TriangleVertexArray();
/// Deleted assignment operator
TriangleVertexArray& operator=(const TriangleVertexArray& triangleVertexArray) = delete;
/// Deleted copy-constructor
TriangleVertexArray(const TriangleVertexArray& triangleVertexArray) = delete;
/// Return the vertex data type
VertexDataType getVertexDataType() const;
/// Return the vertex normal data type
NormalDataType getVertexNormalDataType() const;
/// Return the index data type
IndexDataType getIndexDataType() const;
/// Return the number of vertices
uint getNbVertices() const;
/// Return the number of triangles
uint getNbTriangles() const;
/// Return the vertices stride (number of bytes)
uint getVerticesStride() const;
/// Return the vertex normals stride (number of bytes)
uint getVerticesNormalsStride() const;
/// Return the indices stride (number of bytes)
uint getIndicesStride() const;
/// Return the pointer to the start of the vertices array
const void* getVerticesStart() const;
/// Return the pointer to the start of the vertex normals array
const void* getVerticesNormalsStart() const;
/// Return the pointer to the start of the indices array
const void* getIndicesStart() const;
/// Return the vertices coordinates of a triangle
void getTriangleVertices(uint triangleIndex, Vector3* outTriangleVertices) const;
/// Return the three vertices normals of a triangle
void getTriangleVerticesNormals(uint triangleIndex, Vector3* outTriangleVerticesNormals) const;
/// Return the indices of the three vertices of a given triangle in the array
void getTriangleVerticesIndices(uint triangleIndex, uint* outVerticesIndices) const;
/// Return a vertex of the array
void getVertex(uint vertexIndex, Vector3* outVertex);
/// Return a vertex normal of the array
void getNormal(uint vertexIndex, Vector3* outNormal);
};
// Return the vertex data type
/**
* @return The data type of the vertices in the array
*/
inline TriangleVertexArray::VertexDataType TriangleVertexArray::getVertexDataType() const {
return mVertexDataType;
}
// Return the vertex normal data type
/**
* @return The data type of the normals in the array
*/
inline TriangleVertexArray::NormalDataType TriangleVertexArray::getVertexNormalDataType() const {
return mVertexNormaldDataType;
}
// Return the index data type
/**
* @return The data type of the face indices in the array
*/
inline TriangleVertexArray::IndexDataType TriangleVertexArray::getIndexDataType() const {
return mIndexDataType;
}
// Return the number of vertices
/**
* @return The number of vertices in the array
*/
inline uint TriangleVertexArray::getNbVertices() const {
return mNbVertices;
}
// Return the number of triangles
/**
* @return The number of triangles in the array
*/
inline uint TriangleVertexArray::getNbTriangles() const {
return mNbTriangles;
}
// Return the vertices stride (number of bytes)
/**
* @return The number of bytes separating two consecutive vertices in the array
*/
inline uint TriangleVertexArray::getVerticesStride() const {
return mVerticesStride;
}
// Return the vertex normals stride (number of bytes)
/**
* @return The number of bytes separating two consecutive normals in the array
*/
inline uint TriangleVertexArray::getVerticesNormalsStride() const {
return mVerticesNormalsStride;
}
// Return the indices stride (number of bytes)
/**
* @return The number of bytes separating two consecutive face indices in the array
*/
inline uint TriangleVertexArray::getIndicesStride() const {
return mIndicesStride;
}
// Return the pointer to the start of the vertices array
/**
* @return A pointer to the start of the vertices data in the array
*/
inline const void* TriangleVertexArray::getVerticesStart() const {
return mVerticesStart;
}
// Return the pointer to the start of the vertex normals array
/**
* @return A pointer to the start of the normals data in the array
*/
inline const void* TriangleVertexArray::getVerticesNormalsStart() const {
return mVerticesNormalsStart;
}
// Return the pointer to the start of the indices array
/**
* @return A pointer to the start of the face indices data in the array
*/
inline const void* TriangleVertexArray::getIndicesStart() const {
return mIndicesStart;
}
}
#endif
| [
"simon.keller@stud-mail.uni-wuerzburg.de"
] | simon.keller@stud-mail.uni-wuerzburg.de |
e07e47bfefeb8ddfcb9d4b1546adc23a1bbacafc | 83da09d757e3d0359da993a13951a8719c925b1c | /11150_Cola/t.cpp | 056da433839feef298634783e50bfb5d3f30cd1b | [] | no_license | marcobecerrap/UVa-Solutions | e52f185b3a0b8e31a8b5bd45833818753f2fc17c | 170a0165b9b1da245dfc58c2bebd3bdd85a8125d | refs/heads/master | 2021-06-30T21:26:04.736742 | 2020-11-25T16:09:24 | 2020-11-25T16:09:24 | 16,389,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 550 | cpp | // UVA-ID: #11150
// "Cola"
// (cl) by mabp, oct-2013.
#include <iostream>
using namespace std;
int GetTotalBottles( int NBottles );
int main( int argc, char *argv[] ){
int NBottles;
while( cin >> NBottles )
cout << GetTotalBottles( NBottles ) << endl;
return 0;
}
int GetTotalBottles( int NBottles ){
if( NBottles == 2 )
return 3;
else if( NBottles == 1 )
return 1;
else if( NBottles == 0 )
return 0;
else
return ( ( NBottles - ( NBottles % 3 ) ) + GetTotalBottles( ( NBottles / 3 ) + ( NBottles % 3 ) ) );
}
| [
"marcobecerrap@gmail.com"
] | marcobecerrap@gmail.com |
8743b43bba9ff9a73e09a006cd2ffcafd63d4076 | e1d4ee920bf1472f7a0805b28f918c529d5830b5 | /src/logic/Physics.cpp | 132bcfa8827f10fe72b4f3626f49a6fa6050178c | [] | no_license | almgergo/cpp_sandbox | 6be29c42517aff1b0f4487813e69c09533301337 | 51519cc07aef37513f2e83b40ac51c89cb45b864 | refs/heads/master | 2023-03-14T20:47:13.094953 | 2021-03-08T22:47:54 | 2021-03-08T22:47:54 | 341,943,808 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,141 | cpp | //
// Created by almge on 2/23/2021.
//
#include <iostream>
#include "Physics.h"
void Physics::InteractParticles(Particle &particle1, Particle &particle2) {
Eigen::Vector3d differenceVector = (particle2.position - particle1.position);
double distance = differenceVector.dot(differenceVector);
Eigen::Vector3d normal = differenceVector.normalized();
double force = distance > 0.02 ? G / distance : 0;
Eigen::Vector3d acceleration = normal * force;
particle1.velocity += acceleration * dt;
particle1.position += particle1.velocity * dt;
particle2.velocity -= acceleration * dt;
particle2.position += particle2.velocity * dt;
}
double Physics::calculatePotentialEnergy(const Particle &particle1, const Particle &particle2) {
Eigen::Vector3d differenceVector = (particle2.position - particle1.position);
double distance = differenceVector.dot(differenceVector);
return G * particle1.mass * particle2.mass / distance * 2;
}
double Physics::calculateKineticEnergy(const Particle &particle) {
double vv = particle.velocity.dot(particle.velocity);
return 0.5 * vv * particle.mass;
} | [
"galmasy@chappuishalder.com"
] | galmasy@chappuishalder.com |
2514ff52d176304db32a80e52bd378aa96b485c9 | 5f45d136b340c467cdf74d45494ff25fb271a7cd | /gameassetmanager.cpp | 781e6963e31445b6c8589738c82d74014a4c27da | [] | no_license | notsodistantworlds/spaceblitz | db72afe30167bb48770a139fc788704d09a42463 | 0921613229cad69d3625f5e92666550decfe2122 | refs/heads/master | 2021-10-19T00:20:48.104707 | 2019-02-15T21:12:45 | 2019-02-15T21:12:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,509 | cpp |
#include <assetimporter.h>
#include <gameconsole.h>
#include <math.h>
#include <debuglogger.h>
#include <gameassetmanager.h>
#include <vehicles.h>
#include <equipment.h>
#include <projectiles.h>
#include <effects.h>
GameAsset** GameAssetManager::assets;
int GameAssetManager::assetAmount;
void GameAssetManager::init(){
assetAmount = 5000;
assets = new GameAsset*[assetAmount];
for(int i =0; i<assetAmount; i++){
assets[i] = 0;
}
}
void GameAssetManager::loadAssets(std::string filename){
if(!AssetImporter::openFile(filename))return;
int readSize=0;
std::string read = AssetImporter::readData(readSize);
if(readSize>0){DebugLogger::outputLine("Expected the file to start with line feed character \\n"); return;}
while(AssetImporter::fileOpened()){
int index=0;
int step = 0;
readSize=0;
bool playerUsable = false;
int level = 0;
int otype = 0;
std::vector<std::string> data;
try{
DebugLogger::outputLine("Importing another asset");
index = AssetImporter::readInt(0);
step++;
DebugLogger::outputLine("Importing asset index "+ std::to_string(index));
otype = AssetImporter::readInt(0);
DebugLogger::outputLine("object type: "+ std::to_string(otype));
step++;
level = AssetImporter::readInt(0);
DebugLogger::outputLine("level = "+ std::to_string(level));
step++;
playerUsable = AssetImporter::readInt(0)>0;
DebugLogger::outputLine("playerUsable = "+ std::to_string(playerUsable));
step++;
read = AssetImporter::readData(readSize);
while(readSize>0){
data.push_back(read);
read = AssetImporter::readData(readSize);
}
step++;
}catch (std::exception& e){
DebugLogger::outputLine("Parse error on step "+std::to_string(step)+": "+ e.what());
}
if(assets[index]!=0){DebugLogger::outputLine("Asset "+std::to_string(index)+" already imported!");continue;}
assets[index] = new GameAsset(playerUsable, otype, level);
for(int i = 0; i<data.size(); i++){
assets[index]->loadData(data[i]);
DebugLogger::outputLine("data["+std::to_string(i)+"] = "+ assets[index]->getData(i));
}
}
}
std::vector<GameAsset*> GameAssetManager::getAssets(int objType, int levelMin, int levelMax, bool playerUsable){
std::vector<GameAsset*> r;
for(int i = 0; i<assetAmount; i++){
if(assets[i]!=0){
if(assets[i]->qualifies(playerUsable, objType, levelMin, levelMax))
r.push_back(assets[i]);
}
}
return r;
}
GameObject* GameAssetManager::spawn(int index){
if(assets[index]!=0)
return assets[index]->spawn(); else return 0;
}
GameAsset::GameAsset(bool playerUsable, int objType, int level){
this -> playerUsable = playerUsable;
this -> objType = objType;
this -> level = level;
}
void GameAsset::loadData(std::string s){
this->data.push_back(s);
}
std::string GameAsset::getData(int index){
if(index<data.size())
return data[index]; else return "";
}
GameObject* GameAsset::spawn(){
switch(objType){
case 0:
return VehicleSpawner::spawn(this);
case 1:
return EquipmentSpawner::spawnEquipment(this);
case 2:
return ProjectileSpawner::spawnProjectile(this);
case 10:
return EffectsSpawner::spawn(this);
default: DebugLogger::outputLine("Attempting to spawn asset - unknown object type"); return 0;
}
}
bool GameAsset::qualifies(bool playerUsable, int objType, int levelMin, int levelMax){
if(this->playerUsable == playerUsable)
if(this->objType==objType)
if(this->level<=levelMax&&this->level>=levelMin)
return true;
return false;
} | [
"strutinsky5386@gmail.com"
] | strutinsky5386@gmail.com |
23637ad7860099cc72350bbc91ab271f1c9defd6 | 3b7fabf51350d88d331dc2d18b82722899d7d1d1 | /Locales/English.cpp | 297ebfafdea66f42c0c8a56f7c2d4cdd81b03f99 | [] | no_license | Abin-Liu/AbinRelogger | 8a30f72765aa2b86cacd8eee695629a5db892ad2 | 672e2706c39b254df1fd9be3cdd03b0f6065c509 | refs/heads/master | 2020-03-19T16:03:14.177071 | 2018-06-09T06:47:28 | 2018-06-09T06:47:28 | 136,698,151 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,379 | cpp | #include "stdafx.h"
#include "..\Languages.h"
void CLanguage::Provider_English(CLangMap& aMap)
{
// Menu
aMap.SetAt(LANG_MENU_FILE, _T("File"));
aMap.SetAt(LANG_MENU_EXIT, _T("Exit"));
aMap.SetAt(LANG_MENU_TASK, _T("Task"));
aMap.SetAt(LANG_MENU_START, _T("Start"));
aMap.SetAt(LANG_MENU_STOP, _T("Stop"));
aMap.SetAt(LANG_MENU_STOP_DETACH, _T("Stop (Detach)"));
aMap.SetAt(LANG_MENU_PAUSE_RESUME, _T("Pause / Resume"));
aMap.SetAt(LANG_MENU_HIDE_GAME, _T("Hide game"));
aMap.SetAt(LANG_MENU_NEW, _T("New"));
aMap.SetAt(LANG_MENU_EDIT, _T("Edit"));
aMap.SetAt(LANG_MENU_CLONE, _T("Clone"));
aMap.SetAt(LANG_MENU_DELETE, _T("Delete"));
aMap.SetAt(LANG_MENU_OPTIONS, _T("Options"));
aMap.SetAt(LANG_MENU_LANGUAGES, _T("Language"));
aMap.SetAt(LANG_MENU_CHANGE_PASSWORD, _T("Password"));
aMap.SetAt(LANG_MENU_SETTINGS, _T("Settings..."));
aMap.SetAt(LANG_MENU_HELP, _T("Help"));
aMap.SetAt(LANG_MENU_ABOUT, _T("About"));
aMap.SetAt(LANG_MENU_TASK_LIST, _T("Task list"));
aMap.SetAt(LANG_MENU_HIDE_ALL, _T("Hide all"));
aMap.SetAt(LANG_MENU_SHOW_ALL, _T("Show all"));
aMap.SetAt(LANG_MENU_STOP_ALL, _T("Stop all"));
aMap.SetAt(LANG_MENU_OK, _T("OK"));
aMap.SetAt(LANG_MENU_CANCEL, _T("Cancel"));
// About window
aMap.SetAt(LANG_ABOUT_TITLE, _T("About ARelogger"));
aMap.SetAt(LANG_ABOUT_COPYRIGHT, _T("Copyright (C) 2016, Abin"));
// Main window
aMap.SetAt(LANG_MAIN_LOG, _T("Log"));
aMap.SetAt(LANG_MAIN_SUGGEST_CLEAN, _T("(Clean suggested)"));
aMap.SetAt(LANG_MAIN_LIST_COLUMN_NAME, _T("Name"));
aMap.SetAt(LANG_MAIN_LIST_COLUMN_AGE, _T("Uptime"));
aMap.SetAt(LANG_MAIN_LIST_COLUMN_PROFILE, _T("Profile Name"));
aMap.SetAt(LANG_MAIN_FRAME_BATCH_OPER, _T("Batch operations"));
aMap.SetAt(LANG_MAIN_FRAME_TASK_DATA, _T("Tasks"));
aMap.SetAt(LANG_MAIN_OPEN_LOG, _T("Open Log"));
aMap.SetAt(LANG_MAIN_CLEAN_LOG, _T("Clean Log"));
// Log
aMap.SetAt(LANG_LOG_APP_STARTED, _T("ARelogger launched"));
aMap.SetAt(LANG_LOG_APP_EXIT, _T("ARelogger exit"));
aMap.SetAt(LANG_LOG_PASSWORD_CREATED, _T("Password created"));
aMap.SetAt(LANG_LOG_LOGIN_SUCCESSFUL, _T("Login successful"));
aMap.SetAt(LANG_LOG_INVALID_PASSWORD, _T("Invalid password"));
aMap.SetAt(LANG_LOG_DATA_DELETED, _T("Data deleted"));
aMap.SetAt(LANG_LOG_DATA_NOT_FOUND, _T("No data found, run as new user"));
aMap.SetAt(LANG_LOG_DATA_LOADED, _T("%d tasks loaded"));
aMap.SetAt(LANG_LOG_DATA_SAVED, _T("%d tasks saved"));
aMap.SetAt(LANG_LOG_KILLED_BLIZZARD_ERROR, _T("Found and killed process [BlizzardError.exe]"));
aMap.SetAt(LANG_LOG_TASK_CREATED, _T("Task created"));
aMap.SetAt(LANG_LOG_TASK_MODIFIED, _T("Task updated"));
aMap.SetAt(LANG_LOG_TASK_DELETED, _T("Task deleted"));
aMap.SetAt(LANG_LOG_PASSWORD_CHANGED, _T("Password changed"));
aMap.SetAt(LANG_LOG_MONITOR_TRIPWIRE, _T("Monitor abnormal: TripWire event fired"));
aMap.SetAt(LANG_LOG_MONITOR_DIABLO_CLOSED, _T("Monitor abnormal: Diablo III closed"));
aMap.SetAt(LANG_LOG_MONITOR_DEMONBUDDY_CLOSED, _T("Monitor abnormal: Demonbuddy closed"));
aMap.SetAt(LANG_LOG_MONITOR_OUT_OF_GAME, _T("Monitor abnormal: Player out of game timed out"));
aMap.SetAt(LANG_LOG_MONITOR_DIABLO_DISCONNECTED, _T("Monitor abnormal: Game disconnected timed out"));
aMap.SetAt(LANG_LOG_MONITOR_DIABLO_UNRESPONSIVE, _T("Monitor abnormal: Diablo III unresponsive timed out"));
aMap.SetAt(LANG_LOG_MONITOR_DEMONBUDDY_UNRESPONSIVE, _T("Monitor abnormal: Demonbuddy unresponsive timed out"));
aMap.SetAt(LANG_LOG_MONITOR_DIABLO_MINIMIZED, _T("Monitor abnormal: Stopped Diablo III window minimize"));
aMap.SetAt(LANG_LOG_SET_HIDE_WINDOW_TRUE, _T("Hide game set to: TRUE"));
aMap.SetAt(LANG_LOG_SET_HIDE_WINDOW_FALSE, _T("Hide game set to: FALSE"));
aMap.SetAt(LANG_LOG_DIABLO_LOGIN_SCREEN, _T("Reached login screen"));
aMap.SetAt(LANG_LOG_DIABLO_LOGIN_SUCCESS, _T("Battle.net login successful"));
aMap.SetAt(LANG_LOG_DIABLO_LOGIN_FAILED, _T("Battle.net login failed! Task aborted, please re-config"));
aMap.SetAt(LANG_LOG_DIABLO_GAME_JOINED, _T("Player joined game"));
aMap.SetAt(LANG_LOG_DIABLO_GAME_LEFT, _T("Player left game"));
aMap.SetAt(LANG_LOG_DIABLO_GAME_DISCONNECTED, _T("Game disconnected from server"));
aMap.SetAt(LANG_LOG_LAUNCH_ERROR_RETRY, _T("Relaunch task in 5 seconds..."));
aMap.SetAt(LANG_LOG_LAUNCH_PREPARE, _T("Prepare to launch task"));
aMap.SetAt(LANG_LOG_LAUNCH_CLEANUP, _T("Wait for processes to cleanup"));
aMap.SetAt(LANG_LOG_LAUNCH_PREPARE_DIABLO, _T("Prepare to launch Diablo III"));
aMap.SetAt(LANG_LOG_LAUNCH_START_DIABLO, _T("Launching Diablo III"));
aMap.SetAt(LANG_LOG_LAUNCH_START_DIABLO_FAILED, _T("Diablo III launch failed!"));
aMap.SetAt(LANG_LOG_LAUNCH_DIABLO_REUSED, _T("Diablo III process taken over: PID=%d"));
aMap.SetAt(LANG_LOG_LAUNCH_DIABLO_SUCCESS, _T("Diablo III process launched: PID=%d"));
aMap.SetAt(LANG_LOG_LAUNCH_WAIT_DIABLO, _T("Waiting for Diablo III main window"));
aMap.SetAt(LANG_LOG_LAUNCH_WAIT_BNET_LOGIN, _T("Waiting for Battle.net authentication"));
aMap.SetAt(LANG_LOG_LAUNCH_BNET_LOGIN_TIMEOUT, _T("Battle.net authentication timed out"));
aMap.SetAt(LANG_LOG_LAUNCH_WAIT_JOIN_GAME, _T("Waiting for player to create game"));
aMap.SetAt(LANG_LOG_LAUNCH_JOIN_GAME_FAILED, _T("Game create failed!"));
aMap.SetAt(LANG_LOG_LAUNCH_PREPARE_DEMONBUDDY, _T("Prepare to launch Demonbuddy"));
aMap.SetAt(LANG_LOG_LAUNCH_START_DEMONBUDDY, _T("Launching Demonbuddy"));
aMap.SetAt(LANG_LOG_LAUNCH_START_DEMONBUDDY_FAILED, _T("Demonbuddy launch failed!"));
aMap.SetAt(LANG_LOG_LAUNCH_DEMONBUDDY_REUSED, _T("Demonbuddy process taken over: PID=%d"));
aMap.SetAt(LANG_LOG_LAUNCH_WAIT_DEMONBUDDY, _T("Waiting for Demonbuddy main window"));
aMap.SetAt(LANG_LOG_LAUNCH_DEMONBUDDY_SUCCESS, _T("Demonbuddy launched: PID=%d"));
aMap.SetAt(LANG_LOG_LAUNCH_CLOSE_DEMONBUDDY_ERROR, _T("Close Demonbuddy error window"));
aMap.SetAt(LANG_LOG_LAUNCH_CLOSE_DEMONBUDDY, _T("Close DemonBuddy"));
aMap.SetAt(LANG_LOG_LAUNCH_CHECK_DEMONBUDDY_CLOSE, _T("Waiting for DemonBuddy process to exit"));
aMap.SetAt(LANG_LOG_LAUNCH_DEMONBUDDY_CLOSED, _T("DemonBuddy process closed"));
aMap.SetAt(LANG_LOG_LAUNCH_WAIT_GAME_STABLIZE, _T("Waiting for the game stablizing before restarting DemonBuddy"));
aMap.SetAt(LANG_LOG_LAUNCH_SUCCESSFUL, _T("Task launched successfully, entering monitor stage"));
aMap.SetAt(LANG_LOG_LAUNCH_HIDE_PROCESSES, _T("Hiding monitored windows according to your settings"));
aMap.SetAt(LANG_LOG_STATE_LAUNCH, _T("Prepare to launch task"));
aMap.SetAt(LANG_LOG_STATE_MONITOR, _T("Start to monitor task"));
aMap.SetAt(LANG_LOG_STATE_START, _T("Task thread started"));
aMap.SetAt(LANG_LOG_STATE_STOP, _T("Task thread ended"));
aMap.SetAt(LANG_LOG_STATE_PAUSE, _T("Task paused"));
aMap.SetAt(LANG_LOG_STATE_RESUME, _T("Task resumed"));
// Message box
aMap.SetAt(LANG_MSG_INVALID_INPUT_TITLE, _T("Invalid Input"));
aMap.SetAt(LANG_MSG_CREATE_PASSWORD_TITLE, _T("Create Password"));
aMap.SetAt(LANG_MSG_CREATE_PASSWORD_TEXT, _T("You need to create a password before using ARelogger, it encrypts and protects your personal data such as Battle.net login info. You need to remember your password."));
aMap.SetAt(LANG_MSG_DELETE_TASK_TITLE, _T("Delete Task"));
aMap.SetAt(LANG_MSG_DELETE_TASK_TEXT, _T("About to delete task [%s] permanently, are you sure?"));
aMap.SetAt(LANG_MSG_CLEAN_LOG_TITLE, _T("Clean Log"));
aMap.SetAt(LANG_MSG_CLEAN_LOG_TEXT, _T("About to clean existing log contents, are you sure?"));
aMap.SetAt(LANG_MSG_STOP_ALL_TITLE, _T("Stop All"));
aMap.SetAt(LANG_MSG_STOP_ALL_TEXT, _T("%d tasks are running, do you want to stop them and kill all Diablo & Demonbuddy processes controlled by these tasks?"));
aMap.SetAt(LANG_MSG_EXIT_APP_TITLE, _T("Exit ARelogger"));
aMap.SetAt(LANG_MSG_TASK_RUNNING_TITLE, _T("Task Running"));
aMap.SetAt(LANG_MSG_TASK_RUNNING_TEXT, _T("Task [%s] is running, you need to stop it before operating."));
aMap.SetAt(LANG_MSG_TASK_CONFLICT_TITLE, _T("Task Conflicts"));
aMap.SetAt(LANG_MSG_TASK_CONFLICT_TEXT, _T("Task [%s] has the same Diablo game path [%s] with another running task [%s], Diablo3 does not allow multi-instances from same path."));
aMap.SetAt(LANG_MSG_INPUT_CANNOT_BE_EMPTY, _T("[%s] cannot be empty."));
aMap.SetAt(LANG_MSG_INPUT_INVALID_PATH, _T("[%s] is not a correct %s path."));
aMap.SetAt(LANG_MSG_DELETE_DATA_TITLE, _T("Clean Data"));
aMap.SetAt(LANG_MSG_DELERE_DATA_TEXT, _T("This will delete all existing data permanently, and you will be loging back as new user. Do you want to continue?"));
aMap.SetAt(LANG_MSG_PASSWORD_REPEAT_MISMATCH, _T("New password must be same as repeating password."));
aMap.SetAt(LANG_MSG_ORIGINAL_PASSWORD_INCORRECT, _T("Incorrect password."));
// Password window
aMap.SetAt(LANG_PASSWORD_TITLE, _T("Type Password"));
aMap.SetAt(LANG_PASSWORD_PASSWORD, _T("Password"));
aMap.SetAt(LANG_PASSWORD_OLD_PASSWORD, _T("Old password"));
aMap.SetAt(LANG_PASSWORD_INVALID_TITLE, _T("Invalid Password"));
aMap.SetAt(LANG_PASSWORD_INVALID_TEXT, _T("You may chose Retry to enter password again, or clean all data and relogin as new user."));
aMap.SetAt(LANG_PASSWORD_RETRY, _T("Retry"));
aMap.SetAt(LANG_PASSWORD_CLEAN_EXIT, _T("Clean && Exit"));
aMap.SetAt(LANG_PASSWORD_CREATE_TITLE, _T("Create Password"));
aMap.SetAt(LANG_PASSWORD_CREATE_NEW_PASSWORD, _T("New password"));
aMap.SetAt(LANG_PASSWORD_CREATE_REPEAT_PASSWORD, _T("Repeat password"));
// Task window
aMap.SetAt(LANG_TASK_TITLE, _T("Task Settings"));
aMap.SetAt(LANG_TASK_FRAME_TASK, _T("Task"));
aMap.SetAt(LANG_TASK_TASK_NAME, _T("Task name"));
aMap.SetAt(LANG_TASK_DIABLO_PATH, _T("Game folder"));
aMap.SetAt(LANG_TASK_ACCOUNT, _T("BNet account"));
aMap.SetAt(LANG_TASK_PASSWORD, _T("BNet password"));
aMap.SetAt(LANG_TASK_I_USE_BNET_AUTHENTICATOR, _T("I use Battle.net authenticator"));
aMap.SetAt(LANG_TASK_SERIAL, _T("Seraial code"));
aMap.SetAt(LANG_TASK_RESTORE_CODE, _T("Restore code"));
aMap.SetAt(LANG_TASK_DEMONBUDDY_PATH, _T("App folder"));
aMap.SetAt(LANG_TASK_AUTHORIZE_CODE, _T("Authorize code"));
aMap.SetAt(LANG_TASK_PROFILE_PATH, _T("Profile path"));
// Config window
aMap.SetAt(LANG_CONFIG_TITLE, _T("Options"));
aMap.SetAt(LANG_CONFIG_DBLCLK_TASK_LIST, _T("Dbl-click task list"));
aMap.SetAt(LANG_CONFIG_NO_OPERATION, _T("No operation"));
aMap.SetAt(LANG_CONFIG_OPEN_TASK_EDITING_WINDOW, _T("Open task editing window"));
aMap.SetAt(LANG_CONFIG_CYCLE_START_STOP, _T("Cycles: Start - Stop"));
aMap.SetAt(LANG_CONFIG_CYCLE_START_STOP_NO_KILL, _T("Cycles: Start - Stop (detach)"));
aMap.SetAt(LANG_CONFIG_CYCLE_START_PAUSE_RESUME, _T("Cycles: Start - Pause - Resume"));
aMap.SetAt(LANG_CONFIG_TASK_CONTROL, _T("Task control"));
aMap.SetAt(LANG_CONFIG_PREVENT_DIABLO_MINIMIZED, _T("Stop Diablo window minimize"));
aMap.SetAt(LANG_CONFIG_MONITOR_TRIPWIRE_EVENT, _T("Monitor TripWire event"));
aMap.SetAt(LANG_CONFIG_DOUBLE_LAUNCH_DEMONBUDDY, _T("Double launch Demonbuddy to avoid errors"));
aMap.SetAt(LANG_CONFIG_ATTACH_EXISTING_PROCESSES, _T("Takeover existing Diablo/Demonbuddy processes"));
aMap.SetAt(LANG_CONFIG_TIMEOUT, _T("Timeout"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_LAUNCH_DIABLO, _T("Launch Diablo3 game"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_BNET_LOGIN, _T("Battle.net login"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_CREATE_GAME, _T("Create game"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_OUT_OF_GAME, _T("Player left game"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_GAME_DISCONNECTED, _T("Game disconnects from server"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_DIABLO_UNRESPONSIVE, _T("Diablo unresponsive"));
aMap.SetAt(LANG_CONFIG_TIMEOUT_DEMONBUDDY_UNRESPONSIVE, _T("Demonbuddy unresponsive"));
aMap.SetAt(LANG_CONFIG_FORCE_RESTART_IF_TIMEOUT, _T("Force restart Diablo/Demonbuddy when timeout"));
aMap.SetAt(LANG_CONFIG_TOOLTIP_PREVENT_MIN, _T("Demonbuddy cannot work after Diablo window minimizes, check to prevent Diablo window from minimizing."));
aMap.SetAt(LANG_CONFIG_TOOLTIP_DB_2X_LOGIN, _T("Demonbuddy generates bulk load of errors if it gets started before the player joins a game, check to restart Demonbuddy again after game joined."));
aMap.SetAt(LANG_CONFIG_TOOLTIP_TAKEOVER_PROCESS, _T("Let the tasks take over existing Diablo/Demonbuddy processes instead of launching new ones, if available."));
aMap.SetAt(LANG_CONFIG_RESTORE_DEFAULTS, _T("Restore Defaults"));
aMap.SetAt(LANG_CONFIG_SECONDS, _T("sec"));
}
| [
"abinn32@163.com"
] | abinn32@163.com |
16276c89a7e39e6536119847e2bd79ebbf217354 | 24db27644d02d0bb4901acc9feea56387ca42987 | /C++ Examples/avc.cpp | be9f5bc8fc194443e89d8e80329cbee5f04e7bf9 | [] | no_license | RLCHHABRA/CPP | b97ba4415451d7e15e115cb2c4bd88f13d8e6e38 | fb91f3400a23c72394a7ec922dbcf9a6f3265fb4 | refs/heads/master | 2020-03-27T11:24:39.792117 | 2018-10-30T20:22:29 | 2018-10-30T20:22:29 | 146,485,074 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 549 | cpp | #include<iostream>
#include<conio.h>
#include<string>
#include<stdlib.h>
using namespace std;
class Reverse_string
{
private:
string str;
float l ;
char *p , *q ;
public:
void get_string()
{
cout<<"Enter a string \n";
getline(cin,str);
}
string reverse_s()
{
l = str.size();
for(int i=0;i<l/2;i++)
{
*p = str[i] ;
*q = str[l-1-i];
str[i] = *q;
str[l-1-i] = *p;
}
return str;
}
};
int main()
{
Reverse_string a;
a.get_string();
cout<<a.reverse_s();
return 0 ;
}
| [
"rlc42847@gmail.com"
] | rlc42847@gmail.com |
1e8ee5701b4f8e3936f3cac9c3e2846cb1181ec5 | f4916f97b2ff6a246317fa4e6bc4fa8fc5e81836 | /src/keygen.cpp | 5b00bf4551c501fa2596e6c25d72d015eefdf1a3 | [] | no_license | TedaLIEz/DES | 4b47458737ba304e4174e34c455eccada96dc8e9 | 3ebf3f580e5e45769ea84afe9977ebb9f8f0633b | refs/heads/master | 2021-03-27T16:31:06.649008 | 2017-06-06T09:02:33 | 2017-06-06T09:02:33 | 90,977,211 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,247 | cpp | //
// Created by aLIEzTed on 5/11/17.
//
#include "keygen.h"
#include "helper.h"
Key Keygen::pc1(uint64_t k) {
Key key;
for (int i = 0; i < 28; i++) {
int bit = getBit(k, pc1map[i] - 1);
key.c.set((size_t) (28 - i - 1), bit);
}
for (int i = 0; i < 28; i++) {
int bit = getBit(k, pc1map[i + 28] - 1);
key.d.set((size_t) (28 - i - 1), bit);
}
return key;
}
Key Keygen::leftShift(Key key, int index) {
Key rst;
rst.c = leftShift(key.c, index);
rst.d = leftShift(key.d, index);
return rst;
}
bitset<28> Keygen::leftShift(bitset<28> k, int index) {
bitset<28> mask(~((uint64_t) ((1 << (28 - index)) - 1)));
bitset<28> left = (k & mask) >> (28 - index);
bitset<28> right = k << index;
return left | right;
}
bitset<48> Keygen::pc2(Key key) {
bitset<48> rst(0);
bitset<56> k(key.c.to_ullong());
k = k << 28;
k |= bitset<56>(key.d.to_ulong());
for (int i = 0; i < 48; i++) {
int bit = k[56 - pc2map[i]];
rst.set((size_t) (48 - i - 1), bit);
}
return rst;
}
vector<bitset<48>> Keygen::getK(uint64_t key) {
Key k = pc1(key);
vector<bitset<48>> rst;
for (int i = 0; i < 16; i++) {
Key ki = leftShift(k, shifts[i]);
k = ki;
rst.push_back(pc2(ki));
}
return rst;
}
| [
"aliezted@gmail.com"
] | aliezted@gmail.com |
daeccd04024c43d094021e6532fcd1772dc87877 | 357b88f492f1666081c26ceaa5c33bcfdee193c8 | /c++_practice/template/v5.cpp | 4507e494f580c472696ab6a4cfc1ce1ac8abc103 | [] | no_license | ryankumar/vt_practice_docs | 19670943cc45e156926f9b59490a3859c50bfd71 | cdea1dfe31b3a9e652ba53655e8aa43bc63c0eae | refs/heads/master | 2020-05-29T14:51:39.080039 | 2019-09-18T11:46:51 | 2019-09-18T11:46:51 | 189,204,602 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 316 | cpp |
#include<iostream>
#include<stdlib.h>
using namespace std;
template<class T, class U>
class A {
T x;
U y;
static int count;
};
int main() {
A<char, char> a;
A<int, int> b;
cout << sizeof(a) << endl;
cout << sizeof(b) << endl;
return 0;
}
| [
"pranali.dhudum@gmail.com"
] | pranali.dhudum@gmail.com |
7fd4cbd084e39404caeea8d77914282937063601 | f2b194c605e067d38d1c7794723d03d8e7782fcd | /test/OpenMP/nvptx_unsupported_type_messages.cpp | 6e0fa3b1d5b441d8e34d415be876c683a30dc0c5 | [
"Apache-2.0",
"LLVM-exception",
"NCSA"
] | permissive | dragon-tc-tmp/clang | b1e105ce1adef094b65ba4a56753ef7a21eec40b | 582d213cda71b7dcf85c05e05df8ff10ded1ea9c | refs/heads/release_90 | 2021-01-10T23:21:29.160968 | 2019-03-07T22:47:10 | 2019-06-03T07:23:47 | 70,460,468 | 0 | 3 | Apache-2.0 | 2019-02-15T01:32:04 | 2016-10-10T06:57:37 | C++ | UTF-8 | C++ | false | false | 1,069 | cpp | // Test target codegen - host bc file has to be created first.
// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only
struct T {
char a;
__float128 f;
char c;
T() : a(12), f(15) {}
T &operator+(T &b) { f += b.a; return *this;} // expected-error {{'__float128' is not supported on this target}}
};
struct T1 {
char a;
__int128 f;
__int128 f1;
char c;
T1() : a(12), f(15) {}
T1 &operator/(T1 &b) { f /= b.a; return *this;}
};
#pragma omp declare target
T a = T();
T f = a;
void foo(T a = T()) {
a = a + f; // expected-note {{called by 'foo'}}
return;
}
T bar() {
return T();
}
void baz() {
T t = bar();
}
T1 a1 = T1();
T1 f1 = a1;
void foo1(T1 a = T1()) {
a = a / f1;
return;
}
T1 bar1() {
return T1();
}
void baz1() {
T1 t = bar1();
}
#pragma omp end declare target
| [
"a.bataev@hotmail.com"
] | a.bataev@hotmail.com |
2527eaa605b556d5f48620eabb5e25bde9aaf5ab | cc7661edca4d5fb2fc226bd6605a533f50a2fb63 | /UnityEngine/VisibleLightFlags.h | 60a17e3e3b4a499bee571822823cef941bca8a97 | [
"MIT"
] | permissive | g91/Rust-C-SDK | 698e5b573285d5793250099b59f5453c3c4599eb | d1cce1133191263cba5583c43a8d42d8d65c21b0 | refs/heads/master | 2020-03-27T05:49:01.747456 | 2017-08-23T09:07:35 | 2017-08-23T09:07:35 | 146,053,940 | 1 | 0 | null | 2018-08-25T01:13:44 | 2018-08-25T01:13:44 | null | UTF-8 | C++ | false | false | 229 | h | #pragma once
namespace UnityEngine
{
namespace Experimental
{
{
namespace Rendering
{
class VisibleLightFlags : public Enum // 0x0
{
public:
int value__; // 0x10 (size: 0x4, flags: 0x606, type: 0x8)
}; // size = 0x18
}
| [
"info@cvm-solutions.co.uk"
] | info@cvm-solutions.co.uk |
3bd751a9cd8ab56148e28dcf609d08845bc75a89 | 67a5b8dc30f50fb24f2cc07f25620bde13c80dc9 | /hw6/CPUL.h | 2249d028e1cf69e742883216614fcbfc840f5358 | [] | no_license | rmchakra/CPlusPlus-OOPS-DataStructures-Projects | 4c43113b8794d74f56feb6a958ade1fcf37f2e11 | d6e4f1af3c9b1f9ab5e7609fe38b8262749347a0 | refs/heads/master | 2020-04-27T20:50:55.458709 | 2016-12-07T06:57:00 | 2016-12-07T06:57:00 | 174,673,140 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 207 | h | #ifndef CPUL_H_
#define CPUL_H_
#include "AI_Base.h"
class CPUL: public AI_Base
{
public:
Move getMove (const Board & board, const Player & player, std::map<char, int> initialTileCount);
};
#endif | [
"Rmchakra@usc.edu"
] | Rmchakra@usc.edu |
25f90760ca0c96387bfa47b7687a7a03faf257ad | e2fff7987880180ce1398480dc050e1e77eacafd | /reference/timestamp.cpp | 4115032bc3b72a16d1055017d36be589b39a772f | [
"MIT"
] | permissive | Lephar/Triangle | cde17aed42b3c4acc0f521f5ea0856382b699752 | 7e37ae216dd4e210686a707156134c58b1a60653 | refs/heads/master | 2023-03-01T13:55:44.731031 | 2020-10-25T21:18:49 | 2020-10-25T21:18:49 | 188,873,134 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,138 | cpp | #include <chrono>
#include <sstream>
#include <iostream>
#include <iomanip>
std::chrono::time_point<std::chrono::system_clock> epoch;
std::string time()
{
auto now = std::chrono::system_clock::now() - epoch;
auto sec = std::chrono::duration_cast<std::chrono::seconds>(now).count();
auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(now).count() - sec * 1000;
auto usec = std::chrono::duration_cast<std::chrono::microseconds>(now).count() - msec * 1000 - sec * 1000000;
std::ostringstream stream;
stream << std::setfill('0') << std::setw(3) << sec << ':' << std::setw(3) << msec << ':' << std::setw(3) << usec;
return stream.str();
}
VKAPI_ATTR VkBool32 VKAPI_CALL messageCallback(VkDebugUtilsMessageSeverityFlagBitsEXT severity, VkDebugUtilsMessageTypeFlagsEXT type,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
{
auto error = severity == VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT;
std::cout << time() << (error ? " F: " : " S: ") << pCallbackData->pMessage << std::endl;
return error ? VK_TRUE : VK_FALSE;
}
void initBase()
{
epoch = std::chrono::system_clock::now();
} | [
"aliemre.sirius@gmail.com"
] | aliemre.sirius@gmail.com |
0753552309e5a739f78c376fd9a9628fb7604694 | 7e9f6ef27323546e150402e05f96148a0f72482a | /3_チーム制作作品1/ソースファイル/source/担当コード/UI.cpp | 06a994488e55ba61ce5c2d9e58ee98f43bbac782 | [] | no_license | KamitaniTakafumi/MyWrok | 88a67c408ce5c5c412097f8b95141e0c2120b858 | 5ea639e6686b399d3baa8329ad112c551928939f | refs/heads/master | 2023-01-31T08:54:09.654979 | 2020-12-14T02:50:25 | 2020-12-14T02:50:25 | 302,220,596 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 32,704 | cpp | // 使いたい機能や命令にあわせて include を追加する
#include <Windows.h>
#include "amgame.h"
#include "AmHelper.h"
#include "game.h"
#include "camera.h"
#include "alice.h"
#include "UI.h"
#include "HitJudgment.h"
#include "alice.h"
#include "preparation.h"
#include "recipe.h"
#include "global.h"
#include "Item.h"
// ゲーム情報
int cgItemText;
int cgItemColumn;
int cgFrame;
int cgHealth;
int cgLife[6];
int cgSystem;
int cgEquipment[1 * 10];
int cgEquipment2[1 * 10];
int cgMulti;
int cgMulti2;
int eqtbl[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int eqtbl2[] = { 0, 1 };
int healthAlpha = 255;
int cgDescription;
int ButtonB;
int ButtonA;
int ButtonY;
int ButtonX;
int ButtonRB;
int ButtonLB;
int cgSystemButton;
// UI情報
struct FRAME frm[FRAME_MAX];
struct HEART hrt[HP_MAX];
struct EQUIPMENT eq;
struct DESCRIPTION de;
// 画像読み込み
void LoadCgUi() {
cgItemText = LoadTexture("res/window_text_item.png");
cgItemColumn = LoadTexture("res/window_equipment.png");
cgFrame = LoadTexture("res/frame.png");
cgSystem = LoadTexture("res/window_system.png");
LoadBlkTexture("res/number.png", 27, 60, 10, 1, 1 * 10, cgEquipment);
cgMulti = LoadTexture("res/multi_symbol.png");
LoadBlkTexture("res/number_2.png", 10, 20, 10, 1, 1 * 10, cgEquipment2);
cgMulti2 = LoadTexture("res/multi_symbol_2.png");
cgDescription = LoadTexture("res/description.png");
ButtonB = LoadTexture("res/B.png");
ButtonA = LoadTexture("res/A.png");
ButtonY = LoadTexture("res/Y.png");
ButtonX = LoadTexture("res/X.png");
ButtonRB = LoadTexture("res/RB.png");
ButtonLB = LoadTexture("res/LB.png");
cgPageSelect_right = LoadTexture("res/page_icon_right.png");
cgPageSelect_left = LoadTexture("res/page_icon_left.png");
cgSystemButton = LoadTexture("res/window_system_button.png");
}
// 体力バーの画像読み込み、初期化
void LoadCgHealth() {
int i;
cgHealth = LoadTexture("res/hp.png");
for (i = 0; i < 6; i++) {
cgLife[i] = LoadTexture("res/heart.png");
}
// ハートの位置
i = 0;
hrt[i].use = 1;
hrt[i].x = 140;
hrt[i].y = 70;
i = 1;
hrt[i].use = 1;
hrt[i].x = 177;
hrt[i].y = 70;
i = 2;
hrt[i].use = 1;
hrt[i].x = 214;
hrt[i].y = 70;
i = 3;
hrt[i].use = 1;
hrt[i].x = 251;
hrt[i].y = 70;
i = 4;
hrt[i].use = 1;
hrt[i].x = 288;
hrt[i].y = 70;
i = 5;
hrt[i].use = 1;
hrt[i].x = 325;
hrt[i].y = 70;
}
// アイテムフレーム情報初期化
void InitItemColumn() {
int i;
i = 0;
frm[i].cg = cgItemText;
frm[i].x = 1150;
frm[i].y = 590;
i = 1;
frm[i].cg = cgItemColumn;
frm[i].x = 790;
frm[i].y = 630;
i = 2;
frm[i].cg = cgFrame;
frm[i].x = 790;
frm[i].y = 630;
frm[i].move = 0;
}
// 個数カウントの初期化
void InitEquipment() {
eq.x = 0;
eq.y = 0;
}
// アイテム説明欄の初期化
void InitDescription() {
de.x = 700;
de.y = 560;
}
//アイテム欄の枠の移動
void FrameControll() {
if ((selectTrg == STATE_NONE) & (check == STATE_NONE) || (pick == STATE_ONE)) {
if (gTrg & KEYIN_D) {
PlayMemBack(seCursor);
frm[2].x += 80;
}
if (gTrg & KEYIN_S) {
PlayMemBack(seCursor);
frm[2].x -= 80;
}
if (frm[2].x < 790) {
if (frm[2].move == 0) {
if ((useit[12].use == 1) || (useit[13].use == 1) || (useit[14].use == 1) || (useit[15].use == 1) || (useit[16].use == 1)) {
frm[2].move = 2;
}
else if ((useit[6].use == 1) || (useit[7].use == 1) || (useit[8].use == 1) || (useit[9].use == 1) || (useit[10].use == 1) || (useit[11].use == 1)) {
frm[2].move = 1;
}
else {
frm[2].move = 0;
}
}
else if (frm[2].move == 1) {
if ((useit[0].use == 1) || (useit[1].use == 1) || (useit[2].use == 1) || (useit[3].use == 1) || (useit[4].use == 1) || (useit[5].use == 1)) {
frm[2].move = 0;
}
else if ((useit[12].use == 1) || (useit[13].use == 1) || (useit[14].use == 1) || (useit[15].use == 1) || (useit[16].use == 1)) {
frm[2].move = 2;
}
else {
frm[2].move = 1;
}
}
else if (frm[2].move == 2) {
if ((useit[6].use == 1) || (useit[7].use == 1) || (useit[8].use == 1) || (useit[9].use == 1) || (useit[10].use == 1) || (useit[11].use == 1)) {
frm[2].move = 1;
}
else if ((useit[0].use == 1) || (useit[1].use == 1) || (useit[2].use == 1) || (useit[3].use == 1) || (useit[4].use == 1) || (useit[5].use == 1)) {
frm[2].move = 0;
}
else {
frm[2].move = 2;
}
}
frm[2].x = 1190;
}
if (frm[2].x > 1190) {
if (frm[2].move == 0) {
if ((useit[6].use == 1) || (useit[7].use == 1) || (useit[8].use == 1) || (useit[9].use == 1) || (useit[10].use == 1) || (useit[11].use == 1)) {
frm[2].move = 1;
}
else if ((useit[12].use == 1) || (useit[13].use == 1) || (useit[14].use == 1) || (useit[15].use == 1) || (useit[16].use == 1)) {
frm[2].move = 2;
}
else {
frm[2].move = 0;
}
}
else if (frm[2].move == 1) {
if ((useit[12].use == 1) || (useit[13].use == 1) || (useit[14].use == 1) || (useit[15].use == 1) || (useit[16].use == 1)) {
frm[2].move = 2;
}
else if ((useit[0].use == 1) || (useit[1].use == 1) || (useit[2].use == 1) || (useit[3].use == 1) || (useit[4].use == 1) || (useit[5].use == 1)) {
frm[2].move = 0;
}
else {
frm[2].move = 1;
}
}
else if (frm[2].move == 2) {
if ((useit[0].use == 1) || (useit[1].use == 1) || (useit[2].use == 1) || (useit[3].use == 1) || (useit[4].use == 1) || (useit[5].use == 1)) {
frm[2].move = 0;
}
else if ((useit[6].use == 1) || (useit[7].use == 1) || (useit[8].use == 1) || (useit[9].use == 1) || (useit[10].use == 1) || (useit[11].use == 1)) {
frm[2].move = 1;
}
else {
frm[2].move = 2;
}
}
frm[2].x = 790;
}
}
}
//アイテム欄描画
void DrawItemColumn() {
int i;
if (pick == STATE_ONE) {
DrawTBox(0, 0, DISP_W, DISP_H, GetColor(0, 0, 0));
}
i = 0;
SetDrawMode(AMDRAW_ALPHABLEND, healthAlpha);
DrawMemTh(frm[i].x, frm[i].y, frm[i].cg);
DrawMemTh(frm[i].x - 30, frm[i].y - 60, cgSystemButton);
DrawMemTh(frm[i].x - 20, frm[i].y - 55, ButtonX);
DrawString(frm[i].x + 15, frm[i].y - 45, "所持アイテム", GetColor(0, 0, 0));
SetDrawMode(AMDRAW_NOBLEND, 0);
i = 1;
SetDrawMode(AMDRAW_ALPHABLEND, healthAlpha);
DrawMemTh(frm[i].x, frm[i].y, frm[i].cg);
DrawMemTh(frm[i].x, frm[i].y - 35, cgSystemButton);
DrawMemTh(frm[i].x + 10, frm[i].y - 25, cgPageSelect_left);
DrawMemTh(frm[i].x + 40, frm[i].y - 30, ButtonLB);
DrawMemTh(frm[i].x + 80, frm[i].y - 30, ButtonRB);
DrawMemTh(frm[i].x + 115, frm[i].y - 25, cgPageSelect_right);
SetDrawMode(AMDRAW_NOBLEND, 0);
i = 2;
if (pick != STATE_ONE) {
SetDrawMode(AMDRAW_ALPHABLEND, healthAlpha);
DrawMemTh(frm[i].x, frm[i].y, frm[i].cg);
SetDrawMode(AMDRAW_NOBLEND, 0);
}
else {
if ((gFrameCount % 60) < 50) {
SetDrawMode(AMDRAW_ALPHABLEND, healthAlpha);
DrawMemTh(frm[i].x, frm[i].y, frm[i].cg);
SetDrawMode(AMDRAW_NOBLEND, 0);
}
}
}
// 体力バー描画
void DrawAliceHealth() {
int i;
SetDrawMode(AMDRAW_ALPHABLEND, healthAlpha);
DrawMemTh(0, 0, cgHealth);
for (i = 0; i < HP_MAX; i++) {
if (hrt[i].use == 1) {
DrawMemTh(hrt[i].x, hrt[i].y, cgLife[i]);
}
if ((IsHitBox(
al.x + al.hit_x, al.y + al.hit_y, al.hit_w, al.hit_h,
0, 0, 500, 300)
) ||
IsHitBox(
al.x + al.hit_x - cv.view_y, al.y + al.hit_y - cv.view_y, al.hit_w, al.hit_h,
800, 640, DISP_W, DISP_H)) {
healthAlpha = 60;
}
else {
healthAlpha = 255;
}
// HP増減によるハートの描画数の変化
// ここのコードは変わる可能性が高い
if (al.hitpoint <= 0) {
hrt[0].use = 0;
hrt[1].use = 0;
hrt[2].use = 0;
hrt[3].use = 0;
hrt[4].use = 0;
hrt[5].use = 0;
}
if (al.hitpoint == 1) {
hrt[0].use = 1;
hrt[1].use = 0;
hrt[2].use = 0;
hrt[3].use = 0;
hrt[4].use = 0;
hrt[5].use = 0;
}
if (al.hitpoint == 2) {
hrt[0].use = 1;
hrt[1].use = 1;
hrt[2].use = 0;
hrt[3].use = 0;
hrt[4].use = 0;
hrt[5].use = 0;
}
if (al.hitpoint == 3) {
hrt[0].use = 1;
hrt[1].use = 1;
hrt[2].use = 1;
hrt[3].use = 0;
hrt[4].use = 0;
hrt[5].use = 0;
}
if (al.hitpoint == 4) {
hrt[0].use = 1;
hrt[1].use = 1;
hrt[2].use = 1;
hrt[3].use = 1;
hrt[4].use = 0;
hrt[5].use = 0;
}
if (al.hitpoint == 5) {
hrt[0].use = 1;
hrt[1].use = 1;
hrt[2].use = 1;
hrt[3].use = 1;
hrt[4].use = 1;
hrt[5].use = 0;
}
if (al.hitpoint == 6) {
hrt[0].use = 1;
hrt[1].use = 1;
hrt[2].use = 1;
hrt[3].use = 1;
hrt[4].use = 1;
hrt[5].use = 1;
}
}
SetDrawMode(AMDRAW_NOBLEND, 0);
}
// 個数カウント描画
void DrawEquipment(int x, int y, int itemNumber) {
if ((selectTrg == STATE_ONE) || (check == STATE_ONE)) {
if (pick == STATE_NONE) {
DrawMemTh(x, y, cgMulti);
DrawMemTh(x + 30, y, cgEquipment[(itemNumber / 10) % 3]);
DrawMemTh(x + 60, y, cgEquipment[(itemNumber / 1) % 10]);
}
}
}
void DrawItemEquipment(int x, int y, int itemNumber) {
DrawMemTh(x + 30, y + 40, cgMulti2);
DrawMemTh(x + 40, y + 40, cgEquipment2[(itemNumber / 10) % 2]);
DrawMemTh(x + 50, y + 40, cgEquipment2[(itemNumber / 1) % 10]);
}
void DrawDescription() {
int i;
switch (stateStage) {
case STATE_EP1STAGE:
if (sel.page == 1) {
i = 0;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "トゲ爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "無属性の爆弾、全モンスターに2ダメージ与える", GetColor(0, 0, 0));
}
}
i = 4;
if (re[i].y - 240 == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート1個分回復する", GetColor(0, 0, 0));
}
}
i = 6;
if (re[i].y + 160 == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "投げナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "全モンスターに1ダメージを与える", GetColor(0, 0, 0));
}
}
break;
}
case STATE_EP1STAGE_2:
if (sel.page == 1) {
i = 0;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "トゲ爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "無属性の爆弾、全モンスターに2ダメージ与える", GetColor(0, 0, 0));
}
}
i = 1;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 2;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 3;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷電爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 4;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート1個分回復する", GetColor(0, 0, 0));
}
}
i = 5;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ハイポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート3個分回復する", GetColor(0, 0, 0));
}
}
}
if (sel.page == 2) {
i = 6;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "投げナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "全モンスターに1ダメージを与える", GetColor(0, 0, 0));
}
}
}
break;
case STATE_EP1STAGE_3:
if (sel.page == 1) {
i = 0;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "トゲ爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "無属性の爆弾、全モンスターに2ダメージ与える", GetColor(0, 0, 0));
}
}
i = 1;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 2;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 3;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷電爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 4;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート1個分回復する", GetColor(0, 0, 0));
}
}
i = 5;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ハイポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート3個分回復する", GetColor(0, 0, 0));
}
}
}
if (sel.page == 2) {
i = 6;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "投げナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "全モンスターに1ダメージを与える", GetColor(0, 0, 0));
}
}
i = 7;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性のナイフ、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 8;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性のナイフ、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 9;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "電撃ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性のナイフ、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
}
break;
case STATE_EP2STAGE1_1:
case STATE_EP2STAGE1_2:
if (sel.page == 1) {
i = 0;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "トゲ爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "無属性の爆弾、全モンスターに2ダメージ与える", GetColor(0, 0, 0));
}
}
i = 1;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 2;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 3;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷電爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 4;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート1個分回復する", GetColor(0, 0, 0));
}
}
i = 5;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ハイポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート3個分回復する", GetColor(0, 0, 0));
}
}
}
if (sel.page == 2) {
i = 6;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "投げナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "全モンスターに1ダメージを与える", GetColor(0, 0, 0));
}
}
i = 7;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性のナイフ、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 8;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性のナイフ、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 9;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "電撃ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性のナイフ、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 10;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "焼却爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 11;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷却爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
}
if (sel.page == 3) {
i = 12;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷撃爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 13;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "フルポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力を完全回復する", GetColor(0, 0, 0));
}
}
}
break;
case STATE_EP2STAGE1_3:
case STATE_EP2STAGE2_1:
case STATE_EP2STAGE2_2:
if (sel.page == 1) {
i = 0;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "トゲ爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "無属性の爆弾、全モンスターに2ダメージ与える", GetColor(0, 0, 0));
}
}
i = 1;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 2;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 3;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷電爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 4;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート1個分回復する", GetColor(0, 0, 0));
}
}
i = 5;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "ハイポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力ゲージをハート3個分回復する", GetColor(0, 0, 0));
}
}
}
if (sel.page == 2) {
i = 6;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "投げナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "全モンスターに1ダメージを与える", GetColor(0, 0, 0));
}
}
i = 7;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "火炎ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性のナイフ、火属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 8;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷凍ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性のナイフ、氷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 9;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "電撃ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性のナイフ、雷属性が弱点の敵に3ダメージを与える", GetColor(0, 0, 0));
}
}
i = 10;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "焼却爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性の爆弾、火属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 11;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷却爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性の爆弾、氷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
}
if (sel.page == 3) {
i = 12;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷撃爆弾", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性の爆弾、雷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 13;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "フルポーション", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "体力を完全回復する", GetColor(0, 0, 0));
}
}
i = 14;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "焼却ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "火属性のナイフ、火属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 15;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "冷却ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "氷属性のナイフ、氷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
i = 16;
if (re[i].y == sel.y - 10) {
if (re[i].use == 0) {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 50, de.y + 40, "???", GetColor(0, 0, 0));
}
else {
DrawMemTh(de.x, de.y, cgDescription);
DrawString(de.x + 20, de.y + 20, "雷撃ナイフ", GetColor(0, 0, 0));
DrawString(de.x + 20, de.y + 40, "雷属性のナイフ、雷属性が弱点の敵に6ダメージを与える", GetColor(0, 0, 0));
}
}
}
break;
}
} | [
"119pg1004@tokyo.amg.ac.jp"
] | 119pg1004@tokyo.amg.ac.jp |
f0443075fa8193e789a2c1800cbe4536bf3a7d44 | 130697b2f60a42edc7b53077d7df77ed3fa41fa9 | /src-plugins/v3dView/medAbstractVtkViewInteractor.h | ad072cbccd5b83823878526cacef67d8819386d3 | [
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | XiaomingJiang/medInria-public | a60963d56eb16aa194ed304fddfc616588b65ed7 | fe574dec26cecce9fe8b0a933a51754b11c7ac89 | refs/heads/master | 2021-01-18T19:40:06.218823 | 2014-02-26T11:02:31 | 2014-02-26T11:02:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,161 | h | /*=========================================================================
medInria
Copyright (c) INRIA 2013. All rights reserved.
See LICENSE.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
=========================================================================*/
#pragma once
#include "v3dViewPluginExport.h"
#include <v3dView.h>
#include <medVtkView.h>
#include <medAbstractViewInteractor.h>
class V3DVIEWPLUGIN_EXPORT medAbstractVtkViewInteractor: public medAbstractViewInteractor
{
Q_OBJECT
public:
medAbstractVtkViewInteractor(){}
virtual ~medAbstractVtkViewInteractor(){}
virtual QStringList handled() const
{
return QStringList () << v3dView::s_identifier() << medVtkView::s_identifier();
}
public slots:
virtual void setOpacity(dtkAbstractData * data, double opacity) = 0;
virtual double opacity(dtkAbstractData * data) const = 0;
virtual void setVisible(dtkAbstractData * data, bool visible) = 0;
virtual bool isVisible(dtkAbstractData * data) const = 0;
};
| [
"guillaume.pasquier@inria.fr"
] | guillaume.pasquier@inria.fr |
1c133c33974a0381d775a4e656c005bf0ed3a8e7 | 51095169037b63e9c4f26df6e176451a2b292dce | /src/ast/generate_ast.cpp | 2b228f31b3a5c6ede7d33e990a096b4ed990bf3a | [
"BSL-1.0"
] | permissive | hkaiser/phylanx | d5bc4f4e6cc0ef7f6f86002a4c1ffcc6e56b7b1e | 32c5ba3d50b51b3ba25b3e0f4d8fc3081fee6dba | refs/heads/master | 2022-10-19T21:16:40.570233 | 2017-10-22T15:51:35 | 2017-10-22T15:51:35 | 108,064,754 | 0 | 0 | null | 2017-10-24T02:06:16 | 2017-10-24T02:06:15 | null | UTF-8 | C++ | false | false | 1,457 | cpp | // Copyright (c) 2017 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <phylanx/config.hpp>
#include <phylanx/ast/generate_ast.hpp>
#include <phylanx/ast/node.hpp>
#include <phylanx/ast/parser/expression.hpp>
#include <phylanx/ast/parser/skipper.hpp>
#include <hpx/throw_exception.hpp>
#include <boost/spirit/include/qi.hpp>
#include <sstream>
#include <string>
namespace phylanx { namespace ast
{
ast::expression generate_ast(std::string const& input)
{
using iterator = std::string::const_iterator;
iterator first = input.begin();
iterator last = input.end();
std::stringstream strm;
ast::parser::error_handler<iterator> error_handler(first, last, strm);
ast::parser::expression<iterator> expr(error_handler);
ast::parser::skipper<iterator> skipper;
ast::expression ast;
if (!boost::spirit::qi::phrase_parse(first, last, expr, skipper, ast))
{
HPX_THROW_EXCEPTION(hpx::bad_parameter,
"phylanx::ast::generate_ast", strm.str());
}
if (first != last)
{
error_handler("Error! ", "Incomplete parse:", first);
HPX_THROW_EXCEPTION(hpx::bad_parameter,
"phylanx::ast::generate_ast", strm.str());
}
return ast;
}
}}
| [
"hartmut.kaiser@gmail.com"
] | hartmut.kaiser@gmail.com |
43bbf580fd4071bb04e1ce4f9263db4383650335 | b056d85ac482084525d6f9748fc063a954bc0b85 | /TicTacToe/textureHandler.cpp | f6a999f348d31e27e4cbd7e89cc6369d8ce24ca0 | [
"Zlib",
"FTL"
] | permissive | lelon32/SDL2_TicTacToe | 664f884071d2cb437e2594fe0fbc28537fba49cd | 4cae927ad33548dd8be1654ba80ea18585b71283 | refs/heads/master | 2020-04-06T17:35:25.769621 | 2019-02-07T02:38:06 | 2019-02-07T02:38:06 | 157,666,086 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,077 | cpp | /*********************************************************************
** Program name: Tic Tac Toe
** Author: Long Le
** Date: 7/20/2017
** Description: The TextureHandler class generates textures used to
* render onto the screen from PNG images or text using SDL_image and
* SDL_ttf respectively.
*********************************************************************/
#include "textureHandler.hpp"
/*********************************************************************
** Description: Constructor.
*********************************************************************/
TextureHandler::TextureHandler() : XandO( "image/xo.png" )
{
fontPath = "font/theone.ttf";
X_Render = { 0, 0, 0, 0 };
O_Render = { 0, 0, 0, 0 };
DrawColor = { 0, 0, 0, 0xFF };
font = NULL;
XTurn = NULL;
OTurn = NULL;
XWin = NULL;
OWin = NULL;
OP = NULL;
XP = NULL;
playAgain = NULL;
XPoint = 0;
OPoint = 0;
//Used to render points.
XpointSS.str(string());
XpointSS << XPoint;
OpointSS.str(string());
OpointSS << OPoint;
}
/*********************************************************************
** Description: Destructor.
*********************************************************************/
TextureHandler::~TextureHandler()
{
//empty.
}
/*********************************************************************
** Description: This function loads the related media and calls
* loadTexture() to optimize the images.
*
* Return: bool - indicates whether the operation was successful.
*********************************************************************/
bool TextureHandler::loadMedia( SDL_Renderer* renderer )
{
bool success = true;
XandO.texture = loadTexture( XandO.path, renderer );
if( XandO.texture == NULL)
{
printf( "Failed to load images!\n" );
success = false;
}
font = TTF_OpenFont( fontPath.c_str(), 28 );
if( font == NULL )
{
printf( "Failed to load lazy font! SDL_ttf Error: %s\n", TTF_GetError() );
success = false;
}
else
{
SDL_Color XColor = { 0x55, 0xa3, 0, 0xFF };
SDL_Color OColor = { 0x9d, 0, 0, 0xFF };
XTurn = loadRenderedText( "Player X Turn", XColor, renderer );
OTurn = loadRenderedText( "Player O Turn", OColor, renderer );
XWin = loadRenderedText( "X WON", XColor, renderer );
OWin = loadRenderedText( "O WON", OColor, renderer );
Draw = loadRenderedText( "DRAW", DrawColor, renderer );
XPoints = loadRenderedText( "X Points: ", XColor, renderer );
OPoints = loadRenderedText( "O Points: ", OColor, renderer );
XP = loadRenderedText( XpointSS.str(), DrawColor, renderer );
OP = loadRenderedText( OpointSS.str(), DrawColor, renderer );
playAgain = loadRenderedText( "Play Again?", DrawColor, renderer );
if( XTurn == NULL || OTurn == NULL || XWin == NULL || OWin == NULL )
{
printf( "Failed to render text texture!\n" );
success = false;
}
}
//Clip the X and O sprites from the PNG image.
if( success )
{
X_Render = { 0, 1181 / 2, 591, 1181 / 2 };
O_Render = { 0, 0, 591, 1181 / 2 };
}
return success;
}
/*********************************************************************
** Description: This function creates textures from PNG images.
*
* Parameters:
* 1. string - the path to the picture.
* 2. SDL_Renderer* - the screen renderer.
*
* Return: SDL_Texture* - The optimized texture from an image.
*********************************************************************/
SDL_Texture* TextureHandler::loadTexture( const string &path, SDL_Renderer* renderer )
{
SDL_Texture* newTexture = NULL;
SDL_Surface* loadedSurface = IMG_Load( path.c_str() ); //Load the image onto a surface.
if( loadedSurface == NULL )
{
printf( "Unable to load image! SDL_image Error: %s\n", IMG_GetError() );
}
else
{
//Set transparent color to Cyan.
SDL_SetColorKey( loadedSurface, SDL_TRUE, SDL_MapRGB( loadedSurface->format, 0, 0xFF, 0xFF ) );
//Create texture from the loaded surface pixels.
newTexture = SDL_CreateTextureFromSurface( renderer, loadedSurface );
if( newTexture == NULL )
{
printf( "Unable to create texture from %s! SDL Error: %s\n", path.c_str(), SDL_GetError() );
}
SDL_FreeSurface( loadedSurface ); //Frees the previously loaded surface.
}
return newTexture;
}
/*********************************************************************
** Description: This function creates textures from ttf files.
*
* Parameters:
* 1. string - the path to the font file.
* 2. SDL_Color - the color of the text.
* 3. SDL_Renderer* - the main renderer.
*
* Return: SDL_Texture* - The optimized texture from the font file.
*********************************************************************/
SDL_Texture* TextureHandler::loadRenderedText( const string &text, SDL_Color textColor, SDL_Renderer* renderer )
{
SDL_Texture* newText = NULL;
SDL_Surface* textSurface = TTF_RenderText_Solid( font, text.c_str(), textColor );
if( textSurface == NULL )
{
printf( "Unable to render text surface! SDL_ttf Error: %s\n", TTF_GetError() );
}
else
{
newText = SDL_CreateTextureFromSurface( renderer, textSurface );
if( newText == NULL )
{
printf( "Unable to create texture from %s! SDL Error: %s\n", text.c_str(), SDL_GetError() );
}
SDL_FreeSurface( textSurface ); //Frees the previously loaded surface.
}
return newText;
}
/*********************************************************************
** Description: This function increments the X points and replaces the
* texture with the updated points.
*
* Parameters: SDL_Renderer* - the main renderer.
*********************************************************************/
void TextureHandler::incrementX( SDL_Renderer* renderer )
{
XPoint++;
XpointSS.str(string());
XpointSS << XPoint;
SDL_DestroyTexture( XP );
XP = loadRenderedText( XpointSS.str(), DrawColor, renderer );
}
/*********************************************************************
** Description: This function increments the O points and replaces the
* texture with the updated points.
*
* Parameters: SDL_Renderer* - the main renderer.
*********************************************************************/
void TextureHandler::incrementO( SDL_Renderer* renderer )
{
OPoint++;
OpointSS.str(string());
OpointSS << OPoint;
SDL_DestroyTexture( OP );
OP = loadRenderedText( OpointSS.str(), DrawColor, renderer );
}
/*********************************************************************
** Description: This function frees all memory from textures, fonts,
* images and shuts down SDL processes.
*********************************************************************/
void TextureHandler::cleanUp()
{
XandO.destroyTexture();
if( font != NULL )
{
TTF_CloseFont( font );
font = NULL;
}
if( XTurn != NULL)
{
SDL_DestroyTexture( XTurn );
XTurn = NULL;
}
if( OTurn != NULL)
{
SDL_DestroyTexture( OTurn);
OTurn = NULL;
}
if( XWin != NULL)
{
SDL_DestroyTexture( XWin );
XWin = NULL;
}
if( OWin != NULL)
{
SDL_DestroyTexture( OWin );
OWin = NULL;
}
if( Draw != NULL)
{
SDL_DestroyTexture( Draw );
Draw = NULL;
}
if( XPoints != NULL)
{
SDL_DestroyTexture( XPoints );
XPoints = NULL;
}
if( OPoints != NULL)
{
SDL_DestroyTexture( OPoints );
OPoints = NULL;
}
if( XP != NULL)
{
SDL_DestroyTexture( XP );
XP = NULL;
}
if( OP != NULL)
{
SDL_DestroyTexture( OP );
OP = NULL;
}
if( playAgain != NULL)
{
SDL_DestroyTexture( playAgain );
playAgain = NULL;
}
IMG_Quit();
TTF_Quit();
}
| [
"lelon@oregonstate.edu"
] | lelon@oregonstate.edu |
3df156068d61c987efbd584b8a90efef2f72750e | 9234bfe39e405340af0ed7b1b7a3d429ed3da68a | /esp-test/esp-test-webserver/esp-test-webserver.ino | 34161e04ed1ded4db95fa04e46a7a25da3c8280f | [] | no_license | jglatts/Esp8266-Jawns | 2cd3c0d8339da86634b0ffd34ca67b295a229c09 | 3c8bd744d4b08ae23ef974675615dd21df9a27dc | refs/heads/master | 2020-04-16T12:07:26.556734 | 2019-12-31T17:18:12 | 2019-12-31T17:18:12 | 165,565,444 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,462 | ino | #include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
// Replace with your network credentials
const char* ssid = "";
const char* password = "";
ESP8266WebServer server(80); //instantiate server at port 80 (http port)
String page = "";
int LEDPin = LED_BUILTIN;
void setup(void){
//the HTML of the web page
page = "<h1>Whasup Mane!!!!</h1><p><a href=\"LEDOn\"><button>ON</button></a> <a href=\"LEDOff\"><button>OFF</button></a></p>";
//make the LED pin output and initially turned off
pinMode(LEDPin, OUTPUT);
digitalWrite(LEDPin, LOW);
delay(1000);
Serial.begin(115200);
WiFi.begin(ssid, password); //begin WiFi connection
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", [](){
server.send(200, "text/html", page);
});
server.on("/LEDOn", [](){
server.send(200, "text/html", page);
digitalWrite(LEDPin, LOW);
delay(1000);
});
server.on("/LEDOff", [](){
server.send(200, "text/html", page);
digitalWrite(LEDPin, HIGH);
delay(1000);
});
server.begin();
Serial.println("Web server started!");
}
void loop(void){
// eskedit
server.handleClient();
}
| [
"noreply@github.com"
] | jglatts.noreply@github.com |
450bba4ac17ed20ad356de3faf68f2d2fda6c8d5 | 022f9783fc8c07df7ccc1599abddb4f8ded54d46 | /fishery-nets/solution1/syn/systemc/ccl_5.cpp | 9b544921d2139dea91e7bec5b4c42a7e22ccc159 | [] | no_license | teozax/Reconfigurable-Logic-Based-System-for-Image-Processing-of-Fishery-Nets | 5e08816c69ad30f169ce3fd88b1802ff9ccd15e8 | f806cd7d25f4c9102b2b023e553a7acf02da3256 | refs/heads/main | 2023-06-09T20:35:41.424720 | 2021-06-29T11:38:02 | 2021-06-29T11:38:02 | 373,593,128 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 21,705 | cpp | #include "ccl.h"
#include "AESL_pkg.h"
using namespace std;
namespace ap_rtl {
void ccl::thread_sext_ln559_5_fu_18800_p1() {
sext_ln559_5_fu_18800_p1 = esl_sext<64,16>(select_ln850_8_fu_18792_p3.read());
}
void ccl::thread_sext_ln559_6_fu_19334_p1() {
sext_ln559_6_fu_19334_p1 = esl_sext<64,16>(select_ln850_9_fu_19326_p3.read());
}
void ccl::thread_sext_ln559_7_fu_19505_p1() {
sext_ln559_7_fu_19505_p1 = esl_sext<64,16>(select_ln851_10_fu_19497_p3.read());
}
void ccl::thread_sext_ln559_8_fu_20053_p1() {
sext_ln559_8_fu_20053_p1 = esl_sext<64,16>(ap_phi_mux_p_01106_0_i_phi_fu_17597_p4.read());
}
void ccl::thread_sext_ln559_fu_18419_p1() {
sext_ln559_fu_18419_p1 = esl_sext<64,16>(select_ln850_fu_18411_p3.read());
}
void ccl::thread_sext_ln835_1_fu_18992_p1() {
sext_ln835_1_fu_18992_p1 = esl_sext<64,18>(add_ln835_2_fu_18986_p2.read());
}
void ccl::thread_sext_ln835_2_fu_19462_p1() {
sext_ln835_2_fu_19462_p1 = esl_sext<64,18>(add_ln835_3_fu_19456_p2.read());
}
void ccl::thread_sext_ln835_fu_18553_p1() {
sext_ln835_fu_18553_p1 = esl_sext<18,10>(add_ln68_fu_18547_p2.read());
}
void ccl::thread_shl_ln728_1_fu_18736_p3() {
shl_ln728_1_fu_18736_p3 = esl_concat<16,16>(above_fu_18685_p3.read(), ap_const_lv16_0);
}
void ccl::thread_shl_ln_fu_18727_p3() {
shl_ln_fu_18727_p3 = esl_concat<16,16>(previous_fu_18651_p3.read(), ap_const_lv16_0);
}
void ccl::thread_sizes_V_address0() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp4_stage0.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp4_iter0.read()) &&
esl_seteq<1,1,1>(ap_block_pp4_stage0.read(), ap_const_boolean_0))) {
sizes_V_address0 = (sc_lv<17>) (sext_ln835_2_fu_19462_p1.read());
} else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state45.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln218_reg_39682.read()))) {
sizes_V_address0 = grp_windows_fu_17784_sizes_V_address0.read();
} else {
sizes_V_address0 = (sc_lv<17>) ("XXXXXXXXXXXXXXXXX");
}
}
void ccl::thread_sizes_V_ce0() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp4_stage0.read()) &&
esl_seteq<1,1,1>(ap_block_pp4_stage0_11001.read(), ap_const_boolean_0) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp4_iter0.read()))) {
sizes_V_ce0 = ap_const_logic_1;
} else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state45.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln218_reg_39682.read()))) {
sizes_V_ce0 = grp_windows_fu_17784_sizes_V_ce0.read();
} else {
sizes_V_ce0 = ap_const_logic_0;
}
}
void ccl::thread_sizes_V_d0() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp4_stage0.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp4_iter0.read()) &&
esl_seteq<1,1,1>(ap_block_pp4_stage0.read(), ap_const_boolean_0))) {
sizes_V_d0 = ap_const_lv17_0;
} else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state45.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln218_reg_39682.read()))) {
sizes_V_d0 = grp_windows_fu_17784_sizes_V_d0.read();
} else {
sizes_V_d0 = (sc_lv<17>) ("XXXXXXXXXXXXXXXXX");
}
}
void ccl::thread_sizes_V_we0() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp4_stage0.read()) &&
esl_seteq<1,1,1>(ap_block_pp4_stage0_11001.read(), ap_const_boolean_0) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp4_iter0.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_0, icmp_ln132_fu_19386_p2.read()))) {
sizes_V_we0 = ap_const_logic_1;
} else if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state45.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln218_reg_39682.read()))) {
sizes_V_we0 = grp_windows_fu_17784_sizes_V_we0.read();
} else {
sizes_V_we0 = ap_const_logic_0;
}
}
void ccl::thread_smax31_cast_fu_23086_p1() {
smax31_cast_fu_23086_p1 = esl_zext<18,17>(smax31_fu_23078_p3.read());
}
void ccl::thread_smax31_fu_23078_p3() {
smax31_fu_23078_p3 = (!empty_489_fu_23072_p2.read()[0].is_01())? sc_lv<17>(): ((empty_489_fu_23072_p2.read()[0].to_bool())? add_ln160_fu_23062_p2.read(): empty_488_fu_23058_p1.read());
}
void ccl::thread_smax33_cast_fu_23463_p1() {
smax33_cast_fu_23463_p1 = esl_zext<18,17>(smax33_fu_23458_p3.read());
}
void ccl::thread_smax33_fu_23458_p3() {
smax33_fu_23458_p3 = (!empty_492_reg_32256.read()[0].is_01())? sc_lv<17>(): ((empty_492_reg_32256.read()[0].to_bool())? add_ln172_reg_32251.read(): empty_491_reg_32246.read());
}
void ccl::thread_storemerge_fu_18894_p3() {
storemerge_fu_18894_p3 = esl_concat<16,16>(ap_phi_reg_pp1_iter1_storemerge_in_in_reg_17474.read(), ap_const_lv16_0);
}
void ccl::thread_sub_ln147_1_fu_22763_p2() {
sub_ln147_1_fu_22763_p2 = (!ap_const_lv8_0.is_01() || !trunc_ln147_1_fu_22753_p4.read().is_01())? sc_lv<8>(): (sc_biguint<8>(ap_const_lv8_0) - sc_biguint<8>(trunc_ln147_1_fu_22753_p4.read()));
}
void ccl::thread_sub_ln147_fu_22747_p2() {
sub_ln147_fu_22747_p2 = (!ap_const_lv32_0.is_01() || !grp_local_sort_fu_18064_ap_return_0.read().is_01())? sc_lv<32>(): (sc_biguint<32>(ap_const_lv32_0) - sc_biguint<32>(grp_local_sort_fu_18064_ap_return_0.read()));
}
void ccl::thread_sub_ln1499_fu_19273_p2() {
sub_ln1499_fu_19273_p2 = (!tmp_5_fu_19253_p3.read().is_01() || !zext_ln1499_fu_19269_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(tmp_5_fu_19253_p3.read()) - sc_biguint<18>(zext_ln1499_fu_19269_p1.read()));
}
void ccl::thread_sub_ln160_1_fu_23090_p2() {
sub_ln160_1_fu_23090_p2 = (!smax31_cast_fu_23086_p1.read().is_01() || !p_cast19981_fu_23068_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(smax31_cast_fu_23086_p1.read()) - sc_biguint<18>(p_cast19981_fu_23068_p1.read()));
}
void ccl::thread_sub_ln160_fu_23024_p2() {
sub_ln160_fu_23024_p2 = (!ap_const_lv16_FFCD.is_01() || !row_0_i_reg_17603.read().is_01())? sc_lv<16>(): (sc_bigint<16>(ap_const_lv16_FFCD) - sc_biguint<16>(row_0_i_reg_17603.read()));
}
void ccl::thread_sub_ln162_fu_27281_p2() {
sub_ln162_fu_27281_p2 = (!tmp_9_fu_27261_p3.read().is_01() || !zext_ln162_fu_27277_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(tmp_9_fu_27261_p3.read()) - sc_biguint<18>(zext_ln162_fu_27277_p1.read()));
}
void ccl::thread_sub_ln172_1_fu_23467_p2() {
sub_ln172_1_fu_23467_p2 = (!smax33_cast_fu_23463_p1.read().is_01() || !p_cast19978_fu_23455_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(smax33_cast_fu_23463_p1.read()) - sc_biguint<18>(p_cast19978_fu_23455_p1.read()));
}
void ccl::thread_sub_ln172_fu_23398_p2() {
sub_ln172_fu_23398_p2 = (!ap_const_lv16_FFCD.is_01() || !col_0_i_reg_17650.read().is_01())? sc_lv<16>(): (sc_bigint<16>(ap_const_lv16_FFCD) - sc_biguint<16>(col_0_i_reg_17650.read()));
}
void ccl::thread_sub_ln835_1_fu_18537_p2() {
sub_ln835_1_fu_18537_p2 = (!p_shl_cast_fu_18517_p3.read().is_01() || !zext_ln835_1_fu_18533_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(p_shl_cast_fu_18517_p3.read()) - sc_biguint<18>(zext_ln835_1_fu_18533_p1.read()));
}
void ccl::thread_sub_ln835_2_fu_18976_p2() {
sub_ln835_2_fu_18976_p2 = (!tmp_1_fu_18956_p3.read().is_01() || !zext_ln835_5_fu_18972_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(tmp_1_fu_18956_p3.read()) - sc_biguint<18>(zext_ln835_5_fu_18972_p1.read()));
}
void ccl::thread_sub_ln835_3_fu_19446_p2() {
sub_ln835_3_fu_19446_p2 = (!tmp_7_fu_19426_p3.read().is_01() || !zext_ln835_7_fu_19442_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(tmp_7_fu_19426_p3.read()) - sc_biguint<18>(zext_ln835_7_fu_19442_p1.read()));
}
void ccl::thread_sub_ln835_fu_18504_p2() {
sub_ln835_fu_18504_p2 = (!p_shl1_cast_fu_18484_p3.read().is_01() || !zext_ln835_fu_18500_p1.read().is_01())? sc_lv<18>(): (sc_biguint<18>(p_shl1_cast_fu_18484_p3.read()) - sc_biguint<18>(zext_ln835_fu_18500_p1.read()));
}
void ccl::thread_tmp_10_fu_27269_p3() {
tmp_10_fu_27269_p3 = esl_concat<9,5>(select_ln227_1_fu_27253_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_1_fu_18956_p3() {
tmp_1_fu_18956_p3 = esl_concat<9,9>(select_ln105_1_fu_18948_p3.read(), ap_const_lv9_0);
}
void ccl::thread_tmp_2_fu_18964_p3() {
tmp_2_fu_18964_p3 = esl_concat<9,5>(select_ln105_1_fu_18948_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_38_fu_18492_p3() {
tmp_38_fu_18492_p3 = esl_concat<9,5>(select_ln97_1_fu_18476_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_39_fu_18525_p3() {
tmp_39_fu_18525_p3 = esl_concat<9,5>(select_ln97_2_fu_18510_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_49_fu_22739_p3() {
tmp_49_fu_22739_p3 = grp_local_sort_fu_18064_ap_return_0.read().range(31, 31);
}
void ccl::thread_tmp_5_fu_19253_p3() {
tmp_5_fu_19253_p3 = esl_concat<9,9>(select_ln119_1_fu_19245_p3.read(), ap_const_lv9_0);
}
void ccl::thread_tmp_6_fu_19261_p3() {
tmp_6_fu_19261_p3 = esl_concat<9,5>(select_ln119_1_fu_19245_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_7_fu_19426_p3() {
tmp_7_fu_19426_p3 = esl_concat<9,9>(select_ln136_1_fu_19418_p3.read(), ap_const_lv9_0);
}
void ccl::thread_tmp_8_fu_19434_p3() {
tmp_8_fu_19434_p3 = esl_concat<9,5>(select_ln136_1_fu_19418_p3.read(), ap_const_lv5_0);
}
void ccl::thread_tmp_9_fu_27261_p3() {
tmp_9_fu_27261_p3 = esl_concat<9,9>(select_ln227_1_fu_27253_p3.read(), ap_const_lv9_0);
}
void ccl::thread_tmp_s_fu_24148_p271() {
tmp_s_fu_24148_p271 = (!ap_const_lv9_1FF.is_01() || !trunc_ln211_fu_23559_p1.read().is_01())? sc_lv<9>(): (sc_bigint<9>(ap_const_lv9_1FF) + sc_biguint<9>(trunc_ln211_fu_23559_p1.read()));
}
void ccl::thread_trunc_ln147_1_fu_22753_p4() {
trunc_ln147_1_fu_22753_p4 = sub_ln147_fu_22747_p2.read().range(8, 1);
}
void ccl::thread_trunc_ln147_2_fu_22769_p4() {
trunc_ln147_2_fu_22769_p4 = grp_local_sort_fu_18064_ap_return_0.read().range(8, 1);
}
void ccl::thread_trunc_ln1499_fu_23047_p1() {
trunc_ln1499_fu_23047_p1 = select_ln153_fu_23036_p3.read().range(9-1, 0);
}
void ccl::thread_trunc_ln203_fu_20117_p1() {
trunc_ln203_fu_20117_p1 = N_6_fu_3042.read().range(8-1, 0);
}
void ccl::thread_trunc_ln211_fu_23559_p1() {
trunc_ln211_fu_23559_p1 = select_ln211_3_fu_23551_p3.read().range(9-1, 0);
}
void ccl::thread_trunc_ln731_fu_20101_p1() {
trunc_ln731_fu_20101_p1 = select_ln850_10_fu_20084_p3.read().range(15-1, 0);
}
void ccl::thread_trunc_ln851_10_fu_19487_p1() {
trunc_ln851_10_fu_19487_p1 = results_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_11_fu_20066_p1() {
trunc_ln851_11_fu_20066_p1 = labels_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_2_fu_18627_p1() {
trunc_ln851_2_fu_18627_p1 = results_V_q0.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_3_fu_18667_p1() {
trunc_ln851_3_fu_18667_p1 = results_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_4_fu_19011_p1() {
trunc_ln851_4_fu_19011_p1 = results_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_5_fu_19060_p1() {
trunc_ln851_5_fu_19060_p1 = labels_V_q0.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_6_fu_18863_p1() {
trunc_ln851_6_fu_18863_p1 = labels_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_7_fu_18824_p1() {
trunc_ln851_7_fu_18824_p1 = labels_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_8_fu_18768_p1() {
trunc_ln851_8_fu_18768_p1 = p_Val2_39_fu_2238.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_9_fu_19308_p1() {
trunc_ln851_9_fu_19308_p1 = results_V_q1.read().range(16-1, 0);
}
void ccl::thread_trunc_ln851_fu_18388_p1() {
trunc_ln851_fu_18388_p1 = p_Val2_42_reg_27328.read().range(16-1, 0);
}
void ccl::thread_window_sizes_0_V_4_fu_20105_p3() {
window_sizes_0_V_4_fu_20105_p3 = esl_concat<15,16>(trunc_ln731_fu_20101_p1.read(), ap_const_lv16_0);
}
void ccl::thread_window_sizes_0_V_5_fu_20113_p1() {
window_sizes_0_V_5_fu_20113_p1 = esl_zext<32,31>(window_sizes_0_V_4_fu_20105_p3.read());
}
void ccl::thread_ws_V_V_din() {
if ((esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6757_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_01001.read(), ap_const_boolean_0))) {
ws_V_V_din = tmp_V_215_reg_35580_pp5_iter2_reg.read();
} else if ((esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6756_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_01001.read(), ap_const_boolean_0))) {
ws_V_V_din = tmp_V_216_reg_35565_pp5_iter2_reg.read();
} else if (((esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6754_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_01001.read(), ap_const_boolean_0)) ||
(esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6755_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_01001.read(), ap_const_boolean_0)))) {
ws_V_V_din = tmp_V_1_reg_36941_pp5_iter2_reg.read();
} else if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state35.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, phi_ln160_reg_17639.read()) &&
!(esl_seteq<1,1,1>(ap_const_logic_0, ws_V_V_full_n.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, phi_ln160_reg_17639.read()))) ||
(esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp6_stage0.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln211_reg_39673.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp6_iter1.read()) &&
esl_seteq<1,1,1>(ap_block_pp6_stage0_01001.read(), ap_const_boolean_0)))) {
ws_V_V_din = ap_const_lv32_0;
} else {
ws_V_V_din = (sc_lv<32>) ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
}
}
void ccl::thread_ws_V_V_read() {
if ((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state45.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln218_reg_39682.read()))) {
ws_V_V_read = grp_windows_fu_17784_window_V_V_read.read();
} else {
ws_V_V_read = ap_const_logic_0;
}
}
void ccl::thread_ws_V_V_write() {
if (((esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_state35.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, phi_ln160_reg_17639.read()) &&
!(esl_seteq<1,1,1>(ap_const_logic_0, ws_V_V_full_n.read()) && esl_seteq<1,1,1>(ap_const_lv1_1, phi_ln160_reg_17639.read()))) ||
(esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6754_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_11001.read(), ap_const_boolean_0)) ||
(esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6755_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_11001.read(), ap_const_boolean_0)) ||
(esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6756_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_11001.read(), ap_const_boolean_0)) ||
(esl_seteq<1,1,1>(ap_const_boolean_1, ap_predicate_op6757_write_state40.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp5_iter3.read()) &&
esl_seteq<1,1,1>(ap_block_pp5_stage0_11001.read(), ap_const_boolean_0)) ||
(esl_seteq<1,1,1>(ap_const_logic_1, ap_CS_fsm_pp6_stage0.read()) &&
esl_seteq<1,1,1>(ap_const_lv1_1, icmp_ln211_reg_39673.read()) &&
esl_seteq<1,1,1>(ap_const_logic_1, ap_enable_reg_pp6_iter1.read()) &&
esl_seteq<1,1,1>(ap_block_pp6_stage0_11001.read(), ap_const_boolean_0)))) {
ws_V_V_write = ap_const_logic_1;
} else {
ws_V_V_write = ap_const_logic_0;
}
}
void ccl::thread_xor_ln160_fu_27216_p2() {
xor_ln160_fu_27216_p2 = (icmp_ln163_reg_30878.read() ^ ap_const_lv1_1);
}
void ccl::thread_y_fu_27199_p2() {
y_fu_27199_p2 = (!y_0_i_reg_17741.read().is_01() || !ap_const_lv32_1.is_01())? sc_lv<32>(): (sc_biguint<32>(y_0_i_reg_17741.read()) + sc_biguint<32>(ap_const_lv32_1));
}
void ccl::thread_zext_ln113_1_fu_19114_p1() {
zext_ln113_1_fu_19114_p1 = esl_zext<64,13>(or_ln110_fu_19108_p2.read());
}
void ccl::thread_zext_ln113_2_fu_19131_p1() {
zext_ln113_2_fu_19131_p1 = esl_zext<64,13>(add_ln110_fu_19125_p2.read());
}
void ccl::thread_zext_ln113_3_fu_19142_p1() {
zext_ln113_3_fu_19142_p1 = esl_zext<64,13>(add_ln110_1_fu_19136_p2.read());
}
void ccl::thread_zext_ln113_4_fu_19153_p1() {
zext_ln113_4_fu_19153_p1 = esl_zext<64,13>(add_ln110_2_fu_19147_p2.read());
}
void ccl::thread_zext_ln113_5_fu_19164_p1() {
zext_ln113_5_fu_19164_p1 = esl_zext<64,13>(add_ln110_3_fu_19158_p2.read());
}
void ccl::thread_zext_ln113_6_fu_19175_p1() {
zext_ln113_6_fu_19175_p1 = esl_zext<64,13>(add_ln110_4_fu_19169_p2.read());
}
void ccl::thread_zext_ln113_7_fu_19186_p1() {
zext_ln113_7_fu_19186_p1 = esl_zext<64,13>(add_ln110_5_fu_19180_p2.read());
}
void ccl::thread_zext_ln113_8_fu_19197_p1() {
zext_ln113_8_fu_19197_p1 = esl_zext<64,13>(add_ln110_6_fu_19191_p2.read());
}
void ccl::thread_zext_ln113_9_fu_19208_p1() {
zext_ln113_9_fu_19208_p1 = esl_zext<64,13>(add_ln110_7_fu_19202_p2.read());
}
void ccl::thread_zext_ln113_fu_19103_p1() {
zext_ln113_fu_19103_p1 = esl_zext<64,13>(i_3_0_i_reg_17516.read());
}
void ccl::thread_zext_ln136_fu_19510_p1() {
zext_ln136_fu_19510_p1 = esl_zext<64,9>(select_ln136_reg_28768_pp4_iter1_reg.read());
}
void ccl::thread_zext_ln1499_1_fu_19279_p1() {
zext_ln1499_1_fu_19279_p1 = esl_zext<18,9>(select_ln119_fu_19237_p3.read());
}
void ccl::thread_zext_ln1499_fu_19269_p1() {
zext_ln1499_fu_19269_p1 = esl_zext<18,14>(tmp_6_fu_19261_p3.read());
}
void ccl::thread_zext_ln161_fu_23100_p1() {
zext_ln161_fu_23100_p1 = esl_zext<64,32>(sext_ln160_fu_23096_p1.read());
}
void ccl::thread_zext_ln162_1_fu_27287_p1() {
zext_ln162_1_fu_27287_p1 = esl_zext<18,9>(select_ln227_fu_27245_p3.read());
}
void ccl::thread_zext_ln162_fu_27277_p1() {
zext_ln162_fu_27277_p1 = esl_zext<18,14>(tmp_10_fu_27269_p3.read());
}
void ccl::thread_zext_ln175_1_fu_23442_p1() {
zext_ln175_1_fu_23442_p1 = esl_zext<17,16>(select_ln163_reg_30883.read());
}
void ccl::thread_zext_ln175_2_fu_23451_p1() {
zext_ln175_2_fu_23451_p1 = esl_zext<32,17>(add_ln175_fu_23445_p2.read());
}
void ccl::thread_zext_ln182_fu_23124_p1() {
zext_ln182_fu_23124_p1 = esl_zext<64,16>(select_ln163_fu_23116_p3.read());
}
void ccl::thread_zext_ln203_2_fu_18604_p1() {
zext_ln203_2_fu_18604_p1 = esl_zext<64,18>(add_ln203_fu_18598_p2.read());
}
void ccl::thread_zext_ln203_3_fu_18589_p1() {
zext_ln203_3_fu_18589_p1 = esl_zext<64,18>(add_ln203_3_fu_18583_p2.read());
}
void ccl::thread_zext_ln203_fu_18594_p1() {
zext_ln203_fu_18594_p1 = esl_zext<18,9>(select_ln97_fu_18468_p3.read());
}
void ccl::thread_zext_ln40_fu_18321_p1() {
zext_ln40_fu_18321_p1 = esl_zext<32,18>(ap_phi_mux_p_Val2_ph_phi_fu_17419_p4.read());
}
void ccl::thread_zext_ln46_fu_18355_p1() {
zext_ln46_fu_18355_p1 = esl_zext<64,9>(i_0_i_reg_17427.read());
}
void ccl::thread_zext_ln49_fu_18345_p1() {
zext_ln49_fu_18345_p1 = esl_zext<64,9>(add_ln49_fu_18339_p2.read());
}
void ccl::thread_zext_ln53_fu_18350_p1() {
zext_ln53_fu_18350_p1 = esl_zext<64,9>(i_0_i_reg_17427.read());
}
void ccl::thread_zext_ln559_fu_19482_p1() {
zext_ln559_fu_19482_p1 = esl_zext<64,16>(grp_fu_18274_p4.read());
}
void ccl::thread_zext_ln62_fu_18543_p1() {
zext_ln62_fu_18543_p1 = esl_zext<10,9>(select_ln97_fu_18468_p3.read());
}
void ccl::thread_zext_ln74_1_fu_18722_p1() {
zext_ln74_1_fu_18722_p1 = esl_zext<64,16>(above_fu_18685_p3.read());
}
void ccl::thread_zext_ln74_fu_18912_p1() {
zext_ln74_fu_18912_p1 = esl_zext<64,16>(previous_reg_27412.read());
}
void ccl::thread_zext_ln79_1_fu_18717_p1() {
zext_ln79_1_fu_18717_p1 = esl_zext<64,16>(previous_fu_18651_p3.read());
}
void ccl::thread_zext_ln79_fu_18908_p1() {
zext_ln79_fu_18908_p1 = esl_zext<64,16>(above_reg_27418.read());
}
void ccl::thread_zext_ln835_1_fu_18533_p1() {
zext_ln835_1_fu_18533_p1 = esl_zext<18,14>(tmp_39_fu_18525_p3.read());
}
void ccl::thread_zext_ln835_2_fu_18563_p1() {
zext_ln835_2_fu_18563_p1 = esl_zext<64,18>(add_ln835_fu_18557_p2.read());
}
void ccl::thread_zext_ln835_3_fu_18568_p1() {
zext_ln835_3_fu_18568_p1 = esl_zext<18,9>(select_ln97_fu_18468_p3.read());
}
void ccl::thread_zext_ln835_4_fu_18578_p1() {
zext_ln835_4_fu_18578_p1 = esl_zext<64,18>(add_ln835_1_fu_18572_p2.read());
}
void ccl::thread_zext_ln835_5_fu_18972_p1() {
zext_ln835_5_fu_18972_p1 = esl_zext<18,14>(tmp_2_fu_18964_p3.read());
}
void ccl::thread_zext_ln835_6_fu_18982_p1() {
zext_ln835_6_fu_18982_p1 = esl_zext<18,9>(select_ln105_fu_18940_p3.read());
}
void ccl::thread_zext_ln835_7_fu_19442_p1() {
zext_ln835_7_fu_19442_p1 = esl_zext<18,14>(tmp_8_fu_19434_p3.read());
}
void ccl::thread_zext_ln835_8_fu_19452_p1() {
zext_ln835_8_fu_19452_p1 = esl_zext<18,9>(select_ln136_fu_19410_p3.read());
}
void ccl::thread_zext_ln835_fu_18500_p1() {
zext_ln835_fu_18500_p1 = esl_zext<18,14>(tmp_38_fu_18492_p3.read());
}
}
| [
"32217108+teozax@users.noreply.github.com"
] | 32217108+teozax@users.noreply.github.com |
f63fccdd21b5ef0ef977f71a125b0e6dbbd73278 | 7ad2aac66dc08c3e9f7dfdbe18f3df87d73712eb | /Assign7/Assign7/Queue.h | 6ab62a2c5eb47c0b40950a16271ca1d4b26e1a5d | [] | no_license | AndOrangutan/COMSC-210 | 93f7c19462e736ff65322eeca9af579cd6192221 | 31b52abf1794c00ff5cdb9107bcf703ca8de3df4 | refs/heads/master | 2022-03-23T22:03:30.294127 | 2019-12-13T03:03:43 | 2019-12-13T03:03:43 | 205,643,289 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,288 | h | //Programmer: Von Mueller
//Programmer's ID: 1735441
#ifndef QUEUE_LABEXERCISE6_2_H
#define QUEUE_LABEXERCISE6_2_H
template <typename V>
class Queue
{
class Node
{
public:
V value;
Node* next;
};
int siz;
Node* first;
Node* last;
V dummy = V();
public:
Queue();
Queue(const Queue&);
Queue<V>& operator=(const Queue<V>&);
~Queue();
void push(const V&);
const V& front() const;
const V& back() const;
void pop();
int size() const { return siz; }
bool empty() const { return !siz; }
void clear();
};
template <typename V>
Queue<V>::Queue()
{
first = nullptr;
last = nullptr;
siz = 0;
}
template <typename V>
Queue<V>::Queue(const Queue& input)
{
first = nullptr;
last = nullptr;
siz = input.size();
for (Node* p = input.first; p; p = p->next)
{
Node* temp = new Node;
temp->value = p->value;
temp->next = nullptr;
if (last) last->next = temp;
else first = temp;
last = temp;
}
}
template <typename V>
Queue<V>& Queue<V>::operator=(const Queue<V>& input)
{
if (this != &input)
{
// deallocate existing list
while (first)
{
Node* p = first;
first = first->next;
delete p;
}
//build new queue
last = nullptr;
siz = input.size();
for (Node* p = input.first; p; p = p->next)
{
Node* temp = new Node;
temp->value = p->value;
temp->next = nullptr;
if (last) last->next = temp;
else first = temp;
last = temp;
}
siz = input.size();
}
return *this;
}
template <typename V>
Queue<V>::~Queue()
{
while (first)
{
Node* p = first;
first = first->next;
delete p;
}
}
template <typename V>
void Queue<V>::push(const V& input)
{
Node* temp = new Node{ input };
if (last) last->next = temp;
else first = temp;
last = temp;
siz++;
}
template <typename V>
const V& Queue<V>::front() const
{
if (first)
return first->value;
return dummy;
}
template <typename V>
const V& Queue<V>::back() const
{
if (last)
return last->value;
return dummy;
}
template <typename V>
void Queue<V>::pop()
{
if (first)
{
Node* p = first;
first = first->next;
delete p;
--siz;
}
if (siz == 0)
last = nullptr;
}
template <typename V>
void Queue<V>::clear()
{
while (first)
{
Node* p = first;
first = first->next;
delete p;
--siz;
}
if (siz == 0)
last = nullptr;
}
#endif | [
"vonjonmueller@gmail.com"
] | vonjonmueller@gmail.com |
e56c76cb0a3704f909436c39b518cdcbfd3b0026 | cdab2ef737a481a92fee3e08bbdb7227adbb4259 | /camera/hal/intel/ipu6/modules/sandboxing/IPCIntelAiq.h | 4b911b7b4b002ad4ba35f503910172190d466526 | [
"BSD-3-Clause"
] | permissive | manduSry/platform2 | a2c1c829e45356b920e6c7ba546324e6d6decfdf | 58ede23d2f4cd5651b7afaae5c78893cc836f01d | refs/heads/main | 2023-04-06T19:06:50.384147 | 2020-12-30T04:41:55 | 2021-01-20T04:53:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,586 | h | /*
* Copyright (C) 2019-2020 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <ia_aiq.h>
#include "FaceBase.h"
#include "iutils/CameraLog.h"
#include "iutils/Utils.h"
namespace icamera {
struct aiq_init_params {
unsigned int aiqb_size;
unsigned int nvm_size;
unsigned int aiqd_size;
unsigned int stats_max_width;
unsigned int stats_max_height;
unsigned int max_num_stats_in;
uintptr_t ia_mkn;
uintptr_t cmcRemoteHandle;
uintptr_t results;
};
struct aiq_deinit_params {
uintptr_t aiq_handle;
};
struct af_run_params {
uintptr_t aiq_handle;
ia_aiq_af_input_params base;
ia_rectangle focus_rect;
ia_aiq_manual_focus_parameters manual_focus_parameters;
ia_aiq_af_results results;
};
#define MAX_NUM_GAMMA_LUTS 2048
#define MAX_NUM_TOME_MAP_LUTS 2048
struct gbce_results_params {
ia_aiq_gbce_results base;
float r_gamma_lut[MAX_NUM_GAMMA_LUTS];
float b_gamma_lut[MAX_NUM_GAMMA_LUTS];
float g_gamma_lut[MAX_NUM_GAMMA_LUTS];
float tone_map_lut[MAX_NUM_TOME_MAP_LUTS];
};
struct gbce_run_params {
uintptr_t aiq_handle;
ia_aiq_gbce_input_params base;
gbce_results_params res;
};
#define MAX_NUM_EXPOSURES 3
#define MAX_NUM_FLASHES 1
#define MAX_NUM_OF_EXPOSURE_PLANS 4
#define MAX_SIZE_WEIGHT_GRID (128 * 128)
struct ae_run_params_results {
ia_aiq_ae_results base;
ia_aiq_ae_exposure_result exposures[MAX_NUM_EXPOSURES];
ia_aiq_hist_weight_grid weight_grid;
ia_aiq_flash_parameters flashes[MAX_NUM_FLASHES];
ia_aiq_aperture_control aperture_control;
// the below is in ia_aiq_ae_exposure_result exposures[MAX_NUM_EXPOSURES];
ia_aiq_exposure_parameters exposure[MAX_NUM_EXPOSURES];
ia_aiq_exposure_sensor_parameters sensor_exposure[MAX_NUM_EXPOSURES];
unsigned int exposure_plan_ids[MAX_NUM_EXPOSURES][MAX_NUM_OF_EXPOSURE_PLANS];
// the below is in ia_aiq_hist_weight_grid weight_grid;
unsigned char weights[MAX_SIZE_WEIGHT_GRID];
};
struct ae_run_params {
uintptr_t aiq_handle;
ia_aiq_ae_input_params base;
ia_aiq_exposure_sensor_descriptor sensor_descriptor;
ia_rectangle exposure_window;
ia_coordinate exposure_coordinate;
long manual_exposure_time_us;
float manual_analog_gain;
short manual_iso;
ia_aiq_ae_features aec_features;
ia_aiq_ae_manual_limits manual_limits;
ae_run_params_results res;
};
struct awb_run_params {
uintptr_t aiq_handle;
ia_aiq_awb_input_params base;
ia_aiq_awb_manual_cct_range manual_cct_range;
ia_coordinate manual_white_coordinate;
ia_aiq_awb_results results;
};
#define MAX_NUM_LUTS 128
#define MAX_SECTOR_COUNT 128
#define MAX_IR_WIDTH 128
#define MAX_IR_HEIGHT 128
#define MAX_NUM_IR_BLOCKS (MAX_IR_WIDTH * MAX_IR_HEIGHT)
#define MAX_NUM_IR_MODES 5
struct pa_run_params_results_v1 {
ia_aiq_pa_results_v1 base;
ia_aiq_advanced_ccm_t preferred_acm;
ia_aiq_ir_weight_t ir_weight;
ia_aiq_rgbir_t rgbir;
// for ia_aiq_color_channels_lut linearization
float gr[MAX_NUM_LUTS];
float r[MAX_NUM_LUTS];
float b[MAX_NUM_LUTS];
float gb[MAX_NUM_LUTS];
// for ia_aiq_advanced_ccm_t *preferred_acm
unsigned int hue_of_sectors[MAX_SECTOR_COUNT];
float advanced_color_conversion_matrices[MAX_SECTOR_COUNT][3][3];
// for ia_aiq_ir_weight_t *ir_weight
uint16_t ir_weight_grid_R[MAX_NUM_IR_BLOCKS];
uint16_t ir_weight_grid_G[MAX_NUM_IR_BLOCKS];
uint16_t ir_weight_grid_B[MAX_NUM_IR_BLOCKS];
// for ia_aiq_rgbir_t *rgbir
ia_aiq_rgbir_model_t models[MAX_NUM_IR_MODES];
};
struct ia_atbx_face_state_data {
ia_atbx_face_state base;
ia_atbx_face faces[MAX_FACES_DETECTABLE];
};
struct pa_run_v1_params {
uintptr_t aiq_handle;
ia_aiq_pa_input_params base;
ia_aiq_awb_results awb_results;
ia_aiq_exposure_parameters exposure_params;
ia_aiq_color_channels color_gains;
pa_run_params_results_v1 res;
};
#define LSC_MAX_BAYER_ORDER_NUM 4
#define LSC_TABLE_MAX_WIDTH 100
#define LSC_TABLE_MAX_HEIGHT 100
#define LSC_TABLE_MAX_SIZE (LSC_TABLE_MAX_WIDTH * LSC_TABLE_MAX_HEIGHT)
struct lsc_grid_content {
uint16_t content[LSC_TABLE_MAX_SIZE];
};
struct sa_run_v2_params_results {
ia_aiq_sa_results_v1 base;
lsc_grid_content lsc_grid[LSC_MAX_BAYER_ORDER_NUM][LSC_MAX_BAYER_ORDER_NUM];
};
struct sa_run_v2_params {
uintptr_t aiq_handle;
ia_aiq_sa_input_params_v1 base;
ia_aiq_frame_params sensor_frame_params;
ia_aiq_awb_results awb_results;
sa_run_v2_params_results res;
};
#define MAX_IA_BINARY_DATA_PARAMS_SIZE 500000
struct ia_binary_data_params {
uintptr_t aiq_handle;
uint8_t data[MAX_IA_BINARY_DATA_PARAMS_SIZE];
unsigned int size;
};
#define MAX_IA_AIQ_VERSION_PARAMS_DATA_SIZE 100
struct ia_aiq_version_params {
uintptr_t aiq_handle;
char data[MAX_IA_AIQ_VERSION_PARAMS_DATA_SIZE];
unsigned int size;
};
#define MAX_WIDTH 96
#define MAX_HEIGHT 72
#define MAX_NUM_BLOCKS (MAX_WIDTH * MAX_HEIGHT)
struct ia_aiq_rgbs_grid_data {
ia_aiq_rgbs_grid base;
rgbs_grid_block blocks_ptr[MAX_NUM_BLOCKS];
};
struct ia_aiq_hdr_rgbs_grid_data {
ia_aiq_hdr_rgbs_grid base;
hdr_rgbs_grid_block blocks_ptr[MAX_NUM_BLOCKS];
};
#define MAX_AF_GRID_WIDTH 96
#define MAX_AF_GRID_HEIGHT 72
#define MAX_AF_GRID_SIZE (MAX_AF_GRID_HEIGHT * MAX_AF_GRID_WIDTH)
struct ia_aiq_af_grid_data {
ia_aiq_af_grid base;
int filter_response_1[MAX_AF_GRID_SIZE];
int filter_response_2[MAX_AF_GRID_SIZE];
};
#define MAX_DEPTH_GRID_WIDHT 128
#define MAX_DEPTH_GRID_HEIGHT 128
#define MAX_DEPTH_GRID_SIZE (MAX_DEPTH_GRID_WIDHT * MAX_DEPTH_GRID_HEIGHT)
struct ia_aiq_depth_grid_data {
ia_aiq_depth_grid base;
ia_rectangle grid_rect[MAX_DEPTH_GRID_SIZE];
int depth_data[MAX_DEPTH_GRID_SIZE];
unsigned char confidence[MAX_DEPTH_GRID_SIZE];
};
#define MAX_NUMBER_OF_GRIDS 1
#define MAX_NUMBER_OF_AF_GRIDS 1
#define MAX_NUMBER_OF_HISTROGRAMS 1
#define MAX_NUMBER_OF_DEPTH_GRIDS 1
#define MAX_IR_WEIGHT_GRID_DATA_SIZE 480
struct set_statistics_params_data {
ia_aiq_statistics_input_params_v4 base;
ae_run_params_results frame_ae_parameters;
ia_aiq_af_results frame_af_parameters;
const ia_aiq_rgbs_grid* rgbs_grids_array[MAX_NUMBER_OF_GRIDS];
ia_aiq_rgbs_grid_data rgbs_grids[MAX_NUMBER_OF_GRIDS];
ia_aiq_hdr_rgbs_grid_data hdr_rgbs_grid;
const ia_aiq_af_grid* af_grids_array[MAX_NUMBER_OF_AF_GRIDS];
ia_aiq_af_grid_data af_grids[MAX_NUMBER_OF_AF_GRIDS];
pa_run_params_results_v1 frame_pa_parameters;
ia_atbx_face_state_data faces;
ia_aiq_awb_results awb_results;
sa_run_v2_params_results frame_sa_parameters;
const ia_aiq_depth_grid* depth_grids_array[MAX_NUMBER_OF_DEPTH_GRIDS];
ia_aiq_depth_grid_data depth_grids[MAX_NUMBER_OF_DEPTH_GRIDS];
ia_aiq_grid ir_grid;
unsigned short ir_grid_data[MAX_IR_WEIGHT_GRID_DATA_SIZE];
};
struct set_statistics_set_v4_params {
uintptr_t ia_aiq;
set_statistics_params_data input;
};
class IPCIntelAiq {
public:
IPCIntelAiq();
virtual ~IPCIntelAiq();
// for init
bool clientFlattenInit(const ia_binary_data* aiqbData, const ia_binary_data* nvmData,
const ia_binary_data* aiqdData, unsigned int statsMaxWidth,
unsigned int statsMaxHeight, unsigned int maxNumStatsIn, uintptr_t cmc,
uintptr_t mkn, uint8_t* pData, unsigned int size);
bool serverUnflattenInit(const void* pData, int dataSize, ia_binary_data* aiqbData,
ia_binary_data* nvmData, ia_binary_data* aiqdData);
// for ae
bool clientFlattenAe(uintptr_t aiq, const ia_aiq_ae_input_params& inParams,
ae_run_params* params);
bool clientUnflattenAe(ae_run_params* params, ia_aiq_ae_results** results);
bool serverUnflattenAe(ae_run_params* inParams, ia_aiq_ae_input_params** params);
bool serverFlattenAe(const ia_aiq_ae_results& aeResults, ae_run_params* params);
bool flattenAeResults(const ia_aiq_ae_results& aeResults, ae_run_params_results* res);
bool unflattenAeResults(ae_run_params_results* res);
// for af
bool clientFlattenAf(uintptr_t aiq, const ia_aiq_af_input_params& inParams,
af_run_params* params);
bool clientUnflattenAf(const af_run_params& params, ia_aiq_af_results** results);
bool serverUnflattenAf(af_run_params* inParams, ia_aiq_af_input_params** params);
bool serverFlattenAf(const ia_aiq_af_results& afResults, af_run_params* params);
// for awb
bool clientFlattenAwb(uintptr_t aiq, const ia_aiq_awb_input_params& inParams,
awb_run_params* params);
bool clientUnflattenAwb(const awb_run_params& inParams, ia_aiq_awb_results** results);
bool serverUnflattenAwb(awb_run_params* inParams, ia_aiq_awb_input_params** params);
bool serverFlattenAwb(const ia_aiq_awb_results& awbResults, awb_run_params* params);
// for gbce
bool clientFlattenGbce(uintptr_t aiq, const ia_aiq_gbce_input_params& inParams,
gbce_run_params* params);
bool clientUnflattenGbce(gbce_run_params* params, ia_aiq_gbce_results** results);
bool serverFlattenGbce(const ia_aiq_gbce_results& gbceResults, gbce_run_params* params);
bool flattenGbceResults(const ia_aiq_gbce_results& gbceResults, gbce_results_params* res);
bool unflattenGbceResults(gbce_results_params* res);
// for pa
bool clientFlattenPaV1(uintptr_t aiq, const ia_aiq_pa_input_params& inParams,
pa_run_v1_params* params);
bool clientUnflattenPaV1(pa_run_v1_params* params, ia_aiq_pa_results_v1** results);
bool serverUnflattenPaV1(pa_run_v1_params* inParams, ia_aiq_pa_input_params** params);
bool serverFlattenPaV1(const ia_aiq_pa_results_v1& paResults, pa_run_v1_params* params);
bool flattenPaResultsV1(const ia_aiq_pa_results_v1& paResults, pa_run_params_results_v1* res);
bool unflattenPaResultsV1(pa_run_params_results_v1* res);
// for sa
bool clientFlattenSaV2(uintptr_t aiq, const ia_aiq_sa_input_params_v1& inParams,
sa_run_v2_params* params);
bool clientUnflattenSaV2(sa_run_v2_params* params, ia_aiq_sa_results_v1** results);
bool serverUnflattenSaV2(const sa_run_v2_params& inParams, ia_aiq_sa_input_params_v1** params);
bool serverFlattenSaV2(const ia_aiq_sa_results_v1& saResults, sa_run_v2_params* params);
bool flattenSaResultsV2(const ia_aiq_sa_results_v1& saResults, sa_run_v2_params_results* res);
bool unflattenSaResultsV2(sa_run_v2_params_results* res);
// for statistics
bool clientFlattenStatSetV4(uintptr_t aiq, const ia_aiq_statistics_input_params_v4& inParams,
set_statistics_set_v4_params* params);
bool serverUnflattenStatSetV4(set_statistics_set_v4_params* inParams,
ia_aiq_statistics_input_params_v4** params);
};
} /* namespace icamera */
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
c4078639a484d5c5eaf5fc16d520a02cc889c2eb | e3728ec90949bc6f7bb6f8782c49bd5fb973ef84 | /mylib/hid_protocal/usbGram.cpp | 6a3b3e35bd50029abff42f7a0ffeca554020235e | [] | no_license | zhenghello/QTobj | 7d3c5b351b4fa05d03d7b306b03ab4e02415f139 | 051a78c242e60ce2c6620d2106fad364707e2d58 | refs/heads/master | 2020-05-25T12:51:37.484297 | 2020-05-04T13:39:32 | 2020-05-04T13:39:32 | 187,807,663 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,962 | cpp | /* 这个函数用包和报文之间的转换
* 主要就是对报文和包之间进行校验和转发
*/
#include "usbGram.h"
usbGram::usbGram(int VID, int PID):usbPack(VID, PID)
{
connect(this,SIGNAL(packRx(QVector<char>)),this,SLOT(pack2gram(QVector<char>)));
}
// 校验包 -> 由packRx触发
void usbGram::pack2gram(QVector<char> pack)
{
int lret;
// 校验包的正确性
lret = pack_checksum(pack.data(),pack.size());
// 校验出错的情况
if(lret<0)return;
// 抽出报文,保存
gramRx(pack);// 入队
return ;
}
// 报文转成包
// 计算报文校验码,TXgram再转成的Txpack包
void usbGram::gram2pack(QVector<char> gram)
{
uint16 gram_size;
uint16 i;
gram_size = gram.at(U_LEN_H_INDEX)*256 + gram.at(U_LEN_L_INDEX);// 有效数据长度
// 计算校验码
gram[gram_size+1]=0;
for(i=1;i<(gram_size+1);i++)
{
gram[gram_size+1]+=gram[i];
}
gram[0] = (char)PROTOCOL_FRAME_START_CODE; // 包头
gram[gram_size+2] = (char)PROTOCOL_FRAME_START_CODE;// 包尾
emit gramRx(gram); // 入队
return ;
}
/**
* 函数功能:包校验
* 参数: ppack 一包数据
* 参数: pack_max_len 包数据的最大长度
* 返回: EXIT_FAILURE_LOCOAL 失败 EXIT_SUCCESS_LOCOAL 成功
* 备注: 这里是一帧或多帧数据合并后,校验缓存区的合法性,包括校验头、尾、校验和,可能尾部有空间剩余。
* 比如“aa 00 03 01 00 01 05 55”
*/
int pack_checksum(char *pack, uint pack_size)
{
uint i;
char check_sum; // 校验和
uint length = (uint)pack[U_LEN_H_INDEX]*256 + (uint)pack[U_LEN_L_INDEX];// 数据长度
printf("D:开始校验\r\n");
// 检测头部
if(PROTOCOL_FRAME_START_CODE != pack[U_START_INDEX])
{
// debug_msg("E:ERR_DB_CMD_FORMAT_START",__FILE__,__LINE__);
qDebug()<<"E:ERR_DB_CMD_FORMAT_START";
return -1;
}
// 检测控制码
if( (FRAME_CONTROL_CODE_COMMAND_REP != pack[U_CONTROL_INDEX])\
&&(FRAME_CONTROL_CODE_COMMAND_NO_REP != pack[U_CONTROL_INDEX]))
{
//debug_msg("ERR_DB_CMD_FORMAT_CONTROL",__FILE__,__LINE__);
qDebug()<<"E:ERR_DB_CMD_FORMAT_CONTROL";
return -1;
}
// 检测长度
if(pack_size < length+3)
{
//debug_msg("E:ERR_DB_CMD_FORMAT_DATALEN",__FILE__,__LINE__);
qDebug()<<"E:ERR_DB_CMD_FORMAT_DATALEN";
return -1;
}
// 检测尾部
if(PROTOCOL_FRAME_STOP_CODE != pack[length+5])
{
//debug_msg("E:ERR_DB_CMD_FORMAT_STOP",__FILE__,__LINE__);
qDebug()<<"E:ERR_DB_CMD_FORMAT_STOP";
return -1;
}
// 检验和
check_sum = 0;
for(i=1;i<length+4;i++)
{
check_sum += pack[i];
}
if( check_sum != pack[length+4])
{ // 出错
//debug_msg("E:ERR_DB_CMD_FORMAT_CONTROL",__FILE__,__LINE__);
qDebug()<<"E:ERR_DB_CMD_FORMAT_CONTROL";
return -1;
}
printf("D:校验通过\r\n");
return TRUE;
}
| [
"zkp@qq.com"
] | zkp@qq.com |
8399e2aa27b6be5159980c207d5962f9568670ec | 2eba3b3b3f979c401de3f45667461c41f9b3537a | /cling/stl/dicts/MyClass3.cpp | fb3d5628fc91135e52fcdd2108f7b1d4c0e93ef2 | [] | no_license | root-project/roottest | a8e36a09f019fa557b4ebe3dd72cf633ca0e4c08 | 134508460915282a5d82d6cbbb6e6afa14653413 | refs/heads/master | 2023-09-04T08:09:33.456746 | 2023-08-28T12:36:17 | 2023-08-29T07:02:27 | 50,793,033 | 41 | 105 | null | 2023-09-06T10:55:45 | 2016-01-31T20:15:51 | C++ | UTF-8 | C++ | false | false | 382 | cpp | #include "MyClass3.h"
ClassImp(MyClass3)
MyClass3::MyClass3():
m_id( 0 ),
m_data()
{
m_data.push_back( std::vector< double >() );
}
int
MyClass3::getId() const
{
return m_id;
}
void
MyClass3::setId( int id )
{
m_id = id;
}
void
MyClass3::insert( double value )
{
m_data[0].push_back( value );
}
double
MyClass3::getValue( int id ) const
{
return m_data[0][id];
}
| [
"pcanal@fnal.gov"
] | pcanal@fnal.gov |
1b4c30e7e08938c999ec84733b75a8d153688ffe | 7b26ef8f7122eaede9120c1b80811606cf338a04 | /Assignment1_Game253/Assignment1_Game253/Secondary.h | 6cbf40f9fceea5fd4da564a3a25901ea5f500e36 | [] | no_license | Fabronaut/Game253_Assignment1 | 8df0ce1229ded1cbd1dc444f01241785cbb67ca7 | 51850f19b48a0fa0d6b04fff0a58896458d3a9c3 | refs/heads/master | 2021-09-08T23:12:37.083070 | 2018-03-12T20:25:28 | 2018-03-12T20:25:28 | 124,846,456 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 146 | h | #pragma once
#include "Weapon.h"
class Secondary : public Weapon
{
public:
Secondary();
~Secondary();
Secondary::Secondary(std::string s);
};
| [
"kfaber3234@gmail.com"
] | kfaber3234@gmail.com |
d0dacd551257099186d807bb4a16eea2c7040cba | e22bd6e40dc3bb2053b42ba21d5ef803a27db66f | /src/volcano.h | a404e9081264c3d064f0142b0802f4d733589e24 | [] | no_license | kunalvaswani123/PlaneSimulator | 1e00c417c07b7ea3c1c6464d042e0e159b3ba6c1 | c2bacbcd9b17cf8cd272aef81e957d30615fc5e6 | refs/heads/master | 2020-06-24T06:23:21.652064 | 2019-07-25T17:58:24 | 2019-07-25T17:58:24 | 198,878,414 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 405 | h | #include "main.h"
#ifndef VOLCANO_H
#define VOLCANO_H
class Volcano {
public:
Volcano() {}
Volcano(float x, float y, float z, color_t color);
glm::vec3 position;
glm::vec3 n_position;
float rotation1;
int flag;
float speedz, speedx, speed;
void draw(glm::mat4 VP);
void set_position(float x, float y);
void tick();
private:
VAO *object;
};
#endif // BALL_H
| [
"kvaswani2012@gmail.com"
] | kvaswani2012@gmail.com |
b48f31e0f68be86b6356eee25926e41b342889d7 | 13f45df791b46a1e93bf25fdb8b4601725ec63a2 | /src/layouts/80211b/Layout80211b.cc | b08b9c80e81db858d0e1f8b9a2f934fd643d288b | [] | no_license | polhenarejos/flexicom | 530e55b46c45cf8f78173fd2838000f42c4ef479 | 240aa5c247826c5c6db70ccb14ebb69cb1303150 | refs/heads/master | 2020-07-29T10:39:09.493295 | 2019-09-23T13:51:09 | 2019-09-23T13:51:09 | 209,764,585 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,846 | cc | /*
* This file is part of the FlexiCom distribution (https://github.com/polhenarejos/flexicom).
* Copyright (c) 2012-2020 Pol Henarejos, at Centre Tecnologic de Telecomunicacions de Catalunya (CTTC).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Id$ */
/* $Format:%ci$ ($Format:%h$) by $Format:%an%$ */
#include "Layout80211b.h"
#include <gnuradio/uhd/usrp_source.h>
#include "Rx80211b.h"
#include "MainWindow.h"
#include <QGroupBox>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QComboBox>
#include <iostream>
const char *Layout80211b::name = "802.11b";
static int _d_ = RegisterLayout(Layout80211b::Create);
int channels [] = {
2412, 2417, 2422, 2427, 2432, 2437, 2442,
2447, 2452, 2457, 2462, 2467, 2472, 2484
};
Layout80211b::Layout80211b(MainWindow *_mw, int _radioID) :
LayoutFactory(_mw, _radioID)
{
QObject::connect(mw->panel->rb_layout[radioID]->bt, SIGNAL(toggled(bool)), this, SLOT(RadioPressed(bool)));
}
const char *Layout80211b::Name()
{
return name;
}
LayoutFactory::sptr Layout80211b::Create(MainWindow *_mw, int _radioID)
{
return LayoutFactory::sptr(new Layout80211b(_mw, _radioID));
}
void Layout80211b::Run()
{
grTop = gr::make_top_block(std::string(name));
QString addr = QString("addr0=%1").arg(mw->panel->le_ip[0]->text().remove(' '));
for (int i = 1; i < mw->panel->sp_devs->value(); i++)
addr.append(",addr%1=%2").arg(i).arg(mw->panel->le_ip[i]->text().remove(' '));
if (mw->panel->rb_chain[RB_RX]->isChecked())
{
usrp = gr::uhd::usrp_source::make(addr.toStdString(), uhd::stream_args_t("fc32","sc8"));
usrp->set_samp_rate(10e6);
usrp->set_center_freq(channels[cb_chans->currentIndex()]*1e6);
usrp->set_gain(mw->panel->sp_gain->value());
rx = Rx80211b::Create(this);
grTop->connect(usrp, 0, rx, 0);
grTop->start();
}
}
void Layout80211b::Stop()
{
rx->stop();
grTop->stop();
grTop->wait();
grTop.reset();
}
void Layout80211b::RadioPressed(bool check)
{
if (check)
{
mw->AddCustomTab(CreateTabOpts(), tr("Options"));
mw->panel->rb_chain[RB_TX]->setHidden(true);
mw->panel->rb_chain[RB_RX]->setHidden(false);
mw->panel->rb_chain[RB_RX]->setChecked(true);
ReadSettings(mw->s);
QObject::connect(mw, SIGNAL(SaveSettings(QSettings *)), this, SLOT(SaveSettings(QSettings *)));
DrawPlots();
}
else
{
//SaveSettings(mw->s);
mw->RemoveCustomTabs();
QObject::disconnect(mw, SIGNAL(SaveSettings(QSettings *)), this, SLOT(SaveSettings(QSettings *)));
RemovePlots();
}
}
QWidget *Layout80211b::CreateTabOpts()
{
QWidget *p = new QWidget;
QGroupBox *gBox = new QGroupBox(tr("Channels"));
QGridLayout *vBox = new QGridLayout;
cb_chans = new QComboBox(p);
for (uint i = 0; i < sizeof(channels)/sizeof(int); i++)
cb_chans->addItem(QString("Channel %1: %2 MHz").arg(i+1).arg(channels[i]));
vBox->addWidget(cb_chans);
gBox->setLayout(vBox);
QGridLayout *grid = new QGridLayout(p);
grid->addWidget(gBox, 0, 0);
return p;
}
void Layout80211b::SaveSettings(QSettings *s)
{
s->setValue("80211b/chan", cb_chans->currentIndex());
}
void Layout80211b::ReadSettings(QSettings *s)
{
cb_chans->setCurrentIndex(s->value("80211b/chan").toInt());
}
void Layout80211b::DrawPlots()
{
pl_osc = new QwtPlot;
//mw->AddCustomPlot(pl_osc, 0, 0);
}
void Layout80211b::RemovePlots()
{
//mw->RemoveCustomPlots();
}
| [
"pol.henarejos@cttc.es"
] | pol.henarejos@cttc.es |
c2d6c6c240e2eb48bb1dbc81d507c8863e056a63 | 101ec99130b5dfe724b625a0c8e54b06c422599c | /src/softTone.cc | 61999e3aa56b08cad42f50862ed22ef6aacd9eb8 | [] | no_license | kohei0302/WiringPi-Node | b498a1ce7e88c46290b921b4a53a983bf4f0ffd4 | e245d3f07da20677b74f8b00df79a0011e756309 | refs/heads/master | 2021-01-21T18:11:20.938780 | 2017-09-16T08:28:11 | 2017-09-16T08:28:11 | 92,022,056 | 3 | 3 | null | 2017-05-22T07:03:41 | 2017-05-22T07:03:41 | null | UTF-8 | C++ | false | false | 2,047 | cc | #include "softTone.h"
#include <softTone.h>
DECLARE(softToneCreate);
DECLARE(softToneWrite);
DECLARE(softToneStop);
// Func : int softToneCreate(int pin);
// Description : This creates a software controlled tone pin.
// You can use any GPIO pin and the pin numbering will be that of the wiringPiSetup() function you used.
// The return value is 0 for success.
// Anything else and you should check the global errno variable to see what went wrong.
// NOTE : You must initialise wiringPi with one of wiringPiSetup(), wiringPiSetupGpio() or wiringPiSetupPhys() functions.
// wiringPiSetupSys() is not fast enough, so you must run your programs with sudo.
// NOTE2 : Each pin activated in softTone mode uses approximately 0.5% of the CPU.
// NOTE3 : You need to keep your program running to maintain the sound output!
IMPLEMENT(softToneCreate) {
SCOPE_OPEN();
SET_ARGUMENT_NAME(0, pin);
CHECK_ARGUMENTS_LENGTH_EQUAL(1);
CHECK_ARGUMENT_TYPE_INT32(0);
int pin = GET_ARGUMENT_AS_INT32(0);
int res = ::softToneCreate(pin);
SCOPE_CLOSE(INT32(res));
}
// Func : void softToneWrite(int pin, int freq);
// Description : This updates the tone frequency value on the given pin. The tone will be played until you set the frequency to 0.
IMPLEMENT(softToneWrite) {
SCOPE_OPEN();
SET_ARGUMENT_NAME(0, pin);
SET_ARGUMENT_NAME(1, frequency);
CHECK_ARGUMENTS_LENGTH_EQUAL(2);
CHECK_ARGUMENT_TYPE_INT32(0);
CHECK_ARGUMENT_TYPE_INT32(1);
int pin = GET_ARGUMENT_AS_INT32(0);
int frequency = GET_ARGUMENT_AS_INT32(1);
::softToneWrite(pin, frequency);
SCOPE_CLOSE(UNDEFINED());
}
IMPLEMENT(softToneStop) {
SCOPE_OPEN();
SET_ARGUMENT_NAME(0, pin);
CHECK_ARGUMENTS_LENGTH_EQUAL(1);
CHECK_ARGUMENT_TYPE_INT32(0);
int pin = GET_ARGUMENT_AS_INT32(0);
::softToneStop(pin);
SCOPE_CLOSE(UNDEFINED());
}
IMPLEMENT_EXPORT_INIT(softTone) {
EXPORT_FUNCTION(softToneCreate);
EXPORT_FUNCTION(softToneWrite);
EXPORT_FUNCTION(softToneStop);
} | [
"leandre.gohy@hexeo.be"
] | leandre.gohy@hexeo.be |
d46303e8b742e8263d0c7cdf0aca60f4f576fa8d | ed5669151a0ebe6bcc8c4b08fc6cde6481803d15 | /test/magma-1.4.1/src/dpotrs_gpu.cpp | 17c4645772de00fb121e81efa6ff855253dcf8dd | [] | no_license | JieyangChen7/DVFS-MAGMA | 1c36344bff29eeb0ce32736cadc921ff030225d4 | e7b83fe3a51ddf2cad0bed1d88a63f683b006f54 | refs/heads/master | 2021-09-26T09:11:28.772048 | 2018-05-27T01:45:43 | 2018-05-27T01:45:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,481 | cpp | /*
-- MAGMA (version 1.4.1) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
December 2013
@generated d Tue Dec 17 13:18:34 2013
*/
#include "common_magma.h"
extern "C" magma_int_t
magma_dpotrs_gpu(char uplo, magma_int_t n, magma_int_t nrhs,
double *dA, magma_int_t ldda,
double *dB, magma_int_t lddb, magma_int_t *info)
{
/* -- MAGMA (version 1.4.1) --
Univ. of Tennessee, Knoxville
Univ. of California, Berkeley
Univ. of Colorado, Denver
December 2013
Purpose
=======
DPOTRS solves a system of linear equations A*X = B with a symmetric
positive definite matrix A using the Cholesky factorization
A = U**T*U or A = L*L**T computed by DPOTRF.
Arguments
=========
UPLO (input) CHARACTER*1
= 'U': Upper triangle of A is stored;
= 'L': Lower triangle of A is stored.
N (input) INTEGER
The order of the matrix A. N >= 0.
NRHS (input) INTEGER
The number of right hand sides, i.e., the number of columns
of the matrix B. NRHS >= 0.
dA (input) DOUBLE_PRECISION array on the GPU, dimension (LDDA,N)
The triangular factor U or L from the Cholesky factorization
A = U**T*U or A = L*L**T, as computed by DPOTRF.
LDDA (input) INTEGER
The leading dimension of the array A. LDDA >= max(1,N).
dB (input/output) DOUBLE_PRECISION array on the GPU, dimension (LDDB,NRHS)
On entry, the right hand side matrix B.
On exit, the solution matrix X.
LDDB (input) INTEGER
The leading dimension of the array B. LDDB >= max(1,N).
INFO (output) INTEGER
= 0: successful exit
< 0: if INFO = -i, the i-th argument had an illegal value
===================================================================== */
double c_one = MAGMA_D_ONE;
*info = 0 ;
if( (uplo != 'U') && (uplo != 'u') && (uplo != 'L') && (uplo != 'l') )
*info = -1;
if( n < 0 )
*info = -2;
if( nrhs < 0)
*info = -3;
if ( ldda < max(1, n) )
*info = -5;
if ( lddb < max(1, n) )
*info = -7;
if (*info != 0) {
magma_xerbla( __func__, -(*info) );
return *info;
}
/* Quick return if possible */
if ( (n == 0) || (nrhs == 0) ) {
return *info;
}
if( (uplo=='U') || (uplo=='u') ){
if ( nrhs == 1) {
magma_dtrsv(MagmaUpper, MagmaTrans, MagmaNonUnit, n, dA, ldda, dB, 1 );
magma_dtrsv(MagmaUpper, MagmaNoTrans, MagmaNonUnit, n, dA, ldda, dB, 1 );
} else {
magma_dtrsm(MagmaLeft, MagmaUpper, MagmaTrans, MagmaNonUnit, n, nrhs, c_one, dA, ldda, dB, lddb);
magma_dtrsm(MagmaLeft, MagmaUpper, MagmaNoTrans, MagmaNonUnit, n, nrhs, c_one, dA, ldda, dB, lddb);
}
}
else{
if ( nrhs == 1) {
magma_dtrsv(MagmaLower, MagmaNoTrans, MagmaNonUnit, n, dA, ldda, dB, 1 );
magma_dtrsv(MagmaLower, MagmaTrans, MagmaNonUnit, n, dA, ldda, dB, 1 );
} else {
magma_dtrsm(MagmaLeft, MagmaLower, MagmaNoTrans, MagmaNonUnit, n, nrhs, c_one, dA, ldda, dB, lddb);
magma_dtrsm(MagmaLeft, MagmaLower, MagmaTrans, MagmaNonUnit, n, nrhs, c_one, dA, ldda, dB, lddb);
}
}
return *info;
}
| [
"cjy7117@gmail.com"
] | cjy7117@gmail.com |
97fd62eda1b55b88588c0f8a2ac708bb88a6c454 | b3afd40ff8e996749fa96cfa8f54cab6b8966af5 | /SteeringBehaviors/FleeAgent.h | f046929702fb2d5e7beaac100f4d66acb27b2df7 | [] | no_license | Knothe/SteeringBehaviorsTests | 75babbb11fe6cb35cfa614ebbfaebc92e599fce9 | 41d3608eab001179a531fdd346efd43f1e0eac1e | refs/heads/master | 2021-01-03T02:34:22.886434 | 2020-02-11T22:32:56 | 2020-02-11T22:32:56 | 239,875,816 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 308 | h | #pragma once
#include "Vec2.h"
#include "Image.h"
#include "Platform.h"
class FleeAgent
{
public:
FleeAgent();
void Update(MouseData* mouseData);
void Draw();
void Init();
private:
Platform* platform;
Vec2 position;
Vec2 velocity;
float angle;
float maxSpeed;
float maxForce;
Image texture;
};
| [
"ivanovich99@gmail.com"
] | ivanovich99@gmail.com |
3d93b92aefb66c29a03f693e94c7883a19e19b75 | eb3cc54905262133f6d36e9f5e1770b941b19c76 | /Utils.cpp | 12a8c69a30d4cb6f5759da03be0b3a0c27492ce3 | [] | no_license | defuchocolate/FaceRecognizerSVM | 4591ee08e942885b10b7fed9e1d240e32449f239 | ed7ff1505810a1dffd562558304fc8d92415ef64 | refs/heads/master | 2021-01-22T22:57:22.618237 | 2016-08-11T10:40:25 | 2016-08-11T10:40:25 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 7,080 | cpp | #include "Utils.h"
Utils::Utils(void)
{
}
Utils::~Utils(void)
{
}
Mat Utils::toGrayscale(InputArray _src) {
Mat src = _src.getMat();
// only allow one channel
if(src.channels() != 1) {
CV_Error(1, "Only Matrices with one channel are supported");
}
// create and return normalized image
Mat dst;
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
return dst;
}
void Utils::read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator) {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "No valid input file was given, please check the given filename.";
CV_Error(1, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty())
{
//Mat im = imread
images.push_back(imread(path,0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
void Utils::getPathsFromCSV( const string& csv_path, vector<string>& paths, char separator )
{
std::ifstream file(csv_path.c_str(), ifstream::in);
if (!file) {
string error_message = "No valid input file was given, please check the given filename.";
CV_Error(1, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty())
{
paths.push_back(path);
}
}
}
// Normalizes a given image into a value range between 0 and 255.
Mat Utils::norm_0_255(const Mat& src) {
// Create and return normalized image:
Mat dst;
switch(src.channels()) {
case 1:
cv::normalize(src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
break;
case 3:
cv::normalize(src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
break;
default:
src.copyTo(dst);
break;
}
return dst;
}
//
// Calculates the TanTriggs Preprocessing as described in:
//
// Tan, X., and Triggs, B. "Enhanced local texture feature sets for face
// recognition under difficult lighting conditions.". IEEE Transactions
// on Image Processing 19 (2010), 1635–650.
//
// Default parameters are taken from the paper.
//
Mat Utils::tan_triggs_preprocessing(InputArray src,
float alpha, float tau, float gamma, int sigma0, int sigma1) {
// Convert to floating point:
Mat X = src.getMat();
X.convertTo(X, CV_32FC1);
// Start preprocessing:
Mat I;
pow(X, gamma, I);
// Calculate the DOG Image:
{
Mat gaussian0, gaussian1;
// Kernel Size:
int kernel_sz0 = (3*sigma0);
int kernel_sz1 = (3*sigma1);
// Make them odd for OpenCV:
kernel_sz0 += ((kernel_sz0 % 2) == 0) ? 1 : 0;
kernel_sz1 += ((kernel_sz1 % 2) == 0) ? 1 : 0;
GaussianBlur(I, gaussian0, Size(kernel_sz0,kernel_sz0), sigma0, sigma0, BORDER_CONSTANT);
GaussianBlur(I, gaussian1, Size(kernel_sz1,kernel_sz1), sigma1, sigma1, BORDER_CONSTANT);
subtract(gaussian0, gaussian1, I);
}
{
double meanI = 0.0;
{
Mat tmp;
pow(abs(I), alpha, tmp);
meanI = mean(tmp).val[0];
}
I = I / pow(meanI, 1.0/alpha);
}
{
double meanI = 0.0;
{
Mat tmp;
pow(min(abs(I), tau), alpha, tmp);
meanI = mean(tmp).val[0];
}
I = I / pow(meanI, 1.0/alpha);
}
// Squash into the tanh:
{
for(int r = 0; r < I.rows; r++) {
for(int c = 0; c < I.cols; c++) {
I.at<float>(r,c) = tanh(I.at<float>(r,c) / tau);
}
}
I = tau * I;
}
return I;
}
/* split the string str using delimeter delim and fill the parts vector with the string parts */
void Utils::split(const string& str, const string& delim, vector<string>& parts) {
size_t start, end = 0;
while (end < str.size()) {
start = end;
while (start < str.size() && (delim.find(str[start]) != string::npos)) {
start++; // skip initial whitespace
}
end = start;
while (end < str.size() && (delim.find(str[end]) == string::npos)) {
end++; // skip to end of word
}
if (end-start != 0) { // just ignore zero-length strings.
parts.push_back(string(str, start, end-start));
}
}
}
/* returns true if opt is parsed and i+=0 */
int Utils::readOption(int argc, char** argv, int *i, const char* opt){
if((*i) < argc){
if(_stricmp(argv[(*i)],opt) == 0){
return 1;
}
}
else{
clParseError(argc, argv, (*i), "Error parsing command line.");
}
return 0;
}
/* returns true if opt is parsed and sets arg to point to location in argv that is after flag (the next string) i+=1 */
int Utils::readOptionString(int argc, char** argv, int *i, const char* opt, char** arg){
if((*i) < argc){
if(_stricmp(argv[(*i)],opt) == 0){
(*i) += 1;
if(*i < argc){
(*arg) = argv[(*i)];
} else {
clParseError(argc, argv, (*i), "Option expects one argument.");
}
return 1;
}
}
else{
clParseError(argc, argv, (*i), "Error parsing command line.");
}
return 0;
}
/* check to see if current argument starts with a dash and if it does output an error and exit. otherwize return 0 */
int Utils::checkBadOption(int argc, char** argv, int *i){
if((*i) < argc){
if(argv[(*i)][0] == '-'){
clParseError(argc, argv, (*i), "Unrecognized option.");
}
}
else{
clParseError(argc, argv, (*i), "Error parsing command line.");
}
return 0;
}
/* Output a command line parsing error */
void Utils::clParseError(int argc, char **argv, int i, char* message){
fprintf(stdout, "Error: %s\n", message);
fprintf(stdout, " for command at command line argument <%d: %s >\n", i, (i < argc) ? argv[i] : "(Error: passed end of line)");
//usage((0 < argc) ? argv[0] : "(Error: No program name)");
exit(1);
}
std::vector<std::pair<double,int>> Utils::get_pairs(std::vector<double> vec)
{
std::vector<std::pair<double,int>> temp; // vector of pairs
for(int i = 0; i < vec.size() ; i++)
temp.push_back(std::pair<double,int>(vec[i],i));
return temp;
}
void Utils::getCurrentDateTime( char* result, int sizeInBytes )
{
// get current date and time
time_t now = time(0);
tm tstruct = *localtime(&now);
//char buf[80];
strftime(result, sizeInBytes, "%Y-%m-%d.%X", &tstruct);
//return buf;
}
| [
"noreply@github.com"
] | defuchocolate.noreply@github.com |
d021a230027d1e70282a719e1c5ee46a1c64e45f | 1172b8157cc5f248e43a1388b546939a1da880ef | /oneflow/user/kernels/transpose_kernel.cpp | e9dc5e4e40c7661615032842698980810d81ba39 | [
"Apache-2.0"
] | permissive | WangHuiNEU/oneflow | 27102bdde571b2ae0e069882da99bf1a40f2675e | b105cacd1e3b0b21bdec1a824a2c125390a2a665 | refs/heads/master | 2023-08-25T09:55:40.300174 | 2021-10-19T10:54:41 | 2021-10-19T10:54:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,055 | cpp | /*
Copyright 2020 The OneFlow Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "oneflow/core/common/protobuf.h"
#include "oneflow/core/framework/framework.h"
#include "oneflow/core/kernel/new_kernel_util.h"
#include "oneflow/core/kernel/cuda_graph_support.h"
namespace oneflow {
namespace user_op {
template<DeviceType device_type, typename T>
class TransposeKernel final : public OpKernel, public user_op::CudaGraphSupport {
public:
TransposeKernel() = default;
~TransposeKernel() override = default;
private:
void Compute(KernelComputeContext* ctx) const override {
const Tensor* tensor_in = ctx->Tensor4ArgNameAndIndex("input", 0);
Tensor* tensor_out = ctx->Tensor4ArgNameAndIndex("output", 0);
const auto& perm = ctx->Attr<std::vector<int32_t>>("perm");
const ShapeView& in_shape = tensor_in->shape();
const ShapeView& out_shape = tensor_out->shape();
NewKernelUtil<device_type>::Transpose(ctx->device_ctx(), in_shape.NumAxes(), in_shape,
out_shape, perm, in_shape.elem_cnt(),
tensor_in->dptr<T>(), tensor_out->mut_dptr<T>());
}
bool AlwaysComputeWhenAllOutputsEmpty() const override { return false; }
};
#define REGISTER_TRANSPOSE_KERNEL(device, dtype) \
REGISTER_USER_KERNEL("transpose") \
.SetCreateFn<TransposeKernel<device, dtype>>() \
.SetIsMatchedHob((user_op::HobDeviceTag() == device) \
& (user_op::HobDataType("input", 0) == GetDataType<dtype>::value) \
& (user_op::HobDataType("output", 0) == GetDataType<dtype>::value));
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, uint8_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, int8_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, int32_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, int64_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, float)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kCPU, double)
#ifdef WITH_CUDA
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, uint8_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, int8_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, int32_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, int64_t)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, float)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, double)
REGISTER_TRANSPOSE_KERNEL(DeviceType::kGPU, float16)
#endif
} // namespace user_op
} // namespace oneflow
| [
"noreply@github.com"
] | WangHuiNEU.noreply@github.com |
f58621a8577c7d3691be80db67b86b09eebf9c37 | a6ff63ad418ba4bbbdba2cf2381bf1cd64d1a3a7 | /CodeForces/919B.cpp | 4c53c416538262aaf9d318bf39dbea32e0bc7619 | [] | no_license | Igronemyk/OI | 537eb08f9837d0d83166e10b768cf193520ba069 | eb706fd767ce5a3195681d2140f9e747dab5f12e | refs/heads/master | 2021-09-16T15:37:20.246679 | 2018-06-22T03:08:55 | 2018-06-22T03:08:55 | 103,484,287 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 534 | cpp | #include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int k;
cin >> k;
int value = 1;
while(true) {
int tmpValue = value,sum = 0;
while(tmpValue) {
sum += tmpValue % 10;
tmpValue /= 10;
}
if(sum == 10) {
k--;
}
if(k == 0) {
printf("%d\n",value);
break;
}
value++;
}
return 0;
}
| [
"igronemyk@gmail.com"
] | igronemyk@gmail.com |
8ffb076ad52179f89cb0f23565f23fad3bae37cb | 1e101a641884a7ba3928b82cca62530c78617d38 | /fruitAndbird/Classes/SetLayer.hpp | 0bee4ed30285772b2808a4daa7f220bbc82ae0ef | [] | no_license | Crasader/cocos2d-x-1 | 43c34367ae6ad3e76067ce085d717e9ba8347908 | 784636bfb6dce285e927bd8242f8008de4d3f2fb | refs/heads/master | 2020-11-29T04:20:46.587639 | 2016-07-15T09:09:18 | 2016-07-15T09:09:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 592 | hpp | //
// SetLayer.hpp
// fruitAndbird
//
// Created by zwj on 16/5/27.
//
//
#ifndef SetLayer_hpp
#define SetLayer_hpp
#include <stdio.h>
#include "GameSceneManager.hpp"
#include "cocos2d.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace ui;
class setLayer:public Layer
{
public:
CREATE_FUNC(setLayer);
GameSceneManager *sceneManager;
public:
virtual bool init();
void menuCallBack(Ref* pSender);
void selectedEvent0(Ref *pSender, CheckBox::EventType type);
void selectedEvent1(Ref *pSender,CheckBox::EventType type);
};
#endif /* SetLayer_hpp */
| [
"zwjioro@163.com"
] | zwjioro@163.com |
1cf14ed31d57d7a0cc45d494bd99026662531adf | f1d39c056d00ee1eb96a888ec7818e921c8dc83e | /exercise4/exercise4_src/bus_cx/ram.h | 3819fbfca3feda3bce4a03d3b58ca960cab2a3eb | [] | no_license | SeverinDavis/MSS | afb8023d1e9348a8de55397f4ed8ac2283749e2f | f6100039de99c03503f1e8d8278716b00aecec42 | refs/heads/master | 2020-06-28T02:48:17.157744 | 2017-07-13T05:43:12 | 2017-07-13T05:43:12 | 97,084,250 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 574 | h | #ifndef _RAM_H_
#define _RAM_H_
#include "bus_if.h"
#include "debug_if.h"
class Ram : public sc_module, public bus_if, public debug_if
{
public:
sc_export<bus_if> target_export;
void write( unsigned addr, unsigned data );
void read( unsigned addr, unsigned &data );
unsigned start, sz;
unsigned *mem;
virtual void dump(ostream &os);
Ram( sc_module_name mn, unsigned start_addr, unsigned size )
: sc_module(mn)
{
target_export.bind(*this);
start = start_addr;
sz = size;
mem = new unsigned[sz];
}
~Ram() { delete[] mem; }
};
#endif
| [
"severin.davis@gmail.com"
] | severin.davis@gmail.com |
c396a89195f7f643bfae7452d4ade7de46911c68 | 992de008ba03cfd5e8ac3bd75d5dc1da6a399a58 | /Nyanball/Classes/GameScene.h | 0bc358fe616c122595010797d4ca0cb2c96bb844 | [] | no_license | ippei-takahashi/CocosNyanball | 71dd1d83b2aa0d725097a44321d9d945c1916f60 | e4a425bc8ad41321e9d89f8d8fb3b25cfe7e3e46 | refs/heads/master | 2021-01-10T09:48:25.833763 | 2015-05-24T12:03:32 | 2015-05-24T12:03:32 | 36,170,373 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,359 | h | #ifndef __GAME_SCENE_H__
#define __GAME_SCENE_H__
#include "cocos2d.h"
#include "Box2D/Box2D.h"
class GamePhysicsContactListener : public b2ContactListener
{
protected:
cocos2d::Ref* m_target;
cocos2d::SEL_CallFunc m_selector;
public:
GamePhysicsContactListener(cocos2d::Ref* target, cocos2d::SEL_CallFunc selector);
void BeginContact(b2Contact* contact);
};
class GameScene : public cocos2d::Layer
{
protected:
enum kTag
{
kTagBackground = 1,
};
enum kZOrder
{
kZOrder_Background = 1,
kZOrder_Score,
kZOrder_Flipper,
kZOrder_Ball,
kZOrder_Button,
};
void createBackground();
void createButton();
void createFlipper();
b2World* world;
void initPhysics();
b2Body* bgBody;
void createBall();
virtual bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
b2Body* leftFlipperBody;
b2Body* rightFlipperBody;
cocos2d::LabelTTF* score;
GamePhysicsContactListener* gamePhysicsContactListener;
void createScore();
void updateScore();
int ballCount;
void createReset();
void tapReset(Ref* target);
public:
virtual bool init();
static cocos2d::Scene* scene();
CREATE_FUNC(GameScene);
void update(float dt);
};
#endif // __GAME_SCENE_H__ | [
"ippnin@gmail.com"
] | ippnin@gmail.com |
362b241f309d862bb96b2053712f0015b55c6b20 | 251dbd9ee40da70e16300f4a8c223130a5bb7ae8 | /chapter_1/ex_1.21.cpp | 65563597b164786f84ddb443f4a2bbd3c7ac05b5 | [
"MIT"
] | permissive | YasserKa/Cpp_Primer | cfd2c5b94ccadc444d766ad1a58a0a56f61dfac8 | 198b10255fd67e31c15423a5e44b7f02abb8bdc2 | refs/heads/master | 2021-01-20T10:30:19.416414 | 2017-09-05T20:41:39 | 2017-09-05T20:41:39 | 101,640,247 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 310 | cpp | #include <iostream>
#include "Sales_item.h"
int main()
{
Sales_item item1, item2;
std::cin >> item1 >> item2;
if (item1.isbn() == item2.isbn())
std::cout << item1 + item2;
else
std::cout << "The books don't have the same isbn.";
std::cout << std::endl;
return 0;
}
| [
"yasserkaddouralearn@gmail.com"
] | yasserkaddouralearn@gmail.com |
edefb46f7297d3a3d7b7a82ea51e2bb9a5fefd99 | 8909821cc0fda6051b6f4fb3d30b2b0f1ccf65d8 | /Dynamic Programming/6. Grid Paths.cpp | a32efc7d06911b42f5832098996580d63d6a3e15 | [] | no_license | lsiddiqsunny/CSES-Solution | 7ecdb5a1414d6e6e99d148a44946e2d5128c6fae | 6ad4cc19cd0597f6876625991a1bba038816d606 | refs/heads/master | 2022-12-13T20:37:59.392069 | 2020-09-06T23:08:49 | 2020-09-06T23:08:49 | 290,713,377 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 908 | cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int mod = 1e9 + 7;
int n;
cin >> n;
string s[n];
for (int i = 0; i < n; i++)
{
cin >> s[i];
}
int dp[n][n] = {0};
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (s[i][j] == '*')
{
dp[i][j] = 0;
continue;
}
if (i == 0 and j == 0)
{
dp[i][j] = 1;
continue;
}
if (i == 0)
{
dp[i][j] = dp[i][j - 1];
continue;
}
if (j == 0)
{
dp[i][j] = dp[i - 1][j];
continue;
}
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
dp[i][j] %= mod;
}
}
cout << dp[n - 1][n - 1] << endl;
} | [
"lsiddiqsunny@gmail.com"
] | lsiddiqsunny@gmail.com |
ea0ce30b8e1ca6e038b6fdb058046ab79b457744 | 7fd5e6156d6a42b305809f474659f641450cea81 | /boost/heap/heap_merge.hpp | 1a1ef8741789b29c3f97d43507b053402a382290 | [] | no_license | imos/icfpc2015 | 5509b6cfc060108c9e5df8093c5bc5421c8480ea | e998055c0456c258aa86e8379180fad153878769 | refs/heads/master | 2020-04-11T04:30:08.777739 | 2015-08-10T11:53:12 | 2015-08-10T11:53:12 | 40,011,767 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,741 | hpp | // boost heap: heap merge algorithms
//
// Copyright (C) 2011 Tim Blechmann
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_HEAP_MERGE_HPP
#define BOOST_HEAP_MERGE_HPP
#include "boost/concept/assert.hpp"
#include "boost/heap/heap_concepts.hpp"
#include "boost/type_traits/is_same.hpp"
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
namespace heap {
namespace detail {
template <typename Heap1, typename Heap2>
struct heap_merge_emulate
{
struct dummy_reserver
{
static void reserve (Heap1 & lhs, std::size_t required_size)
{}
};
struct reserver
{
static void reserve (Heap1 & lhs, std::size_t required_size)
{
lhs.reserve(required_size);
}
};
typedef typename boost::mpl::if_c<Heap1::has_reserve,
reserver,
dummy_reserver>::type space_reserver;
static void merge(Heap1 & lhs, Heap2 & rhs)
{
if (Heap1::constant_time_size && Heap2::constant_time_size) {
if (Heap1::has_reserve) {
std::size_t required_size = lhs.size() + rhs.size();
space_reserver::reserve(lhs, required_size);
}
}
// FIXME: container adaptors could benefit from first appending all elements and then restoring the heap order
// FIXME: optimize: if we have ordered iterators and we can efficiently insert keys with a below the lowest key in the heap
// d-ary, b and fibonacci heaps fall into this category
while (!rhs.empty()) {
lhs.push(rhs.top());
rhs.pop();
}
lhs.set_stability_count((std::max)(lhs.get_stability_count(),
rhs.get_stability_count()));
rhs.set_stability_count(0);
}
};
template <typename Heap>
struct heap_merge_same_mergable
{
static void merge(Heap & lhs, Heap & rhs)
{
lhs.merge(rhs);
}
};
template <typename Heap>
struct heap_merge_same
{
static const bool is_mergable = Heap::is_mergable;
typedef typename boost::mpl::if_c<is_mergable,
heap_merge_same_mergable<Heap>,
heap_merge_emulate<Heap, Heap>
>::type heap_merger;
static void merge(Heap & lhs, Heap & rhs)
{
heap_merger::merge(lhs, rhs);
}
};
} /* namespace detail */
/** merge rhs into lhs
*
* \b Effect: lhs contains all elements that have been part of rhs, rhs is empty.
*
* */
template <typename Heap1,
typename Heap2
>
void heap_merge(Heap1 & lhs, Heap2 & rhs)
{
BOOST_CONCEPT_ASSERT((boost::heap::PriorityQueue<Heap1>));
BOOST_CONCEPT_ASSERT((boost::heap::PriorityQueue<Heap2>));
// if this assertion is triggered, the value_compare types are incompatible
BOOST_STATIC_ASSERT((boost::is_same<typename Heap1::value_compare, typename Heap2::value_compare>::value));
const bool same_heaps = boost::is_same<Heap1, Heap2>::value;
typedef typename boost::mpl::if_c<same_heaps,
detail::heap_merge_same<Heap1>,
detail::heap_merge_emulate<Heap1, Heap2>
>::type heap_merger;
heap_merger::merge(lhs, rhs);
}
} /* namespace heap */
} /* namespace boost */
#endif /* BOOST_HEAP_MERGE_HPP */
| [
"git@imoz.jp"
] | git@imoz.jp |
ea4da7510f84c5947a35cba51932304c94074c4d | db013e1c68a636db45264b0833cd7eb4213b5ebd | /src/Enki/Graphics/FontLog.hpp | 548d164cbdd497971c84180708f7c101143852d8 | [
"MIT"
] | permissive | Zephilinox/Enki | 8c00e5ee8d9eff2a696d1800449e27fd97f2d9fb | 5f405fec9ae0f3c3344a99fbee590d76ed4dbe55 | refs/heads/master | 2021-06-22T17:25:16.406539 | 2021-02-27T19:34:00 | 2021-02-27T19:34:00 | 199,689,468 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 323 | hpp | #pragma once
//SELF
#include "Enki/Graphics/Font.hpp"
namespace enki
{
class FontLog final : public Font
{
public:
FontLog();
FontLog(std::unique_ptr<Font> font);
bool loadFromFile(const std::string& file) final;
static constexpr HashedID type = hash_constexpr("Log");
private:
std::unique_ptr<Font> font;
};
} | [
"zephilinox@hotmail.co.uk"
] | zephilinox@hotmail.co.uk |
8a3d05fe0bfefa39a51d2dcd4b170f82c841535f | 7e4ef7ec81cefef0f2092eb9ba65d72263026437 | /Siv3D/include/Siv3D/GamepadInfo.hpp | 3174ca61a6eb02ed320d9ef92a8c313ae6d99729 | [
"MIT"
] | permissive | zakuro9715/OpenSiv3D | 0fb50580212cc667f2f749f8e39dcb696764cbc4 | 6cf5fc00f71cfc39883a2c57a71ad8f51bc69b5d | refs/heads/master | 2023-03-06T13:42:56.410816 | 2023-03-03T13:38:54 | 2023-03-03T13:38:54 | 208,563,311 | 0 | 0 | MIT | 2019-09-15T08:22:18 | 2019-09-15T08:22:17 | null | UTF-8 | C++ | false | false | 925 | hpp | //-----------------------------------------------
//
// This file is part of the Siv3D Engine.
//
// Copyright (c) 2008-2022 Ryo Suzuki
// Copyright (c) 2016-2022 OpenSiv3D Project
//
// Licensed under the MIT License.
//
//-----------------------------------------------
# pragma once
# include "Common.hpp"
# include "Array.hpp"
# include "String.hpp"
namespace s3d
{
/// @brief ゲームパッドの情報
struct GamepadInfo
{
/// @brief 現在接続されているプレイヤーインデックス
uint32 playerIndex = 0;
/// @brief ベンダー ID
uint32 vendorID = 0;
/// @brief プロダクト ID
uint32 productID = 0;
/// @brief ゲームパッドの名称
String name;
};
namespace System
{
/// @brief 使用可能なゲームパッドの一覧を返します。
/// @return 使用可能なゲームパッドの一覧
[[nodiscard]]
Array<GamepadInfo> EnumerateGamepads();
}
}
| [
"reputeless+github@gmail.com"
] | reputeless+github@gmail.com |
6f370aba17152d11642d94b6f9b24f4fbf03c7ca | fd6c03d5fba4ca1ca5a178d8406d27768d0157e2 | /src/coins.h | 9f66fd6714bf72b2364a5c20bc49a95957bc60a9 | [
"MIT"
] | permissive | jschmucke/e4Coin | 021006dd187d56613e54548c94ab6f2b6cdc6af2 | 7611ef00501c1c05969392a11c22860de697184c | refs/heads/master | 2022-01-19T06:24:17.093636 | 2019-07-09T02:21:16 | 2019-07-09T02:21:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,502 | h | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2015 The dash Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef E4COIN_COINS_H
#define E4COIN_COINS_H
#include "compressor.h"
#include "core_memusage.h"
#include "hash.h"
#include "memusage.h"
#include "serialize.h"
#include "uint256.h"
#include <assert.h>
#include <stdint.h>
#include <unordered_map>
/**
* A UTXO entry.
*
* Serialized format:
* - VARINT((coinbase ? 1 : 0) | (height << 1))
* - the non-spent CTxOut (via CTxOutCompressor)
*/
class Coin
{
public:
//! unspent transaction output
CTxOut out;
//! whether containing transaction was a coinbase
unsigned int fCoinBase : 1;
//! at which height this containing transaction was included in the active block chain
uint32_t nHeight : 31;
//! construct a Coin from a CTxOut and height/coinbase information.
Coin(CTxOut&& outIn, int nHeightIn, bool fCoinBaseIn) : out(std::move(outIn)), fCoinBase(fCoinBaseIn), nHeight(nHeightIn) {}
Coin(const CTxOut& outIn, int nHeightIn, bool fCoinBaseIn) : out(outIn), fCoinBase(fCoinBaseIn),nHeight(nHeightIn) {}
void Clear() {
out.SetNull();
fCoinBase = false;
nHeight = 0;
}
//! empty constructor
Coin() : fCoinBase(false), nHeight(0) { }
bool IsCoinBase() const {
return fCoinBase;
}
template<typename Stream>
void Serialize(Stream &s) const {
assert(!IsSpent());
uint32_t code = nHeight * 2 + fCoinBase;
::Serialize(s, VARINT(code));
::Serialize(s, CTxOutCompressor(REF(out)));
}
template<typename Stream>
void Unserialize(Stream &s) {
uint32_t code = 0;
::Unserialize(s, VARINT(code));
nHeight = code >> 1;
fCoinBase = code & 1;
::Unserialize(s, REF(CTxOutCompressor(out)));
}
bool IsSpent() const {
return out.IsNull();
}
size_t DynamicMemoryUsage() const {
return memusage::DynamicUsage(out.scriptPubKey);
}
};
class SaltedOutpointHasher
{
private:
/** Salt */
const uint64_t k0, k1;
public:
SaltedOutpointHasher();
/**
* This *must* return size_t. With Boost 1.46 on 32-bit systems the
* unordered_map will behave unpredictably if the custom hasher returns a
* uint64_t, resulting in failures when syncing the chain (#4634).
*/
size_t operator()(const COutPoint& id) const {
return SipHashUint256Extra(k0, k1, id.hash, id.n);
}
};
struct CCoinsCacheEntry
{
Coin coin; // The actual cached data.
unsigned char flags;
enum Flags {
DIRTY = (1 << 0), // This cache entry is potentially different from the version in the parent view.
FRESH = (1 << 1), // The parent view does not have this entry (or it is pruned).
/* Note that FRESH is a performance optimization with which we can
* erase coins that are fully spent if we know we do not need to
* flush the changes to the parent cache. It is always safe to
* not mark FRESH if that condition is not guaranteed.
*/
};
CCoinsCacheEntry() : flags(0) {}
explicit CCoinsCacheEntry(Coin&& coin_) : coin(std::move(coin_)), flags(0) {}
};
typedef std::unordered_map<COutPoint, CCoinsCacheEntry, SaltedOutpointHasher> CCoinsMap;
/** Cursor for iterating over CoinsView state */
class CCoinsViewCursor
{
public:
CCoinsViewCursor(const uint256 &hashBlockIn): hashBlock(hashBlockIn) {}
virtual ~CCoinsViewCursor() {}
virtual bool GetKey(COutPoint &key) const = 0;
virtual bool GetValue(Coin &coin) const = 0;
/* Don't care about GetKeySize here */
virtual unsigned int GetValueSize() const = 0;
virtual bool Valid() const = 0;
virtual void Next() = 0;
//! Get best block at the time this cursor was created
const uint256 &GetBestBlock() const { return hashBlock; }
private:
uint256 hashBlock;
};
/** Abstract view on the open txout dataset. */
class CCoinsView
{
public:
/** Retrieve the Coin (unspent transaction output) for a given outpoint.
* Returns true only when an unspent coin was found, which is returned in coin.
* When false is returned, coin's value is unspecified.
*/
virtual bool GetCoin(const COutPoint &outpoint, Coin &coin) const;
//! Just check whether a given outpoint is unspent.
virtual bool HaveCoin(const COutPoint &outpoint) const;
//! Retrieve the block hash whose state this CCoinsView currently represents
virtual uint256 GetBestBlock() const;
//! Do a bulk modification (multiple Coin changes + BestBlock change).
//! The passed mapCoins can be modified.
virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
//! Get a cursor to iterate over the whole state
virtual CCoinsViewCursor *Cursor() const;
//! As we use CCoinsViews polymorphically, have a virtual destructor
virtual ~CCoinsView() {}
//! Estimate database size (0 if not implemented)
virtual size_t EstimateSize() const { return 0; }
};
/** CCoinsView backed by another CCoinsView */
class CCoinsViewBacked : public CCoinsView
{
protected:
CCoinsView *base;
public:
CCoinsViewBacked(CCoinsView *viewIn);
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
bool HaveCoin(const COutPoint &outpoint) const override;
uint256 GetBestBlock() const override;
void SetBackend(CCoinsView &viewIn);
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override;
CCoinsViewCursor *Cursor() const override;
size_t EstimateSize() const override;
};
/** CCoinsView that adds a memory cache for transactions to another CCoinsView */
class CCoinsViewCache : public CCoinsViewBacked
{
protected:
/**
* Make mutable so that we can "fill the cache" even from Get-methods
* declared as "const".
*/
mutable uint256 hashBlock;
mutable CCoinsMap cacheCoins;
/* Cached dynamic memory usage for the inner Coin objects. */
mutable size_t cachedCoinsUsage;
public:
CCoinsViewCache(CCoinsView *baseIn);
// Standard CCoinsView methods
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
bool HaveCoin(const COutPoint &outpoint) const override;
uint256 GetBestBlock() const override;
void SetBestBlock(const uint256 &hashBlock);
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override;
CCoinsViewCursor* Cursor() const override {
throw std::logic_error("CCoinsViewCache cursor iteration not supported.");
}
/**
* Check if we have the given utxo already loaded in this cache.
* The semantics are the same as HaveCoin(), but no calls to
* the backing CCoinsView are made.
*/
bool HaveCoinInCache(const COutPoint &outpoint) const;
/**
* Return a reference to Coin in the cache, or a pruned one if not found. This is
* more efficient than GetCoin.
*
* Generally, do not hold the reference returned for more than a short scope.
* While the current implementation allows for modifications to the contents
* of the cache while holding the reference, this behavior should not be relied
* on! To be safe, best to not hold the returned reference through any other
* calls to this cache.
*/
const Coin& AccessCoin(const COutPoint &output) const;
/**
* Add a coin. Set potential_overwrite to true if a non-pruned version may
* already exist.
*/
void AddCoin(const COutPoint& outpoint, Coin&& coin, bool potential_overwrite);
/**
* Spend a coin. Pass moveto in order to get the deleted data.
* If no unspent output exists for the passed outpoint, this call
* has no effect.
*/
bool SpendCoin(const COutPoint &outpoint, Coin* moveto = nullptr);
/**
* Push the modifications applied to this cache to its base.
* Failure to call this method before destruction will cause the changes to be forgotten.
* If false is returned, the state of this cache (and its backing view) will be undefined.
*/
bool Flush();
/**
* Removes the UTXO with the given outpoint from the cache, if it is
* not modified.
*/
void Uncache(const COutPoint &outpoint);
//! Calculate the size of the cache (in number of transaction outputs)
unsigned int GetCacheSize() const;
//! Calculate the size of the cache (in bytes)
size_t DynamicMemoryUsage() const;
/**
* Amount of e4coin coming in to a transaction
* Note that lightweight clients may not know anything besides the hash of previous transactions,
* so may not be able to calculate this.
*
* @param[in] tx transaction for which we are checking input total
* @return Sum of value of all inputs (scriptSigs)
*/
CAmount GetValueIn(const CTransaction& tx) const;
//! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const;
/**
* Return priority of tx at height nHeight. Also calculate the sum of the values of the inputs
* that are already in the chain. These are the inputs that will age and increase priority as
* new blocks are added to the chain.
*/
double GetPriority(const CTransaction &tx, int nHeight, CAmount &inChainInputValue) const;
private:
CCoinsMap::iterator FetchCoin(const COutPoint &outpoint) const;
/**
* By making the copy constructor private, we prevent accidentally using it when one intends to create a cache on top of a base cache.
*/
CCoinsViewCache(const CCoinsViewCache &);
};
//! Utility function to add all of a transaction's outputs to a cache.
// It assumes that overwrites are only possible for coinbase transactions,
// TODO: pass in a boolean to limit these possible overwrites to known
// (pre-BIP34) cases.
void AddCoins(CCoinsViewCache& cache, const CTransaction& tx, int nHeight);
//! Utility function to find any unspent output with a given txid.
// This function can be quite expensive because in the event of a transaction
// which is not found in the cache, it can cause up to MAX_OUTPUTS_PER_BLOCK
// lookups to database, so it should be used with care.
const Coin& AccessByTxid(const CCoinsViewCache& cache, const uint256& txid);
#endif // E4COIN_COINS_H
| [
"lordark@gmail.com"
] | lordark@gmail.com |
99314b326fb5a3a5a9dbd5e2760cf3b222d3c56d | 0767a430674cbcebc2cd45f61c17a280500c049c | /DBFile.h | 6dcaa17f3505abe1516e488e2bd1a8669778d126 | [] | no_license | ishmnnit/DatabaseImplementation | 3627b31849c2fcad58cb867d35b837a66a373e5a | a774e477f14abf9dbefc410229cb4cdf322c76b4 | refs/heads/master | 2020-05-21T00:16:17.577917 | 2014-08-09T22:31:06 | 2014-08-09T22:31:06 | 22,795,932 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,257 | h | #ifndef DBFILE_H
#define DBFILE_H
#include "TwoWayList.h"
#include "Record.h"
#include "Schema.h"
#include "File.h"
#include "Comparison.h"
#include "ComparisonEngine.h"
#include <iostream>
#include <fstream>
#include <cstring>
typedef enum {heap, sorted, tree} fType;
struct SortInfo {
OrderMaker *myOrder;
int run_length;
} ;
class GenericDBFile;
class DBFile {
public:
struct SortInfo *sort_info;
GenericDBFile *db_file_ob;
ifstream input_meta;
ofstream output_meta;
int Create (char *fpath, fType file_type, void *startup);
int Open (char *fpath);
int Close ();
void Load (Schema &myschema, char *loadpath);
void MoveFirst ();
void Add (Record &addme);
int GetNext (Record &fetchme);
int GetNext (Record &fetchme, CNF &cnf, Record &literal);
};
class GenericDBFile
{
public:
ifstream input_meta;
ofstream output_meta;
virtual int Create (char *fpath, fType file_type, void *startup)=0;
virtual int Open (char *fpath)=0;
virtual int Close ()=0;
virtual void Load (Schema &myschema, char *loadpath)=0;
virtual void MoveFirst ()=0;
virtual void Add (Record &addme)=0;
virtual int GetNext (Record &fetchme)=0;
virtual int GetNext (Record &fetchme, CNF &cnf, Record &literal)=0;
};
#endif
| [
"ish.mnnit@gmail.com"
] | ish.mnnit@gmail.com |
6050f8a3de2fd21ebfbd7d3879ebe947665f48c8 | 8ee46a2c0cb08f7110a1f68bce89ff4753c34b81 | /CS3A/CH13/Linked_List/Linked_List/linkedlist (Flash's conflicted copy 2013-04-03).cpp | df4841b3be731dec162aa3e147dcdc34b90c8dc6 | [] | no_license | jonathanpchan/SchoolWork | c885180b8e8635703d239e8a5279adf23ca2820a | fbabeead11c365bab08affa5cbfa173d16040171 | refs/heads/master | 2020-05-30T16:51:00.111330 | 2013-04-29T05:52:37 | 2013-04-29T05:52:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,284 | cpp | #include "linkedlist.h"
#include "node.h"
#include <cstdlib>
#include <iostream>
using namespace std;
/*
DEFAULT CONSTRUCTOR
*/
LinkedList::LinkedList()
{
head = NULL;
cursor = NULL;
rear = NULL;
sorted = false;
}
/*******************
Copy CONSTRUCTOR
*******************/
LinkedList::LinkedList(const LinkedList& a)
{
try
{
Node* walker = a.head;
sorted = a.sorted;
DestroyAllNodes();
while(walker!=NULL)
{
Node* newNode = new Node(*walker);
Append(newNode);
walker = walker->next;
}
cursor = head;
}
catch(std::bad_alloc&)
{
cout<<"Failed to allocate memory."<<endl;
}
}
/*******************
Destructor
*******************/
LinkedList::~LinkedList()
{
delete head;
}
/*******************
Name: InsertAfter
Arguments: two nodes
Returns nothing, void function
Description inserts a node after a given node
Notes: pretty simple.
*******************/
void LinkedList::InsertAfter(Node *insertThis, Node *afterThis)
{
const char ch = 'z';
try
{
if(sorted)
throw true;
if(insertThis == NULL)
throw -1;
if(afterThis == NULL)
throw ch;
insertThis->next = afterThis->next;
afterThis->next = insertThis;
cursor = insertThis;
}
catch(int e)
{
cout<<"CAUTION! First parameter is NULL!"<<endl;
}
catch(char z)
{
cout<<"CAUTION! Second parameter is NULL!"<<endl;
}
catch(bool b)
{
cout<<"Sorry bob. This is not the function you are looking for."<<endl;
}
}
/*******************
Name: InsertBefore
Arguments: two nodes
Returns nothing, void function
Description: inserts before a given node
Notes: pretty simple, uses insertAfter and a previous function
*******************/
void LinkedList::InsertBefore(Node *insertThis, Node *beforeThis)
{
const char ch = 'z';
try
{
if(sorted)
throw true;
if(insertThis == NULL)
throw -1;
if(beforeThis == NULL)
throw ch;
if(*head == *beforeThis)
InsertHead(insertThis);
else
{
Node *afterThis = Previous(beforeThis);
InsertAfter(insertThis,afterThis);
}
}
catch(int e)
{
cout<<"CAUTION! First parameter is NULL!"<<endl;
}
catch(char z)
{
cout<<"CAUTION! Second parameter is NULL!"<<endl;
}
catch(bool b)
{
cout<<"Sorry bob. This is not the function you are looking for."<<endl;
}
}
/*******************
Name: Search
Arguments: a single node
Returns returns a pointer to the node if found, otherwise null
Description: inserts before a given node
Notes: pretty simple, uses insertAfter and a previous function
*******************/
Node* LinkedList::Search(Node *findThis)
{
Node* walker = head;
walker = head;
if(head==NULL)
return NULL;
if(findThis == head)
return head;
while(*findThis != *walker && walker->next!=NULL)
walker = walker->next;
if(*findThis != *walker && walker->next==NULL)
return NULL;
cursor = walker;
return walker;
}
/*******************
Name: Previous
Arguments: zero argument previous
Returns previous to cursor
Description: returns previous to the cursor
Notes: uses previous function
*******************/
Node *LinkedList::Previous()
{
return (cursor = Previous(cursor));
}
/*******************
Name: Previous
Arguments: two nodes
Returns a pointer to the previous node to the given node
Description: returns previous to a given node
Notes: not too difficult
*******************/
Node* LinkedList::Previous(Node *findThis)
{
bool flag = false;
Node *walker = head, *prevNode;
if(findThis == head)
return head;
while(walker != findThis && walker->next!=NULL)
{
prevNode = walker;
walker = walker->next;
flag = true;
}
prevNode = flag!=true?NULL:prevNode;
cursor = prevNode;
return prevNode;
}
/*******************
Name: Remove
Arguments: a node
Returns a copy to the given node
Description: removes a given node
Notes: not too bad
*******************/
Node* LinkedList::Remove(Node *removeThis)
{
try
{
if(removeThis == NULL)
throw -1;
Node* before, *removed;
if(removeThis==head)
{
removed = head;
head=removeThis->next;
cursor = head;
removed->next = NULL;
}
else
{
before = Previous(removeThis);
removed = Search(removeThis);
before->next = removed->next;
removed->next = NULL;
cursor = before->next;
if(cursor == NULL)
cursor = before;
}
return removed;
}
catch(int e)
{
cout<<"CAUTION! Number is NULL!"<<endl;
return NULL;
}
}
/*******************
Name: Remove
Arguments: none
Returns a copy to the removed node
Description: removes the cursor
Notes: not too bad
*******************/
Node *LinkedList::Remove()
{
return Remove(cursor);
}
/*******************
Name: Getnode
Arguments: none
Returns returns the cursor
Description: returns the curspr
Notes: not too bad,uses insert sroted
*******************/
Node *LinkedList::GetNode()
{
return cursor;
}
/*******************
Name: Sort
Arguments: none
Returns none void function
Description: Sorts the list
Notes: not too bad
*******************/
void LinkedList::Sort()
{
try
{
LinkedList newList;
Node* walker = head;
sorted = true;
while(walker!=NULL)
{
Node* newNode = new Node(*walker);
newList.InsertSorted(newNode);
walker = walker->next;
}
head = newList.head;
newList.head = NULL;
rear = newList.rear;
newList.rear = NULL;
cursor = newList.cursor;
newList.cursor = NULL;
}
catch(std::bad_alloc&)
{
cout<<"Failed to allocate memory."<<endl;
}
}
/*******************
Name: Append
Arguments: a node
Returns none void function
Description: appends a node to the end of the list
Notes: not too bad
*******************/
void LinkedList::Append(Node *insertThis)
{
try
{
if(sorted)
throw true;
if(insertThis == NULL)
throw -1;
if(head == NULL)
InsertHead(insertThis);
else
{
Node* walker = head;
while (walker!=NULL)
{
cursor = walker;
walker = walker->next;
}
cursor->next = insertThis;
insertThis = cursor;
cursor = insertThis->next;
}
}
catch(int e)
{
cout<<"CAUTION! Number is NULL!"<<endl;
}
catch(bool b)
{
cout<<"Sorry bob. This is not the function you are looking for."<<endl;
}
}
/*******************
Name: InsertHead
Arguments: a node
Returns none, void function
Description: Inserts a new head.
Notes: not too bad
*******************/
void LinkedList::InsertHead(Node *insertThis)
{
try
{
if(sorted)
throw true;
if(insertThis == NULL)
throw -1;
insertThis->next = head;
head=cursor=insertThis;
}
catch(int e)
{
cout<<"CAUTION! Number is NULL!"<<endl;
}
catch(bool b)
{
cout<<"Sorry bob. This is not the function you are looking for."<<endl;
}
}
/*******************
Name: InsertSorted
Arguments: a node
Returns none, void function
Description: once list is sorted, inserts into the list
Notes: not too bad
*******************/
void LinkedList::InsertSorted(Node *insertThis)
{
try
{
// if(!sorted)
// throw false;
if(insertThis == NULL)
throw -1;
if(head==NULL)
InsertHead(insertThis);
else
{
Node* here = Search(insertThis);
if(here == NULL)
{
Node* walker = head;
cursor = head;
while(*insertThis <= *walker && walker->next != NULL)
{
walker = walker->next;
cursor = walker;
}
if(*insertThis <= *cursor)
{ sorted = false;
InsertAfter(insertThis,cursor);
sorted = true;
}
else
{
sorted = false;
InsertBefore(insertThis,cursor);
sorted=true;
}
}
else
{
sorted = false;
InsertAfter(insertThis,here);
sorted = true;
}
}
}
catch(int e)
{
cout<<"CAUTION! Number is NULL!"<<endl;
}
catch(bool b)
{
cout<<"Please sort first."<<endl;
}
}
/*******************
Name: DestroyAllNodes
Arguments: none
Returns none
Description: destroys all nodes sets them to Null
Notes: not too bad
*******************/
void LinkedList::DestroyAllNodes()
{
delete head;
head = NULL;
cursor = NULL;
rear = NULL;
sorted = false;
}
/*******************
Name: Assignment operator
Arguments: const linked list
Returns a linked list copy
Description: copies a list
Notes: not too bad
*******************/
LinkedList& LinkedList::operator =(const LinkedList &a)
{
try
{
Node* walker = a.head;
sorted = a.sorted;
if(a.head == NULL)
{
DestroyAllNodes();
return *this;
}
if(a.head == head)
return *this;
else
{
DestroyAllNodes();
while(walker!=NULL)
{
Node* newNode = new Node(*walker);
Append(newNode);
walker = walker->next;
}
cursor = head;
}
return *this;
}
catch(std::bad_alloc&)
{
cout<<"Failed to allocate memory."<<endl;
exit(1);
}
}
/*******************
Name: <<
Arguments: linked list
Returns ostream
Description: outputs a linked list
Notes: not too bad
*******************/
ostream& operator <<(ostream& out, LinkedList& A)
{
Node *walker = A.head;
while(walker != NULL)
{
if (walker == A.cursor)
cout<<"[";
out << *walker;
if (walker == A.cursor)
cout<<"]";
walker = walker->next;
cout << " --> ";
}
out << " NULL" << endl;
return out;
}
/*******************
Name: next
Arguments: none
Returns returns a copy to the next node
Description: moves cursor to the next node.
Notes: not too bad
*******************/
Node *LinkedList::Next()
{
return cursor->next!=NULL?cursor = cursor->next:cursor;
//return (cursor = cursor->next);
}
| [
"jonathanpchan@gmail.com"
] | jonathanpchan@gmail.com |
7ea72a8a5fe38ca197e94801f12d11e3531560b0 | 2d8bf29b4e90dbcc582cafbd9b90656cff9792b9 | /237. Delete Node in a Linked List.cpp | 6f34dd7bd7f4db6e4402dc15042a7b6d3ce66299 | [] | no_license | WestLakeBao/Luyaos-LeetCode-Sols-in-Cpp | b614a21b3dbea9d132ead023457a85113a21ab91 | 654f57c1ad7b7df01904f2a44864d456779c9f00 | refs/heads/master | 2022-08-06T21:11:57.871246 | 2020-05-21T23:12:59 | 2020-05-21T23:12:59 | 261,599,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 538 | cpp | struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {}
};
class Solution {
public:
void deleteNode(ListNode* node) {
ListNode* temp=node->next;
node->next = temp->next;
node->val = temp->val;
}
};
int main237(){
ListNode* head = new ListNode(4);
ListNode* head2 = new ListNode(5);
ListNode* head3 = new ListNode(1);
ListNode* head4 = new ListNode(9);
head->next=head2;
head2->next=head3;
head3->next=head4;
Solution solution;
} | [
"chenluyao1020@gmail.com"
] | chenluyao1020@gmail.com |
a82ee6d3f47de0fc369dd74a3e3ee77f03cfab81 | 407b689baa1a6ec758d9170fe4b0d50e16fc1d71 | /ogr/ogrsf_frmts/openfilegdb/filegdbtable_freelist.cpp | b77a98590b8af6e28eff5ea0825b645fe8797e4e | [
"LicenseRef-scancode-warranty-disclaimer",
"SunPro",
"LicenseRef-scancode-info-zip-2005-02",
"BSD-3-Clause",
"MIT",
"ISC",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | DLR-TS/gdal | edb6a9485b4b4a45900182b6888fe566ca7b4c7f | 1c52709d923e8529356aca55205def6d4fc7fc21 | refs/heads/ogr/xodr | 2023-07-06T09:22:19.018806 | 2022-07-07T16:44:48 | 2022-07-07T16:44:48 | 89,003,817 | 16 | 7 | NOASSERTION | 2023-09-04T18:31:58 | 2017-04-21T16:32:09 | C++ | UTF-8 | C++ | false | false | 25,879 | cpp | /******************************************************************************
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Implements management of FileGDB .freelist
* Author: Even Rouault, <even dot rouault at spatialys.com>
*
******************************************************************************
* Copyright (c) 2022, Even Rouault <even dot rouault at spatialys.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "cpl_port.h"
#include "filegdbtable.h"
#include "filegdbtable_priv.h"
#include <algorithm>
#include <limits>
#include <set>
#include "cpl_string.h"
namespace OpenFileGDB
{
constexpr uint32_t MINUS_ONE = 0xFFFFFFFFU;
constexpr int MINIMUM_SIZE_FOR_FREELIST = 8;
constexpr int nTrailerSize = 344;
constexpr int nTrailerEntrySize = 2 * static_cast<int>(sizeof(uint32_t));
constexpr int nPageSize = 4096;
constexpr int nPageHeaderSize = 2 * static_cast<int>(sizeof(uint32_t));
/************************************************************************/
/* FindFreelistRangeSlot() */
/************************************************************************/
// Fibonacci suite
static const uint32_t anHoleSizes[] = {
0,
8,
16,
24,
40,
64,
104,
168,
272,
440,
712,
1152,
1864,
3016,
4880,
7896,
12776,
20672,
33448,
54120,
87568,
141688,
229256,
370944,
600200,
971144,
1571344,
2542488,
4113832,
6656320,
10770152,
17426472,
28196624,
45623096,
73819720,
119442816,
193262536,
312705352,
505967888,
818673240,
1324641128,
2143314368,
3467955496U
};
static int FindFreelistRangeSlot(uint32_t nSize)
{
for( size_t i = 0; i < CPL_ARRAYSIZE(anHoleSizes) - 1; i++ )
{
if( /* nSize >= anHoleSizes[i] && */ nSize < anHoleSizes[i+1] )
{
return static_cast<int>(i);
}
}
CPLDebug("OpenFileGDB", "Hole larger than can be handled");
return -1;
}
/************************************************************************/
/* AddEntryToFreelist() */
/************************************************************************/
void FileGDBTable::AddEntryToFreelist(uint64_t nOffset, uint32_t nSize)
{
if( nSize < MINIMUM_SIZE_FOR_FREELIST )
return;
const std::string osFilename = CPLResetExtension(m_osFilename.c_str(),
"freelist");
VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb+");
if( fp == nullptr )
{
// Initialize an empty .freelist file
fp = VSIFOpenL(osFilename.c_str(), "wb+");
if( fp == nullptr )
return;
std::vector<GByte> abyTrailer;
WriteUInt32(abyTrailer, 1);
WriteUInt32(abyTrailer, MINUS_ONE);
for( int i = 0; i < (nTrailerSize - nTrailerEntrySize) / nTrailerEntrySize; i++ )
{
WriteUInt32(abyTrailer, MINUS_ONE);
WriteUInt32(abyTrailer, 0);
}
CPLAssert( static_cast<int>(abyTrailer.size()) == nTrailerSize );
if( VSIFWriteL( abyTrailer.data(), abyTrailer.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return;
}
}
m_nHasFreeList = true;
// Read trailer
VSIFSeekL(fp, 0, SEEK_END);
auto nFileSize = VSIFTellL(fp);
if( (nFileSize % nPageSize) != nTrailerSize )
{
VSIFCloseL(fp);
return;
}
VSIFSeekL(fp, nFileSize - nTrailerSize, SEEK_SET);
std::vector<GByte> abyTrailer(nTrailerSize);
if( VSIFReadL(abyTrailer.data(), abyTrailer.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return;
}
// Determine in which "slot" of hole size the new entry belongs to
const int iSlot = FindFreelistRangeSlot(nSize);
if( iSlot < 0 )
{
VSIFCloseL(fp);
return;
}
// Read the last page index of the identified slot
uint32_t nPageIdx = GetUInt32(abyTrailer.data() + nTrailerEntrySize * iSlot, 0);
uint32_t nPageCount;
std::vector<GByte> abyPage;
bool bRewriteTrailer = false;
const int nEntrySize = static_cast<int>(sizeof(uint32_t)) + m_nTablxOffsetSize;
const int nMaxEntriesPerPage = (nPageSize - nPageHeaderSize) / nEntrySize;
int nNumEntries = 0;
if( nPageIdx == MINUS_ONE )
{
// There's no allocate page for that range
// So allocate one.
WriteUInt32(abyPage, nNumEntries);
WriteUInt32(abyPage, MINUS_ONE);
abyPage.resize(nPageSize);
// Update trailer
bRewriteTrailer = true;
nPageIdx = static_cast<uint32_t>((nFileSize - nTrailerSize) / nPageSize);
nPageCount = 1;
nFileSize += nPageSize; // virtual extension
}
else
{
nPageCount = GetUInt32(abyTrailer.data() + nTrailerEntrySize * iSlot +
sizeof(uint32_t), 0);
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
abyPage.resize(nPageSize);
if( VSIFReadL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return;
}
nNumEntries = GetUInt32(abyPage.data(), 0);
if( nNumEntries >= nMaxEntriesPerPage )
{
// Allocate new page
abyPage.clear();
nNumEntries = 0;
WriteUInt32(abyPage, nNumEntries);
WriteUInt32(abyPage, nPageIdx); // Link to previous page
abyPage.resize(nPageSize);
// Update trailer
bRewriteTrailer = true;
nPageIdx = static_cast<uint32_t>((nFileSize - nTrailerSize) / nPageSize);
nPageCount ++;
nFileSize += nPageSize; // virtual extension
}
}
// Add new entry into page
WriteUInt32(abyPage, nSize, nPageHeaderSize + nNumEntries * nEntrySize);
WriteFeatureOffset(
nOffset,
abyPage.data() + nPageHeaderSize + nNumEntries * nEntrySize + sizeof(uint32_t));
// Update page header
++ nNumEntries;
WriteUInt32(abyPage, nNumEntries, 0);
// Flush page
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
if( VSIFWriteL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return;
}
if( bRewriteTrailer )
{
WriteUInt32(abyTrailer, nPageIdx, nTrailerEntrySize * iSlot);
WriteUInt32(abyTrailer, nPageCount, nTrailerEntrySize * iSlot + sizeof(uint32_t));
VSIFSeekL(fp, nFileSize - nTrailerSize, 0);
if( VSIFWriteL(abyTrailer.data(), abyTrailer.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return;
}
}
m_bFreelistCanBeDeleted = false;
VSIFCloseL(fp);
}
/************************************************************************/
/* GetOffsetOfFreeAreaFromFreeList() */
/************************************************************************/
uint64_t FileGDBTable::GetOffsetOfFreeAreaFromFreeList(uint32_t nSize)
{
if( nSize < MINIMUM_SIZE_FOR_FREELIST || m_nHasFreeList == FALSE || m_bFreelistCanBeDeleted )
return OFFSET_MINUS_ONE;
const std::string osFilename = CPLResetExtension(m_osFilename.c_str(),
"freelist");
VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb+");
m_nHasFreeList = fp != nullptr;
if( fp == nullptr )
return OFFSET_MINUS_ONE;
// Read trailer
VSIFSeekL(fp, 0, SEEK_END);
auto nFileSize = VSIFTellL(fp);
if( (nFileSize % nPageSize) != nTrailerSize )
{
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
VSIFSeekL(fp, nFileSize - nTrailerSize, SEEK_SET);
std::vector<GByte> abyTrailer(nTrailerSize);
if( VSIFReadL(abyTrailer.data(), abyTrailer.size(), 1, fp ) != 1 )
{
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
// Determine in which "slot" of hole size the new entry belongs to
const int iSlot = FindFreelistRangeSlot(nSize);
if( iSlot < 0 )
{
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
// Read the last page index of the identified slot
uint32_t nPageIdx = GetUInt32(abyTrailer.data() + nTrailerEntrySize * iSlot, 0);
if( nPageIdx == MINUS_ONE )
{
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
std::vector<GByte> abyPage(nPageSize);
if( VSIFReadL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
CPLDebug("OpenFileGDB", "Can't read freelist page %u", nPageIdx);
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
const int nEntrySize = static_cast<int>(sizeof(uint32_t)) + m_nTablxOffsetSize;
const int nMaxEntriesPerPage = (nPageSize - nPageHeaderSize) / nEntrySize;
// Index of page that links to us
uint32_t nReferencingPage = MINUS_ONE;
std::vector<GByte> abyReferencingPage;
int nBestCandidateNumEntries = 0;
uint32_t nBestCandidatePageIdx = MINUS_ONE;
uint32_t nBestCandidateSize = std::numeric_limits<uint32_t>::max();
int iBestCandidateEntry = -1;
uint32_t nBestCandidateReferencingPage = MINUS_ONE;
std::vector<GByte> abyBestCandidateReferencingPage;
std::vector<GByte> abyBestCandidatePage;
std::set<uint32_t> aSetReadPages = { nPageIdx };
while( true )
{
int nNumEntries = static_cast<int>(
std::min(GetUInt32(abyPage.data(), 0),
static_cast<uint32_t>(nMaxEntriesPerPage)));
bool bExactMatch = false;
for( int i = nNumEntries - 1; i >= 0; i-- )
{
const uint32_t nFreeAreaSize = GetUInt32(
abyPage.data() + nPageHeaderSize + i * nEntrySize, 0);
if( nFreeAreaSize < anHoleSizes[iSlot] ||
nFreeAreaSize >= anHoleSizes[iSlot+1] )
{
CPLError(CE_Warning, CPLE_AppDefined,
"Page %u of %s contains free area of unexpected size at entry %d",
nPageIdx, osFilename.c_str(), i);
}
else if( nFreeAreaSize == nSize ||
(nFreeAreaSize > nSize && nFreeAreaSize < nBestCandidateSize) )
{
if( nBestCandidatePageIdx != nPageIdx )
{
abyBestCandidatePage = abyPage;
abyBestCandidateReferencingPage = abyReferencingPage;
}
nBestCandidatePageIdx = nPageIdx;
nBestCandidateReferencingPage = nReferencingPage;
iBestCandidateEntry = i;
nBestCandidateSize = nFreeAreaSize;
nBestCandidateNumEntries = nNumEntries;
if( nFreeAreaSize == nSize )
{
bExactMatch = true;
break;
}
}
}
if( !bExactMatch )
{
const uint32_t nPrevPage = GetUInt32(abyPage.data() + sizeof(uint32_t), 0);
if( nPrevPage == MINUS_ONE )
{
break;
}
if( aSetReadPages.find(nPrevPage) != aSetReadPages.end() )
{
CPLError(CE_Warning, CPLE_AppDefined,
"Cyclic page refererencing in %s",
osFilename.c_str());
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
aSetReadPages.insert(nPrevPage);
abyReferencingPage = abyPage;
nReferencingPage = nPageIdx;
nPageIdx = nPrevPage;
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
if( VSIFReadL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
CPLDebug("OpenFileGDB", "Can't read freelist page %u", nPageIdx);
break;
}
}
else
{
break;
}
}
if( nBestCandidatePageIdx == MINUS_ONE )
{
// If we go here, it means that the trailer section references empty
// pages or pages with features of unexpected size.
// Shouldn't happen for well-behaved .freelist files
VSIFCloseL(fp);
return OFFSET_MINUS_ONE;
}
nPageIdx = nBestCandidatePageIdx;
nReferencingPage = nBestCandidateReferencingPage;
abyPage = std::move(abyBestCandidatePage);
abyReferencingPage = std::move(abyBestCandidateReferencingPage);
uint64_t nCandidateOffset = ReadFeatureOffset(
abyPage.data() + nPageHeaderSize + iBestCandidateEntry * nEntrySize + sizeof(uint32_t));
// Remove entry from page
if( iBestCandidateEntry < nBestCandidateNumEntries - 1 )
{
memmove(abyPage.data() + nPageHeaderSize + iBestCandidateEntry * nEntrySize,
abyPage.data() + nPageHeaderSize + (iBestCandidateEntry + 1) * nEntrySize,
(nBestCandidateNumEntries - 1 - iBestCandidateEntry) * nEntrySize);
}
memset(abyPage.data() + nPageHeaderSize + (nBestCandidateNumEntries - 1) * nEntrySize,
0,
nEntrySize);
nBestCandidateNumEntries --;
WriteUInt32(abyPage, nBestCandidateNumEntries, 0);
if( nBestCandidateNumEntries > 0 )
{
// Rewrite updated page
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
CPL_IGNORE_RET_VAL(VSIFWriteL(abyPage.data(), abyPage.size(), 1, fp ));
}
else
{
const uint32_t nPrevPage = GetUInt32(abyPage.data() + sizeof(uint32_t), 0);
// Link this newly free page to the previous one
const uint32_t nLastFreePage = GetUInt32(abyTrailer.data() + sizeof(uint32_t), 0);
WriteUInt32(abyPage, nLastFreePage, sizeof(uint32_t));
// Rewrite updated page
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
CPL_IGNORE_RET_VAL(VSIFWriteL(abyPage.data(), abyPage.size(), 1, fp ));
// Update trailer to add a new free page
WriteUInt32(abyTrailer, nPageIdx, sizeof(uint32_t));
if( nReferencingPage != MINUS_ONE )
{
// Links referencing page to previous page
WriteUInt32(abyReferencingPage, nPrevPage, sizeof(uint32_t));
VSIFSeekL(fp, static_cast<uint64_t>(nReferencingPage) * nPageSize, 0);
CPL_IGNORE_RET_VAL(VSIFWriteL(abyReferencingPage.data(), abyReferencingPage.size(), 1, fp ));
}
else
{
// and make the slot points to the previous page
WriteUInt32(abyTrailer, nPrevPage, nTrailerEntrySize * iSlot);
}
uint32_t nPageCount = GetUInt32(abyTrailer.data() + nTrailerEntrySize * iSlot + sizeof(uint32_t), 0);
if( nPageCount == 0 )
{
CPLDebug("OpenFileGDB", "Wrong page count for %s at slot %d",
osFilename.c_str(), iSlot);
}
else
{
nPageCount --;
WriteUInt32(abyTrailer, nPageCount, nTrailerEntrySize * iSlot + sizeof(uint32_t));
if( nPageCount == 0 )
{
// Check if the freelist no longer contains pages with free slots
m_bFreelistCanBeDeleted = true;
for( int i = 1; i < nTrailerSize / nTrailerEntrySize; i++ )
{
if( GetUInt32(abyTrailer.data() + i * nTrailerEntrySize + sizeof(uint32_t), 0) != 0 )
{
m_bFreelistCanBeDeleted = false;
break;
}
}
}
}
VSIFSeekL(fp, nFileSize - nTrailerSize, 0);
CPL_IGNORE_RET_VAL(VSIFWriteL(abyTrailer.data(), abyTrailer.size(), 1, fp ));
}
// Extra precaution: check that the uint32_t at offset nOffset is a
// negated compatible size
auto nOffset = nCandidateOffset;
VSIFSeekL(m_fpTable, nOffset, 0);
uint32_t nOldSize = 0;
if( !ReadUInt32(m_fpTable, nOldSize) || (nOldSize >> 31) == 0 )
{
nOffset = OFFSET_MINUS_ONE;
}
else
{
nOldSize = static_cast<uint32_t>(-static_cast<int>(nOldSize));
if( nOldSize < nSize - sizeof(uint32_t) )
{
nOffset = OFFSET_MINUS_ONE;
}
}
if( nOffset == OFFSET_MINUS_ONE )
{
CPLDebug("OpenFileGDB", "%s references a free area at offset "
CPL_FRMT_GUIB ", but it does not appear to match a deleted "
"feature",
osFilename.c_str(),
static_cast<GUIntBig>(nCandidateOffset));
}
VSIFCloseL(fp);
return nOffset;
}
/************************************************************************/
/* CheckFreeListConsistency() */
/************************************************************************/
bool FileGDBTable::CheckFreeListConsistency()
{
const std::string osFilename = CPLResetExtension(m_osFilename.c_str(),
"freelist");
VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb");
if( fp == nullptr )
return true;
// Read trailer
VSIFSeekL(fp, 0, SEEK_END);
auto nFileSize = VSIFTellL(fp);
if( (nFileSize % nPageSize) != nTrailerSize )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Bad file size");
VSIFCloseL(fp);
return false;
}
VSIFSeekL(fp, nFileSize - nTrailerSize, SEEK_SET);
std::vector<GByte> abyTrailer(nTrailerSize);
if( VSIFReadL(abyTrailer.data(), abyTrailer.size(), 1, fp ) != 1 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cannot read trailer section");
VSIFCloseL(fp);
return false;
}
if( GetUInt32(abyTrailer.data(), 0) != 1 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Unexpected value for first uint32 of trailer section");
VSIFCloseL(fp);
return false;
}
std::vector<GByte> abyPage(nPageSize);
std::set<uint32_t> setVisitedPages;
// Check free pages
uint32_t nFreePage = GetUInt32(abyTrailer.data() + sizeof(uint32_t), 0);
while( nFreePage != MINUS_ONE )
{
if( setVisitedPages.find(nFreePage) != setVisitedPages.end() )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cyclic page refererencing in free pages");
VSIFCloseL(fp);
return false;
}
VSIFSeekL(fp, static_cast<uint64_t>(nFreePage) * nPageSize, 0);
if( VSIFReadL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Can't read freelist page %u", nFreePage);
VSIFCloseL(fp);
return false;
}
setVisitedPages.insert(nFreePage);
if( GetUInt32(abyPage.data(), 0) != 0 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Unexpected value for first uint32 of free page");
VSIFCloseL(fp);
return false;
}
nFreePage = GetUInt32(abyPage.data() + sizeof(uint32_t), 0);
}
// Check active pages
const int nEntrySize = static_cast<int>(sizeof(uint32_t)) + m_nTablxOffsetSize;
const int nMaxEntriesPerPage = (nPageSize - nPageHeaderSize) / nEntrySize;
std::set<uint64_t> aSetOffsets;
for( int iSlot = 1; iSlot < (nTrailerSize / nTrailerEntrySize); iSlot++ )
{
uint32_t nPageIdx = GetUInt32(abyTrailer.data() + iSlot * nTrailerEntrySize, 0);
uint32_t nActualCount = 0;
while( nPageIdx != MINUS_ONE )
{
if( setVisitedPages.find(nPageIdx) != setVisitedPages.end() )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cyclic page refererencing or page referenced more than once");
VSIFCloseL(fp);
return false;
}
VSIFSeekL(fp, static_cast<uint64_t>(nPageIdx) * nPageSize, 0);
if( VSIFReadL(abyPage.data(), abyPage.size(), 1, fp ) != 1 )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Can't read active page %u", nPageIdx);
VSIFCloseL(fp);
return false;
}
setVisitedPages.insert(nPageIdx);
nActualCount ++;
const uint32_t nEntries = GetUInt32(abyPage.data(), 0);
if( nEntries == 0 || nEntries > static_cast<uint32_t>(nMaxEntriesPerPage) )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Unexpected value for entries count of active page %u: %d",
nPageIdx, nEntries);
VSIFCloseL(fp);
return false;
}
for( uint32_t i = 0; i < nEntries; ++i )
{
const uint32_t nFreeAreaSize = GetUInt32(
abyPage.data() + nPageHeaderSize + i * nEntrySize, 0);
if( nFreeAreaSize < anHoleSizes[iSlot] ||
nFreeAreaSize >= anHoleSizes[iSlot+1] )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Page %u contains free area of unexpected size at entry %u",
nPageIdx, i);
VSIFCloseL(fp);
return false;
}
const uint64_t nOffset = ReadFeatureOffset(
abyPage.data() + nPageHeaderSize + i * nEntrySize + sizeof(uint32_t));
VSIFSeekL(m_fpTable, nOffset, 0);
uint32_t nOldSize = 0;
if( !ReadUInt32(m_fpTable, nOldSize) )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Page %u contains free area that points to invalid offset " CPL_FRMT_GUIB,
nPageIdx, static_cast<GUIntBig>(nOffset));
VSIFCloseL(fp);
return false;
}
if( (nOldSize >> 31) == 0 ||
(nOldSize = static_cast<uint32_t>(-static_cast<int>(nOldSize))) != nFreeAreaSize - sizeof(uint32_t) )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Page %u contains free area that points to dead "
"zone at offset " CPL_FRMT_GUIB " of unexpected size: %u",
nPageIdx, static_cast<GUIntBig>(nOffset), nOldSize);
VSIFCloseL(fp);
return false;
}
if( aSetOffsets.find(nOffset) != aSetOffsets.end() )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Page %u contains free area that points to "
"offset " CPL_FRMT_GUIB " already referenced",
nPageIdx, static_cast<GUIntBig>(nOffset));
VSIFCloseL(fp);
return false;
}
aSetOffsets.insert(nOffset);
}
nPageIdx = GetUInt32(abyPage.data() + sizeof(uint32_t), 0);
}
const uint32_t nPageCount = GetUInt32(
abyTrailer.data() + iSlot * nTrailerEntrySize + sizeof(uint32_t), 0);
if( nPageCount != nActualCount )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Unexpected value for page count of slot %d: %u vs %u",
iSlot, nPageCount, nActualCount);
VSIFCloseL(fp);
return false;
}
}
const auto nExpectedPageCount = (nFileSize - nTrailerSize ) / nPageSize;
if( setVisitedPages.size() != nExpectedPageCount )
{
CPLError(CE_Failure, CPLE_AppDefined,
"%u pages have been visited, but there are %u pages in total",
static_cast<uint32_t>(setVisitedPages.size()),
static_cast<uint32_t>(nExpectedPageCount));
VSIFCloseL(fp);
return false;
}
VSIFCloseL(fp);
return true;
}
/************************************************************************/
/* DeleteFreeList() */
/************************************************************************/
void FileGDBTable::DeleteFreeList()
{
m_bFreelistCanBeDeleted = false;
m_nHasFreeList = -1;
VSIUnlink( CPLResetExtension(m_osFilename.c_str(), "freelist") );
}
} /* namespace OpenFileGDB */
| [
"even.rouault@spatialys.com"
] | even.rouault@spatialys.com |
fccb6d837a8728a5c4129ca8b3b01241c8a1fa5e | 0404a2330b5c89d228a6e4bf811d047b8bb6c2de | /seive_dp/100To105/dynamicProgramming1.cpp | e4c6720b963d8a4e77677a802404a80e79d81ffa | [] | no_license | sridharan-084/Examples | 1edf3eece528b8a0f0a155efa02b87e496d379fc | 839a50fab879d58467c7e21d0402f5832488c2a8 | refs/heads/main | 2023-07-14T01:12:01.114093 | 2021-08-21T06:57:18 | 2021-08-21T06:57:18 | 394,376,630 | 0 | 0 | null | 2021-08-09T17:10:31 | 2021-08-09T17:10:30 | null | UTF-8 | C++ | false | false | 1,132 | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
ost<<"{"<<p.first<<","<<p.second<<"}";
return ost;
}
template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
ost<<"{";
for(int i=0;i<v.size();i++){
if(i)ost<<",";
ost<<v[i];
}
ost<<"}";
return ost;
}
bool ok[111111];
signed main(){
int X;
cin>>X;
ok[0]=true;
//dynamic programming
for(int i=1;i<=X;i++){
for(int j=100;j<=105;j++)
if(i-j>=0)
ok[i] |= ok[i-j];
}
if(ok[X])
cout<<1<<endl;
else
cout<<0<<endl;
return 0;
}
| [
"33067129+mayankdutta@users.noreply.github.com"
] | 33067129+mayankdutta@users.noreply.github.com |
b9ff8d978432f2a32dbd226e43669c7dc1b63052 | 167c215cd584c54d3af4c5947ed6155e0ddf8cda | /main.cpp | de14b5944ca188b97445a902e225c40111c40efb | [] | no_license | yuriymos/LandLord | 7097f7d8d664ee2027d8dcf2e2971cbba9b583d5 | c6af1fccdf1c97a06adac780882457bc647f30d0 | refs/heads/master | 2021-01-19T13:41:34.860505 | 2017-08-20T11:04:22 | 2017-08-20T11:04:22 | 100,855,858 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 201 | cpp | #include <QApplication>
#include "landlord.h"
//////////////////////////////////
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
landlord w;
w.show();
return a.exec();
}
| [
"yuriyvm@mail.ru"
] | yuriyvm@mail.ru |
24bfc0fc90a9a55a758beb96682f73e1e36da2d6 | a674eb5cd9465556c4b6aa85bf8b953ac2e32a65 | /TimeLogger_v4.0/exitdialog.h | 68da7d4e78efc1b4e03679a8d83ba16d843d402b | [] | no_license | petarbdl/petar | 83f188e065bc49021b8776e51f7e016bca3a700c | 0965ae669504b6362ee52d732446d69d62822547 | refs/heads/master | 2020-08-13T18:31:19.900117 | 2020-01-17T12:06:29 | 2020-01-17T12:06:29 | 215,017,009 | 0 | 0 | null | 2019-12-23T17:27:19 | 2019-10-14T10:42:39 | C++ | UTF-8 | C++ | false | false | 518 | h | #ifndef EXITDIALOG_H
#define EXITDIALOG_H
#include <QDialog>
namespace Ui {
class ExitDialog;
}
class ExitDialog : public QDialog
{
Q_OBJECT
public:
explicit ExitDialog(QWidget *parent = nullptr);
~ExitDialog();
void setValues(QString name);
private slots:
void on_buttonLogout_clicked();
void on_buttonQuit_clicked();
signals:
void logoutButtonPressed();
void quitButtonPressed();
private:
Ui::ExitDialog *ui;
};
#endif // EXITDIALOG_H
| [
"noreply@github.com"
] | petarbdl.noreply@github.com |
7eed58f71de06db710ee57f05273185b733afdd2 | e15a40c51c72fa7184889dda2bfa873ab019299c | /Engine_Master/Application.h | 6bd8839e062bfe8b5daa079f71b27d601ae76f92 | [] | no_license | raulgonzalezupc/LittleEngine | 75966bdb0084e1ca8ca14c6181c951e5988cab28 | 6684bb8dcbb3d5ac2963fd059616dc333db46757 | refs/heads/master | 2020-09-03T19:15:11.837328 | 2019-11-04T20:04:04 | 2019-11-04T20:04:04 | 219,543,827 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 665 | h | #pragma once
#include<list>
#include "Globals.h"
#include "Module.h"
class ModuleRender;
class ModuleWindow;
class ModuleTextures;
class ModuleInput;
class ModuleEngine;
class ModuleProgram;
class ModuleTexture;
class ModuleImgui;
class Application
{
public:
Application();
~Application();
bool Init();
update_status Update();
bool CleanUp();
public:
ModuleRender* renderer = nullptr;
ModuleWindow* window = nullptr;
ModuleInput* input = nullptr;
ModuleEngine* engine = nullptr;
ModuleProgram* shaders = nullptr;
ModuleTexture* texture = nullptr;
ModuleImgui* imgui = nullptr;
private:
std::list<Module*> modules;
};
extern Application* App;
| [
"56253770+raulgonzalezupc@users.noreply.github.com"
] | 56253770+raulgonzalezupc@users.noreply.github.com |
ba71ebd6eb7fbf20e28251a368633a4bf1568a72 | a82b8e87f42b9ec67418d3537473b4be90c38a71 | /Src/PID_v1.cpp | 0f467bf6bbd01c7114ae883aa697da84b5d8e2c5 | [
"MIT"
] | permissive | salvato/BuggySTF411 | fe6ebd1b7cbc203dab0e0d7e43ba3a7dfaa8d41d | c99326a09e7ecda6338e2c6d760d43cbb02d14dd | refs/heads/main | 2023-02-08T22:30:06.209278 | 2021-01-03T20:43:52 | 2021-01-03T20:43:52 | 309,169,249 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,894 | cpp | // ************************************************************
// * Arduino PID Library - Version 1.1.1
// * by Brett Beauregard <br3ttb@gmail.com> brettbeauregard.com
// *
// * This Library is licensed under a GPLv3 License
// ************************************************************
#include "PID_v1.h"
// Constructor (...)*********************************************************
// * The parameters specified here are those for for which we can't set up
// * reliable defaults, so we need to have the user set them.
// **************************************************************************
PID::PID(double* Input, double* Output, double* Setpoint,
double Kp, double Ki, double Kd, int POn, int ControllerDirection)
{
myOutput = Output;
myInput = Input;
mySetpoint = Setpoint;
inAuto = false;
PID::SetOutputLimits(-255.0, 255.0);
SampleTime = 100; // Default sample time in ms
PID::SetControllerDirection(ControllerDirection);
PID::SetTunings(Kp, Ki, Kd, POn);
}
// Constructor (...)***********************************************************
// * To allow backwards compatability for v1.1, or for people that just want
// * to use Proportional on Error without explicitly saying so
// ****************************************************************************
PID::PID(double* Input, double* Output, double* Setpoint,
double Kp, double Ki, double Kd, int ControllerDirection)
:PID::PID(Input, Output, Setpoint, Kp, Ki, Kd, P_ON_E, ControllerDirection)
{
}
// Compute() ***********************************************************************
// * This, as they say, is where the magic happens.
// * This function should be called every time "void loop()" executes.
// * Returns true when the output is computed,false when nothing has been done.
// *********************************************************************************
bool
PID::Compute() {
if(!inAuto) return false;
// Compute all the working error variables
double input = *myInput;
double error = *mySetpoint - input;
double dInput = (input - lastInput);
outputSum += (ki*error);
// Add Proportional on Measurement, if P_ON_M is specified
if(!pOnE)
outputSum -= kp*dInput;
if(outputSum > outMax)
outputSum= outMax;
else if(outputSum < outMin)
outputSum= outMin;
// Add Proportional on Error, if P_ON_E is specified
double output;
if(pOnE)
output = kp * error;
else
output = 0;
// Compute Rest of PID Output
output += outputSum - kd*dInput;
if(output > outMax)
output = outMax;
else if(output < outMin)
output = outMin;
*myOutput = output;
// Remember some variables for next time
lastInput = input;
return true;
}
// SetTunings(...)************************************************************
// * This function allows the controller's dynamic performance to be adjusted.
// * it's called automatically from the constructor, but tunings can also
// * be adjusted on the fly during normal operation
// ***************************************************************************
void
PID::SetTunings(double Kp, double Ki, double Kd, int POn) {
if (Kp<0 || Ki<0 || Kd<0) return;
pOn = POn;
pOnE = (POn == P_ON_E);
dispKp = Kp;
dispKi = Ki;
dispKd = Kd;
double SampleTimeInSec = ((double)SampleTime)/1000;
kp = Kp;
ki = Ki * SampleTimeInSec;
kd = Kd / SampleTimeInSec;
if(controllerDirection == REVERSE) {
kp = (0 - kp);
ki = (0 - ki);
kd = (0 - kd);
}
}
// SetTunings(...)**********************************
// * Set Tunings using the last-rembered POn setting
// *************************************************
void
PID::SetTunings(double Kp, double Ki, double Kd) {
SetTunings(Kp, Ki, Kd, pOn);
}
// SetSampleTime(...) ******************************************************
// * sets the period, in Milliseconds, at which the calculation is performed
// *************************************************************************
void
PID::SetSampleTime(int NewSampleTime) {
if(NewSampleTime > 0) {
double ratio = (double)NewSampleTime / (double)SampleTime;
ki *= ratio;
kd /= ratio;
SampleTime = (unsigned long)NewSampleTime;
}
}
// SetOutputLimits(...)******************************************************
// * This function will be used far more often than SetInputLimits.
// * While the input to the controller will generally be in the 0-1023 range
// * (which is the default already) the output will be a little different.
// * Maybe they'll be doing a time window and will need 0-8000 or something.
// * Or maybe they'll want to clamp it from 0-125. Who knows.
// * At any rate, that can all be done here.
// ***************************************************************************
void
PID::SetOutputLimits(double Min, double Max) {
if(Min >= Max) return;
outMin = Min;
outMax = Max;
if(inAuto) {
if(*myOutput > outMax)
*myOutput = outMax;
else if(*myOutput < outMin)
*myOutput = outMin;
if(outputSum > outMax)
outputSum= outMax;
else if(outputSum < outMin)
outputSum= outMin;
}
}
// SetMode(...)****************************************************************
// * Allows the controller Mode to be set to manual (0) or Automatic (non-zero)
// * when the transition from manual to auto occurs, the controller is
// * automatically initialized
// ****************************************************************************
void
PID::SetMode(int Mode) {
bool newAuto = (Mode == AUTOMATIC);
if(newAuto && !inAuto) { /*we just went from manual to auto*/
PID::Initialize();
}
inAuto = newAuto;
}
// Initialize()************************************************************
// * Does all the things that need to happen to ensure a bumpless transfer
// * from manual to automatic mode.
// ************************************************************************
void
PID::Initialize() {
outputSum = *myOutput;
lastInput = *myInput;
if(outputSum > outMax)
outputSum = outMax;
else if(outputSum < outMin)
outputSum = outMin;
}
// SetControllerDirection(...)***************************************************
// * The PID will either be connected to a DIRECT acting process (+Output leads
// * to +Input) or a REVERSE acting process(+Output leads to -Input.) we need to
// * know which one, because otherwise we may increase the output when we should
// * be decreasing. This is called from the constructor.
// *******************************************************************************
void
PID::SetControllerDirection(int Direction) {
if(inAuto && Direction !=controllerDirection) {
kp = (0 - kp);
ki = (0 - ki);
kd = (0 - kd);
}
controllerDirection = Direction;
}
// Status Funcions***********************************************************
// * Just because you set the Kp=-1 doesn't mean it actually happened. these
// * functions query the internal state of the PID. they're here for display
// * purposes. this are the functions the PID Front-end uses for example
// **************************************************************************
double PID::GetKp(){ return dispKp; }
double PID::GetKi(){ return dispKi;}
double PID::GetKd(){ return dispKd;}
int PID::GetMode(){ return inAuto ? AUTOMATIC : MANUAL;}
int PID::GetDirection(){ return controllerDirection;}
| [
"gabriele.salvato@cnr.it"
] | gabriele.salvato@cnr.it |
a3f05e3af9ca2fbc676018df3fa1a2821cc0b8e1 | 2ce1e8db12b5fd339a165e345ae3f815dc46ee07 | /examples/Backpropagation/Backpropagation_double_Xor/Backpropagation_double_Xor.ino | 5ae7a735848e1bd213568c310b0457bdeffb5b85 | [
"LicenseRef-scancode-other-permissive"
] | permissive | AlexHudnev/NeuralNetworks | d309fbd3b3a7507ca97197707973a7b3020d3056 | e3f0db1d173d2dd03e32aebbaf9d14c71941bf99 | refs/heads/master | 2023-06-19T10:32:12.619320 | 2021-05-08T13:02:18 | 2021-05-08T13:02:18 | 258,358,288 | 0 | 0 | NOASSERTION | 2020-04-23T23:49:31 | 2020-04-23T23:49:30 | null | UTF-8 | C++ | false | false | 2,039 | ino | #define NumberOf(arg) ((unsigned int) (sizeof (arg) / sizeof (arg [0]))) //calculates the amount of layers (in this case 4)
//#define _1_OPTIMIZE B00010000 // REDUCING RAM By using the same pointer for every layer's weights.
#define Tanh // Comment this line to use Sigmoid Activation Function
#include <NeuralNetwork.h>
unsigned int layers[] = {3, 5, 1}; // 3 layers (1st)layer with 3 input neurons (2nd)layer 5 hidden neurons each and (3th)layer with 1 output neuron
float *outputs; // 4th layer's outputs (in this case output)
//Default Inputs/Training-Data
const float inputs[8][3] = {
{0, 0, 0}, //0
{0, 0, 1}, //1
{0, 1, 0}, //1
{0, 1, 1}, //0
{1, 0, 0}, //1
{1, 0, 1}, //0
{1, 1, 0}, //0
{1, 1, 1} //1
};
const float expectedOutput[8][1] = {{0}, {1}, {1}, {0}, {1}, {0}, {0}, {1}}; // values that we were expecting to get from the 4th/(output)layer of Neural-network, in other words something like a feedback to the Neural-network.
void setup()
{
Serial.begin(9600);
NeuralNetwork NN(layers, NumberOf(layers)); // Creating a NeuralNetwork with default learning-rates
do{
for (int j = 0; j < NumberOf(inputs); j++)
{
NN.FeedForward(inputs[j]); // Feeds-Forward the inputs to the first layer of the NN and Gets the output.
NN.BackProp(expectedOutput[j]); // Tells to the NN if the output was right/the-expectedOutput and then, teaches it.
}
// Prints the Error.
Serial.print("MSE: ");
Serial.println(NN.MeanSqrdError,6);
// loops through each epoch Until MSE goes < 0.003
}while(NN.GetMeanSqrdError(NumberOf(inputs)) > 0.003);
Serial.println("\n =-[OUTPUTS]-=");
//Goes through all inputs
for (int i = 0; i < NumberOf(inputs); i++)
{
outputs = NN.FeedForward(inputs[i]); // Feeds-Forward the inputs[i] to the first layer of the NN and Gets the output
Serial.println(outputs[0], 7); // prints the first 7 digits after the comma.
}
NN.print(); // prints the weights and biases of each layer
}
void loop() {
}
| [
"gxousos@gmail.com"
] | gxousos@gmail.com |
aab98c74cbbc789da5958a114632b6d5ccf35f9b | f5d86f2d06ef811a934b9d9d6d2b9a9ad0e59e76 | /include/FlowFunction/FlowFunction.h | c74cda37271faacc9aa72540d58112d4c932aa96 | [] | no_license | XavierWang/llvm | cc48e9f8ed61872286259c76bd8a85712020ce4c | 4dfe2781fe6f3368ad53321750b3d2657ae6e5d3 | refs/heads/master | 2021-01-14T08:54:48.855122 | 2015-12-13T03:30:49 | 2015-12-13T03:30:49 | 47,491,322 | 0 | 0 | null | 2015-12-06T09:55:06 | 2015-12-06T09:55:05 | null | UTF-8 | C++ | false | false | 823 | h | #ifndef FLOWFUNCTION_H_
#define FLOWFUNCTION_H_
#include "llvm/IR/Instruction.h"
#include "llvm/InstVisitor.h"
#include "../../include/Lattice/LatticeNode.h"
#include "../../include/Lattice/CSELatticeNode.h"
#include "../../include/Lattice/RALatticeNode.h"
#include <vector>
using namespace std;
using namespace llvm;
enum FlowFunctionType{
CPFLOW,
CSEFLOW,
RAFLOW,
MAYPFLOW
};
class FlowFunction{
public:
FlowFunction(FlowFunctionType t):type(t){}
virtual LatticeNode* operator()(Instruction *inst, vector<LatticeNode*> input){
errs()<<"go to FlowFunction ()\n";
return NULL;
}
virtual LatticeNode* PassFunction(Instruction *inst, vector<LatticeNode*> input){return NULL;}
virtual void print(){errs() << "---FlowFunction Info---\n";}
/*The only class member variable*/
FlowFunctionType type;
};
#endif
| [
"dih024@eng.ucsd.edu"
] | dih024@eng.ucsd.edu |
88b8776ef2732928fee04b35c2bcca12873314f1 | 8e69376174bbcd51433872b82ae90ef9531370fc | /Materials/Codes/Week3-TH/NhanVienHH.cpp | 034e5772a606bc16a8368b4ae25b651093f8e27f | [] | no_license | danghuudat/CS122 | fd066727947e13c07fdab569add06c246425fd71 | adf4e0a0c1f5ba913e881e8abefa5100a48e2681 | refs/heads/master | 2020-06-08T11:21:38.838423 | 2019-06-07T09:40:50 | 2019-06-07T09:40:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 98 | cpp | #include "NhanVienHH.h"
NhanVienHH::NhanVienHH()
{
}
NhanVienHH::~NhanVienHH()
{
}
| [
"noreply@github.com"
] | danghuudat.noreply@github.com |
35897187f30006038d08378cfa93d545dc6367ad | 3881b43f782d7193e976ef69fb4c5db41a87e261 | /ADE7758.cpp | 3f183303e750e06e04f781eec9c73bfc4c60eea0 | [] | no_license | tiagotobias2003/ADE7758 | 5e20338674649463a7aaf10867c3d62f71801611 | 3088c2e06244f489880d1034d0369b0b5fe93072 | refs/heads/master | 2021-01-18T15:10:47.038702 | 2014-03-09T17:15:51 | 2014-03-09T17:15:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,420 | cpp | #include "Arduino.h"
#include <SPI.h>
#include "ADE7758.h"
#include <avr/wdt.h>
//public
ADE7758::ADE7758(SPIClass ADE7758SPI, int SSpin):
_ADE7758SPI(ADE7758SPI),
_SSpin(SSpin)
{
digitalWrite(_SSpin, HIGH);
//Ensure Chip select pin is output
pinMode(_SSpin, OUTPUT);
}
void ADE7758::begin()
{
//normal mode
write8bits(OPMODE, 0x44);
}
int ADE7758::getWattHR(char phase)
{
return read16bits(AWATTHR+phase);
}
int ADE7758::getVARHR(char phase)
{
return read16bits(AVARHR+phase);
}
int ADE7758::getVAHR(char phase)
{
return read16bits(AVAHR+phase);
}
long ADE7758::VRMS(char phase)
{
char i=0;
long volts=0;
getVRMS(phase);//Ignore first reading
for(i=0;i<100;++i){
volts+=getVRMS(phase);
}
//average
return volts/100;
}
long ADE7758::IRMS(char phase)
{
char i=0;
long current=0;
getIRMS(phase);//Ignore first reading
for(i=0;i<100;++i){
current+=getIRMS(phase);
}
//average
return current/100;
}
long ADE7758::waveform(char phase,char source)
{
}
void ADE7758::powerOff()
{
}
void ADE7758::powerON()
{
}
void ADE7758::sleep()
{
}
void ADE7758::wakeUp()
{
}
long ADE7758::getInterruptStatus(void){
return read24bits(STATUS);
}
long ADE7758::getResetInterruptStatus(void){
return read24bits(RSTATUS);
}
//private
void ADE7758::enableChip()
{
digitalWrite(_SSpin, LOW);
}
void ADE7758::disableChip()
{
digitalWrite(_SSpin, HIGH);
}
void ADE7758::write8bits(char reg, unsigned char data)
{
enableChip();
delayMicroseconds(50);
_ADE7758SPI.transfer(REG_WRITE(reg));
delayMicroseconds(50);
_ADE7758SPI.transfer((unsigned char)data);
delayMicroseconds(50);
disableChip();
}
void ADE7758::write16bits(char reg, unsigned int data)
{
enableChip();
delayMicroseconds(50);
_ADE7758SPI.transfer(REG_WRITE(reg));
delayMicroseconds(50);
_ADE7758SPI.transfer((unsigned char)((data>>8)&0xFF));
delayMicroseconds(50);
_ADE7758SPI.transfer((unsigned char)(data&0xFF));
delayMicroseconds(50);
disableChip();
}
unsigned char ADE7758::read8bits(char reg)
{
enableChip();
unsigned char ret;
delayMicroseconds(50);
_ADE7758SPI.transfer(REG_READ(reg));
delayMicroseconds(50);
ret=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
disableChip();
return ret;
}
unsigned int ADE7758::read16bits(char reg)
{
enableChip();
unsigned int ret=0;
unsigned char ret0=0;
delayMicroseconds(50);
_ADE7758SPI.transfer(REG_READ(reg));
delayMicroseconds(50);
ret=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
ret0=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
disableChip();
ret= (ret<<8)|ret0;
return ret;
}
unsigned long ADE7758::read24bits(char reg)
{
enableChip();
unsigned long ret=0;
unsigned int ret1=0;
unsigned char ret0=0;
delayMicroseconds(50);
_ADE7758SPI.transfer(REG_READ(reg));
delayMicroseconds(50);
ret=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
ret1=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
ret0=_ADE7758SPI.transfer(0x00);
delayMicroseconds(50);
disableChip();
ret= (ret<<16)|(ret1<<8)|ret0;
return ret;
}
long ADE7758::getIRMS(char phase)
{
long lastupdate = 0;
ADE7758::getResetInterruptStatus(); // Clear all interrupts
lastupdate = millis();
while( ! ( ADE7758::getInterruptStatus() & (ZXA+phase) ) ) // wait Zero-Crossing
{ // wait for the selected interrupt to occur
if ( ( millis() - lastupdate ) > 100)
{
wdt_reset();
Serial.println("\n--> getIRMS Timeout - no AC input");
break;
}
}
return read24bits(AIRMS+phase);
}
long ADE7758::getVRMS(char phase)
{
long lastupdate = 0;
ADE7758::getResetInterruptStatus(); // Clear all interrupts
lastupdate = millis();
while( ! ( ADE7758::getInterruptStatus() & (ZXA+phase) ) ) // wait Zero-Crossing
{ // wait for the selected interrupt to occur
if ( ( millis() - lastupdate ) > 100)
{
wdt_reset();
Serial.println("\n--> getIRMS Timeout - no AC input");
break;
}
}
return read24bits(AVRMS+phase);
}
| [
"engkan2kit@gmail.com"
] | engkan2kit@gmail.com |
0bfdc725ccfe2c34a939b577501a38cb165582f4 | c6bddd88916e6c8697a9e02485bd22c58d76bcec | /GeneratedPlaceholders/Engine/MaterialExpressionStaticComponentMaskParameter.h | 6788b5cb8b1cf12df7044e5888542016fbe9c3be | [] | no_license | GIRU-GIRU/Mordhau-Unofficial-SDK | 18d13d62d746a838820e387907d13b0a37aed654 | f831d7355cf553b81fb6e82468b3abf68f7955aa | refs/heads/master | 2020-07-06T03:36:48.908227 | 2020-04-22T13:54:00 | 2020-04-22T13:54:00 | 202,872,898 | 7 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 676 | h | #pragma once
#include "CoreMinimal.h"
#include "MaterialExpressionStaticComponentMaskParameter.generated.h"
UCLASS()
class UMaterialExpressionStaticComponentMaskParameter : public UMaterialExpressionParameter
{
GENERATED_BODY()
public:
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
struct FExpressionInput Input;
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
unsigned char DefaultR : 1;
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
unsigned char DefaultG : 1;
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
unsigned char DefaultB : 1;
UPROPERTY(Replicated, EditAnywhere, BlueprintReadWrite)
unsigned char DefaultA : 1;
}; | [
"45307738+crypdos@users.noreply.github.com"
] | 45307738+crypdos@users.noreply.github.com |
843d392e5b367a79ffeb3350e651c7ecb813234d | 8c121b5c3dc564eb75f7cb8a1e881941d9792db9 | /old_contest/at_coder_abc185_B.cpp | 9a6d44b855c49951156e83d7a8f780e8814c44f4 | [] | no_license | kayaru28/programming_contest | 2f967a4479f5a1f2c30310c00c143e711445b12d | 40bb79adce823c19bbd988f77b515052c710ea42 | refs/heads/master | 2022-12-13T18:32:37.818967 | 2022-11-26T16:36:20 | 2022-11-26T16:36:20 | 147,929,424 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,791 | cpp | #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000 //1e4
#define base10_5 100000 //1e5
#define base10_6 1000000 //1e6
#define base10_7 10000000 //1e7
#define base10_8 100000000 //1e8
#define base10_9 1000000000 //1e9
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
//#include <stack>
//#include <queue>
// #include <iomanip>
// cout << fixed << setprecision(15) << y << endl;
/*
sort(ord.begin(),ord.end(),[&](int x, int y){
return p[x]>p[y];
});
*/
string ans_Yes = "Yes";
string ans_No = "No";
string ans_yes = "yes";
string ans_no = "no";
vll A;
vll B;
ll C;
ll N;
ll M;
ll K;
ll ltmp;
string stmp;
double dtmp;
ll llmin(ll a,ll b){
if(a>=b) return b;
return a;
}
ll llmax(ll a,ll b){
if(a<=b) return b;
return a;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> N;
cin >> M;
cin >> K;
A.resize(M);
B.resize(M);
rep(mi,M){
cin >> A[mi];
cin >> B[mi];
}
ll tmpN = N;
ll nowtime = 0;
rep(mi,M){
tmpN -= (A[mi] - nowtime);
if(tmpN<=0) break;
tmpN += (B[mi]-A[mi]);
tmpN = llmin(N,tmpN);
nowtime = B[mi];
}
tmpN -= (K - nowtime);
if(tmpN<=0) cout << "No" << endl;
else cout << "Yes" << endl;
} | [
"istorytale090415@gmail.com"
] | istorytale090415@gmail.com |
b3c238e3700048893b9b142d5ab52f4bd010f583 | 7a455d1705511cc4dfbcf44d5a9544cd2052f62e | /code/backend/include/insieme/backend/variable_manager.h | 901440f04d1834d6418169e0e675bc8aa58b545a | [] | no_license | 8l/insieme | 69bf70adc34e465c41581dfd077a37451cac56d4 | 1db3b7dc6643d8c4c791c69a4004efabb19b665c | refs/heads/master | 2020-04-05T19:00:15.914694 | 2015-07-20T13:12:31 | 2015-07-20T13:12:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,760 | h | /**
* Copyright (c) 2002-2013 Distributed and Parallel Systems Group,
* Institute of Computer Science,
* University of Innsbruck, Austria
*
* This file is part of the INSIEME Compiler and Runtime System.
*
* We provide the software of this file (below described as "INSIEME")
* under GPL Version 3.0 on an AS IS basis, and do not warrant its
* validity or performance. We reserve the right to update, modify,
* or discontinue this software at any time. We shall have no
* obligation to supply such updates or modifications or any other
* form of support to you.
*
* If you require different license terms for your intended use of the
* software, e.g. for proprietary commercial or industrial use, please
* contact us at:
* insieme@dps.uibk.ac.at
*
* We kindly ask you to acknowledge the use of this software in any
* publication or other disclosure of results by referring to the
* following citation:
*
* H. Jordan, P. Thoman, J. Durillo, S. Pellegrini, P. Gschwandtner,
* T. Fahringer, H. Moritsch. A Multi-Objective Auto-Tuning Framework
* for Parallel Codes, in Proc. of the Intl. Conference for High
* Performance Computing, Networking, Storage and Analysis (SC 2012),
* IEEE Computer Society Press, Nov. 2012, Salt Lake City, USA.
*
* All copyright notices must be kept intact.
*
* INSIEME depends on several third party software packages. Please
* refer to http://www.dps.uibk.ac.at/insieme/license.html for details
* regarding third party software licenses.
*/
#pragma once
#include "insieme/backend/c_ast/forward_decls.h"
#include "insieme/core/ir_expressions.h"
#include "insieme/utils/map_utils.h"
namespace insieme {
namespace backend {
class Converter;
struct TypeInfo;
struct VariableInfo {
enum MemoryLocation {
NONE, /* < the variable is not a reference type */
DIRECT, /* < the variable represents the corresponding memory cell directly (e.g. a local variable) */
INDIRECT /* < the variable is a pointer to the actually represented memory cell */
};
const TypeInfo* typeInfo;
c_ast::VariablePtr var;
MemoryLocation location;
};
class VariableManager {
utils::map::PointerMap<core::VariablePtr, VariableInfo> infos;
public:
VariableManager() : infos() {};
const VariableInfo& getInfo(const core::VariablePtr& var) const;
const VariableInfo& addInfo(const Converter& converter, const core::VariablePtr& var, VariableInfo::MemoryLocation location);
const VariableInfo& addInfo(const Converter& converter, const core::VariablePtr& var, VariableInfo::MemoryLocation location, const TypeInfo& typeInfo);
void remInfo(const core::VariablePtr& var);
};
} // end namespace backend
} // end namespace insieme
| [
"herbert@dps.uibk.ac.at"
] | herbert@dps.uibk.ac.at |
188539c1b4581e1857293e4e8e989ae58c367637 | 68b2cfc0b2e5825247c68d8043de0f85881e2d71 | /C++ test codes (Bari tutorial) Part 1/Arithmetic Operations/Area of Triangle/AreaOfTriangle.cpp | 195624d6202e97b53da9e72c27e52cf6f45d2ac0 | [] | no_license | shubha360/CPP-Practice-Codes | 3bb645ced291e22fad111b55b91eac8c4d24a6ae | a992741d75c11fa85dcfc22c56af5cb4cbcc6575 | refs/heads/master | 2023-01-22T17:00:51.492914 | 2020-12-03T14:01:32 | 2020-12-03T14:01:32 | 282,846,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 359 | cpp | #include<iostream>
using namespace std;
int main() {
int base, height;
double area;
cout<<"Enter integer value of base: ";
cin>>base;
cout<<"\n";
cout<<"Enter integer value of height: ";
cin>>height;
cout<<"\n";
area = (double) (base*height)/2;
cout<<"Area is: "<<area;
return 0;
} | [
"noreply@github.com"
] | shubha360.noreply@github.com |
ef127caf797f0b5880654ee73c604c8ca13ec06b | d2838a6119d5fb7196a8a4999f3134eb19b8ee62 | /havingfan/havingfan.ino | 417fcc6c6f02b06c70f46b28bcf35cfa3526e592 | [] | no_license | draentropia/gettingfan | 406d03b07744f21b54b98b4c9b13f109ba2f218a | 5c9fbb5bf081a534361ccf00a10e62a641b99c25 | refs/heads/master | 2022-01-17T09:30:44.198717 | 2019-07-21T18:42:05 | 2019-07-21T18:42:05 | 198,090,858 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 346 | ino | const int RELE = 8;
void setup() {
Serial.begin(9600);
pinMode(RELE, OUTPUT);
}
void loop() {
int status = 0; // set status to off
while (Serial.available()>0)
{
status = Serial.parseInt();
if (status==1)
{
digitalWrite(RELE, HIGH);
} else {
digitalWrite(RELE, LOW);
}
}
}
| [
"noreply@github.com"
] | draentropia.noreply@github.com |
b2141118de1c0f2969be05624797553cc89bdbfd | fc987ace8516d4d5dfcb5444ed7cb905008c6147 | /v8/test/unittests/compiler/effect-control-linearizer-unittest.cc | 0a12ea371a4a987491122b3917eaf73f98e4a88a | [
"BSD-3-Clause",
"bzip2-1.0.6",
"SunPro"
] | permissive | nfschina/nfs-browser | 3c366cedbdbe995739717d9f61e451bcf7b565ce | b6670ba13beb8ab57003f3ba2c755dc368de3967 | refs/heads/master | 2022-10-28T01:18:08.229807 | 2020-09-07T11:45:28 | 2020-09-07T11:45:28 | 145,939,440 | 2 | 4 | BSD-3-Clause | 2022-10-13T14:59:54 | 2018-08-24T03:47:46 | null | UTF-8 | C++ | false | false | 14,012 | cc | // Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/compiler/effect-control-linearizer.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/linkage.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/schedule.h"
#include "src/compiler/simplified-operator.h"
#include "test/unittests/compiler/graph-unittest.h"
#include "test/unittests/compiler/node-test-utils.h"
#include "test/unittests/test-utils.h"
#include "testing/gmock-support.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace v8 {
namespace internal {
namespace compiler {
using testing::Capture;
class EffectControlLinearizerTest : public GraphTest {
public:
EffectControlLinearizerTest()
: GraphTest(3),
machine_(zone()),
javascript_(zone()),
simplified_(zone()),
jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_,
&machine_) {}
JSGraph* jsgraph() { return &jsgraph_; }
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
private:
MachineOperatorBuilder machine_;
JSOperatorBuilder javascript_;
SimplifiedOperatorBuilder simplified_;
JSGraph jsgraph_;
};
namespace {
BasicBlock* AddBlockToSchedule(Schedule* schedule) {
BasicBlock* block = schedule->NewBasicBlock();
block->set_rpo_number(static_cast<int32_t>(schedule->rpo_order()->size()));
schedule->rpo_order()->push_back(block);
return block;
}
} // namespace
TEST_F(EffectControlLinearizerTest, SimpleLoad) {
Schedule schedule(zone());
// Create the graph.
Node* heap_number = NumberConstant(0.5);
Node* load = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
graph()->start(), graph()->start());
Node* ret = graph()->NewNode(common()->Return(), load, graph()->start(),
graph()->start());
// Build the basic block structure.
BasicBlock* start = schedule.start();
schedule.rpo_order()->push_back(start);
start->set_rpo_number(0);
// Populate the basic blocks with nodes.
schedule.AddNode(start, graph()->start());
schedule.AddNode(start, heap_number);
schedule.AddNode(start, load);
schedule.AddReturn(start, ret);
// Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
introducer.Run();
EXPECT_THAT(load,
IsLoadField(AccessBuilder::ForHeapNumberValue(), heap_number,
graph()->start(), graph()->start()));
// The return should have reconnected effect edge to the load.
EXPECT_THAT(ret, IsReturn(load, load, graph()->start()));
}
TEST_F(EffectControlLinearizerTest, DiamondLoad) {
Schedule schedule(zone());
// Create the graph.
Node* branch =
graph()->NewNode(common()->Branch(), Int32Constant(0), graph()->start());
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* heap_number = NumberConstant(0.5);
Node* vtrue = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
graph()->start(), if_true);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* vfalse = Float64Constant(2);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
Node* phi = graph()->NewNode(
common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge);
Node* ret =
graph()->NewNode(common()->Return(), phi, graph()->start(), merge);
// Build the basic block structure.
BasicBlock* start = schedule.start();
schedule.rpo_order()->push_back(start);
start->set_rpo_number(0);
BasicBlock* tblock = AddBlockToSchedule(&schedule);
BasicBlock* fblock = AddBlockToSchedule(&schedule);
BasicBlock* mblock = AddBlockToSchedule(&schedule);
// Populate the basic blocks with nodes.
schedule.AddNode(start, graph()->start());
schedule.AddBranch(start, branch, tblock, fblock);
schedule.AddNode(tblock, if_true);
schedule.AddNode(tblock, heap_number);
schedule.AddNode(tblock, vtrue);
schedule.AddGoto(tblock, mblock);
schedule.AddNode(fblock, if_false);
schedule.AddNode(fblock, vfalse);
schedule.AddGoto(fblock, mblock);
schedule.AddNode(mblock, merge);
schedule.AddNode(mblock, phi);
schedule.AddReturn(mblock, ret);
// Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
introducer.Run();
// The effect input to the return should be an effect phi with the
// newly introduced effectful change operators.
ASSERT_THAT(
ret, IsReturn(phi, IsEffectPhi(vtrue, graph()->start(), merge), merge));
}
TEST_F(EffectControlLinearizerTest, FloatingDiamondsControlWiring) {
Schedule schedule(zone());
// Create the graph and schedule. Roughly (omitting effects and unimportant
// nodes):
//
// BLOCK 0:
// r1: Start
// c1: Call
// b1: Branch(const0, s1)
// |
// +-------+------+
// | |
// BLOCK 1: BLOCK 2:
// t1: IfTrue(b1) f1: IfFalse(b1)
// | |
// +-------+------+
// |
// BLOCK 3:
// m1: Merge(t1, f1)
// c2: IfSuccess(c1)
// b2: Branch(const0 , s1)
// |
// +-------+------+
// | |
// BLOCK 4: BLOCK 5:
// t2: IfTrue(b2) f2:IfFalse(b2)
// | |
// +-------+------+
// |
// BLOCK 6:
// m2: Merge(t2, f2)
// r1: Return(c1, c2)
LinkageLocation kLocationSignature[] = {
LinkageLocation::ForRegister(0, MachineType::Pointer()),
LinkageLocation::ForRegister(1, MachineType::Pointer())};
const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
CallDescriptor::kCallCodeObject, MachineType::AnyTagged(),
LinkageLocation::ForRegister(0, MachineType::Pointer()),
new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags);
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
Node* const0 = Int32Constant(0);
Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
graph()->start(), graph()->start());
Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
// First Floating diamond.
Node* branch1 =
graph()->NewNode(common()->Branch(), const0, graph()->start());
Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
// Second floating diamond.
Node* branch2 =
graph()->NewNode(common()->Branch(), const0, graph()->start());
Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2);
Node* ret =
graph()->NewNode(common()->Return(), call, graph()->start(), if_success);
// Build the basic block structure.
BasicBlock* start = schedule.start();
schedule.rpo_order()->push_back(start);
start->set_rpo_number(0);
BasicBlock* t1block = AddBlockToSchedule(&schedule);
BasicBlock* f1block = AddBlockToSchedule(&schedule);
BasicBlock* m1block = AddBlockToSchedule(&schedule);
BasicBlock* t2block = AddBlockToSchedule(&schedule);
BasicBlock* f2block = AddBlockToSchedule(&schedule);
BasicBlock* m2block = AddBlockToSchedule(&schedule);
// Populate the basic blocks with nodes.
schedule.AddNode(start, graph()->start());
schedule.AddNode(start, p0);
schedule.AddNode(start, p1);
schedule.AddNode(start, const0);
schedule.AddNode(start, call);
schedule.AddBranch(start, branch1, t1block, f1block);
schedule.AddNode(t1block, if_true1);
schedule.AddGoto(t1block, m1block);
schedule.AddNode(f1block, if_false1);
schedule.AddGoto(f1block, m1block);
schedule.AddNode(m1block, merge1);
// The scheduler does not always put the IfSuccess node to the corresponding
// call's block, simulate that here.
schedule.AddNode(m1block, if_success);
schedule.AddBranch(m1block, branch2, t2block, f2block);
schedule.AddNode(t2block, if_true2);
schedule.AddGoto(t2block, m2block);
schedule.AddNode(f2block, if_false2);
schedule.AddGoto(f2block, m2block);
schedule.AddNode(m2block, merge2);
schedule.AddReturn(m2block, ret);
// Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
introducer.Run();
// The effect input to the return should be an effect phi with the
// newly introduced effectful change operators.
ASSERT_THAT(ret, IsReturn(call, call, merge2));
ASSERT_THAT(branch2, IsBranch(const0, merge1));
ASSERT_THAT(branch1, IsBranch(const0, if_success));
ASSERT_THAT(if_success, IsIfSuccess(call));
}
TEST_F(EffectControlLinearizerTest, LoopLoad) {
Schedule schedule(zone());
// Create the graph.
Node* loop = graph()->NewNode(common()->Loop(1), graph()->start());
Node* effect_phi =
graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop);
Node* cond = Int32Constant(0);
Node* branch = graph()->NewNode(common()->Branch(), cond, loop);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
loop->AppendInput(zone(), if_false);
NodeProperties::ChangeOp(loop, common()->Loop(2));
effect_phi->InsertInput(zone(), 1, effect_phi);
NodeProperties::ChangeOp(effect_phi, common()->EffectPhi(2));
Node* heap_number = NumberConstant(0.5);
Node* load = graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
graph()->start(), loop);
Node* ret = graph()->NewNode(common()->Return(), load, effect_phi, if_true);
// Build the basic block structure.
BasicBlock* start = schedule.start();
schedule.rpo_order()->push_back(start);
start->set_rpo_number(0);
BasicBlock* lblock = AddBlockToSchedule(&schedule);
BasicBlock* fblock = AddBlockToSchedule(&schedule);
BasicBlock* rblock = AddBlockToSchedule(&schedule);
// Populate the basic blocks with nodes.
schedule.AddNode(start, graph()->start());
schedule.AddGoto(start, lblock);
schedule.AddNode(lblock, loop);
schedule.AddNode(lblock, effect_phi);
schedule.AddNode(lblock, heap_number);
schedule.AddNode(lblock, load);
schedule.AddNode(lblock, cond);
schedule.AddBranch(lblock, branch, rblock, fblock);
schedule.AddNode(fblock, if_false);
schedule.AddGoto(fblock, lblock);
schedule.AddNode(rblock, if_true);
schedule.AddReturn(rblock, ret);
// Run the state effect introducer.
EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
introducer.Run();
ASSERT_THAT(ret, IsReturn(load, load, if_true));
EXPECT_THAT(load, IsLoadField(AccessBuilder::ForHeapNumberValue(),
heap_number, effect_phi, loop));
}
TEST_F(EffectControlLinearizerTest, CloneBranch) {
Schedule schedule(zone());
Node* cond0 = Parameter(0);
Node* cond1 = Parameter(1);
Node* cond2 = Parameter(2);
Node* branch0 = graph()->NewNode(common()->Branch(), cond0, start());
Node* control1 = graph()->NewNode(common()->IfTrue(), branch0);
Node* control2 = graph()->NewNode(common()->IfFalse(), branch0);
Node* merge0 = graph()->NewNode(common()->Merge(2), control1, control2);
Node* phi0 = graph()->NewNode(common()->Phi(MachineRepresentation::kBit, 2),
cond1, cond2, merge0);
Node* branch = graph()->NewNode(common()->Branch(), phi0, merge0);
Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
graph()->SetEnd(graph()->NewNode(common()->End(1), merge));
BasicBlock* start = schedule.start();
schedule.rpo_order()->push_back(start);
start->set_rpo_number(0);
BasicBlock* f1block = AddBlockToSchedule(&schedule);
BasicBlock* t1block = AddBlockToSchedule(&schedule);
BasicBlock* bblock = AddBlockToSchedule(&schedule);
BasicBlock* f2block = AddBlockToSchedule(&schedule);
BasicBlock* t2block = AddBlockToSchedule(&schedule);
BasicBlock* mblock = AddBlockToSchedule(&schedule);
// Populate the basic blocks with nodes.
schedule.AddNode(start, graph()->start());
schedule.AddBranch(start, branch0, t1block, f1block);
schedule.AddNode(t1block, control1);
schedule.AddGoto(t1block, bblock);
schedule.AddNode(f1block, control2);
schedule.AddGoto(f1block, bblock);
schedule.AddNode(bblock, merge0);
schedule.AddNode(bblock, phi0);
schedule.AddBranch(bblock, branch, t2block, f2block);
schedule.AddNode(t2block, if_true);
schedule.AddGoto(t2block, mblock);
schedule.AddNode(f2block, if_false);
schedule.AddGoto(f2block, mblock);
schedule.AddNode(mblock, merge);
schedule.AddNode(mblock, graph()->end());
EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
introducer.Run();
Capture<Node *> branch1_capture, branch2_capture;
EXPECT_THAT(
end(),
IsEnd(IsMerge(IsMerge(IsIfTrue(CaptureEq(&branch1_capture)),
IsIfTrue(CaptureEq(&branch2_capture))),
IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture),
IsBranch(cond1, control1))),
IsIfFalse(AllOf(CaptureEq(&branch2_capture),
IsBranch(cond2, control2)))))));
}
} // namespace compiler
} // namespace internal
} // namespace v8
| [
"hukun@cpu-os.ac.cn"
] | hukun@cpu-os.ac.cn |
400aee4ffec7ff2261ee72d1fe8847a6a3a07e7c | e79697cef5abd7a64790fb8619b2e69d1ee204c7 | /Códigos/aplicacao3-ParaleloGaussLegendre.cpp | 0db578084cb6c2954ab8d64e090d4df7d693bbc8 | [] | no_license | caiossoliveira/SO2019-GrupoCaioWanner | cdccb50ae842099293da70fe2a8b6e9b9a90f0df | d2694f75b64f1fe585f83a1a1fc107961046c25c | refs/heads/master | 2020-06-08T18:56:43.561978 | 2019-06-22T23:19:55 | 2019-06-22T23:19:55 | 193,286,984 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,691 | cpp | //declaração das bibliotecas
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <pthread.h>
#include <sys/time.h>
typedef struct{
double a;
double an;
double b;
double t;
long long int p;
}GaussLegStruct;
pthread_mutex_t mutex;
const int MAXIT = 1000000000;//1000000000;
//protótipo das funções
void piGaussParalelo();
void *calcAB(void *ptr);
void *calcTP(void *ptr);
main() {
piGaussParalelo();
}
void piGaussParalelo(){
pthread_t threads[2];
int ret[2];
long int i;
double pi;
GaussLegStruct *glstruct;
//Aloca as structs and inicializa as variaveis
glstruct = (GaussLegStruct*)calloc(1, sizeof(GaussLegStruct));
glstruct->a = 1;
glstruct->an = 1;
glstruct->b = 1.0/sqrt(2);
glstruct->t = 0.25;
glstruct->p = 1;
//Cria as threads para calcular cada parte do algoritmo a cada interação, até o fim do algoritmo
for(i = 0; i < MAXIT; i++){
pthread_mutex_lock (&mutex);
ret[0] = pthread_create(&threads[0], NULL, calcAB, (void*) glstruct);
if(ret[0]){
fprintf(stderr,"Error - pthread_create() return code: %d\n",ret[0]);
exit(EXIT_FAILURE);
}
ret[1] = pthread_create(&threads[1], NULL, calcTP, (void*) glstruct);
if(ret[1]){
fprintf(stderr,"Error - pthread_create() return code: %d\n",ret[1]);
exit(EXIT_FAILURE);
}
pthread_join(threads[0], NULL);
pthread_join(threads[1], NULL);
}
//Calcula o Pi segundo a formula de GaussLegendre
pi = pow( (glstruct->a + glstruct->b), 2.0 )/(4.0*glstruct->t);
printf(" --------------------------------------------------------------------\n");
printf(" | Pi por Gauss-Legendre - Paralelo |\n");
printf(" | Pi por Gauss-Legendre: %.6lf |\n", pi );
printf(" --------------------------------------------------------------------\n");
free(glstruct);
//pthread_exit(NULL);
}
void *calcAB(void *ptr){
//calcula valores A e B
GaussLegStruct *glstr = (GaussLegStruct*)ptr;
glstr->an = glstr->a;
glstr->a = (glstr->an+glstr->b)/2.0;
glstr->b = sqrt( (glstr->an)*(glstr->b) );
//libera a thread
pthread_mutex_unlock (&mutex);
return NULL;
}
void *calcTP(void *ptr){
//tranca a thread para calcular os valores T e P
pthread_mutex_lock (&mutex);
GaussLegStruct *glstr = (GaussLegStruct*)ptr;
glstr->t = (glstr->t) - (glstr->p)*pow( ((glstr->an) - (glstr->a)), 2.0 );
glstr->p = 2*(glstr->p);
//destranca a thread
pthread_mutex_unlock (&mutex);
return NULL;
}
| [
"noreply@github.com"
] | caiossoliveira.noreply@github.com |
fdd111adb07e2904b024d91ec55f30c653e9ea5e | 127c53f4e7e220f44dc82d910a5eed9ae8974997 | /Client/Tools/MrSmith/MrSmith/DataPool/SMDataPool_CharacterList.cpp | 9c2df9e72db364da0117478a17e703ecf93a8c1c | [] | no_license | zhangf911/wxsj2 | 253e16265224b85cc6800176a435deaa219ffc48 | c8e5f538c7beeaa945ed2a9b5a9b04edeb12c3bd | refs/heads/master | 2020-06-11T16:44:14.179685 | 2013-03-03T08:47:18 | 2013-03-03T08:47:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,135 | cpp | #include "StdAfx.h"
#include "SMDataPool_CharacterList.h"
#include "..\SMAgentManager.h"
#include "..\SMAgent.h"
#include "Type.h"
#include "GameStruct.h"
namespace SMITH
{
LoginCharacterList::LoginCharacterList(Agent* pAgent)
: LuaExport< LoginCharacterList >("LoginCharacterList", pAgent->getLuaState())
{
RegisterFunction("GetCharacterCounts", &LoginCharacterList::Lua_GetCharacterCounts);
}
LoginCharacterList::~LoginCharacterList()
{
for(int i=0; i<(int)m_vCharacterVector.size(); i++)
{
delete m_vCharacterVector[i];
m_vCharacterVector[i]=0;
}
m_vCharacterVector.clear();
}
void LoginCharacterList::insertCharInfo(DB_CHAR_BASE_INFO* pCharInfo)
{
DB_CHAR_BASE_INFO* pNew = new DB_CHAR_BASE_INFO;
*pNew = *pCharInfo;
m_vCharacterVector.push_back(pNew);
}
const DB_CHAR_BASE_INFO* LoginCharacterList::getCharacter(int nIndex)
{
if(nIndex<0 || nIndex>=(int)m_vCharacterVector.size()) return 0;
return m_vCharacterVector[nIndex];
}
int LoginCharacterList::Lua_GetCharacterCounts(LuaPlus::LuaState* state)
{
state->PushInteger(getCharCounts());
return 1;
}
} | [
"amwfhv@163.com"
] | amwfhv@163.com |
37b9c1dcd5ec7828d73d5d3a3612112dee1ff724 | 1eec7c89c35d709c6e368e9c5b3db2c039683159 | /pairs.cpp | a5f1abc14d83e9c7a1a417502b470e8528062a7e | [] | no_license | ashishyadav24092000/Conceptual-Programs-C- | c6a81fc7086b6c773e2a35a984ce4e1cdbe32cb8 | 6f593cc1fa1e57e982ebd8207d142ae769183625 | refs/heads/main | 2023-08-15T06:06:43.803960 | 2021-10-02T10:16:00 | 2021-10-02T10:16:00 | 412,756,584 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 937 | cpp | #include<iostream>
#include<vector>
#include<unordered_set>
using namespace std;
//TIME COMPLEXITY O(N)
vector<int> pair_sum(vector<int> arr,int sum)
{
unordered_set<int> set1;
vector<int> result;
for(int i=0;i<arr.size();i++)
{
int x = sum - arr[i];
if(set1.find(x) != set1.end()) //The unordered_set::find() function is a built-in function in C++ STL which is used to search for an element in the container. It returns an iterator to the element, if found else, it returns an iterator pointing to unordered_set::end()
{
result.push_back(x);
result.push_back(arr[i]);
return result;
}
//insert the current item into set
set1.insert(arr[i]);
}
}
int main()
{
vector<int> array{10,5,2,3,-6,9,11};
int target_sum =4;
auto p = pair_sum(array,target_sum);
if(p.size() == 0)
cout<<"\nNo such pair....";
else
cout<<"\n"<<p[0]<<" "<<p[1];
return 0;
}
| [
"noreply@github.com"
] | ashishyadav24092000.noreply@github.com |
58262bb10c1d7ab8c27395b7c99b08022513e2dc | cb24aa9a8edd9d58fea5e5274712d30a5a39a70f | /TriggerStudies/interface/HLTObject.h | 2ff15628ac1860b6bd2413ceccd95de098ef9292 | [] | no_license | joaopela/CMSSW_VBFHToInv | 36b1c7af10bc868c03219111c25f167436f2b7eb | 421310aef87fa0909f1fe7f6c32f39a92e67e4dd | refs/heads/master | 2021-01-17T08:30:16.971952 | 2015-11-23T14:02:09 | 2015-11-23T14:02:09 | 14,692,093 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 806 | h | // -*- C++ -*-
#ifndef VBFHiggsToInvisible_TriggerStudies_HLTObject_H
#define VBFHiggsToInvisible_TriggerStudies_HLTObject_H
#include "Math/Vector4D.h"
#include "Math/Vector4Dfwd.h"
// System include files
#include <string>
#include <vector>
class HLTObject{
public:
HLTObject();
HLTObject(double pt,double eta,double phi,double energy);
double pt();
double px();
double py();
double pz();
double eta();
double phi();
double energy();
bool isJet();
bool isMET();
bool passedFilter(std::string);
ROOT::Math::PtEtaPhiEVector getP4();
void addFilter(std::string filterName);
void addType (int type);
void print();
private:
ROOT::Math::PtEtaPhiEVector p4;
std::vector<int> m_types;
std::vector<std::string> m_filters;
};
#endif
| [
"pela@cern.ch"
] | pela@cern.ch |
43620c378e0f1b0f48902ba474b2bae85414560b | b417693f522e1e92d5d9daae0d1d45180f5224f2 | /Plugin/Log.cpp | 4e5a0fbc8cb798c23b2fdd855de3475caea943af | [] | no_license | killvxk/binkit | dc25faf999b976b0c6bb476f70ca37c80bc1d9e9 | a7872a7bf2cbbeaf0386d6bbabfce2b6bf78c8c3 | refs/heads/master | 2022-09-27T06:17:19.488337 | 2020-06-06T18:01:07 | 2020-06-06T18:01:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 720 | cpp | #pragma warning(disable:4996)
#include <windows.h>
#include <stdio.h>
#include <TCHAR.H>
#include <ida.hpp>
#include <kernwin.hpp>
#include "Log.h"
int gLogLevel = 0;
void SetLogLevel(int gLogLevel)
{
gLogLevel = gLogLevel;
}
void LogMessage(int level, const char *function_name, const TCHAR *format, ...)
{
if (level < gLogLevel)
{
return;
}
TCHAR statement_buffer[1024*4] = { 0, };
va_list args;
va_start(args, format);
_vsntprintf(statement_buffer, sizeof(statement_buffer) / sizeof(TCHAR), format, args);
va_end(args);
SYSTEMTIME lt;
GetLocalTime(<);
msg("[%02d:%02d:%02d] %s: %s", lt.wHour, lt.wMinute, lt.wSecond, function_name, statement_buffer);
}
| [
"oh.jeongwook@gmail.com"
] | oh.jeongwook@gmail.com |
e5598620804017ca4911c1db340f44dab4fd6386 | e2a73f2fd67fd0516cab72d1c8100c3464115144 | /Algorithmic Toolbox/Week 3/fractional_knapsack/fractional_knapsack.cpp | a859abc91bb711b44349dc48a687f37786b9986f | [] | no_license | shubhpy/Cpp-Programs | f60c564f039b4dc53709a0a73d8d15161f22d24f | 1192995a950ae7d22efe356aaf8945c71a18bef4 | refs/heads/master | 2021-05-02T17:53:10.057000 | 2016-10-25T19:52:19 | 2016-10-25T19:52:19 | 62,331,340 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,299 | cpp | #include <iostream>
#include <algorithm>
#include <vector>
using std::vector;
using std::cout;
using std::cin;
double get_optimal_value(int n,int capacity, vector<int> weights, vector<int> values) {
double value = 0.0;
vector<double> valuesByweights(n);
for(int i=0;i<n;i++){
valuesByweights[i] = (double)values[i] / weights[i];
}
std::vector<int> y(valuesByweights.size());
std::size_t nn(0);
std::generate(std::begin(y), std::end(y), [&]{ return nn++; });
std::sort( std::begin(y),
std::end(y),
[&](double i1, double i2) { return valuesByweights[i1] < valuesByweights[i2]; } );
for(int j=0;j<n;j++){
if (capacity>=weights[y[n-1-j]]){
capacity-=weights[y[n-1-j]];
value+=values[y[n-1-j]];
}
else{
value+=valuesByweights[y[n-1-j]]*capacity;
capacity=0;
}
}
return value;
}
int main() {
int n;
int capacity;
std::cin >> n >> capacity;
vector<int> values(n);
vector<int> weights(n);
for (int i = 0; i < n; i++) {
std::cin >> values[i] >> weights[i];
}
double optimal_value = get_optimal_value(n,capacity, weights, values);
std::cout.precision(10);
std::cout << optimal_value << std::endl;
return 0;
}
| [
"shubhpycode@gmail.com"
] | shubhpycode@gmail.com |
38e630b3dadf6b41ed2f0a13125477ae7143877d | 6e2ebb243d380b981905dfd04ebabdc34c08ff73 | /MyActionRPG/Source/MyActionRPG/Public/GameSystem/Abilities/Ability/RPGGameplayAbility.h | a9a1d95e54420169f3f4d2838f29bfdf892a52b1 | [] | no_license | xuguoyang/UE4 | 8201b3228250f587053d240ef112301be24d8d59 | 6210e4711c3d5c04cfdfb7867b374a6f0caa882f | refs/heads/master | 2023-03-08T20:44:24.963244 | 2023-02-22T02:58:28 | 2023-02-22T02:58:28 | 59,945,144 | 1 | 1 | null | 2021-07-13T14:22:19 | 2016-05-29T13:44:53 | C++ | GB18030 | C++ | false | false | 2,470 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Abilities/GameplayAbility.h"
#include "GameplayTagContainer.h"
#include "RPGAbilityTypes.h"
#include "GameplayEffectTypes.h"
#include "Interface/ShortcutUseInterface.h"
#include "RPGGameplayAbility.generated.h"
/**
*
*/
UCLASS()
class MYACTIONRPG_API URPGGameplayAbility : public UGameplayAbility, public IShortcutUseInterface
{
GENERATED_BODY()
public:
URPGGameplayAbility();
/** GameplayTag对应的EffectContainer容器, 在蓝图中配置*/
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GameplayEffects)
TMap<FGameplayTag, FRPGGameplayEffectContainer> EffectContainerMap;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = GameplayEffects)
FGameplayAbilityStaticData GAStaticData;
public:
/** 通过创建spec执行某一个技能容器 */
UFUNCTION(BlueprintCallable, Category = Ability, meta = (AutoCreateRefTerm = "EventData"))
virtual TArray<FActiveGameplayEffectHandle> ApplyEffectContainer(FGameplayTag ContainerTag, const FGameplayEventData& EventData, int32 OverrideGameplayLevel = -1);
/** 通过Gameplaytag搜索EffectContainerMap获取EffectContainer生成EffectContainerSpec*/
UFUNCTION(BlueprintCallable, Category = Ability, meta = (AutoCreateRefTerm = "EventData"))
virtual FRPGGameplayEffectContainerSpec MakeEffectContainerSpec(FGameplayTag ContainerTag, const FGameplayEventData& EventData, int32 OverrideGameplayLevel = -1);
/** 通过EffectContainer生成EffectContainerSpec*/
UFUNCTION(BlueprintCallable, Category = Ability, meta = (AutoCreateRefTerm = "EventData"))
virtual FRPGGameplayEffectContainerSpec MakeEffectContainerSpecFromContainer(const FRPGGameplayEffectContainer& Contanier, const FGameplayEventData& EventData, int32 OverrideGameplayLevel = -1);
/** 执行之前已经创建好的ContainerSpec, 在这里是真正执行技能效果*/
UFUNCTION(BlueprintCallable, Category = Ability)
virtual TArray<FActiveGameplayEffectHandle> ApplyEffectContainerSpec(const FRPGGameplayEffectContainerSpec& ContainerSpec);
public:
virtual bool ShortcutUse() override;
virtual bool OnAddShortcut() override;
virtual bool OnRemoveShortcut() override;
virtual EShortcutType GetType() override;
protected:
UFUNCTION(BlueprintNativeEvent)
void UseAbility();
UFUNCTION(BlueprintPure)
bool AbilityIsActive();
};
| [
"wxkyxgy@foxmail.com"
] | wxkyxgy@foxmail.com |
233bf251bf6db8445c04d1c27bd0d73978448bc0 | 64e4fabf9b43b6b02b14b9df7e1751732b30ad38 | /src/chromium/third_party/blink/public/web/web_local_frame.h | 5665db8f8167d931676bb7d3ef7d70e074e43873 | [
"BSD-3-Clause"
] | permissive | ivan-kits/skia-opengl-emscripten | 8a5ee0eab0214c84df3cd7eef37c8ba54acb045e | 79573e1ee794061bdcfd88cacdb75243eff5f6f0 | refs/heads/master | 2023-02-03T16:39:20.556706 | 2020-12-25T14:00:49 | 2020-12-25T14:00:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 34,300 | h | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_LOCAL_FRAME_H_
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_LOCAL_FRAME_H_
#include <memory>
#include <set>
#include "base/callback.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
#include "third_party/blink/public/common/feature_policy/feature_policy.h"
#include "third_party/blink/public/common/frame/sandbox_flags.h"
#include "third_party/blink/public/common/messaging/transferable_message.h"
#include "third_party/blink/public/mojom/ad_tagging/ad_frame.mojom-shared.h"
#include "third_party/blink/public/mojom/commit_result/commit_result.mojom-shared.h"
#if defined(ENABLE_GNET)
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#endif // ENABLE_GNET
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-shared.h"
#include "third_party/blink/public/mojom/selection_menu/selection_menu_behavior.mojom-shared.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/public/platform/web_focus_type.h"
#include "third_party/blink/public/platform/web_size.h"
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_url_request.h"
#include "third_party/blink/public/web/web_document_loader.h"
#include "third_party/blink/public/web/web_frame.h"
#include "third_party/blink/public/web/web_frame_load_type.h"
#include "third_party/blink/public/web/web_ime_text_span.h"
#include "third_party/blink/public/web/web_navigation_params.h"
#include "third_party/blink/public/web/web_text_direction.h"
#include "v8/include/v8.h"
namespace blink {
class FrameScheduler;
class InterfaceRegistry;
class WebAssociatedURLLoader;
class WebAutofillClient;
class WebContentCaptureClient;
class WebContentSettingsClient;
class WebDocument;
class WebDoubleSize;
class WebDOMEvent;
class WebLocalFrameClient;
class WebFrameWidget;
class WebInputMethodController;
class WebPerformance;
class WebRange;
class WebSecurityOrigin;
class WebScriptExecutionCallback;
class WebSpellCheckPanelHostClient;
class WebString;
class WebTextCheckClient;
class WebURL;
class WebView;
enum class WebTreeScopeType;
struct TransferableMessage;
struct WebAssociatedURLLoaderOptions;
struct WebConsoleMessage;
struct WebContentSecurityPolicyViolation;
struct WebIsolatedWorldInfo;
struct WebMediaPlayerAction;
struct WebPoint;
struct WebPrintParams;
struct WebPrintPresetOptions;
struct WebScriptSource;
struct WebSourceLocation;
// Interface for interacting with in process frames. This contains methods that
// require interacting with a frame's document.
// FIXME: Move lots of methods from WebFrame in here.
class WebLocalFrame : public WebFrame {
public:
// Creates a main local frame for the WebView. Can only be invoked when no
// main frame exists yet. Call Close() to release the returned frame.
// WebLocalFrameClient may not be null.
// TODO(dcheng): The argument order should be more consistent with
// CreateLocalChild() and CreateRemoteChild() in WebRemoteFrame... but it's so
// painful...
BLINK_EXPORT static WebLocalFrame* CreateMainFrame(
WebView*,
WebLocalFrameClient*,
blink::InterfaceRegistry*,
mojo::ScopedMessagePipeHandle,
WebFrame* opener = nullptr,
const WebString& name = WebString(),
WebSandboxFlags = WebSandboxFlags::kNone,
const FeaturePolicy::FeatureState& opener_feature_state =
FeaturePolicy::FeatureState());
// Used to create a provisional local frame. Currently, it's possible for a
// provisional navigation not to commit (i.e. it might turn into a download),
// but this can only be determined by actually trying to load it. The loading
// process depends on having a corresponding LocalFrame in Blink to hold all
// the pending state.
//
// When a provisional frame is first created, it is only partially attached to
// the frame tree. This means that though a provisional frame might have a
// frame owner, the frame owner's content frame does not point back at the
// provisional frame. Similarly, though a provisional frame may have a parent
// frame pointer, the parent frame's children list will not contain the
// provisional frame. Thus, a provisional frame is invisible to the rest of
// Blink unless the navigation commits and the provisional frame is fully
// attached to the frame tree by calling Swap(). It swaps with the
// |previous_web_frame|.
//
// Otherwise, if the load should not commit, call Detach() to discard the
// frame.
BLINK_EXPORT static WebLocalFrame* CreateProvisional(
WebLocalFrameClient*,
blink::InterfaceRegistry*,
mojo::ScopedMessagePipeHandle,
WebFrame* previous_web_frame,
const FramePolicy&);
// Creates a new local child of this frame. Similar to the other methods that
// create frames, the returned frame should be freed by calling Close() when
// it's no longer needed.
virtual WebLocalFrame* CreateLocalChild(WebTreeScopeType,
WebLocalFrameClient*,
blink::InterfaceRegistry*,
mojo::ScopedMessagePipeHandle) = 0;
// Returns the WebFrame associated with the current V8 context. This
// function can return 0 if the context is associated with a Document that
// is not currently being displayed in a Frame.
BLINK_EXPORT static WebLocalFrame* FrameForCurrentContext();
// Returns the frame corresponding to the given context. This can return 0
// if the context is detached from the frame, or if the context doesn't
// correspond to a frame (e.g., workers).
BLINK_EXPORT static WebLocalFrame* FrameForContext(v8::Local<v8::Context>);
// Returns the frame inside a given frame or iframe element. Returns 0 if
// the given element is not a frame, iframe or if the frame is empty.
BLINK_EXPORT static WebLocalFrame* FromFrameOwnerElement(const WebElement&);
virtual WebLocalFrameClient* Client() const = 0;
// Initialization ---------------------------------------------------------
virtual void SetAutofillClient(WebAutofillClient*) = 0;
virtual WebAutofillClient* AutofillClient() = 0;
virtual void SetContentCaptureClient(WebContentCaptureClient*) = 0;
virtual WebContentCaptureClient* ContentCaptureClient() const = 0;
// Closing -------------------------------------------------------------
// Runs unload handlers for this frame.
virtual void DispatchUnloadEvent() = 0;
// Basic properties ---------------------------------------------------
// The urls of the given combination types of favicon (if any) specified by
// the document loaded in this frame. The iconTypesMask is a bit-mask of
// WebIconURL::Type values, used to select from the available set of icon
// URLs
virtual WebVector<WebIconURL> IconURLs(int icon_types_mask) const = 0;
virtual WebDocument GetDocument() const = 0;
// The name of this frame. If no name is given, empty string is returned.
virtual WebString AssignedName() const = 0;
// Sets the name of this frame.
virtual void SetName(const WebString&) = 0;
// Notifies this frame about a user activation from the browser side.
virtual void NotifyUserActivation() = 0;
// Hierarchy ----------------------------------------------------------
// Returns true if the current frame is a local root.
virtual bool IsLocalRoot() const = 0;
// Returns true if the current frame is a provisional frame.
// TODO(https://crbug.com/578349): provisional frames are a hack that should
// be removed.
virtual bool IsProvisional() const = 0;
// Get the highest-level LocalFrame in this frame's in-process subtree.
virtual WebLocalFrame* LocalRoot() = 0;
// Returns the WebFrameWidget associated with this frame if there is one or
// nullptr otherwise.
// TODO(dcheng): The behavior of this will be changing to always return a
// WebFrameWidget. Use IsLocalRoot() if it's important to tell if a frame is a
// local root.
virtual WebFrameWidget* FrameWidget() const = 0;
// Returns the frame identified by the given name. This method supports
// pseudo-names like _self, _top, and _blank and otherwise performs the same
// kind of lookup what |window.open(..., name)| would in Javascript.
virtual WebFrame* FindFrameByName(const WebString& name) = 0;
// Starts scrolling to a specific offset in a frame. Returns false on failure.
virtual bool ScrollTo(const gfx::Point& scrollPosition,
bool animate,
base::OnceClosure on_finish) = 0;
// Navigation Ping --------------------------------------------------------
virtual void SendPings(const WebURL& destination_url) = 0;
// Navigation ----------------------------------------------------------
// Start reloading the current document.
// Note: StartReload() will be deprecated, use StartNavigation() instead.
virtual void StartReload(WebFrameLoadType) = 0;
// Start navigation to the given URL.
virtual void StartNavigation(const WebURLRequest&) = 0;
// View-source rendering mode. Set this before loading an URL to cause
// it to be rendered in view-source mode.
virtual void EnableViewSourceMode(bool) = 0;
virtual bool IsViewSourceModeEnabled() const = 0;
// Returns the document loader that is currently loaded.
virtual WebDocumentLoader* GetDocumentLoader() const = 0;
// Called when a navigation is blocked because a Content Security Policy (CSP)
// is infringed.
virtual void ReportContentSecurityPolicyViolation(
const blink::WebContentSecurityPolicyViolation&) = 0;
// Sets the referrer for the given request to be the specified URL or
// if that is null, then it sets the referrer to the referrer that the
// frame would use for subresources. NOTE: This method also filters
// out invalid referrers (e.g., it is invalid to send a HTTPS URL as
// the referrer for a HTTP request).
virtual void SetReferrerForRequest(WebURLRequest&, const WebURL&) = 0;
// Navigation State -------------------------------------------------------
// Returns true if the current frame's load event has not completed.
bool IsLoading() const override = 0;
// Returns true if there is a pending redirect or location change
// within specified interval (in seconds). This could be caused by:
// * an HTTP Refresh header
// * an X-Frame-Options header
// * the respective http-equiv meta tags
// * window.location value being mutated
// * CSP policy block
// * reload
// * form submission
virtual bool IsNavigationScheduledWithin(
double interval_in_seconds) const = 0;
// Reports a list of unique blink::WebFeature values representing
// Blink features used, performed or encountered by the browser during the
// current page load happening on the frame.
virtual void BlinkFeatureUsageReport(const std::set<int>& features) = 0;
// Informs the renderer that mixed content was found externally regarding this
// frame. Currently only the the browser process can do so. The included data
// is used for instance to report to the CSP policy and to log to the frame
// console.
virtual void MixedContentFound(const WebURL& main_resource_url,
const WebURL& mixed_content_url,
mojom::RequestContextType,
bool was_allowed,
bool had_redirect,
const WebSourceLocation&) = 0;
// Orientation Changes ----------------------------------------------------
// Notify the frame that the screen orientation has changed.
virtual void SendOrientationChangeEvent() = 0;
// Printing ------------------------------------------------------------
// Returns true on success and sets the out parameter to the print preset
// options for the document.
virtual bool GetPrintPresetOptionsForPlugin(const WebNode&,
WebPrintPresetOptions*) = 0;
// CSS3 Paged Media ----------------------------------------------------
// Returns true if page box (margin boxes and page borders) is visible.
virtual bool IsPageBoxVisible(int page_index) = 0;
// Returns true if the page style has custom size information.
virtual bool HasCustomPageSizeStyle(int page_index) = 0;
// Returns the preferred page size and margins in pixels, assuming 96
// pixels per inch. pageSize, marginTop, marginRight, marginBottom,
// marginLeft must be initialized to the default values that are used if
// auto is specified.
virtual void PageSizeAndMarginsInPixels(int page_index,
WebDoubleSize& page_size,
int& margin_top,
int& margin_right,
int& margin_bottom,
int& margin_left) = 0;
// Returns the value for a page property that is only defined when printing.
// printBegin must have been called before this method.
virtual WebString PageProperty(const WebString& property_name,
int page_index) = 0;
// Scripting --------------------------------------------------------------
// Executes script in the context of the current page.
virtual void ExecuteScript(const WebScriptSource&) = 0;
// Executes JavaScript in a new world associated with the web frame.
// The script gets its own global scope and its own prototypes for
// intrinsic JavaScript objects (String, Array, and so-on). It also
// gets its own wrappers for all DOM nodes and DOM constructors.
//
// worldID must be > 0 (as 0 represents the main world).
// worldID must be < kEmbedderWorldIdLimit, high number used internally.
virtual void ExecuteScriptInIsolatedWorld(int world_id,
const WebScriptSource&) = 0;
// worldID must be > 0 (as 0 represents the main world).
// worldID must be < kEmbedderWorldIdLimit, high number used internally.
// DEPRECATED: Use WebLocalFrame::requestExecuteScriptInIsolatedWorld.
WARN_UNUSED_RESULT virtual v8::Local<v8::Value>
ExecuteScriptInIsolatedWorldAndReturnValue(int world_id,
const WebScriptSource&) = 0;
// Sets up an isolated world by associating a |world_id| with |info|.
// worldID must be > 0 (as 0 represents the main world).
// worldID must be < kEmbedderWorldIdLimit, high number used internally.
virtual void SetIsolatedWorldInfo(int world_id,
const WebIsolatedWorldInfo& info) = 0;
// Executes script in the context of the current page and returns the value
// that the script evaluated to.
// DEPRECATED: Use WebLocalFrame::requestExecuteScriptAndReturnValue.
virtual v8::Local<v8::Value> ExecuteScriptAndReturnValue(
const WebScriptSource&) = 0;
// Call the function with the given receiver and arguments, bypassing
// canExecute().
virtual v8::MaybeLocal<v8::Value> CallFunctionEvenIfScriptDisabled(
v8::Local<v8::Function>,
v8::Local<v8::Value>,
int argc,
v8::Local<v8::Value> argv[]) = 0;
// Returns the V8 context for associated with the main world and this
// frame. There can be many V8 contexts associated with this frame, one for
// each isolated world and one for the main world. If you don't know what
// the "main world" or an "isolated world" is, then you probably shouldn't
// be calling this API.
virtual v8::Local<v8::Context> MainWorldScriptContext() const = 0;
// Executes script in the context of the current page and returns the value
// that the script evaluated to with callback. Script execution can be
// suspend.
// DEPRECATED: Prefer requestExecuteScriptInIsolatedWorld().
virtual void RequestExecuteScriptAndReturnValue(
const WebScriptSource&,
bool user_gesture,
WebScriptExecutionCallback*) = 0;
// Requests execution of the given function, but allowing for script
// suspension and asynchronous execution.
virtual void RequestExecuteV8Function(v8::Local<v8::Context>,
v8::Local<v8::Function>,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> argv[],
WebScriptExecutionCallback*) = 0;
enum ScriptExecutionType {
// Execute script synchronously, unless the page is suspended.
kSynchronous,
// Execute script asynchronously.
kAsynchronous,
// Execute script asynchronously, blocking the window.onload event.
kAsynchronousBlockingOnload
};
// worldID must be > 0 (as 0 represents the main world).
// worldID must be < kEmbedderWorldIdLimit, high number used internally.
virtual void RequestExecuteScriptInIsolatedWorld(
int world_id,
const WebScriptSource* source_in,
unsigned num_sources,
bool user_gesture,
ScriptExecutionType,
WebScriptExecutionCallback*) = 0;
// Logs to the console associated with this frame.
virtual void AddMessageToConsole(const WebConsoleMessage&) = 0;
// Expose modal dialog methods to avoid having to go through JavaScript.
virtual void Alert(const WebString& message) = 0;
virtual bool Confirm(const WebString& message) = 0;
virtual WebString Prompt(const WebString& message,
const WebString& default_value) = 0;
// Debugging -----------------------------------------------------------
virtual void BindDevToolsAgent(
mojo::ScopedInterfaceEndpointHandle devtools_agent_host_ptr_info,
mojo::ScopedInterfaceEndpointHandle devtools_agent_request) = 0;
// Editing -------------------------------------------------------------
virtual void SetMarkedText(const WebString& text,
unsigned location,
unsigned length) = 0;
virtual void UnmarkText() = 0;
virtual bool HasMarkedText() const = 0;
virtual WebRange MarkedRange() const = 0;
// Returns the text range rectangle in the viepwort coordinate space.
virtual bool FirstRectForCharacterRange(unsigned location,
unsigned length,
WebRect&) const = 0;
// Returns the index of a character in the Frame's text stream at the given
// point. The point is in the viewport coordinate space. Will return
// WTF::notFound if the point is invalid.
virtual size_t CharacterIndexForPoint(const WebPoint&) const = 0;
// Supports commands like Undo, Redo, Cut, Copy, Paste, SelectAll,
// Unselect, etc. See EditorCommand.cpp for the full list of supported
// commands.
virtual bool ExecuteCommand(const WebString&) = 0;
virtual bool ExecuteCommand(const WebString&, const WebString& value) = 0;
virtual bool IsCommandEnabled(const WebString&) const = 0;
// Returns the text direction at the start and end bounds of the current
// selection. If the selection range is empty, it returns false.
virtual bool SelectionTextDirection(WebTextDirection& start,
WebTextDirection& end) const = 0;
// Returns true if the selection range is nonempty and its anchor is first
// (i.e its anchor is its start).
virtual bool IsSelectionAnchorFirst() const = 0;
// Changes the text direction of the selected input node.
virtual void SetTextDirection(WebTextDirection) = 0;
// Selection -----------------------------------------------------------
virtual bool HasSelection() const = 0;
virtual WebRange SelectionRange() const = 0;
virtual WebString SelectionAsText() const = 0;
virtual WebString SelectionAsMarkup() const = 0;
// Expands the selection to a word around the caret and returns
// true. Does nothing and returns false if there is no caret or
// there is ranged selection.
virtual bool SelectWordAroundCaret() = 0;
// DEPRECATED: Use moveRangeSelection.
virtual void SelectRange(const WebPoint& base, const WebPoint& extent) = 0;
enum HandleVisibilityBehavior {
// Hide handle(s) in the new selection.
kHideSelectionHandle,
// Show handle(s) in the new selection.
kShowSelectionHandle,
// Keep the current handle visibility.
kPreserveHandleVisibility,
};
virtual void SelectRange(const WebRange&,
HandleVisibilityBehavior,
mojom::SelectionMenuBehavior) = 0;
virtual WebString RangeAsText(const WebRange&) = 0;
// Move the current selection to the provided viewport point/points. If the
// current selection is editable, the new selection will be restricted to
// the root editable element.
// |TextGranularity| represents character wrapping granularity. If
// WordGranularity is set, WebFrame extends selection to wrap word.
virtual void MoveRangeSelection(
const WebPoint& base,
const WebPoint& extent,
WebFrame::TextGranularity = kCharacterGranularity) = 0;
virtual void MoveCaretSelection(const WebPoint&) = 0;
virtual bool SetEditableSelectionOffsets(int start, int end) = 0;
virtual bool SetCompositionFromExistingText(
int composition_start,
int composition_end,
const WebVector<WebImeTextSpan>& ime_text_spans) = 0;
virtual void ExtendSelectionAndDelete(int before, int after) = 0;
virtual void SetCaretVisible(bool) = 0;
// Moves the selection extent point. This function does not allow the
// selection to collapse. If the new extent is set to the same position as
// the current base, this function will do nothing.
virtual void MoveRangeSelectionExtent(const WebPoint&) = 0;
// Replaces the selection with the input string.
virtual void ReplaceSelection(const WebString&) = 0;
// Deletes text before and after the current cursor position, excluding the
// selection. The lengths are supplied in UTF-16 Code Unit, not in code points
// or in glyphs.
virtual void DeleteSurroundingText(int before, int after) = 0;
// A variant of deleteSurroundingText(int, int). Major differences are:
// 1. The lengths are supplied in code points, not in UTF-16 Code Unit or in
// glyphs.
// 2. This method does nothing if there are one or more invalid surrogate
// pairs in the requested range.
virtual void DeleteSurroundingTextInCodePoints(int before, int after) = 0;
virtual void ExtractSmartClipData(WebRect rect_in_viewport,
WebString& clip_text,
WebString& clip_html,
WebRect& clip_rect) = 0;
// Spell-checking support -------------------------------------------------
virtual void SetTextCheckClient(WebTextCheckClient*) = 0;
virtual void SetSpellCheckPanelHostClient(WebSpellCheckPanelHostClient*) = 0;
virtual WebSpellCheckPanelHostClient* SpellCheckPanelHostClient() const = 0;
virtual void ReplaceMisspelledRange(const WebString&) = 0;
virtual void RemoveSpellingMarkers() = 0;
virtual void RemoveSpellingMarkersUnderWords(
const WebVector<WebString>& words) = 0;
// Content Settings -------------------------------------------------------
virtual void SetContentSettingsClient(WebContentSettingsClient*) = 0;
// Image reload -----------------------------------------------------------
// If the provided node is an image, reload the image disabling Lo-Fi.
virtual void ReloadImage(const WebNode&) = 0;
// Reloads all the Lo-Fi images in this WebLocalFrame. Ignores the cache and
// reloads from the network.
virtual void ReloadLoFiImages() = 0;
// Feature usage logging --------------------------------------------------
virtual void DidCallAddSearchProvider() = 0;
virtual void DidCallIsSearchProviderInstalled() = 0;
// Iframe sandbox ---------------------------------------------------------
// TODO(ekaramad): This method is only exposed for testing for certain tests
// outside of blink/ that are interested in approximate value of the
// FrameReplicationState. This method should be replaced with one in content/
// where the notion of FrameReplicationState is relevant to.
// Returns the effective sandbox flags which are inherited from their parent
// frame.
virtual WebSandboxFlags EffectiveSandboxFlagsForTesting() const = 0;
// Returns false if this frame, or any parent frame is sandboxed and does not
// have the flag "allow-downloads-without-user-activation" set.
virtual bool IsAllowedToDownloadWithoutUserActivation() const = 0;
// Find-in-page -----------------------------------------------------------
// Searches a frame for a given string. Only used for testing.
//
// If a match is found, this function will select it (scrolling down to
// make it visible if needed) and fill in selectionRect with the
// location of where the match was found (in window coordinates).
//
// If no match is found, this function clears all tickmarks and
// highlighting.
//
// Returns true if the search string was found, false otherwise.
virtual bool FindForTesting(int identifier,
const WebString& search_text,
bool match_case,
bool forward,
bool find_next,
bool force,
bool wrap_within_frame) = 0;
// Set the tickmarks for the frame. This will override the default tickmarks
// generated by find results. If this is called with an empty array, the
// default behavior will be restored.
virtual void SetTickmarks(const WebVector<WebRect>&) = 0;
// Context menu -----------------------------------------------------------
// Returns the node that the context menu opened over.
virtual WebNode ContextMenuNode() const = 0;
// Copy to the clipboard the image located at a particular point in visual
// viewport coordinates.
virtual void CopyImageAt(const WebPoint&) = 0;
// Save as the image located at a particular point in visual viewport
// coordinates.
virtual void SaveImageAt(const WebPoint&) = 0;
// Events --------------------------------------------------------------
// Dispatches a message event on the current DOMWindow in this WebFrame.
virtual void DispatchMessageEventWithOriginCheck(
const WebSecurityOrigin& intended_target_origin,
const WebDOMEvent&,
bool has_user_gesture) = 0;
// TEMP: Usage count for chrome.loadtimes deprecation.
// This will be removed following the deprecation.
virtual void UsageCountChromeLoadTimes(const WebString& metric) = 0;
// Portals -------------------------------------------------------------
// Dispatches an event when a Portal gets activated. |portal_token| is the
// portal's unique identifier, the message pipe |portal_pipe| is the
// portal's mojo interface, and the message pipe |portal_client_pipe| is
// a mojo interface to communicate back with the caller of the portal's
// mojo interface. |data| is an optional message sent together with the
// portal's activation.
using OnPortalActivatedCallback = base::OnceCallback<void(bool)>;
virtual void OnPortalActivated(
const base::UnguessableToken& portal_token,
mojo::ScopedInterfaceEndpointHandle portal_pipe,
mojo::ScopedInterfaceEndpointHandle portal_client_pipe,
TransferableMessage data,
OnPortalActivatedCallback callback) = 0;
// Forwards message to the PortalHost object exposed by the frame.
virtual void ForwardMessageFromHost(
TransferableMessage message,
const WebSecurityOrigin& source_origin,
const base::Optional<WebSecurityOrigin>& target_origin) = 0;
// Scheduling ---------------------------------------------------------------
virtual FrameScheduler* Scheduler() const = 0;
// Task queues --------------------------------------------------------------
// Returns frame-specific task runner to run tasks of this type on.
// They have the same lifetime as the frame.
virtual scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner(
TaskType) = 0;
// Returns the WebInputMethodController associated with this local frame.
virtual WebInputMethodController* GetInputMethodController() = 0;
// Loading ------------------------------------------------------------------
// Returns an AssociatedURLLoader that is associated with this frame. The
// loader will, for example, be cancelled when WebFrame::stopLoading is
// called.
//
// FIXME: stopLoading does not yet cancel an associated loader!!
virtual WebAssociatedURLLoader* CreateAssociatedURLLoader(
const WebAssociatedURLLoaderOptions&) = 0;
// Check whether loading has completed based on subframe state, etc.
virtual void CheckCompleted() = 0;
// Geometry -----------------------------------------------------------------
// NOTE: These routines do not force page layout so their results may
// not be accurate if the page layout is out-of-date.
// The scroll offset from the top-left corner of the frame in pixels.
virtual WebSize GetScrollOffset() const = 0;
virtual void SetScrollOffset(const WebSize&) = 0;
// The size of the document in this frame.
virtual WebSize DocumentSize() const = 0;
// Returns true if the contents (minus scrollbars) has non-zero area.
virtual bool HasVisibleContent() const = 0;
// Printing ------------------------------------------------------------
// Dispatch |beforeprint| event, and execute event handlers. They might detach
// this frame from the owner WebView.
// This function should be called before pairs of PrintBegin() and PrintEnd().
virtual void DispatchBeforePrintEvent() = 0;
// Reformats the WebFrame for printing. WebPrintParams specifies the printable
// content size, paper size, printable area size, printer DPI and print
// scaling option. If constrainToNode node is specified, then only the given
// node is printed (for now only plugins are supported), instead of the entire
// frame.
// Returns the number of pages that can be printed at the given
// page size.
virtual int PrintBegin(const WebPrintParams&,
const WebNode& constrain_to_node = WebNode()) = 0;
// Returns the page shrinking factor calculated by webkit (usually
// between 1/1.33 and 1/2). Returns 0 if the page number is invalid or
// not in printing mode.
virtual float GetPrintPageShrink(int page) = 0;
// Prints one page, and returns the calculated page shrinking factor
// (usually between 1/1.33 and 1/2). Returns 0 if the page number is
// invalid or not in printing mode.
virtual float PrintPage(int page_to_print, cc::PaintCanvas*) = 0;
// Reformats the WebFrame for screen display.
virtual void PrintEnd() = 0;
// Dispatch |afterprint| event, and execute event handlers. They might detach
// this frame from the owner WebView.
// This function should be called after pairs of PrintBegin() and PrintEnd().
virtual void DispatchAfterPrintEvent() = 0;
// Focus --------------------------------------------------------------
// Advance the focus of the WebView to next text input element from current
// input field wrt sequential navigation with TAB or Shift + TAB
// WebFocusTypeForward simulates TAB and WebFocusTypeBackward simulates
// Shift + TAB. (Will be extended to other form controls like select element,
// checkbox, radio etc.)
virtual void AdvanceFocusInForm(WebFocusType) = 0;
// Returns whether the currently focused field could be autofilled by the
// active WebAutofillClient.
virtual bool CanFocusedFieldBeAutofilled() const = 0;
// Performance --------------------------------------------------------
virtual WebPerformance Performance() const = 0;
// Ad Tagging ---------------------------------------------------------
// True if the frame is thought (heuristically) to be created for
// advertising purposes.
virtual bool IsAdSubframe() const = 0;
// This setter is available in case the embedder has more information about
// whether or not the frame is an ad.
virtual void SetIsAdSubframe(blink::mojom::AdFrameType ad_frame_type) = 0;
// Testing ------------------------------------------------------------------
// Dumps the layer tree, used by the accelerated compositor, in
// text form. This is used only by web tests.
virtual WebString GetLayerTreeAsTextForTesting(
bool show_debug_info = false) const = 0;
// Prints the frame into the canvas, with page boundaries drawn as one pixel
// wide blue lines. This method exists to support web tests.
virtual void PrintPagesForTesting(cc::PaintCanvas*, const WebSize&) = 0;
// Returns the bounds rect for current selection. If selection is performed
// on transformed text, the rect will still bound the selection but will
// not be transformed itself. If no selection is present, the rect will be
// empty ((0,0), (0,0)).
virtual WebRect GetSelectionBoundsRectForTesting() const = 0;
// Performs the specified media player action on the media element at the
// given location.
virtual void PerformMediaPlayerAction(const WebPoint&,
const WebMediaPlayerAction&) = 0;
virtual void SetLifecycleState(mojom::FrameLifecycleState state) = 0;
virtual void WasHidden() = 0;
virtual void WasShown() = 0;
protected:
explicit WebLocalFrame(WebTreeScopeType scope) : WebFrame(scope) {}
// Inherited from WebFrame, but intentionally hidden: it never makes sense
// to call these on a WebLocalFrame.
bool IsWebLocalFrame() const override = 0;
WebLocalFrame* ToWebLocalFrame() override = 0;
bool IsWebRemoteFrame() const override = 0;
WebRemoteFrame* ToWebRemoteFrame() override = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_LOCAL_FRAME_H_
| [
"trofimov_d_a@magnit.ru"
] | trofimov_d_a@magnit.ru |
8e6b12a2cd856ff232941ef7baf6c68063297d74 | ac7237f51c8332fa8b44a5776bfc7f4727ff19ea | /client.m.cpp | bb4db96fa60be1dd567e176556ec02729c2a509a | [] | no_license | ChengJoyceJi/BloombergCodeB | 2be9770d96c41ccf656afed7f067176902e39690 | 1dbb6545ad4e6b627c96efe7b5b6086afc5dbb13 | refs/heads/master | 2021-03-12T19:24:38.500858 | 2015-03-21T11:58:45 | 2015-03-21T11:58:45 | 32,619,190 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,244 | cpp | /*
* File: main.cpp
* Author: atamarkin2
*
* Created on June 26, 2014, 5:11 PM
*/
#include <string>
#include "galik_socketstream.h"
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cstring>
using namespace std;
using namespace galik;
using namespace galik::net;
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
size_t start = 0, end = 0;
while ((end = s.find(delim, start)) != string::npos) {
elems.push_back(s.substr(start, end - start));
start = end + 1;
}
elems.push_back(s.substr(start));
return elems;
}
/*
*
*/
int main(int argc, char** argv) {
if (argc < 5) {
cout << "args: <user> <password> <host> <port> <command>" << endl;
cout << argc;
exit(1);
}
string name(argv[1]);
string password(argv[2]);
socketstream ss;
ss.open(argv[3], atoi(argv[4]));
string command("");
for (int i = 5; i < argc; i++) {
command += argv[i];
command += " ";
}
//command;
ss << name << " " << password << "\n" << command << "\nCLOSE_CONNECTION" << endl;
while (ss.good() && !ss.eof()) {
string line;
getline(ss, line);
cout << line << endl;
}
return 0;
}
| [
"jicheng8524@hotmail.com"
] | jicheng8524@hotmail.com |
bf29ea5b95a51a2e9c211a4b802a82448c89d56d | cc99f8aac33b56f040a7be3dbc4c90812df1d40d | /Directx9sdk/Samples/C++/Direct3D/EffectEdit/OptionsView.cpp | 653a6dac78fcb05aa875917ea99265de83b46a0c | [] | no_license | Kiddinglife/t3d | a71231f298646fc57b145783f0935914ae29fdf1 | bec8ed964588611ebf4d11bb4518a7ab92958a38 | refs/heads/main | 2023-03-02T06:07:18.513787 | 2021-02-14T10:12:16 | 2021-02-14T10:12:16 | 338,776,439 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,426 | cpp | // OptionsView.cpp : implementation file
//
#include "stdafx.h"
#include "EffectEdit.h"
#include "EffectDoc.h"
#include "OptionsView.h"
#include "UIElements.h"
#include "RenderView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COptionsView
IMPLEMENT_DYNCREATE(COptionsView, CFormView)
COptionsView::COptionsView()
: CFormView(COptionsView::IDD)
{
//{{AFX_DATA_INIT(COptionsView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
COptionsView::~COptionsView()
{
}
void COptionsView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptionsView)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptionsView, CFormView)
//{{AFX_MSG_MAP(COptionsView)
ON_WM_SIZE()
ON_CBN_SELCHANGE(IDC_TECHNIQUELIST, OnChangeTechnique)
ON_CBN_SELCHANGE(IDC_PASSLIST, OnChangePass)
ON_BN_CLICKED(IDC_SHOWSTATS, OnShowStats)
ON_BN_CLICKED(IDC_WIREFRAME, OnFillModeChange)
ON_BN_CLICKED(IDC_SELECTEDPASS, OnChangeRenderPass)
ON_BN_CLICKED(IDC_NOTEXTURES, OnFillModeChange)
ON_BN_CLICKED(IDC_WITHTEXTURES, OnFillModeChange)
ON_BN_CLICKED(IDC_UPTOSELECTEDPASS, OnChangeRenderPass)
ON_BN_CLICKED(IDC_ALLPASSES, OnChangeRenderPass)
ON_BN_CLICKED(IDC_RESETCAMERA, OnResetCamera)
ON_BN_CLICKED(IDC_RENDERCONTINUOUSLY, OnChangeRenderTiming)
ON_BN_CLICKED(IDC_RENDERONREQUEST, OnChangeRenderTiming)
ON_BN_CLICKED(IDC_RENDER, OnRender)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COptionsView diagnostics
#ifdef _DEBUG
void COptionsView::AssertValid() const
{
CFormView::AssertValid();
}
void COptionsView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CEffectDoc* COptionsView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEffectDoc)));
return (CEffectDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// COptionsView message handlers
void COptionsView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
}
void COptionsView::SetTechniqueNameList( CStringList& techniqueNameList, int iTechniqueCur )
{
CComboBox* pComboBox = (CComboBox*)GetDlgItem( IDC_TECHNIQUELIST );
if( pComboBox == NULL )
return;
pComboBox->ResetContent();
POSITION pos = techniqueNameList.GetHeadPosition();
while (pos != NULL)
{
CString str = techniqueNameList.GetNext(pos);
pComboBox->AddString( str );
}
pComboBox->SetCurSel( iTechniqueCur );
PostMessage( WM_COMMAND,
MAKEWPARAM(IDC_TECHNIQUELIST, CBN_SELCHANGE),
(LPARAM)GetDlgItem( IDC_TECHNIQUELIST )->GetSafeHwnd() );
pComboBox->EnableWindow(pComboBox->GetCount() > 1);
}
void COptionsView::OnChangeTechnique()
{
CComboBox* pComboBox = (CComboBox*)GetDlgItem( IDC_TECHNIQUELIST );
int iTech = pComboBox->GetCurSel();
if( iTech >= 0 )
{
CString strTechName;
pComboBox->GetLBText( iTech, strTechName );
CRenderView* pRenderView = GetDocument()->GetRenderView();
pRenderView->SetTechnique( iTech, strTechName );
CStringList passNameList;
pRenderView->GetPassNameList( iTech, passNameList );
SetPassNameList( passNameList, 0 );
}
}
void COptionsView::SetPassNameList( CStringList& passNameList, int iPassCur )
{
CComboBox* pComboBox = (CComboBox*)GetDlgItem( IDC_PASSLIST );
if( pComboBox == NULL )
return;
pComboBox->ResetContent();
POSITION pos = passNameList.GetHeadPosition();
while (pos != NULL)
{
CString str = passNameList.GetNext(pos);
pComboBox->AddString( str );
}
pComboBox->SetCurSel( iPassCur );
PostMessage( WM_COMMAND,
MAKEWPARAM(IDC_PASSLIST, CBN_SELCHANGE),
(LPARAM)GetDlgItem( IDC_PASSLIST )->GetSafeHwnd() );
pComboBox->EnableWindow(pComboBox->GetCount() > 1);
}
void COptionsView::OnChangePass()
{
CComboBox* pComboBox = (CComboBox*)GetDlgItem( IDC_PASSLIST );
int iPass = pComboBox->GetCurSel();
if( iPass >= 0 )
{
CString strPassName;
pComboBox->GetLBText( iPass, strPassName );
CRenderView* pRenderView = GetDocument()->GetRenderView();
pRenderView->SetPass( iPass, strPassName );
}
}
void COptionsView::OnShowStats()
{
BOOL bShowStats = IsDlgButtonChecked( IDC_SHOWSTATS );
GetDocument()->ShowStats( bShowStats );
}
void COptionsView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
BOOL bShowStats = GetDocument()->GetShowStats();
CheckDlgButton( IDC_SHOWSTATS, bShowStats );
CheckRadioButton( IDC_WIREFRAME, IDC_WITHTEXTURES, IDC_WITHTEXTURES );
CheckRadioButton( IDC_SELECTEDPASS, IDC_ALLPASSES, IDC_ALLPASSES );
CheckRadioButton( IDC_RENDERCONTINUOUSLY, IDC_RENDERONREQUEST,
((CEffectEditApp*)AfxGetApp())->RenderContinuously() ? IDC_RENDERCONTINUOUSLY : IDC_RENDERONREQUEST );
GetDlgItem( IDC_RENDER )->EnableWindow(!((CEffectEditApp*)AfxGetApp())->RenderContinuously() );
OnFillModeChange();
OnChangeRenderPass();
OnChangeRenderTiming();
}
void COptionsView::OnFillModeChange()
{
CRenderView* pRenderView = GetDocument()->GetRenderView();
pRenderView->SetWireframe( IsDlgButtonChecked( IDC_WIREFRAME ) );
pRenderView->SetNoTextures( IsDlgButtonChecked( IDC_NOTEXTURES ) );
}
void COptionsView::OnChangeRenderPass()
{
CRenderView* pRenderView = GetDocument()->GetRenderView();
pRenderView->SetSelectedPassOnly( IsDlgButtonChecked( IDC_SELECTEDPASS ) );
pRenderView->SetUpToSelectedPassOnly( IsDlgButtonChecked( IDC_UPTOSELECTEDPASS ) );
}
void COptionsView::OnResetCamera()
{
CRenderView* pRenderView = GetDocument()->GetRenderView();
pRenderView->ResetCamera();
}
void COptionsView::OnChangeRenderTiming()
{
bool bRenderContinuously = (IsDlgButtonChecked( IDC_RENDERCONTINUOUSLY ) != 0);
((CEffectEditApp*)AfxGetApp())->SetRenderContinuously( bRenderContinuously );
GetDlgItem( IDC_RENDER )->EnableWindow( !bRenderContinuously );
}
void COptionsView::OnRender()
{
AfxGetApp()->GetMainWnd()->SendMessage(WM_COMMAND, ID_VIEW_RENDER);
}
| [
"jake.zhang.work@gmail.com"
] | jake.zhang.work@gmail.com |
a7bd2d423584a43cc54b713b1f63a2ed76a0fa44 | e2e3a6e53e5ac62d216b2e6359865c763bf45432 | /Chapter3/EXC3_17.cpp | 08ba3620a92011381e136f721e6bf20a168063ce | [] | no_license | AyiStar/CppPrimer | b34b4fc7843977e2ead715c6772147d0e9d35875 | 7b48ba28d2fc41581edcb4812e69e2c98fa90ab0 | refs/heads/master | 2021-01-11T00:22:21.265069 | 2017-03-15T12:16:26 | 2017-03-15T12:16:26 | 77,778,019 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 819 | cpp | //
// Created by ayistar on 1/7/17.
//
// read a sequence of words from cin
// and store the values in a vector
// then, process the vector and change each word to uppercase
// print the transformed elements, eight words to a line
#include <iostream>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main()
{
string str;
vector<string> svec;
while(cin >> str){
svec.push_back(str);
}
for(auto &s : svec){
for(auto &c : s){
c = toupper(c);
}
}
for(vector<string>::size_type i = 0
; i < svec.size(); i++ ){
cout << svec[i];
if((i+1) % 8)
cout << " ";
else
cout << endl;
}
cout << endl;
return 0;
}
| [
"824476660@qq.com"
] | 824476660@qq.com |
1eb45c846a0b06b635eee20c0cf4fbe050b67780 | 1c27ad1ad5d5625afdaf421cc518bc0c632da970 | /Classes/CCLabelBMFontAnimated.h | bd999f197d5987f541e5b31ee8778f3521dd306d | [] | no_license | Refetizm/Fly-To-Masomo | 2a0619ae350314d3bec30d4ca4c82a9a7e482f9b | 6dcc000647b449aa2eee1b86b4844ff07459c298 | refs/heads/master | 2020-08-30T23:52:31.740639 | 2019-11-01T11:05:28 | 2019-11-01T11:05:28 | 218,526,204 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,863 | h | //
// CCLabelAnimated.h
// CCLabelAnimated
//
// Created by Steven Barnegren on 23/03/2015.
//
//
/*
Copyright (c) 2015 Steve Barnegren
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __CCLabelAnimated__CCLabelAnimated__
#define __CCLabelAnimated__CCLabelAnimated__
#include <stdio.h>
#include "cocos2d.h"
class CCLabelBMFontAnimated : public cocos2d::Label {
public:
// ONLY USE THIS FUNCTION FOR CREATION
static CCLabelBMFontAnimated* createWithBMFont(const std::string& bmfontFilePath, const std::string& text,const cocos2d::TextHAlignment& alignment /* = TextHAlignment::LEFT */, int maxLineWidth /* = 0 */, const cocos2d::Vec2& imageOffset /* = Vec2::ZERO */);
static CCLabelBMFontAnimated* createWithTTF(const std::string& text, const std::string& fontFile, float fontSize, const cocos2d::Size& dimensions /* = Size::ZERO */, cocos2d::TextHAlignment hAlignment /* = TextHAlignment::LEFT */, cocos2d::TextVAlignment vAlignment /* = TextVAlignment::TOP */);
//FUNCTIONS TO SET BASIC CHARACTER SPRITE PROPERTIES AT INDEX
void setCharScale(int index, float s);
void setCharOpacity(int index, float o);
void setCharRotation(int index, float r);
//FUNCTIONS TO SET BASIC PROPERTIES OF ALL CHARACTER SPRITES
void setAllCharsScale(float s);
void setAllCharsOpacity(float o);
void setAllCharsRotation(float r);
void offsetAllCharsPositionBy(cocos2d::Point offset);
//FUNCTIONS TO RUN CUSTOM ACTIONS ON CHARATER SPRITES
void runActionOnSpriteAtIndex(int index, cocos2d::FiniteTimeAction* action);
void runActionOnAllSprites(cocos2d::Action* action);
void runActionOnAllSprites(cocos2d::Action* action, bool removeOnCompletion);
void runActionOnAllSprites(cocos2d::Action* action, bool removeOnCompletion, cocos2d::CallFunc *callFuncOnCompletion);
void stopActionsOnAllSprites();
//for the 'run actions sequentially' functions, duration refers to the total time to complete actions on all letters, minus the duration of the action itself
void runActionOnAllSpritesSequentially(cocos2d::FiniteTimeAction* action, float duration, bool removeOnCompletion, cocos2d::CallFunc *callFuncOnCompletion);
void runActionOnAllSpritesSequentially(cocos2d::FiniteTimeAction* action, float duration, bool removeOnCompletion);
void runActionOnAllSpritesSequentially(cocos2d::FiniteTimeAction* action, float duration);
void runActionOnAllSpritesSequentiallyReverse(cocos2d::FiniteTimeAction* action, float duration, bool removeOnCompletion, cocos2d::CallFunc *callFuncOnCompletion);
void runActionOnAllSpritesSequentiallyReverse(cocos2d::FiniteTimeAction* action, float duration, bool removeOnCompletion);
void runActionOnAllSpritesSequentiallyReverse(cocos2d::FiniteTimeAction* action, float duration);
//ANIMATIONS
//fly ins
void animateInFlyInFromLeft(float duration);
void animateInFlyInFromRight(float duration);
void animateInFlyInFromTop(float duration);
void animateInFlyInFromBottom(float duration);
//misc animate ins
void animateInTypewriter(float duration);
void animateInDropFromTop(float duration);
void animateInSwell(float duration);
void animateInRevealFromLeft(float duration);
void animateInSpin(float duration, int spins);
void animateInVortex(float duration, int spins);
//misc animations
void animateSwell(float duration);
void animateJump(float duration, float height);
void animateStretchElastic(float stretchDuration, float releaseDuration, float stretchAmount);
void animateRainbow(float duration);
void flyPastAndRemove();
private:
int numLetters();
void animateInVortex(bool removeOnCompletion, bool createGhosts, float duration, int spins);
};
#endif /* defined(__CCLabelAnimated__CCLabelAnimated__) */
| [
"noreply@github.com"
] | Refetizm.noreply@github.com |
7f0812844fef37b04797fa28719673f55903a335 | 5525d270883134aff70cc686ca3be2484ceffb9c | /GEx/include/gex/algorithm/length.hpp | 1d52a6357f1a055ba3102d80a1e7b7b44e793182 | [] | no_license | WilstonOreo/Tomo | 7907a3811c19b70eb64c978ce0feba291adb9e5c | c5bcdd18878f7950b8e5f607d3d48aaf9d95a05e | refs/heads/master | 2021-01-19T01:26:39.373934 | 2016-06-21T11:43:02 | 2016-06-21T11:43:02 | 61,629,539 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 255 | hpp | #pragma once
#include <boost/geometry/algorithm/perimeter.hpp>
namespace gex
{
namespace algorithm
{
namespace functor
{
template<typename PRIMITIVE>
struct Length
{
};
}
void length()
}
}
| [
"m@cr8tr.org"
] | m@cr8tr.org |
5a47825266f9ebe8f2f97b7bcb3a0d3b676d1828 | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE401_Memory_Leak/s02/CWE401_Memory_Leak__new_char_74b.cpp | a71bda7b51b9cf7fb97a03ff263579216f78305b | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 1,446 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE401_Memory_Leak__new_char_74b.cpp
Label Definition File: CWE401_Memory_Leak__new.label.xml
Template File: sources-sinks-74b.tmpl.cpp
*/
/*
* @description
* CWE: 401 Memory Leak
* BadSource: Allocate data using new
* GoodSource: Allocate data on the stack
* Sinks:
* GoodSink: call delete on data
* BadSink : no deallocation of data
* Flow Variant: 74 Data flow: data passed in a map from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <map>
#ifndef _WIN32
#include <wchar.h>
#endif
using namespace std;
namespace CWE401_Memory_Leak__new_char_74
{
#ifndef OMITBAD
void badSink(map<int, char *> dataMap)
{
/* copy data out of dataMap */
char * data = dataMap[2];
/* POTENTIAL FLAW: No deallocation */
; /* empty statement needed for some flow variants */
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void goodG2BSink(map<int, char *> dataMap)
{
char * data = dataMap[2];
/* POTENTIAL FLAW: No deallocation */
; /* empty statement needed for some flow variants */
}
/* goodB2G uses the BadSource with the GoodSink */
void goodB2GSink(map<int, char *> dataMap)
{
char * data = dataMap[2];
/* FIX: Deallocate memory */
delete data;
}
#endif /* OMITGOOD */
} /* close namespace */
| [
"yzhang0701@gmail.com"
] | yzhang0701@gmail.com |
f9e8215785c9a755ca687553e55ebe29db7675a9 | 3f1e036b9629462bcfd7fb0b3efe7bbe34cdb3ee | /iterator.cpp | 5f5ef7b9a280b0caa002eb730884ca5ae80c9731 | [] | no_license | vjain003/Lab_7-UCR_CS100 | 19427efaf677211abb1c6834735c0c5a36a95f07 | e5a53d0a0b06f160233ec96dde2b1c447e84108b | refs/heads/master | 2021-09-10T04:32:36.609503 | 2018-03-21T01:49:00 | 2018-03-21T01:49:00 | 124,028,441 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,218 | cpp | #include "iterator.h"
void PreorderIterator::first() {
// Empty the stack (just in case we had something leftover from another run)
// Create an iterator for the Base* that we built the iterator for
// Initialize that iterator and push it onto the stack
while(iterators.size() > 0)
{
iterators.pop();
}
iterators.push(self_ptr -> create_iterator());
}
void PreorderIterator::next() {
// Create an iterator for the item on the top of the stack
// Initialize the iterator and push it onto the stack
// As long as the top iterator on the stack is_done(), pop it off the stack and then advance whatever iterator is now on top of the stack
Iterator *iter = iterators.top()->current()->create_iterator();
iter->first();
iterators.push(iter);
while(!iterators.empty() && iterators.top()->is_done() ) {
iterators.pop();
if (!iterators.empty()) {
iterators.top()->next();
}
}
}
bool PreorderIterator::is_done() {
// Return true if there are no more elements on the stack to iterate
if(iterators.empty() ) {
return true;
}
return false;
}
Base* PreorderIterator::current() {
// Return the current for the top iterator in the stack
if(!iterators.empty() ) {
return iterators.top()->current();
}
else {
return NULL;
}
}
void OperatorIterator::first() {
current_ptr = self_ptr->get_left();
}
void OperatorIterator::next() {
if(current_ptr == self_ptr) {
current_ptr = self_ptr->get_left();
}
else if(current_ptr == self_ptr->get_left()) {
current_ptr = self_ptr->get_right();
}
else {
current_ptr = NULL;
}
}
bool OperatorIterator::is_done() {
if(current_ptr == NULL) {
return true;
}
return false;
}
Base* OperatorIterator::current() {
return current_ptr;
}
s
void UnaryIterator::first() {
current_ptr = self_ptr->get_left();
}
void UnaryIterator::next() {
current_ptr = NULL;
}
bool UnaryIterator::is_done() {
if(current_ptr == NULL) {
return true;
}
return false;
}
Base* UnaryIterator::current() {
return current_ptr;
} | [
"vjain003@ucr.edu"
] | vjain003@ucr.edu |
5c106856a9a26ceb61c8b4334327d157c2cba9af | ea770a0943c6b9111be180fb815078fb2f449c79 | /CucumberC++/GherkinParser/src/BDD/BDDExecSpecGenerator.h | d36512a5828cb2f9ea6fdd3b8ad3eeceba840421 | [
"MIT"
] | permissive | bzquan/CucumberCpp | b967fd4472d618b5cfbad043043d9359a82e7f39 | 0ada15970e3be59a9f9d1a066e2aef3ca0b8a12d | refs/heads/master | 2021-05-15T01:15:21.040610 | 2016-12-31T00:38:33 | 2016-12-31T00:38:33 | 58,046,305 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,158 | h | /* The MIT License (MIT)
*
* Copyright (c) 2016 Bingzhe Quan
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#pragma once
#include <string>
#include <memory>
#include "BDDFeatureBuilder.h"
#include "BDDStepImplBuilderManager.h"
#include "BDDASTVisitor.h"
namespace GherkinAst
{
class Feature;
}
namespace CucumberCpp
{
class BDDExecSpecGenerator
{
public:
BDDExecSpecGenerator();
void GenExecSpec(GherkinAst::Feature* pFeature);
std::wstring StepHeaderFileName();
std::wstring StepImplFileName();
std::wstring StepModelTemplateHeaderFileName();
std::wstring StepModelTemplateImplFileName();
std::wstring FeatureFileName();
std::wstring StepDefsHeader();
std::wstring StepDefsImpl();
std::wstring StepModelTemplateHeader();
std::wstring StepModelTemplateImpl();
std::wstring FeatureImpl();
private:
std::unique_ptr<BDDASTVisitor> m_BDDASTVisitor;
std::unique_ptr<BDDFeatureBuilder> m_FeatureBuilder;
std::unique_ptr<BDDStepImplBuilderManager> m_StepImplBuilderManager;
};
}
| [
"bzquan@gmail.com"
] | bzquan@gmail.com |
8147df548478d92440f2a12493a29f6b6d1b9b9a | db50162b3ea5c08e676ab491981487a7386a465a | /src/main.cpp | 498b9968d4b8f31cdb0afaf94a6985e69d5da8ef | [
"MIT"
] | permissive | kingsamchen/Yielderator | 1b96f4c735d466c709ee2431e9a38df7e1842c3f | 7da0673e3589e7bfa65a22a2540c0d19a2c415ae | refs/heads/master | 2020-05-01T11:52:58.530758 | 2015-03-20T03:51:10 | 2015-03-20T03:51:10 | 32,259,304 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,023 | cpp | /*
@ Kingsley Chen
*/
#include <conio.h>
#include <iostream>
#include <string>
#include "yielderator.h"
class Collection {
public:
using value_type = std::string;
private:
void Yielderate()
{
yield_return(std::string("abc"));
yield_return(std::string("def"));
yield_return(std::string("hij"));
yield_return(std::string("hello"));
yield_return(std::string("world"));
}
friend Yielderator<Collection>;
};
int main()
{
Collection c;
Yielderator<Collection> yd(&c);
Yielderator<Collection> partial_yd(&c);
std::cout << "partial: ";
partial_yd.MoveNext();
std::cout << *partial_yd.Current() << " ";
partial_yd.MoveNext();
std::cout << *partial_yd.Current() << std::endl;
std::cout << "complete: ";
while (yd.MoveNext()) {
std::cout << *yd.Current() << " ";
}
std::cout << std::endl;
partial_yd.MoveNext();
std::cout << "partial again: " << *partial_yd.Current();
_getch();
return 0;
} | [
"kingsamchen@gmail.com"
] | kingsamchen@gmail.com |
14499b9b0f79d215082ffb983040d84a9cba69c7 | 62ab9e009031da8fe5cb38dd773971c57f30bdb7 | /ardumower/src/DHT.h | f583d32d0332dcc8cb77561cc3a041bcb50cb5d1 | [] | no_license | jussipu/AzuritBer | ce21d5a2948ad2fc5e121d783f1d5f1f5628e006 | b396050fffbdf9b675d20120ff5d58a42f2e1977 | refs/heads/RFID | 2021-08-06T11:52:13.566475 | 2020-05-23T13:54:26 | 2020-05-23T13:54:26 | 187,247,274 | 1 | 0 | null | 2020-04-23T10:04:03 | 2019-05-17T16:15:44 | C++ | UTF-8 | C++ | false | false | 1,733 | h | /* DHT library
MIT license
written by Adafruit Industries
*/
#ifndef DHT_H
#define DHT_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
// Uncomment to enable printing out nice debug messages.
//#define DHT_DEBUG
// Define where debug output will be printed.
#define DEBUG_PRINTER Serial
// Setup debug printing macros.
#ifdef DHT_DEBUG
#define DEBUG_PRINT(...) \
{ \
DEBUG_PRINTER.print(__VA_ARGS__); \
}
#define DEBUG_PRINTLN(...) \
{ \
DEBUG_PRINTER.println(__VA_ARGS__); \
}
#else
#define DEBUG_PRINT(...) \
{ \
}
#define DEBUG_PRINTLN(...) \
{ \
}
#endif
// Define types of sensors.
#define DHT11 11
#define DHT22 22
#define DHT21 21
#define AM2301 21
class DHT
{
public:
DHT(uint8_t pin, uint8_t type, uint8_t count = 6);
void begin(void);
float readTemperature(bool S = false, bool force = false);
float convertCtoF(float);
float convertFtoC(float);
float computeHeatIndex(float temperature, float percentHumidity, bool isFahrenheit = true);
float readHumidity(bool force = false);
bool read(bool force = false);
private:
uint8_t data[5];
uint8_t _pin, _type;
#ifdef __AVR
// Use direct GPIO access on an 8-bit AVR so keep track of the port and bitmask
// for the digital pin connected to the DHT. Other platforms will use digitalRead.
uint8_t _bit, _port;
#endif
uint32_t _lastreadtime, _maxcycles;
bool _lastresult;
uint32_t expectPulse(bool level);
};
class InterruptLock
{
public:
InterruptLock()
{
noInterrupts();
}
~InterruptLock()
{
interrupts();
}
};
#endif
| [
"25924791+jussipu@users.noreply.github.com"
] | 25924791+jussipu@users.noreply.github.com |
820798d7366d6b4368ba5339c8088116d7462fc1 | 3e19165859b69351301f683292135cba75549db6 | /MIT/6.837/3/vecmath/include/Matrix4f.h | 0bb9ea5f2bba63e83f13e0740b96096c1873d6ab | [] | no_license | k-ye/OpenCourses | b084638e212920a831a6baf74d740dd704b9447f | 7ac57b6fbfe1ae574f60378cf15d308e191be3eb | refs/heads/master | 2021-07-04T19:50:34.040105 | 2020-04-05T09:02:14 | 2020-04-05T09:02:14 | 99,991,859 | 27 | 9 | null | null | null | null | UTF-8 | C++ | false | false | 4,021 | h | #ifndef MATRIX4F_H
#define MATRIX4F_H
#include <cstdio>
class Matrix2f;
class Matrix3f;
class Quat4f;
class Vector3f;
class Vector4f;
// 4x4 Matrix, stored in column major order (OpenGL style)
class Matrix4f
{
public:
// Fill a 4x4 matrix with "fill". Default to 0.
Matrix4f( float fill = 0.f );
Matrix4f( float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23,
float m30, float m31, float m32, float m33 );
// setColumns = true ==> sets the columns of the matrix to be [v0 v1 v2 v3]
// otherwise, sets the rows
Matrix4f( const Vector4f& v0, const Vector4f& v1, const Vector4f& v2, const Vector4f& v3, bool setColumns = true );
Matrix4f( const Matrix4f& rm ); // copy constructor
Matrix4f& operator = ( const Matrix4f& rm ); // assignment operator
Matrix4f& operator/=(float d);
// no destructor necessary
const float& operator () ( int i, int j ) const;
float& operator () ( int i, int j );
Vector4f getRow( int i ) const;
void setRow( int i, const Vector4f& v );
// get column j (mod 4)
Vector4f getCol( int j ) const;
void setCol( int j, const Vector4f& v );
// gets the 2x2 submatrix of this matrix to m
// starting with upper left corner at (i0, j0)
Matrix2f getSubmatrix2x2( int i0, int j0 ) const;
// gets the 3x3 submatrix of this matrix to m
// starting with upper left corner at (i0, j0)
Matrix3f getSubmatrix3x3( int i0, int j0 ) const;
// sets a 2x2 submatrix of this matrix to m
// starting with upper left corner at (i0, j0)
void setSubmatrix2x2( int i0, int j0, const Matrix2f& m );
// sets a 3x3 submatrix of this matrix to m
// starting with upper left corner at (i0, j0)
void setSubmatrix3x3( int i0, int j0, const Matrix3f& m );
float determinant() const;
Matrix4f inverse( bool* pbIsSingular = NULL, float epsilon = 0.f ) const;
void transpose();
Matrix4f transposed() const;
// ---- Utility ----
operator float* (); // automatic type conversion for GL
operator const float* () const; // automatic type conversion for GL
void print();
static Matrix4f ones();
static Matrix4f identity();
static Matrix4f translation( float x, float y, float z );
static Matrix4f translation( const Vector3f& rTranslation );
static Matrix4f rotateX( float radians );
static Matrix4f rotateY( float radians );
static Matrix4f rotateZ( float radians );
static Matrix4f rotation( const Vector3f& rDirection, float radians );
static Matrix4f scaling( float sx, float sy, float sz );
static Matrix4f uniformScaling( float s );
static Matrix4f lookAt( const Vector3f& eye, const Vector3f& center, const Vector3f& up );
static Matrix4f orthographicProjection( float width, float height, float zNear, float zFar, bool directX );
static Matrix4f orthographicProjection( float left, float right, float bottom, float top, float zNear, float zFar, bool directX );
static Matrix4f perspectiveProjection( float fLeft, float fRight, float fBottom, float fTop, float fZNear, float fZFar, bool directX );
static Matrix4f perspectiveProjection( float fovYRadians, float aspect, float zNear, float zFar, bool directX );
static Matrix4f infinitePerspectiveProjection( float fLeft, float fRight, float fBottom, float fTop, float fZNear, bool directX );
// Returns the rotation matrix represented by a quaternion
// uses a normalized version of q
static Matrix4f rotation( const Quat4f& q );
// returns an orthogonal matrix that's a uniformly distributed rotation
// given u[i] is a uniformly distributed random number in [0,1]
static Matrix4f randomRotation( float u0, float u1, float u2 );
private:
float m_elements[ 16 ];
};
// Matrix-Vector multiplication
// 4x4 * 4x1 ==> 4x1
Vector4f operator * ( const Matrix4f& m, const Vector4f& v );
// Matrix-Matrix multiplication
Matrix4f operator * ( const Matrix4f& x, const Matrix4f& y );
#endif // MATRIX4F_H
| [
"yekuang.ky@gmail.com"
] | yekuang.ky@gmail.com |
51ed67df5747c74308a1bb11c8ede83810a3466c | 975779ef2a843c2733404af6e5f6f5b14003cea6 | /Feb13/TopBrussels/TopTreeAnalysis/macros/CernWHelicity.cc | e47e248eae439dcd3b570cc9ae33c26c33fe3392 | [] | no_license | rebecacern/OldVUB | 087639e5652c659ee242826a50fcd68df92c3f06 | 481f54483eaf95b98020531aea1d35480708c3de | refs/heads/master | 2020-04-27T17:24:07.590377 | 2014-04-17T14:36:05 | 2014-04-17T14:36:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 90,928 | cc | ///////////////////////////
///// TODO & COMMENTS /////
///////////////////////////
#include "TStyle.h"
#include "TGraphErrors.h"
#include <cmath>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
#include <math.h>
#include "TLorentzVector.h" //Needs to be defined as " TLorentzVector V(Px,Py,Pz,E) " or " TLorentzVector V and V.SetPxPyPzE(Px,Py,Pz,E) "
#include "TF1.h"
#include "TH2.h"
#include "TString.h"
#include <stdio.h>
#include "TMath.h"
//user code
#include "TopTreeProducer/interface/TRootRun.h"
#include "TopTreeProducer/interface/TRootEvent.h"
#include "../Selection/interface/SelectionTable.h"
#include "../Tools/interface/PlottingTools.h"
#include "../Tools/interface/MultiSamplePlot.h"
#include "../Tools/interface/TTreeLoader.h"
#include "../Tools/interface/AnalysisEnvironmentLoader.h"
#include "../Content/interface/AnalysisEnvironment.h"
#include "../Content/interface/Dataset.h"
#include "../MCInformation/interface/JetPartonMatching.h"
#include "../Tools/interface/JetTools.h"
#include "Style.C"
#include "TVector3.h"
#include "TH1.h"
#include "Riostream.h"
//Class for reconstruction of topology
#include "../WHelicities/interface/WReconstruction.h"
//Includes necessary for kinFitter:
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <algorithm>
#include "TMatrixD.h"
#include "../MCInformation/interface/ResolutionFit.h"
#include "../KinFitter/interface/TKinFitter.h"
#include "../KinFitter/interface/TFitConstraintM.h"
#include "../KinFitter/interface/TFitParticleEtThetaPhiEMomFix.h"
using namespace std;
using namespace TopTree;
int FirstEvent=0;
int main (int argc, char *argv[])
{
clock_t start = clock();
cout << "*****************************************" << endl;
cout << " Beginning of the program for Cern WHelicity ! " << endl;
cout << "*****************************************" << endl;
//SetStyle if needed
//setTDRStyle();
setMyStyle();
/////////////////////
// Configuration
/////////////////////
bool doPF2PAT = false;
//xml file
string xmlFileName ="../config/CernMacroConfig.xml"; //Position of .xml file
if (argc >= 2)
xmlFileName=string(argv[1]);
const char *xmlfile = xmlFileName.c_str();
cout << "used config file: " << xmlfile << endl;
//Output ROOT file
string rootFileName ("MacroOutputPValue.root"); //Root output file
const char *rootfile = rootFileName.c_str();
//Configuration output format
TTree *configTree = new TTree("configTree","configuration Tree");
TClonesArray* tcdatasets = new TClonesArray("Dataset",1000);
configTree->Branch("Datasets","TClonesArray",&tcdatasets);
TClonesArray* tcAnaEnv = new TClonesArray("AnalysisEnvironment",1000);
configTree->Branch("AnaEnv","TClonesArray",&tcAnaEnv);
////////////////////////////////////
/// AnalysisEnvironment
////////////////////////////////////
AnalysisEnvironment anaEnv;
cout<<"Loading environment ..."<<endl;
AnalysisEnvironmentLoader anaLoad(anaEnv,xmlfile);
new ((*tcAnaEnv)[0]) AnalysisEnvironment(anaEnv);
int verbose = anaEnv.Verbose;
float oldLuminosity = anaEnv.Luminosity; // in 1/pb
cout << "analysis environment luminosity for rescaling "<< oldLuminosity << endl;
/////////////////////
// Load Datasets
/////////////////////
bool SimulationSampleBoolean;
TTreeLoader treeLoader;
cout << " - Load datasets ..." << endl;
vector < Dataset* > datasets;
treeLoader.LoadDatasets (datasets, xmlfile);
for(unsigned int i=0;i<datasets.size();i++) new ((*tcdatasets)[i]) Dataset(*datasets[i]);
float Luminosity = oldLuminosity;
bool isSemiMu = false;
for (unsigned int d = 0; d < datasets.size (); d++){
cout << "luminosity of dataset "<< d << " is " << datasets[d]->EquivalentLumi() << endl;
if(Luminosity > datasets[d]->EquivalentLumi() ) Luminosity = datasets[d]->EquivalentLumi();
string dataSetName = datasets[d]->Name();
if(dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA"){
Luminosity = datasets[d]->EquivalentLumi();
break;
}
if(dataSetName.find("TTbarJets_SemiMu") == 0) isSemiMu = true;
}
if(Luminosity != oldLuminosity) cout << "changed analysis environment luminosity to "<< Luminosity << endl;
//vector of objects
cout << " - Variable declaration ..." << endl; //All possible variables that can be used for analysis
vector < TRootVertex* > vertex;
vector < TRootMuon* > init_muons;
vector < TRootElectron* > init_electrons;
vector < TRootJet* > init_jets;
vector < TRootJet* > init_jets_corrected;
vector < TRootMET* > mets;
TFile *fout = new TFile (rootfile, "RECREATE"); //Making of a TFile where all information is stored
//Global variable
TRootEvent* event = 0;
//nof selected events
float NEvtsData = 0;
Double_t *nEvents = new Double_t[datasets.size()];
////////////////////////////////////
/// TGraphAsymmErrors
////////////////////////////////////
map<string,TGraphAsymmErrors*> graphAsymmErr;
map<string,TGraphErrors*> graphErr;
std::cout << " starting to define the histograms !! " << std::endl;
////////////////////////////////////
/// Normal Plots (TH1F* and TH2F*)
////////////////////////////////////
//All histograms can be defined as pre-programmed maps which makes definitions and looping easier
map<string,TH1F*> histo1D;
map<string,TH2F*> histo2D;
// Histograms needed to calculate the sigma and Mc mass (from mean value) for W and top mass distribution
// --> Comment out after initializing most recent values ( also lines 1046 and 1356 )
histo1D["WMass"]= new TH1F("WMass","WMass", 200,0,160);
histo1D["TopMass"]= new TH1F("TopMass","TopMass", 200,0,350);
// Give the theoretical distribution for SM values
// --> Always stay the same
//
//histo1D["HelicityDistribution"] = new TH1F("HelicityDistribution","HelicityDistribution",200,-1,1);
//histo1D["HelicityDistributionLong"] = new TH1F("HelicityDistributionLong","HelicityDistributionLong",200,-1,1);
//histo1D["HelicityDistributionLeft"] = new TH1F("HelicityDistributionLeft","HelicityDistributionLeft",200,-1,1);
//histo1D["HelicityDistributionRight"] = new TH1F("HelicityDistributionRight","HelicityDistributionRight",200,-1,1);
// Give the Cos theta distribution for Semi Mu sample before event selection
// Fit histograms gives the helicity values that should be used as SM values from CMS data
// --> Always stay the same
//
histo1D["StandardCosTheta"]=new TH1F("StCosTheta","StCosTheta",200,-1,1);
histo1D["StandardCosThetaFit"]=new TH1F("StCosThetaFit","StCosThetaFit",200,-1,1);
//Histograms which check the position in the descending order of the jets:
//
histo1D["Quark1Number"]=new TH1F("Quark1Number","Quark1Number",11,-0.5,10.5);
histo1D["Quark2Number"]=new TH1F("Quark2Number","Quark2Number",11,-0.5,10.5);
histo1D["BHadronicNumber"]=new TH1F("BHadronicNumber","BHadronicNumber",11,-0.5,10.5);
histo1D["BLeptonicNumber"]=new TH1F("BLeptonicNumber","BLeptonicNumber",11,-0.5,10.5);
//Histograms to check the effect of the reconstruction on the helicity distribution:
//
histo1D["CosThetaRECO"]=new TH1F("CosThetaRECO","CosThetaRECO",200,-1,1);
histo1D["CosThetaRECOBLeptCorrect"]=new TH1F("CosThetaRECOBLeptCorrect","CosThetaRECOBLeptCorrect",200,-1,1);
histo1D["CosThetaBLept"]=new TH1F("CosThetaBLept","CosThetaBLept",200,-1,1);
histo1D["CosThetaMuon"]=new TH1F("CosThetaMuon","CosThetaMuon",200,-1,1);
histo1D["CosThetaNeutrino"]=new TH1F("CosThetaNeutrino","CosThetaNeutrino",200,-1,1);
histo1D["TopMassForCorrect"]=new TH1F("TopMassForCorrect","TopMassForCorrect",200,0,400);
histo1D["TopMassForWrong"]=new TH1F("TopMassForWrong","TopMassForWrong",500,0,1000);
histo1D["TopMassReco"]=new TH1F("TopMassReco","TopMassReco",200,0,400);
histo1D["TopMassNotWrong"]=new TH1F("TopMassNotWrong","TopMassNotWrong",500,0,1000);
histo2D["BtagForTopWrong"]=new TH2F("BtagForTopWrong","BtagForTopWrong",200,0,400,100,0,1);
histo2D["BtagForTopCorrect"]=new TH2F("BtagForTopCorrect","BtagForTopCorrect",200,0,400,100,0,1);
histo2D["BtagForTop"]=new TH2F("BtagForTop","BtagForTop",200,0,400,100,0,1);
histo2D["ChiSquaredForTop"]=new TH2F("ChiSquaredForTop","ChiSquaredForTop",200,0,400,100,0,150);
histo2D["MVACorrelationPlot"]=new TH2F("MVACorrelationPlot","MVACorrelationPlot",100,0,150,100,0,1);
histo2D["MVACorrelationPlotWrong"]=new TH2F("MVACorrelationPlotWrong","MVACorrelationPlotWrong",100,0,150,100,0,1);
histo1D["MVACombination"]=new TH1F("MVACombination","MVACombination",200,0,12);
histo1D["MVACombinationBefore"]=new TH1F("MVACombinationBefore","MVACombinationBefore",200,0,12);
histo1D["MVACombinationTwo"]=new TH1F("MVACombinationTwo","MVACombinationTwo",200,0,12);
int CorrectZero=0;
int CorrectTwo=0;
int CorrectFour=0;
int CorrectSix=0;
int CorrectEight=0;
int CorrectTen=0;
histo1D["CorrectMVANumber"]=new TH1F("CorrectMVANumber","CorrectMVANumber",200,0,12);
bool bTagSelected;
bool ProblemEvent;
histo1D["QuarkOnePtZero"]=new TH1F("QuarkOnePtZero","QuarkOnePtZero",200,0,400);
histo1D["QuarkOnePtTwo"]=new TH1F("QuarkOnePtTwo","QuarkOnePtTwo",200,0,400);
histo1D["QuarkOnePtFour"]=new TH1F("QuarkOnePtFour","QuarkOnePtFour",200,0,400);
histo1D["QuarkOnePtSix"]=new TH1F("QuarkOnePtSix","QuarkOnePtSix",200,0,400);
histo1D["QuarkOnePtEight"]=new TH1F("QuarkOnePtEight","QuarkOnePtEight",200,0,400);
histo1D["QuarkOnePtTen"]=new TH1F("QuarkOnePtTen","QuarkOnePtTen",200,0,400);
histo1D["QuarkTwoPtZero"]=new TH1F("QuarkTwoPtZero","QuarkTwoPtZero",200,0,400);
histo1D["QuarkTwoPtTwo"]=new TH1F("QuarkTwoPtTwo","QuarkTwoPtTwo",200,0,400);
histo1D["QuarkTwoPtFour"]=new TH1F("QuarkTwoPtFour","QuarkTwoPtFour",200,0,400);
histo1D["QuarkTwoPtSix"]=new TH1F("QuarkTwoPtSix","QuarkTwoPtSix",200,0,400);
histo1D["QuarkTwoPtEight"]=new TH1F("QuarkTwoPtEight","QuarkTwoPtEight",200,0,400);
histo1D["QuarkTwoPtTen"]=new TH1F("QuarkTwoPtTen","QuarkTwoPtTen",200,0,400);
histo1D["HadrBPtZero"]=new TH1F("HadrBPtZero","HadrBPtZero",200,0,400);
histo1D["HadrBPtTwo"]=new TH1F("HadrBPtTwo","HadrBPtTwo",200,0,400);
histo1D["HadrBPtFour"]=new TH1F("HadrBPtFour","HadrBPtFour",200,0,400);
histo1D["HadrBPtSix"]=new TH1F("HadrBPtSix","HadrBPtSix",200,0,400);
histo1D["HadrBPtEight"]=new TH1F("HadrBPtEight","HadrBPtEight",200,0,400);
histo1D["HadrBPtTen"]=new TH1F("HadrBPtTen","HadrBPtTen",200,0,400);
histo1D["LeptBPtZero"]=new TH1F("LeptBPtZero","LeptBPtZero",200,0,400);
histo1D["LeptBPtTwo"]=new TH1F("LeptBPtTwo","LeptBPtTwo",200,0,400);
histo1D["LeptBPtFour"]=new TH1F("LeptBPtFour","LeptBPtFour",200,0,400);
histo1D["LeptBPtSix"]=new TH1F("LeptBPtSix","LeptBPtSix",200,0,400);
histo1D["LeptBPtEight"]=new TH1F("LeptBPtEight","LeptBPtEight",200,0,400);
histo1D["LeptBPtTen"]=new TH1F("LeptBPtTen","LeptBPtTen",200,0,400);
int BTagCombinationEvents = 0;
int BTagCorrectCombination = 0;
////////////////////////////////////
/// MultiSamplePlot
////////////////////////////////////
//Whenever there are more than one dataset this can be used to add up the different results of the datasets
//
map<string,MultiSamplePlot*> MSPlot;
//Histograms for chapter event selection: Compare Data vs MC for Cut values!
//
// Histograms that give the chi squared and BTagValueMVA values for the jet distribution selection method
//
MSPlot["ChiSquared"]= new MultiSamplePlot(datasets, "ChiSquared", 20,-1,150,"ChiSquared");
MSPlot["NotSelectedChiSq"]=new MultiSamplePlot(datasets,"NotSelectedChiSq",100,-1,200,"NotSelectedChiSq");
MSPlot["BTagValueMVA"]=new MultiSamplePlot(datasets,"BTagValueMVA",100,0,1,"BTagValueMVA");
MSPlot["NotSelectedBTag"]=new MultiSamplePlot(datasets,"NotSelectedBTag",100,0,1,"NotSelectedBTag");
//
// For SemiMu MC sample can be checked how many times selected jet distribution is correct:
//
MSPlot["ChiSquaredCorrect"]= new MultiSamplePlot(datasets, "ChiSquaredCorrect", 200,-1,150,"ChiSquaredCorrect");
MSPlot["ChiSquaredWrong"]= new MultiSamplePlot(datasets, "ChiSquaredWrong", 200,-1,150,"ChiSquaredWrong");
MSPlot["BTagValueMVACorrect"]=new MultiSamplePlot(datasets,"BTagValueMVACorrect",100,0,1,"BTagValueMVACorrect");
MSPlot["BTagValueMVAWrong"]=new MultiSamplePlot(datasets,"BTagValueMVAWrong",100,0,1,"BTagValueMVAWrong");
MSPlot["RecoWMass"]= new MultiSamplePlot(datasets,"RecoWMass",100,20,250,"RecoWMass");
MSPlot["RecoTopHadrMass"]= new MultiSamplePlot(datasets,"RecoTopHadrMass",400,60,600,"RecoTopHadrMass");
MSPlot["RecoWMassDiff"]= new MultiSamplePlot(datasets,"RecoWMassDiff",40,-70,200,"RecoWMassDiff");
MSPlot["RecoTopHadrMassDiff"]= new MultiSamplePlot(datasets,"RecoTopHadrMassDiff",80,-120,500,"RecoTopHadrMassDiff");
int NumberSemiMuEvents = 0;
int AllJetsCorrect = 0;
int OneJetWrong = 0;
int numberCorrectHadronicB = 0;
int numberCorrectQuarks = 0;
//----------------------------------------------------------------
//-- Definitions for comparing CosTheta between data and Mc --
//----------------------------------------------------------------
//Luminosity should be rescaled
// Number of bins should be 10 since there are only about 200 data entries after all selections
//
int CosThetaBinNumber = 15;
int NumberOfHelicityBins=100;
MSPlot["CosTheta"]= new MultiSamplePlot(datasets, "CosTheta", CosThetaBinNumber,-1,1,"CosTheta");
histo1D["CosThetaMC"] = new TH1F("CosThetaMC","CosThetaMC",CosThetaBinNumber,-1,1);
histo1D["CosThetaData"]=new TH1F("CosThetaData","CosThetaData",CosThetaBinNumber,-1,1);
std::string HelicityNumber[(NumberOfHelicityBins+1)];
for(int ii=0;ii<=NumberOfHelicityBins;ii++){
std::stringstream out;
out << ii;
HelicityNumber[ii] = out.str();
}
histo1D["TheoreticalHelicityDistribution"]= new TH1F("TheoreticalHelicityDistribution","TheoreticalHelicityDistribution",10,-1,1);
histo1D["ChiSquaredReweighting"]=new TH1F("ChiSquaredReweighting","ChiSquaredReweighting",50,0,100);
for(int Longit =0;Longit <=NumberOfHelicityBins;Longit++){
for(int Right =0; Right <=(NumberOfHelicityBins-Longit) ; Right++){
int Left = NumberOfHelicityBins-Longit-Right;
std::string HistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
TString THistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
std::string HelicityWeightHisto = "HelicityWeightRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
TString THelicityWeightHisto = "HelicityWeightRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
std::string ChiSquaredHelicity = "ChiSquaredRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
histo1D[HistoName] = new TH1F(THistoName,THistoName,CosThetaBinNumber,-1,1);
histo1D[HelicityWeightHisto] =new TH1F(THelicityWeightHisto,THelicityWeightHisto,200,0,5);
}//end of second helicity loop
}// end of first helicity loop
// Histograms that give the p-value for the different helicity values
//
float HighestPValue =0;
histo1D["PValueAllBins"]=new TH1F("PValueAllBins","PValueAllBins",5155,0,5155);
float HelicityPointsBin = (1./(NumberOfHelicityBins*2.));
histo2D["HelicityPointsPlot"]=new TH2F("HelicityPointsPlot","HelicityPointsPlot",(NumberOfHelicityBins+1),(0.-HelicityPointsBin),(1.+HelicityPointsBin),(NumberOfHelicityBins+1),(0.-HelicityPointsBin),(1.+HelicityPointsBin));
histo2D["ChiSqPlot"]=new TH2F("ChiSqPlot","ChiSqPlot",(NumberOfHelicityBins+1),(0.-HelicityPointsBin),(1.+HelicityPointsBin),(NumberOfHelicityBins+1),(0.-HelicityPointsBin),(1.+HelicityPointsBin));
float LowestChiSqValue=1000000000000000;
///////////////////////////////////////////////////////
// Making the theoretical helicity distribution // -> To know how the distribution should look like!!
/////////////////////////////////////////////////////// --> Only Fit values are used in code!!
//------ Standard Model -----
float LongitudinalFraction = 0.642324; // values obtained from fit
float RightHandedFraction = 0.0327637;
float LeftHandedFraction = 1 - LongitudinalFraction - RightHandedFraction;
float SMDiffDistribution[3];//0:Longitudinal; 1: Righthanded; 2: Lefthanded
float XVariable;
// std::cout << " Used SM helicity variables: Longitudinal (f0) = " << LongitudinalFraction << " Righthanded (f+) = " << RightHandedFraction << " Lefthanded (f-) = " << LeftHandedFraction << std::endl;
// for(unsigned int jj=0;jj<200;jj++){
// XVariable=-1+0.01*jj;
// SMDiffDistribution[0] = (LongitudinalFraction*6*(1-pow(XVariable,2)))/8;
// SMDiffDistribution[2] = (pow((1-XVariable),2)*3*LeftHandedFraction)/8;
// SMDiffDistribution[1] = (RightHandedFraction*3*pow((1+XVariable),2))/8;
// histo1D["HelicityDistribution"]->SetBinContent(jj+1,(SMDiffDistribution[0]+SMDiffDistribution[1]+SMDiffDistribution[2]));
// histo1D["HelicityDistributionLong"]->SetBinContent(jj+1,SMDiffDistribution[0]);
// histo1D["HelicityDistributionLeft"]->SetBinContent(jj+1,SMDiffDistribution[2]);
// histo1D["HelicityDistributionRight"]->SetBinContent(jj+1,SMDiffDistribution[1]);
// }
/////////////////////////////
/// ResolutionFit Stuff
/////////////////////////////
bool applyKinFit = false;
// ResolutionFit *resFitLightJets_ = new ResolutionFit("LightJet");
// resFitLightJets_->LoadResolutions("lightJetReso.root");
// ResolutionFit *resFitBJets_ = new ResolutionFit("BJet");
// resFitBJets_->LoadResolutions("bJetReso.root");
float TopMassKinFit;
float WMassKinFit = 80.4;
////////////////////////////////
// MVA Stuff
////////////////////////////////
bool applyMVA = true; //Remember: applyKinFit is defined above!!
//Which event reconstruction applied:
//
if(applyKinFit==true){
std::cout << " Only Kinematic Fit applied as event selection " << std::endl;
}
else if(applyMVA==true){
std::cout << " MVA (btag) combined with Kinematic Fit as event selection " << std::endl;
}
else{
std::cout << " Minimal Chi squared method used as event selection " << std::endl;
}
////////////////////////////////////
/// Selection table
////////////////////////////////////
vector<string> CutsSelecTable;//Writes information in a pdf file, is filled during the selection with the different layers
CutsSelecTable.push_back(string("initial"));
CutsSelecTable.push_back(string("preselected"));
CutsSelecTable.push_back(string("trigged"));
CutsSelecTable.push_back(string("Good PV"));
CutsSelecTable.push_back(string("1 selected muon"));
CutsSelecTable.push_back(string("Veto 2nd muon"));
CutsSelecTable.push_back(string("Veto electron"));
char LabelNJets[100];
sprintf(LabelNJets,"$\\geq$ %d jets", anaEnv.NofJets-3);
CutsSelecTable.push_back(string(LabelNJets));
sprintf(LabelNJets,"$\\geq$ %d jets", anaEnv.NofJets-2);
CutsSelecTable.push_back(string(LabelNJets));
sprintf(LabelNJets,"$\\geq$ %d jets", anaEnv.NofJets-1);
CutsSelecTable.push_back(string(LabelNJets));
sprintf(LabelNJets,"$\\geq$ %d jets", anaEnv.NofJets);
CutsSelecTable.push_back(string(LabelNJets));
if (verbose > 0)
cout << " - CutsSelectionTable instantiated ..." << endl;
SelectionTable selecTable(CutsSelecTable, datasets);
selecTable.SetLuminosity(Luminosity);
if (verbose > 0)
cout << " - SelectionTable instantiated ..." << endl;
std::cout << " starting to initialize Whelicities class !! " << std::endl;
////////////////////////////////////
//Reconstruction class WHelicities
////////////////////////////////////
WReconstruction wReconstruction = WReconstruction();
std::cout << " WHelicities class initialized .. " << std::endl;
////////////////////////////////////
// Loop on datasets
////////////////////////////////////
if (verbose > 0)
cout << " - Loop over datasets ... " << datasets.size () << " datasets !" << endl;
for (unsigned int d = 0; d < datasets.size (); d++){
if (verbose > 1)
cout << " Dataset " << d << ": " << datasets[d]->Name () << "/ title : " << datasets[d]->Title () << endl;
if (verbose > 1)
std::cout<<" -> This sample contains, " << datasets[d]->NofEvtsToRunOver() << " events." << endl;
//open files and load
cout<<"LoadEvent"<<endl;
treeLoader.LoadDataset (datasets[d], anaEnv);
cout<<"LoadEvent"<<endl;
string dataSetName = datasets[d]->Name();
selecTable.Fill(d,0, datasets[d]->Xsection() * datasets[d]->EquivalentLumi() );
string previousFilename = "";
int iFile = -1;
//Initializing top mass constraint for kinematic fit:
//Is different for Data(measured by Tevatron) and MC(generated for this top mass)
//
if(dataSetName.find("Data") == 0){
TopMassKinFit = 173.1;
SimulationSampleBoolean = false;
}
else{
TopMassKinFit = 172.5;
SimulationSampleBoolean = true;
}
/////////////////////////////////////
/// Initialize JEC factors
/////////////////////////////////////
vector<JetCorrectorParameters> vCorrParam;
if(dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA") // Data!
{
JetCorrectorParameters *ResJetCorPar = new JetCorrectorParameters("JECFiles/Jec11V2_db_AK5PFchs_L2L3Residual.txt");
vCorrParam.push_back(*ResJetCorPar);
}
JetCorrectionUncertainty *jecUnc = new JetCorrectionUncertainty("JECFiles/Jec11V2_db_AK5PFchs_Uncertainty.txt");
JetTools *jetTools = new JetTools(vCorrParam, jecUnc, false);
////////////////////////////////////
// Loop on events
////////////////////////////////////
nEvents[d] = 0;
int itrigger = -1, previousRun = -1;
if (verbose > 1)
cout << " Loop over events " << endl;
//for (unsigned int ievt = 0; ievt < datasets[d]->NofEvtsToRunOver(); ievt++){ //In this loop plots before selection can be defined
for (unsigned int ievt = 0; ievt < 200; ievt++){
nEvents[d]++;
if(ievt%2000 == 0)
std::cout<<"Processing the "<<ievt<<"th event" <<flush<<"\r";
//load event
event = treeLoader.LoadEvent (ievt, vertex, init_muons, init_electrons, init_jets, mets);
vector<TRootGenJet*> genjets;
if( ! (dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA" ) )
{
genjets = treeLoader.LoadGenJet(ievt);
sort(genjets.begin(),genjets.end(),HighestPt()); // HighestPt() is included from the Selection class
}
// scale factor for the event
float scaleFactor = 1.;
// Load the GenEvent and calculate the branching ratio correction
if(dataSetName.find("TTbarJets") == 0)
{
TRootGenEvent* genEvt = treeLoader.LoadGenEvent(ievt);
if( genEvt->isSemiLeptonic() )
scaleFactor *= (0.108*9.)*(0.676*1.5);
else if( genEvt->isFullHadronic() )
scaleFactor *= (0.676*1.5)*(0.676*1.5);
else if( genEvt->isFullLeptonic() )
scaleFactor *= (0.108*9.)*(0.108*9.);
}
// Clone the init_jets vector, otherwise the corrections will be removed
for(unsigned int i=0; i<init_jets_corrected.size(); i++)
if(init_jets_corrected[i]) delete init_jets_corrected[i];
init_jets_corrected.clear();
for(unsigned int i=0; i<init_jets.size(); i++)
init_jets_corrected.push_back( (TRootJet*) init_jets[i]->Clone() );
// check which file in the dataset it is to have the HLTInfo right
string currentFilename = datasets[d]->eventTree()->GetFile()->GetName();
if(previousFilename != currentFilename)
{
previousFilename = currentFilename;
iFile++;
cout<<"File changed!!! => iFile = "<<iFile<<endl;
}
int currentRun = event->runId();
if(previousRun != currentRun){
previousRun = currentRun;
if(dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA"){
if( event->runId() <= 161016 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_TriCentralJet30_v1"), currentRun, iFile);
else if( event->runId() >= 162762 && event->runId() <= 163261 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_TriCentralJet30_v2"), currentRun, iFile);
else if( event->runId() >= 163270 && event->runId() <= 163869 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_TriCentralJet30_v4"), currentRun, iFile);
else if( event->runId() >= 165088 && event->runId() <= 165633 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_TriCentralJet30_v5"), currentRun, iFile);
else if( event->runId() == 166346 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_QuadCentralJet30_v2"), currentRun, iFile);
else if( event->runId() >= 165970 && event->runId() <= 167043 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_QuadCentralJet30_v1"), currentRun, iFile);
else if( event->runId() >= 167078 )
itrigger = treeLoader.iTrigger (string ("HLT_Mu17_QuadCentralJet30_v3"), currentRun, iFile);
else
cout << "Unknown run for HLTpath selection: " << event->runId() << endl;
}
else{
itrigger = treeLoader.iTrigger (string ("HLT_Mu15_v2"), currentRun);
if (itrigger == 9999)
itrigger = treeLoader.iTrigger (string ("HLT_Mu15_v1"), currentRun); // Spring11: HLT_Mu15_v1
}
}
if(dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA"){
// Apply the scraping veto
bool isBeamBG = true;
if(event->nTracks() > 10){
if( ( (float) event->nHighPurityTracks() ) / ( (float) event->nTracks() ) > 0.25 )
isBeamBG = false;
}
if(isBeamBG) continue;
// Apply the JSON
// bool passedJSON = treeLoader.EventPassedJSON(datasets[d], event->runId(), event->lumiBlockId());
// if(!passedJSON) continue;
}
// Apply Jet Corrections on-the-fly
if( dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA" ){
jetTools->correctJets(init_jets_corrected, vertex);
}
if( ! (dataSetName == "Data" || dataSetName == "data" || dataSetName == "DATA" ) ){
// Correct for the difference in muon efficiency (HLT and Id) between Data and MC
//scaleFactor *= 0.965;
// Correct jets for JES uncertainy systematics
//jetTools->correctJetJESUnc(init_jets_corrected, "minus"); //also with "plus"
// Match RecoJets with GenJets
vector< pair<size_t, size_t> > indexVector; //first index = RecoJet, second index = GenJet
vector<bool> mLock(genjets.size(),false); // when locked, genJet is already matched to a recoJet
for(size_t i=0; i<init_jets_corrected.size(); i++){
pair<size_t, size_t> tmpIndex;
float minDR = 9999.;
for(size_t j=0; j<genjets.size(); j++){
if( ! mLock[j] ){
if( init_jets_corrected[i]->DeltaR(*genjets[j]) < 0.4 && init_jets_corrected[i]->DeltaR(*genjets[j]) < minDR ){
minDR = init_jets_corrected[i]->DeltaR(*genjets[j]);
tmpIndex = pair<size_t, size_t>(i,j);
}
}
}
if(minDR < 999.){
mLock[tmpIndex.second] = true;
indexVector.push_back(tmpIndex);
}
}
// Apply correction for jet energy resolution on-the-fly, only for recoJets matched with a genJet
for(size_t i=0; i<indexVector.size(); i++){
if( genjets[indexVector[i].second]->Pt() < 15 ) continue;
float corrFactor = 0.1; // factor is either 0.1 for bias correction, 0.0 for JER_minus and 0.2 for JER_plus
float deltapt = ( init_jets_corrected[indexVector[i].first]->Pt() - genjets[indexVector[i].second]->Pt() ) * corrFactor;
float ptscale = max(0.0, ( init_jets_corrected[indexVector[i].first]->Pt() + deltapt) / init_jets_corrected[indexVector[i].first]->Pt() );
if(ptscale > 0.0)
init_jets_corrected[indexVector[i].first]->SetPxPyPzE(init_jets_corrected[indexVector[i].first]->Px()*ptscale, init_jets_corrected[indexVector[i].first]->Py()*ptscale,init_jets_corrected[indexVector[i].first]->Pz()*ptscale, init_jets_corrected[indexVector[i].first]->E()*ptscale);
}
//Scale jets with a certain factor
//jetTools->scaleJets(init_jets_corrected, 1.);
//if(dataSetName.find("Data")==0){
//jetTools->scaleJets(init_jets_corrected, 1.05); //1.05 for +5%
//}
}
/////////////////////////////
// Selection
/////////////////////////////
//Declare selection instance
Selection selection(init_jets_corrected, init_muons, init_electrons, mets);
bool trigged = treeLoader.EventTrigged (itrigger);
bool isGoodPV = selection.isPVSelected(vertex, anaEnv.PVertexNdofCut, anaEnv.PVertexZCut, anaEnv.PVertexRhoCut);
vector<TRootJet*> selectedJets;
vector<TRootMuon*> selectedMuons;
if (init_jets_corrected.size() > 0) {
if (init_jets_corrected[0]->jetType() == 1 || doPF2PAT) { // calojets
//cout << "Selecting for caloJets" << endl;
selectedJets = selection.GetSelectedJets(true);
selectedMuons = selection.GetSelectedMuons(vertex[0],selectedJets);
}
else {
//cout << "Selecting for PF/JPT jets" << endl;
vector<TRootMuon*> overlapMuons = selection.GetSelectedMuons(vertex[0]);
//selection.setJetCuts(30.,2.4,0.01,1.,0.98,0.3,0.1); // refSelV4 values
//selection.setMuonCuts(20,2.1,0.12,10,0.02,0.3,1,1,1); //WHelicity uses different PFMuon isolation
selectedJets = selection.GetSelectedJets(overlapMuons,true);
selectedMuons = selection.GetSelectedMuons(vertex[0],selectedJets);
}
}
vector<TRootMuon*> vetoMuons = selection.GetSelectedLooseMuons();
vector<TRootElectron*> vetoElectrons = selection.GetSelectedLooseElectrons(false);
vector<TRootMCParticle*> mcParticles;
if(dataSetName.find("TTbarJets_SemiMu") == 0){
mcParticles = treeLoader.LoadMCPart(ievt);
sort(mcParticles.begin(),mcParticles.end(),HighestPt()); // HighestPt() is included from the Selection class
}
///////////////////////////////////////////////////////
/// Start of program: Defining variables ///
///////////////////////////////////////////////////////
int CorrectQuark1=999; //Needed for Monte Carlo
int CorrectQuark2=999;
int CorrectBHadronic=999;
int CorrectBLeptonic=999;
float MassW=83.6103;
float MassTop = 172.956;
float SigmaW=11.1534; //Obtained from gaussian fit on Top and W distribution with simulated information
float SigmaTop=18.232;
float ChiSquared[12]; //Needed for chi squared caclulation
int UsedCombination;
int QuarkOneIndex[12];
int QuarkTwoIndex[12];
int BHadronicIndex[12];
int BLeptonicIndex;
float ChiSquaredValue;
double btag[12]; //Needed for MVA calculation
for(int i =0; i<12;i++){
btag[i]=0;
}
double BTagValueMVA;
int BLeptonicIndexMVA[12];
int MVACombination[2];
float NeutrinoPx,NeutrinoPy; //(No initialization needed since Px and Py can always be calculated)
float NeutrinoPz=999; //with this value it can be distinguished in plot! Has to be calculated with DCoefficient
float NeutrinoE=999;
TLorentzVector WLeptonic;
TLorentzVector TopLeptonic;
TLorentzVector Neutrino;
TLorentzVector WLeptonicTZMF;
TLorentzVector MuonWZMF;
float CosTheta=0;
float CosThetaData=0;
float standardCosTheta=0;
float TheoreticalDistributionValue = 0; //Function value for SM helicities
TRootMCParticle standardNeutrino, standardTop,standardMuon,standardWLeptonic;
vector<int> jetCombi;
if(dataSetName.find("TTbarJets_SemiMu") == 0){
pair<unsigned int, unsigned int> leptonicBJet_, hadronicBJet_, hadronicWJet1_, hadronicWJet2_; //First index is the JET number, second one is the parton
leptonicBJet_ = hadronicBJet_ = hadronicWJet1_ = hadronicWJet2_ = pair<unsigned int, unsigned int>(9999,9999);
vector<TLorentzVector> mcParticlesTLV, selectedJetsTLV;
vector<TRootMCParticle> mcParticlesMatching;
bool muPlusFromTop = false, muMinusFromTop = false;
for(unsigned int i=0; i<mcParticles.size(); i++){
if( mcParticles[i]->status() != 3) continue;
if( mcParticles[i]->type() == 13 && mcParticles[i]->motherType() == -24 && mcParticles[i]->grannyType() == -6 ){
if(muMinusFromTop) cerr<<"muMinusFromTop was already true"<<endl;
muMinusFromTop = true;
}
if( mcParticles[i]->type() == -13 && mcParticles[i]->motherType() == 24 && mcParticles[i]->grannyType() == 6 ){
if(muPlusFromTop) cerr<<"muPlusFromTop was already true"<<endl;
muPlusFromTop = true;
}
if( abs(mcParticles[i]->type()) < 6 || abs(mcParticles[i]->type()) == 21 ){
mcParticlesTLV.push_back(*mcParticles[i]);
mcParticlesMatching.push_back(*mcParticles[i]);
}
}
if(muPlusFromTop && muMinusFromTop)
cerr<<"muPlusFromTop and muMinusFromTop are both true ?!\nCheck if you are using the right sample..."<<endl;
// take all the selectedJets_ to study the radiation stuff, selectedJets are already ordened in decreasing Pt()
for(unsigned int i=0; i<selectedJets.size(); i++)
selectedJetsTLV.push_back(*selectedJets[i]);
JetPartonMatching matching = JetPartonMatching(mcParticlesTLV, selectedJetsTLV, 2, true, true, 0.3);
if(matching.getNumberOfAvailableCombinations() != 1)
cerr << "matching.getNumberOfAvailableCombinations() = "<<matching.getNumberOfAvailableCombinations()<<" This should be equal to 1 !!!"<<endl;
vector< pair<unsigned int, unsigned int> > JetPartonPair, ISRJetPartonPair; // First one is jet number, second one is mcParticle number
for(unsigned int i=0; i<mcParticlesTLV.size(); i++){
int matchedJetNumber = matching.getMatchForParton(i, 0);
if(matchedJetNumber != -1)
JetPartonPair.push_back( pair<unsigned int, unsigned int> (matchedJetNumber, i) );
}
for(unsigned int i=0; i<JetPartonPair.size(); i++){
unsigned int j = JetPartonPair[i].second;
if( fabs(mcParticlesMatching[j].type()) < 6 ){
if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == -24 && mcParticlesMatching[j].grannyType() == -6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == 24 && mcParticlesMatching[j].grannyType() == 6 ) ){
if(hadronicWJet1_.first == 9999)
hadronicWJet1_ = JetPartonPair[i];
else if(hadronicWJet2_.first == 9999)
hadronicWJet2_ = JetPartonPair[i];
else cerr<<"Found a third jet coming from a W boson which comes from a top quark..."<<endl;
}
}
if( fabs(mcParticlesMatching[j].type()) == 5 ){
if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == -6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == 6 ) )
hadronicBJet_ = JetPartonPair[i];
else if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == 6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == -6 ) )
leptonicBJet_ = JetPartonPair[i];
}
}
jetCombi.push_back(hadronicWJet1_.first);
jetCombi.push_back(hadronicWJet2_.first);
jetCombi.push_back(hadronicBJet_.first);
jetCombi.push_back(leptonicBJet_.first);
CorrectQuark1=jetCombi[0];
CorrectQuark2=jetCombi[1];
CorrectBHadronic = jetCombi[2];
CorrectBLeptonic = jetCombi[3];
//------------------------------------------//
// Identifying Monte Carlo particles //
//------------------------------------------//
int EventParticleNumber[5]; //0:top; 1:b; 2: u,c,d,s; 3:W; 4:mu + neutrino
int MuonNeutrinoNumber[4]; //0:mu-; 1:mu+; 2:nu; 3: anti-nu
int ChargeMuonW[4]; //0:mu-; 1:mu+; 2:W-; 3:W+
for(int ll = 0;ll<5;ll++){EventParticleNumber[ll]=0;}
for(int kk = 0;kk<4;kk++){MuonNeutrinoNumber[kk]=0;}
for(int mm = 0;mm<4;mm++){ChargeMuonW[mm]=0;}
int MuonNumber=0;
int EventChargeTop=0; //1 for top, -1 for anti-top
int EventChargeAntiTop=0;
int EventChargeWPos=0; //1 for W+, -1 for W-
int EventChargeWNeg=0;
int EventChargeMuPos=0; //1 for mu+, -1 for mu-
int EventChargeMuNeg =0;
TRootMCParticle Top,AntiTop,WPos,WNeg,Muon,BQuark,BBarQuark,Neutrino,Bottom;
TLorentzVector standardMuonWZMF, standardWLeptonicTZMF;
TRootMCParticle hadrBottom,hadrTop,UpQuark,DownQuark,hadrW;
TLorentzVector hadrWTZMF,UpQuarkWZMF;
for(unsigned int i=0; i<mcParticles.size(); i++){
if( mcParticles[i]->status() != 3) continue;
if(fabs(mcParticles[i]->type()) == 6){//Identifying top quarks
EventParticleNumber[0]++;
if(mcParticles[i]->type()==6){
Top=*mcParticles[i];
EventChargeTop=1;
}
else if(mcParticles[i]->type()==-6){
AntiTop=*mcParticles[i];
EventChargeAntiTop=-1;
}
}
if(fabs(mcParticles[i]->type()) == 5 && fabs(mcParticles[i]->motherType()) == 6){//Identifying bottom quarks
EventParticleNumber[1]++;
if(mcParticles[i]->type()==5){BQuark=*mcParticles[i];}
else BBarQuark=*mcParticles[i];
}
if(fabs(mcParticles[i]->type()) <= 4 && fabs(mcParticles[i]->motherType()) == 24 && fabs(mcParticles[i]->grannyType()) == 6){
EventParticleNumber[2]++;
if(fabs(mcParticles[i]->type())==1 ||fabs(mcParticles[i]->type())==3 ){
UpQuark =*mcParticles[i];
}
else if(fabs(mcParticles[i]->type())==2 ||fabs(mcParticles[i]->type())==4){
DownQuark=*mcParticles[i];
}
}
if(fabs(mcParticles[i]->type()) == 24 && fabs(mcParticles[i]->motherType()) == 6){ //Identifying W bosons
EventParticleNumber[3]++;
if(mcParticles[i]->type()==24){
WPos=*mcParticles[i];
EventChargeWPos=1;
}
else if(mcParticles[i]->type()==-24){
WNeg=*mcParticles[i];
EventChargeWNeg=-1;
}
}
if(fabs(mcParticles[i]->type()) == 14 && fabs(mcParticles[i]->motherType()) == 24 && fabs(mcParticles[i]->grannyType()) == 6){
EventParticleNumber[4]++; //Identifying neutrino's
standardNeutrino=*mcParticles[i];
}
if(fabs(mcParticles[i]->type()) == 13 && fabs(mcParticles[i]->motherType()) == 24 && fabs(mcParticles[i]->grannyType()) == 6 && mcParticles[i]->status()==3){ //status: 1:stable; 2:shower; 3:hard scattering(coming from the studied hard proces)
MuonNumber++; //Identifying muons
EventParticleNumber[4]++;
standardMuon=*mcParticles[i];
if(mcParticles[i]->type()==13){EventChargeMuNeg=-1;}
else if(mcParticles[i]->type()==-13){EventChargeMuPos=1;}
}
}// if 0 < i < mcParticles.size()
//////////////////////////////////////////////////
// Selecting correct event (b b q q mu nu ) //
//////////////////////////////////////////////////
if(EventParticleNumber[0]==2 && EventParticleNumber[1]==2 && EventParticleNumber[2]==2 && EventParticleNumber[3]==2 && EventParticleNumber[4]==2){
//----- Differentiating between proces from top and anti-top (choose leptonic): -----
if(EventChargeTop==1 && EventChargeWPos==1 && EventChargeMuPos==1){ // Proces: t -> b W+ -> mu+ nu
standardWLeptonicTZMF=WPos;
standardWLeptonic=WPos;
standardTop=Top;
Bottom = BQuark;
}
else if(EventChargeAntiTop==-1 && EventChargeWNeg==-1 && EventChargeMuNeg==-1){ //proces: anti-t -> anti-b W- -> mu- anti-nu
standardWLeptonicTZMF=WNeg;
standardWLeptonic=WNeg;
standardTop=AntiTop;
Bottom = BBarQuark;
}
//----- Applying boost on muon and W: -----
standardMuonWZMF=standardMuon;
standardMuonWZMF.Boost(-standardWLeptonicTZMF.BoostVector());
standardWLeptonicTZMF.Boost(-standardTop.BoostVector());
//----- Calculating cos theta: -----
standardCosTheta = ((standardWLeptonicTZMF.Vect()).Dot(standardMuonWZMF.Vect()))/(((standardWLeptonicTZMF.Vect()).Mag())*((standardMuonWZMF.Vect()).Mag()));
TheoreticalDistributionValue = (LongitudinalFraction*6*(1-standardCosTheta*standardCosTheta) + (1-standardCosTheta)*(1-standardCosTheta)*3*LeftHandedFraction + RightHandedFraction*3*(1+standardCosTheta)*(1+standardCosTheta))/8;
histo1D["StandardCosTheta"]->Fill(standardCosTheta); // Histogram without fit
histo1D["StandardCosThetaFit"]->Fill(standardCosTheta); // Histogram with fit
}
}//if dataset Semi mu ttbar
/////////////////////////
// Event selection //
/////////////////////////
bool eventSelected = false;
selecTable.Fill(d,1,1.);
if(trigged){ //selection steps start: https://twiki.cern.ch/twiki/bin/view/CMS/TopLeptonPlusJetsRefSel_mu#Selection_Version_SelV3_for_HCP2
selecTable.Fill(d,2,1.);
if(isGoodPV){
selecTable.Fill(d,3,1.);
if(selectedMuons.size()==1){
selecTable.Fill(d,4,1.);
if(vetoMuons.size()==1){
selecTable.Fill(d,5,1.);
if(vetoElectrons.size()==0){
selecTable.Fill(d,6,1.);
if(init_jets.size()>=4){
}
if(selectedJets.size()>=(unsigned int)anaEnv.NofJets-3){
selecTable.Fill(d,7,1.);
if(selectedJets.size()>=(unsigned int)anaEnv.NofJets-2){
selecTable.Fill(d,8,1.);
if(selectedJets.size()>=(unsigned int)anaEnv.NofJets-1){
selecTable.Fill(d,9,1.);
if(selectedJets.size()>=(unsigned int)anaEnv.NofJets){ //we ask for 4 jets, but this way (with -3,-2,-1)it is possible to look at plots with other amount of jets
selecTable.Fill(d,10,1.);
eventSelected = true;
if(verbose>2) cout << event->runId() << ":" << event->eventId() << ":" << event->lumiBlockId() << ":" << setprecision(8) << selectedMuons[0]->Pt() << endl;
}
}
}
}
}
}
}
}
}
if(eventSelected==true){
float CorrectRecMassW=0;
float CorrectRecMassTop=0;
vector<int> jetCombi;
if(dataSetName.find("TTbarJets_SemiMu") == 0){
pair<unsigned int, unsigned int> leptonicBJet_, hadronicBJet_, hadronicWJet1_, hadronicWJet2_; //First index is the JET number, second one is the parton
leptonicBJet_ = hadronicBJet_ = hadronicWJet1_ = hadronicWJet2_ = pair<unsigned int, unsigned int>(9999,9999);
vector<TLorentzVector> mcParticlesTLV, selectedJetsTLV;
vector<TRootMCParticle> mcParticlesMatching;
bool muPlusFromTop = false, muMinusFromTop = false;
for(unsigned int i=0; i<mcParticles.size(); i++){
if( mcParticles[i]->status() != 3) continue;
if( mcParticles[i]->type() == 13 && mcParticles[i]->motherType() == -24 && mcParticles[i]->grannyType() == -6 ){
if(muMinusFromTop) cerr<<"muMinusFromTop was already true"<<endl;
muMinusFromTop = true;
}
if( mcParticles[i]->type() == -13 && mcParticles[i]->motherType() == 24 && mcParticles[i]->grannyType() == 6 ){
if(muPlusFromTop) cerr<<"muPlusFromTop was already true"<<endl;
muPlusFromTop = true;
}
if( abs(mcParticles[i]->type()) < 6 || abs(mcParticles[i]->type()) == 21 ){
mcParticlesTLV.push_back(*mcParticles[i]);
mcParticlesMatching.push_back(*mcParticles[i]);
}
}
if(muPlusFromTop && muMinusFromTop)
cerr<<"muPlusFromTop and muMinusFromTop are both true ?!\nCheck if you are using the right sample..."<<endl;
// take all the selectedJets_ to study the radiation stuff, selectedJets are already ordened in decreasing Pt()
for(unsigned int i=0; i<selectedJets.size(); i++)
selectedJetsTLV.push_back(*selectedJets[i]);
JetPartonMatching matching = JetPartonMatching(mcParticlesTLV, selectedJetsTLV, 2, true, true, 0.3);
if(matching.getNumberOfAvailableCombinations() != 1)
cerr << "matching.getNumberOfAvailableCombinations() = "<<matching.getNumberOfAvailableCombinations()<<" This should be equal to 1 !!!"<<endl;
vector< pair<unsigned int, unsigned int> > JetPartonPair, ISRJetPartonPair; //First one is jet number, second one is mcParticle number
for(unsigned int i=0; i<mcParticlesTLV.size(); i++){
int matchedJetNumber = matching.getMatchForParton(i, 0);
if(matchedJetNumber != -1)
JetPartonPair.push_back( pair<unsigned int, unsigned int> (matchedJetNumber, i) );
}
for(unsigned int i=0; i<JetPartonPair.size(); i++){
unsigned int j = JetPartonPair[i].second;
if( fabs(mcParticlesMatching[j].type()) < 6 ){
if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == -24 && mcParticlesMatching[j].grannyType() == -6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == 24 && mcParticlesMatching[j].grannyType() == 6 ) ){
if(hadronicWJet1_.first == 9999)
hadronicWJet1_ = JetPartonPair[i];
else if(hadronicWJet2_.first == 9999)
hadronicWJet2_ = JetPartonPair[i];
else cerr<<"Found a third jet coming from a W boson which comes from a top quark..."<<endl;
}
}
if( fabs(mcParticlesMatching[j].type()) == 5 ){
if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == -6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == 6 ) )
hadronicBJet_ = JetPartonPair[i];
else if( ( muPlusFromTop && mcParticlesMatching[j].motherType() == 6 ) || ( muMinusFromTop && mcParticlesMatching[j].motherType() == -6 ) )
leptonicBJet_ = JetPartonPair[i];
}
}
jetCombi.push_back(hadronicWJet1_.first);
jetCombi.push_back(hadronicWJet2_.first);
jetCombi.push_back(hadronicBJet_.first);
jetCombi.push_back(leptonicBJet_.first);
CorrectQuark1=jetCombi[0];
CorrectQuark2=jetCombi[1];
CorrectBHadronic = jetCombi[2];
CorrectBLeptonic = jetCombi[3];
//Working on generator level (i.e. jets level):
if(jetCombi[0]!=9999 && jetCombi[1]!=9999 && jetCombi[2]!=9999 && jetCombi[3]!=9999){
CorrectRecMassW=(*selectedJets[jetCombi[0]]+*selectedJets[jetCombi[1]]).M();
CorrectRecMassTop=(*selectedJets[jetCombi[0]]+*selectedJets[jetCombi[1]]+*selectedJets[jetCombi[2]]).M();
histo1D["WMass"]->Fill(CorrectRecMassW);
histo1D["TopMass"]->Fill(CorrectRecMassTop);
}
}//if dataset Semi mu ttbar
//Reconstruction class WHelicities
//
//std::cout << " Start of calling WHelicities class " << std::endl;
//
std::cout << " ************** Studied event : " << ievt << std::endl;
std::vector<float> bTagValues;
for(int ii = 0; ii<selectedJets.size();ii++){bTagValues.push_back(selectedJets[ii]->btag_trackCountingHighEffBJetTags());}
std::vector<int> ChosenReconstructionJets;
//vector of TLorentzVector should be given as input:
std::vector<float> lorentzJetsPx;
std::vector<float> lorentzJetsPy;
std::vector<float> lorentzJetsPz;
std::vector<float> lorentzJetsE;
for(int ii=0; ii<selectedJets.size();ii++){
lorentzJetsPx.push_back((*selectedJets[ii]).Px());
lorentzJetsPy.push_back((*selectedJets[ii]).Py());
lorentzJetsPz.push_back((*selectedJets[ii]).Pz());
lorentzJetsE.push_back((*selectedJets[ii]).E());
}
std::vector<float> lorentzMuonsPx;
std::vector<float> lorentzMuonsPy;
std::vector<float> lorentzMuonsPz;
std::vector<float> lorentzMuonsE;
for(int ii=0;ii<selectedMuons.size();ii++){
lorentzMuonsPx.push_back((*selectedMuons[ii]).Px());
lorentzMuonsPy.push_back((*selectedMuons[ii]).Py());
lorentzMuonsPz.push_back((*selectedMuons[ii]).Pz());
lorentzMuonsE.push_back((*selectedMuons[ii]).E());
}
//wReconstruction.Initializing(SimulationSampleBoolean,lorentzJetsPx,lorentzJetsPy,lorentzJetsPz,lorentzJetsE,lorentzMuonsPx,lorentzMuonsPy,lorentzMuonsPz,lorentzMuonsE,bTagValues, applyKinFit, applyMVA);
wReconstruction.Initializing(SimulationSampleBoolean,lorentzJetsPx,lorentzJetsPy,lorentzJetsPz,lorentzJetsE,bTagValues);
std::cout << " --------------------------------------------- " << std::endl;
ChosenReconstructionJets = wReconstruction.BTagAnalysis();
std::cout << " value for boolean event : " << ChosenReconstructionJets[4] << std::endl;
bool EventSelectedWithBTag;
if(ChosenReconstructionJets[4]==1)EventSelectedWithBTag=true;
else continue;
std::cout << " hadronic b number : " << ChosenReconstructionJets[0] << std::endl;
std::cout << " leptonic b number : " << ChosenReconstructionJets[1] << std::endl;
std::cout << " quark1 number : " << ChosenReconstructionJets[2] << std::endl;
std::cout << " quark2 number : " << ChosenReconstructionJets[3] << std::endl;
std::cout << " value for boolean event : " << ChosenReconstructionJets[4] << std::endl;
std::cout << " --------------------------------------------- " << std::endl;
int bHadronicNumber = ChosenReconstructionJets[0];
int bLeptonicNumber = ChosenReconstructionJets[1];
int Quark1Number = ChosenReconstructionJets[2];
int Quark2Number = ChosenReconstructionJets[3];
//std::cout << " Clearing used vectors for next event : " << std::endl;
lorentzMuonsPx.clear();
lorentzMuonsPy.clear();
lorentzMuonsPz.clear();
lorentzMuonsE.clear();
lorentzJetsPx.clear();
lorentzJetsPy.clear();
lorentzJetsPz.clear();
lorentzJetsE.clear();
ChosenReconstructionJets.clear();
bTagValues.clear();
/*//////////////////////////////////////////////////
// Calculating correct jet distribution //
//////////////////////////////////////////////////
//
std::cout << " Studied event : " << ievt << std::endl;
int NumberCombinations=0;
for(int i=0;i<3;i++){
for(int j=i+1;j<4;j++){
for(int k=0;k<4;k++){
if(k!=i && k!=j){
if(applyKinFit == true){
TLorentzVector lightJet1 = *selectedJets[i];
TLorentzVector lightJet2 = *selectedJets[j];
TLorentzVector bJet = *selectedJets[k];
// prepare everything for the Kinematic Fit
TMatrixD Ml1(3,3), Ml2(3,3), Mb(3,3);
Ml1.Zero(); Ml2.Zero(); Mb.Zero();
Ml1(0,0) = pow(resFitLightJets_->EtResolution(&lightJet1), 2);
Ml1(1,1) = pow(resFitLightJets_->ThetaResolution(&lightJet1), 2);
Ml1(2,2) = pow(resFitLightJets_->PhiResolution(&lightJet1), 2);
Ml2(0,0) = pow(resFitLightJets_->EtResolution(&lightJet2), 2);
Ml2(1,1) = pow(resFitLightJets_->ThetaResolution(&lightJet2), 2);
Ml2(2,2) = pow(resFitLightJets_->PhiResolution(&lightJet2), 2);
Mb(0,0) = pow(resFitBJets_->EtResolution(&bJet), 2);
Mb(1,1) = pow(resFitBJets_->ThetaResolution(&bJet), 2);
Mb(2,2) = pow(resFitBJets_->PhiResolution(&bJet), 2);
TKinFitter *theFitter = new TKinFitter("hadtopFit", "hadtopFit");
theFitter->setVerbosity(0);
TFitParticleEtThetaPhiEMomFix *fitLight1 = new TFitParticleEtThetaPhiEMomFix("lightJet1", "lightJet1", &lightJet1, &Ml1);
TFitParticleEtThetaPhiEMomFix *fitLight2 = new TFitParticleEtThetaPhiEMomFix("lightJet2", "lightJet2", &lightJet2, &Ml2);
TFitParticleEtThetaPhiEMomFix *fitB = new TFitParticleEtThetaPhiEMomFix("bJet", "bJet", &bJet, &Mb);
theFitter->addMeasParticles(fitLight1,fitLight2,fitB);
TFitConstraintM *consW = new TFitConstraintM("WBosonMass", "MassConstraint", 0, 0, WMassKinFit);
TFitConstraintM *consTop = new TFitConstraintM("TopQuarkMass", "MassConstraint", 0, 0, TopMassKinFit );//Different mass for MC and Data!!
consW->addParticles1(fitLight1,fitLight2);
consTop->addParticles1(fitB,fitLight1,fitLight2);
theFitter->addConstraint(consW);
theFitter->addConstraint(consTop);
theFitter->setMaxNbIter(30);
theFitter->setMaxDeltaS(5e-5);
theFitter->setMaxF(1e-4);
//do the fit!
theFitter->fit();
if (theFitter->getStatus() == 0) // if the fitter converged
ChiSquared[NumberCombinations]=theFitter->getS();
//else
//cout << "FIT NOT CONVERGED" << endl;
delete theFitter;
delete fitLight1;
delete fitLight2;
delete fitB;
delete consW;
delete consTop;
}//Kinematic fit applied
else if(applyMVA==true){
for(int l = 0; l < 4 ; l++){
if(l!=i && l!=j && l!=k){
float btag_i = selectedJets[i]->btag_trackCountingHighEffBJetTags();
if(btag_i < -90) btag_i = 0;
float btag_j = selectedJets[j]->btag_trackCountingHighEffBJetTags();
if(btag_j < -90) btag_j = 0;
float btag_k = selectedJets[k]->btag_trackCountingHighEffBJetTags();
if(btag_k < -90) btag_k = 0;
float btag_l = selectedJets[l]->btag_trackCountingHighEffBJetTags();
if(btag_l < -90) btag_l = 0;
bTagSelected[NumberCombinations]=false;
if(btag_k > 1.7 || btag_l > 1.7){
bTagSelected[NumberCombinations]=true;
}
btag[NumberCombinations] = pow(btag_k,2) + pow(btag_l,2);
btag[NumberCombinations] = btag[NumberCombinations] / ( pow(btag_i,2) + pow(btag_j,2) + pow(btag_k,2) + pow(btag_l,2) );
ProblemEvent = false;
if(btag_i ==0 && btag_j ==0 && btag_k ==0 && btag_k ==0){
btag[NumberCombinations]=0;
ProblemEvent=true;
}
//Leptonic b quark is also obtained with this method:
BLeptonicIndexMVA[NumberCombinations]=l;
}
}
}
else{
float recMassW = (*selectedJets[i]+*selectedJets[j]).M();
float recMassTop=(*selectedJets[i]+*selectedJets[j]+*selectedJets[k]).M();
ChiSquared[NumberCombinations]=pow(((recMassW-MassW)/SigmaW),2)+pow(((recMassTop-MassTop)/SigmaTop),2);
}//No Kinematic Fit applied (minimal chi squared applied)
QuarkOneIndex[NumberCombinations]=i;
QuarkTwoIndex[NumberCombinations]=j;
BHadronicIndex[NumberCombinations]=k;
NumberCombinations++; //Always gives 12 as it should be!
}
}//end of k loop for jet combination selection
}//end of j loop for jet combination selection
}//end of i loop for jet combination selection
//histo1D["MVACombinationBefore"]->Fill(MVACombination[0]);
//
//Select lowest chi squared value:
//
if(applyMVA == false){
ChiSquaredValue=ChiSquared[0];
for(int ii=0;ii<12;ii++){
if(ChiSquaredValue>ChiSquared[ii]){
ChiSquaredValue=ChiSquared[ii];
UsedCombination=ii;
}
}
//
//Jet not in Chisquared combination is the Leptonic B jet
//
for(int ll=0;ll<4;ll++){
if(ll!=QuarkOneIndex[UsedCombination] && ll!=QuarkTwoIndex[UsedCombination] && ll!=BHadronicIndex[UsedCombination]){
std::cout << " calculating leptonic b " << std::endl;
BLeptonicIndex=ll;
}
}
}
else if(applyMVA == true && bTagSelected==true){
std::cout << " ****************************************************** " << std::endl;
BTagValueMVA=0;
MVACombination[0]=12;
MVACombination[1]=12;
histo1D["MVACombinationBefore"]->Fill(MVACombination[0]);
for(int ii=0;ii<12;ii++){ //From the twelve combinations the combination with the highest BTag value is selected
if(BTagValueMVA<btag[ii] && !(fabs(BTagValueMVA-btag[ii])<0.000001)){
BTagValueMVA=btag[ii];
MVACombination[0]=ii;
MVACombination[1]=ii+1;
}
if(fabs(BTagValueMVA-btag[ii])<0.000001){
MVACombination[1]=ii;
}
}
if(ProblemEvent==true){//In this configuration the b-jets have the highest pT which is more reasonable
MVACombination[0]=10;
MVACombination[1]=11;
std::cout << " Filled MVA combination of problem event : " << ievt << std::endl;
}
std::cout << " two mva combinations : " << MVACombination[0] << " | " << MVACombination[1] << std::endl;
if(MVACombination[0]==CorrectBHadronic || MVACombination[0] == CorrectBLeptonic || MVACombination[1] == CorrectBHadronic || MVACombination[1] == CorrectBLeptonic){
BTagCorrectCombination++;
}
BTagCombinationEvents++;
histo1D["MVACombination"]->Fill(MVACombination[0]);
histo1D["MVACombinationTwo"]->Fill(MVACombination[1]);
if(MVACombination[0]==0){CorrectZero++;}
else if(MVACombination[0]==2){CorrectTwo++;}
else if(MVACombination[0]==4){CorrectFour++;}
else if(MVACombination[0]==6){CorrectSix++;}
else if(MVACombination[0]==8){CorrectEight++;}
else if(MVACombination[0]==10){CorrectTen++;}
for(int ii=0;ii<12;ii++){
if(ii!=MVACombination[0] && ii!=MVACombination[1]){
MSPlot["NotSelectedBTag"]->Fill(btag[ii], datasets[d], true, Luminosity*scaleFactor);
}
}
//BLeptonicIndex = BLeptonicIndexMVA[UsedCombination];
//The two obtained values of the MVA have to be compared with a kinematic fit to select the correct event topology.
for(int jj=0;jj<2; jj++){
int MVAComb=MVACombination[jj];
TLorentzVector lightJet1 = *selectedJets[QuarkOneIndex[MVAComb]];
TLorentzVector lightJet2 = *selectedJets[QuarkTwoIndex[MVAComb]];
TLorentzVector bJet = *selectedJets[BHadronicIndex[MVAComb]];
// prepare everything for the Kinematic Fit
TMatrixD Ml1(3,3), Ml2(3,3), Mb(3,3);
Ml1.Zero(); Ml2.Zero(); Mb.Zero();
Ml1(0,0) = pow(resFitLightJets_->EtResolution(&lightJet1), 2);
Ml1(1,1) = pow(resFitLightJets_->ThetaResolution(&lightJet1), 2);
Ml1(2,2) = pow(resFitLightJets_->PhiResolution(&lightJet1), 2);
Ml2(0,0) = pow(resFitLightJets_->EtResolution(&lightJet2), 2);
Ml2(1,1) = pow(resFitLightJets_->ThetaResolution(&lightJet2), 2);
Ml2(2,2) = pow(resFitLightJets_->PhiResolution(&lightJet2), 2);
Mb(0,0) = pow(resFitBJets_->EtResolution(&bJet), 2);
Mb(1,1) = pow(resFitBJets_->ThetaResolution(&bJet), 2);
Mb(2,2) = pow(resFitBJets_->PhiResolution(&bJet), 2);
TKinFitter *theFitter = new TKinFitter("hadtopFit", "hadtopFit");
theFitter->setVerbosity(0);
TFitParticleEtThetaPhiEMomFix *fitLight1 = new TFitParticleEtThetaPhiEMomFix("lightJet1", "lightJet1", &lightJet1, &Ml1);
TFitParticleEtThetaPhiEMomFix *fitLight2 = new TFitParticleEtThetaPhiEMomFix("lightJet2", "lightJet2", &lightJet2, &Ml2);
TFitParticleEtThetaPhiEMomFix *fitB = new TFitParticleEtThetaPhiEMomFix("bJet", "bJet", &bJet, &Mb);
theFitter->addMeasParticles(fitLight1,fitLight2,fitB);
TFitConstraintM *consW = new TFitConstraintM("WBosonMass", "MassConstraint", 0, 0, WMassKinFit);
TFitConstraintM *consTop = new TFitConstraintM("TopQuarkMass", "MassConstraint", 0, 0, TopMassKinFit );//Different mass for MC and Data!!
consW->addParticles1(fitLight1,fitLight2);
consTop->addParticles1(fitB,fitLight1,fitLight2);
theFitter->addConstraint(consW);
theFitter->addConstraint(consTop);
theFitter->setMaxNbIter(30);
theFitter->setMaxDeltaS(5e-5);
theFitter->setMaxF(1e-4);
//do the fit!
theFitter->fit();
if (theFitter->getStatus() == 0) // if the fitter converged
ChiSquared[jj]=theFitter->getS();
//else
//cout << "FIT NOT CONVERGED" << endl;
delete theFitter;
delete fitLight1;
delete fitLight2;
delete fitB;
delete consW;
delete consTop;
}
ChiSquaredValue=ChiSquared[0];
int ChosenNumber;
UsedCombination=MVACombination[0];
for(int ii=0;ii<2;ii++){
if(ChiSquaredValue>ChiSquared[ii]){
ChiSquaredValue=ChiSquared[ii];
UsedCombination=MVACombination[ii];
ChosenNumber=ii;
}
}
BLeptonicIndex=BLeptonicIndexMVA[UsedCombination];
for(int ii=0;ii<2;ii++){
if(ii!=ChosenNumber){
MSPlot["NotSelectedChiSq"]->Fill(ChiSquared[ii], datasets[d], true, Luminosity*scaleFactor);
histo2D["MVACorrelationPlotWrong"]->Fill(ChiSquared[ii],BTagValueMVA);
}
}
//Make correlation plot for Chi2 and btag of MVA method:
//
histo2D["MVACorrelationPlot"]->Fill(ChiSquaredValue,BTagValueMVA);
std::cout << " bhadronic number : " << BHadronicIndex[UsedCombination] << std::endl;
std::cout << " bleptonic number : " << BLeptonicIndex << std::endl;
std::cout << " quark1 number : " << QuarkOneIndex[UsedCombination] << std::endl;
std::cout << " quark2 number : " << QuarkTwoIndex[UsedCombination] << std::endl;
std::cout << " " << std::endl;
std::cout << " ****************************************************** " << std::endl;
std::cout << " " << std::endl;
}*/
// if(bTagSelected == true){
// //Only for Mc data, check if chosen combination is correct
// //
// if(dataSetName.find("TTbarJets_SemiMu") == 0){
// int EventWrong = 1;
// float RecoTopMassHadrTT = (*selectedJets[QuarkOneIndex[UsedCombination]] + *selectedJets[QuarkTwoIndex[UsedCombination]] + *selectedJets[BHadronicIndex[UsedCombination]]).M();
// NumberSemiMuEvents++;
// if((QuarkOneIndex[UsedCombination]==CorrectQuark1 && QuarkTwoIndex[UsedCombination]==CorrectQuark2 && BHadronicIndex[UsedCombination]==CorrectBHadronic && BLeptonicIndex==CorrectBLeptonic) || (QuarkOneIndex[UsedCombination]==CorrectQuark2 && QuarkTwoIndex[UsedCombination]==CorrectQuark1 && BHadronicIndex[UsedCombination]==CorrectBHadronic && BLeptonicIndex==CorrectBLeptonic)){
// AllJetsCorrect++;
// histo1D["TopMassForCorrect"]->Fill(RecoTopMassHadrTT);
// MSPlot["ChiSquaredCorrect"]->Fill(ChiSquaredValue, datasets[d], true, Luminosity*scaleFactor);
// if(applyMVA==true && bTagSelected==true){
// MSPlot["BTagValueMVACorrect"]->Fill(BTagValueMVA,datasets[d],true,Luminosity*scaleFactor);
// histo2D["BtagForTopCorrect"]->Fill(RecoTopMassHadrTT,BTagValueMVA);
// }
// }
// if((QuarkOneIndex[UsedCombination]!=CorrectQuark1 && QuarkTwoIndex[UsedCombination]!=CorrectQuark2 && BHadronicIndex[UsedCombination]!=CorrectBHadronic && BLeptonicIndex!=CorrectBLeptonic) ||(QuarkOneIndex[UsedCombination]!=CorrectQuark2 && QuarkTwoIndex[UsedCombination]!=CorrectQuark1 && BHadronicIndex[UsedCombination]!=CorrectBHadronic && BLeptonicIndex!=CorrectBLeptonic)){
// OneJetWrong++;
// histo1D["TopMassForWrong"]->Fill(RecoTopMassHadrTT);
// MSPlot["ChiSquaredWrong"]->Fill(ChiSquaredValue, datasets[d], true, Luminosity*scaleFactor);
// if(applyMVA==true && bTagSelected==true){
// MSPlot["BTagValueMVAWrong"]->Fill(BTagValueMVA,datasets[d],true,Luminosity*scaleFactor);
// histo2D["BtagForTopWrong"]->Fill(RecoTopMassHadrTT,BTagValueMVA);
// }
// EventWrong=0;
// }
// if(QuarkOneIndex[UsedCombination]==CorrectQuark1 ||QuarkOneIndex[UsedCombination]==CorrectQuark2 || QuarkTwoIndex[UsedCombination]==CorrectQuark1 || QuarkTwoIndex[UsedCombination]==CorrectQuark2 || BHadronicIndex[UsedCombination]==CorrectBHadronic || BLeptonicIndex==CorrectBLeptonic ){
// histo1D["TopMassNotWrong"]->Fill(RecoTopMassHadrTT);
// }
// //if(BLeptonicIndex==CorrectBLeptonic && bTagValue>1.7){
// //numberCorrectLeptonicBLowbTag++;
// //}
// if(BHadronicIndex[UsedCombination]==CorrectBHadronic){
// numberCorrectHadronicB++;
// }
// if((QuarkOneIndex[UsedCombination]==CorrectQuark1 && QuarkTwoIndex[UsedCombination]==CorrectQuark2) ||(QuarkOneIndex[UsedCombination]==CorrectQuark2 && QuarkTwoIndex[UsedCombination]==CorrectQuark1)){
// numberCorrectQuarks++;
// }
// //Compare reconstructed mass against corresponding chi squared value (and btag value in MVA case)
// histo2D["ChiSquaredForTop"]->Fill(RecoTopMassHadrTT,ChiSquaredValue);
// if(applyMVA==true && bTagSelected==true){
// histo2D["BtagForTop"]->Fill(RecoTopMassHadrTT,BTagValueMVA);
// }
// histo1D["TopMassReco"]->Fill(RecoTopMassHadrTT);
// }
// MSPlot["ChiSquared"]->Fill(ChiSquaredValue,datasets[d],true,Luminosity*scaleFactor);
// MSPlot["BTagValueMVA"]->Fill(BTagValueMVA,datasets[d],true,Luminosity*scaleFactor);
// ////////////////////////////////////////////////////////////////
// // Calculating MET_Pz() (equation ax² + bx + c = 0 ): //
// ////////////////////////////////////////////////////////////////
// //
// // MET_Px() and MET_Py() is known since there is no Px() and Py() component before the collision.
// // The Pz() component before the collision is not known for proton-proton collisions.
// //
// NeutrinoPx = -(*selectedMuons[0]+*selectedJets[0]+*selectedJets[1]+*selectedJets[2]+*selectedJets[3]).Px();
// NeutrinoPy = -(*selectedMuons[0]+*selectedJets[0]+*selectedJets[1]+*selectedJets[2]+*selectedJets[3]).Py();
// //Calculating solutions for quadratic equation
// //
// float aCoefficient = 4*pow(selectedMuons[0]->E(),2)-4*pow(selectedMuons[0]->Pz(),2);
// float bCoefficient = 4*(selectedMuons[0]->Pz())*(pow(selectedMuons[0]->M(),2)-pow(MassW,2)-2*(selectedMuons[0]->Px())*NeutrinoPx-2*(selectedMuons[0]->Py())*NeutrinoPy);
// float cCoefficient = -pow(selectedMuons[0]->M(),4)-pow(MassW,4)-4*pow(selectedMuons[0]->Px(),2)*pow(NeutrinoPx,2)-4*pow(selectedMuons[0]->Py(),2)*pow(NeutrinoPy,2)+4*(pow(selectedMuons[0]->M(),2)-pow(MassW,2))*((selectedMuons[0]->Px())*NeutrinoPx+(selectedMuons[0]->Py())*NeutrinoPy)-8*(selectedMuons[0]->Px())*NeutrinoPx*(selectedMuons[0]->Py())*NeutrinoPy+4*pow(selectedMuons[0]->E(),2)*pow(NeutrinoPx,2)+4*pow(selectedMuons[0]->E(),2)*pow(NeutrinoPy,2)+2*(pow(MassW,2))*(pow(selectedMuons[0]->M(),2));
// float DCoefficient = pow(bCoefficient,2)-4*aCoefficient*cCoefficient;
// if(DCoefficient>=0){ //Still need to find solution for D<0 !!!
// float NeutrinoPzOne = ((-bCoefficient + sqrt(DCoefficient))/(aCoefficient*2));
// float NeutrinoPzTwo = ((-bCoefficient - sqrt(DCoefficient))/(aCoefficient*2));
// float NeutrinoEOne = sqrt(NeutrinoPx*NeutrinoPx+NeutrinoPy*NeutrinoPy+NeutrinoPzOne*NeutrinoPzOne);
// float NeutrinoETwo = sqrt(NeutrinoPx*NeutrinoPx+NeutrinoPy*NeutrinoPy+NeutrinoPzTwo*NeutrinoPzTwo);
// TLorentzVector NeutrinoOne;
// NeutrinoOne.SetPxPyPzE(NeutrinoPx,NeutrinoPy,NeutrinoPzOne,NeutrinoEOne); //Has to be initialized like this !
// TLorentzVector NeutrinoTwo;
// NeutrinoTwo.SetPxPyPzE(NeutrinoPx,NeutrinoPy,NeutrinoPzTwo,NeutrinoETwo);
// float TopMassDiffOne = (MassTop -((NeutrinoOne+*selectedMuons[0]+*selectedJets[BLeptonicIndex]).M()) );
// float TopMassDiffTwo = (MassTop -((NeutrinoTwo+*selectedMuons[0]+*selectedJets[BLeptonicIndex]).M()) );
// //----- Selected neutrino has the smallest derivation from the top mass -----
// //
// if(fabs(TopMassDiffOne)<fabs(TopMassDiffTwo)){
// NeutrinoPz=NeutrinoPzOne;
// NeutrinoE = NeutrinoEOne;
// }
// else{
// NeutrinoPz=NeutrinoPzTwo;
// NeutrinoE = NeutrinoETwo;
// }
// Neutrino.SetPxPyPzE(NeutrinoPx,NeutrinoPy,NeutrinoPz,NeutrinoE);
// WLeptonic = (Neutrino+*selectedMuons[0]);
// TopLeptonic = (Neutrino+*selectedMuons[0]+*selectedJets[BLeptonicIndex]);
// //Reboost the particles to rest frames
// //
// MuonWZMF = *selectedMuons[0]; // In W Zero Mass Frame (WZMF)
// WLeptonicTZMF = WLeptonic; // In Top Zero Mass Frame (TZMF)
// MuonWZMF.Boost(-WLeptonic.BoostVector());
// WLeptonicTZMF.Boost(-TopLeptonic.BoostVector());
// //Calculating cos:
// CosTheta = ((WLeptonicTZMF.Vect()).Dot(MuonWZMF.Vect()))/(((WLeptonicTZMF.Vect()).Mag())*((MuonWZMF.Vect()).Mag()));
// MSPlot["CosTheta"]->Fill(CosTheta,datasets[d],true,Luminosity*scaleFactor);//No applied weight: CosTheta is the same for all helicities
// if(dataSetName.find("Data") == 0){ //Make histogram with only CosTheta values for Data sample
// histo1D["CosThetaData"]->Fill(CosTheta); //No applied weight since this is considered as Data!!
// //histo1D["CosThetaData"]->Fill(CosTheta,scaleFactor*Luminosity*datasets[d]->NormFactor()); //Bckg systematics
// }
// //Systematics run:
// //
// histo1D["CosThetaData"]->Fill(CosTheta,scaleFactor*Luminosity*datasets[d]->NormFactor());
// if(dataSetName.find("Data") != 0){ //Make histogram with CosTheta values for non-Data sample
// histo1D["CosThetaMC"]->Fill(CosTheta,scaleFactor*Luminosity*datasets[d]->NormFactor());
// }
// //////////////////////////////////////////////////
// // Create loop with different helicities //
// //////////////////////////////////////////////////
// float HelicityFraction[3]; //0:Longitudinal; 1: Righthanded; 2: Lefthanded
// float UsedDistributionValue = 0;
// float HelicityWeight = 0;
// for(int Longit =0;Longit <=NumberOfHelicityBins;Longit++){
// for(int Right =0; Right <=(NumberOfHelicityBins-Longit) ; Right++){
// int Left = NumberOfHelicityBins-Longit-Right;
// double longit=Longit*(1.00/NumberOfHelicityBins);
// double right=Right*(1.00/NumberOfHelicityBins);
// double left=Left*(1.00/NumberOfHelicityBins);
// std::string THistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// std::string HelicityWeightHisto = "HelicityWeightRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// HelicityFraction[0]=longit;
// HelicityFraction[1]=right;
// HelicityFraction[2]=left;
// HelicityWeight=1; //enkel voor ttMu via herweging, voor alle andere: HelicityWeight==1
// if(dataSetName.find("TTbarJets_SemiMu") == 0){
// UsedDistributionValue = (HelicityFraction[0]*6*(1-standardCosTheta*standardCosTheta) + (1-standardCosTheta)*(1-standardCosTheta)*3*HelicityFraction[2] + HelicityFraction[1]*3*(1+standardCosTheta)*(1+standardCosTheta))/8;
// HelicityWeight = UsedDistributionValue/TheoreticalDistributionValue;
// histo1D[HelicityWeightHisto]->Fill(HelicityWeight);
// if(standardCosTheta == 0){
// std::cout << ievt << ") Still problem with Standard cos theta " << std::endl;
// }
// }
// if(dataSetName.find("Data") != 0){
// histo1D[THistoName]->Fill(CosTheta,(HelicityWeight*Luminosity*scaleFactor*datasets[d]->NormFactor()));
// } // end of MC loop (not Data)
// } // end of second helicity loop
// } // end of first helicity loop
// } //end of D>=0 loop
// }// end of bTagSelected loop
} //delete selection;
}//loop on events
// /*//////////////////////////////////////////////////////////////////////////// --> No reweighting to PValue = 1 !!
// //--- Compare Data values with simulated values for all helicities ---//
// ////////////////////////////////////////////////////////////////////////////
// // --> Should be outside eventloop since histograms should be filled
// //
// std::string HighestPValueCosTheta;
// std::string LowestChiSqValueCosTheta;
// if(d==(datasets.size()-1)){ //Go in this loop when the last datasample is active
// int NumberHelicity = 0;
// //Loop to calculate the ChiSquaredValues:
// for(int Longit =0;Longit <=NumberOfHelicityBins;Longit++){
// for(int Right =0; Right <=(NumberOfHelicityBins-Longit) ; Right++){
// int Left = NumberOfHelicityBins-Longit-Right;
// double longit=Longit*(1.00/NumberOfHelicityBins);
// double right=Right*(1.00/NumberOfHelicityBins);
// double left=Left*(1.00/NumberOfHelicityBins);
// std::string THistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// std::string ChiSquaredHelicity = "ChiSquaredRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// //Loop over all bins of CosTheta (weighted) and CosThetaData to calculate ChiSquared for each helicity combination
// //
// //To compare MC and data scale them to equal number of entries:
// //
// float ScaleValue = histo1D["CosThetaData"]->Integral();
// histo1D[THistoName]->Scale(ScaleValue/histo1D[THistoName]->Integral());
// //std::cout << " Integral of Data : " << histo1D["CosThetaData"]->Integral() << " | Integral of MC (after scaling) : " << histo1D[THistoName]->Integral() << std::endl;
// float ChiSquaredAllBins =0;
// for(int ii=1;ii<=CosThetaBinNumber;ii++){ //Bin 0 = underflow bin ==> Does not need to be considered!
// ChiSquaredAllBins=ChiSquaredAllBins+((((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))*(((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))); //Total Chi Squared = Sum of chi squared for all bins
// } // end of loop over all bins
// NumberHelicity++;
// float PValueAllBins = TMath::Prob(ChiSquaredAllBins,CosThetaBinNumber);
// histo1D["PValueAllBins"]->SetBinContent(NumberHelicity,PValueAllBins);
// //Calculate highest p-value
// if(HighestPValue<PValueAllBins){
// HighestPValue = PValueAllBins;
// HighestPValueCosTheta = THistoName;
// }
// float XBinValue = histo2D["HelicityPointsPlot"]->GetXaxis()->FindBin(right);
// float YBinValue = histo2D["HelicityPointsPlot"]->GetYaxis()->FindBin(longit);
// histo2D["HelicityPointsPlot"]->SetBinContent(XBinValue,YBinValue,PValueAllBins);
// histo2D["ChiSqPlot"]->SetBinContent(XBinValue,YBinValue,ChiSquaredAllBins);
// histo2D["HelicityPointsPlot"]->SetXTitle("f+");
// histo2D["HelicityPointsPlot"]->SetYTitle("f0");
// } //end of second helicity loop
// } // end of first helicity loop
// //Write out histogram with highest p-value
// TCanvas* HighestPValueCanvas = new TCanvas("HighestPValue","HighestPValue",1400,600);
// std::cout << " highest p value : " << HighestPValue << " corresponding to cos theta : " << HighestPValueCosTheta << std::endl;
// histo1D[HighestPValueCosTheta]->SetXTitle("Cos theta");
// histo1D[HighestPValueCosTheta]->SetYTitle("Entries");
// HighestPValueCanvas->cd();
// histo1D[HighestPValueCosTheta]->Draw();
// HighestPValueCanvas->Modified();
// HighestPValueCanvas->SaveAs("PlotsMacro/HighestPValueCosTheta.png");
// std::cout << "--------------- Effiency of b-tag analysis: -------------------- " << std::endl;
// std::cout << " Total number of studied events : " << BTagCombinationEvents << std::endl;
// std::cout << " Number of events with one of the b-tags correct : " << BTagCorrectCombination << std::endl;
// std::cout << " " << std::endl;
// std::cout << " Combination Zero : " << CorrectZero << std::endl;
// std::cout << " Combination Two : " << CorrectTwo << std::endl;
// std::cout << " Combination Four : " << CorrectFour << std::endl;
// std::cout << " Combination Six : " << CorrectSix << std::endl;
// std::cout << " Combination Eight : " << CorrectEight << std::endl;
// std::cout << " Combination Ten : " << CorrectTen << std::endl;
// std::cout << " " << std::endl;
// //---------------- Output for event selection efficiency ----------------
// std::cout << " total number of semi-muonic events : " << NumberSemiMuEvents << std::endl;
// std::cout << " All jets correctly matched : " << AllJetsCorrect << std::endl;
// std::cout << " One of the jets wrongly matched : " << OneJetWrong << std::endl;
// std::cout << " Hadronic B quark correct : " << numberCorrectHadronicB << std::endl;
// std::cout << " Light quarks correct : " << numberCorrectQuarks << std::endl;
// //-------------------- Sigma for W Mass and Top Mass --------------------
// histo1D["WMass"]->Fit("gaus","Q");
// histo1D["TopMass"]->Fit("gaus","Q");
// std::cout << " sigma values : " << histo1D["WMass"]->GetFunction("gaus")->GetParameter(2) << " " << histo1D["TopMass"]->GetFunction("gaus")->GetParameter(2) << std::endl;
// std::cout << " mass values : " << histo1D["WMass"]->GetFunction("gaus")->GetParameter(1) << " " << histo1D["TopMass"]->GetFunction("gaus")->GetParameter(1) << std::endl;
// //-------------------- Fit to collect used helicity values --------------------
// // if(dataSetName.find("TTbarJets_SemiMu") == 0){
// // TF1 *helicityFit = new TF1("helicityFit","((([0]*3*(1+x)*(1+x))+([1]*3*(1-x)*(1-x))+([2]*6*(1-x*x)))/8)",-1,1);
// // histo1D["StandardCosThetaFit"]->Fit("helicityFit","Q");
// // std::cout << " fit values (before event selection) : " << helicityFit->GetParameter(0) << " " << helicityFit->GetParameter(1) << " " << helicityFit->GetParameter(2) << std::endl;
// // std::cout << " fit values error (before event selection) : " << helicityFit->GetParError(0) << " " << helicityFit->GetParError(1) << " " << helicityFit->GetParError(2) << std::endl;
// // }
// } // end of Data loop */ //--> Calculating pValues without putting the maximum on 1 !!
// ////////////////////////////////////////////////////////////////////////////
// //--- Compare Data values with simulated values for all helicities ---//
// ////////////////////////////////////////////////////////////////////////////
// // --> Should be outside eventloop since histograms should be filled
// //
// std::string HighestPValueCosTheta;
// std::string LowestChiSqValueCosTheta;
// if(d==(datasets.size()-1)){ //Go in this loop when the last datasample is active
// int NumberHelicity = 0;
// //Loop to calculate the ChiSquaredValues:
// for(int Longit =0;Longit <=NumberOfHelicityBins;Longit++){
// for(int Right =0; Right <=(NumberOfHelicityBins-Longit) ; Right++){
// int Left = NumberOfHelicityBins-Longit-Right;
// double longit=Longit*(1.00/NumberOfHelicityBins);
// double right=Right*(1.00/NumberOfHelicityBins);
// double left=Left*(1.00/NumberOfHelicityBins);
// std::string THistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// std::string ChiSquaredHelicity = "ChiSquaredRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// //Loop over all bins of CosTheta (weighted) and CosThetaData to calculate ChiSquared for each helicity combination
// //
// float ChiSquaredAllBins =0;
// for(int ii=1;ii<=CosThetaBinNumber;ii++){ //Bin 0 = underflow bin ==> Does not need to be considered!
// ChiSquaredAllBins=ChiSquaredAllBins+((((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))*(((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))); //Total Chi Squared = Sum of chi squared for all bins
// } // end of loop over all bins
// //Calculate lowest ChiSquaredValue
// if(LowestChiSqValue>ChiSquaredAllBins){
// LowestChiSqValue = ChiSquaredAllBins;
// LowestChiSqValueCosTheta = THistoName;
// }
// } //end of second helicity loop
// } // end of first helicity loop
// //Loop to calculate the ChiSquaredValue-LowestChiSquared --> Makes it possible to compare the different results!!
// for(int Longit =0;Longit <=NumberOfHelicityBins;Longit++){
// for(int Right =0; Right <=(NumberOfHelicityBins-Longit) ; Right++){
// int Left = NumberOfHelicityBins-Longit-Right;
// double longit=Longit*(1.00/NumberOfHelicityBins);
// double right=Right*(1.00/NumberOfHelicityBins);
// double left=Left*(1.00/NumberOfHelicityBins);
// std::string THistoName = "CosThetaRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// std::string ChiSquaredHelicity = "ChiSquaredRight"+HelicityNumber[Right]+"Long"+HelicityNumber[Longit]+"Left"+HelicityNumber[Left];
// //Loop over all bins of CosTheta (weighted) and CosThetaData to calculate ChiSquared for each helicity combination
// //
// float ChiSquaredAllBins =0;
// for(int ii=1;ii<=CosThetaBinNumber;ii++){ //Bin 0 = underflow bin ==> Does not need to be considered!
// ChiSquaredAllBins=ChiSquaredAllBins+((((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))*(((histo1D[THistoName]->GetBinContent(ii))-(histo1D["CosThetaData"]->GetBinContent(ii)))/(sqrt(histo1D["CosThetaData"]->GetBinContent(ii))))); //Total Chi Squared = Sum of chi squared for all bins
// } // end of loop over all bins
// ChiSquaredAllBins = ChiSquaredAllBins-LowestChiSqValue;
// NumberHelicity++;
// float PValueAllBins = TMath::Prob(ChiSquaredAllBins,CosThetaBinNumber);
// histo1D["PValueAllBins"]->SetBinContent(NumberHelicity,PValueAllBins);
// //Calculate highest p-value
// if(HighestPValue<PValueAllBins){
// HighestPValue = PValueAllBins;
// HighestPValueCosTheta = THistoName;
// }
// float XBinValue = histo2D["HelicityPointsPlot"]->GetXaxis()->FindBin(right);
// float YBinValue = histo2D["HelicityPointsPlot"]->GetYaxis()->FindBin(longit);
// histo2D["HelicityPointsPlot"]->SetBinContent(XBinValue,YBinValue,PValueAllBins);
// histo2D["ChiSqPlot"]->SetBinContent(XBinValue,YBinValue,ChiSquaredAllBins);
// histo2D["HelicityPointsPlot"]->SetXTitle("f+");
// histo2D["HelicityPointsPlot"]->SetYTitle("f0");
// } //end of second helicity loop
// } // end of first helicity loop
// //Write out histogram with highest p-value
// TCanvas* HighestPValueCanvas = new TCanvas("HighestPValue","HighestPValue",1400,600);
// std::cout << " highest p value : " << HighestPValue << " corresponding to cos theta : " << HighestPValueCosTheta << std::endl;
// histo1D[HighestPValueCosTheta]->SetXTitle("Cos theta");
// histo1D[HighestPValueCosTheta]->SetYTitle("Entries");
// HighestPValueCanvas->cd();
// histo1D[HighestPValueCosTheta]->Draw();
// HighestPValueCanvas->Modified();
// HighestPValueCanvas->SaveAs("PlotsMacro/HighestPValueCosTheta.png");
// std::cout << "--------------- Effiency of b-tag analysis: -------------------- " << std::endl;
// std::cout << " Total number of studied events : " << BTagCombinationEvents << std::endl;
// std::cout << " Number of events with one of the b-tags correct : " << BTagCorrectCombination << std::endl;
// std::cout << " " << std::endl;
// std::cout << " Combination Zero : " << CorrectZero << std::endl;
// std::cout << " Combination Two : " << CorrectTwo << std::endl;
// std::cout << " Combination Four : " << CorrectFour << std::endl;
// std::cout << " Combination Six : " << CorrectSix << std::endl;
// std::cout << " Combination Eight : " << CorrectEight << std::endl;
// std::cout << " Combination Ten : " << CorrectTen << std::endl;
// std::cout << " " << std::endl;
// //---------------- Output for event selection efficiency ----------------
// std::cout << " total number of semi-muonic events : " << NumberSemiMuEvents << std::endl;
// std::cout << " All jets correctly matched : " << AllJetsCorrect << std::endl;
// std::cout << " One of the jets wrongly matched : " << OneJetWrong << std::endl;
// std::cout << " Hadronic B quark correct : " << numberCorrectHadronicB << std::endl;
// std::cout << " Light quarks correct : " << numberCorrectQuarks << std::endl;
// //-------------------- Sigma for W Mass and Top Mass --------------------
// histo1D["WMass"]->Fit("gaus","Q");
// histo1D["TopMass"]->Fit("gaus","Q");
// std::cout << " sigma values : " << histo1D["WMass"]->GetFunction("gaus")->GetParameter(2) << " " << histo1D["TopMass"]->GetFunction("gaus")->GetParameter(2) << std::endl;
// std::cout << " mass values : " << histo1D["WMass"]->GetFunction("gaus")->GetParameter(1) << " " << histo1D["TopMass"]->GetFunction("gaus")->GetParameter(1) << std::endl;
// //-------------------- Fit to collect used helicity values --------------------
// // if(dataSetName.find("TTbarJets_SemiMu") == 0){
// // TF1 *helicityFit = new TF1("helicityFit","((([0]*3*(1+x)*(1+x))+([1]*3*(1-x)*(1-x))+([2]*6*(1-x*x)))/8)",-1,1);
// // histo1D["StandardCosThetaFit"]->Fit("helicityFit","Q");
// // std::cout << " fit values (before event selection) : " << helicityFit->GetParameter(0) << " " << helicityFit->GetParameter(1) << " " << helicityFit->GetParameter(2) << std::endl;
// // std::cout << " fit values error (before event selection) : " << helicityFit->GetParError(0) << " " << helicityFit->GetParError(1) << " " << helicityFit->GetParError(2) << std::endl;
// // }
// } // end of Data loop
//important: free memory
treeLoader.UnLoadDataset();
} //loop on datasets -->Stops already here
//Once everything is filled ...
if (verbose > 0)
cout << " We ran over all the data ;-)" << endl;
//Selection tables
selecTable.TableCalculator(false, true, true, true);
string selectiontable = "SelectionTable_Macro";
if (argc >= 3){
string sample=string(argv[2]);
selectiontable = selectiontable +"_"+sample;
}
selectiontable = selectiontable +".tex";
selecTable.Write(selectiontable.c_str());
// Do some special things with certain plots (normalize, BayesDivide, ... )
if (verbose > 0)
cout << "Treating the special plots." << endl;
///////////////////
// Writting
//////////////////
if (verbose > 1)
cout << " - Writing outputs on files ..." << endl;
string pathPNG = "CernStudy/PValueMaximumInfluence/PlotsMacro";
if (argc >= 3){
string sample=string(argv[2]);
pathPNG = pathPNG+"_"+sample;
}
pathPNG = pathPNG +"/";
mkdir(pathPNG.c_str(),0777);
mkdir((pathPNG+"MSPlot/").c_str(),0777);
// 1D
TDirectory* th1dir = fout->mkdir("1D_histograms");
for(map<string,MultiSamplePlot*>::const_iterator it = MSPlot.begin(); it != MSPlot.end(); it++){ //Because all the histograms are stored as maps it is quite easy to loop over them
MultiSamplePlot *temp = it->second;
string name = it->first;
temp->Draw(false, name, true, true, true);
temp->Write(fout, name, true, pathPNG+"MSPlot/");
}
//Write histograms
fout->cd();
th1dir->cd();
fout->cd();
for(std::map<std::string,TH1F*>::const_iterator it = histo1D.begin(); it != histo1D.end(); it++){
TH1F *temp = it->second;
string name = it->first;
if( name.find("HelicityWeightRight") !=0 && name.find("CosThetaRight") != 0 ){//Does not want to write out these 5151 histograms (2X)
int N = temp->GetNbinsX();
temp->SetBinContent(N,temp->GetBinContent(N)+temp->GetBinContent(N+1));
temp->SetBinContent(N+1,0);
temp->Write();
TCanvas* tempCanvas = TCanvasCreator(temp, it->first);
tempCanvas->SaveAs( (pathPNG+it->first+".png").c_str() );
}
}
// 2D
TDirectory* th2dir = fout->mkdir("2D_histograms_graphs");
th2dir->cd();
for(std::map<std::string,TH2F*>::const_iterator it = histo2D.begin(); it != histo2D.end(); it++){
TH2F *temp = it->second;
temp->Write();
TCanvas* tempCanvas = TCanvasCreator(temp, it->first);
tempCanvas->SaveAs( (pathPNG+it->first+".png").c_str() );
}
//Write TGraphAsymmErrors
for(map<string,TGraphAsymmErrors*>::const_iterator it = graphAsymmErr.begin(); it != graphAsymmErr.end(); it++){
TGraphAsymmErrors *temp = it->second;
temp->Write();
TCanvas* tempCanvas = TCanvasCreator(temp, it->first);
tempCanvas->SaveAs( (pathPNG+it->first+".png").c_str() );
}
fout->cd();
//add configuration info
fout->cd();
configTree->Fill();
configTree->Write();
//Write TGraphErrors
fout->cd();
for(map<string,TGraphErrors*>::const_iterator it = graphErr.begin(); it != graphErr.end(); it++){
TGraphErrors *temp = it->second;
temp->Write();
TCanvas* tempCanvas = TCanvasCreator(temp, it->first);
tempCanvas->SaveAs( (pathPNG+it->first+".png").c_str() );
}
//
if (verbose > 1)
cout << " - Done with writing the module outputs in the ouput file ..." << endl;
cout << " - Closing the output file now..." << endl;
// fout->Write();
fout->Close();
delete fout;
delete tcdatasets;
delete tcAnaEnv;
delete configTree;
cout << "It took us " << ((double)clock() - start) / CLOCKS_PER_SEC << " to run the program" << endl;
cout << "********************************************" << endl;
cout << " End of the program !! " << endl;
cout << " hasn't crashed yet ;-) " << endl;
cout << "********************************************" << endl;
return 0;
}
| [
"rebeca@cern.ch"
] | rebeca@cern.ch |
50321410dc718652435763b22958f8e914c6b525 | 91733c935dafd770fa01e87acea4d235f3200e4e | /src/WString.cpp | 87378d9912515ffe893978c5bd6337f00d8496f9 | [] | no_license | Coloryr/project6 | d9c6164511adf02073c215d8fbee5f1dad63f695 | d8905b2dc9beb1d350bbe8cdcc47494d8ff20301 | refs/heads/main | 2023-04-06T06:30:17.082282 | 2021-04-18T03:48:30 | 2021-04-18T03:48:30 | 329,954,819 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,209 | cpp | /*
WString.cpp - String library for Wiring & Arduino
...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All rights reserved.
Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "WString.h"
#include "itoa.h"
#include "dtostrf.h"
#include "pgmspace.h"
/*********************************************/
/* Constructors */
/*********************************************/
String::String(const char *cstr)
{
init();
if (cstr) {
copy(cstr, strlen(cstr));
}
}
String::String(const String &value)
{
init();
*this = value;
}
String::String(const __FlashStringHelper *pstr)
{
init();
*this = pstr;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String::String(String &&rval)
{
init();
move(rval);
}
String::String(StringSumHelper &&rval)
{
init();
move(rval);
}
#endif
String::String(char c)
{
init();
char buf[2];
buf[0] = c;
buf[1] = 0;
*this = buf;
}
String::String(unsigned char value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned char)];
utoa(value, buf, base);
*this = buf;
}
String::String(int value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(int)];
itoa(value, buf, base);
*this = buf;
}
String::String(unsigned int value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned int)];
utoa(value, buf, base);
*this = buf;
}
String::String(long value, unsigned char base)
{
init();
char buf[2 + 8 * sizeof(long)];
ltoa(value, buf, base);
*this = buf;
}
String::String(unsigned long value, unsigned char base)
{
init();
char buf[1 + 8 * sizeof(unsigned long)];
ultoa(value, buf, base);
*this = buf;
}
String::String(float value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::String(double value, unsigned char decimalPlaces)
{
init();
char buf[33];
*this = dtostrf(value, (decimalPlaces + 2), decimalPlaces, buf);
}
String::~String()
{
free(buffer);
}
/*********************************************/
/* Memory Management */
/*********************************************/
inline void String::init(void)
{
buffer = NULL;
capacity = 0;
len = 0;
}
void String::invalidate(void)
{
if (buffer) {
free(buffer);
}
buffer = NULL;
capacity = len = 0;
}
unsigned char String::reserve(unsigned int size)
{
if (buffer && capacity >= size) {
return 1;
}
if (changeBuffer(size)) {
if (len == 0) {
buffer[0] = 0;
}
return 1;
}
return 0;
}
unsigned char String::changeBuffer(unsigned int maxStrLen)
{
char *newbuffer = (char *)realloc(buffer, maxStrLen + 1);
if (newbuffer) {
buffer = newbuffer;
capacity = maxStrLen;
return 1;
}
return 0;
}
/*********************************************/
/* Copy and Move */
/*********************************************/
String &String::copy(const char *cstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy(buffer, cstr);
return *this;
}
String &String::copy(const __FlashStringHelper *pstr, unsigned int length)
{
if (!reserve(length)) {
invalidate();
return *this;
}
len = length;
strcpy_P(buffer, (PGM_P)pstr);
return *this;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
void String::move(String &rhs)
{
if (buffer) {
if (rhs && capacity >= rhs.len) {
strcpy(buffer, rhs.buffer);
len = rhs.len;
rhs.len = 0;
return;
} else {
free(buffer);
}
}
buffer = rhs.buffer;
capacity = rhs.capacity;
len = rhs.len;
rhs.buffer = NULL;
rhs.capacity = 0;
rhs.len = 0;
}
#endif
String &String::operator = (const String &rhs)
{
if (this == &rhs) {
return *this;
}
if (rhs.buffer) {
copy(rhs.buffer, rhs.len);
} else {
invalidate();
}
return *this;
}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
String &String::operator = (String &&rval)
{
if (this != &rval) {
move(rval);
}
return *this;
}
String &String::operator = (StringSumHelper &&rval)
{
if (this != &rval) {
move(rval);
}
return *this;
}
#endif
String &String::operator = (const char *cstr)
{
if (cstr) {
copy(cstr, strlen(cstr));
} else {
invalidate();
}
return *this;
}
String &String::operator = (const __FlashStringHelper *pstr)
{
if (pstr) {
copy(pstr, strlen_P((PGM_P)pstr));
} else {
invalidate();
}
return *this;
}
/*********************************************/
/* concat */
/*********************************************/
unsigned char String::concat(const String &s)
{
return concat(s.buffer, s.len);
}
unsigned char String::concat(const char *cstr, unsigned int length)
{
unsigned int newlen = len + length;
if (!cstr) {
return 0;
}
if (length == 0) {
return 1;
}
if (!reserve(newlen)) {
return 0;
}
strcpy(buffer + len, cstr);
len = newlen;
return 1;
}
unsigned char String::concat(const char *cstr)
{
if (!cstr) {
return 0;
}
return concat(cstr, strlen(cstr));
}
unsigned char String::concat(char c)
{
char buf[2];
buf[0] = c;
buf[1] = 0;
return concat(buf, 1);
}
unsigned char String::concat(unsigned char num)
{
char buf[1 + 3 * sizeof(unsigned char)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(int num)
{
char buf[2 + 3 * sizeof(int)];
itoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned int num)
{
char buf[1 + 3 * sizeof(unsigned int)];
utoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(long num)
{
char buf[2 + 3 * sizeof(long)];
ltoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(unsigned long num)
{
char buf[1 + 3 * sizeof(unsigned long)];
ultoa(num, buf, 10);
return concat(buf, strlen(buf));
}
unsigned char String::concat(float num)
{
char buf[20];
char *string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(double num)
{
char buf[20];
char *string = dtostrf(num, 4, 2, buf);
return concat(string, strlen(string));
}
unsigned char String::concat(const __FlashStringHelper *str)
{
if (!str) {
return 0;
}
int length = strlen_P((const char *) str);
if (length == 0) {
return 1;
}
unsigned int newlen = len + length;
if (!reserve(newlen)) {
return 0;
}
strcpy_P(buffer + len, (const char *) str);
len = newlen;
return 1;
}
/*********************************************/
/* Concatenate */
/*********************************************/
StringSumHelper &operator + (const StringSumHelper &lhs, const String &rhs)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(rhs.buffer, rhs.len)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, const char *cstr)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!cstr || !a.concat(cstr, strlen(cstr))) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, char c)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(c)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, unsigned char num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, int num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, unsigned int num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, long num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, unsigned long num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, float num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, double num)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(num)) {
a.invalidate();
}
return a;
}
StringSumHelper &operator + (const StringSumHelper &lhs, const __FlashStringHelper *rhs)
{
StringSumHelper &a = const_cast<StringSumHelper &>(lhs);
if (!a.concat(rhs)) {
a.invalidate();
}
return a;
}
/*********************************************/
/* Comparison */
/*********************************************/
int String::compareTo(const String &s) const
{
if (!buffer || !s.buffer) {
if (s.buffer && s.len > 0) {
return 0 - *(unsigned char *)s.buffer;
}
if (buffer && len > 0) {
return *(unsigned char *)buffer;
}
return 0;
}
return strcmp(buffer, s.buffer);
}
unsigned char String::equals(const String &s2) const
{
return (len == s2.len && compareTo(s2) == 0);
}
unsigned char String::equals(const char *cstr) const
{
if (len == 0) {
return (cstr == NULL || *cstr == 0);
}
if (cstr == NULL) {
return buffer[0] == 0;
}
return strcmp(buffer, cstr) == 0;
}
unsigned char String::operator<(const String &rhs) const
{
return compareTo(rhs) < 0;
}
unsigned char String::operator>(const String &rhs) const
{
return compareTo(rhs) > 0;
}
unsigned char String::operator<=(const String &rhs) const
{
return compareTo(rhs) <= 0;
}
unsigned char String::operator>=(const String &rhs) const
{
return compareTo(rhs) >= 0;
}
unsigned char String::equalsIgnoreCase(const String &s2) const
{
if (this == &s2) {
return 1;
}
if (len != s2.len) {
return 0;
}
if (len == 0) {
return 1;
}
const char *p1 = buffer;
const char *p2 = s2.buffer;
while (*p1) {
if (tolower(*p1++) != tolower(*p2++)) {
return 0;
}
}
return 1;
}
unsigned char String::startsWith(const String &s2) const
{
if (len < s2.len) {
return 0;
}
return startsWith(s2, 0);
}
unsigned char String::startsWith(const String &s2, unsigned int offset) const
{
if (offset > len - s2.len || !buffer || !s2.buffer) {
return 0;
}
return strncmp(&buffer[offset], s2.buffer, s2.len) == 0;
}
unsigned char String::endsWith(const String &s2) const
{
if (len < s2.len || !buffer || !s2.buffer) {
return 0;
}
return strcmp(&buffer[len - s2.len], s2.buffer) == 0;
}
/*********************************************/
/* Character Access */
/*********************************************/
char String::charAt(unsigned int loc) const
{
return operator[](loc);
}
void String::setCharAt(unsigned int loc, char c)
{
if (loc < len) {
buffer[loc] = c;
}
}
char &String::operator[](unsigned int index)
{
static char dummy_writable_char;
if (index >= len || !buffer) {
dummy_writable_char = 0;
return dummy_writable_char;
}
return buffer[index];
}
char String::operator[](unsigned int index) const
{
if (index >= len || !buffer) {
return 0;
}
return buffer[index];
}
void String::getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index) const
{
if (!bufsize || !buf) {
return;
}
if (index >= len) {
buf[0] = 0;
return;
}
unsigned int n = bufsize - 1;
if (n > len - index) {
n = len - index;
}
strncpy((char *)buf, buffer + index, n);
buf[n] = 0;
}
/*********************************************/
/* Search */
/*********************************************/
int String::indexOf(char c) const
{
return indexOf(c, 0);
}
int String::indexOf(char ch, unsigned int fromIndex) const
{
if (fromIndex >= len) {
return -1;
}
const char *temp = strchr(buffer + fromIndex, ch);
if (temp == NULL) {
return -1;
}
return temp - buffer;
}
int String::indexOf(const String &s2) const
{
return indexOf(s2, 0);
}
int String::indexOf(const String &s2, unsigned int fromIndex) const
{
if (fromIndex >= len) {
return -1;
}
const char *found = strstr(buffer + fromIndex, s2.buffer);
if (found == NULL) {
return -1;
}
return found - buffer;
}
int String::lastIndexOf(char theChar) const
{
return lastIndexOf(theChar, len - 1);
}
int String::lastIndexOf(char ch, unsigned int fromIndex) const
{
if (fromIndex >= len) {
return -1;
}
char tempchar = buffer[fromIndex + 1];
buffer[fromIndex + 1] = '\0';
char *temp = strrchr(buffer, ch);
buffer[fromIndex + 1] = tempchar;
if (temp == NULL) {
return -1;
}
return temp - buffer;
}
int String::lastIndexOf(const String &s2) const
{
return lastIndexOf(s2, len - s2.len);
}
int String::lastIndexOf(const String &s2, unsigned int fromIndex) const
{
if (s2.len == 0 || len == 0 || s2.len > len) {
return -1;
}
if (fromIndex >= len) {
fromIndex = len - 1;
}
int found = -1;
for (char *p = buffer; p <= buffer + fromIndex; p++) {
p = strstr(p, s2.buffer);
if (!p) {
break;
}
if ((unsigned int)(p - buffer) <= fromIndex) {
found = p - buffer;
}
}
return found;
}
String String::substring(unsigned int left, unsigned int right) const
{
if (left > right) {
unsigned int temp = right;
right = left;
left = temp;
}
String out;
if (left >= len) {
return out;
}
if (right > len) {
right = len;
}
char temp = buffer[right]; // save the replaced character
buffer[right] = '\0';
out = buffer + left; // pointer arithmetic
buffer[right] = temp; //restore character
return out;
}
/*********************************************/
/* Modification */
/*********************************************/
void String::replace(char find, char replace)
{
if (!buffer) {
return;
}
for (char *p = buffer; *p; p++) {
if (*p == find) {
*p = replace;
}
}
}
void String::replace(const String &find, const String &replace)
{
if (len == 0 || find.len == 0) {
return;
}
int diff = replace.len - find.len;
char *readFrom = buffer;
char *foundAt;
if (diff == 0) {
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
memcpy(foundAt, replace.buffer, replace.len);
readFrom = foundAt + replace.len;
}
} else if (diff < 0) {
char *writeTo = buffer;
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
unsigned int n = foundAt - readFrom;
memcpy(writeTo, readFrom, n);
writeTo += n;
memcpy(writeTo, replace.buffer, replace.len);
writeTo += replace.len;
readFrom = foundAt + find.len;
len += diff;
}
strcpy(writeTo, readFrom);
} else {
unsigned int size = len; // compute size needed for result
while ((foundAt = strstr(readFrom, find.buffer)) != NULL) {
readFrom = foundAt + find.len;
size += diff;
}
if (size == len) {
return;
}
if (size > capacity && !changeBuffer(size)) {
return; // XXX: tell user!
}
int index = len - 1;
while (index >= 0 && (index = lastIndexOf(find, index)) >= 0) {
readFrom = buffer + index + find.len;
memmove(readFrom + diff, readFrom, len - (readFrom - buffer));
len += diff;
buffer[len] = 0;
memcpy(buffer + index, replace.buffer, replace.len);
index--;
}
}
}
void String::remove(unsigned int index)
{
// Pass the biggest integer as the count. The remove method
// below will take care of truncating it at the end of the
// string.
remove(index, (unsigned int) -1);
}
void String::remove(unsigned int index, unsigned int count)
{
if (index >= len) {
return;
}
if (count <= 0) {
return;
}
if (count > len - index) {
count = len - index;
}
char *writeTo = buffer + index;
len = len - count;
memmove(writeTo, buffer + index + count, len - index);
buffer[len] = 0;
}
void String::toLowerCase(void)
{
if (!buffer) {
return;
}
for (char *p = buffer; *p; p++) {
*p = tolower(*p);
}
}
void String::toUpperCase(void)
{
if (!buffer) {
return;
}
for (char *p = buffer; *p; p++) {
*p = toupper(*p);
}
}
void String::trim(void)
{
if (!buffer || len == 0) {
return;
}
char *begin = buffer;
while (isspace(*begin)) {
begin++;
}
char *end = buffer + len - 1;
while (isspace(*end) && end >= begin) {
end--;
}
len = end + 1 - begin;
if (begin > buffer) {
memcpy(buffer, begin, len);
}
buffer[len] = 0;
}
/*********************************************/
/* Parsing / Conversion */
/*********************************************/
long String::toInt(void) const
{
if (buffer) {
return atol(buffer);
}
return 0;
}
float String::toFloat(void) const
{
return float(toDouble());
}
double String::toDouble(void) const
{
if (buffer) {
return atof(buffer);
}
return 0;
}
| [
"402067010@qq.com"
] | 402067010@qq.com |
482fc61a5f1d1aec8c013e59ad8b4345c5cd7128 | 8e5c94cc5a3eeba046995c0c9d73c91b6dd022bc | /KthMin.cpp | dfb5df313ccc9f4eb80a9a50dc4c9fd330eab67e | [] | no_license | heycooldude/Sorting | 3c4c03185587a7e7c7f89db95cc8959f1b7f0918 | 308af143ce3e5c012c3817a5d9e013f80c4b3223 | refs/heads/master | 2020-04-27T04:48:59.798961 | 2015-02-02T23:13:49 | 2015-02-02T23:13:49 | 30,213,525 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,008 | cpp | #include "KthMin.h"
#include <iostream>
KthMin::KthMin()
{
}
KthMin::~KthMin()
{
}
int KthMin::findKthMin(IDoubleList03 * data, int k){
IDoubleNode03 *pk;
/*int cur = 0;
pk = data->getHead();
while (pk != NULL){
cur = pk->getValue();
std::cout << cur << "\n";
pk = pk->getNext();
}*/
IDoubleNode03 * j = new DoubleNode03;
IDoubleNode03 * i = new DoubleNode03;
IDoubleNode03* iMin = new DoubleNode03;
while (j != NULL){
iMin = j;
/* test against elements after j to find the smallest */
for (i = j->getNext(); i != NULL; i = i->getNext()) {
/* if this element is less, then it is the new minimum */
if (i->getValue() < iMin->getValue())
{
iMin = i;
}
if (iMin != j) {
int a = iMin->getValue();
//int b = iMin->getValue();
iMin->setValue(j->getValue());
j->setValue(a);
}
j = j->getNext();
}
IDoubleNode03 * temp;
temp = data->getHead();
for (int z = 0; z <= k; z++){
temp = temp->getNext();
}
return temp->getValue();
}
} | [
"harsh_mkg@yahoo.co.in"
] | harsh_mkg@yahoo.co.in |
363037318a37e546c6f608a24226666a2f1564a5 | a06515f4697a3dbcbae4e3c05de2f8632f8d5f46 | /corpus/taken_from_cppcheck_tests/stolen_10054.cpp | 88b826ce4d36a48681ea08fec9ddaba1520b9a2c | [] | no_license | pauldreik/fuzzcppcheck | 12d9c11bcc182cc1f1bb4893e0925dc05fcaf711 | 794ba352af45971ff1f76d665b52adeb42dcab5f | refs/heads/master | 2020-05-01T01:55:04.280076 | 2019-03-22T21:05:28 | 2019-03-22T21:05:28 | 177,206,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 82 | cpp | void f(int x)
{
int i = 0;
if (x) {
for ( ; i < 10; ++i) ;
}
} | [
"github@pauldreik.se"
] | github@pauldreik.se |
0079a62353fb4843a5966a987352994d2723d741 | 899035356dcd382da91c787214f3a42b71eb43c4 | /library/src/main/cpp/cookie-encrypt.cpp | f4fed1134363033a08a702089372139c3d4a4f6c | [
"Apache-2.0"
] | permissive | TUBB/Explode | d95ad163c3844347c2b1cda272df9f32a8b44092 | 35a13118a11bced7f08b3041b3ca3861baf5b9f8 | refs/heads/master | 2020-03-13T06:50:08.092943 | 2018-08-09T05:24:13 | 2018-08-09T05:24:13 | 131,012,868 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,412 | cpp | #include <jni.h>
#include <string>
const std::string KEY = "Opu@Tea%4*1";
const std::string SIG = "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;";
const std::string AES_ENCRYPT_NAME = "aesEncrypt";
const std::string AES_DECRYPT_NAME = "aesDecrypt";
jstring callMethod(JNIEnv *env, jclass &clazz, jmethodID &methodId, jstring &handleStr);
extern "C"
JNIEXPORT jstring
JNICALL
Java_io_github_tubb_explode_CookieEncrypt_encrypt(
JNIEnv *env,
jclass clazz,
jstring originCookie) {
jmethodID aesEncryptMethodID = env->GetStaticMethodID(clazz, AES_ENCRYPT_NAME.c_str(), SIG.c_str());
return callMethod(env, clazz, aesEncryptMethodID, originCookie);
}
JNIEXPORT jstring
JNICALL
Java_io_github_tubb_explode_CookieEncrypt_decrypt(
JNIEnv *env,
jclass clazz,
jstring encryptedCookie) {
jmethodID aesDecryptMethodID = env->GetStaticMethodID(clazz, AES_DECRYPT_NAME.c_str(), SIG.c_str());
return callMethod(env, clazz, aesDecryptMethodID, encryptedCookie);
}
jstring callMethod(JNIEnv *env, jclass &clazz, jmethodID &methodId, jstring &handleStr) {
const char *key_chars = KEY.c_str();
jstring key = env->NewStringUTF(key_chars);
jstring data = (jstring)env->CallStaticObjectMethod(clazz, methodId, handleStr, key);
jboolean isCopy;
env->ReleaseStringUTFChars(key, env->GetStringUTFChars(key, &isCopy));
return data;
} | [
"tu.bingbing@163.com"
] | tu.bingbing@163.com |
2b12b771c9f057da04bf6a98760b48fd3be403f4 | 78da87159332b7f053c6bcf88f888ffc6c4dd624 | /11958.cpp | 96b8b59dd6f5d8aca24f27c4f02777b6df97a8d4 | [] | no_license | sudiptobd/UVA-Solving | e2d7bb9b8196a469003dde056b1e596af642cc95 | 403dd3a54e1a8e9af42dcd3d121a64269f9b351a | refs/heads/master | 2021-01-11T20:02:09.401456 | 2017-01-19T12:47:13 | 2017-01-19T12:47:13 | 79,452,726 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,104 | cpp | #include<stdio.h>
#include<iostream>
#include<utility>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<deque>
#include<vector>
#include<ctype.h>
using namespace std;
#define lli long long int
#define gcd(a,b) __gcd(a,b)
int bad(int ah,int am,int bh,int bm)
{
int rh,rm;
if(bm>am)
{
rm=am+60-bm;
bh++;
}
else rm=am-bm;
if(bh>ah)rh=ah+24-bh;
else rh=ah-bh;
return 60*rh+rm;
}
int main()
{
//freopen("in.txt","r",stdin);
int t;
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
int n;
scanf("%d",&n);
int car_h,car_m;
scanf("%d:%d",&car_h,&car_m);
int mini=999999999;
for(int j=1;j<=n;j++)
{
int start_h,start_m;
scanf("%d:%d",&start_h,&start_m);
int time;
scanf("%d",&time);
time+=bad(start_h,start_m,car_h,car_m);
if(time<mini)mini=time;
}
printf("Case %d: %d\n",i,mini);
}
return 0;
}
| [
"sudiptoroy900@gmail.com"
] | sudiptoroy900@gmail.com |
afce6d4f89ae15c62c8cda83b96351c03a9ecbf6 | a5d733d9b841a9127dc4a1aad63a3904dbfe0a3d | /0032. Longest Valid Parentheses/solution1.h | d56974b70e7eb4bc8dc5f987ecc3c3660d7236b9 | [] | no_license | yeholdon/Ye-s-LeetCode | 207d24a9b3e0804679e101dfeca4c0cc39a107cb | e17125e57ab0664ac39befc6405e4ea2e48051ee | refs/heads/master | 2021-08-09T01:50:17.991260 | 2021-01-18T02:45:53 | 2021-01-18T02:45:53 | 241,823,865 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,383 | h | #pragma once
#include <vector>
#include <string>
#include <map>
using namespace std;
class Solution {
public:
int longestValidParentheses(string s) {
int len = s.size();
vector<vector<int>> dp(len, vector<int>(len));
vector<int> count(len);
for (size_t i = 0; i < len; i++)
{
if (s[i] == '(')
{
dp[i][i] = 1;
}
else
{
dp[i][i] = 0;
}
}
int max_len = 0;
for (size_t i = 0; i < len; i++)
{
for (size_t j = i + 1; j < len; j++)
{
if (s[j] == '(')
{
dp[i][j] = dp[i][j - 1] + 1;
}
else
{
if (dp[i][j - 1] > 1)
{
dp[i][j] = dp[i][j - 1] - 1;
count[i]++;
}
else if (dp[i][j - 1] == 1)
{
dp[i][j] = dp[i][j - 1] - 1;
count[i]++;
max_len = max(max_len, count[i]);
}
else
{
break;
}
}
}
}
return max_len * 2;
}
}; | [
"yeholdon@gmail.com"
] | yeholdon@gmail.com |
5119dd0ea872bb07a3b640066735b1fcb6fb8480 | 290da1ab2d9e2c74f0cd346fd0c2eb705c5d8530 | /MyGame/Unigine_RTS_Demo1/data/core/scripts/system/wall.h | 148cbaba9a1f11f349ab8a7a196cccf6ae278e82 | [] | no_license | sid1980/MyGame | 00f7135ce4994a6016b54177def61716a3e46ab4 | eca83b366c096a958ffd75c85eff78c8cfcdbc39 | refs/heads/master | 2023-03-18T06:29:24.860934 | 2016-08-25T05:53:27 | 2016-08-25T05:53:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 22,719 | h | /* Copyright (C) 2005-2015, UNIGINE Corp. All rights reserved.
*
* This file is a part of the UNIGINE 2.0-RC SDK.
*
* Your use and / or redistribution of this software in source and / or
* binary form, with or without modification, is subject to: (i) your
* ongoing acceptance of and compliance with the terms and conditions of
* the UNIGINE License Agreement; and (ii) your inclusion of this notice
* in any version of this software that you use or redistribute.
* A copy of the UNIGINE License Agreement is available by contacting
* UNIGINE Corp. at http://unigine.com/
*/
#ifndef __UNIGINE_SYSTEM_WALL_H__
#define __UNIGINE_SYSTEM_WALL_H__
//#define PROJECTION_USER
#ifdef HAS_APP_WALL || HAS_APP_PROJECTION || HAS_APP_SURROUND
#include <core/scripts/projection.h>
#endif
#ifdef HAS_APP_PROJECTION
#include <core/scripts/system/projection.h>
#endif
/*
*/
namespace Wall {
float fov; // fov
float angle; // angle
float bezel_x; // bezel x
float bezel_y; // bezel y
WidgetEditLine fov_el; // fov
WidgetEditLine angle_el; // angle
WidgetEditLine bezel_x_el; // bezel x
WidgetEditLine bezel_y_el; // bezel y
WidgetButton projection_b; // projection
string changed_callback; // changed callback
string changed_world_callback; // changed world callback
string changed_editor_callback; // changed editor callback
/*
*/
void init(float f,float a) {
// load config
fov = engine.config.getFloat("wall_fov",f);
angle = engine.config.getFloat("wall_angle",a);
bezel_x = engine.config.getFloat("wall_bezel_x",0.0f);
bezel_y = engine.config.getFloat("wall_bezel_y",0.0f);
projection_b = projection_b;
#ifdef HAS_APP_WALL
// wall configuration
int wall_width = engine.wall.getWidth();
int wall_height = engine.wall.getHeight();
if(wall_width == 1 && wall_height == 1) engine.wall.setPrimary(0,0);
else if(wall_width == 1 && wall_height == 2) engine.wall.setPrimary(0,0);
else if(wall_width == 2 && wall_height == 1) engine.wall.setPrimary(0,0);
else if(wall_width == 2 && wall_height == 2) engine.wall.setPrimary(0,0);
else if(wall_width == 3 && wall_height == 1) engine.wall.setPrimary(1,0);
else if(wall_width == 3 && wall_height == 2) engine.wall.setPrimary(1,0);
else if(wall_width == 4 && wall_height == 1) engine.wall.setPrimary(1,0);
else if(wall_width == 5 && wall_height == 1) engine.wall.setPrimary(2,0);
else log.error("Wall::init(): unknown wall configuration %dx%d\n",wall_width,wall_height);
// update sliders
if(fov_el != NULL) fov_el.setText(format("%.1f",fov));
if(angle_el != NULL) angle_el.setText(format("%.1f",angle));
if(bezel_x_el != NULL) bezel_x_el.setText(format("%.3f",bezel_x));
if(bezel_y_el != NULL) bezel_y_el.setText(format("%.3f",bezel_y));
if(fov_el != NULL) fov_el.setEnabled((wall_width > 1 || wall_height > 1));
if(angle_el != NULL) angle_el.setEnabled((wall_width > 1 || wall_height > 1));
if(bezel_x_el != NULL) bezel_x_el.setEnabled((wall_width > 1));
if(bezel_y_el != NULL) bezel_y_el.setEnabled((wall_height > 1));
if(projection_b != NULL) projection_b.setHidden(1);
#elif HAS_APP_PROJECTION
// projection configuration
int projection_width = engine.projection.getWidth();
if(projection_width == 1) engine.projection.setPrimary(0);
else if(projection_width == 2) engine.projection.setPrimary(0);
else if(projection_width == 3) engine.projection.setPrimary(1);
else if(projection_width == 4) engine.projection.setPrimary(1);
else if(projection_width == 5) engine.projection.setPrimary(2);
else log.error("Wall::init(): unknown projection configuration %d\n",projection_width);
// update sliders
if(fov_el != NULL) fov_el.setText(format("%.1f",fov));
if(angle_el != NULL) angle_el.setText(format("%.1f",angle));
if(bezel_x_el != NULL) bezel_x_el.setText(format("%.3f",bezel_x));
if(bezel_y_el != NULL) bezel_y_el.setText(format("%.3f",bezel_y));
if(fov_el != NULL) fov_el.setEnabled((projection_width > 1));
if(angle_el != NULL) angle_el.setEnabled((projection_width > 1));
// init projection
projectionInit();
#elif HAS_APP_SURROUND
// update sliders
if(fov_el != NULL) fov_el.setText(format("%.1f",fov));
if(angle_el != NULL) angle_el.setText(format("%.1f",angle));
if(bezel_x_el != NULL) bezel_x_el.setText(format("%.3f",bezel_x));
if(bezel_y_el != NULL) bezel_y_el.setText(format("%.3f",bezel_y));
if(bezel_y_el != NULL) bezel_y_el.setEnabled(0);
if(projection_b != NULL) projection_b.setHidden(1);
#else
// clear system menu
forloop(int i = 0; System::main_tb.getNumTabs()) {
if(System::main_tb.getTabText(i) == engine.gui.translate("Wall")) {
System::main_tb.setTabHidden(i,1);
}
}
#endif
}
void shutdown() {
// save config
engine.config.setFloat("wall_fov",fov);
engine.config.setFloat("wall_angle",angle);
engine.config.setFloat("wall_bezel_x",bezel_x);
engine.config.setFloat("wall_bezel_y",bezel_y);
// shutdown projection
#ifdef HAS_APP_PROJECTION
projectionShutdown();
#endif
}
/*
*/
void render() {
// don't handle projection
#ifdef PROJECTION_USER
return;
#endif
#ifdef HAS_APP_WALL || HAS_APP_PROJECTION || HAS_APP_SURROUND
// enable render
engine.render.setEnabled(1);
// get player
Player player = engine.editor.getPlayer();
if(player == NULL) player = engine.game.getPlayer();
if(player == NULL) return;
// display configuration
float aspect = float(engine.app.getWidth()) / engine.app.getHeight();
// player matrices
mat4 projection = perspective(fov,1.0f,player.getZNear(),player.getZFar());
Mat4 modelview = player.getModelview();
#endif
#ifdef HAS_APP_WALL
// wall configuration
int wall_width = engine.wall.getWidth();
int wall_height = engine.wall.getHeight();
mat4 wall_projection = mat4_identity;
Mat4 wall_modelview = Mat4_identity;
/////////////////////////////////
// 1x2 configuration
/////////////////////////////////
if(wall_width == 1 && wall_height == 2) {
// disable engine render
engine.render.setEnabled(0);
// top bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// bottom bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,1,wall_projection,wall_modelview);
}
/////////////////////////////////
// 2x1 configuration
/////////////////////////////////
else if(wall_width == 2 && wall_height == 1) {
// disable engine render
engine.render.setEnabled(0);
// left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 2x2 configuration
/////////////////////////////////
else if(wall_width == 2 && wall_height == 2) {
// disable engine render
engine.render.setEnabled(0);
// top left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// top right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// bottom left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,1,wall_projection,wall_modelview);
// bottom right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,1,wall_projection,wall_modelview);
}
/////////////////////////////////
// 3x1 configuration
/////////////////////////////////
else if(wall_width == 3 && wall_height == 1) {
// primary display
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.wall.setProjection(1,0,wall_projection);
engine.wall.setModelview(1,0,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
// left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 3x2 configuration
/////////////////////////////////
else if(wall_width == 3 && wall_height == 2) {
// disable engine render
engine.render.setEnabled(0);
// top bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// bottom bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,1,wall_projection,wall_modelview);
// top left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// bottom left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,1,wall_projection,wall_modelview);
// top right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
// bottom right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,2,1,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,1,wall_projection,wall_modelview);
}
/////////////////////////////////
// 4x1 configuration
/////////////////////////////////
else if(wall_width == 4 && wall_height == 1) {
// disable engine render
engine.render.setEnabled(0);
// outer left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// inner left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// inner right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
// outer right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,3,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(3,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 5x1 configuration
/////////////////////////////////
else if(wall_width == 5 && wall_height == 1) {
// primary display
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.wall.setProjection(2,0,wall_projection);
engine.wall.setModelview(2,0,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
// outer left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// inner left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// inner right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,3,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(3,0,wall_projection,wall_modelview);
// outer right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,wall_width,wall_height,4,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(4,0,wall_projection,wall_modelview);
}
#elif HAS_APP_PROJECTION
// projection configuration
int projection_width = engine.projection.getWidth();
mat4 wall_projection = mat4_identity;
Mat4 wall_modelview = Mat4_identity;
/////////////////////////////////
// 1x1 configuration
/////////////////////////////////
if(projection_width == 1) {
// primary display
projection = perspective(player.getFov(),1.0f,player.getZNear(),player.getZFar());
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.projection.setProjection(0,wall_projection);
engine.projection.setModelview(0,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
}
/////////////////////////////////
// 2x1 configuration
/////////////////////////////////
else if(projection_width == 2) {
// disable engine render
engine.render.setEnabled(0);
// left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 3x1 configuration
/////////////////////////////////
else if(projection_width == 3) {
// primary display
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.projection.setProjection(1,wall_projection);
engine.projection.setModelview(1,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
// left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 4x1 configuration
/////////////////////////////////
else if(projection_width == 4) {
// disable engine render
engine.render.setEnabled(0);
// outer left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// inner left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// inner right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
// outer right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,3,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(3,0,wall_projection,wall_modelview);
}
/////////////////////////////////
// 5x1 configuration
/////////////////////////////////
else if(projection_width == 5) {
// primary display
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.projection.setProjection(3,wall_projection);
engine.projection.setModelview(3,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
// outer left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// inner left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(1,0,wall_projection,wall_modelview);
// inner right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,3,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(3,0,wall_projection,wall_modelview);
// outer right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,projection_width,1,4,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(4,0,wall_projection,wall_modelview);
}
#elif HAS_APP_SURROUND
mat4 wall_projection = mat4_identity;
Mat4 wall_modelview = Mat4_identity;
// primary display
Unigine::getWallProjection(projection,modelview,aspect,3,1,1,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
engine.surround.setProjection(1,wall_projection);
engine.surround.setModelview(1,wall_modelview);
player.setProjection(wall_projection);
player.setModelview(wall_modelview);
// left bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,3,1,0,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(0,0,wall_projection,wall_modelview);
// right bounding frustum
Unigine::getWallProjection(projection,modelview,aspect,3,1,2,0,bezel_x,bezel_y,angle,wall_projection,wall_modelview);
set_projection(2,0,wall_projection,wall_modelview);
#endif
}
/*
*/
void set_projection(int x,int y,mat4 projection,Mat4 modelview) {
#ifdef HAS_APP_WALL
engine.wall.setEnabled(x,y,1);
engine.wall.setProjection(x,y,projection);
engine.wall.setModelview(x,y,modelview);
#elif HAS_APP_PROJECTION
engine.projection.setEnabled(x,1);
engine.projection.setProjection(x,projection);
engine.projection.setModelview(x,modelview);
#elif HAS_APP_SURROUND
engine.surround.setEnabled(x,1);
engine.surround.setProjection(x,projection);
engine.surround.setModelview(x,modelview);
#endif
}
/*
*/
void changed() {
if(changed_callback != NULL) call(changed_callback);
if(changed_world_callback != NULL) engine.world.call(changed_world_callback);
if(changed_editor_callback != NULL) engine.editor.call(changed_editor_callback);
}
/*
*/
void fov_pressed() {
fov = clamp(float(fov_el.getText()),1.0f,179.0f);
fov_el.setText(format("%.1f",fov));
changed();
}
void angle_pressed() {
angle = clamp(float(angle_el.getText()),-89.0f,89.0f);
angle_el.setText(format("%.1f",angle));
changed();
}
void bezel_x_pressed() {
bezel_x = clamp(float(bezel_x_el.getText()),-1.0f,1.0f);
bezel_x_el.setText(format("%.3f",bezel_x));
#ifdef HAS_APP_PROJECTION
projectionUpdate();
#endif
changed();
}
void bezel_y_pressed() {
bezel_y = clamp(float(bezel_y_el.getText()),-1.0f,1.0f);
bezel_y_el.setText(format("%.3f",bezel_y));
#ifdef HAS_APP_PROJECTION
projectionUpdate();
#endif
changed();
}
void projection_clicked() {
#ifdef HAS_APP_PROJECTION
projectionRun();
#endif
}
}
/******************************************************************************\
*
* Interface
*
\******************************************************************************/
/*
*/
void wallInit(float fov = 60.0f,float angle = 20.0f) {
Wall::init(fov,angle);
}
void wallShutdown() {
Wall::shutdown();
}
/*
*/
void wallRender() {
Wall::render();
}
/*
*/
void wallSetFov(float fov) {
Wall::fov = fov;
}
float wallGetFov() {
return Wall::fov;
}
void wallSetAngle(float angle) {
Wall::angle = angle;
}
float wallGetAngle() {
return Wall::angle;
}
/*
*/
void wallSetBezelX(float bezel) {
Wall::bezel_x = bezel;
}
float wallGetBezelX() {
return Wall::bezel_x;
}
void wallSetBezelY(float bezel) {
Wall::bezel_y = bezel;
}
float wallGetBezelY() {
return Wall::bezel_y;
}
/*
*/
void wallSetChangedCallback(string callback) {
Wall::changed_callback = callback;
}
string wallGetChangedCallback() {
return Wall::changed_callback;
}
void wallSetChangedWorldCallback(string callback) {
Wall::changed_world_callback = callback;
}
string wallGetChangedWorldCallback() {
return Wall::changed_world_callback;
}
void wallSetChangedEditorCallback(string callback) {
Wall::changed_editor_callback = callback;
}
string wallGetChangedEditorCallback() {
return Wall::changed_editor_callback;
}
#endif /* __UNIGINE_SYSTEM_WALL_H__ */
| [
"wangzhaoyu@ztgame.com"
] | wangzhaoyu@ztgame.com |
4194f34ee5ef03cacc4ccec76615a197a7fdcbd6 | e39117e739995759b9407a400846e5786e5b5f5d | /include/dish2/cell/cardinal_iterators/NeighborKinGroupIDAncestorViewWrapper.hpp | ed0f7365535ba17ae29bf61a2a790b2c32d285c7 | [
"MIT"
] | permissive | perryk12/dishtiny | 5f18c5df1d97a49e58697ec7317773ae5c756ef6 | 4177f09eed90f3b73f952858677fc4001ac6175a | refs/heads/master | 2023-03-28T14:06:56.626589 | 2021-03-25T05:34:50 | 2021-03-25T05:36:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,032 | hpp | #pragma once
#ifndef DISH2_CELL_CARDINAL_ITERATORS_NEIGHBORKINGROUPIDANCESTORVIEWWRAPPER_HPP_INCLUDE
#define DISH2_CELL_CARDINAL_ITERATORS_NEIGHBORKINGROUPIDANCESTORVIEWWRAPPER_HPP_INCLUDE
#include <utility>
#include "../../../../third-party/Empirical/include/emp/base/vector.hpp"
#include "../../peripheral/readable_state/ReadableState.hpp"
#include "../Cardinal.hpp"
namespace dish2 {
template<typename Spec>
class NeighborKinGroupIDAncestorViewWrapper
: public emp::vector<Cardinal<Spec>>::iterator {
using parent_t = typename emp::vector<Cardinal<Spec>>::iterator;
public:
NeighborKinGroupIDAncestorViewWrapper() = default;
NeighborKinGroupIDAncestorViewWrapper(const parent_t& in) : parent_t(in) {}
using value_type = dish2::KinGroupIDAncestorView< Spec >;
using pointer = value_type*;
using reference = value_type&;
const value_type& operator*() {
return std::as_const(
parent_t::operator*().state_node_input
).Get().template Get<
dish2::KinGroupIDAncestorView< Spec >
>();
}
const value_type* operator->() { return &operator*(); }
NeighborKinGroupIDAncestorViewWrapper& operator++() {
parent_t::operator++();
return *this;
}
NeighborKinGroupIDAncestorViewWrapper operator++(int) {
const auto res = *this;
operator++();
return res;
}
NeighborKinGroupIDAncestorViewWrapper& operator--() {
parent_t::operator--();
return *this;
}
NeighborKinGroupIDAncestorViewWrapper operator--(int) {
NeighborKinGroupIDAncestorViewWrapper res{ *this };
res -= 1;
return res;
}
NeighborKinGroupIDAncestorViewWrapper operator+(const size_t rhs) {
NeighborKinGroupIDAncestorViewWrapper res{ *this };
res += rhs;
return res;
}
NeighborKinGroupIDAncestorViewWrapper operator-(const size_t rhs) {
NeighborKinGroupIDAncestorViewWrapper res{ *this };
res -= rhs;
return res;
}
};
} // namespace dish2
#endif // #ifndef DISH2_CELL_CARDINAL_ITERATORS_NEIGHBORKINGROUPIDANCESTORVIEWWRAPPER_HPP_INCLUDE
| [
"mmore500.login+git@gmail.com"
] | mmore500.login+git@gmail.com |
4158bd9168e030e8444220085a36f655d72c801d | 3c2b5dcceff31f38e8f1b92dcb17a1b9790aac2a | /include/solver_GSL.h | 5d1b6260b02208316d954a28f0a31b788bd8581c | [] | no_license | olmomoreno/qp_testing | 624ca09fb4c3723df6b403ec14789b00da4f8447 | 8dc185a058ebb7b762e84a9091027186f2cf788d | refs/heads/master | 2021-01-20T04:43:06.808961 | 2017-04-28T16:00:03 | 2017-04-28T16:00:03 | 89,721,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,497 | h | /*
CQP is an implementation of the Mehrotra's Predictor-Corrector
interior point method for the convex quadratic programming.
CQP solves problems of the form:
min (x^t)Qx+(q^t)x
s.t. Ax = b,
Cx >= d.
Dimensions of the problem data:
Q is a (n x n)-matrix
A is a (me x n)-matrix
C is a (mi x n)-matrix
q,b,d are vectors of appropriate dimensions.
http://www.network-theory.co.uk/download/gslextras/Bundle/CQP-1.2/
*/
#include <iostream>
#include <gsl/gsl_math.h>
#include <gsl_cqp.h>
using namespace std;
int s_GSL(){
gsl_cqp_data *p_problem= new gsl_cqp_data;
gsl_cqp_data problem;
problem.Q = gsl_matrix_alloc (6,6);
problem.q = gsl_vector_alloc (6);
problem.A = gsl_matrix_alloc (1,6);
problem.b = gsl_vector_calloc(1);
problem.C = gsl_matrix_calloc(1,6);
problem.d = gsl_vector_calloc(1);
/*M*/
gsl_matrix_set(problem.Q,0,0,0.0627+1e-9); gsl_matrix_set(problem.Q,0,1,-0.0183); gsl_matrix_set(problem.Q,0,2,-0.0603); gsl_matrix_set(problem.Q,0,3,0.0); gsl_matrix_set(problem.Q,0,4,0.0); gsl_matrix_set(problem.Q,0,5,0.0);
gsl_matrix_set(problem.Q,1,0,-0.0183); gsl_matrix_set(problem.Q,1,1,0.068+1e-9); gsl_matrix_set(problem.Q,1,2,0.0176); gsl_matrix_set(problem.Q,1,3,-0.0183); gsl_matrix_set(problem.Q,1,4,-0.0603); gsl_matrix_set(problem.Q,1,5,0.0);
gsl_matrix_set(problem.Q,2,0,-0.0603); gsl_matrix_set(problem.Q,2,1,0.0176); gsl_matrix_set(problem.Q,2,2,0.1207+1e-9); gsl_matrix_set(problem.Q,2,3,0.0); gsl_matrix_set(problem.Q,2,4,-0.0183); gsl_matrix_set(problem.Q,2,5,-0.0603);
gsl_matrix_set(problem.Q,3,0,0.0); gsl_matrix_set(problem.Q,3,1,-0.0183); gsl_matrix_set(problem.Q,3,2,0.0); gsl_matrix_set(problem.Q,3,3,0.053+1e-9); gsl_matrix_set(problem.Q,3,4,0.0176); gsl_matrix_set(problem.Q,3,5,0.0);
gsl_matrix_set(problem.Q,4,0,0.0); gsl_matrix_set(problem.Q,4,1,-0.0603); gsl_matrix_set(problem.Q,4,2,-0.0183); gsl_matrix_set(problem.Q,4,3,0.0176); gsl_matrix_set(problem.Q,4,4,0.0633+1e-9); gsl_matrix_set(problem.Q,4,5,0.0176);
gsl_matrix_set(problem.Q,5,0,0.0); gsl_matrix_set(problem.Q,5,1,0.0); gsl_matrix_set(problem.Q,5,2,-0.0603); gsl_matrix_set(problem.Q,5,3,0.0); gsl_matrix_set(problem.Q,5,4,0.0176); gsl_matrix_set(problem.Q,5,5,0.0580+1e-9);
/*q*/
for (int i=0;i<=5;i++){
gsl_vector_set(problem.q,i,0.0);
}
/*A*/
for (int i =0;i<=5;i++){
gsl_matrix_set(problem.A,0,i,0.0);
}
/*b*/
gsl_vector_set(problem.b,0,0.0);
/*CI*/
gsl_matrix_set(problem.C,0,0,0.0627); gsl_matrix_set(problem.C,0,1,-0.0366); gsl_matrix_set(problem.C,0,2,0.1206);
gsl_matrix_set(problem.C,0,3,0.0053); gsl_matrix_set(problem.C,0,4,0.0352); gsl_matrix_set(problem.C,0,5,0.0580);
/*ci0*/
gsl_vector_set(problem.d,0,0.6436);
const size_t max_iter = 1000;
size_t iter=1;
const gsl_cqpminimizer_type * T;
gsl_cqpminimizer *s;
T = gsl_cqpminimizer_mg_pdip;
// n me mi
s = gsl_cqpminimizer_alloc(T, (size_t) 6,(size_t) 1,(size_t) 1);
int status;
status = gsl_cqpminimizer_set(s,&problem);
status = gsl_cqpminimizer_iterate(s);
printf("******************** Test ********************\n\n");
printf("== Itn ======= f ======== ||gap|| ==== ||residual||\n\n");
do{
status = gsl_cqpminimizer_iterate(s);
status = gsl_cqpminimizer_test_convergence(s, 1e-15, 1e-15);
printf("%4d %14.8f %13.6e %13.6e\n", iter, gsl_cqpminimizer_f(s), gsl_cqpminimizer_gap(s), gsl_cqpminimizer_residuals_norm(s));
if(status == GSL_SUCCESS){
size_t j;
printf("\nMinimum is found at\n");
for(j=0; j<gsl_cqpminimizer_x(s)->size; j++)
printf("%9.6f ",gsl_vector_get(gsl_cqpminimizer_x(s), j));
printf("\n\n");
printf("\nLagrange-multipliers for Ax=b\n");
for(j=0; j<gsl_cqpminimizer_lm_eq(s)->size; j++)
printf("%9.6f ",gsl_vector_get(gsl_cqpminimizer_lm_eq(s), j));
printf("\n\n");
printf("\nLagrange-multipliers for Cx>=d\n");
for(j=0; j<gsl_cqpminimizer_lm_ineq(s)->size; j++)
printf("%9.6f ",gsl_vector_get(gsl_cqpminimizer_lm_ineq(s), j));
printf("\n\n");
}
else{
iter++;
}
}
while(status == GSL_CONTINUE && iter<=max_iter);
gsl_cqpminimizer_free(s);
printf("End of it\n");
return 0;
}
| [
"olmo.moreno@iit.it"
] | olmo.moreno@iit.it |
40a27c1eb0a414b3f6a6332cd001ace4d70e8c41 | 70022f7e5ac4c229e412b51db248fdd08a0a5b28 | /src/tests/frontend/Linux-g++_(GCC)_4.8.5/openmp/rodinia-lud/lud.c.pre.transformed.cpp | 8c7f05b7d8bd00f569064fa5b7fe2a5cad7d72bf | [] | no_license | agrippa/chimes | 6465fc48f118154e9d42fbd26d6b87a7dce7c5e9 | 695bb5bb54efbcd61469acda79b6ba6532e2d1d9 | refs/heads/master | 2020-12-25T14:02:17.752481 | 2016-07-04T02:20:59 | 2016-07-04T02:20:59 | 23,259,130 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 109,726 | cpp | # 1 "lud.c.pre.transformed.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 147 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 3 4
typedef long int ptrdiff_t;
# 212 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 1 "<command-line>" 2
# 1 "lud.c.pre.transformed.cpp"
static int ____chimes_does_checkpoint_create_matrix_from_file_npm = 1;
static int ____chimes_does_checkpoint_get_interval_by_sec_npm = 1;
static int ____chimes_does_checkpoint_lud_base_npm = 1;
static int ____chimes_does_checkpoint_lud_verify_npm = 1;
static int ____chimes_does_checkpoint_matrix_duplicate_npm = 1;
static int ____chimes_does_checkpoint_print_matrix_npm = 1;
static int ____chimes_does_checkpoint_stopwatch_start_npm = 1;
static int ____chimes_does_checkpoint_stopwatch_stop_npm = 1;
static int ____must_checkpoint_main_matrix_dim_0 = 2;
static int ____must_checkpoint_main_m_0 = 2;
static int ____must_checkpoint_main_mm_0 = 2;
static int ____must_checkpoint_main_sw_0 = 2;
static int ____must_manage_main = 2;
static unsigned ____alias_loc_id_0;
static unsigned ____alias_loc_id_1;
static unsigned ____alias_loc_id_2;
static unsigned ____alias_loc_id_3;
static unsigned ____alias_loc_id_4;
static unsigned ____alias_loc_id_5;
static unsigned ____alias_loc_id_6;
static unsigned ____alias_loc_id_7;
static unsigned ____alias_loc_id_8;
static unsigned ____alias_loc_id_9;
# 1 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 1 "/tmp/chimes-frontend//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/home/jmg3/chimes/src/libchimes/libchimes.h" 1
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 147 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 3 4
typedef long int ptrdiff_t;
# 212 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 5 "/home/jmg3/chimes/src/libchimes/libchimes.h" 2
extern void init_chimes(int argc, char **argv);
extern void checkpoint_transformed(int lbl, unsigned loc_id);
extern void *translate_fptr(void *fptr, int lbl, unsigned loc_id,
size_t return_alias, int n_params, ...);
extern void calling_npm(const char *name, unsigned loc_id);
extern void calling(void *func_ptr, int lbl, unsigned loc_id,
size_t set_return_alias, unsigned naliases, ...);
extern int get_next_call();
extern int new_stack(void *func_ptr, const char *funcname, int *conditional,
unsigned n_local_arg_aliases, unsigned nargs, ...);
extern void init_module(size_t module_id, int n_contains_mappings, int nfunctions,
int nvars, int n_change_locs, int n_provided_npm_functions,
int n_external_npm_functions, int n_npm_conditionals,
int n_static_merges, int n_dynamic_merges, int nstructs, ...);
extern void rm_stack(bool has_return_alias, size_t returned_alias,
const char *funcname, int *conditional, unsigned loc_id, int disabled,
bool is_allocator);
extern void register_stack_var(const char *mangled_name, int *cond_registration,
const char *full_type, void *ptr, size_t size, int is_ptr,
int is_struct, int n_ptr_fields, ...);
extern void register_stack_vars(int nvars, ...);
extern void register_global_var(const char *mangled_name, const char *full_type,
void *ptr, size_t size, int is_ptr, int is_struct, size_t group, int n_ptr_fields,
...);
extern void register_constant(size_t const_id, void *address,
size_t length);
extern int alias_group_changed(unsigned loc_id);
extern void malloc_helper(const void *ptr, size_t nbytes, size_t group, int is_ptr,
int is_struct, ...);
extern void calloc_helper(const void *ptr, size_t num, size_t size, size_t group, int is_ptr,
int is_struct, ...);
extern void realloc_helper(const void *new_ptr, const void *old_ptr,
void *header, size_t nbytes, size_t group, int is_ptr, int is_struct,
...);
extern void free_helper(const void *ptr, size_t group);
extern bool disable_current_thread();
extern void reenable_current_thread(bool was_disabled);
extern void thread_leaving();
extern void *get_thread_ctx();
extern unsigned entering_omp_parallel(unsigned lbl, size_t *region_id,
unsigned nlocals, ...);
extern void register_thread_local_stack_vars(unsigned relation,
unsigned parent, void *parent_ctx_ptr, unsigned threads_in_region,
unsigned parent_stack_depth,
size_t region_id, unsigned nlocals, ...);
extern void leaving_omp_parallel(unsigned expected_parent_stack_depth,
size_t region_id, int is_parallel_for);
extern unsigned get_parent_vars_stack_depth();
extern unsigned get_thread_stack_depth();
extern void chimes_error();
# 69 "/home/jmg3/chimes/src/libchimes/libchimes.h"
extern "C" {
extern int omp_get_thread_num (void) throw ();
extern int omp_get_num_threads(void) throw ();
}
inline unsigned LIBCHIMES_THREAD_NUM() { return omp_get_thread_num(); }
inline unsigned LIBCHIMES_NUM_THREADS() { return omp_get_num_threads(); }
extern int ____chimes_replaying;
# 1 "<command-line>" 2
# 1 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 19 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 28 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/features.h" 1 3 4
# 361 "/usr/include/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 365 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 366 "/usr/include/sys/cdefs.h" 2 3 4
# 362 "/usr/include/features.h" 2 3 4
# 385 "/usr/include/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 5 "/usr/include/gnu/stubs.h" 2 3 4
# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 2 3 4
# 386 "/usr/include/features.h" 2 3 4
# 29 "/usr/include/stdio.h" 2 3 4
extern "C" {
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 35 "/usr/include/stdio.h" 2 3 4
# 1 "/usr/include/bits/types.h" 1 3 4
# 28 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/bits/types.h" 2 3 4
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
# 131 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 132 "/usr/include/bits/types.h" 2 3 4
typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef int __daddr_t;
typedef long int __swblk_t;
typedef int __key_t;
typedef int __clockid_t;
typedef void * __timer_t;
typedef long int __blksize_t;
typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;
typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;
typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;
typedef long int __ssize_t;
typedef __off64_t __loff_t;
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;
typedef long int __intptr_t;
typedef unsigned int __socklen_t;
# 37 "/usr/include/stdio.h" 2 3 4
# 45 "/usr/include/stdio.h" 3 4
struct _IO_FILE;
typedef struct _IO_FILE FILE;
# 65 "/usr/include/stdio.h" 3 4
typedef struct _IO_FILE __FILE;
# 75 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/libio.h" 1 3 4
# 32 "/usr/include/libio.h" 3 4
# 1 "/usr/include/_G_config.h" 1 3 4
# 15 "/usr/include/_G_config.h" 3 4
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 16 "/usr/include/_G_config.h" 2 3 4
# 1 "/usr/include/wchar.h" 1 3 4
# 83 "/usr/include/wchar.h" 3 4
typedef struct
{
int __count;
union
{
unsigned int __wch;
char __wchb[4];
} __value;
} __mbstate_t;
# 21 "/usr/include/_G_config.h" 2 3 4
typedef struct
{
__off_t __pos;
__mbstate_t __state;
} _G_fpos_t;
typedef struct
{
__off64_t __pos;
__mbstate_t __state;
} _G_fpos64_t;
# 53 "/usr/include/_G_config.h" 3 4
typedef int _G_int16_t __attribute__ ((__mode__ (__HI__)));
typedef int _G_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int _G_uint16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
# 33 "/usr/include/libio.h" 2 3 4
# 53 "/usr/include/libio.h" 3 4
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stdarg.h" 1 3 4
# 40 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 54 "/usr/include/libio.h" 2 3 4
# 170 "/usr/include/libio.h" 3 4
struct _IO_jump_t; struct _IO_FILE;
# 180 "/usr/include/libio.h" 3 4
typedef void _IO_lock_t;
struct _IO_marker {
struct _IO_marker *_next;
struct _IO_FILE *_sbuf;
int _pos;
# 203 "/usr/include/libio.h" 3 4
};
enum __codecvt_result
{
__codecvt_ok,
__codecvt_partial,
__codecvt_error,
__codecvt_noconv
};
# 271 "/usr/include/libio.h" 3 4
struct _IO_FILE {
int _flags;
char* _IO_read_ptr;
char* _IO_read_end;
char* _IO_read_base;
char* _IO_write_base;
char* _IO_write_ptr;
char* _IO_write_end;
char* _IO_buf_base;
char* _IO_buf_end;
char *_IO_save_base;
char *_IO_backup_base;
char *_IO_save_end;
struct _IO_marker *_markers;
struct _IO_FILE *_chain;
int _fileno;
int _flags2;
__off_t _old_offset;
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];
_IO_lock_t *_lock;
# 319 "/usr/include/libio.h" 3 4
__off64_t _offset;
# 328 "/usr/include/libio.h" 3 4
void *__pad1;
void *__pad2;
void *__pad3;
void *__pad4;
size_t __pad5;
int _mode;
char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
};
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 364 "/usr/include/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
size_t __n);
typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
typedef int __io_close_fn (void *__cookie);
typedef __io_read_fn cookie_read_function_t;
typedef __io_write_fn cookie_write_function_t;
typedef __io_seek_fn cookie_seek_function_t;
typedef __io_close_fn cookie_close_function_t;
typedef struct
{
__io_read_fn *read;
__io_write_fn *write;
__io_seek_fn *seek;
__io_close_fn *close;
} _IO_cookie_io_functions_t;
typedef _IO_cookie_io_functions_t cookie_io_functions_t;
struct _IO_cookie_file;
extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
void *__cookie, _IO_cookie_io_functions_t __fns);
extern "C" {
extern int __underflow (_IO_FILE *);
extern int __uflow (_IO_FILE *);
extern int __overflow (_IO_FILE *, int);
# 460 "/usr/include/libio.h" 3 4
extern int _IO_getc (_IO_FILE *__fp);
extern int _IO_putc (int __c, _IO_FILE *__fp);
extern int _IO_feof (_IO_FILE *__fp) throw ();
extern int _IO_ferror (_IO_FILE *__fp) throw ();
extern int _IO_peekc_locked (_IO_FILE *__fp);
extern void _IO_flockfile (_IO_FILE *) throw ();
extern void _IO_funlockfile (_IO_FILE *) throw ();
extern int _IO_ftrylockfile (_IO_FILE *) throw ();
# 490 "/usr/include/libio.h" 3 4
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
__gnuc_va_list, int *__restrict);
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
__gnuc_va_list);
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
extern void _IO_free_backup_area (_IO_FILE *) throw ();
# 552 "/usr/include/libio.h" 3 4
}
# 76 "/usr/include/stdio.h" 2 3 4
typedef __gnuc_va_list va_list;
# 91 "/usr/include/stdio.h" 3 4
typedef __off_t off_t;
typedef __off64_t off64_t;
typedef __ssize_t ssize_t;
typedef _G_fpos_t fpos_t;
typedef _G_fpos64_t fpos64_t;
# 161 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio_lim.h" 1 3 4
# 162 "/usr/include/stdio.h" 2 3 4
extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;
# 177 "/usr/include/stdio.h" 3 4
extern int remove (__const char *__filename) throw ();
extern int rename (__const char *__old, __const char *__new) throw ();
extern int renameat (int __oldfd, __const char *__old, int __newfd,
__const char *__new) throw ();
# 194 "/usr/include/stdio.h" 3 4
extern FILE *tmpfile (void) ;
# 204 "/usr/include/stdio.h" 3 4
extern FILE *tmpfile64 (void) ;
extern char *tmpnam (char *__s) throw () ;
extern char *tmpnam_r (char *__s) throw () ;
# 226 "/usr/include/stdio.h" 3 4
extern char *tempnam (__const char *__dir, __const char *__pfx)
throw () __attribute__ ((__malloc__)) ;
# 236 "/usr/include/stdio.h" 3 4
extern int fclose (FILE *__stream);
extern int fflush (FILE *__stream);
# 251 "/usr/include/stdio.h" 3 4
extern int fflush_unlocked (FILE *__stream);
# 261 "/usr/include/stdio.h" 3 4
extern int fcloseall (void);
# 271 "/usr/include/stdio.h" 3 4
extern FILE *fopen (__const char *__restrict __filename,
__const char *__restrict __modes) ;
extern FILE *freopen (__const char *__restrict __filename,
__const char *__restrict __modes,
FILE *__restrict __stream) ;
# 294 "/usr/include/stdio.h" 3 4
extern FILE *fopen64 (__const char *__restrict __filename,
__const char *__restrict __modes) ;
extern FILE *freopen64 (__const char *__restrict __filename,
__const char *__restrict __modes,
FILE *__restrict __stream) ;
extern FILE *fdopen (int __fd, __const char *__modes) throw () ;
extern FILE *fopencookie (void *__restrict __magic_cookie,
__const char *__restrict __modes,
_IO_cookie_io_functions_t __io_funcs) throw () ;
extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
throw () ;
extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () ;
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw ();
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
int __modes, size_t __n) throw ();
extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
size_t __size) throw ();
extern void setlinebuf (FILE *__stream) throw ();
# 355 "/usr/include/stdio.h" 3 4
extern int fprintf (FILE *__restrict __stream,
__const char *__restrict __format, ...);
extern int printf (__const char *__restrict __format, ...);
extern int sprintf (char *__restrict __s,
__const char *__restrict __format, ...) throw ();
extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
__gnuc_va_list __arg);
extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
__gnuc_va_list __arg) throw ();
extern int snprintf (char *__restrict __s, size_t __maxlen,
__const char *__restrict __format, ...)
throw () __attribute__ ((__format__ (__printf__, 3, 4)));
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
__const char *__restrict __format, __gnuc_va_list __arg)
throw () __attribute__ ((__format__ (__printf__, 3, 0)));
extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
__gnuc_va_list __arg)
throw () __attribute__ ((__format__ (__printf__, 2, 0))) ;
extern int __asprintf (char **__restrict __ptr,
__const char *__restrict __fmt, ...)
throw () __attribute__ ((__format__ (__printf__, 2, 3))) ;
extern int asprintf (char **__restrict __ptr,
__const char *__restrict __fmt, ...)
throw () __attribute__ ((__format__ (__printf__, 2, 3))) ;
# 416 "/usr/include/stdio.h" 3 4
extern int vdprintf (int __fd, __const char *__restrict __fmt,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
# 429 "/usr/include/stdio.h" 3 4
extern int fscanf (FILE *__restrict __stream,
__const char *__restrict __format, ...) ;
extern int scanf (__const char *__restrict __format, ...) ;
extern int sscanf (__const char *__restrict __s,
__const char *__restrict __format, ...) throw ();
# 467 "/usr/include/stdio.h" 3 4
# 475 "/usr/include/stdio.h" 3 4
extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0))) ;
extern int vscanf (__const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 1, 0))) ;
extern int vsscanf (__const char *__restrict __s,
__const char *__restrict __format, __gnuc_va_list __arg)
throw () __attribute__ ((__format__ (__scanf__, 2, 0)));
# 526 "/usr/include/stdio.h" 3 4
# 535 "/usr/include/stdio.h" 3 4
extern int fgetc (FILE *__stream);
extern int getc (FILE *__stream);
extern int getchar (void);
# 554 "/usr/include/stdio.h" 3 4
extern int getc_unlocked (FILE *__stream);
extern int getchar_unlocked (void);
# 565 "/usr/include/stdio.h" 3 4
extern int fgetc_unlocked (FILE *__stream);
# 577 "/usr/include/stdio.h" 3 4
extern int fputc (int __c, FILE *__stream);
extern int putc (int __c, FILE *__stream);
extern int putchar (int __c);
# 598 "/usr/include/stdio.h" 3 4
extern int fputc_unlocked (int __c, FILE *__stream);
extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);
extern int getw (FILE *__stream);
extern int putw (int __w, FILE *__stream);
# 626 "/usr/include/stdio.h" 3 4
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
;
extern char *gets (char *__s) ;
# 644 "/usr/include/stdio.h" 3 4
extern char *fgets_unlocked (char *__restrict __s, int __n,
FILE *__restrict __stream) ;
# 660 "/usr/include/stdio.h" 3 4
extern __ssize_t __getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) ;
extern __ssize_t getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) ;
extern __ssize_t getline (char **__restrict __lineptr,
size_t *__restrict __n,
FILE *__restrict __stream) ;
# 684 "/usr/include/stdio.h" 3 4
extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);
extern int puts (__const char *__s);
extern int ungetc (int __c, FILE *__stream);
extern size_t fread (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s) ;
# 721 "/usr/include/stdio.h" 3 4
extern int fputs_unlocked (__const char *__restrict __s,
FILE *__restrict __stream);
# 732 "/usr/include/stdio.h" 3 4
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) ;
# 744 "/usr/include/stdio.h" 3 4
extern int fseek (FILE *__stream, long int __off, int __whence);
extern long int ftell (FILE *__stream) ;
extern void rewind (FILE *__stream);
# 768 "/usr/include/stdio.h" 3 4
extern int fseeko (FILE *__stream, __off_t __off, int __whence);
extern __off_t ftello (FILE *__stream) ;
# 787 "/usr/include/stdio.h" 3 4
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
extern int fsetpos (FILE *__stream, __const fpos_t *__pos);
# 810 "/usr/include/stdio.h" 3 4
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
extern __off64_t ftello64 (FILE *__stream) ;
extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);
extern void clearerr (FILE *__stream) throw ();
extern int feof (FILE *__stream) throw () ;
extern int ferror (FILE *__stream) throw () ;
extern void clearerr_unlocked (FILE *__stream) throw ();
extern int feof_unlocked (FILE *__stream) throw () ;
extern int ferror_unlocked (FILE *__stream) throw () ;
# 841 "/usr/include/stdio.h" 3 4
extern void perror (__const char *__s);
# 1 "/usr/include/bits/sys_errlist.h" 1 3 4
# 27 "/usr/include/bits/sys_errlist.h" 3 4
extern int sys_nerr;
extern __const char *__const sys_errlist[];
extern int _sys_nerr;
extern __const char *__const _sys_errlist[];
# 849 "/usr/include/stdio.h" 2 3 4
extern int fileno (FILE *__stream) throw () ;
extern int fileno_unlocked (FILE *__stream) throw () ;
# 868 "/usr/include/stdio.h" 3 4
extern FILE *popen (__const char *__command, __const char *__modes) ;
extern int pclose (FILE *__stream);
extern char *ctermid (char *__s) throw ();
extern char *cuserid (char *__s);
struct obstack;
extern int obstack_printf (struct obstack *__restrict __obstack,
__const char *__restrict __format, ...)
throw () __attribute__ ((__format__ (__printf__, 2, 3)));
extern int obstack_vprintf (struct obstack *__restrict __obstack,
__const char *__restrict __format,
__gnuc_va_list __args)
throw () __attribute__ ((__format__ (__printf__, 2, 0)));
extern void flockfile (FILE *__stream) throw ();
extern int ftrylockfile (FILE *__stream) throw () ;
extern void funlockfile (FILE *__stream) throw ();
# 929 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio.h" 1 3 4
# 36 "/usr/include/bits/stdio.h" 3 4
extern __inline __attribute__ ((__gnu_inline__)) int
vprintf (__const char *__restrict __fmt, __gnuc_va_list __arg)
{
return vfprintf (stdout, __fmt, __arg);
}
extern __inline __attribute__ ((__gnu_inline__)) int
getchar (void)
{
return _IO_getc (stdin);
}
extern __inline __attribute__ ((__gnu_inline__)) int
fgetc_unlocked (FILE *__fp)
{
return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
}
extern __inline __attribute__ ((__gnu_inline__)) int
getc_unlocked (FILE *__fp)
{
return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
}
extern __inline __attribute__ ((__gnu_inline__)) int
getchar_unlocked (void)
{
return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++);
}
extern __inline __attribute__ ((__gnu_inline__)) int
putchar (int __c)
{
return _IO_putc (__c, stdout);
}
extern __inline __attribute__ ((__gnu_inline__)) int
fputc_unlocked (int __c, FILE *__stream)
{
return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
}
extern __inline __attribute__ ((__gnu_inline__)) int
putc_unlocked (int __c, FILE *__stream)
{
return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
}
extern __inline __attribute__ ((__gnu_inline__)) int
putchar_unlocked (int __c)
{
return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c)));
}
extern __inline __attribute__ ((__gnu_inline__)) __ssize_t
getline (char **__lineptr, size_t *__n, FILE *__stream)
{
return __getdelim (__lineptr, __n, '\n', __stream);
}
extern __inline __attribute__ ((__gnu_inline__)) int
feof_unlocked (FILE *__stream) throw ()
{
return (((__stream)->_flags & 0x10) != 0);
}
extern __inline __attribute__ ((__gnu_inline__)) int
ferror_unlocked (FILE *__stream) throw ()
{
return (((__stream)->_flags & 0x20) != 0);
}
# 930 "/usr/include/stdio.h" 2 3 4
# 938 "/usr/include/stdio.h" 3 4
}
# 20 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 1 "/usr/include/unistd.h" 1 3 4
# 28 "/usr/include/unistd.h" 3 4
extern "C" {
# 203 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/bits/posix_opt.h" 1 3 4
# 204 "/usr/include/unistd.h" 2 3 4
# 1 "/usr/include/bits/environments.h" 1 3 4
# 23 "/usr/include/bits/environments.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 24 "/usr/include/bits/environments.h" 2 3 4
# 208 "/usr/include/unistd.h" 2 3 4
# 227 "/usr/include/unistd.h" 3 4
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 228 "/usr/include/unistd.h" 2 3 4
typedef __gid_t gid_t;
typedef __uid_t uid_t;
# 256 "/usr/include/unistd.h" 3 4
typedef __useconds_t useconds_t;
typedef __pid_t pid_t;
typedef __intptr_t intptr_t;
typedef __socklen_t socklen_t;
# 288 "/usr/include/unistd.h" 3 4
extern int access (__const char *__name, int __type) throw () __attribute__ ((__nonnull__ (1)));
extern int euidaccess (__const char *__name, int __type)
throw () __attribute__ ((__nonnull__ (1)));
extern int eaccess (__const char *__name, int __type)
throw () __attribute__ ((__nonnull__ (1)));
extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
throw () __attribute__ ((__nonnull__ (2))) ;
# 331 "/usr/include/unistd.h" 3 4
extern __off_t lseek (int __fd, __off_t __offset, int __whence) throw ();
# 342 "/usr/include/unistd.h" 3 4
extern __off64_t lseek64 (int __fd, __off64_t __offset, int __whence)
throw ();
extern int close (int __fd);
extern ssize_t read (int __fd, void *__buf, size_t __nbytes) ;
extern ssize_t write (int __fd, __const void *__buf, size_t __n) ;
# 373 "/usr/include/unistd.h" 3 4
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
__off_t __offset) ;
extern ssize_t pwrite (int __fd, __const void *__buf, size_t __n,
__off_t __offset) ;
# 401 "/usr/include/unistd.h" 3 4
extern ssize_t pread64 (int __fd, void *__buf, size_t __nbytes,
__off64_t __offset) ;
extern ssize_t pwrite64 (int __fd, __const void *__buf, size_t __n,
__off64_t __offset) ;
extern int pipe (int __pipedes[2]) throw () ;
extern int pipe2 (int __pipedes[2], int __flags) throw () ;
# 429 "/usr/include/unistd.h" 3 4
extern unsigned int alarm (unsigned int __seconds) throw ();
# 441 "/usr/include/unistd.h" 3 4
extern unsigned int sleep (unsigned int __seconds);
extern __useconds_t ualarm (__useconds_t __value, __useconds_t __interval)
throw ();
extern int usleep (__useconds_t __useconds);
# 466 "/usr/include/unistd.h" 3 4
extern int pause (void);
extern int chown (__const char *__file, __uid_t __owner, __gid_t __group)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int fchown (int __fd, __uid_t __owner, __gid_t __group) throw () ;
extern int lchown (__const char *__file, __uid_t __owner, __gid_t __group)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int fchownat (int __fd, __const char *__file, __uid_t __owner,
__gid_t __group, int __flag)
throw () __attribute__ ((__nonnull__ (2))) ;
extern int chdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ;
extern int fchdir (int __fd) throw () ;
# 508 "/usr/include/unistd.h" 3 4
extern char *getcwd (char *__buf, size_t __size) throw () ;
extern char *get_current_dir_name (void) throw ();
extern char *getwd (char *__buf)
throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__deprecated__)) ;
extern int dup (int __fd) throw () ;
extern int dup2 (int __fd, int __fd2) throw ();
extern int dup3 (int __fd, int __fd2, int __flags) throw ();
extern char **__environ;
extern char **environ;
extern int execve (__const char *__path, char *__const __argv[],
char *__const __envp[]) throw () __attribute__ ((__nonnull__ (1, 2)));
extern int fexecve (int __fd, char *__const __argv[], char *__const __envp[])
throw () __attribute__ ((__nonnull__ (2)));
extern int execv (__const char *__path, char *__const __argv[])
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int execle (__const char *__path, __const char *__arg, ...)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int execl (__const char *__path, __const char *__arg, ...)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int execvp (__const char *__file, char *__const __argv[])
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int execlp (__const char *__file, __const char *__arg, ...)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int execvpe (__const char *__file, char *__const __argv[],
char *__const __envp[])
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int nice (int __inc) throw () ;
extern void _exit (int __status) __attribute__ ((__noreturn__));
# 1 "/usr/include/bits/confname.h" 1 3 4
# 26 "/usr/include/bits/confname.h" 3 4
enum
{
_PC_LINK_MAX,
_PC_MAX_CANON,
_PC_MAX_INPUT,
_PC_NAME_MAX,
_PC_PATH_MAX,
_PC_PIPE_BUF,
_PC_CHOWN_RESTRICTED,
_PC_NO_TRUNC,
_PC_VDISABLE,
_PC_SYNC_IO,
_PC_ASYNC_IO,
_PC_PRIO_IO,
_PC_SOCK_MAXBUF,
_PC_FILESIZEBITS,
_PC_REC_INCR_XFER_SIZE,
_PC_REC_MAX_XFER_SIZE,
_PC_REC_MIN_XFER_SIZE,
_PC_REC_XFER_ALIGN,
_PC_ALLOC_SIZE_MIN,
_PC_SYMLINK_MAX,
_PC_2_SYMLINKS
};
enum
{
_SC_ARG_MAX,
_SC_CHILD_MAX,
_SC_CLK_TCK,
_SC_NGROUPS_MAX,
_SC_OPEN_MAX,
_SC_STREAM_MAX,
_SC_TZNAME_MAX,
_SC_JOB_CONTROL,
_SC_SAVED_IDS,
_SC_REALTIME_SIGNALS,
_SC_PRIORITY_SCHEDULING,
_SC_TIMERS,
_SC_ASYNCHRONOUS_IO,
_SC_PRIORITIZED_IO,
_SC_SYNCHRONIZED_IO,
_SC_FSYNC,
_SC_MAPPED_FILES,
_SC_MEMLOCK,
_SC_MEMLOCK_RANGE,
_SC_MEMORY_PROTECTION,
_SC_MESSAGE_PASSING,
_SC_SEMAPHORES,
_SC_SHARED_MEMORY_OBJECTS,
_SC_AIO_LISTIO_MAX,
_SC_AIO_MAX,
_SC_AIO_PRIO_DELTA_MAX,
_SC_DELAYTIMER_MAX,
_SC_MQ_OPEN_MAX,
_SC_MQ_PRIO_MAX,
_SC_VERSION,
_SC_PAGESIZE,
_SC_RTSIG_MAX,
_SC_SEM_NSEMS_MAX,
_SC_SEM_VALUE_MAX,
_SC_SIGQUEUE_MAX,
_SC_TIMER_MAX,
_SC_BC_BASE_MAX,
_SC_BC_DIM_MAX,
_SC_BC_SCALE_MAX,
_SC_BC_STRING_MAX,
_SC_COLL_WEIGHTS_MAX,
_SC_EQUIV_CLASS_MAX,
_SC_EXPR_NEST_MAX,
_SC_LINE_MAX,
_SC_RE_DUP_MAX,
_SC_CHARCLASS_NAME_MAX,
_SC_2_VERSION,
_SC_2_C_BIND,
_SC_2_C_DEV,
_SC_2_FORT_DEV,
_SC_2_FORT_RUN,
_SC_2_SW_DEV,
_SC_2_LOCALEDEF,
_SC_PII,
_SC_PII_XTI,
_SC_PII_SOCKET,
_SC_PII_INTERNET,
_SC_PII_OSI,
_SC_POLL,
_SC_SELECT,
_SC_UIO_MAXIOV,
_SC_IOV_MAX = _SC_UIO_MAXIOV,
_SC_PII_INTERNET_STREAM,
_SC_PII_INTERNET_DGRAM,
_SC_PII_OSI_COTS,
_SC_PII_OSI_CLTS,
_SC_PII_OSI_M,
_SC_T_IOV_MAX,
_SC_THREADS,
_SC_THREAD_SAFE_FUNCTIONS,
_SC_GETGR_R_SIZE_MAX,
_SC_GETPW_R_SIZE_MAX,
_SC_LOGIN_NAME_MAX,
_SC_TTY_NAME_MAX,
_SC_THREAD_DESTRUCTOR_ITERATIONS,
_SC_THREAD_KEYS_MAX,
_SC_THREAD_STACK_MIN,
_SC_THREAD_THREADS_MAX,
_SC_THREAD_ATTR_STACKADDR,
_SC_THREAD_ATTR_STACKSIZE,
_SC_THREAD_PRIORITY_SCHEDULING,
_SC_THREAD_PRIO_INHERIT,
_SC_THREAD_PRIO_PROTECT,
_SC_THREAD_PROCESS_SHARED,
_SC_NPROCESSORS_CONF,
_SC_NPROCESSORS_ONLN,
_SC_PHYS_PAGES,
_SC_AVPHYS_PAGES,
_SC_ATEXIT_MAX,
_SC_PASS_MAX,
_SC_XOPEN_VERSION,
_SC_XOPEN_XCU_VERSION,
_SC_XOPEN_UNIX,
_SC_XOPEN_CRYPT,
_SC_XOPEN_ENH_I18N,
_SC_XOPEN_SHM,
_SC_2_CHAR_TERM,
_SC_2_C_VERSION,
_SC_2_UPE,
_SC_XOPEN_XPG2,
_SC_XOPEN_XPG3,
_SC_XOPEN_XPG4,
_SC_CHAR_BIT,
_SC_CHAR_MAX,
_SC_CHAR_MIN,
_SC_INT_MAX,
_SC_INT_MIN,
_SC_LONG_BIT,
_SC_WORD_BIT,
_SC_MB_LEN_MAX,
_SC_NZERO,
_SC_SSIZE_MAX,
_SC_SCHAR_MAX,
_SC_SCHAR_MIN,
_SC_SHRT_MAX,
_SC_SHRT_MIN,
_SC_UCHAR_MAX,
_SC_UINT_MAX,
_SC_ULONG_MAX,
_SC_USHRT_MAX,
_SC_NL_ARGMAX,
_SC_NL_LANGMAX,
_SC_NL_MSGMAX,
_SC_NL_NMAX,
_SC_NL_SETMAX,
_SC_NL_TEXTMAX,
_SC_XBS5_ILP32_OFF32,
_SC_XBS5_ILP32_OFFBIG,
_SC_XBS5_LP64_OFF64,
_SC_XBS5_LPBIG_OFFBIG,
_SC_XOPEN_LEGACY,
_SC_XOPEN_REALTIME,
_SC_XOPEN_REALTIME_THREADS,
_SC_ADVISORY_INFO,
_SC_BARRIERS,
_SC_BASE,
_SC_C_LANG_SUPPORT,
_SC_C_LANG_SUPPORT_R,
_SC_CLOCK_SELECTION,
_SC_CPUTIME,
_SC_THREAD_CPUTIME,
_SC_DEVICE_IO,
_SC_DEVICE_SPECIFIC,
_SC_DEVICE_SPECIFIC_R,
_SC_FD_MGMT,
_SC_FIFO,
_SC_PIPE,
_SC_FILE_ATTRIBUTES,
_SC_FILE_LOCKING,
_SC_FILE_SYSTEM,
_SC_MONOTONIC_CLOCK,
_SC_MULTI_PROCESS,
_SC_SINGLE_PROCESS,
_SC_NETWORKING,
_SC_READER_WRITER_LOCKS,
_SC_SPIN_LOCKS,
_SC_REGEXP,
_SC_REGEX_VERSION,
_SC_SHELL,
_SC_SIGNALS,
_SC_SPAWN,
_SC_SPORADIC_SERVER,
_SC_THREAD_SPORADIC_SERVER,
_SC_SYSTEM_DATABASE,
_SC_SYSTEM_DATABASE_R,
_SC_TIMEOUTS,
_SC_TYPED_MEMORY_OBJECTS,
_SC_USER_GROUPS,
_SC_USER_GROUPS_R,
_SC_2_PBS,
_SC_2_PBS_ACCOUNTING,
_SC_2_PBS_LOCATE,
_SC_2_PBS_MESSAGE,
_SC_2_PBS_TRACK,
_SC_SYMLOOP_MAX,
_SC_STREAMS,
_SC_2_PBS_CHECKPOINT,
_SC_V6_ILP32_OFF32,
_SC_V6_ILP32_OFFBIG,
_SC_V6_LP64_OFF64,
_SC_V6_LPBIG_OFFBIG,
_SC_HOST_NAME_MAX,
_SC_TRACE,
_SC_TRACE_EVENT_FILTER,
_SC_TRACE_INHERIT,
_SC_TRACE_LOG,
_SC_LEVEL1_ICACHE_SIZE,
_SC_LEVEL1_ICACHE_ASSOC,
_SC_LEVEL1_ICACHE_LINESIZE,
_SC_LEVEL1_DCACHE_SIZE,
_SC_LEVEL1_DCACHE_ASSOC,
_SC_LEVEL1_DCACHE_LINESIZE,
_SC_LEVEL2_CACHE_SIZE,
_SC_LEVEL2_CACHE_ASSOC,
_SC_LEVEL2_CACHE_LINESIZE,
_SC_LEVEL3_CACHE_SIZE,
_SC_LEVEL3_CACHE_ASSOC,
_SC_LEVEL3_CACHE_LINESIZE,
_SC_LEVEL4_CACHE_SIZE,
_SC_LEVEL4_CACHE_ASSOC,
_SC_LEVEL4_CACHE_LINESIZE,
_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
_SC_RAW_SOCKETS,
_SC_V7_ILP32_OFF32,
_SC_V7_ILP32_OFFBIG,
_SC_V7_LP64_OFF64,
_SC_V7_LPBIG_OFFBIG,
_SC_SS_REPL_MAX,
_SC_TRACE_EVENT_NAME_MAX,
_SC_TRACE_NAME_MAX,
_SC_TRACE_SYS_MAX,
_SC_TRACE_USER_EVENT_MAX,
_SC_XOPEN_STREAMS,
_SC_THREAD_ROBUST_PRIO_INHERIT,
_SC_THREAD_ROBUST_PRIO_PROTECT
};
enum
{
_CS_PATH,
_CS_V6_WIDTH_RESTRICTED_ENVS,
_CS_GNU_LIBC_VERSION,
_CS_GNU_LIBPTHREAD_VERSION,
_CS_V5_WIDTH_RESTRICTED_ENVS,
_CS_V7_WIDTH_RESTRICTED_ENVS,
_CS_LFS_CFLAGS = 1000,
_CS_LFS_LDFLAGS,
_CS_LFS_LIBS,
_CS_LFS_LINTFLAGS,
_CS_LFS64_CFLAGS,
_CS_LFS64_LDFLAGS,
_CS_LFS64_LIBS,
_CS_LFS64_LINTFLAGS,
_CS_XBS5_ILP32_OFF32_CFLAGS = 1100,
_CS_XBS5_ILP32_OFF32_LDFLAGS,
_CS_XBS5_ILP32_OFF32_LIBS,
_CS_XBS5_ILP32_OFF32_LINTFLAGS,
_CS_XBS5_ILP32_OFFBIG_CFLAGS,
_CS_XBS5_ILP32_OFFBIG_LDFLAGS,
_CS_XBS5_ILP32_OFFBIG_LIBS,
_CS_XBS5_ILP32_OFFBIG_LINTFLAGS,
_CS_XBS5_LP64_OFF64_CFLAGS,
_CS_XBS5_LP64_OFF64_LDFLAGS,
_CS_XBS5_LP64_OFF64_LIBS,
_CS_XBS5_LP64_OFF64_LINTFLAGS,
_CS_XBS5_LPBIG_OFFBIG_CFLAGS,
_CS_XBS5_LPBIG_OFFBIG_LDFLAGS,
_CS_XBS5_LPBIG_OFFBIG_LIBS,
_CS_XBS5_LPBIG_OFFBIG_LINTFLAGS,
_CS_POSIX_V6_ILP32_OFF32_CFLAGS,
_CS_POSIX_V6_ILP32_OFF32_LDFLAGS,
_CS_POSIX_V6_ILP32_OFF32_LIBS,
_CS_POSIX_V6_ILP32_OFF32_LINTFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS,
_CS_POSIX_V6_ILP32_OFFBIG_LIBS,
_CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS,
_CS_POSIX_V6_LP64_OFF64_CFLAGS,
_CS_POSIX_V6_LP64_OFF64_LDFLAGS,
_CS_POSIX_V6_LP64_OFF64_LIBS,
_CS_POSIX_V6_LP64_OFF64_LINTFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS,
_CS_POSIX_V6_LPBIG_OFFBIG_LIBS,
_CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS,
_CS_POSIX_V7_ILP32_OFF32_CFLAGS,
_CS_POSIX_V7_ILP32_OFF32_LDFLAGS,
_CS_POSIX_V7_ILP32_OFF32_LIBS,
_CS_POSIX_V7_ILP32_OFF32_LINTFLAGS,
_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS,
_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS,
_CS_POSIX_V7_ILP32_OFFBIG_LIBS,
_CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS,
_CS_POSIX_V7_LP64_OFF64_CFLAGS,
_CS_POSIX_V7_LP64_OFF64_LDFLAGS,
_CS_POSIX_V7_LP64_OFF64_LIBS,
_CS_POSIX_V7_LP64_OFF64_LINTFLAGS,
_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS,
_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS,
_CS_POSIX_V7_LPBIG_OFFBIG_LIBS,
_CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS,
_CS_V6_ENV,
_CS_V7_ENV
};
# 607 "/usr/include/unistd.h" 2 3 4
extern long int pathconf (__const char *__path, int __name)
throw () __attribute__ ((__nonnull__ (1)));
extern long int fpathconf (int __fd, int __name) throw ();
extern long int sysconf (int __name) throw ();
extern size_t confstr (int __name, char *__buf, size_t __len) throw ();
extern __pid_t getpid (void) throw ();
extern __pid_t getppid (void) throw ();
extern __pid_t getpgrp (void) throw ();
# 643 "/usr/include/unistd.h" 3 4
extern __pid_t __getpgid (__pid_t __pid) throw ();
extern __pid_t getpgid (__pid_t __pid) throw ();
extern int setpgid (__pid_t __pid, __pid_t __pgid) throw ();
# 669 "/usr/include/unistd.h" 3 4
extern int setpgrp (void) throw ();
# 686 "/usr/include/unistd.h" 3 4
extern __pid_t setsid (void) throw ();
extern __pid_t getsid (__pid_t __pid) throw ();
extern __uid_t getuid (void) throw ();
extern __uid_t geteuid (void) throw ();
extern __gid_t getgid (void) throw ();
extern __gid_t getegid (void) throw ();
extern int getgroups (int __size, __gid_t __list[]) throw () ;
extern int group_member (__gid_t __gid) throw ();
extern int setuid (__uid_t __uid) throw ();
extern int setreuid (__uid_t __ruid, __uid_t __euid) throw ();
extern int seteuid (__uid_t __uid) throw ();
extern int setgid (__gid_t __gid) throw ();
extern int setregid (__gid_t __rgid, __gid_t __egid) throw ();
extern int setegid (__gid_t __gid) throw ();
extern int getresuid (__uid_t *__ruid, __uid_t *__euid, __uid_t *__suid)
throw ();
extern int getresgid (__gid_t *__rgid, __gid_t *__egid, __gid_t *__sgid)
throw ();
extern int setresuid (__uid_t __ruid, __uid_t __euid, __uid_t __suid)
throw ();
extern int setresgid (__gid_t __rgid, __gid_t __egid, __gid_t __sgid)
throw ();
extern __pid_t fork (void) throw ();
extern __pid_t vfork (void) throw ();
extern char *ttyname (int __fd) throw ();
extern int ttyname_r (int __fd, char *__buf, size_t __buflen)
throw () __attribute__ ((__nonnull__ (2))) ;
extern int isatty (int __fd) throw ();
extern int ttyslot (void) throw ();
extern int link (__const char *__from, __const char *__to)
throw () __attribute__ ((__nonnull__ (1, 2))) ;
extern int linkat (int __fromfd, __const char *__from, int __tofd,
__const char *__to, int __flags)
throw () __attribute__ ((__nonnull__ (2, 4))) ;
extern int symlink (__const char *__from, __const char *__to)
throw () __attribute__ ((__nonnull__ (1, 2))) ;
extern ssize_t readlink (__const char *__restrict __path,
char *__restrict __buf, size_t __len)
throw () __attribute__ ((__nonnull__ (1, 2))) ;
extern int symlinkat (__const char *__from, int __tofd,
__const char *__to) throw () __attribute__ ((__nonnull__ (1, 3))) ;
extern ssize_t readlinkat (int __fd, __const char *__restrict __path,
char *__restrict __buf, size_t __len)
throw () __attribute__ ((__nonnull__ (2, 3))) ;
extern int unlink (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
extern int unlinkat (int __fd, __const char *__name, int __flag)
throw () __attribute__ ((__nonnull__ (2)));
extern int rmdir (__const char *__path) throw () __attribute__ ((__nonnull__ (1)));
extern __pid_t tcgetpgrp (int __fd) throw ();
extern int tcsetpgrp (int __fd, __pid_t __pgrp_id) throw ();
extern char *getlogin (void);
extern int getlogin_r (char *__name, size_t __name_len) __attribute__ ((__nonnull__ (1)));
extern int setlogin (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
# 890 "/usr/include/unistd.h" 3 4
# 1 "/usr/include/getopt.h" 1 3 4
# 50 "/usr/include/getopt.h" 3 4
extern "C" {
# 59 "/usr/include/getopt.h" 3 4
extern char *optarg;
# 73 "/usr/include/getopt.h" 3 4
extern int optind;
extern int opterr;
extern int optopt;
# 152 "/usr/include/getopt.h" 3 4
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
throw ();
# 187 "/usr/include/getopt.h" 3 4
}
# 891 "/usr/include/unistd.h" 2 3 4
extern int gethostname (char *__name, size_t __len) throw () __attribute__ ((__nonnull__ (1)));
extern int sethostname (__const char *__name, size_t __len)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int sethostid (long int __id) throw () ;
extern int getdomainname (char *__name, size_t __len)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int setdomainname (__const char *__name, size_t __len)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int vhangup (void) throw ();
extern int revoke (__const char *__file) throw () __attribute__ ((__nonnull__ (1))) ;
extern int profil (unsigned short int *__sample_buffer, size_t __size,
size_t __offset, unsigned int __scale)
throw () __attribute__ ((__nonnull__ (1)));
extern int acct (__const char *__name) throw ();
extern char *getusershell (void) throw ();
extern void endusershell (void) throw ();
extern void setusershell (void) throw ();
extern int daemon (int __nochdir, int __noclose) throw () ;
extern int chroot (__const char *__path) throw () __attribute__ ((__nonnull__ (1))) ;
extern char *getpass (__const char *__prompt) __attribute__ ((__nonnull__ (1)));
# 976 "/usr/include/unistd.h" 3 4
extern int fsync (int __fd);
extern long int gethostid (void);
extern void sync (void) throw ();
extern int getpagesize (void) throw () __attribute__ ((__const__));
extern int getdtablesize (void) throw ();
# 1007 "/usr/include/unistd.h" 3 4
extern int truncate (__const char *__file, __off_t __length)
throw () __attribute__ ((__nonnull__ (1))) ;
# 1019 "/usr/include/unistd.h" 3 4
extern int truncate64 (__const char *__file, __off64_t __length)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int ftruncate (int __fd, __off_t __length) throw () ;
# 1036 "/usr/include/unistd.h" 3 4
extern int ftruncate64 (int __fd, __off64_t __length) throw () ;
# 1047 "/usr/include/unistd.h" 3 4
extern int brk (void *__addr) throw () ;
extern void *sbrk (intptr_t __delta) throw ();
# 1068 "/usr/include/unistd.h" 3 4
extern long int syscall (long int __sysno, ...) throw ();
# 1091 "/usr/include/unistd.h" 3 4
extern int lockf (int __fd, int __cmd, __off_t __len) ;
# 1101 "/usr/include/unistd.h" 3 4
extern int lockf64 (int __fd, int __cmd, __off64_t __len) ;
# 1122 "/usr/include/unistd.h" 3 4
extern int fdatasync (int __fildes);
extern char *crypt (__const char *__key, __const char *__salt)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern void encrypt (char *__block, int __edflag) throw () __attribute__ ((__nonnull__ (1)));
extern void swab (__const void *__restrict __from, void *__restrict __to,
ssize_t __n) throw () __attribute__ ((__nonnull__ (1, 2)));
extern char *ctermid (char *__s) throw ();
# 1160 "/usr/include/unistd.h" 3 4
}
# 21 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 1 "/usr/include/getopt.h" 1 3 4
# 50 "/usr/include/getopt.h" 3 4
extern "C" {
# 59 "/usr/include/getopt.h" 3 4
extern char *optarg;
# 73 "/usr/include/getopt.h" 3 4
extern int optind;
extern int opterr;
extern int optopt;
# 106 "/usr/include/getopt.h" 3 4
struct option
{
const char *name;
int has_arg;
int *flag;
int val;
};
# 152 "/usr/include/getopt.h" 3 4
extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
throw ();
# 175 "/usr/include/getopt.h" 3 4
extern int getopt_long (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
throw ();
extern int getopt_long_only (int ___argc, char *const *___argv,
const char *__shortopts,
const struct option *__longopts, int *__longind)
throw ();
}
# 22 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 1 "/usr/include/stdlib.h" 1 3 4
# 33 "/usr/include/stdlib.h" 3 4
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 34 "/usr/include/stdlib.h" 2 3 4
extern "C" {
# 1 "/usr/include/bits/waitflags.h" 1 3 4
# 43 "/usr/include/stdlib.h" 2 3 4
# 1 "/usr/include/bits/waitstatus.h" 1 3 4
# 65 "/usr/include/bits/waitstatus.h" 3 4
# 1 "/usr/include/endian.h" 1 3 4
# 37 "/usr/include/endian.h" 3 4
# 1 "/usr/include/bits/endian.h" 1 3 4
# 38 "/usr/include/endian.h" 2 3 4
# 61 "/usr/include/endian.h" 3 4
# 1 "/usr/include/bits/byteswap.h" 1 3 4
# 28 "/usr/include/bits/byteswap.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 29 "/usr/include/bits/byteswap.h" 2 3 4
# 62 "/usr/include/endian.h" 2 3 4
# 66 "/usr/include/bits/waitstatus.h" 2 3 4
union wait
{
int w_status;
struct
{
unsigned int __w_termsig:7;
unsigned int __w_coredump:1;
unsigned int __w_retcode:8;
unsigned int:16;
} __wait_terminated;
struct
{
unsigned int __w_stopval:8;
unsigned int __w_stopsig:8;
unsigned int:16;
} __wait_stopped;
};
# 44 "/usr/include/stdlib.h" 2 3 4
# 96 "/usr/include/stdlib.h" 3 4
typedef struct
{
int quot;
int rem;
} div_t;
typedef struct
{
long int quot;
long int rem;
} ldiv_t;
__extension__ typedef struct
{
long long int quot;
long long int rem;
} lldiv_t;
# 140 "/usr/include/stdlib.h" 3 4
extern size_t __ctype_get_mb_cur_max (void) throw () ;
extern double atof (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern int atoi (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern long int atol (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
__extension__ extern long long int atoll (__const char *__nptr)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
extern double strtod (__const char *__restrict __nptr,
char **__restrict __endptr)
throw () __attribute__ ((__nonnull__ (1))) ;
extern float strtof (__const char *__restrict __nptr,
char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1))) ;
extern long double strtold (__const char *__restrict __nptr,
char **__restrict __endptr)
throw () __attribute__ ((__nonnull__ (1))) ;
extern long int strtol (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
extern unsigned long int strtoul (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
__extension__
extern long long int strtoq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
__extension__
extern unsigned long long int strtouq (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
__extension__
extern long long int strtoll (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
__extension__
extern unsigned long long int strtoull (__const char *__restrict __nptr,
char **__restrict __endptr, int __base)
throw () __attribute__ ((__nonnull__ (1))) ;
# 236 "/usr/include/stdlib.h" 3 4
# 1 "/usr/include/xlocale.h" 1 3 4
# 28 "/usr/include/xlocale.h" 3 4
typedef struct __locale_struct
{
struct __locale_data *__locales[13];
const unsigned short int *__ctype_b;
const int *__ctype_tolower;
const int *__ctype_toupper;
const char *__names[13];
} *__locale_t;
typedef __locale_t locale_t;
# 237 "/usr/include/stdlib.h" 2 3 4
extern long int strtol_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4))) ;
extern unsigned long int strtoul_l (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 4))) ;
__extension__
extern long long int strtoll_l (__const char *__restrict __nptr,
char **__restrict __endptr, int __base,
__locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 4))) ;
__extension__
extern unsigned long long int strtoull_l (__const char *__restrict __nptr,
char **__restrict __endptr,
int __base, __locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 4))) ;
extern double strtod_l (__const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 3))) ;
extern float strtof_l (__const char *__restrict __nptr,
char **__restrict __endptr, __locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 3))) ;
extern long double strtold_l (__const char *__restrict __nptr,
char **__restrict __endptr,
__locale_t __loc)
throw () __attribute__ ((__nonnull__ (1, 3))) ;
extern __inline __attribute__ ((__gnu_inline__)) double
atof (__const char *__nptr) throw ()
{
return strtod (__nptr, (char **) __null);
}
extern __inline __attribute__ ((__gnu_inline__)) int
atoi (__const char *__nptr) throw ()
{
return (int) strtol (__nptr, (char **) __null, 10);
}
extern __inline __attribute__ ((__gnu_inline__)) long int
atol (__const char *__nptr) throw ()
{
return strtol (__nptr, (char **) __null, 10);
}
__extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int
atoll (__const char *__nptr) throw ()
{
return strtoll (__nptr, (char **) __null, 10);
}
# 311 "/usr/include/stdlib.h" 3 4
extern char *l64a (long int __n) throw () ;
extern long int a64l (__const char *__s)
throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ;
# 1 "/usr/include/sys/types.h" 1 3 4
# 28 "/usr/include/sys/types.h" 3 4
extern "C" {
typedef __u_char u_char;
typedef __u_short u_short;
typedef __u_int u_int;
typedef __u_long u_long;
typedef __quad_t quad_t;
typedef __u_quad_t u_quad_t;
typedef __fsid_t fsid_t;
typedef __loff_t loff_t;
typedef __ino_t ino_t;
typedef __ino64_t ino64_t;
typedef __dev_t dev_t;
# 71 "/usr/include/sys/types.h" 3 4
typedef __mode_t mode_t;
typedef __nlink_t nlink_t;
# 105 "/usr/include/sys/types.h" 3 4
typedef __id_t id_t;
# 116 "/usr/include/sys/types.h" 3 4
typedef __daddr_t daddr_t;
typedef __caddr_t caddr_t;
typedef __key_t key_t;
# 133 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/time.h" 1 3 4
# 58 "/usr/include/time.h" 3 4
typedef __clock_t clock_t;
# 74 "/usr/include/time.h" 3 4
typedef __time_t time_t;
# 92 "/usr/include/time.h" 3 4
typedef __clockid_t clockid_t;
# 104 "/usr/include/time.h" 3 4
typedef __timer_t timer_t;
# 134 "/usr/include/sys/types.h" 2 3 4
typedef __suseconds_t suseconds_t;
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 148 "/usr/include/sys/types.h" 2 3 4
typedef unsigned long int ulong;
typedef unsigned short int ushort;
typedef unsigned int uint;
# 195 "/usr/include/sys/types.h" 3 4
typedef int int8_t __attribute__ ((__mode__ (__QI__)));
typedef int int16_t __attribute__ ((__mode__ (__HI__)));
typedef int int32_t __attribute__ ((__mode__ (__SI__)));
typedef int int64_t __attribute__ ((__mode__ (__DI__)));
typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
typedef int register_t __attribute__ ((__mode__ (__word__)));
# 220 "/usr/include/sys/types.h" 3 4
# 1 "/usr/include/sys/select.h" 1 3 4
# 31 "/usr/include/sys/select.h" 3 4
# 1 "/usr/include/bits/select.h" 1 3 4
# 23 "/usr/include/bits/select.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 24 "/usr/include/bits/select.h" 2 3 4
# 32 "/usr/include/sys/select.h" 2 3 4
# 1 "/usr/include/bits/sigset.h" 1 3 4
# 24 "/usr/include/bits/sigset.h" 3 4
typedef int __sig_atomic_t;
typedef struct
{
unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
} __sigset_t;
# 35 "/usr/include/sys/select.h" 2 3 4
typedef __sigset_t sigset_t;
# 1 "/usr/include/time.h" 1 3 4
# 120 "/usr/include/time.h" 3 4
struct timespec
{
__time_t tv_sec;
long int tv_nsec;
};
# 45 "/usr/include/sys/select.h" 2 3 4
# 1 "/usr/include/bits/time.h" 1 3 4
# 75 "/usr/include/bits/time.h" 3 4
struct timeval
{
__time_t tv_sec;
__suseconds_t tv_usec;
};
# 47 "/usr/include/sys/select.h" 2 3 4
# 55 "/usr/include/sys/select.h" 3 4
typedef long int __fd_mask;
# 67 "/usr/include/sys/select.h" 3 4
typedef struct
{
__fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
} fd_set;
typedef __fd_mask fd_mask;
# 99 "/usr/include/sys/select.h" 3 4
extern "C" {
# 109 "/usr/include/sys/select.h" 3 4
extern int select (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
struct timeval *__restrict __timeout);
# 121 "/usr/include/sys/select.h" 3 4
extern int pselect (int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds,
fd_set *__restrict __exceptfds,
const struct timespec *__restrict __timeout,
const __sigset_t *__restrict __sigmask);
}
# 221 "/usr/include/sys/types.h" 2 3 4
# 1 "/usr/include/sys/sysmacros.h" 1 3 4
# 30 "/usr/include/sys/sysmacros.h" 3 4
__extension__
extern unsigned int gnu_dev_major (unsigned long long int __dev)
throw ();
__extension__
extern unsigned int gnu_dev_minor (unsigned long long int __dev)
throw ();
__extension__
extern unsigned long long int gnu_dev_makedev (unsigned int __major,
unsigned int __minor)
throw ();
__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int
gnu_dev_major (unsigned long long int __dev) throw ()
{
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
}
__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned int
gnu_dev_minor (unsigned long long int __dev) throw ()
{
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
}
__extension__ extern __inline __attribute__ ((__gnu_inline__)) unsigned long long int
gnu_dev_makedev (unsigned int __major, unsigned int __minor) throw ()
{
return ((__minor & 0xff) | ((__major & 0xfff) << 8)
| (((unsigned long long int) (__minor & ~0xff)) << 12)
| (((unsigned long long int) (__major & ~0xfff)) << 32));
}
# 224 "/usr/include/sys/types.h" 2 3 4
typedef __blksize_t blksize_t;
typedef __blkcnt_t blkcnt_t;
typedef __fsblkcnt_t fsblkcnt_t;
typedef __fsfilcnt_t fsfilcnt_t;
# 263 "/usr/include/sys/types.h" 3 4
typedef __blkcnt64_t blkcnt64_t;
typedef __fsblkcnt64_t fsblkcnt64_t;
typedef __fsfilcnt64_t fsfilcnt64_t;
# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4
# 23 "/usr/include/bits/pthreadtypes.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 24 "/usr/include/bits/pthreadtypes.h" 2 3 4
# 50 "/usr/include/bits/pthreadtypes.h" 3 4
typedef unsigned long int pthread_t;
typedef union
{
char __size[56];
long int __align;
} pthread_attr_t;
typedef struct __pthread_internal_list
{
struct __pthread_internal_list *__prev;
struct __pthread_internal_list *__next;
} __pthread_list_t;
# 76 "/usr/include/bits/pthreadtypes.h" 3 4
typedef union
{
struct __pthread_mutex_s
{
int __lock;
unsigned int __count;
int __owner;
unsigned int __nusers;
int __kind;
int __spins;
__pthread_list_t __list;
# 101 "/usr/include/bits/pthreadtypes.h" 3 4
} __data;
char __size[40];
long int __align;
} pthread_mutex_t;
typedef union
{
char __size[4];
int __align;
} pthread_mutexattr_t;
typedef union
{
struct
{
int __lock;
unsigned int __futex;
__extension__ unsigned long long int __total_seq;
__extension__ unsigned long long int __wakeup_seq;
__extension__ unsigned long long int __woken_seq;
void *__mutex;
unsigned int __nwaiters;
unsigned int __broadcast_seq;
} __data;
char __size[48];
__extension__ long long int __align;
} pthread_cond_t;
typedef union
{
char __size[4];
int __align;
} pthread_condattr_t;
typedef unsigned int pthread_key_t;
typedef int pthread_once_t;
typedef union
{
struct
{
int __lock;
unsigned int __nr_readers;
unsigned int __readers_wakeup;
unsigned int __writer_wakeup;
unsigned int __nr_readers_queued;
unsigned int __nr_writers_queued;
int __writer;
int __shared;
unsigned long int __pad1;
unsigned long int __pad2;
unsigned int __flags;
} __data;
# 187 "/usr/include/bits/pthreadtypes.h" 3 4
char __size[56];
long int __align;
} pthread_rwlock_t;
typedef union
{
char __size[8];
long int __align;
} pthread_rwlockattr_t;
typedef volatile int pthread_spinlock_t;
typedef union
{
char __size[32];
long int __align;
} pthread_barrier_t;
typedef union
{
char __size[4];
int __align;
} pthread_barrierattr_t;
# 272 "/usr/include/sys/types.h" 2 3 4
}
# 321 "/usr/include/stdlib.h" 2 3 4
extern long int random (void) throw ();
extern void srandom (unsigned int __seed) throw ();
extern char *initstate (unsigned int __seed, char *__statebuf,
size_t __statelen) throw () __attribute__ ((__nonnull__ (2)));
extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1)));
struct random_data
{
int32_t *fptr;
int32_t *rptr;
int32_t *state;
int rand_type;
int rand_deg;
int rand_sep;
int32_t *end_ptr;
};
extern int random_r (struct random_data *__restrict __buf,
int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
extern int srandom_r (unsigned int __seed, struct random_data *__buf)
throw () __attribute__ ((__nonnull__ (2)));
extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
size_t __statelen,
struct random_data *__restrict __buf)
throw () __attribute__ ((__nonnull__ (2, 4)));
extern int setstate_r (char *__restrict __statebuf,
struct random_data *__restrict __buf)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int rand (void) throw ();
extern void srand (unsigned int __seed) throw ();
extern int rand_r (unsigned int *__seed) throw ();
extern double drand48 (void) throw ();
extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1)));
extern long int lrand48 (void) throw ();
extern long int nrand48 (unsigned short int __xsubi[3])
throw () __attribute__ ((__nonnull__ (1)));
extern long int mrand48 (void) throw ();
extern long int jrand48 (unsigned short int __xsubi[3])
throw () __attribute__ ((__nonnull__ (1)));
extern void srand48 (long int __seedval) throw ();
extern unsigned short int *seed48 (unsigned short int __seed16v[3])
throw () __attribute__ ((__nonnull__ (1)));
extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1)));
struct drand48_data
{
unsigned short int __x[3];
unsigned short int __old_x[3];
unsigned short int __c;
unsigned short int __init;
unsigned long long int __a;
};
extern int drand48_r (struct drand48_data *__restrict __buffer,
double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
extern int erand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
extern int lrand48_r (struct drand48_data *__restrict __buffer,
long int *__restrict __result)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int nrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int mrand48_r (struct drand48_data *__restrict __buffer,
long int *__restrict __result)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int jrand48_r (unsigned short int __xsubi[3],
struct drand48_data *__restrict __buffer,
long int *__restrict __result)
throw () __attribute__ ((__nonnull__ (1, 2)));
extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
throw () __attribute__ ((__nonnull__ (2)));
extern int seed48_r (unsigned short int __seed16v[3],
struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2)));
extern int lcong48_r (unsigned short int __param[7],
struct drand48_data *__buffer)
throw () __attribute__ ((__nonnull__ (1, 2)));
# 471 "/usr/include/stdlib.h" 3 4
extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) ;
extern void *calloc (size_t __nmemb, size_t __size)
throw () __attribute__ ((__malloc__)) ;
# 485 "/usr/include/stdlib.h" 3 4
extern void *realloc (void *__ptr, size_t __size)
throw () __attribute__ ((__warn_unused_result__));
extern void free (void *__ptr) throw ();
extern void cfree (void *__ptr) throw ();
# 1 "/usr/include/alloca.h" 1 3 4
# 25 "/usr/include/alloca.h" 3 4
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 26 "/usr/include/alloca.h" 2 3 4
extern "C" {
extern void *alloca (size_t __size) throw ();
}
# 498 "/usr/include/stdlib.h" 2 3 4
extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) ;
extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
throw () __attribute__ ((__nonnull__ (1))) ;
extern void abort (void) throw () __attribute__ ((__noreturn__));
extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1)));
extern "C++" int at_quick_exit (void (*__func) (void))
throw () __asm ("at_quick_exit") __attribute__ ((__nonnull__ (1)));
# 536 "/usr/include/stdlib.h" 3 4
extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
throw () __attribute__ ((__nonnull__ (1)));
extern void exit (int __status) throw () __attribute__ ((__noreturn__));
extern void quick_exit (int __status) throw () __attribute__ ((__noreturn__));
extern void _Exit (int __status) throw () __attribute__ ((__noreturn__));
extern char *getenv (__const char *__name) throw () __attribute__ ((__nonnull__ (1))) ;
extern char *__secure_getenv (__const char *__name)
throw () __attribute__ ((__nonnull__ (1))) ;
extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1)));
extern int setenv (__const char *__name, __const char *__value, int __replace)
throw () __attribute__ ((__nonnull__ (2)));
extern int unsetenv (__const char *__name) throw () __attribute__ ((__nonnull__ (1)));
extern int clearenv (void) throw ();
# 606 "/usr/include/stdlib.h" 3 4
extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ;
# 620 "/usr/include/stdlib.h" 3 4
extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ;
# 630 "/usr/include/stdlib.h" 3 4
extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) ;
# 642 "/usr/include/stdlib.h" 3 4
extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ;
# 652 "/usr/include/stdlib.h" 3 4
extern int mkstemps64 (char *__template, int __suffixlen)
__attribute__ ((__nonnull__ (1))) ;
# 663 "/usr/include/stdlib.h" 3 4
extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) ;
# 674 "/usr/include/stdlib.h" 3 4
extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ;
# 684 "/usr/include/stdlib.h" 3 4
extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) ;
# 694 "/usr/include/stdlib.h" 3 4
extern int mkostemps (char *__template, int __suffixlen, int __flags)
__attribute__ ((__nonnull__ (1))) ;
# 706 "/usr/include/stdlib.h" 3 4
extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
__attribute__ ((__nonnull__ (1))) ;
# 717 "/usr/include/stdlib.h" 3 4
extern int system (__const char *__command) ;
extern char *canonicalize_file_name (__const char *__name)
throw () __attribute__ ((__nonnull__ (1))) ;
# 734 "/usr/include/stdlib.h" 3 4
extern char *realpath (__const char *__restrict __name,
char *__restrict __resolved) throw () ;
typedef int (*__compar_fn_t) (__const void *, __const void *);
typedef __compar_fn_t comparison_fn_t;
typedef int (*__compar_d_fn_t) (__const void *, __const void *, void *);
extern void *bsearch (__const void *__key, __const void *__base,
size_t __nmemb, size_t __size, __compar_fn_t __compar)
__attribute__ ((__nonnull__ (1, 2, 5))) ;
extern void qsort (void *__base, size_t __nmemb, size_t __size,
__compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
__compar_d_fn_t __compar, void *__arg)
__attribute__ ((__nonnull__ (1, 4)));
extern int abs (int __x) throw () __attribute__ ((__const__)) ;
extern long int labs (long int __x) throw () __attribute__ ((__const__)) ;
__extension__ extern long long int llabs (long long int __x)
throw () __attribute__ ((__const__)) ;
extern div_t div (int __numer, int __denom)
throw () __attribute__ ((__const__)) ;
extern ldiv_t ldiv (long int __numer, long int __denom)
throw () __attribute__ ((__const__)) ;
__extension__ extern lldiv_t lldiv (long long int __numer,
long long int __denom)
throw () __attribute__ ((__const__)) ;
# 808 "/usr/include/stdlib.h" 3 4
extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ;
extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) ;
extern char *gcvt (double __value, int __ndigit, char *__buf)
throw () __attribute__ ((__nonnull__ (3))) ;
extern char *qecvt (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign)
throw () __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qfcvt (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign)
throw () __attribute__ ((__nonnull__ (3, 4))) ;
extern char *qgcvt (long double __value, int __ndigit, char *__buf)
throw () __attribute__ ((__nonnull__ (3))) ;
extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign, char *__restrict __buf,
size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
int *__restrict __sign, char *__restrict __buf,
size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qecvt_r (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign,
char *__restrict __buf, size_t __len)
throw () __attribute__ ((__nonnull__ (3, 4, 5)));
extern int qfcvt_r (long double __value, int __ndigit,
int *__restrict __decpt, int *__restrict __sign,
char *__restrict __buf, size_t __len)
throw () __attribute__ ((__nonnull__ (3, 4, 5)));
extern int mblen (__const char *__s, size_t __n) throw () ;
extern int mbtowc (wchar_t *__restrict __pwc,
__const char *__restrict __s, size_t __n) throw () ;
extern int wctomb (char *__s, wchar_t __wchar) throw () ;
extern size_t mbstowcs (wchar_t *__restrict __pwcs,
__const char *__restrict __s, size_t __n) throw ();
extern size_t wcstombs (char *__restrict __s,
__const wchar_t *__restrict __pwcs, size_t __n)
throw ();
# 885 "/usr/include/stdlib.h" 3 4
extern int rpmatch (__const char *__response) throw () __attribute__ ((__nonnull__ (1))) ;
# 896 "/usr/include/stdlib.h" 3 4
extern int getsubopt (char **__restrict __optionp,
char *__const *__restrict __tokens,
char **__restrict __valuep)
throw () __attribute__ ((__nonnull__ (1, 2, 3))) ;
extern void setkey (__const char *__key) throw () __attribute__ ((__nonnull__ (1)));
extern int posix_openpt (int __oflag) ;
extern int grantpt (int __fd) throw ();
extern int unlockpt (int __fd) throw ();
extern char *ptsname (int __fd) throw () ;
extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
throw () __attribute__ ((__nonnull__ (2)));
extern int getpt (void);
extern int getloadavg (double __loadavg[], int __nelem)
throw () __attribute__ ((__nonnull__ (1)));
# 964 "/usr/include/stdlib.h" 3 4
}
# 23 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 1 "/usr/include/assert.h" 1 3 4
# 66 "/usr/include/assert.h" 3 4
extern "C" {
extern void __assert_fail (__const char *__assertion, __const char *__file,
unsigned int __line, __const char *__function)
throw () __attribute__ ((__noreturn__));
extern void __assert_perror_fail (int __errnum, __const char *__file,
unsigned int __line,
__const char *__function)
throw () __attribute__ ((__noreturn__));
extern void __assert (const char *__assertion, const char *__file, int __line)
throw () __attribute__ ((__noreturn__));
}
# 24 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 24 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 1 "/scratch/jmg3/rodinia_3.0/openmp/lud/common/common.h" 1
# 1 "/usr/include/time.h" 1 3 4
# 30 "/usr/include/time.h" 3 4
extern "C" {
# 1 "/opt/apps/software/Core/GCC/4.8.5/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include/stddef.h" 1 3 4
# 39 "/usr/include/time.h" 2 3 4
# 1 "/usr/include/bits/time.h" 1 3 4
# 43 "/usr/include/time.h" 2 3 4
# 131 "/usr/include/time.h" 3 4
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long int tm_gmtoff;
__const char *tm_zone;
};
# 161 "/usr/include/time.h" 3 4
struct itimerspec
{
struct timespec it_interval;
struct timespec it_value;
};
struct sigevent;
# 180 "/usr/include/time.h" 3 4
extern clock_t clock (void) throw ();
extern time_t time (time_t *__timer) throw ();
extern double difftime (time_t __time1, time_t __time0)
throw () __attribute__ ((__const__));
extern time_t mktime (struct tm *__tp) throw ();
extern size_t strftime (char *__restrict __s, size_t __maxsize,
__const char *__restrict __format,
__const struct tm *__restrict __tp) throw ();
extern char *strptime (__const char *__restrict __s,
__const char *__restrict __fmt, struct tm *__tp)
throw ();
extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
__const char *__restrict __format,
__const struct tm *__restrict __tp,
__locale_t __loc) throw ();
extern char *strptime_l (__const char *__restrict __s,
__const char *__restrict __fmt, struct tm *__tp,
__locale_t __loc) throw ();
extern struct tm *gmtime (__const time_t *__timer) throw ();
extern struct tm *localtime (__const time_t *__timer) throw ();
extern struct tm *gmtime_r (__const time_t *__restrict __timer,
struct tm *__restrict __tp) throw ();
extern struct tm *localtime_r (__const time_t *__restrict __timer,
struct tm *__restrict __tp) throw ();
extern char *asctime (__const struct tm *__tp) throw ();
extern char *ctime (__const time_t *__timer) throw ();
extern char *asctime_r (__const struct tm *__restrict __tp,
char *__restrict __buf) throw ();
extern char *ctime_r (__const time_t *__restrict __timer,
char *__restrict __buf) throw ();
extern char *__tzname[2];
extern int __daylight;
extern long int __timezone;
extern char *tzname[2];
extern void tzset (void) throw ();
extern int daylight;
extern long int timezone;
extern int stime (__const time_t *__when) throw ();
# 313 "/usr/include/time.h" 3 4
extern time_t timegm (struct tm *__tp) throw ();
extern time_t timelocal (struct tm *__tp) throw ();
extern int dysize (int __year) throw () __attribute__ ((__const__));
# 328 "/usr/include/time.h" 3 4
extern int nanosleep (__const struct timespec *__requested_time,
struct timespec *__remaining);
extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw ();
extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw ();
extern int clock_settime (clockid_t __clock_id, __const struct timespec *__tp)
throw ();
extern int clock_nanosleep (clockid_t __clock_id, int __flags,
__const struct timespec *__req,
struct timespec *__rem);
extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw ();
extern int timer_create (clockid_t __clock_id,
struct sigevent *__restrict __evp,
timer_t *__restrict __timerid) throw ();
extern int timer_delete (timer_t __timerid) throw ();
extern int timer_settime (timer_t __timerid, int __flags,
__const struct itimerspec *__restrict __value,
struct itimerspec *__restrict __ovalue) throw ();
extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
throw ();
extern int timer_getoverrun (timer_t __timerid) throw ();
# 390 "/usr/include/time.h" 3 4
extern int getdate_err;
# 399 "/usr/include/time.h" 3 4
extern struct tm *getdate (__const char *__string);
# 413 "/usr/include/time.h" 3 4
extern int getdate_r (__const char *__restrict __string,
struct tm *__restrict __resbufp);
}
# 5 "/scratch/jmg3/rodinia_3.0/openmp/lud/common/common.h" 2
# 1 "/usr/include/sys/time.h" 1 3 4
# 29 "/usr/include/sys/time.h" 3 4
# 1 "/usr/include/bits/time.h" 1 3 4
# 30 "/usr/include/sys/time.h" 2 3 4
# 39 "/usr/include/sys/time.h" 3 4
extern "C" {
# 57 "/usr/include/sys/time.h" 3 4
struct timezone
{
int tz_minuteswest;
int tz_dsttime;
};
typedef struct timezone *__restrict __timezone_ptr_t;
# 73 "/usr/include/sys/time.h" 3 4
extern int gettimeofday (struct timeval *__restrict __tv,
__timezone_ptr_t __tz) throw () __attribute__ ((__nonnull__ (1)));
extern int settimeofday (__const struct timeval *__tv,
__const struct timezone *__tz)
throw () __attribute__ ((__nonnull__ (1)));
extern int adjtime (__const struct timeval *__delta,
struct timeval *__olddelta) throw ();
enum __itimer_which
{
ITIMER_REAL = 0,
ITIMER_VIRTUAL = 1,
ITIMER_PROF = 2
};
struct itimerval
{
struct timeval it_interval;
struct timeval it_value;
};
typedef int __itimer_which_t;
extern int getitimer (__itimer_which_t __which,
struct itimerval *__value) throw ();
extern int setitimer (__itimer_which_t __which,
__const struct itimerval *__restrict __new,
struct itimerval *__restrict __old) throw ();
extern int utimes (__const char *__file, __const struct timeval __tvp[2])
throw () __attribute__ ((__nonnull__ (1)));
extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
throw () __attribute__ ((__nonnull__ (1)));
extern int futimes (int __fd, __const struct timeval __tvp[2]) throw ();
extern int futimesat (int __fd, __const char *__file,
__const struct timeval __tvp[2]) throw ();
# 191 "/usr/include/sys/time.h" 3 4
}
# 6 "/scratch/jmg3/rodinia_3.0/openmp/lud/common/common.h" 2
extern "C" {
# 18 "/scratch/jmg3/rodinia_3.0/openmp/lud/common/common.h"
typedef enum _FUNC_RETURN_CODE {
RET_SUCCESS,
RET_FAILURE
}func_ret_t;
typedef struct __stopwatch_t{
struct timeval begin;
struct timeval end;
}stopwatch;
void
stopwatch_start(stopwatch *sw);
void
stopwatch_stop (stopwatch *sw);
double
get_interval_by_sec(stopwatch *sw);
int
get_interval_by_usec(stopwatch *sw);
func_ret_t
create_matrix_from_file(float **mp, const char *filename, int *size_p);
func_ret_t
create_matrix_from_random(float **mp, int size);
func_ret_t
create_matrix(float **mp, int size);
void
lud_verify(float *m, float *lu, int size);
void
matrix_multiply(float *inputa, float *inputb, float *output, int size);
void
matrix_duplicate(float *src, float **dst, int matrix_dim);
void
print_matrix(float *mm, int matrix_dim);
}
# 26 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c" 2
# 26 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 27 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
static int do_verify = 0;
# 28 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 29 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
static struct option long_options[] = {
# 30 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 31 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{"input", 1, __null, 'i'},
# 32 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{"size", 1, __null, 's'},
# 33 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{"verify", 0, __null, 'v'},
# 34 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{0,0,0,0}
# 35 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
};
# 36 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 37 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
extern void
# 38 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
lud_base(float *m, int matrix_dim);
# 39 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 40 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
static enum _FUNC_RETURN_CODE (*____chimes_extern_func_create_matrix_from_file)(float **, const char *, int *) = create_matrix_from_file;static double (*____chimes_extern_func_get_interval_by_sec)(struct __stopwatch_t *) = get_interval_by_sec;static void (*____chimes_extern_func_lud_base)(float *, int) = lud_base;static void (*____chimes_extern_func_lud_verify)(float *, float *, int) = lud_verify;static void (*____chimes_extern_func_matrix_duplicate)(float *, float **, int) = matrix_duplicate;static void (*____chimes_extern_func_print_matrix)(float *, int) = print_matrix;static void (*____chimes_extern_func_stopwatch_start)(struct __stopwatch_t *) = stopwatch_start;static void (*____chimes_extern_func_stopwatch_stop)(struct __stopwatch_t *) = stopwatch_stop;
int main_quick ( int argc, char *argv[] ); int main ( int argc, char *argv[] );
int
# 41 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
main_resumable ( int argc, char *argv[] )
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{const int ____chimes_did_disable0 = new_stack((void *)(&main), "main", &____must_manage_main, 2, 0, (size_t)(0UL), (size_t)(5766999286144554384UL)) ; stopwatch sw;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
float *mm;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
float *m;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int matrix_dim;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (____must_checkpoint_main_sw_0 || ____must_checkpoint_main_mm_0 || ____must_checkpoint_main_m_0 || ____must_checkpoint_main_matrix_dim_0) { register_stack_vars(4, "main|sw|0", &____must_checkpoint_main_sw_0, "%struct.__stopwatch_t = type { %struct.timeval, %struct.timeval }", (void *)(&sw), (size_t)32, 0, 1, 0, "main|mm|0", &____must_checkpoint_main_mm_0, "float*", (void *)(&mm), (size_t)8, 1, 0, 0, "main|m|0", &____must_checkpoint_main_m_0, "float*", (void *)(&m), (size_t)8, 1, 0, 0, "main|matrix_dim|0", &____must_checkpoint_main_matrix_dim_0, "i32", (void *)(&matrix_dim), (size_t)4, 0, 0, 0); } if (____chimes_replaying) { switch(get_next_call()) { case(0): { goto call_lbl_0; } case(1): { goto call_lbl_1; } case(2): { goto call_lbl_2; } case(3): { goto call_lbl_3; } case(4): { goto call_lbl_4; } case(5): { goto call_lbl_5; } case(6): { goto call_lbl_6; } case(7): { goto call_lbl_7; } case(8): { goto call_lbl_8; } default: { chimes_error(); } } } ; ;
# 43 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
matrix_dim = (32) ;
# 44 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int opt; int option_index; option_index = (0) ;
# 45 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
func_ret_t ret; ;
# 46 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
const char *input_file; input_file = (__null) ;
# 47 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
;
# 48 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
;
# 49 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 50 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
while ((opt = getopt_long(argc, argv, "::vs:i:",
# 51 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
long_options, &option_index)) != -1 ) {
# 52 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
switch(opt){
# 53 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 'i':
# 54 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
input_file = optarg;
# 55 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 56 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 'v':
# 57 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
do_verify = 1;
# 58 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 59 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 's':
# 60 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
matrix_dim = atoi(optarg);
# 61 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Currently not supported, use -i instead\n");
# 62 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n", argv[0]);
# 63 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 64 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case '?':
# 65 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "invalid option\n");
# 66 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 67 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case ':':
# 68 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "missing argument\n");
# 69 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 70 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
default:
# 71 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n",
# 72 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
argv[0]);
# 73 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 74 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 75 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 76 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 77 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if ( (optind < argc) || (optind == 1)) {
# 78 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n", argv[0]);
# 79 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 80 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 81 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 82 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (input_file) {
# 83 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("Reading matrix from file %s\n", input_file);
# 84 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_0: ret = (____chimes_does_checkpoint_create_matrix_from_file_npm ? ( ({ calling((void*)create_matrix_from_file, 0, ____alias_loc_id_6, 0UL, 3, (size_t)(5766999286144554242UL), (size_t)(5766999286144554434UL), (size_t)(5766999286144554237UL)); (create_matrix_from_file)(&m, input_file, &matrix_dim); }) ) : (({ calling_npm("create_matrix_from_file", ____alias_loc_id_6); (*____chimes_extern_func_create_matrix_from_file)(&m, input_file, &matrix_dim); })));
# 85 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (ret != RET_SUCCESS) {
# 86 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
m = __null;
# 87 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "error create matrix from file %s\n", input_file);
# 88 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 89 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 90 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
} else {
# 91 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("No input file specified!\n");
# 92 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 93 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 94 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 95 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (do_verify){
# 96 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("Before LUD\n");
# 97 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_1: (____chimes_does_checkpoint_print_matrix_npm ? ( ({ calling((void*)print_matrix, 1, ____alias_loc_id_8, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (print_matrix)(m, matrix_dim); }) ) : (({ calling_npm("print_matrix", ____alias_loc_id_8); (*____chimes_extern_func_print_matrix)(m, matrix_dim); })));
# 98 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_2: (____chimes_does_checkpoint_matrix_duplicate_npm ? ( ({ calling((void*)matrix_duplicate, 2, ____alias_loc_id_7, 0UL, 3, (size_t)(5766999286144554350UL), (size_t)(5766999286144554243UL), (size_t)(0UL)); (matrix_duplicate)(m, &mm, matrix_dim); }) ) : (({ calling_npm("matrix_duplicate", ____alias_loc_id_7); (*____chimes_extern_func_matrix_duplicate)(m, &mm, matrix_dim); })));
# 99 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 100 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 101 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_3: (____chimes_does_checkpoint_stopwatch_start_npm ? ( ({ calling((void*)stopwatch_start, 3, ____alias_loc_id_5, 0UL, 1, (size_t)(5766999286144554244UL)); (stopwatch_start)(&sw); }) ) : (({ calling_npm("stopwatch_start", ____alias_loc_id_5); (*____chimes_extern_func_stopwatch_start)(&sw); })));
# 102 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_4: (____chimes_does_checkpoint_lud_base_npm ? ( ({ calling((void*)lud_base, 4, ____alias_loc_id_4, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (lud_base)(m, matrix_dim); }) ) : (({ calling_npm("lud_base", ____alias_loc_id_4); (*____chimes_extern_func_lud_base)(m, matrix_dim); })));
# 103 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_5: (____chimes_does_checkpoint_stopwatch_stop_npm ? ( ({ calling((void*)stopwatch_stop, 5, ____alias_loc_id_3, 0UL, 1, (size_t)(5766999286144554244UL)); (stopwatch_stop)(&sw); }) ) : (({ calling_npm("stopwatch_stop", ____alias_loc_id_3); (*____chimes_extern_func_stopwatch_stop)(&sw); })));
# 104 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
double ____chimes_unroll_var_0; call_lbl_6: ____chimes_unroll_var_0 = ((____chimes_does_checkpoint_get_interval_by_sec_npm ? ( ({ calling((void*)get_interval_by_sec, 6, ____alias_loc_id_1, 0UL, 1, (size_t)(5766999286144554244UL)); (get_interval_by_sec)(&sw); }) ) : (({ calling_npm("get_interval_by_sec", ____alias_loc_id_1); (*____chimes_extern_func_get_interval_by_sec)(&sw); })))) ; printf("Time consumed(ms): %lf\n", 1000*____chimes_unroll_var_0);
# 105 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 106 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (do_verify){
# 107 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("After LUD\n");
# 108 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_7: (____chimes_does_checkpoint_print_matrix_npm ? ( ({ calling((void*)print_matrix, 7, ____alias_loc_id_2, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (print_matrix)(m, matrix_dim); }) ) : (({ calling_npm("print_matrix", ____alias_loc_id_2); (*____chimes_extern_func_print_matrix)(m, matrix_dim); })));
# 109 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf(">>>Verify<<<<\n");
# 110 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_8: (____chimes_does_checkpoint_lud_verify_npm ? ( ({ calling((void*)lud_verify, 8, ____alias_loc_id_0, 0UL, 3, (size_t)(5766999286144554368UL), (size_t)(5766999286144554350UL), (size_t)(0UL)); (lud_verify)(mm, m, matrix_dim); }) ) : (({ calling_npm("lud_verify", ____alias_loc_id_0); (*____chimes_extern_func_lud_verify)(mm, m, matrix_dim); })));
# 111 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
({ free_helper((((unsigned char *)mm) - sizeof(void *)), 5766999286144554368UL);free((((unsigned char *)mm) - sizeof(void *))); }) ;
# 112 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 113 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 114 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
({ free_helper((((unsigned char *)m) - sizeof(void *)), 5766999286144554350UL);free((((unsigned char *)m) - sizeof(void *))); }) ;
# 115 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 116 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int ____chimes_ret_var_0; ; ____chimes_ret_var_0 = (0); rm_stack(false, 0UL, "main", &____must_manage_main, ____alias_loc_id_9, ____chimes_did_disable0, false); return ____chimes_ret_var_0; ;
# 117 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
rm_stack(false, 0UL, "main", &____must_manage_main, ____alias_loc_id_9, ____chimes_did_disable0, false); }
# 40 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int
# 41 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
main_quick ( int argc, char *argv[] )
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
{const int ____chimes_did_disable0 = new_stack((void *)(&main), "main", &____must_manage_main, 2, 0, (size_t)(0UL), (size_t)(5766999286144554384UL)) ; stopwatch sw;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
float *mm;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
float *m;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int matrix_dim;
# 42 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (____must_checkpoint_main_sw_0 || ____must_checkpoint_main_mm_0 || ____must_checkpoint_main_m_0 || ____must_checkpoint_main_matrix_dim_0) { register_stack_vars(4, "main|sw|0", &____must_checkpoint_main_sw_0, "%struct.__stopwatch_t = type { %struct.timeval, %struct.timeval }", (void *)(&sw), (size_t)32, 0, 1, 0, "main|mm|0", &____must_checkpoint_main_mm_0, "float*", (void *)(&mm), (size_t)8, 1, 0, 0, "main|m|0", &____must_checkpoint_main_m_0, "float*", (void *)(&m), (size_t)8, 1, 0, 0, "main|matrix_dim|0", &____must_checkpoint_main_matrix_dim_0, "i32", (void *)(&matrix_dim), (size_t)4, 0, 0, 0); } ; ;
# 43 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
matrix_dim = (32) ;
# 44 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int opt; int option_index; option_index = (0) ;
# 45 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
func_ret_t ret; ;
# 46 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
const char *input_file; input_file = (__null) ;
# 47 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
;
# 48 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
;
# 49 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 50 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
while ((opt = getopt_long(argc, argv, "::vs:i:",
# 51 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
long_options, &option_index)) != -1 ) {
# 52 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
switch(opt){
# 53 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 'i':
# 54 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
input_file = optarg;
# 55 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 56 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 'v':
# 57 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
do_verify = 1;
# 58 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 59 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case 's':
# 60 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
matrix_dim = atoi(optarg);
# 61 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Currently not supported, use -i instead\n");
# 62 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n", argv[0]);
# 63 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 64 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case '?':
# 65 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "invalid option\n");
# 66 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 67 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
case ':':
# 68 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "missing argument\n");
# 69 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
break;
# 70 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
default:
# 71 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n",
# 72 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
argv[0]);
# 73 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 74 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 75 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 76 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 77 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if ( (optind < argc) || (optind == 1)) {
# 78 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "Usage: %s [-v] [-s matrix_size|-i input_file]\n", argv[0]);
# 79 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 80 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 81 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 82 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (input_file) {
# 83 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("Reading matrix from file %s\n", input_file);
# 84 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_0: ret = (____chimes_does_checkpoint_create_matrix_from_file_npm ? ( ({ calling((void*)create_matrix_from_file, 0, ____alias_loc_id_6, 0UL, 3, (size_t)(5766999286144554242UL), (size_t)(5766999286144554434UL), (size_t)(5766999286144554237UL)); (create_matrix_from_file)(&m, input_file, &matrix_dim); }) ) : (({ calling_npm("create_matrix_from_file", ____alias_loc_id_6); (*____chimes_extern_func_create_matrix_from_file)(&m, input_file, &matrix_dim); })));
# 85 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (ret != RET_SUCCESS) {
# 86 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
m = __null;
# 87 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
fprintf(stderr, "error create matrix from file %s\n", input_file);
# 88 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 89 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 90 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
} else {
# 91 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("No input file specified!\n");
# 92 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
exit(1);
# 93 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 94 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 95 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (do_verify){
# 96 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("Before LUD\n");
# 97 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_1: (____chimes_does_checkpoint_print_matrix_npm ? ( ({ calling((void*)print_matrix, 1, ____alias_loc_id_8, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (print_matrix)(m, matrix_dim); }) ) : (({ calling_npm("print_matrix", ____alias_loc_id_8); (*____chimes_extern_func_print_matrix)(m, matrix_dim); })));
# 98 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_2: (____chimes_does_checkpoint_matrix_duplicate_npm ? ( ({ calling((void*)matrix_duplicate, 2, ____alias_loc_id_7, 0UL, 3, (size_t)(5766999286144554350UL), (size_t)(5766999286144554243UL), (size_t)(0UL)); (matrix_duplicate)(m, &mm, matrix_dim); }) ) : (({ calling_npm("matrix_duplicate", ____alias_loc_id_7); (*____chimes_extern_func_matrix_duplicate)(m, &mm, matrix_dim); })));
# 99 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 100 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 101 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_3: (____chimes_does_checkpoint_stopwatch_start_npm ? ( ({ calling((void*)stopwatch_start, 3, ____alias_loc_id_5, 0UL, 1, (size_t)(5766999286144554244UL)); (stopwatch_start)(&sw); }) ) : (({ calling_npm("stopwatch_start", ____alias_loc_id_5); (*____chimes_extern_func_stopwatch_start)(&sw); })));
# 102 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_4: (____chimes_does_checkpoint_lud_base_npm ? ( ({ calling((void*)lud_base, 4, ____alias_loc_id_4, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (lud_base)(m, matrix_dim); }) ) : (({ calling_npm("lud_base", ____alias_loc_id_4); (*____chimes_extern_func_lud_base)(m, matrix_dim); })));
# 103 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_5: (____chimes_does_checkpoint_stopwatch_stop_npm ? ( ({ calling((void*)stopwatch_stop, 5, ____alias_loc_id_3, 0UL, 1, (size_t)(5766999286144554244UL)); (stopwatch_stop)(&sw); }) ) : (({ calling_npm("stopwatch_stop", ____alias_loc_id_3); (*____chimes_extern_func_stopwatch_stop)(&sw); })));
# 104 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
double ____chimes_unroll_var_0; call_lbl_6: ____chimes_unroll_var_0 = ((____chimes_does_checkpoint_get_interval_by_sec_npm ? ( ({ calling((void*)get_interval_by_sec, 6, ____alias_loc_id_1, 0UL, 1, (size_t)(5766999286144554244UL)); (get_interval_by_sec)(&sw); }) ) : (({ calling_npm("get_interval_by_sec", ____alias_loc_id_1); (*____chimes_extern_func_get_interval_by_sec)(&sw); })))) ; printf("Time consumed(ms): %lf\n", 1000*____chimes_unroll_var_0);
# 105 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 106 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
if (do_verify){
# 107 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf("After LUD\n");
# 108 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_7: (____chimes_does_checkpoint_print_matrix_npm ? ( ({ calling((void*)print_matrix, 7, ____alias_loc_id_2, 0UL, 2, (size_t)(5766999286144554350UL), (size_t)(0UL)); (print_matrix)(m, matrix_dim); }) ) : (({ calling_npm("print_matrix", ____alias_loc_id_2); (*____chimes_extern_func_print_matrix)(m, matrix_dim); })));
# 109 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
printf(">>>Verify<<<<\n");
# 110 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
call_lbl_8: (____chimes_does_checkpoint_lud_verify_npm ? ( ({ calling((void*)lud_verify, 8, ____alias_loc_id_0, 0UL, 3, (size_t)(5766999286144554368UL), (size_t)(5766999286144554350UL), (size_t)(0UL)); (lud_verify)(mm, m, matrix_dim); }) ) : (({ calling_npm("lud_verify", ____alias_loc_id_0); (*____chimes_extern_func_lud_verify)(mm, m, matrix_dim); })));
# 111 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
({ free_helper((((unsigned char *)mm) - sizeof(void *)), 5766999286144554368UL);free((((unsigned char *)mm) - sizeof(void *))); }) ;
# 112 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
}
# 113 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 114 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
({ free_helper((((unsigned char *)m) - sizeof(void *)), 5766999286144554350UL);free((((unsigned char *)m) - sizeof(void *))); }) ;
# 115 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
# 116 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
int ____chimes_ret_var_0; ; ____chimes_ret_var_0 = (0); rm_stack(false, 0UL, "main", &____must_manage_main, ____alias_loc_id_9, ____chimes_did_disable0, false); return ____chimes_ret_var_0; ;
# 117 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
rm_stack(false, 0UL, "main", &____must_manage_main, ____alias_loc_id_9, ____chimes_did_disable0, false); }
int
# 41 "/scratch/jmg3/rodinia_3.0/openmp/lud/base/lud.c"
main ( int argc, char *argv[] ) { init_chimes(argc, argv); return (____chimes_replaying ? main_resumable(argc, argv) : main_quick(argc, argv)); }
static int module_init() {
init_module(5766999286144554233UL, 7, 1, 4, 10, 0, 8, 8, 0, 9, 4,
&____alias_loc_id_0, (unsigned)0, (unsigned)0, (unsigned)1, "lud_verify", (unsigned)2, (5766999286144554233UL + 117UL), (5766999286144554233UL + 135UL),
&____alias_loc_id_1, (unsigned)0, (unsigned)0, (unsigned)1, "get_interval_by_sec", (unsigned)1, (5766999286144554233UL + 11UL),
&____alias_loc_id_2, (unsigned)1, (unsigned)0, (unsigned)1, (5766999286144554233UL + 12UL), "print_matrix", (unsigned)1, (5766999286144554233UL + 117UL),
&____alias_loc_id_3, (unsigned)0, (unsigned)0, (unsigned)1, "stopwatch_stop", (unsigned)1, (5766999286144554233UL + 11UL),
&____alias_loc_id_4, (unsigned)0, (unsigned)0, (unsigned)1, "lud_base", (unsigned)1, (5766999286144554233UL + 117UL),
&____alias_loc_id_5, (unsigned)1, (unsigned)0, (unsigned)1, (5766999286144554233UL + 7UL), "stopwatch_start", (unsigned)1, (5766999286144554233UL + 11UL),
&____alias_loc_id_6, (unsigned)8, (unsigned)0, (unsigned)1, (5766999286144554233UL + 1UL), (5766999286144554233UL + 2UL), (5766999286144554233UL + 3UL), (5766999286144554233UL + 4UL), (5766999286144554233UL + 5UL), (5766999286144554233UL + 6UL), (5766999286144554233UL + 8UL), (5766999286144554233UL + 183UL), "create_matrix_from_file", (unsigned)3, (5766999286144554233UL + 4UL), (5766999286144554233UL + 9UL), (5766999286144554233UL + 201UL),
&____alias_loc_id_7, (unsigned)0, (unsigned)0, (unsigned)1, "matrix_duplicate", (unsigned)2, (5766999286144554233UL + 10UL), (5766999286144554233UL + 117UL),
&____alias_loc_id_8, (unsigned)1, (unsigned)0, (unsigned)1, (5766999286144554233UL + 7UL), "print_matrix", (unsigned)1, (5766999286144554233UL + 117UL),
&____alias_loc_id_9, (unsigned)2, (unsigned)0, (unsigned)0, (5766999286144554233UL + 12UL), (5766999286144554233UL + 13UL),
"create_matrix_from_file", (void **)&(____chimes_extern_func_create_matrix_from_file),
"get_interval_by_sec", (void **)&(____chimes_extern_func_get_interval_by_sec),
"lud_base", (void **)&(____chimes_extern_func_lud_base),
"lud_verify", (void **)&(____chimes_extern_func_lud_verify),
"matrix_duplicate", (void **)&(____chimes_extern_func_matrix_duplicate),
"print_matrix", (void **)&(____chimes_extern_func_print_matrix),
"stopwatch_start", (void **)&(____chimes_extern_func_stopwatch_start),
"stopwatch_stop", (void **)&(____chimes_extern_func_stopwatch_stop),
"create_matrix_from_file", &(____chimes_does_checkpoint_create_matrix_from_file_npm),
"get_interval_by_sec", &(____chimes_does_checkpoint_get_interval_by_sec_npm),
"lud_base", &(____chimes_does_checkpoint_lud_base_npm),
"lud_verify", &(____chimes_does_checkpoint_lud_verify_npm),
"matrix_duplicate", &(____chimes_does_checkpoint_matrix_duplicate_npm),
"print_matrix", &(____chimes_does_checkpoint_print_matrix_npm),
"stopwatch_start", &(____chimes_does_checkpoint_stopwatch_start_npm),
"stopwatch_stop", &(____chimes_does_checkpoint_stopwatch_stop_npm),
(5766999286144554233UL + 151UL), (5766999286144554233UL + 80UL),
(5766999286144554233UL + 10UL), (5766999286144554233UL + 135UL),
(5766999286144554233UL + 182UL), (5766999286144554233UL + 201UL),
(5766999286144554233UL + 3UL), (5766999286144554233UL + 151UL),
(5766999286144554233UL + 184UL), (5766999286144554233UL + 77UL),
(5766999286144554233UL + 9UL), (5766999286144554233UL + 117UL),
(5766999286144554233UL + 8UL), (5766999286144554233UL + 201UL),
"_FUNC_RETURN_CODE", 32UL, 0,
"__stopwatch_t", 256UL, 2, "%struct.timeval", (int)__builtin_offsetof (struct __stopwatch_t, begin), "%struct.timeval", (int)__builtin_offsetof (struct __stopwatch_t, end),
"option", 256UL, 4, "char*", (int)__builtin_offsetof (struct option, name), "int", (int)__builtin_offsetof (struct option, has_arg), "int*", (int)__builtin_offsetof (struct option, flag), "int", (int)__builtin_offsetof (struct option, val),
"timeval", 128UL, 2, "long int", (int)__builtin_offsetof (struct timeval, tv_sec), "long int", (int)__builtin_offsetof (struct timeval, tv_usec),
"main", "main", 0, 9, "create_matrix_from_file", "print_matrix", "matrix_duplicate", "stopwatch_start", "lud_base", "stopwatch_stop", "get_interval_by_sec", "print_matrix", "lud_verify",
"main|matrix_dim|0", 1, "main",
"main|m|0", 8, "stopwatch_stop", "stopwatch_start", "print_matrix", "matrix_duplicate", "lud_verify", "lud_base", "get_interval_by_sec", "create_matrix_from_file",
"main|mm|0", 1, "main",
"main|sw|0", 1, "main",
"create_matrix_from_file", 0UL, (int)3, 5766999286144554242UL, 5766999286144554434UL, 5766999286144554237UL,
"print_matrix", 0UL, (int)2, 5766999286144554350UL, 0UL,
"matrix_duplicate", 0UL, (int)3, 5766999286144554350UL, 5766999286144554243UL, 0UL,
"stopwatch_start", 0UL, (int)1, 5766999286144554244UL,
"lud_base", 0UL, (int)2, 5766999286144554350UL, 0UL,
"stopwatch_stop", 0UL, (int)1, 5766999286144554244UL,
"get_interval_by_sec", 0UL, (int)1, 5766999286144554244UL,
"print_matrix", 0UL, (int)2, 5766999286144554350UL, 0UL,
"lud_verify", 0UL, (int)3, 5766999286144554368UL, 5766999286144554350UL, 0UL);
register_global_var("global|do_verify", "i32", (void *)(&do_verify), 4, 0, 0, 0UL, 0);
register_global_var("global|long_options", "<{ { i8*, i32, i32*, i32, [4 x i8] }, { i8*, i32, i32*, i32, [4 x i8] }, { i8*, i32, i32*, i32, [4 x i8] }, { i8*, i32, i32*, i32, [4 x i8] } }>", (void *)(&long_options), 128, 0, 1, 0UL, 0);
return 0;
}
static const int __libchimes_module_init = module_init();
| [
"jmaxg3@gmail.com"
] | jmaxg3@gmail.com |
7322cd3e2e496dddc9dc155f59202508e8b078fe | e2874bd5d016d5d1349b7911b60f08bf986bd17a | /compiler/CodeGenerator.h | 9d250159c8cf4a72498defb3660b36a96bfdbcbb | [] | no_license | qq464418017/bintalk | c4835dc9a125e192925b3e76f7d944b2e810bfd3 | 97905f8a9e8bf3954db8c7366e215edb0933c003 | refs/heads/main | 2023-03-30T09:52:50.945372 | 2023-03-29T01:55:08 | 2023-03-29T01:55:08 | 620,594,009 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 517 | h | #ifndef __Generator_h__
#define __Generator_h__
#include <string>
class CodeGenerator
{
public:
CodeGenerator(const std::string& name);
virtual void generate()=0;
private:
std::string name_;
CodeGenerator* next_;
public:
static const char* desc();
static bool exec();
private:
static CodeGenerator* root_;
};
#define DECLARE_CG(CLASS, NAME) \
class CLASS : public CodeGenerator\
{public:\
CLASS():CodeGenerator(#NAME){}\
virtual void generate();\
};\
CLASS __##NAME##__;
#endif // __Generator_h__
| [
"noreply@github.com"
] | qq464418017.noreply@github.com |
a84f0e9966581270563a0cea82be8c419f38d435 | 23c6e6f35680bee885ee071ee123870c3dbc1e3d | /test/libcxx/algorithms/equal_range_comp.pass.cpp | 5061b76a62b111942cd827c898fbb4c83328c586 | [] | no_license | paradise-fi/divine | 3a354c00f39ad5788e08eb0e33aff9d2f5919369 | d47985e0b5175a7b4ee506fb05198c4dd9eeb7ce | refs/heads/master | 2021-07-09T08:23:44.201902 | 2021-03-21T14:24:02 | 2021-03-21T14:24:02 | 95,647,518 | 15 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 2,669 | cpp | /* TAGS: c++ fin */
/* CC_OPTS: -std=c++2a */
/* VERIFY_OPTS: -o nofail:malloc */
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <algorithm>
// template<ForwardIterator Iter, class T, CopyConstructible Compare>
// constexpr pair<Iter, Iter> // constexpr after c++17
// equal_range(Iter first, Iter last, const T& value, Compare comp);
#include <algorithm>
#include <functional>
#include <vector>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
#include "test_iterators.h"
#if TEST_STD_VER > 17
TEST_CONSTEXPR bool lt(int a, int b) { return a < b; }
TEST_CONSTEXPR bool test_constexpr() {
int ia[] = {1, 3, 3, 6, 7};
return (std::equal_range(std::begin(ia), std::end(ia), 1, lt) == std::pair<int *, int *>(ia+0, ia+1))
&& (std::equal_range(std::begin(ia), std::end(ia), 3, lt) == std::pair<int *, int *>(ia+1, ia+3))
&& (std::equal_range(std::begin(ia), std::end(ia), 9, lt) == std::pair<int *, int *>(std::end(ia), std::end(ia)))
;
}
#endif
template <class Iter, class T>
void
test(Iter first, Iter last, const T& value)
{
std::pair<Iter, Iter> i = std::equal_range(first, last, value, std::greater<int>());
for (Iter j = first; j != i.first; ++j)
assert(std::greater<int>()(*j, value));
for (Iter j = i.first; j != last; ++j)
assert(!std::greater<int>()(*j, value));
for (Iter j = first; j != i.second; ++j)
assert(!std::greater<int>()(value, *j));
for (Iter j = i.second; j != last; ++j)
assert(std::greater<int>()(value, *j));
}
template <class Iter>
void
test()
{
const unsigned N = 1000;
const int M = 10;
std::vector<int> v(N);
int x = 0;
for (std::size_t i = 0; i < v.size(); ++i)
{
v[i] = x;
if (++x == M)
x = 0;
}
std::sort(v.begin(), v.end(), std::greater<int>());
for (x = 0; x <= M; ++x)
test(Iter(v.data()), Iter(v.data()+v.size()), x);
}
int main(int, char**)
{
int d[] = {3, 2, 1, 0};
for (int* e = d; e <= d+4; ++e)
for (int x = -1; x <= 4; ++x)
test(d, e, x);
test<forward_iterator<const int*> >();
test<bidirectional_iterator<const int*> >();
test<random_access_iterator<const int*> >();
test<const int*>();
#if TEST_STD_VER > 17
static_assert(test_constexpr());
#endif
return 0;
}
| [
"xkorenc1@fi.muni.cz"
] | xkorenc1@fi.muni.cz |
b95c3f45109335d2fd290f0cb1753614dad0560f | 4a740172acf796966560b8b9be8048b90266b861 | /hosts/android-studio/MoaiTemplate/lib/armeabi-v7a/include/moai-sim/MOAICompassSensor.h | 472f997f7dd61a28c1da52e7fe9ba43d93a50f6e | [] | no_license | RazielSun/SampleMoaiProject | 407a5d0435c92053ebb1c112e5b700433fb83995 | 32d42881965d963e1760bdc669f13ecc147b951b | refs/heads/master | 2020-05-18T15:41:37.866163 | 2015-03-18T07:48:17 | 2015-03-18T07:48:17 | 30,076,041 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,111 | h | // Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com
#ifndef MOAICOMPASSSENSOR_H
#define MOAICOMPASSSENSOR_H
#include <moai-sim/MOAISensor.h>
//================================================================//
// MOAICompassSensor
//================================================================//
/** @lua MOAICompassSensor
@text Device heading sensor.
*/
class MOAICompassSensor :
public MOAISensor {
private:
float mHeading;
MOAILuaStrongRef mCallback;
//----------------------------------------------------------------//
static int _getHeading ( lua_State* L );
static int _setCallback ( lua_State* L );
public:
DECL_LUA_FACTORY ( MOAICompassSensor )
//----------------------------------------------------------------//
static void EnqueueCompassEvent ( MOAIInputQueue& queue, u8 deviceID, u8 sensorID, float heading );
MOAICompassSensor ();
~MOAICompassSensor ();
void ParseEvent ( ZLStream& eventStream );
void RegisterLuaClass ( MOAILuaState& state );
void RegisterLuaFuncs ( MOAILuaState& state );
};
#endif
| [
"razielsun@gmail.com"
] | razielsun@gmail.com |
659c105b741628e0f0d27dc5097a25cab2a43d9f | 0d51ea8f9a9c372f38320081f33b4a869b8d1dd6 | /OOPS-1/Student.cpp | 0f122a9a88bf48a29c8ab98fe7f419f4a09a5b4f | [] | no_license | blackenwhite/Interview-Preparation-Coding-Ninjas | ffb81e52c939e19c7f771418bd523b4e8c73e146 | 177645870655616fc1c70ed4077e4c8ade0b1774 | refs/heads/master | 2023-02-05T09:08:20.405159 | 2020-12-19T18:23:24 | 2020-12-19T18:23:24 | 255,102,269 | 8 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 693 | cpp | class Student {
public :
int rollNumber;
private :
int age;
public :
// Default constructor
/*Student() {
cout << "Constreuctor called ! "<< endl;
}*/
// Parameterized constructor
Student(int rollNumber) {
cout << "Constructor 2 called !" << endl;
this -> rollNumber = rollNumber;
}
Student(int a, int r) {
cout << "this : " << this << endl;
cout << "Constructor 3 called ! " << endl;
this -> age = a;
this -> rollNumber = r;
}
void display() {
cout << age << " " << rollNumber << endl;
}
int getAge() {
return age;
}
void setAge(int a, int password) {
if(password != 123) {
return;
}
if(a < 0) {
return;
}
age = a;
}
};
| [
"noreply@github.com"
] | blackenwhite.noreply@github.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.