blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 2
247
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
57
| license_type
stringclasses 2
values | repo_name
stringlengths 4
111
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
58
| visit_date
timestamp[ns]date 2015-07-25 18:16:41
2023-09-06 10:45:08
| revision_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| committer_date
timestamp[ns]date 1970-01-14 14:03:36
2023-09-06 06:22:19
| github_id
int64 3.89k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 25
values | gha_event_created_at
timestamp[ns]date 2012-06-07 00:51:45
2023-09-14 21:58:52
⌀ | gha_created_at
timestamp[ns]date 2008-03-27 23:40:48
2023-08-24 19:49:39
⌀ | gha_language
stringclasses 159
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
10.5M
| extension
stringclasses 111
values | filename
stringlengths 1
195
| text
stringlengths 7
10.5M
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c2473c413216fb54d436c4514e6abd41aea7665a
|
ce4617ba2b0a6433cd06dc3a492ce6ff1add5111
|
/window.cpp
|
9e66da2e451e5faef9b020bd89651590a97c2742
|
[] |
no_license
|
Jovwu/inven_manage_sys
|
77f0615f054067279bfbc7aa5e7f12dcc66ca015
|
6c400e77068c6f6ce55bc0199cf4e3c189d058c6
|
refs/heads/main
| 2023-08-04T11:56:19.489165
| 2021-09-13T00:44:50
| 2021-09-13T00:44:50
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 12,151
|
cpp
|
window.cpp
|
#include "widget.h"
#include "window.h"
Window::Window(const string Title,int PositionX, int PositionY, int Width, int Height, const string Type)
{
this->PositionX = PositionX;
this->PositionY = PositionY;
this->Width = Width;
this->Height = Height;
this->Title.assign(Title);
this->Type.assign(Type);
this->VanishFlag = 0;
}
int Window::Exit()
{
return 0;
}
int Window::Add(Widget* widget)
{
widget->SetPOSITION_X(widget->GetPOSITION_X()+this->PositionX);
widget->SetPOSITION_Y(widget->GetPOSITION_Y() + this->PositionY);
this->WidgetVec.push_back(widget);
return 0;
}
int Window::Load()
{
if (this->Type == "BASE")
{
/*先清空窗口*/
system("cls");
/*加载窗口*/
/*先画最上面的线*/
GoToXY(this->PositionX, this->PositionY);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画两边*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX, this->PositionY + 1 + Loop);
cout << "*";
}
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX + this->Width - 2, this->PositionY + 1 + Loop);
cout << "*";
}
/*画底边*/
GoToXY(this->PositionX, this->PositionY + this->Height);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画提示栏*/
GoToXY(this->PositionX, this->PositionY + this->Height - 2);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画标题栏*/
GoToXY(this->PositionX, this->PositionY + 4);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*标题栏分割*/
for (int Loop = 0; Loop < 4; Loop++)
{
GoToXY(this->PositionX + this->Width * 2 / 3, this->PositionY + 1 + Loop);
cout << "*";
}
/*画标题*/
int TitleSize = this->Title.size();
GoToXY(this->PositionX + this->Width * 2 / 3 / 2 - TitleSize / 2, this->PositionY + 2);
cout << this->Title;
/*显示登录信息*/
/*登陆角色*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 1);
cout << "用户名:" << USER_NAME;
/*角色类别*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 2);
cout << "用户类型:" << USER_TYPE;
/*登陆时间*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 3);
cout << "登录时间:" << DateToStringBySprit();
/*加载控件*/
vector<Widget*>::iterator It = this->WidgetVec.begin();
while (It != this->WidgetVec.end())
{
(*It)->Load();
It++;
}
return 0;
}
else if (this->Type == "MSGBOX")
{
/*先清空窗口*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
ClearArea(this->PositionX, this->PositionY + Loop, this->Width);
}
/*加载窗口*/
/*先画最上面的线*/
GoToXY(this->PositionX, this->PositionY);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画两边*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX, this->PositionY + 1 + Loop);
cout << "+";
}
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX + this->Width - 2, this->PositionY + 1 + Loop);
cout << "+";
}
/*画底边*/
GoToXY(this->PositionX, this->PositionY + this->Height);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画标题栏*/
GoToXY(this->PositionX, this->PositionY + 2);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画标题*/
int TitleSize = this->Title.size();
GoToXY(this->PositionX + this->Width / 2 - TitleSize / 2, this->PositionY + 1);
cout << this->Title;
/*加载控件*/
vector<Widget*>::iterator It = this->WidgetVec.begin();
while (It != this->WidgetVec.end())
{
(*It)->Load();
It++;
}
return 0;
}
return 0;
}
int Window::Run()
{
HideCursor(0);
if (this->Type == "BASE")
{
/*栈为空*/
if (Windows.empty())
{
/*将当前页面入栈*/
this->Init();
Windows.push(this);
this->Load();
}
/*如果该界面还未加载*/
else if (Windows.top() != this)
{
/*清除上个界面的消息框和提示框在内存的残留*/
while (!Windows.top()->MsgBoxSt.empty())
{
delete Windows.top()->MsgBoxSt.top();
Windows.top()->MsgBoxSt.pop();
}
/*将当前页面入栈*/
this->Init();
Windows.push(this);
this->Load();
}
/*如果该界面已存在*/
else if (Windows.top() == this)
{
this->Refresh();
}
}
else if (this->Type == "MSGBOX")
{
/*栈为空或者栈顶不等于当前消息框*/
if (Windows.top()->MsgBoxSt.empty() || Windows.top()->MsgBoxSt.top() != this)
{
/*将消息框入栈*/
this->Init();
Windows.top()->MsgBoxSt.push(this);
this->Load();
/*如果是提示框*/
if (this->VanishFlag)
{
Sleep(HINT_BOX_SLEEP_TIME);
return WIN_REFRESH;
}
}
else if(Windows.top()->MsgBoxSt.top() == this)
{
this->Refresh();
}
}
/*清除指定类型控件*/
vector<Widget*> WidgetRes;
vector<Widget*>::iterator It = this->WidgetVec.begin();
/*控件直接跳转控件*/
vector<int> JumpRes;
int JumpCount = 0;
while (It != this->WidgetVec.end())
{
if ((*It)->GetType() != "Label" && (*It)->GetType() != "Border")
{
JumpCount++;
if ((*It)->GetType() == "Button")
{
JumpRes.push_back(JumpCount);
}
WidgetRes.push_back(*It);
}
It++;
}
/*控件循环*/
It = WidgetRes.begin();
int State = NULL_KEY;
while (State != ESC_KEY)
{
this->ShowHint((*It)->GetHint());
State = (*It)->GetCursor();
/*用于直接选择控件*/
if (State >48 && State <= 57)
{
/*没有对应控件*/
if (State - 48 > JumpRes.size())
{
continue;
}
/*跳转到控件*/
It = WidgetRes.begin() + JumpRes.at(State - 48 - 1) - 1;
continue;
}
if (State == RIGHT_KEY)
{
/*往下判断是否在同一Y轴上*/
vector<Widget*>::iterator TmpIt = It;
/*如果是最后一个*/
if (It == WidgetRes.end()-1)
{
continue;
}
It++;
int Flag = 0;
while (It != WidgetRes.end())
{
/*如果找到*/
if ((*It)->GetPOSITION_Y() == (*TmpIt)->GetPOSITION_Y())
{
Flag = 1;
break;
}
It++;
}
if (Flag == 1)
{
continue;
}
It = TmpIt;
}
else if (State == LEFT_KEY)
{
/*往上判断是否在同一Y轴上*/
vector<Widget*>::iterator TmpIt = It;
/*如果是第一个控件*/
if (It == WidgetRes.begin())
{
continue;
}
int Flag = 0;
int BeginFlag = 0;
while (BeginFlag != 1)
{
It--;
if (It == WidgetRes.begin())
{
BeginFlag = 1;
}
/*如果找到*/
if ((*It)->GetPOSITION_Y() == (*TmpIt)->GetPOSITION_Y())
{
Flag = 1;
break;
}
}
if (Flag == 1)
{
continue;
}
It = TmpIt;
}
else if (State == UP_KEY)//如果用户往上移动控件
{
if (It == WidgetRes.begin()) //如果控件到了第一个
{
It == WidgetRes.end() - 1;
}
else
{
It--;
}
}
else if (State == DOWN_KEY|| State == TAB_KEY)
{
if (It == WidgetRes.end()-1) //如果控件到了最后一个
{
It == WidgetRes.begin();
}
else
{
It++;
}
}
else if (State == ENTER_KEY)
{
/*Res在0~9之间 为系统标志位*/
/*Res在10~20之间 为用户标志位*/
/*Res在48~57之间 为控件标志位*/
/*Res在5000以上 为窗口标志位*/
int Res = this->Event(*It);
if (Res>WIN_FLAG)//跳转窗口
{
return Res;
}
else if (Res == WIN_REFRESH)
{
this->Refresh();
}
else if (Res == WIN_NO_OPS)
{
/*继续操作*/
continue;
}
else if (Res == WIN_EXIT)
{
/*用来跳出父窗口*/
return WIN_EXIT;
}
/*可在多个派生窗口传递*/
else if (Res>= 10 && Res <=20)
{
return Res;
}
/*焦点重置到指定位置*/
else if(Res > 48 && Res <= 57)
{
/*没有对应控件*/
if (Res - 48 > WidgetRes.size())
{
this->Refresh();
continue;
}
It = WidgetRes.begin() + (Res - 48 - 1);
this->Refresh();
}
//事件:1.弹出消息框,2。选择功能->跳转到页面,3。刷新页面
}
else if (State == ESC_KEY)
{
if (this->Type == "MSGBOX")
{
/* this->Clear();*/
return WIN_REFRESH;
}
/*先走界面的Exit方法*/
int Res = this->Exit();
if (Res == WIN_NO_OPS)
{
/*确定退出*/
State = ESC_KEY;
}
else
{
/*重返页面并刷新页面*/
this->Refresh();
State = NULL_KEY;
}
}
else if (State == NULL_KEY)
{
continue;
}
}
return State;
}
int Window::Refresh()
{
if (this->Type == "BASE")
{
/*先清空窗口*/
system("cls");
/*加载窗口*/
/*先画最上面的线*/
GoToXY(this->PositionX, this->PositionY);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画两边*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX, this->PositionY + 1 + Loop);
cout << "*";
}
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX + this->Width - 2, this->PositionY + 1 + Loop);
cout << "*";
}
/*画底边*/
GoToXY(this->PositionX, this->PositionY + this->Height);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画提示栏*/
GoToXY(this->PositionX, this->PositionY + this->Height - 2);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*画标题栏*/
GoToXY(this->PositionX, this->PositionY + 4);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "* ";
}
/*标题栏分割*/
for (int Loop = 0; Loop < 4; Loop++)
{
GoToXY(this->PositionX + this->Width * 2 / 3, this->PositionY + 1 + Loop);
cout << "*";
}
/*画标题*/
int TitleSize = this->Title.size();
GoToXY(this->PositionX + this->Width * 2 / 3 / 2 - TitleSize / 2, this->PositionY + 2);
cout << this->Title;
/*显示登录信息*/
/*登陆角色*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 1);
cout << "用户名:" << USER_NAME;
/*角色类别*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 2);
cout << "用户类型:" << USER_TYPE;
/*登陆时间*/
GoToXY(this->PositionX + this->Width * 2 / 3 + 3, this->PositionY + 3);
cout << "登录时间:" << DateToStringBySprit();
/*加载控件*/
vector<Widget*>::iterator It = this->WidgetVec.begin();
while (It != this->WidgetVec.end())
{
(*It)->Refresh();
It++;
}
return 0;
}
else if (this->Type == "MSGBOX")
{
/*先清空窗口*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
ClearArea(this->PositionX, this->PositionY + Loop, this->Width);
}
/*加载窗口*/
/*先画最上面的线*/
GoToXY(this->PositionX, this->PositionY);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画两边*/
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX, this->PositionY + 1 + Loop);
cout << "+";
}
for (int Loop = 0; Loop < this->Height; Loop++)
{
GoToXY(this->PositionX + this->Width - 2, this->PositionY + 1 + Loop);
cout << "+";
}
/*画底边*/
GoToXY(this->PositionX, this->PositionY + this->Height);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画标题栏*/
GoToXY(this->PositionX, this->PositionY + 2);
for (int Loop = 0; Loop < this->Width; Loop += 2)
{
cout << "+ ";
}
/*画标题*/
int TitleSize = this->Title.size();
GoToXY(this->PositionX + this->Width / 2 - TitleSize / 2, this->PositionY + 1);
cout << this->Title;
/*加载控件*/
vector<Widget*>::iterator It = this->WidgetVec.begin();
while (It != this->WidgetVec.end())
{
(*It)->Refresh();
It++;
}
return 0;
}
return 0;
}
int Window::ShowHint(const string Hint)
{
if(this->Type == "BASE")
{
HideCursor(0);
ClearArea(this->PositionX + 2, this->PositionY + this->Height - 1, this->Width - 4);
GoToXY(this->PositionX + 2, this->PositionY + this->Height - 1);
cout << Hint;
return 0;
}
else if (this->Type == "MSGBOX")
{
return 0;
}
}
|
0e649e8634806faf34fc71af190746747188657e
|
913a56012739e40a17bb5309b40d5ef6971e28d5
|
/Source/Runtime/Private/Image/ImageCommand.cpp
|
41ec73a2726f6ef458f5b57bf25004a35ecec679
|
[
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
davchezt/BlueshiftEngine
|
4265b0bf4ef7a2dbd0d726977f0bae333d1025bb
|
fbc374cbc391e1147c744649f405a66a27c35d89
|
refs/heads/master
| 2020-12-05T22:42:44.353929
| 2020-11-28T22:37:08
| 2020-11-28T22:37:08
| 232,265,027
| 2
| 0
|
Apache-2.0
| 2020-11-29T01:38:17
| 2020-01-07T07:10:48
| null |
UTF-8
|
C++
| false
| false
| 8,469
|
cpp
|
ImageCommand.cpp
|
#include "Precompiled.h"
#pragma hdrstop
B_NAMESPACE_BEGIN
// image command function type
enum icFuncType_t {
FUNC_HEIGHTMAP, // heightmap ( image, bumpiness )
FUNC_ADDNORMALS, // addnormals ( image, image )
FUNC_GRAYSCALE // grayscale ( image )
};
// image command argument type
enum icArgumentType_t {
ARGUMENT_IMAGEFILE,
ARGUMENT_NUMBER
};
// image command parse state
enum icParseState_t {
PARSE_STATE_EMPTY = BIT(0),
PARSE_STATE_FUNC = BIT(1),
PARSE_STATE_LPAREN = BIT(2),
PARSE_STATE_RPAREN = BIT(3),
PARSE_STATE_PATH = BIT(4),
PARSE_STATE_NUMBER = BIT(5),
PARSE_STATE_COMMA = BIT(6)
};
// image command function
struct icFunc_t {
icFuncType_t type;
char * name;
int numArgs;
};
// image command argument
struct icArgument_t {
icArgumentType_t type;
Image image;
float number;
};
static const icFunc_t g_icFuncs[] = {
{ FUNC_HEIGHTMAP, "heightmap", 2 },
{ FUNC_ADDNORMALS, "addnormals", 2 },
{ FUNC_GRAYSCALE, "grayscale", 1 }
};
static icFunc_t g_funcStack[16];
static int g_funcStackPointer;
static icArgument_t g_argumentStack[16];
static int g_argumentStackPointer;
static const icFunc_t *Image_FindImageCommandFunc(const char *name) {
for (int i = 0; i < COUNT_OF(g_icFuncs); i++) {
if (!Str::Icmp(g_icFuncs[i].name, name)) {
return &g_icFuncs[i];
}
}
return NULL;
}
static bool Image_ExecuteImageCommandFunc() {
icFunc_t * func;
icArgument_t dest;
icArgument_t * args[16];
byte * src0;
byte * src1;
byte * tmp;
int i;
assert(g_funcStackPointer > -1);
func = &g_funcStack[g_funcStackPointer--];
assert(g_argumentStackPointer >= func->numArgs - 1);
for (i = func->numArgs - 1; i >= 0; i--) {
args[i] = &g_argumentStack[g_argumentStackPointer--];
}
switch (func->type) {
case FUNC_HEIGHTMAP:
if (args[0]->type != ARGUMENT_IMAGEFILE || args[1]->type != ARGUMENT_NUMBER) {
return false;
}
if (args[0]->image.GetFormat() != IMAGE_FORMAT_RGBA_8_8_8_8) {
args[0]->image.ConvertFormatSelf(IMAGE_FORMAT_RGBA_8_8_8_8);
}
Image *normapMap = args[0]->image.MakeNormalMapRGBA8888(args[1]->number);
dest.type = ARGUMENT_IMAGEFILE;
dest.image = normalMap;
break;
case FUNC_ADDNORMALS:
if (args[0]->type != ARGUMENT_IMAGEFILE || args[1]->type != ARGUMENT_IMAGEFILE) {
return false;
}
if (args[0]->width != args[1]->width || args[0]->height != args[1]->height) {
int maxwidth = Max(args[0]->width, args[1]->width);
int maxheight = Max(args[0]->height, args[1]->height);
if (args[0]->width < maxwidth || args[0]->height < maxheight) {
tmp = (byte *)Mem_Alloc16(Image_MemRequired(maxwidth, maxheight, args[0]->format, false));
Image_Scale(args[0]->pic, args[0]->width, args[0]->height, tmp, maxwidth, maxheight, args[0]->format, IMAGE_BICUBIC);
Mem_AlignedFree(args[0]->pic);
args[0]->pic = tmp;
}
if (args[1]->width < maxwidth || args[1]->height < maxheight) {
tmp = (byte *)Mem_Alloc16(Image_MemRequired(maxwidth, maxheight, args[1]->format, false));
Image_Scale(args[1]->pic, args[1]->width, args[1]->height, tmp, maxwidth, maxheight, args[1]->format, IMAGE_BICUBIC);
Mem_AlignedFree(args[1]->pic);
args[1]->pic = tmp;
}
}
if (args[0]->format != IMAGE_FORMAT_RGBA_8_8_8_8) {
src0 = (byte *)Mem_Alloc16(args[0]->width * args[0]->height * 4);
Image_ConvertFormat(args[0]->pic, args[0]->format, src0, IMAGE_FORMAT_RGBA_8_8_8_8, args[0]->width, args[0]->height);
Mem_AlignedFree(args[0]->pic);
} else {
src0 = args[0]->pic;
}
if (args[1]->format != IMAGE_FORMAT_RGBA_8_8_8_8) {
src1 = (byte *)Mem_Alloc16(args[1]->width * args[1]->height * 4);
Image_ConvertFormat(args[1]->pic, args[1]->format, src1, IMAGE_FORMAT_RGBA_8_8_8_8, args[1]->width, args[1]->height);
Mem_AlignedFree(args[1]->pic);
} else {
src1 = args[1]->pic;
}
Image_AddNormalMapsRGBA8888(src0, src1, args[0]->width, args[0]->height, &tmp);
Mem_AlignedFree(src0);
Mem_AlignedFree(src1);
dest.type = ARGUMENT_IMAGEFILE;
dest.width = args[0]->width;
dest.height = args[0]->height;
dest.format = IMAGE_FORMAT_RGBA_8_8_8_8;
dest.pic = tmp;
break;
case FUNC_GRAYSCALE:
break;
default:
return false;
}
assert(g_argumentStackPointer + 1 < COUNT_OF(g_argumentStack));
g_argumentStack[++g_argumentStackPointer] = dest;
return true;
}
void Image::CommandLoad(const char *command) {
int tokenType;
int puncType;
icParseState_t lastParseState;
const icFunc_t * func;
icArgument_t arg;
Str path;
int i;
*pic = NULL;
Lexer lexer;
lexer.Init(LEXFL_NOERRORS);
lexer.Load(command, Str::Length(command), command);
Str token;
if (!lexer.ReadToken(&token, false)) {
return;
}
if (!Image_FindImageCommandFunc(token.c_str())) {
return;
}
g_funcStackPointer = -1;
g_argumentStackPointer = -1;
lastParseState = PARSE_STATE_EMPTY;
do {
if (token.IsEmpty()) {
goto END_OF_FUNCTION;
}
tokenType = lexer.GetTokenType();
if (tokenType & TT_PUNCTUATION) {
puncType = lexer.GetPunctuationType();
switch (puncType) {
case P_PARENTHESESOPEN:
if (!(lastParseState & PARSE_STATE_FUNC)) {
goto SYNTAX_ERROR;
}
lastParseState = PARSE_STATE_LPAREN;
break;
case P_PARENTHESESCLOSE:
if (!(lastParseState & (PARSE_STATE_PATH | PARSE_STATE_NUMBER | PARSE_STATE_RPAREN))) {
goto SYNTAX_ERROR;
}
if (lastParseState & PARSE_STATE_PATH) {
arg.type = ARGUMENT_IMAGEFILE;
arg.image.Load(path, false);
if (arg.image.IsEmpty()) {
goto IMAGE_FILE_NOT_FOUND;
}
assert(g_argumentStackPointer + 1 < COUNT_OF(g_argumentStack));
g_argumentStack[++g_argumentStackPointer] = arg;
path.Empty();
}
Image_ExecuteImageCommandFunc();
lastParseState = PARSE_STATE_RPAREN;
break;
case P_COMMA:
if (!(lastParseState & (PARSE_STATE_PATH | PARSE_STATE_NUMBER | PARSE_STATE_RPAREN)))
goto SYNTAX_ERROR;
if (lastParseState & PARSE_STATE_PATH) {
arg.type = ARGUMENT_IMAGEFILE;
arg.image.Load(path, false);
if (arg.image.IsEmpty()) {
goto IMAGE_FILE_NOT_FOUND;
}
assert(g_argumentStackPointer + 1 < COUNT_OF(g_argumentStack));
g_argumentStack[++g_argumentStackPointer] = arg;
path.Empty();
}
lastParseState = PARSE_STATE_COMMA;
break;
case P_REF:
case P_DIV:
case P_BACKSLASH:
if (!(lastParseState & PARSE_STATE_PATH)) {
goto SYNTAX_ERROR;
}
path += token;
lastParseState = PARSE_STATE_PATH;
break;
default:
goto SYNTAX_ERROR;
}
} else if (tokenType & TT_IDENTIFIER) {
if (!(lastParseState & (PARSE_STATE_EMPTY | PARSE_STATE_LPAREN | PARSE_STATE_COMMA | PARSE_STATE_PATH))) {
goto SYNTAX_ERROR;
}
func = Image_FindImageCommandFunc(token.c_str());
if (func) {
assert(g_funcStackPointer + 1 < COUNT_OF(g_funcStack));
g_funcStack[++g_funcStackPointer] = *func;
lastParseState = PARSE_STATE_FUNC;
} else {
path += token;
lastParseState = PARSE_STATE_PATH;
}
} else if (tokenType & TT_NUMBER) {
if (!(lastParseState & (PARSE_STATE_LPAREN | PARSE_STATE_COMMA))) {
goto SYNTAX_ERROR;
}
arg.type = ARGUMENT_NUMBER;
arg.number = atof(token.c_str());
assert(g_argumentStackPointer + 1 < COUNT_OF(g_argumentStack));
g_argumentStack[++g_argumentStackPointer] = arg;
lastParseState = PARSE_STATE_NUMBER;
}
} while (lexer.ReadToken(&token, false));
SYNTAX_ERROR:
Core::Log(LOG_WARNING, L"syntax error: '%hs'\n", token.c_str());
for (i = 0; i <= g_argumentStackPointer; i++) {
if (g_argumentStack[i].type == ARGUMENT_IMAGEFILE) {
Mem_AlignedFree(g_argumentStack[i].pic);
}
}
return;
IMAGE_FILE_NOT_FOUND:
Core::Log(LOG_WARNING, L"image file not found: '%hs'\n", path.c_str());
for (i = 0; i <= g_argumentStackPointer; i++) {
if (g_argumentStack[i].type == ARGUMENT_IMAGEFILE) {
Mem_AlignedFree(g_argumentStack[i].pic);
}
}
return;
END_OF_FUNCTION:
if (lastParseState == PARSE_STATE_RPAREN) {
if (g_argumentStackPointer == 0 && g_argumentStack[0].type == ARGUMENT_IMAGEFILE) {
*pic = g_argumentStack[0].pic;
*width = g_argumentStack[0].width;
*height = g_argumentStack[0].height;
*format = g_argumentStack[0].format;
}
}
for (i = 1; i <= g_argumentStackPointer; i++) {
if (g_argumentStack[i].type == ARGUMENT_IMAGEFILE) {
Mem_AlignedFree(g_argumentStack[i].pic);
}
}
}
B_NAMESPACE_END
|
6c890b2f4ad283260a50191a5f723f435eb4753b
|
596d7b122231a4b70c71c9ff47659b8ad91d0bb4
|
/one-time-pad.h
|
21eeca2ecea889ae20de77984769f9bc0c7feb9f
|
[] |
no_license
|
luisnaranjo733/one-time-pad
|
f8110e2278623c9eb36f05dd99c92fcad5de8bcd
|
c282c90e3ce707356b2619f72c84a878098de0a4
|
refs/heads/main
| 2023-07-22T12:24:22.505584
| 2021-08-30T21:28:43
| 2021-08-30T21:28:43
| 401,192,066
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 279
|
h
|
one-time-pad.h
|
// one-time-pad.h : Include file for standard system include files,
// or project specific include files.
#pragma once
#include <vector>
#include <array>
#include <random>
#include <iostream>
// TODO: Reference additional headers your program requires here.
|
08cccd305124d4022846da452d0225da64008299
|
86b881ba691421587c150d835631ac373f80d3d1
|
/Inheritance(Buildings)/Inheritance(Buildings)/ReverseBonus.h
|
5f69f81b8a1dfec06c6d02738b149e954a0fcf53
|
[] |
no_license
|
Marchusky/Programming-I
|
aef05134ed8330997b01359114b3e49590952349
|
626e2f0e113c087cd49ad2d05fda928403729784
|
refs/heads/master
| 2020-04-07T12:59:36.000903
| 2019-06-12T07:15:42
| 2019-06-12T07:15:42
| 158,388,918
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 76
|
h
|
ReverseBonus.h
|
#pragma once
#include <iostream>
#include <string.h>
#include "Building.h"
|
09539f4e625e00d5352446bc914725ec886f457a
|
3cb835f1ad9c1ee72f69feb59866bc7389754a3e
|
/workspace03/day3_lecture_quiz_01/Wrapper.h
|
0d00e2d938075839f9740f28a6a36a68080a04e8
|
[] |
no_license
|
PeterSommerlad/CPlusPlusCourse2018
|
7c294ee33d2bebbf89d1efab645bde0bfeb46f0d
|
b6977845fbe0e682b48f62908c6e8dac8117a977
|
refs/heads/master
| 2022-06-29T09:15:07.657649
| 2018-07-11T09:46:26
| 2018-07-11T09:47:04
| 139,454,062
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 218
|
h
|
Wrapper.h
|
#ifndef WRAPPER_H_
#define WRAPPER_H_
template <typename T>
struct Wrapper {
T wrapped{};
void set(T const & value) {
wrapped.release();
wrapped = value;
}
};
#endif /* WRAPPER_H_ */
|
966e30710b9576cadc39da100061797d151ff548
|
ff5c1d61409b0d462463adce8b9a0889f662d107
|
/src/OpenSpaceToolkit/Mathematics/Geometry/3D/Transformations/Rotations/Quaternion.cpp
|
ba7cb003e49ec881fb62069425426c91ccc5f5cc
|
[
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"MPL-2.0"
] |
permissive
|
open-space-collective/open-space-toolkit-mathematics
|
ff1eb9a1c6baae5f538c434e646e11635f4d773b
|
c441c8ceb8f9fef3c7bb1981e031a83b68960020
|
refs/heads/main
| 2023-09-01T04:59:44.874092
| 2023-08-31T18:24:41
| 2023-08-31T18:24:41
| 136,834,880
| 10
| 3
|
Apache-2.0
| 2023-09-14T10:07:47
| 2018-06-10T18:35:03
|
C++
|
UTF-8
|
C++
| false
| false
| 18,747
|
cpp
|
Quaternion.cpp
|
/// Apache License 2.0
#include <OpenSpaceToolkit/Core/Error.hpp>
#include <OpenSpaceToolkit/Core/Utilities.hpp>
#include <OpenSpaceToolkit/Mathematics/Geometry/3D/Transformations/Rotations/Quaternion.hpp>
#include <OpenSpaceToolkit/Mathematics/Geometry/3D/Transformations/Rotations/RotationMatrix.hpp>
#include <OpenSpaceToolkit/Mathematics/Geometry/3D/Transformations/Rotations/RotationVector.hpp>
namespace ostk
{
namespace math
{
namespace geom
{
namespace d3
{
namespace trf
{
namespace rot
{
Quaternion::Quaternion(
const Real& aFirstComponent,
const Real& aSecondComponent,
const Real& aThirdComponent,
const Real& aFourthComponent,
const Quaternion::Format& aFormat
)
: x_((aFormat == Quaternion::Format::XYZS) ? aFirstComponent : aSecondComponent),
y_((aFormat == Quaternion::Format::XYZS) ? aSecondComponent : aThirdComponent),
z_((aFormat == Quaternion::Format::XYZS) ? aThirdComponent : aFourthComponent),
s_((aFormat == Quaternion::Format::XYZS) ? aFourthComponent : aFirstComponent)
{
}
Quaternion::Quaternion(const Vector4d& aVector, const Quaternion::Format& aFormat)
: x_((aFormat == Quaternion::Format::XYZS) ? aVector(0) : aVector(1)),
y_((aFormat == Quaternion::Format::XYZS) ? aVector(1) : aVector(2)),
z_((aFormat == Quaternion::Format::XYZS) ? aVector(2) : aVector(3)),
s_((aFormat == Quaternion::Format::XYZS) ? aVector(3) : aVector(0))
{
}
Quaternion::Quaternion(const Vector3d& aVectorPart, const Real& aScalarPart)
: x_(aVectorPart.x()),
y_(aVectorPart.y()),
z_(aVectorPart.z()),
s_(aScalarPart)
{
}
bool Quaternion::operator==(const Quaternion& aQuaternion) const
{
if ((!this->isDefined()) || (!aQuaternion.isDefined()))
{
return false;
}
return ((x_ == +aQuaternion.x_) && (y_ == +aQuaternion.y_) && (z_ == +aQuaternion.z_) && (s_ == +aQuaternion.s_)) ||
((x_ == -aQuaternion.x_) && (y_ == -aQuaternion.y_) && (z_ == -aQuaternion.z_) && (s_ == -aQuaternion.s_));
}
bool Quaternion::operator!=(const Quaternion& aQuaternion) const
{
return !((*this) == aQuaternion);
}
Quaternion Quaternion::operator+(const Quaternion& aQuaternion) const
{
return Quaternion(
this->getVectorPart() + aQuaternion.getVectorPart(), this->getScalarPart() + aQuaternion.getScalarPart()
);
}
Quaternion Quaternion::operator*(const Quaternion& aQuaternion) const
{
return this->crossMultiply(aQuaternion);
}
Vector3d Quaternion::operator*(const Vector3d& aVector) const
{
return this->rotateVector(aVector);
}
Quaternion Quaternion::operator*(const Real& aScalar) const
{
return Quaternion(this->getVectorPart() * aScalar, this->getScalarPart() * aScalar);
}
Quaternion operator*(const Real& aScalar, const Quaternion& aQuaternion)
{
return aQuaternion * aScalar;
}
Quaternion Quaternion::operator/(const Quaternion& aQuaternion) const
{
if (aQuaternion.norm() < Real::Epsilon())
{
throw ostk::core::error::RuntimeError("Cannot divide by quaternion with zero norm.");
}
return this->crossMultiply(aQuaternion.toInverse());
}
Quaternion Quaternion::operator^(const Real& aScalar) const
{
return this->pow(aScalar);
}
Quaternion& Quaternion::operator+=(const Quaternion& aQuaternion)
{
if ((!this->isDefined()) || (!aQuaternion.isDefined()))
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
x_ += aQuaternion.x_;
y_ += aQuaternion.y_;
z_ += aQuaternion.z_;
s_ += aQuaternion.s_;
return *this;
}
Quaternion& Quaternion::operator*=(const Quaternion& aQuaternion)
{
(*this) = this->crossMultiply(aQuaternion); // [TBI] This is a shortcut... could be optimized
return *this;
}
Quaternion& Quaternion::operator/=(const Quaternion& aQuaternion)
{
if (aQuaternion.norm() < Real::Epsilon())
{
throw ostk::core::error::RuntimeError("Cannot divide by quaternion with zero norm.");
}
(*this) = this->crossMultiply(aQuaternion.toInverse()); // [TBI] This is a shortcut... could be optimized
return *this;
}
std::ostream& operator<<(std::ostream& anOutputStream, const Quaternion& aQuaternion)
{
ostk::core::utils::Print::Header(anOutputStream, "Quaternion");
ostk::core::utils::Print::Line(anOutputStream)
<< "X:" << (aQuaternion.isDefined() ? String::Format("{:15f}", aQuaternion.x_) : "Undefined");
ostk::core::utils::Print::Line(anOutputStream)
<< "Y:" << (aQuaternion.isDefined() ? String::Format("{:15f}", aQuaternion.y_) : "Undefined");
ostk::core::utils::Print::Line(anOutputStream)
<< "Z:" << (aQuaternion.isDefined() ? String::Format("{:15f}", aQuaternion.z_) : "Undefined");
ostk::core::utils::Print::Line(anOutputStream)
<< "S:" << (aQuaternion.isDefined() ? String::Format("{:15f}", aQuaternion.s_) : "Undefined");
ostk::core::utils::Print::Footer(anOutputStream);
return anOutputStream;
}
bool Quaternion::isDefined() const
{
return x_.isDefined() && y_.isDefined() && z_.isDefined() && s_.isDefined();
}
bool Quaternion::isUnitary() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return std::abs(((x_ * x_) + (y_ * y_) + (z_ * z_) + (s_ * s_)) - 1.0) <= Real::Epsilon();
}
bool Quaternion::isNear(const Quaternion& aQuaternion, const Angle& anAngularTolerance) const
{
if (!anAngularTolerance.isDefined())
{
throw ostk::core::error::runtime::Undefined("Angular tolerance");
}
return this->angularDifferenceWith(aQuaternion).inRadians(0.0, Real::TwoPi()) <=
anAngularTolerance.inRadians(0.0, Real::TwoPi());
}
Real Quaternion::x() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return x_;
}
Real Quaternion::y() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return y_;
}
Real Quaternion::z() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return z_;
}
Real Quaternion::s() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return s_;
}
Vector3d Quaternion::getVectorPart() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return {x_, y_, z_};
}
Real Quaternion::getScalarPart() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return s_;
}
Quaternion Quaternion::toNormalized() const
{
return Quaternion(*this).normalize();
}
Quaternion Quaternion::toConjugate() const
{
return Quaternion(*this).conjugate();
}
Quaternion Quaternion::toInverse() const
{
return Quaternion(*this).inverse();
}
Quaternion Quaternion::exp() const
{
// Ref.: http://www.neil.dantam.name/note/dantam-quaternion.pdf, II-F
const Vector3d v = this->getVectorPart();
const Real v_norm = v.norm();
if (v_norm <= Real::Epsilon())
{
return Quaternion::Unit();
}
return std::exp(s_) * Quaternion(v * sin(v_norm) / v_norm, cos(v_norm));
}
Quaternion Quaternion::log() const
{
// Ref.: http://www.neil.dantam.name/note/dantam-quaternion.pdf, II-G
const Vector3d v = this->getVectorPart();
const Real v_norm = v.norm();
if (v_norm <= Real::Epsilon())
{
return Quaternion({0.0, 0.0, 0.0}, std::log(this->norm()));
}
return Quaternion(std::atan2(v_norm, s_) / v_norm * v, std::log(this->norm()));
}
Quaternion Quaternion::pow(const Real& aValue) const
{
// Ref.: http://www.neil.dantam.name/note/dantam-quaternion.pdf, II-H
return ((this->log()) * aValue).exp();
}
Real Quaternion::norm() const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return ((x_ * x_) + (y_ * y_) + (z_ * z_) + (s_ * s_)).sqrt();
}
Quaternion Quaternion::crossMultiply(const Quaternion& aQuaternion) const
{
const Vector3d leftVectorPart = this->getVectorPart();
const Real& leftScalarPart = s_;
const Vector3d rightVectorPart = aQuaternion.getVectorPart();
const Real& rightScalarPart = aQuaternion.s_;
const Vector3d vectorPart =
(rightScalarPart * leftVectorPart) + (leftScalarPart * rightVectorPart) - leftVectorPart.cross(rightVectorPart);
const Real scalarPart = (leftScalarPart * rightScalarPart) - leftVectorPart.dot(rightVectorPart);
return {vectorPart, scalarPart};
}
Quaternion Quaternion::dotMultiply(const Quaternion& aQuaternion) const
{
const Vector3d leftVectorPart = this->getVectorPart();
const Real& leftScalarPart = s_;
const Vector3d rightVectorPart = aQuaternion.getVectorPart();
const Real& rightScalarPart = aQuaternion.s_;
const Vector3d vectorPart =
(rightScalarPart * leftVectorPart) + (leftScalarPart * rightVectorPart) + leftVectorPart.cross(rightVectorPart);
const Real scalarPart = (leftScalarPart * rightScalarPart) - leftVectorPart.dot(rightVectorPart);
return {vectorPart, scalarPart};
}
Real Quaternion::dotProduct(const Quaternion& aQuaternion) const
{
if ((!this->isDefined()) || (!aQuaternion.isDefined()))
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
return (x_ * aQuaternion.x_) + (y_ * aQuaternion.y_) + (z_ * aQuaternion.z_) + (s_ * aQuaternion.s_);
}
Vector3d Quaternion::rotateVector(const Vector3d& aVector) const
{
if (!aVector.isDefined())
{
throw ostk::core::error::runtime::Undefined("Vector");
}
if (!this->isUnitary())
{
throw ostk::core::error::RuntimeError("Quaternion with norm [{}] is not unitary.", this->norm());
}
return this->crossMultiply(Quaternion(aVector, 0.0)).crossMultiply(this->toConjugate()).getVectorPart();
}
Vector4d Quaternion::toVector(const Quaternion::Format& aFormat) const
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
switch (aFormat)
{
case Quaternion::Format::XYZS:
return Vector4d(x_, y_, z_, s_);
case Quaternion::Format::SXYZ:
return Vector4d(s_, x_, y_, z_);
default:
throw ostk::core::error::runtime::Wrong("Format");
break;
}
return Vector4d::Undefined();
}
String Quaternion::toString(const Quaternion::Format& aFormat) const
{
return this->toVector(aFormat).toString();
}
String Quaternion::toString(const Integer& aPrecision, const Quaternion::Format& aFormat) const
{
return aPrecision.isDefined() ? this->toVector(aFormat).toString(aPrecision) : this->toVector(aFormat).toString();
}
Quaternion& Quaternion::normalize()
{
const Real norm = this->norm();
if (norm.abs() < Real::Epsilon())
{
throw ostk::core::error::RuntimeError("Quaternion norm is zero.");
}
x_ /= norm;
y_ /= norm;
z_ /= norm;
s_ /= norm;
return *this;
}
Quaternion& Quaternion::conjugate()
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
x_ = -x_;
y_ = -y_;
z_ = -z_;
return *this;
}
Quaternion& Quaternion::inverse()
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
const Real reducedNorm = (x_ * x_) + (y_ * y_) + (z_ * z_) + (s_ * s_);
if (reducedNorm.abs() < Real::Epsilon())
{
throw ostk::core::error::RuntimeError("Quaternion norm is zero.");
}
x_ = -x_ / reducedNorm;
y_ = -y_ / reducedNorm;
z_ = -z_ / reducedNorm;
s_ = +s_ / reducedNorm;
return *this;
}
Quaternion& Quaternion::rectify()
{
if (!this->isDefined())
{
throw ostk::core::error::runtime::Undefined("Quaternion");
}
if (s_ < 0.0)
{
x_ = -x_;
y_ = -y_;
z_ = -z_;
s_ = -s_;
}
return *this;
}
Angle Quaternion::angularDifferenceWith(const Quaternion& aQuaternion) const
{
if ((!this->isUnitary()) || (!aQuaternion.isUnitary()))
{
throw ostk::core::error::RuntimeError("Quaternion is not unitary.");
}
const Quaternion deltaQuaternion = ((*this) / aQuaternion).normalize();
return Angle::Radians(2.0 * std::acos(std::abs(deltaQuaternion.s_)));
}
Quaternion Quaternion::Undefined()
{
return {Real::Undefined(), Real::Undefined(), Real::Undefined(), Real::Undefined(), Quaternion::Format::XYZS};
}
Quaternion Quaternion::Unit()
{
return {0.0, 0.0, 0.0, 1.0, Quaternion::Format::XYZS};
}
Quaternion Quaternion::XYZS(
const Real& aFirstComponent, const Real& aSecondComponent, const Real& aThirdComponent, const Real& aFourthComponent
)
{
return {aFirstComponent, aSecondComponent, aThirdComponent, aFourthComponent, Quaternion::Format::XYZS};
}
Quaternion Quaternion::RotationVector(const rot::RotationVector& aRotationVector)
{
/// @ref Markley F. L.: Fundamentals of Spacecraft Attitude Determination and Control, 45
const Real rotationAngle_rad = aRotationVector.getAngle().inRadians();
const Vector3d vectorPart = std::sin(rotationAngle_rad / 2.0) * aRotationVector.getAxis();
const Real scalarPart = std::cos(rotationAngle_rad / 2.0);
return Quaternion(vectorPart, scalarPart).normalize();
}
Quaternion Quaternion::RotationMatrix(const rot::RotationMatrix& aRotationMatrix)
{
/// @ref Markley F. L.: Fundamentals of Spacecraft Attitude Determination and Control, 48
/// @note Should we use this method instead?
/// https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2015/01/matrix-to-quat.pdf
const Real trace = aRotationMatrix.accessMatrix().trace();
const Real rotationMatrix_11 = aRotationMatrix(0, 0);
const Real rotationMatrix_12 = aRotationMatrix(0, 1);
const Real rotationMatrix_13 = aRotationMatrix(0, 2);
const Real rotationMatrix_21 = aRotationMatrix(1, 0);
const Real rotationMatrix_22 = aRotationMatrix(1, 1);
const Real rotationMatrix_23 = aRotationMatrix(1, 2);
const Real rotationMatrix_31 = aRotationMatrix(2, 0);
const Real rotationMatrix_32 = aRotationMatrix(2, 1);
const Real rotationMatrix_33 = aRotationMatrix(2, 2);
Real x = Real::Undefined();
Real y = Real::Undefined();
Real z = Real::Undefined();
Real s = Real::Undefined();
if ((trace >= rotationMatrix_11) && (trace >= rotationMatrix_22) && (trace >= rotationMatrix_33))
{
x = rotationMatrix_23 - rotationMatrix_32;
y = rotationMatrix_31 - rotationMatrix_13;
z = rotationMatrix_12 - rotationMatrix_21;
s = 1.0 + trace;
}
else if ((rotationMatrix_11 >= trace) && (rotationMatrix_11 >= rotationMatrix_22) && (rotationMatrix_11 >= rotationMatrix_33))
{
x = 1.0 + 2.0 * rotationMatrix_11 - trace;
y = rotationMatrix_12 + rotationMatrix_21;
z = rotationMatrix_13 + rotationMatrix_31;
s = rotationMatrix_23 - rotationMatrix_32;
}
else if ((rotationMatrix_22 >= rotationMatrix_11) && (rotationMatrix_22 >= trace) && (rotationMatrix_22 >= rotationMatrix_33))
{
x = rotationMatrix_21 + rotationMatrix_12;
y = 1.0 + 2.0 * rotationMatrix_22 - trace;
z = rotationMatrix_23 + rotationMatrix_32;
s = rotationMatrix_31 - rotationMatrix_13;
}
else if ((rotationMatrix_33 >= rotationMatrix_11) && (rotationMatrix_33 >= rotationMatrix_22) && (rotationMatrix_33 >= trace))
{
x = rotationMatrix_31 + rotationMatrix_13;
y = rotationMatrix_32 + rotationMatrix_23;
z = 1.0 + 2.0 * rotationMatrix_33 - trace;
s = rotationMatrix_12 - rotationMatrix_21;
}
else
{
throw ostk::core::error::RuntimeError("Rotation matrix cannot be converted into quaternion.");
}
return Quaternion::XYZS(x, y, z, s).normalize();
}
Quaternion Quaternion::Parse(const String& aString, const Quaternion::Format& aFormat)
{
using ostk::math::obj::VectorXd;
if (aString.isEmpty())
{
throw ostk::core::error::runtime::Undefined("String");
}
const VectorXd vector = VectorXd::Parse(aString);
if (vector.size() != 4)
{
throw ostk::core::error::RuntimeError("Vector size is not 4.");
}
return {vector, aFormat};
}
Quaternion Quaternion::ShortestRotation(const Vector3d& aFirstVector, const Vector3d& aSecondVector)
{
if (!aFirstVector.isDefined())
{
throw ostk::core::error::runtime::Undefined("First vector");
}
if (!aSecondVector.isDefined())
{
throw ostk::core::error::runtime::Undefined("Second vector");
}
const Vector3d firstNormalizedVector = aFirstVector.normalized();
const Vector3d secondNormalizedVector = aSecondVector.normalized();
const Vector3d orthogonalVector = secondNormalizedVector.cross(firstNormalizedVector);
const Real dotProduct = firstNormalizedVector.dot(secondNormalizedVector);
return Quaternion::XYZS(orthogonalVector.x(), orthogonalVector.y(), orthogonalVector.z(), 1.0 + dotProduct)
.toNormalized();
}
Quaternion Quaternion::LERP(const Quaternion& aFirstQuaternion, const Quaternion& aSecondQuaternion, const Real& aRatio)
{
if (!aRatio.isDefined())
{
throw ostk::core::error::runtime::Undefined("Ratio");
}
if ((aRatio < 0.0) || (aRatio > 1.0))
{
throw ostk::core::error::RuntimeError("Ratio [{}] not in [0, 1] interval.", aRatio);
}
return (aFirstQuaternion * (1.0 - aRatio) + aSecondQuaternion * aRatio);
}
Quaternion Quaternion::NLERP(
const Quaternion& aFirstQuaternion, const Quaternion& aSecondQuaternion, const Real& aRatio
)
{
return Quaternion::LERP(aFirstQuaternion, aSecondQuaternion, aRatio).toNormalized();
}
Quaternion Quaternion::SLERP(
const Quaternion& aFirstQuaternion, const Quaternion& aSecondQuaternion, const Real& aRatio
)
{
if (!aRatio.isDefined())
{
throw ostk::core::error::runtime::Undefined("Ratio");
}
if ((aRatio < 0.0) || (aRatio > 1.0))
{
throw ostk::core::error::RuntimeError("Ratio [{}] not in [0, 1] interval.", aRatio);
}
if (aFirstQuaternion.dotProduct(aSecondQuaternion) >= 0.0)
{
return (aFirstQuaternion * ((aFirstQuaternion.toInverse() * aSecondQuaternion) ^ aRatio)).toNormalized();
}
return (aFirstQuaternion * ((aFirstQuaternion.toInverse() * (-1.0) * aSecondQuaternion) ^ aRatio)).toNormalized();
}
} // namespace rot
} // namespace trf
} // namespace d3
} // namespace geom
} // namespace math
} // namespace ostk
|
2dde9a68e3bf950ec0f60ec5438ba3ef91f0fffe
|
3211ef2ce88b13ad2cbbc3c7307017e52ff2cb51
|
/Engine/SkyBox.cpp
|
0f5638ba5b6c88569fc83e89fd87a0c140634849
|
[] |
no_license
|
YucelCeyhun/KingMuOnline
|
887d84fe6bf688679f0bd45920a2b1e3eff33222
|
f0191fb4b99b6f5b04ac6c5834a6dff0014059e6
|
refs/heads/master
| 2022-04-10T19:14:51.778327
| 2020-03-26T07:53:24
| 2020-03-26T07:53:24
| 249,654,970
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 7,486
|
cpp
|
SkyBox.cpp
|
#include "StdAfx.h"
int IsSky = GetPrivateProfileInt("Engine","UseCustomSkyBox",0,ENGINE_INI);
int IsTim = GetPrivateProfileInt("Engine","UseCustomDayNight",0,ENGINE_INI);
cSkyBox gSkyBox;
cSkyBox::cSkyBox()
{
SkyDisplayInitialized = false;
}
cSkyBox::~cSkyBox()
{
/**/
}
void cSkyBox::ChangeSky()
{
SYSTEMTIME sm;
GetLocalTime(&sm);
// ----
int hourstate = sm.wHour % 2;
int secondstate = sm.wSecond;
float minutestate = (float)sm.wMinute / 60.0f;
// ----
if(hourstate == 0)
{
SkyColor.R = minutestate;
SkyColor.G = minutestate;
SkyColor.B = minutestate;
}
else
{
SkyColor.R = 1.0f - minutestate;
SkyColor.G = 1.0f - minutestate;
SkyColor.B = 1.0f - minutestate;
}
}
void cSkyBox::GetCamCoords(double* x_cam, double* y_cam, double* z_cam)
{
double m[16];
glGetDoublev(GL_MODELVIEW_MATRIX, m);
*x_cam = -m[12] * m[0] - m[13] * m[1] - m[14] * m[2];
*y_cam = -m[12] * m[4] - m[13] * m[5] - m[14] * m[6];
*z_cam = -m[12] * m[8] - m[13] * m[9] - m[14] * m[10];
}
void CALLBACK SkyTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
gSkyBox.ChangeSky();
}
void cSkyBox::InitDisplay()
{
if(IsSky)
{
sprintf_s(this->TexturePath,"%s",SKY_NULL_TEXTURE);
if(!gToolKit.FileExists(this->TexturePath))
{
MessageBox(0,"Cannot find Null.bmp","Error",MB_OK|MB_ICONERROR);
ExitProcess(0);
}
// ----
AUX_RGBImageRec* images[MAX_MAP_SKY][MAX_SKY_FACES];
AUX_RGBImageRec* blankimage = auxDIBImageLoad(this->TexturePath);
// ----
try
{
for(int i=0 ; i<MAX_MAP_SKY; i++)
{
for(int j=0; j<MAX_SKY_FACES; j++)
{
images[i][j] = blankimage;
}
sprintf_s(this->TexturePath,SKY_BACK_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][0] = auxDIBImageLoad(this->TexturePath);
sprintf_s(this->TexturePath,SKY_BOTTOM_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][1] = auxDIBImageLoad(this->TexturePath);
sprintf_s(this->TexturePath,SKY_FRONT_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][2] = auxDIBImageLoad(this->TexturePath);
sprintf_s(this->TexturePath,SKY_LEFT_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][3] = auxDIBImageLoad(this->TexturePath);
sprintf_s(this->TexturePath,SKY_RIGHT_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][4] = auxDIBImageLoad(this->TexturePath);
sprintf_s(this->TexturePath,SKY_TOP_TEXTURE,i+1);
if(gToolKit.FileExists(this->TexturePath))
images[i][5] = auxDIBImageLoad(this->TexturePath);
}
}
catch(...){}
for(int i=0 ; i<MAX_MAP_SKY; i++)
{
for(int j=0; j<MAX_SKY_FACES; j++)
{
glGenTextures(1,&this->uTextures[i][j]);
glBindTexture(GL_TEXTURE_2D,this->uTextures[i][j]);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexImage2D(GL_TEXTURE_2D,0,3,images[i][j]->sizeX,images[i][j]->sizeY,0,GL_RGB,GL_UNSIGNED_BYTE,images[i][j]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
}
}
// ----
SkyColor.R = 1.0f;
SkyColor.G = 1.0f;
SkyColor.B = 1.0f;
// ----
if(IsTim != 0)
{
SetTimer(pGameWindow,2,5000,(TIMERPROC)SkyTimerProc);
ChangeSky();
}
}
// ----
this->SkyDisplayInitialized = true;
}
bool cSkyBox::CanDrawSky()
{
sprintf_s(this->TexturePath,SKY_TOP_TEXTURE,pMapNumber+1);
// ----
if (gToolKit.FileExists(this->TexturePath))
{
return true;
}
return false;
}
bool cSkyBox::SpecialMaps()
{
if(pMapNumber == Vulcanus || pMapNumber == Raklion || pMapNumber == RaklionBoss || pMapNumber == Calmness || pMapNumber == Elbeland || pMapNumber == Karutan || pMapNumber == Market || pMapNumber == Kalimdor || pMapNumber == Arkania || pMapNumber == Acheron)
{
return true;
}
return false;
}
bool cSkyBox::EventMaps()
{
if(pMapNumber == Icarus || pMapNumber == Kalima1 || pMapNumber == Kalima2 || pMapNumber == Kalima3 || pMapNumber == Kalima4 || pMapNumber == Kalima5 || pMapNumber == Kalima6 || pMapNumber == Kalima7)
{
return true;
}
return false;
}
void cSkyBox::Display()
{
pSkyHook();
// ----
if(pPlayerState == GameProcess && gSkyBox.EventMaps() == false)
{
if(!gSkyBox.SkyDisplayInitialized)
gSkyBox.InitDisplay();
if(IsSky && gSkyBox.CanDrawSky())
{
double x_cam, y_cam, z_cam;
gSkyBox.GetCamCoords(&x_cam,&y_cam,&z_cam);
pSetBlend(1);
glColor3d(gSkyBox.SkyColor.R,gSkyBox.SkyColor.G,gSkyBox.SkyColor.B);
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][0]);
glBegin(GL_QUADS);
//BACK
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam-3000, y_cam-3000, 1500);
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam+3000, y_cam-3000, 1500);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam+3000, y_cam-3000, 0);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam-3000, y_cam-3000, 0);
glEnd();
if(gSkyBox.SpecialMaps() == true)
{
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][1]);
glBegin(GL_QUADS);
//BOTTOM
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam-3000, y_cam+3000, -1);
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam+3000, y_cam+3000, -1);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam+3000, y_cam-3000, -1);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam-3000, y_cam-3000, -1);
glEnd();
}
else
{
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][1]);
glBegin(GL_QUADS);
//BOTTOM
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam-3000, y_cam+3000, 0);
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam+3000, y_cam+3000, 0);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam+3000, y_cam-3000, 0);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam-3000, y_cam-3000, 0);
glEnd();
}
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][2]);
glBegin(GL_QUADS);
//FRONT
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam-3000, y_cam+3000, 1500);
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam+3000, y_cam+3000, 1500);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam+3000, y_cam+3000, 0);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam-3000, y_cam+3000, 0);
glEnd();
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][3]);
glBegin(GL_QUADS);
//LEFT
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam-3000, y_cam-3000, 1500);
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam-3000, y_cam+3000, 1500);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam-3000, y_cam+3000, 0);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam-3000, y_cam-3000, 0);
glEnd();
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][4]);
glBegin(GL_QUADS);
//RIGHT
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam+3000, y_cam-3000, 1500);
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam+3000, y_cam+3000, 1500);
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam+3000, y_cam+3000, 0);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam+3000, y_cam-3000, 0);
glEnd();
glBindTexture(GL_TEXTURE_2D, gSkyBox.uTextures[pMapNumber][5]);
glBegin(GL_QUADS);
//TOP
glTexCoord2f(1.0f, 0.0f); glVertex3d(x_cam-3000, y_cam+3000, 1500);
glTexCoord2f(0.0f, 0.0f); glVertex3d(x_cam+3000, y_cam+3000, 1500);
glTexCoord2f(0.0f, 1.0f); glVertex3d(x_cam+3000, y_cam-3000, 1500);
glTexCoord2f(1.0f, 1.0f); glVertex3d(x_cam-3000, y_cam-3000, 1500);
glEnd();
pGLSwitch();
}
}
}
void cSkyBox::Load()
{
if(IsSky == SkyOn)
{
gToolKit.HookOffset((DWORD)&this->Display,oDisplay,ASM::CALL);
}
}
|
e311acf0540613b003355a21ef9287f53e48e9aa
|
a51cd90bb73700e18a5f6683113e196fe38f6a5b
|
/src/game/MusicTile.cpp
|
2fed5853082548b4beca2b7032a9ba06d29ce838
|
[] |
no_license
|
NickM13/MusicTiles
|
82b2f54184c106b39455c6f2dc2f3a7278693d6d
|
028919fd6627b841b02cbfb6ecef75fbbb56bfaf
|
refs/heads/master
| 2021-01-23T19:34:53.982607
| 2015-06-11T19:08:50
| 2015-06-11T19:08:50
| 37,152,133
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,265
|
cpp
|
MusicTile.cpp
|
#include "game/MusicTile.h"
#include <random>
MusicTile::MusicTile()
{
tapped = false;
height_ = -32;
row_ = rand()%10;
explode_ = 0;
color_ = getColor(row_);
}
MusicTile::MusicTile(int row, int height = 0)
{
tapped = false;
height_ = -32 - height;
row_ = row;
explode_ = 0;
color_ = getColor(row_);
}
SDL_Color MusicTile::getColor(int id)
{
SDL_Color tempcolor_;
switch (id)
{
case 0:
tempcolor_ = { 255, 0, 0 };
break;
case 1:
tempcolor_ = { 255, 255, 0 };
break;
case 2:
tempcolor_ = { 0, 255, 0 };
break;
case 3:
tempcolor_ = { 0, 255, 255 };
break;
case 4:
tempcolor_ = { 0, 0, 255 };
break;
case 5:
tempcolor_ = { 255, 0, 0 };
break;
case 6:
tempcolor_ = { 255, 255, 0 };
break;
case 7:
tempcolor_ = { 0, 255, 0 };
break;
case 8:
tempcolor_ = { 0, 255, 255 };
break;
case 9:
tempcolor_ = { 0, 0, 255 };
break;
}
return tempcolor_;
}
void MusicTile::update(float speed)
{
if (!tapped)
height_ += speed;
else
explode_+=0.5f;
}
int offsetX;
void MusicTile::render(SDL_Renderer* screen, int scale)
{
if (row_ >= 5)
offsetX = scale;
else
offsetX = 0;
if (tapped)
{
SDL_Rect tiles_[4];
tiles_[0] = { //top left
row_ * (scale + 1) + offsetX,
(int)height_,
(scale / 2) - explode_ * 2,
(scale / 4) - explode_
};
tiles_[1] = { //bottom left
row_ * (scale + 1) + offsetX,
(int)height_ + (scale / 4) + explode_,
(scale / 2) - explode_ * 2,
(scale / 4) - explode_
};
tiles_[2] = { //bottom right
(int)(row_ * (scale + 1) + (scale / 2) + explode_ * 2) + offsetX,
(int)height_ + (scale / 4) + explode_,
(int)((scale / 2) - explode_ * 2),
(int)((scale / 4) - explode_)
};
tiles_[3] = { //top right
(int)(row_ * (scale + 1) + (scale / 2) + explode_ * 2) + offsetX,
(int)height_,
(int)((scale / 2) - explode_ * 2),
(int)((scale / 4) - explode_)
};
SDL_SetRenderDrawColor(screen, (int)(color_.r + explode_ / 8.f * (255 - color_.r)), (int)(color_.g + explode_ / 8.f * (255 - color_.g)), (int)(color_.b + explode_ / 8.f * (255 - color_.b)), 255);
SDL_RenderFillRects(screen, tiles_, 4);
}
else
{
SDL_Rect tile_ = { row_ * (scale + 1) + offsetX, (int)height_, scale, scale / 2 };
SDL_SetRenderDrawColor(screen, color_.r, color_.g, color_.b, 0xFF);
SDL_RenderFillRect(screen, &tile_);
}
}
int MusicTile::getExplode()
{
return (int)explode_;
}
Uint8 MusicTile::checkCollision(bool* keystates)
{
switch (row_)
{
case 0:
if (keystates['a'])
{
tapped = true;
}
break;
case 1:
if (keystates['s'])
{
tapped = true;
}
break;
case 2:
if (keystates['d'])
{
tapped = true;
}
break;
case 3:
if (keystates['f'])
{
tapped = true;
}
break;
case 4:
if (keystates['g'])
{
tapped = true;
}
break;
case 5:
if (keystates['h'])
{
tapped = true;
}
break;
case 6:
if (keystates['j'])
{
tapped = true;
}
break;
case 7:
if (keystates['k'])
{
tapped = true;
}
break;
case 8:
if (keystates['l'])
{
tapped = true;
}
break;
case 9:
if (keystates[';'])
{
tapped = true;
}
break;
}
if (tapped) return row_ + 1;
else return NULL;
}
bool MusicTile::isTapped()
{
return tapped;
}
MusicTile::~MusicTile()
{
}
|
4a7f966e11ceb49982c831cce0e4c5f633ae428c
|
1a2f2d50183cf1cf51a48bd19023472ae3ff8f67
|
/code/game.cpp
|
28986f0db2c2aab00fb0e7d5597ff0cadccd4661
|
[] |
no_license
|
138paulmiller/idolon
|
31d18caab3553d28ad7810bb5bb20c7af6472ad1
|
bf3f9d425b6738f68174cb8fdca43fba38deb353
|
refs/heads/master
| 2023-01-09T23:37:20.952469
| 2020-11-10T20:35:49
| 2020-11-10T20:35:49
| 274,567,334
| 4
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,291
|
cpp
|
game.cpp
|
#include "game.hpp"
#include "assets/api.hpp"
#include "../scripting/api.hpp"
namespace
{
bool s_mapsEnabled[LAYER_COUNT];
Game::Cartridge * m_cart;
}
//use MMU
namespace Game
{
Header::Header( const std::string &name )
:Asset(name)
{}
Cartridge::Cartridge( const Header & header, const Chunk & chunk )
: header(header), chunk(chunk)
{
}
Cartridge::~Cartridge()
{
}
Asset* Cartridge::LoadImpl( const std::type_info &type, const std::string &name )
{
Factory *factory = nullptr;
if ( type == typeid( Graphics::Map ) )
{
factory = new MapFactory();
}
else if ( type == typeid( Graphics::Tileset ) )
{
factory = new TilesetFactory();
}
else if ( type == typeid( Script ) )
{
factory = new ScriptFactory();
}
const uint offset = chunk.offsets[name];
std::istringstream iss;
iss.str(chunk.data+offset);
Asset* asset = factory->deserialize(iss);
delete factory;
return asset ;
}
void Cartridge::UnloadImpl( const std::type_info &type, Asset* asset )
{
delete asset;
}
///////////////////////////////////////////////////////////////////////////////
void Startup(const std::string & cartpath)
{
//load cartridge header and data.
m_cart = 0;
}
void Shutdown()
{
//unload cartrigde
}
//writes asset meta data (name and offset in chunk)
template <class Type, class FactoryType>
static void PackAssetList( const std::vector<std::string>& names, std::unordered_map<std::string, int> &offsetmap, std::ostream & out )
{
FactoryType * factory = new FactoryType();
for ( int i = 0; i < names.size(); i++ )
{
const std::string &name = names[i];
if ( name.size() == 0 )
{
continue;
}
Type *asset = Assets::Load<Type>( name );
ASSERT(asset, "CartridgeFactory: Could not find %s! ", name.c_str() );
offsetmap[name] = out.tellp();
factory->serialize( asset, out );
}
delete factory;
}
static void PackHeader( const std::vector<std::string>& names, const std::unordered_map<std::string, int> &offsetmap, std::ostream & out )
{
out << names.size() << "\n";\
for ( int i = 0; i < names.size(); i++ )\
{
const std::string &name = names[i];
if ( name.size() == 0 )
{
continue;
}
auto it = offsetmap.find( name );
if ( it != offsetmap.end() )
{
out << it->second << "\n" << name << "\n";\
}
}
}
//package game into cartridge
void Package( const Game::Header & header, const std::string &cartpath )
{
//push relative to header
const std::string & fullpath = FS::FullPath( cartpath );
const std::string & name = FS::BaseName( cartpath );
std::ofstream out;
out.open( fullpath );
if ( !out.is_open() )
{
ASSERT( 0, "Failed to find cartridge %s", fullpath.c_str() );
return;
}
Assets::PushPath( FS::DirName(cartpath) );
std::ostringstream oss;
Game::Chunk outChunk;
//write out asset chunk to string stream
PackAssetList<Graphics::Font, TilesetFactory>( header.fonts, outChunk.offsets, oss );
PackAssetList<Graphics::Tileset, TilesetFactory>( header.tilesets, outChunk.offsets, oss );
PackAssetList<Graphics::Map, MapFactory >( header.maps, outChunk.offsets, oss );
PackAssetList<Script, ScriptFactory >( header.scripts, outChunk.offsets, oss );
outChunk.size = oss.tellp();
if ( outChunk.size > 0)
{
outChunk.data = new char[outChunk.size];
strcpy_s( outChunk.data, outChunk.size, oss.str().c_str() );
}
//write header metadata.
// num
// offset name
// offset name
// offset name
// chunk
out << header.name << "\n";
PackHeader( header.fonts , outChunk.offsets, out );
PackHeader( header.tilesets, outChunk.offsets, out );
PackHeader( header.maps, outChunk.offsets, out );
PackHeader( header.scripts, outChunk.offsets, out );
out << outChunk.size;
out.write( outChunk.data, outChunk.size);
out.close();
Assets::PopPath( );
}
static void UnpackHeader( std::vector<std::string> &names, std::unordered_map<std::string, int> &offsetmap, std::istream &in )
{
int len ;
int offset;
std::string assetname;
in >> len;
names.resize( len );
while ( len-- > 0 )
{
in >> offset;
std::getline( in, assetname );
names.push_back( assetname);
offsetmap[assetname] = offset;
}
}
//package game into cartridge
Game::Cartridge * Unpackage( const std::string &cartpath )
{
const std::string fullpath = FS::FullPath( cartpath );
std::ifstream in;
in.open( fullpath );
Game::Cartridge * cartridge= nullptr;
try
{
if ( !in.is_open() )
{
throw;
}
std::string name;
std::getline( in, name );
Game::Header header(name);
Game::Chunk chunk;
UnpackHeader( header.fonts, chunk.offsets, in );
UnpackHeader( header.tilesets, chunk.offsets, in );
UnpackHeader( header.maps, chunk.offsets, in );
UnpackHeader( header.scripts, chunk.offsets, in );
//read chunk
const int pos = in.tellg();
in.seekg (0, in.end);
in >> chunk.size;
chunk.data = new char[chunk.size];
in.read( chunk.data, chunk.size );
cartridge = new Game::Cartridge( header, chunk );
}
catch ( ... )
{
LOG( "Failed to find cartridge %s", fullpath.c_str());
}
in.close();
return cartridge;
}
}
|
394550e0d7347744e6a90772ff2f1992a78d0e50
|
ebf7654231c1819cef2097f60327c968b2fa6daf
|
/server/base/Stream_Packer.cpp
|
97d403ff557b19c8e579fcb5c640c0c42bbd847b
|
[] |
no_license
|
hdzz/game-server
|
71195bdba5825c2c37cb682ee3a25981237ce2ee
|
0abf247c107900fe36819454ec6298f3f1273e8b
|
refs/heads/master
| 2020-12-30T09:15:17.606172
| 2015-07-29T07:40:01
| 2015-07-29T07:40:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,074
|
cpp
|
Stream_Packer.cpp
|
/*
* Packer.h
*
* Created on: Oct 26, 2012
* Author: Root
*/
#include "Stream_Packer.h"
Stream_Packer::Stream_Packer(void) {
pthread_mutex_init(&this->_mutex,NULL);
pthread_cond_init(&this->_cond,NULL);
}
Stream_Packer::~Stream_Packer(void) { }
int Stream_Packer::push_packing_cid(int cid) {
packing_list_.push_back(cid);
pthread_cond_signal(&this->_cond);
return 0;
}
Svc *Stream_Packer::find_svc(int cid) {
LOG_USER_TRACE("SHOULD NOT HERE");
return 0;
}
Block_Buffer *Stream_Packer::pop_block(int cid) {
LOG_USER_TRACE("SHOULD NOT HERE");
return 0;
}
int Stream_Packer::push_block(int cid, Block_Buffer *block) {
LOG_USER_TRACE("SHOULD NOT HERE");
return 0;
}
int Stream_Packer::packed_data_handler(int cid, Block_Vector &block_vec) {
LOG_USER_TRACE("SHOULD NOT HERE");
return 0;
}
int Stream_Packer::drop_handler(int cid) {
LOG_USER_TRACE("SHOULD NOT HERE");
return 0;
}
int Stream_Packer::push_drop(int cid) {
drop_list_.push_back(cid);
pthread_cond_signal(&this->_cond);
return 0;
}
int Stream_Packer::process_drop(void) {
int cid = 0;
while (! drop_list_.empty()) {
cid = drop_list_.pop_front();
drop_handler(cid);
}
return 0;
}
void Stream_Packer::run_handler(void) {
//LOG_DEBUG("start packer");
process();
}
int Stream_Packer::process(void) {
while (true) {
pthread_mutex_lock(&this->_mutex);
while(this->packing_list_.empty() && this->drop_list_.empty()) {
pthread_cond_wait(&this->_cond,&this->_mutex);
}
pthread_mutex_unlock(&this->_mutex);
process_packing_list();
process_drop();
}
return 0;
}
int Stream_Packer::process_packing_list(void) {
Svc *svc = 0;
int cid = 0;
Block_Vector block_vec;
while (! packing_list_.empty()) {
cid = packing_list_.pop_front();
if ((svc = find_svc(cid)) == 0) {
LOG_USER_TRACE("cannot find svc cid = %d.", cid);
continue;
}
block_vec.clear();
svc->pack_recv_data(block_vec);
if (block_vec.size()) {
svc->recv_pack_size(block_vec.size());
packed_data_handler(cid, block_vec);
}
}
return 0;
}
|
1fafb8ac4dd446a3a02567448af1135a6ef18d2c
|
474f05730eccc5b20269736577c07eb38798ced6
|
/batterup.cpp
|
23c63114a81ed29db8a8b590dfb458489ddbdf9d
|
[] |
no_license
|
kantuni/Kattis
|
5d6fe8480c1155103e8f7933bb2097e1248873db
|
345db8c1252758d7c0d9d04ac4ef995244da43d6
|
refs/heads/master
| 2022-07-22T20:00:33.914326
| 2022-07-19T14:47:39
| 2022-07-19T14:47:39
| 110,396,612
| 8
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 256
|
cpp
|
batterup.cpp
|
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
long double num = 0, denom = 0;
while (n--) {
int r;
cin >> r;
if (r != -1) {
num += r;
denom++;
}
}
cout << num / denom << endl;
return 0;
}
|
3372c2b6bf44a382deed41ad9331ca5fd2c7c04b
|
6501d76a9eb22f81b9e4c12f710b27029dfef70d
|
/queues/Queue using linked list.cpp
|
3bf7ff4aa2a06c5cc44b6a349767994cda47c6e3
|
[] |
no_license
|
hanrick2000/data-structures
|
fe7f4d1eb563005e945439f735c62b8c21fe79d1
|
ba23723ba2d99caa7fbf42ed203b7ccf01b40088
|
refs/heads/master
| 2020-12-03T17:10:14.421985
| 2017-01-09T07:22:01
| 2017-01-09T07:22:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 833
|
cpp
|
Queue using linked list.cpp
|
#include<iostream>
using namespace std;
struct node
{
int data;
node* next;
};
class Queue
{
node* head,*tail;
public:
Queue()
{
head=NULL;
tail=NULL;
}
void enqueue(int data);
void dequeue();
bool isEmpty();
int front();
};
bool Queue::isEmpty()
{
if(head==NULL)
return true;
return false;
}
void Queue::enqueue(int data)
{
node* new_node=new node;
new_node->data=data;
new_node->next=NULL;
if(head==NULL)
{
head=new_node;
tail=new_node;
}
else
{
tail->next=new_node;
tail=new_node;
}
}
void Queue::dequeue()
{
if(!isEmpty())
{
head=head->next;
}
else
{
cout<<"Queue is empty"<<endl;
}
}
int Queue::front()
{
if(!isEmpty())
{
int data=head->data;
head=head->next;
return data;
}
else
{
cout<<"Stack empty"<<endl;
return -1;
}
}
int main()
{
return 0;
}
|
9d1f6860a68438752ecbe8f447fc3fc6cb7850fa
|
74f20c8622266ac8c05200d4dc33d698ef061c86
|
/src/elements/QRcode.h
|
a3a1f12349b845366e23f26bea4655c325c1819b
|
[] |
no_license
|
20SecondsToSun/Funces
|
45303bd9acf910230ad5379043c610df3b09c963
|
d999183fbfcdd10796b0b55c4ac37cfabb76deae
|
refs/heads/master
| 2021-01-01T16:45:13.572464
| 2014-12-20T16:47:15
| 2014-12-20T16:47:15
| 22,994,173
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 771
|
h
|
QRcode.h
|
#pragma once
#include "cinder/app/AppBasic.h"
#include "cinder/gl/gl.h"
#include "AssetsManager.h"
#include "cinder/Text.h"
#include "cinder/Timeline.h"
#include "PreloaderCircle.h"
#include "cinder/Base64.h"
class QRcode
{
public:
void setup();
void init();
void draw();
void initAnim();
void drawError();
bool isReady, isRender;
void setTextureString(std::string str);
void setLink(std::string link);
bool isError;
private:
ci::Font qrCodeFont ;
ci::Anim<ci::Vec2f> startQRCodeHolderXY;
ci::gl::Texture qrCodeFon, qrCodeTextTexture, qrCodeTexture, *errorTexture;
PreloaderCircle preloader;
std::string url;
std::string stringQrcode;
gl::Texture loadImageFromString(std::string value);
};
|
f34b846817c6c2d6e41f6273bf225532a99247e8
|
526f023829a846fa1304e678b4081a4a75d00233
|
/junk/rand/leetcode/minimum_depth_binary_tree.cc
|
0c804fbfccbacbe8194f95db78e6f8ea60fca803
|
[] |
no_license
|
bsergean/pytof
|
9174d2cec5d3361282b08d5384e9166fa1303212
|
af521274159107fc4bd74be831534bb7eecdff75
|
refs/heads/master
| 2020-04-14T14:24:23.970244
| 2015-11-02T05:12:02
| 2015-11-02T05:12:02
| 33,892,763
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,139
|
cc
|
minimum_depth_binary_tree.cc
|
#include <iostream>
// Definition for a binary tree node.
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x, TreeNode* _left, TreeNode* _right) : val(x), left(_left), right(_right) {}
};
void
minDepthHelper(TreeNode* root, int depth, int& min)
{
if (root->left == NULL && root->right == NULL) {
if (depth <= min) min = depth;
return;
}
if (root->left != NULL) minDepthHelper(root->left, depth+1, min);
if (root->right != NULL) minDepthHelper(root->right, depth+1, min);
}
int
minDepth(TreeNode* root)
{
if (root == NULL) return 0;
PriorityQueue pq;
int min = 1000000000;
minDepthHelper(root, 1, min);
return min;
}
int
main()
{
/*
d
b
a c
e
*/
TreeNode* F = new TreeNode(1, NULL, NULL);
TreeNode* E = new TreeNode(1, NULL, NULL);
TreeNode* C = new TreeNode(1, NULL, NULL);
TreeNode* A = new TreeNode(1, E, NULL);
TreeNode* B = new TreeNode(1, A, C);
TreeNode* D = new TreeNode(1, B, NULL);
std::cout << minDepth(D) << std::endl;
return 0;
}
|
2f14a9caf111d50bfeb70e3451e0a213f09d539a
|
a28b383eef9cfcd9e481ffbd609da00023781fb4
|
/implementations/gcc_plugin_hecfi.cpp
|
9fb0c0ef33ca111298036feaa5ec57391cb2039b
|
[] |
no_license
|
cfg-cfi-excec/cfi-gcc-plugin
|
467f0d76721907613d118c78c9299f390a8aa578
|
3131947e21deb0d9296c182b068d21525d13eb2e
|
refs/heads/main
| 2023-06-19T00:17:43.401868
| 2021-06-12T04:23:29
| 2021-06-12T04:24:17
| 388,430,347
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,936
|
cpp
|
gcc_plugin_hecfi.cpp
|
#include "gcc_plugin_hecfi.h"
GCC_PLUGIN_HECFI::GCC_PLUGIN_HECFI(gcc::context *ctxt, struct plugin_argument *arguments, int argcounter)
: GCC_PLUGIN(ctxt, arguments, argcounter) {
init();
}
void GCC_PLUGIN_HECFI::onFunctionEntry(std::string file_name, std::string function_name, basic_block firstBlock, rtx_insn *firstInsn) {
// Don't instrument function entry of __main with a CFICHK
if (strcmp(function_name.c_str(), "__main") == 0) {
// reset CFI state (e.g., exit(1) might have left CFI module in a dirty state)
generateAndEmitAsm(CFI_RESET, firstInsn, firstBlock, false);
// enable CFI from here on
generateAndEmitAsm(CFI_ENABLE, firstInsn, firstBlock, false);
} else if (strcmp(function_name.c_str(), "exit") == 0) {
// reset CFI state because exit() breaks out of CFG
generateAndEmitAsm(CFI_RESET, firstInsn, firstBlock, false);
} else {
int label = getLabelForIndirectlyCalledFunction(function_name, file_name);
if (label >= 0) {
generateAndEmitAsm("CFICHK " + std::to_string(label), firstInsn, firstBlock, false);
}
}
}
void GCC_PLUGIN_HECFI::onFunctionRecursionEntry(std::string file_name, std::string function_name, basic_block firstBlock, rtx_insn *firstInsn) {
onFunctionEntry(file_name, function_name, firstBlock, firstInsn);
}
void GCC_PLUGIN_HECFI::onFunctionReturn(std::string file_name, std::string function_name, basic_block lastBlock, rtx_insn *lastInsn) {
if (function_name.compare("__main") == 0) {
// disable CFI from here on
generateAndEmitAsm(CFI_DISABLE, lastInsn, lastBlock, false);
}
}
void GCC_PLUGIN_HECFI::emitTrampolines(std::string file_name, std::string function_name, int line_number, std::string register_name, basic_block lastBlock, rtx_insn *lastInsn) {
//Generate Trampolines for an indirect call in this function
std::vector<CFG_FUNCTION_CALL> function_calls = getIndirectFunctionCalls();
for(CFG_FUNCTION_CALL function_call : function_calls) {
if (function_call.function_name.compare(function_name) == 0) {
if (function_call.line_number == line_number) {
// generate symbol for trampoline
rtx_insn *insn = generateAndEmitAsm("_trampolines_" + std::string(function_name) + "_"
+ std::to_string(function_call.line_number) + ":", lastInsn, lastBlock, true);
// add CFICHK at the very beginning
insn = generateAndEmitAsm("CFICHK " + std::to_string(function_call.label), insn, lastBlock, true);
// restore original register content
insn = generateAndEmitAsm("lw " + register_name + ",0(sp)", insn, lastBlock, true);
insn = generateAndEmitAsm("addi sp,sp,4", insn, lastBlock, true);
for(CFG_SYMBOL call : function_call.calls) {
// load symbol address of one possible call target to t0
insn = generateAndEmitAsm("LA t0, " + call.symbol_name, insn, lastBlock, true);
// compare actual call target with t0
insn = generateAndEmitAsm("BEQ t0, " + register_name + ", " + call.symbol_name + "+4", insn, lastBlock, true);
}
// This is the "else-branch": if we arrive here, there is a CFI violation
generateAndEmitAsm("CFIRET 0xFFFF", insn, lastBlock, true);
break;
}
}
}
}
void GCC_PLUGIN_HECFI::onDirectFunctionCall(std::string file_name, std::string function_name, basic_block block, rtx_insn *insn) {
// Don't instrument functions in libgcc
if (isLibGccFunction(function_name)) {
// disable CFI from here on
generateAndEmitAsm(CFI_DISABLE, insn, block, false);
rtx_insn *tmpInsn = NEXT_INSN(insn);
while (NOTE_P(tmpInsn)) {
tmpInsn = NEXT_INSN(tmpInsn);
}
// Enable CFI again after excluded function
generateAndEmitAsm(CFI_ENABLE, tmpInsn, block, false);
} else {
writeLabelToTmpFile(readLabelFromTmpFile()+1);
unsigned label = readLabelFromTmpFile();
generateAndEmitAsm("CFIBR " + std::to_string(label), insn, block, false);
rtx_insn *tmpInsn = NEXT_INSN(insn);
while (NOTE_P(tmpInsn)) {
tmpInsn = NEXT_INSN(tmpInsn);
}
generateAndEmitAsm("CFIRET " + std::to_string(label), tmpInsn, block, false);
}
}
void GCC_PLUGIN_HECFI::onSetJumpFunctionCall(std::string file_name, std::string function_name, basic_block block, rtx_insn *insn, int indexn) {
// setjmp calls require normal instrumentation just as any other call
onDirectFunctionCall(file_name, function_name, block, insn);
}
void GCC_PLUGIN_HECFI::onLongJumpFunctionCall(std::string file_name, std::string function_name, basic_block block, rtx_insn *insn, int index) {
// lonjmp calls require normal instrumentation just as any other call
onDirectFunctionCall(file_name, function_name, block, insn);
}
void GCC_PLUGIN_HECFI::onRecursiveFunctionCall(std::string file_name, std::string function_name, basic_block block, rtx_insn *insn) {
onDirectFunctionCall(file_name, function_name, block, insn);
}
void GCC_PLUGIN_HECFI::onIndirectFunctionCall(std::string file_name, std::string function_name, int line_number, basic_block block, rtx_insn *insn) {
writeLabelToTmpFile(readLabelFromTmpFile()+1);
unsigned label = readLabelFromTmpFile();
int labelPRC = getLabelForIndirectFunctionCall(function_name, file_name, line_number);
rtx_insn *indirectCall = insn;
rtx_insn *tmpInsn = NEXT_INSN(insn);
while (NOTE_P(tmpInsn)) {
tmpInsn = NEXT_INSN(tmpInsn);
}
// add CFIRET instruction after the indirect JALR
generateAndEmitAsm("CFIRET " + std::to_string(label), tmpInsn, block, false);
// add CFIBR instruction (for backward edge protection)
insn = generateAndEmitAsm("CFIBR " + std::to_string(label), insn, block, false);
if (labelPRC >= 0) {
bool trampolinesNeeded = areTrampolinesNeeded(file_name, function_name, line_number);
//std::cerr << "#### TRAMPOLINES NEEDED: " << (trampolinesNeeded ? "YES" : "NO") << std::endl;
if (trampolinesNeeded) {
rtx outer = XVECEXP(PATTERN(indirectCall), 0, 0);
if (GET_CODE (outer) == SET) {
outer = XEXP(outer, 1);
}
std::string regName = getRegisterNameForNumber(REGNO(XEXP(XEXP(outer, 0), 0)));
// increase stack pointer
generateAndEmitAsm("addi sp,sp,-4", insn, block, false);
// push old register content to stack
generateAndEmitAsm("SW " + regName + ",0(sp)", insn, block, false);
// re-route jump: write address of trampoline to register
generateAndEmitAsm("LA " + regName + ", _trampolines_" + std::string(function_name) + "_" + std::to_string(line_number), insn, block, false);
// add CFIPRC instruction
generateAndEmitAsm("CFIPRC " + std::to_string(labelPRC), insn, block, true);
basic_block lastBlock = lastRealBlockInFunction();
rtx_insn *lastInsn = UpdatePoint::lastRealINSN(lastBlock);
emitTrampolines(file_name, function_name, line_number, regName, lastBlock, lastInsn);
} else {
// add CFIPRC instruction without trampolines
generateAndEmitAsm("CFIPRC " + std::to_string(labelPRC), insn, block, true);
}
} else {
handleIndirectFunctionCallWithoutConfigEntry(file_name, function_name, line_number);
}
}
void GCC_PLUGIN_HECFI::onNamedLabel(std::string file_name, std::string function_name, std::string label_name, basic_block block, rtx_insn *insn) {
int label = getLabelForIndirectJumpSymbol(file_name, function_name, label_name);
if (label >= 0) {
generateAndEmitAsm("CFICHK " + std::to_string(label), insn, block, false);
}
}
void GCC_PLUGIN_HECFI::onSwitchCase(int label, basic_block block, rtx_insn *insn) {
generateAndEmitAsm("CFICHK " + std::to_string(label), insn, block, true);
}
void GCC_PLUGIN_HECFI::onIndirectJump(std::string file_name, std::string function_name, basic_block block, rtx_insn *insn) {
int label = getLabelForIndirectJump(file_name, function_name);
if (label >= 0) {
generateAndEmitAsm("CFIPRJ " + std::to_string(label), insn, block, false);
} else {
handleIndirectJumpWithoutConfigEntry(file_name, function_name);
}
}
void GCC_PLUGIN_HECFI::init() {
for (int i = 0; i < argc; i++) {
if (std::strcmp(argv[i].key, "cfg_file") == 0) {
std::cerr << "CFG file for instrumentation: " << argv[i].value << "\n";
readConfigFile(argv[i].value);
//printFunctionCalls();
//printLabelJumps();
//printIndirectlyCalledFunctions();
break;
}
}
}
GCC_PLUGIN_HECFI *GCC_PLUGIN_HECFI::clone() {
// We do not clone ourselves
return this;
}
void GCC_PLUGIN_HECFI::onPluginFinished() {
remove("tmp.txt");
}
|
95eb79f95bcc07f1095966c2c49801ca59cd755a
|
cd940b838b452dbf26aa5f694ce183c79edd81fd
|
/wiring_pi/wiringPi.h
|
9e209c296c955c66f92f601b8c3564577660c369
|
[
"Apache-2.0"
] |
permissive
|
heftyy/rpi-networking
|
65f545bd3b413fa1b19554d7c529119c54e0517b
|
88b8ea5de6f113735315aaf52e461cb286934bd9
|
refs/heads/master
| 2021-01-17T11:01:24.062836
| 2016-06-02T16:17:12
| 2016-06-02T16:17:12
| 15,206,245
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 232
|
h
|
wiringPi.h
|
#include <iostream>
enum { WIRING_PI_OUTPUT, WIRING_PI_INPUT};
void wiringPiSetup() { return; }
void pinMode(int pin, int mode) { return;}
int digitalRead(int pin) { return 0; }
void digitalWrite(int pin, int value) { return; }
|
1e9c81c9503b5d81fbc8afa2901cf45ee93ff515
|
f8aa6e689d132d660e71335552b37cc1a5cb0786
|
/TrainData/常用模板/网络流/maxflow.cpp
|
a9f4f47f0de5cc395beb01d73c89aae346670253
|
[] |
no_license
|
VarickQ/ACM
|
91171f381fa57b6644f10b1a4a5a9aeaeeff12b2
|
5d4f2c14272b28c7ff2cb7ebcd4e91400345a096
|
refs/heads/master
| 2021-01-10T14:34:07.812097
| 2017-05-14T09:58:54
| 2017-05-14T09:58:54
| 8,500,751
| 4
| 1
| null | null | null | null |
GB18030
|
C++
| false
| false
| 4,596
|
cpp
|
maxflow.cpp
|
//-----------------Max Flow---------------------//
/*
最大流 Algo : RelabelToFront Preflow
main()里要做的事:
1) 定义类Graph 的实例G。
2) 给边容量矩阵G.c[][]赋值,若无边,赋为0
3) 把顶点的个数赋给G.V。
4) 调用G.MaxFlow(s, t),返回最大流值。同时由G.f[][]可知流值分配。
*/
const int MAX = 405; //最多结点数量
class Graph
{
public:
//构造图结构时只需初始化V域和c域即可。
int V;
int c[MAX][MAX]; //边容量矩阵,若无边,则为0
int f[MAX][MAX]; //流矩阵
int maxflow;
int MaxFlow(int , int);
private:
struct flownode
{
int adjnum;
flownode * next;
};
int e[MAX]; //过剩容量数组
int h[MAX]; //Height数组
flownode * N[MAX]; //Neighbour lists
//
void InitializePreflow(int);
void PushPreflow(int, int);
void RelabelPreflow(int);
void DischargePreflow(int);
//
void listInsert(flownode * , int);
void listErase(flownode *);
void listDestroy(flownode * &);
void neighborDestroy();
};
void Graph::InitializePreflow(int s)
{
int u;
flownode *itr;
for(u = 0; u < V; ++u)
{
h[u] = 0;
e[u] = 0;
}
memset(f,0,sizeof(int) * MAX * V);
h[s] = V;
//
for(itr = N[s]->next; itr; itr = itr->next)
{
u = itr->adjnum;
f[s][u] = c[s][u];
f[u][s] = -c[s][u];
e[u] = c[s][u];
e[s] -= c[s][u];
}
}
void Graph::PushPreflow(int u, int v)
{
//Applies when: u is overflowing, cf[u][v]>0, and h[u] = h[v] +1.
//cf[u][v] = c[u][v] - f[u][v];
//Action: Push df[u][v] = min{e[u], cf[u][v]) units of flow from u to v
int Cf = c[u][v] - f[u][v];
int Df = e[u] < Cf ? e[u] : Cf;
f[u][v] += Df;
f[v][u] = -f[u][v];
e[u] -= Df;
e[v] += Df;
}
void Graph::RelabelPreflow(int u)
{
//Applies when: u is overflowing and for all v in V such that (u,v) is in Ef,
// we have h[u] <= h[v].
//Action: h[u] = 1 + min{h[v] : (u,v) in Ef
int min = V * 2; //这里一开始我写成了G.V + 1,不对,它不能保证是绝对大的。
flownode *itr;
int w;
for( itr = N[u]->next; itr; itr = itr->next)
{
w = itr->adjnum;
if( (c[u][w] > f[u][w] ) && (min > h[w]) )
min = h[w];
}
h[u] = 1 + min;
}
void Graph::DischargePreflow(int u)
{
int v;
flownode *current = N[u]->next;
while(e[u] > 0)
{
if( !current )
{
RelabelPreflow(u);
current = N[u]->next;
}else
{
v = current->adjnum;
if( (c[u][v] > f[u][v]) && (h[u] == h[v] + 1))
PushPreflow(u, v);
else current=current->next;
}
}
}
void Graph::listInsert(flownode * head, int i)
{
flownode * p;
p = new flownode;
p->adjnum = i;
p->next = head->next;
head->next = p;
}
void Graph::listErase(flownode * p)
{
flownode * q;
q = p->next;
p->next = q->next;
delete q;
}
void Graph::listDestroy(flownode * & head)
{
flownode * q;
while(head->next)
{
q = head->next;
head->next = q->next;
delete q;
}
delete head;
head = NULL;
}
void Graph::neighborDestroy()
{
for(int i = 0; i<V; ++i)
listDestroy(N[i]);
}
int Graph::MaxFlow(int s, int t)
{
flownode *L;
flownode *itr;
int i, u, oldheight;
//构造每个结点的Neightbour list;
for(u = 0; u < V; ++u)
{
N[u] = new flownode;
N[u]->next = NULL;
}
for(u = 0; u < V; ++u)
{
for(i = 0; i < u; ++i)
if( c[u][i] || c[i][u] )
{
listInsert(N[u],i);
listInsert(N[i],u);
}
}
//构造L
L = new flownode;
L ->next = NULL;
for( i = 0; i < V; ++i)
{
if(i == s || i == t) continue;
listInsert(L,i);
}
//初始化preflow
InitializePreflow(s);
//
for(itr = L; itr->next; itr = itr->next )
{
u = itr->next->adjnum;
oldheight = h[u];
DischargePreflow(u);
if(h[u] > oldheight)
{
listErase(itr);
listInsert(L,u);
itr = L;
}
}
listDestroy(L);
maxflow = 0;
for( itr = N[s]->next; itr; itr = itr->next)
{
if(f[s][itr->adjnum] )
maxflow += f[s][itr->adjnum];
}
neighborDestroy();
return maxflow;
}
//----------------------Max Flow---------------------//
|
54870c9b26ed4abdf98d182dad96099affea6fa3
|
a32dc7e553a2056f4cf546eb3f9acff733b5254e
|
/DS18B20/DS18B20.ino
|
588e3956062360d16d62e7717643613307a40555
|
[
"MIT"
] |
permissive
|
ombhilare999/Aqua_Farm_Monitor
|
e58786616dd8e9b0ca99c93935c6b48c235fba5e
|
82a9e7b11b1a92e02955f4789b5d813af3c2499e
|
refs/heads/main
| 2023-04-21T23:51:01.603641
| 2021-05-08T14:51:01
| 2021-05-08T14:51:01
| 343,401,194
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,193
|
ino
|
DS18B20.ino
|
/////////////////////////////////////////////////////
// Aqua Farm Monitoring System
// Group 2:
// - Omkar Bhilare
// - Omkar Sargar
// - Lukesh Ankawar
// - Om Fuke
////////////////////////////////////////////////////
#include <OneWire.h>
#include <DallasTemperature.h>
#include <BlynkSimpleStream.h>
#define BLYNK_PRINT Serial
#define ONE_WIRE_BUS 2 // Data wire is plugged into digital pin 2 on the Arduino
float sensorData;
char auth[] = "-----------------------";
OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire device
DallasTemperature sensor(&oneWire); // Pass oneWire reference to DallasTemperature library
BlynkTimer timer; // Announcing the timer
void myTimerEvent()
{
sensorData = sensor.getTempCByIndex(0);
Blynk.virtualWrite(V5, sensorData);
}
void setup(void)
{
sensor.begin(); // Start up the library
Serial.begin(9600);
Blynk.begin(Serial, auth);
timer.setInterval(1000L, myTimerEvent);
}
void loop(void)
{
sensor.requestTemperatures(); // Send the command to get temperatures
Blynk.run();
timer.run(); // running timer every second
delay(50);
}
|
ece118fc4219388d621386aa27c71e482031170c
|
394aec212523c140d85e49fa5d8915e4e204e6ef
|
/src/widgets/widget.h
|
a2fff36606a383637ff7866a7fbfd488a6179c96
|
[] |
no_license
|
ulno/t3widget
|
8c357f479724ae6485f31588f59b88e259aaa927
|
5c2492bdeb2f11042d9319e02e612e4dcf5f0464
|
refs/heads/master
| 2021-09-04T17:50:59.302173
| 2018-01-20T19:05:43
| 2018-01-20T19:05:43
| 117,440,554
| 0
| 1
| null | 2018-01-14T15:08:46
| 2018-01-14T15:08:46
| null |
UTF-8
|
C++
| false
| false
| 4,401
|
h
|
widget.h
|
/* Copyright (C) 2011-2012 G.P. Halkes
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3, as
published by the Free Software Foundation.
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/>.
*/
#ifndef T3_WIDGET_WIDGETS_H
#define T3_WIDGET_WIDGETS_H
#include <deque>
#include <t3widget/interfaces.h>
namespace t3_widget {
/** Base class for widgets. */
class T3_WIDGET_API widget_t : public virtual window_component_t, public mouse_target_t {
private:
friend class container_t;
/** Default parent for widgets, making them invisible. */
static cleanup_t3_window_ptr default_parent;
protected:
bool redraw, /**< Widget requires redrawing on next #update_contents call. */
enabled, /**< Widget is enabled. */
shown; /**< Widget is shown. */
/** Constructor which creates a default @c t3_window_t with @p height and @p width. */
widget_t(int height, int width, bool register_as_mouse_target = true);
/** Constructor which does not create a default t3_window_t.
This constructor should only rarely be necessary. Widgets using this
constructor should call either #init_window, or #init_unbacked_window.
*/
widget_t();
/** Initialize the #window with a @c t3_window_t with @p height and @p width. */
void init_window(int height, int width, bool register_as_mouse_target = true);
/** Initialize the #window with an unbacked @c t3_window_t with @p height and @p width. */
void init_unbacked_window(int height, int width, bool register_as_mouse_target = false);
public:
/** Query whether key is a hotkey for this widget. */
virtual bool is_hotkey(key_t key);
/** Query whether this widget accepts focus. */
virtual bool accepts_focus();
void set_position(optint top, optint left) override;
void show() override;
void hide() override;
/** Set this widget's anchor.
Use @p anchor to position this window. See libt3window's
t3_win_set_anchor for details on the @p relation parameter.
*/
virtual void set_anchor(window_component_t *anchor, int relation);
void force_redraw() override;
/** Set the enabled status of this widget.
When a widget is not enabled, it will not accept focus.
*/
virtual void set_enabled(bool enable);
/** Query the enabled status of this widget. */
virtual bool is_enabled();
/** Query the visibility status of this widget. */
virtual bool is_shown();
void set_focus(focus_t focus) override;
bool process_mouse_event(mouse_event_t event) override;
};
/** Base class for widgets that take focus. */
class T3_WIDGET_API focus_widget_t {
/** @fn signals::connection connect_move_focus_left(const signals::slot<void> &_slot)
Connect a callback to be called on emission of the move_focus_left_signal. */
/** Signal emitted when the user pressed the left arrow key and focus should move. */
T3_WIDGET_SIGNAL(move_focus_left, void);
/** @fn signals::connection connect_move_focus_right(const signals::slot<void> &_slot)
Connect a callback to be called on emission of the move_focus_right_signal. */
/** Signal emitted when the user pressed the right arrow key and focus should move. */
T3_WIDGET_SIGNAL(move_focus_right, void);
/** @fn signals::connection connect_move_focus_up(const signals::slot<void> &_slot)
Connect a callback to be called on emission of the move_focus_up_signal. */
/** Signal emitted when the user pressed the up arrow key and focus should move. */
T3_WIDGET_SIGNAL(move_focus_up, void);
/** @fn signals::connection connect_move_focus_down(const signals::slot<void> &_slot)
Connect a callback to be called on emission of the move_focus_down_signal. */
/** Signal emitted when the user pressed the down arrow key and focus should move. */
T3_WIDGET_SIGNAL(move_focus_down, void);
};
class T3_WIDGET_API widget_container_t : public container_t {
public:
virtual widget_t *is_child_hotkey(key_t key) = 0;
};
typedef std::deque<widget_t *> widgets_t;
}; // namespace
#endif
|
3281004dbbf28bb53a0ba6cb7380e5955118f56c
|
caacd58516d199ee657f10017fca0fe5de15ba21
|
/src/Buzzer.hpp
|
d87ad24eea6bf9437745bf2e343e6e312cb83c4c
|
[] |
no_license
|
SilveRousePL/RPi_Assistant
|
9b0a889436264895167e67020a424500490ad0ef
|
fa23ba8f0a9be6f62c1935fc9a8e92a968274995
|
refs/heads/master
| 2021-04-09T11:05:03.703727
| 2018-03-16T19:40:59
| 2018-03-16T19:40:59
| 125,562,159
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,467
|
hpp
|
Buzzer.hpp
|
/*
* Buzzer.hpp
*
* Created on: 12 mar 2018
* Author: darek
*/
#ifndef BUZZER_HPP_
#define BUZZER_HPP_
#include "../../@RPi_Tools@/wiringPi/wiringPi.h"
#include "../../@RPi_Tools@/wiringPi/softTone.h"
#include <iostream>
class Buzzer {
public:
enum Frequency {
C_1 = 32,
Ci_1 = 34,
D_1 = 36,
Di_1 = 38,
E_1 = 41,
F_1 = 43,
Fi_1 = 46,
G_1 = 48,
Gi_1 = 51,
A_1 = 54,
Ai_1 = 58,
H_1 = 61,
C = 65,
Ci = 69,
D = 73,
Di = 77,
E = 82,
F = 87,
Fi = 92,
G = 97,
Gi = 103,
A = 110,
Ai = 116,
H = 123,
c = 130,
ci = 138,
d = 146,
di = 155,
e = 164,
f = 174,
fi = 184,
g = 195,
gi = 207,
a = 220,
ai = 233,
h = 246,
c1 = 261,
ci1 = 277,
d1 = 293,
di1 = 311,
e1 = 329,
f1 = 349,
fi1 = 369,
g1 = 391,
gi1 = 415,
a1 = 440,
ai1 = 466,
h1 = 493,
c2 = 523,
ci2 = 554,
d2 = 587,
di2 = 622,
e2 = 659,
f2 = 698,
fi2 = 739,
g2 = 783,
gi2 = 830,
a2 = 880,
ai2 = 932,
h2 = 987,
c3 = 1046,
ci3 = 1108,
d3 = 1174,
di3 = 1244,
e3 = 1318,
f3 = 1396,
fi3 = 1479,
g3 = 1567,
gi3 = 1661,
a3 = 1760,
ai3 = 1864,
h3 = 1975,
c4 = 2093,
ci4 = 2217,
d4 = 2349,
di4 = 2489,
e4 = 2637,
f4 = 2793,
fi4 = 2959,
g4 = 3135,
gi4 = 3322,
a4 = 3520,
ai4 = 3729,
h4 = 3951,
c5 = 4186,
};
Buzzer();
virtual ~Buzzer();
};
#endif /* BUZZER_HPP_ */
|
17823d443be4d966a195efb3f237a090c4ba498f
|
3c76de2fbce324923d32747989e062be7ebb03b0
|
/PracticalC++DesignFromProgrammingtoArachitecture/src/Cli.cpp
|
7be9553cd550ce4f498acf9b0a950c196b133ad7
|
[] |
no_license
|
dinglight/books
|
b6510a65ebc174d2caf84ce8d5015c2e5cb2c368
|
53d42b8231f67a45de0f71e19f47cb65bbec9174
|
refs/heads/master
| 2021-07-03T03:03:23.362550
| 2020-08-19T14:13:39
| 2020-08-19T14:13:39
| 148,032,925
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,457
|
cpp
|
Cli.cpp
|
#include "Cli.h"
#include "Tokenizer.h"
#include "Stack.h"
#include "Logger.h"
namespace strawberry {
class Cli::CliImpl {
public:
CliImpl(Cli&, std::istream& in, std::ostream& out);
void Execute();
void PostMessage(const std::string& msg);
void StackChanged();
private:
void StartupMessage();
private:
Cli& parent_;
std::istream& in_;
std::ostream& out_;
};
Cli::CliImpl::CliImpl(Cli& p, std::istream& in, std::ostream& out)
: parent_(p)
, in_(in)
, out_(out)
{
}
void Cli::CliImpl::Execute()
{
StartupMessage();
for (std::string line; std::getline(in_, line, '\n');) {
Tokenizer tokenizer{line};
for (const auto& token : tokenizer) {
if (token == "exit") {
return;
} else {
parent_.Raise(UserInterface::CommandEntered, std::make_shared<CommandData>(token));
}
}
}
}
void Cli::CliImpl::PostMessage(const std::string& msg)
{
out_ << msg << std::endl;
}
/**
* @brief show the top4 numbers on the stack
*
*/
void Cli::CliImpl::StackChanged()
{
size_t nElements{4};
auto v = Stack::Instance().GetElements(nElements);
std::ostringstream oss;
oss.precision(12);
size_t size = Stack::Instance().Size();
oss << "\n";
if (size == 0) {
oss << "Stack currently empty. \n";
} else if (size == 1) {
oss << "Top element of stack (size = " << size << "):\n";
} else if (size > 1 && size <= nElements) {
oss << "Top " << size << " elements of stack (size = " << size << "):\n";
} else {
oss << "Top " << nElements << " elements of stack (size = " << size << "):\n";
}
size_t j {v.size()};
for (auto i = v.rbegin(); i != v.rend(); ++i) {
oss << j << ":\t" << *i << "\n";
--j;
}
PostMessage(oss.str());
}
void Cli::CliImpl::StartupMessage()
{
out_ << "calc\n"
<< "type 'exit' to end program\n" << std::endl;
}
////////////////////////////////////////////////////////////////////////////////
Cli::Cli(std::istream& in, std::ostream& out)
{
LOG("");
cli_impl_ = std::make_unique<CliImpl>(*this, in, out);
}
Cli::~Cli()
{
LOG("");
}
void Cli::Execute()
{
LOG("");
cli_impl_->Execute();
}
void Cli::PostMessage(const std::string& msg)
{
LOG("");
cli_impl_->PostMessage(msg);
}
void Cli::StackChanged()
{
LOG("");
cli_impl_->StackChanged();
}
} // namespace strawberry
|
f1d15df3354d27c20d3ad4d9019468237533ba2c
|
49f159a6878749801931dddfedf109f39f3f1ba6
|
/2-3-构造与析构/2-2-构造与析构.cpp
|
38a36d96192339050199fe428c37078119328737
|
[] |
no_license
|
pythonicrane/heimaCpp
|
cf47910b9db95f009cf4b59647fcef3116c19571
|
a801324cd8ca1825c43a174e8bf7755bf47dbd72
|
refs/heads/master
| 2020-03-23T10:19:02.444658
| 2018-08-06T09:30:46
| 2018-08-06T09:30:46
| 141,436,765
| 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,758
|
cpp
|
2-2-构造与析构.cpp
|
/**-------------------------------------------------------------
* @Author : Zhao Heln
* @Time : 2018年7月20日11:12:29
* @Software : Visual Studio 2017
* @Project : 黑马程序员基础
* @Problem : 类
* @Description :
*
-------------------------------------------------------------**/
#include <iostream>
using namespace std;
class Point {
public:
Point() {
_x = 0;
_y = 0;
cout << "Point noList constructor" << endl;
};
Point(double x, double y) :_x(x), _y(y) {
cout << "Point constructor" << endl;
};
Point(const Point& t) {
_x = t._x;
_y = t._y;
cout << "Point copy constructor" << endl;
};
~Point() {
cout << "Point destructor" << endl;
}
// Point operator=(const Point& t) {
// _x = t._x;
// _y = t._y;
// cout << "Point asignment operator" << endl;
// return *this;
// }
Point operator+(const Point& t) {
_x += t._x;
_y += t._y;
cout << "Point + operator" << endl;
return *this;
};
private:
double _x;
double _y;
};
class Point3D :public Point {
public:
Point3D(double x = 0, double y = 0, double z = 0) :Point(x, y), _z(z) {
cout << "Point3D constructor" << endl;
};
~Point3D() {
cout << "Point3D destructor" << endl;
};
private:
double _z;
};
int main()
{
cout << "0" << endl;
Point a(1, 1);
cout << "1" << endl;
Point b(2, 2);
cout << "2" << endl;
Point c(0,0);
cout << "3" << endl;
c = a + b;
cout << "4" << endl;
Point d = a + c;
cout << "5" << endl;
c + d;
cout << "6" << endl;
system("PAUSE");
}
/*
1.若类无默认构造函数,new不会调用vec_new,仅仅做内存分配,调用malloc
2.delete基类的指针,只能释放相应的基类大小数据。
3.或者可以使用虚析构函数,则会正确删除派生类。
*/
|
d1a5f13758a3318c7071bc7ab1163d14d8cd3c92
|
08b8cf38e1936e8cec27f84af0d3727321cec9c4
|
/data/crawl/squid/old_hunk_5078.cpp
|
e19a6c97c702b9f7e931096b9638a87a5ee532d5
|
[] |
no_license
|
ccdxc/logSurvey
|
eaf28e9c2d6307140b17986d5c05106d1fd8e943
|
6b80226e1667c1e0760ab39160893ee19b0e9fb1
|
refs/heads/master
| 2022-01-07T21:31:55.446839
| 2018-04-21T14:12:43
| 2018-04-21T14:12:43
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 240
|
cpp
|
old_hunk_5078.cpp
|
}
#define free_onoff free_int
#define dump_eol dump_string
#define free_eol free_string
#define dump_debug dump_string
#define free_debug free_string
static void
dump_refreshpattern(StoreEntry * entry, const char *name, refresh_t * head)
|
5bab507b5ace53ee6d39e2bd361bd39785f6a792
|
c96a8c199c4e7f8b636d4ce94926d708ccdd4992
|
/src/graphic/Blender.cpp
|
d15b3ccc36113bcf84165c11559d1db036d87c2e
|
[
"MIT"
] |
permissive
|
Kaosumaru/libmx
|
b662db96e52d9c7805a20b41a96a509357f36c41
|
7f412a7b845a315da02deb279fb208c739fb2f30
|
refs/heads/master
| 2020-08-04T01:50:37.197501
| 2020-02-02T15:24:23
| 2020-02-02T15:24:23
| 73,533,925
| 0
| 0
|
MIT
| 2019-12-18T19:50:53
| 2016-11-12T05:39:35
|
C++
|
UTF-8
|
C++
| false
| false
| 2,049
|
cpp
|
Blender.cpp
|
#include "Blender.h"
#include "OpenGL.h"
#include "graphic/renderer/TextureRenderer.h"
using namespace MX;
using namespace Graphic;
Blender::Blender(int op, int src, int dst)
{
_op = op;
_src = src;
_dst = dst;
_alpha_op = GL_FUNC_ADD;
_alpha_src = GL_ZERO;
_alpha_dst = GL_ONE;
}
Blender::Blender(int op, int src, int dst, int alpha_op, int alpha_src, int alpha_dst)
{
_op = op;
_src = src;
_dst = dst;
_alpha_op = alpha_op;
_alpha_src = alpha_src;
_alpha_dst = alpha_dst;
}
Blender::~Blender()
{
}
bool Blender::operator==(const Blender& other) const
{
if (_op == other._op && _src == other._src && _dst == other._dst && _alpha_op == other._alpha_op && _alpha_src == other._alpha_src && _alpha_dst == other._alpha_dst)
return true;
return false;
}
Blender& Blender::defaultNormal()
{
static Graphic::Blender blender(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD, GL_ZERO, GL_ONE);
return blender;
}
Blender& Blender::defaultAdditive()
{
static Graphic::Blender blender(GL_FUNC_ADD, GL_SRC_ALPHA, GL_ONE, GL_FUNC_ADD, GL_ZERO, GL_ONE);
return blender;
}
Blender& Blender::defaultCopy()
{
static Graphic::Blender blender(GL_FUNC_ADD, GL_ONE, GL_ZERO, GL_FUNC_ADD, GL_ONE, GL_ZERO);
return blender;
}
Blender& Blender::defaultPremultiplied()
{
static Graphic::Blender blender(GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD, GL_ZERO, GL_ONE);
return blender;
}
void Blender::Apply()
{
Graphic::TextureRenderer::current().Flush();
if (_alpha_op == -1)
{
glBlendFunc(_src, _dst);
glBlendEquation(_op);
}
else
{
glBlendFuncSeparate(_src, _dst, _alpha_src, _alpha_dst);
glBlendEquationSeparate(_op, _alpha_op);
}
}
void Blender::CurrentWasSet(Blender* target, Blender* old_target)
{
if (target == old_target)
return;
if (target == nullptr)
{
Graphic::TextureRenderer::current().Flush();
return;
}
target->Apply();
}
|
a2d0ff2ecce07fe564057f152bc6262952754280
|
6f06493bf8df1900ef5352208a2b8ebd2bfac37f
|
/OpenGLProject/transform.cpp
|
0e24b4d89af492d9216add02dfe3a87bee43a43a
|
[] |
no_license
|
Cresspresso/RocketChess
|
c5df0f107cae1fc392976b9f2fb442c67e56431a
|
96c0372317e5f4ca2d866094f02e95f341794ce2
|
refs/heads/master
| 2022-03-14T06:40:50.469855
| 2019-11-11T01:42:51
| 2019-11-11T01:42:51
| 198,104,578
| 1
| 0
| null | 2019-09-02T04:31:58
| 2019-07-21T20:56:09
|
C++
|
UTF-8
|
C++
| false
| false
| 892
|
cpp
|
transform.cpp
|
/*
** Bachelor of Software Engineering
** Media Design School
** Auckland
** New Zealand
**
** (c) 2019 Media Design School
**
** File : transform.cpp
**
** Summary : Component that represents position, rotation, and scale relative to a parent Transform.
**
** Project : Robotron Summative
** Author : Elijah Shadbolt
** Email : elijah.sha7979@mediadesign.school.nz
** Date Edited : 10/06/2019
*/
#include "transform.hpp"
void Transform::recalculateLocalMatrix()
{
localMatrix = makeLocalMatrix();
}
void Transform::recalculateModelMatrix()
{
if (auto parent = this->parent.lock())
{
modelMatrix = parent->modelMatrix * localMatrix;
}
else
{
modelMatrix = localMatrix;
}
}
void Transform::recalculateViewMatrix()
{
viewMatrix = glm::inverse(viewMatrix);
}
void Transform::recalculate()
{
recalculateLocalMatrix();
recalculateModelMatrix();
recalculateViewMatrix();
}
|
40db4422d6cf8edf241b4ac5839bfb8ddaceb2c8
|
453156d45af7d0fbdd905f342ac726037e3680aa
|
/main.cpp
|
280daa87d2c0a8ed81d20a45000c4d18db92406a
|
[] |
no_license
|
Noura2000/10110-Light-more-light
|
12b31ee5d715281a7d8d4ef34b23ff6a9bccefb5
|
62a59616b2f09ad59b1d030799b62d332c78733f
|
refs/heads/master
| 2022-11-06T10:35:12.373349
| 2020-06-27T13:49:14
| 2020-06-27T13:49:14
| 275,381,466
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 286
|
cpp
|
main.cpp
|
#include <bits/stdc++.h>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
long n;
while (scanf("%ld",&n) && n != 0)
{
long root;
root = sqrt(n);
if (root*root!=n)
cout << "no" << endl;
else
cout << "yes" << endl;
}
return 0;
}
|
7fe38690b9a48207b40828e0b71f51ddad344069
|
cb80a8562d90eb969272a7ff2cf52c1fa7aeb084
|
/inletTest3/0.124/p
|
2599b45afe2addb53bf87b5f186550519c04b6bc
|
[] |
no_license
|
mahoep/inletCFD
|
eb516145fad17408f018f51e32aa0604871eaa95
|
0df91e3fbfa60d5db9d52739e212ca6d3f0a28b2
|
refs/heads/main
| 2023-08-30T22:07:41.314690
| 2021-10-14T19:23:51
| 2021-10-14T19:23:51
| 314,657,843
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 116,276
|
p
|
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2006 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0.124";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField nonuniform List<scalar>
16277
(
147985
147991
147994
147980
147990
147987
147988
147991
147995
148000
148005
148011
148017
148023
148030
148036
148043
148051
148058
148066
148074
148082
148091
148100
148109
148119
148128
148138
148149
148159
148170
148181
148192
148204
148215
148227
148239
148251
148263
148276
148288
148301
148313
148326
148339
148352
148364
148377
148390
148403
148416
148428
148441
148454
148466
148479
148491
148503
148515
148527
148539
148550
148561
148572
148583
148594
148604
148614
148624
148634
148643
148652
148660
148669
148677
148684
148691
148698
148705
148711
148717
148723
148728
148732
148734
148736
148736
148736
148735
148737
148736
148740
148745
148755
148771
148783
148790
148779
148778
148774
148771
148772
148773
148767
148767
148767
148762
148762
148762
148758
148758
148758
148754
148754
148754
148752
148752
148752
148750
148749
148749
148748
148748
148748
148747
148746
148746
148746
148746
148746
148745
148745
148745
148745
148745
148745
148745
148745
148745
148745
148745
148745
148746
148745
148745
148746
148747
148747
148748
148747
148747
148749
148749
148749
148750
148750
148750
148752
148752
148752
148754
148753
148753
148756
148756
148756
148758
148758
148758
148760
148760
148761
148763
148763
148762
148765
148766
148766
148768
148768
148768
148771
148772
148772
148774
148774
148774
148778
148778
148778
148781
148781
148781
148785
148785
148785
148789
148789
148788
148793
148793
148793
148797
148797
148797
148801
148801
148802
148806
148805
148805
148810
148810
148811
148815
148815
148815
148820
148820
148820
148825
148825
148824
148830
148830
148830
148835
148835
148835
148841
148841
148841
148846
148846
148846
148852
148853
148853
148858
148858
148858
148864
148865
148865
148871
148870
148870
148877
148877
148878
148884
148883
148883
148891
148891
148891
148897
148897
148897
148904
148905
148905
148912
148911
148911
148919
148919
148919
148927
148926
148926
148934
148934
148935
148942
148942
148942
148950
148950
148951
148958
148958
148958
148967
148967
148967
148975
148975
148975
148984
148984
148984
148992
148992
148992
149001
149001
149002
149010
149010
149010
149019
149020
149020
149029
149028
149028
149038
149038
149039
149048
149047
149047
149057
149057
149058
149067
149066
149066
149076
149077
149077
149086
149086
149086
149096
149096
149096
149106
149105
149105
149115
149116
149116
149125
149125
149125
149135
149135
149135
149145
149144
149144
149154
149154
149154
149163
149163
149163
149173
149173
149173
149182
149181
149181
149190
149190
149191
149199
149198
149198
149207
149207
149207
149214
149214
149214
149222
149222
149222
149228
149228
149228
149235
149235
149235
149240
149240
149240
149245
149246
149246
149250
149250
149249
149253
149254
149254
149256
149256
149256
149259
149259
149259
149259
149259
149259
149260
149260
149260
149260
149260
149260
149259
149259
149259
149256
149256
149257
149254
149254
149254
149249
149249
149250
149245
149245
149245
149239
149239
149240
149234
149234
149234
149227
149227
149227
149221
149221
149220
149212
149213
149213
149206
149206
149205
149197
149197
149197
149190
149189
149189
149180
149180
149181
149173
149173
149172
149163
149163
149164
149156
149155
149155
149146
149147
149147
149139
149139
149138
149130
149130
149130
149123
149123
149122
149114
149115
149115
149108
149108
149107
149100
149100
149100
149094
149094
149094
149087
149087
149087
149082
149082
149081
149075
149076
149076
149071
149071
149071
149065
149066
149066
149062
149062
149061
149057
149057
149057
149054
149054
149053
149049
149050
149050
149047
149047
149047
149043
149043
149044
149041
149041
149041
149038
149038
149038
149036
149036
149036
149033
149033
149034
149032
149032
149032
149029
149030
149030
149029
149029
149028
149027
149027
149027
149025
149026
149026
149024
149024
149024
149023
149023
149024
149022
149022
149021
149020
149021
149021
149020
149019
149019
149018
149019
149019
149018
149017
149017
149016
149016
149016
149015
149015
149016
149015
149014
149014
149012
149013
149014
149013
149013
149012
149011
149011
149012
149011
149011
149011
149009
149010
149011
149009
149009
149009
149008
149008
149009
149009
149008
149008
149006
149007
149007
149007
149006
149006
149005
149006
149006
149004
149004
149004
149004
149003
149003
149003
149004
149004
149001
149001
149001
149000
149000
149001
148999
148999
148999
148999
149000
149000
149008
149008
149006
148981
148978
148979
148986
148995
149000
149001
149000
149001
149000
149000
149000
149000
149000
149000
149000
149000
149001
149000
149002
149001
149001
149002
149003
149004
149005
149005
149004
149004
149002
148998
148994
148999
149002
149003
148998
148991
148997
148998
148998
148997
148998
149000
149000
148999
148999
148999
148999
149000
149000
149000
149000
149000
149001
149001
149001
149001
149001
149001
149002
149002
149002
149002
149002
149003
149003
149002
149003
149003
149003
149003
149003
149003
149003
149004
149004
149004
149004
149004
149004
149004
149005
149005
149005
149005
149005
149005
149005
149005
149005
149006
149006
149006
149005
149006
149006
149006
149006
149006
149006
149006
149007
149007
149007
149007
149007
149007
149007
149008
149008
149007
149007
149008
149008
149008
149008
149008
149008
149009
149009
149008
149009
149009
149009
149009
149009
149009
149009
149009
149009
149010
149010
149009
149010
149010
149010
149011
149010
149010
149010
149010
149011
149011
149011
149011
149011
149011
149011
149011
149011
149012
149012
149011
149011
149011
149012
149012
149012
149012
149012
149012
149012
149013
149013
149012
149012
149012
149013
149013
149013
149013
149013
149013
149013
149013
149014
149013
149013
149013
149013
149013
149013
149014
149014
149014
149014
149013
149013
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149015
149015
149014
149014
149014
149014
149014
149015
149014
149014
149014
149014
149014
149014
149014
149013
149013
149014
149014
149014
149013
149013
149013
149013
149014
149013
149013
149013
149012
149013
149013
149013
149012
149012
149011
149012
149012
149012
149011
149011
149010
149011
149011
149011
149010
149009
149009
149009
149009
149008
149008
149009
149008
149008
149007
149006
149007
149007
149006
149005
149005
149005
149004
149003
149002
149002
149004
149002
149001
149000
148998
148999
149001
148999
148997
148996
148995
148995
148995
148991
148993
148994
148992
148990
148987
148984
148987
148989
148984
148984
148982
148981
148979
148978
148972
148974
148978
148969
148967
148966
148958
148959
148960
148955
148954
148954
148946
148949
148952
148950
148948
148945
148947
148949
148951
148953
148951
148949
148952
148954
148956
148959
148957
148955
148957
148960
148963
148969
148966
148964
148971
148973
148975
148979
148977
148975
148978
148981
148984
148988
148986
148985
149007
149003
148999
149016
149026
149027
148942
148987
148954
148984
148990
148998
149016
149010
149001
149019
149016
149013
149013
149021
149034
149031
149030
149029
149035
149034
149033
149031
149044
149053
149059
149052
149038
149061
149059
149058
149044
149061
149087
149082
149077
149070
149106
149104
149097
149035
149094
149021
149072
149075
149089
149108
149095
149088
149111
149106
149096
149121
149115
149110
149121
149123
149125
149134
149130
149127
149152
149150
149149
149157
149164
149161
149172
149106
149132
149170
149159
149149
149175
149176
149176
149191
149191
149190
149204
149202
149197
149218
149215
149209
149248
149248
149244
149200
149262
149185
149235
149235
149239
149269
149264
149261
149271
149277
149283
149299
149299
149296
149334
149327
149317
149272
149352
149285
149371
149342
149299
149370
149366
149360
149381
149388
149390
149411
149425
149434
149393
149466
149375
149403
149459
149495
149478
149489
149492
149530
149528
149522
149556
149561
149559
149593
149587
149579
149645
149651
149654
149684
149699
149694
149787
149712
149744
149820
149823
149814
149899
149900
149887
149996
150004
149998
150148
150125
150087
150120
150171
150189
150274
150219
150164
150123
150178
150227
149991
149988
149957
149683
149687
149633
149308
149379
149394
149221
149168
149080
149058
149085
149096
149013
148974
148913
148944
148968
148981
148889
148910
148910
148792
148969
148842
148875
148839
148870
148841
148848
148849
148866
148853
148836
148821
148834
148846
148823
148811
148804
148810
148829
148843
148836
148822
148814
148804
148807
148808
148838
148822
148805
148796
148811
148837
148802
148801
148803
148810
148831
148855
148856
148808
148779
148804
148801
148801
148855
148838
148822
148777
148808
148860
148798
148796
148798
148851
148845
148827
148826
148831
148835
148796
148798
148805
148829
148847
148854
148856
148837
148807
148802
148809
148815
148861
148859
148848
148825
148840
148849
148921
148838
148707
148735
148906
148824
148923
148863
148797
148869
148823
148784
148856
148756
148838
148859
148868
148853
148871
148844
148819
148786
148888
148787
148863
148853
148854
148853
148831
148811
148851
148760
148821
148850
148862
148856
148836
148843
148851
148823
148759
148880
148873
148863
148817
148820
148839
148861
148751
148861
148804
148875
148861
148855
148870
148841
148814
148777
148888
148780
148888
148855
148821
148803
148822
148844
148707
148878
148801
148889
148840
148856
148788
148804
148832
148847
148848
148843
148836
148825
148805
148802
148792
148791
148829
148839
148845
148833
148818
148810
148805
148800
148804
148847
148829
148812
148780
148801
148840
148778
148780
148787
148839
148825
148796
148779
148807
148826
148775
148777
148789
148818
148832
148833
148827
148790
148753
148710
148854
148709
148829
148789
148787
148752
148766
148768
148783
148797
148810
148797
148783
148780
148750
148744
148750
148800
148785
148768
148758
148753
148762
148701
148806
148676
148782
148759
148761
148734
148734
148730
148782
148780
148770
148746
148755
148764
148710
148707
148712
148771
148751
148731
148717
148717
148733
148663
148774
148643
148748
148719
148723
148696
148699
148696
148736
148742
148745
148719
148709
148705
148673
148669
148675
148733
148699
148669
148651
148679
148706
148655
148548
148739
148680
148708
148651
148639
148664
148683
148683
148692
148697
148671
148660
148663
148578
148677
148603
148653
148646
148671
148614
148621
148622
148659
148632
148607
148585
148611
148646
148601
148545
148618
148630
148643
148623
148599
148603
148615
148620
148617
148605
148582
148589
148589
148610
148507
148566
148574
148600
148578
148550
148544
148544
148587
148572
148555
148535
148542
148569
148502
148578
148484
148598
148566
148566
148526
148529
148525
148533
148535
148533
148524
148506
148484
148567
148379
148490
148473
148561
148476
148503
148468
148446
148466
148495
148506
148457
148460
148466
148495
148503
148503
148484
148473
148463
148416
148442
148417
148457
148450
148449
148416
148415
148415
148429
148427
148417
148412
148402
148387
148472
148272
148390
148373
148463
148368
148402
148368
148354
148383
148415
148430
148367
148367
148372
148379
148376
148366
148360
148348
148342
148277
148369
148259
148353
148318
148333
148298
148302
148297
148320
148323
148320
148281
148276
148275
148312
148309
148296
148283
148290
148290
148321
148207
148267
148268
148314
148277
148245
148230
148227
148239
148252
148253
148208
148207
148208
148226
148228
148224
148207
148201
148201
148142
148202
148126
148210
148186
148196
148161
148164
148158
148194
148194
148187
148152
148148
148148
148150
148165
148176
148135
148128
148135
148008
148172
148053
148125
148072
148173
148064
148081
148069
148097
148093
148089
148040
148049
148060
148089
148077
148060
148040
148039
148056
147977
148110
147937
148114
148016
148064
148005
148016
148009
148016
148018
148020
147977
147970
147966
147978
147983
147980
147943
147937
147936
147956
147959
147954
147934
147931
147921
147983
147804
147910
147899
147980
147879
147892
147870
147877
147892
147909
147910
147885
147871
147863
147874
147881
147880
147831
147830
147834
147846
147848
147843
147822
147811
147808
147732
147849
147695
147838
147756
147801
147746
147752
147739
147766
147770
147772
147732
147724
147720
147740
147744
147740
147705
147698
147695
147734
147736
147729
147688
147702
147725
147570
147739
147618
147690
147620
147736
147615
147636
147626
147649
147645
147644
147579
147588
147598
147607
147611
147606
147560
147561
147568
147576
147585
147585
147530
147546
147553
147528
147396
147616
147488
147614
147511
147497
147491
147515
147524
147521
147501
147455
147460
147470
147470
147473
147465
147422
147419
147420
147434
147437
147430
147392
147389
147390
147398
147407
147407
147359
147370
147392
147206
147434
147278
147373
147256
147434
147281
147316
147296
147331
147327
147327
147274
147278
147283
147293
147299
147297
147234
147237
147245
147248
147255
147252
147198
147198
147202
147210
147215
147211
147178
147172
147174
147097
147194
147065
147197
147121
147161
147099
147110
147101
147115
147116
147115
147066
147060
147055
147074
147080
147076
147035
147030
147032
147054
147054
147045
147000
146997
146998
147008
147013
147010
146957
146974
147000
146806
147023
146876
146970
146868
147023
146880
146905
146890
146908
146904
146906
146833
146845
146853
146862
146867
146864
146797
146803
146813
146821
146828
146825
146776
146774
146776
146784
146790
146785
146765
146751
146747
146656
146766
146609
146775
146684
146730
146657
146671
146659
146670
146671
146671
146616
146609
146602
146630
146632
146626
146573
146563
146559
146583
146585
146578
146529
146526
146526
146537
146542
146537
146482
146498
146523
146307
146563
146390
146497
146355
146562
146387
146424
146402
146424
146416
146418
146350
146360
146365
146367
146369
146364
146299
146303
146311
146316
146321
146316
146263
146260
146263
146265
146273
146270
146208
146207
146211
146216
146224
146220
146181
146180
146174
146113
146067
146136
146128
146166
146129
146079
146067
146079
146078
146086
146075
146013
146007
146012
146023
146027
146020
145967
145963
145965
145971
145976
145969
145917
145915
145917
145925
145929
145920
145875
145887
145903
145749
145870
145788
145847
145800
145880
145770
145784
145768
145788
145794
145796
145703
145712
145723
145723
145728
145723
145659
145658
145664
145656
145663
145659
145591
145591
145594
145592
145596
145588
145549
145552
145545
145488
145429
145535
145485
145534
145491
145442
145434
145449
145451
145458
145443
145378
145374
145381
145393
145394
145382
145318
145311
145310
145322
145325
145316
145255
145253
145255
145258
145259
145248
145187
145203
145220
145066
145154
145095
145135
145094
145159
145037
145061
145050
145057
145057
145058
144978
144985
144990
145000
145004
144999
144935
144934
144939
144934
144942
144938
144860
144861
144865
144866
144878
144876
144829
144817
144810
144709
144737
144690
144763
144736
144746
144674
144680
144673
144679
144674
144665
144581
144580
144576
144567
144570
144565
144479
144462
144444
144479
144488
144481
144423
144446
144475
144252
144459
144330
144405
144338
144446
144304
144320
144305
144321
144322
144326
144216
144229
144239
144238
144241
144234
144149
144153
144162
144155
144168
144167
144086
144091
144083
143987
143883
144054
143967
144043
143973
143906
143884
143901
143849
143872
143863
143762
143740
143737
143783
143789
143779
143719
143715
143715
143727
143732
143718
143638
143675
143714
143444
143696
143528
143610
143521
143652
143472
143497
143486
143502
143502
143506
143380
143395
143410
143385
143384
143373
143268
143273
143286
143266
143279
143278
143220
143191
143165
143008
143095
142953
143017
142984
143029
142935
142946
142927
142982
142982
142967
142893
142887
142885
142897
142902
142892
142805
142801
142800
142812
142814
142798
142720
142741
142764
142551
142645
142589
142629
142597
142650
142527
142540
142524
142491
142497
142506
142366
142373
142369
142343
142355
142357
142285
142246
142215
142020
142106
141879
142086
142047
142089
142008
142026
142012
142046
142043
142027
141940
141935
141933
141933
141939
141928
141825
141815
141813
141814
141820
141806
141716
141728
141734
141582
141542
141562
141571
141607
141577
141466
141455
141474
141415
141432
141411
141263
141253
141271
141199
141212
141204
140958
141010
141048
140918
140894
140871
140999
141006
140990
140915
140913
140913
140906
140914
140901
140793
140791
140793
140778
140785
140770
140670
140679
140684
140509
140495
140495
140512
140527
140531
140387
140392
140398
140342
140359
140358
140214
140202
140189
139941
139932
139947
139838
139868
139882
139731
139686
139650
139739
139762
139762
139690
139686
139687
139707
139714
139695
139606
139618
139634
139415
139449
139420
139446
139440
139466
139308
139320
139320
139263
139279
139287
139120
139120
139105
138866
138869
138881
138893
138866
138862
138700
138692
138674
138448
138496
138520
138346
138291
138227
138152
138162
138205
138297
138327
138314
138197
138200
138206
138187
138210
138206
138084
138070
138055
137810
137850
137794
137828
137793
137821
137668
137684
137674
137597
137589
137574
137362
137378
137381
137057
137033
137041
136952
136898
136968
136447
136596
136663
136664
136648
136609
136564
136583
136588
136479
136435
136522
136501
136540
136485
136367
136352
136369
136321
136339
136313
136136
136141
136161
135802
135821
135808
135796
135792
135837
135552
135575
135570
135351
135370
135378
134901
134962
135018
134581
134452
134318
134653
134688
134696
134663
134665
134648
134556
134472
134528
134509
134567
134514
134328
134314
134344
134247
134278
134260
134024
134012
134010
133610
133596
133609
133570
133563
133546
133273
133282
133272
132584
132566
132724
132524
132426
132306
132342
132391
132433
132290
132233
132291
132402
132415
132370
132223
132213
132205
132169
132174
132145
131890
131903
131908
131432
131412
131426
131300
131319
131329
130929
130943
130951
130267
130090
130025
129727
129890
130029
129950
129874
129800
129778
129797
129817
129918
129951
129942
129799
129798
129788
129409
129396
129407
129294
129292
129256
128878
128880
128896
128107
128114
128164
127647
127465
127272
126868
127132
127329
127196
127118
126991
126995
127105
127074
127221
127247
127254
127044
127073
127041
126546
126452
126541
126178
126195
126158
125579
125471
125448
123732
124137
124452
124035
123852
123631
124343
124390
124381
124457
124454
124453
124355
124288
124279
123731
123899
123695
123329
123308
123403
122623
122385
122077
120525
121079
121493
121195
121079
120791
121810
121794
121755
121771
121765
121742
121496
121430
121479
120606
120659
120508
118258
118409
119141
119216
119000
118772
119446
119402
119495
119484
119438
119448
119166
119186
119284
118525
118155
117617
117305
117703
117987
118081
117686
117844
118816
118905
118772
118993
118760
118328
118089
118647
118952
119155
118999
118751
119656
119800
119799
120660
120555
120268
121403
121526
121550
122419
122446
122411
123124
123143
123122
123668
123678
123663
124116
124127
124123
124521
124523
124516
124871
124877
124876
125195
125195
125191
125479
125483
125484
125749
125747
125743
125986
125989
125992
126216
126213
126210
126416
126419
126423
126614
126610
126607
126784
126787
126790
126955
126951
126948
127102
127104
127107
127250
127247
127245
127379
127381
127384
127509
127506
127505
127622
127624
127627
127738
127735
127734
127838
127839
127842
127941
127938
127936
128029
128031
128033
128121
128119
128118
128201
128202
128204
128284
128281
128280
128355
128356
128358
128430
128428
128427
128495
128496
128497
128562
128560
128560
128621
128622
128623
128683
128681
128680
128736
128737
128738
128792
128790
128790
128840
128841
128842
128891
128890
128889
128936
128936
128937
128982
128981
128980
129023
129023
129024
129065
129064
129064
129102
129103
129103
129141
129140
129140
129175
129176
129176
129211
129210
129210
129242
129243
129243
129275
129274
129274
129304
129304
129304
129333
129333
129333
129360
129360
129360
129388
129387
129387
129412
129412
129412
129437
129437
129437
129460
129460
129460
129483
129483
129482
129504
129504
129504
129525
129525
129524
129544
129544
129544
129563
129563
129563
129581
129581
129581
129599
129599
129599
129615
129615
129615
129632
129632
129632
129647
129647
129647
129662
129662
129662
129676
129676
129676
129690
129690
129690
129703
129703
129703
129716
129716
129716
129728
129728
129728
129740
129740
129740
129751
129751
129751
129762
129762
129762
129772
129772
129772
129783
129783
129783
129792
129792
129792
129801
129802
129801
129810
129810
129810
129819
129819
129819
129827
129827
129827
129835
129835
129835
129842
129842
129842
129850
129850
129850
129857
129857
129857
129864
129864
129864
129870
129870
129870
129876
129876
129876
129882
129882
129882
129888
129888
129888
129893
129893
129893
129899
129899
129899
129904
129904
129904
129909
129909
129909
129914
129914
129913
129918
129918
129918
129922
129923
129922
129927
129927
129927
129931
129931
129931
129935
129935
129935
129939
129939
129938
129943
129943
129943
129946
129946
129946
129950
129949
129949
129953
129952
129952
129956
129956
129956
129959
129959
129958
129962
129962
129962
129964
129964
129964
129967
129967
129967
129970
129969
129969
129972
129972
129972
129974
129974
129974
129977
129977
129977
129979
129979
129979
129981
129981
129981
129983
129983
129983
129985
129985
129985
129986
129986
129986
129989
129988
129988
129990
129990
129990
129992
129992
129992
129993
129993
129993
129995
129995
129995
129996
129996
129996
129997
129997
129997
129998
129998
129998
130000
130000
130000
130001
130001
130001
130002
130002
130002
130003
130003
130003
130004
130004
130004
130005
130005
130005
130006
130006
130006
130007
130007
130007
130008
130008
130008
130008
130008
130008
130009
130009
130009
130010
130010
130009
130010
130010
130010
130011
130011
130011
130011
130011
130011
130012
130012
130012
130012
130012
130012
130012
130012
130012
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130014
130013
130014
130013
130014
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130013
130012
130012
130012
130012
130012
130012
130011
130011
130011
130011
130011
130011
130010
130010
130010
130010
130010
130010
130009
130009
130009
130009
130009
130009
130008
130008
130008
130007
130007
130007
130006
130006
130006
130005
130005
130005
130004
130004
130004
130003
130003
130003
130002
130002
130002
130001
130001
130001
130000
129999
129999
129998
129998
129998
129997
129997
129997
129996
129996
129996
129994
129994
129994
129993
129993
129993
129992
129992
129991
129990
129990
129990
129989
129989
129989
129988
129988
129988
129986
129986
129986
129985
129985
129985
129983
129983
129983
129982
129982
129982
129980
129980
129980
129980
129980
129980
129979
129979
129979
129977
129977
129977
129973
129973
129973
129967
129967
129968
129965
129964
129963
129972
129973
129973
130004
130006
130007
130031
130027
130024
130040
130067
130036
130014
129986
130035
130070
130028
130003
130029
130055
130044
130028
130019
130014
130012
130011
130012
130012
130012
130012
130013
130013
130013
130013
130012
130012
130012
130011
130011
130010
130011
130010
130008
130010
130016
130021
130029
130037
130047
130058
130071
130083
130094
130102
130106
130109
130113
130118
130125
130132
130141
130151
130161
130173
130186
130201
130218
130236
130257
130281
130307
130338
130373
130412
130457
130507
130565
130629
130702
130783
130874
130976
131090
131216
131355
131509
131678
131863
132064
132282
132516
132767
133033
133315
133612
133922
134244
134577
134918
135267
135622
135981
136342
136704
137065
137424
137780
138131
138478
138818
139151
139477
139794
140104
140404
140696
140979
141253
141517
141773
142020
142258
142487
142708
142921
143126
143323
143512
143694
143869
144037
144199
144354
144503
144646
144783
144915
145042
145164
145281
145393
145501
145605
145705
145801
145893
145981
146066
146148
146226
146301
146374
146444
146511
146575
146637
146697
146754
146810
146863
146914
146963
147010
147056
147099
147142
147182
147221
147259
147295
147329
147363
147395
147426
147455
147484
147511
147538
147563
147587
147611
147633
147654
147675
147695
147714
147732
147749
147766
147782
147797
147811
147825
147838
147851
147862
147874
147884
147894
147904
147912
147921
147928
147935
147942
147948
147954
147958
147963
147967
147970
147976
147983
147989
147992
147992
147994
147982
147989
147989
147997
148005
148009
148014
148018
148023
148028
148033
148038
148044
148050
148057
148064
148071
148078
148086
148095
148103
148112
148121
148131
148141
148151
148161
148172
148183
148194
148205
148217
148228
148240
148252
148264
148277
148289
148301
148314
148327
148339
148352
148365
148378
148391
148403
148416
148429
148441
148454
148466
148479
148491
148503
148515
148527
148539
148550
148561
148572
148583
148593
148604
148614
148623
148633
148642
148650
148659
148667
148675
148682
148689
148695
148701
148707
148713
148718
148723
148727
148731
148732
148733
148735
148740
148749
148755
148758
148754
148752
148750
148748
148747
148746
148746
148746
148745
148746
148746
148747
148748
148750
148751
148753
148754
148757
148758
148761
148763
148766
148769
148772
148775
148779
148782
148786
148789
148794
148797
148802
148806
148811
148815
148821
148825
148831
148836
148842
148847
148853
148859
148865
148871
148878
148884
148891
148898
148905
148912
148920
148927
148935
148942
148951
148959
148968
148975
148985
148993
149002
149011
149020
149029
149039
149048
149058
149067
149077
149086
149097
149106
149116
149126
149136
149145
149155
149164
149174
149182
149191
149199
149208
149215
149223
149229
149236
149241
149246
149250
149254
149256
149259
149260
149261
149260
149259
149257
149254
149249
149245
149239
149234
149226
149220
149212
149205
149196
149189
149179
149172
149162
149155
149145
149138
149129
149122
149113
149107
149099
149093
149086
149081
149075
149070
149065
149061
149056
149053
149049
149047
149043
149041
149038
149036
149033
149032
149030
149029
149026
149025
149023
149023
149021
149020
149019
149018
149017
149016
149015
149015
149013
149013
149012
149011
149010
149010
149009
149009
149007
149007
149006
149005
149004
149004
149001
149002
149001
149002
149005
149003
149003
149004
149003
149001
149001
149002
149002
149002
149004
149003
149004
149005
149005
149005
149007
149006
149007
149008
149008
149009
149010
149009
149010
149011
149011
149011
149013
149012
149013
149015
149014
149015
149016
149016
149017
149018
149018
149018
149020
149020
149021
149023
149022
149023
149025
149024
149026
149028
149027
149029
149032
149030
149033
149036
149034
149037
149040
149039
149042
149046
149044
149048
149052
149050
149054
149060
149057
149063
149069
149066
149072
149079
149077
149084
149091
149089
149096
149105
149102
149111
149119
149118
149126
149135
149134
149142
149152
149151
149159
149169
149169
149177
149187
149186
149194
149203
149204
149210
149219
149220
149225
149233
149234
149238
149245
149248
149249
149255
149258
149257
149260
149263
149261
149262
149265
149261
149261
149264
149258
149257
149259
149252
149249
149251
149243
149239
149239
149231
149226
149226
149217
149211
149210
149201
149195
149193
149184
149177
149175
149166
149159
149157
149147
149140
149137
149127
149120
149118
149108
149101
149098
149088
149081
149078
149069
149062
149059
149050
149043
149040
149031
149024
149021
149012
149006
149003
148994
148988
148985
148977
148971
148968
148960
148954
148952
148944
148938
148936
148928
148923
148921
148913
148908
148906
148899
148894
148892
148885
148881
148879
148872
148868
148866
148860
148856
148854
148848
148844
148843
148837
148833
148832
148826
148823
148822
148816
148813
148812
148807
148804
148803
148798
148796
148795
148790
148788
148787
148783
148781
148780
148776
148774
148774
148770
148768
148768
148764
148763
148763
148759
148758
148758
148755
148754
148754
148752
148751
148751
148749
148748
148749
148747
148747
148747
148746
148746
148747
148746
148747
148747
148747
148748
148748
148749
148751
148749
148753
148743
148745
148746
148747
148748
148750
148753
148756
148760
148764
148770
148776
148782
148789
148797
148805
148814
148823
148834
148844
148856
148868
148880
148893
148907
148922
148937
148952
148969
148986
149003
149022
149040
149060
149079
149099
149119
149139
149159
149178
149197
149215
149231
149246
149258
149267
149272
149274
149272
149266
149254
149239
149222
149205
149186
149167
149148
149130
149114
149098
149085
149073
149062
149054
149047
149041
149037
149033
149029
149026
149024
149022
149020
149018
149016
149014
149013
149011
149010
149008
149007
149005
149004
149003
149002
149002
149001
149002
149002
149000
149002
149000
149001
149001
149001
149000
149001
149002
149003
149004
149005
149006
149008
149009
149010
149012
149013
149015
149016
149018
149020
149022
149020
149019
149017
149016
149014
149013
149012
149010
149009
149008
149006
149005
149004
149003
149002
149001
149001
149000
149001
149001
149000
149001
149001
149002
149003
149004
149004
149003
149002
149001
149000
149001
149002
149000
149000
149001
149001
149001
149002
149003
149005
149005
149005
149006
149007
149009
149009
149007
149006
149006
149007
149008
149008
149007
149007
149006
149006
149005
149004
149003
149003
149002
149001
149000
149001
149001
148999
149000
149001
149002
149003
149003
149002
149001
149000
149001
149000
148999
149000
149001
148999
149000
149000
149001
149000
149000
149000
148999
148999
148998
148998
149000
149002
149004
149001
149001
149002
149001
149001
149002
149002
149002
149002
149003
149003
149002
149003
149003
149004
149003
149003
149004
149003
149003
149003
149002
149002
149001
149004
149004
149005
149004
149004
149005
149005
149005
149005
149006
149006
149005
149005
149006
149006
149006
149006
149006
149006
149006
149005
149005
149005
149004
149007
149007
149007
149006
149007
149008
149008
149007
149007
149008
149009
149008
149008
149009
149009
149008
149008
149009
149009
149009
149008
149008
149007
149007
149007
149009
149009
149010
149010
149010
149010
149010
149011
149013
149014
149013
149012
149011
149011
149012
149013
149014
149014
149015
149016
149017
149018
149017
149016
149015
149015
149015
149015
149015
149014
149015
149014
149014
149014
149014
149013
149013
149012
149012
149011
149011
149010
149010
149009
149009
149010
149010
149010
149011
149010
149010
149010
149010
149010
149010
149009
149011
149011
149011
149011
149011
149011
149011
149011
149012
149012
149011
149011
149012
149012
149012
149012
149013
149013
149012
149012
149013
149013
149013
149013
149013
149013
149012
149012
149012
149012
149011
149013
149013
149014
149013
149013
149014
149014
149013
149013
149014
149015
149014
149014
149014
149015
149014
149014
149014
149014
149014
149014
149014
149014
149013
149014
149015
149015
149014
149014
149015
149015
149014
149014
149015
149015
149014
149014
149014
149015
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149014
149015
149015
149015
149017
149019
149022
149024
149026
149028
149031
149035
149040
149045
149053
149062
149074
149087
149103
149120
149139
149160
149180
149177
149154
149131
149111
149092
149076
149063
149052
149043
149037
149033
149029
149027
149025
149023
149020
149021
149022
149016
149017
149017
149015
149014
149012
149009
149015
149023
149024
149027
149031
149016
149014
149014
149004
149000
148999
148982
148985
148991
148996
149000
149003
149006
149007
149010
149011
149013
149013
149014
149014
149014
149014
149014
149014
149013
149013
149014
149013
149013
149013
149013
149013
149013
149013
149012
149012
149012
149013
149012
149012
149011
149011
149011
149012
149011
149010
149010
149011
149009
149009
149008
149009
149007
149007
149006
149007
149005
149005
149004
149006
149007
149008
149009
149010
149010
149003
149004
149005
149002
149002
149001
149002
149000
148999
148997
148999
148995
148994
148992
148994
148991
148989
148989
148992
148994
148996
148997
148999
149001
148985
148986
148989
148985
148982
148978
148982
148977
148974
148969
148975
148972
148965
148963
148970
148981
148970
148963
148956
148957
148960
148965
148970
148975
148980
148956
148963
148970
148981
149003
149023
149039
149049
149063
149080
149067
149048
149034
149014
149030
149050
149073
149088
149100
149122
149148
149175
149171
149140
149112
149099
149130
149165
149146
149130
149112
149098
149081
149069
149054
149043
149029
149019
149007
149000
148991
148986
148974
148972
148965
148967
148971
148977
148980
148985
148979
148974
148967
148963
148961
148958
148972
148978
148983
148988
148994
148988
148983
148988
148993
148998
149004
148998
149002
149008
149012
149004
149013
149018
149026
149033
149020
149014
149006
149001
149003
148996
148995
149008
149013
149020
149023
149028
149026
149037
149034
149048
149061
149076
149090
149082
149073
149064
149058
149051
149041
149045
149052
149059
149064
149068
149077
149085
149085
149094
149108
149125
149144
149163
149165
149183
149206
149206
149204
149201
149202
149222
149242
149260
149277
149285
149288
149287
149282
149272
149259
149243
149225
149206
149186
149166
149170
149191
149213
149234
149254
149272
149287
149299
149306
149306
149302
149292
149272
149249
149226
149233
149263
149292
149320
149280
149242
149248
149296
149349
149395
149353
149317
149330
149333
149330
149361
149371
149368
149415
149418
149400
149452
149485
149476
149445
149377
149308
149248
149208
149206
149183
149173
149163
149153
149145
149135
149126
149116
149106
149102
149091
149098
149076
149099
149111
149112
149121
149119
149129
149133
149143
149151
149159
149155
149149
149137
149155
149164
149170
149170
149184
149186
149206
149197
149182
149182
149196
149211
149209
149224
149232
149263
149250
149234
149237
149223
149250
149268
149271
149289
149295
149332
149317
149304
149303
149286
149288
149268
149260
149232
149307
149322
149321
149345
149338
149379
149372
149410
149425
149416
149395
149369
149344
149357
149326
149370
149398
149424
149448
149445
149475
149478
149457
149499
149534
149596
149528
149536
149575
149630
149693
149650
149558
149526
149496
149515
149484
149488
149473
149426
149528
149564
149546
149597
149617
149640
149590
149680
149663
149704
149740
149792
149752
149762
149819
149876
149837
149787
149729
149938
149951
150110
150010
149947
149878
149825
149771
149697
149655
149731
149728
149816
149854
149909
149859
149820
149745
149704
149808
149821
149885
149955
149991
150084
150029
149950
149854
149901
149694
149707
149553
149482
149322
149213
149141
149038
149028
148973
148900
148927
148880
148890
148860
148840
148855
148838
148826
148839
148827
148821
148831
148822
148820
148828
148820
148826
148826
148828
148829
148827
148832
148831
148829
148830
148861
148830
148848
148832
148835
148821
148838
148831
148842
148841
148838
148827
148828
148838
148827
148840
148824
148823
148836
148831
148827
148839
148811
148825
148819
148813
148817
148813
148806
148809
148809
148802
148795
148806
148792
148798
148794
148776
148793
148767
148779
148771
148767
148762
148761
148751
148750
148743
148744
148743
148734
148734
148722
148718
148713
148705
148707
148704
148696
148691
148680
148677
148660
148678
148653
148656
148649
148645
148640
148630
148618
148613
148602
148609
148597
148599
148581
148575
148569
148558
148552
148544
148540
148542
148529
148525
148507
148492
148493
148477
148482
148468
148462
148453
148451
148437
148423
148422
148403
148392
148394
148380
148384
148367
148359
148343
148332
148321
148310
148304
148291
148287
148275
148270
148263
148246
148240
148222
148211
148197
148187
148179
148169
148165
148150
148141
148126
148115
148099
148089
148080
148067
148051
148041
148036
148027
148016
148006
147984
147968
147955
147944
147928
147914
147907
147893
147888
147871
147863
147843
147830
147809
147797
147777
147767
147754
147738
147727
147713
147704
147685
147679
147660
147646
147631
147612
147593
147581
147568
147549
147532
147522
147505
147501
147473
147457
147438
147423
147404
147389
147366
147354
147330
147323
147308
147292
147275
147254
147239
147216
147199
147174
147157
147137
147122
147107
147082
147062
147046
147033
147009
146995
146967
146955
146925
146914
146896
146872
146847
146828
146812
146790
146774
146745
146726
146702
146683
146665
146635
146611
146589
146570
146544
146525
146495
146479
146443
146431
146409
146383
146354
146330
146307
146280
146258
146230
146207
146176
146150
146123
146097
146074
146041
146012
145988
145964
145935
145914
145880
145856
145826
145803
145779
145744
145714
145685
145655
145620
145591
145558
145526
145494
145467
145441
145406
145375
145340
145310
145274
145246
145201
145163
145129
145092
145054
145027
144990
144961
144930
144890
144858
144815
144781
144732
144700
144666
144614
144571
144527
144483
144454
144422
144371
144348
144315
144272
144230
144187
144148
144097
144045
143983
143939
143886
143834
143776
143756
143719
143674
143638
143571
143540
143494
143439
143382
143323
143270
143207
143138
143051
143018
142961
142932
142889
142835
142794
142740
142686
142629
142567
142509
142435
142361
142287
142198
142096
142077
142025
141983
141926
141863
141804
141729
141665
141572
141519
141442
141347
141244
141170
141058
140972
140957
140902
140837
140774
140693
140617
140508
140455
140366
140253
140126
139951
139910
139779
139764
139692
139637
139558
139442
139376
139284
139168
139043
138877
138797
138648
138556
138387
138278
138272
138193
138104
137989
137837
137741
137623
137477
137296
137043
136966
136733
136730
136606
136485
136446
136339
136217
136055
135832
135713
135505
135325
135040
134751
134797
134662
134525
134459
134299
134147
133919
133619
133515
133211
132787
132799
132526
132366
132352
132192
132045
131789
131423
131312
130908
130372
130435
130101
129928
129942
129724
129371
129206
128786
128180
128178
127625
127385
127217
127239
126959
126471
126321
125669
124908
124426
124752
124550
124252
123774
123666
122849
122078
121704
122131
121918
121527
120805
119678
120351
119898
119780
119601
119101
118664
118679
119408
119496
119608
119856
120377
121112
121863
122593
123226
123747
124184
124568
124910
125222
125505
125767
126006
126230
126433
126624
126798
126963
127114
127257
127389
127515
127630
127743
127845
127945
128036
128125
128207
128287
128360
128434
128499
128566
128625
128686
128740
128795
128844
128895
128939
128986
129026
129069
129106
129145
129178
129215
129245
129279
129306
129338
129362
129392
129414
129441
129462
129487
129506
129529
129546
129568
129583
129603
129617
129636
129649
129666
129677
129694
129705
129720
129729
129744
129752
129765
129773
129786
129793
129804
129811
129822
129827
129838
129843
129852
129857
129866
129870
129878
129882
129890
129894
129901
129904
129911
129914
129920
129923
129929
129931
129937
129939
129944
129946
129951
129952
129957
129959
129963
129964
129968
129969
129973
129974
129978
129979
129982
129983
129986
129986
129989
129990
129993
129993
129995
129996
129998
129998
130001
130001
130003
130003
130005
130005
130007
130006
130008
130008
130010
130009
130011
130010
130012
130011
130013
130012
130013
130013
130014
130013
130014
130013
130014
130013
130015
130013
130015
130013
130014
130013
130014
130013
130014
130012
130013
130012
130012
130011
130011
130010
130010
130009
130009
130007
130007
130006
130006
130004
130004
130001
130001
129999
129999
129996
129996
129994
129994
129991
129991
129988
129988
129986
129985
129983
129982
129980
129980
129978
129977
129974
129969
129962
129973
130008
130067
130051
130015
130009
129981
129980
130003
130015
129964
130060
130020
130010
129991
130018
129982
129983
129980
129974
129970
129982
129981
129976
129972
129975
129997
129995
129979
129984
129982
129978
129975
129987
129984
129980
129980
129981
129987
129993
129990
129991
129987
129991
129987
129983
129982
129993
129990
129986
129986
129988
129989
129994
129992
129997
129993
129989
129988
129999
129996
129992
129991
129993
129993
129992
130007
130009
130016
130033
130033
130021
130015
130013
130012
130007
129998
129999
129997
130002
129999
129994
129994
130004
130001
129997
129997
129999
129999
130005
130002
130007
130004
129999
129999
130009
130006
130002
130001
130004
130004
130005
130010
130010
130007
130012
130008
130004
130003
130013
130010
130005
130005
130007
130008
130013
130010
130015
130012
130007
130006
130016
130013
130008
130008
130010
130011
130013
130015
130012
130009
130013
130014
130016
130018
130017
130016
130016
130016
130017
130020
130026
130020
130019
130018
130018
130018
130018
130017
130016
130014
130016
130017
130019
130020
130019
130018
130018
130019
130021
130023
130022
130020
130022
130024
130025
130027
130025
130023
130021
130019
130017
130015
130013
130012
130014
130017
130019
130019
130016
130013
130012
130012
130013
130016
130019
130022
130022
130021
130024
130026
130029
130030
130027
130024
130025
130028
130031
130034
130033
130031
130029
130027
130025
130022
130020
130018
130017
130014
130016
130013
130017
130014
130009
130008
130018
130015
130010
130009
130012
130013
130017
130014
130019
130016
130010
130010
130019
130016
130011
130011
130013
130014
130015
130016
130018
130015
130020
130017
130011
130011
130020
130017
130012
130011
130014
130014
130018
130016
130020
130017
130012
130011
130020
130017
130012
130011
130014
130015
130016
130018
130018
130018
130020
130020
130021
130021
130018
130016
130018
130016
130020
130017
130012
130011
130020
130017
130011
130011
130014
130014
130017
130015
130020
130017
130011
130010
130019
130016
130011
130010
130013
130014
130016
130015
130016
130014
130019
130015
130010
130009
130017
130015
130009
130008
130012
130012
130015
130013
130017
130014
130008
130007
130015
130012
130007
130006
130009
130010
130013
130015
130017
130018
130021
130020
130019
130017
130013
130011
130012
130010
130014
130011
130005
130005
130012
130009
130003
130003
130006
130007
130009
130007
130011
130008
130001
130001
130008
130005
129999
129999
130002
130003
130007
130003
130004
130002
130006
130003
129997
129997
130003
130001
129994
129994
129997
129999
129999
129997
130001
129998
129991
129991
129998
129995
129989
129988
129992
129993
129998
130001
130006
130010
130014
130011
130007
130002
129995
129992
129993
129991
129995
129992
129985
129985
129991
129988
129982
129981
129985
129986
129986
129984
129988
129985
129977
129977
129983
129980
129973
129973
129977
129978
129985
129976
129978
129975
129979
129976
129968
129968
129973
129971
129963
129963
129967
129969
129968
129965
129969
129965
129958
129958
129962
129959
129952
129952
129956
129957
129966
129971
129980
129989
129996
129989
129980
129989
129996
130002
130008
130012
130016
130018
130020
130022
130023
130023
130023
130023
130023
130022
130024
130026
130026
130030
130028
130027
130029
130031
130033
130034
130030
130027
130027
130027
130026
130031
130031
130031
130035
130036
130036
130042
130040
130039
130038
130036
130034
130032
130034
130036
130039
130041
130038
130036
130037
130040
130043
130047
130044
130041
130043
130045
130047
130051
130049
130047
130050
130053
130056
130059
130054
130048
130042
130036
130031
130025
130024
130022
130019
130026
130028
130030
130036
130035
130034
130033
130024
130015
130011
130006
130000
130012
130017
130021
130031
130028
130025
130040
130041
130042
130043
130043
130043
130043
130049
130051
130052
130060
130058
130056
130062
130065
130069
130073
130062
130052
130053
130054
130055
130071
130068
130065
130077
130082
130088
130106
130098
130090
130084
130078
130073
130069
130065
130061
130057
130053
130049
130046
130042
130038
130035
130031
130028
130025
130021
130018
130015
130012
130012
130012
130011
130015
130018
130018
130014
130011
130011
130011
130010
130014
130017
130021
130021
130021
130025
130028
130032
130032
130028
130024
130024
130028
130033
130034
130029
130025
130021
130017
130014
130010
130010
130010
130010
130013
130017
130017
130013
130009
130009
130009
130009
130014
130017
130023
130021
130021
130025
130030
130036
130038
130032
130026
130028
130035
130042
130046
130038
130031
130024
130018
130014
130009
130009
130009
130009
130015
130019
130020
130016
130009
130008
130008
130010
130016
130021
130029
130028
130026
130033
130042
130051
130055
130045
130035
130037
130046
130057
130069
130066
130061
130056
130050
130045
130041
130039
130037
130036
130035
130039
130043
130048
130050
130045
130041
130042
130047
130053
130058
130055
130052
130056
130061
130065
130071
130065
130060
130064
130070
130077
130085
130077
130070
130063
130057
130050
130045
130048
130055
130062
130068
130060
130052
130058
130067
130077
130085
130077
130069
130077
130085
130094
130103
130094
130085
130094
130102
130109
130117
130111
130103
130093
130084
130077
130070
130076
130081
130088
130099
130091
130083
130093
130101
130111
130121
130109
130096
130104
130114
130124
130138
130129
130119
130131
130140
130147
130157
130148
130139
130131
130122
130112
130103
130112
130121
130130
130135
130127
130119
130124
130132
130140
130149
130144
130138
130147
130156
130167
130176
130164
130154
130160
130171
130184
130190
130177
130165
130154
130144
130135
130127
130120
130114
130107
130101
130094
130085
130075
130065
130072
130083
130092
130097
130088
130078
130081
130092
130100
130105
130103
130100
130105
130110
130116
130117
130112
130108
130109
130113
130118
130124
130124
130122
130130
130138
130147
130149
130140
130131
130132
130141
130150
130161
130159
130157
130169
130181
130195
130198
130184
130171
130173
130186
130200
130217
130214
130211
130205
130198
130190
130179
130168
130156
130145
130133
130116
130095
130074
130055
130038
130022
130006
129993
129980
129970
129959
129954
129956
129953
129956
129953
129945
129945
129949
129946
129938
129938
129942
129944
129942
129939
129942
129939
129930
129931
129933
129930
129922
129922
129927
129929
129940
129923
129926
129922
129926
129922
129913
129913
129915
129913
129903
129904
129908
129911
129907
129903
129906
129903
129892
129894
129895
129892
129881
129883
129887
129890
129904
129912
129930
129946
129959
129945
129929
129910
129891
129882
129885
129880
129884
129880
129869
129870
129870
129867
129856
129858
129862
129865
129859
129854
129859
129854
129841
129843
129841
129838
129826
129828
129833
129836
129855
129825
129829
129823
129828
129823
129809
129811
129808
129805
129791
129794
129800
129803
129794
129787
129793
129787
129771
129773
129769
129766
129750
129753
129760
129763
129789
129803
129837
129866
129889
129863
129834
129799
129763
129747
129752
129744
129751
129745
129727
129729
129724
129720
129702
129705
129713
129717
129703
129694
129701
129695
129675
129678
129671
129666
129646
129649
129659
129664
129698
129641
129645
129635
129644
129637
129614
129617
129608
129604
129580
129584
129596
129601
129578
129566
129576
129569
129542
129546
129535
129530
129502
129507
129521
129527
129574
129599
129663
129717
129759
129712
129657
129594
129525
129495
129498
129486
129496
129489
129458
129462
129449
129443
129411
129415
129433
129441
129405
129390
129401
129394
129359
129364
129347
129340
129304
129308
129329
129339
129403
129294
129295
129278
129290
129282
129243
129248
129225
129218
129177
129181
129207
129218
129166
129145
129157
129149
129104
129110
129082
129073
129026
129031
129062
129076
129166
129219
129338
129439
129520
129435
129335
129430
129514
129587
129650
129705
129753
129794
129829
129859
129885
129908
129927
129943
129957
129969
129984
129975
129963
129984
129992
130000
130017
130013
130007
130000
129973
129950
129934
129916
129895
129931
129947
129961
129992
129983
129973
130020
130024
130027
130030
130032
130034
130036
130057
130058
130061
130091
130084
130079
130102
130110
130117
130121
130096
130063
130064
130065
130064
130099
130099
130098
130124
130127
130132
130138
130099
130060
130013
129961
129912
129870
129841
129808
129769
129837
129865
129890
129947
129931
129910
129886
129804
129725
129675
129618
129553
129674
129724
129767
129859
129828
129793
129908
129926
129944
129963
129979
129993
130004
130055
130048
130042
130104
130101
130100
130146
130155
130165
130178
130107
130035
130028
130023
130020
130130
130120
130112
130194
130214
130237
130265
130142
130015
129889
129758
129621
129480
129334
129220
129080
129014
129011
128987
129000
128991
128939
128946
128910
128901
128845
128851
128888
128906
128827
128797
128812
128802
128741
128749
128705
128693
128628
128635
128681
128702
128836
128624
128605
128569
128586
128574
128502
128512
128457
128442
128364
128375
128430
128457
128338
128293
128312
128296
128211
128225
128155
128135
128041
128056
128124
128160
128376
128509
128724
128916
129085
128935
128775
128596
128273
128084
128010
127953
127976
127955
127851
127870
127781
127754
127637
127659
127743
127792
127600
127525
127555
127526
127396
127423
127306
127270
127122
127153
127260
127330
127733
127266
127089
126977
127015
126976
126806
126845
126685
126636
126441
126488
126638
126751
126451
126258
126301
126240
126011
126069
125847
125770
125505
125575
125801
125951
126572
126816
127539
127989
128336
127896
127458
127253
126339
125626
125481
125291
125322
125220
124907
125003
124710
124560
124179
124320
124696
124902
124320
123972
123962
123727
123233
123444
122970
122645
122032
122383
123077
123569
124992
124805
123422
122412
121896
121416
120874
121389
121227
120526
120294
121003
122110
123117
123095
122064
120946
120191
120144
120965
121046
120185
119460
119717
120326
121179
121207
122153
123226
124801
126189
126094
126140
127182
127170
127334
127724
126642
125363
123541
122320
122755
121754
120503
120279
120079
121038
121588
121177
121781
122176
122497
124469
123500
122525
122182
122528
122960
123385
122997
122641
123249
123817
124607
124474
124300
124670
125011
125276
125446
124843
126325
125655
125467
125265
125855
126016
126946
126248
126371
126891
126871
127249
127662
127580
127875
128371
128326
128764
128735
129168
129180
129122
129279
129378
128550
127816
127288
127766
127994
127136
127374
128507
128331
127115
125905
125254
125759
124290
124000
123556
127055
126098
127290
128289
128988
128109
129026
128146
129284
130396
129839
131017
130621
129867
129836
129551
129574
129639
129981
130300
130230
130542
130608
130592
129973
129956
131183
130923
130916
130898
131312
131660
131695
131982
131943
131802
131301
131278
131790
131661
130594
130614
131837
132891
132735
132308
132373
132230
132276
132323
132584
132581
132838
133157
133173
133473
133597
133748
133820
134066
134313
134397
134604
134640
134806
134784
134640
134230
134070
133993
134004
133832
133571
133052
132837
133132
132575
132530
133007
132921
134715
134444
134540
134992
135072
134997
135040
135046
135301
135543
135620
135872
135968
136161
136168
136320
136385
136547
136585
136728
136896
136938
137151
137220
137411
137402
137073
136933
136706
136648
136522
136492
136583
136024
135602
135768
135281
135217
135483
135654
135899
134912
135605
135601
134735
133829
133881
134781
135616
135664
134880
134025
133130
132130
132457
131455
131881
130948
129988
130607
129775
130425
129737
129123
128618
128247
128032
127977
127991
128059
128233
128585
128837
128989
129111
129226
129400
129315
129217
129409
129501
129565
129719
129667
129586
129532
129263
129065
128831
128688
128630
129117
129127
129167
129510
129505
129528
129904
129839
129805
129804
129809
129827
129863
130012
130011
130017
130214
130181
130158
130299
130341
130396
130467
130262
130039
130079
130145
130241
130543
130422
130330
130557
130672
130813
130987
130700
130376
130010
129597
129133
128616
128636
128760
129001
129639
129382
129216
129723
129917
130185
130528
129990
129361
129826
130378
130993
131488
130930
130425
130939
131408
131923
132304
131824
131383
130991
130655
130379
130166
130554
130782
131062
131416
131134
130895
131196
131442
131726
132046
131741
131392
131769
132188
132640
132937
132507
132106
132401
132787
133198
133630
133390
133119
132814
132471
132084
131649
131158
131909
131451
132284
133094
132778
133625
133382
134236
135029
135763
135871
135171
134423
134612
133871
134114
133399
132661
133009
132326
132701
133040
133619
133328
133953
133686
134348
134991
134803
135461
135314
135977
136602
136523
136444
136393
136374
136370
136382
136441
137149
137248
137167
137283
137605
137720
137740
137829
137904
138039
137978
138163
137883
138177
138240
138374
138399
138540
138579
138690
138735
138902
138964
139102
139233
139310
139432
139498
139595
139559
139333
139196
139043
138960
138839
138839
138826
139072
139321
139443
139678
139781
139803
139860
139887
140023
140066
140199
140332
140394
140512
140562
140648
140595
140479
140248
140129
140144
139982
139911
140358
140613
140199
139979
140002
139546
139319
139822
140289
140427
140840
140984
141014
141123
141214
141105
141141
141045
141015
140923
140879
140789
140747
140836
140932
140964
141039
140765
140663
140691
140825
141242
141297
141407
141463
141559
141610
141681
141627
141512
141325
141403
141311
141519
141177
141568
141675
141713
141768
141814
141895
141942
142023
142062
142137
142169
142252
142340
142385
142471
142524
142599
142646
142704
142662
142526
142436
142277
142190
142213
142102
142038
141931
141973
141846
141771
142083
142014
142204
142343
142506
142580
142680
142772
142815
142863
142894
142963
142995
143068
143100
143169
143237
143284
143346
143392
143453
143503
143559
143599
143648
143605
143687
143725
143782
143808
143870
143905
143969
144007
144060
144115
144155
144201
144237
144284
144321
144363
144392
144433
144402
144470
144502
144551
144580
144631
144666
144714
144745
144786
144828
144862
144900
144932
144971
145004
145042
145068
145111
145138
145172
145142
145077
144995
144928
144849
144786
144755
144701
144631
144596
144540
144475
144514
144402
144262
144339
144246
144315
144145
144075
144025
143968
143889
143928
143836
143780
143709
143744
143813
143906
143694
143549
143625
143519
143400
143279
143197
143134
143072
142985
142925
142857
143027
143116
143039
142907
142816
142759
142917
143168
143235
143321
143441
143318
143415
143657
143775
143996
144116
144311
144426
144493
144566
144654
144718
144798
144868
144947
145010
145079
145151
145181
145214
145242
145282
145313
145352
145377
145414
145442
145477
145502
145534
145571
145599
145633
145659
145692
145722
145752
145778
145811
145834
145858
145834
145778
145709
145661
145592
145538
145509
145466
145417
145448
145388
145342
145284
145321
145251
145203
145343
145266
145375
145475
145516
145592
145623
145718
145760
145832
145862
145890
145911
145942
145966
145997
146018
146050
146074
146105
146128
146155
146182
146209
146233
146259
146284
146310
146334
146359
146382
146410
146432
146452
146479
146447
146394
146349
146295
146248
146193
146147
146131
146090
146039
146023
145979
145931
145968
145916
145876
145874
145925
145989
146043
146096
146141
146201
146249
146301
146342
146400
146443
146495
146522
146547
146568
146593
146615
146639
146660
146684
146707
146728
146749
146770
146791
146813
146832
146853
146873
146896
146914
146931
146953
146923
146967
146989
147008
147027
147047
147066
147086
147103
147123
147142
147159
147176
147197
147214
147237
147252
147273
147287
147308
147320
147335
147354
147326
147292
147257
147220
147183
147144
147109
147139
147102
147069
147031
147025
146990
146953
146983
146911
146819
146884
146845
146883
146799
146764
146716
146677
146706
146661
146625
146590
146616
146571
146537
146624
146640
146543
146462
146528
146359
146273
146161
146074
145953
145863
145980
146096
146181
146288
146371
146470
146551
146643
146724
146804
146881
146939
146993
147025
147070
147095
147146
147175
147219
147242
147291
147317
147359
147382
147403
147420
147438
147456
147472
147489
147503
147522
147534
147550
147566
147581
147598
147611
147627
147643
147659
147669
147651
147617
147585
147559
147524
147493
147518
147486
147457
147429
147452
147419
147391
147449
147451
147384
147319
147379
147248
147180
147102
147034
146950
147103
147173
147242
147307
147375
147434
147503
147583
147639
147663
147682
147698
147710
147725
147739
147752
147766
147782
147796
147807
147827
147838
147857
147865
147881
147891
147908
147913
147898
147866
147839
147809
147780
147750
147750
147722
147693
147720
147692
147666
147656
147675
147719
147737
147776
147792
147834
147849
147886
147909
147926
147940
147953
147969
147981
147996
148007
148024
148032
148041
148054
148063
148079
148087
148100
148114
148090
148118
148135
148144
148157
148165
148179
148187
148194
148210
148219
148234
148240
148257
148262
148238
148266
148280
148289
148299
148309
148323
148331
148338
148353
148360
148375
148374
148393
148391
148376
148401
148412
148421
148434
148439
148446
148460
148461
148473
148476
148493
148493
148482
148458
148443
148421
148424
148404
148384
148407
148338
148390
148400
148431
148436
148466
148489
148503
148515
148520
148535
148537
148540
148549
148556
148568
148569
148558
148537
148522
148504
148525
148507
148486
148510
148498
148542
148563
148575
148587
148590
148604
148606
148608
148618
148625
148637
148638
148625
148603
148590
148572
148594
148577
148559
148544
148551
148579
148582
148608
148630
148642
148659
148656
148671
148672
148675
148682
148686
148666
148684
148700
148704
148706
148712
148714
148726
148722
148711
148694
148701
148684
148671
148689
148629
148644
148642
148659
148653
148644
148629
148614
148568
148607
148543
148503
148514
148469
148452
148439
148425
148394
148349
148294
148273
148252
148304
148338
148360
148317
148294
148316
148295
148273
148252
148274
148261
148214
148166
148219
148208
148192
148171
148147
148172
148150
148127
148104
148127
148053
148056
148044
148066
148017
147992
148016
147990
147965
147942
147937
147913
147963
147954
147949
148005
148005
147899
147844
147791
147735
147676
147620
147667
147606
147553
147491
147545
147597
147656
147715
147776
147820
147880
147920
147982
148014
148074
148127
148163
148174
148123
148114
148103
148134
148189
148217
148243
148194
148165
148115
148083
148049
147996
147959
147904
147863
147807
147762
147704
147646
147694
147750
147793
147848
147888
147942
147978
148031
148064
148095
148145
148173
148221
148269
148317
148367
148387
148340
148361
148406
148425
148382
148401
148443
148485
148527
148575
148583
148629
148673
148697
148716
148726
148736
148738
148744
148752
148750
148760
148758
148741
148755
148767
148773
148770
148778
148771
148761
148752
148741
148760
148720
148683
148699
148720
148739
148732
148726
148711
148723
148666
148682
148723
148744
148744
148761
148781
148788
148795
148796
148787
148778
148773
148796
148806
148801
148792
148794
148803
148807
148808
148800
148793
148788
148777
148758
148727
148763
148714
148725
148761
148778
148777
148793
148807
148814
148816
148811
148812
148811
148806
148819
148820
148825
148824
148827
148826
148815
148828
148828
148826
148822
148834
148822
148822
148831
148826
148833
148833
148842
148818
148826
148826
148822
148827
148832
148826
148826
148838
148816
148825
148830
148829
148830
148828
148832
148831
148830
148832
148832
148831
148830
148838
148836
148835
148832
148835
148835
148847
148837
148839
148837
148840
148842
148853
148848
148842
148850
148858
148885
148864
148868
148892
148900
148920
148924
148899
148893
148880
148907
148921
148977
148925
148940
148932
148991
148976
149040
149079
149116
149127
149234
149264
149365
149437
149490
149578
149691
149796
149867
149897
149818
149753
149766
149699
149599
149685
149670
149732
149793
149743
149666
149581
149577
149641
149696
149640
149572
149431
149492
149600
149519
149452
149509
149414
149329
149418
149310
149234
149181
149195
149243
149214
149356
149314
149417
149322
149276
149349
149386
149393
149381
149360
149338
149318
149302
149318
149341
149371
149406
149442
149510
149620
149536
149472
149585
149667
149606
149475
149283
149262
149267
149293
149304
149273
149242
149241
149239
149215
149192
149169
149166
149190
149215
149214
149186
149161
149153
149181
149210
149242
149278
149317
149326
149279
149274
149327
149315
149259
149214
149230
149239
149204
149172
149144
149131
149160
149193
149176
149143
149115
149089
149104
149117
149128
149136
149142
149146
149148
149145
149125
149104
149084
149064
149045
149026
149008
148990
148973
148957
148941
148926
148911
148897
148884
148887
148900
148913
148928
148943
148958
148974
148991
149009
149027
149046
149065
149085
149106
149127
149124
149103
149082
149076
149097
149119
149112
149090
149068
149048
149055
149062
149042
149023
149005
148999
149017
149036
149028
149010
148992
148984
149001
149020
149039
149060
149081
149104
149093
149070
149049
149037
149058
149080
149065
149043
149022
149003
149017
149029
149010
148991
148974
148963
148980
148998
148985
148967
148951
148935
148947
148958
148967
148975
148982
148988
148971
148956
148940
148935
148950
148965
148959
148943
148928
148914
148920
148926
148912
148898
148886
148881
148894
148907
148900
148888
148875
148869
148881
148894
148907
148921
148935
148951
148942
148927
148912
148903
148917
148932
148920
148906
148892
148879
148890
148899
148886
148873
148861
148853
148865
148877
148867
148855
148843
148833
148844
148856
148868
148881
148894
148908
148922
148938
148953
148970
148988
149006
149026
149047
149070
149095
149122
149153
149189
149231
149283
149231
149191
149145
149172
149198
149213
149127
149115
149079
149040
149061
149123
149153
148978
148958
148955
148992
148926
148885
148847
148847
148850
148869
148856
148835
148825
148832
148807
148794
148790
148813
148820
148838
148814
148819
148806
148811
148792
148815
148830
148819
148805
148806
148824
148810
148793
148761
148751
148784
148760
148730
148725
148695
148688
148684
148648
148640
148634
148593
148603
148613
148624
148656
148665
148676
148704
148715
148739
148764
148773
148791
148816
148833
148866
148896
148865
148842
148815
148794
148772
148752
148730
148748
148768
148739
148722
148704
148689
148661
148647
148635
148603
148590
148578
148566
148554
148541
148500
148515
148529
148492
148476
148460
148419
148437
148454
148471
148507
148543
148557
148571
148585
148617
148631
148647
148676
148693
148709
148724
148756
148786
148802
148834
148851
148886
148923
148965
149014
149049
148994
148946
148903
148916
148959
149007
149062
149065
149127
149114
149097
149077
149118
149156
149125
149097
149072
149046
149068
149092
149057
149037
149018
148988
149004
149020
149036
149050
149060
149011
149011
148965
148922
148924
148966
148963
149005
148996
148984
148972
148958
148928
148939
148949
148957
148920
148924
148886
148886
148883
148876
148865
148829
148817
148783
148770
148738
148750
148760
148794
148803
148839
148846
148850
148850
148816
148815
148810
148776
148769
148735
148727
148717
148705
148693
148678
148663
148632
148616
148601
148569
148553
148537
148522
148487
148504
148520
148486
148469
148452
148434
148416
148398
148379
148359
148338
148316
148294
148247
148271
148295
148251
148226
148201
148154
148126
148078
148046
148013
147963
147927
147875
147835
147782
147739
147685
147638
147589
147537
147484
147428
147369
147304
147240
147174
147105
147032
146956
146885
146963
147037
146969
146893
146813
146730
146655
146565
146488
146391
146312
146207
146125
146013
145894
145770
145646
145549
145408
145310
145157
145005
145115
145218
144842
144724
144548
144891
145057
145214
145363
145455
145592
145681
145809
145722
145637
145503
145415
145271
145119
144959
144788
144608
144505
144688
144861
144766
144589
144403
144205
144099
143885
143776
143544
143294
143031
142912
142624
142332
142195
141863
141732
141367
141242
141613
141500
141126
140722
140611
140174
139701
139182
138644
138053
138023
138305
138456
137490
137914
138521
139081
139597
140071
140510
140919
141017
141395
141299
141654
141747
141848
141957
142073
142389
142505
142797
143070
143181
143433
143670
143568
143327
143225
142963
142686
142579
142278
142174
142077
141986
142296
142385
142480
142766
142862
143128
143378
143471
143703
143796
143893
143994
144201
144301
144492
144673
144845
144934
145026
145181
145329
145471
145553
145684
145764
145846
145929
146045
146155
146233
146335
146411
146506
146580
146668
146741
146823
146901
146834
146753
146684
146597
146527
146433
146361
146260
146186
146078
145965
145886
146003
146113
146219
146289
146388
146457
146549
146616
146701
146767
146847
146911
146976
147041
147107
147175
147239
147302
147365
147423
147362
147302
147240
147178
147111
147048
147117
147182
147242
147303
147361
147419
147478
147531
147582
147631
147577
147527
147474
147418
147472
147523
147469
147417
147361
147305
147245
147187
147123
147056
146985
146923
146995
147064
147129
147192
147248
147306
147361
147415
147362
147308
147251
147196
147135
147071
147004
146934
146860
146783
146719
146636
146570
146481
146414
146319
146250
146148
146041
145928
145809
145732
145605
145527
145390
145246
145094
145008
145163
145310
145231
145082
144924
144758
144582
144397
144305
144105
144012
143922
144128
144215
144407
144494
144672
144842
145002
145154
145078
144923
144761
144589
144507
144323
144241
144043
143834
143613
143525
143287
143035
142946
142674
142588
142861
143118
143201
143441
143668
143749
143961
144161
144084
143882
143806
143590
143361
143284
143040
142781
142506
142213
141901
141568
141212
140830
140420
139980
139505
138991
138433
137824
137761
137102
137073
137063
137693
137718
138310
138363
138916
139428
139902
140341
140272
139835
139365
138858
138814
138275
138254
137685
137067
137087
137689
138246
138248
137705
137132
137189
137739
138259
138753
138753
138762
138782
139274
139314
139779
140212
140161
139733
139696
139245
139225
139214
139649
139668
140085
140119
140516
140562
140617
140679
140751
141132
141488
141822
141749
141416
141060
140995
141350
141683
141996
142063
142135
142429
142705
142966
142897
142635
142357
142291
142569
142832
142771
142508
142230
141935
141623
141291
140938
140888
141239
141569
141521
141193
140845
140477
140444
140058
140038
139636
139211
138758
138282
137780
137248
136684
136089
136204
135610
135755
135172
134569
134777
134201
134428
133884
133343
133616
134124
134637
134827
134340
133860
134078
134536
134999
135464
135314
135149
134971
135506
135343
135896
136431
136319
136860
136771
137311
137825
138312
138344
137873
137378
137446
136948
137036
136540
136030
136157
135657
135798
135928
136386
136275
136744
136645
137120
137581
137514
137975
137923
138380
138816
138793
138772
139213
139629
140024
140015
139628
139219
139233
139630
140010
140008
139636
139248
138842
138417
138456
138026
138078
137646
137201
137278
136837
136923
136488
136046
135601
135155
134711
134272
133844
133429
133033
132660
132313
131996
131712
131460
131241
131054
130896
130764
130655
130565
130491
130431
130381
130339
130304
130274
130248
130226
130207
130191
130177
130165
130155
130147
130140
130136
130131
130124
130140
130146
130152
130171
130161
130152
130166
130177
130190
130205
130183
130161
130172
130184
130199
130233
130214
130198
130223
130243
130265
130295
130269
130246
130226
130209
130193
130180
130193
130208
130225
130240
130221
130204
130214
130232
130252
130275
130261
130245
130267
130292
130322
130345
130314
130286
130302
130332
130366
130405
130382
130355
130325
130291
130255
130217
130236
130259
130285
130341
130308
130280
130321
130354
130393
130437
130378
130315
130350
130390
130437
130527
130471
130421
130487
130545
130611
130687
130613
130548
130491
130441
130397
130358
130393
130435
130484
130523
130470
130423
130449
130499
130556
130619
130583
130540
130603
130674
130755
130814
130727
130650
130692
130773
130864
130906
130810
130725
130650
130583
130523
130471
130424
130383
130347
130315
130287
130263
130241
130222
130228
130248
130271
130276
130253
130232
130235
130256
130279
130306
130302
130296
130325
130358
130396
130405
130366
130332
130336
130371
130410
130454
130449
130439
130487
130542
130603
130617
130554
130498
130505
130561
130625
130698
130688
130673
130751
130839
130937
130958
130858
130768
130778
130869
130971
131084
131070
131047
131012
130967
130911
130846
130771
130687
130593
130491
130555
130630
130719
130860
130757
130669
130773
130872
130986
131116
130979
130825
130950
131097
131268
131457
131275
131117
131265
131433
131624
131769
131571
131395
131238
131098
130975
130866
130949
131065
131196
131281
131144
131021
131082
131210
131353
131512
131435
131344
131508
131691
131894
132001
131794
131605
131687
131879
132090
132319
132227
132117
131987
131837
131664
131466
131692
131948
132233
132440
132155
131896
132074
132335
132619
132927
132750
132546
132886
133249
133632
133810
133438
133083
133255
133602
133966
134101
133745
133404
133080
132775
132491
132228
132360
132624
132908
133021
132737
132473
132566
132831
133114
133414
133322
133211
133531
133867
134217
134316
133971
133639
133729
134057
134398
134464
134127
133801
133488
133189
132907
132641
132392
132162
131948
131753
131574
131411
131264
131132
131169
131305
131455
131484
131332
131194
131209
131348
131501
131670
131652
131620
131802
132000
132215
132251
132035
131835
131854
132055
132272
132506
132485
132448
132697
132963
133246
133284
133001
132735
132757
133023
133305
133602
133581
133543
133855
134179
134514
134548
134214
133891
133912
134234
134567
134909
134891
134859
134812
134749
134672
134579
134470
134344
134198
134032
134445
134867
135295
135419
135006
134598
134732
135128
135530
135935
135836
135725
136154
136581
137003
137075
136666
136252
136339
136742
137141
137200
136810
136417
136022
135627
135236
134849
134950
135329
135712
135784
135408
135037
135109
135475
135845
136218
136163
136098
136484
136869
137252
137297
136921
136543
136592
136965
137335
137702
137668
137630
137585
137535
137479
137417
137350
137768
137709
138127
138533
138494
138897
138869
139265
139645
140009
140013
139656
139284
139304
138925
138953
138570
138175
138220
137823
137874
137921
138300
138262
138639
138606
138980
139344
139324
139681
139668
140019
140357
140356
140358
140363
140371
140382
140398
140418
140778
140809
141153
141478
141786
141830
141880
142174
142452
142715
142663
142400
142123
142077
142353
142615
142863
142911
142963
143019
143080
143144
143212
143444
143515
143733
143940
144010
144204
144276
144350
144427
144604
144681
144847
145003
144931
144772
144699
144529
144457
144387
144561
144629
144793
144861
145014
145082
145152
145224
145298
145373
145449
145582
145657
145780
145853
145969
145897
145827
145707
145635
145507
145435
145565
145689
145757
145873
145940
146009
146078
146182
146282
146348
146440
146505
146592
146655
146736
146798
146873
146945
146887
146813
146753
146674
146613
146529
146467
146376
146313
146216
146115
146049
146152
146250
146344
146405
146493
146553
146635
146694
146770
146828
146900
146957
147014
147079
147142
147202
147255
147310
147362
147415
147467
147520
147572
147625
147677
147730
147772
147823
147863
147913
147949
147998
148031
148062
148108
148137
148182
148208
148164
148121
148092
148047
148016
147983
147936
147900
147852
147813
147763
147721
147670
147619
147663
147713
147754
147803
147841
147889
147924
147970
148002
148033
148077
148105
148148
148191
148233
148275
148317
148338
148359
148378
148340
148319
148297
148257
148279
148301
148322
148360
148397
148416
148434
148451
148416
148398
148379
148342
148361
148380
148344
148325
148305
148284
148262
148239
148215
148174
148199
148222
148183
148158
148132
148090
148062
148019
147989
147957
147912
147877
147831
147794
147746
147706
147657
147613
147567
147516
147563
147608
147559
147513
147465
147414
147464
147511
147556
147603
147651
147698
147738
147784
147821
147867
147901
147945
147976
148006
148048
148076
148117
148143
148167
148206
148245
148267
148287
148307
148271
148250
148229
148190
148212
148234
148197
148175
148152
148128
148102
148062
148035
147994
147964
147933
147890
147856
147812
147776
147731
147692
147645
147599
147641
147685
147724
147768
147803
147847
147880
147922
147952
147981
148022
148049
148088
148113
148137
148160
148123
148099
148075
148036
148009
147970
147941
147911
147870
147837
147795
147760
147718
147680
147636
147596
147553
147509
147463
147414
147364
147313
147259
147207
147149
147088
147024
146969
147034
147097
147045
146981
146914
146844
146788
146713
146657
146577
146519
146434
146376
146284
146189
146089
145983
145919
145807
145742
145622
145496
145363
145294
145428
145556
145678
145794
145856
145965
146026
146128
146069
146011
145905
145846
145734
145616
145492
145362
145226
145160
145298
145430
145369
145236
145095
144948
144884
144727
144663
144496
144320
144135
144069
143872
143664
143598
143377
143314
143536
143747
143808
144006
144195
144256
144434
144602
144544
144374
144316
144136
143947
143890
143689
143478
143255
143199
143423
143635
143584
143371
143147
143099
143323
143536
143739
143786
143836
144028
144081
144262
144434
144488
144651
144706
144763
144822
144973
145033
145175
145311
145439
145497
145556
145675
145789
145898
145954
146056
146111
146168
146226
146319
146407
146463
146546
146601
146679
146733
146806
146860
146928
146993
146943
146876
146825
146754
146702
146626
146573
146492
146439
146353
146262
146208
146299
146387
146471
146521
146600
146650
146724
146774
146844
146893
146958
147007
147056
147106
147156
147213
147263
147316
147365
147415
147367
147320
147268
147220
147164
147116
147173
147228
147274
147325
147370
147416
147463
147508
147551
147593
147550
147507
147463
147418
147464
147507
147465
147421
147374
147330
147280
147235
147182
147126
147068
147020
147080
147137
147191
147244
147286
147335
147378
147424
147382
147342
147294
147253
147202
147148
147093
147034
146974
146910
146863
146795
146748
146676
146628
146551
146503
146421
146336
146247
146154
146101
146002
145949
145844
145734
145618
145562
145680
145791
145898
146000
146050
146146
146196
146286
146238
146190
146097
146050
145951
145848
145740
145627
145508
145384
145254
145117
145060
144915
144859
144806
144954
145006
145146
145199
145330
145456
145576
145691
145643
145527
145406
145279
145229
145095
145046
144904
144755
144599
144549
144384
144210
144161
143978
143931
144115
144290
144335
144501
144660
144706
144856
144999
144955
144811
144767
144616
144457
144414
144247
144071
143887
143694
143491
143278
143054
142819
142571
142310
142035
141746
141440
141118
141089
140752
140732
140715
141043
141063
141379
141408
141710
141998
142271
142531
142495
142236
141965
141679
141652
141355
141334
141025
140702
140692
141011
141316
141301
141000
140685
140680
140991
141289
141574
141589
141607
141628
141909
141935
142205
142462
142432
142176
142151
141885
141865
141847
142109
142129
142381
142405
142648
142676
142707
142741
142778
143013
143237
143450
143411
143198
142975
142940
143163
143375
143578
143614
143653
143846
144030
144206
144168
143992
143807
143772
143956
144133
144100
143923
143738
143545
143343
143131
142908
142879
143101
143312
143285
143074
142853
142623
142600
142360
142341
142092
141832
141561
141279
140984
140677
140358
140026
140034
139695
139708
139363
139006
139031
138671
138699
138336
137964
138002
138367
138725
138748
138395
138035
138063
138419
138768
139109
139093
139075
139054
139399
139382
139721
140051
140042
140365
140361
140676
140979
141270
141264
140975
140676
140676
140369
140374
140059
139734
139746
139415
139430
139442
139767
139757
140075
140067
140379
140680
140678
140972
140973
141259
141534
141541
141550
141819
142077
142325
142310
142064
141808
141799
142053
142298
142288
142044
141791
141528
141255
141252
140971
140971
140682
140384
140388
140082
140088
139775
139453
139123
138785
138439
138087
137729
137367
137001
136632
136263
135895
135529
135167
135211
135570
135932
135958
135598
135241
135259
135614
135973
136335
136321
136297
136663
137028
137391
137408
137047
136684
136697
137059
137418
137775
137766
137751
138106
138455
138798
138808
138466
138119
138127
138474
138814
139148
139142
139134
139462
139782
140094
140098
139788
139469
139474
139792
140101
140402
140400
140396
140392
140687
140685
140972
141250
141251
141520
141524
141785
142037
142279
142272
142030
141780
141776
141518
141516
141249
140973
140974
140690
140692
140694
140977
140976
141250
141249
141515
141772
141774
142022
142026
142266
142497
142504
142512
142521
142533
142547
142562
142580
142809
142830
143050
143260
143461
143487
143515
143708
143893
144069
144041
143864
143680
143654
143839
144015
143992
143815
143631
143438
143237
143028
143008
142790
142773
142759
142975
142991
143199
143217
143418
143610
143794
143970
143951
143775
143591
143399
143383
143183
143170
142962
142746
142736
142951
143158
143148
142941
142727
142720
142934
143140
143338
143346
143356
143369
143560
143574
143758
143934
143919
143743
143730
143547
143536
143528
143710
143719
143895
143906
144075
144088
144103
144120
144139
144161
144184
144210
144238
144269
144301
144337
144374
144534
144574
144726
144872
144912
145050
145092
145136
145181
145311
145357
145480
145597
145552
145434
145391
145266
145223
145183
145309
145349
145469
145509
145623
145665
145708
145753
145800
145904
146004
146100
146144
146234
146279
146325
146373
146455
146535
146581
146655
146701
146771
146816
146882
146928
146990
147049
147006
146945
146902
146838
146795
146726
146683
146610
146566
146490
146409
146364
146446
146524
146598
146640
146710
146752
146818
146860
146922
146964
147023
147064
147106
147160
147212
147262
147301
147348
147387
147427
147467
147508
147549
147591
147633
147675
147712
147754
147788
147829
147861
147901
147931
147959
147997
148024
148061
148086
148049
148012
147986
147949
147921
147891
147853
147821
147781
147748
147707
147671
147630
147589
147628
147667
147703
147742
147775
147814
147845
147883
147911
147939
147975
148001
148036
148072
148109
148145
148181
148218
148254
148290
148326
148362
148398
148433
148468
148502
148536
148552
148584
148600
148614
148647
148660
148673
148684
148694
148660
148651
148640
148627
148594
148581
148567
148533
148518
148484
148500
148514
148548
148561
148573
148607
148618
148628
148636
148669
148702
148709
148742
148747
148781
148783
148784
148817
148850
148884
148880
148914
148906
148898
148868
148875
148843
148847
148815
148784
148782
148812
148808
148838
148832
148860
148888
148917
148945
148972
148999
149025
149049
149027
149007
148989
148969
148987
149005
148982
148965
148949
148933
148953
148971
148954
148938
148923
148907
148922
148937
148919
148904
148891
148873
148886
148899
148913
148927
148942
148957
148931
148918
148905
148882
148893
148905
148878
148868
148858
148848
148870
148892
148879
148867
148855
148837
148847
148859
148837
148827
148817
148808
148826
148844
148861
148877
148893
148908
148894
148881
148868
148855
148867
148880
148865
148853
148841
148829
148843
148856
148844
148833
148822
148810
148821
148832
148819
148808
148798
148786
148795
148805
148815
148826
148837
148849
148832
148822
148811
148796
148805
148815
148798
148789
148780
148771
148786
148801
148791
148782
148773
148760
148768
148777
148762
148754
148746
148732
148739
148747
148755
148763
148771
148780
148789
148798
148807
148816
148825
148834
148843
148852
148825
148818
148810
148785
148792
148798
148804
148776
148779
148750
148752
148753
148752
148751
148718
148714
148682
148676
148644
148650
148655
148686
148690
148721
148722
148722
148721
148693
148693
148692
148662
148659
148628
148624
148618
148612
148604
148595
148585
148552
148540
148528
148494
148480
148465
148450
148415
148431
148446
148460
148473
148507
148519
148529
148562
148571
148580
148587
148593
148562
148556
148548
148539
148507
148497
148486
148453
148440
148426
148412
148396
148380
148344
148361
148377
148343
148326
148309
148273
148291
148308
148325
148359
148392
148407
148420
148432
148464
148475
148485
148516
148525
148532
148538
148568
148598
148602
148632
148635
148664
148665
148665
148692
148720
148748
148744
148771
148766
148761
148755
148779
148802
148794
148786
148778
148757
148764
148772
148749
148743
148736
148715
148721
148726
148731
148736
148740
148715
148718
148691
148664
148663
148689
148686
148711
148707
148703
148699
148694
148673
148677
148680
148683
148659
148661
148637
148637
148638
148637
148637
148608
148606
148577
148573
148544
148549
148553
148580
148583
148610
148611
148612
148612
148587
148586
148585
148559
148556
148529
148525
148520
148515
148509
148502
148494
148463
148454
148443
148412
148400
148387
148373
148340
148354
148368
148380
148392
148423
148433
148442
148472
148479
148486
148492
148498
148470
148464
148458
148450
148421
148412
148402
148372
148361
148349
148336
148322
148307
148291
148274
148256
148237
148202
148221
148240
148205
148186
148166
148131
148151
148171
148190
148223
148257
148274
148289
148304
148272
148257
148241
148208
148225
148240
148209
148193
148175
148157
148137
148117
148095
148060
148082
148103
148070
148048
148025
147990
147965
147929
147902
147874
147837
147807
147770
147737
147699
147664
147626
147588
147549
147509
147550
147588
147550
147511
147470
147431
147473
147513
147552
147588
147625
147662
147696
147733
147765
147801
147831
147867
147894
147921
147955
147980
148014
148036
148058
148090
148123
148143
148161
148178
148147
148129
148110
148078
148098
148116
148134
148164
148194
148225
148255
148286
148317
148330
148342
148353
148382
148392
148401
148429
148437
148443
148416
148409
148381
148373
148363
148335
148324
148312
148300
148269
148282
148295
148306
148317
148345
148354
148363
148389
148397
148423
148449
148476
148502
148506
148533
148535
148561
148562
148563
148587
148611
148635
148634
148657
148654
148651
148648
148669
148689
148710
148730
148750
148770
148762
148754
148746
148729
148736
148743
148724
148717
148711
148705
148722
148738
148731
148724
148717
148702
148708
148715
148698
148692
148687
148671
148676
148682
148687
148693
148699
148704
148684
148680
148675
148656
148660
148665
148644
148641
148637
148633
148652
148670
148665
148660
148655
148639
148643
148647
148630
148626
148622
148606
148609
148612
148615
148618
148621
148624
148627
148629
148632
148609
148610
148587
148564
148564
148587
148586
148608
148606
148604
148601
148599
148580
148582
148583
148585
148563
148564
148542
148541
148541
148539
148537
148513
148510
148485
148481
148455
148460
148464
148488
148491
148515
148517
148519
148520
148498
148496
148494
148471
148468
148444
148439
148434
148429
148403
148410
148415
148391
148385
148378
148371
148345
148336
148327
148300
148289
148278
148266
148253
148239
148209
148224
148237
148209
148195
148180
148150
148166
148181
148195
148222
148250
148262
148273
148284
148310
148319
148328
148353
148360
148367
148373
148397
148420
148425
148448
148451
148474
148476
148478
148499
148521
148542
148542
148563
148562
148561
148559
148578
148597
148594
148591
148589
148572
148574
148576
148558
148556
148555
148537
148538
148539
148540
148541
148542
148521
148521
148501
148480
148481
148501
148502
148522
148521
148521
148520
148520
148502
148503
148503
148502
148483
148482
148463
148461
148459
148457
148454
148432
148429
148406
148402
148379
148384
148389
148411
148414
148436
148438
148441
148443
148424
148421
148418
148397
148393
148372
148367
148362
148356
148350
148343
148336
148311
148303
148294
148268
148258
148247
148235
148208
148220
148232
148243
148253
148278
148287
148296
148319
148327
148333
148340
148346
148324
148318
148311
148304
148281
148272
148263
148239
148229
148218
148206
148194
148181
148167
148153
148137
148121
148104
148086
148066
148046
148025
148003
147970
147946
147913
147887
147859
147825
147796
147761
147729
147694
147660
147624
147589
147624
147659
147692
147726
147757
147791
147819
147853
147879
147905
147937
147961
147993
148015
148036
148055
148025
148005
147983
147953
147929
147898
147873
147847
147814
147786
147753
147723
147690
147658
147625
147590
147554
147516
147477
147436
147393
147355
147310
147272
147223
147172
147119
147079
147133
147185
147147
147095
147040
146982
146943
146882
146842
146778
146738
146670
146630
146558
146482
146403
146321
146278
146191
146149
146056
145960
145859
145815
145917
146014
146108
146197
146237
146322
146362
146442
146403
146365
146283
146245
146159
146068
145974
145876
145773
145732
145836
145935
145898
145798
145693
145583
145545
145429
145392
145271
145144
145011
144973
144834
144687
144651
144497
144463
144617
144764
144798
144938
145072
145107
145235
145357
145323
145201
145168
145039
144905
144873
144732
144584
144430
144400
144555
144703
144675
144527
144372
144346
144501
144650
144792
144817
144844
144980
145009
145138
145262
145292
145410
145441
145474
145508
145620
145655
145761
145862
145959
145994
146030
146122
146209
146293
146328
146407
146443
146480
146518
146592
146662
146700
146766
146804
146866
146904
146963
147001
147057
147111
147075
147020
146984
146927
146891
146830
146794
146729
146694
146626
146554
146518
146590
146659
146726
146759
146822
146856
146915
146949
147005
147040
147093
147127
147162
147198
147234
147282
147318
147363
147399
147441
147406
147371
147327
147292
147246
147211
147258
147303
147337
147379
147413
147447
147481
147520
147557
147592
147560
147524
147486
147453
147491
147528
147497
147459
147420
147388
147347
147315
147271
147225
147177
147143
147192
147239
147284
147327
147357
147398
147428
147466
147437
147407
147368
147339
147297
147253
147208
147160
147111
147059
147027
146972
146940
146882
146850
146789
146757
146693
146626
146556
146483
146450
146373
146339
146259
146174
146086
146052
146141
146226
146195
146109
146019
145926
145828
145726
145693
145586
145554
145523
145632
145661
145765
145795
145894
145988
146078
146165
146137
146049
145958
145864
145835
145735
145708
145603
145494
145381
145353
145234
145110
145084
144953
144929
145059
145184
145208
145328
145443
145468
145577
145682
145658
145553
145530
145419
145304
145283
145162
145037
144906
144769
144627
144478
144323
144301
144457
144606
144587
144438
144282
144265
144420
144569
144712
144729
144748
144885
145016
145142
145124
144998
144866
144850
144981
145107
145093
144966
144835
144697
144554
144405
144250
144237
144392
144541
144530
144381
144225
144064
144054
143886
143879
143703
143521
143331
143133
142928
142714
142492
142262
142259
142020
142019
141772
141516
141516
141251
141772
142019
142257
142258
142487
142489
142711
142924
143129
143127
142922
142709
142708
142487
142921
143126
143322
143324
143326
143516
143698
143873
143870
143695
143513
143512
143694
143869
144037
144039
144042
144047
144209
144216
144371
144521
144664
144673
144684
144822
144954
145080
145069
144943
144811
144801
144933
145060
145182
145191
145202
145214
145229
145245
145263
145379
145398
145509
145615
145636
145737
145759
145783
145808
145904
145930
146022
146110
146084
145996
145972
145879
145856
145835
145928
145949
146038
146061
146146
146169
146194
146220
146248
146277
146308
146386
146417
146491
146523
146594
146563
146533
146461
146432
146356
146328
146404
146477
146504
146574
146602
146631
146661
146726
146789
146819
146878
146908
146964
146995
147048
147079
147129
147177
147148
147099
147070
147018
146989
146935
146906
146849
146820
146760
146697
146668
146732
146793
146852
146878
146934
146961
147014
147041
147091
147119
147167
147195
147224
147268
147310
147351
147379
147418
147445
147474
147503
147533
147563
147594
147626
147658
147689
147721
147751
147782
147810
147841
147867
147892
147922
147945
147975
147996
147966
147937
147915
147886
147862
147836
147806
147779
147749
147720
147689
147658
147627
147597
147629
147659
147689
147719
147747
147777
147803
147832
147857
147881
147909
147931
147959
147987
148016
148045
148074
148092
148109
148125
148098
148081
148063
148035
148053
148070
148087
148113
148140
148155
148168
148181
148156
148143
148128
148102
148117
148131
148107
148092
148077
148061
148044
148026
148007
147979
147999
148017
147991
147972
147952
147925
147903
147876
147853
147828
147800
147774
147746
147718
147690
147660
147632
147600
147567
147538
147572
147604
147577
147544
147510
147482
147517
147550
147582
147608
147635
147662
147691
147719
147746
147773
147798
147825
147849
147872
147898
147919
147945
147965
147984
148009
148035
148051
148067
148083
148059
148043
148026
148002
148019
148035
148012
147995
147977
147959
147940
147915
147894
147869
147846
147823
147797
147772
147746
147719
147693
147665
147639
147613
147643
147668
147696
147721
147747
147772
147796
147821
147844
147866
147890
147910
147934
147953
147972
147989
147966
147949
147930
147907
147887
147863
147842
147819
147796
147772
147748
147722
147698
147671
147647
147618
147588
147557
147524
147490
147455
147428
147391
147364
147324
147283
147240
147212
147256
147298
147273
147230
147186
147140
147113
147065
147039
146987
146962
146908
146883
146826
146767
146705
146641
146615
146547
146522
146451
146377
146300
146275
146352
146427
146498
146567
146590
146655
146680
146742
146718
146696
146632
146611
146544
146475
146403
146328
146250
146228
146306
146381
146361
146285
146206
146124
146104
146018
145999
145908
145815
145717
145698
145596
145490
145472
145361
145345
145456
145564
145579
145681
145780
145796
145891
145981
145965
145874
145860
145765
145666
145653
145550
145442
145331
145318
145430
145538
145527
145420
145308
145299
145411
145519
145622
145631
145641
145740
145752
145847
145938
145951
146038
146052
146068
146085
146168
146186
146266
146342
146415
146434
146454
146523
146590
146654
146674
146735
146756
146778
146802
146859
146914
146937
146990
147014
147064
147088
147135
147160
147205
147248
147225
147181
147158
147112
147089
147040
147018
146967
146945
146892
146836
146815
146871
146924
146976
146996
147046
147067
147114
147135
147180
147202
147244
147267
147290
147314
147339
147377
147402
147439
147464
147499
147474
147450
147415
147391
147353
147330
147368
147405
147427
147462
147485
147508
147532
147564
147595
147624
147602
147572
147540
147518
147549
147580
147558
147527
147495
147474
147440
147419
147383
147346
147307
147285
147324
147362
147398
147433
147453
147486
147506
147538
147518
147498
147466
147447
147413
147378
147342
147304
147264
147223
147202
147159
147139
147093
147074
147026
147007
146957
146905
146851
146794
146775
146716
146697
146635
146571
146504
146485
146553
146618
146680
146740
146757
146814
146832
146886
146869
146853
146798
146782
146725
146664
146602
146536
146469
146398
146324
146248
146231
146151
146136
146122
146203
146216
146293
146308
146382
146453
146521
146587
146573
146507
146439
146368
146355
146280
146268
146191
146110
146026
146015
145927
145835
145825
145730
145722
145817
145909
145917
146005
146090
146099
146180
146258
146249
146171
146163
146082
145997
145991
145902
145811
145715
145615
145512
145404
145292
145175
145053
144926
144794
144656
144513
144364
144359
144203
144200
144199
144354
144355
144505
144508
144651
144789
144921
145048
145044
144917
144785
144648
144646
144503
144784
144916
145043
145164
145166
145169
145286
145399
145507
145504
145396
145283
145281
145394
145502
145606
145607
145610
145710
145806
145898
145895
145803
145707
145705
145801
145893
145981
145983
145986
146071
146076
146157
146235
146242
146317
146324
146333
146343
146415
146426
146495
146561
146550
146484
146474
146405
146396
146389
146458
146466
146532
146541
146604
146614
146625
146636
146650
146710
146768
146824
146838
146892
146906
146922
146939
146989
147038
147055
147102
147120
147164
147182
147224
147244
147284
147322
147304
147265
147247
147206
147189
147146
147129
147085
147069
147022
146973
146957
147007
147054
147099
147114
147157
147173
147214
147230
147270
147286
147324
147341
147359
147395
147429
147462
147480
147511
147529
147548
147568
147588
147609
147630
147652
147675
147702
147724
147749
147772
147796
147819
147841
147862
147884
147904
147926
147944
147922
147901
147882
147860
147840
147818
147796
147773
147752
147727
147705
147679
147658
147637
147664
147684
147710
147730
147754
147775
147797
147818
147839
147860
147880
147899
147919
147940
147962
147983
148005
148028
148051
148074
148097
148121
148145
148169
148193
148205
148216
148226
148249
148258
148267
148289
148296
148303
148310
148330
148351
148356
148377
148381
148401
148404
148407
148426
148445
148464
148465
148484
148485
148485
148467
148466
148448
148447
148428
148410
148412
148430
148432
148450
148451
148468
148485
148502
148519
148536
148553
148569
148586
148602
148618
148634
148650
148666
148681
148696
148710
148724
148738
148751
148764
148777
148788
148800
148811
148822
148832
148842
148850
148857
148864
148869
148874
148874
148872
148860
148848
148837
148827
148818
148809
148800
148793
148785
148779
148773
148767
148763
148758
148755
148756
148760
148765
148770
148776
148782
148789
148796
148804
148812
148821
148831
148841
148851
148862
148862
148851
148841
148837
148848
148858
148853
148842
148832
148823
148828
148831
148822
148813
148805
148803
148811
148819
148814
148805
148798
148792
148800
148808
148817
148826
148836
148846
148839
148829
148819
148811
148821
148831
148822
148812
148802
148793
148802
148810
148801
148793
148785
148776
148785
148793
148784
148776
148768
148760
148769
148777
148784
148790
148796
148798
148791
148784
148778
148776
148782
148789
148784
148777
148771
148766
148771
148772
148767
148762
148758
148756
148761
148766
148760
148755
148750
148741
148747
148752
148758
148764
148771
148777
148770
148763
148756
148748
148754
148761
148753
148746
148740
148735
148742
148750
148744
148739
148734
148728
148732
148737
148730
148725
148721
148718
148724
148730
148737
148745
148752
148754
148753
148752
148749
148747
148745
148742
148738
148735
148739
148743
148747
148750
148750
148746
148741
148737
148742
148747
148740
148736
148732
148729
148733
148737
148733
148731
148728
148723
148724
148726
148729
148733
148726
148724
148721
148715
148718
148721
148715
148712
148709
148708
148714
148719
148718
148713
148707
148701
148702
148703
148706
148708
148711
148715
148718
148723
148728
148733
148739
148745
148752
148759
148767
148775
148783
148793
148802
148812
148801
148792
148783
148772
148781
148790
148779
148770
148762
148754
148764
148774
148766
148758
148750
148742
148749
148756
148746
148739
148733
148723
148730
148736
148744
148751
148759
148768
148756
148748
148740
148729
148736
148743
148731
148723
148716
148710
148722
148733
148726
148719
148713
148703
148709
148715
148704
148698
148692
148687
148697
148707
148717
148726
148735
148743
148737
148731
148725
148718
148723
148729
148720
148715
148709
148705
148713
148720
148716
148711
148708
148700
148704
148708
148700
148696
148693
148685
148688
148692
148696
148701
148706
148711
148702
148696
148692
148682
148687
148692
148682
148677
148673
148669
148678
148687
148683
148680
148676
148668
148671
148674
148665
148662
148659
148650
148652
148655
148659
148663
148667
148671
148676
148681
148686
148692
148698
148704
148710
148717
148704
148697
148691
148678
148684
148690
148675
148670
148665
148659
148673
148685
148680
148674
148669
148658
148662
148667
148655
148650
148646
148633
148637
148642
148646
148651
148656
148660
148646
148641
148637
148622
148626
148630
148615
148611
148608
148604
148618
148632
148628
148624
148621
148608
148611
148615
148601
148598
148595
148592
148605
148617
148630
148642
148653
148665
148660
148656
148652
148642
148645
148649
148638
148634
148631
148628
148638
148649
148645
148643
148640
148630
148633
148635
148625
148622
148620
148610
148612
148614
148617
148619
148623
148626
148614
148611
148608
148596
148599
148602
148589
148587
148584
148582
148594
148605
148603
148601
148599
148588
148590
148592
148580
148578
148577
148575
148586
148597
148608
148618
148628
148638
148647
148656
148665
148674
148682
148690
148697
148704
148701
148699
148697
148690
148692
148694
148687
148685
148683
148682
148689
148695
148695
148688
148681
148674
148674
148675
148677
148679
148671
148669
148667
148659
148661
148663
148654
148652
148651
148650
148659
148667
148667
148659
148650
148641
148642
148642
148643
148645
148636
148634
148633
148624
148625
148626
148616
148615
148614
148614
148623
148633
148632
148623
148613
148604
148604
148604
148605
148606
148596
148595
148594
148583
148584
148585
148574
148573
148573
148572
148583
148593
148593
148583
148572
148561
148561
148562
148562
148563
148564
148565
148567
148568
148570
148572
148574
148576
148579
148581
148584
148587
148590
148593
148596
148599
148583
148581
148578
148563
148565
148567
148551
148549
148547
148546
148561
148575
148573
148570
148568
148554
148556
148558
148544
148542
148540
148526
148528
148529
148531
148532
148533
148535
148518
148517
148516
148501
148501
148502
148485
148485
148485
148485
148500
148515
148514
148513
148512
148498
148499
148499
148484
148484
148484
148483
148497
148511
148525
148539
148552
148566
148564
148562
148560
148547
148549
148550
148537
148536
148534
148533
148546
148558
148556
148555
148554
148542
148543
148544
148532
148531
148530
148518
148518
148519
148520
148521
148523
148524
148510
148509
148508
148495
148496
148496
148483
148482
148482
148481
148494
148507
148507
148506
148505
148493
148493
148494
148481
148480
148480
148467
148468
148468
148468
148468
148469
148469
148469
148469
148469
148469
148469
148469
148469
148468
148452
148452
148453
148437
148436
148435
148434
148416
148414
148397
148394
148391
148388
148385
148365
148361
148341
148336
148316
148321
148327
148346
148350
148369
148373
148376
148379
148362
148358
148354
148336
148332
148313
148308
148302
148296
148289
148282
148275
148253
148245
148236
148213
148203
148192
148181
148157
148169
148181
148191
148201
148223
148232
148240
148261
148269
148276
148282
148289
148270
148263
148256
148248
148228
148220
148211
148190
148180
148169
148158
148146
148134
148111
148124
148136
148114
148101
148088
148065
148079
148093
148105
148126
148148
148159
148169
148179
148199
148208
148217
148236
148244
148251
148258
148276
148294
148300
148318
148323
148340
148344
148348
148365
148382
148399
148401
148418
148420
148421
148422
148438
148454
148454
148454
148454
148440
148439
148439
148423
148424
148425
148410
148409
148408
148407
148405
148403
148387
148385
148368
148351
148354
148371
148373
148389
148391
148393
148394
148396
148381
148379
148377
148375
148360
148357
148341
148338
148335
148331
148327
148310
148305
148287
148282
148264
148270
148275
148292
148297
148314
148318
148322
148326
148310
148306
148302
148285
148281
148264
148258
148253
148246
148240
148232
148225
148206
148198
148189
148169
148159
148149
148138
148117
148129
148140
148150
148160
148179
148188
148196
148214
148222
148229
148235
148242
148225
148218
148211
148204
148186
148178
148169
148151
148141
148131
148120
148109
148097
148085
148071
148058
148043
148021
148036
148050
148030
148015
148000
147978
147994
148010
148024
148044
148064
148077
148089
148101
148082
148070
148057
148038
148051
148064
148046
148033
148019
148005
147990
147974
147958
147937
147954
147970
147951
147934
147917
147898
147879
147859
147840
147819
147799
147777
147757
147734
147714
147689
147670
147644
147616
147597
147624
147651
147633
147606
147577
147559
147587
147615
147641
147658
147676
147695
147719
147738
147761
147780
147801
147820
147840
147860
147878
147897
147915
147932
147948
147967
147986
148000
148014
148028
148010
147996
147982
147964
147979
147993
148007
148023
148041
148058
148076
148094
148112
148123
148133
148143
148160
148169
148177
148194
148202
148209
148192
148185
148169
148161
148152
148135
148126
148116
148105
148087
148098
148109
148118
148128
148144
148153
148161
148176
148184
148199
148215
148231
148248
148253
148269
148274
148290
148294
148298
148313
148329
148344
148347
148362
148364
148366
148368
148383
148397
148411
148426
148440
148455
148455
148455
148455
148441
148441
148441
148427
148427
148427
148428
148441
148455
148455
148455
148455
148442
148442
148441
148428
148428
148429
148416
148415
148415
148414
148414
148413
148412
148398
148399
148400
148386
148385
148384
148370
148371
148373
148374
148387
148401
148401
148402
148402
148389
148389
148388
148375
148376
148376
148377
148390
148403
148416
148429
148442
148454
148467
148480
148492
148505
148517
148529
148541
148553
148552
148551
148550
148539
148539
148540
148528
148528
148527
148527
148539
148550
148550
148539
148527
148515
148515
148516
148516
148516
148504
148504
148504
148491
148492
148492
148480
148479
148479
148479
148491
148503
148503
148491
148479
148467
148467
148467
148467
148467
148454
148454
148454
148442
148442
148442
148429
148429
148429
148429
148442
148454
148454
148441
148429
148416
148416
148416
148416
148416
148403
148403
148403
148391
148390
148390
148377
148378
148378
148378
148391
148403
148403
148391
148378
148365
148365
148365
148365
148364
148364
148363
148362
148361
148360
148359
148357
148356
148354
148352
148349
148335
148332
148317
148302
148305
148320
148323
148337
148339
148342
148343
148345
148332
148330
148328
148325
148311
148308
148294
148290
148287
148283
148279
148263
148258
148243
148237
148222
148227
148233
148248
148253
148268
148272
148276
148280
148265
148262
148257
148243
148238
148223
148218
148212
148206
148191
148197
148203
148189
148182
148175
148168
148153
148145
148137
148121
148112
148102
148092
148081
148070
148053
148064
148075
148059
148048
148036
148019
148032
148044
148055
148070
148086
148096
148106
148115
148130
148138
148146
148160
148168
148174
148180
148195
148209
148214
148228
148233
148247
148251
148255
148269
148283
148297
148300
148314
148316
148318
148320
148333
148347
148348
148349
148350
148337
148336
148335
148321
148323
148324
148311
148310
148308
148306
148304
148302
148289
148286
148272
148259
148262
148275
148278
148291
148293
148295
148297
148298
148286
148284
148282
148280
148267
148265
148252
148249
148245
148242
148237
148224
148219
148205
148200
148186
148192
148197
148210
148215
148228
148232
148235
148239
148226
148223
148219
148206
148202
148189
148184
148178
148173
148167
148160
148153
148139
148131
148123
148109
148100
148090
148081
148065
148076
148085
148071
148061
148051
148040
148028
148016
148003
147990
147976
147962
147946
147931
147914
147896
147878
147860
147841
147822
147804
147783
147765
147742
147725
147701
147683
147666
147691
147707
147730
147747
147769
147786
147806
147824
147843
147861
147878
147896
147913
147929
147945
147960
147944
147928
147912
147896
147879
147863
147845
147826
147810
147790
147773
147752
147736
147714
147698
147675
147650
147624
147598
147570
147541
147524
147494
147477
147445
147412
147377
147360
147395
147429
147413
147379
147344
147308
147292
147254
147239
147199
147185
147143
147130
147086
147040
146993
146943
146930
146878
146866
146812
146756
146697
146686
146744
146801
146855
146907
146918
146968
146980
147028
147016
147006
146957
146948
146898
146845
146791
146734
146675
146666
146725
146782
146774
146717
146658
146596
146590
146525
146520
146453
146383
146311
146306
146231
146153
146150
146068
146066
146148
146227
146228
146304
146376
146379
146449
146516
146513
146446
146444
146375
146302
146511
146576
146577
146580
146584
146646
146651
146711
146768
146823
146829
146837
146889
146940
146988
146997
147043
147052
147062
147074
147118
147160
147172
147213
147225
147264
147278
147315
147329
147364
147399
147385
147351
147338
147302
147290
147252
147241
147201
147191
147150
147107
147097
147140
147181
147221
147230
147268
147278
147315
147326
147361
147372
147405
147418
147431
147446
147461
147492
147507
147537
147553
147581
147565
147550
147521
147507
147477
147463
147493
147522
147536
147564
147578
147593
147608
147634
147659
147683
147668
147644
147619
147604
147630
147654
147641
147616
147590
147577
147550
147538
147510
147480
147450
147437
147468
147498
147526
147553
147565
147591
147603
147628
147616
147605
147580
147569
147543
147515
147487
147457
147426
147394
147383
147350
147340
147305
147296
147259
147251
147213
147173
147131
147088
147080
147035
147028
146981
146933
146882
146876
146927
146975
146971
146922
146871
146818
146763
146705
146702
146642
146639
146638
146698
146699
146756
146759
146814
146867
146918
146967
146965
146916
146865
146811
146810
146755
146863
146914
146963
147011
147012
147014
147018
147022
147068
147073
147117
147123
147165
147159
147153
147111
147107
147063
147060
147103
147145
147149
147189
147193
147199
147205
147244
147281
147288
147323
147331
147365
147374
147406
147416
147447
147477
147468
147438
147429
147398
147390
147357
147351
147316
147310
147275
147237
147232
147269
147305
147340
147345
147378
147384
147415
147422
147452
147460
147489
147497
147506
147533
147560
147585
147595
147619
147629
147640
147652
147664
147678
147691
147706
147721
147743
147758
147778
147794
147813
147829
147847
147865
147880
147897
147912
147928
147913
147898
147882
147867
147850
147832
147817
147798
147784
147764
147749
147728
147714
147700
147722
147735
147756
147770
147789
147803
147821
147835
147853
147870
147883
147899
147913
147928
147943
147958
147974
147988
148001
148013
147998
147985
147972
147957
147971
147984
147996
148010
148025
148036
148047
148057
148043
148033
148022
148008
148019
148030
148017
148006
147994
147982
147970
147956
147942
147928
147942
147956
147943
147929
147914
147901
147886
147872
147856
147839
147826
147808
147795
147776
147763
147743
147730
147709
147687
147675
147697
147718
147707
147685
147663
147652
147675
147696
147717
147727
147739
147750
147770
147782
147801
147813
147831
147843
147860
147876
147888
147903
147916
147930
147943
147956
147969
147981
147993
148004
147992
147980
147968
147956
147968
147980
147968
147956
147944
147931
147917
147905
147891
147879
147863
147847
147835
147818
147807
147789
147777
147758
147747
147737
147756
147766
147784
147795
147813
147824
147840
147852
147867
147882
147894
147908
147919
147932
147945
147957
147946
147934
147921
147910
147897
147886
147871
147856
147845
147829
147819
147802
147792
147774
147765
147746
147727
147707
147687
147665
147642
147633
147610
147601
147577
147551
147524
147517
147543
147569
147562
147536
147510
147481
147475
147446
147440
147410
147405
147373
147369
147336
147301
147265
147228
147225
147186
147184
147143
147101
147057
147056
147100
147142
147183
147222
147223
147260
147262
147298
147296
147295
147259
147330
147331
147333
147366
147398
147401
147432
147436
147465
147470
147498
147503
147530
147556
147551
147525
147521
147493
147490
147461
147459
147429
147427
147396
147364
147363
147395
147426
147456
147457
147485
147487
147514
147517
147543
147547
147572
147576
147581
147587
147594
147618
147625
147648
147656
147678
147670
147663
147641
147634
147611
147605
147628
147651
147656
147677
147684
147691
147699
147719
147738
147756
147749
147730
147711
147704
147723
147742
147736
147717
147698
147692
147672
147667
147646
147624
147600
147596
147619
147642
147663
147684
147688
147707
147712
147730
147726
147722
147703
147700
147680
147660
147638
147616
147593
147569
147566
147541
147539
147513
147512
147484
147538
147563
147564
147589
147590
147614
147636
147634
147612
147611
147588
147633
147655
147656
147657
147678
147698
147717
147719
147737
147740
147744
147748
147754
147760
147766
147774
147782
147799
147809
147825
147835
147850
147861
147876
147890
147900
147913
147924
147936
147926
147916
147903
147893
147880
147865
147855
147840
147831
147815
147807
147791
147783
147777
147793
147800
147815
147823
147838
147846
147860
147870
147884
147897
147906
147919
147928
147938
147948
147958
147969
147980
147991
148003
148015
148027
148040
148053
148067
148080
148094
148103
148117
148125
148132
148146
148153
148159
148165
148171
148158
148152
148146
148139
148126
148119
148111
148098
148089
148076
148085
148093
148106
148113
148120
148133
148139
148145
148151
148163
148176
148181
148193
148197
148210
148213
148217
148229
148242
148254
148257
148269
148271
148273
148260
148259
148246
148244
148232
148219
148222
148234
148236
148248
148250
148262
148274
148287
148299
148312
148325
148338
148351
148351
148352
148352
148339
148339
148339
148326
148326
148327
148327
148340
148352
148352
148340
148327
148314
148314
148314
148314
148313
148300
148301
148301
148289
148289
148288
148275
148276
148277
148277
148289
148302
148302
148289
148277
148264
148264
148264
148264
148263
148251
148252
148252
148240
148240
148239
148237
148226
148224
148212
148210
148207
148204
148201
148189
148185
148173
148168
148156
148161
148165
148177
148180
148192
148195
148198
148200
148189
148187
148184
148172
148169
148157
148153
148149
148144
148139
148133
148127
148115
148108
148101
148088
148080
148072
148063
148050
148059
148068
148076
148084
148096
148103
148109
148121
148127
148132
148138
148142
148131
148126
148121
148115
148104
148098
148091
148079
148072
148064
148056
148047
148037
148025
148035
148044
148032
148023
148013
148002
148012
148021
148030
148041
148052
148061
148068
148075
148086
148093
148099
148110
148115
148120
148125
148135
148146
148150
148161
148164
148175
148178
148180
148191
148202
148214
148215
148227
148228
148228
148229
148240
148252
148252
148240
148229
148217
148217
148217
148216
148205
148204
148193
148182
148183
148194
148194
148205
148206
148206
148194
148194
148183
148183
148173
148172
148171
148169
148167
148156
148153
148143
148139
148129
148132
148135
148146
148148
148158
148160
148162
148162
148152
148151
148150
148140
148138
148128
148125
148122
148118
148114
148110
148105
148094
148088
148082
148072
148065
148057
148050
148039
148047
148054
148061
148068
148078
148084
148089
148099
148104
148108
148112
148116
148106
148103
148099
148094
148085
148080
148074
148064
148058
148052
148044
148037
148028
148020
148010
148001
147990
147980
147990
148000
147990
147980
147969
147959
147970
147980
147990
147999
148009
148018
148027
148035
148025
148017
148009
147999
148008
148016
148007
147999
147990
147981
147971
147961
147950
147940
147951
147962
147953
147942
147931
147922
147910
147900
147887
147874
147866
147852
147844
147830
147823
147809
147803
147787
147771
147765
147782
147798
147793
147778
147761
147757
147774
147790
147805
147808
147813
147818
147832
147838
147851
147858
147871
147879
147891
147904
147913
147924
147933
147944
147955
147963
147972
147981
147990
147999
147991
147982
147973
147965
147974
147983
147991
147999
148007
148015
148024
148033
148042
148049
148055
148061
148070
148075
148080
148089
148093
148097
148088
148084
148076
148071
148066
148058
148052
148046
148040
148031
148037
148044
148049
148054
148063
148067
148071
148079
148083
148091
148100
148109
148118
148121
148130
148132
148141
148142
148142
148152
148162
148173
148172
148183
148162
148152
148142
148132
148132
148132
148123
148122
148113
148112
148103
148104
148105
148114
148114
148123
148123
148113
148105
148105
148097
148097
148096
148094
148086
148088
148089
148081
148080
148077
148074
148067
148063
148059
148051
148046
148041
148035
148029
148022
148014
148021
148028
148020
148013
148006
147999
148006
148013
148019
148026
148033
148039
148044
148048
148055
148059
148062
148070
148072
148073
148074
148081
148089
148088
148096
148080
148073
148066
148066
148066
148065
148058
148055
148052
148045
148041
148037
148032
148025
148030
148034
148038
148042
148048
148051
148053
148059
148060
148059
148053
148053
148047
148047
148045
148039
148035
148032
148028
148023
148018
148012
148006
147999
147992
147984
147975
147966
147957
147946
147936
147927
147915
147907
147896
147884
147877
147864
147859
147846
147841
147827
147823
147819
147833
147836
147849
147854
147866
147871
147883
147889
147900
147911
147918
147929
147938
147948
147958
147967
147959
147949
147939
147932
147921
147915
147905
147894
147889
147878
147873
147862
147858
147846
147843
147830
147816
147802
147787
147771
147754
147752
147735
147733
147715
147696
147676
147675
147695
147714
147732
147750
147750
147767
147769
147784
147783
147782
147766
147797
147798
147799
147814
147828
147841
147839
147826
147812
147812
147825
147838
147851
147852
147853
147855
147867
147870
147881
147885
147895
147900
147910
147919
147925
147934
147941
147951
147943
147937
147928
147924
147915
147905
147902
147892
147889
147878
147876
147865
147864
147863
147874
147875
147885
147887
147897
147899
147908
147911
147920
147928
147932
147940
147945
147952
147960
147968
147976
147984
147992
147999
147992
147985
147977
147969
147977
147985
147992
147999
148006
148012
148017
148022
148016
148011
148005
147999
148005
148010
148004
147998
147991
147984
147977
147969
147961
147954
147961
147969
147962
147955
147948
147944
147936
147933
147925
147917
147915
147906
147905
147895
147895
147885
147904
147913
147914
147922
147923
147931
147938
147940
147947
147951
147957
147964
147969
147976
147984
147990
147997
147989
147983
147976
147970
147976
147982
147976
147971
147965
147960
147954
147951
147945
147943
147937
147930
147929
147921
147936
147942
147948
147949
147955
147957
147962
147967
147972
147969
147965
147960
147959
147954
147963
147967
147972
147974
147977
147982
147988
147995
148003
148009
148015
148020
148026
148030
148033
148035
148041
148041
148041
148047
148036
148036
148031
148030
148028
148024
148019
148023
148025
148026
148026
148031
148021
148021
148020
148018
148014
148008
148013
148016
148011
148007
148001
147993
147999
148004
148007
148012
148017
148017
148013
148008
147999
147999
147997
147992
147987
147982
147987
147989
147986
147983
147979
147976
147980
147982
147982
147987
147990
147991
147987
147984
148987
148870
148855
148863
148879
148786
148790
148780
148774
148669
147901
148218
148345
148301
148474
148469
147778
147578
147517
147512
147385
147365
146708
146723
146799
147063
146522
146497
146077
143491
143987
144054
144172
144676
142799
142753
141838
141703
139737
139688
138306
137662
137575
136846
126783
123906
148761
148758
148758
148765
148766
148756
148744
148737
148734
148734
148733
148732
148728
148724
148720
148715
148709
148703
148697
148690
148683
148675
148668
148660
148651
148642
148633
148624
148614
148604
148594
148583
148572
148561
148550
148539
148527
148515
148503
148491
148479
148466
148454
148441
148429
148416
148403
148390
148378
148365
148352
148339
148326
148314
148301
148289
148276
148264
148252
148240
148228
148216
148204
148193
148182
148171
148160
148150
148140
148130
148120
148111
148101
148093
148084
148076
148068
148061
148054
148047
148040
148034
148028
148023
148017
148012
148007
148003
147998
147992
147989
147988
148741
148751
148764
148742
)
;
boundaryField
{
bottomEmptyFaces
{
type empty;
}
topEmptyFaces
{
type empty;
}
inlet
{
type uniformTotalPressure;
rho rho;
psi none;
gamma 1;
p0 constant 150000;
value nonuniform List<scalar>
95
(
147987
147987
147987
147988
147989
147992
147996
148002
148009
148015
148022
148029
148035
148042
148050
148057
148065
148073
148081
148090
148099
148108
148118
148128
148138
148148
148159
148169
148180
148192
148203
148215
148227
148238
148251
148263
148275
148288
148300
148313
148326
148339
148351
148364
148377
148390
148403
148416
148428
148441
148454
148466
148479
148491
148503
148515
148527
148539
148550
148562
148573
148584
148594
148605
148615
148624
148634
148643
148652
148661
148669
148677
148685
148692
148699
148706
148713
148719
148726
148731
148735
148737
148737
148736
148735
148735
148737
148741
148748
148735
148735
147987
148817
148771
148759
)
;
}
outlet
{
type fixedValue;
value uniform 130000;
}
walls
{
type zeroGradient;
}
rightWall
{
type fixedValue;
value uniform 149000;
}
symmetryLine
{
type symmetryPlane;
}
}
// ************************************************************************* //
|
|
3ef8ae339f1e58d02eb3700a784aa7ae924332c0
|
a6445017ba43f4ee5fc3e9535d01d4cda8ed6c25
|
/Esercizi/Basic/Fibonacci/fibonacci.cpp
|
78ae4143fe75f57cdc52c616b3586fb74c278818
|
[
"MIT"
] |
permissive
|
gabrielegenovese/Esercizi-Programmazione-2020
|
361c5514b536083aaef5df92607a2c92a5a5fc68
|
bb16aec872ece3f7d88fcbfc88b3778efcb4f16b
|
refs/heads/main
| 2023-02-18T00:16:04.483500
| 2021-01-18T10:14:40
| 2021-01-18T10:14:40
| 307,976,771
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 256
|
cpp
|
fibonacci.cpp
|
#include <iostream>
using namespace std;
int main()
{
int n, ultimo = 0, ris = 1;
cout << "Inserire un numero" << endl;
cin >> n;
while (n-- > 2)
{
ris = ris + ultimo;
ultimo = ris-ultimo;
}
cout << ris;
}
|
7b8ec306339d66aed37d9072a0db7f796974f640
|
998e7931d1a53913b36d3085a6e52d699f611c85
|
/BaekJoon/BaekJoon/11279 최대힙(구현).cpp
|
33c99b581357741ab032a158febae410aca7eeec
|
[] |
no_license
|
wooniverse7/AlgoStudy2021
|
2d5541ecf04f9f5d427f591a0c8b5e98a54b38d4
|
e206070fbc05f18b5a7fb74aa839f4aa16b5fc1e
|
refs/heads/main
| 2023-06-29T05:20:02.015436
| 2021-07-27T14:49:15
| 2021-07-27T14:49:15
| 328,540,833
| 1
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 782
|
cpp
|
11279 최대힙(구현).cpp
|
// 힙을 배열로 구현(정적)
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100002
int heap[MAX];
int sz = 0; // 배열 크기
void swap(int* a, int* b) { // &는 안되고 pointer만 되는 이유 찾아보기. &로 구현해보기
int temp = *a;
*a = *b;
*b = temp;
}
void insert(int num) {
int idx = ++sz; // 삽입 때 마다 사이즈 먼저 1 증가
while ((idx != 1) && (num > heap[idx / 2])) {// 첫 번째가 아니고 입력된 num이 현재 idx의 부모노드보다 클 때까지
heap[idx] = heap[idx / 2]; //
idx /= 2;
}
heap[idx] = num;
}
int deleteHeap() {
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, x; // 반복수, 정보가 담긴 수
cin >> n;
while (n--) {
cin >> x;
}
}
|
47f30c13448209de277e7d46111e69c38cc4ca3d
|
4e5d07a9eb881defd7923a4575809259522bd25f
|
/atcoder/abc/224/d.cpp
|
bdf4c5daa547b9c5623ede3b9bd20ce55cae0027
|
[] |
no_license
|
kt117/ProCom
|
c81e6c55c3f4b329c79755f43e8154e297328174
|
c5547429560100728cf15a8a8a696aa8c6c0317b
|
refs/heads/master
| 2022-05-06T15:41:01.639231
| 2022-04-09T17:23:21
| 2022-04-09T17:23:21
| 254,284,537
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,824
|
cpp
|
d.cpp
|
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;
ll encode(vector<ll> v){
ll res = 0;
zep(i, 0, v.size()){
res *= 10;
res += v[i];
}
return res;
}
struct dijkstra{
vector<long long> min_dst;
vector<vector<pair<long long, long long>>> G;
dijkstra(int n){
min_dst.resize(n);
G.resize(n);
}
void append(int u, int v, long long cost){G[u].push_back(make_pair(v, cost));}
void run(int s){
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> que;
fill(min_dst.begin(), min_dst.end(), -1);
min_dst[s] = 0;
que.push(make_pair(0, s));
while(!que.empty()){
auto p = que.top(); que.pop();
int at = p.second;
if(min_dst[at] < p.first){continue;}
for(int i = 0; i < G[at].size(); i++){
int to = G[at][i].first;
long long cost = G[at][i].second;
if(min_dst[to] == -1 || min_dst[at] + cost < min_dst[to]){
min_dst[to] = min_dst[at] + cost;
que.push(make_pair(min_dst[to], to));
}
}
}
}
long long get(int at){return min_dst[at];}
};
int main(){
cin.tie(0); ios::sync_with_stdio(false);
ll m; cin >> m;
ll u[m], v[m]; zep(i, 0, m){cin >> u[i] >> v[i]; u[i]--; v[i]--;}
ll p[8]; zep(i, 0, 8){cin >> p[i]; p[i]--;}
map<ll, ll> mp;
vector<ll> a = {0, 1, 2, 3, 4, 5, 6, 7, 8};
ll cnt = 0;
do{
mp[encode(a)] = cnt;
cnt++;
}while(next_permutation(a.begin(), a.end()));
dijkstra d(cnt + 1);
do{
zep(i, 0, m){
if(a[u[i]] == 8){
vector<ll> b(a.size());
copy(a.begin(), a.end(), b.begin());
b[u[i]] = a[v[i]];
b[v[i]] = 8;
d.append(mp[encode(a)], mp[encode(b)], 1);
}
if(a[v[i]] == 8){
vector<ll> b(a.size());
copy(a.begin(), a.end(), b.begin());
b[v[i]] = a[u[i]];
b[u[i]] = 8;
d.append(mp[encode(a)], mp[encode(b)], 1);
}
}
}while(next_permutation(a.begin(), a.end()));
vector<ll> c(9, 8);
zep(i, 0, 8)c[p[i]] = i;
d.run(mp[encode(c)]);
print(d.get(mp[encode(a)]))
return 0;
}
|
7a8d09eb448848ae208a0494613da670fbbd0270
|
461dc44f32868e13c23b435cb44d0718475ac633
|
/UI/EventUIMain.h
|
b2920742f834769d85096a5a3d2726ef5d2f2899
|
[] |
no_license
|
WingCuengRay/ControlUi
|
c00156cfa5cef90248b3e52fe342abc1a2c0d393
|
22505bee3ccf10e2cf4ee342fc9b56f0f3de76d1
|
refs/heads/master
| 2021-01-18T22:12:43.711133
| 2017-01-14T02:02:38
| 2017-01-14T02:02:38
| 69,226,407
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 201
|
h
|
EventUIMain.h
|
#ifndef EVENTUIMAIN_H
#define EVENTUIMAIN_H
#include"EventBase.h"
class EventUIMain:public EventBase
{
public:
EventUIMain();
virtual ~EventUIMain();
};
#endif // EVENTUIMAIN_H
|
9222c15bb55f370d9d8eef325b31eaf66f1be12b
|
86530182c3bc55af969091be48c74763dbeecac5
|
/mergesort.cc
|
ea408caa2d54528050db47595bed906b357deede
|
[] |
no_license
|
laakko/parallel-sorts
|
cb3c9952bcaa668fcfbd6ef905a9d842716c647e
|
701b7a4ffcc630c007811e2b577f1735e28cf3d7
|
refs/heads/master
| 2020-04-21T20:58:16.081261
| 2018-11-08T15:01:01
| 2018-11-08T15:01:01
| 169,863,522
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,536
|
cc
|
mergesort.cc
|
#include "mergesort.h"
#include <algorithm>
#include <iostream>
#include <omp.h>
#include <ctime>
void mergesort(int n, data_t* data) {
// FIXME: make this more efficient with parallelism
//std::sort(data, data + n);
unsigned int low = 0;
unsigned int high = n;
#pragma omp parallel
#pragma omp single
mergesort_parallel(data, low, high, omp_get_num_threads());
}
void mergesort_parallel(data_t* data, unsigned int low, unsigned int high, unsigned int threads) {
if(high - low > 1) {
if(threads == 1) {
mergesort_linear(data, low, high);
return;
}
unsigned int mid = low + (high-low) / 2;
#pragma omp task
mergesort_parallel(data, low, mid, threads/2);
#pragma omp task
mergesort_parallel(data, mid, high, threads-threads/2);
#pragma omp taskwait
inplacemerge(data, low, mid, high);
}
}
void mergesort_linear(data_t* data, unsigned int low, unsigned int high) {
if(high - low < 50) {
std::sort(data + low, data + high);
return;
}
unsigned int mid = low + (high-low) / 2;
mergesort_linear(data, low, mid);
mergesort_linear(data, mid, high);
inplacemerge(data, low, mid, high);
}
void inplacemerge(data_t* data, unsigned int low, unsigned int mid, unsigned int high) {
std::inplace_merge(data + low, data + mid, data + high);
}
|
6f61e7e07a52da6a42ce69bfcb196b95871cb02b
|
8fc032bdd555316a5e38e9c940e4e7e888c70239
|
/src/amf/tests/test_message_handler.cpp
|
2bad6f9548f7a2542e1e4c9d7458ed97a8a6384c
|
[
"BSD-3-Clause"
] |
permissive
|
unixod/uau
|
6eb1295f016df424abeeaad51357089cd8cd924d
|
6fb87bce6bc33a66a176f7f63233d1ffadb4f88f
|
refs/heads/develop
| 2020-05-25T11:00:36.938033
| 2015-11-09T20:07:19
| 2015-11-09T20:07:19
| 4,472,850
| 1
| 1
| null | 2014-07-22T19:05:45
| 2012-05-28T17:28:52
|
C++
|
UTF-8
|
C++
| false
| false
| 4,859
|
cpp
|
test_message_handler.cpp
|
#include "lest/lest.hpp"
#include "uau/handlerset.h"
class HandlerName {
public:
HandlerName() :
isObserver(true) {}
HandlerName(const std::string &name) {
const char *sep = handlerName.empty() ? "" : ";";
handlerName.append(sep).append(name);
}
std::string name() const {
return handlerName;
}
~HandlerName() {
if(isObserver)
handlerName.clear();
}
private:
static std::string handlerName;
bool isObserver = false;
};
std::string HandlerName::handlerName;
class Message {
public:
virtual ~Message() {}
};
class Msg1 : public Message{};
class Msg2 : public Message{};
class Msg3 : public Message{};
class Msg4 : public Message{};
class Msg5 : public Message{};
void handlerFreeFunc() {
HandlerName("handlerFreeFunc");
}
void handlerFreeFuncWithArgs(int i, const std::string &str) {
HandlerName("handlerFreeFuncWithArgs");
}
class Foo {
public:
void bar(int) const {
HandlerName("Foo::bar");
}
};
void handlerForMultipleMessages() {
HandlerName("handlerForMultipleMessages");
}
uau::HandlerSet<Message> handler;
const lest::test specification[] = {
"Msg1 -> handlerFreeFunc()", []{
HandlerName lastInvokedHandler;
std::unique_ptr<Message> msg(new Msg1);
EXPECT(handler.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerFreeFunc");
},
"Msg2 -> handlerFreeFuncWithArgs(int i, const std::string &str)",[]{
HandlerName lastInvokedHandler;
std::unique_ptr<Message> msg(new Msg2);
EXPECT(handler.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerFreeFuncWithArgs");
},
"Msg3 -> Foo::bar(int)",[]{
HandlerName lastInvokedHandler;
std::unique_ptr<Message> msg(new Msg3);
EXPECT(handler.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "Foo::bar");
},
"Msg4 -> handlerForMultipleMessages()",[]{
HandlerName lastInvokedHandler;
std::unique_ptr<Message> msg(new Msg4);
EXPECT(handler.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerForMultipleMessages");
},
"Msg5 -> handlerForMultipleMessages()",[]{
HandlerName lastInvokedHandler;
std::unique_ptr<Message> msg(new Msg5);
EXPECT(handler.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerForMultipleMessages");
},
"move constructor", []{
HandlerName lastInvokedHandler;
uau::HandlerSet<Message> h1;
h1.setHandlerFor<Msg1>([]{});
std::unique_ptr<Message> msg(new Msg1);
EXPECT(h1.handle(msg.get()));
uau::HandlerSet<Message> h2 = std::move(h1);
EXPECT(!h1.handle(msg.get()));
EXPECT(h2.handle(msg.get()));
h1.setHandlerFor<Msg3>([]{});
std::unique_ptr<Message> msg3(new Msg3);
EXPECT(h1.handle(msg3.get()));
EXPECT(!h2.handle(msg3.get()));
},
"move assignment", []{
HandlerName lastInvokedHandler;
uau::HandlerSet<Message> h1;
h1.setHandlerFor<Msg1>(handlerFreeFunc);
std::unique_ptr<Message> msg(new Msg1);
EXPECT(h1.handle(msg.get()));
uau::HandlerSet<Message> h2;
h2 = std::move(h1);
EXPECT(!h1.handle(msg.get()));
EXPECT(h2.handle(msg.get()));
h1.setHandlerFor<Msg3>([]{});
std::unique_ptr<Message> msg3(new Msg3);
EXPECT(h1.handle(msg3.get()));
EXPECT(!h2.handle(msg3.get()));
},
"handlers overriding", []{
uau::HandlerSet<Message> h;
std::unique_ptr<Message> msg(new Msg1);
{
HandlerName lastInvokedHandler;
h.setHandlerFor<Msg1>(handlerFreeFunc);
EXPECT(h.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerFreeFunc");
}
{
HandlerName lastInvokedHandler;
h.setHandlerFor<Msg1>(handlerForMultipleMessages);
EXPECT(h.handle(msg.get()));
EXPECT(lastInvokedHandler.name() == "handlerForMultipleMessages");
}
},
"message passing", [] {
uau::HandlerSet<Message> actions;
actions.setHandlerFor<Msg1>([](const Message *b){
EXPECT(dynamic_cast<const Msg1 *>(b));
}, std::placeholders::_1);
std::unique_ptr<Message> msg(new Msg1);
EXPECT(actions.handle(msg.get()));
msg.reset(new Msg2);
EXPECT(!actions.handle(msg.get()));
}
};
int main() {
handler.setHandlerFor<Msg1>(handlerFreeFunc);
handler.setHandlerFor<Msg2>(handlerFreeFuncWithArgs, 1, "second");
Foo foo;
handler.setHandlerFor<Msg3>(&Foo::bar, &foo, 1);
handler.setHandlerFor<Msg4, Msg5>(handlerForMultipleMessages);
return lest::run(specification);
}
|
dabfea5b0b874f5b883769fe0f56d81bb0bf27a8
|
f14626611951a4f11a84cd71f5a2161cd144a53a
|
/Server/GameServer/App/Other/Chat.h
|
1acd0db1e0fc6d28cb1e5f593964d42b69d2dc83
|
[] |
no_license
|
Deadmanovi4/mmo-resourse
|
045616f9be76f3b9cd4a39605accd2afa8099297
|
1c310e15147ae775a59626aa5b5587c6895014de
|
refs/heads/master
| 2021-05-29T06:14:28.650762
| 2015-06-18T01:16:43
| 2015-06-18T01:16:43
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 551
|
h
|
Chat.h
|
#pragma once
// 聊天
class CChat
{
public:
enum eChatType
{
CHAT_NORMAL = 0, // 同屏聊天
CHAT_REGION, // 同场景聊天
CHAT_FACTION, // 帮会聊天
CHAT_UNION, // 联盟聊天
CHAT_TEAM, // 队伍聊天
CHAT_PRIVATE, // 两人私聊
CHAT_COUNTRY, // 国家聊天
CHAT_WOLRD, // 世界聊天
CHAT_BOARDCAST, // 广播
GM_CMD, // GM命令
RUN_SCRIPT, // 运行脚本
RUN_HELP, // 帮助
TYPE_NUM,
};
public:
CChat(void);
virtual ~CChat(void);
};
|
ff52d699573581282cc937cee6b3da92d089afb1
|
00b1ab93bf38f7149ac016d653a2571ca5d83c78
|
/20210408/ds_第五次上机要求_part1/SampleProject/MyString.h
|
07c5ba806443aea8886ba9f233261513909021d2
|
[] |
no_license
|
6607changchun/SS8ruoyan
|
b93657a5c5c5c6fee93f2b33f6d0bdd6c1aa1536
|
360dac1d8fbaf44fa145e32582d58a13f955a38e
|
refs/heads/main
| 2023-05-31T05:52:12.339894
| 2021-06-15T20:25:13
| 2021-06-15T20:25:13
| 370,192,908
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,687
|
h
|
MyString.h
|
/*******************************************************************************
* FileName: MyString.h
* Author: Your_Name
* Student Number: 2019218XXX
* Date: 2020/03/18 11:24:55
* Version: v1.0
* Description: Data Structure Experiment #6
*******************************************************************************/
#ifndef MYSTRING_H
#define MYSTRING_H
class MyString{
private:
static const int MAX_LENGTH = 1000;
char value[MAX_LENGTH];
int len;
public:
/**
构造函数
@name MyString(const char*);
@param const char* 需要构建为String的字符串。
@return
*/
MyString(const char*);
//析构函数
~MyString();
/**
* 将字符串location的位置以及之后的位置替换为str
@name replace(const char*, const int&);
@param const char* 需要替换的字符串
const int& 需要替换的位置
@return void
*/
void replace(const char* str, int location);
/**
返回字符串长度
@name length()
@param
@return int 字符串的长度
*/
int length() const;
/**
查找str在字符串中第一次出现的位置
@name length()
@param const char* 需要查找的字符串
@return int 字符串str第一次出现的位置,如果没有出现,则返回-1.
*/
int find(const char*) const;
/**
返回储存的字符串的C语言风格表示。
@name c_string()
@param
@return const char* 返回的C语言风格字符串。
*/
const char* c_string() const;
};
#endif
|
7ed62176449c3df51b263e440ae5b44033a80350
|
a421596a80aa072c655ce0c9df43fda61a6ff88e
|
/cpp/cpp/main.cpp
|
0db6a02489f435c1962d6ee7239c0185cbcb6faf
|
[] |
no_license
|
gksmfahd78/backjoon_algorithm
|
ba13657c97ab50ad33478e4b5bc825983206906a
|
faca1da16b0f6ba572110638063052946fd2a76d
|
refs/heads/master
| 2021-07-10T15:09:34.463948
| 2021-05-10T02:19:59
| 2021-05-10T02:19:59
| 238,806,858
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 38
|
cpp
|
main.cpp
|
#include "solution.h"
int main() {
}
|
23eaf464d5f78e76c9b2e68b4d8262d4f04b4e57
|
002b6230874dea6e4d76defafc1ae293b5744918
|
/library/SpatialDomains/Conditions.cpp
|
b3b20064d64b4c8d1cc376c42823f26c1ca6e5e0
|
[
"MIT"
] |
permissive
|
SCOREC/nektar
|
f3cf3c44106ac7a2dd678366bb53861e2db67a11
|
add6f04b55fad6ab29d08b5b27eefd9bfec60be3
|
refs/heads/master
| 2021-01-22T23:16:16.440068
| 2015-02-27T17:26:09
| 2015-02-27T17:26:09
| 30,382,914
| 6
| 7
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 32,069
|
cpp
|
Conditions.cpp
|
////////////////////////////////////////////////////////////////////////////////
//
// File: BoundaryConditions.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// 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.
//
// Description:
//
//
////////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
#include <SpatialDomains/Conditions.h>
#include <tinyxml/tinyxml.h>
namespace Nektar
{
namespace SpatialDomains
{
BoundaryConditions::BoundaryConditions(const LibUtilities::SessionReaderSharedPtr &pSession, const MeshGraphSharedPtr &meshGraph)
: m_meshGraph(meshGraph),
m_session (pSession)
{
Read(m_session->GetElement("Nektar/Conditions"));
}
BoundaryConditions::~BoundaryConditions()
{
}
/**
*
*/
void BoundaryConditions::Read(TiXmlElement *conditions)
{
ASSERTL0(conditions, "Unable to find CONDITIONS tag in file.");
TiXmlElement *boundaryRegions = conditions->FirstChildElement("BOUNDARYREGIONS");
if(boundaryRegions)
{
ReadBoundaryRegions(conditions);
ReadBoundaryConditions(conditions);
}
}
/**
*
*/
void BoundaryConditions::ReadBoundaryRegions(TiXmlElement *conditions)
{
TiXmlElement *boundaryRegions = conditions->FirstChildElement("BOUNDARYREGIONS");
ASSERTL0(boundaryRegions, "Unable to find BOUNDARYREGIONS block.");
// See if we have boundary regions defined.
TiXmlElement *boundaryRegionsElement = boundaryRegions->FirstChildElement("B");
while (boundaryRegionsElement)
{
/// All elements are of the form: "<B ID="#"> ... </B>", with
/// ? being the element type.
int indx;
int err = boundaryRegionsElement->QueryIntAttribute("ID", &indx);
ASSERTL0(err == TIXML_SUCCESS, "Unable to read attribute ID.");
TiXmlNode* boundaryRegionChild = boundaryRegionsElement->FirstChild();
// This is primarily to skip comments that may be present.
// Comments appear as nodes just like elements.
// We are specifically looking for text in the body
// of the definition.
while(boundaryRegionChild && boundaryRegionChild->Type() != TiXmlNode::TEXT)
{
boundaryRegionChild = boundaryRegionChild->NextSibling();
}
ASSERTL0(boundaryRegionChild, "Unable to read variable definition body.");
std::string boundaryRegionStr = boundaryRegionChild->ToText()->ValueStr();
std::string::size_type indxBeg = boundaryRegionStr.find_first_of('[') + 1;
std::string::size_type indxEnd = boundaryRegionStr.find_last_of(']') - 1;
ASSERTL0(indxBeg <= indxEnd, (std::string("Error reading boundary region definition:") + boundaryRegionStr).c_str());
std::string indxStr = boundaryRegionStr.substr(indxBeg, indxEnd - indxBeg + 1);
if (!indxStr.empty())
{
// Extract the composites from the string and return them in a list.
BoundaryRegionShPtr boundaryRegion(MemoryManager<BoundaryRegion>::AllocateSharedPtr());
ASSERTL0(m_boundaryRegions.count(indx) == 0,
"Boundary region "+indxStr+ " defined more than "
"once!");
m_meshGraph->GetCompositeList(indxStr, *boundaryRegion);
m_boundaryRegions[indx] = boundaryRegion;
}
boundaryRegionsElement = boundaryRegionsElement->NextSiblingElement("B");
}
}
/**
*
*/
void BoundaryConditions::ReadBoundaryConditions(TiXmlElement *conditions)
{
// Read REGION tags
TiXmlElement *boundaryConditionsElement = conditions->FirstChildElement("BOUNDARYCONDITIONS");
ASSERTL0(boundaryConditionsElement, "Boundary conditions must be specified.");
TiXmlElement *regionElement = boundaryConditionsElement->FirstChildElement("REGION");
// Read R (Robin), D (Dirichlet), N (Neumann), P (Periodic) [What about Cauchy?] tags
while (regionElement)
{
BoundaryConditionMapShPtr boundaryConditions = MemoryManager<BoundaryConditionMap>::AllocateSharedPtr();
int boundaryRegionID;
int err = regionElement->QueryIntAttribute("REF", &boundaryRegionID);
ASSERTL0(err == TIXML_SUCCESS, "Error reading boundary region reference.");
// Find the boundary region corresponding to this ID.
std::string boundaryRegionIDStr;
std::ostringstream boundaryRegionIDStrm(boundaryRegionIDStr);
boundaryRegionIDStrm << boundaryRegionID;
ASSERTL0(m_boundaryRegions.count(boundaryRegionID) == 1,
"Boundary region " + boost::lexical_cast<
string>(boundaryRegionID)+ " not found");
// Here is the boundary region.
// m_boundaryRegions[boundaryRegionID];
TiXmlElement *conditionElement = regionElement->FirstChildElement();
std::vector<std::string> vars = m_session->GetVariables();
while (conditionElement)
{
// Check type.
std::string conditionType = conditionElement->Value();
std::string attrData;
// All have var specified, or else all variables are zero.
TiXmlAttribute *attr = conditionElement->FirstAttribute();
std::vector<std::string>::iterator iter;
std::string attrName;
attrData = conditionElement->Attribute("VAR");
if (!attrData.empty())
{
iter = std::find(vars.begin(), vars.end(), attrData);
ASSERTL0(iter != vars.end(), (std::string("Cannot find variable: ") + attrData).c_str());
}
if (conditionType == "N")
{
if (attrData.empty())
{
// All variables are Neumann and are set to zero.
for (std::vector<std::string>::iterator varIter = vars.begin();
varIter != vars.end(); ++varIter)
{
BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session,"00.0"));
(*boundaryConditions)[*varIter] = neumannCondition;
}
}
else
{
// Use the iterator from above, which must point to the variable.
attr = attr->Next();
if (attr)
{
std::string equation, userDefined, filename;
while(attr)
{
attrName = attr->Name();
if (attrName=="USERDEFINEDTYPE")
{
// Do stuff for the user defined attribute
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "USERDEFINEDTYPE attribute must have associated value.");
// Suppose to go here?
m_session->SubstituteExpressions(attrData);
userDefined = attrData;
}
else if(attrName=="VALUE")
{
ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "VALUE attribute must be specified.");
m_session->SubstituteExpressions(attrData);
equation = attrData;
}
else if(attrName=="FILE")
{
ASSERTL0(attrName == "FILE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "FILE attribute must be specified.");
m_session->SubstituteExpressions(attrData);
filename = attrData;
}
attr = attr->Next();
}
BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session, equation, userDefined, filename));
(*boundaryConditions)[*iter] = neumannCondition;
}
else
{
// This variable's condition is zero.
BoundaryConditionShPtr neumannCondition(MemoryManager<NeumannBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
(*boundaryConditions)[*iter] = neumannCondition;
}
}
}
else if (conditionType == "D")
{
if (attrData.empty())
{
// All variables are Dirichlet and are set to zero.
for (std::vector<std::string>::iterator varIter = vars.begin();
varIter != vars.end(); ++varIter)
{
BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
(*boundaryConditions)[*varIter] = dirichletCondition;
}
}
else
{
// Use the iterator from above, which must point to the variable.
attr = attr->Next();
if (attr)
{
std::string equation, userDefined, filename;
while(attr) {
attrName = attr->Name();
if (attrName=="USERDEFINEDTYPE") {
// Do stuff for the user defined attribute
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "USERDEFINEDTYPE attribute must have associated value.");
m_session->SubstituteExpressions(attrData);
userDefined = attrData;
}
else if(attrName=="VALUE")
{
ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");
m_session->SubstituteExpressions(attrData);
equation = attrData;
}
else if(attrName=="FILE")
{
ASSERTL0(attrName == "FILE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "FILE attribute must be specified.");
m_session->SubstituteExpressions(attrData);
filename = attrData;
}
attr = attr->Next();
}
BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, equation, userDefined, filename));
(*boundaryConditions)[*iter] = dirichletCondition;
}
else
{
// This variable's condition is zero.
BoundaryConditionShPtr dirichletCondition(MemoryManager<DirichletBoundaryCondition>::AllocateSharedPtr(m_session, "0"));
(*boundaryConditions)[*iter] = dirichletCondition;
}
}
}
else if (conditionType == "R") // Read du/dn + PRIMCOEFF u = VALUE
{
if (attrData.empty())
{
// All variables are Robin and are set to zero.
for (std::vector<std::string>::iterator varIter = vars.begin();
varIter != vars.end(); ++varIter)
{
BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, "0", "0"));
(*boundaryConditions)[*varIter] = robinCondition;
}
}
else
{
// Use the iterator from above, which must
// point to the variable. Read the A and
// B attributes.
attr = attr->Next();
if (attr)
{
std::string attrName1;
std::string attrData1;
std::string equation1, equation2, userDefined;
std::string filename;
while(attr){
attrName1 = attr->Name();
if (attrName1=="USERDEFINEDTYPE") {
// Do stuff for the user defined attribute
attrData1 = attr->Value();
ASSERTL0(!attrData1.empty(), "USERDEFINEDTYPE attribute must have associated value.");
m_session->SubstituteExpressions(attrData1);
userDefined = attrData1;
}
else if(attrName1 == "VALUE"){
ASSERTL0(attrName1 == "VALUE", (std::string("Unknown attribute: ") + attrName1).c_str());
attrData1 = attr->Value();
ASSERTL0(!attrData1.empty(), "VALUE attributes must have associated values.");
m_session->SubstituteExpressions(attrData1);
equation1 = attrData1;
attr = attr->Next();
ASSERTL0(attr, "Unable to read PRIMCOEFF attribute.");
attrName1= attr->Name();
ASSERTL0(attrName1 == "PRIMCOEFF", (std::string("Unknown attribute: ") + attrName1).c_str());
attrData1 = attr->Value();
ASSERTL0(!attrData1.empty(), "PRIMCOEFF attributes must have associated values.");
m_session->SubstituteExpressions(attrData1);
equation2 = attrData1;
}
else if(attrName1=="FILE")
{
ASSERTL0(attrName1 == "FILE", (std::string("Unknown attribute: ") + attrName1).c_str());
attrData1 = attr->Value();
ASSERTL0(!attrData1.empty(), "FILE attribute must be specified.");
m_session->SubstituteExpressions(attrData1);
filename = attrData1;
}
attr = attr->Next();
}
BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, equation1, equation2, userDefined, filename));
(*boundaryConditions)[*iter] = robinCondition;
}
else
{
// This variable's condition is zero.
BoundaryConditionShPtr robinCondition(MemoryManager<RobinBoundaryCondition>::AllocateSharedPtr(m_session, "0", "0"));
(*boundaryConditions)[*iter] = robinCondition;
}
}
}
else if (conditionType == "P")
{
if (attrData.empty())
{
attr = attr->Next();
if (attr)
{
attrName = attr->Name();
ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");
int beg = attrData.find_first_of("[");
int end = attrData.find_first_of("]");
std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
ASSERTL0(beg < end, (std::string("Error reading periodic boundary region definition for boundary region: ")
+ boundaryRegionIDStrm.str()).c_str());
vector<unsigned int> periodicBndRegionIndex;
bool parseGood = ParseUtils::GenerateSeqVector(periodicBndRegionIndexStr.c_str(), periodicBndRegionIndex);
ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string("Unable to read periodic boundary condition for boundary region: ")
+ boundaryRegionIDStrm.str()).c_str());
BoundaryConditionShPtr periodicCondition(MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(periodicBndRegionIndex[0]));
for (std::vector<std::string>::iterator varIter = vars.begin();
varIter != vars.end(); ++varIter)
{
(*boundaryConditions)[*varIter] = periodicCondition;
}
}
else
{
ASSERTL0(false, "Periodic boundary conditions should be explicitely defined");
}
}
else
{
// Use the iterator from above, which must point to the variable.
// Read the VALUE attribute. It is the next and only other attribute.
attr = attr->Next();
if (attr)
{
attrName = attr->Name();
ASSERTL0(attrName == "VALUE", (std::string("Unknown attribute: ") + attrName).c_str());
attrData = attr->Value();
ASSERTL0(!attrData.empty(), "VALUE attribute must have associated value.");
int beg = attrData.find_first_of("[");
int end = attrData.find_first_of("]");
std::string periodicBndRegionIndexStr = attrData.substr(beg+1,end-beg-1);
ASSERTL0(beg < end, (std::string("Error reading periodic boundary region definition for boundary region: ")
+ boundaryRegionIDStrm.str()).c_str());
vector<unsigned int> periodicBndRegionIndex;
bool parseGood = ParseUtils::GenerateSeqVector(periodicBndRegionIndexStr.c_str(), periodicBndRegionIndex);
ASSERTL0(parseGood && (periodicBndRegionIndex.size()==1), (std::string("Unable to read periodic boundary condition for boundary region: ") + boundaryRegionIDStrm.str()).c_str());
BoundaryConditionShPtr periodicCondition(MemoryManager<PeriodicBoundaryCondition>::AllocateSharedPtr(periodicBndRegionIndex[0]));
(*boundaryConditions)[*iter] = periodicCondition;
}
else
{
ASSERTL0(false, "Periodic boundary conditions should be explicitely defined");
}
}
}
else if (conditionType == "C")
{
NEKERROR(ErrorUtil::ewarning, "Cauchy type boundary conditions not implemented.");
}
else if (conditionType == "JUNCTION")
{
if (attrData.empty())
{
ASSERTL0(false, "JUNCTION not set up correctly");
}
else
{
// Use the iterator from above, which must point to the variable.
attr = attr->Next();
if (attr)
{
int P = 0;
int D1 = 0;
while(attr) {
attrName = attr->Name();
if (attrName=="P") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
P = atoi(attrData.c_str());
}
else if (attrName=="D1") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
D1 = atoi(attrData.c_str());
}
attr = attr->Next();
}
BoundaryConditionShPtr junctionCondition(MemoryManager<JunctionBoundaryCondition>::AllocateSharedPtr(P, D1));
(*boundaryConditions)[*iter] = junctionCondition;
}
}
}
else if (conditionType == "BIFURCATION")
{
if (attrData.empty())
{
ASSERTL0(false, "BIFURCATION not set up correctly");
}
else
{
// Use the iterator from above, which must point to the variable.
attr = attr->Next();
if (attr)
{
int P = 0;
int D1 = 0;
int D2 = 0;
std::string userDefined;
while(attr) {
attrName = attr->Name();
if (attrName=="P") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
P = atoi(attrData.c_str());
}
else if (attrName=="D1") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
D1 = atoi(attrData.c_str());
}
else if (attrName=="D2") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
D2 = atoi(attrData.c_str());
}
attr = attr->Next();
}
BoundaryConditionShPtr bifurcationCondition(MemoryManager<BifurcationBoundaryCondition>::AllocateSharedPtr(P, D1, D2));
(*boundaryConditions)[*iter] = bifurcationCondition;
}
}
}
else if (conditionType == "MERGING")
{
if (attrData.empty())
{
ASSERTL0(false, "MERGING flow condition not set up correctly");
}
else
{
// Use the iterator from above, which must point to the variable.
attr = attr->Next();
if (attr)
{
int P = 0;
int D1 = 0;
int D2 = 0;
std::string userDefined;
while(attr) {
attrName = attr->Name();
if (attrName=="P") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
P = atoi(attrData.c_str());
}
else if (attrName=="D1") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
D1 = atoi(attrData.c_str());
}
else if (attrName=="D2") {
// Do stuff for the user defined attribute
attrData = attr->Value();
m_session->SubstituteExpressions(attrData);
D2 = atoi(attrData.c_str());
}
attr = attr->Next();
}
BoundaryConditionShPtr mergingCondition(MemoryManager<MergingBoundaryCondition>::AllocateSharedPtr(P, D1, D2));
(*boundaryConditions)[*iter] = mergingCondition;
}
}
}
conditionElement = conditionElement->NextSiblingElement();
}
m_boundaryConditions[boundaryRegionID] = boundaryConditions;
regionElement = regionElement->NextSiblingElement("REGION");
}
}
}
}
|
47096d49bdffc64a52b1adbef9eb72eaaa089916
|
a3d6556180e74af7b555f8d47d3fea55b94bcbda
|
/weblayer/browser/file_select_helper.h
|
37d3fef6fa01d1ef0bc58ad86c2f365704fdf5a7
|
[
"BSD-3-Clause"
] |
permissive
|
chromium/chromium
|
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
|
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
|
refs/heads/main
| 2023-08-24T00:35:12.585945
| 2023-08-23T22:01:11
| 2023-08-23T22:01:11
| 120,360,765
| 17,408
| 7,102
|
BSD-3-Clause
| 2023-09-10T23:44:27
| 2018-02-05T20:55:32
| null |
UTF-8
|
C++
| false
| false
| 3,905
|
h
|
file_select_helper.h
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBLAYER_BROWSER_FILE_SELECT_HELPER_H_
#define WEBLAYER_BROWSER_FILE_SELECT_HELPER_H_
#include <memory>
#include <vector>
#include "base/memory/weak_ptr.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/file_select_listener.h"
#include "ui/shell_dialogs/select_file_dialog.h"
namespace content {
class FileSelectListener;
class RenderFrameHost;
class WebContents;
} // namespace content
namespace ui {
struct SelectedFileInfo;
}
namespace weblayer {
// This class handles file-selection requests coming from renderer processes.
// It implements both the initialisation and listener functions for
// file-selection dialogs.
//
// Since FileSelectHelper listens to observations of a widget, it needs to live
// on and be destroyed on the UI thread. References to FileSelectHelper may be
// passed on to other threads.
class FileSelectHelper : public base::RefCountedThreadSafe<
FileSelectHelper,
content::BrowserThread::DeleteOnUIThread>,
public ui::SelectFileDialog::Listener {
public:
FileSelectHelper(const FileSelectHelper&) = delete;
FileSelectHelper& operator=(const FileSelectHelper&) = delete;
// Show the file chooser dialog.
static void RunFileChooser(
content::RenderFrameHost* render_frame_host,
scoped_refptr<content::FileSelectListener> listener,
const blink::mojom::FileChooserParams& params);
private:
friend class base::RefCountedThreadSafe<FileSelectHelper>;
friend class base::DeleteHelper<FileSelectHelper>;
friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>;
FileSelectHelper();
~FileSelectHelper() override;
void RunFileChooser(content::RenderFrameHost* render_frame_host,
scoped_refptr<content::FileSelectListener> listener,
blink::mojom::FileChooserParamsPtr params);
// Cleans up and releases this instance. This must be called after the last
// callback is received from the file chooser dialog.
void RunFileChooserEnd();
// SelectFileDialog::Listener overrides.
void FileSelected(const base::FilePath& path,
int index,
void* params) override;
void FileSelectedWithExtraInfo(const ui::SelectedFileInfo& file,
int index,
void* params) override;
void MultiFilesSelected(const std::vector<base::FilePath>& files,
void* params) override;
void MultiFilesSelectedWithExtraInfo(
const std::vector<ui::SelectedFileInfo>& files,
void* params) override;
void FileSelectionCanceled(void* params) override;
// This method is called after the user has chosen the file(s) in the UI in
// order to process and filter the list before returning the final result to
// the caller.
void ConvertToFileChooserFileInfoList(
const std::vector<ui::SelectedFileInfo>& files);
// A weak pointer to the WebContents of the RenderFrameHost, for life checks.
base::WeakPtr<content::WebContents> web_contents_;
// |listener_| receives the result of the FileSelectHelper.
scoped_refptr<content::FileSelectListener> listener_;
// Dialog box used for choosing files to upload from file form fields.
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
// The type of file dialog last shown.
ui::SelectFileDialog::Type dialog_type_ =
ui::SelectFileDialog::SELECT_OPEN_FILE;
// The mode of file dialog last shown.
blink::mojom::FileChooserParams::Mode dialog_mode_ =
blink::mojom::FileChooserParams::Mode::kOpen;
};
} // namespace weblayer
#endif // WEBLAYER_BROWSER_FILE_SELECT_HELPER_H_
|
3634600fcb8b55239ba52577ae27fe080170a989
|
f6e28e7a1b2485b18d712fb092fea5fdeaa1d85c
|
/src/pch.h
|
6fb5537d6cff585b46ae4b4b2436f441f2490a75
|
[] |
no_license
|
eypidan/deformation_opengl
|
dba4676c076f83e9b3a7ac14614bebb9d055a6e9
|
043f605a508287f249d235a17ba09cc14870f5f1
|
refs/heads/master
| 2022-11-10T22:49:35.874839
| 2020-06-30T15:05:00
| 2020-06-30T15:05:00
| 262,209,820
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,341
|
h
|
pch.h
|
// settings
#define SCR_WIDTH 1000
#define SCR_HEIGHT 800
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <Eigen/Dense>
#include <Eigen/Geometry>
#include <Eigen/SparseCore>
#include<Eigen/SparseCholesky>
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <string>
#include <chrono>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define STB_IMAGE_IMPLEMENTATION
#define STB_IMAGE_STATIC
#include "stb_image.h"
#include "miscFunction.h"
#include "shaderLoad.h"
#include "camera.h"
#include "readModel.h"
#include "renderFunction.h"
#include "deformation.h"
//model
extern Model *magicCube;
//camera
extern Camera camera;
// timing
extern float deltaTime;
extern float lastFrame;
//model rotate
extern float x_angles;
extern float y_angles;
extern float z_angles;
extern float height;
extern float modelDistance;
//control point move
extern controlMove controlMove_0;
//window
extern GLFWwindow* window;
//mouse
extern double mouseX, mouseY;
//bunny
extern bool bunny;
extern vector<unsigned int> bunnyControlPoints;
extern unsigned int selectedPoint;
//armadillo
extern bool armadillo;
|
6bdfaa5727371813edb054d01f4d52eab90f38bb
|
159b7bd87e07dc2c09827fac804bc30014426511
|
/test/unit/cute/core/inverse_right.cpp
|
4d1501476e83fd1687e5e7bbbc65843140f8fab6
|
[
"BSD-3-Clause"
] |
permissive
|
NVIDIA/cutlass
|
4d161f5ff1a4683baa978abb4e4b99f4b9f68d3b
|
e01b9b5029b7caca5a43c29f7d2714d7cf1dcae8
|
refs/heads/main
| 2023-09-03T00:51:43.978093
| 2023-08-30T20:46:30
| 2023-08-30T20:46:30
| 112,542,515
| 3,368
| 680
|
NOASSERTION
| 2023-09-14T15:04:54
| 2017-11-30T00:11:24
|
C++
|
UTF-8
|
C++
| false
| false
| 6,867
|
cpp
|
inverse_right.cpp
|
/***************************************************************************************************
* Copyright (c) 2017 - 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/
#include "cutlass_unit_test.h"
#include <cutlass/trace.h>
#include <iostream>
#include <cute/tensor.hpp>
using namespace cute;
template <class Layout, class InvLayout>
void
test_postconditions(Layout const& layout, InvLayout const& inv_layout)
{
for (int i = 0; i < size(inv_layout); ++i) {
//printf("%3d: %3d %3d\n", i, int(inv_layout(i)), int(layout(inv_layout(i))));
EXPECT_EQ(layout(inv_layout(i)), i);
}
}
template <class Layout>
void
test_right_inverse(Layout const& layout)
{
auto inv_layout = right_inverse(layout);
CUTLASS_TRACE_HOST(layout << " ^ -1\n" << " => \n" << inv_layout);
CUTLASS_TRACE_HOST("Composition: " << coalesce(composition(layout, inv_layout)) << std::endl);
test_postconditions(layout, inv_layout);
}
TEST(CuTe_core, Inverse_right)
{
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("RIGHT INVERSE" );
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("Simple tests" );
CUTLASS_TRACE_HOST("-------------------------------");
{
auto layout = Layout<_1, _0>{};
test_right_inverse(layout);
}
{
auto layout = Layout<_1, _1>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_4>,
Stride<_0>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <Shape <_1,_1>>,
Stride<Stride<_0,_0>>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <Shape <_3,_7>>,
Stride<Stride<_0,_0>>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_1>,
Stride<_1>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_4>,
Stride<_1>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_4>,
Stride<_2>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_2,_4>,
Stride<_0,_2>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_8, _4>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_8, _4>,
Stride<_4, _1>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape< _2,_4,_6>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_2,_4,_6>,
Stride<_4,_1,_8>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_2,_4,_4,_6>,
Stride<_4,_1,_0,_8>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_4, _2>,
Stride<_1,_16>>{};
test_right_inverse(layout);
}
{
auto layout = Layout<Shape <_4, _2>,
Stride<_1, _5>>{};
test_right_inverse(layout);
}
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("Dynamic shapes/strides" );
CUTLASS_TRACE_HOST("-------------------------------");
{
auto layout = make_layout(Shape<_4, _2>{}, make_stride(Int<1>{}, 4));
test_right_inverse(layout);
}
{
auto layout = make_layout(make_shape(_4{}, 2), make_stride(Int<1>{}, 4));
test_right_inverse(layout);
}
{
auto layout = make_layout(make_shape(4, 2), make_stride(Int<1>{}, 4));
test_right_inverse(layout);
}
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("Swizzle layouts" );
CUTLASS_TRACE_HOST("-------------------------------");
{
auto layout = ComposedLayout<Swizzle<1,0,2>, _0, Layout<Shape <_4, _4>,
Stride<_1, _4>>>{};
test_right_inverse(layout);
}
{
auto layout = ComposedLayout<Swizzle<1,0,2>, _0, Layout<Shape <_4, _4>,
Stride<_4, _1>>>{};
test_right_inverse(layout);
}
{
auto layout = ComposedLayout<Swizzle<1,0,1>, _0, Layout<Shape <_4, _4>,
Stride<_8, _1>>>{};
test_right_inverse(layout);
}
CUTLASS_TRACE_HOST("-------------------------------");
CUTLASS_TRACE_HOST("BETA: Negative strides" );
CUTLASS_TRACE_HOST("-------------------------------");
// Negative strides (beta support)
// Post-conditions/layout indexing aren't generalized enough to support these yet
// However, the composition post-condition is general enough.
{
auto layout = make_layout(Shape<_4>{}, Stride<Int<-1>>{});
test_right_inverse(layout);
}
//{
//auto layout = Layout<Shape < _2,_4>,
// Stride<_m1,_2>>{};
//test_right_inverse(layout);
//}
//{
//auto layout = Layout<Shape < _2, _4>,
// Stride< _4,_m1>>{};
//test_right_inverse(layout);
//}
//{
//auto layout = Layout<Shape < _2, _4, _6>,
// Stride<_m1,_12,_m2>>{};
//test_right_inverse(layout);
//}
}
|
f6f8116f094715992f93237f2498027b54037a33
|
eea1133885ffda42635f8552720b643fb4c8e6c2
|
/src/camera.cpp
|
156500d09ba5f2e669dbd79c6cc141835aa32ac3
|
[] |
no_license
|
gaboche321/engine
|
02f53de7fe6259aa5272522041ccab91bd49c6ea
|
5e9994c23875516caf58ab3ceb79d95cb5228fb1
|
refs/heads/master
| 2020-12-13T16:23:10.006856
| 2020-02-06T01:29:17
| 2020-02-06T01:29:17
| 234,469,623
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 532
|
cpp
|
camera.cpp
|
#include <camera.hpp>
#define ISOMETRIC
camera::
camera()
{
}
camera::
~camera()
{}
glm::mat4
camera::
get_view_matrix()
{
glm::mat4 t = glm::translate(glm::mat4(1.0f), glm::vec3( x() , y() , 0.f ) ) ;
#ifdef ISOMETRIC
float vertical_angle = asin(1) - atan(1/sqrt(2)) ;
float horizontal_angle = -asin(1/sqrt(2)) ;
glm::mat4 r1 = glm::rotate(glm::mat4(1.0f), horizontal_angle, glm::vec3(0,0,1));
glm::mat4 r2 = glm::scale(glm::mat4(1.0f) , glm::vec3( 1.0f, 0.5f, 1.f) ) ;
return t * r2* r1;
#else
return t ;
#endif
}
|
2fc5d062fd2ef93015a4992522995867f60dddbc
|
8d325459fa1cf8e1492c2060d7429e204ef7868a
|
/fofGuitarController_ino/fofGuitarController_CapSense_MenuNavigation/fofGuitarController_CapSense_MenuNavigation.ino
|
35b483b7d5b30c1971c0efb3a1d7b670ffdf0888
|
[] |
no_license
|
drkzrg/guitarController
|
0e03b8f03033e2ee40afce302fefed142cfb198f
|
f13319eb2ef4633a0eec00e3356ebaed3666fae7
|
refs/heads/master
| 2023-03-18T01:10:51.483492
| 2016-04-17T21:22:56
| 2016-04-17T21:22:56
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,880
|
ino
|
fofGuitarController_CapSense_MenuNavigation.ino
|
#include <CapacitiveSensor.h>
int menuInput = 7;
int menuSendPin = 8;
int menuNavState = LOW;
int capSenseSendPin = 9;
CapacitiveSensor pick = CapacitiveSensor(capSenseSendPin,A0);
CapacitiveSensor fret5 = CapacitiveSensor(capSenseSendPin,A1);
CapacitiveSensor fret4 = CapacitiveSensor(capSenseSendPin,A2);
CapacitiveSensor fret3 = CapacitiveSensor(capSenseSendPin,A3);
CapacitiveSensor fret2 = CapacitiveSensor(capSenseSendPin,A4);
CapacitiveSensor fret1 = CapacitiveSensor(capSenseSendPin,A5);
int fret1State, fret2State, fret3State, fret4State, fret5State, pickState = LOW;
int menuNavigationState = LOW;
long threshold = 400;
long valF1 = 0;
long valF2 = 0;
long valF3 = 0;
long valF4 = 0;
long valF5 = 0;
long valPick = 0;
long start = 0;
void setup()
{
pinMode(menuSendPin, OUTPUT);
pinMode(menuInput, INPUT_PULLUP);
digitalWrite(menuSendPin, LOW);
Serial.begin(115200);
if(digitalRead(menuInput) == LOW)
{
menuNavigationHIGH(); //Pullup inverts
}
else
{
menuNavigationLOW();
}
}
void loop()
{
start = millis();
valF1 = fret1.capacitiveSensor(15);
valF2 = fret2.capacitiveSensor(15);
valF3 = fret3.capacitiveSensor(15);
valF4 = fret4.capacitiveSensor(15);
valF5 = fret5.capacitiveSensor(15);
valPick = pick.capacitiveSensor(15);
//debug();
trigger();
triggerMenuSwitch();
}
void trigger()
{
if(valF1 > threshold)
{
if(fret1State == LOW)
{
fret1State = HIGH;
Serial.print("fret1:HIGH;");
}
}
else
{
if(fret1State == HIGH)
{
fret1State = LOW;
Serial.print("fret1:LOW;");
}
}
if(valF2 > threshold)
{
if(fret2State == LOW)
{
fret2State = HIGH;
Serial.print("fret2:HIGH;");
}
}
else
{
if(fret2State == HIGH)
{
fret2State = LOW;
Serial.print("fret2:LOW;");
}
}
if(valF3 > threshold)
{
if(fret3State == LOW)
{
fret3State = HIGH;
Serial.print("fret3:HIGH;");
}
}
else
{
if(fret3State == HIGH)
{
fret3State = LOW;
Serial.print("fret3:LOW;");
}
}
if(valF4 > threshold)
{
if(fret4State == LOW)
{
fret4State = HIGH;
Serial.print("fret4:HIGH;");
}
}
else
{
if(fret4State == HIGH)
{
fret4State = LOW;
Serial.print("fret4:LOW;");
}
}
if(valF5 > threshold)
{
if(fret5State == LOW)
{
fret5State = HIGH;
Serial.print("fret5:HIGH;");
}
}
else
{
if(fret5State == HIGH)
{
fret5State = LOW;
Serial.print("fret5:LOW;");
}
}
if(valPick > threshold)
{
if(pickState == LOW)
{
pickState = HIGH;
Serial.print("pick:HIGH;");
}
}
else
{
if(pickState == HIGH)
{
pickState = LOW;
Serial.print("pick:LOW;");
}
}
}
void triggerMenuSwitch()
{
if(digitalRead(menuInput) == LOW)
{
if(menuNavState == LOW)
{
menuNavigationHIGH(); //Pullup inverts
}
}
else
{
if(menuNavState == HIGH)
{
menuNavigationLOW();
}
}
}
void menuNavigationHIGH()
{
menuNavState = HIGH;
Serial.print("menuNav:HIGH;");
}
void menuNavigationLOW()
{
menuNavState = LOW;
Serial.print("menuNav:LOW;");
}
void debug()
{
Serial.print("Performance Delay: ");
Serial.print(millis() - start);
Serial.print("\r\n");
Serial.print("\tFret1: ");
Serial.print(valF1);
Serial.print("\r\n");
Serial.print("\tFret2: ");
Serial.print(valF2);
Serial.print("\r\n");
Serial.print("\tFret3: ");
Serial.print(valF3);
Serial.print("\r\n");
Serial.print("\tFret4: ");
Serial.print(valF4);
Serial.print("\r\n");
Serial.print("\tFret5: ");
Serial.print(valF5);
Serial.print("\r\n");
Serial.print("\tPick: ");
Serial.print(valPick);
Serial.print("\r\n");
delay(50);
}
|
ce8227491842f64453a9c17c78e525ab6f6ef2ef
|
24f0994a41e60a6c39c12fbc79b949eb026c70c4
|
/Proyecto1/src/Profundidad_Matriz.cpp
|
eb94f4a051d8d21604723f8f9b000ac85c1910b5
|
[] |
no_license
|
Eduardo01004/EDD_2S2019_PY1_201612124
|
a7cf6379d292bdd2089bb728f40b92c3febc4c04
|
bcdf393c1d559cfe0840e0fa55acaf2ce9ce6bac
|
refs/heads/master
| 2020-07-07T19:17:55.281207
| 2019-09-22T04:50:53
| 2019-09-22T04:50:53
| 203,451,733
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,668
|
cpp
|
Profundidad_Matriz.cpp
|
#include "Profundidad_Matriz.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <fstream>
#include <iomanip>
Profundidad_Matriz::Profundidad_Matriz()
{
primero=NULL;
ultimo=NULL;
}
void Profundidad_Matriz::Insertar_eje_Z(int profundidad){
NodoDobleProfundidad *nuevo = new NodoDobleProfundidad();
nuevo->profundidad=profundidad;
nuevo->matriz = new raiz();
if (primero == NULL){
primero=nuevo;
primero->siguiente=NULL;
primero->atras=NULL;
ultimo=primero;
}
else{
ultimo->siguiente=nuevo;
nuevo->siguiente=NULL;
nuevo->atras=ultimo;
ultimo=nuevo;
}
}
void Profundidad_Matriz::Insertarcopiacubo(int profundidad,raiz *cubo){
NodoDobleProfundidad *nuevo = new NodoDobleProfundidad();
nuevo->profundidad=profundidad;
nuevo->matriz = new raiz();
if (primero == NULL){
primero=nuevo;
primero->siguiente=NULL;
primero->atras=NULL;
ultimo=primero;
}
else{
ultimo->siguiente=nuevo;
nuevo->siguiente=NULL;
nuevo->atras=ultimo;
ultimo=nuevo;
}
}
void Profundidad_Matriz::mostrar(){
NodoDobleProfundidad* aux=primero;
if (aux !=NULL){
while(aux != NULL){
cout << aux->profundidad<<endl;
aux=aux->siguiente;
}
}else cout << "vacio"<<endl;
}
NodoDobleProfundidad* Profundidad_Matriz::Buscar(int nivel){
NodoDobleProfundidad *aux=primero;
while(aux != NULL){
if (aux->profundidad == nivel)return aux;
aux=aux->siguiente;
}
return NULL;
}
void Profundidad_Matriz::UnirCapas(raiz *capa, raiz *unido){
cabecera* aux = capa->primerocolumna;
while(aux != NULL){
Nodomatriz *aux2 = aux->primeromatriz;
while(aux2 != NULL){
unido->existeX(aux2->x);
unido->existey(aux2->y);
unido->InsertarMatriz(aux2->x,aux2->y,aux2->color);
aux2 = aux2->siguiente;
}
aux = aux->siguiente;
}
}
int Profundidad_Matriz::cantidadColumnas(raiz *p){
if(p->ultimocolumna != NULL) return p->ultimocolumna->numero;
return -1;
}
void Profundidad_Matriz::EspejoX(raiz*p,raiz *m){
int i=0;
int j=cantidadColumnas(p);
cabecera *aux=p->primerocolumna;
if (j != -1){
while (aux != NULL && i<=j){
Nodomatriz *mat=aux->primeromatriz;
while(mat != NULL){
m->InsertarTodoMatriz(j-(mat->x),mat->y,mat->color);
cout<<j<<endl;
mat=mat->siguiente;
}
aux=aux->siguiente;
i++;
}
}
}
|
7d11f25b2cb9da7b604d873eb0bb054cceac3a64
|
1b17a884a99430295ca11c10130975c9b3670458
|
/DataStructures/old_hws/A13/queueWrapper.cpp
|
c338a2aecdf9ff093468debefa12ebe1a56abbf7
|
[] |
no_license
|
soundestmammal/cpp
|
1eb39aae4ba0761786710cbd8319f44b1b243c34
|
f6455796214b7a2e2d932c9d20ca3c3b69154761
|
refs/heads/master
| 2020-04-14T00:32:27.823771
| 2019-12-08T20:38:57
| 2019-12-08T20:38:57
| 163,535,698
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 709
|
cpp
|
queueWrapper.cpp
|
#include <iostream>
#include "BCS370_queueBase.h"
#include "queueWrapper.h"
farmingdale::statusCode farmingdale::queueWrapper::enqueue(std::string s) {
stlQueue.push(s);
return SUCCESS;
}
farmingdale::statusCode farmingdale::queueWrapper::peek(std::string &s) {
if (isEmpty()) {
return FAILURE;
}
s = stlQueue.front();
return SUCCESS;
}
farmingdale::statusCode farmingdale::queueWrapper::dequeue(std::string &s) {
std::string test;
if(isEmpty()) {
return FAILURE;
}
s = stlQueue.front();
stlQueue.pop();
return SUCCESS;
}
bool farmingdale::queueWrapper::isEmpty() {
if (stlQueue.empty()) {
return true;
}
return false;
}
|
08f5be6244b6e97000a4202d5ca342cd8776a1ca
|
496f5ef04a48107b238af7167c378db38ba42a61
|
/SDHCAL_EventReader/include/DifGeom.h
|
8bb87fedeb028027f79c51c6e3dba06971cfeff7
|
[] |
no_license
|
mirabitl/SDHCAL
|
0784bbd40be94874eaf014a54b38e85f92526677
|
fcd7bee9bea114c531cd1627eebfc7cfd762fef5
|
refs/heads/master
| 2021-01-17T00:53:14.305377
| 2017-09-18T14:46:48
| 2017-09-18T14:46:48
| 10,996,462
| 0
| 2
| null | 2017-09-06T16:31:27
| 2013-06-27T12:38:56
|
C++
|
UTF-8
|
C++
| false
| false
| 7,111
|
h
|
DifGeom.h
|
#ifndef DifGeom_HH
#define DifGeom_HH
/**
\class DifGeom
\author L.Mirabito
\date May 2010
\version 1.0
\brief DIF Geometry: only PAD shift and polarity is stored. It allows to swap from local DIF numbering to local chamber numbering
*/
class DifGeom
{
public:
static const unsigned short Max_Pad_XSize=96;
static const unsigned short Max_Pad_YSize=32;
DifGeom(unsigned int id=0,unsigned int ch=0,float x=0,float y=0,float polx=0, float poly=0) : id_(id),chId_(ch), x_(x),y_(y),polx_(polx),poly_(poly) {;}
inline unsigned int getId(){return id_;}
inline unsigned int getChamberId(){return chId_;}
inline float getX(){return x_;}
inline float getY(){return y_;}
inline float getPolarityX(){return polx_;}
inline float getPolarityY(){return poly_;}
inline float toGlobalX(float x)
{
if (polx_>0)
return x+x_;
else
return Max_Pad_XSize-x+1+x_;
}
inline float toGlobalY(float x)
{
if (poly_>0)
return x+y_;
else
return (Max_Pad_YSize-x+1)+y_;
}
inline double toLocalX(double x)
{
if (polx_>0)
return x-x_;
else
return Max_Pad_XSize-x+1+x_;
}
inline double toLocalY(double x)
{
if (polx_>0)
return x-x_;
else
return Max_Pad_YSize-x+1+x_;
}
static void PadConvert(int asicid,int ipad, int &i, int &j, int asicType)
{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Upper view (ASICs SIDE)
//Asics mapping (channel 0 to 63) on small chambers with HARDROC I
// 0 5 10 15 20 25 30 35 40 45 50 55 60
const unsigned short MapJSmallHR1[64]={2,2,2,7,5,1,3,1,4,1,6,0,3,0,3,0,7,5,4,0,6,7,2,5,3,1,4,4,6,7,5,6,7,5,6,4,3,7,1,0,5,2,6,7,0,5,4,6,0,6,0,4,4,3,3,3,5,7,1,1,2,1,2,2};
const unsigned short MapISmallHR1[64]={7,6,5,7,7,7,7,5,7,6,7,7,5,5,6,6,6,6,6,4,6,5,4,5,4,4,5,4,5,4,4,4,3,3,3,3,3,2,3,3,2,3,2,1,0,1,2,1,2,0,1,1,0,1,2,0,0,0,2,1,2,0,1,0};
//(J Axis)
//
// 7 |11|05|00|06|08|04|10|03|
// 6 |15|09|01|14|18|17|20|16|
// 5 |13|07|02|12|26|23|28|21|
// 4 |19|25|22|24|27|30|31|29|
// 3 |39|38|41|36|35|33|34|32| TOP VIEW (ASICs SIDE)
// 2 |48|58|60|54|46|40|42|37|
// 1 |50|59|62|53|51|45|47|43|
// 0 |44|61|63|55|52|56|49|57|
// 0 1 2 3 4 5 6 7 (I Axis) ----->
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Upper view (ASICs SIDE)
//ASIC 90 deg rotation in the trigonometric way compare to the MapISmallHR1/MapJSmallHR1.
//Asics mapping on large chambers with HARDROC I
// 0 5 10 15 20 25 30 35 40 45 50 55 60
const unsigned short MapJLargeHR1[64]={0,1,2,0,0,0,0,2,0,1,0,0,2,2,1,1,1,1,1,3,1,2,3,2,3,3,2,3,2,3,3,3,4,4,4,4,4,5,4,4,5,4,5,6,7,6,5,6,5,7,6,6,7,6,5,7,7,7,5,6,5,7,6,7};
const unsigned short MapILargeHR1[64]={2,2,2,7,5,1,3,1,4,1,6,0,3,0,3,0,7,5,4,0,6,7,2,5,3,1,4,4,6,7,5,6,7,5,6,4,3,7,1,0,5,2,6,7,0,5,4,6,0,6,0,4,4,3,3,3,5,7,1,1,2,1,2,2};
//(J Axis)
//
// 7 |03|16|21|29|32|37|43|57|
// 6 |10|20|28|31|34|42|47|49|
// 5 |04|17|23|30|33|40|45|56|
// 4 |08|18|26|27|35|46|51|52|
// 3 |06|14|12|24|36|54|53|55| TOP VIEW (ASICs SIDE)
// 2 |00|01|02|22|41|60|62|63|
// 1 |05|09|07|25|38|58|59|61|
// 0 |11|15|13|19|39|48|50|44|
// 0 1 2 3 4 5 6 7 (I Axis) ----->
// | |
// |DIFF|
// |____|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Upper view (ASICs SIDE)
//90 deg rotation in the trigonometric way compare to the MapILargeHR1/MapJLargeHR1.
//180 deg rotation in the trigonometric way compare to the MapISmallHR1/MapJSmallHR1.
//Asics mapping on large chambers with HARDROC II & IIB
// 0 5 10 15 20 25 30 35 40 45 50 55 60
const unsigned short MapJLargeHR2[64]={1,1,2,2,3,3,4,4,5,5,6,6,7,7,4,3,2,0,0,1,0,5,6,7,7,6,5,4,3,2,1,0,0,1,2,3,4,5,6,7,7,6,0,0,1,1,0,2,3,4,5,7,7,6,6,5,5,4,4,3,3,2,2,1};
const unsigned short MapILargeHR2[64]={1,0,1,0,1,0,1,0,0,1,0,1,0,1,2,2,2,0,1,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,6,5,6,7,5,5,5,5,6,7,6,7,6,7,6,7,7,6,7,6,7};
//(J Axis)
//
// 7 |46|63|61|59|58|56|54|52|
// 6 |43|45|62|60|57|55|53|51|
// 5 |42|44|47|48|49|50|41|40|
// 4 |32|33|34|35|36|37|38|39|
// 3 |31|30|29|28|27|26|25|24| TOP VIEW (ASICs SIDE)
// 2 |20|19|16|15|14|21|22|23|
// 1 |18|00|02|04|06|09|11|13|
// 0 |17|01|03|05|07|08|10|12|
// 0 1 2 3 4 5 6 7 (I Axis) ----->
// | |
// |DIFF|
// |____|
unsigned short AsicShiftI[49]={ 0,
0, 0, 0, 0,
8, 8, 8, 8,
16, 16, 16, 16,
24, 24, 24, 24,
32, 32, 32, 32,
40, 40, 40, 40,
48, 48, 48, 48,
56, 56, 56, 56,
64, 64, 64, 64,
72, 72, 72, 72,
80, 80, 80, 80,
88, 88, 88, 88};
unsigned short AsicShiftJ[49]={ 0,
0, 8, 16, 24,
24, 16, 8, 0,
0, 8, 16, 24,
24, 16, 8, 0,
0, 8, 16, 24,
24, 16, 8, 0,
0, 8, 16, 24,
24, 16, 8, 0,
0, 8, 16, 24,
24, 16, 8, 0,
0, 8, 16, 24,
24, 16, 8, 0
};
//Small chambers HR
if(asicType==0){
i = MapISmallHR1[ipad]+AsicShiftI[asicid]+1;
j = MapJSmallHR1[ipad]+AsicShiftJ[asicid]+1;
}
//First square meter HR1
if(asicType==1){
i = MapILargeHR1[ipad]+AsicShiftI[asicid]+1;
j = MapJLargeHR1[ipad]+AsicShiftJ[asicid]+1;
}
//Second Square meter HR2
if(asicType==2){
i = MapILargeHR2[ipad]+AsicShiftI[asicid]+1;
j = MapJLargeHR2[ipad]+AsicShiftJ[asicid]+1;
j=33-j;
}
if(asicType==11){
int jligne = 3-(asicid-1)/12;
int icol = (asicid-1)%12;
int ispad= ((ipad-1)/8)+1;
int jspad=(ipad-1)%8+1;
i = icol*8+ispad;
j = jligne*8+jspad;
//j = (jligne+1)*8-jspad;
}
}
private:
unsigned int id_;
unsigned int chId_;
double x_,y_,polx_,poly_;
};
#endif
|
db53d3b254e25d739593e6fc3462b71aaf957455
|
4065c8f9ea9b8dfa52cc029a7d3f3402c40638c6
|
/Include/Panaskin/PanaseeDialog.h
|
2e91055da7aa3779dbf104961dd13f86ee646b17
|
[] |
no_license
|
yongdono/Panasee
|
4fd5ffa048aa4d12e745464736b8811a08fb17d1
|
cade89049e22c8866aa9f04dabbbb9388f3e99cd
|
refs/heads/master
| 2021-08-31T11:22:04.899654
| 2017-12-21T03:51:56
| 2017-12-21T03:51:56
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 2,494
|
h
|
PanaseeDialog.h
|
#if !defined(AFX_PANASEEDIALOG_H__802C80CF_7A47_4DF8_B1B1_FA76A97D4A5C__INCLUDED_)
#define AFX_PANASEEDIALOG_H__802C80CF_7A47_4DF8_B1B1_FA76A97D4A5C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PanaseeDialog.h : header file
//
#include "panaskin.h"
#include "MemDC.h"
#include <afxtempl.h>
/*********** ningsj *********************
说明:生成panasee风格的窗口
RGB(255,0,0)为默认透明色
*****************************************/
/////////////////////////////////////////////////////////////////////////////
// CPanaseeDialog dialog
class PANASKIN_API CPanaseeDialog : public CDialog
{
// Construction
public:
void EnableSeprateLine(BOOL bEnable);
/*********** ningsj *********************
说明:表示窗口是否包含标题栏以及文字
*****************************************/
void SetTitleBarVisable(BOOL bVisable);
void SetBottomBtnList(CList<CButton *,CButton *> *btnList,BOOL bCenter=FALSE);
CPanaseeDialog(UINT IDD,CWnd* pParent = NULL); // standard constructor
virtual ~CPanaseeDialog();
// Dialog Data
//{{AFX_DATA(CPanaseeDialog)
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPanaseeDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CPanaseeDialog)
virtual BOOL OnInitDialog();
afx_msg void OnNcPaint();
afx_msg BOOL OnEraseBkgnd( CDC* pDC );
afx_msg void OnSize( UINT nType, int cx, int cy );
afx_msg BOOL OnNcActivate( BOOL bActive );
afx_msg void OnNcCalcSize( BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp );
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void Layout();
void CalcFrameRegion();
HBRUSH m_hbrCtrlColor;
CRect m_marginLeftTop,m_marginRightTop,m_marginLeftBottom,m_marginRightBottom,
m_marginCenterTop;
/*********** ningsj *********************
说明:表示窗口是否包含标题栏以及文字
*****************************************/
BOOL m_bTitleBarVisable;
CList<CButton *,CButton *> m_btnList;
BOOL m_bSeprateLine;
BOOL m_bCenterBtn;
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PANASEEDIALOG_H__802C80CF_7A47_4DF8_B1B1_FA76A97D4A5C__INCLUDED_)
|
ccd087f25acb4c03bd27ff37642c4f4783d4b058
|
6de72c400420ab232edcecd3232a7f1e80a8d5f8
|
/src/aris_control/aris_control_motion.cpp
|
14b7d7d6e67bb147cb5bc34a6ee83de82db7bfd1
|
[] |
no_license
|
mexyl/aris_ruicong
|
82b627267374048afb572ca394b73f28bfabd41d
|
50996340988ce2ba4d8bffd86a7cfdf5d3f729a2
|
refs/heads/master
| 2021-01-23T01:40:52.743185
| 2017-06-29T05:05:07
| 2017-06-29T05:05:07
| 85,925,431
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 23,769
|
cpp
|
aris_control_motion.cpp
|
#ifdef UNIX
#include <ecrt.h>
#include <native/task.h>
#include <native/timer.h>
#include <rtdk.h>
#include <sys/mman.h>
#endif
#ifdef WIN32
#define rt_printf printf
#endif
#include <string>
#include <iostream>
#include <map>
#include <fstream>
#include <algorithm>
#include "aris_control_motion.h"
namespace aris
{
namespace control
{
class EthercatMotion::Imp
{
public:
Imp(EthercatMotion *mot) :pFather(mot) {};
~Imp() = default;
std::int16_t enable(const std::uint8_t mode)
{
is_fake = false;
std::uint16_t statusWord;
pFather->readPdo(1, 3, statusWord);
std::uint8_t modeRead;
pFather->readPdo(4, 0, modeRead);
int motorState = (statusWord & 0x000F);
if (motorState == 0x0000)
{
/*state is POWERED_OFF, now set it to STOPPED*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x06));
return 1;
}
else if (motorState == 0x0001)
{
/*state is STOPPED, now set it to ENABLED*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x07));
return 1;
}
else if (motorState == 0x0003)
{
/*state is ENABLED, now set it to RUNNING*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x0F));
return 1;
}
else if ((mode == POSITION) && (modeRead != VELOCITY))
{
/*state is RUNNING, now to set desired mode*/
/*desired mode is POSITION, but we need to use our own velocity loop*/
pFather->writePdo(0, 5, static_cast<std::uint8_t>(VELOCITY));
return 1;
}
else if ((mode != POSITION) && (modeRead != mode))
{
/*state is RUNNING, now change it to desired mode*/
pFather->writePdo(0, 5, static_cast<std::uint8_t>(mode));
return 1;
}
else if (motorState == 0x0007)
{
/*successfull, but still need to wait for 10 more cycles to make it stable*/
switch (mode)
{
case POSITION:
case VELOCITY:
/*velocity loop to set velocity of 0*/
pFather->writePdo(0, 1, static_cast<std::int32_t>(0));
break;
case CURRENT:
pFather->writePdo(0, 2, static_cast<std::int16_t>(0));
pFather->writePdo(0, 3, static_cast<std::int16_t>(1500));
break;
}
if (++enable_period >= 10)
{
running_mode = mode;
enable_period = 0;
return 0;
}
else
{
return 1;
}
}
else
{
/*the motor is in fault*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x80));
return 1;
}
}
std::int16_t disable()
{
is_fake = false;
std::uint16_t statusWord;
pFather->readPdo(1, 3, statusWord);
int motorState = (statusWord & 0x000F);
if (motorState == 0x0001)
{
/*alReady disabled*/
return 0;
}
else if (motorState == 0x0003 || motorState == 0x0007 || motorState == 0x0000)
{
/*try to disable*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x06));
return 1;
}
else
{
/*the motor is in fault*/
pFather->writePdo(0, 4, static_cast<std::uint16_t>(0x80));
return 1;
}
}
std::int16_t home()
{
is_fake = false;
if(is_waiting_mode)
{
auto ret = this->enable(running_mode);
is_waiting_mode = (ret == 0 ? false : true);
return ret;
}
std::uint16_t statusWord;
pFather->readPdo(1, 3, statusWord);
int motorState = (statusWord & 0x000F);
if (motorState != 0x0007)
{
return -1;
}
else
{
/*motor is in running state*/
std::uint8_t mode_Read;
pFather->readPdo(4, 0, mode_Read);
if (mode_Read != 0x0006)
{
/*set motor to mode 0x006, which is homing mode*/
pFather->writePdo(0, 5, static_cast<std::uint8_t>(0x006));
return 1;
}
else
{
if (statusWord & 0x1000)
{
/*home finished, set mode to running mode, whose value is decided by
enable function, also write velocity to 0*/
pFather->writePdo(0, 5, static_cast<uint8_t>(running_mode));
is_waiting_mode = true;
return 1;
}
else
{
/*still homing*/
pFather->writePdo(0, 4, static_cast<uint16_t>(0x1F));
return 1;
}
}
}
}
std::int16_t runPos(const std::int32_t pos)
{
if (is_fake)return 0;
std::uint16_t statusword;
pFather->readPdo(1, 3, statusword);
int motorState = (statusword & 0x000F);
std::uint8_t mode_Read;
pFather->readPdo(4, 0, mode_Read);
if (motorState != 0x0007 || mode_Read != VELOCITY)
{
return -1;
}
else
{
std::int32_t current_pos = this->pos();
double Kp = 200;
std::int32_t desired_vel = static_cast<std::int32_t>(Kp*(pos - current_pos));
/*保护上下限*/
desired_vel = std::max(desired_vel, -max_vel_count_);
desired_vel = std::min(desired_vel, max_vel_count_);
pFather->writePdo(0, 1, desired_vel);
return 0;
}
}
std::int16_t runVel(const std::int32_t vel)
{
if (is_fake)return 0;
std::uint16_t statusword;
pFather->readPdo(1, 3, statusword);
int motorState = (statusword & 0x000F);
std::uint8_t mode_Read;
pFather->readPdo(4, 0, mode_Read);
if (motorState != 0x0007 || mode_Read != VELOCITY)
{
return -1;
}
else
{
pFather->writePdo(0, 1, vel);
return 0;
}
}
std::int16_t runCur(const std::int16_t cur)
{
if (is_fake)return 0;
std::uint16_t statusword;
pFather->readPdo(1, 3, statusword);
int motorState = (statusword & 0x000F);
std::uint8_t mode_Read;
pFather->readPdo(4, 0, mode_Read);
if (motorState != 0x0007 || mode_Read != CURRENT) //need running and cur mode
{
return -1;
}
else
{
pFather->writePdo(0, 2, cur);
return 0;
}
}
std::int32_t pos() { std::int32_t pos; pFather->readPdo(1, 0, pos); return pos + pos_offset_; };
std::int32_t vel() { std::int32_t vel; pFather->readPdo(1, 2, vel); return vel; };
std::int32_t cur() { std::int16_t cur; pFather->readPdo(2, 0, cur); return cur; };
std::int32_t input2count_;
std::int32_t home_count_;
std::int32_t max_pos_count_;
std::int32_t min_pos_count_;
std::int32_t max_vel_count_;
std::int32_t abs_id_;
std::int32_t phy_id_;
EthercatMotion *pFather;
std::int32_t pos_offset_{0};
bool is_fake{ true };
bool is_waiting_mode{ false };
int enable_period{ 0 };
std::uint8_t running_mode{ 9 };
};
EthercatMotion::~EthercatMotion() {}
EthercatMotion::EthercatMotion(const aris::core::XmlElement &xml_ele, const aris::core::XmlElement &type_xml_ele)
:EthercatSlave(type_xml_ele), imp_(new EthercatMotion::Imp(this))
{
if (xml_ele.QueryIntAttribute("input2count", &imp_->input2count_) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"input2count\"");
}
double value;
if (xml_ele.QueryDoubleAttribute("max_pos", &value) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"max_pos\"");
}
imp_->max_pos_count_ = static_cast<std::int32_t>(value * imp_->input2count_);
if (xml_ele.QueryDoubleAttribute("min_pos", &value) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"min_pos\"");
}
imp_->min_pos_count_ = static_cast<std::int32_t>(value * imp_->input2count_);
if (xml_ele.QueryDoubleAttribute("max_vel", &value) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"max_vel\"");
}
imp_->max_vel_count_ = static_cast<std::int32_t>(value * imp_->input2count_);
if (xml_ele.QueryDoubleAttribute("home_pos", &value) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"home_pos\"");
}
imp_->home_count_ = static_cast<std::int32_t>(value * imp_->input2count_);
if (xml_ele.QueryIntAttribute("abs_id", &imp_->abs_id_) != tinyxml2::XML_NO_ERROR)
{
throw std::runtime_error("failed to find motion attribute \"abs_id\"");
}
configSdo(9, static_cast<std::int32_t>(-imp_->home_count_));
};
auto EthercatMotion::writeCommand(const RawData &data)->void
{
switch (data.cmd)
{
case IDLE:
data.ret = 0;
return;
case ENABLE:
data.ret = imp_->enable(data.mode);
return;
case DISABLE:
data.ret = imp_->disable();
return;
case HOME:
data.ret = imp_->home();
return;
case RUN:
switch (data.mode)
{
case POSITION:
data.ret = imp_->runPos(data.target_pos);
return;
case VELOCITY:
data.ret = imp_->runVel(data.target_vel);
return;
case CURRENT:
data.ret = imp_->runCur(data.target_cur);
return;
default:
data.ret = -1;
return;
}
default:
data.ret = -1;
return;
}
}
auto EthercatMotion::readFeedback(RawData &data)->void
{
data.feedback_cur = imp_->cur();
data.feedback_pos = imp_->pos();
data.feedback_vel = imp_->vel();
}
auto EthercatMotion::hasFault()->bool
{
std::uint16_t statusword;
this->readPdo(1, 3, statusword);
int motorState = (statusword & 0x000F);
return (motorState != 0x0003 && motorState != 0x0007 && motorState != 0x0001 && motorState != 0x0000) ? true : false;
}
auto EthercatMotion::absID()->std::int32_t { return imp_->abs_id_; };
auto EthercatMotion::phyID()->std::int32_t { return imp_->phy_id_; };
auto EthercatMotion::maxPosCount()->std::int32_t { return imp_->max_pos_count_; };
auto EthercatMotion::minPosCount()->std::int32_t { return imp_->min_pos_count_; };
auto EthercatMotion::maxVelCount()->std::int32_t { return imp_->max_vel_count_; };
auto EthercatMotion::pos2countRatio()->std::int32_t { return imp_->input2count_; };
auto EthercatMotion::setPosOffset(std::int32_t offset)->void
{
imp_->pos_offset_ = offset;
};
auto EthercatMotion::posOffset()const->std::int32_t
{
return imp_->pos_offset_;
}
auto EthercatForceSensor::readData(Data &data)->void
{
std::int32_t value;
this->readPdo(0, 0, value);
data.Fx = static_cast<double>(value) * force_ratio_;
this->readPdo(0, 1, value);
data.Fy = static_cast<double>(value) * force_ratio_;
this->readPdo(0, 2, value);
data.Fz = static_cast<double>(value) * force_ratio_;
this->readPdo(0, 3, value);
data.Mx = static_cast<double>(value) * torque_ratio_;
this->readPdo(0, 4, value);
data.My = static_cast<double>(value) * torque_ratio_;
this->readPdo(0, 5, value);
data.Mz = static_cast<double>(value) * torque_ratio_;
}
auto EthercatForceSensorRuiCongCombo::readData(RuiCongComboData &data)->void
{
int32_t value=0;
float* pdo_result=NULL;
for(std::size_t i=0;i<data.force.size();i++)
{
// read 6 element in one loop
this->readPdo(i, 0, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).Fx = *pdo_result*force_ratio_;
this->readPdo(i, 1, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).Fy = *pdo_result*force_ratio_;
this->readPdo(i, 2, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).Fz = *pdo_result*force_ratio_;
this->readPdo(i, 3, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).Mx = *pdo_result*torque_ratio_;
this->readPdo(i, 4, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).My = *pdo_result*torque_ratio_;
this->readPdo(i, 5, value);
pdo_result = (float*)&value;
raw_data_.force.at(i).Mz = *pdo_result*torque_ratio_;
std::uint8_t zero_pdo_value;
if (this->zeroing_count_left.at(i) == 1)
{
zero_pdo_value = 1;
this->writePdo(7, i, zero_pdo_value);
this->zeroing_count_left.at(i)--;
}
else if (this->zeroing_count_left.at(i) == 0)
{
zero_pdo_value = 0;
this->writePdo(7, i, zero_pdo_value);
this->zeroing_count_left.at(i)--;
rt_printf("zeroing sensor %d\n",i);
}
else
{
zero_pdo_value = 0;
this->writePdo(7, i, zero_pdo_value);
}
data.force.at(i).Fx = raw_data_.force.at(i).Fx;
data.force.at(i).Fy = raw_data_.force.at(i).Fy;
data.force.at(i).Fz = raw_data_.force.at(i).Fz;
data.force.at(i).Mx = raw_data_.force.at(i).Mx;
data.force.at(i).My = raw_data_.force.at(i).My;
data.force.at(i).Mz = raw_data_.force.at(i).Mz;
//if (this->zeroing_count_left.at(i)>0)
//{
// // set the pdo to zero
// // TBD
// // this->writePdo();
// this->sum_data_.force.at(i).Fx += raw_data_.force.at(i).Fx;
// this->sum_data_.force.at(i).Fy += raw_data_.force.at(i).Fy;
// this->sum_data_.force.at(i).Fz += raw_data_.force.at(i).Fz;
// this->sum_data_.force.at(i).Mx += raw_data_.force.at(i).Mx;
// this->sum_data_.force.at(i).My += raw_data_.force.at(i).My;
// this->sum_data_.force.at(i).Mz += raw_data_.force.at(i).Mz;
// this->zeroing_count_left.at(i)--;
// //this->isZeroing.at(i) = false;
//}
//else if (this->zeroing_count_left.at(i) == 0)
//{
// this->base_data_.force.at(i).Fx = sum_data_.force.at(i).Fx / this->ZEROING_COUNT;
// this->base_data_.force.at(i).Fy = sum_data_.force.at(i).Fy / this->ZEROING_COUNT;
// this->base_data_.force.at(i).Fz = sum_data_.force.at(i).Fz / this->ZEROING_COUNT;
// this->base_data_.force.at(i).Mx = sum_data_.force.at(i).Mx / this->ZEROING_COUNT;
// this->base_data_.force.at(i).My = sum_data_.force.at(i).My / this->ZEROING_COUNT;
// this->base_data_.force.at(i).Mz = sum_data_.force.at(i).Mz / this->ZEROING_COUNT;
// rt_printf("RuiCongCombo index %d zeroing completed.\n",i);
// this->zeroing_count_left.at(i)--;// after completed, the value will be minus one.
//}
//set offset
//data.force.at(i).Fx = raw_data_.force.at(i).Fx - base_data_.force.at(i).Fx;
//data.force.at(i).Fy = raw_data_.force.at(i).Fy - base_data_.force.at(i).Fy;
//data.force.at(i).Fz = raw_data_.force.at(i).Fz - base_data_.force.at(i).Fz;
//data.force.at(i).Mx = raw_data_.force.at(i).Mx - base_data_.force.at(i).Mx;
//data.force.at(i).My = raw_data_.force.at(i).My - base_data_.force.at(i).My;
//data.force.at(i).Mz = raw_data_.force.at(i).Mz - base_data_.force.at(i).Mz;
}
}
auto EthercatForceSensorRuiCongCombo::setRatio(double f_ratio, double t_ratio)->void
{
this->force_ratio_ = f_ratio;
this->torque_ratio_ = t_ratio;
}
auto EthercatForceSensorRuiCongCombo::requireZeroing(int sensor_id)->void
{
if (this->zeroing_count_left.at(sensor_id) < 0)//this means it is not in a zeroing process
{
this->zeroing_count_left.at(sensor_id) = this->ZEROING_COUNT;
for (int i = 0; i < 6; i++)
{
this->sum_data_.force.at(i).Fx = 0.0;
this->sum_data_.force.at(i).Fy = 0.0;
this->sum_data_.force.at(i).Fz = 0.0;
this->sum_data_.force.at(i).Mx = 0.0;
this->sum_data_.force.at(i).My = 0.0;
this->sum_data_.force.at(i).Mz = 0.0;
}
}
return ;
//TBD
// write 1 than write 0 to the zeroing pdo
//this->writePdo();
}
struct EthercatController::Imp
{
std::vector<int> map_phy2abs_, map_abs2phy_;
std::function<int(Data&)> strategy_;
Pipe<aris::core::Msg> msg_pipe_;
std::atomic_bool is_stopping_;
std::vector<EthercatMotion *> motion_vec_;
std::vector<EthercatMotion::RawData> motion_rawdata_, last_motion_rawdata_;
std::vector<EthercatForceSensor *> force_sensor_vec_;
std::vector<EthercatForceSensor::Data> force_sensor_data_;
std::vector<EthercatForceSensorRuiCongCombo *> force_sensor_rcc_vec_;
std::vector<EthercatForceSensorRuiCongCombo::RuiCongComboData> force_sensor_rcc_data_;
std::unique_ptr<Pipe<std::vector<EthercatMotion::RawData> > > record_pipe_;
std::thread record_thread_;
};
EthercatController::~EthercatController() {};
EthercatController::EthercatController() :EthercatMaster(),imp_(new Imp) {};
auto EthercatController::loadXml(const aris::core::XmlElement &xml_ele)->void
{
/*Load EtherCat slave types*/
std::map<std::string, const aris::core::XmlElement *> slaveTypeMap;
auto pSlaveTypes = xml_ele.FirstChildElement("SlaveType");
for (auto type_xml_ele = pSlaveTypes->FirstChildElement(); type_xml_ele; type_xml_ele = type_xml_ele->NextSiblingElement())
{
slaveTypeMap.insert(std::make_pair(std::string(type_xml_ele->name()), type_xml_ele));
}
/*Load all slaves*/
imp_->motion_vec_.clear();
imp_->force_sensor_vec_.clear();
imp_->force_sensor_rcc_vec_.clear();
auto slave_xml = xml_ele.FirstChildElement("Slave");
for (auto sla = slave_xml->FirstChildElement(); sla; sla = sla->NextSiblingElement())
{
std::string type{ sla->Attribute("type") };
if (type == "ElmoSoloWhistle")
{
imp_->motion_vec_.push_back(addSlave<EthercatMotion>(std::ref(*sla), std::ref(*slaveTypeMap.at(type))));
}
else if (type == "AtiForceSensor")
{
imp_->force_sensor_vec_.push_back(addSlave<EthercatForceSensor>(std::ref(*slaveTypeMap.at(type))));
}
else if (type == "RuiCongCombo")
{
imp_->force_sensor_rcc_vec_.push_back(addSlave<EthercatForceSensorRuiCongCombo>(std::ref(*slaveTypeMap.at(type))));
std::cout << "RuiCongCombo added." << std::endl;
}
else
{
throw std::runtime_error(std::string("unknown slave type of \"") + type + "\"");
}
}
/*update map*/
imp_->map_phy2abs_.resize(imp_->motion_vec_.size());
imp_->map_abs2phy_.resize(imp_->motion_vec_.size());
for (std::size_t i = 0; i < imp_->motion_vec_.size(); ++i)
{
imp_->map_phy2abs_[i] = imp_->motion_vec_[i]->absID();
motionAtPhy(i).imp_->phy_id_ = i;
}
for (std::size_t i = 0; i < imp_->motion_vec_.size(); ++i)
{
imp_->map_abs2phy_[i] = std::find(imp_->map_phy2abs_.begin(), imp_->map_phy2abs_.end(), i) - imp_->map_phy2abs_.begin();
}
/*resize other var*/
imp_->motion_rawdata_.resize(imp_->motion_vec_.size());
imp_->last_motion_rawdata_.resize(imp_->motion_vec_.size());
imp_->force_sensor_data_.resize(imp_->force_sensor_vec_.size());
imp_->force_sensor_rcc_data_.resize(imp_->force_sensor_rcc_vec_.size());
imp_->record_pipe_.reset(new Pipe<std::vector<EthercatMotion::RawData> >(true, imp_->motion_vec_.size()));
}
auto EthercatController::setControlStrategy(std::function<int(Data&)> strategy)->void
{
if (imp_->strategy_)
{
throw std::runtime_error("failed to set control strategy, because it alReady has one");
}
imp_->strategy_ = strategy;
}
auto EthercatController::start()->void
{
imp_->is_stopping_ = false;
/*begin thread which will save data*/
if(!imp_->record_thread_.joinable())
imp_->record_thread_ = std::thread([this]()
{
static std::fstream file;
std::string name = aris::core::logFileName();
name.replace(name.rfind("log.txt"), std::strlen("data.txt"), "data.txt");
file.open(name.c_str(), std::ios::out | std::ios::trunc);
std::vector<EthercatMotion::RawData> data;
data.resize(imp_->motion_vec_.size());
long long count = -1;
while (!imp_->is_stopping_)
{
imp_->record_pipe_->recvInNrt(data);
file << ++count << " ";
for (auto &d : data)
{
file << d.feedback_pos << " ";
file << d.target_pos << " ";
file << d.feedback_cur << " ";
}
file << std::endl;
}
file.close();
});
this->EthercatMaster::start();
}
auto EthercatController::stop()->void
{
this->EthercatMaster::stop();
}
auto EthercatController::motionNum()->std::size_t { return imp_->motion_vec_.size(); };
auto EthercatController::motionAtAbs(int i)->EthercatMotion & { return *imp_->motion_vec_.at(imp_->map_abs2phy_[i]); };
auto EthercatController::motionAtPhy(int i)->EthercatMotion & { return *imp_->motion_vec_.at(i); };
auto EthercatController::forceSensorNum()->std::size_t { return imp_->force_sensor_vec_.size(); };
auto EthercatController::forceSensorAt(int i)->EthercatForceSensor & { return *imp_->force_sensor_vec_.at(i); };
auto EthercatController::ruicongComboNum()->std::size_t { return imp_->force_sensor_rcc_vec_.size(); };
auto EthercatController::ruicongComboAt(int i)->EthercatForceSensorRuiCongCombo & { return *imp_->force_sensor_rcc_vec_.at(i); };
auto EthercatController::msgPipe()->Pipe<aris::core::Msg>& { return imp_->msg_pipe_; };
auto EthercatController::controlStrategy()->void
{
/*构造传入strategy的参数*/
Data data{ &imp_->last_motion_rawdata_, &imp_->motion_rawdata_, &imp_->force_sensor_data_, &imp_->force_sensor_rcc_data_, nullptr, nullptr };
/*收取消息*/
if (this->msgPipe().recvInRT(aris::core::MsgRT::instance[0]) > 0)
{
data.msg_recv = &aris::core::MsgRT::instance[0];
};
/*读取反馈*/
if (imp_->motion_vec_.size() > 0)
{
for (std::size_t i = 0; i < imp_->motion_vec_.size(); ++i)
{
motionAtAbs(i).readFeedback(imp_->motion_rawdata_[i]);
}
}
if (imp_->force_sensor_vec_.size() > 0)
{
for (std::size_t i = 0; i < imp_->force_sensor_vec_.size(); ++i)
{
imp_->force_sensor_vec_.at(i)->readData(imp_->force_sensor_data_[i]);
}
}
if (imp_->force_sensor_rcc_vec_.size() > 0)
{
for (std::size_t i = 0; i < imp_->force_sensor_rcc_vec_.size(); ++i)
{
imp_->force_sensor_rcc_vec_.at(i)->readData(imp_->force_sensor_rcc_data_[i]);
}
}
static int test_count = 0;
static int test_counts = 0;
if (test_count == 0)
{
rt_printf("%5d %12.2f %12.2f %12.2f %12.2f %12.2f %12.2f\n",test_counts++
, imp_->force_sensor_rcc_data_[0].force[0].Fz
, imp_->force_sensor_rcc_data_[0].force[1].Fz
, imp_->force_sensor_rcc_data_[0].force[2].Fz
, imp_->force_sensor_rcc_data_[0].force[3].Fz
, imp_->force_sensor_rcc_data_[0].force[4].Fz
, imp_->force_sensor_rcc_data_[0].force[5].Fz);
}
test_count++;
test_count = test_count % 1000;
/*执行自定义的控制策略*/
if (imp_->strategy_)
{
imp_->strategy_(data);
}
/*重新读取反馈信息,因为strategy可能修改已做好的反馈信息,之后写入PDO,之后放进lastMotionData中*/
for (std::size_t i = 0; i < imp_->motion_rawdata_.size(); ++i)
{
motionAtAbs(i).readFeedback(imp_->motion_rawdata_[i]);
motionAtAbs(i).writeCommand(imp_->motion_rawdata_[i]);
imp_->last_motion_rawdata_[i] = imp_->motion_rawdata_[i];
}
for (std::size_t i = 0; i < imp_->force_sensor_rcc_data_.at(0).force.size(); i++)
{
if (imp_->force_sensor_rcc_data_.at(0).isZeroingRequested.at(i))
{
imp_->force_sensor_rcc_vec_.at(0)->requireZeroing(i);
imp_->force_sensor_rcc_data_.at(0).isZeroingRequested.at(i) = false;
}
}
/*发送数据到记录的线程*/
imp_->record_pipe_->sendToNrt(imp_->motion_rawdata_);
/*向外发送消息*/
if (data.msg_send)
{
this->msgPipe().sendToNrt(*data.msg_send);
}
}
}
}
|
9c9456556cead3ecec9c5bf11bf294fc6d8388cf
|
d9b10bf7693472209725f9859bb787a446480181
|
/test/segment_map.test.cpp
|
cd5885b2bc8aafcbde0abc9eb42d8966cca58f57
|
[
"Unlicense"
] |
permissive
|
habara-k/ac-library
|
5ea854772e6fe3396c40b28d6fe95b119c120553
|
c48e576430c335d7037fa88e9fa5f6a61858e68a
|
refs/heads/master
| 2023-09-04T01:07:55.730506
| 2021-10-30T19:32:46
| 2021-10-30T19:32:46
| 385,960,386
| 0
| 0
|
Unlicense
| 2021-10-30T19:29:40
| 2021-07-14T14:00:42
|
C++
|
UTF-8
|
C++
| false
| false
| 1,153
|
cpp
|
segment_map.test.cpp
|
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2880"
#include <atcoder/segment_map>
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
using namespace atcoder;
using namespace std;
int main() {
int n, m, q; cin >> n >> m >> q;
vector<int> d(m), a(m), b(m);
for (int i = 0; i < m; i++) cin >> d[i] >> a[i] >> b[i], --a[i], --b[i];
vector<int> e(q), s(q), t(q);
for (int i = 0; i < q; i++) cin >> e[i] >> s[i] >> t[i], --s[i], --t[i];
using T = tuple<int,int,int>; // time, type, idx
vector<T> events;
for (int i = 0; i < m; i++) events.emplace_back(d[i], 1, i);
for (int i = 0; i < q; i++) events.emplace_back(e[i], 0, i);
sort(events.begin(), events.end());
SegmentMap mp(false);
vector<int> ans(q);
for (auto [time, type, idx] : events) {
if (type == 0) {
// query
ans[idx] = s[idx] > t[idx] or mp.same(s[idx], t[idx]);
}
if (type == 1) {
// insert
mp.insert(a[idx], b[idx]);
}
}
for (int i = 0; i < q; i++) cout << (ans[i] ? "Yes" : "No") << '\n';
}
|
b16009eec00b98efb9d3eeed3835ea7dbe6d64f5
|
cd9b125ccfc18b1beae2bf0eb4a5825087122040
|
/shua_ti_刷题/51/test.cpp
|
edab6a3f535d930bae439eec9a2a99aff73db67f
|
[] |
no_license
|
Tianxintong/git
|
06538c66916c4bd55d2dd0d240f0a182f18cbfd5
|
b943e9338f70e84922dd6784da52dd97455c323a
|
refs/heads/master
| 2021-01-20T01:59:05.496269
| 2017-09-13T13:18:21
| 2017-09-13T13:18:21
| 89,354,253
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,338
|
cpp
|
test.cpp
|
#include<vector>
#include<iostream>
#include<stack>
using namespace std;
struct ListNode
{
int val;
struct ListNode* next;
ListNode(int x) :val(x), next(NULL)
{
}
};
vector<int> printListFromTailToHead(ListNode* head)
{
stack<ListNode*> nodes;
ListNode* tmp = head;
while(tmp)
{
nodes.push(tmp);
tmp = tmp->next;
}
while(!nodes.empty())
{
cout<<nodes.top()->val<<" ";
nodes.pop();
}
vector<int> t;
return t;
}
int main()
{
ListNode node1(1);
ListNode node2(2);
ListNode node3(3);
ListNode node4(4);
node1.next = &node2;
node2.next = &node3;
node3.next = &node4;
printListFromTailToHead(&node1);
return 0;
}
/*
struct ListNode
{
int m_nKey;
ListNode* m_pNext;
}
vector<int> printListFromTailToHead(ListNode* head)
{
deque<int> vec;
ListNode *tmp = head;
while(tmp)
{
vec.push_front(tmp->val);
tmp = tmp->next;
}
deque<int>::iterator it = vec.begin();
while(it != vec.end())
{
cout<<*it<<" ";
++it;
}
return vector<int> tmp;
}
void PrintListFromTailToHead(ListNode * pHead)
{
std::stack<ListNode*> nodes;
ListNode* tmp = nodes;
while(tmp)
{
nodes.push(tmp);
tmp = tmp->m_pNext;
}
while(!nodes.empty())
{
cout<<nodes.top()->m_nKey<<" ";
nodes.pop();
}
}
*/
|
a2cd78bbcb8a5f2f02b8396104343b2558f43bf3
|
63f26436d7da082923543af10731665b23892642
|
/examples/reduce.cpp
|
462639f728a58a61c619ea2fa04d8072a4c54b1d
|
[] |
no_license
|
anevero/map_reduce
|
93e8852f391e2c9b75f12a8943d235525595d9d0
|
d4757820f113c6b7e4457e82cb8648dc8ca2f5bb
|
refs/heads/master
| 2022-01-18T18:32:05.390158
| 2021-12-26T19:55:22
| 2021-12-26T19:55:22
| 249,186,375
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,971
|
cpp
|
reduce.cpp
|
// Input format (delimited protobufs):
// Key: user_id
// Subkey: site string
// Value: time
// Output format (delimited protobufs):
// Key: user_id
// Subkey: site string
// Value: time spent (sum)
// The first argument to the script should be the name of the input file, the
// second - the name of the output file. All the entries in the input file must
// have the same user id!
#include <iostream>
#include <string>
#include <vector>
#include "absl/random/random.h"
#include "data_piece.pb.h"
#include "buffered_io/buffered_reader.h"
#include "buffered_io/buffered_writer.h"
#include "utils/utils.h"
std::vector<DataPiece> ReadEntries(const std::string& src_file) {
std::vector<DataPiece> entries;
BufferedReader reader(src_file);
while (true) {
auto data_piece = reader.ReadDataPiece();
if (data_piece.key().empty()) {
break;
}
entries.push_back(std::move(data_piece));
}
return entries;
}
void ProcessAndWriteEntries(const std::vector<DataPiece>& entries,
const std::string& dst_file) {
std::string user_id = entries.front().key();
std::map<std::string, uint64_t> site_map;
for (auto& entry: entries) {
site_map[entry.subkey()] += std::stoull(entry.value());
}
BufferedWriter writer(dst_file);
for (auto&&[site_address, time]: site_map) {
DataPiece entry;
entry.set_key(user_id);
entry.set_subkey(site_address);
entry.set_value(std::to_string(time));
writer << entry;
}
}
int main(int argc, char* argv[]) {
if (argc < 3) {
std::cerr << "Not enough arguments for this program." << std::endl;
return 1;
}
if (auto status = utils::ValidateFile(argv[1]); !status.ok()) {
std::cerr << status << std::endl;
return 1;
}
absl::BitGen random_generator;
if (absl::Uniform<uint64_t>(
absl::IntervalClosed, random_generator, 1, 7) == 1) {
return 1;
}
ProcessAndWriteEntries(ReadEntries(argv[1]), argv[2]);
return 0;
}
|
6c48504966866fbbca7e34585f41cabf5f810adb
|
d5fce8e6172fc3b2366d3d22ca5816149dfbfd10
|
/hilti/toolchain/src/compiler/visitors/scope-builder.cc
|
454d78e01336f79bc4069e59da7b45c7eef8f94d
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
jonknet/spicy
|
059f12369ca701349080d9816dc461105486b2e4
|
422f31db99cb64c9fea36ee116bb5f9fe3d7e9f4
|
refs/heads/main
| 2023-06-19T09:42:09.644924
| 2021-07-09T06:34:26
| 2021-07-09T06:34:52
| 385,472,907
| 1
| 0
|
NOASSERTION
| 2021-07-13T04:18:36
| 2021-07-13T04:18:36
| null |
UTF-8
|
C++
| false
| false
| 13,519
|
cc
|
scope-builder.cc
|
// Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
#include <hilti/ast/declaration.h>
#include <hilti/ast/declarations/expression.h>
#include <hilti/ast/declarations/forward.h>
#include <hilti/ast/declarations/global-variable.h>
#include <hilti/ast/declarations/imported-module.h>
#include <hilti/ast/detail/visitor.h>
#include <hilti/ast/expressions/keyword.h>
#include <hilti/ast/expressions/list-comprehension.h>
#include <hilti/ast/statements/declaration.h>
#include <hilti/compiler/detail/visitors.h>
#include <hilti/compiler/unit.h>
using namespace hilti;
namespace {
struct VisitorPass1 : public visitor::PostOrder<void, VisitorPass1> {
explicit VisitorPass1(Unit* unit) : unit(unit) {}
Unit* unit;
void operator()(const Module& m, position_t p) {
Node d = Declaration(declaration::Module(NodeRef(p.node), m.meta()));
p.node.scope()->insert(m.id(), std::move(d));
}
void operator()(const declaration::ImportedModule& m, position_t p) {
auto& other = unit->imported(m.id());
p.node = declaration::ImportedModule::setModule(m, NodeRef(other));
p.node.setScope(other.scope());
}
void operator()(const type::Function& m, position_t p) {
if ( p.parent().isA<Function>() )
p.node.scope()->moveInto(p.parent().scope().get());
}
void operator()(const type::Enum& m, position_t p) {
if ( auto t = p.parent().tryAs<declaration::Type>() ) {
for ( const auto& l : m.labels() ) {
auto e = expression::Ctor(ctor::Enum(l, NodeRef(p.parent()), l.meta()), l.meta());
auto d = declaration::Constant(l.id(), std::move(e), t->linkage(), l.meta());
p.parent().scope()->insert(l.id(), Declaration(std::move(d)));
}
}
}
void operator()(const type::Struct& m, position_t p) {
if ( auto t = p.parent().tryAs<declaration::Type>() ) {
auto id = ID("self", m.meta());
auto type = type::Computed(NodeRef(p.parent()),
[](Node& n) { return type::ValueReference(n.as<declaration::Type>().type()); });
auto self = expression::Keyword(expression::keyword::Kind::Self, type, m.meta());
auto d = declaration::Expression(id, self, declaration::Linkage::Private, m.meta());
p.parent().scope()->insert(id, Declaration(d));
// Make parameters accessible
for ( auto&& x : p.node.as<type::Struct>().parameterNodes() )
p.parent().scope()->insert(x->as<type::function::Parameter>().id(), NodeRef(x));
for ( auto& f : m.fields() ) {
// If &id is specified, make field directly accessible under
// given ID (i.e., as alias to "self.[...]").
ID id;
if ( auto x = AttributeSet::find(f.attributes(), "&id") )
id = ID(*x->valueAs<std::string>(), f.meta());
if ( id ) {
Expression self =
expression::ResolvedID("self", NodeRef(p.parent().scope()->lookup("self")->node), f.meta());
self = Expression(
operator_::value_reference::Deref::Operator().instantiate({std::move(self)}, f.meta()));
auto e =
operator_::struct_::MemberConst::Operator().instantiate({std::move(self),
expression::Member(f.id(), f.meta())},
f.meta());
auto d = declaration::Expression(id, std::move(e), {}, declaration::Linkage::Private, f.meta());
p.parent().scope()->insert(id, Declaration(d));
}
if ( f.isStatic() ) {
// Insert static member into struct's namespace.
auto field_id = f.id();
auto module_id = p.template findParent<Module>()->get().id();
auto qualified_id = ID(module_id, t->id(), f.id());
std::optional<Declaration> decl;
if ( f.type().isA<type::Function>() ) {
auto wrapper = type::Computed(NodeRef(p.node), [field_id](auto n) {
auto t = n.template as<type::Struct>();
return t.field(field_id)->type();
});
auto nf = Function(f.id(), wrapper, {}, f.callingConvention());
decl = declaration::Function(std::move(nf), t->linkage(), m.meta());
}
else
// Using a local here is cheating a bit: We just need to
// get the ID through to codegen.
decl = declaration::LocalVariable(qualified_id, f.type());
p.parent().scope()->insert(f.id(), *decl);
}
}
}
}
void operator()(const statement::Switch& s, position_t p) {
auto wrapper =
type::Computed(NodeRef(p.node), [](Node& n) { return n.template as<statement::Switch>().type(); });
auto d = declaration::LocalVariable(ID("__x"), wrapper, {}, true, s.meta());
p.node.scope()->insert(d.id(), Declaration(d));
}
void operator()(const statement::Declaration& d, position_t p) {
p.node.scope()->moveInto(p.parent().scope().get());
}
void operator()(const declaration::Parameter& d, position_t p) {
if ( p.parent(2).isA<Function>() )
p.parent(2).scope()->insert(d.id(), NodeRef(p.node));
if ( p.parent(1).isA<statement::try_::Catch>() )
p.parent(1).scope()->insert(d.id(), NodeRef(p.node));
}
void operator()(const declaration::LocalVariable& d, position_t p) {
if ( p.parent().isA<statement::If>() ) {
// Statement node may be replaced later, so insert an indirect
// reference to the local.
NodeRef x = NodeRef(p.parent());
auto forward =
declaration::Forward([x]() -> Declaration { return *x->as<statement::If>().init(); }, d.meta());
p.parent().scope()->insert(d.id(), Declaration(forward));
return;
}
if ( p.parent().isA<statement::While>() ) {
// Statement node may be replaced later, so insert an indirect
// reference to the local.
NodeRef x = NodeRef(p.parent());
auto forward =
declaration::Forward([x]() -> Declaration { return *x->as<statement::While>().init(); }, d.meta());
p.parent().scope()->insert(d.id(), Declaration(forward));
return;
}
p.parent().scope()->insert(d.id(), NodeRef(p.node));
}
void operator()(const expression::ListComprehension& e, position_t p) {
if ( p.node.scope()->has(e.id()) )
// We can encounter this node multiple times.
return;
auto wrapper = type::Computed(NodeRef(p.node), [](auto n) {
const auto& lc = n.template as<expression::ListComprehension>();
if ( lc.input().type().template isA<type::Unknown>() )
return lc.input().type();
if ( auto t = lc.input().type(); type::isIterable(t) )
return t.iteratorType(true).dereferencedType();
else
return type::unknown;
});
auto d = declaration::LocalVariable(e.id(), wrapper, {}, true, e.id().meta());
p.node.scope()->insert(d.id(), Declaration(d));
}
void operator()(const statement::For& s, position_t p) {
auto wrapper = type::Computed(NodeRef(p.node), [](auto n) {
auto t = n.template as<statement::For>().sequence().type();
if ( t.template isA<type::Unknown>() )
return t;
if ( ! type::isIterable(t) )
return type::unknown;
return t.iteratorType(true).dereferencedType();
});
auto d = declaration::LocalVariable(s.id(), wrapper, {}, true, s.id().meta());
s.scope()->insert(d.id(), Declaration(d));
}
};
struct VisitorPass2 : public visitor::PostOrder<void, VisitorPass2> {
explicit VisitorPass2(Unit* unit) : unit(unit) {}
Unit* unit;
void operator()(const Declaration& d, position_t p) {
if ( p.parent().isA<Module>() && d.id().namespace_().empty() )
p.parent().scope()->insert(d.id(), NodeRef(p.node));
}
};
struct VisitorPass3 : public visitor::PostOrder<void, VisitorPass3> {
explicit VisitorPass3(Unit* unit) : unit(unit) {}
Unit* unit;
std::pair<bool, std::optional<NodeRef>> lookupType(Node* u, const ID& id) {
auto resolved = u->scope()->lookupAll(id);
if ( resolved.empty() )
return std::make_pair(false, std::nullopt);
if ( resolved.size() == 1 ) {
auto& r = resolved.front();
if ( auto t = r.node->template tryAs<declaration::Type>() ) {
if ( t->type().isA<type::Struct>() )
return std::make_pair(false, r.node);
}
u->addError(util::fmt("ID %s does not resolve to a type (but to %s)", id, r.node->typename_()));
return std::make_pair(true, std::nullopt);
}
u->addError(util::fmt("type namespace %s is ambiguous", id));
return std::make_pair(true, std::nullopt);
}
void operator()(const declaration::Function& f, position_t p) {
if ( f.linkage() == declaration::Linkage::Struct && ! f.function().isStatic() ) {
auto ns = f.id().namespace_();
if ( ns.empty() ) {
p.node.addError("method lacks a type namespace");
return;
}
for ( auto i = p.path.rbegin(); i != p.path.rend(); i++ ) {
auto [stop, node] = lookupType(&**i, ns);
if ( stop )
return;
if ( ! node )
continue;
auto t = (*node)->as<declaration::Type>().type().as<type::Struct>();
auto fields = t.fields(f.id().local());
if ( fields.empty() ) {
p.node.addError(util::fmt("type %s does not have a method '%s'", ns, f.id().local()));
return;
}
bool found = false;
for ( const auto& sf : fields ) {
auto sft = sf.type().tryAs<type::Function>();
if ( ! sft ) {
p.node.addError(util::fmt("%s is not a method", ID(ns, f.id().local())));
return;
}
if ( areEquivalent(*sft, f.function().type()) ) {
// Link any "auto" parameters to the declaration. When
// we update one later, all linked instanced will
// reflect the change. For types that are already
// resolved, we can just update any remaining auto
// directly.
auto field_params = sft->parameters();
auto method_params = f.function().type().parameters();
for ( auto&& [pf, pm] : util::zip2(field_params, method_params) ) {
auto af = pf.type().tryAs<type::Auto>();
auto am = pm.type().tryAs<type::Auto>();
if ( af && am )
am->linkTo(*af); // both will be resolved together
else if ( af )
af->typeNode() = pm.type(); // the other is already resolved
else if ( am )
am->typeNode() = pf.type(); // the other is already resolved
}
found = true;
}
}
if ( ! found ) {
p.node.addError(
util::fmt("type %s does not have a method '%s' matching the signature", ns, f.id().local()));
return;
}
p.node.setScope((*node)->scope());
return;
}
p.node.addError(util::fmt("cannot resolve type namespace %s", ns));
}
}
};
} // anonymous namespace
void hilti::detail::clearErrors(Node* root) {
for ( const auto&& i : hilti::visitor::PreOrder<>().walk(root) )
i.node.clearErrors();
}
void hilti::detail::buildScopes(const std::vector<std::pair<ID, NodeRef>>& modules, Unit* unit) {
util::timing::Collector _("hilti/compiler/scope-builder");
// Need to run each phase on all modules first before proceeding to the
// next as they maybe be cross-module dependencies in later phases.
for ( auto& [id, m] : modules ) {
auto v1 = VisitorPass1(unit);
for ( auto i : v1.walk(&*m) )
v1.dispatch(i);
}
for ( auto& [id, m] : modules ) {
auto v2 = VisitorPass2(unit);
for ( auto i : v2.walk(&*m) )
v2.dispatch(i);
}
for ( auto& [id, m] : modules ) {
auto v3 = VisitorPass3(unit);
for ( auto i : v3.walk(&*m) )
v3.dispatch(i);
}
}
|
178f8db357f828ae5757363b2aaae4d6ebf94f73
|
c4f8919d2e6b63a5b4468fed062b49a8e89cdbdd
|
/D_2.0/include/robot-config.h
|
e04ffaf40d71670c23338405853e12ec7237a591
|
[] |
no_license
|
angelawang197/1492k_2020-21
|
bbd96a5b71c190b9386e713869e44444d4f929d9
|
f5fcebd5040155978e1107c9d87b902f6f0bf981
|
refs/heads/master
| 2023-08-23T12:19:56.386842
| 2021-10-31T06:52:58
| 2021-10-31T06:52:58
| 423,070,537
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 378
|
h
|
robot-config.h
|
using namespace vex;
extern brain Brain;
// VEXcode devices
extern motor_group R;
extern motor_group L;
extern motor Lift1;
extern motor BigLift;
extern controller Controller1;
extern motor Rings;
/**
* Used to initialize code/tasks/devices added using tools in VEXcode Pro.
*
* This should be called at the start of your int main function.
*/
void vexcodeInit( void );
|
16afe4d6b2dfaa216d368758ef5ee8577b0162a7
|
90e03cdb144fd14abaaebe0138351bac754bb5a4
|
/tests/firebird/firebird-blobs.cc
|
a9a37e8f9ce7c15cce325a5f27d95f52820b8c31
|
[
"BSD-3-Clause"
] |
permissive
|
informave/dbwtl
|
2038e9c8e1c17b3ab83e5035014271ec15a649ae
|
fed8f84ac42949d906a34b6a5a1b61b3a7b74356
|
refs/heads/master
| 2018-12-11T12:20:39.438122
| 2018-09-12T18:56:38
| 2018-09-12T19:06:16
| 13,350,267
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,738
|
cc
|
firebird-blobs.cc
|
#include <dbwtl/dal/engines/generic>
#include "../cxxc.hh"
#include "fixture_firebird.hh"
CXXC_FIXTURE_TEST(FirebirdTestbaseFixture, DatabaseVersion)
{
std::cout << dbc.dbmsName() << std::endl;
}
CXXC_FIXTURE_TEST(FirebirdTestbaseFixture, WriteMemoStream)
{
dbc.beginTrans(trx_read_committed);
dbc.directCmd("DELETE FROM alltypes");
DBMS::Statement stmt(dbc);
stmt.prepare("INSERT INTO alltypes(t_text) VALUES(?)");
std::wstringstream ss;
ss << "Teststring";
stmt.bind(1, ss.rdbuf());
stmt.execute();
stmt.close();
dbc.commit();
}
CXXC_FIXTURE_TEST(FirebirdTestbaseFixture, WriteMemo)
{
dbc.beginTrans(trx_read_committed);
dbc.directCmd("DELETE FROM alltypes");
DBMS::Statement stmt(dbc);
stmt.prepare("INSERT INTO alltypes(t_text) VALUES(?)");
std::wstringstream ss;
ss << L"TeststringÖÄÜ";
Memo m(ss.rdbuf());
stmt.bind(1, m);
stmt.execute();
stmt.close();
stmt.execDirect("SELECT CAST(t_text AS VARCHAR(30)) FROM alltypes");
DBMS::Resultset rs;
rs.attach(stmt);
rs.first();
CXXC_CHECK( !rs.column(1).isnull() );
CXXC_ECHO( rs.column(1).get<String>() );
CXXC_CHECK( rs.column(1).get<String>() == "TeststringÖÄÜ" );
stmt.close();
dbc.commit();
}
CXXC_FIXTURE_TEST(FirebirdTestbaseFixture, ReadMemo)
{
dbc.beginTrans(trx_read_committed, trx_readonly);
DBMS::Statement stmt(dbc);
stmt.execDirect("SELECT t_text FROM alltypes");
DBMS::Resultset rs;
rs.attach(stmt);
rs.first();
CXXC_CHECK( rs.column(1).get<String>() == "TeststringÖÄÜ" );
stmt.close();
dbc.commit();
}
CXXC_FIXTURE_TEST(FirebirdTestbaseIso88591Fixture, ReadMemoIso88591)
{
dbc.beginTrans(trx_read_committed, trx_readonly);
DBMS::Statement stmt(dbc);
stmt.execDirect("SELECT t_text FROM alltypes");
DBMS::Resultset rs;
rs.attach(stmt);
rs.first();
CXXC_CHECK( rs.column(1).get<String>() == "TeststringÖÄÜ" );
stmt.close();
dbc.commit();
}
CXXC_FIXTURE_TEST(FirebirdTestbaseFixture, WriteStringToMemo)
{
dbc.beginTrans(trx_read_committed);
dbc.directCmd("DELETE FROM alltypes");
DBMS::Statement stmt(dbc);
stmt.prepare("INSERT INTO alltypes(t_text) VALUES(?)");
stmt.bind(1, String("Ghe ÖÄÜ"));
stmt.execute();
stmt.close();
dbc.commit();
}
int main(void)
{
std::locale::global(std::locale(""));
std::cout.imbue(std::locale());
std::cerr.imbue(std::locale());
std::clog.imbue(std::locale());
std::wcout.imbue(std::locale());
std::wcerr.imbue(std::locale());
std::wclog.imbue(std::locale());
return cxxc::runAll();
}
|
c9b999e1b891cdf0e3114f0ce68630140aaa14cd
|
d1c527c454d1287b50fc0ec546b88679868d3833
|
/src/gol/headers/GOLView.hpp
|
061247ffb46c4c3248a1fae89fd2a7c047dcabdf
|
[] |
no_license
|
johnzeringue/gol
|
5d105238f18fe853e043395fc0c6b95854c80ea4
|
0a501b101d825be7f9fb032acd2f06fecdbd29b1
|
refs/heads/master
| 2020-04-25T16:23:36.109527
| 2015-01-03T20:00:14
| 2015-01-03T20:00:14
| 28,373,794
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 605
|
hpp
|
GOLView.hpp
|
#ifndef GOL_VIEW_H
#define GOL_VIEW_H
#include <string>
#include "GOLModel.hpp"
class GOLView {
public:
//
// CONSTRUCTORS
//
GOLView();
GOLView(char alive_char, char dead_char);
//
// INSTANCE VARIABLES
//
char alive_char;
char dead_char;
//
// METHODS
//
void display(GOLModel model);
private:
//
// METHODS
//
void printRow(unsigned row, GOLModel model);
void printGrid(GOLModel model);
std::string promptForInput();
};
#endif
|
800896459556876ccfa4a1870bdd69458a926542
|
f17a88ddef74abe099a0c9d9d9aa91b90075959c
|
/Code/Runtime/Asset/Controllers/AssetOpController.h
|
dc086ace95aaf8966663e3bfd3ee7581c9d81a9c
|
[
"MIT",
"Apache-2.0"
] |
permissive
|
NathanSaidas/LiteForgeMirror
|
bf4b0feb9702b590b510f98f32a3cc1d472f9bb0
|
dcb7f690378dd0abe0d1dc3e2783510ce9462fde
|
refs/heads/master
| 2022-06-12T11:55:06.321048
| 2022-05-30T04:37:59
| 2022-05-30T04:37:59
| 184,840,363
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,202
|
h
|
AssetOpController.h
|
#pragma once
// ********************************************************************
// Copyright (c) 2020 Nathan Hanlan
//
// 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 "Core/Common/API.h"
#include "Core/Concurrent/TaskScheduler.h"
#include "Core/Memory/AtomicSmartPointer.h"
#include "Core/Platform/SpinLock.h"
#include "Core/Utility/Array.h"
#include "Core/Utility/SmartCallback.h"
#include "Runtime/Asset/AssetCommon.h"
namespace lf {
DECLARE_ATOMIC_PTR(AssetOp);
DECLARE_ATOMIC_WPTR(AssetOp);
// Operations will be stored in different 'lists'
//
// Idle List
// Execution List
// Waiting List
//
// Op::Execute -- Moves the operation from the 'Idle' list to the 'Execution' list.
// Op::Update -- Potentially move to the 'Wait List' if the operation is waiting on another operation.
// Op::OnComplete -- Call all the registered callbacks and possibly move something off the wait list and onto the execution list
// Op::OnComplete -- Also moving the op off the execution list and ending it
class LF_RUNTIME_API AssetOpController
{
public:
AssetOpController();
~AssetOpController();
void Initialize();
void Shutdown();
void Update();
void Register(AssetOp* op);
template<typename T>
void Call(AssetOpThread::Value thread, const T& function, void* param = nullptr) { Call(thread, TCallback<void, void*>::Make(function), param); }
void Call(AssetOpThread::Value thread, const TCallback<void, void*>& function, void* param = nullptr);
AssetOpAtomicWPtr GetCompleted() const { return mCompletedOp; }
private:
void DispatchAsyncCalls();
SpinLock mAsyncCallLock;
TaskScheduler mScheduler;
struct AsyncCall
{
TCallback<void, void*> mFunction;
void* mParam;
};
TVector<AsyncCall> mMainThreadAsyncCalls;
SpinLock mInitializeOpsLock;
TVector<AssetOpAtomicPtr> mInitializeOps;
volatile Atomic32 mAsyncOps;
TVector<AssetOpAtomicPtr> mOps;
AssetOpAtomicPtr mCompletedOp;
};
} // namespace lf
|
6b1befb2ac15379698f0967a8d0e66abfcf8461f
|
ef2a556f9b79a5428a13ef65df4998c99a7240fc
|
/FindAllDistinctPalindromicSubstringsOfAGivenString.cpp
|
b8dcae5edb20c02eca75bbb4d9534796f895a168
|
[] |
no_license
|
ppzzyy11/codes
|
451b74cc500f0741b5b2079409122cb32772b7f7
|
306852aabc2bf7bd79b37572905314e7deb46bbc
|
refs/heads/master
| 2021-10-21T19:49:14.386026
| 2019-03-06T06:21:50
| 2019-03-06T06:21:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,032
|
cpp
|
FindAllDistinctPalindromicSubstringsOfAGivenString.cpp
|
#include<iostream>
#include<list>
#include<vector>
#include<climits>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>//make_heap
#include<utility>
#include<unordered_set>
#include<unordered_map>
using namespace std;
ostream& operator<<(ostream& os,const set<string>& strs)
{
for(auto it=strs.begin();it!=strs.end();it++)
{
cout<<*it<<endl;
}
return os;
}
set<string> FindAllDistinctPalindromicSubstringsOfAGivenString(const string& str)
{
set<string> res;
int l,r;
for(int i=0;i<str.size();i++)
{
l=i,r=i;
while(l>=0&&r<str.size()&&str[l]==str[r])
{
string tmp=str.substr(l,r-l+1);
if(res.count(tmp)==0)
{
res.insert(tmp);
}
l--;
r++;
}
l=i,r=i+1;
while(l>=0&&r<str.size()&&str[l]==str[r])
{
string tmp=str.substr(l,r-l+1);
if(res.count(tmp)==0)
{
res.insert(tmp);
}
l--;
r++;
}
}
cout<<res<<endl;
return res;
}
int main()
{
string str="geek";
//string str="abaaa";
FindAllDistinctPalindromicSubstringsOfAGivenString(str);
return 0;
}
|
2b0a81bbe998600fd5927bb9e271e427e65559bc
|
9bcc58e5f99c5b41f8e95fcbe13933297120caa6
|
/Workspace/Aufg_5/Malefiz/Views/AusgangspositionsView.h
|
882a4e8dccfd70ec18eeed1c5a9987d260a95279
|
[] |
no_license
|
NilsHelming/OOAD
|
8bcdd3bf100798ee77de59cb20e79885ee81c4c5
|
df25a84844dad18efb7d3d50728c2f17eba3d719
|
refs/heads/master
| 2023-07-14T11:36:42.889033
| 2021-07-20T08:24:46
| 2021-07-20T08:24:46
| 351,356,011
| 0
| 0
| null | 2021-04-08T08:32:44
| 2021-03-25T08:08:42
|
TeX
|
UTF-8
|
C++
| false
| false
| 342
|
h
|
AusgangspositionsView.h
|
#pragma once
class AusgangspositionsView;
#include <memory>
#include "..\Interfaces\View.h"
#include "..\Models\Spielfeld.h"
class AusgangspositionsView : public View {
private:
std::shared_ptr<Spielfeld> spielfeld;
public:
explicit AusgangspositionsView(std::shared_ptr<Spielfeld>);
void modelChanged();
void show();
};
|
eab1bd3a78ceb756d0a158844797b5a045c98daa
|
29d1f7ef9266cc8c707df4c44e7ba98411edfdae
|
/Codechef/LONG-June2017/SUMQ.cpp
|
c0606ccc613f0bbfa9c83535acf8dc1fd15b6df5
|
[] |
no_license
|
thelazy/ContestCodes
|
2f0484118897746910669ee469166c7fd9e80b47
|
2088c129493b6fc7c4006f079f24f3584dde2805
|
refs/heads/master
| 2020-05-20T12:28:54.809592
| 2019-04-19T05:30:26
| 2019-04-19T05:30:26
| 70,280,672
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,064
|
cpp
|
SUMQ.cpp
|
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long pp[100011], qq[100011], rr[100011], p, q, r, t, i, j, k, ans;
long long ps[100011], rs[100011];
int main(){
scanf("%lld", &t);
while(t--){
ans = 0;
scanf("%lld %lld %lld", &p, &q, &r);
pp[0]=0;qq[0]=0;rr[0]=0;
for(i=1; i<=p; i++)
scanf("%lld", &pp[i]);
for(i=1; i<=q; i++)
scanf("%lld", &qq[i]);
for(i=1; i<=r; i++)
scanf("%lld", &rr[i]);
sort(pp+1, pp+p+1);
sort(qq+1, qq+q+1);
sort(rr+1, rr+r+1);
ps[0]=0; rs[0]=0;
for(i=1; i<=p; i++){
ps[i]=(pp[i]+ps[i-1])%mod;
}
for(i=1; i<=r; i++){
rs[i]=(rr[i]+rs[i-1])%mod;
}
j=1; k=1;
for(i=1; i<=q; i++){
for(j; j<=p; j++){
if(pp[j]>qq[i])
break;
}
for(k; k<=r; k++){
if(rr[k]>qq[i])
break;
}
ans += (((((j-1)*(k-1))%mod)*((qq[i]*qq[i])%mod))%mod);
ans = ans%mod;
ans += ((qq[i]*((((k-1)*ps[j-1])%mod)+(((j-1)*rs[k-1])%mod)))%mod);
ans = ans%mod;
ans += ((ps[j-1]*rs[k-1])%mod);
ans = ans%mod;
}
printf("%lld\n", ans);
}
return 0;
}
|
762e339028da1f997f05eb13beb994984160eff3
|
62408a02b44f2fd20c6d54e1f5def0184e69194c
|
/UVA/10347/21766516_AC_0ms_0kB.cpp
|
f5b9bd2f20ac0bbaefb6391cf9ad4dd2e17998fe
|
[] |
no_license
|
benedicka/Competitive-Programming
|
24eb90b8150aead5c13287b62d9dc860c4b9232e
|
a94ccfc2d726e239981d598e98d1aa538691fa47
|
refs/heads/main
| 2023-03-22T10:14:34.889913
| 2021-03-16T05:33:43
| 2021-03-16T05:33:43
| 348,212,250
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 487
|
cpp
|
21766516_AC_0ms_0kB.cpp
|
#include<bits/stdc++.h>
using namespace std;
double a,b,c,x,y,z;
int mx,cnt;
const double pi = acos(-1.0);
bool ok;
double degree(double a)
{
return a*pi/180.0;
}
double radtodegree(double a)
{
return a*180/pi;
}
int main()
{
while(scanf("%lf %lf %lf",&a,&b,&c)!=EOF )
{
x = a;
y = b;
z = c;
a*=a;
b*=b;
c*=c;
if(2*(a*b+a*c+b*c)<=(a*a+b*b+c*c) || a<=0 || b<=0 ||c <=0) printf("-1.000\n");
else printf("%.3lf\n",sqrt(2*(a*b+a*c+b*c)-(a*a+b*b+c*c))/3);
}
return 0;
}
|
a46c0814d5d43359ba21cfbf172495ad062abe78
|
79c06808b304aeb3007ddebcbe60d09d9ee6bb7b
|
/Assignments/Assignment1Objects/DiceClassCPP/main.cpp
|
64978e1dd2d9ce1c6967c5483644e03bcb0a02bc
|
[] |
no_license
|
SebastianHall69/CIS17B_Spr19_AdvObjects
|
12442dedabe78722e70e628e0c9a7f25cf1f37b2
|
6f6b3d68f844f61f264fcbbfd8cd201839556e29
|
refs/heads/master
| 2020-04-22T18:16:18.486885
| 2019-12-09T06:32:13
| 2019-12-09T06:32:13
| 170,571,606
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 547
|
cpp
|
main.cpp
|
/*
* File: main.cpp
* Author: Sebastian Hall
* Created on March 7, 2019, 1:26 PM
* Purpose: Test the dice class
*/
#include <iostream>
#include "Dice.h"
using namespace std;
int main(int argc, char** argv) {
//Declare variables
Dice *die = nullptr;//Pointer to sides of dice
//Loop through and create/delete 6 sides of a dice and output dice
for(int i = 1; i <= 6; ++i) {
die = new Dice(i);
die->toString();
cout<<endl;
delete die;
}
//A Sebastian Production
return 0;
}
|
6618effc00450ab7888b56ebeed4d8788d7459e6
|
b9c01ab78ffdee7d488e4c8a9ebdaa241d72c436
|
/Project-3/symbol.hpp
|
57bc18d1b88bcacd4d67c0843a60a8ede158097c
|
[] |
no_license
|
lewis267/CS251
|
87cfa7eea19b9ba2a94d5a5b4f74669d421132d7
|
1ce619d8e422a1a2ebe6873a682ab0a1a32aa747
|
refs/heads/master
| 2021-01-20T00:11:11.690628
| 2017-05-06T23:14:56
| 2017-05-06T23:14:56
| 89,091,223
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,229
|
hpp
|
symbol.hpp
|
#ifndef _SYMBOL_HPP_
#define _SYMBOL_HPP_
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "key.hpp"
// a node in the symbol array which will contain the decoded values
struct symbol_node {
symbol_node() : value(0), isfull(0), next(NULL) {}
symbol_node(int value, symbol_node * n = NULL) : value(0), isfull(1), next(n) {}
key_type value;
bool isfull;
symbol_node * next; // pointer to next node
/*
* When delete is used to deallocate memory for a C++ class object,
* the object's destructor is called before the object's memory is
* deallocated (if the object has a destructor).
*
* <https://msdn.microsoft.com/en-us/library/h6227113.aspx>
*/
// Takes care of the linked list dynamic allocation
~symbol_node() {
std::cout << "del";
if (next) { delete next; }
}
};
// array of symbol_nodes to store the values
//typedef unordered_map<key_type, symbol_node> symbol_table;
using value_type = std::vector<key_type>;
//using symbol_table = std::unordered_map<key_type, value_type>;
// class def
class Symbol {
private:
std::vector<Key> T;
public:
Symbol(const std::string&);
~Symbol();
void decrypt(const std::string&);
void print_table();
};
#endif
|
a1bef85e21264d18b957de4ff32f8ff9a129819c
|
19f6b6ae0b4ff04269c4c3067238a8094d4db992
|
/ahgen/src/ahtest.cxx
|
1487ed032cc97daf07196808893094e4c7d73e00
|
[] |
no_license
|
Areustle/heacore
|
20fc58b1c9be75aa2e3ad0c72facdac9b1d5a598
|
4e7be354bdef2f84c37a6b49f60bad9e2827bcc5
|
refs/heads/master
| 2021-01-14T08:47:31.145648
| 2017-02-21T16:45:42
| 2017-02-21T16:45:42
| 81,976,859
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,222
|
cxx
|
ahtest.cxx
|
/// \file ahtest.cxx
/// \brief Declarations of public members of the test support library.
/// \author James Peachey
/// \date $Date: 2014/02/03 22:39:41 $
#define AHLABEL ahgen_ahtest
#define AHCVSID "$Id: ahtest.cxx,v 1.12 2014/02/03 22:39:41 mwitthoe Exp $"
#include "ahgen/ahtest.h"
#include "ahgen/ahgen.h"
#include "ahlog/ahlog.h"
#include <sstream>
#include <cmath>
namespace ahgen {
/// \callgraph
void testReport(const LocalVars & lvars) {
std::stringstream exc;
if (lvars.m_exception != "") exc << std::endl << " " << lvars.m_exception;
if(lvars.m_ok) {
AH_INFO(ahlog::HIGH) << "Passed: " << lvars.m_section << exc.str() << std::endl;
} else {
AH_ERR << "Failed: " << lvars.m_section << exc.str() << std::endl;
}
std::list<std::string>::const_iterator it;
for (it=lvars.m_msg.begin();it!=lvars.m_msg.end();it++)
AH_INFO(ahlog::HIGH) << " --- " << *it << std::endl;
}
/// \callgraph
int finalReport() {
int out=ahgen::getTestStatus();
if (0 == out)
AH_OUT << "Unit test PASSED" << std::endl;
else
AH_OUT << "Unit test FAILED (Status: " << out << ")" << std::endl;
return out;
}
static int s_test_status = 0;
int getTestStatus(void) { return s_test_status; }
int setTestStatus(int status) { if (0 == s_test_status) s_test_status = status; return s_test_status; }
void resetTestStatus(void) { s_test_status = 0; }
bool isEqual(double x, double y, double tol) {
// if x or y are zero, do absolute comparison...
if (0. == x || 0. == y) {
if (tol < std::abs(x-y)) return false;
} else { // else a relative comparison
if (tol < (2.0*std::abs(x-y)/std::abs(x+y))) return false;
}
return true;
}
} /* namespace ahgen */
/* Revision Log
$Log: ahtest.cxx,v $
Revision 1.12 2014/02/03 22:39:41 mwitthoe
ahtest (ahgen): change test messages to more closely match aht output
Revision 1.11 2013/09/17 17:57:46 mwitthoe
ahgen/ahtest: add optional argument to ahgen::isEqual() which allows a custom tolerance, default value is 1.e-10 (as before); if comparing against zero, change to absolute instead of relative difference, since the latter will always be 1. or undefined
Revision 1.10 2013/01/22 14:18:49 mwitthoe
capitalize FAILURE in ahtest summary to ea
Revision 1.9 2012/11/07 18:58:10 mwitthoe
change output chatter level used by FAILTEXT (LOW -> HIGH)
Revision 1.8 2012/10/23 19:39:13 peachey
Fix typo: pased -> passed.
Revision 1.7 2012/10/11 17:58:37 mwitthoe
ahgen: make isEqual() test relative to magnitude instead of absolute
Revision 1.6 2012/09/18 01:05:07 mwitthoe
add isEqual() function to ahtest to help compare doubles
Revision 1.5 2012/09/14 23:55:24 mwitthoe
apply version standards to ahgen
Revision 1.4 2012/08/29 18:55:39 mwitthoe
in ahtest, include exception message, if caught
Revision 1.3 2012/08/22 18:23:29 mwitthoe
give ahtest its own status variable instead of using the (defunct) status from ahgen; this change does not affect usage
Revision 1.2 2012/08/21 19:14:13 mwitthoe
optional messages in ahtest are now printed as low-priority information instead of errors
Revision 1.1 2012/08/21 19:06:29 mwitthoe
implement testing method in ahgen/ahtest
*/
|
dcab5c00604916c5d7f25aee96255c8e6d78edb7
|
1349e33d666d094ec867a7c9fe618fa7125c089a
|
/CSdata/jungFinalExamCsUNO/아두이노 소스 축약/Aduino_serialCommunication_CS/CS_serialCommunication/CS_serialCommunication/CS_serialCommunication.ino
|
4d93857537ddef52921de1de96a4f294a6aa51eb
|
[] |
no_license
|
ghdcjf5/CSharp
|
6126a800b22d08a0cf2ac67d08bf4bf36f18d987
|
92d679a371e37403adef8e5148e9d28eef958857
|
refs/heads/master
| 2023-05-08T01:28:05.434291
| 2021-05-06T01:15:15
| 2021-05-06T01:15:15
| 364,745,547
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,385
|
ino
|
CS_serialCommunication.ino
|
#define LedPin11 11
#define LedPin13 13
#define LedPin9 9
#define LedPin8 8
String inputString = "";
bool stringComplete = false;
void setup() {
// Open serial communications and wait for port to open:
pinMode(LedPin11,OUTPUT); pinMode(LedPin13,OUTPUT); pinMode(LedPin8,OUTPUT); pinMode(LedPin9,OUTPUT);
Serial.begin(9600);
inputString.reserve(200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
}
void loop() { // run over and over
if(digitalRead(LedPin8) ==HIGH)
Serial.println("sw_on");
if(digitalRead(LedPin9) ==HIGH)
Serial.println("sw_off");
if(Serial.available())
{
char inChar = (char)Serial.read();
if (inChar == '\n' || inChar == '\r')
stringComplete = true;
else
inputString += inChar;
}
if (stringComplete){
inputString.toUpperCase();
if(inputString.equals("LED_ON"))
digitalWrite(LedPin13,HIGH);
else if(inputString.equals("LED_OFF"))
digitalWrite(LedPin13,LOW);
else if(inputString.equals("BRIGHT_OFF"))
analogWrite(LedPin11,0);
else if(inputString.equals("BRIGHT_HALF"))
analogWrite(LedPin11,127);
else if(inputString.equals("BRIGHT_FULL"))
analogWrite(LedPin11,255);
inputString = "";
stringComplete = false;
}
}
|
4b9b74be9ca8b997fd55ffd5b444565fb6ad1ca3
|
c4b6f3e7fd3c4d2f7fa3922581ef30b714c12036
|
/VeriyapılarıOdev1/src/Ogrenci.cpp
|
fe21a66fdbdb8fc91cabee5441de8f86a1d3e96f
|
[] |
no_license
|
alituzun/HeapMemoryManagement
|
2ffd29e6bdabcce7ab20e8d846f8485c4b7bf808
|
167a1caab0016ad1c8406578c71484a732c6b0ea
|
refs/heads/master
| 2020-04-28T23:49:26.117898
| 2019-03-14T17:38:32
| 2019-03-14T17:38:32
| 175,670,622
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 310
|
cpp
|
Ogrenci.cpp
|
/**
* @description Dizileri heapbölleğe atama
* @course 1-C
* @assignment 1.ODEV
* @date 30.10.2018
* @author Ali Tüzün ali.tuzun11@gmail.com
*/
#include "Ogrenci.hpp"
Ogrenci::Ogrenci(char p1){
ogrenci_name=p1;
}
char Ogrenci::Ogrenci_Getir(){
return ogrenci_name;
}
|
52be6caf5355be078c7e4fcba7fc1cc71d88a6fa
|
0421aa079dc3a8e24645558e10e1c805e9180cad
|
/Player.h
|
940984c0217f9086b76e20d7fa9ea6125058da66
|
[
"BSD-3-Clause"
] |
permissive
|
apoloid/FutureShinobi
|
4ea2bd45d704a5d893239338947954ce5fb41b16
|
baafda76d490faf3003fe8a7647ad676d7426dca
|
refs/heads/master
| 2020-05-18T10:49:49.079930
| 2014-12-26T01:46:51
| 2014-12-26T01:46:51
| null | 0
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 1,266
|
h
|
Player.h
|
/*
プレイヤーの動きに関するところ
*/
//インクルードガード
#ifndef INCLUDE_PLAYER_H
#define INCLUDE_PLAYER_H
class CPlayer
{
public: //表に出すもの
/*コンストラクタとデストラクタ*/
//コンストラクタ
CPlayer();
//デストラクタ
~CPlayer();
/*メンバ変数・定数*/
//方向
enum DIRECTION
{
LEFT,
RIGHT
};
/*メンバ関数*/
//画像の読み込み
void load();
//画像の解放
void release();
//初期化
void init(double initX,double initY,DIRECTION initD);
//更新
void update();
//描画
void draw();
private: //隠しておくもの
/*メンバ変数・定数*/
//切り取る画像の大きさ
const int TEXTURE_SIZE = 64;
//位置座標
double x, y;
//速度
double vx, vy;
//キャラクターの大きさ
int w, h;
//画像座標
int rx, ry;
//画像サイズ
int dw, dh;
//画像に評する画像の拡大・縮小率
double scale;
//画面に表示する画像の大きさ
int sw, sh;
//画像の回転率
double rad;
//画像の座標調整
int r_adjust;
//画像のアニメーション番号
int anim_number;
//画像のアニメーションタイマー
int anim_timer;
//方向
DIRECTION direction;
};
#endif
/*END*/
|
43a9989084044a43306d4910086b416e154214ae
|
04f15913aca8a702efe47962bf82b60eedad73d9
|
/Utils/UdpRoute/Main.cpp
|
c68104f98920d9b0d6cba9567c02f2b7c33e3336
|
[] |
no_license
|
DevilCCCP/Code
|
eae9b7f5a2fede346deefe603a817027a87ef753
|
9cc1a06e5010bb585876056a727abad48bca3915
|
refs/heads/master
| 2021-10-07T17:04:27.728918
| 2021-09-28T06:49:50
| 2021-09-28T06:49:50
| 166,522,458
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,182
|
cpp
|
Main.cpp
|
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include "Router.h"
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QCoreApplication::setApplicationName("UDP route");
QCoreApplication::setApplicationVersion("1.0");
QCommandLineParser parser;
parser.setApplicationDescription(QString("UDP route from one local port to any of others."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("source", "Local port to read from", "source");
parser.addPositionalArgument("destination", "Local destination ports (any number)", "destination [destination2]...");
parser.process(app);
const QStringList args = parser.positionalArguments();
if (args.size() <= 1) {
parser.showHelp(1);
}
int srcPort = args.at(0).toInt();
if (!srcPort) {
parser.showHelp(2);
}
QVector<int> dstPortList;
for (int i = 1; i < args.size(); i++) {
int dstPort = args.at(i).toInt();
if (!dstPort) {
parser.showHelp(3);
}
dstPortList.append(dstPort);
}
Router* router = new Router(&app);
router->Start(srcPort, dstPortList);
return app.exec();
}
|
6b21c27748417f5c7325a17e5526a26f097b9c99
|
806410cc83acebed719e5804232821bc83a87f01
|
/source/library/render/public/potato/render/render_task.h
|
b4f6435343fe23aff903be99186f340a5b7ec06d
|
[
"MIT"
] |
permissive
|
blockspacer/potato
|
e4d37969b791f434826114721455d8dbb642d361
|
a52f9712e5251412e14406c54927ab9984ec6f0e
|
refs/heads/master
| 2020-07-05T19:02:41.665477
| 2019-07-19T03:15:09
| 2019-07-19T03:15:09
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 162
|
h
|
render_task.h
|
// Copyright (C) 2019 Sean Middleditch, all rights reserverd.
#include "potato/foundation/delegate.h"
namespace up {
using RenderTask = delegate<void()>;
}
|
fdb985c5dceeda33694a383a394e1243f3071c3e
|
3df54efd316b855c07f91eda806d57202fb913fa
|
/Mikrokontroller/pin_PWM_analogWrite_IoT_Blynk.ino
|
6127b479ded0f8c08408b52aeac1ca7895f6efe9
|
[] |
no_license
|
univmajalengka/191410025
|
ffe2909dde75156a7b461231373dca4f7bcb53b1
|
73bf80bcfe1ddf8e1f4fb3d99f87fffd644402bc
|
refs/heads/master
| 2021-11-18T21:27:53.526982
| 2021-11-03T07:33:46
| 2021-11-03T07:33:46
| 218,977,578
| 0
| 1
| null | 2020-11-10T01:21:14
| 2019-11-01T12:03:06
|
Visual Basic .NET
|
UTF-8
|
C++
| false
| false
| 789
|
ino
|
pin_PWM_analogWrite_IoT_Blynk.ino
|
//nodeMcu ESP8266
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int led1 = D1;
int led2 = D4;
int led3 = D5;
int led4 = D7;
//Karena Semua pin Di Board ini PWM
char auth[] = "Auth Dari Blynk App";
char ssid[] = "SSID";
char pass[] = "Password";
void setup() {
// put your setup code here, to run once:
Blynk.begin(auth,ssid,pass);
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
BLYNK_WRITE(V1)
{
nilai = param.asInt();
analogWrite(led1, nilai);
analogWrite(led2, nilai);
analogWrite(led3, nilai);
analogWrite(led4, nilai);
Blynk.virtualWrite(V2, nilai);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
}
|
36c0285b410ea49d9ba41c9e9ca21f1bf47acc8b
|
8d9f794194107c0a2071582fc42e71e0908ac4ea
|
/Zorkish/Node.cpp
|
cc44a943eb1e0ed9d412554af66bb804220f452d
|
[] |
no_license
|
Hughl33/Cplusplus
|
8f3bd60a502d8637317f1779b3a0cb1be480725d
|
d6e0344fe470fde9c88196f4233ddb4499a0f6f8
|
refs/heads/master
| 2020-03-31T12:15:03.825176
| 2017-01-22T11:52:15
| 2017-01-22T11:52:15
| 22,980,140
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 350
|
cpp
|
Node.cpp
|
//
// Node.cpp
// Zorkish
//
// Created by Hugh Lee on 2/09/2014.
// Copyright (c) 2014 OysterFinish. All rights reserved.
//
#include "Node.h"
Node::Node(std::string n, std::vector<std::string> l) {
name = n;
links = l;
}
std::string Node::getName() {
return name;
}
std::vector<std::string> Node::getLinks() {
return links;
}
|
3ef1707bca2908e86d34c37ee8e4ef78cc6ace0c
|
80cc8982aac053afbd5c354e4919da7991fbc4b4
|
/contracts/kv_todo/include/kv_todo.hpp
|
fa49bf8c60c0bf922480e5caabecd24e6f7b9bab
|
[
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
opi-smccoole/sample-kv-tables-application
|
47f83dddcc474fe8244b51d6692ea5febacf17e6
|
b07561567c674209906a990e9afb5416062e3a28
|
refs/heads/master
| 2023-03-26T16:27:15.898024
| 2020-11-04T19:55:32
| 2020-11-04T19:55:32
| 309,510,864
| 0
| 3
|
MIT
| 2021-03-25T01:37:25
| 2020-11-02T22:30:44
|
TypeScript
|
UTF-8
|
C++
| false
| false
| 1,824
|
hpp
|
kv_todo.hpp
|
#include <eosio/eosio.hpp>
#include <eosio/system.hpp>
using namespace eosio;
struct todo_entry {
std::string uuid;
eosio::non_unique<std::string, eosio::name> account_name;
eosio::non_unique<std::string, std::string> task;
eosio::non_unique<std::string, bool> checked;
eosio::non_unique<std::string, uint32_t> created;
std::string get_uuid() const { return uuid; }
eosio::name get_account_name() const { return std::get<1>(account_name); }
std::string get_task() const { return std::get<1>(task); }
bool get_checked() const { return std::get<1>(checked); }
int get_created() const { return std::get<1>(created); }
};
class [[eosio::contract]] kv_todo : public contract {
struct [[eosio::table]] todo_table : eosio::kv::table<todo_entry, "todo"_n> {
KV_NAMED_INDEX("uuid"_n, uuid);
KV_NAMED_INDEX("accname"_n, account_name);
KV_NAMED_INDEX("task"_n, task)
KV_NAMED_INDEX("checked"_n, checked)
KV_NAMED_INDEX("created"_n, created)
// constructor for our `kvtodo` table to setup and initialize it
todo_table(eosio::name contract_name) { init(contract_name, uuid); }
};
public:
using contract::contract;
[[eosio::action]]
std::vector<todo_entry> getbyaccname(name account_name);
[[eosio::action]]
todo_entry upsert(const std::string& uuid,
eosio::name account_name,
const std::string& task,
bool checked);
[[eosio::action]]
void del(const std::string& uuid);
using get_by_account_name_action = action_wrapper<"getbyaccname"_n, &kv_todo::getbyaccname>;
using upsert_action = action_wrapper<"upsert"_n, &kv_todo::upsert>;
using del_action = action_wrapper<"del"_n, &kv_todo::del>;
private:
todo_table todo_entries{"todo"_n};
};
|
4b01283312e93318eabf5423c6a133faad2a2380
|
9d96429ce069961cf187d96643200ab0efb70fbe
|
/src/parser.cpp
|
1dd2b95d2cbc64ae8444bdca1890dc3d0a463911
|
[] |
no_license
|
KevinCybura/K-Lang
|
8dc554b987738bb4ed9e1c0e519ec0ad16d9a25d
|
1c64e51bc8a51711b5b7cc3edd6d5aa870edb56d
|
refs/heads/master
| 2020-04-25T00:13:41.855739
| 2019-02-28T10:53:09
| 2019-02-28T10:53:09
| 172,371,624
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,618
|
cpp
|
parser.cpp
|
//
// Created by kevin Cybura on 2019-02-20.
//
#include "parser.h"
#include <llvm/ADT/STLExtras.h>
#include <iostream>
#include <memory>
#include "AST.h"
#include "lexer.h"
#include "parser.h"
int getNextToken(CurTok& x) { return x.cur = gettok(x); }
std::unique_ptr<ExprAST> LogError(const char* Str) {
fprintf(stderr, "LogError: %s\n", Str);
abort();
return nullptr;
}
std::unique_ptr<PrototypeAST> LogErrorP(const char* Str) {
LogError(Str);
abort();
return nullptr;
}
std::unique_ptr<ExprAST> ParseNumberExpr(CurTok& x) {
auto Result = llvm::make_unique<NumberExprAST>(x.NumVal);
getNextToken(x);
return std::move(Result);
}
std::unique_ptr<ExprAST> ParseParenExpr(CurTok& x) {
getNextToken(x);
auto V = ParseExpression(x);
if (!V) return nullptr;
if (x.cur != ')') return LogError("expected ')'");
getNextToken(x);
return V;
}
std::unique_ptr<ExprAST> ParseIdentifierExpr(CurTok& x) {
std::string IdName = x.IdentifierStr;
getNextToken(x);
if (x.cur != ')') return llvm::make_unique<VariableExprAST>(IdName);
getNextToken(x);
std::vector<std::unique_ptr<ExprAST>> Args;
if (x.cur != ')') {
while (1) {
if (auto Arg = ParseExpression(x))
Args.push_back(std::move(Arg));
else
return nullptr;
if (x.cur == ')') break;
if (x.cur != ',')
return LogError("Expected ')' or ',' in argument list");
getNextToken(x);
}
}
getNextToken(x);
return llvm::make_unique<CallExprAST>(IdName, std::move(Args));
}
int GetTokPrecdence(CurTok& x) {
if (!isascii(x.cur)) return -1;
int TokPrec = BinopPrecedence[x.cur];
if (TokPrec < 0) return -1;
return TokPrec;
}
std::unique_ptr<ExprAST> ParsePrimary(CurTok& x) {
switch (x.cur) {
default:
return LogError("unknown token when expecting an expression");
case tok_identifier:
return ParseIdentifierExpr(x);
case tok_number:
return ParseNumberExpr(x);
case '(':
return ParseParenExpr(x);
}
}
std::unique_ptr<ExprAST> ParseExpression(CurTok& x) {
auto LHS = ParsePrimary(x);
if (!LHS) return nullptr;
return ParseBinOpRHS(0, std::move(LHS), x);
}
std::unique_ptr<ExprAST> ParseBinOpRHS(int ExprPrec,
std::unique_ptr<ExprAST> LHS,
CurTok& x) {
while (true) {
int TokPrec = GetTokPrecdence(x);
if (TokPrec < ExprPrec) return LHS;
int BinOp = x.cur;
getNextToken(x);
auto RHS = ParsePrimary(x);
if (!RHS) return nullptr;
int NextPrec = GetTokPrecdence(x);
if (TokPrec < NextPrec) {
RHS = ParseBinOpRHS(TokPrec + 1, std::move(RHS), x);
if (!RHS) return nullptr;
}
LHS = llvm::make_unique<BinaryExprAST>(BinOp, std::move(LHS),
std::move(RHS));
}
}
std::unique_ptr<PrototypeAST> ParseProtpye(CurTok& x) {
if (x.cur != tok_identifier)
return LogErrorP("Expected function name in protoype");
std::string FnName = x.IdentifierStr;
getNextToken(x);
if (x.cur != '(') return LogErrorP("Expected '('");
std::vector<std::string> ArgNames;
while (getNextToken(x) == tok_identifier)
ArgNames.push_back(x.IdentifierStr);
if (x.cur != ')') return LogErrorP("Expected ')' in prototype");
getNextToken(x);
return llvm::make_unique<PrototypeAST>(FnName, std::move(ArgNames));
}
std::unique_ptr<FunctionAST> ParseDefinition(CurTok& x) {
getNextToken(x);
auto Proto = ParseProtpye(x);
if (!Proto) return nullptr;
if (auto E = ParseExpression(x))
return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(E));
return nullptr;
}
std::unique_ptr<PrototypeAST> ParseExtern(CurTok& x) {
getNextToken(x);
return ParseProtpye(x);
}
std::unique_ptr<FunctionAST> ParseTopLevelExpr(CurTok& x) {
if (auto E = ParseExpression(x)) {
auto Proto =
llvm::make_unique<PrototypeAST>("", std::vector<std::string>());
return llvm::make_unique<FunctionAST>(std::move(Proto), std::move(E));
}
return nullptr;
}
void HandleTopLevelExpression(CurTok& x) {
if (ParseTopLevelExpr(x)) {
fprintf(stderr, "Parsed a top-level expr\n");
} else {
getNextToken(x);
}
}
void HandleExtern(CurTok& x) {
if (ParseExtern(x)) {
fprintf(stderr, "Parsed an extern\n");
} else {
getNextToken(x);
}
}
void HandleDefinition(CurTok& x) {
if (ParseDefinition(x)) {
fprintf(stderr, "Parsed a function definition. \n");
} else {
getNextToken(x);
}
}
void MainLoop(CurTok& x) {
while (true) {
// fprintf(stderr, "ready> ");
switch (x.cur) {
case tok_eof:
fprintf(stderr, "EOF\n");
return;
case ';':
fprintf(stderr, "handle ;\n");
getNextToken(x);
break;
case tok_def:
fprintf(stderr, "HandleDefinition\n");
HandleDefinition(x);
break;
case tok_extern:
fprintf(stderr, "HandleExtern\n");
HandleExtern(x);
break;
default:
fprintf(stderr, "HandleTopLevelExpression\n");
HandleTopLevelExpression(x);
break;
}
}
}
|
b0e970798e3de35fb7748d2f636469b5376a48d0
|
edfc92a7df8d8ce526324f8e21d603450bec6c23
|
/IPXACTmodels/bank.h
|
ffe620c7d6ea7504fea65d0703362ccc9a3e38ea
|
[] |
no_license
|
shrimpdede/kactus2
|
97be5f47918c99c7a3b3c4e17cf89f1cba267588
|
401b9dc80c2f4f3d081a639e498b08a50c89de71
|
refs/heads/master
| 2021-01-21T20:30:09.864195
| 2015-09-14T12:42:14
| 2015-09-14T12:42:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,450
|
h
|
bank.h
|
/*
*
* Created on: 29.7.2010
* Author: Antti Kamppi
*/
#ifndef BANK_H_
#define BANK_H_
#include "generaldeclarations.h"
#include "memorymapitem.h"
#include "memoryblockdata.h"
#include "ipxactmodels_global.h"
#include <QList>
#include <QString>
#include <QDomNode>
#include <QSharedPointer>
#include <QXmlStreamWriter>
class Choice;
class Parameter;
class VendorExtension;
/*! \brief Equals the spirit:bank element in IP-Xact specification
*
* Bank represents a collection of address blocks, banks or subspace maps.
* Bank is a generalization of a class MemoryMapItem which is the base class
* also for classes AddressBlock and SubspaceMap.
*/
class IPXACTMODELS_EXPORT Bank : public MemoryMapItem {
public:
/*! \brief The constructor
*
*\param memoryMapNode A reference to a QDomNode to parse the information
* from.
*
* Exception guarantee: basic
* \exception Parse_error Occurs when a mandatory element is missing in
* this class or one of it's member classes.
*/
Bank(QDomNode &memoryMapNode);
//! \brief Copy constructor
Bank(const Bank &other);
//! \brief Assignment operator
Bank &operator=(const Bank &other);
/*! \brief The destructor
*
*/
~Bank();
/*! \brief Clone this bank and return pointer to the copy.
*
* This is virtual function so it can be used to make a copy of classes that
* inherit MemoryMapItem.
*
* \return QSharedPointer<MemoryMapItem> Pointer to the cloned bank.
*/
virtual QSharedPointer<MemoryMapItem> clone() const;
/*! \brief Write the contents of the class using the writer.
*
* Uses the specified writer to write the class contents into file as valid
* IP-Xact.
*
* \param writer A reference to a QXmlStreamWrite instance that is used to
* write the document into file.
*/
virtual void write(QXmlStreamWriter& writer);
/*! \brief Check if the bank is in a valid state.
*
* \param componentChoices Choices in the containing component.
* \param errorList The list to add the possible error messages to.
* \param parentIdentifier String from parent to help to identify the location of the error.
*
* \return bool True if the state is valid and writing is possible.
*/
virtual bool isValid(QSharedPointer<QList<QSharedPointer<Choice> > > componentChoices,
QStringList& errorList,
const QString& parentIdentifier) const;
/*! \brief Check if the bank is in a valid state.
*
* \param componentChoices Choices in the containing component.
*
* \return bool True if the state is valid and writing is possible.
*/
virtual bool isValid(QSharedPointer<QList<QSharedPointer<Choice> > > componentChoices) const;
/*! \brief Get the items stored in the bank.
*
* \return QList containing pointers to the items. Pointers are base class
* MemoryMapItem type so that instances of Banks, SubspaceMaps and
* AddressBlocks can be saved in the same data structure.
*/
const QList<QSharedPointer<MemoryMapItem> >& getItems();
/*! \brief Set the items stored in the bank.
*
* Calling this function deletes the old items stored in the bank. To keep old
* values function getItems() must be called to add the old values to the
* QList given as a parameter for this function.
*
* \param items QList containing pointers to the items stored in the bank.
*/
void setItems(QList<QSharedPointer<MemoryMapItem> > &items);
/*! \brief Get the access information
*
* \return Accessibility of the data in the Bank
*/
General::Access getAccess() const;
/*! \brief Get the type of usage for the Bank
*
* \return Usage of the Bank
*/
General::Usage getUsage() const;
/*! \brief Get the volatile information
*
* \return BooleanValue value of the volatile element
*/
General::BooleanValue getVolatile() const;
/*! \brief Set the accessibility of the Bank
*
* \param access Enum holding the access type of the Bank
*/
void setAccess(General::Access access);
/*! \brief Set the type of usage for the Bank
*
* \param usage The enum containing the type of usage
*/
void setUsage(General::Usage usage);
/*! \brief Set the volatile setting
*
* \param volatileSetting boolean value if the Bank is volatile or
* not
*/
void setVolatile(const General::BooleanValue volatileSetting);
/*! \brief Get the parameters of the Bank
*
* \return QList containing the attributes
*/
const QList<QSharedPointer<Parameter> >& getParameters();
/*! \brief Set the parameters for the Bank
*
* Calling this function deletes the old parameters. If old values must
* be saved then function getParameters() must first be called to
* add the old values to the QList given as a parameter for this function.
*
* \param parameters QList containing the new parameters
*/
void setParameters(QList<QSharedPointer<Parameter> > ¶meters);
private:
/*!
* Contains the items stored in the Bank.
*/
QList<QSharedPointer<MemoryMapItem> > items_;
/*!
* OPTIONAL
* Collection of elements that contain further specification of Bank.
*/
QSharedPointer<MemoryBlockData> memoryBlockData_;
/*!
* OPTIONAL (spirit: vendorExtensions)
* Bank vendor extensions.
*/
QList<QSharedPointer<VendorExtension> > vendorExtensions_;
};
#endif /* BANK_H_ */
|
5fb4c5d5d89ecd8d004e8b46bcd8db46654cc723
|
2736637fd346f437ecfc85de8f733e454d45db9b
|
/BOJ/Silver/Silver_14888_연산자끼워넣기.cc
|
d6a7f350e73f5a562b5fa1f56d2c51042a0fdb66
|
[] |
no_license
|
Lowvoice-git/BOJCode
|
846db7fd4477d9f3f87993b63acaf044a47ff6f1
|
64f4ad7e998a2b93fd80ba963eeafbbf17a48a9e
|
refs/heads/master
| 2022-12-08T13:37:19.372180
| 2020-09-06T18:32:02
| 2020-09-06T18:32:02
| 206,231,699
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 952
|
cc
|
Silver_14888_연산자끼워넣기.cc
|
#include <iostream>
#include <limits.h>
bool visited[10];
int N, number[11], op[10], max = INT_MIN, min = INT_MAX;
void DFS(int B, int idx, int num, int lengh) {
int result = 0;
if (lengh == N - 1) {
if (num > max) max = num;
if (num < min) min = num;
}
else {
for (int i = 0; i < N - 1; i++) {
if (!visited[i]) {
switch (op[i]) {
case 1: result = num + number[idx]; break;
case 2: result = num - number[idx]; break;
case 3: result = num * number[idx]; break;
case 4: result = num / number[idx]; break;
default: break;
}
visited[i] = true;
DFS(i, idx + 1, result, lengh + 1);
}
}
}
visited[B] = false;
}
int main() {
int index = 0; std::cin >> N;
for (int i = 0; i < N; i++)
std::cin >> number[i];
for (int i = 0; i < 4; i++) {
int count; std::cin >> count;
for (int j = 0; j < count; j++)
op[index++] = i + 1;
}
DFS(0, 1, number[0], 0);
std::cout << max << '\n' << min;
}
|
5716af5a672f1e46427ada077ae280ddda9bd8d0
|
d90a87759b0d153ec12b0f284ee72fcdd8386743
|
/libconfluo/confluo/parser/expression_compiler.h
|
af67ce5464fb5f69053fb53e0f6059e6f2f3ac9e
|
[
"Apache-2.0"
] |
permissive
|
ucbrise/confluo
|
e2e152e6d3de7808280482a7ee14ea0a33a1b6f5
|
e9b8621e99f56b1adf5675c4296c006d89e6e582
|
refs/heads/single-machine
| 2023-03-09T02:08:28.919233
| 2022-02-11T19:33:22
| 2022-02-11T19:33:22
| 50,422,569
| 1,418
| 212
|
Apache-2.0
| 2022-05-20T20:55:43
| 2016-01-26T10:49:47
|
C++
|
UTF-8
|
C++
| false
| false
| 10,994
|
h
|
expression_compiler.h
|
#ifndef CONFLUO_PARSER_EXPRESSION_COMPILER_H_
#define CONFLUO_PARSER_EXPRESSION_COMPILER_H_
#include "schema/schema.h"
#include "schema/schema_snapshot.h"
#include "expression_parser.h"
namespace confluo {
namespace parser {
namespace spirit = boost::spirit;
/**
* Compiled predicate class. Contains operations for extracting data
* from the expression.
*/
struct compiled_predicate {
/**
* Constructs a predicate from the specified fields
*
* @param attr The field of the predicate
* @param op The operator of the predicate
* @param value The value of the predicate
* @param s The schema which contains the attribute
*/
compiled_predicate(const std::string &attr, int op, const std::string &value, const schema_t &s);
/**
* Gets the field name
*
* @return A string containing the field name
*/
std::string const &field_name() const;
/**
* Gets the index of the field
*
* @return The index of the field
*/
uint32_t field_idx() const;
/**
* Gets the relational operator
*
* @return The identifier for the relational operator
*/
reational_op_id op() const;
/**
* Gets the immutable value for the predicate
*
* @return The immutable value in the compiled predicate
*/
immutable_value const &value() const;
/**
* Performs the relational operation on the value and the specified
* record
*
* @param r The record used in the relational operator
*
* @return True if the relational operation is true, false otherwise
*/
bool test(const record_t &r) const;
/**
* Performs the relational operation on the value and the specified
* schema snapshot and data
*
* @param snap The schema snapshot to get the data from
* @param data The data used for the comparison
*
* @return True if the relational operation is true, false otherwise
*/
bool test(const schema_snapshot &snap, void *data) const;
/**
* Gets a string representation of the compiled predicate
*
* @return A string containing the contents of the predicate
*/
std::string to_string() const;
/**
* The less than operator that compares this compiled predicate to
* another compiled predicate
*
* @param other The other compiled predicate used for comparison
*
* @return True if this compiled predicate is less than the other
* compiled predicate, false otherwise
*/
bool operator<(const compiled_predicate &other) const;
private:
std::string field_name_;
uint32_t field_idx_;
reational_op_id op_;
mutable_value val_;
};
/**
* A set of compiled predicates. Manages a list of predicate expressions.
*/
struct compiled_minterm : public std::set<compiled_predicate> {
/**
* Adds a compiled predicate to this compiled minterm
*
* @param p The predicate to add
*/
void add(const compiled_predicate &p);
/**
* Adds a r value compiled predicate to the compiled minterm
*
* @param p The r value predicate to add to the minterm
*/
void add(compiled_predicate &&p);
/**
* Tests every predicate in the set against the record
*
* @param r The record to test the predicate on
*
* @return True if all of the predicates tests are true, false otherwise
*/
bool test(const record_t &r) const;
/**
* Tests every predicate against the data in the schema snapshot
*
* @param snap The schema snapshot to look at
* @param data The data the predicates are tested against
*
* @return True if all of the predicates tests are true, false otherwise
*/
bool test(const schema_snapshot &snap, void *data) const;
/**
* Gets a string representation of the compiled minterm
*
* @return A string with the contents of the compiled minterm
*/
std::string to_string() const;
/**
* Performs a less than comparison with another compiled minterm
*
* @param other The other compiled minterm to perform a comparison with
*
* @return True if this compiled minterm is less than the other compiled
* minterm, false otherwise
*/
bool operator<(const compiled_minterm &other) const;
};
/**
* A set of compiled minterms. Manages a grouping of minterms
*/
struct compiled_expression : public std::set<compiled_minterm> {
/**
* Tests every compiled minterm in the set against a record
*
* @param r The record to test against
*
* @return True if every compiled minterm test is true, false otherwise
*/
bool test(const record_t &r) const;
/**
* Tests every compiled minterm against the data from the schema snapshot
*
* @param snap The snapshot of the schema
* @param data The data that is tested
*
* @return True if the all of the compiled minterm tests are true, false
* otherwise
*/
bool test(const schema_snapshot &snap, void *data) const;
/**
* Gets a string representation of the compiled expression
*
* @return The contents of the compiled expression in string form
*/
std::string to_string() const;
};
/**
* Conjunction operation
*/
class utree_expand_conjunction {
public:
/** The result type */
typedef compiled_expression result_type;
/**
* Expands the conjunction
*
* @param m The compiled minterm
* @param schema The schema for the monolog
*/
utree_expand_conjunction(const compiled_minterm &m, const schema_t &schema);
/**
* Operation for all types exception functions
* @tparam T The type
* @throw parse_exception Unrecognized type
* @return The result
*/
template<typename T>
result_type operator()(T) const {
throw parse_exception(std::string("Unrecognized type ") + typeid(T).name());
}
/**
* Operation for function type
* @throw parse_exception Functions are not supported
* @return The result
*/
result_type operator()(spirit::function_base const &) const;
/**
* Operation for an iterator range
*
* @tparam Iterator type
* @param range The iterator range
*
* @return The result
*/
template<typename Iterator>
result_type operator()(boost::iterator_range<Iterator> const &range) const {
typedef typename boost::iterator_range<Iterator>::const_iterator iterator;
result_type e;
iterator i = range.begin();
int op = spirit::utree::visit(*i, utree_to_op());
switch (op) {
case reational_op_id::EQ:
case reational_op_id::NEQ:
case reational_op_id::LT:
case reational_op_id::GT:
case reational_op_id::LE:
case reational_op_id::GE: {
compiled_minterm right = m_;
std::string attr = spirit::utree::visit(*(++i), utree_to_string());
std::string value = spirit::utree::visit(*(++i), utree_to_string());
right.add(compiled_predicate(attr, op, value, schema_));
e.insert(right);
break;
}
case and_or::OR: {
compiled_expression left = spirit::utree::visit(*(++i), *this);
compiled_expression right = spirit::utree::visit(*(++i), *this);
std::set_union(left.begin(), left.end(), right.begin(), right.end(),
std::inserter(e, e.end()));
break;
}
case and_or::AND: {
compiled_expression lor = spirit::utree::visit(*(++i), *this);
auto r = *(++i);
for (auto &lor_m : lor) {
result_type tmp = spirit::utree::visit(
r, utree_expand_conjunction(lor_m, schema_));
std::set_union(e.begin(), e.end(), tmp.begin(), tmp.end(),
std::inserter(e, e.end()));
}
break;
}
default: {
throw parse_exception("Unexpected op:" + std::to_string(op));
}
}
return e;
}
private:
const compiled_minterm &m_;
const schema_t &schema_;
};
/**
* Tree Compiled expression class.
* Manages operations performed on expressions
*/
class utree_compile_expression {
public:
/** The evaluated compiled expression */
typedef compiled_expression result_type;
/**
* Constructs a compiled expression from the given schema
*
* @param schema The schema used to initialize the compiled expression
*/
utree_compile_expression(const schema_t &schema);
/**
* () operator that evaluates the compiled expression
* @tparam T The type operator is called on
* @throw parse_exception
* @return The result of the operator
*/
template<typename T>
result_type operator()(T) const {
throw parse_exception(std::string("Unrecognized type ") + typeid(T).name());
}
/**
* () operator that evaluates the compiled expression
* @throw parse_exception
* @return The result of the operator
*/
result_type operator()(spirit::function_base const &) const;
/**
* () operator that evaluates the compiled expression
*
* @tparam Iterator
* @param range The range of tokens to evaluate
*
* @return The result of evaluating the expression
*/
template<typename Iterator>
result_type operator()(boost::iterator_range<Iterator> const &range) const {
typedef typename boost::iterator_range<Iterator>::const_iterator iterator;
result_type e;
iterator i = range.begin();
int op = spirit::utree::visit(*i, utree_to_op());
switch (op) {
case reational_op_id::EQ:
case reational_op_id::NEQ:
case reational_op_id::LT:
case reational_op_id::GT:
case reational_op_id::LE:
case reational_op_id::GE: {
compiled_minterm m;
std::string attr = spirit::utree::visit(*(++i), utree_to_string());
std::string value = spirit::utree::visit(*(++i), utree_to_string());
m.add(compiled_predicate(attr, op, value, schema_));
e.insert(m);
break;
}
case and_or::OR: {
result_type left = spirit::utree::visit(*(++i), *this);
result_type right = spirit::utree::visit(*(++i), *this);
std::set_union(left.begin(), left.end(), right.begin(), right.end(),
std::inserter(e, e.end()));
break;
}
case and_or::AND: {
result_type left = spirit::utree::visit(*(++i), *this);
auto r = *(++i);
for (auto &m : left) {
result_type tmp = spirit::utree::visit(
r, utree_expand_conjunction(m, schema_));
std::set_union(e.begin(), e.end(), tmp.begin(), tmp.end(),
std::inserter(e, e.end()));
}
break;
}
default: {
throw parse_exception("Unexpected op:" + std::to_string(op));
}
}
return e;
}
private:
const schema_t &schema_;
};
/**
* Recursively gets the compiled expression from the tree and schema
*
* @param e The utree containing the contents of the expression
* @param schema The schema to create the compiled expression from
*
* @return Compiled expression containing the result of evaluation
*/
compiled_expression compile_expression(const spirit::utree &e, const schema_t &schema);
}
}
#endif /* CONFLUO_PARSER_EXPRESSION_COMPILER_H_ */
|
cb7a5646f412dcdb12951c776acd1748d7b94c4f
|
0fb15365030fdaea012e0fb2e40349620be974f8
|
/loops/print_nat_loops.cpp
|
9548d8cfaa3730c3b096b5dd42441caca60ed045
|
[] |
no_license
|
baziotis/compiler-optimization
|
6146ba0fab552a955acc2dcc0db2ebe89e178ee3
|
dc5a87a1d643830722adbc8de6331c4978d323c5
|
refs/heads/master
| 2023-04-14T15:24:38.277505
| 2021-04-20T17:48:35
| 2021-04-20T17:48:35
| 261,909,377
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 315
|
cpp
|
print_nat_loops.cpp
|
#include <stdio.h>
#include "../common/buf.h"
#include "../common/cfg.h"
#include "../common/parser_ir.h"
#include "../common/stefanos.h"
#include "loop_info.h"
int main(int argc, char **argv) {
assert(argc == 2);
CFG cfg = parse_procedure(argv[1], NULL);
LoopInfo li(cfg);
li.print();
cfg.destruct();
}
|
c886023e265378a067bee425d94e5edbc3039f4f
|
9bce5ae2f0ebbfcbc378452acc0ff615cb9d751b
|
/gpmap/cpp_Script/Cell.cpp
|
761fff4af83b6bb1227852398f2eb70835d2464b
|
[] |
no_license
|
mjaklitsch/gpmap_CPP_and_Processing
|
2cde5d3a5f33e3f9f12817301afa3b79086c5a1f
|
ff4475a71a7e61aaea061101199739fb3c238812
|
refs/heads/master
| 2023-04-22T17:58:45.296474
| 2021-05-03T07:03:50
| 2021-05-03T07:03:50
| 282,727,744
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,276
|
cpp
|
Cell.cpp
|
#include "Cell.hpp"
#include "GenerateGene.hpp"
#include "GlobalVariables.hpp"
#include <iostream>
#include <string>
#include <cmath>
using namespace timer;
Cell::Cell(){
}
Cell::Cell(Gene tempGene, int tempIndex){
gene = tempGene;
index = tempIndex;
xPos = 0;
yPos = 0;
diameter = 0;
radius = 0;
xSpeed = 0;
ySpeed = 0;
growthRate = 0;
doneMoving = false;
doneGrowing = false;
connectedToSensor = false;
}
Cell::Cell(std::string cellType, int tempIndex) {
gene = returnRandomNewGenotype(cellType);
index = tempIndex;
xPos = 0;
yPos = 0;
diameter = 0;
radius = 0;
xSpeed = 0;
ySpeed = 0;
growthRate = 0;
doneMoving = false;
doneGrowing = false;
connectedToSensor = false;
}
bool Cell::isMotor() {
const std::string motors[] = {"LM", "RM"};
return std::find(std::begin(motors), std::end(motors),
getCellType()) != std::end(motors);
}
bool Cell::isSensor() {
const std::string sensors[] = {"R", "P"};
return std::find(std::begin(sensors), std::end(sensors),
getCellType()) != std::end(sensors);
}
bool Cell::isNeuron() {
return (getCellType() == "N");
}
void Cell::setCellSpeedAndGrowth() {
if(growthRate == 0 && timer::currentTick > gene.getGrowthDelay()) {
growthRate = (gene.getGrowthRate() / timer::actionSpread);
}
if (timer::currentTick > gene.getMovementDelay()) {
float speed = (gene.getSpeed() / timer::actionSpread);
// set x and y components of speed
xSpeed = speed * cos(gene.getTheta());
ySpeed = speed * sin(gene.getTheta());
}
}
void Cell::moveAndMorphCell() {
if (!doneMoving && (timer::currentTick - gene.getMovementDelay() < gene.getMovementDuration())) {
xPos += xSpeed;
yPos -= ySpeed;
} else {
doneMoving = true;
}
if (!doneGrowing && (timer::currentTick - gene.getGrowthDelay() < gene.getGrowthDuration())) {
diameter += growthRate;
radius = diameter/2;
} else {
doneGrowing = true;
}
}
// Cell Sub-Gene getters/printers
void Cell::printGenes() {printGenotype(gene);}
std::string Cell::getCellType() {return gene.getCellType();}
Gene Cell::getGene() {return gene;}
float Cell::getTheta() {return gene.getTheta();}
// Cell getters
int Cell::getIndex() {return index;}
float Cell::getXPos() {return xPos;}
float Cell::getYPos() {return yPos;}
float Cell::getDiameter() {return diameter;}
float Cell::getRadius() {return radius;}
float Cell::getXSpeed() {return xSpeed;}
float Cell::getYSpeed() {return ySpeed;}
float Cell::getGrowthRate( ){return growthRate;}
bool Cell::getDoneMoving() {return doneMoving;}
bool Cell::getDoneGrowing() {return doneGrowing;}
bool Cell::getConnectedToSensor() {return connectedToSensor;}
bool Cell::isConnectedToIndex(int index){
// connectedTo is a private Cell::vector<int>
// if index is found in vector, return true, else false
return (std::find(connectedTo.begin(), connectedTo.end(), index) != connectedTo.end());
}
void Cell::setIndex(int i) {index = i;}
void Cell::setGene(Gene g) {gene = g;}
void Cell::setXPos(float x) {xPos = x;}
void Cell::setYPos(float y) {yPos = y;}
void Cell::setDiameter(float d) {diameter = d;}
void Cell::setRadius(float r) {radius = r;}
void Cell::setXSpeed(float dx) {xSpeed = dx;}
void Cell::setYSpeed(float dy) {ySpeed = dy;}
void Cell::setGrowthRate(float ds) {growthRate = ds;}
void Cell::setDoneMoving(bool dmoving) {doneMoving = dmoving;}
void Cell::setDoneGrowing(bool dgrowing) {doneGrowing = dgrowing;}
void Cell::setConnectedToSensor(bool connected) {connectedToSensor = connected;}
void Cell::addConnection(int cellIndex) {connectedTo.push_back(cellIndex);}
void Cell::printCell(int index){
printf("Gene G%d = Gene(\"%s\", ", index,gene.getCellType().c_str());
printf("%f, ", gene.getTheta());
printf("%f, ", gene.getGrowthDelay());
printf("%f, ", gene.getGrowthRate());
printf("%f, ", gene.getGrowthDuration());
printf("%f, ", gene.getSpeed());
printf("%f, ", gene.getMovementDelay());
printf("%f);\n", gene.getMovementDuration());
printf("Cell C%d = Cell(G%d, %d);\n",index, index, index);
}
|
c053d76bab98cb00d0f2612834c7fe5a224ba36c
|
e4dd473e43ddb9ce4e891fd534e113ccf52c6fac
|
/main.cpp
|
50607e49f7c2d7b96ceee70da36e7f79a7632c14
|
[] |
no_license
|
StMichaelsCodingClass/tag
|
a55f5e6d783f183374195dfb9152bf8842d3e3dd
|
1dbbceaaa9f6ceeb043d78e80f871722de1676f2
|
refs/heads/master
| 2021-01-19T07:47:09.471712
| 2015-10-30T16:45:54
| 2015-10-30T16:45:54
| 34,743,669
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 281
|
cpp
|
main.cpp
|
#include <iostream>
#include "area.h"
#include "character.h"
#include "interpret.h"
using namespace std;
int main(){
Area current=getForest();
Character player=getPlayer();
for(;;){
current.describe();
interpret(current, player);
}
return 0;
}
|
3aa3fefe3459f296ca2965a393a5a60021b1764c
|
2cf314b8237fc6a77b7f1a096f17a679179b0057
|
/internal/core/src/index/IndexFactory.h
|
ec1c9cfdf8786942263653874b53648e301b8fde
|
[
"Apache-2.0"
] |
permissive
|
milvus-io/milvus
|
a02d732cf746effec1ea723f9e4d17856843f8a8
|
0530fd80c91dc5b200606c00214c12bf8dd17cb4
|
refs/heads/master
| 2023-09-04T06:28:57.681855
| 2023-09-04T02:01:04
| 2023-09-04T02:01:04
| 208,728,772
| 23,316
| 2,917
|
Apache-2.0
| 2023-09-14T15:06:12
| 2019-09-16T06:43:43
|
Go
|
UTF-8
|
C++
| false
| false
| 2,211
|
h
|
IndexFactory.h
|
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <string>
#include <mutex>
#include <shared_mutex>
#include "common/type_c.h"
#include "index/Index.h"
#include "index/ScalarIndex.h"
#include "index/VectorIndex.h"
#include "index/IndexInfo.h"
#include "storage/Types.h"
#include "storage/FileManager.h"
namespace milvus::index {
class IndexFactory {
public:
IndexFactory() = default;
IndexFactory(const IndexFactory&) = delete;
IndexFactory
operator=(const IndexFactory&) = delete;
public:
static IndexFactory&
GetInstance() {
// thread-safe enough after c++ 11
static IndexFactory instance;
return instance;
}
IndexBasePtr
CreateIndex(const CreateIndexInfo& create_index_info,
storage::FileManagerImplPtr file_manager);
IndexBasePtr
CreateVectorIndex(const CreateIndexInfo& create_index_info,
storage::FileManagerImplPtr file_manager);
IndexBasePtr
CreateScalarIndex(const CreateIndexInfo& create_index_info,
storage::FileManagerImplPtr file_manager = nullptr);
// IndexBasePtr
// CreateIndex(DataType dtype, const IndexType& index_type);
private:
template <typename T>
ScalarIndexPtr<T>
CreateScalarIndex(const IndexType& index_type,
storage::FileManagerImplPtr file_manager = nullptr);
};
} // namespace milvus::index
#include "index/IndexFactory-inl.h"
|
3b1f1009eeb6631d9eb46c88fe702758978bfc7e
|
6ccb723686cf42b2ec8a9a080e0aefeb4e24319e
|
/Szachownica4.cpp
|
6dcdf6e04a745107ac6804e0a24b0ebdd1222403
|
[] |
no_license
|
michczur/Rozne_drobiazgi
|
e7a50b6ffb08721e1a0ab36771edfe95fdd59034
|
b869a0207a20373fd3eda326d2704a83262a869f
|
refs/heads/master
| 2020-04-16T07:54:21.406667
| 2019-01-12T15:38:40
| 2019-01-12T15:38:40
| 165,403,325
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 544
|
cpp
|
Szachownica4.cpp
|
#include <iostream>
int main()
{
int szachownica [8][8];
for (int i=0; i<8; ++i) //uzupełnianie tablicy
{
for (int j=1; j<8; j=j+2)
{
szachownica[i][j]=1;
}
for (int j=0; j<8; j=j+2)
{
szachownica[i][j]=0;
}
}
for (int i=0; i<8; ++i) // wypisywanie tablicy
{
for (int j=0;j<7; ++j)
{
std::cout << szachownica[i][j] << ' ';
}
std::cout << szachownica[i][7] << '\n';
}
return 0;
}
|
c238a047cc7a3db2a00000782c13b0c21f1ac5ad
|
885d0033af38c4164ef499c091a972d637c2fa54
|
/src/tools.cpp
|
76eeeb778076489dd6b8395e1f7fd52e3bbffa43
|
[
"MIT"
] |
permissive
|
iabdelmo/Extended-Kalman-Filter
|
85bdf7277cdfc02f7314fad89c5cb64835267658
|
a2bbad8d5de7425e894e8bda9f9415f9ad822139
|
refs/heads/master
| 2020-03-29T12:53:04.819952
| 2018-09-22T23:28:58
| 2018-09-22T23:28:58
| 149,925,658
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,723
|
cpp
|
tools.cpp
|
#include <iostream>
#include "tools.h"
using Eigen::VectorXd;
using Eigen::MatrixXd;
using std::vector;
Tools::Tools() {}
Tools::~Tools() {}
VectorXd Tools::CalculateRMSE(const vector<VectorXd> &estimations,
const vector<VectorXd> &ground_truth) {
/**
TODO:
* Calculate the RMSE here.
*/
VectorXd rmse(4);
rmse << 0,0,0,0;
// check the validity of the inputs:
if((estimations.empty() != true) && (estimations.size() == ground_truth.size()))
{
//accumulate squared residuals
for(int i=0; i < estimations.size(); ++i){
VectorXd residual = estimations[i] - ground_truth[i];
residual = residual.array() * residual.array();
rmse += residual;
}
//calculate the mean
rmse = rmse.array()* (1.0f/estimations.size());
//calculate the squared root
rmse = rmse.array().sqrt();
}
//return the result
return rmse;
}
MatrixXd Tools::CalculateJacobian(const VectorXd& x_state) {
/**
TODO:
* Calculate a Jacobian here.
*/
MatrixXd Hj(3,4);
//recover state parameters
float px = x_state(0);
float py = x_state(1);
float vx = x_state(2);
float vy = x_state(3);
//check division by zero
if((px == 0) || (py == 0))
{
cout<<"Error dividing by zero"<<std::endl;
}
else
{
Hj(0,0) = px/(sqrt(pow(px,2) + pow(py,2)));
Hj(0,1) = py/(sqrt(pow(px,2) + pow(py,2)));
Hj(0,2) = 0;
Hj(0,3) = 0;
Hj(1,0) = (py/(pow(px,2) + pow(py,2))) * -1;
Hj(1,1) = px/(pow(px,2) + pow(py,2));
Hj(1,2) = 0;
Hj(1,3) = 0;
float temp = ((vx * py) - (vy * px))/pow((pow(px,2)+ pow(py,2)),(3/2));
Hj(2,0) = temp * py;
Hj(2,1) = temp * px;
Hj(2,2) = Hj(0,0);
Hj(2,3) = Hj(0,1);
}
//compute the Jacobian matrix
return Hj;
}
|
d86b0d9d77181353a269b1183b4acc30391f6008
|
7bd533a635b327832e46b4491fa91f0dd4c0a9e1
|
/dp/96_unique_binary_serch_trees.cpp
|
d35dbd19951d7001c9c41d095c6efa3ae701e288
|
[] |
no_license
|
zegzag/DSA
|
21228ffc05200de634a52d551300dcff941d9661
|
3420e2fb2672c01125cab39cba799fc5eb2c7117
|
refs/heads/master
| 2021-06-19T23:34:43.252009
| 2021-04-07T00:23:50
| 2021-04-07T00:23:50
| 183,879,891
| 0
| 0
| null | 2021-04-07T00:23:51
| 2019-04-28T08:30:52
|
C++
|
UTF-8
|
C++
| false
| false
| 557
|
cpp
|
96_unique_binary_serch_trees.cpp
|
#include<cstdio>
int numTrees(int n) {
if(n==0)
return 0;
int *num = new int[n+1];
num[0]=0;
num[1]=1;
for(int i=2;i<n+1;i++){
num[i]=0;
for(int j=0;j<i;j++){
if(num[j]==0)
num[i]+=num[i-j-1];
else if(num[i-j-1]==0)
num[i]+=num[j];
else
num[i]+=num[j]*num[i-j-1];
}
}
return num[n];
}
int main(){
int a=0;
scanf("%d",&a);
int b = numTrees(a);
printf("%d", b);
scanf("%d", &a);
return 0;
}
|
8011ea88c5b893ae42a48e3cbcdba8ead1a93d64
|
ca2125d3a3a4aa7167326a09ff3adae4a03c90fe
|
/Graphics/GraphicsEngineD3DBase/src/DXGITypeConversions.cpp
|
a84bcca543efb6382ccbbd685343fc06f9648db0
|
[
"Apache-2.0",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-public-domain",
"LicenseRef-scancode-nvidia-2002",
"BSD-2-Clause"
] |
permissive
|
DiligentGraphics/DiligentCore
|
9e124fee53bda1b280b3aa8c11ef1d3dc577d630
|
2ebd6cd1b3221a50d7f11f77ac51023a2b33697f
|
refs/heads/master
| 2023-08-28T14:13:18.861391
| 2023-08-24T00:52:40
| 2023-08-24T00:52:40
| 44,292,712
| 545
| 180
|
Apache-2.0
| 2023-09-11T14:44:45
| 2015-10-15T03:56:34
|
C++
|
UTF-8
|
C++
| false
| false
| 20,999
|
cpp
|
DXGITypeConversions.cpp
|
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* 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.
*
* In no event and under no legal theory, whether in tort (including negligence),
* contract, or otherwise, unless required by applicable law (such as deliberate
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
* liable for any damages, including any direct, indirect, special, incidental,
* or consequential damages of any character arising as a result of this License or
* out of the use or inability to use the software (including but not limited to damages
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/
#include "DXGITypeConversions.hpp"
#include "BasicTypes.h"
#include "DebugUtilities.hpp"
#include "GraphicsAccessories.hpp"
namespace Diligent
{
DXGI_FORMAT TypeToDXGI_Format(VALUE_TYPE ValType, Uint32 NumComponents, Bool bIsNormalized)
{
switch (ValType)
{
case VT_FLOAT16:
{
VERIFY(!bIsNormalized, "Floating point formats cannot be normalized");
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R16_FLOAT;
case 2: return DXGI_FORMAT_R16G16_FLOAT;
case 4: return DXGI_FORMAT_R16G16B16A16_FLOAT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
case VT_FLOAT32:
{
VERIFY(!bIsNormalized, "Floating point formats cannot be normalized");
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R32_FLOAT;
case 2: return DXGI_FORMAT_R32G32_FLOAT;
case 3: return DXGI_FORMAT_R32G32B32_FLOAT;
case 4: return DXGI_FORMAT_R32G32B32A32_FLOAT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
case VT_INT32:
{
VERIFY(!bIsNormalized, "32-bit UNORM formats are not supported. Use R32_FLOAT instead");
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R32_SINT;
case 2: return DXGI_FORMAT_R32G32_SINT;
case 3: return DXGI_FORMAT_R32G32B32_SINT;
case 4: return DXGI_FORMAT_R32G32B32A32_SINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
case VT_UINT32:
{
VERIFY(!bIsNormalized, "32-bit UNORM formats are not supported. Use R32_FLOAT instead");
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R32_UINT;
case 2: return DXGI_FORMAT_R32G32_UINT;
case 3: return DXGI_FORMAT_R32G32B32_UINT;
case 4: return DXGI_FORMAT_R32G32B32A32_UINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
case VT_INT16:
{
if (bIsNormalized)
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R16_SNORM;
case 2: return DXGI_FORMAT_R16G16_SNORM;
case 4: return DXGI_FORMAT_R16G16B16A16_SNORM;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
else
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R16_SINT;
case 2: return DXGI_FORMAT_R16G16_SINT;
case 4: return DXGI_FORMAT_R16G16B16A16_SINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
}
case VT_UINT16:
{
if (bIsNormalized)
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R16_UNORM;
case 2: return DXGI_FORMAT_R16G16_UNORM;
case 4: return DXGI_FORMAT_R16G16B16A16_UNORM;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
else
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R16_UINT;
case 2: return DXGI_FORMAT_R16G16_UINT;
case 4: return DXGI_FORMAT_R16G16B16A16_UINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
}
case VT_INT8:
{
if (bIsNormalized)
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R8_SNORM;
case 2: return DXGI_FORMAT_R8G8_SNORM;
case 4: return DXGI_FORMAT_R8G8B8A8_SNORM;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
else
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R8_SINT;
case 2: return DXGI_FORMAT_R8G8_SINT;
case 4: return DXGI_FORMAT_R8G8B8A8_SINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
}
case VT_UINT8:
{
if (bIsNormalized)
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R8_UNORM;
case 2: return DXGI_FORMAT_R8G8_UNORM;
case 4: return DXGI_FORMAT_R8G8B8A8_UNORM;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
else
{
switch (NumComponents)
{
case 1: return DXGI_FORMAT_R8_UINT;
case 2: return DXGI_FORMAT_R8G8_UINT;
case 4: return DXGI_FORMAT_R8G8B8A8_UINT;
default: UNEXPECTED("Unsupported number of components"); return DXGI_FORMAT_UNKNOWN;
}
}
}
default: UNEXPECTED("Unsupported format"); return DXGI_FORMAT_UNKNOWN;
}
}
DXGI_FORMAT CorrectDXGIFormat(DXGI_FORMAT DXGIFormat, Uint32 BindFlags)
{
if ((BindFlags & BIND_DEPTH_STENCIL) && (BindFlags != BIND_DEPTH_STENCIL))
{
switch (DXGIFormat)
{
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_R32_FLOAT:
case DXGI_FORMAT_D32_FLOAT:
DXGIFormat = DXGI_FORMAT_R32_TYPELESS;
break;
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
DXGIFormat = DXGI_FORMAT_R24G8_TYPELESS;
break;
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R16_UNORM:
case DXGI_FORMAT_D16_UNORM:
DXGIFormat = DXGI_FORMAT_R16_TYPELESS;
break;
case DXGI_FORMAT_R32G8X24_TYPELESS:
case DXGI_FORMAT_D32_FLOAT_S8X24_UINT:
case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS:
case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT:
DXGIFormat = DXGI_FORMAT_R32G8X24_TYPELESS;
break;
default:
UNEXPECTED("Unsupported depth-stencil format");
break;
}
}
if (BindFlags == BIND_DEPTH_STENCIL)
{
switch (DXGIFormat)
{
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_R32_FLOAT:
DXGIFormat = DXGI_FORMAT_D32_FLOAT;
break;
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_R24_UNORM_X8_TYPELESS:
case DXGI_FORMAT_X24_TYPELESS_G8_UINT:
DXGIFormat = DXGI_FORMAT_D24_UNORM_S8_UINT;
break;
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R16_UNORM:
DXGIFormat = DXGI_FORMAT_D16_UNORM;
break;
}
}
if (BindFlags == BIND_SHADER_RESOURCE || BindFlags == BIND_UNORDERED_ACCESS)
{
switch (DXGIFormat)
{
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_D32_FLOAT:
DXGIFormat = DXGI_FORMAT_R32_FLOAT;
break;
case DXGI_FORMAT_R24G8_TYPELESS:
case DXGI_FORMAT_D24_UNORM_S8_UINT:
DXGIFormat = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
break;
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_D16_UNORM:
DXGIFormat = DXGI_FORMAT_R16_UNORM;
break;
}
}
return DXGIFormat;
}
DXGI_FORMAT TexFormatToDXGI_Format(TEXTURE_FORMAT TexFormat, Uint32 BindFlags)
{
static Bool bFormatMapInitialized = false;
static DXGI_FORMAT FmtToDXGIFmtMap[TEX_FORMAT_NUM_FORMATS] = {DXGI_FORMAT_UNKNOWN};
if (!bFormatMapInitialized)
{
// clang-format off
FmtToDXGIFmtMap[TEX_FORMAT_UNKNOWN] = DXGI_FORMAT_UNKNOWN;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA32_TYPELESS] = DXGI_FORMAT_R32G32B32A32_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA32_FLOAT] = DXGI_FORMAT_R32G32B32A32_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA32_UINT] = DXGI_FORMAT_R32G32B32A32_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA32_SINT] = DXGI_FORMAT_R32G32B32A32_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGB32_TYPELESS] = DXGI_FORMAT_R32G32B32_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RGB32_FLOAT] = DXGI_FORMAT_R32G32B32_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RGB32_UINT] = DXGI_FORMAT_R32G32B32_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGB32_SINT] = DXGI_FORMAT_R32G32B32_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_TYPELESS] = DXGI_FORMAT_R16G16B16A16_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_FLOAT] = DXGI_FORMAT_R16G16B16A16_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_UNORM] = DXGI_FORMAT_R16G16B16A16_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_UINT] = DXGI_FORMAT_R16G16B16A16_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_SNORM] = DXGI_FORMAT_R16G16B16A16_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA16_SINT] = DXGI_FORMAT_R16G16B16A16_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG32_TYPELESS] = DXGI_FORMAT_R32G32_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RG32_FLOAT] = DXGI_FORMAT_R32G32_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RG32_UINT] = DXGI_FORMAT_R32G32_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG32_SINT] = DXGI_FORMAT_R32G32_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_R32G8X24_TYPELESS] = DXGI_FORMAT_R32G8X24_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_D32_FLOAT_S8X24_UINT] = DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R32_FLOAT_X8X24_TYPELESS]= DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_X32_TYPELESS_G8X24_UINT]= DXGI_FORMAT_X32_TYPELESS_G8X24_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGB10A2_TYPELESS] = DXGI_FORMAT_R10G10B10A2_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RGB10A2_UNORM] = DXGI_FORMAT_R10G10B10A2_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RGB10A2_UINT] = DXGI_FORMAT_R10G10B10A2_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R11G11B10_FLOAT] = DXGI_FORMAT_R11G11B10_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_TYPELESS] = DXGI_FORMAT_R8G8B8A8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_UNORM] = DXGI_FORMAT_R8G8B8A8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_UNORM_SRGB] = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_UINT] = DXGI_FORMAT_R8G8B8A8_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_SNORM] = DXGI_FORMAT_R8G8B8A8_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RGBA8_SINT] = DXGI_FORMAT_R8G8B8A8_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_TYPELESS] = DXGI_FORMAT_R16G16_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_FLOAT] = DXGI_FORMAT_R16G16_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_UNORM] = DXGI_FORMAT_R16G16_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_UINT] = DXGI_FORMAT_R16G16_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_SNORM] = DXGI_FORMAT_R16G16_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RG16_SINT] = DXGI_FORMAT_R16G16_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_R32_TYPELESS] = DXGI_FORMAT_R32_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_D32_FLOAT] = DXGI_FORMAT_D32_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_R32_FLOAT] = DXGI_FORMAT_R32_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_R32_UINT] = DXGI_FORMAT_R32_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R32_SINT] = DXGI_FORMAT_R32_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_R24G8_TYPELESS] = DXGI_FORMAT_R24G8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_D24_UNORM_S8_UINT] = DXGI_FORMAT_D24_UNORM_S8_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R24_UNORM_X8_TYPELESS] = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_X24_TYPELESS_G8_UINT] = DXGI_FORMAT_X24_TYPELESS_G8_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_TYPELESS] = DXGI_FORMAT_R8G8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_UNORM] = DXGI_FORMAT_R8G8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_UINT] = DXGI_FORMAT_R8G8_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_SNORM] = DXGI_FORMAT_R8G8_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_SINT] = DXGI_FORMAT_R8G8_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_R16_TYPELESS] = DXGI_FORMAT_R16_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_R16_FLOAT] = DXGI_FORMAT_R16_FLOAT;
FmtToDXGIFmtMap[TEX_FORMAT_D16_UNORM] = DXGI_FORMAT_D16_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R16_UNORM] = DXGI_FORMAT_R16_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R16_UINT] = DXGI_FORMAT_R16_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R16_SNORM] = DXGI_FORMAT_R16_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R16_SINT] = DXGI_FORMAT_R16_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_R8_TYPELESS] = DXGI_FORMAT_R8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_R8_UNORM] = DXGI_FORMAT_R8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R8_UINT] = DXGI_FORMAT_R8_UINT;
FmtToDXGIFmtMap[TEX_FORMAT_R8_SNORM] = DXGI_FORMAT_R8_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R8_SINT] = DXGI_FORMAT_R8_SINT;
FmtToDXGIFmtMap[TEX_FORMAT_A8_UNORM] = DXGI_FORMAT_A8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R1_UNORM] = DXGI_FORMAT_R1_UNORM ;
FmtToDXGIFmtMap[TEX_FORMAT_RGB9E5_SHAREDEXP] = DXGI_FORMAT_R9G9B9E5_SHAREDEXP;
FmtToDXGIFmtMap[TEX_FORMAT_RG8_B8G8_UNORM] = DXGI_FORMAT_R8G8_B8G8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_G8R8_G8B8_UNORM] = DXGI_FORMAT_G8R8_G8B8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC1_TYPELESS] = DXGI_FORMAT_BC1_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC1_UNORM] = DXGI_FORMAT_BC1_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC1_UNORM_SRGB] = DXGI_FORMAT_BC1_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_BC2_TYPELESS] = DXGI_FORMAT_BC2_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC2_UNORM] = DXGI_FORMAT_BC2_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC2_UNORM_SRGB] = DXGI_FORMAT_BC2_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_BC3_TYPELESS] = DXGI_FORMAT_BC3_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC3_UNORM] = DXGI_FORMAT_BC3_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC3_UNORM_SRGB] = DXGI_FORMAT_BC3_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_BC4_TYPELESS] = DXGI_FORMAT_BC4_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC4_UNORM] = DXGI_FORMAT_BC4_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC4_SNORM] = DXGI_FORMAT_BC4_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC5_TYPELESS] = DXGI_FORMAT_BC5_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC5_UNORM] = DXGI_FORMAT_BC5_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC5_SNORM] = DXGI_FORMAT_BC5_SNORM;
FmtToDXGIFmtMap[TEX_FORMAT_B5G6R5_UNORM] = DXGI_FORMAT_B5G6R5_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_B5G5R5A1_UNORM] = DXGI_FORMAT_B5G5R5A1_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BGRA8_UNORM] = DXGI_FORMAT_B8G8R8A8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BGRX8_UNORM] = DXGI_FORMAT_B8G8R8X8_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_R10G10B10_XR_BIAS_A2_UNORM]= DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BGRA8_TYPELESS] = DXGI_FORMAT_B8G8R8A8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BGRA8_UNORM_SRGB] = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_BGRX8_TYPELESS] = DXGI_FORMAT_B8G8R8X8_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BGRX8_UNORM_SRGB] = DXGI_FORMAT_B8G8R8X8_UNORM_SRGB;
FmtToDXGIFmtMap[TEX_FORMAT_BC6H_TYPELESS] = DXGI_FORMAT_BC6H_TYPELESS;
FmtToDXGIFmtMap[TEX_FORMAT_BC6H_UF16] = DXGI_FORMAT_BC6H_UF16;
FmtToDXGIFmtMap[TEX_FORMAT_BC6H_SF16] = DXGI_FORMAT_BC6H_SF16;
FmtToDXGIFmtMap[TEX_FORMAT_BC7_TYPELESS] = DXGI_FORMAT_BC7_TYPELESS ;
FmtToDXGIFmtMap[TEX_FORMAT_BC7_UNORM] = DXGI_FORMAT_BC7_UNORM;
FmtToDXGIFmtMap[TEX_FORMAT_BC7_UNORM_SRGB] = DXGI_FORMAT_BC7_UNORM_SRGB;
// clang-format on
bFormatMapInitialized = true;
}
if (TexFormat >= TEX_FORMAT_UNKNOWN && TexFormat < TEX_FORMAT_NUM_FORMATS)
{
auto DXGIFormat = FmtToDXGIFmtMap[TexFormat];
VERIFY(TexFormat == TEX_FORMAT_UNKNOWN || DXGIFormat != DXGI_FORMAT_UNKNOWN, "Unsupported texture format");
if (BindFlags != 0)
DXGIFormat = CorrectDXGIFormat(DXGIFormat, BindFlags);
return DXGIFormat;
}
else
{
UNEXPECTED("Texture format (", TexFormat, ") is out of allowed range [0, ", TEX_FORMAT_NUM_FORMATS - 1, "]");
return DXGI_FORMAT_UNKNOWN;
}
}
class DXGIFmtToFmtMapInitializer
{
public:
DXGIFmtToFmtMapInitializer(TEXTURE_FORMAT DXGIFmtToFmtMap[])
{
for (TEXTURE_FORMAT fmt = TEX_FORMAT_UNKNOWN; fmt < TEX_FORMAT_NUM_FORMATS; fmt = static_cast<TEXTURE_FORMAT>(fmt + 1))
{
auto DXGIFmt = TexFormatToDXGI_Format(fmt);
VERIFY_EXPR(DXGIFmt <= DXGI_FORMAT_B4G4R4A4_UNORM);
DXGIFmtToFmtMap[DXGIFmt] = fmt;
}
}
};
TEXTURE_FORMAT DXGI_FormatToTexFormat(DXGI_FORMAT DXGIFormat)
{
static_assert(DXGI_FORMAT_B4G4R4A4_UNORM == 115, "Unexpected DXGI format value");
static TEXTURE_FORMAT DXGIFmtToFmtMap[DXGI_FORMAT_B4G4R4A4_UNORM + 1];
static DXGIFmtToFmtMapInitializer Initializer(DXGIFmtToFmtMap);
if (DXGIFormat >= DXGI_FORMAT_UNKNOWN && DXGIFormat <= DXGI_FORMAT_BC7_UNORM_SRGB)
{
auto Format = DXGIFmtToFmtMap[DXGIFormat];
VERIFY(DXGIFormat == DXGI_FORMAT_UNKNOWN || Format != TEX_FORMAT_UNKNOWN, "Unsupported texture format");
VERIFY_EXPR(DXGIFormat == TexFormatToDXGI_Format(Format));
return Format;
}
else
{
UNEXPECTED("DXGI texture format (", DXGIFormat, ") is out of allowed range [0, ", DXGI_FORMAT_BC7_UNORM_SRGB, "]");
return TEX_FORMAT_UNKNOWN;
}
}
} // namespace Diligent
|
d0cc79876fba29eec4e36b9a9b9495b1dd861974
|
af0a4e4696bde1d25315648c57db973b8d2c2cf4
|
/dsa8infix.cpp
|
df056f46380b99bb3789061d62d71ad3b0cdcbe1
|
[] |
no_license
|
nayanjadhav08/SPPU-SE-DSA-PROGRAMME
|
09f1d8934bb799f654be96a2c792d0dea24c5c8d
|
a7942efecc7d8c512705413935b2477d29ba90af
|
refs/heads/master
| 2022-02-23T04:45:55.743463
| 2019-09-23T17:58:36
| 2019-09-23T17:58:36
| 109,691,681
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,338
|
cpp
|
dsa8infix.cpp
|
//8. Implement C++ program for expression conversion as infix to postfix and its evaluation using stack based on given conditions
//i. Operands and operator, both must be single character.
//ii. Input Postfix expression must be in a desired format.
//iii. Only '+', '-', '*' and '/ ' operators are expected.
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<stack>
using namespace std;
class intopo
{
string infix, postfix ;
int i,j,k,top,top1;
char stk[20];
int stk1[20];
public :
intopo()
{
top=-1;
top1=-1;
}
void push(char a)
{
top++;
stk[top]=a;
}
void push1(int a)
{
top1++;
stk1[top1]=a;
}
void eval();
char pop()
{
char c=stk[top];
top--;
return c;
}
int pop1()
{
int c=stk1[top1];
top1--;
return c;
}
int isfull()
{
if(top==20)
{
return 1;
}
else
return 0;
}
int isempty()
{
if(top==-1)
{
return 1;
}
else
return 0;
}
void getexp()
{
cout<<"\n Enter the Infix expression : ";
cin>>infix;
}
void put()
{
cout<<"\n INFIX expression is :";
cout<<infix;
}
void conversion();
int isoperator(char i)
{
if( i=='+' || i=='-' || i=='*' || i=='/' || i=='('|| i==')' )
{
return 1;
}
else
return 0;
}
int isoperand(int i)
{
if( i>='0' || i<= '9' )
{
return 1;
}
else
return 0;
}
int pref(char o)
{
switch(o)
{
case '+' :
return 1;
break;
case '-' :
return 1;
break;
case '*' :
return 3;
break;
case '/' :
return 3;
break;
default :
cout<<"\n Operartor not found .`";
}
}
};
void intopo::conversion()
{ char s;
for(i=0 ; i<infix.size() ; i++ )
{
if(isoperator(infix[i]) ==1 )
{
if(infix[i]=='(')
{ push(infix[i]);
}
else if(infix[i]==')')
{
while(stk[top] !='(')
{
s=pop();
postfix =postfix + s;
}
pop();
}
else if(isempty() == 1)
{
push(infix[i]);
}
else if(pref(stk[top]) > pref(infix[i]))
{
s= pop();
postfix=postfix + s;
push(infix[i]);
}
else if(pref(stk[top]) < pref(infix[i]))
{
push(infix[i]);
//while(isempty()!=1)
// s=pop();
// postfix=postfix + s;
//}
}
else if(pref(stk[top]) == pref(infix[i]))
{
s=pop();
push(infix[i]);
postfix=postfix+s;
}
}
else if(isoperand(infix[i]) ==1 )
{
postfix=postfix + infix[i];
}
cout<<"\npostdix ="<<postfix;}
while(isempty() !=1)
{ char m;
s= pop();
cout<<"s="<<s;
if(pref(stk[top]) == pref(s))
{ m=pop();
postfix= postfix + m;
postfix= postfix + s;
}
// postfix=postfix + s;
}
cout<<"\npostdix ="<<postfix;
}
void intopo::eval()
{
int op1 , op2 ,ans ;
char ch;
int k;
stack <int> st;
for(i=0 ; i<postfix.size() ; i++)
{
if(isoperator(postfix[i]) == 1 )
{ cout<<"\n pos i : "<<postfix[i];
ch=postfix[i];
op1=pop1();
op2=pop1() ;
cout<<"\nop 1 :"<<op1<<" op2 : "<<op2;
op1 =op1-48;
op2 =op2-48;
cout<<"\nop 1 :"<<op1<<" op2 : "<<op2;
switch(ch){
case '+' :
ans=op1+op2;
cout<<"\n Ans ="<<ans;
break;
case '-' :
ans=op1-op2;
break;
case '*' :
ans=op1*op2;
cout<<"\n Ans ="<<ans;
break;
case '/' :
ans=op1/op2;
break;
default :
cout<<"NOT avilable :";
}
push1(ans+48);
cout<<"\n top now "<<stk1[top1];
}
else if(isoperand(postfix[i]) == 1)
{ //cout<<"\n pos i in : "<<postfix[i];
k=postfix[i];
push1(k);
}
// cout<<"\n top :"<<st.top();
}
cout<<"\n top1 = "<<top1;
cout<<"\n Evalution of the Postfix : ";
int ans1=pop1()-48;
cout<<" "<<ans1;
}
int main()
{ //system("clear");
intopo i ;
i.getexp();
i.conversion();
i
.eval();
}
|
7fac39730b9443ac90648aacad0c822dc87c5597
|
9c046eeda11be532cc0017e6da316e7ddfd16283
|
/Telecomm/SharedLib/zbar/include/Magick++/Image.h
|
219bb3d3fa8851774882c55329d65e5c77225238
|
[
"BSD-3-Clause"
] |
permissive
|
telecommai/windows
|
83cd3ac4dec7742c6e038689689ac7ec9cde842a
|
30e34ffe0bc81f39c25be7624d16856bf42e03eb
|
refs/heads/master
| 2023-01-12T02:10:59.904541
| 2019-04-23T11:42:07
| 2019-04-23T11:42:07
| 180,726,308
| 3
| 0
|
BSD-3-Clause
| 2023-01-03T19:52:20
| 2019-04-11T06:12:20
|
C++
|
UTF-8
|
C++
| false
| false
| 68,103
|
h
|
Image.h
|
// This may look like C code, but it is really -*- C++ -*-
//
// Copyright Bob Friesenhahn, 1999, 2000, 2001, 2002, 2003
// Copyright Dirk Lemstra 2013-2015
//
// Definition of Image, the representation of a single image in Magick++
//
#if !defined(Magick_Image_header)
#define Magick_Image_header
#include "Magick++/Include.h"
#include <string>
#include <list>
#include "Magick++/Blob.h"
#include "Magick++/ChannelMoments.h"
#include "Magick++/Color.h"
#include "Magick++/Drawable.h"
#include "Magick++/Exception.h"
#include "Magick++/Geometry.h"
#include "Magick++/TypeMetric.h"
namespace Magick
{
// Forward declarations
class Options;
class ImageRef;
extern MagickPPExport const char *borderGeometryDefault;
extern MagickPPExport const char *frameGeometryDefault;
extern MagickPPExport const char *raiseGeometryDefault;
// Compare two Image objects regardless of LHS/RHS
// Image sizes and signatures are used as basis of comparison
MagickPPExport int operator ==
(const Magick::Image &left_,const Magick::Image &right_);
MagickPPExport int operator !=
(const Magick::Image &left_,const Magick::Image &right_);
MagickPPExport int operator >
(const Magick::Image &left_,const Magick::Image &right_);
MagickPPExport int operator <
(const Magick::Image &left_,const Magick::Image &right_);
MagickPPExport int operator >=
(const Magick::Image &left_,const Magick::Image &right_);
MagickPPExport int operator <=
(const Magick::Image &left_,const Magick::Image &right_);
//
// Image is the representation of an image. In reality, it actually
// a handle object which contains a pointer to a shared reference
// object (ImageRef). As such, this object is extremely space efficient.
//
class MagickPPExport Image
{
public:
// Obtain image statistics. Statistics are normalized to the range
// of 0.0 to 1.0 and are output to the specified ImageStatistics
// structure.
typedef struct _ImageChannelStatistics
{
/* Minimum value observed */
double maximum;
/* Maximum value observed */
double minimum;
/* Average (mean) value observed */
double mean;
/* Standard deviation, sqrt(variance) */
double standard_deviation;
/* Variance */
double variance;
/* Kurtosis */
double kurtosis;
/* Skewness */
double skewness;
} ImageChannelStatistics;
typedef struct _ImageStatistics
{
ImageChannelStatistics red;
ImageChannelStatistics green;
ImageChannelStatistics blue;
ImageChannelStatistics opacity;
} ImageStatistics;
// Default constructor
Image(void);
// Construct Image from in-memory BLOB
Image(const Blob &blob_);
// Construct Image of specified size from in-memory BLOB
Image(const Blob &blob_,const Geometry &size_);
// Construct Image of specified size and depth from in-memory BLOB
Image(const Blob &blob_,const Geometry &size_,const size_t depth_);
// Construct Image of specified size, depth, and format from
// in-memory BLOB
Image(const Blob &blob_,const Geometry &size_,const size_t depth_,
const std::string &magick_);
// Construct Image of specified size, and format from in-memory BLOB
Image(const Blob &blob_,const Geometry &size_,const std::string &magick_);
// Construct a blank image canvas of specified size and color
Image(const Geometry &size_,const Color &color_);
// Copy constructor
Image(const Image &image_);
// Copy constructor to copy part of the image
Image(const Image &image_,const Geometry &geometry_);
// Construct an image based on an array of raw pixels, of
// specified type and mapping, in memory
Image(const size_t width_,const size_t height_,const std::string &map_,
const StorageType type_,const void *pixels_);
// Construct from image file or image specification
Image(const std::string &imageSpec_);
// Destructor
virtual ~Image();
// Assignment operator
Image& operator=(const Image &image_);
// Join images into a single multi-image file
void adjoin(const bool flag_);
bool adjoin(void) const;
// Anti-alias Postscript and TrueType fonts (default true)
void antiAlias(const bool flag_);
bool antiAlias(void) const;
// Time in 1/100ths of a second which must expire before
// displaying the next image in an animated sequence.
void animationDelay(const size_t delay_);
size_t animationDelay(void) const;
// Number of iterations to loop an animation (e.g. Netscape loop
// extension) for.
void animationIterations(const size_t iterations_);
size_t animationIterations(void) const;
// Lessen (or intensify) when adding noise to an image.
void attenuate(const double attenuate_);
// Image background color
void backgroundColor(const Color &color_);
Color backgroundColor(void) const;
// Name of texture image to tile onto the image background
void backgroundTexture(const std::string &backgroundTexture_);
std::string backgroundTexture(void) const;
// Base image width (before transformations)
size_t baseColumns(void) const;
// Base image filename (before transformations)
std::string baseFilename(void) const;
// Base image height (before transformations)
size_t baseRows(void) const;
// Use black point compensation.
void blackPointCompensation(const bool flag_);
bool blackPointCompensation(void) const;
// Image border color
void borderColor(const Color &color_);
Color borderColor(void) const;
// Return smallest bounding box enclosing non-border pixels. The
// current fuzz value is used when discriminating between pixels.
// This is the crop bounding box used by crop(Geometry(0,0));
Geometry boundingBox(void) const;
// Text bounding-box base color (default none)
void boxColor(const Color &boxColor_);
Color boxColor(void) const;
// This method is now deprecated. Please use ResourceLimits instead.
static void cacheThreshold(const size_t threshold_);
// Image class (DirectClass or PseudoClass)
// NOTE: setting a DirectClass image to PseudoClass will result in
// the loss of color information if the number of colors in the
// image is greater than the maximum palette size (either 256 or
// 65536 entries depending on the value of MAGICKCORE_QUANTUM_DEPTH when
// ImageMagick was built).
void classType(const ClassType class_);
ClassType classType(void) const;
// Associate a clip mask with the image. The clip mask must be the
// same dimensions as the image. Pass an invalid image to unset an
// existing clip mask.
void clipMask(const Image &clipMask_);
Image clipMask(void) const;
// Colors within this distance are considered equal
void colorFuzz(const double fuzz_);
double colorFuzz(void) const;
// Colormap size (number of colormap entries)
void colorMapSize(const size_t entries_);
size_t colorMapSize(void) const;
// Image Color Space
void colorSpace(const ColorspaceType colorSpace_);
ColorspaceType colorSpace(void) const;
void colorspaceType(const ColorspaceType colorSpace_);
ColorspaceType colorspaceType(void) const;
// Image width
size_t columns(void) const;
// Comment image (add comment string to image)
void comment(const std::string &comment_);
std::string comment(void) const;
// Composition operator to be used when composition is implicitly
// used (such as for image flattening).
void compose(const CompositeOperator compose_);
CompositeOperator compose(void) const;
// Compression type
void compressType(const CompressionType compressType_);
CompressionType compressType(void) const;
// Enable printing of debug messages from ImageMagick
void debug(const bool flag_);
bool debug(void) const;
// Vertical and horizontal resolution in pixels of the image
void density(const Geometry &geomery_);
Geometry density(void) const;
// Image depth (bits allocated to red/green/blue components)
void depth(const size_t depth_);
size_t depth(void) const;
// Tile names from within an image montage
std::string directory(void) const;
// Endianness (little like Intel or big like SPARC) for image
// formats which support endian-specific options.
void endian(const EndianType endian_);
EndianType endian(void) const;
// Exif profile (BLOB)
void exifProfile(const Blob &exifProfile_);
Blob exifProfile(void) const;
// Image file name
void fileName(const std::string &fileName_);
std::string fileName(void) const;
// Number of bytes of the image on disk
off_t fileSize(void) const;
// Color to use when filling drawn objects
void fillColor(const Color &fillColor_);
Color fillColor(void) const;
// Rule to use when filling drawn objects
void fillRule(const FillRule &fillRule_);
FillRule fillRule(void) const;
// Pattern to use while filling drawn objects.
void fillPattern(const Image &fillPattern_);
Image fillPattern(void) const;
// Filter to use when resizing image
void filterType(const FilterTypes filterType_);
FilterTypes filterType(void) const;
// Text rendering font
void font(const std::string &font_);
std::string font(void) const;
// Font family
void fontFamily(const std::string &family_);
std::string fontFamily(void) const;
// Font point size
void fontPointsize(const double pointSize_);
double fontPointsize(void) const;
// Font style
void fontStyle(const StyleType style_);
StyleType fontStyle(void) const;
// Font weight
void fontWeight(const size_t weight_);
size_t fontWeight(void) const;
// Long image format description
std::string format(void) const;
// Formats the specified expression
// More info here: http://www.imagemagick.org/script/escape.php
std::string formatExpression(const std::string expression);
// Gamma level of the image
double gamma(void) const;
// Preferred size of the image when encoding
Geometry geometry(void) const;
// GIF disposal method
void gifDisposeMethod(const size_t disposeMethod_);
size_t gifDisposeMethod(void) const;
// When comparing images, emphasize pixel differences with this color.
void highlightColor(const Color color_);
// ICC color profile (BLOB)
void iccColorProfile(const Blob &colorProfile_);
Blob iccColorProfile(void) const;
// Type of interlacing to use
void interlaceType(const InterlaceType interlace_);
InterlaceType interlaceType(void) const;
// Pixel color interpolation method to use
void interpolate(const InterpolatePixelMethod interpolate_);
InterpolatePixelMethod interpolate(void) const;
// IPTC profile (BLOB)
void iptcProfile(const Blob &iptcProfile_);
Blob iptcProfile(void) const;
// Returns true if none of the pixels in the image have an alpha value
// other than OpaqueAlpha (QuantumRange).
bool isOpaque(void) const;
// Does object contain valid image?
void isValid(const bool isValid_);
bool isValid(void) const;
// Image label
void label(const std::string &label_);
std::string label(void) const;
// Stroke width for drawing vector objects (default one)
// This method is now deprecated. Please use strokeWidth instead.
void lineWidth(const double lineWidth_);
double lineWidth(void) const;
// When comparing images, de-emphasize pixel differences with this color.
void lowlightColor(const Color color_);
// File type magick identifier (.e.g "GIF")
void magick(const std::string &magick_);
std::string magick(void) const;
// Associate a mask with the image. The mask must be the same dimensions
// as the image. Pass an invalid image to unset an existing clip mask.
void mask(const Image &mask_);
Image mask(void) const;
// Image supports transparency (matte channel)
void matte(const bool matteFlag_);
bool matte(void) const;
// Transparent color
void matteColor(const Color &matteColor_);
Color matteColor(void) const;
// The mean error per pixel computed when an image is color reduced
double meanErrorPerPixel(void) const;
// Image modulus depth (minimum number of bits required to support
// red/green/blue components without loss of accuracy)
void modulusDepth(const size_t modulusDepth_);
size_t modulusDepth(void) const;
// Transform image to black and white
void monochrome(const bool monochromeFlag_);
bool monochrome(void) const;
// Tile size and offset within an image montage
Geometry montageGeometry(void) const;
// The normalized max error per pixel computed when an image is
// color reduced.
double normalizedMaxError(void) const;
// The normalized mean error per pixel computed when an image is
// color reduced.
double normalizedMeanError(void) const;
// Image orientation
void orientation(const OrientationType orientation_);
OrientationType orientation(void) const;
// Preferred size and location of an image canvas.
void page(const Geometry &pageSize_);
Geometry page(void) const;
// Pen color (deprecated, don't use any more)
void penColor(const Color &penColor_);
Color penColor(void) const;
// Pen texture image (deprecated, don't use any more)
void penTexture(const Image &penTexture_);
Image penTexture(void) const;
// JPEG/MIFF/PNG compression level (default 75).
void quality(const size_t quality_);
size_t quality(void) const;
// Maximum number of colors to quantize to
void quantizeColors(const size_t colors_);
size_t quantizeColors(void) const;
// Colorspace to quantize in.
void quantizeColorSpace(const ColorspaceType colorSpace_);
ColorspaceType quantizeColorSpace(void) const;
// Dither image during quantization (default true).
void quantizeDither(const bool ditherFlag_);
bool quantizeDither(void) const;
// Dither method
void quantizeDitherMethod(const DitherMethod ditherMethod_);
DitherMethod quantizeDitherMethod(void) const;
// Quantization tree-depth
void quantizeTreeDepth(const size_t treeDepth_);
size_t quantizeTreeDepth(void) const;
// Suppress all warning messages. Error messages are still reported.
void quiet(const bool quiet_);
bool quiet(void) const;
// The type of rendering intent
void renderingIntent(const RenderingIntent renderingIntent_);
RenderingIntent renderingIntent(void) const;
// Units of image resolution
void resolutionUnits(const ResolutionType resolutionUnits_);
ResolutionType resolutionUnits(void) const;
// The number of pixel rows in the image
size_t rows(void) const;
// Image scene number
void scene(const size_t scene_);
size_t scene(void) const;
// Width and height of a raw image
void size(const Geometry &geometry_);
Geometry size(void) const;
// enabled/disable stroke anti-aliasing
void strokeAntiAlias(const bool flag_);
bool strokeAntiAlias(void) const;
// Color to use when drawing object outlines
void strokeColor(const Color &strokeColor_);
Color strokeColor(void) const;
// Specify the pattern of dashes and gaps used to stroke
// paths. The strokeDashArray represents a zero-terminated array
// of numbers that specify the lengths of alternating dashes and
// gaps in pixels. If an odd number of values is provided, then
// the list of values is repeated to yield an even number of
// values. A typical strokeDashArray_ array might contain the
// members 5 3 2 0, where the zero value indicates the end of the
// pattern array.
void strokeDashArray(const double *strokeDashArray_);
const double *strokeDashArray(void) const;
// While drawing using a dash pattern, specify distance into the
// dash pattern to start the dash (default 0).
void strokeDashOffset(const double strokeDashOffset_);
double strokeDashOffset(void) const;
// Specify the shape to be used at the end of open subpaths when
// they are stroked. Values of LineCap are UndefinedCap, ButtCap,
// RoundCap, and SquareCap.
void strokeLineCap(const LineCap lineCap_);
LineCap strokeLineCap(void) const;
// Specify the shape to be used at the corners of paths (or other
// vector shapes) when they are stroked. Values of LineJoin are
// UndefinedJoin, MiterJoin, RoundJoin, and BevelJoin.
void strokeLineJoin(const LineJoin lineJoin_);
LineJoin strokeLineJoin(void) const;
// Specify miter limit. When two line segments meet at a sharp
// angle and miter joins have been specified for 'lineJoin', it is
// possible for the miter to extend far beyond the thickness of
// the line stroking the path. The miterLimit' imposes a limit on
// the ratio of the miter length to the 'lineWidth'. The default
// value of this parameter is 4.
void strokeMiterLimit(const size_t miterLimit_);
size_t strokeMiterLimit(void) const;
// Pattern image to use while stroking object outlines.
void strokePattern(const Image &strokePattern_);
Image strokePattern(void) const;
// Stroke width for drawing vector objects (default one)
void strokeWidth(const double strokeWidth_);
double strokeWidth(void) const;
// Subimage of an image sequence
void subImage(const size_t subImage_);
size_t subImage(void) const;
// Number of images relative to the base image
void subRange(const size_t subRange_);
size_t subRange(void) const;
// Render text right-to-left or left-to-right.
void textDirection(DirectionType direction_);
DirectionType textDirection() const;
// Annotation text encoding (e.g. "UTF-16")
void textEncoding(const std::string &encoding_);
std::string textEncoding(void) const;
// Text gravity.
void textGravity(GravityType gravity_);
GravityType textGravity() const;
// Text inter-line spacing
void textInterlineSpacing(double spacing_);
double textInterlineSpacing(void) const;
// Text inter-word spacing
void textInterwordSpacing(double spacing_);
double textInterwordSpacing(void) const;
// Text inter-character kerning
void textKerning(double kerning_);
double textKerning(void) const;
// Text undercolor box
void textUnderColor(const Color &underColor_);
Color textUnderColor(void) const;
// Tile name
void tileName(const std::string &tileName_);
std::string tileName(void) const;
// Number of colors in the image
size_t totalColors(void) const;
// Rotation to use when annotating with text or drawing
void transformRotation(const double angle_);
// Skew to use in X axis when annotating with text or drawing
void transformSkewX(const double skewx_);
// Skew to use in Y axis when annotating with text or drawing
void transformSkewY(const double skewy_);
// Image representation type (also see type operation)
// Available types:
// Bilevel Grayscale GrayscaleMatte
// Palette PaletteMatte TrueColor
// TrueColorMatte ColorSeparation ColorSeparationMatte
void type(const ImageType type_);
ImageType type(void) const;
// Print detailed information about the image
void verbose(const bool verboseFlag_);
bool verbose(void) const;
// FlashPix viewing parameters
void view(const std::string &view_);
std::string view(void) const;
// Virtual pixel method
void virtualPixelMethod(const VirtualPixelMethod virtual_pixel_method_);
VirtualPixelMethod virtualPixelMethod(void) const;
// X11 display to display to, obtain fonts from, or to capture
// image from
void x11Display(const std::string &display_);
std::string x11Display(void) const;
// x resolution of the image
double xResolution(void) const;
// y resolution of the image
double yResolution(void) const;
// Adaptive-blur image with specified blur factor
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
void adaptiveBlur(const double radius_=0.0,const double sigma_=1.0);
// This is shortcut function for a fast interpolative resize using mesh
// interpolation. It works well for small resizes of less than +/- 50%
// of the original image size. For larger resizing on images a full
// filtered and slower resize function should be used instead.
void adaptiveResize(const Geometry &geometry_);
// Adaptively sharpens the image by sharpening more intensely near image
// edges and less intensely far from edges. We sharpen the image with a
// Gaussian operator of the given radius and standard deviation (sigma).
// For reasonable results, radius should be larger than sigma.
void adaptiveSharpen(const double radius_=0.0,const double sigma_=1.0);
void adaptiveSharpenChannel(const ChannelType channel_,
const double radius_=0.0,const double sigma_=1.0);
// Local adaptive threshold image
// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm
// Width x height define the size of the pixel neighborhood
// offset = constant to subtract from pixel neighborhood mean
void adaptiveThreshold(const size_t width,const size_t height,
const ::ssize_t offset=0);
// Add noise to image with specified noise type
void addNoise(const NoiseType noiseType_);
void addNoiseChannel(const ChannelType channel_,
const NoiseType noiseType_);
// Transform image by specified affine (or free transform) matrix.
void affineTransform(const DrawableAffine &affine);
// Activates, deactivates, resets, or sets the alpha channel.
void alphaChannel(AlphaChannelType alphaType_);
//
// Annotate image (draw text on image)
//
// Gravity effects text placement in bounding area according to rules:
// NorthWestGravity text bottom-left corner placed at top-left
// NorthGravity text bottom-center placed at top-center
// NorthEastGravity text bottom-right corner placed at top-right
// WestGravity text left-center placed at left-center
// CenterGravity text center placed at center
// EastGravity text right-center placed at right-center
// SouthWestGravity text top-left placed at bottom-left
// SouthGravity text top-center placed at bottom-center
// SouthEastGravity text top-right placed at bottom-right
// Annotate using specified text, and placement location
void annotate(const std::string &text_,const Geometry &location_);
// Annotate using specified text, bounding area, and placement
// gravity
void annotate(const std::string &text_,const Geometry &boundingArea_,
const GravityType gravity_);
// Annotate with text using specified text, bounding area,
// placement gravity, and rotation.
void annotate(const std::string &text_,const Geometry &boundingArea_,
const GravityType gravity_,const double degrees_);
// Annotate with text (bounding area is entire image) and placement
// gravity.
void annotate(const std::string &text_,const GravityType gravity_);
// Inserts the artifact with the specified name and value into
// the artifact tree of the image.
void artifact(const std::string &name_,const std::string &value_);
// Returns the value of the artifact with the specified name.
std::string artifact(const std::string &name_) const;
// Access/Update a named image attribute
void attribute(const std::string name_,const char *value_);
void attribute(const std::string name_,const std::string value_);
std::string attribute(const std::string name_ ) const;
// Extracts the 'mean' from the image and adjust the image to try
// make set its gamma appropriatally.
void autoGamma(void);
void autoGammaChannel(const ChannelType channel_);
// Adjusts the levels of a particular image channel by scaling the
// minimum and maximum values to the full quantum range.
void autoLevel(void);
void autoLevelChannel(const ChannelType channel_);
// Adjusts an image so that its orientation is suitable for viewing.
void autoOrient(void);
// Forces all pixels below the threshold into black while leaving all
// pixels at or above the threshold unchanged.
void blackThreshold(const std::string &threshold_);
void blackThresholdChannel(const ChannelType channel_,
const std::string &threshold_);
// Simulate a scene at nighttime in the moonlight.
void blueShift(const double factor_=1.5);
// Blur image with specified blur factor
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
void blur(const double radius_=0.0,const double sigma_=1.0);
void blurChannel(const ChannelType channel_,const double radius_=0.0,
const double sigma_=1.0);
// Border image (add border to image)
void border(const Geometry &geometry_=borderGeometryDefault);
// Changes the brightness and/or contrast of an image. It converts the
// brightness and contrast parameters into slope and intercept and calls
// a polynomical function to apply to the image.
void brightnessContrast(const double brightness_=0.0,
const double contrast_=0.0);
void brightnessContrastChannel(const ChannelType channel_,
const double brightness_=0.0,const double contrast_=0.0);
// Uses a multi-stage algorithm to detect a wide range of edges in images.
void cannyEdge(const double radius_=0.0,const double sigma_=1.0,
const double lowerPercent_=0.1,const double upperPercent_=0.3);
// Accepts a lightweight Color Correction Collection
// (CCC) file which solely contains one or more color corrections and
// applies the correction to the image.
void cdl(const std::string &cdl_);
// Extract channel from image
void channel(const ChannelType channel_);
// Set or obtain modulus channel depth
void channelDepth(const ChannelType channel_,const size_t depth_);
size_t channelDepth(const ChannelType channel_);
// Charcoal effect image (looks like charcoal sketch)
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
void charcoal(const double radius_=0.0,const double sigma_=1.0);
// Chop image (remove vertical or horizontal subregion of image)
// FIXME: describe how geometry argument is used to select either
// horizontal or vertical subregion of image.
void chop(const Geometry &geometry_);
// Chromaticity blue primary point (e.g. x=0.15, y=0.06)
void chromaBluePrimary(const double x_,const double y_);
void chromaBluePrimary(double *x_, double *y_) const;
// Chromaticity green primary point (e.g. x=0.3, y=0.6)
void chromaGreenPrimary(const double x_,const double y_);
void chromaGreenPrimary(double *x_,double *y_) const;
// Chromaticity red primary point (e.g. x=0.64, y=0.33)
void chromaRedPrimary(const double x_,const double y_);
void chromaRedPrimary(double *x_,double *y_) const;
// Chromaticity white point (e.g. x=0.3127, y=0.329)
void chromaWhitePoint(const double x_,const double y_);
void chromaWhitePoint(double *x_,double *y_) const;
// Set each pixel whose value is below zero to zero and any the
// pixel whose value is above the quantum range to the quantum range (e.g.
// 65535) otherwise the pixel value remains unchanged.
void clamp(void);
void clampChannel(const ChannelType channel_);
// Sets the image clip mask based on any clipping path information
// if it exists.
void clip(void);
void clipPath(const std::string pathname_,const bool inside_);
// Apply a color lookup table (CLUT) to the image.
void clut(const Image &clutImage_);
void clutChannel(const ChannelType channel_,const Image &clutImage_);
// Colorize image with pen color, using specified percent opacity.
void colorize(const unsigned int opacity_,const Color &penColor_);
// Colorize image with pen color, using specified percent opacity
// for red, green, and blue quantums
void colorize(const unsigned int opacityRed_,
const unsigned int opacityGreen_,const unsigned int opacityBlue_,
const Color &penColor_);
// Color at colormap position index_
void colorMap(const size_t index_,const Color &color_);
Color colorMap(const size_t index_) const;
// Apply a color matrix to the image channels. The user supplied
// matrix may be of order 1 to 5 (1x1 through 5x5).
void colorMatrix(const size_t order_,const double *color_matrix_);
// Compare current image with another image
// Sets meanErrorPerPixel, normalizedMaxError, and normalizedMeanError
// in the current image. False is returned if the images are identical.
bool compare(const Image &reference_);
// Compare current image with another image
// Returns the distortion based on the specified metric.
double compare(const Image &reference_,const MetricType metric_);
double compareChannel(const ChannelType channel_,const Image &reference_,
const MetricType metric_);
// Compare current image with another image
// Sets the distortion and returns the difference image.
Image compare(const Image &reference_,const MetricType metric_,
double *distortion);
Image compareChannel(const ChannelType channel_,const Image &reference_,
const MetricType metric_,double *distortion );
// Compose an image onto another at specified offset and using
// specified algorithm
void composite(const Image &compositeImage_,const Geometry &offset_,
const CompositeOperator compose_=InCompositeOp);
void composite(const Image &compositeImage_,const GravityType gravity_,
const CompositeOperator compose_=InCompositeOp);
void composite(const Image &compositeImage_,const ::ssize_t xOffset_,
const ::ssize_t yOffset_,const CompositeOperator compose_=InCompositeOp);
// Determines the connected-components of the image
void connectedComponents(const size_t connectivity_);
// Contrast image (enhance intensity differences in image)
void contrast(const size_t sharpen_);
// A simple image enhancement technique that attempts to improve the
// contrast in an image by 'stretching' the range of intensity values
// it contains to span a desired range of values. It differs from the
// more sophisticated histogram equalization in that it can only apply a
// linear scaling function to the image pixel values. As a result the
// 'enhancement' is less harsh.
void contrastStretch(const double black_point_,const double white_point_);
void contrastStretchChannel(const ChannelType channel_,
const double black_point_,const double white_point_);
// Convolve image. Applies a user-specified convolution to the image.
// order_ represents the number of columns and rows in the filter kernel.
// kernel_ is an array of doubles representing the convolution kernel.
void convolve(const size_t order_,const double *kernel_);
// Copies pixels from the source image as defined by the geometry the
// destination image at the specified offset.
void copyPixels(const Image &source_,const Geometry &geometry_,
const Offset &offset_);
// Crop image (subregion of original image)
void crop(const Geometry &geometry_);
// Cycle image colormap
void cycleColormap(const ::ssize_t amount_);
// Converts cipher pixels to plain pixels.
void decipher(const std::string &passphrase_);
// Tagged image format define. Similar to the defineValue() method
// except that passing the flag_ value 'true' creates a value-less
// define with that format and key. Passing the flag_ value 'false'
// removes any existing matching definition. The method returns 'true'
// if a matching key exists, and 'false' if no matching key exists.
void defineSet(const std::string &magick_,const std::string &key_,
bool flag_);
bool defineSet(const std::string &magick_,const std::string &key_) const;
// Tagged image format define (set/access coder-specific option) The
// magick_ option specifies the coder the define applies to. The key_
// option provides the key specific to that coder. The value_ option
// provides the value to set (if any). See the defineSet() method if the
// key must be removed entirely.
void defineValue(const std::string &magick_,const std::string &key_,
const std::string &value_);
std::string defineValue(const std::string &magick_,
const std::string &key_) const;
// Removes skew from the image. Skew is an artifact that occurs in scanned
// images because of the camera being misaligned, imperfections in the
// scanning or surface, or simply because the paper was not placed
// completely flat when scanned. The value of threshold_ ranges from 0
// to QuantumRange.
void deskew(const double threshold_);
// Despeckle image (reduce speckle noise)
void despeckle(void);
// Determines the color type of the image. This method can be used to
// automaticly make the type GrayScale.
ImageType determineType(void) const;
// Display image on screen
void display(void);
// Distort image. distorts an image using various distortion methods, by
// mapping color lookups of the source image to a new destination image
// usally of the same size as the source image, unless 'bestfit' is set to
// true.
void distort(const DistortImageMethod method_,
const size_t number_arguments_,const double *arguments_,
const bool bestfit_=false);
// Draw on image using a single drawable
void draw(const Drawable &drawable_);
// Draw on image using a drawable list
void draw(const std::list<Magick::Drawable> &drawable_);
// Edge image (hilight edges in image)
void edge(const double radius_=0.0);
// Emboss image (hilight edges with 3D effect)
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
void emboss(const double radius_=0.0,const double sigma_=1.0);
// Converts pixels to cipher-pixels.
void encipher(const std::string &passphrase_);
// Enhance image (minimize noise)
void enhance(void);
// Equalize image (histogram equalization)
void equalize(void);
// Erase image to current "background color"
void erase(void);
// Extend the image as defined by the geometry.
void extent(const Geometry &geometry_);
void extent(const Geometry &geometry_,const Color &backgroundColor);
void extent(const Geometry &geometry_,const Color &backgroundColor,
const GravityType gravity_ );
void extent(const Geometry &geometry_,const GravityType gravity_);
// Flip image (reflect each scanline in the vertical direction)
void flip(void);
// Flood-fill color across pixels that match the color of the
// target pixel and are neighbors of the target pixel.
// Uses current fuzz setting when determining color match.
void floodFillColor(const Geometry &point_,const Color &fillColor_);
void floodFillColor(const Geometry &point_,const Color &fillColor_,
const bool invert_);
void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
const Color &fillColor_);
void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
const Color &fillColor_,const bool invert_);
// Flood-fill color across pixels starting at target-pixel and
// stopping at pixels matching specified border color.
// Uses current fuzz setting when determining color match.
void floodFillColor(const Geometry &point_,const Color &fillColor_,
const Color &borderColor_);
void floodFillColor(const Geometry &point_,const Color &fillColor_,
const Color &borderColor_,const bool invert_);
void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
const Color &fillColor_,const Color &borderColor_);
void floodFillColor(const ::ssize_t x_,const ::ssize_t y_,
const Color &fillColor_,const Color &borderColor_,const bool invert_);
// Floodfill pixels matching color (within fuzz factor) of target
// pixel(x,y) with replacement opacity value using method.
void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
const unsigned int opacity_,const bool invert_=false);
void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
const unsigned int opacity_,const PaintMethod method_);
void floodFillOpacity(const ::ssize_t x_,const ::ssize_t y_,
const unsigned int opacity_,const Color &target_,
const bool invert_=false);
// Flood-fill texture across pixels that match the color of the
// target pixel and are neighbors of the target pixel.
// Uses current fuzz setting when determining color match.
void floodFillTexture(const Geometry &point_,const Image &texture_);
void floodFillTexture(const Geometry &point_,const Image &texture_,
const bool invert_);
void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
const Image &texture_);
void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
const Image &texture_,const bool invert_);
// Flood-fill texture across pixels starting at target-pixel and
// stopping at pixels matching specified border color.
// Uses current fuzz setting when determining color match.
void floodFillTexture(const Geometry &point_,const Image &texture_,
const Color &borderColor_);
void floodFillTexture(const Geometry &point_,const Image &texture_,
const Color &borderColor_,const bool invert_);
void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
const Image &texture_,const Color &borderColor_);
void floodFillTexture(const ::ssize_t x_,const ::ssize_t y_,
const Image &texture_,const Color &borderColor_,const bool invert_);
// Flop image (reflect each scanline in the horizontal direction)
void flop(void);
// Obtain font metrics for text string given current font,
// pointsize, and density settings.
void fontTypeMetrics(const std::string &text_,TypeMetric *metrics);
// Obtain multi line font metrics for text string given current font,
// pointsize, and density settings.
void fontTypeMetricsMultiline(const std::string &text_,
TypeMetric *metrics);
// Frame image
void frame(const Geometry &geometry_=frameGeometryDefault);
void frame(const size_t width_,const size_t height_,
const ::ssize_t innerBevel_=6, const ::ssize_t outerBevel_=6);
// Applies a mathematical expression to the image.
void fx(const std::string expression);
void fx(const std::string expression,const Magick::ChannelType channel);
// Gamma correct image
void gamma(const double gamma_);
void gamma(const double gammaRed_,const double gammaGreen_,
const double gammaBlue_);
// Gaussian blur image
// The number of neighbor pixels to be included in the convolution
// mask is specified by 'width_'. The standard deviation of the
// gaussian bell curve is specified by 'sigma_'.
void gaussianBlur(const double width_,const double sigma_);
void gaussianBlurChannel(const ChannelType channel_,const double width_,
const double sigma_);
// Obtain immutable image pixel indexes (valid for PseudoClass images)
const IndexPacket *getConstIndexes(void) const;
// Transfers read-only pixels from the image to the pixel cache as
// defined by the specified region
const PixelPacket *getConstPixels(const ::ssize_t x_,const ::ssize_t y_,
const size_t columns_,const size_t rows_) const;
// Obtain mutable image pixel indexes (valid for PseudoClass images)
IndexPacket *getIndexes(void);
// Transfers pixels from the image to the pixel cache as defined
// by the specified region. Modified pixels may be subsequently
// transferred back to the image via syncPixels. This method is
// valid for DirectClass images.
PixelPacket *getPixels(const ::ssize_t x_,const ::ssize_t y_,
const size_t columns_,const size_t rows_);
// Converts the colors in the image to gray.
void grayscale(const PixelIntensityMethod method_);
// Apply a color lookup table (Hald CLUT) to the image.
void haldClut(const Image &clutImage_);
// Identifies lines in the image.
void houghLine(const size_t width_,const size_t height_,
const size_t threshold_=40);
// Implode image (special effect)
void implode(const double factor_);
// Implements the inverse discrete Fourier transform (DFT) of the image
// either as a magnitude / phase or real / imaginary image pair.
void inverseFourierTransform(const Image &phase_);
void inverseFourierTransform(const Image &phase_,const bool magnitude_);
// An edge preserving noise reduction filter.
void kuwahara(const double radius_=0.0,const double sigma_=1.0);
void kuwaharaChannel(const ChannelType channel_,const double radius_=0.0,
const double sigma_=1.0);
// Level image. Adjust the levels of the image by scaling the
// colors falling between specified white and black points to the
// full available quantum range. The parameters provided represent
// the black, mid (gamma), and white points. The black point
// specifies the darkest color in the image. Colors darker than
// the black point are set to zero. Mid point (gamma) specifies a
// gamma correction to apply to the image. White point specifies
// the lightest color in the image. Colors brighter than the
// white point are set to the maximum quantum value. The black and
// white point have the valid range 0 to QuantumRange while mid (gamma)
// has a useful range of 0 to ten.
void level(const double black_point,const double white_point,
const double mid_point=1.0);
void levelChannel(const ChannelType channel,const double black_point,
const double white_point,const double mid_point=1.0);
// Maps the given color to "black" and "white" values, linearly spreading
// out the colors, and level values on a channel by channel bases, as
// per level(). The given colors allows you to specify different level
// ranges for each of the color channels separately.
void levelColors(const Color &blackColor_,const Color &whiteColor_,
const bool invert_=true);
void levelColorsChannel(const ChannelType channel_,
const Color &blackColor_,const Color &whiteColor_,
const bool invert_=true);
// Levelize applies the reversed level operation to just the specific
// channels specified.It compresses the full range of color values, so
// that they lie between the given black and white points. Gamma is
// applied before the values are mapped.
void levelize(const double blackPoint_,const double whitePoint_,
const double gamma_=1.0);
void levelizeChannel(const ChannelType channel_,const double blackPoint_,
const double whitePoint_,const double gamma_=1.0);
// Discards any pixels below the black point and above the white point and
// levels the remaining pixels.
void linearStretch(const double blackPoint_,const double whitePoint_);
// Rescales image with seam carving.
void liquidRescale(const Geometry &geometry_);
// Local contrast enhancement
void localContrast(const double radius_,const double strength_);
// Magnify image by integral size
void magnify(void);
// Remap image colors with closest color from reference image
void map(const Image &mapImage_,const bool dither_=false);
// Floodfill designated area with replacement opacity value
void matteFloodfill(const Color &target_,const unsigned int opacity_,
const ::ssize_t x_,const ::ssize_t y_,const PaintMethod method_);
// Filter image by replacing each pixel component with the median
// color in a circular neighborhood
void medianFilter(const double radius_=0.0);
// Merge image layers (deprecated, don't use any more)
void mergeLayers(const ImageLayerMethod layerType_);
// Reduce image by integral size
void minify(void);
// Modulate percent hue, saturation, and brightness of an image
void modulate(const double brightness_,const double saturation_,
const double hue_);
// Returns the normalized moments of one or more image channels.
ImageMoments moments(void) const;
// Applies a kernel to the image according to the given mophology method.
void morphology(const MorphologyMethod method_,const std::string kernel_,
const ssize_t iterations_=1);
void morphology(const MorphologyMethod method_,
const KernelInfoType kernel_,const std::string arguments_,
const ssize_t iterations_=1);
void morphologyChannel(const ChannelType channel_,
const MorphologyMethod method_,const std::string kernel_,
const ssize_t iterations_=1);
void morphologyChannel(const ChannelType channel_,
const MorphologyMethod method_,const KernelInfoType kernel_,
const std::string arguments_,const ssize_t iterations_=1);
// Motion blur image with specified blur factor
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
// The angle_ parameter specifies the angle the object appears
// to be comming from (zero degrees is from the right).
void motionBlur(const double radius_,const double sigma_,
const double angle_);
// Negate colors in image. Set grayscale to only negate grayscale
// values in image.
void negate(const bool grayscale_=false);
void negateChannel(const ChannelType channel_,const bool grayscale_=false);
// Normalize image (increase contrast by normalizing the pixel
// values to span the full range of color values)
void normalize(void);
// Oilpaint image (image looks like oil painting)
void oilPaint(const double radius_=3.0);
// Set or attenuate the opacity channel in the image. If the image
// pixels are opaque then they are set to the specified opacity
// value, otherwise they are blended with the supplied opacity
// value. The value of opacity_ ranges from 0 (completely opaque)
// to QuantumRange. The defines OpaqueOpacity and TransparentOpacity are
// available to specify completely opaque or completely
// transparent, respectively.
void opacity(const unsigned int opacity_);
// Change color of opaque pixel to specified pen color.
void opaque(const Color &opaqueColor_,const Color &penColor_,
const bool invert_=MagickFalse);
// Perform a ordered dither based on a number of pre-defined dithering
// threshold maps, but over multiple intensity levels.
void orderedDither(std::string thresholdMap_);
void orderedDitherChannel(const ChannelType channel_,
std::string thresholdMap_);
// Set each pixel whose value is less than epsilon to epsilon or
// -epsilon (whichever is closer) otherwise the pixel value remains
// unchanged.
void perceptible(const double epsilon_);
void perceptibleChannel(const ChannelType channel_,const double epsilon_);
// Ping is similar to read except only enough of the image is read
// to determine the image columns, rows, and filesize. Access the
// columns(), rows(), and fileSize() attributes after invoking
// ping. The image data is not valid after calling ping.
void ping(const Blob &blob_);
// Ping is similar to read except only enough of the image is read
// to determine the image columns, rows, and filesize. Access the
// columns(), rows(), and fileSize() attributes after invoking
// ping. The image data is not valid after calling ping.
void ping(const std::string &imageSpec_);
// Get/set pixel color at location x & y.
void pixelColor(const ::ssize_t x_,const ::ssize_t y_,const Color &color_);
Color pixelColor(const ::ssize_t x_,const ::ssize_t y_ ) const;
// Simulates a Polaroid picture.
void polaroid(const std::string &caption_,const double angle_);
// Reduces the image to a limited number of colors for a "poster" effect.
void posterize(const size_t levels_,const bool dither_=false);
void posterizeChannel(const ChannelType channel_, const size_t levels_,
const bool dither_=false);
// Execute a named process module using an argc/argv syntax similar to
// that accepted by a C 'main' routine. An exception is thrown if the
// requested process module doesn't exist, fails to load, or fails during
// execution.
void process(std::string name_,const ::ssize_t argc_,const char **argv_);
// Add or remove a named profile to/from the image. Remove the
// profile by passing an empty Blob (e.g. Blob()). Valid names are
// "*", "8BIM", "ICM", "IPTC", or a user/format-defined profile name.
void profile(const std::string name_,const Blob &colorProfile_);
// Retrieve a named profile from the image. Valid names are:
// "8BIM", "8BIMTEXT", "APP1", "APP1JPEG", "ICC", "ICM", & "IPTC"
// or an existing user/format-defined profile name.
Blob profile(const std::string name_) const;
// Quantize image (reduce number of colors)
void quantize(const bool measureError_=false);
// Apply a value with an arithmetic, relational, or logical operator.
void quantumOperator(const ChannelType channel_,
const MagickEvaluateOperator operator_,double rvalue_);
// Apply a value with an arithmetic, relational, or logical operator.
void quantumOperator(const ChannelType channel_,
const MagickFunction function_,const size_t number_parameters_,
const double *parameters_);
// Apply a value with an arithmetic, relational, or logical operator.
void quantumOperator(const ::ssize_t x_,const ::ssize_t y_,
const size_t columns_,const size_t rows_,const ChannelType channel_,
const MagickEvaluateOperator operator_,const double rvalue_);
// Raise image (lighten or darken the edges of an image to give a
// 3-D raised or lowered effect)
void raise(const Geometry &geometry_=raiseGeometryDefault,
const bool raisedFlag_=false);
// Random threshold image.
//
// Changes the value of individual pixels based on the intensity
// of each pixel compared to a random threshold. The result is a
// low-contrast, two color image. The thresholds_ argument is a
// geometry containing LOWxHIGH thresholds. If the string
// contains 2x2, 3x3, or 4x4, then an ordered dither of order 2,
// 3, or 4 will be performed instead. If a channel_ argument is
// specified then only the specified channel is altered. This is
// a very fast alternative to 'quantize' based dithering.
void randomThreshold(const Geometry &thresholds_);
void randomThresholdChannel(const Geometry &thresholds_,
const ChannelType channel_);
// Read single image frame from in-memory BLOB
void read(const Blob &blob_);
// Read single image frame of specified size from in-memory BLOB
void read(const Blob &blob_,const Geometry &size_);
// Read single image frame of specified size and depth from
// in-memory BLOB
void read(const Blob &blob_,const Geometry &size_,const size_t depth_);
// Read single image frame of specified size, depth, and format
// from in-memory BLOB
void read(const Blob &blob_,const Geometry &size_,const size_t depth_,
const std::string &magick_);
// Read single image frame of specified size, and format from
// in-memory BLOB
void read(const Blob &blob_,const Geometry &size_,
const std::string &magick_);
// Read single image frame of specified size into current object
void read(const Geometry &size_,const std::string &imageSpec_);
// Read single image frame from an array of raw pixels, with
// specified storage type (ConstituteImage), e.g.
// image.read( 640, 480, "RGB", 0, pixels );
void read(const size_t width_,const size_t height_,const std::string &map_,
const StorageType type_,const void *pixels_);
// Read single image frame into current object
void read(const std::string &imageSpec_);
// Transfers one or more pixel components from a buffer or file
// into the image pixel cache of an image.
// Used to support image decoders.
void readPixels(const QuantumType quantum_,const unsigned char *source_);
// Reduce noise in image using a noise peak elimination filter
void reduceNoise(void);
void reduceNoise(const double order_);
// Resets the image page canvas and position.
void repage();
// Resize image in terms of its pixel size.
void resample(const Geometry &geometry_);
// Resize image to specified size.
void resize(const Geometry &geometry_);
// Roll image (rolls image vertically and horizontally) by specified
// number of columnms and rows)
void roll(const Geometry &roll_);
void roll(const size_t columns_,const size_t rows_);
// Rotate image clockwise by specified number of degrees. Specify a
// negative number for degrees to rotate counter-clockwise.
void rotate(const double degrees_);
// Rotational blur image.
void rotationalBlur(const double angle_);
void rotationalBlurChannel(const ChannelType channel_,
const double angle_);
// Resize image by using pixel sampling algorithm
void sample(const Geometry &geometry_);
// Resize image by using simple ratio algorithm
void scale(const Geometry &geometry_);
// Segment (coalesce similar image components) by analyzing the
// histograms of the color components and identifying units that
// are homogeneous with the fuzzy c-means technique. Also uses
// QuantizeColorSpace and Verbose image attributes
void segment(const double clusterThreshold_=1.0,
const double smoothingThreshold_=1.5);
// Selectively blur pixels within a contrast threshold. It is similar to
// the unsharpen mask that sharpens everything with contrast above a
// certain threshold.
void selectiveBlur(const double radius_,const double sigma_,
const double threshold_);
void selectiveBlurChannel(const ChannelType channel_,const double radius_,
const double sigma_,const double threshold_);
// Separates a channel from the image and returns it as a grayscale image.
Image separate(const ChannelType channel_) const;
// Applies a special effect to the image, similar to the effect achieved in
// a photo darkroom by sepia toning. Threshold ranges from 0 to
// QuantumRange and is a measure of the extent of the sepia toning.
// A threshold of 80% is a good starting point for a reasonable tone.
void sepiaTone(const double threshold_);
// Allocates a pixel cache region to store image pixels as defined
// by the region rectangle. This area is subsequently transferred
// from the pixel cache to the image via syncPixels.
PixelPacket *setPixels(const ::ssize_t x_,const ::ssize_t y_,
const size_t columns_,const size_t rows_);
// Shade image using distant light source
void shade(const double azimuth_=30,const double elevation_=30,
const bool colorShading_=false);
// Simulate an image shadow
void shadow(const double percent_opacity_=80.0,const double sigma_=0.5,
const ssize_t x_=5,const ssize_t y_=5);
// Sharpen pixels in image
// The radius_ parameter specifies the radius of the Gaussian, in
// pixels, not counting the center pixel. The sigma_ parameter
// specifies the standard deviation of the Laplacian, in pixels.
void sharpen(const double radius_=0.0,const double sigma_=1.0);
void sharpenChannel(const ChannelType channel_,const double radius_=0.0,
const double sigma_=1.0);
// Shave pixels from image edges.
void shave(const Geometry &geometry_);
// Shear image (create parallelogram by sliding image by X or Y axis)
void shear(const double xShearAngle_,const double yShearAngle_);
// adjust the image contrast with a non-linear sigmoidal contrast algorithm
void sigmoidalContrast(const size_t sharpen_,const double contrast,
const double midpoint=QuantumRange/2.0);
// Image signature. Set force_ to true in order to re-calculate
// the signature regardless of whether the image data has been
// modified.
std::string signature(const bool force_=false) const;
// Simulates a pencil sketch. We convolve the image with a Gaussian
// operator of the given radius and standard deviation (sigma). For
// reasonable results, radius should be larger than sigma. Use a
// radius of 0 and SketchImage() selects a suitable radius for you.
void sketch(const double radius_=0.0,const double sigma_=1.0,
const double angle_=0.0);
// Solarize image (similar to effect seen when exposing a
// photographic film to light during the development process)
void solarize(const double factor_=50.0);
// Sparse color image, given a set of coordinates, interpolates the colors
// found at those coordinates, across the whole image, using various
// methods.
void sparseColor(const ChannelType channel,const SparseColorMethod method,
const size_t number_arguments,const double *arguments);
// Splice the background color into the image.
void splice(const Geometry &geometry_);
void splice(const Geometry &geometry_,const Color &backgroundColor_);
void splice(const Geometry &geometry_,const Color &backgroundColor_,
const GravityType gravity_);
// Spread pixels randomly within image by specified ammount
void spread(const size_t amount_=3);
void statistics(ImageStatistics *statistics) const;
// Add a digital watermark to the image (based on second image)
void stegano(const Image &watermark_);
// Create an image which appears in stereo when viewed with
// red-blue glasses (Red image on left, blue on right)
void stereo(const Image &rightImage_);
// Strip strips an image of all profiles and comments.
void strip(void);
// Search for the specified image at EVERY possible location in this image.
// This is slow! very very slow.. It returns a similarity image such that
// an exact match location is completely white and if none of the pixels
// match, black, otherwise some gray level in-between.
Image subImageSearch(const Image &reference_,const MetricType metric_,
Geometry *offset_,double *similarityMetric_,
const double similarityThreshold=(-1.0));
// Swirl image (image pixels are rotated by degrees)
void swirl(const double degrees_);
// Transfers the image cache pixels to the image.
void syncPixels(void);
// Channel a texture on image background
void texture(const Image &texture_);
// Threshold image
void threshold(const double threshold_);
// Resize image to thumbnail size
void thumbnail(const Geometry &geometry_);
// Applies a color vector to each pixel in the image. The length of the
// vector is 0 for black and white and at its maximum for the midtones.
// The vector weighting function is f(x)=(1-(4.0*((x-0.5)*(x-0.5))))
void tint(const std::string opacity_);
// Transform image based on image and crop geometries
// Crop geometry is optional
void transform(const Geometry &imageGeometry_);
void transform(const Geometry &imageGeometry_,
const Geometry &cropGeometry_);
// Origin of coordinate system to use when annotating with text or drawing
void transformOrigin(const double x_,const double y_);
// Reset transformation parameters to default
void transformReset(void);
// Scale to use when annotating with text or drawing
void transformScale(const double sx_,const double sy_);
// Add matte image to image, setting pixels matching color to
// transparent
void transparent(const Color &color_);
// Add matte image to image, for all the pixels that lies in between
// the given two color
void transparentChroma(const Color &colorLow_,const Color &colorHigh_);
// Creates a horizontal mirror image by reflecting the pixels around the
// central y-axis while rotating them by 90 degrees.
void transpose(void);
// Creates a vertical mirror image by reflecting the pixels around the
// central x-axis while rotating them by 270 degrees.
void transverse(void);
// Trim edges that are the background color from the image
void trim(void);
// Returns the unique colors of an image.
Image uniqueColors(void) const;
// Replace image with a sharpened version of the original image
// using the unsharp mask algorithm.
// radius_
// the radius of the Gaussian, in pixels, not counting the
// center pixel.
// sigma_
// the standard deviation of the Gaussian, in pixels.
// amount_
// the percentage of the difference between the original and
// the blur image that is added back into the original.
// threshold_
// the threshold in pixels needed to apply the diffence amount.
void unsharpmask(const double radius_,const double sigma_,
const double amount_,const double threshold_);
void unsharpmaskChannel(const ChannelType channel_,const double radius_,
const double sigma_,const double amount_,const double threshold_);
// Softens the edges of the image in vignette style.
void vignette(const double radius_=0.0,const double sigma_=1.0,
const ssize_t x_=0,const ssize_t y_=0);
// Map image pixels to a sine wave
void wave(const double amplitude_=25.0,const double wavelength_=150.0);
// Removes noise from the image using a wavelet transform.
void waveletDenoise(const double threshold_,const double softness_);
// Forces all pixels above the threshold into white while leaving all
// pixels at or below the threshold unchanged.
void whiteThreshold(const std::string &threshold_);
void whiteThresholdChannel(const ChannelType channel_,
const std::string &threshold_);
// Write single image frame to in-memory BLOB, with optional
// format and adjoin parameters.
void write(Blob *blob_);
void write(Blob *blob_,const std::string &magick_);
void write(Blob *blob_,const std::string &magick_,const size_t depth_);
// Write single image frame to an array of pixels with storage
// type specified by user (DispatchImage), e.g.
// image.write( 0, 0, 640, 1, "RGB", 0, pixels );
void write(const ::ssize_t x_,const ::ssize_t y_,const size_t columns_,
const size_t rows_,const std::string& map_,const StorageType type_,
void *pixels_);
// Write single image frame to a file
void write(const std::string &imageSpec_);
// Transfers one or more pixel components from the image pixel
// cache to a buffer or file.
// Used to support image encoders.
void writePixels(const QuantumType quantum_,unsigned char *destination_);
// Zoom image to specified size.
void zoom(const Geometry &geometry_);
//////////////////////////////////////////////////////////////////////
//
// No user-serviceable parts beyond this point
//
//////////////////////////////////////////////////////////////////////
// Construct with MagickCore::Image and default options
Image(MagickCore::Image *image_);
// Retrieve Image*
MagickCore::Image *&image(void);
const MagickCore::Image *constImage(void) const;
// Retrieve ImageInfo*
MagickCore::ImageInfo *imageInfo(void);
const MagickCore::ImageInfo *constImageInfo(void) const;
// Retrieve Options*
Options *options(void);
const Options *constOptions(void) const;
// Retrieve QuantizeInfo*
MagickCore::QuantizeInfo *quantizeInfo(void);
const MagickCore::QuantizeInfo *constQuantizeInfo(void) const;
// Prepare to update image (copy if reference > 1)
void modifyImage(void);
// Replace current image (reference counted)
MagickCore::Image *replaceImage(MagickCore::Image *replacement_);
// Test for ImageMagick error and throw exception if error
void throwImageException(void) const;
private:
void read(MagickCore::Image *image,
MagickCore::ExceptionInfo *exceptionInfo);
void floodFill(const ssize_t x_,const ssize_t y_,
const Magick::Image *fillPattern_,const Color &fill_,
const MagickCore::PixelPacket *target,const bool invert_);
ImageRef *_imgRef;
};
} // end of namespace Magick
//
// Inlines
//
inline Magick::ClassType Magick::Image::classType(void) const
{
return static_cast<Magick::ClassType>(constImage()->storage_class);
}
inline size_t Magick::Image::columns(void) const
{
return constImage()->columns;
}
inline void Magick::Image::lineWidth(const double lineWidth_)
{
strokeWidth(lineWidth_);
}
inline double Magick::Image::lineWidth(void) const
{
return strokeWidth();
}
inline void Magick::Image::reduceNoise(void)
{
reduceNoise(3.0);
}
inline size_t Magick::Image::rows(void) const
{
return constImage()->rows;
}
#endif // Magick_Image_header
|
6cf6efccff5b955ce9208f6e149b6e11bca7216d
|
bd93b9171602a2eef8b301fc0460fd455d9fc29c
|
/Source/RTSCapstone/Projectile.h
|
11d0916bcf52669bf09d7744fbb90d50d34693d5
|
[] |
no_license
|
ReyndertLindeyer/RTSCapstone
|
43f9a6de2ef9afa97d3c8944044d13eba156da18
|
7c8f995c8485fa33363f3e6ccd912c7b85795831
|
refs/heads/master
| 2020-04-17T15:34:49.024072
| 2019-10-22T01:01:43
| 2019-10-22T01:01:43
| 166,704,307
| 1
| 0
| null | 2019-04-17T01:55:27
| 2019-01-20T20:10:19
|
C++
|
UTF-8
|
C++
| false
| false
| 1,749
|
h
|
Projectile.h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Engine/StaticMesh.h"
#include "Components/SphereComponent.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/Particles/ParticleSystemComponent.h"
#include "I_Entity.h"
#include "Projectile.generated.h"
UENUM()
enum PROJECTILE_TYPE
{
CANNON,
MISSILE,
};
UCLASS()
class RTSCAPSTONE_API AProjectile : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AProjectile();
void InitializeProjectile(PROJECTILE_TYPE type, FVector targetPosition, float damage, float travelSpeed, float travelDistance, float blastRadius, UParticleSystem* particleSystemA, UParticleSystem* particleSystemB);
void InitializeProjectile(PROJECTILE_TYPE type, FVector targetPosition, float damage, float travelSpeed, float travelDistance, float blastRadius, UParticleSystem* particleSystemA, UParticleSystem* particleSystemB, bool shouldArc);
bool reachedTarget;
float countdown;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UStaticMeshComponent* staticMesh;
PROJECTILE_TYPE projectileType;
float projectileDamage;
FVector targetPosition;
FVector initialPosition;
float travelTime;
float travelDistance;
float blastRadius;
bool arcing;
UPROPERTY()
UParticleSystemComponent* particleComp;
UPROPERTY()
USphereComponent* root;
//The particle system that will be the reaction at the end, ex the explosion when the rocket connects
UParticleSystem* reactionPS;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
|
092167c3a1ab148e3aff82aefb7e8540573fe96a
|
5a0de8d575dd64116e9e13be32cb9a86f0c682e7
|
/leetcode 404.cpp
|
efd25148005dbcb0ffb0476eb458c2248a4addb4
|
[] |
no_license
|
sailll/leetcode-solution-by-myself
|
246499095b798e6a2789ad5d03fc4772ab897c1d
|
15f8fb94c614dba7fe42725a50ae082487da0374
|
refs/heads/master
| 2021-05-22T10:01:27.305761
| 2020-07-13T05:06:06
| 2020-07-13T05:06:06
| 54,723,761
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 585
|
cpp
|
leetcode 404.cpp
|
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
bool judgeleaf(TreeNode* node){
if(!node) return false;
if(!node->left&&!node->right) return true;
else return false;
}
int sumOfLeftLeaves(TreeNode* root) {
if(!root) return 0;
int tmp=judgeleaf(root->left)?root->left->val:0;
return tmp+sumOfLeftLeaves(root->left)+sumOfLeftLeaves(root->right);
}
};
|
6365970bf3fd23f1dd8778c6109393758013ce90
|
d9c9095e837a6f22377a89bd8b88e1ba8ac79ca6
|
/luogu/P1002 过河卒.cpp
|
d2f4636802445efecb9a838475da7914acdcd059
|
[] |
no_license
|
alexcui03/luogu-test
|
3ade46adb43adf50a8f2b40dfde83d399116f0fa
|
7614ce64adcf5399181b113bcc571cdc84092f0f
|
refs/heads/master
| 2021-06-28T02:08:33.365736
| 2020-12-02T14:47:01
| 2020-12-02T14:47:01
| 177,288,367
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 836
|
cpp
|
P1002 过河卒.cpp
|
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define pos(x, y) ((y) * (n + 1) + (x))
int main() {
int n, m, hx, hy;
cin >> n >> m >> hx >> hy;
++m, ++n;
long long *map = new long long[(n + 1) * (m + 1)];
memset(map, 0, (n + 1) * (m + 1) * sizeof(long long));
map[0] = 1;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (i == hy && j == hx)
continue;
if (abs(i - hy) == 1 && abs(j - hx) == 2)
continue;
if (abs(i - hy) == 2 && abs(j - hx) == 1)
continue;
map[pos(j, i + 1)] += map[pos(j, i)];
map[pos(j + 1, i)] += map[pos(j, i)];
}
}
cout << map[pos(n - 1, m - 1)] << endl;
return 0;
}
|
c677bfde39080e4ee34cd829cbff2cdf77fbe4e9
|
3256fe097cbd5db139b11971c1e260fec330ba83
|
/linux_advc/add_two_numbers.cc
|
3fbbb634538b2409f99db4ae7e443ccf623a6028
|
[] |
no_license
|
herywang/algorithmUnlock
|
410fa4fd3914910d1cfbfecc9984732f53eb2717
|
df29078cc9576ebe5811105cae7ef8e59015df86
|
refs/heads/master
| 2022-04-26T12:39:32.433318
| 2020-04-30T02:55:36
| 2020-04-30T02:55:36
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,629
|
cc
|
add_two_numbers.cc
|
#include <iostream>
/*
You are given two non-empty linked lists representing two non-negative integers.
The digits are stored in reverse order and each of their nodes contain a single digit.
Add the two numbers and return it as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Example:
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8
Explanation: 342 + 465 = 807.
*/
/**
* 时间复杂度: O(n), 空间复杂度: O(1)
**/
struct ListNode {
int val;
ListNode* next;
ListNode(int x)
: val(x)
, next(NULL)
{
}
ListNode() {}
ListNode(int x, ListNode* next)
: val(x)
, next(next)
{
}
};
typedef struct ListNode ListNode;
class Solution {
public:
Solution() {}
~Solution() = default;
ListNode* add_two_numbers(ListNode* l1, ListNode* l2)
{
ListNode* p1 = l1;
ListNode* p2 = l2;
ListNode *p1_pre, *p2_pre;
int tmp = 0;
while (p1 != NULL and p2 != NULL) {
if (p1->val + p2->val + tmp <= 9) {
p2->val = p2->val + p1->val + tmp;
tmp = 0;
} else {
p2->val = (p2->val + p1->val + tmp - 10);
tmp = 1;
}
p1_pre = p1;
p2_pre = p2;
p1 = p1->next;
p2 = p2->next;
}
if (p1 == NULL && p2 == NULL && tmp == 0) {
return l2;
}
ListNode* t = p1;
ListNode* t_pre;
if (p1 != NULL) {
t = p1;
while (t != NULL) {
if (t->val + tmp <= 9) {
t->val = t->val + tmp;
p2_pre->next = p1;
tmp = 0;
return l2;
} else {
t->val = t->val + tmp - 10;
tmp = 1;
}
t_pre = t;
t = t->next;
}
ListNode* node = new ListNode;
node->val = tmp;
node->next = NULL;
t_pre->next = node;
p2_pre->next = p1;
} else if (p2 != NULL) {
t = p2;
while (t != NULL) {
if (t->val + tmp <= 9) {
t->val = t->val + tmp;
tmp = 0;
return l2;
} else {
t->val = t->val + tmp - 10;
tmp = 1;
t_pre = t;
t = t->next;
}
}
ListNode* node = new ListNode;
node->val = tmp;
node->next = NULL;
t_pre->next = node;
} else {
ListNode* node = new ListNode;
node->val = tmp;
node->next = NULL;
p2_pre->next = node;
}
return l2;
}
};
void free_node(ListNode* node)
{
ListNode* p = node;
ListNode* tmp;
while (p != NULL) {
tmp = p;
p = p->next;
free(tmp);
}
}
int main()
{
ListNode* node1 = new ListNode(9, NULL);
ListNode* node2 = new ListNode(9, node1);
ListNode* node3 = new ListNode(9, NULL);
ListNode* node4 = new ListNode();
ListNode* node5 = new ListNode();
ListNode* node6 = new ListNode();
Solution* solu = new Solution();
ListNode* result = solu->add_two_numbers(node2, node3);
ListNode* t = result;
while (t != NULL) {
std::cout << t->val << "->";
t = t->next;
}
std::cout << std::endl;
free_node(node1);
free_node(node4);
}
|
0a31d732dc7ba2ad7f0a6a187f22f42bbbcce429
|
ae3b01cde0a051d17454ff6079338adb6871bc8c
|
/practise.cpp
|
f477383b2c820731281b6850f6fd2f6e978eb830
|
[] |
no_license
|
Pratiksha-chokhar/Pg-Dac-CPP
|
0b1ce0855ec602e2455a25680fef4d485e0168f3
|
b9ede29a2aafd4546e09e98ae0857fd6d24431d5
|
refs/heads/master
| 2020-05-15T17:49:35.704553
| 2019-04-20T13:39:12
| 2019-04-20T13:39:12
| 182,411,334
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,146
|
cpp
|
practise.cpp
|
/*int main()
{
char name[20];
printf("Enter name: ");
scanf("%s", name);
printf("Your name is %s.", name);
return 0;
}*/
#include <stdio.h>
/*int main(void) {
char name[] = "Harry Potter";
printf("%c", *name); // Output: H
printf("%c", *(name+1)); // Output: a
printf("%c", *(name+7)); // Output: o
char *namePtr;
namePtr = name;
printf("%c", *namePtr); // Output: H
printf("%c", *(namePtr+1)); // Output: a
printf("%c", *(namePtr+7)); // Output: o
}
*/
int main()
{
/*int i,j,s,n;
printf("enter the level of pattern:");
scanf("%d",&n);
s=n;
for(i=1;i<=n;i++)
{
for(j=1;j<s;j++)
printf(" ");
s--;
for(j=1;j<2*i-1;j++)
printf("*");
printf("\n");
}*/
int row, c, n, s;
printf("Enter the number of rows in pyramid of stars you wish to see\n");
scanf("%d", &n);
s = n;
for (row = 1; row <= n; row++) // Loop to print rows
{
for (c = 1; c < s; c++) // Loop to print spaces in a row
printf(" ");
s--;
for (c = 1; c <= 2*row - 1; c++) // Loop to print stars in a row
printf("*");
printf("\n");
}
return 0;
}
|
6ab29befe96fb62599fa37ef3b99c3f794410333
|
569007d9fc5eef66f5a8c6a4b1b90576ab96dd8c
|
/2014/c++ tutorial/map-multimap/STLmap2.cpp
|
be4da03971e2b77c9151677961cfe6ecb55513c2
|
[] |
no_license
|
SUDHARSHAN99/top20
|
917683dcf49d2e5394eaf07fbd67afac6a7cd780
|
4ff0f28d650a7c212bd9a606a673c6af618a532b
|
refs/heads/master
| 2020-05-04T04:44:27.590605
| 2019-03-30T02:16:40
| 2019-03-30T02:16:40
| 178,972,411
| 1
| 0
| null | 2019-04-02T01:07:05
| 2019-04-02T01:07:05
| null |
UTF-8
|
C++
| false
| false
| 433
|
cpp
|
STLmap2.cpp
|
#include<iostream>
#include<map>
#include<string>
using namespace std;
int main() {
map<int, string> m;
m.insert(make_pair(10,"abc"));
m.insert(make_pair(20,"xyz"));
m.insert(make_pair(15,"pqr"));
m.insert(make_pair(25,"def"));
map<int,string>::iterator res = m.find(20);
if(res==m.end()) cout<<"Element mapping not found"<<endl;
else cout<<"Element mapping:"<<res->second<<endl;
getchar();
}
|
787e7ea6483a68e39fc7973ef6f7b88dd4181330
|
da1ef5b8f357a1d3ad6109248e9c6006d4e7dc36
|
/include/errors.h
|
58aeb4109c22671638c9c980c593657beeeaafb3
|
[] |
no_license
|
Wombozo/harmony
|
24adaae40e77132daae72ef5e83334b1acb8f4fd
|
cb183425985f4b6aaa18f37999416affef7954eb
|
refs/heads/master
| 2020-05-20T15:39:30.991971
| 2019-05-24T13:30:07
| 2019-05-24T13:30:07
| 185,649,283
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 245
|
h
|
errors.h
|
#ifndef _ERRORS
#define _ERRORS
#include <string>
typedef enum
{
E_INTERVAL,
E_CHORD_UNKNOWN,
E_INVERSION,
E_SCALE_UNKNOWN,
E_CHOICE,
E_DEGREE_NOT_FOUND,
E_TYPE,
} H_ERR;
std::string handle_H_ERR(H_ERR e);
#endif
|
1490db9c9845b82ed9e9b9de691ca79ffd7597e8
|
0767851881d0bf4eee61fecbf0ddd9b359824d4d
|
/170/NeedsOrganized/Miscellaneous/misc_License.cpp
|
08f35e7352f35b1ce76275b7a1cad690dd2ad586
|
[] |
no_license
|
mshafer1/SteilHU
|
40e41ac6cb738b2ef063f8a21a08a8750bafdc93
|
b3897023dab9a372122c4cf732b5f783e19e0a62
|
refs/heads/master
| 2021-01-15T21:49:07.785393
| 2019-09-04T02:53:20
| 2019-09-04T02:53:20
| 6,246,636
| 0
| 0
| null | 2019-09-04T02:53:21
| 2012-10-16T15:28:32
|
C++
|
WINDOWS-1252
|
C++
| false
| false
| 1,544
|
cpp
|
misc_License.cpp
|
//this program is an example test question and answer
#include<iostream>
#include<string>
#include<fstream>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::ifstream;
//7. A witness to a bank robbery recalls that the license number
//of the get away car was xxx-SUN, where xxx represents 3 letters
//or digits which were not clearly visible. The state police have
//a disk file named LICENSE.DAT which contains information on every
//license number in the state. The file is a text file, and each
//line in the file contains a license number followed by a comma,
//the name of the vehicle’s owner, and the end of line character. (20 points)
//
//Note:
//• There is no space between the license, the comma, and the name.
//• No license number may contain a comma.
//• Not all license numbers are the same length.
//• Not all license numbers contain a dash.
//
//Write a complete C++ program that will print to screen the license number
//and the owner’s name of all licenses that could possibly match the get-away car.
//(You may use the back of this page.)
int main()
{
const char FILE_NAME[] = "LICENSE.DAT";
ifstream fin(FILE_NAME);
if(!fin.fail())
{
while(!fin.eof())
{
string line;
getline(fin,line);
if(line.find("-SUN,") != string::npos)
{
cout << line << endl;
}
}
fin.close();
}
else
{
cout << "Unable to find " << FILE_NAME << endl;
}
cin.get();
return 0;
}
|
3f5735f0619c5932110f4895e4caf513adb5f66d
|
257f7753fd1a12c08090aacc6bdef032297d9af8
|
/wb32v10.cpp
|
bd913e443c80bf49a5c6da31786ad4c1dc485e47
|
[] |
no_license
|
samsuanchen/wb32f10
|
53482d1ded7528cb436711dabc0e915a1d75085c
|
54cb84cc0f261ee5e4a80d9d9b542fc79b6db14d
|
refs/heads/master
| 2021-01-20T14:15:18.895776
| 2017-05-12T03:05:25
| 2017-05-12T03:05:25
| 90,573,448
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,307
|
cpp
|
wb32v10.cpp
|
#include "wb32v10.h"
void WB32V10::tibOpen () { tibBegin=tibEnd=tib,tibLimit=tib+TIB_SIZE-1; } // init tib and wait for input
void WB32V10::tibClose () { *tibEnd='\0'; } // add '\0' at end of input
void WB32V10::tibPop () { --tibEnd; } // pop last input character
void WB32V10::tibPush (char c) { *(tibEnd++)=c; } // collect input character
/////////////////////////////////////////////////////////////////////////////////////////////////////////
boolean WB32V10::EOL (char c) { return c=='\n'||c=='\r'; } // check if c is end of line
boolean WB32V10::backSpace (char c) { return c=='\b'; } // check if c is back space
boolean WB32V10::whiteSpace (char c) { return c==' '||c=='\t'||c=='\n'||c=='\r'; } // check if c is white space
boolean WB32V10::tibEmpty (){ return tibEnd==tibBegin; } // check if buffer is empty
boolean WB32V10::tibFull (){ return tibEnd==tibLimit; } // check if buffer is full
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void WB32V10::waitInput() { // read input characters until end of line
while ( !AVAILABLE() ); // wait until input available
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
char* WB32V10::readLine() { // read input characters until end of line
tibOpen();
while ( AVAILABLE() ) {
char c=READ(); // get input char
if ( backSpace(c) ) { // if backspace ------------------------
if ( !tibEmpty() ) tibPop(), PRINTF("\b \b"); // erase last input char
} else if ( EOL(c) || tibFull() ) {
tibPush('\0');
return tib;
} else {
tibPush(c); // collect character c
WRITE(c);
waitInput(); // wait until input available
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void WB32V10::parseBegin(char *str){ parseRemain = tibBegin = str; tibEnd = tibBegin+strlen(str); }
char WB32V10::parseAvailable(){ return *parseRemain; } // non '\0' means available to parse
char* WB32V10::parseToken() { // use white spaces as delimiters to parse a token
char c = *parseRemain;
while ( c && whiteSpace(c) ) c = *++parseRemain; // ignore leading white spaces
char *start = parseRemain; // set start at non white space
if ( c ) {
while ( c && !whiteSpace(c) ) c = *++parseRemain; // colect non white spaces
char *limit = parseRemain; // set limit at white space
if ( c ) { // if not end of string
int n=limit-start;
if ( n>TMP_SIZE-1 ) { //
PRINTF("\n error WB32V10::parseToken length %d > %d\n",n,TMP_SIZE-1);
return start;
}
strncpy(tmp,start,n);
tmp[n] = '\0'; // add null as the end of string
start = tmp;
}
}
return start;
}
//.......................................................................................................
void WB32V10::interpret(char *line){
parseBegin(line);
while ( parseAvailable() ) {
char *token = parseToken();
eval(token);
}
PRINTF("\n");
}
//.......................................................................................................
void WB32V10::eval(char *token){
// extern Word, forth, getBase, vocSearch, hexPrefix, Serial.printf, dsPush
char *remain, *p=token, c;
Word* w=vocSearch(token);
if(w){ w->code(); return; }
int b=getBase(); if(remain=hexPrefix(token)) p=remain, b=16;
int n=strtol(p, &remain, b); // conver string at p to integer n on base b (*remain is an illigal digit)
if(c=*remain) PRINTF("\nerr %02d %s ? illigal '%c' at %d as base%d digit",++n,token,c,remain-token,b);
else dsPush(n);
}
//.......................................................................................................
void WB32V10::showDataStack(){ // show data stack info
PRINTF("< dsDepth %d [ ",dsDepth()); // show depth
if(dsDepth()>0){
if(dsDepth()>5)PRINTF(".. "); // showing at most top 5 items
for ( int *i=max(DP-4,DS); i<=DP; i++ ) PRINTF("%s ",toDigits(*i,B)); // show data
}
PRINTF("] base%d >\n",B); // show base
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
boolean WB32V10::dsHasItems (int n) { return DP >= DS+n-1 ; } // check if data stack has n items
boolean WB32V10::dsHasSpace (int n) { return DP+n <= DS+DS_DEPTH; } // check if data stack has space for n items
boolean WB32V10::dsFull () { return DP >= DS+DS_DEPTH ; } // check if data stack full
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void WB32V10::dsClear () { DP=DS-1 ; } // reset data stack
void WB32V10::dsPush (int n) { T=n, *(++DP)=T; } // push a number onto data stack
int WB32V10::dsPop () { return *DP-- ; } // pop a number from data stack
int WB32V10::dsDepth () { return DP-DS+1; } // depth of data stack
char WB32V10::toDigit (int x) { return x += x<10 ? 0x30 : 0x61-10; } // convert integer x into single digit
char* WB32V10::toDigits (uint x, int b) { // convert integer x into digits in given base b
char*p=tmp+TMP_SIZE; *(--p)='\0';
if(x==0){ *(--p)='0'; return p; }
boolean neg; if( neg=(b==10&&(int)x<0) ) x=-x;
while(x){
*(--p)=toDigit(x%b),x/=b; // convert current digit to character
}
if(neg) *(--p)='-';
return p;
}
void WB32V10::setBase (int base) { B=base; }; // set number convertion base
int WB32V10::getBase () {return B;}; // get number convertion base
char* WB32V10::hexPrefix(char *s) { // 0xff 0XFF $ff $FF $Ff are all acceptable as hexadecimal numbers
char c;
if((c=*s++) != '0' && c != '$') return 0;
if(c=='0' && (c=*s++) != 'x' && c != 'X') return 0;
return s; // remain string
}
Word* WB32V10::vocSearch (char *name) { // search name in dict
Word *w=getVoc()->last; while ( w && strcmp(w->name,name) ) w=w->prev; return w;
}
Voc* WB32V10::getVoc() {
return voc;
}
#define CONSOLE_WIDTH 80
//.......................................................................................................
void WB32V10::words(char*sub) { // show all word names having specific substring
PRINTF("\n");
int m=0, n;
Word *w=getVoc()->last;
while (w) {
if(!*sub || strstr(w->name,sub) ){
n=strlen(w->name);
if(m+n>CONSOLE_WIDTH)PRINTF("\n"), m=0;
if(m)PRINTF(" "), m++;
PRINTF(w->name), m+=n;
}
w=w->prev;
}
}
//.......................................................................................................
void WB32V10::see(Word *w) { // show the forth word
if(!w){ PRINTF(" ? undefinded "); return; }
PRINTF("\n----------------------");
PRINTF("\n%x prev %08x" ,&w->prev,w->prev );
PRINTF("\n%x name %08x %s" ,&w->name,w->name,w->name);
PRINTF("\n%x code %08x" ,&w->code,w->code );
PRINTF("\nforth primative word %s ", w->name );
}
//.......................................................................................................
void WB32V10::dump(int *a,int n) { // dump n cells at adr
// extern dsPop, PRINTF
int *lmt=a+n;
char *ba;
char *blmt;
for( ; a<lmt; a+=4) {
PRINTF("\n%8.8x : ", (int) a);
for(int i=0; i< 4; i++){
if( a+i>=lmt )PRINTF(" ");
else PRINTF("%8.8x ", *( a+i));
}
PRINTF(": ");
ba=(char*)a, blmt=(char*)lmt;
for(int i=0; i<16; i++){
if(ba+i>=blmt)PRINTF(" ");
else PRINTF("%2.2x ", *(ba+i));
}
PRINTF(": ");
for(int i=0; i<16; i++){
if(ba+i>=blmt)PRINTF(" ");
else {
char c=*(ba+i); n=(int)c;
if( n==0 ) c='.';
else if( n<0x20 || (n>0x7e&&n<0xa4) || n>0xc6 ) c='_';
else if(n>=0xa4&&n<=0xc6) { // head-byte of commmon big5
n=(int)*(ba+i+1);
if( n<0x40 || (n>0x7e&&n<0xa1) || n>0xfe) c='_'; // next is not tail-byte of commmon big5
else PRINTF("%c",c), c=(char)n, i++; // show head-byte of commmon big5 and get tail-byte
}
PRINTF("%c",c);
}
}
}
}
//.......................................................................................................
void WB32V10::vocInit (Word *last) {
voc = (Voc*) malloc(sizeof(Voc));
voc->last = last;
}
|
21c912957fdf3bc1c46c8655e7e2574131a89e27
|
fe79003d2aef8ce914c7730d81aa027037544560
|
/main.cpp
|
e464d435a33e0a51571c6d1b6e29ca6fa61a5ed0
|
[] |
no_license
|
imkiwa/calc
|
53386cb5e5f04f4e5b9dfc1f030a4b78688a08ea
|
ac1808db3b2672079fcbce2c9c68ef4a86ab0a1e
|
refs/heads/master
| 2021-06-08T01:22:47.427352
| 2016-11-27T03:08:24
| 2016-11-27T03:08:24
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,827
|
cpp
|
main.cpp
|
#include <iostream>
#include "config.h"
#include "expression.h"
#include "function.h"
#include "operator.h"
#include "var.h"
#include "varscope.h"
#define FARG __a
#define FRT __rt
#define FARGS const Args &FARG, int &FRT
#define FRETURN_VOID \
{ \
FRT = kiva::expression::RESULT_NONE; \
return Var(); \
}
using namespace std;
using namespace kiva::function;
using namespace kiva::var;
using namespace kiva::expression;
int main(int argc, char *argv[])
{
String s;
Var v;
int resultType;
bool running = true;
int exitValue = 0;
using F = FunctionTable;
F::linkFunction("exit", [&](FARGS) {
running = false;
exitValue = (!FARG.empty() && FARG[0].isValid())
? static_cast<int>(FARG[0].as<Real>())
: 0;
FRETURN_VOID;
});
F::linkFunction("table", [](FARGS) {
IFunction *func = nullptr;
int start = 0;
int end = 10;
int step = 1;
switch (FARG.size()) {
case 4:
step = static_cast<int>(FARG[3].as<Real>());
case 3:
end = static_cast<int>(FARG[2].as<Real>());
case 2:
start = static_cast<int>(FARG[1].as<Real>());
case 1:
func = F::getFunction(FARG[0].as<String>());
break;
default:
throw std::runtime_error("Too few arguments");
FRETURN_VOID;
}
if (!func) {
throw std::runtime_error("Function not found");
}
printf("Function %s\n", func->getName().c_str());
std::vector<Var> args;
args.push_back(Var(start));
int resultType;
for (; start <= end; start += step) {
args[0] = Var(static_cast<Real>(start));
printf(" x = %3d, y = %lf\n", start,
func->invoke(args, resultType).as<Real>());
}
FRETURN_VOID;
});
do {
printf("> ");
std::getline(std::cin, s);
try {
v = evalDirectly(s, resultType);
switch (resultType) {
case RESULT_BOOL:
printf("@: %s\n",
v.as<Real>() == 0 ? "false" : "true");
break;
case RESULT_NUMBER:
printf("@: %.2lf\n", v.as<Real>());
break;
case RESULT_STRING:
printf("@: %s\n", v.as<String>().c_str());
break;
}
} catch (std::exception &e) {
printf("!: %s\n", e.what());
}
} while (running && std::cin.good());
return exitValue;
}
|
6c3846b7124a27f144812303073d26e377640776
|
529fdade3c3c9c41adc7fbb463d732223310ef8a
|
/util.h
|
9342b479e11dc47fd8295f2fc64ae7aa580a4b12
|
[] |
no_license
|
qxzcode/Bedrock
|
e36a5084600124741ec9dfb404f972e4a3b8fea6
|
cbed879bf9b994220352d24c9c9cbe20192c3b4d
|
refs/heads/master
| 2021-01-20T13:55:50.429559
| 2017-02-21T20:04:57
| 2017-02-21T20:04:57
| 82,722,278
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 9,825
|
h
|
util.h
|
//
// util.h
// Bedrock
//
// Created by Quinn on 9/14/13.
// Copyright (c) 2013 Hexahedron Games. All rights reserved.
//
#pragma once
#include <string>
#include <stdlib.h>
#include "math.h"
#include <climits>
#include "ortho.h"
namespace util {
//// Graphics ////
void swapBuffers();
//// Maths ////
#define EXPAND_VEC3(vec) (vec).x, (vec).y, (vec).z
struct vec2f {
float x,y;
inline vec2f operator+(const vec2f& other) const {
return {x+other.x, y+other.y};
}
inline vec2f operator-(const vec2f& other) const {
return {x-other.x, y-other.y};
}
inline vec2f operator*(const vec2f& other) const {
return {x*other.x, y*other.y};
}
inline vec2f operator/(const vec2f& other) const {
return {x/other.x, y/other.y};
}
inline vec2f operator+(const float& f) const {
return {x+f, y+f};
}
inline vec2f operator-(const float& f) const {
return {x-f, y-f};
}
inline vec2f operator*(const float& d) const {
return {x*d, y*d};
}
inline vec2f operator/(const float& d) const {
return {x/d, y/d};
}
inline bool operator==(const vec2f& other) const {
return x==other.x && y==other.y;
}
inline bool operator!=(const vec2f& other) const {
return !operator==(other);
}
inline float length() const {
return sqrtf((x*x) + (y*y));
}
inline vec2f normalize() const {
return *this/length();
}
inline float dot(const vec2f& other) const {
return (x*other.x) + (y*other.y);
}
};
struct vec3i {
int x,y,z;
inline vec3i operator+(const vec3i& other) const {
return {x+other.x, y+other.y, z+other.z};
}
inline vec3i operator-(const vec3i& other) const {
return {x-other.x, y-other.y, z-other.z};
}
inline vec3i operator+(const int& i) const {
return {x+i, y+i, z+i};
}
inline vec3i operator-(const int& i) const {
return {x-i, y-i, z-i};
}
inline vec3i operator*(const int& d) const {
return {x*d, y*d, z*d};
}
inline bool operator==(const vec3i& other) const {
return x==other.x && y==other.y && z==other.z;
}
inline bool operator!=(const vec3i& other) const {
return !operator==(other);
}
inline float length() const {
return sqrtf((x*x) + (y*y) + (z*z));
}
};
struct vec3f {
float x,y,z;
inline vec3f operator+(const vec3f& other) const {
return {x+other.x, y+other.y, z+other.z};
}
inline vec3f operator-(const vec3f& other) const {
return {x-other.x, y-other.y, z-other.z};
}
inline vec3f operator*(const vec3f& other) const {
return {x*other.x, y*other.y, z*other.z};
}
inline vec3f operator/(const vec3f& other) const {
return {x/other.x, y/other.y, z/other.z};
}
inline vec3f operator+(const float& f) const {
return {x+f, y+f, z+f};
}
inline vec3f operator-(const float& f) const {
return {x-f, y-f, z-f};
}
inline vec3f operator*(const float& d) const {
return {x*d, y*d, z*d};
}
inline vec3f operator/(const float& d) const {
return {x/d, y/d, z/d};
}
inline bool operator==(const vec3f& other) const {
return x==other.x && y==other.y && z==other.z;
}
inline bool operator!=(const vec3f& other) const {
return !operator==(other);
}
inline float length() const {
return sqrtf((x*x) + (y*y) + (z*z));
}
inline vec3f normalize() const {
return *this/length();
}
inline float dot(const vec3f& other) const {
return (x*other.x) + (y*other.y) + (z*other.z);
}
// casting to/from vec3i
vec3f() {}
vec3f(float x, float y, float z):x(x),y(y),z(z) {}
vec3f(const vec3i& v):x(v.x),y(v.y),z(v.z) {}
operator vec3i() const {
return {static_cast<int>(x), static_cast<int>(y), static_cast<int>(z)};
}
};
struct vec4f {
float x,y,z,w;
inline vec4f operator+(const vec4f& other) const {
return {x+other.x, y+other.y, z+other.z, w+other.w};
}
inline vec4f operator-(const vec4f& other) const {
return {x-other.x, y-other.y, z-other.z, w-other.w};
}
inline vec4f operator*(const float& d) const {
return {x*d, y*d, z*d, w*d};
}
inline vec4f operator/(const float& d) const {
return {x/d, y/d, z/d, w/d};
}
inline bool operator==(const vec4f& other) const {
return x==other.x && y==other.y && z==other.z && w==other.w;
}
inline bool operator!=(const vec4f& other) const {
return !operator==(other);
}
inline float length() const {
return sqrtf((x*x) + (y*y) + (z*z) + (w*w));
}
inline vec4f normalize() const {
return *this/length();
}
inline vec3f xyz() const {
return {x, y, z};
}
};
struct mat4f {
float mat[16]; // "column major order"
mat4f() {}
mat4f(float m[16]) {
for (int i = 0; i < 16; i++)
mat[i] = m[i];
}
inline vec4f operator*(const vec4f& vec) {
vec4f res;
res.x = mat[0]*vec.x + mat[4]*vec.y + mat[8]*vec.z + mat[12]*vec.w;
res.y = mat[1]*vec.x + mat[5]*vec.y + mat[9]*vec.z + mat[13]*vec.w;
res.z = mat[2]*vec.x + mat[6]*vec.y + mat[10]*vec.z + mat[14]*vec.w;
res.w = mat[3]*vec.x + mat[7]*vec.y + mat[11]*vec.z + mat[15]*vec.w;
return res;
}
inline mat4f inverse() {
float inv[16], det;
int i;
inv[0] = mat[5] * mat[10] * mat[15] -
mat[5] * mat[11] * mat[14] -
mat[9] * mat[6] * mat[15] +
mat[9] * mat[7] * mat[14] +
mat[13] * mat[6] * mat[11] -
mat[13] * mat[7] * mat[10];
inv[4] = -mat[4] * mat[10] * mat[15] +
mat[4] * mat[11] * mat[14] +
mat[8] * mat[6] * mat[15] -
mat[8] * mat[7] * mat[14] -
mat[12] * mat[6] * mat[11] +
mat[12] * mat[7] * mat[10];
inv[8] = mat[4] * mat[9] * mat[15] -
mat[4] * mat[11] * mat[13] -
mat[8] * mat[5] * mat[15] +
mat[8] * mat[7] * mat[13] +
mat[12] * mat[5] * mat[11] -
mat[12] * mat[7] * mat[9];
inv[12] = -mat[4] * mat[9] * mat[14] +
mat[4] * mat[10] * mat[13] +
mat[8] * mat[5] * mat[14] -
mat[8] * mat[6] * mat[13] -
mat[12] * mat[5] * mat[10] +
mat[12] * mat[6] * mat[9];
inv[1] = -mat[1] * mat[10] * mat[15] +
mat[1] * mat[11] * mat[14] +
mat[9] * mat[2] * mat[15] -
mat[9] * mat[3] * mat[14] -
mat[13] * mat[2] * mat[11] +
mat[13] * mat[3] * mat[10];
inv[5] = mat[0] * mat[10] * mat[15] -
mat[0] * mat[11] * mat[14] -
mat[8] * mat[2] * mat[15] +
mat[8] * mat[3] * mat[14] +
mat[12] * mat[2] * mat[11] -
mat[12] * mat[3] * mat[10];
inv[9] = -mat[0] * mat[9] * mat[15] +
mat[0] * mat[11] * mat[13] +
mat[8] * mat[1] * mat[15] -
mat[8] * mat[3] * mat[13] -
mat[12] * mat[1] * mat[11] +
mat[12] * mat[3] * mat[9];
inv[13] = mat[0] * mat[9] * mat[14] -
mat[0] * mat[10] * mat[13] -
mat[8] * mat[1] * mat[14] +
mat[8] * mat[2] * mat[13] +
mat[12] * mat[1] * mat[10] -
mat[12] * mat[2] * mat[9];
inv[2] = mat[1] * mat[6] * mat[15] -
mat[1] * mat[7] * mat[14] -
mat[5] * mat[2] * mat[15] +
mat[5] * mat[3] * mat[14] +
mat[13] * mat[2] * mat[7] -
mat[13] * mat[3] * mat[6];
inv[6] = -mat[0] * mat[6] * mat[15] +
mat[0] * mat[7] * mat[14] +
mat[4] * mat[2] * mat[15] -
mat[4] * mat[3] * mat[14] -
mat[12] * mat[2] * mat[7] +
mat[12] * mat[3] * mat[6];
inv[10] = mat[0] * mat[5] * mat[15] -
mat[0] * mat[7] * mat[13] -
mat[4] * mat[1] * mat[15] +
mat[4] * mat[3] * mat[13] +
mat[12] * mat[1] * mat[7] -
mat[12] * mat[3] * mat[5];
inv[14] = -mat[0] * mat[5] * mat[14] +
mat[0] * mat[6] * mat[13] +
mat[4] * mat[1] * mat[14] -
mat[4] * mat[2] * mat[13] -
mat[12] * mat[1] * mat[6] +
mat[12] * mat[2] * mat[5];
inv[3] = -mat[1] * mat[6] * mat[11] +
mat[1] * mat[7] * mat[10] +
mat[5] * mat[2] * mat[11] -
mat[5] * mat[3] * mat[10] -
mat[9] * mat[2] * mat[7] +
mat[9] * mat[3] * mat[6];
inv[7] = mat[0] * mat[6] * mat[11] -
mat[0] * mat[7] * mat[10] -
mat[4] * mat[2] * mat[11] +
mat[4] * mat[3] * mat[10] +
mat[8] * mat[2] * mat[7] -
mat[8] * mat[3] * mat[6];
inv[11] = -mat[0] * mat[5] * mat[11] +
mat[0] * mat[7] * mat[9] +
mat[4] * mat[1] * mat[11] -
mat[4] * mat[3] * mat[9] -
mat[8] * mat[1] * mat[7] +
mat[8] * mat[3] * mat[5];
inv[15] = mat[0] * mat[5] * mat[10] -
mat[0] * mat[6] * mat[9] -
mat[4] * mat[1] * mat[10] +
mat[4] * mat[2] * mat[9] +
mat[8] * mat[1] * mat[6] -
mat[8] * mat[2] * mat[5];
det = mat[0] * inv[0] + mat[1] * inv[4] + mat[2] * inv[8] + mat[3] * inv[12];
if (det == 0) {
printf("ERROR: matrix does not have an inverse\n");
return mat4f();
}
det = 1.0 / det;
mat4f res;
for (i = 0; i < 16; i++)
res.mat[i] = inv[i] * det;
return res;
}
};
struct AABB {
float cx, cy, cz, rx, ry, rz; // center coords and halfwidths
};
vec3i rayTrace(vec3f origin, vec3f direction, float radius, bool callback(int,int,int,vec3f));
vec3f rayToAABB(AABB box, vec3f rayOrigin, vec3f rayDir);
bool intersects(const AABB & a, const AABB & b);
float mod(float f1, float f2);
template <typename T> int sign(T val) {
return (T(0) < val) - (val < T(0));
}
//// Files & Data ////
void saveWorld();
void loadWorld();
bool fileExists(std::string path);
void intToBytes(int i, char* dst);
void intFromBytes(int& i, char* src);
std::string getDataDir();
bool createDirectory(std::string path);
void rleEncode(char* data, unsigned long dataLen, char* res, unsigned long& resLen);
void rleDecode(char* data, unsigned long dataLen, char* res, unsigned long& resLen, unsigned long limit = ULONG_MAX);
}
//// Operators ////
#define CONCAT_FUNCS(ntype) \
inline std::string operator+(std::string str, ntype n) {\
return str + ortho::toString(n);\
}\
inline std::string operator+(ntype n, std::string str) {\
return ortho::toString(n) + str;\
}
CONCAT_FUNCS(int)
CONCAT_FUNCS(long)
CONCAT_FUNCS(float)
CONCAT_FUNCS(double)
#undef CONCAT_FUNCS
|
345cbe2767e67b2154038c62dd0ce305569dccc2
|
f85d47fb4f24582dacf9ad96f262d4847ffe194f
|
/include/util/string.hpp
|
21712fd96f61d3c7ebd9fea831bd12225cfa0f1f
|
[] |
no_license
|
WalterCReel3/example-project
|
2490e6a2fa75aea82e22726d2facd9273c8877be
|
14b87ba20ec3227165a635022d409712b4758ff9
|
refs/heads/master
| 2021-01-10T14:32:56.001510
| 2016-02-18T00:32:12
| 2016-02-18T00:32:12
| 51,212,974
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 18,809
|
hpp
|
string.hpp
|
#ifndef __UTIL_STR_HPP__
#define __UTIL_STR_HPP__
#include <wchar.h>
#include <ctype.h>
#include <stdlib.h> // strtol(3)
#include <string.h>
#include <limits.h>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdexcept>
#include <vector>
#include <utility>
#include <util/logging.hpp>
//============================================================================
//
// String Tools
//
//============================================================================
namespace util
{
using namespace std;
static pointer_to_unary_function<int, int> is_alnum = ptr_fun(::isalnum);
static pointer_to_unary_function<int, int> is_alpha = ptr_fun(::isalpha);
static pointer_to_unary_function<int, int> is_ascii = ptr_fun(::isascii);
static pointer_to_unary_function<int, int> is_blank = ptr_fun(::isblank);
static pointer_to_unary_function<int, int> is_cntrl = ptr_fun(::iscntrl);
static pointer_to_unary_function<int, int> is_digit = ptr_fun(::isdigit);
static pointer_to_unary_function<int, int> is_graph = ptr_fun(::isgraph);
static pointer_to_unary_function<int, int> is_lower = ptr_fun(::islower);
static pointer_to_unary_function<int, int> is_print = ptr_fun(::isprint);
static pointer_to_unary_function<int, int> is_punct = ptr_fun(::ispunct);
static pointer_to_unary_function<int, int> is_space = ptr_fun(::isspace);
static pointer_to_unary_function<int, int> is_upper = ptr_fun(::isupper);
static pointer_to_unary_function<int, int> is_xdigit = ptr_fun(::isxdigit);
struct whitespace_tokenizer {
template<typename InputIterator, typename Container>
InputIterator operator()(InputIterator first, InputIterator last,
Container &result)
{
using namespace std;
first = find_if(first, last, not1(is_space));
if (first == last) {
return last;
}
InputIterator stop = find_if(first + 1, last, is_space);
copy(first, stop, back_inserter(result));
return stop;
}
void reset() {}
};
template<typename InputIterator, typename EqualityComparable>
InputIterator
find_escaped(InputIterator first, InputIterator last,
const EqualityComparable &value,
const EqualityComparable &escape_value)
{
for ( ; first != last; ++first) {
if (*first == escape_value) {
if (++first == last) {
break;
}
} else if (*first == value) {
break;
}
}
return first;
}
template<typename EqualityComparable>
struct escaped_find {
escaped_find(const EqualityComparable "e_marker,
const EqualityComparable &escape)
: quote_marker_(quote_marker),
escape_(escape) {}
bool operator()(const EqualityComparable &value)
{
if (escaped_character_) {
escaped_character_ = false;
return false;
}
if (value == quote_marker_) {
return true;
}
if (value == escape_) {
escaped_character_ = true;
}
return false;
}
EqualityComparable quote_marker_;
EqualityComparable escape_;
bool escaped_character_;
};
struct token_break {
template<typename EqualityComparable>
bool operator()(const EqualityComparable &value)
{
return (value == '\'') || (value == '"') || util::is_space(value);
}
};
template<typename Container>
struct quoted_whitespace_tokenizer {
typedef Container token_type;
template<typename InputIterator>
InputIterator operator()(InputIterator first, InputIterator last,
Container &result)
{
using namespace std;
typedef typename iterator_traits<InputIterator>::value_type value_t;
static const value_t single_quote = '\'';
static const value_t double_quote = '"';
static const value_t escape_marker = '\\';
first = find_if(first, last, not1(is_space));
if (first == last) {
return last;
}
InputIterator stop;
if (*first == single_quote) {
stop = find_escaped(first + 1, last, single_quote, escape_marker);
copy(first + 1, stop, back_inserter(result));
if (stop != last) {
++stop;
}
} else if (*first == double_quote) {
stop = find_escaped(first + 1, last, double_quote, escape_marker);
copy(first + 1, stop, back_inserter(result));
if (stop != last) {
++stop;
}
} else {
stop = find_if(first + 1, last, token_break());
copy(first, stop, back_inserter(result));
}
return stop;
}
void reset() {}
};
template<typename T>
struct tokenizer_traits {
typedef typename T::token_type token_type;
};
template<typename InputIterator, typename OutputIterator,
typename Tokenizer>
OutputIterator
tokenize(InputIterator first, InputIterator last,
OutputIterator result, Tokenizer tokr)
{
while (first != last) {
typename tokenizer_traits<Tokenizer>::token_type token;
first = tokr(first, last, token);
if (token.empty()) {
continue;
}
*result++ = token;
}
return result;
}
template<typename InputIterator, typename Parser,
typename Tokenizer>
void
parse(InputIterator first, InputIterator last,
Parser parser, Tokenizer tokr)
{
typedef typename tokenizer_traits<Tokenizer>::token_type token_t;
while (first != last) {
token_t token;
first = tokr(first, last, token);
if (token.empty()) {
continue;
}
parser(token);
}
parser(token_t());
}
template<typename InputIterator, typename Tokenizer>
struct token_generator
: public std::unary_function<typename tokenizer_traits<Tokenizer>::token_type,
void> {
public:
// using Concept PushbackToken
typedef typename tokenizer_traits<Tokenizer>::token_type token_type;
public:
token_generator(InputIterator first, InputIterator last, Tokenizer tokenizer)
: first_(first), last_(last), tokenizer_(tokenizer) {}
typename tokenizer_traits<Tokenizer>::token_type operator()(void)
{
typename tokenizer_traits<Tokenizer>::token_type token;
first_ = tokenizer_(first_, last_, token);
return token;
}
template<typename T>
void copy_position(T /* & */alternate_token_generator)
{
first_ = alternate_token_generator.first_;
last_ = alternate_token_generator.last_;
}
void push_back(typename tokenizer_traits<Tokenizer>::token_type token)
{
first_ = token.first;
}
public:
InputIterator first_;
InputIterator last_;
Tokenizer tokenizer_;
};
template<typename InputIterator, typename OutputIterator,
typename EqualityComparable>
inline
InputIterator
copy_until(InputIterator first, InputIterator last,
OutputIterator result, const EqualityComparable &value)
{
for ( ; first != last; ++first) {
if (*first == value) {
break;
}
*result++ = *first;
}
return first;
}
template<typename InputIterator, typename OutputIterator,
typename Predicate>
InputIterator
copy_until_if(InputIterator first, InputIterator last,
OutputIterator result, Predicate pred)
{
for ( ; first != last; ++first) {
if (pred(*first)) {
break;
}
*result++ = *first;
}
return first;
}
template<typename InputIterator, typename OutputIterator,
typename EqualityComparable>
OutputIterator
split_value(InputIterator first, InputIterator last,
OutputIterator result, const EqualityComparable &value)
{
typedef std::basic_string<
typename std::iterator_traits<InputIterator>::value_type> value_string;
while (first != last) {
value_string line;
first = copy_until(first, last, back_inserter(line), value);
*result++ = line;
if (first == last) {
break;
}
++first; // skip split-value
}
return result;
}
template<typename ForwardIterator1, typename OutputIterator,
typename ForwardIterator2>
OutputIterator
split_sequence(ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
OutputIterator result)
{
typedef std::basic_string<
typename std::iterator_traits<ForwardIterator1>::value_type> value_string;
while (first1 != last1) {
value_string line;
ForwardIterator1 next = std::search(first1, last1, first2, last2);
std::copy(first1, next, back_inserter(line));
first1 = next;
*result++ = line;
if (first1 == last1) {
break;
}
ForwardIterator2 adv = first2;
// skip the split sequence
while (adv != last2) {
++adv;
++first1;
}
}
return result;
}
template<typename Container, typename EqualityComparable>
inline
bool
contains(const Container &container, const EqualityComparable &value)
{
typename Container::const_iterator last = container.end();
return last != find(container.begin(), last, value);
}
// template<typename AssocContainer, typename EqualityComparable>
// bool
// contains_key(const AssocContainer &container,
// const EqualityComparable &value) {
// using namespace std;
// typedef typename AssocContainer::value_type value_t;
// typename AssocContainer::const_iterator last = container.end();
// return last != find_if(container.begin(), last,
// compose1(bind2nd(equal_to<value_t>(), value),
// select1st<value_t>()));
// }
//
// template<typename AssocContainer,
// typename EqualityComparable>
// bool
// contains_value(const AssocContainer &container,
// const EqualityComparable &value) {
// using namespace std;
// typedef typename AssocContainer::value_type value_t;
// typename AssocContainer::const_iterator last = container.end();
// return last != find_if(container.begin(), last,
// compose1(bind2nd(equal_to<value_t>(), value),
// select2nd<value_t>()));
// }
template<typename EqualityComparable>
struct sequence_contains {
explicit sequence_contains(const EqualityComparable &value)
: value_(value) {}
template<typename Container>
bool operator()(Container &container)
{
return contains(container, value_);
}
EqualityComparable value_;
};
template<typename Container>
class wctomb_insert_iterator
{
protected:
mbstate_t ps_;
Container *container_;
public:
typedef Container container_type;
typedef output_iterator_tag iterator_category;
typedef void value_type;
typedef void difference_type;
typedef void pointer;
typedef void reference;
explicit wctomb_insert_iterator(Container& c)
: ps_(), container_(&c)
{
/* mbsinit(&ps_); */
}
wctomb_insert_iterator<Container>&
operator=(const typename Container::value_type& value)
{
using namespace std;
string::value_type conv_buf[MB_LEN_MAX];
size_t n = ::wcrtomb(conv_buf, value, &ps_);
if (n == (size_t)-1) {
throw runtime_error("Can't convert wide character");
}
copy(conv_buf, conv_buf + n, back_inserter(*container_));
return *this;
}
wctomb_insert_iterator<Container>& operator*()
{
return *this;
}
wctomb_insert_iterator<Container>& operator++()
{
return *this;
}
wctomb_insert_iterator<Container>& operator++(int)
{
return *this;
}
};
template<typename Container>
inline
wctomb_insert_iterator<Container>
wctomb_inserter(Container &c)
{
return wctomb_insert_iterator<Container>(c);
}
class mbtowc_iterator
{
protected:
string::iterator i_;
public:
typedef input_iterator_tag iterator_category;
typedef std::wstring::value_type value_type;
typedef std::wstring::difference_type difference_type;
typedef std::wstring::pointer pointer;
typedef std::wstring::reference reference;
explicit mbtowc_iterator() {}
};
inline
std::string
to_string(const std::wstring &s)
{
using namespace std;
string buffer;
copy(s.begin(), s.end(), wctomb_inserter(buffer));
return buffer;
}
template<typename CharT, typename Predicate>
inline basic_string<CharT>
strip(const basic_string<CharT> &input, Predicate pred)
{
typedef typename basic_string<CharT>::const_reverse_iterator
reverse_iterator;
if (input.empty()) {
return basic_string<CharT>();
}
typename basic_string<CharT>::const_iterator p1
= find_if(input.begin(), input.end(), not1(pred));
typename basic_string<CharT>::const_iterator p2
= (find_if(input.rbegin(), reverse_iterator(p1), not1(pred))).base();
return basic_string<CharT>(p1, p2);
}
template<typename RandomAccessIterator, typename Predicate>
inline basic_string<
typename iterator_traits<RandomAccessIterator>::value_type>
strip(RandomAccessIterator first, RandomAccessIterator last, Predicate pred)
{
typedef typename iterator_traits<RandomAccessIterator>::value_type char_t;
typedef reverse_iterator<RandomAccessIterator> riterator;
if (first == last) {
return basic_string<char_t>();
}
RandomAccessIterator p1 = find_if(first, last, not1(pred));
RandomAccessIterator p2
= (find_if(riterator(last), riterator(p1), not1(pred))).base();
return basic_string<char_t>(p1, p2);
}
inline
std::wstring
to_wstring(const std::string &s)
{
using namespace std;
// calculate the exact size
const string::value_type *base = s.c_str();
mbstate_t ps;
::memset(&ps, 0, sizeof ps);
size_t n = ::mbsrtowcs(0, &base, 0, &ps) + 1;
if (n == (size_t)-1) {
throw runtime_error("Invalid multi-byte sequence");
}
// allocate the string buffer for that size
vector<wstring::value_type> buffer(n);
// convert to multi-byte
::mbsrtowcs(&(*buffer.begin()), &base, n, &ps);
return wstring(buffer.begin(), buffer.end() - 1);
}
struct wstring_to_string
: public std::unary_function<std::string, const std::wstring&> {
std::string operator()(const std::wstring &s)
{
return to_string(s);
}
};
template<typename Container>
void
reset(Container &c)
{
Container t;
std::swap(c, t);
}
inline
long int long_of_string(const string &s)
{
char *end;
long int result = strtol(s.c_str(), &end, 10);
if (end == 0) {
throw domain_error("Invalid integer representation");
}
return result;
}
template<typename T>
struct token_traits {
typedef typename T::symbol_type symbol_type;
typedef typename T::value_type value_type;
};
//////////////////////////////////////////////////////////////////////////////
//
// Recursive Descent Parser Using Pushback Token Generator
//
template<typename TokenGenerator>
class base_parser
{
public:
typedef typename TokenGenerator::token_type token_type;
typedef TokenGenerator token_gen;
typedef typename token_traits<token_type>::symbol_type symbol_type;
typedef typename token_traits<token_type>::value_type value_type;
public:
base_parser(token_gen gen)
: input_gen(gen) {}
protected:
void expect(symbol_type input)
{
if (!accept(input)) {
throw std::runtime_error("Error parsing");
}
}
bool accept(symbol_type input)
{
if (current_token.id == input) {
token_stack.push_back(current_token);
current_token = input_gen();
return true;
}
return false;
}
void push_back(size_t count=1)
{
while (count--) {
input_gen.push_back(token_stack.back());
token_stack.pop_back();
}
}
void pop(size_t count=1)
{
while (count--) {
token_stack.pop_back();
}
}
public:
token_gen input_gen;
token_type current_token;
std::vector<token_type> token_stack;
};
template<typename StringType>
class line_iterator
{
public:
typedef typename StringType::const_iterator string_iter;
typedef typename StringType::value_type value_type;
typedef std::pair<string_iter, string_iter> T;
public:
line_iterator()
: _stop_sequence(StringType("\n"))
, _valid(false)
, _end()
, _cur()
, _stride()
{
}
line_iterator(const StringType& str, const char *stop_sequence="\n")
: _stop_sequence(StringType(stop_sequence))
, _valid(true)
, _end(str.end())
, _cur(str.begin())
, _stride(T(str.begin(), str.begin()))
{
_next();
}
line_iterator(const line_iterator & rh)
: _stride(rh._stride)
{
}
line_iterator& operator=(const line_iterator & rh)
{
_valid = rh._valid;
_cur = rh._cur;
_end = rh._end;
_stride = rh._stride;
return *this;
}
bool operator==(const line_iterator & rh)
{
if (_valid && rh._valid) {
return (_stride.first == rh._stride.first &&
_stride.second == rh._stride.second);
} else if (!_valid && !rh._valid) {
// end of stream
return true;
} else {
return false;
}
}
bool operator!=(const line_iterator & rh)
{
return !(*this == rh);
}
T& operator*()
{
return _stride;
}
T* operator->()
{
return &_stride;
}
line_iterator& operator++()
{
_next();
return *this;
}
line_iterator& operator++(int)
{
line_iterator tmp(*this);
_next();
return tmp;
}
bool depleted() const
{
return _stride.first == _stride.second;
}
private:
void _next()
{
string_iter s1 = _stop_sequence.begin();
string_iter s2 = _stop_sequence.end();
string_iter pos = std::search(_cur, _end, s1, s2);
if (pos != _end) {
pos += _stop_sequence.size();
}
_stride.first = _cur;
_stride.second = pos;
_cur = pos;
if (_stride.first == _stride.second) {
*this = line_iterator();
}
}
public:
StringType _stop_sequence;
bool _valid;
string_iter _end;
string_iter _cur;
T _stride;
};
} // namespace util
#endif
// vim: set sts=2 sw=2 expandtab:
|
2a92753ca75370e126ca89546dee30df46e1a117
|
d661c959dd65f711e06aeb3609ceb3f2eb636e34
|
/DB.cpp
|
2b97c0bcb7def7a99ce01a57d579dca2e4c3ac61
|
[] |
no_license
|
Erax33/pc1tprog
|
2e16ae99ad1eb763c2c673bdf8eddda7ae05b259
|
724eaba925464a45fb2666cb1041a51501caa569
|
refs/heads/main
| 2023-01-24T03:46:36.335062
| 2020-12-06T16:43:00
| 2020-12-06T16:43:00
| 319,080,807
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,408
|
cpp
|
DB.cpp
|
#include <stdio.h>
#include "options.h"
#include <stdlib.h>
#include <string.h>
void add(char* fname, char* lname, char* date, char* phone, char* tarif, struct s_dec** pnt)
{
struct s_dec* new_c;
struct s_dec* curr_c;
new_c = (struct s_dec*)malloc(sizeof(struct s_dec));
curr_c = (struct s_dec*)malloc(sizeof(struct s_dec));
strcpy_s(new_c->fname, length, fname);
strcpy_s(new_c->lname, length, lname);
strcpy_s(new_c->date, length, date);
strcpy_s(new_c->phone, length, phone);
strcpy_s(new_c->tarif, length, tarif);
new_c->next = NULL;
if (*pnt == NULL)
{
*pnt = new_c;
return;
}
else if (strcmp(new_c->fname, (*pnt)->fname) < 0)
{
new_c->next = *pnt;
*pnt = new_c;
return;
}
new_c = *pnt;
while (curr_c)
{
if (curr_c->next == NULL)
{
curr_c->next = new_c;
return;
}
else if (strcmp(new_c->fname, curr_c->next->fname) < 0)
{
new_c->next = curr_c->next;
curr_c->next = new_c;
return;
}
curr_c = curr_c->next;
}
}
void rem(char* date, struct s_dec** pnt)
{
struct s_dec* curr_c;
while (*pnt && strcmp((*pnt)->date, date) == 0)
{
struct s_dec* first_fix = (*pnt)->next;
free(*pnt);
*pnt = first_fix;
}
curr_c = *pnt;
while (curr_c && curr_c->next)
{
if (strcmp(curr_c->next->date, date) == 0)
{
struct s_dec* next_fix = curr_c->next->next;
free(curr_c->next);
curr_c->next = next_fix;
}
curr_c = curr_c->next;
}
}
|
f97bde0418ba72a38c9bc562f8af278b6cbd8e83
|
a95ef80bf3cb6d253044d18a3d1ad671e0ed0ece
|
/src/besteng/core.cpp
|
2fdc8561eecfb137777dd34c6083214deace2b95
|
[] |
no_license
|
DanUdal/besteng
|
8a00380ee30e02a7b6ccc3f6bd323b3b7fb04927
|
8b66cda721959a652aa06119deffc9d47ad3a85a
|
refs/heads/main
| 2023-02-13T05:54:30.594579
| 2021-01-15T08:18:45
| 2021-01-15T08:18:45
| 329,594,138
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,198
|
cpp
|
core.cpp
|
#include "core.h"
namespace besteng
{
std::shared_ptr<Core> Core::initialise()
{
std::shared_ptr<Core> rtn = std::shared_ptr<Core>(); //creates the shared pointer for the function to return
rtn->self = rtn;
rtn->window = SDL_CreateWindow("besteng", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 800, 600,
SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE); //creates the window to render everything to
if (!rtn->window)
{
throw rend::Exception("Failed to create window"); //error handling
}
rtn->glContext = SDL_GL_CreateContext(rtn->window); //creates context for the window
if (!rtn->glContext)
{
throw rend::Exception("Failed to create OpenGL context");
}
rtn->context = rend::Context::initialize(); //initialises the rend context
std::shared_ptr<Entity> camera = rtn->addEntity("main camera"); //adds the main camera to the scene as an entity
rtn->currentScreen = camera;
camera->addComponent<Screen>();
camera->getComponent<Screen>()->core = rtn->self;
camera->getComponent<Screen>()->windowWidth = 800;
camera->getComponent<Screen>()->windowHeight = 600;
camera->getComponent<Screen>()->fov = 45.0f;
camera->getComponent<Screen>()->near = 1.0f;
camera->getComponent<Screen>()->far = 1000.0f; //initialises the main camera's variables
rtn->environment = std::make_shared<Environment>();
rtn->environment->core = rtn->self;
rtn->environment->self = rtn->environment; //initialises the environment
rtn->Input = std::make_shared<InputManager>(); //initialises the input manager
return rtn;
}
std::shared_ptr<Entity> Core::addEntity(std::string name) //adds an entity at the default position with the name passed in
{
std::shared_ptr<Entity> rtn = std::make_shared<Entity>();
entities.push_back(rtn);
rtn->self = rtn;
rtn->core = self;
rtn->name = name;
std::shared_ptr<Transform> transform = rtn->addComponent<Transform>(); //all entities must have a transform component
transform->position = glm::vec3(0, 0, 0);
transform->rotation = glm::vec3(0, 0, 0);
transform->scale = glm::vec3(1, 1, 1);
std::shared_ptr<Renderer> renderer = Renderer::initialise();
rtn->addComponent(renderer); //adds a renderer component by default
return rtn;
}
std::shared_ptr<Entity> Core::addEntity(std::string name, std::shared_ptr<Transform> position) //adds an entity with the transform given
{
std::shared_ptr<Entity> rtn = std::make_shared<Entity>();
entities.push_back(rtn);
rtn->self = rtn;
rtn->core = self;
rtn->name = name;
rtn->addComponent<Transform>(position);
std::shared_ptr<Renderer> renderer = Renderer::initialise();
rtn->addComponent(renderer); //adds a renderer component by default
return rtn;
}
void Core::start() //runs the main game loop
{
SDL_Event events = { 0 }; //gets all events from the input
bool running = true; //variable tracks if the game has ended
while (running)
{
Input->checkInput(); //adds any inputs to the input manager
if (Input->quit)
{
running = false; //if SDL_QUIT happens end the game loop
}
for (size_t ei = 0; ei < entities.size(); ei++)
{
entities.at(ei)->tick(); //calls the tick for all entity components
}
glClearColor(0.39f, 0.58f, 0.93f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //sets a default background colour
for (size_t ei = 0; ei < entities.size(); ei++)
{
entities.at(ei)->render(); //renders all components for the entities
}
SDL_GL_SwapWindow(window); //finishes the render and displays to screen
Input->clear(); //clears all single frame inputs
environment->updateDeltaTime();
environment->frameCap(); //updates deltaT and caps the frames to 60 fps
}
}
std::shared_ptr<Entity> Core::findEntity(std::string name)
{
for (auto it = entities.begin(); it < entities.end(); it++)
{
if ((*it)->name == name) //checks the name against every entity until the target is found
{
return (*it);
}
}
throw rend::Exception("Entity of that name not found");
}
Core & Core::operator=(const Core &)
{
}
bool sameDirection(glm::vec3 direction, glm::vec3 aOrigin)
{
return glm::dot(direction, aOrigin) > 0; //returns true if the direction given is in the direction of the origin. it is 0 or below if the angle is > 90 degrees
}
bool line(std::shared_ptr<Simplex> simplex, glm::vec3& direction)
{
glm::vec3 a = simplex->operator[](0); //gets the first 2 points from the simplex in order to create a line for the 1D test
glm::vec3 b = simplex->operator[](1);
glm::vec3 ab = b - a; //this creates the vector acting as the line
glm::vec3 aOrigin = -a; //-a is a vector from a to the origin
if (sameDirection(ab, aOrigin)) //if ab is pointing towards the origin
{
direction = glm::cross(ab, glm::cross(aOrigin, ab));
} //this generates the next direction to look in by creating a vector perpendicular to ab on the same plane as ab and -a
else
{
simplex->operator=({a}); //if ab is not pointing towards the origin remove b from the simplex and set the direction to be towards the origin from a
direction = aOrigin;
}
return false;
}
bool triangle(std::shared_ptr<Simplex> simplex, glm::vec3& direction)
{
glm::vec3 a = simplex->operator[](0);
glm::vec3 b = simplex->operator[](1);
glm::vec3 c = simplex->operator[](2); //gets the 3 vertices of the triangle from the simplex for the 2D test
glm::vec3 ab = b - a;
glm::vec3 ac = c - a;
glm::vec3 aOrigin = -a; //generates 3 lines from a pointing towards b, c and the origin
glm::vec3 abc = glm::cross(ab, ac); //creates a vector perpendicular to the plane creates by ab and ac
if (sameDirection(glm::cross(abc, ac), aOrigin)) //if the vector perpendicular to the plane abc, ac which is a vector going straight up vertically is towards the origin
{
if (sameDirection(ac, aOrigin)) //if ac is in the direction of the origin
{
simplex->operator=({a, c}); //create a line between a and c
direction = glm::cross(ac, glm::cross(aOrigin, ac)); //set the direction to be perpendicular to ac and the vector straight up from the plane it creates
}
else
{
return line(simplex->operator=({a, b}), direction); //recalculate the 1D test with a and b with the same direction used on the triangle
}
}
else
{
if (sameDirection(glm::cross(ab, abc), aOrigin)) //if the vector created on the place abc, ab is in the direction of the origin
{
return line(simplex->operator=({a, b}), direction); //recalculates the 1D test with a and b
}
else
{
if (sameDirection(abc, aOrigin))
{
direction = abc; //if abc is towards the origin then set the direction equal to abc
}
else
{
simplex->operator=({a, c, b}); //give the simplex the vertices for the triangle
direction = -abc; //if the direction is away from the origin set the direction to -abc to make it towards
}
}
}
return false;
}
bool tetrahedron(std::shared_ptr<Simplex> simplex, glm::vec3& direction)
{
glm::vec3 a = simplex->operator[](0);
glm::vec3 b = simplex->operator[](1);
glm::vec3 c = simplex->operator[](2);
glm::vec3 d = simplex->operator[](3); //gets the 4 vertices for the tetrahedron from the simplex for the 3D test
glm::vec3 ab = b - a;
glm::vec3 ac = c - a;
glm::vec3 ad = d - a;
glm::vec3 aOrigin = -a; //creates a vector for each of the shape's sides and one towards the origin from a
glm::vec3 abc = glm::cross(ab, ac);
glm::vec3 acd = glm::cross(ad, ac);
glm::vec3 abd = glm::cross(ab, ad); //creates a vector perpendicular to each side of the tetrahedron for testing against the origin line
if (sameDirection(abc, aOrigin))
{
return triangle(simplex->operator=({a, b, c}), direction);
}
if (sameDirection(acd, aOrigin))
{
return triangle(simplex->operator=({a, c, d}), direction);
}
if (sameDirection(abd, aOrigin))
{ //if any of the cross vectors are in the direction of the origin then the simplex does not contain the origin and a collision hasn't been detected
return triangle(simplex->operator=({a, d, b}), direction);
}
return true;
}
bool nextSimplex(std::shared_ptr<Simplex> simplex, glm::vec3& direction)
{
switch (simplex->getSize()) //calls the function required based on the size of the simplex given
{
case 2: return line(simplex, direction);
case 3: return triangle(simplex, direction);
case 4: return tetrahedron(simplex, direction);
}
}
bool Core::GJK(std::shared_ptr<Collider> ObjectA, std::shared_ptr<Collider> ObjectB)
{
glm::vec3 support = ObjectA->findFurthestPoint(glm::vec3(1,0,0))
- ObjectB->findFurthestPoint(glm::vec3(-1,0,0));
//calculates the furthest distance between points inside each shape along an arbitrary line to get the first support function
std::shared_ptr<Simplex> points; //creates an empty simplex
points->self = points;
points->pushFront(support); //initialises simplex with one point
glm::vec3 direction = -support;
while (true)
{
support = ObjectA->findFurthestPoint(direction)
- ObjectB->findFurthestPoint(-direction); //creates a new support function along the new direction created
if (glm::dot(support, direction) <= 0)
{
return false; //if the support and direction are perpendicular to each other then there is no collision
}
points->pushFront(support); //adds the support point to the simplex
if (nextSimplex(points, direction))
{
return true; //if this function calls the tetrahedron and that returns true then a collision has been found
}
}
return false; //must return along all possible lines
}
void Core::collisionTest()
{
for (auto it1 = entities.begin(); it1 < entities.end(); it1++)
{
for (auto it2 = entities.begin(); it2 < entities.end(); it2++) //iterate through each entity and check it for collision with each other entity
{
if ((*it1) != (*it2)) //if the objects being checked are not the same object
{
std::shared_ptr<Collider> col1 = (*it1)->getComponent<Collider>();
std::shared_ptr<Collider> col2 = (*it2)->getComponent<Collider>(); //get the colliders for each object
if (col1 && col2) //if both objects have a collider attached
{
bool collision; //collision test variable
glm::vec3 pos1 = (*it1)->getComponent<Transform>()->position;
glm::vec3 pos2 = (*it2)->getComponent<Transform>()->position; //gets the postion of te objects for the broad test
if (glm::distance(pos1, pos2) <= (col1->maxDis + col2->maxDis)) //if the spheres around the objects don't collide don't test further
{ //done for effieicnecy
if ((col1->mesh) || (col2->mesh))
{
collision = GJK(col1, col2); //if either object has a mesh then do GJK
}
else
{
collision = true; //if both objects are a sphere then the collision has already been tested
}
}
else
{
collision = false;
}
if (collision)
{
(*it1)->collision(col2);
(*it2)->collision(col1); //calls the collision function for both objects
}
}
}
}
}
}
}
|
b047698fcd69b312e01efd20c3d83e39541aa663
|
c9518f034ee56db7a0c97fc881c4e31712e912a9
|
/Paint/WarningCmd.cpp
|
ea82a195b9529ea0c89cfc8bc1d0cb5c105ac921
|
[
"BSD-3-Clause",
"BSD-2-Clause-Views"
] |
permissive
|
linhongyi/Paint
|
0994156cfdc1a599e30bbfa2f3e0dbdc001bb69f
|
65c9e6f8a4cec6dca12ddfec760460b34d0b1608
|
refs/heads/master
| 2021-01-16T00:27:49.371830
| 2013-02-08T02:06:15
| 2013-02-08T02:06:15
| null | 0
| 0
| null | null | null | null |
BIG5
|
C++
| false
| false
| 405
|
cpp
|
WarningCmd.cpp
|
#include "StdAfx.h"
#include "WarningCmd.h"
WarningCmd::WarningCmd(void)
{
}
WarningCmd::~WarningCmd(void)
{
}
void WarningCmd::Execute(RecordObj *recordObj)
{
::MessageBox( gPaintInfo.GetMainHwnd(), _T(" 無此命令物件 Execute \n"),NULL,NULL);
}
void WarningCmd::UnExecute(RecordObj *recordObj)
{
::MessageBox( gPaintInfo.GetMainHwnd(), _T(" 無此命令物件 UnExecute \n"),NULL,NULL);
}
|
9799042f6dd5fb4aba9db61e2afcbf6734f0bff0
|
fd911fe124408f4f6e300b084b6f1d30f5da30ba
|
/libs/hwdrivers/include/mrpt/hwdrivers/TCaptureOptions_bumblebee.h
|
f568627ed79a7de4810c799eda251852616b750f
|
[
"BSD-3-Clause"
] |
permissive
|
tg1716/SLAM
|
5710024e34f83687c6524cfb947479951d67941e
|
b8583fb98a4241d87ae08ac78b0420c154f5e1a5
|
refs/heads/master
| 2021-01-02T09:11:41.110755
| 2017-07-30T16:04:31
| 2017-07-30T16:04:31
| 99,160,224
| 5
| 2
| null | 2017-08-02T21:13:21
| 2017-08-02T20:57:07
| null |
UTF-8
|
C++
| false
| false
| 1,371
|
h
|
TCaptureOptions_bumblebee.h
|
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
| See: http://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See details in http://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#pragma once
#include <mrpt/hwdrivers/link_pragmas.h>
namespace mrpt
{
namespace hwdrivers
{
/** Options used when creating a bumblebee camera capture object
* \sa CStereoGrabber_Bumblebee, CStereoGrabber_Bumblebee_dc1394
* \ingroup mrpt_hwdrivers_grp
*/
struct HWDRIVERS_IMPEXP TCaptureOptions_bumblebee
{
TCaptureOptions_bumblebee();
/** Capture resolution (Default: 640x480) */
int frame_width, frame_height;
/** Indicates if the Bumblebee camera must capture color images (Default:
* false -> grayscale) */
bool color;
/** Indicates if the Bumblebee camera must capture rectified images
* (Default: true -> rectified) */
bool getRectified;
/** Bumblebee camera frame rate (Default: 15 fps) */
double framerate;
};
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.